@netlify/agent-runner-cli 1.189.2 → 1.189.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin-local.js +2 -2
- package/dist/bin.js +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/bin-local.js
CHANGED
|
@@ -143,7 +143,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
143
143
|
`,LF:`
|
|
144
144
|
`,concatBytes:qU},dVe=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},fVe={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:dVe};import{Buffer as pVe}from"buffer";var Fae=(t,e)=>t?void 0:hVe.bind(void 0,e),hVe=function*(t,e){if(typeof e!="string"&&!dr(e)&&!pVe.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},zae=(t,e)=>t?mVe.bind(void 0,e):gVe.bind(void 0,e),mVe=function*(t,e){jae(t,e),yield e},gVe=function*(t,e){if(jae(t,e),typeof e!="string"&&!dr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},jae=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
145
145
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
146
|
-
if (condition) { yield value; }`)};import{Buffer as _Ve}from"buffer";import{StringDecoder as yVe}from"string_decoder";var $R=(t,e,r)=>{if(r)return;if(t)return{transform:SVe.bind(void 0,new TextEncoder)};let n=new yVe(e);return{transform:EVe.bind(void 0,n),final:vVe.bind(void 0,n)}},SVe=function*(t,e){_Ve.isBuffer(e)?yield _a(e):typeof e=="string"?yield t.encode(e):yield e},EVe=function*(t,e){yield dr(e)?t.write(e):e},vVe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Bae}from"util";var VU=Bae(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),LR=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=bVe}=e[r];for await(let i of n(t))yield*LR(i,e,r+1)},qae=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*TVe(r,Number(e),t)},TVe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*LR(n,r,e+1)},Gae=Bae(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),bVe=function*(t){yield t};var HU=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Vae=(t,e)=>[...e.flatMap(r=>[...Gu(r,t,0)]),...Qy(t)],Gu=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=AVe}=e[r];for(let i of n(t))yield*Gu(i,e,r+1)},Qy=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*wVe(r,Number(e),t)},wVe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Gu(n,r,e+1)},AVe=function*(t){yield t};var WU=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Wae(t,s,o),l=qu(e),u=qu(r),d=l?VU.bind(void 0,LR,a):HU.bind(void 0,Gu),f=l||u?VU.bind(void 0,qae,a):HU.bind(void 0,Qy),p=l||u?Gae.bind(void 0,a):void 0;return{stream:new xVe({writableObjectMode:n,writableHighWaterMark:Hae(n),readableObjectMode:i,readableHighWaterMark:Hae(i),transform(m,g,_){d([m,c,0],this,_)},flush(m){f([c],this,m)},destroy:p})}},UR=(t,e,r,n)=>{let i=e.filter(({type:s})=>s==="generator"),o=n?i.reverse():i;for(let{value:s,optionName:a}of o){let c=Wae(s,r,a);t=Vae(c,t)}return t},Wae=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Fae(n,a)},$R(r,s,n),DR(r,o,n,c),{transform:t,final:e},{transform:zae(i,a)},Uae({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Yae=(t,e)=>{for(let r of RVe(t))CVe(t,r,e)},RVe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),CVe=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Lc[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>IVe(a,n));r.input=qy(s)},IVe=(t,e)=>{let r=UR(t,e,"utf8",!0);return PVe(r),qy(r)},PVe=t=>{let e=t.find(r=>typeof r!="string"&&!dr(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 MVe,appendFileSync as DVe}from"fs";var FR=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Dp(r,n)&&!ii.has(e)&&OVe(n)&&(t.some(({type:i,value:o})=>i==="native"&&NVe.has(o))||t.every(({type:i})=>ki.has(i))),OVe=t=>t===1||t===2,NVe=new Set(["pipe","overlapped"]),Kae=async(t,e,r,n)=>{for await(let i of t)kVe(e)||Jae(i,r,n)},Zae=(t,e,r)=>{for(let n of t)Jae(n,e,r)},kVe=t=>t._readableState.pipes.length>0,Jae=(t,e,r)=>{let n=Qx(t);us({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Xae=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,l)=>$Ve({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},$Ve=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=Qse(t,o,d),p=_a(f),{stdioItems:h,objectMode:m}=e[r],g=LVe([p],h,c,n),{serializedResult:_,finalResult:S=_}=UVe({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});FVe({serializedResult:_,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let T=a[r]?S:void 0;try{return n.error===void 0&&zVe(_,h,i),T}catch(y){return n.error=y,T}},LVe=(t,e,r,n)=>{try{return UR(t,e,r,!1)}catch(i){return n.error=i,t}},UVe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:qy(t)};let s=pie(t,r);return n[o]?{serializedResult:s,finalResult:GU(s,!i[o],e)}:{serializedResult:s}},FVe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!FR({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=GU(t,!1,s);try{Zae(a,e,n)}catch(c){r.error??=c}},zVe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>kR.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?DVe(n,t):(r.add(o),MVe(n,t))}};var Qae=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Ea(e,r,"all")]:Array.isArray(e)?[Ea(t,r,"all"),...e]:dr(t)&&dr(e)?Q1([t,e]):`${t}${e}`};import{once as YU}from"events";var ece=async(t,e)=>{let[r,n]=await jVe(t);return e.isForcefullyTerminated??=!1,[r,n]},jVe=async t=>{let[e,r]=await Promise.allSettled([YU(t,"spawn"),YU(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?tce(t):r.value},tce=async t=>{try{return await YU(t,"exit")}catch{return tce(t)}},rce=async t=>{let[e,r]=await t;if(!BVe(e,r)&&KU(e,r))throw new ho;return[e,r]},BVe=(t,e)=>t===void 0&&e===void 0,KU=(t,e)=>t!==0||e!==null;var nce=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=qVe(t,e,r),s=o?.code==="ETIMEDOUT",a=Xse(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},qVe=(t,e,r)=>t!==void 0?t:KU(e,r)?new ho:void 0;var ice=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=VVe(t,e,r),d=YVe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Vp(d,c,l)},VVe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=tR(t,e,r),a=HVe(r),{file:c,commandArguments:l,options:u}=vR(t,e,a);WVe(u);let d=Mae(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},HVe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,WVe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&zR("ipcInput"),t&&zR("ipc: true"),r&&zR("detached: true"),n&&zR("cancelSignal")},zR=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},YVe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=KVe({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=nce(c,r),{output:h,error:m=l}=Xae({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((S,T)=>Ea(S,r,T)),_=Ea(Qae(h,r),r,"all");return JVe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:_,options:r,command:n,escapedCommand:i,startTime:a})},KVe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Yae(o,r);let a=ZVe(r);return GVe(...TR(t,e,a))}catch(a){return Gp({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},ZVe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:IR(e)}),JVe=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?PR({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):Xy({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as UHe}from"events";import{spawn as FHe}from"child_process";import lce from"process";import{once as ZU,on as XVe}from"events";var oce=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Up({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:mR(t)}),QVe({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),QVe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{dR(e,i);let o=$c(t,e,r),s=new AbortController;try{return await Promise.race([e4e(o,n,s),t4e(o,r,s),r4e(o,r,s)])}catch(a){throw Fp(t),a}finally{s.abort(),fR(e,i)}},e4e=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await ZU(t,"message",{signal:r});return n}for await(let[n]of XVe(t,"message",{signal:r}))if(e(n))return n},t4e=async(t,e,{signal:r})=>{await ZU(t,"disconnect",{signal:r}),Voe(e)},r4e=async(t,e,{signal:r})=>{let[n]=await ZU(t,"strict:error",{signal:r});throw cR(n,e)};import{once as ace,on as n4e}from"events";var cce=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>JU({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),JU=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Up({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:mR(t)}),dR(e,o);let s=$c(t,e,r),a=new AbortController,c={};return i4e(t,s,a),o4e({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),s4e({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},i4e=async(t,e,r)=>{try{await ace(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},o4e=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await ace(t,"strict:error",{signal:r.signal});n.error=cR(i,e),r.abort()}catch{}},s4e=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of n4e(r,"message",{signal:o.signal}))sce(s),yield c}catch{sce(s)}finally{o.abort(),fR(e,a),n||Fp(t),i&&await t}},sce=({error:t})=>{if(t)throw t};var uce=(t,{ipc:e})=>{Object.assign(t,fce(t,!1,e))},dce=()=>{let t=lce,e=!0,r=lce.channel!==void 0;return{...fce(t,e,r),getCancelSignal:yse.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},fce=(t,e,r)=>({sendMessage:SR.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:oce.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:cce.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as a4e}from"child_process";import{PassThrough as c4e,Readable as l4e,Writable as u4e,Duplex as d4e}from"stream";var pce=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{jU(n);let a=new a4e;f4e(a,n),Object.assign(a,{readable:p4e,writable:h4e,duplex:m4e});let c=Gp({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=g4e(c,s,i);return{subprocess:a,promise:l}},f4e=(t,e)=>{let r=eS(),n=eS(),i=eS(),o=Array.from({length:e.length-3},eS),s=eS(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},eS=()=>{let t=new c4e;return t.end(),t},p4e=()=>new l4e({read(){}}),h4e=()=>new u4e({write(){}}),m4e=()=>new d4e({read(){},write(){}}),g4e=async(t,e,r)=>Vp(t,e,r);import{createReadStream as hce,createWriteStream as mce}from"fs";import{Buffer as _4e}from"buffer";import{Readable as tS,Writable as y4e,Duplex as S4e}from"stream";var _ce=(t,e)=>MR(E4e,t,e,!1),rS=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Lc[t]}.`)},gce={fileNumber:rS,generator:WU,asyncGenerator:WU,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:S4e.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},E4e={input:{...gce,fileUrl:({value:t})=>({stream:hce(t)}),filePath:({value:{file:t}})=>({stream:hce(t)}),webStream:({value:t})=>({stream:tS.fromWeb(t)}),iterable:({value:t})=>({stream:tS.from(t)}),asyncIterable:({value:t})=>({stream:tS.from(t)}),string:({value:t})=>({stream:tS.from(t)}),uint8Array:({value:t})=>({stream:tS.from(_4e.from(t))})},output:{...gce,fileUrl:({value:t})=>({stream:mce(t)}),filePath:({value:{file:t,append:e}})=>({stream:mce(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:y4e.fromWeb(t)}),iterable:rS,asyncIterable:rS,string:rS,uint8Array:rS}};import{on as v4e,once as yce}from"events";import{PassThrough as T4e,getDefaultHighWaterMark as b4e}from"stream";import{finished as vce}from"stream/promises";function Vu(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)QU(i);let e=t.some(({readableObjectMode:i})=>i),r=w4e(t,e),n=new XU({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var w4e=(t,e)=>{if(t.length===0)return b4e(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},XU=class extends T4e{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(QU(e),this.#e.has(e))return;this.#e.add(e),this.#n??=A4e(this,this.#e,this.#o);let r=C4e({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#o});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(QU(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},A4e=async(t,e,r)=>{jR(t,Sce);let n=new AbortController;try{await Promise.race([x4e(t,n),R4e(t,e,r,n)])}finally{n.abort(),jR(t,-Sce)}},x4e=async(t,{signal:e})=>{try{await vce(t,{signal:e,cleanup:!0})}catch(r){throw Tce(t,r),r}},R4e=async(t,e,r,{signal:n})=>{for await(let[i]of v4e(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},QU=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},C4e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{jR(t,Ece);let a=new AbortController;try{await Promise.race([I4e(o,e,a),P4e({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),O4e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),jR(t,-Ece)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?eF(t):N4e(t))},I4e=async(t,e,{signal:r})=>{try{await t,r.aborted||eF(e)}catch(n){r.aborted||Tce(e,n)}},P4e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await vce(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;bce(s)?i.add(e):wce(t,s)}},O4e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await yce(t,i,{signal:o}),!t.readable)return yce(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},N4e=t=>{t.writable&&t.end()},Tce=(t,e)=>{bce(e)?eF(t):wce(t,e)},bce=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",eF=t=>{(t.readable||t.writable)&&t.destroy()},wce=(t,e)=>{t.destroyed||(t.once("error",k4e),t.destroy(e))},k4e=()=>{},jR=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Sce=2,Ece=1;import{finished as Ace}from"stream/promises";var Wp=(t,e)=>{t.pipe(e),M4e(t,e),D4e(t,e)},M4e=async(t,e)=>{if(!(po(t)||po(e))){try{await Ace(t,{cleanup:!0,readable:!0,writable:!1})}catch{}tF(e)}},tF=t=>{t.writable&&t.end()},D4e=async(t,e)=>{if(!(po(t)||po(e))){try{await Ace(e,{cleanup:!0,readable:!1,writable:!0})}catch{}rF(t)}},rF=t=>{t.readable&&t.destroy()};var xce=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:o,direction:s}]of Object.entries(e)){for(let{stream:a}of o.filter(({type:c})=>ki.has(c)))$4e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!ki.has(c)))U4e({subprocess:t,stream:a,direction:s,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,o]of n.entries()){let s=o.length===1?o[0]:Vu(o);Wp(s,i)}},$4e=(t,e,r,n)=>{r==="output"?Wp(t.stdio[n],e):Wp(e,t.stdio[n]);let i=L4e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},L4e=["stdin","stdout","stderr"],U4e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;F4e(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},F4e=(t,{signal:e})=>{po(t)&&ju(t,z4e,e)},z4e=2;import{addAbortListener as q4e}from"events";var Hu=[];Hu.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Hu.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Hu.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var BR=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",nF=Symbol.for("signal-exit emitter"),iF=globalThis,j4e=Object.defineProperty.bind(Object),oF=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(iF[nF])return iF[nF];j4e(iF,nF,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let o of this.listeners[e])i=o(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},qR=class{},B4e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),sF=class extends qR{onExit(){return()=>{}}load(){}unload(){}},aF=class extends qR{#e=cF.platform==="win32"?"SIGINT":"SIGHUP";#r=new oF;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Hu)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,o=e;if(typeof o.__signal_exit_emitter__=="object"&&typeof o.__signal_exit_emitter__.count=="number"&&(i+=o.__signal_exit_emitter__.count),n.length===i){this.unload();let s=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;s||e.kill(e.pid,a)}};this.#o=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!BR(this.#t))return()=>{};this.#s===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#r.on(n,e),()=>{this.#r.removeListener(n,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#s){this.#s=!0,this.#r.count+=1;for(let e of Hu)try{let r=this.#i[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#s&&(this.#s=!1,Hu.forEach(e=>{let r=this.#i[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#o,this.#r.count-=1)}#a(e){return BR(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#o.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&BR(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let i=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),i}else return n.call(this.#t,e,...r)}},cF=globalThis.process,{onExit:Rce,load:g1t,unload:_1t}=B4e(BR(cF)?new aF(cF):new sF);var Cce=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Rce(()=>{t.kill()});q4e(n,()=>{i()})};var Pce=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=eR(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=G4e(r,n,i),{sourceStream:d,sourceError:f}=H4e(t,l),{options:p,fileDescriptors:h}=fs.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},G4e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=V4e(t,e,...r),a=uR(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},V4e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Ice,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||J1(r)){if(Object.keys(t).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[i,o,s]=Gx(r,...n);return{destination:e(Ice)(i,o,s),pipeOptions:s}}if(fs.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}`)},Ice=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),H4e=(t,e)=>{try{return{sourceStream:zp(t,e)}}catch(r){return{sourceError:r}}};var Nce=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=W4e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw lF({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},W4e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return rF(t),n;if(e!==void 0)return tF(r),e},lF=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Gp({error:t,command:Oce,escapedCommand:Oce,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Oce="source.pipe(destination)";var kce=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:o,value:s=o}]=await t;if(s.pipedFrom.includes(n)||s.pipedFrom.push(n),i==="rejected")throw s;if(e==="rejected")throw n;return s};import{finished as Y4e}from"stream/promises";var Mce=(t,e,r)=>{let n=GR.has(e)?Z4e(t,e):K4e(t,e);return ju(t,X4e,r.signal),ju(e,Q4e,r.signal),J4e(e),n},K4e=(t,e)=>{let r=Vu([t]);return Wp(r,e),GR.set(e,r),r},Z4e=(t,e)=>{let r=GR.get(e);return r.add(t),r},J4e=async t=>{try{await Y4e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}GR.delete(t)},GR=new WeakMap,X4e=2,Q4e=1;import{aborted as eHe}from"util";var Dce=(t,e)=>t===void 0?[]:[tHe(t,e)],tHe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await eHe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw lF({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var VR=(t,...e)=>{if(Jt(e[0]))return VR.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=Pce(t,...e),i=rHe({...n,destination:r});return i.pipe=VR.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},rHe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=nHe(t,i);Nce({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Mce(e,o,d);return await Promise.race([kce(u),...Dce(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},nHe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as uHe}from"timers/promises";import{on as iHe}from"events";import{getDefaultHighWaterMark as oHe}from"stream";var HR=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return sHe(e,s),Lce({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},sHe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},uF=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;aHe(e,s,t);let a=t.readableObjectMode&&!o;return Lce({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},aHe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Lce=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=iHe(t,"data",{signal:e.signal,highWaterMark:$ce,highWatermark:$ce});return cHe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},dF=oHe(!0),$ce=dF,cHe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=lHe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Gu(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Qy(a)}},lHe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[$R(t,r,!e),DR(t,i,!n,{})].filter(Boolean);var Uce=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=dHe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([fHe(t),d]);return}let f=BU(c,r),p=uF({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([pHe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},dHe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!FR({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=uF({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Kae(a,t,r,o)},fHe=async t=>{await uHe(),t.readableFlowing===null&&t.resume()},pHe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await xR(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await RR(r,{maxBuffer:o})):await qp(r,{maxBuffer:o})}catch(a){return Fce(Kse({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},fF=async t=>{try{return await t}catch(e){return Fce(e)}},Fce=({bufferedData:t})=>die(t)?new Uint8Array(t):t;import{finished as hHe}from"stream/promises";var nS=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=mHe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],hHe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||yHe(a,e,r,n)}finally{s.abort()}},mHe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&gHe(t,r,n),n},gHe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{_He(e,r),n.call(t,...i)}},_He=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},yHe=(t,e,r,n)=>{if(!SHe(t,e,r,n))throw t},SHe=(t,e,r,n=!0)=>r.propagating?zce(t)||WR(t):(r.propagating=!0,pF(r,e)===n?zce(t):WR(t)),pF=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",WR=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",zce=t=>t?.code==="EPIPE";var jce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>hF({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),hF=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=nS(t,e,l);if(pF(l,e)){await u;return}let[d]=await Promise.all([Uce({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var Bce=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Vu([t,e].filter(Boolean)):void 0,qce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>hF({...EHe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:vHe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),EHe=({stdout:t,stderr:e,all:r},[,n,i])=>{let o=n||i;return o?n?i?{stream:r,buffer:o}:{stream:t,buffer:o}:{stream:e,buffer:o}:{stream:r,buffer:o}},vHe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as THe}from"events";var Gce=t=>Dp(t,"ipc"),Vce=(t,e)=>{let r=Qx(t);us({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Hce=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=Gce(o),a=ya(e,"ipc"),c=ya(r,"ipc");for await(let l of JU({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Zse(t,i,c),i.push(l)),s&&Vce(l,o);return i},Wce=async(t,e)=>(await Promise.allSettled([t]),e);var Yce=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:g,controller:_})=>{let S=ece(t,f),T={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:S,propagating:!1},y=jce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),w=qce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),A=[],R=Hce({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:A,verboseInfo:p}),I=bHe(m,t,T),O=wHe(h,T);try{return await Promise.race([Promise.all([{},rce(S),Promise.all(y),w,R,Cse(t,d),...I,...O]),g,AHe(t,_),...bse(t,o,f,_),...Goe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:_}),...vse({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:_})])}catch($){return f.terminationReason??="other",Promise.all([{error:$},S,Promise.all(y.map(b=>fF(b))),fF(w),Wce(R,A),Promise.allSettled(I),Promise.allSettled(O)])}},bHe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:nS(n,i,r)),wHe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>go(o,{checkOpen:!1})&&!po(o)).map(({type:i,value:o,stream:s=o})=>nS(s,n,e,{isSameDirection:ki.has(i),stopOnExit:i==="native"}))),AHe=async(t,{signal:e})=>{let[r]=await THe(t,"error",{signal:e});throw r};var Kce=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),iS=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=ds();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Yp=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 xHe}from"stream";import{callbackify as RHe}from"util";import{finished as Zce}from"stream/promises";var mF=async t=>{if(t!==void 0)try{await gF(t)}catch{}},Jce=async t=>{if(t!==void 0)try{await _F(t)}catch{}},gF=async t=>{await Zce(t,{cleanup:!0,readable:!1,writable:!0})},_F=async t=>{await Zce(t,{cleanup:!0,readable:!0,writable:!1})},YR=async(t,e)=>{if(await t,e)throw e},KR=(t,e,r)=>{r&&!WR(r)?t.destroy(r):e&&t.destroy()};var Xce=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||ii.has(r),{subprocessStdout:a,waitReadableDestroy:c}=yF(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=SF(a,s),{read:f,onStdoutDataDone:p}=EF({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new xHe({read:f,destroy:RHe(TF.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return vF({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},yF=(t,e,r)=>{let n=zp(t,e),i=iS(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},SF=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:dF},EF=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=ds(),s=HR({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){CHe(this,s,o)},onStdoutDataDone:o}},CHe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},vF=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await _F(t),await n,await mF(i),await e,r.readable&&r.push(null)}catch(o){await mF(i),Qce(r,o)}},TF=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Yp(r,e)&&(Qce(t,n),await YR(e,n))},Qce=(t,e)=>{KR(t,t.readable,e)};import{Writable as IHe}from"stream";import{callbackify as ele}from"util";var tle=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=bF(t,r,e),s=new IHe({...wF(n,t,i),destroy:ele(xF.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return AF(n,s),s},bF=(t,e,r)=>{let n=uR(t,e),i=iS(r,n,"writableFinal"),o=iS(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},wF=(t,e,r)=>({write:PHe.bind(void 0,t),final:ele(OHe.bind(void 0,t,e,r))}),PHe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},OHe=async(t,e,r)=>{await Yp(r,e)&&(t.writable&&t.end(),await e)},AF=async(t,e,r)=>{try{await gF(t),e.writable&&e.end()}catch(n){await Jce(r),rle(e,n)}},xF=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Yp(r,e),await Yp(n,e)&&(rle(t,i),await YR(e,i))},rle=(t,e)=>{KR(t,t.writable,e)};import{Duplex as NHe}from"stream";import{callbackify as kHe}from"util";var nle=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||ii.has(r),{subprocessStdout:c,waitReadableDestroy:l}=yF(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=bF(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=SF(c,a),{read:g,onStdoutDataDone:_}=EF({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),S=new NHe({read:g,...wF(u,t,d),destroy:kHe(MHe.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return vF({subprocessStdout:c,onStdoutDataDone:_,readable:S,subprocess:t,subprocessStdin:u}),AF(u,S,c),S},MHe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([TF({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),xF({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var RF=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||ii.has(e),s=zp(t,r),a=HR({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return DHe(a,s,t)},DHe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var ile=(t,{encoding:e})=>{let r=Kce();t.readable=Xce.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=tle.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=nle.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=RF.bind(void 0,t,e),t[Symbol.asyncIterator]=RF.bind(void 0,t,e,{})};var ole=(t,e)=>{for(let[r,n]of LHe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},$He=(async()=>{})().constructor.prototype,LHe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor($He,t)]);var sle=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=zHe(t,e,r),{subprocess:f,promise:p}=BHe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=VR.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),ole(f,p),fs.set(f,{options:u,fileDescriptors:d}),f},zHe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=tR(t,e,r),{file:a,commandArguments:c,options:l}=vR(t,e,r),u=jHe(l),d=_ce(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},jHe=({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}},BHe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=FHe(...TR(t,e,r))}catch(h){return pce({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;UHe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];xce(c,a,l),Cce(c,r,l);let d={},f=ds();c.kill=Boe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Bce(c,r),ile(c,r),uce(c,r);let p=qHe({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:o,escapedCommand:s,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},qHe=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,g]=await Yce({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let _=h.map((y,w)=>Ea(y,e,w)),S=Ea(m,e,"all"),T=GHe({errorInfo:d,exitCode:f,signal:p,stdio:_,all:S,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Vp(T,n,e)},GHe=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?Xy({error:t.error,command:c,escapedCommand:l,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof ps,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):PR({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var ZR=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,VHe(n,t[n],i)]));return{...t,...r}},VHe=(t,e,r)=>HHe.has(t)&&Jt(e)&&Jt(r)?{...e,...r}:r,HHe=new Set(["env",...nU]);var Uc=(t,e,r,n)=>{let i=(s,a,c)=>Uc(s,a,r,c),o=(...s)=>WHe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},WHe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Jt(o))return i(t,ZR(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=YHe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?ice(a,c,l):sle(a,c,l,i)},YHe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=_ie(e)?yie(e,r):[e,...r],[s,a,c]=Gx(...o),l=ZR(ZR(n,i),c),{file:u=s,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:s,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var ale=({file:t,commandArguments:e})=>lle(t,e),cle=({file:t,commandArguments:e})=>({...lle(t,e),isSync:!0}),lle=(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]=KHe(t);return{file:r,commandArguments:n}},KHe=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(ZHe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},ZHe=/ +/g;var ule=(t,e,r)=>{t.sync=e(JHe,r),t.s=t.sync},dle=({options:t})=>fle(t),JHe=({options:t})=>({...fle(t),isSync:!0}),fle=t=>({options:{...XHe(t),...t}}),XHe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},ple={preferLocal:!0};var hle=Uc(()=>({})),szt=Uc(()=>({isSync:!0})),mle=Uc(ale),azt=Uc(cle),czt=Uc(Ase),lzt=Uc(dle,{},ple,ule),{sendMessage:uzt,getOneMessage:dzt,getEachMessage:fzt,getCancelSignal:pzt}=dce();var gle=!1,_le,QHe=t=>{_le??=t},yle=t=>{gle=!0,QHe(t)},oi=()=>gle,Fc=()=>_le,Sle=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var oS=null,Ele=t=>(oS&&oS.destroy(),oS=new _o({totalAllowedTime:t}),oS),vle=()=>oS;var _o=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&oi())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await kx({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{q.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),o(),s&&clearTimeout(s)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var Tle={name:"@netlify/agent-runner-cli",type:"module",version:"1.189.2",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",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:opencode":"vitest run test/integration/opencode.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.6","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.280","@anthropic-ai/sdk":"^0.128.0","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.1","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.153.4","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var n6e=t6e(import.meta.url),i6e=va.dirname(n6e),o6e=r6e(import.meta.url),Kp=oe("shell"),CF=new Set,ble={preferLocal:!0},It=(t,e,r)=>{let[n,i]=s6e(e,r),o={...ble,...i},s=hle(t,n,o);Ale(s,o),Cle(s);let a=r?.idleTimeout;return a&&a>0&&Rle(s,a),s},wle=(t,e)=>{let r={...ble,...e},n=mle(t,r);return Ale(n,r),Cle(n),e?.idleTimeout&&e.idleTimeout>0&&Rle(n,e.idleTimeout),n},s6e=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},Ale=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||ms.env.NETLIFY_LOCAL_QUIET==="true")return;if(ms.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new My).pipe(ms.stdout),t.stderr?.pipe(new My).pipe(ms.stderr);return}t.stdout?.pipe(ms.stdout),t.stderr?.pipe(ms.stderr)},IF=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(ms.kill(-t.pid,e),Kp.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Kp.error("Error killing process:",r),!1}},xle=t=>IF(t,"SIGKILL"),Rle=(t,e)=>{let r=null,n=()=>{Kp.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),IF(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Kp.log(`Force killing idle process ${t.pid}`),xle(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let o=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",o),t.on("error",o)},Cle=t=>{CF.add(t);let e=vle();if(e){let r=e.onTimesUp(()=>{Kp.log(`Global timer expired, killing process ${t.pid}`),IF(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Kp.log(`Force killing process ${t.pid} after timeout`),xle(t))},5e3)});t.on("exit",()=>{CF.delete(t),r()}),t.on("error",()=>{CF.delete(t),r()})}};function XR(t,e){return!!yo(t,e)}function yo(t,e){if(!ms.env.NETLIFY_LOCAL_MODE)try{let i=o6e.resolve(Tle.name),o=va.dirname(i);for(;o!==va.dirname(o);){let s=va.dirname(o);if(va.basename(s)==="node_modules"){let a=va.join(s,".bin",e);if(JR.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(ms.env.NODE_PATH){let i=va.join(ms.env.NODE_PATH,".bin",e);if(JR.existsSync(i))return i}let r=va.join(t,"node_modules",".bin",e);if(JR.existsSync(r))return r;let n=va.join(i6e,"..","node_modules",".bin",e);if(JR.existsSync(n))return n}var Ile=oe("repo"),kle="runner-diffs-",tC=t=>`${kle}${t}-`,Mle=async t=>{let e=Nle.tmpdir(),r;try{r=await QR.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(kle)&&!n.startsWith(tC(t))).map(n=>QR.rm(eC.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},Xt=(t,e={})=>It("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),rC=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{Ile.info("Getting runner diffs");let n=await kF(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let l=MF(o);await h6e(l,r)}Ile.info("Changes after processing"),await NF(r);let s=await aS(o,r);if(await OF(s,r),i=await d6e(r),!i)return{hasChanges:!1,ignored:s};await Xt(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await QR.mkdtemp(eC.join(Nle.tmpdir(),tC(t.sessionId))),c=await PF({config:t,diffDir:a,cwd:r,target:{commit:"HEAD"},ignored:s});return await l6e(r),c.hasChanges&&q.distribution("diff.size",(c.diffBinary??c.diff).size,{phase:"final"}),c},PF=async({config:t,diffDir:e,cwd:r,target:n,ignored:i})=>{let o="commit"in n?n.commit:"--cached",s="indexPath"in n?{GIT_INDEX_FILE:n.indexPath}:void 0,a=async({from:p,fileName:h,binary:m})=>{let g=eC.join(e,h);await Xt([...m?["diff",p,o,"--binary"]:["diff",p,o],`--output=${g}`],{stdio:["ignore","ignore","pipe"],cwd:r,env:s});let{size:S}=await QR.stat(g);return{path:g,size:S}},c=await a({from:t.runSha,fileName:"session.patch"});if(c.size===0)return{hasChanges:!1,ignored:i};let l=await a({from:t.runSha,fileName:"session-binary.patch",binary:!0}),u,d;if(t.sha){u=await a({from:t.sha,fileName:"cumulative.patch"});let p=await a({from:t.sha,fileName:"cumulative-binary.patch",binary:!0});await Ole(u,p)||(d=p)}let f={hasChanges:!0,diff:c,resultDiff:u,ignored:i};return await Ole(c,l)||(f.diffBinary=l),d&&(f.resultDiffBinary=d),f},Ple=async t=>{let e=a6e("sha256");for await(let r of c6e(t))e.update(r);return e.digest("hex")},Ole=async(t,e)=>t.size===e.size&&await Ple(t.path)===await Ple(e.path),l6e=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Xt(["reset","--soft","HEAD~1"],{cwd:t})},OF=async(t=[],e=process.cwd())=>{await Xt(["add",".",...t],{cwd:e})},NF=async(t=process.cwd())=>{let e=await Xt(["status","-s"],{cwd:t});return String(e.stdout??"")},Dle=/.. (.+)?\.log$/,u6e=[Dle],kF=async(t=process.cwd())=>{let e=await NF(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
146
|
+
if (condition) { yield value; }`)};import{Buffer as _Ve}from"buffer";import{StringDecoder as yVe}from"string_decoder";var $R=(t,e,r)=>{if(r)return;if(t)return{transform:SVe.bind(void 0,new TextEncoder)};let n=new yVe(e);return{transform:EVe.bind(void 0,n),final:vVe.bind(void 0,n)}},SVe=function*(t,e){_Ve.isBuffer(e)?yield _a(e):typeof e=="string"?yield t.encode(e):yield e},EVe=function*(t,e){yield dr(e)?t.write(e):e},vVe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Bae}from"util";var VU=Bae(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),LR=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=bVe}=e[r];for await(let i of n(t))yield*LR(i,e,r+1)},qae=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*TVe(r,Number(e),t)},TVe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*LR(n,r,e+1)},Gae=Bae(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),bVe=function*(t){yield t};var HU=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Vae=(t,e)=>[...e.flatMap(r=>[...Gu(r,t,0)]),...Qy(t)],Gu=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=AVe}=e[r];for(let i of n(t))yield*Gu(i,e,r+1)},Qy=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*wVe(r,Number(e),t)},wVe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Gu(n,r,e+1)},AVe=function*(t){yield t};var WU=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Wae(t,s,o),l=qu(e),u=qu(r),d=l?VU.bind(void 0,LR,a):HU.bind(void 0,Gu),f=l||u?VU.bind(void 0,qae,a):HU.bind(void 0,Qy),p=l||u?Gae.bind(void 0,a):void 0;return{stream:new xVe({writableObjectMode:n,writableHighWaterMark:Hae(n),readableObjectMode:i,readableHighWaterMark:Hae(i),transform(m,g,_){d([m,c,0],this,_)},flush(m){f([c],this,m)},destroy:p})}},UR=(t,e,r,n)=>{let i=e.filter(({type:s})=>s==="generator"),o=n?i.reverse():i;for(let{value:s,optionName:a}of o){let c=Wae(s,r,a);t=Vae(c,t)}return t},Wae=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Fae(n,a)},$R(r,s,n),DR(r,o,n,c),{transform:t,final:e},{transform:zae(i,a)},Uae({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Yae=(t,e)=>{for(let r of RVe(t))CVe(t,r,e)},RVe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),CVe=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Lc[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>IVe(a,n));r.input=qy(s)},IVe=(t,e)=>{let r=UR(t,e,"utf8",!0);return PVe(r),qy(r)},PVe=t=>{let e=t.find(r=>typeof r!="string"&&!dr(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 MVe,appendFileSync as DVe}from"fs";var FR=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Dp(r,n)&&!ii.has(e)&&OVe(n)&&(t.some(({type:i,value:o})=>i==="native"&&NVe.has(o))||t.every(({type:i})=>ki.has(i))),OVe=t=>t===1||t===2,NVe=new Set(["pipe","overlapped"]),Kae=async(t,e,r,n)=>{for await(let i of t)kVe(e)||Jae(i,r,n)},Zae=(t,e,r)=>{for(let n of t)Jae(n,e,r)},kVe=t=>t._readableState.pipes.length>0,Jae=(t,e,r)=>{let n=Qx(t);us({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Xae=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,l)=>$Ve({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},$Ve=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=Qse(t,o,d),p=_a(f),{stdioItems:h,objectMode:m}=e[r],g=LVe([p],h,c,n),{serializedResult:_,finalResult:S=_}=UVe({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});FVe({serializedResult:_,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let T=a[r]?S:void 0;try{return n.error===void 0&&zVe(_,h,i),T}catch(y){return n.error=y,T}},LVe=(t,e,r,n)=>{try{return UR(t,e,r,!1)}catch(i){return n.error=i,t}},UVe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:qy(t)};let s=pie(t,r);return n[o]?{serializedResult:s,finalResult:GU(s,!i[o],e)}:{serializedResult:s}},FVe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!FR({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=GU(t,!1,s);try{Zae(a,e,n)}catch(c){r.error??=c}},zVe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>kR.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?DVe(n,t):(r.add(o),MVe(n,t))}};var Qae=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Ea(e,r,"all")]:Array.isArray(e)?[Ea(t,r,"all"),...e]:dr(t)&&dr(e)?Q1([t,e]):`${t}${e}`};import{once as YU}from"events";var ece=async(t,e)=>{let[r,n]=await jVe(t);return e.isForcefullyTerminated??=!1,[r,n]},jVe=async t=>{let[e,r]=await Promise.allSettled([YU(t,"spawn"),YU(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?tce(t):r.value},tce=async t=>{try{return await YU(t,"exit")}catch{return tce(t)}},rce=async t=>{let[e,r]=await t;if(!BVe(e,r)&&KU(e,r))throw new ho;return[e,r]},BVe=(t,e)=>t===void 0&&e===void 0,KU=(t,e)=>t!==0||e!==null;var nce=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=qVe(t,e,r),s=o?.code==="ETIMEDOUT",a=Xse(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},qVe=(t,e,r)=>t!==void 0?t:KU(e,r)?new ho:void 0;var ice=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=VVe(t,e,r),d=YVe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Vp(d,c,l)},VVe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=tR(t,e,r),a=HVe(r),{file:c,commandArguments:l,options:u}=vR(t,e,a);WVe(u);let d=Mae(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},HVe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,WVe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&zR("ipcInput"),t&&zR("ipc: true"),r&&zR("detached: true"),n&&zR("cancelSignal")},zR=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},YVe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=KVe({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=nce(c,r),{output:h,error:m=l}=Xae({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((S,T)=>Ea(S,r,T)),_=Ea(Qae(h,r),r,"all");return JVe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:_,options:r,command:n,escapedCommand:i,startTime:a})},KVe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Yae(o,r);let a=ZVe(r);return GVe(...TR(t,e,a))}catch(a){return Gp({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},ZVe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:IR(e)}),JVe=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?PR({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):Xy({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as UHe}from"events";import{spawn as FHe}from"child_process";import lce from"process";import{once as ZU,on as XVe}from"events";var oce=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Up({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:mR(t)}),QVe({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),QVe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{dR(e,i);let o=$c(t,e,r),s=new AbortController;try{return await Promise.race([e4e(o,n,s),t4e(o,r,s),r4e(o,r,s)])}catch(a){throw Fp(t),a}finally{s.abort(),fR(e,i)}},e4e=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await ZU(t,"message",{signal:r});return n}for await(let[n]of XVe(t,"message",{signal:r}))if(e(n))return n},t4e=async(t,e,{signal:r})=>{await ZU(t,"disconnect",{signal:r}),Voe(e)},r4e=async(t,e,{signal:r})=>{let[n]=await ZU(t,"strict:error",{signal:r});throw cR(n,e)};import{once as ace,on as n4e}from"events";var cce=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>JU({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),JU=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Up({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:mR(t)}),dR(e,o);let s=$c(t,e,r),a=new AbortController,c={};return i4e(t,s,a),o4e({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),s4e({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},i4e=async(t,e,r)=>{try{await ace(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},o4e=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await ace(t,"strict:error",{signal:r.signal});n.error=cR(i,e),r.abort()}catch{}},s4e=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of n4e(r,"message",{signal:o.signal}))sce(s),yield c}catch{sce(s)}finally{o.abort(),fR(e,a),n||Fp(t),i&&await t}},sce=({error:t})=>{if(t)throw t};var uce=(t,{ipc:e})=>{Object.assign(t,fce(t,!1,e))},dce=()=>{let t=lce,e=!0,r=lce.channel!==void 0;return{...fce(t,e,r),getCancelSignal:yse.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},fce=(t,e,r)=>({sendMessage:SR.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:oce.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:cce.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as a4e}from"child_process";import{PassThrough as c4e,Readable as l4e,Writable as u4e,Duplex as d4e}from"stream";var pce=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{jU(n);let a=new a4e;f4e(a,n),Object.assign(a,{readable:p4e,writable:h4e,duplex:m4e});let c=Gp({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=g4e(c,s,i);return{subprocess:a,promise:l}},f4e=(t,e)=>{let r=eS(),n=eS(),i=eS(),o=Array.from({length:e.length-3},eS),s=eS(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},eS=()=>{let t=new c4e;return t.end(),t},p4e=()=>new l4e({read(){}}),h4e=()=>new u4e({write(){}}),m4e=()=>new d4e({read(){},write(){}}),g4e=async(t,e,r)=>Vp(t,e,r);import{createReadStream as hce,createWriteStream as mce}from"fs";import{Buffer as _4e}from"buffer";import{Readable as tS,Writable as y4e,Duplex as S4e}from"stream";var _ce=(t,e)=>MR(E4e,t,e,!1),rS=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Lc[t]}.`)},gce={fileNumber:rS,generator:WU,asyncGenerator:WU,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:S4e.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},E4e={input:{...gce,fileUrl:({value:t})=>({stream:hce(t)}),filePath:({value:{file:t}})=>({stream:hce(t)}),webStream:({value:t})=>({stream:tS.fromWeb(t)}),iterable:({value:t})=>({stream:tS.from(t)}),asyncIterable:({value:t})=>({stream:tS.from(t)}),string:({value:t})=>({stream:tS.from(t)}),uint8Array:({value:t})=>({stream:tS.from(_4e.from(t))})},output:{...gce,fileUrl:({value:t})=>({stream:mce(t)}),filePath:({value:{file:t,append:e}})=>({stream:mce(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:y4e.fromWeb(t)}),iterable:rS,asyncIterable:rS,string:rS,uint8Array:rS}};import{on as v4e,once as yce}from"events";import{PassThrough as T4e,getDefaultHighWaterMark as b4e}from"stream";import{finished as vce}from"stream/promises";function Vu(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)QU(i);let e=t.some(({readableObjectMode:i})=>i),r=w4e(t,e),n=new XU({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var w4e=(t,e)=>{if(t.length===0)return b4e(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},XU=class extends T4e{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(QU(e),this.#e.has(e))return;this.#e.add(e),this.#n??=A4e(this,this.#e,this.#o);let r=C4e({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#o});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(QU(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},A4e=async(t,e,r)=>{jR(t,Sce);let n=new AbortController;try{await Promise.race([x4e(t,n),R4e(t,e,r,n)])}finally{n.abort(),jR(t,-Sce)}},x4e=async(t,{signal:e})=>{try{await vce(t,{signal:e,cleanup:!0})}catch(r){throw Tce(t,r),r}},R4e=async(t,e,r,{signal:n})=>{for await(let[i]of v4e(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},QU=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},C4e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{jR(t,Ece);let a=new AbortController;try{await Promise.race([I4e(o,e,a),P4e({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),O4e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),jR(t,-Ece)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?eF(t):N4e(t))},I4e=async(t,e,{signal:r})=>{try{await t,r.aborted||eF(e)}catch(n){r.aborted||Tce(e,n)}},P4e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await vce(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;bce(s)?i.add(e):wce(t,s)}},O4e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await yce(t,i,{signal:o}),!t.readable)return yce(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},N4e=t=>{t.writable&&t.end()},Tce=(t,e)=>{bce(e)?eF(t):wce(t,e)},bce=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",eF=t=>{(t.readable||t.writable)&&t.destroy()},wce=(t,e)=>{t.destroyed||(t.once("error",k4e),t.destroy(e))},k4e=()=>{},jR=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Sce=2,Ece=1;import{finished as Ace}from"stream/promises";var Wp=(t,e)=>{t.pipe(e),M4e(t,e),D4e(t,e)},M4e=async(t,e)=>{if(!(po(t)||po(e))){try{await Ace(t,{cleanup:!0,readable:!0,writable:!1})}catch{}tF(e)}},tF=t=>{t.writable&&t.end()},D4e=async(t,e)=>{if(!(po(t)||po(e))){try{await Ace(e,{cleanup:!0,readable:!1,writable:!0})}catch{}rF(t)}},rF=t=>{t.readable&&t.destroy()};var xce=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:o,direction:s}]of Object.entries(e)){for(let{stream:a}of o.filter(({type:c})=>ki.has(c)))$4e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!ki.has(c)))U4e({subprocess:t,stream:a,direction:s,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,o]of n.entries()){let s=o.length===1?o[0]:Vu(o);Wp(s,i)}},$4e=(t,e,r,n)=>{r==="output"?Wp(t.stdio[n],e):Wp(e,t.stdio[n]);let i=L4e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},L4e=["stdin","stdout","stderr"],U4e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;F4e(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},F4e=(t,{signal:e})=>{po(t)&&ju(t,z4e,e)},z4e=2;import{addAbortListener as q4e}from"events";var Hu=[];Hu.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Hu.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Hu.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var BR=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",nF=Symbol.for("signal-exit emitter"),iF=globalThis,j4e=Object.defineProperty.bind(Object),oF=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(iF[nF])return iF[nF];j4e(iF,nF,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let o of this.listeners[e])i=o(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},qR=class{},B4e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),sF=class extends qR{onExit(){return()=>{}}load(){}unload(){}},aF=class extends qR{#e=cF.platform==="win32"?"SIGINT":"SIGHUP";#r=new oF;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Hu)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,o=e;if(typeof o.__signal_exit_emitter__=="object"&&typeof o.__signal_exit_emitter__.count=="number"&&(i+=o.__signal_exit_emitter__.count),n.length===i){this.unload();let s=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;s||e.kill(e.pid,a)}};this.#o=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!BR(this.#t))return()=>{};this.#s===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#r.on(n,e),()=>{this.#r.removeListener(n,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#s){this.#s=!0,this.#r.count+=1;for(let e of Hu)try{let r=this.#i[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#s&&(this.#s=!1,Hu.forEach(e=>{let r=this.#i[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#o,this.#r.count-=1)}#a(e){return BR(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#o.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&BR(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let i=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),i}else return n.call(this.#t,e,...r)}},cF=globalThis.process,{onExit:Rce,load:g1t,unload:_1t}=B4e(BR(cF)?new aF(cF):new sF);var Cce=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Rce(()=>{t.kill()});q4e(n,()=>{i()})};var Pce=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=eR(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=G4e(r,n,i),{sourceStream:d,sourceError:f}=H4e(t,l),{options:p,fileDescriptors:h}=fs.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},G4e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=V4e(t,e,...r),a=uR(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},V4e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Ice,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||J1(r)){if(Object.keys(t).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[i,o,s]=Gx(r,...n);return{destination:e(Ice)(i,o,s),pipeOptions:s}}if(fs.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}`)},Ice=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),H4e=(t,e)=>{try{return{sourceStream:zp(t,e)}}catch(r){return{sourceError:r}}};var Nce=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=W4e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw lF({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},W4e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return rF(t),n;if(e!==void 0)return tF(r),e},lF=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Gp({error:t,command:Oce,escapedCommand:Oce,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Oce="source.pipe(destination)";var kce=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:o,value:s=o}]=await t;if(s.pipedFrom.includes(n)||s.pipedFrom.push(n),i==="rejected")throw s;if(e==="rejected")throw n;return s};import{finished as Y4e}from"stream/promises";var Mce=(t,e,r)=>{let n=GR.has(e)?Z4e(t,e):K4e(t,e);return ju(t,X4e,r.signal),ju(e,Q4e,r.signal),J4e(e),n},K4e=(t,e)=>{let r=Vu([t]);return Wp(r,e),GR.set(e,r),r},Z4e=(t,e)=>{let r=GR.get(e);return r.add(t),r},J4e=async t=>{try{await Y4e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}GR.delete(t)},GR=new WeakMap,X4e=2,Q4e=1;import{aborted as eHe}from"util";var Dce=(t,e)=>t===void 0?[]:[tHe(t,e)],tHe=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await eHe(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw lF({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var VR=(t,...e)=>{if(Jt(e[0]))return VR.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=Pce(t,...e),i=rHe({...n,destination:r});return i.pipe=VR.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},rHe=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=nHe(t,i);Nce({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=Mce(e,o,d);return await Promise.race([kce(u),...Dce(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},nHe=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as uHe}from"timers/promises";import{on as iHe}from"events";import{getDefaultHighWaterMark as oHe}from"stream";var HR=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return sHe(e,s),Lce({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},sHe=async(t,e)=>{try{await t}catch{}finally{e.abort()}},uF=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;aHe(e,s,t);let a=t.readableObjectMode&&!o;return Lce({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},aHe=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Lce=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=iHe(t,"data",{signal:e.signal,highWaterMark:$ce,highWatermark:$ce});return cHe({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},dF=oHe(!0),$ce=dF,cHe=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=lHe({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Gu(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Qy(a)}},lHe=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[$R(t,r,!e),DR(t,i,!n,{})].filter(Boolean);var Uce=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=dHe({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([fHe(t),d]);return}let f=BU(c,r),p=uF({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([pHe({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},dHe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!FR({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=uF({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Kae(a,t,r,o)},fHe=async t=>{await uHe(),t.readableFlowing===null&&t.resume()},pHe=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await xR(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await RR(r,{maxBuffer:o})):await qp(r,{maxBuffer:o})}catch(a){return Fce(Kse({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},fF=async t=>{try{return await t}catch(e){return Fce(e)}},Fce=({bufferedData:t})=>die(t)?new Uint8Array(t):t;import{finished as hHe}from"stream/promises";var nS=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=mHe(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],hHe(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||yHe(a,e,r,n)}finally{s.abort()}},mHe=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&gHe(t,r,n),n},gHe=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{_He(e,r),n.call(t,...i)}},_He=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},yHe=(t,e,r,n)=>{if(!SHe(t,e,r,n))throw t},SHe=(t,e,r,n=!0)=>r.propagating?zce(t)||WR(t):(r.propagating=!0,pF(r,e)===n?zce(t):WR(t)),pF=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",WR=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",zce=t=>t?.code==="EPIPE";var jce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>hF({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),hF=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=nS(t,e,l);if(pF(l,e)){await u;return}let[d]=await Promise.all([Uce({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var Bce=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Vu([t,e].filter(Boolean)):void 0,qce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>hF({...EHe(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:vHe(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),EHe=({stdout:t,stderr:e,all:r},[,n,i])=>{let o=n||i;return o?n?i?{stream:r,buffer:o}:{stream:t,buffer:o}:{stream:e,buffer:o}:{stream:r,buffer:o}},vHe=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as THe}from"events";var Gce=t=>Dp(t,"ipc"),Vce=(t,e)=>{let r=Qx(t);us({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Hce=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=Gce(o),a=ya(e,"ipc"),c=ya(r,"ipc");for await(let l of JU({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Zse(t,i,c),i.push(l)),s&&Vce(l,o);return i},Wce=async(t,e)=>(await Promise.allSettled([t]),e);var Yce=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:g,controller:_})=>{let S=ece(t,f),T={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:S,propagating:!1},y=jce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),w=qce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),A=[],R=Hce({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:A,verboseInfo:p}),I=bHe(m,t,T),O=wHe(h,T);try{return await Promise.race([Promise.all([{},rce(S),Promise.all(y),w,R,Cse(t,d),...I,...O]),g,AHe(t,_),...bse(t,o,f,_),...Goe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:_}),...vse({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:_})])}catch($){return f.terminationReason??="other",Promise.all([{error:$},S,Promise.all(y.map(b=>fF(b))),fF(w),Wce(R,A),Promise.allSettled(I),Promise.allSettled(O)])}},bHe=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:nS(n,i,r)),wHe=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>go(o,{checkOpen:!1})&&!po(o)).map(({type:i,value:o,stream:s=o})=>nS(s,n,e,{isSameDirection:ki.has(i),stopOnExit:i==="native"}))),AHe=async(t,{signal:e})=>{let[r]=await THe(t,"error",{signal:e});throw r};var Kce=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),iS=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=ds();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Yp=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 xHe}from"stream";import{callbackify as RHe}from"util";import{finished as Zce}from"stream/promises";var mF=async t=>{if(t!==void 0)try{await gF(t)}catch{}},Jce=async t=>{if(t!==void 0)try{await _F(t)}catch{}},gF=async t=>{await Zce(t,{cleanup:!0,readable:!1,writable:!0})},_F=async t=>{await Zce(t,{cleanup:!0,readable:!0,writable:!1})},YR=async(t,e)=>{if(await t,e)throw e},KR=(t,e,r)=>{r&&!WR(r)?t.destroy(r):e&&t.destroy()};var Xce=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||ii.has(r),{subprocessStdout:a,waitReadableDestroy:c}=yF(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=SF(a,s),{read:f,onStdoutDataDone:p}=EF({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new xHe({read:f,destroy:RHe(TF.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return vF({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},yF=(t,e,r)=>{let n=zp(t,e),i=iS(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},SF=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:dF},EF=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=ds(),s=HR({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){CHe(this,s,o)},onStdoutDataDone:o}},CHe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},vF=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await _F(t),await n,await mF(i),await e,r.readable&&r.push(null)}catch(o){await mF(i),Qce(r,o)}},TF=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Yp(r,e)&&(Qce(t,n),await YR(e,n))},Qce=(t,e)=>{KR(t,t.readable,e)};import{Writable as IHe}from"stream";import{callbackify as ele}from"util";var tle=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=bF(t,r,e),s=new IHe({...wF(n,t,i),destroy:ele(xF.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return AF(n,s),s},bF=(t,e,r)=>{let n=uR(t,e),i=iS(r,n,"writableFinal"),o=iS(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},wF=(t,e,r)=>({write:PHe.bind(void 0,t),final:ele(OHe.bind(void 0,t,e,r))}),PHe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},OHe=async(t,e,r)=>{await Yp(r,e)&&(t.writable&&t.end(),await e)},AF=async(t,e,r)=>{try{await gF(t),e.writable&&e.end()}catch(n){await Jce(r),rle(e,n)}},xF=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Yp(r,e),await Yp(n,e)&&(rle(t,i),await YR(e,i))},rle=(t,e)=>{KR(t,t.writable,e)};import{Duplex as NHe}from"stream";import{callbackify as kHe}from"util";var nle=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||ii.has(r),{subprocessStdout:c,waitReadableDestroy:l}=yF(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=bF(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=SF(c,a),{read:g,onStdoutDataDone:_}=EF({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),S=new NHe({read:g,...wF(u,t,d),destroy:kHe(MHe.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return vF({subprocessStdout:c,onStdoutDataDone:_,readable:S,subprocess:t,subprocessStdin:u}),AF(u,S,c),S},MHe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([TF({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),xF({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var RF=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||ii.has(e),s=zp(t,r),a=HR({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return DHe(a,s,t)},DHe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var ile=(t,{encoding:e})=>{let r=Kce();t.readable=Xce.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=tle.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=nle.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=RF.bind(void 0,t,e),t[Symbol.asyncIterator]=RF.bind(void 0,t,e,{})};var ole=(t,e)=>{for(let[r,n]of LHe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},$He=(async()=>{})().constructor.prototype,LHe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor($He,t)]);var sle=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=zHe(t,e,r),{subprocess:f,promise:p}=BHe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=VR.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),ole(f,p),fs.set(f,{options:u,fileDescriptors:d}),f},zHe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=tR(t,e,r),{file:a,commandArguments:c,options:l}=vR(t,e,r),u=jHe(l),d=_ce(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},jHe=({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}},BHe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=FHe(...TR(t,e,r))}catch(h){return pce({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;UHe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];xce(c,a,l),Cce(c,r,l);let d={},f=ds();c.kill=Boe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=Bce(c,r),ile(c,r),uce(c,r);let p=qHe({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:o,escapedCommand:s,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},qHe=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,g]=await Yce({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let _=h.map((y,w)=>Ea(y,e,w)),S=Ea(m,e,"all"),T=GHe({errorInfo:d,exitCode:f,signal:p,stdio:_,all:S,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Vp(T,n,e)},GHe=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?Xy({error:t.error,command:c,escapedCommand:l,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof ps,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):PR({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var ZR=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,VHe(n,t[n],i)]));return{...t,...r}},VHe=(t,e,r)=>HHe.has(t)&&Jt(e)&&Jt(r)?{...e,...r}:r,HHe=new Set(["env",...nU]);var Uc=(t,e,r,n)=>{let i=(s,a,c)=>Uc(s,a,r,c),o=(...s)=>WHe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},WHe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Jt(o))return i(t,ZR(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=YHe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?ice(a,c,l):sle(a,c,l,i)},YHe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=_ie(e)?yie(e,r):[e,...r],[s,a,c]=Gx(...o),l=ZR(ZR(n,i),c),{file:u=s,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:s,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var ale=({file:t,commandArguments:e})=>lle(t,e),cle=({file:t,commandArguments:e})=>({...lle(t,e),isSync:!0}),lle=(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]=KHe(t);return{file:r,commandArguments:n}},KHe=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(ZHe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},ZHe=/ +/g;var ule=(t,e,r)=>{t.sync=e(JHe,r),t.s=t.sync},dle=({options:t})=>fle(t),JHe=({options:t})=>({...fle(t),isSync:!0}),fle=t=>({options:{...XHe(t),...t}}),XHe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},ple={preferLocal:!0};var hle=Uc(()=>({})),szt=Uc(()=>({isSync:!0})),mle=Uc(ale),azt=Uc(cle),czt=Uc(Ase),lzt=Uc(dle,{},ple,ule),{sendMessage:uzt,getOneMessage:dzt,getEachMessage:fzt,getCancelSignal:pzt}=dce();var gle=!1,_le,QHe=t=>{_le??=t},yle=t=>{gle=!0,QHe(t)},oi=()=>gle,Fc=()=>_le,Sle=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var oS=null,Ele=t=>(oS&&oS.destroy(),oS=new _o({totalAllowedTime:t}),oS),vle=()=>oS;var _o=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&oi())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await kx({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{q.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),o(),s&&clearTimeout(s)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var Tle={name:"@netlify/agent-runner-cli",type:"module",version:"1.189.3",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",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:opencode":"vitest run test/integration/opencode.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.6","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.280","@anthropic-ai/sdk":"^0.128.0","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.1","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.153.4","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var n6e=t6e(import.meta.url),i6e=va.dirname(n6e),o6e=r6e(import.meta.url),Kp=oe("shell"),CF=new Set,ble={preferLocal:!0},It=(t,e,r)=>{let[n,i]=s6e(e,r),o={...ble,...i},s=hle(t,n,o);Ale(s,o),Cle(s);let a=r?.idleTimeout;return a&&a>0&&Rle(s,a),s},wle=(t,e)=>{let r={...ble,...e},n=mle(t,r);return Ale(n,r),Cle(n),e?.idleTimeout&&e.idleTimeout>0&&Rle(n,e.idleTimeout),n},s6e=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},Ale=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||ms.env.NETLIFY_LOCAL_QUIET==="true")return;if(ms.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new My).pipe(ms.stdout),t.stderr?.pipe(new My).pipe(ms.stderr);return}t.stdout?.pipe(ms.stdout),t.stderr?.pipe(ms.stderr)},IF=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(ms.kill(-t.pid,e),Kp.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Kp.error("Error killing process:",r),!1}},xle=t=>IF(t,"SIGKILL"),Rle=(t,e)=>{let r=null,n=()=>{Kp.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),IF(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Kp.log(`Force killing idle process ${t.pid}`),xle(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let o=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",o),t.on("error",o)},Cle=t=>{CF.add(t);let e=vle();if(e){let r=e.onTimesUp(()=>{Kp.log(`Global timer expired, killing process ${t.pid}`),IF(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Kp.log(`Force killing process ${t.pid} after timeout`),xle(t))},5e3)});t.on("exit",()=>{CF.delete(t),r()}),t.on("error",()=>{CF.delete(t),r()})}};function XR(t,e){return!!yo(t,e)}function yo(t,e){if(!ms.env.NETLIFY_LOCAL_MODE)try{let i=o6e.resolve(Tle.name),o=va.dirname(i);for(;o!==va.dirname(o);){let s=va.dirname(o);if(va.basename(s)==="node_modules"){let a=va.join(s,".bin",e);if(JR.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(ms.env.NODE_PATH){let i=va.join(ms.env.NODE_PATH,".bin",e);if(JR.existsSync(i))return i}let r=va.join(t,"node_modules",".bin",e);if(JR.existsSync(r))return r;let n=va.join(i6e,"..","node_modules",".bin",e);if(JR.existsSync(n))return n}var Ile=oe("repo"),kle="runner-diffs-",tC=t=>`${kle}${t}-`,Mle=async t=>{let e=Nle.tmpdir(),r;try{r=await QR.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(kle)&&!n.startsWith(tC(t))).map(n=>QR.rm(eC.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},Xt=(t,e={})=>It("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),rC=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{Ile.info("Getting runner diffs");let n=await kF(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let l=MF(o);await h6e(l,r)}Ile.info("Changes after processing"),await NF(r);let s=await aS(o,r);if(await OF(s,r),i=await d6e(r),!i)return{hasChanges:!1,ignored:s};await Xt(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await QR.mkdtemp(eC.join(Nle.tmpdir(),tC(t.sessionId))),c=await PF({config:t,diffDir:a,cwd:r,target:{commit:"HEAD"},ignored:s});return await l6e(r),c.hasChanges&&q.distribution("diff.size",(c.diffBinary??c.diff).size,{phase:"final"}),c},PF=async({config:t,diffDir:e,cwd:r,target:n,ignored:i})=>{let o="commit"in n?n.commit:"--cached",s="indexPath"in n?{GIT_INDEX_FILE:n.indexPath}:void 0,a=async({from:p,fileName:h,binary:m})=>{let g=eC.join(e,h);await Xt([...m?["diff",p,o,"--binary"]:["diff",p,o],`--output=${g}`],{stdio:["ignore","ignore","pipe"],cwd:r,env:s});let{size:S}=await QR.stat(g);return{path:g,size:S}},c=await a({from:t.runSha,fileName:"session.patch"});if(c.size===0)return{hasChanges:!1,ignored:i};let l=await a({from:t.runSha,fileName:"session-binary.patch",binary:!0}),u,d;if(t.sha){u=await a({from:t.sha,fileName:"cumulative.patch"});let p=await a({from:t.sha,fileName:"cumulative-binary.patch",binary:!0});await Ole(u,p)||(d=p)}let f={hasChanges:!0,diff:c,resultDiff:u,ignored:i};return await Ole(c,l)||(f.diffBinary=l),d&&(f.resultDiffBinary=d),f},Ple=async t=>{let e=a6e("sha256");for await(let r of c6e(t))e.update(r);return e.digest("hex")},Ole=async(t,e)=>t.size===e.size&&await Ple(t.path)===await Ple(e.path),l6e=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Xt(["reset","--soft","HEAD~1"],{cwd:t})},OF=async(t=[],e=process.cwd())=>{await Xt(["add",".",...t],{cwd:e})},NF=async(t=process.cwd())=>{let e=await Xt(["status","-s"],{cwd:t});return String(e.stdout??"")},Dle=/.. (.+)?\.log$/,u6e=[Dle],kF=async(t=process.cwd())=>{let e=await NF(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
147
147
|
`).filter(i=>u6e.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}},d6e=async(t=process.cwd())=>{try{return await Xt(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},sS=async(t=process.cwd())=>{let{stdout:e}=await Xt(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},f6e=1,p6e=async t=>{try{return await Xt(["rev-parse","--verify","--quiet","HEAD"],{cwd:t}),!0}catch(e){if(e.exitCode===f6e)return!1;throw e}},$le=async(t=process.cwd())=>{if(!await p6e(t))return!0;let{stdout:e}=await Xt(["ls-tree","--name-only","HEAD"],{cwd:t});return String(e??"").trim().length===0},Lle=async(t=process.cwd())=>{let{stdout:e}=await Xt(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},aS=async(t,e=process.cwd())=>{t||=await NF(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(`
|
|
148
148
|
`).forEach(i=>{r.forEach(s=>{let a=i===`?? ${s}`,c=i.startsWith(`?? ${s}/`)||i.startsWith(`?? ${s}${eC.sep}`);(a||c)&&n.push(`:!${s}`)});let o=i.match(Dle)?.[1];o&&n.push(`:!${o}.log`)}),n},Ule=async(t=process.cwd())=>{await Xt(["reset","--hard","HEAD"],{cwd:t})},Fle=async(t=process.cwd())=>{let e=await Xt(["clean","-fd","-e",".netlify"],{stdio:["ignore","pipe","pipe"],cwd:t});return String(e.stdout??"").split(`
|
|
149
149
|
`).filter(r=>r.startsWith("Removing ")).map(r=>r.slice(9))},MF=t=>{let e=t.split(`
|
|
@@ -345,7 +345,7 @@ NETLIFY_BUILD_BASE="\${NETLIFY_BUILD_BASE:-${l7e}}" ${e} ${r} <template-id> [--p
|
|
|
345
345
|
Replace \`<template-id>\` with the matching template \`id\`. Include \`--package-manager\` only if the user specified one. The templates can include relevant agent skills. The \`NETLIFY_BUILD_BASE=\u2026\` prefix lets the scaffold use a local template mirror if the platform set one \u2014 leave it as-is. Follow the instructions printed by the scaffold command.`:"",a="You are creating a new Netlify project to fulfill the user's request. The project directory is currently empty.",c=[a,s,a7e];return n?c=[a,c7e,s]:i&&(c=[a,o7e,s]),c.filter(Boolean).join(`
|
|
346
346
|
|
|
347
347
|
`)},p7e=t=>{try{return JSON.parse(KQe(YE.join(t,".netlify","scaffold-result.json"),"utf8"))}catch{return}},n_e=async t=>{let e=p7e(t);await Ct(ot(),"create-scaffold-telemetry",r=>{r?.setAttributes({"create.template":e?.template??"none","create.packageManager":e?.packageManager??"none"})})},i_e=async({config:t,cwd:e=KI.cwd()})=>await Ct(ot(),"create-stage",async r=>{let n=performance.now();r?.setAttributes({"create.runner":t.runner,"create.id":t.id,"create.sessionId":t.sessionId}),await e_e(e,[".netlify",".git","node_modules"]),Td.info("Cleaned cwd folder");let{nodeCmd:i,tsCliPath:o}=u7e({cwd:e}),s=[];if(o){let f=[o,"--list-addons-json"];Td.log(`Running ${i} ${f.join(" ")}`);let{stdout:p}=await It(i,f);s=d7e(p),Td.info("Retrieved add-ons")}else Td.warn("ts-cli binary not resolved; create-mode prompt will omit template section"),q.inc("context.degraded",1,{component:"templates"});let a=w4(t),c=a==="budget_constrained",l=a==="ask_first";l&&Td.log("Low budget create run - Instructing the agent to ask for clarity if necessary",{accountType:t.accountType,sessionCreditLimit:t.sessionCreditLimit}),q.inc("create.low_budget_limit_ask",1,{ask_first:l}),c&&Td.log("Budget-constrained create run \u2014 using plan + first-milestone instructions",{accountType:t.accountType,sessionCreditLimit:t.sessionCreditLimit}),q.inc("create.budget_constrained",1,{constrained:c});let u=f7e({templates:s,nodeCmd:i,scaffoldScriptPath:JQe,budgetConstrained:c,askUserClarity:l}),d=performance.now()-n;return r?.setAttributes({"create.duration.ms":d,"create.status":"success","create.budget_constrained":c,"create.ask_user_clarity":l}),{additionalContext:u}});var Da={Task:{name:"Task",category:G.Task},Agent:{name:"Task",category:G.Task},SendMessage:{name:"Message agent",category:G.Task},TaskOutput:{name:"Get task output",category:G.Task},TaskStop:{name:"Stop task",category:G.Task},TaskCreate:{name:"Update task list",category:G.Todo},TaskUpdate:{name:"Update task list",category:G.Todo},TaskList:{name:"Read task list",category:G.Todo},TaskGet:{name:"Read task list",category:G.Todo},ToolSearch:{name:"Load tools",category:G.Explore},Skill:{name:"Use skill",category:G.Skill},EnterPlanMode:{name:"Start planning",category:G.Plan},ListMcpResources:{name:"List resources",category:G.Explore},ReadMcpResource:{name:"Read resource",category:G.Explore},Bash:{name:"Run command",category:G.RunCommand},Glob:{name:"Find files",category:G.Explore},Grep:{name:"Search files",category:G.Explore},LS:{name:"List directory",category:G.Explore},ExitPlanMode:{name:"Exit planning",category:G.Plan},Read:{name:"Read file",category:G.FileRead},Edit:{name:"Edit file",category:G.FileWrite},MultiEdit:{name:"Edit multiple files",category:G.FileWrite},Write:{name:"Edit file",category:G.FileWrite},NotebookEdit:{name:"Edit notebook",category:G.Notebook},WebFetch:{name:"Fetch web",category:G.Web},TodoWrite:{name:"Update task list",category:G.Todo},WebSearch:{name:"Search web",category:G.Web},BashOutput:{name:"Get command output",category:G.RunCommand},KillBash:{name:"Stop command",category:G.RunCommand}},KE=t=>{if(Da[t])return Da[t].name;let e=t.match(/^mcp__(.+?)__(.+)$/);return e?`${e[2].replace(/_/g," ")} (${e[1]})`:t},C4=t=>t==="Task"||t==="Agent",o_e=t=>{let[e=""]=t.split(`
|
|
348
|
-
`,1);return/^(Async agent launched successfully|Agent launched in background)/.test(e)||/\(internal ID:?\s*[\w./-]+\)/i.test(e)},s_e=new Set(["SendMessage","ToolSearch","TaskList","TaskGet","EnterPlanMode","TaskStop"]);var Wr=oe("runner_claude"),ZI="Claude Code",ZE="claude-opus-5-5",I4="claude-sonnet-5";async function m7e({aiGateway:t,config:e,model:r}){let n=r;if(t)if(e.modelVersionOverrides?.claude){let i=e.modelVersionOverrides?.claude?.[e.accountType];if(i){if(!await t.isModelAvailableForProvider("anthropic",i))throw new Error(`Model override '${i}' is not available for anthropic provider`);n=i}}else r?await t.isModelAvailableForProvider("anthropic",r)||(Wr.log(`Model '${r}' is not available for anthropic provider, proceeding without model specification`),q.inc("model.unavailable",1,{provider:"anthropic"}),n=void 0):await t.isModelAvailableForProvider("anthropic",ZE)?(Wr.log(`Using default model: ${ZE}`),n=ZE):Wr.log(`Model ${ZE} is not available, proceeding without model specification`);return n}function g7e({aiGateway:t}){if(t){let{token:e,url:r}=t;if(!e||!r)throw new Error("No token or url provided from AI Gateway");return{...sm.env,ANTHROPIC_API_KEY:e,ANTHROPIC_BASE_URL:r}}if(!sm.env.ANTHROPIC_API_KEY)throw new Error("ANTHROPIC_API_KEY is not provided");return{...sm.env}}async function _7e(){let t=JE.join(sm.cwd(),"AGENTS.md");try{await om.access(t)}catch{return}let e=JE.join(sm.cwd(),"CLAUDE.local.md"),r="@AGENTS.md";try{if((await om.readFile(e,"utf-8")).includes(r))return;await om.appendFile(e,`
|
|
348
|
+
`,1);return/^(Async agent launched successfully|Agent launched in background)/.test(e)||/\(internal ID:?\s*[\w./-]+\)/i.test(e)},s_e=new Set(["SendMessage","ToolSearch","TaskList","TaskGet","EnterPlanMode","TaskStop"]);var Wr=oe("runner_claude"),ZI="Claude Code",ZE="claude-opus-5-5",I4="claude-sonnet-5-5";async function m7e({aiGateway:t,config:e,model:r}){let n=r;if(t)if(e.modelVersionOverrides?.claude){let i=e.modelVersionOverrides?.claude?.[e.accountType];if(i){if(!await t.isModelAvailableForProvider("anthropic",i))throw new Error(`Model override '${i}' is not available for anthropic provider`);n=i}}else r?await t.isModelAvailableForProvider("anthropic",r)||(Wr.log(`Model '${r}' is not available for anthropic provider, proceeding without model specification`),q.inc("model.unavailable",1,{provider:"anthropic"}),n=void 0):await t.isModelAvailableForProvider("anthropic",ZE)?(Wr.log(`Using default model: ${ZE}`),n=ZE):Wr.log(`Model ${ZE} is not available, proceeding without model specification`);return n}function g7e({aiGateway:t}){if(t){let{token:e,url:r}=t;if(!e||!r)throw new Error("No token or url provided from AI Gateway");return{...sm.env,ANTHROPIC_API_KEY:e,ANTHROPIC_BASE_URL:r}}if(!sm.env.ANTHROPIC_API_KEY)throw new Error("ANTHROPIC_API_KEY is not provided");return{...sm.env}}async function _7e(){let t=JE.join(sm.cwd(),"AGENTS.md");try{await om.access(t)}catch{return}let e=JE.join(sm.cwd(),"CLAUDE.local.md"),r="@AGENTS.md";try{if((await om.readFile(e,"utf-8")).includes(r))return;await om.appendFile(e,`
|
|
349
349
|
${r}
|
|
350
350
|
`)}catch{await om.writeFile(e,`${r}
|
|
351
351
|
`)}Wr.log("Added @AGENTS.md import to CLAUDE.local.md")}async function P4({config:t,persistSteps:e,aiGateway:r,continueSession:n,priorAgentSessionId:i,cwd:o=sm.cwd(),cliPath:s="netlify",abortSignal:a,onSessionId:c,forceLowEffortForCreditWrapUp:l}){let u=t,{prompt:d}=u,{model:f}=t,p="";await _7e();let h=g7e({aiGateway:r}),m=await m7e({config:t,aiGateway:r,model:f});l&&m?.includes("fable")&&(!r||await r.isModelAvailableForProvider("anthropic",I4))&&(Wr.log(`Credit wrap-up: downgrading model ${m} to ${I4}`),m=I4);let g=[],_=[],S={},T=new Set,y=[],w=J=>J?.match(/task\s+#([\w-]+)\s+created/i)?.[1],A=J=>{if(typeof J=="string")return J;if(Array.isArray(J))return J.filter(Oe=>Oe?.type==="text"&&typeof Oe.text=="string").map(Oe=>Oe.text).join(`
|
package/dist/bin.js
CHANGED
|
@@ -594,7 +594,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
594
594
|
`,LF:`
|
|
595
595
|
`,concatBytes:eW},Dbt=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},Mbt={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:Dbt};import{Buffer as Ubt}from"buffer";var Vwe=(t,e)=>t?void 0:Fbt.bind(void 0,e),Fbt=function*(t,e){if(typeof e!="string"&&!Br(e)&&!Ubt.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},Hwe=(t,e)=>t?jbt.bind(void 0,e):zbt.bind(void 0,e),jbt=function*(t,e){Gwe(t,e),yield e},zbt=function*(t,e){if(Gwe(t,e),typeof e!="string"&&!Br(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},Gwe=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
596
596
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
597
|
-
if (condition) { yield value; }`)};import{Buffer as qbt}from"buffer";import{StringDecoder as Bbt}from"string_decoder";var kP=(t,e,r)=>{if(r)return;if(t)return{transform:Vbt.bind(void 0,new TextEncoder)};let n=new Bbt(e);return{transform:Hbt.bind(void 0,n),final:Gbt.bind(void 0,n)}},Vbt=function*(t,e){qbt.isBuffer(e)?yield Nc(e):typeof e=="string"?yield t.encode(e):yield e},Hbt=function*(t,e){yield Br(e)?t.write(e):e},Gbt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Wwe}from"util";var rW=Wwe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),$P=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Ybt}=e[r];for await(let i of n(t))yield*$P(i,e,r+1)},Ywe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Wbt(r,Number(e),t)},Wbt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*$P(n,r,e+1)},Kwe=Wwe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),Ybt=function*(t){yield t};var nW=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Zwe=(t,e)=>[...e.flatMap(r=>[...Kf(r,t,0)]),...YT(t)],Kf=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Zbt}=e[r];for(let i of n(t))yield*Kf(i,e,r+1)},YT=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Kbt(r,Number(e),t)},Kbt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Kf(n,r,e+1)},Zbt=function*(t){yield t};var iW=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=Xwe(t,o,s),l=Yf(e),u=Yf(r),d=l?rW.bind(void 0,$P,a):nW.bind(void 0,Kf),f=l||u?rW.bind(void 0,Ywe,a):nW.bind(void 0,YT),p=l||u?Kwe.bind(void 0,a):void 0;return{stream:new Jbt({writableObjectMode:n,writableHighWaterMark:Jwe(n),readableObjectMode:i,readableHighWaterMark:Jwe(i),transform(m,_,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:p})}},LP=(t,e,r,n)=>{let i=e.filter(({type:o})=>o==="generator"),s=n?i.reverse():i;for(let{value:o,optionName:a}of s){let c=Xwe(o,r,a);t=Zwe(c,t)}return t},Xwe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:Vwe(n,a)},kP(r,o,n),NP(r,s,n,c),{transform:t,final:e},{transform:Hwe(i,a)},Bwe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var Qwe=(t,e)=>{for(let r of Xbt(t))Qbt(t,r,e)},Xbt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Qbt=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Iu[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>ewt(a,n));r.input=UT(o)},ewt=(t,e)=>{let r=LP(t,e,"utf8",!0);return twt(r),UT(r)},twt=t=>{let e=t.find(r=>typeof r!="string"&&!Br(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 swt,appendFileSync as owt}from"fs";var DP=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Cg(r,n)&&!Yi.has(e)&&rwt(n)&&(t.some(({type:i,value:s})=>i==="native"&&nwt.has(s))||t.every(({type:i})=>Is.has(i))),rwt=t=>t===1||t===2,nwt=new Set(["pipe","overlapped"]),eRe=async(t,e,r,n)=>{for await(let i of t)iwt(e)||rRe(i,r,n)},tRe=(t,e,r)=>{for(let n of t)rRe(n,e,r)},iwt=t=>t._readableState.pipes.length>0,rRe=(t,e,r)=>{let n=ZO(t);da({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var nRe=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let s={},o=new Set([]);return{output:e.map((c,l)=>awt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},awt=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=iwe(t,s,d),p=Nc(f),{stdioItems:h,objectMode:m}=e[r],_=cwt([p],h,c,n),{serializedResult:S,finalResult:E=S}=lwt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});uwt({serializedResult:S,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let y=a[r]?E:void 0;try{return n.error===void 0&&dwt(S,h,i),y}catch(g){return n.error=g,y}},cwt=(t,e,r,n)=>{try{return LP(t,e,r,!1)}catch(i){return n.error=i,t}},lwt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:UT(t)};let o=yve(t,r);return n[s]?{serializedResult:o,finalResult:tW(o,!i[s],e)}:{serializedResult:o}},uwt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!DP({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=tW(t,!1,o);try{tRe(a,e,n)}catch(c){r.error??=c}},dwt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>OP.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?owt(n,t):(r.add(s),swt(n,t))}};var iRe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Lc(e,r,"all")]:Array.isArray(e)?[Lc(t,r,"all"),...e]:Br(t)&&Br(e)?u3([t,e]):`${t}${e}`};import{once as sW}from"events";var sRe=async(t,e)=>{let[r,n]=await fwt(t);return e.isForcefullyTerminated??=!1,[r,n]},fwt=async t=>{let[e,r]=await Promise.allSettled([sW(t,"spawn"),sW(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?oRe(t):r.value},oRe=async t=>{try{return await sW(t,"exit")}catch{return oRe(t)}},aRe=async t=>{let[e,r]=await t;if(!pwt(e,r)&&oW(e,r))throw new co;return[e,r]},pwt=(t,e)=>t===void 0&&e===void 0,oW=(t,e)=>t!==0||e!==null;var cRe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=hwt(t,e,r),o=s?.code==="ETIMEDOUT",a=nwe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},hwt=(t,e,r)=>t!==void 0?t:oW(e,r)?new co:void 0;var lRe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=gwt(t,e,r),d=Swt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Ug(d,c,l)},gwt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=XO(t,e,r),a=_wt(r),{file:c,commandArguments:l,options:u}=yP(t,e,a);ywt(u);let d=Fwe(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},_wt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,ywt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&MP("ipcInput"),t&&MP("ipc: true"),r&&MP("detached: true"),n&&MP("cancelSignal")},MP=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Swt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=Ewt({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=cRe(c,r),{output:h,error:m=l}=nRe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((E,y)=>Lc(E,r,y)),S=Lc(iRe(h,r),r,"all");return Twt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:S,options:r,command:n,escapedCommand:i,startTime:a})},Ewt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{Qwe(s,r);let a=vwt(r);return mwt(...SP(t,e,a))}catch(a){return Mg({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},vwt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:AP(e)}),Twt=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:s,all:o,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?xP({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):WT({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as lAt}from"events";import{spawn as uAt}from"child_process";import hRe from"process";import{once as aW,on as bwt}from"events";var uRe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(Pg({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:fP(t)}),wwt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),wwt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{cP(e,i);let s=Cu(t,e,r),o=new AbortController;try{return await Promise.race([Rwt(s,n,o),Awt(s,r,o),xwt(s,r,o)])}catch(a){throw Ng(t),a}finally{o.abort(),lP(e,i)}},Rwt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await aW(t,"message",{signal:r});return n}for await(let[n]of bwt(t,"message",{signal:r}))if(e(n))return n},Awt=async(t,e,{signal:r})=>{await aW(t,"disconnect",{signal:r}),ZTe(e)},xwt=async(t,e,{signal:r})=>{let[n]=await aW(t,"strict:error",{signal:r});throw sP(n,e)};import{once as fRe,on as Cwt}from"events";var pRe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>cW({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),cW=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{Pg({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:fP(t)}),cP(e,s);let o=Cu(t,e,r),a=new AbortController,c={};return Iwt(t,o,a),Owt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),Pwt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},Iwt=async(t,e,r)=>{try{await fRe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Owt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await fRe(t,"strict:error",{signal:r.signal});n.error=sP(i,e),r.abort()}catch{}},Pwt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of Cwt(r,"message",{signal:s.signal}))dRe(o),yield c}catch{dRe(o)}finally{s.abort(),lP(e,a),n||Ng(t),i&&await t}},dRe=({error:t})=>{if(t)throw t};var mRe=(t,{ipc:e})=>{Object.assign(t,_Re(t,!1,e))},gRe=()=>{let t=hRe,e=!0,r=hRe.channel!==void 0;return{..._Re(t,e,r),getCancelSignal:bbe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},_Re=(t,e,r)=>({sendMessage:gP.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:uRe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:pRe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Nwt}from"child_process";import{PassThrough as kwt,Readable as $wt,Writable as Lwt,Duplex as Dwt}from"stream";var yRe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{X3(n);let a=new Nwt;Mwt(a,n),Object.assign(a,{readable:Uwt,writable:Fwt,duplex:jwt});let c=Mg({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=zwt(c,o,i);return{subprocess:a,promise:l}},Mwt=(t,e)=>{let r=KT(),n=KT(),i=KT(),s=Array.from({length:e.length-3},KT),o=KT(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},KT=()=>{let t=new kwt;return t.end(),t},Uwt=()=>new $wt({read(){}}),Fwt=()=>new Lwt({write(){}}),jwt=()=>new Dwt({read(){},write(){}}),zwt=async(t,e,r)=>Ug(t,e,r);import{createReadStream as SRe,createWriteStream as ERe}from"fs";import{Buffer as qwt}from"buffer";import{Readable as ZT,Writable as Bwt,Duplex as Vwt}from"stream";var TRe=(t,e)=>PP(Hwt,t,e,!1),JT=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Iu[t]}.`)},vRe={fileNumber:JT,generator:iW,asyncGenerator:iW,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Vwt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Hwt={input:{...vRe,fileUrl:({value:t})=>({stream:SRe(t)}),filePath:({value:{file:t}})=>({stream:SRe(t)}),webStream:({value:t})=>({stream:ZT.fromWeb(t)}),iterable:({value:t})=>({stream:ZT.from(t)}),asyncIterable:({value:t})=>({stream:ZT.from(t)}),string:({value:t})=>({stream:ZT.from(t)}),uint8Array:({value:t})=>({stream:ZT.from(qwt.from(t))})},output:{...vRe,fileUrl:({value:t})=>({stream:ERe(t)}),filePath:({value:{file:t,append:e}})=>({stream:ERe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Bwt.fromWeb(t)}),iterable:JT,asyncIterable:JT,string:JT,uint8Array:JT}};import{on as Gwt,once as bRe}from"events";import{PassThrough as Wwt,getDefaultHighWaterMark as Ywt}from"stream";import{finished as ARe}from"stream/promises";function Zf(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)uW(i);let e=t.some(({readableObjectMode:i})=>i),r=Kwt(t,e),n=new lW({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Kwt=(t,e)=>{if(t.length===0)return Ywt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},lW=class extends Wwt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(uW(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Zwt(this,this.#e,this.#s);let r=Qwt({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#s});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(uW(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},Zwt=async(t,e,r)=>{UP(t,wRe);let n=new AbortController;try{await Promise.race([Jwt(t,n),Xwt(t,e,r,n)])}finally{n.abort(),UP(t,-wRe)}},Jwt=async(t,{signal:e})=>{try{await ARe(t,{signal:e,cleanup:!0})}catch(r){throw xRe(t,r),r}},Xwt=async(t,e,r,{signal:n})=>{for await(let[i]of Gwt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},uW=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Qwt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{UP(t,RRe);let a=new AbortController;try{await Promise.race([eRt(s,e,a),tRt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),rRt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),UP(t,-RRe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?dW(t):nRt(t))},eRt=async(t,e,{signal:r})=>{try{await t,r.aborted||dW(e)}catch(n){r.aborted||xRe(e,n)}},tRt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await ARe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;CRe(o)?i.add(e):IRe(t,o)}},rRt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await bRe(t,i,{signal:s}),!t.readable)return bRe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},nRt=t=>{t.writable&&t.end()},xRe=(t,e)=>{CRe(e)?dW(t):IRe(t,e)},CRe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",dW=t=>{(t.readable||t.writable)&&t.destroy()},IRe=(t,e)=>{t.destroyed||(t.once("error",iRt),t.destroy(e))},iRt=()=>{},UP=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},wRe=2,RRe=1;import{finished as ORe}from"stream/promises";var jg=(t,e)=>{t.pipe(e),sRt(t,e),oRt(t,e)},sRt=async(t,e)=>{if(!(ao(t)||ao(e))){try{await ORe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}fW(e)}},fW=t=>{t.writable&&t.end()},oRt=async(t,e)=>{if(!(ao(t)||ao(e))){try{await ORe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}pW(t)}},pW=t=>{t.readable&&t.destroy()};var PRe=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:s,direction:o}]of Object.entries(e)){for(let{stream:a}of s.filter(({type:c})=>Is.has(c)))aRt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Is.has(c)))lRt({subprocess:t,stream:a,direction:o,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,s]of n.entries()){let o=s.length===1?s[0]:Zf(s);jg(o,i)}},aRt=(t,e,r,n)=>{r==="output"?jg(t.stdio[n],e):jg(e,t.stdio[n]);let i=cRt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},cRt=["stdin","stdout","stderr"],lRt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;uRt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},uRt=(t,{signal:e})=>{ao(t)&&Gf(t,dRt,e)},dRt=2;import{addAbortListener as hRt}from"events";var Jf=[];Jf.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Jf.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Jf.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var FP=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",hW=Symbol.for("signal-exit emitter"),mW=globalThis,fRt=Object.defineProperty.bind(Object),gW=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(mW[hW])return mW[hW];fRt(mW,hW,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let s of this.listeners[e])i=s(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},jP=class{},pRt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),_W=class extends jP{onExit(){return()=>{}}load(){}unload(){}},yW=class extends jP{#e=SW.platform==="win32"?"SIGINT":"SIGHUP";#r=new gW;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Jf)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,s=e;if(typeof s.__signal_exit_emitter__=="object"&&typeof s.__signal_exit_emitter__.count=="number"&&(i+=s.__signal_exit_emitter__.count),n.length===i){this.unload();let o=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;o||e.kill(e.pid,a)}};this.#s=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!FP(this.#t))return()=>{};this.#o===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#r.on(n,e),()=>{this.#r.removeListener(n,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#o){this.#o=!0,this.#r.count+=1;for(let e of Jf)try{let r=this.#i[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#o&&(this.#o=!1,Jf.forEach(e=>{let r=this.#i[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#s,this.#r.count-=1)}#a(e){return FP(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#s.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&FP(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let i=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),i}else return n.call(this.#t,e,...r)}},SW=globalThis.process,{onExit:NRe,load:Lmr,unload:Dmr}=pRt(FP(SW)?new yW(SW):new _W);var kRe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=NRe(()=>{t.kill()});hRt(n,()=>{i()})};var LRe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=JO(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=mRt(r,n,i),{sourceStream:d,sourceError:f}=_Rt(t,l),{options:p,fileDescriptors:h}=pa.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},mRt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=gRt(t,e,...r),a=aP(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},gRt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e($Re,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||c3(r)){if(Object.keys(t).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[i,s,o]=zO(r,...n);return{destination:e($Re)(i,s,o),pipeOptions:o}}if(pa.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}`)},$Re=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),_Rt=(t,e)=>{try{return{sourceStream:kg(t,e)}}catch(r){return{sourceError:r}}};var MRe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=yRt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw EW({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},yRt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return pW(t),n;if(e!==void 0)return fW(r),e},EW=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Mg({error:t,command:DRe,escapedCommand:DRe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),DRe="source.pipe(destination)";var URe=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:s,value:o=s}]=await t;if(o.pipedFrom.includes(n)||o.pipedFrom.push(n),i==="rejected")throw o;if(e==="rejected")throw n;return o};import{finished as SRt}from"stream/promises";var FRe=(t,e,r)=>{let n=zP.has(e)?vRt(t,e):ERt(t,e);return Gf(t,bRt,r.signal),Gf(e,wRt,r.signal),TRt(e),n},ERt=(t,e)=>{let r=Zf([t]);return jg(r,e),zP.set(e,r),r},vRt=(t,e)=>{let r=zP.get(e);return r.add(t),r},TRt=async t=>{try{await SRt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}zP.delete(t)},zP=new WeakMap,bRt=2,wRt=1;import{aborted as RRt}from"util";var jRe=(t,e)=>t===void 0?[]:[ARt(t,e)],ARt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await RRt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw EW({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var qP=(t,...e)=>{if(Cr(e[0]))return qP.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=LRe(t,...e),i=xRt({...n,destination:r});return i.pipe=qP.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},xRt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=CRt(t,i);MRe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=FRe(e,s,d);return await Promise.race([URe(u),...jRe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},CRt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as LRt}from"timers/promises";import{on as IRt}from"events";import{getDefaultHighWaterMark as ORt}from"stream";var BP=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return PRt(e,o),qRe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},PRt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},vW=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;NRt(e,o,t);let a=t.readableObjectMode&&!s;return qRe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},NRt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},qRe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=IRt(t,"data",{signal:e.signal,highWaterMark:zRe,highWatermark:zRe});return kRt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},TW=ORt(!0),zRe=TW,kRt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=$Rt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Kf(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*YT(a)}},$Rt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[kP(t,r,!e),NP(t,i,!n,{})].filter(Boolean);var BRe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=DRt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([MRt(t),d]);return}let f=Q3(c,r),p=vW({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([URt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},DRt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!DP({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=vW({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await eRe(a,t,r,s)},MRt=async t=>{await LRt(),t.readableFlowing===null&&t.resume()},URt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await bP(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await wP(r,{maxBuffer:s})):await Dg(r,{maxBuffer:s})}catch(a){return VRe(ewe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},bW=async t=>{try{return await t}catch(e){return VRe(e)}},VRe=({bufferedData:t})=>gve(t)?new Uint8Array(t):t;import{finished as FRt}from"stream/promises";var XT=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=jRt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],FRt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||BRt(a,e,r,n)}finally{o.abort()}},jRt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&zRt(t,r,n),n},zRt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{qRt(e,r),n.call(t,...i)}},qRt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},BRt=(t,e,r,n)=>{if(!VRt(t,e,r,n))throw t},VRt=(t,e,r,n=!0)=>r.propagating?HRe(t)||VP(t):(r.propagating=!0,wW(r,e)===n?HRe(t):VP(t)),wW=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",VP=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",HRe=t=>t?.code==="EPIPE";var GRe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>RW({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),RW=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=XT(t,e,l);if(wW(l,e)){await u;return}let[d]=await Promise.all([BRe({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var WRe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Zf([t,e].filter(Boolean)):void 0,YRe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>RW({...HRt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:GRt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),HRt=({stdout:t,stderr:e,all:r},[,n,i])=>{let s=n||i;return s?n?i?{stream:r,buffer:s}:{stream:t,buffer:s}:{stream:e,buffer:s}:{stream:r,buffer:s}},GRt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as WRt}from"events";var KRe=t=>Cg(t,"ipc"),ZRe=(t,e)=>{let r=ZO(t);da({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var JRe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=KRe(s),a=kc(e,"ipc"),c=kc(r,"ipc");for await(let l of cW({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(twe(t,i,c),i.push(l)),o&&ZRe(l,s);return i},XRe=async(t,e)=>(await Promise.allSettled([t]),e);var QRe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:_,controller:S})=>{let E=sRe(t,f),y={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:E,propagating:!1},g=GRe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:y}),T=YRe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:y}),w=[],A=JRe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:w,verboseInfo:p}),b=YRt(m,t,y),C=KRt(h,y);try{return await Promise.race([Promise.all([{},aRe(E),Promise.all(g),T,A,kbe(t,d),...b,...C]),_,ZRt(t,S),...Cbe(t,s,f,S),...KTe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:S}),...Abe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(P){return f.terminationReason??="other",Promise.all([{error:P},E,Promise.all(g.map(x=>bW(x))),bW(T),XRe(A,w),Promise.allSettled(b),Promise.allSettled(C)])}},YRt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:XT(n,i,r)),KRt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>uo(s,{checkOpen:!1})&&!ao(s)).map(({type:i,value:s,stream:o=s})=>XT(o,n,e,{isSameDirection:Is.has(i),stopOnExit:i==="native"}))),ZRt=async(t,{signal:e})=>{let[r]=await WRt(t,"error",{signal:e});throw r};var eAe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),QT=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=fa();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},zg=async({resolve:t,promises:e},r)=>{t();let[n]=await Promise.race([Promise.allSettled([!0,r]),Promise.all([!1,...e])]);return!n};import{Readable as JRt}from"stream";import{callbackify as XRt}from"util";import{finished as tAe}from"stream/promises";var AW=async t=>{if(t!==void 0)try{await xW(t)}catch{}},rAe=async t=>{if(t!==void 0)try{await CW(t)}catch{}},xW=async t=>{await tAe(t,{cleanup:!0,readable:!1,writable:!0})},CW=async t=>{await tAe(t,{cleanup:!0,readable:!0,writable:!1})},HP=async(t,e)=>{if(await t,e)throw e},GP=(t,e,r)=>{r&&!VP(r)?t.destroy(r):e&&t.destroy()};var nAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||Yi.has(r),{subprocessStdout:a,waitReadableDestroy:c}=IW(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=OW(a,o),{read:f,onStdoutDataDone:p}=PW({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new JRt({read:f,destroy:XRt(kW.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return NW({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},IW=(t,e,r)=>{let n=kg(t,e),i=QT(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},OW=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:TW},PW=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=fa(),o=BP({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){QRt(this,o,s)},onStdoutDataDone:s}},QRt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},NW=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await CW(t),await n,await AW(i),await e,r.readable&&r.push(null)}catch(s){await AW(i),iAe(r,s)}},kW=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await zg(r,e)&&(iAe(t,n),await HP(e,n))},iAe=(t,e)=>{GP(t,t.readable,e)};import{Writable as eAt}from"stream";import{callbackify as sAe}from"util";var oAe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=$W(t,r,e),o=new eAt({...LW(n,t,i),destroy:sAe(MW.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return DW(n,o),o},$W=(t,e,r)=>{let n=aP(t,e),i=QT(r,n,"writableFinal"),s=QT(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},LW=(t,e,r)=>({write:tAt.bind(void 0,t),final:sAe(rAt.bind(void 0,t,e,r))}),tAt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},rAt=async(t,e,r)=>{await zg(r,e)&&(t.writable&&t.end(),await e)},DW=async(t,e,r)=>{try{await xW(t),e.writable&&e.end()}catch(n){await rAe(r),aAe(e,n)}},MW=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await zg(r,e),await zg(n,e)&&(aAe(t,i),await HP(e,i))},aAe=(t,e)=>{GP(t,t.writable,e)};import{Duplex as nAt}from"stream";import{callbackify as iAt}from"util";var cAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||Yi.has(r),{subprocessStdout:c,waitReadableDestroy:l}=IW(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=$W(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=OW(c,a),{read:_,onStdoutDataDone:S}=PW({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),E=new nAt({read:_,...LW(u,t,d),destroy:iAt(sAt.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return NW({subprocessStdout:c,onStdoutDataDone:S,readable:E,subprocess:t,subprocessStdin:u}),DW(u,E,c),E},sAt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([kW({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),MW({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var UW=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||Yi.has(e),o=kg(t,r),a=BP({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return oAt(a,o,t)},oAt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var lAe=(t,{encoding:e})=>{let r=eAe();t.readable=nAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=oAe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=cAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=UW.bind(void 0,t,e),t[Symbol.asyncIterator]=UW.bind(void 0,t,e,{})};var uAe=(t,e)=>{for(let[r,n]of cAt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},aAt=(async()=>{})().constructor.prototype,cAt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(aAt,t)]);var dAe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=dAt(t,e,r),{subprocess:f,promise:p}=pAt({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=qP.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),uAe(f,p),pa.set(f,{options:u,fileDescriptors:d}),f},dAt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=XO(t,e,r),{file:a,commandArguments:c,options:l}=yP(t,e,r),u=fAt(l),d=TRe(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},fAt=({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}},pAt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=uAt(...SP(t,e,r))}catch(h){return yRe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;lAt(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];PRe(c,a,l),kRe(c,r,l);let d={},f=fa();c.kill=WTe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=WRe(c,r),lAe(c,r),mRe(c,r);let p=hAt({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:s,escapedCommand:o,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},hAt=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:s,command:o,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,_]=await QRe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:l,controller:u});u.abort(),l.resolve();let S=h.map((g,T)=>Lc(g,e,T)),E=Lc(m,e,"all"),y=mAt({errorInfo:d,exitCode:f,signal:p,stdio:S,all:E,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Ug(y,n,e)},mAt=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,context:o,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?WT({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 ha,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):xP({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var WP=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,gAt(n,t[n],i)]));return{...t,...r}},gAt=(t,e,r)=>_At.has(t)&&Cr(e)&&Cr(r)?{...e,...r}:r,_At=new Set(["env",...h3]);var Ou=(t,e,r,n)=>{let i=(o,a,c)=>Ou(o,a,r,c),s=(...o)=>yAt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},yAt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Cr(s))return i(t,WP(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=SAt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?lRe(a,c,l):dAe(a,c,l,i)},SAt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=Tve(e)?bve(e,r):[e,...r],[o,a,c]=zO(...s),l=WP(WP(n,i),c),{file:u=o,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:o,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var fAe=({file:t,commandArguments:e})=>hAe(t,e),pAe=({file:t,commandArguments:e})=>({...hAe(t,e),isSync:!0}),hAe=(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]=EAt(t);return{file:r,commandArguments:n}},EAt=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(vAt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},vAt=/ +/g;var mAe=(t,e,r)=>{t.sync=e(TAt,r),t.s=t.sync},gAe=({options:t})=>_Ae(t),TAt=({options:t})=>({..._Ae(t),isSync:!0}),_Ae=t=>({options:{...bAt(t),...t}}),bAt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},yAe={preferLocal:!0};var SAe=Ou(()=>({})),Ryr=Ou(()=>({isSync:!0})),EAe=Ou(fAe),Ayr=Ou(pAe),xyr=Ou(Obe),Cyr=Ou(gAe,{},yAe,mAe),{sendMessage:Iyr,getOneMessage:Oyr,getEachMessage:Pyr,getCancelSignal:Nyr}=gRe();import{Transform as wAt}from"stream";var RAt=["NETLIFY_AI_GATEWAY_KEY"];function AAt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...RAt])]}function xAt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function CAt(){let e=AAt().map(r=>process.env[r]).filter(r=>!(!r||xAt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Pi(t){if(typeof t!="string")return t;let e=CAt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(IAt(n),"g");r=r.replace(i,"******")}),r}function IAt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var eb=class extends wAt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Pi(i);n(null,s)}},YP=Symbol("maskedWrite");function vAe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[YP]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Pi(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[YP]=!0,process.stdout.write=r}if(!process.stderr.write[YP]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Pi(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[YP]=!0,process.stderr.write=r}}}var TAe=!1,bAe,FW=t=>{bAe??=t},wAe=t=>{TAe=!0,FW(t)},Cn=()=>TAe,ga=()=>bAe,RAe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var tb=null,AAe=t=>(tb&&tb.destroy(),tb=new fo({totalAllowedTime:t}),tb),xAe=()=>tb;var fo=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&Cn())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let s=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),o=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await DO({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}),s(),o&&clearTimeout(o)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var CAe={name:"@netlify/agent-runner-cli",type:"module",version:"1.189.2",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",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:opencode":"vitest run test/integration/opencode.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.6","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.280","@anthropic-ai/sdk":"^0.128.0","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.1","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.153.4","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var kAt=PAt(import.meta.url),$At=Dc.dirname(kAt),LAt=NAt(import.meta.url),qg=fe("shell"),jW=new Set,IAe={preferLocal:!0},sr=(t,e,r)=>{let[n,i]=DAt(e,r),s={...IAe,...i},o=SAe(t,n,s);PAe(o,s),$Ae(o);let a=r?.idleTimeout;return a&&a>0&&kAe(o,a),o},OAe=(t,e)=>{let r={...IAe,...e},n=EAe(t,r);return PAe(n,r),$Ae(n),e?.idleTimeout&&e.idleTimeout>0&&kAe(n,e.idleTimeout),n},DAt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},PAe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||_a.env.NETLIFY_LOCAL_QUIET==="true")return;if(_a.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new eb).pipe(_a.stdout),t.stderr?.pipe(new eb).pipe(_a.stderr);return}t.stdout?.pipe(_a.stdout),t.stderr?.pipe(_a.stderr)},zW=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(_a.kill(-t.pid,e),qg.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return qg.error("Error killing process:",r),!1}},NAe=t=>zW(t,"SIGKILL"),kAe=(t,e)=>{let r=null,n=()=>{qg.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),zW(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(qg.log(`Force killing idle process ${t.pid}`),NAe(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let s=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",s),t.on("error",s)},$Ae=t=>{jW.add(t);let e=xAe();if(e){let r=e.onTimesUp(()=>{qg.log(`Global timer expired, killing process ${t.pid}`),zW(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(qg.log(`Force killing process ${t.pid} after timeout`),NAe(t))},5e3)});t.on("exit",()=>{jW.delete(t),r()}),t.on("error",()=>{jW.delete(t),r()})}};function ya(t,e){if(!_a.env.NETLIFY_LOCAL_MODE)try{let i=LAt.resolve(CAe.name),s=Dc.dirname(i);for(;s!==Dc.dirname(s);){let o=Dc.dirname(s);if(Dc.basename(o)==="node_modules"){let a=Dc.join(o,".bin",e);if(KP.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(_a.env.NODE_PATH){let i=Dc.join(_a.env.NODE_PATH,".bin",e);if(KP.existsSync(i))return i}let r=Dc.join(t,"node_modules",".bin",e);if(KP.existsSync(r))return r;let n=Dc.join($At,"..","node_modules",".bin",e);if(KP.existsSync(n))return n}import yD from"process";import{fileURLToPath as dFt}from"url";import{createRequire as fFt}from"module";import tR from"path";import{readFileSync as pFt}from"fs";var MAt="__netlify__getTracer",UAt="__netlify__shutdownTracers",Tt=(t,e)=>globalThis[MAt]?.(t,e),LAe=async()=>globalThis[UAt]?.();function rb(t,e,r,n,i){let s=typeof n=="function"?n:typeof r=="function"?r:i;if(!s)throw new Error("function to execute with active span is missing");return t?t.withActiveSpan(e,r,n,s):s()}import{setTimeout as iFt}from"timers/promises";Ne();import Fxt from"process";Ne();var c0t=(t,e)=>{e.recordException(t),e.setStatus({code:Gn.ERROR})};var Fc=class{constructor(e){this._tracer=e,this.startSpan=e.startSpan.bind(this._tracer),this.startActiveSpan=e.startActiveSpan.bind(this._tracer)}withActiveSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=C0e(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>I0e(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=C0e(r,n,i),c=this._tracer.startSpan(e,s,o);return I0e(c,s,a)}};function C0e(t,e,r){let n,i,s;return!e&&!r?s=t:r?(n=t,i=e,s=r):(n=t,s=e),n=n??{},i=i??Gt.active(),{opts:n,ctx:i,fn:s}}function I0e(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:c0t,s=o=>{throw i(o,t),t.end(),o};try{let o=r(t);return typeof o?.then=="function"?o.then(a=>(t.end(),a),s):(t.end(),o)}catch(o){throw s(o)}}Ne();var Kg=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var vY=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=F0e(e),n._asyncAttributesPending=e.filter(([i,s])=>Kg(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(Kg(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=F0e(this._rawAttributes),this._schemaUrl=l0t(r?.schemaUrl)}get asyncAttributesPending(){return this._asyncAttributesPending}async waitForAsyncAttributes(){if(this.asyncAttributesPending){for(let e=0;e<this._rawAttributes.length;e++){let[r,n]=this._rawAttributes[e];this._rawAttributes[e]=[r,Kg(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&ue.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(Kg(n)){ue.debug(`Unsettled resource attribute ${r} skipped`);continue}n!=null&&(e[r]??=n)}return this._asyncAttributesPending||(this._memoizedAttributes=e),e}getRawAttributes(){return this._rawAttributes}get schemaUrl(){return this._schemaUrl}merge(e){if(e==null)return this;let r=u0t(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function TY(t,e){return vY.FromAttributeList(Object.entries(t),e)}function F0e(t){return t.map(([e,r])=>Kg(r)?[e,r.catch(n=>{ue.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function l0t(t){if(typeof t=="string"||t===void 0)return t;ue.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function u0t(t,e){let r=t?.schemaUrl,n=e?.schemaUrl,i=r===void 0||r==="",s=n===void 0||n==="";if(i)return n;if(s||r===n)return r;ue.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}Ne();var hb=class{emit(e){}enabled(){return!1}},j0e=new hb;var mb=Symbol.for("io.opentelemetry.js.api.logs"),Zg=globalThis;function z0e(t,e,r){return n=>n===t?e:r}var bY=1;var wY=class{getLogger(e,r,n){return new hb}},yN=new wY;var SN=class{constructor(e,r,n,i){this._provider=e,this.name=r,this.version=n,this.options=i}emit(e){this._getLogger().emit(e)}enabled(e){return this._getLogger().enabled(e)}_getLogger(){if(this._delegate)return this._delegate;let e=this._provider._getDelegateLogger(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):j0e}};var gb=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new SN(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:yN}_setDelegate(e){this._delegate=e}_getDelegateLogger(e,r,n){var i;return(i=this._delegate)===null||i===void 0?void 0:i.getLogger(e,r,n)}};var EN=class t{constructor(){this._proxyLoggerProvider=new gb}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return Zg[mb]?this.getLoggerProvider():(Zg[mb]=z0e(bY,e,yN),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=Zg[mb])===null||e===void 0?void 0:e.call(Zg,bY))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete Zg[mb],this._proxyLoggerProvider=new gb}};var q0e=EN.getInstance();function B0e(t,e,r,n){for(let i=0,s=t.length;i<s;i++){let o=t[i];e&&o.setTracerProvider(e),r&&o.setMeterProvider(r),n&&o.setLoggerProvider&&o.setLoggerProvider(n),o.getConfig().enabled||o.enable()}}function V0e(t){t.forEach(e=>e.disable())}function RY(t){let e=t.tracerProvider||Ot.getTracerProvider(),r=t.meterProvider||pb.getMeterProvider(),n=t.loggerProvider||q0e.getLoggerProvider(),i=t.instrumentations?.flat()??[];return B0e(i,e,r,n),()=>{V0e(i)}}Ne();var d0t=Qr("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function H0e(t){return t.getValue(d0t)===!0}var Jg;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(Jg||(Jg={}));Ne();var AY="[_0-9a-z-*/]",f0t=`[a-z]${AY}{0,255}`,p0t=`[a-z0-9]${AY}{0,240}@[a-z]${AY}{0,13}`,h0t=new RegExp(`^(?:${f0t}|${p0t})$`),m0t=/^[ -~]{0,255}[!-~]$/,g0t=/,|=/;function xY(t){return h0t.test(t)}function CY(t){return m0t.test(t)&&!g0t.test(t)}var _0t=32,G0e=512,W0e=",",Y0e="=",vN=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!xY(e)||!CY(r))return this;let n=this._getState(),i=n.get(e),s=this._length;if(typeof i=="string"?s+=r.length-i.length:s+=e.length+r.length+(n.size>0?2:1),s>G0e)return this;let o=new Map(n);return o.delete(e),o.set(e,r),this._fromState(o,s)}unset(e){let r=this._getState(),n=r.get(e);if(typeof n!="string")return this;let i=this._length-(e.length+n.length+1);r.size>1&&(i=i-1);let s=new Map(r);return s.delete(e),this._fromState(s,i)}get(e){return this._getState().get(e)}serialize(){let e="",r=0;for(let n of this._getState())r>0&&(e=W0e+e),e=`${n[0]}${Y0e}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(W0e),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(Y0e);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!xY(a)||!CY(c))continue;let l=n+s.length+(r.size>0?1:0);if(!(l>G0e)&&(r.set(a,c),n=l,r.size>=_0t))break}return this._length=n,this._internalState=new Map(Array.from(r.entries()).reverse()),this._internalState}_fromState(e,r){let n=Object.create(t.prototype);return n._internalState=e,n._length=r,n}};var TN="traceparent",bN="tracestate",y0t="00",S0t="(?!ff)[\\da-f]{2}",E0t="(?![0]{32})[\\da-f]{32}",v0t="(?![0]{16})[\\da-f]{16}",T0t="[\\da-f]{2}",b0t=new RegExp(`^\\s?(${S0t})-(${E0t})-(${v0t})-(${T0t})(-.*)?\\s?$`);function K0e(t){let e=b0t.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var ku=class{inject(e,r,n){let i=Ot.getSpanContext(e);if(!i||H0e(e)||!Ni(i))return;let s=`${y0t}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||Er.NONE).toString(16)}`;n.set(r,TN,s),i.traceState&&n.set(r,bN,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,TN);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=K0e(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,bN);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new vN(typeof c=="string"?c:void 0)}return Ot.setSpanContext(e,o)}fields(){return[TN,bN]}};var wN=class{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,r)=>{this._resolve=e,this._reject=r})}get promise(){return this._promise}resolve(e){this._resolve(e)}reject(e){this._reject(e)}};var _b=class{_isCalled=!1;_deferred=new wN;_callback;_that;constructor(e,r){this._callback=e,this._that=r}get isCalled(){return this._isCalled}get promise(){return this._deferred.promise}call(...e){if(!this._isCalled){this._isCalled=!0;try{Promise.resolve(this._callback.call(this._that,...e)).then(r=>this._deferred.resolve(r),r=>this._deferred.reject(r))}catch(r){this._deferred.reject(r)}}return this._deferred.promise}};var mk=pn(pK(),1);Ne();var PIe=t=>{throw TypeError(t)},_K=(t,e,r)=>e.has(t)||PIe("Cannot "+r),hk=(t,e,r)=>(_K(t,e,"read from private field"),r?r.call(t):e.get(t)),hK=(t,e,r)=>e.has(t)?PIe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),CIe=(t,e,r,n)=>(_K(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),Uxt=(t,e,r)=>(_K(t,e,"access private method"),r),IIe="__netlify__getTracer",jxt="__netlify__shutdownTracers",zxt="__nfOTLPTrace",Nb,kb,gK,NIe,qxt=class{constructor(){hK(this,gK),hK(this,Nb),hK(this,kb),CIe(this,Nb,new _b(Uxt(this,gK,NIe),this)),CIe(this,kb,ue.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(hk(this,kb).debug(`export ${t.length.toString()} spans`),hk(this,Nb).isCalled){e({code:Jg.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(zxt,JSON.stringify(Bxt(t))),e({code:Jg.SUCCESS})}shutdown(){return hk(this,Nb).call()}};Nb=new WeakMap;kb=new WeakMap;gK=new WeakSet;NIe=function(){return hk(this,kb).debug("Shutting down"),Promise.resolve()};function Bxt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:pk(e.resource.attributes),droppedAttributesCount:e.droppedAttributesCount},scopeSpans:[{scope:{name:e.instrumentationScope.name,version:e.instrumentationScope.version},spans:[{traceId:r.traceId,spanId:r.spanId,parentSpanId:e.parentSpanContext?.spanId,name:e.name,kind:e.kind||po.SERVER,startTimeUnixNano:mK(e.startTime),endTimeUnixNano:mK(e.endTime),attributes:pk(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:mK(n.time),attributes:pk(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedEventsCount:e.droppedEventsCount,status:{code:e.status.code,message:e.status.message},links:e.links.map(n=>({spanId:n.context.spanId,traceId:n.context.traceId,attributes:pk(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function pk(t){return Object.keys(t).map(e=>kIe(e,t[e]))}function kIe(t,e){return{key:t,value:$Ie(e)}}function $Ie(t){let e=typeof t;return e==="string"?{stringValue:t}:e==="number"?Number.isInteger(t)?{intValue:t}:{doubleValue:t}:e==="boolean"?{boolValue:t}:t instanceof Uint8Array?{bytesValue:t}:Array.isArray(t)?{arrayValue:{values:t.map($Ie)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>kIe(r,n))}}:{}}function mK(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var OIe={name:"@netlify/otel",version:"6.0.6",type:"module",engines:{node:"^18.14.0 || >=20.6.1"},main:"./dist/main.cjs",module:"./dist/main.js",types:"./dist/main.d.ts",exports:{".":{require:{types:"./dist/main.d.cts",default:"./dist/main.cjs"},import:{types:"./dist/main.d.ts",default:"./dist/main.js"},default:{types:"./dist/main.d.ts",default:"./dist/main.js"}},"./package.json":"./package.json","./bootstrap":{require:{types:"./dist/bootstrap/main.d.cts",default:"./dist/bootstrap/main.cjs"},import:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"},default:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"}},"./exporter-netlify":{require:{types:"./dist/exporters/netlify.d.cts",default:"./dist/exporters/netlify.cjs"},import:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"},default:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"}},"./instrumentation-fetch":{require:{types:"./dist/instrumentations/fetch.d.cts",default:"./dist/instrumentations/fetch.cjs"},import:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"},default:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"}},"./instrumentation-http":{require:{types:"./dist/instrumentations/http.d.cts",default:"./dist/instrumentations/http.cjs"},import:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"},default:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"}},"./opentelemetry":{require:{types:"./dist/opentelemetry.d.cts",default:"./dist/opentelemetry.cjs"},import:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"},default:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"}}},files:["dist/**/*"],scripts:{build:"tsup-node",dev:"tsup-node --watch",prepack:"npm run build",test:"run-s build test:ci","test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"vitest","test:dev:vitest:watch":"vitest watch","test:ci:vitest":"vitest run",publint:"npx -y publint --strict"},keywords:["netlify","cdn"],license:"MIT",repository:{type:"git",url:"https://github.com/netlify/primitives.git",directory:"packages/otel"},bugs:{url:"https://github.com/netlify/primitives/issues"},author:"Netlify Inc.",devDependencies:{"@netlify/dev-utils":"^5.0.0",msw:"^2.10.5","npm-run-all2":"^7.0.2",tsup:"^8.0.0",vitest:"^3.0.0"},dependencies:{"@opentelemetry/api":"1.9.1","@opentelemetry/core":"2.8.0","@opentelemetry/instrumentation":"^0.220.0","@opentelemetry/resources":"2.9.0","@opentelemetry/sdk-trace-node":"2.9.0"}},LIe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,IIe))return;let e=Fxt.version.slice(1),r=TY({"service.name":t.serviceName,"service.version":t.serviceVersion,"process.runtime.name":"nodejs","process.runtime.version":e,"deployment.environment":t.deploymentEnvironment,"http.url":t.siteUrl,"netlify.site.id":t.siteId,"netlify.site.name":t.siteName}),n=t.spanProcessors??[Vxt()],i=new mk.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new ku});let s=t.instrumentations??[];RY({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,IIe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new Fc(Ot.getTracer(a,c)):new Fc(Ot.getTracer(OIe.name,OIe.version))}}),Object.defineProperty(globalThis,jxt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},Vxt=()=>new mk.SimpleSpanProcessor(new qxt);Ne();var $b=pn(pK(),1);Ne();import*as gk from"diagnostics_channel";var DIe=class{constructor(t={}){this.instrumentationName="@netlify/otel/instrumentation-fetch",this.instrumentationVersion="1.0.0",this._recordFromReq=new WeakMap,this.config=t,this._channelSubs=[]}getConfig(){return this.config}setConfig(){}setMeterProvider(){}setTracerProvider(t){this.provider=t}getTracerProvider(){return this.provider}annotateFromRequest(t,e){let r=this.config.getRequestAttributes?.(e)??{},n=new URL(e.path,e.origin);t.setAttributes({...r,"http.request.method":e.method,"url.full":n.href,"url.host":n.host,"url.scheme":n.protocol.slice(0,-1),"server.address":n.hostname,"server.port":n.port,...this.prepareHeaders("request",e.headers)})}annotateFromResponse(t,e){let r=this.config.getResponseAttributes?.(e)??{};t.setAttributes({...r,"http.response.status_code":e.statusCode,...this.prepareHeaders("response",e.headers)}),t.setStatus({code:e.statusCode>=400?Gn.ERROR:Gn.UNSET})}prepareHeaders(t,e){if(!Array.isArray(e))return{};if(this.config.skipHeaders===!0)return{};let r=["*","/.*/"],n=this.config.skipHeaders??[],i=this.config.redactHeaders??[],s=n.some(a=>r.includes(a.toString())),o={};if(s)return o;for(let a=0;a+1<e.length;a=a+2){let c=e[a],l=e[a+1];if(typeof c!="string"&&!Buffer.isBuffer(c)||typeof l!="string"&&!Buffer.isBuffer(l))continue;let u=c.toString().toLowerCase();if(n.some(f=>typeof f=="string"?f==u:f.test(u)))continue;let d=`http.${t}.header.${u}`;i===!0||i.some(f=>typeof f=="string"?f==u:f.test(u))?o[d]="REDACTED":o[d]=l.toString()}return o}getRequestMethod(t){return["HEAD","GET","POST","PUT","PATCH","DELETE"].includes(t.toUpperCase())?t.toUpperCase():"_OTHER"}getTracer(){if(!this.provider)return;let t=this.provider.getTracer(this.instrumentationName,this.instrumentationVersion);return t instanceof Fc?t:new Fc(t)}enable(){this._channelSubs.length>0||(this.subscribe("undici:request:create",this.onRequestCreate.bind(this)),this.subscribe("undici:request:headers",this.onRequestHeaders.bind(this)),this.subscribe("undici:request:trailers",this.onRequestEnd.bind(this)),this.subscribe("undici:request:error",this.onRequestError.bind(this)))}subscribe(t,e){gk.subscribe(t,e);let r=()=>gk.unsubscribe(t,e);this._channelSubs.push({name:t,unsubscribe:r})}disable(){this._channelSubs.forEach(t=>{t.unsubscribe()}),this._channelSubs.length=0}onRequestCreate({request:t}){try{let e=this.getTracer(),r=new URL(t.path,t.origin);if(!e||t.method==="CONNECT"||this.config.skipURLs?.some(i=>typeof i=="string"?r.href.startsWith(i):i.test(r.href)))return;let n=e.startSpan(this.getRequestMethod(t.method),{kind:po.CLIENT},Gt.active());this.annotateFromRequest(n,t),this._recordFromReq.set(t,n)}catch{}}onRequestHeaders({request:t,response:e}){try{let r=this._recordFromReq.get(t);if(!r)return;this.annotateFromResponse(r,e)}catch{}}onRequestError({request:t,error:e}){try{let r=this._recordFromReq.get(t);if(!r)return;r.recordException(e),r.setStatus({code:Gn.ERROR,message:e.message}),r.end(),this._recordFromReq.delete(t)}catch{}}onRequestEnd({request:t}){try{let e=this._recordFromReq.get(t);if(!e)return;e.end(),this._recordFromReq.delete(t)}catch{}}};var o1e=pn(i1e(),1);var gD=fe("tracing"),s1e=8e3,sFt=5e3,Xw=async(t=sFt)=>{try{await Promise.race([LAe(),iFt(t)])}catch(e){gD.warn("Failed to flush tracers on shutdown",e)}},a1e=async(t,e,r)=>{if(!Tt()){let n=[new $b.SimpleSpanProcessor(new yJ),new $b.SimpleSpanProcessor(new o1e.OTLPTraceExporter({url:r.exporterUrl}))];await LIe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new DIe({skipHeaders:!0})]})}return r.traceparent?(ui.setGlobalPropagator(new ku),ui.extract(Gt.active(),{traceparent:r.traceparent,isRemote:!0})):Gt.active()};function Kt(t,e,r){return gD.log(`\u23F3 TRACE: ${e} starting...`),rb(t,e,r)}var yJ=class{export(e,r){for(let n of e)this.logSpan(n);r({code:1})}async shutdown(){}forceFlush(){return Promise.resolve()}logSpan(e){let r=(e.endTime[0]-e.startTime[0])*1e3+(e.endTime[1]-e.startTime[1])/1e6,n=e.attributes,i=[];for(let[a,c]of Object.entries(n))a.includes("duration")&&typeof c=="number"?i.push(`${a}=${c.toFixed(2)}ms`):i.push(`${a}=${c}`);let s=e.status?.code===2?"\u274C":"\u2705",o=i.length>0?` [${i.join(", ")}]`:"";gD.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&gD.log(` \u274C Error: ${e.status.message}`)}};function SJ(){return Ve().captureLlmContentEnabled}function c1e(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function _D(t,e,r){let n={role:t,parts:[{type:"text",content:Pi(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var oFt=new Set([te.Task,te.RunCommand,te.Explore,te.FileRead,te.FileWrite,te.Notebook,te.Web,te.Todo,te.Skill,te.Tool,te.Memorize,te.Deployment,te.SiteGeneration]);function l1e(t,e,r,n){if(!t.length)return;let i=Tt();if(!i)return;let s=SJ(),o=Math.max(1,(n-r)/t.length);t.forEach((a,c)=>{let l=Math.min(n,r+c*o),u=Math.min(n,l+o),d=a.type==="tool_use"||a.type==="tool_result"||a.category!=null&&oFt.has(a.category),f=d?"execute_tool":"chat",p=a.title||a.type||`step-${a.id??c}`,h=a.category||"unknown",m=d?`${f} ${h}`:f,_=a.message?a.message.length>s1e?`${a.message.slice(0,s1e)}\u2026`:a.message:void 0;i.startSpan(m,{startTime:l,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":p,"gen_ai.operation.name":f,...d?{"gen_ai.tool.name":h}:{},"spark.step.id":a.id??-1,...a.type?{"spark.step.type":a.type}:{},...a.category?{"spark.step.category":a.category}:{},...a.groupId?{"spark.step.group_id":a.groupId}:{},...a.parentGroupId?{"spark.step.parent_group_id":a.parentGroupId}:{},...s&&_?d?{"gen_ai.tool.call.result":Pi(_)}:{"gen_ai.output.messages":_D("assistant",_)}:{}}}).end(u)})}import{readdir as aFt,rm as cFt}from"fs/promises";import{join as lFt}from"path";async function u1e(t,e=[]){let n=(await aFt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>cFt(lFt(t,i),{recursive:!0,force:!0})))}var uFt=300,Qw=t=>Ve().budgetCreditThresholds[t.mode]?.[t.runner]??uFt,eR=({mode:t,sessionCreditLimit:e},r)=>t==="create"&&e!=null&&e<=r;var EJ=t=>{let e=Qw(t);if(!eR(t,e))return"default";let r=Ve();return r.createAskFirstEnabled&&r.questionsEnabled?"ask_first":r.creditWrapUpEnabled?"budget_constrained":"default"},d1e=t=>{let e=EJ(t),r=Qw(t);return{budget_eligible:eR(t,r),budget_constrained:e==="budget_constrained",ask_first:e==="ask_first"}};var hFt=tR.dirname(dFt(import.meta.url)),f1e=fFt(import.meta.url),mFt=tR.resolve(hFt,"scripts/scaffold.js"),gFt="scripts/scaffold.js",_Ft=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,vJ=t=>{if(t.length>=2){let e=t[0],r=t[t.length-1];if(e==='"'&&r==='"'||e==="'"&&r==="'")return t.slice(1,-1)}return t},yFt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),SFt=t=>{let e=vJ(t);return e==="node"||e.endsWith("/node")},ll=t=>{if(typeof t!="string")return!1;let e=t.match(_Ft)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&yFt(vJ(e[r]));)r+=1;if(r>=e.length||!SFt(e[r]))return!1;let n=e[r+1];return n?vJ(n).includes(gFt):!1},Mp=fe("create_stage"),TJ="Do not run local validation or dev-server commands to check your work \u2014 specifically `tsc`, `npx tsc`, `vite build`, `vite dev`, or any equivalent build/start/test command. The build pipeline installs and validates the project automatically after your edits. Verify your changes by reading the files you edited.",EFt=`${TJ}
|
|
597
|
+
if (condition) { yield value; }`)};import{Buffer as qbt}from"buffer";import{StringDecoder as Bbt}from"string_decoder";var kP=(t,e,r)=>{if(r)return;if(t)return{transform:Vbt.bind(void 0,new TextEncoder)};let n=new Bbt(e);return{transform:Hbt.bind(void 0,n),final:Gbt.bind(void 0,n)}},Vbt=function*(t,e){qbt.isBuffer(e)?yield Nc(e):typeof e=="string"?yield t.encode(e):yield e},Hbt=function*(t,e){yield Br(e)?t.write(e):e},Gbt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Wwe}from"util";var rW=Wwe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),$P=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Ybt}=e[r];for await(let i of n(t))yield*$P(i,e,r+1)},Ywe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Wbt(r,Number(e),t)},Wbt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*$P(n,r,e+1)},Kwe=Wwe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),Ybt=function*(t){yield t};var nW=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Zwe=(t,e)=>[...e.flatMap(r=>[...Kf(r,t,0)]),...YT(t)],Kf=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Zbt}=e[r];for(let i of n(t))yield*Kf(i,e,r+1)},YT=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Kbt(r,Number(e),t)},Kbt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Kf(n,r,e+1)},Zbt=function*(t){yield t};var iW=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=Xwe(t,o,s),l=Yf(e),u=Yf(r),d=l?rW.bind(void 0,$P,a):nW.bind(void 0,Kf),f=l||u?rW.bind(void 0,Ywe,a):nW.bind(void 0,YT),p=l||u?Kwe.bind(void 0,a):void 0;return{stream:new Jbt({writableObjectMode:n,writableHighWaterMark:Jwe(n),readableObjectMode:i,readableHighWaterMark:Jwe(i),transform(m,_,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:p})}},LP=(t,e,r,n)=>{let i=e.filter(({type:o})=>o==="generator"),s=n?i.reverse():i;for(let{value:o,optionName:a}of s){let c=Xwe(o,r,a);t=Zwe(c,t)}return t},Xwe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:Vwe(n,a)},kP(r,o,n),NP(r,s,n,c),{transform:t,final:e},{transform:Hwe(i,a)},Bwe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var Qwe=(t,e)=>{for(let r of Xbt(t))Qbt(t,r,e)},Xbt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Qbt=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Iu[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>ewt(a,n));r.input=UT(o)},ewt=(t,e)=>{let r=LP(t,e,"utf8",!0);return twt(r),UT(r)},twt=t=>{let e=t.find(r=>typeof r!="string"&&!Br(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 swt,appendFileSync as owt}from"fs";var DP=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Cg(r,n)&&!Yi.has(e)&&rwt(n)&&(t.some(({type:i,value:s})=>i==="native"&&nwt.has(s))||t.every(({type:i})=>Is.has(i))),rwt=t=>t===1||t===2,nwt=new Set(["pipe","overlapped"]),eRe=async(t,e,r,n)=>{for await(let i of t)iwt(e)||rRe(i,r,n)},tRe=(t,e,r)=>{for(let n of t)rRe(n,e,r)},iwt=t=>t._readableState.pipes.length>0,rRe=(t,e,r)=>{let n=ZO(t);da({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var nRe=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let s={},o=new Set([]);return{output:e.map((c,l)=>awt({result:c,fileDescriptors:t,fdNumber:l,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},awt=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=iwe(t,s,d),p=Nc(f),{stdioItems:h,objectMode:m}=e[r],_=cwt([p],h,c,n),{serializedResult:S,finalResult:E=S}=lwt({chunks:_,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});uwt({serializedResult:S,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let y=a[r]?E:void 0;try{return n.error===void 0&&dwt(S,h,i),y}catch(g){return n.error=g,y}},cwt=(t,e,r,n)=>{try{return LP(t,e,r,!1)}catch(i){return n.error=i,t}},lwt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:UT(t)};let o=yve(t,r);return n[s]?{serializedResult:o,finalResult:tW(o,!i[s],e)}:{serializedResult:o}},uwt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!DP({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=tW(t,!1,o);try{tRe(a,e,n)}catch(c){r.error??=c}},dwt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>OP.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?owt(n,t):(r.add(s),swt(n,t))}};var iRe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Lc(e,r,"all")]:Array.isArray(e)?[Lc(t,r,"all"),...e]:Br(t)&&Br(e)?u3([t,e]):`${t}${e}`};import{once as sW}from"events";var sRe=async(t,e)=>{let[r,n]=await fwt(t);return e.isForcefullyTerminated??=!1,[r,n]},fwt=async t=>{let[e,r]=await Promise.allSettled([sW(t,"spawn"),sW(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?oRe(t):r.value},oRe=async t=>{try{return await sW(t,"exit")}catch{return oRe(t)}},aRe=async t=>{let[e,r]=await t;if(!pwt(e,r)&&oW(e,r))throw new co;return[e,r]},pwt=(t,e)=>t===void 0&&e===void 0,oW=(t,e)=>t!==0||e!==null;var cRe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=hwt(t,e,r),o=s?.code==="ETIMEDOUT",a=nwe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},hwt=(t,e,r)=>t!==void 0?t:oW(e,r)?new co:void 0;var lRe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=gwt(t,e,r),d=Swt({file:n,commandArguments:i,options:l,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:a});return Ug(d,c,l)},gwt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=XO(t,e,r),a=_wt(r),{file:c,commandArguments:l,options:u}=yP(t,e,a);ywt(u);let d=Fwe(u,o);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},_wt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,ywt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&MP("ipcInput"),t&&MP("ipc: true"),r&&MP("detached: true"),n&&MP("cancelSignal")},MP=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Swt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=Ewt({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=cRe(c,r),{output:h,error:m=l}=nRe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),_=h.map((E,y)=>Lc(E,r,y)),S=Lc(iRe(h,r),r,"all");return Twt({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:S,options:r,command:n,escapedCommand:i,startTime:a})},Ewt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{Qwe(s,r);let a=vwt(r);return mwt(...SP(t,e,a))}catch(a){return Mg({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},vwt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:AP(e)}),Twt=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:s,all:o,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?xP({command:c,escapedCommand:l,stdio:s,all:o,ipcOutput:[],options:a,startTime:u}):WT({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as lAt}from"events";import{spawn as uAt}from"child_process";import hRe from"process";import{once as aW,on as bwt}from"events";var uRe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(Pg({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:fP(t)}),wwt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),wwt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{cP(e,i);let s=Cu(t,e,r),o=new AbortController;try{return await Promise.race([Rwt(s,n,o),Awt(s,r,o),xwt(s,r,o)])}catch(a){throw Ng(t),a}finally{o.abort(),lP(e,i)}},Rwt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await aW(t,"message",{signal:r});return n}for await(let[n]of bwt(t,"message",{signal:r}))if(e(n))return n},Awt=async(t,e,{signal:r})=>{await aW(t,"disconnect",{signal:r}),ZTe(e)},xwt=async(t,e,{signal:r})=>{let[n]=await aW(t,"strict:error",{signal:r});throw sP(n,e)};import{once as fRe,on as Cwt}from"events";var pRe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>cW({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),cW=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{Pg({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:fP(t)}),cP(e,s);let o=Cu(t,e,r),a=new AbortController,c={};return Iwt(t,o,a),Owt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),Pwt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},Iwt=async(t,e,r)=>{try{await fRe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Owt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await fRe(t,"strict:error",{signal:r.signal});n.error=sP(i,e),r.abort()}catch{}},Pwt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of Cwt(r,"message",{signal:s.signal}))dRe(o),yield c}catch{dRe(o)}finally{s.abort(),lP(e,a),n||Ng(t),i&&await t}},dRe=({error:t})=>{if(t)throw t};var mRe=(t,{ipc:e})=>{Object.assign(t,_Re(t,!1,e))},gRe=()=>{let t=hRe,e=!0,r=hRe.channel!==void 0;return{..._Re(t,e,r),getCancelSignal:bbe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},_Re=(t,e,r)=>({sendMessage:gP.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:uRe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:pRe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Nwt}from"child_process";import{PassThrough as kwt,Readable as $wt,Writable as Lwt,Duplex as Dwt}from"stream";var yRe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{X3(n);let a=new Nwt;Mwt(a,n),Object.assign(a,{readable:Uwt,writable:Fwt,duplex:jwt});let c=Mg({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),l=zwt(c,o,i);return{subprocess:a,promise:l}},Mwt=(t,e)=>{let r=KT(),n=KT(),i=KT(),s=Array.from({length:e.length-3},KT),o=KT(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},KT=()=>{let t=new kwt;return t.end(),t},Uwt=()=>new $wt({read(){}}),Fwt=()=>new Lwt({write(){}}),jwt=()=>new Dwt({read(){},write(){}}),zwt=async(t,e,r)=>Ug(t,e,r);import{createReadStream as SRe,createWriteStream as ERe}from"fs";import{Buffer as qwt}from"buffer";import{Readable as ZT,Writable as Bwt,Duplex as Vwt}from"stream";var TRe=(t,e)=>PP(Hwt,t,e,!1),JT=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Iu[t]}.`)},vRe={fileNumber:JT,generator:iW,asyncGenerator:iW,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Vwt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Hwt={input:{...vRe,fileUrl:({value:t})=>({stream:SRe(t)}),filePath:({value:{file:t}})=>({stream:SRe(t)}),webStream:({value:t})=>({stream:ZT.fromWeb(t)}),iterable:({value:t})=>({stream:ZT.from(t)}),asyncIterable:({value:t})=>({stream:ZT.from(t)}),string:({value:t})=>({stream:ZT.from(t)}),uint8Array:({value:t})=>({stream:ZT.from(qwt.from(t))})},output:{...vRe,fileUrl:({value:t})=>({stream:ERe(t)}),filePath:({value:{file:t,append:e}})=>({stream:ERe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Bwt.fromWeb(t)}),iterable:JT,asyncIterable:JT,string:JT,uint8Array:JT}};import{on as Gwt,once as bRe}from"events";import{PassThrough as Wwt,getDefaultHighWaterMark as Ywt}from"stream";import{finished as ARe}from"stream/promises";function Zf(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)uW(i);let e=t.some(({readableObjectMode:i})=>i),r=Kwt(t,e),n=new lW({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Kwt=(t,e)=>{if(t.length===0)return Ywt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},lW=class extends Wwt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(uW(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Zwt(this,this.#e,this.#s);let r=Qwt({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#s});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(uW(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},Zwt=async(t,e,r)=>{UP(t,wRe);let n=new AbortController;try{await Promise.race([Jwt(t,n),Xwt(t,e,r,n)])}finally{n.abort(),UP(t,-wRe)}},Jwt=async(t,{signal:e})=>{try{await ARe(t,{signal:e,cleanup:!0})}catch(r){throw xRe(t,r),r}},Xwt=async(t,e,r,{signal:n})=>{for await(let[i]of Gwt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},uW=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Qwt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{UP(t,RRe);let a=new AbortController;try{await Promise.race([eRt(s,e,a),tRt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),rRt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),UP(t,-RRe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?dW(t):nRt(t))},eRt=async(t,e,{signal:r})=>{try{await t,r.aborted||dW(e)}catch(n){r.aborted||xRe(e,n)}},tRt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await ARe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;CRe(o)?i.add(e):IRe(t,o)}},rRt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await bRe(t,i,{signal:s}),!t.readable)return bRe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},nRt=t=>{t.writable&&t.end()},xRe=(t,e)=>{CRe(e)?dW(t):IRe(t,e)},CRe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",dW=t=>{(t.readable||t.writable)&&t.destroy()},IRe=(t,e)=>{t.destroyed||(t.once("error",iRt),t.destroy(e))},iRt=()=>{},UP=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},wRe=2,RRe=1;import{finished as ORe}from"stream/promises";var jg=(t,e)=>{t.pipe(e),sRt(t,e),oRt(t,e)},sRt=async(t,e)=>{if(!(ao(t)||ao(e))){try{await ORe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}fW(e)}},fW=t=>{t.writable&&t.end()},oRt=async(t,e)=>{if(!(ao(t)||ao(e))){try{await ORe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}pW(t)}},pW=t=>{t.readable&&t.destroy()};var PRe=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:s,direction:o}]of Object.entries(e)){for(let{stream:a}of s.filter(({type:c})=>Is.has(c)))aRt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Is.has(c)))lRt({subprocess:t,stream:a,direction:o,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,s]of n.entries()){let o=s.length===1?s[0]:Zf(s);jg(o,i)}},aRt=(t,e,r,n)=>{r==="output"?jg(t.stdio[n],e):jg(e,t.stdio[n]);let i=cRt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},cRt=["stdin","stdout","stderr"],lRt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;uRt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},uRt=(t,{signal:e})=>{ao(t)&&Gf(t,dRt,e)},dRt=2;import{addAbortListener as hRt}from"events";var Jf=[];Jf.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Jf.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Jf.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var FP=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",hW=Symbol.for("signal-exit emitter"),mW=globalThis,fRt=Object.defineProperty.bind(Object),gW=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(mW[hW])return mW[hW];fRt(mW,hW,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let s of this.listeners[e])i=s(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},jP=class{},pRt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),_W=class extends jP{onExit(){return()=>{}}load(){}unload(){}},yW=class extends jP{#e=SW.platform==="win32"?"SIGINT":"SIGHUP";#r=new gW;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Jf)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,s=e;if(typeof s.__signal_exit_emitter__=="object"&&typeof s.__signal_exit_emitter__.count=="number"&&(i+=s.__signal_exit_emitter__.count),n.length===i){this.unload();let o=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;o||e.kill(e.pid,a)}};this.#s=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!FP(this.#t))return()=>{};this.#o===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#r.on(n,e),()=>{this.#r.removeListener(n,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#o){this.#o=!0,this.#r.count+=1;for(let e of Jf)try{let r=this.#i[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#o&&(this.#o=!1,Jf.forEach(e=>{let r=this.#i[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#s,this.#r.count-=1)}#a(e){return FP(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#s.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&FP(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let i=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),i}else return n.call(this.#t,e,...r)}},SW=globalThis.process,{onExit:NRe,load:Lmr,unload:Dmr}=pRt(FP(SW)?new yW(SW):new _W);var kRe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=NRe(()=>{t.kill()});hRt(n,()=>{i()})};var LRe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=JO(),{destination:o,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=mRt(r,n,i),{sourceStream:d,sourceError:f}=_Rt(t,l),{options:p,fileDescriptors:h}=pa.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:s}},mRt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=gRt(t,e,...r),a=aP(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},gRt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e($Re,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||c3(r)){if(Object.keys(t).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[i,s,o]=zO(r,...n);return{destination:e($Re)(i,s,o),pipeOptions:o}}if(pa.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}`)},$Re=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),_Rt=(t,e)=>{try{return{sourceStream:kg(t,e)}}catch(r){return{sourceError:r}}};var MRe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=yRt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw EW({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},yRt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return pW(t),n;if(e!==void 0)return fW(r),e},EW=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Mg({error:t,command:DRe,escapedCommand:DRe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),DRe="source.pipe(destination)";var URe=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:s,value:o=s}]=await t;if(o.pipedFrom.includes(n)||o.pipedFrom.push(n),i==="rejected")throw o;if(e==="rejected")throw n;return o};import{finished as SRt}from"stream/promises";var FRe=(t,e,r)=>{let n=zP.has(e)?vRt(t,e):ERt(t,e);return Gf(t,bRt,r.signal),Gf(e,wRt,r.signal),TRt(e),n},ERt=(t,e)=>{let r=Zf([t]);return jg(r,e),zP.set(e,r),r},vRt=(t,e)=>{let r=zP.get(e);return r.add(t),r},TRt=async t=>{try{await SRt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}zP.delete(t)},zP=new WeakMap,bRt=2,wRt=1;import{aborted as RRt}from"util";var jRe=(t,e)=>t===void 0?[]:[ARt(t,e)],ARt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await RRt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw EW({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var qP=(t,...e)=>{if(Cr(e[0]))return qP.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=LRe(t,...e),i=xRt({...n,destination:r});return i.pipe=qP.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},xRt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=CRt(t,i);MRe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=FRe(e,s,d);return await Promise.race([URe(u),...jRe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},CRt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as LRt}from"timers/promises";import{on as IRt}from"events";import{getDefaultHighWaterMark as ORt}from"stream";var BP=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return PRt(e,o),qRe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},PRt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},vW=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;NRt(e,o,t);let a=t.readableObjectMode&&!s;return qRe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},NRt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},qRe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=IRt(t,"data",{signal:e.signal,highWaterMark:zRe,highWatermark:zRe});return kRt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},TW=ORt(!0),zRe=TW,kRt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=$Rt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Kf(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*YT(a)}},$Rt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[kP(t,r,!e),NP(t,i,!n,{})].filter(Boolean);var BRe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=DRt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([MRt(t),d]);return}let f=Q3(c,r),p=vW({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([URt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},DRt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!DP({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=vW({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await eRe(a,t,r,s)},MRt=async t=>{await LRt(),t.readableFlowing===null&&t.resume()},URt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await bP(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await wP(r,{maxBuffer:s})):await Dg(r,{maxBuffer:s})}catch(a){return VRe(ewe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},bW=async t=>{try{return await t}catch(e){return VRe(e)}},VRe=({bufferedData:t})=>gve(t)?new Uint8Array(t):t;import{finished as FRt}from"stream/promises";var XT=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=jRt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],FRt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||BRt(a,e,r,n)}finally{o.abort()}},jRt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&zRt(t,r,n),n},zRt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{qRt(e,r),n.call(t,...i)}},qRt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},BRt=(t,e,r,n)=>{if(!VRt(t,e,r,n))throw t},VRt=(t,e,r,n=!0)=>r.propagating?HRe(t)||VP(t):(r.propagating=!0,wW(r,e)===n?HRe(t):VP(t)),wW=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",VP=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",HRe=t=>t?.code==="EPIPE";var GRe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,l)=>RW({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),RW=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=XT(t,e,l);if(wW(l,e)){await u;return}let[d]=await Promise.all([BRe({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var WRe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Zf([t,e].filter(Boolean)):void 0,YRe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>RW({...HRt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:GRt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),HRt=({stdout:t,stderr:e,all:r},[,n,i])=>{let s=n||i;return s?n?i?{stream:r,buffer:s}:{stream:t,buffer:s}:{stream:e,buffer:s}:{stream:r,buffer:s}},GRt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as WRt}from"events";var KRe=t=>Cg(t,"ipc"),ZRe=(t,e)=>{let r=ZO(t);da({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var JRe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=KRe(s),a=kc(e,"ipc"),c=kc(r,"ipc");for await(let l of cW({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(twe(t,i,c),i.push(l)),o&&ZRe(l,s);return i},XRe=async(t,e)=>(await Promise.allSettled([t]),e);var QRe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:_,controller:S})=>{let E=sRe(t,f),y={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:E,propagating:!1},g=GRe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:y}),T=YRe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:y}),w=[],A=JRe({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:w,verboseInfo:p}),b=YRt(m,t,y),C=KRt(h,y);try{return await Promise.race([Promise.all([{},aRe(E),Promise.all(g),T,A,kbe(t,d),...b,...C]),_,ZRt(t,S),...Cbe(t,s,f,S),...KTe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:S}),...Abe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(P){return f.terminationReason??="other",Promise.all([{error:P},E,Promise.all(g.map(x=>bW(x))),bW(T),XRe(A,w),Promise.allSettled(b),Promise.allSettled(C)])}},YRt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:XT(n,i,r)),KRt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>uo(s,{checkOpen:!1})&&!ao(s)).map(({type:i,value:s,stream:o=s})=>XT(o,n,e,{isSameDirection:Is.has(i),stopOnExit:i==="native"}))),ZRt=async(t,{signal:e})=>{let[r]=await WRt(t,"error",{signal:e});throw r};var eAe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),QT=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=fa();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},zg=async({resolve:t,promises:e},r)=>{t();let[n]=await Promise.race([Promise.allSettled([!0,r]),Promise.all([!1,...e])]);return!n};import{Readable as JRt}from"stream";import{callbackify as XRt}from"util";import{finished as tAe}from"stream/promises";var AW=async t=>{if(t!==void 0)try{await xW(t)}catch{}},rAe=async t=>{if(t!==void 0)try{await CW(t)}catch{}},xW=async t=>{await tAe(t,{cleanup:!0,readable:!1,writable:!0})},CW=async t=>{await tAe(t,{cleanup:!0,readable:!0,writable:!1})},HP=async(t,e)=>{if(await t,e)throw e},GP=(t,e,r)=>{r&&!VP(r)?t.destroy(r):e&&t.destroy()};var nAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||Yi.has(r),{subprocessStdout:a,waitReadableDestroy:c}=IW(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=OW(a,o),{read:f,onStdoutDataDone:p}=PW({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new JRt({read:f,destroy:XRt(kW.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return NW({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},IW=(t,e,r)=>{let n=kg(t,e),i=QT(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},OW=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:TW},PW=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=fa(),o=BP({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){QRt(this,o,s)},onStdoutDataDone:s}},QRt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},NW=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await CW(t),await n,await AW(i),await e,r.readable&&r.push(null)}catch(s){await AW(i),iAe(r,s)}},kW=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await zg(r,e)&&(iAe(t,n),await HP(e,n))},iAe=(t,e)=>{GP(t,t.readable,e)};import{Writable as eAt}from"stream";import{callbackify as sAe}from"util";var oAe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=$W(t,r,e),o=new eAt({...LW(n,t,i),destroy:sAe(MW.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return DW(n,o),o},$W=(t,e,r)=>{let n=aP(t,e),i=QT(r,n,"writableFinal"),s=QT(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},LW=(t,e,r)=>({write:tAt.bind(void 0,t),final:sAe(rAt.bind(void 0,t,e,r))}),tAt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},rAt=async(t,e,r)=>{await zg(r,e)&&(t.writable&&t.end(),await e)},DW=async(t,e,r)=>{try{await xW(t),e.writable&&e.end()}catch(n){await rAe(r),aAe(e,n)}},MW=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await zg(r,e),await zg(n,e)&&(aAe(t,i),await HP(e,i))},aAe=(t,e)=>{GP(t,t.writable,e)};import{Duplex as nAt}from"stream";import{callbackify as iAt}from"util";var cAe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||Yi.has(r),{subprocessStdout:c,waitReadableDestroy:l}=IW(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=$W(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=OW(c,a),{read:_,onStdoutDataDone:S}=PW({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),E=new nAt({read:_,...LW(u,t,d),destroy:iAt(sAt.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return NW({subprocessStdout:c,onStdoutDataDone:S,readable:E,subprocess:t,subprocessStdin:u}),DW(u,E,c),E},sAt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([kW({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),MW({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var UW=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||Yi.has(e),o=kg(t,r),a=BP({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return oAt(a,o,t)},oAt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var lAe=(t,{encoding:e})=>{let r=eAe();t.readable=nAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=oAe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=cAe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=UW.bind(void 0,t,e),t[Symbol.asyncIterator]=UW.bind(void 0,t,e,{})};var uAe=(t,e)=>{for(let[r,n]of cAt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},aAt=(async()=>{})().constructor.prototype,cAt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(aAt,t)]);var dAe=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=dAt(t,e,r),{subprocess:f,promise:p}=pAt({file:i,commandArguments:s,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=qP.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),uAe(f,p),pa.set(f,{options:u,fileDescriptors:d}),f},dAt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=XO(t,e,r),{file:a,commandArguments:c,options:l}=yP(t,e,r),u=fAt(l),d=TRe(u,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:u,fileDescriptors:d}},fAt=({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}},pAt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=uAt(...SP(t,e,r))}catch(h){return yRe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;lAt(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];PRe(c,a,l),kRe(c,r,l);let d={},f=fa();c.kill=WTe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=WRe(c,r),lAe(c,r),mRe(c,r);let p=hAt({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:s,escapedCommand:o,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},hAt=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:s,command:o,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,_]=await QRe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:l,controller:u});u.abort(),l.resolve();let S=h.map((g,T)=>Lc(g,e,T)),E=Lc(m,e,"all"),y=mAt({errorInfo:d,exitCode:f,signal:p,stdio:S,all:E,ipcOutput:_,context:c,options:e,command:o,escapedCommand:a,startTime:r});return Ug(y,n,e)},mAt=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,context:o,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?WT({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 ha,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:u,isSync:!1}):xP({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:s,options:a,startTime:u});var WP=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,gAt(n,t[n],i)]));return{...t,...r}},gAt=(t,e,r)=>_At.has(t)&&Cr(e)&&Cr(r)?{...e,...r}:r,_At=new Set(["env",...h3]);var Ou=(t,e,r,n)=>{let i=(o,a,c)=>Ou(o,a,r,c),s=(...o)=>yAt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},yAt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Cr(s))return i(t,WP(r,s),n);let{file:a,commandArguments:c,options:l,isSync:u}=SAt({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return u?lRe(a,c,l):dAe(a,c,l,i)},SAt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=Tve(e)?bve(e,r):[e,...r],[o,a,c]=zO(...s),l=WP(WP(n,i),c),{file:u=o,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:o,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var fAe=({file:t,commandArguments:e})=>hAe(t,e),pAe=({file:t,commandArguments:e})=>({...hAe(t,e),isSync:!0}),hAe=(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]=EAt(t);return{file:r,commandArguments:n}},EAt=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(vAt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},vAt=/ +/g;var mAe=(t,e,r)=>{t.sync=e(TAt,r),t.s=t.sync},gAe=({options:t})=>_Ae(t),TAt=({options:t})=>({..._Ae(t),isSync:!0}),_Ae=t=>({options:{...bAt(t),...t}}),bAt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},yAe={preferLocal:!0};var SAe=Ou(()=>({})),Ryr=Ou(()=>({isSync:!0})),EAe=Ou(fAe),Ayr=Ou(pAe),xyr=Ou(Obe),Cyr=Ou(gAe,{},yAe,mAe),{sendMessage:Iyr,getOneMessage:Oyr,getEachMessage:Pyr,getCancelSignal:Nyr}=gRe();import{Transform as wAt}from"stream";var RAt=["NETLIFY_AI_GATEWAY_KEY"];function AAt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...RAt])]}function xAt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function CAt(){let e=AAt().map(r=>process.env[r]).filter(r=>!(!r||xAt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Pi(t){if(typeof t!="string")return t;let e=CAt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(IAt(n),"g");r=r.replace(i,"******")}),r}function IAt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var eb=class extends wAt{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Pi(i);n(null,s)}},YP=Symbol("maskedWrite");function vAe(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[YP]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Pi(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[YP]=!0,process.stdout.write=r}if(!process.stderr.write[YP]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Pi(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[YP]=!0,process.stderr.write=r}}}var TAe=!1,bAe,FW=t=>{bAe??=t},wAe=t=>{TAe=!0,FW(t)},Cn=()=>TAe,ga=()=>bAe,RAe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var tb=null,AAe=t=>(tb&&tb.destroy(),tb=new fo({totalAllowedTime:t}),tb),xAe=()=>tb;var fo=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&Cn())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let s=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),o=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await DO({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}),s(),o&&clearTimeout(o)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var CAe={name:"@netlify/agent-runner-cli",type:"module",version:"1.189.3",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",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:opencode":"vitest run test/integration/opencode.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.6","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.280","@anthropic-ai/sdk":"^0.128.0","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.1","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.153.4","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var kAt=PAt(import.meta.url),$At=Dc.dirname(kAt),LAt=NAt(import.meta.url),qg=fe("shell"),jW=new Set,IAe={preferLocal:!0},sr=(t,e,r)=>{let[n,i]=DAt(e,r),s={...IAe,...i},o=SAe(t,n,s);PAe(o,s),$Ae(o);let a=r?.idleTimeout;return a&&a>0&&kAe(o,a),o},OAe=(t,e)=>{let r={...IAe,...e},n=EAe(t,r);return PAe(n,r),$Ae(n),e?.idleTimeout&&e.idleTimeout>0&&kAe(n,e.idleTimeout),n},DAt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},PAe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||_a.env.NETLIFY_LOCAL_QUIET==="true")return;if(_a.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new eb).pipe(_a.stdout),t.stderr?.pipe(new eb).pipe(_a.stderr);return}t.stdout?.pipe(_a.stdout),t.stderr?.pipe(_a.stderr)},zW=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(_a.kill(-t.pid,e),qg.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return qg.error("Error killing process:",r),!1}},NAe=t=>zW(t,"SIGKILL"),kAe=(t,e)=>{let r=null,n=()=>{qg.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),zW(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(qg.log(`Force killing idle process ${t.pid}`),NAe(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let s=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",s),t.on("error",s)},$Ae=t=>{jW.add(t);let e=xAe();if(e){let r=e.onTimesUp(()=>{qg.log(`Global timer expired, killing process ${t.pid}`),zW(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(qg.log(`Force killing process ${t.pid} after timeout`),NAe(t))},5e3)});t.on("exit",()=>{jW.delete(t),r()}),t.on("error",()=>{jW.delete(t),r()})}};function ya(t,e){if(!_a.env.NETLIFY_LOCAL_MODE)try{let i=LAt.resolve(CAe.name),s=Dc.dirname(i);for(;s!==Dc.dirname(s);){let o=Dc.dirname(s);if(Dc.basename(o)==="node_modules"){let a=Dc.join(o,".bin",e);if(KP.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(_a.env.NODE_PATH){let i=Dc.join(_a.env.NODE_PATH,".bin",e);if(KP.existsSync(i))return i}let r=Dc.join(t,"node_modules",".bin",e);if(KP.existsSync(r))return r;let n=Dc.join($At,"..","node_modules",".bin",e);if(KP.existsSync(n))return n}import yD from"process";import{fileURLToPath as dFt}from"url";import{createRequire as fFt}from"module";import tR from"path";import{readFileSync as pFt}from"fs";var MAt="__netlify__getTracer",UAt="__netlify__shutdownTracers",Tt=(t,e)=>globalThis[MAt]?.(t,e),LAe=async()=>globalThis[UAt]?.();function rb(t,e,r,n,i){let s=typeof n=="function"?n:typeof r=="function"?r:i;if(!s)throw new Error("function to execute with active span is missing");return t?t.withActiveSpan(e,r,n,s):s()}import{setTimeout as iFt}from"timers/promises";Ne();import Fxt from"process";Ne();var c0t=(t,e)=>{e.recordException(t),e.setStatus({code:Gn.ERROR})};var Fc=class{constructor(e){this._tracer=e,this.startSpan=e.startSpan.bind(this._tracer),this.startActiveSpan=e.startActiveSpan.bind(this._tracer)}withActiveSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=C0e(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>I0e(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=C0e(r,n,i),c=this._tracer.startSpan(e,s,o);return I0e(c,s,a)}};function C0e(t,e,r){let n,i,s;return!e&&!r?s=t:r?(n=t,i=e,s=r):(n=t,s=e),n=n??{},i=i??Gt.active(),{opts:n,ctx:i,fn:s}}function I0e(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:c0t,s=o=>{throw i(o,t),t.end(),o};try{let o=r(t);return typeof o?.then=="function"?o.then(a=>(t.end(),a),s):(t.end(),o)}catch(o){throw s(o)}}Ne();var Kg=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var vY=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=F0e(e),n._asyncAttributesPending=e.filter(([i,s])=>Kg(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(Kg(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=F0e(this._rawAttributes),this._schemaUrl=l0t(r?.schemaUrl)}get asyncAttributesPending(){return this._asyncAttributesPending}async waitForAsyncAttributes(){if(this.asyncAttributesPending){for(let e=0;e<this._rawAttributes.length;e++){let[r,n]=this._rawAttributes[e];this._rawAttributes[e]=[r,Kg(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&ue.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(Kg(n)){ue.debug(`Unsettled resource attribute ${r} skipped`);continue}n!=null&&(e[r]??=n)}return this._asyncAttributesPending||(this._memoizedAttributes=e),e}getRawAttributes(){return this._rawAttributes}get schemaUrl(){return this._schemaUrl}merge(e){if(e==null)return this;let r=u0t(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function TY(t,e){return vY.FromAttributeList(Object.entries(t),e)}function F0e(t){return t.map(([e,r])=>Kg(r)?[e,r.catch(n=>{ue.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function l0t(t){if(typeof t=="string"||t===void 0)return t;ue.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function u0t(t,e){let r=t?.schemaUrl,n=e?.schemaUrl,i=r===void 0||r==="",s=n===void 0||n==="";if(i)return n;if(s||r===n)return r;ue.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}Ne();var hb=class{emit(e){}enabled(){return!1}},j0e=new hb;var mb=Symbol.for("io.opentelemetry.js.api.logs"),Zg=globalThis;function z0e(t,e,r){return n=>n===t?e:r}var bY=1;var wY=class{getLogger(e,r,n){return new hb}},yN=new wY;var SN=class{constructor(e,r,n,i){this._provider=e,this.name=r,this.version=n,this.options=i}emit(e){this._getLogger().emit(e)}enabled(e){return this._getLogger().enabled(e)}_getLogger(){if(this._delegate)return this._delegate;let e=this._provider._getDelegateLogger(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):j0e}};var gb=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new SN(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:yN}_setDelegate(e){this._delegate=e}_getDelegateLogger(e,r,n){var i;return(i=this._delegate)===null||i===void 0?void 0:i.getLogger(e,r,n)}};var EN=class t{constructor(){this._proxyLoggerProvider=new gb}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return Zg[mb]?this.getLoggerProvider():(Zg[mb]=z0e(bY,e,yN),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=Zg[mb])===null||e===void 0?void 0:e.call(Zg,bY))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete Zg[mb],this._proxyLoggerProvider=new gb}};var q0e=EN.getInstance();function B0e(t,e,r,n){for(let i=0,s=t.length;i<s;i++){let o=t[i];e&&o.setTracerProvider(e),r&&o.setMeterProvider(r),n&&o.setLoggerProvider&&o.setLoggerProvider(n),o.getConfig().enabled||o.enable()}}function V0e(t){t.forEach(e=>e.disable())}function RY(t){let e=t.tracerProvider||Ot.getTracerProvider(),r=t.meterProvider||pb.getMeterProvider(),n=t.loggerProvider||q0e.getLoggerProvider(),i=t.instrumentations?.flat()??[];return B0e(i,e,r,n),()=>{V0e(i)}}Ne();var d0t=Qr("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function H0e(t){return t.getValue(d0t)===!0}var Jg;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(Jg||(Jg={}));Ne();var AY="[_0-9a-z-*/]",f0t=`[a-z]${AY}{0,255}`,p0t=`[a-z0-9]${AY}{0,240}@[a-z]${AY}{0,13}`,h0t=new RegExp(`^(?:${f0t}|${p0t})$`),m0t=/^[ -~]{0,255}[!-~]$/,g0t=/,|=/;function xY(t){return h0t.test(t)}function CY(t){return m0t.test(t)&&!g0t.test(t)}var _0t=32,G0e=512,W0e=",",Y0e="=",vN=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!xY(e)||!CY(r))return this;let n=this._getState(),i=n.get(e),s=this._length;if(typeof i=="string"?s+=r.length-i.length:s+=e.length+r.length+(n.size>0?2:1),s>G0e)return this;let o=new Map(n);return o.delete(e),o.set(e,r),this._fromState(o,s)}unset(e){let r=this._getState(),n=r.get(e);if(typeof n!="string")return this;let i=this._length-(e.length+n.length+1);r.size>1&&(i=i-1);let s=new Map(r);return s.delete(e),this._fromState(s,i)}get(e){return this._getState().get(e)}serialize(){let e="",r=0;for(let n of this._getState())r>0&&(e=W0e+e),e=`${n[0]}${Y0e}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(W0e),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(Y0e);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!xY(a)||!CY(c))continue;let l=n+s.length+(r.size>0?1:0);if(!(l>G0e)&&(r.set(a,c),n=l,r.size>=_0t))break}return this._length=n,this._internalState=new Map(Array.from(r.entries()).reverse()),this._internalState}_fromState(e,r){let n=Object.create(t.prototype);return n._internalState=e,n._length=r,n}};var TN="traceparent",bN="tracestate",y0t="00",S0t="(?!ff)[\\da-f]{2}",E0t="(?![0]{32})[\\da-f]{32}",v0t="(?![0]{16})[\\da-f]{16}",T0t="[\\da-f]{2}",b0t=new RegExp(`^\\s?(${S0t})-(${E0t})-(${v0t})-(${T0t})(-.*)?\\s?$`);function K0e(t){let e=b0t.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var ku=class{inject(e,r,n){let i=Ot.getSpanContext(e);if(!i||H0e(e)||!Ni(i))return;let s=`${y0t}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||Er.NONE).toString(16)}`;n.set(r,TN,s),i.traceState&&n.set(r,bN,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,TN);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=K0e(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,bN);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new vN(typeof c=="string"?c:void 0)}return Ot.setSpanContext(e,o)}fields(){return[TN,bN]}};var wN=class{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,r)=>{this._resolve=e,this._reject=r})}get promise(){return this._promise}resolve(e){this._resolve(e)}reject(e){this._reject(e)}};var _b=class{_isCalled=!1;_deferred=new wN;_callback;_that;constructor(e,r){this._callback=e,this._that=r}get isCalled(){return this._isCalled}get promise(){return this._deferred.promise}call(...e){if(!this._isCalled){this._isCalled=!0;try{Promise.resolve(this._callback.call(this._that,...e)).then(r=>this._deferred.resolve(r),r=>this._deferred.reject(r))}catch(r){this._deferred.reject(r)}}return this._deferred.promise}};var mk=pn(pK(),1);Ne();var PIe=t=>{throw TypeError(t)},_K=(t,e,r)=>e.has(t)||PIe("Cannot "+r),hk=(t,e,r)=>(_K(t,e,"read from private field"),r?r.call(t):e.get(t)),hK=(t,e,r)=>e.has(t)?PIe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),CIe=(t,e,r,n)=>(_K(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),Uxt=(t,e,r)=>(_K(t,e,"access private method"),r),IIe="__netlify__getTracer",jxt="__netlify__shutdownTracers",zxt="__nfOTLPTrace",Nb,kb,gK,NIe,qxt=class{constructor(){hK(this,gK),hK(this,Nb),hK(this,kb),CIe(this,Nb,new _b(Uxt(this,gK,NIe),this)),CIe(this,kb,ue.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(hk(this,kb).debug(`export ${t.length.toString()} spans`),hk(this,Nb).isCalled){e({code:Jg.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(zxt,JSON.stringify(Bxt(t))),e({code:Jg.SUCCESS})}shutdown(){return hk(this,Nb).call()}};Nb=new WeakMap;kb=new WeakMap;gK=new WeakSet;NIe=function(){return hk(this,kb).debug("Shutting down"),Promise.resolve()};function Bxt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:pk(e.resource.attributes),droppedAttributesCount:e.droppedAttributesCount},scopeSpans:[{scope:{name:e.instrumentationScope.name,version:e.instrumentationScope.version},spans:[{traceId:r.traceId,spanId:r.spanId,parentSpanId:e.parentSpanContext?.spanId,name:e.name,kind:e.kind||po.SERVER,startTimeUnixNano:mK(e.startTime),endTimeUnixNano:mK(e.endTime),attributes:pk(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:mK(n.time),attributes:pk(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedEventsCount:e.droppedEventsCount,status:{code:e.status.code,message:e.status.message},links:e.links.map(n=>({spanId:n.context.spanId,traceId:n.context.traceId,attributes:pk(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function pk(t){return Object.keys(t).map(e=>kIe(e,t[e]))}function kIe(t,e){return{key:t,value:$Ie(e)}}function $Ie(t){let e=typeof t;return e==="string"?{stringValue:t}:e==="number"?Number.isInteger(t)?{intValue:t}:{doubleValue:t}:e==="boolean"?{boolValue:t}:t instanceof Uint8Array?{bytesValue:t}:Array.isArray(t)?{arrayValue:{values:t.map($Ie)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>kIe(r,n))}}:{}}function mK(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var OIe={name:"@netlify/otel",version:"6.0.6",type:"module",engines:{node:"^18.14.0 || >=20.6.1"},main:"./dist/main.cjs",module:"./dist/main.js",types:"./dist/main.d.ts",exports:{".":{require:{types:"./dist/main.d.cts",default:"./dist/main.cjs"},import:{types:"./dist/main.d.ts",default:"./dist/main.js"},default:{types:"./dist/main.d.ts",default:"./dist/main.js"}},"./package.json":"./package.json","./bootstrap":{require:{types:"./dist/bootstrap/main.d.cts",default:"./dist/bootstrap/main.cjs"},import:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"},default:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"}},"./exporter-netlify":{require:{types:"./dist/exporters/netlify.d.cts",default:"./dist/exporters/netlify.cjs"},import:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"},default:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"}},"./instrumentation-fetch":{require:{types:"./dist/instrumentations/fetch.d.cts",default:"./dist/instrumentations/fetch.cjs"},import:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"},default:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"}},"./instrumentation-http":{require:{types:"./dist/instrumentations/http.d.cts",default:"./dist/instrumentations/http.cjs"},import:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"},default:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"}},"./opentelemetry":{require:{types:"./dist/opentelemetry.d.cts",default:"./dist/opentelemetry.cjs"},import:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"},default:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"}}},files:["dist/**/*"],scripts:{build:"tsup-node",dev:"tsup-node --watch",prepack:"npm run build",test:"run-s build test:ci","test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"vitest","test:dev:vitest:watch":"vitest watch","test:ci:vitest":"vitest run",publint:"npx -y publint --strict"},keywords:["netlify","cdn"],license:"MIT",repository:{type:"git",url:"https://github.com/netlify/primitives.git",directory:"packages/otel"},bugs:{url:"https://github.com/netlify/primitives/issues"},author:"Netlify Inc.",devDependencies:{"@netlify/dev-utils":"^5.0.0",msw:"^2.10.5","npm-run-all2":"^7.0.2",tsup:"^8.0.0",vitest:"^3.0.0"},dependencies:{"@opentelemetry/api":"1.9.1","@opentelemetry/core":"2.8.0","@opentelemetry/instrumentation":"^0.220.0","@opentelemetry/resources":"2.9.0","@opentelemetry/sdk-trace-node":"2.9.0"}},LIe=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,IIe))return;let e=Fxt.version.slice(1),r=TY({"service.name":t.serviceName,"service.version":t.serviceVersion,"process.runtime.name":"nodejs","process.runtime.version":e,"deployment.environment":t.deploymentEnvironment,"http.url":t.siteUrl,"netlify.site.id":t.siteId,"netlify.site.name":t.siteName}),n=t.spanProcessors??[Vxt()],i=new mk.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new ku});let s=t.instrumentations??[];RY({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,IIe,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new Fc(Ot.getTracer(a,c)):new Fc(Ot.getTracer(OIe.name,OIe.version))}}),Object.defineProperty(globalThis,jxt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},Vxt=()=>new mk.SimpleSpanProcessor(new qxt);Ne();var $b=pn(pK(),1);Ne();import*as gk from"diagnostics_channel";var DIe=class{constructor(t={}){this.instrumentationName="@netlify/otel/instrumentation-fetch",this.instrumentationVersion="1.0.0",this._recordFromReq=new WeakMap,this.config=t,this._channelSubs=[]}getConfig(){return this.config}setConfig(){}setMeterProvider(){}setTracerProvider(t){this.provider=t}getTracerProvider(){return this.provider}annotateFromRequest(t,e){let r=this.config.getRequestAttributes?.(e)??{},n=new URL(e.path,e.origin);t.setAttributes({...r,"http.request.method":e.method,"url.full":n.href,"url.host":n.host,"url.scheme":n.protocol.slice(0,-1),"server.address":n.hostname,"server.port":n.port,...this.prepareHeaders("request",e.headers)})}annotateFromResponse(t,e){let r=this.config.getResponseAttributes?.(e)??{};t.setAttributes({...r,"http.response.status_code":e.statusCode,...this.prepareHeaders("response",e.headers)}),t.setStatus({code:e.statusCode>=400?Gn.ERROR:Gn.UNSET})}prepareHeaders(t,e){if(!Array.isArray(e))return{};if(this.config.skipHeaders===!0)return{};let r=["*","/.*/"],n=this.config.skipHeaders??[],i=this.config.redactHeaders??[],s=n.some(a=>r.includes(a.toString())),o={};if(s)return o;for(let a=0;a+1<e.length;a=a+2){let c=e[a],l=e[a+1];if(typeof c!="string"&&!Buffer.isBuffer(c)||typeof l!="string"&&!Buffer.isBuffer(l))continue;let u=c.toString().toLowerCase();if(n.some(f=>typeof f=="string"?f==u:f.test(u)))continue;let d=`http.${t}.header.${u}`;i===!0||i.some(f=>typeof f=="string"?f==u:f.test(u))?o[d]="REDACTED":o[d]=l.toString()}return o}getRequestMethod(t){return["HEAD","GET","POST","PUT","PATCH","DELETE"].includes(t.toUpperCase())?t.toUpperCase():"_OTHER"}getTracer(){if(!this.provider)return;let t=this.provider.getTracer(this.instrumentationName,this.instrumentationVersion);return t instanceof Fc?t:new Fc(t)}enable(){this._channelSubs.length>0||(this.subscribe("undici:request:create",this.onRequestCreate.bind(this)),this.subscribe("undici:request:headers",this.onRequestHeaders.bind(this)),this.subscribe("undici:request:trailers",this.onRequestEnd.bind(this)),this.subscribe("undici:request:error",this.onRequestError.bind(this)))}subscribe(t,e){gk.subscribe(t,e);let r=()=>gk.unsubscribe(t,e);this._channelSubs.push({name:t,unsubscribe:r})}disable(){this._channelSubs.forEach(t=>{t.unsubscribe()}),this._channelSubs.length=0}onRequestCreate({request:t}){try{let e=this.getTracer(),r=new URL(t.path,t.origin);if(!e||t.method==="CONNECT"||this.config.skipURLs?.some(i=>typeof i=="string"?r.href.startsWith(i):i.test(r.href)))return;let n=e.startSpan(this.getRequestMethod(t.method),{kind:po.CLIENT},Gt.active());this.annotateFromRequest(n,t),this._recordFromReq.set(t,n)}catch{}}onRequestHeaders({request:t,response:e}){try{let r=this._recordFromReq.get(t);if(!r)return;this.annotateFromResponse(r,e)}catch{}}onRequestError({request:t,error:e}){try{let r=this._recordFromReq.get(t);if(!r)return;r.recordException(e),r.setStatus({code:Gn.ERROR,message:e.message}),r.end(),this._recordFromReq.delete(t)}catch{}}onRequestEnd({request:t}){try{let e=this._recordFromReq.get(t);if(!e)return;e.end(),this._recordFromReq.delete(t)}catch{}}};var o1e=pn(i1e(),1);var gD=fe("tracing"),s1e=8e3,sFt=5e3,Xw=async(t=sFt)=>{try{await Promise.race([LAe(),iFt(t)])}catch(e){gD.warn("Failed to flush tracers on shutdown",e)}},a1e=async(t,e,r)=>{if(!Tt()){let n=[new $b.SimpleSpanProcessor(new yJ),new $b.SimpleSpanProcessor(new o1e.OTLPTraceExporter({url:r.exporterUrl}))];await LIe({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new DIe({skipHeaders:!0})]})}return r.traceparent?(ui.setGlobalPropagator(new ku),ui.extract(Gt.active(),{traceparent:r.traceparent,isRemote:!0})):Gt.active()};function Kt(t,e,r){return gD.log(`\u23F3 TRACE: ${e} starting...`),rb(t,e,r)}var yJ=class{export(e,r){for(let n of e)this.logSpan(n);r({code:1})}async shutdown(){}forceFlush(){return Promise.resolve()}logSpan(e){let r=(e.endTime[0]-e.startTime[0])*1e3+(e.endTime[1]-e.startTime[1])/1e6,n=e.attributes,i=[];for(let[a,c]of Object.entries(n))a.includes("duration")&&typeof c=="number"?i.push(`${a}=${c.toFixed(2)}ms`):i.push(`${a}=${c}`);let s=e.status?.code===2?"\u274C":"\u2705",o=i.length>0?` [${i.join(", ")}]`:"";gD.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&gD.log(` \u274C Error: ${e.status.message}`)}};function SJ(){return Ve().captureLlmContentEnabled}function c1e(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")?"google":t.includes("opencode")?"opencode":t}function _D(t,e,r){let n={role:t,parts:[{type:"text",content:Pi(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var oFt=new Set([te.Task,te.RunCommand,te.Explore,te.FileRead,te.FileWrite,te.Notebook,te.Web,te.Todo,te.Skill,te.Tool,te.Memorize,te.Deployment,te.SiteGeneration]);function l1e(t,e,r,n){if(!t.length)return;let i=Tt();if(!i)return;let s=SJ(),o=Math.max(1,(n-r)/t.length);t.forEach((a,c)=>{let l=Math.min(n,r+c*o),u=Math.min(n,l+o),d=a.type==="tool_use"||a.type==="tool_result"||a.category!=null&&oFt.has(a.category),f=d?"execute_tool":"chat",p=a.title||a.type||`step-${a.id??c}`,h=a.category||"unknown",m=d?`${f} ${h}`:f,_=a.message?a.message.length>s1e?`${a.message.slice(0,s1e)}\u2026`:a.message:void 0;i.startSpan(m,{startTime:l,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":p,"gen_ai.operation.name":f,...d?{"gen_ai.tool.name":h}:{},"spark.step.id":a.id??-1,...a.type?{"spark.step.type":a.type}:{},...a.category?{"spark.step.category":a.category}:{},...a.groupId?{"spark.step.group_id":a.groupId}:{},...a.parentGroupId?{"spark.step.parent_group_id":a.parentGroupId}:{},...s&&_?d?{"gen_ai.tool.call.result":Pi(_)}:{"gen_ai.output.messages":_D("assistant",_)}:{}}}).end(u)})}import{readdir as aFt,rm as cFt}from"fs/promises";import{join as lFt}from"path";async function u1e(t,e=[]){let n=(await aFt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>cFt(lFt(t,i),{recursive:!0,force:!0})))}var uFt=300,Qw=t=>Ve().budgetCreditThresholds[t.mode]?.[t.runner]??uFt,eR=({mode:t,sessionCreditLimit:e},r)=>t==="create"&&e!=null&&e<=r;var EJ=t=>{let e=Qw(t);if(!eR(t,e))return"default";let r=Ve();return r.createAskFirstEnabled&&r.questionsEnabled?"ask_first":r.creditWrapUpEnabled?"budget_constrained":"default"},d1e=t=>{let e=EJ(t),r=Qw(t);return{budget_eligible:eR(t,r),budget_constrained:e==="budget_constrained",ask_first:e==="ask_first"}};var hFt=tR.dirname(dFt(import.meta.url)),f1e=fFt(import.meta.url),mFt=tR.resolve(hFt,"scripts/scaffold.js"),gFt="scripts/scaffold.js",_Ft=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,vJ=t=>{if(t.length>=2){let e=t[0],r=t[t.length-1];if(e==='"'&&r==='"'||e==="'"&&r==="'")return t.slice(1,-1)}return t},yFt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),SFt=t=>{let e=vJ(t);return e==="node"||e.endsWith("/node")},ll=t=>{if(typeof t!="string")return!1;let e=t.match(_Ft)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&yFt(vJ(e[r]));)r+=1;if(r>=e.length||!SFt(e[r]))return!1;let n=e[r+1];return n?vJ(n).includes(gFt):!1},Mp=fe("create_stage"),TJ="Do not run local validation or dev-server commands to check your work \u2014 specifically `tsc`, `npx tsc`, `vite build`, `vite dev`, or any equivalent build/start/test command. The build pipeline installs and validates the project automatically after your edits. Verify your changes by reading the files you edited.",EFt=`${TJ}
|
|
598
598
|
|
|
599
599
|
Commands that generate or modify project files are fine to run when the task requires them \u2014 for example \`drizzle-kit generate\` to write a database migration after a schema change, or other code-generation utilities documented in the skills.`,vFt=`${TJ}
|
|
600
600
|
|
|
@@ -708,7 +708,7 @@ NETLIFY_BUILD_BASE="\${NETLIFY_BUILD_BASE:-${xFt}}" ${e} ${r} <template-id> [--p
|
|
|
708
708
|
Replace \`<template-id>\` with the matching template \`id\`. Include \`--package-manager\` only if the user specified one. The templates can include relevant agent skills. The \`NETLIFY_BUILD_BASE=\u2026\` prefix lets the scaffold use a local template mirror if the platform set one \u2014 leave it as-is. Follow the instructions printed by the scaffold command.`:"",a="You are creating a new Netlify project to fulfill the user's request. The project directory is currently empty.",c=[a,o,RFt];return n?c=[a,AFt,o]:i&&(c=[a,bFt,o]),c.filter(Boolean).join(`
|
|
709
709
|
|
|
710
710
|
`)},PFt=t=>{try{return JSON.parse(pFt(tR.join(t,".netlify","scaffold-result.json"),"utf8"))}catch{return}},p1e=async t=>{let e=PFt(t);await Kt(Tt(),"create-scaffold-telemetry",r=>{r?.setAttributes({"create.template":e?.template??"none","create.packageManager":e?.packageManager??"none"})})},h1e=async({config:t,cwd:e=yD.cwd()})=>await Kt(Tt(),"create-stage",async r=>{let n=performance.now();r?.setAttributes({"create.runner":t.runner,"create.id":t.id,"create.sessionId":t.sessionId}),await u1e(e,[".netlify",".git","node_modules"]),Mp.info("Cleaned cwd folder");let{nodeCmd:i,tsCliPath:s}=CFt({cwd:e}),o=[];if(s){let f=[s,"--list-addons-json"];Mp.log(`Running ${i} ${f.join(" ")}`);let{stdout:p}=await sr(i,f);o=IFt(p),Mp.info("Retrieved add-ons")}else Mp.warn("ts-cli binary not resolved; create-mode prompt will omit template section"),ee.inc("context.degraded",1,{component:"templates"});let a=EJ(t),c=a==="budget_constrained",l=a==="ask_first";l&&Mp.log("Low budget create run - Instructing the agent to ask for clarity if necessary",{accountType:t.accountType,sessionCreditLimit:t.sessionCreditLimit}),ee.inc("create.low_budget_limit_ask",1,{ask_first:l}),c&&Mp.log("Budget-constrained create run \u2014 using plan + first-milestone instructions",{accountType:t.accountType,sessionCreditLimit:t.sessionCreditLimit}),ee.inc("create.budget_constrained",1,{constrained:c});let u=OFt({templates:o,nodeCmd:i,scaffoldScriptPath:mFt,budgetConstrained:c,askUserClarity:l}),d=performance.now()-n;return r?.setAttributes({"create.duration.ms":d,"create.status":"success","create.budget_constrained":c,"create.ask_user_clarity":l}),{additionalContext:u}});var ul={Task:{name:"Task",category:te.Task},Agent:{name:"Task",category:te.Task},SendMessage:{name:"Message agent",category:te.Task},TaskOutput:{name:"Get task output",category:te.Task},TaskStop:{name:"Stop task",category:te.Task},TaskCreate:{name:"Update task list",category:te.Todo},TaskUpdate:{name:"Update task list",category:te.Todo},TaskList:{name:"Read task list",category:te.Todo},TaskGet:{name:"Read task list",category:te.Todo},ToolSearch:{name:"Load tools",category:te.Explore},Skill:{name:"Use skill",category:te.Skill},EnterPlanMode:{name:"Start planning",category:te.Plan},ListMcpResources:{name:"List resources",category:te.Explore},ReadMcpResource:{name:"Read resource",category:te.Explore},Bash:{name:"Run command",category:te.RunCommand},Glob:{name:"Find files",category:te.Explore},Grep:{name:"Search files",category:te.Explore},LS:{name:"List directory",category:te.Explore},ExitPlanMode:{name:"Exit planning",category:te.Plan},Read:{name:"Read file",category:te.FileRead},Edit:{name:"Edit file",category:te.FileWrite},MultiEdit:{name:"Edit multiple files",category:te.FileWrite},Write:{name:"Edit file",category:te.FileWrite},NotebookEdit:{name:"Edit notebook",category:te.Notebook},WebFetch:{name:"Fetch web",category:te.Web},TodoWrite:{name:"Update task list",category:te.Todo},WebSearch:{name:"Search web",category:te.Web},BashOutput:{name:"Get command output",category:te.RunCommand},KillBash:{name:"Stop command",category:te.RunCommand}},rR=t=>{if(ul[t])return ul[t].name;let e=t.match(/^mcp__(.+?)__(.+)$/);return e?`${e[2].replace(/_/g," ")} (${e[1]})`:t},wJ=t=>t==="Task"||t==="Agent",m1e=t=>{let[e=""]=t.split(`
|
|
711
|
-
`,1);return/^(Async agent launched successfully|Agent launched in background)/.test(e)||/\(internal ID:?\s*[\w./-]+\)/i.test(e)},g1e=new Set(["SendMessage","ToolSearch","TaskList","TaskGet","EnterPlanMode","TaskStop"]);var kn=fe("runner_claude"),SD="Claude Code",nR="claude-opus-5-5",RJ="claude-sonnet-5";async function kFt({aiGateway:t,config:e,model:r}){let n=r;if(t)if(e.modelVersionOverrides?.claude){let i=e.modelVersionOverrides?.claude?.[e.accountType];if(i){if(!await t.isModelAvailableForProvider("anthropic",i))throw new Error(`Model override '${i}' is not available for anthropic provider`);n=i}}else r?await t.isModelAvailableForProvider("anthropic",r)||(kn.log(`Model '${r}' is not available for anthropic provider, proceeding without model specification`),ee.inc("model.unavailable",1,{provider:"anthropic"}),n=void 0):await t.isModelAvailableForProvider("anthropic",nR)?(kn.log(`Using default model: ${nR}`),n=nR):kn.log(`Model ${nR} is not available, proceeding without model specification`);return n}function $Ft({aiGateway:t}){if(t){let{token:e,url:r}=t;if(!e||!r)throw new Error("No token or url provided from AI Gateway");return{...ly.env,ANTHROPIC_API_KEY:e,ANTHROPIC_BASE_URL:r}}if(!ly.env.ANTHROPIC_API_KEY)throw new Error("ANTHROPIC_API_KEY is not provided");return{...ly.env}}async function LFt(){let t=iR.join(ly.cwd(),"AGENTS.md");try{await cy.access(t)}catch{return}let e=iR.join(ly.cwd(),"CLAUDE.local.md"),r="@AGENTS.md";try{if((await cy.readFile(e,"utf-8")).includes(r))return;await cy.appendFile(e,`
|
|
711
|
+
`,1);return/^(Async agent launched successfully|Agent launched in background)/.test(e)||/\(internal ID:?\s*[\w./-]+\)/i.test(e)},g1e=new Set(["SendMessage","ToolSearch","TaskList","TaskGet","EnterPlanMode","TaskStop"]);var kn=fe("runner_claude"),SD="Claude Code",nR="claude-opus-5-5",RJ="claude-sonnet-5-5";async function kFt({aiGateway:t,config:e,model:r}){let n=r;if(t)if(e.modelVersionOverrides?.claude){let i=e.modelVersionOverrides?.claude?.[e.accountType];if(i){if(!await t.isModelAvailableForProvider("anthropic",i))throw new Error(`Model override '${i}' is not available for anthropic provider`);n=i}}else r?await t.isModelAvailableForProvider("anthropic",r)||(kn.log(`Model '${r}' is not available for anthropic provider, proceeding without model specification`),ee.inc("model.unavailable",1,{provider:"anthropic"}),n=void 0):await t.isModelAvailableForProvider("anthropic",nR)?(kn.log(`Using default model: ${nR}`),n=nR):kn.log(`Model ${nR} is not available, proceeding without model specification`);return n}function $Ft({aiGateway:t}){if(t){let{token:e,url:r}=t;if(!e||!r)throw new Error("No token or url provided from AI Gateway");return{...ly.env,ANTHROPIC_API_KEY:e,ANTHROPIC_BASE_URL:r}}if(!ly.env.ANTHROPIC_API_KEY)throw new Error("ANTHROPIC_API_KEY is not provided");return{...ly.env}}async function LFt(){let t=iR.join(ly.cwd(),"AGENTS.md");try{await cy.access(t)}catch{return}let e=iR.join(ly.cwd(),"CLAUDE.local.md"),r="@AGENTS.md";try{if((await cy.readFile(e,"utf-8")).includes(r))return;await cy.appendFile(e,`
|
|
712
712
|
${r}
|
|
713
713
|
`)}catch{await cy.writeFile(e,`${r}
|
|
714
714
|
`)}kn.log("Added @AGENTS.md import to CLAUDE.local.md")}async function AJ({config:t,persistSteps:e,aiGateway:r,continueSession:n,priorAgentSessionId:i,cwd:s=ly.cwd(),cliPath:o="netlify",abortSignal:a,onSessionId:c,forceLowEffortForCreditWrapUp:l}){let u=t,{prompt:d}=u,{model:f}=t,p="";await LFt();let h=$Ft({aiGateway:r}),m=await kFt({config:t,aiGateway:r,model:f});l&&m?.includes("fable")&&(!r||await r.isModelAvailableForProvider("anthropic",RJ))&&(kn.log(`Credit wrap-up: downgrading model ${m} to ${RJ}`),m=RJ);let _=[],S=[],E={},y=new Set,g=[],T=se=>se?.match(/task\s+#([\w-]+)\s+created/i)?.[1],w=se=>{if(typeof se=="string")return se;if(Array.isArray(se))return se.filter(Ie=>Ie?.type==="text"&&typeof Ie.text=="string").map(Ie=>Ie.text).join(`
|
package/dist/index.js
CHANGED
|
@@ -142,7 +142,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
142
142
|
`,LF:`
|
|
143
143
|
`,concatBytes:PU},UGe=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},FGe={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:UGe};import{Buffer as zGe}from"buffer";var Eae=(t,e)=>t?void 0:jGe.bind(void 0,e),jGe=function*(t,e){if(typeof e!="string"&&!dr(e)&&!zGe.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},vae=(t,e)=>t?BGe.bind(void 0,e):qGe.bind(void 0,e),BGe=function*(t,e){Tae(t,e),yield e},qGe=function*(t,e){if(Tae(t,e),typeof e!="string"&&!dr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},Tae=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
144
144
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
145
|
-
if (condition) { yield value; }`)};import{Buffer as GGe}from"buffer";import{StringDecoder as VGe}from"string_decoder";var RR=(t,e,r)=>{if(r)return;if(t)return{transform:HGe.bind(void 0,new TextEncoder)};let n=new VGe(e);return{transform:WGe.bind(void 0,n),final:YGe.bind(void 0,n)}},HGe=function*(t,e){GGe.isBuffer(e)?yield fa(e):typeof e=="string"?yield t.encode(e):yield e},WGe=function*(t,e){yield dr(e)?t.write(e):e},YGe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as bae}from"util";var NU=bae(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),CR=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=ZGe}=e[r];for await(let i of n(t))yield*CR(i,e,r+1)},wae=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*KGe(r,Number(e),t)},KGe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*CR(n,r,e+1)},Aae=bae(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),ZGe=function*(t){yield t};var kU=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},xae=(t,e)=>[...e.flatMap(r=>[...Fu(r,t,0)]),...Wy(t)],Fu=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=XGe}=e[r];for(let i of n(t))yield*Fu(i,e,r+1)},Wy=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*JGe(r,Number(e),t)},JGe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Fu(n,r,e+1)},XGe=function*(t){yield t};var MU=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Cae(t,s,o),l=Uu(e),u=Uu(r),d=l?NU.bind(void 0,CR,a):kU.bind(void 0,Fu),f=l||u?NU.bind(void 0,wae,a):kU.bind(void 0,Wy),p=l||u?Aae.bind(void 0,a):void 0;return{stream:new QGe({writableObjectMode:n,writableHighWaterMark:Rae(n),readableObjectMode:i,readableHighWaterMark:Rae(i),transform(m,g,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:p})}},IR=(t,e,r,n)=>{let i=e.filter(({type:s})=>s==="generator"),o=n?i.reverse():i;for(let{value:s,optionName:a}of o){let c=Cae(s,r,a);t=xae(c,t)}return t},Cae=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Eae(n,a)},RR(r,s,n),xR(r,o,n,c),{transform:t,final:e},{transform:vae(i,a)},Sae({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Iae=(t,e)=>{for(let r of eVe(t))tVe(t,r,e)},eVe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),tVe=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Nc[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>rVe(a,n));r.input=Ly(s)},rVe=(t,e)=>{let r=IR(t,e,"utf8",!0);return nVe(r),Ly(r)},nVe=t=>{let e=t.find(r=>typeof r!="string"&&!dr(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 aVe,appendFileSync as cVe}from"fs";var PR=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Ip(r,n)&&!ti.has(e)&&iVe(n)&&(t.some(({type:i,value:o})=>i==="native"&&oVe.has(o))||t.every(({type:i})=>Pi.has(i))),iVe=t=>t===1||t===2,oVe=new Set(["pipe","overlapped"]),Pae=async(t,e,r,n)=>{for await(let i of t)sVe(e)||Nae(i,r,n)},Oae=(t,e,r)=>{for(let n of t)Nae(n,e,r)},sVe=t=>t._readableState.pipes.length>0,Nae=(t,e,r)=>{let n=Gx(t);os({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var kae=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,l)=>lVe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},lVe=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=Mse(t,o,d),p=fa(f),{stdioItems:h,objectMode:m}=e[r],g=uVe([p],h,c,n),{serializedResult:S,finalResult:E=S}=dVe({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});fVe({serializedResult:S,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let T=a[r]?E:void 0;try{return n.error===void 0&&pVe(S,h,i),T}catch(b){return n.error=b,T}},uVe=(t,e,r,n)=>{try{return IR(t,e,r,!1)}catch(i){return n.error=i,t}},dVe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Ly(t)};let s=Yne(t,r);return n[o]?{serializedResult:s,finalResult:OU(s,!i[o],e)}:{serializedResult:s}},fVe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!PR({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=OU(t,!1,s);try{Oae(a,e,n)}catch(c){r.error??=c}},pVe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>wR.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?cVe(n,t):(r.add(o),aVe(n,t))}};var Mae=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,ma(e,r,"all")]:Array.isArray(e)?[ma(t,r,"all"),...e]:dr(t)&&dr(e)?z1([t,e]):`${t}${e}`};import{once as DU}from"events";var Dae=async(t,e)=>{let[r,n]=await hVe(t);return e.isForcefullyTerminated??=!1,[r,n]},hVe=async t=>{let[e,r]=await Promise.allSettled([DU(t,"spawn"),DU(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?$ae(t):r.value},$ae=async t=>{try{return await DU(t,"exit")}catch{return $ae(t)}},Lae=async t=>{let[e,r]=await t;if(!mVe(e,r)&&$U(e,r))throw new lo;return[e,r]},mVe=(t,e)=>t===void 0&&e===void 0,$U=(t,e)=>t!==0||e!==null;var Uae=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=gVe(t,e,r),s=o?.code==="ETIMEDOUT",a=kse(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},gVe=(t,e,r)=>t!==void 0?t:$U(e,r)?new lo:void 0;var Fae=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=yVe(t,e,r),d=vVe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Fp(d,c,l)},yVe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=Hx(t,e,r),a=SVe(r),{file:c,commandArguments:l,options:u}=fR(t,e,a);EVe(u);let d=mae(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},SVe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,EVe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&OR("ipcInput"),t&&OR("ipc: true"),r&&OR("detached: true"),n&&OR("cancelSignal")},OR=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},vVe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=TVe({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=Uae(c,r),{output:h,error:m=l}=kae({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((E,T)=>ma(E,r,T)),S=ma(Mae(h,r),r,"all");return wVe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:S,options:r,command:n,escapedCommand:i,startTime:a})},TVe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Iae(o,r);let a=bVe(r);return _Ve(...pR(t,e,a))}catch(a){return Up({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},bVe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:ER(e)}),wVe=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?vR({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):Hy({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as dHe}from"events";import{spawn as fHe}from"child_process";import Gae from"process";import{once as LU,on as AVe}from"events";var zae=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Np({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:sR(t)}),xVe({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),xVe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{rR(e,i);let o=Oc(t,e,r),s=new AbortController;try{return await Promise.race([RVe(o,n,s),CVe(o,r,s),IVe(o,r,s)])}catch(a){throw kp(t),a}finally{s.abort(),nR(e,i)}},RVe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await LU(t,"message",{signal:r});return n}for await(let[n]of AVe(t,"message",{signal:r}))if(e(n))return n},CVe=async(t,e,{signal:r})=>{await LU(t,"disconnect",{signal:r}),xoe(e)},IVe=async(t,e,{signal:r})=>{let[n]=await LU(t,"strict:error",{signal:r});throw Qx(n,e)};import{once as Bae,on as PVe}from"events";var qae=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>UU({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),UU=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Np({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:sR(t)}),rR(e,o);let s=Oc(t,e,r),a=new AbortController,c={};return OVe(t,s,a),NVe({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),kVe({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},OVe=async(t,e,r)=>{try{await Bae(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},NVe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Bae(t,"strict:error",{signal:r.signal});n.error=Qx(i,e),r.abort()}catch{}},kVe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of PVe(r,"message",{signal:o.signal}))jae(s),yield c}catch{jae(s)}finally{o.abort(),nR(e,a),n||kp(t),i&&await t}},jae=({error:t})=>{if(t)throw t};var Vae=(t,{ipc:e})=>{Object.assign(t,Wae(t,!1,e))},Hae=()=>{let t=Gae,e=!0,r=Gae.channel!==void 0;return{...Wae(t,e,r),getCancelSignal:Qoe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Wae=(t,e,r)=>({sendMessage:uR.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:zae.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:qae.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as MVe}from"child_process";import{PassThrough as DVe,Readable as $Ve,Writable as LVe,Duplex as UVe}from"stream";var Yae=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{CU(n);let a=new MVe;FVe(a,n),Object.assign(a,{readable:zVe,writable:jVe,duplex:BVe});let c=Up({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=qVe(c,s,i);return{subprocess:a,promise:l}},FVe=(t,e)=>{let r=Yy(),n=Yy(),i=Yy(),o=Array.from({length:e.length-3},Yy),s=Yy(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},Yy=()=>{let t=new DVe;return t.end(),t},zVe=()=>new $Ve({read(){}}),jVe=()=>new LVe({write(){}}),BVe=()=>new UVe({read(){},write(){}}),qVe=async(t,e,r)=>Fp(t,e,r);import{createReadStream as Kae,createWriteStream as Zae}from"fs";import{Buffer as GVe}from"buffer";import{Readable as Ky,Writable as VVe,Duplex as HVe}from"stream";var Xae=(t,e)=>AR(WVe,t,e,!1),Zy=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Nc[t]}.`)},Jae={fileNumber:Zy,generator:MU,asyncGenerator:MU,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:HVe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},WVe={input:{...Jae,fileUrl:({value:t})=>({stream:Kae(t)}),filePath:({value:{file:t}})=>({stream:Kae(t)}),webStream:({value:t})=>({stream:Ky.fromWeb(t)}),iterable:({value:t})=>({stream:Ky.from(t)}),asyncIterable:({value:t})=>({stream:Ky.from(t)}),string:({value:t})=>({stream:Ky.from(t)}),uint8Array:({value:t})=>({stream:Ky.from(GVe.from(t))})},output:{...Jae,fileUrl:({value:t})=>({stream:Zae(t)}),filePath:({value:{file:t,append:e}})=>({stream:Zae(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:VVe.fromWeb(t)}),iterable:Zy,asyncIterable:Zy,string:Zy,uint8Array:Zy}};import{on as YVe,once as Qae}from"events";import{PassThrough as KVe,getDefaultHighWaterMark as ZVe}from"stream";import{finished as rce}from"stream/promises";function zu(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)zU(i);let e=t.some(({readableObjectMode:i})=>i),r=JVe(t,e),n=new FU({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var JVe=(t,e)=>{if(t.length===0)return ZVe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},FU=class extends KVe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(zU(e),this.#e.has(e))return;this.#e.add(e),this.#n??=XVe(this,this.#e,this.#o);let r=t4e({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#o});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(zU(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},XVe=async(t,e,r)=>{NR(t,ece);let n=new AbortController;try{await Promise.race([QVe(t,n),e4e(t,e,r,n)])}finally{n.abort(),NR(t,-ece)}},QVe=async(t,{signal:e})=>{try{await rce(t,{signal:e,cleanup:!0})}catch(r){throw nce(t,r),r}},e4e=async(t,e,r,{signal:n})=>{for await(let[i]of YVe(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},zU=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},t4e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{NR(t,tce);let a=new AbortController;try{await Promise.race([r4e(o,e,a),n4e({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),i4e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),NR(t,-tce)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?jU(t):o4e(t))},r4e=async(t,e,{signal:r})=>{try{await t,r.aborted||jU(e)}catch(n){r.aborted||nce(e,n)}},n4e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await rce(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;ice(s)?i.add(e):oce(t,s)}},i4e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await Qae(t,i,{signal:o}),!t.readable)return Qae(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},o4e=t=>{t.writable&&t.end()},nce=(t,e)=>{ice(e)?jU(t):oce(t,e)},ice=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",jU=t=>{(t.readable||t.writable)&&t.destroy()},oce=(t,e)=>{t.destroyed||(t.once("error",s4e),t.destroy(e))},s4e=()=>{},NR=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},ece=2,tce=1;import{finished as sce}from"stream/promises";var jp=(t,e)=>{t.pipe(e),a4e(t,e),c4e(t,e)},a4e=async(t,e)=>{if(!(co(t)||co(e))){try{await sce(t,{cleanup:!0,readable:!0,writable:!1})}catch{}BU(e)}},BU=t=>{t.writable&&t.end()},c4e=async(t,e)=>{if(!(co(t)||co(e))){try{await sce(e,{cleanup:!0,readable:!1,writable:!0})}catch{}qU(t)}},qU=t=>{t.readable&&t.destroy()};var ace=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:o,direction:s}]of Object.entries(e)){for(let{stream:a}of o.filter(({type:c})=>Pi.has(c)))l4e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Pi.has(c)))d4e({subprocess:t,stream:a,direction:s,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,o]of n.entries()){let s=o.length===1?o[0]:zu(o);jp(s,i)}},l4e=(t,e,r,n)=>{r==="output"?jp(t.stdio[n],e):jp(e,t.stdio[n]);let i=u4e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},u4e=["stdin","stdout","stderr"],d4e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;f4e(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},f4e=(t,{signal:e})=>{co(t)&&$u(t,p4e,e)},p4e=2;import{addAbortListener as g4e}from"events";var ju=[];ju.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&ju.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&ju.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var kR=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",GU=Symbol.for("signal-exit emitter"),VU=globalThis,h4e=Object.defineProperty.bind(Object),HU=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(VU[GU])return VU[GU];h4e(VU,GU,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let o of this.listeners[e])i=o(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},MR=class{},m4e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),WU=class extends MR{onExit(){return()=>{}}load(){}unload(){}},YU=class extends MR{#e=KU.platform==="win32"?"SIGINT":"SIGHUP";#r=new HU;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of ju)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,o=e;if(typeof o.__signal_exit_emitter__=="object"&&typeof o.__signal_exit_emitter__.count=="number"&&(i+=o.__signal_exit_emitter__.count),n.length===i){this.unload();let s=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;s||e.kill(e.pid,a)}};this.#o=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!kR(this.#t))return()=>{};this.#s===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#r.on(n,e),()=>{this.#r.removeListener(n,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#s){this.#s=!0,this.#r.count+=1;for(let e of ju)try{let r=this.#i[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#s&&(this.#s=!1,ju.forEach(e=>{let r=this.#i[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#o,this.#r.count-=1)}#a(e){return kR(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#o.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&kR(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let i=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),i}else return n.call(this.#t,e,...r)}},KU=globalThis.process,{onExit:cce,load:WLt,unload:YLt}=m4e(kR(KU)?new YU(KU):new WU);var lce=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=cce(()=>{t.kill()});g4e(n,()=>{i()})};var dce=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=Vx(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=_4e(r,n,i),{sourceStream:d,sourceError:f}=S4e(t,l),{options:p,fileDescriptors:h}=as.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},_4e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=y4e(t,e,...r),a=tR(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},y4e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(uce,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||U1(r)){if(Object.keys(t).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[i,o,s]=Dx(r,...n);return{destination:e(uce)(i,o,s),pipeOptions:s}}if(as.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}`)},uce=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),S4e=(t,e)=>{try{return{sourceStream:Mp(t,e)}}catch(r){return{sourceError:r}}};var pce=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=E4e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw ZU({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},E4e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return qU(t),n;if(e!==void 0)return BU(r),e},ZU=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Up({error:t,command:fce,escapedCommand:fce,fileDescriptors:e,options:r,startTime:n,isSync:!1}),fce="source.pipe(destination)";var hce=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:o,value:s=o}]=await t;if(s.pipedFrom.includes(n)||s.pipedFrom.push(n),i==="rejected")throw s;if(e==="rejected")throw n;return s};import{finished as v4e}from"stream/promises";var mce=(t,e,r)=>{let n=DR.has(e)?b4e(t,e):T4e(t,e);return $u(t,A4e,r.signal),$u(e,x4e,r.signal),w4e(e),n},T4e=(t,e)=>{let r=zu([t]);return jp(r,e),DR.set(e,r),r},b4e=(t,e)=>{let r=DR.get(e);return r.add(t),r},w4e=async t=>{try{await v4e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}DR.delete(t)},DR=new WeakMap,A4e=2,x4e=1;import{aborted as R4e}from"util";var gce=(t,e)=>t===void 0?[]:[C4e(t,e)],C4e=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await R4e(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw ZU({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var $R=(t,...e)=>{if(Jt(e[0]))return $R.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=dce(t,...e),i=I4e({...n,destination:r});return i.pipe=$R.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},I4e=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=P4e(t,i);pce({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=mce(e,o,d);return await Promise.race([hce(u),...gce(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},P4e=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as L4e}from"timers/promises";import{on as O4e}from"events";import{getDefaultHighWaterMark as N4e}from"stream";var LR=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return k4e(e,s),yce({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},k4e=async(t,e)=>{try{await t}catch{}finally{e.abort()}},JU=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;M4e(e,s,t);let a=t.readableObjectMode&&!o;return yce({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},M4e=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},yce=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=O4e(t,"data",{signal:e.signal,highWaterMark:_ce,highWatermark:_ce});return D4e({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},XU=N4e(!0),_ce=XU,D4e=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=$4e({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Fu(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Wy(a)}},$4e=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[RR(t,r,!e),xR(t,i,!n,{})].filter(Boolean);var Sce=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=U4e({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([F4e(t),d]);return}let f=IU(c,r),p=JU({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([z4e({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},U4e=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!PR({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=JU({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Pae(a,t,r,o)},F4e=async t=>{await L4e(),t.readableFlowing===null&&t.resume()},z4e=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await _R(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await yR(r,{maxBuffer:o})):await Lp(r,{maxBuffer:o})}catch(a){return Ece(Pse({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},QU=async t=>{try{return await t}catch(e){return Ece(e)}},Ece=({bufferedData:t})=>Hne(t)?new Uint8Array(t):t;import{finished as j4e}from"stream/promises";var Jy=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=B4e(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],j4e(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||V4e(a,e,r,n)}finally{s.abort()}},B4e=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&q4e(t,r,n),n},q4e=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{G4e(e,r),n.call(t,...i)}},G4e=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},V4e=(t,e,r,n)=>{if(!H4e(t,e,r,n))throw t},H4e=(t,e,r,n=!0)=>r.propagating?vce(t)||UR(t):(r.propagating=!0,eF(r,e)===n?vce(t):UR(t)),eF=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",UR=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",vce=t=>t?.code==="EPIPE";var Tce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>tF({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),tF=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=Jy(t,e,l);if(eF(l,e)){await u;return}let[d]=await Promise.all([Sce({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var bce=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?zu([t,e].filter(Boolean)):void 0,wce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>tF({...W4e(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:Y4e(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),W4e=({stdout:t,stderr:e,all:r},[,n,i])=>{let o=n||i;return o?n?i?{stream:r,buffer:o}:{stream:t,buffer:o}:{stream:e,buffer:o}:{stream:r,buffer:o}},Y4e=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as K4e}from"events";var Ace=t=>Ip(t,"ipc"),xce=(t,e)=>{let r=Gx(t);os({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Rce=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=Ace(o),a=pa(e,"ipc"),c=pa(r,"ipc");for await(let l of UU({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Ose(t,i,c),i.push(l)),s&&xce(l,o);return i},Cce=async(t,e)=>(await Promise.allSettled([t]),e);var Ice=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:g,controller:S})=>{let E=Dae(t,f),T={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:E,propagating:!1},b=Tce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),w=wce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),x=[],P=Rce({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:x,verboseInfo:p}),I=Z4e(m,t,T),N=J4e(h,T);try{return await Promise.race([Promise.all([{},Lae(E),Promise.all(b),w,P,lse(t,d),...I,...N]),g,X4e(t,S),...ise(t,o,f,S),...Aoe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:S}),...rse({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(L){return f.terminationReason??="other",Promise.all([{error:L},E,Promise.all(b.map(v=>QU(v))),QU(w),Cce(P,x),Promise.allSettled(I),Promise.allSettled(N)])}},Z4e=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:Jy(n,i,r)),J4e=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>fo(o,{checkOpen:!1})&&!co(o)).map(({type:i,value:o,stream:s=o})=>Jy(s,n,e,{isSameDirection:Pi.has(i),stopOnExit:i==="native"}))),X4e=async(t,{signal:e})=>{let[r]=await K4e(t,"error",{signal:e});throw r};var Pce=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),Xy=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=ss();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Bp=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 Q4e}from"stream";import{callbackify as eHe}from"util";import{finished as Oce}from"stream/promises";var rF=async t=>{if(t!==void 0)try{await nF(t)}catch{}},Nce=async t=>{if(t!==void 0)try{await iF(t)}catch{}},nF=async t=>{await Oce(t,{cleanup:!0,readable:!1,writable:!0})},iF=async t=>{await Oce(t,{cleanup:!0,readable:!0,writable:!1})},FR=async(t,e)=>{if(await t,e)throw e},zR=(t,e,r)=>{r&&!UR(r)?t.destroy(r):e&&t.destroy()};var kce=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||ti.has(r),{subprocessStdout:a,waitReadableDestroy:c}=oF(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=sF(a,s),{read:f,onStdoutDataDone:p}=aF({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new Q4e({read:f,destroy:eHe(lF.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return cF({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},oF=(t,e,r)=>{let n=Mp(t,e),i=Xy(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},sF=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:XU},aF=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=ss(),s=LR({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){tHe(this,s,o)},onStdoutDataDone:o}},tHe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},cF=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await iF(t),await n,await rF(i),await e,r.readable&&r.push(null)}catch(o){await rF(i),Mce(r,o)}},lF=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Bp(r,e)&&(Mce(t,n),await FR(e,n))},Mce=(t,e)=>{zR(t,t.readable,e)};import{Writable as rHe}from"stream";import{callbackify as Dce}from"util";var $ce=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=uF(t,r,e),s=new rHe({...dF(n,t,i),destroy:Dce(pF.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return fF(n,s),s},uF=(t,e,r)=>{let n=tR(t,e),i=Xy(r,n,"writableFinal"),o=Xy(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},dF=(t,e,r)=>({write:nHe.bind(void 0,t),final:Dce(iHe.bind(void 0,t,e,r))}),nHe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},iHe=async(t,e,r)=>{await Bp(r,e)&&(t.writable&&t.end(),await e)},fF=async(t,e,r)=>{try{await nF(t),e.writable&&e.end()}catch(n){await Nce(r),Lce(e,n)}},pF=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Bp(r,e),await Bp(n,e)&&(Lce(t,i),await FR(e,i))},Lce=(t,e)=>{zR(t,t.writable,e)};import{Duplex as oHe}from"stream";import{callbackify as sHe}from"util";var Uce=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||ti.has(r),{subprocessStdout:c,waitReadableDestroy:l}=oF(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=uF(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=sF(c,a),{read:g,onStdoutDataDone:S}=aF({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),E=new oHe({read:g,...dF(u,t,d),destroy:sHe(aHe.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return cF({subprocessStdout:c,onStdoutDataDone:S,readable:E,subprocess:t,subprocessStdin:u}),fF(u,E,c),E},aHe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([lF({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),pF({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var hF=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||ti.has(e),s=Mp(t,r),a=LR({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return cHe(a,s,t)},cHe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Fce=(t,{encoding:e})=>{let r=Pce();t.readable=kce.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=$ce.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Uce.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=hF.bind(void 0,t,e),t[Symbol.asyncIterator]=hF.bind(void 0,t,e,{})};var zce=(t,e)=>{for(let[r,n]of uHe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},lHe=(async()=>{})().constructor.prototype,uHe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(lHe,t)]);var jce=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=pHe(t,e,r),{subprocess:f,promise:p}=mHe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=$R.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),zce(f,p),as.set(f,{options:u,fileDescriptors:d}),f},pHe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=Hx(t,e,r),{file:a,commandArguments:c,options:l}=fR(t,e,r),u=hHe(l),d=Xae(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},hHe=({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}},mHe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=fHe(...pR(t,e,r))}catch(h){return Yae({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;dHe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];ace(c,a,l),lce(c,r,l);let d={},f=ss();c.kill=boe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=bce(c,r),Fce(c,r),Vae(c,r);let p=gHe({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:o,escapedCommand:s,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},gHe=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,g]=await Ice({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let S=h.map((b,w)=>ma(b,e,w)),E=ma(m,e,"all"),T=_He({errorInfo:d,exitCode:f,signal:p,stdio:S,all:E,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Fp(T,n,e)},_He=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?Hy({error:t.error,command:c,escapedCommand:l,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof cs,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):vR({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var jR=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,yHe(n,t[n],i)]));return{...t,...r}},yHe=(t,e,r)=>SHe.has(t)&&Jt(e)&&Jt(r)?{...e,...r}:r,SHe=new Set(["env",...G1]);var kc=(t,e,r,n)=>{let i=(s,a,c)=>kc(s,a,r,c),o=(...s)=>EHe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},EHe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Jt(o))return i(t,jR(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=vHe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?Fae(a,c,l):jce(a,c,l,i)},vHe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=Xne(e)?Qne(e,r):[e,...r],[s,a,c]=Dx(...o),l=jR(jR(n,i),c),{file:u=s,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:s,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var Bce=({file:t,commandArguments:e})=>Gce(t,e),qce=({file:t,commandArguments:e})=>({...Gce(t,e),isSync:!0}),Gce=(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]=THe(t);return{file:r,commandArguments:n}},THe=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(bHe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},bHe=/ +/g;var Vce=(t,e,r)=>{t.sync=e(wHe,r),t.s=t.sync},Hce=({options:t})=>Wce(t),wHe=({options:t})=>({...Wce(t),isSync:!0}),Wce=t=>({options:{...AHe(t),...t}}),AHe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Yce={preferLocal:!0};var Kce=kc(()=>({})),LFt=kc(()=>({isSync:!0})),Zce=kc(Bce),UFt=kc(qce),FFt=kc(sse),zFt=kc(Hce,{},Yce,Vce),{sendMessage:jFt,getOneMessage:BFt,getEachMessage:qFt,getCancelSignal:GFt}=Hae();var Jce=!1,Xce,xHe=t=>{Xce??=t},Qce=t=>{Jce=!0,xHe(t)},ri=()=>Jce,Mc=()=>Xce,ele=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var Qy=null,tle=t=>(Qy&&Qy.destroy(),Qy=new po({totalAllowedTime:t}),Qy),rle=()=>Qy;var po=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&ri())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await Ax({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{q.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),o(),s&&clearTimeout(s)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var nle={name:"@netlify/agent-runner-cli",type:"module",version:"1.189.2",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",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:opencode":"vitest run test/integration/opencode.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.6","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.280","@anthropic-ai/sdk":"^0.128.0","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.1","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.153.4","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var PHe=CHe(import.meta.url),OHe=ga.dirname(PHe),NHe=IHe(import.meta.url),qp=oe("shell"),mF=new Set,ile={preferLocal:!0},Mt=(t,e,r)=>{let[n,i]=kHe(e,r),o={...ile,...i},s=Kce(t,n,o);sle(s,o),lle(s);let a=r?.idleTimeout;return a&&a>0&&cle(s,a),s},ole=(t,e)=>{let r={...ile,...e},n=Zce(t,r);return sle(n,r),lle(n),e?.idleTimeout&&e.idleTimeout>0&&cle(n,e.idleTimeout),n},kHe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},sle=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||us.env.NETLIFY_LOCAL_QUIET==="true")return;if(us.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Cy).pipe(us.stdout),t.stderr?.pipe(new Cy).pipe(us.stderr);return}t.stdout?.pipe(us.stdout),t.stderr?.pipe(us.stderr)},gF=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(us.kill(-t.pid,e),qp.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return qp.error("Error killing process:",r),!1}},ale=t=>gF(t,"SIGKILL"),cle=(t,e)=>{let r=null,n=()=>{qp.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),gF(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(qp.log(`Force killing idle process ${t.pid}`),ale(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let o=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",o),t.on("error",o)},lle=t=>{mF.add(t);let e=rle();if(e){let r=e.onTimesUp(()=>{qp.log(`Global timer expired, killing process ${t.pid}`),gF(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(qp.log(`Force killing process ${t.pid} after timeout`),ale(t))},5e3)});t.on("exit",()=>{mF.delete(t),r()}),t.on("error",()=>{mF.delete(t),r()})}};function ds(t,e){if(!us.env.NETLIFY_LOCAL_MODE)try{let i=NHe.resolve(nle.name),o=ga.dirname(i);for(;o!==ga.dirname(o);){let s=ga.dirname(o);if(ga.basename(s)==="node_modules"){let a=ga.join(s,".bin",e);if(BR.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(us.env.NODE_PATH){let i=ga.join(us.env.NODE_PATH,".bin",e);if(BR.existsSync(i))return i}let r=ga.join(t,"node_modules",".bin",e);if(BR.existsSync(r))return r;let n=ga.join(OHe,"..","node_modules",".bin",e);if(BR.existsSync(n))return n}var ule=oe("repo"),hle="runner-diffs-",VR=t=>`${hle}${t}-`,mle=async t=>{let e=ple.tmpdir(),r;try{r=await qR.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(hle)&&!n.startsWith(VR(t))).map(n=>qR.rm(GR.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},Xt=(t,e={})=>Mt("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),HR=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{ule.info("Getting runner diffs");let n=await EF(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let l=TF(o);await jHe(l,r)}ule.info("Changes after processing"),await SF(r);let s=await eS(o,r);if(await yF(s,r),i=await UHe(r),!i)return{hasChanges:!1,ignored:s};await Xt(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await qR.mkdtemp(GR.join(ple.tmpdir(),VR(t.sessionId))),c=await _F({config:t,diffDir:a,cwd:r,target:{commit:"HEAD"},ignored:s});return await $He(r),c.hasChanges&&q.distribution("diff.size",(c.diffBinary??c.diff).size,{phase:"final"}),c},_F=async({config:t,diffDir:e,cwd:r,target:n,ignored:i})=>{let o="commit"in n?n.commit:"--cached",s="indexPath"in n?{GIT_INDEX_FILE:n.indexPath}:void 0,a=async({from:p,fileName:h,binary:m})=>{let g=GR.join(e,h);await Xt([...m?["diff",p,o,"--binary"]:["diff",p,o],`--output=${g}`],{stdio:["ignore","ignore","pipe"],cwd:r,env:s});let{size:E}=await qR.stat(g);return{path:g,size:E}},c=await a({from:t.runSha,fileName:"session.patch"});if(c.size===0)return{hasChanges:!1,ignored:i};let l=await a({from:t.runSha,fileName:"session-binary.patch",binary:!0}),u,d;if(t.sha){u=await a({from:t.sha,fileName:"cumulative.patch"});let p=await a({from:t.sha,fileName:"cumulative-binary.patch",binary:!0});await fle(u,p)||(d=p)}let f={hasChanges:!0,diff:c,resultDiff:u,ignored:i};return await fle(c,l)||(f.diffBinary=l),d&&(f.resultDiffBinary=d),f},dle=async t=>{let e=MHe("sha256");for await(let r of DHe(t))e.update(r);return e.digest("hex")},fle=async(t,e)=>t.size===e.size&&await dle(t.path)===await dle(e.path),$He=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Xt(["reset","--soft","HEAD~1"],{cwd:t})},yF=async(t=[],e=process.cwd())=>{await Xt(["add",".",...t],{cwd:e})},SF=async(t=process.cwd())=>{let e=await Xt(["status","-s"],{cwd:t});return String(e.stdout??"")},gle=/.. (.+)?\.log$/,LHe=[gle],EF=async(t=process.cwd())=>{let e=await SF(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
145
|
+
if (condition) { yield value; }`)};import{Buffer as GGe}from"buffer";import{StringDecoder as VGe}from"string_decoder";var RR=(t,e,r)=>{if(r)return;if(t)return{transform:HGe.bind(void 0,new TextEncoder)};let n=new VGe(e);return{transform:WGe.bind(void 0,n),final:YGe.bind(void 0,n)}},HGe=function*(t,e){GGe.isBuffer(e)?yield fa(e):typeof e=="string"?yield t.encode(e):yield e},WGe=function*(t,e){yield dr(e)?t.write(e):e},YGe=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as bae}from"util";var NU=bae(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),CR=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=ZGe}=e[r];for await(let i of n(t))yield*CR(i,e,r+1)},wae=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*KGe(r,Number(e),t)},KGe=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*CR(n,r,e+1)},Aae=bae(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),ZGe=function*(t){yield t};var kU=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},xae=(t,e)=>[...e.flatMap(r=>[...Fu(r,t,0)]),...Wy(t)],Fu=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=XGe}=e[r];for(let i of n(t))yield*Fu(i,e,r+1)},Wy=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*JGe(r,Number(e),t)},JGe=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Fu(n,r,e+1)},XGe=function*(t){yield t};var MU=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Cae(t,s,o),l=Uu(e),u=Uu(r),d=l?NU.bind(void 0,CR,a):kU.bind(void 0,Fu),f=l||u?NU.bind(void 0,wae,a):kU.bind(void 0,Wy),p=l||u?Aae.bind(void 0,a):void 0;return{stream:new QGe({writableObjectMode:n,writableHighWaterMark:Rae(n),readableObjectMode:i,readableHighWaterMark:Rae(i),transform(m,g,S){d([m,c,0],this,S)},flush(m){f([c],this,m)},destroy:p})}},IR=(t,e,r,n)=>{let i=e.filter(({type:s})=>s==="generator"),o=n?i.reverse():i;for(let{value:s,optionName:a}of o){let c=Cae(s,r,a);t=xae(c,t)}return t},Cae=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:Eae(n,a)},RR(r,s,n),xR(r,o,n,c),{transform:t,final:e},{transform:vae(i,a)},Sae({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Iae=(t,e)=>{for(let r of eVe(t))tVe(t,r,e)},eVe=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),tVe=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${Nc[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>rVe(a,n));r.input=Ly(s)},rVe=(t,e)=>{let r=IR(t,e,"utf8",!0);return nVe(r),Ly(r)},nVe=t=>{let e=t.find(r=>typeof r!="string"&&!dr(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 aVe,appendFileSync as cVe}from"fs";var PR=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Ip(r,n)&&!ti.has(e)&&iVe(n)&&(t.some(({type:i,value:o})=>i==="native"&&oVe.has(o))||t.every(({type:i})=>Pi.has(i))),iVe=t=>t===1||t===2,oVe=new Set(["pipe","overlapped"]),Pae=async(t,e,r,n)=>{for await(let i of t)sVe(e)||Nae(i,r,n)},Oae=(t,e,r)=>{for(let n of t)Nae(n,e,r)},sVe=t=>t._readableState.pipes.length>0,Nae=(t,e,r)=>{let n=Gx(t);os({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var kae=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,l)=>lVe({result:c,fileDescriptors:t,fdNumber:l,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},lVe=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(t===null)return;let f=Mse(t,o,d),p=fa(f),{stdioItems:h,objectMode:m}=e[r],g=uVe([p],h,c,n),{serializedResult:S,finalResult:E=S}=dVe({chunks:g,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:r});fVe({serializedResult:S,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let T=a[r]?E:void 0;try{return n.error===void 0&&pVe(S,h,i),T}catch(b){return n.error=b,T}},uVe=(t,e,r,n)=>{try{return IR(t,e,r,!1)}catch(i){return n.error=i,t}},dVe=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:Ly(t)};let s=Yne(t,r);return n[o]?{serializedResult:s,finalResult:OU(s,!i[o],e)}:{serializedResult:s}},fVe=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!PR({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=OU(t,!1,s);try{Oae(a,e,n)}catch(c){r.error??=c}},pVe=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>wR.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?cVe(n,t):(r.add(o),aVe(n,t))}};var Mae=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,ma(e,r,"all")]:Array.isArray(e)?[ma(t,r,"all"),...e]:dr(t)&&dr(e)?z1([t,e]):`${t}${e}`};import{once as DU}from"events";var Dae=async(t,e)=>{let[r,n]=await hVe(t);return e.isForcefullyTerminated??=!1,[r,n]},hVe=async t=>{let[e,r]=await Promise.allSettled([DU(t,"spawn"),DU(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?$ae(t):r.value},$ae=async t=>{try{return await DU(t,"exit")}catch{return $ae(t)}},Lae=async t=>{let[e,r]=await t;if(!mVe(e,r)&&$U(e,r))throw new lo;return[e,r]},mVe=(t,e)=>t===void 0&&e===void 0,$U=(t,e)=>t!==0||e!==null;var Uae=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=gVe(t,e,r),s=o?.code==="ETIMEDOUT",a=kse(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},gVe=(t,e,r)=>t!==void 0?t:$U(e,r)?new lo:void 0;var Fae=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:l,fileDescriptors:u}=yVe(t,e,r),d=vVe({file:n,commandArguments:i,options:l,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:u,startTime:a});return Fp(d,c,l)},yVe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=Hx(t,e,r),a=SVe(r),{file:c,commandArguments:l,options:u}=fR(t,e,a);EVe(u);let d=mae(u,s);return{file:c,commandArguments:l,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},SVe=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,EVe=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&OR("ipcInput"),t&&OR("ipc: true"),r&&OR("detached: true"),n&&OR("cancelSignal")},OR=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},vVe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=TVe({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=Uae(c,r),{output:h,error:m=l}=kae({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),g=h.map((E,T)=>ma(E,r,T)),S=ma(Mae(h,r),r,"all");return wVe({error:m,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:S,options:r,command:n,escapedCommand:i,startTime:a})},TVe=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Iae(o,r);let a=bVe(r);return _Ve(...pR(t,e,a))}catch(a){return Up({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},bVe=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:ER(e)}),wVe=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:l,startTime:u})=>t===void 0?vR({command:c,escapedCommand:l,stdio:o,all:s,ipcOutput:[],options:a,startTime:u}):Hy({error:t,command:c,escapedCommand:l,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:u,isSync:!0});import{setMaxListeners as dHe}from"events";import{spawn as fHe}from"child_process";import Gae from"process";import{once as LU,on as AVe}from"events";var zae=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(Np({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:sR(t)}),xVe({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),xVe=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{rR(e,i);let o=Oc(t,e,r),s=new AbortController;try{return await Promise.race([RVe(o,n,s),CVe(o,r,s),IVe(o,r,s)])}catch(a){throw kp(t),a}finally{s.abort(),nR(e,i)}},RVe=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await LU(t,"message",{signal:r});return n}for await(let[n]of AVe(t,"message",{signal:r}))if(e(n))return n},CVe=async(t,e,{signal:r})=>{await LU(t,"disconnect",{signal:r}),xoe(e)},IVe=async(t,e,{signal:r})=>{let[n]=await LU(t,"strict:error",{signal:r});throw Qx(n,e)};import{once as Bae,on as PVe}from"events";var qae=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>UU({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),UU=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{Np({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:sR(t)}),rR(e,o);let s=Oc(t,e,r),a=new AbortController,c={};return OVe(t,s,a),NVe({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),kVe({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},OVe=async(t,e,r)=>{try{await Bae(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},NVe=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Bae(t,"strict:error",{signal:r.signal});n.error=Qx(i,e),r.abort()}catch{}},kVe=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of PVe(r,"message",{signal:o.signal}))jae(s),yield c}catch{jae(s)}finally{o.abort(),nR(e,a),n||kp(t),i&&await t}},jae=({error:t})=>{if(t)throw t};var Vae=(t,{ipc:e})=>{Object.assign(t,Wae(t,!1,e))},Hae=()=>{let t=Gae,e=!0,r=Gae.channel!==void 0;return{...Wae(t,e,r),getCancelSignal:Qoe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Wae=(t,e,r)=>({sendMessage:uR.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:zae.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:qae.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as MVe}from"child_process";import{PassThrough as DVe,Readable as $Ve,Writable as LVe,Duplex as UVe}from"stream";var Yae=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{CU(n);let a=new MVe;FVe(a,n),Object.assign(a,{readable:zVe,writable:jVe,duplex:BVe});let c=Up({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),l=qVe(c,s,i);return{subprocess:a,promise:l}},FVe=(t,e)=>{let r=Yy(),n=Yy(),i=Yy(),o=Array.from({length:e.length-3},Yy),s=Yy(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},Yy=()=>{let t=new DVe;return t.end(),t},zVe=()=>new $Ve({read(){}}),jVe=()=>new LVe({write(){}}),BVe=()=>new UVe({read(){},write(){}}),qVe=async(t,e,r)=>Fp(t,e,r);import{createReadStream as Kae,createWriteStream as Zae}from"fs";import{Buffer as GVe}from"buffer";import{Readable as Ky,Writable as VVe,Duplex as HVe}from"stream";var Xae=(t,e)=>AR(WVe,t,e,!1),Zy=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Nc[t]}.`)},Jae={fileNumber:Zy,generator:MU,asyncGenerator:MU,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:HVe.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},WVe={input:{...Jae,fileUrl:({value:t})=>({stream:Kae(t)}),filePath:({value:{file:t}})=>({stream:Kae(t)}),webStream:({value:t})=>({stream:Ky.fromWeb(t)}),iterable:({value:t})=>({stream:Ky.from(t)}),asyncIterable:({value:t})=>({stream:Ky.from(t)}),string:({value:t})=>({stream:Ky.from(t)}),uint8Array:({value:t})=>({stream:Ky.from(GVe.from(t))})},output:{...Jae,fileUrl:({value:t})=>({stream:Zae(t)}),filePath:({value:{file:t,append:e}})=>({stream:Zae(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:VVe.fromWeb(t)}),iterable:Zy,asyncIterable:Zy,string:Zy,uint8Array:Zy}};import{on as YVe,once as Qae}from"events";import{PassThrough as KVe,getDefaultHighWaterMark as ZVe}from"stream";import{finished as rce}from"stream/promises";function zu(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)zU(i);let e=t.some(({readableObjectMode:i})=>i),r=JVe(t,e),n=new FU({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var JVe=(t,e)=>{if(t.length===0)return ZVe(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},FU=class extends KVe{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(zU(e),this.#e.has(e))return;this.#e.add(e),this.#n??=XVe(this,this.#e,this.#o);let r=t4e({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#o});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(zU(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},XVe=async(t,e,r)=>{NR(t,ece);let n=new AbortController;try{await Promise.race([QVe(t,n),e4e(t,e,r,n)])}finally{n.abort(),NR(t,-ece)}},QVe=async(t,{signal:e})=>{try{await rce(t,{signal:e,cleanup:!0})}catch(r){throw nce(t,r),r}},e4e=async(t,e,r,{signal:n})=>{for await(let[i]of YVe(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},zU=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},t4e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{NR(t,tce);let a=new AbortController;try{await Promise.race([r4e(o,e,a),n4e({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),i4e({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),NR(t,-tce)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?jU(t):o4e(t))},r4e=async(t,e,{signal:r})=>{try{await t,r.aborted||jU(e)}catch(n){r.aborted||nce(e,n)}},n4e=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await rce(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;ice(s)?i.add(e):oce(t,s)}},i4e=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await Qae(t,i,{signal:o}),!t.readable)return Qae(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},o4e=t=>{t.writable&&t.end()},nce=(t,e)=>{ice(e)?jU(t):oce(t,e)},ice=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",jU=t=>{(t.readable||t.writable)&&t.destroy()},oce=(t,e)=>{t.destroyed||(t.once("error",s4e),t.destroy(e))},s4e=()=>{},NR=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},ece=2,tce=1;import{finished as sce}from"stream/promises";var jp=(t,e)=>{t.pipe(e),a4e(t,e),c4e(t,e)},a4e=async(t,e)=>{if(!(co(t)||co(e))){try{await sce(t,{cleanup:!0,readable:!0,writable:!1})}catch{}BU(e)}},BU=t=>{t.writable&&t.end()},c4e=async(t,e)=>{if(!(co(t)||co(e))){try{await sce(e,{cleanup:!0,readable:!1,writable:!0})}catch{}qU(t)}},qU=t=>{t.readable&&t.destroy()};var ace=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:o,direction:s}]of Object.entries(e)){for(let{stream:a}of o.filter(({type:c})=>Pi.has(c)))l4e(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Pi.has(c)))d4e({subprocess:t,stream:a,direction:s,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,o]of n.entries()){let s=o.length===1?o[0]:zu(o);jp(s,i)}},l4e=(t,e,r,n)=>{r==="output"?jp(t.stdio[n],e):jp(e,t.stdio[n]);let i=u4e[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},u4e=["stdin","stdout","stderr"],d4e=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;f4e(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},f4e=(t,{signal:e})=>{co(t)&&$u(t,p4e,e)},p4e=2;import{addAbortListener as g4e}from"events";var ju=[];ju.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&ju.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&ju.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var kR=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",GU=Symbol.for("signal-exit emitter"),VU=globalThis,h4e=Object.defineProperty.bind(Object),HU=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(VU[GU])return VU[GU];h4e(VU,GU,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let o of this.listeners[e])i=o(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},MR=class{},m4e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),WU=class extends MR{onExit(){return()=>{}}load(){}unload(){}},YU=class extends MR{#e=KU.platform==="win32"?"SIGINT":"SIGHUP";#r=new HU;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of ju)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,o=e;if(typeof o.__signal_exit_emitter__=="object"&&typeof o.__signal_exit_emitter__.count=="number"&&(i+=o.__signal_exit_emitter__.count),n.length===i){this.unload();let s=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;s||e.kill(e.pid,a)}};this.#o=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!kR(this.#t))return()=>{};this.#s===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#r.on(n,e),()=>{this.#r.removeListener(n,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#s){this.#s=!0,this.#r.count+=1;for(let e of ju)try{let r=this.#i[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#s&&(this.#s=!1,ju.forEach(e=>{let r=this.#i[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#o,this.#r.count-=1)}#a(e){return kR(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#o.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&kR(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let i=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),i}else return n.call(this.#t,e,...r)}},KU=globalThis.process,{onExit:cce,load:WLt,unload:YLt}=m4e(kR(KU)?new YU(KU):new WU);var lce=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=cce(()=>{t.kill()});g4e(n,()=>{i()})};var dce=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=Vx(),{destination:s,destinationStream:a,destinationError:c,from:l,unpipeSignal:u}=_4e(r,n,i),{sourceStream:d,sourceError:f}=S4e(t,l),{options:p,fileDescriptors:h}=as.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:h,startTime:o}},_4e=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=y4e(t,e,...r),a=tR(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},y4e=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(uce,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||U1(r)){if(Object.keys(t).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[i,o,s]=Dx(r,...n);return{destination:e(uce)(i,o,s),pipeOptions:s}}if(as.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}`)},uce=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),S4e=(t,e)=>{try{return{sourceStream:Mp(t,e)}}catch(r){return{sourceError:r}}};var pce=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=E4e({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw ZU({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},E4e=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return qU(t),n;if(e!==void 0)return BU(r),e},ZU=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Up({error:t,command:fce,escapedCommand:fce,fileDescriptors:e,options:r,startTime:n,isSync:!1}),fce="source.pipe(destination)";var hce=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:o,value:s=o}]=await t;if(s.pipedFrom.includes(n)||s.pipedFrom.push(n),i==="rejected")throw s;if(e==="rejected")throw n;return s};import{finished as v4e}from"stream/promises";var mce=(t,e,r)=>{let n=DR.has(e)?b4e(t,e):T4e(t,e);return $u(t,A4e,r.signal),$u(e,x4e,r.signal),w4e(e),n},T4e=(t,e)=>{let r=zu([t]);return jp(r,e),DR.set(e,r),r},b4e=(t,e)=>{let r=DR.get(e);return r.add(t),r},w4e=async t=>{try{await v4e(t,{cleanup:!0,readable:!1,writable:!0})}catch{}DR.delete(t)},DR=new WeakMap,A4e=2,x4e=1;import{aborted as R4e}from"util";var gce=(t,e)=>t===void 0?[]:[C4e(t,e)],C4e=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await R4e(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw ZU({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var $R=(t,...e)=>{if(Jt(e[0]))return $R.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=dce(t,...e),i=I4e({...n,destination:r});return i.pipe=$R.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},I4e=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:l})=>{let u=P4e(t,i);pce({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:l});let d=new AbortController;try{let f=mce(e,o,d);return await Promise.race([hce(u),...gce(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:l})])}finally{d.abort()}},P4e=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as L4e}from"timers/promises";import{on as O4e}from"events";import{getDefaultHighWaterMark as N4e}from"stream";var LR=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return k4e(e,s),yce({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},k4e=async(t,e)=>{try{await t}catch{}finally{e.abort()}},JU=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;M4e(e,s,t);let a=t.readableObjectMode&&!o;return yce({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},M4e=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},yce=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=O4e(t,"data",{signal:e.signal,highWaterMark:_ce,highWatermark:_ce});return D4e({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},XU=N4e(!0),_ce=XU,D4e=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=$4e({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Fu(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Wy(a)}},$4e=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[RR(t,r,!e),xR(t,i,!n,{})].filter(Boolean);var Sce=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=U4e({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([F4e(t),d]);return}let f=IU(c,r),p=JU({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([z4e({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},U4e=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!PR({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=JU({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Pae(a,t,r,o)},F4e=async t=>{await L4e(),t.readableFlowing===null&&t.resume()},z4e=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await _R(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await yR(r,{maxBuffer:o})):await Lp(r,{maxBuffer:o})}catch(a){return Ece(Pse({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},QU=async t=>{try{return await t}catch(e){return Ece(e)}},Ece=({bufferedData:t})=>Hne(t)?new Uint8Array(t):t;import{finished as j4e}from"stream/promises";var Jy=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=B4e(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],j4e(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||V4e(a,e,r,n)}finally{s.abort()}},B4e=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&q4e(t,r,n),n},q4e=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{G4e(e,r),n.call(t,...i)}},G4e=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},V4e=(t,e,r,n)=>{if(!H4e(t,e,r,n))throw t},H4e=(t,e,r,n=!0)=>r.propagating?vce(t)||UR(t):(r.propagating=!0,eF(r,e)===n?vce(t):UR(t)),eF=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",UR=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",vce=t=>t?.code==="EPIPE";var Tce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,l)=>tF({stream:c,fdNumber:l,encoding:e,buffer:r[l],maxBuffer:n[l],lines:i[l],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),tF=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l})=>{if(!t)return;let u=Jy(t,e,l);if(eF(l,e)){await u;return}let[d]=await Promise.all([Sce({stream:t,onStreamEnd:u,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:l}),u]);return d};var bce=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?zu([t,e].filter(Boolean)):void 0,wce=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>tF({...W4e(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:Y4e(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),W4e=({stdout:t,stderr:e,all:r},[,n,i])=>{let o=n||i;return o?n?i?{stream:r,buffer:o}:{stream:t,buffer:o}:{stream:e,buffer:o}:{stream:r,buffer:o}},Y4e=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as K4e}from"events";var Ace=t=>Ip(t,"ipc"),xce=(t,e)=>{let r=Gx(t);os({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var Rce=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=Ace(o),a=pa(e,"ipc"),c=pa(r,"ipc");for await(let l of UU({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(Ose(t,i,c),i.push(l)),s&&xce(l,o);return i},Cce=async(t,e)=>(await Promise.allSettled([t]),e);var Ice=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:g,controller:S})=>{let E=Dae(t,f),T={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:E,propagating:!1},b=Tce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),w=wce({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:T}),x=[],P=Rce({subprocess:t,buffer:r,maxBuffer:n,ipc:u,ipcOutput:x,verboseInfo:p}),I=Z4e(m,t,T),N=J4e(h,T);try{return await Promise.race([Promise.all([{},Lae(E),Promise.all(b),w,P,lse(t,d),...I,...N]),g,X4e(t,S),...ise(t,o,f,S),...Aoe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:S}),...rse({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:S})])}catch(L){return f.terminationReason??="other",Promise.all([{error:L},E,Promise.all(b.map(v=>QU(v))),QU(w),Cce(P,x),Promise.allSettled(I),Promise.allSettled(N)])}},Z4e=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:Jy(n,i,r)),J4e=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>fo(o,{checkOpen:!1})&&!co(o)).map(({type:i,value:o,stream:s=o})=>Jy(s,n,e,{isSameDirection:Pi.has(i),stopOnExit:i==="native"}))),X4e=async(t,{signal:e})=>{let[r]=await K4e(t,"error",{signal:e});throw r};var Pce=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),Xy=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=ss();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Bp=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 Q4e}from"stream";import{callbackify as eHe}from"util";import{finished as Oce}from"stream/promises";var rF=async t=>{if(t!==void 0)try{await nF(t)}catch{}},Nce=async t=>{if(t!==void 0)try{await iF(t)}catch{}},nF=async t=>{await Oce(t,{cleanup:!0,readable:!1,writable:!0})},iF=async t=>{await Oce(t,{cleanup:!0,readable:!0,writable:!1})},FR=async(t,e)=>{if(await t,e)throw e},zR=(t,e,r)=>{r&&!UR(r)?t.destroy(r):e&&t.destroy()};var kce=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||ti.has(r),{subprocessStdout:a,waitReadableDestroy:c}=oF(t,n,e),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=sF(a,s),{read:f,onStdoutDataDone:p}=aF({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new Q4e({read:f,destroy:eHe(lF.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return cF({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},oF=(t,e,r)=>{let n=Mp(t,e),i=Xy(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},sF=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:XU},aF=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=ss(),s=LR({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){tHe(this,s,o)},onStdoutDataDone:o}},tHe=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},cF=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await iF(t),await n,await rF(i),await e,r.readable&&r.push(null)}catch(o){await rF(i),Mce(r,o)}},lF=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Bp(r,e)&&(Mce(t,n),await FR(e,n))},Mce=(t,e)=>{zR(t,t.readable,e)};import{Writable as rHe}from"stream";import{callbackify as Dce}from"util";var $ce=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=uF(t,r,e),s=new rHe({...dF(n,t,i),destroy:Dce(pF.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return fF(n,s),s},uF=(t,e,r)=>{let n=tR(t,e),i=Xy(r,n,"writableFinal"),o=Xy(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},dF=(t,e,r)=>({write:nHe.bind(void 0,t),final:Dce(iHe.bind(void 0,t,e,r))}),nHe=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},iHe=async(t,e,r)=>{await Bp(r,e)&&(t.writable&&t.end(),await e)},fF=async(t,e,r)=>{try{await nF(t),e.writable&&e.end()}catch(n){await Nce(r),Lce(e,n)}},pF=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Bp(r,e),await Bp(n,e)&&(Lce(t,i),await FR(e,i))},Lce=(t,e)=>{zR(t,t.writable,e)};import{Duplex as oHe}from"stream";import{callbackify as sHe}from"util";var Uce=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||ti.has(r),{subprocessStdout:c,waitReadableDestroy:l}=oF(t,n,e),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=uF(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=sF(c,a),{read:g,onStdoutDataDone:S}=aF({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),E=new oHe({read:g,...dF(u,t,d),destroy:sHe(aHe.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:t,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:h,writableObjectMode:u.writableObjectMode,encoding:p});return cF({subprocessStdout:c,onStdoutDataDone:S,readable:E,subprocess:t,subprocessStdin:u}),fF(u,E,c),E},aHe=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([lF({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),pF({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var hF=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||ti.has(e),s=Mp(t,r),a=LR({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return cHe(a,s,t)},cHe=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var Fce=(t,{encoding:e})=>{let r=Pce();t.readable=kce.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=$ce.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=Uce.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=hF.bind(void 0,t,e),t[Symbol.asyncIterator]=hF.bind(void 0,t,e,{})};var zce=(t,e)=>{for(let[r,n]of uHe){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},lHe=(async()=>{})().constructor.prototype,uHe=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(lHe,t)]);var jce=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=pHe(t,e,r),{subprocess:f,promise:p}=mHe({file:i,commandArguments:o,options:u,startTime:c,verboseInfo:l,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=$R.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),zce(f,p),as.set(f,{options:u,fileDescriptors:d}),f},pHe=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=Hx(t,e,r),{file:a,commandArguments:c,options:l}=fR(t,e,r),u=hHe(l),d=Xae(u,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:u,fileDescriptors:d}},hHe=({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}},mHe=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=fHe(...pR(t,e,r))}catch(h){return Yae({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let l=new AbortController;dHe(Number.POSITIVE_INFINITY,l.signal);let u=[...c.stdio];ace(c,a,l),lce(c,r,l);let d={},f=ss();c.kill=boe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:l}),c.all=bce(c,r),Fce(c,r),Vae(c,r);let p=gHe({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:u,command:o,escapedCommand:s,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},gHe=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],h,m,g]=await Ice({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:l,controller:u});u.abort(),l.resolve();let S=h.map((b,w)=>ma(b,e,w)),E=ma(m,e,"all"),T=_He({errorInfo:d,exitCode:f,signal:p,stdio:S,all:E,ipcOutput:g,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Fp(T,n,e)},_He=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:l,startTime:u})=>"error"in t?Hy({error:t.error,command:c,escapedCommand:l,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof cs,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:u,isSync:!1}):vR({command:c,escapedCommand:l,stdio:n,all:i,ipcOutput:o,options:a,startTime:u});var jR=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,yHe(n,t[n],i)]));return{...t,...r}},yHe=(t,e,r)=>SHe.has(t)&&Jt(e)&&Jt(r)?{...e,...r}:r,SHe=new Set(["env",...G1]);var kc=(t,e,r,n)=>{let i=(s,a,c)=>kc(s,a,r,c),o=(...s)=>EHe({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},EHe=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Jt(o))return i(t,jR(r,o),n);let{file:a,commandArguments:c,options:l,isSync:u}=vHe({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return u?Fae(a,c,l):jce(a,c,l,i)},vHe=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=Xne(e)?Qne(e,r):[e,...r],[s,a,c]=Dx(...o),l=jR(jR(n,i),c),{file:u=s,commandArguments:d=a,options:f=l,isSync:p=!1}=t({file:s,commandArguments:a,options:l});return{file:u,commandArguments:d,options:f,isSync:p}};var Bce=({file:t,commandArguments:e})=>Gce(t,e),qce=({file:t,commandArguments:e})=>({...Gce(t,e),isSync:!0}),Gce=(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]=THe(t);return{file:r,commandArguments:n}},THe=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(bHe)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},bHe=/ +/g;var Vce=(t,e,r)=>{t.sync=e(wHe,r),t.s=t.sync},Hce=({options:t})=>Wce(t),wHe=({options:t})=>({...Wce(t),isSync:!0}),Wce=t=>({options:{...AHe(t),...t}}),AHe=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},Yce={preferLocal:!0};var Kce=kc(()=>({})),LFt=kc(()=>({isSync:!0})),Zce=kc(Bce),UFt=kc(qce),FFt=kc(sse),zFt=kc(Hce,{},Yce,Vce),{sendMessage:jFt,getOneMessage:BFt,getEachMessage:qFt,getCancelSignal:GFt}=Hae();var Jce=!1,Xce,xHe=t=>{Xce??=t},Qce=t=>{Jce=!0,xHe(t)},ri=()=>Jce,Mc=()=>Xce,ele=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var Qy=null,tle=t=>(Qy&&Qy.destroy(),Qy=new po({totalAllowedTime:t}),Qy),rle=()=>Qy;var po=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&ri())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((u,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),l="success";try{return await Ax({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(u){throw l="failure",u}finally{q.timing("stage.duration",Date.now()-c,{stage:e,outcome:l}),o(),s&&clearTimeout(s)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var nle={name:"@netlify/agent-runner-cli",type:"module",version:"1.189.3",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",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:opencode":"vitest run test/integration/opencode.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.6","@netlify/eslint-config-node":"^7.0.1","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.280","@anthropic-ai/sdk":"^0.128.0","@google/gemini-cli":"0.42.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.1","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.153.4","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0",execa:"^9.6.1",fastify:"5.12.5",minimist:"^1.2.8",openai:"6.34.0",zod:"^4.4.3"}};var PHe=CHe(import.meta.url),OHe=ga.dirname(PHe),NHe=IHe(import.meta.url),qp=oe("shell"),mF=new Set,ile={preferLocal:!0},Mt=(t,e,r)=>{let[n,i]=kHe(e,r),o={...ile,...i},s=Kce(t,n,o);sle(s,o),lle(s);let a=r?.idleTimeout;return a&&a>0&&cle(s,a),s},ole=(t,e)=>{let r={...ile,...e},n=Zce(t,r);return sle(n,r),lle(n),e?.idleTimeout&&e.idleTimeout>0&&cle(n,e.idleTimeout),n},kHe=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},sle=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||us.env.NETLIFY_LOCAL_QUIET==="true")return;if(us.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Cy).pipe(us.stdout),t.stderr?.pipe(new Cy).pipe(us.stderr);return}t.stdout?.pipe(us.stdout),t.stderr?.pipe(us.stderr)},gF=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(us.kill(-t.pid,e),qp.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return qp.error("Error killing process:",r),!1}},ale=t=>gF(t,"SIGKILL"),cle=(t,e)=>{let r=null,n=()=>{qp.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),gF(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(qp.log(`Force killing idle process ${t.pid}`),ale(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let o=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",o),t.on("error",o)},lle=t=>{mF.add(t);let e=rle();if(e){let r=e.onTimesUp(()=>{qp.log(`Global timer expired, killing process ${t.pid}`),gF(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(qp.log(`Force killing process ${t.pid} after timeout`),ale(t))},5e3)});t.on("exit",()=>{mF.delete(t),r()}),t.on("error",()=>{mF.delete(t),r()})}};function ds(t,e){if(!us.env.NETLIFY_LOCAL_MODE)try{let i=NHe.resolve(nle.name),o=ga.dirname(i);for(;o!==ga.dirname(o);){let s=ga.dirname(o);if(ga.basename(s)==="node_modules"){let a=ga.join(s,".bin",e);if(BR.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(us.env.NODE_PATH){let i=ga.join(us.env.NODE_PATH,".bin",e);if(BR.existsSync(i))return i}let r=ga.join(t,"node_modules",".bin",e);if(BR.existsSync(r))return r;let n=ga.join(OHe,"..","node_modules",".bin",e);if(BR.existsSync(n))return n}var ule=oe("repo"),hle="runner-diffs-",VR=t=>`${hle}${t}-`,mle=async t=>{let e=ple.tmpdir(),r;try{r=await qR.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(hle)&&!n.startsWith(VR(t))).map(n=>qR.rm(GR.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},Xt=(t,e={})=>Mt("git",t,{...e,env:{...e.env,NETLIFY_INTERNAL_GIT:"1"}}),HR=async({config:t,isRetry:e,cwd:r=process.cwd()})=>{ule.info("Getting runner diffs");let n=await EF(r),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!e){let l=TF(o);await jHe(l,r)}ule.info("Changes after processing"),await SF(r);let s=await eS(o,r);if(await yF(s,r),i=await UHe(r),!i)return{hasChanges:!1,ignored:s};await Xt(["commit","-m","Agent runner [skip ci]"],{cwd:r});let a=await qR.mkdtemp(GR.join(ple.tmpdir(),VR(t.sessionId))),c=await _F({config:t,diffDir:a,cwd:r,target:{commit:"HEAD"},ignored:s});return await $He(r),c.hasChanges&&q.distribution("diff.size",(c.diffBinary??c.diff).size,{phase:"final"}),c},_F=async({config:t,diffDir:e,cwd:r,target:n,ignored:i})=>{let o="commit"in n?n.commit:"--cached",s="indexPath"in n?{GIT_INDEX_FILE:n.indexPath}:void 0,a=async({from:p,fileName:h,binary:m})=>{let g=GR.join(e,h);await Xt([...m?["diff",p,o,"--binary"]:["diff",p,o],`--output=${g}`],{stdio:["ignore","ignore","pipe"],cwd:r,env:s});let{size:E}=await qR.stat(g);return{path:g,size:E}},c=await a({from:t.runSha,fileName:"session.patch"});if(c.size===0)return{hasChanges:!1,ignored:i};let l=await a({from:t.runSha,fileName:"session-binary.patch",binary:!0}),u,d;if(t.sha){u=await a({from:t.sha,fileName:"cumulative.patch"});let p=await a({from:t.sha,fileName:"cumulative-binary.patch",binary:!0});await fle(u,p)||(d=p)}let f={hasChanges:!0,diff:c,resultDiff:u,ignored:i};return await fle(c,l)||(f.diffBinary=l),d&&(f.resultDiffBinary=d),f},dle=async t=>{let e=MHe("sha256");for await(let r of DHe(t))e.update(r);return e.digest("hex")},fle=async(t,e)=>t.size===e.size&&await dle(t.path)===await dle(e.path),$He=async(t=process.cwd())=>{process.env.NETLIFY_LOCAL_MODE&&await Xt(["reset","--soft","HEAD~1"],{cwd:t})},yF=async(t=[],e=process.cwd())=>{await Xt(["add",".",...t],{cwd:e})},SF=async(t=process.cwd())=>{let e=await Xt(["status","-s"],{cwd:t});return String(e.stdout??"")},gle=/.. (.+)?\.log$/,LHe=[gle],EF=async(t=process.cwd())=>{let e=await SF(t);return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
146
146
|
`).filter(i=>LHe.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}},UHe=async(t=process.cwd())=>{try{return await Xt(["diff","--staged","--quiet"],{cwd:t}),!1}catch{return!0}},vF=async(t=process.cwd())=>{let{stdout:e}=await Xt(["rev-parse","HEAD"],{cwd:t});return String(e??"").trim()},FHe=1,zHe=async t=>{try{return await Xt(["rev-parse","--verify","--quiet","HEAD"],{cwd:t}),!0}catch(e){if(e.exitCode===FHe)return!1;throw e}},_le=async(t=process.cwd())=>{if(!await zHe(t))return!0;let{stdout:e}=await Xt(["ls-tree","--name-only","HEAD"],{cwd:t});return String(e??"").trim().length===0},yle=async(t=process.cwd())=>{let{stdout:e}=await Xt(["rev-list","--max-parents=0","HEAD"],{cwd:t});return String(e??"").trim()},eS=async(t,e=process.cwd())=>{t||=await SF(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(`
|
|
147
147
|
`).forEach(i=>{r.forEach(s=>{let a=i===`?? ${s}`,c=i.startsWith(`?? ${s}/`)||i.startsWith(`?? ${s}${GR.sep}`);(a||c)&&n.push(`:!${s}`)});let o=i.match(gle)?.[1];o&&n.push(`:!${o}.log`)}),n},Sle=async(t=process.cwd())=>{await Xt(["reset","--hard","HEAD"],{cwd:t})},Ele=async(t=process.cwd())=>{let e=await Xt(["clean","-fd","-e",".netlify"],{stdio:["ignore","pipe","pipe"],cwd:t});return String(e.stdout??"").split(`
|
|
148
148
|
`).filter(r=>r.startsWith("Removing ")).map(r=>r.slice(9))},TF=t=>{let e=t.split(`
|
|
@@ -344,7 +344,7 @@ NETLIFY_BUILD_BASE="\${NETLIFY_BUILD_BASE:-${$Qe}}" ${e} ${r} <template-id> [--p
|
|
|
344
344
|
Replace \`<template-id>\` with the matching template \`id\`. Include \`--package-manager\` only if the user specified one. The templates can include relevant agent skills. The \`NETLIFY_BUILD_BASE=\u2026\` prefix lets the scaffold use a local template mirror if the platform set one \u2014 leave it as-is. Follow the instructions printed by the scaffold command.`:"",a="You are creating a new Netlify project to fulfill the user's request. The project directory is currently empty.",c=[a,s,MQe];return n?c=[a,DQe,s]:i&&(c=[a,NQe,s]),c.filter(Boolean).join(`
|
|
345
345
|
|
|
346
346
|
`)},zQe=t=>{try{return JSON.parse(TQe(jE.join(t,".netlify","scaffold-result.json"),"utf8"))}catch{return}},Uge=async t=>{let e=zQe(t);await Ct(ot(),"create-scaffold-telemetry",r=>{r?.setAttributes({"create.template":e?.template??"none","create.packageManager":e?.packageManager??"none"})})},Fge=async({config:t,cwd:e=FI.cwd()})=>await Ct(ot(),"create-stage",async r=>{let n=performance.now();r?.setAttributes({"create.runner":t.runner,"create.id":t.id,"create.sessionId":t.sessionId}),await Dge(e,[".netlify",".git","node_modules"]),_d.info("Cleaned cwd folder");let{nodeCmd:i,tsCliPath:o}=LQe({cwd:e}),s=[];if(o){let f=[o,"--list-addons-json"];_d.log(`Running ${i} ${f.join(" ")}`);let{stdout:p}=await Mt(i,f);s=UQe(p),_d.info("Retrieved add-ons")}else _d.warn("ts-cli binary not resolved; create-mode prompt will omit template section"),q.inc("context.degraded",1,{component:"templates"});let a=f4(t),c=a==="budget_constrained",l=a==="ask_first";l&&_d.log("Low budget create run - Instructing the agent to ask for clarity if necessary",{accountType:t.accountType,sessionCreditLimit:t.sessionCreditLimit}),q.inc("create.low_budget_limit_ask",1,{ask_first:l}),c&&_d.log("Budget-constrained create run \u2014 using plan + first-milestone instructions",{accountType:t.accountType,sessionCreditLimit:t.sessionCreditLimit}),q.inc("create.budget_constrained",1,{constrained:c});let u=FQe({templates:s,nodeCmd:i,scaffoldScriptPath:wQe,budgetConstrained:c,askUserClarity:l}),d=performance.now()-n;return r?.setAttributes({"create.duration.ms":d,"create.status":"success","create.budget_constrained":c,"create.ask_user_clarity":l}),{additionalContext:u}});var Pa={Task:{name:"Task",category:G.Task},Agent:{name:"Task",category:G.Task},SendMessage:{name:"Message agent",category:G.Task},TaskOutput:{name:"Get task output",category:G.Task},TaskStop:{name:"Stop task",category:G.Task},TaskCreate:{name:"Update task list",category:G.Todo},TaskUpdate:{name:"Update task list",category:G.Todo},TaskList:{name:"Read task list",category:G.Todo},TaskGet:{name:"Read task list",category:G.Todo},ToolSearch:{name:"Load tools",category:G.Explore},Skill:{name:"Use skill",category:G.Skill},EnterPlanMode:{name:"Start planning",category:G.Plan},ListMcpResources:{name:"List resources",category:G.Explore},ReadMcpResource:{name:"Read resource",category:G.Explore},Bash:{name:"Run command",category:G.RunCommand},Glob:{name:"Find files",category:G.Explore},Grep:{name:"Search files",category:G.Explore},LS:{name:"List directory",category:G.Explore},ExitPlanMode:{name:"Exit planning",category:G.Plan},Read:{name:"Read file",category:G.FileRead},Edit:{name:"Edit file",category:G.FileWrite},MultiEdit:{name:"Edit multiple files",category:G.FileWrite},Write:{name:"Edit file",category:G.FileWrite},NotebookEdit:{name:"Edit notebook",category:G.Notebook},WebFetch:{name:"Fetch web",category:G.Web},TodoWrite:{name:"Update task list",category:G.Todo},WebSearch:{name:"Search web",category:G.Web},BashOutput:{name:"Get command output",category:G.RunCommand},KillBash:{name:"Stop command",category:G.RunCommand}},BE=t=>{if(Pa[t])return Pa[t].name;let e=t.match(/^mcp__(.+?)__(.+)$/);return e?`${e[2].replace(/_/g," ")} (${e[1]})`:t},g4=t=>t==="Task"||t==="Agent",zge=t=>{let[e=""]=t.split(`
|
|
347
|
-
`,1);return/^(Async agent launched successfully|Agent launched in background)/.test(e)||/\(internal ID:?\s*[\w./-]+\)/i.test(e)},jge=new Set(["SendMessage","ToolSearch","TaskList","TaskGet","EnterPlanMode","TaskStop"]);var Hr=oe("runner_claude"),zI="Claude Code",qE="claude-opus-5-5",_4="claude-sonnet-5";async function BQe({aiGateway:t,config:e,model:r}){let n=r;if(t)if(e.modelVersionOverrides?.claude){let i=e.modelVersionOverrides?.claude?.[e.accountType];if(i){if(!await t.isModelAvailableForProvider("anthropic",i))throw new Error(`Model override '${i}' is not available for anthropic provider`);n=i}}else r?await t.isModelAvailableForProvider("anthropic",r)||(Hr.log(`Model '${r}' is not available for anthropic provider, proceeding without model specification`),q.inc("model.unavailable",1,{provider:"anthropic"}),n=void 0):await t.isModelAvailableForProvider("anthropic",qE)?(Hr.log(`Using default model: ${qE}`),n=qE):Hr.log(`Model ${qE} is not available, proceeding without model specification`);return n}function qQe({aiGateway:t}){if(t){let{token:e,url:r}=t;if(!e||!r)throw new Error("No token or url provided from AI Gateway");return{...em.env,ANTHROPIC_API_KEY:e,ANTHROPIC_BASE_URL:r}}if(!em.env.ANTHROPIC_API_KEY)throw new Error("ANTHROPIC_API_KEY is not provided");return{...em.env}}async function GQe(){let t=GE.join(em.cwd(),"AGENTS.md");try{await Qh.access(t)}catch{return}let e=GE.join(em.cwd(),"CLAUDE.local.md"),r="@AGENTS.md";try{if((await Qh.readFile(e,"utf-8")).includes(r))return;await Qh.appendFile(e,`
|
|
347
|
+
`,1);return/^(Async agent launched successfully|Agent launched in background)/.test(e)||/\(internal ID:?\s*[\w./-]+\)/i.test(e)},jge=new Set(["SendMessage","ToolSearch","TaskList","TaskGet","EnterPlanMode","TaskStop"]);var Hr=oe("runner_claude"),zI="Claude Code",qE="claude-opus-5-5",_4="claude-sonnet-5-5";async function BQe({aiGateway:t,config:e,model:r}){let n=r;if(t)if(e.modelVersionOverrides?.claude){let i=e.modelVersionOverrides?.claude?.[e.accountType];if(i){if(!await t.isModelAvailableForProvider("anthropic",i))throw new Error(`Model override '${i}' is not available for anthropic provider`);n=i}}else r?await t.isModelAvailableForProvider("anthropic",r)||(Hr.log(`Model '${r}' is not available for anthropic provider, proceeding without model specification`),q.inc("model.unavailable",1,{provider:"anthropic"}),n=void 0):await t.isModelAvailableForProvider("anthropic",qE)?(Hr.log(`Using default model: ${qE}`),n=qE):Hr.log(`Model ${qE} is not available, proceeding without model specification`);return n}function qQe({aiGateway:t}){if(t){let{token:e,url:r}=t;if(!e||!r)throw new Error("No token or url provided from AI Gateway");return{...em.env,ANTHROPIC_API_KEY:e,ANTHROPIC_BASE_URL:r}}if(!em.env.ANTHROPIC_API_KEY)throw new Error("ANTHROPIC_API_KEY is not provided");return{...em.env}}async function GQe(){let t=GE.join(em.cwd(),"AGENTS.md");try{await Qh.access(t)}catch{return}let e=GE.join(em.cwd(),"CLAUDE.local.md"),r="@AGENTS.md";try{if((await Qh.readFile(e,"utf-8")).includes(r))return;await Qh.appendFile(e,`
|
|
348
348
|
${r}
|
|
349
349
|
`)}catch{await Qh.writeFile(e,`${r}
|
|
350
350
|
`)}Hr.log("Added @AGENTS.md import to CLAUDE.local.md")}async function y4({config:t,persistSteps:e,aiGateway:r,continueSession:n,priorAgentSessionId:i,cwd:o=em.cwd(),cliPath:s="netlify",abortSignal:a,onSessionId:c,forceLowEffortForCreditWrapUp:l}){let u=t,{prompt:d}=u,{model:f}=t,p="";await GQe();let h=qQe({aiGateway:r}),m=await BQe({config:t,aiGateway:r,model:f});l&&m?.includes("fable")&&(!r||await r.isModelAvailableForProvider("anthropic",_4))&&(Hr.log(`Credit wrap-up: downgrading model ${m} to ${_4}`),m=_4);let g=[],S=[],E={},T=new Set,b=[],w=J=>J?.match(/task\s+#([\w-]+)\s+created/i)?.[1],x=J=>{if(typeof J=="string")return J;if(Array.isArray(J))return J.filter(Oe=>Oe?.type==="text"&&typeof Oe.text=="string").map(Oe=>Oe.text).join(`
|