@netlify/agent-runner-cli 1.138.0-pty.1 → 1.138.0-pty.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -85,7 +85,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
85
85
  `,LF:`
86
86
  `,concatBytes:lI},pye=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},mye={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:pye};import{Buffer as gye}from"buffer";var y4=(t,e)=>t?void 0:_ye.bind(void 0,e),_ye=function*(t,e){if(typeof e!="string"&&!gt(e)&&!gye.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},T4=(t,e)=>t?Sye.bind(void 0,e):Eye.bind(void 0,e),Sye=function*(t,e){b4(t,e),yield e},Eye=function*(t,e){if(b4(t,e),typeof e!="string"&&!gt(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},b4=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
87
87
  Instead, \`yield\` should either be called with a value, or not be called at all. For example:
88
- if (condition) { yield value; }`)};import{Buffer as yye}from"buffer";import{StringDecoder as Tye}from"string_decoder";var zT=(t,e,r)=>{if(r)return;if(t)return{transform:bye.bind(void 0,new TextEncoder)};let n=new Tye(e);return{transform:Aye.bind(void 0,n),final:vye.bind(void 0,n)}},bye=function*(t,e){yye.isBuffer(e)?yield Si(e):typeof e=="string"?yield t.encode(e):yield e},Aye=function*(t,e){yield gt(e)?t.write(e):e},vye=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as A4}from"util";var dI=A4(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let s of e.currentIterable)n.push(s)}finally{delete e.currentIterable}}),YT=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Rye}=e[r];for await(let s of n(t))yield*YT(s,e,r+1)},v4=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*wye(r,Number(e),t)},wye=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*YT(n,r,e+1)},w4=A4(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),Rye=function*(t){yield t};var fI=(t,e,r,n)=>{try{for(let s of t(...e))r.push(s);n()}catch(s){n(s)}},R4=(t,e)=>[...e.flatMap(r=>[...hc(r,t,0)]),...cm(t)],hc=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=xye}=e[r];for(let s of n(t))yield*hc(s,e,r+1)},cm=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Cye(r,Number(e),t)},Cye=function*(t,e,r){if(t!==void 0)for(let n of t())yield*hc(n,r,e+1)},xye=function*(t){yield t};var hI=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:s},optionName:i},{encoding:o})=>{let a={},c=x4(t,o,i),l=fc(e),u=fc(r),d=l?dI.bind(void 0,YT,a):fI.bind(void 0,hc),f=l||u?dI.bind(void 0,v4,a):fI.bind(void 0,cm),h=l||u?w4.bind(void 0,a):void 0;return{stream:new Pye({writableObjectMode:n,writableHighWaterMark:C4(n),readableObjectMode:s,readableHighWaterMark:C4(s),transform(m,E,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:h})}},KT=(t,e,r,n)=>{let s=e.filter(({type:o})=>o==="generator"),i=n?s.reverse():s;for(let{value:o,optionName:a}of i){let c=x4(o,r,a);t=R4(c,t)}return t},x4=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:s,preserveNewlines:i},o,a)=>{let c={};return[{transform:y4(n,a)},zT(r,o,n),WT(r,i,n,c),{transform:t,final:e},{transform:T4(s,a)},E4({binary:r,preserveNewlines:i,readableObjectMode:s,state:c})].filter(Boolean)};var P4=(t,e)=>{for(let r of Oye(t))Iye(t,r,e)},Oye=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Iye=(t,e,r)=>{let{stdioItems:n}=t[e],s=n.filter(({contents:a})=>a!==void 0);if(s.length===0)return;if(e!==0){let[{type:a,optionName:c}]=s;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Oo[a]} with synchronous methods.`)}let o=s.map(({contents:a})=>a).map(a=>Nye(a,n));r.input=Jp(o)},Nye=(t,e)=>{let r=KT(t,e,"utf8",!0);return Mye(r),Jp(r)},Mye=t=>{let e=t.find(r=>typeof r!="string"&&!gt(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 Uye,appendFileSync as Fye}from"fs";var XT=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Au(r,n)&&!Dr.has(e)&&Lye(n)&&(t.some(({type:s,value:i})=>s==="native"&&Dye.has(i))||t.every(({type:s})=>dn.has(s))),Lye=t=>t===1||t===2,Dye=new Set(["pipe","overlapped"]),O4=async(t,e,r,n)=>{for await(let s of t)kye(e)||N4(s,r,n)},I4=(t,e,r)=>{for(let n of t)N4(n,e,r)},kye=t=>t._readableState.pipes.length>0,N4=(t,e,r)=>{let n=uT(t);vs({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var M4=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:s})=>{if(e===null)return{output:Array.from({length:3})};let i={},o=new Set([]);return{output:e.map((c,l)=>Bye({result:c,fileDescriptors:t,fdNumber:l,state:i,outputFiles:o,isMaxBuffer:n,verboseInfo:s},r)),...i}},Bye=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:s,isMaxBuffer:i,verboseInfo:o},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=LY(t,i,d),h=Si(f),{stdioItems:p,objectMode:m}=e[r],E=$ye([h],p,c,n),{serializedResult:S,finalResult:b=S}=Gye({chunks:E,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});qye({serializedResult:S,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:p,objectMode:m});let R=a[r]?b:void 0;try{return n.error===void 0&&Hye(S,p,s),R}catch(A){return n.error=A,R}},$ye=(t,e,r,n)=>{try{return KT(t,e,r,!1)}catch(s){return n.error=s,t}},Gye=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:s,fdNumber:i})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Jp(t)};let o=Y3(t,r);return n[i]?{serializedResult:o,finalResult:uI(o,!s[i],e)}:{serializedResult:o}},qye=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:s,stdioItems:i,objectMode:o})=>{if(!XT({stdioItems:i,encoding:s,verboseInfo:n,fdNumber:e}))return;let a=uI(t,!1,o);try{I4(a,e,n)}catch(c){r.error??=c}},Hye=(t,e,r)=>{for(let{path:n,append:s}of e.filter(({type:i})=>VT.has(i))){let i=typeof n=="string"?n:n.toString();s||r.has(i)?Fye(n,t):(r.add(i),Uye(n,t))}};var L4=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Ti(e,r,"all")]:Array.isArray(e)?[Ti(t,r,"all"),...e]:gt(t)&&gt(e)?EO([t,e]):`${t}${e}`};import{once as pI}from"events";var D4=async(t,e)=>{let[r,n]=await Vye(t);return e.isForcefullyTerminated??=!1,[r,n]},Vye=async t=>{let[e,r]=await Promise.allSettled([pI(t,"spawn"),pI(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?k4(t):r.value},k4=async t=>{try{return await pI(t,"exit")}catch{return k4(t)}},U4=async t=>{let[e,r]=await t;if(!jye(e,r)&&mI(e,r))throw new qn;return[e,r]},jye=(t,e)=>t===void 0&&e===void 0,mI=(t,e)=>t!==0||e!==null;var F4=({error:t,status:e,signal:r,output:n},{maxBuffer:s})=>{let i=Wye(t,e,r),o=i?.code==="ETIMEDOUT",a=MY(i,n,s);return{resultError:i,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},Wye=(t,e,r)=>t!==void 0?t:mI(e,r)?new qn:void 0;var B4=(t,e,r)=>{let{file:n,commandArguments:s,command:i,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=Yye(t,e,r),d=Qye({file:n,commandArguments:s,options:l,command:i,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Mu(d,c,l)},Yye=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=fT(t,e,r),a=Kye(r),{file:c,commandArguments:l,options:u}=NT(t,e,a);Xye(u);let d=m4(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:d}},Kye=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Xye=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&QT("ipcInput"),t&&QT("ipc: true"),r&&QT("detached: true"),n&&QT("cancelSignal")},QT=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Qye=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,verboseInfo:i,fileDescriptors:o,startTime:a})=>{let c=Jye({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:h}=F4(c,r),{output:p,error:m=l}=M4({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:h,verboseInfo:i}),E=p.map((b,R)=>Ti(b,r,R)),S=Ti(L4(p,r),r,"all");return eTe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:h,stdio:E,all:S,options:r,command:n,escapedCommand:s,startTime:a})},Jye=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,fileDescriptors:i,startTime:o})=>{try{P4(i,r);let a=Zye(r);return zye(...MT(t,e,a))}catch(a){return Nu({error:a,command:n,escapedCommand:s,fileDescriptors:i,options:r,startTime:o,isSync:!0})}},Zye=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:$T(e)}),eTe=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:s,stdio:i,all:o,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?GT({command:c,escapedCommand:l,stdio:i,all:o,ipcOutput:[],options:a,startTime:u}):am({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:s,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:i,all:o,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as Gbe}from"events";import{spawn as qbe}from"child_process";import V4 from"process";import{once as gI,on as tTe}from"events";var $4=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0,filter:i}={})=>(Ru({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:RT(t)}),rTe({anyProcess:t,channel:e,isSubprocess:r,filter:i,reference:s})),rTe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:s})=>{bT(e,s);let i=Po(t,e,r),o=new AbortController;try{return await Promise.race([nTe(i,n,o),sTe(i,r,o),iTe(i,r,o)])}catch(a){throw Cu(t),a}finally{o.abort(),AT(e,s)}},nTe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await gI(t,"message",{signal:r});return n}for await(let[n]of tTe(t,"message",{signal:r}))if(e(n))return n},sTe=async(t,e,{signal:r})=>{await gI(t,"disconnect",{signal:r}),Rz(e)},iTe=async(t,e,{signal:r})=>{let[n]=await gI(t,"strict:error",{signal:r});throw ET(n,e)};import{once as q4,on as oTe}from"events";var H4=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0}={})=>_I({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:s}),_I=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:s,reference:i})=>{Ru({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:RT(t)}),bT(e,i);let o=Po(t,e,r),a=new AbortController,c={};return aTe(t,o,a),cTe({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),lTe({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:s,controller:a,state:c,reference:i})},aTe=async(t,e,r)=>{try{await q4(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},cTe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[s]=await q4(t,"strict:error",{signal:r.signal});n.error=ET(s,e),r.abort()}catch{}},lTe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:s,controller:i,state:o,reference:a}){try{for await(let[c]of oTe(r,"message",{signal:i.signal}))G4(o),yield c}catch{G4(o)}finally{i.abort(),AT(e,a),n||Cu(t),s&&await t}},G4=({error:t})=>{if(t)throw t};var j4=(t,{ipc:e})=>{Object.assign(t,z4(t,!1,e))},W4=()=>{let t=V4,e=!0,r=V4.channel!==void 0;return{...z4(t,e,r),getCancelSignal:Zz.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},z4=(t,e,r)=>({sendMessage:OT.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:$4.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:H4.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as uTe}from"child_process";import{PassThrough as dTe,Readable as fTe,Writable as hTe,Duplex as pTe}from"stream";var Y4=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,verboseInfo:o})=>{aI(n);let a=new uTe;mTe(a,n),Object.assign(a,{readable:gTe,writable:_Te,duplex:STe});let c=Nu({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,isSync:!1}),l=ETe(c,o,s);return{subprocess:a,promise:l}},mTe=(t,e)=>{let r=lm(),n=lm(),s=lm(),i=Array.from({length:e.length-3},lm),o=lm(),a=[r,n,s,...i];Object.assign(t,{stdin:r,stdout:n,stderr:s,all:o,stdio:a})},lm=()=>{let t=new dTe;return t.end(),t},gTe=()=>new fTe({read(){}}),_Te=()=>new hTe({write(){}}),STe=()=>new pTe({read(){},write(){}}),ETe=async(t,e,r)=>Mu(t,e,r);import{createReadStream as K4,createWriteStream as X4}from"fs";import{Buffer as yTe}from"buffer";import{Readable as um,Writable as TTe,Duplex as bTe}from"stream";var J4=(t,e)=>jT(ATe,t,e,!1),dm=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Oo[t]}.`)},Q4={fileNumber:dm,generator:hI,asyncGenerator:hI,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:bTe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},ATe={input:{...Q4,fileUrl:({value:t})=>({stream:K4(t)}),filePath:({value:{file:t}})=>({stream:K4(t)}),webStream:({value:t})=>({stream:um.fromWeb(t)}),iterable:({value:t})=>({stream:um.from(t)}),asyncIterable:({value:t})=>({stream:um.from(t)}),string:({value:t})=>({stream:um.from(t)}),uint8Array:({value:t})=>({stream:um.from(yTe.from(t))})},output:{...Q4,fileUrl:({value:t})=>({stream:X4(t)}),filePath:({value:{file:t,append:e}})=>({stream:X4(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:TTe.fromWeb(t)}),iterable:dm,asyncIterable:dm,string:dm,uint8Array:dm}};import{on as vTe,once as Z4}from"events";import{PassThrough as wTe,getDefaultHighWaterMark as RTe}from"stream";import{finished as r6}from"stream/promises";function pc(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let s of t)EI(s);let e=t.some(({readableObjectMode:s})=>s),r=CTe(t,e),n=new SI({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let s of t)n.add(s);return n}var CTe=(t,e)=>{if(t.length===0)return RTe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},SI=class extends wTe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#i=Symbol("unpipe");#s=new WeakMap;add(e){if(EI(e),this.#e.has(e))return;this.#e.add(e),this.#n??=xTe(this,this.#e,this.#i);let r=ITe({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#i});this.#s.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(EI(e),!this.#e.has(e))return!1;let r=this.#s.get(e);return r===void 0?!1:(this.#s.delete(e),e.unpipe(this),await r,!0)}},xTe=async(t,e,r)=>{JT(t,e6);let n=new AbortController;try{await Promise.race([PTe(t,n),OTe(t,e,r,n)])}finally{n.abort(),JT(t,-e6)}},PTe=async(t,{signal:e})=>{try{await r6(t,{signal:e,cleanup:!0})}catch(r){throw n6(t,r),r}},OTe=async(t,e,r,{signal:n})=>{for await(let[s]of vTe(t,"unpipe",{signal:n}))e.has(s)&&s.emit(r)},EI=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},ITe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,onFinished:i,unpipeEvent:o})=>{JT(t,t6);let a=new AbortController;try{await Promise.race([NTe(i,e,a),MTe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:a}),LTe({stream:e,streams:r,ended:n,aborted:s,unpipeEvent:o,controller:a})])}finally{a.abort(),JT(t,-t6)}r.size>0&&r.size===n.size+s.size&&(n.size===0&&s.size>0?yI(t):DTe(t))},NTe=async(t,e,{signal:r})=>{try{await t,r.aborted||yI(e)}catch(n){r.aborted||n6(e,n)}},MTe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:{signal:i}})=>{try{await r6(e,{signal:i,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(i.aborted||!r.has(e))return;s6(o)?s.add(e):i6(t,o)}},LTe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:s,controller:{signal:i}})=>{if(await Z4(t,s,{signal:i}),!t.readable)return Z4(i,"abort",{signal:i});e.delete(t),r.delete(t),n.delete(t)},DTe=t=>{t.writable&&t.end()},n6=(t,e)=>{s6(e)?yI(t):i6(t,e)},s6=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",yI=t=>{(t.readable||t.writable)&&t.destroy()},i6=(t,e)=>{t.destroyed||(t.once("error",kTe),t.destroy(e))},kTe=()=>{},JT=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},e6=2,t6=1;import{finished as o6}from"stream/promises";var Du=(t,e)=>{t.pipe(e),UTe(t,e),FTe(t,e)},UTe=async(t,e)=>{if(!(Gn(t)||Gn(e))){try{await o6(t,{cleanup:!0,readable:!0,writable:!1})}catch{}TI(e)}},TI=t=>{t.writable&&t.end()},FTe=async(t,e)=>{if(!(Gn(t)||Gn(e))){try{await o6(e,{cleanup:!0,readable:!1,writable:!0})}catch{}bI(t)}},bI=t=>{t.readable&&t.destroy()};var a6=(t,e,r)=>{let n=new Map;for(let[s,{stdioItems:i,direction:o}]of Object.entries(e)){for(let{stream:a}of i.filter(({type:c})=>dn.has(c)))BTe(t,a,o,s);for(let{stream:a}of i.filter(({type:c})=>!dn.has(c)))GTe({subprocess:t,stream:a,direction:o,fdNumber:s,pipeGroups:n,controller:r})}for(let[s,i]of n.entries()){let o=i.length===1?i[0]:pc(i);Du(o,s)}},BTe=(t,e,r,n)=>{r==="output"?Du(t.stdio[n],e):Du(e,t.stdio[n]);let s=$Te[n];s!==void 0&&(t[s]=e),t.stdio[n]=e},$Te=["stdin","stdout","stderr"],GTe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:s,controller:i})=>{if(e===void 0)return;qTe(e,i);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=s.get(o)??[];s.set(o,[...c,a])},qTe=(t,{signal:e})=>{Gn(t)&&uc(t,HTe,e)},HTe=2;import{addAbortListener as WTe}from"events";var mc=[];mc.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&mc.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&mc.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var ZT=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",AI=Symbol.for("signal-exit emitter"),vI=globalThis,VTe=Object.defineProperty.bind(Object),wI=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(vI[AI])return vI[AI];VTe(vI,AI,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],s=n.indexOf(r);s!==-1&&(s===0&&n.length===1?n.length=0:n.splice(s,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let s=!1;for(let i of this.listeners[e])s=i(r,n)===!0||s;return e==="exit"&&(s=this.emit("afterExit",r,n)||s),s}},eb=class{},jTe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),RI=class extends eb{onExit(){return()=>{}}load(){}unload(){}},CI=class extends eb{#e=xI.platform==="win32"?"SIGINT":"SIGHUP";#r=new wI;#t;#n;#i;#s={};#o=!1;constructor(e){super(),this.#t=e,this.#s={};for(let r of mc)this.#s[r]=()=>{let n=this.#t.listeners(r),{count:s}=this.#r,i=e;if(typeof i.__signal_exit_emitter__=="object"&&typeof i.__signal_exit_emitter__.count=="number"&&(s+=i.__signal_exit_emitter__.count),n.length===s){this.unload();let o=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;o||e.kill(e.pid,a)}};this.#i=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!ZT(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 mc)try{let r=this.#s[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#o&&(this.#o=!1,mc.forEach(e=>{let r=this.#s[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#i,this.#r.count-=1)}#a(e){return ZT(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#i.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&ZT(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let s=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),s}else return n.call(this.#t,e,...r)}},xI=globalThis.process,{onExit:c6,load:oJe,unload:aJe}=jTe(ZT(xI)?new CI(xI):new RI);var l6=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let s=c6(()=>{t.kill()});WTe(n,()=>{s()})};var d6=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...s)=>{let i=dT(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=zTe(r,n,s),{sourceStream:d,sourceError:f}=KTe(t,l),{options:h,fileDescriptors:p}=Rs.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:h,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:p,startTime:i}},zTe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:s,to:i,unpipeSignal:o}={}}=YTe(t,e,...r),a=TT(n,i);return{destination:n,destinationStream:a,from:s,unpipeSignal:o}}catch(n){return{destinationError:n}}},YTe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(u6,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||_O(r)){if(Object.keys(t).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[s,i,o]=tT(r,...n);return{destination:e(u6)(s,i,o),pipeOptions:o}}if(Rs.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}`)},u6=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),KTe=(t,e)=>{try{return{sourceStream:xu(t,e)}}catch(r){return{sourceError:r}}};var h6=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:s,sourceOptions:i,startTime:o})=>{let a=XTe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw PI({error:a,fileDescriptors:s,sourceOptions:i,startTime:o})},XTe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return bI(t),n;if(e!==void 0)return TI(r),e},PI=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Nu({error:t,command:f6,escapedCommand:f6,fileDescriptors:e,options:r,startTime:n,isSync:!1}),f6="source.pipe(destination)";var p6=async t=>{let[{status:e,reason:r,value:n=r},{status:s,reason:i,value:o=i}]=await t;if(o.pipedFrom.includes(n)||o.pipedFrom.push(n),s==="rejected")throw o;if(e==="rejected")throw n;return o};import{finished as QTe}from"stream/promises";var m6=(t,e,r)=>{let n=tb.has(e)?ZTe(t,e):JTe(t,e);return uc(t,tbe,r.signal),uc(e,rbe,r.signal),ebe(e),n},JTe=(t,e)=>{let r=pc([t]);return Du(r,e),tb.set(e,r),r},ZTe=(t,e)=>{let r=tb.get(e);return r.add(t),r},ebe=async t=>{try{await QTe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}tb.delete(t)},tb=new WeakMap,tbe=2,rbe=1;import{aborted as nbe}from"util";var g6=(t,e)=>t===void 0?[]:[sbe(t,e)],sbe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:s,startTime:i})=>{await nbe(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw PI({error:o,fileDescriptors:n,sourceOptions:s,startTime:i})};var rb=(t,...e)=>{if(ot(e[0]))return rb.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=d6(t,...e),s=ibe({...n,destination:r});return s.pipe=rb.bind(void 0,{...t,source:r,sourcePromise:s,boundOptions:{}}),s},ibe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:s,destinationStream:i,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=obe(t,s);h6({sourceStream:e,sourceError:n,destinationStream:i,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=m6(e,i,d);return await Promise.race([p6(u),...g6(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},obe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as hbe}from"timers/promises";import{on as abe}from"events";import{getDefaultHighWaterMark as cbe}from"stream";var nb=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:s,preserveNewlines:i})=>{let o=new AbortController;return lbe(e,o),S6({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:s,shouldSplit:!t.readableObjectMode,preserveNewlines:i})},lbe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},OI=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:s,allMixed:i})=>{let o=new AbortController;ube(e,o,t);let a=t.readableObjectMode&&!i;return S6({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!s})},ube=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},S6=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})=>{let a=abe(t,"data",{signal:e.signal,highWaterMark:_6,highWatermark:_6});return dbe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})},II=cbe(!0),_6=II,dbe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o}){let a=fbe({binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o});try{for await(let[c]of t)yield*hc(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*cm(a)}},fbe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:s})=>[zT(t,r,!e),WT(t,s,!n,{})].filter(Boolean);var E6=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:s,maxBuffer:i,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=pbe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!s){await Promise.all([mbe(t),d]);return}let f=cI(c,r),h=OI({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[p]=await Promise.all([gbe({stream:t,iterable:h,fdNumber:r,encoding:n,maxBuffer:i,lines:o}),d]);return p},pbe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:s,verboseInfo:i,streamInfo:{fileDescriptors:o}})=>{if(!XT({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:i,fdNumber:r}))return;let a=OI({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:s});await O4(a,t,r,i)},mbe=async t=>{await hbe(),t.readableFlowing===null&&t.resume()},gbe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:s,maxBuffer:i,lines:o})=>{try{return e||o?await UT(r,{maxBuffer:i}):s==="buffer"?new Uint8Array(await FT(r,{maxBuffer:i})):await Iu(r,{maxBuffer:i})}catch(a){return y6(OY({error:a,stream:t,readableObjectMode:e,lines:o,encoding:s,fdNumber:n}))}},NI=async t=>{try{return await t}catch(e){return y6(e)}},y6=({bufferedData:t})=>W3(t)?new Uint8Array(t):t;import{finished as _be}from"stream/promises";var fm=async(t,e,r,{isSameDirection:n,stopOnExit:s=!1}={})=>{let i=Sbe(t,r),o=new AbortController;try{await Promise.race([...s?[r.exitPromise]:[],_be(t,{cleanup:!0,signal:o.signal})])}catch(a){i.stdinCleanedUp||Tbe(a,e,r,n)}finally{o.abort()}},Sbe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&Ebe(t,r,n),n},Ebe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...s)=>{ybe(e,r),n.call(t,...s)}},ybe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Tbe=(t,e,r,n)=>{if(!bbe(t,e,r,n))throw t},bbe=(t,e,r,n=!0)=>r.propagating?T6(t)||sb(t):(r.propagating=!0,MI(r,e)===n?T6(t):sb(t)),MI=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",sb=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",T6=t=>t?.code==="EPIPE";var b6=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>LI({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:s[l],allMixed:!1,stripFinalNewline:i,verboseInfo:o,streamInfo:a})),LI=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:s,lines:i,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=fm(t,e,l);if(MI(l,e)){await u;return}let[d]=await Promise.all([E6({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:s,lines:i,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var A6=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?pc([t,e].filter(Boolean)):void 0,v6=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>LI({...Abe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:s[1]||s[2],allMixed:vbe(t),stripFinalNewline:i,verboseInfo:o,streamInfo:a}),Abe=({stdout:t,stderr:e,all:r},[,n,s])=>{let i=n||s;return i?n?s?{stream:r,buffer:i}:{stream:t,buffer:i}:{stream:e,buffer:i}:{stream:r,buffer:i}},vbe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as wbe}from"events";var w6=t=>Au(t,"ipc"),R6=(t,e)=>{let r=uT(t);vs({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var C6=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:s,verboseInfo:i})=>{if(!n)return s;let o=w6(i),a=Ei(e,"ipc"),c=Ei(r,"ipc");for await(let l of _I({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(IY(t,s,c),s.push(l)),o&&R6(l,i);return s},x6=async(t,e)=>(await Promise.allSettled([t]),e);var P6=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:s,timeoutDuration:i,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:h,fileDescriptors:p,originalStreams:m,onInternalError:E,controller:S})=>{let b=D4(t,f),R={originalStreams:m,fileDescriptors:p,subprocess:t,exitPromise:b,propagating:!1},A=b6({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:R}),G=v6({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:R}),I=[],U=C6({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:I,verboseInfo:h}),P=Rbe(m,t,R),O=Cbe(p,R);try{return await Promise.race([Promise.all([{},U4(b),Promise.all(A),G,U,lY(t,d),...P,...O]),E,xbe(t,S),...sY(t,i,f,S),...wz({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:S}),...rY({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(D){return f.terminationReason??="other",Promise.all([{error:D},b,Promise.all(A.map(_=>NI(_))),NI(G),x6(U,I),Promise.allSettled(P),Promise.allSettled(O)])}},Rbe=(t,e,r)=>t.map((n,s)=>n===e.stdio[s]?void 0:fm(n,s,r)),Cbe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:s,stream:i=s})=>Vn(i,{checkOpen:!1})&&!Gn(i)).map(({type:s,value:i,stream:o=i})=>fm(o,n,e,{isSameDirection:dn.has(s),stopOnExit:s==="native"}))),xbe=async(t,{signal:e})=>{let[r]=await wbe(t,"error",{signal:e});throw r};var O6=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),hm=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let s=n.get(e),i=ws();return s.push(i),{resolve:i.resolve.bind(i),promises:s}},ku=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 Pbe}from"stream";import{callbackify as Obe}from"util";import{finished as I6}from"stream/promises";var DI=async t=>{if(t!==void 0)try{await kI(t)}catch{}},N6=async t=>{if(t!==void 0)try{await UI(t)}catch{}},kI=async t=>{await I6(t,{cleanup:!0,readable:!1,writable:!0})},UI=async t=>{await I6(t,{cleanup:!0,readable:!0,writable:!1})},ib=async(t,e)=>{if(await t,e)throw e},ob=(t,e,r)=>{r&&!sb(r)?t.destroy(r):e&&t.destroy()};var M6=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:s=!0,preserveNewlines:i=!0}={})=>{let o=s||Dr.has(r),{subprocessStdout:a,waitReadableDestroy:c}=FI(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=BI(a,o),{read:f,onStdoutDataDone:h}=$I({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:i}),p=new Pbe({read:f,destroy:Obe(qI.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return GI({subprocessStdout:a,onStdoutDataDone:h,readable:p,subprocess:t}),p},FI=(t,e,r)=>{let n=xu(t,e),s=hm(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:s}},BI=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:II},$I=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:s})=>{let i=ws(),o=nb({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:s});return{read(){Ibe(this,o,i)},onStdoutDataDone:i}},Ibe=async(t,e,r)=>{try{let{value:n,done:s}=await e.next();s?r.resolve():t.push(n)}catch{}},GI=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:s})=>{try{await UI(t),await n,await DI(s),await e,r.readable&&r.push(null)}catch(i){await DI(s),L6(r,i)}},qI=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await ku(r,e)&&(L6(t,n),await ib(e,n))},L6=(t,e)=>{ob(t,t.readable,e)};import{Writable as Nbe}from"stream";import{callbackify as D6}from"util";var k6=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}=HI(t,r,e),o=new Nbe({...VI(n,t,s),destroy:D6(WI.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:s,waitWritableDestroy:i})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return jI(n,o),o},HI=(t,e,r)=>{let n=TT(t,e),s=hm(r,n,"writableFinal"),i=hm(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}},VI=(t,e,r)=>({write:Mbe.bind(void 0,t),final:D6(Lbe.bind(void 0,t,e,r))}),Mbe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},Lbe=async(t,e,r)=>{await ku(r,e)&&(t.writable&&t.end(),await e)},jI=async(t,e,r)=>{try{await kI(t),e.writable&&e.end()}catch(n){await N6(r),U6(e,n)}},WI=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},s)=>{await ku(r,e),await ku(n,e)&&(U6(t,s),await ib(e,s))},U6=(t,e)=>{ob(t,t.writable,e)};import{Duplex as Dbe}from"stream";import{callbackify as kbe}from"util";var F6=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:s,binary:i=!0,preserveNewlines:o=!0}={})=>{let a=i||Dr.has(r),{subprocessStdout:c,waitReadableDestroy:l}=FI(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=HI(t,s,e),{readableEncoding:h,readableObjectMode:p,readableHighWaterMark:m}=BI(c,a),{read:E,onStdoutDataDone:S}=$I({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),b=new Dbe({read:E,...VI(u,t,d),destroy:kbe(Ube.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:p,writableObjectMode:u.writableObjectMode,encoding:h});return GI({subprocessStdout:c,onStdoutDataDone:S,readable:b,subprocess:t,subprocessStdin:u}),jI(u,b,c),b},Ube=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:s,waitWritableDestroy:i},o)=>{await Promise.all([qI({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),WI({subprocessStdin:e,subprocess:r,waitWritableFinal:s,waitWritableDestroy:i},o)])};var zI=(t,e,{from:r,binary:n=!1,preserveNewlines:s=!1}={})=>{let i=n||Dr.has(e),o=xu(t,r),a=nb({subprocessStdout:o,subprocess:t,binary:i,shouldEncode:!0,encoding:e,preserveNewlines:s});return Fbe(a,o,t)},Fbe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var B6=(t,{encoding:e})=>{let r=O6();t.readable=M6.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=k6.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=F6.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=zI.bind(void 0,t,e),t[Symbol.asyncIterator]=zI.bind(void 0,t,e,{})};var $6=(t,e)=>{for(let[r,n]of $be){let s=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:s})}},Bbe=(async()=>{})().constructor.prototype,$be=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(Bbe,t)]);var G6=(t,e,r,n)=>{let{file:s,commandArguments:i,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=Hbe(t,e,r),{subprocess:f,promise:h}=jbe({file:s,commandArguments:i,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=rb.bind(void 0,{source:f,sourcePromise:h,boundOptions:{},createNested:n}),$6(f,h),Rs.set(f,{options:u,fileDescriptors:d}),f},Hbe=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=fT(t,e,r),{file:a,commandArguments:c,options:l}=NT(t,e,r),u=Vbe(l),d=J4(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:d}},Vbe=({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}},jbe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:s,command:i,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=qbe(...MT(t,e,r))}catch(p){return Y4({error:p,command:i,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:s})}let l=new AbortController;Gbe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];a6(c,a,l),l6(c,r,l);let d={},f=ws();c.kill=Az.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=A6(c,r),B6(c,r),j4(c,r);let h=Wbe({subprocess:c,options:r,startTime:n,verboseInfo:s,fileDescriptors:a,originalStreams:u,command:i,escapedCommand:o,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:h}},Wbe=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:s,originalStreams:i,command:o,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,h],p,m,E]=await P6({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:s,originalStreams:i,onInternalError:l,controller:u});u.abort(),l.resolve();let S=p.map((A,G)=>Ti(A,e,G)),b=Ti(m,e,"all"),R=zbe({errorInfo:d,exitCode:f,signal:h,stdio:S,all:b,ipcOutput:E,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Mu(R,n,e)},zbe=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:s,ipcOutput:i,context:o,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?am({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 Cs,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:s,ipcOutput:i,options:a,startTime:u,isSync:!1}):GT({command:c,escapedCommand:l,stdio:n,all:s,ipcOutput:i,options:a,startTime:u});var ab=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,s])=>[n,Ybe(n,t[n],s)]));return{...t,...r}},Ybe=(t,e,r)=>Kbe.has(t)&&ot(e)&&ot(r)?{...e,...r}:r,Kbe=new Set(["env",...AO]);var Io=(t,e,r,n)=>{let s=(o,a,c)=>Io(o,a,r,c),i=(...o)=>Xbe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:s},...o);return n!==void 0&&n(i,s,e),i},Xbe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:s},i,...o)=>{if(ot(i))return s(t,ab(r,i),n);let{file:a,commandArguments:c,options:l,isSync:u}=Qbe({mapArguments:t,firstArgument:i,nextArguments:o,deepOptions:e,boundOptions:r});return u?B4(a,c,l):G6(a,c,l,s)},Qbe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:s})=>{let i=J3(e)?Z3(e,r):[e,...r],[o,a,c]=tT(...i),l=ab(ab(n,s),c),{file:u=o,commandArguments:d=a,options:f=l,isSync:h=!1}=t({file:o,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:h}};var q6=({file:t,commandArguments:e})=>V6(t,e),H6=({file:t,commandArguments:e})=>({...V6(t,e),isSync:!0}),V6=(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]=Jbe(t);return{file:r,commandArguments:n}},Jbe=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(Zbe)){let s=r.at(-1);s&&s.endsWith("\\")?r[r.length-1]=`${s.slice(0,-1)} ${n}`:r.push(n)}return r},Zbe=/ +/g;var j6=(t,e,r)=>{t.sync=e(eAe,r),t.s=t.sync},W6=({options:t})=>z6(t),eAe=({options:t})=>({...z6(t),isSync:!0}),z6=t=>({options:{...tAe(t),...t}}),tAe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Y6={preferLocal:!0};var K6=Io(()=>({})),XZe=Io(()=>({isSync:!0})),X6=Io(q6),QZe=Io(H6),JZe=Io(oY),ZZe=Io(W6,{},Y6,j6),{sendMessage:eet,getOneMessage:tet,getEachMessage:ret,getCancelSignal:net}=W4();var rAe=!1;var Ps=()=>rAe;var pm=null,Q6=t=>(pm&&pm.destroy(),pm=new bi({totalAllowedTime:t}),pm),J6=()=>pm;var bi=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:s=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(s&&Ps())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let i=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),o=null,a=null;n!==void 0&&(a=new Promise((u,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 Ky({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{Ee.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),i(),o&&clearTimeout(o)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var Z6={name:"@netlify/agent-runner-cli",type:"module",version:"1.138.0-pty.1",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js","agent-runner-pty":"./dist/pty-client.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","@types/ws":"^8.5.12","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"2.1.197","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.1.5","@netlify/otel":"^6.0.3","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.8.5",minimist:"^1.2.8","node-pty":"1.1.0",openai:"6.34.0",ws:"8.21.0"}};var oAe=sAe(import.meta.url),aAe=Ai.dirname(oAe),cAe=iAe(import.meta.url),Uu=me("shell"),YI=new Set,e8={preferLocal:!0},kr=(t,e,r)=>{let[n,s]=lAe(e,r),i={...e8,...s},o=K6(t,n,i);r8(o,i),i8(o);let a=r?.idleTimeout;return a&&a>0&&s8(o,a),o},t8=(t,e)=>{let r={...e8,...e},n=X6(t,r);return r8(n,r),i8(n),e?.idleTimeout&&e.idleTimeout>0&&s8(n,e.idleTimeout),n},lAe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},r8=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(vi.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new jp).pipe(vi.stdout),t.stderr?.pipe(new jp).pipe(vi.stderr);return}t.stdout?.pipe(vi.stdout),t.stderr?.pipe(vi.stderr)},KI=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(vi.kill(-t.pid,e),Uu.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Uu.error("Error killing process:",r),!1}},n8=t=>KI(t,"SIGKILL"),s8=(t,e)=>{let r=null,n=()=>{Uu.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),KI(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Uu.log(`Force killing idle process ${t.pid}`),n8(t))},5e3)},s=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};s(),t.stdout?.on("data",s),t.stderr?.on("data",s);let i=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",i),t.on("error",i)},i8=t=>{YI.add(t);let e=J6();if(e){let r=e.onTimesUp(()=>{Uu.log(`Global timer expired, killing process ${t.pid}`),KI(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Uu.log(`Force killing process ${t.pid} after timeout`),n8(t))},5e3)});t.on("exit",()=>{YI.delete(t),r()}),t.on("error",()=>{YI.delete(t),r()})}};function No(t,e){if(!vi.env.NETLIFY_LOCAL_MODE)try{let s=cAe.resolve(Z6.name),i=Ai.dirname(s);for(;i!==Ai.dirname(i);){let o=Ai.dirname(i);if(Ai.basename(o)==="node_modules"){let a=Ai.join(o,".bin",e);if(cb.existsSync(a))return a;break}i=o}}catch(s){console.error("Could not resolve package.json",s)}if(vi.env.NODE_PATH){let s=Ai.join(vi.env.NODE_PATH,".bin",e);if(cb.existsSync(s))return s}let r=Ai.join(t,"node_modules",".bin",e);if(cb.existsSync(r))return r;let n=Ai.join(aAe,"..","node_modules",".bin",e);if(cb.existsSync(n))return n}var uAe=me("utils"),dAe=t=>new Promise(e=>{setTimeout(e,t)});var lb=(t,e=3e3)=>{let r=!1,n=null,s=[],i=null,o=(...a)=>{if(r)return n=a,new Promise(u=>{s.push(u)});r=!0;let c,l=new Promise(u=>{c=u});return i=(async()=>{await Promise.resolve();let u=await t(...a);for(c(u);;){if(await dAe(e),!n)return r=!1,i=null,u;let d=n,f=s;n=null,s=[],u=await t(...d),f.forEach(h=>{h(u)})}})(),l};return o.flush=async()=>{if((r||n)&&i)return await i,o.flush()},o.cancel=()=>{n=null,s.forEach(a=>a(void 0)),s=[]},o},Fu=(t,e,r=!1)=>{let n=null,s=null,i=null,o=function(...a){s=a,i=this;let c=r&&!n;clearTimeout(n),n=setTimeout(()=>{n=null,r||(t.apply(i,s),s=null,i=null)},e),c&&(t.apply(i,s),s=null,i=null)};return o.cancel=()=>{clearTimeout(n),n=null,s=null,i=null},o.flush=()=>{if(n){clearTimeout(n);let a=s,c=i;n=null,s=null,i=null,t.apply(c,a)}},o},o8=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):uAe.error("Could not parse JSON",n))}},fAe=t=>t.charAt(0).toUpperCase()+t.slice(1),Mo=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():fAe(e)).join(" ");function gc(t,e){e&&t.log(`Skill invoked: ${e}`)}var a8=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),c8=(t,e,r=!1)=>{if(r)return;let n=60,s=55,i=".netlify.app",o="agent-",a=6;if(!e)return`${o}${t.slice(0,a)}`;let c=`--${e}${i}`;if(c.length>s)return"";let l=n-c.length;if(l<=0)return"";if(l>=o.length+a){let u=Math.min(l-o.length,t.length);return`${o}${t.slice(0,u)}`}return t.slice(0,l)};var XI=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}},hAe=1e4,QI=(t,e=hAe)=>{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 l8}from"buffer";import pAe from"path";var u8=me("repo"),gr=(t,e={})=>kr("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),f8=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{u8.info("Getting runner diffs");let n=await gAe(r),{hasChanges:s}=n,{status:i}=n;if(!s)return{hasChanges:!1};if(!e){let m=SAe(i);await EAe(m,r)}u8.info("Changes after processing"),await ZI(r);let o=await tN(i,r);if(await JI(o,r),s=await _Ae(r),!s)return{hasChanges:!1,ignored:o};await gr(["commit","-m","Agent runner"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await gr(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(s=!!l,!s)return await d8(r),{hasChanges:!1,ignored:o};let u=await gr(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,h;if(t.sha){let m=await gr(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let E=await gr(["diff",t.sha,"HEAD","--binary"],a),S=String(E.stdout??"");f!==S&&(h=l8.from(S).toString("base64"))}await d8(r);let p={hasChanges:!0,diff:l,resultDiff:f,ignored:o};return l!==d&&(p.diffBinary=l8.from(d).toString("base64")),h&&(p.resultDiffBinary=h),p},d8=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await gr(["reset","--soft","HEAD~1"],{cwd:t})},JI=async(t=[],e=process.cwd())=>{await gr(["add",".",...t],{cwd:e})},ZI=async(t=process.cwd())=>{let e=await gr(["status","-s"],{cwd:t});return String(e.stdout??"")},h8=/.. (.+)?\.log$/,mAe=[h8],gAe=async(t=process.cwd())=>{let e=await ZI(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
88
+ if (condition) { yield value; }`)};import{Buffer as yye}from"buffer";import{StringDecoder as Tye}from"string_decoder";var zT=(t,e,r)=>{if(r)return;if(t)return{transform:bye.bind(void 0,new TextEncoder)};let n=new Tye(e);return{transform:Aye.bind(void 0,n),final:vye.bind(void 0,n)}},bye=function*(t,e){yye.isBuffer(e)?yield Si(e):typeof e=="string"?yield t.encode(e):yield e},Aye=function*(t,e){yield gt(e)?t.write(e):e},vye=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as A4}from"util";var dI=A4(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let s of e.currentIterable)n.push(s)}finally{delete e.currentIterable}}),YT=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Rye}=e[r];for await(let s of n(t))yield*YT(s,e,r+1)},v4=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*wye(r,Number(e),t)},wye=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*YT(n,r,e+1)},w4=A4(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),Rye=function*(t){yield t};var fI=(t,e,r,n)=>{try{for(let s of t(...e))r.push(s);n()}catch(s){n(s)}},R4=(t,e)=>[...e.flatMap(r=>[...hc(r,t,0)]),...cm(t)],hc=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=xye}=e[r];for(let s of n(t))yield*hc(s,e,r+1)},cm=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Cye(r,Number(e),t)},Cye=function*(t,e,r){if(t!==void 0)for(let n of t())yield*hc(n,r,e+1)},xye=function*(t){yield t};var hI=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:s},optionName:i},{encoding:o})=>{let a={},c=x4(t,o,i),l=fc(e),u=fc(r),d=l?dI.bind(void 0,YT,a):fI.bind(void 0,hc),f=l||u?dI.bind(void 0,v4,a):fI.bind(void 0,cm),h=l||u?w4.bind(void 0,a):void 0;return{stream:new Pye({writableObjectMode:n,writableHighWaterMark:C4(n),readableObjectMode:s,readableHighWaterMark:C4(s),transform(m,E,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:h})}},KT=(t,e,r,n)=>{let s=e.filter(({type:o})=>o==="generator"),i=n?s.reverse():s;for(let{value:o,optionName:a}of i){let c=x4(o,r,a);t=R4(c,t)}return t},x4=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:s,preserveNewlines:i},o,a)=>{let c={};return[{transform:y4(n,a)},zT(r,o,n),WT(r,i,n,c),{transform:t,final:e},{transform:T4(s,a)},E4({binary:r,preserveNewlines:i,readableObjectMode:s,state:c})].filter(Boolean)};var P4=(t,e)=>{for(let r of Oye(t))Iye(t,r,e)},Oye=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Iye=(t,e,r)=>{let{stdioItems:n}=t[e],s=n.filter(({contents:a})=>a!==void 0);if(s.length===0)return;if(e!==0){let[{type:a,optionName:c}]=s;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Oo[a]} with synchronous methods.`)}let o=s.map(({contents:a})=>a).map(a=>Nye(a,n));r.input=Jp(o)},Nye=(t,e)=>{let r=KT(t,e,"utf8",!0);return Mye(r),Jp(r)},Mye=t=>{let e=t.find(r=>typeof r!="string"&&!gt(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 Uye,appendFileSync as Fye}from"fs";var XT=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Au(r,n)&&!Dr.has(e)&&Lye(n)&&(t.some(({type:s,value:i})=>s==="native"&&Dye.has(i))||t.every(({type:s})=>dn.has(s))),Lye=t=>t===1||t===2,Dye=new Set(["pipe","overlapped"]),O4=async(t,e,r,n)=>{for await(let s of t)kye(e)||N4(s,r,n)},I4=(t,e,r)=>{for(let n of t)N4(n,e,r)},kye=t=>t._readableState.pipes.length>0,N4=(t,e,r)=>{let n=uT(t);vs({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var M4=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:s})=>{if(e===null)return{output:Array.from({length:3})};let i={},o=new Set([]);return{output:e.map((c,l)=>Bye({result:c,fileDescriptors:t,fdNumber:l,state:i,outputFiles:o,isMaxBuffer:n,verboseInfo:s},r)),...i}},Bye=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:s,isMaxBuffer:i,verboseInfo:o},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=LY(t,i,d),h=Si(f),{stdioItems:p,objectMode:m}=e[r],E=$ye([h],p,c,n),{serializedResult:S,finalResult:b=S}=Gye({chunks:E,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});qye({serializedResult:S,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:p,objectMode:m});let R=a[r]?b:void 0;try{return n.error===void 0&&Hye(S,p,s),R}catch(A){return n.error=A,R}},$ye=(t,e,r,n)=>{try{return KT(t,e,r,!1)}catch(s){return n.error=s,t}},Gye=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:s,fdNumber:i})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Jp(t)};let o=Y3(t,r);return n[i]?{serializedResult:o,finalResult:uI(o,!s[i],e)}:{serializedResult:o}},qye=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:s,stdioItems:i,objectMode:o})=>{if(!XT({stdioItems:i,encoding:s,verboseInfo:n,fdNumber:e}))return;let a=uI(t,!1,o);try{I4(a,e,n)}catch(c){r.error??=c}},Hye=(t,e,r)=>{for(let{path:n,append:s}of e.filter(({type:i})=>VT.has(i))){let i=typeof n=="string"?n:n.toString();s||r.has(i)?Fye(n,t):(r.add(i),Uye(n,t))}};var L4=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Ti(e,r,"all")]:Array.isArray(e)?[Ti(t,r,"all"),...e]:gt(t)&&gt(e)?EO([t,e]):`${t}${e}`};import{once as pI}from"events";var D4=async(t,e)=>{let[r,n]=await Vye(t);return e.isForcefullyTerminated??=!1,[r,n]},Vye=async t=>{let[e,r]=await Promise.allSettled([pI(t,"spawn"),pI(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?k4(t):r.value},k4=async t=>{try{return await pI(t,"exit")}catch{return k4(t)}},U4=async t=>{let[e,r]=await t;if(!jye(e,r)&&mI(e,r))throw new qn;return[e,r]},jye=(t,e)=>t===void 0&&e===void 0,mI=(t,e)=>t!==0||e!==null;var F4=({error:t,status:e,signal:r,output:n},{maxBuffer:s})=>{let i=Wye(t,e,r),o=i?.code==="ETIMEDOUT",a=MY(i,n,s);return{resultError:i,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},Wye=(t,e,r)=>t!==void 0?t:mI(e,r)?new qn:void 0;var B4=(t,e,r)=>{let{file:n,commandArguments:s,command:i,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=Yye(t,e,r),d=Qye({file:n,commandArguments:s,options:l,command:i,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Mu(d,c,l)},Yye=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=fT(t,e,r),a=Kye(r),{file:c,commandArguments:l,options:u}=NT(t,e,a);Xye(u);let d=m4(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:d}},Kye=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Xye=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&QT("ipcInput"),t&&QT("ipc: true"),r&&QT("detached: true"),n&&QT("cancelSignal")},QT=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Qye=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,verboseInfo:i,fileDescriptors:o,startTime:a})=>{let c=Jye({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:h}=F4(c,r),{output:p,error:m=l}=M4({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:h,verboseInfo:i}),E=p.map((b,R)=>Ti(b,r,R)),S=Ti(L4(p,r),r,"all");return eTe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:h,stdio:E,all:S,options:r,command:n,escapedCommand:s,startTime:a})},Jye=({file:t,commandArguments:e,options:r,command:n,escapedCommand:s,fileDescriptors:i,startTime:o})=>{try{P4(i,r);let a=Zye(r);return zye(...MT(t,e,a))}catch(a){return Nu({error:a,command:n,escapedCommand:s,fileDescriptors:i,options:r,startTime:o,isSync:!0})}},Zye=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:$T(e)}),eTe=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:s,stdio:i,all:o,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?GT({command:c,escapedCommand:l,stdio:i,all:o,ipcOutput:[],options:a,startTime:u}):am({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:s,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:i,all:o,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as Gbe}from"events";import{spawn as qbe}from"child_process";import V4 from"process";import{once as gI,on as tTe}from"events";var $4=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0,filter:i}={})=>(Ru({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:RT(t)}),rTe({anyProcess:t,channel:e,isSubprocess:r,filter:i,reference:s})),rTe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:s})=>{bT(e,s);let i=Po(t,e,r),o=new AbortController;try{return await Promise.race([nTe(i,n,o),sTe(i,r,o),iTe(i,r,o)])}catch(a){throw Cu(t),a}finally{o.abort(),AT(e,s)}},nTe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await gI(t,"message",{signal:r});return n}for await(let[n]of tTe(t,"message",{signal:r}))if(e(n))return n},sTe=async(t,e,{signal:r})=>{await gI(t,"disconnect",{signal:r}),Rz(e)},iTe=async(t,e,{signal:r})=>{let[n]=await gI(t,"strict:error",{signal:r});throw ET(n,e)};import{once as q4,on as oTe}from"events";var H4=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:s=!0}={})=>_I({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:s}),_I=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:s,reference:i})=>{Ru({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:RT(t)}),bT(e,i);let o=Po(t,e,r),a=new AbortController,c={};return aTe(t,o,a),cTe({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),lTe({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:s,controller:a,state:c,reference:i})},aTe=async(t,e,r)=>{try{await q4(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},cTe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[s]=await q4(t,"strict:error",{signal:r.signal});n.error=ET(s,e),r.abort()}catch{}},lTe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:s,controller:i,state:o,reference:a}){try{for await(let[c]of oTe(r,"message",{signal:i.signal}))G4(o),yield c}catch{G4(o)}finally{i.abort(),AT(e,a),n||Cu(t),s&&await t}},G4=({error:t})=>{if(t)throw t};var j4=(t,{ipc:e})=>{Object.assign(t,z4(t,!1,e))},W4=()=>{let t=V4,e=!0,r=V4.channel!==void 0;return{...z4(t,e,r),getCancelSignal:Zz.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},z4=(t,e,r)=>({sendMessage:OT.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:$4.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:H4.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as uTe}from"child_process";import{PassThrough as dTe,Readable as fTe,Writable as hTe,Duplex as pTe}from"stream";var Y4=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,verboseInfo:o})=>{aI(n);let a=new uTe;mTe(a,n),Object.assign(a,{readable:gTe,writable:_Te,duplex:STe});let c=Nu({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:s,startTime:i,isSync:!1}),l=ETe(c,o,s);return{subprocess:a,promise:l}},mTe=(t,e)=>{let r=lm(),n=lm(),s=lm(),i=Array.from({length:e.length-3},lm),o=lm(),a=[r,n,s,...i];Object.assign(t,{stdin:r,stdout:n,stderr:s,all:o,stdio:a})},lm=()=>{let t=new dTe;return t.end(),t},gTe=()=>new fTe({read(){}}),_Te=()=>new hTe({write(){}}),STe=()=>new pTe({read(){},write(){}}),ETe=async(t,e,r)=>Mu(t,e,r);import{createReadStream as K4,createWriteStream as X4}from"fs";import{Buffer as yTe}from"buffer";import{Readable as um,Writable as TTe,Duplex as bTe}from"stream";var J4=(t,e)=>jT(ATe,t,e,!1),dm=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Oo[t]}.`)},Q4={fileNumber:dm,generator:hI,asyncGenerator:hI,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:bTe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},ATe={input:{...Q4,fileUrl:({value:t})=>({stream:K4(t)}),filePath:({value:{file:t}})=>({stream:K4(t)}),webStream:({value:t})=>({stream:um.fromWeb(t)}),iterable:({value:t})=>({stream:um.from(t)}),asyncIterable:({value:t})=>({stream:um.from(t)}),string:({value:t})=>({stream:um.from(t)}),uint8Array:({value:t})=>({stream:um.from(yTe.from(t))})},output:{...Q4,fileUrl:({value:t})=>({stream:X4(t)}),filePath:({value:{file:t,append:e}})=>({stream:X4(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:TTe.fromWeb(t)}),iterable:dm,asyncIterable:dm,string:dm,uint8Array:dm}};import{on as vTe,once as Z4}from"events";import{PassThrough as wTe,getDefaultHighWaterMark as RTe}from"stream";import{finished as r6}from"stream/promises";function pc(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let s of t)EI(s);let e=t.some(({readableObjectMode:s})=>s),r=CTe(t,e),n=new SI({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let s of t)n.add(s);return n}var CTe=(t,e)=>{if(t.length===0)return RTe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},SI=class extends wTe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#i=Symbol("unpipe");#s=new WeakMap;add(e){if(EI(e),this.#e.has(e))return;this.#e.add(e),this.#n??=xTe(this,this.#e,this.#i);let r=ITe({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#i});this.#s.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(EI(e),!this.#e.has(e))return!1;let r=this.#s.get(e);return r===void 0?!1:(this.#s.delete(e),e.unpipe(this),await r,!0)}},xTe=async(t,e,r)=>{JT(t,e6);let n=new AbortController;try{await Promise.race([PTe(t,n),OTe(t,e,r,n)])}finally{n.abort(),JT(t,-e6)}},PTe=async(t,{signal:e})=>{try{await r6(t,{signal:e,cleanup:!0})}catch(r){throw n6(t,r),r}},OTe=async(t,e,r,{signal:n})=>{for await(let[s]of vTe(t,"unpipe",{signal:n}))e.has(s)&&s.emit(r)},EI=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},ITe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,onFinished:i,unpipeEvent:o})=>{JT(t,t6);let a=new AbortController;try{await Promise.race([NTe(i,e,a),MTe({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:a}),LTe({stream:e,streams:r,ended:n,aborted:s,unpipeEvent:o,controller:a})])}finally{a.abort(),JT(t,-t6)}r.size>0&&r.size===n.size+s.size&&(n.size===0&&s.size>0?yI(t):DTe(t))},NTe=async(t,e,{signal:r})=>{try{await t,r.aborted||yI(e)}catch(n){r.aborted||n6(e,n)}},MTe=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:s,controller:{signal:i}})=>{try{await r6(e,{signal:i,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(i.aborted||!r.has(e))return;s6(o)?s.add(e):i6(t,o)}},LTe=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:s,controller:{signal:i}})=>{if(await Z4(t,s,{signal:i}),!t.readable)return Z4(i,"abort",{signal:i});e.delete(t),r.delete(t),n.delete(t)},DTe=t=>{t.writable&&t.end()},n6=(t,e)=>{s6(e)?yI(t):i6(t,e)},s6=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",yI=t=>{(t.readable||t.writable)&&t.destroy()},i6=(t,e)=>{t.destroyed||(t.once("error",kTe),t.destroy(e))},kTe=()=>{},JT=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},e6=2,t6=1;import{finished as o6}from"stream/promises";var Du=(t,e)=>{t.pipe(e),UTe(t,e),FTe(t,e)},UTe=async(t,e)=>{if(!(Gn(t)||Gn(e))){try{await o6(t,{cleanup:!0,readable:!0,writable:!1})}catch{}TI(e)}},TI=t=>{t.writable&&t.end()},FTe=async(t,e)=>{if(!(Gn(t)||Gn(e))){try{await o6(e,{cleanup:!0,readable:!1,writable:!0})}catch{}bI(t)}},bI=t=>{t.readable&&t.destroy()};var a6=(t,e,r)=>{let n=new Map;for(let[s,{stdioItems:i,direction:o}]of Object.entries(e)){for(let{stream:a}of i.filter(({type:c})=>dn.has(c)))BTe(t,a,o,s);for(let{stream:a}of i.filter(({type:c})=>!dn.has(c)))GTe({subprocess:t,stream:a,direction:o,fdNumber:s,pipeGroups:n,controller:r})}for(let[s,i]of n.entries()){let o=i.length===1?i[0]:pc(i);Du(o,s)}},BTe=(t,e,r,n)=>{r==="output"?Du(t.stdio[n],e):Du(e,t.stdio[n]);let s=$Te[n];s!==void 0&&(t[s]=e),t.stdio[n]=e},$Te=["stdin","stdout","stderr"],GTe=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:s,controller:i})=>{if(e===void 0)return;qTe(e,i);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=s.get(o)??[];s.set(o,[...c,a])},qTe=(t,{signal:e})=>{Gn(t)&&uc(t,HTe,e)},HTe=2;import{addAbortListener as WTe}from"events";var mc=[];mc.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&mc.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&mc.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var ZT=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",AI=Symbol.for("signal-exit emitter"),vI=globalThis,VTe=Object.defineProperty.bind(Object),wI=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(vI[AI])return vI[AI];VTe(vI,AI,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],s=n.indexOf(r);s!==-1&&(s===0&&n.length===1?n.length=0:n.splice(s,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let s=!1;for(let i of this.listeners[e])s=i(r,n)===!0||s;return e==="exit"&&(s=this.emit("afterExit",r,n)||s),s}},eb=class{},jTe=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),RI=class extends eb{onExit(){return()=>{}}load(){}unload(){}},CI=class extends eb{#e=xI.platform==="win32"?"SIGINT":"SIGHUP";#r=new wI;#t;#n;#i;#s={};#o=!1;constructor(e){super(),this.#t=e,this.#s={};for(let r of mc)this.#s[r]=()=>{let n=this.#t.listeners(r),{count:s}=this.#r,i=e;if(typeof i.__signal_exit_emitter__=="object"&&typeof i.__signal_exit_emitter__.count=="number"&&(s+=i.__signal_exit_emitter__.count),n.length===s){this.unload();let o=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;o||e.kill(e.pid,a)}};this.#i=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!ZT(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 mc)try{let r=this.#s[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#o&&(this.#o=!1,mc.forEach(e=>{let r=this.#s[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#i,this.#r.count-=1)}#a(e){return ZT(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#i.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&ZT(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let s=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),s}else return n.call(this.#t,e,...r)}},xI=globalThis.process,{onExit:c6,load:oJe,unload:aJe}=jTe(ZT(xI)?new CI(xI):new RI);var l6=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let s=c6(()=>{t.kill()});WTe(n,()=>{s()})};var d6=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...s)=>{let i=dT(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=zTe(r,n,s),{sourceStream:d,sourceError:f}=KTe(t,l),{options:h,fileDescriptors:p}=Rs.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:h,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:p,startTime:i}},zTe=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:s,to:i,unpipeSignal:o}={}}=YTe(t,e,...r),a=TT(n,i);return{destination:n,destinationStream:a,from:s,unpipeSignal:o}}catch(n){return{destinationError:n}}},YTe=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(u6,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||_O(r)){if(Object.keys(t).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[s,i,o]=tT(r,...n);return{destination:e(u6)(s,i,o),pipeOptions:o}}if(Rs.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}`)},u6=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),KTe=(t,e)=>{try{return{sourceStream:xu(t,e)}}catch(r){return{sourceError:r}}};var h6=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:s,sourceOptions:i,startTime:o})=>{let a=XTe({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw PI({error:a,fileDescriptors:s,sourceOptions:i,startTime:o})},XTe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return bI(t),n;if(e!==void 0)return TI(r),e},PI=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Nu({error:t,command:f6,escapedCommand:f6,fileDescriptors:e,options:r,startTime:n,isSync:!1}),f6="source.pipe(destination)";var p6=async t=>{let[{status:e,reason:r,value:n=r},{status:s,reason:i,value:o=i}]=await t;if(o.pipedFrom.includes(n)||o.pipedFrom.push(n),s==="rejected")throw o;if(e==="rejected")throw n;return o};import{finished as QTe}from"stream/promises";var m6=(t,e,r)=>{let n=tb.has(e)?ZTe(t,e):JTe(t,e);return uc(t,tbe,r.signal),uc(e,rbe,r.signal),ebe(e),n},JTe=(t,e)=>{let r=pc([t]);return Du(r,e),tb.set(e,r),r},ZTe=(t,e)=>{let r=tb.get(e);return r.add(t),r},ebe=async t=>{try{await QTe(t,{cleanup:!0,readable:!1,writable:!0})}catch{}tb.delete(t)},tb=new WeakMap,tbe=2,rbe=1;import{aborted as nbe}from"util";var g6=(t,e)=>t===void 0?[]:[sbe(t,e)],sbe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:s,startTime:i})=>{await nbe(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw PI({error:o,fileDescriptors:n,sourceOptions:s,startTime:i})};var rb=(t,...e)=>{if(ot(e[0]))return rb.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=d6(t,...e),s=ibe({...n,destination:r});return s.pipe=rb.bind(void 0,{...t,source:r,sourcePromise:s,boundOptions:{}}),s},ibe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:s,destinationStream:i,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=obe(t,s);h6({sourceStream:e,sourceError:n,destinationStream:i,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=m6(e,i,d);return await Promise.race([p6(u),...g6(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},obe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as hbe}from"timers/promises";import{on as abe}from"events";import{getDefaultHighWaterMark as cbe}from"stream";var nb=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:s,preserveNewlines:i})=>{let o=new AbortController;return lbe(e,o),S6({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:s,shouldSplit:!t.readableObjectMode,preserveNewlines:i})},lbe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},OI=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:s,allMixed:i})=>{let o=new AbortController;ube(e,o,t);let a=t.readableObjectMode&&!i;return S6({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!s})},ube=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},S6=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})=>{let a=abe(t,"data",{signal:e.signal,highWaterMark:_6,highWatermark:_6});return dbe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o})},II=cbe(!0),_6=II,dbe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o}){let a=fbe({binary:r,shouldEncode:n,encoding:s,shouldSplit:i,preserveNewlines:o});try{for await(let[c]of t)yield*hc(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*cm(a)}},fbe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:s})=>[zT(t,r,!e),WT(t,s,!n,{})].filter(Boolean);var E6=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:s,maxBuffer:i,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=pbe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!s){await Promise.all([mbe(t),d]);return}let f=cI(c,r),h=OI({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[p]=await Promise.all([gbe({stream:t,iterable:h,fdNumber:r,encoding:n,maxBuffer:i,lines:o}),d]);return p},pbe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:s,verboseInfo:i,streamInfo:{fileDescriptors:o}})=>{if(!XT({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:i,fdNumber:r}))return;let a=OI({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:s});await O4(a,t,r,i)},mbe=async t=>{await hbe(),t.readableFlowing===null&&t.resume()},gbe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:s,maxBuffer:i,lines:o})=>{try{return e||o?await UT(r,{maxBuffer:i}):s==="buffer"?new Uint8Array(await FT(r,{maxBuffer:i})):await Iu(r,{maxBuffer:i})}catch(a){return y6(OY({error:a,stream:t,readableObjectMode:e,lines:o,encoding:s,fdNumber:n}))}},NI=async t=>{try{return await t}catch(e){return y6(e)}},y6=({bufferedData:t})=>W3(t)?new Uint8Array(t):t;import{finished as _be}from"stream/promises";var fm=async(t,e,r,{isSameDirection:n,stopOnExit:s=!1}={})=>{let i=Sbe(t,r),o=new AbortController;try{await Promise.race([...s?[r.exitPromise]:[],_be(t,{cleanup:!0,signal:o.signal})])}catch(a){i.stdinCleanedUp||Tbe(a,e,r,n)}finally{o.abort()}},Sbe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&Ebe(t,r,n),n},Ebe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...s)=>{ybe(e,r),n.call(t,...s)}},ybe=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Tbe=(t,e,r,n)=>{if(!bbe(t,e,r,n))throw t},bbe=(t,e,r,n=!0)=>r.propagating?T6(t)||sb(t):(r.propagating=!0,MI(r,e)===n?T6(t):sb(t)),MI=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",sb=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",T6=t=>t?.code==="EPIPE";var b6=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>LI({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:s[l],allMixed:!1,stripFinalNewline:i,verboseInfo:o,streamInfo:a})),LI=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:s,lines:i,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=fm(t,e,l);if(MI(l,e)){await u;return}let[d]=await Promise.all([E6({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:s,lines:i,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var A6=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?pc([t,e].filter(Boolean)):void 0,v6=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:i,verboseInfo:o,streamInfo:a})=>LI({...Abe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:s[1]||s[2],allMixed:vbe(t),stripFinalNewline:i,verboseInfo:o,streamInfo:a}),Abe=({stdout:t,stderr:e,all:r},[,n,s])=>{let i=n||s;return i?n?s?{stream:r,buffer:i}:{stream:t,buffer:i}:{stream:e,buffer:i}:{stream:r,buffer:i}},vbe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as wbe}from"events";var w6=t=>Au(t,"ipc"),R6=(t,e)=>{let r=uT(t);vs({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var C6=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:s,verboseInfo:i})=>{if(!n)return s;let o=w6(i),a=Ei(e,"ipc"),c=Ei(r,"ipc");for await(let l of _I({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(IY(t,s,c),s.push(l)),o&&R6(l,i);return s},x6=async(t,e)=>(await Promise.allSettled([t]),e);var P6=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:s,timeoutDuration:i,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:h,fileDescriptors:p,originalStreams:m,onInternalError:E,controller:S})=>{let b=D4(t,f),R={originalStreams:m,fileDescriptors:p,subprocess:t,exitPromise:b,propagating:!1},A=b6({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:R}),G=v6({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:s,stripFinalNewline:l,verboseInfo:h,streamInfo:R}),I=[],U=C6({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:I,verboseInfo:h}),P=Rbe(m,t,R),O=Cbe(p,R);try{return await Promise.race([Promise.all([{},U4(b),Promise.all(A),G,U,lY(t,d),...P,...O]),E,xbe(t,S),...sY(t,i,f,S),...wz({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:S}),...rY({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(D){return f.terminationReason??="other",Promise.all([{error:D},b,Promise.all(A.map(_=>NI(_))),NI(G),x6(U,I),Promise.allSettled(P),Promise.allSettled(O)])}},Rbe=(t,e,r)=>t.map((n,s)=>n===e.stdio[s]?void 0:fm(n,s,r)),Cbe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:s,stream:i=s})=>Vn(i,{checkOpen:!1})&&!Gn(i)).map(({type:s,value:i,stream:o=i})=>fm(o,n,e,{isSameDirection:dn.has(s),stopOnExit:s==="native"}))),xbe=async(t,{signal:e})=>{let[r]=await wbe(t,"error",{signal:e});throw r};var O6=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),hm=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let s=n.get(e),i=ws();return s.push(i),{resolve:i.resolve.bind(i),promises:s}},ku=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 Pbe}from"stream";import{callbackify as Obe}from"util";import{finished as I6}from"stream/promises";var DI=async t=>{if(t!==void 0)try{await kI(t)}catch{}},N6=async t=>{if(t!==void 0)try{await UI(t)}catch{}},kI=async t=>{await I6(t,{cleanup:!0,readable:!1,writable:!0})},UI=async t=>{await I6(t,{cleanup:!0,readable:!0,writable:!1})},ib=async(t,e)=>{if(await t,e)throw e},ob=(t,e,r)=>{r&&!sb(r)?t.destroy(r):e&&t.destroy()};var M6=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:s=!0,preserveNewlines:i=!0}={})=>{let o=s||Dr.has(r),{subprocessStdout:a,waitReadableDestroy:c}=FI(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=BI(a,o),{read:f,onStdoutDataDone:h}=$I({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:i}),p=new Pbe({read:f,destroy:Obe(qI.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return GI({subprocessStdout:a,onStdoutDataDone:h,readable:p,subprocess:t}),p},FI=(t,e,r)=>{let n=xu(t,e),s=hm(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:s}},BI=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:II},$I=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:s})=>{let i=ws(),o=nb({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:s});return{read(){Ibe(this,o,i)},onStdoutDataDone:i}},Ibe=async(t,e,r)=>{try{let{value:n,done:s}=await e.next();s?r.resolve():t.push(n)}catch{}},GI=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:s})=>{try{await UI(t),await n,await DI(s),await e,r.readable&&r.push(null)}catch(i){await DI(s),L6(r,i)}},qI=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await ku(r,e)&&(L6(t,n),await ib(e,n))},L6=(t,e)=>{ob(t,t.readable,e)};import{Writable as Nbe}from"stream";import{callbackify as D6}from"util";var k6=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}=HI(t,r,e),o=new Nbe({...VI(n,t,s),destroy:D6(WI.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:s,waitWritableDestroy:i})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return jI(n,o),o},HI=(t,e,r)=>{let n=TT(t,e),s=hm(r,n,"writableFinal"),i=hm(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:s,waitWritableDestroy:i}},VI=(t,e,r)=>({write:Mbe.bind(void 0,t),final:D6(Lbe.bind(void 0,t,e,r))}),Mbe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},Lbe=async(t,e,r)=>{await ku(r,e)&&(t.writable&&t.end(),await e)},jI=async(t,e,r)=>{try{await kI(t),e.writable&&e.end()}catch(n){await N6(r),U6(e,n)}},WI=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},s)=>{await ku(r,e),await ku(n,e)&&(U6(t,s),await ib(e,s))},U6=(t,e)=>{ob(t,t.writable,e)};import{Duplex as Dbe}from"stream";import{callbackify as kbe}from"util";var F6=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:s,binary:i=!0,preserveNewlines:o=!0}={})=>{let a=i||Dr.has(r),{subprocessStdout:c,waitReadableDestroy:l}=FI(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=HI(t,s,e),{readableEncoding:h,readableObjectMode:p,readableHighWaterMark:m}=BI(c,a),{read:E,onStdoutDataDone:S}=$I({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),b=new Dbe({read:E,...VI(u,t,d),destroy:kbe(Ube.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:p,writableObjectMode:u.writableObjectMode,encoding:h});return GI({subprocessStdout:c,onStdoutDataDone:S,readable:b,subprocess:t,subprocessStdin:u}),jI(u,b,c),b},Ube=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:s,waitWritableDestroy:i},o)=>{await Promise.all([qI({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),WI({subprocessStdin:e,subprocess:r,waitWritableFinal:s,waitWritableDestroy:i},o)])};var zI=(t,e,{from:r,binary:n=!1,preserveNewlines:s=!1}={})=>{let i=n||Dr.has(e),o=xu(t,r),a=nb({subprocessStdout:o,subprocess:t,binary:i,shouldEncode:!0,encoding:e,preserveNewlines:s});return Fbe(a,o,t)},Fbe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var B6=(t,{encoding:e})=>{let r=O6();t.readable=M6.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=k6.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=F6.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=zI.bind(void 0,t,e),t[Symbol.asyncIterator]=zI.bind(void 0,t,e,{})};var $6=(t,e)=>{for(let[r,n]of $be){let s=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:s})}},Bbe=(async()=>{})().constructor.prototype,$be=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(Bbe,t)]);var G6=(t,e,r,n)=>{let{file:s,commandArguments:i,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=Hbe(t,e,r),{subprocess:f,promise:h}=jbe({file:s,commandArguments:i,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=rb.bind(void 0,{source:f,sourcePromise:h,boundOptions:{},createNested:n}),$6(f,h),Rs.set(f,{options:u,fileDescriptors:d}),f},Hbe=(t,e,r)=>{let{command:n,escapedCommand:s,startTime:i,verboseInfo:o}=fT(t,e,r),{file:a,commandArguments:c,options:l}=NT(t,e,r),u=Vbe(l),d=J4(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:s,startTime:i,verboseInfo:o,options:u,fileDescriptors:d}},Vbe=({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}},jbe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:s,command:i,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=qbe(...MT(t,e,r))}catch(p){return Y4({error:p,command:i,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:s})}let l=new AbortController;Gbe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];a6(c,a,l),l6(c,r,l);let d={},f=ws();c.kill=Az.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=A6(c,r),B6(c,r),j4(c,r);let h=Wbe({subprocess:c,options:r,startTime:n,verboseInfo:s,fileDescriptors:a,originalStreams:u,command:i,escapedCommand:o,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:h}},Wbe=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:s,originalStreams:i,command:o,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,h],p,m,E]=await P6({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:s,originalStreams:i,onInternalError:l,controller:u});u.abort(),l.resolve();let S=p.map((A,G)=>Ti(A,e,G)),b=Ti(m,e,"all"),R=zbe({errorInfo:d,exitCode:f,signal:h,stdio:S,all:b,ipcOutput:E,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Mu(R,n,e)},zbe=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:s,ipcOutput:i,context:o,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?am({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 Cs,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:s,ipcOutput:i,options:a,startTime:u,isSync:!1}):GT({command:c,escapedCommand:l,stdio:n,all:s,ipcOutput:i,options:a,startTime:u});var ab=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,s])=>[n,Ybe(n,t[n],s)]));return{...t,...r}},Ybe=(t,e,r)=>Kbe.has(t)&&ot(e)&&ot(r)?{...e,...r}:r,Kbe=new Set(["env",...AO]);var Io=(t,e,r,n)=>{let s=(o,a,c)=>Io(o,a,r,c),i=(...o)=>Xbe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:s},...o);return n!==void 0&&n(i,s,e),i},Xbe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:s},i,...o)=>{if(ot(i))return s(t,ab(r,i),n);let{file:a,commandArguments:c,options:l,isSync:u}=Qbe({mapArguments:t,firstArgument:i,nextArguments:o,deepOptions:e,boundOptions:r});return u?B4(a,c,l):G6(a,c,l,s)},Qbe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:s})=>{let i=J3(e)?Z3(e,r):[e,...r],[o,a,c]=tT(...i),l=ab(ab(n,s),c),{file:u=o,commandArguments:d=a,options:f=l,isSync:h=!1}=t({file:o,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:h}};var q6=({file:t,commandArguments:e})=>V6(t,e),H6=({file:t,commandArguments:e})=>({...V6(t,e),isSync:!0}),V6=(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]=Jbe(t);return{file:r,commandArguments:n}},Jbe=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(Zbe)){let s=r.at(-1);s&&s.endsWith("\\")?r[r.length-1]=`${s.slice(0,-1)} ${n}`:r.push(n)}return r},Zbe=/ +/g;var j6=(t,e,r)=>{t.sync=e(eAe,r),t.s=t.sync},W6=({options:t})=>z6(t),eAe=({options:t})=>({...z6(t),isSync:!0}),z6=t=>({options:{...tAe(t),...t}}),tAe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Y6={preferLocal:!0};var K6=Io(()=>({})),XZe=Io(()=>({isSync:!0})),X6=Io(q6),QZe=Io(H6),JZe=Io(oY),ZZe=Io(W6,{},Y6,j6),{sendMessage:eet,getOneMessage:tet,getEachMessage:ret,getCancelSignal:net}=W4();var rAe=!1;var Ps=()=>rAe;var pm=null,Q6=t=>(pm&&pm.destroy(),pm=new bi({totalAllowedTime:t}),pm),J6=()=>pm;var bi=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:s=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(s&&Ps())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let i=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),o=null,a=null;n!==void 0&&(a=new Promise((u,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 Ky({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{Ee.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),i(),o&&clearTimeout(o)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var Z6={name:"@netlify/agent-runner-cli",type:"module",version:"1.138.0-pty.2",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js","agent-runner-pty":"./dist/pty-client.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","@types/ws":"^8.5.12","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"2.1.197","@anthropic-ai/sdk":"0.91.1","@google/gemini-cli":"0.42.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.1.5","@netlify/otel":"^6.0.3","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.128.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.8.5",minimist:"^1.2.8","node-pty":"1.1.0",openai:"6.34.0",ws:"8.21.0"}};var oAe=sAe(import.meta.url),aAe=Ai.dirname(oAe),cAe=iAe(import.meta.url),Uu=me("shell"),YI=new Set,e8={preferLocal:!0},kr=(t,e,r)=>{let[n,s]=lAe(e,r),i={...e8,...s},o=K6(t,n,i);r8(o,i),i8(o);let a=r?.idleTimeout;return a&&a>0&&s8(o,a),o},t8=(t,e)=>{let r={...e8,...e},n=X6(t,r);return r8(n,r),i8(n),e?.idleTimeout&&e.idleTimeout>0&&s8(n,e.idleTimeout),n},lAe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},r8=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0)return;if(vi.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new jp).pipe(vi.stdout),t.stderr?.pipe(new jp).pipe(vi.stderr);return}t.stdout?.pipe(vi.stdout),t.stderr?.pipe(vi.stderr)},KI=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(vi.kill(-t.pid,e),Uu.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Uu.error("Error killing process:",r),!1}},n8=t=>KI(t,"SIGKILL"),s8=(t,e)=>{let r=null,n=()=>{Uu.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),KI(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Uu.log(`Force killing idle process ${t.pid}`),n8(t))},5e3)},s=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};s(),t.stdout?.on("data",s),t.stderr?.on("data",s);let i=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",i),t.on("error",i)},i8=t=>{YI.add(t);let e=J6();if(e){let r=e.onTimesUp(()=>{Uu.log(`Global timer expired, killing process ${t.pid}`),KI(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Uu.log(`Force killing process ${t.pid} after timeout`),n8(t))},5e3)});t.on("exit",()=>{YI.delete(t),r()}),t.on("error",()=>{YI.delete(t),r()})}};function No(t,e){if(!vi.env.NETLIFY_LOCAL_MODE)try{let s=cAe.resolve(Z6.name),i=Ai.dirname(s);for(;i!==Ai.dirname(i);){let o=Ai.dirname(i);if(Ai.basename(o)==="node_modules"){let a=Ai.join(o,".bin",e);if(cb.existsSync(a))return a;break}i=o}}catch(s){console.error("Could not resolve package.json",s)}if(vi.env.NODE_PATH){let s=Ai.join(vi.env.NODE_PATH,".bin",e);if(cb.existsSync(s))return s}let r=Ai.join(t,"node_modules",".bin",e);if(cb.existsSync(r))return r;let n=Ai.join(aAe,"..","node_modules",".bin",e);if(cb.existsSync(n))return n}var uAe=me("utils"),dAe=t=>new Promise(e=>{setTimeout(e,t)});var lb=(t,e=3e3)=>{let r=!1,n=null,s=[],i=null,o=(...a)=>{if(r)return n=a,new Promise(u=>{s.push(u)});r=!0;let c,l=new Promise(u=>{c=u});return i=(async()=>{await Promise.resolve();let u=await t(...a);for(c(u);;){if(await dAe(e),!n)return r=!1,i=null,u;let d=n,f=s;n=null,s=[],u=await t(...d),f.forEach(h=>{h(u)})}})(),l};return o.flush=async()=>{if((r||n)&&i)return await i,o.flush()},o.cancel=()=>{n=null,s.forEach(a=>a(void 0)),s=[]},o},Fu=(t,e,r=!1)=>{let n=null,s=null,i=null,o=function(...a){s=a,i=this;let c=r&&!n;clearTimeout(n),n=setTimeout(()=>{n=null,r||(t.apply(i,s),s=null,i=null)},e),c&&(t.apply(i,s),s=null,i=null)};return o.cancel=()=>{clearTimeout(n),n=null,s=null,i=null},o.flush=()=>{if(n){clearTimeout(n);let a=s,c=i;n=null,s=null,i=null,t.apply(c,a)}},o},o8=(t,e=!0,r)=>{if(t)try{return JSON.parse(t)}catch(n){e&&(r?.error?r.error("Could not parse JSON",n):uAe.error("Could not parse JSON",n))}},fAe=t=>t.charAt(0).toUpperCase()+t.slice(1),Mo=t=>t.split("-").map(e=>e.length===2?e.toUpperCase():fAe(e)).join(" ");function gc(t,e){e&&t.log(`Skill invoked: ${e}`)}var a8=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),c8=(t,e,r=!1)=>{if(r)return;let n=60,s=55,i=".netlify.app",o="agent-",a=6;if(!e)return`${o}${t.slice(0,a)}`;let c=`--${e}${i}`;if(c.length>s)return"";let l=n-c.length;if(l<=0)return"";if(l>=o.length+a){let u=Math.min(l-o.length,t.length);return`${o}${t.slice(0,u)}`}return t.slice(0,l)};var XI=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}},hAe=1e4,QI=(t,e=hAe)=>{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 l8}from"buffer";import pAe from"path";var u8=me("repo"),gr=(t,e={})=>kr("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),f8=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{u8.info("Getting runner diffs");let n=await gAe(r),{hasChanges:s}=n,{status:i}=n;if(!s)return{hasChanges:!1};if(!e){let m=SAe(i);await EAe(m,r)}u8.info("Changes after processing"),await ZI(r);let o=await tN(i,r);if(await JI(o,r),s=await _Ae(r),!s)return{hasChanges:!1,ignored:o};await gr(["commit","-m","Agent runner"],{cwd:r});let a={stdio:["ignore","pipe","pipe"],cwd:r},c=await gr(["diff",t.runSha,"HEAD"],a),l=String(c.stdout??"");if(s=!!l,!s)return await d8(r),{hasChanges:!1,ignored:o};let u=await gr(["diff",t.runSha,"HEAD","--binary"],a),d=String(u.stdout??""),f,h;if(t.sha){let m=await gr(["diff",t.sha,"HEAD"],a);f=String(m.stdout??"");let E=await gr(["diff",t.sha,"HEAD","--binary"],a),S=String(E.stdout??"");f!==S&&(h=l8.from(S).toString("base64"))}await d8(r);let p={hasChanges:!0,diff:l,resultDiff:f,ignored:o};return l!==d&&(p.diffBinary=l8.from(d).toString("base64")),h&&(p.resultDiffBinary=h),p},d8=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await gr(["reset","--soft","HEAD~1"],{cwd:t})},JI=async(t=[],e=process.cwd())=>{await gr(["add",".",...t],{cwd:e})},ZI=async(t=process.cwd())=>{let e=await gr(["status","-s"],{cwd:t});return String(e.stdout??"")},h8=/.. (.+)?\.log$/,mAe=[h8],gAe=async(t=process.cwd())=>{let e=await ZI(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
89
89
  `).filter(s=>mAe.some(o=>o instanceof RegExp?o.test(s):s===o)?!1:s[1]?.trim()!=="")).length!==0,status:e}},_Ae=async(t=process.cwd())=>{try{return await gr(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},eN=async(t=process.cwd())=>{let{stdout:e}=await gr(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},p8=async(t=process.cwd())=>{let{stdout:e}=await gr(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},tN=async(t,e=process.cwd())=>{t||=await ZI(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(`
90
90
  `).forEach(s=>{r.forEach(o=>{let a=s===`?? ${o}`,c=s.startsWith(`?? ${o}/`)||s.startsWith(`?? ${o}${pAe.sep}`);(a||c)&&n.push(`:!${o}`)});let i=s.match(h8)?.[1];i&&n.push(`:!${i}.log`)}),n},rN=async(t=process.cwd())=>{await gr(["reset","--hard","HEAD"],{cwd:t})},m8=async(t=process.cwd())=>{let e=await gr(["clean","-fd","-e",".netlify"],{stdio:["ignore","pipe","pipe"],cwd:t});return String(e.stdout??"").split(`
91
91
  `).filter(r=>r.startsWith("Removing ")).map(r=>r.slice(9))},SAe=t=>{let e=t.split(`
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __cr } from 'node:module'; import { fileURLToPath as __ftu } from 'node:url'; import { dirname as __dnn } from 'node:path'; const require = __cr(import.meta.url); const __filename = __ftu(import.meta.url); const __dirname = __dnn(__filename);
3
- var q=Object.create;var U=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var Q=Object.getOwnPropertyNames;var Z=Object.getPrototypeOf,G=Object.prototype.hasOwnProperty;var V=(t,o)=>()=>(o||t((o={exports:{}}).exports,o),o.exports);var X=(t,o,e,f)=>{if(o&&typeof o=="object"||typeof o=="function")for(let c of Q(o))!G.call(t,c)&&c!==e&&U(t,c,{get:()=>o[c],enumerable:!(f=H(o,c))||f.enumerable});return t};var x=(t,o,e)=>(e=t!=null?q(Z(t)):{},X(o||!t||!t.__esModule?U(e,"default",{value:t,enumerable:!0}):e,t));var g=V((lt,W)=>{"use strict";function y(t,o){var e=t;o.slice(0,-1).forEach(function(c){e=e[c]||{}});var f=o[o.length-1];return f in e}function Y(t){return typeof t=="number"||/^0x[0-9a-f]+$/i.test(t)?!0:/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(t)}function z(t,o){return o==="constructor"&&typeof t[o]=="function"||o==="__proto__"}W.exports=function(t,o){o||(o={});var e={bools:{},strings:{},unknownFn:null};typeof o.unknown=="function"&&(e.unknownFn=o.unknown),typeof o.boolean=="boolean"&&o.boolean?e.allBools=!0:[].concat(o.boolean).filter(Boolean).forEach(function(n){e.bools[n]=!0});var f={};function c(n){return f[n].some(function(l){return e.bools[l]})}Object.keys(o.alias||{}).forEach(function(n){f[n]=[].concat(o.alias[n]),f[n].forEach(function(l){f[l]=[n].concat(f[n].filter(function(b){return l!==b}))})}),[].concat(o.string).filter(Boolean).forEach(function(n){e.strings[n]=!0,f[n]&&[].concat(f[n]).forEach(function(l){e.strings[l]=!0})});var _=o.default||{},m={_:[]};function J(n,l){return e.allBools&&/^--[^=]+$/.test(l)||e.strings[n]||e.bools[n]||f[n]}function $(n,l,b){for(var i=n,T=0;T<l.length-1;T++){var w=l[T];if(z(i,w))return;i[w]===void 0&&(i[w]={}),(i[w]===Object.prototype||i[w]===Number.prototype||i[w]===String.prototype)&&(i[w]={}),i[w]===Array.prototype&&(i[w]=[]),i=i[w]}var O=l[l.length-1];z(i,O)||((i===Object.prototype||i===Number.prototype||i===String.prototype)&&(i={}),i===Array.prototype&&(i=[]),i[O]===void 0||e.bools[O]||typeof i[O]=="boolean"?i[O]=b:Array.isArray(i[O])?i[O].push(b):i[O]=[i[O],b])}function d(n,l,b){if(!(b&&e.unknownFn&&!J(n,b)&&e.unknownFn(b)===!1)){var i=!e.strings[n]&&Y(l)?Number(l):l;$(m,n.split("."),i),(f[n]||[]).forEach(function(T){$(m,T.split("."),i)})}}Object.keys(e.bools).forEach(function(n){d(n,_[n]===void 0?!1:_[n])});var N=[];t.indexOf("--")!==-1&&(N=t.slice(t.indexOf("--")+1),t=t.slice(0,t.indexOf("--")));for(var a=0;a<t.length;a++){var r=t[a],s,h;if(/^--.+=/.test(r)){var R=r.match(/^--([^=]+)=([\s\S]*)$/);s=R[1];var P=R[2];e.bools[s]&&(P=P!=="false"),d(s,P,r)}else if(/^--no-.+/.test(r))s=r.match(/^--no-(.+)/)[1],d(s,!1,r);else if(/^--.+/.test(r))s=r.match(/^--(.+)/)[1],h=t[a+1],h!==void 0&&!/^(-|--)[^-]/.test(h)&&!e.bools[s]&&!e.allBools&&(!f[s]||!c(s))?(d(s,h,r),a+=1):/^(true|false)$/.test(h)?(d(s,h==="true",r),a+=1):d(s,e.strings[s]?"":!0,r);else if(/^-[^-]+/.test(r)){for(var v=r.slice(1,-1).split(""),A=!1,p=0;p<v.length;p++){if(h=r.slice(p+2),h==="-"){d(v[p],h,r);continue}if(/[A-Za-z]/.test(v[p])&&h[0]==="="){d(v[p],h.slice(1),r),A=!0;break}if(/[A-Za-z]/.test(v[p])&&/-?\d+(\.\d*)?(e-?\d+)?$/.test(h)){d(v[p],h,r),A=!0;break}if(v[p+1]&&v[p+1].match(/\W/)){d(v[p],r.slice(p+2),r),A=!0;break}else d(v[p],e.strings[v[p]]?"":!0,r)}s=r.slice(-1)[0],!A&&s!=="-"&&(t[a+1]&&!/^(-|--)[^-]/.test(t[a+1])&&!e.bools[s]&&(!f[s]||!c(s))?(d(s,t[a+1],r),a+=1):t[a+1]&&/^(true|false)$/.test(t[a+1])?(d(s,t[a+1]==="true",r),a+=1):d(s,e.strings[s]?"":!0,r))}else if((!e.unknownFn||e.unknownFn(r)!==!1)&&m._.push(e.strings._||!Y(r)?r:Number(r)),o.stopEarly){m._.push.apply(m._,t.slice(a+1));break}}return Object.keys(_).forEach(function(n){y(m,n.split("."))||($(m,n.split("."),_[n]),(f[n]||[]).forEach(function(l){$(m,l.split("."),_[n])}))}),o["--"]?m["--"]=N.slice():N.forEach(function(n){m._.push(n)}),m}});var M=x(g(),1);import j from"fs";import k from"path";import u from"process";import B from"ws";var tt=29,et=()=>{try{let t=j.readFileSync(k.join(u.cwd(),".env"),"utf8");for(let o of t.split(`
4
- `)){let e=o.trim();if(!e||e.startsWith("#"))continue;let f=e.indexOf("=");if(f===-1||e.slice(0,f).trim()!=="PTY_COOKIE")continue;let c=e.slice(f+1).trim();if(/^(".*"|'.*')$/.test(c)&&(c=c.slice(1,-1)),c)return c}}catch{}return u.env.PTY_COOKIE||void 0},S=(0,M.default)(u.argv.slice(2),{string:["url","host","port","cwd","model"],boolean:["help"],alias:{h:"help"}}),ot=()=>{u.stdout.write(`
3
+ var Q=Object.create;var g=Object.defineProperty;var Z=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var V=Object.getPrototypeOf,X=Object.prototype.hasOwnProperty;var x=(t,o)=>()=>(o||t((o={exports:{}}).exports,o),o.exports);var y=(t,o,e,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let f of G(o))!X.call(t,f)&&f!==e&&g(t,f,{get:()=>o[f],enumerable:!(i=Z(o,f))||i.enumerable});return t};var j=(t,o,e)=>(e=t!=null?Q(V(t)):{},y(o||!t||!t.__esModule?g(e,"default",{value:t,enumerable:!0}):e,t));var Y=x((lt,W)=>{"use strict";function k(t,o){var e=t;o.slice(0,-1).forEach(function(f){e=e[f]||{}});var i=o[o.length-1];return i in e}function z(t){return typeof t=="number"||/^0x[0-9a-f]+$/i.test(t)?!0:/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(t)}function K(t,o){return o==="constructor"&&typeof t[o]=="function"||o==="__proto__"}W.exports=function(t,o){o||(o={});var e={bools:{},strings:{},unknownFn:null};typeof o.unknown=="function"&&(e.unknownFn=o.unknown),typeof o.boolean=="boolean"&&o.boolean?e.allBools=!0:[].concat(o.boolean).filter(Boolean).forEach(function(n){e.bools[n]=!0});var i={};function f(n){return i[n].some(function(u){return e.bools[u]})}Object.keys(o.alias||{}).forEach(function(n){i[n]=[].concat(o.alias[n]),i[n].forEach(function(u){i[u]=[n].concat(i[n].filter(function(S){return u!==S}))})}),[].concat(o.string).filter(Boolean).forEach(function(n){e.strings[n]=!0,i[n]&&[].concat(i[n]).forEach(function(u){e.strings[u]=!0})});var T=o.default||{},m={_:[]};function q(n,u){return e.allBools&&/^--[^=]+$/.test(u)||e.strings[n]||e.bools[n]||i[n]}function _(n,u,S){for(var s=n,C=0;C<u.length-1;C++){var v=u[C];if(K(s,v))return;s[v]===void 0&&(s[v]={}),(s[v]===Object.prototype||s[v]===Number.prototype||s[v]===String.prototype)&&(s[v]={}),s[v]===Array.prototype&&(s[v]=[]),s=s[v]}var O=u[u.length-1];K(s,O)||((s===Object.prototype||s===Number.prototype||s===String.prototype)&&(s={}),s===Array.prototype&&(s=[]),s[O]===void 0||e.bools[O]||typeof s[O]=="boolean"?s[O]=S:Array.isArray(s[O])?s[O].push(S):s[O]=[s[O],S])}function d(n,u,S){if(!(S&&e.unknownFn&&!q(n,S)&&e.unknownFn(S)===!1)){var s=!e.strings[n]&&z(u)?Number(u):u;_(m,n.split("."),s),(i[n]||[]).forEach(function(C){_(m,C.split("."),s)})}}Object.keys(e.bools).forEach(function(n){d(n,T[n]===void 0?!1:T[n])});var N=[];t.indexOf("--")!==-1&&(N=t.slice(t.indexOf("--")+1),t=t.slice(0,t.indexOf("--")));for(var a=0;a<t.length;a++){var r=t[a],l,p;if(/^--.+=/.test(r)){var U=r.match(/^--([^=]+)=([\s\S]*)$/);l=U[1];var P=U[2];e.bools[l]&&(P=P!=="false"),d(l,P,r)}else if(/^--no-.+/.test(r))l=r.match(/^--no-(.+)/)[1],d(l,!1,r);else if(/^--.+/.test(r))l=r.match(/^--(.+)/)[1],p=t[a+1],p!==void 0&&!/^(-|--)[^-]/.test(p)&&!e.bools[l]&&!e.allBools&&(!i[l]||!f(l))?(d(l,p,r),a+=1):/^(true|false)$/.test(p)?(d(l,p==="true",r),a+=1):d(l,e.strings[l]?"":!0,r);else if(/^-[^-]+/.test(r)){for(var w=r.slice(1,-1).split(""),A=!1,h=0;h<w.length;h++){if(p=r.slice(h+2),p==="-"){d(w[h],p,r);continue}if(/[A-Za-z]/.test(w[h])&&p[0]==="="){d(w[h],p.slice(1),r),A=!0;break}if(/[A-Za-z]/.test(w[h])&&/-?\d+(\.\d*)?(e-?\d+)?$/.test(p)){d(w[h],p,r),A=!0;break}if(w[h+1]&&w[h+1].match(/\W/)){d(w[h],r.slice(h+2),r),A=!0;break}else d(w[h],e.strings[w[h]]?"":!0,r)}l=r.slice(-1)[0],!A&&l!=="-"&&(t[a+1]&&!/^(-|--)[^-]/.test(t[a+1])&&!e.bools[l]&&(!i[l]||!f(l))?(d(l,t[a+1],r),a+=1):t[a+1]&&/^(true|false)$/.test(t[a+1])?(d(l,t[a+1]==="true",r),a+=1):d(l,e.strings[l]?"":!0,r))}else if((!e.unknownFn||e.unknownFn(r)!==!1)&&m._.push(e.strings._||!z(r)?r:Number(r)),o.stopEarly){m._.push.apply(m._,t.slice(a+1));break}}return Object.keys(T).forEach(function(n){k(m,n.split("."))||(_(m,n.split("."),T[n]),(i[n]||[]).forEach(function(u){_(m,u.split("."),T[n])}))}),o["--"]?m["--"]=N.slice():N.forEach(function(n){m._.push(n)}),m}});var D=j(Y(),1);import tt from"fs";import et from"path";import c from"process";import I from"ws";var ot=29,nt=()=>{try{let t=tt.readFileSync(et.join(c.cwd(),".env"),"utf8");for(let o of t.split(`
4
+ `)){let e=o.trim();if(!e||e.startsWith("#"))continue;let i=e.indexOf("=");if(i===-1||e.slice(0,i).trim()!=="PTY_COOKIE")continue;let f=e.slice(i+1).trim();if(/^(".*"|'.*')$/.test(f)&&(f=f.slice(1,-1)),f)return f}}catch{}return c.env.PTY_COOKIE||void 0},b=(0,D.default)(c.argv.slice(2),{string:["url","host","port","cwd","model"],boolean:["help"],alias:{h:"help"}}),rt=()=>{c.stdout.write(`
5
5
  agent-runner-pty - Interactive terminal client for a remote Claude PTY
6
6
 
7
7
  USAGE:
@@ -21,9 +21,10 @@ AUTH:
21
21
 
22
22
  QUIT:
23
23
  Exit Claude normally (e.g. /exit), or press Ctrl-] to force quit.
24
- `)};S.help&&(ot(),u.exit(0));var nt=()=>{if(S.url)return S.url;let t=S.host||"localhost",o=S.port||"8888",e=new URLSearchParams;return S.cwd&&e.set("cwd",S.cwd),S.model&&e.set("model",S.model),e.set("cols",String(u.stdout.columns||80)),e.set("rows",String(u.stdout.rows||24)),`ws://${t}:${o}/pty?${e.toString()}`},rt=nt(),L=et(),C=new B(rt,L?{headers:{Cookie:`PTY_COOKIE=${L}`}}:void 0),E=u.stdin,F=!1,I=0,K=()=>{F&&E.isTTY&&(E.setRawMode(!1),F=!1),E.pause()},D=t=>{K(),E.removeAllListeners("data"),u.stdout.removeAllListeners("resize"),u.exit(t)},it=()=>{C.readyState===B.OPEN&&C.send(JSON.stringify({type:"resize",cols:u.stdout.columns||80,rows:u.stdout.rows||24}))},st=t=>{if(t.length===1&&t[0]===tt){D(0);return}C.readyState===B.OPEN&&C.send(JSON.stringify({type:"stdin",data:t.toString("utf8")}))};C.on("open",()=>{E.isTTY&&(E.setRawMode(!0),F=!0),E.resume(),E.on("data",st),u.stdout.on("resize",it)});C.on("message",(t,o)=>{if(o){u.stdout.write(t);return}try{let e=JSON.parse(t.toString());e.type==="exit"?I=e.code??0:e.type==="error"&&(K(),u.stderr.write(`
24
+ `)};b.help&&(rt(),c.exit(0));var st=()=>{if(b.url)return b.url;let t=b.host||"localhost",o=/^(localhost|127\.0\.0\.1|\[::1\])$/.test(t),e=o?"ws":"wss",i=b.port?`${t}:${b.port}`:o?`${t}:8888`:t,f=new URLSearchParams;return b.cwd&&f.set("cwd",b.cwd),b.model&&f.set("model",b.model),f.set("cols",String(c.stdout.columns||80)),f.set("rows",String(c.stdout.rows||24)),`${e}://${i}/pty?${f.toString()}`},H=st(),L=nt(),$=new I(H,{followRedirects:!0,...L?{headers:{Cookie:`${L}`}}:{}}),E=c.stdin,F=!1,B=0,R=()=>{F&&E.isTTY&&(E.setRawMode(!1),F=!1),E.pause()},J=t=>{R(),E.removeAllListeners("data"),c.stdout.removeAllListeners("resize"),c.exit(t)},M=()=>{$.readyState===I.OPEN&&$.send(JSON.stringify({type:"resize",cols:c.stdout.columns||80,rows:c.stdout.rows||24}))},it=t=>{if(t.length===1&&t[0]===ot){J(0);return}$.readyState===I.OPEN&&$.send(JSON.stringify({type:"stdin",data:t.toString("utf8")}))};$.on("open",()=>{E.isTTY&&(E.setRawMode(!0),F=!0),E.resume(),E.on("data",it),c.stdout.on("resize",M),M()});$.on("message",(t,o)=>{if(o){c.stdout.write(t);return}try{let e=JSON.parse(t.toString());e.type==="exit"?B=e.code??0:e.type==="error"&&(R(),c.stderr.write(`
25
25
  [agent-runner-pty] ${e.message??"server error"}
26
- `),I=1)}catch{}});C.on("close",()=>{D(I)});C.on("error",t=>{K(),u.stderr.write(`
26
+ `),B=1)}catch{}});$.on("close",()=>{J(B)});$.on("error",t=>{R(),c.stderr.write(`
27
27
  [agent-runner-pty] connection error: ${t.message}
28
- `),u.exit(1)});
28
+ `),/response: 3\d\d/.test(t.message)&&H.startsWith("ws://")&&c.stderr.write(`[agent-runner-pty] hint: this host redirects to HTTPS \u2014 use wss:// instead of ws://
29
+ `),c.exit(1)});
29
30
  //# sourceMappingURL=pty-client.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@netlify/agent-runner-cli",
3
3
  "type": "module",
4
- "version": "1.138.0-pty.1",
4
+ "version": "1.138.0-pty.2",
5
5
  "description": "CLI tool for running Netlify agents",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",