@netlify/agent-runner-cli 2.14.0-nb590e7980a5a5.0 → 2.14.0-nb62dba44206b2.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 CHANGED
@@ -217,7 +217,9 @@ ${E}`,d++;break;case"id":u=E.includes("\0")?void 0:E;break;case"retry":/^\d+$/.t
217
217
  - Read files efficiently. Use glob first to find the right paths before reading
218
218
  - Prefer editing over writing entire files when possible
219
219
  - 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.
220
- - Do not use Netlify Functions, Edge Functions, Forms, Database, Blobs, Image CDN, redirects or headers rules; use third-party services or client-side code.
220
+ - When the task requires data storage or persistence, you MUST use Netlify platform primitives. Use the \`general-database\` skill to determine the right storage solution. NEVER use in-memory data structures, local JSON files, or external database services for data that needs to persist.
221
+ - 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.
222
+ - Complete the task and meet its requirements without using Netlify Blobs; keep any required data another way.
221
223
  ${jwe(t)}
222
224
  </rules>`,jD=({skillsDir:t,mode:e,runner:r})=>e==="ask"?llt(t):Bwe(t,r),qwe=({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
225
  `),Vwe=async(t,e)=>{let r=await Owe(e);return r?flt(plt(r,e.runner),t):t},flt=(t,e)=>[t,e].filter(Boolean).join(`
@@ -383,7 +385,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
383
385
  `,LF:`
384
386
  `,concatBytes:X5},Umt=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},Fmt={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:Umt};import{Buffer as zmt}from"buffer";var kxe=(t,e)=>t?void 0:jmt.bind(void 0,e),jmt=function*(t,e){if(typeof e!="string"&&!Wr(e)&&!zmt.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},Nxe=(t,e)=>t?Bmt.bind(void 0,e):qmt.bind(void 0,e),Bmt=function*(t,e){$xe(t,e),yield e},qmt=function*(t,e){if($xe(t,e),typeof e!="string"&&!Wr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},$xe=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
385
387
  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 Vmt}from"buffer";import{StringDecoder as Gmt}from"string_decoder";var jM=(t,e,r)=>{if(r)return;if(t)return{transform:Hmt.bind(void 0,new TextEncoder)};let n=new Gmt(e);return{transform:Wmt.bind(void 0,n),final:Kmt.bind(void 0,n)}},Hmt=function*(t,e){Vmt.isBuffer(e)?yield wu(e):typeof e=="string"?yield t.encode(e):yield e},Wmt=function*(t,e){yield Wr(e)?t.write(e):e},Kmt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Dxe}from"util";var e8=Dxe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),BM=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Zmt}=e[r];for await(let i of n(t))yield*BM(i,e,r+1)},Mxe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Ymt(r,Number(e),t)},Ymt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*BM(n,r,e+1)},Lxe=Dxe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),Zmt=function*(t){yield t};var t8=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Uxe=(t,e)=>[...e.flatMap(r=>[...ih(r,t,0)]),...mR(t)],ih=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Xmt}=e[r];for(let i of n(t))yield*ih(i,e,r+1)},mR=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Jmt(r,Number(e),t)},Jmt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*ih(n,r,e+1)},Xmt=function*(t){yield t};var r8=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=zxe(t,s,o),u=nh(e),l=nh(r),d=u?e8.bind(void 0,BM,a):t8.bind(void 0,ih),f=u||l?e8.bind(void 0,Mxe,a):t8.bind(void 0,mR),p=u||l?Lxe.bind(void 0,a):void 0;return{stream:new Qmt({writableObjectMode:n,writableHighWaterMark:Fxe(n),readableObjectMode:i,readableHighWaterMark:Fxe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},qM=(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=zxe(s,r,a);t=Uxe(c,t)}return t},zxe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:kxe(n,a)},jM(r,s,n),zM(r,o,n,c),{transform:t,final:e},{transform:Nxe(i,a)},Cxe({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var jxe=(t,e)=>{for(let r of egt(t))tgt(t,r,e)},egt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),tgt=(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 ${gd[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>rgt(a,n));r.input=oR(s)},rgt=(t,e)=>{let r=qM(t,e,"utf8",!0);return ngt(r),oR(r)},ngt=t=>{let e=t.find(r=>typeof r!="string"&&!Wr(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 agt,appendFileSync as cgt}from"fs";var VM=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Ty(r,n)&&!_o.has(e)&&igt(n)&&(t.some(({type:i,value:o})=>i==="native"&&ogt.has(o))||t.every(({type:i})=>ts.has(i))),igt=t=>t===1||t===2,ogt=new Set(["pipe","overlapped"]),Bxe=async(t,e,r,n)=>{for await(let i of t)sgt(e)||Vxe(i,r,n)},qxe=(t,e,r)=>{for(let n of t)Vxe(n,e,r)},sgt=t=>t._readableState.pipes.length>0,Vxe=(t,e,r)=>{let n=iM(t);lc({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Gxe=({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)=>ugt({result:c,fileDescriptors:t,fdNumber:u,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},ugt=({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=HRe(t,o,d),p=wu(f),{stdioItems:h,objectMode:m}=e[r],_=lgt([p],h,c,n),{serializedResult:y,finalResult:v=y}=dgt({chunks:_,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});fgt({serializedResult:y,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let T=a[r]?v:void 0;try{return n.error===void 0&&pgt(y,h,i),T}catch(S){return n.error=S,T}},lgt=(t,e,r,n)=>{try{return qM(t,e,r,!1)}catch(i){return n.error=i,t}},dgt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:oR(t)};let s=sTe(t,r);return n[o]?{serializedResult:s,finalResult:Q5(s,!i[o],e)}:{serializedResult:s}},fgt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!VM({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=Q5(t,!1,s);try{qxe(a,e,n)}catch(c){r.error??=c}},pgt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>UM.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?cgt(n,t):(r.add(o),agt(n,t))}};var Hxe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Ru(e,r,"all")]:Array.isArray(e)?[Ru(t,r,"all"),...e]:Wr(t)&&Wr(e)?c5([t,e]):`${t}${e}`};import{once as n8}from"events";var Wxe=async(t,e)=>{let[r,n]=await hgt(t);return e.isForcefullyTerminated??=!1,[r,n]},hgt=async t=>{let[e,r]=await Promise.allSettled([n8(t,"spawn"),n8(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Kxe(t):r.value},Kxe=async t=>{try{return await n8(t,"exit")}catch{return Kxe(t)}},Yxe=async t=>{let[e,r]=await t;if(!mgt(e,r)&&i8(e,r))throw new da;return[e,r]},mgt=(t,e)=>t===void 0&&e===void 0,i8=(t,e)=>t!==0||e!==null;var Zxe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=ggt(t,e,r),s=o?.code==="ETIMEDOUT",a=GRe(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},ggt=(t,e,r)=>t!==void 0?t:i8(e,r)?new da:void 0;var Jxe=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=ygt(t,e,r),d=Egt({file:n,commandArguments:i,options:u,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:l,startTime:a});return $y(d,c,u)},ygt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=sM(t,e,r),a=Sgt(r),{file:c,commandArguments:u,options:l}=RM(t,e,a);vgt(l);let d=xxe(l,s);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},Sgt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,vgt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&GM("ipcInput"),t&&GM("ipc: true"),r&&GM("detached: true"),n&&GM("cancelSignal")},GM=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Egt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=bgt({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}=Zxe(c,r),{output:h,error:m=u}=Gxe({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),_=h.map((v,T)=>Ru(v,r,T)),y=Ru(Hxe(h,r),r,"all");return Tgt({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},bgt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{jxe(o,r);let a=wgt(r);return _gt(...xM(t,e,a))}catch(a){return Ny({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},wgt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:$M(e)}),Tgt=({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?DM({command:c,escapedCommand:u,stdio:o,all:s,ipcOutput:[],options:a,startTime:l}):hR({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 dyt}from"events";import{spawn as fyt}from"child_process";import rIe from"process";import{once as o8,on as Agt}from"events";var Xxe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(xy({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:vM(t)}),Rgt({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),Rgt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{gM(e,i);let o=md(t,e,r),s=new AbortController;try{return await Promise.race([xgt(o,n,s),Igt(o,r,s),Ogt(o,r,s)])}catch(a){throw Iy(t),a}finally{s.abort(),_M(e,i)}},xgt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await o8(t,"message",{signal:r});return n}for await(let[n]of Agt(t,"message",{signal:r}))if(e(n))return n},Igt=async(t,e,{signal:r})=>{await o8(t,"disconnect",{signal:r}),UAe(e)},Ogt=async(t,e,{signal:r})=>{let[n]=await o8(t,"strict:error",{signal:r});throw pM(n,e)};import{once as eIe,on as Pgt}from"events";var tIe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>s8({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),s8=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{xy({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:vM(t)}),gM(e,o);let s=md(t,e,r),a=new AbortController,c={};return Cgt(t,s,a),kgt({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),Ngt({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},Cgt=async(t,e,r)=>{try{await eIe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},kgt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await eIe(t,"strict:error",{signal:r.signal});n.error=pM(i,e),r.abort()}catch{}},Ngt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of Pgt(r,"message",{signal:o.signal}))Qxe(s),yield c}catch{Qxe(s)}finally{o.abort(),_M(e,a),n||Iy(t),i&&await t}},Qxe=({error:t})=>{if(t)throw t};var nIe=(t,{ipc:e})=>{Object.assign(t,oIe(t,!1,e))},iIe=()=>{let t=rIe,e=!0,r=rIe.channel!==void 0;return{...oIe(t,e,r),getCancelSignal:dRe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},oIe=(t,e,r)=>({sendMessage:TM.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Xxe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:tIe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as $gt}from"child_process";import{PassThrough as Dgt,Readable as Mgt,Writable as Lgt,Duplex as Ugt}from"stream";var sIe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{Z5(n);let a=new $gt;Fgt(a,n),Object.assign(a,{readable:zgt,writable:jgt,duplex:Bgt});let c=Ny({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),u=qgt(c,s,i);return{subprocess:a,promise:u}},Fgt=(t,e)=>{let r=gR(),n=gR(),i=gR(),o=Array.from({length:e.length-3},gR),s=gR(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},gR=()=>{let t=new Dgt;return t.end(),t},zgt=()=>new Mgt({read(){}}),jgt=()=>new Lgt({write(){}}),Bgt=()=>new Ugt({read(){},write(){}}),qgt=async(t,e,r)=>$y(t,e,r);import{createReadStream as aIe,createWriteStream as cIe}from"fs";import{Buffer as Vgt}from"buffer";import{Readable as _R,Writable as Ggt,Duplex as Hgt}from"stream";var lIe=(t,e)=>FM(Wgt,t,e,!1),yR=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${gd[t]}.`)},uIe={fileNumber:yR,generator:r8,asyncGenerator:r8,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Hgt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Wgt={input:{...uIe,fileUrl:({value:t})=>({stream:aIe(t)}),filePath:({value:{file:t}})=>({stream:aIe(t)}),webStream:({value:t})=>({stream:_R.fromWeb(t)}),iterable:({value:t})=>({stream:_R.from(t)}),asyncIterable:({value:t})=>({stream:_R.from(t)}),string:({value:t})=>({stream:_R.from(t)}),uint8Array:({value:t})=>({stream:_R.from(Vgt.from(t))})},output:{...uIe,fileUrl:({value:t})=>({stream:cIe(t)}),filePath:({value:{file:t,append:e}})=>({stream:cIe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Ggt.fromWeb(t)}),iterable:yR,asyncIterable:yR,string:yR,uint8Array:yR}};import{on as Kgt,once as dIe}from"events";import{PassThrough as Ygt,getDefaultHighWaterMark as Zgt}from"stream";import{finished as hIe}from"stream/promises";function oh(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)c8(i);let e=t.some(({readableObjectMode:i})=>i),r=Jgt(t,e),n=new a8({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Jgt=(t,e)=>{if(t.length===0)return Zgt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},a8=class extends Ygt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(c8(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Xgt(this,this.#e,this.#o);let r=t_t({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(c8(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)}},Xgt=async(t,e,r)=>{HM(t,fIe);let n=new AbortController;try{await Promise.race([Qgt(t,n),e_t(t,e,r,n)])}finally{n.abort(),HM(t,-fIe)}},Qgt=async(t,{signal:e})=>{try{await hIe(t,{signal:e,cleanup:!0})}catch(r){throw mIe(t,r),r}},e_t=async(t,e,r,{signal:n})=>{for await(let[i]of Kgt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},c8=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},t_t=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{HM(t,pIe);let a=new AbortController;try{await Promise.race([r_t(o,e,a),n_t({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),i_t({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),HM(t,-pIe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?u8(t):o_t(t))},r_t=async(t,e,{signal:r})=>{try{await t,r.aborted||u8(e)}catch(n){r.aborted||mIe(e,n)}},n_t=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await hIe(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;gIe(s)?i.add(e):_Ie(t,s)}},i_t=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await dIe(t,i,{signal:o}),!t.readable)return dIe(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},o_t=t=>{t.writable&&t.end()},mIe=(t,e)=>{gIe(e)?u8(t):_Ie(t,e)},gIe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",u8=t=>{(t.readable||t.writable)&&t.destroy()},_Ie=(t,e)=>{t.destroyed||(t.once("error",s_t),t.destroy(e))},s_t=()=>{},HM=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},fIe=2,pIe=1;import{finished as yIe}from"stream/promises";var My=(t,e)=>{t.pipe(e),a_t(t,e),c_t(t,e)},a_t=async(t,e)=>{if(!(la(t)||la(e))){try{await yIe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}l8(e)}},l8=t=>{t.writable&&t.end()},c_t=async(t,e)=>{if(!(la(t)||la(e))){try{await yIe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}d8(t)}},d8=t=>{t.readable&&t.destroy()};var SIe=(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})=>ts.has(c)))u_t(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!ts.has(c)))d_t({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]:oh(o);My(s,i)}},u_t=(t,e,r,n)=>{r==="output"?My(t.stdio[n],e):My(e,t.stdio[n]);let i=l_t[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},l_t=["stdin","stdout","stderr"],d_t=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;f_t(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},f_t=(t,{signal:e})=>{la(t)&&th(t,p_t,e)},p_t=2;import{addAbortListener as g_t}from"events";var sh=[];sh.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&sh.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&sh.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var WM=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",f8=Symbol.for("signal-exit emitter"),p8=globalThis,h_t=Object.defineProperty.bind(Object),h8=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(p8[f8])return p8[f8];h_t(p8,f8,{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}},KM=class{},m_t=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),m8=class extends KM{onExit(){return()=>{}}load(){}unload(){}},g8=class extends KM{#e=_8.platform==="win32"?"SIGINT":"SIGHUP";#r=new h8;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of sh)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(!WM(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 sh)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,sh.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 WM(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"&&WM(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)}},_8=globalThis.process,{onExit:vIe,load:Upr,unload:Fpr}=m_t(WM(_8)?new g8(_8):new m8);var EIe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=vIe(()=>{t.kill()});g_t(n,()=>{i()})};var wIe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=oM(),{destination:s,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=__t(r,n,i),{sourceStream:d,sourceError:f}=S_t(t,u),{options:p,fileDescriptors:h}=fc.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:o}},__t=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=y_t(t,e,...r),a=mM(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},y_t=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(bIe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||s5(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]=YD(r,...n);return{destination:e(bIe)(i,o,s),pipeOptions:s}}if(fc.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}`)},bIe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),S_t=(t,e)=>{try{return{sourceStream:Oy(t,e)}}catch(r){return{sourceError:r}}};var AIe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=v_t({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw y8({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},v_t=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return d8(t),n;if(e!==void 0)return l8(r),e},y8=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Ny({error:t,command:TIe,escapedCommand:TIe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),TIe="source.pipe(destination)";var RIe=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 E_t}from"stream/promises";var xIe=(t,e,r)=>{let n=YM.has(e)?w_t(t,e):b_t(t,e);return th(t,A_t,r.signal),th(e,R_t,r.signal),T_t(e),n},b_t=(t,e)=>{let r=oh([t]);return My(r,e),YM.set(e,r),r},w_t=(t,e)=>{let r=YM.get(e);return r.add(t),r},T_t=async t=>{try{await E_t(t,{cleanup:!0,readable:!1,writable:!0})}catch{}YM.delete(t)},YM=new WeakMap,A_t=2,R_t=1;import{aborted as x_t}from"util";var IIe=(t,e)=>t===void 0?[]:[I_t(t,e)],I_t=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await x_t(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw y8({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var ZM=(t,...e)=>{if(Ar(e[0]))return ZM.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=wIe(t,...e),i=O_t({...n,destination:r});return i.pipe=ZM.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},O_t=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=P_t(t,i);AIe({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=xIe(e,o,d);return await Promise.race([RIe(l),...IIe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},P_t=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as L_t}from"timers/promises";import{on as C_t}from"events";import{getDefaultHighWaterMark as k_t}from"stream";var JM=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return N_t(e,s),PIe({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},N_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;$_t(e,s,t);let a=t.readableObjectMode&&!o;return PIe({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},$_t=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},PIe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=C_t(t,"data",{signal:e.signal,highWaterMark:OIe,highWatermark:OIe});return D_t({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},v8=k_t(!0),OIe=v8,D_t=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=M_t({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*ih(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*mR(a)}},M_t=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[jM(t,r,!e),zM(t,i,!n,{})].filter(Boolean);var CIe=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=U_t({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([F_t(t),d]);return}let f=J5(c,r),p=S8({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([z_t({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},U_t=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!VM({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 Bxe(a,t,r,o)},F_t=async t=>{await L_t(),t.readableFlowing===null&&t.resume()},z_t=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await CM(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await kM(r,{maxBuffer:o})):await ky(r,{maxBuffer:o})}catch(a){return kIe(BRe({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},E8=async t=>{try{return await t}catch(e){return kIe(e)}},kIe=({bufferedData:t})=>iTe(t)?new Uint8Array(t):t;import{finished as j_t}from"stream/promises";var SR=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=B_t(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],j_t(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||G_t(a,e,r,n)}finally{s.abort()}},B_t=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&q_t(t,r,n),n},q_t=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{V_t(e,r),n.call(t,...i)}},V_t=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},G_t=(t,e,r,n)=>{if(!H_t(t,e,r,n))throw t},H_t=(t,e,r,n=!0)=>r.propagating?NIe(t)||XM(t):(r.propagating=!0,b8(r,e)===n?NIe(t):XM(t)),b8=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",XM=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",NIe=t=>t?.code==="EPIPE";var $Ie=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,u)=>w8({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),w8=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=SR(t,e,u);if(b8(u,e)){await l;return}let[d]=await Promise.all([CIe({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 DIe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?oh([t,e].filter(Boolean)):void 0,MIe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>w8({...W_t(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:K_t(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),W_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}},K_t=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as Y_t}from"events";var LIe=t=>Ty(t,"ipc"),UIe=(t,e)=>{let r=iM(t);lc({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var FIe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=LIe(o),a=Tu(e,"ipc"),c=Tu(r,"ipc");for await(let u of s8({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(qRe(t,i,c),i.push(u)),s&&UIe(u,o);return i},zIe=async(t,e)=>(await Promise.allSettled([t]),e);var jIe=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=Wxe(t,f),T={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},S=$Ie({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:T}),b=MIe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:T}),E=[],R=FIe({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:E,verboseInfo:p}),P=Z_t(m,t,T),O=J_t(h,T);try{return await Promise.race([Promise.all([{},Yxe(v),Promise.all(S),b,R,ERe(t,d),...P,...O]),_,X_t(t,y),...gRe(t,o,f,y),...LAe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:y}),...hRe({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(A=>E8(A))),E8(b),zIe(R,E),Promise.allSettled(P),Promise.allSettled(O)])}},Z_t=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:SR(n,i,r)),J_t=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>pa(o,{checkOpen:!1})&&!la(o)).map(({type:i,value:o,stream:s=o})=>SR(s,n,e,{isSameDirection:ts.has(i),stopOnExit:i==="native"}))),X_t=async(t,{signal:e})=>{let[r]=await Y_t(t,"error",{signal:e});throw r};var BIe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),vR=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=dc();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Ly=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 Q_t}from"stream";import{callbackify as eyt}from"util";import{finished as qIe}from"stream/promises";var T8=async t=>{if(t!==void 0)try{await A8(t)}catch{}},VIe=async t=>{if(t!==void 0)try{await R8(t)}catch{}},A8=async t=>{await qIe(t,{cleanup:!0,readable:!1,writable:!0})},R8=async t=>{await qIe(t,{cleanup:!0,readable:!0,writable:!1})},QM=async(t,e)=>{if(await t,e)throw e},eL=(t,e,r)=>{r&&!XM(r)?t.destroy(r):e&&t.destroy()};var GIe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||_o.has(r),{subprocessStdout:a,waitReadableDestroy:c}=x8(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=I8(a,s),{read:f,onStdoutDataDone:p}=O8({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new Q_t({read:f,destroy:eyt(C8.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return P8({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},x8=(t,e,r)=>{let n=Oy(t,e),i=vR(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},I8=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:v8},O8=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=dc(),s=JM({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){tyt(this,s,o)},onStdoutDataDone:o}},tyt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},P8=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await R8(t),await n,await T8(i),await e,r.readable&&r.push(null)}catch(o){await T8(i),HIe(r,o)}},C8=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Ly(r,e)&&(HIe(t,n),await QM(e,n))},HIe=(t,e)=>{eL(t,t.readable,e)};import{Writable as ryt}from"stream";import{callbackify as WIe}from"util";var KIe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=k8(t,r,e),s=new ryt({...N8(n,t,i),destroy:WIe(D8.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return $8(n,s),s},k8=(t,e,r)=>{let n=mM(t,e),i=vR(r,n,"writableFinal"),o=vR(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},N8=(t,e,r)=>({write:nyt.bind(void 0,t),final:WIe(iyt.bind(void 0,t,e,r))}),nyt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},iyt=async(t,e,r)=>{await Ly(r,e)&&(t.writable&&t.end(),await e)},$8=async(t,e,r)=>{try{await A8(t),e.writable&&e.end()}catch(n){await VIe(r),YIe(e,n)}},D8=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Ly(r,e),await Ly(n,e)&&(YIe(t,i),await QM(e,i))},YIe=(t,e)=>{eL(t,t.writable,e)};import{Duplex as oyt}from"stream";import{callbackify as syt}from"util";var ZIe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||_o.has(r),{subprocessStdout:c,waitReadableDestroy:u}=x8(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=k8(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=I8(c,a),{read:_,onStdoutDataDone:y}=O8({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),v=new oyt({read:_,...N8(l,t,d),destroy:syt(ayt.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 P8({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:l}),$8(l,v,c),v},ayt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([C8({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),D8({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var M8=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||_o.has(e),s=Oy(t,r),a=JM({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return cyt(a,s,t)},cyt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var JIe=(t,{encoding:e})=>{let r=BIe();t.readable=GIe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=KIe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=ZIe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=M8.bind(void 0,t,e),t[Symbol.asyncIterator]=M8.bind(void 0,t,e,{})};var XIe=(t,e)=>{for(let[r,n]of lyt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},uyt=(async()=>{})().constructor.prototype,lyt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(uyt,t)]);var QIe=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=pyt(t,e,r),{subprocess:f,promise:p}=myt({file:i,commandArguments:o,options:l,startTime:c,verboseInfo:u,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=ZM.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),XIe(f,p),fc.set(f,{options:l,fileDescriptors:d}),f},pyt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=sM(t,e,r),{file:a,commandArguments:c,options:u}=RM(t,e,r),l=hyt(u),d=lIe(l,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},hyt=({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}},myt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=fyt(...xM(t,e,r))}catch(h){return sIe({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;dyt(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];SIe(c,a,u),EIe(c,r,u);let d={},f=dc();c.kill=DAe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=DIe(c,r),JIe(c,r),nIe(c,r);let p=gyt({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}},gyt=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 jIe({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)=>Ru(S,e,b)),v=Ru(m,e,"all"),T=_yt({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:s,escapedCommand:a,startTime:r});return $y(T,n,e)},_yt=({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?hR({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 pc,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:l,isSync:!1}):DM({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:o,options:a,startTime:l});var tL=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,yyt(n,t[n],i)]));return{...t,...r}},yyt=(t,e,r)=>Syt.has(t)&&Ar(e)&&Ar(r)?{...e,...r}:r,Syt=new Set(["env",...f5]);var _d=(t,e,r,n)=>{let i=(s,a,c)=>_d(s,a,r,c),o=(...s)=>vyt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},vyt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Ar(o))return i(t,tL(r,o),n);let{file:a,commandArguments:c,options:u,isSync:l}=Eyt({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return l?Jxe(a,c,u):QIe(a,c,u,i)},Eyt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=lTe(e)?dTe(e,r):[e,...r],[s,a,c]=YD(...o),u=tL(tL(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 eOe=({file:t,commandArguments:e})=>rOe(t,e),tOe=({file:t,commandArguments:e})=>({...rOe(t,e),isSync:!0}),rOe=(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]=byt(t);return{file:r,commandArguments:n}},byt=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(wyt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},wyt=/ +/g;var nOe=(t,e,r)=>{t.sync=e(Tyt,r),t.s=t.sync},iOe=({options:t})=>oOe(t),Tyt=({options:t})=>({...oOe(t),isSync:!0}),oOe=t=>({options:{...Ayt(t),...t}}),Ayt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},sOe={preferLocal:!0};var aOe=_d(()=>({})),Igr=_d(()=>({isSync:!0})),cOe=_d(eOe),Ogr=_d(tOe),Pgr=_d(yRe),Cgr=_d(iOe,{},sOe,nOe),{sendMessage:kgr,getOneMessage:Ngr,getEachMessage:$gr,getCancelSignal:Dgr}=iIe();var uOe=!1,lOe,Ryt=t=>{lOe??=t},dOe=t=>{uOe=!0,Ryt(t)},Gn=()=>uOe,xu=()=>lOe,fOe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var ER=null,pOe=t=>(ER&&ER.destroy(),ER=new rs({totalAllowedTime:t}),ER),hOe=()=>ER;var rs=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 hk({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 mOe={name:"@netlify/agent-runner-cli",type:"module",version:"2.14.0-nb590e7980a5a5.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 Pyt=Iyt(import.meta.url),Cyt=Iu.dirname(Pyt),kyt=Oyt(import.meta.url),Uy=ce("shell"),L8=new Set,gOe={preferLocal:!0},Et=(t,e,r)=>{let[n,i]=Nyt(e,r),o={...gOe,...i},s=aOe(t,n,o);yOe(s,o),EOe(s);let a=r?.idleTimeout;return a&&a>0&&vOe(s,a),s},_Oe=(t,e)=>{let r={...gOe,...e},n=cOe(t,r);return yOe(n,r),EOe(n),e?.idleTimeout&&e.idleTimeout>0&&vOe(n,e.idleTimeout),n},Nyt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},yOe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||mc.env.NETLIFY_LOCAL_QUIET==="true")return;if(mc.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new qw).pipe(mc.stdout),t.stderr?.pipe(new qw).pipe(mc.stderr);return}t.stdout?.pipe(mc.stdout),t.stderr?.pipe(mc.stderr)},U8=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(mc.kill(-t.pid,e),Uy.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Uy.error("Error killing process:",r),!1}},SOe=t=>U8(t,"SIGKILL"),vOe=(t,e)=>{let r=null,n=()=>{Uy.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),U8(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Uy.log(`Force killing idle process ${t.pid}`),SOe(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)},EOe=t=>{L8.add(t);let e=hOe();if(e){let r=e.onTimesUp(()=>{Uy.log(`Global timer expired, killing process ${t.pid}`),U8(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Uy.log(`Force killing process ${t.pid} after timeout`),SOe(t))},5e3)});t.on("exit",()=>{L8.delete(t),r()}),t.on("error",()=>{L8.delete(t),r()})}};function nL(t,e){return!!ha(t,e)}function ha(t,e){if(!mc.env.NETLIFY_LOCAL_MODE)try{let i=kyt.resolve(mOe.name),o=Iu.dirname(i);for(;o!==Iu.dirname(o);){let s=Iu.dirname(o);if(Iu.basename(s)==="node_modules"){let a=Iu.join(s,".bin",e);if(rL.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(mc.env.NODE_PATH){let i=Iu.join(mc.env.NODE_PATH,".bin",e);if(rL.existsSync(i))return i}let r=Iu.join(t,"node_modules",".bin",e);if(rL.existsSync(r))return r;let n=Iu.join(Cyt,"..","node_modules",".bin",e);if(rL.existsSync(n))return n}var Fy=ce("repo"),IOe="runner-diffs-",F8=t=>`${IOe}${t}-`,OOe=async t=>{let e=oL.tmpdir(),r;try{r=await mi.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(IOe)&&!n.startsWith(F8(t))).map(n=>mi.rm(ns.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},bOe=async t=>{let e=$yt("sha256");for await(let r of Dyt(t))e.update(r);return e.digest("hex")},wOe=async(t,e)=>t.size===e.size&&await bOe(t.path)===await bOe(e.path),POe=/.. (.+)?\.log$/,Myt=[POe],Lyt=1,TOe=t=>{let e=t.split(`
388
+ if (condition) { yield value; }`)};import{Buffer as Vmt}from"buffer";import{StringDecoder as Gmt}from"string_decoder";var jM=(t,e,r)=>{if(r)return;if(t)return{transform:Hmt.bind(void 0,new TextEncoder)};let n=new Gmt(e);return{transform:Wmt.bind(void 0,n),final:Kmt.bind(void 0,n)}},Hmt=function*(t,e){Vmt.isBuffer(e)?yield wu(e):typeof e=="string"?yield t.encode(e):yield e},Wmt=function*(t,e){yield Wr(e)?t.write(e):e},Kmt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Dxe}from"util";var e8=Dxe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),BM=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Zmt}=e[r];for await(let i of n(t))yield*BM(i,e,r+1)},Mxe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Ymt(r,Number(e),t)},Ymt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*BM(n,r,e+1)},Lxe=Dxe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),Zmt=function*(t){yield t};var t8=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},Uxe=(t,e)=>[...e.flatMap(r=>[...ih(r,t,0)]),...mR(t)],ih=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Xmt}=e[r];for(let i of n(t))yield*ih(i,e,r+1)},mR=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Jmt(r,Number(e),t)},Jmt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*ih(n,r,e+1)},Xmt=function*(t){yield t};var r8=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=zxe(t,s,o),u=nh(e),l=nh(r),d=u?e8.bind(void 0,BM,a):t8.bind(void 0,ih),f=u||l?e8.bind(void 0,Mxe,a):t8.bind(void 0,mR),p=u||l?Lxe.bind(void 0,a):void 0;return{stream:new Qmt({writableObjectMode:n,writableHighWaterMark:Fxe(n),readableObjectMode:i,readableHighWaterMark:Fxe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},qM=(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=zxe(s,r,a);t=Uxe(c,t)}return t},zxe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:kxe(n,a)},jM(r,s,n),zM(r,o,n,c),{transform:t,final:e},{transform:Nxe(i,a)},Cxe({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var jxe=(t,e)=>{for(let r of egt(t))tgt(t,r,e)},egt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),tgt=(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 ${gd[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>rgt(a,n));r.input=oR(s)},rgt=(t,e)=>{let r=qM(t,e,"utf8",!0);return ngt(r),oR(r)},ngt=t=>{let e=t.find(r=>typeof r!="string"&&!Wr(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 agt,appendFileSync as cgt}from"fs";var VM=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Ty(r,n)&&!_o.has(e)&&igt(n)&&(t.some(({type:i,value:o})=>i==="native"&&ogt.has(o))||t.every(({type:i})=>ts.has(i))),igt=t=>t===1||t===2,ogt=new Set(["pipe","overlapped"]),Bxe=async(t,e,r,n)=>{for await(let i of t)sgt(e)||Vxe(i,r,n)},qxe=(t,e,r)=>{for(let n of t)Vxe(n,e,r)},sgt=t=>t._readableState.pipes.length>0,Vxe=(t,e,r)=>{let n=iM(t);lc({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Gxe=({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)=>ugt({result:c,fileDescriptors:t,fdNumber:u,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},ugt=({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=HRe(t,o,d),p=wu(f),{stdioItems:h,objectMode:m}=e[r],_=lgt([p],h,c,n),{serializedResult:y,finalResult:v=y}=dgt({chunks:_,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});fgt({serializedResult:y,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let T=a[r]?v:void 0;try{return n.error===void 0&&pgt(y,h,i),T}catch(S){return n.error=S,T}},lgt=(t,e,r,n)=>{try{return qM(t,e,r,!1)}catch(i){return n.error=i,t}},dgt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:oR(t)};let s=sTe(t,r);return n[o]?{serializedResult:s,finalResult:Q5(s,!i[o],e)}:{serializedResult:s}},fgt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!VM({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=Q5(t,!1,s);try{qxe(a,e,n)}catch(c){r.error??=c}},pgt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>UM.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?cgt(n,t):(r.add(o),agt(n,t))}};var Hxe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Ru(e,r,"all")]:Array.isArray(e)?[Ru(t,r,"all"),...e]:Wr(t)&&Wr(e)?c5([t,e]):`${t}${e}`};import{once as n8}from"events";var Wxe=async(t,e)=>{let[r,n]=await hgt(t);return e.isForcefullyTerminated??=!1,[r,n]},hgt=async t=>{let[e,r]=await Promise.allSettled([n8(t,"spawn"),n8(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?Kxe(t):r.value},Kxe=async t=>{try{return await n8(t,"exit")}catch{return Kxe(t)}},Yxe=async t=>{let[e,r]=await t;if(!mgt(e,r)&&i8(e,r))throw new da;return[e,r]},mgt=(t,e)=>t===void 0&&e===void 0,i8=(t,e)=>t!==0||e!==null;var Zxe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=ggt(t,e,r),s=o?.code==="ETIMEDOUT",a=GRe(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},ggt=(t,e,r)=>t!==void 0?t:i8(e,r)?new da:void 0;var Jxe=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=ygt(t,e,r),d=Egt({file:n,commandArguments:i,options:u,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:l,startTime:a});return $y(d,c,u)},ygt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=sM(t,e,r),a=Sgt(r),{file:c,commandArguments:u,options:l}=RM(t,e,a);vgt(l);let d=xxe(l,s);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},Sgt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,vgt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&GM("ipcInput"),t&&GM("ipc: true"),r&&GM("detached: true"),n&&GM("cancelSignal")},GM=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Egt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=bgt({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}=Zxe(c,r),{output:h,error:m=u}=Gxe({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),_=h.map((v,T)=>Ru(v,r,T)),y=Ru(Hxe(h,r),r,"all");return Tgt({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},bgt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{jxe(o,r);let a=wgt(r);return _gt(...xM(t,e,a))}catch(a){return Ny({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},wgt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:$M(e)}),Tgt=({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?DM({command:c,escapedCommand:u,stdio:o,all:s,ipcOutput:[],options:a,startTime:l}):hR({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 dyt}from"events";import{spawn as fyt}from"child_process";import rIe from"process";import{once as o8,on as Agt}from"events";var Xxe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(xy({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:vM(t)}),Rgt({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),Rgt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{gM(e,i);let o=md(t,e,r),s=new AbortController;try{return await Promise.race([xgt(o,n,s),Igt(o,r,s),Ogt(o,r,s)])}catch(a){throw Iy(t),a}finally{s.abort(),_M(e,i)}},xgt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await o8(t,"message",{signal:r});return n}for await(let[n]of Agt(t,"message",{signal:r}))if(e(n))return n},Igt=async(t,e,{signal:r})=>{await o8(t,"disconnect",{signal:r}),UAe(e)},Ogt=async(t,e,{signal:r})=>{let[n]=await o8(t,"strict:error",{signal:r});throw pM(n,e)};import{once as eIe,on as Pgt}from"events";var tIe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>s8({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),s8=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{xy({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:vM(t)}),gM(e,o);let s=md(t,e,r),a=new AbortController,c={};return Cgt(t,s,a),kgt({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),Ngt({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},Cgt=async(t,e,r)=>{try{await eIe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},kgt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await eIe(t,"strict:error",{signal:r.signal});n.error=pM(i,e),r.abort()}catch{}},Ngt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of Pgt(r,"message",{signal:o.signal}))Qxe(s),yield c}catch{Qxe(s)}finally{o.abort(),_M(e,a),n||Iy(t),i&&await t}},Qxe=({error:t})=>{if(t)throw t};var nIe=(t,{ipc:e})=>{Object.assign(t,oIe(t,!1,e))},iIe=()=>{let t=rIe,e=!0,r=rIe.channel!==void 0;return{...oIe(t,e,r),getCancelSignal:dRe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},oIe=(t,e,r)=>({sendMessage:TM.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Xxe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:tIe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as $gt}from"child_process";import{PassThrough as Dgt,Readable as Mgt,Writable as Lgt,Duplex as Ugt}from"stream";var sIe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{Z5(n);let a=new $gt;Fgt(a,n),Object.assign(a,{readable:zgt,writable:jgt,duplex:Bgt});let c=Ny({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),u=qgt(c,s,i);return{subprocess:a,promise:u}},Fgt=(t,e)=>{let r=gR(),n=gR(),i=gR(),o=Array.from({length:e.length-3},gR),s=gR(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},gR=()=>{let t=new Dgt;return t.end(),t},zgt=()=>new Mgt({read(){}}),jgt=()=>new Lgt({write(){}}),Bgt=()=>new Ugt({read(){},write(){}}),qgt=async(t,e,r)=>$y(t,e,r);import{createReadStream as aIe,createWriteStream as cIe}from"fs";import{Buffer as Vgt}from"buffer";import{Readable as _R,Writable as Ggt,Duplex as Hgt}from"stream";var lIe=(t,e)=>FM(Wgt,t,e,!1),yR=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${gd[t]}.`)},uIe={fileNumber:yR,generator:r8,asyncGenerator:r8,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Hgt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Wgt={input:{...uIe,fileUrl:({value:t})=>({stream:aIe(t)}),filePath:({value:{file:t}})=>({stream:aIe(t)}),webStream:({value:t})=>({stream:_R.fromWeb(t)}),iterable:({value:t})=>({stream:_R.from(t)}),asyncIterable:({value:t})=>({stream:_R.from(t)}),string:({value:t})=>({stream:_R.from(t)}),uint8Array:({value:t})=>({stream:_R.from(Vgt.from(t))})},output:{...uIe,fileUrl:({value:t})=>({stream:cIe(t)}),filePath:({value:{file:t,append:e}})=>({stream:cIe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Ggt.fromWeb(t)}),iterable:yR,asyncIterable:yR,string:yR,uint8Array:yR}};import{on as Kgt,once as dIe}from"events";import{PassThrough as Ygt,getDefaultHighWaterMark as Zgt}from"stream";import{finished as hIe}from"stream/promises";function oh(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)c8(i);let e=t.some(({readableObjectMode:i})=>i),r=Jgt(t,e),n=new a8({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Jgt=(t,e)=>{if(t.length===0)return Zgt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},a8=class extends Ygt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(c8(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Xgt(this,this.#e,this.#o);let r=t_t({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(c8(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)}},Xgt=async(t,e,r)=>{HM(t,fIe);let n=new AbortController;try{await Promise.race([Qgt(t,n),e_t(t,e,r,n)])}finally{n.abort(),HM(t,-fIe)}},Qgt=async(t,{signal:e})=>{try{await hIe(t,{signal:e,cleanup:!0})}catch(r){throw mIe(t,r),r}},e_t=async(t,e,r,{signal:n})=>{for await(let[i]of Kgt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},c8=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},t_t=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{HM(t,pIe);let a=new AbortController;try{await Promise.race([r_t(o,e,a),n_t({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),i_t({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),HM(t,-pIe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?u8(t):o_t(t))},r_t=async(t,e,{signal:r})=>{try{await t,r.aborted||u8(e)}catch(n){r.aborted||mIe(e,n)}},n_t=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await hIe(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;gIe(s)?i.add(e):_Ie(t,s)}},i_t=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await dIe(t,i,{signal:o}),!t.readable)return dIe(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},o_t=t=>{t.writable&&t.end()},mIe=(t,e)=>{gIe(e)?u8(t):_Ie(t,e)},gIe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",u8=t=>{(t.readable||t.writable)&&t.destroy()},_Ie=(t,e)=>{t.destroyed||(t.once("error",s_t),t.destroy(e))},s_t=()=>{},HM=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},fIe=2,pIe=1;import{finished as yIe}from"stream/promises";var My=(t,e)=>{t.pipe(e),a_t(t,e),c_t(t,e)},a_t=async(t,e)=>{if(!(la(t)||la(e))){try{await yIe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}l8(e)}},l8=t=>{t.writable&&t.end()},c_t=async(t,e)=>{if(!(la(t)||la(e))){try{await yIe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}d8(t)}},d8=t=>{t.readable&&t.destroy()};var SIe=(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})=>ts.has(c)))u_t(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!ts.has(c)))d_t({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]:oh(o);My(s,i)}},u_t=(t,e,r,n)=>{r==="output"?My(t.stdio[n],e):My(e,t.stdio[n]);let i=l_t[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},l_t=["stdin","stdout","stderr"],d_t=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;f_t(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},f_t=(t,{signal:e})=>{la(t)&&th(t,p_t,e)},p_t=2;import{addAbortListener as g_t}from"events";var sh=[];sh.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&sh.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&sh.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var WM=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",f8=Symbol.for("signal-exit emitter"),p8=globalThis,h_t=Object.defineProperty.bind(Object),h8=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(p8[f8])return p8[f8];h_t(p8,f8,{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}},KM=class{},m_t=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),m8=class extends KM{onExit(){return()=>{}}load(){}unload(){}},g8=class extends KM{#e=_8.platform==="win32"?"SIGINT":"SIGHUP";#r=new h8;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of sh)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(!WM(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 sh)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,sh.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 WM(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"&&WM(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)}},_8=globalThis.process,{onExit:vIe,load:Upr,unload:Fpr}=m_t(WM(_8)?new g8(_8):new m8);var EIe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=vIe(()=>{t.kill()});g_t(n,()=>{i()})};var wIe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=oM(),{destination:s,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=__t(r,n,i),{sourceStream:d,sourceError:f}=S_t(t,u),{options:p,fileDescriptors:h}=fc.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:o}},__t=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=y_t(t,e,...r),a=mM(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},y_t=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(bIe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||s5(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]=YD(r,...n);return{destination:e(bIe)(i,o,s),pipeOptions:s}}if(fc.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}`)},bIe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),S_t=(t,e)=>{try{return{sourceStream:Oy(t,e)}}catch(r){return{sourceError:r}}};var AIe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=v_t({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw y8({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},v_t=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return d8(t),n;if(e!==void 0)return l8(r),e},y8=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Ny({error:t,command:TIe,escapedCommand:TIe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),TIe="source.pipe(destination)";var RIe=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 E_t}from"stream/promises";var xIe=(t,e,r)=>{let n=YM.has(e)?w_t(t,e):b_t(t,e);return th(t,A_t,r.signal),th(e,R_t,r.signal),T_t(e),n},b_t=(t,e)=>{let r=oh([t]);return My(r,e),YM.set(e,r),r},w_t=(t,e)=>{let r=YM.get(e);return r.add(t),r},T_t=async t=>{try{await E_t(t,{cleanup:!0,readable:!1,writable:!0})}catch{}YM.delete(t)},YM=new WeakMap,A_t=2,R_t=1;import{aborted as x_t}from"util";var IIe=(t,e)=>t===void 0?[]:[I_t(t,e)],I_t=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await x_t(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw y8({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var ZM=(t,...e)=>{if(Ar(e[0]))return ZM.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=wIe(t,...e),i=O_t({...n,destination:r});return i.pipe=ZM.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},O_t=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=P_t(t,i);AIe({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=xIe(e,o,d);return await Promise.race([RIe(l),...IIe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},P_t=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as L_t}from"timers/promises";import{on as C_t}from"events";import{getDefaultHighWaterMark as k_t}from"stream";var JM=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return N_t(e,s),PIe({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},N_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;$_t(e,s,t);let a=t.readableObjectMode&&!o;return PIe({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},$_t=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},PIe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=C_t(t,"data",{signal:e.signal,highWaterMark:OIe,highWatermark:OIe});return D_t({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},v8=k_t(!0),OIe=v8,D_t=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=M_t({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*ih(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*mR(a)}},M_t=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[jM(t,r,!e),zM(t,i,!n,{})].filter(Boolean);var CIe=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=U_t({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([F_t(t),d]);return}let f=J5(c,r),p=S8({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([z_t({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},U_t=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!VM({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 Bxe(a,t,r,o)},F_t=async t=>{await L_t(),t.readableFlowing===null&&t.resume()},z_t=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await CM(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await kM(r,{maxBuffer:o})):await ky(r,{maxBuffer:o})}catch(a){return kIe(BRe({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},E8=async t=>{try{return await t}catch(e){return kIe(e)}},kIe=({bufferedData:t})=>iTe(t)?new Uint8Array(t):t;import{finished as j_t}from"stream/promises";var SR=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=B_t(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],j_t(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||G_t(a,e,r,n)}finally{s.abort()}},B_t=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&q_t(t,r,n),n},q_t=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{V_t(e,r),n.call(t,...i)}},V_t=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},G_t=(t,e,r,n)=>{if(!H_t(t,e,r,n))throw t},H_t=(t,e,r,n=!0)=>r.propagating?NIe(t)||XM(t):(r.propagating=!0,b8(r,e)===n?NIe(t):XM(t)),b8=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",XM=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",NIe=t=>t?.code==="EPIPE";var $Ie=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,u)=>w8({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),w8=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=SR(t,e,u);if(b8(u,e)){await l;return}let[d]=await Promise.all([CIe({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 DIe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?oh([t,e].filter(Boolean)):void 0,MIe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>w8({...W_t(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:K_t(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),W_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}},K_t=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as Y_t}from"events";var LIe=t=>Ty(t,"ipc"),UIe=(t,e)=>{let r=iM(t);lc({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var FIe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=LIe(o),a=Tu(e,"ipc"),c=Tu(r,"ipc");for await(let u of s8({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(qRe(t,i,c),i.push(u)),s&&UIe(u,o);return i},zIe=async(t,e)=>(await Promise.allSettled([t]),e);var jIe=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=Wxe(t,f),T={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},S=$Ie({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:T}),b=MIe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:T}),E=[],R=FIe({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:E,verboseInfo:p}),P=Z_t(m,t,T),O=J_t(h,T);try{return await Promise.race([Promise.all([{},Yxe(v),Promise.all(S),b,R,ERe(t,d),...P,...O]),_,X_t(t,y),...gRe(t,o,f,y),...LAe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:y}),...hRe({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(A=>E8(A))),E8(b),zIe(R,E),Promise.allSettled(P),Promise.allSettled(O)])}},Z_t=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:SR(n,i,r)),J_t=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>pa(o,{checkOpen:!1})&&!la(o)).map(({type:i,value:o,stream:s=o})=>SR(s,n,e,{isSameDirection:ts.has(i),stopOnExit:i==="native"}))),X_t=async(t,{signal:e})=>{let[r]=await Y_t(t,"error",{signal:e});throw r};var BIe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),vR=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=dc();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Ly=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 Q_t}from"stream";import{callbackify as eyt}from"util";import{finished as qIe}from"stream/promises";var T8=async t=>{if(t!==void 0)try{await A8(t)}catch{}},VIe=async t=>{if(t!==void 0)try{await R8(t)}catch{}},A8=async t=>{await qIe(t,{cleanup:!0,readable:!1,writable:!0})},R8=async t=>{await qIe(t,{cleanup:!0,readable:!0,writable:!1})},QM=async(t,e)=>{if(await t,e)throw e},eL=(t,e,r)=>{r&&!XM(r)?t.destroy(r):e&&t.destroy()};var GIe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||_o.has(r),{subprocessStdout:a,waitReadableDestroy:c}=x8(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=I8(a,s),{read:f,onStdoutDataDone:p}=O8({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new Q_t({read:f,destroy:eyt(C8.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return P8({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},x8=(t,e,r)=>{let n=Oy(t,e),i=vR(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},I8=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:v8},O8=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=dc(),s=JM({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){tyt(this,s,o)},onStdoutDataDone:o}},tyt=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},P8=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await R8(t),await n,await T8(i),await e,r.readable&&r.push(null)}catch(o){await T8(i),HIe(r,o)}},C8=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Ly(r,e)&&(HIe(t,n),await QM(e,n))},HIe=(t,e)=>{eL(t,t.readable,e)};import{Writable as ryt}from"stream";import{callbackify as WIe}from"util";var KIe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=k8(t,r,e),s=new ryt({...N8(n,t,i),destroy:WIe(D8.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return $8(n,s),s},k8=(t,e,r)=>{let n=mM(t,e),i=vR(r,n,"writableFinal"),o=vR(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},N8=(t,e,r)=>({write:nyt.bind(void 0,t),final:WIe(iyt.bind(void 0,t,e,r))}),nyt=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},iyt=async(t,e,r)=>{await Ly(r,e)&&(t.writable&&t.end(),await e)},$8=async(t,e,r)=>{try{await A8(t),e.writable&&e.end()}catch(n){await VIe(r),YIe(e,n)}},D8=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Ly(r,e),await Ly(n,e)&&(YIe(t,i),await QM(e,i))},YIe=(t,e)=>{eL(t,t.writable,e)};import{Duplex as oyt}from"stream";import{callbackify as syt}from"util";var ZIe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||_o.has(r),{subprocessStdout:c,waitReadableDestroy:u}=x8(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=k8(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=I8(c,a),{read:_,onStdoutDataDone:y}=O8({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),v=new oyt({read:_,...N8(l,t,d),destroy:syt(ayt.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 P8({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:l}),$8(l,v,c),v},ayt=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([C8({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),D8({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var M8=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||_o.has(e),s=Oy(t,r),a=JM({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return cyt(a,s,t)},cyt=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var JIe=(t,{encoding:e})=>{let r=BIe();t.readable=GIe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=KIe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=ZIe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=M8.bind(void 0,t,e),t[Symbol.asyncIterator]=M8.bind(void 0,t,e,{})};var XIe=(t,e)=>{for(let[r,n]of lyt){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},uyt=(async()=>{})().constructor.prototype,lyt=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(uyt,t)]);var QIe=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=pyt(t,e,r),{subprocess:f,promise:p}=myt({file:i,commandArguments:o,options:l,startTime:c,verboseInfo:u,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=ZM.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),XIe(f,p),fc.set(f,{options:l,fileDescriptors:d}),f},pyt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=sM(t,e,r),{file:a,commandArguments:c,options:u}=RM(t,e,r),l=hyt(u),d=lIe(l,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},hyt=({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}},myt=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=fyt(...xM(t,e,r))}catch(h){return sIe({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;dyt(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];SIe(c,a,u),EIe(c,r,u);let d={},f=dc();c.kill=DAe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=DIe(c,r),JIe(c,r),nIe(c,r);let p=gyt({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}},gyt=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 jIe({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)=>Ru(S,e,b)),v=Ru(m,e,"all"),T=_yt({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:s,escapedCommand:a,startTime:r});return $y(T,n,e)},_yt=({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?hR({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 pc,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:l,isSync:!1}):DM({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:o,options:a,startTime:l});var tL=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,yyt(n,t[n],i)]));return{...t,...r}},yyt=(t,e,r)=>Syt.has(t)&&Ar(e)&&Ar(r)?{...e,...r}:r,Syt=new Set(["env",...f5]);var _d=(t,e,r,n)=>{let i=(s,a,c)=>_d(s,a,r,c),o=(...s)=>vyt({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},vyt=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Ar(o))return i(t,tL(r,o),n);let{file:a,commandArguments:c,options:u,isSync:l}=Eyt({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return l?Jxe(a,c,u):QIe(a,c,u,i)},Eyt=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=lTe(e)?dTe(e,r):[e,...r],[s,a,c]=YD(...o),u=tL(tL(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 eOe=({file:t,commandArguments:e})=>rOe(t,e),tOe=({file:t,commandArguments:e})=>({...rOe(t,e),isSync:!0}),rOe=(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]=byt(t);return{file:r,commandArguments:n}},byt=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(wyt)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},wyt=/ +/g;var nOe=(t,e,r)=>{t.sync=e(Tyt,r),t.s=t.sync},iOe=({options:t})=>oOe(t),Tyt=({options:t})=>({...oOe(t),isSync:!0}),oOe=t=>({options:{...Ayt(t),...t}}),Ayt=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},sOe={preferLocal:!0};var aOe=_d(()=>({})),Igr=_d(()=>({isSync:!0})),cOe=_d(eOe),Ogr=_d(tOe),Pgr=_d(yRe),Cgr=_d(iOe,{},sOe,nOe),{sendMessage:kgr,getOneMessage:Ngr,getEachMessage:$gr,getCancelSignal:Dgr}=iIe();var uOe=!1,lOe,Ryt=t=>{lOe??=t},dOe=t=>{uOe=!0,Ryt(t)},Gn=()=>uOe,xu=()=>lOe,fOe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var ER=null,pOe=t=>(ER&&ER.destroy(),ER=new rs({totalAllowedTime:t}),ER),hOe=()=>ER;var rs=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 hk({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 mOe={name:"@netlify/agent-runner-cli",type:"module",version:"2.14.0-nb62dba44206b2.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 Pyt=Iyt(import.meta.url),Cyt=Iu.dirname(Pyt),kyt=Oyt(import.meta.url),Uy=ce("shell"),L8=new Set,gOe={preferLocal:!0},Et=(t,e,r)=>{let[n,i]=Nyt(e,r),o={...gOe,...i},s=aOe(t,n,o);yOe(s,o),EOe(s);let a=r?.idleTimeout;return a&&a>0&&vOe(s,a),s},_Oe=(t,e)=>{let r={...gOe,...e},n=cOe(t,r);return yOe(n,r),EOe(n),e?.idleTimeout&&e.idleTimeout>0&&vOe(n,e.idleTimeout),n},Nyt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},yOe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||mc.env.NETLIFY_LOCAL_QUIET==="true")return;if(mc.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new qw).pipe(mc.stdout),t.stderr?.pipe(new qw).pipe(mc.stderr);return}t.stdout?.pipe(mc.stdout),t.stderr?.pipe(mc.stderr)},U8=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(mc.kill(-t.pid,e),Uy.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Uy.error("Error killing process:",r),!1}},SOe=t=>U8(t,"SIGKILL"),vOe=(t,e)=>{let r=null,n=()=>{Uy.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),U8(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Uy.log(`Force killing idle process ${t.pid}`),SOe(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)},EOe=t=>{L8.add(t);let e=hOe();if(e){let r=e.onTimesUp(()=>{Uy.log(`Global timer expired, killing process ${t.pid}`),U8(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Uy.log(`Force killing process ${t.pid} after timeout`),SOe(t))},5e3)});t.on("exit",()=>{L8.delete(t),r()}),t.on("error",()=>{L8.delete(t),r()})}};function nL(t,e){return!!ha(t,e)}function ha(t,e){if(!mc.env.NETLIFY_LOCAL_MODE)try{let i=kyt.resolve(mOe.name),o=Iu.dirname(i);for(;o!==Iu.dirname(o);){let s=Iu.dirname(o);if(Iu.basename(s)==="node_modules"){let a=Iu.join(s,".bin",e);if(rL.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(mc.env.NODE_PATH){let i=Iu.join(mc.env.NODE_PATH,".bin",e);if(rL.existsSync(i))return i}let r=Iu.join(t,"node_modules",".bin",e);if(rL.existsSync(r))return r;let n=Iu.join(Cyt,"..","node_modules",".bin",e);if(rL.existsSync(n))return n}var Fy=ce("repo"),IOe="runner-diffs-",F8=t=>`${IOe}${t}-`,OOe=async t=>{let e=oL.tmpdir(),r;try{r=await mi.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(IOe)&&!n.startsWith(F8(t))).map(n=>mi.rm(ns.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},bOe=async t=>{let e=$yt("sha256");for await(let r of Dyt(t))e.update(r);return e.digest("hex")},wOe=async(t,e)=>t.size===e.size&&await bOe(t.path)===await bOe(e.path),POe=/.. (.+)?\.log$/,Myt=[POe],Lyt=1,TOe=t=>{let e=t.split(`
387
389
  `).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)},Uyt=t=>t instanceof Error&&String(t.stderr??"").includes("No such remote"),AOe=t=>{let e=t instanceof Error?t.message:String(t),r=String(t?.stderr??"").trim();return Rn(r?`${e}: ${r}`:e)},Fyt=t=>/Authentication failed|returned error: 401/.test(String(t?.stderr??"")),ROe=t=>t.pathname.replace(/\/+$/,"").replace(/\.git$/,""),zyt=(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&&ROe(n)===ROe(r)&&n.password!==""}catch{return!1}},xOe={stdin:"pipe",stdout:"pipe",stderr:"pipe",stripFinalNewline:!1},iL=500,bR=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 bR(r,n)}}run(e,r={}){return Et("git",e,{cwd:this.cwd,...r,env:{...r.env,NETLIFY_INTERNAL_GIT:"1"}})}async commitAndCreateDiffs({config:e,isRetry:r}){Fy.info("Getting runner diffs");let n=await this.hasAgentChanges(),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!r){let u=TOe(o);await this.discardSetupOnlyChanges(u)}Fy.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(ns.join(oL.tmpdir(),F8(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
390
  `).filter(i=>Myt.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
391
  `)})}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 ns.resolve(e,String(r).trim())}),this.setupMetadataPath}async listIndexEntries(e,r){let n=[];for(let i=0;i<e.length;i+=iL){let o=e.slice(i,i+iL).map(a=>`:(literal)${a}`),{stdout:s}=await this.run(["ls-files","--stage","-z","--",...o],{...xOe,...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(`
package/dist/bin.js CHANGED
@@ -594,7 +594,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
594
594
  `,LF:`
595
595
  `,concatBytes:n7},lqt=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},dqt={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:lqt};import{Buffer as fqt}from"buffer";var nMe=(t,e)=>t?void 0:pqt.bind(void 0,e),pqt=function*(t,e){if(typeof e!="string"&&!Tn(e)&&!fqt.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},iMe=(t,e)=>t?hqt.bind(void 0,e):mqt.bind(void 0,e),hqt=function*(t,e){sMe(t,e),yield e},mqt=function*(t,e){if(sMe(t,e),typeof e!="string"&&!Tn(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},sMe=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
596
596
  Instead, \`yield\` should either be called with a value, or not be called at all. For example:
597
- if (condition) { yield value; }`)};import{Buffer as gqt}from"buffer";import{StringDecoder as _qt}from"string_decoder";var _U=(t,e,r)=>{if(r)return;if(t)return{transform:yqt.bind(void 0,new TextEncoder)};let n=new _qt(e);return{transform:Sqt.bind(void 0,n),final:Eqt.bind(void 0,n)}},yqt=function*(t,e){gqt.isBuffer(e)?yield Il(e):typeof e=="string"?yield t.encode(e):yield e},Sqt=function*(t,e){yield Tn(e)?t.write(e):e},Eqt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as oMe}from"util";var s7=oMe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),yU=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=bqt}=e[r];for await(let i of n(t))yield*yU(i,e,r+1)},aMe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*vqt(r,Number(e),t)},vqt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*yU(n,r,e+1)},cMe=oMe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),bqt=function*(t){yield t};var o7=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},uMe=(t,e)=>[...e.flatMap(r=>[...jm(r,t,0)]),...Ax(t)],jm=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Tqt}=e[r];for(let i of n(t))yield*jm(i,e,r+1)},Ax=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*wqt(r,Number(e),t)},wqt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*jm(n,r,e+1)},Tqt=function*(t){yield t};var a7=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=dMe(t,o,s),u=Fm(e),l=Fm(r),d=u?s7.bind(void 0,yU,a):o7.bind(void 0,jm),f=u||l?s7.bind(void 0,aMe,a):o7.bind(void 0,Ax),p=u||l?cMe.bind(void 0,a):void 0;return{stream:new Aqt({writableObjectMode:n,writableHighWaterMark:lMe(n),readableObjectMode:i,readableHighWaterMark:lMe(i),transform(m,g,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},SU=(t,e,r,n)=>{let i=e.filter(({type:o})=>o==="generator"),s=n?i.reverse():i;for(let{value:o,optionName:a}of s){let c=dMe(o,r,a);t=uMe(c,t)}return t},dMe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:nMe(n,a)},_U(r,o,n),gU(r,s,n,c),{transform:t,final:e},{transform:iMe(i,a)},rMe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var fMe=(t,e)=>{for(let r of Rqt(t))xqt(t,r,e)},Rqt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),xqt=(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 ${Ff[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>Oqt(a,n));r.input=mx(o)},Oqt=(t,e)=>{let r=SU(t,e,"utf8",!0);return Iqt(r),mx(r)},Iqt=t=>{let e=t.find(r=>typeof r!="string"&&!Tn(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 Nqt,appendFileSync as $qt}from"fs";var EU=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&lE(r,n)&&!to.has(e)&&Pqt(n)&&(t.some(({type:i,value:s})=>i==="native"&&Cqt.has(s))||t.every(({type:i})=>Qo.has(i))),Pqt=t=>t===1||t===2,Cqt=new Set(["pipe","overlapped"]),pMe=async(t,e,r,n)=>{for await(let i of t)kqt(e)||mMe(i,r,n)},hMe=(t,e,r)=>{for(let n of t)mMe(n,e,r)},kqt=t=>t._readableState.pipes.length>0,mMe=(t,e,r)=>{let n=$1(t);ou({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var gMe=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let s={},o=new Set([]);return{output:e.map((c,u)=>Dqt({result:c,fileDescriptors:t,fdNumber:u,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},Dqt=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:c,lines:u,stripFinalNewline:l,maxBuffer:d})=>{if(t===null)return;let f=_Le(t,s,d),p=Il(f),{stdioItems:h,objectMode:m}=e[r],g=Lqt([p],h,c,n),{serializedResult:y,finalResult:E=y}=Mqt({chunks:g,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});Uqt({serializedResult:y,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let S=a[r]?E:void 0;try{return n.error===void 0&&Fqt(y,h,i),S}catch(_){return n.error=_,S}},Lqt=(t,e,r,n)=>{try{return SU(t,e,r,!1)}catch(i){return n.error=i,t}},Mqt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:mx(t)};let o=CNe(t,r);return n[s]?{serializedResult:o,finalResult:i7(o,!i[s],e)}:{serializedResult:o}},Uqt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!EU({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=i7(t,!1,o);try{hMe(a,e,n)}catch(c){r.error??=c}},Fqt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>hU.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?$qt(n,t):(r.add(s),Nqt(n,t))}};var _Me=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,kl(e,r,"all")]:Array.isArray(e)?[kl(t,r,"all"),...e]:Tn(t)&&Tn(e)?pQ([t,e]):`${t}${e}`};import{once as c7}from"events";var yMe=async(t,e)=>{let[r,n]=await jqt(t);return e.isForcefullyTerminated??=!1,[r,n]},jqt=async t=>{let[e,r]=await Promise.allSettled([c7(t,"spawn"),c7(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?SMe(t):r.value},SMe=async t=>{try{return await c7(t,"exit")}catch{return SMe(t)}},EMe=async t=>{let[e,r]=await t;if(!zqt(e,r)&&u7(e,r))throw new Ja;return[e,r]},zqt=(t,e)=>t===void 0&&e===void 0,u7=(t,e)=>t!==0||e!==null;var vMe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=qqt(t,e,r),o=s?.code==="ETIMEDOUT",a=gLe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},qqt=(t,e,r)=>t!==void 0?t:u7(e,r)?new Ja:void 0;var bMe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=Vqt(t,e,r),d=Wqt({file:n,commandArguments:i,options:u,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:l,startTime:a});return EE(d,c,u)},Vqt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=L1(t,e,r),a=Hqt(r),{file:c,commandArguments:u,options:l}=rU(t,e,a);Gqt(l);let d=XLe(l,o);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},Hqt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Gqt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&vU("ipcInput"),t&&vU("ipc: true"),r&&vU("detached: true"),n&&vU("cancelSignal")},vU=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Wqt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=Kqt({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:u,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p}=vMe(c,r),{output:h,error:m=u}=gMe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),g=h.map((E,S)=>kl(E,r,S)),y=kl(_Me(h,r),r,"all");return Jqt({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:y,options:r,command:n,escapedCommand:i,startTime:a})},Kqt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{fMe(s,r);let a=Yqt(r);return Bqt(...nU(t,e,a))}catch(a){return SE({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},Yqt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:lU(e)}),Jqt=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:s,all:o,options:a,command:c,escapedCommand:u,startTime:l})=>t===void 0?dU({command:c,escapedCommand:u,stdio:s,all:o,ipcOutput:[],options:a,startTime:l}):Tx({error:t,command:c,escapedCommand:u,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:l,isSync:!0});import{setMaxListeners as M2t}from"events";import{spawn as U2t}from"child_process";import xMe from"process";import{once as l7,on as Zqt}from"events";var wMe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(pE({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:J1(t)}),Xqt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),Xqt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{G1(e,i);let s=Uf(t,e,r),o=new AbortController;try{return await Promise.race([Qqt(s,n,o),eBt(s,r,o),tBt(s,r,o)])}catch(a){throw hE(t),a}finally{o.abort(),W1(e,i)}},Qqt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await l7(t,"message",{signal:r});return n}for await(let[n]of Zqt(t,"message",{signal:r}))if(e(n))return n},eBt=async(t,e,{signal:r})=>{await l7(t,"disconnect",{signal:r}),uDe(e)},tBt=async(t,e,{signal:r})=>{let[n]=await l7(t,"strict:error",{signal:r});throw B1(n,e)};import{once as AMe,on as rBt}from"events";var RMe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>d7({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),d7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{pE({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:J1(t)}),G1(e,s);let o=Uf(t,e,r),a=new AbortController,c={};return nBt(t,o,a),iBt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),sBt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},nBt=async(t,e,r)=>{try{await AMe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},iBt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await AMe(t,"strict:error",{signal:r.signal});n.error=B1(i,e),r.abort()}catch{}},sBt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of rBt(r,"message",{signal:s.signal}))TMe(o),yield c}catch{TMe(o)}finally{s.abort(),W1(e,a),n||hE(t),i&&await t}},TMe=({error:t})=>{if(t)throw t};var OMe=(t,{ipc:e})=>{Object.assign(t,PMe(t,!1,e))},IMe=()=>{let t=xMe,e=!0,r=xMe.channel!==void 0;return{...PMe(t,e,r),getCancelSignal:LDe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},PMe=(t,e,r)=>({sendMessage:eU.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:wMe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:RMe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as oBt}from"child_process";import{PassThrough as aBt,Readable as cBt,Writable as uBt,Duplex as lBt}from"stream";var CMe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{t7(n);let a=new oBt;dBt(a,n),Object.assign(a,{readable:fBt,writable:pBt,duplex:hBt});let c=SE({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),u=mBt(c,o,i);return{subprocess:a,promise:u}},dBt=(t,e)=>{let r=Rx(),n=Rx(),i=Rx(),s=Array.from({length:e.length-3},Rx),o=Rx(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},Rx=()=>{let t=new aBt;return t.end(),t},fBt=()=>new cBt({read(){}}),pBt=()=>new uBt({write(){}}),hBt=()=>new lBt({read(){},write(){}}),mBt=async(t,e,r)=>EE(t,e,r);import{createReadStream as kMe,createWriteStream as NMe}from"fs";import{Buffer as gBt}from"buffer";import{Readable as xx,Writable as _Bt,Duplex as yBt}from"stream";var DMe=(t,e)=>mU(SBt,t,e,!1),Ox=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Ff[t]}.`)},$Me={fileNumber:Ox,generator:a7,asyncGenerator:a7,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:yBt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},SBt={input:{...$Me,fileUrl:({value:t})=>({stream:kMe(t)}),filePath:({value:{file:t}})=>({stream:kMe(t)}),webStream:({value:t})=>({stream:xx.fromWeb(t)}),iterable:({value:t})=>({stream:xx.from(t)}),asyncIterable:({value:t})=>({stream:xx.from(t)}),string:({value:t})=>({stream:xx.from(t)}),uint8Array:({value:t})=>({stream:xx.from(gBt.from(t))})},output:{...$Me,fileUrl:({value:t})=>({stream:NMe(t)}),filePath:({value:{file:t,append:e}})=>({stream:NMe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:_Bt.fromWeb(t)}),iterable:Ox,asyncIterable:Ox,string:Ox,uint8Array:Ox}};import{on as EBt,once as LMe}from"events";import{PassThrough as vBt,getDefaultHighWaterMark as bBt}from"stream";import{finished as FMe}from"stream/promises";function zm(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)p7(i);let e=t.some(({readableObjectMode:i})=>i),r=wBt(t,e),n=new f7({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var wBt=(t,e)=>{if(t.length===0)return bBt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},f7=class extends vBt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(p7(e),this.#e.has(e))return;this.#e.add(e),this.#n??=TBt(this,this.#e,this.#s);let r=xBt({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#s});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(p7(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)}},TBt=async(t,e,r)=>{bU(t,MMe);let n=new AbortController;try{await Promise.race([ABt(t,n),RBt(t,e,r,n)])}finally{n.abort(),bU(t,-MMe)}},ABt=async(t,{signal:e})=>{try{await FMe(t,{signal:e,cleanup:!0})}catch(r){throw jMe(t,r),r}},RBt=async(t,e,r,{signal:n})=>{for await(let[i]of EBt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},p7=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},xBt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{bU(t,UMe);let a=new AbortController;try{await Promise.race([OBt(s,e,a),IBt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),PBt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),bU(t,-UMe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?h7(t):CBt(t))},OBt=async(t,e,{signal:r})=>{try{await t,r.aborted||h7(e)}catch(n){r.aborted||jMe(e,n)}},IBt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await FMe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;zMe(o)?i.add(e):qMe(t,o)}},PBt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await LMe(t,i,{signal:s}),!t.readable)return LMe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},CBt=t=>{t.writable&&t.end()},jMe=(t,e)=>{zMe(e)?h7(t):qMe(t,e)},zMe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",h7=t=>{(t.readable||t.writable)&&t.destroy()},qMe=(t,e)=>{t.destroyed||(t.once("error",kBt),t.destroy(e))},kBt=()=>{},bU=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},MMe=2,UMe=1;import{finished as BMe}from"stream/promises";var bE=(t,e)=>{t.pipe(e),NBt(t,e),$Bt(t,e)},NBt=async(t,e)=>{if(!(Ya(t)||Ya(e))){try{await BMe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}m7(e)}},m7=t=>{t.writable&&t.end()},$Bt=async(t,e)=>{if(!(Ya(t)||Ya(e))){try{await BMe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}g7(t)}},g7=t=>{t.readable&&t.destroy()};var VMe=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:s,direction:o}]of Object.entries(e)){for(let{stream:a}of s.filter(({type:c})=>Qo.has(c)))DBt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Qo.has(c)))MBt({subprocess:t,stream:a,direction:o,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,s]of n.entries()){let o=s.length===1?s[0]:zm(s);bE(o,i)}},DBt=(t,e,r,n)=>{r==="output"?bE(t.stdio[n],e):bE(e,t.stdio[n]);let i=LBt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},LBt=["stdin","stdout","stderr"],MBt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;UBt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},UBt=(t,{signal:e})=>{Ya(t)&&Mm(t,FBt,e)},FBt=2;import{addAbortListener as qBt}from"events";var qm=[];qm.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&qm.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&qm.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var wU=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",_7=Symbol.for("signal-exit emitter"),y7=globalThis,jBt=Object.defineProperty.bind(Object),S7=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(y7[_7])return y7[_7];jBt(y7,_7,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let s of this.listeners[e])i=s(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},TU=class{},zBt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),E7=class extends TU{onExit(){return()=>{}}load(){}unload(){}},v7=class extends TU{#e=b7.platform==="win32"?"SIGINT":"SIGHUP";#r=new S7;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of qm)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,s=e;if(typeof s.__signal_exit_emitter__=="object"&&typeof s.__signal_exit_emitter__.count=="number"&&(i+=s.__signal_exit_emitter__.count),n.length===i){this.unload();let o=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;o||e.kill(e.pid,a)}};this.#s=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!wU(this.#t))return()=>{};this.#o===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#r.on(n,e),()=>{this.#r.removeListener(n,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#o){this.#o=!0,this.#r.count+=1;for(let e of qm)try{let r=this.#i[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#o&&(this.#o=!1,qm.forEach(e=>{let r=this.#i[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#s,this.#r.count-=1)}#a(e){return wU(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#s.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&wU(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)}},b7=globalThis.process,{onExit:HMe,load:Y2r,unload:J2r}=zBt(wU(b7)?new v7(b7):new E7);var GMe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=HMe(()=>{t.kill()});qBt(n,()=>{i()})};var KMe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=D1(),{destination:o,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=BBt(r,n,i),{sourceStream:d,sourceError:f}=HBt(t,u),{options:p,fileDescriptors:h}=cu.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:s}},BBt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=VBt(t,e,...r),a=H1(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},VBt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(WMe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||dQ(r)){if(Object.keys(t).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[i,s,o]=A1(r,...n);return{destination:e(WMe)(i,s,o),pipeOptions:o}}if(cu.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}`)},WMe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),HBt=(t,e)=>{try{return{sourceStream:mE(t,e)}}catch(r){return{sourceError:r}}};var JMe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=GBt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw w7({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},GBt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return g7(t),n;if(e!==void 0)return m7(r),e},w7=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>SE({error:t,command:YMe,escapedCommand:YMe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),YMe="source.pipe(destination)";var ZMe=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:s,value:o=s}]=await t;if(o.pipedFrom.includes(n)||o.pipedFrom.push(n),i==="rejected")throw o;if(e==="rejected")throw n;return o};import{finished as WBt}from"stream/promises";var XMe=(t,e,r)=>{let n=AU.has(e)?YBt(t,e):KBt(t,e);return Mm(t,ZBt,r.signal),Mm(e,XBt,r.signal),JBt(e),n},KBt=(t,e)=>{let r=zm([t]);return bE(r,e),AU.set(e,r),r},YBt=(t,e)=>{let r=AU.get(e);return r.add(t),r},JBt=async t=>{try{await WBt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}AU.delete(t)},AU=new WeakMap,ZBt=2,XBt=1;import{aborted as QBt}from"util";var QMe=(t,e)=>t===void 0?[]:[e2t(t,e)],e2t=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await QBt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw w7({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var RU=(t,...e)=>{if(Qr(e[0]))return RU.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=KMe(t,...e),i=t2t({...n,destination:r});return i.pipe=RU.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},t2t=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=r2t(t,i);JMe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=XMe(e,s,d);return await Promise.race([ZMe(l),...QMe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},r2t=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as u2t}from"timers/promises";import{on as n2t}from"events";import{getDefaultHighWaterMark as i2t}from"stream";var xU=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return s2t(e,o),t1e({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},s2t=async(t,e)=>{try{await t}catch{}finally{e.abort()}},T7=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;o2t(e,o,t);let a=t.readableObjectMode&&!s;return t1e({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},o2t=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},t1e=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=n2t(t,"data",{signal:e.signal,highWaterMark:e1e,highWatermark:e1e});return a2t({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},A7=i2t(!0),e1e=A7,a2t=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=c2t({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*jm(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Ax(a)}},c2t=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[_U(t,r,!e),gU(t,i,!n,{})].filter(Boolean);var r1e=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:u,streamInfo:l})=>{let d=l2t({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([d2t(t),d]);return}let f=r7(c,r),p=T7({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([f2t({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},l2t=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!EU({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=T7({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await pMe(a,t,r,s)},d2t=async t=>{await u2t(),t.readableFlowing===null&&t.resume()},f2t=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await aU(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await cU(r,{maxBuffer:s})):await yE(r,{maxBuffer:s})}catch(a){return n1e(pLe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},R7=async t=>{try{return await t}catch(e){return n1e(e)}},n1e=({bufferedData:t})=>INe(t)?new Uint8Array(t):t;import{finished as p2t}from"stream/promises";var Ix=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=h2t(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],p2t(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||_2t(a,e,r,n)}finally{o.abort()}},h2t=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&m2t(t,r,n),n},m2t=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{g2t(e,r),n.call(t,...i)}},g2t=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},_2t=(t,e,r,n)=>{if(!y2t(t,e,r,n))throw t},y2t=(t,e,r,n=!0)=>r.propagating?i1e(t)||OU(t):(r.propagating=!0,x7(r,e)===n?i1e(t):OU(t)),x7=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",OU=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",i1e=t=>t?.code==="EPIPE";var s1e=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,u)=>O7({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),O7=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:u})=>{if(!t)return;let l=Ix(t,e,u);if(x7(u,e)){await l;return}let[d]=await Promise.all([r1e({stream:t,onStreamEnd:l,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:u}),l]);return d};var o1e=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?zm([t,e].filter(Boolean)):void 0,a1e=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>O7({...S2t(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:E2t(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),S2t=({stdout:t,stderr:e,all:r},[,n,i])=>{let s=n||i;return s?n?i?{stream:r,buffer:s}:{stream:t,buffer:s}:{stream:e,buffer:s}:{stream:r,buffer:s}},E2t=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as v2t}from"events";var c1e=t=>lE(t,"ipc"),u1e=(t,e)=>{let r=$1(t);ou({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var l1e=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=c1e(s),a=Pl(e,"ipc"),c=Pl(r,"ipc");for await(let u of d7({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(hLe(t,i,c),i.push(u)),o&&u1e(u,s);return i},d1e=async(t,e)=>(await Promise.allSettled([t]),e);var f1e=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:u,ipc:l,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:g,controller:y})=>{let E=yMe(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:E,propagating:!1},_=s1e({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:S}),w=a1e({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:S}),b=[],A=l1e({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:b,verboseInfo:p}),T=b2t(m,t,S),O=w2t(h,S);try{return await Promise.race([Promise.all([{},EMe(E),Promise.all(_),w,A,GDe(t,d),...T,...O]),g,T2t(t,y),...zDe(t,s,f,y),...cDe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...FDe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(P){return f.terminationReason??="other",Promise.all([{error:P},E,Promise.all(_.map(I=>R7(I))),R7(w),d1e(A,b),Promise.allSettled(T),Promise.allSettled(O)])}},b2t=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:Ix(n,i,r)),w2t=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>Xa(s,{checkOpen:!1})&&!Ya(s)).map(({type:i,value:s,stream:o=s})=>Ix(o,n,e,{isSameDirection:Qo.has(i),stopOnExit:i==="native"}))),T2t=async(t,{signal:e})=>{let[r]=await v2t(t,"error",{signal:e});throw r};var p1e=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),Px=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=au();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},wE=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 A2t}from"stream";import{callbackify as R2t}from"util";import{finished as h1e}from"stream/promises";var I7=async t=>{if(t!==void 0)try{await P7(t)}catch{}},m1e=async t=>{if(t!==void 0)try{await C7(t)}catch{}},P7=async t=>{await h1e(t,{cleanup:!0,readable:!1,writable:!0})},C7=async t=>{await h1e(t,{cleanup:!0,readable:!0,writable:!1})},IU=async(t,e)=>{if(await t,e)throw e},PU=(t,e,r)=>{r&&!OU(r)?t.destroy(r):e&&t.destroy()};var g1e=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||to.has(r),{subprocessStdout:a,waitReadableDestroy:c}=k7(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=N7(a,o),{read:f,onStdoutDataDone:p}=$7({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new A2t({read:f,destroy:R2t(L7.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return D7({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},k7=(t,e,r)=>{let n=mE(t,e),i=Px(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},N7=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:A7},$7=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=au(),o=xU({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){x2t(this,o,s)},onStdoutDataDone:s}},x2t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},D7=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await C7(t),await n,await I7(i),await e,r.readable&&r.push(null)}catch(s){await I7(i),_1e(r,s)}},L7=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await wE(r,e)&&(_1e(t,n),await IU(e,n))},_1e=(t,e)=>{PU(t,t.readable,e)};import{Writable as O2t}from"stream";import{callbackify as y1e}from"util";var S1e=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=M7(t,r,e),o=new O2t({...U7(n,t,i),destroy:y1e(j7.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return F7(n,o),o},M7=(t,e,r)=>{let n=H1(t,e),i=Px(r,n,"writableFinal"),s=Px(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},U7=(t,e,r)=>({write:I2t.bind(void 0,t),final:y1e(P2t.bind(void 0,t,e,r))}),I2t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},P2t=async(t,e,r)=>{await wE(r,e)&&(t.writable&&t.end(),await e)},F7=async(t,e,r)=>{try{await P7(t),e.writable&&e.end()}catch(n){await m1e(r),E1e(e,n)}},j7=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await wE(r,e),await wE(n,e)&&(E1e(t,i),await IU(e,i))},E1e=(t,e)=>{PU(t,t.writable,e)};import{Duplex as C2t}from"stream";import{callbackify as k2t}from"util";var v1e=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||to.has(r),{subprocessStdout:c,waitReadableDestroy:u}=k7(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=M7(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=N7(c,a),{read:g,onStdoutDataDone:y}=$7({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),E=new C2t({read:g,...U7(l,t,d),destroy:k2t(N2t.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 D7({subprocessStdout:c,onStdoutDataDone:y,readable:E,subprocess:t,subprocessStdin:l}),F7(l,E,c),E},N2t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([L7({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),j7({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var z7=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||to.has(e),o=mE(t,r),a=xU({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return $2t(a,o,t)},$2t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var b1e=(t,{encoding:e})=>{let r=p1e();t.readable=g1e.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=S1e.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=v1e.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=z7.bind(void 0,t,e),t[Symbol.asyncIterator]=z7.bind(void 0,t,e,{})};var w1e=(t,e)=>{for(let[r,n]of L2t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},D2t=(async()=>{})().constructor.prototype,L2t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(D2t,t)]);var T1e=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=F2t(t,e,r),{subprocess:f,promise:p}=z2t({file:i,commandArguments:s,options:l,startTime:c,verboseInfo:u,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=RU.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),w1e(f,p),cu.set(f,{options:l,fileDescriptors:d}),f},F2t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=L1(t,e,r),{file:a,commandArguments:c,options:u}=rU(t,e,r),l=j2t(u),d=DMe(l,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},j2t=({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}},z2t=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=U2t(...nU(t,e,r))}catch(h){return CMe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;M2t(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];VMe(c,a,u),GMe(c,r,u);let d={},f=au();c.kill=oDe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=o1e(c,r),b1e(c,r),OMe(c,r);let p=q2t({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:l,command:s,escapedCommand:o,context:d,onInternalError:f,controller:u});return{subprocess:c,promise:p}},q2t=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:s,command:o,escapedCommand:a,context:c,onInternalError:u,controller:l})=>{let[d,[f,p],h,m,g]=await f1e({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:u,controller:l});l.abort(),u.resolve();let y=h.map((_,w)=>kl(_,e,w)),E=kl(m,e,"all"),S=B2t({errorInfo:d,exitCode:f,signal:p,stdio:y,all:E,ipcOutput:g,context:c,options:e,command:o,escapedCommand:a,startTime:r});return EE(S,n,e)},B2t=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,context:o,options:a,command:c,escapedCommand:u,startTime:l})=>"error"in t?Tx({error:t.error,command:c,escapedCommand:u,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof uu,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:l,isSync:!1}):dU({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:s,options:a,startTime:l});var CU=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,V2t(n,t[n],i)]));return{...t,...r}},V2t=(t,e,r)=>H2t.has(t)&&Qr(e)&&Qr(r)?{...e,...r}:r,H2t=new Set(["env",..._Q]);var jf=(t,e,r,n)=>{let i=(o,a,c)=>jf(o,a,r,c),s=(...o)=>G2t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},G2t=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Qr(s))return i(t,CU(r,s),n);let{file:a,commandArguments:c,options:u,isSync:l}=W2t({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return l?bMe(a,c,u):T1e(a,c,u,i)},W2t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=DNe(e)?LNe(e,r):[e,...r],[o,a,c]=A1(...s),u=CU(CU(n,i),c),{file:l=o,commandArguments:d=a,options:f=u,isSync:p=!1}=t({file:o,commandArguments:a,options:u});return{file:l,commandArguments:d,options:f,isSync:p}};var A1e=({file:t,commandArguments:e})=>x1e(t,e),R1e=({file:t,commandArguments:e})=>({...x1e(t,e),isSync:!0}),x1e=(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]=K2t(t);return{file:r,commandArguments:n}},K2t=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(Y2t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},Y2t=/ +/g;var O1e=(t,e,r)=>{t.sync=e(J2t,r),t.s=t.sync},I1e=({options:t})=>P1e(t),J2t=({options:t})=>({...P1e(t),isSync:!0}),P1e=t=>({options:{...Z2t(t),...t}}),Z2t=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},C1e={preferLocal:!0};var k1e=jf(()=>({})),F4r=jf(()=>({isSync:!0})),N1e=jf(A1e),j4r=jf(R1e),z4r=jf(BDe),q4r=jf(I1e,{},C1e,O1e),{sendMessage:B4r,getOneMessage:V4r,getEachMessage:H4r,getCancelSignal:G4r}=IMe();import{Transform as X2t}from"stream";var Q2t=["NETLIFY_AI_GATEWAY_KEY","NETLIFY_API_TOKEN","NETLIFY_AUTH_TOKEN"];function eVt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...Q2t])]}function tVt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function rVt(){let e=eVt().map(r=>process.env[r]).filter(r=>!(!r||tVt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Si(t){if(typeof t!="string")return t;let e=rVt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(nVt(n),"g");r=r.replace(i,"******")}),r}function nVt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Cx=class extends X2t{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Si(i);n(null,s)}},kU=Symbol("maskedWrite");function $1e(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[kU]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Si(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[kU]=!0,process.stdout.write=r}if(!process.stderr.write[kU]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Si(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[kU]=!0,process.stderr.write=r}}}var D1e=!1,L1e,q7=t=>{L1e??=t},M1e=t=>{D1e=!0,q7(t)},en=()=>D1e,ea=()=>L1e,U1e=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var kx=null,F1e=t=>(kx&&kx.destroy(),kx=new ta({totalAllowedTime:t}),kx),j1e=()=>kx;var ta=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&&en())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let s=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),o=null,a=null;n!==void 0&&(a=new Promise((l,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),u="success";try{return await ID({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(l){throw u="failure",l}finally{X.timing("stage.duration",Date.now()-c,{stage:e,outcome:u}),s(),o&&clearTimeout(o)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var z1e={name:"@netlify/agent-runner-cli",type:"module",version:"2.14.0-nb590e7980a5a5.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 aVt=sVt(import.meta.url),cVt=Nl.dirname(aVt),uVt=oVt(import.meta.url),TE=me("shell"),B7=new Set,q1e={preferLocal:!0},Ft=(t,e,r)=>{let[n,i]=lVt(e,r),s={...q1e,...i},o=k1e(t,n,s);V1e(o,s),W1e(o);let a=r?.idleTimeout;return a&&a>0&&G1e(o,a),o},B1e=(t,e)=>{let r={...q1e,...e},n=N1e(t,r);return V1e(n,r),W1e(n),e?.idleTimeout&&e.idleTimeout>0&&G1e(n,e.idleTimeout),n},lVt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},V1e=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||du.env.NETLIFY_LOCAL_QUIET==="true")return;if(du.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Cx).pipe(du.stdout),t.stderr?.pipe(new Cx).pipe(du.stderr);return}t.stdout?.pipe(du.stdout),t.stderr?.pipe(du.stderr)},V7=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(du.kill(-t.pid,e),TE.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return TE.error("Error killing process:",r),!1}},H1e=t=>V7(t,"SIGKILL"),G1e=(t,e)=>{let r=null,n=()=>{TE.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),V7(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(TE.log(`Force killing idle process ${t.pid}`),H1e(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let s=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",s),t.on("error",s)},W1e=t=>{B7.add(t);let e=j1e();if(e){let r=e.onTimesUp(()=>{TE.log(`Global timer expired, killing process ${t.pid}`),V7(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(TE.log(`Force killing process ${t.pid} after timeout`),H1e(t))},5e3)});t.on("exit",()=>{B7.delete(t),r()}),t.on("error",()=>{B7.delete(t),r()})}};function fu(t,e){if(!du.env.NETLIFY_LOCAL_MODE)try{let i=uVt.resolve(z1e.name),s=Nl.dirname(i);for(;s!==Nl.dirname(s);){let o=Nl.dirname(s);if(Nl.basename(o)==="node_modules"){let a=Nl.join(o,".bin",e);if(NU.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(du.env.NODE_PATH){let i=Nl.join(du.env.NODE_PATH,".bin",e);if(NU.existsSync(i))return i}let r=Nl.join(t,"node_modules",".bin",e);if(NU.existsSync(r))return r;let n=Nl.join(cVt,"..","node_modules",".bin",e);if(NU.existsSync(n))return n}import Dq from"process";import{fileURLToPath as PXt}from"url";import{createRequire as CXt}from"module";import CI from"path";import{readFileSync as kXt}from"fs";var dVt="__netlify__getTracer",fVt="__netlify__shutdownTracers",Nt=(t,e)=>globalThis[dVt]?.(t,e),K1e=async()=>globalThis[fVt]?.();function Nx(t,e,r,n,i){let s=typeof n=="function"?n:typeof r=="function"?r:i;if(!s)throw new Error("function to execute with active span is missing");return t?t.withActiveSpan(e,r,n,s):s()}import{createHash as _Xt}from"crypto";import{setTimeout as yXt}from"timers/promises";Me();import o4t from"process";Me();var pVt=(t,e)=>{e.recordException(t),e.setStatus({code:Fn.ERROR})};var $l=class{constructor(e){this._tracer=e,this.startSpan=e.startSpan.bind(this._tracer),this.startActiveSpan=e.startActiveSpan.bind(this._tracer)}withActiveSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=Y1e(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>J1e(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=Y1e(r,n,i),c=this._tracer.startSpan(e,s,o);return J1e(c,s,a)}};function Y1e(t,e,r){let n,i,s;return!e&&!r?s=t:r?(n=t,i=e,s=r):(n=t,s=e),n=n??{},i=i??tr.active(),{opts:n,ctx:i,fn:s}}function J1e(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:pVt,s=o=>{throw i(o,t),t.end(),o};try{let o=r(t);return typeof o?.then=="function"?o.then(a=>(t.end(),a),s):(t.end(),o)}catch(o){throw s(o)}}Me();var RE=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var G7=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=oUe(e),n._asyncAttributesPending=e.filter(([i,s])=>RE(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(RE(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=oUe(this._rawAttributes),this._schemaUrl=hVt(r?.schemaUrl)}get asyncAttributesPending(){return this._asyncAttributesPending}async waitForAsyncAttributes(){if(this.asyncAttributesPending){for(let e=0;e<this._rawAttributes.length;e++){let[r,n]=this._rawAttributes[e];this._rawAttributes[e]=[r,RE(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&ge.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(RE(n)){ge.debug(`Unsettled resource attribute ${r} skipped`);continue}n!=null&&(e[r]??=n)}return this._asyncAttributesPending||(this._memoizedAttributes=e),e}getRawAttributes(){return this._rawAttributes}get schemaUrl(){return this._schemaUrl}merge(e){if(e==null)return this;let r=mVt(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function W7(t,e){return G7.FromAttributeList(Object.entries(t),e)}function oUe(t){return t.map(([e,r])=>RE(r)?[e,r.catch(n=>{ge.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function hVt(t){if(typeof t=="string"||t===void 0)return t;ge.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function mVt(t,e){let r=t?.schemaUrl,n=e?.schemaUrl,i=r===void 0||r==="",s=n===void 0||n==="";if(i)return n;if(s||r===n)return r;ge.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}Me();var $x=class{emit(e){}enabled(){return!1}},aUe=new $x;var Dx=Symbol.for("io.opentelemetry.js.api.logs"),xE=globalThis;function cUe(t,e,r){return n=>n===t?e:r}var K7=1;var Y7=class{getLogger(e,r,n){return new $x}},LU=new Y7;var MU=class{constructor(e,r,n,i){this._provider=e,this.name=r,this.version=n,this.options=i}emit(e){this._getLogger().emit(e)}enabled(e){return this._getLogger().enabled(e)}_getLogger(){if(this._delegate)return this._delegate;let e=this._provider._getDelegateLogger(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):aUe}};var Lx=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new MU(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:LU}_setDelegate(e){this._delegate=e}_getDelegateLogger(e,r,n){var i;return(i=this._delegate)===null||i===void 0?void 0:i.getLogger(e,r,n)}};var UU=class t{constructor(){this._proxyLoggerProvider=new Lx}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return xE[Dx]?this.getLoggerProvider():(xE[Dx]=cUe(K7,e,LU),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=xE[Dx])===null||e===void 0?void 0:e.call(xE,K7))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete xE[Dx],this._proxyLoggerProvider=new Lx}};var uUe=UU.getInstance();function lUe(t,e,r,n){for(let i=0,s=t.length;i<s;i++){let o=t[i];e&&o.setTracerProvider(e),r&&o.setMeterProvider(r),n&&o.setLoggerProvider&&o.setLoggerProvider(n),o.getConfig().enabled||o.enable()}}function dUe(t){t.forEach(e=>e.disable())}function J7(t){let e=t.tracerProvider||Ut.getTracerProvider(),r=t.meterProvider||NR.getMeterProvider(),n=t.loggerProvider||uUe.getLoggerProvider(),i=t.instrumentations?.flat()??[];return lUe(i,e,r,n),()=>{dUe(i)}}Me();var gVt=Un("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function fUe(t){return t.getValue(gVt)===!0}var OE;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(OE||(OE={}));Me();var Z7="[_0-9a-z-*/]",_Vt=`[a-z]${Z7}{0,255}`,yVt=`[a-z0-9]${Z7}{0,240}@[a-z]${Z7}{0,13}`,SVt=new RegExp(`^(?:${_Vt}|${yVt})$`),EVt=/^[ -~]{0,255}[!-~]$/,vVt=/,|=/;function X7(t){return SVt.test(t)}function Q7(t){return EVt.test(t)&&!vVt.test(t)}var bVt=32,pUe=512,hUe=",",mUe="=",FU=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!X7(e)||!Q7(r))return this;let n=this._getState(),i=n.get(e),s=this._length;if(typeof i=="string"?s+=r.length-i.length:s+=e.length+r.length+(n.size>0?2:1),s>pUe)return this;let o=new Map(n);return o.delete(e),o.set(e,r),this._fromState(o,s)}unset(e){let r=this._getState(),n=r.get(e);if(typeof n!="string")return this;let i=this._length-(e.length+n.length+1);r.size>1&&(i=i-1);let s=new Map(r);return s.delete(e),this._fromState(s,i)}get(e){return this._getState().get(e)}serialize(){let e="",r=0;for(let n of this._getState())r>0&&(e=hUe+e),e=`${n[0]}${mUe}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(hUe),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(mUe);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!X7(a)||!Q7(c))continue;let u=n+s.length+(r.size>0?1:0);if(!(u>pUe)&&(r.set(a,c),n=u,r.size>=bVt))break}return this._length=n,this._internalState=new Map(Array.from(r.entries()).reverse()),this._internalState}_fromState(e,r){let n=Object.create(t.prototype);return n._internalState=e,n._length=r,n}};var jU="traceparent",zU="tracestate",wVt="00",TVt="(?!ff)[\\da-f]{2}",AVt="(?![0]{32})[\\da-f]{32}",RVt="(?![0]{16})[\\da-f]{16}",xVt="[\\da-f]{2}",OVt=new RegExp(`^\\s?(${TVt})-(${AVt})-(${RVt})-(${xVt})(-.*)?\\s?$`);function gUe(t){let e=OVt.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var zf=class{inject(e,r,n){let i=Ut.getSpanContext(e);if(!i||fUe(e)||!vs(i))return;let s=`${wVt}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||Or.NONE).toString(16)}`;n.set(r,jU,s),i.traceState&&n.set(r,zU,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,jU);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=gUe(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,zU);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new FU(typeof c=="string"?c:void 0)}return Ut.setSpanContext(e,o)}fields(){return[jU,zU]}};var qU=class{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,r)=>{this._resolve=e,this._reject=r})}get promise(){return this._promise}resolve(e){this._resolve(e)}reject(e){this._reject(e)}};var Mx=class{_isCalled=!1;_deferred=new qU;_callback;_that;constructor(e,r){this._callback=e,this._that=r}get isCalled(){return this._isCalled}get promise(){return this._deferred.promise}call(...e){if(!this._isCalled){this._isCalled=!0;try{Promise.resolve(this._callback.call(this._that,...e)).then(r=>this._deferred.resolve(r),r=>this._deferred.reject(r))}catch(r){this._deferred.reject(r)}}return this._deferred.promise}};var DF=yn(zee(),1);Me();var hze=t=>{throw TypeError(t)},Hee=(t,e,r)=>e.has(t)||hze("Cannot "+r),$F=(t,e,r)=>(Hee(t,e,"read from private field"),r?r.call(t):e.get(t)),qee=(t,e,r)=>e.has(t)?hze("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),dze=(t,e,r,n)=>(Hee(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),s4t=(t,e,r)=>(Hee(t,e,"access private method"),r),fze="__netlify__getTracer",a4t="__netlify__shutdownTracers",c4t="__nfOTLPTrace",rO,nO,Vee,mze,u4t=class{constructor(){qee(this,Vee),qee(this,rO),qee(this,nO),dze(this,rO,new Mx(s4t(this,Vee,mze),this)),dze(this,nO,ge.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if($F(this,nO).debug(`export ${t.length.toString()} spans`),$F(this,rO).isCalled){e({code:OE.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(c4t,JSON.stringify(l4t(t))),e({code:OE.SUCCESS})}shutdown(){return $F(this,rO).call()}};rO=new WeakMap;nO=new WeakMap;Vee=new WeakSet;mze=function(){return $F(this,nO).debug("Shutting down"),Promise.resolve()};function l4t(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:NF(e.resource.attributes),droppedAttributesCount:e.droppedAttributesCount},scopeSpans:[{scope:{name:e.instrumentationScope.name,version:e.instrumentationScope.version},spans:[{traceId:r.traceId,spanId:r.spanId,parentSpanId:e.parentSpanContext?.spanId,name:e.name,kind:e.kind||Va.SERVER,startTimeUnixNano:Bee(e.startTime),endTimeUnixNano:Bee(e.endTime),attributes:NF(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:Bee(n.time),attributes:NF(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedEventsCount:e.droppedEventsCount,status:{code:e.status.code,message:e.status.message},links:e.links.map(n=>({spanId:n.context.spanId,traceId:n.context.traceId,attributes:NF(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function NF(t){return Object.keys(t).map(e=>gze(e,t[e]))}function gze(t,e){return{key:t,value:_ze(e)}}function _ze(t){let e=typeof t;return e==="string"?{stringValue:t}:e==="number"?Number.isInteger(t)?{intValue:t}:{doubleValue:t}:e==="boolean"?{boolValue:t}:t instanceof Uint8Array?{bytesValue:t}:Array.isArray(t)?{arrayValue:{values:t.map(_ze)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>gze(r,n))}}:{}}function Bee(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var pze={name:"@netlify/otel",version:"6.0.6",type:"module",engines:{node:"^18.14.0 || >=20.6.1"},main:"./dist/main.cjs",module:"./dist/main.js",types:"./dist/main.d.ts",exports:{".":{require:{types:"./dist/main.d.cts",default:"./dist/main.cjs"},import:{types:"./dist/main.d.ts",default:"./dist/main.js"},default:{types:"./dist/main.d.ts",default:"./dist/main.js"}},"./package.json":"./package.json","./bootstrap":{require:{types:"./dist/bootstrap/main.d.cts",default:"./dist/bootstrap/main.cjs"},import:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"},default:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"}},"./exporter-netlify":{require:{types:"./dist/exporters/netlify.d.cts",default:"./dist/exporters/netlify.cjs"},import:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"},default:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"}},"./instrumentation-fetch":{require:{types:"./dist/instrumentations/fetch.d.cts",default:"./dist/instrumentations/fetch.cjs"},import:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"},default:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"}},"./instrumentation-http":{require:{types:"./dist/instrumentations/http.d.cts",default:"./dist/instrumentations/http.cjs"},import:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"},default:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"}},"./opentelemetry":{require:{types:"./dist/opentelemetry.d.cts",default:"./dist/opentelemetry.cjs"},import:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"},default:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"}}},files:["dist/**/*"],scripts:{build:"tsup-node",dev:"tsup-node --watch",prepack:"npm run build",test:"run-s build test:ci","test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"vitest","test:dev:vitest:watch":"vitest watch","test:ci:vitest":"vitest run",publint:"npx -y publint --strict"},keywords:["netlify","cdn"],license:"MIT",repository:{type:"git",url:"https://github.com/netlify/primitives.git",directory:"packages/otel"},bugs:{url:"https://github.com/netlify/primitives/issues"},author:"Netlify Inc.",devDependencies:{"@netlify/dev-utils":"^5.0.0",msw:"^2.10.5","npm-run-all2":"^7.0.2",tsup:"^8.0.0",vitest:"^3.0.0"},dependencies:{"@opentelemetry/api":"1.9.1","@opentelemetry/core":"2.8.0","@opentelemetry/instrumentation":"^0.220.0","@opentelemetry/resources":"2.9.0","@opentelemetry/sdk-trace-node":"2.9.0"}},yze=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,fze))return;let e=o4t.version.slice(1),r=W7({"service.name":t.serviceName,"service.version":t.serviceVersion,"process.runtime.name":"nodejs","process.runtime.version":e,"deployment.environment":t.deploymentEnvironment,"http.url":t.siteUrl,"netlify.site.id":t.siteId,"netlify.site.name":t.siteName}),n=t.spanProcessors??[d4t()],i=new DF.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new zf});let s=t.instrumentations??[];J7({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,fze,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new $l(Ut.getTracer(a,c)):new $l(Ut.getTracer(pze.name,pze.version))}}),Object.defineProperty(globalThis,a4t,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},d4t=()=>new DF.SimpleSpanProcessor(new u4t);Me();var jE=yn(zee(),1);Me();import*as LF from"diagnostics_channel";var Sze=class{constructor(t={}){this.instrumentationName="@netlify/otel/instrumentation-fetch",this.instrumentationVersion="1.0.0",this._recordFromReq=new WeakMap,this.config=t,this._channelSubs=[]}getConfig(){return this.config}setConfig(){}setMeterProvider(){}setTracerProvider(t){this.provider=t}getTracerProvider(){return this.provider}annotateFromRequest(t,e){let r=this.config.getRequestAttributes?.(e)??{},n=new URL(e.path,e.origin);t.setAttributes({...r,"http.request.method":e.method,"url.full":n.href,"url.host":n.host,"url.scheme":n.protocol.slice(0,-1),"server.address":n.hostname,"server.port":n.port,...this.prepareHeaders("request",e.headers)})}annotateFromResponse(t,e){let r=this.config.getResponseAttributes?.(e)??{};t.setAttributes({...r,"http.response.status_code":e.statusCode,...this.prepareHeaders("response",e.headers)}),t.setStatus({code:e.statusCode>=400?Fn.ERROR:Fn.UNSET})}prepareHeaders(t,e){if(!Array.isArray(e))return{};if(this.config.skipHeaders===!0)return{};let r=["*","/.*/"],n=this.config.skipHeaders??[],i=this.config.redactHeaders??[],s=n.some(a=>r.includes(a.toString())),o={};if(s)return o;for(let a=0;a+1<e.length;a=a+2){let c=e[a],u=e[a+1];if(typeof c!="string"&&!Buffer.isBuffer(c)||typeof u!="string"&&!Buffer.isBuffer(u))continue;let l=c.toString().toLowerCase();if(n.some(f=>typeof f=="string"?f==l:f.test(l)))continue;let d=`http.${t}.header.${l}`;i===!0||i.some(f=>typeof f=="string"?f==l:f.test(l))?o[d]="REDACTED":o[d]=u.toString()}return o}getRequestMethod(t){return["HEAD","GET","POST","PUT","PATCH","DELETE"].includes(t.toUpperCase())?t.toUpperCase():"_OTHER"}getTracer(){if(!this.provider)return;let t=this.provider.getTracer(this.instrumentationName,this.instrumentationVersion);return t instanceof $l?t:new $l(t)}enable(){this._channelSubs.length>0||(this.subscribe("undici:request:create",this.onRequestCreate.bind(this)),this.subscribe("undici:request:headers",this.onRequestHeaders.bind(this)),this.subscribe("undici:request:trailers",this.onRequestEnd.bind(this)),this.subscribe("undici:request:error",this.onRequestError.bind(this)))}subscribe(t,e){LF.subscribe(t,e);let r=()=>LF.unsubscribe(t,e);this._channelSubs.push({name:t,unsubscribe:r})}disable(){this._channelSubs.forEach(t=>{t.unsubscribe()}),this._channelSubs.length=0}onRequestCreate({request:t}){try{let e=this.getTracer(),r=new URL(t.path,t.origin);if(!e||t.method==="CONNECT"||this.config.skipURLs?.some(i=>typeof i=="string"?r.href.startsWith(i):i.test(r.href)))return;let n=e.startSpan(this.getRequestMethod(t.method),{kind:Va.CLIENT},tr.active());this.annotateFromRequest(n,t),this._recordFromReq.set(t,n)}catch{}}onRequestHeaders({request:t,response:e}){try{let r=this._recordFromReq.get(t);if(!r)return;this.annotateFromResponse(r,e)}catch{}}onRequestError({request:t,error:e}){try{let r=this._recordFromReq.get(t);if(!r)return;r.recordException(e),r.setStatus({code:Fn.ERROR,message:e.message}),r.end(),this._recordFromReq.delete(t)}catch{}}onRequestEnd({request:t}){try{let e=this._recordFromReq.get(t);if(!e)return;e.end(),this._recordFromReq.delete(t)}catch{}}};var aWe=yn(nWe(),1);Me();jse();var iWe=0;var mXt=3*1024*1024,gXt=t=>RI.serializeRequest([t])?.byteLength??Number.POSITIVE_INFINITY,Nq=class{constructor(e,r=mXt){this.inner=e;this.maxBytes=r}export(e,r){let n=[],i=[],s=0;for(let c of e){let u=gXt(c);i.length&&s+u>this.maxBytes&&(n.push(i),i=[],s=0),i.push(c),s+=u}i.length&&n.push(i);let o,a=c=>{if(c===n.length){r(o??{code:iWe});return}this.inner.export(n[c],u=>{u.code!==iWe&&(o??=u),a(c+1)})};a(0)}shutdown(){return this.inner.shutdown()}forceFlush(){return this.inner.forceFlush?.()??Promise.resolve()}};var jv=me("tracing"),sWe=8e3,SXt=5e3,oWe=t=>t.length>sWe?`${t.slice(0,sWe)}\u2026`:t,zv={maxQueueSize:20480,maxExportBatchSize:128,scheduledDelayMillis:1e3},EXt=Math.ceil(zv.maxQueueSize/zv.maxExportBatchSize)+1,cWe=0,Bse=()=>cWe,vXt=t=>{let e=0,r=new Nq(new aWe.OTLPTraceExporter({url:t,concurrencyLimit:EXt})),n=new jE.BatchSpanProcessor({export:(i,s)=>{e=Math.max(0,e-i.length),r.export(i,s)},shutdown:()=>r.shutdown(),forceFlush:()=>r.forceFlush()},zv);return{onStart:(i,s)=>n.onStart(i,s),onEnd:i=>{i.spanContext().traceFlags&Or.SAMPLED&&(e>=zv.maxQueueSize?cWe+=1:e+=1),n.onEnd(i)},forceFlush:()=>n.forceFlush(),shutdown:()=>n.shutdown()}},wg=async(t=SXt)=>{try{let e=Symbol("timed out");await Promise.race([K1e(),yXt(t,e)])===e&&jv.warn(`Tracer flush did not finish in ${t} ms; unsent spans are lost`)}catch(e){jv.warn("Failed to flush tracers on shutdown",e)}},uWe=async(t,e,r)=>{if(!Nt()){let n=[new jE.SimpleSpanProcessor(new qse),vXt(r.exporterUrl)];await yze({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new Sze({skipHeaders:!0})]})}return r.traceparent?(Yi.setGlobalPropagator(new zf),Yi.extract(tr.active(),{traceparent:r.traceparent,isRemote:!0})):tr.active()};function fr(t,e,r){return jv.log(`\u23F3 TRACE: ${e} starting...`),Nx(t,e,r)}var qse=class{export(e,r){for(let n of e)this.logSpan(n);r({code:1})}async shutdown(){}forceFlush(){return Promise.resolve()}logSpan(e){let r=(e.endTime[0]-e.startTime[0])*1e3+(e.endTime[1]-e.startTime[1])/1e6,n=e.attributes,i=[];for(let[a,c]of Object.entries(n))a.includes("duration")&&typeof c=="number"?i.push(`${a}=${c.toFixed(2)}ms`):i.push(`${a}=${c}`);let s=e.status?.code===2?"\u274C":"\u2705",o=i.length>0?` [${i.join(", ")}]`:"";jv.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&jv.log(` \u274C Error: ${e.status.message}`)}};function Vse(){return Ye().captureLlmContentEnabled}function lWe(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")||t.includes("antigravity")?"google":t.includes("muse")?"meta":t.includes("opencode")?"opencode":t}function $q(t,e,r){let n={role:t,parts:[{type:"text",content:Si(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var bXt=new Set([ee.Task,ee.RunCommand,ee.Explore,ee.FileRead,ee.FileWrite,ee.Notebook,ee.Web,ee.Todo,ee.Skill,ee.Tool,ee.Memorize,ee.Deployment,ee.SiteGeneration]),wXt=new Set(["claude","codex"]),TXt=(t,e)=>JSON.stringify([t,e.operation,e.path??null]),AXt=t=>_Xt("sha256").update(t.map(e=>Buffer.from(e)).sort(Buffer.compare).join(`
597
+ if (condition) { yield value; }`)};import{Buffer as gqt}from"buffer";import{StringDecoder as _qt}from"string_decoder";var _U=(t,e,r)=>{if(r)return;if(t)return{transform:yqt.bind(void 0,new TextEncoder)};let n=new _qt(e);return{transform:Sqt.bind(void 0,n),final:Eqt.bind(void 0,n)}},yqt=function*(t,e){gqt.isBuffer(e)?yield Il(e):typeof e=="string"?yield t.encode(e):yield e},Sqt=function*(t,e){yield Tn(e)?t.write(e):e},Eqt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as oMe}from"util";var s7=oMe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),yU=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=bqt}=e[r];for await(let i of n(t))yield*yU(i,e,r+1)},aMe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*vqt(r,Number(e),t)},vqt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*yU(n,r,e+1)},cMe=oMe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),bqt=function*(t){yield t};var o7=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},uMe=(t,e)=>[...e.flatMap(r=>[...jm(r,t,0)]),...Ax(t)],jm=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Tqt}=e[r];for(let i of n(t))yield*jm(i,e,r+1)},Ax=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*wqt(r,Number(e),t)},wqt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*jm(n,r,e+1)},Tqt=function*(t){yield t};var a7=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=dMe(t,o,s),u=Fm(e),l=Fm(r),d=u?s7.bind(void 0,yU,a):o7.bind(void 0,jm),f=u||l?s7.bind(void 0,aMe,a):o7.bind(void 0,Ax),p=u||l?cMe.bind(void 0,a):void 0;return{stream:new Aqt({writableObjectMode:n,writableHighWaterMark:lMe(n),readableObjectMode:i,readableHighWaterMark:lMe(i),transform(m,g,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},SU=(t,e,r,n)=>{let i=e.filter(({type:o})=>o==="generator"),s=n?i.reverse():i;for(let{value:o,optionName:a}of s){let c=dMe(o,r,a);t=uMe(c,t)}return t},dMe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:nMe(n,a)},_U(r,o,n),gU(r,s,n,c),{transform:t,final:e},{transform:iMe(i,a)},rMe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var fMe=(t,e)=>{for(let r of Rqt(t))xqt(t,r,e)},Rqt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),xqt=(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 ${Ff[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>Oqt(a,n));r.input=mx(o)},Oqt=(t,e)=>{let r=SU(t,e,"utf8",!0);return Iqt(r),mx(r)},Iqt=t=>{let e=t.find(r=>typeof r!="string"&&!Tn(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 Nqt,appendFileSync as $qt}from"fs";var EU=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&lE(r,n)&&!to.has(e)&&Pqt(n)&&(t.some(({type:i,value:s})=>i==="native"&&Cqt.has(s))||t.every(({type:i})=>Qo.has(i))),Pqt=t=>t===1||t===2,Cqt=new Set(["pipe","overlapped"]),pMe=async(t,e,r,n)=>{for await(let i of t)kqt(e)||mMe(i,r,n)},hMe=(t,e,r)=>{for(let n of t)mMe(n,e,r)},kqt=t=>t._readableState.pipes.length>0,mMe=(t,e,r)=>{let n=$1(t);ou({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var gMe=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let s={},o=new Set([]);return{output:e.map((c,u)=>Dqt({result:c,fileDescriptors:t,fdNumber:u,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},Dqt=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:c,lines:u,stripFinalNewline:l,maxBuffer:d})=>{if(t===null)return;let f=_Le(t,s,d),p=Il(f),{stdioItems:h,objectMode:m}=e[r],g=Lqt([p],h,c,n),{serializedResult:y,finalResult:E=y}=Mqt({chunks:g,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});Uqt({serializedResult:y,fdNumber:r,state:n,verboseInfo:o,encoding:c,stdioItems:h,objectMode:m});let S=a[r]?E:void 0;try{return n.error===void 0&&Fqt(y,h,i),S}catch(_){return n.error=_,S}},Lqt=(t,e,r,n)=>{try{return SU(t,e,r,!1)}catch(i){return n.error=i,t}},Mqt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:mx(t)};let o=CNe(t,r);return n[s]?{serializedResult:o,finalResult:i7(o,!i[s],e)}:{serializedResult:o}},Uqt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!EU({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=i7(t,!1,o);try{hMe(a,e,n)}catch(c){r.error??=c}},Fqt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>hU.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?$qt(n,t):(r.add(s),Nqt(n,t))}};var _Me=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,kl(e,r,"all")]:Array.isArray(e)?[kl(t,r,"all"),...e]:Tn(t)&&Tn(e)?pQ([t,e]):`${t}${e}`};import{once as c7}from"events";var yMe=async(t,e)=>{let[r,n]=await jqt(t);return e.isForcefullyTerminated??=!1,[r,n]},jqt=async t=>{let[e,r]=await Promise.allSettled([c7(t,"spawn"),c7(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?SMe(t):r.value},SMe=async t=>{try{return await c7(t,"exit")}catch{return SMe(t)}},EMe=async t=>{let[e,r]=await t;if(!zqt(e,r)&&u7(e,r))throw new Ja;return[e,r]},zqt=(t,e)=>t===void 0&&e===void 0,u7=(t,e)=>t!==0||e!==null;var vMe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=qqt(t,e,r),o=s?.code==="ETIMEDOUT",a=gLe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},qqt=(t,e,r)=>t!==void 0?t:u7(e,r)?new Ja:void 0;var bMe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=Vqt(t,e,r),d=Wqt({file:n,commandArguments:i,options:u,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:l,startTime:a});return EE(d,c,u)},Vqt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=L1(t,e,r),a=Hqt(r),{file:c,commandArguments:u,options:l}=rU(t,e,a);Gqt(l);let d=XLe(l,o);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},Hqt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Gqt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&vU("ipcInput"),t&&vU("ipc: true"),r&&vU("detached: true"),n&&vU("cancelSignal")},vU=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Wqt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=Kqt({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:a});if(c.failed)return c;let{resultError:u,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p}=vMe(c,r),{output:h,error:m=u}=gMe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),g=h.map((E,S)=>kl(E,r,S)),y=kl(_Me(h,r),r,"all");return Jqt({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:y,options:r,command:n,escapedCommand:i,startTime:a})},Kqt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{fMe(s,r);let a=Yqt(r);return Bqt(...nU(t,e,a))}catch(a){return SE({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},Yqt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:lU(e)}),Jqt=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:s,all:o,options:a,command:c,escapedCommand:u,startTime:l})=>t===void 0?dU({command:c,escapedCommand:u,stdio:s,all:o,ipcOutput:[],options:a,startTime:l}):Tx({error:t,command:c,escapedCommand:u,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:l,isSync:!0});import{setMaxListeners as M2t}from"events";import{spawn as U2t}from"child_process";import xMe from"process";import{once as l7,on as Zqt}from"events";var wMe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(pE({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:J1(t)}),Xqt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),Xqt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{G1(e,i);let s=Uf(t,e,r),o=new AbortController;try{return await Promise.race([Qqt(s,n,o),eBt(s,r,o),tBt(s,r,o)])}catch(a){throw hE(t),a}finally{o.abort(),W1(e,i)}},Qqt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await l7(t,"message",{signal:r});return n}for await(let[n]of Zqt(t,"message",{signal:r}))if(e(n))return n},eBt=async(t,e,{signal:r})=>{await l7(t,"disconnect",{signal:r}),uDe(e)},tBt=async(t,e,{signal:r})=>{let[n]=await l7(t,"strict:error",{signal:r});throw B1(n,e)};import{once as AMe,on as rBt}from"events";var RMe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>d7({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),d7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{pE({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:J1(t)}),G1(e,s);let o=Uf(t,e,r),a=new AbortController,c={};return nBt(t,o,a),iBt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),sBt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},nBt=async(t,e,r)=>{try{await AMe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},iBt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await AMe(t,"strict:error",{signal:r.signal});n.error=B1(i,e),r.abort()}catch{}},sBt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of rBt(r,"message",{signal:s.signal}))TMe(o),yield c}catch{TMe(o)}finally{s.abort(),W1(e,a),n||hE(t),i&&await t}},TMe=({error:t})=>{if(t)throw t};var OMe=(t,{ipc:e})=>{Object.assign(t,PMe(t,!1,e))},IMe=()=>{let t=xMe,e=!0,r=xMe.channel!==void 0;return{...PMe(t,e,r),getCancelSignal:LDe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},PMe=(t,e,r)=>({sendMessage:eU.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:wMe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:RMe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as oBt}from"child_process";import{PassThrough as aBt,Readable as cBt,Writable as uBt,Duplex as lBt}from"stream";var CMe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{t7(n);let a=new oBt;dBt(a,n),Object.assign(a,{readable:fBt,writable:pBt,duplex:hBt});let c=SE({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),u=mBt(c,o,i);return{subprocess:a,promise:u}},dBt=(t,e)=>{let r=Rx(),n=Rx(),i=Rx(),s=Array.from({length:e.length-3},Rx),o=Rx(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},Rx=()=>{let t=new aBt;return t.end(),t},fBt=()=>new cBt({read(){}}),pBt=()=>new uBt({write(){}}),hBt=()=>new lBt({read(){},write(){}}),mBt=async(t,e,r)=>EE(t,e,r);import{createReadStream as kMe,createWriteStream as NMe}from"fs";import{Buffer as gBt}from"buffer";import{Readable as xx,Writable as _Bt,Duplex as yBt}from"stream";var DMe=(t,e)=>mU(SBt,t,e,!1),Ox=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${Ff[t]}.`)},$Me={fileNumber:Ox,generator:a7,asyncGenerator:a7,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:yBt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},SBt={input:{...$Me,fileUrl:({value:t})=>({stream:kMe(t)}),filePath:({value:{file:t}})=>({stream:kMe(t)}),webStream:({value:t})=>({stream:xx.fromWeb(t)}),iterable:({value:t})=>({stream:xx.from(t)}),asyncIterable:({value:t})=>({stream:xx.from(t)}),string:({value:t})=>({stream:xx.from(t)}),uint8Array:({value:t})=>({stream:xx.from(gBt.from(t))})},output:{...$Me,fileUrl:({value:t})=>({stream:NMe(t)}),filePath:({value:{file:t,append:e}})=>({stream:NMe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:_Bt.fromWeb(t)}),iterable:Ox,asyncIterable:Ox,string:Ox,uint8Array:Ox}};import{on as EBt,once as LMe}from"events";import{PassThrough as vBt,getDefaultHighWaterMark as bBt}from"stream";import{finished as FMe}from"stream/promises";function zm(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)p7(i);let e=t.some(({readableObjectMode:i})=>i),r=wBt(t,e),n=new f7({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var wBt=(t,e)=>{if(t.length===0)return bBt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},f7=class extends vBt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(p7(e),this.#e.has(e))return;this.#e.add(e),this.#n??=TBt(this,this.#e,this.#s);let r=xBt({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#s});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(p7(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)}},TBt=async(t,e,r)=>{bU(t,MMe);let n=new AbortController;try{await Promise.race([ABt(t,n),RBt(t,e,r,n)])}finally{n.abort(),bU(t,-MMe)}},ABt=async(t,{signal:e})=>{try{await FMe(t,{signal:e,cleanup:!0})}catch(r){throw jMe(t,r),r}},RBt=async(t,e,r,{signal:n})=>{for await(let[i]of EBt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},p7=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},xBt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{bU(t,UMe);let a=new AbortController;try{await Promise.race([OBt(s,e,a),IBt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),PBt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),bU(t,-UMe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?h7(t):CBt(t))},OBt=async(t,e,{signal:r})=>{try{await t,r.aborted||h7(e)}catch(n){r.aborted||jMe(e,n)}},IBt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await FMe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;zMe(o)?i.add(e):qMe(t,o)}},PBt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await LMe(t,i,{signal:s}),!t.readable)return LMe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},CBt=t=>{t.writable&&t.end()},jMe=(t,e)=>{zMe(e)?h7(t):qMe(t,e)},zMe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",h7=t=>{(t.readable||t.writable)&&t.destroy()},qMe=(t,e)=>{t.destroyed||(t.once("error",kBt),t.destroy(e))},kBt=()=>{},bU=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},MMe=2,UMe=1;import{finished as BMe}from"stream/promises";var bE=(t,e)=>{t.pipe(e),NBt(t,e),$Bt(t,e)},NBt=async(t,e)=>{if(!(Ya(t)||Ya(e))){try{await BMe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}m7(e)}},m7=t=>{t.writable&&t.end()},$Bt=async(t,e)=>{if(!(Ya(t)||Ya(e))){try{await BMe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}g7(t)}},g7=t=>{t.readable&&t.destroy()};var VMe=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:s,direction:o}]of Object.entries(e)){for(let{stream:a}of s.filter(({type:c})=>Qo.has(c)))DBt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Qo.has(c)))MBt({subprocess:t,stream:a,direction:o,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,s]of n.entries()){let o=s.length===1?s[0]:zm(s);bE(o,i)}},DBt=(t,e,r,n)=>{r==="output"?bE(t.stdio[n],e):bE(e,t.stdio[n]);let i=LBt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},LBt=["stdin","stdout","stderr"],MBt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;UBt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},UBt=(t,{signal:e})=>{Ya(t)&&Mm(t,FBt,e)},FBt=2;import{addAbortListener as qBt}from"events";var qm=[];qm.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&qm.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&qm.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var wU=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",_7=Symbol.for("signal-exit emitter"),y7=globalThis,jBt=Object.defineProperty.bind(Object),S7=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(y7[_7])return y7[_7];jBt(y7,_7,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let s of this.listeners[e])i=s(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},TU=class{},zBt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),E7=class extends TU{onExit(){return()=>{}}load(){}unload(){}},v7=class extends TU{#e=b7.platform==="win32"?"SIGINT":"SIGHUP";#r=new S7;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of qm)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,s=e;if(typeof s.__signal_exit_emitter__=="object"&&typeof s.__signal_exit_emitter__.count=="number"&&(i+=s.__signal_exit_emitter__.count),n.length===i){this.unload();let o=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;o||e.kill(e.pid,a)}};this.#s=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!wU(this.#t))return()=>{};this.#o===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#r.on(n,e),()=>{this.#r.removeListener(n,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#o){this.#o=!0,this.#r.count+=1;for(let e of qm)try{let r=this.#i[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#o&&(this.#o=!1,qm.forEach(e=>{let r=this.#i[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#s,this.#r.count-=1)}#a(e){return wU(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#s.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&wU(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)}},b7=globalThis.process,{onExit:HMe,load:Y2r,unload:J2r}=zBt(wU(b7)?new v7(b7):new E7);var GMe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=HMe(()=>{t.kill()});qBt(n,()=>{i()})};var KMe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=D1(),{destination:o,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=BBt(r,n,i),{sourceStream:d,sourceError:f}=HBt(t,u),{options:p,fileDescriptors:h}=cu.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:s}},BBt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=VBt(t,e,...r),a=H1(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},VBt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(WMe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||dQ(r)){if(Object.keys(t).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[i,s,o]=A1(r,...n);return{destination:e(WMe)(i,s,o),pipeOptions:o}}if(cu.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}`)},WMe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),HBt=(t,e)=>{try{return{sourceStream:mE(t,e)}}catch(r){return{sourceError:r}}};var JMe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=GBt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw w7({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},GBt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return g7(t),n;if(e!==void 0)return m7(r),e},w7=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>SE({error:t,command:YMe,escapedCommand:YMe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),YMe="source.pipe(destination)";var ZMe=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:s,value:o=s}]=await t;if(o.pipedFrom.includes(n)||o.pipedFrom.push(n),i==="rejected")throw o;if(e==="rejected")throw n;return o};import{finished as WBt}from"stream/promises";var XMe=(t,e,r)=>{let n=AU.has(e)?YBt(t,e):KBt(t,e);return Mm(t,ZBt,r.signal),Mm(e,XBt,r.signal),JBt(e),n},KBt=(t,e)=>{let r=zm([t]);return bE(r,e),AU.set(e,r),r},YBt=(t,e)=>{let r=AU.get(e);return r.add(t),r},JBt=async t=>{try{await WBt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}AU.delete(t)},AU=new WeakMap,ZBt=2,XBt=1;import{aborted as QBt}from"util";var QMe=(t,e)=>t===void 0?[]:[e2t(t,e)],e2t=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await QBt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw w7({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var RU=(t,...e)=>{if(Qr(e[0]))return RU.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=KMe(t,...e),i=t2t({...n,destination:r});return i.pipe=RU.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},t2t=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=r2t(t,i);JMe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=XMe(e,s,d);return await Promise.race([ZMe(l),...QMe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},r2t=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as u2t}from"timers/promises";import{on as n2t}from"events";import{getDefaultHighWaterMark as i2t}from"stream";var xU=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return s2t(e,o),t1e({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},s2t=async(t,e)=>{try{await t}catch{}finally{e.abort()}},T7=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;o2t(e,o,t);let a=t.readableObjectMode&&!s;return t1e({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},o2t=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},t1e=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=n2t(t,"data",{signal:e.signal,highWaterMark:e1e,highWatermark:e1e});return a2t({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},A7=i2t(!0),e1e=A7,a2t=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=c2t({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*jm(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*Ax(a)}},c2t=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[_U(t,r,!e),gU(t,i,!n,{})].filter(Boolean);var r1e=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:c,verboseInfo:u,streamInfo:l})=>{let d=l2t({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([d2t(t),d]);return}let f=r7(c,r),p=T7({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([f2t({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},l2t=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!EU({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=T7({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await pMe(a,t,r,s)},d2t=async t=>{await u2t(),t.readableFlowing===null&&t.resume()},f2t=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await aU(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await cU(r,{maxBuffer:s})):await yE(r,{maxBuffer:s})}catch(a){return n1e(pLe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},R7=async t=>{try{return await t}catch(e){return n1e(e)}},n1e=({bufferedData:t})=>INe(t)?new Uint8Array(t):t;import{finished as p2t}from"stream/promises";var Ix=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=h2t(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],p2t(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||_2t(a,e,r,n)}finally{o.abort()}},h2t=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&m2t(t,r,n),n},m2t=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{g2t(e,r),n.call(t,...i)}},g2t=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},_2t=(t,e,r,n)=>{if(!y2t(t,e,r,n))throw t},y2t=(t,e,r,n=!0)=>r.propagating?i1e(t)||OU(t):(r.propagating=!0,x7(r,e)===n?i1e(t):OU(t)),x7=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",OU=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",i1e=t=>t?.code==="EPIPE";var s1e=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,u)=>O7({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),O7=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:u})=>{if(!t)return;let l=Ix(t,e,u);if(x7(u,e)){await l;return}let[d]=await Promise.all([r1e({stream:t,onStreamEnd:l,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:c,streamInfo:u}),l]);return d};var o1e=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?zm([t,e].filter(Boolean)):void 0,a1e=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>O7({...S2t(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:E2t(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),S2t=({stdout:t,stderr:e,all:r},[,n,i])=>{let s=n||i;return s?n?i?{stream:r,buffer:s}:{stream:t,buffer:s}:{stream:e,buffer:s}:{stream:r,buffer:s}},E2t=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as v2t}from"events";var c1e=t=>lE(t,"ipc"),u1e=(t,e)=>{let r=$1(t);ou({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var l1e=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=c1e(s),a=Pl(e,"ipc"),c=Pl(r,"ipc");for await(let u of d7({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(hLe(t,i,c),i.push(u)),o&&u1e(u,s);return i},d1e=async(t,e)=>(await Promise.allSettled([t]),e);var f1e=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:u,ipc:l,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:g,controller:y})=>{let E=yMe(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:E,propagating:!1},_=s1e({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:S}),w=a1e({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:S}),b=[],A=l1e({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:b,verboseInfo:p}),T=b2t(m,t,S),O=w2t(h,S);try{return await Promise.race([Promise.all([{},EMe(E),Promise.all(_),w,A,GDe(t,d),...T,...O]),g,T2t(t,y),...zDe(t,s,f,y),...cDe({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...FDe({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(P){return f.terminationReason??="other",Promise.all([{error:P},E,Promise.all(_.map(I=>R7(I))),R7(w),d1e(A,b),Promise.allSettled(T),Promise.allSettled(O)])}},b2t=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:Ix(n,i,r)),w2t=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>Xa(s,{checkOpen:!1})&&!Ya(s)).map(({type:i,value:s,stream:o=s})=>Ix(o,n,e,{isSameDirection:Qo.has(i),stopOnExit:i==="native"}))),T2t=async(t,{signal:e})=>{let[r]=await v2t(t,"error",{signal:e});throw r};var p1e=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),Px=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=au();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},wE=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 A2t}from"stream";import{callbackify as R2t}from"util";import{finished as h1e}from"stream/promises";var I7=async t=>{if(t!==void 0)try{await P7(t)}catch{}},m1e=async t=>{if(t!==void 0)try{await C7(t)}catch{}},P7=async t=>{await h1e(t,{cleanup:!0,readable:!1,writable:!0})},C7=async t=>{await h1e(t,{cleanup:!0,readable:!0,writable:!1})},IU=async(t,e)=>{if(await t,e)throw e},PU=(t,e,r)=>{r&&!OU(r)?t.destroy(r):e&&t.destroy()};var g1e=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||to.has(r),{subprocessStdout:a,waitReadableDestroy:c}=k7(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=N7(a,o),{read:f,onStdoutDataDone:p}=$7({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new A2t({read:f,destroy:R2t(L7.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return D7({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},k7=(t,e,r)=>{let n=mE(t,e),i=Px(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},N7=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:A7},$7=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=au(),o=xU({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){x2t(this,o,s)},onStdoutDataDone:s}},x2t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},D7=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await C7(t),await n,await I7(i),await e,r.readable&&r.push(null)}catch(s){await I7(i),_1e(r,s)}},L7=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await wE(r,e)&&(_1e(t,n),await IU(e,n))},_1e=(t,e)=>{PU(t,t.readable,e)};import{Writable as O2t}from"stream";import{callbackify as y1e}from"util";var S1e=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=M7(t,r,e),o=new O2t({...U7(n,t,i),destroy:y1e(j7.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return F7(n,o),o},M7=(t,e,r)=>{let n=H1(t,e),i=Px(r,n,"writableFinal"),s=Px(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},U7=(t,e,r)=>({write:I2t.bind(void 0,t),final:y1e(P2t.bind(void 0,t,e,r))}),I2t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},P2t=async(t,e,r)=>{await wE(r,e)&&(t.writable&&t.end(),await e)},F7=async(t,e,r)=>{try{await P7(t),e.writable&&e.end()}catch(n){await m1e(r),E1e(e,n)}},j7=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await wE(r,e),await wE(n,e)&&(E1e(t,i),await IU(e,i))},E1e=(t,e)=>{PU(t,t.writable,e)};import{Duplex as C2t}from"stream";import{callbackify as k2t}from"util";var v1e=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||to.has(r),{subprocessStdout:c,waitReadableDestroy:u}=k7(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=M7(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=N7(c,a),{read:g,onStdoutDataDone:y}=$7({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),E=new C2t({read:g,...U7(l,t,d),destroy:k2t(N2t.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 D7({subprocessStdout:c,onStdoutDataDone:y,readable:E,subprocess:t,subprocessStdin:l}),F7(l,E,c),E},N2t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([L7({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),j7({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var z7=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||to.has(e),o=mE(t,r),a=xU({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return $2t(a,o,t)},$2t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var b1e=(t,{encoding:e})=>{let r=p1e();t.readable=g1e.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=S1e.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=v1e.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=z7.bind(void 0,t,e),t[Symbol.asyncIterator]=z7.bind(void 0,t,e,{})};var w1e=(t,e)=>{for(let[r,n]of L2t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},D2t=(async()=>{})().constructor.prototype,L2t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(D2t,t)]);var T1e=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=F2t(t,e,r),{subprocess:f,promise:p}=z2t({file:i,commandArguments:s,options:l,startTime:c,verboseInfo:u,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=RU.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),w1e(f,p),cu.set(f,{options:l,fileDescriptors:d}),f},F2t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=L1(t,e,r),{file:a,commandArguments:c,options:u}=rU(t,e,r),l=j2t(u),d=DMe(l,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},j2t=({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}},z2t=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=U2t(...nU(t,e,r))}catch(h){return CMe({error:h,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;M2t(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];VMe(c,a,u),GMe(c,r,u);let d={},f=au();c.kill=oDe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=o1e(c,r),b1e(c,r),OMe(c,r);let p=q2t({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:l,command:s,escapedCommand:o,context:d,onInternalError:f,controller:u});return{subprocess:c,promise:p}},q2t=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:s,command:o,escapedCommand:a,context:c,onInternalError:u,controller:l})=>{let[d,[f,p],h,m,g]=await f1e({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:u,controller:l});l.abort(),u.resolve();let y=h.map((_,w)=>kl(_,e,w)),E=kl(m,e,"all"),S=B2t({errorInfo:d,exitCode:f,signal:p,stdio:y,all:E,ipcOutput:g,context:c,options:e,command:o,escapedCommand:a,startTime:r});return EE(S,n,e)},B2t=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,context:o,options:a,command:c,escapedCommand:u,startTime:l})=>"error"in t?Tx({error:t.error,command:c,escapedCommand:u,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof uu,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:l,isSync:!1}):dU({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:s,options:a,startTime:l});var CU=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,V2t(n,t[n],i)]));return{...t,...r}},V2t=(t,e,r)=>H2t.has(t)&&Qr(e)&&Qr(r)?{...e,...r}:r,H2t=new Set(["env",..._Q]);var jf=(t,e,r,n)=>{let i=(o,a,c)=>jf(o,a,r,c),s=(...o)=>G2t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},G2t=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Qr(s))return i(t,CU(r,s),n);let{file:a,commandArguments:c,options:u,isSync:l}=W2t({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return l?bMe(a,c,u):T1e(a,c,u,i)},W2t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=DNe(e)?LNe(e,r):[e,...r],[o,a,c]=A1(...s),u=CU(CU(n,i),c),{file:l=o,commandArguments:d=a,options:f=u,isSync:p=!1}=t({file:o,commandArguments:a,options:u});return{file:l,commandArguments:d,options:f,isSync:p}};var A1e=({file:t,commandArguments:e})=>x1e(t,e),R1e=({file:t,commandArguments:e})=>({...x1e(t,e),isSync:!0}),x1e=(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]=K2t(t);return{file:r,commandArguments:n}},K2t=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(Y2t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},Y2t=/ +/g;var O1e=(t,e,r)=>{t.sync=e(J2t,r),t.s=t.sync},I1e=({options:t})=>P1e(t),J2t=({options:t})=>({...P1e(t),isSync:!0}),P1e=t=>({options:{...Z2t(t),...t}}),Z2t=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},C1e={preferLocal:!0};var k1e=jf(()=>({})),F4r=jf(()=>({isSync:!0})),N1e=jf(A1e),j4r=jf(R1e),z4r=jf(BDe),q4r=jf(I1e,{},C1e,O1e),{sendMessage:B4r,getOneMessage:V4r,getEachMessage:H4r,getCancelSignal:G4r}=IMe();import{Transform as X2t}from"stream";var Q2t=["NETLIFY_AI_GATEWAY_KEY","NETLIFY_API_TOKEN","NETLIFY_AUTH_TOKEN"];function eVt(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...Q2t])]}function tVt(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function rVt(){let e=eVt().map(r=>process.env[r]).filter(r=>!(!r||tVt(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Si(t){if(typeof t!="string")return t;let e=rVt();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(nVt(n),"g");r=r.replace(i,"******")}),r}function nVt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Cx=class extends X2t{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Si(i);n(null,s)}},kU=Symbol("maskedWrite");function $1e(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[kU]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Si(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[kU]=!0,process.stdout.write=r}if(!process.stderr.write[kU]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Si(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[kU]=!0,process.stderr.write=r}}}var D1e=!1,L1e,q7=t=>{L1e??=t},M1e=t=>{D1e=!0,q7(t)},en=()=>D1e,ea=()=>L1e,U1e=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var kx=null,F1e=t=>(kx&&kx.destroy(),kx=new ta({totalAllowedTime:t}),kx),j1e=()=>kx;var ta=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&&en())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let s=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),o=null,a=null;n!==void 0&&(a=new Promise((l,d)=>{o=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),u="success";try{return await ID({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(l){throw u="failure",l}finally{X.timing("stage.duration",Date.now()-c,{stage:e,outcome:u}),s(),o&&clearTimeout(o)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var z1e={name:"@netlify/agent-runner-cli",type:"module",version:"2.14.0-nb62dba44206b2.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 aVt=sVt(import.meta.url),cVt=Nl.dirname(aVt),uVt=oVt(import.meta.url),TE=me("shell"),B7=new Set,q1e={preferLocal:!0},Ft=(t,e,r)=>{let[n,i]=lVt(e,r),s={...q1e,...i},o=k1e(t,n,s);V1e(o,s),W1e(o);let a=r?.idleTimeout;return a&&a>0&&G1e(o,a),o},B1e=(t,e)=>{let r={...q1e,...e},n=N1e(t,r);return V1e(n,r),W1e(n),e?.idleTimeout&&e.idleTimeout>0&&G1e(n,e.idleTimeout),n},lVt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},V1e=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||du.env.NETLIFY_LOCAL_QUIET==="true")return;if(du.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Cx).pipe(du.stdout),t.stderr?.pipe(new Cx).pipe(du.stderr);return}t.stdout?.pipe(du.stdout),t.stderr?.pipe(du.stderr)},V7=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(du.kill(-t.pid,e),TE.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return TE.error("Error killing process:",r),!1}},H1e=t=>V7(t,"SIGKILL"),G1e=(t,e)=>{let r=null,n=()=>{TE.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),V7(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(TE.log(`Force killing idle process ${t.pid}`),H1e(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let s=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",s),t.on("error",s)},W1e=t=>{B7.add(t);let e=j1e();if(e){let r=e.onTimesUp(()=>{TE.log(`Global timer expired, killing process ${t.pid}`),V7(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(TE.log(`Force killing process ${t.pid} after timeout`),H1e(t))},5e3)});t.on("exit",()=>{B7.delete(t),r()}),t.on("error",()=>{B7.delete(t),r()})}};function fu(t,e){if(!du.env.NETLIFY_LOCAL_MODE)try{let i=uVt.resolve(z1e.name),s=Nl.dirname(i);for(;s!==Nl.dirname(s);){let o=Nl.dirname(s);if(Nl.basename(o)==="node_modules"){let a=Nl.join(o,".bin",e);if(NU.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(du.env.NODE_PATH){let i=Nl.join(du.env.NODE_PATH,".bin",e);if(NU.existsSync(i))return i}let r=Nl.join(t,"node_modules",".bin",e);if(NU.existsSync(r))return r;let n=Nl.join(cVt,"..","node_modules",".bin",e);if(NU.existsSync(n))return n}import Dq from"process";import{fileURLToPath as PXt}from"url";import{createRequire as CXt}from"module";import CI from"path";import{readFileSync as kXt}from"fs";var dVt="__netlify__getTracer",fVt="__netlify__shutdownTracers",Nt=(t,e)=>globalThis[dVt]?.(t,e),K1e=async()=>globalThis[fVt]?.();function Nx(t,e,r,n,i){let s=typeof n=="function"?n:typeof r=="function"?r:i;if(!s)throw new Error("function to execute with active span is missing");return t?t.withActiveSpan(e,r,n,s):s()}import{createHash as _Xt}from"crypto";import{setTimeout as yXt}from"timers/promises";Me();import o4t from"process";Me();var pVt=(t,e)=>{e.recordException(t),e.setStatus({code:Fn.ERROR})};var $l=class{constructor(e){this._tracer=e,this.startSpan=e.startSpan.bind(this._tracer),this.startActiveSpan=e.startActiveSpan.bind(this._tracer)}withActiveSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=Y1e(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>J1e(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=Y1e(r,n,i),c=this._tracer.startSpan(e,s,o);return J1e(c,s,a)}};function Y1e(t,e,r){let n,i,s;return!e&&!r?s=t:r?(n=t,i=e,s=r):(n=t,s=e),n=n??{},i=i??tr.active(),{opts:n,ctx:i,fn:s}}function J1e(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:pVt,s=o=>{throw i(o,t),t.end(),o};try{let o=r(t);return typeof o?.then=="function"?o.then(a=>(t.end(),a),s):(t.end(),o)}catch(o){throw s(o)}}Me();var RE=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var G7=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=oUe(e),n._asyncAttributesPending=e.filter(([i,s])=>RE(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(RE(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=oUe(this._rawAttributes),this._schemaUrl=hVt(r?.schemaUrl)}get asyncAttributesPending(){return this._asyncAttributesPending}async waitForAsyncAttributes(){if(this.asyncAttributesPending){for(let e=0;e<this._rawAttributes.length;e++){let[r,n]=this._rawAttributes[e];this._rawAttributes[e]=[r,RE(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&ge.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(RE(n)){ge.debug(`Unsettled resource attribute ${r} skipped`);continue}n!=null&&(e[r]??=n)}return this._asyncAttributesPending||(this._memoizedAttributes=e),e}getRawAttributes(){return this._rawAttributes}get schemaUrl(){return this._schemaUrl}merge(e){if(e==null)return this;let r=mVt(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function W7(t,e){return G7.FromAttributeList(Object.entries(t),e)}function oUe(t){return t.map(([e,r])=>RE(r)?[e,r.catch(n=>{ge.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function hVt(t){if(typeof t=="string"||t===void 0)return t;ge.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function mVt(t,e){let r=t?.schemaUrl,n=e?.schemaUrl,i=r===void 0||r==="",s=n===void 0||n==="";if(i)return n;if(s||r===n)return r;ge.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}Me();var $x=class{emit(e){}enabled(){return!1}},aUe=new $x;var Dx=Symbol.for("io.opentelemetry.js.api.logs"),xE=globalThis;function cUe(t,e,r){return n=>n===t?e:r}var K7=1;var Y7=class{getLogger(e,r,n){return new $x}},LU=new Y7;var MU=class{constructor(e,r,n,i){this._provider=e,this.name=r,this.version=n,this.options=i}emit(e){this._getLogger().emit(e)}enabled(e){return this._getLogger().enabled(e)}_getLogger(){if(this._delegate)return this._delegate;let e=this._provider._getDelegateLogger(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):aUe}};var Lx=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new MU(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:LU}_setDelegate(e){this._delegate=e}_getDelegateLogger(e,r,n){var i;return(i=this._delegate)===null||i===void 0?void 0:i.getLogger(e,r,n)}};var UU=class t{constructor(){this._proxyLoggerProvider=new Lx}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return xE[Dx]?this.getLoggerProvider():(xE[Dx]=cUe(K7,e,LU),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=xE[Dx])===null||e===void 0?void 0:e.call(xE,K7))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete xE[Dx],this._proxyLoggerProvider=new Lx}};var uUe=UU.getInstance();function lUe(t,e,r,n){for(let i=0,s=t.length;i<s;i++){let o=t[i];e&&o.setTracerProvider(e),r&&o.setMeterProvider(r),n&&o.setLoggerProvider&&o.setLoggerProvider(n),o.getConfig().enabled||o.enable()}}function dUe(t){t.forEach(e=>e.disable())}function J7(t){let e=t.tracerProvider||Ut.getTracerProvider(),r=t.meterProvider||NR.getMeterProvider(),n=t.loggerProvider||uUe.getLoggerProvider(),i=t.instrumentations?.flat()??[];return lUe(i,e,r,n),()=>{dUe(i)}}Me();var gVt=Un("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function fUe(t){return t.getValue(gVt)===!0}var OE;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(OE||(OE={}));Me();var Z7="[_0-9a-z-*/]",_Vt=`[a-z]${Z7}{0,255}`,yVt=`[a-z0-9]${Z7}{0,240}@[a-z]${Z7}{0,13}`,SVt=new RegExp(`^(?:${_Vt}|${yVt})$`),EVt=/^[ -~]{0,255}[!-~]$/,vVt=/,|=/;function X7(t){return SVt.test(t)}function Q7(t){return EVt.test(t)&&!vVt.test(t)}var bVt=32,pUe=512,hUe=",",mUe="=",FU=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!X7(e)||!Q7(r))return this;let n=this._getState(),i=n.get(e),s=this._length;if(typeof i=="string"?s+=r.length-i.length:s+=e.length+r.length+(n.size>0?2:1),s>pUe)return this;let o=new Map(n);return o.delete(e),o.set(e,r),this._fromState(o,s)}unset(e){let r=this._getState(),n=r.get(e);if(typeof n!="string")return this;let i=this._length-(e.length+n.length+1);r.size>1&&(i=i-1);let s=new Map(r);return s.delete(e),this._fromState(s,i)}get(e){return this._getState().get(e)}serialize(){let e="",r=0;for(let n of this._getState())r>0&&(e=hUe+e),e=`${n[0]}${mUe}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(hUe),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(mUe);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!X7(a)||!Q7(c))continue;let u=n+s.length+(r.size>0?1:0);if(!(u>pUe)&&(r.set(a,c),n=u,r.size>=bVt))break}return this._length=n,this._internalState=new Map(Array.from(r.entries()).reverse()),this._internalState}_fromState(e,r){let n=Object.create(t.prototype);return n._internalState=e,n._length=r,n}};var jU="traceparent",zU="tracestate",wVt="00",TVt="(?!ff)[\\da-f]{2}",AVt="(?![0]{32})[\\da-f]{32}",RVt="(?![0]{16})[\\da-f]{16}",xVt="[\\da-f]{2}",OVt=new RegExp(`^\\s?(${TVt})-(${AVt})-(${RVt})-(${xVt})(-.*)?\\s?$`);function gUe(t){let e=OVt.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var zf=class{inject(e,r,n){let i=Ut.getSpanContext(e);if(!i||fUe(e)||!vs(i))return;let s=`${wVt}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||Or.NONE).toString(16)}`;n.set(r,jU,s),i.traceState&&n.set(r,zU,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,jU);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=gUe(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,zU);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new FU(typeof c=="string"?c:void 0)}return Ut.setSpanContext(e,o)}fields(){return[jU,zU]}};var qU=class{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,r)=>{this._resolve=e,this._reject=r})}get promise(){return this._promise}resolve(e){this._resolve(e)}reject(e){this._reject(e)}};var Mx=class{_isCalled=!1;_deferred=new qU;_callback;_that;constructor(e,r){this._callback=e,this._that=r}get isCalled(){return this._isCalled}get promise(){return this._deferred.promise}call(...e){if(!this._isCalled){this._isCalled=!0;try{Promise.resolve(this._callback.call(this._that,...e)).then(r=>this._deferred.resolve(r),r=>this._deferred.reject(r))}catch(r){this._deferred.reject(r)}}return this._deferred.promise}};var DF=yn(zee(),1);Me();var hze=t=>{throw TypeError(t)},Hee=(t,e,r)=>e.has(t)||hze("Cannot "+r),$F=(t,e,r)=>(Hee(t,e,"read from private field"),r?r.call(t):e.get(t)),qee=(t,e,r)=>e.has(t)?hze("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),dze=(t,e,r,n)=>(Hee(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),s4t=(t,e,r)=>(Hee(t,e,"access private method"),r),fze="__netlify__getTracer",a4t="__netlify__shutdownTracers",c4t="__nfOTLPTrace",rO,nO,Vee,mze,u4t=class{constructor(){qee(this,Vee),qee(this,rO),qee(this,nO),dze(this,rO,new Mx(s4t(this,Vee,mze),this)),dze(this,nO,ge.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if($F(this,nO).debug(`export ${t.length.toString()} spans`),$F(this,rO).isCalled){e({code:OE.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(c4t,JSON.stringify(l4t(t))),e({code:OE.SUCCESS})}shutdown(){return $F(this,rO).call()}};rO=new WeakMap;nO=new WeakMap;Vee=new WeakSet;mze=function(){return $F(this,nO).debug("Shutting down"),Promise.resolve()};function l4t(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:NF(e.resource.attributes),droppedAttributesCount:e.droppedAttributesCount},scopeSpans:[{scope:{name:e.instrumentationScope.name,version:e.instrumentationScope.version},spans:[{traceId:r.traceId,spanId:r.spanId,parentSpanId:e.parentSpanContext?.spanId,name:e.name,kind:e.kind||Va.SERVER,startTimeUnixNano:Bee(e.startTime),endTimeUnixNano:Bee(e.endTime),attributes:NF(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:Bee(n.time),attributes:NF(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedEventsCount:e.droppedEventsCount,status:{code:e.status.code,message:e.status.message},links:e.links.map(n=>({spanId:n.context.spanId,traceId:n.context.traceId,attributes:NF(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function NF(t){return Object.keys(t).map(e=>gze(e,t[e]))}function gze(t,e){return{key:t,value:_ze(e)}}function _ze(t){let e=typeof t;return e==="string"?{stringValue:t}:e==="number"?Number.isInteger(t)?{intValue:t}:{doubleValue:t}:e==="boolean"?{boolValue:t}:t instanceof Uint8Array?{bytesValue:t}:Array.isArray(t)?{arrayValue:{values:t.map(_ze)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>gze(r,n))}}:{}}function Bee(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var pze={name:"@netlify/otel",version:"6.0.6",type:"module",engines:{node:"^18.14.0 || >=20.6.1"},main:"./dist/main.cjs",module:"./dist/main.js",types:"./dist/main.d.ts",exports:{".":{require:{types:"./dist/main.d.cts",default:"./dist/main.cjs"},import:{types:"./dist/main.d.ts",default:"./dist/main.js"},default:{types:"./dist/main.d.ts",default:"./dist/main.js"}},"./package.json":"./package.json","./bootstrap":{require:{types:"./dist/bootstrap/main.d.cts",default:"./dist/bootstrap/main.cjs"},import:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"},default:{types:"./dist/bootstrap/main.d.ts",default:"./dist/bootstrap/main.js"}},"./exporter-netlify":{require:{types:"./dist/exporters/netlify.d.cts",default:"./dist/exporters/netlify.cjs"},import:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"},default:{types:"./dist/exporters/netlify.d.ts",default:"./dist/exporters/netlify.js"}},"./instrumentation-fetch":{require:{types:"./dist/instrumentations/fetch.d.cts",default:"./dist/instrumentations/fetch.cjs"},import:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"},default:{types:"./dist/instrumentations/fetch.d.ts",default:"./dist/instrumentations/fetch.js"}},"./instrumentation-http":{require:{types:"./dist/instrumentations/http.d.cts",default:"./dist/instrumentations/http.cjs"},import:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"},default:{types:"./dist/instrumentations/http.d.ts",default:"./dist/instrumentations/http.js"}},"./opentelemetry":{require:{types:"./dist/opentelemetry.d.cts",default:"./dist/opentelemetry.cjs"},import:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"},default:{types:"./dist/opentelemetry.d.ts",default:"./dist/opentelemetry.js"}}},files:["dist/**/*"],scripts:{build:"tsup-node",dev:"tsup-node --watch",prepack:"npm run build",test:"run-s build test:ci","test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"vitest","test:dev:vitest:watch":"vitest watch","test:ci:vitest":"vitest run",publint:"npx -y publint --strict"},keywords:["netlify","cdn"],license:"MIT",repository:{type:"git",url:"https://github.com/netlify/primitives.git",directory:"packages/otel"},bugs:{url:"https://github.com/netlify/primitives/issues"},author:"Netlify Inc.",devDependencies:{"@netlify/dev-utils":"^5.0.0",msw:"^2.10.5","npm-run-all2":"^7.0.2",tsup:"^8.0.0",vitest:"^3.0.0"},dependencies:{"@opentelemetry/api":"1.9.1","@opentelemetry/core":"2.8.0","@opentelemetry/instrumentation":"^0.220.0","@opentelemetry/resources":"2.9.0","@opentelemetry/sdk-trace-node":"2.9.0"}},yze=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,fze))return;let e=o4t.version.slice(1),r=W7({"service.name":t.serviceName,"service.version":t.serviceVersion,"process.runtime.name":"nodejs","process.runtime.version":e,"deployment.environment":t.deploymentEnvironment,"http.url":t.siteUrl,"netlify.site.id":t.siteId,"netlify.site.name":t.siteName}),n=t.spanProcessors??[d4t()],i=new DF.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new zf});let s=t.instrumentations??[];J7({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,fze,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new $l(Ut.getTracer(a,c)):new $l(Ut.getTracer(pze.name,pze.version))}}),Object.defineProperty(globalThis,a4t,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},d4t=()=>new DF.SimpleSpanProcessor(new u4t);Me();var jE=yn(zee(),1);Me();import*as LF from"diagnostics_channel";var Sze=class{constructor(t={}){this.instrumentationName="@netlify/otel/instrumentation-fetch",this.instrumentationVersion="1.0.0",this._recordFromReq=new WeakMap,this.config=t,this._channelSubs=[]}getConfig(){return this.config}setConfig(){}setMeterProvider(){}setTracerProvider(t){this.provider=t}getTracerProvider(){return this.provider}annotateFromRequest(t,e){let r=this.config.getRequestAttributes?.(e)??{},n=new URL(e.path,e.origin);t.setAttributes({...r,"http.request.method":e.method,"url.full":n.href,"url.host":n.host,"url.scheme":n.protocol.slice(0,-1),"server.address":n.hostname,"server.port":n.port,...this.prepareHeaders("request",e.headers)})}annotateFromResponse(t,e){let r=this.config.getResponseAttributes?.(e)??{};t.setAttributes({...r,"http.response.status_code":e.statusCode,...this.prepareHeaders("response",e.headers)}),t.setStatus({code:e.statusCode>=400?Fn.ERROR:Fn.UNSET})}prepareHeaders(t,e){if(!Array.isArray(e))return{};if(this.config.skipHeaders===!0)return{};let r=["*","/.*/"],n=this.config.skipHeaders??[],i=this.config.redactHeaders??[],s=n.some(a=>r.includes(a.toString())),o={};if(s)return o;for(let a=0;a+1<e.length;a=a+2){let c=e[a],u=e[a+1];if(typeof c!="string"&&!Buffer.isBuffer(c)||typeof u!="string"&&!Buffer.isBuffer(u))continue;let l=c.toString().toLowerCase();if(n.some(f=>typeof f=="string"?f==l:f.test(l)))continue;let d=`http.${t}.header.${l}`;i===!0||i.some(f=>typeof f=="string"?f==l:f.test(l))?o[d]="REDACTED":o[d]=u.toString()}return o}getRequestMethod(t){return["HEAD","GET","POST","PUT","PATCH","DELETE"].includes(t.toUpperCase())?t.toUpperCase():"_OTHER"}getTracer(){if(!this.provider)return;let t=this.provider.getTracer(this.instrumentationName,this.instrumentationVersion);return t instanceof $l?t:new $l(t)}enable(){this._channelSubs.length>0||(this.subscribe("undici:request:create",this.onRequestCreate.bind(this)),this.subscribe("undici:request:headers",this.onRequestHeaders.bind(this)),this.subscribe("undici:request:trailers",this.onRequestEnd.bind(this)),this.subscribe("undici:request:error",this.onRequestError.bind(this)))}subscribe(t,e){LF.subscribe(t,e);let r=()=>LF.unsubscribe(t,e);this._channelSubs.push({name:t,unsubscribe:r})}disable(){this._channelSubs.forEach(t=>{t.unsubscribe()}),this._channelSubs.length=0}onRequestCreate({request:t}){try{let e=this.getTracer(),r=new URL(t.path,t.origin);if(!e||t.method==="CONNECT"||this.config.skipURLs?.some(i=>typeof i=="string"?r.href.startsWith(i):i.test(r.href)))return;let n=e.startSpan(this.getRequestMethod(t.method),{kind:Va.CLIENT},tr.active());this.annotateFromRequest(n,t),this._recordFromReq.set(t,n)}catch{}}onRequestHeaders({request:t,response:e}){try{let r=this._recordFromReq.get(t);if(!r)return;this.annotateFromResponse(r,e)}catch{}}onRequestError({request:t,error:e}){try{let r=this._recordFromReq.get(t);if(!r)return;r.recordException(e),r.setStatus({code:Fn.ERROR,message:e.message}),r.end(),this._recordFromReq.delete(t)}catch{}}onRequestEnd({request:t}){try{let e=this._recordFromReq.get(t);if(!e)return;e.end(),this._recordFromReq.delete(t)}catch{}}};var aWe=yn(nWe(),1);Me();jse();var iWe=0;var mXt=3*1024*1024,gXt=t=>RI.serializeRequest([t])?.byteLength??Number.POSITIVE_INFINITY,Nq=class{constructor(e,r=mXt){this.inner=e;this.maxBytes=r}export(e,r){let n=[],i=[],s=0;for(let c of e){let u=gXt(c);i.length&&s+u>this.maxBytes&&(n.push(i),i=[],s=0),i.push(c),s+=u}i.length&&n.push(i);let o,a=c=>{if(c===n.length){r(o??{code:iWe});return}this.inner.export(n[c],u=>{u.code!==iWe&&(o??=u),a(c+1)})};a(0)}shutdown(){return this.inner.shutdown()}forceFlush(){return this.inner.forceFlush?.()??Promise.resolve()}};var jv=me("tracing"),sWe=8e3,SXt=5e3,oWe=t=>t.length>sWe?`${t.slice(0,sWe)}\u2026`:t,zv={maxQueueSize:20480,maxExportBatchSize:128,scheduledDelayMillis:1e3},EXt=Math.ceil(zv.maxQueueSize/zv.maxExportBatchSize)+1,cWe=0,Bse=()=>cWe,vXt=t=>{let e=0,r=new Nq(new aWe.OTLPTraceExporter({url:t,concurrencyLimit:EXt})),n=new jE.BatchSpanProcessor({export:(i,s)=>{e=Math.max(0,e-i.length),r.export(i,s)},shutdown:()=>r.shutdown(),forceFlush:()=>r.forceFlush()},zv);return{onStart:(i,s)=>n.onStart(i,s),onEnd:i=>{i.spanContext().traceFlags&Or.SAMPLED&&(e>=zv.maxQueueSize?cWe+=1:e+=1),n.onEnd(i)},forceFlush:()=>n.forceFlush(),shutdown:()=>n.shutdown()}},wg=async(t=SXt)=>{try{let e=Symbol("timed out");await Promise.race([K1e(),yXt(t,e)])===e&&jv.warn(`Tracer flush did not finish in ${t} ms; unsent spans are lost`)}catch(e){jv.warn("Failed to flush tracers on shutdown",e)}},uWe=async(t,e,r)=>{if(!Nt()){let n=[new jE.SimpleSpanProcessor(new qse),vXt(r.exporterUrl)];await yze({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new Sze({skipHeaders:!0})]})}return r.traceparent?(Yi.setGlobalPropagator(new zf),Yi.extract(tr.active(),{traceparent:r.traceparent,isRemote:!0})):tr.active()};function fr(t,e,r){return jv.log(`\u23F3 TRACE: ${e} starting...`),Nx(t,e,r)}var qse=class{export(e,r){for(let n of e)this.logSpan(n);r({code:1})}async shutdown(){}forceFlush(){return Promise.resolve()}logSpan(e){let r=(e.endTime[0]-e.startTime[0])*1e3+(e.endTime[1]-e.startTime[1])/1e6,n=e.attributes,i=[];for(let[a,c]of Object.entries(n))a.includes("duration")&&typeof c=="number"?i.push(`${a}=${c.toFixed(2)}ms`):i.push(`${a}=${c}`);let s=e.status?.code===2?"\u274C":"\u2705",o=i.length>0?` [${i.join(", ")}]`:"";jv.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&jv.log(` \u274C Error: ${e.status.message}`)}};function Vse(){return Ye().captureLlmContentEnabled}function lWe(t){return t.includes("claude")?"anthropic":t.includes("codex")?"openai":t.includes("gemini")||t.includes("antigravity")?"google":t.includes("muse")?"meta":t.includes("opencode")?"opencode":t}function $q(t,e,r){let n={role:t,parts:[{type:"text",content:Si(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var bXt=new Set([ee.Task,ee.RunCommand,ee.Explore,ee.FileRead,ee.FileWrite,ee.Notebook,ee.Web,ee.Todo,ee.Skill,ee.Tool,ee.Memorize,ee.Deployment,ee.SiteGeneration]),wXt=new Set(["claude","codex"]),TXt=(t,e)=>JSON.stringify([t,e.operation,e.path??null]),AXt=t=>_Xt("sha256").update(t.map(e=>Buffer.from(e)).sort(Buffer.compare).join(`
598
598
  `)).digest("hex"),dWe=(t,e,r)=>({"spark.trace.file_operations_recorded":wXt.has(t)&&!e.fileOperationsIncomplete,...r?{"spark.file_operations.count":r.count,"spark.file_operations.digest":r.digest}:{}});function fWe(t,e,r,n){let i=[],s=()=>({count:i.length,digest:AXt(i)});if(!t.length)return s();let o=Nt();if(!o)return s();let a=t.reduce((l,d)=>l+1+(d.fileOperations?.length??0),0);a>zv.maxQueueSize&&jv.warn(`${a} step spans exceed the span queue of ${zv.maxQueueSize}; spans may be dropped`);let c=Vse(),u=Math.max(1,(n-r)/t.length);return t.forEach((l,d)=>{let f=l.timingSource?Zs(l.startedAtMs,l.endedAtMs,l.timingSource):{},p=f.startedAtMs??Math.min(n,r+d*u),h=f.endedAtMs??Math.min(n,p+u),m=f.timingSource??"even-split",g=l.type==="tool_use"||l.type==="tool_result"||l.category!=null&&bXt.has(l.category)||l.category===ee.AgentMessage&&l.toolCallId!==void 0,y=g?"execute_tool":"chat",E=oWe(l.title||l.type||`step-${l.id??d}`),S=l.category||"unknown",_=g?`${y} ${S}`:y,w=l.message?oWe(l.message):void 0,b=o.startSpan(_,{startTime:p,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":Si(E),"gen_ai.operation.name":y,...g?{"gen_ai.tool.name":S}:{},"spark.step.id":l.id??-1,"spark.step.timing":m,"spark.file_operations.count":l.fileOperations?.length??0,...l.type?{"spark.step.type":l.type}:{},...l.category?{"spark.step.category":l.category}:{},...l.groupId?{"spark.step.group_id":l.groupId}:{},...l.parentGroupId?{"spark.step.parent_group_id":l.parentGroupId}:{},...l.skillId?{"spark.skill.id":l.skillId}:{},...c&&w?g?{"gen_ai.tool.call.result":Si(w)}:{"gen_ai.output.messages":$q("assistant",w)}:{}}});g&&(l.toolCallId!==void 0&&b.setAttribute("gen_ai.tool.call.id",l.toolCallId),l.toolStatus!==void 0&&b.setAttribute("spark.step.tool_status",l.toolStatus),l.exitCode!==void 0&&b.setAttribute("spark.step.exit_code",l.exitCode),l.toolStatus==="error"&&(b.setAttribute("error.type","tool_error"),b.setStatus({code:Fn.ERROR})));let A=l.fileOperations?.length?Ut.setSpan(tr.active(),b):void 0;for(let T of l.fileOperations??[])i.push(TXt(l.id??-1,T)),o.startSpan("file_operation",{startTime:p,attributes:{"gen_ai.capability.name":e,"spark.step.id":l.id??-1,"spark.file.operation":T.operation,...T.path!==void 0?{"spark.file.path":T.path}:T.unresolved?{"spark.file.path_unresolved":!0}:{"spark.file.outside_repo":!0},...l.toolCallId!==void 0?{"gen_ai.tool.call.id":l.toolCallId}:{}}},A).end(h);b.end(h)}),s()}import{readdir as RXt,rm as xXt}from"fs/promises";import{join as OXt}from"path";async function pWe(t,e=[]){let n=(await RXt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>xXt(OXt(t,i),{recursive:!0,force:!0})))}var IXt=300,II=t=>Ye().budgetCreditThresholds[t.mode]?.[t.runner]??IXt,PI=({mode:t,sessionCreditLimit:e},r)=>t==="create"&&e!=null&&e<=r;var Hse=t=>{let e=II(t);if(!PI(t,e))return"default";let r=Ye();return r.createAskFirstEnabled?"ask_first":r.creditWrapUpEnabled?"budget_constrained":"default"},hWe=t=>{let e=Hse(t),r=II(t);return{budget_eligible:PI(t,r),budget_constrained:e==="budget_constrained",ask_first:e==="ask_first"}};var NXt=CI.dirname(PXt(import.meta.url)),mWe=CXt(import.meta.url),$Xt=CI.resolve(NXt,"scripts/scaffold.js"),DXt="scripts/scaffold.js",LXt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,Gse=t=>{if(t.length>=2){let e=t[0],r=t[t.length-1];if(e==='"'&&r==='"'||e==="'"&&r==="'")return t.slice(1,-1)}return t},MXt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),UXt=t=>{let e=Gse(t);return e==="node"||e.endsWith("/node")},uo=t=>{if(typeof t!="string")return!1;let e=t.match(LXt)||[];if(e.length<2)return!1;let r=0;for(;r<e.length&&MXt(Gse(e[r]));)r+=1;if(r>=e.length||!UXt(e[r]))return!1;let n=e[r+1];return n?Gse(n).includes(DXt):!1},Tg=me("create_stage"),Wse="Do not run local validation or dev-server commands to check your work \u2014 specifically `tsc`, `npx tsc`, `vite build`, `vite dev`, or any equivalent build/start/test command. The build pipeline installs and validates the project automatically after your edits. Verify your changes by reading the files you edited.",FXt=`${Wse}
599
599
 
600
600
  Commands that generate or modify project files are fine to run when the task requires them \u2014 for example \`drizzle-kit generate\` to write a database migration after a schema change, or other code-generation utilities documented in the skills.`,jXt=`${Wse}
@@ -868,7 +868,9 @@ ${r.join(`
868
868
  - Read files efficiently. Use glob first to find the right paths before reading
869
869
  - Prefer editing over writing entire files when possible
870
870
  - 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.
871
- - Do not use Netlify Functions, Edge Functions, Forms, Database, Blobs, Image CDN, redirects or headers rules; use third-party services or client-side code.
871
+ - When the task requires data storage or persistence, you MUST use Netlify platform primitives. Use the \`general-database\` skill to determine the right storage solution. NEVER use in-memory data structures, local JSON files, or external database services for data that needs to persist.
872
+ - 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.
873
+ - Complete the task and meet its requirements without using Netlify Blobs; keep any required data another way.
872
874
  ${m8e(t)}
873
875
  </rules>`,X2=({skillsDir:t,mode:e,runner:r})=>e==="ask"?far(t):g8e(t,r),_8e=({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(`
874
876
  `),y8e=async(t,e)=>{let r=await Wke(e);return r?har(mar(r,e.runner),t):t},har=(t,e)=>[t,e].filter(Boolean).join(`
package/dist/index.js CHANGED
@@ -216,7 +216,9 @@ ${b}`,d++;break;case"id":u=b.includes("\0")?void 0:b;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
- - Do not use Netlify Functions, Edge Functions, Forms, Database, Blobs, Image CDN, redirects or headers rules; use third-party services or client-side code.
219
+ - When the task requires data storage or persistence, you MUST use Netlify platform primitives. Use the \`general-database\` skill to determine the right storage solution. NEVER use in-memory data structures, local JSON files, or external database services for data that needs to persist.
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.
221
+ - Complete the task and meet its requirements without using Netlify Blobs; keep any required data another way.
220
222
  ${vwe(t)}
221
223
  </rules>`,kD=({skillsDir:t,mode:e,runner:r})=>e==="ask"?Lut(t):bwe(t,r),Ewe=({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(`
222
224
  `),wwe=async(t,e)=>{let r=await cwe(e);return r?Fut(zut(r,e.runner),t):t},Fut=(t,e)=>[t,e].filter(Boolean).join(`
@@ -382,7 +384,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
382
384
  `,LF:`
383
385
  `,concatBytes:U5},dmt=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},fmt={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:dmt};import{Buffer as pmt}from"buffer";var dxe=(t,e)=>t?void 0:hmt.bind(void 0,e),hmt=function*(t,e){if(typeof e!="string"&&!Hr(e)&&!pmt.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},fxe=(t,e)=>t?mmt.bind(void 0,e):gmt.bind(void 0,e),mmt=function*(t,e){pxe(t,e),yield e},gmt=function*(t,e){if(pxe(t,e),typeof e!="string"&&!Hr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},pxe=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
384
386
  Instead, \`yield\` should either be called with a value, or not be called at all. For example:
385
- if (condition) { yield value; }`)};import{Buffer as _mt}from"buffer";import{StringDecoder as ymt}from"string_decoder";var kM=(t,e,r)=>{if(r)return;if(t)return{transform:Smt.bind(void 0,new TextEncoder)};let n=new ymt(e);return{transform:vmt.bind(void 0,n),final:bmt.bind(void 0,n)}},Smt=function*(t,e){_mt.isBuffer(e)?yield yu(e):typeof e=="string"?yield t.encode(e):yield e},vmt=function*(t,e){yield Hr(e)?t.write(e):e},bmt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as hxe}from"util";var z5=hxe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),NM=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=wmt}=e[r];for await(let i of n(t))yield*NM(i,e,r+1)},mxe=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*NM(n,r,e+1)},gxe=hxe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),wmt=function*(t){yield t};var j5=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},_xe=(t,e)=>[...e.flatMap(r=>[...Qp(r,t,0)]),...aR(t)],Qp=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Amt}=e[r];for(let i of n(t))yield*Qp(i,e,r+1)},aR=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Tmt(r,Number(e),t)},Tmt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Qp(n,r,e+1)},Amt=function*(t){yield t};var B5=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Sxe(t,s,o),u=Xp(e),l=Xp(r),d=u?z5.bind(void 0,NM,a):j5.bind(void 0,Qp),f=u||l?z5.bind(void 0,mxe,a):j5.bind(void 0,aR),p=u||l?gxe.bind(void 0,a):void 0;return{stream:new Rmt({writableObjectMode:n,writableHighWaterMark:yxe(n),readableObjectMode:i,readableHighWaterMark:yxe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},$M=(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=Sxe(s,r,a);t=_xe(c,t)}return t},Sxe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:dxe(n,a)},kM(r,s,n),CM(r,o,n,c),{transform:t,final:e},{transform:fxe(i,a)},lxe({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var vxe=(t,e)=>{for(let r of xmt(t))Imt(t,r,e)},xmt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Imt=(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 ${dd[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>Omt(a,n));r.input=JA(s)},Omt=(t,e)=>{let r=$M(t,e,"utf8",!0);return Pmt(r),JA(r)},Pmt=t=>{let e=t.find(r=>typeof r!="string"&&!Hr(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 $mt,appendFileSync as Dmt}from"fs";var DM=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&_y(r,n)&&!ho.has(e)&&Cmt(n)&&(t.some(({type:i,value:o})=>i==="native"&&kmt.has(o))||t.every(({type:i})=>Xo.has(i))),Cmt=t=>t===1||t===2,kmt=new Set(["pipe","overlapped"]),bxe=async(t,e,r,n)=>{for await(let i of t)Nmt(e)||wxe(i,r,n)},Exe=(t,e,r)=>{for(let n of t)wxe(n,e,r)},Nmt=t=>t._readableState.pipes.length>0,wxe=(t,e,r)=>{let n=YD(t);oc({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Txe=({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)=>Mmt({result:c,fileDescriptors:t,fdNumber:u,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},Mmt=({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=ARe(t,o,d),p=yu(f),{stdioItems:h,objectMode:m}=e[r],_=Lmt([p],h,c,n),{serializedResult:y,finalResult:v=y}=Umt({chunks:_,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});Fmt({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&&zmt(y,h,i),A}catch(S){return n.error=S,A}},Lmt=(t,e,r,n)=>{try{return $M(t,e,r,!1)}catch(i){return n.error=i,t}},Umt=({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=Fwe(t,r);return n[o]?{serializedResult:s,finalResult:F5(s,!i[o],e)}:{serializedResult:s}},Fmt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!DM({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=F5(t,!1,s);try{Exe(a,e,n)}catch(c){r.error??=c}},zmt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>OM.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?Dmt(n,t):(r.add(o),$mt(n,t))}};var Axe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,bu(e,r,"all")]:Array.isArray(e)?[bu(t,r,"all"),...e]:Hr(t)&&Hr(e)?K9([t,e]):`${t}${e}`};import{once as q5}from"events";var Rxe=async(t,e)=>{let[r,n]=await jmt(t);return e.isForcefullyTerminated??=!1,[r,n]},jmt=async t=>{let[e,r]=await Promise.allSettled([q5(t,"spawn"),q5(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?xxe(t):r.value},xxe=async t=>{try{return await q5(t,"exit")}catch{return xxe(t)}},Ixe=async t=>{let[e,r]=await t;if(!Bmt(e,r)&&V5(e,r))throw new aa;return[e,r]},Bmt=(t,e)=>t===void 0&&e===void 0,V5=(t,e)=>t!==0||e!==null;var Oxe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=qmt(t,e,r),s=o?.code==="ETIMEDOUT",a=TRe(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},qmt=(t,e,r)=>t!==void 0?t:V5(e,r)?new aa:void 0;var Pxe=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=Gmt(t,e,r),d=Kmt({file:n,commandArguments:i,options:u,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:l,startTime:a});return xy(d,c,u)},Gmt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=JD(t,e,r),a=Hmt(r),{file:c,commandArguments:u,options:l}=_M(t,e,a);Wmt(l);let d=sxe(l,s);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},Hmt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Wmt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&MM("ipcInput"),t&&MM("ipc: true"),r&&MM("detached: true"),n&&MM("cancelSignal")},MM=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Kmt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=Ymt({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}=Oxe(c,r),{output:h,error:m=u}=Txe({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),_=h.map((v,A)=>bu(v,r,A)),y=bu(Axe(h,r),r,"all");return Jmt({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},Ymt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{vxe(o,r);let a=Zmt(r);return Vmt(...yM(t,e,a))}catch(a){return Ry({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},Zmt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:AM(e)}),Jmt=({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?RM({command:c,escapedCommand:u,stdio:o,all:s,ipcOutput:[],options:a,startTime:l}):sR({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 U_t}from"events";import{spawn as F_t}from"child_process";import Dxe from"process";import{once as G5,on as Xmt}from"events";var Cxe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(vy({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:dM(t)}),Qmt({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),Qmt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{aM(e,i);let o=ld(t,e,r),s=new AbortController;try{return await Promise.race([egt(o,n,s),tgt(o,r,s),rgt(o,r,s)])}catch(a){throw by(t),a}finally{s.abort(),cM(e,i)}},egt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await G5(t,"message",{signal:r});return n}for await(let[n]of Xmt(t,"message",{signal:r}))if(e(n))return n},tgt=async(t,e,{signal:r})=>{await G5(t,"disconnect",{signal:r}),_Ae(e)},rgt=async(t,e,{signal:r})=>{let[n]=await G5(t,"strict:error",{signal:r});throw iM(n,e)};import{once as Nxe,on as ngt}from"events";var $xe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>H5({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),H5=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{vy({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:dM(t)}),aM(e,o);let s=ld(t,e,r),a=new AbortController,c={};return igt(t,s,a),ogt({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),sgt({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},igt=async(t,e,r)=>{try{await Nxe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},ogt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Nxe(t,"strict:error",{signal:r.signal});n.error=iM(i,e),r.abort()}catch{}},sgt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of ngt(r,"message",{signal:o.signal}))kxe(s),yield c}catch{kxe(s)}finally{o.abort(),cM(e,a),n||by(t),i&&await t}},kxe=({error:t})=>{if(t)throw t};var Mxe=(t,{ipc:e})=>{Object.assign(t,Uxe(t,!1,e))},Lxe=()=>{let t=Dxe,e=!0,r=Dxe.channel!==void 0;return{...Uxe(t,e,r),getCancelSignal:VAe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Uxe=(t,e,r)=>({sendMessage:mM.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Cxe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:$xe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as agt}from"child_process";import{PassThrough as cgt,Readable as ugt,Writable as lgt,Duplex as dgt}from"stream";var Fxe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{M5(n);let a=new agt;fgt(a,n),Object.assign(a,{readable:pgt,writable:hgt,duplex:mgt});let c=Ry({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),u=ggt(c,s,i);return{subprocess:a,promise:u}},fgt=(t,e)=>{let r=cR(),n=cR(),i=cR(),o=Array.from({length:e.length-3},cR),s=cR(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},cR=()=>{let t=new cgt;return t.end(),t},pgt=()=>new ugt({read(){}}),hgt=()=>new lgt({write(){}}),mgt=()=>new dgt({read(){},write(){}}),ggt=async(t,e,r)=>xy(t,e,r);import{createReadStream as zxe,createWriteStream as jxe}from"fs";import{Buffer as _gt}from"buffer";import{Readable as uR,Writable as ygt,Duplex as Sgt}from"stream";var qxe=(t,e)=>PM(vgt,t,e,!1),lR=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${dd[t]}.`)},Bxe={fileNumber:lR,generator:B5,asyncGenerator:B5,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Sgt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},vgt={input:{...Bxe,fileUrl:({value:t})=>({stream:zxe(t)}),filePath:({value:{file:t}})=>({stream:zxe(t)}),webStream:({value:t})=>({stream:uR.fromWeb(t)}),iterable:({value:t})=>({stream:uR.from(t)}),asyncIterable:({value:t})=>({stream:uR.from(t)}),string:({value:t})=>({stream:uR.from(t)}),uint8Array:({value:t})=>({stream:uR.from(_gt.from(t))})},output:{...Bxe,fileUrl:({value:t})=>({stream:jxe(t)}),filePath:({value:{file:t,append:e}})=>({stream:jxe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:ygt.fromWeb(t)}),iterable:lR,asyncIterable:lR,string:lR,uint8Array:lR}};import{on as bgt,once as Vxe}from"events";import{PassThrough as Egt,getDefaultHighWaterMark as wgt}from"stream";import{finished as Wxe}from"stream/promises";function eh(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)K5(i);let e=t.some(({readableObjectMode:i})=>i),r=Tgt(t,e),n=new W5({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Tgt=(t,e)=>{if(t.length===0)return wgt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},W5=class extends Egt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(K5(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Agt(this,this.#e,this.#o);let r=Igt({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(K5(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)}},Agt=async(t,e,r)=>{LM(t,Gxe);let n=new AbortController;try{await Promise.race([Rgt(t,n),xgt(t,e,r,n)])}finally{n.abort(),LM(t,-Gxe)}},Rgt=async(t,{signal:e})=>{try{await Wxe(t,{signal:e,cleanup:!0})}catch(r){throw Kxe(t,r),r}},xgt=async(t,e,r,{signal:n})=>{for await(let[i]of bgt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},K5=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Igt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{LM(t,Hxe);let a=new AbortController;try{await Promise.race([Ogt(o,e,a),Pgt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),Cgt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),LM(t,-Hxe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?Y5(t):kgt(t))},Ogt=async(t,e,{signal:r})=>{try{await t,r.aborted||Y5(e)}catch(n){r.aborted||Kxe(e,n)}},Pgt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await Wxe(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;Yxe(s)?i.add(e):Zxe(t,s)}},Cgt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await Vxe(t,i,{signal:o}),!t.readable)return Vxe(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},kgt=t=>{t.writable&&t.end()},Kxe=(t,e)=>{Yxe(e)?Y5(t):Zxe(t,e)},Yxe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Y5=t=>{(t.readable||t.writable)&&t.destroy()},Zxe=(t,e)=>{t.destroyed||(t.once("error",Ngt),t.destroy(e))},Ngt=()=>{},LM=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Gxe=2,Hxe=1;import{finished as Jxe}from"stream/promises";var Oy=(t,e)=>{t.pipe(e),$gt(t,e),Dgt(t,e)},$gt=async(t,e)=>{if(!(sa(t)||sa(e))){try{await Jxe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}Z5(e)}},Z5=t=>{t.writable&&t.end()},Dgt=async(t,e)=>{if(!(sa(t)||sa(e))){try{await Jxe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}J5(t)}},J5=t=>{t.readable&&t.destroy()};var Xxe=(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})=>Xo.has(c)))Mgt(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Xo.has(c)))Ugt({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]:eh(o);Oy(s,i)}},Mgt=(t,e,r,n)=>{r==="output"?Oy(t.stdio[n],e):Oy(e,t.stdio[n]);let i=Lgt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},Lgt=["stdin","stdout","stderr"],Ugt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;Fgt(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},Fgt=(t,{signal:e})=>{sa(t)&&Zp(t,zgt,e)},zgt=2;import{addAbortListener as qgt}from"events";var th=[];th.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&th.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&th.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var UM=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",X5=Symbol.for("signal-exit emitter"),Q5=globalThis,jgt=Object.defineProperty.bind(Object),e8=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(Q5[X5])return Q5[X5];jgt(Q5,X5,{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}},FM=class{},Bgt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),t8=class extends FM{onExit(){return()=>{}}load(){}unload(){}},r8=class extends FM{#e=n8.platform==="win32"?"SIGINT":"SIGHUP";#r=new e8;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of th)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(!UM(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 th)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,th.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 UM(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"&&UM(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)}},n8=globalThis.process,{onExit:Qxe,load:mpr,unload:gpr}=Bgt(UM(n8)?new r8(n8):new t8);var eIe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Qxe(()=>{t.kill()});qgt(n,()=>{i()})};var rIe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=ZD(),{destination:s,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=Vgt(r,n,i),{sourceStream:d,sourceError:f}=Hgt(t,u),{options:p,fileDescriptors:h}=ac.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:o}},Vgt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=Ggt(t,e,...r),a=sM(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},Ggt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(tIe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||H9(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]=zD(r,...n);return{destination:e(tIe)(i,o,s),pipeOptions:s}}if(ac.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}`)},tIe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),Hgt=(t,e)=>{try{return{sourceStream:Ey(t,e)}}catch(r){return{sourceError:r}}};var iIe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=Wgt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw i8({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},Wgt=({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 Z5(r),e},i8=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Ry({error:t,command:nIe,escapedCommand:nIe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),nIe="source.pipe(destination)";var oIe=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 Kgt}from"stream/promises";var sIe=(t,e,r)=>{let n=zM.has(e)?Zgt(t,e):Ygt(t,e);return Zp(t,Xgt,r.signal),Zp(e,Qgt,r.signal),Jgt(e),n},Ygt=(t,e)=>{let r=eh([t]);return Oy(r,e),zM.set(e,r),r},Zgt=(t,e)=>{let r=zM.get(e);return r.add(t),r},Jgt=async t=>{try{await Kgt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}zM.delete(t)},zM=new WeakMap,Xgt=2,Qgt=1;import{aborted as e_t}from"util";var aIe=(t,e)=>t===void 0?[]:[t_t(t,e)],t_t=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await e_t(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw i8({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var jM=(t,...e)=>{if(Tr(e[0]))return jM.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=rIe(t,...e),i=r_t({...n,destination:r});return i.pipe=jM.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},r_t=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=n_t(t,i);iIe({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=sIe(e,o,d);return await Promise.race([oIe(l),...aIe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},n_t=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as l_t}from"timers/promises";import{on as i_t}from"events";import{getDefaultHighWaterMark as o_t}from"stream";var BM=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return s_t(e,s),uIe({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},s_t=async(t,e)=>{try{await t}catch{}finally{e.abort()}},o8=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;a_t(e,s,t);let a=t.readableObjectMode&&!o;return uIe({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},a_t=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},uIe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=i_t(t,"data",{signal:e.signal,highWaterMark:cIe,highWatermark:cIe});return c_t({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},s8=o_t(!0),cIe=s8,c_t=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=u_t({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Qp(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*aR(a)}},u_t=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[kM(t,r,!e),CM(t,i,!n,{})].filter(Boolean);var lIe=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=d_t({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([f_t(t),d]);return}let f=L5(c,r),p=o8({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([p_t({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},d_t=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!DM({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=o8({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await bxe(a,t,r,o)},f_t=async t=>{await l_t(),t.readableFlowing===null&&t.resume()},p_t=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await EM(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await wM(r,{maxBuffer:o})):await Ay(r,{maxBuffer:o})}catch(a){return dIe(bRe({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},a8=async t=>{try{return await t}catch(e){return dIe(e)}},dIe=({bufferedData:t})=>Lwe(t)?new Uint8Array(t):t;import{finished as h_t}from"stream/promises";var dR=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=m_t(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],h_t(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||y_t(a,e,r,n)}finally{s.abort()}},m_t=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&g_t(t,r,n),n},g_t=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{__t(e,r),n.call(t,...i)}},__t=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},y_t=(t,e,r,n)=>{if(!S_t(t,e,r,n))throw t},S_t=(t,e,r,n=!0)=>r.propagating?fIe(t)||qM(t):(r.propagating=!0,c8(r,e)===n?fIe(t):qM(t)),c8=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",qM=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",fIe=t=>t?.code==="EPIPE";var pIe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,u)=>u8({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),u8=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=dR(t,e,u);if(c8(u,e)){await l;return}let[d]=await Promise.all([lIe({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 hIe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?eh([t,e].filter(Boolean)):void 0,mIe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>u8({...v_t(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:b_t(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),v_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}},b_t=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as E_t}from"events";var gIe=t=>_y(t,"ipc"),_Ie=(t,e)=>{let r=YD(t);oc({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var yIe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=gIe(o),a=Su(e,"ipc"),c=Su(r,"ipc");for await(let u of H5({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(ERe(t,i,c),i.push(u)),s&&_Ie(u,o);return i},SIe=async(t,e)=>(await Promise.allSettled([t]),e);var vIe=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=Rxe(t,f),A={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},S=pIe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:A}),E=mIe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:A}),b=[],x=yIe({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:b,verboseInfo:p}),P=w_t(m,t,A),O=T_t(h,A);try{return await Promise.race([Promise.all([{},Ixe(v),Promise.all(S),E,x,eRe(t,d),...P,...O]),_,A_t(t,y),...YAe(t,o,f,y),...gAe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:y}),...WAe({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=>a8(T))),a8(E),SIe(x,b),Promise.allSettled(P),Promise.allSettled(O)])}},w_t=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:dR(n,i,r)),T_t=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>ua(o,{checkOpen:!1})&&!sa(o)).map(({type:i,value:o,stream:s=o})=>dR(s,n,e,{isSameDirection:Xo.has(i),stopOnExit:i==="native"}))),A_t=async(t,{signal:e})=>{let[r]=await E_t(t,"error",{signal:e});throw r};var bIe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),fR=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=sc();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Py=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 R_t}from"stream";import{callbackify as x_t}from"util";import{finished as EIe}from"stream/promises";var l8=async t=>{if(t!==void 0)try{await d8(t)}catch{}},wIe=async t=>{if(t!==void 0)try{await f8(t)}catch{}},d8=async t=>{await EIe(t,{cleanup:!0,readable:!1,writable:!0})},f8=async t=>{await EIe(t,{cleanup:!0,readable:!0,writable:!1})},VM=async(t,e)=>{if(await t,e)throw e},GM=(t,e,r)=>{r&&!qM(r)?t.destroy(r):e&&t.destroy()};var TIe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||ho.has(r),{subprocessStdout:a,waitReadableDestroy:c}=p8(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=h8(a,s),{read:f,onStdoutDataDone:p}=m8({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new R_t({read:f,destroy:x_t(_8.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return g8({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},p8=(t,e,r)=>{let n=Ey(t,e),i=fR(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},h8=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:s8},m8=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=sc(),s=BM({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){I_t(this,s,o)},onStdoutDataDone:o}},I_t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},g8=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await f8(t),await n,await l8(i),await e,r.readable&&r.push(null)}catch(o){await l8(i),AIe(r,o)}},_8=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Py(r,e)&&(AIe(t,n),await VM(e,n))},AIe=(t,e)=>{GM(t,t.readable,e)};import{Writable as O_t}from"stream";import{callbackify as RIe}from"util";var xIe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=y8(t,r,e),s=new O_t({...S8(n,t,i),destroy:RIe(b8.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return v8(n,s),s},y8=(t,e,r)=>{let n=sM(t,e),i=fR(r,n,"writableFinal"),o=fR(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},S8=(t,e,r)=>({write:P_t.bind(void 0,t),final:RIe(C_t.bind(void 0,t,e,r))}),P_t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},C_t=async(t,e,r)=>{await Py(r,e)&&(t.writable&&t.end(),await e)},v8=async(t,e,r)=>{try{await d8(t),e.writable&&e.end()}catch(n){await wIe(r),IIe(e,n)}},b8=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Py(r,e),await Py(n,e)&&(IIe(t,i),await VM(e,i))},IIe=(t,e)=>{GM(t,t.writable,e)};import{Duplex as k_t}from"stream";import{callbackify as N_t}from"util";var OIe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||ho.has(r),{subprocessStdout:c,waitReadableDestroy:u}=p8(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=y8(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=h8(c,a),{read:_,onStdoutDataDone:y}=m8({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),v=new k_t({read:_,...S8(l,t,d),destroy:N_t($_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 g8({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:l}),v8(l,v,c),v},$_t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([_8({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),b8({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var E8=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||ho.has(e),s=Ey(t,r),a=BM({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return D_t(a,s,t)},D_t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var PIe=(t,{encoding:e})=>{let r=bIe();t.readable=TIe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=xIe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=OIe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=E8.bind(void 0,t,e),t[Symbol.asyncIterator]=E8.bind(void 0,t,e,{})};var CIe=(t,e)=>{for(let[r,n]of L_t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},M_t=(async()=>{})().constructor.prototype,L_t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(M_t,t)]);var kIe=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=z_t(t,e,r),{subprocess:f,promise:p}=B_t({file:i,commandArguments:o,options:l,startTime:c,verboseInfo:u,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=jM.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),CIe(f,p),ac.set(f,{options:l,fileDescriptors:d}),f},z_t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=JD(t,e,r),{file:a,commandArguments:c,options:u}=_M(t,e,r),l=j_t(u),d=qxe(l,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},j_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}},B_t=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=F_t(...yM(t,e,r))}catch(h){return Fxe({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;U_t(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];Xxe(c,a,u),eIe(c,r,u);let d={},f=sc();c.kill=hAe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=hIe(c,r),PIe(c,r),Mxe(c,r);let p=q_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}},q_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 vIe({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,E)=>bu(S,e,E)),v=bu(m,e,"all"),A=V_t({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:s,escapedCommand:a,startTime:r});return xy(A,n,e)},V_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?sR({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 cc,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:l,isSync:!1}):RM({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:o,options:a,startTime:l});var HM=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,G_t(n,t[n],i)]));return{...t,...r}},G_t=(t,e,r)=>H_t.has(t)&&Tr(e)&&Tr(r)?{...e,...r}:r,H_t=new Set(["env",...X9]);var fd=(t,e,r,n)=>{let i=(s,a,c)=>fd(s,a,r,c),o=(...s)=>W_t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},W_t=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Tr(o))return i(t,HM(r,o),n);let{file:a,commandArguments:c,options:u,isSync:l}=K_t({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return l?Pxe(a,c,u):kIe(a,c,u,i)},K_t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=qwe(e)?Vwe(e,r):[e,...r],[s,a,c]=zD(...o),u=HM(HM(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 NIe=({file:t,commandArguments:e})=>DIe(t,e),$Ie=({file:t,commandArguments:e})=>({...DIe(t,e),isSync:!0}),DIe=(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]=Y_t(t);return{file:r,commandArguments:n}},Y_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(Z_t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},Z_t=/ +/g;var MIe=(t,e,r)=>{t.sync=e(J_t,r),t.s=t.sync},LIe=({options:t})=>UIe(t),J_t=({options:t})=>({...UIe(t),isSync:!0}),UIe=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"}:{},FIe={preferLocal:!0};var zIe=fd(()=>({})),ogr=fd(()=>({isSync:!0})),jIe=fd(NIe),sgr=fd($Ie),agr=fd(JAe),cgr=fd(LIe,{},FIe,MIe),{sendMessage:ugr,getOneMessage:lgr,getEachMessage:dgr,getCancelSignal:fgr}=Lxe();var BIe=!1,qIe,Q_t=t=>{qIe??=t},VIe=t=>{BIe=!0,Q_t(t)},Bn=()=>BIe,Eu=()=>qIe,GIe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var pR=null,HIe=t=>(pR&&pR.destroy(),pR=new Qo({totalAllowedTime:t}),pR),WIe=()=>pR;var Qo=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&&Bn())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 sk({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 KIe={name:"@netlify/agent-runner-cli",type:"module",version:"2.14.0-nb590e7980a5a5.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 nyt=tyt(import.meta.url),iyt=wu.dirname(nyt),oyt=ryt(import.meta.url),Cy=ce("shell"),w8=new Set,YIe={preferLocal:!0},wt=(t,e,r)=>{let[n,i]=syt(e,r),o={...YIe,...i},s=zIe(t,n,o);JIe(s,o),eOe(s);let a=r?.idleTimeout;return a&&a>0&&QIe(s,a),s},ZIe=(t,e)=>{let r={...YIe,...e},n=jIe(t,r);return JIe(n,r),eOe(n),e?.idleTimeout&&e.idleTimeout>0&&QIe(n,e.idleTimeout),n},syt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},JIe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||lc.env.NETLIFY_LOCAL_QUIET==="true")return;if(lc.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Dw).pipe(lc.stdout),t.stderr?.pipe(new Dw).pipe(lc.stderr);return}t.stdout?.pipe(lc.stdout),t.stderr?.pipe(lc.stderr)},T8=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(lc.kill(-t.pid,e),Cy.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Cy.error("Error killing process:",r),!1}},XIe=t=>T8(t,"SIGKILL"),QIe=(t,e)=>{let r=null,n=()=>{Cy.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),T8(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Cy.log(`Force killing idle process ${t.pid}`),XIe(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)},eOe=t=>{w8.add(t);let e=WIe();if(e){let r=e.onTimesUp(()=>{Cy.log(`Global timer expired, killing process ${t.pid}`),T8(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Cy.log(`Force killing process ${t.pid} after timeout`),XIe(t))},5e3)});t.on("exit",()=>{w8.delete(t),r()}),t.on("error",()=>{w8.delete(t),r()})}};function dc(t,e){if(!lc.env.NETLIFY_LOCAL_MODE)try{let i=oyt.resolve(KIe.name),o=wu.dirname(i);for(;o!==wu.dirname(o);){let s=wu.dirname(o);if(wu.basename(s)==="node_modules"){let a=wu.join(s,".bin",e);if(WM.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(lc.env.NODE_PATH){let i=wu.join(lc.env.NODE_PATH,".bin",e);if(WM.existsSync(i))return i}let r=wu.join(t,"node_modules",".bin",e);if(WM.existsSync(r))return r;let n=wu.join(iyt,"..","node_modules",".bin",e);if(WM.existsSync(n))return n}var ky=ce("repo"),aOe="runner-diffs-",A8=t=>`${aOe}${t}-`,cOe=async t=>{let e=YM.tmpdir(),r;try{r=await di.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(aOe)&&!n.startsWith(A8(t))).map(n=>di.rm(es.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},tOe=async t=>{let e=ayt("sha256");for await(let r of cyt(t))e.update(r);return e.digest("hex")},rOe=async(t,e)=>t.size===e.size&&await tOe(t.path)===await tOe(e.path),uOe=/.. (.+)?\.log$/,uyt=[uOe],lyt=1,nOe=t=>{let e=t.split(`
387
+ if (condition) { yield value; }`)};import{Buffer as _mt}from"buffer";import{StringDecoder as ymt}from"string_decoder";var kM=(t,e,r)=>{if(r)return;if(t)return{transform:Smt.bind(void 0,new TextEncoder)};let n=new ymt(e);return{transform:vmt.bind(void 0,n),final:bmt.bind(void 0,n)}},Smt=function*(t,e){_mt.isBuffer(e)?yield yu(e):typeof e=="string"?yield t.encode(e):yield e},vmt=function*(t,e){yield Hr(e)?t.write(e):e},bmt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as hxe}from"util";var z5=hxe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),NM=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=wmt}=e[r];for await(let i of n(t))yield*NM(i,e,r+1)},mxe=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*NM(n,r,e+1)},gxe=hxe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),wmt=function*(t){yield t};var j5=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},_xe=(t,e)=>[...e.flatMap(r=>[...Qp(r,t,0)]),...aR(t)],Qp=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Amt}=e[r];for(let i of n(t))yield*Qp(i,e,r+1)},aR=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Tmt(r,Number(e),t)},Tmt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Qp(n,r,e+1)},Amt=function*(t){yield t};var B5=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Sxe(t,s,o),u=Xp(e),l=Xp(r),d=u?z5.bind(void 0,NM,a):j5.bind(void 0,Qp),f=u||l?z5.bind(void 0,mxe,a):j5.bind(void 0,aR),p=u||l?gxe.bind(void 0,a):void 0;return{stream:new Rmt({writableObjectMode:n,writableHighWaterMark:yxe(n),readableObjectMode:i,readableHighWaterMark:yxe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},$M=(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=Sxe(s,r,a);t=_xe(c,t)}return t},Sxe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:dxe(n,a)},kM(r,s,n),CM(r,o,n,c),{transform:t,final:e},{transform:fxe(i,a)},lxe({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var vxe=(t,e)=>{for(let r of xmt(t))Imt(t,r,e)},xmt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),Imt=(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 ${dd[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>Omt(a,n));r.input=JA(s)},Omt=(t,e)=>{let r=$M(t,e,"utf8",!0);return Pmt(r),JA(r)},Pmt=t=>{let e=t.find(r=>typeof r!="string"&&!Hr(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 $mt,appendFileSync as Dmt}from"fs";var DM=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&_y(r,n)&&!ho.has(e)&&Cmt(n)&&(t.some(({type:i,value:o})=>i==="native"&&kmt.has(o))||t.every(({type:i})=>Xo.has(i))),Cmt=t=>t===1||t===2,kmt=new Set(["pipe","overlapped"]),bxe=async(t,e,r,n)=>{for await(let i of t)Nmt(e)||wxe(i,r,n)},Exe=(t,e,r)=>{for(let n of t)wxe(n,e,r)},Nmt=t=>t._readableState.pipes.length>0,wxe=(t,e,r)=>{let n=YD(t);oc({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Txe=({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)=>Mmt({result:c,fileDescriptors:t,fdNumber:u,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},Mmt=({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=ARe(t,o,d),p=yu(f),{stdioItems:h,objectMode:m}=e[r],_=Lmt([p],h,c,n),{serializedResult:y,finalResult:v=y}=Umt({chunks:_,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});Fmt({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&&zmt(y,h,i),A}catch(S){return n.error=S,A}},Lmt=(t,e,r,n)=>{try{return $M(t,e,r,!1)}catch(i){return n.error=i,t}},Umt=({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=Fwe(t,r);return n[o]?{serializedResult:s,finalResult:F5(s,!i[o],e)}:{serializedResult:s}},Fmt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!DM({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=F5(t,!1,s);try{Exe(a,e,n)}catch(c){r.error??=c}},zmt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>OM.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?Dmt(n,t):(r.add(o),$mt(n,t))}};var Axe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,bu(e,r,"all")]:Array.isArray(e)?[bu(t,r,"all"),...e]:Hr(t)&&Hr(e)?K9([t,e]):`${t}${e}`};import{once as q5}from"events";var Rxe=async(t,e)=>{let[r,n]=await jmt(t);return e.isForcefullyTerminated??=!1,[r,n]},jmt=async t=>{let[e,r]=await Promise.allSettled([q5(t,"spawn"),q5(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?xxe(t):r.value},xxe=async t=>{try{return await q5(t,"exit")}catch{return xxe(t)}},Ixe=async t=>{let[e,r]=await t;if(!Bmt(e,r)&&V5(e,r))throw new aa;return[e,r]},Bmt=(t,e)=>t===void 0&&e===void 0,V5=(t,e)=>t!==0||e!==null;var Oxe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=qmt(t,e,r),s=o?.code==="ETIMEDOUT",a=TRe(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},qmt=(t,e,r)=>t!==void 0?t:V5(e,r)?new aa:void 0;var Pxe=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=Gmt(t,e,r),d=Kmt({file:n,commandArguments:i,options:u,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:l,startTime:a});return xy(d,c,u)},Gmt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=JD(t,e,r),a=Hmt(r),{file:c,commandArguments:u,options:l}=_M(t,e,a);Wmt(l);let d=sxe(l,s);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},Hmt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Wmt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&MM("ipcInput"),t&&MM("ipc: true"),r&&MM("detached: true"),n&&MM("cancelSignal")},MM=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Kmt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=Ymt({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}=Oxe(c,r),{output:h,error:m=u}=Txe({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),_=h.map((v,A)=>bu(v,r,A)),y=bu(Axe(h,r),r,"all");return Jmt({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},Ymt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{vxe(o,r);let a=Zmt(r);return Vmt(...yM(t,e,a))}catch(a){return Ry({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},Zmt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:AM(e)}),Jmt=({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?RM({command:c,escapedCommand:u,stdio:o,all:s,ipcOutput:[],options:a,startTime:l}):sR({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 U_t}from"events";import{spawn as F_t}from"child_process";import Dxe from"process";import{once as G5,on as Xmt}from"events";var Cxe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(vy({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:dM(t)}),Qmt({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),Qmt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{aM(e,i);let o=ld(t,e,r),s=new AbortController;try{return await Promise.race([egt(o,n,s),tgt(o,r,s),rgt(o,r,s)])}catch(a){throw by(t),a}finally{s.abort(),cM(e,i)}},egt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await G5(t,"message",{signal:r});return n}for await(let[n]of Xmt(t,"message",{signal:r}))if(e(n))return n},tgt=async(t,e,{signal:r})=>{await G5(t,"disconnect",{signal:r}),_Ae(e)},rgt=async(t,e,{signal:r})=>{let[n]=await G5(t,"strict:error",{signal:r});throw iM(n,e)};import{once as Nxe,on as ngt}from"events";var $xe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>H5({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),H5=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{vy({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:dM(t)}),aM(e,o);let s=ld(t,e,r),a=new AbortController,c={};return igt(t,s,a),ogt({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),sgt({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},igt=async(t,e,r)=>{try{await Nxe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},ogt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Nxe(t,"strict:error",{signal:r.signal});n.error=iM(i,e),r.abort()}catch{}},sgt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of ngt(r,"message",{signal:o.signal}))kxe(s),yield c}catch{kxe(s)}finally{o.abort(),cM(e,a),n||by(t),i&&await t}},kxe=({error:t})=>{if(t)throw t};var Mxe=(t,{ipc:e})=>{Object.assign(t,Uxe(t,!1,e))},Lxe=()=>{let t=Dxe,e=!0,r=Dxe.channel!==void 0;return{...Uxe(t,e,r),getCancelSignal:VAe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Uxe=(t,e,r)=>({sendMessage:mM.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Cxe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:$xe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as agt}from"child_process";import{PassThrough as cgt,Readable as ugt,Writable as lgt,Duplex as dgt}from"stream";var Fxe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{M5(n);let a=new agt;fgt(a,n),Object.assign(a,{readable:pgt,writable:hgt,duplex:mgt});let c=Ry({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),u=ggt(c,s,i);return{subprocess:a,promise:u}},fgt=(t,e)=>{let r=cR(),n=cR(),i=cR(),o=Array.from({length:e.length-3},cR),s=cR(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},cR=()=>{let t=new cgt;return t.end(),t},pgt=()=>new ugt({read(){}}),hgt=()=>new lgt({write(){}}),mgt=()=>new dgt({read(){},write(){}}),ggt=async(t,e,r)=>xy(t,e,r);import{createReadStream as zxe,createWriteStream as jxe}from"fs";import{Buffer as _gt}from"buffer";import{Readable as uR,Writable as ygt,Duplex as Sgt}from"stream";var qxe=(t,e)=>PM(vgt,t,e,!1),lR=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${dd[t]}.`)},Bxe={fileNumber:lR,generator:B5,asyncGenerator:B5,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Sgt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},vgt={input:{...Bxe,fileUrl:({value:t})=>({stream:zxe(t)}),filePath:({value:{file:t}})=>({stream:zxe(t)}),webStream:({value:t})=>({stream:uR.fromWeb(t)}),iterable:({value:t})=>({stream:uR.from(t)}),asyncIterable:({value:t})=>({stream:uR.from(t)}),string:({value:t})=>({stream:uR.from(t)}),uint8Array:({value:t})=>({stream:uR.from(_gt.from(t))})},output:{...Bxe,fileUrl:({value:t})=>({stream:jxe(t)}),filePath:({value:{file:t,append:e}})=>({stream:jxe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:ygt.fromWeb(t)}),iterable:lR,asyncIterable:lR,string:lR,uint8Array:lR}};import{on as bgt,once as Vxe}from"events";import{PassThrough as Egt,getDefaultHighWaterMark as wgt}from"stream";import{finished as Wxe}from"stream/promises";function eh(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)K5(i);let e=t.some(({readableObjectMode:i})=>i),r=Tgt(t,e),n=new W5({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Tgt=(t,e)=>{if(t.length===0)return wgt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},W5=class extends Egt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(K5(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Agt(this,this.#e,this.#o);let r=Igt({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(K5(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)}},Agt=async(t,e,r)=>{LM(t,Gxe);let n=new AbortController;try{await Promise.race([Rgt(t,n),xgt(t,e,r,n)])}finally{n.abort(),LM(t,-Gxe)}},Rgt=async(t,{signal:e})=>{try{await Wxe(t,{signal:e,cleanup:!0})}catch(r){throw Kxe(t,r),r}},xgt=async(t,e,r,{signal:n})=>{for await(let[i]of bgt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},K5=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Igt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{LM(t,Hxe);let a=new AbortController;try{await Promise.race([Ogt(o,e,a),Pgt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),Cgt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),LM(t,-Hxe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?Y5(t):kgt(t))},Ogt=async(t,e,{signal:r})=>{try{await t,r.aborted||Y5(e)}catch(n){r.aborted||Kxe(e,n)}},Pgt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await Wxe(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;Yxe(s)?i.add(e):Zxe(t,s)}},Cgt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await Vxe(t,i,{signal:o}),!t.readable)return Vxe(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},kgt=t=>{t.writable&&t.end()},Kxe=(t,e)=>{Yxe(e)?Y5(t):Zxe(t,e)},Yxe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Y5=t=>{(t.readable||t.writable)&&t.destroy()},Zxe=(t,e)=>{t.destroyed||(t.once("error",Ngt),t.destroy(e))},Ngt=()=>{},LM=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Gxe=2,Hxe=1;import{finished as Jxe}from"stream/promises";var Oy=(t,e)=>{t.pipe(e),$gt(t,e),Dgt(t,e)},$gt=async(t,e)=>{if(!(sa(t)||sa(e))){try{await Jxe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}Z5(e)}},Z5=t=>{t.writable&&t.end()},Dgt=async(t,e)=>{if(!(sa(t)||sa(e))){try{await Jxe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}J5(t)}},J5=t=>{t.readable&&t.destroy()};var Xxe=(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})=>Xo.has(c)))Mgt(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Xo.has(c)))Ugt({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]:eh(o);Oy(s,i)}},Mgt=(t,e,r,n)=>{r==="output"?Oy(t.stdio[n],e):Oy(e,t.stdio[n]);let i=Lgt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},Lgt=["stdin","stdout","stderr"],Ugt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;Fgt(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},Fgt=(t,{signal:e})=>{sa(t)&&Zp(t,zgt,e)},zgt=2;import{addAbortListener as qgt}from"events";var th=[];th.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&th.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&th.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var UM=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",X5=Symbol.for("signal-exit emitter"),Q5=globalThis,jgt=Object.defineProperty.bind(Object),e8=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(Q5[X5])return Q5[X5];jgt(Q5,X5,{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}},FM=class{},Bgt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),t8=class extends FM{onExit(){return()=>{}}load(){}unload(){}},r8=class extends FM{#e=n8.platform==="win32"?"SIGINT":"SIGHUP";#r=new e8;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of th)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(!UM(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 th)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,th.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 UM(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"&&UM(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)}},n8=globalThis.process,{onExit:Qxe,load:mpr,unload:gpr}=Bgt(UM(n8)?new r8(n8):new t8);var eIe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Qxe(()=>{t.kill()});qgt(n,()=>{i()})};var rIe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=ZD(),{destination:s,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=Vgt(r,n,i),{sourceStream:d,sourceError:f}=Hgt(t,u),{options:p,fileDescriptors:h}=ac.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:o}},Vgt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=Ggt(t,e,...r),a=sM(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},Ggt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(tIe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||H9(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]=zD(r,...n);return{destination:e(tIe)(i,o,s),pipeOptions:s}}if(ac.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}`)},tIe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),Hgt=(t,e)=>{try{return{sourceStream:Ey(t,e)}}catch(r){return{sourceError:r}}};var iIe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=Wgt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw i8({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},Wgt=({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 Z5(r),e},i8=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Ry({error:t,command:nIe,escapedCommand:nIe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),nIe="source.pipe(destination)";var oIe=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 Kgt}from"stream/promises";var sIe=(t,e,r)=>{let n=zM.has(e)?Zgt(t,e):Ygt(t,e);return Zp(t,Xgt,r.signal),Zp(e,Qgt,r.signal),Jgt(e),n},Ygt=(t,e)=>{let r=eh([t]);return Oy(r,e),zM.set(e,r),r},Zgt=(t,e)=>{let r=zM.get(e);return r.add(t),r},Jgt=async t=>{try{await Kgt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}zM.delete(t)},zM=new WeakMap,Xgt=2,Qgt=1;import{aborted as e_t}from"util";var aIe=(t,e)=>t===void 0?[]:[t_t(t,e)],t_t=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await e_t(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw i8({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var jM=(t,...e)=>{if(Tr(e[0]))return jM.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=rIe(t,...e),i=r_t({...n,destination:r});return i.pipe=jM.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},r_t=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=n_t(t,i);iIe({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=sIe(e,o,d);return await Promise.race([oIe(l),...aIe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},n_t=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as l_t}from"timers/promises";import{on as i_t}from"events";import{getDefaultHighWaterMark as o_t}from"stream";var BM=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return s_t(e,s),uIe({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},s_t=async(t,e)=>{try{await t}catch{}finally{e.abort()}},o8=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;a_t(e,s,t);let a=t.readableObjectMode&&!o;return uIe({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},a_t=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},uIe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=i_t(t,"data",{signal:e.signal,highWaterMark:cIe,highWatermark:cIe});return c_t({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},s8=o_t(!0),cIe=s8,c_t=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=u_t({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Qp(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*aR(a)}},u_t=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[kM(t,r,!e),CM(t,i,!n,{})].filter(Boolean);var lIe=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=d_t({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([f_t(t),d]);return}let f=L5(c,r),p=o8({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([p_t({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},d_t=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!DM({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=o8({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await bxe(a,t,r,o)},f_t=async t=>{await l_t(),t.readableFlowing===null&&t.resume()},p_t=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await EM(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await wM(r,{maxBuffer:o})):await Ay(r,{maxBuffer:o})}catch(a){return dIe(bRe({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},a8=async t=>{try{return await t}catch(e){return dIe(e)}},dIe=({bufferedData:t})=>Lwe(t)?new Uint8Array(t):t;import{finished as h_t}from"stream/promises";var dR=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=m_t(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],h_t(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||y_t(a,e,r,n)}finally{s.abort()}},m_t=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&g_t(t,r,n),n},g_t=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{__t(e,r),n.call(t,...i)}},__t=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},y_t=(t,e,r,n)=>{if(!S_t(t,e,r,n))throw t},S_t=(t,e,r,n=!0)=>r.propagating?fIe(t)||qM(t):(r.propagating=!0,c8(r,e)===n?fIe(t):qM(t)),c8=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",qM=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",fIe=t=>t?.code==="EPIPE";var pIe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,u)=>u8({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),u8=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=dR(t,e,u);if(c8(u,e)){await l;return}let[d]=await Promise.all([lIe({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 hIe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?eh([t,e].filter(Boolean)):void 0,mIe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>u8({...v_t(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:b_t(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),v_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}},b_t=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as E_t}from"events";var gIe=t=>_y(t,"ipc"),_Ie=(t,e)=>{let r=YD(t);oc({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var yIe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=gIe(o),a=Su(e,"ipc"),c=Su(r,"ipc");for await(let u of H5({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(ERe(t,i,c),i.push(u)),s&&_Ie(u,o);return i},SIe=async(t,e)=>(await Promise.allSettled([t]),e);var vIe=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=Rxe(t,f),A={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},S=pIe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:A}),E=mIe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:A}),b=[],x=yIe({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:b,verboseInfo:p}),P=w_t(m,t,A),O=T_t(h,A);try{return await Promise.race([Promise.all([{},Ixe(v),Promise.all(S),E,x,eRe(t,d),...P,...O]),_,A_t(t,y),...YAe(t,o,f,y),...gAe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:y}),...WAe({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=>a8(T))),a8(E),SIe(x,b),Promise.allSettled(P),Promise.allSettled(O)])}},w_t=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:dR(n,i,r)),T_t=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>ua(o,{checkOpen:!1})&&!sa(o)).map(({type:i,value:o,stream:s=o})=>dR(s,n,e,{isSameDirection:Xo.has(i),stopOnExit:i==="native"}))),A_t=async(t,{signal:e})=>{let[r]=await E_t(t,"error",{signal:e});throw r};var bIe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),fR=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=sc();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Py=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 R_t}from"stream";import{callbackify as x_t}from"util";import{finished as EIe}from"stream/promises";var l8=async t=>{if(t!==void 0)try{await d8(t)}catch{}},wIe=async t=>{if(t!==void 0)try{await f8(t)}catch{}},d8=async t=>{await EIe(t,{cleanup:!0,readable:!1,writable:!0})},f8=async t=>{await EIe(t,{cleanup:!0,readable:!0,writable:!1})},VM=async(t,e)=>{if(await t,e)throw e},GM=(t,e,r)=>{r&&!qM(r)?t.destroy(r):e&&t.destroy()};var TIe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||ho.has(r),{subprocessStdout:a,waitReadableDestroy:c}=p8(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=h8(a,s),{read:f,onStdoutDataDone:p}=m8({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new R_t({read:f,destroy:x_t(_8.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return g8({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},p8=(t,e,r)=>{let n=Ey(t,e),i=fR(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},h8=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:s8},m8=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=sc(),s=BM({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){I_t(this,s,o)},onStdoutDataDone:o}},I_t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},g8=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await f8(t),await n,await l8(i),await e,r.readable&&r.push(null)}catch(o){await l8(i),AIe(r,o)}},_8=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Py(r,e)&&(AIe(t,n),await VM(e,n))},AIe=(t,e)=>{GM(t,t.readable,e)};import{Writable as O_t}from"stream";import{callbackify as RIe}from"util";var xIe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=y8(t,r,e),s=new O_t({...S8(n,t,i),destroy:RIe(b8.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return v8(n,s),s},y8=(t,e,r)=>{let n=sM(t,e),i=fR(r,n,"writableFinal"),o=fR(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},S8=(t,e,r)=>({write:P_t.bind(void 0,t),final:RIe(C_t.bind(void 0,t,e,r))}),P_t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},C_t=async(t,e,r)=>{await Py(r,e)&&(t.writable&&t.end(),await e)},v8=async(t,e,r)=>{try{await d8(t),e.writable&&e.end()}catch(n){await wIe(r),IIe(e,n)}},b8=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Py(r,e),await Py(n,e)&&(IIe(t,i),await VM(e,i))},IIe=(t,e)=>{GM(t,t.writable,e)};import{Duplex as k_t}from"stream";import{callbackify as N_t}from"util";var OIe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||ho.has(r),{subprocessStdout:c,waitReadableDestroy:u}=p8(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=y8(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=h8(c,a),{read:_,onStdoutDataDone:y}=m8({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),v=new k_t({read:_,...S8(l,t,d),destroy:N_t($_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 g8({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:l}),v8(l,v,c),v},$_t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([_8({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),b8({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var E8=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||ho.has(e),s=Ey(t,r),a=BM({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return D_t(a,s,t)},D_t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var PIe=(t,{encoding:e})=>{let r=bIe();t.readable=TIe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=xIe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=OIe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=E8.bind(void 0,t,e),t[Symbol.asyncIterator]=E8.bind(void 0,t,e,{})};var CIe=(t,e)=>{for(let[r,n]of L_t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},M_t=(async()=>{})().constructor.prototype,L_t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(M_t,t)]);var kIe=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=z_t(t,e,r),{subprocess:f,promise:p}=B_t({file:i,commandArguments:o,options:l,startTime:c,verboseInfo:u,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=jM.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),CIe(f,p),ac.set(f,{options:l,fileDescriptors:d}),f},z_t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=JD(t,e,r),{file:a,commandArguments:c,options:u}=_M(t,e,r),l=j_t(u),d=qxe(l,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},j_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}},B_t=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=F_t(...yM(t,e,r))}catch(h){return Fxe({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;U_t(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];Xxe(c,a,u),eIe(c,r,u);let d={},f=sc();c.kill=hAe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=hIe(c,r),PIe(c,r),Mxe(c,r);let p=q_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}},q_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 vIe({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,E)=>bu(S,e,E)),v=bu(m,e,"all"),A=V_t({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:s,escapedCommand:a,startTime:r});return xy(A,n,e)},V_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?sR({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 cc,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:l,isSync:!1}):RM({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:o,options:a,startTime:l});var HM=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,G_t(n,t[n],i)]));return{...t,...r}},G_t=(t,e,r)=>H_t.has(t)&&Tr(e)&&Tr(r)?{...e,...r}:r,H_t=new Set(["env",...X9]);var fd=(t,e,r,n)=>{let i=(s,a,c)=>fd(s,a,r,c),o=(...s)=>W_t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},W_t=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Tr(o))return i(t,HM(r,o),n);let{file:a,commandArguments:c,options:u,isSync:l}=K_t({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return l?Pxe(a,c,u):kIe(a,c,u,i)},K_t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=qwe(e)?Vwe(e,r):[e,...r],[s,a,c]=zD(...o),u=HM(HM(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 NIe=({file:t,commandArguments:e})=>DIe(t,e),$Ie=({file:t,commandArguments:e})=>({...DIe(t,e),isSync:!0}),DIe=(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]=Y_t(t);return{file:r,commandArguments:n}},Y_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(Z_t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},Z_t=/ +/g;var MIe=(t,e,r)=>{t.sync=e(J_t,r),t.s=t.sync},LIe=({options:t})=>UIe(t),J_t=({options:t})=>({...UIe(t),isSync:!0}),UIe=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"}:{},FIe={preferLocal:!0};var zIe=fd(()=>({})),ogr=fd(()=>({isSync:!0})),jIe=fd(NIe),sgr=fd($Ie),agr=fd(JAe),cgr=fd(LIe,{},FIe,MIe),{sendMessage:ugr,getOneMessage:lgr,getEachMessage:dgr,getCancelSignal:fgr}=Lxe();var BIe=!1,qIe,Q_t=t=>{qIe??=t},VIe=t=>{BIe=!0,Q_t(t)},Bn=()=>BIe,Eu=()=>qIe,GIe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var pR=null,HIe=t=>(pR&&pR.destroy(),pR=new Qo({totalAllowedTime:t}),pR),WIe=()=>pR;var Qo=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&&Bn())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 sk({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 KIe={name:"@netlify/agent-runner-cli",type:"module",version:"2.14.0-nb62dba44206b2.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 nyt=tyt(import.meta.url),iyt=wu.dirname(nyt),oyt=ryt(import.meta.url),Cy=ce("shell"),w8=new Set,YIe={preferLocal:!0},wt=(t,e,r)=>{let[n,i]=syt(e,r),o={...YIe,...i},s=zIe(t,n,o);JIe(s,o),eOe(s);let a=r?.idleTimeout;return a&&a>0&&QIe(s,a),s},ZIe=(t,e)=>{let r={...YIe,...e},n=jIe(t,r);return JIe(n,r),eOe(n),e?.idleTimeout&&e.idleTimeout>0&&QIe(n,e.idleTimeout),n},syt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},JIe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||lc.env.NETLIFY_LOCAL_QUIET==="true")return;if(lc.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Dw).pipe(lc.stdout),t.stderr?.pipe(new Dw).pipe(lc.stderr);return}t.stdout?.pipe(lc.stdout),t.stderr?.pipe(lc.stderr)},T8=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(lc.kill(-t.pid,e),Cy.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Cy.error("Error killing process:",r),!1}},XIe=t=>T8(t,"SIGKILL"),QIe=(t,e)=>{let r=null,n=()=>{Cy.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),T8(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Cy.log(`Force killing idle process ${t.pid}`),XIe(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)},eOe=t=>{w8.add(t);let e=WIe();if(e){let r=e.onTimesUp(()=>{Cy.log(`Global timer expired, killing process ${t.pid}`),T8(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Cy.log(`Force killing process ${t.pid} after timeout`),XIe(t))},5e3)});t.on("exit",()=>{w8.delete(t),r()}),t.on("error",()=>{w8.delete(t),r()})}};function dc(t,e){if(!lc.env.NETLIFY_LOCAL_MODE)try{let i=oyt.resolve(KIe.name),o=wu.dirname(i);for(;o!==wu.dirname(o);){let s=wu.dirname(o);if(wu.basename(s)==="node_modules"){let a=wu.join(s,".bin",e);if(WM.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(lc.env.NODE_PATH){let i=wu.join(lc.env.NODE_PATH,".bin",e);if(WM.existsSync(i))return i}let r=wu.join(t,"node_modules",".bin",e);if(WM.existsSync(r))return r;let n=wu.join(iyt,"..","node_modules",".bin",e);if(WM.existsSync(n))return n}var ky=ce("repo"),aOe="runner-diffs-",A8=t=>`${aOe}${t}-`,cOe=async t=>{let e=YM.tmpdir(),r;try{r=await di.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(aOe)&&!n.startsWith(A8(t))).map(n=>di.rm(es.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},tOe=async t=>{let e=ayt("sha256");for await(let r of cyt(t))e.update(r);return e.digest("hex")},rOe=async(t,e)=>t.size===e.size&&await tOe(t.path)===await tOe(e.path),uOe=/.. (.+)?\.log$/,uyt=[uOe],lyt=1,nOe=t=>{let e=t.split(`
386
388
  `).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)},dyt=t=>t instanceof Error&&String(t.stderr??"").includes("No such remote"),iOe=t=>{let e=t instanceof Error?t.message:String(t),r=String(t?.stderr??"").trim();return An(r?`${e}: ${r}`:e)},fyt=t=>/Authentication failed|returned error: 401/.test(String(t?.stderr??"")),oOe=t=>t.pathname.replace(/\/+$/,"").replace(/\.git$/,""),pyt=(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&&oOe(n)===oOe(r)&&n.password!==""}catch{return!1}},sOe={stdin:"pipe",stdout:"pipe",stderr:"pipe",stripFinalNewline:!1},KM=500,hR=class extends Error{constructor(r,n){super(n instanceof Error?n.message:String(n));this.step=r;this.cause=n}},ji=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 di.writeFile(await this.getSetupMetadataPath(),JSON.stringify(s)),{rewrittenFileCount:n.rewrittenFileCount}}catch(n){throw new hR(r,n)}}run(e,r={}){return wt("git",e,{cwd:this.cwd,...r,env:{...r.env,NETLIFY_INTERNAL_GIT:"1"}})}async commitAndCreateDiffs({config:e,isRetry:r}){ky.info("Getting runner diffs");let n=await this.hasAgentChanges(),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!r){let u=nOe(o);await this.discardSetupOnlyChanges(u)}ky.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 di.mkdtemp(es.join(YM.tmpdir(),A8(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(`
387
389
  `).filter(i=>uyt.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 di.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(`
388
390
  `)})}async stageBuildSetup(){await di.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 es.resolve(e,String(r).trim())}),this.setupMetadataPath}async listIndexEntries(e,r){let n=[];for(let i=0;i<e.length;i+=KM){let o=e.slice(i,i+KM).map(a=>`:(literal)${a}`),{stdout:s}=await this.run(["ls-files","--stage","-z","--",...o],{...sOe,...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 di.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(`
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@netlify/agent-runner-cli",
3
3
  "type": "module",
4
- "version": "2.14.0-nb590e7980a5a5.0",
4
+ "version": "2.14.0-nb62dba44206b2.0",
5
5
  "description": "CLI tool for running Netlify agents",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",