@netlify/agent-runner-cli 2.12.0-nb8c571bb6e224.0 → 2.12.0-nbf5699a060950.0
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 -3
- package/dist/bin.js +2 -3
- package/dist/index.js +129 -130
- package/package.json +1 -1
package/dist/bin-local.js
CHANGED
|
@@ -216,8 +216,7 @@ ${E}`,d++;break;case"id":u=E.includes("\0")?void 0:E;break;case"retry":/^\d+$/.t
|
|
|
216
216
|
- Read files efficiently. Use glob first to find the right paths before reading
|
|
217
217
|
- Prefer editing over writing entire files when possible
|
|
218
218
|
- Do NOT run any build commands (e.g. \`netlify build\`, \`netlify functions:build\`, \`npm run build\`, \`yarn build\`, \`pnpm build\`). The system validates builds automatically after your changes. Running these commands can produce build artifacts that pollute the repository.
|
|
219
|
-
-
|
|
220
|
-
- You have access to Netlify specific skills in ${t}. Before implementing a feature, read the relevant skill's SKILL.md for instructions. Some skills have activation scripts (e.g. \`node scripts/enable.cjs\`) that you MUST run after implementing the feature. Currently, Netlify Forms and Netlify Identity have activation scripts. Skipping this step will cause the feature to not be enabled on deploy.
|
|
219
|
+
- Do not use Netlify Functions, Forms, Database, Blobs, redirects or headers rules; use third-party services or client-side code.
|
|
221
220
|
${Awe(t)}
|
|
222
221
|
</rules>`,ND=({skillsDir:t,mode:e,runner:r})=>e==="ask"?Mut(t):Rwe(t,r),xwe=({cliPath:t,branch:e})=>["## Netlify Database (read-only)","",`This project has a Netlify Database (managed Postgres). You are connected to the \`${e}\` branch with a`,"read-only role, so you can answer questions about the schema and the data in it.","","Query it by running:","","```",`${t} db connect --query "SELECT count(*) FROM users"`,"```","",`Add \`--json\` for machine-readable output. Always pass \`--query\`: \`${t} db connect\` on its own opens an`,"interactive session that never returns.","","Rules for this run:","","- The connection is read-only. INSERT, UPDATE, DELETE, and DDL are refused by the database.","- Do NOT generate or run migrations, and do NOT run `drizzle-kit`. This run cannot change the schema.","- The branch is a fork of production taken when the branch was created, so data may lag production."," Say which branch you read when the answer depends on the data.","- Prefer schema queries (`information_schema`) and aggregates over selecting rows. When you do read rows,"," use a LIMIT and leave out columns holding personal data or secrets \u2014 query output is shown to the user"," and stored with the session."].join(`
|
|
223
222
|
`),Iwe=async(t,e)=>{let r=await pwe(e);return r?Uut(Fut(r,e.runner),t):t},Uut=(t,e)=>[t,e].filter(Boolean).join(`
|
|
@@ -383,7 +382,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
383
382
|
`,LF:`
|
|
384
383
|
`,concatBytes:F5},lmt=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},dmt={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:lmt};import{Buffer as fmt}from"buffer";var gxe=(t,e)=>t?void 0:pmt.bind(void 0,e),pmt=function*(t,e){if(typeof e!="string"&&!Kr(e)&&!fmt.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},_xe=(t,e)=>t?hmt.bind(void 0,e):mmt.bind(void 0,e),hmt=function*(t,e){yxe(t,e),yield e},mmt=function*(t,e){if(yxe(t,e),typeof e!="string"&&!Kr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},yxe=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
385
384
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
386
|
-
if (condition) { yield value; }`)};import{Buffer as gmt}from"buffer";import{StringDecoder as _mt}from"string_decoder";var NM=(t,e,r)=>{if(r)return;if(t)return{transform:ymt.bind(void 0,new TextEncoder)};let n=new _mt(e);return{transform:Smt.bind(void 0,n),final:vmt.bind(void 0,n)}},ymt=function*(t,e){gmt.isBuffer(e)?yield Eu(e):typeof e=="string"?yield t.encode(e):yield e},Smt=function*(t,e){yield Kr(e)?t.write(e):e},vmt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Sxe}from"util";var j5=Sxe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),$M=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=bmt}=e[r];for await(let i of n(t))yield*$M(i,e,r+1)},vxe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Emt(r,Number(e),t)},Emt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*$M(n,r,e+1)},Exe=Sxe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),bmt=function*(t){yield t};var B5=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},bxe=(t,e)=>[...e.flatMap(r=>[...rh(r,t,0)]),...cR(t)],rh=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Tmt}=e[r];for(let i of n(t))yield*rh(i,e,r+1)},cR=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*wmt(r,Number(e),t)},wmt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*rh(n,r,e+1)},Tmt=function*(t){yield t};var q5=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Txe(t,s,o),u=th(e),l=th(r),d=u?j5.bind(void 0,$M,a):B5.bind(void 0,rh),f=u||l?j5.bind(void 0,vxe,a):B5.bind(void 0,cR),p=u||l?Exe.bind(void 0,a):void 0;return{stream:new Amt({writableObjectMode:n,writableHighWaterMark:wxe(n),readableObjectMode:i,readableHighWaterMark:wxe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},DM=(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=Txe(s,r,a);t=bxe(c,t)}return t},Txe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:gxe(n,a)},NM(r,s,n),kM(r,o,n,c),{transform:t,final:e},{transform:_xe(i,a)},mxe({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Axe=(t,e)=>{for(let r of Rmt(t))xmt(t,r,e)},Rmt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),xmt=(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 ${pd[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>Imt(a,n));r.input=JA(s)},Imt=(t,e)=>{let r=DM(t,e,"utf8",!0);return Omt(r),JA(r)},Omt=t=>{let e=t.find(r=>typeof r!="string"&&!Kr(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 Nmt,appendFileSync as $mt}from"fs";var MM=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Sy(r,n)&&!go.has(e)&&Pmt(n)&&(t.some(({type:i,value:o})=>i==="native"&&Cmt.has(o))||t.every(({type:i})=>Qo.has(i))),Pmt=t=>t===1||t===2,Cmt=new Set(["pipe","overlapped"]),Rxe=async(t,e,r,n)=>{for await(let i of t)kmt(e)||Ixe(i,r,n)},xxe=(t,e,r)=>{for(let n of t)Ixe(n,e,r)},kmt=t=>t._readableState.pipes.length>0,Ixe=(t,e,r)=>{let n=ZD(t);sc({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Oxe=({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,u)=>Dmt({result:c,fileDescriptors:t,fdNumber:u,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},Dmt=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:u,stripFinalNewline:l,maxBuffer:d})=>{if(t===null)return;let f=PRe(t,o,d),p=Eu(f),{stdioItems:h,objectMode:m}=e[r],_=Mmt([p],h,c,n),{serializedResult:y,finalResult:v=y}=Lmt({chunks:_,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});Umt({serializedResult:y,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let A=a[r]?v:void 0;try{return n.error===void 0&&Fmt(y,h,i),A}catch(S){return n.error=S,A}},Mmt=(t,e,r,n)=>{try{return DM(t,e,r,!1)}catch(i){return n.error=i,t}},Lmt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:JA(t)};let s=Vwe(t,r);return n[o]?{serializedResult:s,finalResult:z5(s,!i[o],e)}:{serializedResult:s}},Umt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!MM({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=z5(t,!1,s);try{xxe(a,e,n)}catch(c){r.error??=c}},Fmt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>PM.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?$mt(n,t):(r.add(o),Nmt(n,t))}};var Pxe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Tu(e,r,"all")]:Array.isArray(e)?[Tu(t,r,"all"),...e]:Kr(t)&&Kr(e)?Y9([t,e]):`${t}${e}`};import{once as V5}from"events";var Cxe=async(t,e)=>{let[r,n]=await zmt(t);return e.isForcefullyTerminated??=!1,[r,n]},zmt=async t=>{let[e,r]=await Promise.allSettled([V5(t,"spawn"),V5(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?kxe(t):r.value},kxe=async t=>{try{return await V5(t,"exit")}catch{return kxe(t)}},Nxe=async t=>{let[e,r]=await t;if(!jmt(e,r)&&G5(e,r))throw new ua;return[e,r]},jmt=(t,e)=>t===void 0&&e===void 0,G5=(t,e)=>t!==0||e!==null;var $xe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=Bmt(t,e,r),s=o?.code==="ETIMEDOUT",a=ORe(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},Bmt=(t,e,r)=>t!==void 0?t:G5(e,r)?new ua:void 0;var Dxe=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=Vmt(t,e,r),d=Wmt({file:n,commandArguments:i,options:u,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:l,startTime:a});return Oy(d,c,u)},Vmt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=JD(t,e,r),a=Gmt(r),{file:c,commandArguments:u,options:l}=yM(t,e,a);Hmt(l);let d=dxe(l,s);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},Gmt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Hmt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&LM("ipcInput"),t&&LM("ipc: true"),r&&LM("detached: true"),n&&LM("cancelSignal")},LM=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Wmt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=Kmt({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:u,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p}=$xe(c,r),{output:h,error:m=u}=Oxe({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),_=h.map((v,A)=>Tu(v,r,A)),y=Tu(Pxe(h,r),r,"all");return Zmt({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},Kmt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Axe(o,r);let a=Ymt(r);return qmt(...SM(t,e,a))}catch(a){return Iy({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},Ymt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:RM(e)}),Zmt=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:u,startTime:l})=>t===void 0?xM({command:c,escapedCommand:u,stdio:o,all:s,ipcOutput:[],options:a,startTime:l}):aR({error:t,command:c,escapedCommand:u,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:l,isSync:!0});import{setMaxListeners as L_t}from"events";import{spawn as U_t}from"child_process";import zxe from"process";import{once as H5,on as Xmt}from"events";var Mxe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(by({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:fM(t)}),Jmt({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),Jmt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{cM(e,i);let o=fd(t,e,r),s=new AbortController;try{return await Promise.race([Qmt(o,n,s),egt(o,r,s),tgt(o,r,s)])}catch(a){throw wy(t),a}finally{s.abort(),uM(e,i)}},Qmt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await H5(t,"message",{signal:r});return n}for await(let[n]of Xmt(t,"message",{signal:r}))if(e(n))return n},egt=async(t,e,{signal:r})=>{await H5(t,"disconnect",{signal:r}),bAe(e)},tgt=async(t,e,{signal:r})=>{let[n]=await H5(t,"strict:error",{signal:r});throw oM(n,e)};import{once as Uxe,on as rgt}from"events";var Fxe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>W5({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),W5=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{by({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:fM(t)}),cM(e,o);let s=fd(t,e,r),a=new AbortController,c={};return ngt(t,s,a),igt({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),ogt({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},ngt=async(t,e,r)=>{try{await Uxe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},igt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Uxe(t,"strict:error",{signal:r.signal});n.error=oM(i,e),r.abort()}catch{}},ogt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of rgt(r,"message",{signal:o.signal}))Lxe(s),yield c}catch{Lxe(s)}finally{o.abort(),uM(e,a),n||wy(t),i&&await t}},Lxe=({error:t})=>{if(t)throw t};var jxe=(t,{ipc:e})=>{Object.assign(t,qxe(t,!1,e))},Bxe=()=>{let t=zxe,e=!0,r=zxe.channel!==void 0;return{...qxe(t,e,r),getCancelSignal:YAe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},qxe=(t,e,r)=>({sendMessage:gM.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Mxe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Fxe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as sgt}from"child_process";import{PassThrough as agt,Readable as cgt,Writable as ugt,Duplex as lgt}from"stream";var Vxe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{L5(n);let a=new sgt;dgt(a,n),Object.assign(a,{readable:fgt,writable:pgt,duplex:hgt});let c=Iy({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),u=mgt(c,s,i);return{subprocess:a,promise:u}},dgt=(t,e)=>{let r=uR(),n=uR(),i=uR(),o=Array.from({length:e.length-3},uR),s=uR(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},uR=()=>{let t=new agt;return t.end(),t},fgt=()=>new cgt({read(){}}),pgt=()=>new ugt({write(){}}),hgt=()=>new lgt({read(){},write(){}}),mgt=async(t,e,r)=>Oy(t,e,r);import{createReadStream as Gxe,createWriteStream as Hxe}from"fs";import{Buffer as ggt}from"buffer";import{Readable as lR,Writable as _gt,Duplex as ygt}from"stream";var Kxe=(t,e)=>CM(Sgt,t,e,!1),dR=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${pd[t]}.`)},Wxe={fileNumber:dR,generator:q5,asyncGenerator:q5,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:ygt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Sgt={input:{...Wxe,fileUrl:({value:t})=>({stream:Gxe(t)}),filePath:({value:{file:t}})=>({stream:Gxe(t)}),webStream:({value:t})=>({stream:lR.fromWeb(t)}),iterable:({value:t})=>({stream:lR.from(t)}),asyncIterable:({value:t})=>({stream:lR.from(t)}),string:({value:t})=>({stream:lR.from(t)}),uint8Array:({value:t})=>({stream:lR.from(ggt.from(t))})},output:{...Wxe,fileUrl:({value:t})=>({stream:Hxe(t)}),filePath:({value:{file:t,append:e}})=>({stream:Hxe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:_gt.fromWeb(t)}),iterable:dR,asyncIterable:dR,string:dR,uint8Array:dR}};import{on as vgt,once as Yxe}from"events";import{PassThrough as Egt,getDefaultHighWaterMark as bgt}from"stream";import{finished as Jxe}from"stream/promises";function nh(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)Y5(i);let e=t.some(({readableObjectMode:i})=>i),r=wgt(t,e),n=new K5({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var wgt=(t,e)=>{if(t.length===0)return bgt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},K5=class extends Egt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(Y5(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Tgt(this,this.#e,this.#o);let r=xgt({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(Y5(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)}},Tgt=async(t,e,r)=>{UM(t,Zxe);let n=new AbortController;try{await Promise.race([Agt(t,n),Rgt(t,e,r,n)])}finally{n.abort(),UM(t,-Zxe)}},Agt=async(t,{signal:e})=>{try{await Jxe(t,{signal:e,cleanup:!0})}catch(r){throw Qxe(t,r),r}},Rgt=async(t,e,r,{signal:n})=>{for await(let[i]of vgt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},Y5=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},xgt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{UM(t,Xxe);let a=new AbortController;try{await Promise.race([Igt(o,e,a),Ogt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),Pgt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),UM(t,-Xxe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?Z5(t):Cgt(t))},Igt=async(t,e,{signal:r})=>{try{await t,r.aborted||Z5(e)}catch(n){r.aborted||Qxe(e,n)}},Ogt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await Jxe(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;eIe(s)?i.add(e):tIe(t,s)}},Pgt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await Yxe(t,i,{signal:o}),!t.readable)return Yxe(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},Cgt=t=>{t.writable&&t.end()},Qxe=(t,e)=>{eIe(e)?Z5(t):tIe(t,e)},eIe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Z5=t=>{(t.readable||t.writable)&&t.destroy()},tIe=(t,e)=>{t.destroyed||(t.once("error",kgt),t.destroy(e))},kgt=()=>{},UM=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Zxe=2,Xxe=1;import{finished as rIe}from"stream/promises";var Cy=(t,e)=>{t.pipe(e),Ngt(t,e),$gt(t,e)},Ngt=async(t,e)=>{if(!(ca(t)||ca(e))){try{await rIe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}X5(e)}},X5=t=>{t.writable&&t.end()},$gt=async(t,e)=>{if(!(ca(t)||ca(e))){try{await rIe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}J5(t)}},J5=t=>{t.readable&&t.destroy()};var nIe=(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})=>Qo.has(c)))Dgt(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Qo.has(c)))Lgt({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]:nh(o);Cy(s,i)}},Dgt=(t,e,r,n)=>{r==="output"?Cy(t.stdio[n],e):Cy(e,t.stdio[n]);let i=Mgt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},Mgt=["stdin","stdout","stderr"],Lgt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;Ugt(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},Ugt=(t,{signal:e})=>{ca(t)&&Qp(t,Fgt,e)},Fgt=2;import{addAbortListener as Bgt}from"events";var ih=[];ih.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&ih.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&ih.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var FM=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",Q5=Symbol.for("signal-exit emitter"),e8=globalThis,zgt=Object.defineProperty.bind(Object),t8=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(e8[Q5])return e8[Q5];zgt(e8,Q5,{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}},zM=class{},jgt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),r8=class extends zM{onExit(){return()=>{}}load(){}unload(){}},n8=class extends zM{#e=i8.platform==="win32"?"SIGINT":"SIGHUP";#r=new t8;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of ih)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(!FM(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 ih)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,ih.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 FM(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"&&FM(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)}},i8=globalThis.process,{onExit:iIe,load:Hfr,unload:Wfr}=jgt(FM(i8)?new n8(i8):new r8);var oIe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=iIe(()=>{t.kill()});Bgt(n,()=>{i()})};var aIe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=XD(),{destination:s,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=qgt(r,n,i),{sourceStream:d,sourceError:f}=Ggt(t,u),{options:p,fileDescriptors:h}=cc.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:o}},qgt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=Vgt(t,e,...r),a=aM(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},Vgt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(sIe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||W9(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]=jD(r,...n);return{destination:e(sIe)(i,o,s),pipeOptions:s}}if(cc.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}`)},sIe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),Ggt=(t,e)=>{try{return{sourceStream:Ty(t,e)}}catch(r){return{sourceError:r}}};var uIe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=Hgt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw o8({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},Hgt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return J5(t),n;if(e!==void 0)return X5(r),e},o8=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Iy({error:t,command:cIe,escapedCommand:cIe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),cIe="source.pipe(destination)";var lIe=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 Wgt}from"stream/promises";var dIe=(t,e,r)=>{let n=jM.has(e)?Ygt(t,e):Kgt(t,e);return Qp(t,Xgt,r.signal),Qp(e,Jgt,r.signal),Zgt(e),n},Kgt=(t,e)=>{let r=nh([t]);return Cy(r,e),jM.set(e,r),r},Ygt=(t,e)=>{let r=jM.get(e);return r.add(t),r},Zgt=async t=>{try{await Wgt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}jM.delete(t)},jM=new WeakMap,Xgt=2,Jgt=1;import{aborted as Qgt}from"util";var fIe=(t,e)=>t===void 0?[]:[e_t(t,e)],e_t=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await Qgt(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw o8({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var BM=(t,...e)=>{if(Tr(e[0]))return BM.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=aIe(t,...e),i=t_t({...n,destination:r});return i.pipe=BM.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},t_t=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=r_t(t,i);uIe({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=dIe(e,o,d);return await Promise.race([lIe(l),...fIe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},r_t=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as u_t}from"timers/promises";import{on as n_t}from"events";import{getDefaultHighWaterMark as i_t}from"stream";var qM=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return o_t(e,s),hIe({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},o_t=async(t,e)=>{try{await t}catch{}finally{e.abort()}},s8=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;s_t(e,s,t);let a=t.readableObjectMode&&!o;return hIe({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},s_t=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},hIe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=n_t(t,"data",{signal:e.signal,highWaterMark:pIe,highWatermark:pIe});return a_t({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},a8=i_t(!0),pIe=a8,a_t=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=c_t({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*rh(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*cR(a)}},c_t=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[NM(t,r,!e),kM(t,i,!n,{})].filter(Boolean);var mIe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:u,streamInfo:l})=>{let d=l_t({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([d_t(t),d]);return}let f=U5(c,r),p=s8({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([f_t({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},l_t=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!MM({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=s8({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Rxe(a,t,r,o)},d_t=async t=>{await u_t(),t.readableFlowing===null&&t.resume()},f_t=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await wM(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await TM(r,{maxBuffer:o})):await xy(r,{maxBuffer:o})}catch(a){return gIe(RRe({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},c8=async t=>{try{return await t}catch(e){return gIe(e)}},gIe=({bufferedData:t})=>Bwe(t)?new Uint8Array(t):t;import{finished as p_t}from"stream/promises";var fR=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=h_t(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],p_t(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||__t(a,e,r,n)}finally{s.abort()}},h_t=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&m_t(t,r,n),n},m_t=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{g_t(e,r),n.call(t,...i)}},g_t=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},__t=(t,e,r,n)=>{if(!y_t(t,e,r,n))throw t},y_t=(t,e,r,n=!0)=>r.propagating?_Ie(t)||VM(t):(r.propagating=!0,u8(r,e)===n?_Ie(t):VM(t)),u8=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",VM=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",_Ie=t=>t?.code==="EPIPE";var yIe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,u)=>l8({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),l8=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:u})=>{if(!t)return;let l=fR(t,e,u);if(u8(u,e)){await l;return}let[d]=await Promise.all([mIe({stream:t,onStreamEnd:l,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:u}),l]);return d};var SIe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?nh([t,e].filter(Boolean)):void 0,vIe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>l8({...S_t(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:v_t(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),S_t=({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}},v_t=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as E_t}from"events";var EIe=t=>Sy(t,"ipc"),bIe=(t,e)=>{let r=ZD(t);sc({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var wIe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=EIe(o),a=bu(e,"ipc"),c=bu(r,"ipc");for await(let u of W5({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(xRe(t,i,c),i.push(u)),s&&bIe(u,o);return i},TIe=async(t,e)=>(await Promise.allSettled([t]),e);var AIe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:u,ipc:l,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:_,controller:y})=>{let v=Cxe(t,f),A={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},S=yIe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:A}),b=vIe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:A}),E=[],R=wIe({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:E,verboseInfo:p}),C=b_t(m,t,A),O=w_t(h,A);try{return await Promise.race([Promise.all([{},Nxe(v),Promise.all(S),b,R,oRe(t,d),...C,...O]),_,T_t(t,y),...eRe(t,o,f,y),...EAe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:y}),...JAe({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(k){return f.terminationReason??="other",Promise.all([{error:k},v,Promise.all(S.map(T=>c8(T))),c8(b),TIe(R,E),Promise.allSettled(C),Promise.allSettled(O)])}},b_t=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:fR(n,i,r)),w_t=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>da(o,{checkOpen:!1})&&!ca(o)).map(({type:i,value:o,stream:s=o})=>fR(s,n,e,{isSameDirection:Qo.has(i),stopOnExit:i==="native"}))),T_t=async(t,{signal:e})=>{let[r]=await E_t(t,"error",{signal:e});throw r};var RIe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),pR=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=ac();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},ky=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 A_t}from"stream";import{callbackify as R_t}from"util";import{finished as xIe}from"stream/promises";var d8=async t=>{if(t!==void 0)try{await f8(t)}catch{}},IIe=async t=>{if(t!==void 0)try{await p8(t)}catch{}},f8=async t=>{await xIe(t,{cleanup:!0,readable:!1,writable:!0})},p8=async t=>{await xIe(t,{cleanup:!0,readable:!0,writable:!1})},GM=async(t,e)=>{if(await t,e)throw e},HM=(t,e,r)=>{r&&!VM(r)?t.destroy(r):e&&t.destroy()};var OIe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||go.has(r),{subprocessStdout:a,waitReadableDestroy:c}=h8(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=m8(a,s),{read:f,onStdoutDataDone:p}=g8({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new A_t({read:f,destroy:R_t(y8.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return _8({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},h8=(t,e,r)=>{let n=Ty(t,e),i=pR(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},m8=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:a8},g8=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=ac(),s=qM({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){x_t(this,s,o)},onStdoutDataDone:o}},x_t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},_8=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await p8(t),await n,await d8(i),await e,r.readable&&r.push(null)}catch(o){await d8(i),PIe(r,o)}},y8=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await ky(r,e)&&(PIe(t,n),await GM(e,n))},PIe=(t,e)=>{HM(t,t.readable,e)};import{Writable as I_t}from"stream";import{callbackify as CIe}from"util";var kIe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=S8(t,r,e),s=new I_t({...v8(n,t,i),destroy:CIe(b8.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return E8(n,s),s},S8=(t,e,r)=>{let n=aM(t,e),i=pR(r,n,"writableFinal"),o=pR(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},v8=(t,e,r)=>({write:O_t.bind(void 0,t),final:CIe(P_t.bind(void 0,t,e,r))}),O_t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},P_t=async(t,e,r)=>{await ky(r,e)&&(t.writable&&t.end(),await e)},E8=async(t,e,r)=>{try{await f8(t),e.writable&&e.end()}catch(n){await IIe(r),NIe(e,n)}},b8=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await ky(r,e),await ky(n,e)&&(NIe(t,i),await GM(e,i))},NIe=(t,e)=>{HM(t,t.writable,e)};import{Duplex as C_t}from"stream";import{callbackify as k_t}from"util";var $Ie=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||go.has(r),{subprocessStdout:c,waitReadableDestroy:u}=h8(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=S8(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=m8(c,a),{read:_,onStdoutDataDone:y}=g8({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),v=new C_t({read:_,...v8(l,t,d),destroy:k_t(N_t.bind(void 0,{subprocessStdout:c,subprocessStdin:l,subprocess:t,waitReadableDestroy:u,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:l.writableHighWaterMark,readableObjectMode:h,writableObjectMode:l.writableObjectMode,encoding:p});return _8({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:l}),E8(l,v,c),v},N_t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([y8({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),b8({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var w8=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||go.has(e),s=Ty(t,r),a=qM({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return $_t(a,s,t)},$_t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var DIe=(t,{encoding:e})=>{let r=RIe();t.readable=OIe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=kIe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=$Ie.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=w8.bind(void 0,t,e),t[Symbol.asyncIterator]=w8.bind(void 0,t,e,{})};var MIe=(t,e)=>{for(let[r,n]of M_t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},D_t=(async()=>{})().constructor.prototype,M_t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(D_t,t)]);var LIe=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=F_t(t,e,r),{subprocess:f,promise:p}=j_t({file:i,commandArguments:o,options:l,startTime:c,verboseInfo:u,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=BM.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),MIe(f,p),cc.set(f,{options:l,fileDescriptors:d}),f},F_t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=JD(t,e,r),{file:a,commandArguments:c,options:u}=yM(t,e,r),l=z_t(u),d=Kxe(l,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},z_t=({timeout:t,signal:e,...r})=>{if(e!==void 0)throw new TypeError('The "signal" option has been renamed to "cancelSignal" instead.');return{...r,timeoutDuration:t}},j_t=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=U_t(...SM(t,e,r))}catch(h){return Vxe({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;L_t(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];nIe(c,a,u),oIe(c,r,u);let d={},f=ac();c.kill=SAe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=SIe(c,r),DIe(c,r),jxe(c,r);let p=B_t({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:l,command:o,escapedCommand:s,context:d,onInternalError:f,controller:u});return{subprocess:c,promise:p}},B_t=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:u,controller:l})=>{let[d,[f,p],h,m,_]=await AIe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:u,controller:l});l.abort(),u.resolve();let y=h.map((S,b)=>Tu(S,e,b)),v=Tu(m,e,"all"),A=q_t({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Oy(A,n,e)},q_t=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:u,startTime:l})=>"error"in t?aR({error:t.error,command:c,escapedCommand:u,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof uc,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:l,isSync:!1}):xM({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:o,options:a,startTime:l});var WM=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,V_t(n,t[n],i)]));return{...t,...r}},V_t=(t,e,r)=>G_t.has(t)&&Tr(e)&&Tr(r)?{...e,...r}:r,G_t=new Set(["env",...Q9]);var hd=(t,e,r,n)=>{let i=(s,a,c)=>hd(s,a,r,c),o=(...s)=>H_t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},H_t=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Tr(o))return i(t,WM(r,o),n);let{file:a,commandArguments:c,options:u,isSync:l}=W_t({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return l?Dxe(a,c,u):LIe(a,c,u,i)},W_t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=Kwe(e)?Ywe(e,r):[e,...r],[s,a,c]=jD(...o),u=WM(WM(n,i),c),{file:l=s,commandArguments:d=a,options:f=u,isSync:p=!1}=t({file:s,commandArguments:a,options:u});return{file:l,commandArguments:d,options:f,isSync:p}};var UIe=({file:t,commandArguments:e})=>zIe(t,e),FIe=({file:t,commandArguments:e})=>({...zIe(t,e),isSync:!0}),zIe=(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]=K_t(t);return{file:r,commandArguments:n}},K_t=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(Y_t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},Y_t=/ +/g;var jIe=(t,e,r)=>{t.sync=e(Z_t,r),t.s=t.sync},BIe=({options:t})=>qIe(t),Z_t=({options:t})=>({...qIe(t),isSync:!0}),qIe=t=>({options:{...X_t(t),...t}}),X_t=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},VIe={preferLocal:!0};var GIe=hd(()=>({})),Mmr=hd(()=>({isSync:!0})),HIe=hd(UIe),Lmr=hd(FIe),Umr=hd(rRe),Fmr=hd(BIe,{},VIe,jIe),{sendMessage:zmr,getOneMessage:jmr,getEachMessage:Bmr,getCancelSignal:qmr}=Bxe();var WIe=!1,KIe,J_t=t=>{KIe??=t},YIe=t=>{WIe=!0,J_t(t)},Gn=()=>WIe,Au=()=>KIe,ZIe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var hR=null,XIe=t=>(hR&&hR.destroy(),hR=new es({totalAllowedTime:t}),hR),JIe=()=>hR;var es=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&&Gn())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((l,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),u="success";try{return await ok({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(l){throw u="failure",l}finally{K.timing("stage.duration",Date.now()-c,{stage:e,outcome:u}),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 QIe={name:"@netlify/agent-runner-cli",type:"module",version:"2.12.0-nb8c571bb6e224.0",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" "!src/lib/__fixtures__/**"',"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" "!src/lib/__fixtures__/**"',"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:muse":"vitest run test/integration/muse.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},engines:{node:">=22"},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","@grpc/grpc-js":"1.14.6","@netlify/axis":"^1.21.0","@netlify/eslint-config-node":"^7.0.1","@netlify/skills":"1.7.0","@opentelemetry/sdk-trace-base":"2.9.0","@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.295","@anthropic-ai/sdk":"^0.134.0","@google/gemini-cli":"0.63.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.2","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.162.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0","@opentelemetry/otlp-transformer":"0.218.0",execa:"^9.6.1",fastify:"5.12.6",minimist:"^1.2.8",openai:"7.31.0",zod:"^4.4.3"}};var ryt=eyt(import.meta.url),nyt=Ru.dirname(ryt),iyt=tyt(import.meta.url),Ny=oe("shell"),T8=new Set,eOe={preferLocal:!0},vt=(t,e,r)=>{let[n,i]=oyt(e,r),o={...eOe,...i},s=GIe(t,n,o);rOe(s,o),oOe(s);let a=r?.idleTimeout;return a&&a>0&&iOe(s,a),s},tOe=(t,e)=>{let r={...eOe,...e},n=HIe(t,r);return rOe(n,r),oOe(n),e?.idleTimeout&&e.idleTimeout>0&&iOe(n,e.idleTimeout),n},oyt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},rOe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||dc.env.NETLIFY_LOCAL_QUIET==="true")return;if(dc.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Lw).pipe(dc.stdout),t.stderr?.pipe(new Lw).pipe(dc.stderr);return}t.stdout?.pipe(dc.stdout),t.stderr?.pipe(dc.stderr)},A8=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(dc.kill(-t.pid,e),Ny.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Ny.error("Error killing process:",r),!1}},nOe=t=>A8(t,"SIGKILL"),iOe=(t,e)=>{let r=null,n=()=>{Ny.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),A8(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Ny.log(`Force killing idle process ${t.pid}`),nOe(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)},oOe=t=>{T8.add(t);let e=JIe();if(e){let r=e.onTimesUp(()=>{Ny.log(`Global timer expired, killing process ${t.pid}`),A8(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Ny.log(`Force killing process ${t.pid} after timeout`),nOe(t))},5e3)});t.on("exit",()=>{T8.delete(t),r()}),t.on("error",()=>{T8.delete(t),r()})}};function YM(t,e){return!!fa(t,e)}function fa(t,e){if(!dc.env.NETLIFY_LOCAL_MODE)try{let i=iyt.resolve(QIe.name),o=Ru.dirname(i);for(;o!==Ru.dirname(o);){let s=Ru.dirname(o);if(Ru.basename(s)==="node_modules"){let a=Ru.join(s,".bin",e);if(KM.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(dc.env.NODE_PATH){let i=Ru.join(dc.env.NODE_PATH,".bin",e);if(KM.existsSync(i))return i}let r=Ru.join(t,"node_modules",".bin",e);if(KM.existsSync(r))return r;let n=Ru.join(nyt,"..","node_modules",".bin",e);if(KM.existsSync(n))return n}var $y=oe("repo"),fOe="runner-diffs-",R8=t=>`${fOe}${t}-`,pOe=async t=>{let e=XM.tmpdir(),r;try{r=await mi.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(fOe)&&!n.startsWith(R8(t))).map(n=>mi.rm(ts.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},sOe=async t=>{let e=syt("sha256");for await(let r of ayt(t))e.update(r);return e.digest("hex")},aOe=async(t,e)=>t.size===e.size&&await sOe(t.path)===await sOe(e.path),hOe=/.. (.+)?\.log$/,cyt=[hOe],uyt=1,cOe=t=>{let e=t.split(`
|
|
385
|
+
if (condition) { yield value; }`)};import{Buffer as gmt}from"buffer";import{StringDecoder as _mt}from"string_decoder";var NM=(t,e,r)=>{if(r)return;if(t)return{transform:ymt.bind(void 0,new TextEncoder)};let n=new _mt(e);return{transform:Smt.bind(void 0,n),final:vmt.bind(void 0,n)}},ymt=function*(t,e){gmt.isBuffer(e)?yield Eu(e):typeof e=="string"?yield t.encode(e):yield e},Smt=function*(t,e){yield Kr(e)?t.write(e):e},vmt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Sxe}from"util";var j5=Sxe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),$M=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=bmt}=e[r];for await(let i of n(t))yield*$M(i,e,r+1)},vxe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Emt(r,Number(e),t)},Emt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*$M(n,r,e+1)},Exe=Sxe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),bmt=function*(t){yield t};var B5=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},bxe=(t,e)=>[...e.flatMap(r=>[...rh(r,t,0)]),...cR(t)],rh=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Tmt}=e[r];for(let i of n(t))yield*rh(i,e,r+1)},cR=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*wmt(r,Number(e),t)},wmt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*rh(n,r,e+1)},Tmt=function*(t){yield t};var q5=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Txe(t,s,o),u=th(e),l=th(r),d=u?j5.bind(void 0,$M,a):B5.bind(void 0,rh),f=u||l?j5.bind(void 0,vxe,a):B5.bind(void 0,cR),p=u||l?Exe.bind(void 0,a):void 0;return{stream:new Amt({writableObjectMode:n,writableHighWaterMark:wxe(n),readableObjectMode:i,readableHighWaterMark:wxe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},DM=(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=Txe(s,r,a);t=bxe(c,t)}return t},Txe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:gxe(n,a)},NM(r,s,n),kM(r,o,n,c),{transform:t,final:e},{transform:_xe(i,a)},mxe({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Axe=(t,e)=>{for(let r of Rmt(t))xmt(t,r,e)},Rmt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),xmt=(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 ${pd[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>Imt(a,n));r.input=JA(s)},Imt=(t,e)=>{let r=DM(t,e,"utf8",!0);return Omt(r),JA(r)},Omt=t=>{let e=t.find(r=>typeof r!="string"&&!Kr(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 Nmt,appendFileSync as $mt}from"fs";var MM=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Sy(r,n)&&!go.has(e)&&Pmt(n)&&(t.some(({type:i,value:o})=>i==="native"&&Cmt.has(o))||t.every(({type:i})=>Qo.has(i))),Pmt=t=>t===1||t===2,Cmt=new Set(["pipe","overlapped"]),Rxe=async(t,e,r,n)=>{for await(let i of t)kmt(e)||Ixe(i,r,n)},xxe=(t,e,r)=>{for(let n of t)Ixe(n,e,r)},kmt=t=>t._readableState.pipes.length>0,Ixe=(t,e,r)=>{let n=ZD(t);sc({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Oxe=({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,u)=>Dmt({result:c,fileDescriptors:t,fdNumber:u,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},Dmt=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:u,stripFinalNewline:l,maxBuffer:d})=>{if(t===null)return;let f=PRe(t,o,d),p=Eu(f),{stdioItems:h,objectMode:m}=e[r],_=Mmt([p],h,c,n),{serializedResult:y,finalResult:v=y}=Lmt({chunks:_,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});Umt({serializedResult:y,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let A=a[r]?v:void 0;try{return n.error===void 0&&Fmt(y,h,i),A}catch(S){return n.error=S,A}},Mmt=(t,e,r,n)=>{try{return DM(t,e,r,!1)}catch(i){return n.error=i,t}},Lmt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:JA(t)};let s=Vwe(t,r);return n[o]?{serializedResult:s,finalResult:z5(s,!i[o],e)}:{serializedResult:s}},Umt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!MM({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=z5(t,!1,s);try{xxe(a,e,n)}catch(c){r.error??=c}},Fmt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>PM.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?$mt(n,t):(r.add(o),Nmt(n,t))}};var Pxe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Tu(e,r,"all")]:Array.isArray(e)?[Tu(t,r,"all"),...e]:Kr(t)&&Kr(e)?Y9([t,e]):`${t}${e}`};import{once as V5}from"events";var Cxe=async(t,e)=>{let[r,n]=await zmt(t);return e.isForcefullyTerminated??=!1,[r,n]},zmt=async t=>{let[e,r]=await Promise.allSettled([V5(t,"spawn"),V5(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?kxe(t):r.value},kxe=async t=>{try{return await V5(t,"exit")}catch{return kxe(t)}},Nxe=async t=>{let[e,r]=await t;if(!jmt(e,r)&&G5(e,r))throw new ua;return[e,r]},jmt=(t,e)=>t===void 0&&e===void 0,G5=(t,e)=>t!==0||e!==null;var $xe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=Bmt(t,e,r),s=o?.code==="ETIMEDOUT",a=ORe(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},Bmt=(t,e,r)=>t!==void 0?t:G5(e,r)?new ua:void 0;var Dxe=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=Vmt(t,e,r),d=Wmt({file:n,commandArguments:i,options:u,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:l,startTime:a});return Oy(d,c,u)},Vmt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=JD(t,e,r),a=Gmt(r),{file:c,commandArguments:u,options:l}=yM(t,e,a);Hmt(l);let d=dxe(l,s);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},Gmt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Hmt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&LM("ipcInput"),t&&LM("ipc: true"),r&&LM("detached: true"),n&&LM("cancelSignal")},LM=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Wmt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=Kmt({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:u,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p}=$xe(c,r),{output:h,error:m=u}=Oxe({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),_=h.map((v,A)=>Tu(v,r,A)),y=Tu(Pxe(h,r),r,"all");return Zmt({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},Kmt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Axe(o,r);let a=Ymt(r);return qmt(...SM(t,e,a))}catch(a){return Iy({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},Ymt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:RM(e)}),Zmt=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:u,startTime:l})=>t===void 0?xM({command:c,escapedCommand:u,stdio:o,all:s,ipcOutput:[],options:a,startTime:l}):aR({error:t,command:c,escapedCommand:u,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:l,isSync:!0});import{setMaxListeners as L_t}from"events";import{spawn as U_t}from"child_process";import zxe from"process";import{once as H5,on as Xmt}from"events";var Mxe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(by({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:fM(t)}),Jmt({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),Jmt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{cM(e,i);let o=fd(t,e,r),s=new AbortController;try{return await Promise.race([Qmt(o,n,s),egt(o,r,s),tgt(o,r,s)])}catch(a){throw wy(t),a}finally{s.abort(),uM(e,i)}},Qmt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await H5(t,"message",{signal:r});return n}for await(let[n]of Xmt(t,"message",{signal:r}))if(e(n))return n},egt=async(t,e,{signal:r})=>{await H5(t,"disconnect",{signal:r}),bAe(e)},tgt=async(t,e,{signal:r})=>{let[n]=await H5(t,"strict:error",{signal:r});throw oM(n,e)};import{once as Uxe,on as rgt}from"events";var Fxe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>W5({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),W5=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{by({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:fM(t)}),cM(e,o);let s=fd(t,e,r),a=new AbortController,c={};return ngt(t,s,a),igt({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),ogt({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},ngt=async(t,e,r)=>{try{await Uxe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},igt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Uxe(t,"strict:error",{signal:r.signal});n.error=oM(i,e),r.abort()}catch{}},ogt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of rgt(r,"message",{signal:o.signal}))Lxe(s),yield c}catch{Lxe(s)}finally{o.abort(),uM(e,a),n||wy(t),i&&await t}},Lxe=({error:t})=>{if(t)throw t};var jxe=(t,{ipc:e})=>{Object.assign(t,qxe(t,!1,e))},Bxe=()=>{let t=zxe,e=!0,r=zxe.channel!==void 0;return{...qxe(t,e,r),getCancelSignal:YAe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},qxe=(t,e,r)=>({sendMessage:gM.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Mxe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Fxe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as sgt}from"child_process";import{PassThrough as agt,Readable as cgt,Writable as ugt,Duplex as lgt}from"stream";var Vxe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{L5(n);let a=new sgt;dgt(a,n),Object.assign(a,{readable:fgt,writable:pgt,duplex:hgt});let c=Iy({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),u=mgt(c,s,i);return{subprocess:a,promise:u}},dgt=(t,e)=>{let r=uR(),n=uR(),i=uR(),o=Array.from({length:e.length-3},uR),s=uR(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},uR=()=>{let t=new agt;return t.end(),t},fgt=()=>new cgt({read(){}}),pgt=()=>new ugt({write(){}}),hgt=()=>new lgt({read(){},write(){}}),mgt=async(t,e,r)=>Oy(t,e,r);import{createReadStream as Gxe,createWriteStream as Hxe}from"fs";import{Buffer as ggt}from"buffer";import{Readable as lR,Writable as _gt,Duplex as ygt}from"stream";var Kxe=(t,e)=>CM(Sgt,t,e,!1),dR=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${pd[t]}.`)},Wxe={fileNumber:dR,generator:q5,asyncGenerator:q5,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:ygt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Sgt={input:{...Wxe,fileUrl:({value:t})=>({stream:Gxe(t)}),filePath:({value:{file:t}})=>({stream:Gxe(t)}),webStream:({value:t})=>({stream:lR.fromWeb(t)}),iterable:({value:t})=>({stream:lR.from(t)}),asyncIterable:({value:t})=>({stream:lR.from(t)}),string:({value:t})=>({stream:lR.from(t)}),uint8Array:({value:t})=>({stream:lR.from(ggt.from(t))})},output:{...Wxe,fileUrl:({value:t})=>({stream:Hxe(t)}),filePath:({value:{file:t,append:e}})=>({stream:Hxe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:_gt.fromWeb(t)}),iterable:dR,asyncIterable:dR,string:dR,uint8Array:dR}};import{on as vgt,once as Yxe}from"events";import{PassThrough as Egt,getDefaultHighWaterMark as bgt}from"stream";import{finished as Jxe}from"stream/promises";function nh(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)Y5(i);let e=t.some(({readableObjectMode:i})=>i),r=wgt(t,e),n=new K5({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var wgt=(t,e)=>{if(t.length===0)return bgt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},K5=class extends Egt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(Y5(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Tgt(this,this.#e,this.#o);let r=xgt({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(Y5(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)}},Tgt=async(t,e,r)=>{UM(t,Zxe);let n=new AbortController;try{await Promise.race([Agt(t,n),Rgt(t,e,r,n)])}finally{n.abort(),UM(t,-Zxe)}},Agt=async(t,{signal:e})=>{try{await Jxe(t,{signal:e,cleanup:!0})}catch(r){throw Qxe(t,r),r}},Rgt=async(t,e,r,{signal:n})=>{for await(let[i]of vgt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},Y5=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},xgt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{UM(t,Xxe);let a=new AbortController;try{await Promise.race([Igt(o,e,a),Ogt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),Pgt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),UM(t,-Xxe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?Z5(t):Cgt(t))},Igt=async(t,e,{signal:r})=>{try{await t,r.aborted||Z5(e)}catch(n){r.aborted||Qxe(e,n)}},Ogt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await Jxe(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;eIe(s)?i.add(e):tIe(t,s)}},Pgt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await Yxe(t,i,{signal:o}),!t.readable)return Yxe(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},Cgt=t=>{t.writable&&t.end()},Qxe=(t,e)=>{eIe(e)?Z5(t):tIe(t,e)},eIe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Z5=t=>{(t.readable||t.writable)&&t.destroy()},tIe=(t,e)=>{t.destroyed||(t.once("error",kgt),t.destroy(e))},kgt=()=>{},UM=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Zxe=2,Xxe=1;import{finished as rIe}from"stream/promises";var Cy=(t,e)=>{t.pipe(e),Ngt(t,e),$gt(t,e)},Ngt=async(t,e)=>{if(!(ca(t)||ca(e))){try{await rIe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}X5(e)}},X5=t=>{t.writable&&t.end()},$gt=async(t,e)=>{if(!(ca(t)||ca(e))){try{await rIe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}J5(t)}},J5=t=>{t.readable&&t.destroy()};var nIe=(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})=>Qo.has(c)))Dgt(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Qo.has(c)))Lgt({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]:nh(o);Cy(s,i)}},Dgt=(t,e,r,n)=>{r==="output"?Cy(t.stdio[n],e):Cy(e,t.stdio[n]);let i=Mgt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},Mgt=["stdin","stdout","stderr"],Lgt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;Ugt(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},Ugt=(t,{signal:e})=>{ca(t)&&Qp(t,Fgt,e)},Fgt=2;import{addAbortListener as Bgt}from"events";var ih=[];ih.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&ih.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&ih.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var FM=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",Q5=Symbol.for("signal-exit emitter"),e8=globalThis,zgt=Object.defineProperty.bind(Object),t8=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(e8[Q5])return e8[Q5];zgt(e8,Q5,{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}},zM=class{},jgt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),r8=class extends zM{onExit(){return()=>{}}load(){}unload(){}},n8=class extends zM{#e=i8.platform==="win32"?"SIGINT":"SIGHUP";#r=new t8;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of ih)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(!FM(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 ih)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,ih.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 FM(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"&&FM(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)}},i8=globalThis.process,{onExit:iIe,load:Hfr,unload:Wfr}=jgt(FM(i8)?new n8(i8):new r8);var oIe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=iIe(()=>{t.kill()});Bgt(n,()=>{i()})};var aIe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=XD(),{destination:s,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=qgt(r,n,i),{sourceStream:d,sourceError:f}=Ggt(t,u),{options:p,fileDescriptors:h}=cc.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:o}},qgt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=Vgt(t,e,...r),a=aM(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},Vgt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(sIe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||W9(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]=jD(r,...n);return{destination:e(sIe)(i,o,s),pipeOptions:s}}if(cc.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}`)},sIe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),Ggt=(t,e)=>{try{return{sourceStream:Ty(t,e)}}catch(r){return{sourceError:r}}};var uIe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=Hgt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw o8({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},Hgt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return J5(t),n;if(e!==void 0)return X5(r),e},o8=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Iy({error:t,command:cIe,escapedCommand:cIe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),cIe="source.pipe(destination)";var lIe=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 Wgt}from"stream/promises";var dIe=(t,e,r)=>{let n=jM.has(e)?Ygt(t,e):Kgt(t,e);return Qp(t,Xgt,r.signal),Qp(e,Jgt,r.signal),Zgt(e),n},Kgt=(t,e)=>{let r=nh([t]);return Cy(r,e),jM.set(e,r),r},Ygt=(t,e)=>{let r=jM.get(e);return r.add(t),r},Zgt=async t=>{try{await Wgt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}jM.delete(t)},jM=new WeakMap,Xgt=2,Jgt=1;import{aborted as Qgt}from"util";var fIe=(t,e)=>t===void 0?[]:[e_t(t,e)],e_t=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await Qgt(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw o8({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var BM=(t,...e)=>{if(Tr(e[0]))return BM.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=aIe(t,...e),i=t_t({...n,destination:r});return i.pipe=BM.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},t_t=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=r_t(t,i);uIe({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=dIe(e,o,d);return await Promise.race([lIe(l),...fIe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},r_t=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as u_t}from"timers/promises";import{on as n_t}from"events";import{getDefaultHighWaterMark as i_t}from"stream";var qM=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return o_t(e,s),hIe({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},o_t=async(t,e)=>{try{await t}catch{}finally{e.abort()}},s8=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;s_t(e,s,t);let a=t.readableObjectMode&&!o;return hIe({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},s_t=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},hIe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=n_t(t,"data",{signal:e.signal,highWaterMark:pIe,highWatermark:pIe});return a_t({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},a8=i_t(!0),pIe=a8,a_t=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=c_t({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*rh(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*cR(a)}},c_t=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[NM(t,r,!e),kM(t,i,!n,{})].filter(Boolean);var mIe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:u,streamInfo:l})=>{let d=l_t({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([d_t(t),d]);return}let f=U5(c,r),p=s8({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([f_t({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},l_t=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!MM({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=s8({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Rxe(a,t,r,o)},d_t=async t=>{await u_t(),t.readableFlowing===null&&t.resume()},f_t=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await wM(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await TM(r,{maxBuffer:o})):await xy(r,{maxBuffer:o})}catch(a){return gIe(RRe({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},c8=async t=>{try{return await t}catch(e){return gIe(e)}},gIe=({bufferedData:t})=>Bwe(t)?new Uint8Array(t):t;import{finished as p_t}from"stream/promises";var fR=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=h_t(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],p_t(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||__t(a,e,r,n)}finally{s.abort()}},h_t=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&m_t(t,r,n),n},m_t=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{g_t(e,r),n.call(t,...i)}},g_t=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},__t=(t,e,r,n)=>{if(!y_t(t,e,r,n))throw t},y_t=(t,e,r,n=!0)=>r.propagating?_Ie(t)||VM(t):(r.propagating=!0,u8(r,e)===n?_Ie(t):VM(t)),u8=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",VM=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",_Ie=t=>t?.code==="EPIPE";var yIe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,u)=>l8({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),l8=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:u})=>{if(!t)return;let l=fR(t,e,u);if(u8(u,e)){await l;return}let[d]=await Promise.all([mIe({stream:t,onStreamEnd:l,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:u}),l]);return d};var SIe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?nh([t,e].filter(Boolean)):void 0,vIe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>l8({...S_t(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:v_t(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),S_t=({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}},v_t=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as E_t}from"events";var EIe=t=>Sy(t,"ipc"),bIe=(t,e)=>{let r=ZD(t);sc({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var wIe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=EIe(o),a=bu(e,"ipc"),c=bu(r,"ipc");for await(let u of W5({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(xRe(t,i,c),i.push(u)),s&&bIe(u,o);return i},TIe=async(t,e)=>(await Promise.allSettled([t]),e);var AIe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:u,ipc:l,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:_,controller:y})=>{let v=Cxe(t,f),A={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},S=yIe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:A}),b=vIe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:A}),E=[],R=wIe({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:E,verboseInfo:p}),C=b_t(m,t,A),O=w_t(h,A);try{return await Promise.race([Promise.all([{},Nxe(v),Promise.all(S),b,R,oRe(t,d),...C,...O]),_,T_t(t,y),...eRe(t,o,f,y),...EAe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:y}),...JAe({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(k){return f.terminationReason??="other",Promise.all([{error:k},v,Promise.all(S.map(T=>c8(T))),c8(b),TIe(R,E),Promise.allSettled(C),Promise.allSettled(O)])}},b_t=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:fR(n,i,r)),w_t=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>da(o,{checkOpen:!1})&&!ca(o)).map(({type:i,value:o,stream:s=o})=>fR(s,n,e,{isSameDirection:Qo.has(i),stopOnExit:i==="native"}))),T_t=async(t,{signal:e})=>{let[r]=await E_t(t,"error",{signal:e});throw r};var RIe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),pR=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=ac();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},ky=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 A_t}from"stream";import{callbackify as R_t}from"util";import{finished as xIe}from"stream/promises";var d8=async t=>{if(t!==void 0)try{await f8(t)}catch{}},IIe=async t=>{if(t!==void 0)try{await p8(t)}catch{}},f8=async t=>{await xIe(t,{cleanup:!0,readable:!1,writable:!0})},p8=async t=>{await xIe(t,{cleanup:!0,readable:!0,writable:!1})},GM=async(t,e)=>{if(await t,e)throw e},HM=(t,e,r)=>{r&&!VM(r)?t.destroy(r):e&&t.destroy()};var OIe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||go.has(r),{subprocessStdout:a,waitReadableDestroy:c}=h8(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=m8(a,s),{read:f,onStdoutDataDone:p}=g8({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new A_t({read:f,destroy:R_t(y8.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return _8({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},h8=(t,e,r)=>{let n=Ty(t,e),i=pR(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},m8=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:a8},g8=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=ac(),s=qM({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){x_t(this,s,o)},onStdoutDataDone:o}},x_t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},_8=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await p8(t),await n,await d8(i),await e,r.readable&&r.push(null)}catch(o){await d8(i),PIe(r,o)}},y8=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await ky(r,e)&&(PIe(t,n),await GM(e,n))},PIe=(t,e)=>{HM(t,t.readable,e)};import{Writable as I_t}from"stream";import{callbackify as CIe}from"util";var kIe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=S8(t,r,e),s=new I_t({...v8(n,t,i),destroy:CIe(b8.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return E8(n,s),s},S8=(t,e,r)=>{let n=aM(t,e),i=pR(r,n,"writableFinal"),o=pR(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},v8=(t,e,r)=>({write:O_t.bind(void 0,t),final:CIe(P_t.bind(void 0,t,e,r))}),O_t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},P_t=async(t,e,r)=>{await ky(r,e)&&(t.writable&&t.end(),await e)},E8=async(t,e,r)=>{try{await f8(t),e.writable&&e.end()}catch(n){await IIe(r),NIe(e,n)}},b8=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await ky(r,e),await ky(n,e)&&(NIe(t,i),await GM(e,i))},NIe=(t,e)=>{HM(t,t.writable,e)};import{Duplex as C_t}from"stream";import{callbackify as k_t}from"util";var $Ie=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||go.has(r),{subprocessStdout:c,waitReadableDestroy:u}=h8(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=S8(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=m8(c,a),{read:_,onStdoutDataDone:y}=g8({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),v=new C_t({read:_,...v8(l,t,d),destroy:k_t(N_t.bind(void 0,{subprocessStdout:c,subprocessStdin:l,subprocess:t,waitReadableDestroy:u,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:l.writableHighWaterMark,readableObjectMode:h,writableObjectMode:l.writableObjectMode,encoding:p});return _8({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:l}),E8(l,v,c),v},N_t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([y8({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),b8({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var w8=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||go.has(e),s=Ty(t,r),a=qM({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return $_t(a,s,t)},$_t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var DIe=(t,{encoding:e})=>{let r=RIe();t.readable=OIe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=kIe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=$Ie.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=w8.bind(void 0,t,e),t[Symbol.asyncIterator]=w8.bind(void 0,t,e,{})};var MIe=(t,e)=>{for(let[r,n]of M_t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},D_t=(async()=>{})().constructor.prototype,M_t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(D_t,t)]);var LIe=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=F_t(t,e,r),{subprocess:f,promise:p}=j_t({file:i,commandArguments:o,options:l,startTime:c,verboseInfo:u,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=BM.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),MIe(f,p),cc.set(f,{options:l,fileDescriptors:d}),f},F_t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=JD(t,e,r),{file:a,commandArguments:c,options:u}=yM(t,e,r),l=z_t(u),d=Kxe(l,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},z_t=({timeout:t,signal:e,...r})=>{if(e!==void 0)throw new TypeError('The "signal" option has been renamed to "cancelSignal" instead.');return{...r,timeoutDuration:t}},j_t=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=U_t(...SM(t,e,r))}catch(h){return Vxe({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;L_t(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];nIe(c,a,u),oIe(c,r,u);let d={},f=ac();c.kill=SAe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=SIe(c,r),DIe(c,r),jxe(c,r);let p=B_t({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:l,command:o,escapedCommand:s,context:d,onInternalError:f,controller:u});return{subprocess:c,promise:p}},B_t=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:u,controller:l})=>{let[d,[f,p],h,m,_]=await AIe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:u,controller:l});l.abort(),u.resolve();let y=h.map((S,b)=>Tu(S,e,b)),v=Tu(m,e,"all"),A=q_t({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Oy(A,n,e)},q_t=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:u,startTime:l})=>"error"in t?aR({error:t.error,command:c,escapedCommand:u,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof uc,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:l,isSync:!1}):xM({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:o,options:a,startTime:l});var WM=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,V_t(n,t[n],i)]));return{...t,...r}},V_t=(t,e,r)=>G_t.has(t)&&Tr(e)&&Tr(r)?{...e,...r}:r,G_t=new Set(["env",...Q9]);var hd=(t,e,r,n)=>{let i=(s,a,c)=>hd(s,a,r,c),o=(...s)=>H_t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},H_t=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Tr(o))return i(t,WM(r,o),n);let{file:a,commandArguments:c,options:u,isSync:l}=W_t({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return l?Dxe(a,c,u):LIe(a,c,u,i)},W_t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=Kwe(e)?Ywe(e,r):[e,...r],[s,a,c]=jD(...o),u=WM(WM(n,i),c),{file:l=s,commandArguments:d=a,options:f=u,isSync:p=!1}=t({file:s,commandArguments:a,options:u});return{file:l,commandArguments:d,options:f,isSync:p}};var UIe=({file:t,commandArguments:e})=>zIe(t,e),FIe=({file:t,commandArguments:e})=>({...zIe(t,e),isSync:!0}),zIe=(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]=K_t(t);return{file:r,commandArguments:n}},K_t=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(Y_t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},Y_t=/ +/g;var jIe=(t,e,r)=>{t.sync=e(Z_t,r),t.s=t.sync},BIe=({options:t})=>qIe(t),Z_t=({options:t})=>({...qIe(t),isSync:!0}),qIe=t=>({options:{...X_t(t),...t}}),X_t=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},VIe={preferLocal:!0};var GIe=hd(()=>({})),Mmr=hd(()=>({isSync:!0})),HIe=hd(UIe),Lmr=hd(FIe),Umr=hd(rRe),Fmr=hd(BIe,{},VIe,jIe),{sendMessage:zmr,getOneMessage:jmr,getEachMessage:Bmr,getCancelSignal:qmr}=Bxe();var WIe=!1,KIe,J_t=t=>{KIe??=t},YIe=t=>{WIe=!0,J_t(t)},Gn=()=>WIe,Au=()=>KIe,ZIe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var hR=null,XIe=t=>(hR&&hR.destroy(),hR=new es({totalAllowedTime:t}),hR),JIe=()=>hR;var es=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&&Gn())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((l,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),u="success";try{return await ok({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(l){throw u="failure",l}finally{K.timing("stage.duration",Date.now()-c,{stage:e,outcome:u}),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 QIe={name:"@netlify/agent-runner-cli",type:"module",version:"2.12.0-nbf5699a060950.0",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" "!src/lib/__fixtures__/**"',"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" "!src/lib/__fixtures__/**"',"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:muse":"vitest run test/integration/muse.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},engines:{node:">=22"},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","@grpc/grpc-js":"1.14.6","@netlify/axis":"^1.21.0","@netlify/eslint-config-node":"^7.0.1","@netlify/skills":"1.7.0","@opentelemetry/sdk-trace-base":"2.9.0","@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.295","@anthropic-ai/sdk":"^0.134.0","@google/gemini-cli":"0.63.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.2","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.162.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0","@opentelemetry/otlp-transformer":"0.218.0",execa:"^9.6.1",fastify:"5.12.6",minimist:"^1.2.8",openai:"7.31.0",zod:"^4.4.3"}};var ryt=eyt(import.meta.url),nyt=Ru.dirname(ryt),iyt=tyt(import.meta.url),Ny=oe("shell"),T8=new Set,eOe={preferLocal:!0},vt=(t,e,r)=>{let[n,i]=oyt(e,r),o={...eOe,...i},s=GIe(t,n,o);rOe(s,o),oOe(s);let a=r?.idleTimeout;return a&&a>0&&iOe(s,a),s},tOe=(t,e)=>{let r={...eOe,...e},n=HIe(t,r);return rOe(n,r),oOe(n),e?.idleTimeout&&e.idleTimeout>0&&iOe(n,e.idleTimeout),n},oyt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},rOe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||dc.env.NETLIFY_LOCAL_QUIET==="true")return;if(dc.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Lw).pipe(dc.stdout),t.stderr?.pipe(new Lw).pipe(dc.stderr);return}t.stdout?.pipe(dc.stdout),t.stderr?.pipe(dc.stderr)},A8=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(dc.kill(-t.pid,e),Ny.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Ny.error("Error killing process:",r),!1}},nOe=t=>A8(t,"SIGKILL"),iOe=(t,e)=>{let r=null,n=()=>{Ny.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),A8(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Ny.log(`Force killing idle process ${t.pid}`),nOe(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)},oOe=t=>{T8.add(t);let e=JIe();if(e){let r=e.onTimesUp(()=>{Ny.log(`Global timer expired, killing process ${t.pid}`),A8(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Ny.log(`Force killing process ${t.pid} after timeout`),nOe(t))},5e3)});t.on("exit",()=>{T8.delete(t),r()}),t.on("error",()=>{T8.delete(t),r()})}};function YM(t,e){return!!fa(t,e)}function fa(t,e){if(!dc.env.NETLIFY_LOCAL_MODE)try{let i=iyt.resolve(QIe.name),o=Ru.dirname(i);for(;o!==Ru.dirname(o);){let s=Ru.dirname(o);if(Ru.basename(s)==="node_modules"){let a=Ru.join(s,".bin",e);if(KM.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(dc.env.NODE_PATH){let i=Ru.join(dc.env.NODE_PATH,".bin",e);if(KM.existsSync(i))return i}let r=Ru.join(t,"node_modules",".bin",e);if(KM.existsSync(r))return r;let n=Ru.join(nyt,"..","node_modules",".bin",e);if(KM.existsSync(n))return n}var $y=oe("repo"),fOe="runner-diffs-",R8=t=>`${fOe}${t}-`,pOe=async t=>{let e=XM.tmpdir(),r;try{r=await mi.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(fOe)&&!n.startsWith(R8(t))).map(n=>mi.rm(ts.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},sOe=async t=>{let e=syt("sha256");for await(let r of ayt(t))e.update(r);return e.digest("hex")},aOe=async(t,e)=>t.size===e.size&&await sOe(t.path)===await sOe(e.path),hOe=/.. (.+)?\.log$/,cyt=[hOe],uyt=1,cOe=t=>{let e=t.split(`
|
|
387
386
|
`).reduce((r,n)=>{if(!n)return r;let[i,o,,...s]=n,a=s.join(""),c=i.trim(),u=o.trim();return r[a]?r[a].change=u:r[a]={filePath:a,stage:c,change:u},r},{});return Object.values(e)},lyt=t=>t instanceof Error&&String(t.stderr??"").includes("No such remote"),uOe=t=>{let e=t instanceof Error?t.message:String(t),r=String(t?.stderr??"").trim();return Rn(r?`${e}: ${r}`:e)},dyt=t=>/Authentication failed|returned error: 401/.test(String(t?.stderr??"")),lOe=t=>t.pathname.replace(/\/+$/,"").replace(/\.git$/,""),fyt=(t,e)=>{try{let r=new URL(t),n=new URL(e);return["https:","http:"].includes(n.protocol)&&n.protocol===r.protocol&&n.host===r.host&&lOe(n)===lOe(r)&&n.password!==""}catch{return!1}},dOe={stdin:"pipe",stdout:"pipe",stderr:"pipe",stripFinalNewline:!1},ZM=500,mR=class extends Error{constructor(r,n){super(n instanceof Error?n.message:String(n));this.step=r;this.cause=n}},Hn=class{constructor(e=process.cwd()){this.cwd=e}getRoot(){return this.root??=this.run(["rev-parse","--show-toplevel"],{stdout:"pipe"}).then(({stdout:e})=>String(e).trim()),this.root}async restorePausedWork(e){let r="restore";try{let n=await this.restorePausedFiles(e);r="stage",await this.stageBuildSetup();let i=await this.getRoot(),o=new Set(n.changedFiles),s=(await this.listIndexEntries(n.deletedFiles,{cwd:i})).filter(({filePath:a})=>!o.has(a));return await this.unstageFiles(n.changedFiles,{cwd:i}),s.length>0&&await mi.writeFile(await this.getSetupMetadataPath(),JSON.stringify(s)),{rewrittenFileCount:n.rewrittenFileCount}}catch(n){throw new mR(r,n)}}run(e,r={}){return vt("git",e,{cwd:this.cwd,...r,env:{...r.env,NETLIFY_INTERNAL_GIT:"1"}})}async commitAndCreateDiffs({config:e,isRetry:r}){$y.info("Getting runner diffs");let n=await this.hasAgentChanges(),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!r){let u=cOe(o);await this.discardSetupOnlyChanges(u)}$y.info("Changes after processing"),await this.getStatus();let s=await this.getIgnoredPathspecs(o);if(await this.stageFiles(s),await this.excludeUnchangedSetupDescendants(),i=await this.hasStagedChanges(),!i)return{hasChanges:!1,ignored:s};await this.run(["commit","-m","Agent runner [skip ci]"]);let a=await mi.mkdtemp(ts.join(XM.tmpdir(),R8(e.sessionId))),c=await this.writeDiffFiles({config:e,diffDir:a,target:{commit:"HEAD"},ignored:s});return await this.rollbackIfLocal(),c.hasChanges&&K.distribution("diff.size",(c.diffBinary??c.diff).size,{phase:"final"}),c}async getStatus(){let e=await this.run(["-c","status.relativePaths=true","status","-s"]);return String(e.stdout??"")}async hasAgentChanges(){let e=await this.getStatus();return{hasChanges:(e.trim().length===0?[]:e.split(`
|
|
388
387
|
`).filter(i=>cyt.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}}async getCurrentCommitSha(){let{stdout:e}=await this.run(["rev-parse","HEAD"]);return String(e??"").trim()}async reset(){await this.run(["reset","--hard","HEAD"]),await mi.rm(await this.getSetupMetadataPath(),{force:!0})}async discardSetupOnlyChanges(e){let r=e.filter(n=>n.stage&&!n.change).map(n=>n.filePath);r.length!==0&&await this.run(["restore","--staged","--worktree","--pathspec-from-file=-"],{input:r.join(`
|
|
389
388
|
`)})}async stageBuildSetup(){await mi.rm(await this.getSetupMetadataPath(),{force:!0});let e=await this.getIgnoredPathspecs();await this.stageFiles(e)}getSetupMetadataPath(){return this.setupMetadataPath??=this.getRoot().then(async e=>{let{stdout:r}=await this.run(["rev-parse","--git-path","netlify-agent-runner-setup.json"],{cwd:e,stdout:"pipe"});return ts.resolve(e,String(r).trim())}),this.setupMetadataPath}async listIndexEntries(e,r){let n=[];for(let i=0;i<e.length;i+=ZM){let o=e.slice(i,i+ZM).map(a=>`:(literal)${a}`),{stdout:s}=await this.run(["ls-files","--stage","-z","--",...o],{...dOe,...r});for(let a of String(s??"").split("\0").filter(Boolean))n.push({filePath:a.slice(a.indexOf(" ")+1),entry:a})}return n}async excludeUnchangedSetupDescendants(e){let r;try{r=JSON.parse(await mi.readFile(await this.getSetupMetadataPath(),"utf8"))}catch(a){if(a.code==="ENOENT")return;throw a}let i={cwd:await this.getRoot(),env:e},o=new Map((await this.listIndexEntries(r.map(({filePath:a})=>a),i)).map(({filePath:a,entry:c})=>[a,c])),s=r.filter(({filePath:a,entry:c})=>o.get(a)===c);s.length!==0&&await this.run(["update-index","--force-remove","-z","--stdin"],{...i,input:s.map(({filePath:a})=>a).join("\0")})}async getIgnoredPathspecs(e){e||=await this.getStatus();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 e.split(`
|