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