@netlify/agent-runner-cli 1.142.1-test.8 → 1.142.1-test.9
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 +1 -1
- package/dist/bin.js +1 -1
- package/dist/index.js +1 -1
- 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:wD},ANe=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},RNe={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:ANe};import{Buffer as INe}from"buffer";var JQ=(t,e)=>t?void 0:CNe.bind(void 0,e),CNe=function*(t,e){if(typeof e!="string"&&!Bt(e)&&!INe.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},XQ=(t,e)=>t?PNe.bind(void 0,e):ONe.bind(void 0,e),PNe=function*(t,e){QQ(t,e),yield e},ONe=function*(t,e){if(QQ(t,e),typeof e!="string"&&!Bt(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},QQ=(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 NNe}from"buffer";import{StringDecoder as MNe}from"string_decoder";var Ax=(t,e,r)=>{if(r)return;if(t)return{transform:kNe.bind(void 0,new TextEncoder)};let n=new MNe(e);return{transform:DNe.bind(void 0,n),final:LNe.bind(void 0,n)}},kNe=function*(t,e){NNe.isBuffer(e)?yield hs(e):typeof e=="string"?yield t.encode(e):yield e},DNe=function*(t,e){yield Bt(e)?t.write(e):e},LNe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as e7}from"util";var RD=e7(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),Rx=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=UNe}=e[r];for await(let i of n(t))yield*Rx(i,e,r+1)},t7=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*$Ne(r,Number(e),t)},$Ne=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*Rx(n,r,e+1)},r7=e7(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),UNe=function*(t){yield t};var ID=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},n7=(t,e)=>[...e.flatMap(r=>[...Rl(r,t,0)]),...s_(t)],Rl=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=BNe}=e[r];for(let i of n(t))yield*Rl(i,e,r+1)},s_=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*FNe(r,Number(e),t)},FNe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Rl(n,r,e+1)},BNe=function*(t){yield t};var CD=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=o7(t,s,o),l=Al(e),u=Al(r),d=l?RD.bind(void 0,Rx,a):ID.bind(void 0,Rl),f=l||u?RD.bind(void 0,t7,a):ID.bind(void 0,s_),p=l||u?r7.bind(void 0,a):void 0;return{stream:new jNe({writableObjectMode:n,writableHighWaterMark:i7(n),readableObjectMode:i,readableHighWaterMark:i7(i),transform(m,S,E){d([m,c,0],this,E)},flush(m){f([c],this,m)},destroy:p})}},Ix=(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=o7(s,r,a);t=n7(c,t)}return t},o7=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:JQ(n,a)},Ax(r,s,n),wx(r,o,n,c),{transform:t,final:e},{transform:XQ(i,a)},ZQ({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var s7=(t,e)=>{for(let r of zNe(t))GNe(t,r,e)},zNe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),GNe=(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 ${Ma[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>VNe(a,n));r.input=Zg(s)},VNe=(t,e)=>{let r=Ix(t,e,"utf8",!0);return qNe(r),Zg(r)},qNe=t=>{let e=t.find(r=>typeof r!="string"&&!Bt(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 KNe,appendFileSync as ZNe}from"fs";var Cx=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Gd(r,n)&&!yn.has(e)&&HNe(n)&&(t.some(({type:i,value:o})=>i==="native"&&WNe.has(o))||t.every(({type:i})=>Yn.has(i))),HNe=t=>t===1||t===2,WNe=new Set(["pipe","overlapped"]),a7=async(t,e,r,n)=>{for await(let i of t)YNe(e)||l7(i,r,n)},c7=(t,e,r)=>{for(let n of t)l7(n,e,r)},YNe=t=>t._readableState.pipes.length>0,l7=(t,e,r)=>{let n=GT(t);fo({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var u7=({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)=>JNe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},JNe=({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=dQ(t,o,d),p=hs(f),{stdioItems:h,objectMode:m}=e[r],S=XNe([p],h,c,n),{serializedResult:E,finalResult:b=E}=QNe({chunks:S,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});eMe({serializedResult:E,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let x=a[r]?b:void 0;try{return n.error===void 0&&tMe(E,h,i),x}catch(_){return n.error=_,x}},XNe=(t,e,r,n)=>{try{return Ix(t,e,r,!1)}catch(i){return n.error=i,t}},QNe=({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=w9(t,r);return n[o]?{serializedResult:s,finalResult:AD(s,!i[o],e)}:{serializedResult:s}},eMe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!Cx({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=AD(t,!1,s);try{c7(a,e,n)}catch(c){r.error??=c}},tMe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>Tx.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?ZNe(n,t):(r.add(o),KNe(n,t))}};var d7=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,_s(e,r,"all")]:Array.isArray(e)?[_s(t,r,"all"),...e]:Bt(t)&&Bt(e)?Dk([t,e]):`${t}${e}`};import{once as PD}from"events";var f7=async(t,e)=>{let[r,n]=await rMe(t);return e.isForcefullyTerminated??=!1,[r,n]},rMe=async t=>{let[e,r]=await Promise.allSettled([PD(t,"spawn"),PD(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?p7(t):r.value},p7=async t=>{try{return await PD(t,"exit")}catch{return p7(t)}},h7=async t=>{let[e,r]=await t;if(!nMe(e,r)&&OD(e,r))throw new Ai;return[e,r]},nMe=(t,e)=>t===void 0&&e===void 0,OD=(t,e)=>t!==0||e!==null;var m7=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=iMe(t,e,r),s=o?.code==="ETIMEDOUT",a=uQ(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},iMe=(t,e,r)=>t!==void 0?t:OD(e,r)?new Ai:void 0;var g7=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=sMe(t,e,r),d=lMe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Qd(d,c,l)},sMe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=qT(t,e,r),a=aMe(r),{file:c,commandArguments:l,options:u}=dx(t,e,a);cMe(u);let d=HQ(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},aMe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,cMe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&Px("ipcInput"),t&&Px("ipc: true"),r&&Px("detached: true"),n&&Px("cancelSignal")},Px=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},lMe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=uMe({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}=m7(c,r),{output:h,error:m=l}=u7({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),S=h.map((b,x)=>_s(b,r,x)),E=_s(d7(h,r),r,"all");return fMe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:S,all:E,options:r,command:n,escapedCommand:i,startTime:a})},uMe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{s7(o,r);let a=dMe(r);return oMe(...fx(t,e,a))}catch(a){return Xd({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},dMe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:Sx(e)}),fMe=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?Ex({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):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 Qke}from"events";import{spawn as eDe}from"child_process";import v7 from"process";import{once as ND,on as pMe}from"events";var _7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Hd({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:ox(t)}),hMe({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),hMe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{tx(e,i);let o=Na(t,e,r),s=new AbortController;try{return await Promise.race([mMe(o,n,s),gMe(o,r,s),_Me(o,r,s)])}catch(a){throw Wd(t),a}finally{s.abort(),rx(e,i)}},mMe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await ND(t,"message",{signal:r});return n}for await(let[n]of pMe(t,"message",{signal:r}))if(e(n))return n},gMe=async(t,e,{signal:r})=>{await ND(t,"disconnect",{signal:r}),nX(e)},_Me=async(t,e,{signal:r})=>{let[n]=await ND(t,"strict:error",{signal:r});throw XT(n,e)};import{once as S7,on as yMe}from"events";var E7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>MD({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),MD=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Hd({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:ox(t)}),tx(e,o);let s=Na(t,e,r),a=new AbortController,c={};return SMe(t,s,a),EMe({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),vMe({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},SMe=async(t,e,r)=>{try{await S7(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},EMe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await S7(t,"strict:error",{signal:r.signal});n.error=XT(i,e),r.abort()}catch{}},vMe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of yMe(r,"message",{signal:o.signal}))y7(s),yield c}catch{y7(s)}finally{o.abort(),rx(e,a),n||Wd(t),i&&await t}},y7=({error:t})=>{if(t)throw t};var b7=(t,{ipc:e})=>{Object.assign(t,x7(t,!1,e))},T7=()=>{let t=v7,e=!0,r=v7.channel!==void 0;return{...x7(t,e,r),getCancelSignal:PX.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},x7=(t,e,r)=>({sendMessage:lx.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:_7.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:E7.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as bMe}from"child_process";import{PassThrough as TMe,Readable as xMe,Writable as wMe,Duplex as AMe}from"stream";var w7=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{TD(n);let a=new bMe;RMe(a,n),Object.assign(a,{readable:IMe,writable:CMe,duplex:PMe});let c=Xd({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=OMe(c,s,i);return{subprocess:a,promise:l}},RMe=(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 TMe;return t.end(),t},IMe=()=>new xMe({read(){}}),CMe=()=>new wMe({write(){}}),PMe=()=>new AMe({read(){},write(){}}),OMe=async(t,e,r)=>Qd(t,e,r);import{createReadStream as A7,createWriteStream as R7}from"fs";import{Buffer as NMe}from"buffer";import{Readable as c_,Writable as MMe,Duplex as kMe}from"stream";var C7=(t,e)=>xx(DMe,t,e,!1),l_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Ma[t]}.`)},I7={fileNumber:l_,generator:CD,asyncGenerator:CD,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:kMe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},DMe={input:{...I7,fileUrl:({value:t})=>({stream:A7(t)}),filePath:({value:{file:t}})=>({stream:A7(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(NMe.from(t))})},output:{...I7,fileUrl:({value:t})=>({stream:R7(t)}),filePath:({value:{file:t,append:e}})=>({stream:R7(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:MMe.fromWeb(t)}),iterable:l_,asyncIterable:l_,string:l_,uint8Array:l_}};import{on as LMe,once as P7}from"events";import{PassThrough as $Me,getDefaultHighWaterMark as UMe}from"stream";import{finished as M7}from"stream/promises";function Il(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)DD(i);let e=t.some(({readableObjectMode:i})=>i),r=FMe(t,e),n=new kD({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var FMe=(t,e)=>{if(t.length===0)return UMe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},kD=class extends $Me{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(DD(e),this.#e.has(e))return;this.#e.add(e),this.#n??=BMe(this,this.#e,this.#o);let r=GMe({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(DD(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)}},BMe=async(t,e,r)=>{Ox(t,O7);let n=new AbortController;try{await Promise.race([jMe(t,n),zMe(t,e,r,n)])}finally{n.abort(),Ox(t,-O7)}},jMe=async(t,{signal:e})=>{try{await M7(t,{signal:e,cleanup:!0})}catch(r){throw k7(t,r),r}},zMe=async(t,e,r,{signal:n})=>{for await(let[i]of LMe(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},DD=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},GMe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{Ox(t,N7);let a=new AbortController;try{await Promise.race([VMe(o,e,a),qMe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),HMe({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),Ox(t,-N7)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?LD(t):WMe(t))},VMe=async(t,e,{signal:r})=>{try{await t,r.aborted||LD(e)}catch(n){r.aborted||k7(e,n)}},qMe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await M7(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;D7(s)?i.add(e):L7(t,s)}},HMe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await P7(t,i,{signal:o}),!t.readable)return P7(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},WMe=t=>{t.writable&&t.end()},k7=(t,e)=>{D7(e)?LD(t):L7(t,e)},D7=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",LD=t=>{(t.readable||t.writable)&&t.destroy()},L7=(t,e)=>{t.destroyed||(t.once("error",YMe),t.destroy(e))},YMe=()=>{},Ox=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},O7=2,N7=1;import{finished as $7}from"stream/promises";var tf=(t,e)=>{t.pipe(e),KMe(t,e),ZMe(t,e)},KMe=async(t,e)=>{if(!(wi(t)||wi(e))){try{await $7(t,{cleanup:!0,readable:!0,writable:!1})}catch{}$D(e)}},$D=t=>{t.writable&&t.end()},ZMe=async(t,e)=>{if(!(wi(t)||wi(e))){try{await $7(e,{cleanup:!0,readable:!1,writable:!0})}catch{}UD(t)}},UD=t=>{t.readable&&t.destroy()};var U7=(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)))JMe(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Yn.has(c)))QMe({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)}},JMe=(t,e,r,n)=>{r==="output"?tf(t.stdio[n],e):tf(e,t.stdio[n]);let i=XMe[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},XMe=["stdin","stdout","stderr"],QMe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;eke(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},eke=(t,{signal:e})=>{wi(t)&&xl(t,tke,e)},tke=2;import{addAbortListener as ike}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 Nx=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",FD=Symbol.for("signal-exit emitter"),BD=globalThis,rke=Object.defineProperty.bind(Object),jD=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(BD[FD])return BD[FD];rke(BD,FD,{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}},Mx=class{},nke=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),zD=class extends Mx{onExit(){return()=>{}}load(){}unload(){}},GD=class extends Mx{#e=VD.platform==="win32"?"SIGINT":"SIGHUP";#r=new jD;#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(!Nx(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 Nx(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"&&Nx(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)}},VD=globalThis.process,{onExit:F7,load:Dpt,unload:Lpt}=nke(Nx(VD)?new GD(VD):new zD);var B7=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=F7(()=>{t.kill()});ike(n,()=>{i()})};var z7=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=VT(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=oke(r,n,i),{sourceStream:d,sourceError:f}=ake(t,l),{options:p,fileDescriptors:h}=ho.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},oke=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=ske(t,e,...r),a=ex(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},ske=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(j7,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||Mk(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]=kT(r,...n);return{destination:e(j7)(i,o,s),pipeOptions:s}}if(ho.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}`)},j7=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),ake=(t,e)=>{try{return{sourceStream:Yd(t,e)}}catch(r){return{sourceError:r}}};var V7=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=cke({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw qD({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},cke=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return UD(t),n;if(e!==void 0)return $D(r),e},qD=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Xd({error:t,command:G7,escapedCommand:G7,fileDescriptors:e,options:r,startTime:n,isSync:!1}),G7="source.pipe(destination)";var q7=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 lke}from"stream/promises";var H7=(t,e,r)=>{let n=kx.has(e)?dke(t,e):uke(t,e);return xl(t,pke,r.signal),xl(e,hke,r.signal),fke(e),n},uke=(t,e)=>{let r=Il([t]);return tf(r,e),kx.set(e,r),r},dke=(t,e)=>{let r=kx.get(e);return r.add(t),r},fke=async t=>{try{await lke(t,{cleanup:!0,readable:!1,writable:!0})}catch{}kx.delete(t)},kx=new WeakMap,pke=2,hke=1;import{aborted as mke}from"util";var W7=(t,e)=>t===void 0?[]:[gke(t,e)],gke=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await mke(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 Dx=(t,...e)=>{if(Pt(e[0]))return Dx.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=z7(t,...e),i=_ke({...n,destination:r});return i.pipe=Dx.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},_ke=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=yke(t,i);V7({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=H7(e,o,d);return await Promise.race([q7(u),...W7(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},yke=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as wke}from"timers/promises";import{on as Ske}from"events";import{getDefaultHighWaterMark as Eke}from"stream";var Lx=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return vke(e,s),K7({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},vke=async(t,e)=>{try{await t}catch{}finally{e.abort()}},HD=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;bke(e,s,t);let a=t.readableObjectMode&&!o;return K7({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},bke=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},K7=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=Ske(t,"data",{signal:e.signal,highWaterMark:Y7,highWatermark:Y7});return Tke({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},WD=Eke(!0),Y7=WD,Tke=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=xke({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*s_(a)}},xke=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[Ax(t,r,!e),wx(t,i,!n,{})].filter(Boolean);var Z7=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=Ake({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([Rke(t),d]);return}let f=xD(c,r),p=HD({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([Ike({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},Ake=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!Cx({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=HD({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await a7(a,t,r,o)},Rke=async t=>{await wke(),t.readableFlowing===null&&t.resume()},Ike=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await gx(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await _x(r,{maxBuffer:o})):await Jd(r,{maxBuffer:o})}catch(a){return J7(aQ({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},YD=async t=>{try{return await t}catch(e){return J7(e)}},J7=({bufferedData:t})=>T9(t)?new Uint8Array(t):t;import{finished as Cke}from"stream/promises";var u_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=Pke(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],Cke(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||Mke(a,e,r,n)}finally{s.abort()}},Pke=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&Oke(t,r,n),n},Oke=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{Nke(e,r),n.call(t,...i)}},Nke=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Mke=(t,e,r,n)=>{if(!kke(t,e,r,n))throw t},kke=(t,e,r,n=!0)=>r.propagating?X7(t)||$x(t):(r.propagating=!0,KD(r,e)===n?X7(t):$x(t)),KD=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",$x=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",X7=t=>t?.code==="EPIPE";var Q7=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>ZD({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),ZD=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(KD(l,e)){await u;return}let[d]=await Promise.all([Z7({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 eee=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Il([t,e].filter(Boolean)):void 0,tee=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>ZD({...Dke(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:Lke(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),Dke=({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}},Lke=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as $ke}from"events";var ree=t=>Gd(t,"ipc"),nee=(t,e)=>{let r=GT(t);fo({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var iee=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=ree(o),a=ms(e,"ipc"),c=ms(r,"ipc");for await(let l of MD({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(cQ(t,i,c),i.push(l)),s&&nee(l,o);return i},oee=async(t,e)=>(await Promise.allSettled([t]),e);var see=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 b=f7(t,f),x={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},_=Q7({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:x}),A=tee({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:x}),R=[],C=iee({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:R,verboseInfo:p}),O=Uke(m,t,x),k=Fke(h,x);try{return await Promise.race([Promise.all([{},h7(b),Promise.all(_),A,C,BX(t,d),...O,...k]),S,Bke(t,E),...DX(t,o,f,E),...rX({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:E}),...MX({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:E})])}catch(B){return f.terminationReason??="other",Promise.all([{error:B},b,Promise.all(_.map(y=>YD(y))),YD(A),oee(C,R),Promise.allSettled(O),Promise.allSettled(k)])}},Uke=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:u_(n,i,r)),Fke=(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})=>u_(s,n,e,{isSameDirection:Yn.has(i),stopOnExit:i==="native"}))),Bke=async(t,{signal:e})=>{let[r]=await $ke(t,"error",{signal:e});throw r};var aee=()=>({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=po();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 jke}from"stream";import{callbackify as zke}from"util";import{finished as cee}from"stream/promises";var JD=async t=>{if(t!==void 0)try{await XD(t)}catch{}},lee=async t=>{if(t!==void 0)try{await QD(t)}catch{}},XD=async t=>{await cee(t,{cleanup:!0,readable:!1,writable:!0})},QD=async t=>{await cee(t,{cleanup:!0,readable:!0,writable:!1})},Ux=async(t,e)=>{if(await t,e)throw e},Fx=(t,e,r)=>{r&&!$x(r)?t.destroy(r):e&&t.destroy()};var uee=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||yn.has(r),{subprocessStdout:a,waitReadableDestroy:c}=eL(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=tL(a,s),{read:f,onStdoutDataDone:p}=rL({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new jke({read:f,destroy:zke(iL.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return nL({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},eL=(t,e,r)=>{let n=Yd(t,e),i=d_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},tL=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:WD},rL=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=po(),s=Lx({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){Gke(this,s,o)},onStdoutDataDone:o}},Gke=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},nL=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await QD(t),await n,await JD(i),await e,r.readable&&r.push(null)}catch(o){await JD(i),dee(r,o)}},iL=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await rf(r,e)&&(dee(t,n),await Ux(e,n))},dee=(t,e)=>{Fx(t,t.readable,e)};import{Writable as Vke}from"stream";import{callbackify as fee}from"util";var pee=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=oL(t,r,e),s=new Vke({...sL(n,t,i),destroy:fee(cL.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return aL(n,s),s},oL=(t,e,r)=>{let n=ex(t,e),i=d_(r,n,"writableFinal"),o=d_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},sL=(t,e,r)=>({write:qke.bind(void 0,t),final:fee(Hke.bind(void 0,t,e,r))}),qke=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},Hke=async(t,e,r)=>{await rf(r,e)&&(t.writable&&t.end(),await e)},aL=async(t,e,r)=>{try{await XD(t),e.writable&&e.end()}catch(n){await lee(r),hee(e,n)}},cL=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await rf(r,e),await rf(n,e)&&(hee(t,i),await Ux(e,i))},hee=(t,e)=>{Fx(t,t.writable,e)};import{Duplex as Wke}from"stream";import{callbackify as Yke}from"util";var mee=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||yn.has(r),{subprocessStdout:c,waitReadableDestroy:l}=eL(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=oL(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=tL(c,a),{read:S,onStdoutDataDone:E}=rL({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),b=new Wke({read:S,...sL(u,t,d),destroy:Yke(Kke.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 nL({subprocessStdout:c,onStdoutDataDone:E,readable:b,subprocess:t,subprocessStdin:u}),aL(u,b,c),b},Kke=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([iL({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),cL({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var lL=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||yn.has(e),s=Yd(t,r),a=Lx({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return Zke(a,s,t)},Zke=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var gee=(t,{encoding:e})=>{let r=aee();t.readable=uee.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=pee.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=mee.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=lL.bind(void 0,t,e),t[Symbol.asyncIterator]=lL.bind(void 0,t,e,{})};var _ee=(t,e)=>{for(let[r,n]of Xke){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},Jke=(async()=>{})().constructor.prototype,Xke=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(Jke,t)]);var yee=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=tDe(t,e,r),{subprocess:f,promise:p}=nDe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=Dx.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),_ee(f,p),ho.set(f,{options:u,fileDescriptors:d}),f},tDe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=qT(t,e,r),{file:a,commandArguments:c,options:l}=dx(t,e,r),u=rDe(l),d=C7(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},rDe=({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}},nDe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=eDe(...fx(t,e,r))}catch(h){return w7({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;Qke(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];U7(c,a,l),B7(c,r,l);let d={},f=po();c.kill=eX.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=eee(c,r),gee(c,r),b7(c,r);let p=iDe({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}},iDe=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 see({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)=>_s(_,e,A)),b=_s(m,e,"all"),x=oDe({errorInfo:d,exitCode:f,signal:p,stdio:E,all:b,ipcOutput:S,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Qd(x,n,e)},oDe=({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 mo,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):Ex({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var Bx=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,sDe(n,t[n],i)]));return{...t,...r}},sDe=(t,e,r)=>aDe.has(t)&&Pt(e)&&Pt(r)?{...e,...r}:r,aDe=new Set(["env",...Fk]);var ka=(t,e,r,n)=>{let i=(s,a,c)=>ka(s,a,r,c),o=(...s)=>cDe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},cDe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Pt(o))return i(t,Bx(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=lDe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?g7(a,c,l):yee(a,c,l,i)},lDe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=C9(e)?P9(e,r):[e,...r],[s,a,c]=kT(...o),l=Bx(Bx(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 See=({file:t,commandArguments:e})=>vee(t,e),Eee=({file:t,commandArguments:e})=>({...vee(t,e),isSync:!0}),vee=(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]=uDe(t);return{file:r,commandArguments:n}},uDe=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(dDe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},dDe=/ +/g;var bee=(t,e,r)=>{t.sync=e(fDe,r),t.s=t.sync},Tee=({options:t})=>xee(t),fDe=({options:t})=>({...xee(t),isSync:!0}),xee=t=>({options:{...pDe(t),...t}}),pDe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},wee={preferLocal:!0};var Aee=ka(()=>({})),wgt=ka(()=>({isSync:!0})),Ree=ka(See),Agt=ka(Eee),Rgt=ka($X),Igt=ka(Tee,{},wee,bee),{sendMessage:Cgt,getOneMessage:Pgt,getEachMessage:Ogt,getCancelSignal:Ngt}=T7();var Iee=!1,Cee=()=>{Iee=!0},_o=()=>Iee;var f_=null,Pee=t=>(f_&&f_.destroy(),f_=new ys({totalAllowedTime:t}),f_),Oee=()=>f_;var ys=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&&_o())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 IT({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}),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 Nee={name:"@netlify/agent-runner-cli",type:"module",version:"1.142.1-test.8",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.0","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"2.1.197","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@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","opencode-ai":"1.17.19",zod:"^4.4.3"}};var _De=mDe(import.meta.url),yDe=Ss.dirname(_De),SDe=gDe(import.meta.url),nf=ye("shell"),uL=new Set,Mee={preferLocal:!0},Mr=(t,e,r)=>{let[n,i]=EDe(e,r),o={...Mee,...i},s=Aee(t,n,o);Dee(s,o),Uee(s);let a=r?.idleTimeout;return a&&a>0&&$ee(s,a),s},kee=(t,e)=>{let r={...Mee,...e},n=Ree(t,r);return Dee(n,r),Uee(n),e?.idleTimeout&&e.idleTimeout>0&&$ee(n,e.idleTimeout),n},EDe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},Dee=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(Es.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new zg).pipe(Es.stdout),t.stderr?.pipe(new zg).pipe(Es.stderr);return}t.stdout?.pipe(Es.stdout),t.stderr?.pipe(Es.stderr)},dL=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Es.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}},Lee=t=>dL(t,"SIGKILL"),$ee=(t,e)=>{let r=null,n=()=>{nf.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),dL(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(nf.log(`Force killing idle process ${t.pid}`),Lee(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)},Uee=t=>{uL.add(t);let e=Oee();if(e){let r=e.onTimesUp(()=>{nf.log(`Global timer expired, killing process ${t.pid}`),dL(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(nf.log(`Force killing process ${t.pid} after timeout`),Lee(t))},5e3)});t.on("exit",()=>{uL.delete(t),r()}),t.on("error",()=>{uL.delete(t),r()})}};function zx(t,e){return!!Ci(t,e)}function Ci(t,e){if(!Es.env.NETLIFY_LOCAL_MODE)try{let i=SDe.resolve(Nee.name),o=Ss.dirname(i);for(;o!==Ss.dirname(o);){let s=Ss.dirname(o);if(Ss.basename(s)==="node_modules"){let a=Ss.join(s,".bin",e);if(jx.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(Es.env.NODE_PATH){let i=Ss.join(Es.env.NODE_PATH,".bin",e);if(jx.existsSync(i))return i}let r=Ss.join(t,"node_modules",".bin",e);if(jx.existsSync(r))return r;let n=Ss.join(yDe,"..","node_modules",".bin",e);if(jx.existsSync(n))return n}var vDe=ye("utils"),bDe=t=>new Promise(e=>{setTimeout(e,t)});var Gx=(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 bDe(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},Fee=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):vDe.error("Could not parse JSON",n))}},TDe=t=>t.charAt(0).toUpperCase()+t.slice(1),yo=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():TDe(e)).join(" ");function vs(t,e){e&&t.log(`Skill invoked: ${e}`)}var Vx=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),Bee=(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 fL=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}},xDe=1e4,pL=(t,e=xDe)=>{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 jee}from"buffer";import wDe from"path";var zee=ye("repo"),Zr=(t,e={})=>Mr("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),qx=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{zee.info("Getting runner diffs");let n=await RDe(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let m=CDe(o);await PDe(m,r)}zee.info("Changes after processing"),await mL(r);let s=await gL(o,r);if(await hL(s,r),i=await IDe(r),!i)return{hasChanges:!1,ignored:s};await Zr(["commit","-m","Agent runner"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await Zr(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(i=!!l,!i)return await Gee(r),{hasChanges:!1,ignored:s};let u=await Zr(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,p;if(t.sha){let m=await Zr(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let S=await Zr(["diff",t.sha,"HEAD","--binary"],a),E=String(S.stdout??"");f!==E&&(p=jee.from(E).toString("base64"))}await Gee(r);let h={hasChanges:!0,diff:l,resultDiff:f,ignored:s};return l!==d&&(h.diffBinary=jee.from(d).toString("base64")),p&&(h.resultDiffBinary=p),h},Gee=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Zr(["reset","--soft","HEAD~1"],{cwd:t})},hL=async(t=[],e=process.cwd())=>{await Zr(["add",".",...t],{cwd:e})},mL=async(t=process.cwd())=>{let e=await Zr(["status","-s"],{cwd:t});return String(e.stdout??"")},Vee=/.. (.+)?\.log$/,ADe=[Vee],RDe=async(t=process.cwd())=>{let e=await mL(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
102
|
+
if (condition) { yield value; }`)};import{Buffer as NNe}from"buffer";import{StringDecoder as MNe}from"string_decoder";var Ax=(t,e,r)=>{if(r)return;if(t)return{transform:kNe.bind(void 0,new TextEncoder)};let n=new MNe(e);return{transform:DNe.bind(void 0,n),final:LNe.bind(void 0,n)}},kNe=function*(t,e){NNe.isBuffer(e)?yield hs(e):typeof e=="string"?yield t.encode(e):yield e},DNe=function*(t,e){yield Bt(e)?t.write(e):e},LNe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as e7}from"util";var RD=e7(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),Rx=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=UNe}=e[r];for await(let i of n(t))yield*Rx(i,e,r+1)},t7=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*$Ne(r,Number(e),t)},$Ne=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*Rx(n,r,e+1)},r7=e7(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),UNe=function*(t){yield t};var ID=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},n7=(t,e)=>[...e.flatMap(r=>[...Rl(r,t,0)]),...s_(t)],Rl=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=BNe}=e[r];for(let i of n(t))yield*Rl(i,e,r+1)},s_=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*FNe(r,Number(e),t)},FNe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Rl(n,r,e+1)},BNe=function*(t){yield t};var CD=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=o7(t,s,o),l=Al(e),u=Al(r),d=l?RD.bind(void 0,Rx,a):ID.bind(void 0,Rl),f=l||u?RD.bind(void 0,t7,a):ID.bind(void 0,s_),p=l||u?r7.bind(void 0,a):void 0;return{stream:new jNe({writableObjectMode:n,writableHighWaterMark:i7(n),readableObjectMode:i,readableHighWaterMark:i7(i),transform(m,S,E){d([m,c,0],this,E)},flush(m){f([c],this,m)},destroy:p})}},Ix=(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=o7(s,r,a);t=n7(c,t)}return t},o7=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:JQ(n,a)},Ax(r,s,n),wx(r,o,n,c),{transform:t,final:e},{transform:XQ(i,a)},ZQ({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var s7=(t,e)=>{for(let r of zNe(t))GNe(t,r,e)},zNe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),GNe=(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 ${Ma[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>VNe(a,n));r.input=Zg(s)},VNe=(t,e)=>{let r=Ix(t,e,"utf8",!0);return qNe(r),Zg(r)},qNe=t=>{let e=t.find(r=>typeof r!="string"&&!Bt(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 KNe,appendFileSync as ZNe}from"fs";var Cx=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Gd(r,n)&&!yn.has(e)&&HNe(n)&&(t.some(({type:i,value:o})=>i==="native"&&WNe.has(o))||t.every(({type:i})=>Yn.has(i))),HNe=t=>t===1||t===2,WNe=new Set(["pipe","overlapped"]),a7=async(t,e,r,n)=>{for await(let i of t)YNe(e)||l7(i,r,n)},c7=(t,e,r)=>{for(let n of t)l7(n,e,r)},YNe=t=>t._readableState.pipes.length>0,l7=(t,e,r)=>{let n=GT(t);fo({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var u7=({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)=>JNe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},JNe=({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=dQ(t,o,d),p=hs(f),{stdioItems:h,objectMode:m}=e[r],S=XNe([p],h,c,n),{serializedResult:E,finalResult:b=E}=QNe({chunks:S,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});eMe({serializedResult:E,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let x=a[r]?b:void 0;try{return n.error===void 0&&tMe(E,h,i),x}catch(_){return n.error=_,x}},XNe=(t,e,r,n)=>{try{return Ix(t,e,r,!1)}catch(i){return n.error=i,t}},QNe=({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=w9(t,r);return n[o]?{serializedResult:s,finalResult:AD(s,!i[o],e)}:{serializedResult:s}},eMe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!Cx({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=AD(t,!1,s);try{c7(a,e,n)}catch(c){r.error??=c}},tMe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>Tx.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?ZNe(n,t):(r.add(o),KNe(n,t))}};var d7=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,_s(e,r,"all")]:Array.isArray(e)?[_s(t,r,"all"),...e]:Bt(t)&&Bt(e)?Dk([t,e]):`${t}${e}`};import{once as PD}from"events";var f7=async(t,e)=>{let[r,n]=await rMe(t);return e.isForcefullyTerminated??=!1,[r,n]},rMe=async t=>{let[e,r]=await Promise.allSettled([PD(t,"spawn"),PD(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?p7(t):r.value},p7=async t=>{try{return await PD(t,"exit")}catch{return p7(t)}},h7=async t=>{let[e,r]=await t;if(!nMe(e,r)&&OD(e,r))throw new Ai;return[e,r]},nMe=(t,e)=>t===void 0&&e===void 0,OD=(t,e)=>t!==0||e!==null;var m7=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=iMe(t,e,r),s=o?.code==="ETIMEDOUT",a=uQ(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},iMe=(t,e,r)=>t!==void 0?t:OD(e,r)?new Ai:void 0;var g7=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=sMe(t,e,r),d=lMe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Qd(d,c,l)},sMe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=qT(t,e,r),a=aMe(r),{file:c,commandArguments:l,options:u}=dx(t,e,a);cMe(u);let d=HQ(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},aMe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,cMe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&Px("ipcInput"),t&&Px("ipc: true"),r&&Px("detached: true"),n&&Px("cancelSignal")},Px=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},lMe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=uMe({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}=m7(c,r),{output:h,error:m=l}=u7({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),S=h.map((b,x)=>_s(b,r,x)),E=_s(d7(h,r),r,"all");return fMe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:S,all:E,options:r,command:n,escapedCommand:i,startTime:a})},uMe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{s7(o,r);let a=dMe(r);return oMe(...fx(t,e,a))}catch(a){return Xd({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},dMe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:Sx(e)}),fMe=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?Ex({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):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 Qke}from"events";import{spawn as eDe}from"child_process";import v7 from"process";import{once as ND,on as pMe}from"events";var _7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Hd({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:ox(t)}),hMe({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),hMe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{tx(e,i);let o=Na(t,e,r),s=new AbortController;try{return await Promise.race([mMe(o,n,s),gMe(o,r,s),_Me(o,r,s)])}catch(a){throw Wd(t),a}finally{s.abort(),rx(e,i)}},mMe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await ND(t,"message",{signal:r});return n}for await(let[n]of pMe(t,"message",{signal:r}))if(e(n))return n},gMe=async(t,e,{signal:r})=>{await ND(t,"disconnect",{signal:r}),nX(e)},_Me=async(t,e,{signal:r})=>{let[n]=await ND(t,"strict:error",{signal:r});throw XT(n,e)};import{once as S7,on as yMe}from"events";var E7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>MD({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),MD=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Hd({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:ox(t)}),tx(e,o);let s=Na(t,e,r),a=new AbortController,c={};return SMe(t,s,a),EMe({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),vMe({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},SMe=async(t,e,r)=>{try{await S7(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},EMe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await S7(t,"strict:error",{signal:r.signal});n.error=XT(i,e),r.abort()}catch{}},vMe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of yMe(r,"message",{signal:o.signal}))y7(s),yield c}catch{y7(s)}finally{o.abort(),rx(e,a),n||Wd(t),i&&await t}},y7=({error:t})=>{if(t)throw t};var b7=(t,{ipc:e})=>{Object.assign(t,x7(t,!1,e))},T7=()=>{let t=v7,e=!0,r=v7.channel!==void 0;return{...x7(t,e,r),getCancelSignal:PX.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},x7=(t,e,r)=>({sendMessage:lx.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:_7.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:E7.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as bMe}from"child_process";import{PassThrough as TMe,Readable as xMe,Writable as wMe,Duplex as AMe}from"stream";var w7=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{TD(n);let a=new bMe;RMe(a,n),Object.assign(a,{readable:IMe,writable:CMe,duplex:PMe});let c=Xd({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=OMe(c,s,i);return{subprocess:a,promise:l}},RMe=(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 TMe;return t.end(),t},IMe=()=>new xMe({read(){}}),CMe=()=>new wMe({write(){}}),PMe=()=>new AMe({read(){},write(){}}),OMe=async(t,e,r)=>Qd(t,e,r);import{createReadStream as A7,createWriteStream as R7}from"fs";import{Buffer as NMe}from"buffer";import{Readable as c_,Writable as MMe,Duplex as kMe}from"stream";var C7=(t,e)=>xx(DMe,t,e,!1),l_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Ma[t]}.`)},I7={fileNumber:l_,generator:CD,asyncGenerator:CD,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:kMe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},DMe={input:{...I7,fileUrl:({value:t})=>({stream:A7(t)}),filePath:({value:{file:t}})=>({stream:A7(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(NMe.from(t))})},output:{...I7,fileUrl:({value:t})=>({stream:R7(t)}),filePath:({value:{file:t,append:e}})=>({stream:R7(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:MMe.fromWeb(t)}),iterable:l_,asyncIterable:l_,string:l_,uint8Array:l_}};import{on as LMe,once as P7}from"events";import{PassThrough as $Me,getDefaultHighWaterMark as UMe}from"stream";import{finished as M7}from"stream/promises";function Il(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)DD(i);let e=t.some(({readableObjectMode:i})=>i),r=FMe(t,e),n=new kD({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var FMe=(t,e)=>{if(t.length===0)return UMe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},kD=class extends $Me{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(DD(e),this.#e.has(e))return;this.#e.add(e),this.#n??=BMe(this,this.#e,this.#o);let r=GMe({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(DD(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)}},BMe=async(t,e,r)=>{Ox(t,O7);let n=new AbortController;try{await Promise.race([jMe(t,n),zMe(t,e,r,n)])}finally{n.abort(),Ox(t,-O7)}},jMe=async(t,{signal:e})=>{try{await M7(t,{signal:e,cleanup:!0})}catch(r){throw k7(t,r),r}},zMe=async(t,e,r,{signal:n})=>{for await(let[i]of LMe(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},DD=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},GMe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{Ox(t,N7);let a=new AbortController;try{await Promise.race([VMe(o,e,a),qMe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),HMe({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),Ox(t,-N7)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?LD(t):WMe(t))},VMe=async(t,e,{signal:r})=>{try{await t,r.aborted||LD(e)}catch(n){r.aborted||k7(e,n)}},qMe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await M7(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;D7(s)?i.add(e):L7(t,s)}},HMe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await P7(t,i,{signal:o}),!t.readable)return P7(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},WMe=t=>{t.writable&&t.end()},k7=(t,e)=>{D7(e)?LD(t):L7(t,e)},D7=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",LD=t=>{(t.readable||t.writable)&&t.destroy()},L7=(t,e)=>{t.destroyed||(t.once("error",YMe),t.destroy(e))},YMe=()=>{},Ox=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},O7=2,N7=1;import{finished as $7}from"stream/promises";var tf=(t,e)=>{t.pipe(e),KMe(t,e),ZMe(t,e)},KMe=async(t,e)=>{if(!(wi(t)||wi(e))){try{await $7(t,{cleanup:!0,readable:!0,writable:!1})}catch{}$D(e)}},$D=t=>{t.writable&&t.end()},ZMe=async(t,e)=>{if(!(wi(t)||wi(e))){try{await $7(e,{cleanup:!0,readable:!1,writable:!0})}catch{}UD(t)}},UD=t=>{t.readable&&t.destroy()};var U7=(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)))JMe(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Yn.has(c)))QMe({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)}},JMe=(t,e,r,n)=>{r==="output"?tf(t.stdio[n],e):tf(e,t.stdio[n]);let i=XMe[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},XMe=["stdin","stdout","stderr"],QMe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;eke(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},eke=(t,{signal:e})=>{wi(t)&&xl(t,tke,e)},tke=2;import{addAbortListener as ike}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 Nx=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",FD=Symbol.for("signal-exit emitter"),BD=globalThis,rke=Object.defineProperty.bind(Object),jD=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(BD[FD])return BD[FD];rke(BD,FD,{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}},Mx=class{},nke=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),zD=class extends Mx{onExit(){return()=>{}}load(){}unload(){}},GD=class extends Mx{#e=VD.platform==="win32"?"SIGINT":"SIGHUP";#r=new jD;#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(!Nx(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 Nx(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"&&Nx(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)}},VD=globalThis.process,{onExit:F7,load:Dpt,unload:Lpt}=nke(Nx(VD)?new GD(VD):new zD);var B7=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=F7(()=>{t.kill()});ike(n,()=>{i()})};var z7=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=VT(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=oke(r,n,i),{sourceStream:d,sourceError:f}=ake(t,l),{options:p,fileDescriptors:h}=ho.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},oke=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=ske(t,e,...r),a=ex(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},ske=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(j7,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||Mk(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]=kT(r,...n);return{destination:e(j7)(i,o,s),pipeOptions:s}}if(ho.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}`)},j7=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),ake=(t,e)=>{try{return{sourceStream:Yd(t,e)}}catch(r){return{sourceError:r}}};var V7=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=cke({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw qD({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},cke=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return UD(t),n;if(e!==void 0)return $D(r),e},qD=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Xd({error:t,command:G7,escapedCommand:G7,fileDescriptors:e,options:r,startTime:n,isSync:!1}),G7="source.pipe(destination)";var q7=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 lke}from"stream/promises";var H7=(t,e,r)=>{let n=kx.has(e)?dke(t,e):uke(t,e);return xl(t,pke,r.signal),xl(e,hke,r.signal),fke(e),n},uke=(t,e)=>{let r=Il([t]);return tf(r,e),kx.set(e,r),r},dke=(t,e)=>{let r=kx.get(e);return r.add(t),r},fke=async t=>{try{await lke(t,{cleanup:!0,readable:!1,writable:!0})}catch{}kx.delete(t)},kx=new WeakMap,pke=2,hke=1;import{aborted as mke}from"util";var W7=(t,e)=>t===void 0?[]:[gke(t,e)],gke=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await mke(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 Dx=(t,...e)=>{if(Pt(e[0]))return Dx.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=z7(t,...e),i=_ke({...n,destination:r});return i.pipe=Dx.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},_ke=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=yke(t,i);V7({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=H7(e,o,d);return await Promise.race([q7(u),...W7(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},yke=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as wke}from"timers/promises";import{on as Ske}from"events";import{getDefaultHighWaterMark as Eke}from"stream";var Lx=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return vke(e,s),K7({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},vke=async(t,e)=>{try{await t}catch{}finally{e.abort()}},HD=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;bke(e,s,t);let a=t.readableObjectMode&&!o;return K7({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},bke=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},K7=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=Ske(t,"data",{signal:e.signal,highWaterMark:Y7,highWatermark:Y7});return Tke({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},WD=Eke(!0),Y7=WD,Tke=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=xke({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*s_(a)}},xke=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[Ax(t,r,!e),wx(t,i,!n,{})].filter(Boolean);var Z7=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=Ake({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([Rke(t),d]);return}let f=xD(c,r),p=HD({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([Ike({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},Ake=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!Cx({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=HD({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await a7(a,t,r,o)},Rke=async t=>{await wke(),t.readableFlowing===null&&t.resume()},Ike=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await gx(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await _x(r,{maxBuffer:o})):await Jd(r,{maxBuffer:o})}catch(a){return J7(aQ({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},YD=async t=>{try{return await t}catch(e){return J7(e)}},J7=({bufferedData:t})=>T9(t)?new Uint8Array(t):t;import{finished as Cke}from"stream/promises";var u_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=Pke(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],Cke(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||Mke(a,e,r,n)}finally{s.abort()}},Pke=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&Oke(t,r,n),n},Oke=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{Nke(e,r),n.call(t,...i)}},Nke=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Mke=(t,e,r,n)=>{if(!kke(t,e,r,n))throw t},kke=(t,e,r,n=!0)=>r.propagating?X7(t)||$x(t):(r.propagating=!0,KD(r,e)===n?X7(t):$x(t)),KD=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",$x=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",X7=t=>t?.code==="EPIPE";var Q7=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>ZD({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),ZD=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(KD(l,e)){await u;return}let[d]=await Promise.all([Z7({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 eee=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Il([t,e].filter(Boolean)):void 0,tee=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>ZD({...Dke(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:Lke(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),Dke=({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}},Lke=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as $ke}from"events";var ree=t=>Gd(t,"ipc"),nee=(t,e)=>{let r=GT(t);fo({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var iee=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=ree(o),a=ms(e,"ipc"),c=ms(r,"ipc");for await(let l of MD({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(cQ(t,i,c),i.push(l)),s&&nee(l,o);return i},oee=async(t,e)=>(await Promise.allSettled([t]),e);var see=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 b=f7(t,f),x={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},_=Q7({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:x}),A=tee({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:x}),R=[],C=iee({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:R,verboseInfo:p}),O=Uke(m,t,x),k=Fke(h,x);try{return await Promise.race([Promise.all([{},h7(b),Promise.all(_),A,C,BX(t,d),...O,...k]),S,Bke(t,E),...DX(t,o,f,E),...rX({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:E}),...MX({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:E})])}catch(B){return f.terminationReason??="other",Promise.all([{error:B},b,Promise.all(_.map(y=>YD(y))),YD(A),oee(C,R),Promise.allSettled(O),Promise.allSettled(k)])}},Uke=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:u_(n,i,r)),Fke=(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})=>u_(s,n,e,{isSameDirection:Yn.has(i),stopOnExit:i==="native"}))),Bke=async(t,{signal:e})=>{let[r]=await $ke(t,"error",{signal:e});throw r};var aee=()=>({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=po();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 jke}from"stream";import{callbackify as zke}from"util";import{finished as cee}from"stream/promises";var JD=async t=>{if(t!==void 0)try{await XD(t)}catch{}},lee=async t=>{if(t!==void 0)try{await QD(t)}catch{}},XD=async t=>{await cee(t,{cleanup:!0,readable:!1,writable:!0})},QD=async t=>{await cee(t,{cleanup:!0,readable:!0,writable:!1})},Ux=async(t,e)=>{if(await t,e)throw e},Fx=(t,e,r)=>{r&&!$x(r)?t.destroy(r):e&&t.destroy()};var uee=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||yn.has(r),{subprocessStdout:a,waitReadableDestroy:c}=eL(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=tL(a,s),{read:f,onStdoutDataDone:p}=rL({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new jke({read:f,destroy:zke(iL.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return nL({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},eL=(t,e,r)=>{let n=Yd(t,e),i=d_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},tL=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:WD},rL=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=po(),s=Lx({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){Gke(this,s,o)},onStdoutDataDone:o}},Gke=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},nL=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await QD(t),await n,await JD(i),await e,r.readable&&r.push(null)}catch(o){await JD(i),dee(r,o)}},iL=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await rf(r,e)&&(dee(t,n),await Ux(e,n))},dee=(t,e)=>{Fx(t,t.readable,e)};import{Writable as Vke}from"stream";import{callbackify as fee}from"util";var pee=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=oL(t,r,e),s=new Vke({...sL(n,t,i),destroy:fee(cL.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return aL(n,s),s},oL=(t,e,r)=>{let n=ex(t,e),i=d_(r,n,"writableFinal"),o=d_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},sL=(t,e,r)=>({write:qke.bind(void 0,t),final:fee(Hke.bind(void 0,t,e,r))}),qke=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},Hke=async(t,e,r)=>{await rf(r,e)&&(t.writable&&t.end(),await e)},aL=async(t,e,r)=>{try{await XD(t),e.writable&&e.end()}catch(n){await lee(r),hee(e,n)}},cL=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await rf(r,e),await rf(n,e)&&(hee(t,i),await Ux(e,i))},hee=(t,e)=>{Fx(t,t.writable,e)};import{Duplex as Wke}from"stream";import{callbackify as Yke}from"util";var mee=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||yn.has(r),{subprocessStdout:c,waitReadableDestroy:l}=eL(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=oL(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=tL(c,a),{read:S,onStdoutDataDone:E}=rL({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),b=new Wke({read:S,...sL(u,t,d),destroy:Yke(Kke.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 nL({subprocessStdout:c,onStdoutDataDone:E,readable:b,subprocess:t,subprocessStdin:u}),aL(u,b,c),b},Kke=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([iL({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),cL({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var lL=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||yn.has(e),s=Yd(t,r),a=Lx({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return Zke(a,s,t)},Zke=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var gee=(t,{encoding:e})=>{let r=aee();t.readable=uee.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=pee.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=mee.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=lL.bind(void 0,t,e),t[Symbol.asyncIterator]=lL.bind(void 0,t,e,{})};var _ee=(t,e)=>{for(let[r,n]of Xke){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},Jke=(async()=>{})().constructor.prototype,Xke=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(Jke,t)]);var yee=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=tDe(t,e,r),{subprocess:f,promise:p}=nDe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=Dx.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),_ee(f,p),ho.set(f,{options:u,fileDescriptors:d}),f},tDe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=qT(t,e,r),{file:a,commandArguments:c,options:l}=dx(t,e,r),u=rDe(l),d=C7(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},rDe=({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}},nDe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=eDe(...fx(t,e,r))}catch(h){return w7({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;Qke(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];U7(c,a,l),B7(c,r,l);let d={},f=po();c.kill=eX.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=eee(c,r),gee(c,r),b7(c,r);let p=iDe({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}},iDe=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 see({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)=>_s(_,e,A)),b=_s(m,e,"all"),x=oDe({errorInfo:d,exitCode:f,signal:p,stdio:E,all:b,ipcOutput:S,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Qd(x,n,e)},oDe=({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 mo,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):Ex({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var Bx=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,sDe(n,t[n],i)]));return{...t,...r}},sDe=(t,e,r)=>aDe.has(t)&&Pt(e)&&Pt(r)?{...e,...r}:r,aDe=new Set(["env",...Fk]);var ka=(t,e,r,n)=>{let i=(s,a,c)=>ka(s,a,r,c),o=(...s)=>cDe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},cDe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Pt(o))return i(t,Bx(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=lDe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?g7(a,c,l):yee(a,c,l,i)},lDe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=C9(e)?P9(e,r):[e,...r],[s,a,c]=kT(...o),l=Bx(Bx(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 See=({file:t,commandArguments:e})=>vee(t,e),Eee=({file:t,commandArguments:e})=>({...vee(t,e),isSync:!0}),vee=(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]=uDe(t);return{file:r,commandArguments:n}},uDe=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(dDe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},dDe=/ +/g;var bee=(t,e,r)=>{t.sync=e(fDe,r),t.s=t.sync},Tee=({options:t})=>xee(t),fDe=({options:t})=>({...xee(t),isSync:!0}),xee=t=>({options:{...pDe(t),...t}}),pDe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},wee={preferLocal:!0};var Aee=ka(()=>({})),wgt=ka(()=>({isSync:!0})),Ree=ka(See),Agt=ka(Eee),Rgt=ka($X),Igt=ka(Tee,{},wee,bee),{sendMessage:Cgt,getOneMessage:Pgt,getEachMessage:Ogt,getCancelSignal:Ngt}=T7();var Iee=!1,Cee=()=>{Iee=!0},_o=()=>Iee;var f_=null,Pee=t=>(f_&&f_.destroy(),f_=new ys({totalAllowedTime:t}),f_),Oee=()=>f_;var ys=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&&_o())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 IT({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}),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 Nee={name:"@netlify/agent-runner-cli",type:"module",version:"1.142.1-test.9",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.0","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"2.1.197","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@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","opencode-ai":"1.17.19",zod:"^4.4.3"}};var _De=mDe(import.meta.url),yDe=Ss.dirname(_De),SDe=gDe(import.meta.url),nf=ye("shell"),uL=new Set,Mee={preferLocal:!0},Mr=(t,e,r)=>{let[n,i]=EDe(e,r),o={...Mee,...i},s=Aee(t,n,o);Dee(s,o),Uee(s);let a=r?.idleTimeout;return a&&a>0&&$ee(s,a),s},kee=(t,e)=>{let r={...Mee,...e},n=Ree(t,r);return Dee(n,r),Uee(n),e?.idleTimeout&&e.idleTimeout>0&&$ee(n,e.idleTimeout),n},EDe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},Dee=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(Es.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new zg).pipe(Es.stdout),t.stderr?.pipe(new zg).pipe(Es.stderr);return}t.stdout?.pipe(Es.stdout),t.stderr?.pipe(Es.stderr)},dL=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Es.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}},Lee=t=>dL(t,"SIGKILL"),$ee=(t,e)=>{let r=null,n=()=>{nf.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),dL(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(nf.log(`Force killing idle process ${t.pid}`),Lee(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)},Uee=t=>{uL.add(t);let e=Oee();if(e){let r=e.onTimesUp(()=>{nf.log(`Global timer expired, killing process ${t.pid}`),dL(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(nf.log(`Force killing process ${t.pid} after timeout`),Lee(t))},5e3)});t.on("exit",()=>{uL.delete(t),r()}),t.on("error",()=>{uL.delete(t),r()})}};function zx(t,e){return!!Ci(t,e)}function Ci(t,e){if(!Es.env.NETLIFY_LOCAL_MODE)try{let i=SDe.resolve(Nee.name),o=Ss.dirname(i);for(;o!==Ss.dirname(o);){let s=Ss.dirname(o);if(Ss.basename(s)==="node_modules"){let a=Ss.join(s,".bin",e);if(jx.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(Es.env.NODE_PATH){let i=Ss.join(Es.env.NODE_PATH,".bin",e);if(jx.existsSync(i))return i}let r=Ss.join(t,"node_modules",".bin",e);if(jx.existsSync(r))return r;let n=Ss.join(yDe,"..","node_modules",".bin",e);if(jx.existsSync(n))return n}var vDe=ye("utils"),bDe=t=>new Promise(e=>{setTimeout(e,t)});var Gx=(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 bDe(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},Fee=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):vDe.error("Could not parse JSON",n))}},TDe=t=>t.charAt(0).toUpperCase()+t.slice(1),yo=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():TDe(e)).join(" ");function vs(t,e){e&&t.log(`Skill invoked: ${e}`)}var Vx=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),Bee=(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 fL=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}},xDe=1e4,pL=(t,e=xDe)=>{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 jee}from"buffer";import wDe from"path";var zee=ye("repo"),Zr=(t,e={})=>Mr("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),qx=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{zee.info("Getting runner diffs");let n=await RDe(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let m=CDe(o);await PDe(m,r)}zee.info("Changes after processing"),await mL(r);let s=await gL(o,r);if(await hL(s,r),i=await IDe(r),!i)return{hasChanges:!1,ignored:s};await Zr(["commit","-m","Agent runner"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await Zr(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(i=!!l,!i)return await Gee(r),{hasChanges:!1,ignored:s};let u=await Zr(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,p;if(t.sha){let m=await Zr(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let S=await Zr(["diff",t.sha,"HEAD","--binary"],a),E=String(S.stdout??"");f!==E&&(p=jee.from(E).toString("base64"))}await Gee(r);let h={hasChanges:!0,diff:l,resultDiff:f,ignored:s};return l!==d&&(h.diffBinary=jee.from(d).toString("base64")),p&&(h.resultDiffBinary=p),h},Gee=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Zr(["reset","--soft","HEAD~1"],{cwd:t})},hL=async(t=[],e=process.cwd())=>{await Zr(["add",".",...t],{cwd:e})},mL=async(t=process.cwd())=>{let e=await Zr(["status","-s"],{cwd:t});return String(e.stdout??"")},Vee=/.. (.+)?\.log$/,ADe=[Vee],RDe=async(t=process.cwd())=>{let e=await mL(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
103
103
|
`).filter(i=>ADe.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}},IDe=async(t=process.cwd())=>{try{return await Zr(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},p_=async(t=process.cwd())=>{let{stdout:e}=await Zr(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},qee=async(t=process.cwd())=>{let{stdout:e}=await Zr(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},gL=async(t,e=process.cwd())=>{t||=await mL(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}${wDe.sep}`);(a||c)&&n.push(`:!${s}`)});let o=i.match(Vee)?.[1];o&&n.push(`:!${o}.log`)}),n},_L=async(t=process.cwd())=>{await Zr(["reset","--hard","HEAD"],{cwd:t})},Hee=async(t=process.cwd())=>{let e=await Zr(["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))},CDe=t=>{let e=t.split(`
|
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:m6},Smt=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},Emt={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:Smt};import{Buffer as vmt}from"buffer";var qve=(t,e)=>t?void 0:bmt.bind(void 0,e),bmt=function*(t,e){if(typeof e!="string"&&!Pr(e)&&!vmt.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},Bve=(t,e)=>t?Tmt.bind(void 0,e):wmt.bind(void 0,e),Tmt=function*(t,e){zve(t,e),yield e},wmt=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 Rmt}from"buffer";import{StringDecoder as Amt}from"string_decoder";var YO=(t,e,r)=>{if(r)return;if(t)return{transform:xmt.bind(void 0,new TextEncoder)};let n=new Amt(e);return{transform:Imt.bind(void 0,n),final:Pmt.bind(void 0,n)}},xmt=function*(t,e){Rmt.isBuffer(e)?yield Sc(e):typeof e=="string"?yield t.encode(e):yield e},Imt=function*(t,e){yield Pr(e)?t.write(e):e},Pmt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Vve}from"util";var _6=Vve(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),KO=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Cmt}=e[r];for await(let i of n(t))yield*KO(i,e,r+1)},Hve=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Omt(r,Number(e),t)},Omt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*KO(n,r,e+1)},Gve=Vve(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),Cmt=function*(t){yield t};var y6=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Wve=(t,e)=>[...e.flatMap(r=>[...Uf(r,t,0)]),...xb(t)],Uf=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=kmt}=e[r];for(let i of n(t))yield*Uf(i,e,r+1)},xb=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Nmt(r,Number(e),t)},Nmt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Uf(n,r,e+1)},kmt=function*(t){yield t};var S6=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=Kve(t,o,s),l=Mf(e),u=Mf(r),d=l?_6.bind(void 0,KO,a):y6.bind(void 0,Uf),f=l||u?_6.bind(void 0,Hve,a):y6.bind(void 0,xb),p=l||u?Gve.bind(void 0,a):void 0;return{stream:new $mt({writableObjectMode:n,writableHighWaterMark:Yve(n),readableObjectMode:i,readableHighWaterMark:Yve(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},JO=(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=Kve(o,r,a);t=Wve(c,t)}return t},Kve=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:qve(n,a)},YO(r,o,n),WO(r,s,n,c),{transform:t,final:e},{transform:Bve(i,a)},jve({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var Jve=(t,e)=>{for(let r of Lmt(t))Dmt(t,r,e)},Lmt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Dmt=(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=>Mmt(a,n));r.input=_b(o)},Mmt=(t,e)=>{let r=JO(t,e,"utf8",!0);return Umt(r),_b(r)},Umt=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 Bmt,appendFileSync as zmt}from"fs";var ZO=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Ag(r,n)&&!$i.has(e)&&Fmt(n)&&(t.some(({type:i,value:s})=>i==="native"&&jmt.has(s))||t.every(({type:i})=>vs.has(i))),Fmt=t=>t===1||t===2,jmt=new Set(["pipe","overlapped"]),Zve=async(t,e,r,n)=>{for await(let i of t)qmt(e)||Qve(i,r,n)},Xve=(t,e,r)=>{for(let n of t)Qve(n,e,r)},qmt=t=>t._readableState.pipes.length>0,Qve=(t,e,r)=>{let n=dO(t);ea({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var ebe=({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)=>Vmt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},Vmt=({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=tve(t,s,d),p=Sc(f),{stdioItems:h,objectMode:m}=e[r],_=Hmt([p],h,c,n),{serializedResult:y,finalResult:v=y}=Gmt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});Wmt({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&&Ymt(y,h,i),S}catch(g){return n.error=g,S}},Hmt=(t,e,r,n)=>{try{return JO(t,e,r,!1)}catch(i){return n.error=i,t}},Gmt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:_b(t)};let o=mye(t,r);return n[s]?{serializedResult:o,finalResult:g6(o,!i[s],e)}:{serializedResult:o}},Wmt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!ZO({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=g6(t,!1,o);try{Xve(a,e,n)}catch(c){r.error??=c}},Ymt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>HO.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?zmt(n,t):(r.add(s),Bmt(n,t))}};var tbe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,bc(e,r,"all")]:Array.isArray(e)?[bc(t,r,"all"),...e]:Pr(t)&&Pr(e)?RG([t,e]):`${t}${e}`};import{once as E6}from"events";var rbe=async(t,e)=>{let[r,n]=await Kmt(t);return e.isForcefullyTerminated??=!1,[r,n]},Kmt=async t=>{let[e,r]=await Promise.allSettled([E6(t,"spawn"),E6(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?nbe(t):r.value},nbe=async t=>{try{return await E6(t,"exit")}catch{return nbe(t)}},ibe=async t=>{let[e,r]=await t;if(!Jmt(e,r)&&v6(e,r))throw new Xs;return[e,r]},Jmt=(t,e)=>t===void 0&&e===void 0,v6=(t,e)=>t!==0||e!==null;var sbe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=Zmt(t,e,r),o=s?.code==="ETIMEDOUT",a=eve(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},Zmt=(t,e,r)=>t!==void 0?t:v6(e,r)?new Xs:void 0;var obe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=Qmt(t,e,r),d=rgt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Dg(d,c,l)},Qmt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=pO(t,e,r),a=egt(r),{file:c,commandArguments:l,options:u}=kO(t,e,a);tgt(u);let d=Dve(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},egt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,tgt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&XO("ipcInput"),t&&XO("ipc: true"),r&&XO("detached: true"),n&&XO("cancelSignal")},XO=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},rgt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=ngt({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}=sbe(c,r),{output:h,error:m=l}=ebe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((v,S)=>bc(v,r,S)),y=bc(tbe(h,r),r,"all");return sgt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},ngt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{Jve(s,r);let a=igt(r);return Xmt(...$O(t,e,a))}catch(a){return Lg({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},igt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:qO(e)}),sgt=({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?BO({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):Ab({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 G_t}from"events";import{spawn as W_t}from"child_process";import dbe from"process";import{once as b6,on as ogt}from"events";var abe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(Pg({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:xO(t)}),agt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),agt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{TO(e,i);let s=Eu(t,e,r),o=new AbortController;try{return await Promise.race([cgt(s,n,o),lgt(s,r,o),ugt(s,r,o)])}catch(a){throw Og(t),a}finally{o.abort(),wO(e,i)}},cgt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await b6(t,"message",{signal:r});return n}for await(let[n]of ogt(t,"message",{signal:r}))if(e(n))return n},lgt=async(t,e,{signal:r})=>{await b6(t,"disconnect",{signal:r}),WSe(e)},ugt=async(t,e,{signal:r})=>{let[n]=await b6(t,"strict:error",{signal:r});throw EO(n,e)};import{once as lbe,on as dgt}from"events";var ube=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>T6({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),T6=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{Pg({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:xO(t)}),TO(e,s);let o=Eu(t,e,r),a=new AbortController,c={};return fgt(t,o,a),pgt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),hgt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},fgt=async(t,e,r)=>{try{await lbe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},pgt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await lbe(t,"strict:error",{signal:r.signal});n.error=EO(i,e),r.abort()}catch{}},hgt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of dgt(r,"message",{signal:s.signal}))cbe(o),yield c}catch{cbe(o)}finally{s.abort(),wO(e,a),n||Og(t),i&&await t}},cbe=({error:t})=>{if(t)throw t};var fbe=(t,{ipc:e})=>{Object.assign(t,hbe(t,!1,e))},pbe=()=>{let t=dbe,e=!0,r=dbe.channel!==void 0;return{...hbe(t,e,r),getCancelSignal:EEe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},hbe=(t,e,r)=>({sendMessage:CO.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:abe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:ube.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as mgt}from"child_process";import{PassThrough as ggt,Readable as _gt,Writable as ygt,Duplex as Sgt}from"stream";var mbe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{p6(n);let a=new mgt;Egt(a,n),Object.assign(a,{readable:vgt,writable:bgt,duplex:Tgt});let c=Lg({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=wgt(c,o,i);return{subprocess:a,promise:l}},Egt=(t,e)=>{let r=Ib(),n=Ib(),i=Ib(),s=Array.from({length:e.length-3},Ib),o=Ib(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},Ib=()=>{let t=new ggt;return t.end(),t},vgt=()=>new _gt({read(){}}),bgt=()=>new ygt({write(){}}),Tgt=()=>new Sgt({read(){},write(){}}),wgt=async(t,e,r)=>Dg(t,e,r);import{createReadStream as gbe,createWriteStream as _be}from"fs";import{Buffer as Rgt}from"buffer";import{Readable as Pb,Writable as Agt,Duplex as xgt}from"stream";var Sbe=(t,e)=>GO(Igt,t,e,!1),Ob=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${vu[t]}.`)},ybe={fileNumber:Ob,generator:S6,asyncGenerator:S6,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:xgt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Igt={input:{...ybe,fileUrl:({value:t})=>({stream:gbe(t)}),filePath:({value:{file:t}})=>({stream:gbe(t)}),webStream:({value:t})=>({stream:Pb.fromWeb(t)}),iterable:({value:t})=>({stream:Pb.from(t)}),asyncIterable:({value:t})=>({stream:Pb.from(t)}),string:({value:t})=>({stream:Pb.from(t)}),uint8Array:({value:t})=>({stream:Pb.from(Rgt.from(t))})},output:{...ybe,fileUrl:({value:t})=>({stream:_be(t)}),filePath:({value:{file:t,append:e}})=>({stream:_be(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Agt.fromWeb(t)}),iterable:Ob,asyncIterable:Ob,string:Ob,uint8Array:Ob}};import{on as Pgt,once as Ebe}from"events";import{PassThrough as Ogt,getDefaultHighWaterMark as Cgt}from"stream";import{finished as Tbe}from"stream/promises";function Ff(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)R6(i);let e=t.some(({readableObjectMode:i})=>i),r=Ngt(t,e),n=new w6({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Ngt=(t,e)=>{if(t.length===0)return Cgt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},w6=class extends Ogt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(R6(e),this.#e.has(e))return;this.#e.add(e),this.#n??=kgt(this,this.#e,this.#s);let r=Dgt({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(R6(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)}},kgt=async(t,e,r)=>{QO(t,vbe);let n=new AbortController;try{await Promise.race([$gt(t,n),Lgt(t,e,r,n)])}finally{n.abort(),QO(t,-vbe)}},$gt=async(t,{signal:e})=>{try{await Tbe(t,{signal:e,cleanup:!0})}catch(r){throw wbe(t,r),r}},Lgt=async(t,e,r,{signal:n})=>{for await(let[i]of Pgt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},R6=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Dgt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{QO(t,bbe);let a=new AbortController;try{await Promise.race([Mgt(s,e,a),Ugt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),Fgt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),QO(t,-bbe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?A6(t):jgt(t))},Mgt=async(t,e,{signal:r})=>{try{await t,r.aborted||A6(e)}catch(n){r.aborted||wbe(e,n)}},Ugt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await Tbe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;Rbe(o)?i.add(e):Abe(t,o)}},Fgt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await Ebe(t,i,{signal:s}),!t.readable)return Ebe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},jgt=t=>{t.writable&&t.end()},wbe=(t,e)=>{Rbe(e)?A6(t):Abe(t,e)},Rbe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",A6=t=>{(t.readable||t.writable)&&t.destroy()},Abe=(t,e)=>{t.destroyed||(t.once("error",qgt),t.destroy(e))},qgt=()=>{},QO=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},vbe=2,bbe=1;import{finished as xbe}from"stream/promises";var Ug=(t,e)=>{t.pipe(e),Bgt(t,e),zgt(t,e)},Bgt=async(t,e)=>{if(!(Zs(t)||Zs(e))){try{await xbe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}x6(e)}},x6=t=>{t.writable&&t.end()},zgt=async(t,e)=>{if(!(Zs(t)||Zs(e))){try{await xbe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}I6(t)}},I6=t=>{t.readable&&t.destroy()};var Ibe=(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)))Vgt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!vs.has(c)))Ggt({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);Ug(o,i)}},Vgt=(t,e,r,n)=>{r==="output"?Ug(t.stdio[n],e):Ug(e,t.stdio[n]);let i=Hgt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},Hgt=["stdin","stdout","stderr"],Ggt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;Wgt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},Wgt=(t,{signal:e})=>{Zs(t)&&Lf(t,Ygt,e)},Ygt=2;import{addAbortListener as Zgt}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 eC=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",P6=Symbol.for("signal-exit emitter"),O6=globalThis,Kgt=Object.defineProperty.bind(Object),C6=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(O6[P6])return O6[P6];Kgt(O6,P6,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let s of this.listeners[e])i=s(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},tC=class{},Jgt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),N6=class extends tC{onExit(){return()=>{}}load(){}unload(){}},k6=class extends tC{#e=$6.platform==="win32"?"SIGINT":"SIGHUP";#r=new C6;#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(!eC(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 eC(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"&&eC(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)}},$6=globalThis.process,{onExit:Pbe,load:fir,unload:pir}=Jgt(eC($6)?new k6($6):new N6);var Obe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Pbe(()=>{t.kill()});Zgt(n,()=>{i()})};var Nbe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=fO(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=Xgt(r,n,i),{sourceStream:d,sourceError:f}=e_t(t,l),{options:p,fileDescriptors:h}=ra.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},Xgt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=Qgt(t,e,...r),a=bO(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},Qgt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Cbe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||TG(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]=rO(r,...n);return{destination:e(Cbe)(i,s,o),pipeOptions:o}}if(ra.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}`)},Cbe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),e_t=(t,e)=>{try{return{sourceStream:Cg(t,e)}}catch(r){return{sourceError:r}}};var $be=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=t_t({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw L6({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},t_t=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return I6(t),n;if(e!==void 0)return x6(r),e},L6=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Lg({error:t,command:kbe,escapedCommand:kbe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),kbe="source.pipe(destination)";var Lbe=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 r_t}from"stream/promises";var Dbe=(t,e,r)=>{let n=rC.has(e)?i_t(t,e):n_t(t,e);return Lf(t,o_t,r.signal),Lf(e,a_t,r.signal),s_t(e),n},n_t=(t,e)=>{let r=Ff([t]);return Ug(r,e),rC.set(e,r),r},i_t=(t,e)=>{let r=rC.get(e);return r.add(t),r},s_t=async t=>{try{await r_t(t,{cleanup:!0,readable:!1,writable:!0})}catch{}rC.delete(t)},rC=new WeakMap,o_t=2,a_t=1;import{aborted as c_t}from"util";var Mbe=(t,e)=>t===void 0?[]:[l_t(t,e)],l_t=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await c_t(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw L6({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var nC=(t,...e)=>{if(yr(e[0]))return nC.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=Nbe(t,...e),i=u_t({...n,destination:r});return i.pipe=nC.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},u_t=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=d_t(t,i);$be({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Dbe(e,s,d);return await Promise.race([Lbe(u),...Mbe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},d_t=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as y_t}from"timers/promises";import{on as f_t}from"events";import{getDefaultHighWaterMark as p_t}from"stream";var iC=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return h_t(e,o),Fbe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},h_t=async(t,e)=>{try{await t}catch{}finally{e.abort()}},D6=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;m_t(e,o,t);let a=t.readableObjectMode&&!s;return Fbe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},m_t=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Fbe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=f_t(t,"data",{signal:e.signal,highWaterMark:Ube,highWatermark:Ube});return g_t({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},M6=p_t(!0),Ube=M6,g_t=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=__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*xb(a)}},__t=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[YO(t,r,!e),WO(t,i,!n,{})].filter(Boolean);var jbe=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=S_t({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([E_t(t),d]);return}let f=h6(c,r),p=D6({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([v_t({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},S_t=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!ZO({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=D6({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Zve(a,t,r,s)},E_t=async t=>{await y_t(),t.readableFlowing===null&&t.resume()},v_t=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await UO(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await FO(r,{maxBuffer:s})):await $g(r,{maxBuffer:s})}catch(a){return qbe(ZEe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},U6=async t=>{try{return await t}catch(e){return qbe(e)}},qbe=({bufferedData:t})=>pye(t)?new Uint8Array(t):t;import{finished as b_t}from"stream/promises";var Cb=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=T_t(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],b_t(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||A_t(a,e,r,n)}finally{o.abort()}},T_t=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&w_t(t,r,n),n},w_t=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{R_t(e,r),n.call(t,...i)}},R_t=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},A_t=(t,e,r,n)=>{if(!x_t(t,e,r,n))throw t},x_t=(t,e,r,n=!0)=>r.propagating?Bbe(t)||sC(t):(r.propagating=!0,F6(r,e)===n?Bbe(t):sC(t)),F6=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",sC=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Bbe=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)=>j6({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),j6=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=Cb(t,e,l);if(F6(l,e)){await u;return}let[d]=await Promise.all([jbe({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 Vbe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Ff([t,e].filter(Boolean)):void 0,Hbe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>j6({...I_t(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:P_t(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),I_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}},P_t=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as O_t}from"events";var Gbe=t=>Ag(t,"ipc"),Wbe=(t,e)=>{let r=dO(t);ea({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Ybe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=Gbe(s),a=Ec(e,"ipc"),c=Ec(r,"ipc");for await(let l of T6({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(XEe(t,i,c),i.push(l)),o&&Wbe(l,s);return i},Kbe=async(t,e)=>(await Promise.allSettled([t]),e);var Jbe=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=rbe(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=Hbe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),P=[],x=Ybe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:P,verboseInfo:p}),R=C_t(m,t,S),O=N_t(h,S);try{return await Promise.race([Promise.all([{},ibe(v),Promise.all(g),w,x,OEe(t,d),...R,...O]),_,k_t(t,y),...REe(t,s,f,y),...GSe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...TEe({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=>U6(b))),U6(w),Kbe(x,P),Promise.allSettled(R),Promise.allSettled(O)])}},C_t=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:Cb(n,i,r)),N_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})=>Cb(o,n,e,{isSameDirection:vs.has(i),stopOnExit:i==="native"}))),k_t=async(t,{signal:e})=>{let[r]=await O_t(t,"error",{signal:e});throw r};var Zbe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),Nb=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=ta();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},Fg=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 $_t}from"stream";import{callbackify as L_t}from"util";import{finished as Xbe}from"stream/promises";var q6=async t=>{if(t!==void 0)try{await B6(t)}catch{}},Qbe=async t=>{if(t!==void 0)try{await z6(t)}catch{}},B6=async t=>{await Xbe(t,{cleanup:!0,readable:!1,writable:!0})},z6=async t=>{await Xbe(t,{cleanup:!0,readable:!0,writable:!1})},oC=async(t,e)=>{if(await t,e)throw e},aC=(t,e,r)=>{r&&!sC(r)?t.destroy(r):e&&t.destroy()};var eTe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||$i.has(r),{subprocessStdout:a,waitReadableDestroy:c}=V6(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=H6(a,o),{read:f,onStdoutDataDone:p}=G6({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new $_t({read:f,destroy:L_t(Y6.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return W6({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},V6=(t,e,r)=>{let n=Cg(t,e),i=Nb(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},H6=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:M6},G6=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=ta(),o=iC({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){D_t(this,o,s)},onStdoutDataDone:s}},D_t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},W6=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await z6(t),await n,await q6(i),await e,r.readable&&r.push(null)}catch(s){await q6(i),tTe(r,s)}},Y6=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Fg(r,e)&&(tTe(t,n),await oC(e,n))},tTe=(t,e)=>{aC(t,t.readable,e)};import{Writable as M_t}from"stream";import{callbackify as rTe}from"util";var nTe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=K6(t,r,e),o=new M_t({...J6(n,t,i),destroy:rTe(X6.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return Z6(n,o),o},K6=(t,e,r)=>{let n=bO(t,e),i=Nb(r,n,"writableFinal"),s=Nb(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},J6=(t,e,r)=>({write:U_t.bind(void 0,t),final:rTe(F_t.bind(void 0,t,e,r))}),U_t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},F_t=async(t,e,r)=>{await Fg(r,e)&&(t.writable&&t.end(),await e)},Z6=async(t,e,r)=>{try{await B6(t),e.writable&&e.end()}catch(n){await Qbe(r),iTe(e,n)}},X6=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Fg(r,e),await Fg(n,e)&&(iTe(t,i),await oC(e,i))},iTe=(t,e)=>{aC(t,t.writable,e)};import{Duplex as j_t}from"stream";import{callbackify as q_t}from"util";var sTe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||$i.has(r),{subprocessStdout:c,waitReadableDestroy:l}=V6(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=K6(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=H6(c,a),{read:_,onStdoutDataDone:y}=G6({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),v=new j_t({read:_,...J6(u,t,d),destroy:q_t(B_t.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 W6({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:u}),Z6(u,v,c),v},B_t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([Y6({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),X6({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var Q6=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||$i.has(e),o=Cg(t,r),a=iC({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return z_t(a,o,t)},z_t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var oTe=(t,{encoding:e})=>{let r=Zbe();t.readable=eTe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=nTe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=sTe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=Q6.bind(void 0,t,e),t[Symbol.asyncIterator]=Q6.bind(void 0,t,e,{})};var aTe=(t,e)=>{for(let[r,n]of H_t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},V_t=(async()=>{})().constructor.prototype,H_t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(V_t,t)]);var cTe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=Y_t(t,e,r),{subprocess:f,promise:p}=J_t({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=nC.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),aTe(f,p),ra.set(f,{options:u,fileDescriptors:d}),f},Y_t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=pO(t,e,r),{file:a,commandArguments:c,options:l}=kO(t,e,r),u=K_t(l),d=Sbe(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},K_t=({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}},J_t=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=W_t(...$O(t,e,r))}catch(h){return mbe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;G_t(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];Ibe(c,a,l),Obe(c,r,l);let d={},f=ta();c.kill=VSe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Vbe(c,r),oTe(c,r),fbe(c,r);let p=Z_t({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}},Z_t=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 Jbe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:l,controller:u});u.abort(),l.resolve();let y=h.map((g,w)=>bc(g,e,w)),v=bc(m,e,"all"),S=X_t({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Dg(S,n,e)},X_t=({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?Ab({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 na,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):BO({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var cC=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,Q_t(n,t[n],i)]));return{...t,...r}},Q_t=(t,e,r)=>eyt.has(t)&&yr(e)&&yr(r)?{...e,...r}:r,eyt=new Set(["env",...PG]);var bu=(t,e,r,n)=>{let i=(o,a,c)=>bu(o,a,r,c),s=(...o)=>tyt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},tyt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(yr(s))return i(t,cC(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=ryt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?obe(a,c,l):cTe(a,c,l,i)},ryt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=Sye(e)?Eye(e,r):[e,...r],[o,a,c]=rO(...s),l=cC(cC(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 lTe=({file:t,commandArguments:e})=>dTe(t,e),uTe=({file:t,commandArguments:e})=>({...dTe(t,e),isSync:!0}),dTe=(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]=nyt(t);return{file:r,commandArguments:n}},nyt=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(iyt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},iyt=/ +/g;var fTe=(t,e,r)=>{t.sync=e(syt,r),t.s=t.sync},pTe=({options:t})=>hTe(t),syt=({options:t})=>({...hTe(t),isSync:!0}),hTe=t=>({options:{...oyt(t),...t}}),oyt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},mTe={preferLocal:!0};var gTe=bu(()=>({})),nar=bu(()=>({isSync:!0})),_Te=bu(lTe),iar=bu(uTe),sar=bu(xEe),oar=bu(pTe,{},mTe,fTe),{sendMessage:aar,getOneMessage:car,getEachMessage:lar,getCancelSignal:uar}=pbe();import{Transform as ayt}from"stream";var cyt=["NETLIFY_AI_GATEWAY_KEY"];function lyt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...cyt])]}function uyt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function dyt(){let e=lyt().map(r=>process.env[r]).filter(r=>!(!r||uyt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function bs(t){if(typeof t!="string")return t;let e=dyt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(fyt(n),"g");r=r.replace(i,"******")}),r}function fyt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var kb=class extends ayt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=bs(i);n(null,s)}},lC=Symbol("maskedWrite");function yTe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[lC]){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[lC]=!0,process.stdout.write=r}if(!process.stderr.write[lC]){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[lC]=!0,process.stderr.write=r}}}var STe=!1,ETe=()=>{STe=!0},hi=()=>STe;var $b=null,vTe=t=>($b&&$b.destroy(),$b=new Tc({totalAllowedTime:t}),$b),bTe=()=>$b;var Tc=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&hi())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 eO({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{Ie.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 TTe={name:"@netlify/agent-runner-cli",type:"module",version:"1.142.1-test.8",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.0","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"2.1.197","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@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","opencode-ai":"1.17.19",zod:"^4.4.3"}};var gyt=hyt(import.meta.url),_yt=wc.dirname(gyt),yyt=myt(import.meta.url),jg=Re("shell"),e3=new Set,wTe={preferLocal:!0},Li=(t,e,r)=>{let[n,i]=Syt(e,r),s={...wTe,...i},o=gTe(t,n,s);ATe(o,s),PTe(o);let a=r?.idleTimeout;return a&&a>0&&ITe(o,a),o},RTe=(t,e)=>{let r={...wTe,...e},n=_Te(t,r);return ATe(n,r),PTe(n),e?.idleTimeout&&e.idleTimeout>0&&ITe(n,e.idleTimeout),n},Syt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},ATe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(Rc.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new kb).pipe(Rc.stdout),t.stderr?.pipe(new kb).pipe(Rc.stderr);return}t.stdout?.pipe(Rc.stdout),t.stderr?.pipe(Rc.stderr)},t3=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Rc.kill(-t.pid,e),jg.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return jg.error("Error killing process:",r),!1}},xTe=t=>t3(t,"SIGKILL"),ITe=(t,e)=>{let r=null,n=()=>{jg.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),t3(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(jg.log(`Force killing idle process ${t.pid}`),xTe(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)},PTe=t=>{e3.add(t);let e=bTe();if(e){let r=e.onTimesUp(()=>{jg.log(`Global timer expired, killing process ${t.pid}`),t3(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(jg.log(`Force killing process ${t.pid} after timeout`),xTe(t))},5e3)});t.on("exit",()=>{e3.delete(t),r()}),t.on("error",()=>{e3.delete(t),r()})}};function sa(t,e){if(!Rc.env.NETLIFY_LOCAL_MODE)try{let i=yyt.resolve(TTe.name),s=wc.dirname(i);for(;s!==wc.dirname(s);){let o=wc.dirname(s);if(wc.basename(o)==="node_modules"){let a=wc.join(o,".bin",e);if(uC.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(Rc.env.NODE_PATH){let i=wc.join(Rc.env.NODE_PATH,".bin",e);if(uC.existsSync(i))return i}let r=wc.join(t,"node_modules",".bin",e);if(uC.existsSync(r))return r;let n=wc.join(_yt,"..","node_modules",".bin",e);if(uC.existsSync(n))return n}import hL from"process";import{fileURLToPath as cCt}from"url";import{createRequire as lCt}from"module";import mL from"path";var Eyt="__netlify__getTracer",vyt="__netlify__shutdownTracers",ft=(t,e)=>globalThis[Eyt]?.(t,e),OTe=async()=>globalThis[vyt]?.();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 rCt}from"timers/promises";import _Et from"process";var CTe=typeof globalThis=="object"?globalThis:global;var Ac="1.9.0";var NTe=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function byt(t){var e=new Set([t]),r=new Set,n=t.match(NTe);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(NTe);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 kTe=byt(Ac);var Tyt=Ac.split(".")[0],Lb=Symbol.for("opentelemetry.js.api."+Tyt),Db=CTe;function Tu(t,e,r,n){var i;n===void 0&&(n=!1);var s=Db[Lb]=(i=Db[Lb])!==null&&i!==void 0?i:{version:Ac};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!==Ac){var o=new Error("@opentelemetry/api: Registration of version v"+s.version+" for "+t+" does not match previously registered API v"+Ac);return r.error(o.stack||o.message),!1}return s[t]=e,r.debug("@opentelemetry/api: Registered a global for "+t+" v"+Ac+"."),!0}function to(t){var e,r,n=(e=Db[Lb])===null||e===void 0?void 0:e.version;if(!(!n||!kTe(n)))return(r=Db[Lb])===null||r===void 0?void 0:r[t]}function wu(t,e){e.debug("@opentelemetry/api: Unregistering a global for "+t+" v"+Ac+".");var r=Db[Lb];r&&delete r[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},Ryt=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))},$Te=(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 Mb("debug",this._namespace,e)},t.prototype.error=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Mb("error",this._namespace,e)},t.prototype.info=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Mb("info",this._namespace,e)},t.prototype.warn=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Mb("warn",this._namespace,e)},t.prototype.verbose=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Mb("verbose",this._namespace,e)},t})();function Mb(t,e,r){var n=to("diag");if(n)return r.unshift(e),n[t].apply(n,Ryt([],wyt(r),!1))}var Gn;(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"})(Gn||(Gn={}));function LTe(t,e){t<Gn.NONE?t=Gn.NONE:t>Gn.ALL&&(t=Gn.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",Gn.ERROR),warn:r("warn",Gn.WARN),info:r("info",Gn.INFO),debug:r("debug",Gn.DEBUG),verbose:r("verbose",Gn.VERBOSE)}}var Ayt=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},xyt=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))},Iyt="diag",Di=(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,xyt([],Ayt(s),!1))}}var r=this,n=function(i,s){var o,a,c;if(s===void 0&&(s={logLevel:Gn.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=LTe((a=s.logLevel)!==null&&a!==void 0?a:Gn.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(Iyt,r)},r.createComponentLogger=function(i){return new $Te(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 Pyt=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},Oyt=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.")},DTe=(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=Pyt(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=Oyt(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 ecr=Di.instance();function MTe(t){return t===void 0&&(t={}),new DTe(new Map(Object.entries(t)))}function dC(t){return Symbol.for(t)}var Cyt=(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})(),UTe=new Cyt;var FTe={get:function(t,e){if(t!=null)return t[e]},keys:function(t){return t==null?[]:Object.keys(t)}},jTe={set:function(t,e,r){t!=null&&(t[e]=r)}};var Nyt=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},kyt=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))},qTe=(function(){function t(){}return t.prototype.active=function(){return UTe},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,kyt([n],Nyt(i),!1))},t.prototype.bind=function(e,r){return r},t.prototype.enable=function(){return this},t.prototype.disable=function(){return this},t})();var $yt=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},Lyt=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))},r3="context",Dyt=new qTe,Ru=(function(){function t(){}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalContextManager=function(e){return Tu(r3,e,Di.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,Lyt([e,r,n],$yt(s),!1))},t.prototype.bind=function(e,r){return this._getContextManager().bind(e,r)},t.prototype._getContextManager=function(){return to(r3)||Dyt},t.prototype.disable=function(){this._getContextManager().disable(),wu(r3,Di.instance())},t})();var fC;(function(t){t[t.NONE=0]="NONE",t[t.SAMPLED=1]="SAMPLED"})(fC||(fC={}));var n3="0000000000000000",i3="00000000000000000000000000000000",BTe={traceId:i3,spanId:n3,traceFlags:fC.NONE};var Au=(function(){function t(e){e===void 0&&(e=BTe),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 s3=dC("OpenTelemetry Context Key SPAN");function pC(t){return t.getValue(s3)||void 0}function zTe(){return pC(Ru.getInstance().active())}function Ub(t,e){return t.setValue(s3,e)}function VTe(t){return t.deleteValue(s3)}function HTe(t,e){return Ub(t,new Au(e))}function hC(t){var e;return(e=pC(t))===null||e===void 0?void 0:e.spanContext()}var Myt=/^([0-9a-f]{32})$/i,Uyt=/^[0-9a-f]{16}$/i;function Fyt(t){return Myt.test(t)&&t!==i3}function jyt(t){return Uyt.test(t)&&t!==n3}function mC(t){return Fyt(t.traceId)&&jyt(t.spanId)}function GTe(t){return new Au(t)}var o3=Ru.getInstance(),gC=(function(){function t(){}return t.prototype.startSpan=function(e,r,n){n===void 0&&(n=o3.active());var i=!!r?.root;if(i)return new Au;var s=n&&hC(n);return qyt(s)&&mC(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??o3.active(),l=this.startSpan(e,s,c),u=Ub(c,l);return o3.with(u,a,void 0,l)}},t})();function qyt(t){return typeof t=="object"&&typeof t.spanId=="string"&&typeof t.traceId=="string"&&typeof t.traceFlags=="number"}var Byt=new gC,WTe=(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):Byt},t})();var YTe=(function(){function t(){}return t.prototype.getTracer=function(e,r,n){return new gC},t})();var zyt=new YTe,a3=(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 WTe(this,e,r,n)},t.prototype.getDelegate=function(){var e;return(e=this._delegate)!==null&&e!==void 0?e:zyt},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 oa;(function(t){t[t.UNSET=0]="UNSET",t[t.OK=1]="OK",t[t.ERROR=2]="ERROR"})(oa||(oa={}));var xc=Ru.getInstance();var c3=Di.instance();var KTe=(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 l3=dC("OpenTelemetry Baggage Key");function u3(t){return t.getValue(l3)||void 0}function JTe(){return u3(Ru.getInstance().active())}function ZTe(t,e){return t.setValue(l3,e)}function XTe(t){return t.deleteValue(l3)}var d3="propagation",Vyt=new KTe,QTe=(function(){function t(){this.createBaggage=MTe,this.getBaggage=u3,this.getActiveBaggage=JTe,this.setBaggage=ZTe,this.deleteBaggage=XTe}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalPropagator=function(e){return Tu(d3,e,Di.instance())},t.prototype.inject=function(e,r,n){return n===void 0&&(n=jTe),this._getGlobalPropagator().inject(e,r,n)},t.prototype.extract=function(e,r,n){return n===void 0&&(n=FTe),this._getGlobalPropagator().extract(e,r,n)},t.prototype.fields=function(){return this._getGlobalPropagator().fields()},t.prototype.disable=function(){wu(d3,Di.instance())},t.prototype._getGlobalPropagator=function(){return to(d3)||Vyt},t})();var Fb=QTe.getInstance();var f3="trace",ewe=(function(){function t(){this._proxyTracerProvider=new a3,this.wrapSpanContext=GTe,this.isSpanContextValid=mC,this.deleteSpan=VTe,this.getSpan=pC,this.getActiveSpan=zTe,this.getSpanContext=hC,this.setSpan=Ub,this.setSpanContext=HTe}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalTracerProvider=function(e){var r=Tu(f3,this._proxyTracerProvider,Di.instance());return r&&this._proxyTracerProvider.setDelegate(e),r},t.prototype.getTracerProvider=function(){return to(f3)||this._proxyTracerProvider},t.prototype.getTracer=function(e,r){return this.getTracerProvider().getTracer(e,r)},t.prototype.disable=function(){wu(f3,Di.instance()),this._proxyTracerProvider=new a3},t})();var jb=ewe.getInstance();var Gyt=function(t,e){e.recordException(t),e.setStatus({code:oa.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=twe(r,n,i),o=s.opts,a=s.ctx,c=s.fn;return this._tracer.startActiveSpan(e,o,a,function(l){return rwe(l,o,c)})},t.prototype.withSpan=function(e,r,n,i){var s=twe(r,n,i),o=s.opts,a=s.ctx,c=s.fn,l=this._tracer.startSpan(e,o,a);return rwe(l,o,c)},t})();function twe(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??xc.active(),{opts:n,ctx:i,fn:s}}function rwe(t,e,r){var n,i=(n=e.onException)!==null&&n!==void 0?n:Gyt,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)}}lW();Qe();var dT=class{emit(e){}enabled(){return!1}},mRe=new dT;var fT=Symbol.for("io.opentelemetry.js.api.logs"),Jg=globalThis;function gRe(t,e,r){return n=>n===t?e:r}var uW=1;var dW=class{getLogger(e,r,n){return new dT}},aN=new dW;var cN=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):mRe}};var pT=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new cN(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:aN}_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 lN=class t{constructor(){this._proxyLoggerProvider=new pT}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return Jg[fT]?this.getLoggerProvider():(Jg[fT]=gRe(uW,e,aN),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=Jg[fT])===null||e===void 0?void 0:e.call(Jg,uW))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete Jg[fT],this._proxyLoggerProvider=new pT}};var _Re=lN.getInstance();function yRe(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 SRe(t){t.forEach(e=>e.disable())}function fW(t){let e=t.tracerProvider||Or.getTracerProvider(),r=t.meterProvider||Zb.getMeterProvider(),n=t.loggerProvider||_Re.getLoggerProvider(),i=t.instrumentations?.flat()??[];return yRe(i,e,r,n),()=>{SRe(i)}}dr();var CN=Ln(IW(),1);dr();var XRe=t=>{throw TypeError(t)},NW=(t,e,r)=>e.has(t)||XRe("Cannot "+r),ON=(t,e,r)=>(NW(t,e,"read from private field"),r?r.call(t):e.get(t)),PW=(t,e,r)=>e.has(t)?XRe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),KRe=(t,e,r,n)=>(NW(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),gEt=(t,e,r)=>(NW(t,e,"access private method"),r),JRe="__netlify__getTracer",yEt="__netlify__shutdownTracers",SEt="__nfOTLPTrace",mT,gT,CW,QRe,EEt=class{constructor(){PW(this,CW),PW(this,mT),PW(this,gT),KRe(this,mT,new pa(gEt(this,CW,QRe),this)),KRe(this,gT,c3.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(ON(this,gT).debug(`export ${t.length.toString()} spans`),ON(this,mT).isCalled){e({code:Xt.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(SEt,JSON.stringify(vEt(t))),e({code:Xt.SUCCESS})}shutdown(){return ON(this,mT).call()}};mT=new WeakMap;gT=new WeakMap;CW=new WeakSet;QRe=function(){return ON(this,gT).debug("Shutting down"),Promise.resolve()};function vEt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:PN(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:OW(e.startTime),endTimeUnixNano:OW(e.endTime),attributes:PN(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:OW(n.time),attributes:PN(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:PN(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function PN(t){return Object.keys(t).map(e=>eAe(e,t[e]))}function eAe(t,e){return{key:t,value:tAe(e)}}function tAe(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(tAe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>eAe(r,n))}}:{}}function OW(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var ZRe={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"}},rAe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,JRe))return;let e=_Et.version.slice(1),r=oN({"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??[bEt()],i=new CN.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new Nc});let s=t.instrumentations??[];fW({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,JRe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new Bf(jb.getTracer(a,c)):new Bf(jb.getTracer(ZRe.name,ZRe.version))}}),Object.defineProperty(globalThis,yEt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},bEt=()=>new CN.SimpleSpanProcessor(new EEt);dr();var _T=Ln(IW(),1);import*as NN from"diagnostics_channel";var nAe=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?oa.ERROR:oa.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){NN.subscribe(t,e);let r=()=>NN.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},xc.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:oa.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 mke=Ln(pke(),1);var fL=Re("tracing"),hke=8e3,nCt=5e3,Ow=async(t=nCt)=>{try{await Promise.race([OTe(),rCt(t)])}catch(e){fL.warn("Failed to flush tracers on shutdown",e)}},gke=async(t,e,r)=>{if(!ft()){let n=[new _T.SimpleSpanProcessor(new g9),new _T.SimpleSpanProcessor(new mke.OTLPTraceExporter({url:r.exporterUrl}))];await rAe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new nAe({skipHeaders:!0})]})}return r.traceparent?(Fb.setGlobalPropagator(new Nc),Fb.extract(xc.active(),{traceparent:r.traceparent,isRemote:!0})):xc.active()};function zt(t,e,r){return fL.log(`\u23F3 TRACE: ${e} starting...`),qf(t,e,r)}var g9=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(", ")}]`:"";fL.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&fL.log(` \u274C Error: ${e.status.message}`)}};function _9(){return ut().captureLlmContentEnabled}function _ke(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function pL(t,e,r){let n={role:t,parts:[{type:"text",content:bs(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}function yke(t,e,r,n){if(!t.length)return;let i=ft();if(!i)return;let s=_9(),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>hke?`${a.message.slice(0,hke)}\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":pL("assistant",p)}:{}}}).end(u)})}import{readdir as iCt,rm as sCt}from"fs/promises";import{join as oCt}from"path";async function Ske(t,e=[]){let n=(await iCt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>sCt(oCt(t,i),{recursive:!0,force:!0})))}var aCt=700,Eke=t=>t.mode==="create"&&(t.accountType===Tl||t.enforcedAICreditsRemaining!=null&&t.enforcedAICreditsRemaining<=aCt);var uCt=mL.dirname(cCt(import.meta.url)),vke=lCt(import.meta.url),dCt=mL.resolve(uCt,"scripts/scaffold.js"),fCt="scripts/scaffold.js",pCt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,y9=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},hCt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),mCt=t=>{let e=y9(t);return e==="node"||e.endsWith("/node")},Qc=t=>{if(typeof t!="string")return!1;let e=t.match(pCt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&hCt(y9(e[r]));)r+=1;if(r>=e.length||!mCt(e[r]))return!1;let n=e[r+1];return n?y9(n).includes(fCt):!1},W_=Re("create_stage"),bke="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.",gCt=`${bke}
|
|
581
|
+
if (condition) { yield value; }`)};import{Buffer as Rmt}from"buffer";import{StringDecoder as Amt}from"string_decoder";var YO=(t,e,r)=>{if(r)return;if(t)return{transform:xmt.bind(void 0,new TextEncoder)};let n=new Amt(e);return{transform:Imt.bind(void 0,n),final:Pmt.bind(void 0,n)}},xmt=function*(t,e){Rmt.isBuffer(e)?yield Sc(e):typeof e=="string"?yield t.encode(e):yield e},Imt=function*(t,e){yield Pr(e)?t.write(e):e},Pmt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Vve}from"util";var _6=Vve(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),KO=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Cmt}=e[r];for await(let i of n(t))yield*KO(i,e,r+1)},Hve=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Omt(r,Number(e),t)},Omt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*KO(n,r,e+1)},Gve=Vve(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),Cmt=function*(t){yield t};var y6=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Wve=(t,e)=>[...e.flatMap(r=>[...Uf(r,t,0)]),...xb(t)],Uf=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=kmt}=e[r];for(let i of n(t))yield*Uf(i,e,r+1)},xb=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Nmt(r,Number(e),t)},Nmt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Uf(n,r,e+1)},kmt=function*(t){yield t};var S6=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=Kve(t,o,s),l=Mf(e),u=Mf(r),d=l?_6.bind(void 0,KO,a):y6.bind(void 0,Uf),f=l||u?_6.bind(void 0,Hve,a):y6.bind(void 0,xb),p=l||u?Gve.bind(void 0,a):void 0;return{stream:new $mt({writableObjectMode:n,writableHighWaterMark:Yve(n),readableObjectMode:i,readableHighWaterMark:Yve(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},JO=(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=Kve(o,r,a);t=Wve(c,t)}return t},Kve=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:qve(n,a)},YO(r,o,n),WO(r,s,n,c),{transform:t,final:e},{transform:Bve(i,a)},jve({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var Jve=(t,e)=>{for(let r of Lmt(t))Dmt(t,r,e)},Lmt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Dmt=(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=>Mmt(a,n));r.input=_b(o)},Mmt=(t,e)=>{let r=JO(t,e,"utf8",!0);return Umt(r),_b(r)},Umt=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 Bmt,appendFileSync as zmt}from"fs";var ZO=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Ag(r,n)&&!$i.has(e)&&Fmt(n)&&(t.some(({type:i,value:s})=>i==="native"&&jmt.has(s))||t.every(({type:i})=>vs.has(i))),Fmt=t=>t===1||t===2,jmt=new Set(["pipe","overlapped"]),Zve=async(t,e,r,n)=>{for await(let i of t)qmt(e)||Qve(i,r,n)},Xve=(t,e,r)=>{for(let n of t)Qve(n,e,r)},qmt=t=>t._readableState.pipes.length>0,Qve=(t,e,r)=>{let n=dO(t);ea({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var ebe=({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)=>Vmt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},Vmt=({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=tve(t,s,d),p=Sc(f),{stdioItems:h,objectMode:m}=e[r],_=Hmt([p],h,c,n),{serializedResult:y,finalResult:v=y}=Gmt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});Wmt({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&&Ymt(y,h,i),S}catch(g){return n.error=g,S}},Hmt=(t,e,r,n)=>{try{return JO(t,e,r,!1)}catch(i){return n.error=i,t}},Gmt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:_b(t)};let o=mye(t,r);return n[s]?{serializedResult:o,finalResult:g6(o,!i[s],e)}:{serializedResult:o}},Wmt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!ZO({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=g6(t,!1,o);try{Xve(a,e,n)}catch(c){r.error??=c}},Ymt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>HO.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?zmt(n,t):(r.add(s),Bmt(n,t))}};var tbe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,bc(e,r,"all")]:Array.isArray(e)?[bc(t,r,"all"),...e]:Pr(t)&&Pr(e)?RG([t,e]):`${t}${e}`};import{once as E6}from"events";var rbe=async(t,e)=>{let[r,n]=await Kmt(t);return e.isForcefullyTerminated??=!1,[r,n]},Kmt=async t=>{let[e,r]=await Promise.allSettled([E6(t,"spawn"),E6(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?nbe(t):r.value},nbe=async t=>{try{return await E6(t,"exit")}catch{return nbe(t)}},ibe=async t=>{let[e,r]=await t;if(!Jmt(e,r)&&v6(e,r))throw new Xs;return[e,r]},Jmt=(t,e)=>t===void 0&&e===void 0,v6=(t,e)=>t!==0||e!==null;var sbe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=Zmt(t,e,r),o=s?.code==="ETIMEDOUT",a=eve(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},Zmt=(t,e,r)=>t!==void 0?t:v6(e,r)?new Xs:void 0;var obe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=Qmt(t,e,r),d=rgt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Dg(d,c,l)},Qmt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=pO(t,e,r),a=egt(r),{file:c,commandArguments:l,options:u}=kO(t,e,a);tgt(u);let d=Dve(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},egt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,tgt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&XO("ipcInput"),t&&XO("ipc: true"),r&&XO("detached: true"),n&&XO("cancelSignal")},XO=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},rgt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=ngt({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}=sbe(c,r),{output:h,error:m=l}=ebe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((v,S)=>bc(v,r,S)),y=bc(tbe(h,r),r,"all");return sgt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},ngt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{Jve(s,r);let a=igt(r);return Xmt(...$O(t,e,a))}catch(a){return Lg({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},igt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:qO(e)}),sgt=({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?BO({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):Ab({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 G_t}from"events";import{spawn as W_t}from"child_process";import dbe from"process";import{once as b6,on as ogt}from"events";var abe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(Pg({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:xO(t)}),agt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),agt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{TO(e,i);let s=Eu(t,e,r),o=new AbortController;try{return await Promise.race([cgt(s,n,o),lgt(s,r,o),ugt(s,r,o)])}catch(a){throw Og(t),a}finally{o.abort(),wO(e,i)}},cgt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await b6(t,"message",{signal:r});return n}for await(let[n]of ogt(t,"message",{signal:r}))if(e(n))return n},lgt=async(t,e,{signal:r})=>{await b6(t,"disconnect",{signal:r}),WSe(e)},ugt=async(t,e,{signal:r})=>{let[n]=await b6(t,"strict:error",{signal:r});throw EO(n,e)};import{once as lbe,on as dgt}from"events";var ube=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>T6({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),T6=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{Pg({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:xO(t)}),TO(e,s);let o=Eu(t,e,r),a=new AbortController,c={};return fgt(t,o,a),pgt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),hgt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},fgt=async(t,e,r)=>{try{await lbe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},pgt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await lbe(t,"strict:error",{signal:r.signal});n.error=EO(i,e),r.abort()}catch{}},hgt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of dgt(r,"message",{signal:s.signal}))cbe(o),yield c}catch{cbe(o)}finally{s.abort(),wO(e,a),n||Og(t),i&&await t}},cbe=({error:t})=>{if(t)throw t};var fbe=(t,{ipc:e})=>{Object.assign(t,hbe(t,!1,e))},pbe=()=>{let t=dbe,e=!0,r=dbe.channel!==void 0;return{...hbe(t,e,r),getCancelSignal:EEe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},hbe=(t,e,r)=>({sendMessage:CO.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:abe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:ube.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as mgt}from"child_process";import{PassThrough as ggt,Readable as _gt,Writable as ygt,Duplex as Sgt}from"stream";var mbe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{p6(n);let a=new mgt;Egt(a,n),Object.assign(a,{readable:vgt,writable:bgt,duplex:Tgt});let c=Lg({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=wgt(c,o,i);return{subprocess:a,promise:l}},Egt=(t,e)=>{let r=Ib(),n=Ib(),i=Ib(),s=Array.from({length:e.length-3},Ib),o=Ib(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},Ib=()=>{let t=new ggt;return t.end(),t},vgt=()=>new _gt({read(){}}),bgt=()=>new ygt({write(){}}),Tgt=()=>new Sgt({read(){},write(){}}),wgt=async(t,e,r)=>Dg(t,e,r);import{createReadStream as gbe,createWriteStream as _be}from"fs";import{Buffer as Rgt}from"buffer";import{Readable as Pb,Writable as Agt,Duplex as xgt}from"stream";var Sbe=(t,e)=>GO(Igt,t,e,!1),Ob=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${vu[t]}.`)},ybe={fileNumber:Ob,generator:S6,asyncGenerator:S6,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:xgt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Igt={input:{...ybe,fileUrl:({value:t})=>({stream:gbe(t)}),filePath:({value:{file:t}})=>({stream:gbe(t)}),webStream:({value:t})=>({stream:Pb.fromWeb(t)}),iterable:({value:t})=>({stream:Pb.from(t)}),asyncIterable:({value:t})=>({stream:Pb.from(t)}),string:({value:t})=>({stream:Pb.from(t)}),uint8Array:({value:t})=>({stream:Pb.from(Rgt.from(t))})},output:{...ybe,fileUrl:({value:t})=>({stream:_be(t)}),filePath:({value:{file:t,append:e}})=>({stream:_be(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Agt.fromWeb(t)}),iterable:Ob,asyncIterable:Ob,string:Ob,uint8Array:Ob}};import{on as Pgt,once as Ebe}from"events";import{PassThrough as Ogt,getDefaultHighWaterMark as Cgt}from"stream";import{finished as Tbe}from"stream/promises";function Ff(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)R6(i);let e=t.some(({readableObjectMode:i})=>i),r=Ngt(t,e),n=new w6({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Ngt=(t,e)=>{if(t.length===0)return Cgt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},w6=class extends Ogt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(R6(e),this.#e.has(e))return;this.#e.add(e),this.#n??=kgt(this,this.#e,this.#s);let r=Dgt({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(R6(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)}},kgt=async(t,e,r)=>{QO(t,vbe);let n=new AbortController;try{await Promise.race([$gt(t,n),Lgt(t,e,r,n)])}finally{n.abort(),QO(t,-vbe)}},$gt=async(t,{signal:e})=>{try{await Tbe(t,{signal:e,cleanup:!0})}catch(r){throw wbe(t,r),r}},Lgt=async(t,e,r,{signal:n})=>{for await(let[i]of Pgt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},R6=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Dgt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{QO(t,bbe);let a=new AbortController;try{await Promise.race([Mgt(s,e,a),Ugt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),Fgt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),QO(t,-bbe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?A6(t):jgt(t))},Mgt=async(t,e,{signal:r})=>{try{await t,r.aborted||A6(e)}catch(n){r.aborted||wbe(e,n)}},Ugt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await Tbe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;Rbe(o)?i.add(e):Abe(t,o)}},Fgt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await Ebe(t,i,{signal:s}),!t.readable)return Ebe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},jgt=t=>{t.writable&&t.end()},wbe=(t,e)=>{Rbe(e)?A6(t):Abe(t,e)},Rbe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",A6=t=>{(t.readable||t.writable)&&t.destroy()},Abe=(t,e)=>{t.destroyed||(t.once("error",qgt),t.destroy(e))},qgt=()=>{},QO=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},vbe=2,bbe=1;import{finished as xbe}from"stream/promises";var Ug=(t,e)=>{t.pipe(e),Bgt(t,e),zgt(t,e)},Bgt=async(t,e)=>{if(!(Zs(t)||Zs(e))){try{await xbe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}x6(e)}},x6=t=>{t.writable&&t.end()},zgt=async(t,e)=>{if(!(Zs(t)||Zs(e))){try{await xbe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}I6(t)}},I6=t=>{t.readable&&t.destroy()};var Ibe=(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)))Vgt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!vs.has(c)))Ggt({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);Ug(o,i)}},Vgt=(t,e,r,n)=>{r==="output"?Ug(t.stdio[n],e):Ug(e,t.stdio[n]);let i=Hgt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},Hgt=["stdin","stdout","stderr"],Ggt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;Wgt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},Wgt=(t,{signal:e})=>{Zs(t)&&Lf(t,Ygt,e)},Ygt=2;import{addAbortListener as Zgt}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 eC=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",P6=Symbol.for("signal-exit emitter"),O6=globalThis,Kgt=Object.defineProperty.bind(Object),C6=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(O6[P6])return O6[P6];Kgt(O6,P6,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let s of this.listeners[e])i=s(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},tC=class{},Jgt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),N6=class extends tC{onExit(){return()=>{}}load(){}unload(){}},k6=class extends tC{#e=$6.platform==="win32"?"SIGINT":"SIGHUP";#r=new C6;#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(!eC(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 eC(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"&&eC(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)}},$6=globalThis.process,{onExit:Pbe,load:fir,unload:pir}=Jgt(eC($6)?new k6($6):new N6);var Obe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Pbe(()=>{t.kill()});Zgt(n,()=>{i()})};var Nbe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=fO(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=Xgt(r,n,i),{sourceStream:d,sourceError:f}=e_t(t,l),{options:p,fileDescriptors:h}=ra.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},Xgt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=Qgt(t,e,...r),a=bO(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},Qgt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Cbe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||TG(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]=rO(r,...n);return{destination:e(Cbe)(i,s,o),pipeOptions:o}}if(ra.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}`)},Cbe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),e_t=(t,e)=>{try{return{sourceStream:Cg(t,e)}}catch(r){return{sourceError:r}}};var $be=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=t_t({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw L6({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},t_t=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return I6(t),n;if(e!==void 0)return x6(r),e},L6=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Lg({error:t,command:kbe,escapedCommand:kbe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),kbe="source.pipe(destination)";var Lbe=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 r_t}from"stream/promises";var Dbe=(t,e,r)=>{let n=rC.has(e)?i_t(t,e):n_t(t,e);return Lf(t,o_t,r.signal),Lf(e,a_t,r.signal),s_t(e),n},n_t=(t,e)=>{let r=Ff([t]);return Ug(r,e),rC.set(e,r),r},i_t=(t,e)=>{let r=rC.get(e);return r.add(t),r},s_t=async t=>{try{await r_t(t,{cleanup:!0,readable:!1,writable:!0})}catch{}rC.delete(t)},rC=new WeakMap,o_t=2,a_t=1;import{aborted as c_t}from"util";var Mbe=(t,e)=>t===void 0?[]:[l_t(t,e)],l_t=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await c_t(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw L6({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var nC=(t,...e)=>{if(yr(e[0]))return nC.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=Nbe(t,...e),i=u_t({...n,destination:r});return i.pipe=nC.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},u_t=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=d_t(t,i);$be({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Dbe(e,s,d);return await Promise.race([Lbe(u),...Mbe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},d_t=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as y_t}from"timers/promises";import{on as f_t}from"events";import{getDefaultHighWaterMark as p_t}from"stream";var iC=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return h_t(e,o),Fbe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},h_t=async(t,e)=>{try{await t}catch{}finally{e.abort()}},D6=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;m_t(e,o,t);let a=t.readableObjectMode&&!s;return Fbe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},m_t=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Fbe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=f_t(t,"data",{signal:e.signal,highWaterMark:Ube,highWatermark:Ube});return g_t({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},M6=p_t(!0),Ube=M6,g_t=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=__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*xb(a)}},__t=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[YO(t,r,!e),WO(t,i,!n,{})].filter(Boolean);var jbe=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=S_t({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([E_t(t),d]);return}let f=h6(c,r),p=D6({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([v_t({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},S_t=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!ZO({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=D6({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Zve(a,t,r,s)},E_t=async t=>{await y_t(),t.readableFlowing===null&&t.resume()},v_t=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await UO(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await FO(r,{maxBuffer:s})):await $g(r,{maxBuffer:s})}catch(a){return qbe(ZEe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},U6=async t=>{try{return await t}catch(e){return qbe(e)}},qbe=({bufferedData:t})=>pye(t)?new Uint8Array(t):t;import{finished as b_t}from"stream/promises";var Cb=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=T_t(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],b_t(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||A_t(a,e,r,n)}finally{o.abort()}},T_t=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&w_t(t,r,n),n},w_t=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{R_t(e,r),n.call(t,...i)}},R_t=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},A_t=(t,e,r,n)=>{if(!x_t(t,e,r,n))throw t},x_t=(t,e,r,n=!0)=>r.propagating?Bbe(t)||sC(t):(r.propagating=!0,F6(r,e)===n?Bbe(t):sC(t)),F6=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",sC=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Bbe=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)=>j6({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),j6=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=Cb(t,e,l);if(F6(l,e)){await u;return}let[d]=await Promise.all([jbe({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 Vbe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Ff([t,e].filter(Boolean)):void 0,Hbe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>j6({...I_t(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:P_t(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),I_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}},P_t=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as O_t}from"events";var Gbe=t=>Ag(t,"ipc"),Wbe=(t,e)=>{let r=dO(t);ea({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Ybe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=Gbe(s),a=Ec(e,"ipc"),c=Ec(r,"ipc");for await(let l of T6({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(XEe(t,i,c),i.push(l)),o&&Wbe(l,s);return i},Kbe=async(t,e)=>(await Promise.allSettled([t]),e);var Jbe=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=rbe(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=Hbe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:S}),P=[],x=Ybe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:P,verboseInfo:p}),R=C_t(m,t,S),O=N_t(h,S);try{return await Promise.race([Promise.all([{},ibe(v),Promise.all(g),w,x,OEe(t,d),...R,...O]),_,k_t(t,y),...REe(t,s,f,y),...GSe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...TEe({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=>U6(b))),U6(w),Kbe(x,P),Promise.allSettled(R),Promise.allSettled(O)])}},C_t=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:Cb(n,i,r)),N_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})=>Cb(o,n,e,{isSameDirection:vs.has(i),stopOnExit:i==="native"}))),k_t=async(t,{signal:e})=>{let[r]=await O_t(t,"error",{signal:e});throw r};var Zbe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),Nb=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=ta();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},Fg=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 $_t}from"stream";import{callbackify as L_t}from"util";import{finished as Xbe}from"stream/promises";var q6=async t=>{if(t!==void 0)try{await B6(t)}catch{}},Qbe=async t=>{if(t!==void 0)try{await z6(t)}catch{}},B6=async t=>{await Xbe(t,{cleanup:!0,readable:!1,writable:!0})},z6=async t=>{await Xbe(t,{cleanup:!0,readable:!0,writable:!1})},oC=async(t,e)=>{if(await t,e)throw e},aC=(t,e,r)=>{r&&!sC(r)?t.destroy(r):e&&t.destroy()};var eTe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||$i.has(r),{subprocessStdout:a,waitReadableDestroy:c}=V6(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=H6(a,o),{read:f,onStdoutDataDone:p}=G6({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new $_t({read:f,destroy:L_t(Y6.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return W6({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},V6=(t,e,r)=>{let n=Cg(t,e),i=Nb(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},H6=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:M6},G6=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=ta(),o=iC({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){D_t(this,o,s)},onStdoutDataDone:s}},D_t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},W6=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await z6(t),await n,await q6(i),await e,r.readable&&r.push(null)}catch(s){await q6(i),tTe(r,s)}},Y6=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Fg(r,e)&&(tTe(t,n),await oC(e,n))},tTe=(t,e)=>{aC(t,t.readable,e)};import{Writable as M_t}from"stream";import{callbackify as rTe}from"util";var nTe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=K6(t,r,e),o=new M_t({...J6(n,t,i),destroy:rTe(X6.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return Z6(n,o),o},K6=(t,e,r)=>{let n=bO(t,e),i=Nb(r,n,"writableFinal"),s=Nb(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},J6=(t,e,r)=>({write:U_t.bind(void 0,t),final:rTe(F_t.bind(void 0,t,e,r))}),U_t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},F_t=async(t,e,r)=>{await Fg(r,e)&&(t.writable&&t.end(),await e)},Z6=async(t,e,r)=>{try{await B6(t),e.writable&&e.end()}catch(n){await Qbe(r),iTe(e,n)}},X6=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Fg(r,e),await Fg(n,e)&&(iTe(t,i),await oC(e,i))},iTe=(t,e)=>{aC(t,t.writable,e)};import{Duplex as j_t}from"stream";import{callbackify as q_t}from"util";var sTe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||$i.has(r),{subprocessStdout:c,waitReadableDestroy:l}=V6(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=K6(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=H6(c,a),{read:_,onStdoutDataDone:y}=G6({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),v=new j_t({read:_,...J6(u,t,d),destroy:q_t(B_t.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 W6({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:u}),Z6(u,v,c),v},B_t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([Y6({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),X6({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var Q6=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||$i.has(e),o=Cg(t,r),a=iC({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return z_t(a,o,t)},z_t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var oTe=(t,{encoding:e})=>{let r=Zbe();t.readable=eTe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=nTe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=sTe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=Q6.bind(void 0,t,e),t[Symbol.asyncIterator]=Q6.bind(void 0,t,e,{})};var aTe=(t,e)=>{for(let[r,n]of H_t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},V_t=(async()=>{})().constructor.prototype,H_t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(V_t,t)]);var cTe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=Y_t(t,e,r),{subprocess:f,promise:p}=J_t({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=nC.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),aTe(f,p),ra.set(f,{options:u,fileDescriptors:d}),f},Y_t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=pO(t,e,r),{file:a,commandArguments:c,options:l}=kO(t,e,r),u=K_t(l),d=Sbe(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},K_t=({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}},J_t=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=W_t(...$O(t,e,r))}catch(h){return mbe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;G_t(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];Ibe(c,a,l),Obe(c,r,l);let d={},f=ta();c.kill=VSe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Vbe(c,r),oTe(c,r),fbe(c,r);let p=Z_t({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}},Z_t=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 Jbe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:l,controller:u});u.abort(),l.resolve();let y=h.map((g,w)=>bc(g,e,w)),v=bc(m,e,"all"),S=X_t({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Dg(S,n,e)},X_t=({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?Ab({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 na,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):BO({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var cC=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,Q_t(n,t[n],i)]));return{...t,...r}},Q_t=(t,e,r)=>eyt.has(t)&&yr(e)&&yr(r)?{...e,...r}:r,eyt=new Set(["env",...PG]);var bu=(t,e,r,n)=>{let i=(o,a,c)=>bu(o,a,r,c),s=(...o)=>tyt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},tyt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(yr(s))return i(t,cC(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=ryt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?obe(a,c,l):cTe(a,c,l,i)},ryt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=Sye(e)?Eye(e,r):[e,...r],[o,a,c]=rO(...s),l=cC(cC(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 lTe=({file:t,commandArguments:e})=>dTe(t,e),uTe=({file:t,commandArguments:e})=>({...dTe(t,e),isSync:!0}),dTe=(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]=nyt(t);return{file:r,commandArguments:n}},nyt=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(iyt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},iyt=/ +/g;var fTe=(t,e,r)=>{t.sync=e(syt,r),t.s=t.sync},pTe=({options:t})=>hTe(t),syt=({options:t})=>({...hTe(t),isSync:!0}),hTe=t=>({options:{...oyt(t),...t}}),oyt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},mTe={preferLocal:!0};var gTe=bu(()=>({})),nar=bu(()=>({isSync:!0})),_Te=bu(lTe),iar=bu(uTe),sar=bu(xEe),oar=bu(pTe,{},mTe,fTe),{sendMessage:aar,getOneMessage:car,getEachMessage:lar,getCancelSignal:uar}=pbe();import{Transform as ayt}from"stream";var cyt=["NETLIFY_AI_GATEWAY_KEY"];function lyt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...cyt])]}function uyt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function dyt(){let e=lyt().map(r=>process.env[r]).filter(r=>!(!r||uyt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function bs(t){if(typeof t!="string")return t;let e=dyt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(fyt(n),"g");r=r.replace(i,"******")}),r}function fyt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var kb=class extends ayt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=bs(i);n(null,s)}},lC=Symbol("maskedWrite");function yTe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[lC]){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[lC]=!0,process.stdout.write=r}if(!process.stderr.write[lC]){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[lC]=!0,process.stderr.write=r}}}var STe=!1,ETe=()=>{STe=!0},hi=()=>STe;var $b=null,vTe=t=>($b&&$b.destroy(),$b=new Tc({totalAllowedTime:t}),$b),bTe=()=>$b;var Tc=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&hi())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 eO({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{Ie.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 TTe={name:"@netlify/agent-runner-cli",type:"module",version:"1.142.1-test.9",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.0","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"2.1.197","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@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","opencode-ai":"1.17.19",zod:"^4.4.3"}};var gyt=hyt(import.meta.url),_yt=wc.dirname(gyt),yyt=myt(import.meta.url),jg=Re("shell"),e3=new Set,wTe={preferLocal:!0},Li=(t,e,r)=>{let[n,i]=Syt(e,r),s={...wTe,...i},o=gTe(t,n,s);ATe(o,s),PTe(o);let a=r?.idleTimeout;return a&&a>0&&ITe(o,a),o},RTe=(t,e)=>{let r={...wTe,...e},n=_Te(t,r);return ATe(n,r),PTe(n),e?.idleTimeout&&e.idleTimeout>0&&ITe(n,e.idleTimeout),n},Syt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},ATe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(Rc.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new kb).pipe(Rc.stdout),t.stderr?.pipe(new kb).pipe(Rc.stderr);return}t.stdout?.pipe(Rc.stdout),t.stderr?.pipe(Rc.stderr)},t3=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(Rc.kill(-t.pid,e),jg.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return jg.error("Error killing process:",r),!1}},xTe=t=>t3(t,"SIGKILL"),ITe=(t,e)=>{let r=null,n=()=>{jg.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),t3(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(jg.log(`Force killing idle process ${t.pid}`),xTe(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)},PTe=t=>{e3.add(t);let e=bTe();if(e){let r=e.onTimesUp(()=>{jg.log(`Global timer expired, killing process ${t.pid}`),t3(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(jg.log(`Force killing process ${t.pid} after timeout`),xTe(t))},5e3)});t.on("exit",()=>{e3.delete(t),r()}),t.on("error",()=>{e3.delete(t),r()})}};function sa(t,e){if(!Rc.env.NETLIFY_LOCAL_MODE)try{let i=yyt.resolve(TTe.name),s=wc.dirname(i);for(;s!==wc.dirname(s);){let o=wc.dirname(s);if(wc.basename(o)==="node_modules"){let a=wc.join(o,".bin",e);if(uC.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(Rc.env.NODE_PATH){let i=wc.join(Rc.env.NODE_PATH,".bin",e);if(uC.existsSync(i))return i}let r=wc.join(t,"node_modules",".bin",e);if(uC.existsSync(r))return r;let n=wc.join(_yt,"..","node_modules",".bin",e);if(uC.existsSync(n))return n}import hL from"process";import{fileURLToPath as cCt}from"url";import{createRequire as lCt}from"module";import mL from"path";var Eyt="__netlify__getTracer",vyt="__netlify__shutdownTracers",ft=(t,e)=>globalThis[Eyt]?.(t,e),OTe=async()=>globalThis[vyt]?.();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 rCt}from"timers/promises";import _Et from"process";var CTe=typeof globalThis=="object"?globalThis:global;var Ac="1.9.0";var NTe=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function byt(t){var e=new Set([t]),r=new Set,n=t.match(NTe);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(NTe);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 kTe=byt(Ac);var Tyt=Ac.split(".")[0],Lb=Symbol.for("opentelemetry.js.api."+Tyt),Db=CTe;function Tu(t,e,r,n){var i;n===void 0&&(n=!1);var s=Db[Lb]=(i=Db[Lb])!==null&&i!==void 0?i:{version:Ac};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!==Ac){var o=new Error("@opentelemetry/api: Registration of version v"+s.version+" for "+t+" does not match previously registered API v"+Ac);return r.error(o.stack||o.message),!1}return s[t]=e,r.debug("@opentelemetry/api: Registered a global for "+t+" v"+Ac+"."),!0}function to(t){var e,r,n=(e=Db[Lb])===null||e===void 0?void 0:e.version;if(!(!n||!kTe(n)))return(r=Db[Lb])===null||r===void 0?void 0:r[t]}function wu(t,e){e.debug("@opentelemetry/api: Unregistering a global for "+t+" v"+Ac+".");var r=Db[Lb];r&&delete r[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},Ryt=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))},$Te=(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 Mb("debug",this._namespace,e)},t.prototype.error=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Mb("error",this._namespace,e)},t.prototype.info=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Mb("info",this._namespace,e)},t.prototype.warn=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Mb("warn",this._namespace,e)},t.prototype.verbose=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Mb("verbose",this._namespace,e)},t})();function Mb(t,e,r){var n=to("diag");if(n)return r.unshift(e),n[t].apply(n,Ryt([],wyt(r),!1))}var Gn;(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"})(Gn||(Gn={}));function LTe(t,e){t<Gn.NONE?t=Gn.NONE:t>Gn.ALL&&(t=Gn.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",Gn.ERROR),warn:r("warn",Gn.WARN),info:r("info",Gn.INFO),debug:r("debug",Gn.DEBUG),verbose:r("verbose",Gn.VERBOSE)}}var Ayt=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},xyt=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))},Iyt="diag",Di=(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,xyt([],Ayt(s),!1))}}var r=this,n=function(i,s){var o,a,c;if(s===void 0&&(s={logLevel:Gn.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=LTe((a=s.logLevel)!==null&&a!==void 0?a:Gn.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(Iyt,r)},r.createComponentLogger=function(i){return new $Te(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 Pyt=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},Oyt=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.")},DTe=(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=Pyt(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=Oyt(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 ecr=Di.instance();function MTe(t){return t===void 0&&(t={}),new DTe(new Map(Object.entries(t)))}function dC(t){return Symbol.for(t)}var Cyt=(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})(),UTe=new Cyt;var FTe={get:function(t,e){if(t!=null)return t[e]},keys:function(t){return t==null?[]:Object.keys(t)}},jTe={set:function(t,e,r){t!=null&&(t[e]=r)}};var Nyt=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},kyt=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))},qTe=(function(){function t(){}return t.prototype.active=function(){return UTe},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,kyt([n],Nyt(i),!1))},t.prototype.bind=function(e,r){return r},t.prototype.enable=function(){return this},t.prototype.disable=function(){return this},t})();var $yt=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},Lyt=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))},r3="context",Dyt=new qTe,Ru=(function(){function t(){}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalContextManager=function(e){return Tu(r3,e,Di.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,Lyt([e,r,n],$yt(s),!1))},t.prototype.bind=function(e,r){return this._getContextManager().bind(e,r)},t.prototype._getContextManager=function(){return to(r3)||Dyt},t.prototype.disable=function(){this._getContextManager().disable(),wu(r3,Di.instance())},t})();var fC;(function(t){t[t.NONE=0]="NONE",t[t.SAMPLED=1]="SAMPLED"})(fC||(fC={}));var n3="0000000000000000",i3="00000000000000000000000000000000",BTe={traceId:i3,spanId:n3,traceFlags:fC.NONE};var Au=(function(){function t(e){e===void 0&&(e=BTe),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 s3=dC("OpenTelemetry Context Key SPAN");function pC(t){return t.getValue(s3)||void 0}function zTe(){return pC(Ru.getInstance().active())}function Ub(t,e){return t.setValue(s3,e)}function VTe(t){return t.deleteValue(s3)}function HTe(t,e){return Ub(t,new Au(e))}function hC(t){var e;return(e=pC(t))===null||e===void 0?void 0:e.spanContext()}var Myt=/^([0-9a-f]{32})$/i,Uyt=/^[0-9a-f]{16}$/i;function Fyt(t){return Myt.test(t)&&t!==i3}function jyt(t){return Uyt.test(t)&&t!==n3}function mC(t){return Fyt(t.traceId)&&jyt(t.spanId)}function GTe(t){return new Au(t)}var o3=Ru.getInstance(),gC=(function(){function t(){}return t.prototype.startSpan=function(e,r,n){n===void 0&&(n=o3.active());var i=!!r?.root;if(i)return new Au;var s=n&&hC(n);return qyt(s)&&mC(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??o3.active(),l=this.startSpan(e,s,c),u=Ub(c,l);return o3.with(u,a,void 0,l)}},t})();function qyt(t){return typeof t=="object"&&typeof t.spanId=="string"&&typeof t.traceId=="string"&&typeof t.traceFlags=="number"}var Byt=new gC,WTe=(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):Byt},t})();var YTe=(function(){function t(){}return t.prototype.getTracer=function(e,r,n){return new gC},t})();var zyt=new YTe,a3=(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 WTe(this,e,r,n)},t.prototype.getDelegate=function(){var e;return(e=this._delegate)!==null&&e!==void 0?e:zyt},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 oa;(function(t){t[t.UNSET=0]="UNSET",t[t.OK=1]="OK",t[t.ERROR=2]="ERROR"})(oa||(oa={}));var xc=Ru.getInstance();var c3=Di.instance();var KTe=(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 l3=dC("OpenTelemetry Baggage Key");function u3(t){return t.getValue(l3)||void 0}function JTe(){return u3(Ru.getInstance().active())}function ZTe(t,e){return t.setValue(l3,e)}function XTe(t){return t.deleteValue(l3)}var d3="propagation",Vyt=new KTe,QTe=(function(){function t(){this.createBaggage=MTe,this.getBaggage=u3,this.getActiveBaggage=JTe,this.setBaggage=ZTe,this.deleteBaggage=XTe}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalPropagator=function(e){return Tu(d3,e,Di.instance())},t.prototype.inject=function(e,r,n){return n===void 0&&(n=jTe),this._getGlobalPropagator().inject(e,r,n)},t.prototype.extract=function(e,r,n){return n===void 0&&(n=FTe),this._getGlobalPropagator().extract(e,r,n)},t.prototype.fields=function(){return this._getGlobalPropagator().fields()},t.prototype.disable=function(){wu(d3,Di.instance())},t.prototype._getGlobalPropagator=function(){return to(d3)||Vyt},t})();var Fb=QTe.getInstance();var f3="trace",ewe=(function(){function t(){this._proxyTracerProvider=new a3,this.wrapSpanContext=GTe,this.isSpanContextValid=mC,this.deleteSpan=VTe,this.getSpan=pC,this.getActiveSpan=zTe,this.getSpanContext=hC,this.setSpan=Ub,this.setSpanContext=HTe}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalTracerProvider=function(e){var r=Tu(f3,this._proxyTracerProvider,Di.instance());return r&&this._proxyTracerProvider.setDelegate(e),r},t.prototype.getTracerProvider=function(){return to(f3)||this._proxyTracerProvider},t.prototype.getTracer=function(e,r){return this.getTracerProvider().getTracer(e,r)},t.prototype.disable=function(){wu(f3,Di.instance()),this._proxyTracerProvider=new a3},t})();var jb=ewe.getInstance();var Gyt=function(t,e){e.recordException(t),e.setStatus({code:oa.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=twe(r,n,i),o=s.opts,a=s.ctx,c=s.fn;return this._tracer.startActiveSpan(e,o,a,function(l){return rwe(l,o,c)})},t.prototype.withSpan=function(e,r,n,i){var s=twe(r,n,i),o=s.opts,a=s.ctx,c=s.fn,l=this._tracer.startSpan(e,o,a);return rwe(l,o,c)},t})();function twe(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??xc.active(),{opts:n,ctx:i,fn:s}}function rwe(t,e,r){var n,i=(n=e.onException)!==null&&n!==void 0?n:Gyt,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)}}lW();Qe();var dT=class{emit(e){}enabled(){return!1}},mRe=new dT;var fT=Symbol.for("io.opentelemetry.js.api.logs"),Jg=globalThis;function gRe(t,e,r){return n=>n===t?e:r}var uW=1;var dW=class{getLogger(e,r,n){return new dT}},aN=new dW;var cN=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):mRe}};var pT=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new cN(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:aN}_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 lN=class t{constructor(){this._proxyLoggerProvider=new pT}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return Jg[fT]?this.getLoggerProvider():(Jg[fT]=gRe(uW,e,aN),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=Jg[fT])===null||e===void 0?void 0:e.call(Jg,uW))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete Jg[fT],this._proxyLoggerProvider=new pT}};var _Re=lN.getInstance();function yRe(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 SRe(t){t.forEach(e=>e.disable())}function fW(t){let e=t.tracerProvider||Or.getTracerProvider(),r=t.meterProvider||Zb.getMeterProvider(),n=t.loggerProvider||_Re.getLoggerProvider(),i=t.instrumentations?.flat()??[];return yRe(i,e,r,n),()=>{SRe(i)}}dr();var CN=Ln(IW(),1);dr();var XRe=t=>{throw TypeError(t)},NW=(t,e,r)=>e.has(t)||XRe("Cannot "+r),ON=(t,e,r)=>(NW(t,e,"read from private field"),r?r.call(t):e.get(t)),PW=(t,e,r)=>e.has(t)?XRe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),KRe=(t,e,r,n)=>(NW(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),gEt=(t,e,r)=>(NW(t,e,"access private method"),r),JRe="__netlify__getTracer",yEt="__netlify__shutdownTracers",SEt="__nfOTLPTrace",mT,gT,CW,QRe,EEt=class{constructor(){PW(this,CW),PW(this,mT),PW(this,gT),KRe(this,mT,new pa(gEt(this,CW,QRe),this)),KRe(this,gT,c3.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(ON(this,gT).debug(`export ${t.length.toString()} spans`),ON(this,mT).isCalled){e({code:Xt.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(SEt,JSON.stringify(vEt(t))),e({code:Xt.SUCCESS})}shutdown(){return ON(this,mT).call()}};mT=new WeakMap;gT=new WeakMap;CW=new WeakSet;QRe=function(){return ON(this,gT).debug("Shutting down"),Promise.resolve()};function vEt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:PN(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:OW(e.startTime),endTimeUnixNano:OW(e.endTime),attributes:PN(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:OW(n.time),attributes:PN(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:PN(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function PN(t){return Object.keys(t).map(e=>eAe(e,t[e]))}function eAe(t,e){return{key:t,value:tAe(e)}}function tAe(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(tAe)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>eAe(r,n))}}:{}}function OW(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var ZRe={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"}},rAe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,JRe))return;let e=_Et.version.slice(1),r=oN({"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??[bEt()],i=new CN.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new Nc});let s=t.instrumentations??[];fW({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,JRe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new Bf(jb.getTracer(a,c)):new Bf(jb.getTracer(ZRe.name,ZRe.version))}}),Object.defineProperty(globalThis,yEt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},bEt=()=>new CN.SimpleSpanProcessor(new EEt);dr();var _T=Ln(IW(),1);import*as NN from"diagnostics_channel";var nAe=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?oa.ERROR:oa.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){NN.subscribe(t,e);let r=()=>NN.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},xc.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:oa.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 mke=Ln(pke(),1);var fL=Re("tracing"),hke=8e3,nCt=5e3,Ow=async(t=nCt)=>{try{await Promise.race([OTe(),rCt(t)])}catch(e){fL.warn("Failed to flush tracers on shutdown",e)}},gke=async(t,e,r)=>{if(!ft()){let n=[new _T.SimpleSpanProcessor(new g9),new _T.SimpleSpanProcessor(new mke.OTLPTraceExporter({url:r.exporterUrl}))];await rAe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new nAe({skipHeaders:!0})]})}return r.traceparent?(Fb.setGlobalPropagator(new Nc),Fb.extract(xc.active(),{traceparent:r.traceparent,isRemote:!0})):xc.active()};function zt(t,e,r){return fL.log(`\u23F3 TRACE: ${e} starting...`),qf(t,e,r)}var g9=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(", ")}]`:"";fL.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&fL.log(` \u274C Error: ${e.status.message}`)}};function _9(){return ut().captureLlmContentEnabled}function _ke(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function pL(t,e,r){let n={role:t,parts:[{type:"text",content:bs(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}function yke(t,e,r,n){if(!t.length)return;let i=ft();if(!i)return;let s=_9(),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>hke?`${a.message.slice(0,hke)}\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":pL("assistant",p)}:{}}}).end(u)})}import{readdir as iCt,rm as sCt}from"fs/promises";import{join as oCt}from"path";async function Ske(t,e=[]){let n=(await iCt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>sCt(oCt(t,i),{recursive:!0,force:!0})))}var aCt=700,Eke=t=>t.mode==="create"&&(t.accountType===Tl||t.enforcedAICreditsRemaining!=null&&t.enforcedAICreditsRemaining<=aCt);var uCt=mL.dirname(cCt(import.meta.url)),vke=lCt(import.meta.url),dCt=mL.resolve(uCt,"scripts/scaffold.js"),fCt="scripts/scaffold.js",pCt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,y9=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},hCt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),mCt=t=>{let e=y9(t);return e==="node"||e.endsWith("/node")},Qc=t=>{if(typeof t!="string")return!1;let e=t.match(pCt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&hCt(y9(e[r]));)r+=1;if(r>=e.length||!mCt(e[r]))return!1;let n=e[r+1];return n?y9(n).includes(fCt):!1},W_=Re("create_stage"),bke="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.",gCt=`${bke}
|
|
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.`,_Ct=`${bke}
|
|
584
584
|
|
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:SD},uNe=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},dNe={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:uNe};import{Buffer as fNe}from"buffer";var BQ=(t,e)=>t?void 0:pNe.bind(void 0,e),pNe=function*(t,e){if(typeof e!="string"&&!Bt(e)&&!fNe.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},jQ=(t,e)=>t?hNe.bind(void 0,e):mNe.bind(void 0,e),hNe=function*(t,e){zQ(t,e),yield e},mNe=function*(t,e){if(zQ(t,e),typeof e!="string"&&!Bt(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},zQ=(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 gNe}from"buffer";import{StringDecoder as _Ne}from"string_decoder";var vx=(t,e,r)=>{if(r)return;if(t)return{transform:yNe.bind(void 0,new TextEncoder)};let n=new _Ne(e);return{transform:SNe.bind(void 0,n),final:ENe.bind(void 0,n)}},yNe=function*(t,e){gNe.isBuffer(e)?yield ds(e):typeof e=="string"?yield t.encode(e):yield e},SNe=function*(t,e){yield Bt(e)?t.write(e):e},ENe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as GQ}from"util";var vD=GQ(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),bx=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=bNe}=e[r];for await(let i of n(t))yield*bx(i,e,r+1)},VQ=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*vNe(r,Number(e),t)},vNe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*bx(n,r,e+1)},qQ=GQ(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),bNe=function*(t){yield t};var bD=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},HQ=(t,e)=>[...e.flatMap(r=>[...xl(r,t,0)]),...n_(t)],xl=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=xNe}=e[r];for(let i of n(t))yield*xl(i,e,r+1)},n_=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*TNe(r,Number(e),t)},TNe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*xl(n,r,e+1)},xNe=function*(t){yield t};var TD=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=YQ(t,s,o),l=Tl(e),u=Tl(r),d=l?vD.bind(void 0,bx,a):bD.bind(void 0,xl),f=l||u?vD.bind(void 0,VQ,a):bD.bind(void 0,n_),p=l||u?qQ.bind(void 0,a):void 0;return{stream:new wNe({writableObjectMode:n,writableHighWaterMark:WQ(n),readableObjectMode:i,readableHighWaterMark:WQ(i),transform(m,y,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:p})}},Tx=(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=YQ(s,r,a);t=HQ(c,t)}return t},YQ=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:BQ(n,a)},vx(r,s,n),Ex(r,o,n,c),{transform:t,final:e},{transform:jQ(i,a)},FQ({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var KQ=(t,e)=>{for(let r of ANe(t))RNe(t,r,e)},ANe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),RNe=(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=>INe(a,n));r.input=Wg(s)},INe=(t,e)=>{let r=Tx(t,e,"utf8",!0);return CNe(r),Wg(r)},CNe=t=>{let e=t.find(r=>typeof r!="string"&&!Bt(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 kNe,appendFileSync as MNe}from"fs";var xx=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Bd(r,n)&&!mn.has(e)&&PNe(n)&&(t.some(({type:i,value:o})=>i==="native"&&ONe.has(o))||t.every(({type:i})=>qn.has(i))),PNe=t=>t===1||t===2,ONe=new Set(["pipe","overlapped"]),ZQ=async(t,e,r,n)=>{for await(let i of t)NNe(e)||XQ(i,r,n)},JQ=(t,e,r)=>{for(let n of t)XQ(n,e,r)},NNe=t=>t._readableState.pipes.length>0,XQ=(t,e,r)=>{let n=UT(t);ao({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var QQ=({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)=>DNe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},DNe=({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=eQ(t,o,d),p=ds(f),{stdioItems:h,objectMode:m}=e[r],y=LNe([p],h,c,n),{serializedResult:S,finalResult:b=S}=$Ne({chunks:y,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});UNe({serializedResult:S,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let w=a[r]?b:void 0;try{return n.error===void 0&&FNe(S,h,i),w}catch(v){return n.error=v,w}},LNe=(t,e,r,n)=>{try{return Tx(t,e,r,!1)}catch(i){return n.error=i,t}},$Ne=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Wg(t)};let s=h9(t,r);return n[o]?{serializedResult:s,finalResult:ED(s,!i[o],e)}:{serializedResult:s}},UNe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!xx({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=ED(t,!1,s);try{JQ(a,e,n)}catch(c){r.error??=c}},FNe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>yx.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?MNe(n,t):(r.add(o),kNe(n,t))}};var e7=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,hs(e,r,"all")]:Array.isArray(e)?[hs(t,r,"all"),...e]:Bt(t)&&Bt(e)?CM([t,e]):`${t}${e}`};import{once as xD}from"events";var t7=async(t,e)=>{let[r,n]=await BNe(t);return e.isForcefullyTerminated??=!1,[r,n]},BNe=async t=>{let[e,r]=await Promise.allSettled([xD(t,"spawn"),xD(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?r7(t):r.value},r7=async t=>{try{return await xD(t,"exit")}catch{return r7(t)}},n7=async t=>{let[e,r]=await t;if(!jNe(e,r)&&wD(e,r))throw new Ti;return[e,r]},jNe=(t,e)=>t===void 0&&e===void 0,wD=(t,e)=>t!==0||e!==null;var i7=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=zNe(t,e,r),s=o?.code==="ETIMEDOUT",a=QX(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},zNe=(t,e,r)=>t!==void 0?t:wD(e,r)?new Ti:void 0;var o7=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=VNe(t,e,r),d=WNe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Zd(d,c,l)},VNe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=BT(t,e,r),a=qNe(r),{file:c,commandArguments:l,options:u}=sx(t,e,a);HNe(u);let d=DQ(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},qNe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,HNe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&wx("ipcInput"),t&&wx("ipc: true"),r&&wx("detached: true"),n&&wx("cancelSignal")},wx=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},WNe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=YNe({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}=i7(c,r),{output:h,error:m=l}=QQ({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),y=h.map((b,w)=>hs(b,r,w)),S=hs(e7(h,r),r,"all");return ZNe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:y,all:S,options:r,command:n,escapedCommand:i,startTime:a})},YNe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{KQ(o,r);let a=KNe(r);return GNe(...ax(t,e,a))}catch(a){return Kd({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},KNe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:hx(e)}),ZNe=({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?mx({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):r_({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 $Me}from"events";import{spawn as UMe}from"child_process";import u7 from"process";import{once as AD,on as JNe}from"events";var s7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Gd({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:ex(t)}),XNe({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),XNe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{ZT(e,i);let o=Ca(t,e,r),s=new AbortController;try{return await Promise.race([QNe(o,n,s),eke(o,r,s),tke(o,r,s)])}catch(a){throw Vd(t),a}finally{s.abort(),JT(e,i)}},QNe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await AD(t,"message",{signal:r});return n}for await(let[n]of JNe(t,"message",{signal:r}))if(e(n))return n},eke=async(t,e,{signal:r})=>{await AD(t,"disconnect",{signal:r}),HJ(e)},tke=async(t,e,{signal:r})=>{let[n]=await AD(t,"strict:error",{signal:r});throw WT(n,e)};import{once as c7,on as rke}from"events";var l7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>RD({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),RD=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Gd({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:ex(t)}),ZT(e,o);let s=Ca(t,e,r),a=new AbortController,c={};return nke(t,s,a),ike({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),oke({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},nke=async(t,e,r)=>{try{await c7(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},ike=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await c7(t,"strict:error",{signal:r.signal});n.error=WT(i,e),r.abort()}catch{}},oke=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of rke(r,"message",{signal:o.signal}))a7(s),yield c}catch{a7(s)}finally{o.abort(),JT(e,a),n||Vd(t),i&&await t}},a7=({error:t})=>{if(t)throw t};var d7=(t,{ipc:e})=>{Object.assign(t,p7(t,!1,e))},f7=()=>{let t=u7,e=!0,r=u7.channel!==void 0;return{...p7(t,e,r),getCancelSignal:SX.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},p7=(t,e,r)=>({sendMessage:ix.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:s7.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:l7.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as ske}from"child_process";import{PassThrough as ake,Readable as cke,Writable as lke,Duplex as uke}from"stream";var h7=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{_D(n);let a=new ske;dke(a,n),Object.assign(a,{readable:fke,writable:pke,duplex:hke});let c=Kd({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=mke(c,s,i);return{subprocess:a,promise:l}},dke=(t,e)=>{let r=i_(),n=i_(),i=i_(),o=Array.from({length:e.length-3},i_),s=i_(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},i_=()=>{let t=new ake;return t.end(),t},fke=()=>new cke({read(){}}),pke=()=>new lke({write(){}}),hke=()=>new uke({read(){},write(){}}),mke=async(t,e,r)=>Zd(t,e,r);import{createReadStream as m7,createWriteStream as g7}from"fs";import{Buffer as gke}from"buffer";import{Readable as o_,Writable as _ke,Duplex as yke}from"stream";var y7=(t,e)=>Sx(Ske,t,e,!1),s_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Pa[t]}.`)},_7={fileNumber:s_,generator:TD,asyncGenerator:TD,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(){}},Ske={input:{..._7,fileUrl:({value:t})=>({stream:m7(t)}),filePath:({value:{file:t}})=>({stream:m7(t)}),webStream:({value:t})=>({stream:o_.fromWeb(t)}),iterable:({value:t})=>({stream:o_.from(t)}),asyncIterable:({value:t})=>({stream:o_.from(t)}),string:({value:t})=>({stream:o_.from(t)}),uint8Array:({value:t})=>({stream:o_.from(gke.from(t))})},output:{..._7,fileUrl:({value:t})=>({stream:g7(t)}),filePath:({value:{file:t,append:e}})=>({stream:g7(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:_ke.fromWeb(t)}),iterable:s_,asyncIterable:s_,string:s_,uint8Array:s_}};import{on as Eke,once as S7}from"events";import{PassThrough as vke,getDefaultHighWaterMark as bke}from"stream";import{finished as b7}from"stream/promises";function wl(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)CD(i);let e=t.some(({readableObjectMode:i})=>i),r=Tke(t,e),n=new ID({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Tke=(t,e)=>{if(t.length===0)return bke(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},ID=class extends vke{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(CD(e),this.#e.has(e))return;this.#e.add(e),this.#n??=xke(this,this.#e,this.#o);let r=Rke({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(CD(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)}},xke=async(t,e,r)=>{Ax(t,E7);let n=new AbortController;try{await Promise.race([wke(t,n),Ake(t,e,r,n)])}finally{n.abort(),Ax(t,-E7)}},wke=async(t,{signal:e})=>{try{await b7(t,{signal:e,cleanup:!0})}catch(r){throw T7(t,r),r}},Ake=async(t,e,r,{signal:n})=>{for await(let[i]of Eke(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},CD=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Rke=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{Ax(t,v7);let a=new AbortController;try{await Promise.race([Ike(o,e,a),Cke({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),Pke({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),Ax(t,-v7)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?PD(t):Oke(t))},Ike=async(t,e,{signal:r})=>{try{await t,r.aborted||PD(e)}catch(n){r.aborted||T7(e,n)}},Cke=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;x7(s)?i.add(e):w7(t,s)}},Pke=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await S7(t,i,{signal:o}),!t.readable)return S7(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},Oke=t=>{t.writable&&t.end()},T7=(t,e)=>{x7(e)?PD(t):w7(t,e)},x7=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",PD=t=>{(t.readable||t.writable)&&t.destroy()},w7=(t,e)=>{t.destroyed||(t.once("error",Nke),t.destroy(e))},Nke=()=>{},Ax=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},E7=2,v7=1;import{finished as A7}from"stream/promises";var Xd=(t,e)=>{t.pipe(e),kke(t,e),Mke(t,e)},kke=async(t,e)=>{if(!(bi(t)||bi(e))){try{await A7(t,{cleanup:!0,readable:!0,writable:!1})}catch{}OD(e)}},OD=t=>{t.writable&&t.end()},Mke=async(t,e)=>{if(!(bi(t)||bi(e))){try{await A7(e,{cleanup:!0,readable:!1,writable:!0})}catch{}ND(t)}},ND=t=>{t.readable&&t.destroy()};var R7=(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})=>qn.has(c)))Dke(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!qn.has(c)))$ke({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)}},Dke=(t,e,r,n)=>{r==="output"?Xd(t.stdio[n],e):Xd(e,t.stdio[n]);let i=Lke[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},Lke=["stdin","stdout","stderr"],$ke=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;Uke(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},Uke=(t,{signal:e})=>{bi(t)&&vl(t,Fke,e)},Fke=2;import{addAbortListener as zke}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 Rx=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",kD=Symbol.for("signal-exit emitter"),MD=globalThis,Bke=Object.defineProperty.bind(Object),DD=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(MD[kD])return MD[kD];Bke(MD,kD,{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}},Ix=class{},jke=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),LD=class extends Ix{onExit(){return()=>{}}load(){}unload(){}},$D=class extends Ix{#e=UD.platform==="win32"?"SIGINT":"SIGHUP";#r=new DD;#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(!Rx(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 Rx(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"&&Rx(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)}},UD=globalThis.process,{onExit:I7,load:ypt,unload:Spt}=jke(Rx(UD)?new $D(UD):new LD);var C7=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=I7(()=>{t.kill()});zke(n,()=>{i()})};var O7=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=FT(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=Gke(r,n,i),{sourceStream:d,sourceError:f}=qke(t,l),{options:p,fileDescriptors:h}=lo.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},Gke=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=Vke(t,e,...r),a=KT(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},Vke=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(P7,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||RM(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]=CT(r,...n);return{destination:e(P7)(i,o,s),pipeOptions:s}}if(lo.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}`)},P7=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),qke=(t,e)=>{try{return{sourceStream:qd(t,e)}}catch(r){return{sourceError:r}}};var k7=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=Hke({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw FD({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},Hke=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return ND(t),n;if(e!==void 0)return OD(r),e},FD=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Kd({error:t,command:N7,escapedCommand:N7,fileDescriptors:e,options:r,startTime:n,isSync:!1}),N7="source.pipe(destination)";var M7=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 Wke}from"stream/promises";var D7=(t,e,r)=>{let n=Cx.has(e)?Kke(t,e):Yke(t,e);return vl(t,Jke,r.signal),vl(e,Xke,r.signal),Zke(e),n},Yke=(t,e)=>{let r=wl([t]);return Xd(r,e),Cx.set(e,r),r},Kke=(t,e)=>{let r=Cx.get(e);return r.add(t),r},Zke=async t=>{try{await Wke(t,{cleanup:!0,readable:!1,writable:!0})}catch{}Cx.delete(t)},Cx=new WeakMap,Jke=2,Xke=1;import{aborted as Qke}from"util";var L7=(t,e)=>t===void 0?[]:[eMe(t,e)],eMe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await Qke(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw FD({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var Px=(t,...e)=>{if(Pt(e[0]))return Px.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=O7(t,...e),i=tMe({...n,destination:r});return i.pipe=Px.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},tMe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=rMe(t,i);k7({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=D7(e,o,d);return await Promise.race([M7(u),...L7(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},rMe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as lMe}from"timers/promises";import{on as nMe}from"events";import{getDefaultHighWaterMark as iMe}from"stream";var Ox=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return oMe(e,s),U7({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},oMe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},BD=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;sMe(e,s,t);let a=t.readableObjectMode&&!o;return U7({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},sMe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},U7=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=nMe(t,"data",{signal:e.signal,highWaterMark:$7,highWatermark:$7});return aMe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},jD=iMe(!0),$7=jD,aMe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=cMe({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*n_(a)}},cMe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[vx(t,r,!e),Ex(t,i,!n,{})].filter(Boolean);var F7=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=uMe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([dMe(t),d]);return}let f=yD(c,r),p=BD({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([fMe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},uMe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!xx({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=BD({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await ZQ(a,t,r,o)},dMe=async t=>{await lMe(),t.readableFlowing===null&&t.resume()},fMe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await dx(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await fx(r,{maxBuffer:o})):await Yd(r,{maxBuffer:o})}catch(a){return B7(ZX({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},zD=async t=>{try{return await t}catch(e){return B7(e)}},B7=({bufferedData:t})=>f9(t)?new Uint8Array(t):t;import{finished as pMe}from"stream/promises";var a_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=hMe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],pMe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||_Me(a,e,r,n)}finally{s.abort()}},hMe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&mMe(t,r,n),n},mMe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{gMe(e,r),n.call(t,...i)}},gMe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},_Me=(t,e,r,n)=>{if(!yMe(t,e,r,n))throw t},yMe=(t,e,r,n=!0)=>r.propagating?j7(t)||Nx(t):(r.propagating=!0,GD(r,e)===n?j7(t):Nx(t)),GD=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",Nx=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",j7=t=>t?.code==="EPIPE";var z7=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>VD({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),VD=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=a_(t,e,l);if(GD(l,e)){await u;return}let[d]=await Promise.all([F7({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 G7=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?wl([t,e].filter(Boolean)):void 0,V7=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>VD({...SMe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:EMe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),SMe=({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}},EMe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as vMe}from"events";var q7=t=>Bd(t,"ipc"),H7=(t,e)=>{let r=UT(t);ao({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var W7=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=q7(o),a=fs(e,"ipc"),c=fs(r,"ipc");for await(let l of RD({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(JX(t,i,c),i.push(l)),s&&H7(l,o);return i},Y7=async(t,e)=>(await Promise.allSettled([t]),e);var K7=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 b=t7(t,f),w={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},v=z7({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:w}),O=V7({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:w}),C=[],$=W7({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:C,verboseInfo:p}),N=bMe(m,t,w),M=TMe(h,w);try{return await Promise.race([Promise.all([{},n7(b),Promise.all(v),O,$,CX(t,d),...N,...M]),y,xMe(t,S),...xX(t,o,f,S),...qJ({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:S}),...bX({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(z){return f.terminationReason??="other",Promise.all([{error:z},b,Promise.all(v.map(_=>zD(_))),zD(O),Y7($,C),Promise.allSettled(N),Promise.allSettled(M)])}},bMe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:a_(n,i,r)),TMe=(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})=>a_(s,n,e,{isSameDirection:qn.has(i),stopOnExit:i==="native"}))),xMe=async(t,{signal:e})=>{let[r]=await vMe(t,"error",{signal:e});throw r};var Z7=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),c_=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=co();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 wMe}from"stream";import{callbackify as AMe}from"util";import{finished as J7}from"stream/promises";var qD=async t=>{if(t!==void 0)try{await HD(t)}catch{}},X7=async t=>{if(t!==void 0)try{await WD(t)}catch{}},HD=async t=>{await J7(t,{cleanup:!0,readable:!1,writable:!0})},WD=async t=>{await J7(t,{cleanup:!0,readable:!0,writable:!1})},kx=async(t,e)=>{if(await t,e)throw e},Mx=(t,e,r)=>{r&&!Nx(r)?t.destroy(r):e&&t.destroy()};var Q7=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||mn.has(r),{subprocessStdout:a,waitReadableDestroy:c}=YD(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=KD(a,s),{read:f,onStdoutDataDone:p}=ZD({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new wMe({read:f,destroy:AMe(XD.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return JD({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},YD=(t,e,r)=>{let n=qd(t,e),i=c_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},KD=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:jD},ZD=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=co(),s=Ox({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){RMe(this,s,o)},onStdoutDataDone:o}},RMe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},JD=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await WD(t),await n,await qD(i),await e,r.readable&&r.push(null)}catch(o){await qD(i),eee(r,o)}},XD=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Qd(r,e)&&(eee(t,n),await kx(e,n))},eee=(t,e)=>{Mx(t,t.readable,e)};import{Writable as IMe}from"stream";import{callbackify as tee}from"util";var ree=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=QD(t,r,e),s=new IMe({...eL(n,t,i),destroy:tee(rL.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return tL(n,s),s},QD=(t,e,r)=>{let n=KT(t,e),i=c_(r,n,"writableFinal"),o=c_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},eL=(t,e,r)=>({write:CMe.bind(void 0,t),final:tee(PMe.bind(void 0,t,e,r))}),CMe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},PMe=async(t,e,r)=>{await Qd(r,e)&&(t.writable&&t.end(),await e)},tL=async(t,e,r)=>{try{await HD(t),e.writable&&e.end()}catch(n){await X7(r),nee(e,n)}},rL=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Qd(r,e),await Qd(n,e)&&(nee(t,i),await kx(e,i))},nee=(t,e)=>{Mx(t,t.writable,e)};import{Duplex as OMe}from"stream";import{callbackify as NMe}from"util";var iee=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||mn.has(r),{subprocessStdout:c,waitReadableDestroy:l}=YD(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=QD(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=KD(c,a),{read:y,onStdoutDataDone:S}=ZD({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),b=new OMe({read:y,...eL(u,t,d),destroy:NMe(kMe.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 JD({subprocessStdout:c,onStdoutDataDone:S,readable:b,subprocess:t,subprocessStdin:u}),tL(u,b,c),b},kMe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([XD({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),rL({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var nL=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||mn.has(e),s=qd(t,r),a=Ox({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return MMe(a,s,t)},MMe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var oee=(t,{encoding:e})=>{let r=Z7();t.readable=Q7.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=ree.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=iee.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=nL.bind(void 0,t,e),t[Symbol.asyncIterator]=nL.bind(void 0,t,e,{})};var see=(t,e)=>{for(let[r,n]of LMe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},DMe=(async()=>{})().constructor.prototype,LMe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(DMe,t)]);var aee=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=FMe(t,e,r),{subprocess:f,promise:p}=jMe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=Px.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),see(f,p),lo.set(f,{options:u,fileDescriptors:d}),f},FMe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=BT(t,e,r),{file:a,commandArguments:c,options:l}=sx(t,e,r),u=BMe(l),d=y7(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},BMe=({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}},jMe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=UMe(...ax(t,e,r))}catch(h){return h7({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;$Me(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];R7(c,a,l),C7(c,r,l);let d={},f=co();c.kill=GJ.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=G7(c,r),oee(c,r),d7(c,r);let p=zMe({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}},zMe=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 K7({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,O)=>hs(v,e,O)),b=hs(m,e,"all"),w=GMe({errorInfo:d,exitCode:f,signal:p,stdio:S,all:b,ipcOutput:y,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Zd(w,n,e)},GMe=({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?r_({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 uo,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):mx({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var Dx=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,VMe(n,t[n],i)]));return{...t,...r}},VMe=(t,e,r)=>qMe.has(t)&&Pt(e)&&Pt(r)?{...e,...r}:r,qMe=new Set(["env",...kM]);var Oa=(t,e,r,n)=>{let i=(s,a,c)=>Oa(s,a,r,c),o=(...s)=>HMe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},HMe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Pt(o))return i(t,Dx(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=WMe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?o7(a,c,l):aee(a,c,l,i)},WMe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=y9(e)?S9(e,r):[e,...r],[s,a,c]=CT(...o),l=Dx(Dx(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 cee=({file:t,commandArguments:e})=>uee(t,e),lee=({file:t,commandArguments:e})=>({...uee(t,e),isSync:!0}),uee=(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]=YMe(t);return{file:r,commandArguments:n}},YMe=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(KMe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},KMe=/ +/g;var dee=(t,e,r)=>{t.sync=e(ZMe,r),t.s=t.sync},fee=({options:t})=>pee(t),ZMe=({options:t})=>({...pee(t),isSync:!0}),pee=t=>({options:{...JMe(t),...t}}),JMe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},hee={preferLocal:!0};var mee=Oa(()=>({})),cgt=Oa(()=>({isSync:!0})),gee=Oa(cee),lgt=Oa(lee),ugt=Oa(AX),dgt=Oa(fee,{},hee,dee),{sendMessage:fgt,getOneMessage:pgt,getEachMessage:hgt,getCancelSignal:mgt}=f7();var _ee=!1,yee=()=>{_ee=!0},po=()=>_ee;var l_=null,See=t=>(l_&&l_.destroy(),l_=new ms({totalAllowedTime:t}),l_),Eee=()=>l_;var ms=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&&po())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 TT({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{ye.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 vee={name:"@netlify/agent-runner-cli",type:"module",version:"1.142.1-test.8",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.0","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"2.1.197","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@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","opencode-ai":"1.17.19",zod:"^4.4.3"}};var tDe=QMe(import.meta.url),rDe=gs.dirname(tDe),nDe=eDe(import.meta.url),ef=Se("shell"),iL=new Set,bee={preferLocal:!0},gn=(t,e,r)=>{let[n,i]=iDe(e,r),o={...bee,...i},s=mee(t,n,o);xee(s,o),Ree(s);let a=r?.idleTimeout;return a&&a>0&&Aee(s,a),s},Tee=(t,e)=>{let r={...bee,...e},n=gee(t,r);return xee(n,r),Ree(n),e?.idleTimeout&&e.idleTimeout>0&&Aee(n,e.idleTimeout),n},iDe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},xee=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(_s.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Fg).pipe(_s.stdout),t.stderr?.pipe(new Fg).pipe(_s.stderr);return}t.stdout?.pipe(_s.stdout),t.stderr?.pipe(_s.stderr)},oL=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(_s.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}},wee=t=>oL(t,"SIGKILL"),Aee=(t,e)=>{let r=null,n=()=>{ef.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),oL(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(ef.log(`Force killing idle process ${t.pid}`),wee(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)},Ree=t=>{iL.add(t);let e=Eee();if(e){let r=e.onTimesUp(()=>{ef.log(`Global timer expired, killing process ${t.pid}`),oL(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(ef.log(`Force killing process ${t.pid} after timeout`),wee(t))},5e3)});t.on("exit",()=>{iL.delete(t),r()}),t.on("error",()=>{iL.delete(t),r()})}};function ho(t,e){if(!_s.env.NETLIFY_LOCAL_MODE)try{let i=nDe.resolve(vee.name),o=gs.dirname(i);for(;o!==gs.dirname(o);){let s=gs.dirname(o);if(gs.basename(s)==="node_modules"){let a=gs.join(s,".bin",e);if(Lx.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(_s.env.NODE_PATH){let i=gs.join(_s.env.NODE_PATH,".bin",e);if(Lx.existsSync(i))return i}let r=gs.join(t,"node_modules",".bin",e);if(Lx.existsSync(r))return r;let n=gs.join(rDe,"..","node_modules",".bin",e);if(Lx.existsSync(n))return n}var oDe=Se("utils"),sDe=t=>new Promise(e=>{setTimeout(e,t)});var $x=(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 sDe(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},Iee=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):oDe.error("Could not parse JSON",n))}},aDe=t=>t.charAt(0).toUpperCase()+t.slice(1),mo=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():aDe(e)).join(" ");function ys(t,e){e&&t.log(`Skill invoked: ${e}`)}var Ux=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),Cee=(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 sL=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}},cDe=1e4,aL=(t,e=cDe)=>{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 Pee}from"buffer";import lDe from"path";var Oee=Se("repo"),Hr=(t,e={})=>gn("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),Fx=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{Oee.info("Getting runner diffs");let n=await dDe(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let m=pDe(o);await hDe(m,r)}Oee.info("Changes after processing"),await lL(r);let s=await dL(o,r);if(await cL(s,r),i=await fDe(r),!i)return{hasChanges:!1,ignored:s};await Hr(["commit","-m","Agent runner"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await Hr(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(i=!!l,!i)return await Nee(r),{hasChanges:!1,ignored:s};let u=await Hr(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,p;if(t.sha){let m=await Hr(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let y=await Hr(["diff",t.sha,"HEAD","--binary"],a),S=String(y.stdout??"");f!==S&&(p=Pee.from(S).toString("base64"))}await Nee(r);let h={hasChanges:!0,diff:l,resultDiff:f,ignored:s};return l!==d&&(h.diffBinary=Pee.from(d).toString("base64")),p&&(h.resultDiffBinary=p),h},Nee=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Hr(["reset","--soft","HEAD~1"],{cwd:t})},cL=async(t=[],e=process.cwd())=>{await Hr(["add",".",...t],{cwd:e})},lL=async(t=process.cwd())=>{let e=await Hr(["status","-s"],{cwd:t});return String(e.stdout??"")},kee=/.. (.+)?\.log$/,uDe=[kee],dDe=async(t=process.cwd())=>{let e=await lL(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
101
|
+
if (condition) { yield value; }`)};import{Buffer as gNe}from"buffer";import{StringDecoder as _Ne}from"string_decoder";var vx=(t,e,r)=>{if(r)return;if(t)return{transform:yNe.bind(void 0,new TextEncoder)};let n=new _Ne(e);return{transform:SNe.bind(void 0,n),final:ENe.bind(void 0,n)}},yNe=function*(t,e){gNe.isBuffer(e)?yield ds(e):typeof e=="string"?yield t.encode(e):yield e},SNe=function*(t,e){yield Bt(e)?t.write(e):e},ENe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as GQ}from"util";var vD=GQ(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),bx=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=bNe}=e[r];for await(let i of n(t))yield*bx(i,e,r+1)},VQ=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*vNe(r,Number(e),t)},vNe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*bx(n,r,e+1)},qQ=GQ(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),bNe=function*(t){yield t};var bD=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},HQ=(t,e)=>[...e.flatMap(r=>[...xl(r,t,0)]),...n_(t)],xl=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=xNe}=e[r];for(let i of n(t))yield*xl(i,e,r+1)},n_=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*TNe(r,Number(e),t)},TNe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*xl(n,r,e+1)},xNe=function*(t){yield t};var TD=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=YQ(t,s,o),l=Tl(e),u=Tl(r),d=l?vD.bind(void 0,bx,a):bD.bind(void 0,xl),f=l||u?vD.bind(void 0,VQ,a):bD.bind(void 0,n_),p=l||u?qQ.bind(void 0,a):void 0;return{stream:new wNe({writableObjectMode:n,writableHighWaterMark:WQ(n),readableObjectMode:i,readableHighWaterMark:WQ(i),transform(m,y,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:p})}},Tx=(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=YQ(s,r,a);t=HQ(c,t)}return t},YQ=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:BQ(n,a)},vx(r,s,n),Ex(r,o,n,c),{transform:t,final:e},{transform:jQ(i,a)},FQ({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var KQ=(t,e)=>{for(let r of ANe(t))RNe(t,r,e)},ANe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),RNe=(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=>INe(a,n));r.input=Wg(s)},INe=(t,e)=>{let r=Tx(t,e,"utf8",!0);return CNe(r),Wg(r)},CNe=t=>{let e=t.find(r=>typeof r!="string"&&!Bt(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 kNe,appendFileSync as MNe}from"fs";var xx=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Bd(r,n)&&!mn.has(e)&&PNe(n)&&(t.some(({type:i,value:o})=>i==="native"&&ONe.has(o))||t.every(({type:i})=>qn.has(i))),PNe=t=>t===1||t===2,ONe=new Set(["pipe","overlapped"]),ZQ=async(t,e,r,n)=>{for await(let i of t)NNe(e)||XQ(i,r,n)},JQ=(t,e,r)=>{for(let n of t)XQ(n,e,r)},NNe=t=>t._readableState.pipes.length>0,XQ=(t,e,r)=>{let n=UT(t);ao({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var QQ=({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)=>DNe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},DNe=({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=eQ(t,o,d),p=ds(f),{stdioItems:h,objectMode:m}=e[r],y=LNe([p],h,c,n),{serializedResult:S,finalResult:b=S}=$Ne({chunks:y,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});UNe({serializedResult:S,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let w=a[r]?b:void 0;try{return n.error===void 0&&FNe(S,h,i),w}catch(v){return n.error=v,w}},LNe=(t,e,r,n)=>{try{return Tx(t,e,r,!1)}catch(i){return n.error=i,t}},$Ne=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Wg(t)};let s=h9(t,r);return n[o]?{serializedResult:s,finalResult:ED(s,!i[o],e)}:{serializedResult:s}},UNe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!xx({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=ED(t,!1,s);try{JQ(a,e,n)}catch(c){r.error??=c}},FNe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>yx.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?MNe(n,t):(r.add(o),kNe(n,t))}};var e7=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,hs(e,r,"all")]:Array.isArray(e)?[hs(t,r,"all"),...e]:Bt(t)&&Bt(e)?CM([t,e]):`${t}${e}`};import{once as xD}from"events";var t7=async(t,e)=>{let[r,n]=await BNe(t);return e.isForcefullyTerminated??=!1,[r,n]},BNe=async t=>{let[e,r]=await Promise.allSettled([xD(t,"spawn"),xD(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?r7(t):r.value},r7=async t=>{try{return await xD(t,"exit")}catch{return r7(t)}},n7=async t=>{let[e,r]=await t;if(!jNe(e,r)&&wD(e,r))throw new Ti;return[e,r]},jNe=(t,e)=>t===void 0&&e===void 0,wD=(t,e)=>t!==0||e!==null;var i7=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=zNe(t,e,r),s=o?.code==="ETIMEDOUT",a=QX(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},zNe=(t,e,r)=>t!==void 0?t:wD(e,r)?new Ti:void 0;var o7=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=VNe(t,e,r),d=WNe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Zd(d,c,l)},VNe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=BT(t,e,r),a=qNe(r),{file:c,commandArguments:l,options:u}=sx(t,e,a);HNe(u);let d=DQ(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},qNe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,HNe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&wx("ipcInput"),t&&wx("ipc: true"),r&&wx("detached: true"),n&&wx("cancelSignal")},wx=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},WNe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=YNe({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}=i7(c,r),{output:h,error:m=l}=QQ({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),y=h.map((b,w)=>hs(b,r,w)),S=hs(e7(h,r),r,"all");return ZNe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:y,all:S,options:r,command:n,escapedCommand:i,startTime:a})},YNe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{KQ(o,r);let a=KNe(r);return GNe(...ax(t,e,a))}catch(a){return Kd({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},KNe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:hx(e)}),ZNe=({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?mx({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):r_({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 $Me}from"events";import{spawn as UMe}from"child_process";import u7 from"process";import{once as AD,on as JNe}from"events";var s7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Gd({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:ex(t)}),XNe({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),XNe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{ZT(e,i);let o=Ca(t,e,r),s=new AbortController;try{return await Promise.race([QNe(o,n,s),eke(o,r,s),tke(o,r,s)])}catch(a){throw Vd(t),a}finally{s.abort(),JT(e,i)}},QNe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await AD(t,"message",{signal:r});return n}for await(let[n]of JNe(t,"message",{signal:r}))if(e(n))return n},eke=async(t,e,{signal:r})=>{await AD(t,"disconnect",{signal:r}),HJ(e)},tke=async(t,e,{signal:r})=>{let[n]=await AD(t,"strict:error",{signal:r});throw WT(n,e)};import{once as c7,on as rke}from"events";var l7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>RD({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),RD=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Gd({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:ex(t)}),ZT(e,o);let s=Ca(t,e,r),a=new AbortController,c={};return nke(t,s,a),ike({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),oke({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},nke=async(t,e,r)=>{try{await c7(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},ike=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await c7(t,"strict:error",{signal:r.signal});n.error=WT(i,e),r.abort()}catch{}},oke=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of rke(r,"message",{signal:o.signal}))a7(s),yield c}catch{a7(s)}finally{o.abort(),JT(e,a),n||Vd(t),i&&await t}},a7=({error:t})=>{if(t)throw t};var d7=(t,{ipc:e})=>{Object.assign(t,p7(t,!1,e))},f7=()=>{let t=u7,e=!0,r=u7.channel!==void 0;return{...p7(t,e,r),getCancelSignal:SX.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},p7=(t,e,r)=>({sendMessage:ix.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:s7.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:l7.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as ske}from"child_process";import{PassThrough as ake,Readable as cke,Writable as lke,Duplex as uke}from"stream";var h7=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{_D(n);let a=new ske;dke(a,n),Object.assign(a,{readable:fke,writable:pke,duplex:hke});let c=Kd({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=mke(c,s,i);return{subprocess:a,promise:l}},dke=(t,e)=>{let r=i_(),n=i_(),i=i_(),o=Array.from({length:e.length-3},i_),s=i_(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},i_=()=>{let t=new ake;return t.end(),t},fke=()=>new cke({read(){}}),pke=()=>new lke({write(){}}),hke=()=>new uke({read(){},write(){}}),mke=async(t,e,r)=>Zd(t,e,r);import{createReadStream as m7,createWriteStream as g7}from"fs";import{Buffer as gke}from"buffer";import{Readable as o_,Writable as _ke,Duplex as yke}from"stream";var y7=(t,e)=>Sx(Ske,t,e,!1),s_=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Pa[t]}.`)},_7={fileNumber:s_,generator:TD,asyncGenerator:TD,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(){}},Ske={input:{..._7,fileUrl:({value:t})=>({stream:m7(t)}),filePath:({value:{file:t}})=>({stream:m7(t)}),webStream:({value:t})=>({stream:o_.fromWeb(t)}),iterable:({value:t})=>({stream:o_.from(t)}),asyncIterable:({value:t})=>({stream:o_.from(t)}),string:({value:t})=>({stream:o_.from(t)}),uint8Array:({value:t})=>({stream:o_.from(gke.from(t))})},output:{..._7,fileUrl:({value:t})=>({stream:g7(t)}),filePath:({value:{file:t,append:e}})=>({stream:g7(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:_ke.fromWeb(t)}),iterable:s_,asyncIterable:s_,string:s_,uint8Array:s_}};import{on as Eke,once as S7}from"events";import{PassThrough as vke,getDefaultHighWaterMark as bke}from"stream";import{finished as b7}from"stream/promises";function wl(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)CD(i);let e=t.some(({readableObjectMode:i})=>i),r=Tke(t,e),n=new ID({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Tke=(t,e)=>{if(t.length===0)return bke(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},ID=class extends vke{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(CD(e),this.#e.has(e))return;this.#e.add(e),this.#n??=xke(this,this.#e,this.#o);let r=Rke({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(CD(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)}},xke=async(t,e,r)=>{Ax(t,E7);let n=new AbortController;try{await Promise.race([wke(t,n),Ake(t,e,r,n)])}finally{n.abort(),Ax(t,-E7)}},wke=async(t,{signal:e})=>{try{await b7(t,{signal:e,cleanup:!0})}catch(r){throw T7(t,r),r}},Ake=async(t,e,r,{signal:n})=>{for await(let[i]of Eke(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},CD=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Rke=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{Ax(t,v7);let a=new AbortController;try{await Promise.race([Ike(o,e,a),Cke({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),Pke({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),Ax(t,-v7)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?PD(t):Oke(t))},Ike=async(t,e,{signal:r})=>{try{await t,r.aborted||PD(e)}catch(n){r.aborted||T7(e,n)}},Cke=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;x7(s)?i.add(e):w7(t,s)}},Pke=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await S7(t,i,{signal:o}),!t.readable)return S7(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},Oke=t=>{t.writable&&t.end()},T7=(t,e)=>{x7(e)?PD(t):w7(t,e)},x7=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",PD=t=>{(t.readable||t.writable)&&t.destroy()},w7=(t,e)=>{t.destroyed||(t.once("error",Nke),t.destroy(e))},Nke=()=>{},Ax=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},E7=2,v7=1;import{finished as A7}from"stream/promises";var Xd=(t,e)=>{t.pipe(e),kke(t,e),Mke(t,e)},kke=async(t,e)=>{if(!(bi(t)||bi(e))){try{await A7(t,{cleanup:!0,readable:!0,writable:!1})}catch{}OD(e)}},OD=t=>{t.writable&&t.end()},Mke=async(t,e)=>{if(!(bi(t)||bi(e))){try{await A7(e,{cleanup:!0,readable:!1,writable:!0})}catch{}ND(t)}},ND=t=>{t.readable&&t.destroy()};var R7=(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})=>qn.has(c)))Dke(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!qn.has(c)))$ke({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)}},Dke=(t,e,r,n)=>{r==="output"?Xd(t.stdio[n],e):Xd(e,t.stdio[n]);let i=Lke[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},Lke=["stdin","stdout","stderr"],$ke=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;Uke(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},Uke=(t,{signal:e})=>{bi(t)&&vl(t,Fke,e)},Fke=2;import{addAbortListener as zke}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 Rx=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",kD=Symbol.for("signal-exit emitter"),MD=globalThis,Bke=Object.defineProperty.bind(Object),DD=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(MD[kD])return MD[kD];Bke(MD,kD,{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}},Ix=class{},jke=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),LD=class extends Ix{onExit(){return()=>{}}load(){}unload(){}},$D=class extends Ix{#e=UD.platform==="win32"?"SIGINT":"SIGHUP";#r=new DD;#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(!Rx(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 Rx(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"&&Rx(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)}},UD=globalThis.process,{onExit:I7,load:ypt,unload:Spt}=jke(Rx(UD)?new $D(UD):new LD);var C7=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=I7(()=>{t.kill()});zke(n,()=>{i()})};var O7=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=FT(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=Gke(r,n,i),{sourceStream:d,sourceError:f}=qke(t,l),{options:p,fileDescriptors:h}=lo.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},Gke=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=Vke(t,e,...r),a=KT(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},Vke=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(P7,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||RM(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]=CT(r,...n);return{destination:e(P7)(i,o,s),pipeOptions:s}}if(lo.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}`)},P7=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),qke=(t,e)=>{try{return{sourceStream:qd(t,e)}}catch(r){return{sourceError:r}}};var k7=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=Hke({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw FD({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},Hke=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return ND(t),n;if(e!==void 0)return OD(r),e},FD=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Kd({error:t,command:N7,escapedCommand:N7,fileDescriptors:e,options:r,startTime:n,isSync:!1}),N7="source.pipe(destination)";var M7=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 Wke}from"stream/promises";var D7=(t,e,r)=>{let n=Cx.has(e)?Kke(t,e):Yke(t,e);return vl(t,Jke,r.signal),vl(e,Xke,r.signal),Zke(e),n},Yke=(t,e)=>{let r=wl([t]);return Xd(r,e),Cx.set(e,r),r},Kke=(t,e)=>{let r=Cx.get(e);return r.add(t),r},Zke=async t=>{try{await Wke(t,{cleanup:!0,readable:!1,writable:!0})}catch{}Cx.delete(t)},Cx=new WeakMap,Jke=2,Xke=1;import{aborted as Qke}from"util";var L7=(t,e)=>t===void 0?[]:[eMe(t,e)],eMe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await Qke(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw FD({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var Px=(t,...e)=>{if(Pt(e[0]))return Px.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=O7(t,...e),i=tMe({...n,destination:r});return i.pipe=Px.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},tMe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=rMe(t,i);k7({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=D7(e,o,d);return await Promise.race([M7(u),...L7(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},rMe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as lMe}from"timers/promises";import{on as nMe}from"events";import{getDefaultHighWaterMark as iMe}from"stream";var Ox=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return oMe(e,s),U7({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},oMe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},BD=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;sMe(e,s,t);let a=t.readableObjectMode&&!o;return U7({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},sMe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},U7=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=nMe(t,"data",{signal:e.signal,highWaterMark:$7,highWatermark:$7});return aMe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},jD=iMe(!0),$7=jD,aMe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=cMe({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*n_(a)}},cMe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[vx(t,r,!e),Ex(t,i,!n,{})].filter(Boolean);var F7=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=uMe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([dMe(t),d]);return}let f=yD(c,r),p=BD({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([fMe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},uMe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!xx({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=BD({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await ZQ(a,t,r,o)},dMe=async t=>{await lMe(),t.readableFlowing===null&&t.resume()},fMe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await dx(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await fx(r,{maxBuffer:o})):await Yd(r,{maxBuffer:o})}catch(a){return B7(ZX({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},zD=async t=>{try{return await t}catch(e){return B7(e)}},B7=({bufferedData:t})=>f9(t)?new Uint8Array(t):t;import{finished as pMe}from"stream/promises";var a_=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=hMe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],pMe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||_Me(a,e,r,n)}finally{s.abort()}},hMe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&mMe(t,r,n),n},mMe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{gMe(e,r),n.call(t,...i)}},gMe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},_Me=(t,e,r,n)=>{if(!yMe(t,e,r,n))throw t},yMe=(t,e,r,n=!0)=>r.propagating?j7(t)||Nx(t):(r.propagating=!0,GD(r,e)===n?j7(t):Nx(t)),GD=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",Nx=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",j7=t=>t?.code==="EPIPE";var z7=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>VD({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),VD=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=a_(t,e,l);if(GD(l,e)){await u;return}let[d]=await Promise.all([F7({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 G7=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?wl([t,e].filter(Boolean)):void 0,V7=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>VD({...SMe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:EMe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),SMe=({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}},EMe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as vMe}from"events";var q7=t=>Bd(t,"ipc"),H7=(t,e)=>{let r=UT(t);ao({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var W7=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=q7(o),a=fs(e,"ipc"),c=fs(r,"ipc");for await(let l of RD({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(JX(t,i,c),i.push(l)),s&&H7(l,o);return i},Y7=async(t,e)=>(await Promise.allSettled([t]),e);var K7=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 b=t7(t,f),w={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:b,propagating:!1},v=z7({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:w}),O=V7({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:w}),C=[],$=W7({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:C,verboseInfo:p}),N=bMe(m,t,w),M=TMe(h,w);try{return await Promise.race([Promise.all([{},n7(b),Promise.all(v),O,$,CX(t,d),...N,...M]),y,xMe(t,S),...xX(t,o,f,S),...qJ({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:S}),...bX({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(z){return f.terminationReason??="other",Promise.all([{error:z},b,Promise.all(v.map(_=>zD(_))),zD(O),Y7($,C),Promise.allSettled(N),Promise.allSettled(M)])}},bMe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:a_(n,i,r)),TMe=(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})=>a_(s,n,e,{isSameDirection:qn.has(i),stopOnExit:i==="native"}))),xMe=async(t,{signal:e})=>{let[r]=await vMe(t,"error",{signal:e});throw r};var Z7=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),c_=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=co();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 wMe}from"stream";import{callbackify as AMe}from"util";import{finished as J7}from"stream/promises";var qD=async t=>{if(t!==void 0)try{await HD(t)}catch{}},X7=async t=>{if(t!==void 0)try{await WD(t)}catch{}},HD=async t=>{await J7(t,{cleanup:!0,readable:!1,writable:!0})},WD=async t=>{await J7(t,{cleanup:!0,readable:!0,writable:!1})},kx=async(t,e)=>{if(await t,e)throw e},Mx=(t,e,r)=>{r&&!Nx(r)?t.destroy(r):e&&t.destroy()};var Q7=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||mn.has(r),{subprocessStdout:a,waitReadableDestroy:c}=YD(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=KD(a,s),{read:f,onStdoutDataDone:p}=ZD({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new wMe({read:f,destroy:AMe(XD.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return JD({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},YD=(t,e,r)=>{let n=qd(t,e),i=c_(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},KD=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:jD},ZD=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=co(),s=Ox({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){RMe(this,s,o)},onStdoutDataDone:o}},RMe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},JD=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await WD(t),await n,await qD(i),await e,r.readable&&r.push(null)}catch(o){await qD(i),eee(r,o)}},XD=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Qd(r,e)&&(eee(t,n),await kx(e,n))},eee=(t,e)=>{Mx(t,t.readable,e)};import{Writable as IMe}from"stream";import{callbackify as tee}from"util";var ree=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=QD(t,r,e),s=new IMe({...eL(n,t,i),destroy:tee(rL.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return tL(n,s),s},QD=(t,e,r)=>{let n=KT(t,e),i=c_(r,n,"writableFinal"),o=c_(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},eL=(t,e,r)=>({write:CMe.bind(void 0,t),final:tee(PMe.bind(void 0,t,e,r))}),CMe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},PMe=async(t,e,r)=>{await Qd(r,e)&&(t.writable&&t.end(),await e)},tL=async(t,e,r)=>{try{await HD(t),e.writable&&e.end()}catch(n){await X7(r),nee(e,n)}},rL=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Qd(r,e),await Qd(n,e)&&(nee(t,i),await kx(e,i))},nee=(t,e)=>{Mx(t,t.writable,e)};import{Duplex as OMe}from"stream";import{callbackify as NMe}from"util";var iee=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||mn.has(r),{subprocessStdout:c,waitReadableDestroy:l}=YD(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=QD(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=KD(c,a),{read:y,onStdoutDataDone:S}=ZD({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),b=new OMe({read:y,...eL(u,t,d),destroy:NMe(kMe.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 JD({subprocessStdout:c,onStdoutDataDone:S,readable:b,subprocess:t,subprocessStdin:u}),tL(u,b,c),b},kMe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([XD({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),rL({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var nL=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||mn.has(e),s=qd(t,r),a=Ox({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return MMe(a,s,t)},MMe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var oee=(t,{encoding:e})=>{let r=Z7();t.readable=Q7.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=ree.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=iee.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=nL.bind(void 0,t,e),t[Symbol.asyncIterator]=nL.bind(void 0,t,e,{})};var see=(t,e)=>{for(let[r,n]of LMe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},DMe=(async()=>{})().constructor.prototype,LMe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(DMe,t)]);var aee=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=FMe(t,e,r),{subprocess:f,promise:p}=jMe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=Px.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),see(f,p),lo.set(f,{options:u,fileDescriptors:d}),f},FMe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=BT(t,e,r),{file:a,commandArguments:c,options:l}=sx(t,e,r),u=BMe(l),d=y7(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},BMe=({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}},jMe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=UMe(...ax(t,e,r))}catch(h){return h7({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;$Me(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];R7(c,a,l),C7(c,r,l);let d={},f=co();c.kill=GJ.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=G7(c,r),oee(c,r),d7(c,r);let p=zMe({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}},zMe=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 K7({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,O)=>hs(v,e,O)),b=hs(m,e,"all"),w=GMe({errorInfo:d,exitCode:f,signal:p,stdio:S,all:b,ipcOutput:y,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Zd(w,n,e)},GMe=({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?r_({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 uo,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):mx({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var Dx=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,VMe(n,t[n],i)]));return{...t,...r}},VMe=(t,e,r)=>qMe.has(t)&&Pt(e)&&Pt(r)?{...e,...r}:r,qMe=new Set(["env",...kM]);var Oa=(t,e,r,n)=>{let i=(s,a,c)=>Oa(s,a,r,c),o=(...s)=>HMe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},HMe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Pt(o))return i(t,Dx(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=WMe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?o7(a,c,l):aee(a,c,l,i)},WMe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=y9(e)?S9(e,r):[e,...r],[s,a,c]=CT(...o),l=Dx(Dx(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 cee=({file:t,commandArguments:e})=>uee(t,e),lee=({file:t,commandArguments:e})=>({...uee(t,e),isSync:!0}),uee=(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]=YMe(t);return{file:r,commandArguments:n}},YMe=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(KMe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},KMe=/ +/g;var dee=(t,e,r)=>{t.sync=e(ZMe,r),t.s=t.sync},fee=({options:t})=>pee(t),ZMe=({options:t})=>({...pee(t),isSync:!0}),pee=t=>({options:{...JMe(t),...t}}),JMe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},hee={preferLocal:!0};var mee=Oa(()=>({})),cgt=Oa(()=>({isSync:!0})),gee=Oa(cee),lgt=Oa(lee),ugt=Oa(AX),dgt=Oa(fee,{},hee,dee),{sendMessage:fgt,getOneMessage:pgt,getEachMessage:hgt,getCancelSignal:mgt}=f7();var _ee=!1,yee=()=>{_ee=!0},po=()=>_ee;var l_=null,See=t=>(l_&&l_.destroy(),l_=new ms({totalAllowedTime:t}),l_),Eee=()=>l_;var ms=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&&po())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 TT({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{ye.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 vee={name:"@netlify/agent-runner-cli",type:"module",version:"1.142.1-test.9",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@netlify/axis":"^1.17.0","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"2.1.197","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@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","opencode-ai":"1.17.19",zod:"^4.4.3"}};var tDe=QMe(import.meta.url),rDe=gs.dirname(tDe),nDe=eDe(import.meta.url),ef=Se("shell"),iL=new Set,bee={preferLocal:!0},gn=(t,e,r)=>{let[n,i]=iDe(e,r),o={...bee,...i},s=mee(t,n,o);xee(s,o),Ree(s);let a=r?.idleTimeout;return a&&a>0&&Aee(s,a),s},Tee=(t,e)=>{let r={...bee,...e},n=gee(t,r);return xee(n,r),Ree(n),e?.idleTimeout&&e.idleTimeout>0&&Aee(n,e.idleTimeout),n},iDe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},xee=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(_s.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Fg).pipe(_s.stdout),t.stderr?.pipe(new Fg).pipe(_s.stderr);return}t.stdout?.pipe(_s.stdout),t.stderr?.pipe(_s.stderr)},oL=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(_s.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}},wee=t=>oL(t,"SIGKILL"),Aee=(t,e)=>{let r=null,n=()=>{ef.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),oL(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(ef.log(`Force killing idle process ${t.pid}`),wee(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)},Ree=t=>{iL.add(t);let e=Eee();if(e){let r=e.onTimesUp(()=>{ef.log(`Global timer expired, killing process ${t.pid}`),oL(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(ef.log(`Force killing process ${t.pid} after timeout`),wee(t))},5e3)});t.on("exit",()=>{iL.delete(t),r()}),t.on("error",()=>{iL.delete(t),r()})}};function ho(t,e){if(!_s.env.NETLIFY_LOCAL_MODE)try{let i=nDe.resolve(vee.name),o=gs.dirname(i);for(;o!==gs.dirname(o);){let s=gs.dirname(o);if(gs.basename(s)==="node_modules"){let a=gs.join(s,".bin",e);if(Lx.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(_s.env.NODE_PATH){let i=gs.join(_s.env.NODE_PATH,".bin",e);if(Lx.existsSync(i))return i}let r=gs.join(t,"node_modules",".bin",e);if(Lx.existsSync(r))return r;let n=gs.join(rDe,"..","node_modules",".bin",e);if(Lx.existsSync(n))return n}var oDe=Se("utils"),sDe=t=>new Promise(e=>{setTimeout(e,t)});var $x=(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 sDe(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},Iee=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):oDe.error("Could not parse JSON",n))}},aDe=t=>t.charAt(0).toUpperCase()+t.slice(1),mo=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():aDe(e)).join(" ");function ys(t,e){e&&t.log(`Skill invoked: ${e}`)}var Ux=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),Cee=(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 sL=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}},cDe=1e4,aL=(t,e=cDe)=>{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 Pee}from"buffer";import lDe from"path";var Oee=Se("repo"),Hr=(t,e={})=>gn("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),Fx=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{Oee.info("Getting runner diffs");let n=await dDe(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let m=pDe(o);await hDe(m,r)}Oee.info("Changes after processing"),await lL(r);let s=await dL(o,r);if(await cL(s,r),i=await fDe(r),!i)return{hasChanges:!1,ignored:s};await Hr(["commit","-m","Agent runner"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await Hr(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(i=!!l,!i)return await Nee(r),{hasChanges:!1,ignored:s};let u=await Hr(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,p;if(t.sha){let m=await Hr(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let y=await Hr(["diff",t.sha,"HEAD","--binary"],a),S=String(y.stdout??"");f!==S&&(p=Pee.from(S).toString("base64"))}await Nee(r);let h={hasChanges:!0,diff:l,resultDiff:f,ignored:s};return l!==d&&(h.diffBinary=Pee.from(d).toString("base64")),p&&(h.resultDiffBinary=p),h},Nee=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Hr(["reset","--soft","HEAD~1"],{cwd:t})},cL=async(t=[],e=process.cwd())=>{await Hr(["add",".",...t],{cwd:e})},lL=async(t=process.cwd())=>{let e=await Hr(["status","-s"],{cwd:t});return String(e.stdout??"")},kee=/.. (.+)?\.log$/,uDe=[kee],dDe=async(t=process.cwd())=>{let e=await lL(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
102
102
|
`).filter(i=>uDe.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}},fDe=async(t=process.cwd())=>{try{return await Hr(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},uL=async(t=process.cwd())=>{let{stdout:e}=await Hr(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},Mee=async(t=process.cwd())=>{let{stdout:e}=await Hr(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},dL=async(t,e=process.cwd())=>{t||=await lL(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}${lDe.sep}`);(a||c)&&n.push(`:!${s}`)});let o=i.match(kee)?.[1];o&&n.push(`:!${o}.log`)}),n},fL=async(t=process.cwd())=>{await Hr(["reset","--hard","HEAD"],{cwd:t})},Dee=async(t=process.cwd())=>{let e=await Hr(["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))},pDe=t=>{let e=t.split(`
|
package/package.json
CHANGED