@netlify/agent-runner-cli 1.150.0-ex-2643.1 → 1.150.0-ex-2643.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin-local.js +2 -2
- package/dist/bin.js +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/bin-local.js
CHANGED
|
@@ -99,7 +99,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
99
99
|
`,LF:`
|
|
100
100
|
`,concatBytes:vL},ZDe=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},JDe={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:ZDe};import{Buffer as XDe}from"buffer";var Mte=(t,e)=>t?void 0:QDe.bind(void 0,e),QDe=function*(t,e){if(typeof e!="string"&&!jt(e)&&!XDe.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},Dte=(t,e)=>t?eLe.bind(void 0,e):tLe.bind(void 0,e),eLe=function*(t,e){Lte(t,e),yield e},tLe=function*(t,e){if(Lte(t,e),typeof e!="string"&&!jt(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},Lte=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
101
101
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
102
|
-
if (condition) { yield value; }`)};import{Buffer as rLe}from"buffer";import{StringDecoder as nLe}from"string_decoder";var sx=(t,e,r)=>{if(r)return;if(t)return{transform:iLe.bind(void 0,new TextEncoder)};let n=new nLe(e);return{transform:oLe.bind(void 0,n),final:sLe.bind(void 0,n)}},iLe=function*(t,e){rLe.isBuffer(e)?yield ps(e):typeof e=="string"?yield t.encode(e):yield e},oLe=function*(t,e){yield jt(e)?t.write(e):e},sLe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as $te}from"util";var TL=$te(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),ax=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=cLe}=e[r];for await(let i of n(t))yield*ax(i,e,r+1)},Ute=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*aLe(r,Number(e),t)},aLe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*ax(n,r,e+1)},Fte=$te(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),cLe=function*(t){yield t};var AL=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Bte=(t,e)=>[...e.flatMap(r=>[...wl(r,t,0)]),...x_(t)],wl=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=uLe}=e[r];for(let i of n(t))yield*wl(i,e,r+1)},x_=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*lLe(r,Number(e),t)},lLe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*wl(n,r,e+1)},uLe=function*(t){yield t};var xL=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=zte(t,s,o),l=xl(e),u=xl(r),d=l?TL.bind(void 0,ax,a):AL.bind(void 0,wl),f=l||u?TL.bind(void 0,Ute,a):AL.bind(void 0,x_),p=l||u?Fte.bind(void 0,a):void 0;return{stream:new dLe({writableObjectMode:n,writableHighWaterMark:jte(n),readableObjectMode:i,readableHighWaterMark:jte(i),transform(m,v,b){d([m,c,0],this,b)},flush(m){f([c],this,m)},destroy:p})}},cx=(t,e,r,n)=>{let i=e.filter(({type:s})=>s==="generator"),o=n?i.reverse():i;for(let{value:s,optionName:a}of o){let c=zte(s,r,a);t=Bte(c,t)}return t},zte=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Mte(n,a)},sx(r,s,n),ox(r,o,n,c),{transform:t,final:e},{transform:Dte(i,a)},kte({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Gte=(t,e)=>{for(let r of fLe(t))pLe(t,r,e)},fLe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),pLe=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Pa[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>hLe(a,n));r.input=m_(s)},hLe=(t,e)=>{let r=cx(t,e,"utf8",!0);return mLe(r),m_(r)},mLe=t=>{let e=t.find(r=>typeof r!="string"&&!jt(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 SLe,appendFileSync as ELe}from"fs";var lx=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&rf(r,n)&&!_n.has(e)&&gLe(n)&&(t.some(({type:i,value:o})=>i==="native"&&_Le.has(o))||t.every(({type:i})=>Yn.has(i))),gLe=t=>t===1||t===2,_Le=new Set(["pipe","overlapped"]),Vte=async(t,e,r,n)=>{for await(let i of t)yLe(e)||Hte(i,r,n)},qte=(t,e,r)=>{for(let n of t)Hte(n,e,r)},yLe=t=>t._readableState.pipes.length>0,Hte=(t,e,r)=>{let n=TA(t);uo({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Wte=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,l)=>vLe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},vLe=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=Yee(t,o,d),p=ps(f),{stdioItems:h,objectMode:m}=e[r],v=bLe([p],h,c,n),{serializedResult:b,finalResult:E=b}=TLe({chunks:v,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});ALe({serializedResult:b,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let A=a[r]?E:void 0;try{return n.error===void 0&&xLe(b,h,i),A}catch(_){return n.error=_,A}},bLe=(t,e,r,n)=>{try{return cx(t,e,r,!1)}catch(i){return n.error=i,t}},TLe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:m_(t)};let s=cQ(t,r);return n[o]?{serializedResult:s,finalResult:bL(s,!i[o],e)}:{serializedResult:s}},ALe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!lx({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=bL(t,!1,s);try{qte(a,e,n)}catch(c){r.error??=c}},xLe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>nx.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?ELe(n,t):(r.add(o),SLe(n,t))}};var Yte=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,gs(e,r,"all")]:Array.isArray(e)?[gs(t,r,"all"),...e]:jt(t)&&jt(e)?OD([t,e]):`${t}${e}`};import{once as wL}from"events";var Kte=async(t,e)=>{let[r,n]=await wLe(t);return e.isForcefullyTerminated??=!1,[r,n]},wLe=async t=>{let[e,r]=await Promise.allSettled([wL(t,"spawn"),wL(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Zte(t):r.value},Zte=async t=>{try{return await wL(t,"exit")}catch{return Zte(t)}},Jte=async t=>{let[e,r]=await t;if(!RLe(e,r)&&RL(e,r))throw new Ri;return[e,r]},RLe=(t,e)=>t===void 0&&e===void 0,RL=(t,e)=>t!==0||e!==null;var Xte=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=ILe(t,e,r),s=o?.code==="ETIMEDOUT",a=Wee(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},ILe=(t,e,r)=>t!==void 0?t:RL(e,r)?new Ri:void 0;var Qte=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=PLe(t,e,r),d=kLe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return pf(d,c,l)},PLe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=xA(t,e,r),a=OLe(r),{file:c,commandArguments:l,options:u}=qA(t,e,a);NLe(u);let d=Cte(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},OLe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,NLe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&ux("ipcInput"),t&&ux("ipc: true"),r&&ux("detached: true"),n&&ux("cancelSignal")},ux=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},kLe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=MLe({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=Xte(c,r),{output:h,error:m=l}=Wte({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),v=h.map((E,A)=>gs(E,r,A)),b=gs(Yte(h,r),r,"all");return LLe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:v,all:b,options:r,command:n,escapedCommand:i,startTime:a})},MLe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Gte(o,r);let a=DLe(r);return CLe(...HA(t,e,a))}catch(a){return ff({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},DLe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:QA(e)}),LLe=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?ex({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):A_({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as T1e}from"events";import{spawn as A1e}from"child_process";import ire from"process";import{once as IL,on as $Le}from"events";var ere=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(sf({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:FA(t)}),ULe({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),ULe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{DA(e,i);let o=Ca(t,e,r),s=new AbortController;try{return await Promise.race([FLe(o,n,s),BLe(o,r,s),jLe(o,r,s)])}catch(a){throw af(t),a}finally{s.abort(),LA(e,i)}},FLe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await IL(t,"message",{signal:r});return n}for await(let[n]of $Le(t,"message",{signal:r}))if(e(n))return n},BLe=async(t,e,{signal:r})=>{await IL(t,"disconnect",{signal:r}),B7(e)},jLe=async(t,e,{signal:r})=>{let[n]=await IL(t,"strict:error",{signal:r});throw NA(n,e)};import{once as rre,on as zLe}from"events";var nre=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>CL({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),CL=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{sf({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:FA(t)}),DA(e,o);let s=Ca(t,e,r),a=new AbortController,c={};return GLe(t,s,a),VLe({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),qLe({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},GLe=async(t,e,r)=>{try{await rre(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},VLe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await rre(t,"strict:error",{signal:r.signal});n.error=NA(i,e),r.abort()}catch{}},qLe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of zLe(r,"message",{signal:o.signal}))tre(s),yield c}catch{tre(s)}finally{o.abort(),LA(e,a),n||af(t),i&&await t}},tre=({error:t})=>{if(t)throw t};var ore=(t,{ipc:e})=>{Object.assign(t,are(t,!1,e))},sre=()=>{let t=ire,e=!0,r=ire.channel!==void 0;return{...are(t,e,r),getCancelSignal:pee.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},are=(t,e,r)=>({sendMessage:GA.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:ere.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:nre.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as HLe}from"child_process";import{PassThrough as WLe,Readable as YLe,Writable as KLe,Duplex as ZLe}from"stream";var cre=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{SL(n);let a=new HLe;JLe(a,n),Object.assign(a,{readable:XLe,writable:QLe,duplex:e$e});let c=ff({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=t$e(c,s,i);return{subprocess:a,promise:l}},JLe=(t,e)=>{let r=w_(),n=w_(),i=w_(),o=Array.from({length:e.length-3},w_),s=w_(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},w_=()=>{let t=new WLe;return t.end(),t},XLe=()=>new YLe({read(){}}),QLe=()=>new KLe({write(){}}),e$e=()=>new ZLe({read(){},write(){}}),t$e=async(t,e,r)=>pf(t,e,r);import{createReadStream as lre,createWriteStream as ure}from"fs";import{Buffer as r$e}from"buffer";import{Readable as R_,Writable as n$e,Duplex as i$e}from"stream";var fre=(t,e)=>ix(o$e,t,e,!1),I_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Pa[t]}.`)},dre={fileNumber:I_,generator:xL,asyncGenerator:xL,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:i$e.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},o$e={input:{...dre,fileUrl:({value:t})=>({stream:lre(t)}),filePath:({value:{file:t}})=>({stream:lre(t)}),webStream:({value:t})=>({stream:R_.fromWeb(t)}),iterable:({value:t})=>({stream:R_.from(t)}),asyncIterable:({value:t})=>({stream:R_.from(t)}),string:({value:t})=>({stream:R_.from(t)}),uint8Array:({value:t})=>({stream:R_.from(r$e.from(t))})},output:{...dre,fileUrl:({value:t})=>({stream:ure(t)}),filePath:({value:{file:t,append:e}})=>({stream:ure(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:n$e.fromWeb(t)}),iterable:I_,asyncIterable:I_,string:I_,uint8Array:I_}};import{on as s$e,once as pre}from"events";import{PassThrough as a$e,getDefaultHighWaterMark as c$e}from"stream";import{finished as gre}from"stream/promises";function Rl(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)OL(i);let e=t.some(({readableObjectMode:i})=>i),r=l$e(t,e),n=new PL({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var l$e=(t,e)=>{if(t.length===0)return c$e(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},PL=class extends a$e{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(OL(e),this.#e.has(e))return;this.#e.add(e),this.#n??=u$e(this,this.#e,this.#o);let r=p$e({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#o});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(OL(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},u$e=async(t,e,r)=>{dx(t,hre);let n=new AbortController;try{await Promise.race([d$e(t,n),f$e(t,e,r,n)])}finally{n.abort(),dx(t,-hre)}},d$e=async(t,{signal:e})=>{try{await gre(t,{signal:e,cleanup:!0})}catch(r){throw _re(t,r),r}},f$e=async(t,e,r,{signal:n})=>{for await(let[i]of s$e(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},OL=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},p$e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{dx(t,mre);let a=new AbortController;try{await Promise.race([h$e(o,e,a),m$e({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),g$e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),dx(t,-mre)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?NL(t):_$e(t))},h$e=async(t,e,{signal:r})=>{try{await t,r.aborted||NL(e)}catch(n){r.aborted||_re(e,n)}},m$e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await gre(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;yre(s)?i.add(e):Sre(t,s)}},g$e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await pre(t,i,{signal:o}),!t.readable)return pre(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},_$e=t=>{t.writable&&t.end()},_re=(t,e)=>{yre(e)?NL(t):Sre(t,e)},yre=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",NL=t=>{(t.readable||t.writable)&&t.destroy()},Sre=(t,e)=>{t.destroyed||(t.once("error",y$e),t.destroy(e))},y$e=()=>{},dx=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},hre=2,mre=1;import{finished as Ere}from"stream/promises";var mf=(t,e)=>{t.pipe(e),S$e(t,e),E$e(t,e)},S$e=async(t,e)=>{if(!(wi(t)||wi(e))){try{await Ere(t,{cleanup:!0,readable:!0,writable:!1})}catch{}kL(e)}},kL=t=>{t.writable&&t.end()},E$e=async(t,e)=>{if(!(wi(t)||wi(e))){try{await Ere(e,{cleanup:!0,readable:!1,writable:!0})}catch{}ML(t)}},ML=t=>{t.readable&&t.destroy()};var vre=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:o,direction:s}]of Object.entries(e)){for(let{stream:a}of o.filter(({type:c})=>Yn.has(c)))v$e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Yn.has(c)))T$e({subprocess:t,stream:a,direction:s,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,o]of n.entries()){let s=o.length===1?o[0]:Rl(o);mf(s,i)}},v$e=(t,e,r,n)=>{r==="output"?mf(t.stdio[n],e):mf(e,t.stdio[n]);let i=b$e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},b$e=["stdin","stdout","stderr"],T$e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;A$e(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},A$e=(t,{signal:e})=>{wi(t)&&Tl(t,x$e,e)},x$e=2;import{addAbortListener as I$e}from"events";var Il=[];Il.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Il.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Il.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var fx=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",DL=Symbol.for("signal-exit emitter"),LL=globalThis,w$e=Object.defineProperty.bind(Object),$L=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(LL[DL])return LL[DL];w$e(LL,DL,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let o of this.listeners[e])i=o(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},px=class{},R$e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),UL=class extends px{onExit(){return()=>{}}load(){}unload(){}},FL=class extends px{#e=BL.platform==="win32"?"SIGINT":"SIGHUP";#r=new $L;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Il)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,o=e;if(typeof o.__signal_exit_emitter__=="object"&&typeof o.__signal_exit_emitter__.count=="number"&&(i+=o.__signal_exit_emitter__.count),n.length===i){this.unload();let s=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;s||e.kill(e.pid,a)}};this.#o=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!fx(this.#t))return()=>{};this.#s===!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.#s){this.#s=!0,this.#r.count+=1;for(let e of Il)try{let r=this.#i[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#s&&(this.#s=!1,Il.forEach(e=>{let r=this.#i[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#o,this.#r.count-=1)}#a(e){return fx(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#o.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&fx(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let i=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),i}else return n.call(this.#t,e,...r)}},BL=globalThis.process,{onExit:bre,load:Uyt,unload:Fyt}=R$e(fx(BL)?new FL(BL):new UL);var Tre=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=bre(()=>{t.kill()});I$e(n,()=>{i()})};var xre=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=AA(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=C$e(r,n,i),{sourceStream:d,sourceError:f}=O$e(t,l),{options:p,fileDescriptors:h}=po.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},C$e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=P$e(t,e,...r),a=MA(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},P$e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Are,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||CD(r)){if(Object.keys(t).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[i,o,s]=hA(r,...n);return{destination:e(Are)(i,o,s),pipeOptions:s}}if(po.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}`)},Are=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),O$e=(t,e)=>{try{return{sourceStream:cf(t,e)}}catch(r){return{sourceError:r}}};var Rre=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=N$e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw jL({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},N$e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return ML(t),n;if(e!==void 0)return kL(r),e},jL=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>ff({error:t,command:wre,escapedCommand:wre,fileDescriptors:e,options:r,startTime:n,isSync:!1}),wre="source.pipe(destination)";var Ire=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:o,value:s=o}]=await t;if(s.pipedFrom.includes(n)||s.pipedFrom.push(n),i==="rejected")throw s;if(e==="rejected")throw n;return s};import{finished as k$e}from"stream/promises";var Cre=(t,e,r)=>{let n=hx.has(e)?D$e(t,e):M$e(t,e);return Tl(t,$$e,r.signal),Tl(e,U$e,r.signal),L$e(e),n},M$e=(t,e)=>{let r=Rl([t]);return mf(r,e),hx.set(e,r),r},D$e=(t,e)=>{let r=hx.get(e);return r.add(t),r},L$e=async t=>{try{await k$e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}hx.delete(t)},hx=new WeakMap,$$e=2,U$e=1;import{aborted as F$e}from"util";var Pre=(t,e)=>t===void 0?[]:[B$e(t,e)],B$e=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await F$e(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw jL({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var mx=(t,...e)=>{if(Pt(e[0]))return mx.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=xre(t,...e),i=j$e({...n,destination:r});return i.pipe=mx.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},j$e=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=z$e(t,i);Rre({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Cre(e,o,d);return await Promise.race([Ire(u),...Pre(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},z$e=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as K$e}from"timers/promises";import{on as G$e}from"events";import{getDefaultHighWaterMark as V$e}from"stream";var gx=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return q$e(e,s),Nre({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},q$e=async(t,e)=>{try{await t}catch{}finally{e.abort()}},zL=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;H$e(e,s,t);let a=t.readableObjectMode&&!o;return Nre({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},H$e=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Nre=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=G$e(t,"data",{signal:e.signal,highWaterMark:Ore,highWatermark:Ore});return W$e({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},GL=V$e(!0),Ore=GL,W$e=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=Y$e({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*wl(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*x_(a)}},Y$e=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[sx(t,r,!e),ox(t,i,!n,{})].filter(Boolean);var kre=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=Z$e({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([J$e(t),d]);return}let f=EL(c,r),p=zL({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([X$e({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},Z$e=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!lx({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=zL({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Vte(a,t,r,o)},J$e=async t=>{await K$e(),t.readableFlowing===null&&t.resume()},X$e=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await ZA(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await JA(r,{maxBuffer:o})):await df(r,{maxBuffer:o})}catch(a){return Mre(Vee({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},VL=async t=>{try{return await t}catch(e){return Mre(e)}},Mre=({bufferedData:t})=>sQ(t)?new Uint8Array(t):t;import{finished as Q$e}from"stream/promises";var C_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=e1e(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],Q$e(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||n1e(a,e,r,n)}finally{s.abort()}},e1e=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&t1e(t,r,n),n},t1e=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{r1e(e,r),n.call(t,...i)}},r1e=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},n1e=(t,e,r,n)=>{if(!i1e(t,e,r,n))throw t},i1e=(t,e,r,n=!0)=>r.propagating?Dre(t)||_x(t):(r.propagating=!0,qL(r,e)===n?Dre(t):_x(t)),qL=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",_x=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Dre=t=>t?.code==="EPIPE";var Lre=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>HL({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),HL=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=C_(t,e,l);if(qL(l,e)){await u;return}let[d]=await Promise.all([kre({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var $re=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Rl([t,e].filter(Boolean)):void 0,Ure=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>HL({...o1e(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:s1e(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),o1e=({stdout:t,stderr:e,all:r},[,n,i])=>{let o=n||i;return o?n?i?{stream:r,buffer:o}:{stream:t,buffer:o}:{stream:e,buffer:o}:{stream:r,buffer:o}},s1e=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as a1e}from"events";var Fre=t=>rf(t,"ipc"),Bre=(t,e)=>{let r=TA(t);uo({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var jre=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=Fre(o),a=hs(e,"ipc"),c=hs(r,"ipc");for await(let l of CL({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(qee(t,i,c),i.push(l)),s&&Bre(l,o);return i},zre=async(t,e)=>(await Promise.allSettled([t]),e);var Gre=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:v,controller:b})=>{let E=Kte(t,f),A={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:E,propagating:!1},_=Lre({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:A}),R=Ure({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:A}),I=[],O=jre({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:I,verboseInfo:p}),C=c1e(m,t,A),P=l1e(h,A);try{return await Promise.race([Promise.all([{},Jte(E),Promise.all(_),R,O,Tee(t,d),...C,...P]),v,u1e(t,b),...yee(t,o,f,b),...F7({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:b}),...gee({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:b})])}catch($){return f.terminationReason??="other",Promise.all([{error:$},E,Promise.all(_.map(y=>VL(y))),VL(R),zre(O,I),Promise.allSettled(C),Promise.allSettled(P)])}},c1e=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:C_(n,i,r)),l1e=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Ci(o,{checkOpen:!1})&&!wi(o)).map(({type:i,value:o,stream:s=o})=>C_(s,n,e,{isSameDirection:Yn.has(i),stopOnExit:i==="native"}))),u1e=async(t,{signal:e})=>{let[r]=await a1e(t,"error",{signal:e});throw r};var Vre=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),P_=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=fo();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},gf=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 d1e}from"stream";import{callbackify as f1e}from"util";import{finished as qre}from"stream/promises";var WL=async t=>{if(t!==void 0)try{await YL(t)}catch{}},Hre=async t=>{if(t!==void 0)try{await KL(t)}catch{}},YL=async t=>{await qre(t,{cleanup:!0,readable:!1,writable:!0})},KL=async t=>{await qre(t,{cleanup:!0,readable:!0,writable:!1})},yx=async(t,e)=>{if(await t,e)throw e},Sx=(t,e,r)=>{r&&!_x(r)?t.destroy(r):e&&t.destroy()};var Wre=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||_n.has(r),{subprocessStdout:a,waitReadableDestroy:c}=ZL(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=JL(a,s),{read:f,onStdoutDataDone:p}=XL({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new d1e({read:f,destroy:f1e(e$.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return QL({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},ZL=(t,e,r)=>{let n=cf(t,e),i=P_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},JL=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:GL},XL=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=fo(),s=gx({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){p1e(this,s,o)},onStdoutDataDone:o}},p1e=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},QL=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await KL(t),await n,await WL(i),await e,r.readable&&r.push(null)}catch(o){await WL(i),Yre(r,o)}},e$=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await gf(r,e)&&(Yre(t,n),await yx(e,n))},Yre=(t,e)=>{Sx(t,t.readable,e)};import{Writable as h1e}from"stream";import{callbackify as Kre}from"util";var Zre=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=t$(t,r,e),s=new h1e({...r$(n,t,i),destroy:Kre(i$.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return n$(n,s),s},t$=(t,e,r)=>{let n=MA(t,e),i=P_(r,n,"writableFinal"),o=P_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},r$=(t,e,r)=>({write:m1e.bind(void 0,t),final:Kre(g1e.bind(void 0,t,e,r))}),m1e=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},g1e=async(t,e,r)=>{await gf(r,e)&&(t.writable&&t.end(),await e)},n$=async(t,e,r)=>{try{await YL(t),e.writable&&e.end()}catch(n){await Hre(r),Jre(e,n)}},i$=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await gf(r,e),await gf(n,e)&&(Jre(t,i),await yx(e,i))},Jre=(t,e)=>{Sx(t,t.writable,e)};import{Duplex as _1e}from"stream";import{callbackify as y1e}from"util";var Xre=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||_n.has(r),{subprocessStdout:c,waitReadableDestroy:l}=ZL(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=t$(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=JL(c,a),{read:v,onStdoutDataDone:b}=XL({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),E=new _1e({read:v,...r$(u,t,d),destroy:y1e(S1e.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return QL({subprocessStdout:c,onStdoutDataDone:b,readable:E,subprocess:t,subprocessStdin:u}),n$(u,E,c),E},S1e=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([e$({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),i$({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var o$=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||_n.has(e),s=cf(t,r),a=gx({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return E1e(a,s,t)},E1e=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Qre=(t,{encoding:e})=>{let r=Vre();t.readable=Wre.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Zre.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Xre.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=o$.bind(void 0,t,e),t[Symbol.asyncIterator]=o$.bind(void 0,t,e,{})};var ene=(t,e)=>{for(let[r,n]of b1e){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},v1e=(async()=>{})().constructor.prototype,b1e=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(v1e,t)]);var tne=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=x1e(t,e,r),{subprocess:f,promise:p}=R1e({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=mx.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),ene(f,p),po.set(f,{options:u,fileDescriptors:d}),f},x1e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=xA(t,e,r),{file:a,commandArguments:c,options:l}=qA(t,e,r),u=w1e(l),d=fre(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},w1e=({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}},R1e=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=A1e(...HA(t,e,r))}catch(h){return cre({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;T1e(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];vre(c,a,l),Tre(c,r,l);let d={},f=fo();c.kill=$7.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=$re(c,r),Qre(c,r),ore(c,r);let p=I1e({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:o,escapedCommand:s,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},I1e=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,v]=await Gre({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let b=h.map((_,R)=>gs(_,e,R)),E=gs(m,e,"all"),A=C1e({errorInfo:d,exitCode:f,signal:p,stdio:b,all:E,ipcOutput:v,context:c,options:e,command:s,escapedCommand:a,startTime:r});return pf(A,n,e)},C1e=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?A_({error:t.error,command:c,escapedCommand:l,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof ho,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):ex({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var Ex=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,P1e(n,t[n],i)]));return{...t,...r}},P1e=(t,e,r)=>O1e.has(t)&&Pt(e)&&Pt(r)?{...e,...r}:r,O1e=new Set(["env",...DD]);var Oa=(t,e,r,n)=>{let i=(s,a,c)=>Oa(s,a,r,c),o=(...s)=>N1e({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},N1e=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Pt(o))return i(t,Ex(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=k1e({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?Qte(a,c,l):tne(a,c,l,i)},k1e=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=fQ(e)?pQ(e,r):[e,...r],[s,a,c]=hA(...o),l=Ex(Ex(n,i),c),{file:u=s,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:s,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var rne=({file:t,commandArguments:e})=>ine(t,e),nne=({file:t,commandArguments:e})=>({...ine(t,e),isSync:!0}),ine=(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]=M1e(t);return{file:r,commandArguments:n}},M1e=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(D1e)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},D1e=/ +/g;var one=(t,e,r)=>{t.sync=e(L1e,r),t.s=t.sync},sne=({options:t})=>ane(t),L1e=({options:t})=>({...ane(t),isSync:!0}),ane=t=>({options:{...$1e(t),...t}}),$1e=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},cne={preferLocal:!0};var lne=Oa(()=>({})),Ivt=Oa(()=>({isSync:!0})),une=Oa(rne),Cvt=Oa(nne),Pvt=Oa(Eee),Ovt=Oa(sne,{},cne,one),{sendMessage:Nvt,getOneMessage:kvt,getEachMessage:Mvt,getCancelSignal:Dvt}=sre();var dne=!1,fne=()=>{dne=!0},go=()=>dne;var O_=null,pne=t=>(O_&&O_.destroy(),O_=new _s({totalAllowedTime:t}),O_),hne=()=>O_;var _s=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&go())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await aA({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{pe.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),o(),s&&clearTimeout(s)}};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 mne={name:"@netlify/agent-runner-cli",type:"module",version:"1.150.0-ex-2643.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.2","@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.219","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.1.5","@netlify/otel":"^6.0.4","@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",zod:"^4.4.3"}};var j1e=F1e(import.meta.url),z1e=ys.dirname(j1e),G1e=B1e(import.meta.url),_f=fe("shell"),s$=new Set,gne={preferLocal:!0},ur=(t,e,r)=>{let[n,i]=V1e(e,r),o={...gne,...i},s=lne(t,n,o);yne(s,o),vne(s);let a=r?.idleTimeout;return a&&a>0&&Ene(s,a),s},_ne=(t,e)=>{let r={...gne,...e},n=une(t,r);return yne(n,r),vne(n),e?.idleTimeout&&e.idleTimeout>0&&Ene(n,e.idleTimeout),n},V1e=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},yne=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(Ss.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new o_).pipe(Ss.stdout),t.stderr?.pipe(new o_).pipe(Ss.stderr);return}t.stdout?.pipe(Ss.stdout),t.stderr?.pipe(Ss.stderr)},a$=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Ss.kill(-t.pid,e),_f.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return _f.error("Error killing process:",r),!1}},Sne=t=>a$(t,"SIGKILL"),Ene=(t,e)=>{let r=null,n=()=>{_f.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),a$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(_f.log(`Force killing idle process ${t.pid}`),Sne(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let o=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",o),t.on("error",o)},vne=t=>{s$.add(t);let e=hne();if(e){let r=e.onTimesUp(()=>{_f.log(`Global timer expired, killing process ${t.pid}`),a$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(_f.log(`Force killing process ${t.pid} after timeout`),Sne(t))},5e3)});t.on("exit",()=>{s$.delete(t),r()}),t.on("error",()=>{s$.delete(t),r()})}};function bx(t,e){return!!Pi(t,e)}function Pi(t,e){if(!Ss.env.NETLIFY_LOCAL_MODE)try{let i=G1e.resolve(mne.name),o=ys.dirname(i);for(;o!==ys.dirname(o);){let s=ys.dirname(o);if(ys.basename(s)==="node_modules"){let a=ys.join(s,".bin",e);if(vx.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(Ss.env.NODE_PATH){let i=ys.join(Ss.env.NODE_PATH,".bin",e);if(vx.existsSync(i))return i}let r=ys.join(t,"node_modules",".bin",e);if(vx.existsSync(r))return r;let n=ys.join(z1e,"..","node_modules",".bin",e);if(vx.existsSync(n))return n}var q1e=fe("utils"),H1e=t=>new Promise(e=>{setTimeout(e,t)});var c$=t=>{try{return new URL(t).hostname||null}catch{return null}},Tx=(t,e=3e3)=>{let r=!1,n=null,i=[],o=null,s=(...a)=>{if(r)return n=a,new Promise(u=>{i.push(u)});r=!0;let c,l=new Promise(u=>{c=u});return o=(async()=>{await Promise.resolve();let u=await t(...a);for(c(u);;){if(await H1e(e),!n)return r=!1,o=null,u;let d=n,f=i;n=null,i=[],u=await t(...d),f.forEach(p=>{p(u)})}})(),l};return s.flush=async()=>{if((r||n)&&o)return await o,s.flush()},s.cancel=()=>{n=null,i.forEach(a=>a(void 0)),i=[]},s},Na=(t,e,r=!1)=>{let n=null,i=null,o=null,s=function(...a){i=a,o=this;let c=r&&!n;clearTimeout(n),n=setTimeout(()=>{n=null,r||(t.apply(o,i),i=null,o=null)},e),c&&(t.apply(o,i),i=null,o=null)};return s.cancel=()=>{clearTimeout(n),n=null,i=null,o=null},s.flush=()=>{if(n){clearTimeout(n);let a=i,c=o;n=null,i=null,o=null,t.apply(c,a)}},s},bne=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):q1e.error("Could not parse JSON",n))}},W1e=t=>t.charAt(0).toUpperCase()+t.slice(1),_o=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():W1e(e)).join(" ");function Es(t,e){e&&t.log(`Skill invoked: ${e}`)}var Ax=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),Tne=(t,e,r=!1)=>{if(r)return;let n=60,i=55,o=".netlify.app",s="agent-",a=6;if(!e)return`${s}${t.slice(0,a)}`;let c=`--${e}${o}`;if(c.length>i)return"";let l=n-c.length;if(l<=0)return"";if(l>=s.length+a){let u=Math.min(l-s.length,t.length);return`${s}${t.slice(0,u)}`}return t.slice(0,l)};var l$=t=>{let e=t.match(/<<-?\s*['"]?(\w+)['"]?/);if(!e)return{command:t};let r=t.indexOf(e[0]),n=t.slice(r+e[0].length).trim();return{command:t.slice(0,r).trim(),heredocContent:n||void 0}},Y1e=1e4,u$=(t,e=Y1e)=>{if(!t||typeof t!="string"||t.length<=e)return t;let n=t.startsWith("```")?"\n... [truncated]\n```":"... [truncated]";return t.slice(0,e)+n};import{Buffer as Ane}from"buffer";import K1e from"path";var xne=fe("repo"),Qr=(t,e={})=>ur("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),xx=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{xne.info("Getting runner diffs");let n=await J1e(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let m=Q1e(o);await eUe(m,r)}xne.info("Changes after processing"),await f$(r);let s=await p$(o,r);if(await d$(s,r),i=await X1e(r),!i)return{hasChanges:!1,ignored:s};await Qr(["commit","-m","Agent runner"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await Qr(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(i=!!l,!i)return await wne(r),{hasChanges:!1,ignored:s};let u=await Qr(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,p;if(t.sha){let m=await Qr(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let v=await Qr(["diff",t.sha,"HEAD","--binary"],a),b=String(v.stdout??"");f!==b&&(p=Ane.from(b).toString("base64"))}await wne(r);let h={hasChanges:!0,diff:l,resultDiff:f,ignored:s};return l!==d&&(h.diffBinary=Ane.from(d).toString("base64")),p&&(h.resultDiffBinary=p),h},wne=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Qr(["reset","--soft","HEAD~1"],{cwd:t})},d$=async(t=[],e=process.cwd())=>{await Qr(["add",".",...t],{cwd:e})},f$=async(t=process.cwd())=>{let e=await Qr(["status","-s"],{cwd:t});return String(e.stdout??"")},Rne=/.. (.+)?\.log$/,Z1e=[Rne],J1e=async(t=process.cwd())=>{let e=await f$(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
102
|
+
if (condition) { yield value; }`)};import{Buffer as rLe}from"buffer";import{StringDecoder as nLe}from"string_decoder";var sx=(t,e,r)=>{if(r)return;if(t)return{transform:iLe.bind(void 0,new TextEncoder)};let n=new nLe(e);return{transform:oLe.bind(void 0,n),final:sLe.bind(void 0,n)}},iLe=function*(t,e){rLe.isBuffer(e)?yield ps(e):typeof e=="string"?yield t.encode(e):yield e},oLe=function*(t,e){yield jt(e)?t.write(e):e},sLe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as $te}from"util";var TL=$te(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),ax=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=cLe}=e[r];for await(let i of n(t))yield*ax(i,e,r+1)},Ute=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*aLe(r,Number(e),t)},aLe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*ax(n,r,e+1)},Fte=$te(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),cLe=function*(t){yield t};var AL=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Bte=(t,e)=>[...e.flatMap(r=>[...wl(r,t,0)]),...x_(t)],wl=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=uLe}=e[r];for(let i of n(t))yield*wl(i,e,r+1)},x_=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*lLe(r,Number(e),t)},lLe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*wl(n,r,e+1)},uLe=function*(t){yield t};var xL=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=zte(t,s,o),l=xl(e),u=xl(r),d=l?TL.bind(void 0,ax,a):AL.bind(void 0,wl),f=l||u?TL.bind(void 0,Ute,a):AL.bind(void 0,x_),p=l||u?Fte.bind(void 0,a):void 0;return{stream:new dLe({writableObjectMode:n,writableHighWaterMark:jte(n),readableObjectMode:i,readableHighWaterMark:jte(i),transform(m,v,b){d([m,c,0],this,b)},flush(m){f([c],this,m)},destroy:p})}},cx=(t,e,r,n)=>{let i=e.filter(({type:s})=>s==="generator"),o=n?i.reverse():i;for(let{value:s,optionName:a}of o){let c=zte(s,r,a);t=Bte(c,t)}return t},zte=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Mte(n,a)},sx(r,s,n),ox(r,o,n,c),{transform:t,final:e},{transform:Dte(i,a)},kte({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Gte=(t,e)=>{for(let r of fLe(t))pLe(t,r,e)},fLe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),pLe=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Pa[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>hLe(a,n));r.input=m_(s)},hLe=(t,e)=>{let r=cx(t,e,"utf8",!0);return mLe(r),m_(r)},mLe=t=>{let e=t.find(r=>typeof r!="string"&&!jt(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 SLe,appendFileSync as ELe}from"fs";var lx=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&rf(r,n)&&!_n.has(e)&&gLe(n)&&(t.some(({type:i,value:o})=>i==="native"&&_Le.has(o))||t.every(({type:i})=>Yn.has(i))),gLe=t=>t===1||t===2,_Le=new Set(["pipe","overlapped"]),Vte=async(t,e,r,n)=>{for await(let i of t)yLe(e)||Hte(i,r,n)},qte=(t,e,r)=>{for(let n of t)Hte(n,e,r)},yLe=t=>t._readableState.pipes.length>0,Hte=(t,e,r)=>{let n=TA(t);uo({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Wte=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,l)=>vLe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},vLe=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=Yee(t,o,d),p=ps(f),{stdioItems:h,objectMode:m}=e[r],v=bLe([p],h,c,n),{serializedResult:b,finalResult:E=b}=TLe({chunks:v,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});ALe({serializedResult:b,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let A=a[r]?E:void 0;try{return n.error===void 0&&xLe(b,h,i),A}catch(_){return n.error=_,A}},bLe=(t,e,r,n)=>{try{return cx(t,e,r,!1)}catch(i){return n.error=i,t}},TLe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:m_(t)};let s=cQ(t,r);return n[o]?{serializedResult:s,finalResult:bL(s,!i[o],e)}:{serializedResult:s}},ALe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!lx({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=bL(t,!1,s);try{qte(a,e,n)}catch(c){r.error??=c}},xLe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>nx.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?ELe(n,t):(r.add(o),SLe(n,t))}};var Yte=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,gs(e,r,"all")]:Array.isArray(e)?[gs(t,r,"all"),...e]:jt(t)&&jt(e)?OD([t,e]):`${t}${e}`};import{once as wL}from"events";var Kte=async(t,e)=>{let[r,n]=await wLe(t);return e.isForcefullyTerminated??=!1,[r,n]},wLe=async t=>{let[e,r]=await Promise.allSettled([wL(t,"spawn"),wL(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Zte(t):r.value},Zte=async t=>{try{return await wL(t,"exit")}catch{return Zte(t)}},Jte=async t=>{let[e,r]=await t;if(!RLe(e,r)&&RL(e,r))throw new Ri;return[e,r]},RLe=(t,e)=>t===void 0&&e===void 0,RL=(t,e)=>t!==0||e!==null;var Xte=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=ILe(t,e,r),s=o?.code==="ETIMEDOUT",a=Wee(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},ILe=(t,e,r)=>t!==void 0?t:RL(e,r)?new Ri:void 0;var Qte=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=PLe(t,e,r),d=kLe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return pf(d,c,l)},PLe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=xA(t,e,r),a=OLe(r),{file:c,commandArguments:l,options:u}=qA(t,e,a);NLe(u);let d=Cte(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},OLe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,NLe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&ux("ipcInput"),t&&ux("ipc: true"),r&&ux("detached: true"),n&&ux("cancelSignal")},ux=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},kLe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=MLe({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=Xte(c,r),{output:h,error:m=l}=Wte({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),v=h.map((E,A)=>gs(E,r,A)),b=gs(Yte(h,r),r,"all");return LLe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:v,all:b,options:r,command:n,escapedCommand:i,startTime:a})},MLe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Gte(o,r);let a=DLe(r);return CLe(...HA(t,e,a))}catch(a){return ff({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},DLe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:QA(e)}),LLe=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?ex({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):A_({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as T1e}from"events";import{spawn as A1e}from"child_process";import ire from"process";import{once as IL,on as $Le}from"events";var ere=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(sf({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:FA(t)}),ULe({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),ULe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{DA(e,i);let o=Ca(t,e,r),s=new AbortController;try{return await Promise.race([FLe(o,n,s),BLe(o,r,s),jLe(o,r,s)])}catch(a){throw af(t),a}finally{s.abort(),LA(e,i)}},FLe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await IL(t,"message",{signal:r});return n}for await(let[n]of $Le(t,"message",{signal:r}))if(e(n))return n},BLe=async(t,e,{signal:r})=>{await IL(t,"disconnect",{signal:r}),B7(e)},jLe=async(t,e,{signal:r})=>{let[n]=await IL(t,"strict:error",{signal:r});throw NA(n,e)};import{once as rre,on as zLe}from"events";var nre=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>CL({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),CL=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{sf({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:FA(t)}),DA(e,o);let s=Ca(t,e,r),a=new AbortController,c={};return GLe(t,s,a),VLe({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),qLe({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},GLe=async(t,e,r)=>{try{await rre(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},VLe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await rre(t,"strict:error",{signal:r.signal});n.error=NA(i,e),r.abort()}catch{}},qLe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of zLe(r,"message",{signal:o.signal}))tre(s),yield c}catch{tre(s)}finally{o.abort(),LA(e,a),n||af(t),i&&await t}},tre=({error:t})=>{if(t)throw t};var ore=(t,{ipc:e})=>{Object.assign(t,are(t,!1,e))},sre=()=>{let t=ire,e=!0,r=ire.channel!==void 0;return{...are(t,e,r),getCancelSignal:pee.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},are=(t,e,r)=>({sendMessage:GA.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:ere.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:nre.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as HLe}from"child_process";import{PassThrough as WLe,Readable as YLe,Writable as KLe,Duplex as ZLe}from"stream";var cre=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{SL(n);let a=new HLe;JLe(a,n),Object.assign(a,{readable:XLe,writable:QLe,duplex:e$e});let c=ff({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=t$e(c,s,i);return{subprocess:a,promise:l}},JLe=(t,e)=>{let r=w_(),n=w_(),i=w_(),o=Array.from({length:e.length-3},w_),s=w_(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},w_=()=>{let t=new WLe;return t.end(),t},XLe=()=>new YLe({read(){}}),QLe=()=>new KLe({write(){}}),e$e=()=>new ZLe({read(){},write(){}}),t$e=async(t,e,r)=>pf(t,e,r);import{createReadStream as lre,createWriteStream as ure}from"fs";import{Buffer as r$e}from"buffer";import{Readable as R_,Writable as n$e,Duplex as i$e}from"stream";var fre=(t,e)=>ix(o$e,t,e,!1),I_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Pa[t]}.`)},dre={fileNumber:I_,generator:xL,asyncGenerator:xL,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:i$e.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},o$e={input:{...dre,fileUrl:({value:t})=>({stream:lre(t)}),filePath:({value:{file:t}})=>({stream:lre(t)}),webStream:({value:t})=>({stream:R_.fromWeb(t)}),iterable:({value:t})=>({stream:R_.from(t)}),asyncIterable:({value:t})=>({stream:R_.from(t)}),string:({value:t})=>({stream:R_.from(t)}),uint8Array:({value:t})=>({stream:R_.from(r$e.from(t))})},output:{...dre,fileUrl:({value:t})=>({stream:ure(t)}),filePath:({value:{file:t,append:e}})=>({stream:ure(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:n$e.fromWeb(t)}),iterable:I_,asyncIterable:I_,string:I_,uint8Array:I_}};import{on as s$e,once as pre}from"events";import{PassThrough as a$e,getDefaultHighWaterMark as c$e}from"stream";import{finished as gre}from"stream/promises";function Rl(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)OL(i);let e=t.some(({readableObjectMode:i})=>i),r=l$e(t,e),n=new PL({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var l$e=(t,e)=>{if(t.length===0)return c$e(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},PL=class extends a$e{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(OL(e),this.#e.has(e))return;this.#e.add(e),this.#n??=u$e(this,this.#e,this.#o);let r=p$e({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#o});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(OL(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},u$e=async(t,e,r)=>{dx(t,hre);let n=new AbortController;try{await Promise.race([d$e(t,n),f$e(t,e,r,n)])}finally{n.abort(),dx(t,-hre)}},d$e=async(t,{signal:e})=>{try{await gre(t,{signal:e,cleanup:!0})}catch(r){throw _re(t,r),r}},f$e=async(t,e,r,{signal:n})=>{for await(let[i]of s$e(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},OL=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},p$e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{dx(t,mre);let a=new AbortController;try{await Promise.race([h$e(o,e,a),m$e({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),g$e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),dx(t,-mre)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?NL(t):_$e(t))},h$e=async(t,e,{signal:r})=>{try{await t,r.aborted||NL(e)}catch(n){r.aborted||_re(e,n)}},m$e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await gre(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;yre(s)?i.add(e):Sre(t,s)}},g$e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await pre(t,i,{signal:o}),!t.readable)return pre(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},_$e=t=>{t.writable&&t.end()},_re=(t,e)=>{yre(e)?NL(t):Sre(t,e)},yre=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",NL=t=>{(t.readable||t.writable)&&t.destroy()},Sre=(t,e)=>{t.destroyed||(t.once("error",y$e),t.destroy(e))},y$e=()=>{},dx=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},hre=2,mre=1;import{finished as Ere}from"stream/promises";var mf=(t,e)=>{t.pipe(e),S$e(t,e),E$e(t,e)},S$e=async(t,e)=>{if(!(wi(t)||wi(e))){try{await Ere(t,{cleanup:!0,readable:!0,writable:!1})}catch{}kL(e)}},kL=t=>{t.writable&&t.end()},E$e=async(t,e)=>{if(!(wi(t)||wi(e))){try{await Ere(e,{cleanup:!0,readable:!1,writable:!0})}catch{}ML(t)}},ML=t=>{t.readable&&t.destroy()};var vre=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:o,direction:s}]of Object.entries(e)){for(let{stream:a}of o.filter(({type:c})=>Yn.has(c)))v$e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Yn.has(c)))T$e({subprocess:t,stream:a,direction:s,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,o]of n.entries()){let s=o.length===1?o[0]:Rl(o);mf(s,i)}},v$e=(t,e,r,n)=>{r==="output"?mf(t.stdio[n],e):mf(e,t.stdio[n]);let i=b$e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},b$e=["stdin","stdout","stderr"],T$e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;A$e(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},A$e=(t,{signal:e})=>{wi(t)&&Tl(t,x$e,e)},x$e=2;import{addAbortListener as I$e}from"events";var Il=[];Il.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Il.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Il.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var fx=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",DL=Symbol.for("signal-exit emitter"),LL=globalThis,w$e=Object.defineProperty.bind(Object),$L=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(LL[DL])return LL[DL];w$e(LL,DL,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let o of this.listeners[e])i=o(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},px=class{},R$e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),UL=class extends px{onExit(){return()=>{}}load(){}unload(){}},FL=class extends px{#e=BL.platform==="win32"?"SIGINT":"SIGHUP";#r=new $L;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Il)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,o=e;if(typeof o.__signal_exit_emitter__=="object"&&typeof o.__signal_exit_emitter__.count=="number"&&(i+=o.__signal_exit_emitter__.count),n.length===i){this.unload();let s=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;s||e.kill(e.pid,a)}};this.#o=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!fx(this.#t))return()=>{};this.#s===!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.#s){this.#s=!0,this.#r.count+=1;for(let e of Il)try{let r=this.#i[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#s&&(this.#s=!1,Il.forEach(e=>{let r=this.#i[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#o,this.#r.count-=1)}#a(e){return fx(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#o.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&fx(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let i=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),i}else return n.call(this.#t,e,...r)}},BL=globalThis.process,{onExit:bre,load:Uyt,unload:Fyt}=R$e(fx(BL)?new FL(BL):new UL);var Tre=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=bre(()=>{t.kill()});I$e(n,()=>{i()})};var xre=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=AA(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=C$e(r,n,i),{sourceStream:d,sourceError:f}=O$e(t,l),{options:p,fileDescriptors:h}=po.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},C$e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=P$e(t,e,...r),a=MA(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},P$e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Are,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||CD(r)){if(Object.keys(t).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[i,o,s]=hA(r,...n);return{destination:e(Are)(i,o,s),pipeOptions:s}}if(po.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}`)},Are=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),O$e=(t,e)=>{try{return{sourceStream:cf(t,e)}}catch(r){return{sourceError:r}}};var Rre=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=N$e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw jL({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},N$e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return ML(t),n;if(e!==void 0)return kL(r),e},jL=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>ff({error:t,command:wre,escapedCommand:wre,fileDescriptors:e,options:r,startTime:n,isSync:!1}),wre="source.pipe(destination)";var Ire=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:o,value:s=o}]=await t;if(s.pipedFrom.includes(n)||s.pipedFrom.push(n),i==="rejected")throw s;if(e==="rejected")throw n;return s};import{finished as k$e}from"stream/promises";var Cre=(t,e,r)=>{let n=hx.has(e)?D$e(t,e):M$e(t,e);return Tl(t,$$e,r.signal),Tl(e,U$e,r.signal),L$e(e),n},M$e=(t,e)=>{let r=Rl([t]);return mf(r,e),hx.set(e,r),r},D$e=(t,e)=>{let r=hx.get(e);return r.add(t),r},L$e=async t=>{try{await k$e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}hx.delete(t)},hx=new WeakMap,$$e=2,U$e=1;import{aborted as F$e}from"util";var Pre=(t,e)=>t===void 0?[]:[B$e(t,e)],B$e=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await F$e(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw jL({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var mx=(t,...e)=>{if(Pt(e[0]))return mx.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=xre(t,...e),i=j$e({...n,destination:r});return i.pipe=mx.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},j$e=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=z$e(t,i);Rre({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Cre(e,o,d);return await Promise.race([Ire(u),...Pre(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},z$e=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as K$e}from"timers/promises";import{on as G$e}from"events";import{getDefaultHighWaterMark as V$e}from"stream";var gx=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return q$e(e,s),Nre({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},q$e=async(t,e)=>{try{await t}catch{}finally{e.abort()}},zL=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;H$e(e,s,t);let a=t.readableObjectMode&&!o;return Nre({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},H$e=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Nre=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=G$e(t,"data",{signal:e.signal,highWaterMark:Ore,highWatermark:Ore});return W$e({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},GL=V$e(!0),Ore=GL,W$e=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=Y$e({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*wl(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*x_(a)}},Y$e=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[sx(t,r,!e),ox(t,i,!n,{})].filter(Boolean);var kre=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=Z$e({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([J$e(t),d]);return}let f=EL(c,r),p=zL({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([X$e({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},Z$e=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!lx({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=zL({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Vte(a,t,r,o)},J$e=async t=>{await K$e(),t.readableFlowing===null&&t.resume()},X$e=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await ZA(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await JA(r,{maxBuffer:o})):await df(r,{maxBuffer:o})}catch(a){return Mre(Vee({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},VL=async t=>{try{return await t}catch(e){return Mre(e)}},Mre=({bufferedData:t})=>sQ(t)?new Uint8Array(t):t;import{finished as Q$e}from"stream/promises";var C_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=e1e(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],Q$e(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||n1e(a,e,r,n)}finally{s.abort()}},e1e=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&t1e(t,r,n),n},t1e=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{r1e(e,r),n.call(t,...i)}},r1e=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},n1e=(t,e,r,n)=>{if(!i1e(t,e,r,n))throw t},i1e=(t,e,r,n=!0)=>r.propagating?Dre(t)||_x(t):(r.propagating=!0,qL(r,e)===n?Dre(t):_x(t)),qL=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",_x=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Dre=t=>t?.code==="EPIPE";var Lre=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>HL({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),HL=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=C_(t,e,l);if(qL(l,e)){await u;return}let[d]=await Promise.all([kre({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var $re=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Rl([t,e].filter(Boolean)):void 0,Ure=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>HL({...o1e(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:s1e(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),o1e=({stdout:t,stderr:e,all:r},[,n,i])=>{let o=n||i;return o?n?i?{stream:r,buffer:o}:{stream:t,buffer:o}:{stream:e,buffer:o}:{stream:r,buffer:o}},s1e=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as a1e}from"events";var Fre=t=>rf(t,"ipc"),Bre=(t,e)=>{let r=TA(t);uo({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var jre=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=Fre(o),a=hs(e,"ipc"),c=hs(r,"ipc");for await(let l of CL({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(qee(t,i,c),i.push(l)),s&&Bre(l,o);return i},zre=async(t,e)=>(await Promise.allSettled([t]),e);var Gre=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:v,controller:b})=>{let E=Kte(t,f),A={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:E,propagating:!1},_=Lre({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:A}),R=Ure({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:A}),I=[],O=jre({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:I,verboseInfo:p}),C=c1e(m,t,A),P=l1e(h,A);try{return await Promise.race([Promise.all([{},Jte(E),Promise.all(_),R,O,Tee(t,d),...C,...P]),v,u1e(t,b),...yee(t,o,f,b),...F7({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:b}),...gee({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:b})])}catch($){return f.terminationReason??="other",Promise.all([{error:$},E,Promise.all(_.map(y=>VL(y))),VL(R),zre(O,I),Promise.allSettled(C),Promise.allSettled(P)])}},c1e=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:C_(n,i,r)),l1e=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Ci(o,{checkOpen:!1})&&!wi(o)).map(({type:i,value:o,stream:s=o})=>C_(s,n,e,{isSameDirection:Yn.has(i),stopOnExit:i==="native"}))),u1e=async(t,{signal:e})=>{let[r]=await a1e(t,"error",{signal:e});throw r};var Vre=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),P_=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=fo();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},gf=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 d1e}from"stream";import{callbackify as f1e}from"util";import{finished as qre}from"stream/promises";var WL=async t=>{if(t!==void 0)try{await YL(t)}catch{}},Hre=async t=>{if(t!==void 0)try{await KL(t)}catch{}},YL=async t=>{await qre(t,{cleanup:!0,readable:!1,writable:!0})},KL=async t=>{await qre(t,{cleanup:!0,readable:!0,writable:!1})},yx=async(t,e)=>{if(await t,e)throw e},Sx=(t,e,r)=>{r&&!_x(r)?t.destroy(r):e&&t.destroy()};var Wre=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||_n.has(r),{subprocessStdout:a,waitReadableDestroy:c}=ZL(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=JL(a,s),{read:f,onStdoutDataDone:p}=XL({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new d1e({read:f,destroy:f1e(e$.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return QL({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},ZL=(t,e,r)=>{let n=cf(t,e),i=P_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},JL=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:GL},XL=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=fo(),s=gx({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){p1e(this,s,o)},onStdoutDataDone:o}},p1e=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},QL=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await KL(t),await n,await WL(i),await e,r.readable&&r.push(null)}catch(o){await WL(i),Yre(r,o)}},e$=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await gf(r,e)&&(Yre(t,n),await yx(e,n))},Yre=(t,e)=>{Sx(t,t.readable,e)};import{Writable as h1e}from"stream";import{callbackify as Kre}from"util";var Zre=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=t$(t,r,e),s=new h1e({...r$(n,t,i),destroy:Kre(i$.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return n$(n,s),s},t$=(t,e,r)=>{let n=MA(t,e),i=P_(r,n,"writableFinal"),o=P_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},r$=(t,e,r)=>({write:m1e.bind(void 0,t),final:Kre(g1e.bind(void 0,t,e,r))}),m1e=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},g1e=async(t,e,r)=>{await gf(r,e)&&(t.writable&&t.end(),await e)},n$=async(t,e,r)=>{try{await YL(t),e.writable&&e.end()}catch(n){await Hre(r),Jre(e,n)}},i$=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await gf(r,e),await gf(n,e)&&(Jre(t,i),await yx(e,i))},Jre=(t,e)=>{Sx(t,t.writable,e)};import{Duplex as _1e}from"stream";import{callbackify as y1e}from"util";var Xre=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||_n.has(r),{subprocessStdout:c,waitReadableDestroy:l}=ZL(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=t$(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=JL(c,a),{read:v,onStdoutDataDone:b}=XL({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),E=new _1e({read:v,...r$(u,t,d),destroy:y1e(S1e.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return QL({subprocessStdout:c,onStdoutDataDone:b,readable:E,subprocess:t,subprocessStdin:u}),n$(u,E,c),E},S1e=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([e$({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),i$({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var o$=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||_n.has(e),s=cf(t,r),a=gx({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return E1e(a,s,t)},E1e=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Qre=(t,{encoding:e})=>{let r=Vre();t.readable=Wre.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Zre.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Xre.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=o$.bind(void 0,t,e),t[Symbol.asyncIterator]=o$.bind(void 0,t,e,{})};var ene=(t,e)=>{for(let[r,n]of b1e){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},v1e=(async()=>{})().constructor.prototype,b1e=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(v1e,t)]);var tne=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=x1e(t,e,r),{subprocess:f,promise:p}=R1e({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=mx.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),ene(f,p),po.set(f,{options:u,fileDescriptors:d}),f},x1e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=xA(t,e,r),{file:a,commandArguments:c,options:l}=qA(t,e,r),u=w1e(l),d=fre(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},w1e=({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}},R1e=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=A1e(...HA(t,e,r))}catch(h){return cre({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;T1e(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];vre(c,a,l),Tre(c,r,l);let d={},f=fo();c.kill=$7.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=$re(c,r),Qre(c,r),ore(c,r);let p=I1e({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:o,escapedCommand:s,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},I1e=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,v]=await Gre({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let b=h.map((_,R)=>gs(_,e,R)),E=gs(m,e,"all"),A=C1e({errorInfo:d,exitCode:f,signal:p,stdio:b,all:E,ipcOutput:v,context:c,options:e,command:s,escapedCommand:a,startTime:r});return pf(A,n,e)},C1e=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?A_({error:t.error,command:c,escapedCommand:l,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof ho,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):ex({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var Ex=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,P1e(n,t[n],i)]));return{...t,...r}},P1e=(t,e,r)=>O1e.has(t)&&Pt(e)&&Pt(r)?{...e,...r}:r,O1e=new Set(["env",...DD]);var Oa=(t,e,r,n)=>{let i=(s,a,c)=>Oa(s,a,r,c),o=(...s)=>N1e({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},N1e=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Pt(o))return i(t,Ex(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=k1e({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?Qte(a,c,l):tne(a,c,l,i)},k1e=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=fQ(e)?pQ(e,r):[e,...r],[s,a,c]=hA(...o),l=Ex(Ex(n,i),c),{file:u=s,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:s,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var rne=({file:t,commandArguments:e})=>ine(t,e),nne=({file:t,commandArguments:e})=>({...ine(t,e),isSync:!0}),ine=(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]=M1e(t);return{file:r,commandArguments:n}},M1e=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(D1e)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},D1e=/ +/g;var one=(t,e,r)=>{t.sync=e(L1e,r),t.s=t.sync},sne=({options:t})=>ane(t),L1e=({options:t})=>({...ane(t),isSync:!0}),ane=t=>({options:{...$1e(t),...t}}),$1e=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},cne={preferLocal:!0};var lne=Oa(()=>({})),Ivt=Oa(()=>({isSync:!0})),une=Oa(rne),Cvt=Oa(nne),Pvt=Oa(Eee),Ovt=Oa(sne,{},cne,one),{sendMessage:Nvt,getOneMessage:kvt,getEachMessage:Mvt,getCancelSignal:Dvt}=sre();var dne=!1,fne=()=>{dne=!0},go=()=>dne;var O_=null,pne=t=>(O_&&O_.destroy(),O_=new _s({totalAllowedTime:t}),O_),hne=()=>O_;var _s=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&go())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await aA({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{pe.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),o(),s&&clearTimeout(s)}};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 mne={name:"@netlify/agent-runner-cli",type:"module",version:"1.150.0-ex-2643.2",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.2","@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.219","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.1.5","@netlify/otel":"^6.0.4","@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",zod:"^4.4.3"}};var j1e=F1e(import.meta.url),z1e=ys.dirname(j1e),G1e=B1e(import.meta.url),_f=fe("shell"),s$=new Set,gne={preferLocal:!0},ur=(t,e,r)=>{let[n,i]=V1e(e,r),o={...gne,...i},s=lne(t,n,o);yne(s,o),vne(s);let a=r?.idleTimeout;return a&&a>0&&Ene(s,a),s},_ne=(t,e)=>{let r={...gne,...e},n=une(t,r);return yne(n,r),vne(n),e?.idleTimeout&&e.idleTimeout>0&&Ene(n,e.idleTimeout),n},V1e=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},yne=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(Ss.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new o_).pipe(Ss.stdout),t.stderr?.pipe(new o_).pipe(Ss.stderr);return}t.stdout?.pipe(Ss.stdout),t.stderr?.pipe(Ss.stderr)},a$=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Ss.kill(-t.pid,e),_f.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return _f.error("Error killing process:",r),!1}},Sne=t=>a$(t,"SIGKILL"),Ene=(t,e)=>{let r=null,n=()=>{_f.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),a$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(_f.log(`Force killing idle process ${t.pid}`),Sne(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let o=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",o),t.on("error",o)},vne=t=>{s$.add(t);let e=hne();if(e){let r=e.onTimesUp(()=>{_f.log(`Global timer expired, killing process ${t.pid}`),a$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(_f.log(`Force killing process ${t.pid} after timeout`),Sne(t))},5e3)});t.on("exit",()=>{s$.delete(t),r()}),t.on("error",()=>{s$.delete(t),r()})}};function bx(t,e){return!!Pi(t,e)}function Pi(t,e){if(!Ss.env.NETLIFY_LOCAL_MODE)try{let i=G1e.resolve(mne.name),o=ys.dirname(i);for(;o!==ys.dirname(o);){let s=ys.dirname(o);if(ys.basename(s)==="node_modules"){let a=ys.join(s,".bin",e);if(vx.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(Ss.env.NODE_PATH){let i=ys.join(Ss.env.NODE_PATH,".bin",e);if(vx.existsSync(i))return i}let r=ys.join(t,"node_modules",".bin",e);if(vx.existsSync(r))return r;let n=ys.join(z1e,"..","node_modules",".bin",e);if(vx.existsSync(n))return n}var q1e=fe("utils"),H1e=t=>new Promise(e=>{setTimeout(e,t)});var c$=t=>{try{return new URL(t).hostname||null}catch{return null}},Tx=(t,e=3e3)=>{let r=!1,n=null,i=[],o=null,s=(...a)=>{if(r)return n=a,new Promise(u=>{i.push(u)});r=!0;let c,l=new Promise(u=>{c=u});return o=(async()=>{await Promise.resolve();let u=await t(...a);for(c(u);;){if(await H1e(e),!n)return r=!1,o=null,u;let d=n,f=i;n=null,i=[],u=await t(...d),f.forEach(p=>{p(u)})}})(),l};return s.flush=async()=>{if((r||n)&&o)return await o,s.flush()},s.cancel=()=>{n=null,i.forEach(a=>a(void 0)),i=[]},s},Na=(t,e,r=!1)=>{let n=null,i=null,o=null,s=function(...a){i=a,o=this;let c=r&&!n;clearTimeout(n),n=setTimeout(()=>{n=null,r||(t.apply(o,i),i=null,o=null)},e),c&&(t.apply(o,i),i=null,o=null)};return s.cancel=()=>{clearTimeout(n),n=null,i=null,o=null},s.flush=()=>{if(n){clearTimeout(n);let a=i,c=o;n=null,i=null,o=null,t.apply(c,a)}},s},bne=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):q1e.error("Could not parse JSON",n))}},W1e=t=>t.charAt(0).toUpperCase()+t.slice(1),_o=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():W1e(e)).join(" ");function Es(t,e){e&&t.log(`Skill invoked: ${e}`)}var Ax=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),Tne=(t,e,r=!1)=>{if(r)return;let n=60,i=55,o=".netlify.app",s="agent-",a=6;if(!e)return`${s}${t.slice(0,a)}`;let c=`--${e}${o}`;if(c.length>i)return"";let l=n-c.length;if(l<=0)return"";if(l>=s.length+a){let u=Math.min(l-s.length,t.length);return`${s}${t.slice(0,u)}`}return t.slice(0,l)};var l$=t=>{let e=t.match(/<<-?\s*['"]?(\w+)['"]?/);if(!e)return{command:t};let r=t.indexOf(e[0]),n=t.slice(r+e[0].length).trim();return{command:t.slice(0,r).trim(),heredocContent:n||void 0}},Y1e=1e4,u$=(t,e=Y1e)=>{if(!t||typeof t!="string"||t.length<=e)return t;let n=t.startsWith("```")?"\n... [truncated]\n```":"... [truncated]";return t.slice(0,e)+n};import{Buffer as Ane}from"buffer";import K1e from"path";var xne=fe("repo"),Qr=(t,e={})=>ur("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),xx=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{xne.info("Getting runner diffs");let n=await J1e(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let m=Q1e(o);await eUe(m,r)}xne.info("Changes after processing"),await f$(r);let s=await p$(o,r);if(await d$(s,r),i=await X1e(r),!i)return{hasChanges:!1,ignored:s};await Qr(["commit","-m","Agent runner"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await Qr(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(i=!!l,!i)return await wne(r),{hasChanges:!1,ignored:s};let u=await Qr(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,p;if(t.sha){let m=await Qr(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let v=await Qr(["diff",t.sha,"HEAD","--binary"],a),b=String(v.stdout??"");f!==b&&(p=Ane.from(b).toString("base64"))}await wne(r);let h={hasChanges:!0,diff:l,resultDiff:f,ignored:s};return l!==d&&(h.diffBinary=Ane.from(d).toString("base64")),p&&(h.resultDiffBinary=p),h},wne=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Qr(["reset","--soft","HEAD~1"],{cwd:t})},d$=async(t=[],e=process.cwd())=>{await Qr(["add",".",...t],{cwd:e})},f$=async(t=process.cwd())=>{let e=await Qr(["status","-s"],{cwd:t});return String(e.stdout??"")},Rne=/.. (.+)?\.log$/,Z1e=[Rne],J1e=async(t=process.cwd())=>{let e=await f$(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
103
103
|
`).filter(i=>Z1e.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}},X1e=async(t=process.cwd())=>{try{return await Qr(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},N_=async(t=process.cwd())=>{let{stdout:e}=await Qr(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},Ine=async(t=process.cwd())=>{let{stdout:e}=await Qr(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},p$=async(t,e=process.cwd())=>{t||=await f$(e);let r=[".netlify","node_modules","dist",".next","out",".nuxt",".output",".cache",".turbo",".parcel-cache","coverage",".nyc_output","storybook-static","public/build","CLAUDE.local.md"],n=[];return t.split(`
|
|
104
104
|
`).forEach(i=>{r.forEach(s=>{let a=i===`?? ${s}`,c=i.startsWith(`?? ${s}/`)||i.startsWith(`?? ${s}${K1e.sep}`);(a||c)&&n.push(`:!${s}`)});let o=i.match(Rne)?.[1];o&&n.push(`:!${o}.log`)}),n},Cne=async(t=process.cwd())=>{await Qr(["reset","--hard","HEAD"],{cwd:t})},Pne=async(t=process.cwd())=>{let e=await Qr(["clean","-fd","-e",".netlify"],{stdio:["ignore","pipe","pipe"],cwd:t});return String(e.stdout??"").split(`
|
|
105
105
|
`).filter(r=>r.startsWith("Removing ")).map(r=>r.slice(9))},Q1e=t=>{let e=t.split(`
|
|
@@ -295,7 +295,7 @@ you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
|
|
|
295
295
|
new OpenAI({ apiKey, dangerouslyAllowBrowser: true });
|
|
296
296
|
|
|
297
297
|
https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
|
|
298
|
-
`);this.baseURL=c.baseURL,this.timeout=c.timeout??j2.DEFAULT_TIMEOUT,this.logger=c.logger??console;let l="warn";this.logLevel=l,this.logLevel=m2(c.logLevel,"ClientOptions.logLevel",this)??m2(uc("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??l,this.fetchOptions=c.fetchOptions,this.maxRetries=c.maxRetries??2,this.fetch=c.fetch??qR(),we(this,SI,qae,"f"),this._options=c,s&&(this._workloadIdentityAuth=new XR(s,this.fetch)),this.apiKey=typeof r=="string"?r:"Missing Key",this.organization=n,this.project=i,this.webhookSecret=o}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 ece(e)}getUserAgent(){return`${this.constructor.name}/JS ${nc}`}defaultIdempotencyKey(){return`stainless-node-retry-${t2()}`}makeStatusError(e,r,n,i){return wt.generate(e,r,n,i)}async _callApiKey(){let e=this._options.apiKey;if(typeof e!="function")return!1;let r;try{r=await e()}catch(n){throw n instanceof ge?n:new ge(`Failed to get token from 'apiKey' function: ${n.message}`,{cause:n})}if(typeof r!="string"||!r)throw new ge(`Expected 'apiKey' function argument to return a string but it returned ${r}`);return this.apiKey=r,!0}buildURL(e,r,n){let i=!L(this,B2,"m",$ce).call(this)&&n||this.baseURL,o=Dae(e)?new URL(e):new URL(i+(i.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),s=this.defaultQuery(),a=Object.fromEntries(o.searchParams);return(!i2(s)||!i2(a))&&(r={...a,...s,...r}),typeof r=="object"&&r&&!Array.isArray(r)&&(o.search=this.stringifyQuery(r)),o.toString()}async prepareOptions(e){await this._callApiKey()}async prepareRequest(e,{url:r,options:n}){}get(e,r){return this.methodRequest("get",e,r)}post(e,r){return this.methodRequest("post",e,r)}patch(e,r){return this.methodRequest("patch",e,r)}put(e,r){return this.methodRequest("put",e,r)}delete(e,r){return this.methodRequest("delete",e,r)}methodRequest(e,r,n){return this.request(Promise.resolve(n).then(i=>({method:e,path:r,...i})))}request(e,r=null){return new Xl(this,this.makeRequest(e,r,void 0))}async makeRequest(e,r,n){let i=await e,o=i.maxRetries??this.maxRetries;r==null&&(r=o),await this.prepareOptions(i);let{req:s,url:a,timeout:c}=await this.buildRequest(i,{retryCount:o-r});await this.prepareRequest(s,{url:a,options:i});let l="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),u=n===void 0?"":`, retryOf: ${n}`,d=Date.now();if(Ot(this).debug(`[${l}] sending request`,Ms({retryOfRequestLogID:n,method:i.method,url:a,options:i,headers:s.headers})),i.signal?.aborted)throw new Dt;let f=new AbortController,p=await this.fetchWithAuth(a,s,c,f).catch(By),h=Date.now();if(p instanceof globalThis.Error){let b=`retrying, ${r} attempts remaining`;if(i.signal?.aborted)throw new Dt;let E=Fy(p)||/timed? ?out/i.test(String(p)+("cause"in p?String(p.cause):""));if(r)return Ot(this).info(`[${l}] connection ${E?"timed out":"failed"} - ${b}`),Ot(this).debug(`[${l}] connection ${E?"timed out":"failed"} (${b})`,Ms({retryOfRequestLogID:n,url:a,durationMs:h-d,message:p.message})),this.retryRequest(i,r,n??l);throw Ot(this).info(`[${l}] connection ${E?"timed out":"failed"} - error; no more retries left`),Ot(this).debug(`[${l}] connection ${E?"timed out":"failed"} (error; no more retries left)`,Ms({retryOfRequestLogID:n,url:a,durationMs:h-d,message:p.message})),p instanceof Zl||p instanceof jy?p:E?new rc:new tc({cause:p})}let m=[...p.headers.entries()].filter(([b])=>b==="x-request-id").map(([b,E])=>", "+b+": "+JSON.stringify(E)).join(""),v=`[${l}${u}${m}] ${s.method} ${a} ${p.ok?"succeeded":"failed"} with status ${p.status} in ${h-d}ms`;if(!p.ok){if(p.status===401&&this._workloadIdentityAuth&&!i.__metadata?.hasStreamingBody&&!i.__metadata?.workloadIdentityTokenRefreshed)return await a2(p.body),this._workloadIdentityAuth.invalidateToken(),this.makeRequest({...i,__metadata:{...i.__metadata,workloadIdentityTokenRefreshed:!0}},r,n??l);let b=await this.shouldRetry(p);if(r&&b){let O=`retrying, ${r} attempts remaining`;return await a2(p.body),Ot(this).info(`${v} - ${O}`),Ot(this).debug(`[${l}] response error (${O})`,Ms({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:h-d})),this.retryRequest(i,r,n??l,p.headers)}let E=b?"error; no more retries left":"error; not retryable";Ot(this).info(`${v} - ${E}`);let A=await p.text().catch(O=>By(O).message),_=Uae(A),R=_?void 0:A;throw Ot(this).debug(`[${l}] response error (${E})`,Ms({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,message:R,durationMs:Date.now()-d})),this.makeStatusError(p.status,_,R,p.headers)}return Ot(this).info(v),Ot(this).debug(`[${l}] response start`,Ms({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:h-d})),{response:p,options:i,controller:f,requestLogID:l,retryOfRequestLogID:n,startTime:d}}getAPIList(e,r,n){return this.requestAPIList(r,n&&"then"in n?n.then(i=>({method:"get",path:e,...i})):{method:"get",path:e,...n})}requestAPIList(e,r){let n=this.makeRequest(r,null,void 0);return new Wy(this,n,e)}async fetchWithAuth(e,r,n,i){if(this._workloadIdentityAuth){let s=r.headers,a=s.get("Authorization");if(!a||a===`Bearer ${F2}`){let c=await this._workloadIdentityAuth.getToken();s.set("Authorization",`Bearer ${c}`)}}return await this.fetchWithTimeout(e,r,n,i)}async fetchWithTimeout(e,r,n,i){let{signal:o,method:s,...a}=r||{},c=this._makeAbort(i);o&&o.addEventListener("abort",c,{once:!0});let l=setTimeout(c,n),u=globalThis.ReadableStream&&a.body instanceof globalThis.ReadableStream||typeof a.body=="object"&&a.body!==null&&Symbol.asyncIterator in a.body,d={signal:i.signal,...u?{duplex:"half"}:{},method:"GET",...a};s&&(d.method=s.toUpperCase());try{return await this.fetch.call(void 0,e,d)}finally{clearTimeout(l)}}async shouldRetry(e){let r=e.headers.get("x-should-retry");return r==="true"?!0:r==="false"?!1:e.status===408||e.status===409||e.status===429||e.status>=500}async retryRequest(e,r,n,i){let o,s=i?.get("retry-after-ms");if(s){let c=parseFloat(s);Number.isNaN(c)||(o=c)}let a=i?.get("retry-after");if(a&&!o){let c=parseFloat(a);Number.isNaN(c)?o=Date.parse(a)-Date.now():o=c*1e3}if(o===void 0){let c=e.maxRetries??this.maxRetries;o=this.calculateDefaultRetryTimeoutMillis(r,c)}return await Ao(o),this.makeRequest(e,r-1,n)}calculateDefaultRetryTimeoutMillis(e,r){let o=r-e,s=Math.min(.5*Math.pow(2,o),8),a=1-Math.random()*.25;return s*a*1e3}async buildRequest(e,{retryCount:r=0}={}){let n={...e},{method:i,path:o,query:s,defaultBaseURL:a}=n,c=this.buildURL(o,s,a);"timeout"in n&&$ae("timeout",n.timeout),n.timeout=n.timeout??this.timeout;let{bodyHeaders:l,body:u,isStreamingBody:d}=this.buildBody({options:n});d&&(e.__metadata={...e.__metadata,hasStreamingBody:!0});let f=await this.buildHeaders({options:e,method:i,bodyHeaders:l,retryCount:r});return{req:{method:i,headers:f,...n.signal&&{signal:n.signal},...globalThis.ReadableStream&&u instanceof globalThis.ReadableStream&&{duplex:"half"},...u&&{body:u},...this.fetchOptions??{},...n.fetchOptions??{}},url:c,timeout:n.timeout}}async buildHeaders({options:e,method:r,bodyHeaders:n,retryCount:i}){let o={};this.idempotencyHeader&&r!=="get"&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),o[this.idempotencyHeader]=e.idempotencyKey);let s=ne([o,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(i),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...Gae(),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},await this.authHeaders(e),this._options.defaultHeaders,n,e.headers]);return this.validateHeaders(s),s.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]),i=typeof globalThis.ReadableStream<"u"&&e instanceof globalThis.ReadableStream,o=!i&&(typeof e=="string"||e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof globalThis.Blob<"u"&&e instanceof globalThis.Blob||e instanceof URLSearchParams||e instanceof FormData);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e=="string"&&n.values.has("content-type")||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||i?{bodyHeaders:void 0,body:e,isStreamingBody:!o}:typeof e=="object"&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&typeof e.next=="function")?{bodyHeaders:void 0,body:HR(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}:{...L(this,SI,"f").call(this,{body:e,headers:n}),isStreamingBody:!1}}};j2=Ne,SI=new WeakMap,B2=new WeakSet,$ce=function(){return this.baseURL!=="https://api.openai.com/v1"};Ne.OpenAI=j2;Ne.DEFAULT_TIMEOUT=6e5;Ne.OpenAIError=ge;Ne.APIError=wt;Ne.APIConnectionError=tc;Ne.APIConnectionTimeoutError=rc;Ne.APIUserAbortError=Dt;Ne.NotFoundError=Dp;Ne.ConflictError=Lp;Ne.RateLimitError=Up;Ne.BadRequestError=Np;Ne.AuthenticationError=kp;Ne.InternalServerError=Fp;Ne.PermissionDeniedError=Mp;Ne.UnprocessableEntityError=$p;Ne.InvalidWebhookSignatureError=To;Ne.toFile=eI;Ne.Completions=au;Ne.Chat=ac;Ne.Embeddings=lu;Ne.Files=du;Ne.Images=mu;Ne.Audio=Io;Ne.Moderations=_u;Ne.Models=gu;Ne.FineTuning=Li;Ne.Graders=mc;Ne.VectorStores=zs;Ne.Webhooks=Eu;Ne.Beta=Di;Ne.Batches=ru;Ne.Uploads=_c;Ne.Responses=Bs;Ne.Realtime=Fs;Ne.Conversations=pc;Ne.Evals=hc;Ne.Containers=fc;Ne.Skills=js;Ne.Videos=Su;var Qn=fe("runner_codex"),z2="Codex CLI",Ah="gpt-5.6-sol";async function qze({aiGateway:t,config:e,model:r}){let n=r;if(t)if(e.modelVersionOverrides?.codex){let i=e.modelVersionOverrides?.codex?.[e.accountType];if(i){if(!await t.isModelAvailableForProvider("openai",i))throw new Error(`Model override '${i}' is not available for openai provider`);n=i}}else if(r){if(!await t.isModelAvailableForProvider("openai",r))throw new Error(`Model '${r}' is not available for openai provider`)}else!!Ah&&await t.isModelAvailableForProvider("openai",Ah)?(n=Ah,Qn.log(`Using default model: ${Ah}`)):Ah&&Qn.log(`Default model ${Ah} is not available, proceeding without model specification`);return n}var EI="netlify-ask-db",Hze=`default_permissions = "${EI}"`,Wze=t=>["",`[permissions.${EI}]`,'description = "Ask mode: read-only filesystem, network limited to the project database"','extends = ":read-only"',"",`[permissions.${EI}.network]`,"enabled = true","",`[permissions.${EI}.network.domains]`,`"${t}" = "allow"`,'"*" = "deny"'];function Yze({aiGateway:t}){if(t){let{token:e,url:r}=t;if(!e||!r)throw new Error("No token or url provided from AI Gateway");yc.env.OPENAI_API_KEY=e,yc.env.OPENAI_BASE_URL=r}else if(!yc.env.OPENAI_API_KEY)throw new Error("OPENAI_API_KEY is not provided")}async function G2({config:t,netlify:e,persistSteps:r,sendSteps:n,aiGateway:i,continueSession:o,priorAgentSessionId:s,cwd:a=yc.cwd(),abortSignal:c,onSessionId:l,effortOverride:u}){let{prompt:d}=t,{model:f}=t;Yze({aiGateway:i});let p=await qze({config:t,aiGateway:i,model:f}),h=[],m=[],v=[],b={},E=new Set,A=0,_=0,R,I,O,C,P,$=Kf(t),y=`${yc.env.NVM_BIN}/node`,oe=xh.join(vI.homedir(),".codex"),N=xh.join(oe,"config.toml"),g=xh.join(oe,"auth.json");try{await aS.mkdir(oe,{recursive:!0});let De={OPENAI_API_KEY:yc.env.OPENAI_API_KEY};await aS.writeFile(g,JSON.stringify(De,null,2),"utf-8"),Qn.log("Created Codex auth.json file");let z=yc.env.OPENAI_BASE_URL,Ee=['forced_login_method = "api"'],W=We().questionsEnabled;$&&Ee.push(Hze),z&&Ee.push('model_provider = "openai_proxy"',"","[model_providers.openai_proxy]",'name = "OpenAI Proxy"',`base_url = "${z}"`,'env_key = "OPENAI_API_KEY"','wire_api = "responses"',"supports_websockets = false","requires_openai_auth = true"),W&&Ee.push(...Aie()),$&&Ee.push(...Wze($.host)),await aS.writeFile(N,`${Ee.join(`
|
|
298
|
+
`);this.baseURL=c.baseURL,this.timeout=c.timeout??j2.DEFAULT_TIMEOUT,this.logger=c.logger??console;let l="warn";this.logLevel=l,this.logLevel=m2(c.logLevel,"ClientOptions.logLevel",this)??m2(uc("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??l,this.fetchOptions=c.fetchOptions,this.maxRetries=c.maxRetries??2,this.fetch=c.fetch??qR(),we(this,SI,qae,"f"),this._options=c,s&&(this._workloadIdentityAuth=new XR(s,this.fetch)),this.apiKey=typeof r=="string"?r:"Missing Key",this.organization=n,this.project=i,this.webhookSecret=o}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 ece(e)}getUserAgent(){return`${this.constructor.name}/JS ${nc}`}defaultIdempotencyKey(){return`stainless-node-retry-${t2()}`}makeStatusError(e,r,n,i){return wt.generate(e,r,n,i)}async _callApiKey(){let e=this._options.apiKey;if(typeof e!="function")return!1;let r;try{r=await e()}catch(n){throw n instanceof ge?n:new ge(`Failed to get token from 'apiKey' function: ${n.message}`,{cause:n})}if(typeof r!="string"||!r)throw new ge(`Expected 'apiKey' function argument to return a string but it returned ${r}`);return this.apiKey=r,!0}buildURL(e,r,n){let i=!L(this,B2,"m",$ce).call(this)&&n||this.baseURL,o=Dae(e)?new URL(e):new URL(i+(i.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),s=this.defaultQuery(),a=Object.fromEntries(o.searchParams);return(!i2(s)||!i2(a))&&(r={...a,...s,...r}),typeof r=="object"&&r&&!Array.isArray(r)&&(o.search=this.stringifyQuery(r)),o.toString()}async prepareOptions(e){await this._callApiKey()}async prepareRequest(e,{url:r,options:n}){}get(e,r){return this.methodRequest("get",e,r)}post(e,r){return this.methodRequest("post",e,r)}patch(e,r){return this.methodRequest("patch",e,r)}put(e,r){return this.methodRequest("put",e,r)}delete(e,r){return this.methodRequest("delete",e,r)}methodRequest(e,r,n){return this.request(Promise.resolve(n).then(i=>({method:e,path:r,...i})))}request(e,r=null){return new Xl(this,this.makeRequest(e,r,void 0))}async makeRequest(e,r,n){let i=await e,o=i.maxRetries??this.maxRetries;r==null&&(r=o),await this.prepareOptions(i);let{req:s,url:a,timeout:c}=await this.buildRequest(i,{retryCount:o-r});await this.prepareRequest(s,{url:a,options:i});let l="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),u=n===void 0?"":`, retryOf: ${n}`,d=Date.now();if(Ot(this).debug(`[${l}] sending request`,Ms({retryOfRequestLogID:n,method:i.method,url:a,options:i,headers:s.headers})),i.signal?.aborted)throw new Dt;let f=new AbortController,p=await this.fetchWithAuth(a,s,c,f).catch(By),h=Date.now();if(p instanceof globalThis.Error){let b=`retrying, ${r} attempts remaining`;if(i.signal?.aborted)throw new Dt;let E=Fy(p)||/timed? ?out/i.test(String(p)+("cause"in p?String(p.cause):""));if(r)return Ot(this).info(`[${l}] connection ${E?"timed out":"failed"} - ${b}`),Ot(this).debug(`[${l}] connection ${E?"timed out":"failed"} (${b})`,Ms({retryOfRequestLogID:n,url:a,durationMs:h-d,message:p.message})),this.retryRequest(i,r,n??l);throw Ot(this).info(`[${l}] connection ${E?"timed out":"failed"} - error; no more retries left`),Ot(this).debug(`[${l}] connection ${E?"timed out":"failed"} (error; no more retries left)`,Ms({retryOfRequestLogID:n,url:a,durationMs:h-d,message:p.message})),p instanceof Zl||p instanceof jy?p:E?new rc:new tc({cause:p})}let m=[...p.headers.entries()].filter(([b])=>b==="x-request-id").map(([b,E])=>", "+b+": "+JSON.stringify(E)).join(""),v=`[${l}${u}${m}] ${s.method} ${a} ${p.ok?"succeeded":"failed"} with status ${p.status} in ${h-d}ms`;if(!p.ok){if(p.status===401&&this._workloadIdentityAuth&&!i.__metadata?.hasStreamingBody&&!i.__metadata?.workloadIdentityTokenRefreshed)return await a2(p.body),this._workloadIdentityAuth.invalidateToken(),this.makeRequest({...i,__metadata:{...i.__metadata,workloadIdentityTokenRefreshed:!0}},r,n??l);let b=await this.shouldRetry(p);if(r&&b){let O=`retrying, ${r} attempts remaining`;return await a2(p.body),Ot(this).info(`${v} - ${O}`),Ot(this).debug(`[${l}] response error (${O})`,Ms({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:h-d})),this.retryRequest(i,r,n??l,p.headers)}let E=b?"error; no more retries left":"error; not retryable";Ot(this).info(`${v} - ${E}`);let A=await p.text().catch(O=>By(O).message),_=Uae(A),R=_?void 0:A;throw Ot(this).debug(`[${l}] response error (${E})`,Ms({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,message:R,durationMs:Date.now()-d})),this.makeStatusError(p.status,_,R,p.headers)}return Ot(this).info(v),Ot(this).debug(`[${l}] response start`,Ms({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:h-d})),{response:p,options:i,controller:f,requestLogID:l,retryOfRequestLogID:n,startTime:d}}getAPIList(e,r,n){return this.requestAPIList(r,n&&"then"in n?n.then(i=>({method:"get",path:e,...i})):{method:"get",path:e,...n})}requestAPIList(e,r){let n=this.makeRequest(r,null,void 0);return new Wy(this,n,e)}async fetchWithAuth(e,r,n,i){if(this._workloadIdentityAuth){let s=r.headers,a=s.get("Authorization");if(!a||a===`Bearer ${F2}`){let c=await this._workloadIdentityAuth.getToken();s.set("Authorization",`Bearer ${c}`)}}return await this.fetchWithTimeout(e,r,n,i)}async fetchWithTimeout(e,r,n,i){let{signal:o,method:s,...a}=r||{},c=this._makeAbort(i);o&&o.addEventListener("abort",c,{once:!0});let l=setTimeout(c,n),u=globalThis.ReadableStream&&a.body instanceof globalThis.ReadableStream||typeof a.body=="object"&&a.body!==null&&Symbol.asyncIterator in a.body,d={signal:i.signal,...u?{duplex:"half"}:{},method:"GET",...a};s&&(d.method=s.toUpperCase());try{return await this.fetch.call(void 0,e,d)}finally{clearTimeout(l)}}async shouldRetry(e){let r=e.headers.get("x-should-retry");return r==="true"?!0:r==="false"?!1:e.status===408||e.status===409||e.status===429||e.status>=500}async retryRequest(e,r,n,i){let o,s=i?.get("retry-after-ms");if(s){let c=parseFloat(s);Number.isNaN(c)||(o=c)}let a=i?.get("retry-after");if(a&&!o){let c=parseFloat(a);Number.isNaN(c)?o=Date.parse(a)-Date.now():o=c*1e3}if(o===void 0){let c=e.maxRetries??this.maxRetries;o=this.calculateDefaultRetryTimeoutMillis(r,c)}return await Ao(o),this.makeRequest(e,r-1,n)}calculateDefaultRetryTimeoutMillis(e,r){let o=r-e,s=Math.min(.5*Math.pow(2,o),8),a=1-Math.random()*.25;return s*a*1e3}async buildRequest(e,{retryCount:r=0}={}){let n={...e},{method:i,path:o,query:s,defaultBaseURL:a}=n,c=this.buildURL(o,s,a);"timeout"in n&&$ae("timeout",n.timeout),n.timeout=n.timeout??this.timeout;let{bodyHeaders:l,body:u,isStreamingBody:d}=this.buildBody({options:n});d&&(e.__metadata={...e.__metadata,hasStreamingBody:!0});let f=await this.buildHeaders({options:e,method:i,bodyHeaders:l,retryCount:r});return{req:{method:i,headers:f,...n.signal&&{signal:n.signal},...globalThis.ReadableStream&&u instanceof globalThis.ReadableStream&&{duplex:"half"},...u&&{body:u},...this.fetchOptions??{},...n.fetchOptions??{}},url:c,timeout:n.timeout}}async buildHeaders({options:e,method:r,bodyHeaders:n,retryCount:i}){let o={};this.idempotencyHeader&&r!=="get"&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),o[this.idempotencyHeader]=e.idempotencyKey);let s=ne([o,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(i),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...Gae(),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},await this.authHeaders(e),this._options.defaultHeaders,n,e.headers]);return this.validateHeaders(s),s.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]),i=typeof globalThis.ReadableStream<"u"&&e instanceof globalThis.ReadableStream,o=!i&&(typeof e=="string"||e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof globalThis.Blob<"u"&&e instanceof globalThis.Blob||e instanceof URLSearchParams||e instanceof FormData);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e=="string"&&n.values.has("content-type")||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||i?{bodyHeaders:void 0,body:e,isStreamingBody:!o}:typeof e=="object"&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&typeof e.next=="function")?{bodyHeaders:void 0,body:HR(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}:{...L(this,SI,"f").call(this,{body:e,headers:n}),isStreamingBody:!1}}};j2=Ne,SI=new WeakMap,B2=new WeakSet,$ce=function(){return this.baseURL!=="https://api.openai.com/v1"};Ne.OpenAI=j2;Ne.DEFAULT_TIMEOUT=6e5;Ne.OpenAIError=ge;Ne.APIError=wt;Ne.APIConnectionError=tc;Ne.APIConnectionTimeoutError=rc;Ne.APIUserAbortError=Dt;Ne.NotFoundError=Dp;Ne.ConflictError=Lp;Ne.RateLimitError=Up;Ne.BadRequestError=Np;Ne.AuthenticationError=kp;Ne.InternalServerError=Fp;Ne.PermissionDeniedError=Mp;Ne.UnprocessableEntityError=$p;Ne.InvalidWebhookSignatureError=To;Ne.toFile=eI;Ne.Completions=au;Ne.Chat=ac;Ne.Embeddings=lu;Ne.Files=du;Ne.Images=mu;Ne.Audio=Io;Ne.Moderations=_u;Ne.Models=gu;Ne.FineTuning=Li;Ne.Graders=mc;Ne.VectorStores=zs;Ne.Webhooks=Eu;Ne.Beta=Di;Ne.Batches=ru;Ne.Uploads=_c;Ne.Responses=Bs;Ne.Realtime=Fs;Ne.Conversations=pc;Ne.Evals=hc;Ne.Containers=fc;Ne.Skills=js;Ne.Videos=Su;var Qn=fe("runner_codex"),z2="Codex CLI",Ah="gpt-5.6-sol";async function qze({aiGateway:t,config:e,model:r}){let n=r;if(t)if(e.modelVersionOverrides?.codex){let i=e.modelVersionOverrides?.codex?.[e.accountType];if(i){if(!await t.isModelAvailableForProvider("openai",i))throw new Error(`Model override '${i}' is not available for openai provider`);n=i}}else if(r){if(!await t.isModelAvailableForProvider("openai",r))throw new Error(`Model '${r}' is not available for openai provider`)}else!!Ah&&await t.isModelAvailableForProvider("openai",Ah)?(n=Ah,Qn.log(`Using default model: ${Ah}`)):Ah&&Qn.log(`Default model ${Ah} is not available, proceeding without model specification`);return n}var EI="netlify-ask-db",Hze=`default_permissions = "${EI}"`,Wze=t=>["",`[permissions.${EI}]`,'description = "Ask mode: read-only filesystem, network limited to the project database"','extends = ":read-only"',"",`[permissions.${EI}.network]`,"enabled = true","",`[permissions.${EI}.network.domains]`,`"${t}" = "allow"`];function Yze({aiGateway:t}){if(t){let{token:e,url:r}=t;if(!e||!r)throw new Error("No token or url provided from AI Gateway");yc.env.OPENAI_API_KEY=e,yc.env.OPENAI_BASE_URL=r}else if(!yc.env.OPENAI_API_KEY)throw new Error("OPENAI_API_KEY is not provided")}async function G2({config:t,netlify:e,persistSteps:r,sendSteps:n,aiGateway:i,continueSession:o,priorAgentSessionId:s,cwd:a=yc.cwd(),abortSignal:c,onSessionId:l,effortOverride:u}){let{prompt:d}=t,{model:f}=t;Yze({aiGateway:i});let p=await qze({config:t,aiGateway:i,model:f}),h=[],m=[],v=[],b={},E=new Set,A=0,_=0,R,I,O,C,P,$=Kf(t),y=`${yc.env.NVM_BIN}/node`,oe=xh.join(vI.homedir(),".codex"),N=xh.join(oe,"config.toml"),g=xh.join(oe,"auth.json");try{await aS.mkdir(oe,{recursive:!0});let De={OPENAI_API_KEY:yc.env.OPENAI_API_KEY};await aS.writeFile(g,JSON.stringify(De,null,2),"utf-8"),Qn.log("Created Codex auth.json file");let z=yc.env.OPENAI_BASE_URL,Ee=['forced_login_method = "api"'],W=We().questionsEnabled;$&&Ee.push(Hze),z&&Ee.push('model_provider = "openai_proxy"',"","[model_providers.openai_proxy]",'name = "OpenAI Proxy"',`base_url = "${z}"`,'env_key = "OPENAI_API_KEY"','wire_api = "responses"',"supports_websockets = false","requires_openai_auth = true"),W&&Ee.push(...Aie()),$&&Ee.push(...Wze($.host)),await aS.writeFile(N,`${Ee.join(`
|
|
299
299
|
`)}
|
|
300
300
|
`,"utf-8"),Qn.log("Wrote Codex config.toml")}catch(De){let z=De instanceof Error?De.message:String(De);throw Qn.warn("Failed to setup Codex config and credentials",{error:z}),new Error(`Codex setup failed: ${z}`)}let S=p==="gpt-5.6-sol",w=u??(S?"low":"high"),X=!!(o&&s),q="mode"in t&&t.mode==="ask",ae=!!$,Re=[Pi(a,"codex"),"exec",...q&&!ae?["--sandbox","read-only"]:[],...X?["resume",s]:[],...q?[]:["--yolo"],"--json",...u?["-c",`model_reasoning_effort="${u}"`]:S?["-c",'model_reasoning_effort="low"']:[],...p?["--model",p]:[]].filter(Boolean);Qn.log(`Running ${y} ${Re.join(" ")}`);let xe=e.utils.run(y,Re,{all:!0,cwd:a,env:{...yc.env},stdin:"pipe",idleTimeout:fs,cancelSignal:c});xe.stdin?.end(d);let $e=Na(()=>{r?.({steps:h,duration:_}),n?.({steps:m,duration:_}),m=[]},250),se=(De,z)=>{let Ee={...De,id:A};A+=1,v.push(Ee),h.push(Ee),m.push(Ee),z||$e.flush(),$e(),z&&$e.flush()};se({title:`Using ${z2} with ${p||"default"}`,category:Z.Environment},!0);let Ae=Vze.createInterface({input:xe.all});Ae.on("error",De=>{Qn.error("Readline interface error",{error:De.message,stack:De.stack})}),Ae.on("line",De=>{let z;try{z=JSON.parse(De)}catch{Qn.log("Could not parse line",De);return}if(z?.duration_ms&&(_=z.duration_ms),z?.type==="thread.started"&&typeof z?.thread_id=="string"&&(O=z.thread_id,l?.(O)),z?.type==="item.started"&&z?.item?.type==="command_execution")b[z.item.id]=z.item;else if(z?.type==="item.completed"&&z?.item?.type==="command_execution"){let Ee=z.item,W=Jze(Ee);W&&se(W,!0);let M=Ee.command?.match(/\.agents\/skills\/([^\s/]+)/)?.[1];if(M&&!E.has(M)){E.add(M);let U=_o(M);Es(Qn,U),se({title:`Use ${U}`,category:Z.Skill,type:M},!0)}}else if(z?.type==="item.completed"&&z?.item?.type==="reasoning"){let Ee={title:"Reasoning",message:z.item.text,category:Z.Reasoning};se(Ee,!0)}else if(z?.type==="item.completed"&&z?.item?.type==="agent_message")R=z.item.text;else if(z?.type==="item.started"&&z?.item?.type==="mcp_tool_call"){let Ee=z.item;if(Ee.server===Zf&&Ee.tool==="ask"&&!P){let W=Ip.safeParse(Ee.arguments);W.success?(P={questions:W.data.questions,toolUseId:Ee.id},xe.kill()):(Qn.warn("Ignoring malformed ask tool input",{toolUseId:Ee.id}),pe.inc("inference.malformed_ask",1))}}else if(z?.type==="turn.completed"&&z.usage)C={input_tokens:z.usage.input_tokens,output_tokens:z.usage.output_tokens},wa(C);else if(z?.type==="turn.failed"&&z?.error?.message)I=z.error.message;else if(z?.type==="local_shell_call"){let Ee=z;b[Ee.call_id]=Ee}else if(z?.type==="local_shell_call_output"){let Ee=z,W=b[Ee.call_id],M=Xze(W,Ee);M&&se(M,!0);let F=(W?.action?.command?.join(" ")??"").match(/\.agents\/skills\/([^\s/]+)/)?.[1];if(F&&!E.has(F)){E.add(F);let B=_o(F);Es(Qn,B),se({title:`Use ${B}`,category:Z.Skill,type:F},!0)}}else z?.type==="message"&&z.role==="assistant"?R=z.content?.map(Ee=>Ee.text).join(`
|
|
301
301
|
`):z?.type==="message"&&z.role==="system"&&(I=z.content?.map(Ee=>Ee.text).join(`
|
package/dist/bin.js
CHANGED
|
@@ -578,7 +578,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
578
578
|
`,LF:`
|
|
579
579
|
`,concatBytes:n3},lyt=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},uyt={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:lyt};import{Buffer as dyt}from"buffer";var zbe=(t,e)=>t?void 0:fyt.bind(void 0,e),fyt=function*(t,e){if(typeof e!="string"&&!Pr(e)&&!dyt.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},Vbe=(t,e)=>t?pyt.bind(void 0,e):hyt.bind(void 0,e),pyt=function*(t,e){Hbe(t,e),yield e},hyt=function*(t,e){if(Hbe(t,e),typeof e!="string"&&!Pr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},Hbe=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
580
580
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
581
|
-
if (condition) { yield value; }`)};import{Buffer as myt}from"buffer";import{StringDecoder as gyt}from"string_decoder";var gC=(t,e,r)=>{if(r)return;if(t)return{transform:_yt.bind(void 0,new TextEncoder)};let n=new gyt(e);return{transform:yyt.bind(void 0,n),final:Syt.bind(void 0,n)}},_yt=function*(t,e){myt.isBuffer(e)?yield Sc(e):typeof e=="string"?yield t.encode(e):yield e},yyt=function*(t,e){yield Pr(e)?t.write(e):e},Syt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Gbe}from"util";var s3=Gbe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),_C=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=vyt}=e[r];for await(let i of n(t))yield*_C(i,e,r+1)},Wbe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Eyt(r,Number(e),t)},Eyt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*_C(n,r,e+1)},Ybe=Gbe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),vyt=function*(t){yield t};var o3=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Kbe=(t,e)=>[...e.flatMap(r=>[...Mf(r,t,0)]),...Hb(t)],Mf=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Tyt}=e[r];for(let i of n(t))yield*Mf(i,e,r+1)},Hb=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*byt(r,Number(e),t)},byt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Mf(n,r,e+1)},Tyt=function*(t){yield t};var a3=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=Zbe(t,o,s),l=Df(e),u=Df(r),d=l?s3.bind(void 0,_C,a):o3.bind(void 0,Mf),f=l||u?s3.bind(void 0,Wbe,a):o3.bind(void 0,Hb),p=l||u?Ybe.bind(void 0,a):void 0;return{stream:new wyt({writableObjectMode:n,writableHighWaterMark:Jbe(n),readableObjectMode:i,readableHighWaterMark:Jbe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},yC=(t,e,r,n)=>{let i=e.filter(({type:o})=>o==="generator"),s=n?i.reverse():i;for(let{value:o,optionName:a}of s){let c=Zbe(o,r,a);t=Kbe(c,t)}return t},Zbe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:zbe(n,a)},gC(r,o,n),mC(r,s,n,c),{transform:t,final:e},{transform:Vbe(i,a)},Bbe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var Xbe=(t,e)=>{for(let r of Ayt(t))Ryt(t,r,e)},Ayt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Ryt=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Eu[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>xyt(a,n));r.input=Lb(o)},xyt=(t,e)=>{let r=yC(t,e,"utf8",!0);return Iyt(r),Lb(r)},Iyt=t=>{let e=t.find(r=>typeof r!="string"&&!Pr(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 Nyt,appendFileSync as kyt}from"fs";var SC=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Pg(r,n)&&!Mi.has(e)&&Oyt(n)&&(t.some(({type:i,value:s})=>i==="native"&&Pyt.has(s))||t.every(({type:i})=>Ss.has(i))),Oyt=t=>t===1||t===2,Pyt=new Set(["pipe","overlapped"]),Qbe=async(t,e,r,n)=>{for await(let i of t)Cyt(e)||tTe(i,r,n)},eTe=(t,e,r)=>{for(let n of t)tTe(n,e,r)},Cyt=t=>t._readableState.pipes.length>0,tTe=(t,e,r)=>{let n=kP(t);ta({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var rTe=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let s={},o=new Set([]);return{output:e.map((c,l)=>$yt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},$yt=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=nbe(t,s,d),p=Sc(f),{stdioItems:h,objectMode:m}=e[r],_=Lyt([p],h,c,n),{serializedResult:y,finalResult:E=y}=Dyt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});Myt({serializedResult:y,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let S=a[r]?E:void 0;try{return n.error===void 0&&Uyt(y,h,i),S}catch(g){return n.error=g,S}},Lyt=(t,e,r,n)=>{try{return yC(t,e,r,!1)}catch(i){return n.error=i,t}},Dyt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Lb(t)};let o=_Se(t,r);return n[s]?{serializedResult:o,finalResult:i3(o,!i[s],e)}:{serializedResult:o}},Myt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!SC({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=i3(t,!1,o);try{eTe(a,e,n)}catch(c){r.error??=c}},Uyt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>pC.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?kyt(n,t):(r.add(s),Nyt(n,t))}};var nTe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,bc(e,r,"all")]:Array.isArray(e)?[bc(t,r,"all"),...e]:Pr(t)&&Pr(e)?p6([t,e]):`${t}${e}`};import{once as c3}from"events";var iTe=async(t,e)=>{let[r,n]=await Fyt(t);return e.isForcefullyTerminated??=!1,[r,n]},Fyt=async t=>{let[e,r]=await Promise.allSettled([c3(t,"spawn"),c3(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?sTe(t):r.value},sTe=async t=>{try{return await c3(t,"exit")}catch{return sTe(t)}},oTe=async t=>{let[e,r]=await t;if(!jyt(e,r)&&l3(e,r))throw new to;return[e,r]},jyt=(t,e)=>t===void 0&&e===void 0,l3=(t,e)=>t!==0||e!==null;var aTe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=qyt(t,e,r),o=s?.code==="ETIMEDOUT",a=rbe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},qyt=(t,e,r)=>t!==void 0?t:l3(e,r)?new to:void 0;var cTe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=zyt(t,e,r),d=Gyt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return jg(d,c,l)},zyt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=LP(t,e,r),a=Vyt(r),{file:c,commandArguments:l,options:u}=tC(t,e,a);Hyt(u);let d=Ube(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},Vyt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Hyt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&EC("ipcInput"),t&&EC("ipc: true"),r&&EC("detached: true"),n&&EC("cancelSignal")},EC=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Gyt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=Wyt({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=aTe(c,r),{output:h,error:m=l}=rTe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((E,S)=>bc(E,r,S)),y=bc(nTe(h,r),r,"all");return Kyt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},Wyt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{Xbe(s,r);let a=Yyt(r);return Byt(...rC(t,e,a))}catch(a){return Fg({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},Yyt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:lC(e)}),Kyt=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:s,all:o,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?uC({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):Vb({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as DEt}from"events";import{spawn as MEt}from"child_process";import pTe from"process";import{once as u3,on as Jyt}from"events";var lTe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(kg({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:KP(t)}),Zyt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),Zyt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{HP(e,i);let s=Su(t,e,r),o=new AbortController;try{return await Promise.race([Xyt(s,n,o),Qyt(s,r,o),eSt(s,r,o)])}catch(a){throw $g(t),a}finally{o.abort(),GP(e,i)}},Xyt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await u3(t,"message",{signal:r});return n}for await(let[n]of Jyt(t,"message",{signal:r}))if(e(n))return n},Qyt=async(t,e,{signal:r})=>{await u3(t,"disconnect",{signal:r}),KEe(e)},eSt=async(t,e,{signal:r})=>{let[n]=await u3(t,"strict:error",{signal:r});throw BP(n,e)};import{once as dTe,on as tSt}from"events";var fTe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>d3({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),d3=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{kg({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:KP(t)}),HP(e,s);let o=Su(t,e,r),a=new AbortController,c={};return rSt(t,o,a),nSt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),iSt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},rSt=async(t,e,r)=>{try{await dTe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},nSt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await dTe(t,"strict:error",{signal:r.signal});n.error=BP(i,e),r.abort()}catch{}},iSt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of tSt(r,"message",{signal:s.signal}))uTe(o),yield c}catch{uTe(o)}finally{s.abort(),GP(e,a),n||$g(t),i&&await t}},uTe=({error:t})=>{if(t)throw t};var hTe=(t,{ipc:e})=>{Object.assign(t,gTe(t,!1,e))},mTe=()=>{let t=pTe,e=!0,r=pTe.channel!==void 0;return{...gTe(t,e,r),getCancelSignal:bve.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},gTe=(t,e,r)=>({sendMessage:QP.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:lTe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:fTe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as sSt}from"child_process";import{PassThrough as oSt,Readable as aSt,Writable as cSt,Duplex as lSt}from"stream";var _Te=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{t3(n);let a=new sSt;uSt(a,n),Object.assign(a,{readable:dSt,writable:fSt,duplex:pSt});let c=Fg({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=hSt(c,o,i);return{subprocess:a,promise:l}},uSt=(t,e)=>{let r=Gb(),n=Gb(),i=Gb(),s=Array.from({length:e.length-3},Gb),o=Gb(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},Gb=()=>{let t=new oSt;return t.end(),t},dSt=()=>new aSt({read(){}}),fSt=()=>new cSt({write(){}}),pSt=()=>new lSt({read(){},write(){}}),hSt=async(t,e,r)=>jg(t,e,r);import{createReadStream as yTe,createWriteStream as STe}from"fs";import{Buffer as mSt}from"buffer";import{Readable as Wb,Writable as gSt,Duplex as _St}from"stream";var vTe=(t,e)=>hC(ySt,t,e,!1),Yb=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Eu[t]}.`)},ETe={fileNumber:Yb,generator:a3,asyncGenerator:a3,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:_St.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},ySt={input:{...ETe,fileUrl:({value:t})=>({stream:yTe(t)}),filePath:({value:{file:t}})=>({stream:yTe(t)}),webStream:({value:t})=>({stream:Wb.fromWeb(t)}),iterable:({value:t})=>({stream:Wb.from(t)}),asyncIterable:({value:t})=>({stream:Wb.from(t)}),string:({value:t})=>({stream:Wb.from(t)}),uint8Array:({value:t})=>({stream:Wb.from(mSt.from(t))})},output:{...ETe,fileUrl:({value:t})=>({stream:STe(t)}),filePath:({value:{file:t,append:e}})=>({stream:STe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:gSt.fromWeb(t)}),iterable:Yb,asyncIterable:Yb,string:Yb,uint8Array:Yb}};import{on as SSt,once as bTe}from"events";import{PassThrough as ESt,getDefaultHighWaterMark as vSt}from"stream";import{finished as ATe}from"stream/promises";function Uf(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)p3(i);let e=t.some(({readableObjectMode:i})=>i),r=bSt(t,e),n=new f3({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var bSt=(t,e)=>{if(t.length===0)return vSt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},f3=class extends ESt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(p3(e),this.#e.has(e))return;this.#e.add(e),this.#n??=TSt(this,this.#e,this.#s);let r=RSt({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#s});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(p3(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},TSt=async(t,e,r)=>{vC(t,TTe);let n=new AbortController;try{await Promise.race([wSt(t,n),ASt(t,e,r,n)])}finally{n.abort(),vC(t,-TTe)}},wSt=async(t,{signal:e})=>{try{await ATe(t,{signal:e,cleanup:!0})}catch(r){throw RTe(t,r),r}},ASt=async(t,e,r,{signal:n})=>{for await(let[i]of SSt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},p3=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},RSt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{vC(t,wTe);let a=new AbortController;try{await Promise.race([xSt(s,e,a),ISt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),OSt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),vC(t,-wTe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?h3(t):PSt(t))},xSt=async(t,e,{signal:r})=>{try{await t,r.aborted||h3(e)}catch(n){r.aborted||RTe(e,n)}},ISt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await ATe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;xTe(o)?i.add(e):ITe(t,o)}},OSt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await bTe(t,i,{signal:s}),!t.readable)return bTe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},PSt=t=>{t.writable&&t.end()},RTe=(t,e)=>{xTe(e)?h3(t):ITe(t,e)},xTe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",h3=t=>{(t.readable||t.writable)&&t.destroy()},ITe=(t,e)=>{t.destroyed||(t.once("error",CSt),t.destroy(e))},CSt=()=>{},vC=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},TTe=2,wTe=1;import{finished as OTe}from"stream/promises";var Bg=(t,e)=>{t.pipe(e),NSt(t,e),kSt(t,e)},NSt=async(t,e)=>{if(!(eo(t)||eo(e))){try{await OTe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}m3(e)}},m3=t=>{t.writable&&t.end()},kSt=async(t,e)=>{if(!(eo(t)||eo(e))){try{await OTe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}g3(t)}},g3=t=>{t.readable&&t.destroy()};var PTe=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:s,direction:o}]of Object.entries(e)){for(let{stream:a}of s.filter(({type:c})=>Ss.has(c)))$St(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Ss.has(c)))DSt({subprocess:t,stream:a,direction:o,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,s]of n.entries()){let o=s.length===1?s[0]:Uf(s);Bg(o,i)}},$St=(t,e,r,n)=>{r==="output"?Bg(t.stdio[n],e):Bg(e,t.stdio[n]);let i=LSt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},LSt=["stdin","stdout","stderr"],DSt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;MSt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},MSt=(t,{signal:e})=>{eo(t)&&$f(t,USt,e)},USt=2;import{addAbortListener as qSt}from"events";var Ff=[];Ff.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Ff.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Ff.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var bC=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",_3=Symbol.for("signal-exit emitter"),y3=globalThis,FSt=Object.defineProperty.bind(Object),S3=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(y3[_3])return y3[_3];FSt(y3,_3,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let s of this.listeners[e])i=s(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},TC=class{},jSt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),E3=class extends TC{onExit(){return()=>{}}load(){}unload(){}},v3=class extends TC{#e=b3.platform==="win32"?"SIGINT":"SIGHUP";#r=new S3;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Ff)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,s=e;if(typeof s.__signal_exit_emitter__=="object"&&typeof s.__signal_exit_emitter__.count=="number"&&(i+=s.__signal_exit_emitter__.count),n.length===i){this.unload();let o=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;o||e.kill(e.pid,a)}};this.#s=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!bC(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 Ff)try{let r=this.#i[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#o&&(this.#o=!1,Ff.forEach(e=>{let r=this.#i[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#s,this.#r.count-=1)}#a(e){return bC(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#s.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&bC(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let i=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),i}else return n.call(this.#t,e,...r)}},b3=globalThis.process,{onExit:CTe,load:ecr,unload:tcr}=jSt(bC(b3)?new v3(b3):new E3);var NTe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=CTe(()=>{t.kill()});qSt(n,()=>{i()})};var $Te=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=$P(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=BSt(r,n,i),{sourceStream:d,sourceError:f}=VSt(t,l),{options:p,fileDescriptors:h}=na.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},BSt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=zSt(t,e,...r),a=VP(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},zSt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(kTe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||d6(r)){if(Object.keys(t).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[i,s,o]=wP(r,...n);return{destination:e(kTe)(i,s,o),pipeOptions:o}}if(na.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}`)},kTe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),VSt=(t,e)=>{try{return{sourceStream:Lg(t,e)}}catch(r){return{sourceError:r}}};var DTe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=HSt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw T3({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},HSt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return g3(t),n;if(e!==void 0)return m3(r),e},T3=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Fg({error:t,command:LTe,escapedCommand:LTe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),LTe="source.pipe(destination)";var MTe=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:s,value:o=s}]=await t;if(o.pipedFrom.includes(n)||o.pipedFrom.push(n),i==="rejected")throw o;if(e==="rejected")throw n;return o};import{finished as GSt}from"stream/promises";var UTe=(t,e,r)=>{let n=wC.has(e)?YSt(t,e):WSt(t,e);return $f(t,JSt,r.signal),$f(e,ZSt,r.signal),KSt(e),n},WSt=(t,e)=>{let r=Uf([t]);return Bg(r,e),wC.set(e,r),r},YSt=(t,e)=>{let r=wC.get(e);return r.add(t),r},KSt=async t=>{try{await GSt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}wC.delete(t)},wC=new WeakMap,JSt=2,ZSt=1;import{aborted as XSt}from"util";var FTe=(t,e)=>t===void 0?[]:[QSt(t,e)],QSt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await XSt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw T3({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var AC=(t,...e)=>{if(gr(e[0]))return AC.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=$Te(t,...e),i=eEt({...n,destination:r});return i.pipe=AC.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},eEt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=tEt(t,i);DTe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=UTe(e,s,d);return await Promise.race([MTe(u),...FTe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},tEt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as cEt}from"timers/promises";import{on as rEt}from"events";import{getDefaultHighWaterMark as nEt}from"stream";var RC=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return iEt(e,o),qTe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},iEt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},w3=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;sEt(e,o,t);let a=t.readableObjectMode&&!s;return qTe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},sEt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},qTe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=rEt(t,"data",{signal:e.signal,highWaterMark:jTe,highWatermark:jTe});return oEt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},A3=nEt(!0),jTe=A3,oEt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=aEt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Mf(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Hb(a)}},aEt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[gC(t,r,!e),mC(t,i,!n,{})].filter(Boolean);var BTe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=lEt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([uEt(t),d]);return}let f=r3(c,r),p=w3({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([dEt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},lEt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!SC({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=w3({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Qbe(a,t,r,s)},uEt=async t=>{await cEt(),t.readableFlowing===null&&t.resume()},dEt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await oC(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await aC(r,{maxBuffer:s})):await Ug(r,{maxBuffer:s})}catch(a){return zTe(Qve({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},R3=async t=>{try{return await t}catch(e){return zTe(e)}},zTe=({bufferedData:t})=>mSe(t)?new Uint8Array(t):t;import{finished as fEt}from"stream/promises";var Kb=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=pEt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],fEt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||gEt(a,e,r,n)}finally{o.abort()}},pEt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&hEt(t,r,n),n},hEt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{mEt(e,r),n.call(t,...i)}},mEt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},gEt=(t,e,r,n)=>{if(!_Et(t,e,r,n))throw t},_Et=(t,e,r,n=!0)=>r.propagating?VTe(t)||xC(t):(r.propagating=!0,x3(r,e)===n?VTe(t):xC(t)),x3=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",xC=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",VTe=t=>t?.code==="EPIPE";var HTe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>I3({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),I3=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=Kb(t,e,l);if(x3(l,e)){await u;return}let[d]=await Promise.all([BTe({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var GTe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Uf([t,e].filter(Boolean)):void 0,WTe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>I3({...yEt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:SEt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),yEt=({stdout:t,stderr:e,all:r},[,n,i])=>{let s=n||i;return s?n?i?{stream:r,buffer:s}:{stream:t,buffer:s}:{stream:e,buffer:s}:{stream:r,buffer:s}},SEt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as EEt}from"events";var YTe=t=>Pg(t,"ipc"),KTe=(t,e)=>{let r=kP(t);ta({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var JTe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=YTe(s),a=Ec(e,"ipc"),c=Ec(r,"ipc");for await(let l of d3({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(ebe(t,i,c),i.push(l)),o&&KTe(l,s);return i},ZTe=async(t,e)=>(await Promise.allSettled([t]),e);var XTe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:_,controller:y})=>{let E=iTe(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:E,propagating:!1},g=HTe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),w=WTe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),P=[],x=JTe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:P,verboseInfo:p}),A=vEt(m,t,S),O=bEt(h,S);try{return await Promise.race([Promise.all([{},oTe(E),Promise.all(g),w,x,Nve(t,d),...A,...O]),_,TEt(t,y),...xve(t,s,f,y),...YEe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...Ave({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(R){return f.terminationReason??="other",Promise.all([{error:R},E,Promise.all(g.map(b=>R3(b))),R3(w),ZTe(x,P),Promise.allSettled(A),Promise.allSettled(O)])}},vEt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:Kb(n,i,r)),bEt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>no(s,{checkOpen:!1})&&!eo(s)).map(({type:i,value:s,stream:o=s})=>Kb(o,n,e,{isSameDirection:Ss.has(i),stopOnExit:i==="native"}))),TEt=async(t,{signal:e})=>{let[r]=await EEt(t,"error",{signal:e});throw r};var QTe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),Jb=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=ra();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},zg=async({resolve:t,promises:e},r)=>{t();let[n]=await Promise.race([Promise.allSettled([!0,r]),Promise.all([!1,...e])]);return!n};import{Readable as wEt}from"stream";import{callbackify as AEt}from"util";import{finished as ewe}from"stream/promises";var O3=async t=>{if(t!==void 0)try{await P3(t)}catch{}},twe=async t=>{if(t!==void 0)try{await C3(t)}catch{}},P3=async t=>{await ewe(t,{cleanup:!0,readable:!1,writable:!0})},C3=async t=>{await ewe(t,{cleanup:!0,readable:!0,writable:!1})},IC=async(t,e)=>{if(await t,e)throw e},OC=(t,e,r)=>{r&&!xC(r)?t.destroy(r):e&&t.destroy()};var rwe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||Mi.has(r),{subprocessStdout:a,waitReadableDestroy:c}=N3(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=k3(a,o),{read:f,onStdoutDataDone:p}=$3({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new wEt({read:f,destroy:AEt(D3.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return L3({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},N3=(t,e,r)=>{let n=Lg(t,e),i=Jb(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},k3=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:A3},$3=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=ra(),o=RC({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){REt(this,o,s)},onStdoutDataDone:s}},REt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},L3=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await C3(t),await n,await O3(i),await e,r.readable&&r.push(null)}catch(s){await O3(i),nwe(r,s)}},D3=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await zg(r,e)&&(nwe(t,n),await IC(e,n))},nwe=(t,e)=>{OC(t,t.readable,e)};import{Writable as xEt}from"stream";import{callbackify as iwe}from"util";var swe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=M3(t,r,e),o=new xEt({...U3(n,t,i),destroy:iwe(j3.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return F3(n,o),o},M3=(t,e,r)=>{let n=VP(t,e),i=Jb(r,n,"writableFinal"),s=Jb(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},U3=(t,e,r)=>({write:IEt.bind(void 0,t),final:iwe(OEt.bind(void 0,t,e,r))}),IEt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},OEt=async(t,e,r)=>{await zg(r,e)&&(t.writable&&t.end(),await e)},F3=async(t,e,r)=>{try{await P3(t),e.writable&&e.end()}catch(n){await twe(r),owe(e,n)}},j3=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await zg(r,e),await zg(n,e)&&(owe(t,i),await IC(e,i))},owe=(t,e)=>{OC(t,t.writable,e)};import{Duplex as PEt}from"stream";import{callbackify as CEt}from"util";var awe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||Mi.has(r),{subprocessStdout:c,waitReadableDestroy:l}=N3(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=M3(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=k3(c,a),{read:_,onStdoutDataDone:y}=$3({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),E=new PEt({read:_,...U3(u,t,d),destroy:CEt(NEt.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return L3({subprocessStdout:c,onStdoutDataDone:y,readable:E,subprocess:t,subprocessStdin:u}),F3(u,E,c),E},NEt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([D3({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),j3({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var q3=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||Mi.has(e),o=Lg(t,r),a=RC({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return kEt(a,o,t)},kEt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var cwe=(t,{encoding:e})=>{let r=QTe();t.readable=rwe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=swe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=awe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=q3.bind(void 0,t,e),t[Symbol.asyncIterator]=q3.bind(void 0,t,e,{})};var lwe=(t,e)=>{for(let[r,n]of LEt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},$Et=(async()=>{})().constructor.prototype,LEt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor($Et,t)]);var uwe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=UEt(t,e,r),{subprocess:f,promise:p}=jEt({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=AC.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),lwe(f,p),na.set(f,{options:u,fileDescriptors:d}),f},UEt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=LP(t,e,r),{file:a,commandArguments:c,options:l}=tC(t,e,r),u=FEt(l),d=vTe(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},FEt=({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}},jEt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=MEt(...rC(t,e,r))}catch(h){return _Te({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;DEt(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];PTe(c,a,l),NTe(c,r,l);let d={},f=ra();c.kill=GEe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=GTe(c,r),cwe(c,r),hTe(c,r);let p=qEt({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:s,escapedCommand:o,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},qEt=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:s,command:o,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,_]=await XTe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:l,controller:u});u.abort(),l.resolve();let y=h.map((g,w)=>bc(g,e,w)),E=bc(m,e,"all"),S=BEt({errorInfo:d,exitCode:f,signal:p,stdio:y,all:E,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return jg(S,n,e)},BEt=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,context:o,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?Vb({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 ia,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):uC({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var PC=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,zEt(n,t[n],i)]));return{...t,...r}},zEt=(t,e,r)=>VEt.has(t)&&gr(e)&&gr(r)?{...e,...r}:r,VEt=new Set(["env",..._6]);var vu=(t,e,r,n)=>{let i=(o,a,c)=>vu(o,a,r,c),s=(...o)=>HEt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},HEt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(gr(s))return i(t,PC(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=GEt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?cTe(a,c,l):uwe(a,c,l,i)},GEt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=vSe(e)?bSe(e,r):[e,...r],[o,a,c]=wP(...s),l=PC(PC(n,i),c),{file:u=o,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:o,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var dwe=({file:t,commandArguments:e})=>pwe(t,e),fwe=({file:t,commandArguments:e})=>({...pwe(t,e),isSync:!0}),pwe=(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]=WEt(t);return{file:r,commandArguments:n}},WEt=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(YEt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},YEt=/ +/g;var hwe=(t,e,r)=>{t.sync=e(KEt,r),t.s=t.sync},mwe=({options:t})=>gwe(t),KEt=({options:t})=>({...gwe(t),isSync:!0}),gwe=t=>({options:{...JEt(t),...t}}),JEt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},_we={preferLocal:!0};var ywe=vu(()=>({})),Vur=vu(()=>({isSync:!0})),Swe=vu(dwe),Hur=vu(fwe),Gur=vu(Ove),Wur=vu(mwe,{},_we,hwe),{sendMessage:Yur,getOneMessage:Kur,getEachMessage:Jur,getCancelSignal:Zur}=mTe();import{Transform as ZEt}from"stream";var XEt=["NETLIFY_AI_GATEWAY_KEY"];function QEt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...XEt])]}function evt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function tvt(){let e=QEt().map(r=>process.env[r]).filter(r=>!(!r||evt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Es(t){if(typeof t!="string")return t;let e=tvt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(rvt(n),"g");r=r.replace(i,"******")}),r}function rvt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Zb=class extends ZEt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Es(i);n(null,s)}},CC=Symbol("maskedWrite");function Ewe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[CC]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Es(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[CC]=!0,process.stdout.write=r}if(!process.stderr.write[CC]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Es(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[CC]=!0,process.stderr.write=r}}}var vwe=!1,bwe=()=>{vwe=!0},_i=()=>vwe;var Xb=null,Twe=t=>(Xb&&Xb.destroy(),Xb=new Tc({totalAllowedTime:t}),Xb),wwe=()=>Xb;var Tc=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&_i())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let s=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),o=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await bP({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{be.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),s(),o&&clearTimeout(o)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var Awe={name:"@netlify/agent-runner-cli",type:"module",version:"1.150.0-ex-2643.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.2","@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.219","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.1.5","@netlify/otel":"^6.0.4","@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",zod:"^4.4.3"}};var ovt=ivt(import.meta.url),avt=wc.dirname(ovt),cvt=svt(import.meta.url),Vg=Ee("shell"),B3=new Set,Rwe={preferLocal:!0},Hn=(t,e,r)=>{let[n,i]=lvt(e,r),s={...Rwe,...i},o=ywe(t,n,s);Iwe(o,s),Cwe(o);let a=r?.idleTimeout;return a&&a>0&&Pwe(o,a),o},xwe=(t,e)=>{let r={...Rwe,...e},n=Swe(t,r);return Iwe(n,r),Cwe(n),e?.idleTimeout&&e.idleTimeout>0&&Pwe(n,e.idleTimeout),n},lvt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},Iwe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(Ac.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Zb).pipe(Ac.stdout),t.stderr?.pipe(new Zb).pipe(Ac.stderr);return}t.stdout?.pipe(Ac.stdout),t.stderr?.pipe(Ac.stderr)},z3=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Ac.kill(-t.pid,e),Vg.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Vg.error("Error killing process:",r),!1}},Owe=t=>z3(t,"SIGKILL"),Pwe=(t,e)=>{let r=null,n=()=>{Vg.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),z3(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Vg.log(`Force killing idle process ${t.pid}`),Owe(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let s=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",s),t.on("error",s)},Cwe=t=>{B3.add(t);let e=wwe();if(e){let r=e.onTimesUp(()=>{Vg.log(`Global timer expired, killing process ${t.pid}`),z3(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Vg.log(`Force killing process ${t.pid} after timeout`),Owe(t))},5e3)});t.on("exit",()=>{B3.delete(t),r()}),t.on("error",()=>{B3.delete(t),r()})}};function oa(t,e){if(!Ac.env.NETLIFY_LOCAL_MODE)try{let i=cvt.resolve(Awe.name),s=wc.dirname(i);for(;s!==wc.dirname(s);){let o=wc.dirname(s);if(wc.basename(o)==="node_modules"){let a=wc.join(o,".bin",e);if(NC.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(Ac.env.NODE_PATH){let i=wc.join(Ac.env.NODE_PATH,".bin",e);if(NC.existsSync(i))return i}let r=wc.join(t,"node_modules",".bin",e);if(NC.existsSync(r))return r;let n=wc.join(avt,"..","node_modules",".bin",e);if(NC.existsSync(n))return n}import KL from"process";import{fileURLToPath as w$t}from"url";import{createRequire as A$t}from"module";import JL from"path";var uvt="__netlify__getTracer",dvt="__netlify__shutdownTracers",mt=(t,e)=>globalThis[uvt]?.(t,e),Nwe=async()=>globalThis[dvt]?.();function jf(t,e,r,n,i){let s=typeof n=="function"?n:typeof r=="function"?r:i;if(!s)throw new Error("function to execute with active span is missing");return t?t.withActiveSpan(e,r,n,s):s()}import{setTimeout as y$t}from"timers/promises";Ne();import kTt from"process";Ne();var Lvt=(t,e)=>{e.recordException(t),e.setStatus({code:xn.ERROR})};var Ic=class{constructor(e){this._tracer=e,this.startSpan=e.startSpan.bind(this._tracer),this.startActiveSpan=e.startActiveSpan.bind(this._tracer)}withActiveSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=A0e(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>R0e(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=A0e(r,n,i),c=this._tracer.startSpan(e,s,o);return R0e(c,s,a)}};function A0e(t,e,r){let n,i,s;return!e&&!r?s=t:r?(n=t,i=e,s=r):(n=t,s=e),n=n??{},i=i??Ut.active(),{opts:n,ctx:i,fn:s}}function R0e(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:Lvt,s=o=>{throw i(o,t),t.end(),o};try{let o=r(t);return typeof o?.then=="function"?o.then(a=>(t.end(),a),s):(t.end(),o)}catch(o){throw s(o)}}Ne();var Zg=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var TW=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=D0e(e),n._asyncAttributesPending=e.filter(([i,s])=>Zg(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(Zg(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=D0e(this._rawAttributes),this._schemaUrl=Dvt(r?.schemaUrl)}get asyncAttributesPending(){return this._asyncAttributesPending}async waitForAsyncAttributes(){if(this.asyncAttributesPending){for(let e=0;e<this._rawAttributes.length;e++){let[r,n]=this._rawAttributes[e];this._rawAttributes[e]=[r,Zg(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&ae.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(Zg(n)){ae.debug(`Unsettled resource attribute ${r} skipped`);continue}n!=null&&(e[r]??=n)}return this._asyncAttributesPending||(this._memoizedAttributes=e),e}getRawAttributes(){return this._rawAttributes}get schemaUrl(){return this._schemaUrl}merge(e){if(e==null)return this;let r=Mvt(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function wW(t,e){return TW.FromAttributeList(Object.entries(t),e)}function D0e(t){return t.map(([e,r])=>Zg(r)?[e,r.catch(n=>{ae.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function Dvt(t){if(typeof t=="string"||t===void 0)return t;ae.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function Mvt(t,e){let r=t?.schemaUrl,n=e?.schemaUrl,i=r===void 0||r==="",s=n===void 0||n==="";if(i)return n;if(s||r===n)return r;ae.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}Ne();var uT=class{emit(e){}enabled(){return!1}},M0e=new uT;var dT=Symbol.for("io.opentelemetry.js.api.logs"),Xg=globalThis;function U0e(t,e,r){return n=>n===t?e:r}var AW=1;var RW=class{getLogger(e,r,n){return new uT}},tN=new RW;var rN=class{constructor(e,r,n,i){this._provider=e,this.name=r,this.version=n,this.options=i}emit(e){this._getLogger().emit(e)}enabled(e){return this._getLogger().enabled(e)}_getLogger(){if(this._delegate)return this._delegate;let e=this._provider._getDelegateLogger(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):M0e}};var fT=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new rN(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:tN}_setDelegate(e){this._delegate=e}_getDelegateLogger(e,r,n){var i;return(i=this._delegate)===null||i===void 0?void 0:i.getLogger(e,r,n)}};var nN=class t{constructor(){this._proxyLoggerProvider=new fT}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return Xg[dT]?this.getLoggerProvider():(Xg[dT]=U0e(AW,e,tN),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=Xg[dT])===null||e===void 0?void 0:e.call(Xg,AW))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete Xg[dT],this._proxyLoggerProvider=new fT}};var F0e=nN.getInstance();function j0e(t,e,r,n){for(let i=0,s=t.length;i<s;i++){let o=t[i];e&&o.setTracerProvider(e),r&&o.setMeterProvider(r),n&&o.setLoggerProvider&&o.setLoggerProvider(n),o.getConfig().enabled||o.enable()}}function q0e(t){t.forEach(e=>e.disable())}function xW(t){let e=t.tracerProvider||Bt.getTracerProvider(),r=t.meterProvider||lT.getMeterProvider(),n=t.loggerProvider||F0e.getLoggerProvider(),i=t.instrumentations?.flat()??[];return j0e(i,e,r,n),()=>{q0e(i)}}kc();var fk=$n(OY(),1);Ne();kc();var LIe=t=>{throw TypeError(t)},kY=(t,e,r)=>e.has(t)||LIe("Cannot "+r),dk=(t,e,r)=>(kY(t,e,"read from private field"),r?r.call(t):e.get(t)),PY=(t,e,r)=>e.has(t)?LIe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),NIe=(t,e,r,n)=>(kY(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),NTt=(t,e,r)=>(kY(t,e,"access private method"),r),kIe="__netlify__getTracer",$Tt="__netlify__shutdownTracers",LTt="__nfOTLPTrace",NT,kT,NY,DIe,DTt=class{constructor(){PY(this,NY),PY(this,NT),PY(this,kT),NIe(this,NT,new n_(NTt(this,NY,DIe),this)),NIe(this,kT,ae.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(dk(this,kT).debug(`export ${t.length.toString()} spans`),dk(this,NT).isCalled){e({code:Wn.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(LTt,JSON.stringify(MTt(t))),e({code:Wn.SUCCESS})}shutdown(){return dk(this,NT).call()}};NT=new WeakMap;kT=new WeakMap;NY=new WeakSet;DIe=function(){return dk(this,kT).debug("Shutting down"),Promise.resolve()};function MTt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:uk(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||io.SERVER,startTimeUnixNano:CY(e.startTime),endTimeUnixNano:CY(e.endTime),attributes:uk(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:CY(n.time),attributes:uk(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:uk(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function uk(t){return Object.keys(t).map(e=>MIe(e,t[e]))}function MIe(t,e){return{key:t,value:UIe(e)}}function UIe(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(UIe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>MIe(r,n))}}:{}}function CY(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var $Ie={name:"@netlify/otel",version:"6.0.4",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.7",msw:"^2.10.5","npm-run-all2":"^7.0.2",tsup:"^8.0.0",vitest:"^3.0.0"},dependencies:{"@opentelemetry/api":"1.9.1","@opentelemetry/core":"2.7.1","@opentelemetry/instrumentation":"^0.220.0","@opentelemetry/resources":"2.9.0","@opentelemetry/sdk-trace-node":"2.9.0"}},FIe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,kIe))return;let e=kTt.version.slice(1),r=wW({"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??[UTt()],i=new fk.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new Nc});let s=t.instrumentations??[];xW({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,kIe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new Ic(Bt.getTracer(a,c)):new Ic(Bt.getTracer($Ie.name,$Ie.version))}}),Object.defineProperty(globalThis,$Tt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},UTt=()=>new fk.SimpleSpanProcessor(new DTt);Ne();kc();var $T=$n(OY(),1);Ne();import*as pk from"diagnostics_channel";var jIe=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?xn.ERROR:xn.UNSET})}prepareHeaders(t,e){if(!Array.isArray(e))return{};if(this.config.skipHeaders===!0)return{};let r=["*","/.*/"],n=this.config.skipHeaders??[],i=this.config.redactHeaders??[],s=n.some(a=>r.includes(a.toString())),o={};if(s)return o;for(let a=0;a+1<e.length;a=a+2){let c=e[a],l=e[a+1];if(typeof c!="string"&&!Buffer.isBuffer(c)||typeof l!="string"&&!Buffer.isBuffer(l))continue;let u=c.toString().toLowerCase();if(n.some(f=>typeof f=="string"?f==u:f.test(u)))continue;let d=`http.${t}.header.${u}`;i===!0||i.some(f=>typeof f=="string"?f==u:f.test(u))?o[d]="REDACTED":o[d]=l.toString()}return o}getRequestMethod(t){return["HEAD","GET","POST","PUT","PATCH","DELETE"].includes(t.toUpperCase())?t.toUpperCase():"_OTHER"}getTracer(){if(!this.provider)return;let t=this.provider.getTracer(this.instrumentationName,this.instrumentationVersion);return t instanceof Ic?t:new Ic(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){pk.subscribe(t,e);let r=()=>pk.unsubscribe(t,e);this._channelSubs.push({name:t,unsubscribe:r})}disable(){this._channelSubs.forEach(t=>{t.unsubscribe()}),this._channelSubs.length=0}onRequestCreate({request:t}){try{let e=this.getTracer(),r=new URL(t.path,t.origin);if(!e||t.method==="CONNECT"||this.config.skipURLs?.some(i=>typeof i=="string"?r.href.startsWith(i):i.test(r.href)))return;let n=e.startSpan(this.getRequestMethod(t.method),{kind:io.CLIENT},Ut.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:xn.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 XLe=$n(JLe(),1);var WL=Ee("tracing"),ZLe=8e3,S$t=5e3,Ww=async(t=S$t)=>{try{await Promise.race([Nwe(),y$t(t)])}catch(e){WL.warn("Failed to flush tracers on shutdown",e)}},QLe=async(t,e,r)=>{if(!mt()){let n=[new $T.SimpleSpanProcessor(new _J),new $T.SimpleSpanProcessor(new XLe.OTLPTraceExporter({url:r.exporterUrl}))];await FIe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new jIe({skipHeaders:!0})]})}return r.traceparent?(Gn.setGlobalPropagator(new Nc),Gn.extract(Ut.active(),{traceparent:r.traceparent,isRemote:!0})):Ut.active()};function Vt(t,e,r){return WL.log(`\u23F3 TRACE: ${e} starting...`),jf(t,e,r)}var _J=class{export(e,r){for(let n of e)this.logSpan(n);r({code:1})}async shutdown(){}forceFlush(){return Promise.resolve()}logSpan(e){let r=(e.endTime[0]-e.startTime[0])*1e3+(e.endTime[1]-e.startTime[1])/1e6,n=e.attributes,i=[];for(let[a,c]of Object.entries(n))a.includes("duration")&&typeof c=="number"?i.push(`${a}=${c.toFixed(2)}ms`):i.push(`${a}=${c}`);let s=e.status?.code===2?"\u274C":"\u2705",o=i.length>0?` [${i.join(", ")}]`:"";WL.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&WL.log(` \u274C Error: ${e.status.message}`)}};function yJ(){return nt().captureLlmContentEnabled}function eDe(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function YL(t,e,r){let n={role:t,parts:[{type:"text",content:Es(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}function tDe(t,e,r,n){if(!t.length)return;let i=mt();if(!i)return;let s=yJ(),o=Math.max(1,(n-r)/t.length);t.forEach((a,c)=>{let l=Math.min(n,r+c*o),u=Math.min(n,l+o),d=a.title||a.type||`step-${a.id??c}`,f=a.type==="tool_use"||a.type==="tool_result",p=a.message?a.message.length>ZLe?`${a.message.slice(0,ZLe)}\u2026`:a.message:void 0;i.startSpan(d,{startTime:l,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":d,"gen_ai.operation.name":f?"execute_tool":"chat",...f?{"gen_ai.tool.name":d}:{},"spark.step.id":a.id??-1,...a.type?{"spark.step.type":a.type}:{},...a.category?{"spark.step.category":a.category}:{},...a.groupId?{"spark.step.group_id":a.groupId}:{},...a.parentGroupId?{"spark.step.parent_group_id":a.parentGroupId}:{},...s&&p?f?{"gen_ai.tool.call.result":Es(p)}:{"gen_ai.output.messages":YL("assistant",p)}:{}}}).end(u)})}import{readdir as E$t,rm as v$t}from"fs/promises";import{join as b$t}from"path";async function rDe(t,e=[]){let n=(await E$t(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>v$t(b$t(t,i),{recursive:!0,force:!0})))}var T$t=700,nDe=t=>t.mode==="create"&&(t.accountType===vl||t.enforcedAICreditsRemaining!=null&&t.enforcedAICreditsRemaining<=T$t);var R$t=JL.dirname(w$t(import.meta.url)),iDe=A$t(import.meta.url),x$t=JL.resolve(R$t,"scripts/scaffold.js"),I$t="scripts/scaffold.js",O$t=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,SJ=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},P$t=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),C$t=t=>{let e=SJ(t);return e==="node"||e.endsWith("/node")},el=t=>{if(typeof t!="string")return!1;let e=t.match(O$t)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&P$t(SJ(e[r]));)r+=1;if(r>=e.length||!C$t(e[r]))return!1;let n=e[r+1];return n?SJ(n).includes(I$t):!1},ly=Ee("create_stage"),sDe="Do not run local validation or dev-server commands to check your work \u2014 specifically `tsc`, `npx tsc`, `vite build`, `vite dev`, or any equivalent build/start/test command. The build pipeline installs and validates the project automatically after your edits. Verify your changes by reading the files you edited.",N$t=`${sDe}
|
|
581
|
+
if (condition) { yield value; }`)};import{Buffer as myt}from"buffer";import{StringDecoder as gyt}from"string_decoder";var gC=(t,e,r)=>{if(r)return;if(t)return{transform:_yt.bind(void 0,new TextEncoder)};let n=new gyt(e);return{transform:yyt.bind(void 0,n),final:Syt.bind(void 0,n)}},_yt=function*(t,e){myt.isBuffer(e)?yield Sc(e):typeof e=="string"?yield t.encode(e):yield e},yyt=function*(t,e){yield Pr(e)?t.write(e):e},Syt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Gbe}from"util";var s3=Gbe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),_C=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=vyt}=e[r];for await(let i of n(t))yield*_C(i,e,r+1)},Wbe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Eyt(r,Number(e),t)},Eyt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*_C(n,r,e+1)},Ybe=Gbe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),vyt=function*(t){yield t};var o3=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Kbe=(t,e)=>[...e.flatMap(r=>[...Mf(r,t,0)]),...Hb(t)],Mf=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Tyt}=e[r];for(let i of n(t))yield*Mf(i,e,r+1)},Hb=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*byt(r,Number(e),t)},byt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Mf(n,r,e+1)},Tyt=function*(t){yield t};var a3=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=Zbe(t,o,s),l=Df(e),u=Df(r),d=l?s3.bind(void 0,_C,a):o3.bind(void 0,Mf),f=l||u?s3.bind(void 0,Wbe,a):o3.bind(void 0,Hb),p=l||u?Ybe.bind(void 0,a):void 0;return{stream:new wyt({writableObjectMode:n,writableHighWaterMark:Jbe(n),readableObjectMode:i,readableHighWaterMark:Jbe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},yC=(t,e,r,n)=>{let i=e.filter(({type:o})=>o==="generator"),s=n?i.reverse():i;for(let{value:o,optionName:a}of s){let c=Zbe(o,r,a);t=Kbe(c,t)}return t},Zbe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:zbe(n,a)},gC(r,o,n),mC(r,s,n,c),{transform:t,final:e},{transform:Vbe(i,a)},Bbe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var Xbe=(t,e)=>{for(let r of Ayt(t))Ryt(t,r,e)},Ayt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Ryt=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Eu[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>xyt(a,n));r.input=Lb(o)},xyt=(t,e)=>{let r=yC(t,e,"utf8",!0);return Iyt(r),Lb(r)},Iyt=t=>{let e=t.find(r=>typeof r!="string"&&!Pr(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 Nyt,appendFileSync as kyt}from"fs";var SC=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Pg(r,n)&&!Mi.has(e)&&Oyt(n)&&(t.some(({type:i,value:s})=>i==="native"&&Pyt.has(s))||t.every(({type:i})=>Ss.has(i))),Oyt=t=>t===1||t===2,Pyt=new Set(["pipe","overlapped"]),Qbe=async(t,e,r,n)=>{for await(let i of t)Cyt(e)||tTe(i,r,n)},eTe=(t,e,r)=>{for(let n of t)tTe(n,e,r)},Cyt=t=>t._readableState.pipes.length>0,tTe=(t,e,r)=>{let n=kP(t);ta({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var rTe=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let s={},o=new Set([]);return{output:e.map((c,l)=>$yt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},$yt=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=nbe(t,s,d),p=Sc(f),{stdioItems:h,objectMode:m}=e[r],_=Lyt([p],h,c,n),{serializedResult:y,finalResult:E=y}=Dyt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});Myt({serializedResult:y,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let S=a[r]?E:void 0;try{return n.error===void 0&&Uyt(y,h,i),S}catch(g){return n.error=g,S}},Lyt=(t,e,r,n)=>{try{return yC(t,e,r,!1)}catch(i){return n.error=i,t}},Dyt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Lb(t)};let o=_Se(t,r);return n[s]?{serializedResult:o,finalResult:i3(o,!i[s],e)}:{serializedResult:o}},Myt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!SC({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=i3(t,!1,o);try{eTe(a,e,n)}catch(c){r.error??=c}},Uyt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>pC.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?kyt(n,t):(r.add(s),Nyt(n,t))}};var nTe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,bc(e,r,"all")]:Array.isArray(e)?[bc(t,r,"all"),...e]:Pr(t)&&Pr(e)?p6([t,e]):`${t}${e}`};import{once as c3}from"events";var iTe=async(t,e)=>{let[r,n]=await Fyt(t);return e.isForcefullyTerminated??=!1,[r,n]},Fyt=async t=>{let[e,r]=await Promise.allSettled([c3(t,"spawn"),c3(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?sTe(t):r.value},sTe=async t=>{try{return await c3(t,"exit")}catch{return sTe(t)}},oTe=async t=>{let[e,r]=await t;if(!jyt(e,r)&&l3(e,r))throw new to;return[e,r]},jyt=(t,e)=>t===void 0&&e===void 0,l3=(t,e)=>t!==0||e!==null;var aTe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=qyt(t,e,r),o=s?.code==="ETIMEDOUT",a=rbe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},qyt=(t,e,r)=>t!==void 0?t:l3(e,r)?new to:void 0;var cTe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=zyt(t,e,r),d=Gyt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return jg(d,c,l)},zyt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=LP(t,e,r),a=Vyt(r),{file:c,commandArguments:l,options:u}=tC(t,e,a);Hyt(u);let d=Ube(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},Vyt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Hyt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&EC("ipcInput"),t&&EC("ipc: true"),r&&EC("detached: true"),n&&EC("cancelSignal")},EC=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Gyt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=Wyt({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=aTe(c,r),{output:h,error:m=l}=rTe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((E,S)=>bc(E,r,S)),y=bc(nTe(h,r),r,"all");return Kyt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},Wyt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{Xbe(s,r);let a=Yyt(r);return Byt(...rC(t,e,a))}catch(a){return Fg({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},Yyt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:lC(e)}),Kyt=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:s,all:o,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?uC({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):Vb({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as DEt}from"events";import{spawn as MEt}from"child_process";import pTe from"process";import{once as u3,on as Jyt}from"events";var lTe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(kg({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:KP(t)}),Zyt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),Zyt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{HP(e,i);let s=Su(t,e,r),o=new AbortController;try{return await Promise.race([Xyt(s,n,o),Qyt(s,r,o),eSt(s,r,o)])}catch(a){throw $g(t),a}finally{o.abort(),GP(e,i)}},Xyt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await u3(t,"message",{signal:r});return n}for await(let[n]of Jyt(t,"message",{signal:r}))if(e(n))return n},Qyt=async(t,e,{signal:r})=>{await u3(t,"disconnect",{signal:r}),KEe(e)},eSt=async(t,e,{signal:r})=>{let[n]=await u3(t,"strict:error",{signal:r});throw BP(n,e)};import{once as dTe,on as tSt}from"events";var fTe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>d3({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),d3=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{kg({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:KP(t)}),HP(e,s);let o=Su(t,e,r),a=new AbortController,c={};return rSt(t,o,a),nSt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),iSt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},rSt=async(t,e,r)=>{try{await dTe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},nSt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await dTe(t,"strict:error",{signal:r.signal});n.error=BP(i,e),r.abort()}catch{}},iSt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of tSt(r,"message",{signal:s.signal}))uTe(o),yield c}catch{uTe(o)}finally{s.abort(),GP(e,a),n||$g(t),i&&await t}},uTe=({error:t})=>{if(t)throw t};var hTe=(t,{ipc:e})=>{Object.assign(t,gTe(t,!1,e))},mTe=()=>{let t=pTe,e=!0,r=pTe.channel!==void 0;return{...gTe(t,e,r),getCancelSignal:bve.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},gTe=(t,e,r)=>({sendMessage:QP.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:lTe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:fTe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as sSt}from"child_process";import{PassThrough as oSt,Readable as aSt,Writable as cSt,Duplex as lSt}from"stream";var _Te=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{t3(n);let a=new sSt;uSt(a,n),Object.assign(a,{readable:dSt,writable:fSt,duplex:pSt});let c=Fg({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=hSt(c,o,i);return{subprocess:a,promise:l}},uSt=(t,e)=>{let r=Gb(),n=Gb(),i=Gb(),s=Array.from({length:e.length-3},Gb),o=Gb(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},Gb=()=>{let t=new oSt;return t.end(),t},dSt=()=>new aSt({read(){}}),fSt=()=>new cSt({write(){}}),pSt=()=>new lSt({read(){},write(){}}),hSt=async(t,e,r)=>jg(t,e,r);import{createReadStream as yTe,createWriteStream as STe}from"fs";import{Buffer as mSt}from"buffer";import{Readable as Wb,Writable as gSt,Duplex as _St}from"stream";var vTe=(t,e)=>hC(ySt,t,e,!1),Yb=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Eu[t]}.`)},ETe={fileNumber:Yb,generator:a3,asyncGenerator:a3,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:_St.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},ySt={input:{...ETe,fileUrl:({value:t})=>({stream:yTe(t)}),filePath:({value:{file:t}})=>({stream:yTe(t)}),webStream:({value:t})=>({stream:Wb.fromWeb(t)}),iterable:({value:t})=>({stream:Wb.from(t)}),asyncIterable:({value:t})=>({stream:Wb.from(t)}),string:({value:t})=>({stream:Wb.from(t)}),uint8Array:({value:t})=>({stream:Wb.from(mSt.from(t))})},output:{...ETe,fileUrl:({value:t})=>({stream:STe(t)}),filePath:({value:{file:t,append:e}})=>({stream:STe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:gSt.fromWeb(t)}),iterable:Yb,asyncIterable:Yb,string:Yb,uint8Array:Yb}};import{on as SSt,once as bTe}from"events";import{PassThrough as ESt,getDefaultHighWaterMark as vSt}from"stream";import{finished as ATe}from"stream/promises";function Uf(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)p3(i);let e=t.some(({readableObjectMode:i})=>i),r=bSt(t,e),n=new f3({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var bSt=(t,e)=>{if(t.length===0)return vSt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},f3=class extends ESt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(p3(e),this.#e.has(e))return;this.#e.add(e),this.#n??=TSt(this,this.#e,this.#s);let r=RSt({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#s});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(p3(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},TSt=async(t,e,r)=>{vC(t,TTe);let n=new AbortController;try{await Promise.race([wSt(t,n),ASt(t,e,r,n)])}finally{n.abort(),vC(t,-TTe)}},wSt=async(t,{signal:e})=>{try{await ATe(t,{signal:e,cleanup:!0})}catch(r){throw RTe(t,r),r}},ASt=async(t,e,r,{signal:n})=>{for await(let[i]of SSt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},p3=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},RSt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{vC(t,wTe);let a=new AbortController;try{await Promise.race([xSt(s,e,a),ISt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),OSt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),vC(t,-wTe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?h3(t):PSt(t))},xSt=async(t,e,{signal:r})=>{try{await t,r.aborted||h3(e)}catch(n){r.aborted||RTe(e,n)}},ISt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await ATe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;xTe(o)?i.add(e):ITe(t,o)}},OSt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await bTe(t,i,{signal:s}),!t.readable)return bTe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},PSt=t=>{t.writable&&t.end()},RTe=(t,e)=>{xTe(e)?h3(t):ITe(t,e)},xTe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",h3=t=>{(t.readable||t.writable)&&t.destroy()},ITe=(t,e)=>{t.destroyed||(t.once("error",CSt),t.destroy(e))},CSt=()=>{},vC=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},TTe=2,wTe=1;import{finished as OTe}from"stream/promises";var Bg=(t,e)=>{t.pipe(e),NSt(t,e),kSt(t,e)},NSt=async(t,e)=>{if(!(eo(t)||eo(e))){try{await OTe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}m3(e)}},m3=t=>{t.writable&&t.end()},kSt=async(t,e)=>{if(!(eo(t)||eo(e))){try{await OTe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}g3(t)}},g3=t=>{t.readable&&t.destroy()};var PTe=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:s,direction:o}]of Object.entries(e)){for(let{stream:a}of s.filter(({type:c})=>Ss.has(c)))$St(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Ss.has(c)))DSt({subprocess:t,stream:a,direction:o,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,s]of n.entries()){let o=s.length===1?s[0]:Uf(s);Bg(o,i)}},$St=(t,e,r,n)=>{r==="output"?Bg(t.stdio[n],e):Bg(e,t.stdio[n]);let i=LSt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},LSt=["stdin","stdout","stderr"],DSt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;MSt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},MSt=(t,{signal:e})=>{eo(t)&&$f(t,USt,e)},USt=2;import{addAbortListener as qSt}from"events";var Ff=[];Ff.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Ff.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Ff.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var bC=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",_3=Symbol.for("signal-exit emitter"),y3=globalThis,FSt=Object.defineProperty.bind(Object),S3=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(y3[_3])return y3[_3];FSt(y3,_3,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let s of this.listeners[e])i=s(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},TC=class{},jSt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),E3=class extends TC{onExit(){return()=>{}}load(){}unload(){}},v3=class extends TC{#e=b3.platform==="win32"?"SIGINT":"SIGHUP";#r=new S3;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Ff)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,s=e;if(typeof s.__signal_exit_emitter__=="object"&&typeof s.__signal_exit_emitter__.count=="number"&&(i+=s.__signal_exit_emitter__.count),n.length===i){this.unload();let o=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;o||e.kill(e.pid,a)}};this.#s=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!bC(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 Ff)try{let r=this.#i[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#o&&(this.#o=!1,Ff.forEach(e=>{let r=this.#i[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#s,this.#r.count-=1)}#a(e){return bC(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#s.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&bC(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let i=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),i}else return n.call(this.#t,e,...r)}},b3=globalThis.process,{onExit:CTe,load:ecr,unload:tcr}=jSt(bC(b3)?new v3(b3):new E3);var NTe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=CTe(()=>{t.kill()});qSt(n,()=>{i()})};var $Te=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=$P(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=BSt(r,n,i),{sourceStream:d,sourceError:f}=VSt(t,l),{options:p,fileDescriptors:h}=na.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},BSt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=zSt(t,e,...r),a=VP(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},zSt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(kTe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||d6(r)){if(Object.keys(t).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[i,s,o]=wP(r,...n);return{destination:e(kTe)(i,s,o),pipeOptions:o}}if(na.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}`)},kTe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),VSt=(t,e)=>{try{return{sourceStream:Lg(t,e)}}catch(r){return{sourceError:r}}};var DTe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=HSt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw T3({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},HSt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return g3(t),n;if(e!==void 0)return m3(r),e},T3=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Fg({error:t,command:LTe,escapedCommand:LTe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),LTe="source.pipe(destination)";var MTe=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:s,value:o=s}]=await t;if(o.pipedFrom.includes(n)||o.pipedFrom.push(n),i==="rejected")throw o;if(e==="rejected")throw n;return o};import{finished as GSt}from"stream/promises";var UTe=(t,e,r)=>{let n=wC.has(e)?YSt(t,e):WSt(t,e);return $f(t,JSt,r.signal),$f(e,ZSt,r.signal),KSt(e),n},WSt=(t,e)=>{let r=Uf([t]);return Bg(r,e),wC.set(e,r),r},YSt=(t,e)=>{let r=wC.get(e);return r.add(t),r},KSt=async t=>{try{await GSt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}wC.delete(t)},wC=new WeakMap,JSt=2,ZSt=1;import{aborted as XSt}from"util";var FTe=(t,e)=>t===void 0?[]:[QSt(t,e)],QSt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await XSt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw T3({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var AC=(t,...e)=>{if(gr(e[0]))return AC.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=$Te(t,...e),i=eEt({...n,destination:r});return i.pipe=AC.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},eEt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=tEt(t,i);DTe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=UTe(e,s,d);return await Promise.race([MTe(u),...FTe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},tEt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as cEt}from"timers/promises";import{on as rEt}from"events";import{getDefaultHighWaterMark as nEt}from"stream";var RC=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return iEt(e,o),qTe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},iEt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},w3=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;sEt(e,o,t);let a=t.readableObjectMode&&!s;return qTe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},sEt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},qTe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=rEt(t,"data",{signal:e.signal,highWaterMark:jTe,highWatermark:jTe});return oEt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},A3=nEt(!0),jTe=A3,oEt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=aEt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Mf(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Hb(a)}},aEt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[gC(t,r,!e),mC(t,i,!n,{})].filter(Boolean);var BTe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=lEt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([uEt(t),d]);return}let f=r3(c,r),p=w3({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([dEt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},lEt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!SC({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=w3({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Qbe(a,t,r,s)},uEt=async t=>{await cEt(),t.readableFlowing===null&&t.resume()},dEt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await oC(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await aC(r,{maxBuffer:s})):await Ug(r,{maxBuffer:s})}catch(a){return zTe(Qve({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},R3=async t=>{try{return await t}catch(e){return zTe(e)}},zTe=({bufferedData:t})=>mSe(t)?new Uint8Array(t):t;import{finished as fEt}from"stream/promises";var Kb=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=pEt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],fEt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||gEt(a,e,r,n)}finally{o.abort()}},pEt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&hEt(t,r,n),n},hEt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{mEt(e,r),n.call(t,...i)}},mEt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},gEt=(t,e,r,n)=>{if(!_Et(t,e,r,n))throw t},_Et=(t,e,r,n=!0)=>r.propagating?VTe(t)||xC(t):(r.propagating=!0,x3(r,e)===n?VTe(t):xC(t)),x3=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",xC=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",VTe=t=>t?.code==="EPIPE";var HTe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>I3({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),I3=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=Kb(t,e,l);if(x3(l,e)){await u;return}let[d]=await Promise.all([BTe({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var GTe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Uf([t,e].filter(Boolean)):void 0,WTe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>I3({...yEt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:SEt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),yEt=({stdout:t,stderr:e,all:r},[,n,i])=>{let s=n||i;return s?n?i?{stream:r,buffer:s}:{stream:t,buffer:s}:{stream:e,buffer:s}:{stream:r,buffer:s}},SEt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as EEt}from"events";var YTe=t=>Pg(t,"ipc"),KTe=(t,e)=>{let r=kP(t);ta({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var JTe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=YTe(s),a=Ec(e,"ipc"),c=Ec(r,"ipc");for await(let l of d3({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(ebe(t,i,c),i.push(l)),o&&KTe(l,s);return i},ZTe=async(t,e)=>(await Promise.allSettled([t]),e);var XTe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:_,controller:y})=>{let E=iTe(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:E,propagating:!1},g=HTe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),w=WTe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),P=[],x=JTe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:P,verboseInfo:p}),A=vEt(m,t,S),O=bEt(h,S);try{return await Promise.race([Promise.all([{},oTe(E),Promise.all(g),w,x,Nve(t,d),...A,...O]),_,TEt(t,y),...xve(t,s,f,y),...YEe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...Ave({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(R){return f.terminationReason??="other",Promise.all([{error:R},E,Promise.all(g.map(b=>R3(b))),R3(w),ZTe(x,P),Promise.allSettled(A),Promise.allSettled(O)])}},vEt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:Kb(n,i,r)),bEt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>no(s,{checkOpen:!1})&&!eo(s)).map(({type:i,value:s,stream:o=s})=>Kb(o,n,e,{isSameDirection:Ss.has(i),stopOnExit:i==="native"}))),TEt=async(t,{signal:e})=>{let[r]=await EEt(t,"error",{signal:e});throw r};var QTe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),Jb=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=ra();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},zg=async({resolve:t,promises:e},r)=>{t();let[n]=await Promise.race([Promise.allSettled([!0,r]),Promise.all([!1,...e])]);return!n};import{Readable as wEt}from"stream";import{callbackify as AEt}from"util";import{finished as ewe}from"stream/promises";var O3=async t=>{if(t!==void 0)try{await P3(t)}catch{}},twe=async t=>{if(t!==void 0)try{await C3(t)}catch{}},P3=async t=>{await ewe(t,{cleanup:!0,readable:!1,writable:!0})},C3=async t=>{await ewe(t,{cleanup:!0,readable:!0,writable:!1})},IC=async(t,e)=>{if(await t,e)throw e},OC=(t,e,r)=>{r&&!xC(r)?t.destroy(r):e&&t.destroy()};var rwe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||Mi.has(r),{subprocessStdout:a,waitReadableDestroy:c}=N3(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=k3(a,o),{read:f,onStdoutDataDone:p}=$3({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new wEt({read:f,destroy:AEt(D3.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return L3({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},N3=(t,e,r)=>{let n=Lg(t,e),i=Jb(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},k3=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:A3},$3=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=ra(),o=RC({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){REt(this,o,s)},onStdoutDataDone:s}},REt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},L3=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await C3(t),await n,await O3(i),await e,r.readable&&r.push(null)}catch(s){await O3(i),nwe(r,s)}},D3=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await zg(r,e)&&(nwe(t,n),await IC(e,n))},nwe=(t,e)=>{OC(t,t.readable,e)};import{Writable as xEt}from"stream";import{callbackify as iwe}from"util";var swe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=M3(t,r,e),o=new xEt({...U3(n,t,i),destroy:iwe(j3.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return F3(n,o),o},M3=(t,e,r)=>{let n=VP(t,e),i=Jb(r,n,"writableFinal"),s=Jb(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},U3=(t,e,r)=>({write:IEt.bind(void 0,t),final:iwe(OEt.bind(void 0,t,e,r))}),IEt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},OEt=async(t,e,r)=>{await zg(r,e)&&(t.writable&&t.end(),await e)},F3=async(t,e,r)=>{try{await P3(t),e.writable&&e.end()}catch(n){await twe(r),owe(e,n)}},j3=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await zg(r,e),await zg(n,e)&&(owe(t,i),await IC(e,i))},owe=(t,e)=>{OC(t,t.writable,e)};import{Duplex as PEt}from"stream";import{callbackify as CEt}from"util";var awe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||Mi.has(r),{subprocessStdout:c,waitReadableDestroy:l}=N3(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=M3(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=k3(c,a),{read:_,onStdoutDataDone:y}=$3({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),E=new PEt({read:_,...U3(u,t,d),destroy:CEt(NEt.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return L3({subprocessStdout:c,onStdoutDataDone:y,readable:E,subprocess:t,subprocessStdin:u}),F3(u,E,c),E},NEt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([D3({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),j3({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var q3=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||Mi.has(e),o=Lg(t,r),a=RC({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return kEt(a,o,t)},kEt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var cwe=(t,{encoding:e})=>{let r=QTe();t.readable=rwe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=swe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=awe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=q3.bind(void 0,t,e),t[Symbol.asyncIterator]=q3.bind(void 0,t,e,{})};var lwe=(t,e)=>{for(let[r,n]of LEt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},$Et=(async()=>{})().constructor.prototype,LEt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor($Et,t)]);var uwe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=UEt(t,e,r),{subprocess:f,promise:p}=jEt({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=AC.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),lwe(f,p),na.set(f,{options:u,fileDescriptors:d}),f},UEt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=LP(t,e,r),{file:a,commandArguments:c,options:l}=tC(t,e,r),u=FEt(l),d=vTe(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},FEt=({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}},jEt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=MEt(...rC(t,e,r))}catch(h){return _Te({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;DEt(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];PTe(c,a,l),NTe(c,r,l);let d={},f=ra();c.kill=GEe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=GTe(c,r),cwe(c,r),hTe(c,r);let p=qEt({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:s,escapedCommand:o,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},qEt=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:s,command:o,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,_]=await XTe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:l,controller:u});u.abort(),l.resolve();let y=h.map((g,w)=>bc(g,e,w)),E=bc(m,e,"all"),S=BEt({errorInfo:d,exitCode:f,signal:p,stdio:y,all:E,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return jg(S,n,e)},BEt=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,context:o,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?Vb({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 ia,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):uC({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var PC=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,zEt(n,t[n],i)]));return{...t,...r}},zEt=(t,e,r)=>VEt.has(t)&&gr(e)&&gr(r)?{...e,...r}:r,VEt=new Set(["env",..._6]);var vu=(t,e,r,n)=>{let i=(o,a,c)=>vu(o,a,r,c),s=(...o)=>HEt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},HEt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(gr(s))return i(t,PC(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=GEt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?cTe(a,c,l):uwe(a,c,l,i)},GEt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=vSe(e)?bSe(e,r):[e,...r],[o,a,c]=wP(...s),l=PC(PC(n,i),c),{file:u=o,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:o,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var dwe=({file:t,commandArguments:e})=>pwe(t,e),fwe=({file:t,commandArguments:e})=>({...pwe(t,e),isSync:!0}),pwe=(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]=WEt(t);return{file:r,commandArguments:n}},WEt=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(YEt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},YEt=/ +/g;var hwe=(t,e,r)=>{t.sync=e(KEt,r),t.s=t.sync},mwe=({options:t})=>gwe(t),KEt=({options:t})=>({...gwe(t),isSync:!0}),gwe=t=>({options:{...JEt(t),...t}}),JEt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},_we={preferLocal:!0};var ywe=vu(()=>({})),Vur=vu(()=>({isSync:!0})),Swe=vu(dwe),Hur=vu(fwe),Gur=vu(Ove),Wur=vu(mwe,{},_we,hwe),{sendMessage:Yur,getOneMessage:Kur,getEachMessage:Jur,getCancelSignal:Zur}=mTe();import{Transform as ZEt}from"stream";var XEt=["NETLIFY_AI_GATEWAY_KEY"];function QEt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...XEt])]}function evt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function tvt(){let e=QEt().map(r=>process.env[r]).filter(r=>!(!r||evt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Es(t){if(typeof t!="string")return t;let e=tvt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(rvt(n),"g");r=r.replace(i,"******")}),r}function rvt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Zb=class extends ZEt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Es(i);n(null,s)}},CC=Symbol("maskedWrite");function Ewe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[CC]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Es(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[CC]=!0,process.stdout.write=r}if(!process.stderr.write[CC]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Es(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[CC]=!0,process.stderr.write=r}}}var vwe=!1,bwe=()=>{vwe=!0},_i=()=>vwe;var Xb=null,Twe=t=>(Xb&&Xb.destroy(),Xb=new Tc({totalAllowedTime:t}),Xb),wwe=()=>Xb;var Tc=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&_i())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let s=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),o=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await bP({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{be.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),s(),o&&clearTimeout(o)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var Awe={name:"@netlify/agent-runner-cli",type:"module",version:"1.150.0-ex-2643.2",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.2","@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.219","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.1.5","@netlify/otel":"^6.0.4","@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",zod:"^4.4.3"}};var ovt=ivt(import.meta.url),avt=wc.dirname(ovt),cvt=svt(import.meta.url),Vg=Ee("shell"),B3=new Set,Rwe={preferLocal:!0},Hn=(t,e,r)=>{let[n,i]=lvt(e,r),s={...Rwe,...i},o=ywe(t,n,s);Iwe(o,s),Cwe(o);let a=r?.idleTimeout;return a&&a>0&&Pwe(o,a),o},xwe=(t,e)=>{let r={...Rwe,...e},n=Swe(t,r);return Iwe(n,r),Cwe(n),e?.idleTimeout&&e.idleTimeout>0&&Pwe(n,e.idleTimeout),n},lvt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},Iwe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(Ac.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Zb).pipe(Ac.stdout),t.stderr?.pipe(new Zb).pipe(Ac.stderr);return}t.stdout?.pipe(Ac.stdout),t.stderr?.pipe(Ac.stderr)},z3=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Ac.kill(-t.pid,e),Vg.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Vg.error("Error killing process:",r),!1}},Owe=t=>z3(t,"SIGKILL"),Pwe=(t,e)=>{let r=null,n=()=>{Vg.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),z3(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Vg.log(`Force killing idle process ${t.pid}`),Owe(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let s=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",s),t.on("error",s)},Cwe=t=>{B3.add(t);let e=wwe();if(e){let r=e.onTimesUp(()=>{Vg.log(`Global timer expired, killing process ${t.pid}`),z3(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Vg.log(`Force killing process ${t.pid} after timeout`),Owe(t))},5e3)});t.on("exit",()=>{B3.delete(t),r()}),t.on("error",()=>{B3.delete(t),r()})}};function oa(t,e){if(!Ac.env.NETLIFY_LOCAL_MODE)try{let i=cvt.resolve(Awe.name),s=wc.dirname(i);for(;s!==wc.dirname(s);){let o=wc.dirname(s);if(wc.basename(o)==="node_modules"){let a=wc.join(o,".bin",e);if(NC.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(Ac.env.NODE_PATH){let i=wc.join(Ac.env.NODE_PATH,".bin",e);if(NC.existsSync(i))return i}let r=wc.join(t,"node_modules",".bin",e);if(NC.existsSync(r))return r;let n=wc.join(avt,"..","node_modules",".bin",e);if(NC.existsSync(n))return n}import KL from"process";import{fileURLToPath as w$t}from"url";import{createRequire as A$t}from"module";import JL from"path";var uvt="__netlify__getTracer",dvt="__netlify__shutdownTracers",mt=(t,e)=>globalThis[uvt]?.(t,e),Nwe=async()=>globalThis[dvt]?.();function jf(t,e,r,n,i){let s=typeof n=="function"?n:typeof r=="function"?r:i;if(!s)throw new Error("function to execute with active span is missing");return t?t.withActiveSpan(e,r,n,s):s()}import{setTimeout as y$t}from"timers/promises";Ne();import kTt from"process";Ne();var Lvt=(t,e)=>{e.recordException(t),e.setStatus({code:xn.ERROR})};var Ic=class{constructor(e){this._tracer=e,this.startSpan=e.startSpan.bind(this._tracer),this.startActiveSpan=e.startActiveSpan.bind(this._tracer)}withActiveSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=A0e(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>R0e(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=A0e(r,n,i),c=this._tracer.startSpan(e,s,o);return R0e(c,s,a)}};function A0e(t,e,r){let n,i,s;return!e&&!r?s=t:r?(n=t,i=e,s=r):(n=t,s=e),n=n??{},i=i??Ut.active(),{opts:n,ctx:i,fn:s}}function R0e(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:Lvt,s=o=>{throw i(o,t),t.end(),o};try{let o=r(t);return typeof o?.then=="function"?o.then(a=>(t.end(),a),s):(t.end(),o)}catch(o){throw s(o)}}Ne();var Zg=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var TW=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=D0e(e),n._asyncAttributesPending=e.filter(([i,s])=>Zg(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(Zg(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=D0e(this._rawAttributes),this._schemaUrl=Dvt(r?.schemaUrl)}get asyncAttributesPending(){return this._asyncAttributesPending}async waitForAsyncAttributes(){if(this.asyncAttributesPending){for(let e=0;e<this._rawAttributes.length;e++){let[r,n]=this._rawAttributes[e];this._rawAttributes[e]=[r,Zg(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&ae.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(Zg(n)){ae.debug(`Unsettled resource attribute ${r} skipped`);continue}n!=null&&(e[r]??=n)}return this._asyncAttributesPending||(this._memoizedAttributes=e),e}getRawAttributes(){return this._rawAttributes}get schemaUrl(){return this._schemaUrl}merge(e){if(e==null)return this;let r=Mvt(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function wW(t,e){return TW.FromAttributeList(Object.entries(t),e)}function D0e(t){return t.map(([e,r])=>Zg(r)?[e,r.catch(n=>{ae.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function Dvt(t){if(typeof t=="string"||t===void 0)return t;ae.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function Mvt(t,e){let r=t?.schemaUrl,n=e?.schemaUrl,i=r===void 0||r==="",s=n===void 0||n==="";if(i)return n;if(s||r===n)return r;ae.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}Ne();var uT=class{emit(e){}enabled(){return!1}},M0e=new uT;var dT=Symbol.for("io.opentelemetry.js.api.logs"),Xg=globalThis;function U0e(t,e,r){return n=>n===t?e:r}var AW=1;var RW=class{getLogger(e,r,n){return new uT}},tN=new RW;var rN=class{constructor(e,r,n,i){this._provider=e,this.name=r,this.version=n,this.options=i}emit(e){this._getLogger().emit(e)}enabled(e){return this._getLogger().enabled(e)}_getLogger(){if(this._delegate)return this._delegate;let e=this._provider._getDelegateLogger(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):M0e}};var fT=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new rN(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:tN}_setDelegate(e){this._delegate=e}_getDelegateLogger(e,r,n){var i;return(i=this._delegate)===null||i===void 0?void 0:i.getLogger(e,r,n)}};var nN=class t{constructor(){this._proxyLoggerProvider=new fT}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return Xg[dT]?this.getLoggerProvider():(Xg[dT]=U0e(AW,e,tN),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=Xg[dT])===null||e===void 0?void 0:e.call(Xg,AW))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete Xg[dT],this._proxyLoggerProvider=new fT}};var F0e=nN.getInstance();function j0e(t,e,r,n){for(let i=0,s=t.length;i<s;i++){let o=t[i];e&&o.setTracerProvider(e),r&&o.setMeterProvider(r),n&&o.setLoggerProvider&&o.setLoggerProvider(n),o.getConfig().enabled||o.enable()}}function q0e(t){t.forEach(e=>e.disable())}function xW(t){let e=t.tracerProvider||Bt.getTracerProvider(),r=t.meterProvider||lT.getMeterProvider(),n=t.loggerProvider||F0e.getLoggerProvider(),i=t.instrumentations?.flat()??[];return j0e(i,e,r,n),()=>{q0e(i)}}kc();var fk=$n(OY(),1);Ne();kc();var LIe=t=>{throw TypeError(t)},kY=(t,e,r)=>e.has(t)||LIe("Cannot "+r),dk=(t,e,r)=>(kY(t,e,"read from private field"),r?r.call(t):e.get(t)),PY=(t,e,r)=>e.has(t)?LIe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),NIe=(t,e,r,n)=>(kY(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),NTt=(t,e,r)=>(kY(t,e,"access private method"),r),kIe="__netlify__getTracer",$Tt="__netlify__shutdownTracers",LTt="__nfOTLPTrace",NT,kT,NY,DIe,DTt=class{constructor(){PY(this,NY),PY(this,NT),PY(this,kT),NIe(this,NT,new n_(NTt(this,NY,DIe),this)),NIe(this,kT,ae.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(dk(this,kT).debug(`export ${t.length.toString()} spans`),dk(this,NT).isCalled){e({code:Wn.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(LTt,JSON.stringify(MTt(t))),e({code:Wn.SUCCESS})}shutdown(){return dk(this,NT).call()}};NT=new WeakMap;kT=new WeakMap;NY=new WeakSet;DIe=function(){return dk(this,kT).debug("Shutting down"),Promise.resolve()};function MTt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:uk(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||io.SERVER,startTimeUnixNano:CY(e.startTime),endTimeUnixNano:CY(e.endTime),attributes:uk(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:CY(n.time),attributes:uk(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:uk(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function uk(t){return Object.keys(t).map(e=>MIe(e,t[e]))}function MIe(t,e){return{key:t,value:UIe(e)}}function UIe(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(UIe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>MIe(r,n))}}:{}}function CY(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var $Ie={name:"@netlify/otel",version:"6.0.4",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.7",msw:"^2.10.5","npm-run-all2":"^7.0.2",tsup:"^8.0.0",vitest:"^3.0.0"},dependencies:{"@opentelemetry/api":"1.9.1","@opentelemetry/core":"2.7.1","@opentelemetry/instrumentation":"^0.220.0","@opentelemetry/resources":"2.9.0","@opentelemetry/sdk-trace-node":"2.9.0"}},FIe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,kIe))return;let e=kTt.version.slice(1),r=wW({"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??[UTt()],i=new fk.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new Nc});let s=t.instrumentations??[];xW({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,kIe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new Ic(Bt.getTracer(a,c)):new Ic(Bt.getTracer($Ie.name,$Ie.version))}}),Object.defineProperty(globalThis,$Tt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},UTt=()=>new fk.SimpleSpanProcessor(new DTt);Ne();kc();var $T=$n(OY(),1);Ne();import*as pk from"diagnostics_channel";var jIe=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?xn.ERROR:xn.UNSET})}prepareHeaders(t,e){if(!Array.isArray(e))return{};if(this.config.skipHeaders===!0)return{};let r=["*","/.*/"],n=this.config.skipHeaders??[],i=this.config.redactHeaders??[],s=n.some(a=>r.includes(a.toString())),o={};if(s)return o;for(let a=0;a+1<e.length;a=a+2){let c=e[a],l=e[a+1];if(typeof c!="string"&&!Buffer.isBuffer(c)||typeof l!="string"&&!Buffer.isBuffer(l))continue;let u=c.toString().toLowerCase();if(n.some(f=>typeof f=="string"?f==u:f.test(u)))continue;let d=`http.${t}.header.${u}`;i===!0||i.some(f=>typeof f=="string"?f==u:f.test(u))?o[d]="REDACTED":o[d]=l.toString()}return o}getRequestMethod(t){return["HEAD","GET","POST","PUT","PATCH","DELETE"].includes(t.toUpperCase())?t.toUpperCase():"_OTHER"}getTracer(){if(!this.provider)return;let t=this.provider.getTracer(this.instrumentationName,this.instrumentationVersion);return t instanceof Ic?t:new Ic(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){pk.subscribe(t,e);let r=()=>pk.unsubscribe(t,e);this._channelSubs.push({name:t,unsubscribe:r})}disable(){this._channelSubs.forEach(t=>{t.unsubscribe()}),this._channelSubs.length=0}onRequestCreate({request:t}){try{let e=this.getTracer(),r=new URL(t.path,t.origin);if(!e||t.method==="CONNECT"||this.config.skipURLs?.some(i=>typeof i=="string"?r.href.startsWith(i):i.test(r.href)))return;let n=e.startSpan(this.getRequestMethod(t.method),{kind:io.CLIENT},Ut.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:xn.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 XLe=$n(JLe(),1);var WL=Ee("tracing"),ZLe=8e3,S$t=5e3,Ww=async(t=S$t)=>{try{await Promise.race([Nwe(),y$t(t)])}catch(e){WL.warn("Failed to flush tracers on shutdown",e)}},QLe=async(t,e,r)=>{if(!mt()){let n=[new $T.SimpleSpanProcessor(new _J),new $T.SimpleSpanProcessor(new XLe.OTLPTraceExporter({url:r.exporterUrl}))];await FIe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new jIe({skipHeaders:!0})]})}return r.traceparent?(Gn.setGlobalPropagator(new Nc),Gn.extract(Ut.active(),{traceparent:r.traceparent,isRemote:!0})):Ut.active()};function Vt(t,e,r){return WL.log(`\u23F3 TRACE: ${e} starting...`),jf(t,e,r)}var _J=class{export(e,r){for(let n of e)this.logSpan(n);r({code:1})}async shutdown(){}forceFlush(){return Promise.resolve()}logSpan(e){let r=(e.endTime[0]-e.startTime[0])*1e3+(e.endTime[1]-e.startTime[1])/1e6,n=e.attributes,i=[];for(let[a,c]of Object.entries(n))a.includes("duration")&&typeof c=="number"?i.push(`${a}=${c.toFixed(2)}ms`):i.push(`${a}=${c}`);let s=e.status?.code===2?"\u274C":"\u2705",o=i.length>0?` [${i.join(", ")}]`:"";WL.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&WL.log(` \u274C Error: ${e.status.message}`)}};function yJ(){return nt().captureLlmContentEnabled}function eDe(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function YL(t,e,r){let n={role:t,parts:[{type:"text",content:Es(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}function tDe(t,e,r,n){if(!t.length)return;let i=mt();if(!i)return;let s=yJ(),o=Math.max(1,(n-r)/t.length);t.forEach((a,c)=>{let l=Math.min(n,r+c*o),u=Math.min(n,l+o),d=a.title||a.type||`step-${a.id??c}`,f=a.type==="tool_use"||a.type==="tool_result",p=a.message?a.message.length>ZLe?`${a.message.slice(0,ZLe)}\u2026`:a.message:void 0;i.startSpan(d,{startTime:l,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":d,"gen_ai.operation.name":f?"execute_tool":"chat",...f?{"gen_ai.tool.name":d}:{},"spark.step.id":a.id??-1,...a.type?{"spark.step.type":a.type}:{},...a.category?{"spark.step.category":a.category}:{},...a.groupId?{"spark.step.group_id":a.groupId}:{},...a.parentGroupId?{"spark.step.parent_group_id":a.parentGroupId}:{},...s&&p?f?{"gen_ai.tool.call.result":Es(p)}:{"gen_ai.output.messages":YL("assistant",p)}:{}}}).end(u)})}import{readdir as E$t,rm as v$t}from"fs/promises";import{join as b$t}from"path";async function rDe(t,e=[]){let n=(await E$t(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>v$t(b$t(t,i),{recursive:!0,force:!0})))}var T$t=700,nDe=t=>t.mode==="create"&&(t.accountType===vl||t.enforcedAICreditsRemaining!=null&&t.enforcedAICreditsRemaining<=T$t);var R$t=JL.dirname(w$t(import.meta.url)),iDe=A$t(import.meta.url),x$t=JL.resolve(R$t,"scripts/scaffold.js"),I$t="scripts/scaffold.js",O$t=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,SJ=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},P$t=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),C$t=t=>{let e=SJ(t);return e==="node"||e.endsWith("/node")},el=t=>{if(typeof t!="string")return!1;let e=t.match(O$t)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&P$t(SJ(e[r]));)r+=1;if(r>=e.length||!C$t(e[r]))return!1;let n=e[r+1];return n?SJ(n).includes(I$t):!1},ly=Ee("create_stage"),sDe="Do not run local validation or dev-server commands to check your work \u2014 specifically `tsc`, `npx tsc`, `vite build`, `vite dev`, or any equivalent build/start/test command. The build pipeline installs and validates the project automatically after your edits. Verify your changes by reading the files you edited.",N$t=`${sDe}
|
|
582
582
|
|
|
583
583
|
Commands that generate or modify project files are fine to run when the task requires them \u2014 for example \`drizzle-kit generate\` to write a database migration after a schema change, or other code-generation utilities documented in the skills.`,k$t=`${sDe}
|
|
584
584
|
|
|
@@ -666,7 +666,7 @@ you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
|
|
|
666
666
|
new OpenAI({ apiKey, dangerouslyAllowBrowser: true });
|
|
667
667
|
|
|
668
668
|
https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
|
|
669
|
-
`);this.baseURL=c.baseURL,this.timeout=c.timeout??cZ.DEFAULT_TIMEOUT,this.logger=c.logger??console;let l="warn";this.logLevel=l,this.logLevel=DJ(c.logLevel,"ClientOptions.logLevel",this)??DJ(ad("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??l,this.fetchOptions=c.fetchOptions,this.maxRetries=c.maxRetries??2,this.fetch=c.fetch??XL(),De(this,RD,TDe,"f"),this._options=c,o&&(this._workloadIdentityAuth=new sD(o,this.fetch)),this.apiKey=typeof r=="string"?r:"Missing Key",this.organization=n,this.project=i,this.webhookSecret=s}withOptions(e){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,workloadIdentity:this._options.workloadIdentity,organization:this.organization,project:this.project,webhookSecret:this.webhookSecret,...e})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:r}){}async authHeaders(e){return fe([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(e){return NDe(e)}getUserAgent(){return`${this.constructor.name}/JS ${ed}`}defaultIdempotencyKey(){return`stainless-node-retry-${bJ()}`}makeStatusError(e,r,n,i){return dr.generate(e,r,n,i)}async _callApiKey(){let e=this._options.apiKey;if(typeof e!="function")return!1;let r;try{r=await e()}catch(n){throw n instanceof Re?n:new Re(`Failed to get token from 'apiKey' function: ${n.message}`,{cause:n})}if(typeof r!="string"||!r)throw new Re(`Expected 'apiKey' function argument to return a string but it returned ${r}`);return this.apiKey=r,!0}buildURL(e,r,n){let i=!W(this,aZ,"m",mMe).call(this)&&n||this.baseURL,s=pDe(e)?new URL(e):new URL(i+(i.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),o=this.defaultQuery(),a=Object.fromEntries(s.searchParams);return(!AJ(o)||!AJ(a))&&(r={...a,...o,...r}),typeof r=="object"&&r&&!Array.isArray(r)&&(s.search=this.stringifyQuery(r)),s.toString()}async prepareOptions(e){await this._callApiKey()}async prepareRequest(e,{url:r,options:n}){}get(e,r){return this.methodRequest("get",e,r)}post(e,r){return this.methodRequest("post",e,r)}patch(e,r){return this.methodRequest("patch",e,r)}put(e,r){return this.methodRequest("put",e,r)}delete(e,r){return this.methodRequest("delete",e,r)}methodRequest(e,r,n){return this.request(Promise.resolve(n).then(i=>({method:e,path:r,...i})))}request(e,r=null){return new Ip(this,this.makeRequest(e,r,void 0))}async makeRequest(e,r,n){let i=await e,s=i.maxRetries??this.maxRetries;r==null&&(r=s),await this.prepareOptions(i);let{req:o,url:a,timeout:c}=await this.buildRequest(i,{retryCount:s-r});await this.prepareRequest(o,{url:a,options:i});let l="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),u=n===void 0?"":`, retryOf: ${n}`,d=Date.now();if(Er(this).debug(`[${l}] sending request`,rl({retryOfRequestLogID:n,method:i.method,url:a,options:i,headers:o.headers})),i.signal?.aborted)throw new Rr;let f=new AbortController,p=await this.fetchWithAuth(a,o,c,f).catch(Zw),h=Date.now();if(p instanceof globalThis.Error){let y=`retrying, ${r} attempts remaining`;if(i.signal?.aborted)throw new Rr;let E=Jw(p)||/timed? ?out/i.test(String(p)+("cause"in p?String(p.cause):""));if(r)return Er(this).info(`[${l}] connection ${E?"timed out":"failed"} - ${y}`),Er(this).debug(`[${l}] connection ${E?"timed out":"failed"} (${y})`,rl({retryOfRequestLogID:n,url:a,durationMs:h-d,message:p.message})),this.retryRequest(i,r,n??l);throw Er(this).info(`[${l}] connection ${E?"timed out":"failed"} - error; no more retries left`),Er(this).debug(`[${l}] connection ${E?"timed out":"failed"} (error; no more retries left)`,rl({retryOfRequestLogID:n,url:a,durationMs:h-d,message:p.message})),p instanceof Rp||p instanceof Xw?p:E?new Qu:new Xu({cause:p})}let m=[...p.headers.entries()].filter(([y])=>y==="x-request-id").map(([y,E])=>", "+y+": "+JSON.stringify(E)).join(""),_=`[${l}${u}${m}] ${o.method} ${a} ${p.ok?"succeeded":"failed"} with status ${p.status} in ${h-d}ms`;if(!p.ok){if(p.status===401&&this._workloadIdentityAuth&&!i.__metadata?.hasStreamingBody&&!i.__metadata?.workloadIdentityTokenRefreshed)return await IJ(p.body),this._workloadIdentityAuth.invalidateToken(),this.makeRequest({...i,__metadata:{...i.__metadata,workloadIdentityTokenRefreshed:!0}},r,n??l);let y=await this.shouldRetry(p);if(r&&y){let x=`retrying, ${r} attempts remaining`;return await IJ(p.body),Er(this).info(`${_} - ${x}`),Er(this).debug(`[${l}] response error (${x})`,rl({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:h-d})),this.retryRequest(i,r,n??l,p.headers)}let E=y?"error; no more retries left":"error; not retryable";Er(this).info(`${_} - ${E}`);let S=await p.text().catch(x=>Zw(x).message),g=gDe(S),w=g?void 0:S;throw Er(this).debug(`[${l}] response error (${E})`,rl({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,message:w,durationMs:Date.now()-d})),this.makeStatusError(p.status,g,w,p.headers)}return Er(this).info(_),Er(this).debug(`[${l}] response start`,rl({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:h-d})),{response:p,options:i,controller:f,requestLogID:l,retryOfRequestLogID:n,startTime:d}}getAPIList(e,r,n){return this.requestAPIList(r,n&&"then"in n?n.then(i=>({method:"get",path:e,...i})):{method:"get",path:e,...n})}requestAPIList(e,r){let n=this.makeRequest(r,null,void 0);return new i0(this,n,e)}async fetchWithAuth(e,r,n,i){if(this._workloadIdentityAuth){let o=r.headers,a=o.get("Authorization");if(!a||a===`Bearer ${oZ}`){let c=await this._workloadIdentityAuth.getToken();o.set("Authorization",`Bearer ${c}`)}}return await this.fetchWithTimeout(e,r,n,i)}async fetchWithTimeout(e,r,n,i){let{signal:s,method:o,...a}=r||{},c=this._makeAbort(i);s&&s.addEventListener("abort",c,{once:!0});let l=setTimeout(c,n),u=globalThis.ReadableStream&&a.body instanceof globalThis.ReadableStream||typeof a.body=="object"&&a.body!==null&&Symbol.asyncIterator in a.body,d={signal:i.signal,...u?{duplex:"half"}:{},method:"GET",...a};o&&(d.method=o.toUpperCase());try{return await this.fetch.call(void 0,e,d)}finally{clearTimeout(l)}}async shouldRetry(e){let r=e.headers.get("x-should-retry");return r==="true"?!0:r==="false"?!1:e.status===408||e.status===409||e.status===429||e.status>=500}async retryRequest(e,r,n,i){let s,o=i?.get("retry-after-ms");if(o){let c=parseFloat(o);Number.isNaN(c)||(s=c)}let a=i?.get("retry-after");if(a&&!s){let c=parseFloat(a);Number.isNaN(c)?s=Date.parse(a)-Date.now():s=c*1e3}if(s===void 0){let c=e.maxRetries??this.maxRetries;s=this.calculateDefaultRetryTimeoutMillis(r,c)}return await Ca(s),this.makeRequest(e,r-1,n)}calculateDefaultRetryTimeoutMillis(e,r){let s=r-e,o=Math.min(.5*Math.pow(2,s),8),a=1-Math.random()*.25;return o*a*1e3}async buildRequest(e,{retryCount:r=0}={}){let n={...e},{method:i,path:s,query:o,defaultBaseURL:a}=n,c=this.buildURL(s,o,a);"timeout"in n&&mDe("timeout",n.timeout),n.timeout=n.timeout??this.timeout;let{bodyHeaders:l,body:u,isStreamingBody:d}=this.buildBody({options:n});d&&(e.__metadata={...e.__metadata,hasStreamingBody:!0});let f=await this.buildHeaders({options:e,method:i,bodyHeaders:l,retryCount:r});return{req:{method:i,headers:f,...n.signal&&{signal:n.signal},...globalThis.ReadableStream&&u instanceof globalThis.ReadableStream&&{duplex:"half"},...u&&{body:u},...this.fetchOptions??{},...n.fetchOptions??{}},url:c,timeout:n.timeout}}async buildHeaders({options:e,method:r,bodyHeaders:n,retryCount:i}){let s={};this.idempotencyHeader&&r!=="get"&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),s[this.idempotencyHeader]=e.idempotencyKey);let o=fe([s,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(i),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...vDe(),"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=fe([r]),i=typeof globalThis.ReadableStream<"u"&&e instanceof globalThis.ReadableStream,s=!i&&(typeof e=="string"||e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof globalThis.Blob<"u"&&e instanceof globalThis.Blob||e instanceof URLSearchParams||e instanceof FormData);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e=="string"&&n.values.has("content-type")||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||i?{bodyHeaders:void 0,body:e,isStreamingBody:!s}:typeof e=="object"&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&typeof e.next=="function")?{bodyHeaders:void 0,body:QL(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}:{...W(this,RD,"f").call(this,{body:e,headers:n}),isStreamingBody:!1}}};cZ=He,RD=new WeakMap,aZ=new WeakSet,mMe=function(){return this.baseURL!=="https://api.openai.com/v1"};He.OpenAI=cZ;He.DEFAULT_TIMEOUT=6e5;He.OpenAIError=Re;He.APIError=dr;He.APIConnectionError=Xu;He.APIConnectionTimeoutError=Qu;He.APIUserAbortError=Rr;He.NotFoundError=my;He.ConflictError=gy;He.RateLimitError=yy;He.BadRequestError=fy;He.AuthenticationError=py;He.InternalServerError=Sy;He.PermissionDeniedError=hy;He.UnprocessableEntityError=_y;He.InvalidWebhookSignatureError=Pa;He.toFile=aD;He.Completions=Mp;He.Chat=id;He.Embeddings=Fp;He.Files=qp;He.Images=Hp;He.Audio=La;He.Moderations=Wp;He.Models=Gp;He.FineTuning=xo;He.Graders=fd;He.VectorStores=ul;He.Webhooks=Jp;He.Beta=Ro;He.Batches=Np;He.Uploads=hd;He.Responses=cl;He.Realtime=al;He.Conversations=ud;He.Evals=dd;He.Containers=ld;He.Skills=ll;He.Videos=Kp;var ks=Ee("runner_codex"),lZ="Codex CLI",iS="gpt-5.6-sol";async function gDt({aiGateway:t,config:e,model:r}){let n=r;if(t)if(e.modelVersionOverrides?.codex){let i=e.modelVersionOverrides?.codex?.[e.accountType];if(i){if(!await t.isModelAvailableForProvider("openai",i))throw new Error(`Model override '${i}' is not available for openai provider`);n=i}}else if(r){if(!await t.isModelAvailableForProvider("openai",r))throw new Error(`Model '${r}' is not available for openai provider`)}else!!iS&&await t.isModelAvailableForProvider("openai",iS)?(n=iS,ks.log(`Using default model: ${iS}`)):iS&&ks.log(`Default model ${iS} is not available, proceeding without model specification`);return n}var xD="netlify-ask-db",_Dt=`default_permissions = "${xD}"`,yDt=t=>["",`[permissions.${xD}]`,'description = "Ask mode: read-only filesystem, network limited to the project database"','extends = ":read-only"',"",`[permissions.${xD}.network]`,"enabled = true","",`[permissions.${xD}.network.domains]`,`"${t}" = "allow"`,'"*" = "deny"'];function SDt({aiGateway:t}){if(t){let{token:e,url:r}=t;if(!e||!r)throw new Error("No token or url provided from AI Gateway");md.env.OPENAI_API_KEY=e,md.env.OPENAI_BASE_URL=r}else if(!md.env.OPENAI_API_KEY)throw new Error("OPENAI_API_KEY is not provided")}async function uZ({config:t,netlify:e,persistSteps:r,sendSteps:n,aiGateway:i,continueSession:s,priorAgentSessionId:o,cwd:a=md.cwd(),abortSignal:c,onSessionId:l,effortOverride:u}){let{prompt:d}=t,{model:f}=t;SDt({aiGateway:i});let p=await gDt({config:t,aiGateway:i,model:f}),h=[],m=[],_=[],y={},E=new Set,S=0,g=0,w,P,x,A,O,R=Wm(t),b=`${md.env.NVM_BIN}/node`,D=sS.join(ID.homedir(),".codex"),C=sS.join(D,"config.toml"),T=sS.join(D,"auth.json");try{await y0.mkdir(D,{recursive:!0});let ne={OPENAI_API_KEY:md.env.OPENAI_API_KEY};await y0.writeFile(T,JSON.stringify(ne,null,2),"utf-8"),ks.log("Created Codex auth.json file");let $=md.env.OPENAI_BASE_URL,de=['forced_login_method = "api"'],Y=nt().questionsEnabled;R&&de.push(_Dt),$&&de.push('model_provider = "openai_proxy"',"","[model_providers.openai_proxy]",'name = "OpenAI Proxy"',`base_url = "${$}"`,'env_key = "OPENAI_API_KEY"','wire_api = "responses"',"supports_websockets = false","requires_openai_auth = true"),Y&&de.push(...dge()),R&&de.push(...yDt(R.host)),await y0.writeFile(C,`${de.join(`
|
|
669
|
+
`);this.baseURL=c.baseURL,this.timeout=c.timeout??cZ.DEFAULT_TIMEOUT,this.logger=c.logger??console;let l="warn";this.logLevel=l,this.logLevel=DJ(c.logLevel,"ClientOptions.logLevel",this)??DJ(ad("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??l,this.fetchOptions=c.fetchOptions,this.maxRetries=c.maxRetries??2,this.fetch=c.fetch??XL(),De(this,RD,TDe,"f"),this._options=c,o&&(this._workloadIdentityAuth=new sD(o,this.fetch)),this.apiKey=typeof r=="string"?r:"Missing Key",this.organization=n,this.project=i,this.webhookSecret=s}withOptions(e){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,workloadIdentity:this._options.workloadIdentity,organization:this.organization,project:this.project,webhookSecret:this.webhookSecret,...e})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:r}){}async authHeaders(e){return fe([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(e){return NDe(e)}getUserAgent(){return`${this.constructor.name}/JS ${ed}`}defaultIdempotencyKey(){return`stainless-node-retry-${bJ()}`}makeStatusError(e,r,n,i){return dr.generate(e,r,n,i)}async _callApiKey(){let e=this._options.apiKey;if(typeof e!="function")return!1;let r;try{r=await e()}catch(n){throw n instanceof Re?n:new Re(`Failed to get token from 'apiKey' function: ${n.message}`,{cause:n})}if(typeof r!="string"||!r)throw new Re(`Expected 'apiKey' function argument to return a string but it returned ${r}`);return this.apiKey=r,!0}buildURL(e,r,n){let i=!W(this,aZ,"m",mMe).call(this)&&n||this.baseURL,s=pDe(e)?new URL(e):new URL(i+(i.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),o=this.defaultQuery(),a=Object.fromEntries(s.searchParams);return(!AJ(o)||!AJ(a))&&(r={...a,...o,...r}),typeof r=="object"&&r&&!Array.isArray(r)&&(s.search=this.stringifyQuery(r)),s.toString()}async prepareOptions(e){await this._callApiKey()}async prepareRequest(e,{url:r,options:n}){}get(e,r){return this.methodRequest("get",e,r)}post(e,r){return this.methodRequest("post",e,r)}patch(e,r){return this.methodRequest("patch",e,r)}put(e,r){return this.methodRequest("put",e,r)}delete(e,r){return this.methodRequest("delete",e,r)}methodRequest(e,r,n){return this.request(Promise.resolve(n).then(i=>({method:e,path:r,...i})))}request(e,r=null){return new Ip(this,this.makeRequest(e,r,void 0))}async makeRequest(e,r,n){let i=await e,s=i.maxRetries??this.maxRetries;r==null&&(r=s),await this.prepareOptions(i);let{req:o,url:a,timeout:c}=await this.buildRequest(i,{retryCount:s-r});await this.prepareRequest(o,{url:a,options:i});let l="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),u=n===void 0?"":`, retryOf: ${n}`,d=Date.now();if(Er(this).debug(`[${l}] sending request`,rl({retryOfRequestLogID:n,method:i.method,url:a,options:i,headers:o.headers})),i.signal?.aborted)throw new Rr;let f=new AbortController,p=await this.fetchWithAuth(a,o,c,f).catch(Zw),h=Date.now();if(p instanceof globalThis.Error){let y=`retrying, ${r} attempts remaining`;if(i.signal?.aborted)throw new Rr;let E=Jw(p)||/timed? ?out/i.test(String(p)+("cause"in p?String(p.cause):""));if(r)return Er(this).info(`[${l}] connection ${E?"timed out":"failed"} - ${y}`),Er(this).debug(`[${l}] connection ${E?"timed out":"failed"} (${y})`,rl({retryOfRequestLogID:n,url:a,durationMs:h-d,message:p.message})),this.retryRequest(i,r,n??l);throw Er(this).info(`[${l}] connection ${E?"timed out":"failed"} - error; no more retries left`),Er(this).debug(`[${l}] connection ${E?"timed out":"failed"} (error; no more retries left)`,rl({retryOfRequestLogID:n,url:a,durationMs:h-d,message:p.message})),p instanceof Rp||p instanceof Xw?p:E?new Qu:new Xu({cause:p})}let m=[...p.headers.entries()].filter(([y])=>y==="x-request-id").map(([y,E])=>", "+y+": "+JSON.stringify(E)).join(""),_=`[${l}${u}${m}] ${o.method} ${a} ${p.ok?"succeeded":"failed"} with status ${p.status} in ${h-d}ms`;if(!p.ok){if(p.status===401&&this._workloadIdentityAuth&&!i.__metadata?.hasStreamingBody&&!i.__metadata?.workloadIdentityTokenRefreshed)return await IJ(p.body),this._workloadIdentityAuth.invalidateToken(),this.makeRequest({...i,__metadata:{...i.__metadata,workloadIdentityTokenRefreshed:!0}},r,n??l);let y=await this.shouldRetry(p);if(r&&y){let x=`retrying, ${r} attempts remaining`;return await IJ(p.body),Er(this).info(`${_} - ${x}`),Er(this).debug(`[${l}] response error (${x})`,rl({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:h-d})),this.retryRequest(i,r,n??l,p.headers)}let E=y?"error; no more retries left":"error; not retryable";Er(this).info(`${_} - ${E}`);let S=await p.text().catch(x=>Zw(x).message),g=gDe(S),w=g?void 0:S;throw Er(this).debug(`[${l}] response error (${E})`,rl({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,message:w,durationMs:Date.now()-d})),this.makeStatusError(p.status,g,w,p.headers)}return Er(this).info(_),Er(this).debug(`[${l}] response start`,rl({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:h-d})),{response:p,options:i,controller:f,requestLogID:l,retryOfRequestLogID:n,startTime:d}}getAPIList(e,r,n){return this.requestAPIList(r,n&&"then"in n?n.then(i=>({method:"get",path:e,...i})):{method:"get",path:e,...n})}requestAPIList(e,r){let n=this.makeRequest(r,null,void 0);return new i0(this,n,e)}async fetchWithAuth(e,r,n,i){if(this._workloadIdentityAuth){let o=r.headers,a=o.get("Authorization");if(!a||a===`Bearer ${oZ}`){let c=await this._workloadIdentityAuth.getToken();o.set("Authorization",`Bearer ${c}`)}}return await this.fetchWithTimeout(e,r,n,i)}async fetchWithTimeout(e,r,n,i){let{signal:s,method:o,...a}=r||{},c=this._makeAbort(i);s&&s.addEventListener("abort",c,{once:!0});let l=setTimeout(c,n),u=globalThis.ReadableStream&&a.body instanceof globalThis.ReadableStream||typeof a.body=="object"&&a.body!==null&&Symbol.asyncIterator in a.body,d={signal:i.signal,...u?{duplex:"half"}:{},method:"GET",...a};o&&(d.method=o.toUpperCase());try{return await this.fetch.call(void 0,e,d)}finally{clearTimeout(l)}}async shouldRetry(e){let r=e.headers.get("x-should-retry");return r==="true"?!0:r==="false"?!1:e.status===408||e.status===409||e.status===429||e.status>=500}async retryRequest(e,r,n,i){let s,o=i?.get("retry-after-ms");if(o){let c=parseFloat(o);Number.isNaN(c)||(s=c)}let a=i?.get("retry-after");if(a&&!s){let c=parseFloat(a);Number.isNaN(c)?s=Date.parse(a)-Date.now():s=c*1e3}if(s===void 0){let c=e.maxRetries??this.maxRetries;s=this.calculateDefaultRetryTimeoutMillis(r,c)}return await Ca(s),this.makeRequest(e,r-1,n)}calculateDefaultRetryTimeoutMillis(e,r){let s=r-e,o=Math.min(.5*Math.pow(2,s),8),a=1-Math.random()*.25;return o*a*1e3}async buildRequest(e,{retryCount:r=0}={}){let n={...e},{method:i,path:s,query:o,defaultBaseURL:a}=n,c=this.buildURL(s,o,a);"timeout"in n&&mDe("timeout",n.timeout),n.timeout=n.timeout??this.timeout;let{bodyHeaders:l,body:u,isStreamingBody:d}=this.buildBody({options:n});d&&(e.__metadata={...e.__metadata,hasStreamingBody:!0});let f=await this.buildHeaders({options:e,method:i,bodyHeaders:l,retryCount:r});return{req:{method:i,headers:f,...n.signal&&{signal:n.signal},...globalThis.ReadableStream&&u instanceof globalThis.ReadableStream&&{duplex:"half"},...u&&{body:u},...this.fetchOptions??{},...n.fetchOptions??{}},url:c,timeout:n.timeout}}async buildHeaders({options:e,method:r,bodyHeaders:n,retryCount:i}){let s={};this.idempotencyHeader&&r!=="get"&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),s[this.idempotencyHeader]=e.idempotencyKey);let o=fe([s,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(i),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...vDe(),"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=fe([r]),i=typeof globalThis.ReadableStream<"u"&&e instanceof globalThis.ReadableStream,s=!i&&(typeof e=="string"||e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof globalThis.Blob<"u"&&e instanceof globalThis.Blob||e instanceof URLSearchParams||e instanceof FormData);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e=="string"&&n.values.has("content-type")||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||i?{bodyHeaders:void 0,body:e,isStreamingBody:!s}:typeof e=="object"&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&typeof e.next=="function")?{bodyHeaders:void 0,body:QL(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}:{...W(this,RD,"f").call(this,{body:e,headers:n}),isStreamingBody:!1}}};cZ=He,RD=new WeakMap,aZ=new WeakSet,mMe=function(){return this.baseURL!=="https://api.openai.com/v1"};He.OpenAI=cZ;He.DEFAULT_TIMEOUT=6e5;He.OpenAIError=Re;He.APIError=dr;He.APIConnectionError=Xu;He.APIConnectionTimeoutError=Qu;He.APIUserAbortError=Rr;He.NotFoundError=my;He.ConflictError=gy;He.RateLimitError=yy;He.BadRequestError=fy;He.AuthenticationError=py;He.InternalServerError=Sy;He.PermissionDeniedError=hy;He.UnprocessableEntityError=_y;He.InvalidWebhookSignatureError=Pa;He.toFile=aD;He.Completions=Mp;He.Chat=id;He.Embeddings=Fp;He.Files=qp;He.Images=Hp;He.Audio=La;He.Moderations=Wp;He.Models=Gp;He.FineTuning=xo;He.Graders=fd;He.VectorStores=ul;He.Webhooks=Jp;He.Beta=Ro;He.Batches=Np;He.Uploads=hd;He.Responses=cl;He.Realtime=al;He.Conversations=ud;He.Evals=dd;He.Containers=ld;He.Skills=ll;He.Videos=Kp;var ks=Ee("runner_codex"),lZ="Codex CLI",iS="gpt-5.6-sol";async function gDt({aiGateway:t,config:e,model:r}){let n=r;if(t)if(e.modelVersionOverrides?.codex){let i=e.modelVersionOverrides?.codex?.[e.accountType];if(i){if(!await t.isModelAvailableForProvider("openai",i))throw new Error(`Model override '${i}' is not available for openai provider`);n=i}}else if(r){if(!await t.isModelAvailableForProvider("openai",r))throw new Error(`Model '${r}' is not available for openai provider`)}else!!iS&&await t.isModelAvailableForProvider("openai",iS)?(n=iS,ks.log(`Using default model: ${iS}`)):iS&&ks.log(`Default model ${iS} is not available, proceeding without model specification`);return n}var xD="netlify-ask-db",_Dt=`default_permissions = "${xD}"`,yDt=t=>["",`[permissions.${xD}]`,'description = "Ask mode: read-only filesystem, network limited to the project database"','extends = ":read-only"',"",`[permissions.${xD}.network]`,"enabled = true","",`[permissions.${xD}.network.domains]`,`"${t}" = "allow"`];function SDt({aiGateway:t}){if(t){let{token:e,url:r}=t;if(!e||!r)throw new Error("No token or url provided from AI Gateway");md.env.OPENAI_API_KEY=e,md.env.OPENAI_BASE_URL=r}else if(!md.env.OPENAI_API_KEY)throw new Error("OPENAI_API_KEY is not provided")}async function uZ({config:t,netlify:e,persistSteps:r,sendSteps:n,aiGateway:i,continueSession:s,priorAgentSessionId:o,cwd:a=md.cwd(),abortSignal:c,onSessionId:l,effortOverride:u}){let{prompt:d}=t,{model:f}=t;SDt({aiGateway:i});let p=await gDt({config:t,aiGateway:i,model:f}),h=[],m=[],_=[],y={},E=new Set,S=0,g=0,w,P,x,A,O,R=Wm(t),b=`${md.env.NVM_BIN}/node`,D=sS.join(ID.homedir(),".codex"),C=sS.join(D,"config.toml"),T=sS.join(D,"auth.json");try{await y0.mkdir(D,{recursive:!0});let ne={OPENAI_API_KEY:md.env.OPENAI_API_KEY};await y0.writeFile(T,JSON.stringify(ne,null,2),"utf-8"),ks.log("Created Codex auth.json file");let $=md.env.OPENAI_BASE_URL,de=['forced_login_method = "api"'],Y=nt().questionsEnabled;R&&de.push(_Dt),$&&de.push('model_provider = "openai_proxy"',"","[model_providers.openai_proxy]",'name = "OpenAI Proxy"',`base_url = "${$}"`,'env_key = "OPENAI_API_KEY"','wire_api = "responses"',"supports_websockets = false","requires_openai_auth = true"),Y&&de.push(...dge()),R&&de.push(...yDt(R.host)),await y0.writeFile(C,`${de.join(`
|
|
670
670
|
`)}
|
|
671
671
|
`,"utf-8"),ks.log("Wrote Codex config.toml")}catch(ne){let $=ne instanceof Error?ne.message:String(ne);throw ks.warn("Failed to setup Codex config and credentials",{error:$}),new Error(`Codex setup failed: ${$}`)}let I=p==="gpt-5.6-sol",N=u??(I?"low":"high"),q=!!(s&&o),B="mode"in t&&t.mode==="ask",ce=!!R,_e=[oa(a,"codex"),"exec",...B&&!ce?["--sandbox","read-only"]:[],...q?["resume",o]:[],...B?[]:["--yolo"],"--json",...u?["-c",`model_reasoning_effort="${u}"`]:I?["-c",'model_reasoning_effort="low"']:[],...p?["--model",p]:[]].filter(Boolean);ks.log(`Running ${b} ${_e.join(" ")}`);let Te=e.utils.run(b,_e,{all:!0,cwd:a,env:{...md.env},stdin:"pipe",idleTimeout:za,cancelSignal:c});Te.stdin?.end(d);let Fe=Tl(()=>{r?.({steps:h,duration:g}),n?.({steps:m,duration:g}),m=[]},250),X=(ne,$)=>{let de={...ne,id:S};S+=1,_.push(de),h.push(de),m.push(de),$||Fe.flush(),Fe(),$&&Fe.flush()};X({title:`Using ${lZ} with ${p||"default"}`,category:se.Environment},!0);let Pe=mDt.createInterface({input:Te.all});Pe.on("error",ne=>{ks.error("Readline interface error",{error:ne.message,stack:ne.stack})}),Pe.on("line",ne=>{let $;try{$=JSON.parse(ne)}catch{ks.log("Could not parse line",ne);return}if($?.duration_ms&&(g=$.duration_ms),$?.type==="thread.started"&&typeof $?.thread_id=="string"&&(x=$.thread_id,l?.(x)),$?.type==="item.started"&&$?.item?.type==="command_execution")y[$.item.id]=$.item;else if($?.type==="item.completed"&&$?.item?.type==="command_execution"){let de=$.item,Y=bDt(de);Y&&X(Y,!0);let M=de.command?.match(/\.agents\/skills\/([^\s/]+)/)?.[1];if(M&&!E.has(M)){E.add(M);let F=Lo(M);Ha(ks,F),X({title:`Use ${F}`,category:se.Skill,type:M},!0)}}else if($?.type==="item.completed"&&$?.item?.type==="reasoning"){let de={title:"Reasoning",message:$.item.text,category:se.Reasoning};X(de,!0)}else if($?.type==="item.completed"&&$?.item?.type==="agent_message")w=$.item.text;else if($?.type==="item.started"&&$?.item?.type==="mcp_tool_call"){let de=$.item;if(de.server===Ym&&de.tool==="ask"&&!O){let Y=Rg.safeParse(de.arguments);Y.success?(O={questions:Y.data.questions,toolUseId:de.id},Te.kill()):(ks.warn("Ignoring malformed ask tool input",{toolUseId:de.id}),be.inc("inference.malformed_ask",1))}}else if($?.type==="turn.completed"&&$.usage)A={input_tokens:$.usage.input_tokens,output_tokens:$.usage.output_tokens},pu(A);else if($?.type==="turn.failed"&&$?.error?.message)P=$.error.message;else if($?.type==="local_shell_call"){let de=$;y[de.call_id]=de}else if($?.type==="local_shell_call_output"){let de=$,Y=y[de.call_id],M=TDt(Y,de);M&&X(M,!0);let z=(Y?.action?.command?.join(" ")??"").match(/\.agents\/skills\/([^\s/]+)/)?.[1];if(z&&!E.has(z)){E.add(z);let H=Lo(z);Ha(ks,H),X({title:`Use ${H}`,category:se.Skill,type:z},!0)}}else $?.type==="message"&&$.role==="assistant"?w=$.content?.map(de=>de.text).join(`
|
|
672
672
|
`):$?.type==="message"&&$.role==="system"&&(P=$.content?.map(de=>de.text).join(`
|
package/dist/index.js
CHANGED
|
@@ -98,7 +98,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
98
98
|
`,LF:`
|
|
99
99
|
`,concatBytes:mL},MDe=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},DDe={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:MDe};import{Buffer as LDe}from"buffer";var Tte=(t,e)=>t?void 0:$De.bind(void 0,e),$De=function*(t,e){if(typeof e!="string"&&!jt(e)&&!LDe.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},Ate=(t,e)=>t?UDe.bind(void 0,e):FDe.bind(void 0,e),UDe=function*(t,e){xte(t,e),yield e},FDe=function*(t,e){if(xte(t,e),typeof e!="string"&&!jt(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},xte=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
100
100
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
101
|
-
if (condition) { yield value; }`)};import{Buffer as BDe}from"buffer";import{StringDecoder as jDe}from"string_decoder";var tx=(t,e,r)=>{if(r)return;if(t)return{transform:zDe.bind(void 0,new TextEncoder)};let n=new jDe(e);return{transform:GDe.bind(void 0,n),final:VDe.bind(void 0,n)}},zDe=function*(t,e){BDe.isBuffer(e)?yield lo(e):typeof e=="string"?yield t.encode(e):yield e},GDe=function*(t,e){yield jt(e)?t.write(e):e},VDe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as wte}from"util";var _L=wte(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),rx=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=HDe}=e[r];for await(let i of n(t))yield*rx(i,e,r+1)},Rte=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*qDe(r,Number(e),t)},qDe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*rx(n,r,e+1)},Ite=wte(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),HDe=function*(t){yield t};var yL=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Cte=(t,e)=>[...e.flatMap(r=>[...Tl(r,t,0)]),...b_(t)],Tl=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=YDe}=e[r];for(let i of n(t))yield*Tl(i,e,r+1)},b_=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*WDe(r,Number(e),t)},WDe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Tl(n,r,e+1)},YDe=function*(t){yield t};var SL=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=Ote(t,o,s),l=bl(e),u=bl(r),d=l?_L.bind(void 0,rx,a):yL.bind(void 0,Tl),f=l||u?_L.bind(void 0,Rte,a):yL.bind(void 0,b_),p=l||u?Ite.bind(void 0,a):void 0;return{stream:new KDe({writableObjectMode:n,writableHighWaterMark:Pte(n),readableObjectMode:i,readableHighWaterMark:Pte(i),transform(m,S,T){d([m,c,0],this,T)},flush(m){f([c],this,m)},destroy:p})}},nx=(t,e,r,n)=>{let i=e.filter(({type:o})=>o==="generator"),s=n?i.reverse():i;for(let{value:o,optionName:a}of s){let c=Ote(o,r,a);t=Cte(c,t)}return t},Ote=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:Tte(n,a)},tx(r,o,n),ex(r,s,n,c),{transform:t,final:e},{transform:Ate(i,a)},bte({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var Nte=(t,e)=>{for(let r of ZDe(t))JDe(t,r,e)},ZDe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),JDe=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Ra[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>XDe(a,n));r.input=f_(o)},XDe=(t,e)=>{let r=nx(t,e,"utf8",!0);return QDe(r),f_(r)},QDe=t=>{let e=t.find(r=>typeof r!="string"&&!jt(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 nLe,appendFileSync as iLe}from"fs";var ix=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Qd(r,n)&&!mn.has(e)&&eLe(n)&&(t.some(({type:i,value:s})=>i==="native"&&tLe.has(s))||t.every(({type:i})=>qn.has(i))),eLe=t=>t===1||t===2,tLe=new Set(["pipe","overlapped"]),kte=async(t,e,r,n)=>{for await(let i of t)rLe(e)||Dte(i,r,n)},Mte=(t,e,r)=>{for(let n of t)Dte(n,e,r)},rLe=t=>t._readableState.pipes.length>0,Dte=(t,e,r)=>{let n=yA(t);os({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Lte=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let s={},o=new Set([]);return{output:e.map((c,l)=>sLe({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},sLe=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=$ee(t,s,d),p=lo(f),{stdioItems:h,objectMode:m}=e[r],S=oLe([p],h,c,n),{serializedResult:T,finalResult:E=T}=aLe({chunks:S,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});cLe({serializedResult:T,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let A=a[r]?E:void 0;try{return n.error===void 0&&lLe(T,h,i),A}catch(v){return n.error=v,A}},oLe=(t,e,r,n)=>{try{return nx(t,e,r,!1)}catch(i){return n.error=i,t}},aLe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:f_(t)};let o=JX(t,r);return n[s]?{serializedResult:o,finalResult:gL(o,!i[s],e)}:{serializedResult:o}},cLe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!ix({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=gL(t,!1,o);try{Mte(a,e,n)}catch(c){r.error??=c}},lLe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>XA.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?iLe(n,t):(r.add(s),nLe(n,t))}};var $te=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,po(e,r,"all")]:Array.isArray(e)?[po(t,r,"all"),...e]:jt(t)&&jt(e)?xD([t,e]):`${t}${e}`};import{once as EL}from"events";var Ute=async(t,e)=>{let[r,n]=await uLe(t);return e.isForcefullyTerminated??=!1,[r,n]},uLe=async t=>{let[e,r]=await Promise.allSettled([EL(t,"spawn"),EL(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Fte(t):r.value},Fte=async t=>{try{return await EL(t,"exit")}catch{return Fte(t)}},Bte=async t=>{let[e,r]=await t;if(!dLe(e,r)&&vL(e,r))throw new Ai;return[e,r]},dLe=(t,e)=>t===void 0&&e===void 0,vL=(t,e)=>t!==0||e!==null;var jte=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=fLe(t,e,r),o=s?.code==="ETIMEDOUT",a=Lee(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},fLe=(t,e,r)=>t!==void 0?t:vL(e,r)?new Ai:void 0;var zte=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=hLe(t,e,r),d=_Le({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return uf(d,c,l)},hLe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=EA(t,e,r),a=mLe(r),{file:c,commandArguments:l,options:u}=BA(t,e,a);gLe(u);let d=yte(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},mLe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,gLe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&sx("ipcInput"),t&&sx("ipc: true"),r&&sx("detached: true"),n&&sx("cancelSignal")},sx=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},_Le=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=yLe({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=jte(c,r),{output:h,error:m=l}=Lte({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),S=h.map((E,A)=>po(E,r,A)),T=po($te(h,r),r,"all");return ELe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:S,all:T,options:r,command:n,escapedCommand:i,startTime:a})},yLe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{Nte(s,r);let a=SLe(r);return pLe(...jA(t,e,a))}catch(a){return lf({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},SLe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:YA(e)}),ELe=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:s,all:o,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?KA({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):v_({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as a1e}from"events";import{spawn as c1e}from"child_process";import Wte from"process";import{once as bL,on as vLe}from"events";var Gte=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(rf({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:MA(t)}),bLe({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),bLe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{PA(e,i);let s=wa(t,e,r),o=new AbortController;try{return await Promise.race([TLe(s,n,o),ALe(s,r,o),xLe(s,r,o)])}catch(a){throw nf(t),a}finally{o.abort(),OA(e,i)}},TLe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await bL(t,"message",{signal:r});return n}for await(let[n]of vLe(t,"message",{signal:r}))if(e(n))return n},ALe=async(t,e,{signal:r})=>{await bL(t,"disconnect",{signal:r}),C7(e)},xLe=async(t,e,{signal:r})=>{let[n]=await bL(t,"strict:error",{signal:r});throw RA(n,e)};import{once as qte,on as wLe}from"events";var Hte=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>TL({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),TL=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{rf({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:MA(t)}),PA(e,s);let o=wa(t,e,r),a=new AbortController,c={};return RLe(t,o,a),ILe({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),CLe({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},RLe=async(t,e,r)=>{try{await qte(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},ILe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await qte(t,"strict:error",{signal:r.signal});n.error=RA(i,e),r.abort()}catch{}},CLe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of wLe(r,"message",{signal:s.signal}))Vte(o),yield c}catch{Vte(o)}finally{s.abort(),OA(e,a),n||nf(t),i&&await t}},Vte=({error:t})=>{if(t)throw t};var Yte=(t,{ipc:e})=>{Object.assign(t,Zte(t,!1,e))},Kte=()=>{let t=Wte,e=!0,r=Wte.channel!==void 0;return{...Zte(t,e,r),getCancelSignal:ree.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Zte=(t,e,r)=>({sendMessage:UA.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Gte.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Hte.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as PLe}from"child_process";import{PassThrough as OLe,Readable as NLe,Writable as kLe,Duplex as MLe}from"stream";var Jte=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{pL(n);let a=new PLe;DLe(a,n),Object.assign(a,{readable:LLe,writable:$Le,duplex:ULe});let c=lf({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=FLe(c,o,i);return{subprocess:a,promise:l}},DLe=(t,e)=>{let r=T_(),n=T_(),i=T_(),s=Array.from({length:e.length-3},T_),o=T_(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},T_=()=>{let t=new OLe;return t.end(),t},LLe=()=>new NLe({read(){}}),$Le=()=>new kLe({write(){}}),ULe=()=>new MLe({read(){},write(){}}),FLe=async(t,e,r)=>uf(t,e,r);import{createReadStream as Xte,createWriteStream as Qte}from"fs";import{Buffer as BLe}from"buffer";import{Readable as A_,Writable as jLe,Duplex as zLe}from"stream";var tre=(t,e)=>QA(GLe,t,e,!1),x_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Ra[t]}.`)},ere={fileNumber:x_,generator:SL,asyncGenerator:SL,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:zLe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},GLe={input:{...ere,fileUrl:({value:t})=>({stream:Xte(t)}),filePath:({value:{file:t}})=>({stream:Xte(t)}),webStream:({value:t})=>({stream:A_.fromWeb(t)}),iterable:({value:t})=>({stream:A_.from(t)}),asyncIterable:({value:t})=>({stream:A_.from(t)}),string:({value:t})=>({stream:A_.from(t)}),uint8Array:({value:t})=>({stream:A_.from(BLe.from(t))})},output:{...ere,fileUrl:({value:t})=>({stream:Qte(t)}),filePath:({value:{file:t,append:e}})=>({stream:Qte(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:jLe.fromWeb(t)}),iterable:x_,asyncIterable:x_,string:x_,uint8Array:x_}};import{on as VLe,once as rre}from"events";import{PassThrough as qLe,getDefaultHighWaterMark as HLe}from"stream";import{finished as sre}from"stream/promises";function Al(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)xL(i);let e=t.some(({readableObjectMode:i})=>i),r=WLe(t,e),n=new AL({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var WLe=(t,e)=>{if(t.length===0)return HLe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},AL=class extends qLe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(xL(e),this.#e.has(e))return;this.#e.add(e),this.#n??=YLe(this,this.#e,this.#s);let r=JLe({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#s});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(xL(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},YLe=async(t,e,r)=>{ox(t,nre);let n=new AbortController;try{await Promise.race([KLe(t,n),ZLe(t,e,r,n)])}finally{n.abort(),ox(t,-nre)}},KLe=async(t,{signal:e})=>{try{await sre(t,{signal:e,cleanup:!0})}catch(r){throw ore(t,r),r}},ZLe=async(t,e,r,{signal:n})=>{for await(let[i]of VLe(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},xL=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},JLe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{ox(t,ire);let a=new AbortController;try{await Promise.race([XLe(s,e,a),QLe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),e$e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),ox(t,-ire)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?wL(t):t$e(t))},XLe=async(t,e,{signal:r})=>{try{await t,r.aborted||wL(e)}catch(n){r.aborted||ore(e,n)}},QLe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await sre(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;are(o)?i.add(e):cre(t,o)}},e$e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await rre(t,i,{signal:s}),!t.readable)return rre(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},t$e=t=>{t.writable&&t.end()},ore=(t,e)=>{are(e)?wL(t):cre(t,e)},are=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",wL=t=>{(t.readable||t.writable)&&t.destroy()},cre=(t,e)=>{t.destroyed||(t.once("error",r$e),t.destroy(e))},r$e=()=>{},ox=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},nre=2,ire=1;import{finished as lre}from"stream/promises";var ff=(t,e)=>{t.pipe(e),n$e(t,e),i$e(t,e)},n$e=async(t,e)=>{if(!(Ti(t)||Ti(e))){try{await lre(t,{cleanup:!0,readable:!0,writable:!1})}catch{}RL(e)}},RL=t=>{t.writable&&t.end()},i$e=async(t,e)=>{if(!(Ti(t)||Ti(e))){try{await lre(e,{cleanup:!0,readable:!1,writable:!0})}catch{}IL(t)}},IL=t=>{t.readable&&t.destroy()};var ure=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:s,direction:o}]of Object.entries(e)){for(let{stream:a}of s.filter(({type:c})=>qn.has(c)))s$e(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!qn.has(c)))a$e({subprocess:t,stream:a,direction:o,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,s]of n.entries()){let o=s.length===1?s[0]:Al(s);ff(o,i)}},s$e=(t,e,r,n)=>{r==="output"?ff(t.stdio[n],e):ff(e,t.stdio[n]);let i=o$e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},o$e=["stdin","stdout","stderr"],a$e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;c$e(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},c$e=(t,{signal:e})=>{Ti(t)&&El(t,l$e,e)},l$e=2;import{addAbortListener as f$e}from"events";var xl=[];xl.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&xl.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&xl.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var ax=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",CL=Symbol.for("signal-exit emitter"),PL=globalThis,u$e=Object.defineProperty.bind(Object),OL=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(PL[CL])return PL[CL];u$e(PL,CL,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let s of this.listeners[e])i=s(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},cx=class{},d$e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),NL=class extends cx{onExit(){return()=>{}}load(){}unload(){}},kL=class extends cx{#e=ML.platform==="win32"?"SIGINT":"SIGHUP";#r=new OL;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of xl)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,s=e;if(typeof s.__signal_exit_emitter__=="object"&&typeof s.__signal_exit_emitter__.count=="number"&&(i+=s.__signal_exit_emitter__.count),n.length===i){this.unload();let o=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;o||e.kill(e.pid,a)}};this.#s=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!ax(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 xl)try{let r=this.#i[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#o&&(this.#o=!1,xl.forEach(e=>{let r=this.#i[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#s,this.#r.count-=1)}#a(e){return ax(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#s.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&ax(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let i=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),i}else return n.call(this.#t,e,...r)}},ML=globalThis.process,{onExit:dre,load:vyt,unload:byt}=d$e(ax(ML)?new kL(ML):new NL);var fre=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=dre(()=>{t.kill()});f$e(n,()=>{i()})};var hre=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=SA(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=p$e(r,n,i),{sourceStream:d,sourceError:f}=m$e(t,l),{options:p,fileDescriptors:h}=cs.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},p$e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=h$e(t,e,...r),a=CA(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},h$e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(pre,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||TD(r)){if(Object.keys(t).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[i,s,o]=lA(r,...n);return{destination:e(pre)(i,s,o),pipeOptions:o}}if(cs.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}`)},pre=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),m$e=(t,e)=>{try{return{sourceStream:sf(t,e)}}catch(r){return{sourceError:r}}};var gre=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=g$e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw DL({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},g$e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return IL(t),n;if(e!==void 0)return RL(r),e},DL=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>lf({error:t,command:mre,escapedCommand:mre,fileDescriptors:e,options:r,startTime:n,isSync:!1}),mre="source.pipe(destination)";var _re=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:s,value:o=s}]=await t;if(o.pipedFrom.includes(n)||o.pipedFrom.push(n),i==="rejected")throw o;if(e==="rejected")throw n;return o};import{finished as _$e}from"stream/promises";var yre=(t,e,r)=>{let n=lx.has(e)?S$e(t,e):y$e(t,e);return El(t,v$e,r.signal),El(e,b$e,r.signal),E$e(e),n},y$e=(t,e)=>{let r=Al([t]);return ff(r,e),lx.set(e,r),r},S$e=(t,e)=>{let r=lx.get(e);return r.add(t),r},E$e=async t=>{try{await _$e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}lx.delete(t)},lx=new WeakMap,v$e=2,b$e=1;import{aborted as T$e}from"util";var Sre=(t,e)=>t===void 0?[]:[A$e(t,e)],A$e=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await T$e(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw DL({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var ux=(t,...e)=>{if(Pt(e[0]))return ux.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=hre(t,...e),i=x$e({...n,destination:r});return i.pipe=ux.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},x$e=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=w$e(t,i);gre({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=yre(e,s,d);return await Promise.race([_re(u),...Sre(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},w$e=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as k$e}from"timers/promises";import{on as R$e}from"events";import{getDefaultHighWaterMark as I$e}from"stream";var dx=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return C$e(e,o),vre({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},C$e=async(t,e)=>{try{await t}catch{}finally{e.abort()}},LL=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;P$e(e,o,t);let a=t.readableObjectMode&&!s;return vre({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},P$e=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},vre=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=R$e(t,"data",{signal:e.signal,highWaterMark:Ere,highWatermark:Ere});return O$e({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},$L=I$e(!0),Ere=$L,O$e=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=N$e({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Tl(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*b_(a)}},N$e=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[tx(t,r,!e),ex(t,i,!n,{})].filter(Boolean);var bre=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=M$e({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([D$e(t),d]);return}let f=hL(c,r),p=LL({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([L$e({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},M$e=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!ix({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=LL({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await kte(a,t,r,s)},D$e=async t=>{await k$e(),t.readableFlowing===null&&t.resume()},L$e=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await qA(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await HA(r,{maxBuffer:s})):await cf(r,{maxBuffer:s})}catch(a){return Tre(kee({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},UL=async t=>{try{return await t}catch(e){return Tre(e)}},Tre=({bufferedData:t})=>KX(t)?new Uint8Array(t):t;import{finished as $$e}from"stream/promises";var w_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=U$e(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],$$e(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||j$e(a,e,r,n)}finally{o.abort()}},U$e=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&F$e(t,r,n),n},F$e=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{B$e(e,r),n.call(t,...i)}},B$e=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},j$e=(t,e,r,n)=>{if(!z$e(t,e,r,n))throw t},z$e=(t,e,r,n=!0)=>r.propagating?Are(t)||fx(t):(r.propagating=!0,FL(r,e)===n?Are(t):fx(t)),FL=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",fx=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Are=t=>t?.code==="EPIPE";var xre=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>BL({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),BL=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=w_(t,e,l);if(FL(l,e)){await u;return}let[d]=await Promise.all([bre({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var wre=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Al([t,e].filter(Boolean)):void 0,Rre=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>BL({...G$e(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:V$e(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),G$e=({stdout:t,stderr:e,all:r},[,n,i])=>{let s=n||i;return s?n?i?{stream:r,buffer:s}:{stream:t,buffer:s}:{stream:e,buffer:s}:{stream:r,buffer:s}},V$e=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as q$e}from"events";var Ire=t=>Qd(t,"ipc"),Cre=(t,e)=>{let r=yA(t);os({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Pre=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=Ire(s),a=uo(e,"ipc"),c=uo(r,"ipc");for await(let l of TL({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Mee(t,i,c),i.push(l)),o&&Cre(l,s);return i},Ore=async(t,e)=>(await Promise.allSettled([t]),e);var Nre=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:S,controller:T})=>{let E=Ute(t,f),A={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:E,propagating:!1},v=xre({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:A}),R=Rre({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:A}),P=[],L=Pre({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:P,verboseInfo:p}),C=H$e(m,t,A),N=W$e(h,A);try{return await Promise.race([Promise.all([{},Bte(E),Promise.all(v),R,L,fee(t,d),...C,...N]),S,Y$e(t,T),...aee(t,s,f,T),...I7({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:T}),...see({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:T})])}catch(B){return f.terminationReason??="other",Promise.all([{error:B},E,Promise.all(v.map(_=>UL(_))),UL(R),Ore(L,P),Promise.allSettled(C),Promise.allSettled(N)])}},H$e=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:w_(n,i,r)),W$e=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>wi(s,{checkOpen:!1})&&!Ti(s)).map(({type:i,value:s,stream:o=s})=>w_(o,n,e,{isSameDirection:qn.has(i),stopOnExit:i==="native"}))),Y$e=async(t,{signal:e})=>{let[r]=await q$e(t,"error",{signal:e});throw r};var kre=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),R_=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=as();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},pf=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 K$e}from"stream";import{callbackify as Z$e}from"util";import{finished as Mre}from"stream/promises";var jL=async t=>{if(t!==void 0)try{await zL(t)}catch{}},Dre=async t=>{if(t!==void 0)try{await GL(t)}catch{}},zL=async t=>{await Mre(t,{cleanup:!0,readable:!1,writable:!0})},GL=async t=>{await Mre(t,{cleanup:!0,readable:!0,writable:!1})},px=async(t,e)=>{if(await t,e)throw e},hx=(t,e,r)=>{r&&!fx(r)?t.destroy(r):e&&t.destroy()};var Lre=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||mn.has(r),{subprocessStdout:a,waitReadableDestroy:c}=VL(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=qL(a,o),{read:f,onStdoutDataDone:p}=HL({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new K$e({read:f,destroy:Z$e(YL.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return WL({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},VL=(t,e,r)=>{let n=sf(t,e),i=R_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},qL=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:$L},HL=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=as(),o=dx({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){J$e(this,o,s)},onStdoutDataDone:s}},J$e=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},WL=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await GL(t),await n,await jL(i),await e,r.readable&&r.push(null)}catch(s){await jL(i),$re(r,s)}},YL=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await pf(r,e)&&($re(t,n),await px(e,n))},$re=(t,e)=>{hx(t,t.readable,e)};import{Writable as X$e}from"stream";import{callbackify as Ure}from"util";var Fre=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=KL(t,r,e),o=new X$e({...ZL(n,t,i),destroy:Ure(XL.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return JL(n,o),o},KL=(t,e,r)=>{let n=CA(t,e),i=R_(r,n,"writableFinal"),s=R_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},ZL=(t,e,r)=>({write:Q$e.bind(void 0,t),final:Ure(e1e.bind(void 0,t,e,r))}),Q$e=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},e1e=async(t,e,r)=>{await pf(r,e)&&(t.writable&&t.end(),await e)},JL=async(t,e,r)=>{try{await zL(t),e.writable&&e.end()}catch(n){await Dre(r),Bre(e,n)}},XL=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await pf(r,e),await pf(n,e)&&(Bre(t,i),await px(e,i))},Bre=(t,e)=>{hx(t,t.writable,e)};import{Duplex as t1e}from"stream";import{callbackify as r1e}from"util";var jre=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||mn.has(r),{subprocessStdout:c,waitReadableDestroy:l}=VL(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=KL(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=qL(c,a),{read:S,onStdoutDataDone:T}=HL({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),E=new t1e({read:S,...ZL(u,t,d),destroy:r1e(n1e.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return WL({subprocessStdout:c,onStdoutDataDone:T,readable:E,subprocess:t,subprocessStdin:u}),JL(u,E,c),E},n1e=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([YL({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),XL({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var QL=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||mn.has(e),o=sf(t,r),a=dx({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return i1e(a,o,t)},i1e=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var zre=(t,{encoding:e})=>{let r=kre();t.readable=Lre.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Fre.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=jre.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=QL.bind(void 0,t,e),t[Symbol.asyncIterator]=QL.bind(void 0,t,e,{})};var Gre=(t,e)=>{for(let[r,n]of o1e){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},s1e=(async()=>{})().constructor.prototype,o1e=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(s1e,t)]);var Vre=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=l1e(t,e,r),{subprocess:f,promise:p}=d1e({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=ux.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Gre(f,p),cs.set(f,{options:u,fileDescriptors:d}),f},l1e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=EA(t,e,r),{file:a,commandArguments:c,options:l}=BA(t,e,r),u=u1e(l),d=tre(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},u1e=({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}},d1e=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=c1e(...jA(t,e,r))}catch(h){return Jte({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;a1e(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];ure(c,a,l),fre(c,r,l);let d={},f=as();c.kill=w7.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=wre(c,r),zre(c,r),Yte(c,r);let p=f1e({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:s,escapedCommand:o,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},f1e=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:s,command:o,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,S]=await Nre({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:l,controller:u});u.abort(),l.resolve();let T=h.map((v,R)=>po(v,e,R)),E=po(m,e,"all"),A=p1e({errorInfo:d,exitCode:f,signal:p,stdio:T,all:E,ipcOutput:S,context:c,options:e,command:o,escapedCommand:a,startTime:r});return uf(A,n,e)},p1e=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,context:o,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?v_({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 ls,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):KA({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var mx=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,h1e(n,t[n],i)]));return{...t,...r}},h1e=(t,e,r)=>m1e.has(t)&&Pt(e)&&Pt(r)?{...e,...r}:r,m1e=new Set(["env",...CD]);var Ia=(t,e,r,n)=>{let i=(o,a,c)=>Ia(o,a,r,c),s=(...o)=>g1e({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},g1e=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Pt(s))return i(t,mx(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=_1e({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?zte(a,c,l):Vre(a,c,l,i)},_1e=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=tQ(e)?rQ(e,r):[e,...r],[o,a,c]=lA(...s),l=mx(mx(n,i),c),{file:u=o,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:o,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var qre=({file:t,commandArguments:e})=>Wre(t,e),Hre=({file:t,commandArguments:e})=>({...Wre(t,e),isSync:!0}),Wre=(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]=y1e(t);return{file:r,commandArguments:n}},y1e=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(S1e)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},S1e=/ +/g;var Yre=(t,e,r)=>{t.sync=e(E1e,r),t.s=t.sync},Kre=({options:t})=>Zre(t),E1e=({options:t})=>({...Zre(t),isSync:!0}),Zre=t=>({options:{...v1e(t),...t}}),v1e=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Jre={preferLocal:!0};var Xre=Ia(()=>({})),dvt=Ia(()=>({isSync:!0})),Qre=Ia(qre),fvt=Ia(Hre),pvt=Ia(lee),hvt=Ia(Kre,{},Jre,Yre),{sendMessage:mvt,getOneMessage:gvt,getEachMessage:_vt,getCancelSignal:yvt}=Kte();var ene=!1,tne=()=>{ene=!0},ds=()=>ene;var I_=null,rne=t=>(I_&&I_.destroy(),I_=new ho({totalAllowedTime:t}),I_),nne=()=>I_;var ho=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&ds())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let s=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),o=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await rA({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{fe.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),s(),o&&clearTimeout(o)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var ine={name:"@netlify/agent-runner-cli",type:"module",version:"1.150.0-ex-2643.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.2","@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.219","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.1.5","@netlify/otel":"^6.0.4","@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",zod:"^4.4.3"}};var x1e=T1e(import.meta.url),w1e=mo.dirname(x1e),R1e=A1e(import.meta.url),hf=me("shell"),e$=new Set,sne={preferLocal:!0},kr=(t,e,r)=>{let[n,i]=I1e(e,r),s={...sne,...i},o=Xre(t,n,s);ane(o,s),une(o);let a=r?.idleTimeout;return a&&a>0&&lne(o,a),o},one=(t,e)=>{let r={...sne,...e},n=Qre(t,r);return ane(n,r),une(n),e?.idleTimeout&&e.idleTimeout>0&&lne(n,e.idleTimeout),n},I1e=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},ane=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(go.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new r_).pipe(go.stdout),t.stderr?.pipe(new r_).pipe(go.stderr);return}t.stdout?.pipe(go.stdout),t.stderr?.pipe(go.stderr)},t$=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(go.kill(-t.pid,e),hf.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return hf.error("Error killing process:",r),!1}},cne=t=>t$(t,"SIGKILL"),lne=(t,e)=>{let r=null,n=()=>{hf.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),t$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(hf.log(`Force killing idle process ${t.pid}`),cne(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let s=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",s),t.on("error",s)},une=t=>{e$.add(t);let e=nne();if(e){let r=e.onTimesUp(()=>{hf.log(`Global timer expired, killing process ${t.pid}`),t$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(hf.log(`Force killing process ${t.pid} after timeout`),cne(t))},5e3)});t.on("exit",()=>{e$.delete(t),r()}),t.on("error",()=>{e$.delete(t),r()})}};function fs(t,e){if(!go.env.NETLIFY_LOCAL_MODE)try{let i=R1e.resolve(ine.name),s=mo.dirname(i);for(;s!==mo.dirname(s);){let o=mo.dirname(s);if(mo.basename(o)==="node_modules"){let a=mo.join(o,".bin",e);if(gx.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(go.env.NODE_PATH){let i=mo.join(go.env.NODE_PATH,".bin",e);if(gx.existsSync(i))return i}let r=mo.join(t,"node_modules",".bin",e);if(gx.existsSync(r))return r;let n=mo.join(w1e,"..","node_modules",".bin",e);if(gx.existsSync(n))return n}var C1e=me("utils"),P1e=t=>new Promise(e=>{setTimeout(e,t)});var r$=t=>{try{return new URL(t).hostname||null}catch{return null}},_x=(t,e=3e3)=>{let r=!1,n=null,i=[],s=null,o=(...a)=>{if(r)return n=a,new Promise(u=>{i.push(u)});r=!0;let c,l=new Promise(u=>{c=u});return s=(async()=>{await Promise.resolve();let u=await t(...a);for(c(u);;){if(await P1e(e),!n)return r=!1,s=null,u;let d=n,f=i;n=null,i=[],u=await t(...d),f.forEach(p=>{p(u)})}})(),l};return o.flush=async()=>{if((r||n)&&s)return await s,o.flush()},o.cancel=()=>{n=null,i.forEach(a=>a(void 0)),i=[]},o},Ca=(t,e,r=!1)=>{let n=null,i=null,s=null,o=function(...a){i=a,s=this;let c=r&&!n;clearTimeout(n),n=setTimeout(()=>{n=null,r||(t.apply(s,i),i=null,s=null)},e),c&&(t.apply(s,i),i=null,s=null)};return o.cancel=()=>{clearTimeout(n),n=null,i=null,s=null},o.flush=()=>{if(n){clearTimeout(n);let a=i,c=s;n=null,i=null,s=null,t.apply(c,a)}},o},dne=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):C1e.error("Could not parse JSON",n))}},O1e=t=>t.charAt(0).toUpperCase()+t.slice(1),ps=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():O1e(e)).join(" ");function _o(t,e){e&&t.log(`Skill invoked: ${e}`)}var yx=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),fne=(t,e,r=!1)=>{if(r)return;let n=60,i=55,s=".netlify.app",o="agent-",a=6;if(!e)return`${o}${t.slice(0,a)}`;let c=`--${e}${s}`;if(c.length>i)return"";let l=n-c.length;if(l<=0)return"";if(l>=o.length+a){let u=Math.min(l-o.length,t.length);return`${o}${t.slice(0,u)}`}return t.slice(0,l)};var n$=t=>{let e=t.match(/<<-?\s*['"]?(\w+)['"]?/);if(!e)return{command:t};let r=t.indexOf(e[0]),n=t.slice(r+e[0].length).trim();return{command:t.slice(0,r).trim(),heredocContent:n||void 0}},N1e=1e4,i$=(t,e=N1e)=>{if(!t||typeof t!="string"||t.length<=e)return t;let n=t.startsWith("```")?"\n... [truncated]\n```":"... [truncated]";return t.slice(0,e)+n};import{Buffer as pne}from"buffer";import k1e from"path";var hne=me("repo"),Zr=(t,e={})=>kr("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),Sx=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{hne.info("Getting runner diffs");let n=await D1e(r),{hasChanges:i}=n,{status:s}=n;if(!i)return{hasChanges:!1};if(!e){let m=$1e(s);await U1e(m,r)}hne.info("Changes after processing"),await o$(r);let o=await c$(s,r);if(await s$(o,r),i=await L1e(r),!i)return{hasChanges:!1,ignored:o};await Zr(["commit","-m","Agent runner"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await Zr(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(i=!!l,!i)return await mne(r),{hasChanges:!1,ignored:o};let u=await Zr(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,p;if(t.sha){let m=await Zr(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let S=await Zr(["diff",t.sha,"HEAD","--binary"],a),T=String(S.stdout??"");f!==T&&(p=pne.from(T).toString("base64"))}await mne(r);let h={hasChanges:!0,diff:l,resultDiff:f,ignored:o};return l!==d&&(h.diffBinary=pne.from(d).toString("base64")),p&&(h.resultDiffBinary=p),h},mne=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Zr(["reset","--soft","HEAD~1"],{cwd:t})},s$=async(t=[],e=process.cwd())=>{await Zr(["add",".",...t],{cwd:e})},o$=async(t=process.cwd())=>{let e=await Zr(["status","-s"],{cwd:t});return String(e.stdout??"")},gne=/.. (.+)?\.log$/,M1e=[gne],D1e=async(t=process.cwd())=>{let e=await o$(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
101
|
+
if (condition) { yield value; }`)};import{Buffer as BDe}from"buffer";import{StringDecoder as jDe}from"string_decoder";var tx=(t,e,r)=>{if(r)return;if(t)return{transform:zDe.bind(void 0,new TextEncoder)};let n=new jDe(e);return{transform:GDe.bind(void 0,n),final:VDe.bind(void 0,n)}},zDe=function*(t,e){BDe.isBuffer(e)?yield lo(e):typeof e=="string"?yield t.encode(e):yield e},GDe=function*(t,e){yield jt(e)?t.write(e):e},VDe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as wte}from"util";var _L=wte(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),rx=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=HDe}=e[r];for await(let i of n(t))yield*rx(i,e,r+1)},Rte=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*qDe(r,Number(e),t)},qDe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*rx(n,r,e+1)},Ite=wte(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),HDe=function*(t){yield t};var yL=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Cte=(t,e)=>[...e.flatMap(r=>[...Tl(r,t,0)]),...b_(t)],Tl=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=YDe}=e[r];for(let i of n(t))yield*Tl(i,e,r+1)},b_=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*WDe(r,Number(e),t)},WDe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Tl(n,r,e+1)},YDe=function*(t){yield t};var SL=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=Ote(t,o,s),l=bl(e),u=bl(r),d=l?_L.bind(void 0,rx,a):yL.bind(void 0,Tl),f=l||u?_L.bind(void 0,Rte,a):yL.bind(void 0,b_),p=l||u?Ite.bind(void 0,a):void 0;return{stream:new KDe({writableObjectMode:n,writableHighWaterMark:Pte(n),readableObjectMode:i,readableHighWaterMark:Pte(i),transform(m,S,T){d([m,c,0],this,T)},flush(m){f([c],this,m)},destroy:p})}},nx=(t,e,r,n)=>{let i=e.filter(({type:o})=>o==="generator"),s=n?i.reverse():i;for(let{value:o,optionName:a}of s){let c=Ote(o,r,a);t=Cte(c,t)}return t},Ote=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:Tte(n,a)},tx(r,o,n),ex(r,s,n,c),{transform:t,final:e},{transform:Ate(i,a)},bte({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var Nte=(t,e)=>{for(let r of ZDe(t))JDe(t,r,e)},ZDe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),JDe=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Ra[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>XDe(a,n));r.input=f_(o)},XDe=(t,e)=>{let r=nx(t,e,"utf8",!0);return QDe(r),f_(r)},QDe=t=>{let e=t.find(r=>typeof r!="string"&&!jt(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 nLe,appendFileSync as iLe}from"fs";var ix=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Qd(r,n)&&!mn.has(e)&&eLe(n)&&(t.some(({type:i,value:s})=>i==="native"&&tLe.has(s))||t.every(({type:i})=>qn.has(i))),eLe=t=>t===1||t===2,tLe=new Set(["pipe","overlapped"]),kte=async(t,e,r,n)=>{for await(let i of t)rLe(e)||Dte(i,r,n)},Mte=(t,e,r)=>{for(let n of t)Dte(n,e,r)},rLe=t=>t._readableState.pipes.length>0,Dte=(t,e,r)=>{let n=yA(t);os({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Lte=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let s={},o=new Set([]);return{output:e.map((c,l)=>sLe({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},sLe=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=$ee(t,s,d),p=lo(f),{stdioItems:h,objectMode:m}=e[r],S=oLe([p],h,c,n),{serializedResult:T,finalResult:E=T}=aLe({chunks:S,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});cLe({serializedResult:T,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let A=a[r]?E:void 0;try{return n.error===void 0&&lLe(T,h,i),A}catch(v){return n.error=v,A}},oLe=(t,e,r,n)=>{try{return nx(t,e,r,!1)}catch(i){return n.error=i,t}},aLe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:f_(t)};let o=JX(t,r);return n[s]?{serializedResult:o,finalResult:gL(o,!i[s],e)}:{serializedResult:o}},cLe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!ix({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=gL(t,!1,o);try{Mte(a,e,n)}catch(c){r.error??=c}},lLe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>XA.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?iLe(n,t):(r.add(s),nLe(n,t))}};var $te=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,po(e,r,"all")]:Array.isArray(e)?[po(t,r,"all"),...e]:jt(t)&&jt(e)?xD([t,e]):`${t}${e}`};import{once as EL}from"events";var Ute=async(t,e)=>{let[r,n]=await uLe(t);return e.isForcefullyTerminated??=!1,[r,n]},uLe=async t=>{let[e,r]=await Promise.allSettled([EL(t,"spawn"),EL(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Fte(t):r.value},Fte=async t=>{try{return await EL(t,"exit")}catch{return Fte(t)}},Bte=async t=>{let[e,r]=await t;if(!dLe(e,r)&&vL(e,r))throw new Ai;return[e,r]},dLe=(t,e)=>t===void 0&&e===void 0,vL=(t,e)=>t!==0||e!==null;var jte=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=fLe(t,e,r),o=s?.code==="ETIMEDOUT",a=Lee(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},fLe=(t,e,r)=>t!==void 0?t:vL(e,r)?new Ai:void 0;var zte=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=hLe(t,e,r),d=_Le({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return uf(d,c,l)},hLe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=EA(t,e,r),a=mLe(r),{file:c,commandArguments:l,options:u}=BA(t,e,a);gLe(u);let d=yte(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},mLe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,gLe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&sx("ipcInput"),t&&sx("ipc: true"),r&&sx("detached: true"),n&&sx("cancelSignal")},sx=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},_Le=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=yLe({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=jte(c,r),{output:h,error:m=l}=Lte({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),S=h.map((E,A)=>po(E,r,A)),T=po($te(h,r),r,"all");return ELe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:S,all:T,options:r,command:n,escapedCommand:i,startTime:a})},yLe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{Nte(s,r);let a=SLe(r);return pLe(...jA(t,e,a))}catch(a){return lf({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},SLe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:YA(e)}),ELe=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:s,all:o,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?KA({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):v_({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as a1e}from"events";import{spawn as c1e}from"child_process";import Wte from"process";import{once as bL,on as vLe}from"events";var Gte=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(rf({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:MA(t)}),bLe({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),bLe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{PA(e,i);let s=wa(t,e,r),o=new AbortController;try{return await Promise.race([TLe(s,n,o),ALe(s,r,o),xLe(s,r,o)])}catch(a){throw nf(t),a}finally{o.abort(),OA(e,i)}},TLe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await bL(t,"message",{signal:r});return n}for await(let[n]of vLe(t,"message",{signal:r}))if(e(n))return n},ALe=async(t,e,{signal:r})=>{await bL(t,"disconnect",{signal:r}),C7(e)},xLe=async(t,e,{signal:r})=>{let[n]=await bL(t,"strict:error",{signal:r});throw RA(n,e)};import{once as qte,on as wLe}from"events";var Hte=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>TL({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),TL=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{rf({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:MA(t)}),PA(e,s);let o=wa(t,e,r),a=new AbortController,c={};return RLe(t,o,a),ILe({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),CLe({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},RLe=async(t,e,r)=>{try{await qte(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},ILe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await qte(t,"strict:error",{signal:r.signal});n.error=RA(i,e),r.abort()}catch{}},CLe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of wLe(r,"message",{signal:s.signal}))Vte(o),yield c}catch{Vte(o)}finally{s.abort(),OA(e,a),n||nf(t),i&&await t}},Vte=({error:t})=>{if(t)throw t};var Yte=(t,{ipc:e})=>{Object.assign(t,Zte(t,!1,e))},Kte=()=>{let t=Wte,e=!0,r=Wte.channel!==void 0;return{...Zte(t,e,r),getCancelSignal:ree.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Zte=(t,e,r)=>({sendMessage:UA.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Gte.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Hte.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as PLe}from"child_process";import{PassThrough as OLe,Readable as NLe,Writable as kLe,Duplex as MLe}from"stream";var Jte=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{pL(n);let a=new PLe;DLe(a,n),Object.assign(a,{readable:LLe,writable:$Le,duplex:ULe});let c=lf({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=FLe(c,o,i);return{subprocess:a,promise:l}},DLe=(t,e)=>{let r=T_(),n=T_(),i=T_(),s=Array.from({length:e.length-3},T_),o=T_(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},T_=()=>{let t=new OLe;return t.end(),t},LLe=()=>new NLe({read(){}}),$Le=()=>new kLe({write(){}}),ULe=()=>new MLe({read(){},write(){}}),FLe=async(t,e,r)=>uf(t,e,r);import{createReadStream as Xte,createWriteStream as Qte}from"fs";import{Buffer as BLe}from"buffer";import{Readable as A_,Writable as jLe,Duplex as zLe}from"stream";var tre=(t,e)=>QA(GLe,t,e,!1),x_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Ra[t]}.`)},ere={fileNumber:x_,generator:SL,asyncGenerator:SL,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:zLe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},GLe={input:{...ere,fileUrl:({value:t})=>({stream:Xte(t)}),filePath:({value:{file:t}})=>({stream:Xte(t)}),webStream:({value:t})=>({stream:A_.fromWeb(t)}),iterable:({value:t})=>({stream:A_.from(t)}),asyncIterable:({value:t})=>({stream:A_.from(t)}),string:({value:t})=>({stream:A_.from(t)}),uint8Array:({value:t})=>({stream:A_.from(BLe.from(t))})},output:{...ere,fileUrl:({value:t})=>({stream:Qte(t)}),filePath:({value:{file:t,append:e}})=>({stream:Qte(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:jLe.fromWeb(t)}),iterable:x_,asyncIterable:x_,string:x_,uint8Array:x_}};import{on as VLe,once as rre}from"events";import{PassThrough as qLe,getDefaultHighWaterMark as HLe}from"stream";import{finished as sre}from"stream/promises";function Al(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)xL(i);let e=t.some(({readableObjectMode:i})=>i),r=WLe(t,e),n=new AL({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var WLe=(t,e)=>{if(t.length===0)return HLe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},AL=class extends qLe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(xL(e),this.#e.has(e))return;this.#e.add(e),this.#n??=YLe(this,this.#e,this.#s);let r=JLe({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#s});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(xL(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},YLe=async(t,e,r)=>{ox(t,nre);let n=new AbortController;try{await Promise.race([KLe(t,n),ZLe(t,e,r,n)])}finally{n.abort(),ox(t,-nre)}},KLe=async(t,{signal:e})=>{try{await sre(t,{signal:e,cleanup:!0})}catch(r){throw ore(t,r),r}},ZLe=async(t,e,r,{signal:n})=>{for await(let[i]of VLe(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},xL=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},JLe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{ox(t,ire);let a=new AbortController;try{await Promise.race([XLe(s,e,a),QLe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),e$e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),ox(t,-ire)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?wL(t):t$e(t))},XLe=async(t,e,{signal:r})=>{try{await t,r.aborted||wL(e)}catch(n){r.aborted||ore(e,n)}},QLe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await sre(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;are(o)?i.add(e):cre(t,o)}},e$e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await rre(t,i,{signal:s}),!t.readable)return rre(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},t$e=t=>{t.writable&&t.end()},ore=(t,e)=>{are(e)?wL(t):cre(t,e)},are=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",wL=t=>{(t.readable||t.writable)&&t.destroy()},cre=(t,e)=>{t.destroyed||(t.once("error",r$e),t.destroy(e))},r$e=()=>{},ox=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},nre=2,ire=1;import{finished as lre}from"stream/promises";var ff=(t,e)=>{t.pipe(e),n$e(t,e),i$e(t,e)},n$e=async(t,e)=>{if(!(Ti(t)||Ti(e))){try{await lre(t,{cleanup:!0,readable:!0,writable:!1})}catch{}RL(e)}},RL=t=>{t.writable&&t.end()},i$e=async(t,e)=>{if(!(Ti(t)||Ti(e))){try{await lre(e,{cleanup:!0,readable:!1,writable:!0})}catch{}IL(t)}},IL=t=>{t.readable&&t.destroy()};var ure=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:s,direction:o}]of Object.entries(e)){for(let{stream:a}of s.filter(({type:c})=>qn.has(c)))s$e(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!qn.has(c)))a$e({subprocess:t,stream:a,direction:o,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,s]of n.entries()){let o=s.length===1?s[0]:Al(s);ff(o,i)}},s$e=(t,e,r,n)=>{r==="output"?ff(t.stdio[n],e):ff(e,t.stdio[n]);let i=o$e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},o$e=["stdin","stdout","stderr"],a$e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;c$e(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},c$e=(t,{signal:e})=>{Ti(t)&&El(t,l$e,e)},l$e=2;import{addAbortListener as f$e}from"events";var xl=[];xl.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&xl.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&xl.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var ax=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",CL=Symbol.for("signal-exit emitter"),PL=globalThis,u$e=Object.defineProperty.bind(Object),OL=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(PL[CL])return PL[CL];u$e(PL,CL,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let s of this.listeners[e])i=s(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},cx=class{},d$e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),NL=class extends cx{onExit(){return()=>{}}load(){}unload(){}},kL=class extends cx{#e=ML.platform==="win32"?"SIGINT":"SIGHUP";#r=new OL;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of xl)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,s=e;if(typeof s.__signal_exit_emitter__=="object"&&typeof s.__signal_exit_emitter__.count=="number"&&(i+=s.__signal_exit_emitter__.count),n.length===i){this.unload();let o=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;o||e.kill(e.pid,a)}};this.#s=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!ax(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 xl)try{let r=this.#i[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#o&&(this.#o=!1,xl.forEach(e=>{let r=this.#i[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#s,this.#r.count-=1)}#a(e){return ax(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#s.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&ax(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let i=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),i}else return n.call(this.#t,e,...r)}},ML=globalThis.process,{onExit:dre,load:vyt,unload:byt}=d$e(ax(ML)?new kL(ML):new NL);var fre=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=dre(()=>{t.kill()});f$e(n,()=>{i()})};var hre=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=SA(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=p$e(r,n,i),{sourceStream:d,sourceError:f}=m$e(t,l),{options:p,fileDescriptors:h}=cs.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},p$e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=h$e(t,e,...r),a=CA(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},h$e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(pre,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||TD(r)){if(Object.keys(t).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[i,s,o]=lA(r,...n);return{destination:e(pre)(i,s,o),pipeOptions:o}}if(cs.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}`)},pre=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),m$e=(t,e)=>{try{return{sourceStream:sf(t,e)}}catch(r){return{sourceError:r}}};var gre=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=g$e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw DL({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},g$e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return IL(t),n;if(e!==void 0)return RL(r),e},DL=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>lf({error:t,command:mre,escapedCommand:mre,fileDescriptors:e,options:r,startTime:n,isSync:!1}),mre="source.pipe(destination)";var _re=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:s,value:o=s}]=await t;if(o.pipedFrom.includes(n)||o.pipedFrom.push(n),i==="rejected")throw o;if(e==="rejected")throw n;return o};import{finished as _$e}from"stream/promises";var yre=(t,e,r)=>{let n=lx.has(e)?S$e(t,e):y$e(t,e);return El(t,v$e,r.signal),El(e,b$e,r.signal),E$e(e),n},y$e=(t,e)=>{let r=Al([t]);return ff(r,e),lx.set(e,r),r},S$e=(t,e)=>{let r=lx.get(e);return r.add(t),r},E$e=async t=>{try{await _$e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}lx.delete(t)},lx=new WeakMap,v$e=2,b$e=1;import{aborted as T$e}from"util";var Sre=(t,e)=>t===void 0?[]:[A$e(t,e)],A$e=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await T$e(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw DL({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var ux=(t,...e)=>{if(Pt(e[0]))return ux.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=hre(t,...e),i=x$e({...n,destination:r});return i.pipe=ux.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},x$e=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=w$e(t,i);gre({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=yre(e,s,d);return await Promise.race([_re(u),...Sre(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},w$e=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as k$e}from"timers/promises";import{on as R$e}from"events";import{getDefaultHighWaterMark as I$e}from"stream";var dx=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return C$e(e,o),vre({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},C$e=async(t,e)=>{try{await t}catch{}finally{e.abort()}},LL=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;P$e(e,o,t);let a=t.readableObjectMode&&!s;return vre({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},P$e=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},vre=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=R$e(t,"data",{signal:e.signal,highWaterMark:Ere,highWatermark:Ere});return O$e({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},$L=I$e(!0),Ere=$L,O$e=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=N$e({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Tl(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*b_(a)}},N$e=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[tx(t,r,!e),ex(t,i,!n,{})].filter(Boolean);var bre=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=M$e({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([D$e(t),d]);return}let f=hL(c,r),p=LL({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([L$e({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},M$e=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!ix({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=LL({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await kte(a,t,r,s)},D$e=async t=>{await k$e(),t.readableFlowing===null&&t.resume()},L$e=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await qA(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await HA(r,{maxBuffer:s})):await cf(r,{maxBuffer:s})}catch(a){return Tre(kee({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},UL=async t=>{try{return await t}catch(e){return Tre(e)}},Tre=({bufferedData:t})=>KX(t)?new Uint8Array(t):t;import{finished as $$e}from"stream/promises";var w_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=U$e(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],$$e(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||j$e(a,e,r,n)}finally{o.abort()}},U$e=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&F$e(t,r,n),n},F$e=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{B$e(e,r),n.call(t,...i)}},B$e=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},j$e=(t,e,r,n)=>{if(!z$e(t,e,r,n))throw t},z$e=(t,e,r,n=!0)=>r.propagating?Are(t)||fx(t):(r.propagating=!0,FL(r,e)===n?Are(t):fx(t)),FL=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",fx=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Are=t=>t?.code==="EPIPE";var xre=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>BL({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),BL=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=w_(t,e,l);if(FL(l,e)){await u;return}let[d]=await Promise.all([bre({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var wre=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Al([t,e].filter(Boolean)):void 0,Rre=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>BL({...G$e(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:V$e(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),G$e=({stdout:t,stderr:e,all:r},[,n,i])=>{let s=n||i;return s?n?i?{stream:r,buffer:s}:{stream:t,buffer:s}:{stream:e,buffer:s}:{stream:r,buffer:s}},V$e=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as q$e}from"events";var Ire=t=>Qd(t,"ipc"),Cre=(t,e)=>{let r=yA(t);os({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Pre=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=Ire(s),a=uo(e,"ipc"),c=uo(r,"ipc");for await(let l of TL({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Mee(t,i,c),i.push(l)),o&&Cre(l,s);return i},Ore=async(t,e)=>(await Promise.allSettled([t]),e);var Nre=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:S,controller:T})=>{let E=Ute(t,f),A={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:E,propagating:!1},v=xre({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:A}),R=Rre({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:A}),P=[],L=Pre({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:P,verboseInfo:p}),C=H$e(m,t,A),N=W$e(h,A);try{return await Promise.race([Promise.all([{},Bte(E),Promise.all(v),R,L,fee(t,d),...C,...N]),S,Y$e(t,T),...aee(t,s,f,T),...I7({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:T}),...see({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:T})])}catch(B){return f.terminationReason??="other",Promise.all([{error:B},E,Promise.all(v.map(_=>UL(_))),UL(R),Ore(L,P),Promise.allSettled(C),Promise.allSettled(N)])}},H$e=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:w_(n,i,r)),W$e=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>wi(s,{checkOpen:!1})&&!Ti(s)).map(({type:i,value:s,stream:o=s})=>w_(o,n,e,{isSameDirection:qn.has(i),stopOnExit:i==="native"}))),Y$e=async(t,{signal:e})=>{let[r]=await q$e(t,"error",{signal:e});throw r};var kre=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),R_=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=as();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},pf=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 K$e}from"stream";import{callbackify as Z$e}from"util";import{finished as Mre}from"stream/promises";var jL=async t=>{if(t!==void 0)try{await zL(t)}catch{}},Dre=async t=>{if(t!==void 0)try{await GL(t)}catch{}},zL=async t=>{await Mre(t,{cleanup:!0,readable:!1,writable:!0})},GL=async t=>{await Mre(t,{cleanup:!0,readable:!0,writable:!1})},px=async(t,e)=>{if(await t,e)throw e},hx=(t,e,r)=>{r&&!fx(r)?t.destroy(r):e&&t.destroy()};var Lre=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||mn.has(r),{subprocessStdout:a,waitReadableDestroy:c}=VL(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=qL(a,o),{read:f,onStdoutDataDone:p}=HL({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new K$e({read:f,destroy:Z$e(YL.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return WL({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},VL=(t,e,r)=>{let n=sf(t,e),i=R_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},qL=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:$L},HL=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=as(),o=dx({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){J$e(this,o,s)},onStdoutDataDone:s}},J$e=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},WL=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await GL(t),await n,await jL(i),await e,r.readable&&r.push(null)}catch(s){await jL(i),$re(r,s)}},YL=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await pf(r,e)&&($re(t,n),await px(e,n))},$re=(t,e)=>{hx(t,t.readable,e)};import{Writable as X$e}from"stream";import{callbackify as Ure}from"util";var Fre=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=KL(t,r,e),o=new X$e({...ZL(n,t,i),destroy:Ure(XL.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return JL(n,o),o},KL=(t,e,r)=>{let n=CA(t,e),i=R_(r,n,"writableFinal"),s=R_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},ZL=(t,e,r)=>({write:Q$e.bind(void 0,t),final:Ure(e1e.bind(void 0,t,e,r))}),Q$e=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},e1e=async(t,e,r)=>{await pf(r,e)&&(t.writable&&t.end(),await e)},JL=async(t,e,r)=>{try{await zL(t),e.writable&&e.end()}catch(n){await Dre(r),Bre(e,n)}},XL=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await pf(r,e),await pf(n,e)&&(Bre(t,i),await px(e,i))},Bre=(t,e)=>{hx(t,t.writable,e)};import{Duplex as t1e}from"stream";import{callbackify as r1e}from"util";var jre=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||mn.has(r),{subprocessStdout:c,waitReadableDestroy:l}=VL(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=KL(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=qL(c,a),{read:S,onStdoutDataDone:T}=HL({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),E=new t1e({read:S,...ZL(u,t,d),destroy:r1e(n1e.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return WL({subprocessStdout:c,onStdoutDataDone:T,readable:E,subprocess:t,subprocessStdin:u}),JL(u,E,c),E},n1e=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([YL({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),XL({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var QL=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||mn.has(e),o=sf(t,r),a=dx({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return i1e(a,o,t)},i1e=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var zre=(t,{encoding:e})=>{let r=kre();t.readable=Lre.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Fre.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=jre.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=QL.bind(void 0,t,e),t[Symbol.asyncIterator]=QL.bind(void 0,t,e,{})};var Gre=(t,e)=>{for(let[r,n]of o1e){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},s1e=(async()=>{})().constructor.prototype,o1e=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(s1e,t)]);var Vre=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=l1e(t,e,r),{subprocess:f,promise:p}=d1e({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=ux.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),Gre(f,p),cs.set(f,{options:u,fileDescriptors:d}),f},l1e=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=EA(t,e,r),{file:a,commandArguments:c,options:l}=BA(t,e,r),u=u1e(l),d=tre(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},u1e=({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}},d1e=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=c1e(...jA(t,e,r))}catch(h){return Jte({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;a1e(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];ure(c,a,l),fre(c,r,l);let d={},f=as();c.kill=w7.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=wre(c,r),zre(c,r),Yte(c,r);let p=f1e({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:s,escapedCommand:o,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},f1e=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:s,command:o,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,S]=await Nre({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:l,controller:u});u.abort(),l.resolve();let T=h.map((v,R)=>po(v,e,R)),E=po(m,e,"all"),A=p1e({errorInfo:d,exitCode:f,signal:p,stdio:T,all:E,ipcOutput:S,context:c,options:e,command:o,escapedCommand:a,startTime:r});return uf(A,n,e)},p1e=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,context:o,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?v_({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 ls,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):KA({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var mx=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,h1e(n,t[n],i)]));return{...t,...r}},h1e=(t,e,r)=>m1e.has(t)&&Pt(e)&&Pt(r)?{...e,...r}:r,m1e=new Set(["env",...CD]);var Ia=(t,e,r,n)=>{let i=(o,a,c)=>Ia(o,a,r,c),s=(...o)=>g1e({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},g1e=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Pt(s))return i(t,mx(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=_1e({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?zte(a,c,l):Vre(a,c,l,i)},_1e=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=tQ(e)?rQ(e,r):[e,...r],[o,a,c]=lA(...s),l=mx(mx(n,i),c),{file:u=o,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:o,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var qre=({file:t,commandArguments:e})=>Wre(t,e),Hre=({file:t,commandArguments:e})=>({...Wre(t,e),isSync:!0}),Wre=(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]=y1e(t);return{file:r,commandArguments:n}},y1e=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(S1e)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},S1e=/ +/g;var Yre=(t,e,r)=>{t.sync=e(E1e,r),t.s=t.sync},Kre=({options:t})=>Zre(t),E1e=({options:t})=>({...Zre(t),isSync:!0}),Zre=t=>({options:{...v1e(t),...t}}),v1e=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Jre={preferLocal:!0};var Xre=Ia(()=>({})),dvt=Ia(()=>({isSync:!0})),Qre=Ia(qre),fvt=Ia(Hre),pvt=Ia(lee),hvt=Ia(Kre,{},Jre,Yre),{sendMessage:mvt,getOneMessage:gvt,getEachMessage:_vt,getCancelSignal:yvt}=Kte();var ene=!1,tne=()=>{ene=!0},ds=()=>ene;var I_=null,rne=t=>(I_&&I_.destroy(),I_=new ho({totalAllowedTime:t}),I_),nne=()=>I_;var ho=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&ds())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let s=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),o=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await rA({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{fe.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),s(),o&&clearTimeout(o)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var ine={name:"@netlify/agent-runner-cli",type:"module",version:"1.150.0-ex-2643.2",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.2","@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.219","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.1.5","@netlify/otel":"^6.0.4","@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",zod:"^4.4.3"}};var x1e=T1e(import.meta.url),w1e=mo.dirname(x1e),R1e=A1e(import.meta.url),hf=me("shell"),e$=new Set,sne={preferLocal:!0},kr=(t,e,r)=>{let[n,i]=I1e(e,r),s={...sne,...i},o=Xre(t,n,s);ane(o,s),une(o);let a=r?.idleTimeout;return a&&a>0&&lne(o,a),o},one=(t,e)=>{let r={...sne,...e},n=Qre(t,r);return ane(n,r),une(n),e?.idleTimeout&&e.idleTimeout>0&&lne(n,e.idleTimeout),n},I1e=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},ane=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(go.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new r_).pipe(go.stdout),t.stderr?.pipe(new r_).pipe(go.stderr);return}t.stdout?.pipe(go.stdout),t.stderr?.pipe(go.stderr)},t$=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(go.kill(-t.pid,e),hf.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return hf.error("Error killing process:",r),!1}},cne=t=>t$(t,"SIGKILL"),lne=(t,e)=>{let r=null,n=()=>{hf.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),t$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(hf.log(`Force killing idle process ${t.pid}`),cne(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let s=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",s),t.on("error",s)},une=t=>{e$.add(t);let e=nne();if(e){let r=e.onTimesUp(()=>{hf.log(`Global timer expired, killing process ${t.pid}`),t$(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(hf.log(`Force killing process ${t.pid} after timeout`),cne(t))},5e3)});t.on("exit",()=>{e$.delete(t),r()}),t.on("error",()=>{e$.delete(t),r()})}};function fs(t,e){if(!go.env.NETLIFY_LOCAL_MODE)try{let i=R1e.resolve(ine.name),s=mo.dirname(i);for(;s!==mo.dirname(s);){let o=mo.dirname(s);if(mo.basename(o)==="node_modules"){let a=mo.join(o,".bin",e);if(gx.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(go.env.NODE_PATH){let i=mo.join(go.env.NODE_PATH,".bin",e);if(gx.existsSync(i))return i}let r=mo.join(t,"node_modules",".bin",e);if(gx.existsSync(r))return r;let n=mo.join(w1e,"..","node_modules",".bin",e);if(gx.existsSync(n))return n}var C1e=me("utils"),P1e=t=>new Promise(e=>{setTimeout(e,t)});var r$=t=>{try{return new URL(t).hostname||null}catch{return null}},_x=(t,e=3e3)=>{let r=!1,n=null,i=[],s=null,o=(...a)=>{if(r)return n=a,new Promise(u=>{i.push(u)});r=!0;let c,l=new Promise(u=>{c=u});return s=(async()=>{await Promise.resolve();let u=await t(...a);for(c(u);;){if(await P1e(e),!n)return r=!1,s=null,u;let d=n,f=i;n=null,i=[],u=await t(...d),f.forEach(p=>{p(u)})}})(),l};return o.flush=async()=>{if((r||n)&&s)return await s,o.flush()},o.cancel=()=>{n=null,i.forEach(a=>a(void 0)),i=[]},o},Ca=(t,e,r=!1)=>{let n=null,i=null,s=null,o=function(...a){i=a,s=this;let c=r&&!n;clearTimeout(n),n=setTimeout(()=>{n=null,r||(t.apply(s,i),i=null,s=null)},e),c&&(t.apply(s,i),i=null,s=null)};return o.cancel=()=>{clearTimeout(n),n=null,i=null,s=null},o.flush=()=>{if(n){clearTimeout(n);let a=i,c=s;n=null,i=null,s=null,t.apply(c,a)}},o},dne=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):C1e.error("Could not parse JSON",n))}},O1e=t=>t.charAt(0).toUpperCase()+t.slice(1),ps=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():O1e(e)).join(" ");function _o(t,e){e&&t.log(`Skill invoked: ${e}`)}var yx=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),fne=(t,e,r=!1)=>{if(r)return;let n=60,i=55,s=".netlify.app",o="agent-",a=6;if(!e)return`${o}${t.slice(0,a)}`;let c=`--${e}${s}`;if(c.length>i)return"";let l=n-c.length;if(l<=0)return"";if(l>=o.length+a){let u=Math.min(l-o.length,t.length);return`${o}${t.slice(0,u)}`}return t.slice(0,l)};var n$=t=>{let e=t.match(/<<-?\s*['"]?(\w+)['"]?/);if(!e)return{command:t};let r=t.indexOf(e[0]),n=t.slice(r+e[0].length).trim();return{command:t.slice(0,r).trim(),heredocContent:n||void 0}},N1e=1e4,i$=(t,e=N1e)=>{if(!t||typeof t!="string"||t.length<=e)return t;let n=t.startsWith("```")?"\n... [truncated]\n```":"... [truncated]";return t.slice(0,e)+n};import{Buffer as pne}from"buffer";import k1e from"path";var hne=me("repo"),Zr=(t,e={})=>kr("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),Sx=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{hne.info("Getting runner diffs");let n=await D1e(r),{hasChanges:i}=n,{status:s}=n;if(!i)return{hasChanges:!1};if(!e){let m=$1e(s);await U1e(m,r)}hne.info("Changes after processing"),await o$(r);let o=await c$(s,r);if(await s$(o,r),i=await L1e(r),!i)return{hasChanges:!1,ignored:o};await Zr(["commit","-m","Agent runner"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await Zr(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(i=!!l,!i)return await mne(r),{hasChanges:!1,ignored:o};let u=await Zr(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,p;if(t.sha){let m=await Zr(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let S=await Zr(["diff",t.sha,"HEAD","--binary"],a),T=String(S.stdout??"");f!==T&&(p=pne.from(T).toString("base64"))}await mne(r);let h={hasChanges:!0,diff:l,resultDiff:f,ignored:o};return l!==d&&(h.diffBinary=pne.from(d).toString("base64")),p&&(h.resultDiffBinary=p),h},mne=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Zr(["reset","--soft","HEAD~1"],{cwd:t})},s$=async(t=[],e=process.cwd())=>{await Zr(["add",".",...t],{cwd:e})},o$=async(t=process.cwd())=>{let e=await Zr(["status","-s"],{cwd:t});return String(e.stdout??"")},gne=/.. (.+)?\.log$/,M1e=[gne],D1e=async(t=process.cwd())=>{let e=await o$(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
102
102
|
`).filter(i=>M1e.some(o=>o instanceof RegExp?o.test(i):i===o)?!1:i[1]?.trim()!=="")).length!==0,status:e}},L1e=async(t=process.cwd())=>{try{return await Zr(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},a$=async(t=process.cwd())=>{let{stdout:e}=await Zr(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},_ne=async(t=process.cwd())=>{let{stdout:e}=await Zr(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},c$=async(t,e=process.cwd())=>{t||=await o$(e);let r=[".netlify","node_modules","dist",".next","out",".nuxt",".output",".cache",".turbo",".parcel-cache","coverage",".nyc_output","storybook-static","public/build","CLAUDE.local.md"],n=[];return t.split(`
|
|
103
103
|
`).forEach(i=>{r.forEach(o=>{let a=i===`?? ${o}`,c=i.startsWith(`?? ${o}/`)||i.startsWith(`?? ${o}${k1e.sep}`);(a||c)&&n.push(`:!${o}`)});let s=i.match(gne)?.[1];s&&n.push(`:!${s}.log`)}),n},yne=async(t=process.cwd())=>{await Zr(["reset","--hard","HEAD"],{cwd:t})},Sne=async(t=process.cwd())=>{let e=await Zr(["clean","-fd","-e",".netlify"],{stdio:["ignore","pipe","pipe"],cwd:t});return String(e.stdout??"").split(`
|
|
104
104
|
`).filter(r=>r.startsWith("Removing ")).map(r=>r.slice(9))},$1e=t=>{let e=t.split(`
|
|
@@ -294,7 +294,7 @@ you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
|
|
|
294
294
|
new OpenAI({ apiKey, dangerouslyAllowBrowser: true });
|
|
295
295
|
|
|
296
296
|
https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
|
|
297
|
-
`);this.baseURL=c.baseURL,this.timeout=c.timeout??L2.DEFAULT_TIMEOUT,this.logger=c.logger??console;let l="warn";this.logLevel=l,this.logLevel=u2(c.logLevel,"ClientOptions.logLevel",this)??u2(ac("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??l,this.fetchOptions=c.fetchOptions,this.maxRetries=c.maxRetries??2,this.fetch=c.fetch??FR(),we(this,pI,Mae,"f"),this._options=c,o&&(this._workloadIdentityAuth=new HR(o,this.fetch)),this.apiKey=typeof r=="string"?r:"Missing Key",this.organization=n,this.project=i,this.webhookSecret=s}withOptions(e){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,workloadIdentity:this._options.workloadIdentity,organization:this.organization,project:this.project,webhookSecret:this.webhookSecret,...e})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:r}){}async authHeaders(e){return ne([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(e){return Gae(e)}getUserAgent(){return`${this.constructor.name}/JS ${ec}`}defaultIdempotencyKey(){return`stainless-node-retry-${Zj()}`}makeStatusError(e,r,n,i){return wt.generate(e,r,n,i)}async _callApiKey(){let e=this._options.apiKey;if(typeof e!="function")return!1;let r;try{r=await e()}catch(n){throw n instanceof ge?n:new ge(`Failed to get token from 'apiKey' function: ${n.message}`,{cause:n})}if(typeof r!="string"||!r)throw new ge(`Expected 'apiKey' function argument to return a string but it returned ${r}`);return this.apiKey=r,!0}buildURL(e,r,n){let i=!D(this,D2,"m",wce).call(this)&&n||this.baseURL,s=Aae(e)?new URL(e):new URL(i+(i.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),o=this.defaultQuery(),a=Object.fromEntries(s.searchParams);return(!Qj(o)||!Qj(a))&&(r={...a,...o,...r}),typeof r=="object"&&r&&!Array.isArray(r)&&(s.search=this.stringifyQuery(r)),s.toString()}async prepareOptions(e){await this._callApiKey()}async prepareRequest(e,{url:r,options:n}){}get(e,r){return this.methodRequest("get",e,r)}post(e,r){return this.methodRequest("post",e,r)}patch(e,r){return this.methodRequest("patch",e,r)}put(e,r){return this.methodRequest("put",e,r)}delete(e,r){return this.methodRequest("delete",e,r)}methodRequest(e,r,n){return this.request(Promise.resolve(n).then(i=>({method:e,path:r,...i})))}request(e,r=null){return new Kl(this,this.makeRequest(e,r,void 0))}async makeRequest(e,r,n){let i=await e,s=i.maxRetries??this.maxRetries;r==null&&(r=s),await this.prepareOptions(i);let{req:o,url:a,timeout:c}=await this.buildRequest(i,{retryCount:s-r});await this.prepareRequest(o,{url:a,options:i});let l="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),u=n===void 0?"":`, retryOf: ${n}`,d=Date.now();if(Ot(this).debug(`[${l}] sending request`,Oo({retryOfRequestLogID:n,method:i.method,url:a,options:i,headers:o.headers})),i.signal?.aborted)throw new Dt;let f=new AbortController,p=await this.fetchWithAuth(a,o,c,f).catch(Ly),h=Date.now();if(p instanceof globalThis.Error){let T=`retrying, ${r} attempts remaining`;if(i.signal?.aborted)throw new Dt;let E=Dy(p)||/timed? ?out/i.test(String(p)+("cause"in p?String(p.cause):""));if(r)return Ot(this).info(`[${l}] connection ${E?"timed out":"failed"} - ${T}`),Ot(this).debug(`[${l}] connection ${E?"timed out":"failed"} (${T})`,Oo({retryOfRequestLogID:n,url:a,durationMs:h-d,message:p.message})),this.retryRequest(i,r,n??l);throw Ot(this).info(`[${l}] connection ${E?"timed out":"failed"} - error; no more retries left`),Ot(this).debug(`[${l}] connection ${E?"timed out":"failed"} (error; no more retries left)`,Oo({retryOfRequestLogID:n,url:a,durationMs:h-d,message:p.message})),p instanceof Wl||p instanceof $y?p:E?new Qa:new Xa({cause:p})}let m=[...p.headers.entries()].filter(([T])=>T==="x-request-id").map(([T,E])=>", "+T+": "+JSON.stringify(E)).join(""),S=`[${l}${u}${m}] ${o.method} ${a} ${p.ok?"succeeded":"failed"} with status ${p.status} in ${h-d}ms`;if(!p.ok){if(p.status===401&&this._workloadIdentityAuth&&!i.__metadata?.hasStreamingBody&&!i.__metadata?.workloadIdentityTokenRefreshed)return await r2(p.body),this._workloadIdentityAuth.invalidateToken(),this.makeRequest({...i,__metadata:{...i.__metadata,workloadIdentityTokenRefreshed:!0}},r,n??l);let T=await this.shouldRetry(p);if(r&&T){let L=`retrying, ${r} attempts remaining`;return await r2(p.body),Ot(this).info(`${S} - ${L}`),Ot(this).debug(`[${l}] response error (${L})`,Oo({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:h-d})),this.retryRequest(i,r,n??l,p.headers)}let E=T?"error; no more retries left":"error; not retryable";Ot(this).info(`${S} - ${E}`);let A=await p.text().catch(L=>Ly(L).message),v=Rae(A),R=v?void 0:A;throw Ot(this).debug(`[${l}] response error (${E})`,Oo({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,message:R,durationMs:Date.now()-d})),this.makeStatusError(p.status,v,R,p.headers)}return Ot(this).info(S),Ot(this).debug(`[${l}] response start`,Oo({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:h-d})),{response:p,options:i,controller:f,requestLogID:l,retryOfRequestLogID:n,startTime:d}}getAPIList(e,r,n){return this.requestAPIList(r,n&&"then"in n?n.then(i=>({method:"get",path:e,...i})):{method:"get",path:e,...n})}requestAPIList(e,r){let n=this.makeRequest(r,null,void 0);return new Gy(this,n,e)}async fetchWithAuth(e,r,n,i){if(this._workloadIdentityAuth){let o=r.headers,a=o.get("Authorization");if(!a||a===`Bearer ${M2}`){let c=await this._workloadIdentityAuth.getToken();o.set("Authorization",`Bearer ${c}`)}}return await this.fetchWithTimeout(e,r,n,i)}async fetchWithTimeout(e,r,n,i){let{signal:s,method:o,...a}=r||{},c=this._makeAbort(i);s&&s.addEventListener("abort",c,{once:!0});let l=setTimeout(c,n),u=globalThis.ReadableStream&&a.body instanceof globalThis.ReadableStream||typeof a.body=="object"&&a.body!==null&&Symbol.asyncIterator in a.body,d={signal:i.signal,...u?{duplex:"half"}:{},method:"GET",...a};o&&(d.method=o.toUpperCase());try{return await this.fetch.call(void 0,e,d)}finally{clearTimeout(l)}}async shouldRetry(e){let r=e.headers.get("x-should-retry");return r==="true"?!0:r==="false"?!1:e.status===408||e.status===409||e.status===429||e.status>=500}async retryRequest(e,r,n,i){let s,o=i?.get("retry-after-ms");if(o){let c=parseFloat(o);Number.isNaN(c)||(s=c)}let a=i?.get("retry-after");if(a&&!s){let c=parseFloat(a);Number.isNaN(c)?s=Date.parse(a)-Date.now():s=c*1e3}if(s===void 0){let c=e.maxRetries??this.maxRetries;s=this.calculateDefaultRetryTimeoutMillis(r,c)}return await Es(s),this.makeRequest(e,r-1,n)}calculateDefaultRetryTimeoutMillis(e,r){let s=r-e,o=Math.min(.5*Math.pow(2,s),8),a=1-Math.random()*.25;return o*a*1e3}async buildRequest(e,{retryCount:r=0}={}){let n={...e},{method:i,path:s,query:o,defaultBaseURL:a}=n,c=this.buildURL(s,o,a);"timeout"in n&&wae("timeout",n.timeout),n.timeout=n.timeout??this.timeout;let{bodyHeaders:l,body:u,isStreamingBody:d}=this.buildBody({options:n});d&&(e.__metadata={...e.__metadata,hasStreamingBody:!0});let f=await this.buildHeaders({options:e,method:i,bodyHeaders:l,retryCount:r});return{req:{method:i,headers:f,...n.signal&&{signal:n.signal},...globalThis.ReadableStream&&u instanceof globalThis.ReadableStream&&{duplex:"half"},...u&&{body:u},...this.fetchOptions??{},...n.fetchOptions??{}},url:c,timeout:n.timeout}}async buildHeaders({options:e,method:r,bodyHeaders:n,retryCount:i}){let s={};this.idempotencyHeader&&r!=="get"&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),s[this.idempotencyHeader]=e.idempotencyKey);let o=ne([s,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(i),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...Nae(),"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]),i=typeof globalThis.ReadableStream<"u"&&e instanceof globalThis.ReadableStream,s=!i&&(typeof e=="string"||e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof globalThis.Blob<"u"&&e instanceof globalThis.Blob||e instanceof URLSearchParams||e instanceof FormData);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e=="string"&&n.values.has("content-type")||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||i?{bodyHeaders:void 0,body:e,isStreamingBody:!s}:typeof e=="object"&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&typeof e.next=="function")?{bodyHeaders:void 0,body:BR(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}:{...D(this,pI,"f").call(this,{body:e,headers:n}),isStreamingBody:!1}}};L2=Ne,pI=new WeakMap,D2=new WeakSet,wce=function(){return this.baseURL!=="https://api.openai.com/v1"};Ne.OpenAI=L2;Ne.DEFAULT_TIMEOUT=6e5;Ne.OpenAIError=ge;Ne.APIError=wt;Ne.APIConnectionError=Xa;Ne.APIConnectionTimeoutError=Qa;Ne.APIUserAbortError=Dt;Ne.NotFoundError=Np;Ne.ConflictError=kp;Ne.RateLimitError=Dp;Ne.BadRequestError=Cp;Ne.AuthenticationError=Pp;Ne.InternalServerError=Lp;Ne.PermissionDeniedError=Op;Ne.UnprocessableEntityError=Mp;Ne.InvalidWebhookSignatureError=Ss;Ne.toFile=YR;Ne.Completions=iu;Ne.Chat=ic;Ne.Embeddings=ou;Ne.Files=cu;Ne.Images=fu;Ne.Audio=As;Ne.Moderations=hu;Ne.Models=pu;Ne.FineTuning=Ni;Ne.Graders=fc;Ne.VectorStores=Fo;Ne.Webhooks=_u;Ne.Beta=Oi;Ne.Batches=Ql;Ne.Uploads=hc;Ne.Responses=$o;Ne.Realtime=Lo;Ne.Conversations=uc;Ne.Evals=dc;Ne.Containers=lc;Ne.Skills=Uo;Ne.Videos=gu;var Zn=me("runner_codex"),$2="Codex CLI",vh="gpt-5.6-sol";async function Cze({aiGateway:t,config:e,model:r}){let n=r;if(t)if(e.modelVersionOverrides?.codex){let i=e.modelVersionOverrides?.codex?.[e.accountType];if(i){if(!await t.isModelAvailableForProvider("openai",i))throw new Error(`Model override '${i}' is not available for openai provider`);n=i}}else if(r){if(!await t.isModelAvailableForProvider("openai",r))throw new Error(`Model '${r}' is not available for openai provider`)}else!!vh&&await t.isModelAvailableForProvider("openai",vh)?(n=vh,Zn.log(`Using default model: ${vh}`)):vh&&Zn.log(`Default model ${vh} is not available, proceeding without model specification`);return n}var hI="netlify-ask-db",Pze=`default_permissions = "${hI}"`,Oze=t=>["",`[permissions.${hI}]`,'description = "Ask mode: read-only filesystem, network limited to the project database"','extends = ":read-only"',"",`[permissions.${hI}.network]`,"enabled = true","",`[permissions.${hI}.network.domains]`,`"${t}" = "allow"`,'"*" = "deny"'];function Nze({aiGateway:t}){if(t){let{token:e,url:r}=t;if(!e||!r)throw new Error("No token or url provided from AI Gateway");mc.env.OPENAI_API_KEY=e,mc.env.OPENAI_BASE_URL=r}else if(!mc.env.OPENAI_API_KEY)throw new Error("OPENAI_API_KEY is not provided")}async function U2({config:t,netlify:e,persistSteps:r,sendSteps:n,aiGateway:i,continueSession:s,priorAgentSessionId:o,cwd:a=mc.cwd(),abortSignal:c,onSessionId:l,effortOverride:u}){let{prompt:d}=t,{model:f}=t;Nze({aiGateway:i});let p=await Cze({config:t,aiGateway:i,model:f}),h=[],m=[],S=[],T={},E=new Set,A=0,v=0,R,P,L,C,N,B=Hf(t),_=`${mc.env.NVM_BIN}/node`,se=bh.join(mI.homedir(),".codex"),I=bh.join(se,"config.toml"),g=bh.join(se,"auth.json");try{await nS.mkdir(se,{recursive:!0});let De={OPENAI_API_KEY:mc.env.OPENAI_API_KEY};await nS.writeFile(g,JSON.stringify(De,null,2),"utf-8"),Zn.log("Created Codex auth.json file");let z=mc.env.OPENAI_BASE_URL,Ee=['forced_login_method = "api"'],W=We().questionsEnabled;B&&Ee.push(Pze),z&&Ee.push('model_provider = "openai_proxy"',"","[model_providers.openai_proxy]",'name = "OpenAI Proxy"',`base_url = "${z}"`,'env_key = "OPENAI_API_KEY"','wire_api = "responses"',"supports_websockets = false","requires_openai_auth = true"),W&&Ee.push(...pie()),B&&Ee.push(...Oze(B.host)),await nS.writeFile(I,`${Ee.join(`
|
|
297
|
+
`);this.baseURL=c.baseURL,this.timeout=c.timeout??L2.DEFAULT_TIMEOUT,this.logger=c.logger??console;let l="warn";this.logLevel=l,this.logLevel=u2(c.logLevel,"ClientOptions.logLevel",this)??u2(ac("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??l,this.fetchOptions=c.fetchOptions,this.maxRetries=c.maxRetries??2,this.fetch=c.fetch??FR(),we(this,pI,Mae,"f"),this._options=c,o&&(this._workloadIdentityAuth=new HR(o,this.fetch)),this.apiKey=typeof r=="string"?r:"Missing Key",this.organization=n,this.project=i,this.webhookSecret=s}withOptions(e){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,workloadIdentity:this._options.workloadIdentity,organization:this.organization,project:this.project,webhookSecret:this.webhookSecret,...e})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:r}){}async authHeaders(e){return ne([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(e){return Gae(e)}getUserAgent(){return`${this.constructor.name}/JS ${ec}`}defaultIdempotencyKey(){return`stainless-node-retry-${Zj()}`}makeStatusError(e,r,n,i){return wt.generate(e,r,n,i)}async _callApiKey(){let e=this._options.apiKey;if(typeof e!="function")return!1;let r;try{r=await e()}catch(n){throw n instanceof ge?n:new ge(`Failed to get token from 'apiKey' function: ${n.message}`,{cause:n})}if(typeof r!="string"||!r)throw new ge(`Expected 'apiKey' function argument to return a string but it returned ${r}`);return this.apiKey=r,!0}buildURL(e,r,n){let i=!D(this,D2,"m",wce).call(this)&&n||this.baseURL,s=Aae(e)?new URL(e):new URL(i+(i.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),o=this.defaultQuery(),a=Object.fromEntries(s.searchParams);return(!Qj(o)||!Qj(a))&&(r={...a,...o,...r}),typeof r=="object"&&r&&!Array.isArray(r)&&(s.search=this.stringifyQuery(r)),s.toString()}async prepareOptions(e){await this._callApiKey()}async prepareRequest(e,{url:r,options:n}){}get(e,r){return this.methodRequest("get",e,r)}post(e,r){return this.methodRequest("post",e,r)}patch(e,r){return this.methodRequest("patch",e,r)}put(e,r){return this.methodRequest("put",e,r)}delete(e,r){return this.methodRequest("delete",e,r)}methodRequest(e,r,n){return this.request(Promise.resolve(n).then(i=>({method:e,path:r,...i})))}request(e,r=null){return new Kl(this,this.makeRequest(e,r,void 0))}async makeRequest(e,r,n){let i=await e,s=i.maxRetries??this.maxRetries;r==null&&(r=s),await this.prepareOptions(i);let{req:o,url:a,timeout:c}=await this.buildRequest(i,{retryCount:s-r});await this.prepareRequest(o,{url:a,options:i});let l="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),u=n===void 0?"":`, retryOf: ${n}`,d=Date.now();if(Ot(this).debug(`[${l}] sending request`,Oo({retryOfRequestLogID:n,method:i.method,url:a,options:i,headers:o.headers})),i.signal?.aborted)throw new Dt;let f=new AbortController,p=await this.fetchWithAuth(a,o,c,f).catch(Ly),h=Date.now();if(p instanceof globalThis.Error){let T=`retrying, ${r} attempts remaining`;if(i.signal?.aborted)throw new Dt;let E=Dy(p)||/timed? ?out/i.test(String(p)+("cause"in p?String(p.cause):""));if(r)return Ot(this).info(`[${l}] connection ${E?"timed out":"failed"} - ${T}`),Ot(this).debug(`[${l}] connection ${E?"timed out":"failed"} (${T})`,Oo({retryOfRequestLogID:n,url:a,durationMs:h-d,message:p.message})),this.retryRequest(i,r,n??l);throw Ot(this).info(`[${l}] connection ${E?"timed out":"failed"} - error; no more retries left`),Ot(this).debug(`[${l}] connection ${E?"timed out":"failed"} (error; no more retries left)`,Oo({retryOfRequestLogID:n,url:a,durationMs:h-d,message:p.message})),p instanceof Wl||p instanceof $y?p:E?new Qa:new Xa({cause:p})}let m=[...p.headers.entries()].filter(([T])=>T==="x-request-id").map(([T,E])=>", "+T+": "+JSON.stringify(E)).join(""),S=`[${l}${u}${m}] ${o.method} ${a} ${p.ok?"succeeded":"failed"} with status ${p.status} in ${h-d}ms`;if(!p.ok){if(p.status===401&&this._workloadIdentityAuth&&!i.__metadata?.hasStreamingBody&&!i.__metadata?.workloadIdentityTokenRefreshed)return await r2(p.body),this._workloadIdentityAuth.invalidateToken(),this.makeRequest({...i,__metadata:{...i.__metadata,workloadIdentityTokenRefreshed:!0}},r,n??l);let T=await this.shouldRetry(p);if(r&&T){let L=`retrying, ${r} attempts remaining`;return await r2(p.body),Ot(this).info(`${S} - ${L}`),Ot(this).debug(`[${l}] response error (${L})`,Oo({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:h-d})),this.retryRequest(i,r,n??l,p.headers)}let E=T?"error; no more retries left":"error; not retryable";Ot(this).info(`${S} - ${E}`);let A=await p.text().catch(L=>Ly(L).message),v=Rae(A),R=v?void 0:A;throw Ot(this).debug(`[${l}] response error (${E})`,Oo({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,message:R,durationMs:Date.now()-d})),this.makeStatusError(p.status,v,R,p.headers)}return Ot(this).info(S),Ot(this).debug(`[${l}] response start`,Oo({retryOfRequestLogID:n,url:p.url,status:p.status,headers:p.headers,durationMs:h-d})),{response:p,options:i,controller:f,requestLogID:l,retryOfRequestLogID:n,startTime:d}}getAPIList(e,r,n){return this.requestAPIList(r,n&&"then"in n?n.then(i=>({method:"get",path:e,...i})):{method:"get",path:e,...n})}requestAPIList(e,r){let n=this.makeRequest(r,null,void 0);return new Gy(this,n,e)}async fetchWithAuth(e,r,n,i){if(this._workloadIdentityAuth){let o=r.headers,a=o.get("Authorization");if(!a||a===`Bearer ${M2}`){let c=await this._workloadIdentityAuth.getToken();o.set("Authorization",`Bearer ${c}`)}}return await this.fetchWithTimeout(e,r,n,i)}async fetchWithTimeout(e,r,n,i){let{signal:s,method:o,...a}=r||{},c=this._makeAbort(i);s&&s.addEventListener("abort",c,{once:!0});let l=setTimeout(c,n),u=globalThis.ReadableStream&&a.body instanceof globalThis.ReadableStream||typeof a.body=="object"&&a.body!==null&&Symbol.asyncIterator in a.body,d={signal:i.signal,...u?{duplex:"half"}:{},method:"GET",...a};o&&(d.method=o.toUpperCase());try{return await this.fetch.call(void 0,e,d)}finally{clearTimeout(l)}}async shouldRetry(e){let r=e.headers.get("x-should-retry");return r==="true"?!0:r==="false"?!1:e.status===408||e.status===409||e.status===429||e.status>=500}async retryRequest(e,r,n,i){let s,o=i?.get("retry-after-ms");if(o){let c=parseFloat(o);Number.isNaN(c)||(s=c)}let a=i?.get("retry-after");if(a&&!s){let c=parseFloat(a);Number.isNaN(c)?s=Date.parse(a)-Date.now():s=c*1e3}if(s===void 0){let c=e.maxRetries??this.maxRetries;s=this.calculateDefaultRetryTimeoutMillis(r,c)}return await Es(s),this.makeRequest(e,r-1,n)}calculateDefaultRetryTimeoutMillis(e,r){let s=r-e,o=Math.min(.5*Math.pow(2,s),8),a=1-Math.random()*.25;return o*a*1e3}async buildRequest(e,{retryCount:r=0}={}){let n={...e},{method:i,path:s,query:o,defaultBaseURL:a}=n,c=this.buildURL(s,o,a);"timeout"in n&&wae("timeout",n.timeout),n.timeout=n.timeout??this.timeout;let{bodyHeaders:l,body:u,isStreamingBody:d}=this.buildBody({options:n});d&&(e.__metadata={...e.__metadata,hasStreamingBody:!0});let f=await this.buildHeaders({options:e,method:i,bodyHeaders:l,retryCount:r});return{req:{method:i,headers:f,...n.signal&&{signal:n.signal},...globalThis.ReadableStream&&u instanceof globalThis.ReadableStream&&{duplex:"half"},...u&&{body:u},...this.fetchOptions??{},...n.fetchOptions??{}},url:c,timeout:n.timeout}}async buildHeaders({options:e,method:r,bodyHeaders:n,retryCount:i}){let s={};this.idempotencyHeader&&r!=="get"&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),s[this.idempotencyHeader]=e.idempotencyKey);let o=ne([s,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(i),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...Nae(),"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]),i=typeof globalThis.ReadableStream<"u"&&e instanceof globalThis.ReadableStream,s=!i&&(typeof e=="string"||e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof globalThis.Blob<"u"&&e instanceof globalThis.Blob||e instanceof URLSearchParams||e instanceof FormData);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e=="string"&&n.values.has("content-type")||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||i?{bodyHeaders:void 0,body:e,isStreamingBody:!s}:typeof e=="object"&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&typeof e.next=="function")?{bodyHeaders:void 0,body:BR(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}:{...D(this,pI,"f").call(this,{body:e,headers:n}),isStreamingBody:!1}}};L2=Ne,pI=new WeakMap,D2=new WeakSet,wce=function(){return this.baseURL!=="https://api.openai.com/v1"};Ne.OpenAI=L2;Ne.DEFAULT_TIMEOUT=6e5;Ne.OpenAIError=ge;Ne.APIError=wt;Ne.APIConnectionError=Xa;Ne.APIConnectionTimeoutError=Qa;Ne.APIUserAbortError=Dt;Ne.NotFoundError=Np;Ne.ConflictError=kp;Ne.RateLimitError=Dp;Ne.BadRequestError=Cp;Ne.AuthenticationError=Pp;Ne.InternalServerError=Lp;Ne.PermissionDeniedError=Op;Ne.UnprocessableEntityError=Mp;Ne.InvalidWebhookSignatureError=Ss;Ne.toFile=YR;Ne.Completions=iu;Ne.Chat=ic;Ne.Embeddings=ou;Ne.Files=cu;Ne.Images=fu;Ne.Audio=As;Ne.Moderations=hu;Ne.Models=pu;Ne.FineTuning=Ni;Ne.Graders=fc;Ne.VectorStores=Fo;Ne.Webhooks=_u;Ne.Beta=Oi;Ne.Batches=Ql;Ne.Uploads=hc;Ne.Responses=$o;Ne.Realtime=Lo;Ne.Conversations=uc;Ne.Evals=dc;Ne.Containers=lc;Ne.Skills=Uo;Ne.Videos=gu;var Zn=me("runner_codex"),$2="Codex CLI",vh="gpt-5.6-sol";async function Cze({aiGateway:t,config:e,model:r}){let n=r;if(t)if(e.modelVersionOverrides?.codex){let i=e.modelVersionOverrides?.codex?.[e.accountType];if(i){if(!await t.isModelAvailableForProvider("openai",i))throw new Error(`Model override '${i}' is not available for openai provider`);n=i}}else if(r){if(!await t.isModelAvailableForProvider("openai",r))throw new Error(`Model '${r}' is not available for openai provider`)}else!!vh&&await t.isModelAvailableForProvider("openai",vh)?(n=vh,Zn.log(`Using default model: ${vh}`)):vh&&Zn.log(`Default model ${vh} is not available, proceeding without model specification`);return n}var hI="netlify-ask-db",Pze=`default_permissions = "${hI}"`,Oze=t=>["",`[permissions.${hI}]`,'description = "Ask mode: read-only filesystem, network limited to the project database"','extends = ":read-only"',"",`[permissions.${hI}.network]`,"enabled = true","",`[permissions.${hI}.network.domains]`,`"${t}" = "allow"`];function Nze({aiGateway:t}){if(t){let{token:e,url:r}=t;if(!e||!r)throw new Error("No token or url provided from AI Gateway");mc.env.OPENAI_API_KEY=e,mc.env.OPENAI_BASE_URL=r}else if(!mc.env.OPENAI_API_KEY)throw new Error("OPENAI_API_KEY is not provided")}async function U2({config:t,netlify:e,persistSteps:r,sendSteps:n,aiGateway:i,continueSession:s,priorAgentSessionId:o,cwd:a=mc.cwd(),abortSignal:c,onSessionId:l,effortOverride:u}){let{prompt:d}=t,{model:f}=t;Nze({aiGateway:i});let p=await Cze({config:t,aiGateway:i,model:f}),h=[],m=[],S=[],T={},E=new Set,A=0,v=0,R,P,L,C,N,B=Hf(t),_=`${mc.env.NVM_BIN}/node`,se=bh.join(mI.homedir(),".codex"),I=bh.join(se,"config.toml"),g=bh.join(se,"auth.json");try{await nS.mkdir(se,{recursive:!0});let De={OPENAI_API_KEY:mc.env.OPENAI_API_KEY};await nS.writeFile(g,JSON.stringify(De,null,2),"utf-8"),Zn.log("Created Codex auth.json file");let z=mc.env.OPENAI_BASE_URL,Ee=['forced_login_method = "api"'],W=We().questionsEnabled;B&&Ee.push(Pze),z&&Ee.push('model_provider = "openai_proxy"',"","[model_providers.openai_proxy]",'name = "OpenAI Proxy"',`base_url = "${z}"`,'env_key = "OPENAI_API_KEY"','wire_api = "responses"',"supports_websockets = false","requires_openai_auth = true"),W&&Ee.push(...pie()),B&&Ee.push(...Oze(B.host)),await nS.writeFile(I,`${Ee.join(`
|
|
298
298
|
`)}
|
|
299
299
|
`,"utf-8"),Zn.log("Wrote Codex config.toml")}catch(De){let z=De instanceof Error?De.message:String(De);throw Zn.warn("Failed to setup Codex config and credentials",{error:z}),new Error(`Codex setup failed: ${z}`)}let y=p==="gpt-5.6-sol",w=u??(y?"low":"high"),X=!!(s&&o),q="mode"in t&&t.mode==="ask",ae=!!B,Re=[fs(a,"codex"),"exec",...q&&!ae?["--sandbox","read-only"]:[],...X?["resume",o]:[],...q?[]:["--yolo"],"--json",...u?["-c",`model_reasoning_effort="${u}"`]:y?["-c",'model_reasoning_effort="low"']:[],...p?["--model",p]:[]].filter(Boolean);Zn.log(`Running ${_} ${Re.join(" ")}`);let xe=e.utils.run(_,Re,{all:!0,cwd:a,env:{...mc.env},stdin:"pipe",idleTimeout:co,cancelSignal:c});xe.stdin?.end(d);let $e=Ca(()=>{r?.({steps:h,duration:v}),n?.({steps:m,duration:v}),m=[]},250),oe=(De,z)=>{let Ee={...De,id:A};A+=1,S.push(Ee),h.push(Ee),m.push(Ee),z||$e.flush(),$e(),z&&$e.flush()};oe({title:`Using ${$2} with ${p||"default"}`,category:Z.Environment},!0);let Ae=Ize.createInterface({input:xe.all});Ae.on("error",De=>{Zn.error("Readline interface error",{error:De.message,stack:De.stack})}),Ae.on("line",De=>{let z;try{z=JSON.parse(De)}catch{Zn.log("Could not parse line",De);return}if(z?.duration_ms&&(v=z.duration_ms),z?.type==="thread.started"&&typeof z?.thread_id=="string"&&(L=z.thread_id,l?.(L)),z?.type==="item.started"&&z?.item?.type==="command_execution")T[z.item.id]=z.item;else if(z?.type==="item.completed"&&z?.item?.type==="command_execution"){let Ee=z.item,W=Dze(Ee);W&&oe(W,!0);let k=Ee.command?.match(/\.agents\/skills\/([^\s/]+)/)?.[1];if(k&&!E.has(k)){E.add(k);let $=ps(k);_o(Zn,$),oe({title:`Use ${$}`,category:Z.Skill,type:k},!0)}}else if(z?.type==="item.completed"&&z?.item?.type==="reasoning"){let Ee={title:"Reasoning",message:z.item.text,category:Z.Reasoning};oe(Ee,!0)}else if(z?.type==="item.completed"&&z?.item?.type==="agent_message")R=z.item.text;else if(z?.type==="item.started"&&z?.item?.type==="mcp_tool_call"){let Ee=z.item;if(Ee.server===Wf&&Ee.tool==="ask"&&!N){let W=xp.safeParse(Ee.arguments);W.success?(N={questions:W.data.questions,toolUseId:Ee.id},xe.kill()):(Zn.warn("Ignoring malformed ask tool input",{toolUseId:Ee.id}),fe.inc("inference.malformed_ask",1))}}else if(z?.type==="turn.completed"&&z.usage)C={input_tokens:z.usage.input_tokens,output_tokens:z.usage.output_tokens},Ta(C);else if(z?.type==="turn.failed"&&z?.error?.message)P=z.error.message;else if(z?.type==="local_shell_call"){let Ee=z;T[Ee.call_id]=Ee}else if(z?.type==="local_shell_call_output"){let Ee=z,W=T[Ee.call_id],k=Lze(W,Ee);k&&oe(k,!0);let U=(W?.action?.command?.join(" ")??"").match(/\.agents\/skills\/([^\s/]+)/)?.[1];if(U&&!E.has(U)){E.add(U);let F=ps(U);_o(Zn,F),oe({title:`Use ${F}`,category:Z.Skill,type:U},!0)}}else z?.type==="message"&&z.role==="assistant"?R=z.content?.map(Ee=>Ee.text).join(`
|
|
300
300
|
`):z?.type==="message"&&z.role==="system"&&(P=z.content?.map(Ee=>Ee.text).join(`
|
package/package.json
CHANGED