@linzumi/cli 1.0.277 → 1.0.278

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.
@@ -1,7 +1,7 @@
1
1
  import { createRequire as __linzumiBundleCreateRequire } from 'node:module';
2
2
  const require = __linzumiBundleCreateRequire(import.meta.url);
3
3
  var Zp=Object.create;var po=Object.defineProperty;var Yp=Object.getOwnPropertyDescriptor;var Xp=Object.getOwnPropertyNames;var em=Object.getPrototypeOf,nm=Object.prototype.hasOwnProperty;var D=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(n,t)=>(typeof require<"u"?require:n)[t]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var m=(e,n)=>()=>(e&&(n=e(e=0)),n);var K=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports),tm=(e,n)=>{for(var t in n)po(e,t,{get:n[t],enumerable:!0})},rm=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of Xp(n))!nm.call(e,i)&&i!==t&&po(e,i,{get:()=>n[i],enumerable:!(r=Yp(n,i))||r.enumerable});return e};var St=(e,n,t)=>(t=e!=null?Zp(em(e)):{},rm(n||!e||!e.__esModule?po(t,"default",{value:e,enumerable:!0}):t,e));var mo=m(()=>{});function _e(e){return e===void 0?{BS_PRIVATE_NESTED_SOME_NONE:0}:e!==null&&e.BS_PRIVATE_NESTED_SOME_NONE!==void 0?{BS_PRIVATE_NESTED_SOME_NONE:e.BS_PRIVATE_NESTED_SOME_NONE+1|0}:e}function J(e){if(e===null||e.BS_PRIVATE_NESTED_SOME_NONE===void 0)return e;let n=e.BS_PRIVATE_NESTED_SOME_NONE;if(n!==0)return{BS_PRIVATE_NESTED_SOME_NONE:n-1|0}}var B=m(()=>{});function vt(e,n){if(e!==void 0)return n(J(e))}function H(e,n){if(e!==void 0)return _e(n(J(e)))}function Pe(e,n){if(e!==void 0)return n(J(e))}function L(e,n){return e!==void 0?J(e):n}var F=m(()=>{mo();B()});var Br=m(()=>{});function Re(e,n,t){return e.reduce(t,n)}var te=m(()=>{Br();B()});function In(e){if(e.RE_EXN_ID==="JsExn")return _e(e._1)}var zr,om,On,PS,RS,Mn=m(()=>{B();zr=(e=>n=>n&&typeof n[e]=="string"?n[e]:void 0),om=zr("stack"),On=zr("message"),PS=zr("name"),RS=zr("fileName")});var Wr=m(()=>{});var Ds=K((IS,Ns)=>{var qn=D("constants"),am=process.cwd,Hr=null,sm=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return Hr||(Hr=am.call(process)),Hr};try{process.cwd()}catch{}typeof process.chdir=="function"&&(yo=process.chdir,process.chdir=function(e){Hr=null,yo.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,yo));var yo;Ns.exports=dm;function dm(e){qn.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&n(e),e.lutimes||t(e),e.chown=o(e.chown),e.fchown=o(e.fchown),e.lchown=o(e.lchown),e.chmod=r(e.chmod),e.fchmod=r(e.fchmod),e.lchmod=r(e.lchmod),e.chownSync=a(e.chownSync),e.fchownSync=a(e.fchownSync),e.lchownSync=a(e.lchownSync),e.chmodSync=i(e.chmodSync),e.fchmodSync=i(e.fchmodSync),e.lchmodSync=i(e.lchmodSync),e.stat=s(e.stat),e.fstat=s(e.fstat),e.lstat=s(e.lstat),e.statSync=l(e.statSync),e.fstatSync=l(e.fstatSync),e.lstatSync=l(e.lstatSync),e.chmod&&!e.lchmod&&(e.lchmod=function(d,f,p){p&&process.nextTick(p)},e.lchmodSync=function(){}),e.chown&&!e.lchown&&(e.lchown=function(d,f,p,u){u&&process.nextTick(u)},e.lchownSync=function(){}),sm==="win32"&&(e.rename=typeof e.rename!="function"?e.rename:(function(d){function f(p,u,_){var h=Date.now(),y=0;d(p,u,function b(g){if(g&&(g.code==="EACCES"||g.code==="EPERM"||g.code==="EBUSY")&&Date.now()-h<6e4){setTimeout(function(){e.stat(u,function(S,v){S&&S.code==="ENOENT"?d(p,u,b):_(g)})},y),y<100&&(y+=10);return}_&&_(g)})}return Object.setPrototypeOf&&Object.setPrototypeOf(f,d),f})(e.rename)),e.read=typeof e.read!="function"?e.read:(function(d){function f(p,u,_,h,y,b){var g;if(b&&typeof b=="function"){var S=0;g=function(v,T,O){if(v&&v.code==="EAGAIN"&&S<10)return S++,d.call(e,p,u,_,h,y,g);b.apply(this,arguments)}}return d.call(e,p,u,_,h,y,g)}return Object.setPrototypeOf&&Object.setPrototypeOf(f,d),f})(e.read),e.readSync=typeof e.readSync!="function"?e.readSync:(function(d){return function(f,p,u,_,h){for(var y=0;;)try{return d.call(e,f,p,u,_,h)}catch(b){if(b.code==="EAGAIN"&&y<10){y++;continue}throw b}}})(e.readSync);function n(d){d.lchmod=function(f,p,u){d.open(f,qn.O_WRONLY|qn.O_SYMLINK,p,function(_,h){if(_){u&&u(_);return}d.fchmod(h,p,function(y){d.close(h,function(b){u&&u(y||b)})})})},d.lchmodSync=function(f,p){var u=d.openSync(f,qn.O_WRONLY|qn.O_SYMLINK,p),_=!0,h;try{h=d.fchmodSync(u,p),_=!1}finally{if(_)try{d.closeSync(u)}catch{}else d.closeSync(u)}return h}}function t(d){qn.hasOwnProperty("O_SYMLINK")&&d.futimes?(d.lutimes=function(f,p,u,_){d.open(f,qn.O_SYMLINK,function(h,y){if(h){_&&_(h);return}d.futimes(y,p,u,function(b){d.close(y,function(g){_&&_(b||g)})})})},d.lutimesSync=function(f,p,u){var _=d.openSync(f,qn.O_SYMLINK),h,y=!0;try{h=d.futimesSync(_,p,u),y=!1}finally{if(y)try{d.closeSync(_)}catch{}else d.closeSync(_)}return h}):d.futimes&&(d.lutimes=function(f,p,u,_){_&&process.nextTick(_)},d.lutimesSync=function(){})}function r(d){return d&&function(f,p,u){return d.call(e,f,p,function(_){c(_)&&(_=null),u&&u.apply(this,arguments)})}}function i(d){return d&&function(f,p){try{return d.call(e,f,p)}catch(u){if(!c(u))throw u}}}function o(d){return d&&function(f,p,u,_){return d.call(e,f,p,u,function(h){c(h)&&(h=null),_&&_.apply(this,arguments)})}}function a(d){return d&&function(f,p,u){try{return d.call(e,f,p,u)}catch(_){if(!c(_))throw _}}}function s(d){return d&&function(f,p,u){typeof p=="function"&&(u=p,p=null);function _(h,y){y&&(y.uid<0&&(y.uid+=4294967296),y.gid<0&&(y.gid+=4294967296)),u&&u.apply(this,arguments)}return p?d.call(e,f,p,_):d.call(e,f,_)}}function l(d){return d&&function(f,p){var u=p?d.call(e,f,p):d.call(e,f);return u&&(u.uid<0&&(u.uid+=4294967296),u.gid<0&&(u.gid+=4294967296)),u}}function c(d){if(!d||d.code==="ENOSYS")return!0;var f=!process.getuid||process.getuid()!==0;return!!(f&&(d.code==="EINVAL"||d.code==="EPERM"))}}});var Js=K((OS,Ls)=>{var Gs=D("stream").Stream;Ls.exports=lm;function lm(e){return{ReadStream:n,WriteStream:t};function n(r,i){if(!(this instanceof n))return new n(r,i);Gs.call(this);var o=this;this.path=r,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=64*1024,i=i||{};for(var a=Object.keys(i),s=0,l=a.length;s<l;s++){var c=a[s];this[c]=i[c]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.end===void 0)this.end=1/0;else if(typeof this.end!="number")throw TypeError("end must be a Number");if(this.start>this.end)throw new Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){o._read()});return}e.open(this.path,this.flags,this.mode,function(d,f){if(d){o.emit("error",d),o.readable=!1;return}o.fd=f,o.emit("open",f),o._read()})}function t(r,i){if(!(this instanceof t))return new t(r,i);Gs.call(this),this.path=r,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,i=i||{};for(var o=Object.keys(i),a=0,s=o.length;a<s;a++){var l=o[a];this[l]=i[l]}if(this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.start<0)throw new Error("start must be >= zero");this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=e.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}});var Ks=K((MS,Us)=>{"use strict";Us.exports=cm;var um=Object.getPrototypeOf||function(e){return e.__proto__};function cm(e){if(e===null||typeof e!="object")return e;if(e instanceof Object)var n={__proto__:um(e)};else var n=Object.create(null);return Object.getOwnPropertyNames(e).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(e,t))}),n}});var vo=K((qS,So)=>{var X=D("fs"),fm=Ds(),pm=Js(),mm=Ks(),Vr=D("util"),Te,Zr;typeof Symbol=="function"&&typeof Symbol.for=="function"?(Te=Symbol.for("graceful-fs.queue"),Zr=Symbol.for("graceful-fs.previous")):(Te="___graceful-fs.queue",Zr="___graceful-fs.previous");function hm(){}function Ws(e,n){Object.defineProperty(e,Te,{get:function(){return n}})}var Hn=hm;Vr.debuglog?Hn=Vr.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(Hn=function(){var e=Vr.format.apply(Vr,arguments);e="GFS4: "+e.split(/\n/).join(`
4
- GFS4: `),console.error(e)});X[Te]||(Bs=global[Te]||[],Ws(X,Bs),X.close=(function(e){function n(t,r){return e.call(X,t,function(i){i||zs(),typeof r=="function"&&r.apply(this,arguments)})}return Object.defineProperty(n,Zr,{value:e}),n})(X.close),X.closeSync=(function(e){function n(t){e.apply(X,arguments),zs()}return Object.defineProperty(n,Zr,{value:e}),n})(X.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){Hn(X[Te]),D("assert").equal(X[Te].length,0)}));var Bs;global[Te]||Ws(global,X[Te]);So.exports=go(mm(X));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!X.__patched&&(So.exports=go(X),X.__patched=!0);function go(e){fm(e),e.gracefulify=go,e.createReadStream=T,e.createWriteStream=O;var n=e.readFile;e.readFile=t;function t(A,I,M){return typeof I=="function"&&(M=I,I=null),ne(A,I,M);function ne(R,w,x,E){return n(R,w,function(P){P&&(P.code==="EMFILE"||P.code==="ENFILE")?xt([ne,[R,w,x],P,E||Date.now(),Date.now()]):typeof x=="function"&&x.apply(this,arguments)})}}var r=e.writeFile;e.writeFile=i;function i(A,I,M,ne){return typeof M=="function"&&(ne=M,M=null),R(A,I,M,ne);function R(w,x,E,P,k){return r(w,x,E,function(C){C&&(C.code==="EMFILE"||C.code==="ENFILE")?xt([R,[w,x,E,P],C,k||Date.now(),Date.now()]):typeof P=="function"&&P.apply(this,arguments)})}}var o=e.appendFile;o&&(e.appendFile=a);function a(A,I,M,ne){return typeof M=="function"&&(ne=M,M=null),R(A,I,M,ne);function R(w,x,E,P,k){return o(w,x,E,function(C){C&&(C.code==="EMFILE"||C.code==="ENFILE")?xt([R,[w,x,E,P],C,k||Date.now(),Date.now()]):typeof P=="function"&&P.apply(this,arguments)})}}var s=e.copyFile;s&&(e.copyFile=l);function l(A,I,M,ne){return typeof M=="function"&&(ne=M,M=0),R(A,I,M,ne);function R(w,x,E,P,k){return s(w,x,E,function(C){C&&(C.code==="EMFILE"||C.code==="ENFILE")?xt([R,[w,x,E,P],C,k||Date.now(),Date.now()]):typeof P=="function"&&P.apply(this,arguments)})}}var c=e.readdir;e.readdir=f;var d=/^v[0-5]\./;function f(A,I,M){typeof I=="function"&&(M=I,I=null);var ne=d.test(process.version)?function(x,E,P,k){return c(x,R(x,E,P,k))}:function(x,E,P,k){return c(x,E,R(x,E,P,k))};return ne(A,I,M);function R(w,x,E,P){return function(k,C){k&&(k.code==="EMFILE"||k.code==="ENFILE")?xt([ne,[w,x,E],k,P||Date.now(),Date.now()]):(C&&C.sort&&C.sort(),typeof E=="function"&&E.call(this,k,C))}}}if(process.version.substr(0,4)==="v0.8"){var p=pm(e);b=p.ReadStream,S=p.WriteStream}var u=e.ReadStream;u&&(b.prototype=Object.create(u.prototype),b.prototype.open=g);var _=e.WriteStream;_&&(S.prototype=Object.create(_.prototype),S.prototype.open=v),Object.defineProperty(e,"ReadStream",{get:function(){return b},set:function(A){b=A},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return S},set:function(A){S=A},enumerable:!0,configurable:!0});var h=b;Object.defineProperty(e,"FileReadStream",{get:function(){return h},set:function(A){h=A},enumerable:!0,configurable:!0});var y=S;Object.defineProperty(e,"FileWriteStream",{get:function(){return y},set:function(A){y=A},enumerable:!0,configurable:!0});function b(A,I){return this instanceof b?(u.apply(this,arguments),this):b.apply(Object.create(b.prototype),arguments)}function g(){var A=this;Ee(A.path,A.flags,A.mode,function(I,M){I?(A.autoClose&&A.destroy(),A.emit("error",I)):(A.fd=M,A.emit("open",M),A.read())})}function S(A,I){return this instanceof S?(_.apply(this,arguments),this):S.apply(Object.create(S.prototype),arguments)}function v(){var A=this;Ee(A.path,A.flags,A.mode,function(I,M){I?(A.destroy(),A.emit("error",I)):(A.fd=M,A.emit("open",M))})}function T(A,I){return new e.ReadStream(A,I)}function O(A,I){return new e.WriteStream(A,I)}var se=e.open;e.open=Ee;function Ee(A,I,M,ne){return typeof M=="function"&&(ne=M,M=null),R(A,I,M,ne);function R(w,x,E,P,k){return se(w,x,E,function(C,q){C&&(C.code==="EMFILE"||C.code==="ENFILE")?xt([R,[w,x,E,P],C,k||Date.now(),Date.now()]):typeof P=="function"&&P.apply(this,arguments)})}}return e}function xt(e){Hn("ENQUEUE",e[0].name,e[1]),X[Te].push(e),bo()}var Qr;function zs(){for(var e=Date.now(),n=0;n<X[Te].length;++n)X[Te][n].length>2&&(X[Te][n][3]=e,X[Te][n][4]=e);bo()}function bo(){if(clearTimeout(Qr),Qr=void 0,X[Te].length!==0){var e=X[Te].shift(),n=e[0],t=e[1],r=e[2],i=e[3],o=e[4];if(i===void 0)Hn("RETRY",n.name,t),n.apply(null,t);else if(Date.now()-i>=6e4){Hn("TIMEOUT",n.name,t);var a=t.pop();typeof a=="function"&&a.call(null,r)}else{var s=Date.now()-o,l=Math.max(o-i,1),c=Math.min(l*1.2,100);s>=c?(Hn("RETRY",n.name,t),n.apply(null,t.concat([i]))):X[Te].push(e)}Qr===void 0&&(Qr=setTimeout(bo,0))}}});var Vs=K((FS,Hs)=>{function We(e,n){typeof n=="boolean"&&(n={forever:n}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=n||{},this._maxRetryTime=n&&n.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}Hs.exports=We;We.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};We.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null};We.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var n=new Date().getTime();if(e&&n-this._operationStart>=this._maxRetryTime)return this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var t=this._timeouts.shift();if(t===void 0)if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),t=this._timeouts.shift();else return!1;var r=this,i=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},t);return this._options.unref&&i.unref(),!0};We.prototype.attempt=function(e,n){this._fn=e,n&&(n.timeout&&(this._operationTimeout=n.timeout),n.cb&&(this._operationTimeoutCb=n.cb));var t=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){t._operationTimeoutCb()},t._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};We.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)};We.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)};We.prototype.start=We.prototype.try;We.prototype.errors=function(){return this._errors};We.prototype.attempts=function(){return this._attempts};We.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},n=null,t=0,r=0;r<this._errors.length;r++){var i=this._errors[r],o=i.message,a=(e[o]||0)+1;e[o]=a,a>=t&&(n=i,t=a)}return n}});var Qs=K(Vn=>{var _m=Vs();Vn.operation=function(e){var n=Vn.timeouts(e);return new _m(n,{forever:e&&e.forever,unref:e&&e.unref,maxRetryTime:e&&e.maxRetryTime})};Vn.timeouts=function(e){if(e instanceof Array)return[].concat(e);var n={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var t in e)n[t]=e[t];if(n.minTimeout>n.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var r=[],i=0;i<n.retries;i++)r.push(this.createTimeout(i,n));return e&&e.forever&&!r.length&&r.push(this.createTimeout(i,n)),r.sort(function(o,a){return o-a}),r};Vn.createTimeout=function(e,n){var t=n.randomize?Math.random()+1:1,r=Math.round(t*n.minTimeout*Math.pow(n.factor,e));return r=Math.min(r,n.maxTimeout),r};Vn.wrap=function(e,n,t){if(n instanceof Array&&(t=n,n=null),!t){t=[];for(var r in e)typeof e[r]=="function"&&t.push(r)}for(var i=0;i<t.length;i++){var o=t[i],a=e[o];e[o]=function(l){var c=Vn.operation(n),d=Array.prototype.slice.call(arguments,1),f=d.pop();d.push(function(p){c.retry(p)||(p&&(arguments[0]=c.mainError()),f.apply(this,arguments))}),c.attempt(function(){l.apply(e,d)})}.bind(e,a),e[o].options=n}}});var Ys=K(($S,Zs)=>{Zs.exports=Qs()});var Xs=K((NS,Yr)=>{Yr.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];process.platform!=="win32"&&Yr.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Yr.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var id=K((DS,Tt)=>{var V=global.process,Qn=function(e){return e&&typeof e=="object"&&typeof e.removeListener=="function"&&typeof e.emit=="function"&&typeof e.reallyExit=="function"&&typeof e.listeners=="function"&&typeof e.kill=="function"&&typeof e.pid=="number"&&typeof e.on=="function"};Qn(V)?(ed=D("assert"),wt=Xs(),nd=/^win/i.test(V.platform),ir=D("events"),typeof ir!="function"&&(ir=ir.EventEmitter),V.__signal_exit_emitter__?ye=V.__signal_exit_emitter__:(ye=V.__signal_exit_emitter__=new ir,ye.count=0,ye.emitted={}),ye.infinite||(ye.setMaxListeners(1/0),ye.infinite=!0),Tt.exports=function(e,n){if(!Qn(global.process))return function(){};ed.equal(typeof e,"function","a callback must be provided for exit handler"),kt===!1&&xo();var t="exit";n&&n.alwaysLast&&(t="afterexit");var r=function(){ye.removeListener(t,e),ye.listeners("exit").length===0&&ye.listeners("afterexit").length===0&&Xr()};return ye.on(t,e),r},Xr=function(){!kt||!Qn(global.process)||(kt=!1,wt.forEach(function(n){try{V.removeListener(n,ei[n])}catch{}}),V.emit=ni,V.reallyExit=wo,ye.count-=1)},Tt.exports.unload=Xr,Zn=function(n,t,r){ye.emitted[n]||(ye.emitted[n]=!0,ye.emit(n,t,r))},ei={},wt.forEach(function(e){ei[e]=function(){if(Qn(global.process)){var t=V.listeners(e);t.length===ye.count&&(Xr(),Zn("exit",null,e),Zn("afterexit",null,e),nd&&e==="SIGHUP"&&(e="SIGINT"),V.kill(V.pid,e))}}}),Tt.exports.signals=function(){return wt},kt=!1,xo=function(){kt||!Qn(global.process)||(kt=!0,ye.count+=1,wt=wt.filter(function(n){try{return V.on(n,ei[n]),!0}catch{return!1}}),V.emit=rd,V.reallyExit=td)},Tt.exports.load=xo,wo=V.reallyExit,td=function(n){Qn(global.process)&&(V.exitCode=n||0,Zn("exit",V.exitCode,null),Zn("afterexit",V.exitCode,null),wo.call(V,V.exitCode))},ni=V.emit,rd=function(n,t){if(n==="exit"&&Qn(global.process)){t!==void 0&&(V.exitCode=t);var r=ni.apply(this,arguments);return Zn("exit",V.exitCode,null),Zn("afterexit",V.exitCode,null),r}else return ni.apply(this,arguments)}):Tt.exports=function(){return function(){}};var ed,wt,nd,ir,ye,Xr,Zn,ei,kt,xo,wo,td,ni,rd});var ld=K((GS,or)=>{"use strict";var ym=D("path"),Co=vo(),gm=Ys(),bm=id(),yn={};function Ct(e,n){return n.lockfilePath||`${e}.lock`}function Ao(e,n,t){if(!n.realpath)return t(null,ym.resolve(e));n.fs.realpath(e,t)}function ko(e,n,t){n.fs.mkdir(Ct(e,n),r=>{if(!r)return t();if(r.code!=="EEXIST")return t(r);if(n.stale<=0)return t(Object.assign(new Error("Lock file is already being hold"),{code:"ELOCKED",file:e}));n.fs.stat(Ct(e,n),(i,o)=>{if(i)return i.code==="ENOENT"?ko(e,{...n,stale:0},t):t(i);if(!ad(o,n))return t(Object.assign(new Error("Lock file is already being hold"),{code:"ELOCKED",file:e}));sd(e,n,a=>{if(a)return t(a);ko(e,{...n,stale:0},t)})})})}function ad(e,n){return e.mtime.getTime()<Date.now()-n.stale}function sd(e,n,t){n.fs.rmdir(Ct(e,n),r=>{if(r&&r.code!=="ENOENT")return t(r);t()})}function To(e,n){let t=yn[e];t.updateTimeout||(t.updateDelay=t.updateDelay||n.update,t.updateTimeout=setTimeout(()=>{let r=Date.now()/1e3;t.updateTimeout=null,n.fs.utimes(Ct(e,n),r,r,i=>{if(!t.released){if(t.lastUpdate<=Date.now()-n.stale&&t.lastUpdate>Date.now()-n.stale*2){let o=Object.assign(new Error(t.updateError||"Unable to update lock within the stale threshold"),{code:"ECOMPROMISED"});return od(e,t,o)}if(i)return i.code==="ENOENT"?od(e,t,Object.assign(i,{code:"ECOMPROMISED"})):(t.updateError=i,t.updateDelay=1e3,To(e,n));t.lastUpdate=Date.now(),t.updateError=null,t.updateDelay=null,To(e,n)}})},t.updateDelay),t.updateTimeout.unref&&t.updateTimeout.unref())}function od(e,n,t){n.released=!0,n.updateTimeout&&clearTimeout(n.updateTimeout),yn[e]===n&&delete yn[e],n.options.onCompromised(t)}function Sm(e,n,t){n={stale:1e4,update:null,realpath:!0,retries:0,fs:Co,onCompromised:r=>{throw r},...n},n.retries=n.retries||0,n.retries=typeof n.retries=="number"?{retries:n.retries}:n.retries,n.stale=Math.max(n.stale||0,2e3),n.update=n.update==null?n.stale/2:n.update||0,n.update=Math.max(Math.min(n.update,n.stale/2),1e3),Ao(e,n,(r,i)=>{if(r)return t(r);let o=gm.operation(n.retries);o.attempt(()=>{ko(i,n,a=>{if(o.retry(a))return;if(a)return t(o.mainError());let s=yn[i]={options:n,lastUpdate:Date.now()};To(i,n),t(null,l=>{if(s.released)return l&&l(Object.assign(new Error("Lock is already released"),{code:"ERELEASED"}));dd(i,{...n,realpath:!1},l)})})})})}function dd(e,n,t){n={fs:Co,realpath:!0,...n},Ao(e,n,(r,i)=>{if(r)return t(r);let o=yn[i];if(!o)return t(Object.assign(new Error("Lock is not acquired/owned by you"),{code:"ENOTACQUIRED"}));o.updateTimeout&&clearTimeout(o.updateTimeout),o.released=!0,delete yn[i],sd(i,n,t)})}function vm(e,n,t){n={stale:1e4,realpath:!0,fs:Co,...n},n.stale=Math.max(n.stale||0,2e3),Ao(e,n,(r,i)=>{if(r)return t(r);n.fs.stat(Ct(i,n),(o,a)=>o?o.code==="ENOENT"?t(null,!1):t(o):t(null,!ad(a,n)))})}function xm(){return yn}bm(()=>{for(let e in yn){let n=yn[e].options;try{n.fs.rmdirSync(Ct(e,n))}catch{}}});or.exports.lock=Sm;or.exports.unlock=dd;or.exports.check=vm;or.exports.getLocks=xm});var cd=K((LS,ud)=>{"use strict";var wm=vo();function km(e){let n=["mkdir","realpath","stat","rmdir","utimes"],t={...e};return n.forEach(r=>{t[r]=(...i)=>{let o=i.pop(),a;try{a=e[`${r}Sync`](...i)}catch(s){return o(s)}o(null,a)}}),t}function Tm(e){return(...n)=>new Promise((t,r)=>{n.push((i,o)=>{i?r(i):t(o)}),e(...n)})}function Cm(e){return(...n)=>{let t,r;if(n.push((i,o)=>{t=i,r=o}),e(...n),t)throw t;return r}}function Am(e){if(e={...e},e.fs=km(e.fs||wm),typeof e.retries=="number"&&e.retries>0||e.retries&&typeof e.retries.retries=="number"&&e.retries.retries>0)throw Object.assign(new Error("Cannot use retries with the sync api"),{code:"ESYNC"});return e}ud.exports={toPromise:Tm,toSync:Cm,toSyncOptions:Am}});var pd=K((JS,Fn)=>{"use strict";var At=ld(),{toPromise:ti,toSync:ri,toSyncOptions:Eo}=cd();async function fd(e,n){let t=await ti(At.lock)(e,n);return ti(t)}function Em(e,n){let t=ri(At.lock)(e,Eo(n));return ri(t)}function Pm(e,n){return ti(At.unlock)(e,n)}function Rm(e,n){return ri(At.unlock)(e,Eo(n))}function Im(e,n){return ti(At.check)(e,n)}function Om(e,n){return ri(At.check)(e,Eo(n))}Fn.exports=fd;Fn.exports.lock=fd;Fn.exports.unlock=Pm;Fn.exports.lockSync=Em;Fn.exports.unlockSync=Rm;Fn.exports.check=Im;Fn.exports.checkSync=Om});var md=m(()=>{});var Po=m(()=>{});var ar=m(()=>{});var ge=m(()=>{md();Po();ar()});function Fm(e){return e==null?!1:typeof e.RE_EXN_ID=="string"}function qe(e){return Fm(e)?e:{RE_EXN_ID:"JsExn",_1:e}}function Oo(e){let n=Io[e];if(n!==void 0){let t=n+1|0;return Io[e]=t,e+("/"+t)}return Io[e]=1,e}var Io,Ie=m(()=>{Io={}});var jm,be=m(()=>{Mn();F();Wr();jm=St(pd(),1);ge();B();Ie()});function bd(e,n){return e!==void 0&&n!==void 0?e===n?{TAG:"Match",version:e}:{TAG:"Mismatch",pathVersion:e,pinnedVersion:n}:{TAG:"Unverified",pathVersion:e,pinnedVersion:n}}var gd,Sd=m(()=>{te();be();F();ge();gd=new RegExp("(\\d+\\.\\d+\\.\\d+)")});function vd(e){return e!=="claude_code"}function Nm(e,n){let t=bd(e,n);switch(t.TAG){case"Match":return{TAG:"Ok",_0:t.version};case"Mismatch":return{TAG:"Error",_0:"hosted_codex_runtime_refused reason=mismatch observed="+t.pathVersion+" expected="+t.pinnedVersion};case"Unverified":return{TAG:"Error",_0:"hosted_codex_runtime_refused reason=unverified observed=unverified expected="+n}}}function xd(e,n,t){let r;if(e===0&&n.length<=1048576){let i=gd.exec(n);r=i==null?void 0:Pe(i.slice(1)[0],o=>o)}else r=void 0;return Nm(r,t)}var wd=m(()=>{F();Sd()});var kd,Td,Mo=m(()=>{wd();kd=vd,Td=xd});var Ad,Cd=m(()=>{Ad={name:"@linzumi/cli",version:"1.0.277",description:"Linzumi CLI \u2014 point a Codex agent at the real code on your laptop, with your team watching and steering from shared threads.",type:"module",bin:{linzumi:"bin/linzumi.js"},files:["README.md","bin","dist","scripts","!scripts/build-*-oracle.mjs"],scripts:{build:"rescript build ../linzumi-cli-rescript && node scripts/build.mjs","bump-version":"node scripts/bump-cli-version.mjs",test:"pnpm --dir ../linzumi-cli-rescript test && npm run test:operational",typecheck:"rescript build ../linzumi-cli-rescript && tsgo --noEmit -p tsconfig.source.json",prepack:"rescript build -q ../linzumi-cli-rescript && node scripts/build.mjs","pack:dry-run":"npm pack --dry-run","test:operational":"vitest run --config vitest.config.mjs","vendor:codex-app-server-protocol":"tsx scripts/vendor-codex-app-server-protocol.ts","test:startup":"npm run build && node --test --test-concurrency=1 ../linzumi-cli-rescript/src/parity/CommanderStartupRefusalConformance.res.mjs","typecheck:all":"rescript build ../linzumi-cli-rescript && tsgo --noEmit -p tsconfig.json","typecheck:watch":"rescript build ../linzumi-cli-rescript && tsgo --noEmit -w -p tsconfig.source.json","test:agent-source":"LINZUMI_CI_QUARANTINE=0 pnpm exec vitest run --config vitest.config.mjs test/channelSession.test.ts test/kandanQueue.test.ts -t '(retains three busy accepted source snapshots without fusing or interrupting|keeps different accepted agent sources distinct through interrupt pickup)' && pnpm --dir ../linzumi-cli-rescript build && pnpm --dir ../linzumi-cli-rescript exec node --import tsx src/parity/AgentOpenaiModelProviderConformance.res.mjs && pnpm --dir ../linzumi-cli-rescript exec node --import tsx src/parity/WorkerMintCredentialConformance.res.mjs","codex:history-table":"node scripts/codex_history_table.mjs","vendor:codex-app-server-protocol:check":"tsx scripts/vendor-codex-app-server-protocol.ts --check"},keywords:["linzumi","kandan","codex","local-runner"],license:"MIT",publishConfig:{access:"public"},dependencies:{"@anthropic-ai/claude-agent-sdk":"0.3.283","@inquirer/prompts":"^7.8.6","@modelcontextprotocol/sdk":"^1.29.0","@openai/codex":"0.153.2",blessed:"^0.1.81","proper-lockfile":"3.2.0",undici:"^6.25.0",ws:"^8.18.0",zod:"^3.25.76"},engines:{node:">=20"},readmeFilename:"README.md",devDependencies:{"@types/blessed":"^0.1.27","@types/node":"^22.18.6","@types/proper-lockfile":"4.1.4","@typescript/native-preview":"7.0.0-dev.20260703.1",esbuild:"^0.27.2","fast-check":"^3.23.2",rescript:"12.3.0",tsx:"^4.21.0",typescript:"^5.9.3",vitest:"^1.6.1"}}});var ai,si=m(()=>{"use strict";Cd();ai=Ad.dependencies["@openai/codex"]});import{readFileSync as Lm}from"node:fs";function Km(e=process.env,n=void 0,t=r=>Lm(r,"utf8")){let r=e.SMOLCLOUD_API_KEY?.trim();if(r!==void 0&&r!=="")return r;if(n?.apiKeyFile!==void 0&&n.apiKeyFile!=="")try{let o=t(n.apiKeyFile).trim();if(o!=="")return o}catch{}let i=e.SMOL_CLOUD_TOKEN?.trim();if(i!==void 0&&i!=="")return i}function jo(e){let n=e.env??process.env,t=Km(n,e.config);if(t===void 0)return;let r=(n.SMOLCLOUD_BASE_URL??e.config?.baseUrl??Jm).replace(/\/+$/,"");return e.fetchImpl===void 0?{baseUrl:r,apiKey:t}:{baseUrl:r,apiKey:t,fetchImpl:e.fetchImpl}}function di(e){return e.replace(/\bsmk_[A-Za-z0-9._-]+/g,"smk_[REDACTED]")}function Ed(e){return e.split("/").map(encodeURIComponent).join("/")}async function gn(e,n,t,r={}){let i=e.fetchImpl??fetch,o={authorization:`Bearer ${e.apiKey}`},a;r.json!==void 0?(o["content-type"]="application/json",a=JSON.stringify(r.json)):r.body!==void 0&&(o["content-type"]="application/octet-stream",a=r.body);let s=new AbortController,l=r.timeoutMs??Fo,c=setTimeout(()=>s.abort(),l),d;try{d=await i(`${e.baseUrl}${t}`,{method:n,headers:o,body:a??null,signal:s.signal})}catch(p){throw p instanceof Error&&p.name==="AbortError"?new je("TIMEOUT",`smolcloud ${n} ${t} timed out after ${l}ms`):new je("CONNECTION",`smolcloud request failed: ${p instanceof Error?p.message:String(p)}`)}finally{clearTimeout(c)}if(!d.ok){let p=await d.text().catch(()=>""),u=d.status===404?"NOT_FOUND":d.status===401||d.status===403?"UNAUTHORIZED":"CLOUD_ERROR";throw new je(u,`smolcloud ${n} ${t} \u2192 ${d.status}${p===""?"":`: ${p}`}`)}return r.accept==="bytes"?Buffer.from(await d.arrayBuffer()):d.status===204?void 0:(d.headers.get("content-type")??"").includes("application/json")?await d.json():void 0}async function*Bm(e){let n=e.getReader(),t=new TextDecoder,r="",i="",o=[],a=()=>{let s=i,l=o.join(`
4
+ GFS4: `),console.error(e)});X[Te]||(Bs=global[Te]||[],Ws(X,Bs),X.close=(function(e){function n(t,r){return e.call(X,t,function(i){i||zs(),typeof r=="function"&&r.apply(this,arguments)})}return Object.defineProperty(n,Zr,{value:e}),n})(X.close),X.closeSync=(function(e){function n(t){e.apply(X,arguments),zs()}return Object.defineProperty(n,Zr,{value:e}),n})(X.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){Hn(X[Te]),D("assert").equal(X[Te].length,0)}));var Bs;global[Te]||Ws(global,X[Te]);So.exports=go(mm(X));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!X.__patched&&(So.exports=go(X),X.__patched=!0);function go(e){fm(e),e.gracefulify=go,e.createReadStream=T,e.createWriteStream=O;var n=e.readFile;e.readFile=t;function t(A,I,M){return typeof I=="function"&&(M=I,I=null),ne(A,I,M);function ne(R,w,x,E){return n(R,w,function(P){P&&(P.code==="EMFILE"||P.code==="ENFILE")?xt([ne,[R,w,x],P,E||Date.now(),Date.now()]):typeof x=="function"&&x.apply(this,arguments)})}}var r=e.writeFile;e.writeFile=i;function i(A,I,M,ne){return typeof M=="function"&&(ne=M,M=null),R(A,I,M,ne);function R(w,x,E,P,k){return r(w,x,E,function(C){C&&(C.code==="EMFILE"||C.code==="ENFILE")?xt([R,[w,x,E,P],C,k||Date.now(),Date.now()]):typeof P=="function"&&P.apply(this,arguments)})}}var o=e.appendFile;o&&(e.appendFile=a);function a(A,I,M,ne){return typeof M=="function"&&(ne=M,M=null),R(A,I,M,ne);function R(w,x,E,P,k){return o(w,x,E,function(C){C&&(C.code==="EMFILE"||C.code==="ENFILE")?xt([R,[w,x,E,P],C,k||Date.now(),Date.now()]):typeof P=="function"&&P.apply(this,arguments)})}}var s=e.copyFile;s&&(e.copyFile=l);function l(A,I,M,ne){return typeof M=="function"&&(ne=M,M=0),R(A,I,M,ne);function R(w,x,E,P,k){return s(w,x,E,function(C){C&&(C.code==="EMFILE"||C.code==="ENFILE")?xt([R,[w,x,E,P],C,k||Date.now(),Date.now()]):typeof P=="function"&&P.apply(this,arguments)})}}var c=e.readdir;e.readdir=f;var d=/^v[0-5]\./;function f(A,I,M){typeof I=="function"&&(M=I,I=null);var ne=d.test(process.version)?function(x,E,P,k){return c(x,R(x,E,P,k))}:function(x,E,P,k){return c(x,E,R(x,E,P,k))};return ne(A,I,M);function R(w,x,E,P){return function(k,C){k&&(k.code==="EMFILE"||k.code==="ENFILE")?xt([ne,[w,x,E],k,P||Date.now(),Date.now()]):(C&&C.sort&&C.sort(),typeof E=="function"&&E.call(this,k,C))}}}if(process.version.substr(0,4)==="v0.8"){var p=pm(e);b=p.ReadStream,S=p.WriteStream}var u=e.ReadStream;u&&(b.prototype=Object.create(u.prototype),b.prototype.open=g);var _=e.WriteStream;_&&(S.prototype=Object.create(_.prototype),S.prototype.open=v),Object.defineProperty(e,"ReadStream",{get:function(){return b},set:function(A){b=A},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return S},set:function(A){S=A},enumerable:!0,configurable:!0});var h=b;Object.defineProperty(e,"FileReadStream",{get:function(){return h},set:function(A){h=A},enumerable:!0,configurable:!0});var y=S;Object.defineProperty(e,"FileWriteStream",{get:function(){return y},set:function(A){y=A},enumerable:!0,configurable:!0});function b(A,I){return this instanceof b?(u.apply(this,arguments),this):b.apply(Object.create(b.prototype),arguments)}function g(){var A=this;Ee(A.path,A.flags,A.mode,function(I,M){I?(A.autoClose&&A.destroy(),A.emit("error",I)):(A.fd=M,A.emit("open",M),A.read())})}function S(A,I){return this instanceof S?(_.apply(this,arguments),this):S.apply(Object.create(S.prototype),arguments)}function v(){var A=this;Ee(A.path,A.flags,A.mode,function(I,M){I?(A.destroy(),A.emit("error",I)):(A.fd=M,A.emit("open",M))})}function T(A,I){return new e.ReadStream(A,I)}function O(A,I){return new e.WriteStream(A,I)}var se=e.open;e.open=Ee;function Ee(A,I,M,ne){return typeof M=="function"&&(ne=M,M=null),R(A,I,M,ne);function R(w,x,E,P,k){return se(w,x,E,function(C,q){C&&(C.code==="EMFILE"||C.code==="ENFILE")?xt([R,[w,x,E,P],C,k||Date.now(),Date.now()]):typeof P=="function"&&P.apply(this,arguments)})}}return e}function xt(e){Hn("ENQUEUE",e[0].name,e[1]),X[Te].push(e),bo()}var Qr;function zs(){for(var e=Date.now(),n=0;n<X[Te].length;++n)X[Te][n].length>2&&(X[Te][n][3]=e,X[Te][n][4]=e);bo()}function bo(){if(clearTimeout(Qr),Qr=void 0,X[Te].length!==0){var e=X[Te].shift(),n=e[0],t=e[1],r=e[2],i=e[3],o=e[4];if(i===void 0)Hn("RETRY",n.name,t),n.apply(null,t);else if(Date.now()-i>=6e4){Hn("TIMEOUT",n.name,t);var a=t.pop();typeof a=="function"&&a.call(null,r)}else{var s=Date.now()-o,l=Math.max(o-i,1),c=Math.min(l*1.2,100);s>=c?(Hn("RETRY",n.name,t),n.apply(null,t.concat([i]))):X[Te].push(e)}Qr===void 0&&(Qr=setTimeout(bo,0))}}});var Vs=K((FS,Hs)=>{function We(e,n){typeof n=="boolean"&&(n={forever:n}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=n||{},this._maxRetryTime=n&&n.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}Hs.exports=We;We.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};We.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null};We.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var n=new Date().getTime();if(e&&n-this._operationStart>=this._maxRetryTime)return this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var t=this._timeouts.shift();if(t===void 0)if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),t=this._timeouts.shift();else return!1;var r=this,i=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},t);return this._options.unref&&i.unref(),!0};We.prototype.attempt=function(e,n){this._fn=e,n&&(n.timeout&&(this._operationTimeout=n.timeout),n.cb&&(this._operationTimeoutCb=n.cb));var t=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){t._operationTimeoutCb()},t._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};We.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)};We.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)};We.prototype.start=We.prototype.try;We.prototype.errors=function(){return this._errors};We.prototype.attempts=function(){return this._attempts};We.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},n=null,t=0,r=0;r<this._errors.length;r++){var i=this._errors[r],o=i.message,a=(e[o]||0)+1;e[o]=a,a>=t&&(n=i,t=a)}return n}});var Qs=K(Vn=>{var _m=Vs();Vn.operation=function(e){var n=Vn.timeouts(e);return new _m(n,{forever:e&&e.forever,unref:e&&e.unref,maxRetryTime:e&&e.maxRetryTime})};Vn.timeouts=function(e){if(e instanceof Array)return[].concat(e);var n={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var t in e)n[t]=e[t];if(n.minTimeout>n.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var r=[],i=0;i<n.retries;i++)r.push(this.createTimeout(i,n));return e&&e.forever&&!r.length&&r.push(this.createTimeout(i,n)),r.sort(function(o,a){return o-a}),r};Vn.createTimeout=function(e,n){var t=n.randomize?Math.random()+1:1,r=Math.round(t*n.minTimeout*Math.pow(n.factor,e));return r=Math.min(r,n.maxTimeout),r};Vn.wrap=function(e,n,t){if(n instanceof Array&&(t=n,n=null),!t){t=[];for(var r in e)typeof e[r]=="function"&&t.push(r)}for(var i=0;i<t.length;i++){var o=t[i],a=e[o];e[o]=function(l){var c=Vn.operation(n),d=Array.prototype.slice.call(arguments,1),f=d.pop();d.push(function(p){c.retry(p)||(p&&(arguments[0]=c.mainError()),f.apply(this,arguments))}),c.attempt(function(){l.apply(e,d)})}.bind(e,a),e[o].options=n}}});var Ys=K(($S,Zs)=>{Zs.exports=Qs()});var Xs=K((NS,Yr)=>{Yr.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];process.platform!=="win32"&&Yr.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Yr.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var id=K((DS,Tt)=>{var V=global.process,Qn=function(e){return e&&typeof e=="object"&&typeof e.removeListener=="function"&&typeof e.emit=="function"&&typeof e.reallyExit=="function"&&typeof e.listeners=="function"&&typeof e.kill=="function"&&typeof e.pid=="number"&&typeof e.on=="function"};Qn(V)?(ed=D("assert"),wt=Xs(),nd=/^win/i.test(V.platform),ir=D("events"),typeof ir!="function"&&(ir=ir.EventEmitter),V.__signal_exit_emitter__?ye=V.__signal_exit_emitter__:(ye=V.__signal_exit_emitter__=new ir,ye.count=0,ye.emitted={}),ye.infinite||(ye.setMaxListeners(1/0),ye.infinite=!0),Tt.exports=function(e,n){if(!Qn(global.process))return function(){};ed.equal(typeof e,"function","a callback must be provided for exit handler"),kt===!1&&xo();var t="exit";n&&n.alwaysLast&&(t="afterexit");var r=function(){ye.removeListener(t,e),ye.listeners("exit").length===0&&ye.listeners("afterexit").length===0&&Xr()};return ye.on(t,e),r},Xr=function(){!kt||!Qn(global.process)||(kt=!1,wt.forEach(function(n){try{V.removeListener(n,ei[n])}catch{}}),V.emit=ni,V.reallyExit=wo,ye.count-=1)},Tt.exports.unload=Xr,Zn=function(n,t,r){ye.emitted[n]||(ye.emitted[n]=!0,ye.emit(n,t,r))},ei={},wt.forEach(function(e){ei[e]=function(){if(Qn(global.process)){var t=V.listeners(e);t.length===ye.count&&(Xr(),Zn("exit",null,e),Zn("afterexit",null,e),nd&&e==="SIGHUP"&&(e="SIGINT"),V.kill(V.pid,e))}}}),Tt.exports.signals=function(){return wt},kt=!1,xo=function(){kt||!Qn(global.process)||(kt=!0,ye.count+=1,wt=wt.filter(function(n){try{return V.on(n,ei[n]),!0}catch{return!1}}),V.emit=rd,V.reallyExit=td)},Tt.exports.load=xo,wo=V.reallyExit,td=function(n){Qn(global.process)&&(V.exitCode=n||0,Zn("exit",V.exitCode,null),Zn("afterexit",V.exitCode,null),wo.call(V,V.exitCode))},ni=V.emit,rd=function(n,t){if(n==="exit"&&Qn(global.process)){t!==void 0&&(V.exitCode=t);var r=ni.apply(this,arguments);return Zn("exit",V.exitCode,null),Zn("afterexit",V.exitCode,null),r}else return ni.apply(this,arguments)}):Tt.exports=function(){return function(){}};var ed,wt,nd,ir,ye,Xr,Zn,ei,kt,xo,wo,td,ni,rd});var ld=K((GS,or)=>{"use strict";var ym=D("path"),Co=vo(),gm=Ys(),bm=id(),yn={};function Ct(e,n){return n.lockfilePath||`${e}.lock`}function Ao(e,n,t){if(!n.realpath)return t(null,ym.resolve(e));n.fs.realpath(e,t)}function ko(e,n,t){n.fs.mkdir(Ct(e,n),r=>{if(!r)return t();if(r.code!=="EEXIST")return t(r);if(n.stale<=0)return t(Object.assign(new Error("Lock file is already being hold"),{code:"ELOCKED",file:e}));n.fs.stat(Ct(e,n),(i,o)=>{if(i)return i.code==="ENOENT"?ko(e,{...n,stale:0},t):t(i);if(!ad(o,n))return t(Object.assign(new Error("Lock file is already being hold"),{code:"ELOCKED",file:e}));sd(e,n,a=>{if(a)return t(a);ko(e,{...n,stale:0},t)})})})}function ad(e,n){return e.mtime.getTime()<Date.now()-n.stale}function sd(e,n,t){n.fs.rmdir(Ct(e,n),r=>{if(r&&r.code!=="ENOENT")return t(r);t()})}function To(e,n){let t=yn[e];t.updateTimeout||(t.updateDelay=t.updateDelay||n.update,t.updateTimeout=setTimeout(()=>{let r=Date.now()/1e3;t.updateTimeout=null,n.fs.utimes(Ct(e,n),r,r,i=>{if(!t.released){if(t.lastUpdate<=Date.now()-n.stale&&t.lastUpdate>Date.now()-n.stale*2){let o=Object.assign(new Error(t.updateError||"Unable to update lock within the stale threshold"),{code:"ECOMPROMISED"});return od(e,t,o)}if(i)return i.code==="ENOENT"?od(e,t,Object.assign(i,{code:"ECOMPROMISED"})):(t.updateError=i,t.updateDelay=1e3,To(e,n));t.lastUpdate=Date.now(),t.updateError=null,t.updateDelay=null,To(e,n)}})},t.updateDelay),t.updateTimeout.unref&&t.updateTimeout.unref())}function od(e,n,t){n.released=!0,n.updateTimeout&&clearTimeout(n.updateTimeout),yn[e]===n&&delete yn[e],n.options.onCompromised(t)}function Sm(e,n,t){n={stale:1e4,update:null,realpath:!0,retries:0,fs:Co,onCompromised:r=>{throw r},...n},n.retries=n.retries||0,n.retries=typeof n.retries=="number"?{retries:n.retries}:n.retries,n.stale=Math.max(n.stale||0,2e3),n.update=n.update==null?n.stale/2:n.update||0,n.update=Math.max(Math.min(n.update,n.stale/2),1e3),Ao(e,n,(r,i)=>{if(r)return t(r);let o=gm.operation(n.retries);o.attempt(()=>{ko(i,n,a=>{if(o.retry(a))return;if(a)return t(o.mainError());let s=yn[i]={options:n,lastUpdate:Date.now()};To(i,n),t(null,l=>{if(s.released)return l&&l(Object.assign(new Error("Lock is already released"),{code:"ERELEASED"}));dd(i,{...n,realpath:!1},l)})})})})}function dd(e,n,t){n={fs:Co,realpath:!0,...n},Ao(e,n,(r,i)=>{if(r)return t(r);let o=yn[i];if(!o)return t(Object.assign(new Error("Lock is not acquired/owned by you"),{code:"ENOTACQUIRED"}));o.updateTimeout&&clearTimeout(o.updateTimeout),o.released=!0,delete yn[i],sd(i,n,t)})}function vm(e,n,t){n={stale:1e4,realpath:!0,fs:Co,...n},n.stale=Math.max(n.stale||0,2e3),Ao(e,n,(r,i)=>{if(r)return t(r);n.fs.stat(Ct(i,n),(o,a)=>o?o.code==="ENOENT"?t(null,!1):t(o):t(null,!ad(a,n)))})}function xm(){return yn}bm(()=>{for(let e in yn){let n=yn[e].options;try{n.fs.rmdirSync(Ct(e,n))}catch{}}});or.exports.lock=Sm;or.exports.unlock=dd;or.exports.check=vm;or.exports.getLocks=xm});var cd=K((LS,ud)=>{"use strict";var wm=vo();function km(e){let n=["mkdir","realpath","stat","rmdir","utimes"],t={...e};return n.forEach(r=>{t[r]=(...i)=>{let o=i.pop(),a;try{a=e[`${r}Sync`](...i)}catch(s){return o(s)}o(null,a)}}),t}function Tm(e){return(...n)=>new Promise((t,r)=>{n.push((i,o)=>{i?r(i):t(o)}),e(...n)})}function Cm(e){return(...n)=>{let t,r;if(n.push((i,o)=>{t=i,r=o}),e(...n),t)throw t;return r}}function Am(e){if(e={...e},e.fs=km(e.fs||wm),typeof e.retries=="number"&&e.retries>0||e.retries&&typeof e.retries.retries=="number"&&e.retries.retries>0)throw Object.assign(new Error("Cannot use retries with the sync api"),{code:"ESYNC"});return e}ud.exports={toPromise:Tm,toSync:Cm,toSyncOptions:Am}});var pd=K((JS,Fn)=>{"use strict";var At=ld(),{toPromise:ti,toSync:ri,toSyncOptions:Eo}=cd();async function fd(e,n){let t=await ti(At.lock)(e,n);return ti(t)}function Em(e,n){let t=ri(At.lock)(e,Eo(n));return ri(t)}function Pm(e,n){return ti(At.unlock)(e,n)}function Rm(e,n){return ri(At.unlock)(e,Eo(n))}function Im(e,n){return ti(At.check)(e,n)}function Om(e,n){return ri(At.check)(e,Eo(n))}Fn.exports=fd;Fn.exports.lock=fd;Fn.exports.unlock=Pm;Fn.exports.lockSync=Em;Fn.exports.unlockSync=Rm;Fn.exports.check=Im;Fn.exports.checkSync=Om});var md=m(()=>{});var Po=m(()=>{});var ar=m(()=>{});var ge=m(()=>{md();Po();ar()});function Fm(e){return e==null?!1:typeof e.RE_EXN_ID=="string"}function qe(e){return Fm(e)?e:{RE_EXN_ID:"JsExn",_1:e}}function Oo(e){let n=Io[e];if(n!==void 0){let t=n+1|0;return Io[e]=t,e+("/"+t)}return Io[e]=1,e}var Io,Ie=m(()=>{Io={}});var jm,be=m(()=>{Mn();F();Wr();jm=St(pd(),1);ge();B();Ie()});function bd(e,n){return e!==void 0&&n!==void 0?e===n?{TAG:"Match",version:e}:{TAG:"Mismatch",pathVersion:e,pinnedVersion:n}:{TAG:"Unverified",pathVersion:e,pinnedVersion:n}}var gd,Sd=m(()=>{te();be();F();ge();gd=new RegExp("(\\d+\\.\\d+\\.\\d+)")});function vd(e){return e!=="claude_code"}function Nm(e,n){let t=bd(e,n);switch(t.TAG){case"Match":return{TAG:"Ok",_0:t.version};case"Mismatch":return{TAG:"Error",_0:"hosted_codex_runtime_refused reason=mismatch observed="+t.pathVersion+" expected="+t.pinnedVersion};case"Unverified":return{TAG:"Error",_0:"hosted_codex_runtime_refused reason=unverified observed=unverified expected="+n}}}function xd(e,n,t){let r;if(e===0&&n.length<=1048576){let i=gd.exec(n);r=i==null?void 0:Pe(i.slice(1)[0],o=>o)}else r=void 0;return Nm(r,t)}var wd=m(()=>{F();Sd()});var kd,Td,Mo=m(()=>{wd();kd=vd,Td=xd});var Ad,Cd=m(()=>{Ad={name:"@linzumi/cli",version:"1.0.278",description:"Linzumi CLI \u2014 point a Codex agent at the real code on your laptop, with your team watching and steering from shared threads.",type:"module",bin:{linzumi:"bin/linzumi.js"},files:["README.md","bin","dist","scripts","!scripts/build-*-oracle.mjs"],scripts:{build:"rescript build ../linzumi-cli-rescript && node scripts/build.mjs","bump-version":"node scripts/bump-cli-version.mjs",test:"pnpm --dir ../linzumi-cli-rescript test && npm run test:operational",typecheck:"rescript build ../linzumi-cli-rescript && tsgo --noEmit -p tsconfig.source.json",prepack:"rescript build -q ../linzumi-cli-rescript && node scripts/build.mjs","pack:dry-run":"npm pack --dry-run","test:operational":"vitest run --config vitest.config.mjs","vendor:codex-app-server-protocol":"tsx scripts/vendor-codex-app-server-protocol.ts","test:startup":"npm run build && node --test --test-concurrency=1 ../linzumi-cli-rescript/src/parity/CommanderStartupRefusalConformance.res.mjs","typecheck:all":"rescript build ../linzumi-cli-rescript && tsgo --noEmit -p tsconfig.json","typecheck:watch":"rescript build ../linzumi-cli-rescript && tsgo --noEmit -w -p tsconfig.source.json","test:agent-source":"LINZUMI_CI_QUARANTINE=0 pnpm exec vitest run --config vitest.config.mjs test/channelSession.test.ts test/kandanQueue.test.ts -t '(retains three busy accepted source snapshots without fusing or interrupting|keeps different accepted agent sources distinct through interrupt pickup)' && pnpm --dir ../linzumi-cli-rescript build && pnpm --dir ../linzumi-cli-rescript exec node --import tsx src/parity/AgentOpenaiModelProviderConformance.res.mjs && pnpm --dir ../linzumi-cli-rescript exec node --import tsx src/parity/WorkerMintCredentialConformance.res.mjs","codex:history-table":"node scripts/codex_history_table.mjs","vendor:codex-app-server-protocol:check":"tsx scripts/vendor-codex-app-server-protocol.ts --check"},keywords:["linzumi","kandan","codex","local-runner"],license:"MIT",publishConfig:{access:"public"},dependencies:{"@anthropic-ai/claude-agent-sdk":"0.3.283","@inquirer/prompts":"^7.8.6","@modelcontextprotocol/sdk":"^1.29.0","@openai/codex":"0.158.0",blessed:"^0.1.81","proper-lockfile":"3.2.0",undici:"^6.25.0",ws:"^8.18.0",zod:"^3.25.76"},engines:{node:">=20"},readmeFilename:"README.md",devDependencies:{"@types/blessed":"^0.1.27","@types/node":"^22.18.6","@types/proper-lockfile":"4.1.4","@typescript/native-preview":"7.0.0-dev.20260703.1",esbuild:"^0.27.2","fast-check":"^3.23.2",rescript:"12.3.0",tsx:"^4.21.0",typescript:"^5.9.3",vitest:"^1.6.1"}}});var ai,si=m(()=>{"use strict";Cd();ai=Ad.dependencies["@openai/codex"]});import{readFileSync as Lm}from"node:fs";function Km(e=process.env,n=void 0,t=r=>Lm(r,"utf8")){let r=e.SMOLCLOUD_API_KEY?.trim();if(r!==void 0&&r!=="")return r;if(n?.apiKeyFile!==void 0&&n.apiKeyFile!=="")try{let o=t(n.apiKeyFile).trim();if(o!=="")return o}catch{}let i=e.SMOL_CLOUD_TOKEN?.trim();if(i!==void 0&&i!=="")return i}function jo(e){let n=e.env??process.env,t=Km(n,e.config);if(t===void 0)return;let r=(n.SMOLCLOUD_BASE_URL??e.config?.baseUrl??Jm).replace(/\/+$/,"");return e.fetchImpl===void 0?{baseUrl:r,apiKey:t}:{baseUrl:r,apiKey:t,fetchImpl:e.fetchImpl}}function di(e){return e.replace(/\bsmk_[A-Za-z0-9._-]+/g,"smk_[REDACTED]")}function Ed(e){return e.split("/").map(encodeURIComponent).join("/")}async function gn(e,n,t,r={}){let i=e.fetchImpl??fetch,o={authorization:`Bearer ${e.apiKey}`},a;r.json!==void 0?(o["content-type"]="application/json",a=JSON.stringify(r.json)):r.body!==void 0&&(o["content-type"]="application/octet-stream",a=r.body);let s=new AbortController,l=r.timeoutMs??Fo,c=setTimeout(()=>s.abort(),l),d;try{d=await i(`${e.baseUrl}${t}`,{method:n,headers:o,body:a??null,signal:s.signal})}catch(p){throw p instanceof Error&&p.name==="AbortError"?new je("TIMEOUT",`smolcloud ${n} ${t} timed out after ${l}ms`):new je("CONNECTION",`smolcloud request failed: ${p instanceof Error?p.message:String(p)}`)}finally{clearTimeout(c)}if(!d.ok){let p=await d.text().catch(()=>""),u=d.status===404?"NOT_FOUND":d.status===401||d.status===403?"UNAUTHORIZED":"CLOUD_ERROR";throw new je(u,`smolcloud ${n} ${t} \u2192 ${d.status}${p===""?"":`: ${p}`}`)}return r.accept==="bytes"?Buffer.from(await d.arrayBuffer()):d.status===204?void 0:(d.headers.get("content-type")??"").includes("application/json")?await d.json():void 0}async function*Bm(e){let n=e.getReader(),t=new TextDecoder,r="",i="",o=[],a=()=>{let s=i,l=o.join(`
5
5
  `);if(i="",o=[],s==="stdout")return{kind:"stdout",data:l};if(s==="stderr")return{kind:"stderr",data:l};if(s==="error")return{kind:"error",message:di(l)};if(s==="exit"){let c=0;try{c=JSON.parse(l).exitCode??0}catch{}return{kind:"exit",exitCode:c}}};try{for(;;){let{value:l,done:c}=await n.read();if(c)break;r+=t.decode(l,{stream:!0});let d;for(;(d=r.indexOf(`
6
6
  `))>=0;){let f=r.slice(0,d);r=r.slice(d+1);let p=f.endsWith("\r")?f.slice(0,-1):f;if(p===""){let u=a();u!==void 0&&(yield u)}else p.startsWith("event:")?i=p.slice(6).trim():p.startsWith("data:")&&o.push(p.slice(5).replace(/^ /,""))}}let s=a();s!==void 0&&(yield s)}finally{n.releaseLock()}}function zm(e){if(!e.startsWith("smolmachine:"))return{type:"image",reference:e};let n=e.slice(12),t=n.lastIndexOf("@");if(t<0)return{type:"smolmachine",reference:n,arch:"arm64"};let r=n.slice(t+1);if(r!=="arm64"&&r!=="amd64")throw new je("CLOUD_ERROR",`invalid smolmachine image arch suffix ${JSON.stringify(r)} in ${JSON.stringify(e)} (expected @arm64 or @amd64)`);return{type:"smolmachine",reference:n.slice(0,t),arch:r}}async function Pd(e,n){let t={name:n.name??null,source:zm(n.image),resources:{...n.cpus!==void 0?{cpus:n.cpus}:{},...n.memoryMb!==void 0?{memoryMb:n.memoryMb}:{},diskGb:n.diskGb??null},...n.network!==void 0?{network:n.network}:{},...n.env!==void 0?{env:n.env}:{},autoStopSeconds:n.autoStopSeconds??null,ttlSeconds:n.ttlSeconds??null},r=await gn(e,"POST","/v1/machines",{json:t});if(r.id===void 0)throw new je("CLOUD_ERROR","machine create returned no machine id");let i=new dr(e,r.id);try{return await gn(e,"POST",`/v1/machines/${r.id}/start`).catch(()=>{}),await Wm(e,r.id),i}catch(o){throw await i.delete().catch(()=>{}),o}}async function Wm(e,n,t=Um,r=i=>new Promise(o=>setTimeout(o,i))){let i=Date.now()+t;for(;;){let o;try{o=(await gn(e,"GET",`/v1/machines/${n}`))?.state}catch(a){if(a instanceof je&&(a.code==="UNAUTHORIZED"||a.code==="NOT_FOUND"))throw a}if(o==="started"||o==="running")return;if(o==="error")throw new je("CLOUD_ERROR",`machine ${n} entered error state while starting`);if(Date.now()>=i)throw new je("TIMEOUT",`machine ${n} not ready after ${t}ms (state=${o??"unknown"})`);await r(1e3)}}var Jm,Fo,qo,Um,je,dr,$o=m(()=>{"use strict";si();Jm="https://api.smolmachines.com",Fo=3e4,qo=3e4,Um=12e4;je=class extends Error{code;constructor(n,t){super(di(t)),this.code=n,this.name="SmolcloudError"}};dr=class{id;conn;constructor(n,t){this.conn=n,this.id=t}get name(){return this.id}async state(){return(await this.info()).state}async info(){let n=await gn(this.conn,"GET",`/v1/machines/${this.id}`);return{id:n?.id??this.id,name:n?.name??null,state:n?.state??"unknown",env:n?.env??{}}}async exec(n,t){let r={command:[...n],env:t?.env??{},cwd:t?.workdir??null,stdin:t?.stdin??null,timeoutSeconds:t?.timeout??null},i=t?.timeout!==void 0?Math.max(Fo,t.timeout*1e3+qo):Fo,o=await gn(this.conn,"POST",`/v1/machines/${this.id}/exec`,{json:r,timeoutMs:i});return{exitCode:o.exitCode??0,stdout:o.stdout??"",stderr:o.stderr??""}}async*execStream(n,t){let r=this.conn.fetchImpl??fetch,i={command:[...n],env:t?.env??{},cwd:t?.workdir??null,stdin:t?.stdin??null,timeoutSeconds:t?.timeout??null},o=new AbortController,a=t?.timeout!==void 0?setTimeout(()=>o.abort(),t.timeout*1e3+qo):void 0,s;try{s=await r(`${this.conn.baseUrl}/v1/machines/${this.id}/exec/stream`,{method:"POST",headers:{authorization:`Bearer ${this.conn.apiKey}`,"content-type":"application/json",accept:"text/event-stream"},body:JSON.stringify(i),signal:o.signal})}catch(l){throw a!==void 0&&clearTimeout(a),l instanceof Error&&l.name==="AbortError"?new je("TIMEOUT",`smolcloud exec/stream timed out after ${(t?.timeout??0)*1e3+qo}ms`):new je("CONNECTION",`smolcloud exec/stream failed: ${l instanceof Error?l.message:String(l)}`)}try{if(!s.ok){let l=await s.text().catch(()=>"");throw new je(s.status===404?"NOT_FOUND":"CLOUD_ERROR",`smolcloud POST /v1/machines/${this.id}/exec/stream \u2192 ${s.status}${l===""?"":`: ${l}`}`)}if(s.body===null)throw new je("CLOUD_ERROR","exec/stream returned no response body");yield*Bm(s.body)}finally{a!==void 0&&clearTimeout(a)}}async readFile(n){return await gn(this.conn,"GET",`/v1/machines/${this.id}/files/${Ed(n)}`,{accept:"bytes"})}async writeFile(n,t,r){await gn(this.conn,"PUT",`/v1/machines/${this.id}/files/${Ed(n)}`,{body:typeof t=="string"?Buffer.from(t,"utf8"):t}),r!==void 0&&await this.exec(["chmod",r.toString(8),n])}async stop(){await gn(this.conn,"POST",`/v1/machines/${this.id}/stop`)}async delete(){await gn(this.conn,"DELETE",`/v1/machines/${this.id}`)}}});function Rd(e){return`'${e.replaceAll("'",String.raw`'\''`)}'`}var No,iv,ov,av,Id=m(()=>{"use strict";No="/dev/shm/linzumi",iv=`${No}/codex`,ov=`${No}/mcp-auth.json`,av=`${No}/codex.env`});function Do(e){let n=e.replace(/[^A-Za-z0-9._-]/g,"_");return`${an}/.linzumi-provisioned-${Od}-${n}`}function Fd(e){return["/bin/sh","-c",["set -e",`mkdir -p ${an} ${lr} ${li}`,`chmod 700 ${lr} ${li}`,"export DEBIAN_FRONTEND=noninteractive","apt-get update -qq >/dev/null","apt-get install -y --no-install-recommends bubblewrap ca-certificates git ripgrep curl >/dev/null","update-ca-certificates >/dev/null 2>&1 || true",`npm install -g --no-fund --no-audit @openai/codex@${Rd(e)} >/dev/null`,`rm -f ${an}/.linzumi-provisioned-${Od}-* 2>/dev/null || true`,`touch ${Do(e)}`,`touch ${Jd}`].join(" && ")]}function jd(e){return["/bin/sh","-c",`test -f ${Do(e)} && command -v codex >/dev/null && command -v node >/dev/null && command -v bwrap >/dev/null && test -s ${qd}`]}function $d(e){return["/bin/sh","-c",`if test -f ${Do(e)} && command -v codex >/dev/null && command -v node >/dev/null && command -v bwrap >/dev/null && test -s ${qd}; then echo TOOLCHAIN_OK; else echo TOOLCHAIN_MISSING; fi; echo BUNDLE_SUP $(sha256sum ${ui} 2>/dev/null | cut -d' ' -f1); echo BUNDLE_MCP $(sha256sum ${ci} 2>/dev/null | cut -d' ' -f1)`]}function Go(){return["/bin/sh","-c",`rm -rf ${lr} 2>/dev/null; true`]}function Jo(e){if(!Qm.test(e))throw new Error(`invalid cloud turn nonce: ${JSON.stringify(e.slice(0,80))}`)}function Nd(e){return Jo(e),`${Lo}/${e}.beat`}function Dd(e){return Jo(e),`${Lo}/${e}.exit`}function Gd(e){let n=Dd(e),t=Nd(e);return["/bin/sh","-c",`if test -f ${n}; then echo EXIT; cat ${n}; elif test -f ${t}; then now=$(date +%s); hb=$(stat -c %Y ${t} 2>/dev/null || echo 0); echo AGE $((now-hb)); else echo NONE; fi`]}function Ld(e){let n=Dd(e),t=Nd(e);return["/bin/sh","-c",`rm -f ${n} ${t} 2>/dev/null; true`]}var Od,Md,ui,ci,lr,Hm,li,Vm,qd,Lo,Qm,Uo=m(()=>{"use strict";Ko();Id();Od="v1",Md=4500,ui=`${an}/cloud-supervisor.mjs`,ci=`${an}/mcp-server.mjs`,lr=`${an}/.secrets`,Hm=`${lr}/mcp-auth.json`,li=`${an}/.codex`,Vm=`${li}/linzumi-thread-map.json`,qd="/etc/ssl/certs/ca-certificates.crt";Lo=`${an}/.turn-heartbeats`,Qm=/^[A-Za-z0-9-]{8,64}$/});function Ud(e){return Buffer.from(JSON.stringify(e),"utf8").toString("base64")}var fi,Kd,Bo=m(()=>{"use strict";fi={mcpAuthFileContents:"LINZUMI_CLOUD_MCP_AUTH_JSON",llmProxyToken:"LINZUMI_CLOUD_LLM_PROXY_TOKEN"};Kd="exit"});var Bd=m(()=>{});var zd=m(()=>{Bd()});var re=m(()=>{"use strict"});var pi=m(()=>{"use strict";re()});var Wd=m(()=>{"use strict";pi();re()});var bn=K((vv,Qd)=>{"use strict";var Hd=["nodebuffer","arraybuffer","fragments"],Vd=typeof Blob<"u";Vd&&Hd.push("blob");Qd.exports={BINARY_TYPES:Hd,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:Vd,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var ur=K((xv,mi)=>{"use strict";var{EMPTY_BUFFER:eh}=bn(),zo=Buffer[Symbol.species];function nh(e,n){if(e.length===0)return eh;if(e.length===1)return e[0];let t=Buffer.allocUnsafe(n),r=0;for(let i=0;i<e.length;i++){let o=e[i];t.set(o,r),r+=o.length}return r<n?new zo(t.buffer,t.byteOffset,r):t}function Zd(e,n,t,r,i){for(let o=0;o<i;o++)t[r+o]=e[o]^n[o&3]}function Yd(e,n){for(let t=0;t<e.length;t++)e[t]^=n[t&3]}function th(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)}function Wo(e){if(Wo.readOnly=!0,Buffer.isBuffer(e))return e;let n;return e instanceof ArrayBuffer?n=new zo(e):ArrayBuffer.isView(e)?n=new zo(e.buffer,e.byteOffset,e.byteLength):(n=Buffer.from(e),Wo.readOnly=!1),n}mi.exports={concat:nh,mask:Zd,toArrayBuffer:th,toBuffer:Wo,unmask:Yd};if(!process.env.WS_NO_BUFFER_UTIL)try{let e=D("bufferutil");mi.exports.mask=function(n,t,r,i,o){o<48?Zd(n,t,r,i,o):e.mask(n,t,r,i,o)},mi.exports.unmask=function(n,t){n.length<32?Yd(n,t):e.unmask(n,t)}}catch{}});var nl=K((wv,el)=>{"use strict";var Xd=Symbol("kDone"),Ho=Symbol("kRun"),Vo=class{constructor(n){this[Xd]=()=>{this.pending--,this[Ho]()},this.concurrency=n||1/0,this.jobs=[],this.pending=0}add(n){this.jobs.push(n),this[Ho]()}[Ho](){if(this.pending!==this.concurrency&&this.jobs.length){let n=this.jobs.shift();this.pending++,n(this[Xd])}}};el.exports=Vo});var fr=K((kv,ol)=>{"use strict";var cr=D("zlib"),tl=ur(),rh=nl(),{kStatusCode:rl}=bn(),ih=Buffer[Symbol.species],oh=Buffer.from([0,0,255,255]),_i=Symbol("permessage-deflate"),Sn=Symbol("total-length"),Pt=Symbol("callback"),jn=Symbol("buffers"),Rt=Symbol("error"),hi,Qo=class{constructor(n,t,r){if(this._maxPayload=r|0,this._options=n||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!t,this._deflate=null,this._inflate=null,this.params=null,!hi){let i=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;hi=new rh(i)}}static get extensionName(){return"permessage-deflate"}offer(){let n={};return this._options.serverNoContextTakeover&&(n.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(n.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(n.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?n.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(n.client_max_window_bits=!0),n}accept(n){return n=this.normalizeParams(n),this.params=this._isServer?this.acceptAsServer(n):this.acceptAsClient(n),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let n=this._deflate[Pt];this._deflate.close(),this._deflate=null,n&&n(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(n){let t=this._options,r=n.find(i=>!(t.serverNoContextTakeover===!1&&i.server_no_context_takeover||i.server_max_window_bits&&(t.serverMaxWindowBits===!1||typeof t.serverMaxWindowBits=="number"&&t.serverMaxWindowBits>i.server_max_window_bits)||typeof t.clientMaxWindowBits=="number"&&!i.client_max_window_bits));if(!r)throw new Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(r.server_no_context_takeover=!0),t.clientNoContextTakeover&&(r.client_no_context_takeover=!0),typeof t.serverMaxWindowBits=="number"&&(r.server_max_window_bits=t.serverMaxWindowBits),typeof t.clientMaxWindowBits=="number"?r.client_max_window_bits=t.clientMaxWindowBits:(r.client_max_window_bits===!0||t.clientMaxWindowBits===!1)&&delete r.client_max_window_bits,r}acceptAsClient(n){let t=n[0];if(this._options.clientNoContextTakeover===!1&&t.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!t.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(t.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return t}normalizeParams(n){return n.forEach(t=>{Object.keys(t).forEach(r=>{let i=t[r];if(i.length>1)throw new Error(`Parameter "${r}" must have only a single value`);if(i=i[0],r==="client_max_window_bits"){if(i!==!0){let o=+i;if(!Number.isInteger(o)||o<8||o>15)throw new TypeError(`Invalid value for parameter "${r}": ${i}`);i=o}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${r}": ${i}`)}else if(r==="server_max_window_bits"){let o=+i;if(!Number.isInteger(o)||o<8||o>15)throw new TypeError(`Invalid value for parameter "${r}": ${i}`);i=o}else if(r==="client_no_context_takeover"||r==="server_no_context_takeover"){if(i!==!0)throw new TypeError(`Invalid value for parameter "${r}": ${i}`)}else throw new Error(`Unknown parameter "${r}"`);t[r]=i})}),n}decompress(n,t,r){hi.add(i=>{this._decompress(n,t,(o,a)=>{i(),r(o,a)})})}compress(n,t,r){hi.add(i=>{this._compress(n,t,(o,a)=>{i(),r(o,a)})})}_decompress(n,t,r){let i=this._isServer?"client":"server";if(!this._inflate){let o=`${i}_max_window_bits`,a=typeof this.params[o]!="number"?cr.Z_DEFAULT_WINDOWBITS:this.params[o];this._inflate=cr.createInflateRaw({...this._options.zlibInflateOptions,windowBits:a}),this._inflate[_i]=this,this._inflate[Sn]=0,this._inflate[jn]=[],this._inflate.on("error",sh),this._inflate.on("data",il)}this._inflate[Pt]=r,this._inflate.write(n),t&&this._inflate.write(oh),this._inflate.flush(()=>{let o=this._inflate[Rt];if(o){this._inflate.close(),this._inflate=null,r(o);return}let a=tl.concat(this._inflate[jn],this._inflate[Sn]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Sn]=0,this._inflate[jn]=[],t&&this.params[`${i}_no_context_takeover`]&&this._inflate.reset()),r(null,a)})}_compress(n,t,r){let i=this._isServer?"server":"client";if(!this._deflate){let o=`${i}_max_window_bits`,a=typeof this.params[o]!="number"?cr.Z_DEFAULT_WINDOWBITS:this.params[o];this._deflate=cr.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:a}),this._deflate[Sn]=0,this._deflate[jn]=[],this._deflate.on("data",ah)}this._deflate[Pt]=r,this._deflate.write(n),this._deflate.flush(cr.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let o=tl.concat(this._deflate[jn],this._deflate[Sn]);t&&(o=new ih(o.buffer,o.byteOffset,o.length-4)),this._deflate[Pt]=null,this._deflate[Sn]=0,this._deflate[jn]=[],t&&this.params[`${i}_no_context_takeover`]&&this._deflate.reset(),r(null,o)})}};ol.exports=Qo;function ah(e){this[jn].push(e),this[Sn]+=e.length}function il(e){if(this[Sn]+=e.length,this[_i]._maxPayload<1||this[Sn]<=this[_i]._maxPayload){this[jn].push(e);return}this[Rt]=new RangeError("Max payload size exceeded"),this[Rt].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Rt][rl]=1009,this.removeListener("data",il),this.reset()}function sh(e){if(this[_i]._inflate=null,this[Rt]){this[Pt](this[Rt]);return}e[rl]=1007,this[Pt](e)}});var It=K((Tv,yi)=>{"use strict";var{isUtf8:al}=D("buffer"),{hasBlob:dh}=bn(),lh=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function uh(e){return e>=1e3&&e<=1014&&e!==1004&&e!==1005&&e!==1006||e>=3e3&&e<=4999}function Zo(e){let n=e.length,t=0;for(;t<n;)if((e[t]&128)===0)t++;else if((e[t]&224)===192){if(t+1===n||(e[t+1]&192)!==128||(e[t]&254)===192)return!1;t+=2}else if((e[t]&240)===224){if(t+2>=n||(e[t+1]&192)!==128||(e[t+2]&192)!==128||e[t]===224&&(e[t+1]&224)===128||e[t]===237&&(e[t+1]&224)===160)return!1;t+=3}else if((e[t]&248)===240){if(t+3>=n||(e[t+1]&192)!==128||(e[t+2]&192)!==128||(e[t+3]&192)!==128||e[t]===240&&(e[t+1]&240)===128||e[t]===244&&e[t+1]>143||e[t]>244)return!1;t+=4}else return!1;return!0}function ch(e){return dh&&typeof e=="object"&&typeof e.arrayBuffer=="function"&&typeof e.type=="string"&&typeof e.stream=="function"&&(e[Symbol.toStringTag]==="Blob"||e[Symbol.toStringTag]==="File")}yi.exports={isBlob:ch,isValidStatusCode:uh,isValidUTF8:Zo,tokenChars:lh};if(al)yi.exports.isValidUTF8=function(e){return e.length<24?Zo(e):al(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let e=D("utf-8-validate");yi.exports.isValidUTF8=function(n){return n.length<32?Zo(n):e(n)}}catch{}});var ta=K((Cv,pl)=>{"use strict";var{Writable:fh}=D("stream"),sl=fr(),{BINARY_TYPES:ph,EMPTY_BUFFER:dl,kStatusCode:mh,kWebSocket:hh}=bn(),{concat:Yo,toArrayBuffer:_h,unmask:yh}=ur(),{isValidStatusCode:gh,isValidUTF8:ll}=It(),gi=Buffer[Symbol.species],He=0,ul=1,cl=2,fl=3,Xo=4,ea=5,bi=6,na=class extends fh{constructor(n={}){super(),this._allowSynchronousEvents=n.allowSynchronousEvents!==void 0?n.allowSynchronousEvents:!0,this._binaryType=n.binaryType||ph[0],this._extensions=n.extensions||{},this._isServer=!!n.isServer,this._maxPayload=n.maxPayload|0,this._skipUTF8Validation=!!n.skipUTF8Validation,this[hh]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=He}_write(n,t,r){if(this._opcode===8&&this._state==He)return r();this._bufferedBytes+=n.length,this._buffers.push(n),this.startLoop(r)}consume(n){if(this._bufferedBytes-=n,n===this._buffers[0].length)return this._buffers.shift();if(n<this._buffers[0].length){let r=this._buffers[0];return this._buffers[0]=new gi(r.buffer,r.byteOffset+n,r.length-n),new gi(r.buffer,r.byteOffset,n)}let t=Buffer.allocUnsafe(n);do{let r=this._buffers[0],i=t.length-n;n>=r.length?t.set(this._buffers.shift(),i):(t.set(new Uint8Array(r.buffer,r.byteOffset,n),i),this._buffers[0]=new gi(r.buffer,r.byteOffset+n,r.length-n)),n-=r.length}while(n>0);return t}startLoop(n){this._loop=!0;do switch(this._state){case He:this.getInfo(n);break;case ul:this.getPayloadLength16(n);break;case cl:this.getPayloadLength64(n);break;case fl:this.getMask();break;case Xo:this.getData(n);break;case ea:case bi:this._loop=!1;return}while(this._loop);this._errored||n()}getInfo(n){if(this._bufferedBytes<2){this._loop=!1;return}let t=this.consume(2);if((t[0]&48)!==0){let i=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");n(i);return}let r=(t[0]&64)===64;if(r&&!this._extensions[sl.extensionName]){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");n(i);return}if(this._fin=(t[0]&128)===128,this._opcode=t[0]&15,this._payloadLength=t[1]&127,this._opcode===0){if(r){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");n(i);return}if(!this._fragmented){let i=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");n(i);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let i=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");n(i);return}this._compressed=r}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let i=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");n(i);return}if(r){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");n(i);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let i=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");n(i);return}}else{let i=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");n(i);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(t[1]&128)===128,this._isServer){if(!this._masked){let i=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");n(i);return}}else if(this._masked){let i=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");n(i);return}this._payloadLength===126?this._state=ul:this._payloadLength===127?this._state=cl:this.haveLength(n)}getPayloadLength16(n){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(n)}getPayloadLength64(n){if(this._bufferedBytes<8){this._loop=!1;return}let t=this.consume(8),r=t.readUInt32BE(0);if(r>Math.pow(2,21)-1){let i=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");n(i);return}this._payloadLength=r*Math.pow(2,32)+t.readUInt32BE(4),this.haveLength(n)}haveLength(n){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let t=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");n(t);return}this._masked?this._state=fl:this._state=Xo}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Xo}getData(n){let t=dl;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}t=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&yh(t,this._mask)}if(this._opcode>7){this.controlMessage(t,n);return}if(this._compressed){this._state=ea,this.decompress(t,n);return}t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage(n)}decompress(n,t){this._extensions[sl.extensionName].decompress(n,this._fin,(i,o)=>{if(i)return t(i);if(o.length){if(this._messageLength+=o.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let a=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");t(a);return}this._fragments.push(o)}this.dataMessage(t),this._state===He&&this.startLoop(t)})}dataMessage(n){if(!this._fin){this._state=He;return}let t=this._messageLength,r=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let i;this._binaryType==="nodebuffer"?i=Yo(r,t):this._binaryType==="arraybuffer"?i=_h(Yo(r,t)):this._binaryType==="blob"?i=new Blob(r):i=r,this._allowSynchronousEvents?(this.emit("message",i,!0),this._state=He):(this._state=bi,setImmediate(()=>{this.emit("message",i,!0),this._state=He,this.startLoop(n)}))}else{let i=Yo(r,t);if(!this._skipUTF8Validation&&!ll(i)){let o=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");n(o);return}this._state===ea||this._allowSynchronousEvents?(this.emit("message",i,!1),this._state=He):(this._state=bi,setImmediate(()=>{this.emit("message",i,!1),this._state=He,this.startLoop(n)}))}}controlMessage(n,t){if(this._opcode===8){if(n.length===0)this._loop=!1,this.emit("conclude",1005,dl),this.end();else{let r=n.readUInt16BE(0);if(!gh(r)){let o=this.createError(RangeError,`invalid status code ${r}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");t(o);return}let i=new gi(n.buffer,n.byteOffset+2,n.length-2);if(!this._skipUTF8Validation&&!ll(i)){let o=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");t(o);return}this._loop=!1,this.emit("conclude",r,i),this.end()}this._state=He;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",n),this._state=He):(this._state=bi,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",n),this._state=He,this.startLoop(t)}))}createError(n,t,r,i,o){this._loop=!1,this._errored=!0;let a=new n(r?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(a,this.createError),a.code=o,a[mh]=i,a}};pl.exports=na});var oa=K((Ev,_l)=>{"use strict";var{Duplex:Av}=D("stream"),{randomFillSync:bh}=D("crypto"),ml=fr(),{EMPTY_BUFFER:Sh,kWebSocket:vh,NOOP:xh}=bn(),{isBlob:Ot,isValidStatusCode:wh}=It(),{mask:hl,toBuffer:Yn}=ur(),Ve=Symbol("kByteLength"),kh=Buffer.alloc(4),Si=8*1024,Xn,Mt=Si,Xe=0,Th=1,Ch=2,ra=class e{constructor(n,t,r){this._extensions=t||{},r&&(this._generateMask=r,this._maskBuffer=Buffer.alloc(4)),this._socket=n,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=Xe,this.onerror=xh,this[vh]=void 0}static frame(n,t){let r,i=!1,o=2,a=!1;t.mask&&(r=t.maskBuffer||kh,t.generateMask?t.generateMask(r):(Mt===Si&&(Xn===void 0&&(Xn=Buffer.alloc(Si)),bh(Xn,0,Si),Mt=0),r[0]=Xn[Mt++],r[1]=Xn[Mt++],r[2]=Xn[Mt++],r[3]=Xn[Mt++]),a=(r[0]|r[1]|r[2]|r[3])===0,o=6);let s;typeof n=="string"?(!t.mask||a)&&t[Ve]!==void 0?s=t[Ve]:(n=Buffer.from(n),s=n.length):(s=n.length,i=t.mask&&t.readOnly&&!a);let l=s;s>=65536?(o+=8,l=127):s>125&&(o+=2,l=126);let c=Buffer.allocUnsafe(i?s+o:o);return c[0]=t.fin?t.opcode|128:t.opcode,t.rsv1&&(c[0]|=64),c[1]=l,l===126?c.writeUInt16BE(s,2):l===127&&(c[2]=c[3]=0,c.writeUIntBE(s,4,6)),t.mask?(c[1]|=128,c[o-4]=r[0],c[o-3]=r[1],c[o-2]=r[2],c[o-1]=r[3],a?[c,n]:i?(hl(n,r,c,o,s),[c]):(hl(n,r,n,0,s),[c,n])):[c,n]}close(n,t,r,i){let o;if(n===void 0)o=Sh;else{if(typeof n!="number"||!wh(n))throw new TypeError("First argument must be a valid error code number");if(t===void 0||!t.length)o=Buffer.allocUnsafe(2),o.writeUInt16BE(n,0);else{let s=Buffer.byteLength(t);if(s>123)throw new RangeError("The message must not be greater than 123 bytes");o=Buffer.allocUnsafe(2+s),o.writeUInt16BE(n,0),typeof t=="string"?o.write(t,2):o.set(t,2)}}let a={[Ve]:o.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==Xe?this.enqueue([this.dispatch,o,!1,a,i]):this.sendFrame(e.frame(o,a),i)}ping(n,t,r){let i,o;if(typeof n=="string"?(i=Buffer.byteLength(n),o=!1):Ot(n)?(i=n.size,o=!1):(n=Yn(n),i=n.length,o=Yn.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let a={[Ve]:i,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:o,rsv1:!1};Ot(n)?this._state!==Xe?this.enqueue([this.getBlobData,n,!1,a,r]):this.getBlobData(n,!1,a,r):this._state!==Xe?this.enqueue([this.dispatch,n,!1,a,r]):this.sendFrame(e.frame(n,a),r)}pong(n,t,r){let i,o;if(typeof n=="string"?(i=Buffer.byteLength(n),o=!1):Ot(n)?(i=n.size,o=!1):(n=Yn(n),i=n.length,o=Yn.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let a={[Ve]:i,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:o,rsv1:!1};Ot(n)?this._state!==Xe?this.enqueue([this.getBlobData,n,!1,a,r]):this.getBlobData(n,!1,a,r):this._state!==Xe?this.enqueue([this.dispatch,n,!1,a,r]):this.sendFrame(e.frame(n,a),r)}send(n,t,r){let i=this._extensions[ml.extensionName],o=t.binary?2:1,a=t.compress,s,l;typeof n=="string"?(s=Buffer.byteLength(n),l=!1):Ot(n)?(s=n.size,l=!1):(n=Yn(n),s=n.length,l=Yn.readOnly),this._firstFragment?(this._firstFragment=!1,a&&i&&i.params[i._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(a=s>=i._threshold),this._compress=a):(a=!1,o=0),t.fin&&(this._firstFragment=!0);let c={[Ve]:s,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:o,readOnly:l,rsv1:a};Ot(n)?this._state!==Xe?this.enqueue([this.getBlobData,n,this._compress,c,r]):this.getBlobData(n,this._compress,c,r):this._state!==Xe?this.enqueue([this.dispatch,n,this._compress,c,r]):this.dispatch(n,this._compress,c,r)}getBlobData(n,t,r,i){this._bufferedBytes+=r[Ve],this._state=Ch,n.arrayBuffer().then(o=>{if(this._socket.destroyed){let s=new Error("The socket was closed while the blob was being read");process.nextTick(ia,this,s,i);return}this._bufferedBytes-=r[Ve];let a=Yn(o);t?this.dispatch(a,t,r,i):(this._state=Xe,this.sendFrame(e.frame(a,r),i),this.dequeue())}).catch(o=>{process.nextTick(Ah,this,o,i)})}dispatch(n,t,r,i){if(!t){this.sendFrame(e.frame(n,r),i);return}let o=this._extensions[ml.extensionName];this._bufferedBytes+=r[Ve],this._state=Th,o.compress(n,r.fin,(a,s)=>{if(this._socket.destroyed){let l=new Error("The socket was closed while data was being compressed");ia(this,l,i);return}this._bufferedBytes-=r[Ve],this._state=Xe,r.readOnly=!1,this.sendFrame(e.frame(s,r),i),this.dequeue()})}dequeue(){for(;this._state===Xe&&this._queue.length;){let n=this._queue.shift();this._bufferedBytes-=n[3][Ve],Reflect.apply(n[0],this,n.slice(1))}}enqueue(n){this._bufferedBytes+=n[3][Ve],this._queue.push(n)}sendFrame(n,t){n.length===2?(this._socket.cork(),this._socket.write(n[0]),this._socket.write(n[1],t),this._socket.uncork()):this._socket.write(n[0],t)}};_l.exports=ra;function ia(e,n,t){typeof t=="function"&&t(n);for(let r=0;r<e._queue.length;r++){let i=e._queue[r],o=i[i.length-1];typeof o=="function"&&o(n)}}function Ah(e,n,t){ia(e,n,t),e.onerror(n)}});var Tl=K((Pv,kl)=>{"use strict";var{kForOnEventAttribute:pr,kListener:aa}=bn(),yl=Symbol("kCode"),gl=Symbol("kData"),bl=Symbol("kError"),Sl=Symbol("kMessage"),vl=Symbol("kReason"),qt=Symbol("kTarget"),xl=Symbol("kType"),wl=Symbol("kWasClean"),vn=class{constructor(n){this[qt]=null,this[xl]=n}get target(){return this[qt]}get type(){return this[xl]}};Object.defineProperty(vn.prototype,"target",{enumerable:!0});Object.defineProperty(vn.prototype,"type",{enumerable:!0});var et=class extends vn{constructor(n,t={}){super(n),this[yl]=t.code===void 0?0:t.code,this[vl]=t.reason===void 0?"":t.reason,this[wl]=t.wasClean===void 0?!1:t.wasClean}get code(){return this[yl]}get reason(){return this[vl]}get wasClean(){return this[wl]}};Object.defineProperty(et.prototype,"code",{enumerable:!0});Object.defineProperty(et.prototype,"reason",{enumerable:!0});Object.defineProperty(et.prototype,"wasClean",{enumerable:!0});var Ft=class extends vn{constructor(n,t={}){super(n),this[bl]=t.error===void 0?null:t.error,this[Sl]=t.message===void 0?"":t.message}get error(){return this[bl]}get message(){return this[Sl]}};Object.defineProperty(Ft.prototype,"error",{enumerable:!0});Object.defineProperty(Ft.prototype,"message",{enumerable:!0});var mr=class extends vn{constructor(n,t={}){super(n),this[gl]=t.data===void 0?null:t.data}get data(){return this[gl]}};Object.defineProperty(mr.prototype,"data",{enumerable:!0});var Eh={addEventListener(e,n,t={}){for(let i of this.listeners(e))if(!t[pr]&&i[aa]===n&&!i[pr])return;let r;if(e==="message")r=function(o,a){let s=new mr("message",{data:a?o:o.toString()});s[qt]=this,vi(n,this,s)};else if(e==="close")r=function(o,a){let s=new et("close",{code:o,reason:a.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});s[qt]=this,vi(n,this,s)};else if(e==="error")r=function(o){let a=new Ft("error",{error:o,message:o.message});a[qt]=this,vi(n,this,a)};else if(e==="open")r=function(){let o=new vn("open");o[qt]=this,vi(n,this,o)};else return;r[pr]=!!t[pr],r[aa]=n,t.once?this.once(e,r):this.on(e,r)},removeEventListener(e,n){for(let t of this.listeners(e))if(t[aa]===n&&!t[pr]){this.removeListener(e,t);break}}};kl.exports={CloseEvent:et,ErrorEvent:Ft,Event:vn,EventTarget:Eh,MessageEvent:mr};function vi(e,n,t){typeof e=="object"&&e.handleEvent?e.handleEvent.call(e,t):e.call(n,t)}});var sa=K((Rv,Cl)=>{"use strict";var{tokenChars:hr}=It();function sn(e,n,t){e[n]===void 0?e[n]=[t]:e[n].push(t)}function Ph(e){let n=Object.create(null),t=Object.create(null),r=!1,i=!1,o=!1,a,s,l=-1,c=-1,d=-1,f=0;for(;f<e.length;f++)if(c=e.charCodeAt(f),a===void 0)if(d===-1&&hr[c]===1)l===-1&&(l=f);else if(f!==0&&(c===32||c===9))d===-1&&l!==-1&&(d=f);else if(c===59||c===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${f}`);d===-1&&(d=f);let u=e.slice(l,d);c===44?(sn(n,u,t),t=Object.create(null)):a=u,l=d=-1}else throw new SyntaxError(`Unexpected character at index ${f}`);else if(s===void 0)if(d===-1&&hr[c]===1)l===-1&&(l=f);else if(c===32||c===9)d===-1&&l!==-1&&(d=f);else if(c===59||c===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${f}`);d===-1&&(d=f),sn(t,e.slice(l,d),!0),c===44&&(sn(n,a,t),t=Object.create(null),a=void 0),l=d=-1}else if(c===61&&l!==-1&&d===-1)s=e.slice(l,f),l=d=-1;else throw new SyntaxError(`Unexpected character at index ${f}`);else if(i){if(hr[c]!==1)throw new SyntaxError(`Unexpected character at index ${f}`);l===-1?l=f:r||(r=!0),i=!1}else if(o)if(hr[c]===1)l===-1&&(l=f);else if(c===34&&l!==-1)o=!1,d=f;else if(c===92)i=!0;else throw new SyntaxError(`Unexpected character at index ${f}`);else if(c===34&&e.charCodeAt(f-1)===61)o=!0;else if(d===-1&&hr[c]===1)l===-1&&(l=f);else if(l!==-1&&(c===32||c===9))d===-1&&(d=f);else if(c===59||c===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${f}`);d===-1&&(d=f);let u=e.slice(l,d);r&&(u=u.replace(/\\/g,""),r=!1),sn(t,s,u),c===44&&(sn(n,a,t),t=Object.create(null),a=void 0),s=void 0,l=d=-1}else throw new SyntaxError(`Unexpected character at index ${f}`);if(l===-1||o||c===32||c===9)throw new SyntaxError("Unexpected end of input");d===-1&&(d=f);let p=e.slice(l,d);return a===void 0?sn(n,p,t):(s===void 0?sn(t,p,!0):r?sn(t,s,p.replace(/\\/g,"")):sn(t,s,p),sn(n,a,t)),n}function Rh(e){return Object.keys(e).map(n=>{let t=e[n];return Array.isArray(t)||(t=[t]),t.map(r=>[n].concat(Object.keys(r).map(i=>{let o=r[i];return Array.isArray(o)||(o=[o]),o.map(a=>a===!0?i:`${i}=${a}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Cl.exports={format:Rh,parse:Ph}});var Ti=K((Mv,Nl)=>{"use strict";var Ih=D("events"),Oh=D("https"),Mh=D("http"),Pl=D("net"),qh=D("tls"),{randomBytes:Fh,createHash:jh}=D("crypto"),{Duplex:Iv,Readable:Ov}=D("stream"),{URL:da}=D("url"),$n=fr(),$h=ta(),Nh=oa(),{isBlob:Dh}=It(),{BINARY_TYPES:Al,EMPTY_BUFFER:xi,GUID:Gh,kForOnEventAttribute:la,kListener:Lh,kStatusCode:Jh,kWebSocket:ve,NOOP:Rl}=bn(),{EventTarget:{addEventListener:Uh,removeEventListener:Kh}}=Tl(),{format:Bh,parse:zh}=sa(),{toBuffer:Wh}=ur(),Hh=30*1e3,Il=Symbol("kAborted"),ua=[8,13],xn=["CONNECTING","OPEN","CLOSING","CLOSED"],Vh=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,Q=class e extends Ih{constructor(n,t,r){super(),this._binaryType=Al[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=xi,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=e.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,n!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,t===void 0?t=[]:Array.isArray(t)||(typeof t=="object"&&t!==null?(r=t,t=[]):t=[t]),Ol(this,n,t,r)):(this._autoPong=r.autoPong,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(n){Al.includes(n)&&(this._binaryType=n,this._receiver&&(this._receiver._binaryType=n))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(n,t,r){let i=new $h({allowSynchronousEvents:r.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation}),o=new Nh(n,this._extensions,r.generateMask);this._receiver=i,this._sender=o,this._socket=n,i[ve]=this,o[ve]=this,n[ve]=this,i.on("conclude",Yh),i.on("drain",Xh),i.on("error",e_),i.on("message",n_),i.on("ping",t_),i.on("pong",r_),o.onerror=i_,n.setTimeout&&n.setTimeout(0),n.setNoDelay&&n.setNoDelay(),t.length>0&&n.unshift(t),n.on("close",Fl),n.on("data",ki),n.on("end",jl),n.on("error",$l),this._readyState=e.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=e.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[$n.extensionName]&&this._extensions[$n.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=e.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(n,t){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){Ke(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===e.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=e.CLOSING,this._sender.close(n,t,!this._isServer,r=>{r||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),ql(this)}}pause(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!0,this._socket.pause())}ping(n,t,r){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof n=="function"?(r=n,n=t=void 0):typeof t=="function"&&(r=t,t=void 0),typeof n=="number"&&(n=n.toString()),this.readyState!==e.OPEN){ca(this,n,r);return}t===void 0&&(t=!this._isServer),this._sender.ping(n||xi,t,r)}pong(n,t,r){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof n=="function"?(r=n,n=t=void 0):typeof t=="function"&&(r=t,t=void 0),typeof n=="number"&&(n=n.toString()),this.readyState!==e.OPEN){ca(this,n,r);return}t===void 0&&(t=!this._isServer),this._sender.pong(n||xi,t,r)}resume(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(n,t,r){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"&&(r=t,t={}),typeof n=="number"&&(n=n.toString()),this.readyState!==e.OPEN){ca(this,n,r);return}let i={binary:typeof n!="string",mask:!this._isServer,compress:!0,fin:!0,...t};this._extensions[$n.extensionName]||(i.compress=!1),this._sender.send(n||xi,i,r)}terminate(){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){Ke(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=e.CLOSING,this._socket.destroy())}}};Object.defineProperty(Q,"CONNECTING",{enumerable:!0,value:xn.indexOf("CONNECTING")});Object.defineProperty(Q.prototype,"CONNECTING",{enumerable:!0,value:xn.indexOf("CONNECTING")});Object.defineProperty(Q,"OPEN",{enumerable:!0,value:xn.indexOf("OPEN")});Object.defineProperty(Q.prototype,"OPEN",{enumerable:!0,value:xn.indexOf("OPEN")});Object.defineProperty(Q,"CLOSING",{enumerable:!0,value:xn.indexOf("CLOSING")});Object.defineProperty(Q.prototype,"CLOSING",{enumerable:!0,value:xn.indexOf("CLOSING")});Object.defineProperty(Q,"CLOSED",{enumerable:!0,value:xn.indexOf("CLOSED")});Object.defineProperty(Q.prototype,"CLOSED",{enumerable:!0,value:xn.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(e=>{Object.defineProperty(Q.prototype,e,{enumerable:!0})});["open","error","close","message"].forEach(e=>{Object.defineProperty(Q.prototype,`on${e}`,{enumerable:!0,get(){for(let n of this.listeners(e))if(n[la])return n[Lh];return null},set(n){for(let t of this.listeners(e))if(t[la]){this.removeListener(e,t);break}typeof n=="function"&&this.addEventListener(e,n,{[la]:!0})}})});Q.prototype.addEventListener=Uh;Q.prototype.removeEventListener=Kh;Nl.exports=Q;function Ol(e,n,t,r){let i={allowSynchronousEvents:!0,autoPong:!0,protocolVersion:ua[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...r,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(e._autoPong=i.autoPong,!ua.includes(i.protocolVersion))throw new RangeError(`Unsupported protocol version: ${i.protocolVersion} (supported versions: ${ua.join(", ")})`);let o;if(n instanceof da)o=n;else try{o=new da(n)}catch{throw new SyntaxError(`Invalid URL: ${n}`)}o.protocol==="http:"?o.protocol="ws:":o.protocol==="https:"&&(o.protocol="wss:"),e._url=o.href;let a=o.protocol==="wss:",s=o.protocol==="ws+unix:",l;if(o.protocol!=="ws:"&&!a&&!s?l=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:s&&!o.pathname?l="The URL's pathname is empty":o.hash&&(l="The URL contains a fragment identifier"),l){let h=new SyntaxError(l);if(e._redirects===0)throw h;wi(e,h);return}let c=a?443:80,d=Fh(16).toString("base64"),f=a?Oh.request:Mh.request,p=new Set,u;if(i.createConnection=i.createConnection||(a?Zh:Qh),i.defaultPort=i.defaultPort||c,i.port=o.port||c,i.host=o.hostname.startsWith("[")?o.hostname.slice(1,-1):o.hostname,i.headers={...i.headers,"Sec-WebSocket-Version":i.protocolVersion,"Sec-WebSocket-Key":d,Connection:"Upgrade",Upgrade:"websocket"},i.path=o.pathname+o.search,i.timeout=i.handshakeTimeout,i.perMessageDeflate&&(u=new $n(i.perMessageDeflate!==!0?i.perMessageDeflate:{},!1,i.maxPayload),i.headers["Sec-WebSocket-Extensions"]=Bh({[$n.extensionName]:u.offer()})),t.length){for(let h of t){if(typeof h!="string"||!Vh.test(h)||p.has(h))throw new SyntaxError("An invalid or duplicated subprotocol was specified");p.add(h)}i.headers["Sec-WebSocket-Protocol"]=t.join(",")}if(i.origin&&(i.protocolVersion<13?i.headers["Sec-WebSocket-Origin"]=i.origin:i.headers.Origin=i.origin),(o.username||o.password)&&(i.auth=`${o.username}:${o.password}`),s){let h=i.path.split(":");i.socketPath=h[0],i.path=h[1]}let _;if(i.followRedirects){if(e._redirects===0){e._originalIpc=s,e._originalSecure=a,e._originalHostOrSocketPath=s?i.socketPath:o.host;let h=r&&r.headers;if(r={...r,headers:{}},h)for(let[y,b]of Object.entries(h))r.headers[y.toLowerCase()]=b}else if(e.listenerCount("redirect")===0){let h=s?e._originalIpc?i.socketPath===e._originalHostOrSocketPath:!1:e._originalIpc?!1:o.host===e._originalHostOrSocketPath;(!h||e._originalSecure&&!a)&&(delete i.headers.authorization,delete i.headers.cookie,h||delete i.headers.host,i.auth=void 0)}i.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(i.auth).toString("base64")),_=e._req=f(i),e._redirects&&e.emit("redirect",e.url,_)}else _=e._req=f(i);i.timeout&&_.on("timeout",()=>{Ke(e,_,"Opening handshake has timed out")}),_.on("error",h=>{_===null||_[Il]||(_=e._req=null,wi(e,h))}),_.on("response",h=>{let y=h.headers.location,b=h.statusCode;if(y&&i.followRedirects&&b>=300&&b<400){if(++e._redirects>i.maxRedirects){Ke(e,_,"Maximum redirects exceeded");return}_.abort();let g;try{g=new da(y,n)}catch{let v=new SyntaxError(`Invalid URL: ${y}`);wi(e,v);return}Ol(e,g,t,r)}else e.emit("unexpected-response",_,h)||Ke(e,_,`Unexpected server response: ${h.statusCode}`)}),_.on("upgrade",(h,y,b)=>{if(e.emit("upgrade",h),e.readyState!==Q.CONNECTING)return;_=e._req=null;let g=h.headers.upgrade;if(g===void 0||g.toLowerCase()!=="websocket"){Ke(e,y,"Invalid Upgrade header");return}let S=jh("sha1").update(d+Gh).digest("base64");if(h.headers["sec-websocket-accept"]!==S){Ke(e,y,"Invalid Sec-WebSocket-Accept header");return}let v=h.headers["sec-websocket-protocol"],T;if(v!==void 0?p.size?p.has(v)||(T="Server sent an invalid subprotocol"):T="Server sent a subprotocol but none was requested":p.size&&(T="Server sent no subprotocol"),T){Ke(e,y,T);return}v&&(e._protocol=v);let O=h.headers["sec-websocket-extensions"];if(O!==void 0){if(!u){Ke(e,y,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let se;try{se=zh(O)}catch{Ke(e,y,"Invalid Sec-WebSocket-Extensions header");return}let Ee=Object.keys(se);if(Ee.length!==1||Ee[0]!==$n.extensionName){Ke(e,y,"Server indicated an extension that was not requested");return}try{u.accept(se[$n.extensionName])}catch{Ke(e,y,"Invalid Sec-WebSocket-Extensions header");return}e._extensions[$n.extensionName]=u}e.setSocket(y,b,{allowSynchronousEvents:i.allowSynchronousEvents,generateMask:i.generateMask,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation})}),i.finishRequest?i.finishRequest(_,e):_.end()}function wi(e,n){e._readyState=Q.CLOSING,e._errorEmitted=!0,e.emit("error",n),e.emitClose()}function Qh(e){return e.path=e.socketPath,Pl.connect(e)}function Zh(e){return e.path=void 0,!e.servername&&e.servername!==""&&(e.servername=Pl.isIP(e.host)?"":e.host),qh.connect(e)}function Ke(e,n,t){e._readyState=Q.CLOSING;let r=new Error(t);Error.captureStackTrace(r,Ke),n.setHeader?(n[Il]=!0,n.abort(),n.socket&&!n.socket.destroyed&&n.socket.destroy(),process.nextTick(wi,e,r)):(n.destroy(r),n.once("error",e.emit.bind(e,"error")),n.once("close",e.emitClose.bind(e)))}function ca(e,n,t){if(n){let r=Dh(n)?n.size:Wh(n).length;e._socket?e._sender._bufferedBytes+=r:e._bufferedAmount+=r}if(t){let r=new Error(`WebSocket is not open: readyState ${e.readyState} (${xn[e.readyState]})`);process.nextTick(t,r)}}function Yh(e,n){let t=this[ve];t._closeFrameReceived=!0,t._closeMessage=n,t._closeCode=e,t._socket[ve]!==void 0&&(t._socket.removeListener("data",ki),process.nextTick(Ml,t._socket),e===1005?t.close():t.close(e,n))}function Xh(){let e=this[ve];e.isPaused||e._socket.resume()}function e_(e){let n=this[ve];n._socket[ve]!==void 0&&(n._socket.removeListener("data",ki),process.nextTick(Ml,n._socket),n.close(e[Jh])),n._errorEmitted||(n._errorEmitted=!0,n.emit("error",e))}function El(){this[ve].emitClose()}function n_(e,n){this[ve].emit("message",e,n)}function t_(e){let n=this[ve];n._autoPong&&n.pong(e,!this._isServer,Rl),n.emit("ping",e)}function r_(e){this[ve].emit("pong",e)}function Ml(e){e.resume()}function i_(e){let n=this[ve];n.readyState!==Q.CLOSED&&(n.readyState===Q.OPEN&&(n._readyState=Q.CLOSING,ql(n)),this._socket.end(),n._errorEmitted||(n._errorEmitted=!0,n.emit("error",e)))}function ql(e){e._closeTimer=setTimeout(e._socket.destroy.bind(e._socket),Hh)}function Fl(){let e=this[ve];this.removeListener("close",Fl),this.removeListener("data",ki),this.removeListener("end",jl),e._readyState=Q.CLOSING;let n;!this._readableState.endEmitted&&!e._closeFrameReceived&&!e._receiver._writableState.errorEmitted&&(n=e._socket.read())!==null&&e._receiver.write(n),e._receiver.end(),this[ve]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",El),e._receiver.on("finish",El))}function ki(e){this[ve]._receiver.write(e)||this.pause()}function jl(){let e=this[ve];e._readyState=Q.CLOSING,e._receiver.end(),this.end()}function $l(){let e=this[ve];this.removeListener("error",$l),this.on("error",Rl),e&&(e._readyState=Q.CLOSING,this.destroy())}});var Jl=K((Fv,Ll)=>{"use strict";var qv=Ti(),{Duplex:o_}=D("stream");function Dl(e){e.emit("close")}function a_(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Gl(e){this.removeListener("error",Gl),this.destroy(),this.listenerCount("error")===0&&this.emit("error",e)}function s_(e,n){let t=!0,r=new o_({...n,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on("message",function(o,a){let s=!a&&r._readableState.objectMode?o.toString():o;r.push(s)||e.pause()}),e.once("error",function(o){r.destroyed||(t=!1,r.destroy(o))}),e.once("close",function(){r.destroyed||r.push(null)}),r._destroy=function(i,o){if(e.readyState===e.CLOSED){o(i),process.nextTick(Dl,r);return}let a=!1;e.once("error",function(l){a=!0,o(l)}),e.once("close",function(){a||o(i),process.nextTick(Dl,r)}),t&&e.terminate()},r._final=function(i){if(e.readyState===e.CONNECTING){e.once("open",function(){r._final(i)});return}e._socket!==null&&(e._socket._writableState.finished?(i(),r._readableState.endEmitted&&r.destroy()):(e._socket.once("finish",function(){i()}),e.close()))},r._read=function(){e.isPaused&&e.resume()},r._write=function(i,o,a){if(e.readyState===e.CONNECTING){e.once("open",function(){r._write(i,o,a)});return}e.send(i,a)},r.on("end",a_),r.on("error",Gl),r}Ll.exports=s_});var Kl=K((jv,Ul)=>{"use strict";var{tokenChars:d_}=It();function l_(e){let n=new Set,t=-1,r=-1,i=0;for(i;i<e.length;i++){let a=e.charCodeAt(i);if(r===-1&&d_[a]===1)t===-1&&(t=i);else if(i!==0&&(a===32||a===9))r===-1&&t!==-1&&(r=i);else if(a===44){if(t===-1)throw new SyntaxError(`Unexpected character at index ${i}`);r===-1&&(r=i);let s=e.slice(t,r);if(n.has(s))throw new SyntaxError(`The "${s}" subprotocol is duplicated`);n.add(s),t=r=-1}else throw new SyntaxError(`Unexpected character at index ${i}`)}if(t===-1||r!==-1)throw new SyntaxError("Unexpected end of input");let o=e.slice(t,i);if(n.has(o))throw new SyntaxError(`The "${o}" subprotocol is duplicated`);return n.add(o),n}Ul.exports={parse:l_}});var Zl=K((Nv,Ql)=>{"use strict";var u_=D("events"),Ci=D("http"),{Duplex:$v}=D("stream"),{createHash:c_}=D("crypto"),Bl=sa(),nt=fr(),f_=Kl(),p_=Ti(),{GUID:m_,kWebSocket:h_}=bn(),__=/^[+/0-9A-Za-z]{22}==$/,zl=0,Wl=1,Vl=2,fa=class extends u_{constructor(n,t){if(super(),n={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:p_,...n},n.port==null&&!n.server&&!n.noServer||n.port!=null&&(n.server||n.noServer)||n.server&&n.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(n.port!=null?(this._server=Ci.createServer((r,i)=>{let o=Ci.STATUS_CODES[426];i.writeHead(426,{"Content-Length":o.length,"Content-Type":"text/plain"}),i.end(o)}),this._server.listen(n.port,n.host,n.backlog,t)):n.server&&(this._server=n.server),this._server){let r=this.emit.bind(this,"connection");this._removeListeners=y_(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(i,o,a)=>{this.handleUpgrade(i,o,a,r)}})}n.perMessageDeflate===!0&&(n.perMessageDeflate={}),n.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=n,this._state=zl}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(n){if(this._state===Vl){n&&this.once("close",()=>{n(new Error("The server is not running"))}),process.nextTick(_r,this);return}if(n&&this.once("close",n),this._state!==Wl)if(this._state=Wl,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(_r,this):process.nextTick(_r,this);else{let t=this._server;this._removeListeners(),this._removeListeners=this._server=null,t.close(()=>{_r(this)})}}shouldHandle(n){if(this.options.path){let t=n.url.indexOf("?");if((t!==-1?n.url.slice(0,t):n.url)!==this.options.path)return!1}return!0}handleUpgrade(n,t,r,i){t.on("error",Hl);let o=n.headers["sec-websocket-key"],a=n.headers.upgrade,s=+n.headers["sec-websocket-version"];if(n.method!=="GET"){tt(this,n,t,405,"Invalid HTTP method");return}if(a===void 0||a.toLowerCase()!=="websocket"){tt(this,n,t,400,"Invalid Upgrade header");return}if(o===void 0||!__.test(o)){tt(this,n,t,400,"Missing or invalid Sec-WebSocket-Key header");return}if(s!==13&&s!==8){tt(this,n,t,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(n)){yr(t,400);return}let l=n.headers["sec-websocket-protocol"],c=new Set;if(l!==void 0)try{c=f_.parse(l)}catch{tt(this,n,t,400,"Invalid Sec-WebSocket-Protocol header");return}let d=n.headers["sec-websocket-extensions"],f={};if(this.options.perMessageDeflate&&d!==void 0){let p=new nt(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let u=Bl.parse(d);u[nt.extensionName]&&(p.accept(u[nt.extensionName]),f[nt.extensionName]=p)}catch{tt(this,n,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let p={origin:n.headers[`${s===8?"sec-websocket-origin":"origin"}`],secure:!!(n.socket.authorized||n.socket.encrypted),req:n};if(this.options.verifyClient.length===2){this.options.verifyClient(p,(u,_,h,y)=>{if(!u)return yr(t,_||401,h,y);this.completeUpgrade(f,o,c,n,t,r,i)});return}if(!this.options.verifyClient(p))return yr(t,401)}this.completeUpgrade(f,o,c,n,t,r,i)}completeUpgrade(n,t,r,i,o,a,s){if(!o.readable||!o.writable)return o.destroy();if(o[h_])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>zl)return yr(o,503);let c=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${c_("sha1").update(t+m_).digest("base64")}`],d=new this.options.WebSocket(null,void 0,this.options);if(r.size){let f=this.options.handleProtocols?this.options.handleProtocols(r,i):r.values().next().value;f&&(c.push(`Sec-WebSocket-Protocol: ${f}`),d._protocol=f)}if(n[nt.extensionName]){let f=n[nt.extensionName].params,p=Bl.format({[nt.extensionName]:[f]});c.push(`Sec-WebSocket-Extensions: ${p}`),d._extensions=n}this.emit("headers",c,i),o.write(c.concat(`\r
7
7
  `).join(`\r