@netlify/agent-runner-cli 2.12.0-nb8c571bb6e224.0 → 2.12.0-nb987b7e96221d.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
@@ -218,6 +218,7 @@ ${E}`,d++;break;case"id":u=E.includes("\0")?void 0:E;break;case"retry":/^\d+$/.t
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
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
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 Database; keep any required data another way.
221
222
  ${Awe(t)}
222
223
  </rules>`,ND=({skillsDir:t,mode:e,runner:r})=>e==="ask"?Mut(t):Rwe(t,r),xwe=({cliPath:t,branch:e})=>["## Netlify Database (read-only)","",`This project has a Netlify Database (managed Postgres). You are connected to the \`${e}\` branch with a`,"read-only role, so you can answer questions about the schema and the data in it.","","Query it by running:","","```",`${t} db connect --query "SELECT count(*) FROM users"`,"```","",`Add \`--json\` for machine-readable output. Always pass \`--query\`: \`${t} db connect\` on its own opens an`,"interactive session that never returns.","","Rules for this run:","","- The connection is read-only. INSERT, UPDATE, DELETE, and DDL are refused by the database.","- Do NOT generate or run migrations, and do NOT run `drizzle-kit`. This run cannot change the schema.","- The branch is a fork of production taken when the branch was created, so data may lag production."," Say which branch you read when the answer depends on the data.","- Prefer schema queries (`information_schema`) and aggregates over selecting rows. When you do read rows,"," use a LIMIT and leave out columns holding personal data or secrets \u2014 query output is shown to the user"," and stored with the session."].join(`
223
224
  `),Iwe=async(t,e)=>{let r=await pwe(e);return r?Uut(Fut(r,e.runner),t):t},Uut=(t,e)=>[t,e].filter(Boolean).join(`
@@ -383,7 +384,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
383
384
  `,LF:`
384
385
  `,concatBytes:F5},lmt=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},dmt={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:lmt};import{Buffer as fmt}from"buffer";var gxe=(t,e)=>t?void 0:pmt.bind(void 0,e),pmt=function*(t,e){if(typeof e!="string"&&!Kr(e)&&!fmt.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},_xe=(t,e)=>t?hmt.bind(void 0,e):mmt.bind(void 0,e),hmt=function*(t,e){yxe(t,e),yield e},mmt=function*(t,e){if(yxe(t,e),typeof e!="string"&&!Kr(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},yxe=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
385
386
  Instead, \`yield\` should either be called with a value, or not be called at all. For example:
386
- if (condition) { yield value; }`)};import{Buffer as gmt}from"buffer";import{StringDecoder as _mt}from"string_decoder";var NM=(t,e,r)=>{if(r)return;if(t)return{transform:ymt.bind(void 0,new TextEncoder)};let n=new _mt(e);return{transform:Smt.bind(void 0,n),final:vmt.bind(void 0,n)}},ymt=function*(t,e){gmt.isBuffer(e)?yield Eu(e):typeof e=="string"?yield t.encode(e):yield e},Smt=function*(t,e){yield Kr(e)?t.write(e):e},vmt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Sxe}from"util";var j5=Sxe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),$M=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=bmt}=e[r];for await(let i of n(t))yield*$M(i,e,r+1)},vxe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Emt(r,Number(e),t)},Emt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*$M(n,r,e+1)},Exe=Sxe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),bmt=function*(t){yield t};var B5=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},bxe=(t,e)=>[...e.flatMap(r=>[...rh(r,t,0)]),...cR(t)],rh=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Tmt}=e[r];for(let i of n(t))yield*rh(i,e,r+1)},cR=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*wmt(r,Number(e),t)},wmt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*rh(n,r,e+1)},Tmt=function*(t){yield t};var q5=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Txe(t,s,o),u=th(e),l=th(r),d=u?j5.bind(void 0,$M,a):B5.bind(void 0,rh),f=u||l?j5.bind(void 0,vxe,a):B5.bind(void 0,cR),p=u||l?Exe.bind(void 0,a):void 0;return{stream:new Amt({writableObjectMode:n,writableHighWaterMark:wxe(n),readableObjectMode:i,readableHighWaterMark:wxe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},DM=(t,e,r,n)=>{let i=e.filter(({type:s})=>s==="generator"),o=n?i.reverse():i;for(let{value:s,optionName:a}of o){let c=Txe(s,r,a);t=bxe(c,t)}return t},Txe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:gxe(n,a)},NM(r,s,n),kM(r,o,n,c),{transform:t,final:e},{transform:_xe(i,a)},mxe({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Axe=(t,e)=>{for(let r of Rmt(t))xmt(t,r,e)},Rmt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),xmt=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${pd[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>Imt(a,n));r.input=JA(s)},Imt=(t,e)=>{let r=DM(t,e,"utf8",!0);return Omt(r),JA(r)},Omt=t=>{let e=t.find(r=>typeof r!="string"&&!Kr(r));if(e!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${e}.`)};import{writeFileSync as Nmt,appendFileSync as $mt}from"fs";var MM=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Sy(r,n)&&!go.has(e)&&Pmt(n)&&(t.some(({type:i,value:o})=>i==="native"&&Cmt.has(o))||t.every(({type:i})=>Qo.has(i))),Pmt=t=>t===1||t===2,Cmt=new Set(["pipe","overlapped"]),Rxe=async(t,e,r,n)=>{for await(let i of t)kmt(e)||Ixe(i,r,n)},xxe=(t,e,r)=>{for(let n of t)Ixe(n,e,r)},kmt=t=>t._readableState.pipes.length>0,Ixe=(t,e,r)=>{let n=ZD(t);sc({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Oxe=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,u)=>Dmt({result:c,fileDescriptors:t,fdNumber:u,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},Dmt=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:u,stripFinalNewline:l,maxBuffer:d})=>{if(t===null)return;let f=PRe(t,o,d),p=Eu(f),{stdioItems:h,objectMode:m}=e[r],_=Mmt([p],h,c,n),{serializedResult:y,finalResult:v=y}=Lmt({chunks:_,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});Umt({serializedResult:y,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let A=a[r]?v:void 0;try{return n.error===void 0&&Fmt(y,h,i),A}catch(S){return n.error=S,A}},Mmt=(t,e,r,n)=>{try{return DM(t,e,r,!1)}catch(i){return n.error=i,t}},Lmt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:JA(t)};let s=Vwe(t,r);return n[o]?{serializedResult:s,finalResult:z5(s,!i[o],e)}:{serializedResult:s}},Umt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!MM({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=z5(t,!1,s);try{xxe(a,e,n)}catch(c){r.error??=c}},Fmt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>PM.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?$mt(n,t):(r.add(o),Nmt(n,t))}};var Pxe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Tu(e,r,"all")]:Array.isArray(e)?[Tu(t,r,"all"),...e]:Kr(t)&&Kr(e)?Y9([t,e]):`${t}${e}`};import{once as V5}from"events";var Cxe=async(t,e)=>{let[r,n]=await zmt(t);return e.isForcefullyTerminated??=!1,[r,n]},zmt=async t=>{let[e,r]=await Promise.allSettled([V5(t,"spawn"),V5(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?kxe(t):r.value},kxe=async t=>{try{return await V5(t,"exit")}catch{return kxe(t)}},Nxe=async t=>{let[e,r]=await t;if(!jmt(e,r)&&G5(e,r))throw new ua;return[e,r]},jmt=(t,e)=>t===void 0&&e===void 0,G5=(t,e)=>t!==0||e!==null;var $xe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=Bmt(t,e,r),s=o?.code==="ETIMEDOUT",a=ORe(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},Bmt=(t,e,r)=>t!==void 0?t:G5(e,r)?new ua:void 0;var Dxe=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=Vmt(t,e,r),d=Wmt({file:n,commandArguments:i,options:u,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:l,startTime:a});return Oy(d,c,u)},Vmt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=JD(t,e,r),a=Gmt(r),{file:c,commandArguments:u,options:l}=yM(t,e,a);Hmt(l);let d=dxe(l,s);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},Gmt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Hmt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&LM("ipcInput"),t&&LM("ipc: true"),r&&LM("detached: true"),n&&LM("cancelSignal")},LM=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Wmt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=Kmt({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:u,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p}=$xe(c,r),{output:h,error:m=u}=Oxe({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),_=h.map((v,A)=>Tu(v,r,A)),y=Tu(Pxe(h,r),r,"all");return Zmt({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},Kmt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Axe(o,r);let a=Ymt(r);return qmt(...SM(t,e,a))}catch(a){return Iy({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},Ymt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:RM(e)}),Zmt=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:u,startTime:l})=>t===void 0?xM({command:c,escapedCommand:u,stdio:o,all:s,ipcOutput:[],options:a,startTime:l}):aR({error:t,command:c,escapedCommand:u,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:l,isSync:!0});import{setMaxListeners as L_t}from"events";import{spawn as U_t}from"child_process";import zxe from"process";import{once as H5,on as Xmt}from"events";var Mxe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(by({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:fM(t)}),Jmt({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),Jmt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{cM(e,i);let o=fd(t,e,r),s=new AbortController;try{return await Promise.race([Qmt(o,n,s),egt(o,r,s),tgt(o,r,s)])}catch(a){throw wy(t),a}finally{s.abort(),uM(e,i)}},Qmt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await H5(t,"message",{signal:r});return n}for await(let[n]of Xmt(t,"message",{signal:r}))if(e(n))return n},egt=async(t,e,{signal:r})=>{await H5(t,"disconnect",{signal:r}),bAe(e)},tgt=async(t,e,{signal:r})=>{let[n]=await H5(t,"strict:error",{signal:r});throw oM(n,e)};import{once as Uxe,on as rgt}from"events";var Fxe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>W5({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),W5=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{by({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:fM(t)}),cM(e,o);let s=fd(t,e,r),a=new AbortController,c={};return ngt(t,s,a),igt({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),ogt({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},ngt=async(t,e,r)=>{try{await Uxe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},igt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Uxe(t,"strict:error",{signal:r.signal});n.error=oM(i,e),r.abort()}catch{}},ogt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of rgt(r,"message",{signal:o.signal}))Lxe(s),yield c}catch{Lxe(s)}finally{o.abort(),uM(e,a),n||wy(t),i&&await t}},Lxe=({error:t})=>{if(t)throw t};var jxe=(t,{ipc:e})=>{Object.assign(t,qxe(t,!1,e))},Bxe=()=>{let t=zxe,e=!0,r=zxe.channel!==void 0;return{...qxe(t,e,r),getCancelSignal:YAe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},qxe=(t,e,r)=>({sendMessage:gM.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Mxe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Fxe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as sgt}from"child_process";import{PassThrough as agt,Readable as cgt,Writable as ugt,Duplex as lgt}from"stream";var Vxe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{L5(n);let a=new sgt;dgt(a,n),Object.assign(a,{readable:fgt,writable:pgt,duplex:hgt});let c=Iy({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),u=mgt(c,s,i);return{subprocess:a,promise:u}},dgt=(t,e)=>{let r=uR(),n=uR(),i=uR(),o=Array.from({length:e.length-3},uR),s=uR(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},uR=()=>{let t=new agt;return t.end(),t},fgt=()=>new cgt({read(){}}),pgt=()=>new ugt({write(){}}),hgt=()=>new lgt({read(){},write(){}}),mgt=async(t,e,r)=>Oy(t,e,r);import{createReadStream as Gxe,createWriteStream as Hxe}from"fs";import{Buffer as ggt}from"buffer";import{Readable as lR,Writable as _gt,Duplex as ygt}from"stream";var Kxe=(t,e)=>CM(Sgt,t,e,!1),dR=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${pd[t]}.`)},Wxe={fileNumber:dR,generator:q5,asyncGenerator:q5,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:ygt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Sgt={input:{...Wxe,fileUrl:({value:t})=>({stream:Gxe(t)}),filePath:({value:{file:t}})=>({stream:Gxe(t)}),webStream:({value:t})=>({stream:lR.fromWeb(t)}),iterable:({value:t})=>({stream:lR.from(t)}),asyncIterable:({value:t})=>({stream:lR.from(t)}),string:({value:t})=>({stream:lR.from(t)}),uint8Array:({value:t})=>({stream:lR.from(ggt.from(t))})},output:{...Wxe,fileUrl:({value:t})=>({stream:Hxe(t)}),filePath:({value:{file:t,append:e}})=>({stream:Hxe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:_gt.fromWeb(t)}),iterable:dR,asyncIterable:dR,string:dR,uint8Array:dR}};import{on as vgt,once as Yxe}from"events";import{PassThrough as Egt,getDefaultHighWaterMark as bgt}from"stream";import{finished as Jxe}from"stream/promises";function nh(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)Y5(i);let e=t.some(({readableObjectMode:i})=>i),r=wgt(t,e),n=new K5({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var wgt=(t,e)=>{if(t.length===0)return bgt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},K5=class extends Egt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(Y5(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Tgt(this,this.#e,this.#o);let r=xgt({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#o});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(Y5(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},Tgt=async(t,e,r)=>{UM(t,Zxe);let n=new AbortController;try{await Promise.race([Agt(t,n),Rgt(t,e,r,n)])}finally{n.abort(),UM(t,-Zxe)}},Agt=async(t,{signal:e})=>{try{await Jxe(t,{signal:e,cleanup:!0})}catch(r){throw Qxe(t,r),r}},Rgt=async(t,e,r,{signal:n})=>{for await(let[i]of vgt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},Y5=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},xgt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{UM(t,Xxe);let a=new AbortController;try{await Promise.race([Igt(o,e,a),Ogt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),Pgt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),UM(t,-Xxe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?Z5(t):Cgt(t))},Igt=async(t,e,{signal:r})=>{try{await t,r.aborted||Z5(e)}catch(n){r.aborted||Qxe(e,n)}},Ogt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await Jxe(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;eIe(s)?i.add(e):tIe(t,s)}},Pgt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await Yxe(t,i,{signal:o}),!t.readable)return Yxe(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},Cgt=t=>{t.writable&&t.end()},Qxe=(t,e)=>{eIe(e)?Z5(t):tIe(t,e)},eIe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Z5=t=>{(t.readable||t.writable)&&t.destroy()},tIe=(t,e)=>{t.destroyed||(t.once("error",kgt),t.destroy(e))},kgt=()=>{},UM=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Zxe=2,Xxe=1;import{finished as rIe}from"stream/promises";var Cy=(t,e)=>{t.pipe(e),Ngt(t,e),$gt(t,e)},Ngt=async(t,e)=>{if(!(ca(t)||ca(e))){try{await rIe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}X5(e)}},X5=t=>{t.writable&&t.end()},$gt=async(t,e)=>{if(!(ca(t)||ca(e))){try{await rIe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}J5(t)}},J5=t=>{t.readable&&t.destroy()};var nIe=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:o,direction:s}]of Object.entries(e)){for(let{stream:a}of o.filter(({type:c})=>Qo.has(c)))Dgt(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Qo.has(c)))Lgt({subprocess:t,stream:a,direction:s,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,o]of n.entries()){let s=o.length===1?o[0]:nh(o);Cy(s,i)}},Dgt=(t,e,r,n)=>{r==="output"?Cy(t.stdio[n],e):Cy(e,t.stdio[n]);let i=Mgt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},Mgt=["stdin","stdout","stderr"],Lgt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;Ugt(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},Ugt=(t,{signal:e})=>{ca(t)&&Qp(t,Fgt,e)},Fgt=2;import{addAbortListener as Bgt}from"events";var ih=[];ih.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&ih.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&ih.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var FM=t=>!!t&&typeof t=="object"&&typeof t.removeListener=="function"&&typeof t.emit=="function"&&typeof t.reallyExit=="function"&&typeof t.listeners=="function"&&typeof t.kill=="function"&&typeof t.pid=="number"&&typeof t.on=="function",Q5=Symbol.for("signal-exit emitter"),e8=globalThis,zgt=Object.defineProperty.bind(Object),t8=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(e8[Q5])return e8[Q5];zgt(e8,Q5,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let o of this.listeners[e])i=o(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},zM=class{},jgt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),r8=class extends zM{onExit(){return()=>{}}load(){}unload(){}},n8=class extends zM{#e=i8.platform==="win32"?"SIGINT":"SIGHUP";#r=new t8;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of ih)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,o=e;if(typeof o.__signal_exit_emitter__=="object"&&typeof o.__signal_exit_emitter__.count=="number"&&(i+=o.__signal_exit_emitter__.count),n.length===i){this.unload();let s=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;s||e.kill(e.pid,a)}};this.#o=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!FM(this.#t))return()=>{};this.#s===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#r.on(n,e),()=>{this.#r.removeListener(n,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#s){this.#s=!0,this.#r.count+=1;for(let e of ih)try{let r=this.#i[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#s&&(this.#s=!1,ih.forEach(e=>{let r=this.#i[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#o,this.#r.count-=1)}#a(e){return FM(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#o.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&FM(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let i=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),i}else return n.call(this.#t,e,...r)}},i8=globalThis.process,{onExit:iIe,load:Hfr,unload:Wfr}=jgt(FM(i8)?new n8(i8):new r8);var oIe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=iIe(()=>{t.kill()});Bgt(n,()=>{i()})};var aIe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=XD(),{destination:s,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=qgt(r,n,i),{sourceStream:d,sourceError:f}=Ggt(t,u),{options:p,fileDescriptors:h}=cc.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:o}},qgt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=Vgt(t,e,...r),a=aM(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},Vgt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(sIe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||W9(r)){if(Object.keys(t).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[i,o,s]=jD(r,...n);return{destination:e(sIe)(i,o,s),pipeOptions:s}}if(cc.has(r)){if(Object.keys(t).length>0)throw new TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:r,pipeOptions:n[0]}}throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${r}`)},sIe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),Ggt=(t,e)=>{try{return{sourceStream:Ty(t,e)}}catch(r){return{sourceError:r}}};var uIe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=Hgt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw o8({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},Hgt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return J5(t),n;if(e!==void 0)return X5(r),e},o8=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Iy({error:t,command:cIe,escapedCommand:cIe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),cIe="source.pipe(destination)";var lIe=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:o,value:s=o}]=await t;if(s.pipedFrom.includes(n)||s.pipedFrom.push(n),i==="rejected")throw s;if(e==="rejected")throw n;return s};import{finished as Wgt}from"stream/promises";var dIe=(t,e,r)=>{let n=jM.has(e)?Ygt(t,e):Kgt(t,e);return Qp(t,Xgt,r.signal),Qp(e,Jgt,r.signal),Zgt(e),n},Kgt=(t,e)=>{let r=nh([t]);return Cy(r,e),jM.set(e,r),r},Ygt=(t,e)=>{let r=jM.get(e);return r.add(t),r},Zgt=async t=>{try{await Wgt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}jM.delete(t)},jM=new WeakMap,Xgt=2,Jgt=1;import{aborted as Qgt}from"util";var fIe=(t,e)=>t===void 0?[]:[e_t(t,e)],e_t=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await Qgt(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw o8({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var BM=(t,...e)=>{if(Tr(e[0]))return BM.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=aIe(t,...e),i=t_t({...n,destination:r});return i.pipe=BM.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},t_t=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=r_t(t,i);uIe({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=dIe(e,o,d);return await Promise.race([lIe(l),...fIe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},r_t=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as u_t}from"timers/promises";import{on as n_t}from"events";import{getDefaultHighWaterMark as i_t}from"stream";var qM=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return o_t(e,s),hIe({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},o_t=async(t,e)=>{try{await t}catch{}finally{e.abort()}},s8=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;s_t(e,s,t);let a=t.readableObjectMode&&!o;return hIe({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},s_t=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},hIe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=n_t(t,"data",{signal:e.signal,highWaterMark:pIe,highWatermark:pIe});return a_t({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},a8=i_t(!0),pIe=a8,a_t=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=c_t({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*rh(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*cR(a)}},c_t=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[NM(t,r,!e),kM(t,i,!n,{})].filter(Boolean);var mIe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:u,streamInfo:l})=>{let d=l_t({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([d_t(t),d]);return}let f=U5(c,r),p=s8({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([f_t({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},l_t=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!MM({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=s8({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Rxe(a,t,r,o)},d_t=async t=>{await u_t(),t.readableFlowing===null&&t.resume()},f_t=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await wM(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await TM(r,{maxBuffer:o})):await xy(r,{maxBuffer:o})}catch(a){return gIe(RRe({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},c8=async t=>{try{return await t}catch(e){return gIe(e)}},gIe=({bufferedData:t})=>Bwe(t)?new Uint8Array(t):t;import{finished as p_t}from"stream/promises";var fR=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=h_t(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],p_t(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||__t(a,e,r,n)}finally{s.abort()}},h_t=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&m_t(t,r,n),n},m_t=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{g_t(e,r),n.call(t,...i)}},g_t=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},__t=(t,e,r,n)=>{if(!y_t(t,e,r,n))throw t},y_t=(t,e,r,n=!0)=>r.propagating?_Ie(t)||VM(t):(r.propagating=!0,u8(r,e)===n?_Ie(t):VM(t)),u8=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",VM=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",_Ie=t=>t?.code==="EPIPE";var yIe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,u)=>l8({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),l8=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:u})=>{if(!t)return;let l=fR(t,e,u);if(u8(u,e)){await l;return}let[d]=await Promise.all([mIe({stream:t,onStreamEnd:l,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:u}),l]);return d};var SIe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?nh([t,e].filter(Boolean)):void 0,vIe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>l8({...S_t(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:v_t(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),S_t=({stdout:t,stderr:e,all:r},[,n,i])=>{let o=n||i;return o?n?i?{stream:r,buffer:o}:{stream:t,buffer:o}:{stream:e,buffer:o}:{stream:r,buffer:o}},v_t=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as E_t}from"events";var EIe=t=>Sy(t,"ipc"),bIe=(t,e)=>{let r=ZD(t);sc({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var wIe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=EIe(o),a=bu(e,"ipc"),c=bu(r,"ipc");for await(let u of W5({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(xRe(t,i,c),i.push(u)),s&&bIe(u,o);return i},TIe=async(t,e)=>(await Promise.allSettled([t]),e);var AIe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:u,ipc:l,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:_,controller:y})=>{let v=Cxe(t,f),A={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},S=yIe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:A}),b=vIe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:A}),E=[],R=wIe({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:E,verboseInfo:p}),C=b_t(m,t,A),O=w_t(h,A);try{return await Promise.race([Promise.all([{},Nxe(v),Promise.all(S),b,R,oRe(t,d),...C,...O]),_,T_t(t,y),...eRe(t,o,f,y),...EAe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:y}),...JAe({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(k){return f.terminationReason??="other",Promise.all([{error:k},v,Promise.all(S.map(T=>c8(T))),c8(b),TIe(R,E),Promise.allSettled(C),Promise.allSettled(O)])}},b_t=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:fR(n,i,r)),w_t=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>da(o,{checkOpen:!1})&&!ca(o)).map(({type:i,value:o,stream:s=o})=>fR(s,n,e,{isSameDirection:Qo.has(i),stopOnExit:i==="native"}))),T_t=async(t,{signal:e})=>{let[r]=await E_t(t,"error",{signal:e});throw r};var RIe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),pR=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=ac();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},ky=async({resolve:t,promises:e},r)=>{t();let[n]=await Promise.race([Promise.allSettled([!0,r]),Promise.all([!1,...e])]);return!n};import{Readable as A_t}from"stream";import{callbackify as R_t}from"util";import{finished as xIe}from"stream/promises";var d8=async t=>{if(t!==void 0)try{await f8(t)}catch{}},IIe=async t=>{if(t!==void 0)try{await p8(t)}catch{}},f8=async t=>{await xIe(t,{cleanup:!0,readable:!1,writable:!0})},p8=async t=>{await xIe(t,{cleanup:!0,readable:!0,writable:!1})},GM=async(t,e)=>{if(await t,e)throw e},HM=(t,e,r)=>{r&&!VM(r)?t.destroy(r):e&&t.destroy()};var OIe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||go.has(r),{subprocessStdout:a,waitReadableDestroy:c}=h8(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=m8(a,s),{read:f,onStdoutDataDone:p}=g8({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new A_t({read:f,destroy:R_t(y8.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return _8({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},h8=(t,e,r)=>{let n=Ty(t,e),i=pR(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},m8=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:a8},g8=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=ac(),s=qM({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){x_t(this,s,o)},onStdoutDataDone:o}},x_t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},_8=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await p8(t),await n,await d8(i),await e,r.readable&&r.push(null)}catch(o){await d8(i),PIe(r,o)}},y8=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await ky(r,e)&&(PIe(t,n),await GM(e,n))},PIe=(t,e)=>{HM(t,t.readable,e)};import{Writable as I_t}from"stream";import{callbackify as CIe}from"util";var kIe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=S8(t,r,e),s=new I_t({...v8(n,t,i),destroy:CIe(b8.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return E8(n,s),s},S8=(t,e,r)=>{let n=aM(t,e),i=pR(r,n,"writableFinal"),o=pR(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},v8=(t,e,r)=>({write:O_t.bind(void 0,t),final:CIe(P_t.bind(void 0,t,e,r))}),O_t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},P_t=async(t,e,r)=>{await ky(r,e)&&(t.writable&&t.end(),await e)},E8=async(t,e,r)=>{try{await f8(t),e.writable&&e.end()}catch(n){await IIe(r),NIe(e,n)}},b8=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await ky(r,e),await ky(n,e)&&(NIe(t,i),await GM(e,i))},NIe=(t,e)=>{HM(t,t.writable,e)};import{Duplex as C_t}from"stream";import{callbackify as k_t}from"util";var $Ie=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||go.has(r),{subprocessStdout:c,waitReadableDestroy:u}=h8(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=S8(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=m8(c,a),{read:_,onStdoutDataDone:y}=g8({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),v=new C_t({read:_,...v8(l,t,d),destroy:k_t(N_t.bind(void 0,{subprocessStdout:c,subprocessStdin:l,subprocess:t,waitReadableDestroy:u,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:l.writableHighWaterMark,readableObjectMode:h,writableObjectMode:l.writableObjectMode,encoding:p});return _8({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:l}),E8(l,v,c),v},N_t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([y8({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),b8({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var w8=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||go.has(e),s=Ty(t,r),a=qM({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return $_t(a,s,t)},$_t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var DIe=(t,{encoding:e})=>{let r=RIe();t.readable=OIe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=kIe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=$Ie.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=w8.bind(void 0,t,e),t[Symbol.asyncIterator]=w8.bind(void 0,t,e,{})};var MIe=(t,e)=>{for(let[r,n]of M_t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},D_t=(async()=>{})().constructor.prototype,M_t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(D_t,t)]);var LIe=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=F_t(t,e,r),{subprocess:f,promise:p}=j_t({file:i,commandArguments:o,options:l,startTime:c,verboseInfo:u,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=BM.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),MIe(f,p),cc.set(f,{options:l,fileDescriptors:d}),f},F_t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=JD(t,e,r),{file:a,commandArguments:c,options:u}=yM(t,e,r),l=z_t(u),d=Kxe(l,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},z_t=({timeout:t,signal:e,...r})=>{if(e!==void 0)throw new TypeError('The "signal" option has been renamed to "cancelSignal" instead.');return{...r,timeoutDuration:t}},j_t=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=U_t(...SM(t,e,r))}catch(h){return Vxe({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;L_t(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];nIe(c,a,u),oIe(c,r,u);let d={},f=ac();c.kill=SAe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=SIe(c,r),DIe(c,r),jxe(c,r);let p=B_t({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:l,command:o,escapedCommand:s,context:d,onInternalError:f,controller:u});return{subprocess:c,promise:p}},B_t=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:u,controller:l})=>{let[d,[f,p],h,m,_]=await AIe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:u,controller:l});l.abort(),u.resolve();let y=h.map((S,b)=>Tu(S,e,b)),v=Tu(m,e,"all"),A=q_t({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Oy(A,n,e)},q_t=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:u,startTime:l})=>"error"in t?aR({error:t.error,command:c,escapedCommand:u,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof uc,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:l,isSync:!1}):xM({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:o,options:a,startTime:l});var WM=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,V_t(n,t[n],i)]));return{...t,...r}},V_t=(t,e,r)=>G_t.has(t)&&Tr(e)&&Tr(r)?{...e,...r}:r,G_t=new Set(["env",...Q9]);var hd=(t,e,r,n)=>{let i=(s,a,c)=>hd(s,a,r,c),o=(...s)=>H_t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},H_t=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Tr(o))return i(t,WM(r,o),n);let{file:a,commandArguments:c,options:u,isSync:l}=W_t({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return l?Dxe(a,c,u):LIe(a,c,u,i)},W_t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=Kwe(e)?Ywe(e,r):[e,...r],[s,a,c]=jD(...o),u=WM(WM(n,i),c),{file:l=s,commandArguments:d=a,options:f=u,isSync:p=!1}=t({file:s,commandArguments:a,options:u});return{file:l,commandArguments:d,options:f,isSync:p}};var UIe=({file:t,commandArguments:e})=>zIe(t,e),FIe=({file:t,commandArguments:e})=>({...zIe(t,e),isSync:!0}),zIe=(t,e)=>{if(e.length>0)throw new TypeError(`The command and its arguments must be passed as a single string: ${t} ${e}.`);let[r,...n]=K_t(t);return{file:r,commandArguments:n}},K_t=t=>{if(typeof t!="string")throw new TypeError(`The command must be a string: ${String(t)}.`);let e=t.trim();if(e==="")return[];let r=[];for(let n of e.split(Y_t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},Y_t=/ +/g;var jIe=(t,e,r)=>{t.sync=e(Z_t,r),t.s=t.sync},BIe=({options:t})=>qIe(t),Z_t=({options:t})=>({...qIe(t),isSync:!0}),qIe=t=>({options:{...X_t(t),...t}}),X_t=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},VIe={preferLocal:!0};var GIe=hd(()=>({})),Mmr=hd(()=>({isSync:!0})),HIe=hd(UIe),Lmr=hd(FIe),Umr=hd(rRe),Fmr=hd(BIe,{},VIe,jIe),{sendMessage:zmr,getOneMessage:jmr,getEachMessage:Bmr,getCancelSignal:qmr}=Bxe();var WIe=!1,KIe,J_t=t=>{KIe??=t},YIe=t=>{WIe=!0,J_t(t)},Gn=()=>WIe,Au=()=>KIe,ZIe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var hR=null,XIe=t=>(hR&&hR.destroy(),hR=new es({totalAllowedTime:t}),hR),JIe=()=>hR;var es=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&Gn())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((l,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),u="success";try{return await ok({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(l){throw u="failure",l}finally{K.timing("stage.duration",Date.now()-c,{stage:e,outcome:u}),o(),s&&clearTimeout(s)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var QIe={name:"@netlify/agent-runner-cli",type:"module",version:"2.12.0-nb8c571bb6e224.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md" "!src/lib/__fixtures__/**"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md" "!src/lib/__fixtures__/**"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:opencode":"vitest run test/integration/opencode.test.ts","test:integration:muse":"vitest run test/integration/muse.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},engines:{node:">=22"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@grpc/grpc-js":"1.14.6","@netlify/axis":"^1.21.0","@netlify/eslint-config-node":"^7.0.1","@netlify/skills":"1.7.0","@opentelemetry/sdk-trace-base":"2.9.0","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.295","@anthropic-ai/sdk":"^0.134.0","@google/gemini-cli":"0.63.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.2","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.162.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0","@opentelemetry/otlp-transformer":"0.218.0",execa:"^9.6.1",fastify:"5.12.6",minimist:"^1.2.8",openai:"7.31.0",zod:"^4.4.3"}};var ryt=eyt(import.meta.url),nyt=Ru.dirname(ryt),iyt=tyt(import.meta.url),Ny=oe("shell"),T8=new Set,eOe={preferLocal:!0},vt=(t,e,r)=>{let[n,i]=oyt(e,r),o={...eOe,...i},s=GIe(t,n,o);rOe(s,o),oOe(s);let a=r?.idleTimeout;return a&&a>0&&iOe(s,a),s},tOe=(t,e)=>{let r={...eOe,...e},n=HIe(t,r);return rOe(n,r),oOe(n),e?.idleTimeout&&e.idleTimeout>0&&iOe(n,e.idleTimeout),n},oyt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},rOe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||dc.env.NETLIFY_LOCAL_QUIET==="true")return;if(dc.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Lw).pipe(dc.stdout),t.stderr?.pipe(new Lw).pipe(dc.stderr);return}t.stdout?.pipe(dc.stdout),t.stderr?.pipe(dc.stderr)},A8=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(dc.kill(-t.pid,e),Ny.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Ny.error("Error killing process:",r),!1}},nOe=t=>A8(t,"SIGKILL"),iOe=(t,e)=>{let r=null,n=()=>{Ny.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),A8(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Ny.log(`Force killing idle process ${t.pid}`),nOe(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let o=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",o),t.on("error",o)},oOe=t=>{T8.add(t);let e=JIe();if(e){let r=e.onTimesUp(()=>{Ny.log(`Global timer expired, killing process ${t.pid}`),A8(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Ny.log(`Force killing process ${t.pid} after timeout`),nOe(t))},5e3)});t.on("exit",()=>{T8.delete(t),r()}),t.on("error",()=>{T8.delete(t),r()})}};function YM(t,e){return!!fa(t,e)}function fa(t,e){if(!dc.env.NETLIFY_LOCAL_MODE)try{let i=iyt.resolve(QIe.name),o=Ru.dirname(i);for(;o!==Ru.dirname(o);){let s=Ru.dirname(o);if(Ru.basename(s)==="node_modules"){let a=Ru.join(s,".bin",e);if(KM.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(dc.env.NODE_PATH){let i=Ru.join(dc.env.NODE_PATH,".bin",e);if(KM.existsSync(i))return i}let r=Ru.join(t,"node_modules",".bin",e);if(KM.existsSync(r))return r;let n=Ru.join(nyt,"..","node_modules",".bin",e);if(KM.existsSync(n))return n}var $y=oe("repo"),fOe="runner-diffs-",R8=t=>`${fOe}${t}-`,pOe=async t=>{let e=XM.tmpdir(),r;try{r=await mi.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(fOe)&&!n.startsWith(R8(t))).map(n=>mi.rm(ts.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},sOe=async t=>{let e=syt("sha256");for await(let r of ayt(t))e.update(r);return e.digest("hex")},aOe=async(t,e)=>t.size===e.size&&await sOe(t.path)===await sOe(e.path),hOe=/.. (.+)?\.log$/,cyt=[hOe],uyt=1,cOe=t=>{let e=t.split(`
387
+ if (condition) { yield value; }`)};import{Buffer as gmt}from"buffer";import{StringDecoder as _mt}from"string_decoder";var NM=(t,e,r)=>{if(r)return;if(t)return{transform:ymt.bind(void 0,new TextEncoder)};let n=new _mt(e);return{transform:Smt.bind(void 0,n),final:vmt.bind(void 0,n)}},ymt=function*(t,e){gmt.isBuffer(e)?yield Eu(e):typeof e=="string"?yield t.encode(e):yield e},Smt=function*(t,e){yield Kr(e)?t.write(e):e},vmt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as Sxe}from"util";var j5=Sxe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),$M=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=bmt}=e[r];for await(let i of n(t))yield*$M(i,e,r+1)},vxe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Emt(r,Number(e),t)},Emt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*$M(n,r,e+1)},Exe=Sxe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),bmt=function*(t){yield t};var B5=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},bxe=(t,e)=>[...e.flatMap(r=>[...rh(r,t,0)]),...cR(t)],rh=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Tmt}=e[r];for(let i of n(t))yield*rh(i,e,r+1)},cR=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*wmt(r,Number(e),t)},wmt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*rh(n,r,e+1)},Tmt=function*(t){yield t};var q5=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=Txe(t,s,o),u=th(e),l=th(r),d=u?j5.bind(void 0,$M,a):B5.bind(void 0,rh),f=u||l?j5.bind(void 0,vxe,a):B5.bind(void 0,cR),p=u||l?Exe.bind(void 0,a):void 0;return{stream:new Amt({writableObjectMode:n,writableHighWaterMark:wxe(n),readableObjectMode:i,readableHighWaterMark:wxe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},DM=(t,e,r,n)=>{let i=e.filter(({type:s})=>s==="generator"),o=n?i.reverse():i;for(let{value:s,optionName:a}of o){let c=Txe(s,r,a);t=bxe(c,t)}return t},Txe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:gxe(n,a)},NM(r,s,n),kM(r,o,n,c),{transform:t,final:e},{transform:_xe(i,a)},mxe({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var Axe=(t,e)=>{for(let r of Rmt(t))xmt(t,r,e)},Rmt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),xmt=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:c}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${c}\`, can be ${pd[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>Imt(a,n));r.input=JA(s)},Imt=(t,e)=>{let r=DM(t,e,"utf8",!0);return Omt(r),JA(r)},Omt=t=>{let e=t.find(r=>typeof r!="string"&&!Kr(r));if(e!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${e}.`)};import{writeFileSync as Nmt,appendFileSync as $mt}from"fs";var MM=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&Sy(r,n)&&!go.has(e)&&Pmt(n)&&(t.some(({type:i,value:o})=>i==="native"&&Cmt.has(o))||t.every(({type:i})=>Qo.has(i))),Pmt=t=>t===1||t===2,Cmt=new Set(["pipe","overlapped"]),Rxe=async(t,e,r,n)=>{for await(let i of t)kmt(e)||Ixe(i,r,n)},xxe=(t,e,r)=>{for(let n of t)Ixe(n,e,r)},kmt=t=>t._readableState.pipes.length>0,Ixe=(t,e,r)=>{let n=ZD(t);sc({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var Oxe=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let o={},s=new Set([]);return{output:e.map((c,u)=>Dmt({result:c,fileDescriptors:t,fdNumber:u,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},Dmt=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:o,verboseInfo:s},{buffer:a,encoding:c,lines:u,stripFinalNewline:l,maxBuffer:d})=>{if(t===null)return;let f=PRe(t,o,d),p=Eu(f),{stdioItems:h,objectMode:m}=e[r],_=Mmt([p],h,c,n),{serializedResult:y,finalResult:v=y}=Lmt({chunks:_,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});Umt({serializedResult:y,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let A=a[r]?v:void 0;try{return n.error===void 0&&Fmt(y,h,i),A}catch(S){return n.error=S,A}},Mmt=(t,e,r,n)=>{try{return DM(t,e,r,!1)}catch(i){return n.error=i,t}},Lmt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:JA(t)};let s=Vwe(t,r);return n[o]?{serializedResult:s,finalResult:z5(s,!i[o],e)}:{serializedResult:s}},Umt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!MM({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=z5(t,!1,s);try{xxe(a,e,n)}catch(c){r.error??=c}},Fmt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>PM.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?$mt(n,t):(r.add(o),Nmt(n,t))}};var Pxe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Tu(e,r,"all")]:Array.isArray(e)?[Tu(t,r,"all"),...e]:Kr(t)&&Kr(e)?Y9([t,e]):`${t}${e}`};import{once as V5}from"events";var Cxe=async(t,e)=>{let[r,n]=await zmt(t);return e.isForcefullyTerminated??=!1,[r,n]},zmt=async t=>{let[e,r]=await Promise.allSettled([V5(t,"spawn"),V5(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?kxe(t):r.value},kxe=async t=>{try{return await V5(t,"exit")}catch{return kxe(t)}},Nxe=async t=>{let[e,r]=await t;if(!jmt(e,r)&&G5(e,r))throw new ua;return[e,r]},jmt=(t,e)=>t===void 0&&e===void 0,G5=(t,e)=>t!==0||e!==null;var $xe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=Bmt(t,e,r),s=o?.code==="ETIMEDOUT",a=ORe(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},Bmt=(t,e,r)=>t!==void 0?t:G5(e,r)?new ua:void 0;var Dxe=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=Vmt(t,e,r),d=Wmt({file:n,commandArguments:i,options:u,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:l,startTime:a});return Oy(d,c,u)},Vmt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=JD(t,e,r),a=Gmt(r),{file:c,commandArguments:u,options:l}=yM(t,e,a);Hmt(l);let d=dxe(l,s);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},Gmt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Hmt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&LM("ipcInput"),t&&LM("ipc: true"),r&&LM("detached: true"),n&&LM("cancelSignal")},LM=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Wmt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=Kmt({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:a});if(c.failed)return c;let{resultError:u,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p}=$xe(c,r),{output:h,error:m=u}=Oxe({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),_=h.map((v,A)=>Tu(v,r,A)),y=Tu(Pxe(h,r),r,"all");return Zmt({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},Kmt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{Axe(o,r);let a=Ymt(r);return qmt(...SM(t,e,a))}catch(a){return Iy({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},Ymt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:RM(e)}),Zmt=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:o,all:s,options:a,command:c,escapedCommand:u,startTime:l})=>t===void 0?xM({command:c,escapedCommand:u,stdio:o,all:s,ipcOutput:[],options:a,startTime:l}):aR({error:t,command:c,escapedCommand:u,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:l,isSync:!0});import{setMaxListeners as L_t}from"events";import{spawn as U_t}from"child_process";import zxe from"process";import{once as H5,on as Xmt}from"events";var Mxe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(by({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:fM(t)}),Jmt({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),Jmt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{cM(e,i);let o=fd(t,e,r),s=new AbortController;try{return await Promise.race([Qmt(o,n,s),egt(o,r,s),tgt(o,r,s)])}catch(a){throw wy(t),a}finally{s.abort(),uM(e,i)}},Qmt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await H5(t,"message",{signal:r});return n}for await(let[n]of Xmt(t,"message",{signal:r}))if(e(n))return n},egt=async(t,e,{signal:r})=>{await H5(t,"disconnect",{signal:r}),bAe(e)},tgt=async(t,e,{signal:r})=>{let[n]=await H5(t,"strict:error",{signal:r});throw oM(n,e)};import{once as Uxe,on as rgt}from"events";var Fxe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>W5({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),W5=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{by({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:fM(t)}),cM(e,o);let s=fd(t,e,r),a=new AbortController,c={};return ngt(t,s,a),igt({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),ogt({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},ngt=async(t,e,r)=>{try{await Uxe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},igt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await Uxe(t,"strict:error",{signal:r.signal});n.error=oM(i,e),r.abort()}catch{}},ogt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of rgt(r,"message",{signal:o.signal}))Lxe(s),yield c}catch{Lxe(s)}finally{o.abort(),uM(e,a),n||wy(t),i&&await t}},Lxe=({error:t})=>{if(t)throw t};var jxe=(t,{ipc:e})=>{Object.assign(t,qxe(t,!1,e))},Bxe=()=>{let t=zxe,e=!0,r=zxe.channel!==void 0;return{...qxe(t,e,r),getCancelSignal:YAe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},qxe=(t,e,r)=>({sendMessage:gM.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Mxe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:Fxe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as sgt}from"child_process";import{PassThrough as agt,Readable as cgt,Writable as ugt,Duplex as lgt}from"stream";var Vxe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{L5(n);let a=new sgt;dgt(a,n),Object.assign(a,{readable:fgt,writable:pgt,duplex:hgt});let c=Iy({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),u=mgt(c,s,i);return{subprocess:a,promise:u}},dgt=(t,e)=>{let r=uR(),n=uR(),i=uR(),o=Array.from({length:e.length-3},uR),s=uR(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},uR=()=>{let t=new agt;return t.end(),t},fgt=()=>new cgt({read(){}}),pgt=()=>new ugt({write(){}}),hgt=()=>new lgt({read(){},write(){}}),mgt=async(t,e,r)=>Oy(t,e,r);import{createReadStream as Gxe,createWriteStream as Hxe}from"fs";import{Buffer as ggt}from"buffer";import{Readable as lR,Writable as _gt,Duplex as ygt}from"stream";var Kxe=(t,e)=>CM(Sgt,t,e,!1),dR=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${pd[t]}.`)},Wxe={fileNumber:dR,generator:q5,asyncGenerator:q5,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:ygt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Sgt={input:{...Wxe,fileUrl:({value:t})=>({stream:Gxe(t)}),filePath:({value:{file:t}})=>({stream:Gxe(t)}),webStream:({value:t})=>({stream:lR.fromWeb(t)}),iterable:({value:t})=>({stream:lR.from(t)}),asyncIterable:({value:t})=>({stream:lR.from(t)}),string:({value:t})=>({stream:lR.from(t)}),uint8Array:({value:t})=>({stream:lR.from(ggt.from(t))})},output:{...Wxe,fileUrl:({value:t})=>({stream:Hxe(t)}),filePath:({value:{file:t,append:e}})=>({stream:Hxe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:_gt.fromWeb(t)}),iterable:dR,asyncIterable:dR,string:dR,uint8Array:dR}};import{on as vgt,once as Yxe}from"events";import{PassThrough as Egt,getDefaultHighWaterMark as bgt}from"stream";import{finished as Jxe}from"stream/promises";function nh(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)Y5(i);let e=t.some(({readableObjectMode:i})=>i),r=wgt(t,e),n=new K5({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var wgt=(t,e)=>{if(t.length===0)return bgt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},K5=class extends Egt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(Y5(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Tgt(this,this.#e,this.#o);let r=xgt({passThroughStream:this,stream:e,streams:this.#e,ended:this.#r,aborted:this.#t,onFinished:this.#n,unpipeEvent:this.#o});this.#i.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(Y5(e),!this.#e.has(e))return!1;let r=this.#i.get(e);return r===void 0?!1:(this.#i.delete(e),e.unpipe(this),await r,!0)}},Tgt=async(t,e,r)=>{UM(t,Zxe);let n=new AbortController;try{await Promise.race([Agt(t,n),Rgt(t,e,r,n)])}finally{n.abort(),UM(t,-Zxe)}},Agt=async(t,{signal:e})=>{try{await Jxe(t,{signal:e,cleanup:!0})}catch(r){throw Qxe(t,r),r}},Rgt=async(t,e,r,{signal:n})=>{for await(let[i]of vgt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},Y5=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},xgt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{UM(t,Xxe);let a=new AbortController;try{await Promise.race([Igt(o,e,a),Ogt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),Pgt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),UM(t,-Xxe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?Z5(t):Cgt(t))},Igt=async(t,e,{signal:r})=>{try{await t,r.aborted||Z5(e)}catch(n){r.aborted||Qxe(e,n)}},Ogt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await Jxe(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;eIe(s)?i.add(e):tIe(t,s)}},Pgt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await Yxe(t,i,{signal:o}),!t.readable)return Yxe(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},Cgt=t=>{t.writable&&t.end()},Qxe=(t,e)=>{eIe(e)?Z5(t):tIe(t,e)},eIe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Z5=t=>{(t.readable||t.writable)&&t.destroy()},tIe=(t,e)=>{t.destroyed||(t.once("error",kgt),t.destroy(e))},kgt=()=>{},UM=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Zxe=2,Xxe=1;import{finished as rIe}from"stream/promises";var Cy=(t,e)=>{t.pipe(e),Ngt(t,e),$gt(t,e)},Ngt=async(t,e)=>{if(!(ca(t)||ca(e))){try{await rIe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}X5(e)}},X5=t=>{t.writable&&t.end()},$gt=async(t,e)=>{if(!(ca(t)||ca(e))){try{await rIe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}J5(t)}},J5=t=>{t.readable&&t.destroy()};var nIe=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:o,direction:s}]of Object.entries(e)){for(let{stream:a}of o.filter(({type:c})=>Qo.has(c)))Dgt(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Qo.has(c)))Lgt({subprocess:t,stream:a,direction:s,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,o]of n.entries()){let s=o.length===1?o[0]:nh(o);Cy(s,i)}},Dgt=(t,e,r,n)=>{r==="output"?Cy(t.stdio[n],e):Cy(e,t.stdio[n]);let i=Mgt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},Mgt=["stdin","stdout","stderr"],Lgt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;Ugt(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},Ugt=(t,{signal:e})=>{ca(t)&&Qp(t,Fgt,e)},Fgt=2;import{addAbortListener as Bgt}from"events";var ih=[];ih.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&ih.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&ih.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var FM=t=>!!t&&typeof t=="object"&&typeof t.removeListener=="function"&&typeof t.emit=="function"&&typeof t.reallyExit=="function"&&typeof t.listeners=="function"&&typeof t.kill=="function"&&typeof t.pid=="number"&&typeof t.on=="function",Q5=Symbol.for("signal-exit emitter"),e8=globalThis,zgt=Object.defineProperty.bind(Object),t8=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(e8[Q5])return e8[Q5];zgt(e8,Q5,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let o of this.listeners[e])i=o(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},zM=class{},jgt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),r8=class extends zM{onExit(){return()=>{}}load(){}unload(){}},n8=class extends zM{#e=i8.platform==="win32"?"SIGINT":"SIGHUP";#r=new t8;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of ih)this.#i[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#r,o=e;if(typeof o.__signal_exit_emitter__=="object"&&typeof o.__signal_exit_emitter__.count=="number"&&(i+=o.__signal_exit_emitter__.count),n.length===i){this.unload();let s=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#e:r;s||e.kill(e.pid,a)}};this.#o=e.reallyExit,this.#n=e.emit}onExit(e,r){if(!FM(this.#t))return()=>{};this.#s===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#r.on(n,e),()=>{this.#r.removeListener(n,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#s){this.#s=!0,this.#r.count+=1;for(let e of ih)try{let r=this.#i[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#c(e,...r),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#s&&(this.#s=!1,ih.forEach(e=>{let r=this.#i[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#n,this.#t.reallyExit=this.#o,this.#r.count-=1)}#a(e){return FM(this.#t)?(this.#t.exitCode=e||0,this.#r.emit("exit",this.#t.exitCode,null),this.#o.call(this.#t,this.#t.exitCode)):0}#c(e,...r){let n=this.#n;if(e==="exit"&&FM(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let i=n.call(this.#t,e,...r);return this.#r.emit("exit",this.#t.exitCode,null),i}else return n.call(this.#t,e,...r)}},i8=globalThis.process,{onExit:iIe,load:Hfr,unload:Wfr}=jgt(FM(i8)?new n8(i8):new r8);var oIe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=iIe(()=>{t.kill()});Bgt(n,()=>{i()})};var aIe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=XD(),{destination:s,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=qgt(r,n,i),{sourceStream:d,sourceError:f}=Ggt(t,u),{options:p,fileDescriptors:h}=cc.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:o}},qgt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=Vgt(t,e,...r),a=aM(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},Vgt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(sIe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||W9(r)){if(Object.keys(t).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[i,o,s]=jD(r,...n);return{destination:e(sIe)(i,o,s),pipeOptions:s}}if(cc.has(r)){if(Object.keys(t).length>0)throw new TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:r,pipeOptions:n[0]}}throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${r}`)},sIe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),Ggt=(t,e)=>{try{return{sourceStream:Ty(t,e)}}catch(r){return{sourceError:r}}};var uIe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=Hgt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw o8({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},Hgt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return J5(t),n;if(e!==void 0)return X5(r),e},o8=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Iy({error:t,command:cIe,escapedCommand:cIe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),cIe="source.pipe(destination)";var lIe=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:o,value:s=o}]=await t;if(s.pipedFrom.includes(n)||s.pipedFrom.push(n),i==="rejected")throw s;if(e==="rejected")throw n;return s};import{finished as Wgt}from"stream/promises";var dIe=(t,e,r)=>{let n=jM.has(e)?Ygt(t,e):Kgt(t,e);return Qp(t,Xgt,r.signal),Qp(e,Jgt,r.signal),Zgt(e),n},Kgt=(t,e)=>{let r=nh([t]);return Cy(r,e),jM.set(e,r),r},Ygt=(t,e)=>{let r=jM.get(e);return r.add(t),r},Zgt=async t=>{try{await Wgt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}jM.delete(t)},jM=new WeakMap,Xgt=2,Jgt=1;import{aborted as Qgt}from"util";var fIe=(t,e)=>t===void 0?[]:[e_t(t,e)],e_t=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await Qgt(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw o8({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var BM=(t,...e)=>{if(Tr(e[0]))return BM.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=aIe(t,...e),i=t_t({...n,destination:r});return i.pipe=BM.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},t_t=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=r_t(t,i);uIe({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=dIe(e,o,d);return await Promise.race([lIe(l),...fIe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},r_t=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as u_t}from"timers/promises";import{on as n_t}from"events";import{getDefaultHighWaterMark as i_t}from"stream";var qM=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return o_t(e,s),hIe({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},o_t=async(t,e)=>{try{await t}catch{}finally{e.abort()}},s8=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;s_t(e,s,t);let a=t.readableObjectMode&&!o;return hIe({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},s_t=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},hIe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=n_t(t,"data",{signal:e.signal,highWaterMark:pIe,highWatermark:pIe});return a_t({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},a8=i_t(!0),pIe=a8,a_t=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=c_t({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*rh(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*cR(a)}},c_t=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[NM(t,r,!e),kM(t,i,!n,{})].filter(Boolean);var mIe=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:o,lines:s,allMixed:a,stripFinalNewline:c,verboseInfo:u,streamInfo:l})=>{let d=l_t({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([d_t(t),d]);return}let f=U5(c,r),p=s8({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([f_t({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},l_t=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!MM({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=s8({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await Rxe(a,t,r,o)},d_t=async t=>{await u_t(),t.readableFlowing===null&&t.resume()},f_t=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await wM(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await TM(r,{maxBuffer:o})):await xy(r,{maxBuffer:o})}catch(a){return gIe(RRe({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},c8=async t=>{try{return await t}catch(e){return gIe(e)}},gIe=({bufferedData:t})=>Bwe(t)?new Uint8Array(t):t;import{finished as p_t}from"stream/promises";var fR=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=h_t(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],p_t(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||__t(a,e,r,n)}finally{s.abort()}},h_t=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&m_t(t,r,n),n},m_t=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{g_t(e,r),n.call(t,...i)}},g_t=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},__t=(t,e,r,n)=>{if(!y_t(t,e,r,n))throw t},y_t=(t,e,r,n=!0)=>r.propagating?_Ie(t)||VM(t):(r.propagating=!0,u8(r,e)===n?_Ie(t):VM(t)),u8=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",VM=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",_Ie=t=>t?.code==="EPIPE";var yIe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,u)=>l8({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),l8=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:u})=>{if(!t)return;let l=fR(t,e,u);if(u8(u,e)){await l;return}let[d]=await Promise.all([mIe({stream:t,onStreamEnd:l,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:o,allMixed:s,stripFinalNewline:a,verboseInfo:c,streamInfo:u}),l]);return d};var SIe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?nh([t,e].filter(Boolean)):void 0,vIe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>l8({...S_t(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:v_t(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),S_t=({stdout:t,stderr:e,all:r},[,n,i])=>{let o=n||i;return o?n?i?{stream:r,buffer:o}:{stream:t,buffer:o}:{stream:e,buffer:o}:{stream:r,buffer:o}},v_t=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as E_t}from"events";var EIe=t=>Sy(t,"ipc"),bIe=(t,e)=>{let r=ZD(t);sc({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var wIe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=EIe(o),a=bu(e,"ipc"),c=bu(r,"ipc");for await(let u of W5({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(xRe(t,i,c),i.push(u)),s&&bIe(u,o);return i},TIe=async(t,e)=>(await Promise.allSettled([t]),e);var AIe=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:o,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,stripFinalNewline:u,ipc:l,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:h,originalStreams:m,onInternalError:_,controller:y})=>{let v=Cxe(t,f),A={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},S=yIe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:A}),b=vIe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:A}),E=[],R=wIe({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:E,verboseInfo:p}),C=b_t(m,t,A),O=w_t(h,A);try{return await Promise.race([Promise.all([{},Nxe(v),Promise.all(S),b,R,oRe(t,d),...C,...O]),_,T_t(t,y),...eRe(t,o,f,y),...EAe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:y}),...JAe({subprocess:t,cancelSignal:s,gracefulCancel:a,forceKillAfterDelay:c,context:f,controller:y})])}catch(k){return f.terminationReason??="other",Promise.all([{error:k},v,Promise.all(S.map(T=>c8(T))),c8(b),TIe(R,E),Promise.allSettled(C),Promise.allSettled(O)])}},b_t=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:fR(n,i,r)),w_t=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>da(o,{checkOpen:!1})&&!ca(o)).map(({type:i,value:o,stream:s=o})=>fR(s,n,e,{isSameDirection:Qo.has(i),stopOnExit:i==="native"}))),T_t=async(t,{signal:e})=>{let[r]=await E_t(t,"error",{signal:e});throw r};var RIe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),pR=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=ac();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},ky=async({resolve:t,promises:e},r)=>{t();let[n]=await Promise.race([Promise.allSettled([!0,r]),Promise.all([!1,...e])]);return!n};import{Readable as A_t}from"stream";import{callbackify as R_t}from"util";import{finished as xIe}from"stream/promises";var d8=async t=>{if(t!==void 0)try{await f8(t)}catch{}},IIe=async t=>{if(t!==void 0)try{await p8(t)}catch{}},f8=async t=>{await xIe(t,{cleanup:!0,readable:!1,writable:!0})},p8=async t=>{await xIe(t,{cleanup:!0,readable:!0,writable:!1})},GM=async(t,e)=>{if(await t,e)throw e},HM=(t,e,r)=>{r&&!VM(r)?t.destroy(r):e&&t.destroy()};var OIe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||go.has(r),{subprocessStdout:a,waitReadableDestroy:c}=h8(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=m8(a,s),{read:f,onStdoutDataDone:p}=g8({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new A_t({read:f,destroy:R_t(y8.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return _8({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},h8=(t,e,r)=>{let n=Ty(t,e),i=pR(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},m8=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:a8},g8=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=ac(),s=qM({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){x_t(this,s,o)},onStdoutDataDone:o}},x_t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},_8=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await p8(t),await n,await d8(i),await e,r.readable&&r.push(null)}catch(o){await d8(i),PIe(r,o)}},y8=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await ky(r,e)&&(PIe(t,n),await GM(e,n))},PIe=(t,e)=>{HM(t,t.readable,e)};import{Writable as I_t}from"stream";import{callbackify as CIe}from"util";var kIe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=S8(t,r,e),s=new I_t({...v8(n,t,i),destroy:CIe(b8.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return E8(n,s),s},S8=(t,e,r)=>{let n=aM(t,e),i=pR(r,n,"writableFinal"),o=pR(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},v8=(t,e,r)=>({write:O_t.bind(void 0,t),final:CIe(P_t.bind(void 0,t,e,r))}),O_t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},P_t=async(t,e,r)=>{await ky(r,e)&&(t.writable&&t.end(),await e)},E8=async(t,e,r)=>{try{await f8(t),e.writable&&e.end()}catch(n){await IIe(r),NIe(e,n)}},b8=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await ky(r,e),await ky(n,e)&&(NIe(t,i),await GM(e,i))},NIe=(t,e)=>{HM(t,t.writable,e)};import{Duplex as C_t}from"stream";import{callbackify as k_t}from"util";var $Ie=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||go.has(r),{subprocessStdout:c,waitReadableDestroy:u}=h8(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=S8(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=m8(c,a),{read:_,onStdoutDataDone:y}=g8({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),v=new C_t({read:_,...v8(l,t,d),destroy:k_t(N_t.bind(void 0,{subprocessStdout:c,subprocessStdin:l,subprocess:t,waitReadableDestroy:u,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:m,writableHighWaterMark:l.writableHighWaterMark,readableObjectMode:h,writableObjectMode:l.writableObjectMode,encoding:p});return _8({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:l}),E8(l,v,c),v},N_t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([y8({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),b8({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var w8=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||go.has(e),s=Ty(t,r),a=qM({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return $_t(a,s,t)},$_t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var DIe=(t,{encoding:e})=>{let r=RIe();t.readable=OIe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=kIe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=$Ie.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=w8.bind(void 0,t,e),t[Symbol.asyncIterator]=w8.bind(void 0,t,e,{})};var MIe=(t,e)=>{for(let[r,n]of M_t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},D_t=(async()=>{})().constructor.prototype,M_t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(D_t,t)]);var LIe=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=F_t(t,e,r),{subprocess:f,promise:p}=j_t({file:i,commandArguments:o,options:l,startTime:c,verboseInfo:u,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=BM.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),MIe(f,p),cc.set(f,{options:l,fileDescriptors:d}),f},F_t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=JD(t,e,r),{file:a,commandArguments:c,options:u}=yM(t,e,r),l=z_t(u),d=Kxe(l,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},z_t=({timeout:t,signal:e,...r})=>{if(e!==void 0)throw new TypeError('The "signal" option has been renamed to "cancelSignal" instead.');return{...r,timeoutDuration:t}},j_t=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=U_t(...SM(t,e,r))}catch(h){return Vxe({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;L_t(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];nIe(c,a,u),oIe(c,r,u);let d={},f=ac();c.kill=SAe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=SIe(c,r),DIe(c,r),jxe(c,r);let p=B_t({subprocess:c,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:l,command:o,escapedCommand:s,context:d,onInternalError:f,controller:u});return{subprocess:c,promise:p}},B_t=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:o,command:s,escapedCommand:a,context:c,onInternalError:u,controller:l})=>{let[d,[f,p],h,m,_]=await AIe({subprocess:t,options:e,context:c,verboseInfo:n,fileDescriptors:i,originalStreams:o,onInternalError:u,controller:l});l.abort(),u.resolve();let y=h.map((S,b)=>Tu(S,e,b)),v=Tu(m,e,"all"),A=q_t({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Oy(A,n,e)},q_t=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,context:s,options:a,command:c,escapedCommand:u,startTime:l})=>"error"in t?aR({error:t.error,command:c,escapedCommand:u,timedOut:s.terminationReason==="timeout",isCanceled:s.terminationReason==="cancel"||s.terminationReason==="gracefulCancel",isGracefullyCanceled:s.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof uc,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:l,isSync:!1}):xM({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:o,options:a,startTime:l});var WM=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,V_t(n,t[n],i)]));return{...t,...r}},V_t=(t,e,r)=>G_t.has(t)&&Tr(e)&&Tr(r)?{...e,...r}:r,G_t=new Set(["env",...Q9]);var hd=(t,e,r,n)=>{let i=(s,a,c)=>hd(s,a,r,c),o=(...s)=>H_t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},H_t=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(Tr(o))return i(t,WM(r,o),n);let{file:a,commandArguments:c,options:u,isSync:l}=W_t({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return l?Dxe(a,c,u):LIe(a,c,u,i)},W_t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=Kwe(e)?Ywe(e,r):[e,...r],[s,a,c]=jD(...o),u=WM(WM(n,i),c),{file:l=s,commandArguments:d=a,options:f=u,isSync:p=!1}=t({file:s,commandArguments:a,options:u});return{file:l,commandArguments:d,options:f,isSync:p}};var UIe=({file:t,commandArguments:e})=>zIe(t,e),FIe=({file:t,commandArguments:e})=>({...zIe(t,e),isSync:!0}),zIe=(t,e)=>{if(e.length>0)throw new TypeError(`The command and its arguments must be passed as a single string: ${t} ${e}.`);let[r,...n]=K_t(t);return{file:r,commandArguments:n}},K_t=t=>{if(typeof t!="string")throw new TypeError(`The command must be a string: ${String(t)}.`);let e=t.trim();if(e==="")return[];let r=[];for(let n of e.split(Y_t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},Y_t=/ +/g;var jIe=(t,e,r)=>{t.sync=e(Z_t,r),t.s=t.sync},BIe=({options:t})=>qIe(t),Z_t=({options:t})=>({...qIe(t),isSync:!0}),qIe=t=>({options:{...X_t(t),...t}}),X_t=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},VIe={preferLocal:!0};var GIe=hd(()=>({})),Mmr=hd(()=>({isSync:!0})),HIe=hd(UIe),Lmr=hd(FIe),Umr=hd(rRe),Fmr=hd(BIe,{},VIe,jIe),{sendMessage:zmr,getOneMessage:jmr,getEachMessage:Bmr,getCancelSignal:qmr}=Bxe();var WIe=!1,KIe,J_t=t=>{KIe??=t},YIe=t=>{WIe=!0,J_t(t)},Gn=()=>WIe,Au=()=>KIe,ZIe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var hR=null,XIe=t=>(hR&&hR.destroy(),hR=new es({totalAllowedTime:t}),hR),JIe=()=>hR;var es=class{constructor({totalAllowedTime:e}){this.withStageTimer=async(e,r,n,{interruptible:i=!0}={})=>{if(this.isTimeExpired())throw new Error(`${e} stage did not complete in the allowed time. Time has already expired.`);if(i&&Gn())throw new Error(`Aborting ${e} stage \u2014 shutting down`);let o=this.onTimesUp(()=>{throw new Error(`${e} stage did not complete in the allowed time.`)}),s=null,a=null;n!==void 0&&(a=new Promise((l,d)=>{s=setTimeout(()=>{d(new Error(`${e} stage exceeded its maximum duration of ${n}ms`))},n)}));let c=Date.now(),u="success";try{return await ok({stage:e},async()=>a?await Promise.race([r(),a]):await r())}catch(l){throw u="failure",l}finally{K.timing("stage.duration",Date.now()-c,{stage:e,outcome:u}),o(),s&&clearTimeout(s)}};this.startTime=Date.now(),this.totalAllowedTime=e,this.globalTimeoutId=null,this.subscribers=[],this.hasTimedOut=!1,this.setupGlobalTimeout()}getElapsedTime(){return Date.now()-this.startTime}getRemainingTime(){let e=this.getElapsedTime(),r=this.totalAllowedTime-e;return Math.max(0,r)}isTimeExpired(){return this.getRemainingTime()===0||this.hasTimedOut}setupGlobalTimeout(){this.globalTimeoutId&&clearTimeout(this.globalTimeoutId),this.globalTimeoutId=setTimeout(()=>{this.notifyTimeUp()},this.totalAllowedTime)}notifyTimeUp(){this.hasTimedOut=!0;for(let e=this.subscribers.length-1;e>=0;e--)try{this.subscribers[e]()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}}onTimesUp(e){if(this.subscribers.push(e),this.hasTimedOut)try{e()}catch(r){console.error("TimeKeeper: Error in time up callback:",r)}return()=>{let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}}off(e){let r=this.subscribers.indexOf(e);r>-1&&this.subscribers.splice(r,1)}clearSubscribers(){this.subscribers.length=0}getSubscriberCount(){return this.subscribers.length}destroy(){this.globalTimeoutId&&(clearTimeout(this.globalTimeoutId),this.globalTimeoutId=null),this.clearSubscribers()}static{this.timeUnits={seconds:e=>e*1e3,minutes:e=>e*60*1e3,hours:e=>e*60*60*1e3}}};var QIe={name:"@netlify/agent-runner-cli",type:"module",version:"2.12.0-nb987b7e96221d.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md" "!src/lib/__fixtures__/**"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md" "!src/lib/__fixtures__/**"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:opencode":"vitest run test/integration/opencode.test.ts","test:integration:muse":"vitest run test/integration/muse.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},engines:{node:">=22"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@grpc/grpc-js":"1.14.6","@netlify/axis":"^1.21.0","@netlify/eslint-config-node":"^7.0.1","@netlify/skills":"1.7.0","@opentelemetry/sdk-trace-base":"2.9.0","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.295","@anthropic-ai/sdk":"^0.134.0","@google/gemini-cli":"0.63.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.2","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.162.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0","@opentelemetry/otlp-transformer":"0.218.0",execa:"^9.6.1",fastify:"5.12.6",minimist:"^1.2.8",openai:"7.31.0",zod:"^4.4.3"}};var ryt=eyt(import.meta.url),nyt=Ru.dirname(ryt),iyt=tyt(import.meta.url),Ny=oe("shell"),T8=new Set,eOe={preferLocal:!0},vt=(t,e,r)=>{let[n,i]=oyt(e,r),o={...eOe,...i},s=GIe(t,n,o);rOe(s,o),oOe(s);let a=r?.idleTimeout;return a&&a>0&&iOe(s,a),s},tOe=(t,e)=>{let r={...eOe,...e},n=HIe(t,r);return rOe(n,r),oOe(n),e?.idleTimeout&&e.idleTimeout>0&&iOe(n,e.idleTimeout),n},oyt=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},rOe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||dc.env.NETLIFY_LOCAL_QUIET==="true")return;if(dc.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Lw).pipe(dc.stdout),t.stderr?.pipe(new Lw).pipe(dc.stderr);return}t.stdout?.pipe(dc.stdout),t.stderr?.pipe(dc.stderr)},A8=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(dc.kill(-t.pid,e),Ny.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Ny.error("Error killing process:",r),!1}},nOe=t=>A8(t,"SIGKILL"),iOe=(t,e)=>{let r=null,n=()=>{Ny.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),A8(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Ny.log(`Force killing idle process ${t.pid}`),nOe(t))},5e3)},i=()=>{r&&clearTimeout(r),r=setTimeout(n,e)};i(),t.stdout?.on("data",i),t.stderr?.on("data",i);let o=()=>{r&&(clearTimeout(r),r=null)};t.on("exit",o),t.on("error",o)},oOe=t=>{T8.add(t);let e=JIe();if(e){let r=e.onTimesUp(()=>{Ny.log(`Global timer expired, killing process ${t.pid}`),A8(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Ny.log(`Force killing process ${t.pid} after timeout`),nOe(t))},5e3)});t.on("exit",()=>{T8.delete(t),r()}),t.on("error",()=>{T8.delete(t),r()})}};function YM(t,e){return!!fa(t,e)}function fa(t,e){if(!dc.env.NETLIFY_LOCAL_MODE)try{let i=iyt.resolve(QIe.name),o=Ru.dirname(i);for(;o!==Ru.dirname(o);){let s=Ru.dirname(o);if(Ru.basename(s)==="node_modules"){let a=Ru.join(s,".bin",e);if(KM.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(dc.env.NODE_PATH){let i=Ru.join(dc.env.NODE_PATH,".bin",e);if(KM.existsSync(i))return i}let r=Ru.join(t,"node_modules",".bin",e);if(KM.existsSync(r))return r;let n=Ru.join(nyt,"..","node_modules",".bin",e);if(KM.existsSync(n))return n}var $y=oe("repo"),fOe="runner-diffs-",R8=t=>`${fOe}${t}-`,pOe=async t=>{let e=XM.tmpdir(),r;try{r=await mi.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(fOe)&&!n.startsWith(R8(t))).map(n=>mi.rm(ts.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},sOe=async t=>{let e=syt("sha256");for await(let r of ayt(t))e.update(r);return e.digest("hex")},aOe=async(t,e)=>t.size===e.size&&await sOe(t.path)===await sOe(e.path),hOe=/.. (.+)?\.log$/,cyt=[hOe],uyt=1,cOe=t=>{let e=t.split(`
387
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)},lyt=t=>t instanceof Error&&String(t.stderr??"").includes("No such remote"),uOe=t=>{let e=t instanceof Error?t.message:String(t),r=String(t?.stderr??"").trim();return Rn(r?`${e}: ${r}`:e)},dyt=t=>/Authentication failed|returned error: 401/.test(String(t?.stderr??"")),lOe=t=>t.pathname.replace(/\/+$/,"").replace(/\.git$/,""),fyt=(t,e)=>{try{let r=new URL(t),n=new URL(e);return["https:","http:"].includes(n.protocol)&&n.protocol===r.protocol&&n.host===r.host&&lOe(n)===lOe(r)&&n.password!==""}catch{return!1}},dOe={stdin:"pipe",stdout:"pipe",stderr:"pipe",stripFinalNewline:!1},ZM=500,mR=class extends Error{constructor(r,n){super(n instanceof Error?n.message:String(n));this.step=r;this.cause=n}},Hn=class{constructor(e=process.cwd()){this.cwd=e}getRoot(){return this.root??=this.run(["rev-parse","--show-toplevel"],{stdout:"pipe"}).then(({stdout:e})=>String(e).trim()),this.root}async restorePausedWork(e){let r="restore";try{let n=await this.restorePausedFiles(e);r="stage",await this.stageBuildSetup();let i=await this.getRoot(),o=new Set(n.changedFiles),s=(await this.listIndexEntries(n.deletedFiles,{cwd:i})).filter(({filePath:a})=>!o.has(a));return await this.unstageFiles(n.changedFiles,{cwd:i}),s.length>0&&await mi.writeFile(await this.getSetupMetadataPath(),JSON.stringify(s)),{rewrittenFileCount:n.rewrittenFileCount}}catch(n){throw new mR(r,n)}}run(e,r={}){return vt("git",e,{cwd:this.cwd,...r,env:{...r.env,NETLIFY_INTERNAL_GIT:"1"}})}async commitAndCreateDiffs({config:e,isRetry:r}){$y.info("Getting runner diffs");let n=await this.hasAgentChanges(),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!r){let u=cOe(o);await this.discardSetupOnlyChanges(u)}$y.info("Changes after processing"),await this.getStatus();let s=await this.getIgnoredPathspecs(o);if(await this.stageFiles(s),await this.excludeUnchangedSetupDescendants(),i=await this.hasStagedChanges(),!i)return{hasChanges:!1,ignored:s};await this.run(["commit","-m","Agent runner [skip ci]"]);let a=await mi.mkdtemp(ts.join(XM.tmpdir(),R8(e.sessionId))),c=await this.writeDiffFiles({config:e,diffDir:a,target:{commit:"HEAD"},ignored:s});return await this.rollbackIfLocal(),c.hasChanges&&K.distribution("diff.size",(c.diffBinary??c.diff).size,{phase:"final"}),c}async getStatus(){let e=await this.run(["-c","status.relativePaths=true","status","-s"]);return String(e.stdout??"")}async hasAgentChanges(){let e=await this.getStatus();return{hasChanges:(e.trim().length===0?[]:e.split(`
388
389
  `).filter(i=>cyt.some(s=>s instanceof RegExp?s.test(i):i===s)?!1:i[1]?.trim()!=="")).length!==0,status:e}}async getCurrentCommitSha(){let{stdout:e}=await this.run(["rev-parse","HEAD"]);return String(e??"").trim()}async reset(){await this.run(["reset","--hard","HEAD"]),await mi.rm(await this.getSetupMetadataPath(),{force:!0})}async discardSetupOnlyChanges(e){let r=e.filter(n=>n.stage&&!n.change).map(n=>n.filePath);r.length!==0&&await this.run(["restore","--staged","--worktree","--pathspec-from-file=-"],{input:r.join(`
389
390
  `)})}async stageBuildSetup(){await mi.rm(await this.getSetupMetadataPath(),{force:!0});let e=await this.getIgnoredPathspecs();await this.stageFiles(e)}getSetupMetadataPath(){return this.setupMetadataPath??=this.getRoot().then(async e=>{let{stdout:r}=await this.run(["rev-parse","--git-path","netlify-agent-runner-setup.json"],{cwd:e,stdout:"pipe"});return ts.resolve(e,String(r).trim())}),this.setupMetadataPath}async listIndexEntries(e,r){let n=[];for(let i=0;i<e.length;i+=ZM){let o=e.slice(i,i+ZM).map(a=>`:(literal)${a}`),{stdout:s}=await this.run(["ls-files","--stage","-z","--",...o],{...dOe,...r});for(let a of String(s??"").split("\0").filter(Boolean))n.push({filePath:a.slice(a.indexOf(" ")+1),entry:a})}return n}async excludeUnchangedSetupDescendants(e){let r;try{r=JSON.parse(await mi.readFile(await this.getSetupMetadataPath(),"utf8"))}catch(a){if(a.code==="ENOENT")return;throw a}let i={cwd:await this.getRoot(),env:e},o=new Map((await this.listIndexEntries(r.map(({filePath:a})=>a),i)).map(({filePath:a,entry:c})=>[a,c])),s=r.filter(({filePath:a,entry:c})=>o.get(a)===c);s.length!==0&&await this.run(["update-index","--force-remove","-z","--stdin"],{...i,input:s.map(({filePath:a})=>a).join("\0")})}async getIgnoredPathspecs(e){e||=await this.getStatus();let r=[".netlify","node_modules","dist",".next","out",".nuxt",".output",".cache",".turbo",".parcel-cache","coverage",".nyc_output","storybook-static","public/build","CLAUDE.local.md"],n=[];return e.split(`
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:YQ},qzt=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},Bzt={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:qzt};import{Buffer as Vzt}from"buffer";var VLe=(t,e)=>t?void 0:Hzt.bind(void 0,e),Hzt=function*(t,e){if(typeof e!="string"&&!xn(e)&&!Vzt.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},HLe=(t,e)=>t?Gzt.bind(void 0,e):Wzt.bind(void 0,e),Gzt=function*(t,e){GLe(t,e),yield e},Wzt=function*(t,e){if(GLe(t,e),typeof e!="string"&&!xn(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},GLe=(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 Kzt}from"buffer";import{StringDecoder as Yzt}from"string_decoder";var lU=(t,e,r)=>{if(r)return;if(t)return{transform:Jzt.bind(void 0,new TextEncoder)};let n=new Yzt(e);return{transform:Zzt.bind(void 0,n),final:Xzt.bind(void 0,n)}},Jzt=function*(t,e){Kzt.isBuffer(e)?yield Rl(e):typeof e=="string"?yield t.encode(e):yield e},Zzt=function*(t,e){yield xn(e)?t.write(e):e},Xzt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as WLe}from"util";var ZQ=WLe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),dU=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=eqt}=e[r];for await(let i of n(t))yield*dU(i,e,r+1)},KLe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Qzt(r,Number(e),t)},Qzt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*dU(n,r,e+1)},YLe=WLe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),eqt=function*(t){yield t};var XQ=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},JLe=(t,e)=>[...e.flatMap(r=>[...Dm(r,t,0)]),...yx(t)],Dm=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=rqt}=e[r];for(let i of n(t))yield*Dm(i,e,r+1)},yx=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*tqt(r,Number(e),t)},tqt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Dm(n,r,e+1)},rqt=function*(t){yield t};var QQ=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=XLe(t,o,s),u=$m(e),l=$m(r),d=u?ZQ.bind(void 0,dU,a):XQ.bind(void 0,Dm),f=u||l?ZQ.bind(void 0,KLe,a):XQ.bind(void 0,yx),p=u||l?YLe.bind(void 0,a):void 0;return{stream:new nqt({writableObjectMode:n,writableHighWaterMark:ZLe(n),readableObjectMode:i,readableHighWaterMark:ZLe(i),transform(m,g,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},fU=(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=XLe(o,r,a);t=JLe(c,t)}return t},XLe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:VLe(n,a)},lU(r,o,n),uU(r,s,n,c),{transform:t,final:e},{transform:HLe(i,a)},BLe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var QLe=(t,e)=>{for(let r of iqt(t))sqt(t,r,e)},iqt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),sqt=(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 ${$f[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>oqt(a,n));r.input=cx(o)},oqt=(t,e)=>{let r=fU(t,e,"utf8",!0);return aqt(r),cx(r)},aqt=t=>{let e=t.find(r=>typeof r!="string"&&!xn(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 dqt,appendFileSync as fqt}from"fs";var pU=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&oE(r,n)&&!ro.has(e)&&cqt(n)&&(t.some(({type:i,value:s})=>i==="native"&&uqt.has(s))||t.every(({type:i})=>Zo.has(i))),cqt=t=>t===1||t===2,uqt=new Set(["pipe","overlapped"]),eMe=async(t,e,r,n)=>{for await(let i of t)lqt(e)||rMe(i,r,n)},tMe=(t,e,r)=>{for(let n of t)rMe(n,e,r)},lqt=t=>t._readableState.pipes.length>0,rMe=(t,e,r)=>{let n=x1(t);iu({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var nMe=({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)=>pqt({result:c,fileDescriptors:t,fdNumber:u,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},pqt=({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=iLe(t,s,d),p=Rl(f),{stdioItems:h,objectMode:m}=e[r],g=hqt([p],h,c,n),{serializedResult:y,finalResult:E=y}=mqt({chunks:g,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});gqt({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&&_qt(y,h,i),S}catch(_){return n.error=_,S}},hqt=(t,e,r,n)=>{try{return fU(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:cx(t)};let o=yNe(t,r);return n[s]?{serializedResult:o,finalResult:JQ(o,!i[s],e)}:{serializedResult:o}},gqt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!pU({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=JQ(t,!1,o);try{tMe(a,e,n)}catch(c){r.error??=c}},_qt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>aU.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?fqt(n,t):(r.add(s),dqt(n,t))}};var iMe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Il(e,r,"all")]:Array.isArray(e)?[Il(t,r,"all"),...e]:xn(t)&&xn(e)?sQ([t,e]):`${t}${e}`};import{once as e7}from"events";var sMe=async(t,e)=>{let[r,n]=await yqt(t);return e.isForcefullyTerminated??=!1,[r,n]},yqt=async t=>{let[e,r]=await Promise.allSettled([e7(t,"spawn"),e7(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?oMe(t):r.value},oMe=async t=>{try{return await e7(t,"exit")}catch{return oMe(t)}},aMe=async t=>{let[e,r]=await t;if(!Sqt(e,r)&&t7(e,r))throw new Ka;return[e,r]},Sqt=(t,e)=>t===void 0&&e===void 0,t7=(t,e)=>t!==0||e!==null;var cMe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=Eqt(t,e,r),o=s?.code==="ETIMEDOUT",a=nLe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},Eqt=(t,e,r)=>t!==void 0?t:t7(e,r)?new Ka:void 0;var uMe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=bqt(t,e,r),d=Aqt({file:n,commandArguments:i,options:u,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:l,startTime:a});return gE(d,c,u)},bqt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=I1(t,e,r),a=wqt(r),{file:c,commandArguments:u,options:l}=Y1(t,e,a);Tqt(l);let d=FLe(l,o);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},wqt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Tqt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&hU("ipcInput"),t&&hU("ipc: true"),r&&hU("detached: true"),n&&hU("cancelSignal")},hU=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Aqt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=Rqt({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}=cMe(c,r),{output:h,error:m=u}=nMe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),g=h.map((E,S)=>Il(E,r,S)),y=Il(iMe(h,r),r,"all");return Oqt({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:y,options:r,command:n,escapedCommand:i,startTime:a})},Rqt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{QLe(s,r);let a=xqt(r);return vqt(...J1(t,e,a))}catch(a){return mE({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},xqt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:nU(e)}),Oqt=({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?iU({command:c,escapedCommand:u,stdio:s,all:o,ipcOutput:[],options:a,startTime:l}):_x({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 g2t}from"child_process";import hMe from"process";import{once as r7,on as Iqt}from"events";var lMe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(uE({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:B1(t)}),Pqt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),Pqt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{F1(e,i);let s=Nf(t,e,r),o=new AbortController;try{return await Promise.race([Cqt(s,n,o),kqt(s,r,o),Nqt(s,r,o)])}catch(a){throw lE(t),a}finally{o.abort(),j1(e,i)}},Cqt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await r7(t,"message",{signal:r});return n}for await(let[n]of Iqt(t,"message",{signal:r}))if(e(n))return n},kqt=async(t,e,{signal:r})=>{await r7(t,"disconnect",{signal:r}),J$e(e)},Nqt=async(t,e,{signal:r})=>{let[n]=await r7(t,"strict:error",{signal:r});throw L1(n,e)};import{once as fMe,on as $qt}from"events";var pMe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>n7({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),n7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{uE({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:B1(t)}),F1(e,s);let o=Nf(t,e,r),a=new AbortController,c={};return Dqt(t,o,a),Lqt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),Mqt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},Dqt=async(t,e,r)=>{try{await fMe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Lqt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await fMe(t,"strict:error",{signal:r.signal});n.error=L1(i,e),r.abort()}catch{}},Mqt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of $qt(r,"message",{signal:s.signal}))dMe(o),yield c}catch{dMe(o)}finally{s.abort(),j1(e,a),n||lE(t),i&&await t}},dMe=({error:t})=>{if(t)throw t};var mMe=(t,{ipc:e})=>{Object.assign(t,_Me(t,!1,e))},gMe=()=>{let t=hMe,e=!0,r=hMe.channel!==void 0;return{..._Me(t,e,r),getCancelSignal:wDe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},_Me=(t,e,r)=>({sendMessage:W1.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:lMe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:pMe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Uqt}from"child_process";import{PassThrough as Fqt,Readable as jqt,Writable as zqt,Duplex as qqt}from"stream";var yMe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{WQ(n);let a=new Uqt;Bqt(a,n),Object.assign(a,{readable:Vqt,writable:Hqt,duplex:Gqt});let c=mE({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),u=Wqt(c,o,i);return{subprocess:a,promise:u}},Bqt=(t,e)=>{let r=Sx(),n=Sx(),i=Sx(),s=Array.from({length:e.length-3},Sx),o=Sx(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},Sx=()=>{let t=new Fqt;return t.end(),t},Vqt=()=>new jqt({read(){}}),Hqt=()=>new zqt({write(){}}),Gqt=()=>new qqt({read(){},write(){}}),Wqt=async(t,e,r)=>gE(t,e,r);import{createReadStream as SMe,createWriteStream as EMe}from"fs";import{Buffer as Kqt}from"buffer";import{Readable as Ex,Writable as Yqt,Duplex as Jqt}from"stream";var bMe=(t,e)=>cU(Zqt,t,e,!1),vx=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${$f[t]}.`)},vMe={fileNumber:vx,generator:QQ,asyncGenerator:QQ,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Jqt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Zqt={input:{...vMe,fileUrl:({value:t})=>({stream:SMe(t)}),filePath:({value:{file:t}})=>({stream:SMe(t)}),webStream:({value:t})=>({stream:Ex.fromWeb(t)}),iterable:({value:t})=>({stream:Ex.from(t)}),asyncIterable:({value:t})=>({stream:Ex.from(t)}),string:({value:t})=>({stream:Ex.from(t)}),uint8Array:({value:t})=>({stream:Ex.from(Kqt.from(t))})},output:{...vMe,fileUrl:({value:t})=>({stream:EMe(t)}),filePath:({value:{file:t,append:e}})=>({stream:EMe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Yqt.fromWeb(t)}),iterable:vx,asyncIterable:vx,string:vx,uint8Array:vx}};import{on as Xqt,once as wMe}from"events";import{PassThrough as Qqt,getDefaultHighWaterMark as eBt}from"stream";import{finished as RMe}from"stream/promises";function Lm(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)s7(i);let e=t.some(({readableObjectMode:i})=>i),r=tBt(t,e),n=new i7({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var tBt=(t,e)=>{if(t.length===0)return eBt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},i7=class extends Qqt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(s7(e),this.#e.has(e))return;this.#e.add(e),this.#n??=rBt(this,this.#e,this.#s);let r=sBt({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(s7(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)}},rBt=async(t,e,r)=>{mU(t,TMe);let n=new AbortController;try{await Promise.race([nBt(t,n),iBt(t,e,r,n)])}finally{n.abort(),mU(t,-TMe)}},nBt=async(t,{signal:e})=>{try{await RMe(t,{signal:e,cleanup:!0})}catch(r){throw xMe(t,r),r}},iBt=async(t,e,r,{signal:n})=>{for await(let[i]of Xqt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},s7=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},sBt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{mU(t,AMe);let a=new AbortController;try{await Promise.race([oBt(s,e,a),aBt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),cBt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),mU(t,-AMe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?o7(t):uBt(t))},oBt=async(t,e,{signal:r})=>{try{await t,r.aborted||o7(e)}catch(n){r.aborted||xMe(e,n)}},aBt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await RMe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;OMe(o)?i.add(e):IMe(t,o)}},cBt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await wMe(t,i,{signal:s}),!t.readable)return wMe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},uBt=t=>{t.writable&&t.end()},xMe=(t,e)=>{OMe(e)?o7(t):IMe(t,e)},OMe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",o7=t=>{(t.readable||t.writable)&&t.destroy()},IMe=(t,e)=>{t.destroyed||(t.once("error",lBt),t.destroy(e))},lBt=()=>{},mU=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},TMe=2,AMe=1;import{finished as PMe}from"stream/promises";var yE=(t,e)=>{t.pipe(e),dBt(t,e),fBt(t,e)},dBt=async(t,e)=>{if(!(Wa(t)||Wa(e))){try{await PMe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}a7(e)}},a7=t=>{t.writable&&t.end()},fBt=async(t,e)=>{if(!(Wa(t)||Wa(e))){try{await PMe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}c7(t)}},c7=t=>{t.readable&&t.destroy()};var CMe=(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})=>Zo.has(c)))pBt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Zo.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]:Lm(s);yE(o,i)}},pBt=(t,e,r,n)=>{r==="output"?yE(t.stdio[n],e):yE(e,t.stdio[n]);let i=hBt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},hBt=["stdin","stdout","stderr"],mBt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;gBt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},gBt=(t,{signal:e})=>{Wa(t)&&km(t,_Bt,e)},_Bt=2;import{addAbortListener as EBt}from"events";var Mm=[];Mm.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Mm.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Mm.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var gU=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",u7=Symbol.for("signal-exit emitter"),l7=globalThis,yBt=Object.defineProperty.bind(Object),d7=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(l7[u7])return l7[u7];yBt(l7,u7,{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}},_U=class{},SBt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),f7=class extends _U{onExit(){return()=>{}}load(){}unload(){}},p7=class extends _U{#e=h7.platform==="win32"?"SIGINT":"SIGHUP";#r=new d7;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Mm)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(!gU(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 Mm)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,Mm.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 gU(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"&&gU(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)}},h7=globalThis.process,{onExit:kMe,load:g2r,unload:_2r}=SBt(gU(h7)?new p7(h7):new f7);var NMe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=kMe(()=>{t.kill()});EBt(n,()=>{i()})};var DMe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=O1(),{destination:o,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=vBt(r,n,i),{sourceStream:d,sourceError:f}=wBt(t,u),{options:p,fileDescriptors:h}=ou.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:s}},vBt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=bBt(t,e,...r),a=U1(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},bBt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e($Me,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||nQ(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]=y1(r,...n);return{destination:e($Me)(i,s,o),pipeOptions:o}}if(ou.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}`)},$Me=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),wBt=(t,e)=>{try{return{sourceStream:dE(t,e)}}catch(r){return{sourceError:r}}};var MMe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=TBt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw m7({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},TBt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return c7(t),n;if(e!==void 0)return a7(r),e},m7=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>mE({error:t,command:LMe,escapedCommand:LMe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),LMe="source.pipe(destination)";var UMe=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 ABt}from"stream/promises";var FMe=(t,e,r)=>{let n=yU.has(e)?xBt(t,e):RBt(t,e);return km(t,IBt,r.signal),km(e,PBt,r.signal),OBt(e),n},RBt=(t,e)=>{let r=Lm([t]);return yE(r,e),yU.set(e,r),r},xBt=(t,e)=>{let r=yU.get(e);return r.add(t),r},OBt=async t=>{try{await ABt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}yU.delete(t)},yU=new WeakMap,IBt=2,PBt=1;import{aborted as CBt}from"util";var jMe=(t,e)=>t===void 0?[]:[kBt(t,e)],kBt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await CBt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw m7({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var SU=(t,...e)=>{if(Qr(e[0]))return SU.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=DMe(t,...e),i=NBt({...n,destination:r});return i.pipe=SU.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},NBt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=$Bt(t,i);MMe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=FMe(e,s,d);return await Promise.race([UMe(l),...jMe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},$Bt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as zBt}from"timers/promises";import{on as DBt}from"events";import{getDefaultHighWaterMark as LBt}from"stream";var EU=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return MBt(e,o),qMe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},MBt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},g7=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;UBt(e,o,t);let a=t.readableObjectMode&&!s;return qMe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},UBt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},qMe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=DBt(t,"data",{signal:e.signal,highWaterMark:zMe,highWatermark:zMe});return FBt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},_7=LBt(!0),zMe=_7,FBt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=jBt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Dm(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*yx(a)}},jBt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[lU(t,r,!e),uU(t,i,!n,{})].filter(Boolean);var BMe=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=qBt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([BBt(t),d]);return}let f=KQ(c,r),p=g7({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([VBt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},qBt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!pU({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=g7({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await eMe(a,t,r,s)},BBt=async t=>{await zBt(),t.readableFlowing===null&&t.resume()},VBt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await eU(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await tU(r,{maxBuffer:s})):await hE(r,{maxBuffer:s})}catch(a){return VMe(eLe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},y7=async t=>{try{return await t}catch(e){return VMe(e)}},VMe=({bufferedData:t})=>gNe(t)?new Uint8Array(t):t;import{finished as HBt}from"stream/promises";var bx=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=GBt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],HBt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||YBt(a,e,r,n)}finally{o.abort()}},GBt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&WBt(t,r,n),n},WBt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{KBt(e,r),n.call(t,...i)}},KBt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},YBt=(t,e,r,n)=>{if(!JBt(t,e,r,n))throw t},JBt=(t,e,r,n=!0)=>r.propagating?HMe(t)||vU(t):(r.propagating=!0,S7(r,e)===n?HMe(t):vU(t)),S7=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",vU=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",HMe=t=>t?.code==="EPIPE";var GMe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,u)=>E7({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),E7=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=bx(t,e,u);if(S7(u,e)){await l;return}let[d]=await Promise.all([BMe({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 WMe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Lm([t,e].filter(Boolean)):void 0,KMe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>E7({...ZBt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:XBt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),ZBt=({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}},XBt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as QBt}from"events";var YMe=t=>oE(t,"ipc"),JMe=(t,e)=>{let r=x1(t);iu({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var ZMe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=YMe(s),a=xl(e,"ipc"),c=xl(r,"ipc");for await(let u of n7({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(tLe(t,i,c),i.push(u)),o&&JMe(u,s);return i},XMe=async(t,e)=>(await Promise.allSettled([t]),e);var QMe=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=sMe(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:E,propagating:!1},_=GMe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:S}),w=KMe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:S}),b=[],R=ZMe({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:b,verboseInfo:p}),T=e2t(m,t,S),I=t2t(h,S);try{return await Promise.race([Promise.all([{},aMe(E),Promise.all(_),w,R,NDe(t,d),...T,...I]),g,r2t(t,y),...ODe(t,s,f,y),...Y$e({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...RDe({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(O=>y7(O))),y7(w),XMe(R,b),Promise.allSettled(T),Promise.allSettled(I)])}},e2t=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:bx(n,i,r)),t2t=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>Ja(s,{checkOpen:!1})&&!Wa(s)).map(({type:i,value:s,stream:o=s})=>bx(o,n,e,{isSameDirection:Zo.has(i),stopOnExit:i==="native"}))),r2t=async(t,{signal:e})=>{let[r]=await QBt(t,"error",{signal:e});throw r};var e1e=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),wx=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=su();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},SE=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 n2t}from"stream";import{callbackify as i2t}from"util";import{finished as t1e}from"stream/promises";var v7=async t=>{if(t!==void 0)try{await b7(t)}catch{}},r1e=async t=>{if(t!==void 0)try{await w7(t)}catch{}},b7=async t=>{await t1e(t,{cleanup:!0,readable:!1,writable:!0})},w7=async t=>{await t1e(t,{cleanup:!0,readable:!0,writable:!1})},bU=async(t,e)=>{if(await t,e)throw e},wU=(t,e,r)=>{r&&!vU(r)?t.destroy(r):e&&t.destroy()};var n1e=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||ro.has(r),{subprocessStdout:a,waitReadableDestroy:c}=T7(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=A7(a,o),{read:f,onStdoutDataDone:p}=R7({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new n2t({read:f,destroy:i2t(O7.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return x7({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},T7=(t,e,r)=>{let n=dE(t,e),i=wx(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},A7=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:_7},R7=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=su(),o=EU({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){s2t(this,o,s)},onStdoutDataDone:s}},s2t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},x7=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await w7(t),await n,await v7(i),await e,r.readable&&r.push(null)}catch(s){await v7(i),i1e(r,s)}},O7=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await SE(r,e)&&(i1e(t,n),await bU(e,n))},i1e=(t,e)=>{wU(t,t.readable,e)};import{Writable as o2t}from"stream";import{callbackify as s1e}from"util";var o1e=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=I7(t,r,e),o=new o2t({...P7(n,t,i),destroy:s1e(k7.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return C7(n,o),o},I7=(t,e,r)=>{let n=U1(t,e),i=wx(r,n,"writableFinal"),s=wx(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},P7=(t,e,r)=>({write:a2t.bind(void 0,t),final:s1e(c2t.bind(void 0,t,e,r))}),a2t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},c2t=async(t,e,r)=>{await SE(r,e)&&(t.writable&&t.end(),await e)},C7=async(t,e,r)=>{try{await b7(t),e.writable&&e.end()}catch(n){await r1e(r),a1e(e,n)}},k7=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await SE(r,e),await SE(n,e)&&(a1e(t,i),await bU(e,i))},a1e=(t,e)=>{wU(t,t.writable,e)};import{Duplex as u2t}from"stream";import{callbackify as l2t}from"util";var c1e=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||ro.has(r),{subprocessStdout:c,waitReadableDestroy:u}=T7(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=I7(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=A7(c,a),{read:g,onStdoutDataDone:y}=R7({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),E=new u2t({read:g,...P7(l,t,d),destroy:l2t(d2t.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 x7({subprocessStdout:c,onStdoutDataDone:y,readable:E,subprocess:t,subprocessStdin:l}),C7(l,E,c),E},d2t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([O7({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),k7({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var N7=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||ro.has(e),o=dE(t,r),a=EU({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return f2t(a,o,t)},f2t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var u1e=(t,{encoding:e})=>{let r=e1e();t.readable=n1e.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=o1e.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=c1e.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=N7.bind(void 0,t,e),t[Symbol.asyncIterator]=N7.bind(void 0,t,e,{})};var l1e=(t,e)=>{for(let[r,n]of h2t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},p2t=(async()=>{})().constructor.prototype,h2t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(p2t,t)]);var d1e=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=_2t(t,e,r),{subprocess:f,promise:p}=S2t({file:i,commandArguments:s,options:l,startTime:c,verboseInfo:u,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=SU.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),l1e(f,p),ou.set(f,{options:l,fileDescriptors:d}),f},_2t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=I1(t,e,r),{file:a,commandArguments:c,options:u}=Y1(t,e,r),l=y2t(u),d=bMe(l,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},y2t=({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}},S2t=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=g2t(...J1(t,e,r))}catch(h){return yMe({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];CMe(c,a,u),NMe(c,r,u);let d={},f=su();c.kill=W$e.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=WMe(c,r),u1e(c,r),mMe(c,r);let p=E2t({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}},E2t=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 QMe({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)=>Il(_,e,w)),E=Il(m,e,"all"),S=v2t({errorInfo:d,exitCode:f,signal:p,stdio:y,all:E,ipcOutput:g,context:c,options:e,command:o,escapedCommand:a,startTime:r});return gE(S,n,e)},v2t=({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?_x({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 au,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:l,isSync:!1}):iU({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:s,options:a,startTime:l});var TU=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,b2t(n,t[n],i)]));return{...t,...r}},b2t=(t,e,r)=>w2t.has(t)&&Qr(e)&&Qr(r)?{...e,...r}:r,w2t=new Set(["env",...uQ]);var Df=(t,e,r,n)=>{let i=(o,a,c)=>Df(o,a,r,c),s=(...o)=>T2t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},T2t=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Qr(s))return i(t,TU(r,s),n);let{file:a,commandArguments:c,options:u,isSync:l}=A2t({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return l?uMe(a,c,u):d1e(a,c,u,i)},A2t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=bNe(e)?wNe(e,r):[e,...r],[o,a,c]=y1(...s),u=TU(TU(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 f1e=({file:t,commandArguments:e})=>h1e(t,e),p1e=({file:t,commandArguments:e})=>({...h1e(t,e),isSync:!0}),h1e=(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]=R2t(t);return{file:r,commandArguments:n}},R2t=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(x2t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},x2t=/ +/g;var m1e=(t,e,r)=>{t.sync=e(O2t,r),t.s=t.sync},g1e=({options:t})=>_1e(t),O2t=({options:t})=>({..._1e(t),isSync:!0}),_1e=t=>({options:{...I2t(t),...t}}),I2t=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},y1e={preferLocal:!0};var S1e=Df(()=>({})),o4r=Df(()=>({isSync:!0})),E1e=Df(f1e),a4r=Df(p1e),c4r=Df(PDe),u4r=Df(g1e,{},y1e,m1e),{sendMessage:l4r,getOneMessage:d4r,getEachMessage:f4r,getCancelSignal:p4r}=gMe();import{Transform as P2t}from"stream";var C2t=["NETLIFY_AI_GATEWAY_KEY","NETLIFY_API_TOKEN","NETLIFY_AUTH_TOKEN"];function k2t(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...C2t])]}function N2t(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function $2t(){let e=k2t().map(r=>process.env[r]).filter(r=>!(!r||N2t(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Ei(t){if(typeof t!="string")return t;let e=$2t();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(D2t(n),"g");r=r.replace(i,"******")}),r}function D2t(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Tx=class extends P2t{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Ei(i);n(null,s)}},AU=Symbol("maskedWrite");function v1e(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[AU]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Ei(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[AU]=!0,process.stdout.write=r}if(!process.stderr.write[AU]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Ei(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[AU]=!0,process.stderr.write=r}}}var b1e=!1,w1e,$7=t=>{w1e??=t},T1e=t=>{b1e=!0,$7(t)},en=()=>b1e,Xo=()=>w1e,A1e=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var Ax=null,R1e=t=>(Ax&&Ax.destroy(),Ax=new Qo({totalAllowedTime:t}),Ax),x1e=()=>Ax;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&&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 vD({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 O1e={name:"@netlify/agent-runner-cli",type:"module",version:"2.12.0-nb8c571bb6e224.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md" "!src/lib/__fixtures__/**"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md" "!src/lib/__fixtures__/**"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:opencode":"vitest run test/integration/opencode.test.ts","test:integration:muse":"vitest run test/integration/muse.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},engines:{node:">=22"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@grpc/grpc-js":"1.14.6","@netlify/axis":"^1.21.0","@netlify/eslint-config-node":"^7.0.1","@netlify/skills":"1.7.0","@opentelemetry/sdk-trace-base":"2.9.0","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.295","@anthropic-ai/sdk":"^0.134.0","@google/gemini-cli":"0.63.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.2","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.162.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0","@opentelemetry/otlp-transformer":"0.218.0",execa:"^9.6.1",fastify:"5.12.6",minimist:"^1.2.8",openai:"7.31.0",zod:"^4.4.3"}};var F2t=M2t(import.meta.url),j2t=Pl.dirname(F2t),z2t=U2t(import.meta.url),EE=he("shell"),D7=new Set,I1e={preferLocal:!0},Ut=(t,e,r)=>{let[n,i]=q2t(e,r),s={...I1e,...i},o=S1e(t,n,s);C1e(o,s),$1e(o);let a=r?.idleTimeout;return a&&a>0&&N1e(o,a),o},P1e=(t,e)=>{let r={...I1e,...e},n=E1e(t,r);return C1e(n,r),$1e(n),e?.idleTimeout&&e.idleTimeout>0&&N1e(n,e.idleTimeout),n},q2t=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},C1e=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||uu.env.NETLIFY_LOCAL_QUIET==="true")return;if(uu.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Tx).pipe(uu.stdout),t.stderr?.pipe(new Tx).pipe(uu.stderr);return}t.stdout?.pipe(uu.stdout),t.stderr?.pipe(uu.stderr)},L7=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(uu.kill(-t.pid,e),EE.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return EE.error("Error killing process:",r),!1}},k1e=t=>L7(t,"SIGKILL"),N1e=(t,e)=>{let r=null,n=()=>{EE.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),L7(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(EE.log(`Force killing idle process ${t.pid}`),k1e(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)},$1e=t=>{D7.add(t);let e=x1e();if(e){let r=e.onTimesUp(()=>{EE.log(`Global timer expired, killing process ${t.pid}`),L7(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(EE.log(`Force killing process ${t.pid} after timeout`),k1e(t))},5e3)});t.on("exit",()=>{D7.delete(t),r()}),t.on("error",()=>{D7.delete(t),r()})}};function lu(t,e){if(!uu.env.NETLIFY_LOCAL_MODE)try{let i=z2t.resolve(O1e.name),s=Pl.dirname(i);for(;s!==Pl.dirname(s);){let o=Pl.dirname(s);if(Pl.basename(o)==="node_modules"){let a=Pl.join(o,".bin",e);if(RU.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(uu.env.NODE_PATH){let i=Pl.join(uu.env.NODE_PATH,".bin",e);if(RU.existsSync(i))return i}let r=Pl.join(t,"node_modules",".bin",e);if(RU.existsSync(r))return r;let n=Pl.join(j2t,"..","node_modules",".bin",e);if(RU.existsSync(n))return n}import Oq from"process";import{fileURLToPath as iXt}from"url";import{createRequire as sXt}from"module";import AI from"path";import{readFileSync as oXt}from"fs";var B2t="__netlify__getTracer",V2t="__netlify__shutdownTracers",$t=(t,e)=>globalThis[B2t]?.(t,e),D1e=async()=>globalThis[V2t]?.();function Rx(t,e,r,n,i){let s=typeof n=="function"?n:typeof r=="function"?r:i;if(!s)throw new Error("function to execute with active span is missing");return t?t.withActiveSpan(e,r,n,s):s()}import{setTimeout as YZt}from"timers/promises";Ue();import UHt from"process";Ue();var H2t=(t,e)=>{e.recordException(t),e.setStatus({code:qn.ERROR})};var Cl=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}=L1e(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>M1e(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=L1e(r,n,i),c=this._tracer.startSpan(e,s,o);return M1e(c,s,a)}};function L1e(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??lr.active(),{opts:n,ctx:i,fn:s}}function M1e(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:H2t,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)}}Ue();var bE=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var U7=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=W1e(e),n._asyncAttributesPending=e.filter(([i,s])=>bE(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(bE(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=W1e(this._rawAttributes),this._schemaUrl=G2t(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,bE(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&me.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(bE(n)){me.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=W2t(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function F7(t,e){return U7.FromAttributeList(Object.entries(t),e)}function W1e(t){return t.map(([e,r])=>bE(r)?[e,r.catch(n=>{me.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function G2t(t){if(typeof t=="string"||t===void 0)return t;me.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function W2t(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;me.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}Ue();var xx=class{emit(e){}enabled(){return!1}},K1e=new xx;var Ox=Symbol.for("io.opentelemetry.js.api.logs"),wE=globalThis;function Y1e(t,e,r){return n=>n===t?e:r}var j7=1;var z7=class{getLogger(e,r,n){return new xx}},IU=new z7;var PU=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):K1e}};var Ix=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new PU(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:IU}_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 CU=class t{constructor(){this._proxyLoggerProvider=new Ix}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return wE[Ox]?this.getLoggerProvider():(wE[Ox]=Y1e(j7,e,IU),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=wE[Ox])===null||e===void 0?void 0:e.call(wE,j7))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete wE[Ox],this._proxyLoggerProvider=new Ix}};var J1e=CU.getInstance();function Z1e(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 X1e(t){t.forEach(e=>e.disable())}function q7(t){let e=t.tracerProvider||Wt.getTracerProvider(),r=t.meterProvider||xR.getMeterProvider(),n=t.loggerProvider||J1e.getLoggerProvider(),i=t.instrumentations?.flat()??[];return Z1e(i,e,r,n),()=>{X1e(i)}}Ue();var K2t=zn("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function Q1e(t){return t.getValue(K2t)===!0}var TE;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(TE||(TE={}));Ue();var B7="[_0-9a-z-*/]",Y2t=`[a-z]${B7}{0,255}`,J2t=`[a-z0-9]${B7}{0,240}@[a-z]${B7}{0,13}`,Z2t=new RegExp(`^(?:${Y2t}|${J2t})$`),X2t=/^[ -~]{0,255}[!-~]$/,Q2t=/,|=/;function V7(t){return Z2t.test(t)}function H7(t){return X2t.test(t)&&!Q2t.test(t)}var eVt=32,eUe=512,tUe=",",rUe="=",kU=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!V7(e)||!H7(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>eUe)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=tUe+e),e=`${n[0]}${rUe}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(tUe),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(rUe);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!V7(a)||!H7(c))continue;let u=n+s.length+(r.size>0?1:0);if(!(u>eUe)&&(r.set(a,c),n=u,r.size>=eVt))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 NU="traceparent",$U="tracestate",tVt="00",rVt="(?!ff)[\\da-f]{2}",nVt="(?![0]{32})[\\da-f]{32}",iVt="(?![0]{16})[\\da-f]{16}",sVt="[\\da-f]{2}",oVt=new RegExp(`^\\s?(${rVt})-(${nVt})-(${iVt})-(${sVt})(-.*)?\\s?$`);function nUe(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 Lf=class{inject(e,r,n){let i=Wt.getSpanContext(e);if(!i||Q1e(e)||!ws(i))return;let s=`${tVt}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||zr.NONE).toString(16)}`;n.set(r,NU,s),i.traceState&&n.set(r,$U,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,NU);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=nUe(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,$U);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new kU(typeof c=="string"?c:void 0)}return Wt.setSpanContext(e,o)}fields(){return[NU,$U]}};var DU=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 Px=class{_isCalled=!1;_deferred=new DU;_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 OF=En(Nee(),1);Ue();var tze=t=>{throw TypeError(t)},Mee=(t,e,r)=>e.has(t)||tze("Cannot "+r),xF=(t,e,r)=>(Mee(t,e,"read from private field"),r?r.call(t):e.get(t)),$ee=(t,e,r)=>e.has(t)?tze("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),Xje=(t,e,r,n)=>(Mee(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),MHt=(t,e,r)=>(Mee(t,e,"access private method"),r),Qje="__netlify__getTracer",FHt="__netlify__shutdownTracers",jHt="__nfOTLPTrace",Yx,Jx,Lee,rze,zHt=class{constructor(){$ee(this,Lee),$ee(this,Yx),$ee(this,Jx),Xje(this,Yx,new Px(MHt(this,Lee,rze),this)),Xje(this,Jx,me.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(xF(this,Jx).debug(`export ${t.length.toString()} spans`),xF(this,Yx).isCalled){e({code:TE.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(jHt,JSON.stringify(qHt(t))),e({code:TE.SUCCESS})}shutdown(){return xF(this,Yx).call()}};Yx=new WeakMap;Jx=new WeakMap;Lee=new WeakSet;rze=function(){return xF(this,Jx).debug("Shutting down"),Promise.resolve()};function qHt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:RF(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||qa.SERVER,startTimeUnixNano:Dee(e.startTime),endTimeUnixNano:Dee(e.endTime),attributes:RF(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:Dee(n.time),attributes:RF(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:RF(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function RF(t){return Object.keys(t).map(e=>nze(e,t[e]))}function nze(t,e){return{key:t,value:ize(e)}}function ize(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(ize)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>nze(r,n))}}:{}}function Dee(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var eze={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"}},sze=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,Qje))return;let e=UHt.version.slice(1),r=F7({"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??[BHt()],i=new OF.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new Lf});let s=t.instrumentations??[];q7({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,Qje,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new Cl(Wt.getTracer(a,c)):new Cl(Wt.getTracer(eze.name,eze.version))}}),Object.defineProperty(globalThis,FHt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},BHt=()=>new OF.SimpleSpanProcessor(new zHt);Ue();var LE=En(Nee(),1);Ue();import*as IF from"diagnostics_channel";var oze=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?qn.ERROR:qn.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 Cl?t:new Cl(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){IF.subscribe(t,e);let r=()=>IF.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:qa.CLIENT},lr.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:qn.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 K6e=En(V6e(),1);kse();var H6e=0;var WZt=3*1024*1024,KZt=t=>SI.serializeRequest([t])?.byteLength??Number.POSITIVE_INFINITY,Rq=class{constructor(e,r=WZt){this.inner=e;this.maxBytes=r}export(e,r){let n=[],i=[],s=0;for(let c of e){let u=KZt(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:H6e});return}this.inner.export(n[c],u=>{u.code!==H6e&&(o??=u),a(c+1)})};a(0)}shutdown(){return this.inner.shutdown()}forceFlush(){return this.inner.forceFlush?.()??Promise.resolve()}};var Lv=he("tracing"),G6e=8e3,JZt=5e3,W6e=t=>t.length>G6e?`${t.slice(0,G6e)}\u2026`:t,bI={maxQueueSize:20480,maxExportBatchSize:128,scheduledDelayMillis:1e3},ZZt=Math.ceil(bI.maxQueueSize/bI.maxExportBatchSize)+1,XZt=t=>new LE.BatchSpanProcessor(new Rq(new K6e.OTLPTraceExporter({url:t,concurrencyLimit:ZZt})),bI),yg=async(t=JZt)=>{try{let e=Symbol("timed out");await Promise.race([D1e(),YZt(t,e)])===e&&Lv.warn(`Tracer flush did not finish in ${t} ms; unsent spans are lost`)}catch(e){Lv.warn("Failed to flush tracers on shutdown",e)}},Y6e=async(t,e,r)=>{if(!$t()){let n=[new LE.SimpleSpanProcessor(new $se),XZt(r.exporterUrl)];await sze({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new oze({skipHeaders:!0})]})}return r.traceparent?(Ji.setGlobalPropagator(new Lf),Ji.extract(lr.active(),{traceparent:r.traceparent,isRemote:!0})):lr.active()};function hr(t,e,r){return Lv.log(`\u23F3 TRACE: ${e} starting...`),Rx(t,e,r)}var $se=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(", ")}]`:"";Lv.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&Lv.log(` \u274C Error: ${e.status.message}`)}};function Dse(){return We().captureLlmContentEnabled}function J6e(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 xq(t,e,r){let n={role:t,parts:[{type:"text",content:Ei(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var QZt=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]);function Z6e(t,e,r,n){if(!t.length)return;let i=$t();if(!i)return;t.length>bI.maxQueueSize&&Lv.warn(`${t.length} step spans exceed the span queue of ${bI.maxQueueSize}; spans may be dropped`);let s=Dse(),o=Math.max(1,(n-r)/t.length);t.forEach((a,c)=>{let u=Math.min(n,r+c*o),l=Math.min(n,u+o),d=a.type==="tool_use"||a.type==="tool_result"||a.category!=null&&QZt.has(a.category)||a.category===ee.AgentMessage&&a.toolCallId!==void 0,f=d?"execute_tool":"chat",p=W6e(a.title||a.type||`step-${a.id??c}`),h=a.category||"unknown",m=d?`${f} ${h}`:f,g=a.message?W6e(a.message):void 0,y=i.startSpan(m,{startTime:u,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":Ei(p),"gen_ai.operation.name":f,...d?{"gen_ai.tool.name":h}:{},"spark.step.id":a.id??-1,...a.type?{"spark.step.type":a.type}:{},...a.category?{"spark.step.category":a.category}:{},...a.groupId?{"spark.step.group_id":a.groupId}:{},...a.parentGroupId?{"spark.step.parent_group_id":a.parentGroupId}:{},...s&&g?d?{"gen_ai.tool.call.result":Ei(g)}:{"gen_ai.output.messages":xq("assistant",g)}:{}}});d&&(a.toolCallId!==void 0&&y.setAttribute("gen_ai.tool.call.id",a.toolCallId),a.toolStatus!==void 0&&y.setAttribute("spark.step.tool_status",a.toolStatus),a.exitCode!==void 0&&y.setAttribute("spark.step.exit_code",a.exitCode),a.toolStatus==="error"&&(y.setAttribute("error.type","tool_error"),y.setStatus({code:qn.ERROR}))),y.end(l)})}import{readdir as eXt,rm as tXt}from"fs/promises";import{join as rXt}from"path";async function X6e(t,e=[]){let n=(await eXt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>tXt(rXt(t,i),{recursive:!0,force:!0})))}var nXt=300,wI=t=>We().budgetCreditThresholds[t.mode]?.[t.runner]??nXt,TI=({mode:t,sessionCreditLimit:e},r)=>t==="create"&&e!=null&&e<=r;var Lse=t=>{let e=wI(t);if(!TI(t,e))return"default";let r=We();return r.createAskFirstEnabled?"ask_first":r.creditWrapUpEnabled?"budget_constrained":"default"},Q6e=t=>{let e=Lse(t),r=wI(t);return{budget_eligible:TI(t,r),budget_constrained:e==="budget_constrained",ask_first:e==="ask_first"}};var aXt=AI.dirname(iXt(import.meta.url)),eWe=sXt(import.meta.url),cXt=AI.resolve(aXt,"scripts/scaffold.js"),uXt="scripts/scaffold.js",lXt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,Mse=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},dXt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),fXt=t=>{let e=Mse(t);return e==="node"||e.endsWith("/node")},lo=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&&dXt(Mse(e[r]));)r+=1;if(r>=e.length||!fXt(e[r]))return!1;let n=e[r+1];return n?Mse(n).includes(uXt):!1},Sg=he("create_stage"),Use="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.",pXt=`${Use}
597
+ if (condition) { yield value; }`)};import{Buffer as Kzt}from"buffer";import{StringDecoder as Yzt}from"string_decoder";var lU=(t,e,r)=>{if(r)return;if(t)return{transform:Jzt.bind(void 0,new TextEncoder)};let n=new Yzt(e);return{transform:Zzt.bind(void 0,n),final:Xzt.bind(void 0,n)}},Jzt=function*(t,e){Kzt.isBuffer(e)?yield Rl(e):typeof e=="string"?yield t.encode(e):yield e},Zzt=function*(t,e){yield xn(e)?t.write(e):e},Xzt=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as WLe}from"util";var ZQ=WLe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),dU=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=eqt}=e[r];for await(let i of n(t))yield*dU(i,e,r+1)},KLe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Qzt(r,Number(e),t)},Qzt=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*dU(n,r,e+1)},YLe=WLe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),eqt=function*(t){yield t};var XQ=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},JLe=(t,e)=>[...e.flatMap(r=>[...Dm(r,t,0)]),...yx(t)],Dm=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=rqt}=e[r];for(let i of n(t))yield*Dm(i,e,r+1)},yx=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*tqt(r,Number(e),t)},tqt=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Dm(n,r,e+1)},rqt=function*(t){yield t};var QQ=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},c=XLe(t,o,s),u=$m(e),l=$m(r),d=u?ZQ.bind(void 0,dU,a):XQ.bind(void 0,Dm),f=u||l?ZQ.bind(void 0,KLe,a):XQ.bind(void 0,yx),p=u||l?YLe.bind(void 0,a):void 0;return{stream:new nqt({writableObjectMode:n,writableHighWaterMark:ZLe(n),readableObjectMode:i,readableHighWaterMark:ZLe(i),transform(m,g,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},fU=(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=XLe(o,r,a);t=JLe(c,t)}return t},XLe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let c={};return[{transform:VLe(n,a)},lU(r,o,n),uU(r,s,n,c),{transform:t,final:e},{transform:HLe(i,a)},BLe({binary:r,preserveNewlines:s,readableObjectMode:i,state:c})].filter(Boolean)};var QLe=(t,e)=>{for(let r of iqt(t))sqt(t,r,e)},iqt=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),sqt=(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 ${$f[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>oqt(a,n));r.input=cx(o)},oqt=(t,e)=>{let r=fU(t,e,"utf8",!0);return aqt(r),cx(r)},aqt=t=>{let e=t.find(r=>typeof r!="string"&&!xn(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 dqt,appendFileSync as fqt}from"fs";var pU=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&oE(r,n)&&!ro.has(e)&&cqt(n)&&(t.some(({type:i,value:s})=>i==="native"&&uqt.has(s))||t.every(({type:i})=>Zo.has(i))),cqt=t=>t===1||t===2,uqt=new Set(["pipe","overlapped"]),eMe=async(t,e,r,n)=>{for await(let i of t)lqt(e)||rMe(i,r,n)},tMe=(t,e,r)=>{for(let n of t)rMe(n,e,r)},lqt=t=>t._readableState.pipes.length>0,rMe=(t,e,r)=>{let n=x1(t);iu({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var nMe=({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)=>pqt({result:c,fileDescriptors:t,fdNumber:u,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},pqt=({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=iLe(t,s,d),p=Rl(f),{stdioItems:h,objectMode:m}=e[r],g=hqt([p],h,c,n),{serializedResult:y,finalResult:E=y}=mqt({chunks:g,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});gqt({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&&_qt(y,h,i),S}catch(_){return n.error=_,S}},hqt=(t,e,r,n)=>{try{return fU(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:cx(t)};let o=yNe(t,r);return n[s]?{serializedResult:o,finalResult:JQ(o,!i[s],e)}:{serializedResult:o}},gqt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!pU({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=JQ(t,!1,o);try{tMe(a,e,n)}catch(c){r.error??=c}},_qt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>aU.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?fqt(n,t):(r.add(s),dqt(n,t))}};var iMe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Il(e,r,"all")]:Array.isArray(e)?[Il(t,r,"all"),...e]:xn(t)&&xn(e)?sQ([t,e]):`${t}${e}`};import{once as e7}from"events";var sMe=async(t,e)=>{let[r,n]=await yqt(t);return e.isForcefullyTerminated??=!1,[r,n]},yqt=async t=>{let[e,r]=await Promise.allSettled([e7(t,"spawn"),e7(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?oMe(t):r.value},oMe=async t=>{try{return await e7(t,"exit")}catch{return oMe(t)}},aMe=async t=>{let[e,r]=await t;if(!Sqt(e,r)&&t7(e,r))throw new Ka;return[e,r]},Sqt=(t,e)=>t===void 0&&e===void 0,t7=(t,e)=>t!==0||e!==null;var cMe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=Eqt(t,e,r),o=s?.code==="ETIMEDOUT",a=nLe(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},Eqt=(t,e,r)=>t!==void 0?t:t7(e,r)?new Ka:void 0;var uMe=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=bqt(t,e,r),d=Aqt({file:n,commandArguments:i,options:u,command:s,escapedCommand:o,verboseInfo:c,fileDescriptors:l,startTime:a});return gE(d,c,u)},bqt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=I1(t,e,r),a=wqt(r),{file:c,commandArguments:u,options:l}=Y1(t,e,a);Tqt(l);let d=FLe(l,o);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},wqt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Tqt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&hU("ipcInput"),t&&hU("ipc: true"),r&&hU("detached: true"),n&&hU("cancelSignal")},hU=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},Aqt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let c=Rqt({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}=cMe(c,r),{output:h,error:m=u}=nMe({fileDescriptors:o,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:s}),g=h.map((E,S)=>Il(E,r,S)),y=Il(iMe(h,r),r,"all");return Oqt({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:y,options:r,command:n,escapedCommand:i,startTime:a})},Rqt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{QLe(s,r);let a=xqt(r);return vqt(...J1(t,e,a))}catch(a){return mE({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},xqt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:nU(e)}),Oqt=({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?iU({command:c,escapedCommand:u,stdio:s,all:o,ipcOutput:[],options:a,startTime:l}):_x({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 g2t}from"child_process";import hMe from"process";import{once as r7,on as Iqt}from"events";var lMe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(uE({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:B1(t)}),Pqt({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),Pqt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{F1(e,i);let s=Nf(t,e,r),o=new AbortController;try{return await Promise.race([Cqt(s,n,o),kqt(s,r,o),Nqt(s,r,o)])}catch(a){throw lE(t),a}finally{o.abort(),j1(e,i)}},Cqt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await r7(t,"message",{signal:r});return n}for await(let[n]of Iqt(t,"message",{signal:r}))if(e(n))return n},kqt=async(t,e,{signal:r})=>{await r7(t,"disconnect",{signal:r}),J$e(e)},Nqt=async(t,e,{signal:r})=>{let[n]=await r7(t,"strict:error",{signal:r});throw L1(n,e)};import{once as fMe,on as $qt}from"events";var pMe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>n7({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),n7=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{uE({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:B1(t)}),F1(e,s);let o=Nf(t,e,r),a=new AbortController,c={};return Dqt(t,o,a),Lqt({ipcEmitter:o,isSubprocess:r,controller:a,state:c}),Mqt({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:s})},Dqt=async(t,e,r)=>{try{await fMe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Lqt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await fMe(t,"strict:error",{signal:r.signal});n.error=L1(i,e),r.abort()}catch{}},Mqt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[c]of $qt(r,"message",{signal:s.signal}))dMe(o),yield c}catch{dMe(o)}finally{s.abort(),j1(e,a),n||lE(t),i&&await t}},dMe=({error:t})=>{if(t)throw t};var mMe=(t,{ipc:e})=>{Object.assign(t,_Me(t,!1,e))},gMe=()=>{let t=hMe,e=!0,r=hMe.channel!==void 0;return{..._Me(t,e,r),getCancelSignal:wDe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},_Me=(t,e,r)=>({sendMessage:W1.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:lMe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:pMe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Uqt}from"child_process";import{PassThrough as Fqt,Readable as jqt,Writable as zqt,Duplex as qqt}from"stream";var yMe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{WQ(n);let a=new Uqt;Bqt(a,n),Object.assign(a,{readable:Vqt,writable:Hqt,duplex:Gqt});let c=mE({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),u=Wqt(c,o,i);return{subprocess:a,promise:u}},Bqt=(t,e)=>{let r=Sx(),n=Sx(),i=Sx(),s=Array.from({length:e.length-3},Sx),o=Sx(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},Sx=()=>{let t=new Fqt;return t.end(),t},Vqt=()=>new jqt({read(){}}),Hqt=()=>new zqt({write(){}}),Gqt=()=>new qqt({read(){},write(){}}),Wqt=async(t,e,r)=>gE(t,e,r);import{createReadStream as SMe,createWriteStream as EMe}from"fs";import{Buffer as Kqt}from"buffer";import{Readable as Ex,Writable as Yqt,Duplex as Jqt}from"stream";var bMe=(t,e)=>cU(Zqt,t,e,!1),vx=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${$f[t]}.`)},vMe={fileNumber:vx,generator:QQ,asyncGenerator:QQ,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Jqt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Zqt={input:{...vMe,fileUrl:({value:t})=>({stream:SMe(t)}),filePath:({value:{file:t}})=>({stream:SMe(t)}),webStream:({value:t})=>({stream:Ex.fromWeb(t)}),iterable:({value:t})=>({stream:Ex.from(t)}),asyncIterable:({value:t})=>({stream:Ex.from(t)}),string:({value:t})=>({stream:Ex.from(t)}),uint8Array:({value:t})=>({stream:Ex.from(Kqt.from(t))})},output:{...vMe,fileUrl:({value:t})=>({stream:EMe(t)}),filePath:({value:{file:t,append:e}})=>({stream:EMe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Yqt.fromWeb(t)}),iterable:vx,asyncIterable:vx,string:vx,uint8Array:vx}};import{on as Xqt,once as wMe}from"events";import{PassThrough as Qqt,getDefaultHighWaterMark as eBt}from"stream";import{finished as RMe}from"stream/promises";function Lm(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)s7(i);let e=t.some(({readableObjectMode:i})=>i),r=tBt(t,e),n=new i7({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var tBt=(t,e)=>{if(t.length===0)return eBt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},i7=class extends Qqt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#s=Symbol("unpipe");#i=new WeakMap;add(e){if(s7(e),this.#e.has(e))return;this.#e.add(e),this.#n??=rBt(this,this.#e,this.#s);let r=sBt({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(s7(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)}},rBt=async(t,e,r)=>{mU(t,TMe);let n=new AbortController;try{await Promise.race([nBt(t,n),iBt(t,e,r,n)])}finally{n.abort(),mU(t,-TMe)}},nBt=async(t,{signal:e})=>{try{await RMe(t,{signal:e,cleanup:!0})}catch(r){throw xMe(t,r),r}},iBt=async(t,e,r,{signal:n})=>{for await(let[i]of Xqt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},s7=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},sBt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{mU(t,AMe);let a=new AbortController;try{await Promise.race([oBt(s,e,a),aBt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),cBt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),mU(t,-AMe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?o7(t):uBt(t))},oBt=async(t,e,{signal:r})=>{try{await t,r.aborted||o7(e)}catch(n){r.aborted||xMe(e,n)}},aBt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await RMe(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;OMe(o)?i.add(e):IMe(t,o)}},cBt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await wMe(t,i,{signal:s}),!t.readable)return wMe(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},uBt=t=>{t.writable&&t.end()},xMe=(t,e)=>{OMe(e)?o7(t):IMe(t,e)},OMe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",o7=t=>{(t.readable||t.writable)&&t.destroy()},IMe=(t,e)=>{t.destroyed||(t.once("error",lBt),t.destroy(e))},lBt=()=>{},mU=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},TMe=2,AMe=1;import{finished as PMe}from"stream/promises";var yE=(t,e)=>{t.pipe(e),dBt(t,e),fBt(t,e)},dBt=async(t,e)=>{if(!(Wa(t)||Wa(e))){try{await PMe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}a7(e)}},a7=t=>{t.writable&&t.end()},fBt=async(t,e)=>{if(!(Wa(t)||Wa(e))){try{await PMe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}c7(t)}},c7=t=>{t.readable&&t.destroy()};var CMe=(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})=>Zo.has(c)))pBt(t,a,o,i);for(let{stream:a}of s.filter(({type:c})=>!Zo.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]:Lm(s);yE(o,i)}},pBt=(t,e,r,n)=>{r==="output"?yE(t.stdio[n],e):yE(e,t.stdio[n]);let i=hBt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},hBt=["stdin","stdout","stderr"],mBt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;gBt(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(o)??[];i.set(o,[...c,a])},gBt=(t,{signal:e})=>{Wa(t)&&km(t,_Bt,e)},_Bt=2;import{addAbortListener as EBt}from"events";var Mm=[];Mm.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Mm.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Mm.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var gU=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",u7=Symbol.for("signal-exit emitter"),l7=globalThis,yBt=Object.defineProperty.bind(Object),d7=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(l7[u7])return l7[u7];yBt(l7,u7,{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}},_U=class{},SBt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),f7=class extends _U{onExit(){return()=>{}}load(){}unload(){}},p7=class extends _U{#e=h7.platform==="win32"?"SIGINT":"SIGHUP";#r=new d7;#t;#n;#s;#i={};#o=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Mm)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(!gU(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 Mm)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,Mm.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 gU(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"&&gU(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)}},h7=globalThis.process,{onExit:kMe,load:g2r,unload:_2r}=SBt(gU(h7)?new p7(h7):new f7);var NMe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=kMe(()=>{t.kill()});EBt(n,()=>{i()})};var DMe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=O1(),{destination:o,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=vBt(r,n,i),{sourceStream:d,sourceError:f}=wBt(t,u),{options:p,fileDescriptors:h}=ou.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:s}},vBt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=bBt(t,e,...r),a=U1(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},bBt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e($Me,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||nQ(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]=y1(r,...n);return{destination:e($Me)(i,s,o),pipeOptions:o}}if(ou.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}`)},$Me=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),wBt=(t,e)=>{try{return{sourceStream:dE(t,e)}}catch(r){return{sourceError:r}}};var MMe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=TBt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw m7({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},TBt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return c7(t),n;if(e!==void 0)return a7(r),e},m7=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>mE({error:t,command:LMe,escapedCommand:LMe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),LMe="source.pipe(destination)";var UMe=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 ABt}from"stream/promises";var FMe=(t,e,r)=>{let n=yU.has(e)?xBt(t,e):RBt(t,e);return km(t,IBt,r.signal),km(e,PBt,r.signal),OBt(e),n},RBt=(t,e)=>{let r=Lm([t]);return yE(r,e),yU.set(e,r),r},xBt=(t,e)=>{let r=yU.get(e);return r.add(t),r},OBt=async t=>{try{await ABt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}yU.delete(t)},yU=new WeakMap,IBt=2,PBt=1;import{aborted as CBt}from"util";var jMe=(t,e)=>t===void 0?[]:[kBt(t,e)],kBt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await CBt(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw m7({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var SU=(t,...e)=>{if(Qr(e[0]))return SU.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=DMe(t,...e),i=NBt({...n,destination:r});return i.pipe=SU.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},NBt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=$Bt(t,i);MMe({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=FMe(e,s,d);return await Promise.race([UMe(l),...jMe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},$Bt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as zBt}from"timers/promises";import{on as DBt}from"events";import{getDefaultHighWaterMark as LBt}from"stream";var EU=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return MBt(e,o),qMe({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},MBt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},g7=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;UBt(e,o,t);let a=t.readableObjectMode&&!s;return qMe({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},UBt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},qMe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=DBt(t,"data",{signal:e.signal,highWaterMark:zMe,highWatermark:zMe});return FBt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},_7=LBt(!0),zMe=_7,FBt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=jBt({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[c]of t)yield*Dm(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*yx(a)}},jBt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[lU(t,r,!e),uU(t,i,!n,{})].filter(Boolean);var BMe=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=qBt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([BBt(t),d]);return}let f=KQ(c,r),p=g7({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([VBt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return h},qBt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!pU({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=g7({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await eMe(a,t,r,s)},BBt=async t=>{await zBt(),t.readableFlowing===null&&t.resume()},VBt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await eU(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await tU(r,{maxBuffer:s})):await hE(r,{maxBuffer:s})}catch(a){return VMe(eLe({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},y7=async t=>{try{return await t}catch(e){return VMe(e)}},VMe=({bufferedData:t})=>gNe(t)?new Uint8Array(t):t;import{finished as HBt}from"stream/promises";var bx=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=GBt(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],HBt(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||YBt(a,e,r,n)}finally{o.abort()}},GBt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&WBt(t,r,n),n},WBt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{KBt(e,r),n.call(t,...i)}},KBt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},YBt=(t,e,r,n)=>{if(!JBt(t,e,r,n))throw t},JBt=(t,e,r,n=!0)=>r.propagating?HMe(t)||vU(t):(r.propagating=!0,S7(r,e)===n?HMe(t):vU(t)),S7=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",vU=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",HMe=t=>t?.code==="EPIPE";var GMe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((c,u)=>E7({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),E7=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=bx(t,e,u);if(S7(u,e)){await l;return}let[d]=await Promise.all([BMe({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 WMe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Lm([t,e].filter(Boolean)):void 0,KMe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>E7({...ZBt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:XBt(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),ZBt=({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}},XBt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as QBt}from"events";var YMe=t=>oE(t,"ipc"),JMe=(t,e)=>{let r=x1(t);iu({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var ZMe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=YMe(s),a=xl(e,"ipc"),c=xl(r,"ipc");for await(let u of n7({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(tLe(t,i,c),i.push(u)),o&&JMe(u,s);return i},XMe=async(t,e)=>(await Promise.allSettled([t]),e);var QMe=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=sMe(t,f),S={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:E,propagating:!1},_=GMe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:S}),w=KMe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:S}),b=[],R=ZMe({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:b,verboseInfo:p}),T=e2t(m,t,S),I=t2t(h,S);try{return await Promise.race([Promise.all([{},aMe(E),Promise.all(_),w,R,NDe(t,d),...T,...I]),g,r2t(t,y),...ODe(t,s,f,y),...Y$e({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:y}),...RDe({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(O=>y7(O))),y7(w),XMe(R,b),Promise.allSettled(T),Promise.allSettled(I)])}},e2t=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:bx(n,i,r)),t2t=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>Ja(s,{checkOpen:!1})&&!Wa(s)).map(({type:i,value:s,stream:o=s})=>bx(o,n,e,{isSameDirection:Zo.has(i),stopOnExit:i==="native"}))),r2t=async(t,{signal:e})=>{let[r]=await QBt(t,"error",{signal:e});throw r};var e1e=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),wx=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=su();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},SE=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 n2t}from"stream";import{callbackify as i2t}from"util";import{finished as t1e}from"stream/promises";var v7=async t=>{if(t!==void 0)try{await b7(t)}catch{}},r1e=async t=>{if(t!==void 0)try{await w7(t)}catch{}},b7=async t=>{await t1e(t,{cleanup:!0,readable:!1,writable:!0})},w7=async t=>{await t1e(t,{cleanup:!0,readable:!0,writable:!1})},bU=async(t,e)=>{if(await t,e)throw e},wU=(t,e,r)=>{r&&!vU(r)?t.destroy(r):e&&t.destroy()};var n1e=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||ro.has(r),{subprocessStdout:a,waitReadableDestroy:c}=T7(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=A7(a,o),{read:f,onStdoutDataDone:p}=R7({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),h=new n2t({read:f,destroy:i2t(O7.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return x7({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},T7=(t,e,r)=>{let n=dE(t,e),i=wx(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},A7=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:_7},R7=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=su(),o=EU({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){s2t(this,o,s)},onStdoutDataDone:s}},s2t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},x7=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await w7(t),await n,await v7(i),await e,r.readable&&r.push(null)}catch(s){await v7(i),i1e(r,s)}},O7=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await SE(r,e)&&(i1e(t,n),await bU(e,n))},i1e=(t,e)=>{wU(t,t.readable,e)};import{Writable as o2t}from"stream";import{callbackify as s1e}from"util";var o1e=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=I7(t,r,e),o=new o2t({...P7(n,t,i),destroy:s1e(k7.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return C7(n,o),o},I7=(t,e,r)=>{let n=U1(t,e),i=wx(r,n,"writableFinal"),s=wx(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},P7=(t,e,r)=>({write:a2t.bind(void 0,t),final:s1e(c2t.bind(void 0,t,e,r))}),a2t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},c2t=async(t,e,r)=>{await SE(r,e)&&(t.writable&&t.end(),await e)},C7=async(t,e,r)=>{try{await b7(t),e.writable&&e.end()}catch(n){await r1e(r),a1e(e,n)}},k7=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await SE(r,e),await SE(n,e)&&(a1e(t,i),await bU(e,i))},a1e=(t,e)=>{wU(t,t.writable,e)};import{Duplex as u2t}from"stream";import{callbackify as l2t}from"util";var c1e=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||ro.has(r),{subprocessStdout:c,waitReadableDestroy:u}=T7(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=I7(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=A7(c,a),{read:g,onStdoutDataDone:y}=R7({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),E=new u2t({read:g,...P7(l,t,d),destroy:l2t(d2t.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 x7({subprocessStdout:c,onStdoutDataDone:y,readable:E,subprocess:t,subprocessStdin:l}),C7(l,E,c),E},d2t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([O7({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),k7({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var N7=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||ro.has(e),o=dE(t,r),a=EU({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return f2t(a,o,t)},f2t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var u1e=(t,{encoding:e})=>{let r=e1e();t.readable=n1e.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=o1e.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=c1e.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=N7.bind(void 0,t,e),t[Symbol.asyncIterator]=N7.bind(void 0,t,e,{})};var l1e=(t,e)=>{for(let[r,n]of h2t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},p2t=(async()=>{})().constructor.prototype,h2t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(p2t,t)]);var d1e=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=_2t(t,e,r),{subprocess:f,promise:p}=S2t({file:i,commandArguments:s,options:l,startTime:c,verboseInfo:u,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=SU.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),l1e(f,p),ou.set(f,{options:l,fileDescriptors:d}),f},_2t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=I1(t,e,r),{file:a,commandArguments:c,options:u}=Y1(t,e,r),l=y2t(u),d=bMe(l,o);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:l,fileDescriptors:d}},y2t=({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}},S2t=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let c;try{c=g2t(...J1(t,e,r))}catch(h){return yMe({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];CMe(c,a,u),NMe(c,r,u);let d={},f=su();c.kill=W$e.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=WMe(c,r),u1e(c,r),mMe(c,r);let p=E2t({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}},E2t=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 QMe({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)=>Il(_,e,w)),E=Il(m,e,"all"),S=v2t({errorInfo:d,exitCode:f,signal:p,stdio:y,all:E,ipcOutput:g,context:c,options:e,command:o,escapedCommand:a,startTime:r});return gE(S,n,e)},v2t=({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?_x({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 au,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:l,isSync:!1}):iU({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:s,options:a,startTime:l});var TU=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,b2t(n,t[n],i)]));return{...t,...r}},b2t=(t,e,r)=>w2t.has(t)&&Qr(e)&&Qr(r)?{...e,...r}:r,w2t=new Set(["env",...uQ]);var Df=(t,e,r,n)=>{let i=(o,a,c)=>Df(o,a,r,c),s=(...o)=>T2t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},T2t=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(Qr(s))return i(t,TU(r,s),n);let{file:a,commandArguments:c,options:u,isSync:l}=A2t({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return l?uMe(a,c,u):d1e(a,c,u,i)},A2t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=bNe(e)?wNe(e,r):[e,...r],[o,a,c]=y1(...s),u=TU(TU(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 f1e=({file:t,commandArguments:e})=>h1e(t,e),p1e=({file:t,commandArguments:e})=>({...h1e(t,e),isSync:!0}),h1e=(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]=R2t(t);return{file:r,commandArguments:n}},R2t=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(x2t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},x2t=/ +/g;var m1e=(t,e,r)=>{t.sync=e(O2t,r),t.s=t.sync},g1e=({options:t})=>_1e(t),O2t=({options:t})=>({..._1e(t),isSync:!0}),_1e=t=>({options:{...I2t(t),...t}}),I2t=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},y1e={preferLocal:!0};var S1e=Df(()=>({})),o4r=Df(()=>({isSync:!0})),E1e=Df(f1e),a4r=Df(p1e),c4r=Df(PDe),u4r=Df(g1e,{},y1e,m1e),{sendMessage:l4r,getOneMessage:d4r,getEachMessage:f4r,getCancelSignal:p4r}=gMe();import{Transform as P2t}from"stream";var C2t=["NETLIFY_AI_GATEWAY_KEY","NETLIFY_API_TOKEN","NETLIFY_AUTH_TOKEN"];function k2t(){let t=(process.env.NETLIFY_SENSITIVE_ENV_KEYS||"").split(",").map(e=>e.trim()).filter(Boolean);return[...new Set([...t,...C2t])]}function N2t(t){let e=t.toLowerCase();return e==="true"||e==="false"?!0:t.trim().length<4}function $2t(){let e=k2t().map(r=>process.env[r]).filter(r=>!(!r||N2t(r)));return[...new Set(e)].sort((r,n)=>n.length-r.length)}function Ei(t){if(typeof t!="string")return t;let e=$2t();if(e.length===0)return t;let r=t;return e.forEach(n=>{let i=new RegExp(D2t(n),"g");r=r.replace(i,"******")}),r}function D2t(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Tx=class extends P2t{constructor(e={}){super({...e,objectMode:!1})}_transform(e,r,n){let i=e.toString(),s=Ei(i);n(null,s)}},AU=Symbol("maskedWrite");function v1e(){if(process.env.NETLIFY_MASK_LOGS!=="false"){if(!process.stdout.write[AU]){let e=process.stdout.write.bind(process.stdout),r=function(n,i,s){let o=typeof n=="string"?Ei(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[AU]=!0,process.stdout.write=r}if(!process.stderr.write[AU]){let e=process.stderr.write.bind(process.stderr),r=function(n,i,s){let o=typeof n=="string"?Ei(n):n;return typeof i=="function"?e(o,i):e(o,i,s)};r[AU]=!0,process.stderr.write=r}}}var b1e=!1,w1e,$7=t=>{w1e??=t},T1e=t=>{b1e=!0,$7(t)},en=()=>b1e,Xo=()=>w1e,A1e=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var Ax=null,R1e=t=>(Ax&&Ax.destroy(),Ax=new Qo({totalAllowedTime:t}),Ax),x1e=()=>Ax;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&&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 vD({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 O1e={name:"@netlify/agent-runner-cli",type:"module",version:"2.12.0-nb987b7e96221d.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 F2t=M2t(import.meta.url),j2t=Pl.dirname(F2t),z2t=U2t(import.meta.url),EE=he("shell"),D7=new Set,I1e={preferLocal:!0},Ut=(t,e,r)=>{let[n,i]=q2t(e,r),s={...I1e,...i},o=S1e(t,n,s);C1e(o,s),$1e(o);let a=r?.idleTimeout;return a&&a>0&&N1e(o,a),o},P1e=(t,e)=>{let r={...I1e,...e},n=E1e(t,r);return C1e(n,r),$1e(n),e?.idleTimeout&&e.idleTimeout>0&&N1e(n,e.idleTimeout),n},q2t=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},C1e=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||uu.env.NETLIFY_LOCAL_QUIET==="true")return;if(uu.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Tx).pipe(uu.stdout),t.stderr?.pipe(new Tx).pipe(uu.stderr);return}t.stdout?.pipe(uu.stdout),t.stderr?.pipe(uu.stderr)},L7=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(uu.kill(-t.pid,e),EE.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return EE.error("Error killing process:",r),!1}},k1e=t=>L7(t,"SIGKILL"),N1e=(t,e)=>{let r=null,n=()=>{EE.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),L7(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(EE.log(`Force killing idle process ${t.pid}`),k1e(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)},$1e=t=>{D7.add(t);let e=x1e();if(e){let r=e.onTimesUp(()=>{EE.log(`Global timer expired, killing process ${t.pid}`),L7(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(EE.log(`Force killing process ${t.pid} after timeout`),k1e(t))},5e3)});t.on("exit",()=>{D7.delete(t),r()}),t.on("error",()=>{D7.delete(t),r()})}};function lu(t,e){if(!uu.env.NETLIFY_LOCAL_MODE)try{let i=z2t.resolve(O1e.name),s=Pl.dirname(i);for(;s!==Pl.dirname(s);){let o=Pl.dirname(s);if(Pl.basename(o)==="node_modules"){let a=Pl.join(o,".bin",e);if(RU.existsSync(a))return a;break}s=o}}catch(i){console.error("Could not resolve package.json",i)}if(uu.env.NODE_PATH){let i=Pl.join(uu.env.NODE_PATH,".bin",e);if(RU.existsSync(i))return i}let r=Pl.join(t,"node_modules",".bin",e);if(RU.existsSync(r))return r;let n=Pl.join(j2t,"..","node_modules",".bin",e);if(RU.existsSync(n))return n}import Oq from"process";import{fileURLToPath as iXt}from"url";import{createRequire as sXt}from"module";import AI from"path";import{readFileSync as oXt}from"fs";var B2t="__netlify__getTracer",V2t="__netlify__shutdownTracers",$t=(t,e)=>globalThis[B2t]?.(t,e),D1e=async()=>globalThis[V2t]?.();function Rx(t,e,r,n,i){let s=typeof n=="function"?n:typeof r=="function"?r:i;if(!s)throw new Error("function to execute with active span is missing");return t?t.withActiveSpan(e,r,n,s):s()}import{setTimeout as YZt}from"timers/promises";Ue();import UHt from"process";Ue();var H2t=(t,e)=>{e.recordException(t),e.setStatus({code:qn.ERROR})};var Cl=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}=L1e(r,n,i);return this._tracer.startActiveSpan(e,s,o,c=>M1e(c,s,a))}withSpan(e,r,n,i){let{opts:s,ctx:o,fn:a}=L1e(r,n,i),c=this._tracer.startSpan(e,s,o);return M1e(c,s,a)}};function L1e(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??lr.active(),{opts:n,ctx:i,fn:s}}function M1e(t,e,r){var n;let i=(n=e.onException)!==null&&n!==void 0?n:H2t,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)}}Ue();var bE=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var U7=class t{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=W1e(e),n._asyncAttributesPending=e.filter(([i,s])=>bE(s)).length>0,n}constructor(e,r){let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([i,s])=>(bE(s)&&(this._asyncAttributesPending=!0),[i,s])),this._rawAttributes=W1e(this._rawAttributes),this._schemaUrl=G2t(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,bE(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&me.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(bE(n)){me.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=W2t(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function F7(t,e){return U7.FromAttributeList(Object.entries(t),e)}function W1e(t){return t.map(([e,r])=>bE(r)?[e,r.catch(n=>{me.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function G2t(t){if(typeof t=="string"||t===void 0)return t;me.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function W2t(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;me.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}Ue();var xx=class{emit(e){}enabled(){return!1}},K1e=new xx;var Ox=Symbol.for("io.opentelemetry.js.api.logs"),wE=globalThis;function Y1e(t,e,r){return n=>n===t?e:r}var j7=1;var z7=class{getLogger(e,r,n){return new xx}},IU=new z7;var PU=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):K1e}};var Ix=class{getLogger(e,r,n){var i;return(i=this._getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new PU(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:IU}_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 CU=class t{constructor(){this._proxyLoggerProvider=new Ix}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return wE[Ox]?this.getLoggerProvider():(wE[Ox]=Y1e(j7,e,IU),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=wE[Ox])===null||e===void 0?void 0:e.call(wE,j7))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete wE[Ox],this._proxyLoggerProvider=new Ix}};var J1e=CU.getInstance();function Z1e(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 X1e(t){t.forEach(e=>e.disable())}function q7(t){let e=t.tracerProvider||Wt.getTracerProvider(),r=t.meterProvider||xR.getMeterProvider(),n=t.loggerProvider||J1e.getLoggerProvider(),i=t.instrumentations?.flat()??[];return Z1e(i,e,r,n),()=>{X1e(i)}}Ue();var K2t=zn("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function Q1e(t){return t.getValue(K2t)===!0}var TE;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(TE||(TE={}));Ue();var B7="[_0-9a-z-*/]",Y2t=`[a-z]${B7}{0,255}`,J2t=`[a-z0-9]${B7}{0,240}@[a-z]${B7}{0,13}`,Z2t=new RegExp(`^(?:${Y2t}|${J2t})$`),X2t=/^[ -~]{0,255}[!-~]$/,Q2t=/,|=/;function V7(t){return Z2t.test(t)}function H7(t){return X2t.test(t)&&!Q2t.test(t)}var eVt=32,eUe=512,tUe=",",rUe="=",kU=class t{_length;_rawTraceState;_internalState;constructor(e){this._rawTraceState=typeof e=="string"?e:"",this._length=this._rawTraceState.length}set(e,r){if(!V7(e)||!H7(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>eUe)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=tUe+e),e=`${n[0]}${rUe}${n[1]}`+e,r++;return e}_getState(){if(this._internalState)return this._internalState;let e=this._rawTraceState.split(tUe),r=new Map,n=0;for(let i of e){let s=i.trim(),o=s.indexOf(rUe);if(o===-1)continue;let a=s.slice(0,o),c=s.slice(o+1);if(!V7(a)||!H7(c))continue;let u=n+s.length+(r.size>0?1:0);if(!(u>eUe)&&(r.set(a,c),n=u,r.size>=eVt))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 NU="traceparent",$U="tracestate",tVt="00",rVt="(?!ff)[\\da-f]{2}",nVt="(?![0]{32})[\\da-f]{32}",iVt="(?![0]{16})[\\da-f]{16}",sVt="[\\da-f]{2}",oVt=new RegExp(`^\\s?(${rVt})-(${nVt})-(${iVt})-(${sVt})(-.*)?\\s?$`);function nUe(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 Lf=class{inject(e,r,n){let i=Wt.getSpanContext(e);if(!i||Q1e(e)||!ws(i))return;let s=`${tVt}-${i.traceId}-${i.spanId}-0${Number(i.traceFlags||zr.NONE).toString(16)}`;n.set(r,NU,s),i.traceState&&n.set(r,$U,i.traceState.serialize())}extract(e,r,n){let i=n.get(r,NU);if(!i)return e;let s=Array.isArray(i)?i[0]:i;if(typeof s!="string")return e;let o=nUe(s);if(!o)return e;o.isRemote=!0;let a=n.get(r,$U);if(a){let c=Array.isArray(a)?a.join(","):a;o.traceState=new kU(typeof c=="string"?c:void 0)}return Wt.setSpanContext(e,o)}fields(){return[NU,$U]}};var DU=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 Px=class{_isCalled=!1;_deferred=new DU;_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 OF=En(Nee(),1);Ue();var tze=t=>{throw TypeError(t)},Mee=(t,e,r)=>e.has(t)||tze("Cannot "+r),xF=(t,e,r)=>(Mee(t,e,"read from private field"),r?r.call(t):e.get(t)),$ee=(t,e,r)=>e.has(t)?tze("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),Xje=(t,e,r,n)=>(Mee(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),MHt=(t,e,r)=>(Mee(t,e,"access private method"),r),Qje="__netlify__getTracer",FHt="__netlify__shutdownTracers",jHt="__nfOTLPTrace",Yx,Jx,Lee,rze,zHt=class{constructor(){$ee(this,Lee),$ee(this,Yx),$ee(this,Jx),Xje(this,Yx,new Px(MHt(this,Lee,rze),this)),Xje(this,Jx,me.createComponentLogger({namespace:"netlify-span-exporter"}))}export(t,e){if(xF(this,Jx).debug(`export ${t.length.toString()} spans`),xF(this,Yx).isCalled){e({code:TE.FAILED,error:new Error("Exporter has been shutdown")});return}console.log(jHt,JSON.stringify(qHt(t))),e({code:TE.SUCCESS})}shutdown(){return xF(this,Yx).call()}};Yx=new WeakMap;Jx=new WeakMap;Lee=new WeakSet;rze=function(){return xF(this,Jx).debug("Shutting down"),Promise.resolve()};function qHt(t){return{resourceSpans:t.map(e=>{let r=e.spanContext();return{resource:{attributes:RF(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||qa.SERVER,startTimeUnixNano:Dee(e.startTime),endTimeUnixNano:Dee(e.endTime),attributes:RF(e.attributes),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(n=>({name:n.name,timeUnixNano:Dee(n.time),attributes:RF(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:RF(n.attributes??{}),droppedAttributesCount:n.droppedAttributesCount??0})),droppedLinksCount:e.droppedLinksCount}]}]}})}}function RF(t){return Object.keys(t).map(e=>nze(e,t[e]))}function nze(t,e){return{key:t,value:ize(e)}}function ize(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(ize)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>nze(r,n))}}:{}}function Dee(t){let e=BigInt(1e9);return(BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))).toString()}var eze={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"}},sze=t=>{if(Object.prototype.hasOwnProperty.call(globalThis,Qje))return;let e=UHt.version.slice(1),r=F7({"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??[BHt()],i=new OF.NodeTracerProvider({resource:r,spanProcessors:n});i.register({propagator:new Lf});let s=t.instrumentations??[];q7({instrumentations:s,tracerProvider:i}),Object.defineProperty(globalThis,Qje,{enumerable:!1,configurable:!0,writable:!1,value:function(a,c){return a?new Cl(Wt.getTracer(a,c)):new Cl(Wt.getTracer(eze.name,eze.version))}}),Object.defineProperty(globalThis,FHt,{enumerable:!1,configurable:!0,writable:!1,value:async()=>await i.shutdown()})},BHt=()=>new OF.SimpleSpanProcessor(new zHt);Ue();var LE=En(Nee(),1);Ue();import*as IF from"diagnostics_channel";var oze=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?qn.ERROR:qn.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 Cl?t:new Cl(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){IF.subscribe(t,e);let r=()=>IF.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:qa.CLIENT},lr.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:qn.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 K6e=En(V6e(),1);kse();var H6e=0;var WZt=3*1024*1024,KZt=t=>SI.serializeRequest([t])?.byteLength??Number.POSITIVE_INFINITY,Rq=class{constructor(e,r=WZt){this.inner=e;this.maxBytes=r}export(e,r){let n=[],i=[],s=0;for(let c of e){let u=KZt(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:H6e});return}this.inner.export(n[c],u=>{u.code!==H6e&&(o??=u),a(c+1)})};a(0)}shutdown(){return this.inner.shutdown()}forceFlush(){return this.inner.forceFlush?.()??Promise.resolve()}};var Lv=he("tracing"),G6e=8e3,JZt=5e3,W6e=t=>t.length>G6e?`${t.slice(0,G6e)}\u2026`:t,bI={maxQueueSize:20480,maxExportBatchSize:128,scheduledDelayMillis:1e3},ZZt=Math.ceil(bI.maxQueueSize/bI.maxExportBatchSize)+1,XZt=t=>new LE.BatchSpanProcessor(new Rq(new K6e.OTLPTraceExporter({url:t,concurrencyLimit:ZZt})),bI),yg=async(t=JZt)=>{try{let e=Symbol("timed out");await Promise.race([D1e(),YZt(t,e)])===e&&Lv.warn(`Tracer flush did not finish in ${t} ms; unsent spans are lost`)}catch(e){Lv.warn("Failed to flush tracers on shutdown",e)}},Y6e=async(t,e,r)=>{if(!$t()){let n=[new LE.SimpleSpanProcessor(new $se),XZt(r.exporterUrl)];await sze({serviceName:"@netlify/agent-runner-cli",serviceVersion:t,deploymentEnvironment:"production",siteUrl:"",siteId:process.env.SITE_ID??"",siteName:e,spanProcessors:n,instrumentations:[new oze({skipHeaders:!0})]})}return r.traceparent?(Ji.setGlobalPropagator(new Lf),Ji.extract(lr.active(),{traceparent:r.traceparent,isRemote:!0})):lr.active()};function hr(t,e,r){return Lv.log(`\u23F3 TRACE: ${e} starting...`),Rx(t,e,r)}var $se=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(", ")}]`:"";Lv.log(`${s} TRACE: ${e.name} completed in ${r.toFixed(2)}ms${o}`),e.status?.code===2&&e.status.message&&Lv.log(` \u274C Error: ${e.status.message}`)}};function Dse(){return We().captureLlmContentEnabled}function J6e(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 xq(t,e,r){let n={role:t,parts:[{type:"text",content:Ei(e)}]};return r&&(n.finish_reason=r),JSON.stringify([n])}var QZt=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]);function Z6e(t,e,r,n){if(!t.length)return;let i=$t();if(!i)return;t.length>bI.maxQueueSize&&Lv.warn(`${t.length} step spans exceed the span queue of ${bI.maxQueueSize}; spans may be dropped`);let s=Dse(),o=Math.max(1,(n-r)/t.length);t.forEach((a,c)=>{let u=Math.min(n,r+c*o),l=Math.min(n,u+o),d=a.type==="tool_use"||a.type==="tool_result"||a.category!=null&&QZt.has(a.category)||a.category===ee.AgentMessage&&a.toolCallId!==void 0,f=d?"execute_tool":"chat",p=W6e(a.title||a.type||`step-${a.id??c}`),h=a.category||"unknown",m=d?`${f} ${h}`:f,g=a.message?W6e(a.message):void 0,y=i.startSpan(m,{startTime:u,attributes:{"gen_ai.capability.name":e,"gen_ai.step.name":Ei(p),"gen_ai.operation.name":f,...d?{"gen_ai.tool.name":h}:{},"spark.step.id":a.id??-1,...a.type?{"spark.step.type":a.type}:{},...a.category?{"spark.step.category":a.category}:{},...a.groupId?{"spark.step.group_id":a.groupId}:{},...a.parentGroupId?{"spark.step.parent_group_id":a.parentGroupId}:{},...s&&g?d?{"gen_ai.tool.call.result":Ei(g)}:{"gen_ai.output.messages":xq("assistant",g)}:{}}});d&&(a.toolCallId!==void 0&&y.setAttribute("gen_ai.tool.call.id",a.toolCallId),a.toolStatus!==void 0&&y.setAttribute("spark.step.tool_status",a.toolStatus),a.exitCode!==void 0&&y.setAttribute("spark.step.exit_code",a.exitCode),a.toolStatus==="error"&&(y.setAttribute("error.type","tool_error"),y.setStatus({code:qn.ERROR}))),y.end(l)})}import{readdir as eXt,rm as tXt}from"fs/promises";import{join as rXt}from"path";async function X6e(t,e=[]){let n=(await eXt(t)).filter(i=>!e.includes(i));await Promise.all(n.map(i=>tXt(rXt(t,i),{recursive:!0,force:!0})))}var nXt=300,wI=t=>We().budgetCreditThresholds[t.mode]?.[t.runner]??nXt,TI=({mode:t,sessionCreditLimit:e},r)=>t==="create"&&e!=null&&e<=r;var Lse=t=>{let e=wI(t);if(!TI(t,e))return"default";let r=We();return r.createAskFirstEnabled?"ask_first":r.creditWrapUpEnabled?"budget_constrained":"default"},Q6e=t=>{let e=Lse(t),r=wI(t);return{budget_eligible:TI(t,r),budget_constrained:e==="budget_constrained",ask_first:e==="ask_first"}};var aXt=AI.dirname(iXt(import.meta.url)),eWe=sXt(import.meta.url),cXt=AI.resolve(aXt,"scripts/scaffold.js"),uXt="scripts/scaffold.js",lXt=/"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+/g,Mse=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},dXt=t=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t),fXt=t=>{let e=Mse(t);return e==="node"||e.endsWith("/node")},lo=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&&dXt(Mse(e[r]));)r+=1;if(r>=e.length||!fXt(e[r]))return!1;let n=e[r+1];return n?Mse(n).includes(uXt):!1},Sg=he("create_stage"),Use="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.",pXt=`${Use}
598
598
 
599
599
  Commands that generate or modify project files are fine to run when the task requires them \u2014 for example \`drizzle-kit generate\` to write a database migration after a schema change, or other code-generation utilities documented in the skills.`,hXt=`${Use}
600
600
 
@@ -869,6 +869,7 @@ ${r.join(`
869
869
  - 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.
870
870
  - 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.
871
871
  - 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.
872
+ - Complete the task and meet its requirements without using Netlify Database; keep any required data another way.
872
873
  ${Y9e(t)}
873
874
  </rules>`,B2=({skillsDir:t,mode:e,runner:r})=>e==="ask"?Dor(t):J9e(t,r),Z9e=({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
875
  `),X9e=async(t,e)=>{let r=await Dke(e);return r?Mor(Uor(r,e.runner),t):t},Mor=(t,e)=>[t,e].filter(Boolean).join(`
package/dist/index.js CHANGED
@@ -217,6 +217,7 @@ ${b}`,d++;break;case"id":u=b.includes("\0")?void 0:b;break;case"retry":/^\d+$/.t
217
217
  - 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.
218
218
  - 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.
219
219
  - 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.
220
+ - Complete the task and meet its requirements without using Netlify Database; keep any required data another way.
220
221
  ${iwe(t)}
221
222
  </rules>`,TD=({skillsDir:t,mode:e,runner:r})=>e==="ask"?uut(t):owe(t,r),swe=({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
223
  `),awe=async(t,e)=>{let r=await HEe(e);return r?dut(fut(r,e.runner),t):t},dut=(t,e)=>[t,e].filter(Boolean).join(`
@@ -382,7 +383,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
382
383
  `,LF:`
383
384
  `,concatBytes:A5},Lht=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},Uht={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:Lht};import{Buffer as Fht}from"buffer";var YRe=(t,e)=>t?void 0:zht.bind(void 0,e),zht=function*(t,e){if(typeof e!="string"&&!Wr(e)&&!Fht.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},ZRe=(t,e)=>t?jht.bind(void 0,e):Bht.bind(void 0,e),jht=function*(t,e){XRe(t,e),yield e},Bht=function*(t,e){if(XRe(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},XRe=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
384
385
  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 qht}from"buffer";import{StringDecoder as Vht}from"string_decoder";var TM=(t,e,r)=>{if(r)return;if(t)return{transform:Ght.bind(void 0,new TextEncoder)};let n=new Vht(e);return{transform:Hht.bind(void 0,n),final:Wht.bind(void 0,n)}},Ght=function*(t,e){qht.isBuffer(e)?yield gu(e):typeof e=="string"?yield t.encode(e):yield e},Hht=function*(t,e){yield Wr(e)?t.write(e):e},Wht=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as JRe}from"util";var x5=JRe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),AM=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Yht}=e[r];for await(let i of n(t))yield*AM(i,e,r+1)},QRe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Kht(r,Number(e),t)},Kht=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*AM(n,r,e+1)},exe=JRe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),Yht=function*(t){yield t};var I5=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},txe=(t,e)=>[...e.flatMap(r=>[...Xp(r,t,0)]),...eR(t)],Xp=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Xht}=e[r];for(let i of n(t))yield*Xp(i,e,r+1)},eR=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Zht(r,Number(e),t)},Zht=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Xp(n,r,e+1)},Xht=function*(t){yield t};var O5=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=nxe(t,s,o),u=Zp(e),l=Zp(r),d=u?x5.bind(void 0,AM,a):I5.bind(void 0,Xp),f=u||l?x5.bind(void 0,QRe,a):I5.bind(void 0,eR),p=u||l?exe.bind(void 0,a):void 0;return{stream:new Jht({writableObjectMode:n,writableHighWaterMark:rxe(n),readableObjectMode:i,readableHighWaterMark:rxe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},RM=(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=nxe(s,r,a);t=txe(c,t)}return t},nxe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:YRe(n,a)},TM(r,s,n),wM(r,o,n,c),{transform:t,final:e},{transform:ZRe(i,a)},KRe({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var ixe=(t,e)=>{for(let r of Qht(t))emt(t,r,e)},Qht=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),emt=(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 ${cd[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>tmt(a,n));r.input=VA(s)},tmt=(t,e)=>{let r=RM(t,e,"utf8",!0);return rmt(r),VA(r)},rmt=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 smt,appendFileSync as amt}from"fs";var xM=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&fy(r,n)&&!po.has(e)&&nmt(n)&&(t.some(({type:i,value:o})=>i==="native"&&imt.has(o))||t.every(({type:i})=>Zo.has(i))),nmt=t=>t===1||t===2,imt=new Set(["pipe","overlapped"]),oxe=async(t,e,r,n)=>{for await(let i of t)omt(e)||axe(i,r,n)},sxe=(t,e,r)=>{for(let n of t)axe(n,e,r)},omt=t=>t._readableState.pipes.length>0,axe=(t,e,r)=>{let n=jD(t);tc({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var cxe=({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)=>cmt({result:c,fileDescriptors:t,fdNumber:u,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},cmt=({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=uRe(t,o,d),p=gu(f),{stdioItems:h,objectMode:m}=e[r],_=umt([p],h,c,n),{serializedResult:y,finalResult:v=y}=lmt({chunks:_,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});dmt({serializedResult:y,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let A=a[r]?v:void 0;try{return n.error===void 0&&fmt(y,h,i),A}catch(S){return n.error=S,A}},umt=(t,e,r,n)=>{try{return RM(t,e,r,!1)}catch(i){return n.error=i,t}},lmt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:VA(t)};let s=wwe(t,r);return n[o]?{serializedResult:s,finalResult:R5(s,!i[o],e)}:{serializedResult:s}},dmt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!xM({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=R5(t,!1,s);try{sxe(a,e,n)}catch(c){r.error??=c}},fmt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>bM.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?amt(n,t):(r.add(o),smt(n,t))}};var uxe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Su(e,r,"all")]:Array.isArray(e)?[Su(t,r,"all"),...e]:Wr(t)&&Wr(e)?D9([t,e]):`${t}${e}`};import{once as P5}from"events";var lxe=async(t,e)=>{let[r,n]=await pmt(t);return e.isForcefullyTerminated??=!1,[r,n]},pmt=async t=>{let[e,r]=await Promise.allSettled([P5(t,"spawn"),P5(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?dxe(t):r.value},dxe=async t=>{try{return await P5(t,"exit")}catch{return dxe(t)}},fxe=async t=>{let[e,r]=await t;if(!hmt(e,r)&&C5(e,r))throw new oa;return[e,r]},hmt=(t,e)=>t===void 0&&e===void 0,C5=(t,e)=>t!==0||e!==null;var pxe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=mmt(t,e,r),s=o?.code==="ETIMEDOUT",a=cRe(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},mmt=(t,e,r)=>t!==void 0?t:C5(e,r)?new oa:void 0;var hxe=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=_mt(t,e,r),d=vmt({file:n,commandArguments:i,options:u,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:l,startTime:a});return Ey(d,c,u)},_mt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=qD(t,e,r),a=ymt(r),{file:c,commandArguments:u,options:l}=uM(t,e,a);Smt(l);let d=VRe(l,s);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},ymt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Smt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&IM("ipcInput"),t&&IM("ipc: true"),r&&IM("detached: true"),n&&IM("cancelSignal")},IM=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},vmt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=bmt({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}=pxe(c,r),{output:h,error:m=u}=cxe({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),_=h.map((v,A)=>Su(v,r,A)),y=Su(uxe(h,r),r,"all");return wmt({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},bmt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{ixe(o,r);let a=Emt(r);return gmt(...lM(t,e,a))}catch(a){return by({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},Emt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:_M(e)}),wmt=({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?yM({command:c,escapedCommand:u,stdio:o,all:s,ipcOutput:[],options:a,startTime:l}):QA({error:t,command:c,escapedCommand:u,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:l,isSync:!0});import{setMaxListeners as l_t}from"events";import{spawn as d_t}from"child_process";import Sxe from"process";import{once as k5,on as Tmt}from"events";var mxe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(my({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:nM(t)}),Amt({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),Amt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{QD(e,i);let o=ad(t,e,r),s=new AbortController;try{return await Promise.race([Rmt(o,n,s),xmt(o,r,s),Imt(o,r,s)])}catch(a){throw gy(t),a}finally{s.abort(),eM(e,i)}},Rmt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await k5(t,"message",{signal:r});return n}for await(let[n]of Tmt(t,"message",{signal:r}))if(e(n))return n},xmt=async(t,e,{signal:r})=>{await k5(t,"disconnect",{signal:r}),tAe(e)},Imt=async(t,e,{signal:r})=>{let[n]=await k5(t,"strict:error",{signal:r});throw ZD(n,e)};import{once as _xe,on as Omt}from"events";var yxe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>N5({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),N5=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{my({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:nM(t)}),QD(e,o);let s=ad(t,e,r),a=new AbortController,c={};return Pmt(t,s,a),Cmt({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),kmt({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},Pmt=async(t,e,r)=>{try{await _xe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Cmt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await _xe(t,"strict:error",{signal:r.signal});n.error=ZD(i,e),r.abort()}catch{}},kmt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of Omt(r,"message",{signal:o.signal}))gxe(s),yield c}catch{gxe(s)}finally{o.abort(),eM(e,a),n||gy(t),i&&await t}},gxe=({error:t})=>{if(t)throw t};var vxe=(t,{ipc:e})=>{Object.assign(t,Exe(t,!1,e))},bxe=()=>{let t=Sxe,e=!0,r=Sxe.channel!==void 0;return{...Exe(t,e,r),getCancelSignal:IAe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Exe=(t,e,r)=>({sendMessage:aM.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:mxe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:yxe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Nmt}from"child_process";import{PassThrough as $mt,Readable as Dmt,Writable as Mmt,Duplex as Lmt}from"stream";var wxe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{w5(n);let a=new Nmt;Umt(a,n),Object.assign(a,{readable:Fmt,writable:zmt,duplex:jmt});let c=by({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),u=Bmt(c,s,i);return{subprocess:a,promise:u}},Umt=(t,e)=>{let r=tR(),n=tR(),i=tR(),o=Array.from({length:e.length-3},tR),s=tR(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},tR=()=>{let t=new $mt;return t.end(),t},Fmt=()=>new Dmt({read(){}}),zmt=()=>new Mmt({write(){}}),jmt=()=>new Lmt({read(){},write(){}}),Bmt=async(t,e,r)=>Ey(t,e,r);import{createReadStream as Txe,createWriteStream as Axe}from"fs";import{Buffer as qmt}from"buffer";import{Readable as rR,Writable as Vmt,Duplex as Gmt}from"stream";var xxe=(t,e)=>EM(Hmt,t,e,!1),nR=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${cd[t]}.`)},Rxe={fileNumber:nR,generator:O5,asyncGenerator:O5,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Gmt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Hmt={input:{...Rxe,fileUrl:({value:t})=>({stream:Txe(t)}),filePath:({value:{file:t}})=>({stream:Txe(t)}),webStream:({value:t})=>({stream:rR.fromWeb(t)}),iterable:({value:t})=>({stream:rR.from(t)}),asyncIterable:({value:t})=>({stream:rR.from(t)}),string:({value:t})=>({stream:rR.from(t)}),uint8Array:({value:t})=>({stream:rR.from(qmt.from(t))})},output:{...Rxe,fileUrl:({value:t})=>({stream:Axe(t)}),filePath:({value:{file:t,append:e}})=>({stream:Axe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Vmt.fromWeb(t)}),iterable:nR,asyncIterable:nR,string:nR,uint8Array:nR}};import{on as Wmt,once as Ixe}from"events";import{PassThrough as Kmt,getDefaultHighWaterMark as Ymt}from"stream";import{finished as Cxe}from"stream/promises";function Jp(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)D5(i);let e=t.some(({readableObjectMode:i})=>i),r=Zmt(t,e),n=new $5({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Zmt=(t,e)=>{if(t.length===0)return Ymt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},$5=class extends Kmt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(D5(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Xmt(this,this.#e,this.#o);let r=egt({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(D5(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)}},Xmt=async(t,e,r)=>{OM(t,Oxe);let n=new AbortController;try{await Promise.race([Jmt(t,n),Qmt(t,e,r,n)])}finally{n.abort(),OM(t,-Oxe)}},Jmt=async(t,{signal:e})=>{try{await Cxe(t,{signal:e,cleanup:!0})}catch(r){throw kxe(t,r),r}},Qmt=async(t,e,r,{signal:n})=>{for await(let[i]of Wmt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},D5=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},egt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{OM(t,Pxe);let a=new AbortController;try{await Promise.race([tgt(o,e,a),rgt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),ngt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),OM(t,-Pxe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?M5(t):igt(t))},tgt=async(t,e,{signal:r})=>{try{await t,r.aborted||M5(e)}catch(n){r.aborted||kxe(e,n)}},rgt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await Cxe(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;Nxe(s)?i.add(e):$xe(t,s)}},ngt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await Ixe(t,i,{signal:o}),!t.readable)return Ixe(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},igt=t=>{t.writable&&t.end()},kxe=(t,e)=>{Nxe(e)?M5(t):$xe(t,e)},Nxe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",M5=t=>{(t.readable||t.writable)&&t.destroy()},$xe=(t,e)=>{t.destroyed||(t.once("error",ogt),t.destroy(e))},ogt=()=>{},OM=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Oxe=2,Pxe=1;import{finished as Dxe}from"stream/promises";var Ty=(t,e)=>{t.pipe(e),sgt(t,e),agt(t,e)},sgt=async(t,e)=>{if(!(ia(t)||ia(e))){try{await Dxe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}L5(e)}},L5=t=>{t.writable&&t.end()},agt=async(t,e)=>{if(!(ia(t)||ia(e))){try{await Dxe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}U5(t)}},U5=t=>{t.readable&&t.destroy()};var Mxe=(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})=>Zo.has(c)))cgt(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Zo.has(c)))lgt({subprocess:t,stream:a,direction:s,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,o]of n.entries()){let s=o.length===1?o[0]:Jp(o);Ty(s,i)}},cgt=(t,e,r,n)=>{r==="output"?Ty(t.stdio[n],e):Ty(e,t.stdio[n]);let i=ugt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},ugt=["stdin","stdout","stderr"],lgt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;dgt(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},dgt=(t,{signal:e})=>{ia(t)&&Kp(t,fgt,e)},fgt=2;import{addAbortListener as mgt}from"events";var Qp=[];Qp.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Qp.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Qp.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var PM=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",F5=Symbol.for("signal-exit emitter"),z5=globalThis,pgt=Object.defineProperty.bind(Object),j5=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(z5[F5])return z5[F5];pgt(z5,F5,{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}},CM=class{},hgt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),B5=class extends CM{onExit(){return()=>{}}load(){}unload(){}},q5=class extends CM{#e=V5.platform==="win32"?"SIGINT":"SIGHUP";#r=new j5;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Qp)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(!PM(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 Qp)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,Qp.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 PM(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"&&PM(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)}},V5=globalThis.process,{onExit:Lxe,load:wfr,unload:Tfr}=hgt(PM(V5)?new q5(V5):new B5);var Uxe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Lxe(()=>{t.kill()});mgt(n,()=>{i()})};var zxe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=BD(),{destination:s,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=ggt(r,n,i),{sourceStream:d,sourceError:f}=ygt(t,u),{options:p,fileDescriptors:h}=nc.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:o}},ggt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=_gt(t,e,...r),a=JD(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},_gt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Fxe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||N9(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]=kD(r,...n);return{destination:e(Fxe)(i,o,s),pipeOptions:s}}if(nc.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}`)},Fxe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),ygt=(t,e)=>{try{return{sourceStream:_y(t,e)}}catch(r){return{sourceError:r}}};var Bxe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=Sgt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw G5({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},Sgt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return U5(t),n;if(e!==void 0)return L5(r),e},G5=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>by({error:t,command:jxe,escapedCommand:jxe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),jxe="source.pipe(destination)";var qxe=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 vgt}from"stream/promises";var Vxe=(t,e,r)=>{let n=kM.has(e)?Egt(t,e):bgt(t,e);return Kp(t,Tgt,r.signal),Kp(e,Agt,r.signal),wgt(e),n},bgt=(t,e)=>{let r=Jp([t]);return Ty(r,e),kM.set(e,r),r},Egt=(t,e)=>{let r=kM.get(e);return r.add(t),r},wgt=async t=>{try{await vgt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}kM.delete(t)},kM=new WeakMap,Tgt=2,Agt=1;import{aborted as Rgt}from"util";var Gxe=(t,e)=>t===void 0?[]:[xgt(t,e)],xgt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await Rgt(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw G5({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var NM=(t,...e)=>{if(wr(e[0]))return NM.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=zxe(t,...e),i=Igt({...n,destination:r});return i.pipe=NM.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},Igt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=Ogt(t,i);Bxe({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=Vxe(e,o,d);return await Promise.race([qxe(l),...Gxe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},Ogt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as Mgt}from"timers/promises";import{on as Pgt}from"events";import{getDefaultHighWaterMark as Cgt}from"stream";var $M=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return kgt(e,s),Wxe({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},kgt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},H5=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;Ngt(e,s,t);let a=t.readableObjectMode&&!o;return Wxe({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},Ngt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Wxe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=Pgt(t,"data",{signal:e.signal,highWaterMark:Hxe,highWatermark:Hxe});return $gt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},W5=Cgt(!0),Hxe=W5,$gt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=Dgt({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Xp(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*eR(a)}},Dgt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[TM(t,r,!e),wM(t,i,!n,{})].filter(Boolean);var Kxe=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=Lgt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([Ugt(t),d]);return}let f=T5(c,r),p=H5({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([Fgt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},Lgt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!xM({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=H5({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await oxe(a,t,r,o)},Ugt=async t=>{await Mgt(),t.readableFlowing===null&&t.resume()},Fgt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await hM(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await mM(r,{maxBuffer:o})):await vy(r,{maxBuffer:o})}catch(a){return Yxe(oRe({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},K5=async t=>{try{return await t}catch(e){return Yxe(e)}},Yxe=({bufferedData:t})=>bwe(t)?new Uint8Array(t):t;import{finished as zgt}from"stream/promises";var iR=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=jgt(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],zgt(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||Vgt(a,e,r,n)}finally{s.abort()}},jgt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&Bgt(t,r,n),n},Bgt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{qgt(e,r),n.call(t,...i)}},qgt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Vgt=(t,e,r,n)=>{if(!Ggt(t,e,r,n))throw t},Ggt=(t,e,r,n=!0)=>r.propagating?Zxe(t)||DM(t):(r.propagating=!0,Y5(r,e)===n?Zxe(t):DM(t)),Y5=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",DM=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Zxe=t=>t?.code==="EPIPE";var Xxe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,u)=>Z5({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),Z5=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=iR(t,e,u);if(Y5(u,e)){await l;return}let[d]=await Promise.all([Kxe({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 Jxe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Jp([t,e].filter(Boolean)):void 0,Qxe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>Z5({...Hgt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:Wgt(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),Hgt=({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}},Wgt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as Kgt}from"events";var eIe=t=>fy(t,"ipc"),tIe=(t,e)=>{let r=jD(t);tc({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var rIe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=eIe(o),a=_u(e,"ipc"),c=_u(r,"ipc");for await(let u of N5({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(sRe(t,i,c),i.push(u)),s&&tIe(u,o);return i},nIe=async(t,e)=>(await Promise.allSettled([t]),e);var iIe=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=lxe(t,f),A={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},S=Xxe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:A}),E=Qxe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:A}),b=[],I=rIe({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:b,verboseInfo:p}),C=Ygt(m,t,A),P=Zgt(h,A);try{return await Promise.race([Promise.all([{},fxe(v),Promise.all(S),E,I,UAe(t,d),...C,...P]),_,Xgt(t,y),...NAe(t,o,f,y),...eAe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:y}),...CAe({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=>K5(T))),K5(E),nIe(I,b),Promise.allSettled(C),Promise.allSettled(P)])}},Ygt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:iR(n,i,r)),Zgt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>aa(o,{checkOpen:!1})&&!ia(o)).map(({type:i,value:o,stream:s=o})=>iR(s,n,e,{isSameDirection:Zo.has(i),stopOnExit:i==="native"}))),Xgt=async(t,{signal:e})=>{let[r]=await Kgt(t,"error",{signal:e});throw r};var oIe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),oR=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=rc();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Ay=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 Jgt}from"stream";import{callbackify as Qgt}from"util";import{finished as sIe}from"stream/promises";var X5=async t=>{if(t!==void 0)try{await J5(t)}catch{}},aIe=async t=>{if(t!==void 0)try{await Q5(t)}catch{}},J5=async t=>{await sIe(t,{cleanup:!0,readable:!1,writable:!0})},Q5=async t=>{await sIe(t,{cleanup:!0,readable:!0,writable:!1})},MM=async(t,e)=>{if(await t,e)throw e},LM=(t,e,r)=>{r&&!DM(r)?t.destroy(r):e&&t.destroy()};var cIe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||po.has(r),{subprocessStdout:a,waitReadableDestroy:c}=e8(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=t8(a,s),{read:f,onStdoutDataDone:p}=r8({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new Jgt({read:f,destroy:Qgt(i8.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return n8({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},e8=(t,e,r)=>{let n=_y(t,e),i=oR(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},t8=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:W5},r8=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=rc(),s=$M({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){e_t(this,s,o)},onStdoutDataDone:o}},e_t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},n8=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await Q5(t),await n,await X5(i),await e,r.readable&&r.push(null)}catch(o){await X5(i),uIe(r,o)}},i8=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Ay(r,e)&&(uIe(t,n),await MM(e,n))},uIe=(t,e)=>{LM(t,t.readable,e)};import{Writable as t_t}from"stream";import{callbackify as lIe}from"util";var dIe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=o8(t,r,e),s=new t_t({...s8(n,t,i),destroy:lIe(c8.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return a8(n,s),s},o8=(t,e,r)=>{let n=JD(t,e),i=oR(r,n,"writableFinal"),o=oR(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},s8=(t,e,r)=>({write:r_t.bind(void 0,t),final:lIe(n_t.bind(void 0,t,e,r))}),r_t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},n_t=async(t,e,r)=>{await Ay(r,e)&&(t.writable&&t.end(),await e)},a8=async(t,e,r)=>{try{await J5(t),e.writable&&e.end()}catch(n){await aIe(r),fIe(e,n)}},c8=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Ay(r,e),await Ay(n,e)&&(fIe(t,i),await MM(e,i))},fIe=(t,e)=>{LM(t,t.writable,e)};import{Duplex as i_t}from"stream";import{callbackify as o_t}from"util";var pIe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||po.has(r),{subprocessStdout:c,waitReadableDestroy:u}=e8(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=o8(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=t8(c,a),{read:_,onStdoutDataDone:y}=r8({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),v=new i_t({read:_,...s8(l,t,d),destroy:o_t(s_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 n8({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:l}),a8(l,v,c),v},s_t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([i8({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),c8({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var u8=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||po.has(e),s=_y(t,r),a=$M({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return a_t(a,s,t)},a_t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var hIe=(t,{encoding:e})=>{let r=oIe();t.readable=cIe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=dIe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=pIe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=u8.bind(void 0,t,e),t[Symbol.asyncIterator]=u8.bind(void 0,t,e,{})};var mIe=(t,e)=>{for(let[r,n]of u_t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},c_t=(async()=>{})().constructor.prototype,u_t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(c_t,t)]);var gIe=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=f_t(t,e,r),{subprocess:f,promise:p}=h_t({file:i,commandArguments:o,options:l,startTime:c,verboseInfo:u,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=NM.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),mIe(f,p),nc.set(f,{options:l,fileDescriptors:d}),f},f_t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=qD(t,e,r),{file:a,commandArguments:c,options:u}=uM(t,e,r),l=p_t(u),d=xxe(l,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},p_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}},h_t=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=d_t(...lM(t,e,r))}catch(h){return wxe({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;l_t(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];Mxe(c,a,u),Uxe(c,r,u);let d={},f=rc();c.kill=JTe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=Jxe(c,r),hIe(c,r),vxe(c,r);let p=m_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}},m_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 iIe({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)=>Su(S,e,E)),v=Su(m,e,"all"),A=g_t({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Ey(A,n,e)},g_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?QA({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 ic,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:l,isSync:!1}):yM({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:o,options:a,startTime:l});var UM=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,__t(n,t[n],i)]));return{...t,...r}},__t=(t,e,r)=>y_t.has(t)&&wr(e)&&wr(r)?{...e,...r}:r,y_t=new Set(["env",...F9]);var ud=(t,e,r,n)=>{let i=(s,a,c)=>ud(s,a,r,c),o=(...s)=>S_t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},S_t=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(wr(o))return i(t,UM(r,o),n);let{file:a,commandArguments:c,options:u,isSync:l}=v_t({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return l?hxe(a,c,u):gIe(a,c,u,i)},v_t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=xwe(e)?Iwe(e,r):[e,...r],[s,a,c]=kD(...o),u=UM(UM(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 _Ie=({file:t,commandArguments:e})=>SIe(t,e),yIe=({file:t,commandArguments:e})=>({...SIe(t,e),isSync:!0}),SIe=(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]=b_t(t);return{file:r,commandArguments:n}},b_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(E_t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},E_t=/ +/g;var vIe=(t,e,r)=>{t.sync=e(w_t,r),t.s=t.sync},bIe=({options:t})=>EIe(t),w_t=({options:t})=>({...EIe(t),isSync:!0}),EIe=t=>({options:{...T_t(t),...t}}),T_t=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},wIe={preferLocal:!0};var TIe=ud(()=>({})),pmr=ud(()=>({isSync:!0})),AIe=ud(_Ie),hmr=ud(yIe),mmr=ud(DAe),gmr=ud(bIe,{},wIe,vIe),{sendMessage:_mr,getOneMessage:ymr,getEachMessage:Smr,getCancelSignal:vmr}=bxe();var RIe=!1,xIe,A_t=t=>{xIe??=t},IIe=t=>{RIe=!0,A_t(t)},Bn=()=>RIe,vu=()=>xIe,OIe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var sR=null,PIe=t=>(sR&&sR.destroy(),sR=new Xo({totalAllowedTime:t}),sR),CIe=()=>sR;var Xo=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 X0({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.12.0-nb8c571bb6e224.0",description:"CLI tool for running Netlify agents",main:"./dist/index.js",types:"./dist/index.d.ts",exports:"./dist/index.js",bin:{"agent-runner-cli":"./dist/bin.js","agent-runner-cli-local":"./dist/bin-local.js"},files:["dist/**/*.js","dist/**/*.d.ts","dist/skills/**","patches","scripts"],scripts:{prebuild:"rm -rf dist",build:"tsup",dev:"tsup --watch",prepare:"husky install node_modules/@netlify/eslint-config-node/.husky/",prepublishOnly:"npm ci && npm test",prepack:"npm run build",test:"run-s build format test:dev",format:"run-s build format:check-fix:*","format:ci":"run-s build format:check:*","format:check-fix:lint":"run-e format:check:lint format:fix:lint","format:check:lint":'eslint --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:fix:lint":'eslint --fix --cache --format=codeframe --max-warnings=0 "{src,scripts,test,.github}/**/*.{js,ts,md,html}"',"format:check-fix:prettier":"run-e format:check:prettier format:fix:prettier","format:check:prettier":'prettier --check --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md" "!src/lib/__fixtures__/**"',"format:fix:prettier":'prettier --write --ignore-path .gitignore --loglevel=warn "{src,scripts,test,.github}/**/*.{js,ts,md,yml,json,html}" "*.{js,ts,yml,json,html}" ".*.{js,ts,yml,json,html}" "!**/package-lock.json" "!package-lock.json" "!src/skills/**/*.md" "!src/lib/__fixtures__/**"',"test:dev":"run-s build test:dev:*","test:ci":"run-s build test:ci:*","test:dev:vitest":"LOG=0 vitest --exclude '**/integration/**'","test:ci:vitest":"LOG=0 vitest run --coverage --exclude '**/integration/**'","test:smoke":"node scripts/smoke-dist.js","test:integration":"vitest run test/integration/","test:integration:codex":"vitest run test/integration/codex.test.ts","test:integration:claude":"vitest run test/integration/claude.test.ts","test:integration:gemini":"vitest run test/integration/gemini.test.ts","test:integration:opencode":"vitest run test/integration/opencode.test.ts","test:integration:muse":"vitest run test/integration/muse.test.ts","test:integration:skill-invocation":"vitest run test/integration/skill-invocation.test.ts","check:types":"tsc --noEmit",postinstall:"node scripts/postinstall.js"},engines:{node:">=22"},keywords:[],license:"MIT",repository:"netlify/agent-runner-cli",bugs:{url:"https://github.com/netlify/agent-runner-cli/issues"},author:"Netlify Inc.",directories:{test:"test"},devDependencies:{"@commitlint/cli":"^20.0.0","@commitlint/config-conventional":"^20.0.0","@eslint/compat":"^2.0.0","@eslint/js":"^10.0.1","@grpc/grpc-js":"1.14.6","@netlify/axis":"^1.21.0","@netlify/eslint-config-node":"^7.0.1","@netlify/skills":"1.7.0","@opentelemetry/sdk-trace-base":"2.9.0","@types/node":"^24.5.0","@typescript-eslint/eslint-plugin":"^8.0.0","@typescript-eslint/parser":"^8.0.0","@vitest/coverage-v8":"^4.1.5","@vitest/eslint-plugin":"^1.6.6",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-n":"^17.0.0",husky:"^9.0.0",jiti:"^2.7.0","patch-package":"^8.0.0",tsup:"^8.5.0",typescript:"^5.0.0","typescript-eslint":"^8.44.0",vitest:"^4.0.16"},dependencies:{"@anthropic-ai/claude-code":"^2.1.295","@anthropic-ai/sdk":"^0.134.0","@google/gemini-cli":"0.63.0","@modelcontextprotocol/sdk":"^1.29.0","@netlify/cache-utils":"^6.0.5","@netlify/database-proxy":"^0.2.2","@netlify/otel":"^6.0.6","@netlify/ts-cli":"^1.2.0","@openai/codex":"0.162.0","@opentelemetry/api":"^1.9.0","@opentelemetry/exporter-trace-otlp-grpc":"0.218.0","@opentelemetry/otlp-transformer":"0.218.0",execa:"^9.6.1",fastify:"5.12.6",minimist:"^1.2.8",openai:"7.31.0",zod:"^4.4.3"}};var O_t=x_t(import.meta.url),P_t=bu.dirname(O_t),C_t=I_t(import.meta.url),Ry=oe("shell"),l8=new Set,NIe={preferLocal:!0},bt=(t,e,r)=>{let[n,i]=k_t(e,r),o={...NIe,...i},s=TIe(t,n,o);DIe(s,o),UIe(s);let a=r?.idleTimeout;return a&&a>0&&LIe(s,a),s},$Ie=(t,e)=>{let r={...NIe,...e},n=AIe(t,r);return DIe(n,r),UIe(n),e?.idleTimeout&&e.idleTimeout>0&&LIe(n,e.idleTimeout),n},k_t=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},DIe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||sc.env.NETLIFY_LOCAL_QUIET==="true")return;if(sc.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Ow).pipe(sc.stdout),t.stderr?.pipe(new Ow).pipe(sc.stderr);return}t.stdout?.pipe(sc.stdout),t.stderr?.pipe(sc.stderr)},d8=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(sc.kill(-t.pid,e),Ry.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Ry.error("Error killing process:",r),!1}},MIe=t=>d8(t,"SIGKILL"),LIe=(t,e)=>{let r=null,n=()=>{Ry.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),d8(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Ry.log(`Force killing idle process ${t.pid}`),MIe(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)},UIe=t=>{l8.add(t);let e=CIe();if(e){let r=e.onTimesUp(()=>{Ry.log(`Global timer expired, killing process ${t.pid}`),d8(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Ry.log(`Force killing process ${t.pid} after timeout`),MIe(t))},5e3)});t.on("exit",()=>{l8.delete(t),r()}),t.on("error",()=>{l8.delete(t),r()})}};function ac(t,e){if(!sc.env.NETLIFY_LOCAL_MODE)try{let i=C_t.resolve(kIe.name),o=bu.dirname(i);for(;o!==bu.dirname(o);){let s=bu.dirname(o);if(bu.basename(s)==="node_modules"){let a=bu.join(s,".bin",e);if(FM.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(sc.env.NODE_PATH){let i=bu.join(sc.env.NODE_PATH,".bin",e);if(FM.existsSync(i))return i}let r=bu.join(t,"node_modules",".bin",e);if(FM.existsSync(r))return r;let n=bu.join(P_t,"..","node_modules",".bin",e);if(FM.existsSync(n))return n}var xy=oe("repo"),GIe="runner-diffs-",f8=t=>`${GIe}${t}-`,HIe=async t=>{let e=jM.tmpdir(),r;try{r=await di.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(GIe)&&!n.startsWith(f8(t))).map(n=>di.rm(Jo.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},FIe=async t=>{let e=N_t("sha256");for await(let r of $_t(t))e.update(r);return e.digest("hex")},zIe=async(t,e)=>t.size===e.size&&await FIe(t.path)===await FIe(e.path),WIe=/.. (.+)?\.log$/,D_t=[WIe],M_t=1,jIe=t=>{let e=t.split(`
386
+ if (condition) { yield value; }`)};import{Buffer as qht}from"buffer";import{StringDecoder as Vht}from"string_decoder";var TM=(t,e,r)=>{if(r)return;if(t)return{transform:Ght.bind(void 0,new TextEncoder)};let n=new Vht(e);return{transform:Hht.bind(void 0,n),final:Wht.bind(void 0,n)}},Ght=function*(t,e){qht.isBuffer(e)?yield gu(e):typeof e=="string"?yield t.encode(e):yield e},Hht=function*(t,e){yield Wr(e)?t.write(e):e},Wht=function*(t){let e=t.end();e!==""&&(yield e)};import{callbackify as JRe}from"util";var x5=JRe(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),AM=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Yht}=e[r];for await(let i of n(t))yield*AM(i,e,r+1)},QRe=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Kht(r,Number(e),t)},Kht=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*AM(n,r,e+1)},exe=JRe(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),Yht=function*(t){yield t};var I5=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},txe=(t,e)=>[...e.flatMap(r=>[...Xp(r,t,0)]),...eR(t)],Xp=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=Xht}=e[r];for(let i of n(t))yield*Xp(i,e,r+1)},eR=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*Zht(r,Number(e),t)},Zht=function*(t,e,r){if(t!==void 0)for(let n of t())yield*Xp(n,r,e+1)},Xht=function*(t){yield t};var O5=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:o},{encoding:s})=>{let a={},c=nxe(t,s,o),u=Zp(e),l=Zp(r),d=u?x5.bind(void 0,AM,a):I5.bind(void 0,Xp),f=u||l?x5.bind(void 0,QRe,a):I5.bind(void 0,eR),p=u||l?exe.bind(void 0,a):void 0;return{stream:new Jht({writableObjectMode:n,writableHighWaterMark:rxe(n),readableObjectMode:i,readableHighWaterMark:rxe(i),transform(m,_,y){d([m,c,0],this,y)},flush(m){f([c],this,m)},destroy:p})}},RM=(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=nxe(s,r,a);t=txe(c,t)}return t},nxe=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:o},s,a)=>{let c={};return[{transform:YRe(n,a)},TM(r,s,n),wM(r,o,n,c),{transform:t,final:e},{transform:ZRe(i,a)},KRe({binary:r,preserveNewlines:o,readableObjectMode:i,state:c})].filter(Boolean)};var ixe=(t,e)=>{for(let r of Qht(t))emt(t,r,e)},Qht=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),emt=(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 ${cd[a]} with synchronous methods.`)}let s=i.map(({contents:a})=>a).map(a=>tmt(a,n));r.input=VA(s)},tmt=(t,e)=>{let r=RM(t,e,"utf8",!0);return rmt(r),VA(r)},rmt=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 smt,appendFileSync as amt}from"fs";var xM=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&fy(r,n)&&!po.has(e)&&nmt(n)&&(t.some(({type:i,value:o})=>i==="native"&&imt.has(o))||t.every(({type:i})=>Zo.has(i))),nmt=t=>t===1||t===2,imt=new Set(["pipe","overlapped"]),oxe=async(t,e,r,n)=>{for await(let i of t)omt(e)||axe(i,r,n)},sxe=(t,e,r)=>{for(let n of t)axe(n,e,r)},omt=t=>t._readableState.pipes.length>0,axe=(t,e,r)=>{let n=jD(t);tc({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var cxe=({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)=>cmt({result:c,fileDescriptors:t,fdNumber:u,state:o,outputFiles:s,isMaxBuffer:n,verboseInfo:i},r)),...o}},cmt=({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=uRe(t,o,d),p=gu(f),{stdioItems:h,objectMode:m}=e[r],_=umt([p],h,c,n),{serializedResult:y,finalResult:v=y}=lmt({chunks:_,objectMode:m,encoding:c,lines:u,stripFinalNewline:l,fdNumber:r});dmt({serializedResult:y,fdNumber:r,state:n,verboseInfo:s,encoding:c,stdioItems:h,objectMode:m});let A=a[r]?v:void 0;try{return n.error===void 0&&fmt(y,h,i),A}catch(S){return n.error=S,A}},umt=(t,e,r,n)=>{try{return RM(t,e,r,!1)}catch(i){return n.error=i,t}},lmt=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:o})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:VA(t)};let s=wwe(t,r);return n[o]?{serializedResult:s,finalResult:R5(s,!i[o],e)}:{serializedResult:s}},dmt=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:o,objectMode:s})=>{if(!xM({stdioItems:o,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=R5(t,!1,s);try{sxe(a,e,n)}catch(c){r.error??=c}},fmt=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:o})=>bM.has(o))){let o=typeof n=="string"?n:n.toString();i||r.has(o)?amt(n,t):(r.add(o),smt(n,t))}};var uxe=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Su(e,r,"all")]:Array.isArray(e)?[Su(t,r,"all"),...e]:Wr(t)&&Wr(e)?D9([t,e]):`${t}${e}`};import{once as P5}from"events";var lxe=async(t,e)=>{let[r,n]=await pmt(t);return e.isForcefullyTerminated??=!1,[r,n]},pmt=async t=>{let[e,r]=await Promise.allSettled([P5(t,"spawn"),P5(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?dxe(t):r.value},dxe=async t=>{try{return await P5(t,"exit")}catch{return dxe(t)}},fxe=async t=>{let[e,r]=await t;if(!hmt(e,r)&&C5(e,r))throw new oa;return[e,r]},hmt=(t,e)=>t===void 0&&e===void 0,C5=(t,e)=>t!==0||e!==null;var pxe=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let o=mmt(t,e,r),s=o?.code==="ETIMEDOUT",a=cRe(o,n,i);return{resultError:o,exitCode:e,signal:r,timedOut:s,isMaxBuffer:a}},mmt=(t,e,r)=>t!==void 0?t:C5(e,r)?new oa:void 0;var hxe=(t,e,r)=>{let{file:n,commandArguments:i,command:o,escapedCommand:s,startTime:a,verboseInfo:c,options:u,fileDescriptors:l}=_mt(t,e,r),d=vmt({file:n,commandArguments:i,options:u,command:o,escapedCommand:s,verboseInfo:c,fileDescriptors:l,startTime:a});return Ey(d,c,u)},_mt=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=qD(t,e,r),a=ymt(r),{file:c,commandArguments:u,options:l}=uM(t,e,a);Smt(l);let d=VRe(l,s);return{file:c,commandArguments:u,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},ymt=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,Smt=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&IM("ipcInput"),t&&IM("ipc: true"),r&&IM("detached: true"),n&&IM("cancelSignal")},IM=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},vmt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:o,fileDescriptors:s,startTime:a})=>{let c=bmt({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}=pxe(c,r),{output:h,error:m=u}=cxe({fileDescriptors:s,syncResult:c,options:r,isMaxBuffer:p,verboseInfo:o}),_=h.map((v,A)=>Su(v,r,A)),y=Su(uxe(h,r),r,"all");return wmt({error:m,exitCode:l,signal:d,timedOut:f,isMaxBuffer:p,stdio:_,all:y,options:r,command:n,escapedCommand:i,startTime:a})},bmt=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:s})=>{try{ixe(o,r);let a=Emt(r);return gmt(...lM(t,e,a))}catch(a){return by({error:a,command:n,escapedCommand:i,fileDescriptors:o,options:r,startTime:s,isSync:!0})}},Emt=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:_M(e)}),wmt=({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?yM({command:c,escapedCommand:u,stdio:o,all:s,ipcOutput:[],options:a,startTime:l}):QA({error:t,command:c,escapedCommand:u,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:o,all:s,ipcOutput:[],options:a,startTime:l,isSync:!0});import{setMaxListeners as l_t}from"events";import{spawn as d_t}from"child_process";import Sxe from"process";import{once as k5,on as Tmt}from"events";var mxe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:o}={})=>(my({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:nM(t)}),Amt({anyProcess:t,channel:e,isSubprocess:r,filter:o,reference:i})),Amt=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{QD(e,i);let o=ad(t,e,r),s=new AbortController;try{return await Promise.race([Rmt(o,n,s),xmt(o,r,s),Imt(o,r,s)])}catch(a){throw gy(t),a}finally{s.abort(),eM(e,i)}},Rmt=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await k5(t,"message",{signal:r});return n}for await(let[n]of Tmt(t,"message",{signal:r}))if(e(n))return n},xmt=async(t,e,{signal:r})=>{await k5(t,"disconnect",{signal:r}),tAe(e)},Imt=async(t,e,{signal:r})=>{let[n]=await k5(t,"strict:error",{signal:r});throw ZD(n,e)};import{once as _xe,on as Omt}from"events";var yxe=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>N5({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),N5=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:o})=>{my({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:nM(t)}),QD(e,o);let s=ad(t,e,r),a=new AbortController,c={};return Pmt(t,s,a),Cmt({ipcEmitter:s,isSubprocess:r,controller:a,state:c}),kmt({anyProcess:t,channel:e,ipcEmitter:s,isSubprocess:r,shouldAwait:i,controller:a,state:c,reference:o})},Pmt=async(t,e,r)=>{try{await _xe(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},Cmt=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await _xe(t,"strict:error",{signal:r.signal});n.error=ZD(i,e),r.abort()}catch{}},kmt=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:o,state:s,reference:a}){try{for await(let[c]of Omt(r,"message",{signal:o.signal}))gxe(s),yield c}catch{gxe(s)}finally{o.abort(),eM(e,a),n||gy(t),i&&await t}},gxe=({error:t})=>{if(t)throw t};var vxe=(t,{ipc:e})=>{Object.assign(t,Exe(t,!1,e))},bxe=()=>{let t=Sxe,e=!0,r=Sxe.channel!==void 0;return{...Exe(t,e,r),getCancelSignal:IAe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Exe=(t,e,r)=>({sendMessage:aM.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:mxe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:yxe.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});import{ChildProcess as Nmt}from"child_process";import{PassThrough as $mt,Readable as Dmt,Writable as Mmt,Duplex as Lmt}from"stream";var wxe=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,verboseInfo:s})=>{w5(n);let a=new Nmt;Umt(a,n),Object.assign(a,{readable:Fmt,writable:zmt,duplex:jmt});let c=by({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:o,isSync:!1}),u=Bmt(c,s,i);return{subprocess:a,promise:u}},Umt=(t,e)=>{let r=tR(),n=tR(),i=tR(),o=Array.from({length:e.length-3},tR),s=tR(),a=[r,n,i,...o];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:s,stdio:a})},tR=()=>{let t=new $mt;return t.end(),t},Fmt=()=>new Dmt({read(){}}),zmt=()=>new Mmt({write(){}}),jmt=()=>new Lmt({read(){},write(){}}),Bmt=async(t,e,r)=>Ey(t,e,r);import{createReadStream as Txe,createWriteStream as Axe}from"fs";import{Buffer as qmt}from"buffer";import{Readable as rR,Writable as Vmt,Duplex as Gmt}from"stream";var xxe=(t,e)=>EM(Hmt,t,e,!1),nR=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${cd[t]}.`)},Rxe={fileNumber:nR,generator:O5,asyncGenerator:O5,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:Gmt.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},Hmt={input:{...Rxe,fileUrl:({value:t})=>({stream:Txe(t)}),filePath:({value:{file:t}})=>({stream:Txe(t)}),webStream:({value:t})=>({stream:rR.fromWeb(t)}),iterable:({value:t})=>({stream:rR.from(t)}),asyncIterable:({value:t})=>({stream:rR.from(t)}),string:({value:t})=>({stream:rR.from(t)}),uint8Array:({value:t})=>({stream:rR.from(qmt.from(t))})},output:{...Rxe,fileUrl:({value:t})=>({stream:Axe(t)}),filePath:({value:{file:t,append:e}})=>({stream:Axe(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:Vmt.fromWeb(t)}),iterable:nR,asyncIterable:nR,string:nR,uint8Array:nR}};import{on as Wmt,once as Ixe}from"events";import{PassThrough as Kmt,getDefaultHighWaterMark as Ymt}from"stream";import{finished as Cxe}from"stream/promises";function Jp(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)D5(i);let e=t.some(({readableObjectMode:i})=>i),r=Zmt(t,e),n=new $5({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var Zmt=(t,e)=>{if(t.length===0)return Ymt(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},$5=class extends Kmt{#e=new Set([]);#r=new Set([]);#t=new Set([]);#n;#o=Symbol("unpipe");#i=new WeakMap;add(e){if(D5(e),this.#e.has(e))return;this.#e.add(e),this.#n??=Xmt(this,this.#e,this.#o);let r=egt({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(D5(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)}},Xmt=async(t,e,r)=>{OM(t,Oxe);let n=new AbortController;try{await Promise.race([Jmt(t,n),Qmt(t,e,r,n)])}finally{n.abort(),OM(t,-Oxe)}},Jmt=async(t,{signal:e})=>{try{await Cxe(t,{signal:e,cleanup:!0})}catch(r){throw kxe(t,r),r}},Qmt=async(t,e,r,{signal:n})=>{for await(let[i]of Wmt(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},D5=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},egt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:o,unpipeEvent:s})=>{OM(t,Pxe);let a=new AbortController;try{await Promise.race([tgt(o,e,a),rgt({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),ngt({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:s,controller:a})])}finally{a.abort(),OM(t,-Pxe)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?M5(t):igt(t))},tgt=async(t,e,{signal:r})=>{try{await t,r.aborted||M5(e)}catch(n){r.aborted||kxe(e,n)}},rgt=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:o}})=>{try{await Cxe(e,{signal:o,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(s){if(o.aborted||!r.has(e))return;Nxe(s)?i.add(e):$xe(t,s)}},ngt=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:o}})=>{if(await Ixe(t,i,{signal:o}),!t.readable)return Ixe(o,"abort",{signal:o});e.delete(t),r.delete(t),n.delete(t)},igt=t=>{t.writable&&t.end()},kxe=(t,e)=>{Nxe(e)?M5(t):$xe(t,e)},Nxe=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",M5=t=>{(t.readable||t.writable)&&t.destroy()},$xe=(t,e)=>{t.destroyed||(t.once("error",ogt),t.destroy(e))},ogt=()=>{},OM=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},Oxe=2,Pxe=1;import{finished as Dxe}from"stream/promises";var Ty=(t,e)=>{t.pipe(e),sgt(t,e),agt(t,e)},sgt=async(t,e)=>{if(!(ia(t)||ia(e))){try{await Dxe(t,{cleanup:!0,readable:!0,writable:!1})}catch{}L5(e)}},L5=t=>{t.writable&&t.end()},agt=async(t,e)=>{if(!(ia(t)||ia(e))){try{await Dxe(e,{cleanup:!0,readable:!1,writable:!0})}catch{}U5(t)}},U5=t=>{t.readable&&t.destroy()};var Mxe=(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})=>Zo.has(c)))cgt(t,a,s,i);for(let{stream:a}of o.filter(({type:c})=>!Zo.has(c)))lgt({subprocess:t,stream:a,direction:s,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,o]of n.entries()){let s=o.length===1?o[0]:Jp(o);Ty(s,i)}},cgt=(t,e,r,n)=>{r==="output"?Ty(t.stdio[n],e):Ty(e,t.stdio[n]);let i=ugt[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},ugt=["stdin","stdout","stderr"],lgt=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:o})=>{if(e===void 0)return;dgt(e,o);let[s,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],c=i.get(s)??[];i.set(s,[...c,a])},dgt=(t,{signal:e})=>{ia(t)&&Kp(t,fgt,e)},fgt=2;import{addAbortListener as mgt}from"events";var Qp=[];Qp.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Qp.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Qp.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var PM=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",F5=Symbol.for("signal-exit emitter"),z5=globalThis,pgt=Object.defineProperty.bind(Object),j5=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(z5[F5])return z5[F5];pgt(z5,F5,{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}},CM=class{},hgt=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),B5=class extends CM{onExit(){return()=>{}}load(){}unload(){}},q5=class extends CM{#e=V5.platform==="win32"?"SIGINT":"SIGHUP";#r=new j5;#t;#n;#o;#i={};#s=!1;constructor(e){super(),this.#t=e,this.#i={};for(let r of Qp)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(!PM(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 Qp)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,Qp.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 PM(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"&&PM(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)}},V5=globalThis.process,{onExit:Lxe,load:wfr,unload:Tfr}=hgt(PM(V5)?new q5(V5):new B5);var Uxe=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Lxe(()=>{t.kill()});mgt(n,()=>{i()})};var zxe=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let o=BD(),{destination:s,destinationStream:a,destinationError:c,from:u,unpipeSignal:l}=ggt(r,n,i),{sourceStream:d,sourceError:f}=ygt(t,u),{options:p,fileDescriptors:h}=nc.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:p,sourceError:f,destination:s,destinationStream:a,destinationError:c,unpipeSignal:l,fileDescriptors:h,startTime:o}},ggt=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:o,unpipeSignal:s}={}}=_gt(t,e,...r),a=JD(n,o);return{destination:n,destinationStream:a,from:i,unpipeSignal:s}}catch(n){return{destinationError:n}}},_gt=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Fxe,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||N9(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]=kD(r,...n);return{destination:e(Fxe)(i,o,s),pipeOptions:s}}if(nc.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}`)},Fxe=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),ygt=(t,e)=>{try{return{sourceStream:_y(t,e)}}catch(r){return{sourceError:r}}};var Bxe=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:o,startTime:s})=>{let a=Sgt({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw G5({error:a,fileDescriptors:i,sourceOptions:o,startTime:s})},Sgt=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return U5(t),n;if(e!==void 0)return L5(r),e},G5=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>by({error:t,command:jxe,escapedCommand:jxe,fileDescriptors:e,options:r,startTime:n,isSync:!1}),jxe="source.pipe(destination)";var qxe=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 vgt}from"stream/promises";var Vxe=(t,e,r)=>{let n=kM.has(e)?Egt(t,e):bgt(t,e);return Kp(t,Tgt,r.signal),Kp(e,Agt,r.signal),wgt(e),n},bgt=(t,e)=>{let r=Jp([t]);return Ty(r,e),kM.set(e,r),r},Egt=(t,e)=>{let r=kM.get(e);return r.add(t),r},wgt=async t=>{try{await vgt(t,{cleanup:!0,readable:!1,writable:!0})}catch{}kM.delete(t)},kM=new WeakMap,Tgt=2,Agt=1;import{aborted as Rgt}from"util";var Gxe=(t,e)=>t===void 0?[]:[xgt(t,e)],xgt=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:o})=>{await Rgt(t,e),await r.remove(e);let s=new Error("Pipe canceled by `unpipeSignal` option.");throw G5({error:s,fileDescriptors:n,sourceOptions:i,startTime:o})};var NM=(t,...e)=>{if(wr(e[0]))return NM.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=zxe(t,...e),i=Igt({...n,destination:r});return i.pipe=NM.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},Igt=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:o,destinationError:s,unpipeSignal:a,fileDescriptors:c,startTime:u})=>{let l=Ogt(t,i);Bxe({sourceStream:e,sourceError:n,destinationStream:o,destinationError:s,fileDescriptors:c,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=Vxe(e,o,d);return await Promise.race([qxe(l),...Gxe(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:c,startTime:u})])}finally{d.abort()}},Ogt=(t,e)=>Promise.allSettled([t,e]);import{setImmediate as Mgt}from"timers/promises";import{on as Pgt}from"events";import{getDefaultHighWaterMark as Cgt}from"stream";var $M=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:o})=>{let s=new AbortController;return kgt(e,s),Wxe({stream:t,controller:s,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:o})},kgt=async(t,e)=>{try{await t}catch{}finally{e.abort()}},H5=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:o})=>{let s=new AbortController;Ngt(e,s,t);let a=t.readableObjectMode&&!o;return Wxe({stream:t,controller:s,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},Ngt=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},Wxe=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})=>{let a=Pgt(t,"data",{signal:e.signal,highWaterMark:Hxe,highWatermark:Hxe});return $gt({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s})},W5=Cgt(!0),Hxe=W5,$gt=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s}){let a=Dgt({binary:r,shouldEncode:n,encoding:i,shouldSplit:o,preserveNewlines:s});try{for await(let[c]of t)yield*Xp(c,a,0)}catch(c){if(!e.signal.aborted)throw c}finally{yield*eR(a)}},Dgt=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[TM(t,r,!e),wM(t,i,!n,{})].filter(Boolean);var Kxe=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=Lgt({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:l});if(!i){await Promise.all([Ugt(t),d]);return}let f=T5(c,r),p=H5({stream:t,onStreamEnd:e,lines:s,encoding:n,stripFinalNewline:f,allMixed:a}),[h]=await Promise.all([Fgt({stream:t,iterable:p,fdNumber:r,encoding:n,maxBuffer:o,lines:s}),d]);return h},Lgt=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:o,streamInfo:{fileDescriptors:s}})=>{if(!xM({stdioItems:s[r]?.stdioItems,encoding:n,verboseInfo:o,fdNumber:r}))return;let a=H5({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await oxe(a,t,r,o)},Ugt=async t=>{await Mgt(),t.readableFlowing===null&&t.resume()},Fgt=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:o,lines:s})=>{try{return e||s?await hM(r,{maxBuffer:o}):i==="buffer"?new Uint8Array(await mM(r,{maxBuffer:o})):await vy(r,{maxBuffer:o})}catch(a){return Yxe(oRe({error:a,stream:t,readableObjectMode:e,lines:s,encoding:i,fdNumber:n}))}},K5=async t=>{try{return await t}catch(e){return Yxe(e)}},Yxe=({bufferedData:t})=>bwe(t)?new Uint8Array(t):t;import{finished as zgt}from"stream/promises";var iR=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let o=jgt(t,r),s=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],zgt(t,{cleanup:!0,signal:s.signal})])}catch(a){o.stdinCleanedUp||Vgt(a,e,r,n)}finally{s.abort()}},jgt=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&Bgt(t,r,n),n},Bgt=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{qgt(e,r),n.call(t,...i)}},qgt=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},Vgt=(t,e,r,n)=>{if(!Ggt(t,e,r,n))throw t},Ggt=(t,e,r,n=!0)=>r.propagating?Zxe(t)||DM(t):(r.propagating=!0,Y5(r,e)===n?Zxe(t):DM(t)),Y5=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",DM=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",Zxe=t=>t?.code==="EPIPE";var Xxe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>t.stdio.map((c,u)=>Z5({stream:c,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:o,verboseInfo:s,streamInfo:a})),Z5=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=iR(t,e,u);if(Y5(u,e)){await l;return}let[d]=await Promise.all([Kxe({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 Jxe=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?Jp([t,e].filter(Boolean)):void 0,Qxe=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:o,verboseInfo:s,streamInfo:a})=>Z5({...Hgt(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:Wgt(t),stripFinalNewline:o,verboseInfo:s,streamInfo:a}),Hgt=({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}},Wgt=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;import{once as Kgt}from"events";var eIe=t=>fy(t,"ipc"),tIe=(t,e)=>{let r=jD(t);tc({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var rIe=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:o})=>{if(!n)return i;let s=eIe(o),a=_u(e,"ipc"),c=_u(r,"ipc");for await(let u of N5({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(sRe(t,i,c),i.push(u)),s&&tIe(u,o);return i},nIe=async(t,e)=>(await Promise.allSettled([t]),e);var iIe=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=lxe(t,f),A={originalStreams:m,fileDescriptors:h,subprocess:t,exitPromise:v,propagating:!1},S=Xxe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:A}),E=Qxe({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:p,streamInfo:A}),b=[],I=rIe({subprocess:t,buffer:r,maxBuffer:n,ipc:l,ipcOutput:b,verboseInfo:p}),C=Ygt(m,t,A),P=Zgt(h,A);try{return await Promise.race([Promise.all([{},fxe(v),Promise.all(S),E,I,UAe(t,d),...C,...P]),_,Xgt(t,y),...NAe(t,o,f,y),...eAe({subprocess:t,cancelSignal:s,gracefulCancel:a,context:f,controller:y}),...CAe({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=>K5(T))),K5(E),nIe(I,b),Promise.allSettled(C),Promise.allSettled(P)])}},Ygt=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:iR(n,i,r)),Zgt=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:o=i})=>aa(o,{checkOpen:!1})&&!ia(o)).map(({type:i,value:o,stream:s=o})=>iR(s,n,e,{isSameDirection:Zo.has(i),stopOnExit:i==="native"}))),Xgt=async(t,{signal:e})=>{let[r]=await Kgt(t,"error",{signal:e});throw r};var oIe=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),oR=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),o=rc();return i.push(o),{resolve:o.resolve.bind(o),promises:i}},Ay=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 Jgt}from"stream";import{callbackify as Qgt}from"util";import{finished as sIe}from"stream/promises";var X5=async t=>{if(t!==void 0)try{await J5(t)}catch{}},aIe=async t=>{if(t!==void 0)try{await Q5(t)}catch{}},J5=async t=>{await sIe(t,{cleanup:!0,readable:!1,writable:!0})},Q5=async t=>{await sIe(t,{cleanup:!0,readable:!0,writable:!1})},MM=async(t,e)=>{if(await t,e)throw e},LM=(t,e,r)=>{r&&!DM(r)?t.destroy(r):e&&t.destroy()};var cIe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:o=!0}={})=>{let s=i||po.has(r),{subprocessStdout:a,waitReadableDestroy:c}=e8(t,n,e),{readableEncoding:u,readableObjectMode:l,readableHighWaterMark:d}=t8(a,s),{read:f,onStdoutDataDone:p}=r8({subprocessStdout:a,subprocess:t,binary:s,encoding:r,preserveNewlines:o}),h=new Jgt({read:f,destroy:Qgt(i8.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:c})),highWaterMark:d,objectMode:l,encoding:u});return n8({subprocessStdout:a,onStdoutDataDone:p,readable:h,subprocess:t}),h},e8=(t,e,r)=>{let n=_y(t,e),i=oR(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},t8=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:W5},r8=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let o=rc(),s=$M({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){e_t(this,s,o)},onStdoutDataDone:o}},e_t=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},n8=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await Q5(t),await n,await X5(i),await e,r.readable&&r.push(null)}catch(o){await X5(i),uIe(r,o)}},i8=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Ay(r,e)&&(uIe(t,n),await MM(e,n))},uIe=(t,e)=>{LM(t,t.readable,e)};import{Writable as t_t}from"stream";import{callbackify as lIe}from"util";var dIe=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}=o8(t,r,e),s=new t_t({...s8(n,t,i),destroy:lIe(c8.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:o})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return a8(n,s),s},o8=(t,e,r)=>{let n=JD(t,e),i=oR(r,n,"writableFinal"),o=oR(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:o}},s8=(t,e,r)=>({write:r_t.bind(void 0,t),final:lIe(n_t.bind(void 0,t,e,r))}),r_t=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},n_t=async(t,e,r)=>{await Ay(r,e)&&(t.writable&&t.end(),await e)},a8=async(t,e,r)=>{try{await J5(t),e.writable&&e.end()}catch(n){await aIe(r),fIe(e,n)}},c8=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Ay(r,e),await Ay(n,e)&&(fIe(t,i),await MM(e,i))},fIe=(t,e)=>{LM(t,t.writable,e)};import{Duplex as i_t}from"stream";import{callbackify as o_t}from"util";var pIe=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:o=!0,preserveNewlines:s=!0}={})=>{let a=o||po.has(r),{subprocessStdout:c,waitReadableDestroy:u}=e8(t,n,e),{subprocessStdin:l,waitWritableFinal:d,waitWritableDestroy:f}=o8(t,i,e),{readableEncoding:p,readableObjectMode:h,readableHighWaterMark:m}=t8(c,a),{read:_,onStdoutDataDone:y}=r8({subprocessStdout:c,subprocess:t,binary:a,encoding:r,preserveNewlines:s}),v=new i_t({read:_,...s8(l,t,d),destroy:o_t(s_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 n8({subprocessStdout:c,onStdoutDataDone:y,readable:v,subprocess:t,subprocessStdin:l}),a8(l,v,c),v},s_t=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:o},s)=>{await Promise.all([i8({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},s),c8({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:o},s)])};var u8=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let o=n||po.has(e),s=_y(t,r),a=$M({subprocessStdout:s,subprocess:t,binary:o,shouldEncode:!0,encoding:e,preserveNewlines:i});return a_t(a,s,t)},a_t=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var hIe=(t,{encoding:e})=>{let r=oIe();t.readable=cIe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=dIe.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=pIe.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=u8.bind(void 0,t,e),t[Symbol.asyncIterator]=u8.bind(void 0,t,e,{})};var mIe=(t,e)=>{for(let[r,n]of u_t){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},c_t=(async()=>{})().constructor.prototype,u_t=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(c_t,t)]);var gIe=(t,e,r,n)=>{let{file:i,commandArguments:o,command:s,escapedCommand:a,startTime:c,verboseInfo:u,options:l,fileDescriptors:d}=f_t(t,e,r),{subprocess:f,promise:p}=h_t({file:i,commandArguments:o,options:l,startTime:c,verboseInfo:u,command:s,escapedCommand:a,fileDescriptors:d});return f.pipe=NM.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:n}),mIe(f,p),nc.set(f,{options:l,fileDescriptors:d}),f},f_t=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:o,verboseInfo:s}=qD(t,e,r),{file:a,commandArguments:c,options:u}=uM(t,e,r),l=p_t(u),d=xxe(l,s);return{file:a,commandArguments:c,command:n,escapedCommand:i,startTime:o,verboseInfo:s,options:l,fileDescriptors:d}},p_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}},h_t=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:o,escapedCommand:s,fileDescriptors:a})=>{let c;try{c=d_t(...lM(t,e,r))}catch(h){return wxe({error:h,command:o,escapedCommand:s,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;l_t(Number.POSITIVE_INFINITY,u.signal);let l=[...c.stdio];Mxe(c,a,u),Uxe(c,r,u);let d={},f=rc();c.kill=JTe.bind(void 0,{kill:c.kill.bind(c),options:r,onInternalError:f,context:d,controller:u}),c.all=Jxe(c,r),hIe(c,r),vxe(c,r);let p=m_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}},m_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 iIe({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)=>Su(S,e,E)),v=Su(m,e,"all"),A=g_t({errorInfo:d,exitCode:f,signal:p,stdio:y,all:v,ipcOutput:_,context:c,options:e,command:s,escapedCommand:a,startTime:r});return Ey(A,n,e)},g_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?QA({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 ic,isForcefullyTerminated:s.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:o,options:a,startTime:l,isSync:!1}):yM({command:c,escapedCommand:u,stdio:n,all:i,ipcOutput:o,options:a,startTime:l});var UM=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,__t(n,t[n],i)]));return{...t,...r}},__t=(t,e,r)=>y_t.has(t)&&wr(e)&&wr(r)?{...e,...r}:r,y_t=new Set(["env",...F9]);var ud=(t,e,r,n)=>{let i=(s,a,c)=>ud(s,a,r,c),o=(...s)=>S_t({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...s);return n!==void 0&&n(o,i,e),o},S_t=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},o,...s)=>{if(wr(o))return i(t,UM(r,o),n);let{file:a,commandArguments:c,options:u,isSync:l}=v_t({mapArguments:t,firstArgument:o,nextArguments:s,deepOptions:e,boundOptions:r});return l?hxe(a,c,u):gIe(a,c,u,i)},v_t=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let o=xwe(e)?Iwe(e,r):[e,...r],[s,a,c]=kD(...o),u=UM(UM(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 _Ie=({file:t,commandArguments:e})=>SIe(t,e),yIe=({file:t,commandArguments:e})=>({...SIe(t,e),isSync:!0}),SIe=(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]=b_t(t);return{file:r,commandArguments:n}},b_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(E_t)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},E_t=/ +/g;var vIe=(t,e,r)=>{t.sync=e(w_t,r),t.s=t.sync},bIe=({options:t})=>EIe(t),w_t=({options:t})=>({...EIe(t),isSync:!0}),EIe=t=>({options:{...T_t(t),...t}}),T_t=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},wIe={preferLocal:!0};var TIe=ud(()=>({})),pmr=ud(()=>({isSync:!0})),AIe=ud(_Ie),hmr=ud(yIe),mmr=ud(DAe),gmr=ud(bIe,{},wIe,vIe),{sendMessage:_mr,getOneMessage:ymr,getEachMessage:Smr,getCancelSignal:vmr}=bxe();var RIe=!1,xIe,A_t=t=>{xIe??=t},IIe=t=>{RIe=!0,A_t(t)},Bn=()=>RIe,vu=()=>xIe,OIe=t=>{switch(t){case"SIGTERM":case"SIGINT":return t;case void 0:return"interrupted";default:return}};var sR=null,PIe=t=>(sR&&sR.destroy(),sR=new Xo({totalAllowedTime:t}),sR),CIe=()=>sR;var Xo=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 X0({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.12.0-nb987b7e96221d.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 O_t=x_t(import.meta.url),P_t=bu.dirname(O_t),C_t=I_t(import.meta.url),Ry=oe("shell"),l8=new Set,NIe={preferLocal:!0},bt=(t,e,r)=>{let[n,i]=k_t(e,r),o={...NIe,...i},s=TIe(t,n,o);DIe(s,o),UIe(s);let a=r?.idleTimeout;return a&&a>0&&LIe(s,a),s},$Ie=(t,e)=>{let r={...NIe,...e},n=AIe(t,r);return DIe(n,r),UIe(n),e?.idleTimeout&&e.idleTimeout>0&&LIe(n,e.idleTimeout),n},k_t=function(t,e){return Array.isArray(t)?[t,e]:typeof t=="object"&&t!==null?[[],t]:[[],void 0]},DIe=(t,e)=>{if(e.stdio!==void 0||e.stdout!==void 0||e.stderr!==void 0||sc.env.NETLIFY_LOCAL_QUIET==="true")return;if(sc.env.NETLIFY_MASK_LOGS!=="false"){t.stdout?.pipe(new Ow).pipe(sc.stdout),t.stderr?.pipe(new Ow).pipe(sc.stderr);return}t.stdout?.pipe(sc.stdout),t.stderr?.pipe(sc.stderr)},d8=(t,e="SIGTERM")=>{try{return t.pid&&!t.killed?(sc.kill(-t.pid,e),Ry.log(`Killed process ${t.pid} with signal ${e}`),!0):!1}catch(r){return Ry.error("Error killing process:",r),!1}},MIe=t=>d8(t,"SIGKILL"),LIe=(t,e)=>{let r=null,n=()=>{Ry.log(`Process ${t.pid} killed due to idle timeout (no output for ${e}ms)`),d8(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Ry.log(`Force killing idle process ${t.pid}`),MIe(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)},UIe=t=>{l8.add(t);let e=CIe();if(e){let r=e.onTimesUp(()=>{Ry.log(`Global timer expired, killing process ${t.pid}`),d8(t,"SIGTERM"),setTimeout(()=>{t.pid&&!t.killed&&(Ry.log(`Force killing process ${t.pid} after timeout`),MIe(t))},5e3)});t.on("exit",()=>{l8.delete(t),r()}),t.on("error",()=>{l8.delete(t),r()})}};function ac(t,e){if(!sc.env.NETLIFY_LOCAL_MODE)try{let i=C_t.resolve(kIe.name),o=bu.dirname(i);for(;o!==bu.dirname(o);){let s=bu.dirname(o);if(bu.basename(s)==="node_modules"){let a=bu.join(s,".bin",e);if(FM.existsSync(a))return a;break}o=s}}catch(i){console.error("Could not resolve package.json",i)}if(sc.env.NODE_PATH){let i=bu.join(sc.env.NODE_PATH,".bin",e);if(FM.existsSync(i))return i}let r=bu.join(t,"node_modules",".bin",e);if(FM.existsSync(r))return r;let n=bu.join(P_t,"..","node_modules",".bin",e);if(FM.existsSync(n))return n}var xy=oe("repo"),GIe="runner-diffs-",f8=t=>`${GIe}${t}-`,HIe=async t=>{let e=jM.tmpdir(),r;try{r=await di.readdir(e)}catch{return}await Promise.all(r.filter(n=>n.startsWith(GIe)&&!n.startsWith(f8(t))).map(n=>di.rm(Jo.join(e,n),{recursive:!0,force:!0}).catch(()=>{})))},FIe=async t=>{let e=N_t("sha256");for await(let r of $_t(t))e.update(r);return e.digest("hex")},zIe=async(t,e)=>t.size===e.size&&await FIe(t.path)===await FIe(e.path),WIe=/.. (.+)?\.log$/,D_t=[WIe],M_t=1,jIe=t=>{let e=t.split(`
386
387
  `).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)},L_t=t=>t instanceof Error&&String(t.stderr??"").includes("No such remote"),BIe=t=>{let e=t instanceof Error?t.message:String(t),r=String(t?.stderr??"").trim();return An(r?`${e}: ${r}`:e)},U_t=t=>/Authentication failed|returned error: 401/.test(String(t?.stderr??"")),qIe=t=>t.pathname.replace(/\/+$/,"").replace(/\.git$/,""),F_t=(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&&qIe(n)===qIe(r)&&n.password!==""}catch{return!1}},VIe={stdin:"pipe",stdout:"pipe",stderr:"pipe",stripFinalNewline:!1},zM=500,aR=class extends Error{constructor(r,n){super(n instanceof Error?n.message:String(n));this.step=r;this.cause=n}},zi=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 aR(r,n)}}run(e,r={}){return bt("git",e,{cwd:this.cwd,...r,env:{...r.env,NETLIFY_INTERNAL_GIT:"1"}})}async commitAndCreateDiffs({config:e,isRetry:r}){xy.info("Getting runner diffs");let n=await this.hasAgentChanges(),{hasChanges:i}=n,{status:o}=n;if(!i)return{hasChanges:!1};if(!r){let u=jIe(o);await this.discardSetupOnlyChanges(u)}xy.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(Jo.join(jM.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(`
387
388
  `).filter(i=>D_t.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
389
  `)})}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 Jo.resolve(e,String(r).trim())}),this.setupMetadataPath}async listIndexEntries(e,r){let n=[];for(let i=0;i<e.length;i+=zM){let o=e.slice(i,i+zM).map(a=>`:(literal)${a}`),{stdout:s}=await this.run(["ls-files","--stage","-z","--",...o],{...VIe,...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.12.0-nb8c571bb6e224.0",
4
+ "version": "2.12.0-nb987b7e96221d.0",
5
5
  "description": "CLI tool for running Netlify agents",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",