@netlify/agent-runner-cli 1.145.0-ex-2517.3 → 1.145.0-ex-2517.4
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:PD},BNe=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},jNe={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:BNe};import{Buffer as zNe}from"buffer";var i7=(t,e)=>t?void 0:GNe.bind(void 0,e),GNe=function*(t,e){if(typeof e!="string"&&!jt(e)&&!zNe.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},o7=(t,e)=>t?qNe.bind(void 0,e):VNe.bind(void 0,e),qNe=function*(t,e){s7(t,e),yield e},VNe=function*(t,e){if(s7(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},s7=(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 HNe}from"buffer";import{StringDecoder as WNe}from"string_decoder";var Cx=(t,e,r)=>{if(r)return;if(t)return{transform:YNe.bind(void 0,new TextEncoder)};let n=new WNe(e);return{transform:KNe.bind(void 0,n),final:ZNe.bind(void 0,n)}},YNe=function*(t,e){HNe.isBuffer(e)?yield ms(e):typeof e=="string"?yield t.encode(e):yield e},KNe=function*(t,e){yield jt(e)?t.write(e):e},ZNe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as a7}from"util";var ND=a7(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),Px=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=XNe}=e[r];for await(let i of n(t))yield*Px(i,e,r+1)},c7=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*JNe(r,Number(e),t)},JNe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*Px(n,r,e+1)},l7=a7(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),XNe=function*(t){yield t};var kD=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},u7=(t,e)=>[...e.flatMap(r=>[...Rl(r,t,0)]),...l_(t)],Rl=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=eke}=e[r];for(let i of n(t))yield*Rl(i,e,r+1)},l_=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*QNe(r,Number(e),t)},QNe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Rl(n,r,e+1)},eke=function*(t){yield t};var MD=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=f7(t,s,o),l=Al(e),u=Al(r),d=l?ND.bind(void 0,Px,a):kD.bind(void 0,Rl),f=l||u?ND.bind(void 0,c7,a):kD.bind(void 0,l_),p=l||u?l7.bind(void 0,a):void 0;return{stream:new tke({writableObjectMode:n,writableHighWaterMark:d7(n),readableObjectMode:i,readableHighWaterMark:d7(i),transform(m,S,E){d([m,c,0],this,E)},flush(m){f([c],this,m)},destroy:p})}},Ox=(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=f7(s,r,a);t=u7(c,t)}return t},f7=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:i7(n,a)},Cx(r,s,n),Ix(r,o,n,c),{transform:t,final:e},{transform:o7(i,a)},n7({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var p7=(t,e)=>{for(let r of rke(t))nke(t,r,e)},rke=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),nke=(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 ${ka[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>ike(a,n));r.input=Qg(s)},ike=(t,e)=>{let r=Ox(t,e,"utf8",!0);return oke(r),Qg(r)},oke=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 lke,appendFileSync as uke}from"fs";var Nx=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Gd(r,n)&&!Sn.has(e)&&ske(n)&&(t.some(({type:i,value:o})=>i==="native"&&ake.has(o))||t.every(({type:i})=>Yn.has(i))),ske=t=>t===1||t===2,ake=new Set(["pipe","overlapped"]),h7=async(t,e,r,n)=>{for await(let i of t)cke(e)||g7(i,r,n)},m7=(t,e,r)=>{for(let n of t)g7(n,e,r)},cke=t=>t._readableState.pipes.length>0,g7=(t,e,r)=>{let n=HT(t);po({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var _7=({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)=>dke({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},dke=({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=yQ(t,o,d),p=ms(f),{stdioItems:h,objectMode:m}=e[r],S=fke([p],h,c,n),{serializedResult:E,finalResult:T=E}=pke({chunks:S,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});hke({serializedResult:E,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let x=a[r]?T:void 0;try{return n.error===void 0&&mke(E,h,i),x}catch(_){return n.error=_,x}},fke=(t,e,r,n)=>{try{return Ox(t,e,r,!1)}catch(i){return n.error=i,t}},pke=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Qg(t)};let s=N9(t,r);return n[o]?{serializedResult:s,finalResult:OD(s,!i[o],e)}:{serializedResult:s}},hke=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!Nx({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=OD(t,!1,s);try{m7(a,e,n)}catch(c){r.error??=c}},mke=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>Ax.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?uke(n,t):(r.add(o),lke(n,t))}};var y7=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,ys(e,r,"all")]:Array.isArray(e)?[ys(t,r,"all"),...e]:jt(t)&&jt(e)?BM([t,e]):`${t}${e}`};import{once as DD}from"events";var S7=async(t,e)=>{let[r,n]=await gke(t);return e.isForcefullyTerminated??=!1,[r,n]},gke=async t=>{let[e,r]=await Promise.allSettled([DD(t,"spawn"),DD(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?E7(t):r.value},E7=async t=>{try{return await DD(t,"exit")}catch{return E7(t)}},v7=async t=>{let[e,r]=await t;if(!_ke(e,r)&&LD(e,r))throw new Ai;return[e,r]},_ke=(t,e)=>t===void 0&&e===void 0,LD=(t,e)=>t!==0||e!==null;var b7=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=yke(t,e,r),s=o?.code==="ETIMEDOUT",a=_Q(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},yke=(t,e,r)=>t!==void 0?t:LD(e,r)?new Ai:void 0;var T7=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=Eke(t,e,r),d=Tke({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Qd(d,c,l)},Eke=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=YT(t,e,r),a=vke(r),{file:c,commandArguments:l,options:u}=hx(t,e,a);bke(u);let d=QQ(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},vke=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,bke=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&kx("ipcInput"),t&&kx("ipc: true"),r&&kx("detached: true"),n&&kx("cancelSignal")},kx=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Tke=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=xke({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}=b7(c,r),{output:h,error:m=l}=_7({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),S=h.map((T,x)=>ys(T,r,x)),E=ys(y7(h,r),r,"all");return Ake({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:S,all:E,options:r,command:n,escapedCommand:i,startTime:a})},xke=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{p7(o,r);let a=wke(r);return Ske(...mx(t,e,a))}catch(a){return Xd({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},wke=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:bx(e)}),Ake=({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?Tx({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):c_({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 pDe}from"events";import{spawn as hDe}from"child_process";import I7 from"process";import{once as $D,on as Rke}from"events";var x7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Hd({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:cx(t)}),Ike({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),Ike=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{ix(e,i);let o=Na(t,e,r),s=new AbortController;try{return await Promise.race([Cke(o,n,s),Pke(o,r,s),Oke(o,r,s)])}catch(a){throw Wd(t),a}finally{s.abort(),ox(e,i)}},Cke=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await $D(t,"message",{signal:r});return n}for await(let[n]of Rke(t,"message",{signal:r}))if(e(n))return n},Pke=async(t,e,{signal:r})=>{await $D(t,"disconnect",{signal:r}),uX(e)},Oke=async(t,e,{signal:r})=>{let[n]=await $D(t,"strict:error",{signal:r});throw tx(n,e)};import{once as A7,on as Nke}from"events";var R7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>UD({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),UD=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Hd({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:cx(t)}),ix(e,o);let s=Na(t,e,r),a=new AbortController,c={};return kke(t,s,a),Mke({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),Dke({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},kke=async(t,e,r)=>{try{await A7(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Mke=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await A7(t,"strict:error",{signal:r.signal});n.error=tx(i,e),r.abort()}catch{}},Dke=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of Nke(r,"message",{signal:o.signal}))w7(s),yield c}catch{w7(s)}finally{o.abort(),ox(e,a),n||Wd(t),i&&await t}},w7=({error:t})=>{if(t)throw t};var C7=(t,{ipc:e})=>{Object.assign(t,O7(t,!1,e))},P7=()=>{let t=I7,e=!0,r=I7.channel!==void 0;return{...O7(t,e,r),getCancelSignal:$X.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},O7=(t,e,r)=>({sendMessage:fx.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:x7.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:R7.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Lke}from"child_process";import{PassThrough as $ke,Readable as Uke,Writable as Fke,Duplex as Bke}from"stream";var N7=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{ID(n);let a=new Lke;jke(a,n),Object.assign(a,{readable:zke,writable:Gke,duplex:qke});let c=Xd({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=Vke(c,s,i);return{subprocess:a,promise:l}},jke=(t,e)=>{let r=u_(),n=u_(),i=u_(),o=Array.from({length:e.length-3},u_),s=u_(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},u_=()=>{let t=new $ke;return t.end(),t},zke=()=>new Uke({read(){}}),Gke=()=>new Fke({write(){}}),qke=()=>new Bke({read(){},write(){}}),Vke=async(t,e,r)=>Qd(t,e,r);import{createReadStream as k7,createWriteStream as M7}from"fs";import{Buffer as Hke}from"buffer";import{Readable as d_,Writable as Wke,Duplex as Yke}from"stream";var L7=(t,e)=>Rx(Kke,t,e,!1),f_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${ka[t]}.`)},D7={fileNumber:f_,generator:MD,asyncGenerator:MD,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Yke.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Kke={input:{...D7,fileUrl:({value:t})=>({stream:k7(t)}),filePath:({value:{file:t}})=>({stream:k7(t)}),webStream:({value:t})=>({stream:d_.fromWeb(t)}),iterable:({value:t})=>({stream:d_.from(t)}),asyncIterable:({value:t})=>({stream:d_.from(t)}),string:({value:t})=>({stream:d_.from(t)}),uint8Array:({value:t})=>({stream:d_.from(Hke.from(t))})},output:{...D7,fileUrl:({value:t})=>({stream:M7(t)}),filePath:({value:{file:t,append:e}})=>({stream:M7(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Wke.fromWeb(t)}),iterable:f_,asyncIterable:f_,string:f_,uint8Array:f_}};import{on as Zke,once as $7}from"events";import{PassThrough as Jke,getDefaultHighWaterMark as Xke}from"stream";import{finished as B7}from"stream/promises";function Il(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)BD(i);let e=t.some(({readableObjectMode:i})=>i),r=Qke(t,e),n=new FD({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Qke=(t,e)=>{if(t.length===0)return Xke(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},FD=class extends Jke{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(BD(e),this.#e.has(e))return;this.#e.add(e),this.#n??=eMe(this,this.#e,this.#o);let r=nMe({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(BD(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)}},eMe=async(t,e,r)=>{Mx(t,U7);let n=new AbortController;try{await Promise.race([tMe(t,n),rMe(t,e,r,n)])}finally{n.abort(),Mx(t,-U7)}},tMe=async(t,{signal:e})=>{try{await B7(t,{signal:e,cleanup:!0})}catch(r){throw j7(t,r),r}},rMe=async(t,e,r,{signal:n})=>{for await(let[i]of Zke(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},BD=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},nMe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{Mx(t,F7);let a=new AbortController;try{await Promise.race([iMe(o,e,a),oMe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),sMe({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),Mx(t,-F7)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?jD(t):aMe(t))},iMe=async(t,e,{signal:r})=>{try{await t,r.aborted||jD(e)}catch(n){r.aborted||j7(e,n)}},oMe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await B7(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;z7(s)?i.add(e):G7(t,s)}},sMe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await $7(t,i,{signal:o}),!t.readable)return $7(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},aMe=t=>{t.writable&&t.end()},j7=(t,e)=>{z7(e)?jD(t):G7(t,e)},z7=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",jD=t=>{(t.readable||t.writable)&&t.destroy()},G7=(t,e)=>{t.destroyed||(t.once("error",cMe),t.destroy(e))},cMe=()=>{},Mx=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},U7=2,F7=1;import{finished as q7}from"stream/promises";var tf=(t,e)=>{t.pipe(e),lMe(t,e),uMe(t,e)},lMe=async(t,e)=>{if(!(wi(t)||wi(e))){try{await q7(t,{cleanup:!0,readable:!0,writable:!1})}catch{}zD(e)}},zD=t=>{t.writable&&t.end()},uMe=async(t,e)=>{if(!(wi(t)||wi(e))){try{await q7(e,{cleanup:!0,readable:!1,writable:!0})}catch{}GD(t)}},GD=t=>{t.readable&&t.destroy()};var V7=(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)))dMe(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Yn.has(c)))pMe({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]:Il(o);tf(s,i)}},dMe=(t,e,r,n)=>{r==="output"?tf(t.stdio[n],e):tf(e,t.stdio[n]);let i=fMe[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},fMe=["stdin","stdout","stderr"],pMe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;hMe(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},hMe=(t,{signal:e})=>{wi(t)&&xl(t,mMe,e)},mMe=2;import{addAbortListener as yMe}from"events";var Cl=[];Cl.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Cl.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Cl.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var Dx=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",qD=Symbol.for("signal-exit emitter"),VD=globalThis,gMe=Object.defineProperty.bind(Object),HD=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(VD[qD])return VD[qD];gMe(VD,qD,{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}},Lx=class{},_Me=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),WD=class extends Lx{onExit(){return()=>{}}load(){}unload(){}},YD=class extends Lx{#e=KD.platform==="win32"?"SIGINT":"SIGHUP";#r=new HD;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Cl)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(!Dx(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 Cl)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,Cl.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 Dx(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"&&Dx(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)}},KD=globalThis.process,{onExit:H7,load:Qpt,unload:eht}=_Me(Dx(KD)?new YD(KD):new WD);var W7=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=H7(()=>{t.kill()});yMe(n,()=>{i()})};var K7=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=WT(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=SMe(r,n,i),{sourceStream:d,sourceError:f}=vMe(t,l),{options:p,fileDescriptors:h}=mo.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},SMe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=EMe(t,e,...r),a=nx(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},EMe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Y7,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||UM(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]=$T(r,...n);return{destination:e(Y7)(i,o,s),pipeOptions:s}}if(mo.has(r)){if(Object.keys(t).length>0)throw new TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:r,pipeOptions:n[0]}}throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${r}`)},Y7=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),vMe=(t,e)=>{try{return{sourceStream:Yd(t,e)}}catch(r){return{sourceError:r}}};var J7=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=bMe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw ZD({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},bMe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return GD(t),n;if(e!==void 0)return zD(r),e},ZD=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Xd({error:t,command:Z7,escapedCommand:Z7,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Z7="source.pipe(destination)";var X7=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 TMe}from"stream/promises";var Q7=(t,e,r)=>{let n=$x.has(e)?wMe(t,e):xMe(t,e);return xl(t,RMe,r.signal),xl(e,IMe,r.signal),AMe(e),n},xMe=(t,e)=>{let r=Il([t]);return tf(r,e),$x.set(e,r),r},wMe=(t,e)=>{let r=$x.get(e);return r.add(t),r},AMe=async t=>{try{await TMe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}$x.delete(t)},$x=new WeakMap,RMe=2,IMe=1;import{aborted as CMe}from"util";var eee=(t,e)=>t===void 0?[]:[PMe(t,e)],PMe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await CMe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw ZD({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var Ux=(t,...e)=>{if(Ct(e[0]))return Ux.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=K7(t,...e),i=OMe({...n,destination:r});return i.pipe=Ux.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},OMe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=NMe(t,i);J7({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Q7(e,o,d);return await Promise.race([X7(u),...eee(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},NMe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as FMe}from"timers/promises";import{on as kMe}from"events";import{getDefaultHighWaterMark as MMe}from"stream";var Fx=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return DMe(e,s),ree({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},DMe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},JD=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;LMe(e,s,t);let a=t.readableObjectMode&&!o;return ree({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},LMe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},ree=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=kMe(t,"data",{signal:e.signal,highWaterMark:tee,highWatermark:tee});return $Me({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},XD=MMe(!0),tee=XD,$Me=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=UMe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Rl(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*l_(a)}},UMe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[Cx(t,r,!e),Ix(t,i,!n,{})].filter(Boolean);var nee=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=BMe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([jMe(t),d]);return}let f=CD(c,r),p=JD({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([zMe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},BMe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!Nx({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=JD({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await h7(a,t,r,o)},jMe=async t=>{await FMe(),t.readableFlowing===null&&t.resume()},zMe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await Sx(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await Ex(r,{maxBuffer:o})):await Jd(r,{maxBuffer:o})}catch(a){return iee(hQ({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},QD=async t=>{try{return await t}catch(e){return iee(e)}},iee=({bufferedData:t})=>P9(t)?new Uint8Array(t):t;import{finished as GMe}from"stream/promises";var p_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=qMe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],GMe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||WMe(a,e,r,n)}finally{s.abort()}},qMe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&VMe(t,r,n),n},VMe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{HMe(e,r),n.call(t,...i)}},HMe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},WMe=(t,e,r,n)=>{if(!YMe(t,e,r,n))throw t},YMe=(t,e,r,n=!0)=>r.propagating?oee(t)||Bx(t):(r.propagating=!0,eL(r,e)===n?oee(t):Bx(t)),eL=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",Bx=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",oee=t=>t?.code==="EPIPE";var see=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>tL({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),tL=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=p_(t,e,l);if(eL(l,e)){await u;return}let[d]=await Promise.all([nee({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 aee=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Il([t,e].filter(Boolean)):void 0,cee=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>tL({...KMe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:ZMe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),KMe=({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}},ZMe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as JMe}from"events";var lee=t=>Gd(t,"ipc"),uee=(t,e)=>{let r=HT(t);po({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var dee=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=lee(o),a=gs(e,"ipc"),c=gs(r,"ipc");for await(let l of UD({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(mQ(t,i,c),i.push(l)),s&&uee(l,o);return i},fee=async(t,e)=>(await Promise.allSettled([t]),e);var pee=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:S,controller:E})=>{let T=S7(t,f),x={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:T,propagating:!1},_=see({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:x}),A=cee({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:x}),R=[],P=dee({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:R,verboseInfo:p}),C=XMe(m,t,x),M=QMe(h,x);try{return await Promise.race([Promise.all([{},v7(T),Promise.all(_),A,P,WX(t,d),...C,...M]),S,eDe(t,E),...zX(t,o,f,E),...lX({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:E}),...BX({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:E})])}catch(F){return f.terminationReason??="other",Promise.all([{error:F},T,Promise.all(_.map(y=>QD(y))),QD(A),fee(P,R),Promise.allSettled(C),Promise.allSettled(M)])}},XMe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:p_(n,i,r)),QMe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Ii(o,{checkOpen:!1})&&!wi(o)).map(({type:i,value:o,stream:s=o})=>p_(s,n,e,{isSameDirection:Yn.has(i),stopOnExit:i==="native"}))),eDe=async(t,{signal:e})=>{let[r]=await JMe(t,"error",{signal:e});throw r};var hee=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),h_=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=ho();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},rf=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 tDe}from"stream";import{callbackify as rDe}from"util";import{finished as mee}from"stream/promises";var rL=async t=>{if(t!==void 0)try{await nL(t)}catch{}},gee=async t=>{if(t!==void 0)try{await iL(t)}catch{}},nL=async t=>{await mee(t,{cleanup:!0,readable:!1,writable:!0})},iL=async t=>{await mee(t,{cleanup:!0,readable:!0,writable:!1})},jx=async(t,e)=>{if(await t,e)throw e},zx=(t,e,r)=>{r&&!Bx(r)?t.destroy(r):e&&t.destroy()};var _ee=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||Sn.has(r),{subprocessStdout:a,waitReadableDestroy:c}=oL(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=sL(a,s),{read:f,onStdoutDataDone:p}=aL({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new tDe({read:f,destroy:rDe(lL.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return cL({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},oL=(t,e,r)=>{let n=Yd(t,e),i=h_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},sL=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:XD},aL=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=ho(),s=Fx({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){nDe(this,s,o)},onStdoutDataDone:o}},nDe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},cL=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await iL(t),await n,await rL(i),await e,r.readable&&r.push(null)}catch(o){await rL(i),yee(r,o)}},lL=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await rf(r,e)&&(yee(t,n),await jx(e,n))},yee=(t,e)=>{zx(t,t.readable,e)};import{Writable as iDe}from"stream";import{callbackify as See}from"util";var Eee=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=uL(t,r,e),s=new iDe({...dL(n,t,i),destroy:See(pL.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return fL(n,s),s},uL=(t,e,r)=>{let n=nx(t,e),i=h_(r,n,"writableFinal"),o=h_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},dL=(t,e,r)=>({write:oDe.bind(void 0,t),final:See(sDe.bind(void 0,t,e,r))}),oDe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},sDe=async(t,e,r)=>{await rf(r,e)&&(t.writable&&t.end(),await e)},fL=async(t,e,r)=>{try{await nL(t),e.writable&&e.end()}catch(n){await gee(r),vee(e,n)}},pL=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await rf(r,e),await rf(n,e)&&(vee(t,i),await jx(e,i))},vee=(t,e)=>{zx(t,t.writable,e)};import{Duplex as aDe}from"stream";import{callbackify as cDe}from"util";var bee=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||Sn.has(r),{subprocessStdout:c,waitReadableDestroy:l}=oL(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=uL(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=sL(c,a),{read:S,onStdoutDataDone:E}=aL({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),T=new aDe({read:S,...dL(u,t,d),destroy:cDe(lDe.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 cL({subprocessStdout:c,onStdoutDataDone:E,readable:T,subprocess:t,subprocessStdin:u}),fL(u,T,c),T},lDe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([lL({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),pL({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var hL=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||Sn.has(e),s=Yd(t,r),a=Fx({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return uDe(a,s,t)},uDe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Tee=(t,{encoding:e})=>{let r=hee();t.readable=_ee.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Eee.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=bee.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=hL.bind(void 0,t,e),t[Symbol.asyncIterator]=hL.bind(void 0,t,e,{})};var xee=(t,e)=>{for(let[r,n]of fDe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},dDe=(async()=>{})().constructor.prototype,fDe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(dDe,t)]);var wee=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=mDe(t,e,r),{subprocess:f,promise:p}=_De({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=Ux.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),xee(f,p),mo.set(f,{options:u,fileDescriptors:d}),f},mDe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=YT(t,e,r),{file:a,commandArguments:c,options:l}=hx(t,e,r),u=gDe(l),d=L7(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},gDe=({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}},_De=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=hDe(...mx(t,e,r))}catch(h){return N7({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;pDe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];V7(c,a,l),W7(c,r,l);let d={},f=ho();c.kill=aX.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=aee(c,r),Tee(c,r),C7(c,r);let p=yDe({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}},yDe=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,S]=await pee({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let E=h.map((_,A)=>ys(_,e,A)),T=ys(m,e,"all"),x=SDe({errorInfo:d,exitCode:f,signal:p,stdio:E,all:T,ipcOutput:S,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Qd(x,n,e)},SDe=({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?c_({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 go,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):Tx({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var Gx=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,EDe(n,t[n],i)]));return{...t,...r}},EDe=(t,e,r)=>vDe.has(t)&&Ct(e)&&Ct(r)?{...e,...r}:r,vDe=new Set(["env",...qM]);var Ma=(t,e,r,n)=>{let i=(s,a,c)=>Ma(s,a,r,c),o=(...s)=>bDe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},bDe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Ct(o))return i(t,Gx(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=TDe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?T7(a,c,l):wee(a,c,l,i)},TDe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=L9(e)?$9(e,r):[e,...r],[s,a,c]=$T(...o),l=Gx(Gx(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 Aee=({file:t,commandArguments:e})=>Iee(t,e),Ree=({file:t,commandArguments:e})=>({...Iee(t,e),isSync:!0}),Iee=(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]=xDe(t);return{file:r,commandArguments:n}},xDe=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(wDe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},wDe=/ +/g;var Cee=(t,e,r)=>{t.sync=e(ADe,r),t.s=t.sync},Pee=({options:t})=>Oee(t),ADe=({options:t})=>({...Oee(t),isSync:!0}),Oee=t=>({options:{...RDe(t),...t}}),RDe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Nee={preferLocal:!0};var kee=Ma(()=>({})),Ggt=Ma(()=>({isSync:!0})),Mee=Ma(Aee),qgt=Ma(Ree),Vgt=Ma(qX),Hgt=Ma(Pee,{},Nee,Cee),{sendMessage:Wgt,getOneMessage:Ygt,getEachMessage:Kgt,getCancelSignal:Zgt}=P7();var Dee=!1,Lee=()=>{Dee=!0},yo=()=>Dee;var m_=null,$ee=t=>(m_&&m_.destroy(),m_=new Ss({totalAllowedTime:t}),m_),Uee=()=>m_;var Ss=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&&yo())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 PT({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}),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 Fee={name:"@netlify/agent-runner-cli",type:"module",version:"1.145.0-ex-2517.3",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.197","@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.3","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.8.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var ODe=CDe(import.meta.url),NDe=Es.dirname(ODe),kDe=PDe(import.meta.url),nf=ye("shell"),mL=new Set,Bee={preferLocal:!0},lr=(t,e,r)=>{let[n,i]=MDe(e,r),o={...Bee,...i},s=kee(t,n,o);zee(s,o),Vee(s);let a=r?.idleTimeout;return a&&a>0&&qee(s,a),s},jee=(t,e)=>{let r={...Bee,...e},n=Mee(t,r);return zee(n,r),Vee(n),e?.idleTimeout&&e.idleTimeout>0&&qee(n,e.idleTimeout),n},MDe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},zee=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(vs.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Vg).pipe(vs.stdout),t.stderr?.pipe(new Vg).pipe(vs.stderr);return}t.stdout?.pipe(vs.stdout),t.stderr?.pipe(vs.stderr)},gL=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(vs.kill(-t.pid,e),nf.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return nf.error("Error killing process:",r),!1}},Gee=t=>gL(t,"SIGKILL"),qee=(t,e)=>{let r=null,n=()=>{nf.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),gL(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(nf.log(`Force killing idle process ${t.pid}`),Gee(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)},Vee=t=>{mL.add(t);let e=Uee();if(e){let r=e.onTimesUp(()=>{nf.log(`Global timer expired, killing process ${t.pid}`),gL(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(nf.log(`Force killing process ${t.pid} after timeout`),Gee(t))},5e3)});t.on("exit",()=>{mL.delete(t),r()}),t.on("error",()=>{mL.delete(t),r()})}};function Vx(t,e){return!!Ci(t,e)}function Ci(t,e){if(!vs.env.NETLIFY_LOCAL_MODE)try{let i=kDe.resolve(Fee.name),o=Es.dirname(i);for(;o!==Es.dirname(o);){let s=Es.dirname(o);if(Es.basename(s)==="node_modules"){let a=Es.join(s,".bin",e);if(qx.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(vs.env.NODE_PATH){let i=Es.join(vs.env.NODE_PATH,".bin",e);if(qx.existsSync(i))return i}let r=Es.join(t,"node_modules",".bin",e);if(qx.existsSync(r))return r;let n=Es.join(NDe,"..","node_modules",".bin",e);if(qx.existsSync(n))return n}var DDe=ye("utils"),LDe=t=>new Promise(e=>{setTimeout(e,t)});var Hx=(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 LDe(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},Da=(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},Hee=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):DDe.error("Could not parse JSON",n))}},$De=t=>t.charAt(0).toUpperCase()+t.slice(1),So=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():$De(e)).join(" ");function bs(t,e){e&&t.log(`Skill invoked: ${e}`)}var Wx=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),Wee=(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}},UDe=1e4,yL=(t,e=UDe)=>{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 Yee}from"buffer";import FDe from"path";var Kee=ye("repo"),Xr=(t,e={})=>lr("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),Yx=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{Kee.info("Getting runner diffs");let n=await jDe(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let m=GDe(o);await qDe(m,r)}Kee.info("Changes after processing"),await EL(r);let s=await vL(o,r);if(await SL(s,r),i=await zDe(r),!i)return{hasChanges:!1,ignored:s};await Xr(["commit","-m","Agent runner"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await Xr(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(i=!!l,!i)return await Zee(r),{hasChanges:!1,ignored:s};let u=await Xr(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,p;if(t.sha){let m=await Xr(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let S=await Xr(["diff",t.sha,"HEAD","--binary"],a),E=String(S.stdout??"");f!==E&&(p=Yee.from(E).toString("base64"))}await Zee(r);let h={hasChanges:!0,diff:l,resultDiff:f,ignored:s};return l!==d&&(h.diffBinary=Yee.from(d).toString("base64")),p&&(h.resultDiffBinary=p),h},Zee=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Xr(["reset","--soft","HEAD~1"],{cwd:t})},SL=async(t=[],e=process.cwd())=>{await Xr(["add",".",...t],{cwd:e})},EL=async(t=process.cwd())=>{let e=await Xr(["status","-s"],{cwd:t});return String(e.stdout??"")},Jee=/.. (.+)?\.log$/,BDe=[Jee],jDe=async(t=process.cwd())=>{let e=await EL(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
102
|
+
if (condition) { yield value; }`)};import{Buffer as HNe}from"buffer";import{StringDecoder as WNe}from"string_decoder";var Cx=(t,e,r)=>{if(r)return;if(t)return{transform:YNe.bind(void 0,new TextEncoder)};let n=new WNe(e);return{transform:KNe.bind(void 0,n),final:ZNe.bind(void 0,n)}},YNe=function*(t,e){HNe.isBuffer(e)?yield ms(e):typeof e=="string"?yield t.encode(e):yield e},KNe=function*(t,e){yield jt(e)?t.write(e):e},ZNe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as a7}from"util";var ND=a7(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),Px=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=XNe}=e[r];for await(let i of n(t))yield*Px(i,e,r+1)},c7=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*JNe(r,Number(e),t)},JNe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*Px(n,r,e+1)},l7=a7(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),XNe=function*(t){yield t};var kD=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},u7=(t,e)=>[...e.flatMap(r=>[...Rl(r,t,0)]),...l_(t)],Rl=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=eke}=e[r];for(let i of n(t))yield*Rl(i,e,r+1)},l_=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*QNe(r,Number(e),t)},QNe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Rl(n,r,e+1)},eke=function*(t){yield t};var MD=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=f7(t,s,o),l=Al(e),u=Al(r),d=l?ND.bind(void 0,Px,a):kD.bind(void 0,Rl),f=l||u?ND.bind(void 0,c7,a):kD.bind(void 0,l_),p=l||u?l7.bind(void 0,a):void 0;return{stream:new tke({writableObjectMode:n,writableHighWaterMark:d7(n),readableObjectMode:i,readableHighWaterMark:d7(i),transform(m,S,E){d([m,c,0],this,E)},flush(m){f([c],this,m)},destroy:p})}},Ox=(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=f7(s,r,a);t=u7(c,t)}return t},f7=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:i7(n,a)},Cx(r,s,n),Ix(r,o,n,c),{transform:t,final:e},{transform:o7(i,a)},n7({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var p7=(t,e)=>{for(let r of rke(t))nke(t,r,e)},rke=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),nke=(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 ${ka[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>ike(a,n));r.input=Qg(s)},ike=(t,e)=>{let r=Ox(t,e,"utf8",!0);return oke(r),Qg(r)},oke=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 lke,appendFileSync as uke}from"fs";var Nx=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Gd(r,n)&&!Sn.has(e)&&ske(n)&&(t.some(({type:i,value:o})=>i==="native"&&ake.has(o))||t.every(({type:i})=>Yn.has(i))),ske=t=>t===1||t===2,ake=new Set(["pipe","overlapped"]),h7=async(t,e,r,n)=>{for await(let i of t)cke(e)||g7(i,r,n)},m7=(t,e,r)=>{for(let n of t)g7(n,e,r)},cke=t=>t._readableState.pipes.length>0,g7=(t,e,r)=>{let n=HT(t);po({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var _7=({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)=>dke({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},dke=({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=yQ(t,o,d),p=ms(f),{stdioItems:h,objectMode:m}=e[r],S=fke([p],h,c,n),{serializedResult:E,finalResult:T=E}=pke({chunks:S,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});hke({serializedResult:E,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let x=a[r]?T:void 0;try{return n.error===void 0&&mke(E,h,i),x}catch(_){return n.error=_,x}},fke=(t,e,r,n)=>{try{return Ox(t,e,r,!1)}catch(i){return n.error=i,t}},pke=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Qg(t)};let s=N9(t,r);return n[o]?{serializedResult:s,finalResult:OD(s,!i[o],e)}:{serializedResult:s}},hke=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!Nx({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=OD(t,!1,s);try{m7(a,e,n)}catch(c){r.error??=c}},mke=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>Ax.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?uke(n,t):(r.add(o),lke(n,t))}};var y7=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,ys(e,r,"all")]:Array.isArray(e)?[ys(t,r,"all"),...e]:jt(t)&&jt(e)?BM([t,e]):`${t}${e}`};import{once as DD}from"events";var S7=async(t,e)=>{let[r,n]=await gke(t);return e.isForcefullyTerminated??=!1,[r,n]},gke=async t=>{let[e,r]=await Promise.allSettled([DD(t,"spawn"),DD(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?E7(t):r.value},E7=async t=>{try{return await DD(t,"exit")}catch{return E7(t)}},v7=async t=>{let[e,r]=await t;if(!_ke(e,r)&&LD(e,r))throw new Ai;return[e,r]},_ke=(t,e)=>t===void 0&&e===void 0,LD=(t,e)=>t!==0||e!==null;var b7=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=yke(t,e,r),s=o?.code==="ETIMEDOUT",a=_Q(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},yke=(t,e,r)=>t!==void 0?t:LD(e,r)?new Ai:void 0;var T7=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=Eke(t,e,r),d=Tke({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Qd(d,c,l)},Eke=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=YT(t,e,r),a=vke(r),{file:c,commandArguments:l,options:u}=hx(t,e,a);bke(u);let d=QQ(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},vke=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,bke=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&kx("ipcInput"),t&&kx("ipc: true"),r&&kx("detached: true"),n&&kx("cancelSignal")},kx=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Tke=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=xke({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}=b7(c,r),{output:h,error:m=l}=_7({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),S=h.map((T,x)=>ys(T,r,x)),E=ys(y7(h,r),r,"all");return Ake({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:S,all:E,options:r,command:n,escapedCommand:i,startTime:a})},xke=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{p7(o,r);let a=wke(r);return Ske(...mx(t,e,a))}catch(a){return Xd({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},wke=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:bx(e)}),Ake=({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?Tx({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):c_({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 pDe}from"events";import{spawn as hDe}from"child_process";import I7 from"process";import{once as $D,on as Rke}from"events";var x7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Hd({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:cx(t)}),Ike({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),Ike=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{ix(e,i);let o=Na(t,e,r),s=new AbortController;try{return await Promise.race([Cke(o,n,s),Pke(o,r,s),Oke(o,r,s)])}catch(a){throw Wd(t),a}finally{s.abort(),ox(e,i)}},Cke=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await $D(t,"message",{signal:r});return n}for await(let[n]of Rke(t,"message",{signal:r}))if(e(n))return n},Pke=async(t,e,{signal:r})=>{await $D(t,"disconnect",{signal:r}),uX(e)},Oke=async(t,e,{signal:r})=>{let[n]=await $D(t,"strict:error",{signal:r});throw tx(n,e)};import{once as A7,on as Nke}from"events";var R7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>UD({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),UD=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Hd({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:cx(t)}),ix(e,o);let s=Na(t,e,r),a=new AbortController,c={};return kke(t,s,a),Mke({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),Dke({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},kke=async(t,e,r)=>{try{await A7(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Mke=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await A7(t,"strict:error",{signal:r.signal});n.error=tx(i,e),r.abort()}catch{}},Dke=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of Nke(r,"message",{signal:o.signal}))w7(s),yield c}catch{w7(s)}finally{o.abort(),ox(e,a),n||Wd(t),i&&await t}},w7=({error:t})=>{if(t)throw t};var C7=(t,{ipc:e})=>{Object.assign(t,O7(t,!1,e))},P7=()=>{let t=I7,e=!0,r=I7.channel!==void 0;return{...O7(t,e,r),getCancelSignal:$X.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},O7=(t,e,r)=>({sendMessage:fx.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:x7.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:R7.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Lke}from"child_process";import{PassThrough as $ke,Readable as Uke,Writable as Fke,Duplex as Bke}from"stream";var N7=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{ID(n);let a=new Lke;jke(a,n),Object.assign(a,{readable:zke,writable:Gke,duplex:qke});let c=Xd({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=Vke(c,s,i);return{subprocess:a,promise:l}},jke=(t,e)=>{let r=u_(),n=u_(),i=u_(),o=Array.from({length:e.length-3},u_),s=u_(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},u_=()=>{let t=new $ke;return t.end(),t},zke=()=>new Uke({read(){}}),Gke=()=>new Fke({write(){}}),qke=()=>new Bke({read(){},write(){}}),Vke=async(t,e,r)=>Qd(t,e,r);import{createReadStream as k7,createWriteStream as M7}from"fs";import{Buffer as Hke}from"buffer";import{Readable as d_,Writable as Wke,Duplex as Yke}from"stream";var L7=(t,e)=>Rx(Kke,t,e,!1),f_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${ka[t]}.`)},D7={fileNumber:f_,generator:MD,asyncGenerator:MD,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Yke.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Kke={input:{...D7,fileUrl:({value:t})=>({stream:k7(t)}),filePath:({value:{file:t}})=>({stream:k7(t)}),webStream:({value:t})=>({stream:d_.fromWeb(t)}),iterable:({value:t})=>({stream:d_.from(t)}),asyncIterable:({value:t})=>({stream:d_.from(t)}),string:({value:t})=>({stream:d_.from(t)}),uint8Array:({value:t})=>({stream:d_.from(Hke.from(t))})},output:{...D7,fileUrl:({value:t})=>({stream:M7(t)}),filePath:({value:{file:t,append:e}})=>({stream:M7(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Wke.fromWeb(t)}),iterable:f_,asyncIterable:f_,string:f_,uint8Array:f_}};import{on as Zke,once as $7}from"events";import{PassThrough as Jke,getDefaultHighWaterMark as Xke}from"stream";import{finished as B7}from"stream/promises";function Il(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)BD(i);let e=t.some(({readableObjectMode:i})=>i),r=Qke(t,e),n=new FD({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Qke=(t,e)=>{if(t.length===0)return Xke(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},FD=class extends Jke{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(BD(e),this.#e.has(e))return;this.#e.add(e),this.#n??=eMe(this,this.#e,this.#o);let r=nMe({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(BD(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)}},eMe=async(t,e,r)=>{Mx(t,U7);let n=new AbortController;try{await Promise.race([tMe(t,n),rMe(t,e,r,n)])}finally{n.abort(),Mx(t,-U7)}},tMe=async(t,{signal:e})=>{try{await B7(t,{signal:e,cleanup:!0})}catch(r){throw j7(t,r),r}},rMe=async(t,e,r,{signal:n})=>{for await(let[i]of Zke(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},BD=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},nMe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{Mx(t,F7);let a=new AbortController;try{await Promise.race([iMe(o,e,a),oMe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),sMe({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),Mx(t,-F7)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?jD(t):aMe(t))},iMe=async(t,e,{signal:r})=>{try{await t,r.aborted||jD(e)}catch(n){r.aborted||j7(e,n)}},oMe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await B7(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;z7(s)?i.add(e):G7(t,s)}},sMe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await $7(t,i,{signal:o}),!t.readable)return $7(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},aMe=t=>{t.writable&&t.end()},j7=(t,e)=>{z7(e)?jD(t):G7(t,e)},z7=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",jD=t=>{(t.readable||t.writable)&&t.destroy()},G7=(t,e)=>{t.destroyed||(t.once("error",cMe),t.destroy(e))},cMe=()=>{},Mx=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},U7=2,F7=1;import{finished as q7}from"stream/promises";var tf=(t,e)=>{t.pipe(e),lMe(t,e),uMe(t,e)},lMe=async(t,e)=>{if(!(wi(t)||wi(e))){try{await q7(t,{cleanup:!0,readable:!0,writable:!1})}catch{}zD(e)}},zD=t=>{t.writable&&t.end()},uMe=async(t,e)=>{if(!(wi(t)||wi(e))){try{await q7(e,{cleanup:!0,readable:!1,writable:!0})}catch{}GD(t)}},GD=t=>{t.readable&&t.destroy()};var V7=(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)))dMe(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Yn.has(c)))pMe({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]:Il(o);tf(s,i)}},dMe=(t,e,r,n)=>{r==="output"?tf(t.stdio[n],e):tf(e,t.stdio[n]);let i=fMe[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},fMe=["stdin","stdout","stderr"],pMe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;hMe(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},hMe=(t,{signal:e})=>{wi(t)&&xl(t,mMe,e)},mMe=2;import{addAbortListener as yMe}from"events";var Cl=[];Cl.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Cl.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Cl.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var Dx=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",qD=Symbol.for("signal-exit emitter"),VD=globalThis,gMe=Object.defineProperty.bind(Object),HD=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(VD[qD])return VD[qD];gMe(VD,qD,{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}},Lx=class{},_Me=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),WD=class extends Lx{onExit(){return()=>{}}load(){}unload(){}},YD=class extends Lx{#e=KD.platform==="win32"?"SIGINT":"SIGHUP";#r=new HD;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Cl)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(!Dx(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 Cl)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,Cl.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 Dx(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"&&Dx(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)}},KD=globalThis.process,{onExit:H7,load:Qpt,unload:eht}=_Me(Dx(KD)?new YD(KD):new WD);var W7=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=H7(()=>{t.kill()});yMe(n,()=>{i()})};var K7=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=WT(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=SMe(r,n,i),{sourceStream:d,sourceError:f}=vMe(t,l),{options:p,fileDescriptors:h}=mo.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},SMe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=EMe(t,e,...r),a=nx(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},EMe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Y7,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||UM(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]=$T(r,...n);return{destination:e(Y7)(i,o,s),pipeOptions:s}}if(mo.has(r)){if(Object.keys(t).length>0)throw new TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:r,pipeOptions:n[0]}}throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${r}`)},Y7=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),vMe=(t,e)=>{try{return{sourceStream:Yd(t,e)}}catch(r){return{sourceError:r}}};var J7=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=bMe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw ZD({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},bMe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return GD(t),n;if(e!==void 0)return zD(r),e},ZD=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Xd({error:t,command:Z7,escapedCommand:Z7,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Z7="source.pipe(destination)";var X7=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 TMe}from"stream/promises";var Q7=(t,e,r)=>{let n=$x.has(e)?wMe(t,e):xMe(t,e);return xl(t,RMe,r.signal),xl(e,IMe,r.signal),AMe(e),n},xMe=(t,e)=>{let r=Il([t]);return tf(r,e),$x.set(e,r),r},wMe=(t,e)=>{let r=$x.get(e);return r.add(t),r},AMe=async t=>{try{await TMe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}$x.delete(t)},$x=new WeakMap,RMe=2,IMe=1;import{aborted as CMe}from"util";var eee=(t,e)=>t===void 0?[]:[PMe(t,e)],PMe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await CMe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw ZD({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var Ux=(t,...e)=>{if(Ct(e[0]))return Ux.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=K7(t,...e),i=OMe({...n,destination:r});return i.pipe=Ux.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},OMe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=NMe(t,i);J7({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Q7(e,o,d);return await Promise.race([X7(u),...eee(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},NMe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as FMe}from"timers/promises";import{on as kMe}from"events";import{getDefaultHighWaterMark as MMe}from"stream";var Fx=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return DMe(e,s),ree({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},DMe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},JD=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;LMe(e,s,t);let a=t.readableObjectMode&&!o;return ree({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},LMe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},ree=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=kMe(t,"data",{signal:e.signal,highWaterMark:tee,highWatermark:tee});return $Me({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},XD=MMe(!0),tee=XD,$Me=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=UMe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Rl(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*l_(a)}},UMe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[Cx(t,r,!e),Ix(t,i,!n,{})].filter(Boolean);var nee=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=BMe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([jMe(t),d]);return}let f=CD(c,r),p=JD({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([zMe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},BMe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!Nx({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=JD({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await h7(a,t,r,o)},jMe=async t=>{await FMe(),t.readableFlowing===null&&t.resume()},zMe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await Sx(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await Ex(r,{maxBuffer:o})):await Jd(r,{maxBuffer:o})}catch(a){return iee(hQ({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},QD=async t=>{try{return await t}catch(e){return iee(e)}},iee=({bufferedData:t})=>P9(t)?new Uint8Array(t):t;import{finished as GMe}from"stream/promises";var p_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=qMe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],GMe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||WMe(a,e,r,n)}finally{s.abort()}},qMe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&VMe(t,r,n),n},VMe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{HMe(e,r),n.call(t,...i)}},HMe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},WMe=(t,e,r,n)=>{if(!YMe(t,e,r,n))throw t},YMe=(t,e,r,n=!0)=>r.propagating?oee(t)||Bx(t):(r.propagating=!0,eL(r,e)===n?oee(t):Bx(t)),eL=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",Bx=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",oee=t=>t?.code==="EPIPE";var see=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>tL({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),tL=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=p_(t,e,l);if(eL(l,e)){await u;return}let[d]=await Promise.all([nee({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 aee=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Il([t,e].filter(Boolean)):void 0,cee=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>tL({...KMe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:ZMe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),KMe=({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}},ZMe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as JMe}from"events";var lee=t=>Gd(t,"ipc"),uee=(t,e)=>{let r=HT(t);po({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var dee=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=lee(o),a=gs(e,"ipc"),c=gs(r,"ipc");for await(let l of UD({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(mQ(t,i,c),i.push(l)),s&&uee(l,o);return i},fee=async(t,e)=>(await Promise.allSettled([t]),e);var pee=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:S,controller:E})=>{let T=S7(t,f),x={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:T,propagating:!1},_=see({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:x}),A=cee({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:x}),R=[],P=dee({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:R,verboseInfo:p}),C=XMe(m,t,x),M=QMe(h,x);try{return await Promise.race([Promise.all([{},v7(T),Promise.all(_),A,P,WX(t,d),...C,...M]),S,eDe(t,E),...zX(t,o,f,E),...lX({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:E}),...BX({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:E})])}catch(F){return f.terminationReason??="other",Promise.all([{error:F},T,Promise.all(_.map(y=>QD(y))),QD(A),fee(P,R),Promise.allSettled(C),Promise.allSettled(M)])}},XMe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:p_(n,i,r)),QMe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>Ii(o,{checkOpen:!1})&&!wi(o)).map(({type:i,value:o,stream:s=o})=>p_(s,n,e,{isSameDirection:Yn.has(i),stopOnExit:i==="native"}))),eDe=async(t,{signal:e})=>{let[r]=await JMe(t,"error",{signal:e});throw r};var hee=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),h_=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=ho();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},rf=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 tDe}from"stream";import{callbackify as rDe}from"util";import{finished as mee}from"stream/promises";var rL=async t=>{if(t!==void 0)try{await nL(t)}catch{}},gee=async t=>{if(t!==void 0)try{await iL(t)}catch{}},nL=async t=>{await mee(t,{cleanup:!0,readable:!1,writable:!0})},iL=async t=>{await mee(t,{cleanup:!0,readable:!0,writable:!1})},jx=async(t,e)=>{if(await t,e)throw e},zx=(t,e,r)=>{r&&!Bx(r)?t.destroy(r):e&&t.destroy()};var _ee=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||Sn.has(r),{subprocessStdout:a,waitReadableDestroy:c}=oL(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=sL(a,s),{read:f,onStdoutDataDone:p}=aL({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new tDe({read:f,destroy:rDe(lL.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return cL({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},oL=(t,e,r)=>{let n=Yd(t,e),i=h_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},sL=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:XD},aL=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=ho(),s=Fx({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){nDe(this,s,o)},onStdoutDataDone:o}},nDe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},cL=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await iL(t),await n,await rL(i),await e,r.readable&&r.push(null)}catch(o){await rL(i),yee(r,o)}},lL=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await rf(r,e)&&(yee(t,n),await jx(e,n))},yee=(t,e)=>{zx(t,t.readable,e)};import{Writable as iDe}from"stream";import{callbackify as See}from"util";var Eee=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=uL(t,r,e),s=new iDe({...dL(n,t,i),destroy:See(pL.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return fL(n,s),s},uL=(t,e,r)=>{let n=nx(t,e),i=h_(r,n,"writableFinal"),o=h_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},dL=(t,e,r)=>({write:oDe.bind(void 0,t),final:See(sDe.bind(void 0,t,e,r))}),oDe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},sDe=async(t,e,r)=>{await rf(r,e)&&(t.writable&&t.end(),await e)},fL=async(t,e,r)=>{try{await nL(t),e.writable&&e.end()}catch(n){await gee(r),vee(e,n)}},pL=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await rf(r,e),await rf(n,e)&&(vee(t,i),await jx(e,i))},vee=(t,e)=>{zx(t,t.writable,e)};import{Duplex as aDe}from"stream";import{callbackify as cDe}from"util";var bee=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||Sn.has(r),{subprocessStdout:c,waitReadableDestroy:l}=oL(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=uL(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=sL(c,a),{read:S,onStdoutDataDone:E}=aL({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),T=new aDe({read:S,...dL(u,t,d),destroy:cDe(lDe.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 cL({subprocessStdout:c,onStdoutDataDone:E,readable:T,subprocess:t,subprocessStdin:u}),fL(u,T,c),T},lDe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([lL({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),pL({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var hL=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||Sn.has(e),s=Yd(t,r),a=Fx({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return uDe(a,s,t)},uDe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Tee=(t,{encoding:e})=>{let r=hee();t.readable=_ee.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=Eee.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=bee.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=hL.bind(void 0,t,e),t[Symbol.asyncIterator]=hL.bind(void 0,t,e,{})};var xee=(t,e)=>{for(let[r,n]of fDe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},dDe=(async()=>{})().constructor.prototype,fDe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(dDe,t)]);var wee=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=mDe(t,e,r),{subprocess:f,promise:p}=_De({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=Ux.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),xee(f,p),mo.set(f,{options:u,fileDescriptors:d}),f},mDe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=YT(t,e,r),{file:a,commandArguments:c,options:l}=hx(t,e,r),u=gDe(l),d=L7(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},gDe=({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}},_De=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=hDe(...mx(t,e,r))}catch(h){return N7({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;pDe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];V7(c,a,l),W7(c,r,l);let d={},f=ho();c.kill=aX.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=aee(c,r),Tee(c,r),C7(c,r);let p=yDe({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}},yDe=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,S]=await pee({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let E=h.map((_,A)=>ys(_,e,A)),T=ys(m,e,"all"),x=SDe({errorInfo:d,exitCode:f,signal:p,stdio:E,all:T,ipcOutput:S,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Qd(x,n,e)},SDe=({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?c_({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 go,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):Tx({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var Gx=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,EDe(n,t[n],i)]));return{...t,...r}},EDe=(t,e,r)=>vDe.has(t)&&Ct(e)&&Ct(r)?{...e,...r}:r,vDe=new Set(["env",...qM]);var Ma=(t,e,r,n)=>{let i=(s,a,c)=>Ma(s,a,r,c),o=(...s)=>bDe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},bDe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Ct(o))return i(t,Gx(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=TDe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?T7(a,c,l):wee(a,c,l,i)},TDe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=L9(e)?$9(e,r):[e,...r],[s,a,c]=$T(...o),l=Gx(Gx(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 Aee=({file:t,commandArguments:e})=>Iee(t,e),Ree=({file:t,commandArguments:e})=>({...Iee(t,e),isSync:!0}),Iee=(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]=xDe(t);return{file:r,commandArguments:n}},xDe=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(wDe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},wDe=/ +/g;var Cee=(t,e,r)=>{t.sync=e(ADe,r),t.s=t.sync},Pee=({options:t})=>Oee(t),ADe=({options:t})=>({...Oee(t),isSync:!0}),Oee=t=>({options:{...RDe(t),...t}}),RDe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Nee={preferLocal:!0};var kee=Ma(()=>({})),Ggt=Ma(()=>({isSync:!0})),Mee=Ma(Aee),qgt=Ma(Ree),Vgt=Ma(qX),Hgt=Ma(Pee,{},Nee,Cee),{sendMessage:Wgt,getOneMessage:Ygt,getEachMessage:Kgt,getCancelSignal:Zgt}=P7();var Dee=!1,Lee=()=>{Dee=!0},yo=()=>Dee;var m_=null,$ee=t=>(m_&&m_.destroy(),m_=new Ss({totalAllowedTime:t}),m_),Uee=()=>m_;var Ss=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&&yo())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 PT({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}),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 Fee={name:"@netlify/agent-runner-cli",type:"module",version:"1.145.0-ex-2517.4",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{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.197","@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.3","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.8.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var ODe=CDe(import.meta.url),NDe=Es.dirname(ODe),kDe=PDe(import.meta.url),nf=ye("shell"),mL=new Set,Bee={preferLocal:!0},lr=(t,e,r)=>{let[n,i]=MDe(e,r),o={...Bee,...i},s=kee(t,n,o);zee(s,o),Vee(s);let a=r?.idleTimeout;return a&&a>0&&qee(s,a),s},jee=(t,e)=>{let r={...Bee,...e},n=Mee(t,r);return zee(n,r),Vee(n),e?.idleTimeout&&e.idleTimeout>0&&qee(n,e.idleTimeout),n},MDe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},zee=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(vs.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Vg).pipe(vs.stdout),t.stderr?.pipe(new Vg).pipe(vs.stderr);return}t.stdout?.pipe(vs.stdout),t.stderr?.pipe(vs.stderr)},gL=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(vs.kill(-t.pid,e),nf.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return nf.error("Error killing process:",r),!1}},Gee=t=>gL(t,"SIGKILL"),qee=(t,e)=>{let r=null,n=()=>{nf.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),gL(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(nf.log(`Force killing idle process ${t.pid}`),Gee(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)},Vee=t=>{mL.add(t);let e=Uee();if(e){let r=e.onTimesUp(()=>{nf.log(`Global timer expired, killing process ${t.pid}`),gL(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(nf.log(`Force killing process ${t.pid} after timeout`),Gee(t))},5e3)});t.on("exit",()=>{mL.delete(t),r()}),t.on("error",()=>{mL.delete(t),r()})}};function Vx(t,e){return!!Ci(t,e)}function Ci(t,e){if(!vs.env.NETLIFY_LOCAL_MODE)try{let i=kDe.resolve(Fee.name),o=Es.dirname(i);for(;o!==Es.dirname(o);){let s=Es.dirname(o);if(Es.basename(s)==="node_modules"){let a=Es.join(s,".bin",e);if(qx.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(vs.env.NODE_PATH){let i=Es.join(vs.env.NODE_PATH,".bin",e);if(qx.existsSync(i))return i}let r=Es.join(t,"node_modules",".bin",e);if(qx.existsSync(r))return r;let n=Es.join(NDe,"..","node_modules",".bin",e);if(qx.existsSync(n))return n}var DDe=ye("utils"),LDe=t=>new Promise(e=>{setTimeout(e,t)});var Hx=(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 LDe(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},Da=(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},Hee=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):DDe.error("Could not parse JSON",n))}},$De=t=>t.charAt(0).toUpperCase()+t.slice(1),So=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():$De(e)).join(" ");function bs(t,e){e&&t.log(`Skill invoked: ${e}`)}var Wx=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),Wee=(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}},UDe=1e4,yL=(t,e=UDe)=>{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 Yee}from"buffer";import FDe from"path";var Kee=ye("repo"),Xr=(t,e={})=>lr("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),Yx=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{Kee.info("Getting runner diffs");let n=await jDe(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let m=GDe(o);await qDe(m,r)}Kee.info("Changes after processing"),await EL(r);let s=await vL(o,r);if(await SL(s,r),i=await zDe(r),!i)return{hasChanges:!1,ignored:s};await Xr(["commit","-m","Agent runner"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await Xr(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(i=!!l,!i)return await Zee(r),{hasChanges:!1,ignored:s};let u=await Xr(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,p;if(t.sha){let m=await Xr(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let S=await Xr(["diff",t.sha,"HEAD","--binary"],a),E=String(S.stdout??"");f!==E&&(p=Yee.from(E).toString("base64"))}await Zee(r);let h={hasChanges:!0,diff:l,resultDiff:f,ignored:s};return l!==d&&(h.diffBinary=Yee.from(d).toString("base64")),p&&(h.resultDiffBinary=p),h},Zee=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Xr(["reset","--soft","HEAD~1"],{cwd:t})},SL=async(t=[],e=process.cwd())=>{await Xr(["add",".",...t],{cwd:e})},EL=async(t=process.cwd())=>{let e=await Xr(["status","-s"],{cwd:t});return String(e.stdout??"")},Jee=/.. (.+)?\.log$/,BDe=[Jee],jDe=async(t=process.cwd())=>{let e=await EL(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
103
103
|
`).filter(i=>BDe.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}},zDe=async(t=process.cwd())=>{try{return await Xr(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},g_=async(t=process.cwd())=>{let{stdout:e}=await Xr(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},Xee=async(t=process.cwd())=>{let{stdout:e}=await Xr(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},vL=async(t,e=process.cwd())=>{t||=await EL(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}${FDe.sep}`);(a||c)&&n.push(`:!${s}`)});let o=i.match(Jee)?.[1];o&&n.push(`:!${o}.log`)}),n},bL=async(t=process.cwd())=>{await Xr(["reset","--hard","HEAD"],{cwd:t})},Qee=async(t=process.cwd())=>{let e=await Xr(["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))},GDe=t=>{let e=t.split(`
|
|
@@ -324,7 +324,7 @@ ${s.trim()}
|
|
|
324
324
|
toolName = "web_fetch"
|
|
325
325
|
decision = "allow"
|
|
326
326
|
priority = 10
|
|
327
|
-
`,"utf-8"));let y=[Ci(a,"gemini"),...d?["--model",d]:[],...M?["--approval-mode","default","--policy",F]:["--yolo"],"--skip-trust","--output-format","stream-json",...C?["-r",s]:[],"-p",""],ae=`${fh.env.NVM_BIN}/node`;rr.log(`Running ${ae} ${y.join(" ")}`);let O=e.utils.run(ae,y,{all:!0,env:fh.env,cwd:a,idleTimeout:hs,cancelSignal:c});O.stdin?.end(u);let g=Da(()=>{r?.({steps:f,duration:E}),n?.({steps:p,duration:E}),p=[]},250),v=(Ce,V)=>{Ce.id=S,S+=1,h.push(Ce),f.push(Ce),p.push(Ce),V||g.flush(),g(),V&&g.flush()};v({title:`Using ${ej} with ${d||"default"}`,category:Y.Environment},!0);let W=zBe.createInterface({input:O.all});W.on("error",Ce=>{rr.error("Readline interface error",{error:Ce.message,stack:Ce.stack})});let G="",ce=()=>{G&&v({message:G.trim(),category:Y.AgentMessage}),G=""};W.on("line",Ce=>{let V;try{if(Ce.startsWith("[API Error")){let De=Ce.match(/\[api error: (.+?)]$/i)?.[1];V={type:"error",value:Hee(De,!1)?.error?.message||De||"Gemini encountered error"}}else V=JSON.parse(Ce)}catch{return}if(V)switch(V.type==="init"&&typeof V.session_id=="string"&&(A=V.session_id,l?.(A)),["message","result"].includes(V.type)||ce(),V.type){case"message":{V.role!=="user"&&V.content&&(G+=V.content);break}case"tool_use":{if(V.tool_name===qte){if(rr.info("Gemini ask came in"),V.tool_id&&!R){rr.info("About to parse");let L=pp.safeParse(V.parameters);L.success?(rr.info("Parse successful"),R={questions:L.data.questions,toolUseId:V.tool_id},rr.info("trying to kill process"),O.kill()):(rr.warn("Ignoring malformed ask tool input",{toolUseId:V.tool_id}),fe.inc("inference.malformed_ask",1))}break}let De=Q2[V.tool_name]?.name??V.tool_name,be=V.parameters?.file_path,ee=be&&bc.relative(a,be),ie=V.parameters?.command,Re=V.tool_name==="activate_skill"&&V.parameters?.name,te=V.tool_name==="run_shell_command"&&ks(ie),Ae=[De,ee&&`\`${ee}\``,ie&&`\`${ie}\``].filter(Boolean).join(" ");if(Re)Ae=`Use ${So(Re)}`;else if(te)Ae="Generating the site";else if(V.tool_name==="grep_search"){let{dir_path:L,pattern:D}=V.parameters||{};L&&D?Ae=`Search in \`${L}\` for \`${D}\``:L?Ae=`Search in \`${L}\``:D&&(Ae=`Search for \`${D}\``)}else if(V.tool_name==="update_topic"){let L=V.parameters?.title;L&&(Ae=`${De} \`${L}\``)}let K={title:Ae,category:te?Y.SiteGeneration:Q2[V.tool_name]?.category,...Re&&{type:Re}};m[V.tool_id]=K,g.flush();break}case"tool_result":{let De=m[V.tool_id];De&&(V.output&&(De.message=`\`\`\`
|
|
327
|
+
`,"utf-8"));let y=[Ci(a,"gemini"),...d?["--model",d]:[],...M?["--approval-mode","default","--policy",F]:["--yolo"],"--skip-trust","--output-format","stream-json",...C?["-r",s]:[],"-p",""],ae=`${fh.env.NVM_BIN}/node`;rr.log(`Running ${ae} ${y.join(" ")}`);let O=e.utils.run(ae,y,{all:!0,env:{...fh.env,GEMINI_CLI_NO_RELAUNCH:"1"},cwd:a,idleTimeout:hs,cancelSignal:c});O.stdin?.end(u);let g=Da(()=>{r?.({steps:f,duration:E}),n?.({steps:p,duration:E}),p=[]},250),v=(Ce,V)=>{Ce.id=S,S+=1,h.push(Ce),f.push(Ce),p.push(Ce),V||g.flush(),g(),V&&g.flush()};v({title:`Using ${ej} with ${d||"default"}`,category:Y.Environment},!0);let W=zBe.createInterface({input:O.all});W.on("error",Ce=>{rr.error("Readline interface error",{error:Ce.message,stack:Ce.stack})});let G="",ce=()=>{G&&v({message:G.trim(),category:Y.AgentMessage}),G=""};W.on("line",Ce=>{let V;try{if(Ce.startsWith("[API Error")){let De=Ce.match(/\[api error: (.+?)]$/i)?.[1];V={type:"error",value:Hee(De,!1)?.error?.message||De||"Gemini encountered error"}}else V=JSON.parse(Ce)}catch{return}if(V)switch(V.type==="init"&&typeof V.session_id=="string"&&(A=V.session_id,l?.(A)),["message","result"].includes(V.type)||ce(),V.type){case"message":{V.role!=="user"&&V.content&&(G+=V.content);break}case"tool_use":{if(V.tool_name===qte){if(rr.info("Gemini ask came in"),V.tool_id&&!R){rr.info("About to parse");let L=pp.safeParse(V.parameters);L.success?(rr.info("Parse successful"),R={questions:L.data.questions,toolUseId:V.tool_id},rr.info("trying to kill process"),O.kill()):(rr.warn("Ignoring malformed ask tool input",{toolUseId:V.tool_id}),fe.inc("inference.malformed_ask",1))}break}let De=Q2[V.tool_name]?.name??V.tool_name,be=V.parameters?.file_path,ee=be&&bc.relative(a,be),ie=V.parameters?.command,Re=V.tool_name==="activate_skill"&&V.parameters?.name,te=V.tool_name==="run_shell_command"&&ks(ie),Ae=[De,ee&&`\`${ee}\``,ie&&`\`${ie}\``].filter(Boolean).join(" ");if(Re)Ae=`Use ${So(Re)}`;else if(te)Ae="Generating the site";else if(V.tool_name==="grep_search"){let{dir_path:L,pattern:D}=V.parameters||{};L&&D?Ae=`Search in \`${L}\` for \`${D}\``:L?Ae=`Search in \`${L}\``:D&&(Ae=`Search for \`${D}\``)}else if(V.tool_name==="update_topic"){let L=V.parameters?.title;L&&(Ae=`${De} \`${L}\``)}let K={title:Ae,category:te?Y.SiteGeneration:Q2[V.tool_name]?.category,...Re&&{type:Re}};m[V.tool_id]=K,g.flush();break}case"tool_result":{let De=m[V.tool_id];De&&(V.output&&(De.message=`\`\`\`
|
|
328
328
|
${V.output.trim()}
|
|
329
329
|
\`\`\``),v(De,!0),VBe(De));break}case"result":{E=V.stats?.duration_ms,V.stats&&(uo(V.stats),_=V.stats),V.status==="error"?x=V.error?.message:T=G.trim();break}case"error":{x=V.error;break}case"finished":break;case"init":break;default:{rr.warn("Unhandled message type:",V.type);break}}});let Te=!1;if(await O.catch(Ce=>{Te=Mf(Ce,c),{error:x,result:T}=GBe({catchError:Ce,runCmd:O,error:x,result:T,runnerName:"Gemini"})}),W.close(),R)return g.flush(),{steps:h,duration:E,agentSessionId:A,resolvedModel:d,usage:_,pendingInteraction:R};let we=Te;return we&&(!T&&G.trim()&&(T=G.trim()),x=void 0),g.flush(),{steps:h,duration:E,result:await ec({initialResult:T,agentName:ej,hasError:!!x}),error:tc({error:x,agentName:ej}),isRetryableError:rc(x),isProviderUnavailableError:nc(x),resolvedModel:d,usage:_,agentSessionId:A,...we?{aborted:!0}:{}}}var gse=async()=>{let t=bc.join(Wy.homedir(),".gemini");await vu.rm(t,{recursive:!0,force:!0});let e=bc.join(Wy.homedir(),".agents","skills");await vu.rm(e,{recursive:!0,force:!0})},_se={baseDir:bc.join(Wy.homedir(),".gemini"),include:["tmp"]};import ZBe from"fs/promises";import bse from"os";import nj from"path";import qR from"process";import JBe from"readline";import YBe from"os";import Ese from"path";import rj from"fs";var yse=ye("opencode_install"),Sse="1.17.19",KBe=()=>Ese.join(YBe.homedir(),".netlify-agent-runner","opencode"),vse=async t=>{let e=Ci(t,"opencode");if(e)return e;let r=KBe(),n=Ese.join(r,"node_modules",".bin","opencode");if(rj.existsSync(n))return n;rj.mkdirSync(r,{recursive:!0}),yse.log(`Installing opencode-ai@${Sse} on demand`);let i=Date.now();await lr("npm",["install","--no-save","--no-audit","--no-fund","--prefix",r,`opencode-ai@${Sse}`],{cwd:r});let o=Date.now()-i;if(fe.timing("opencode.install_duration",o),yse.log(`Installed opencode-ai in ${o}ms`),!rj.existsSync(n))throw new Error("OpenCode CLI binary not found after installing opencode-ai");return n};var qs=ye("runner_opencode"),GR="OpenCode",Tse="gateway",XBe="z-ai/glm-5.2",xse={bash:{name:"Run command",category:Y.RunCommand},read:{name:"Read file",category:Y.FileRead},write:{name:"Edit file",category:Y.FileWrite},edit:{name:"Edit file",category:Y.FileWrite},glob:{name:"Find files",category:Y.Explore},grep:{name:"Search files",category:Y.Explore},list:{name:"List directory",category:Y.Explore},task:{name:"Task",category:Y.Task},todowrite:{name:"Update task list",category:Y.Todo},webfetch:{name:"Fetch web",category:Y.Web},websearch:{name:"Search web",category:Y.Web},skill:{name:"Use Skill",category:Y.Skill}},QBe=t=>xse[t]?.name||t,e2e=({catchError:t,runCmd:e,error:r,result:n,runnerName:i})=>(qs.log(`${i} command completed with catch handler triggered`,{hadExistingError:!!r,hadExistingResult:!!n,resultLength:n?n.length:0,catchError:t?.message||"No error object",processExitCode:e.exitCode,processKilled:e.killed}),n?(qs.log("Preserving existing result despite catch handler being triggered"),r?{error:r,result:n}:{error:"Process completed with errors but result was captured",result:n}):(qs.log("Setting result to undefined because no valid result was captured"),{error:r||`${i} failed`,result:void 0}));async function t2e({aiGateway:t,config:e,model:r}){let n=r;if(t){let i=t.isModelAvailable;if(!i)throw new Error("OpenCode runner requires a gateway with isModelAvailable support");let o=e.modelVersionOverrides?.opencode?.[e.accountType];o?n=o:r||(n=We().opencodeDefaultModel||XBe),n&&(await i(n)||qs.log(`Model '${n}' not found in gateway catalog; proceeding anyway (gateway is authoritative, e.g. flag-gated OpenRouter models)`))}return n}function r2e({aiGateway:t,model:e}){if(!t)throw new Error("OpenCode runner requires the AI gateway");let{token:r,url:n}=t;if(!r||!n)throw new Error("No token or url provided from AI Gateway");let i=e?{[e]:{id:e,name:e,tool_call:!0,reasoning:!0,interleaved:{field:"reasoning_details"}}}:{},o={$schema:"https://opencode.ai/config.json",provider:{[Tse]:{api:"openai",name:"Netlify AI Gateway",options:{apiKey:r,baseURL:n},...Object.keys(i).length>0?{models:i}:{}}}};qR.env.OPENCODE_CONFIG_CONTENT=JSON.stringify(o),qR.env.OPENCODE_DISABLE_AUTOUPDATE="1"}async function ij({config:t,netlify:e,persistSteps:r,aiGateway:n,continueSession:i,priorAgentSessionId:o,cwd:s=qR.cwd()}){let{prompt:a}=t,{model:c}=t,l="",u,d,f,p=await t2e({config:t,aiGateway:n,model:c});r2e({aiGateway:n,model:p});let h=[],m=0,S=Date.now(),E=await vse(s),T=["run","--format","json","--dangerously-skip-permissions","--agent","build",...p?["--model",`${Tse}/${p}`]:[],...i?o?["--session",o]:["--continue"]:[]];qs.log(`Running ${E} ${T.join(" ")}`);let x=e.utils.run(E,T,{all:!0,env:qR.env,cwd:s,idleTimeout:hs});x.stdin?.end(a);let _=Da(()=>{r?.({steps:h,duration:Date.now()-S})},250),A=(O,g)=>{let{wrapMessage:v,...w}=O,W=Wx({...w,id:m});W.message&&v&&(W.message=`\`\`\`
|
|
330
330
|
${W.message}
|
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:T6},Nmt=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},kmt={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:Nmt};import{Buffer as $mt}from"buffer";var Kve=(t,e)=>t?void 0:Lmt.bind(void 0,e),Lmt=function*(t,e){if(typeof e!="string"&&!Pr(e)&&!$mt.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},Jve=(t,e)=>t?Dmt.bind(void 0,e):Mmt.bind(void 0,e),Dmt=function*(t,e){Zve(t,e),yield e},Mmt=function*(t,e){if(Zve(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},Zve=(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 Umt}from"buffer";import{StringDecoder as Fmt}from"string_decoder";var ZO=(t,e,r)=>{if(r)return;if(t)return{transform:jmt.bind(void 0,new TextEncoder)};let n=new Fmt(e);return{transform:qmt.bind(void 0,n),final:Bmt.bind(void 0,n)}},jmt=function*(t,e){Umt.isBuffer(e)?yield Ec(e):typeof e=="string"?yield t.encode(e):yield e},qmt=function*(t,e){yield Pr(e)?t.write(e):e},Bmt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Xve}from"util";var R6=Xve(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),XO=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Vmt}=e[r];for await(let i of n(t))yield*XO(i,e,r+1)},Qve=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*zmt(r,Number(e),t)},zmt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*XO(n,r,e+1)},ebe=Xve(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),Vmt=function*(t){yield t};var A6=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},tbe=(t,e)=>[...e.flatMap(r=>[...Uf(r,t,0)]),...Ob(t)],Uf=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Gmt}=e[r];for(let i of n(t))yield*Uf(i,e,r+1)},Ob=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Hmt(r,Number(e),t)},Hmt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Uf(n,r,e+1)},Gmt=function*(t){yield t};var x6=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=nbe(t,o,s),l=Mf(e),u=Mf(r),d=l?R6.bind(void 0,XO,a):A6.bind(void 0,Uf),f=l||u?R6.bind(void 0,Qve,a):A6.bind(void 0,Ob),p=l||u?ebe.bind(void 0,a):void 0;return{stream:new Wmt({writableObjectMode:n,writableHighWaterMark:rbe(n),readableObjectMode:i,readableHighWaterMark:rbe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},QO=(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=nbe(o,r,a);t=tbe(c,t)}return t},nbe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:Kve(n,a)},ZO(r,o,n),JO(r,s,n,c),{transform:t,final:e},{transform:Jve(i,a)},Yve({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var ibe=(t,e)=>{for(let r of Ymt(t))Kmt(t,r,e)},Ymt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Kmt=(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 ${vu[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>Jmt(a,n));r.input=Eb(o)},Jmt=(t,e)=>{let r=QO(t,e,"utf8",!0);return Zmt(r),Eb(r)},Zmt=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 tgt,appendFileSync as rgt}from"fs";var eC=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Ig(r,n)&&!Di.has(e)&&Xmt(n)&&(t.some(({type:i,value:s})=>i==="native"&&Qmt.has(s))||t.every(({type:i})=>vs.has(i))),Xmt=t=>t===1||t===2,Qmt=new Set(["pipe","overlapped"]),sbe=async(t,e,r,n)=>{for await(let i of t)egt(e)||abe(i,r,n)},obe=(t,e,r)=>{for(let n of t)abe(n,e,r)},egt=t=>t._readableState.pipes.length>0,abe=(t,e,r)=>{let n=hO(t);ta({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var cbe=({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)=>ngt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},ngt=({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=lve(t,s,d),p=Ec(f),{stdioItems:h,objectMode:m}=e[r],_=igt([p],h,c,n),{serializedResult:y,finalResult:v=y}=sgt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});ogt({serializedResult:y,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let S=a[r]?v:void 0;try{return n.error===void 0&&agt(y,h,i),S}catch(g){return n.error=g,S}},igt=(t,e,r,n)=>{try{return QO(t,e,r,!1)}catch(i){return n.error=i,t}},sgt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Eb(t)};let o=Tye(t,r);return n[s]?{serializedResult:o,finalResult:w6(o,!i[s],e)}:{serializedResult:o}},ogt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!eC({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=w6(t,!1,o);try{obe(a,e,n)}catch(c){r.error??=c}},agt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>YO.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?rgt(n,t):(r.add(s),tgt(n,t))}};var lbe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Tc(e,r,"all")]:Array.isArray(e)?[Tc(t,r,"all"),...e]:Pr(t)&&Pr(e)?kG([t,e]):`${t}${e}`};import{once as I6}from"events";var ube=async(t,e)=>{let[r,n]=await cgt(t);return e.isForcefullyTerminated??=!1,[r,n]},cgt=async t=>{let[e,r]=await Promise.allSettled([I6(t,"spawn"),I6(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?dbe(t):r.value},dbe=async t=>{try{return await I6(t,"exit")}catch{return dbe(t)}},fbe=async t=>{let[e,r]=await t;if(!lgt(e,r)&&P6(e,r))throw new Xs;return[e,r]},lgt=(t,e)=>t===void 0&&e===void 0,P6=(t,e)=>t!==0||e!==null;var pbe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=ugt(t,e,r),o=s?.code==="ETIMEDOUT",a=cve(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},ugt=(t,e,r)=>t!==void 0?t:P6(e,r)?new Xs:void 0;var hbe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=fgt(t,e,r),d=mgt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Ug(d,c,l)},fgt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=gO(t,e,r),a=pgt(r),{file:c,commandArguments:l,options:u}=DO(t,e,a);hgt(u);let d=Vve(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},pgt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,hgt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&tC("ipcInput"),t&&tC("ipc: true"),r&&tC("detached: true"),n&&tC("cancelSignal")},tC=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},mgt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=ggt({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}=pbe(c,r),{output:h,error:m=l}=cbe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((v,S)=>Tc(v,r,S)),y=Tc(lbe(h,r),r,"all");return ygt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},ggt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{ibe(s,r);let a=_gt(r);return dgt(...MO(t,e,a))}catch(a){return Mg({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},_gt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:VO(e)}),ygt=({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?HO({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):Pb({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 syt}from"events";import{spawn as oyt}from"child_process";import Sbe from"process";import{once as O6,on as Sgt}from"events";var mbe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(Cg({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:OO(t)}),Egt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),Egt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{AO(e,i);let s=Eu(t,e,r),o=new AbortController;try{return await Promise.race([vgt(s,n,o),bgt(s,r,o),Tgt(s,r,o)])}catch(a){throw Ng(t),a}finally{o.abort(),xO(e,i)}},vgt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await O6(t,"message",{signal:r});return n}for await(let[n]of Sgt(t,"message",{signal:r}))if(e(n))return n},bgt=async(t,e,{signal:r})=>{await O6(t,"disconnect",{signal:r}),tEe(e)},Tgt=async(t,e,{signal:r})=>{let[n]=await O6(t,"strict:error",{signal:r});throw TO(n,e)};import{once as _be,on as wgt}from"events";var ybe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>C6({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),C6=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{Cg({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:OO(t)}),AO(e,s);let o=Eu(t,e,r),a=new AbortController,c={};return Rgt(t,o,a),Agt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),xgt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},Rgt=async(t,e,r)=>{try{await _be(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Agt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await _be(t,"strict:error",{signal:r.signal});n.error=TO(i,e),r.abort()}catch{}},xgt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of wgt(r,"message",{signal:s.signal}))gbe(o),yield c}catch{gbe(o)}finally{s.abort(),xO(e,a),n||Ng(t),i&&await t}},gbe=({error:t})=>{if(t)throw t};var Ebe=(t,{ipc:e})=>{Object.assign(t,bbe(t,!1,e))},vbe=()=>{let t=Sbe,e=!0,r=Sbe.channel!==void 0;return{...bbe(t,e,r),getCancelSignal:IEe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},bbe=(t,e,r)=>({sendMessage:$O.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:mbe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:ybe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Igt}from"child_process";import{PassThrough as Pgt,Readable as Ogt,Writable as Cgt,Duplex as Ngt}from"stream";var Tbe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{v6(n);let a=new Igt;kgt(a,n),Object.assign(a,{readable:$gt,writable:Lgt,duplex:Dgt});let c=Mg({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=Mgt(c,o,i);return{subprocess:a,promise:l}},kgt=(t,e)=>{let r=Cb(),n=Cb(),i=Cb(),s=Array.from({length:e.length-3},Cb),o=Cb(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},Cb=()=>{let t=new Pgt;return t.end(),t},$gt=()=>new Ogt({read(){}}),Lgt=()=>new Cgt({write(){}}),Dgt=()=>new Ngt({read(){},write(){}}),Mgt=async(t,e,r)=>Ug(t,e,r);import{createReadStream as wbe,createWriteStream as Rbe}from"fs";import{Buffer as Ugt}from"buffer";import{Readable as Nb,Writable as Fgt,Duplex as jgt}from"stream";var xbe=(t,e)=>KO(qgt,t,e,!1),kb=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${vu[t]}.`)},Abe={fileNumber:kb,generator:x6,asyncGenerator:x6,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:jgt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},qgt={input:{...Abe,fileUrl:({value:t})=>({stream:wbe(t)}),filePath:({value:{file:t}})=>({stream:wbe(t)}),webStream:({value:t})=>({stream:Nb.fromWeb(t)}),iterable:({value:t})=>({stream:Nb.from(t)}),asyncIterable:({value:t})=>({stream:Nb.from(t)}),string:({value:t})=>({stream:Nb.from(t)}),uint8Array:({value:t})=>({stream:Nb.from(Ugt.from(t))})},output:{...Abe,fileUrl:({value:t})=>({stream:Rbe(t)}),filePath:({value:{file:t,append:e}})=>({stream:Rbe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Fgt.fromWeb(t)}),iterable:kb,asyncIterable:kb,string:kb,uint8Array:kb}};import{on as Bgt,once as Ibe}from"events";import{PassThrough as zgt,getDefaultHighWaterMark as Vgt}from"stream";import{finished as Cbe}from"stream/promises";function Ff(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)k6(i);let e=t.some(({readableObjectMode:i})=>i),r=Hgt(t,e),n=new N6({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Hgt=(t,e)=>{if(t.length===0)return Vgt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},N6=class extends zgt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(k6(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Ggt(this,this.#e,this.#s);let r=Kgt({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(k6(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)}},Ggt=async(t,e,r)=>{rC(t,Pbe);let n=new AbortController;try{await Promise.race([Wgt(t,n),Ygt(t,e,r,n)])}finally{n.abort(),rC(t,-Pbe)}},Wgt=async(t,{signal:e})=>{try{await Cbe(t,{signal:e,cleanup:!0})}catch(r){throw Nbe(t,r),r}},Ygt=async(t,e,r,{signal:n})=>{for await(let[i]of Bgt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},k6=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Kgt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{rC(t,Obe);let a=new AbortController;try{await Promise.race([Jgt(s,e,a),Zgt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),Xgt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),rC(t,-Obe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?$6(t):Qgt(t))},Jgt=async(t,e,{signal:r})=>{try{await t,r.aborted||$6(e)}catch(n){r.aborted||Nbe(e,n)}},Zgt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await Cbe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;kbe(o)?i.add(e):$be(t,o)}},Xgt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await Ibe(t,i,{signal:s}),!t.readable)return Ibe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},Qgt=t=>{t.writable&&t.end()},Nbe=(t,e)=>{kbe(e)?$6(t):$be(t,e)},kbe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",$6=t=>{(t.readable||t.writable)&&t.destroy()},$be=(t,e)=>{t.destroyed||(t.once("error",e_t),t.destroy(e))},e_t=()=>{},rC=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Pbe=2,Obe=1;import{finished as Lbe}from"stream/promises";var jg=(t,e)=>{t.pipe(e),t_t(t,e),r_t(t,e)},t_t=async(t,e)=>{if(!(Zs(t)||Zs(e))){try{await Lbe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}L6(e)}},L6=t=>{t.writable&&t.end()},r_t=async(t,e)=>{if(!(Zs(t)||Zs(e))){try{await Lbe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}D6(t)}},D6=t=>{t.readable&&t.destroy()};var Dbe=(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})=>vs.has(c)))n_t(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!vs.has(c)))s_t({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]:Ff(s);jg(o,i)}},n_t=(t,e,r,n)=>{r==="output"?jg(t.stdio[n],e):jg(e,t.stdio[n]);let i=i_t[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},i_t=["stdin","stdout","stderr"],s_t=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;o_t(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},o_t=(t,{signal:e})=>{Zs(t)&&Lf(t,a_t,e)},a_t=2;import{addAbortListener as u_t}from"events";var jf=[];jf.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&jf.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&jf.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var nC=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",M6=Symbol.for("signal-exit emitter"),U6=globalThis,c_t=Object.defineProperty.bind(Object),F6=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(U6[M6])return U6[M6];c_t(U6,M6,{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}},iC=class{},l_t=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),j6=class extends iC{onExit(){return()=>{}}load(){}unload(){}},q6=class extends iC{#e=B6.platform==="win32"?"SIGINT":"SIGHUP";#r=new F6;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of jf)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,s=e;if(typeof s.__signal_exit_emitter__=="object"&&typeof s.__signal_exit_emitter__.count=="number"&&(i+=s.__signal_exit_emitter__.count),n.length===i){this.unload();let o=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;o||e.kill(e.pid,a)}};this.#s=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!nC(this.#t))return()=>{};this.#o===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#r.on(n,e),()=>{this.#r.removeListener(n,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#o){this.#o=!0,this.#r.count+=1;for(let e of jf)try{let r=this.#i[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#o&&(this.#o=!1,jf.forEach(e=>{let r=this.#i[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#s,this.#r.count-=1)}#a(e){return nC(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"&&nC(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)}},B6=globalThis.process,{onExit:Mbe,load:Oir,unload:Cir}=l_t(nC(B6)?new q6(B6):new j6);var Ube=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Mbe(()=>{t.kill()});u_t(n,()=>{i()})};var jbe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=mO(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=d_t(r,n,i),{sourceStream:d,sourceError:f}=p_t(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}},d_t=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=f_t(t,e,...r),a=RO(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},f_t=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Fbe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||CG(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]=sO(r,...n);return{destination:e(Fbe)(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}`)},Fbe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),p_t=(t,e)=>{try{return{sourceStream:kg(t,e)}}catch(r){return{sourceError:r}}};var Bbe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=h_t({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw z6({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},h_t=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return D6(t),n;if(e!==void 0)return L6(r),e},z6=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Mg({error:t,command:qbe,escapedCommand:qbe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),qbe="source.pipe(destination)";var zbe=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 m_t}from"stream/promises";var Vbe=(t,e,r)=>{let n=sC.has(e)?__t(t,e):g_t(t,e);return Lf(t,S_t,r.signal),Lf(e,E_t,r.signal),y_t(e),n},g_t=(t,e)=>{let r=Ff([t]);return jg(r,e),sC.set(e,r),r},__t=(t,e)=>{let r=sC.get(e);return r.add(t),r},y_t=async t=>{try{await m_t(t,{cleanup:!0,readable:!1,writable:!0})}catch{}sC.delete(t)},sC=new WeakMap,S_t=2,E_t=1;import{aborted as v_t}from"util";var Hbe=(t,e)=>t===void 0?[]:[b_t(t,e)],b_t=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await v_t(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw z6({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var oC=(t,...e)=>{if(yr(e[0]))return oC.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=jbe(t,...e),i=T_t({...n,destination:r});return i.pipe=oC.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},T_t=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=w_t(t,i);Bbe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Vbe(e,s,d);return await Promise.race([zbe(u),...Hbe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},w_t=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as C_t}from"timers/promises";import{on as R_t}from"events";import{getDefaultHighWaterMark as A_t}from"stream";var aC=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return x_t(e,o),Wbe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},x_t=async(t,e)=>{try{await t}catch{}finally{e.abort()}},V6=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;I_t(e,o,t);let a=t.readableObjectMode&&!s;return Wbe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},I_t=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Wbe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=R_t(t,"data",{signal:e.signal,highWaterMark:Gbe,highWatermark:Gbe});return P_t({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},H6=A_t(!0),Gbe=H6,P_t=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=O_t({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Uf(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Ob(a)}},O_t=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[ZO(t,r,!e),JO(t,i,!n,{})].filter(Boolean);var Ybe=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=N_t({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([k_t(t),d]);return}let f=b6(c,r),p=V6({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([$_t({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},N_t=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!eC({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=V6({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await sbe(a,t,r,s)},k_t=async t=>{await C_t(),t.readableFlowing===null&&t.resume()},$_t=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await qO(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await BO(r,{maxBuffer:s})):await Dg(r,{maxBuffer:s})}catch(a){return Kbe(sve({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},G6=async t=>{try{return await t}catch(e){return Kbe(e)}},Kbe=({bufferedData:t})=>vye(t)?new Uint8Array(t):t;import{finished as L_t}from"stream/promises";var $b=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=D_t(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],L_t(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||F_t(a,e,r,n)}finally{o.abort()}},D_t=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&M_t(t,r,n),n},M_t=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{U_t(e,r),n.call(t,...i)}},U_t=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},F_t=(t,e,r,n)=>{if(!j_t(t,e,r,n))throw t},j_t=(t,e,r,n=!0)=>r.propagating?Jbe(t)||cC(t):(r.propagating=!0,W6(r,e)===n?Jbe(t):cC(t)),W6=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",cC=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Jbe=t=>t?.code==="EPIPE";var Zbe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>Y6({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),Y6=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=$b(t,e,l);if(W6(l,e)){await u;return}let[d]=await Promise.all([Ybe({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 Xbe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Ff([t,e].filter(Boolean)):void 0,Qbe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>Y6({...q_t(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:B_t(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),q_t=({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}},B_t=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as z_t}from"events";var eTe=t=>Ig(t,"ipc"),tTe=(t,e)=>{let r=hO(t);ta({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var rTe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=eTe(s),a=vc(e,"ipc"),c=vc(r,"ipc");for await(let l of C6({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(ove(t,i,c),i.push(l)),o&&tTe(l,s);return i},nTe=async(t,e)=>(await Promise.allSettled([t]),e);var iTe=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 v=ube(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},g=Zbe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),w=Qbe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),P=[],x=rTe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:P,verboseInfo:p}),R=V_t(m,t,S),O=H_t(h,S);try{return await Promise.race([Promise.all([{},fbe(v),Promise.all(g),w,x,UEe(t,d),...R,...O]),_,G_t(t,y),...kEe(t,s,f,y),...eEe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...CEe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(A){return f.terminationReason??="other",Promise.all([{error:A},v,Promise.all(g.map(b=>G6(b))),G6(w),nTe(x,P),Promise.allSettled(R),Promise.allSettled(O)])}},V_t=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:$b(n,i,r)),H_t=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>eo(s,{checkOpen:!1})&&!Zs(s)).map(({type:i,value:s,stream:o=s})=>$b(o,n,e,{isSameDirection:vs.has(i),stopOnExit:i==="native"}))),G_t=async(t,{signal:e})=>{let[r]=await z_t(t,"error",{signal:e});throw r};var sTe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),Lb=(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}},qg=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 W_t}from"stream";import{callbackify as Y_t}from"util";import{finished as oTe}from"stream/promises";var K6=async t=>{if(t!==void 0)try{await J6(t)}catch{}},aTe=async t=>{if(t!==void 0)try{await Z6(t)}catch{}},J6=async t=>{await oTe(t,{cleanup:!0,readable:!1,writable:!0})},Z6=async t=>{await oTe(t,{cleanup:!0,readable:!0,writable:!1})},lC=async(t,e)=>{if(await t,e)throw e},uC=(t,e,r)=>{r&&!cC(r)?t.destroy(r):e&&t.destroy()};var cTe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||Di.has(r),{subprocessStdout:a,waitReadableDestroy:c}=X6(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=Q6(a,o),{read:f,onStdoutDataDone:p}=e3({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new W_t({read:f,destroy:Y_t(r3.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return t3({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},X6=(t,e,r)=>{let n=kg(t,e),i=Lb(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},Q6=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:H6},e3=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=ra(),o=aC({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){K_t(this,o,s)},onStdoutDataDone:s}},K_t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},t3=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await Z6(t),await n,await K6(i),await e,r.readable&&r.push(null)}catch(s){await K6(i),lTe(r,s)}},r3=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await qg(r,e)&&(lTe(t,n),await lC(e,n))},lTe=(t,e)=>{uC(t,t.readable,e)};import{Writable as J_t}from"stream";import{callbackify as uTe}from"util";var dTe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=n3(t,r,e),o=new J_t({...i3(n,t,i),destroy:uTe(o3.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return s3(n,o),o},n3=(t,e,r)=>{let n=RO(t,e),i=Lb(r,n,"writableFinal"),s=Lb(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},i3=(t,e,r)=>({write:Z_t.bind(void 0,t),final:uTe(X_t.bind(void 0,t,e,r))}),Z_t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},X_t=async(t,e,r)=>{await qg(r,e)&&(t.writable&&t.end(),await e)},s3=async(t,e,r)=>{try{await J6(t),e.writable&&e.end()}catch(n){await aTe(r),fTe(e,n)}},o3=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await qg(r,e),await qg(n,e)&&(fTe(t,i),await lC(e,i))},fTe=(t,e)=>{uC(t,t.writable,e)};import{Duplex as Q_t}from"stream";import{callbackify as eyt}from"util";var pTe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||Di.has(r),{subprocessStdout:c,waitReadableDestroy:l}=X6(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=n3(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=Q6(c,a),{read:_,onStdoutDataDone:y}=e3({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),v=new Q_t({read:_,...i3(u,t,d),destroy:eyt(tyt.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 t3({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:u}),s3(u,v,c),v},tyt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([r3({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),o3({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var a3=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||Di.has(e),o=kg(t,r),a=aC({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return ryt(a,o,t)},ryt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var hTe=(t,{encoding:e})=>{let r=sTe();t.readable=cTe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=dTe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=pTe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=a3.bind(void 0,t,e),t[Symbol.asyncIterator]=a3.bind(void 0,t,e,{})};var mTe=(t,e)=>{for(let[r,n]of iyt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},nyt=(async()=>{})().constructor.prototype,iyt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(nyt,t)]);var gTe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=ayt(t,e,r),{subprocess:f,promise:p}=lyt({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=oC.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),mTe(f,p),na.set(f,{options:u,fileDescriptors:d}),f},ayt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=gO(t,e,r),{file:a,commandArguments:c,options:l}=DO(t,e,r),u=cyt(l),d=xbe(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},cyt=({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}},lyt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=oyt(...MO(t,e,r))}catch(h){return Tbe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;syt(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];Dbe(c,a,l),Ube(c,r,l);let d={},f=ra();c.kill=XSe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Xbe(c,r),hTe(c,r),Ebe(c,r);let p=uyt({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}},uyt=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 iTe({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)=>Tc(g,e,w)),v=Tc(m,e,"all"),S=dyt({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Ug(S,n,e)},dyt=({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?Pb({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}):HO({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var dC=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,fyt(n,t[n],i)]));return{...t,...r}},fyt=(t,e,r)=>pyt.has(t)&&yr(e)&&yr(r)?{...e,...r}:r,pyt=new Set(["env",...MG]);var bu=(t,e,r,n)=>{let i=(o,a,c)=>bu(o,a,r,c),s=(...o)=>hyt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},hyt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(yr(s))return i(t,dC(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=myt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?hbe(a,c,l):gTe(a,c,l,i)},myt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=xye(e)?Iye(e,r):[e,...r],[o,a,c]=sO(...s),l=dC(dC(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 _Te=({file:t,commandArguments:e})=>STe(t,e),yTe=({file:t,commandArguments:e})=>({...STe(t,e),isSync:!0}),STe=(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]=gyt(t);return{file:r,commandArguments:n}},gyt=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(_yt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},_yt=/ +/g;var ETe=(t,e,r)=>{t.sync=e(yyt,r),t.s=t.sync},vTe=({options:t})=>bTe(t),yyt=({options:t})=>({...bTe(t),isSync:!0}),bTe=t=>({options:{...Syt(t),...t}}),Syt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},TTe={preferLocal:!0};var wTe=bu(()=>({})),bar=bu(()=>({isSync:!0})),RTe=bu(_Te),Tar=bu(yTe),war=bu(LEe),Rar=bu(vTe,{},TTe,ETe),{sendMessage:Aar,getOneMessage:xar,getEachMessage:Iar,getCancelSignal:Par}=vbe();import{Transform as Eyt}from"stream";var vyt=["NETLIFY_AI_GATEWAY_KEY"];function byt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...vyt])]}function Tyt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function wyt(){let e=byt().map(r=>process.env[r]).filter(r=>!(!r||Tyt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function bs(t){if(typeof t!="string")return t;let e=wyt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(Ryt(n),"g");r=r.replace(i,"******")}),r}function Ryt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Db=class extends Eyt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=bs(i);n(null,s)}},fC=Symbol("maskedWrite");function ATe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[fC]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?bs(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[fC]=!0,process.stdout.write=r}if(!process.stderr.write[fC]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?bs(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[fC]=!0,process.stderr.write=r}}}var xTe=!1,ITe=()=>{xTe=!0},_i=()=>xTe;var Mb=null,PTe=t=>(Mb&&Mb.destroy(),Mb=new wc({totalAllowedTime:t}),Mb),OTe=()=>Mb;var wc=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 nO({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{Se.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 CTe={name:"@netlify/agent-runner-cli",type:"module",version:"1.145.0-ex-2517.3",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.197","@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.3","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.8.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var Pyt=xyt(import.meta.url),Oyt=Rc.dirname(Pyt),Cyt=Iyt(import.meta.url),Bg=ve("shell"),c3=new Set,NTe={preferLocal:!0},Wn=(t,e,r)=>{let[n,i]=Nyt(e,r),s={...NTe,...i},o=wTe(t,n,s);$Te(o,s),MTe(o);let a=r?.idleTimeout;return a&&a>0&&DTe(o,a),o},kTe=(t,e)=>{let r={...NTe,...e},n=RTe(t,r);return $Te(n,r),MTe(n),e?.idleTimeout&&e.idleTimeout>0&&DTe(n,e.idleTimeout),n},Nyt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},$Te=(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 Db).pipe(Ac.stdout),t.stderr?.pipe(new Db).pipe(Ac.stderr);return}t.stdout?.pipe(Ac.stdout),t.stderr?.pipe(Ac.stderr)},l3=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Ac.kill(-t.pid,e),Bg.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Bg.error("Error killing process:",r),!1}},LTe=t=>l3(t,"SIGKILL"),DTe=(t,e)=>{let r=null,n=()=>{Bg.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),l3(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Bg.log(`Force killing idle process ${t.pid}`),LTe(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)},MTe=t=>{c3.add(t);let e=OTe();if(e){let r=e.onTimesUp(()=>{Bg.log(`Global timer expired, killing process ${t.pid}`),l3(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Bg.log(`Force killing process ${t.pid} after timeout`),LTe(t))},5e3)});t.on("exit",()=>{c3.delete(t),r()}),t.on("error",()=>{c3.delete(t),r()})}};function oa(t,e){if(!Ac.env.NETLIFY_LOCAL_MODE)try{let i=Cyt.resolve(CTe.name),s=Rc.dirname(i);for(;s!==Rc.dirname(s);){let o=Rc.dirname(s);if(Rc.basename(o)==="node_modules"){let a=Rc.join(o,".bin",e);if(pC.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(Ac.env.NODE_PATH){let i=Rc.join(Ac.env.NODE_PATH,".bin",e);if(pC.existsSync(i))return i}let r=Rc.join(t,"node_modules",".bin",e);if(pC.existsSync(r))return r;let n=Rc.join(Oyt,"..","node_modules",".bin",e);if(pC.existsSync(n))return n}import _L from"process";import{fileURLToPath as vCt}from"url";import{createRequire as bCt}from"module";import yL from"path";var kyt="__netlify__getTracer",$yt="__netlify__shutdownTracers",ht=(t,e)=>globalThis[kyt]?.(t,e),UTe=async()=>globalThis[$yt]?.();function qf(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 mCt}from"timers/promises";import OEt from"process";var FTe=typeof globalThis=="object"?globalThis:global;var xc="1.9.0";var jTe=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function Lyt(t){var e=new Set([t]),r=new Set,n=t.match(jTe);if(!n)return function(){return!1};var i={major:+n[1],minor:+n[2],patch:+n[3],prerelease:n[4]};if(i.prerelease!=null)return function(c){return c===t};function s(a){return r.add(a),!1}function o(a){return e.add(a),!0}return function(c){if(e.has(c))return!0;if(r.has(c))return!1;var l=c.match(jTe);if(!l)return s(c);var u={major:+l[1],minor:+l[2],patch:+l[3],prerelease:l[4]};return u.prerelease!=null||i.major!==u.major?s(c):i.major===0?i.minor===u.minor&&i.patch<=u.patch?o(c):s(c):i.minor<=u.minor?o(c):s(c)}}var qTe=Lyt(xc);var Dyt=xc.split(".")[0],Ub=Symbol.for("opentelemetry.js.api."+Dyt),Fb=FTe;function Tu(t,e,r,n){var i;n===void 0&&(n=!1);var s=Fb[Ub]=(i=Fb[Ub])!==null&&i!==void 0?i:{version:xc};if(!n&&s[t]){var o=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+t);return r.error(o.stack||o.message),!1}if(s.version!==xc){var o=new Error("@opentelemetry/api: Registration of version v"+s.version+" for "+t+" does not match previously registered API v"+xc);return r.error(o.stack||o.message),!1}return s[t]=e,r.debug("@opentelemetry/api: Registered a global for "+t+" v"+xc+"."),!0}function to(t){var e,r,n=(e=Fb[Ub])===null||e===void 0?void 0:e.version;if(!(!n||!qTe(n)))return(r=Fb[Ub])===null||r===void 0?void 0:r[t]}function wu(t,e){e.debug("@opentelemetry/api: Unregistering a global for "+t+" v"+xc+".");var r=Fb[Ub];r&&delete r[t]}var Myt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s},Uyt=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))},BTe=(function(){function t(e){this._namespace=e.namespace||"DiagComponentLogger"}return t.prototype.debug=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return jb("debug",this._namespace,e)},t.prototype.error=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return jb("error",this._namespace,e)},t.prototype.info=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return jb("info",this._namespace,e)},t.prototype.warn=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return jb("warn",this._namespace,e)},t.prototype.verbose=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return jb("verbose",this._namespace,e)},t})();function jb(t,e,r){var n=to("diag");if(n)return r.unshift(e),n[t].apply(n,Uyt([],Myt(r),!1))}var Yn;(function(t){t[t.NONE=0]="NONE",t[t.ERROR=30]="ERROR",t[t.WARN=50]="WARN",t[t.INFO=60]="INFO",t[t.DEBUG=70]="DEBUG",t[t.VERBOSE=80]="VERBOSE",t[t.ALL=9999]="ALL"})(Yn||(Yn={}));function zTe(t,e){t<Yn.NONE?t=Yn.NONE:t>Yn.ALL&&(t=Yn.ALL),e=e||{};function r(n,i){var s=e[n];return typeof s=="function"&&t>=i?s.bind(e):function(){}}return{error:r("error",Yn.ERROR),warn:r("warn",Yn.WARN),info:r("info",Yn.INFO),debug:r("debug",Yn.DEBUG),verbose:r("verbose",Yn.VERBOSE)}}var Fyt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s},jyt=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))},qyt="diag",Mi=(function(){function t(){function e(i){return function(){for(var s=[],o=0;o<arguments.length;o++)s[o]=arguments[o];var a=to("diag");if(a)return a[i].apply(a,jyt([],Fyt(s),!1))}}var r=this,n=function(i,s){var o,a,c;if(s===void 0&&(s={logLevel:Yn.INFO}),i===r){var l=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return r.error((o=l.stack)!==null&&o!==void 0?o:l.message),!1}typeof s=="number"&&(s={logLevel:s});var u=to("diag"),d=zTe((a=s.logLevel)!==null&&a!==void 0?a:Yn.INFO,i);if(u&&!s.suppressOverrideMessage){var f=(c=new Error().stack)!==null&&c!==void 0?c:"<failed to generate stacktrace>";u.warn("Current logger will be overwritten from "+f),d.warn("Current logger will overwrite one already registered from "+f)}return Tu("diag",d,r,!0)};r.setLogger=n,r.disable=function(){wu(qyt,r)},r.createComponentLogger=function(i){return new BTe(i)},r.verbose=e("verbose"),r.debug=e("debug"),r.info=e("info"),r.warn=e("warn"),r.error=e("error")}return t.instance=function(){return this._instance||(this._instance=new t),this._instance},t})();var Byt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s},zyt=function(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},VTe=(function(){function t(e){this._entries=e?new Map(e):new Map}return t.prototype.getEntry=function(e){var r=this._entries.get(e);if(r)return Object.assign({},r)},t.prototype.getAllEntries=function(){return Array.from(this._entries.entries()).map(function(e){var r=Byt(e,2),n=r[0],i=r[1];return[n,i]})},t.prototype.setEntry=function(e,r){var n=new t(this._entries);return n._entries.set(e,r),n},t.prototype.removeEntry=function(e){var r=new t(this._entries);return r._entries.delete(e),r},t.prototype.removeEntries=function(){for(var e,r,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var s=new t(this._entries);try{for(var o=zyt(n),a=o.next();!a.done;a=o.next()){var c=a.value;s._entries.delete(c)}}catch(l){e={error:l}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return s},t.prototype.clear=function(){return new t},t})();var ycr=Mi.instance();function HTe(t){return t===void 0&&(t={}),new VTe(new Map(Object.entries(t)))}function hC(t){return Symbol.for(t)}var Vyt=(function(){function t(e){var r=this;r._currentContext=e?new Map(e):new Map,r.getValue=function(n){return r._currentContext.get(n)},r.setValue=function(n,i){var s=new t(r._currentContext);return s._currentContext.set(n,i),s},r.deleteValue=function(n){var i=new t(r._currentContext);return i._currentContext.delete(n),i}}return t})(),GTe=new Vyt;var WTe={get:function(t,e){if(t!=null)return t[e]},keys:function(t){return t==null?[]:Object.keys(t)}},YTe={set:function(t,e,r){t!=null&&(t[e]=r)}};var Hyt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s},Gyt=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))},KTe=(function(){function t(){}return t.prototype.active=function(){return GTe},t.prototype.with=function(e,r,n){for(var i=[],s=3;s<arguments.length;s++)i[s-3]=arguments[s];return r.call.apply(r,Gyt([n],Hyt(i),!1))},t.prototype.bind=function(e,r){return r},t.prototype.enable=function(){return this},t.prototype.disable=function(){return this},t})();var Wyt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s},Yyt=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))},u3="context",Kyt=new KTe,Ru=(function(){function t(){}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalContextManager=function(e){return Tu(u3,e,Mi.instance())},t.prototype.active=function(){return this._getContextManager().active()},t.prototype.with=function(e,r,n){for(var i,s=[],o=3;o<arguments.length;o++)s[o-3]=arguments[o];return(i=this._getContextManager()).with.apply(i,Yyt([e,r,n],Wyt(s),!1))},t.prototype.bind=function(e,r){return this._getContextManager().bind(e,r)},t.prototype._getContextManager=function(){return to(u3)||Kyt},t.prototype.disable=function(){this._getContextManager().disable(),wu(u3,Mi.instance())},t})();var mC;(function(t){t[t.NONE=0]="NONE",t[t.SAMPLED=1]="SAMPLED"})(mC||(mC={}));var d3="0000000000000000",f3="00000000000000000000000000000000",JTe={traceId:f3,spanId:d3,traceFlags:mC.NONE};var Au=(function(){function t(e){e===void 0&&(e=JTe),this._spanContext=e}return t.prototype.spanContext=function(){return this._spanContext},t.prototype.setAttribute=function(e,r){return this},t.prototype.setAttributes=function(e){return this},t.prototype.addEvent=function(e,r){return this},t.prototype.addLink=function(e){return this},t.prototype.addLinks=function(e){return this},t.prototype.setStatus=function(e){return this},t.prototype.updateName=function(e){return this},t.prototype.end=function(e){},t.prototype.isRecording=function(){return!1},t.prototype.recordException=function(e,r){},t})();var p3=hC("OpenTelemetry Context Key SPAN");function gC(t){return t.getValue(p3)||void 0}function ZTe(){return gC(Ru.getInstance().active())}function qb(t,e){return t.setValue(p3,e)}function XTe(t){return t.deleteValue(p3)}function QTe(t,e){return qb(t,new Au(e))}function _C(t){var e;return(e=gC(t))===null||e===void 0?void 0:e.spanContext()}var Jyt=/^([0-9a-f]{32})$/i,Zyt=/^[0-9a-f]{16}$/i;function Xyt(t){return Jyt.test(t)&&t!==f3}function Qyt(t){return Zyt.test(t)&&t!==d3}function yC(t){return Xyt(t.traceId)&&Qyt(t.spanId)}function ewe(t){return new Au(t)}var h3=Ru.getInstance(),SC=(function(){function t(){}return t.prototype.startSpan=function(e,r,n){n===void 0&&(n=h3.active());var i=!!r?.root;if(i)return new Au;var s=n&&_C(n);return eSt(s)&&yC(s)?new Au(s):new Au},t.prototype.startActiveSpan=function(e,r,n,i){var s,o,a;if(!(arguments.length<2)){arguments.length===2?a=r:arguments.length===3?(s=r,a=n):(s=r,o=n,a=i);var c=o??h3.active(),l=this.startSpan(e,s,c),u=qb(c,l);return h3.with(u,a,void 0,l)}},t})();function eSt(t){return typeof t=="object"&&typeof t.spanId=="string"&&typeof t.traceId=="string"&&typeof t.traceFlags=="number"}var tSt=new SC,twe=(function(){function t(e,r,n,i){this._provider=e,this.name=r,this.version=n,this.options=i}return t.prototype.startSpan=function(e,r,n){return this._getTracer().startSpan(e,r,n)},t.prototype.startActiveSpan=function(e,r,n,i){var s=this._getTracer();return Reflect.apply(s.startActiveSpan,s,arguments)},t.prototype._getTracer=function(){if(this._delegate)return this._delegate;var e=this._provider.getDelegateTracer(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):tSt},t})();var rwe=(function(){function t(){}return t.prototype.getTracer=function(e,r,n){return new SC},t})();var rSt=new rwe,m3=(function(){function t(){}return t.prototype.getTracer=function(e,r,n){var i;return(i=this.getDelegateTracer(e,r,n))!==null&&i!==void 0?i:new twe(this,e,r,n)},t.prototype.getDelegate=function(){var e;return(e=this._delegate)!==null&&e!==void 0?e:rSt},t.prototype.setDelegate=function(e){this._delegate=e},t.prototype.getDelegateTracer=function(e,r,n){var i;return(i=this._delegate)===null||i===void 0?void 0:i.getTracer(e,r,n)},t})();var xu;(function(t){t[t.INTERNAL=0]="INTERNAL",t[t.SERVER=1]="SERVER",t[t.CLIENT=2]="CLIENT",t[t.PRODUCER=3]="PRODUCER",t[t.CONSUMER=4]="CONSUMER"})(xu||(xu={}));var aa;(function(t){t[t.UNSET=0]="UNSET",t[t.OK=1]="OK",t[t.ERROR=2]="ERROR"})(aa||(aa={}));var Ic=Ru.getInstance();var g3=Mi.instance();var nwe=(function(){function t(){}return t.prototype.inject=function(e,r){},t.prototype.extract=function(e,r){return e},t.prototype.fields=function(){return[]},t})();var _3=hC("OpenTelemetry Baggage Key");function y3(t){return t.getValue(_3)||void 0}function iwe(){return y3(Ru.getInstance().active())}function swe(t,e){return t.setValue(_3,e)}function owe(t){return t.deleteValue(_3)}var S3="propagation",nSt=new nwe,awe=(function(){function t(){this.createBaggage=HTe,this.getBaggage=y3,this.getActiveBaggage=iwe,this.setBaggage=swe,this.deleteBaggage=owe}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalPropagator=function(e){return Tu(S3,e,Mi.instance())},t.prototype.inject=function(e,r,n){return n===void 0&&(n=YTe),this._getGlobalPropagator().inject(e,r,n)},t.prototype.extract=function(e,r,n){return n===void 0&&(n=WTe),this._getGlobalPropagator().extract(e,r,n)},t.prototype.fields=function(){return this._getGlobalPropagator().fields()},t.prototype.disable=function(){wu(S3,Mi.instance())},t.prototype._getGlobalPropagator=function(){return to(S3)||nSt},t})();var Bb=awe.getInstance();var E3="trace",cwe=(function(){function t(){this._proxyTracerProvider=new m3,this.wrapSpanContext=ewe,this.isSpanContextValid=yC,this.deleteSpan=XTe,this.getSpan=gC,this.getActiveSpan=ZTe,this.getSpanContext=_C,this.setSpan=qb,this.setSpanContext=QTe}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalTracerProvider=function(e){var r=Tu(E3,this._proxyTracerProvider,Mi.instance());return r&&this._proxyTracerProvider.setDelegate(e),r},t.prototype.getTracerProvider=function(){return to(E3)||this._proxyTracerProvider},t.prototype.getTracer=function(e,r){return this.getTracerProvider().getTracer(e,r)},t.prototype.disable=function(){wu(E3,Mi.instance()),this._proxyTracerProvider=new m3},t})();var zb=cwe.getInstance();var sSt=function(t,e){e.recordException(t),e.setStatus({code:aa.ERROR})};var Bf=(function(){function t(e){this._tracer=e,this.startSpan=e.startSpan.bind(this._tracer),this.startActiveSpan=e.startActiveSpan.bind(this._tracer)}return t.prototype.withActiveSpan=function(e,r,n,i){var s=lwe(r,n,i),o=s.opts,a=s.ctx,c=s.fn;return this._tracer.startActiveSpan(e,o,a,function(l){return uwe(l,o,c)})},t.prototype.withSpan=function(e,r,n,i){var s=lwe(r,n,i),o=s.opts,a=s.ctx,c=s.fn,l=this._tracer.startSpan(e,o,a);return uwe(l,o,c)},t})();function lwe(t,e,r){var n,i,s;return!e&&!r?s=t:r?(n=t,i=e,s=r):(n=t,s=e),n=n??{},i=i??Ic.active(),{opts:n,ctx:i,fn:s}}function uwe(t,e,r){var n,i=(n=e.onException)!==null&&n!==void 0?n:sSt,s=function(a){throw i(a,t),t.end(),a};try{var o=r(t);return typeof o?.then=="function"?o.then(function(a){return t.end(),a},s):(t.end(),o)}catch(a){throw s(a)}}_W();et();var hT=class{emit(e){}enabled(){return!1}},TRe=new hT;var mT=Symbol.for("io.opentelemetry.js.api.logs"),Xg=globalThis;function wRe(t,e,r){return n=>n===t?e:r}var yW=1;var SW=class{getLogger(e,r,n){return new hT}},uN=new SW;var dN=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):TRe}};var gT=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new dN(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:uN}_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 fN=class t{constructor(){this._proxyLoggerProvider=new gT}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return Xg[mT]?this.getLoggerProvider():(Xg[mT]=wRe(yW,e,uN),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=Xg[mT])===null||e===void 0?void 0:e.call(Xg,yW))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete Xg[mT],this._proxyLoggerProvider=new gT}};var RRe=fN.getInstance();function ARe(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 xRe(t){t.forEach(e=>e.disable())}function EW(t){let e=t.tracerProvider||Or.getTracerProvider(),r=t.meterProvider||eT.getMeterProvider(),n=t.loggerProvider||RRe.getLoggerProvider(),i=t.instrumentations?.flat()??[];return ARe(i,e,r,n),()=>{xRe(i)}}dr();var $N=Dn(DW(),1);dr();var oAe=t=>{throw TypeError(t)},jW=(t,e,r)=>e.has(t)||oAe("Cannot "+r),kN=(t,e,r)=>(jW(t,e,"read from private field"),r?r.call(t):e.get(t)),MW=(t,e,r)=>e.has(t)?oAe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),nAe=(t,e,r,n)=>(jW(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),PEt=(t,e,r)=>(jW(t,e,"access private method"),r),iAe="__netlify__getTracer",CEt="__netlify__shutdownTracers",NEt="__nfOTLPTrace",yT,ST,FW,aAe,kEt=class{constructor(){MW(this,FW),MW(this,yT),MW(this,ST),nAe(this,yT,new ha(PEt(this,FW,aAe),this)),nAe(this,ST,g3.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(kN(this,ST).debug(`export ${t.length.toString()} spans`),kN(this,yT).isCalled){e({code:Qt.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(NEt,JSON.stringify($Et(t))),e({code:Qt.SUCCESS})}shutdown(){return kN(this,yT).call()}};yT=new WeakMap;ST=new WeakMap;FW=new WeakSet;aAe=function(){return kN(this,ST).debug("Shutting down"),Promise.resolve()};function $Et(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:NN(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||xu.SERVER,startTimeUnixNano:UW(e.startTime),endTimeUnixNano:UW(e.endTime),attributes:NN(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:UW(n.time),attributes:NN(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:NN(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function NN(t){return Object.keys(t).map(e=>cAe(e,t[e]))}function cAe(t,e){return{key:t,value:lAe(e)}}function lAe(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(lAe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>cAe(r,n))}}:{}}function UW(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var sAe={name:"@netlify/otel",version:"6.0.3",type:"module",engines:{node:"^18.14.0 || >=20.6.1"},main:"./dist/main.cjs",module:"./dist/main.js",types:"./dist/main.d.ts",exports:{".":{require:{types:"./dist/main.d.cts",default:"./dist/main.cjs"},import:{types:"./dist/main.d.ts",default:"./dist/main.js"},default:{types:"./dist/main.d.ts",default:"./dist/main.js"}},"./package.json":"./package.json","./bootstrap":{require:{types:"./dist/bootstrap/main.d.cts",default:"./dist/bootstrap/main.cjs"},import:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"},default:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"}},"./exporter-netlify":{require:{types:"./dist/exporters/netlify.d.cts",default:"./dist/exporters/netlify.cjs"},import:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"},default:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"}},"./instrumentation-fetch":{require:{types:"./dist/instrumentations/fetch.d.cts",default:"./dist/instrumentations/fetch.cjs"},import:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"},default:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"}},"./instrumentation-http":{require:{types:"./dist/instrumentations/http.d.cts",default:"./dist/instrumentations/http.cjs"},import:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"},default:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"}},"./opentelemetry":{require:{types:"./dist/opentelemetry.d.cts",default:"./dist/opentelemetry.cjs"},import:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"},default:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"}}},files:["dist/**/*"],scripts:{build:"tsup-node",dev:"tsup-node --watch",prepack:"npm run build",test:"run-s build test:ci","test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"vitest","test:dev:vitest:watch":"vitest watch","test:ci:vitest":"vitest run",publint:"npx -y publint --strict"},keywords:["netlify","cdn"],license:"MIT",repository:{type:"git",url:"https://github.com/netlify/primitives.git",directory:"packages/otel"},bugs:{url:"https://github.com/netlify/primitives/issues"},author:"Netlify Inc.",devDependencies:{"@netlify/dev-utils":"^4.4.6",msw:"^2.10.5","npm-run-all2":"^7.0.2",tsup:"^8.0.0",vitest:"^3.0.0"},dependencies:{"@opentelemetry/api":"1.9.0","@opentelemetry/core":"2.7.1","@opentelemetry/instrumentation":"^0.217.0","@opentelemetry/resources":"2.7.1","@opentelemetry/sdk-trace-node":"2.7.1"}},uAe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,iAe))return;let e=OEt.version.slice(1),r=lN({"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??[LEt()],i=new $N.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new kc});let s=t.instrumentations??[];EW({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,iAe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new Bf(zb.getTracer(a,c)):new Bf(zb.getTracer(sAe.name,sAe.version))}}),Object.defineProperty(globalThis,CEt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},LEt=()=>new $N.SimpleSpanProcessor(new kEt);dr();var ET=Dn(DW(),1);import*as LN from"diagnostics_channel";var dAe=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?aa.ERROR:aa.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 Bf?t:new Bf(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){LN.subscribe(t,e);let r=()=>LN.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:xu.CLIENT},Ic.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:aa.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 Tke=Dn(vke(),1);var mL=ve("tracing"),bke=8e3,gCt=5e3,kw=async(t=gCt)=>{try{await Promise.race([UTe(),mCt(t)])}catch(e){mL.warn("Failed to flush tracers on shutdown",e)}},wke=async(t,e,r)=>{if(!ht()){let n=[new ET.SimpleSpanProcessor(new w9),new ET.SimpleSpanProcessor(new Tke.OTLPTraceExporter({url:r.exporterUrl}))];await uAe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new dAe({skipHeaders:!0})]})}return r.traceparent?(Bb.setGlobalPropagator(new kc),Bb.extract(Ic.active(),{traceparent:r.traceparent,isRemote:!0})):Ic.active()};function Vt(t,e,r){return mL.log(`\u23F3 TRACE: ${e} starting...`),qf(t,e,r)}var w9=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(", ")}]`:"";mL.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&mL.log(` \u274C Error: ${e.status.message}`)}};function R9(){return rt().captureLlmContentEnabled}function Rke(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function gL(t,e,r){let n={role:t,parts:[{type:"text",content:bs(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}function Ake(t,e,r,n){if(!t.length)return;let i=ht();if(!i)return;let s=R9(),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>bke?`${a.message.slice(0,bke)}\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":bs(p)}:{"gen_ai.output.messages":gL("assistant",p)}:{}}}).end(u)})}import{readdir as _Ct,rm as yCt}from"fs/promises";import{join as SCt}from"path";async function xke(t,e=[]){let n=(await _Ct(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>yCt(SCt(t,i),{recursive:!0,force:!0})))}var ECt=700,Ike=t=>t.mode==="create"&&(t.accountType===wl||t.enforcedAICreditsRemaining!=null&&t.enforcedAICreditsRemaining<=ECt);var TCt=yL.dirname(vCt(import.meta.url)),Pke=bCt(import.meta.url),wCt=yL.resolve(TCt,"scripts/scaffold.js"),RCt="scripts/scaffold.js",ACt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,A9=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},xCt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),ICt=t=>{let e=A9(t);return e==="node"||e.endsWith("/node")},el=t=>{if(typeof t!="string")return!1;let e=t.match(ACt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&xCt(A9(e[r]));)r+=1;if(r>=e.length||!ICt(e[r]))return!1;let n=e[r+1];return n?A9(n).includes(RCt):!1},K_=ve("create_stage"),Oke="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.",PCt=`${Oke}
|
|
581
|
+
if (condition) { yield value; }`)};import{Buffer as Umt}from"buffer";import{StringDecoder as Fmt}from"string_decoder";var ZO=(t,e,r)=>{if(r)return;if(t)return{transform:jmt.bind(void 0,new TextEncoder)};let n=new Fmt(e);return{transform:qmt.bind(void 0,n),final:Bmt.bind(void 0,n)}},jmt=function*(t,e){Umt.isBuffer(e)?yield Ec(e):typeof e=="string"?yield t.encode(e):yield e},qmt=function*(t,e){yield Pr(e)?t.write(e):e},Bmt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Xve}from"util";var R6=Xve(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),XO=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Vmt}=e[r];for await(let i of n(t))yield*XO(i,e,r+1)},Qve=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*zmt(r,Number(e),t)},zmt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*XO(n,r,e+1)},ebe=Xve(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),Vmt=function*(t){yield t};var A6=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},tbe=(t,e)=>[...e.flatMap(r=>[...Uf(r,t,0)]),...Ob(t)],Uf=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Gmt}=e[r];for(let i of n(t))yield*Uf(i,e,r+1)},Ob=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Hmt(r,Number(e),t)},Hmt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Uf(n,r,e+1)},Gmt=function*(t){yield t};var x6=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=nbe(t,o,s),l=Mf(e),u=Mf(r),d=l?R6.bind(void 0,XO,a):A6.bind(void 0,Uf),f=l||u?R6.bind(void 0,Qve,a):A6.bind(void 0,Ob),p=l||u?ebe.bind(void 0,a):void 0;return{stream:new Wmt({writableObjectMode:n,writableHighWaterMark:rbe(n),readableObjectMode:i,readableHighWaterMark:rbe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},QO=(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=nbe(o,r,a);t=tbe(c,t)}return t},nbe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:Kve(n,a)},ZO(r,o,n),JO(r,s,n,c),{transform:t,final:e},{transform:Jve(i,a)},Yve({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var ibe=(t,e)=>{for(let r of Ymt(t))Kmt(t,r,e)},Ymt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Kmt=(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 ${vu[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>Jmt(a,n));r.input=Eb(o)},Jmt=(t,e)=>{let r=QO(t,e,"utf8",!0);return Zmt(r),Eb(r)},Zmt=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 tgt,appendFileSync as rgt}from"fs";var eC=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Ig(r,n)&&!Di.has(e)&&Xmt(n)&&(t.some(({type:i,value:s})=>i==="native"&&Qmt.has(s))||t.every(({type:i})=>vs.has(i))),Xmt=t=>t===1||t===2,Qmt=new Set(["pipe","overlapped"]),sbe=async(t,e,r,n)=>{for await(let i of t)egt(e)||abe(i,r,n)},obe=(t,e,r)=>{for(let n of t)abe(n,e,r)},egt=t=>t._readableState.pipes.length>0,abe=(t,e,r)=>{let n=hO(t);ta({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var cbe=({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)=>ngt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},ngt=({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=lve(t,s,d),p=Ec(f),{stdioItems:h,objectMode:m}=e[r],_=igt([p],h,c,n),{serializedResult:y,finalResult:v=y}=sgt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});ogt({serializedResult:y,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let S=a[r]?v:void 0;try{return n.error===void 0&&agt(y,h,i),S}catch(g){return n.error=g,S}},igt=(t,e,r,n)=>{try{return QO(t,e,r,!1)}catch(i){return n.error=i,t}},sgt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Eb(t)};let o=Tye(t,r);return n[s]?{serializedResult:o,finalResult:w6(o,!i[s],e)}:{serializedResult:o}},ogt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!eC({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=w6(t,!1,o);try{obe(a,e,n)}catch(c){r.error??=c}},agt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>YO.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?rgt(n,t):(r.add(s),tgt(n,t))}};var lbe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Tc(e,r,"all")]:Array.isArray(e)?[Tc(t,r,"all"),...e]:Pr(t)&&Pr(e)?kG([t,e]):`${t}${e}`};import{once as I6}from"events";var ube=async(t,e)=>{let[r,n]=await cgt(t);return e.isForcefullyTerminated??=!1,[r,n]},cgt=async t=>{let[e,r]=await Promise.allSettled([I6(t,"spawn"),I6(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?dbe(t):r.value},dbe=async t=>{try{return await I6(t,"exit")}catch{return dbe(t)}},fbe=async t=>{let[e,r]=await t;if(!lgt(e,r)&&P6(e,r))throw new Xs;return[e,r]},lgt=(t,e)=>t===void 0&&e===void 0,P6=(t,e)=>t!==0||e!==null;var pbe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=ugt(t,e,r),o=s?.code==="ETIMEDOUT",a=cve(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},ugt=(t,e,r)=>t!==void 0?t:P6(e,r)?new Xs:void 0;var hbe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=fgt(t,e,r),d=mgt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Ug(d,c,l)},fgt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=gO(t,e,r),a=pgt(r),{file:c,commandArguments:l,options:u}=DO(t,e,a);hgt(u);let d=Vve(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},pgt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,hgt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&tC("ipcInput"),t&&tC("ipc: true"),r&&tC("detached: true"),n&&tC("cancelSignal")},tC=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},mgt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=ggt({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}=pbe(c,r),{output:h,error:m=l}=cbe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((v,S)=>Tc(v,r,S)),y=Tc(lbe(h,r),r,"all");return ygt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},ggt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{ibe(s,r);let a=_gt(r);return dgt(...MO(t,e,a))}catch(a){return Mg({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},_gt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:VO(e)}),ygt=({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?HO({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):Pb({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 syt}from"events";import{spawn as oyt}from"child_process";import Sbe from"process";import{once as O6,on as Sgt}from"events";var mbe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(Cg({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:OO(t)}),Egt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),Egt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{AO(e,i);let s=Eu(t,e,r),o=new AbortController;try{return await Promise.race([vgt(s,n,o),bgt(s,r,o),Tgt(s,r,o)])}catch(a){throw Ng(t),a}finally{o.abort(),xO(e,i)}},vgt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await O6(t,"message",{signal:r});return n}for await(let[n]of Sgt(t,"message",{signal:r}))if(e(n))return n},bgt=async(t,e,{signal:r})=>{await O6(t,"disconnect",{signal:r}),tEe(e)},Tgt=async(t,e,{signal:r})=>{let[n]=await O6(t,"strict:error",{signal:r});throw TO(n,e)};import{once as _be,on as wgt}from"events";var ybe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>C6({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),C6=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{Cg({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:OO(t)}),AO(e,s);let o=Eu(t,e,r),a=new AbortController,c={};return Rgt(t,o,a),Agt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),xgt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},Rgt=async(t,e,r)=>{try{await _be(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Agt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await _be(t,"strict:error",{signal:r.signal});n.error=TO(i,e),r.abort()}catch{}},xgt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of wgt(r,"message",{signal:s.signal}))gbe(o),yield c}catch{gbe(o)}finally{s.abort(),xO(e,a),n||Ng(t),i&&await t}},gbe=({error:t})=>{if(t)throw t};var Ebe=(t,{ipc:e})=>{Object.assign(t,bbe(t,!1,e))},vbe=()=>{let t=Sbe,e=!0,r=Sbe.channel!==void 0;return{...bbe(t,e,r),getCancelSignal:IEe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},bbe=(t,e,r)=>({sendMessage:$O.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:mbe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:ybe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Igt}from"child_process";import{PassThrough as Pgt,Readable as Ogt,Writable as Cgt,Duplex as Ngt}from"stream";var Tbe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{v6(n);let a=new Igt;kgt(a,n),Object.assign(a,{readable:$gt,writable:Lgt,duplex:Dgt});let c=Mg({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=Mgt(c,o,i);return{subprocess:a,promise:l}},kgt=(t,e)=>{let r=Cb(),n=Cb(),i=Cb(),s=Array.from({length:e.length-3},Cb),o=Cb(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},Cb=()=>{let t=new Pgt;return t.end(),t},$gt=()=>new Ogt({read(){}}),Lgt=()=>new Cgt({write(){}}),Dgt=()=>new Ngt({read(){},write(){}}),Mgt=async(t,e,r)=>Ug(t,e,r);import{createReadStream as wbe,createWriteStream as Rbe}from"fs";import{Buffer as Ugt}from"buffer";import{Readable as Nb,Writable as Fgt,Duplex as jgt}from"stream";var xbe=(t,e)=>KO(qgt,t,e,!1),kb=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${vu[t]}.`)},Abe={fileNumber:kb,generator:x6,asyncGenerator:x6,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:jgt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},qgt={input:{...Abe,fileUrl:({value:t})=>({stream:wbe(t)}),filePath:({value:{file:t}})=>({stream:wbe(t)}),webStream:({value:t})=>({stream:Nb.fromWeb(t)}),iterable:({value:t})=>({stream:Nb.from(t)}),asyncIterable:({value:t})=>({stream:Nb.from(t)}),string:({value:t})=>({stream:Nb.from(t)}),uint8Array:({value:t})=>({stream:Nb.from(Ugt.from(t))})},output:{...Abe,fileUrl:({value:t})=>({stream:Rbe(t)}),filePath:({value:{file:t,append:e}})=>({stream:Rbe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Fgt.fromWeb(t)}),iterable:kb,asyncIterable:kb,string:kb,uint8Array:kb}};import{on as Bgt,once as Ibe}from"events";import{PassThrough as zgt,getDefaultHighWaterMark as Vgt}from"stream";import{finished as Cbe}from"stream/promises";function Ff(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)k6(i);let e=t.some(({readableObjectMode:i})=>i),r=Hgt(t,e),n=new N6({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Hgt=(t,e)=>{if(t.length===0)return Vgt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},N6=class extends zgt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(k6(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Ggt(this,this.#e,this.#s);let r=Kgt({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(k6(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)}},Ggt=async(t,e,r)=>{rC(t,Pbe);let n=new AbortController;try{await Promise.race([Wgt(t,n),Ygt(t,e,r,n)])}finally{n.abort(),rC(t,-Pbe)}},Wgt=async(t,{signal:e})=>{try{await Cbe(t,{signal:e,cleanup:!0})}catch(r){throw Nbe(t,r),r}},Ygt=async(t,e,r,{signal:n})=>{for await(let[i]of Bgt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},k6=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Kgt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{rC(t,Obe);let a=new AbortController;try{await Promise.race([Jgt(s,e,a),Zgt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),Xgt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),rC(t,-Obe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?$6(t):Qgt(t))},Jgt=async(t,e,{signal:r})=>{try{await t,r.aborted||$6(e)}catch(n){r.aborted||Nbe(e,n)}},Zgt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await Cbe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;kbe(o)?i.add(e):$be(t,o)}},Xgt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await Ibe(t,i,{signal:s}),!t.readable)return Ibe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},Qgt=t=>{t.writable&&t.end()},Nbe=(t,e)=>{kbe(e)?$6(t):$be(t,e)},kbe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",$6=t=>{(t.readable||t.writable)&&t.destroy()},$be=(t,e)=>{t.destroyed||(t.once("error",e_t),t.destroy(e))},e_t=()=>{},rC=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Pbe=2,Obe=1;import{finished as Lbe}from"stream/promises";var jg=(t,e)=>{t.pipe(e),t_t(t,e),r_t(t,e)},t_t=async(t,e)=>{if(!(Zs(t)||Zs(e))){try{await Lbe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}L6(e)}},L6=t=>{t.writable&&t.end()},r_t=async(t,e)=>{if(!(Zs(t)||Zs(e))){try{await Lbe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}D6(t)}},D6=t=>{t.readable&&t.destroy()};var Dbe=(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})=>vs.has(c)))n_t(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!vs.has(c)))s_t({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]:Ff(s);jg(o,i)}},n_t=(t,e,r,n)=>{r==="output"?jg(t.stdio[n],e):jg(e,t.stdio[n]);let i=i_t[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},i_t=["stdin","stdout","stderr"],s_t=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;o_t(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},o_t=(t,{signal:e})=>{Zs(t)&&Lf(t,a_t,e)},a_t=2;import{addAbortListener as u_t}from"events";var jf=[];jf.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&jf.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&jf.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var nC=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",M6=Symbol.for("signal-exit emitter"),U6=globalThis,c_t=Object.defineProperty.bind(Object),F6=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(U6[M6])return U6[M6];c_t(U6,M6,{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}},iC=class{},l_t=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),j6=class extends iC{onExit(){return()=>{}}load(){}unload(){}},q6=class extends iC{#e=B6.platform==="win32"?"SIGINT":"SIGHUP";#r=new F6;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of jf)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,s=e;if(typeof s.__signal_exit_emitter__=="object"&&typeof s.__signal_exit_emitter__.count=="number"&&(i+=s.__signal_exit_emitter__.count),n.length===i){this.unload();let o=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;o||e.kill(e.pid,a)}};this.#s=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!nC(this.#t))return()=>{};this.#o===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#r.on(n,e),()=>{this.#r.removeListener(n,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#o){this.#o=!0,this.#r.count+=1;for(let e of jf)try{let r=this.#i[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#o&&(this.#o=!1,jf.forEach(e=>{let r=this.#i[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#s,this.#r.count-=1)}#a(e){return nC(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"&&nC(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)}},B6=globalThis.process,{onExit:Mbe,load:Oir,unload:Cir}=l_t(nC(B6)?new q6(B6):new j6);var Ube=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Mbe(()=>{t.kill()});u_t(n,()=>{i()})};var jbe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=mO(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=d_t(r,n,i),{sourceStream:d,sourceError:f}=p_t(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}},d_t=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=f_t(t,e,...r),a=RO(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},f_t=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Fbe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||CG(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]=sO(r,...n);return{destination:e(Fbe)(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}`)},Fbe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),p_t=(t,e)=>{try{return{sourceStream:kg(t,e)}}catch(r){return{sourceError:r}}};var Bbe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=h_t({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw z6({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},h_t=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return D6(t),n;if(e!==void 0)return L6(r),e},z6=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Mg({error:t,command:qbe,escapedCommand:qbe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),qbe="source.pipe(destination)";var zbe=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 m_t}from"stream/promises";var Vbe=(t,e,r)=>{let n=sC.has(e)?__t(t,e):g_t(t,e);return Lf(t,S_t,r.signal),Lf(e,E_t,r.signal),y_t(e),n},g_t=(t,e)=>{let r=Ff([t]);return jg(r,e),sC.set(e,r),r},__t=(t,e)=>{let r=sC.get(e);return r.add(t),r},y_t=async t=>{try{await m_t(t,{cleanup:!0,readable:!1,writable:!0})}catch{}sC.delete(t)},sC=new WeakMap,S_t=2,E_t=1;import{aborted as v_t}from"util";var Hbe=(t,e)=>t===void 0?[]:[b_t(t,e)],b_t=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await v_t(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw z6({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var oC=(t,...e)=>{if(yr(e[0]))return oC.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=jbe(t,...e),i=T_t({...n,destination:r});return i.pipe=oC.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},T_t=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=w_t(t,i);Bbe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Vbe(e,s,d);return await Promise.race([zbe(u),...Hbe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},w_t=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as C_t}from"timers/promises";import{on as R_t}from"events";import{getDefaultHighWaterMark as A_t}from"stream";var aC=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return x_t(e,o),Wbe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},x_t=async(t,e)=>{try{await t}catch{}finally{e.abort()}},V6=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;I_t(e,o,t);let a=t.readableObjectMode&&!s;return Wbe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},I_t=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Wbe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=R_t(t,"data",{signal:e.signal,highWaterMark:Gbe,highWatermark:Gbe});return P_t({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},H6=A_t(!0),Gbe=H6,P_t=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=O_t({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Uf(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Ob(a)}},O_t=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[ZO(t,r,!e),JO(t,i,!n,{})].filter(Boolean);var Ybe=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=N_t({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([k_t(t),d]);return}let f=b6(c,r),p=V6({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([$_t({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},N_t=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!eC({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=V6({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await sbe(a,t,r,s)},k_t=async t=>{await C_t(),t.readableFlowing===null&&t.resume()},$_t=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await qO(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await BO(r,{maxBuffer:s})):await Dg(r,{maxBuffer:s})}catch(a){return Kbe(sve({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},G6=async t=>{try{return await t}catch(e){return Kbe(e)}},Kbe=({bufferedData:t})=>vye(t)?new Uint8Array(t):t;import{finished as L_t}from"stream/promises";var $b=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=D_t(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],L_t(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||F_t(a,e,r,n)}finally{o.abort()}},D_t=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&M_t(t,r,n),n},M_t=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{U_t(e,r),n.call(t,...i)}},U_t=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},F_t=(t,e,r,n)=>{if(!j_t(t,e,r,n))throw t},j_t=(t,e,r,n=!0)=>r.propagating?Jbe(t)||cC(t):(r.propagating=!0,W6(r,e)===n?Jbe(t):cC(t)),W6=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",cC=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Jbe=t=>t?.code==="EPIPE";var Zbe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>Y6({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),Y6=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=$b(t,e,l);if(W6(l,e)){await u;return}let[d]=await Promise.all([Ybe({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 Xbe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Ff([t,e].filter(Boolean)):void 0,Qbe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>Y6({...q_t(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:B_t(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),q_t=({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}},B_t=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as z_t}from"events";var eTe=t=>Ig(t,"ipc"),tTe=(t,e)=>{let r=hO(t);ta({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var rTe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=eTe(s),a=vc(e,"ipc"),c=vc(r,"ipc");for await(let l of C6({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(ove(t,i,c),i.push(l)),o&&tTe(l,s);return i},nTe=async(t,e)=>(await Promise.allSettled([t]),e);var iTe=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 v=ube(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},g=Zbe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),w=Qbe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),P=[],x=rTe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:P,verboseInfo:p}),R=V_t(m,t,S),O=H_t(h,S);try{return await Promise.race([Promise.all([{},fbe(v),Promise.all(g),w,x,UEe(t,d),...R,...O]),_,G_t(t,y),...kEe(t,s,f,y),...eEe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...CEe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(A){return f.terminationReason??="other",Promise.all([{error:A},v,Promise.all(g.map(b=>G6(b))),G6(w),nTe(x,P),Promise.allSettled(R),Promise.allSettled(O)])}},V_t=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:$b(n,i,r)),H_t=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>eo(s,{checkOpen:!1})&&!Zs(s)).map(({type:i,value:s,stream:o=s})=>$b(o,n,e,{isSameDirection:vs.has(i),stopOnExit:i==="native"}))),G_t=async(t,{signal:e})=>{let[r]=await z_t(t,"error",{signal:e});throw r};var sTe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),Lb=(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}},qg=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 W_t}from"stream";import{callbackify as Y_t}from"util";import{finished as oTe}from"stream/promises";var K6=async t=>{if(t!==void 0)try{await J6(t)}catch{}},aTe=async t=>{if(t!==void 0)try{await Z6(t)}catch{}},J6=async t=>{await oTe(t,{cleanup:!0,readable:!1,writable:!0})},Z6=async t=>{await oTe(t,{cleanup:!0,readable:!0,writable:!1})},lC=async(t,e)=>{if(await t,e)throw e},uC=(t,e,r)=>{r&&!cC(r)?t.destroy(r):e&&t.destroy()};var cTe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||Di.has(r),{subprocessStdout:a,waitReadableDestroy:c}=X6(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=Q6(a,o),{read:f,onStdoutDataDone:p}=e3({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new W_t({read:f,destroy:Y_t(r3.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return t3({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},X6=(t,e,r)=>{let n=kg(t,e),i=Lb(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},Q6=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:H6},e3=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=ra(),o=aC({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){K_t(this,o,s)},onStdoutDataDone:s}},K_t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},t3=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await Z6(t),await n,await K6(i),await e,r.readable&&r.push(null)}catch(s){await K6(i),lTe(r,s)}},r3=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await qg(r,e)&&(lTe(t,n),await lC(e,n))},lTe=(t,e)=>{uC(t,t.readable,e)};import{Writable as J_t}from"stream";import{callbackify as uTe}from"util";var dTe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=n3(t,r,e),o=new J_t({...i3(n,t,i),destroy:uTe(o3.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return s3(n,o),o},n3=(t,e,r)=>{let n=RO(t,e),i=Lb(r,n,"writableFinal"),s=Lb(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},i3=(t,e,r)=>({write:Z_t.bind(void 0,t),final:uTe(X_t.bind(void 0,t,e,r))}),Z_t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},X_t=async(t,e,r)=>{await qg(r,e)&&(t.writable&&t.end(),await e)},s3=async(t,e,r)=>{try{await J6(t),e.writable&&e.end()}catch(n){await aTe(r),fTe(e,n)}},o3=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await qg(r,e),await qg(n,e)&&(fTe(t,i),await lC(e,i))},fTe=(t,e)=>{uC(t,t.writable,e)};import{Duplex as Q_t}from"stream";import{callbackify as eyt}from"util";var pTe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||Di.has(r),{subprocessStdout:c,waitReadableDestroy:l}=X6(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=n3(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=Q6(c,a),{read:_,onStdoutDataDone:y}=e3({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),v=new Q_t({read:_,...i3(u,t,d),destroy:eyt(tyt.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 t3({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:u}),s3(u,v,c),v},tyt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([r3({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),o3({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var a3=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||Di.has(e),o=kg(t,r),a=aC({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return ryt(a,o,t)},ryt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var hTe=(t,{encoding:e})=>{let r=sTe();t.readable=cTe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=dTe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=pTe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=a3.bind(void 0,t,e),t[Symbol.asyncIterator]=a3.bind(void 0,t,e,{})};var mTe=(t,e)=>{for(let[r,n]of iyt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},nyt=(async()=>{})().constructor.prototype,iyt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(nyt,t)]);var gTe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=ayt(t,e,r),{subprocess:f,promise:p}=lyt({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=oC.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),mTe(f,p),na.set(f,{options:u,fileDescriptors:d}),f},ayt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=gO(t,e,r),{file:a,commandArguments:c,options:l}=DO(t,e,r),u=cyt(l),d=xbe(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},cyt=({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}},lyt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=oyt(...MO(t,e,r))}catch(h){return Tbe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;syt(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];Dbe(c,a,l),Ube(c,r,l);let d={},f=ra();c.kill=XSe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Xbe(c,r),hTe(c,r),Ebe(c,r);let p=uyt({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}},uyt=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 iTe({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)=>Tc(g,e,w)),v=Tc(m,e,"all"),S=dyt({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Ug(S,n,e)},dyt=({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?Pb({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}):HO({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var dC=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,fyt(n,t[n],i)]));return{...t,...r}},fyt=(t,e,r)=>pyt.has(t)&&yr(e)&&yr(r)?{...e,...r}:r,pyt=new Set(["env",...MG]);var bu=(t,e,r,n)=>{let i=(o,a,c)=>bu(o,a,r,c),s=(...o)=>hyt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},hyt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(yr(s))return i(t,dC(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=myt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?hbe(a,c,l):gTe(a,c,l,i)},myt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=xye(e)?Iye(e,r):[e,...r],[o,a,c]=sO(...s),l=dC(dC(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 _Te=({file:t,commandArguments:e})=>STe(t,e),yTe=({file:t,commandArguments:e})=>({...STe(t,e),isSync:!0}),STe=(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]=gyt(t);return{file:r,commandArguments:n}},gyt=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(_yt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},_yt=/ +/g;var ETe=(t,e,r)=>{t.sync=e(yyt,r),t.s=t.sync},vTe=({options:t})=>bTe(t),yyt=({options:t})=>({...bTe(t),isSync:!0}),bTe=t=>({options:{...Syt(t),...t}}),Syt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},TTe={preferLocal:!0};var wTe=bu(()=>({})),bar=bu(()=>({isSync:!0})),RTe=bu(_Te),Tar=bu(yTe),war=bu(LEe),Rar=bu(vTe,{},TTe,ETe),{sendMessage:Aar,getOneMessage:xar,getEachMessage:Iar,getCancelSignal:Par}=vbe();import{Transform as Eyt}from"stream";var vyt=["NETLIFY_AI_GATEWAY_KEY"];function byt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...vyt])]}function Tyt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function wyt(){let e=byt().map(r=>process.env[r]).filter(r=>!(!r||Tyt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function bs(t){if(typeof t!="string")return t;let e=wyt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(Ryt(n),"g");r=r.replace(i,"******")}),r}function Ryt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Db=class extends Eyt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=bs(i);n(null,s)}},fC=Symbol("maskedWrite");function ATe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[fC]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?bs(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[fC]=!0,process.stdout.write=r}if(!process.stderr.write[fC]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?bs(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[fC]=!0,process.stderr.write=r}}}var xTe=!1,ITe=()=>{xTe=!0},_i=()=>xTe;var Mb=null,PTe=t=>(Mb&&Mb.destroy(),Mb=new wc({totalAllowedTime:t}),Mb),OTe=()=>Mb;var wc=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 nO({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{Se.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 CTe={name:"@netlify/agent-runner-cli",type:"module",version:"1.145.0-ex-2517.4",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{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.197","@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.3","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.8.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var Pyt=xyt(import.meta.url),Oyt=Rc.dirname(Pyt),Cyt=Iyt(import.meta.url),Bg=ve("shell"),c3=new Set,NTe={preferLocal:!0},Wn=(t,e,r)=>{let[n,i]=Nyt(e,r),s={...NTe,...i},o=wTe(t,n,s);$Te(o,s),MTe(o);let a=r?.idleTimeout;return a&&a>0&&DTe(o,a),o},kTe=(t,e)=>{let r={...NTe,...e},n=RTe(t,r);return $Te(n,r),MTe(n),e?.idleTimeout&&e.idleTimeout>0&&DTe(n,e.idleTimeout),n},Nyt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},$Te=(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 Db).pipe(Ac.stdout),t.stderr?.pipe(new Db).pipe(Ac.stderr);return}t.stdout?.pipe(Ac.stdout),t.stderr?.pipe(Ac.stderr)},l3=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Ac.kill(-t.pid,e),Bg.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Bg.error("Error killing process:",r),!1}},LTe=t=>l3(t,"SIGKILL"),DTe=(t,e)=>{let r=null,n=()=>{Bg.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),l3(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Bg.log(`Force killing idle process ${t.pid}`),LTe(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)},MTe=t=>{c3.add(t);let e=OTe();if(e){let r=e.onTimesUp(()=>{Bg.log(`Global timer expired, killing process ${t.pid}`),l3(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Bg.log(`Force killing process ${t.pid} after timeout`),LTe(t))},5e3)});t.on("exit",()=>{c3.delete(t),r()}),t.on("error",()=>{c3.delete(t),r()})}};function oa(t,e){if(!Ac.env.NETLIFY_LOCAL_MODE)try{let i=Cyt.resolve(CTe.name),s=Rc.dirname(i);for(;s!==Rc.dirname(s);){let o=Rc.dirname(s);if(Rc.basename(o)==="node_modules"){let a=Rc.join(o,".bin",e);if(pC.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(Ac.env.NODE_PATH){let i=Rc.join(Ac.env.NODE_PATH,".bin",e);if(pC.existsSync(i))return i}let r=Rc.join(t,"node_modules",".bin",e);if(pC.existsSync(r))return r;let n=Rc.join(Oyt,"..","node_modules",".bin",e);if(pC.existsSync(n))return n}import _L from"process";import{fileURLToPath as vCt}from"url";import{createRequire as bCt}from"module";import yL from"path";var kyt="__netlify__getTracer",$yt="__netlify__shutdownTracers",ht=(t,e)=>globalThis[kyt]?.(t,e),UTe=async()=>globalThis[$yt]?.();function qf(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 mCt}from"timers/promises";import OEt from"process";var FTe=typeof globalThis=="object"?globalThis:global;var xc="1.9.0";var jTe=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function Lyt(t){var e=new Set([t]),r=new Set,n=t.match(jTe);if(!n)return function(){return!1};var i={major:+n[1],minor:+n[2],patch:+n[3],prerelease:n[4]};if(i.prerelease!=null)return function(c){return c===t};function s(a){return r.add(a),!1}function o(a){return e.add(a),!0}return function(c){if(e.has(c))return!0;if(r.has(c))return!1;var l=c.match(jTe);if(!l)return s(c);var u={major:+l[1],minor:+l[2],patch:+l[3],prerelease:l[4]};return u.prerelease!=null||i.major!==u.major?s(c):i.major===0?i.minor===u.minor&&i.patch<=u.patch?o(c):s(c):i.minor<=u.minor?o(c):s(c)}}var qTe=Lyt(xc);var Dyt=xc.split(".")[0],Ub=Symbol.for("opentelemetry.js.api."+Dyt),Fb=FTe;function Tu(t,e,r,n){var i;n===void 0&&(n=!1);var s=Fb[Ub]=(i=Fb[Ub])!==null&&i!==void 0?i:{version:xc};if(!n&&s[t]){var o=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+t);return r.error(o.stack||o.message),!1}if(s.version!==xc){var o=new Error("@opentelemetry/api: Registration of version v"+s.version+" for "+t+" does not match previously registered API v"+xc);return r.error(o.stack||o.message),!1}return s[t]=e,r.debug("@opentelemetry/api: Registered a global for "+t+" v"+xc+"."),!0}function to(t){var e,r,n=(e=Fb[Ub])===null||e===void 0?void 0:e.version;if(!(!n||!qTe(n)))return(r=Fb[Ub])===null||r===void 0?void 0:r[t]}function wu(t,e){e.debug("@opentelemetry/api: Unregistering a global for "+t+" v"+xc+".");var r=Fb[Ub];r&&delete r[t]}var Myt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s},Uyt=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))},BTe=(function(){function t(e){this._namespace=e.namespace||"DiagComponentLogger"}return t.prototype.debug=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return jb("debug",this._namespace,e)},t.prototype.error=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return jb("error",this._namespace,e)},t.prototype.info=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return jb("info",this._namespace,e)},t.prototype.warn=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return jb("warn",this._namespace,e)},t.prototype.verbose=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return jb("verbose",this._namespace,e)},t})();function jb(t,e,r){var n=to("diag");if(n)return r.unshift(e),n[t].apply(n,Uyt([],Myt(r),!1))}var Yn;(function(t){t[t.NONE=0]="NONE",t[t.ERROR=30]="ERROR",t[t.WARN=50]="WARN",t[t.INFO=60]="INFO",t[t.DEBUG=70]="DEBUG",t[t.VERBOSE=80]="VERBOSE",t[t.ALL=9999]="ALL"})(Yn||(Yn={}));function zTe(t,e){t<Yn.NONE?t=Yn.NONE:t>Yn.ALL&&(t=Yn.ALL),e=e||{};function r(n,i){var s=e[n];return typeof s=="function"&&t>=i?s.bind(e):function(){}}return{error:r("error",Yn.ERROR),warn:r("warn",Yn.WARN),info:r("info",Yn.INFO),debug:r("debug",Yn.DEBUG),verbose:r("verbose",Yn.VERBOSE)}}var Fyt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s},jyt=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))},qyt="diag",Mi=(function(){function t(){function e(i){return function(){for(var s=[],o=0;o<arguments.length;o++)s[o]=arguments[o];var a=to("diag");if(a)return a[i].apply(a,jyt([],Fyt(s),!1))}}var r=this,n=function(i,s){var o,a,c;if(s===void 0&&(s={logLevel:Yn.INFO}),i===r){var l=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return r.error((o=l.stack)!==null&&o!==void 0?o:l.message),!1}typeof s=="number"&&(s={logLevel:s});var u=to("diag"),d=zTe((a=s.logLevel)!==null&&a!==void 0?a:Yn.INFO,i);if(u&&!s.suppressOverrideMessage){var f=(c=new Error().stack)!==null&&c!==void 0?c:"<failed to generate stacktrace>";u.warn("Current logger will be overwritten from "+f),d.warn("Current logger will overwrite one already registered from "+f)}return Tu("diag",d,r,!0)};r.setLogger=n,r.disable=function(){wu(qyt,r)},r.createComponentLogger=function(i){return new BTe(i)},r.verbose=e("verbose"),r.debug=e("debug"),r.info=e("info"),r.warn=e("warn"),r.error=e("error")}return t.instance=function(){return this._instance||(this._instance=new t),this._instance},t})();var Byt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s},zyt=function(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},VTe=(function(){function t(e){this._entries=e?new Map(e):new Map}return t.prototype.getEntry=function(e){var r=this._entries.get(e);if(r)return Object.assign({},r)},t.prototype.getAllEntries=function(){return Array.from(this._entries.entries()).map(function(e){var r=Byt(e,2),n=r[0],i=r[1];return[n,i]})},t.prototype.setEntry=function(e,r){var n=new t(this._entries);return n._entries.set(e,r),n},t.prototype.removeEntry=function(e){var r=new t(this._entries);return r._entries.delete(e),r},t.prototype.removeEntries=function(){for(var e,r,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var s=new t(this._entries);try{for(var o=zyt(n),a=o.next();!a.done;a=o.next()){var c=a.value;s._entries.delete(c)}}catch(l){e={error:l}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return s},t.prototype.clear=function(){return new t},t})();var ycr=Mi.instance();function HTe(t){return t===void 0&&(t={}),new VTe(new Map(Object.entries(t)))}function hC(t){return Symbol.for(t)}var Vyt=(function(){function t(e){var r=this;r._currentContext=e?new Map(e):new Map,r.getValue=function(n){return r._currentContext.get(n)},r.setValue=function(n,i){var s=new t(r._currentContext);return s._currentContext.set(n,i),s},r.deleteValue=function(n){var i=new t(r._currentContext);return i._currentContext.delete(n),i}}return t})(),GTe=new Vyt;var WTe={get:function(t,e){if(t!=null)return t[e]},keys:function(t){return t==null?[]:Object.keys(t)}},YTe={set:function(t,e,r){t!=null&&(t[e]=r)}};var Hyt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s},Gyt=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))},KTe=(function(){function t(){}return t.prototype.active=function(){return GTe},t.prototype.with=function(e,r,n){for(var i=[],s=3;s<arguments.length;s++)i[s-3]=arguments[s];return r.call.apply(r,Gyt([n],Hyt(i),!1))},t.prototype.bind=function(e,r){return r},t.prototype.enable=function(){return this},t.prototype.disable=function(){return this},t})();var Wyt=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s},Yyt=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))},u3="context",Kyt=new KTe,Ru=(function(){function t(){}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalContextManager=function(e){return Tu(u3,e,Mi.instance())},t.prototype.active=function(){return this._getContextManager().active()},t.prototype.with=function(e,r,n){for(var i,s=[],o=3;o<arguments.length;o++)s[o-3]=arguments[o];return(i=this._getContextManager()).with.apply(i,Yyt([e,r,n],Wyt(s),!1))},t.prototype.bind=function(e,r){return this._getContextManager().bind(e,r)},t.prototype._getContextManager=function(){return to(u3)||Kyt},t.prototype.disable=function(){this._getContextManager().disable(),wu(u3,Mi.instance())},t})();var mC;(function(t){t[t.NONE=0]="NONE",t[t.SAMPLED=1]="SAMPLED"})(mC||(mC={}));var d3="0000000000000000",f3="00000000000000000000000000000000",JTe={traceId:f3,spanId:d3,traceFlags:mC.NONE};var Au=(function(){function t(e){e===void 0&&(e=JTe),this._spanContext=e}return t.prototype.spanContext=function(){return this._spanContext},t.prototype.setAttribute=function(e,r){return this},t.prototype.setAttributes=function(e){return this},t.prototype.addEvent=function(e,r){return this},t.prototype.addLink=function(e){return this},t.prototype.addLinks=function(e){return this},t.prototype.setStatus=function(e){return this},t.prototype.updateName=function(e){return this},t.prototype.end=function(e){},t.prototype.isRecording=function(){return!1},t.prototype.recordException=function(e,r){},t})();var p3=hC("OpenTelemetry Context Key SPAN");function gC(t){return t.getValue(p3)||void 0}function ZTe(){return gC(Ru.getInstance().active())}function qb(t,e){return t.setValue(p3,e)}function XTe(t){return t.deleteValue(p3)}function QTe(t,e){return qb(t,new Au(e))}function _C(t){var e;return(e=gC(t))===null||e===void 0?void 0:e.spanContext()}var Jyt=/^([0-9a-f]{32})$/i,Zyt=/^[0-9a-f]{16}$/i;function Xyt(t){return Jyt.test(t)&&t!==f3}function Qyt(t){return Zyt.test(t)&&t!==d3}function yC(t){return Xyt(t.traceId)&&Qyt(t.spanId)}function ewe(t){return new Au(t)}var h3=Ru.getInstance(),SC=(function(){function t(){}return t.prototype.startSpan=function(e,r,n){n===void 0&&(n=h3.active());var i=!!r?.root;if(i)return new Au;var s=n&&_C(n);return eSt(s)&&yC(s)?new Au(s):new Au},t.prototype.startActiveSpan=function(e,r,n,i){var s,o,a;if(!(arguments.length<2)){arguments.length===2?a=r:arguments.length===3?(s=r,a=n):(s=r,o=n,a=i);var c=o??h3.active(),l=this.startSpan(e,s,c),u=qb(c,l);return h3.with(u,a,void 0,l)}},t})();function eSt(t){return typeof t=="object"&&typeof t.spanId=="string"&&typeof t.traceId=="string"&&typeof t.traceFlags=="number"}var tSt=new SC,twe=(function(){function t(e,r,n,i){this._provider=e,this.name=r,this.version=n,this.options=i}return t.prototype.startSpan=function(e,r,n){return this._getTracer().startSpan(e,r,n)},t.prototype.startActiveSpan=function(e,r,n,i){var s=this._getTracer();return Reflect.apply(s.startActiveSpan,s,arguments)},t.prototype._getTracer=function(){if(this._delegate)return this._delegate;var e=this._provider.getDelegateTracer(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):tSt},t})();var rwe=(function(){function t(){}return t.prototype.getTracer=function(e,r,n){return new SC},t})();var rSt=new rwe,m3=(function(){function t(){}return t.prototype.getTracer=function(e,r,n){var i;return(i=this.getDelegateTracer(e,r,n))!==null&&i!==void 0?i:new twe(this,e,r,n)},t.prototype.getDelegate=function(){var e;return(e=this._delegate)!==null&&e!==void 0?e:rSt},t.prototype.setDelegate=function(e){this._delegate=e},t.prototype.getDelegateTracer=function(e,r,n){var i;return(i=this._delegate)===null||i===void 0?void 0:i.getTracer(e,r,n)},t})();var xu;(function(t){t[t.INTERNAL=0]="INTERNAL",t[t.SERVER=1]="SERVER",t[t.CLIENT=2]="CLIENT",t[t.PRODUCER=3]="PRODUCER",t[t.CONSUMER=4]="CONSUMER"})(xu||(xu={}));var aa;(function(t){t[t.UNSET=0]="UNSET",t[t.OK=1]="OK",t[t.ERROR=2]="ERROR"})(aa||(aa={}));var Ic=Ru.getInstance();var g3=Mi.instance();var nwe=(function(){function t(){}return t.prototype.inject=function(e,r){},t.prototype.extract=function(e,r){return e},t.prototype.fields=function(){return[]},t})();var _3=hC("OpenTelemetry Baggage Key");function y3(t){return t.getValue(_3)||void 0}function iwe(){return y3(Ru.getInstance().active())}function swe(t,e){return t.setValue(_3,e)}function owe(t){return t.deleteValue(_3)}var S3="propagation",nSt=new nwe,awe=(function(){function t(){this.createBaggage=HTe,this.getBaggage=y3,this.getActiveBaggage=iwe,this.setBaggage=swe,this.deleteBaggage=owe}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalPropagator=function(e){return Tu(S3,e,Mi.instance())},t.prototype.inject=function(e,r,n){return n===void 0&&(n=YTe),this._getGlobalPropagator().inject(e,r,n)},t.prototype.extract=function(e,r,n){return n===void 0&&(n=WTe),this._getGlobalPropagator().extract(e,r,n)},t.prototype.fields=function(){return this._getGlobalPropagator().fields()},t.prototype.disable=function(){wu(S3,Mi.instance())},t.prototype._getGlobalPropagator=function(){return to(S3)||nSt},t})();var Bb=awe.getInstance();var E3="trace",cwe=(function(){function t(){this._proxyTracerProvider=new m3,this.wrapSpanContext=ewe,this.isSpanContextValid=yC,this.deleteSpan=XTe,this.getSpan=gC,this.getActiveSpan=ZTe,this.getSpanContext=_C,this.setSpan=qb,this.setSpanContext=QTe}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalTracerProvider=function(e){var r=Tu(E3,this._proxyTracerProvider,Mi.instance());return r&&this._proxyTracerProvider.setDelegate(e),r},t.prototype.getTracerProvider=function(){return to(E3)||this._proxyTracerProvider},t.prototype.getTracer=function(e,r){return this.getTracerProvider().getTracer(e,r)},t.prototype.disable=function(){wu(E3,Mi.instance()),this._proxyTracerProvider=new m3},t})();var zb=cwe.getInstance();var sSt=function(t,e){e.recordException(t),e.setStatus({code:aa.ERROR})};var Bf=(function(){function t(e){this._tracer=e,this.startSpan=e.startSpan.bind(this._tracer),this.startActiveSpan=e.startActiveSpan.bind(this._tracer)}return t.prototype.withActiveSpan=function(e,r,n,i){var s=lwe(r,n,i),o=s.opts,a=s.ctx,c=s.fn;return this._tracer.startActiveSpan(e,o,a,function(l){return uwe(l,o,c)})},t.prototype.withSpan=function(e,r,n,i){var s=lwe(r,n,i),o=s.opts,a=s.ctx,c=s.fn,l=this._tracer.startSpan(e,o,a);return uwe(l,o,c)},t})();function lwe(t,e,r){var n,i,s;return!e&&!r?s=t:r?(n=t,i=e,s=r):(n=t,s=e),n=n??{},i=i??Ic.active(),{opts:n,ctx:i,fn:s}}function uwe(t,e,r){var n,i=(n=e.onException)!==null&&n!==void 0?n:sSt,s=function(a){throw i(a,t),t.end(),a};try{var o=r(t);return typeof o?.then=="function"?o.then(function(a){return t.end(),a},s):(t.end(),o)}catch(a){throw s(a)}}_W();et();var hT=class{emit(e){}enabled(){return!1}},TRe=new hT;var mT=Symbol.for("io.opentelemetry.js.api.logs"),Xg=globalThis;function wRe(t,e,r){return n=>n===t?e:r}var yW=1;var SW=class{getLogger(e,r,n){return new hT}},uN=new SW;var dN=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):TRe}};var gT=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new dN(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:uN}_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 fN=class t{constructor(){this._proxyLoggerProvider=new gT}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return Xg[mT]?this.getLoggerProvider():(Xg[mT]=wRe(yW,e,uN),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=Xg[mT])===null||e===void 0?void 0:e.call(Xg,yW))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete Xg[mT],this._proxyLoggerProvider=new gT}};var RRe=fN.getInstance();function ARe(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 xRe(t){t.forEach(e=>e.disable())}function EW(t){let e=t.tracerProvider||Or.getTracerProvider(),r=t.meterProvider||eT.getMeterProvider(),n=t.loggerProvider||RRe.getLoggerProvider(),i=t.instrumentations?.flat()??[];return ARe(i,e,r,n),()=>{xRe(i)}}dr();var $N=Dn(DW(),1);dr();var oAe=t=>{throw TypeError(t)},jW=(t,e,r)=>e.has(t)||oAe("Cannot "+r),kN=(t,e,r)=>(jW(t,e,"read from private field"),r?r.call(t):e.get(t)),MW=(t,e,r)=>e.has(t)?oAe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),nAe=(t,e,r,n)=>(jW(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),PEt=(t,e,r)=>(jW(t,e,"access private method"),r),iAe="__netlify__getTracer",CEt="__netlify__shutdownTracers",NEt="__nfOTLPTrace",yT,ST,FW,aAe,kEt=class{constructor(){MW(this,FW),MW(this,yT),MW(this,ST),nAe(this,yT,new ha(PEt(this,FW,aAe),this)),nAe(this,ST,g3.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(kN(this,ST).debug(`export ${t.length.toString()} spans`),kN(this,yT).isCalled){e({code:Qt.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(NEt,JSON.stringify($Et(t))),e({code:Qt.SUCCESS})}shutdown(){return kN(this,yT).call()}};yT=new WeakMap;ST=new WeakMap;FW=new WeakSet;aAe=function(){return kN(this,ST).debug("Shutting down"),Promise.resolve()};function $Et(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:NN(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||xu.SERVER,startTimeUnixNano:UW(e.startTime),endTimeUnixNano:UW(e.endTime),attributes:NN(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:UW(n.time),attributes:NN(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:NN(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function NN(t){return Object.keys(t).map(e=>cAe(e,t[e]))}function cAe(t,e){return{key:t,value:lAe(e)}}function lAe(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(lAe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>cAe(r,n))}}:{}}function UW(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var sAe={name:"@netlify/otel",version:"6.0.3",type:"module",engines:{node:"^18.14.0 || >=20.6.1"},main:"./dist/main.cjs",module:"./dist/main.js",types:"./dist/main.d.ts",exports:{".":{require:{types:"./dist/main.d.cts",default:"./dist/main.cjs"},import:{types:"./dist/main.d.ts",default:"./dist/main.js"},default:{types:"./dist/main.d.ts",default:"./dist/main.js"}},"./package.json":"./package.json","./bootstrap":{require:{types:"./dist/bootstrap/main.d.cts",default:"./dist/bootstrap/main.cjs"},import:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"},default:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"}},"./exporter-netlify":{require:{types:"./dist/exporters/netlify.d.cts",default:"./dist/exporters/netlify.cjs"},import:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"},default:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"}},"./instrumentation-fetch":{require:{types:"./dist/instrumentations/fetch.d.cts",default:"./dist/instrumentations/fetch.cjs"},import:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"},default:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"}},"./instrumentation-http":{require:{types:"./dist/instrumentations/http.d.cts",default:"./dist/instrumentations/http.cjs"},import:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"},default:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"}},"./opentelemetry":{require:{types:"./dist/opentelemetry.d.cts",default:"./dist/opentelemetry.cjs"},import:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"},default:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"}}},files:["dist/**/*"],scripts:{build:"tsup-node",dev:"tsup-node --watch",prepack:"npm run build",test:"run-s build test:ci","test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"vitest","test:dev:vitest:watch":"vitest watch","test:ci:vitest":"vitest run",publint:"npx -y publint --strict"},keywords:["netlify","cdn"],license:"MIT",repository:{type:"git",url:"https://github.com/netlify/primitives.git",directory:"packages/otel"},bugs:{url:"https://github.com/netlify/primitives/issues"},author:"Netlify Inc.",devDependencies:{"@netlify/dev-utils":"^4.4.6",msw:"^2.10.5","npm-run-all2":"^7.0.2",tsup:"^8.0.0",vitest:"^3.0.0"},dependencies:{"@opentelemetry/api":"1.9.0","@opentelemetry/core":"2.7.1","@opentelemetry/instrumentation":"^0.217.0","@opentelemetry/resources":"2.7.1","@opentelemetry/sdk-trace-node":"2.7.1"}},uAe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,iAe))return;let e=OEt.version.slice(1),r=lN({"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??[LEt()],i=new $N.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new kc});let s=t.instrumentations??[];EW({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,iAe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new Bf(zb.getTracer(a,c)):new Bf(zb.getTracer(sAe.name,sAe.version))}}),Object.defineProperty(globalThis,CEt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},LEt=()=>new $N.SimpleSpanProcessor(new kEt);dr();var ET=Dn(DW(),1);import*as LN from"diagnostics_channel";var dAe=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?aa.ERROR:aa.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 Bf?t:new Bf(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){LN.subscribe(t,e);let r=()=>LN.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:xu.CLIENT},Ic.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:aa.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 Tke=Dn(vke(),1);var mL=ve("tracing"),bke=8e3,gCt=5e3,kw=async(t=gCt)=>{try{await Promise.race([UTe(),mCt(t)])}catch(e){mL.warn("Failed to flush tracers on shutdown",e)}},wke=async(t,e,r)=>{if(!ht()){let n=[new ET.SimpleSpanProcessor(new w9),new ET.SimpleSpanProcessor(new Tke.OTLPTraceExporter({url:r.exporterUrl}))];await uAe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new dAe({skipHeaders:!0})]})}return r.traceparent?(Bb.setGlobalPropagator(new kc),Bb.extract(Ic.active(),{traceparent:r.traceparent,isRemote:!0})):Ic.active()};function Vt(t,e,r){return mL.log(`\u23F3 TRACE: ${e} starting...`),qf(t,e,r)}var w9=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(", ")}]`:"";mL.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&mL.log(` \u274C Error: ${e.status.message}`)}};function R9(){return rt().captureLlmContentEnabled}function Rke(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function gL(t,e,r){let n={role:t,parts:[{type:"text",content:bs(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}function Ake(t,e,r,n){if(!t.length)return;let i=ht();if(!i)return;let s=R9(),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>bke?`${a.message.slice(0,bke)}\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":bs(p)}:{"gen_ai.output.messages":gL("assistant",p)}:{}}}).end(u)})}import{readdir as _Ct,rm as yCt}from"fs/promises";import{join as SCt}from"path";async function xke(t,e=[]){let n=(await _Ct(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>yCt(SCt(t,i),{recursive:!0,force:!0})))}var ECt=700,Ike=t=>t.mode==="create"&&(t.accountType===wl||t.enforcedAICreditsRemaining!=null&&t.enforcedAICreditsRemaining<=ECt);var TCt=yL.dirname(vCt(import.meta.url)),Pke=bCt(import.meta.url),wCt=yL.resolve(TCt,"scripts/scaffold.js"),RCt="scripts/scaffold.js",ACt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,A9=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},xCt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),ICt=t=>{let e=A9(t);return e==="node"||e.endsWith("/node")},el=t=>{if(typeof t!="string")return!1;let e=t.match(ACt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&xCt(A9(e[r]));)r+=1;if(r>=e.length||!ICt(e[r]))return!1;let n=e[r+1];return n?A9(n).includes(RCt):!1},K_=ve("create_stage"),Oke="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.",PCt=`${Oke}
|
|
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.`,OCt=`${Oke}
|
|
584
584
|
|
|
@@ -695,7 +695,7 @@ ${o.trim()}
|
|
|
695
695
|
toolName = "web_fetch"
|
|
696
696
|
decision = "allow"
|
|
697
697
|
priority = 10
|
|
698
|
-
`,"utf-8"));let b=[oa(a,"gemini"),...d?["--model",d]:[],...O?["--approval-mode","default","--policy",A]:["--yolo"],"--skip-trust","--output-format","stream-json",...R?["-r",o]:[],"-p",""],$=`${Wy.env.NVM_BIN}/node`;Jr.log(`Running ${$} ${b.join(" ")}`);let C=e.utils.run($,b,{all:!0,env:Wy.env,cwd:a,idleTimeout:Ha,cancelSignal:c});C.stdin?.end(u);let T=Rl(()=>{r?.({steps:f,duration:y}),n?.({steps:p,duration:y}),p=[]},250),I=($e,z)=>{$e.id=_,_+=1,h.push($e),f.push($e),p.push($e),z||T.flush(),T(),z&&T.flush()};I({title:`Using ${EJ} with ${d||"default"}`,category:ne.Environment},!0);let F=vkt.createInterface({input:C.all});F.on("error",$e=>{Jr.error("Readline interface error",{error:$e.message,stack:$e.stack})});let V="",oe=()=>{V&&I({message:V.trim(),category:ne.AgentMessage}),V=""};F.on("line",$e=>{let z;try{if($e.startsWith("[API Error")){let ye=$e.match(/\[api error: (.+?)]$/i)?.[1];z={type:"error",value:$S(ye,!1)?.error?.message||ye||"Gemini encountered error"}}else z=JSON.parse($e)}catch{return}if(z)switch(z.type==="init"&&typeof z.session_id=="string"&&(w=z.session_id,l?.(w)),["message","result"].includes(z.type)||oe(),z.type){case"message":{z.role!=="user"&&z.content&&(V+=z.content);break}case"tool_use":{if(z.tool_name===mme){if(Jr.info("Gemini ask came in"),z.tool_id&&!P){Jr.info("About to parse");let M=wg.safeParse(z.parameters);M.success?(Jr.info("Parse successful"),P={questions:M.data.questions,toolUseId:z.tool_id},Jr.info("trying to kill process"),C.kill()):(Jr.warn("Ignoring malformed ask tool input",{toolUseId:z.tool_id}),Se.inc("inference.malformed_ask",1))}break}let ye=SJ[z.tool_name]?.name??z.tool_name,Ce=z.parameters?.file_path,k=Ce&&yd.relative(a,Ce),D=z.parameters?.command,te=z.tool_name==="activate_skill"&&z.parameters?.name,q=z.tool_name==="run_shell_command"&&el(D),me=[ye,k&&`\`${k}\``,D&&`\`${D}\``].filter(Boolean).join(" ");if(te)me=`Use ${ko(te)}`;else if(q)me="Generating the site";else if(z.tool_name==="grep_search"){let{dir_path:M,pattern:U}=z.parameters||{};M&&U?me=`Search in \`${M}\` for \`${U}\``:M?me=`Search in \`${M}\``:U&&(me=`Search for \`${U}\``)}else if(z.tool_name==="update_topic"){let M=z.parameters?.title;M&&(me=`${ye} \`${M}\``)}let J={title:me,category:q?ne.SiteGeneration:SJ[z.tool_name]?.category,...te&&{type:te}};m[z.tool_id]=J,T.flush();break}case"tool_result":{let ye=m[z.tool_id];ye&&(z.output&&(ye.message=`\`\`\`
|
|
698
|
+
`,"utf-8"));let b=[oa(a,"gemini"),...d?["--model",d]:[],...O?["--approval-mode","default","--policy",A]:["--yolo"],"--skip-trust","--output-format","stream-json",...R?["-r",o]:[],"-p",""],$=`${Wy.env.NVM_BIN}/node`;Jr.log(`Running ${$} ${b.join(" ")}`);let C=e.utils.run($,b,{all:!0,env:{...Wy.env,GEMINI_CLI_NO_RELAUNCH:"1"},cwd:a,idleTimeout:Ha,cancelSignal:c});C.stdin?.end(u);let T=Rl(()=>{r?.({steps:f,duration:y}),n?.({steps:p,duration:y}),p=[]},250),I=($e,z)=>{$e.id=_,_+=1,h.push($e),f.push($e),p.push($e),z||T.flush(),T(),z&&T.flush()};I({title:`Using ${EJ} with ${d||"default"}`,category:ne.Environment},!0);let F=vkt.createInterface({input:C.all});F.on("error",$e=>{Jr.error("Readline interface error",{error:$e.message,stack:$e.stack})});let V="",oe=()=>{V&&I({message:V.trim(),category:ne.AgentMessage}),V=""};F.on("line",$e=>{let z;try{if($e.startsWith("[API Error")){let ye=$e.match(/\[api error: (.+?)]$/i)?.[1];z={type:"error",value:$S(ye,!1)?.error?.message||ye||"Gemini encountered error"}}else z=JSON.parse($e)}catch{return}if(z)switch(z.type==="init"&&typeof z.session_id=="string"&&(w=z.session_id,l?.(w)),["message","result"].includes(z.type)||oe(),z.type){case"message":{z.role!=="user"&&z.content&&(V+=z.content);break}case"tool_use":{if(z.tool_name===mme){if(Jr.info("Gemini ask came in"),z.tool_id&&!P){Jr.info("About to parse");let M=wg.safeParse(z.parameters);M.success?(Jr.info("Parse successful"),P={questions:M.data.questions,toolUseId:z.tool_id},Jr.info("trying to kill process"),C.kill()):(Jr.warn("Ignoring malformed ask tool input",{toolUseId:z.tool_id}),Se.inc("inference.malformed_ask",1))}break}let ye=SJ[z.tool_name]?.name??z.tool_name,Ce=z.parameters?.file_path,k=Ce&&yd.relative(a,Ce),D=z.parameters?.command,te=z.tool_name==="activate_skill"&&z.parameters?.name,q=z.tool_name==="run_shell_command"&&el(D),me=[ye,k&&`\`${k}\``,D&&`\`${D}\``].filter(Boolean).join(" ");if(te)me=`Use ${ko(te)}`;else if(q)me="Generating the site";else if(z.tool_name==="grep_search"){let{dir_path:M,pattern:U}=z.parameters||{};M&&U?me=`Search in \`${M}\` for \`${U}\``:M?me=`Search in \`${M}\``:U&&(me=`Search for \`${U}\``)}else if(z.tool_name==="update_topic"){let M=z.parameters?.title;M&&(me=`${ye} \`${M}\``)}let J={title:me,category:q?ne.SiteGeneration:SJ[z.tool_name]?.category,...te&&{type:te}};m[z.tool_id]=J,T.flush();break}case"tool_result":{let ye=m[z.tool_id];ye&&(z.output&&(ye.message=`\`\`\`
|
|
699
699
|
${z.output.trim()}
|
|
700
700
|
\`\`\``),I(ye,!0),wkt(ye));break}case"result":{y=z.stats?.duration_ms,z.stats&&(ea(z.stats),g=z.stats),z.status==="error"?S=z.error?.message:v=V.trim();break}case"error":{S=z.error;break}case"finished":break;case"init":break;default:{Jr.warn("Unhandled message type:",z.type);break}}});let pe=!1;if(await C.catch($e=>{pe=Hm($e,c),{error:S,result:v}=bkt({catchError:$e,runCmd:C,error:S,result:v,runnerName:"Gemini"})}),F.close(),P)return T.flush(),{steps:h,duration:y,agentSessionId:w,resolvedModel:d,usage:g,pendingInteraction:P};let xe=pe;return xe&&(!v&&V.trim()&&(v=V.trim()),S=void 0),T.flush(),{steps:h,duration:y,result:await mu({initialResult:v,agentName:EJ,hasError:!!S}),error:gu({error:S,agentName:EJ}),isRetryableError:_u(S),isProviderUnavailableError:yu(S),resolvedModel:d,usage:g,agentSessionId:w,...xe?{aborted:!0}:{}}}var Z$e=async()=>{let t=yd.join(a0.homedir(),".gemini");await Jp.rm(t,{recursive:!0,force:!0});let e=yd.join(a0.homedir(),".agents","skills");await Jp.rm(e,{recursive:!0,force:!0})},X$e={baseDir:yd.join(a0.homedir(),".gemini"),include:["tmp"]};import Pkt from"fs/promises";import nLe from"os";import TJ from"path";import XL from"process";import Okt from"readline";import xkt from"os";import tLe from"path";import bJ from"fs";var Q$e=ve("opencode_install"),eLe="1.17.19",Ikt=()=>tLe.join(xkt.homedir(),".netlify-agent-runner","opencode"),rLe=async t=>{let e=oa(t,"opencode");if(e)return e;let r=Ikt(),n=tLe.join(r,"node_modules",".bin","opencode");if(bJ.existsSync(n))return n;bJ.mkdirSync(r,{recursive:!0}),Q$e.log(`Installing opencode-ai@${eLe} on demand`);let i=Date.now();await Wn("npm",["install","--no-save","--no-audit","--no-fund","--prefix",r,`opencode-ai@${eLe}`],{cwd:r});let s=Date.now()-i;if(Se.timing("opencode.install_duration",s),Q$e.log(`Installed opencode-ai in ${s}ms`),!bJ.existsSync(n))throw new Error("OpenCode CLI binary not found after installing opencode-ai");return n};var dl=ve("runner_opencode"),ZL="OpenCode",iLe="gateway",Ckt="z-ai/glm-5.2",sLe={bash:{name:"Run command",category:ne.RunCommand},read:{name:"Read file",category:ne.FileRead},write:{name:"Edit file",category:ne.FileWrite},edit:{name:"Edit file",category:ne.FileWrite},glob:{name:"Find files",category:ne.Explore},grep:{name:"Search files",category:ne.Explore},list:{name:"List directory",category:ne.Explore},task:{name:"Task",category:ne.Task},todowrite:{name:"Update task list",category:ne.Todo},webfetch:{name:"Fetch web",category:ne.Web},websearch:{name:"Search web",category:ne.Web},skill:{name:"Use Skill",category:ne.Skill}},Nkt=t=>sLe[t]?.name||t,kkt=({catchError:t,runCmd:e,error:r,result:n,runnerName:i})=>(dl.log(`${i} command completed with catch handler triggered`,{hadExistingError:!!r,hadExistingResult:!!n,resultLength:n?n.length:0,catchError:t?.message||"No error object",processExitCode:e.exitCode,processKilled:e.killed}),n?(dl.log("Preserving existing result despite catch handler being triggered"),r?{error:r,result:n}:{error:"Process completed with errors but result was captured",result:n}):(dl.log("Setting result to undefined because no valid result was captured"),{error:r||`${i} failed`,result:void 0}));async function $kt({aiGateway:t,config:e,model:r}){let n=r;if(t){let i=t.isModelAvailable;if(!i)throw new Error("OpenCode runner requires a gateway with isModelAvailable support");let s=e.modelVersionOverrides?.opencode?.[e.accountType];s?n=s:r||(n=rt().opencodeDefaultModel||Ckt),n&&(await i(n)||dl.log(`Model '${n}' not found in gateway catalog; proceeding anyway (gateway is authoritative, e.g. flag-gated OpenRouter models)`))}return n}function Lkt({aiGateway:t,model:e}){if(!t)throw new Error("OpenCode runner requires the AI gateway");let{token:r,url:n}=t;if(!r||!n)throw new Error("No token or url provided from AI Gateway");let i=e?{[e]:{id:e,name:e,tool_call:!0,reasoning:!0,interleaved:{field:"reasoning_details"}}}:{},s={$schema:"https://opencode.ai/config.json",provider:{[iLe]:{api:"openai",name:"Netlify AI Gateway",options:{apiKey:r,baseURL:n},...Object.keys(i).length>0?{models:i}:{}}}};XL.env.OPENCODE_CONFIG_CONTENT=JSON.stringify(s),XL.env.OPENCODE_DISABLE_AUTOUPDATE="1"}async function wJ({config:t,netlify:e,persistSteps:r,aiGateway:n,continueSession:i,priorAgentSessionId:s,cwd:o=XL.cwd()}){let{prompt:a}=t,{model:c}=t,l="",u,d,f,p=await $kt({config:t,aiGateway:n,model:c});Lkt({aiGateway:n,model:p});let h=[],m=0,_=Date.now(),y=await rLe(o),v=["run","--format","json","--dangerously-skip-permissions","--agent","build",...p?["--model",`${iLe}/${p}`]:[],...i?s?["--session",s]:["--continue"]:[]];dl.log(`Running ${y} ${v.join(" ")}`);let S=e.utils.run(y,v,{all:!0,env:XL.env,cwd:o,idleTimeout:Ha});S.stdin?.end(a);let g=Rl(()=>{r?.({steps:h,duration:Date.now()-_})},250),w=(C,T)=>{let{wrapMessage:I,...N}=C,F=J0({...N,id:m});F.message&&I&&(F.message=`\`\`\`
|
|
701
701
|
${F.message}
|
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:xD},xNe=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},wNe={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:xNe};import{Buffer as ANe}from"buffer";var WQ=(t,e)=>t?void 0:RNe.bind(void 0,e),RNe=function*(t,e){if(typeof e!="string"&&!jt(e)&&!ANe.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},YQ=(t,e)=>t?INe.bind(void 0,e):CNe.bind(void 0,e),INe=function*(t,e){KQ(t,e),yield e},CNe=function*(t,e){if(KQ(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},KQ=(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 PNe}from"buffer";import{StringDecoder as ONe}from"string_decoder";var xx=(t,e,r)=>{if(r)return;if(t)return{transform:NNe.bind(void 0,new TextEncoder)};let n=new ONe(e);return{transform:kNe.bind(void 0,n),final:MNe.bind(void 0,n)}},NNe=function*(t,e){PNe.isBuffer(e)?yield fs(e):typeof e=="string"?yield t.encode(e):yield e},kNe=function*(t,e){yield jt(e)?t.write(e):e},MNe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as ZQ}from"util";var AD=ZQ(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),wx=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=LNe}=e[r];for await(let i of n(t))yield*wx(i,e,r+1)},JQ=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*DNe(r,Number(e),t)},DNe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*wx(n,r,e+1)},XQ=ZQ(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),LNe=function*(t){yield t};var RD=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},QQ=(t,e)=>[...e.flatMap(r=>[...xl(r,t,0)]),...s_(t)],xl=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=UNe}=e[r];for(let i of n(t))yield*xl(i,e,r+1)},s_=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*$Ne(r,Number(e),t)},$Ne=function*(t,e,r){if(t!==void 0)for(let n of t())yield*xl(n,r,e+1)},UNe=function*(t){yield t};var ID=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=t7(t,s,o),l=Tl(e),u=Tl(r),d=l?AD.bind(void 0,wx,a):RD.bind(void 0,xl),f=l||u?AD.bind(void 0,JQ,a):RD.bind(void 0,s_),p=l||u?XQ.bind(void 0,a):void 0;return{stream:new FNe({writableObjectMode:n,writableHighWaterMark:e7(n),readableObjectMode:i,readableHighWaterMark:e7(i),transform(m,y,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:p})}},Ax=(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=t7(s,r,a);t=QQ(c,t)}return t},t7=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:WQ(n,a)},xx(r,s,n),Tx(r,o,n,c),{transform:t,final:e},{transform:YQ(i,a)},HQ({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var r7=(t,e)=>{for(let r of BNe(t))jNe(t,r,e)},BNe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),jNe=(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=>zNe(a,n));r.input=Zg(s)},zNe=(t,e)=>{let r=Ax(t,e,"utf8",!0);return GNe(r),Zg(r)},GNe=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 WNe,appendFileSync as YNe}from"fs";var Rx=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Bd(r,n)&&!_n.has(e)&&qNe(n)&&(t.some(({type:i,value:o})=>i==="native"&&VNe.has(o))||t.every(({type:i})=>Vn.has(i))),qNe=t=>t===1||t===2,VNe=new Set(["pipe","overlapped"]),n7=async(t,e,r,n)=>{for await(let i of t)HNe(e)||o7(i,r,n)},i7=(t,e,r)=>{for(let n of t)o7(n,e,r)},HNe=t=>t._readableState.pipes.length>0,o7=(t,e,r)=>{let n=jT(t);co({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var s7=({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)=>KNe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},KNe=({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=aQ(t,o,d),p=fs(f),{stdioItems:h,objectMode:m}=e[r],y=ZNe([p],h,c,n),{serializedResult:S,finalResult:T=S}=JNe({chunks:y,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});XNe({serializedResult:S,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let x=a[r]?T:void 0;try{return n.error===void 0&&QNe(S,h,i),x}catch(v){return n.error=v,x}},ZNe=(t,e,r,n)=>{try{return Ax(t,e,r,!1)}catch(i){return n.error=i,t}},JNe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Zg(t)};let s=v9(t,r);return n[o]?{serializedResult:s,finalResult:wD(s,!i[o],e)}:{serializedResult:s}},XNe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!Rx({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=wD(t,!1,s);try{i7(a,e,n)}catch(c){r.error??=c}},QNe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>vx.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?YNe(n,t):(r.add(o),WNe(n,t))}};var a7=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,ms(e,r,"all")]:Array.isArray(e)?[ms(t,r,"all"),...e]:jt(t)&&jt(e)?MM([t,e]):`${t}${e}`};import{once as CD}from"events";var c7=async(t,e)=>{let[r,n]=await eke(t);return e.isForcefullyTerminated??=!1,[r,n]},eke=async t=>{let[e,r]=await Promise.allSettled([CD(t,"spawn"),CD(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?l7(t):r.value},l7=async t=>{try{return await CD(t,"exit")}catch{return l7(t)}},u7=async t=>{let[e,r]=await t;if(!tke(e,r)&&PD(e,r))throw new Ti;return[e,r]},tke=(t,e)=>t===void 0&&e===void 0,PD=(t,e)=>t!==0||e!==null;var d7=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=rke(t,e,r),s=o?.code==="ETIMEDOUT",a=sQ(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},rke=(t,e,r)=>t!==void 0?t:PD(e,r)?new Ti:void 0;var f7=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=ike(t,e,r),d=ake({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Zd(d,c,l)},ike=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=GT(t,e,r),a=oke(r),{file:c,commandArguments:l,options:u}=lx(t,e,a);ske(u);let d=zQ(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},oke=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,ske=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&Ix("ipcInput"),t&&Ix("ipc: true"),r&&Ix("detached: true"),n&&Ix("cancelSignal")},Ix=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},ake=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=cke({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}=d7(c,r),{output:h,error:m=l}=s7({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),y=h.map((T,x)=>ms(T,r,x)),S=ms(a7(h,r),r,"all");return uke({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:y,all:S,options:r,command:n,escapedCommand:i,startTime:a})},cke=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{r7(o,r);let a=lke(r);return nke(...ux(t,e,a))}catch(a){return Kd({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},lke=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:_x(e)}),uke=({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?yx({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):o_({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 JMe}from"events";import{spawn as XMe}from"child_process";import _7 from"process";import{once as OD,on as dke}from"events";var p7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Gd({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:nx(t)}),fke({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),fke=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{QT(e,i);let o=Ca(t,e,r),s=new AbortController;try{return await Promise.race([pke(o,n,s),hke(o,r,s),mke(o,r,s)])}catch(a){throw qd(t),a}finally{s.abort(),ex(e,i)}},pke=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await OD(t,"message",{signal:r});return n}for await(let[n]of dke(t,"message",{signal:r}))if(e(n))return n},hke=async(t,e,{signal:r})=>{await OD(t,"disconnect",{signal:r}),QJ(e)},mke=async(t,e,{signal:r})=>{let[n]=await OD(t,"strict:error",{signal:r});throw ZT(n,e)};import{once as m7,on as gke}from"events";var g7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>ND({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),ND=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Gd({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:nx(t)}),QT(e,o);let s=Ca(t,e,r),a=new AbortController,c={};return _ke(t,s,a),yke({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),Ske({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},_ke=async(t,e,r)=>{try{await m7(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},yke=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await m7(t,"strict:error",{signal:r.signal});n.error=ZT(i,e),r.abort()}catch{}},Ske=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of gke(r,"message",{signal:o.signal}))h7(s),yield c}catch{h7(s)}finally{o.abort(),ex(e,a),n||qd(t),i&&await t}},h7=({error:t})=>{if(t)throw t};var y7=(t,{ipc:e})=>{Object.assign(t,E7(t,!1,e))},S7=()=>{let t=_7,e=!0,r=_7.channel!==void 0;return{...E7(t,e,r),getCancelSignal:AX.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},E7=(t,e,r)=>({sendMessage:ax.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:p7.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:g7.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Eke}from"child_process";import{PassThrough as vke,Readable as bke,Writable as Tke,Duplex as xke}from"stream";var v7=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{bD(n);let a=new Eke;wke(a,n),Object.assign(a,{readable:Ake,writable:Rke,duplex:Ike});let c=Kd({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=Cke(c,s,i);return{subprocess:a,promise:l}},wke=(t,e)=>{let r=a_(),n=a_(),i=a_(),o=Array.from({length:e.length-3},a_),s=a_(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},a_=()=>{let t=new vke;return t.end(),t},Ake=()=>new bke({read(){}}),Rke=()=>new Tke({write(){}}),Ike=()=>new xke({read(){},write(){}}),Cke=async(t,e,r)=>Zd(t,e,r);import{createReadStream as b7,createWriteStream as T7}from"fs";import{Buffer as Pke}from"buffer";import{Readable as c_,Writable as Oke,Duplex as Nke}from"stream";var w7=(t,e)=>bx(kke,t,e,!1),l_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Pa[t]}.`)},x7={fileNumber:l_,generator:ID,asyncGenerator:ID,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Nke.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},kke={input:{...x7,fileUrl:({value:t})=>({stream:b7(t)}),filePath:({value:{file:t}})=>({stream:b7(t)}),webStream:({value:t})=>({stream:c_.fromWeb(t)}),iterable:({value:t})=>({stream:c_.from(t)}),asyncIterable:({value:t})=>({stream:c_.from(t)}),string:({value:t})=>({stream:c_.from(t)}),uint8Array:({value:t})=>({stream:c_.from(Pke.from(t))})},output:{...x7,fileUrl:({value:t})=>({stream:T7(t)}),filePath:({value:{file:t,append:e}})=>({stream:T7(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Oke.fromWeb(t)}),iterable:l_,asyncIterable:l_,string:l_,uint8Array:l_}};import{on as Mke,once as A7}from"events";import{PassThrough as Dke,getDefaultHighWaterMark as Lke}from"stream";import{finished as C7}from"stream/promises";function wl(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)MD(i);let e=t.some(({readableObjectMode:i})=>i),r=$ke(t,e),n=new kD({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var $ke=(t,e)=>{if(t.length===0)return Lke(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},kD=class extends Dke{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(MD(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Uke(this,this.#e,this.#o);let r=jke({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(MD(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)}},Uke=async(t,e,r)=>{Cx(t,R7);let n=new AbortController;try{await Promise.race([Fke(t,n),Bke(t,e,r,n)])}finally{n.abort(),Cx(t,-R7)}},Fke=async(t,{signal:e})=>{try{await C7(t,{signal:e,cleanup:!0})}catch(r){throw P7(t,r),r}},Bke=async(t,e,r,{signal:n})=>{for await(let[i]of Mke(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},MD=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},jke=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{Cx(t,I7);let a=new AbortController;try{await Promise.race([zke(o,e,a),Gke({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),qke({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),Cx(t,-I7)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?DD(t):Vke(t))},zke=async(t,e,{signal:r})=>{try{await t,r.aborted||DD(e)}catch(n){r.aborted||P7(e,n)}},Gke=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await C7(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;O7(s)?i.add(e):N7(t,s)}},qke=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await A7(t,i,{signal:o}),!t.readable)return A7(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},Vke=t=>{t.writable&&t.end()},P7=(t,e)=>{O7(e)?DD(t):N7(t,e)},O7=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",DD=t=>{(t.readable||t.writable)&&t.destroy()},N7=(t,e)=>{t.destroyed||(t.once("error",Hke),t.destroy(e))},Hke=()=>{},Cx=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},R7=2,I7=1;import{finished as k7}from"stream/promises";var Xd=(t,e)=>{t.pipe(e),Wke(t,e),Yke(t,e)},Wke=async(t,e)=>{if(!(bi(t)||bi(e))){try{await k7(t,{cleanup:!0,readable:!0,writable:!1})}catch{}LD(e)}},LD=t=>{t.writable&&t.end()},Yke=async(t,e)=>{if(!(bi(t)||bi(e))){try{await k7(e,{cleanup:!0,readable:!1,writable:!0})}catch{}$D(t)}},$D=t=>{t.readable&&t.destroy()};var M7=(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})=>Vn.has(c)))Kke(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Vn.has(c)))Jke({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]:wl(o);Xd(s,i)}},Kke=(t,e,r,n)=>{r==="output"?Xd(t.stdio[n],e):Xd(e,t.stdio[n]);let i=Zke[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},Zke=["stdin","stdout","stderr"],Jke=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;Xke(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},Xke=(t,{signal:e})=>{bi(t)&&vl(t,Qke,e)},Qke=2;import{addAbortListener as rMe}from"events";var Al=[];Al.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Al.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Al.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var Px=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",UD=Symbol.for("signal-exit emitter"),FD=globalThis,eMe=Object.defineProperty.bind(Object),BD=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(FD[UD])return FD[UD];eMe(FD,UD,{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}},Ox=class{},tMe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),jD=class extends Ox{onExit(){return()=>{}}load(){}unload(){}},zD=class extends Ox{#e=GD.platform==="win32"?"SIGINT":"SIGHUP";#r=new BD;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Al)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(!Px(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 Al)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,Al.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 Px(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"&&Px(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)}},GD=globalThis.process,{onExit:D7,load:Lpt,unload:$pt}=tMe(Px(GD)?new zD(GD):new jD);var L7=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=D7(()=>{t.kill()});rMe(n,()=>{i()})};var U7=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=zT(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=nMe(r,n,i),{sourceStream:d,sourceError:f}=oMe(t,l),{options:p,fileDescriptors:h}=uo.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},nMe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=iMe(t,e,...r),a=XT(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},iMe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e($7,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||NM(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]=NT(r,...n);return{destination:e($7)(i,o,s),pipeOptions:s}}if(uo.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}`)},$7=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),oMe=(t,e)=>{try{return{sourceStream:Vd(t,e)}}catch(r){return{sourceError:r}}};var B7=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=sMe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw qD({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},sMe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return $D(t),n;if(e!==void 0)return LD(r),e},qD=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Kd({error:t,command:F7,escapedCommand:F7,fileDescriptors:e,options:r,startTime:n,isSync:!1}),F7="source.pipe(destination)";var j7=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 aMe}from"stream/promises";var z7=(t,e,r)=>{let n=Nx.has(e)?lMe(t,e):cMe(t,e);return vl(t,dMe,r.signal),vl(e,fMe,r.signal),uMe(e),n},cMe=(t,e)=>{let r=wl([t]);return Xd(r,e),Nx.set(e,r),r},lMe=(t,e)=>{let r=Nx.get(e);return r.add(t),r},uMe=async t=>{try{await aMe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}Nx.delete(t)},Nx=new WeakMap,dMe=2,fMe=1;import{aborted as pMe}from"util";var G7=(t,e)=>t===void 0?[]:[hMe(t,e)],hMe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await pMe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw qD({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var kx=(t,...e)=>{if(Ct(e[0]))return kx.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=U7(t,...e),i=mMe({...n,destination:r});return i.pipe=kx.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},mMe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=gMe(t,i);B7({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=z7(e,o,d);return await Promise.race([j7(u),...G7(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},gMe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as TMe}from"timers/promises";import{on as _Me}from"events";import{getDefaultHighWaterMark as yMe}from"stream";var Mx=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return SMe(e,s),V7({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},SMe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},VD=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;EMe(e,s,t);let a=t.readableObjectMode&&!o;return V7({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},EMe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},V7=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=_Me(t,"data",{signal:e.signal,highWaterMark:q7,highWatermark:q7});return vMe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},HD=yMe(!0),q7=HD,vMe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=bMe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*xl(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*s_(a)}},bMe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[xx(t,r,!e),Tx(t,i,!n,{})].filter(Boolean);var H7=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=xMe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([wMe(t),d]);return}let f=TD(c,r),p=VD({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([AMe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},xMe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!Rx({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=VD({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await n7(a,t,r,o)},wMe=async t=>{await TMe(),t.readableFlowing===null&&t.resume()},AMe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await hx(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await mx(r,{maxBuffer:o})):await Yd(r,{maxBuffer:o})}catch(a){return W7(nQ({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},WD=async t=>{try{return await t}catch(e){return W7(e)}},W7=({bufferedData:t})=>S9(t)?new Uint8Array(t):t;import{finished as RMe}from"stream/promises";var u_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=IMe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],RMe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||OMe(a,e,r,n)}finally{s.abort()}},IMe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&CMe(t,r,n),n},CMe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{PMe(e,r),n.call(t,...i)}},PMe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},OMe=(t,e,r,n)=>{if(!NMe(t,e,r,n))throw t},NMe=(t,e,r,n=!0)=>r.propagating?Y7(t)||Dx(t):(r.propagating=!0,YD(r,e)===n?Y7(t):Dx(t)),YD=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",Dx=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Y7=t=>t?.code==="EPIPE";var K7=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>KD({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),KD=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=u_(t,e,l);if(YD(l,e)){await u;return}let[d]=await Promise.all([H7({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 Z7=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?wl([t,e].filter(Boolean)):void 0,J7=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>KD({...kMe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:MMe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),kMe=({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}},MMe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as DMe}from"events";var X7=t=>Bd(t,"ipc"),Q7=(t,e)=>{let r=jT(t);co({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var eee=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=X7(o),a=ps(e,"ipc"),c=ps(r,"ipc");for await(let l of ND({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(iQ(t,i,c),i.push(l)),s&&Q7(l,o);return i},tee=async(t,e)=>(await Promise.allSettled([t]),e);var ree=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:y,controller:S})=>{let T=c7(t,f),x={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:T,propagating:!1},v=K7({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:x}),N=J7({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:x}),R=[],U=eee({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:R,verboseInfo:p}),C=LMe(m,t,x),D=$Me(h,x);try{return await Promise.race([Promise.all([{},u7(T),Promise.all(v),N,U,LX(t,d),...C,...D]),y,UMe(t,S),...OX(t,o,f,S),...XJ({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:S}),...CX({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(j){return f.terminationReason??="other",Promise.all([{error:j},T,Promise.all(v.map(_=>WD(_))),WD(N),tee(U,R),Promise.allSettled(C),Promise.allSettled(D)])}},LMe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:u_(n,i,r)),$Me=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>wi(o,{checkOpen:!1})&&!bi(o)).map(({type:i,value:o,stream:s=o})=>u_(s,n,e,{isSameDirection:Vn.has(i),stopOnExit:i==="native"}))),UMe=async(t,{signal:e})=>{let[r]=await DMe(t,"error",{signal:e});throw r};var nee=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),d_=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=lo();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Qd=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 FMe}from"stream";import{callbackify as BMe}from"util";import{finished as iee}from"stream/promises";var ZD=async t=>{if(t!==void 0)try{await JD(t)}catch{}},oee=async t=>{if(t!==void 0)try{await XD(t)}catch{}},JD=async t=>{await iee(t,{cleanup:!0,readable:!1,writable:!0})},XD=async t=>{await iee(t,{cleanup:!0,readable:!0,writable:!1})},Lx=async(t,e)=>{if(await t,e)throw e},$x=(t,e,r)=>{r&&!Dx(r)?t.destroy(r):e&&t.destroy()};var see=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||_n.has(r),{subprocessStdout:a,waitReadableDestroy:c}=QD(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=eL(a,s),{read:f,onStdoutDataDone:p}=tL({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new FMe({read:f,destroy:BMe(nL.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return rL({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},QD=(t,e,r)=>{let n=Vd(t,e),i=d_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},eL=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:HD},tL=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=lo(),s=Mx({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){jMe(this,s,o)},onStdoutDataDone:o}},jMe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},rL=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await XD(t),await n,await ZD(i),await e,r.readable&&r.push(null)}catch(o){await ZD(i),aee(r,o)}},nL=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Qd(r,e)&&(aee(t,n),await Lx(e,n))},aee=(t,e)=>{$x(t,t.readable,e)};import{Writable as zMe}from"stream";import{callbackify as cee}from"util";var lee=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=iL(t,r,e),s=new zMe({...oL(n,t,i),destroy:cee(aL.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return sL(n,s),s},iL=(t,e,r)=>{let n=XT(t,e),i=d_(r,n,"writableFinal"),o=d_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},oL=(t,e,r)=>({write:GMe.bind(void 0,t),final:cee(qMe.bind(void 0,t,e,r))}),GMe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},qMe=async(t,e,r)=>{await Qd(r,e)&&(t.writable&&t.end(),await e)},sL=async(t,e,r)=>{try{await JD(t),e.writable&&e.end()}catch(n){await oee(r),uee(e,n)}},aL=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Qd(r,e),await Qd(n,e)&&(uee(t,i),await Lx(e,i))},uee=(t,e)=>{$x(t,t.writable,e)};import{Duplex as VMe}from"stream";import{callbackify as HMe}from"util";var dee=({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}=QD(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=iL(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=eL(c,a),{read:y,onStdoutDataDone:S}=tL({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),T=new VMe({read:y,...oL(u,t,d),destroy:HMe(WMe.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 rL({subprocessStdout:c,onStdoutDataDone:S,readable:T,subprocess:t,subprocessStdin:u}),sL(u,T,c),T},WMe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([nL({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),aL({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var cL=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||_n.has(e),s=Vd(t,r),a=Mx({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return YMe(a,s,t)},YMe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var fee=(t,{encoding:e})=>{let r=nee();t.readable=see.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=lee.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=dee.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=cL.bind(void 0,t,e),t[Symbol.asyncIterator]=cL.bind(void 0,t,e,{})};var pee=(t,e)=>{for(let[r,n]of ZMe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},KMe=(async()=>{})().constructor.prototype,ZMe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(KMe,t)]);var hee=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=QMe(t,e,r),{subprocess:f,promise:p}=tDe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=kx.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),pee(f,p),uo.set(f,{options:u,fileDescriptors:d}),f},QMe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=GT(t,e,r),{file:a,commandArguments:c,options:l}=lx(t,e,r),u=eDe(l),d=w7(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},eDe=({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}},tDe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=XMe(...ux(t,e,r))}catch(h){return v7({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;JMe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];M7(c,a,l),L7(c,r,l);let d={},f=lo();c.kill=ZJ.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Z7(c,r),fee(c,r),y7(c,r);let p=rDe({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}},rDe=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,y]=await ree({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let S=h.map((v,N)=>ms(v,e,N)),T=ms(m,e,"all"),x=nDe({errorInfo:d,exitCode:f,signal:p,stdio:S,all:T,ipcOutput:y,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Zd(x,n,e)},nDe=({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?o_({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 fo,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):yx({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var Ux=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,iDe(n,t[n],i)]));return{...t,...r}},iDe=(t,e,r)=>oDe.has(t)&&Ct(e)&&Ct(r)?{...e,...r}:r,oDe=new Set(["env",...UM]);var Oa=(t,e,r,n)=>{let i=(s,a,c)=>Oa(s,a,r,c),o=(...s)=>sDe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},sDe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Ct(o))return i(t,Ux(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=aDe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?f7(a,c,l):hee(a,c,l,i)},aDe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=w9(e)?A9(e,r):[e,...r],[s,a,c]=NT(...o),l=Ux(Ux(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 mee=({file:t,commandArguments:e})=>_ee(t,e),gee=({file:t,commandArguments:e})=>({..._ee(t,e),isSync:!0}),_ee=(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]=cDe(t);return{file:r,commandArguments:n}},cDe=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(lDe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},lDe=/ +/g;var yee=(t,e,r)=>{t.sync=e(uDe,r),t.s=t.sync},See=({options:t})=>Eee(t),uDe=({options:t})=>({...Eee(t),isSync:!0}),Eee=t=>({options:{...dDe(t),...t}}),dDe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},vee={preferLocal:!0};var bee=Oa(()=>({})),Agt=Oa(()=>({isSync:!0})),Tee=Oa(mee),Rgt=Oa(gee),Igt=Oa(kX),Cgt=Oa(See,{},vee,yee),{sendMessage:Pgt,getOneMessage:Ogt,getEachMessage:Ngt,getCancelSignal:kgt}=S7();var xee=!1,wee=()=>{xee=!0},ho=()=>xee;var f_=null,Aee=t=>(f_&&f_.destroy(),f_=new gs({totalAllowedTime:t}),f_),Ree=()=>f_;var gs=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&&ho())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 wT({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}),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 Iee={name:"@netlify/agent-runner-cli",type:"module",version:"1.145.0-ex-2517.3",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.197","@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.3","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.8.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var mDe=pDe(import.meta.url),gDe=_s.dirname(mDe),_De=hDe(import.meta.url),ef=ye("shell"),lL=new Set,Cee={preferLocal:!0},kr=(t,e,r)=>{let[n,i]=yDe(e,r),o={...Cee,...i},s=bee(t,n,o);Oee(s,o),Mee(s);let a=r?.idleTimeout;return a&&a>0&&kee(s,a),s},Pee=(t,e)=>{let r={...Cee,...e},n=Tee(t,r);return Oee(n,r),Mee(n),e?.idleTimeout&&e.idleTimeout>0&&kee(n,e.idleTimeout),n},yDe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},Oee=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(ys.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new zg).pipe(ys.stdout),t.stderr?.pipe(new zg).pipe(ys.stderr);return}t.stdout?.pipe(ys.stdout),t.stderr?.pipe(ys.stderr)},uL=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(ys.kill(-t.pid,e),ef.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return ef.error("Error killing process:",r),!1}},Nee=t=>uL(t,"SIGKILL"),kee=(t,e)=>{let r=null,n=()=>{ef.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),uL(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(ef.log(`Force killing idle process ${t.pid}`),Nee(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)},Mee=t=>{lL.add(t);let e=Ree();if(e){let r=e.onTimesUp(()=>{ef.log(`Global timer expired, killing process ${t.pid}`),uL(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(ef.log(`Force killing process ${t.pid} after timeout`),Nee(t))},5e3)});t.on("exit",()=>{lL.delete(t),r()}),t.on("error",()=>{lL.delete(t),r()})}};function mo(t,e){if(!ys.env.NETLIFY_LOCAL_MODE)try{let i=_De.resolve(Iee.name),o=_s.dirname(i);for(;o!==_s.dirname(o);){let s=_s.dirname(o);if(_s.basename(s)==="node_modules"){let a=_s.join(s,".bin",e);if(Fx.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(ys.env.NODE_PATH){let i=_s.join(ys.env.NODE_PATH,".bin",e);if(Fx.existsSync(i))return i}let r=_s.join(t,"node_modules",".bin",e);if(Fx.existsSync(r))return r;let n=_s.join(gDe,"..","node_modules",".bin",e);if(Fx.existsSync(n))return n}var SDe=ye("utils"),EDe=t=>new Promise(e=>{setTimeout(e,t)});var Bx=(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 EDe(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},Dee=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):SDe.error("Could not parse JSON",n))}},vDe=t=>t.charAt(0).toUpperCase()+t.slice(1),go=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():vDe(e)).join(" ");function Ss(t,e){e&&t.log(`Skill invoked: ${e}`)}var jx=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),Lee=(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 dL=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}},bDe=1e4,fL=(t,e=bDe)=>{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 $ee}from"buffer";import TDe from"path";var Uee=ye("repo"),Kr=(t,e={})=>kr("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),zx=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{Uee.info("Getting runner diffs");let n=await wDe(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let m=RDe(o);await IDe(m,r)}Uee.info("Changes after processing"),await hL(r);let s=await gL(o,r);if(await pL(s,r),i=await ADe(r),!i)return{hasChanges:!1,ignored:s};await Kr(["commit","-m","Agent runner"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await Kr(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(i=!!l,!i)return await Fee(r),{hasChanges:!1,ignored:s};let u=await Kr(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,p;if(t.sha){let m=await Kr(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let y=await Kr(["diff",t.sha,"HEAD","--binary"],a),S=String(y.stdout??"");f!==S&&(p=$ee.from(S).toString("base64"))}await Fee(r);let h={hasChanges:!0,diff:l,resultDiff:f,ignored:s};return l!==d&&(h.diffBinary=$ee.from(d).toString("base64")),p&&(h.resultDiffBinary=p),h},Fee=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Kr(["reset","--soft","HEAD~1"],{cwd:t})},pL=async(t=[],e=process.cwd())=>{await Kr(["add",".",...t],{cwd:e})},hL=async(t=process.cwd())=>{let e=await Kr(["status","-s"],{cwd:t});return String(e.stdout??"")},Bee=/.. (.+)?\.log$/,xDe=[Bee],wDe=async(t=process.cwd())=>{let e=await hL(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
101
|
+
if (condition) { yield value; }`)};import{Buffer as PNe}from"buffer";import{StringDecoder as ONe}from"string_decoder";var xx=(t,e,r)=>{if(r)return;if(t)return{transform:NNe.bind(void 0,new TextEncoder)};let n=new ONe(e);return{transform:kNe.bind(void 0,n),final:MNe.bind(void 0,n)}},NNe=function*(t,e){PNe.isBuffer(e)?yield fs(e):typeof e=="string"?yield t.encode(e):yield e},kNe=function*(t,e){yield jt(e)?t.write(e):e},MNe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as ZQ}from"util";var AD=ZQ(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),wx=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=LNe}=e[r];for await(let i of n(t))yield*wx(i,e,r+1)},JQ=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*DNe(r,Number(e),t)},DNe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*wx(n,r,e+1)},XQ=ZQ(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),LNe=function*(t){yield t};var RD=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},QQ=(t,e)=>[...e.flatMap(r=>[...xl(r,t,0)]),...s_(t)],xl=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=UNe}=e[r];for(let i of n(t))yield*xl(i,e,r+1)},s_=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*$Ne(r,Number(e),t)},$Ne=function*(t,e,r){if(t!==void 0)for(let n of t())yield*xl(n,r,e+1)},UNe=function*(t){yield t};var ID=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=t7(t,s,o),l=Tl(e),u=Tl(r),d=l?AD.bind(void 0,wx,a):RD.bind(void 0,xl),f=l||u?AD.bind(void 0,JQ,a):RD.bind(void 0,s_),p=l||u?XQ.bind(void 0,a):void 0;return{stream:new FNe({writableObjectMode:n,writableHighWaterMark:e7(n),readableObjectMode:i,readableHighWaterMark:e7(i),transform(m,y,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:p})}},Ax=(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=t7(s,r,a);t=QQ(c,t)}return t},t7=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:WQ(n,a)},xx(r,s,n),Tx(r,o,n,c),{transform:t,final:e},{transform:YQ(i,a)},HQ({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var r7=(t,e)=>{for(let r of BNe(t))jNe(t,r,e)},BNe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),jNe=(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=>zNe(a,n));r.input=Zg(s)},zNe=(t,e)=>{let r=Ax(t,e,"utf8",!0);return GNe(r),Zg(r)},GNe=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 WNe,appendFileSync as YNe}from"fs";var Rx=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Bd(r,n)&&!_n.has(e)&&qNe(n)&&(t.some(({type:i,value:o})=>i==="native"&&VNe.has(o))||t.every(({type:i})=>Vn.has(i))),qNe=t=>t===1||t===2,VNe=new Set(["pipe","overlapped"]),n7=async(t,e,r,n)=>{for await(let i of t)HNe(e)||o7(i,r,n)},i7=(t,e,r)=>{for(let n of t)o7(n,e,r)},HNe=t=>t._readableState.pipes.length>0,o7=(t,e,r)=>{let n=jT(t);co({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var s7=({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)=>KNe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},KNe=({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=aQ(t,o,d),p=fs(f),{stdioItems:h,objectMode:m}=e[r],y=ZNe([p],h,c,n),{serializedResult:S,finalResult:T=S}=JNe({chunks:y,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});XNe({serializedResult:S,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let x=a[r]?T:void 0;try{return n.error===void 0&&QNe(S,h,i),x}catch(v){return n.error=v,x}},ZNe=(t,e,r,n)=>{try{return Ax(t,e,r,!1)}catch(i){return n.error=i,t}},JNe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Zg(t)};let s=v9(t,r);return n[o]?{serializedResult:s,finalResult:wD(s,!i[o],e)}:{serializedResult:s}},XNe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!Rx({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=wD(t,!1,s);try{i7(a,e,n)}catch(c){r.error??=c}},QNe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>vx.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?YNe(n,t):(r.add(o),WNe(n,t))}};var a7=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,ms(e,r,"all")]:Array.isArray(e)?[ms(t,r,"all"),...e]:jt(t)&&jt(e)?MM([t,e]):`${t}${e}`};import{once as CD}from"events";var c7=async(t,e)=>{let[r,n]=await eke(t);return e.isForcefullyTerminated??=!1,[r,n]},eke=async t=>{let[e,r]=await Promise.allSettled([CD(t,"spawn"),CD(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?l7(t):r.value},l7=async t=>{try{return await CD(t,"exit")}catch{return l7(t)}},u7=async t=>{let[e,r]=await t;if(!tke(e,r)&&PD(e,r))throw new Ti;return[e,r]},tke=(t,e)=>t===void 0&&e===void 0,PD=(t,e)=>t!==0||e!==null;var d7=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=rke(t,e,r),s=o?.code==="ETIMEDOUT",a=sQ(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},rke=(t,e,r)=>t!==void 0?t:PD(e,r)?new Ti:void 0;var f7=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=ike(t,e,r),d=ake({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Zd(d,c,l)},ike=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=GT(t,e,r),a=oke(r),{file:c,commandArguments:l,options:u}=lx(t,e,a);ske(u);let d=zQ(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},oke=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,ske=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&Ix("ipcInput"),t&&Ix("ipc: true"),r&&Ix("detached: true"),n&&Ix("cancelSignal")},Ix=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},ake=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=cke({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}=d7(c,r),{output:h,error:m=l}=s7({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),y=h.map((T,x)=>ms(T,r,x)),S=ms(a7(h,r),r,"all");return uke({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:y,all:S,options:r,command:n,escapedCommand:i,startTime:a})},cke=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{r7(o,r);let a=lke(r);return nke(...ux(t,e,a))}catch(a){return Kd({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},lke=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:_x(e)}),uke=({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?yx({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):o_({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 JMe}from"events";import{spawn as XMe}from"child_process";import _7 from"process";import{once as OD,on as dke}from"events";var p7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Gd({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:nx(t)}),fke({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),fke=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{QT(e,i);let o=Ca(t,e,r),s=new AbortController;try{return await Promise.race([pke(o,n,s),hke(o,r,s),mke(o,r,s)])}catch(a){throw qd(t),a}finally{s.abort(),ex(e,i)}},pke=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await OD(t,"message",{signal:r});return n}for await(let[n]of dke(t,"message",{signal:r}))if(e(n))return n},hke=async(t,e,{signal:r})=>{await OD(t,"disconnect",{signal:r}),QJ(e)},mke=async(t,e,{signal:r})=>{let[n]=await OD(t,"strict:error",{signal:r});throw ZT(n,e)};import{once as m7,on as gke}from"events";var g7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>ND({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),ND=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Gd({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:nx(t)}),QT(e,o);let s=Ca(t,e,r),a=new AbortController,c={};return _ke(t,s,a),yke({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),Ske({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},_ke=async(t,e,r)=>{try{await m7(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},yke=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await m7(t,"strict:error",{signal:r.signal});n.error=ZT(i,e),r.abort()}catch{}},Ske=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of gke(r,"message",{signal:o.signal}))h7(s),yield c}catch{h7(s)}finally{o.abort(),ex(e,a),n||qd(t),i&&await t}},h7=({error:t})=>{if(t)throw t};var y7=(t,{ipc:e})=>{Object.assign(t,E7(t,!1,e))},S7=()=>{let t=_7,e=!0,r=_7.channel!==void 0;return{...E7(t,e,r),getCancelSignal:AX.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},E7=(t,e,r)=>({sendMessage:ax.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:p7.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:g7.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Eke}from"child_process";import{PassThrough as vke,Readable as bke,Writable as Tke,Duplex as xke}from"stream";var v7=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{bD(n);let a=new Eke;wke(a,n),Object.assign(a,{readable:Ake,writable:Rke,duplex:Ike});let c=Kd({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=Cke(c,s,i);return{subprocess:a,promise:l}},wke=(t,e)=>{let r=a_(),n=a_(),i=a_(),o=Array.from({length:e.length-3},a_),s=a_(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},a_=()=>{let t=new vke;return t.end(),t},Ake=()=>new bke({read(){}}),Rke=()=>new Tke({write(){}}),Ike=()=>new xke({read(){},write(){}}),Cke=async(t,e,r)=>Zd(t,e,r);import{createReadStream as b7,createWriteStream as T7}from"fs";import{Buffer as Pke}from"buffer";import{Readable as c_,Writable as Oke,Duplex as Nke}from"stream";var w7=(t,e)=>bx(kke,t,e,!1),l_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Pa[t]}.`)},x7={fileNumber:l_,generator:ID,asyncGenerator:ID,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Nke.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},kke={input:{...x7,fileUrl:({value:t})=>({stream:b7(t)}),filePath:({value:{file:t}})=>({stream:b7(t)}),webStream:({value:t})=>({stream:c_.fromWeb(t)}),iterable:({value:t})=>({stream:c_.from(t)}),asyncIterable:({value:t})=>({stream:c_.from(t)}),string:({value:t})=>({stream:c_.from(t)}),uint8Array:({value:t})=>({stream:c_.from(Pke.from(t))})},output:{...x7,fileUrl:({value:t})=>({stream:T7(t)}),filePath:({value:{file:t,append:e}})=>({stream:T7(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Oke.fromWeb(t)}),iterable:l_,asyncIterable:l_,string:l_,uint8Array:l_}};import{on as Mke,once as A7}from"events";import{PassThrough as Dke,getDefaultHighWaterMark as Lke}from"stream";import{finished as C7}from"stream/promises";function wl(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)MD(i);let e=t.some(({readableObjectMode:i})=>i),r=$ke(t,e),n=new kD({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var $ke=(t,e)=>{if(t.length===0)return Lke(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},kD=class extends Dke{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(MD(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Uke(this,this.#e,this.#o);let r=jke({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(MD(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)}},Uke=async(t,e,r)=>{Cx(t,R7);let n=new AbortController;try{await Promise.race([Fke(t,n),Bke(t,e,r,n)])}finally{n.abort(),Cx(t,-R7)}},Fke=async(t,{signal:e})=>{try{await C7(t,{signal:e,cleanup:!0})}catch(r){throw P7(t,r),r}},Bke=async(t,e,r,{signal:n})=>{for await(let[i]of Mke(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},MD=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},jke=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{Cx(t,I7);let a=new AbortController;try{await Promise.race([zke(o,e,a),Gke({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),qke({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),Cx(t,-I7)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?DD(t):Vke(t))},zke=async(t,e,{signal:r})=>{try{await t,r.aborted||DD(e)}catch(n){r.aborted||P7(e,n)}},Gke=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await C7(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;O7(s)?i.add(e):N7(t,s)}},qke=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await A7(t,i,{signal:o}),!t.readable)return A7(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},Vke=t=>{t.writable&&t.end()},P7=(t,e)=>{O7(e)?DD(t):N7(t,e)},O7=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",DD=t=>{(t.readable||t.writable)&&t.destroy()},N7=(t,e)=>{t.destroyed||(t.once("error",Hke),t.destroy(e))},Hke=()=>{},Cx=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},R7=2,I7=1;import{finished as k7}from"stream/promises";var Xd=(t,e)=>{t.pipe(e),Wke(t,e),Yke(t,e)},Wke=async(t,e)=>{if(!(bi(t)||bi(e))){try{await k7(t,{cleanup:!0,readable:!0,writable:!1})}catch{}LD(e)}},LD=t=>{t.writable&&t.end()},Yke=async(t,e)=>{if(!(bi(t)||bi(e))){try{await k7(e,{cleanup:!0,readable:!1,writable:!0})}catch{}$D(t)}},$D=t=>{t.readable&&t.destroy()};var M7=(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})=>Vn.has(c)))Kke(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Vn.has(c)))Jke({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]:wl(o);Xd(s,i)}},Kke=(t,e,r,n)=>{r==="output"?Xd(t.stdio[n],e):Xd(e,t.stdio[n]);let i=Zke[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},Zke=["stdin","stdout","stderr"],Jke=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;Xke(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},Xke=(t,{signal:e})=>{bi(t)&&vl(t,Qke,e)},Qke=2;import{addAbortListener as rMe}from"events";var Al=[];Al.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Al.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Al.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var Px=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",UD=Symbol.for("signal-exit emitter"),FD=globalThis,eMe=Object.defineProperty.bind(Object),BD=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(FD[UD])return FD[UD];eMe(FD,UD,{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}},Ox=class{},tMe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),jD=class extends Ox{onExit(){return()=>{}}load(){}unload(){}},zD=class extends Ox{#e=GD.platform==="win32"?"SIGINT":"SIGHUP";#r=new BD;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Al)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(!Px(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 Al)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,Al.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 Px(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"&&Px(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)}},GD=globalThis.process,{onExit:D7,load:Lpt,unload:$pt}=tMe(Px(GD)?new zD(GD):new jD);var L7=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=D7(()=>{t.kill()});rMe(n,()=>{i()})};var U7=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=zT(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=nMe(r,n,i),{sourceStream:d,sourceError:f}=oMe(t,l),{options:p,fileDescriptors:h}=uo.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},nMe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=iMe(t,e,...r),a=XT(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},iMe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e($7,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||NM(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]=NT(r,...n);return{destination:e($7)(i,o,s),pipeOptions:s}}if(uo.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}`)},$7=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),oMe=(t,e)=>{try{return{sourceStream:Vd(t,e)}}catch(r){return{sourceError:r}}};var B7=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=sMe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw qD({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},sMe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return $D(t),n;if(e!==void 0)return LD(r),e},qD=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Kd({error:t,command:F7,escapedCommand:F7,fileDescriptors:e,options:r,startTime:n,isSync:!1}),F7="source.pipe(destination)";var j7=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 aMe}from"stream/promises";var z7=(t,e,r)=>{let n=Nx.has(e)?lMe(t,e):cMe(t,e);return vl(t,dMe,r.signal),vl(e,fMe,r.signal),uMe(e),n},cMe=(t,e)=>{let r=wl([t]);return Xd(r,e),Nx.set(e,r),r},lMe=(t,e)=>{let r=Nx.get(e);return r.add(t),r},uMe=async t=>{try{await aMe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}Nx.delete(t)},Nx=new WeakMap,dMe=2,fMe=1;import{aborted as pMe}from"util";var G7=(t,e)=>t===void 0?[]:[hMe(t,e)],hMe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await pMe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw qD({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var kx=(t,...e)=>{if(Ct(e[0]))return kx.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=U7(t,...e),i=mMe({...n,destination:r});return i.pipe=kx.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},mMe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=gMe(t,i);B7({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=z7(e,o,d);return await Promise.race([j7(u),...G7(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},gMe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as TMe}from"timers/promises";import{on as _Me}from"events";import{getDefaultHighWaterMark as yMe}from"stream";var Mx=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return SMe(e,s),V7({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},SMe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},VD=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;EMe(e,s,t);let a=t.readableObjectMode&&!o;return V7({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},EMe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},V7=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=_Me(t,"data",{signal:e.signal,highWaterMark:q7,highWatermark:q7});return vMe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},HD=yMe(!0),q7=HD,vMe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=bMe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*xl(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*s_(a)}},bMe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[xx(t,r,!e),Tx(t,i,!n,{})].filter(Boolean);var H7=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=xMe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([wMe(t),d]);return}let f=TD(c,r),p=VD({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([AMe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},xMe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!Rx({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=VD({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await n7(a,t,r,o)},wMe=async t=>{await TMe(),t.readableFlowing===null&&t.resume()},AMe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await hx(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await mx(r,{maxBuffer:o})):await Yd(r,{maxBuffer:o})}catch(a){return W7(nQ({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},WD=async t=>{try{return await t}catch(e){return W7(e)}},W7=({bufferedData:t})=>S9(t)?new Uint8Array(t):t;import{finished as RMe}from"stream/promises";var u_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=IMe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],RMe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||OMe(a,e,r,n)}finally{s.abort()}},IMe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&CMe(t,r,n),n},CMe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{PMe(e,r),n.call(t,...i)}},PMe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},OMe=(t,e,r,n)=>{if(!NMe(t,e,r,n))throw t},NMe=(t,e,r,n=!0)=>r.propagating?Y7(t)||Dx(t):(r.propagating=!0,YD(r,e)===n?Y7(t):Dx(t)),YD=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",Dx=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Y7=t=>t?.code==="EPIPE";var K7=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>KD({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),KD=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=u_(t,e,l);if(YD(l,e)){await u;return}let[d]=await Promise.all([H7({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 Z7=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?wl([t,e].filter(Boolean)):void 0,J7=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>KD({...kMe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:MMe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),kMe=({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}},MMe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as DMe}from"events";var X7=t=>Bd(t,"ipc"),Q7=(t,e)=>{let r=jT(t);co({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var eee=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=X7(o),a=ps(e,"ipc"),c=ps(r,"ipc");for await(let l of ND({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(iQ(t,i,c),i.push(l)),s&&Q7(l,o);return i},tee=async(t,e)=>(await Promise.allSettled([t]),e);var ree=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:y,controller:S})=>{let T=c7(t,f),x={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:T,propagating:!1},v=K7({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:x}),N=J7({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:x}),R=[],U=eee({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:R,verboseInfo:p}),C=LMe(m,t,x),D=$Me(h,x);try{return await Promise.race([Promise.all([{},u7(T),Promise.all(v),N,U,LX(t,d),...C,...D]),y,UMe(t,S),...OX(t,o,f,S),...XJ({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:S}),...CX({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(j){return f.terminationReason??="other",Promise.all([{error:j},T,Promise.all(v.map(_=>WD(_))),WD(N),tee(U,R),Promise.allSettled(C),Promise.allSettled(D)])}},LMe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:u_(n,i,r)),$Me=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>wi(o,{checkOpen:!1})&&!bi(o)).map(({type:i,value:o,stream:s=o})=>u_(s,n,e,{isSameDirection:Vn.has(i),stopOnExit:i==="native"}))),UMe=async(t,{signal:e})=>{let[r]=await DMe(t,"error",{signal:e});throw r};var nee=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),d_=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=lo();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Qd=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 FMe}from"stream";import{callbackify as BMe}from"util";import{finished as iee}from"stream/promises";var ZD=async t=>{if(t!==void 0)try{await JD(t)}catch{}},oee=async t=>{if(t!==void 0)try{await XD(t)}catch{}},JD=async t=>{await iee(t,{cleanup:!0,readable:!1,writable:!0})},XD=async t=>{await iee(t,{cleanup:!0,readable:!0,writable:!1})},Lx=async(t,e)=>{if(await t,e)throw e},$x=(t,e,r)=>{r&&!Dx(r)?t.destroy(r):e&&t.destroy()};var see=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||_n.has(r),{subprocessStdout:a,waitReadableDestroy:c}=QD(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=eL(a,s),{read:f,onStdoutDataDone:p}=tL({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new FMe({read:f,destroy:BMe(nL.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return rL({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},QD=(t,e,r)=>{let n=Vd(t,e),i=d_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},eL=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:HD},tL=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=lo(),s=Mx({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){jMe(this,s,o)},onStdoutDataDone:o}},jMe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},rL=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await XD(t),await n,await ZD(i),await e,r.readable&&r.push(null)}catch(o){await ZD(i),aee(r,o)}},nL=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Qd(r,e)&&(aee(t,n),await Lx(e,n))},aee=(t,e)=>{$x(t,t.readable,e)};import{Writable as zMe}from"stream";import{callbackify as cee}from"util";var lee=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=iL(t,r,e),s=new zMe({...oL(n,t,i),destroy:cee(aL.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return sL(n,s),s},iL=(t,e,r)=>{let n=XT(t,e),i=d_(r,n,"writableFinal"),o=d_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},oL=(t,e,r)=>({write:GMe.bind(void 0,t),final:cee(qMe.bind(void 0,t,e,r))}),GMe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},qMe=async(t,e,r)=>{await Qd(r,e)&&(t.writable&&t.end(),await e)},sL=async(t,e,r)=>{try{await JD(t),e.writable&&e.end()}catch(n){await oee(r),uee(e,n)}},aL=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Qd(r,e),await Qd(n,e)&&(uee(t,i),await Lx(e,i))},uee=(t,e)=>{$x(t,t.writable,e)};import{Duplex as VMe}from"stream";import{callbackify as HMe}from"util";var dee=({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}=QD(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=iL(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=eL(c,a),{read:y,onStdoutDataDone:S}=tL({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),T=new VMe({read:y,...oL(u,t,d),destroy:HMe(WMe.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 rL({subprocessStdout:c,onStdoutDataDone:S,readable:T,subprocess:t,subprocessStdin:u}),sL(u,T,c),T},WMe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([nL({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),aL({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var cL=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||_n.has(e),s=Vd(t,r),a=Mx({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return YMe(a,s,t)},YMe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var fee=(t,{encoding:e})=>{let r=nee();t.readable=see.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=lee.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=dee.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=cL.bind(void 0,t,e),t[Symbol.asyncIterator]=cL.bind(void 0,t,e,{})};var pee=(t,e)=>{for(let[r,n]of ZMe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},KMe=(async()=>{})().constructor.prototype,ZMe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(KMe,t)]);var hee=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=QMe(t,e,r),{subprocess:f,promise:p}=tDe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=kx.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),pee(f,p),uo.set(f,{options:u,fileDescriptors:d}),f},QMe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=GT(t,e,r),{file:a,commandArguments:c,options:l}=lx(t,e,r),u=eDe(l),d=w7(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},eDe=({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}},tDe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=XMe(...ux(t,e,r))}catch(h){return v7({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;JMe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];M7(c,a,l),L7(c,r,l);let d={},f=lo();c.kill=ZJ.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Z7(c,r),fee(c,r),y7(c,r);let p=rDe({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}},rDe=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,y]=await ree({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let S=h.map((v,N)=>ms(v,e,N)),T=ms(m,e,"all"),x=nDe({errorInfo:d,exitCode:f,signal:p,stdio:S,all:T,ipcOutput:y,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Zd(x,n,e)},nDe=({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?o_({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 fo,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):yx({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var Ux=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,iDe(n,t[n],i)]));return{...t,...r}},iDe=(t,e,r)=>oDe.has(t)&&Ct(e)&&Ct(r)?{...e,...r}:r,oDe=new Set(["env",...UM]);var Oa=(t,e,r,n)=>{let i=(s,a,c)=>Oa(s,a,r,c),o=(...s)=>sDe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},sDe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Ct(o))return i(t,Ux(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=aDe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?f7(a,c,l):hee(a,c,l,i)},aDe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=w9(e)?A9(e,r):[e,...r],[s,a,c]=NT(...o),l=Ux(Ux(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 mee=({file:t,commandArguments:e})=>_ee(t,e),gee=({file:t,commandArguments:e})=>({..._ee(t,e),isSync:!0}),_ee=(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]=cDe(t);return{file:r,commandArguments:n}},cDe=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(lDe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},lDe=/ +/g;var yee=(t,e,r)=>{t.sync=e(uDe,r),t.s=t.sync},See=({options:t})=>Eee(t),uDe=({options:t})=>({...Eee(t),isSync:!0}),Eee=t=>({options:{...dDe(t),...t}}),dDe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},vee={preferLocal:!0};var bee=Oa(()=>({})),Agt=Oa(()=>({isSync:!0})),Tee=Oa(mee),Rgt=Oa(gee),Igt=Oa(kX),Cgt=Oa(See,{},vee,yee),{sendMessage:Pgt,getOneMessage:Ogt,getEachMessage:Ngt,getCancelSignal:kgt}=S7();var xee=!1,wee=()=>{xee=!0},ho=()=>xee;var f_=null,Aee=t=>(f_&&f_.destroy(),f_=new gs({totalAllowedTime:t}),f_),Ree=()=>f_;var gs=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&&ho())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 wT({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}),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 Iee={name:"@netlify/agent-runner-cli",type:"module",version:"1.145.0-ex-2517.4",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{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.197","@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.3","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.8.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var mDe=pDe(import.meta.url),gDe=_s.dirname(mDe),_De=hDe(import.meta.url),ef=ye("shell"),lL=new Set,Cee={preferLocal:!0},kr=(t,e,r)=>{let[n,i]=yDe(e,r),o={...Cee,...i},s=bee(t,n,o);Oee(s,o),Mee(s);let a=r?.idleTimeout;return a&&a>0&&kee(s,a),s},Pee=(t,e)=>{let r={...Cee,...e},n=Tee(t,r);return Oee(n,r),Mee(n),e?.idleTimeout&&e.idleTimeout>0&&kee(n,e.idleTimeout),n},yDe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},Oee=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(ys.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new zg).pipe(ys.stdout),t.stderr?.pipe(new zg).pipe(ys.stderr);return}t.stdout?.pipe(ys.stdout),t.stderr?.pipe(ys.stderr)},uL=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(ys.kill(-t.pid,e),ef.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return ef.error("Error killing process:",r),!1}},Nee=t=>uL(t,"SIGKILL"),kee=(t,e)=>{let r=null,n=()=>{ef.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),uL(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(ef.log(`Force killing idle process ${t.pid}`),Nee(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)},Mee=t=>{lL.add(t);let e=Ree();if(e){let r=e.onTimesUp(()=>{ef.log(`Global timer expired, killing process ${t.pid}`),uL(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(ef.log(`Force killing process ${t.pid} after timeout`),Nee(t))},5e3)});t.on("exit",()=>{lL.delete(t),r()}),t.on("error",()=>{lL.delete(t),r()})}};function mo(t,e){if(!ys.env.NETLIFY_LOCAL_MODE)try{let i=_De.resolve(Iee.name),o=_s.dirname(i);for(;o!==_s.dirname(o);){let s=_s.dirname(o);if(_s.basename(s)==="node_modules"){let a=_s.join(s,".bin",e);if(Fx.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(ys.env.NODE_PATH){let i=_s.join(ys.env.NODE_PATH,".bin",e);if(Fx.existsSync(i))return i}let r=_s.join(t,"node_modules",".bin",e);if(Fx.existsSync(r))return r;let n=_s.join(gDe,"..","node_modules",".bin",e);if(Fx.existsSync(n))return n}var SDe=ye("utils"),EDe=t=>new Promise(e=>{setTimeout(e,t)});var Bx=(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 EDe(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},Dee=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):SDe.error("Could not parse JSON",n))}},vDe=t=>t.charAt(0).toUpperCase()+t.slice(1),go=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():vDe(e)).join(" ");function Ss(t,e){e&&t.log(`Skill invoked: ${e}`)}var jx=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),Lee=(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 dL=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}},bDe=1e4,fL=(t,e=bDe)=>{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 $ee}from"buffer";import TDe from"path";var Uee=ye("repo"),Kr=(t,e={})=>kr("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),zx=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{Uee.info("Getting runner diffs");let n=await wDe(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let m=RDe(o);await IDe(m,r)}Uee.info("Changes after processing"),await hL(r);let s=await gL(o,r);if(await pL(s,r),i=await ADe(r),!i)return{hasChanges:!1,ignored:s};await Kr(["commit","-m","Agent runner"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await Kr(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(i=!!l,!i)return await Fee(r),{hasChanges:!1,ignored:s};let u=await Kr(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,p;if(t.sha){let m=await Kr(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let y=await Kr(["diff",t.sha,"HEAD","--binary"],a),S=String(y.stdout??"");f!==S&&(p=$ee.from(S).toString("base64"))}await Fee(r);let h={hasChanges:!0,diff:l,resultDiff:f,ignored:s};return l!==d&&(h.diffBinary=$ee.from(d).toString("base64")),p&&(h.resultDiffBinary=p),h},Fee=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Kr(["reset","--soft","HEAD~1"],{cwd:t})},pL=async(t=[],e=process.cwd())=>{await Kr(["add",".",...t],{cwd:e})},hL=async(t=process.cwd())=>{let e=await Kr(["status","-s"],{cwd:t});return String(e.stdout??"")},Bee=/.. (.+)?\.log$/,xDe=[Bee],wDe=async(t=process.cwd())=>{let e=await hL(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
102
102
|
`).filter(i=>xDe.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}},ADe=async(t=process.cwd())=>{try{return await Kr(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},mL=async(t=process.cwd())=>{let{stdout:e}=await Kr(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},jee=async(t=process.cwd())=>{let{stdout:e}=await Kr(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},gL=async(t,e=process.cwd())=>{t||=await hL(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(s=>{let a=i===`?? ${s}`,c=i.startsWith(`?? ${s}/`)||i.startsWith(`?? ${s}${TDe.sep}`);(a||c)&&n.push(`:!${s}`)});let o=i.match(Bee)?.[1];o&&n.push(`:!${o}.log`)}),n},_L=async(t=process.cwd())=>{await Kr(["reset","--hard","HEAD"],{cwd:t})},zee=async(t=process.cwd())=>{let e=await Kr(["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))},RDe=t=>{let e=t.split(`
|
|
@@ -323,7 +323,7 @@ ${s.trim()}
|
|
|
323
323
|
toolName = "web_fetch"
|
|
324
324
|
decision = "allow"
|
|
325
325
|
priority = 10
|
|
326
|
-
`,"utf-8"));let _=[mo(a,"gemini"),...d?["--model",d]:[],...D?["--approval-mode","default","--policy",j]:["--yolo"],"--skip-trust","--output-format","stream-json",...C?["-r",s]:[],"-p",""],ae=`${lh.env.NVM_BIN}/node`;rr.log(`Running ${ae} ${_.join(" ")}`);let I=e.utils.run(ae,_,{all:!0,env:lh.env,cwd:a,idleTimeout:ds,cancelSignal:c});I.stdin?.end(u);let g=Na(()=>{r?.({steps:f,duration:S}),n?.({steps:p,duration:S}),p=[]},250),E=(Ce,V)=>{Ce.id=y,y+=1,h.push(Ce),f.push(Ce),p.push(Ce),V||g.flush(),g(),V&&g.flush()};E({title:`Using ${K2} with ${d||"default"}`,category:Y.Environment},!0);let W=ABe.createInterface({input:I.all});W.on("error",Ce=>{rr.error("Readline interface error",{error:Ce.message,stack:Ce.stack})});let G="",ce=()=>{G&&E({message:G.trim(),category:Y.AgentMessage}),G=""};W.on("line",Ce=>{let V;try{if(Ce.startsWith("[API Error")){let De=Ce.match(/\[api error: (.+?)]$/i)?.[1];V={type:"error",value:Dee(De,!1)?.error?.message||De||"Gemini encountered error"}}else V=JSON.parse(Ce)}catch{return}if(V)switch(V.type==="init"&&typeof V.session_id=="string"&&(N=V.session_id,l?.(N)),["message","result"].includes(V.type)||ce(),V.type){case"message":{V.role!=="user"&&V.content&&(G+=V.content);break}case"tool_use":{if(V.tool_name===kte){if(rr.info("Gemini ask came in"),V.tool_id&&!R){rr.info("About to parse");let M=up.safeParse(V.parameters);M.success?(rr.info("Parse successful"),R={questions:M.data.questions,toolUseId:V.tool_id},rr.info("trying to kill process"),I.kill()):(rr.warn("Ignoring malformed ask tool input",{toolUseId:V.tool_id}),fe.inc("inference.malformed_ask",1))}break}let De=Y2[V.tool_name]?.name??V.tool_name,be=V.parameters?.file_path,ee=be&&Sc.relative(a,be),ie=V.parameters?.command,Re=V.tool_name==="activate_skill"&&V.parameters?.name,te=V.tool_name==="run_shell_command"&&Ps(ie),Ae=[De,ee&&`\`${ee}\``,ie&&`\`${ie}\``].filter(Boolean).join(" ");if(Re)Ae=`Use ${go(Re)}`;else if(te)Ae="Generating the site";else if(V.tool_name==="grep_search"){let{dir_path:M,pattern:k}=V.parameters||{};M&&k?Ae=`Search in \`${M}\` for \`${k}\``:M?Ae=`Search in \`${M}\``:k&&(Ae=`Search for \`${k}\``)}else if(V.tool_name==="update_topic"){let M=V.parameters?.title;M&&(Ae=`${De} \`${M}\``)}let K={title:Ae,category:te?Y.SiteGeneration:Y2[V.tool_name]?.category,...Re&&{type:Re}};m[V.tool_id]=K,g.flush();break}case"tool_result":{let De=m[V.tool_id];De&&(V.output&&(De.message=`\`\`\`
|
|
326
|
+
`,"utf-8"));let _=[mo(a,"gemini"),...d?["--model",d]:[],...D?["--approval-mode","default","--policy",j]:["--yolo"],"--skip-trust","--output-format","stream-json",...C?["-r",s]:[],"-p",""],ae=`${lh.env.NVM_BIN}/node`;rr.log(`Running ${ae} ${_.join(" ")}`);let I=e.utils.run(ae,_,{all:!0,env:{...lh.env,GEMINI_CLI_NO_RELAUNCH:"1"},cwd:a,idleTimeout:ds,cancelSignal:c});I.stdin?.end(u);let g=Na(()=>{r?.({steps:f,duration:S}),n?.({steps:p,duration:S}),p=[]},250),E=(Ce,V)=>{Ce.id=y,y+=1,h.push(Ce),f.push(Ce),p.push(Ce),V||g.flush(),g(),V&&g.flush()};E({title:`Using ${K2} with ${d||"default"}`,category:Y.Environment},!0);let W=ABe.createInterface({input:I.all});W.on("error",Ce=>{rr.error("Readline interface error",{error:Ce.message,stack:Ce.stack})});let G="",ce=()=>{G&&E({message:G.trim(),category:Y.AgentMessage}),G=""};W.on("line",Ce=>{let V;try{if(Ce.startsWith("[API Error")){let De=Ce.match(/\[api error: (.+?)]$/i)?.[1];V={type:"error",value:Dee(De,!1)?.error?.message||De||"Gemini encountered error"}}else V=JSON.parse(Ce)}catch{return}if(V)switch(V.type==="init"&&typeof V.session_id=="string"&&(N=V.session_id,l?.(N)),["message","result"].includes(V.type)||ce(),V.type){case"message":{V.role!=="user"&&V.content&&(G+=V.content);break}case"tool_use":{if(V.tool_name===kte){if(rr.info("Gemini ask came in"),V.tool_id&&!R){rr.info("About to parse");let M=up.safeParse(V.parameters);M.success?(rr.info("Parse successful"),R={questions:M.data.questions,toolUseId:V.tool_id},rr.info("trying to kill process"),I.kill()):(rr.warn("Ignoring malformed ask tool input",{toolUseId:V.tool_id}),fe.inc("inference.malformed_ask",1))}break}let De=Y2[V.tool_name]?.name??V.tool_name,be=V.parameters?.file_path,ee=be&&Sc.relative(a,be),ie=V.parameters?.command,Re=V.tool_name==="activate_skill"&&V.parameters?.name,te=V.tool_name==="run_shell_command"&&Ps(ie),Ae=[De,ee&&`\`${ee}\``,ie&&`\`${ie}\``].filter(Boolean).join(" ");if(Re)Ae=`Use ${go(Re)}`;else if(te)Ae="Generating the site";else if(V.tool_name==="grep_search"){let{dir_path:M,pattern:k}=V.parameters||{};M&&k?Ae=`Search in \`${M}\` for \`${k}\``:M?Ae=`Search in \`${M}\``:k&&(Ae=`Search for \`${k}\``)}else if(V.tool_name==="update_topic"){let M=V.parameters?.title;M&&(Ae=`${De} \`${M}\``)}let K={title:Ae,category:te?Y.SiteGeneration:Y2[V.tool_name]?.category,...Re&&{type:Re}};m[V.tool_id]=K,g.flush();break}case"tool_result":{let De=m[V.tool_id];De&&(V.output&&(De.message=`\`\`\`
|
|
327
327
|
${V.output.trim()}
|
|
328
328
|
\`\`\``),E(De,!0),CBe(De));break}case"result":{S=V.stats?.duration_ms,V.stats&&(so(V.stats),v=V.stats),V.status==="error"?x=V.error?.message:T=G.trim();break}case"error":{x=V.error;break}case"finished":break;case"init":break;default:{rr.warn("Unhandled message type:",V.type);break}}});let Te=!1;if(await I.catch(Ce=>{Te=Of(Ce,c),{error:x,result:T}=RBe({catchError:Ce,runCmd:I,error:x,result:T,runnerName:"Gemini"})}),W.close(),R)return g.flush(),{steps:h,duration:S,agentSessionId:N,resolvedModel:d,usage:v,pendingInteraction:R};let we=Te;return we&&(!T&&G.trim()&&(T=G.trim()),x=void 0),g.flush(),{steps:h,duration:S,result:await Ja({initialResult:T,agentName:K2,hasError:!!x}),error:Xa({error:x,agentName:K2}),isRetryableError:Qa(x),isProviderUnavailableError:ec(x),resolvedModel:d,usage:v,agentSessionId:N,...we?{aborted:!0}:{}}}var ose=async()=>{let t=Sc.join(Gy.homedir(),".gemini");await yu.rm(t,{recursive:!0,force:!0});let e=Sc.join(Gy.homedir(),".agents","skills");await yu.rm(e,{recursive:!0,force:!0})},sse={baseDir:Sc.join(Gy.homedir(),".gemini"),include:["tmp"]};import MBe from"fs/promises";import dse from"os";import X2 from"path";import UR from"process";import DBe from"readline";import NBe from"os";import lse from"path";import J2 from"fs";var ase=ye("opencode_install"),cse="1.17.19",kBe=()=>lse.join(NBe.homedir(),".netlify-agent-runner","opencode"),use=async t=>{let e=mo(t,"opencode");if(e)return e;let r=kBe(),n=lse.join(r,"node_modules",".bin","opencode");if(J2.existsSync(n))return n;J2.mkdirSync(r,{recursive:!0}),ase.log(`Installing opencode-ai@${cse} on demand`);let i=Date.now();await kr("npm",["install","--no-save","--no-audit","--no-fund","--prefix",r,`opencode-ai@${cse}`],{cwd:r});let o=Date.now()-i;if(fe.timing("opencode.install_duration",o),ase.log(`Installed opencode-ai in ${o}ms`),!J2.existsSync(n))throw new Error("OpenCode CLI binary not found after installing opencode-ai");return n};var js=ye("runner_opencode"),$R="OpenCode",fse="gateway",LBe="z-ai/glm-5.2",pse={bash:{name:"Run command",category:Y.RunCommand},read:{name:"Read file",category:Y.FileRead},write:{name:"Edit file",category:Y.FileWrite},edit:{name:"Edit file",category:Y.FileWrite},glob:{name:"Find files",category:Y.Explore},grep:{name:"Search files",category:Y.Explore},list:{name:"List directory",category:Y.Explore},task:{name:"Task",category:Y.Task},todowrite:{name:"Update task list",category:Y.Todo},webfetch:{name:"Fetch web",category:Y.Web},websearch:{name:"Search web",category:Y.Web},skill:{name:"Use Skill",category:Y.Skill}},$Be=t=>pse[t]?.name||t,UBe=({catchError:t,runCmd:e,error:r,result:n,runnerName:i})=>(js.log(`${i} command completed with catch handler triggered`,{hadExistingError:!!r,hadExistingResult:!!n,resultLength:n?n.length:0,catchError:t?.message||"No error object",processExitCode:e.exitCode,processKilled:e.killed}),n?(js.log("Preserving existing result despite catch handler being triggered"),r?{error:r,result:n}:{error:"Process completed with errors but result was captured",result:n}):(js.log("Setting result to undefined because no valid result was captured"),{error:r||`${i} failed`,result:void 0}));async function FBe({aiGateway:t,config:e,model:r}){let n=r;if(t){let i=t.isModelAvailable;if(!i)throw new Error("OpenCode runner requires a gateway with isModelAvailable support");let o=e.modelVersionOverrides?.opencode?.[e.accountType];o?n=o:r||(n=We().opencodeDefaultModel||LBe),n&&(await i(n)||js.log(`Model '${n}' not found in gateway catalog; proceeding anyway (gateway is authoritative, e.g. flag-gated OpenRouter models)`))}return n}function BBe({aiGateway:t,model:e}){if(!t)throw new Error("OpenCode runner requires the AI gateway");let{token:r,url:n}=t;if(!r||!n)throw new Error("No token or url provided from AI Gateway");let i=e?{[e]:{id:e,name:e,tool_call:!0,reasoning:!0,interleaved:{field:"reasoning_details"}}}:{},o={$schema:"https://opencode.ai/config.json",provider:{[fse]:{api:"openai",name:"Netlify AI Gateway",options:{apiKey:r,baseURL:n},...Object.keys(i).length>0?{models:i}:{}}}};UR.env.OPENCODE_CONFIG_CONTENT=JSON.stringify(o),UR.env.OPENCODE_DISABLE_AUTOUPDATE="1"}async function Q2({config:t,netlify:e,persistSteps:r,aiGateway:n,continueSession:i,priorAgentSessionId:o,cwd:s=UR.cwd()}){let{prompt:a}=t,{model:c}=t,l="",u,d,f,p=await FBe({config:t,aiGateway:n,model:c});BBe({aiGateway:n,model:p});let h=[],m=0,y=Date.now(),S=await use(s),T=["run","--format","json","--dangerously-skip-permissions","--agent","build",...p?["--model",`${fse}/${p}`]:[],...i?o?["--session",o]:["--continue"]:[]];js.log(`Running ${S} ${T.join(" ")}`);let x=e.utils.run(S,T,{all:!0,env:UR.env,cwd:s,idleTimeout:ds});x.stdin?.end(a);let v=Na(()=>{r?.({steps:h,duration:Date.now()-y})},250),N=(I,g)=>{let{wrapMessage:E,...w}=I,W=jx({...w,id:m});W.message&&E&&(W.message=`\`\`\`
|
|
329
329
|
${W.message}
|
package/package.json
CHANGED