@linzumi/cli 1.0.282 → 1.0.284

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 Sp=Object.create;var To=Object.defineProperty;var vp=Object.getOwnPropertyDescriptor;var xp=Object.getOwnPropertyNames;var wp=Object.getPrototypeOf,kp=Object.prototype.hasOwnProperty;var J=(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 _=(e,n)=>()=>(e&&(n=e(e=0)),n);var H=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports),Tp=(e,n)=>{for(var t in n)To(e,t,{get:n[t],enumerable:!0})},Cp=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of xp(n))!kp.call(e,i)&&i!==t&&To(e,i,{get:()=>n[i],enumerable:!(r=vp(n,i))||r.enumerable});return e};var Rt=(e,n,t)=>(t=e!=null?Sp(wp(e)):{},Cp(n||!e||!e.__esModule?To(t,"default",{value:e,enumerable:!0}):t,e));var Co=_(()=>{});function he(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 ri(e){if(e!=null)return he(e)}function L(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=_(()=>{});function jn(e,n){if(e!==void 0)return n(L(e))}function sn(e,n,t){return e!==void 0?t(L(e)):n}function U(e,n){if(e!==void 0)return he(n(L(e)))}function ye(e,n){if(e!==void 0)return n(L(e))}function G(e,n){return e!==void 0?L(e):n}var q=_(()=>{Co();B()});var ii=_(()=>{});function Te(e,n,t){return e.reduce(t,n)}var ee=_(()=>{ii();B()});function Sn(e){if(e.RE_EXN_ID==="JsExn")return he(e._1)}var oi,Ep,vn,YS,XS,$n=_(()=>{B();oi=(e=>n=>n&&typeof n[e]=="string"?n[e]:void 0),Ep=oi("stack"),vn=oi("message"),YS=oi("name"),XS=oi("fileName")});var pr=_(()=>{});var Xd=H((ev,Yd)=>{var Gn=J("constants"),Pp=process.cwd,di=null,Op=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return di||(di=Pp.call(process)),di};try{process.cwd()}catch{}typeof process.chdir=="function"&&(Eo=process.chdir,process.chdir=function(e){di=null,Eo.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,Eo));var Eo;Yd.exports=Rp;function Rp(e){Gn.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=d(e.stat),e.fstat=d(e.fstat),e.lstat=d(e.lstat),e.statSync=l(e.statSync),e.fstatSync=l(e.fstatSync),e.lstatSync=l(e.lstatSync),e.chmod&&!e.lchmod&&(e.lchmod=function(s,m,p){p&&process.nextTick(p)},e.lchmodSync=function(){}),e.chown&&!e.lchown&&(e.lchown=function(s,m,p,f){f&&process.nextTick(f)},e.lchownSync=function(){}),Op==="win32"&&(e.rename=typeof e.rename!="function"?e.rename:(function(s){function m(p,f,h){var c=Date.now(),y=0;s(p,f,function b(x){if(x&&(x.code==="EACCES"||x.code==="EPERM"||x.code==="EBUSY")&&Date.now()-c<6e4){setTimeout(function(){e.stat(f,function(v,g){v&&v.code==="ENOENT"?s(p,f,b):h(x)})},y),y<100&&(y+=10);return}h&&h(x)})}return Object.setPrototypeOf&&Object.setPrototypeOf(m,s),m})(e.rename)),e.read=typeof e.read!="function"?e.read:(function(s){function m(p,f,h,c,y,b){var x;if(b&&typeof b=="function"){var v=0;x=function(g,P,O){if(g&&g.code==="EAGAIN"&&v<10)return v++,s.call(e,p,f,h,c,y,x);b.apply(this,arguments)}}return s.call(e,p,f,h,c,y,x)}return Object.setPrototypeOf&&Object.setPrototypeOf(m,s),m})(e.read),e.readSync=typeof e.readSync!="function"?e.readSync:(function(s){return function(m,p,f,h,c){for(var y=0;;)try{return s.call(e,m,p,f,h,c)}catch(b){if(b.code==="EAGAIN"&&y<10){y++;continue}throw b}}})(e.readSync);function n(s){s.lchmod=function(m,p,f){s.open(m,Gn.O_WRONLY|Gn.O_SYMLINK,p,function(h,c){if(h){f&&f(h);return}s.fchmod(c,p,function(y){s.close(c,function(b){f&&f(y||b)})})})},s.lchmodSync=function(m,p){var f=s.openSync(m,Gn.O_WRONLY|Gn.O_SYMLINK,p),h=!0,c;try{c=s.fchmodSync(f,p),h=!1}finally{if(h)try{s.closeSync(f)}catch{}else s.closeSync(f)}return c}}function t(s){Gn.hasOwnProperty("O_SYMLINK")&&s.futimes?(s.lutimes=function(m,p,f,h){s.open(m,Gn.O_SYMLINK,function(c,y){if(c){h&&h(c);return}s.futimes(y,p,f,function(b){s.close(y,function(x){h&&h(b||x)})})})},s.lutimesSync=function(m,p,f){var h=s.openSync(m,Gn.O_SYMLINK),c,y=!0;try{c=s.futimesSync(h,p,f),y=!1}finally{if(y)try{s.closeSync(h)}catch{}else s.closeSync(h)}return c}):s.futimes&&(s.lutimes=function(m,p,f,h){h&&process.nextTick(h)},s.lutimesSync=function(){})}function r(s){return s&&function(m,p,f){return s.call(e,m,p,function(h){u(h)&&(h=null),f&&f.apply(this,arguments)})}}function i(s){return s&&function(m,p){try{return s.call(e,m,p)}catch(f){if(!u(f))throw f}}}function o(s){return s&&function(m,p,f,h){return s.call(e,m,p,f,function(c){u(c)&&(c=null),h&&h.apply(this,arguments)})}}function a(s){return s&&function(m,p,f){try{return s.call(e,m,p,f)}catch(h){if(!u(h))throw h}}}function d(s){return s&&function(m,p,f){typeof p=="function"&&(f=p,p=null);function h(c,y){y&&(y.uid<0&&(y.uid+=4294967296),y.gid<0&&(y.gid+=4294967296)),f&&f.apply(this,arguments)}return p?s.call(e,m,p,h):s.call(e,m,h)}}function l(s){return s&&function(m,p){var f=p?s.call(e,m,p):s.call(e,m);return f&&(f.uid<0&&(f.uid+=4294967296),f.gid<0&&(f.gid+=4294967296)),f}}function u(s){if(!s||s.code==="ENOSYS")return!0;var m=!process.getuid||process.getuid()!==0;return!!(m&&(s.code==="EINVAL"||s.code==="EPERM"))}}});var ts=H((nv,ns)=>{var es=J("stream").Stream;ns.exports=Ip;function Ip(e){return{ReadStream:n,WriteStream:t};function n(r,i){if(!(this instanceof n))return new n(r,i);es.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),d=0,l=a.length;d<l;d++){var u=a[d];this[u]=i[u]}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(s,m){if(s){o.emit("error",s),o.readable=!1;return}o.fd=m,o.emit("open",m),o._read()})}function t(r,i){if(!(this instanceof t))return new t(r,i);es.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,d=o.length;a<d;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 is=H((tv,rs)=>{"use strict";rs.exports=qp;var Mp=Object.getPrototypeOf||function(e){return e.__proto__};function qp(e){if(e===null||typeof e!="object")return e;if(e instanceof Object)var n={__proto__:Mp(e)};else var n=Object.create(null);return Object.getOwnPropertyNames(e).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(e,t))}),n}});var Io=H((rv,Ro)=>{var ne=J("fs"),Fp=Xd(),jp=ts(),$p=is(),si=J("util"),Ie,ui;typeof Symbol=="function"&&typeof Symbol.for=="function"?(Ie=Symbol.for("graceful-fs.queue"),ui=Symbol.for("graceful-fs.previous")):(Ie="___graceful-fs.queue",ui="___graceful-fs.previous");function Gp(){}function ds(e,n){Object.defineProperty(e,Ie,{get:function(){return n}})}var ot=Gp;si.debuglog?ot=si.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(ot=function(){var e=si.format.apply(si,arguments);e="GFS4: "+e.split(/\n/).join(`
4
- GFS4: `),console.error(e)});ne[Ie]||(os=global[Ie]||[],ds(ne,os),ne.close=(function(e){function n(t,r){return e.call(ne,t,function(i){i||as(),typeof r=="function"&&r.apply(this,arguments)})}return Object.defineProperty(n,ui,{value:e}),n})(ne.close),ne.closeSync=(function(e){function n(t){e.apply(ne,arguments),as()}return Object.defineProperty(n,ui,{value:e}),n})(ne.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){ot(ne[Ie]),J("assert").equal(ne[Ie].length,0)}));var os;global[Ie]||ds(global,ne[Ie]);Ro.exports=Po($p(ne));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!ne.__patched&&(Ro.exports=Po(ne),ne.__patched=!0);function Po(e){Fp(e),e.gracefulify=Po,e.createReadStream=P,e.createWriteStream=O;var n=e.readFile;e.readFile=t;function t(T,I,M){return typeof I=="function"&&(M=I,I=null),ae(T,I,M);function ae(R,w,S,A){return n(R,w,function(E){E&&(E.code==="EMFILE"||E.code==="ENFILE")?It([ae,[R,w,S],E,A||Date.now(),Date.now()]):typeof S=="function"&&S.apply(this,arguments)})}}var r=e.writeFile;e.writeFile=i;function i(T,I,M,ae){return typeof M=="function"&&(ae=M,M=null),R(T,I,M,ae);function R(w,S,A,E,k){return r(w,S,A,function(C){C&&(C.code==="EMFILE"||C.code==="ENFILE")?It([R,[w,S,A,E],C,k||Date.now(),Date.now()]):typeof E=="function"&&E.apply(this,arguments)})}}var o=e.appendFile;o&&(e.appendFile=a);function a(T,I,M,ae){return typeof M=="function"&&(ae=M,M=null),R(T,I,M,ae);function R(w,S,A,E,k){return o(w,S,A,function(C){C&&(C.code==="EMFILE"||C.code==="ENFILE")?It([R,[w,S,A,E],C,k||Date.now(),Date.now()]):typeof E=="function"&&E.apply(this,arguments)})}}var d=e.copyFile;d&&(e.copyFile=l);function l(T,I,M,ae){return typeof M=="function"&&(ae=M,M=0),R(T,I,M,ae);function R(w,S,A,E,k){return d(w,S,A,function(C){C&&(C.code==="EMFILE"||C.code==="ENFILE")?It([R,[w,S,A,E],C,k||Date.now(),Date.now()]):typeof E=="function"&&E.apply(this,arguments)})}}var u=e.readdir;e.readdir=m;var s=/^v[0-5]\./;function m(T,I,M){typeof I=="function"&&(M=I,I=null);var ae=s.test(process.version)?function(S,A,E,k){return u(S,R(S,A,E,k))}:function(S,A,E,k){return u(S,A,R(S,A,E,k))};return ae(T,I,M);function R(w,S,A,E){return function(k,C){k&&(k.code==="EMFILE"||k.code==="ENFILE")?It([ae,[w,S,A],k,E||Date.now(),Date.now()]):(C&&C.sort&&C.sort(),typeof A=="function"&&A.call(this,k,C))}}}if(process.version.substr(0,4)==="v0.8"){var p=jp(e);b=p.ReadStream,v=p.WriteStream}var f=e.ReadStream;f&&(b.prototype=Object.create(f.prototype),b.prototype.open=x);var h=e.WriteStream;h&&(v.prototype=Object.create(h.prototype),v.prototype.open=g),Object.defineProperty(e,"ReadStream",{get:function(){return b},set:function(T){b=T},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return v},set:function(T){v=T},enumerable:!0,configurable:!0});var c=b;Object.defineProperty(e,"FileReadStream",{get:function(){return c},set:function(T){c=T},enumerable:!0,configurable:!0});var y=v;Object.defineProperty(e,"FileWriteStream",{get:function(){return y},set:function(T){y=T},enumerable:!0,configurable:!0});function b(T,I){return this instanceof b?(f.apply(this,arguments),this):b.apply(Object.create(b.prototype),arguments)}function x(){var T=this;oe(T.path,T.flags,T.mode,function(I,M){I?(T.autoClose&&T.destroy(),T.emit("error",I)):(T.fd=M,T.emit("open",M),T.read())})}function v(T,I){return this instanceof v?(h.apply(this,arguments),this):v.apply(Object.create(v.prototype),arguments)}function g(){var T=this;oe(T.path,T.flags,T.mode,function(I,M){I?(T.destroy(),T.emit("error",I)):(T.fd=M,T.emit("open",M))})}function P(T,I){return new e.ReadStream(T,I)}function O(T,I){return new e.WriteStream(T,I)}var $=e.open;e.open=oe;function oe(T,I,M,ae){return typeof M=="function"&&(ae=M,M=null),R(T,I,M,ae);function R(w,S,A,E,k){return $(w,S,A,function(C,j){C&&(C.code==="EMFILE"||C.code==="ENFILE")?It([R,[w,S,A,E],C,k||Date.now(),Date.now()]):typeof E=="function"&&E.apply(this,arguments)})}}return e}function It(e){ot("ENQUEUE",e[0].name,e[1]),ne[Ie].push(e),Oo()}var li;function as(){for(var e=Date.now(),n=0;n<ne[Ie].length;++n)ne[Ie][n].length>2&&(ne[Ie][n][3]=e,ne[Ie][n][4]=e);Oo()}function Oo(){if(clearTimeout(li),li=void 0,ne[Ie].length!==0){var e=ne[Ie].shift(),n=e[0],t=e[1],r=e[2],i=e[3],o=e[4];if(i===void 0)ot("RETRY",n.name,t),n.apply(null,t);else if(Date.now()-i>=6e4){ot("TIMEOUT",n.name,t);var a=t.pop();typeof a=="function"&&a.call(null,r)}else{var d=Date.now()-o,l=Math.max(o-i,1),u=Math.min(l*1.2,100);d>=u?(ot("RETRY",n.name,t),n.apply(null,t.concat([i]))):ne[Ie].push(e)}li===void 0&&(li=setTimeout(Oo,0))}}});var ls=H((iv,ss)=>{function He(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))}ss.exports=He;He.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};He.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null};He.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};He.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)};He.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)};He.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)};He.prototype.start=He.prototype.try;He.prototype.errors=function(){return this._errors};He.prototype.attempts=function(){return this._attempts};He.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 us=H(at=>{var Np=ls();at.operation=function(e){var n=at.timeouts(e);return new Np(n,{forever:e&&e.forever,unref:e&&e.unref,maxRetryTime:e&&e.maxRetryTime})};at.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};at.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};at.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 u=at.operation(n),s=Array.prototype.slice.call(arguments,1),m=s.pop();s.push(function(p){u.retry(p)||(p&&(arguments[0]=u.mainError()),m.apply(this,arguments))}),u.attempt(function(){l.apply(e,s)})}.bind(e,a),e[o].options=n}}});var fs=H((av,cs)=>{cs.exports=us()});var ms=H((dv,ci)=>{ci.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];process.platform!=="win32"&&ci.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&ci.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var gs=H((sv,Ft)=>{var Q=global.process,dt=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"};dt(Q)?(ps=J("assert"),Mt=ms(),_s=/^win/i.test(Q.platform),_r=J("events"),typeof _r!="function"&&(_r=_r.EventEmitter),Q.__signal_exit_emitter__?Ce=Q.__signal_exit_emitter__:(Ce=Q.__signal_exit_emitter__=new _r,Ce.count=0,Ce.emitted={}),Ce.infinite||(Ce.setMaxListeners(1/0),Ce.infinite=!0),Ft.exports=function(e,n){if(!dt(global.process))return function(){};ps.equal(typeof e,"function","a callback must be provided for exit handler"),qt===!1&&Mo();var t="exit";n&&n.alwaysLast&&(t="afterexit");var r=function(){Ce.removeListener(t,e),Ce.listeners("exit").length===0&&Ce.listeners("afterexit").length===0&&fi()};return Ce.on(t,e),r},fi=function(){!qt||!dt(global.process)||(qt=!1,Mt.forEach(function(n){try{Q.removeListener(n,mi[n])}catch{}}),Q.emit=pi,Q.reallyExit=qo,Ce.count-=1)},Ft.exports.unload=fi,st=function(n,t,r){Ce.emitted[n]||(Ce.emitted[n]=!0,Ce.emit(n,t,r))},mi={},Mt.forEach(function(e){mi[e]=function(){if(dt(global.process)){var t=Q.listeners(e);t.length===Ce.count&&(fi(),st("exit",null,e),st("afterexit",null,e),_s&&e==="SIGHUP"&&(e="SIGINT"),Q.kill(Q.pid,e))}}}),Ft.exports.signals=function(){return Mt},qt=!1,Mo=function(){qt||!dt(global.process)||(qt=!0,Ce.count+=1,Mt=Mt.filter(function(n){try{return Q.on(n,mi[n]),!0}catch{return!1}}),Q.emit=ys,Q.reallyExit=hs)},Ft.exports.load=Mo,qo=Q.reallyExit,hs=function(n){dt(global.process)&&(Q.exitCode=n||0,st("exit",Q.exitCode,null),st("afterexit",Q.exitCode,null),qo.call(Q,Q.exitCode))},pi=Q.emit,ys=function(n,t){if(n==="exit"&&dt(global.process)){t!==void 0&&(Q.exitCode=t);var r=pi.apply(this,arguments);return st("exit",Q.exitCode,null),st("afterexit",Q.exitCode,null),r}else return pi.apply(this,arguments)}):Ft.exports=function(){return function(){}};var ps,Mt,_s,_r,Ce,fi,st,mi,qt,Mo,qo,hs,pi,ys});var ws=H((lv,hr)=>{"use strict";var Dp=J("path"),$o=Io(),Lp=fs(),Jp=gs(),xn={};function jt(e,n){return n.lockfilePath||`${e}.lock`}function Go(e,n,t){if(!n.realpath)return t(null,Dp.resolve(e));n.fs.realpath(e,t)}function Fo(e,n,t){n.fs.mkdir(jt(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(jt(e,n),(i,o)=>{if(i)return i.code==="ENOENT"?Fo(e,{...n,stale:0},t):t(i);if(!Ss(o,n))return t(Object.assign(new Error("Lock file is already being hold"),{code:"ELOCKED",file:e}));vs(e,n,a=>{if(a)return t(a);Fo(e,{...n,stale:0},t)})})})}function Ss(e,n){return e.mtime.getTime()<Date.now()-n.stale}function vs(e,n,t){n.fs.rmdir(jt(e,n),r=>{if(r&&r.code!=="ENOENT")return t(r);t()})}function jo(e,n){let t=xn[e];t.updateTimeout||(t.updateDelay=t.updateDelay||n.update,t.updateTimeout=setTimeout(()=>{let r=Date.now()/1e3;t.updateTimeout=null,n.fs.utimes(jt(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 bs(e,t,o)}if(i)return i.code==="ENOENT"?bs(e,t,Object.assign(i,{code:"ECOMPROMISED"})):(t.updateError=i,t.updateDelay=1e3,jo(e,n));t.lastUpdate=Date.now(),t.updateError=null,t.updateDelay=null,jo(e,n)}})},t.updateDelay),t.updateTimeout.unref&&t.updateTimeout.unref())}function bs(e,n,t){n.released=!0,n.updateTimeout&&clearTimeout(n.updateTimeout),xn[e]===n&&delete xn[e],n.options.onCompromised(t)}function Up(e,n,t){n={stale:1e4,update:null,realpath:!0,retries:0,fs:$o,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),Go(e,n,(r,i)=>{if(r)return t(r);let o=Lp.operation(n.retries);o.attempt(()=>{Fo(i,n,a=>{if(o.retry(a))return;if(a)return t(o.mainError());let d=xn[i]={options:n,lastUpdate:Date.now()};jo(i,n),t(null,l=>{if(d.released)return l&&l(Object.assign(new Error("Lock is already released"),{code:"ERELEASED"}));xs(i,{...n,realpath:!1},l)})})})})}function xs(e,n,t){n={fs:$o,realpath:!0,...n},Go(e,n,(r,i)=>{if(r)return t(r);let o=xn[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 xn[i],vs(i,n,t)})}function Kp(e,n,t){n={stale:1e4,realpath:!0,fs:$o,...n},n.stale=Math.max(n.stale||0,2e3),Go(e,n,(r,i)=>{if(r)return t(r);n.fs.stat(jt(i,n),(o,a)=>o?o.code==="ENOENT"?t(null,!1):t(o):t(null,!Ss(a,n)))})}function Bp(){return xn}Jp(()=>{for(let e in xn){let n=xn[e].options;try{n.fs.rmdirSync(jt(e,n))}catch{}}});hr.exports.lock=Up;hr.exports.unlock=xs;hr.exports.check=Kp;hr.exports.getLocks=Bp});var Ts=H((uv,ks)=>{"use strict";var zp=Io();function Wp(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(d){return o(d)}o(null,a)}}),t}function Hp(e){return(...n)=>new Promise((t,r)=>{n.push((i,o)=>{i?r(i):t(o)}),e(...n)})}function Vp(e){return(...n)=>{let t,r;if(n.push((i,o)=>{t=i,r=o}),e(...n),t)throw t;return r}}function Qp(e){if(e={...e},e.fs=Wp(e.fs||zp),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}ks.exports={toPromise:Hp,toSync:Vp,toSyncOptions:Qp}});var As=H((cv,Nn)=>{"use strict";var $t=ws(),{toPromise:_i,toSync:hi,toSyncOptions:No}=Ts();async function Cs(e,n){let t=await _i($t.lock)(e,n);return _i(t)}function Zp(e,n){let t=hi($t.lock)(e,No(n));return hi(t)}function Yp(e,n){return _i($t.unlock)(e,n)}function Xp(e,n){return hi($t.unlock)(e,No(n))}function e_(e,n){return _i($t.check)(e,n)}function n_(e,n){return hi($t.check)(e,No(n))}Nn.exports=Cs;Nn.exports.lock=Cs;Nn.exports.unlock=Yp;Nn.exports.lockSync=Zp;Nn.exports.unlockSync=Xp;Nn.exports.check=e_;Nn.exports.checkSync=n_});var Es=_(()=>{});var yi=_(()=>{});var Gt=_(()=>{});var te=_(()=>{Es();yi();Gt()});function r_(e){return e==null?!1:typeof e.RE_EXN_ID=="string"}function ge(e){return r_(e)?e:{RE_EXN_ID:"JsExn",_1:e}}function Jo(e){let n=Lo[e];if(n!==void 0){let t=n+1|0;return Lo[e]=t,e+("/"+t)}return Lo[e]=1,e}var Lo,ve=_(()=>{Lo={}});function en(e){let n=Sn(e);if(n===void 0)return{code:void 0,message:"unknown error"};let t=L(n);return{code:ri(t.code),message:G(vn(t),"unknown error")}}var i_,le=_(()=>{$n();q();pr();i_=Rt(As(),1);te();B();ve()});function Is(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 Rs,Ms=_(()=>{ee();le();q();te();Rs=new RegExp("(\\d+\\.\\d+\\.\\d+)")});function qs(e){return e!=="claude_code"}function a_(e,n){let t=Is(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 Fs(e,n,t){let r;if(e===0&&n.length<=1048576){let i=Rs.exec(n);r=i==null?void 0:ye(i.slice(1)[0],o=>o)}else r=void 0;return a_(r,t)}var js=_(()=>{q();Ms()});var $s,Gs,Uo=_(()=>{js();$s=qs,Gs=Fs});var Ds,Ns=_(()=>{Ds={name:"@linzumi/cli",version:"1.0.282",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.159.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 Si,vi=_(()=>{"use strict";Ns();Si=Ds.dependencies["@openai/codex"]});import{readFileSync as l_}from"node:fs";function f_(e=process.env,n=void 0,t=r=>l_(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 zo(e){let n=e.env??process.env,t=f_(n,e.config);if(t===void 0)return;let r=(n.SMOLCLOUD_BASE_URL??e.config?.baseUrl??u_).replace(/\/+$/,"");return e.fetchImpl===void 0?{baseUrl:r,apiKey:t}:{baseUrl:r,apiKey:t,fetchImpl:e.fetchImpl}}function xi(e){return e.replace(/\bsmk_[A-Za-z0-9._-]+/g,"smk_[REDACTED]")}function Ls(e){return e.split("/").map(encodeURIComponent).join("/")}async function wn(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 d=new AbortController,l=r.timeoutMs??Bo,u=setTimeout(()=>d.abort(),l),s;try{s=await i(`${e.baseUrl}${t}`,{method:n,headers:o,body:a??null,signal:d.signal})}catch(p){throw p instanceof Error&&p.name==="AbortError"?new $e("TIMEOUT",`smolcloud ${n} ${t} timed out after ${l}ms`):new $e("CONNECTION",`smolcloud request failed: ${p instanceof Error?p.message:String(p)}`)}finally{clearTimeout(u)}if(!s.ok){let p=await s.text().catch(()=>""),f=s.status===404?"NOT_FOUND":s.status===401||s.status===403?"UNAUTHORIZED":"CLOUD_ERROR";throw new $e(f,`smolcloud ${n} ${t} \u2192 ${s.status}${p===""?"":`: ${p}`}`)}return r.accept==="bytes"?Buffer.from(await s.arrayBuffer()):s.status===204?void 0:(s.headers.get("content-type")??"").includes("application/json")?await s.json():void 0}async function*m_(e){let n=e.getReader(),t=new TextDecoder,r="",i="",o=[],a=()=>{let d=i,l=o.join(`
4
+ GFS4: `),console.error(e)});ne[Ie]||(os=global[Ie]||[],ds(ne,os),ne.close=(function(e){function n(t,r){return e.call(ne,t,function(i){i||as(),typeof r=="function"&&r.apply(this,arguments)})}return Object.defineProperty(n,ui,{value:e}),n})(ne.close),ne.closeSync=(function(e){function n(t){e.apply(ne,arguments),as()}return Object.defineProperty(n,ui,{value:e}),n})(ne.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){ot(ne[Ie]),J("assert").equal(ne[Ie].length,0)}));var os;global[Ie]||ds(global,ne[Ie]);Ro.exports=Po($p(ne));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!ne.__patched&&(Ro.exports=Po(ne),ne.__patched=!0);function Po(e){Fp(e),e.gracefulify=Po,e.createReadStream=P,e.createWriteStream=O;var n=e.readFile;e.readFile=t;function t(T,I,M){return typeof I=="function"&&(M=I,I=null),ae(T,I,M);function ae(R,w,S,A){return n(R,w,function(E){E&&(E.code==="EMFILE"||E.code==="ENFILE")?It([ae,[R,w,S],E,A||Date.now(),Date.now()]):typeof S=="function"&&S.apply(this,arguments)})}}var r=e.writeFile;e.writeFile=i;function i(T,I,M,ae){return typeof M=="function"&&(ae=M,M=null),R(T,I,M,ae);function R(w,S,A,E,k){return r(w,S,A,function(C){C&&(C.code==="EMFILE"||C.code==="ENFILE")?It([R,[w,S,A,E],C,k||Date.now(),Date.now()]):typeof E=="function"&&E.apply(this,arguments)})}}var o=e.appendFile;o&&(e.appendFile=a);function a(T,I,M,ae){return typeof M=="function"&&(ae=M,M=null),R(T,I,M,ae);function R(w,S,A,E,k){return o(w,S,A,function(C){C&&(C.code==="EMFILE"||C.code==="ENFILE")?It([R,[w,S,A,E],C,k||Date.now(),Date.now()]):typeof E=="function"&&E.apply(this,arguments)})}}var d=e.copyFile;d&&(e.copyFile=l);function l(T,I,M,ae){return typeof M=="function"&&(ae=M,M=0),R(T,I,M,ae);function R(w,S,A,E,k){return d(w,S,A,function(C){C&&(C.code==="EMFILE"||C.code==="ENFILE")?It([R,[w,S,A,E],C,k||Date.now(),Date.now()]):typeof E=="function"&&E.apply(this,arguments)})}}var u=e.readdir;e.readdir=m;var s=/^v[0-5]\./;function m(T,I,M){typeof I=="function"&&(M=I,I=null);var ae=s.test(process.version)?function(S,A,E,k){return u(S,R(S,A,E,k))}:function(S,A,E,k){return u(S,A,R(S,A,E,k))};return ae(T,I,M);function R(w,S,A,E){return function(k,C){k&&(k.code==="EMFILE"||k.code==="ENFILE")?It([ae,[w,S,A],k,E||Date.now(),Date.now()]):(C&&C.sort&&C.sort(),typeof A=="function"&&A.call(this,k,C))}}}if(process.version.substr(0,4)==="v0.8"){var p=jp(e);b=p.ReadStream,v=p.WriteStream}var f=e.ReadStream;f&&(b.prototype=Object.create(f.prototype),b.prototype.open=x);var h=e.WriteStream;h&&(v.prototype=Object.create(h.prototype),v.prototype.open=g),Object.defineProperty(e,"ReadStream",{get:function(){return b},set:function(T){b=T},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return v},set:function(T){v=T},enumerable:!0,configurable:!0});var c=b;Object.defineProperty(e,"FileReadStream",{get:function(){return c},set:function(T){c=T},enumerable:!0,configurable:!0});var y=v;Object.defineProperty(e,"FileWriteStream",{get:function(){return y},set:function(T){y=T},enumerable:!0,configurable:!0});function b(T,I){return this instanceof b?(f.apply(this,arguments),this):b.apply(Object.create(b.prototype),arguments)}function x(){var T=this;oe(T.path,T.flags,T.mode,function(I,M){I?(T.autoClose&&T.destroy(),T.emit("error",I)):(T.fd=M,T.emit("open",M),T.read())})}function v(T,I){return this instanceof v?(h.apply(this,arguments),this):v.apply(Object.create(v.prototype),arguments)}function g(){var T=this;oe(T.path,T.flags,T.mode,function(I,M){I?(T.destroy(),T.emit("error",I)):(T.fd=M,T.emit("open",M))})}function P(T,I){return new e.ReadStream(T,I)}function O(T,I){return new e.WriteStream(T,I)}var $=e.open;e.open=oe;function oe(T,I,M,ae){return typeof M=="function"&&(ae=M,M=null),R(T,I,M,ae);function R(w,S,A,E,k){return $(w,S,A,function(C,j){C&&(C.code==="EMFILE"||C.code==="ENFILE")?It([R,[w,S,A,E],C,k||Date.now(),Date.now()]):typeof E=="function"&&E.apply(this,arguments)})}}return e}function It(e){ot("ENQUEUE",e[0].name,e[1]),ne[Ie].push(e),Oo()}var li;function as(){for(var e=Date.now(),n=0;n<ne[Ie].length;++n)ne[Ie][n].length>2&&(ne[Ie][n][3]=e,ne[Ie][n][4]=e);Oo()}function Oo(){if(clearTimeout(li),li=void 0,ne[Ie].length!==0){var e=ne[Ie].shift(),n=e[0],t=e[1],r=e[2],i=e[3],o=e[4];if(i===void 0)ot("RETRY",n.name,t),n.apply(null,t);else if(Date.now()-i>=6e4){ot("TIMEOUT",n.name,t);var a=t.pop();typeof a=="function"&&a.call(null,r)}else{var d=Date.now()-o,l=Math.max(o-i,1),u=Math.min(l*1.2,100);d>=u?(ot("RETRY",n.name,t),n.apply(null,t.concat([i]))):ne[Ie].push(e)}li===void 0&&(li=setTimeout(Oo,0))}}});var ls=H((iv,ss)=>{function He(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))}ss.exports=He;He.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};He.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null};He.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};He.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)};He.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)};He.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)};He.prototype.start=He.prototype.try;He.prototype.errors=function(){return this._errors};He.prototype.attempts=function(){return this._attempts};He.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 us=H(at=>{var Np=ls();at.operation=function(e){var n=at.timeouts(e);return new Np(n,{forever:e&&e.forever,unref:e&&e.unref,maxRetryTime:e&&e.maxRetryTime})};at.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};at.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};at.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 u=at.operation(n),s=Array.prototype.slice.call(arguments,1),m=s.pop();s.push(function(p){u.retry(p)||(p&&(arguments[0]=u.mainError()),m.apply(this,arguments))}),u.attempt(function(){l.apply(e,s)})}.bind(e,a),e[o].options=n}}});var fs=H((av,cs)=>{cs.exports=us()});var ms=H((dv,ci)=>{ci.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];process.platform!=="win32"&&ci.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&ci.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var gs=H((sv,Ft)=>{var Q=global.process,dt=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"};dt(Q)?(ps=J("assert"),Mt=ms(),_s=/^win/i.test(Q.platform),_r=J("events"),typeof _r!="function"&&(_r=_r.EventEmitter),Q.__signal_exit_emitter__?Ce=Q.__signal_exit_emitter__:(Ce=Q.__signal_exit_emitter__=new _r,Ce.count=0,Ce.emitted={}),Ce.infinite||(Ce.setMaxListeners(1/0),Ce.infinite=!0),Ft.exports=function(e,n){if(!dt(global.process))return function(){};ps.equal(typeof e,"function","a callback must be provided for exit handler"),qt===!1&&Mo();var t="exit";n&&n.alwaysLast&&(t="afterexit");var r=function(){Ce.removeListener(t,e),Ce.listeners("exit").length===0&&Ce.listeners("afterexit").length===0&&fi()};return Ce.on(t,e),r},fi=function(){!qt||!dt(global.process)||(qt=!1,Mt.forEach(function(n){try{Q.removeListener(n,mi[n])}catch{}}),Q.emit=pi,Q.reallyExit=qo,Ce.count-=1)},Ft.exports.unload=fi,st=function(n,t,r){Ce.emitted[n]||(Ce.emitted[n]=!0,Ce.emit(n,t,r))},mi={},Mt.forEach(function(e){mi[e]=function(){if(dt(global.process)){var t=Q.listeners(e);t.length===Ce.count&&(fi(),st("exit",null,e),st("afterexit",null,e),_s&&e==="SIGHUP"&&(e="SIGINT"),Q.kill(Q.pid,e))}}}),Ft.exports.signals=function(){return Mt},qt=!1,Mo=function(){qt||!dt(global.process)||(qt=!0,Ce.count+=1,Mt=Mt.filter(function(n){try{return Q.on(n,mi[n]),!0}catch{return!1}}),Q.emit=ys,Q.reallyExit=hs)},Ft.exports.load=Mo,qo=Q.reallyExit,hs=function(n){dt(global.process)&&(Q.exitCode=n||0,st("exit",Q.exitCode,null),st("afterexit",Q.exitCode,null),qo.call(Q,Q.exitCode))},pi=Q.emit,ys=function(n,t){if(n==="exit"&&dt(global.process)){t!==void 0&&(Q.exitCode=t);var r=pi.apply(this,arguments);return st("exit",Q.exitCode,null),st("afterexit",Q.exitCode,null),r}else return pi.apply(this,arguments)}):Ft.exports=function(){return function(){}};var ps,Mt,_s,_r,Ce,fi,st,mi,qt,Mo,qo,hs,pi,ys});var ws=H((lv,hr)=>{"use strict";var Dp=J("path"),$o=Io(),Lp=fs(),Jp=gs(),xn={};function jt(e,n){return n.lockfilePath||`${e}.lock`}function Go(e,n,t){if(!n.realpath)return t(null,Dp.resolve(e));n.fs.realpath(e,t)}function Fo(e,n,t){n.fs.mkdir(jt(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(jt(e,n),(i,o)=>{if(i)return i.code==="ENOENT"?Fo(e,{...n,stale:0},t):t(i);if(!Ss(o,n))return t(Object.assign(new Error("Lock file is already being hold"),{code:"ELOCKED",file:e}));vs(e,n,a=>{if(a)return t(a);Fo(e,{...n,stale:0},t)})})})}function Ss(e,n){return e.mtime.getTime()<Date.now()-n.stale}function vs(e,n,t){n.fs.rmdir(jt(e,n),r=>{if(r&&r.code!=="ENOENT")return t(r);t()})}function jo(e,n){let t=xn[e];t.updateTimeout||(t.updateDelay=t.updateDelay||n.update,t.updateTimeout=setTimeout(()=>{let r=Date.now()/1e3;t.updateTimeout=null,n.fs.utimes(jt(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 bs(e,t,o)}if(i)return i.code==="ENOENT"?bs(e,t,Object.assign(i,{code:"ECOMPROMISED"})):(t.updateError=i,t.updateDelay=1e3,jo(e,n));t.lastUpdate=Date.now(),t.updateError=null,t.updateDelay=null,jo(e,n)}})},t.updateDelay),t.updateTimeout.unref&&t.updateTimeout.unref())}function bs(e,n,t){n.released=!0,n.updateTimeout&&clearTimeout(n.updateTimeout),xn[e]===n&&delete xn[e],n.options.onCompromised(t)}function Up(e,n,t){n={stale:1e4,update:null,realpath:!0,retries:0,fs:$o,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),Go(e,n,(r,i)=>{if(r)return t(r);let o=Lp.operation(n.retries);o.attempt(()=>{Fo(i,n,a=>{if(o.retry(a))return;if(a)return t(o.mainError());let d=xn[i]={options:n,lastUpdate:Date.now()};jo(i,n),t(null,l=>{if(d.released)return l&&l(Object.assign(new Error("Lock is already released"),{code:"ERELEASED"}));xs(i,{...n,realpath:!1},l)})})})})}function xs(e,n,t){n={fs:$o,realpath:!0,...n},Go(e,n,(r,i)=>{if(r)return t(r);let o=xn[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 xn[i],vs(i,n,t)})}function Kp(e,n,t){n={stale:1e4,realpath:!0,fs:$o,...n},n.stale=Math.max(n.stale||0,2e3),Go(e,n,(r,i)=>{if(r)return t(r);n.fs.stat(jt(i,n),(o,a)=>o?o.code==="ENOENT"?t(null,!1):t(o):t(null,!Ss(a,n)))})}function Bp(){return xn}Jp(()=>{for(let e in xn){let n=xn[e].options;try{n.fs.rmdirSync(jt(e,n))}catch{}}});hr.exports.lock=Up;hr.exports.unlock=xs;hr.exports.check=Kp;hr.exports.getLocks=Bp});var Ts=H((uv,ks)=>{"use strict";var zp=Io();function Wp(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(d){return o(d)}o(null,a)}}),t}function Hp(e){return(...n)=>new Promise((t,r)=>{n.push((i,o)=>{i?r(i):t(o)}),e(...n)})}function Vp(e){return(...n)=>{let t,r;if(n.push((i,o)=>{t=i,r=o}),e(...n),t)throw t;return r}}function Qp(e){if(e={...e},e.fs=Wp(e.fs||zp),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}ks.exports={toPromise:Hp,toSync:Vp,toSyncOptions:Qp}});var As=H((cv,Nn)=>{"use strict";var $t=ws(),{toPromise:_i,toSync:hi,toSyncOptions:No}=Ts();async function Cs(e,n){let t=await _i($t.lock)(e,n);return _i(t)}function Zp(e,n){let t=hi($t.lock)(e,No(n));return hi(t)}function Yp(e,n){return _i($t.unlock)(e,n)}function Xp(e,n){return hi($t.unlock)(e,No(n))}function e_(e,n){return _i($t.check)(e,n)}function n_(e,n){return hi($t.check)(e,No(n))}Nn.exports=Cs;Nn.exports.lock=Cs;Nn.exports.unlock=Yp;Nn.exports.lockSync=Zp;Nn.exports.unlockSync=Xp;Nn.exports.check=e_;Nn.exports.checkSync=n_});var Es=_(()=>{});var yi=_(()=>{});var Gt=_(()=>{});var te=_(()=>{Es();yi();Gt()});function r_(e){return e==null?!1:typeof e.RE_EXN_ID=="string"}function ge(e){return r_(e)?e:{RE_EXN_ID:"JsExn",_1:e}}function Jo(e){let n=Lo[e];if(n!==void 0){let t=n+1|0;return Lo[e]=t,e+("/"+t)}return Lo[e]=1,e}var Lo,ve=_(()=>{Lo={}});function en(e){let n=Sn(e);if(n===void 0)return{code:void 0,message:"unknown error"};let t=L(n);return{code:ri(t.code),message:G(vn(t),"unknown error")}}var i_,le=_(()=>{$n();q();pr();i_=Rt(As(),1);te();B();ve()});function Is(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 Rs,Ms=_(()=>{ee();le();q();te();Rs=new RegExp("(\\d+\\.\\d+\\.\\d+)")});function qs(e){return e!=="claude_code"}function a_(e,n){let t=Is(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 Fs(e,n,t){let r;if(e===0&&n.length<=1048576){let i=Rs.exec(n);r=i==null?void 0:ye(i.slice(1)[0],o=>o)}else r=void 0;return a_(r,t)}var js=_(()=>{q();Ms()});var $s,Gs,Uo=_(()=>{js();$s=qs,Gs=Fs});var Ds,Ns=_(()=>{Ds={name:"@linzumi/cli",version:"1.0.284",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.159.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 Si,vi=_(()=>{"use strict";Ns();Si=Ds.dependencies["@openai/codex"]});import{readFileSync as l_}from"node:fs";function f_(e=process.env,n=void 0,t=r=>l_(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 zo(e){let n=e.env??process.env,t=f_(n,e.config);if(t===void 0)return;let r=(n.SMOLCLOUD_BASE_URL??e.config?.baseUrl??u_).replace(/\/+$/,"");return e.fetchImpl===void 0?{baseUrl:r,apiKey:t}:{baseUrl:r,apiKey:t,fetchImpl:e.fetchImpl}}function xi(e){return e.replace(/\bsmk_[A-Za-z0-9._-]+/g,"smk_[REDACTED]")}function Ls(e){return e.split("/").map(encodeURIComponent).join("/")}async function wn(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 d=new AbortController,l=r.timeoutMs??Bo,u=setTimeout(()=>d.abort(),l),s;try{s=await i(`${e.baseUrl}${t}`,{method:n,headers:o,body:a??null,signal:d.signal})}catch(p){throw p instanceof Error&&p.name==="AbortError"?new $e("TIMEOUT",`smolcloud ${n} ${t} timed out after ${l}ms`):new $e("CONNECTION",`smolcloud request failed: ${p instanceof Error?p.message:String(p)}`)}finally{clearTimeout(u)}if(!s.ok){let p=await s.text().catch(()=>""),f=s.status===404?"NOT_FOUND":s.status===401||s.status===403?"UNAUTHORIZED":"CLOUD_ERROR";throw new $e(f,`smolcloud ${n} ${t} \u2192 ${s.status}${p===""?"":`: ${p}`}`)}return r.accept==="bytes"?Buffer.from(await s.arrayBuffer()):s.status===204?void 0:(s.headers.get("content-type")??"").includes("application/json")?await s.json():void 0}async function*m_(e){let n=e.getReader(),t=new TextDecoder,r="",i="",o=[],a=()=>{let d=i,l=o.join(`
5
5
  `);if(i="",o=[],d==="stdout")return{kind:"stdout",data:l};if(d==="stderr")return{kind:"stderr",data:l};if(d==="error")return{kind:"error",message:xi(l)};if(d==="exit"){let u=0;try{u=JSON.parse(l).exitCode??0}catch{}return{kind:"exit",exitCode:u}}};try{for(;;){let{value:l,done:u}=await n.read();if(u)break;r+=t.decode(l,{stream:!0});let s;for(;(s=r.indexOf(`
6
6
  `))>=0;){let m=r.slice(0,s);r=r.slice(s+1);let p=m.endsWith("\r")?m.slice(0,-1):m;if(p===""){let f=a();f!==void 0&&(yield f)}else p.startsWith("event:")?i=p.slice(6).trim():p.startsWith("data:")&&o.push(p.slice(5).replace(/^ /,""))}}let d=a();d!==void 0&&(yield d)}finally{n.releaseLock()}}function p_(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 $e("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 Js(e,n){let t={name:n.name??null,source:p_(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 wn(e,"POST","/v1/machines",{json:t});if(r.id===void 0)throw new $e("CLOUD_ERROR","machine create returned no machine id");let i=new br(e,r.id);try{return await wn(e,"POST",`/v1/machines/${r.id}/start`).catch(()=>{}),await __(e,r.id),i}catch(o){throw await i.delete().catch(()=>{}),o}}async function __(e,n,t=c_,r=i=>new Promise(o=>setTimeout(o,i))){let i=Date.now()+t;for(;;){let o;try{o=(await wn(e,"GET",`/v1/machines/${n}`))?.state}catch(a){if(a instanceof $e&&(a.code==="UNAUTHORIZED"||a.code==="NOT_FOUND"))throw a}if(o==="started"||o==="running")return;if(o==="error")throw new $e("CLOUD_ERROR",`machine ${n} entered error state while starting`);if(Date.now()>=i)throw new $e("TIMEOUT",`machine ${n} not ready after ${t}ms (state=${o??"unknown"})`);await r(1e3)}}var u_,Bo,Ko,c_,$e,br,Wo=_(()=>{"use strict";vi();u_="https://api.smolmachines.com",Bo=3e4,Ko=3e4,c_=12e4;$e=class extends Error{code;constructor(n,t){super(xi(t)),this.code=n,this.name="SmolcloudError"}};br=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 wn(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(Bo,t.timeout*1e3+Ko):Bo,o=await wn(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+Ko):void 0,d;try{d=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 $e("TIMEOUT",`smolcloud exec/stream timed out after ${(t?.timeout??0)*1e3+Ko}ms`):new $e("CONNECTION",`smolcloud exec/stream failed: ${l instanceof Error?l.message:String(l)}`)}try{if(!d.ok){let l=await d.text().catch(()=>"");throw new $e(d.status===404?"NOT_FOUND":"CLOUD_ERROR",`smolcloud POST /v1/machines/${this.id}/exec/stream \u2192 ${d.status}${l===""?"":`: ${l}`}`)}if(d.body===null)throw new $e("CLOUD_ERROR","exec/stream returned no response body");yield*m_(d.body)}finally{a!==void 0&&clearTimeout(a)}}async readFile(n){return await wn(this.conn,"GET",`/v1/machines/${this.id}/files/${Ls(n)}`,{accept:"bytes"})}async writeFile(n,t,r){await wn(this.conn,"PUT",`/v1/machines/${this.id}/files/${Ls(n)}`,{body:typeof t=="string"?Buffer.from(t,"utf8"):t}),r!==void 0&&await this.exec(["chmod",r.toString(8),n])}async stop(){await wn(this.conn,"POST",`/v1/machines/${this.id}/stop`)}async delete(){await wn(this.conn,"DELETE",`/v1/machines/${this.id}`)}}});function Us(e){return`'${e.replaceAll("'",String.raw`'\''`)}'`}var Ho,Av,Ev,Pv,Ks=_(()=>{"use strict";Ho="/dev/shm/linzumi",Av=`${Ho}/codex`,Ev=`${Ho}/mcp-auth.json`,Pv=`${Ho}/codex.env`});function Vo(e){let n=e.replace(/[^A-Za-z0-9._-]/g,"_");return`${ln}/.linzumi-provisioned-${Bs}-${n}`}function Hs(e){return["/bin/sh","-c",["set -e",`mkdir -p ${ln} ${Sr} ${wi}`,`chmod 700 ${Sr} ${wi}`,"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@${Us(e)} >/dev/null`,`rm -f ${ln}/.linzumi-provisioned-${Bs}-* 2>/dev/null || true`,`touch ${Vo(e)}`,`touch ${nl}`].join(" && ")]}function Vs(e){return["/bin/sh","-c",`test -f ${Vo(e)} && command -v codex >/dev/null && command -v node >/dev/null && command -v bwrap >/dev/null && test -s ${Ws}`]}function Qs(e){return["/bin/sh","-c",`if test -f ${Vo(e)} && command -v codex >/dev/null && command -v node >/dev/null && command -v bwrap >/dev/null && test -s ${Ws}; then echo TOOLCHAIN_OK; else echo TOOLCHAIN_MISSING; fi; echo BUNDLE_SUP $(sha256sum ${ki} 2>/dev/null | cut -d' ' -f1); echo BUNDLE_MCP $(sha256sum ${Ti} 2>/dev/null | cut -d' ' -f1)`]}function Qo(){return["/bin/sh","-c",`rm -rf ${Sr} 2>/dev/null; true`]}function Yo(e){if(!g_.test(e))throw new Error(`invalid cloud turn nonce: ${JSON.stringify(e.slice(0,80))}`)}function Zs(e){return Yo(e),`${Zo}/${e}.beat`}function Ys(e){return Yo(e),`${Zo}/${e}.exit`}function Xs(e){let n=Ys(e),t=Zs(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 el(e){let n=Ys(e),t=Zs(e);return["/bin/sh","-c",`rm -f ${n} ${t} 2>/dev/null; true`]}var Bs,zs,ki,Ti,Sr,h_,wi,y_,Ws,Zo,g_,Xo=_(()=>{"use strict";ea();Ks();Bs="v1",zs=4500,ki=`${ln}/cloud-supervisor.mjs`,Ti=`${ln}/mcp-server.mjs`,Sr=`${ln}/.secrets`,h_=`${Sr}/mcp-auth.json`,wi=`${ln}/.codex`,y_=`${wi}/linzumi-thread-map.json`,Ws="/etc/ssl/certs/ca-certificates.crt";Zo=`${ln}/.turn-heartbeats`,g_=/^[A-Za-z0-9-]{8,64}$/});function tl(e){return Buffer.from(JSON.stringify(e),"utf8").toString("base64")}var Ci,rl,na=_(()=>{"use strict";Ci={mcpAuthFileContents:"LINZUMI_CLOUD_MCP_AUTH_JSON",llmProxyToken:"LINZUMI_CLOUD_LLM_PROXY_TOKEN"};rl="exit"});var il=_(()=>{});var ol=_(()=>{il()});var be=_(()=>{"use strict"});var Ai=_(()=>{"use strict";be()});var al=_(()=>{"use strict";Ai();be()});var kn=H((Kv,ll)=>{"use strict";var dl=["nodebuffer","arraybuffer","fragments"],sl=typeof Blob<"u";sl&&dl.push("blob");ll.exports={BINARY_TYPES:dl,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:sl,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var vr=H((Bv,Ei)=>{"use strict";var{EMPTY_BUFFER:x_}=kn(),ta=Buffer[Symbol.species];function w_(e,n){if(e.length===0)return x_;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 ta(t.buffer,t.byteOffset,r):t}function ul(e,n,t,r,i){for(let o=0;o<i;o++)t[r+o]=e[o]^n[o&3]}function cl(e,n){for(let t=0;t<e.length;t++)e[t]^=n[t&3]}function k_(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)}function ra(e){if(ra.readOnly=!0,Buffer.isBuffer(e))return e;let n;return e instanceof ArrayBuffer?n=new ta(e):ArrayBuffer.isView(e)?n=new ta(e.buffer,e.byteOffset,e.byteLength):(n=Buffer.from(e),ra.readOnly=!1),n}Ei.exports={concat:w_,mask:ul,toArrayBuffer:k_,toBuffer:ra,unmask:cl};if(!process.env.WS_NO_BUFFER_UTIL)try{let e=J("bufferutil");Ei.exports.mask=function(n,t,r,i,o){o<48?ul(n,t,r,i,o):e.mask(n,t,r,i,o)},Ei.exports.unmask=function(n,t){n.length<32?cl(n,t):e.unmask(n,t)}}catch{}});var pl=H((zv,ml)=>{"use strict";var fl=Symbol("kDone"),ia=Symbol("kRun"),oa=class{constructor(n){this[fl]=()=>{this.pending--,this[ia]()},this.concurrency=n||1/0,this.jobs=[],this.pending=0}add(n){this.jobs.push(n),this[ia]()}[ia](){if(this.pending!==this.concurrency&&this.jobs.length){let n=this.jobs.shift();this.pending++,n(this[fl])}}};ml.exports=oa});var wr=H((Wv,gl)=>{"use strict";var xr=J("zlib"),_l=vr(),T_=pl(),{kStatusCode:hl}=kn(),C_=Buffer[Symbol.species],A_=Buffer.from([0,0,255,255]),Oi=Symbol("permessage-deflate"),Tn=Symbol("total-length"),Nt=Symbol("callback"),Dn=Symbol("buffers"),Dt=Symbol("error"),Pi,aa=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,!Pi){let i=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Pi=new T_(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[Nt];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){Pi.add(i=>{this._decompress(n,t,(o,a)=>{i(),r(o,a)})})}compress(n,t,r){Pi.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"?xr.Z_DEFAULT_WINDOWBITS:this.params[o];this._inflate=xr.createInflateRaw({...this._options.zlibInflateOptions,windowBits:a}),this._inflate[Oi]=this,this._inflate[Tn]=0,this._inflate[Dn]=[],this._inflate.on("error",P_),this._inflate.on("data",yl)}this._inflate[Nt]=r,this._inflate.write(n),t&&this._inflate.write(A_),this._inflate.flush(()=>{let o=this._inflate[Dt];if(o){this._inflate.close(),this._inflate=null,r(o);return}let a=_l.concat(this._inflate[Dn],this._inflate[Tn]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Tn]=0,this._inflate[Dn]=[],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"?xr.Z_DEFAULT_WINDOWBITS:this.params[o];this._deflate=xr.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:a}),this._deflate[Tn]=0,this._deflate[Dn]=[],this._deflate.on("data",E_)}this._deflate[Nt]=r,this._deflate.write(n),this._deflate.flush(xr.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let o=_l.concat(this._deflate[Dn],this._deflate[Tn]);t&&(o=new C_(o.buffer,o.byteOffset,o.length-4)),this._deflate[Nt]=null,this._deflate[Tn]=0,this._deflate[Dn]=[],t&&this.params[`${i}_no_context_takeover`]&&this._deflate.reset(),r(null,o)})}};gl.exports=aa;function E_(e){this[Dn].push(e),this[Tn]+=e.length}function yl(e){if(this[Tn]+=e.length,this[Oi]._maxPayload<1||this[Tn]<=this[Oi]._maxPayload){this[Dn].push(e);return}this[Dt]=new RangeError("Max payload size exceeded"),this[Dt].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Dt][hl]=1009,this.removeListener("data",yl),this.reset()}function P_(e){if(this[Oi]._inflate=null,this[Dt]){this[Nt](this[Dt]);return}e[hl]=1007,this[Nt](e)}});var Lt=H((Hv,Ri)=>{"use strict";var{isUtf8:bl}=J("buffer"),{hasBlob:O_}=kn(),R_=[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 I_(e){return e>=1e3&&e<=1014&&e!==1004&&e!==1005&&e!==1006||e>=3e3&&e<=4999}function da(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 M_(e){return O_&&typeof e=="object"&&typeof e.arrayBuffer=="function"&&typeof e.type=="string"&&typeof e.stream=="function"&&(e[Symbol.toStringTag]==="Blob"||e[Symbol.toStringTag]==="File")}Ri.exports={isBlob:M_,isValidStatusCode:I_,isValidUTF8:da,tokenChars:R_};if(bl)Ri.exports.isValidUTF8=function(e){return e.length<24?da(e):bl(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let e=J("utf-8-validate");Ri.exports.isValidUTF8=function(n){return n.length<32?da(n):e(n)}}catch{}});var fa=H((Vv,Cl)=>{"use strict";var{Writable:q_}=J("stream"),Sl=wr(),{BINARY_TYPES:F_,EMPTY_BUFFER:vl,kStatusCode:j_,kWebSocket:$_}=kn(),{concat:sa,toArrayBuffer:G_,unmask:N_}=vr(),{isValidStatusCode:D_,isValidUTF8:xl}=Lt(),Ii=Buffer[Symbol.species],Ve=0,wl=1,kl=2,Tl=3,la=4,ua=5,Mi=6,ca=class extends q_{constructor(n={}){super(),this._allowSynchronousEvents=n.allowSynchronousEvents!==void 0?n.allowSynchronousEvents:!0,this._binaryType=n.binaryType||F_[0],this._extensions=n.extensions||{},this._isServer=!!n.isServer,this._maxPayload=n.maxPayload|0,this._skipUTF8Validation=!!n.skipUTF8Validation,this[$_]=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=Ve}_write(n,t,r){if(this._opcode===8&&this._state==Ve)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 Ii(r.buffer,r.byteOffset+n,r.length-n),new Ii(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 Ii(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 Ve:this.getInfo(n);break;case wl:this.getPayloadLength16(n);break;case kl:this.getPayloadLength64(n);break;case Tl:this.getMask();break;case la:this.getData(n);break;case ua:case Mi: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=wl:this._payloadLength===127?this._state=kl: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=Tl:this._state=la}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=la}getData(n){let t=vl;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&&N_(t,this._mask)}if(this._opcode>7){this.controlMessage(t,n);return}if(this._compressed){this._state=ua,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===Ve&&this.startLoop(t)})}dataMessage(n){if(!this._fin){this._state=Ve;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=sa(r,t):this._binaryType==="arraybuffer"?i=G_(sa(r,t)):this._binaryType==="blob"?i=new Blob(r):i=r,this._allowSynchronousEvents?(this.emit("message",i,!0),this._state=Ve):(this._state=Mi,setImmediate(()=>{this.emit("message",i,!0),this._state=Ve,this.startLoop(n)}))}else{let i=sa(r,t);if(!this._skipUTF8Validation&&!xl(i)){let o=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");n(o);return}this._state===ua||this._allowSynchronousEvents?(this.emit("message",i,!1),this._state=Ve):(this._state=Mi,setImmediate(()=>{this.emit("message",i,!1),this._state=Ve,this.startLoop(n)}))}}controlMessage(n,t){if(this._opcode===8){if(n.length===0)this._loop=!1,this.emit("conclude",1005,vl),this.end();else{let r=n.readUInt16BE(0);if(!D_(r)){let o=this.createError(RangeError,`invalid status code ${r}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");t(o);return}let i=new Ii(n.buffer,n.byteOffset+2,n.length-2);if(!this._skipUTF8Validation&&!xl(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=Ve;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",n),this._state=Ve):(this._state=Mi,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",n),this._state=Ve,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[j_]=i,a}};Cl.exports=ca});var _a=H((Zv,Pl)=>{"use strict";var{Duplex:Qv}=J("stream"),{randomFillSync:L_}=J("crypto"),Al=wr(),{EMPTY_BUFFER:J_,kWebSocket:U_,NOOP:K_}=kn(),{isBlob:Jt,isValidStatusCode:B_}=Lt(),{mask:El,toBuffer:lt}=vr(),Qe=Symbol("kByteLength"),z_=Buffer.alloc(4),qi=8*1024,ut,Ut=qi,nn=0,W_=1,H_=2,ma=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=nn,this.onerror=K_,this[U_]=void 0}static frame(n,t){let r,i=!1,o=2,a=!1;t.mask&&(r=t.maskBuffer||z_,t.generateMask?t.generateMask(r):(Ut===qi&&(ut===void 0&&(ut=Buffer.alloc(qi)),L_(ut,0,qi),Ut=0),r[0]=ut[Ut++],r[1]=ut[Ut++],r[2]=ut[Ut++],r[3]=ut[Ut++]),a=(r[0]|r[1]|r[2]|r[3])===0,o=6);let d;typeof n=="string"?(!t.mask||a)&&t[Qe]!==void 0?d=t[Qe]:(n=Buffer.from(n),d=n.length):(d=n.length,i=t.mask&&t.readOnly&&!a);let l=d;d>=65536?(o+=8,l=127):d>125&&(o+=2,l=126);let u=Buffer.allocUnsafe(i?d+o:o);return u[0]=t.fin?t.opcode|128:t.opcode,t.rsv1&&(u[0]|=64),u[1]=l,l===126?u.writeUInt16BE(d,2):l===127&&(u[2]=u[3]=0,u.writeUIntBE(d,4,6)),t.mask?(u[1]|=128,u[o-4]=r[0],u[o-3]=r[1],u[o-2]=r[2],u[o-1]=r[3],a?[u,n]:i?(El(n,r,u,o,d),[u]):(El(n,r,n,0,d),[u,n])):[u,n]}close(n,t,r,i){let o;if(n===void 0)o=J_;else{if(typeof n!="number"||!B_(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 d=Buffer.byteLength(t);if(d>123)throw new RangeError("The message must not be greater than 123 bytes");o=Buffer.allocUnsafe(2+d),o.writeUInt16BE(n,0),typeof t=="string"?o.write(t,2):o.set(t,2)}}let a={[Qe]:o.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==nn?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):Jt(n)?(i=n.size,o=!1):(n=lt(n),i=n.length,o=lt.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let a={[Qe]:i,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:o,rsv1:!1};Jt(n)?this._state!==nn?this.enqueue([this.getBlobData,n,!1,a,r]):this.getBlobData(n,!1,a,r):this._state!==nn?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):Jt(n)?(i=n.size,o=!1):(n=lt(n),i=n.length,o=lt.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let a={[Qe]:i,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:o,rsv1:!1};Jt(n)?this._state!==nn?this.enqueue([this.getBlobData,n,!1,a,r]):this.getBlobData(n,!1,a,r):this._state!==nn?this.enqueue([this.dispatch,n,!1,a,r]):this.sendFrame(e.frame(n,a),r)}send(n,t,r){let i=this._extensions[Al.extensionName],o=t.binary?2:1,a=t.compress,d,l;typeof n=="string"?(d=Buffer.byteLength(n),l=!1):Jt(n)?(d=n.size,l=!1):(n=lt(n),d=n.length,l=lt.readOnly),this._firstFragment?(this._firstFragment=!1,a&&i&&i.params[i._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(a=d>=i._threshold),this._compress=a):(a=!1,o=0),t.fin&&(this._firstFragment=!0);let u={[Qe]:d,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:o,readOnly:l,rsv1:a};Jt(n)?this._state!==nn?this.enqueue([this.getBlobData,n,this._compress,u,r]):this.getBlobData(n,this._compress,u,r):this._state!==nn?this.enqueue([this.dispatch,n,this._compress,u,r]):this.dispatch(n,this._compress,u,r)}getBlobData(n,t,r,i){this._bufferedBytes+=r[Qe],this._state=H_,n.arrayBuffer().then(o=>{if(this._socket.destroyed){let d=new Error("The socket was closed while the blob was being read");process.nextTick(pa,this,d,i);return}this._bufferedBytes-=r[Qe];let a=lt(o);t?this.dispatch(a,t,r,i):(this._state=nn,this.sendFrame(e.frame(a,r),i),this.dequeue())}).catch(o=>{process.nextTick(V_,this,o,i)})}dispatch(n,t,r,i){if(!t){this.sendFrame(e.frame(n,r),i);return}let o=this._extensions[Al.extensionName];this._bufferedBytes+=r[Qe],this._state=W_,o.compress(n,r.fin,(a,d)=>{if(this._socket.destroyed){let l=new Error("The socket was closed while data was being compressed");pa(this,l,i);return}this._bufferedBytes-=r[Qe],this._state=nn,r.readOnly=!1,this.sendFrame(e.frame(d,r),i),this.dequeue()})}dequeue(){for(;this._state===nn&&this._queue.length;){let n=this._queue.shift();this._bufferedBytes-=n[3][Qe],Reflect.apply(n[0],this,n.slice(1))}}enqueue(n){this._bufferedBytes+=n[3][Qe],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)}};Pl.exports=ma;function pa(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 V_(e,n,t){pa(e,n,t),e.onerror(n)}});var Gl=H((Yv,$l)=>{"use strict";var{kForOnEventAttribute:kr,kListener:ha}=kn(),Ol=Symbol("kCode"),Rl=Symbol("kData"),Il=Symbol("kError"),Ml=Symbol("kMessage"),ql=Symbol("kReason"),Kt=Symbol("kTarget"),Fl=Symbol("kType"),jl=Symbol("kWasClean"),Cn=class{constructor(n){this[Kt]=null,this[Fl]=n}get target(){return this[Kt]}get type(){return this[Fl]}};Object.defineProperty(Cn.prototype,"target",{enumerable:!0});Object.defineProperty(Cn.prototype,"type",{enumerable:!0});var ct=class extends Cn{constructor(n,t={}){super(n),this[Ol]=t.code===void 0?0:t.code,this[ql]=t.reason===void 0?"":t.reason,this[jl]=t.wasClean===void 0?!1:t.wasClean}get code(){return this[Ol]}get reason(){return this[ql]}get wasClean(){return this[jl]}};Object.defineProperty(ct.prototype,"code",{enumerable:!0});Object.defineProperty(ct.prototype,"reason",{enumerable:!0});Object.defineProperty(ct.prototype,"wasClean",{enumerable:!0});var Bt=class extends Cn{constructor(n,t={}){super(n),this[Il]=t.error===void 0?null:t.error,this[Ml]=t.message===void 0?"":t.message}get error(){return this[Il]}get message(){return this[Ml]}};Object.defineProperty(Bt.prototype,"error",{enumerable:!0});Object.defineProperty(Bt.prototype,"message",{enumerable:!0});var Tr=class extends Cn{constructor(n,t={}){super(n),this[Rl]=t.data===void 0?null:t.data}get data(){return this[Rl]}};Object.defineProperty(Tr.prototype,"data",{enumerable:!0});var Q_={addEventListener(e,n,t={}){for(let i of this.listeners(e))if(!t[kr]&&i[ha]===n&&!i[kr])return;let r;if(e==="message")r=function(o,a){let d=new Tr("message",{data:a?o:o.toString()});d[Kt]=this,Fi(n,this,d)};else if(e==="close")r=function(o,a){let d=new ct("close",{code:o,reason:a.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});d[Kt]=this,Fi(n,this,d)};else if(e==="error")r=function(o){let a=new Bt("error",{error:o,message:o.message});a[Kt]=this,Fi(n,this,a)};else if(e==="open")r=function(){let o=new Cn("open");o[Kt]=this,Fi(n,this,o)};else return;r[kr]=!!t[kr],r[ha]=n,t.once?this.once(e,r):this.on(e,r)},removeEventListener(e,n){for(let t of this.listeners(e))if(t[ha]===n&&!t[kr]){this.removeListener(e,t);break}}};$l.exports={CloseEvent:ct,ErrorEvent:Bt,Event:Cn,EventTarget:Q_,MessageEvent:Tr};function Fi(e,n,t){typeof e=="object"&&e.handleEvent?e.handleEvent.call(e,t):e.call(n,t)}});var ya=H((Xv,Nl)=>{"use strict";var{tokenChars:Cr}=Lt();function un(e,n,t){e[n]===void 0?e[n]=[t]:e[n].push(t)}function Z_(e){let n=Object.create(null),t=Object.create(null),r=!1,i=!1,o=!1,a,d,l=-1,u=-1,s=-1,m=0;for(;m<e.length;m++)if(u=e.charCodeAt(m),a===void 0)if(s===-1&&Cr[u]===1)l===-1&&(l=m);else if(m!==0&&(u===32||u===9))s===-1&&l!==-1&&(s=m);else if(u===59||u===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${m}`);s===-1&&(s=m);let f=e.slice(l,s);u===44?(un(n,f,t),t=Object.create(null)):a=f,l=s=-1}else throw new SyntaxError(`Unexpected character at index ${m}`);else if(d===void 0)if(s===-1&&Cr[u]===1)l===-1&&(l=m);else if(u===32||u===9)s===-1&&l!==-1&&(s=m);else if(u===59||u===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${m}`);s===-1&&(s=m),un(t,e.slice(l,s),!0),u===44&&(un(n,a,t),t=Object.create(null),a=void 0),l=s=-1}else if(u===61&&l!==-1&&s===-1)d=e.slice(l,m),l=s=-1;else throw new SyntaxError(`Unexpected character at index ${m}`);else if(i){if(Cr[u]!==1)throw new SyntaxError(`Unexpected character at index ${m}`);l===-1?l=m:r||(r=!0),i=!1}else if(o)if(Cr[u]===1)l===-1&&(l=m);else if(u===34&&l!==-1)o=!1,s=m;else if(u===92)i=!0;else throw new SyntaxError(`Unexpected character at index ${m}`);else if(u===34&&e.charCodeAt(m-1)===61)o=!0;else if(s===-1&&Cr[u]===1)l===-1&&(l=m);else if(l!==-1&&(u===32||u===9))s===-1&&(s=m);else if(u===59||u===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${m}`);s===-1&&(s=m);let f=e.slice(l,s);r&&(f=f.replace(/\\/g,""),r=!1),un(t,d,f),u===44&&(un(n,a,t),t=Object.create(null),a=void 0),d=void 0,l=s=-1}else throw new SyntaxError(`Unexpected character at index ${m}`);if(l===-1||o||u===32||u===9)throw new SyntaxError("Unexpected end of input");s===-1&&(s=m);let p=e.slice(l,s);return a===void 0?un(n,p,t):(d===void 0?un(t,p,!0):r?un(t,d,p.replace(/\\/g,"")):un(t,d,p),un(n,a,t)),n}function Y_(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(", ")}Nl.exports={format:Y_,parse:Z_}});var Ni=H((tx,Zl)=>{"use strict";var X_=J("events"),eh=J("https"),nh=J("http"),Jl=J("net"),th=J("tls"),{randomBytes:rh,createHash:ih}=J("crypto"),{Duplex:ex,Readable:nx}=J("stream"),{URL:ga}=J("url"),Ln=wr(),oh=fa(),ah=_a(),{isBlob:dh}=Lt(),{BINARY_TYPES:Dl,EMPTY_BUFFER:ji,GUID:sh,kForOnEventAttribute:ba,kListener:lh,kStatusCode:uh,kWebSocket:Ee,NOOP:Ul}=kn(),{EventTarget:{addEventListener:ch,removeEventListener:fh}}=Gl(),{format:mh,parse:ph}=ya(),{toBuffer:_h}=vr(),hh=30*1e3,Kl=Symbol("kAborted"),Sa=[8,13],An=["CONNECTING","OPEN","CLOSING","CLOSED"],yh=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,Z=class e extends X_{constructor(n,t,r){super(),this._binaryType=Dl[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=ji,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]),Bl(this,n,t,r)):(this._autoPong=r.autoPong,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(n){Dl.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 oh({allowSynchronousEvents:r.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation}),o=new ah(n,this._extensions,r.generateMask);this._receiver=i,this._sender=o,this._socket=n,i[Ee]=this,o[Ee]=this,n[Ee]=this,i.on("conclude",Sh),i.on("drain",vh),i.on("error",xh),i.on("message",wh),i.on("ping",kh),i.on("pong",Th),o.onerror=Ch,n.setTimeout&&n.setTimeout(0),n.setNoDelay&&n.setNoDelay(),t.length>0&&n.unshift(t),n.on("close",Hl),n.on("data",Gi),n.on("end",Vl),n.on("error",Ql),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[Ln.extensionName]&&this._extensions[Ln.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){Ue(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())}),Wl(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){va(this,n,r);return}t===void 0&&(t=!this._isServer),this._sender.ping(n||ji,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){va(this,n,r);return}t===void 0&&(t=!this._isServer),this._sender.pong(n||ji,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){va(this,n,r);return}let i={binary:typeof n!="string",mask:!this._isServer,compress:!0,fin:!0,...t};this._extensions[Ln.extensionName]||(i.compress=!1),this._sender.send(n||ji,i,r)}terminate(){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){Ue(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=e.CLOSING,this._socket.destroy())}}};Object.defineProperty(Z,"CONNECTING",{enumerable:!0,value:An.indexOf("CONNECTING")});Object.defineProperty(Z.prototype,"CONNECTING",{enumerable:!0,value:An.indexOf("CONNECTING")});Object.defineProperty(Z,"OPEN",{enumerable:!0,value:An.indexOf("OPEN")});Object.defineProperty(Z.prototype,"OPEN",{enumerable:!0,value:An.indexOf("OPEN")});Object.defineProperty(Z,"CLOSING",{enumerable:!0,value:An.indexOf("CLOSING")});Object.defineProperty(Z.prototype,"CLOSING",{enumerable:!0,value:An.indexOf("CLOSING")});Object.defineProperty(Z,"CLOSED",{enumerable:!0,value:An.indexOf("CLOSED")});Object.defineProperty(Z.prototype,"CLOSED",{enumerable:!0,value:An.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(e=>{Object.defineProperty(Z.prototype,e,{enumerable:!0})});["open","error","close","message"].forEach(e=>{Object.defineProperty(Z.prototype,`on${e}`,{enumerable:!0,get(){for(let n of this.listeners(e))if(n[ba])return n[lh];return null},set(n){for(let t of this.listeners(e))if(t[ba]){this.removeListener(e,t);break}typeof n=="function"&&this.addEventListener(e,n,{[ba]:!0})}})});Z.prototype.addEventListener=ch;Z.prototype.removeEventListener=fh;Zl.exports=Z;function Bl(e,n,t,r){let i={allowSynchronousEvents:!0,autoPong:!0,protocolVersion:Sa[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,!Sa.includes(i.protocolVersion))throw new RangeError(`Unsupported protocol version: ${i.protocolVersion} (supported versions: ${Sa.join(", ")})`);let o;if(n instanceof ga)o=n;else try{o=new ga(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:",d=o.protocol==="ws+unix:",l;if(o.protocol!=="ws:"&&!a&&!d?l=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:d&&!o.pathname?l="The URL's pathname is empty":o.hash&&(l="The URL contains a fragment identifier"),l){let c=new SyntaxError(l);if(e._redirects===0)throw c;$i(e,c);return}let u=a?443:80,s=rh(16).toString("base64"),m=a?eh.request:nh.request,p=new Set,f;if(i.createConnection=i.createConnection||(a?bh:gh),i.defaultPort=i.defaultPort||u,i.port=o.port||u,i.host=o.hostname.startsWith("[")?o.hostname.slice(1,-1):o.hostname,i.headers={...i.headers,"Sec-WebSocket-Version":i.protocolVersion,"Sec-WebSocket-Key":s,Connection:"Upgrade",Upgrade:"websocket"},i.path=o.pathname+o.search,i.timeout=i.handshakeTimeout,i.perMessageDeflate&&(f=new Ln(i.perMessageDeflate!==!0?i.perMessageDeflate:{},!1,i.maxPayload),i.headers["Sec-WebSocket-Extensions"]=mh({[Ln.extensionName]:f.offer()})),t.length){for(let c of t){if(typeof c!="string"||!yh.test(c)||p.has(c))throw new SyntaxError("An invalid or duplicated subprotocol was specified");p.add(c)}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}`),d){let c=i.path.split(":");i.socketPath=c[0],i.path=c[1]}let h;if(i.followRedirects){if(e._redirects===0){e._originalIpc=d,e._originalSecure=a,e._originalHostOrSocketPath=d?i.socketPath:o.host;let c=r&&r.headers;if(r={...r,headers:{}},c)for(let[y,b]of Object.entries(c))r.headers[y.toLowerCase()]=b}else if(e.listenerCount("redirect")===0){let c=d?e._originalIpc?i.socketPath===e._originalHostOrSocketPath:!1:e._originalIpc?!1:o.host===e._originalHostOrSocketPath;(!c||e._originalSecure&&!a)&&(delete i.headers.authorization,delete i.headers.cookie,c||delete i.headers.host,i.auth=void 0)}i.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(i.auth).toString("base64")),h=e._req=m(i),e._redirects&&e.emit("redirect",e.url,h)}else h=e._req=m(i);i.timeout&&h.on("timeout",()=>{Ue(e,h,"Opening handshake has timed out")}),h.on("error",c=>{h===null||h[Kl]||(h=e._req=null,$i(e,c))}),h.on("response",c=>{let y=c.headers.location,b=c.statusCode;if(y&&i.followRedirects&&b>=300&&b<400){if(++e._redirects>i.maxRedirects){Ue(e,h,"Maximum redirects exceeded");return}h.abort();let x;try{x=new ga(y,n)}catch{let g=new SyntaxError(`Invalid URL: ${y}`);$i(e,g);return}Bl(e,x,t,r)}else e.emit("unexpected-response",h,c)||Ue(e,h,`Unexpected server response: ${c.statusCode}`)}),h.on("upgrade",(c,y,b)=>{if(e.emit("upgrade",c),e.readyState!==Z.CONNECTING)return;h=e._req=null;let x=c.headers.upgrade;if(x===void 0||x.toLowerCase()!=="websocket"){Ue(e,y,"Invalid Upgrade header");return}let v=ih("sha1").update(s+sh).digest("base64");if(c.headers["sec-websocket-accept"]!==v){Ue(e,y,"Invalid Sec-WebSocket-Accept header");return}let g=c.headers["sec-websocket-protocol"],P;if(g!==void 0?p.size?p.has(g)||(P="Server sent an invalid subprotocol"):P="Server sent a subprotocol but none was requested":p.size&&(P="Server sent no subprotocol"),P){Ue(e,y,P);return}g&&(e._protocol=g);let O=c.headers["sec-websocket-extensions"];if(O!==void 0){if(!f){Ue(e,y,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let $;try{$=ph(O)}catch{Ue(e,y,"Invalid Sec-WebSocket-Extensions header");return}let oe=Object.keys($);if(oe.length!==1||oe[0]!==Ln.extensionName){Ue(e,y,"Server indicated an extension that was not requested");return}try{f.accept($[Ln.extensionName])}catch{Ue(e,y,"Invalid Sec-WebSocket-Extensions header");return}e._extensions[Ln.extensionName]=f}e.setSocket(y,b,{allowSynchronousEvents:i.allowSynchronousEvents,generateMask:i.generateMask,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation})}),i.finishRequest?i.finishRequest(h,e):h.end()}function $i(e,n){e._readyState=Z.CLOSING,e._errorEmitted=!0,e.emit("error",n),e.emitClose()}function gh(e){return e.path=e.socketPath,Jl.connect(e)}function bh(e){return e.path=void 0,!e.servername&&e.servername!==""&&(e.servername=Jl.isIP(e.host)?"":e.host),th.connect(e)}function Ue(e,n,t){e._readyState=Z.CLOSING;let r=new Error(t);Error.captureStackTrace(r,Ue),n.setHeader?(n[Kl]=!0,n.abort(),n.socket&&!n.socket.destroyed&&n.socket.destroy(),process.nextTick($i,e,r)):(n.destroy(r),n.once("error",e.emit.bind(e,"error")),n.once("close",e.emitClose.bind(e)))}function va(e,n,t){if(n){let r=dh(n)?n.size:_h(n).length;e._socket?e._sender._bufferedBytes+=r:e._bufferedAmount+=r}if(t){let r=new Error(`WebSocket is not open: readyState ${e.readyState} (${An[e.readyState]})`);process.nextTick(t,r)}}function Sh(e,n){let t=this[Ee];t._closeFrameReceived=!0,t._closeMessage=n,t._closeCode=e,t._socket[Ee]!==void 0&&(t._socket.removeListener("data",Gi),process.nextTick(zl,t._socket),e===1005?t.close():t.close(e,n))}function vh(){let e=this[Ee];e.isPaused||e._socket.resume()}function xh(e){let n=this[Ee];n._socket[Ee]!==void 0&&(n._socket.removeListener("data",Gi),process.nextTick(zl,n._socket),n.close(e[uh])),n._errorEmitted||(n._errorEmitted=!0,n.emit("error",e))}function Ll(){this[Ee].emitClose()}function wh(e,n){this[Ee].emit("message",e,n)}function kh(e){let n=this[Ee];n._autoPong&&n.pong(e,!this._isServer,Ul),n.emit("ping",e)}function Th(e){this[Ee].emit("pong",e)}function zl(e){e.resume()}function Ch(e){let n=this[Ee];n.readyState!==Z.CLOSED&&(n.readyState===Z.OPEN&&(n._readyState=Z.CLOSING,Wl(n)),this._socket.end(),n._errorEmitted||(n._errorEmitted=!0,n.emit("error",e)))}function Wl(e){e._closeTimer=setTimeout(e._socket.destroy.bind(e._socket),hh)}function Hl(){let e=this[Ee];this.removeListener("close",Hl),this.removeListener("data",Gi),this.removeListener("end",Vl),e._readyState=Z.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[Ee]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",Ll),e._receiver.on("finish",Ll))}function Gi(e){this[Ee]._receiver.write(e)||this.pause()}function Vl(){let e=this[Ee];e._readyState=Z.CLOSING,e._receiver.end(),this.end()}function Ql(){let e=this[Ee];this.removeListener("error",Ql),this.on("error",Ul),e&&(e._readyState=Z.CLOSING,this.destroy())}});var nu=H((ix,eu)=>{"use strict";var rx=Ni(),{Duplex:Ah}=J("stream");function Yl(e){e.emit("close")}function Eh(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Xl(e){this.removeListener("error",Xl),this.destroy(),this.listenerCount("error")===0&&this.emit("error",e)}function Ph(e,n){let t=!0,r=new Ah({...n,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on("message",function(o,a){let d=!a&&r._readableState.objectMode?o.toString():o;r.push(d)||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(Yl,r);return}let a=!1;e.once("error",function(l){a=!0,o(l)}),e.once("close",function(){a||o(i),process.nextTick(Yl,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",Eh),r.on("error",Xl),r}eu.exports=Ph});var ru=H((ox,tu)=>{"use strict";var{tokenChars:Oh}=Lt();function Rh(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&&Oh[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 d=e.slice(t,r);if(n.has(d))throw new SyntaxError(`The "${d}" subprotocol is duplicated`);n.add(d),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}tu.exports={parse:Rh}});var uu=H((dx,lu)=>{"use strict";var Ih=J("events"),Di=J("http"),{Duplex:ax}=J("stream"),{createHash:Mh}=J("crypto"),iu=ya(),ft=wr(),qh=ru(),Fh=Ni(),{GUID:jh,kWebSocket:$h}=kn(),Gh=/^[+/0-9A-Za-z]{22}==$/,ou=0,au=1,su=2,xa=class extends Ih{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:Fh,...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=Di.createServer((r,i)=>{let o=Di.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=Nh(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=ou}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===su){n&&this.once("close",()=>{n(new Error("The server is not running"))}),process.nextTick(Ar,this);return}if(n&&this.once("close",n),this._state!==au)if(this._state=au,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(Ar,this):process.nextTick(Ar,this);else{let t=this._server;this._removeListeners(),this._removeListeners=this._server=null,t.close(()=>{Ar(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",du);let o=n.headers["sec-websocket-key"],a=n.headers.upgrade,d=+n.headers["sec-websocket-version"];if(n.method!=="GET"){mt(this,n,t,405,"Invalid HTTP method");return}if(a===void 0||a.toLowerCase()!=="websocket"){mt(this,n,t,400,"Invalid Upgrade header");return}if(o===void 0||!Gh.test(o)){mt(this,n,t,400,"Missing or invalid Sec-WebSocket-Key header");return}if(d!==13&&d!==8){mt(this,n,t,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(n)){Er(t,400);return}let l=n.headers["sec-websocket-protocol"],u=new Set;if(l!==void 0)try{u=qh.parse(l)}catch{mt(this,n,t,400,"Invalid Sec-WebSocket-Protocol header");return}let s=n.headers["sec-websocket-extensions"],m={};if(this.options.perMessageDeflate&&s!==void 0){let p=new ft(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let f=iu.parse(s);f[ft.extensionName]&&(p.accept(f[ft.extensionName]),m[ft.extensionName]=p)}catch{mt(this,n,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let p={origin:n.headers[`${d===8?"sec-websocket-origin":"origin"}`],secure:!!(n.socket.authorized||n.socket.encrypted),req:n};if(this.options.verifyClient.length===2){this.options.verifyClient(p,(f,h,c,y)=>{if(!f)return Er(t,h||401,c,y);this.completeUpgrade(m,o,u,n,t,r,i)});return}if(!this.options.verifyClient(p))return Er(t,401)}this.completeUpgrade(m,o,u,n,t,r,i)}completeUpgrade(n,t,r,i,o,a,d){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>ou)return Er(o,503);let u=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Mh("sha1").update(t+jh).digest("base64")}`],s=new this.options.WebSocket(null,void 0,this.options);if(r.size){let m=this.options.handleProtocols?this.options.handleProtocols(r,i):r.values().next().value;m&&(u.push(`Sec-WebSocket-Protocol: ${m}`),s._protocol=m)}if(n[ft.extensionName]){let m=n[ft.extensionName].params,p=iu.format({[ft.extensionName]:[m]});u.push(`Sec-WebSocket-Extensions: ${p}`),s._extensions=n}this.emit("headers",u,i),o.write(u.concat(`\r
7
7
  `).join(`\r