@onfrontier/cli 0.8.16 → 0.8.18

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.
Files changed (2) hide show
  1. package/dist/cli.js +19 -15
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -47,7 +47,7 @@ GFS4: `),console.error(Q)};if(!W1[o1]){if(Ez=global[o1]||[],aS(W1,Ez),W1.close=f
47
47
  `:"")+($?`
48
48
  ${$}
49
49
  `:`
50
- `);let K=(L)=>{console.log($),s7.exit(typeof L==="number"?L:2)},V=()=>{console.log(typeof X.version==="string"?X.version:q.version),s7.exit(0)};if(Y._.length===0&&X.argv.length===1){if(Y.version===!0&&X.autoVersion)V();else if(Y.help===!0&&X.autoHelp)K(0)}let W=Y._;if(delete Y._,!X.allowUnknownFlags){let L=W.filter((B)=>typeof B==="string"&&B.startsWith("-"));if(L.length>0)j90(L),s7.exit(2)}let G=MW(Y,{exclude:["--",/^\w$/]}),z={...G};R90(G,X);for(let L of Object.values(X.flags))delete G[L.alias];let U=P90(X.flags,G,W);if(U.length>0)C90(U),s7.exit(2);return{input:W,flags:G,unnormalizedFlags:z,pkg:q,help:$,showHelp:K,showVersion:V}},oj=D90;var z60=U1(jV(),1);import{mkdtempSync as Iy0,readFileSync as Py0,statSync as Cy0,writeFileSync as JH}from"node:fs";import{tmpdir as Oy0}from"node:os";import{join as LZ}from"node:path";import{spawn as jy0}from"node:child_process";var l1={api:{url:process.env.ONFRONTIER_BASE_URL||"https://api.onfrontier.ai"},app:{url:process.env.ONFRONTIER_APP_URL||"https://app.onfrontier.ai"},router:{url:process.env.ONFRONTIER_ROUTER_URL||"https://go.trybons.ai"},snapshots:{url:process.env.ONFRONTIER_SNAPSHOT_URL||"https://api.onfrontier.ai"},cli:{projectName:"onfrontier-cli"},statsig:{clientKey:process.env.STATSIG_CLIENT_KEY||"client-yHi9oHzSCwrVz3W62PaedcrxeGnL7o2PjNJDByGkIsn"}};function n8(Q=0,X=2000){process.exitCode=Q,setTimeout(()=>{process.exit(Q)},X).unref()}import{appendFileSync as bG0,mkdirSync as fG0,readFileSync as gG0}from"node:fs";import{createRequire as uG0}from"node:module";import{join as N_}from"node:path";import{dirname as hG0}from"node:path";import{isDeepStrictEqual as SG0}from"node:util";import B_ from"node:process";import r5 from"node:fs";import L_ from"node:path";import aX from"node:crypto";import vG0 from"node:assert";var g5=(Q)=>{let X=typeof Q;return Q!==null&&(X==="object"||X==="function")};var NV=new Set(["__proto__","prototype","constructor"]),HJ0=new Set("0123456789");function tq(Q){let X=[],J="",Z="start",q=!1;for(let Y of Q)switch(Y){case"\\":{if(Z==="index")throw Error("Invalid character in an index");if(Z==="indexEnd")throw Error("Invalid character after an index");if(q)J+=Y;Z="property",q=!q;break}case".":{if(Z==="index")throw Error("Invalid character in an index");if(Z==="indexEnd"){Z="property";break}if(q){q=!1,J+=Y;break}if(NV.has(J))return[];X.push(J),J="",Z="property";break}case"[":{if(Z==="index")throw Error("Invalid character in an index");if(Z==="indexEnd"){Z="index";break}if(q){q=!1,J+=Y;break}if(Z==="property"){if(NV.has(J))return[];X.push(J),J=""}Z="index";break}case"]":{if(Z==="index"){X.push(Number.parseInt(J,10)),J="",Z="indexEnd";break}if(Z==="indexEnd")throw Error("Invalid character after an index")}default:{if(Z==="index"&&!HJ0.has(Y))throw Error("Invalid character in an index");if(Z==="indexEnd")throw Error("Invalid character after an index");if(Z==="start")Z="property";if(q)q=!1,J+="\\";J+=Y}}if(q)J+="\\";switch(Z){case"property":{if(NV.has(J))return[];X.push(J);break}case"index":throw Error("Index was not closed");case"start":{X.push("");break}}return X}function RV(Q,X){if(typeof X!=="number"&&Array.isArray(Q)){let J=Number.parseInt(X,10);return Number.isInteger(J)&&Q[J]===Q[X]}return!1}function DR(Q,X){if(RV(Q,X))throw Error("Cannot use string index")}function wR(Q,X,J){if(!g5(Q)||typeof X!=="string")return J===void 0?Q:J;let Z=tq(X);if(Z.length===0)return J;for(let q=0;q<Z.length;q++){let Y=Z[q];if(RV(Q,Y))Q=q===Z.length-1?void 0:null;else Q=Q[Y];if(Q===void 0||Q===null){if(q!==Z.length-1)return J;break}}return Q===void 0?J:Q}function DV(Q,X,J){if(!g5(Q)||typeof X!=="string")return Q;let Z=Q,q=tq(X);for(let Y=0;Y<q.length;Y++){let $=q[Y];if(DR(Q,$),Y===q.length-1)Q[$]=J;else if(!g5(Q[$]))Q[$]=typeof q[Y+1]==="number"?[]:{};Q=Q[$]}return Z}function TR(Q,X){if(!g5(Q)||typeof X!=="string")return!1;let J=tq(X);for(let Z=0;Z<J.length;Z++){let q=J[Z];if(DR(Q,q),Z===J.length-1)return delete Q[q],!0;if(Q=Q[q],!g5(Q))return!1}}function AR(Q,X){if(!g5(Q)||typeof X!=="string")return!1;let J=tq(X);if(J.length===0)return!1;for(let Z of J){if(!g5(Q)||!(Z in Q)||RV(Q,Z))return!1;Q=Q[Z]}return!0}import K1 from"node:path";import ER from"node:os";import wV from"node:process";var i8=ER.homedir(),TV=ER.tmpdir(),{env:a7}=wV,KJ0=(Q)=>{let X=K1.join(i8,"Library");return{data:K1.join(X,"Application Support",Q),config:K1.join(X,"Preferences",Q),cache:K1.join(X,"Caches",Q),log:K1.join(X,"Logs",Q),temp:K1.join(TV,Q)}},WJ0=(Q)=>{let X=a7.APPDATA||K1.join(i8,"AppData","Roaming"),J=a7.LOCALAPPDATA||K1.join(i8,"AppData","Local");return{data:K1.join(J,Q,"Data"),config:K1.join(X,Q,"Config"),cache:K1.join(J,Q,"Cache"),log:K1.join(J,Q,"Log"),temp:K1.join(TV,Q)}},VJ0=(Q)=>{let X=K1.basename(i8);return{data:K1.join(a7.XDG_DATA_HOME||K1.join(i8,".local","share"),Q),config:K1.join(a7.XDG_CONFIG_HOME||K1.join(i8,".config"),Q),cache:K1.join(a7.XDG_CACHE_HOME||K1.join(i8,".cache"),Q),log:K1.join(a7.XDG_STATE_HOME||K1.join(i8,".local","state"),Q),temp:K1.join(TV,X,Q)}};function AV(Q,{suffix:X="nodejs"}={}){if(typeof Q!=="string")throw TypeError(`Expected a string, got ${typeof Q}`);if(X)Q+=`-${X}`;if(wV.platform==="darwin")return KJ0(Q);if(wV.platform==="win32")return WJ0(Q);return VJ0(Q)}import IJ0 from"node:path";import b0 from"node:fs";import{promisify as t1}from"node:util";var GJ0=(Q,X)=>{let{onError:J}=X;return function(...q){return Q.apply(void 0,q).catch(J)}},g4=GJ0;var zJ0=(Q,X)=>{let{onError:J}=X;return function(...q){try{return Q.apply(void 0,q)}catch(Y){return J(Y)}}},L4=zJ0;var _R=250;var UJ0=(Q,X)=>{let{isRetriable:J}=X;return function(q){let{timeout:Y}=q,$=q.interval??_R,H=Date.now()+Y;return function K(...V){return Q.apply(void 0,V).catch((W)=>{if(!J(W))throw W;if(Date.now()>=H)throw W;let G=Math.round($*Math.random());if(G>0)return new Promise((U)=>setTimeout(U,G)).then(()=>K.apply(void 0,V));else return K.apply(void 0,V)})}}},u4=UJ0;var BJ0=(Q,X)=>{let{isRetriable:J}=X;return function(q){let{timeout:Y}=q,$=Date.now()+Y;return function(...K){while(!0)try{return Q.apply(void 0,K)}catch(V){if(!J(V))throw V;if(Date.now()>=$)throw V;continue}}}},m4=BJ0;import vR from"node:process";var RX={isChangeErrorOk:(Q)=>{if(!RX.isNodeError(Q))return!1;let{code:X}=Q;if(X==="ENOSYS")return!0;if(!SR&&(X==="EINVAL"||X==="EPERM"))return!0;return!1},isNodeError:(Q)=>{return Q instanceof Error},isRetriableError:(Q)=>{if(!RX.isNodeError(Q))return!1;let{code:X}=Q;if(X==="EMFILE"||X==="ENFILE"||X==="EAGAIN"||X==="EBUSY"||X==="EACCESS"||X==="EACCES"||X==="EACCS"||X==="EPERM")return!0;return!1},onChangeError:(Q)=>{if(!RX.isNodeError(Q))throw Q;if(RX.isChangeErrorOk(Q))return;throw Q}},EV=RX;var DX={onError:EV.onChangeError},O6={onError:()=>{return}},SR=vR.getuid?!vR.getuid():!1,p1={isRetriable:EV.isRetriableError};var LJ0={attempt:{chmod:g4(t1(b0.chmod),DX),chown:g4(t1(b0.chown),DX),close:g4(t1(b0.close),O6),fsync:g4(t1(b0.fsync),O6),mkdir:g4(t1(b0.mkdir),O6),realpath:g4(t1(b0.realpath),O6),stat:g4(t1(b0.stat),O6),unlink:g4(t1(b0.unlink),O6),chmodSync:L4(b0.chmodSync,DX),chownSync:L4(b0.chownSync,DX),closeSync:L4(b0.closeSync,O6),existsSync:L4(b0.existsSync,O6),fsyncSync:L4(b0.fsync,O6),mkdirSync:L4(b0.mkdirSync,O6),realpathSync:L4(b0.realpathSync,O6),statSync:L4(b0.statSync,O6),unlinkSync:L4(b0.unlinkSync,O6)},retry:{close:u4(t1(b0.close),p1),fsync:u4(t1(b0.fsync),p1),open:u4(t1(b0.open),p1),readFile:u4(t1(b0.readFile),p1),rename:u4(t1(b0.rename),p1),stat:u4(t1(b0.stat),p1),write:u4(t1(b0.write),p1),writeFile:u4(t1(b0.writeFile),p1),closeSync:m4(b0.closeSync,p1),fsyncSync:m4(b0.fsyncSync,p1),openSync:m4(b0.openSync,p1),readFileSync:m4(b0.readFileSync,p1),renameSync:m4(b0.renameSync,p1),statSync:m4(b0.statSync,p1),writeSync:m4(b0.writeSync,p1),writeFileSync:m4(b0.writeFileSync,p1)}},h1=LJ0;import u5 from"node:process";var xR="utf8",_V=438,kR=511;var yR={},hR=u5.geteuid?u5.geteuid():-1,bR=u5.getegid?u5.getegid():-1;var fR=1000,gR=!!u5.getuid,vt0=u5.getuid?!u5.getuid():!1,SV=128;var uR=(Q)=>{return Q instanceof Error&&"code"in Q};var vV=(Q)=>{return typeof Q==="string"},eq=(Q)=>{return Q===void 0};import MJ0 from"node:path";import t7 from"node:process";import mR from"node:process";var dR=mR.platform==="linux",QY=mR.platform==="win32";var xV=["SIGHUP","SIGINT","SIGTERM"];if(!QY)xV.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(dR)xV.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var cR=xV;class lR{constructor(){this.callbacks=new Set,this.exited=!1,this.exit=(Q)=>{if(this.exited)return;this.exited=!0;for(let X of this.callbacks)X();if(Q)if(QY&&(Q!=="SIGINT"&&Q!=="SIGTERM"&&Q!=="SIGKILL"))t7.kill(t7.pid,"SIGTERM");else t7.kill(t7.pid,Q)},this.hook=()=>{t7.once("exit",()=>this.exit());for(let Q of cR)try{t7.once(Q,()=>this.exit(Q))}catch{}},this.register=(Q)=>{return this.callbacks.add(Q),()=>{this.callbacks.delete(Q)}},this.hook()}}var pR=new lR;var FJ0=pR.register,nR=FJ0;var S6={store:{},create:(Q)=>{let X=`000000${Math.floor(Math.random()*16777215).toString(16)}`.slice(-6),J=Date.now().toString().slice(-10),Z="tmp-",q=`.tmp-${J}${X}`;return`${Q}${q}`},get:(Q,X,J=!0)=>{let Z=S6.truncate(X(Q));if(Z in S6.store)return S6.get(Q,X,J);return S6.store[Z]=J,[Z,()=>delete S6.store[Z]]},purge:(Q)=>{if(!S6.store[Q])return;delete S6.store[Q],h1.attempt.unlink(Q)},purgeSync:(Q)=>{if(!S6.store[Q])return;delete S6.store[Q],h1.attempt.unlinkSync(Q)},purgeSyncAll:()=>{for(let Q in S6.store)S6.purgeSync(Q)},truncate:(Q)=>{let X=MJ0.basename(Q);if(X.length<=SV)return Q;let J=/^(\.?)(.*?)((?:\.[^.]+)?(?:\.tmp-\d{10}[a-f0-9]{6})?)$/.exec(X);if(!J)return Q;let Z=X.length-SV;return`${Q.slice(0,-X.length)}${J[1]}${J[2].slice(0,-Z)}${J[3]}`}};nR(S6.purgeSyncAll);var wX=S6;function kV(Q,X,J=yR){if(vV(J))return kV(Q,X,{encoding:J});let q={timeout:J.timeout??fR},Y=null,$=null,H=null;try{let K=h1.attempt.realpathSync(Q),V=!!K;Q=K||Q,[$,Y]=wX.get(Q,J.tmpCreate||wX.create,J.tmpPurge!==!1);let W=gR&&eq(J.chown),G=eq(J.mode);if(V&&(W||G)){let z=h1.attempt.statSync(Q);if(z){if(J={...J},W)J.chown={uid:z.uid,gid:z.gid};if(G)J.mode=z.mode}}if(!V){let z=IJ0.dirname(Q);h1.attempt.mkdirSync(z,{mode:kR,recursive:!0})}if(H=h1.retry.openSync(q)($,"w",J.mode||_V),J.tmpCreated)J.tmpCreated($);if(vV(X))h1.retry.writeSync(q)(H,X,0,J.encoding||xR);else if(!eq(X))h1.retry.writeSync(q)(H,X,0,X.length,0);if(J.fsync!==!1)if(J.fsyncWait!==!1)h1.retry.fsyncSync(q)(H);else h1.attempt.fsync(H);if(h1.retry.closeSync(q)(H),H=null,J.chown&&(J.chown.uid!==hR||J.chown.gid!==bR))h1.attempt.chownSync($,J.chown.uid,J.chown.gid);if(J.mode&&J.mode!==_V)h1.attempt.chmodSync($,J.mode);try{h1.retry.renameSync(q)($,Q)}catch(z){if(!uR(z))throw z;if(z.code!=="ENAMETOOLONG")throw z;h1.retry.renameSync(q)($,wX.truncate(Q))}Y(),$=null}finally{if(H)h1.attempt.closeSync(H);if($)wX.purge($)}}var M_=U1(dE(),1),I_=U1(V_(),1);var FG0=(Q,X,J,Z)=>{if(J==="length"||J==="prototype")return;if(J==="arguments"||J==="caller")return;let q=Object.getOwnPropertyDescriptor(Q,J),Y=Object.getOwnPropertyDescriptor(X,J);if(!MG0(q,Y)&&Z)return;Object.defineProperty(Q,J,Y)},MG0=function(Q,X){return Q===void 0||Q.configurable||Q.writable===X.writable&&Q.enumerable===X.enumerable&&Q.configurable===X.configurable&&(Q.writable||Q.value===X.value)},IG0=(Q,X)=>{let J=Object.getPrototypeOf(X);if(J===Object.getPrototypeOf(Q))return;Object.setPrototypeOf(Q,J)},PG0=(Q,X)=>`/* Wrapped ${Q}*/
50
+ `);let K=(L)=>{console.log($),s7.exit(typeof L==="number"?L:2)},V=()=>{console.log(typeof X.version==="string"?X.version:q.version),s7.exit(0)};if(Y._.length===0&&X.argv.length===1){if(Y.version===!0&&X.autoVersion)V();else if(Y.help===!0&&X.autoHelp)K(0)}let W=Y._;if(delete Y._,!X.allowUnknownFlags){let L=W.filter((B)=>typeof B==="string"&&B.startsWith("-"));if(L.length>0)j90(L),s7.exit(2)}let G=MW(Y,{exclude:["--",/^\w$/]}),z={...G};R90(G,X);for(let L of Object.values(X.flags))delete G[L.alias];let U=P90(X.flags,G,W);if(U.length>0)C90(U),s7.exit(2);return{input:W,flags:G,unnormalizedFlags:z,pkg:q,help:$,showHelp:K,showVersion:V}},oj=D90;var z60=U1(jV(),1);import{mkdtempSync as Iy0,readFileSync as Py0,statSync as Cy0,writeFileSync as JH}from"node:fs";import{tmpdir as Oy0}from"node:os";import{join as LZ}from"node:path";import{spawn as jy0}from"node:child_process";var l1={api:{url:process.env.ONFRONTIER_BASE_URL||"https://api.onfrontier.ai"},app:{url:process.env.ONFRONTIER_APP_URL||"https://app.onfrontier.ai"},router:{url:process.env.ONFRONTIER_ROUTER_URL||"https://go.trybons.ai"},snapshots:{url:process.env.ONFRONTIER_SNAPSHOT_URL||"https://api.onfrontier.ai"},cli:{projectName:"onfrontier-cli"},statsig:{clientKey:process.env.STATSIG_CLIENT_KEY||"client-yHi9oHzSCwrVz3W62PaedcrxeGnL7o2PjNJDByGkIsn"}};function n8(Q=0,X=2000){process.exitCode=Q,setTimeout(()=>{process.exit(Q)},X).unref()}import{appendFileSync as bG0,mkdirSync as fG0,readFileSync as gG0}from"node:fs";import{createRequire as uG0}from"node:module";import{join as N_}from"node:path";import{dirname as hG0}from"node:path";import{isDeepStrictEqual as SG0}from"node:util";import B_ from"node:process";import r5 from"node:fs";import L_ from"node:path";import aX from"node:crypto";import vG0 from"node:assert";var g5=(Q)=>{let X=typeof Q;return Q!==null&&(X==="object"||X==="function")};var NV=new Set(["__proto__","prototype","constructor"]),HJ0=new Set("0123456789");function tq(Q){let X=[],J="",Z="start",q=!1;for(let Y of Q)switch(Y){case"\\":{if(Z==="index")throw Error("Invalid character in an index");if(Z==="indexEnd")throw Error("Invalid character after an index");if(q)J+=Y;Z="property",q=!q;break}case".":{if(Z==="index")throw Error("Invalid character in an index");if(Z==="indexEnd"){Z="property";break}if(q){q=!1,J+=Y;break}if(NV.has(J))return[];X.push(J),J="",Z="property";break}case"[":{if(Z==="index")throw Error("Invalid character in an index");if(Z==="indexEnd"){Z="index";break}if(q){q=!1,J+=Y;break}if(Z==="property"){if(NV.has(J))return[];X.push(J),J=""}Z="index";break}case"]":{if(Z==="index"){X.push(Number.parseInt(J,10)),J="",Z="indexEnd";break}if(Z==="indexEnd")throw Error("Invalid character after an index")}default:{if(Z==="index"&&!HJ0.has(Y))throw Error("Invalid character in an index");if(Z==="indexEnd")throw Error("Invalid character after an index");if(Z==="start")Z="property";if(q)q=!1,J+="\\";J+=Y}}if(q)J+="\\";switch(Z){case"property":{if(NV.has(J))return[];X.push(J);break}case"index":throw Error("Index was not closed");case"start":{X.push("");break}}return X}function RV(Q,X){if(typeof X!=="number"&&Array.isArray(Q)){let J=Number.parseInt(X,10);return Number.isInteger(J)&&Q[J]===Q[X]}return!1}function DR(Q,X){if(RV(Q,X))throw Error("Cannot use string index")}function wR(Q,X,J){if(!g5(Q)||typeof X!=="string")return J===void 0?Q:J;let Z=tq(X);if(Z.length===0)return J;for(let q=0;q<Z.length;q++){let Y=Z[q];if(RV(Q,Y))Q=q===Z.length-1?void 0:null;else Q=Q[Y];if(Q===void 0||Q===null){if(q!==Z.length-1)return J;break}}return Q===void 0?J:Q}function DV(Q,X,J){if(!g5(Q)||typeof X!=="string")return Q;let Z=Q,q=tq(X);for(let Y=0;Y<q.length;Y++){let $=q[Y];if(DR(Q,$),Y===q.length-1)Q[$]=J;else if(!g5(Q[$]))Q[$]=typeof q[Y+1]==="number"?[]:{};Q=Q[$]}return Z}function TR(Q,X){if(!g5(Q)||typeof X!=="string")return!1;let J=tq(X);for(let Z=0;Z<J.length;Z++){let q=J[Z];if(DR(Q,q),Z===J.length-1)return delete Q[q],!0;if(Q=Q[q],!g5(Q))return!1}}function AR(Q,X){if(!g5(Q)||typeof X!=="string")return!1;let J=tq(X);if(J.length===0)return!1;for(let Z of J){if(!g5(Q)||!(Z in Q)||RV(Q,Z))return!1;Q=Q[Z]}return!0}import K1 from"node:path";import ER from"node:os";import wV from"node:process";var i8=ER.homedir(),TV=ER.tmpdir(),{env:a7}=wV,KJ0=(Q)=>{let X=K1.join(i8,"Library");return{data:K1.join(X,"Application Support",Q),config:K1.join(X,"Preferences",Q),cache:K1.join(X,"Caches",Q),log:K1.join(X,"Logs",Q),temp:K1.join(TV,Q)}},WJ0=(Q)=>{let X=a7.APPDATA||K1.join(i8,"AppData","Roaming"),J=a7.LOCALAPPDATA||K1.join(i8,"AppData","Local");return{data:K1.join(J,Q,"Data"),config:K1.join(X,Q,"Config"),cache:K1.join(J,Q,"Cache"),log:K1.join(J,Q,"Log"),temp:K1.join(TV,Q)}},VJ0=(Q)=>{let X=K1.basename(i8);return{data:K1.join(a7.XDG_DATA_HOME||K1.join(i8,".local","share"),Q),config:K1.join(a7.XDG_CONFIG_HOME||K1.join(i8,".config"),Q),cache:K1.join(a7.XDG_CACHE_HOME||K1.join(i8,".cache"),Q),log:K1.join(a7.XDG_STATE_HOME||K1.join(i8,".local","state"),Q),temp:K1.join(TV,X,Q)}};function AV(Q,{suffix:X="nodejs"}={}){if(typeof Q!=="string")throw TypeError(`Expected a string, got ${typeof Q}`);if(X)Q+=`-${X}`;if(wV.platform==="darwin")return KJ0(Q);if(wV.platform==="win32")return WJ0(Q);return VJ0(Q)}import IJ0 from"node:path";import f0 from"node:fs";import{promisify as t1}from"node:util";var GJ0=(Q,X)=>{let{onError:J}=X;return function(...q){return Q.apply(void 0,q).catch(J)}},g4=GJ0;var zJ0=(Q,X)=>{let{onError:J}=X;return function(...q){try{return Q.apply(void 0,q)}catch(Y){return J(Y)}}},L4=zJ0;var _R=250;var UJ0=(Q,X)=>{let{isRetriable:J}=X;return function(q){let{timeout:Y}=q,$=q.interval??_R,H=Date.now()+Y;return function K(...V){return Q.apply(void 0,V).catch((W)=>{if(!J(W))throw W;if(Date.now()>=H)throw W;let G=Math.round($*Math.random());if(G>0)return new Promise((U)=>setTimeout(U,G)).then(()=>K.apply(void 0,V));else return K.apply(void 0,V)})}}},u4=UJ0;var BJ0=(Q,X)=>{let{isRetriable:J}=X;return function(q){let{timeout:Y}=q,$=Date.now()+Y;return function(...K){while(!0)try{return Q.apply(void 0,K)}catch(V){if(!J(V))throw V;if(Date.now()>=$)throw V;continue}}}},m4=BJ0;import vR from"node:process";var RX={isChangeErrorOk:(Q)=>{if(!RX.isNodeError(Q))return!1;let{code:X}=Q;if(X==="ENOSYS")return!0;if(!SR&&(X==="EINVAL"||X==="EPERM"))return!0;return!1},isNodeError:(Q)=>{return Q instanceof Error},isRetriableError:(Q)=>{if(!RX.isNodeError(Q))return!1;let{code:X}=Q;if(X==="EMFILE"||X==="ENFILE"||X==="EAGAIN"||X==="EBUSY"||X==="EACCESS"||X==="EACCES"||X==="EACCS"||X==="EPERM")return!0;return!1},onChangeError:(Q)=>{if(!RX.isNodeError(Q))throw Q;if(RX.isChangeErrorOk(Q))return;throw Q}},EV=RX;var DX={onError:EV.onChangeError},O6={onError:()=>{return}},SR=vR.getuid?!vR.getuid():!1,p1={isRetriable:EV.isRetriableError};var LJ0={attempt:{chmod:g4(t1(f0.chmod),DX),chown:g4(t1(f0.chown),DX),close:g4(t1(f0.close),O6),fsync:g4(t1(f0.fsync),O6),mkdir:g4(t1(f0.mkdir),O6),realpath:g4(t1(f0.realpath),O6),stat:g4(t1(f0.stat),O6),unlink:g4(t1(f0.unlink),O6),chmodSync:L4(f0.chmodSync,DX),chownSync:L4(f0.chownSync,DX),closeSync:L4(f0.closeSync,O6),existsSync:L4(f0.existsSync,O6),fsyncSync:L4(f0.fsync,O6),mkdirSync:L4(f0.mkdirSync,O6),realpathSync:L4(f0.realpathSync,O6),statSync:L4(f0.statSync,O6),unlinkSync:L4(f0.unlinkSync,O6)},retry:{close:u4(t1(f0.close),p1),fsync:u4(t1(f0.fsync),p1),open:u4(t1(f0.open),p1),readFile:u4(t1(f0.readFile),p1),rename:u4(t1(f0.rename),p1),stat:u4(t1(f0.stat),p1),write:u4(t1(f0.write),p1),writeFile:u4(t1(f0.writeFile),p1),closeSync:m4(f0.closeSync,p1),fsyncSync:m4(f0.fsyncSync,p1),openSync:m4(f0.openSync,p1),readFileSync:m4(f0.readFileSync,p1),renameSync:m4(f0.renameSync,p1),statSync:m4(f0.statSync,p1),writeSync:m4(f0.writeSync,p1),writeFileSync:m4(f0.writeFileSync,p1)}},h1=LJ0;import u5 from"node:process";var xR="utf8",_V=438,kR=511;var yR={},hR=u5.geteuid?u5.geteuid():-1,bR=u5.getegid?u5.getegid():-1;var fR=1000,gR=!!u5.getuid,vt0=u5.getuid?!u5.getuid():!1,SV=128;var uR=(Q)=>{return Q instanceof Error&&"code"in Q};var vV=(Q)=>{return typeof Q==="string"},eq=(Q)=>{return Q===void 0};import MJ0 from"node:path";import t7 from"node:process";import mR from"node:process";var dR=mR.platform==="linux",QY=mR.platform==="win32";var xV=["SIGHUP","SIGINT","SIGTERM"];if(!QY)xV.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(dR)xV.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var cR=xV;class lR{constructor(){this.callbacks=new Set,this.exited=!1,this.exit=(Q)=>{if(this.exited)return;this.exited=!0;for(let X of this.callbacks)X();if(Q)if(QY&&(Q!=="SIGINT"&&Q!=="SIGTERM"&&Q!=="SIGKILL"))t7.kill(t7.pid,"SIGTERM");else t7.kill(t7.pid,Q)},this.hook=()=>{t7.once("exit",()=>this.exit());for(let Q of cR)try{t7.once(Q,()=>this.exit(Q))}catch{}},this.register=(Q)=>{return this.callbacks.add(Q),()=>{this.callbacks.delete(Q)}},this.hook()}}var pR=new lR;var FJ0=pR.register,nR=FJ0;var S6={store:{},create:(Q)=>{let X=`000000${Math.floor(Math.random()*16777215).toString(16)}`.slice(-6),J=Date.now().toString().slice(-10),Z="tmp-",q=`.tmp-${J}${X}`;return`${Q}${q}`},get:(Q,X,J=!0)=>{let Z=S6.truncate(X(Q));if(Z in S6.store)return S6.get(Q,X,J);return S6.store[Z]=J,[Z,()=>delete S6.store[Z]]},purge:(Q)=>{if(!S6.store[Q])return;delete S6.store[Q],h1.attempt.unlink(Q)},purgeSync:(Q)=>{if(!S6.store[Q])return;delete S6.store[Q],h1.attempt.unlinkSync(Q)},purgeSyncAll:()=>{for(let Q in S6.store)S6.purgeSync(Q)},truncate:(Q)=>{let X=MJ0.basename(Q);if(X.length<=SV)return Q;let J=/^(\.?)(.*?)((?:\.[^.]+)?(?:\.tmp-\d{10}[a-f0-9]{6})?)$/.exec(X);if(!J)return Q;let Z=X.length-SV;return`${Q.slice(0,-X.length)}${J[1]}${J[2].slice(0,-Z)}${J[3]}`}};nR(S6.purgeSyncAll);var wX=S6;function kV(Q,X,J=yR){if(vV(J))return kV(Q,X,{encoding:J});let q={timeout:J.timeout??fR},Y=null,$=null,H=null;try{let K=h1.attempt.realpathSync(Q),V=!!K;Q=K||Q,[$,Y]=wX.get(Q,J.tmpCreate||wX.create,J.tmpPurge!==!1);let W=gR&&eq(J.chown),G=eq(J.mode);if(V&&(W||G)){let z=h1.attempt.statSync(Q);if(z){if(J={...J},W)J.chown={uid:z.uid,gid:z.gid};if(G)J.mode=z.mode}}if(!V){let z=IJ0.dirname(Q);h1.attempt.mkdirSync(z,{mode:kR,recursive:!0})}if(H=h1.retry.openSync(q)($,"w",J.mode||_V),J.tmpCreated)J.tmpCreated($);if(vV(X))h1.retry.writeSync(q)(H,X,0,J.encoding||xR);else if(!eq(X))h1.retry.writeSync(q)(H,X,0,X.length,0);if(J.fsync!==!1)if(J.fsyncWait!==!1)h1.retry.fsyncSync(q)(H);else h1.attempt.fsync(H);if(h1.retry.closeSync(q)(H),H=null,J.chown&&(J.chown.uid!==hR||J.chown.gid!==bR))h1.attempt.chownSync($,J.chown.uid,J.chown.gid);if(J.mode&&J.mode!==_V)h1.attempt.chmodSync($,J.mode);try{h1.retry.renameSync(q)($,Q)}catch(z){if(!uR(z))throw z;if(z.code!=="ENAMETOOLONG")throw z;h1.retry.renameSync(q)($,wX.truncate(Q))}Y(),$=null}finally{if(H)h1.attempt.closeSync(H);if($)wX.purge($)}}var M_=U1(dE(),1),I_=U1(V_(),1);var FG0=(Q,X,J,Z)=>{if(J==="length"||J==="prototype")return;if(J==="arguments"||J==="caller")return;let q=Object.getOwnPropertyDescriptor(Q,J),Y=Object.getOwnPropertyDescriptor(X,J);if(!MG0(q,Y)&&Z)return;Object.defineProperty(Q,J,Y)},MG0=function(Q,X){return Q===void 0||Q.configurable||Q.writable===X.writable&&Q.enumerable===X.enumerable&&Q.configurable===X.configurable&&(Q.writable||Q.value===X.value)},IG0=(Q,X)=>{let J=Object.getPrototypeOf(X);if(J===Object.getPrototypeOf(Q))return;Object.setPrototypeOf(Q,J)},PG0=(Q,X)=>`/* Wrapped ${Q}*/
51
51
  ${X}`,CG0=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),OG0=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),jG0=(Q,X,J)=>{let Z=J===""?"":`with ${J.trim()}() `,q=PG0.bind(null,Z,X.toString());Object.defineProperty(q,"name",OG0);let{writable:Y,enumerable:$,configurable:H}=CG0;Object.defineProperty(Q,"toString",{value:q,writable:Y,enumerable:$,configurable:H})};function sG(Q,X,{ignoreNonConfigurable:J=!1}={}){let{name:Z}=Q;for(let q of Reflect.ownKeys(X))FG0(Q,X,q,J);return IG0(Q,X),jG0(Q,X,Z),Q}var NG0=(Q,X={})=>{if(typeof Q!=="function")throw TypeError(`Expected the first argument to be a function, got \`${typeof Q}\``);let{wait:J=0,maxWait:Z=Number.POSITIVE_INFINITY,before:q=!1,after:Y=!0}=X;if(J<0||Z<0)throw RangeError("`wait` and `maxWait` must not be negative.");if(!q&&!Y)throw Error("Both `before` and `after` are false, function wouldn't be called.");let $,H,K,V=function(...W){let G=this,z=()=>{if($=void 0,H)clearTimeout(H),H=void 0;if(Y)K=Q.apply(G,W)},U=()=>{if(H=void 0,$)clearTimeout($),$=void 0;if(Y)K=Q.apply(G,W)},L=q&&!$;if(clearTimeout($),$=setTimeout(z,J),Z>0&&Z!==Number.POSITIVE_INFINITY&&!H)H=setTimeout(U,Z);if(L)K=Q.apply(G,W);return K};return sG(V,Q),V.cancel=()=>{if($)clearTimeout($),$=void 0;if(H)clearTimeout(H),H=void 0},V},aG=NG0;var s5=U1(jV(),1);var RG0=Object.prototype.toString;function z_(Q,X,J){if(!Q)return!1;if(Q.constructor===X)return!0;return RG0.call(Q)===J}function U_(Q){return z_(Q,Uint8Array,"[object Uint8Array]")}function DG0(Q){return z_(Q,ArrayBuffer,"[object ArrayBuffer]")}function wG0(Q){return U_(Q)||DG0(Q)}function TG0(Q){if(!U_(Q))throw TypeError(`Expected \`Uint8Array\`, got \`${typeof Q}\``)}function AG0(Q){if(!wG0(Q))throw TypeError(`Expected \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof Q}\``)}function tG(Q,X){if(Q.length===0)return new Uint8Array(0);X??=Q.reduce((q,Y)=>q+Y.length,0);let J=new Uint8Array(X),Z=0;for(let q of Q)TG0(q),J.set(q,Z),Z+=q.length;return J}var G_={utf8:new globalThis.TextDecoder("utf8")};function eG(Q,X="utf8"){return AG0(Q),G_[X]??=new globalThis.TextDecoder(X),G_[X].decode(Q)}function EG0(Q){if(typeof Q!=="string")throw TypeError(`Expected \`string\`, got \`${typeof Q}\``)}var _G0=new globalThis.TextEncoder;function gY(Q){return EG0(Q),_G0.encode(Q)}var E11=Array.from({length:256},(Q,X)=>X.toString(16).padStart(2,"0"));var xG0=I_.default.default,F_="aes-256-cbc",B9=()=>Object.create(null),kG0=(Q)=>Q!==void 0&&Q!==null,yG0=(Q,X)=>{let J=new Set(["undefined","symbol","function"]),Z=typeof X;if(J.has(Z))throw TypeError(`Setting a value of type \`${Z}\` for key \`${Q}\` is not allowed as it's not supported by JSON`)},uY="__internal__",Qz=`${uY}.migrations.version`;class L9{path;events;#X;#Z;#J;#Q={};constructor(Q={}){let X={configName:"config",fileExtension:"json",projectSuffix:"nodejs",clearInvalidConfig:!1,accessPropertiesByDotNotation:!0,configFileMode:438,...Q};if(!X.cwd){if(!X.projectName)throw Error("Please specify the `projectName` option.");X.cwd=AV(X.projectName,{suffix:X.projectSuffix}).config}if(this.#J=X,X.schema??X.ajvOptions??X.rootSchema){if(X.schema&&typeof X.schema!=="object")throw TypeError("The `schema` option must be an object.");let Y=new M_.Ajv2020({allErrors:!0,useDefaults:!0,...X.ajvOptions});xG0(Y);let $={...X.rootSchema,type:"object",properties:X.schema};this.#X=Y.compile($);for(let[H,K]of Object.entries(X.schema??{}))if(K?.default)this.#Q[H]=K.default}if(X.defaults)this.#Q={...this.#Q,...X.defaults};if(X.serialize)this._serialize=X.serialize;if(X.deserialize)this._deserialize=X.deserialize;this.events=new EventTarget,this.#Z=X.encryptionKey;let J=X.fileExtension?`.${X.fileExtension}`:"";this.path=L_.resolve(X.cwd,`${X.configName??"config"}${J}`);let Z=this.store,q=Object.assign(B9(),X.defaults,Z);if(X.migrations){if(!X.projectVersion)throw Error("Please specify the `projectVersion` option.");this._migrate(X.migrations,X.projectVersion,X.beforeEachMigration)}this._validate(q);try{vG0.deepEqual(Z,q)}catch{this.store=q}if(X.watch)this._watch()}get(Q,X){if(this.#J.accessPropertiesByDotNotation)return this._get(Q,X);let{store:J}=this;return Q in J?J[Q]:X}set(Q,X){if(typeof Q!=="string"&&typeof Q!=="object")throw TypeError(`Expected \`key\` to be of type \`string\` or \`object\`, got ${typeof Q}`);if(typeof Q!=="object"&&X===void 0)throw TypeError("Use `delete()` to clear values");if(this._containsReservedKey(Q))throw TypeError(`Please don't use the ${uY} key, as it's used to manage this module internal operations.`);let{store:J}=this,Z=(q,Y)=>{if(yG0(q,Y),this.#J.accessPropertiesByDotNotation)DV(J,q,Y);else J[q]=Y};if(typeof Q==="object"){let q=Q;for(let[Y,$]of Object.entries(q))Z(Y,$)}else Z(Q,X);this.store=J}has(Q){if(this.#J.accessPropertiesByDotNotation)return AR(this.store,Q);return Q in this.store}reset(...Q){for(let X of Q)if(kG0(this.#Q[X]))this.set(X,this.#Q[X])}delete(Q){let{store:X}=this;if(this.#J.accessPropertiesByDotNotation)TR(X,Q);else delete X[Q];this.store=X}clear(){this.store=B9();for(let Q of Object.keys(this.#Q))this.reset(Q)}onDidChange(Q,X){if(typeof Q!=="string")throw TypeError(`Expected \`key\` to be of type \`string\`, got ${typeof Q}`);if(typeof X!=="function")throw TypeError(`Expected \`callback\` to be of type \`function\`, got ${typeof X}`);return this._handleChange(()=>this.get(Q),X)}onDidAnyChange(Q){if(typeof Q!=="function")throw TypeError(`Expected \`callback\` to be of type \`function\`, got ${typeof Q}`);return this._handleChange(()=>this.store,Q)}get size(){return Object.keys(this.store).length}get store(){try{let Q=r5.readFileSync(this.path,this.#Z?null:"utf8"),X=this._encryptData(Q),J=this._deserialize(X);return this._validate(J),Object.assign(B9(),J)}catch(Q){if(Q?.code==="ENOENT")return this._ensureDirectory(),B9();if(this.#J.clearInvalidConfig&&Q.name==="SyntaxError")return B9();throw Q}}set store(Q){this._ensureDirectory(),this._validate(Q),this._write(Q),this.events.dispatchEvent(new Event("change"))}*[Symbol.iterator](){for(let[Q,X]of Object.entries(this.store))yield[Q,X]}_encryptData(Q){if(!this.#Z)return typeof Q==="string"?Q:eG(Q);try{let X=Q.slice(0,16),J=aX.pbkdf2Sync(this.#Z,X.toString(),1e4,32,"sha512"),Z=aX.createDecipheriv(F_,J,X),q=Q.slice(17),Y=typeof q==="string"?gY(q):q;return eG(tG([Z.update(Y),Z.final()]))}catch{}return Q.toString()}_handleChange(Q,X){let J=Q(),Z=()=>{let q=J,Y=Q();if(SG0(Y,q))return;J=Y,X.call(this,Y,q)};return this.events.addEventListener("change",Z),()=>{this.events.removeEventListener("change",Z)}}_deserialize=(Q)=>JSON.parse(Q);_serialize=(Q)=>JSON.stringify(Q,void 0,"\t");_validate(Q){if(!this.#X)return;if(this.#X(Q)||!this.#X.errors)return;let J=this.#X.errors.map(({instancePath:Z,message:q=""})=>`\`${Z.slice(1)}\` ${q}`);throw Error("Config schema violation: "+J.join("; "))}_ensureDirectory(){r5.mkdirSync(L_.dirname(this.path),{recursive:!0})}_write(Q){let X=this._serialize(Q);if(this.#Z){let J=aX.randomBytes(16),Z=aX.pbkdf2Sync(this.#Z,J.toString(),1e4,32,"sha512"),q=aX.createCipheriv(F_,Z,J);X=tG([J,gY(":"),q.update(gY(X)),q.final()])}if(B_.env.SNAP)r5.writeFileSync(this.path,X,{mode:this.#J.configFileMode});else try{kV(this.path,X,{mode:this.#J.configFileMode})}catch(J){if(J?.code==="EXDEV"){r5.writeFileSync(this.path,X,{mode:this.#J.configFileMode});return}throw J}}_watch(){if(this._ensureDirectory(),!r5.existsSync(this.path))this._write(B9());if(B_.platform==="win32")r5.watch(this.path,{persistent:!1},aG(()=>{this.events.dispatchEvent(new Event("change"))},{wait:100}));else r5.watchFile(this.path,{persistent:!1},aG(()=>{this.events.dispatchEvent(new Event("change"))},{wait:5000}))}_migrate(Q,X,J){let Z=this._get(Qz,"0.0.0"),q=Object.keys(Q).filter(($)=>this._shouldPerformMigration($,Z,X)),Y={...this.store};for(let $ of q)try{if(J)J(this,{fromVersion:Z,toVersion:$,finalVersion:X,versions:q});let H=Q[$];H?.(this),this._set(Qz,$),Z=$,Y={...this.store}}catch(H){throw this.store=Y,Error(`Something went wrong during the migration! Changes applied to the store until this failed migration will be restored. ${H}`)}if(this._isVersionInRangeFormat(Z)||!s5.default.eq(Z,X))this._set(Qz,X)}_containsReservedKey(Q){if(typeof Q==="object"){if(Object.keys(Q)[0]===uY)return!0}if(typeof Q!=="string")return!1;if(this.#J.accessPropertiesByDotNotation){if(Q.startsWith(`${uY}.`))return!0;return!1}return!1}_isVersionInRangeFormat(Q){return s5.default.clean(Q)===null}_shouldPerformMigration(Q,X,J){if(this._isVersionInRangeFormat(Q)){if(X!=="0.0.0"&&s5.default.satisfies(X,Q))return!1;return s5.default.satisfies(J,Q)}if(s5.default.lte(Q,X))return!1;if(s5.default.gt(Q,J))return!1;return!0}_get(Q,X){return wR(this.store,Q,X)}_set(Q,X){let{store:J}=this;DV(J,Q,X),this.store=J}}var J5=new L9({projectName:l1.cli.projectName,configName:"snapshots"}),Xz=hG0(J5.path);function Jz(Q){return J5.get(`${Q}.step`,0)}function P_(Q){let X=Jz(Q)+1;return J5.set(`${Q}.step`,X),X}function Zz(Q){return J5.get(`${Q}.baseCommit`,null)}function C_(Q,X){J5.set(`${Q}.baseCommit`,X)}function O_(Q){return J5.get(`${Q}.pendingTranscript`,null)}function j_(Q,X){J5.set(`${Q}.pendingTranscript`,X)}function qz(Q){J5.delete(`${Q}.pendingTranscript`)}var mG0=uG0(import.meta.url),Yz=(()=>{try{return mG0("../package.json").version}catch{return"unknown"}})();function R_(Q){return N_(Xz,"hook-logs",`${Q.replaceAll(/[^\w.-]/g,"_")}.jsonl`)}function C8(Q,X,J){try{let Z=R_(Q);fG0(N_(Xz,"hook-logs"),{recursive:!0}),bG0(Z,JSON.stringify({ts:new Date().toISOString(),pid:process.pid,event:X,...J})+`
52
52
  `)}catch{}}function dG0(Q){try{return process.kill(Q,0),!0}catch(X){return X.code==="EPERM"}}function D_(Q){let X={prevUpload:null,prevUnfinished:null},J;try{J=gG0(R_(Q),"utf8")}catch{return X}let Z=new Map;for(let Y of J.split(`
53
53
  `).slice(-500)){let $;try{$=JSON.parse(Y)}catch{continue}let H=$.pid;if($.event==="start")Z.set(H,$);else if($.event==="end")Z.delete(H);else if($.event==="upload"){let{ts:K,pid:V,event:W,...G}=$;X.prevUpload={at:K,...G}}}let q=[...Z.entries()].filter(([Y])=>Y!==process.pid).at(-1);if(q){let[Y,$]=q;X.prevUnfinished={hook:$.hook,step:$.step,started_at:$.ts,alive:dG0(Y)}}return X}var Un=U1(BS(),1),Bn=U1(Fc(),1);import{existsSync as tk0,mkdtempSync as ek0,readdirSync as Qy0,readFileSync as zn,rmSync as Xy0,statSync as Jy0}from"node:fs";import{devNull as Zy0,tmpdir as qy0}from"node:os";import{join as UZ}from"node:path";var n3=U1(Tc(),1);var i2=new WeakMap;function HQ(...Q){let X=new String(Q);return i2.set(X,Q),X}function Y4(Q){return Q instanceof String&&i2.has(Q)}function KQ(Q){return i2.get(Q)??[]}var l3=U1(p2(),1);import{spawn as Ev0}from"child_process";var mp=U1(r2(),1);import{normalize as ix0}from"node:path";function*_c(Q,X){let J=X==="global";for(let Z of Q)Z.isGlobal===J&&(yield Z)}var BS0=new Set(["--add","--edit","--remove-section","--rename-section","--replace-all","--unset","--unset-all","-e"]),LS0=new Set(["--get","--get-all","--get-color","--get-colorbool","--get-regexp","--get-urlmatch","--list","-l"]),FS0=new Set(["edit","remove-section","rename-section","set","unset"]),MS0=new Set(["get","get-color","get-colorbool","list"]);function IS0(Q,X){for(let{name:Z}of _c(Q,"task")){if(BS0.has(Z))return WQ(!0,X);if(LS0.has(Z))return WQ(!1,X)}let J=X.at(0)?.toLowerCase();return J===void 0?null:FS0.has(J)?WQ(!0,X.slice(1)):MS0.has(J)?WQ(!1,X.slice(1)):X.length===1?WQ(!1,X):WQ(!0,X)}function WQ(Q=!1,X=[]){let J=X.at(0)?.toLowerCase();return J===void 0?null:{isWrite:Q,isRead:!Q,key:J,value:X.at(1)}}function PS0(Q,X){return X.isWrite&&X.value!==void 0?{key:X.key,value:X.value,scope:Q}:{key:X.key,scope:Q}}function CS0(Q){let X=Q?.indexOf("=")||-1;return!Q||X<0?null:{key:Q.slice(0,X).trim().toLowerCase(),value:Q.slice(X+1)}}function OS0(Q){for(let{name:X}of _c(Q,"task"))switch(X){case"--global":return"global";case"--system":return"system";case"--worktree":return"worktree";case"--local":return"local";case"--file":case"-f":return"file"}return"local"}function jS0({name:Q}){if(Q==="-c"||Q==="--config")return"inline";if(Q==="--config-env")return"env"}function*NS0(Q){for(let X of Q){let J=jS0(X),Z=J&&CS0(X.value);Z&&(yield{...Z,scope:J})}}function RS0(Q,X,J){let Z={read:[],write:[...NS0(X)]};return Q==="config"&&DS0(Z,OS0(X),IS0(X,J)),Z}function DS0(Q,X,J){if(J===null)return;let Z=PS0(X,J);J.isWrite?Q.write.push(Z):Q.read.push(Z)}var Sc={short:new Map([["c",!0]])},wS0={short:new Map([["C",!0],["P",!1],["h",!1],["p",!1],["v",!1],...Sc.short.entries()]),long:new Set(["attr-source","config-env","exec-path","git-dir","list-cmds","namespace","super-prefix","work-tree"])},TS0={clone:{short:new Map([["b",!0],["j",!0],["l",!1],["n",!1],["o",!0],["q",!1],["s",!1],["u",!0]]),long:new Set(["branch","config","jobs","origin","upload-pack","u","template"])},commit:{short:new Map([["C",!0],["F",!0],["c",!0],["m",!0],["t",!0]]),long:new Set(["file","message","reedit-message","reuse-message","template"])},config:{short:new Map([["e",!1],["f",!0],["l",!1]]),long:new Set(["blob","comment","default","file","type","value"])},fetch:{short:new Map,long:new Set(["upload-pack"])},init:{short:new Map,long:new Set(["template"])},pull:{short:new Map,long:new Set(["upload-pack"])},push:{short:new Map,long:new Set(["exec","receive-pack"])}},AS0={short:new Map,long:new Set};function ES0(Q){let X=TS0[Q??""]??AS0;return{short:new Map([...Sc.short.entries(),...X.short.entries()]),long:X.long}}function vc(Q,X=wS0){if(Q.startsWith("--")){let J=Q.indexOf("=");if(J>2)return[{name:Q.slice(0,J),value:Q.slice(J+1),needsNext:!1}];let Z=Q.slice(2);return[{name:Q,needsNext:X.long.has(Z)}]}if(Q.length===2){let J=Q.charAt(1),Z=X.short.get(J);return[{name:Q,needsNext:Z===!0}]}return _S0(Q,X.short)}function _S0(Q,X){let J=Q.slice(1).split(""),Z=[];for(let q=0;q<J.length;q++){let Y=J[q],$=X.get(Y);if($===void 0)return[{name:Q,needsNext:!1}];if($){let H=J.slice(q+1).join("");if(H&&![...H].every((K)=>X.has(K)))return Z.push({name:`-${Y}`,value:H,needsNext:!1}),Z}Z.push({name:`-${Y}`,needsNext:$})}return Z}function SS0(Q,X=[]){let J=0;for(;J<Q.length;){let Z=String(Q[J]);if(!Z.startsWith("-")||Z.length<2)break;let q=vc(Z),Y=J+1;for(let $ of q){let H={name:$.name,value:$.value,absorbedNext:!1,isGlobal:!0};$.needsNext&&H.value===void 0&&Y<Q.length&&(H.value=String(Q[Y]),H.absorbedNext=!0,Y++),X.push(H)}J=Y}return{flags:X,taskIndex:J}}function vS0(Q,X,J=[]){let Z=ES0(X),q=[],Y=[],$=0;for(;$<Q.length;){let H=Q[$];if(Y4(H)){Y.push(...KQ(H)),$++;continue}let K=String(H);if(K==="--"){for(let G=$+1;G<Q.length;G++){let z=Q[G];Y4(z)?Y.push(...KQ(z)):Y.push(String(z))}break}if(!K.startsWith("-")||K.length<2){q.push(K),$++;continue}let V=vc(K,Z),W=$+1;for(let G of V){let z={name:G.name,value:G.value,absorbedNext:!1,isGlobal:!1};G.needsNext&&z.value===void 0&&W<Q.length&&!Y4(Q[W])&&(z.value=String(Q[W]),z.absorbedNext=!0,W++),J.push(z)}$=W}return{flags:J,positionals:q,pathspecs:Y}}function*xS0({write:Q}){for(let X of Q)for(let J of kS0){let Z=J(X.key);Z&&(yield Z)}}function H4(Q,X,J=String(Q)){let Z=typeof Q=="string"?new RegExp(`\\s*${Q.toLowerCase()}`):Q;return function(q){if(Z.test(q))return{category:X,message:`Configuring ${J} is not permitted without enabling ${X}`}}}function $4(Q,X){let J=new RegExp(`\\s*${Q.toLowerCase().replace(/\./g,"(..+)?.")}`);return H4(J,X,Q)}var kS0=[H4("alias","allowUnsafeAlias"),H4("core.askPass","allowUnsafeAskPass"),H4("core.editor","allowUnsafeEditor"),H4("core.fsmonitor","allowUnsafeFsMonitor"),H4("core.gitProxy","allowUnsafeGitProxy"),H4("core.hooksPath","allowUnsafeHooksPath"),H4("core.pager","allowUnsafePager"),H4("core.sshCommand","allowUnsafeSshCommand"),$4("credential.helper","allowUnsafeCredentialHelper"),$4("diff.command","allowUnsafeDiffExternal"),H4("diff.external","allowUnsafeDiffExternal"),$4("diff.textconv","allowUnsafeDiffTextConv"),$4("filter.clean","allowUnsafeFilter"),$4("filter.smudge","allowUnsafeFilter"),$4("gpg.program","allowUnsafeGpgProgram"),H4("init.templateDir","allowUnsafeTemplateDir"),$4("merge.driver","allowUnsafeMergeDriver"),$4("mergetool.path","allowUnsafeMergeDriver"),$4("mergetool.cmd","allowUnsafeMergeDriver"),$4("protocol.allow","allowUnsafeProtocolOverride"),$4("remote.receivepack","allowUnsafePack"),$4("remote.uploadpack","allowUnsafePack"),H4("sequence.editor","allowUnsafeEditor")];function*yS0(Q,X){for(let J of X)for(let Z of hS0){let q=Z(Q,J.name);q&&(yield q)}}function qZ(Q,X,J,Z=String(X)){let q=typeof X=="string"?new RegExp(`\\s*${X.toLowerCase()}`):X,Y=`Use of ${Q?`${Q} with option `:""}${Z} is not permitted without enabling ${J}`;return function($,H){if((!Q||$===Q)&&q.test(H))return{category:J,message:Y}}}var hS0=[qZ(null,/--(upload|receive)-pack/,"allowUnsafePack","--upload-pack or --receive-pack"),qZ("clone",/^-\w*u/,"allowUnsafePack"),qZ("clone","--u","allowUnsafePack"),qZ("push","--exec","allowUnsafePack"),qZ(null,"--template","allowUnsafeTemplateDir")];function xc(Q,X,J){return[...yS0(Q,X),...xS0(J)]}function bS0(...Q){let{flags:X,taskIndex:J}=SS0(Q),Z=J<Q.length?String(Q[J]).toLowerCase():null,q=Z!==null?Q.slice(J+1):[],{positionals:Y,pathspecs:$}=vS0(q,Z,X),H=RS0(Z,X,Y);return{task:Z,flags:X.map(gS0),paths:$,config:H,vulnerabilities:fS0(xc(Z,X,H))}}function fS0(Q){return Object.defineProperty(Q,"vulnerabilities",{value:Q})}function gS0({value:Q,name:X}){return Q!==void 0?{name:X,value:Q}:{name:X}}var kc={editor:"allowUnsafeEditor",git_askpass:"allowUnsafeAskPass",git_config_global:"allowUnsafeConfigPaths",git_config_system:"allowUnsafeConfigPaths",git_config_count:"allowUnsafeConfigEnvCount",git_config:"allowUnsafeConfigPaths",git_editor:"allowUnsafeEditor",git_exec_path:"allowUnsafeConfigPaths",git_external_diff:"allowUnsafeDiffExternal",git_pager:"allowUnsafePager",git_proxy_command:"allowUnsafeGitProxy",git_template_dir:"allowUnsafeTemplateDir",git_sequence_editor:"allowUnsafeEditor",git_ssh:"allowUnsafeSshCommand",git_ssh_command:"allowUnsafeSshCommand",pager:"allowUnsafePager",prefix:"allowUnsafeConfigPaths",ssh_askpass:"allowUnsafeAskPass"};function*uS0(Q){let X=parseInt(Q.git_config_count??"0",10);for(let J=0;J<X;J++){let Z=Q[`git_config_key_${J}`],q=Q[`git_config_value_${J}`];Z!==void 0&&(yield{key:Z.toLowerCase().trim(),value:q,scope:"env"})}}function*mS0(Q){for(let X of Object.keys(Q))if(yc(X)){let J=kc[X];yield{category:J,message:`Use of "${X.toUpperCase()}" is not permitted without enabling ${J}`}}}function yc(Q){return Object.hasOwn(kc,Q)}function dS0(Q){let X={};for(let[J,Z]of Object.entries(Q)){let q=J.toLowerCase().trim();(yc(q)||q.startsWith("git"))&&(X[q]=String(Z))}return X}function cS0(Q){let X=dS0(Q),J={read:[],write:[...uS0(X)]},Z=[...mS0(X),...xc(null,[],J)];return{config:J,vulnerabilities:Z}}function hc(Q,X){return[...bS0(...Q).vulnerabilities,...cS0(X).vulnerabilities]}var VQ=U1(r2(),1);import{EventEmitter as ck0}from"node:events";var{defineProperty:FL,getOwnPropertyDescriptor:lS0,getOwnPropertyNames:ML}=Object,pS0=Object.prototype.hasOwnProperty,i=(Q,X)=>function(){return Q&&(X=(0,Q[ML(Q)[0]])(Q=0)),X},nS0=(Q,X)=>function(){return X||(0,Q[ML(Q)[0]])((X={exports:{}}).exports,X),X.exports},w1=(Q,X)=>{for(var J in X)FL(Q,J,{get:X[J],enumerable:!0})},iS0=(Q,X,J,Z)=>{if(X&&typeof X==="object"||typeof X==="function"){for(let q of ML(X))if(!pS0.call(Q,q)&&q!==J)FL(Q,q,{get:()=>X[q],enumerable:!(Z=lS0(X,q))||Z.enumerable})}return Q},P1=(Q)=>iS0(FL({},"__esModule",{value:!0}),Q),S8,I5=i({"src/lib/errors/git-error.ts"(){S8=class extends Error{constructor(Q,X){super(X);this.task=Q,Object.setPrototypeOf(this,new.target.prototype)}}}}),KZ,UQ=i({"src/lib/errors/git-response-error.ts"(){I5(),KZ=class extends S8{constructor(Q,X){super(void 0,X||String(Q));this.git=Q}}}}),Bl,Ll=i({"src/lib/errors/task-configuration-error.ts"(){I5(),Bl=class extends S8{constructor(Q){super(void 0,Q)}}}});function Fl(Q){if(typeof Q!=="function")return D7;return Q}function Ml(Q){return typeof Q==="function"&&Q!==D7}function Il(Q,X){let J=Q.indexOf(X);if(J<=0)return[Q,""];return[Q.substr(0,J),Q.substr(J+1)]}function Pl(Q,X=0){return Cl(Q)&&Q.length>X?Q[X]:void 0}function R7(Q,X=0){if(Cl(Q)&&Q.length>X)return Q[Q.length-1-X]}function Cl(Q){return s3(Q)}function WZ(Q="",X=!0,J=`
@@ -90,7 +90,7 @@ ${Q}
90
90
  ${Q0.default.green(HH)} ${Q0.default.reset(X)} ${Q0.default.gray(en.repeat(Math.max(q-Z-1,1))+Zh0)}
91
91
  ${Y}
92
92
  ${Q0.default.gray(qh0+en.repeat(q+2)+Yh0)}
93
- `)},f0=(Q="")=>{process.stdout.write(`${Q0.default.gray(KH)} ${Q0.default.red(Q)}
93
+ `)},b0=(Q="")=>{process.stdout.write(`${Q0.default.gray(KH)} ${Q0.default.red(Q)}
94
94
 
95
95
  `)},LQ=(Q="")=>{process.stdout.write(`${Q0.default.gray(Jh0)} ${Q}
96
96
  `)},W4=(Q="")=>{process.stdout.write(`${Q0.default.gray(T1)}
@@ -108,11 +108,11 @@ ${Q0.default.gray(KH)} ${Q}
108
108
 
109
109
  ${Q}
110
110
 
111
- Then run \`onfrontier start\`.`,"Identity check"),C5(Q)}class MQ extends Error{}async function qi(Q,X){let J=await fetch(`${Q}/user_management/authorize/device`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:X})});if(!J.ok)throw new MQ(`Could not start sign-in (${J.status})`);return await J.json()}var Lh0=(Q)=>new Promise((X)=>setTimeout(X,Q*1000));async function Yi(Q,X,J){let Z=J.interval||5,q=Date.now()+J.expires_in*1000;while(Date.now()<q){await Lh0(Z);let $=await(await fetch(`${Q}/user_management/authenticate`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"urn:ietf:params:oauth:grant-type:device_code",device_code:J.device_code,client_id:X})})).json();if($.access_token&&$.refresh_token)return{accessToken:$.access_token,refreshToken:$.refresh_token};switch($.error){case"authorization_pending":continue;case"slow_down":Z+=5;continue;default:throw new MQ($.error_description||$.error||"Sign-in failed")}}throw new MQ("The sign-in request expired. Run `onfrontier login` to try again.")}async function $i(){LQ("On Frontier login");let Q=await H6.currentUser();if(Q){if(await H6.identityCheckRequired())OZ();W4(`Already logged in as ${Q.email}. Run \`onfrontier logout\` to switch accounts.`);return}let X=V4();X.start("Starting sign-in");let J,Z;try{Z=await H6.authConfig(),J=await qi(Z.workos_api_url,Z.workos_client_id)}catch(q){X.stop("Could not start sign-in"),f0(q.message),process.exit(1)}X.stop("Sign-in started"),A4(`Finish signing in with your browser (passkey or password):
111
+ Then run \`onfrontier start\`.`,"Identity check"),C5(Q)}class MQ extends Error{}async function qi(Q,X){let J=await fetch(`${Q}/user_management/authorize/device`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:X})});if(!J.ok)throw new MQ(`Could not start sign-in (${J.status})`);return await J.json()}var Lh0=(Q)=>new Promise((X)=>setTimeout(X,Q*1000));async function Yi(Q,X,J){let Z=J.interval||5,q=Date.now()+J.expires_in*1000;while(Date.now()<q){await Lh0(Z);let $=await(await fetch(`${Q}/user_management/authenticate`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"urn:ietf:params:oauth:grant-type:device_code",device_code:J.device_code,client_id:X})})).json();if($.access_token&&$.refresh_token)return{accessToken:$.access_token,refreshToken:$.refresh_token};switch($.error){case"authorization_pending":continue;case"slow_down":Z+=5;continue;default:throw new MQ($.error_description||$.error||"Sign-in failed")}}throw new MQ("The sign-in request expired. Run `onfrontier login` to try again.")}async function $i(){LQ("On Frontier login");let Q=await H6.currentUser();if(Q){if(await H6.identityCheckRequired())OZ();W4(`Already logged in as ${Q.email}. Run \`onfrontier logout\` to switch accounts.`);return}let X=V4();X.start("Starting sign-in");let J,Z;try{Z=await H6.authConfig(),J=await qi(Z.workos_api_url,Z.workos_client_id)}catch(q){X.stop("Could not start sign-in"),b0(q.message),process.exit(1)}X.stop("Sign-in started"),A4(`Finish signing in with your browser (passkey or password):
112
112
 
113
113
  ${J.verification_uri_complete}
114
114
 
115
- Confirmation code: ${J.user_code}`,"Continue in browser"),C5(J.verification_uri_complete),X.start("Waiting for you to finish in the browser");try{let q=await Yi(Z.workos_api_url,Z.workos_client_id,J),Y=await H6.createSession(q.accessToken,q.refreshToken);if(X.stop(`Logged in as ${Y.email}`),await H6.identityCheckRequired()){OZ(),W4("Finish the identity check before you start work.");return}W4("You are all set.")}catch(q){X.stop("Sign-in failed"),f0(q instanceof MQ?q.message:q.message),process.exit(1)}}function Hi(){LQ("On Frontier logout"),E4.clear(),W4("Logged out - stored session cleared.")}import{randomUUID as Zl0}from"node:crypto";import{existsSync as ql0,mkdirSync as wt,readdirSync as Yl0,readFileSync as Et,realpathSync as $l0,statSync as Hl0,writeFileSync as Kl0}from"node:fs";import{homedir as Wl0}from"node:os";import{join as D5}from"node:path";function j1(Q){if(typeof Q!=="object"||Q===null)return!1;let X=Object.getPrototypeOf(Q);return(X===null||X===Object.prototype||Object.getPrototypeOf(X)===null)&&!(Symbol.toStringTag in Q)&&!(Symbol.iterator in Q)}import{fileURLToPath as Fh0}from"node:url";var IQ=(Q,X)=>{let J=JF(Mh0(Q));if(typeof J!=="string")throw TypeError(`${X} must be a string or a file URL: ${J}.`);return J},Mh0=(Q)=>XF(Q)?Q.toString():Q,XF=(Q)=>typeof Q!=="string"&&Q&&Object.getPrototypeOf(Q)===String.prototype,JF=(Q)=>Q instanceof URL?Fh0(Q):Q;var WH=(Q,X=[],J={})=>{let Z=IQ(Q,"First argument"),[q,Y]=j1(X)?[[],X]:[X,J];if(!Array.isArray(q))throw TypeError(`Second argument must be either an array of arguments or an options object: ${q}`);if(q.some((K)=>typeof K==="object"&&K!==null))throw TypeError(`Second argument must be an array of strings: ${q}`);let $=q.map(String),H=$.find((K)=>K.includes("\x00"));if(H!==void 0)throw TypeError(`Arguments cannot contain null bytes ("\\0"): ${H}`);if(!j1(Y))throw TypeError(`Last argument must be an options object: ${Y}`);return[Z,$,Y]};import{ChildProcess as Rh0}from"node:child_process";import{StringDecoder as Ih0}from"node:string_decoder";var{toString:Ki}=Object.prototype,Wi=(Q)=>Ki.call(Q)==="[object ArrayBuffer]",v1=(Q)=>Ki.call(Q)==="[object Uint8Array]",x8=(Q)=>new Uint8Array(Q.buffer,Q.byteOffset,Q.byteLength),Ph0=new TextEncoder,Vi=(Q)=>Ph0.encode(Q),Ch0=new TextDecoder,VH=(Q)=>Ch0.decode(Q),Gi=(Q,X)=>{return Oh0(Q,X).join("")},Oh0=(Q,X)=>{if(X==="utf8"&&Q.every((Y)=>typeof Y==="string"))return Q;let J=new Ih0(X),Z=Q.map((Y)=>typeof Y==="string"?Vi(Y):Y).map((Y)=>J.write(Y)),q=J.end();return q===""?Z:[...Z,q]},jZ=(Q)=>{if(Q.length===1&&v1(Q[0]))return Q[0];return ZF(jh0(Q))},jh0=(Q)=>Q.map((X)=>typeof X==="string"?Vi(X):X),ZF=(Q)=>{let X=new Uint8Array(Nh0(Q)),J=0;for(let Z of Q)X.set(Z,J),J+=Z.length;return X},Nh0=(Q)=>{let X=0;for(let J of Q)X+=J.length;return X};var Li=(Q)=>Array.isArray(Q)&&Array.isArray(Q.raw),Fi=(Q,X)=>{let J=[];for(let[Y,$]of Q.entries())J=Dh0({templates:Q,expressions:X,tokens:J,index:Y,template:$});if(J.length===0)throw TypeError("Template script must not be empty");let[Z,...q]=J;return[Z,q,{}]},Dh0=({templates:Q,expressions:X,tokens:J,index:Z,template:q})=>{if(q===void 0)throw TypeError(`Invalid backslash sequence: ${Q.raw[Z]}`);let{nextTokens:Y,leadingWhitespaces:$,trailingWhitespaces:H}=wh0(q,Q.raw[Z]),K=Ui(J,Y,$);if(Z===X.length)return K;let V=X[Z],W=Array.isArray(V)?V.map((G)=>Bi(G)):[Bi(V)];return Ui(K,W,H)},wh0=(Q,X)=>{if(X.length===0)return{nextTokens:[],leadingWhitespaces:!1,trailingWhitespaces:!1};let J=[],Z=0,q=zi.has(X[0]);for(let $=0,H=0;$<Q.length;$+=1,H+=1){let K=X[H];if(zi.has(K)){if(Z!==$)J.push(Q.slice(Z,$));Z=$+1}else if(K==="\\"){let V=X[H+1];if(V===`
115
+ Confirmation code: ${J.user_code}`,"Continue in browser"),C5(J.verification_uri_complete),X.start("Waiting for you to finish in the browser");try{let q=await Yi(Z.workos_api_url,Z.workos_client_id,J),Y=await H6.createSession(q.accessToken,q.refreshToken);if(X.stop(`Logged in as ${Y.email}`),await H6.identityCheckRequired()){OZ(),W4("Finish the identity check before you start work.");return}W4("You are all set.")}catch(q){X.stop("Sign-in failed"),b0(q instanceof MQ?q.message:q.message),process.exit(1)}}function Hi(){LQ("On Frontier logout"),E4.clear(),W4("Logged out - stored session cleared.")}import{randomUUID as Zl0}from"node:crypto";import{existsSync as ql0,mkdirSync as wt,readdirSync as Yl0,readFileSync as Et,realpathSync as $l0,statSync as Hl0,writeFileSync as Kl0}from"node:fs";import{homedir as Wl0}from"node:os";import{join as D5}from"node:path";function j1(Q){if(typeof Q!=="object"||Q===null)return!1;let X=Object.getPrototypeOf(Q);return(X===null||X===Object.prototype||Object.getPrototypeOf(X)===null)&&!(Symbol.toStringTag in Q)&&!(Symbol.iterator in Q)}import{fileURLToPath as Fh0}from"node:url";var IQ=(Q,X)=>{let J=JF(Mh0(Q));if(typeof J!=="string")throw TypeError(`${X} must be a string or a file URL: ${J}.`);return J},Mh0=(Q)=>XF(Q)?Q.toString():Q,XF=(Q)=>typeof Q!=="string"&&Q&&Object.getPrototypeOf(Q)===String.prototype,JF=(Q)=>Q instanceof URL?Fh0(Q):Q;var WH=(Q,X=[],J={})=>{let Z=IQ(Q,"First argument"),[q,Y]=j1(X)?[[],X]:[X,J];if(!Array.isArray(q))throw TypeError(`Second argument must be either an array of arguments or an options object: ${q}`);if(q.some((K)=>typeof K==="object"&&K!==null))throw TypeError(`Second argument must be an array of strings: ${q}`);let $=q.map(String),H=$.find((K)=>K.includes("\x00"));if(H!==void 0)throw TypeError(`Arguments cannot contain null bytes ("\\0"): ${H}`);if(!j1(Y))throw TypeError(`Last argument must be an options object: ${Y}`);return[Z,$,Y]};import{ChildProcess as Rh0}from"node:child_process";import{StringDecoder as Ih0}from"node:string_decoder";var{toString:Ki}=Object.prototype,Wi=(Q)=>Ki.call(Q)==="[object ArrayBuffer]",v1=(Q)=>Ki.call(Q)==="[object Uint8Array]",x8=(Q)=>new Uint8Array(Q.buffer,Q.byteOffset,Q.byteLength),Ph0=new TextEncoder,Vi=(Q)=>Ph0.encode(Q),Ch0=new TextDecoder,VH=(Q)=>Ch0.decode(Q),Gi=(Q,X)=>{return Oh0(Q,X).join("")},Oh0=(Q,X)=>{if(X==="utf8"&&Q.every((Y)=>typeof Y==="string"))return Q;let J=new Ih0(X),Z=Q.map((Y)=>typeof Y==="string"?Vi(Y):Y).map((Y)=>J.write(Y)),q=J.end();return q===""?Z:[...Z,q]},jZ=(Q)=>{if(Q.length===1&&v1(Q[0]))return Q[0];return ZF(jh0(Q))},jh0=(Q)=>Q.map((X)=>typeof X==="string"?Vi(X):X),ZF=(Q)=>{let X=new Uint8Array(Nh0(Q)),J=0;for(let Z of Q)X.set(Z,J),J+=Z.length;return X},Nh0=(Q)=>{let X=0;for(let J of Q)X+=J.length;return X};var Li=(Q)=>Array.isArray(Q)&&Array.isArray(Q.raw),Fi=(Q,X)=>{let J=[];for(let[Y,$]of Q.entries())J=Dh0({templates:Q,expressions:X,tokens:J,index:Y,template:$});if(J.length===0)throw TypeError("Template script must not be empty");let[Z,...q]=J;return[Z,q,{}]},Dh0=({templates:Q,expressions:X,tokens:J,index:Z,template:q})=>{if(q===void 0)throw TypeError(`Invalid backslash sequence: ${Q.raw[Z]}`);let{nextTokens:Y,leadingWhitespaces:$,trailingWhitespaces:H}=wh0(q,Q.raw[Z]),K=Ui(J,Y,$);if(Z===X.length)return K;let V=X[Z],W=Array.isArray(V)?V.map((G)=>Bi(G)):[Bi(V)];return Ui(K,W,H)},wh0=(Q,X)=>{if(X.length===0)return{nextTokens:[],leadingWhitespaces:!1,trailingWhitespaces:!1};let J=[],Z=0,q=zi.has(X[0]);for(let $=0,H=0;$<Q.length;$+=1,H+=1){let K=X[H];if(zi.has(K)){if(Z!==$)J.push(Q.slice(Z,$));Z=$+1}else if(K==="\\"){let V=X[H+1];if(V===`
116
116
  `)$-=1,H+=1;else if(V==="u"&&X[H+2]==="{")H=X.indexOf("}",H+3);else H+=Th0[V]??1}}let Y=Z===Q.length;if(!Y)J.push(Q.slice(Z));return{nextTokens:J,leadingWhitespaces:q,trailingWhitespaces:Y}},zi=new Set([" ","\t","\r",`
117
117
  `]),Th0={x:3,u:5},Ui=(Q,X,J)=>J||Q.length===0||X.length===0?[...Q,...X]:[...Q.slice(0,-1),`${Q.at(-1)}${X[0]}`,...X.slice(1)],Bi=(Q)=>{let X=typeof Q;if(X==="string")return Q;if(X==="number")return String(Q);if(j1(Q)&&(("stdout"in Q)||("isMaxBuffer"in Q)))return Ah0(Q);if(Q instanceof Rh0||Object.prototype.toString.call(Q)==="[object Promise]")throw TypeError("Unexpected subprocess in template expression. Please use ${await subprocess} instead of ${subprocess}.");throw TypeError(`Unexpected "${X}" in template expression`)},Ah0=({stdout:Q})=>{if(typeof Q==="string")return Q;if(v1(Q))return VH(Q);if(Q===void 0)throw TypeError(`Missing result.stdout in template expression. This is probably due to the previous subprocess' "stdout" option.`);throw TypeError(`Unexpected "${typeof Q}" stdout in template expression`)};import{spawnSync as ym0}from"node:child_process";import{debuglog as Eh0}from"node:util";import qF from"node:process";var _4=(Q)=>GH.includes(Q),GH=[qF.stdin,qF.stdout,qF.stderr],G4=["stdin","stdout","stderr"],zH=(Q)=>G4[Q]??`stdio[${Q}]`;var Ii=(Q)=>{let X={...Q};for(let J of HF)X[J]=YF(Q,J);return X},YF=(Q,X)=>{let J=Array.from({length:_h0(Q)+1}),Z=Sh0(Q[X],J,X);return hh0(Z,X)},_h0=({stdio:Q})=>Array.isArray(Q)?Math.max(Q.length,G4.length):G4.length,Sh0=(Q,X,J)=>j1(Q)?vh0(Q,X,J):X.fill(Q),vh0=(Q,X,J)=>{for(let Z of Object.keys(Q).sort(xh0))for(let q of kh0(Z,J,X))X[q]=Q[Z];return X},xh0=(Q,X)=>Mi(Q)<Mi(X)?1:-1,Mi=(Q)=>{if(Q==="stdout"||Q==="stderr")return 0;return Q==="all"?2:1},kh0=(Q,X,J)=>{if(Q==="ipc")return[J.length-1];let Z=$F(Q);if(Z===void 0||Z===0)throw TypeError(`"${X}.${Q}" is invalid.
118
118
  It must be "${X}.stdout", "${X}.stderr", "${X}.all", "${X}.ipc", or "${X}.fd3", "${X}.fd4" (and so on).`);if(Z>=J.length)throw TypeError(`"${X}.${Q}" is invalid: that file descriptor does not exist.
@@ -154,9 +154,9 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
154
154
  `,LF:`
155
155
  `,concatBytes:iF},Jm0=(Q,X)=>{let J=new Uint8Array(Q.length+X.length);return J.set(Q,0),J.set(X,Q.length),J},Zm0={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:Jm0};import{Buffer as qm0}from"node:buffer";var fs=(Q,X)=>Q?void 0:Ym0.bind(void 0,X),Ym0=function*(Q,X){if(typeof X!=="string"&&!v1(X)&&!qm0.isBuffer(X))throw TypeError(`The \`${Q}\` option's transform must use "objectMode: true" to receive as input: ${typeof X}.`);yield X},gs=(Q,X)=>Q?$m0.bind(void 0,X):Hm0.bind(void 0,X),$m0=function*(Q,X){us(Q,X),yield X},Hm0=function*(Q,X){if(us(Q,X),typeof X!=="string"&&!v1(X))throw TypeError(`The \`${Q}\` option's function must yield a string or an Uint8Array, not ${typeof X}.`);yield X},us=(Q,X)=>{if(X===null||X===void 0)throw TypeError(`The \`${Q}\` option's function must not call \`yield ${X}\`.
156
156
  Instead, \`yield\` should either be called with a value, or not be called at all. For example:
157
- if (condition) { yield value; }`)};import{Buffer as Km0}from"node:buffer";import{StringDecoder as Wm0}from"node:string_decoder";var YK=(Q,X,J)=>{if(J)return;if(Q)return{transform:Vm0.bind(void 0,new TextEncoder)};let Z=new Wm0(X);return{transform:Gm0.bind(void 0,Z),final:zm0.bind(void 0,Z)}},Vm0=function*(Q,X){if(Km0.isBuffer(X))yield x8(X);else if(typeof X==="string")yield Q.encode(X);else yield X},Gm0=function*(Q,X){yield v1(X)?Q.write(X):X},zm0=function*(Q){let X=Q.end();if(X!=="")yield X};import{callbackify as ms}from"node:util";var rF=ms(async(Q,X,J,Z)=>{X.currentIterable=Q(...J);try{for await(let q of X.currentIterable)Z.push(q)}finally{delete X.currentIterable}}),$K=async function*(Q,X,J){if(J===X.length){yield Q;return}let{transform:Z=Bm0}=X[J];for await(let q of Z(Q))yield*$K(q,X,J+1)},ds=async function*(Q){for(let[X,{final:J}]of Object.entries(Q))yield*Um0(J,Number(X),Q)},Um0=async function*(Q,X,J){if(Q===void 0)return;for await(let Z of Q())yield*$K(Z,J,X+1)},cs=ms(async({currentIterable:Q},X)=>{if(Q!==void 0){await(X?Q.throw(X):Q.return());return}if(X)throw X}),Bm0=function*(Q){yield Q};var sF=(Q,X,J,Z)=>{try{for(let q of Q(...X))J.push(q);Z()}catch(q){Z(q)}},ls=(Q,X)=>[...X.flatMap((J)=>[...x7(J,Q,0)]),..._Z(Q)],x7=function*(Q,X,J){if(J===X.length){yield Q;return}let{transform:Z=Fm0}=X[J];for(let q of Z(Q))yield*x7(q,X,J+1)},_Z=function*(Q){for(let[X,{final:J}]of Object.entries(Q))yield*Lm0(J,Number(X),Q)},Lm0=function*(Q,X,J){if(Q===void 0)return;for(let Z of Q())yield*x7(Z,J,X+1)},Fm0=function*(Q){yield Q};var aF=({value:Q,value:{transform:X,final:J,writableObjectMode:Z,readableObjectMode:q},optionName:Y},{encoding:$})=>{let H={},K=ns(Q,$,Y),V=v7(X),W=v7(J),G=V?rF.bind(void 0,$K,H):sF.bind(void 0,x7),z=V||W?rF.bind(void 0,ds,H):sF.bind(void 0,_Z),U=V||W?cs.bind(void 0,H):void 0;return{stream:new Mm0({writableObjectMode:Z,writableHighWaterMark:ps(Z),readableObjectMode:q,readableHighWaterMark:ps(q),transform(B,M,I){G([B,K,0],this,I)},flush(B){z([K],this,B)},destroy:U})}},HK=(Q,X,J,Z)=>{let q=X.filter(({type:$})=>$==="generator"),Y=Z?q.reverse():q;for(let{value:$,optionName:H}of Y){let K=ns($,J,H);Q=ls(K,Q)}return Q},ns=({transform:Q,final:X,binary:J,writableObjectMode:Z,readableObjectMode:q,preserveNewlines:Y},$,H)=>{let K={};return[{transform:fs(Z,H)},YK(J,$,Z),qK(J,Y,Z,K),{transform:Q,final:X},{transform:gs(q,H)},bs({binary:J,preserveNewlines:Y,readableObjectMode:q,state:K})].filter(Boolean)};var is=(Q,X)=>{for(let J of Im0(Q))Pm0(Q,J,X)},Im0=(Q)=>new Set(Object.entries(Q).filter(([,{direction:X}])=>X==="input").map(([X])=>Number(X))),Pm0=(Q,X,J)=>{let{stdioItems:Z}=Q[X],q=Z.filter(({contents:H})=>H!==void 0);if(q.length===0)return;if(X!==0){let[{type:H,optionName:K}]=q;throw TypeError(`Only the \`stdin\` option, not \`${K}\`, can be ${N5[H]} with synchronous methods.`)}let $=q.map(({contents:H})=>H).map((H)=>Cm0(H,Z));J.input=jZ($)},Cm0=(Q,X)=>{let J=HK(Q,X,"utf8",!0);return Om0(J),jZ(J)},Om0=(Q)=>{let X=Q.find((J)=>typeof J!=="string"&&!v1(J));if(X!==void 0)throw TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${X}.`)};import{writeFileSync as Dm0,appendFileSync as wm0}from"node:fs";var KK=({stdioItems:Q,encoding:X,verboseInfo:J,fdNumber:Z})=>Z!=="all"&&CQ(J,Z)&&!g6.has(X)&&jm0(Z)&&(Q.some(({type:q,value:Y})=>q==="native"&&Nm0.has(Y))||Q.every(({type:q})=>z4.has(q))),jm0=(Q)=>Q===1||Q===2,Nm0=new Set(["pipe","overlapped"]),os=async(Q,X,J,Z)=>{for await(let q of Q)if(!Rm0(X))ss(q,J,Z)},rs=(Q,X,J)=>{for(let Z of Q)ss(Z,X,J)},Rm0=(Q)=>Q._readableState.pipes.length>0,ss=(Q,X,J)=>{let Z=IH(Q);q8({type:"output",verboseMessage:Z,fdNumber:X,verboseInfo:J})};var as=({fileDescriptors:Q,syncResult:{output:X},options:J,isMaxBuffer:Z,verboseInfo:q})=>{if(X===null)return{output:Array.from({length:3})};let Y={},$=new Set([]);return{output:X.map((K,V)=>Tm0({result:K,fileDescriptors:Q,fdNumber:V,state:Y,outputFiles:$,isMaxBuffer:Z,verboseInfo:q},J)),...Y}},Tm0=({result:Q,fileDescriptors:X,fdNumber:J,state:Z,outputFiles:q,isMaxBuffer:Y,verboseInfo:$},{buffer:H,encoding:K,lines:V,stripFinalNewline:W,maxBuffer:G})=>{if(Q===null)return;let z=tr(Q,Y,G),U=x8(z),{stdioItems:L,objectMode:B}=X[J],M=Am0([U],L,K,Z),{serializedResult:I,finalResult:j=I}=Em0({chunks:M,objectMode:B,encoding:K,lines:V,stripFinalNewline:W,fdNumber:J});_m0({serializedResult:I,fdNumber:J,state:Z,verboseInfo:$,encoding:K,stdioItems:L,objectMode:B});let R=H[J]?j:void 0;try{if(Z.error===void 0)Sm0(I,L,q);return R}catch(N){return Z.error=N,R}},Am0=(Q,X,J,Z)=>{try{return HK(Q,X,J,!1)}catch(q){return Z.error=q,Q}},Em0=({chunks:Q,objectMode:X,encoding:J,lines:Z,stripFinalNewline:q,fdNumber:Y})=>{if(X)return{serializedResult:Q};if(J==="buffer")return{serializedResult:jZ(Q)};let $=Gi(Q,J);if(Z[Y])return{serializedResult:$,finalResult:oF($,!q[Y],X)};return{serializedResult:$}},_m0=({serializedResult:Q,fdNumber:X,state:J,verboseInfo:Z,encoding:q,stdioItems:Y,objectMode:$})=>{if(!KK({stdioItems:Y,encoding:q,verboseInfo:Z,fdNumber:X}))return;let H=oF(Q,!1,$);try{rs(H,X,Z)}catch(K){J.error??=K}},Sm0=(Q,X,J)=>{for(let{path:Z,append:q}of X.filter(({type:Y})=>JK.has(Y))){let Y=typeof Z==="string"?Z:Z.toString();if(q||J.has(Y))wm0(Z,Q);else J.add(Y),Dm0(Z,Q)}};var ts=([,Q,X],J)=>{if(!J.all)return;if(Q===void 0)return X;if(X===void 0)return Q;if(Array.isArray(Q))return Array.isArray(X)?[...Q,...X]:[...Q,b8(X,J,"all")];if(Array.isArray(X))return[b8(Q,J,"all"),...X];if(v1(Q)&&v1(X))return ZF([Q,X]);return`${Q}${X}`};import{once as tF}from"node:events";var es=async(Q,X)=>{let[J,Z]=await vm0(Q);return X.isForcefullyTerminated??=!1,[J,Z]},vm0=async(Q)=>{let[X,J]=await Promise.allSettled([tF(Q,"spawn"),tF(Q,"exit")]);if(X.status==="rejected")return[];return J.status==="rejected"?Qa(Q):J.value},Qa=async(Q)=>{try{return await tF(Q,"exit")}catch{return Qa(Q)}},Xa=async(Q)=>{let[X,J]=await Q;if(!xm0(X,J)&&eF(X,J))throw new Y8;return[X,J]},xm0=(Q,X)=>Q===void 0&&X===void 0,eF=(Q,X)=>Q!==0||X!==null;var Ja=({error:Q,status:X,signal:J,output:Z},{maxBuffer:q})=>{let Y=km0(Q,X,J),$=Y?.code==="ETIMEDOUT",H=ar(Y,Z,q);return{resultError:Y,exitCode:X,signal:J,timedOut:$,isMaxBuffer:H}},km0=(Q,X,J)=>{if(Q!==void 0)return Q;return eF(X,J)?new Y8:void 0};var Za=(Q,X,J)=>{let{file:Z,commandArguments:q,command:Y,escapedCommand:$,startTime:H,verboseInfo:K,options:V,fileDescriptors:W}=hm0(Q,X,J),G=gm0({file:Z,commandArguments:q,options:V,command:Y,escapedCommand:$,verboseInfo:K,fileDescriptors:W,startTime:H});return EQ(G,K,V)},hm0=(Q,X,J)=>{let{command:Z,escapedCommand:q,startTime:Y,verboseInfo:$}=CH(Q,X,J),H=bm0(J),{file:K,commandArguments:V,options:W}=cH(Q,X,H);fm0(W);let G=xs(W,$);return{file:K,commandArguments:V,command:Z,escapedCommand:q,startTime:Y,verboseInfo:$,options:W,fileDescriptors:G}},bm0=(Q)=>Q.node&&!Q.ipc?{...Q,ipc:!1}:Q,fm0=({ipc:Q,ipcInput:X,detached:J,cancelSignal:Z})=>{if(X)WK("ipcInput");if(Q)WK("ipc: true");if(J)WK("detached: true");if(Z)WK("cancelSignal")},WK=(Q)=>{throw TypeError(`The "${Q}" option cannot be used with synchronous methods.`)},gm0=({file:Q,commandArguments:X,options:J,command:Z,escapedCommand:q,verboseInfo:Y,fileDescriptors:$,startTime:H})=>{let K=um0({file:Q,commandArguments:X,options:J,command:Z,escapedCommand:q,fileDescriptors:$,startTime:H});if(K.failed)return K;let{resultError:V,exitCode:W,signal:G,timedOut:z,isMaxBuffer:U}=Ja(K,J),{output:L,error:B=V}=as({fileDescriptors:$,syncResult:K,options:J,isMaxBuffer:U,verboseInfo:Y}),M=L.map((j,R)=>b8(j,J,R)),I=b8(ts(L,J),J,"all");return dm0({error:B,exitCode:W,signal:G,timedOut:z,isMaxBuffer:U,stdio:M,all:I,options:J,command:Z,escapedCommand:q,startTime:H})},um0=({file:Q,commandArguments:X,options:J,command:Z,escapedCommand:q,fileDescriptors:Y,startTime:$})=>{try{is(Y,J);let H=mm0(J);return ym0(...lH(Q,X,H))}catch(H){return AQ({error:H,command:Z,escapedCommand:q,fileDescriptors:Y,options:J,startTime:$,isSync:!0})}},mm0=({encoding:Q,maxBuffer:X,...J})=>({...J,encoding:"buffer",maxBuffer:tH(X)}),dm0=({error:Q,exitCode:X,signal:J,timedOut:Z,isMaxBuffer:q,stdio:Y,all:$,options:H,command:K,escapedCommand:V,startTime:W})=>Q===void 0?eH({command:K,escapedCommand:V,stdio:Y,all:$,ipcOutput:[],options:H,startTime:W}):EZ({error:Q,command:K,escapedCommand:V,timedOut:Z,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:q,isForcefullyTerminated:!1,exitCode:X,signal:J,stdio:Y,all:$,ipcOutput:[],options:H,startTime:W,isSync:!0});import{setMaxListeners as Ec0}from"node:events";import{spawn as _c0}from"node:child_process";import Ka from"node:process";import{once as QM,on as cm0}from"node:events";var qa=({anyProcess:Q,channel:X,isSubprocess:J,ipc:Z},{reference:q=!0,filter:Y}={})=>{return NQ({methodName:"getOneMessage",isSubprocess:J,ipc:Z,isConnected:bH(Q)}),lm0({anyProcess:Q,channel:X,isSubprocess:J,filter:Y,reference:q})},lm0=async({anyProcess:Q,channel:X,isSubprocess:J,filter:Z,reference:q})=>{xH(X,q);let Y=j5(Q,X,J),$=new AbortController;try{return await Promise.race([pm0(Y,Z,$),nm0(Y,J,$),im0(Y,J,$)])}catch(H){throw RQ(Q),H}finally{$.abort(),kH(X,q)}},pm0=async(Q,X,{signal:J})=>{if(X===void 0){let[Z]=await QM(Q,"message",{signal:J});return Z}for await(let[Z]of cm0(Q,"message",{signal:J}))if(X(Z))return Z},nm0=async(Q,X,{signal:J})=>{await QM(Q,"disconnect",{signal:J}),co(X)},im0=async(Q,X,{signal:J})=>{let[Z]=await QM(Q,"strict:error",{signal:J});throw _H(Z,X)};import{once as $a,on as om0}from"node:events";var Ha=({anyProcess:Q,channel:X,isSubprocess:J,ipc:Z},{reference:q=!0}={})=>XM({anyProcess:Q,channel:X,isSubprocess:J,ipc:Z,shouldAwait:!J,reference:q}),XM=({anyProcess:Q,channel:X,isSubprocess:J,ipc:Z,shouldAwait:q,reference:Y})=>{NQ({methodName:"getEachMessage",isSubprocess:J,ipc:Z,isConnected:bH(Q)}),xH(X,Y);let $=j5(Q,X,J),H=new AbortController,K={};return rm0(Q,$,H),sm0({ipcEmitter:$,isSubprocess:J,controller:H,state:K}),am0({anyProcess:Q,channel:X,ipcEmitter:$,isSubprocess:J,shouldAwait:q,controller:H,state:K,reference:Y})},rm0=async(Q,X,J)=>{try{await $a(X,"disconnect",{signal:J.signal}),J.abort()}catch{}},sm0=async({ipcEmitter:Q,isSubprocess:X,controller:J,state:Z})=>{try{let[q]=await $a(Q,"strict:error",{signal:J.signal});Z.error=_H(q,X),J.abort()}catch{}},am0=async function*({anyProcess:Q,channel:X,ipcEmitter:J,isSubprocess:Z,shouldAwait:q,controller:Y,state:$,reference:H}){try{for await(let[K]of om0(J,"message",{signal:Y.signal}))Ya($),yield K}catch{Ya($)}finally{if(Y.abort(),kH(X,H),!Z)RQ(Q);if(q)await Q}},Ya=({error:Q})=>{if(Q)throw Q};var Wa=(Q,{ipc:X})=>{Object.assign(Q,Ga(Q,!1,X))},Va=()=>{let Q=Ka,X=!0,J=Ka.channel!==void 0;return{...Ga(Q,!0,J),getCancelSignal:Fr.bind(void 0,{anyProcess:Q,channel:Q.channel,isSubprocess:!0,ipc:J})}},Ga=(Q,X,J)=>({sendMessage:mH.bind(void 0,{anyProcess:Q,channel:Q.channel,isSubprocess:X,ipc:J}),getOneMessage:qa.bind(void 0,{anyProcess:Q,channel:Q.channel,isSubprocess:X,ipc:J}),getEachMessage:Ha.bind(void 0,{anyProcess:Q,channel:Q.channel,isSubprocess:X,ipc:J})});import{ChildProcess as tm0}from"node:child_process";import{PassThrough as em0,Readable as Qd0,Writable as Xd0,Duplex as Jd0}from"node:stream";var za=({error:Q,command:X,escapedCommand:J,fileDescriptors:Z,options:q,startTime:Y,verboseInfo:$})=>{pF(Z);let H=new tm0;Zd0(H,Z),Object.assign(H,{readable:qd0,writable:Yd0,duplex:$d0});let K=AQ({error:Q,command:X,escapedCommand:J,fileDescriptors:Z,options:q,startTime:Y,isSync:!1}),V=Hd0(K,$,q);return{subprocess:H,promise:V}},Zd0=(Q,X)=>{let J=SZ(),Z=SZ(),q=SZ(),Y=Array.from({length:X.length-3},SZ),$=SZ(),H=[J,Z,q,...Y];Object.assign(Q,{stdin:J,stdout:Z,stderr:q,all:$,stdio:H})},SZ=()=>{let Q=new em0;return Q.end(),Q},qd0=()=>new Qd0({read(){}}),Yd0=()=>new Xd0({write(){}}),$d0=()=>new Jd0({read(){},write(){}}),Hd0=async(Q,X,J)=>EQ(Q,X,J);import{createReadStream as Ua,createWriteStream as Ba}from"node:fs";import{Buffer as Kd0}from"node:buffer";import{Readable as vZ,Writable as Wd0,Duplex as Vd0}from"node:stream";var Fa=(Q,X)=>ZK(Gd0,Q,X,!1),xZ=({type:Q,optionName:X})=>{throw TypeError(`The \`${X}\` option cannot be ${N5[Q]}.`)},La={fileNumber:xZ,generator:aF,asyncGenerator:aF,nodeStream:({value:Q})=>({stream:Q}),webTransform({value:{transform:Q,writableObjectMode:X,readableObjectMode:J}}){let Z=X||J;return{stream:Vd0.fromWeb(Q,{objectMode:Z})}},duplex:({value:{transform:Q}})=>({stream:Q}),native(){}},Gd0={input:{...La,fileUrl:({value:Q})=>({stream:Ua(Q)}),filePath:({value:{file:Q}})=>({stream:Ua(Q)}),webStream:({value:Q})=>({stream:vZ.fromWeb(Q)}),iterable:({value:Q})=>({stream:vZ.from(Q)}),asyncIterable:({value:Q})=>({stream:vZ.from(Q)}),string:({value:Q})=>({stream:vZ.from(Q)}),uint8Array:({value:Q})=>({stream:vZ.from(Kd0.from(Q))})},output:{...La,fileUrl:({value:Q})=>({stream:Ba(Q)}),filePath:({value:{file:Q,append:X}})=>({stream:Ba(Q,X?{flags:"a"}:{})}),webStream:({value:Q})=>({stream:Wd0.fromWeb(Q)}),iterable:xZ,asyncIterable:xZ,string:xZ,uint8Array:xZ}};import{on as zd0,once as Ma}from"node:events";import{PassThrough as Ud0,getDefaultHighWaterMark as Bd0}from"node:stream";import{finished as Ca}from"node:stream/promises";function k7(Q){if(!Array.isArray(Q))throw TypeError(`Expected an array, got \`${typeof Q}\`.`);for(let q of Q)JM(q);let X=Q.some(({readableObjectMode:q})=>q),J=Ld0(Q,X),Z=new Oa({objectMode:X,writableHighWaterMark:J,readableHighWaterMark:J});for(let q of Q)Z.add(q);return Z}var Ld0=(Q,X)=>{if(Q.length===0)return Bd0(X);let J=Q.filter(({readableObjectMode:Z})=>Z===X).map(({readableHighWaterMark:Z})=>Z);return Math.max(...J)};class Oa extends Ud0{#X=new Set([]);#Z=new Set([]);#J=new Set([]);#Q;#q=Symbol("unpipe");#V=new WeakMap;add(Q){if(JM(Q),this.#X.has(Q))return;this.#X.add(Q),this.#Q??=Fd0(this,this.#X,this.#q);let X=Pd0({passThroughStream:this,stream:Q,streams:this.#X,ended:this.#Z,aborted:this.#J,onFinished:this.#Q,unpipeEvent:this.#q});this.#V.set(Q,X),Q.pipe(this,{end:!1})}async remove(Q){if(JM(Q),!this.#X.has(Q))return!1;let X=this.#V.get(Q);if(X===void 0)return!1;return this.#V.delete(Q),Q.unpipe(this),await X,!0}}var Fd0=async(Q,X,J)=>{VK(Q,Ia);let Z=new AbortController;try{await Promise.race([Md0(Q,Z),Id0(Q,X,J,Z)])}finally{Z.abort(),VK(Q,-Ia)}},Md0=async(Q,{signal:X})=>{try{await Ca(Q,{signal:X,cleanup:!0})}catch(J){throw ja(Q,J),J}},Id0=async(Q,X,J,{signal:Z})=>{for await(let[q]of zd0(Q,"unpipe",{signal:Z}))if(X.has(q))q.emit(J)},JM=(Q)=>{if(typeof Q?.pipe!=="function")throw TypeError(`Expected a readable stream, got: \`${typeof Q}\`.`)},Pd0=async({passThroughStream:Q,stream:X,streams:J,ended:Z,aborted:q,onFinished:Y,unpipeEvent:$})=>{VK(Q,Pa);let H=new AbortController;try{await Promise.race([Cd0(Y,X,H),Od0({passThroughStream:Q,stream:X,streams:J,ended:Z,aborted:q,controller:H}),jd0({stream:X,streams:J,ended:Z,aborted:q,unpipeEvent:$,controller:H})])}finally{H.abort(),VK(Q,-Pa)}if(J.size>0&&J.size===Z.size+q.size)if(Z.size===0&&q.size>0)ZM(Q);else Nd0(Q)},Cd0=async(Q,X,{signal:J})=>{try{if(await Q,!J.aborted)ZM(X)}catch(Z){if(!J.aborted)ja(X,Z)}},Od0=async({passThroughStream:Q,stream:X,streams:J,ended:Z,aborted:q,controller:{signal:Y}})=>{try{if(await Ca(X,{signal:Y,cleanup:!0,readable:!0,writable:!1}),J.has(X))Z.add(X)}catch($){if(Y.aborted||!J.has(X))return;if(Na($))q.add(X);else Ra(Q,$)}},jd0=async({stream:Q,streams:X,ended:J,aborted:Z,unpipeEvent:q,controller:{signal:Y}})=>{if(await Ma(Q,q,{signal:Y}),!Q.readable)return Ma(Y,"abort",{signal:Y});X.delete(Q),J.delete(Q),Z.delete(Q)},Nd0=(Q)=>{if(Q.writable)Q.end()},ja=(Q,X)=>{if(Na(X))ZM(Q);else Ra(Q,X)},Na=(Q)=>Q?.code==="ERR_STREAM_PREMATURE_CLOSE",ZM=(Q)=>{if(Q.readable||Q.writable)Q.destroy()},Ra=(Q,X)=>{if(!Q.destroyed)Q.once("error",Rd0),Q.destroy(X)},Rd0=()=>{},VK=(Q,X)=>{let J=Q.getMaxListeners();if(J!==0&&J!==Number.POSITIVE_INFINITY)Q.setMaxListeners(J+X)},Ia=2,Pa=1;import{finished as Da}from"node:stream/promises";var SQ=(Q,X)=>{Q.pipe(X),Dd0(Q,X),wd0(Q,X)},Dd0=async(Q,X)=>{if(_4(Q)||_4(X))return;try{await Da(Q,{cleanup:!0,readable:!0,writable:!1})}catch{}qM(X)},qM=(Q)=>{if(Q.writable)Q.end()},wd0=async(Q,X)=>{if(_4(Q)||_4(X))return;try{await Da(X,{cleanup:!0,readable:!1,writable:!0})}catch{}YM(Q)},YM=(Q)=>{if(Q.readable)Q.destroy()};var wa=(Q,X,J)=>{let Z=new Map;for(let[q,{stdioItems:Y,direction:$}]of Object.entries(X)){for(let{stream:H}of Y.filter(({type:K})=>z4.has(K)))Td0(Q,H,$,q);for(let{stream:H}of Y.filter(({type:K})=>!z4.has(K)))Ed0({subprocess:Q,stream:H,direction:$,fdNumber:q,pipeGroups:Z,controller:J})}for(let[q,Y]of Z.entries()){let $=Y.length===1?Y[0]:k7(Y);SQ($,q)}},Td0=(Q,X,J,Z)=>{if(J==="output")SQ(Q.stdio[Z],X);else SQ(X,Q.stdio[Z]);let q=Ad0[Z];if(q!==void 0)Q[q]=X;Q.stdio[Z]=X},Ad0=["stdin","stdout","stderr"],Ed0=({subprocess:Q,stream:X,direction:J,fdNumber:Z,pipeGroups:q,controller:Y})=>{if(X===void 0)return;_d0(X,Y);let[$,H]=J==="output"?[X,Q.stdio[Z]]:[Q.stdio[Z],X],K=q.get($)??[];q.set($,[...K,H])},_d0=(Q,{signal:X})=>{if(_4(Q))_7(Q,Sd0,X)},Sd0=2;import{addAbortListener as kd0}from"node:events";var y7=[];y7.push("SIGHUP","SIGINT","SIGTERM");if(process.platform!=="win32")y7.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")y7.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var GK=(Q)=>!!Q&&typeof Q==="object"&&typeof Q.removeListener==="function"&&typeof Q.emit==="function"&&typeof Q.reallyExit==="function"&&typeof Q.listeners==="function"&&typeof Q.kill==="function"&&typeof Q.pid==="number"&&typeof Q.on==="function",$M=Symbol.for("signal-exit emitter"),HM=globalThis,vd0=Object.defineProperty.bind(Object);class Ta{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(HM[$M])return HM[$M];vd0(HM,$M,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(Q,X){this.listeners[Q].push(X)}removeListener(Q,X){let J=this.listeners[Q],Z=J.indexOf(X);if(Z===-1)return;if(Z===0&&J.length===1)J.length=0;else J.splice(Z,1)}emit(Q,X,J){if(this.emitted[Q])return!1;this.emitted[Q]=!0;let Z=!1;for(let q of this.listeners[Q])Z=q(X,J)===!0||Z;if(Q==="exit")Z=this.emit("afterExit",X,J)||Z;return Z}}class WM{}var xd0=(Q)=>{return{onExit(X,J){return Q.onExit(X,J)},load(){return Q.load()},unload(){return Q.unload()}}};class Aa extends WM{onExit(){return()=>{}}load(){}unload(){}}class Ea extends WM{#X=KM.platform==="win32"?"SIGINT":"SIGHUP";#Z=new Ta;#J;#Q;#q;#V={};#W=!1;constructor(Q){super();this.#J=Q,this.#V={};for(let X of y7)this.#V[X]=()=>{let J=this.#J.listeners(X),{count:Z}=this.#Z,q=Q;if(typeof q.__signal_exit_emitter__==="object"&&typeof q.__signal_exit_emitter__.count==="number")Z+=q.__signal_exit_emitter__.count;if(J.length===Z){this.unload();let Y=this.#Z.emit("exit",null,X),$=X==="SIGHUP"?this.#X:X;if(!Y)Q.kill(Q.pid,$)}};this.#q=Q.reallyExit,this.#Q=Q.emit}onExit(Q,X){if(!GK(this.#J))return()=>{};if(this.#W===!1)this.load();let J=X?.alwaysLast?"afterExit":"exit";return this.#Z.on(J,Q),()=>{if(this.#Z.removeListener(J,Q),this.#Z.listeners.exit.length===0&&this.#Z.listeners.afterExit.length===0)this.unload()}}load(){if(this.#W)return;this.#W=!0,this.#Z.count+=1;for(let Q of y7)try{let X=this.#V[Q];if(X)this.#J.on(Q,X)}catch(X){}this.#J.emit=(Q,...X)=>{return this.#K(Q,...X)},this.#J.reallyExit=(Q)=>{return this.#G(Q)}}unload(){if(!this.#W)return;this.#W=!1,y7.forEach((Q)=>{let X=this.#V[Q];if(!X)throw Error("Listener not defined for signal: "+Q);try{this.#J.removeListener(Q,X)}catch(J){}}),this.#J.emit=this.#Q,this.#J.reallyExit=this.#q,this.#Z.count-=1}#G(Q){if(!GK(this.#J))return 0;return this.#J.exitCode=Q||0,this.#Z.emit("exit",this.#J.exitCode,null),this.#q.call(this.#J,this.#J.exitCode)}#K(Q,...X){let J=this.#Q;if(Q==="exit"&&GK(this.#J)){if(typeof X[0]==="number")this.#J.exitCode=X[0];let Z=J.call(this.#J,Q,...X);return this.#Z.emit("exit",this.#J.exitCode,null),Z}else return J.call(this.#J,Q,...X)}}var KM=globalThis.process,{onExit:_a,load:oH1,unload:rH1}=xd0(GK(KM)?new Ea(KM):new Aa);var Sa=(Q,{cleanup:X,detached:J},{signal:Z})=>{if(!X||J)return;let q=_a(()=>{Q.kill()});kd0(Z,()=>{q()})};var xa=({source:Q,sourcePromise:X,boundOptions:J,createNested:Z},...q)=>{let Y=PH(),{destination:$,destinationStream:H,destinationError:K,from:V,unpipeSignal:W}=yd0(J,Z,q),{sourceStream:G,sourceError:z}=bd0(Q,V),{options:U,fileDescriptors:L}=H8.get(Q);return{sourcePromise:X,sourceStream:G,sourceOptions:U,sourceError:z,destination:$,destinationStream:H,destinationError:K,unpipeSignal:W,fileDescriptors:L,startTime:Y}},yd0=(Q,X,J)=>{try{let{destination:Z,pipeOptions:{from:q,to:Y,unpipeSignal:$}={}}=hd0(Q,X,...J),H=vH(Z,Y);return{destination:Z,destinationStream:H,from:q,unpipeSignal:$}}catch(Z){return{destinationError:Z}}},hd0=(Q,X,J,...Z)=>{if(Array.isArray(J))return{destination:X(va,Q)(J,...Z),pipeOptions:Q};if(typeof J==="string"||J instanceof URL||XF(J)){if(Object.keys(Q).length>0)throw TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[q,Y,$]=WH(J,...Z);return{destination:X(va)(q,Y,$),pipeOptions:$}}if(H8.has(J)){if(Object.keys(Q).length>0)throw TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:J,pipeOptions:Z[0]}}throw TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${J}`)},va=({options:Q})=>({options:{...Q,stdin:"pipe",piped:!0}}),bd0=(Q,X)=>{try{return{sourceStream:DQ(Q,X)}}catch(J){return{sourceError:J}}};var ya=({sourceStream:Q,sourceError:X,destinationStream:J,destinationError:Z,fileDescriptors:q,sourceOptions:Y,startTime:$})=>{let H=fd0({sourceStream:Q,sourceError:X,destinationStream:J,destinationError:Z});if(H!==void 0)throw VM({error:H,fileDescriptors:q,sourceOptions:Y,startTime:$})},fd0=({sourceStream:Q,sourceError:X,destinationStream:J,destinationError:Z})=>{if(X!==void 0&&Z!==void 0)return Z;if(Z!==void 0)return YM(Q),Z;if(X!==void 0)return qM(J),X},VM=({error:Q,fileDescriptors:X,sourceOptions:J,startTime:Z})=>AQ({error:Q,command:ka,escapedCommand:ka,fileDescriptors:X,options:J,startTime:Z,isSync:!1}),ka="source.pipe(destination)";var ha=async(Q)=>{let[{status:X,reason:J,value:Z=J},{status:q,reason:Y,value:$=Y}]=await Q;if(!$.pipedFrom.includes(Z))$.pipedFrom.push(Z);if(q==="rejected")throw $;if(X==="rejected")throw Z;return $};import{finished as gd0}from"node:stream/promises";var ba=(Q,X,J)=>{let Z=zK.has(X)?md0(Q,X):ud0(Q,X);return _7(Q,cd0,J.signal),_7(X,ld0,J.signal),dd0(X),Z},ud0=(Q,X)=>{let J=k7([Q]);return SQ(J,X),zK.set(X,J),J},md0=(Q,X)=>{let J=zK.get(X);return J.add(Q),J},dd0=async(Q)=>{try{await gd0(Q,{cleanup:!0,readable:!1,writable:!0})}catch{}zK.delete(Q)},zK=new WeakMap,cd0=2,ld0=1;import{aborted as pd0}from"node:util";var fa=(Q,X)=>Q===void 0?[]:[nd0(Q,X)],nd0=async(Q,{sourceStream:X,mergedStream:J,fileDescriptors:Z,sourceOptions:q,startTime:Y})=>{await pd0(Q,X),await J.remove(X);let $=Error("Pipe canceled by `unpipeSignal` option.");throw VM({error:$,fileDescriptors:Z,sourceOptions:q,startTime:Y})};var UK=(Q,...X)=>{if(j1(X[0]))return UK.bind(void 0,{...Q,boundOptions:{...Q.boundOptions,...X[0]}});let{destination:J,...Z}=xa(Q,...X),q=id0({...Z,destination:J});return q.pipe=UK.bind(void 0,{...Q,source:J,sourcePromise:q,boundOptions:{}}),q},id0=async({sourcePromise:Q,sourceStream:X,sourceOptions:J,sourceError:Z,destination:q,destinationStream:Y,destinationError:$,unpipeSignal:H,fileDescriptors:K,startTime:V})=>{let W=od0(Q,q);ya({sourceStream:X,sourceError:Z,destinationStream:Y,destinationError:$,fileDescriptors:K,sourceOptions:J,startTime:V});let G=new AbortController;try{let z=ba(X,Y,G);return await Promise.race([ha(W),...fa(H,{sourceStream:X,mergedStream:z,sourceOptions:J,fileDescriptors:K,startTime:V})])}finally{G.abort()}},od0=(Q,X)=>Promise.allSettled([Q,X]);import{setImmediate as Xc0}from"node:timers/promises";import{on as rd0}from"node:events";import{getDefaultHighWaterMark as sd0}from"node:stream";var BK=({subprocessStdout:Q,subprocess:X,binary:J,shouldEncode:Z,encoding:q,preserveNewlines:Y})=>{let $=new AbortController;return ad0(X,$),ua({stream:Q,controller:$,binary:J,shouldEncode:!Q.readableObjectMode&&Z,encoding:q,shouldSplit:!Q.readableObjectMode,preserveNewlines:Y})},ad0=async(Q,X)=>{try{await Q}catch{}finally{X.abort()}},GM=({stream:Q,onStreamEnd:X,lines:J,encoding:Z,stripFinalNewline:q,allMixed:Y})=>{let $=new AbortController;td0(X,$,Q);let H=Q.readableObjectMode&&!Y;return ua({stream:Q,controller:$,binary:Z==="buffer",shouldEncode:!H,encoding:Z,shouldSplit:!H&&J,preserveNewlines:!q})},td0=async(Q,X,J)=>{try{await Q}catch{J.destroy()}finally{X.abort()}},ua=({stream:Q,controller:X,binary:J,shouldEncode:Z,encoding:q,shouldSplit:Y,preserveNewlines:$})=>{let H=rd0(Q,"data",{signal:X.signal,highWaterMark:ga,highWatermark:ga});return ed0({onStdoutChunk:H,controller:X,binary:J,shouldEncode:Z,encoding:q,shouldSplit:Y,preserveNewlines:$})},zM=sd0(!0),ga=zM,ed0=async function*({onStdoutChunk:Q,controller:X,binary:J,shouldEncode:Z,encoding:q,shouldSplit:Y,preserveNewlines:$}){let H=Qc0({binary:J,shouldEncode:Z,encoding:q,shouldSplit:Y,preserveNewlines:$});try{for await(let[K]of Q)yield*x7(K,H,0)}catch(K){if(!X.signal.aborted)throw K}finally{yield*_Z(H)}},Qc0=({binary:Q,shouldEncode:X,encoding:J,shouldSplit:Z,preserveNewlines:q})=>[YK(Q,J,!X),qK(Q,q,!Z,{})].filter(Boolean);var ma=async({stream:Q,onStreamEnd:X,fdNumber:J,encoding:Z,buffer:q,maxBuffer:Y,lines:$,allMixed:H,stripFinalNewline:K,verboseInfo:V,streamInfo:W})=>{let G=Jc0({stream:Q,onStreamEnd:X,fdNumber:J,encoding:Z,allMixed:H,verboseInfo:V,streamInfo:W});if(!q){await Promise.all([Zc0(Q),G]);return}let z=nF(K,J),U=GM({stream:Q,onStreamEnd:X,lines:$,encoding:Z,stripFinalNewline:z,allMixed:H}),[L]=await Promise.all([qc0({stream:Q,iterable:U,fdNumber:J,encoding:Z,maxBuffer:Y,lines:$}),G]);return L},Jc0=async({stream:Q,onStreamEnd:X,fdNumber:J,encoding:Z,allMixed:q,verboseInfo:Y,streamInfo:{fileDescriptors:$}})=>{if(!KK({stdioItems:$[J]?.stdioItems,encoding:Z,verboseInfo:Y,fdNumber:J}))return;let H=GM({stream:Q,onStreamEnd:X,lines:!0,encoding:Z,stripFinalNewline:!0,allMixed:q});await os(H,Q,J,Y)},Zc0=async(Q)=>{if(await Xc0(),Q.readableFlowing===null)Q.resume()},qc0=async({stream:Q,stream:{readableObjectMode:X},iterable:J,fdNumber:Z,encoding:q,maxBuffer:Y,lines:$})=>{try{if(X||$)return await oH(J,{maxBuffer:Y});if(q==="buffer")return new Uint8Array(await rH(J,{maxBuffer:Y}));return await aH(J,{maxBuffer:Y})}catch(H){return da(or({error:H,stream:Q,readableObjectMode:X,lines:$,encoding:q,fdNumber:Z}))}},UM=async(Q)=>{try{return await Q}catch(X){return da(X)}},da=({bufferedData:Q})=>Wi(Q)?new Uint8Array(Q):Q;import{finished as Yc0}from"node:stream/promises";var kZ=async(Q,X,J,{isSameDirection:Z,stopOnExit:q=!1}={})=>{let Y=$c0(Q,J),$=new AbortController;try{await Promise.race([...q?[J.exitPromise]:[],Yc0(Q,{cleanup:!0,signal:$.signal})])}catch(H){if(!Y.stdinCleanedUp)Wc0(H,X,J,Z)}finally{$.abort()}},$c0=(Q,{originalStreams:[X],subprocess:J})=>{let Z={stdinCleanedUp:!1};if(Q===X)Hc0(Q,J,Z);return Z},Hc0=(Q,X,J)=>{let{_destroy:Z}=Q;Q._destroy=(...q)=>{Kc0(X,J),Z.call(Q,...q)}},Kc0=({exitCode:Q,signalCode:X},J)=>{if(Q!==null||X!==null)J.stdinCleanedUp=!0},Wc0=(Q,X,J,Z)=>{if(!Vc0(Q,X,J,Z))throw Q},Vc0=(Q,X,J,Z=!0)=>{if(J.propagating)return ca(Q)||LK(Q);return J.propagating=!0,BM(J,X)===Z?ca(Q):LK(Q)},BM=({fileDescriptors:Q},X)=>X!=="all"&&Q[X].direction==="input",LK=(Q)=>Q?.code==="ERR_STREAM_PREMATURE_CLOSE",ca=(Q)=>Q?.code==="EPIPE";var la=({subprocess:Q,encoding:X,buffer:J,maxBuffer:Z,lines:q,stripFinalNewline:Y,verboseInfo:$,streamInfo:H})=>Q.stdio.map((K,V)=>LM({stream:K,fdNumber:V,encoding:X,buffer:J[V],maxBuffer:Z[V],lines:q[V],allMixed:!1,stripFinalNewline:Y,verboseInfo:$,streamInfo:H})),LM=async({stream:Q,fdNumber:X,encoding:J,buffer:Z,maxBuffer:q,lines:Y,allMixed:$,stripFinalNewline:H,verboseInfo:K,streamInfo:V})=>{if(!Q)return;let W=kZ(Q,X,V);if(BM(V,X)){await W;return}let[G]=await Promise.all([ma({stream:Q,onStreamEnd:W,fdNumber:X,encoding:J,buffer:Z,maxBuffer:q,lines:Y,allMixed:$,stripFinalNewline:H,verboseInfo:K,streamInfo:V}),W]);return G};var pa=({stdout:Q,stderr:X},{all:J})=>J&&(Q||X)?k7([Q,X].filter(Boolean)):void 0,na=({subprocess:Q,encoding:X,buffer:J,maxBuffer:Z,lines:q,stripFinalNewline:Y,verboseInfo:$,streamInfo:H})=>LM({...Gc0(Q,J),fdNumber:"all",encoding:X,maxBuffer:Z[1]+Z[2],lines:q[1]||q[2],allMixed:zc0(Q),stripFinalNewline:Y,verboseInfo:$,streamInfo:H}),Gc0=({stdout:Q,stderr:X,all:J},[,Z,q])=>{let Y=Z||q;if(!Y)return{stream:J,buffer:Y};if(!Z)return{stream:X,buffer:Y};if(!q)return{stream:Q,buffer:Y};return{stream:J,buffer:Y}},zc0=({all:Q,stdout:X,stderr:J})=>Q&&X&&J&&X.readableObjectMode!==J.readableObjectMode;import{once as Uc0}from"node:events";var ia=(Q)=>CQ(Q,"ipc"),oa=(Q,X)=>{let J=IH(Q);q8({type:"ipc",verboseMessage:J,fdNumber:"ipc",verboseInfo:X})};var ra=async({subprocess:Q,buffer:X,maxBuffer:J,ipc:Z,ipcOutput:q,verboseInfo:Y})=>{if(!Z)return q;let $=ia(Y),H=k8(X,"ipc"),K=k8(J,"ipc");for await(let V of XM({anyProcess:Q,channel:Q.channel,isSubprocess:!1,ipc:Z,shouldAwait:!1,reference:!0})){if(H)rr(Q,q,K),q.push(V);if($)oa(V,Y)}return q},sa=async(Q,X)=>{return await Promise.allSettled([Q]),X};var aa=async({subprocess:Q,options:{encoding:X,buffer:J,maxBuffer:Z,lines:q,timeoutDuration:Y,cancelSignal:$,gracefulCancel:H,forceKillAfterDelay:K,stripFinalNewline:V,ipc:W,ipcInput:G},context:z,verboseInfo:U,fileDescriptors:L,originalStreams:B,onInternalError:M,controller:I})=>{let j=es(Q,z),R={originalStreams:B,fileDescriptors:L,subprocess:Q,exitPromise:j,propagating:!1},N=la({subprocess:Q,encoding:X,buffer:J,maxBuffer:Z,lines:q,stripFinalNewline:V,verboseInfo:U,streamInfo:R}),x=na({subprocess:Q,encoding:X,buffer:J,maxBuffer:Z,lines:q,stripFinalNewline:V,verboseInfo:U,streamInfo:R}),f=[],E=ra({subprocess:Q,buffer:J,maxBuffer:Z,ipc:W,ipcOutput:f,verboseInfo:U}),l=Bc0(B,Q,R),T=Lc0(L,R);try{return await Promise.race([Promise.all([{},Xa(j),Promise.all(N),x,E,wr(Q,G),...l,...T]),M,Fc0(Q,I),...Or(Q,Y,z,I),...mo({subprocess:Q,cancelSignal:$,gracefulCancel:H,context:z,controller:I}),...Pr({subprocess:Q,cancelSignal:$,gracefulCancel:H,forceKillAfterDelay:K,context:z,controller:I})])}catch(u){return z.terminationReason??="other",Promise.all([{error:u},j,Promise.all(N.map((c)=>UM(c))),UM(x),sa(E,f),Promise.allSettled(l),Promise.allSettled(T)])}},Bc0=(Q,X,J)=>Q.map((Z,q)=>Z===X.stdio[q]?void 0:kZ(Z,q,J)),Lc0=(Q,X)=>Q.flatMap(({stdioItems:J},Z)=>J.filter(({value:q,stream:Y=q})=>v4(Y,{checkOpen:!1})&&!_4(Y)).map(({type:q,value:Y,stream:$=Y})=>kZ($,Z,X,{isSameDirection:z4.has(q),stopOnExit:q==="native"}))),Fc0=async(Q,{signal:X})=>{let[J]=await Uc0(Q,"error",{signal:X});throw J};var ta=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),yZ=(Q,X,J)=>{let Z=Q[J];if(!Z.has(X))Z.set(X,[]);let q=Z.get(X),Y=$8();return q.push(Y),{resolve:Y.resolve.bind(Y),promises:q}},vQ=async({resolve:Q,promises:X},J)=>{Q();let[Z]=await Promise.race([Promise.allSettled([!0,J]),Promise.all([!1,...X])]);return!Z};import{Readable as Mc0}from"node:stream";import{callbackify as Ic0}from"node:util";import{finished as ea}from"node:stream/promises";var FM=async(Q)=>{if(Q===void 0)return;try{await MM(Q)}catch{}},Qt=async(Q)=>{if(Q===void 0)return;try{await IM(Q)}catch{}},MM=async(Q)=>{await ea(Q,{cleanup:!0,readable:!1,writable:!0})},IM=async(Q)=>{await ea(Q,{cleanup:!0,readable:!0,writable:!1})},FK=async(Q,X)=>{if(await Q,X)throw X},MK=(Q,X,J)=>{if(J&&!LK(J))Q.destroy(J);else if(X)Q.destroy()};var Xt=({subprocess:Q,concurrentStreams:X,encoding:J},{from:Z,binary:q=!0,preserveNewlines:Y=!0}={})=>{let $=q||g6.has(J),{subprocessStdout:H,waitReadableDestroy:K}=PM(Q,Z,X),{readableEncoding:V,readableObjectMode:W,readableHighWaterMark:G}=CM(H,$),{read:z,onStdoutDataDone:U}=OM({subprocessStdout:H,subprocess:Q,binary:$,encoding:J,preserveNewlines:Y}),L=new Mc0({read:z,destroy:Ic0(NM.bind(void 0,{subprocessStdout:H,subprocess:Q,waitReadableDestroy:K})),highWaterMark:G,objectMode:W,encoding:V});return jM({subprocessStdout:H,onStdoutDataDone:U,readable:L,subprocess:Q}),L},PM=(Q,X,J)=>{let Z=DQ(Q,X),q=yZ(J,Z,"readableDestroy");return{subprocessStdout:Z,waitReadableDestroy:q}},CM=({readableEncoding:Q,readableObjectMode:X,readableHighWaterMark:J},Z)=>Z?{readableEncoding:Q,readableObjectMode:X,readableHighWaterMark:J}:{readableEncoding:Q,readableObjectMode:!0,readableHighWaterMark:zM},OM=({subprocessStdout:Q,subprocess:X,binary:J,encoding:Z,preserveNewlines:q})=>{let Y=$8(),$=BK({subprocessStdout:Q,subprocess:X,binary:J,shouldEncode:!J,encoding:Z,preserveNewlines:q});return{read(){Pc0(this,$,Y)},onStdoutDataDone:Y}},Pc0=async(Q,X,J)=>{try{let{value:Z,done:q}=await X.next();if(q)J.resolve();else Q.push(Z)}catch{}},jM=async({subprocessStdout:Q,onStdoutDataDone:X,readable:J,subprocess:Z,subprocessStdin:q})=>{try{if(await IM(Q),await Z,await FM(q),await X,J.readable)J.push(null)}catch(Y){await FM(q),Jt(J,Y)}},NM=async({subprocessStdout:Q,subprocess:X,waitReadableDestroy:J},Z)=>{if(await vQ(J,X))Jt(Q,Z),await FK(X,Z)},Jt=(Q,X)=>{MK(Q,Q.readable,X)};import{Writable as Cc0}from"node:stream";import{callbackify as Zt}from"node:util";var qt=({subprocess:Q,concurrentStreams:X},{to:J}={})=>{let{subprocessStdin:Z,waitWritableFinal:q,waitWritableDestroy:Y}=RM(Q,J,X),$=new Cc0({...DM(Z,Q,q),destroy:Zt(TM.bind(void 0,{subprocessStdin:Z,subprocess:Q,waitWritableFinal:q,waitWritableDestroy:Y})),highWaterMark:Z.writableHighWaterMark,objectMode:Z.writableObjectMode});return wM(Z,$),$},RM=(Q,X,J)=>{let Z=vH(Q,X),q=yZ(J,Z,"writableFinal"),Y=yZ(J,Z,"writableDestroy");return{subprocessStdin:Z,waitWritableFinal:q,waitWritableDestroy:Y}},DM=(Q,X,J)=>({write:Oc0.bind(void 0,Q),final:Zt(jc0.bind(void 0,Q,X,J))}),Oc0=(Q,X,J,Z)=>{if(Q.write(X,J))Z();else Q.once("drain",Z)},jc0=async(Q,X,J)=>{if(await vQ(J,X)){if(Q.writable)Q.end();await X}},wM=async(Q,X,J)=>{try{if(await MM(Q),X.writable)X.end()}catch(Z){await Qt(J),Yt(X,Z)}},TM=async({subprocessStdin:Q,subprocess:X,waitWritableFinal:J,waitWritableDestroy:Z},q)=>{if(await vQ(J,X),await vQ(Z,X))Yt(Q,q),await FK(X,q)},Yt=(Q,X)=>{MK(Q,Q.writable,X)};import{Duplex as Nc0}from"node:stream";import{callbackify as Rc0}from"node:util";var $t=({subprocess:Q,concurrentStreams:X,encoding:J},{from:Z,to:q,binary:Y=!0,preserveNewlines:$=!0}={})=>{let H=Y||g6.has(J),{subprocessStdout:K,waitReadableDestroy:V}=PM(Q,Z,X),{subprocessStdin:W,waitWritableFinal:G,waitWritableDestroy:z}=RM(Q,q,X),{readableEncoding:U,readableObjectMode:L,readableHighWaterMark:B}=CM(K,H),{read:M,onStdoutDataDone:I}=OM({subprocessStdout:K,subprocess:Q,binary:H,encoding:J,preserveNewlines:$}),j=new Nc0({read:M,...DM(W,Q,G),destroy:Rc0(Dc0.bind(void 0,{subprocessStdout:K,subprocessStdin:W,subprocess:Q,waitReadableDestroy:V,waitWritableFinal:G,waitWritableDestroy:z})),readableHighWaterMark:B,writableHighWaterMark:W.writableHighWaterMark,readableObjectMode:L,writableObjectMode:W.writableObjectMode,encoding:U});return jM({subprocessStdout:K,onStdoutDataDone:I,readable:j,subprocess:Q,subprocessStdin:W}),wM(W,j,K),j},Dc0=async({subprocessStdout:Q,subprocessStdin:X,subprocess:J,waitReadableDestroy:Z,waitWritableFinal:q,waitWritableDestroy:Y},$)=>{await Promise.all([NM({subprocessStdout:Q,subprocess:J,waitReadableDestroy:Z},$),TM({subprocessStdin:X,subprocess:J,waitWritableFinal:q,waitWritableDestroy:Y},$)])};var AM=(Q,X,{from:J,binary:Z=!1,preserveNewlines:q=!1}={})=>{let Y=Z||g6.has(X),$=DQ(Q,J),H=BK({subprocessStdout:$,subprocess:Q,binary:Y,shouldEncode:!0,encoding:X,preserveNewlines:q});return wc0(H,$,Q)},wc0=async function*(Q,X,J){try{yield*Q}finally{if(X.readable)X.destroy();await J}};var Ht=(Q,{encoding:X})=>{let J=ta();Q.readable=Xt.bind(void 0,{subprocess:Q,concurrentStreams:J,encoding:X}),Q.writable=qt.bind(void 0,{subprocess:Q,concurrentStreams:J}),Q.duplex=$t.bind(void 0,{subprocess:Q,concurrentStreams:J,encoding:X}),Q.iterable=AM.bind(void 0,Q,X),Q[Symbol.asyncIterator]=AM.bind(void 0,Q,X,{})};var Kt=(Q,X)=>{for(let[J,Z]of Ac0){let q=Z.value.bind(X);Reflect.defineProperty(Q,J,{...Z,value:q})}},Tc0=(async()=>{})().constructor.prototype,Ac0=["then","catch","finally"].map((Q)=>[Q,Reflect.getOwnPropertyDescriptor(Tc0,Q)]);var Wt=(Q,X,J,Z)=>{let{file:q,commandArguments:Y,command:$,escapedCommand:H,startTime:K,verboseInfo:V,options:W,fileDescriptors:G}=Sc0(Q,X,J),{subprocess:z,promise:U}=xc0({file:q,commandArguments:Y,options:W,startTime:K,verboseInfo:V,command:$,escapedCommand:H,fileDescriptors:G});return z.pipe=UK.bind(void 0,{source:z,sourcePromise:U,boundOptions:{},createNested:Z}),Kt(z,U),H8.set(z,{options:W,fileDescriptors:G}),z},Sc0=(Q,X,J)=>{let{command:Z,escapedCommand:q,startTime:Y,verboseInfo:$}=CH(Q,X,J),{file:H,commandArguments:K,options:V}=cH(Q,X,J),W=vc0(V),G=Fa(W,$);return{file:H,commandArguments:K,command:Z,escapedCommand:q,startTime:Y,verboseInfo:$,options:W,fileDescriptors:G}},vc0=({timeout:Q,signal:X,...J})=>{if(X!==void 0)throw TypeError('The "signal" option has been renamed to "cancelSignal" instead.');return{...J,timeoutDuration:Q}},xc0=({file:Q,commandArguments:X,options:J,startTime:Z,verboseInfo:q,command:Y,escapedCommand:$,fileDescriptors:H})=>{let K;try{K=_c0(...lH(Q,X,J))}catch(L){return za({error:L,command:Y,escapedCommand:$,fileDescriptors:H,options:J,startTime:Z,verboseInfo:q})}let V=new AbortController;Ec0(Number.POSITIVE_INFINITY,V.signal);let W=[...K.stdio];wa(K,H,V),Sa(K,J,V);let G={},z=$8();K.kill=go.bind(void 0,{kill:K.kill.bind(K),options:J,onInternalError:z,context:G,controller:V}),K.all=pa(K,J),Ht(K,J),Wa(K,J);let U=kc0({subprocess:K,options:J,startTime:Z,verboseInfo:q,fileDescriptors:H,originalStreams:W,command:Y,escapedCommand:$,context:G,onInternalError:z,controller:V});return{subprocess:K,promise:U}},kc0=async({subprocess:Q,options:X,startTime:J,verboseInfo:Z,fileDescriptors:q,originalStreams:Y,command:$,escapedCommand:H,context:K,onInternalError:V,controller:W})=>{let[G,[z,U],L,B,M]=await aa({subprocess:Q,options:X,context:K,verboseInfo:Z,fileDescriptors:q,originalStreams:Y,onInternalError:V,controller:W});W.abort(),V.resolve();let I=L.map((N,x)=>b8(N,X,x)),j=b8(B,X,"all"),R=yc0({errorInfo:G,exitCode:z,signal:U,stdio:I,all:j,ipcOutput:M,context:K,options:X,command:$,escapedCommand:H,startTime:J});return EQ(R,Z,X)},yc0=({errorInfo:Q,exitCode:X,signal:J,stdio:Z,all:q,ipcOutput:Y,context:$,options:H,command:K,escapedCommand:V,startTime:W})=>("error"in Q)?EZ({error:Q.error,command:K,escapedCommand:V,timedOut:$.terminationReason==="timeout",isCanceled:$.terminationReason==="cancel"||$.terminationReason==="gracefulCancel",isGracefullyCanceled:$.terminationReason==="gracefulCancel",isMaxBuffer:Q.error instanceof y8,isForcefullyTerminated:$.isForcefullyTerminated,exitCode:X,signal:J,stdio:Z,all:q,ipcOutput:Y,options:H,startTime:W,isSync:!1}):eH({command:K,escapedCommand:V,stdio:Z,all:q,ipcOutput:Y,options:H,startTime:W});var IK=(Q,X)=>{let J=Object.fromEntries(Object.entries(X).map(([Z,q])=>[Z,hc0(Z,Q[Z],q)]));return{...Q,...J}},hc0=(Q,X,J)=>{if(bc0.has(Q)&&j1(X)&&j1(J))return{...X,...J};return J},bc0=new Set(["env",...HF]);var R5=(Q,X,J,Z)=>{let q=($,H,K)=>R5($,H,J,K),Y=(...$)=>fc0({mapArguments:Q,deepOptions:J,boundOptions:X,setBoundExeca:Z,createNested:q},...$);if(Z!==void 0)Z(Y,q,X);return Y},fc0=({mapArguments:Q,deepOptions:X={},boundOptions:J={},setBoundExeca:Z,createNested:q},Y,...$)=>{if(j1(Y))return q(Q,IK(J,Y),Z);let{file:H,commandArguments:K,options:V,isSync:W}=gc0({mapArguments:Q,firstArgument:Y,nextArguments:$,deepOptions:X,boundOptions:J});return W?Za(H,K,V):Wt(H,K,V,q)},gc0=({mapArguments:Q,firstArgument:X,nextArguments:J,deepOptions:Z,boundOptions:q})=>{let Y=Li(X)?Fi(X,J):[X,...J],[$,H,K]=WH(...Y),V=IK(IK(Z,q),K),{file:W=$,commandArguments:G=H,options:z=V,isSync:U=!1}=Q({file:$,commandArguments:H,options:V});return{file:W,commandArguments:G,options:z,isSync:U}};var Vt=({file:Q,commandArguments:X})=>zt(Q,X),Gt=({file:Q,commandArguments:X})=>({...zt(Q,X),isSync:!0}),zt=(Q,X)=>{if(X.length>0)throw TypeError(`The command and its arguments must be passed as a single string: ${Q} ${X}.`);let[J,...Z]=uc0(Q);return{file:J,commandArguments:Z}},uc0=(Q)=>{if(typeof Q!=="string")throw TypeError(`The command must be a string: ${String(Q)}.`);let X=Q.trim();if(X==="")return[];let J=[];for(let Z of X.split(mc0)){let q=J.at(-1);if(q&&q.endsWith("\\"))J[J.length-1]=`${q.slice(0,-1)} ${Z}`;else J.push(Z)}return J},mc0=/ +/g;var Ut=(Q,X,J)=>{Q.sync=X(dc0,J),Q.s=Q.sync},Bt=({options:Q})=>Lt(Q),dc0=({options:Q})=>({...Lt(Q),isSync:!0}),Lt=(Q)=>({options:{...cc0(Q),...Q}}),cc0=({input:Q,inputFile:X,stdio:J})=>Q===void 0&&X===void 0&&J===void 0?{stdin:"inherit"}:{},Ft={preferLocal:!0};var G1=R5(()=>({})),fV1=R5(()=>({isSync:!0})),gV1=R5(Vt),uV1=R5(Gt),mV1=R5(Nr),dV1=R5(Bt,{},Ft,Ut),{sendMessage:cV1,getOneMessage:lV1,getEachMessage:pV1,getCancelSignal:nV1}=Va();import{spawnSync as lc0}from"node:child_process";var PK,Mt=!1;function It(Q){if(PK=Q,!Mt)Mt=!0,process.on("exit",()=>{EM()})}function Pt(){PK=void 0}function EM(){let Q=PK;if(Q===void 0)return!1;if(PK=void 0,process.platform==="win32")return lc0("taskkill",["/PID",String(Q),"/T","/F"],{stdio:"ignore"}),!0;try{process.kill(-Q,"SIGKILL")}catch{}return!0}import{createHash as pc0}from"node:crypto";import{existsSync as Ot,statSync as jt}from"node:fs";import{homedir as nc0}from"node:os";import{join as CK,resolve as ic0}from"node:path";function Ct(){let[Q="",X=""]=process.argv,J=(Y)=>Y.replaceAll("\\","/"),Z={type:"command",command:J(Q),args:[J(X),"internal","snapshot"]},q=[{hooks:[Z]}];return JSON.stringify({hooks:{SessionStart:[{matcher:"startup",hooks:[Z]}],UserPromptSubmit:q,Stop:q,StopFailure:q,PostToolUseFailure:q}})}var Dt={tool_search:[{name:"ENABLE_TOOL_SEARCH",value:"true"}],inherit_subagent_models:[{name:"CLAUDE_CODE_SUBAGENT_MODEL",value:"inherit"}],sync_only_bash:[{name:"CLAUDE_CODE_DISABLE_BACKGROUND_TASKS",value:"1"}],long_bash_timeouts:[{name:"BASH_DEFAULT_TIMEOUT_MS",value:"600000"},{name:"BASH_MAX_TIMEOUT_MS",value:"3600000"}]};function oc0(Q){let X={};for(let J of Q){let Z=Dt[J];if(!Z){console.warn(`Ignoring unknown env option from config: ${J}`);continue}for(let{name:q,value:Y}of Z)X[q]=Y}return X}var rc0=[/^ANTHROPIC_/,/^CLAUDE_CODE_/],sc0=new Set(["ONFRONTIER_SNAPSHOT_REPO",...Object.values(Dt).flat().map((Q)=>Q.name)]);function ac0(){let Q={};for(let[X,J]of Object.entries(process.env)){if(J===void 0)continue;if(sc0.has(X))continue;if(rc0.some((Z)=>Z.test(X)))continue;Q[X]=J}return Q}var Nt=new Map;function tc0(Q,X){let J=X??"",Z=Nt.get(J);if(!Z)Z=ec0(Q,X),Nt.set(J,Z);return Z}async function ec0(Q,X){let[J,Z]=await G1("npx",["--version"],{cwd:X}).then(({stdout:q})=>{let[Y=0,$=0]=q.trim().split(".").map((H)=>Number.parseInt(H,10)||0);return[Y,$]},()=>[0,0]);if(J>11||J===11&&Z>=17){let Y=(await G1("npm",["config","get","min-release-age-exclude"],{cwd:X}).then(({stdout:$})=>$.trim(),()=>"")).split(",").map(($)=>$.trim()).filter(($)=>$!==""&&$!=="undefined");if(!Y.includes(Q))Y.push(Q);return{npm_config_min_release_age_exclude:Y.join(",")}}if(J===11&&Z>=10)return{npm_config_min_release_age:"0"};return{}}async function OK(Q,X=[]){let J=`${Q.modelId}[1m]`,Z={...oc0(Q.envOptions??[]),ANTHROPIC_BASE_URL:l1.router.url,ANTHROPIC_AUTH_TOKEN:Q.apiKey,ANTHROPIC_MODEL:J,DISABLE_AUTOUPDATER:"1",CLAUDE_CODE_AUTO_MODE_SERVER:"0",CLAUDE_CODE_MAX_OUTPUT_TOKENS:"64000",...Q.snapshotRepo?{ONFRONTIER_SNAPSHOT_REPO:"1"}:{},...await tc0(Q.clientType,Q.cwd)},q=["--model",J,"--settings",Ct()];if(Q.sessionId)q.push("--session-id",Q.sessionId);if(Q.skipPermissions)q.push("--dangerously-skip-permissions");else q.push("--permission-mode","auto");if(Q.disallowedTools&&Q.disallowedTools.length>0)q.push("--disallowedTools",...Q.disallowedTools);if(Q.headlessLogFiles)q.push("-p","--output-format","json");let Y=Q.headlessLogFiles?{input:Q.initialPrompt??"",stdout:{file:Q.headlessLogFiles.stdout},stderr:{file:Q.headlessLogFiles.stderr}}:{stdio:"inherit"},$=Date.now(),H=`${Q.clientType}@${Q.clientVersion}`,K=["--yes",H,...q,...X],V={...Y,env:{...ac0(),...Z},cwd:Q.cwd,reject:!1,detached:Q.headlessLogFiles!==void 0&&process.platform!=="win32"},W=async()=>{let z=G1("npx",K,V);if(Q.headlessLogFiles)It(z.pid);try{return await z}finally{Pt()}},G=await W();if(typeof G.exitCode==="number"&&G.exitCode!==0&&!G.signal&&await Ql0(Q.clientType,H,Q.cwd))G=await W();return{exitCode:G.exitCode,signal:G.signal,durationMs:Date.now()-$}}var Rt=1e6;async function Ql0(Q,X,J){try{let Z=[process.env.npm_config_cache,process.env.NPM_CONFIG_CACHE].find((V)=>V!==void 0&&V!==""),q=Z===void 0?(await G1("npm",["config","get","cache"],{cwd:J})).stdout.trim():Xl0(Z,J),Y=pc0("sha512").update(X).digest("hex").slice(0,16),$=CK(q,"_npx",Y,"node_modules",...Q.split("/")),H=CK($,"bin","claude.exe"),K=CK($,"install.cjs");if(!Ot(H)||!Ot(K))return!1;if(jt(H).size>Rt)return!1;return console.warn("The coding client was installed without its native binary (npm 12 skips install scripts). Repairing the install and retrying…"),await G1("node",[K]),jt(H).size>Rt}catch{return!1}}function Xl0(Q,X){let J=Jl0(Q),Z=J==="~"||J.startsWith("~/")||J.startsWith("~\\")?CK(nc0(),J.slice(1)):J;return ic0(X??process.cwd(),Z)}function Jl0(Q){return Q.replace(/(\\*)\$\{([^${}]+)\}/g,(X,J,Z)=>{if(J.length%2===1)return X.slice((J.length+1)/2);let q=process.env[Z];return q===void 0?X:J.slice(J.length/2)+q})}async function _t(Q,X){let J=Q.headless_spec;if(!J||Q.models.length!==2)f0("This headless task is missing its launch spec or model pair. Contact support@onfrontier.ai."),process.exit(1);let Z=J.task_prompt;if(!Z.trim())f0("This headless task has an empty prompt. Contact support@onfrontier.ai."),process.exit(1);let q=Q.task_id.replaceAll(/[^A-Za-z\d._-]+/g,"-"),Y=D5(process.cwd(),`${Ll0(J.github_url)}-${q}`);if(ql0(Y)&&Yl0(Y).length>0)f0(`Run folder already exists: ${Y}
158
- Each comparison starts from fresh folders; rename or delete this folder, then run again.`),process.exit(1);wt(Y,{recursive:!0});let $=D5(Y,"source"),H=process.platform==="win32"?["-c","core.longpaths=true"]:[],K=V4();K.start(`Cloning ${J.github_url}`);try{await G1("git",["clone",...H,"--quiet","--branch",J.branch,J.github_url,$]),await G1("git",["checkout","--quiet","--detach",J.commit_hash],{cwd:$})}catch(p){K.stop("Failed to prepare the task repository"),f0(`${p.message}
159
- The task record's repository, branch, or starting commit could not be prepared. Contact support@onfrontier.ai.`),process.exit(1)}let V=await Fl0($);if(!V)K.stop("Failed to prepare the task repository"),f0(`Could not resolve the starting commit in ${$}.`),process.exit(1);K.stop(`Cloned the task repository at ${V.slice(0,12)}`);let W=Q.models.map((p,Y0)=>({modelId:p,runDir:D5(Y,`run-${Y0+1}-${p}`),sessionId:Zl0()})),G=V4();G.start("Preparing isolated run folders");try{for(let p of W)await G1("git",["clone",...H,"--quiet",$,p.runDir]),await G1("git",["checkout","--quiet","--detach",V],{cwd:p.runDir})}catch(p){G.stop("Failed to prepare run folders"),f0(p.message),process.exit(1)}G.stop(`Cloned the starting state (${V.slice(0,12)}) into two run folders`);let z=new Map;try{for(let p of W){let Y0=await H6.createRouterKey(Q.task_id,p.modelId);z.set(p.modelId,Y0.key)}}catch(p){f0(`Could not prepare the runs.
157
+ if (condition) { yield value; }`)};import{Buffer as Km0}from"node:buffer";import{StringDecoder as Wm0}from"node:string_decoder";var YK=(Q,X,J)=>{if(J)return;if(Q)return{transform:Vm0.bind(void 0,new TextEncoder)};let Z=new Wm0(X);return{transform:Gm0.bind(void 0,Z),final:zm0.bind(void 0,Z)}},Vm0=function*(Q,X){if(Km0.isBuffer(X))yield x8(X);else if(typeof X==="string")yield Q.encode(X);else yield X},Gm0=function*(Q,X){yield v1(X)?Q.write(X):X},zm0=function*(Q){let X=Q.end();if(X!=="")yield X};import{callbackify as ms}from"node:util";var rF=ms(async(Q,X,J,Z)=>{X.currentIterable=Q(...J);try{for await(let q of X.currentIterable)Z.push(q)}finally{delete X.currentIterable}}),$K=async function*(Q,X,J){if(J===X.length){yield Q;return}let{transform:Z=Bm0}=X[J];for await(let q of Z(Q))yield*$K(q,X,J+1)},ds=async function*(Q){for(let[X,{final:J}]of Object.entries(Q))yield*Um0(J,Number(X),Q)},Um0=async function*(Q,X,J){if(Q===void 0)return;for await(let Z of Q())yield*$K(Z,J,X+1)},cs=ms(async({currentIterable:Q},X)=>{if(Q!==void 0){await(X?Q.throw(X):Q.return());return}if(X)throw X}),Bm0=function*(Q){yield Q};var sF=(Q,X,J,Z)=>{try{for(let q of Q(...X))J.push(q);Z()}catch(q){Z(q)}},ls=(Q,X)=>[...X.flatMap((J)=>[...x7(J,Q,0)]),..._Z(Q)],x7=function*(Q,X,J){if(J===X.length){yield Q;return}let{transform:Z=Fm0}=X[J];for(let q of Z(Q))yield*x7(q,X,J+1)},_Z=function*(Q){for(let[X,{final:J}]of Object.entries(Q))yield*Lm0(J,Number(X),Q)},Lm0=function*(Q,X,J){if(Q===void 0)return;for(let Z of Q())yield*x7(Z,J,X+1)},Fm0=function*(Q){yield Q};var aF=({value:Q,value:{transform:X,final:J,writableObjectMode:Z,readableObjectMode:q},optionName:Y},{encoding:$})=>{let H={},K=ns(Q,$,Y),V=v7(X),W=v7(J),G=V?rF.bind(void 0,$K,H):sF.bind(void 0,x7),z=V||W?rF.bind(void 0,ds,H):sF.bind(void 0,_Z),U=V||W?cs.bind(void 0,H):void 0;return{stream:new Mm0({writableObjectMode:Z,writableHighWaterMark:ps(Z),readableObjectMode:q,readableHighWaterMark:ps(q),transform(B,M,I){G([B,K,0],this,I)},flush(B){z([K],this,B)},destroy:U})}},HK=(Q,X,J,Z)=>{let q=X.filter(({type:$})=>$==="generator"),Y=Z?q.reverse():q;for(let{value:$,optionName:H}of Y){let K=ns($,J,H);Q=ls(K,Q)}return Q},ns=({transform:Q,final:X,binary:J,writableObjectMode:Z,readableObjectMode:q,preserveNewlines:Y},$,H)=>{let K={};return[{transform:fs(Z,H)},YK(J,$,Z),qK(J,Y,Z,K),{transform:Q,final:X},{transform:gs(q,H)},bs({binary:J,preserveNewlines:Y,readableObjectMode:q,state:K})].filter(Boolean)};var is=(Q,X)=>{for(let J of Im0(Q))Pm0(Q,J,X)},Im0=(Q)=>new Set(Object.entries(Q).filter(([,{direction:X}])=>X==="input").map(([X])=>Number(X))),Pm0=(Q,X,J)=>{let{stdioItems:Z}=Q[X],q=Z.filter(({contents:H})=>H!==void 0);if(q.length===0)return;if(X!==0){let[{type:H,optionName:K}]=q;throw TypeError(`Only the \`stdin\` option, not \`${K}\`, can be ${N5[H]} with synchronous methods.`)}let $=q.map(({contents:H})=>H).map((H)=>Cm0(H,Z));J.input=jZ($)},Cm0=(Q,X)=>{let J=HK(Q,X,"utf8",!0);return Om0(J),jZ(J)},Om0=(Q)=>{let X=Q.find((J)=>typeof J!=="string"&&!v1(J));if(X!==void 0)throw TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${X}.`)};import{writeFileSync as Dm0,appendFileSync as wm0}from"node:fs";var KK=({stdioItems:Q,encoding:X,verboseInfo:J,fdNumber:Z})=>Z!=="all"&&CQ(J,Z)&&!g6.has(X)&&jm0(Z)&&(Q.some(({type:q,value:Y})=>q==="native"&&Nm0.has(Y))||Q.every(({type:q})=>z4.has(q))),jm0=(Q)=>Q===1||Q===2,Nm0=new Set(["pipe","overlapped"]),os=async(Q,X,J,Z)=>{for await(let q of Q)if(!Rm0(X))ss(q,J,Z)},rs=(Q,X,J)=>{for(let Z of Q)ss(Z,X,J)},Rm0=(Q)=>Q._readableState.pipes.length>0,ss=(Q,X,J)=>{let Z=IH(Q);q8({type:"output",verboseMessage:Z,fdNumber:X,verboseInfo:J})};var as=({fileDescriptors:Q,syncResult:{output:X},options:J,isMaxBuffer:Z,verboseInfo:q})=>{if(X===null)return{output:Array.from({length:3})};let Y={},$=new Set([]);return{output:X.map((K,V)=>Tm0({result:K,fileDescriptors:Q,fdNumber:V,state:Y,outputFiles:$,isMaxBuffer:Z,verboseInfo:q},J)),...Y}},Tm0=({result:Q,fileDescriptors:X,fdNumber:J,state:Z,outputFiles:q,isMaxBuffer:Y,verboseInfo:$},{buffer:H,encoding:K,lines:V,stripFinalNewline:W,maxBuffer:G})=>{if(Q===null)return;let z=tr(Q,Y,G),U=x8(z),{stdioItems:L,objectMode:B}=X[J],M=Am0([U],L,K,Z),{serializedResult:I,finalResult:j=I}=Em0({chunks:M,objectMode:B,encoding:K,lines:V,stripFinalNewline:W,fdNumber:J});_m0({serializedResult:I,fdNumber:J,state:Z,verboseInfo:$,encoding:K,stdioItems:L,objectMode:B});let R=H[J]?j:void 0;try{if(Z.error===void 0)Sm0(I,L,q);return R}catch(N){return Z.error=N,R}},Am0=(Q,X,J,Z)=>{try{return HK(Q,X,J,!1)}catch(q){return Z.error=q,Q}},Em0=({chunks:Q,objectMode:X,encoding:J,lines:Z,stripFinalNewline:q,fdNumber:Y})=>{if(X)return{serializedResult:Q};if(J==="buffer")return{serializedResult:jZ(Q)};let $=Gi(Q,J);if(Z[Y])return{serializedResult:$,finalResult:oF($,!q[Y],X)};return{serializedResult:$}},_m0=({serializedResult:Q,fdNumber:X,state:J,verboseInfo:Z,encoding:q,stdioItems:Y,objectMode:$})=>{if(!KK({stdioItems:Y,encoding:q,verboseInfo:Z,fdNumber:X}))return;let H=oF(Q,!1,$);try{rs(H,X,Z)}catch(K){J.error??=K}},Sm0=(Q,X,J)=>{for(let{path:Z,append:q}of X.filter(({type:Y})=>JK.has(Y))){let Y=typeof Z==="string"?Z:Z.toString();if(q||J.has(Y))wm0(Z,Q);else J.add(Y),Dm0(Z,Q)}};var ts=([,Q,X],J)=>{if(!J.all)return;if(Q===void 0)return X;if(X===void 0)return Q;if(Array.isArray(Q))return Array.isArray(X)?[...Q,...X]:[...Q,b8(X,J,"all")];if(Array.isArray(X))return[b8(Q,J,"all"),...X];if(v1(Q)&&v1(X))return ZF([Q,X]);return`${Q}${X}`};import{once as tF}from"node:events";var es=async(Q,X)=>{let[J,Z]=await vm0(Q);return X.isForcefullyTerminated??=!1,[J,Z]},vm0=async(Q)=>{let[X,J]=await Promise.allSettled([tF(Q,"spawn"),tF(Q,"exit")]);if(X.status==="rejected")return[];return J.status==="rejected"?Qa(Q):J.value},Qa=async(Q)=>{try{return await tF(Q,"exit")}catch{return Qa(Q)}},Xa=async(Q)=>{let[X,J]=await Q;if(!xm0(X,J)&&eF(X,J))throw new Y8;return[X,J]},xm0=(Q,X)=>Q===void 0&&X===void 0,eF=(Q,X)=>Q!==0||X!==null;var Ja=({error:Q,status:X,signal:J,output:Z},{maxBuffer:q})=>{let Y=km0(Q,X,J),$=Y?.code==="ETIMEDOUT",H=ar(Y,Z,q);return{resultError:Y,exitCode:X,signal:J,timedOut:$,isMaxBuffer:H}},km0=(Q,X,J)=>{if(Q!==void 0)return Q;return eF(X,J)?new Y8:void 0};var Za=(Q,X,J)=>{let{file:Z,commandArguments:q,command:Y,escapedCommand:$,startTime:H,verboseInfo:K,options:V,fileDescriptors:W}=hm0(Q,X,J),G=gm0({file:Z,commandArguments:q,options:V,command:Y,escapedCommand:$,verboseInfo:K,fileDescriptors:W,startTime:H});return EQ(G,K,V)},hm0=(Q,X,J)=>{let{command:Z,escapedCommand:q,startTime:Y,verboseInfo:$}=CH(Q,X,J),H=bm0(J),{file:K,commandArguments:V,options:W}=cH(Q,X,H);fm0(W);let G=xs(W,$);return{file:K,commandArguments:V,command:Z,escapedCommand:q,startTime:Y,verboseInfo:$,options:W,fileDescriptors:G}},bm0=(Q)=>Q.node&&!Q.ipc?{...Q,ipc:!1}:Q,fm0=({ipc:Q,ipcInput:X,detached:J,cancelSignal:Z})=>{if(X)WK("ipcInput");if(Q)WK("ipc: true");if(J)WK("detached: true");if(Z)WK("cancelSignal")},WK=(Q)=>{throw TypeError(`The "${Q}" option cannot be used with synchronous methods.`)},gm0=({file:Q,commandArguments:X,options:J,command:Z,escapedCommand:q,verboseInfo:Y,fileDescriptors:$,startTime:H})=>{let K=um0({file:Q,commandArguments:X,options:J,command:Z,escapedCommand:q,fileDescriptors:$,startTime:H});if(K.failed)return K;let{resultError:V,exitCode:W,signal:G,timedOut:z,isMaxBuffer:U}=Ja(K,J),{output:L,error:B=V}=as({fileDescriptors:$,syncResult:K,options:J,isMaxBuffer:U,verboseInfo:Y}),M=L.map((j,R)=>b8(j,J,R)),I=b8(ts(L,J),J,"all");return dm0({error:B,exitCode:W,signal:G,timedOut:z,isMaxBuffer:U,stdio:M,all:I,options:J,command:Z,escapedCommand:q,startTime:H})},um0=({file:Q,commandArguments:X,options:J,command:Z,escapedCommand:q,fileDescriptors:Y,startTime:$})=>{try{is(Y,J);let H=mm0(J);return ym0(...lH(Q,X,H))}catch(H){return AQ({error:H,command:Z,escapedCommand:q,fileDescriptors:Y,options:J,startTime:$,isSync:!0})}},mm0=({encoding:Q,maxBuffer:X,...J})=>({...J,encoding:"buffer",maxBuffer:tH(X)}),dm0=({error:Q,exitCode:X,signal:J,timedOut:Z,isMaxBuffer:q,stdio:Y,all:$,options:H,command:K,escapedCommand:V,startTime:W})=>Q===void 0?eH({command:K,escapedCommand:V,stdio:Y,all:$,ipcOutput:[],options:H,startTime:W}):EZ({error:Q,command:K,escapedCommand:V,timedOut:Z,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:q,isForcefullyTerminated:!1,exitCode:X,signal:J,stdio:Y,all:$,ipcOutput:[],options:H,startTime:W,isSync:!0});import{setMaxListeners as Ec0}from"node:events";import{spawn as _c0}from"node:child_process";import Ka from"node:process";import{once as QM,on as cm0}from"node:events";var qa=({anyProcess:Q,channel:X,isSubprocess:J,ipc:Z},{reference:q=!0,filter:Y}={})=>{return NQ({methodName:"getOneMessage",isSubprocess:J,ipc:Z,isConnected:bH(Q)}),lm0({anyProcess:Q,channel:X,isSubprocess:J,filter:Y,reference:q})},lm0=async({anyProcess:Q,channel:X,isSubprocess:J,filter:Z,reference:q})=>{xH(X,q);let Y=j5(Q,X,J),$=new AbortController;try{return await Promise.race([pm0(Y,Z,$),nm0(Y,J,$),im0(Y,J,$)])}catch(H){throw RQ(Q),H}finally{$.abort(),kH(X,q)}},pm0=async(Q,X,{signal:J})=>{if(X===void 0){let[Z]=await QM(Q,"message",{signal:J});return Z}for await(let[Z]of cm0(Q,"message",{signal:J}))if(X(Z))return Z},nm0=async(Q,X,{signal:J})=>{await QM(Q,"disconnect",{signal:J}),co(X)},im0=async(Q,X,{signal:J})=>{let[Z]=await QM(Q,"strict:error",{signal:J});throw _H(Z,X)};import{once as $a,on as om0}from"node:events";var Ha=({anyProcess:Q,channel:X,isSubprocess:J,ipc:Z},{reference:q=!0}={})=>XM({anyProcess:Q,channel:X,isSubprocess:J,ipc:Z,shouldAwait:!J,reference:q}),XM=({anyProcess:Q,channel:X,isSubprocess:J,ipc:Z,shouldAwait:q,reference:Y})=>{NQ({methodName:"getEachMessage",isSubprocess:J,ipc:Z,isConnected:bH(Q)}),xH(X,Y);let $=j5(Q,X,J),H=new AbortController,K={};return rm0(Q,$,H),sm0({ipcEmitter:$,isSubprocess:J,controller:H,state:K}),am0({anyProcess:Q,channel:X,ipcEmitter:$,isSubprocess:J,shouldAwait:q,controller:H,state:K,reference:Y})},rm0=async(Q,X,J)=>{try{await $a(X,"disconnect",{signal:J.signal}),J.abort()}catch{}},sm0=async({ipcEmitter:Q,isSubprocess:X,controller:J,state:Z})=>{try{let[q]=await $a(Q,"strict:error",{signal:J.signal});Z.error=_H(q,X),J.abort()}catch{}},am0=async function*({anyProcess:Q,channel:X,ipcEmitter:J,isSubprocess:Z,shouldAwait:q,controller:Y,state:$,reference:H}){try{for await(let[K]of om0(J,"message",{signal:Y.signal}))Ya($),yield K}catch{Ya($)}finally{if(Y.abort(),kH(X,H),!Z)RQ(Q);if(q)await Q}},Ya=({error:Q})=>{if(Q)throw Q};var Wa=(Q,{ipc:X})=>{Object.assign(Q,Ga(Q,!1,X))},Va=()=>{let Q=Ka,X=!0,J=Ka.channel!==void 0;return{...Ga(Q,!0,J),getCancelSignal:Fr.bind(void 0,{anyProcess:Q,channel:Q.channel,isSubprocess:!0,ipc:J})}},Ga=(Q,X,J)=>({sendMessage:mH.bind(void 0,{anyProcess:Q,channel:Q.channel,isSubprocess:X,ipc:J}),getOneMessage:qa.bind(void 0,{anyProcess:Q,channel:Q.channel,isSubprocess:X,ipc:J}),getEachMessage:Ha.bind(void 0,{anyProcess:Q,channel:Q.channel,isSubprocess:X,ipc:J})});import{ChildProcess as tm0}from"node:child_process";import{PassThrough as em0,Readable as Qd0,Writable as Xd0,Duplex as Jd0}from"node:stream";var za=({error:Q,command:X,escapedCommand:J,fileDescriptors:Z,options:q,startTime:Y,verboseInfo:$})=>{pF(Z);let H=new tm0;Zd0(H,Z),Object.assign(H,{readable:qd0,writable:Yd0,duplex:$d0});let K=AQ({error:Q,command:X,escapedCommand:J,fileDescriptors:Z,options:q,startTime:Y,isSync:!1}),V=Hd0(K,$,q);return{subprocess:H,promise:V}},Zd0=(Q,X)=>{let J=SZ(),Z=SZ(),q=SZ(),Y=Array.from({length:X.length-3},SZ),$=SZ(),H=[J,Z,q,...Y];Object.assign(Q,{stdin:J,stdout:Z,stderr:q,all:$,stdio:H})},SZ=()=>{let Q=new em0;return Q.end(),Q},qd0=()=>new Qd0({read(){}}),Yd0=()=>new Xd0({write(){}}),$d0=()=>new Jd0({read(){},write(){}}),Hd0=async(Q,X,J)=>EQ(Q,X,J);import{createReadStream as Ua,createWriteStream as Ba}from"node:fs";import{Buffer as Kd0}from"node:buffer";import{Readable as vZ,Writable as Wd0,Duplex as Vd0}from"node:stream";var Fa=(Q,X)=>ZK(Gd0,Q,X,!1),xZ=({type:Q,optionName:X})=>{throw TypeError(`The \`${X}\` option cannot be ${N5[Q]}.`)},La={fileNumber:xZ,generator:aF,asyncGenerator:aF,nodeStream:({value:Q})=>({stream:Q}),webTransform({value:{transform:Q,writableObjectMode:X,readableObjectMode:J}}){let Z=X||J;return{stream:Vd0.fromWeb(Q,{objectMode:Z})}},duplex:({value:{transform:Q}})=>({stream:Q}),native(){}},Gd0={input:{...La,fileUrl:({value:Q})=>({stream:Ua(Q)}),filePath:({value:{file:Q}})=>({stream:Ua(Q)}),webStream:({value:Q})=>({stream:vZ.fromWeb(Q)}),iterable:({value:Q})=>({stream:vZ.from(Q)}),asyncIterable:({value:Q})=>({stream:vZ.from(Q)}),string:({value:Q})=>({stream:vZ.from(Q)}),uint8Array:({value:Q})=>({stream:vZ.from(Kd0.from(Q))})},output:{...La,fileUrl:({value:Q})=>({stream:Ba(Q)}),filePath:({value:{file:Q,append:X}})=>({stream:Ba(Q,X?{flags:"a"}:{})}),webStream:({value:Q})=>({stream:Wd0.fromWeb(Q)}),iterable:xZ,asyncIterable:xZ,string:xZ,uint8Array:xZ}};import{on as zd0,once as Ma}from"node:events";import{PassThrough as Ud0,getDefaultHighWaterMark as Bd0}from"node:stream";import{finished as Ca}from"node:stream/promises";function k7(Q){if(!Array.isArray(Q))throw TypeError(`Expected an array, got \`${typeof Q}\`.`);for(let q of Q)JM(q);let X=Q.some(({readableObjectMode:q})=>q),J=Ld0(Q,X),Z=new Oa({objectMode:X,writableHighWaterMark:J,readableHighWaterMark:J});for(let q of Q)Z.add(q);return Z}var Ld0=(Q,X)=>{if(Q.length===0)return Bd0(X);let J=Q.filter(({readableObjectMode:Z})=>Z===X).map(({readableHighWaterMark:Z})=>Z);return Math.max(...J)};class Oa extends Ud0{#X=new Set([]);#Z=new Set([]);#J=new Set([]);#Q;#q=Symbol("unpipe");#V=new WeakMap;add(Q){if(JM(Q),this.#X.has(Q))return;this.#X.add(Q),this.#Q??=Fd0(this,this.#X,this.#q);let X=Pd0({passThroughStream:this,stream:Q,streams:this.#X,ended:this.#Z,aborted:this.#J,onFinished:this.#Q,unpipeEvent:this.#q});this.#V.set(Q,X),Q.pipe(this,{end:!1})}async remove(Q){if(JM(Q),!this.#X.has(Q))return!1;let X=this.#V.get(Q);if(X===void 0)return!1;return this.#V.delete(Q),Q.unpipe(this),await X,!0}}var Fd0=async(Q,X,J)=>{VK(Q,Ia);let Z=new AbortController;try{await Promise.race([Md0(Q,Z),Id0(Q,X,J,Z)])}finally{Z.abort(),VK(Q,-Ia)}},Md0=async(Q,{signal:X})=>{try{await Ca(Q,{signal:X,cleanup:!0})}catch(J){throw ja(Q,J),J}},Id0=async(Q,X,J,{signal:Z})=>{for await(let[q]of zd0(Q,"unpipe",{signal:Z}))if(X.has(q))q.emit(J)},JM=(Q)=>{if(typeof Q?.pipe!=="function")throw TypeError(`Expected a readable stream, got: \`${typeof Q}\`.`)},Pd0=async({passThroughStream:Q,stream:X,streams:J,ended:Z,aborted:q,onFinished:Y,unpipeEvent:$})=>{VK(Q,Pa);let H=new AbortController;try{await Promise.race([Cd0(Y,X,H),Od0({passThroughStream:Q,stream:X,streams:J,ended:Z,aborted:q,controller:H}),jd0({stream:X,streams:J,ended:Z,aborted:q,unpipeEvent:$,controller:H})])}finally{H.abort(),VK(Q,-Pa)}if(J.size>0&&J.size===Z.size+q.size)if(Z.size===0&&q.size>0)ZM(Q);else Nd0(Q)},Cd0=async(Q,X,{signal:J})=>{try{if(await Q,!J.aborted)ZM(X)}catch(Z){if(!J.aborted)ja(X,Z)}},Od0=async({passThroughStream:Q,stream:X,streams:J,ended:Z,aborted:q,controller:{signal:Y}})=>{try{if(await Ca(X,{signal:Y,cleanup:!0,readable:!0,writable:!1}),J.has(X))Z.add(X)}catch($){if(Y.aborted||!J.has(X))return;if(Na($))q.add(X);else Ra(Q,$)}},jd0=async({stream:Q,streams:X,ended:J,aborted:Z,unpipeEvent:q,controller:{signal:Y}})=>{if(await Ma(Q,q,{signal:Y}),!Q.readable)return Ma(Y,"abort",{signal:Y});X.delete(Q),J.delete(Q),Z.delete(Q)},Nd0=(Q)=>{if(Q.writable)Q.end()},ja=(Q,X)=>{if(Na(X))ZM(Q);else Ra(Q,X)},Na=(Q)=>Q?.code==="ERR_STREAM_PREMATURE_CLOSE",ZM=(Q)=>{if(Q.readable||Q.writable)Q.destroy()},Ra=(Q,X)=>{if(!Q.destroyed)Q.once("error",Rd0),Q.destroy(X)},Rd0=()=>{},VK=(Q,X)=>{let J=Q.getMaxListeners();if(J!==0&&J!==Number.POSITIVE_INFINITY)Q.setMaxListeners(J+X)},Ia=2,Pa=1;import{finished as Da}from"node:stream/promises";var SQ=(Q,X)=>{Q.pipe(X),Dd0(Q,X),wd0(Q,X)},Dd0=async(Q,X)=>{if(_4(Q)||_4(X))return;try{await Da(Q,{cleanup:!0,readable:!0,writable:!1})}catch{}qM(X)},qM=(Q)=>{if(Q.writable)Q.end()},wd0=async(Q,X)=>{if(_4(Q)||_4(X))return;try{await Da(X,{cleanup:!0,readable:!1,writable:!0})}catch{}YM(Q)},YM=(Q)=>{if(Q.readable)Q.destroy()};var wa=(Q,X,J)=>{let Z=new Map;for(let[q,{stdioItems:Y,direction:$}]of Object.entries(X)){for(let{stream:H}of Y.filter(({type:K})=>z4.has(K)))Td0(Q,H,$,q);for(let{stream:H}of Y.filter(({type:K})=>!z4.has(K)))Ed0({subprocess:Q,stream:H,direction:$,fdNumber:q,pipeGroups:Z,controller:J})}for(let[q,Y]of Z.entries()){let $=Y.length===1?Y[0]:k7(Y);SQ($,q)}},Td0=(Q,X,J,Z)=>{if(J==="output")SQ(Q.stdio[Z],X);else SQ(X,Q.stdio[Z]);let q=Ad0[Z];if(q!==void 0)Q[q]=X;Q.stdio[Z]=X},Ad0=["stdin","stdout","stderr"],Ed0=({subprocess:Q,stream:X,direction:J,fdNumber:Z,pipeGroups:q,controller:Y})=>{if(X===void 0)return;_d0(X,Y);let[$,H]=J==="output"?[X,Q.stdio[Z]]:[Q.stdio[Z],X],K=q.get($)??[];q.set($,[...K,H])},_d0=(Q,{signal:X})=>{if(_4(Q))_7(Q,Sd0,X)},Sd0=2;import{addAbortListener as kd0}from"node:events";var y7=[];y7.push("SIGHUP","SIGINT","SIGTERM");if(process.platform!=="win32")y7.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")y7.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var GK=(Q)=>!!Q&&typeof Q==="object"&&typeof Q.removeListener==="function"&&typeof Q.emit==="function"&&typeof Q.reallyExit==="function"&&typeof Q.listeners==="function"&&typeof Q.kill==="function"&&typeof Q.pid==="number"&&typeof Q.on==="function",$M=Symbol.for("signal-exit emitter"),HM=globalThis,vd0=Object.defineProperty.bind(Object);class Ta{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(HM[$M])return HM[$M];vd0(HM,$M,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(Q,X){this.listeners[Q].push(X)}removeListener(Q,X){let J=this.listeners[Q],Z=J.indexOf(X);if(Z===-1)return;if(Z===0&&J.length===1)J.length=0;else J.splice(Z,1)}emit(Q,X,J){if(this.emitted[Q])return!1;this.emitted[Q]=!0;let Z=!1;for(let q of this.listeners[Q])Z=q(X,J)===!0||Z;if(Q==="exit")Z=this.emit("afterExit",X,J)||Z;return Z}}class WM{}var xd0=(Q)=>{return{onExit(X,J){return Q.onExit(X,J)},load(){return Q.load()},unload(){return Q.unload()}}};class Aa extends WM{onExit(){return()=>{}}load(){}unload(){}}class Ea extends WM{#X=KM.platform==="win32"?"SIGINT":"SIGHUP";#Z=new Ta;#J;#Q;#q;#V={};#W=!1;constructor(Q){super();this.#J=Q,this.#V={};for(let X of y7)this.#V[X]=()=>{let J=this.#J.listeners(X),{count:Z}=this.#Z,q=Q;if(typeof q.__signal_exit_emitter__==="object"&&typeof q.__signal_exit_emitter__.count==="number")Z+=q.__signal_exit_emitter__.count;if(J.length===Z){this.unload();let Y=this.#Z.emit("exit",null,X),$=X==="SIGHUP"?this.#X:X;if(!Y)Q.kill(Q.pid,$)}};this.#q=Q.reallyExit,this.#Q=Q.emit}onExit(Q,X){if(!GK(this.#J))return()=>{};if(this.#W===!1)this.load();let J=X?.alwaysLast?"afterExit":"exit";return this.#Z.on(J,Q),()=>{if(this.#Z.removeListener(J,Q),this.#Z.listeners.exit.length===0&&this.#Z.listeners.afterExit.length===0)this.unload()}}load(){if(this.#W)return;this.#W=!0,this.#Z.count+=1;for(let Q of y7)try{let X=this.#V[Q];if(X)this.#J.on(Q,X)}catch(X){}this.#J.emit=(Q,...X)=>{return this.#K(Q,...X)},this.#J.reallyExit=(Q)=>{return this.#G(Q)}}unload(){if(!this.#W)return;this.#W=!1,y7.forEach((Q)=>{let X=this.#V[Q];if(!X)throw Error("Listener not defined for signal: "+Q);try{this.#J.removeListener(Q,X)}catch(J){}}),this.#J.emit=this.#Q,this.#J.reallyExit=this.#q,this.#Z.count-=1}#G(Q){if(!GK(this.#J))return 0;return this.#J.exitCode=Q||0,this.#Z.emit("exit",this.#J.exitCode,null),this.#q.call(this.#J,this.#J.exitCode)}#K(Q,...X){let J=this.#Q;if(Q==="exit"&&GK(this.#J)){if(typeof X[0]==="number")this.#J.exitCode=X[0];let Z=J.call(this.#J,Q,...X);return this.#Z.emit("exit",this.#J.exitCode,null),Z}else return J.call(this.#J,Q,...X)}}var KM=globalThis.process,{onExit:_a,load:oH1,unload:rH1}=xd0(GK(KM)?new Ea(KM):new Aa);var Sa=(Q,{cleanup:X,detached:J},{signal:Z})=>{if(!X||J)return;let q=_a(()=>{Q.kill()});kd0(Z,()=>{q()})};var xa=({source:Q,sourcePromise:X,boundOptions:J,createNested:Z},...q)=>{let Y=PH(),{destination:$,destinationStream:H,destinationError:K,from:V,unpipeSignal:W}=yd0(J,Z,q),{sourceStream:G,sourceError:z}=bd0(Q,V),{options:U,fileDescriptors:L}=H8.get(Q);return{sourcePromise:X,sourceStream:G,sourceOptions:U,sourceError:z,destination:$,destinationStream:H,destinationError:K,unpipeSignal:W,fileDescriptors:L,startTime:Y}},yd0=(Q,X,J)=>{try{let{destination:Z,pipeOptions:{from:q,to:Y,unpipeSignal:$}={}}=hd0(Q,X,...J),H=vH(Z,Y);return{destination:Z,destinationStream:H,from:q,unpipeSignal:$}}catch(Z){return{destinationError:Z}}},hd0=(Q,X,J,...Z)=>{if(Array.isArray(J))return{destination:X(va,Q)(J,...Z),pipeOptions:Q};if(typeof J==="string"||J instanceof URL||XF(J)){if(Object.keys(Q).length>0)throw TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[q,Y,$]=WH(J,...Z);return{destination:X(va)(q,Y,$),pipeOptions:$}}if(H8.has(J)){if(Object.keys(Q).length>0)throw TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:J,pipeOptions:Z[0]}}throw TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${J}`)},va=({options:Q})=>({options:{...Q,stdin:"pipe",piped:!0}}),bd0=(Q,X)=>{try{return{sourceStream:DQ(Q,X)}}catch(J){return{sourceError:J}}};var ya=({sourceStream:Q,sourceError:X,destinationStream:J,destinationError:Z,fileDescriptors:q,sourceOptions:Y,startTime:$})=>{let H=fd0({sourceStream:Q,sourceError:X,destinationStream:J,destinationError:Z});if(H!==void 0)throw VM({error:H,fileDescriptors:q,sourceOptions:Y,startTime:$})},fd0=({sourceStream:Q,sourceError:X,destinationStream:J,destinationError:Z})=>{if(X!==void 0&&Z!==void 0)return Z;if(Z!==void 0)return YM(Q),Z;if(X!==void 0)return qM(J),X},VM=({error:Q,fileDescriptors:X,sourceOptions:J,startTime:Z})=>AQ({error:Q,command:ka,escapedCommand:ka,fileDescriptors:X,options:J,startTime:Z,isSync:!1}),ka="source.pipe(destination)";var ha=async(Q)=>{let[{status:X,reason:J,value:Z=J},{status:q,reason:Y,value:$=Y}]=await Q;if(!$.pipedFrom.includes(Z))$.pipedFrom.push(Z);if(q==="rejected")throw $;if(X==="rejected")throw Z;return $};import{finished as gd0}from"node:stream/promises";var ba=(Q,X,J)=>{let Z=zK.has(X)?md0(Q,X):ud0(Q,X);return _7(Q,cd0,J.signal),_7(X,ld0,J.signal),dd0(X),Z},ud0=(Q,X)=>{let J=k7([Q]);return SQ(J,X),zK.set(X,J),J},md0=(Q,X)=>{let J=zK.get(X);return J.add(Q),J},dd0=async(Q)=>{try{await gd0(Q,{cleanup:!0,readable:!1,writable:!0})}catch{}zK.delete(Q)},zK=new WeakMap,cd0=2,ld0=1;import{aborted as pd0}from"node:util";var fa=(Q,X)=>Q===void 0?[]:[nd0(Q,X)],nd0=async(Q,{sourceStream:X,mergedStream:J,fileDescriptors:Z,sourceOptions:q,startTime:Y})=>{await pd0(Q,X),await J.remove(X);let $=Error("Pipe canceled by `unpipeSignal` option.");throw VM({error:$,fileDescriptors:Z,sourceOptions:q,startTime:Y})};var UK=(Q,...X)=>{if(j1(X[0]))return UK.bind(void 0,{...Q,boundOptions:{...Q.boundOptions,...X[0]}});let{destination:J,...Z}=xa(Q,...X),q=id0({...Z,destination:J});return q.pipe=UK.bind(void 0,{...Q,source:J,sourcePromise:q,boundOptions:{}}),q},id0=async({sourcePromise:Q,sourceStream:X,sourceOptions:J,sourceError:Z,destination:q,destinationStream:Y,destinationError:$,unpipeSignal:H,fileDescriptors:K,startTime:V})=>{let W=od0(Q,q);ya({sourceStream:X,sourceError:Z,destinationStream:Y,destinationError:$,fileDescriptors:K,sourceOptions:J,startTime:V});let G=new AbortController;try{let z=ba(X,Y,G);return await Promise.race([ha(W),...fa(H,{sourceStream:X,mergedStream:z,sourceOptions:J,fileDescriptors:K,startTime:V})])}finally{G.abort()}},od0=(Q,X)=>Promise.allSettled([Q,X]);import{setImmediate as Xc0}from"node:timers/promises";import{on as rd0}from"node:events";import{getDefaultHighWaterMark as sd0}from"node:stream";var BK=({subprocessStdout:Q,subprocess:X,binary:J,shouldEncode:Z,encoding:q,preserveNewlines:Y})=>{let $=new AbortController;return ad0(X,$),ua({stream:Q,controller:$,binary:J,shouldEncode:!Q.readableObjectMode&&Z,encoding:q,shouldSplit:!Q.readableObjectMode,preserveNewlines:Y})},ad0=async(Q,X)=>{try{await Q}catch{}finally{X.abort()}},GM=({stream:Q,onStreamEnd:X,lines:J,encoding:Z,stripFinalNewline:q,allMixed:Y})=>{let $=new AbortController;td0(X,$,Q);let H=Q.readableObjectMode&&!Y;return ua({stream:Q,controller:$,binary:Z==="buffer",shouldEncode:!H,encoding:Z,shouldSplit:!H&&J,preserveNewlines:!q})},td0=async(Q,X,J)=>{try{await Q}catch{J.destroy()}finally{X.abort()}},ua=({stream:Q,controller:X,binary:J,shouldEncode:Z,encoding:q,shouldSplit:Y,preserveNewlines:$})=>{let H=rd0(Q,"data",{signal:X.signal,highWaterMark:ga,highWatermark:ga});return ed0({onStdoutChunk:H,controller:X,binary:J,shouldEncode:Z,encoding:q,shouldSplit:Y,preserveNewlines:$})},zM=sd0(!0),ga=zM,ed0=async function*({onStdoutChunk:Q,controller:X,binary:J,shouldEncode:Z,encoding:q,shouldSplit:Y,preserveNewlines:$}){let H=Qc0({binary:J,shouldEncode:Z,encoding:q,shouldSplit:Y,preserveNewlines:$});try{for await(let[K]of Q)yield*x7(K,H,0)}catch(K){if(!X.signal.aborted)throw K}finally{yield*_Z(H)}},Qc0=({binary:Q,shouldEncode:X,encoding:J,shouldSplit:Z,preserveNewlines:q})=>[YK(Q,J,!X),qK(Q,q,!Z,{})].filter(Boolean);var ma=async({stream:Q,onStreamEnd:X,fdNumber:J,encoding:Z,buffer:q,maxBuffer:Y,lines:$,allMixed:H,stripFinalNewline:K,verboseInfo:V,streamInfo:W})=>{let G=Jc0({stream:Q,onStreamEnd:X,fdNumber:J,encoding:Z,allMixed:H,verboseInfo:V,streamInfo:W});if(!q){await Promise.all([Zc0(Q),G]);return}let z=nF(K,J),U=GM({stream:Q,onStreamEnd:X,lines:$,encoding:Z,stripFinalNewline:z,allMixed:H}),[L]=await Promise.all([qc0({stream:Q,iterable:U,fdNumber:J,encoding:Z,maxBuffer:Y,lines:$}),G]);return L},Jc0=async({stream:Q,onStreamEnd:X,fdNumber:J,encoding:Z,allMixed:q,verboseInfo:Y,streamInfo:{fileDescriptors:$}})=>{if(!KK({stdioItems:$[J]?.stdioItems,encoding:Z,verboseInfo:Y,fdNumber:J}))return;let H=GM({stream:Q,onStreamEnd:X,lines:!0,encoding:Z,stripFinalNewline:!0,allMixed:q});await os(H,Q,J,Y)},Zc0=async(Q)=>{if(await Xc0(),Q.readableFlowing===null)Q.resume()},qc0=async({stream:Q,stream:{readableObjectMode:X},iterable:J,fdNumber:Z,encoding:q,maxBuffer:Y,lines:$})=>{try{if(X||$)return await oH(J,{maxBuffer:Y});if(q==="buffer")return new Uint8Array(await rH(J,{maxBuffer:Y}));return await aH(J,{maxBuffer:Y})}catch(H){return da(or({error:H,stream:Q,readableObjectMode:X,lines:$,encoding:q,fdNumber:Z}))}},UM=async(Q)=>{try{return await Q}catch(X){return da(X)}},da=({bufferedData:Q})=>Wi(Q)?new Uint8Array(Q):Q;import{finished as Yc0}from"node:stream/promises";var kZ=async(Q,X,J,{isSameDirection:Z,stopOnExit:q=!1}={})=>{let Y=$c0(Q,J),$=new AbortController;try{await Promise.race([...q?[J.exitPromise]:[],Yc0(Q,{cleanup:!0,signal:$.signal})])}catch(H){if(!Y.stdinCleanedUp)Wc0(H,X,J,Z)}finally{$.abort()}},$c0=(Q,{originalStreams:[X],subprocess:J})=>{let Z={stdinCleanedUp:!1};if(Q===X)Hc0(Q,J,Z);return Z},Hc0=(Q,X,J)=>{let{_destroy:Z}=Q;Q._destroy=(...q)=>{Kc0(X,J),Z.call(Q,...q)}},Kc0=({exitCode:Q,signalCode:X},J)=>{if(Q!==null||X!==null)J.stdinCleanedUp=!0},Wc0=(Q,X,J,Z)=>{if(!Vc0(Q,X,J,Z))throw Q},Vc0=(Q,X,J,Z=!0)=>{if(J.propagating)return ca(Q)||LK(Q);return J.propagating=!0,BM(J,X)===Z?ca(Q):LK(Q)},BM=({fileDescriptors:Q},X)=>X!=="all"&&Q[X].direction==="input",LK=(Q)=>Q?.code==="ERR_STREAM_PREMATURE_CLOSE",ca=(Q)=>Q?.code==="EPIPE";var la=({subprocess:Q,encoding:X,buffer:J,maxBuffer:Z,lines:q,stripFinalNewline:Y,verboseInfo:$,streamInfo:H})=>Q.stdio.map((K,V)=>LM({stream:K,fdNumber:V,encoding:X,buffer:J[V],maxBuffer:Z[V],lines:q[V],allMixed:!1,stripFinalNewline:Y,verboseInfo:$,streamInfo:H})),LM=async({stream:Q,fdNumber:X,encoding:J,buffer:Z,maxBuffer:q,lines:Y,allMixed:$,stripFinalNewline:H,verboseInfo:K,streamInfo:V})=>{if(!Q)return;let W=kZ(Q,X,V);if(BM(V,X)){await W;return}let[G]=await Promise.all([ma({stream:Q,onStreamEnd:W,fdNumber:X,encoding:J,buffer:Z,maxBuffer:q,lines:Y,allMixed:$,stripFinalNewline:H,verboseInfo:K,streamInfo:V}),W]);return G};var pa=({stdout:Q,stderr:X},{all:J})=>J&&(Q||X)?k7([Q,X].filter(Boolean)):void 0,na=({subprocess:Q,encoding:X,buffer:J,maxBuffer:Z,lines:q,stripFinalNewline:Y,verboseInfo:$,streamInfo:H})=>LM({...Gc0(Q,J),fdNumber:"all",encoding:X,maxBuffer:Z[1]+Z[2],lines:q[1]||q[2],allMixed:zc0(Q),stripFinalNewline:Y,verboseInfo:$,streamInfo:H}),Gc0=({stdout:Q,stderr:X,all:J},[,Z,q])=>{let Y=Z||q;if(!Y)return{stream:J,buffer:Y};if(!Z)return{stream:X,buffer:Y};if(!q)return{stream:Q,buffer:Y};return{stream:J,buffer:Y}},zc0=({all:Q,stdout:X,stderr:J})=>Q&&X&&J&&X.readableObjectMode!==J.readableObjectMode;import{once as Uc0}from"node:events";var ia=(Q)=>CQ(Q,"ipc"),oa=(Q,X)=>{let J=IH(Q);q8({type:"ipc",verboseMessage:J,fdNumber:"ipc",verboseInfo:X})};var ra=async({subprocess:Q,buffer:X,maxBuffer:J,ipc:Z,ipcOutput:q,verboseInfo:Y})=>{if(!Z)return q;let $=ia(Y),H=k8(X,"ipc"),K=k8(J,"ipc");for await(let V of XM({anyProcess:Q,channel:Q.channel,isSubprocess:!1,ipc:Z,shouldAwait:!1,reference:!0})){if(H)rr(Q,q,K),q.push(V);if($)oa(V,Y)}return q},sa=async(Q,X)=>{return await Promise.allSettled([Q]),X};var aa=async({subprocess:Q,options:{encoding:X,buffer:J,maxBuffer:Z,lines:q,timeoutDuration:Y,cancelSignal:$,gracefulCancel:H,forceKillAfterDelay:K,stripFinalNewline:V,ipc:W,ipcInput:G},context:z,verboseInfo:U,fileDescriptors:L,originalStreams:B,onInternalError:M,controller:I})=>{let j=es(Q,z),R={originalStreams:B,fileDescriptors:L,subprocess:Q,exitPromise:j,propagating:!1},N=la({subprocess:Q,encoding:X,buffer:J,maxBuffer:Z,lines:q,stripFinalNewline:V,verboseInfo:U,streamInfo:R}),x=na({subprocess:Q,encoding:X,buffer:J,maxBuffer:Z,lines:q,stripFinalNewline:V,verboseInfo:U,streamInfo:R}),f=[],E=ra({subprocess:Q,buffer:J,maxBuffer:Z,ipc:W,ipcOutput:f,verboseInfo:U}),l=Bc0(B,Q,R),T=Lc0(L,R);try{return await Promise.race([Promise.all([{},Xa(j),Promise.all(N),x,E,wr(Q,G),...l,...T]),M,Fc0(Q,I),...Or(Q,Y,z,I),...mo({subprocess:Q,cancelSignal:$,gracefulCancel:H,context:z,controller:I}),...Pr({subprocess:Q,cancelSignal:$,gracefulCancel:H,forceKillAfterDelay:K,context:z,controller:I})])}catch(u){return z.terminationReason??="other",Promise.all([{error:u},j,Promise.all(N.map((c)=>UM(c))),UM(x),sa(E,f),Promise.allSettled(l),Promise.allSettled(T)])}},Bc0=(Q,X,J)=>Q.map((Z,q)=>Z===X.stdio[q]?void 0:kZ(Z,q,J)),Lc0=(Q,X)=>Q.flatMap(({stdioItems:J},Z)=>J.filter(({value:q,stream:Y=q})=>v4(Y,{checkOpen:!1})&&!_4(Y)).map(({type:q,value:Y,stream:$=Y})=>kZ($,Z,X,{isSameDirection:z4.has(q),stopOnExit:q==="native"}))),Fc0=async(Q,{signal:X})=>{let[J]=await Uc0(Q,"error",{signal:X});throw J};var ta=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),yZ=(Q,X,J)=>{let Z=Q[J];if(!Z.has(X))Z.set(X,[]);let q=Z.get(X),Y=$8();return q.push(Y),{resolve:Y.resolve.bind(Y),promises:q}},vQ=async({resolve:Q,promises:X},J)=>{Q();let[Z]=await Promise.race([Promise.allSettled([!0,J]),Promise.all([!1,...X])]);return!Z};import{Readable as Mc0}from"node:stream";import{callbackify as Ic0}from"node:util";import{finished as ea}from"node:stream/promises";var FM=async(Q)=>{if(Q===void 0)return;try{await MM(Q)}catch{}},Qt=async(Q)=>{if(Q===void 0)return;try{await IM(Q)}catch{}},MM=async(Q)=>{await ea(Q,{cleanup:!0,readable:!1,writable:!0})},IM=async(Q)=>{await ea(Q,{cleanup:!0,readable:!0,writable:!1})},FK=async(Q,X)=>{if(await Q,X)throw X},MK=(Q,X,J)=>{if(J&&!LK(J))Q.destroy(J);else if(X)Q.destroy()};var Xt=({subprocess:Q,concurrentStreams:X,encoding:J},{from:Z,binary:q=!0,preserveNewlines:Y=!0}={})=>{let $=q||g6.has(J),{subprocessStdout:H,waitReadableDestroy:K}=PM(Q,Z,X),{readableEncoding:V,readableObjectMode:W,readableHighWaterMark:G}=CM(H,$),{read:z,onStdoutDataDone:U}=OM({subprocessStdout:H,subprocess:Q,binary:$,encoding:J,preserveNewlines:Y}),L=new Mc0({read:z,destroy:Ic0(NM.bind(void 0,{subprocessStdout:H,subprocess:Q,waitReadableDestroy:K})),highWaterMark:G,objectMode:W,encoding:V});return jM({subprocessStdout:H,onStdoutDataDone:U,readable:L,subprocess:Q}),L},PM=(Q,X,J)=>{let Z=DQ(Q,X),q=yZ(J,Z,"readableDestroy");return{subprocessStdout:Z,waitReadableDestroy:q}},CM=({readableEncoding:Q,readableObjectMode:X,readableHighWaterMark:J},Z)=>Z?{readableEncoding:Q,readableObjectMode:X,readableHighWaterMark:J}:{readableEncoding:Q,readableObjectMode:!0,readableHighWaterMark:zM},OM=({subprocessStdout:Q,subprocess:X,binary:J,encoding:Z,preserveNewlines:q})=>{let Y=$8(),$=BK({subprocessStdout:Q,subprocess:X,binary:J,shouldEncode:!J,encoding:Z,preserveNewlines:q});return{read(){Pc0(this,$,Y)},onStdoutDataDone:Y}},Pc0=async(Q,X,J)=>{try{let{value:Z,done:q}=await X.next();if(q)J.resolve();else Q.push(Z)}catch{}},jM=async({subprocessStdout:Q,onStdoutDataDone:X,readable:J,subprocess:Z,subprocessStdin:q})=>{try{if(await IM(Q),await Z,await FM(q),await X,J.readable)J.push(null)}catch(Y){await FM(q),Jt(J,Y)}},NM=async({subprocessStdout:Q,subprocess:X,waitReadableDestroy:J},Z)=>{if(await vQ(J,X))Jt(Q,Z),await FK(X,Z)},Jt=(Q,X)=>{MK(Q,Q.readable,X)};import{Writable as Cc0}from"node:stream";import{callbackify as Zt}from"node:util";var qt=({subprocess:Q,concurrentStreams:X},{to:J}={})=>{let{subprocessStdin:Z,waitWritableFinal:q,waitWritableDestroy:Y}=RM(Q,J,X),$=new Cc0({...DM(Z,Q,q),destroy:Zt(TM.bind(void 0,{subprocessStdin:Z,subprocess:Q,waitWritableFinal:q,waitWritableDestroy:Y})),highWaterMark:Z.writableHighWaterMark,objectMode:Z.writableObjectMode});return wM(Z,$),$},RM=(Q,X,J)=>{let Z=vH(Q,X),q=yZ(J,Z,"writableFinal"),Y=yZ(J,Z,"writableDestroy");return{subprocessStdin:Z,waitWritableFinal:q,waitWritableDestroy:Y}},DM=(Q,X,J)=>({write:Oc0.bind(void 0,Q),final:Zt(jc0.bind(void 0,Q,X,J))}),Oc0=(Q,X,J,Z)=>{if(Q.write(X,J))Z();else Q.once("drain",Z)},jc0=async(Q,X,J)=>{if(await vQ(J,X)){if(Q.writable)Q.end();await X}},wM=async(Q,X,J)=>{try{if(await MM(Q),X.writable)X.end()}catch(Z){await Qt(J),Yt(X,Z)}},TM=async({subprocessStdin:Q,subprocess:X,waitWritableFinal:J,waitWritableDestroy:Z},q)=>{if(await vQ(J,X),await vQ(Z,X))Yt(Q,q),await FK(X,q)},Yt=(Q,X)=>{MK(Q,Q.writable,X)};import{Duplex as Nc0}from"node:stream";import{callbackify as Rc0}from"node:util";var $t=({subprocess:Q,concurrentStreams:X,encoding:J},{from:Z,to:q,binary:Y=!0,preserveNewlines:$=!0}={})=>{let H=Y||g6.has(J),{subprocessStdout:K,waitReadableDestroy:V}=PM(Q,Z,X),{subprocessStdin:W,waitWritableFinal:G,waitWritableDestroy:z}=RM(Q,q,X),{readableEncoding:U,readableObjectMode:L,readableHighWaterMark:B}=CM(K,H),{read:M,onStdoutDataDone:I}=OM({subprocessStdout:K,subprocess:Q,binary:H,encoding:J,preserveNewlines:$}),j=new Nc0({read:M,...DM(W,Q,G),destroy:Rc0(Dc0.bind(void 0,{subprocessStdout:K,subprocessStdin:W,subprocess:Q,waitReadableDestroy:V,waitWritableFinal:G,waitWritableDestroy:z})),readableHighWaterMark:B,writableHighWaterMark:W.writableHighWaterMark,readableObjectMode:L,writableObjectMode:W.writableObjectMode,encoding:U});return jM({subprocessStdout:K,onStdoutDataDone:I,readable:j,subprocess:Q,subprocessStdin:W}),wM(W,j,K),j},Dc0=async({subprocessStdout:Q,subprocessStdin:X,subprocess:J,waitReadableDestroy:Z,waitWritableFinal:q,waitWritableDestroy:Y},$)=>{await Promise.all([NM({subprocessStdout:Q,subprocess:J,waitReadableDestroy:Z},$),TM({subprocessStdin:X,subprocess:J,waitWritableFinal:q,waitWritableDestroy:Y},$)])};var AM=(Q,X,{from:J,binary:Z=!1,preserveNewlines:q=!1}={})=>{let Y=Z||g6.has(X),$=DQ(Q,J),H=BK({subprocessStdout:$,subprocess:Q,binary:Y,shouldEncode:!0,encoding:X,preserveNewlines:q});return wc0(H,$,Q)},wc0=async function*(Q,X,J){try{yield*Q}finally{if(X.readable)X.destroy();await J}};var Ht=(Q,{encoding:X})=>{let J=ta();Q.readable=Xt.bind(void 0,{subprocess:Q,concurrentStreams:J,encoding:X}),Q.writable=qt.bind(void 0,{subprocess:Q,concurrentStreams:J}),Q.duplex=$t.bind(void 0,{subprocess:Q,concurrentStreams:J,encoding:X}),Q.iterable=AM.bind(void 0,Q,X),Q[Symbol.asyncIterator]=AM.bind(void 0,Q,X,{})};var Kt=(Q,X)=>{for(let[J,Z]of Ac0){let q=Z.value.bind(X);Reflect.defineProperty(Q,J,{...Z,value:q})}},Tc0=(async()=>{})().constructor.prototype,Ac0=["then","catch","finally"].map((Q)=>[Q,Reflect.getOwnPropertyDescriptor(Tc0,Q)]);var Wt=(Q,X,J,Z)=>{let{file:q,commandArguments:Y,command:$,escapedCommand:H,startTime:K,verboseInfo:V,options:W,fileDescriptors:G}=Sc0(Q,X,J),{subprocess:z,promise:U}=xc0({file:q,commandArguments:Y,options:W,startTime:K,verboseInfo:V,command:$,escapedCommand:H,fileDescriptors:G});return z.pipe=UK.bind(void 0,{source:z,sourcePromise:U,boundOptions:{},createNested:Z}),Kt(z,U),H8.set(z,{options:W,fileDescriptors:G}),z},Sc0=(Q,X,J)=>{let{command:Z,escapedCommand:q,startTime:Y,verboseInfo:$}=CH(Q,X,J),{file:H,commandArguments:K,options:V}=cH(Q,X,J),W=vc0(V),G=Fa(W,$);return{file:H,commandArguments:K,command:Z,escapedCommand:q,startTime:Y,verboseInfo:$,options:W,fileDescriptors:G}},vc0=({timeout:Q,signal:X,...J})=>{if(X!==void 0)throw TypeError('The "signal" option has been renamed to "cancelSignal" instead.');return{...J,timeoutDuration:Q}},xc0=({file:Q,commandArguments:X,options:J,startTime:Z,verboseInfo:q,command:Y,escapedCommand:$,fileDescriptors:H})=>{let K;try{K=_c0(...lH(Q,X,J))}catch(L){return za({error:L,command:Y,escapedCommand:$,fileDescriptors:H,options:J,startTime:Z,verboseInfo:q})}let V=new AbortController;Ec0(Number.POSITIVE_INFINITY,V.signal);let W=[...K.stdio];wa(K,H,V),Sa(K,J,V);let G={},z=$8();K.kill=go.bind(void 0,{kill:K.kill.bind(K),options:J,onInternalError:z,context:G,controller:V}),K.all=pa(K,J),Ht(K,J),Wa(K,J);let U=kc0({subprocess:K,options:J,startTime:Z,verboseInfo:q,fileDescriptors:H,originalStreams:W,command:Y,escapedCommand:$,context:G,onInternalError:z,controller:V});return{subprocess:K,promise:U}},kc0=async({subprocess:Q,options:X,startTime:J,verboseInfo:Z,fileDescriptors:q,originalStreams:Y,command:$,escapedCommand:H,context:K,onInternalError:V,controller:W})=>{let[G,[z,U],L,B,M]=await aa({subprocess:Q,options:X,context:K,verboseInfo:Z,fileDescriptors:q,originalStreams:Y,onInternalError:V,controller:W});W.abort(),V.resolve();let I=L.map((N,x)=>b8(N,X,x)),j=b8(B,X,"all"),R=yc0({errorInfo:G,exitCode:z,signal:U,stdio:I,all:j,ipcOutput:M,context:K,options:X,command:$,escapedCommand:H,startTime:J});return EQ(R,Z,X)},yc0=({errorInfo:Q,exitCode:X,signal:J,stdio:Z,all:q,ipcOutput:Y,context:$,options:H,command:K,escapedCommand:V,startTime:W})=>("error"in Q)?EZ({error:Q.error,command:K,escapedCommand:V,timedOut:$.terminationReason==="timeout",isCanceled:$.terminationReason==="cancel"||$.terminationReason==="gracefulCancel",isGracefullyCanceled:$.terminationReason==="gracefulCancel",isMaxBuffer:Q.error instanceof y8,isForcefullyTerminated:$.isForcefullyTerminated,exitCode:X,signal:J,stdio:Z,all:q,ipcOutput:Y,options:H,startTime:W,isSync:!1}):eH({command:K,escapedCommand:V,stdio:Z,all:q,ipcOutput:Y,options:H,startTime:W});var IK=(Q,X)=>{let J=Object.fromEntries(Object.entries(X).map(([Z,q])=>[Z,hc0(Z,Q[Z],q)]));return{...Q,...J}},hc0=(Q,X,J)=>{if(bc0.has(Q)&&j1(X)&&j1(J))return{...X,...J};return J},bc0=new Set(["env",...HF]);var R5=(Q,X,J,Z)=>{let q=($,H,K)=>R5($,H,J,K),Y=(...$)=>fc0({mapArguments:Q,deepOptions:J,boundOptions:X,setBoundExeca:Z,createNested:q},...$);if(Z!==void 0)Z(Y,q,X);return Y},fc0=({mapArguments:Q,deepOptions:X={},boundOptions:J={},setBoundExeca:Z,createNested:q},Y,...$)=>{if(j1(Y))return q(Q,IK(J,Y),Z);let{file:H,commandArguments:K,options:V,isSync:W}=gc0({mapArguments:Q,firstArgument:Y,nextArguments:$,deepOptions:X,boundOptions:J});return W?Za(H,K,V):Wt(H,K,V,q)},gc0=({mapArguments:Q,firstArgument:X,nextArguments:J,deepOptions:Z,boundOptions:q})=>{let Y=Li(X)?Fi(X,J):[X,...J],[$,H,K]=WH(...Y),V=IK(IK(Z,q),K),{file:W=$,commandArguments:G=H,options:z=V,isSync:U=!1}=Q({file:$,commandArguments:H,options:V});return{file:W,commandArguments:G,options:z,isSync:U}};var Vt=({file:Q,commandArguments:X})=>zt(Q,X),Gt=({file:Q,commandArguments:X})=>({...zt(Q,X),isSync:!0}),zt=(Q,X)=>{if(X.length>0)throw TypeError(`The command and its arguments must be passed as a single string: ${Q} ${X}.`);let[J,...Z]=uc0(Q);return{file:J,commandArguments:Z}},uc0=(Q)=>{if(typeof Q!=="string")throw TypeError(`The command must be a string: ${String(Q)}.`);let X=Q.trim();if(X==="")return[];let J=[];for(let Z of X.split(mc0)){let q=J.at(-1);if(q&&q.endsWith("\\"))J[J.length-1]=`${q.slice(0,-1)} ${Z}`;else J.push(Z)}return J},mc0=/ +/g;var Ut=(Q,X,J)=>{Q.sync=X(dc0,J),Q.s=Q.sync},Bt=({options:Q})=>Lt(Q),dc0=({options:Q})=>({...Lt(Q),isSync:!0}),Lt=(Q)=>({options:{...cc0(Q),...Q}}),cc0=({input:Q,inputFile:X,stdio:J})=>Q===void 0&&X===void 0&&J===void 0?{stdin:"inherit"}:{},Ft={preferLocal:!0};var G1=R5(()=>({})),fV1=R5(()=>({isSync:!0})),gV1=R5(Vt),uV1=R5(Gt),mV1=R5(Nr),dV1=R5(Bt,{},Ft,Ut),{sendMessage:cV1,getOneMessage:lV1,getEachMessage:pV1,getCancelSignal:nV1}=Va();import{spawnSync as lc0}from"node:child_process";var PK,Mt=!1;function It(Q){if(PK=Q,!Mt)Mt=!0,process.on("exit",()=>{EM()})}function Pt(){PK=void 0}function EM(){let Q=PK;if(Q===void 0)return!1;if(PK=void 0,process.platform==="win32")return lc0("taskkill",["/PID",String(Q),"/T","/F"],{stdio:"ignore"}),!0;try{process.kill(-Q,"SIGKILL")}catch{}return!0}import{createHash as pc0}from"node:crypto";import{existsSync as Ot,statSync as jt}from"node:fs";import{homedir as nc0}from"node:os";import{join as CK,resolve as ic0}from"node:path";function Ct(){let[Q="",X=""]=process.argv,J=(Y)=>Y.replaceAll("\\","/"),Z={type:"command",command:J(Q),args:[J(X),"internal","snapshot"]},q=[{hooks:[Z]}];return JSON.stringify({hooks:{SessionStart:[{matcher:"startup",hooks:[Z]}],UserPromptSubmit:q,Stop:q,StopFailure:q,PostToolUseFailure:q}})}var Dt={tool_search:[{name:"ENABLE_TOOL_SEARCH",value:"true"}],inherit_subagent_models:[{name:"CLAUDE_CODE_SUBAGENT_MODEL",value:"inherit"}],sync_only_bash:[{name:"CLAUDE_CODE_DISABLE_BACKGROUND_TASKS",value:"1"}],long_bash_timeouts:[{name:"BASH_DEFAULT_TIMEOUT_MS",value:"600000"},{name:"BASH_MAX_TIMEOUT_MS",value:"3600000"}]};function oc0(Q){let X={};for(let J of Q){let Z=Dt[J];if(!Z){console.warn(`Ignoring unknown env option from config: ${J}`);continue}for(let{name:q,value:Y}of Z)X[q]=Y}return X}var rc0=[/^ANTHROPIC_/,/^CLAUDE_CODE_/],sc0=new Set(["ONFRONTIER_SNAPSHOT_REPO",...Object.values(Dt).flat().map((Q)=>Q.name)]);function ac0(){let Q={};for(let[X,J]of Object.entries(process.env)){if(J===void 0)continue;if(sc0.has(X))continue;if(rc0.some((Z)=>Z.test(X)))continue;Q[X]=J}return Q}var Nt=new Map;function tc0(Q,X){let J=X??"",Z=Nt.get(J);if(!Z)Z=ec0(Q,X),Nt.set(J,Z);return Z}async function ec0(Q,X){let[J,Z]=await G1("npx",["--version"],{cwd:X}).then(({stdout:q})=>{let[Y=0,$=0]=q.trim().split(".").map((H)=>Number.parseInt(H,10)||0);return[Y,$]},()=>[0,0]);if(J>11||J===11&&Z>=17){let Y=(await G1("npm",["config","get","min-release-age-exclude"],{cwd:X}).then(({stdout:$})=>$.trim(),()=>"")).split(",").map(($)=>$.trim()).filter(($)=>$!==""&&$!=="undefined");if(!Y.includes(Q))Y.push(Q);return{npm_config_min_release_age_exclude:Y.join(",")}}if(J===11&&Z>=10)return{npm_config_min_release_age:"0"};return{}}async function OK(Q,X=[]){let J=`${Q.modelId}[1m]`,Z={...oc0(Q.envOptions??[]),ANTHROPIC_BASE_URL:l1.router.url,ANTHROPIC_AUTH_TOKEN:Q.apiKey,ANTHROPIC_MODEL:J,DISABLE_AUTOUPDATER:"1",CLAUDE_CODE_AUTO_MODE_SERVER:"0",CLAUDE_CODE_MAX_OUTPUT_TOKENS:"64000",CLAUDE_CODE_AUTO_COMPACT_WINDOW:"1000000",...Q.snapshotRepo?{ONFRONTIER_SNAPSHOT_REPO:"1"}:{},...await tc0(Q.clientType,Q.cwd)},q=["--model",J,"--settings",Ct()];if(Q.sessionId)q.push("--session-id",Q.sessionId);if(Q.skipPermissions)q.push("--dangerously-skip-permissions");else q.push("--permission-mode","auto");if(Q.disallowedTools&&Q.disallowedTools.length>0)q.push("--disallowedTools",...Q.disallowedTools);if(Q.headlessLogFiles)q.push("-p","--output-format","json");let Y=Q.headlessLogFiles?{input:Q.initialPrompt??"",stdout:{file:Q.headlessLogFiles.stdout},stderr:{file:Q.headlessLogFiles.stderr}}:{stdio:"inherit"},$=Date.now(),H=`${Q.clientType}@${Q.clientVersion}`,K=["--yes",H,...q,...X],V={...Y,env:{...ac0(),...Z},cwd:Q.cwd,reject:!1,detached:Q.headlessLogFiles!==void 0&&process.platform!=="win32"},W=async()=>{let z=G1("npx",K,V);if(Q.headlessLogFiles)It(z.pid);try{return await z}finally{Pt()}},G=await W();if(typeof G.exitCode==="number"&&G.exitCode!==0&&!G.signal&&await Ql0(Q.clientType,H,Q.cwd))G=await W();return{exitCode:G.exitCode,signal:G.signal,durationMs:Date.now()-$}}var Rt=1e6;async function Ql0(Q,X,J){try{let Z=[process.env.npm_config_cache,process.env.NPM_CONFIG_CACHE].find((V)=>V!==void 0&&V!==""),q=Z===void 0?(await G1("npm",["config","get","cache"],{cwd:J})).stdout.trim():Xl0(Z,J),Y=pc0("sha512").update(X).digest("hex").slice(0,16),$=CK(q,"_npx",Y,"node_modules",...Q.split("/")),H=CK($,"bin","claude.exe"),K=CK($,"install.cjs");if(!Ot(H)||!Ot(K))return!1;if(jt(H).size>Rt)return!1;return console.warn("The coding client was installed without its native binary (npm 12 skips install scripts). Repairing the install and retrying…"),await G1("node",[K]),jt(H).size>Rt}catch{return!1}}function Xl0(Q,X){let J=Jl0(Q),Z=J==="~"||J.startsWith("~/")||J.startsWith("~\\")?CK(nc0(),J.slice(1)):J;return ic0(X??process.cwd(),Z)}function Jl0(Q){return Q.replace(/(\\*)\$\{([^${}]+)\}/g,(X,J,Z)=>{if(J.length%2===1)return X.slice((J.length+1)/2);let q=process.env[Z];return q===void 0?X:J.slice(J.length/2)+q})}async function _t(Q,X){let J=Q.headless_spec;if(!J||Q.models.length!==2)b0("This headless task is missing its launch spec or model pair. Contact support@onfrontier.ai."),process.exit(1);let Z=J.task_prompt;if(!Z.trim())b0("This headless task has an empty prompt. Contact support@onfrontier.ai."),process.exit(1);let q=Q.task_id.replaceAll(/[^A-Za-z\d._-]+/g,"-"),Y=D5(process.cwd(),`${Ll0(J.github_url)}-${q}`);if(ql0(Y)&&Yl0(Y).length>0)b0(`Run folder already exists: ${Y}
158
+ Each comparison starts from fresh folders; rename or delete this folder, then run again.`),process.exit(1);wt(Y,{recursive:!0});let $=D5(Y,"source"),H=process.platform==="win32"?["-c","core.longpaths=true"]:[],K=V4();K.start(`Cloning ${J.github_url}`);try{await G1("git",["clone",...H,"--quiet","--branch",J.branch,J.github_url,$]),await G1("git",["checkout","--quiet","--detach",J.commit_hash],{cwd:$})}catch(p){K.stop("Failed to prepare the task repository"),b0(`${p.message}
159
+ The task record's repository, branch, or starting commit could not be prepared. Contact support@onfrontier.ai.`),process.exit(1)}let V=await Fl0($);if(!V)K.stop("Failed to prepare the task repository"),b0(`Could not resolve the starting commit in ${$}.`),process.exit(1);K.stop(`Cloned the task repository at ${V.slice(0,12)}`);let W=Q.models.map((p,Y0)=>({modelId:p,runDir:D5(Y,`run-${Y0+1}-${p}`),sessionId:Zl0()})),G=V4();G.start("Preparing isolated run folders");try{for(let p of W)await G1("git",["clone",...H,"--quiet",$,p.runDir]),await G1("git",["checkout","--quiet","--detach",V],{cwd:p.runDir})}catch(p){G.stop("Failed to prepare run folders"),b0(p.message),process.exit(1)}G.stop(`Cloned the starting state (${V.slice(0,12)}) into two run folders`);let z=new Map;try{for(let p of W){let Y0=await H6.createRouterKey(Q.task_id,p.modelId);z.set(p.modelId,Y0.key)}}catch(p){b0(`Could not prepare the runs.
160
160
  ${p.message}`),process.exit(1)}let U={clientType:X.clientType,clientVersion:X.clientVersion,snapshotRepo:X.snapshotRepo,initialPrompt:Z,skipPermissions:!0,disallowedTools:["Monitor"],envOptions:[...new Set([...X.envOptions,"sync_only_bash","long_bash_timeouts"])]},L=D5(Zi,"comparison-logs");wt(L,{recursive:!0});let B=(p)=>({stdout:D5(L,`${q}-${p.modelId}-${p.sessionId}.out.log`),stderr:D5(L,`${q}-${p.modelId}-${p.sessionId}.err.log`)});C6.info(`Running both arms of "${Q.name}" headlessly, one at a time in randomized order. This can take a while. Do not open or modify the run folders until both finish, and leave this terminal open: stopping discards the comparison.`);let M=V4();M.start("Running");let I=Date.now(),j,R=()=>{let p=_M(Date.now()-I),Y0=j?At(j):void 0,L0=Y0===void 0?"":`, model active ${_M(Date.now()-Y0)} ago`;return`Running (${p} elapsed${L0}) - a run usually takes 1-6 hours, do not stop`},N=setInterval(()=>{M.message(R())},1e4),x=()=>{clearInterval(N),M.stop(`Aborted after ${Tt(Date.now()-I)}. The model process was stopped.`),EM();try{console.log([""," this comparison: partial work is not staged and cannot be submitted",` to try again: delete ${Y}, then run \`onfrontier start\` again`,' while it runs: leave the terminal open until you see "Both runs finished", a run usually takes 1-6 hours',""].join(`
161
161
  `))}catch{}process.exit(130)},f=0,E=()=>{if(Date.now()-f<5000)x();f=Date.now();let p=j?At(j):void 0,Y0=p===void 0?"":` The model was active ${_M(Date.now()-p)} ago.`;M.message(`Stopping discards this comparison (both runs must complete in one go). Press Ctrl+C again within 5s to abort, or wait.${Y0}`)},l=process.stdin;for(let p of l.listeners("keypress"))l.off("keypress",p);let T=(p,Y0)=>{if(Y0?.sequence==="\x03"||Y0?.ctrl===!0&&Y0.name==="c")E()};l.on("keypress",T),process.removeAllListeners("SIGINT"),process.removeAllListeners("SIGTERM"),process.on("SIGINT",E),process.on("SIGTERM",x),process.on("SIGHUP",x);let u=Math.random()<0.5?[0,1]:[1,0],c=[];try{for(let p of u){let Y0=W[p];j=Y0;let L0=await OK({...U,apiKey:z.get(Y0.modelId),modelId:Y0.modelId,cwd:Y0.runDir,sessionId:Y0.sessionId,headlessLogFiles:B(Y0)});if(L0.signal!==void 0||Date.now()-f<5000)x();c[p]=L0}}finally{clearInterval(N),j=void 0,l.off("keypress",T),process.off("SIGINT",E),process.off("SIGTERM",x),process.off("SIGHUP",x)}M.stop("Both runs finished"),W4("Comparison complete");let t=[];for(let[p,Y0]of W.entries()){let L0=B(Y0);try{Kl0(`${L0.stdout.replace(/\.out\.log$/,"")}.meta.json`,JSON.stringify({...c[p],runPosition:u.indexOf(p)+1}))}catch{}try{await G1("git",["add","-A"],{cwd:Y0.runDir})}catch(w0){t[p]=w0 instanceof Error?w0.message.split(`
162
162
  `)[0]:String(w0)}}console.log(`
@@ -164,7 +164,7 @@ ${p.message}`),process.exit(1)}let U={clientType:X.clientType,clientVersion:X.cl
164
164
  `);for(let[p,Y0]of W.entries()){let L0=c[p],w0=t[p];if(console.log(` ${Y0.modelId}`),L0.exitCode===0&&!w0)console.log(" status: completed, no errors in this run");else if(L0.exitCode===0)console.log(" status: the run finished, but its changes could not be staged for review. Please contact support@onfrontier.ai"),console.log(` error: ${w0}`);else{console.log(` status: ${Vl0(L0)}. Please contact support@onfrontier.ai`);let s0=Gl0(B(Y0));if(s0)console.log(` error: ${s0}`)}console.log(` code changes: ${Y0.runDir}`),console.log(` session id: ${Y0.sessionId}
165
165
  `)}let P0=c.every((p)=>p.exitCode===0)&&t.every((p)=>!p);console.log(P0?"Assess each run's final state against the grading criteria.\n`git diff --cached` inside each run folder shows every change, including new files, but you can just as well open it in an IDE or run the code.":"A run ended with an error, so this comparison may be invalid. Contact support@onfrontier.ai with the session ids above before reviewing or submitting it.")}function Tt(Q){let X=Math.round(Q/1000),J=Math.floor(X/3600),Z=Math.floor(X%3600/60),q=X%60;if(J>0)return`${J}h ${Z}m ${q}s`;if(Z>0)return`${Z}m ${q}s`;return`${q}s`}function _M(Q){let X=Math.max(0,Math.round(Q/1000));if(X<60)return`${X}s`;let J=Math.floor(X/60);if(J<60)return`${J}m`;return`${Math.floor(J/60)}h ${J%60}m`}function At(Q){try{let X=$l0(Q.runDir).replaceAll(/[^a-zA-Z\d]/g,"-"),J=process.env.CLAUDE_CONFIG_DIR??D5(Wl0(),".claude");return Hl0(D5(J,"projects",X,`${Q.sessionId}.jsonl`)).mtimeMs}catch{return}}function Vl0(Q){if(Q.signal)return`the run was killed (signal ${Q.signal})`;return`ended with an error (exit code ${Q.exitCode??"unknown"})`}function Gl0(Q){return zl0(Q.stdout)??Bl0(Q.stderr)}function zl0(Q){try{let X=Et(Q,"utf8").split(`
166
166
  `);for(let J=X.length-1;J>=0;J--){let Z=X[J].trim();if(!Z.startsWith("{"))continue;let q;try{q=JSON.parse(Z)}catch{continue}if(q.type!=="result")continue;if(q.is_error===!0&&typeof q.result==="string"){let Y=q.result.trim().replaceAll(/\s+/g," ");if(Y)return Y.length>200?`${Y.slice(0,200)}…`:Y}return null}return null}catch{return null}}var Ul0=/^\[claude-code:unrecognized_model]/;function Bl0(Q){try{let X=Et(Q,"utf8").split(`
167
- `).map((Y)=>Y.trim()).filter((Y)=>Y.length>0&&!Y.startsWith("⚠")),J=[],Z=!1;for(let Y of X){if(Ul0.test(Y)){Z=!0;continue}if(Z&&Y.startsWith("{")){Z=!1;continue}Z=!1,J.push(Y)}let q=J.at(-1);if(!q)return null;if(/^operable program or batch file\.?$/i.test(q)){let Y=J.at(-2);if(Y)q=`${Y} ${q}`}return q.length>200?`${q.slice(0,200)}…`:q}catch{return null}}function Ll0(Q){return(Q.replace(/\/+$/,"").split("/").pop()??"repo").replace(/\.git$/,"").replaceAll(/[^A-Za-z\d._-]+/g,"-")||"repo"}async function Fl0(Q){try{let{stdout:X}=await G1("git",["rev-parse","HEAD"],{cwd:Q});return X.trim()}catch{return null}}import{readFileSync as q60}from"node:fs";import{createHash as Po0}from"node:crypto";import{homedir as Co0,userInfo as Oo0}from"node:os";import{join as wI}from"node:path";var J60=U1(X60(),1);import{randomUUID as Mo0}from"node:crypto";var oK=null;async function Io0(Q){if(!oK)oK=new J60.StatsigClient(l1.statsig.clientKey,{userID:Q,customIDs:{CliSessionId:Mo0()}}),await oK.initializeAsync();return oK}async function rK(Q){return(await Io0(Q)).getParameterStore("onfrontier-cli")}var jo0="model-feedback-program",NI="cc_mp_ol",No0="https://feedback.anthropic.com/claude_code";async function Y60(Q=[]){if(Q.includes("--tmux"))f0("claude-hfi --tmux is not supported through onfrontier. Run without --tmux."),process.exit(1);let X=await Ro0(),J=await _o0(),{address:Z}=J,q=J.claude_ai_login?void 0:process.env.ANTHROPIC_API_KEY??J.api_key??void 0;if(await So0(X),C6.info(`claude-hfi ${await yo0()}`),J.claude_ai_login)await wo0(J);let Y=await xo0(),$=await ko0();if(A4(`A browser window opens to authenticate your account. Click "Continue with Google"
167
+ `).map((Y)=>Y.trim()).filter((Y)=>Y.length>0&&!Y.startsWith("⚠")),J=[],Z=!1;for(let Y of X){if(Ul0.test(Y)){Z=!0;continue}if(Z&&Y.startsWith("{")){Z=!1;continue}Z=!1,J.push(Y)}let q=J.at(-1);if(!q)return null;if(/^operable program or batch file\.?$/i.test(q)){let Y=J.at(-2);if(Y)q=`${Y} ${q}`}return q.length>200?`${q.slice(0,200)}…`:q}catch{return null}}function Ll0(Q){return(Q.replace(/\/+$/,"").split("/").pop()??"repo").replace(/\.git$/,"").replaceAll(/[^A-Za-z\d._-]+/g,"-")||"repo"}async function Fl0(Q){try{let{stdout:X}=await G1("git",["rev-parse","HEAD"],{cwd:Q});return X.trim()}catch{return null}}import{readFileSync as q60}from"node:fs";import{createHash as Po0}from"node:crypto";import{homedir as Co0,userInfo as Oo0}from"node:os";import{join as wI}from"node:path";var J60=U1(X60(),1);import{randomUUID as Mo0}from"node:crypto";var oK=null;async function Io0(Q){if(!oK)oK=new J60.StatsigClient(l1.statsig.clientKey,{userID:Q,customIDs:{CliSessionId:Mo0()}}),await oK.initializeAsync();return oK}async function rK(Q){return(await Io0(Q)).getParameterStore("onfrontier-cli")}var jo0="model-feedback-program",NI="cc_mp_ol",No0="https://feedback.anthropic.com/claude_code";async function Y60(Q=[]){if(Q.includes("--tmux"))b0("claude-hfi --tmux is not supported through onfrontier. Run without --tmux."),process.exit(1);let X=await Ro0(),J=await _o0(),{address:Z}=J,q=J.claude_ai_login?void 0:process.env.ANTHROPIC_API_KEY??J.api_key??void 0;if(await So0(X),C6.info(`claude-hfi ${await yo0()}`),J.claude_ai_login)await wo0(J);let Y=await xo0(),$=await ko0();if(A4(`A browser window opens to authenticate your account. Click "Continue with Google"
168
168
  and use your Google account associated to this program:
169
169
 
170
170
  ${DI(Z??"<your_account>@c.onfrontier.ai")}
@@ -174,25 +174,29 @@ code it gives you back into this terminal.`,$?"Sign in":"1. Sign in"),!$)A4(`Bac
174
174
 
175
175
  ${DI(Y)}
176
176
 
177
- and press Enter.`,"2. Interface code");C6.warn("Don't edit files in this repository while a step is running: rating the step replaces them.");let H=["--vscode",...X?["--continue"]:[]];W4(`Starting claude-hfi ${H.join(" ")}`);let K=await G1("claude-hfi",[...H,...$?["--interface-code",Y]:[],...Q],{stdio:"inherit",reject:!1,env:$60(q),extendEnv:!1});process.exit(K.exitCode??1)}async function Ro0(){let Q=await IZ({message:"Start a new session or continue your last one?",initialValue:"new",options:[{value:"new",label:"New session"},{value:"continue",label:"Continue my most recent session",hint:"picks up after its last rated step"}]});if(Z8(Q))f0("Cancelled."),process.exit(0);return Q==="continue"}var Do0=new Set(["ANTHROPIC_BASE_URL","CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS"]);function $60(Q){let X={};for(let[J,Z]of Object.entries(process.env)){let q=J.toUpperCase();if(Z!==void 0&&!Do0.has(q)&&q!=="ANTHROPIC_API_KEY")X[J]=Z}return{...X,ENABLE_TOOL_SEARCH:"true",...Q?{ANTHROPIC_API_KEY:Q}:{}}}var Z60="https://login.onfrontier.ai/home/onfrontier_claude_1/0oa28ecgqlwAZQSvW1d8/aln28ecnwgtH72F2i1d8";async function wo0(Q){let X=Q;if(!X.claude_ai_member)A4(`The program now runs on your claude.ai account. A browser window opens to Okta: sign in
177
+ and press Enter.`,"2. Interface code");C6.warn("Don't edit files in this repository while a step is running: rating the step replaces them.");let H=["--vscode",...X?["--continue"]:[]];W4(`Starting claude-hfi ${H.join(" ")}`);let K=await G1("claude-hfi",[...H,...$?["--interface-code",Y]:[],...Q],{stdio:"inherit",reject:!1,env:$60(q),extendEnv:!1});process.exit(K.exitCode??1)}async function Ro0(){let Q=await IZ({message:"Start a new session or continue your last one?",initialValue:"new",options:[{value:"new",label:"New session"},{value:"continue",label:"Continue my most recent session",hint:"picks up after its last rated step"}]});if(Z8(Q))b0("Cancelled."),process.exit(0);return Q==="continue"}var Do0=new Set(["ANTHROPIC_BASE_URL","CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS"]);function $60(Q){let X={};for(let[J,Z]of Object.entries(process.env)){let q=J.toUpperCase();if(Z!==void 0&&!Do0.has(q)&&q!=="ANTHROPIC_API_KEY")X[J]=Z}return{...X,ENABLE_TOOL_SEARCH:"true",...Q?{ANTHROPIC_API_KEY:Q}:{}}}var Z60="https://login.onfrontier.ai/home/onfrontier_claude_1/0oa28ecgqlwAZQSvW1d8/aln28ecnwgtH72F2i1d8";async function wo0(Q){let X=Q;if(!X.claude_ai_member)A4(`The program now runs on your claude.ai account. A browser window opens to Okta: sign in
178
178
  the way you usually do (your On Frontier email, your Okta password and Okta Verify).
179
179
  claude.ai then opens signed in as
180
180
 
181
181
  ${DI(X.address)}
182
182
 
183
183
  If no window opens, open:
184
- ${Z60}`,"Sign in to claude.ai"),C5(Z60),X=await Eo0();if(!await To0(X)){if(A4(`claude-hfi now opens claude.ai to connect your account: approve it there. If claude.ai
185
- asks you to log in, choose "Continue with SSO" with ${X.address}.`,"Connect claude-hfi"),(await G1("claude-hfi",["--login"],{stdio:"inherit",reject:!1,env:$60(void 0),extendEnv:!1})).exitCode!==0||K60()!==X.address.toLowerCase())f0(`The claude.ai sign-in didn't finish. Run \`onfrontier start\` again and sign in with ${X.address}.`),process.exit(1);E4.setClaudeAiLoginMember(X.claude_ai_member_since??"")}await G1("tmux",["set-environment","-g","-u","ANTHROPIC_API_KEY"],{reject:!1})}async function To0(Q){return K60()===Q.address.toLowerCase()&&await Ao0()&&E4.getClaudeAiLoginMember()===(Q.claude_ai_member_since??"")}function H60(){return process.env.CLAUDE_CONFIG_DIR??wI(Co0(),".claude-hfi")}async function Ao0(){let Q=H60();if(process.platform==="darwin"){let X=Po0("sha256").update(Q.normalize("NFC")).digest("hex").slice(0,8);return(await G1("security",["find-generic-password","-s",`Claude Code-credentials-${X}`,"-a",process.env.USER??Oo0().username],{reject:!1})).exitCode===0}try{return typeof JSON.parse(q60(wI(Q,".credentials.json"),"utf8")).claudeAiOauth?.accessToken==="string"}catch{return!1}}async function Eo0(){let Q=V4();Q.start("Waiting for your claude.ai sign-in");let X=Date.now()+600000;while(Date.now()<X){await new Promise((Z)=>setTimeout(Z,3000));let J=await H6.hfiCredential().catch(()=>{return});if(J?.claude_ai_member)return Q.stop("Signed in to claude.ai"),J}Q.stop("No claude.ai sign-in yet"),f0("We didn't see your claude.ai sign-in. Run `onfrontier start` again."),process.exit(1)}function K60(){try{let X=JSON.parse(q60(wI(H60(),".claude.json"),"utf8")).oauthAccount?.emailAddress;return typeof X==="string"?X.toLowerCase():void 0}catch{return}}function DI(Q){return process.stdout.isTTY&&!process.env.NO_COLOR?`\x1B[1;32m${Q}\x1B[0m`:Q}async function _o0(){let Q=V4();Q.start("Fetching your program account");try{let X=await H6.hfiCredential();return Q.stop(`Program account ready (${X.address})`),X}catch(X){Q.stop("Could not fetch your program account"),f0(X.message),process.exit(1)}}async function So0(Q){if(!await RI("claude-hfi"))f0(`claude-hfi is not installed or not on your PATH.
184
+ ${Z60}`,"Sign in to claude.ai"),C5(Z60),X=await Eo0();if(!await To0(X)){A4(`claude-hfi now opens claude.ai to connect your account: approve it there. If claude.ai
185
+ asks you to log in, choose "Continue with SSO" with ${X.address}.
186
+ If your browser is signed in to Claude with a different account, open the link
187
+ claude-hfi shows in a private window instead.`,"Connect claude-hfi");let J=await G1("claude-hfi",["--login"],{stdio:"inherit",reject:!1,env:$60(void 0),extendEnv:!1}),Z=K60();if(J.exitCode===0&&Z&&Z!==X.address.toLowerCase())b0(`claude-hfi signed in as ${Z}, not your program account ${X.address}.
188
+ Open the sign-in link in a private browser window, or sign out of claude.ai in your
189
+ browser, then run \`onfrontier start\` again.`),process.exit(1);if(J.exitCode!==0||Z!==X.address.toLowerCase())b0(`The claude.ai sign-in didn't finish. Run \`onfrontier start\` again and sign in with ${X.address}.`),process.exit(1);E4.setClaudeAiLoginMember(X.claude_ai_member_since??"")}await G1("tmux",["set-environment","-g","-u","ANTHROPIC_API_KEY"],{reject:!1})}async function To0(Q){return K60()===Q.address.toLowerCase()&&await Ao0()&&E4.getClaudeAiLoginMember()===(Q.claude_ai_member_since??"")}function H60(){return process.env.CLAUDE_CONFIG_DIR??wI(Co0(),".claude-hfi")}async function Ao0(){let Q=H60();if(process.platform==="darwin"){let X=Po0("sha256").update(Q.normalize("NFC")).digest("hex").slice(0,8);return(await G1("security",["find-generic-password","-s",`Claude Code-credentials-${X}`,"-a",process.env.USER??Oo0().username],{reject:!1})).exitCode===0}try{return typeof JSON.parse(q60(wI(Q,".credentials.json"),"utf8")).claudeAiOauth?.accessToken==="string"}catch{return!1}}async function Eo0(){let Q=V4();Q.start("Waiting for your claude.ai sign-in");let X=Date.now()+600000;while(Date.now()<X){await new Promise((Z)=>setTimeout(Z,3000));let J=await H6.hfiCredential().catch(()=>{return});if(J?.claude_ai_member)return Q.stop("Signed in to claude.ai"),J}Q.stop("No claude.ai sign-in yet"),b0("We didn't see your claude.ai sign-in. Run `onfrontier start` again."),process.exit(1)}function K60(){try{let X=JSON.parse(q60(wI(H60(),".claude.json"),"utf8")).oauthAccount?.emailAddress;return typeof X==="string"?X.toLowerCase():void 0}catch{return}}function DI(Q){return process.stdout.isTTY&&!process.env.NO_COLOR?`\x1B[1;32m${Q}\x1B[0m`:Q}async function _o0(){let Q=V4();Q.start("Fetching your program account");try{let X=await H6.hfiCredential();return Q.stop(`Program account ready (${X.address})`),X}catch(X){Q.stop("Could not fetch your program account"),b0(X.message),process.exit(1)}}async function So0(Q){if(!await RI("claude-hfi"))b0(`claude-hfi is not installed or not on your PATH.
186
190
  Download it from ${No0} (sign in with your program Google account),
187
- then follow the install steps on your project page.`),process.exit(1);if(!await RI("tmux"))f0("tmux is not installed. Install it first (`brew install tmux` on macOS, `sudo apt-get install tmux` on Ubuntu or Debian)."),process.exit(1);if(!await RI("code"))f0(`VS Code's \`code\` command is not on your PATH, so the two trajectory windows would not open.
191
+ then follow the install steps on your project page.`),process.exit(1);if(!await RI("tmux"))b0("tmux is not installed. Install it first (`brew install tmux` on macOS, `sudo apt-get install tmux` on Ubuntu or Debian)."),process.exit(1);if(!await RI("code"))b0(`VS Code's \`code\` command is not on your PATH, so the two trajectory windows would not open.
188
192
  In VS Code, press Cmd+Shift+P and run "Shell Command: Install 'code' command in PATH",
189
- then open a new terminal and try again.`),process.exit(1);let X=await G1("git",["rev-parse","--show-toplevel"],{reject:!1});if(X.exitCode!==0)f0("This folder is not inside a git repository. Run from the root of the repository you want to work on."),process.exit(1);let J=X.stdout.trim();if(!vo0(J,process.cwd()))f0(`Run this from the root of your repository:
193
+ then open a new terminal and try again.`),process.exit(1);let X=await G1("git",["rev-parse","--show-toplevel"],{reject:!1});if(X.exitCode!==0)b0("This folder is not inside a git repository. Run from the root of the repository you want to work on."),process.exit(1);let J=X.stdout.trim();if(!vo0(J,process.cwd()))b0(`Run this from the root of your repository:
190
194
 
191
- cd ${J}`),process.exit(1);if(Q){C6.info("Your uncommitted changes are the earlier steps' winning work. Leave them in place: don't stash or reset them.");return}let Z=await G1("git",["status","--porcelain"],{reject:!1});if(Z.exitCode===0&&Z.stdout.trim()!==""){let q=await MZ({message:"Your working tree has uncommitted changes, possibly left by a previous session. Both runs will start from them. To start clean, commit or stash them first. Continue anyway?",initialValue:!1});if(Z8(q)||!q)f0("Cancelled."),process.exit(0)}}async function RI(Q){let X=process.platform==="win32"?"where":"which";return(await G1(X,[Q],{reject:!1})).exitCode===0}function vo0(Q,X){let J=(Z)=>{let q=Z.replace(/[\\/]+$/,"");return process.platform==="win32"?q.replace(/\\/g,"/").toLowerCase():q};return J(Q)===J(X)}async function xo0(){try{let X=(await rK(jo0)).get("hfi_interface_code",NI).trim();return X===""?NI:X}catch{return NI}}async function ko0(){let Q=await G1("claude-hfi",["--help"],{reject:!1});return Q.exitCode===0&&Q.stdout.includes("--interface-code")}async function yo0(){let Q=await G1("claude-hfi",["--version"],{reject:!1});return Q.exitCode===0&&Q.stdout.trim()!==""?Q.stdout.trim():"unknown version"}var ho0="@anthropic-ai/claude-code",bo0="latest",fo0=[],go0=new Map([["v1","This workspace is part of Anthropic's vendor program. Conversations and activity may be reviewed by Anthropic and used to train and improve our models."]]);async function W60(Q=[]){if(LQ("On Frontier start"),E4.clearApiKey(),!await H6.currentUser())f0("Not logged in. Run `onfrontier login` first."),process.exit(1);let J=await uo0(),Z=await co0(J.tasks);if(Z.run_mode==="hfi"){await Y60(Q);return}await mo0();let q=await rK(Z.project_id),Y=q.get("client_type",ho0),$=q.get("client_version",bo0),H=q.get("env",fo0),K=q.get("snapshot_repo",!1);if(await do0(q.get("vendor_notice","")),Z.run_mode==="headless"){await _t(Z,{clientType:Y,clientVersion:$,envOptions:H,snapshotRepo:K});return}let V=await lo0(Z),W=V4();W.start("Creating API key");let G;try{G=await H6.createRouterKey(Z.task_id,V)}catch(z){W.stop("Failed to create an API key"),f0(z.message),process.exit(1)}W.stop("Created API key"),W4(`Starting ${Y} on "${Z.name}" as ${V}`),await OK({clientType:Y,clientVersion:$,apiKey:G.key,modelId:V,envOptions:H,snapshotRepo:K},Q)}async function uo0(){let Q=V4();Q.start("Checking your tasks");let X;try{X=await H6.sessionConfig()}catch(J){if(J instanceof CZ&&J.status===403&&J.message==="agreement_reacceptance_required"){Q.stop("Action needed");let Z=`${l1.app.url}/agreements`;A4(`On Frontier's terms have been updated. Accept them in your browser:
195
+ cd ${J}`),process.exit(1);if(Q){C6.info("Your uncommitted changes are the earlier steps' winning work. Leave them in place: don't stash or reset them.");return}let Z=await G1("git",["status","--porcelain"],{reject:!1});if(Z.exitCode===0&&Z.stdout.trim()!==""){let q=await MZ({message:"Your working tree has uncommitted changes, possibly left by a previous session. Both runs will start from them. To start clean, commit or stash them first. Continue anyway?",initialValue:!1});if(Z8(q)||!q)b0("Cancelled."),process.exit(0)}}async function RI(Q){let X=process.platform==="win32"?"where":"which";return(await G1(X,[Q],{reject:!1})).exitCode===0}function vo0(Q,X){let J=(Z)=>{let q=Z.replace(/[\\/]+$/,"");return process.platform==="win32"?q.replace(/\\/g,"/").toLowerCase():q};return J(Q)===J(X)}async function xo0(){try{let X=(await rK(jo0)).get("hfi_interface_code",NI).trim();return X===""?NI:X}catch{return NI}}async function ko0(){let Q=await G1("claude-hfi",["--help"],{reject:!1});return Q.exitCode===0&&Q.stdout.includes("--interface-code")}async function yo0(){let Q=await G1("claude-hfi",["--version"],{reject:!1});return Q.exitCode===0&&Q.stdout.trim()!==""?Q.stdout.trim():"unknown version"}var ho0="@anthropic-ai/claude-code",bo0="latest",fo0=[],go0=new Map([["v1","This workspace is part of Anthropic's vendor program. Conversations and activity may be reviewed by Anthropic and used to train and improve our models."]]);async function W60(Q=[]){if(LQ("On Frontier start"),E4.clearApiKey(),!await H6.currentUser())b0("Not logged in. Run `onfrontier login` first."),process.exit(1);let J=await uo0(),Z=await co0(J.tasks);if(Z.run_mode==="hfi"){await Y60(Q);return}await mo0();let q=await rK(Z.project_id),Y=q.get("client_type",ho0),$=q.get("client_version",bo0),H=q.get("env",fo0),K=q.get("snapshot_repo",!1);if(await do0(q.get("vendor_notice","")),Z.run_mode==="headless"){await _t(Z,{clientType:Y,clientVersion:$,envOptions:H,snapshotRepo:K});return}let V=await lo0(Z),W=V4();W.start("Creating API key");let G;try{G=await H6.createRouterKey(Z.task_id,V)}catch(z){W.stop("Failed to create an API key"),b0(z.message),process.exit(1)}W.stop("Created API key"),W4(`Starting ${Y} on "${Z.name}" as ${V}`),await OK({clientType:Y,clientVersion:$,apiKey:G.key,modelId:V,envOptions:H,snapshotRepo:K},Q)}async function uo0(){let Q=V4();Q.start("Checking your tasks");let X;try{X=await H6.sessionConfig()}catch(J){if(J instanceof CZ&&J.status===403&&J.message==="agreement_reacceptance_required"){Q.stop("Action needed");let Z=`${l1.app.url}/agreements`;A4(`On Frontier's terms have been updated. Accept them in your browser:
192
196
 
193
197
  ${Z}
194
198
 
195
- Then run \`onfrontier start\` again.`,"Updated agreements"),C5(Z),process.exit(1)}if(J instanceof CZ&&J.status===403&&J.message==="identity_check_required")Q.stop("Action needed"),OZ(),process.exit(1);Q.stop("Failed to check your tasks"),f0(J.message),process.exit(1)}if(X.tasks.length===0)Q.stop("No active tasks"),f0("Your account can't use the CLI at this time."),process.exit(1);return Q.stop(`${X.tasks.length} active task${X.tasks.length===1?"":"s"}`),X}async function mo0(){let Q=await MZ({message:"On Frontier snapshots and uploads your working directory, project contents and other session data for model evaluation and training purposes. Do not run in folders containing personal data or other sensitive information. Continue?",initialValue:!1});if(Z8(Q)||!Q)f0("Cancelled."),process.exit(0)}async function do0(Q){let X=go0.get(Q);if(!X)return;let J=await MZ({message:`${X} Continue?`,initialValue:!1});if(Z8(J)||!J)f0("Cancelled."),process.exit(0)}async function co0(Q){if(Q.length===1)return C6.info(`Task: ${Q[0].name}`),Q[0];let X=await IZ({message:"Which task are you working on?",options:Q.map((J)=>({value:J.task_id,label:J.name,hint:J.run_mode==="headless"?"runs both models automatically":J.run_mode==="hfi"?"runs claude-hfi":J.models.join(", ")}))});if(Z8(X))f0("Cancelled."),process.exit(0);return Q.find((J)=>J.task_id===X)}async function lo0(Q){if(Q.models.length===0)f0("This task has no models configured. Contact support."),process.exit(1);if(Q.models.length===1)return C6.info(`Model: ${Q.models[0]}`),Q.models[0];let X=await IZ({message:"Which model are you running?",options:Q.models.map((J)=>({value:J,label:J}))});if(Z8(X))f0("Cancelled."),process.exit(0);return X}var no0=po0(import.meta.url),{version:V60}=no0("../package.json");async function TI(){try{let Q=await fetch("https://registry.npmjs.org/@onfrontier/cli/latest",{signal:AbortSignal.timeout(3000)}),{version:X}=await Q.json();if(z60.default.gt(X,V60))console.error(`A new version of @onfrontier/cli is available: ${X} (current: ${V60})`),console.error(`
199
+ Then run \`onfrontier start\` again.`,"Updated agreements"),C5(Z),process.exit(1)}if(J instanceof CZ&&J.status===403&&J.message==="identity_check_required")Q.stop("Action needed"),OZ(),process.exit(1);Q.stop("Failed to check your tasks"),b0(J.message),process.exit(1)}if(X.tasks.length===0)Q.stop("No active tasks"),b0("Your account can't use the CLI at this time."),process.exit(1);return Q.stop(`${X.tasks.length} active task${X.tasks.length===1?"":"s"}`),X}async function mo0(){let Q=await MZ({message:"On Frontier snapshots and uploads your working directory, project contents and other session data for model evaluation and training purposes. Do not run in folders containing personal data or other sensitive information. Continue?",initialValue:!1});if(Z8(Q)||!Q)b0("Cancelled."),process.exit(0)}async function do0(Q){let X=go0.get(Q);if(!X)return;let J=await MZ({message:`${X} Continue?`,initialValue:!1});if(Z8(J)||!J)b0("Cancelled."),process.exit(0)}async function co0(Q){if(Q.length===1)return C6.info(`Task: ${Q[0].name}`),Q[0];let X=await IZ({message:"Which task are you working on?",options:Q.map((J)=>({value:J.task_id,label:J.name,hint:J.run_mode==="headless"?"runs both models automatically":J.run_mode==="hfi"?"runs claude-hfi":J.models.join(", ")}))});if(Z8(X))b0("Cancelled."),process.exit(0);return Q.find((J)=>J.task_id===X)}async function lo0(Q){if(Q.models.length===0)b0("This task has no models configured. Contact support."),process.exit(1);if(Q.models.length===1)return C6.info(`Model: ${Q.models[0]}`),Q.models[0];let X=await IZ({message:"Which model are you running?",options:Q.models.map((J)=>({value:J,label:J}))});if(Z8(X))b0("Cancelled."),process.exit(0);return X}var no0=po0(import.meta.url),{version:V60}=no0("../package.json");async function TI(){try{let Q=await fetch("https://registry.npmjs.org/@onfrontier/cli/latest",{signal:AbortSignal.timeout(3000)}),{version:X}=await Q.json();if(z60.default.gt(X,V60))console.error(`A new version of @onfrontier/cli is available: ${X} (current: ${V60})`),console.error(`
196
200
  Update with:
197
201
  npm install -g @onfrontier/cli@latest
198
202
  `),process.exit(1)}catch{}}var U60=oj(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onfrontier/cli",
3
- "version": "0.8.16",
3
+ "version": "0.8.18",
4
4
  "description": "On Frontier CLI - run evaluation sessions with Claude Code",
5
5
  "license": "UNLICENSED",
6
6
  "bin": {