@linzumi/cli 1.0.146 → 1.0.148
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/impl-res/cloud-supervisor.mjs +2 -2
- package/dist/impl-res/crossHarnessFailover.mjs +2 -2
- package/dist/impl-res/index.js +3 -3
- package/dist/impl-res/mcp-server.mjs +2 -2
- package/dist/impl-ts/cloud-supervisor.mjs +2 -2
- package/dist/impl-ts/crossHarnessFailover.mjs +2 -2
- package/dist/impl-ts/index.js +3 -3
- package/dist/impl-ts/mcp-server.mjs +2 -2
- package/dist/mcp-server.mjs +2 -2
- package/package.json +1 -1
- package/scripts/build.mjs +11 -1
- package/scripts/bump-cli-version.mjs +2 -2
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';
|
|
2
|
-
const require =
|
|
1
|
+
import { createRequire as __linzumiBundleCreateRequire } from 'node:module';
|
|
2
|
+
const require = __linzumiBundleCreateRequire(import.meta.url);
|
|
3
3
|
var lr=Object.create;var wn=Object.defineProperty;var ur=Object.getOwnPropertyDescriptor;var fr=Object.getOwnPropertyNames;var pr=Object.getPrototypeOf,gr=Object.prototype.hasOwnProperty;var E=(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 A=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports);var mr=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of fr(n))!gr.call(e,o)&&o!==t&&wn(e,o,{get:()=>n[o],enumerable:!(r=ur(n,o))||r.enumerable});return e};var fe=(e,n,t)=>(t=e!=null?lr(pr(e)):{},mr(n||!e||!e.__esModule?wn(t,"default",{value:e,enumerable:!0}):t,e));var F=A((Oi,On)=>{"use strict";var kn=["nodebuffer","arraybuffer","fragments"],Cn=typeof Blob<"u";Cn&&kn.push("blob");On.exports={BINARY_TYPES:kn,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:Cn,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var pe=A((Ei,Ce)=>{"use strict";var{EMPTY_BUFFER:hr}=F(),Ve=Buffer[Symbol.species];function yr(e,n){if(e.length===0)return hr;if(e.length===1)return e[0];let t=Buffer.allocUnsafe(n),r=0;for(let o=0;o<e.length;o++){let s=e[o];t.set(s,r),r+=s.length}return r<n?new Ve(t.buffer,t.byteOffset,r):t}function En(e,n,t,r,o){for(let s=0;s<o;s++)t[r+s]=e[s]^n[s&3]}function Pn(e,n){for(let t=0;t<e.length;t++)e[t]^=n[t&3]}function _r(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)}function Ge(e){if(Ge.readOnly=!0,Buffer.isBuffer(e))return e;let n;return e instanceof ArrayBuffer?n=new Ve(e):ArrayBuffer.isView(e)?n=new Ve(e.buffer,e.byteOffset,e.byteLength):(n=Buffer.from(e),Ge.readOnly=!1),n}Ce.exports={concat:yr,mask:En,toArrayBuffer:_r,toBuffer:Ge,unmask:Pn};if(!process.env.WS_NO_BUFFER_UTIL)try{let e=E("bufferutil");Ce.exports.mask=function(n,t,r,o,s){s<48?En(n,t,r,o,s):e.mask(n,t,r,o,s)},Ce.exports.unmask=function(n,t){n.length<32?Pn(n,t):e.unmask(n,t)}}catch{}});var An=A((Pi,In)=>{"use strict";var Tn=Symbol("kDone"),qe=Symbol("kRun"),Be=class{constructor(n){this[Tn]=()=>{this.pending--,this[qe]()},this.concurrency=n||1/0,this.jobs=[],this.pending=0}add(n){this.jobs.push(n),this[qe]()}[qe](){if(this.pending!==this.concurrency&&this.jobs.length){let n=this.jobs.shift();this.pending++,n(this[Tn])}}};In.exports=Be});var me=A((Ti,Nn)=>{"use strict";var ge=E("zlib"),Rn=pe(),xr=An(),{kStatusCode:Mn}=F(),br=Buffer[Symbol.species],vr=Buffer.from([0,0,255,255]),Ee=Symbol("permessage-deflate"),V=Symbol("total-length"),te=Symbol("callback"),B=Symbol("buffers"),re=Symbol("error"),Oe,We=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,!Oe){let o=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Oe=new xr(o)}}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[te];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(o=>!(t.serverNoContextTakeover===!1&&o.server_no_context_takeover||o.server_max_window_bits&&(t.serverMaxWindowBits===!1||typeof t.serverMaxWindowBits=="number"&&t.serverMaxWindowBits>o.server_max_window_bits)||typeof t.clientMaxWindowBits=="number"&&!o.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 o=t[r];if(o.length>1)throw new Error(`Parameter "${r}" must have only a single value`);if(o=o[0],r==="client_max_window_bits"){if(o!==!0){let s=+o;if(!Number.isInteger(s)||s<8||s>15)throw new TypeError(`Invalid value for parameter "${r}": ${o}`);o=s}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${r}": ${o}`)}else if(r==="server_max_window_bits"){let s=+o;if(!Number.isInteger(s)||s<8||s>15)throw new TypeError(`Invalid value for parameter "${r}": ${o}`);o=s}else if(r==="client_no_context_takeover"||r==="server_no_context_takeover"){if(o!==!0)throw new TypeError(`Invalid value for parameter "${r}": ${o}`)}else throw new Error(`Unknown parameter "${r}"`);t[r]=o})}),n}decompress(n,t,r){Oe.add(o=>{this._decompress(n,t,(s,i)=>{o(),r(s,i)})})}compress(n,t,r){Oe.add(o=>{this._compress(n,t,(s,i)=>{o(),r(s,i)})})}_decompress(n,t,r){let o=this._isServer?"client":"server";if(!this._inflate){let s=`${o}_max_window_bits`,i=typeof this.params[s]!="number"?ge.Z_DEFAULT_WINDOWBITS:this.params[s];this._inflate=ge.createInflateRaw({...this._options.zlibInflateOptions,windowBits:i}),this._inflate[Ee]=this,this._inflate[V]=0,this._inflate[B]=[],this._inflate.on("error",wr),this._inflate.on("data",jn)}this._inflate[te]=r,this._inflate.write(n),t&&this._inflate.write(vr),this._inflate.flush(()=>{let s=this._inflate[re];if(s){this._inflate.close(),this._inflate=null,r(s);return}let i=Rn.concat(this._inflate[B],this._inflate[V]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[V]=0,this._inflate[B]=[],t&&this.params[`${o}_no_context_takeover`]&&this._inflate.reset()),r(null,i)})}_compress(n,t,r){let o=this._isServer?"server":"client";if(!this._deflate){let s=`${o}_max_window_bits`,i=typeof this.params[s]!="number"?ge.Z_DEFAULT_WINDOWBITS:this.params[s];this._deflate=ge.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:i}),this._deflate[V]=0,this._deflate[B]=[],this._deflate.on("data",Sr)}this._deflate[te]=r,this._deflate.write(n),this._deflate.flush(ge.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let s=Rn.concat(this._deflate[B],this._deflate[V]);t&&(s=new br(s.buffer,s.byteOffset,s.length-4)),this._deflate[te]=null,this._deflate[V]=0,this._deflate[B]=[],t&&this.params[`${o}_no_context_takeover`]&&this._deflate.reset(),r(null,s)})}};Nn.exports=We;function Sr(e){this[B].push(e),this[V]+=e.length}function jn(e){if(this[V]+=e.length,this[Ee]._maxPayload<1||this[V]<=this[Ee]._maxPayload){this[B].push(e);return}this[re]=new RangeError("Max payload size exceeded"),this[re].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[re][Mn]=1009,this.removeListener("data",jn),this.reset()}function wr(e){if(this[Ee]._inflate=null,this[re]){this[te](this[re]);return}e[Mn]=1007,this[te](e)}});var oe=A((Ii,Pe)=>{"use strict";var{isUtf8:Ln}=E("buffer"),{hasBlob:kr}=F(),Cr=[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 Or(e){return e>=1e3&&e<=1014&&e!==1004&&e!==1005&&e!==1006||e>=3e3&&e<=4999}function Ke(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 Er(e){return kr&&typeof e=="object"&&typeof e.arrayBuffer=="function"&&typeof e.type=="string"&&typeof e.stream=="function"&&(e[Symbol.toStringTag]==="Blob"||e[Symbol.toStringTag]==="File")}Pe.exports={isBlob:Er,isValidStatusCode:Or,isValidUTF8:Ke,tokenChars:Cr};if(Ln)Pe.exports.isValidUTF8=function(e){return e.length<24?Ke(e):Ln(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let e=E("utf-8-validate");Pe.exports.isValidUTF8=function(n){return n.length<32?Ke(n):e(n)}}catch{}});var Qe=A((Ai,Vn)=>{"use strict";var{Writable:Pr}=E("stream"),Jn=me(),{BINARY_TYPES:Tr,EMPTY_BUFFER:$n,kStatusCode:Ir,kWebSocket:Ar}=F(),{concat:He,toArrayBuffer:Rr,unmask:Mr}=pe(),{isValidStatusCode:jr,isValidUTF8:Un}=oe(),Te=Buffer[Symbol.species],j=0,Dn=1,zn=2,Fn=3,Ze=4,Xe=5,Ie=6,Ye=class extends Pr{constructor(n={}){super(),this._allowSynchronousEvents=n.allowSynchronousEvents!==void 0?n.allowSynchronousEvents:!0,this._binaryType=n.binaryType||Tr[0],this._extensions=n.extensions||{},this._isServer=!!n.isServer,this._maxPayload=n.maxPayload|0,this._skipUTF8Validation=!!n.skipUTF8Validation,this[Ar]=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=j}_write(n,t,r){if(this._opcode===8&&this._state==j)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 Te(r.buffer,r.byteOffset+n,r.length-n),new Te(r.buffer,r.byteOffset,n)}let t=Buffer.allocUnsafe(n);do{let r=this._buffers[0],o=t.length-n;n>=r.length?t.set(this._buffers.shift(),o):(t.set(new Uint8Array(r.buffer,r.byteOffset,n),o),this._buffers[0]=new Te(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 j:this.getInfo(n);break;case Dn:this.getPayloadLength16(n);break;case zn:this.getPayloadLength64(n);break;case Fn:this.getMask();break;case Ze:this.getData(n);break;case Xe:case Ie: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 o=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");n(o);return}let r=(t[0]&64)===64;if(r&&!this._extensions[Jn.extensionName]){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");n(o);return}if(this._fin=(t[0]&128)===128,this._opcode=t[0]&15,this._payloadLength=t[1]&127,this._opcode===0){if(r){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");n(o);return}if(!this._fragmented){let o=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");n(o);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let o=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");n(o);return}this._compressed=r}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let o=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");n(o);return}if(r){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");n(o);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let o=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");n(o);return}}else{let o=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");n(o);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(t[1]&128)===128,this._isServer){if(!this._masked){let o=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");n(o);return}}else if(this._masked){let o=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");n(o);return}this._payloadLength===126?this._state=Dn:this._payloadLength===127?this._state=zn: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 o=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");n(o);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=Fn:this._state=Ze}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Ze}getData(n){let t=$n;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&&Mr(t,this._mask)}if(this._opcode>7){this.controlMessage(t,n);return}if(this._compressed){this._state=Xe,this.decompress(t,n);return}t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage(n)}decompress(n,t){this._extensions[Jn.extensionName].decompress(n,this._fin,(o,s)=>{if(o)return t(o);if(s.length){if(this._messageLength+=s.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let i=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");t(i);return}this._fragments.push(s)}this.dataMessage(t),this._state===j&&this.startLoop(t)})}dataMessage(n){if(!this._fin){this._state=j;return}let t=this._messageLength,r=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let o;this._binaryType==="nodebuffer"?o=He(r,t):this._binaryType==="arraybuffer"?o=Rr(He(r,t)):this._binaryType==="blob"?o=new Blob(r):o=r,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=j):(this._state=Ie,setImmediate(()=>{this.emit("message",o,!0),this._state=j,this.startLoop(n)}))}else{let o=He(r,t);if(!this._skipUTF8Validation&&!Un(o)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");n(s);return}this._state===Xe||this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=j):(this._state=Ie,setImmediate(()=>{this.emit("message",o,!1),this._state=j,this.startLoop(n)}))}}controlMessage(n,t){if(this._opcode===8){if(n.length===0)this._loop=!1,this.emit("conclude",1005,$n),this.end();else{let r=n.readUInt16BE(0);if(!jr(r)){let s=this.createError(RangeError,`invalid status code ${r}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");t(s);return}let o=new Te(n.buffer,n.byteOffset+2,n.length-2);if(!this._skipUTF8Validation&&!Un(o)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");t(s);return}this._loop=!1,this.emit("conclude",r,o),this.end()}this._state=j;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",n),this._state=j):(this._state=Ie,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",n),this._state=j,this.startLoop(t)}))}createError(n,t,r,o,s){this._loop=!1,this._errored=!0;let i=new n(r?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(i,this.createError),i.code=s,i[Ir]=o,i}};Vn.exports=Ye});var tn=A((Mi,Bn)=>{"use strict";var{Duplex:Ri}=E("stream"),{randomFillSync:Nr}=E("crypto"),Gn=me(),{EMPTY_BUFFER:Lr,kWebSocket:Jr,NOOP:$r}=F(),{isBlob:se,isValidStatusCode:Ur}=oe(),{mask:qn,toBuffer:H}=pe(),N=Symbol("kByteLength"),Dr=Buffer.alloc(4),Ae=8*1024,Z,ie=Ae,J=0,zr=1,Fr=2,en=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=J,this.onerror=$r,this[Jr]=void 0}static frame(n,t){let r,o=!1,s=2,i=!1;t.mask&&(r=t.maskBuffer||Dr,t.generateMask?t.generateMask(r):(ie===Ae&&(Z===void 0&&(Z=Buffer.alloc(Ae)),Nr(Z,0,Ae),ie=0),r[0]=Z[ie++],r[1]=Z[ie++],r[2]=Z[ie++],r[3]=Z[ie++]),i=(r[0]|r[1]|r[2]|r[3])===0,s=6);let a;typeof n=="string"?(!t.mask||i)&&t[N]!==void 0?a=t[N]:(n=Buffer.from(n),a=n.length):(a=n.length,o=t.mask&&t.readOnly&&!i);let c=a;a>=65536?(s+=8,c=127):a>125&&(s+=2,c=126);let d=Buffer.allocUnsafe(o?a+s:s);return d[0]=t.fin?t.opcode|128:t.opcode,t.rsv1&&(d[0]|=64),d[1]=c,c===126?d.writeUInt16BE(a,2):c===127&&(d[2]=d[3]=0,d.writeUIntBE(a,4,6)),t.mask?(d[1]|=128,d[s-4]=r[0],d[s-3]=r[1],d[s-2]=r[2],d[s-1]=r[3],i?[d,n]:o?(qn(n,r,d,s,a),[d]):(qn(n,r,n,0,a),[d,n])):[d,n]}close(n,t,r,o){let s;if(n===void 0)s=Lr;else{if(typeof n!="number"||!Ur(n))throw new TypeError("First argument must be a valid error code number");if(t===void 0||!t.length)s=Buffer.allocUnsafe(2),s.writeUInt16BE(n,0);else{let a=Buffer.byteLength(t);if(a>123)throw new RangeError("The message must not be greater than 123 bytes");s=Buffer.allocUnsafe(2+a),s.writeUInt16BE(n,0),typeof t=="string"?s.write(t,2):s.set(t,2)}}let i={[N]:s.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==J?this.enqueue([this.dispatch,s,!1,i,o]):this.sendFrame(e.frame(s,i),o)}ping(n,t,r){let o,s;if(typeof n=="string"?(o=Buffer.byteLength(n),s=!1):se(n)?(o=n.size,s=!1):(n=H(n),o=n.length,s=H.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let i={[N]:o,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:s,rsv1:!1};se(n)?this._state!==J?this.enqueue([this.getBlobData,n,!1,i,r]):this.getBlobData(n,!1,i,r):this._state!==J?this.enqueue([this.dispatch,n,!1,i,r]):this.sendFrame(e.frame(n,i),r)}pong(n,t,r){let o,s;if(typeof n=="string"?(o=Buffer.byteLength(n),s=!1):se(n)?(o=n.size,s=!1):(n=H(n),o=n.length,s=H.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let i={[N]:o,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:s,rsv1:!1};se(n)?this._state!==J?this.enqueue([this.getBlobData,n,!1,i,r]):this.getBlobData(n,!1,i,r):this._state!==J?this.enqueue([this.dispatch,n,!1,i,r]):this.sendFrame(e.frame(n,i),r)}send(n,t,r){let o=this._extensions[Gn.extensionName],s=t.binary?2:1,i=t.compress,a,c;typeof n=="string"?(a=Buffer.byteLength(n),c=!1):se(n)?(a=n.size,c=!1):(n=H(n),a=n.length,c=H.readOnly),this._firstFragment?(this._firstFragment=!1,i&&o&&o.params[o._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(i=a>=o._threshold),this._compress=i):(i=!1,s=0),t.fin&&(this._firstFragment=!0);let d={[N]:a,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:s,readOnly:c,rsv1:i};se(n)?this._state!==J?this.enqueue([this.getBlobData,n,this._compress,d,r]):this.getBlobData(n,this._compress,d,r):this._state!==J?this.enqueue([this.dispatch,n,this._compress,d,r]):this.dispatch(n,this._compress,d,r)}getBlobData(n,t,r,o){this._bufferedBytes+=r[N],this._state=Fr,n.arrayBuffer().then(s=>{if(this._socket.destroyed){let a=new Error("The socket was closed while the blob was being read");process.nextTick(nn,this,a,o);return}this._bufferedBytes-=r[N];let i=H(s);t?this.dispatch(i,t,r,o):(this._state=J,this.sendFrame(e.frame(i,r),o),this.dequeue())}).catch(s=>{process.nextTick(Vr,this,s,o)})}dispatch(n,t,r,o){if(!t){this.sendFrame(e.frame(n,r),o);return}let s=this._extensions[Gn.extensionName];this._bufferedBytes+=r[N],this._state=zr,s.compress(n,r.fin,(i,a)=>{if(this._socket.destroyed){let c=new Error("The socket was closed while data was being compressed");nn(this,c,o);return}this._bufferedBytes-=r[N],this._state=J,r.readOnly=!1,this.sendFrame(e.frame(a,r),o),this.dequeue()})}dequeue(){for(;this._state===J&&this._queue.length;){let n=this._queue.shift();this._bufferedBytes-=n[3][N],Reflect.apply(n[0],this,n.slice(1))}}enqueue(n){this._bufferedBytes+=n[3][N],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)}};Bn.exports=en;function nn(e,n,t){typeof t=="function"&&t(n);for(let r=0;r<e._queue.length;r++){let o=e._queue[r],s=o[o.length-1];typeof s=="function"&&s(n)}}function Vr(e,n,t){nn(e,n,t),e.onerror(n)}});var nt=A((ji,et)=>{"use strict";var{kForOnEventAttribute:he,kListener:rn}=F(),Wn=Symbol("kCode"),Kn=Symbol("kData"),Hn=Symbol("kError"),Zn=Symbol("kMessage"),Xn=Symbol("kReason"),ae=Symbol("kTarget"),Yn=Symbol("kType"),Qn=Symbol("kWasClean"),G=class{constructor(n){this[ae]=null,this[Yn]=n}get target(){return this[ae]}get type(){return this[Yn]}};Object.defineProperty(G.prototype,"target",{enumerable:!0});Object.defineProperty(G.prototype,"type",{enumerable:!0});var X=class extends G{constructor(n,t={}){super(n),this[Wn]=t.code===void 0?0:t.code,this[Xn]=t.reason===void 0?"":t.reason,this[Qn]=t.wasClean===void 0?!1:t.wasClean}get code(){return this[Wn]}get reason(){return this[Xn]}get wasClean(){return this[Qn]}};Object.defineProperty(X.prototype,"code",{enumerable:!0});Object.defineProperty(X.prototype,"reason",{enumerable:!0});Object.defineProperty(X.prototype,"wasClean",{enumerable:!0});var de=class extends G{constructor(n,t={}){super(n),this[Hn]=t.error===void 0?null:t.error,this[Zn]=t.message===void 0?"":t.message}get error(){return this[Hn]}get message(){return this[Zn]}};Object.defineProperty(de.prototype,"error",{enumerable:!0});Object.defineProperty(de.prototype,"message",{enumerable:!0});var ye=class extends G{constructor(n,t={}){super(n),this[Kn]=t.data===void 0?null:t.data}get data(){return this[Kn]}};Object.defineProperty(ye.prototype,"data",{enumerable:!0});var Gr={addEventListener(e,n,t={}){for(let o of this.listeners(e))if(!t[he]&&o[rn]===n&&!o[he])return;let r;if(e==="message")r=function(s,i){let a=new ye("message",{data:i?s:s.toString()});a[ae]=this,Re(n,this,a)};else if(e==="close")r=function(s,i){let a=new X("close",{code:s,reason:i.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});a[ae]=this,Re(n,this,a)};else if(e==="error")r=function(s){let i=new de("error",{error:s,message:s.message});i[ae]=this,Re(n,this,i)};else if(e==="open")r=function(){let s=new G("open");s[ae]=this,Re(n,this,s)};else return;r[he]=!!t[he],r[rn]=n,t.once?this.once(e,r):this.on(e,r)},removeEventListener(e,n){for(let t of this.listeners(e))if(t[rn]===n&&!t[he]){this.removeListener(e,t);break}}};et.exports={CloseEvent:X,ErrorEvent:de,Event:G,EventTarget:Gr,MessageEvent:ye};function Re(e,n,t){typeof e=="object"&&e.handleEvent?e.handleEvent.call(e,t):e.call(n,t)}});var on=A((Ni,tt)=>{"use strict";var{tokenChars:_e}=oe();function U(e,n,t){e[n]===void 0?e[n]=[t]:e[n].push(t)}function qr(e){let n=Object.create(null),t=Object.create(null),r=!1,o=!1,s=!1,i,a,c=-1,d=-1,f=-1,p=0;for(;p<e.length;p++)if(d=e.charCodeAt(p),i===void 0)if(f===-1&&_e[d]===1)c===-1&&(c=p);else if(p!==0&&(d===32||d===9))f===-1&&c!==-1&&(f=p);else if(d===59||d===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${p}`);f===-1&&(f=p);let u=e.slice(c,f);d===44?(U(n,u,t),t=Object.create(null)):i=u,c=f=-1}else throw new SyntaxError(`Unexpected character at index ${p}`);else if(a===void 0)if(f===-1&&_e[d]===1)c===-1&&(c=p);else if(d===32||d===9)f===-1&&c!==-1&&(f=p);else if(d===59||d===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${p}`);f===-1&&(f=p),U(t,e.slice(c,f),!0),d===44&&(U(n,i,t),t=Object.create(null),i=void 0),c=f=-1}else if(d===61&&c!==-1&&f===-1)a=e.slice(c,p),c=f=-1;else throw new SyntaxError(`Unexpected character at index ${p}`);else if(o){if(_e[d]!==1)throw new SyntaxError(`Unexpected character at index ${p}`);c===-1?c=p:r||(r=!0),o=!1}else if(s)if(_e[d]===1)c===-1&&(c=p);else if(d===34&&c!==-1)s=!1,f=p;else if(d===92)o=!0;else throw new SyntaxError(`Unexpected character at index ${p}`);else if(d===34&&e.charCodeAt(p-1)===61)s=!0;else if(f===-1&&_e[d]===1)c===-1&&(c=p);else if(c!==-1&&(d===32||d===9))f===-1&&(f=p);else if(d===59||d===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${p}`);f===-1&&(f=p);let u=e.slice(c,f);r&&(u=u.replace(/\\/g,""),r=!1),U(t,a,u),d===44&&(U(n,i,t),t=Object.create(null),i=void 0),a=void 0,c=f=-1}else throw new SyntaxError(`Unexpected character at index ${p}`);if(c===-1||s||d===32||d===9)throw new SyntaxError("Unexpected end of input");f===-1&&(f=p);let y=e.slice(c,f);return i===void 0?U(n,y,t):(a===void 0?U(t,y,!0):r?U(t,a,y.replace(/\\/g,"")):U(t,a,y),U(n,i,t)),n}function Br(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(o=>{let s=r[o];return Array.isArray(s)||(s=[s]),s.map(i=>i===!0?o:`${o}=${i}`).join("; ")})).join("; ")).join(", ")}).join(", ")}tt.exports={format:Br,parse:qr}});var Le=A(($i,gt)=>{"use strict";var Wr=E("events"),Kr=E("https"),Hr=E("http"),st=E("net"),Zr=E("tls"),{randomBytes:Xr,createHash:Yr}=E("crypto"),{Duplex:Li,Readable:Ji}=E("stream"),{URL:sn}=E("url"),W=me(),Qr=Qe(),eo=tn(),{isBlob:no}=oe(),{BINARY_TYPES:rt,EMPTY_BUFFER:Me,GUID:to,kForOnEventAttribute:an,kListener:ro,kStatusCode:oo,kWebSocket:P,NOOP:it}=F(),{EventTarget:{addEventListener:so,removeEventListener:io}}=nt(),{format:ao,parse:co}=on(),{toBuffer:lo}=pe(),uo=30*1e3,at=Symbol("kAborted"),dn=[8,13],q=["CONNECTING","OPEN","CLOSING","CLOSED"],fo=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,C=class e extends Wr{constructor(n,t,r){super(),this._binaryType=rt[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Me,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]),dt(this,n,t,r)):(this._autoPong=r.autoPong,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(n){rt.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 o=new Qr({allowSynchronousEvents:r.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation}),s=new eo(n,this._extensions,r.generateMask);this._receiver=o,this._sender=s,this._socket=n,o[P]=this,s[P]=this,n[P]=this,o.on("conclude",mo),o.on("drain",ho),o.on("error",yo),o.on("message",_o),o.on("ping",xo),o.on("pong",bo),s.onerror=vo,n.setTimeout&&n.setTimeout(0),n.setNoDelay&&n.setNoDelay(),t.length>0&&n.unshift(t),n.on("close",ut),n.on("data",Ne),n.on("end",ft),n.on("error",pt),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[W.extensionName]&&this._extensions[W.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){R(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())}),lt(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){cn(this,n,r);return}t===void 0&&(t=!this._isServer),this._sender.ping(n||Me,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){cn(this,n,r);return}t===void 0&&(t=!this._isServer),this._sender.pong(n||Me,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){cn(this,n,r);return}let o={binary:typeof n!="string",mask:!this._isServer,compress:!0,fin:!0,...t};this._extensions[W.extensionName]||(o.compress=!1),this._sender.send(n||Me,o,r)}terminate(){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){R(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=e.CLOSING,this._socket.destroy())}}};Object.defineProperty(C,"CONNECTING",{enumerable:!0,value:q.indexOf("CONNECTING")});Object.defineProperty(C.prototype,"CONNECTING",{enumerable:!0,value:q.indexOf("CONNECTING")});Object.defineProperty(C,"OPEN",{enumerable:!0,value:q.indexOf("OPEN")});Object.defineProperty(C.prototype,"OPEN",{enumerable:!0,value:q.indexOf("OPEN")});Object.defineProperty(C,"CLOSING",{enumerable:!0,value:q.indexOf("CLOSING")});Object.defineProperty(C.prototype,"CLOSING",{enumerable:!0,value:q.indexOf("CLOSING")});Object.defineProperty(C,"CLOSED",{enumerable:!0,value:q.indexOf("CLOSED")});Object.defineProperty(C.prototype,"CLOSED",{enumerable:!0,value:q.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(e=>{Object.defineProperty(C.prototype,e,{enumerable:!0})});["open","error","close","message"].forEach(e=>{Object.defineProperty(C.prototype,`on${e}`,{enumerable:!0,get(){for(let n of this.listeners(e))if(n[an])return n[ro];return null},set(n){for(let t of this.listeners(e))if(t[an]){this.removeListener(e,t);break}typeof n=="function"&&this.addEventListener(e,n,{[an]:!0})}})});C.prototype.addEventListener=so;C.prototype.removeEventListener=io;gt.exports=C;function dt(e,n,t,r){let o={allowSynchronousEvents:!0,autoPong:!0,protocolVersion:dn[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=o.autoPong,!dn.includes(o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${dn.join(", ")})`);let s;if(n instanceof sn)s=n;else try{s=new sn(n)}catch{throw new SyntaxError(`Invalid URL: ${n}`)}s.protocol==="http:"?s.protocol="ws:":s.protocol==="https:"&&(s.protocol="wss:"),e._url=s.href;let i=s.protocol==="wss:",a=s.protocol==="ws+unix:",c;if(s.protocol!=="ws:"&&!i&&!a?c=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:a&&!s.pathname?c="The URL's pathname is empty":s.hash&&(c="The URL contains a fragment identifier"),c){let l=new SyntaxError(c);if(e._redirects===0)throw l;je(e,l);return}let d=i?443:80,f=Xr(16).toString("base64"),p=i?Kr.request:Hr.request,y=new Set,u;if(o.createConnection=o.createConnection||(i?go:po),o.defaultPort=o.defaultPort||d,o.port=s.port||d,o.host=s.hostname.startsWith("[")?s.hostname.slice(1,-1):s.hostname,o.headers={...o.headers,"Sec-WebSocket-Version":o.protocolVersion,"Sec-WebSocket-Key":f,Connection:"Upgrade",Upgrade:"websocket"},o.path=s.pathname+s.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&(u=new W(o.perMessageDeflate!==!0?o.perMessageDeflate:{},!1,o.maxPayload),o.headers["Sec-WebSocket-Extensions"]=ao({[W.extensionName]:u.offer()})),t.length){for(let l of t){if(typeof l!="string"||!fo.test(l)||y.has(l))throw new SyntaxError("An invalid or duplicated subprotocol was specified");y.add(l)}o.headers["Sec-WebSocket-Protocol"]=t.join(",")}if(o.origin&&(o.protocolVersion<13?o.headers["Sec-WebSocket-Origin"]=o.origin:o.headers.Origin=o.origin),(s.username||s.password)&&(o.auth=`${s.username}:${s.password}`),a){let l=o.path.split(":");o.socketPath=l[0],o.path=l[1]}let g;if(o.followRedirects){if(e._redirects===0){e._originalIpc=a,e._originalSecure=i,e._originalHostOrSocketPath=a?o.socketPath:s.host;let l=r&&r.headers;if(r={...r,headers:{}},l)for(let[x,O]of Object.entries(l))r.headers[x.toLowerCase()]=O}else if(e.listenerCount("redirect")===0){let l=a?e._originalIpc?o.socketPath===e._originalHostOrSocketPath:!1:e._originalIpc?!1:s.host===e._originalHostOrSocketPath;(!l||e._originalSecure&&!i)&&(delete o.headers.authorization,delete o.headers.cookie,l||delete o.headers.host,o.auth=void 0)}o.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")),g=e._req=p(o),e._redirects&&e.emit("redirect",e.url,g)}else g=e._req=p(o);o.timeout&&g.on("timeout",()=>{R(e,g,"Opening handshake has timed out")}),g.on("error",l=>{g===null||g[at]||(g=e._req=null,je(e,l))}),g.on("response",l=>{let x=l.headers.location,O=l.statusCode;if(x&&o.followRedirects&&O>=300&&O<400){if(++e._redirects>o.maxRedirects){R(e,g,"Maximum redirects exceeded");return}g.abort();let M;try{M=new sn(x,n)}catch{let v=new SyntaxError(`Invalid URL: ${x}`);je(e,v);return}dt(e,M,t,r)}else e.emit("unexpected-response",g,l)||R(e,g,`Unexpected server response: ${l.statusCode}`)}),g.on("upgrade",(l,x,O)=>{if(e.emit("upgrade",l),e.readyState!==C.CONNECTING)return;g=e._req=null;let M=l.headers.upgrade;if(M===void 0||M.toLowerCase()!=="websocket"){R(e,x,"Invalid Upgrade header");return}let L=Yr("sha1").update(f+to).digest("base64");if(l.headers["sec-websocket-accept"]!==L){R(e,x,"Invalid Sec-WebSocket-Accept header");return}let v=l.headers["sec-websocket-protocol"],h;if(v!==void 0?y.size?y.has(v)||(h="Server sent an invalid subprotocol"):h="Server sent a subprotocol but none was requested":y.size&&(h="Server sent no subprotocol"),h){R(e,x,h);return}v&&(e._protocol=v);let S=l.headers["sec-websocket-extensions"];if(S!==void 0){if(!u){R(e,x,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let k;try{k=co(S)}catch{R(e,x,"Invalid Sec-WebSocket-Extensions header");return}let b=Object.keys(k);if(b.length!==1||b[0]!==W.extensionName){R(e,x,"Server indicated an extension that was not requested");return}try{u.accept(k[W.extensionName])}catch{R(e,x,"Invalid Sec-WebSocket-Extensions header");return}e._extensions[W.extensionName]=u}e.setSocket(x,O,{allowSynchronousEvents:o.allowSynchronousEvents,generateMask:o.generateMask,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(g,e):g.end()}function je(e,n){e._readyState=C.CLOSING,e._errorEmitted=!0,e.emit("error",n),e.emitClose()}function po(e){return e.path=e.socketPath,st.connect(e)}function go(e){return e.path=void 0,!e.servername&&e.servername!==""&&(e.servername=st.isIP(e.host)?"":e.host),Zr.connect(e)}function R(e,n,t){e._readyState=C.CLOSING;let r=new Error(t);Error.captureStackTrace(r,R),n.setHeader?(n[at]=!0,n.abort(),n.socket&&!n.socket.destroyed&&n.socket.destroy(),process.nextTick(je,e,r)):(n.destroy(r),n.once("error",e.emit.bind(e,"error")),n.once("close",e.emitClose.bind(e)))}function cn(e,n,t){if(n){let r=no(n)?n.size:lo(n).length;e._socket?e._sender._bufferedBytes+=r:e._bufferedAmount+=r}if(t){let r=new Error(`WebSocket is not open: readyState ${e.readyState} (${q[e.readyState]})`);process.nextTick(t,r)}}function mo(e,n){let t=this[P];t._closeFrameReceived=!0,t._closeMessage=n,t._closeCode=e,t._socket[P]!==void 0&&(t._socket.removeListener("data",Ne),process.nextTick(ct,t._socket),e===1005?t.close():t.close(e,n))}function ho(){let e=this[P];e.isPaused||e._socket.resume()}function yo(e){let n=this[P];n._socket[P]!==void 0&&(n._socket.removeListener("data",Ne),process.nextTick(ct,n._socket),n.close(e[oo])),n._errorEmitted||(n._errorEmitted=!0,n.emit("error",e))}function ot(){this[P].emitClose()}function _o(e,n){this[P].emit("message",e,n)}function xo(e){let n=this[P];n._autoPong&&n.pong(e,!this._isServer,it),n.emit("ping",e)}function bo(e){this[P].emit("pong",e)}function ct(e){e.resume()}function vo(e){let n=this[P];n.readyState!==C.CLOSED&&(n.readyState===C.OPEN&&(n._readyState=C.CLOSING,lt(n)),this._socket.end(),n._errorEmitted||(n._errorEmitted=!0,n.emit("error",e)))}function lt(e){e._closeTimer=setTimeout(e._socket.destroy.bind(e._socket),uo)}function ut(){let e=this[P];this.removeListener("close",ut),this.removeListener("data",Ne),this.removeListener("end",ft),e._readyState=C.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[P]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",ot),e._receiver.on("finish",ot))}function Ne(e){this[P]._receiver.write(e)||this.pause()}function ft(){let e=this[P];e._readyState=C.CLOSING,e._receiver.end(),this.end()}function pt(){let e=this[P];this.removeListener("error",pt),this.on("error",it),e&&(e._readyState=C.CLOSING,this.destroy())}});var _t=A((Di,yt)=>{"use strict";var Ui=Le(),{Duplex:So}=E("stream");function mt(e){e.emit("close")}function wo(){!this.destroyed&&this._writableState.finished&&this.destroy()}function ht(e){this.removeListener("error",ht),this.destroy(),this.listenerCount("error")===0&&this.emit("error",e)}function ko(e,n){let t=!0,r=new So({...n,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on("message",function(s,i){let a=!i&&r._readableState.objectMode?s.toString():s;r.push(a)||e.pause()}),e.once("error",function(s){r.destroyed||(t=!1,r.destroy(s))}),e.once("close",function(){r.destroyed||r.push(null)}),r._destroy=function(o,s){if(e.readyState===e.CLOSED){s(o),process.nextTick(mt,r);return}let i=!1;e.once("error",function(c){i=!0,s(c)}),e.once("close",function(){i||s(o),process.nextTick(mt,r)}),t&&e.terminate()},r._final=function(o){if(e.readyState===e.CONNECTING){e.once("open",function(){r._final(o)});return}e._socket!==null&&(e._socket._writableState.finished?(o(),r._readableState.endEmitted&&r.destroy()):(e._socket.once("finish",function(){o()}),e.close()))},r._read=function(){e.isPaused&&e.resume()},r._write=function(o,s,i){if(e.readyState===e.CONNECTING){e.once("open",function(){r._write(o,s,i)});return}e.send(o,i)},r.on("end",wo),r.on("error",ht),r}yt.exports=ko});var bt=A((zi,xt)=>{"use strict";var{tokenChars:Co}=oe();function Oo(e){let n=new Set,t=-1,r=-1,o=0;for(o;o<e.length;o++){let i=e.charCodeAt(o);if(r===-1&&Co[i]===1)t===-1&&(t=o);else if(o!==0&&(i===32||i===9))r===-1&&t!==-1&&(r=o);else if(i===44){if(t===-1)throw new SyntaxError(`Unexpected character at index ${o}`);r===-1&&(r=o);let a=e.slice(t,r);if(n.has(a))throw new SyntaxError(`The "${a}" subprotocol is duplicated`);n.add(a),t=r=-1}else throw new SyntaxError(`Unexpected character at index ${o}`)}if(t===-1||r!==-1)throw new SyntaxError("Unexpected end of input");let s=e.slice(t,o);if(n.has(s))throw new SyntaxError(`The "${s}" subprotocol is duplicated`);return n.add(s),n}xt.exports={parse:Oo}});var Et=A((Vi,Ot)=>{"use strict";var Eo=E("events"),Je=E("http"),{Duplex:Fi}=E("stream"),{createHash:Po}=E("crypto"),vt=on(),Y=me(),To=bt(),Io=Le(),{GUID:Ao,kWebSocket:Ro}=F(),Mo=/^[+/0-9A-Za-z]{22}==$/,St=0,wt=1,Ct=2,ln=class extends Eo{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:Io,...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=Je.createServer((r,o)=>{let s=Je.STATUS_CODES[426];o.writeHead(426,{"Content-Length":s.length,"Content-Type":"text/plain"}),o.end(s)}),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=jo(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(o,s,i)=>{this.handleUpgrade(o,s,i,r)}})}n.perMessageDeflate===!0&&(n.perMessageDeflate={}),n.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=n,this._state=St}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===Ct){n&&this.once("close",()=>{n(new Error("The server is not running"))}),process.nextTick(xe,this);return}if(n&&this.once("close",n),this._state!==wt)if(this._state=wt,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(xe,this):process.nextTick(xe,this);else{let t=this._server;this._removeListeners(),this._removeListeners=this._server=null,t.close(()=>{xe(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,o){t.on("error",kt);let s=n.headers["sec-websocket-key"],i=n.headers.upgrade,a=+n.headers["sec-websocket-version"];if(n.method!=="GET"){Q(this,n,t,405,"Invalid HTTP method");return}if(i===void 0||i.toLowerCase()!=="websocket"){Q(this,n,t,400,"Invalid Upgrade header");return}if(s===void 0||!Mo.test(s)){Q(this,n,t,400,"Missing or invalid Sec-WebSocket-Key header");return}if(a!==13&&a!==8){Q(this,n,t,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(n)){be(t,400);return}let c=n.headers["sec-websocket-protocol"],d=new Set;if(c!==void 0)try{d=To.parse(c)}catch{Q(this,n,t,400,"Invalid Sec-WebSocket-Protocol header");return}let f=n.headers["sec-websocket-extensions"],p={};if(this.options.perMessageDeflate&&f!==void 0){let y=new Y(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let u=vt.parse(f);u[Y.extensionName]&&(y.accept(u[Y.extensionName]),p[Y.extensionName]=y)}catch{Q(this,n,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let y={origin:n.headers[`${a===8?"sec-websocket-origin":"origin"}`],secure:!!(n.socket.authorized||n.socket.encrypted),req:n};if(this.options.verifyClient.length===2){this.options.verifyClient(y,(u,g,l,x)=>{if(!u)return be(t,g||401,l,x);this.completeUpgrade(p,s,d,n,t,r,o)});return}if(!this.options.verifyClient(y))return be(t,401)}this.completeUpgrade(p,s,d,n,t,r,o)}completeUpgrade(n,t,r,o,s,i,a){if(!s.readable||!s.writable)return s.destroy();if(s[Ro])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>St)return be(s,503);let d=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Po("sha1").update(t+Ao).digest("base64")}`],f=new this.options.WebSocket(null,void 0,this.options);if(r.size){let p=this.options.handleProtocols?this.options.handleProtocols(r,o):r.values().next().value;p&&(d.push(`Sec-WebSocket-Protocol: ${p}`),f._protocol=p)}if(n[Y.extensionName]){let p=n[Y.extensionName].params,y=vt.format({[Y.extensionName]:[p]});d.push(`Sec-WebSocket-Extensions: ${y}`),f._extensions=n}this.emit("headers",d,o),s.write(d.concat(`\r
|
|
4
4
|
`).join(`\r
|
|
5
5
|
`)),s.removeListener("error",kt),f.setSocket(s,i,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(f),f.on("close",()=>{this.clients.delete(f),this._shouldEmitClose&&!this.clients.size&&process.nextTick(xe,this)})),a(f,o)}};Ot.exports=ln;function jo(e,n){for(let t of Object.keys(n))e.on(t,n[t]);return function(){for(let r of Object.keys(n))e.removeListener(r,n[r])}}function xe(e){e._state=Ct,e.emit("close")}function kt(){this.destroy()}function be(e,n,t,r){t=t||Je.STATUS_CODES[n],r={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(t),...r},e.once("finish",e.destroy),e.end(`HTTP/1.1 ${n} ${Je.STATUS_CODES[n]}\r
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';
|
|
2
|
-
const require =
|
|
1
|
+
import { createRequire as __linzumiBundleCreateRequire } from 'node:module';
|
|
2
|
+
const require = __linzumiBundleCreateRequire(import.meta.url);
|
|
3
3
|
import{randomUUID as ce}from"node:crypto";import{mkdir as me,realpath as pe,writeFile as _e}from"node:fs/promises";import{homedir as J}from"node:os";import{join as L}from"node:path";function $(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 _(e){if(e===null||e.BS_PRIVATE_NESTED_SOME_NONE===void 0)return e;let t=e.BS_PRIVATE_NESTED_SOME_NONE;if(t!==0)return{BS_PRIVATE_NESTED_SOME_NONE:t-1|0}}function h(e,t){let r=e.length,i=new Array(r),n=0;for(let s=0;s<r;++s){let o=e[s],m=t(o);m!==void 0&&(i[n]=_(m),n=n+1|0)}return i.length=n,i}function g(e,t,r){return e!==void 0?r(_(e)):t}function k(e,t){if(e!==void 0)return $(t(_(e)))}function v(e,t){if(e!==void 0)return t(_(e))}function E(e,t){return e!==void 0?_(e):t}var R=["codex","claude-code","pi","opencode"];function M(e){return e}function D(e,t){let r=e[t];if(typeof r=="object"&&r!==null&&!Array.isArray(r))return r}function d(e,t){let r=e[t];if(typeof r=="string")return r}function T(e,t){let r=e[t];if(Array.isArray(r))return r}function I(e){return h(e,t=>{if(typeof t!="object"||t===null||Array.isArray(t))return;if(d(t,"type")==="text")return d(t,"text")}).join(`
|
|
4
4
|
`)}function j(e,t,r,i){return e+":"+t+":"+r+":"+i}function N(e,t){let r=t.split(":"),i=r[0],n=r[1],s=r[2];if(i===void 0||n===void 0||s===void 0||!(i===e&&n!==""&&s!==""&&r.length>=4))return;let o=r.slice(3,r.length).join(":");if(o!=="")return{keySessionId:n,keyTurnId:s,keyItemId:o}}function W(e,t){return{threadId:e,threadTitle:void 0,nodes:t,hasMore:!1,cursor:void 0,budget:void 0,session:void 0}}var V="codex";function ne(e,t,r){return j(V,e,t,r)}function ie(e){if(e===void 0)return"system_notice";switch(e){case"agentMessage":return"assistant_message";case"commandExecution":return"command_execution";case"fileChange":return"file_change";case"collabAgentToolCall":case"dynamicToolCall":case"mcpToolCall":return"tool_call";case"reasoning":return"reasoning";case"plan":case"subAgentActivity":return"agent_status";case"terminalInput":return"terminal_input";case"userMessage":return"user_message";default:return"system_notice"}}function B(e){return h(e,t=>{if(typeof t=="string")return t})}function se(e){let t=d(e,"type");if(t===void 0)return"";switch(t){case"collabAgentToolCall":return E(d(e,"prompt"),"");case"commandExecution":return E(d(e,"aggregatedOutput"),"");case"dynamicToolCall":return g(T(e,"contentItems"),"",I);case"fileChange":return g(T(e,"changes"),[],n=>h(n,s=>{if(typeof s=="object"&&s!==null&&!Array.isArray(s))return d(s,"path")})).join(`
|
|
5
5
|
`);case"mcpToolCall":return g(v(D(e,"result"),n=>T(n,"content")),"",I);case"reasoning":let r=g(T(e,"summary"),[],B),i=g(T(e,"content"),[],B);return r.concat(i).filter(n=>n!=="").join(`
|
package/dist/impl-res/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';
|
|
2
|
-
const require =
|
|
1
|
+
import { createRequire as __linzumiBundleCreateRequire } from 'node:module';
|
|
2
|
+
const require = __linzumiBundleCreateRequire(import.meta.url);
|
|
3
3
|
var $j=Object.create;var Np=Object.defineProperty;var Mj=Object.getOwnPropertyDescriptor;var jj=Object.getOwnPropertyNames;var zj=Object.getPrototypeOf,Nj=Object.prototype.hasOwnProperty;var ce=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Gp=(e,t)=>{for(var r in t)Np(e,r,{get:t[r],enumerable:!0})},Gj=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of jj(t))!Nj.call(e,i)&&i!==r&&Np(e,i,{get:()=>t[i],enumerable:!(n=Mj(t,i))||n.enumerable});return e};var Tw=(e,t,r)=>(r=e!=null?$j(zj(e)):{},Gj(t||!e||!e.__esModule?Np(r,"default",{value:e,enumerable:!0}):r,e));var Bd=ce(xt=>{"use strict";Object.defineProperty(xt,"__esModule",{value:!0});xt.regexpCode=xt.getEsmExportName=xt.getProperty=xt.safeStringify=xt.stringify=xt.strConcat=xt.addCodeArg=xt.str=xt._=xt.nil=xt._Code=xt.Name=xt.IDENTIFIER=xt._CodeOrName=void 0;var Vd=class{};xt._CodeOrName=Vd;xt.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var qa=class extends Vd{constructor(t){if(super(),!xt.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};xt.Name=qa;var Yn=class extends Vd{constructor(t){super(),this._items=typeof t=="string"?[t]:t}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let t=this._items[0];return t===""||t==='""'}get str(){var t;return(t=this._str)!==null&&t!==void 0?t:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var t;return(t=this._names)!==null&&t!==void 0?t:this._names=this._items.reduce((r,n)=>(n instanceof qa&&(r[n.str]=(r[n.str]||0)+1),r),{})}};xt._Code=Yn;xt.nil=new Yn("");function XA(e,...t){let r=[e[0]],n=0;for(;n<t.length;)Ay(r,t[n]),r.push(e[++n]);return new Yn(r)}xt._=XA;var Ty=new Yn("+");function QA(e,...t){let r=[Hd(e[0])],n=0;for(;n<t.length;)r.push(Ty),Ay(r,t[n]),r.push(Ty,Hd(e[++n]));return rL(r),new Yn(r)}xt.str=QA;function Ay(e,t){t instanceof Yn?e.push(...t._items):t instanceof qa?e.push(t):e.push(oL(t))}xt.addCodeArg=Ay;function rL(e){let t=1;for(;t<e.length-1;){if(e[t]===Ty){let r=nL(e[t-1],e[t+1]);if(r!==void 0){e.splice(t-1,3,r);continue}e[t++]="+"}t++}}function nL(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof qa||e[e.length-1]!=='"'?void 0:typeof t!="string"?`${e.slice(0,-1)}${t}"`:t[0]==='"'?e.slice(0,-1)+t.slice(1):void 0;if(typeof t=="string"&&t[0]==='"'&&!(e instanceof qa))return`"${e}${t.slice(1)}`}function iL(e,t){return t.emptyStr()?e:e.emptyStr()?t:QA`${e}${t}`}xt.strConcat=iL;function oL(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:Hd(Array.isArray(e)?e.join(","):e)}function aL(e){return new Yn(Hd(e))}xt.stringify=aL;function Hd(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}xt.safeStringify=Hd;function sL(e){return typeof e=="string"&&xt.IDENTIFIER.test(e)?new Yn(`.${e}`):XA`[${e}]`}xt.getProperty=sL;function lL(e){if(typeof e=="string"&&xt.IDENTIFIER.test(e))return new Yn(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}xt.getEsmExportName=lL;function dL(e){return new Yn(e.toString())}xt.regexpCode=dL});var Ey=ce(Tn=>{"use strict";Object.defineProperty(Tn,"__esModule",{value:!0});Tn.ValueScope=Tn.ValueScopeName=Tn.Scope=Tn.varKinds=Tn.UsedValueState=void 0;var xn=Bd(),Oy=class extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value}},Lf;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"})(Lf||(Tn.UsedValueState=Lf={}));Tn.varKinds={const:new xn.Name("const"),let:new xn.Name("let"),var:new xn.Name("var")};var Uf=class{constructor({prefixes:t,parent:r}={}){this._names={},this._prefixes=t,this._parent=r}toName(t){return t instanceof xn.Name?t:this.name(t)}name(t){return new xn.Name(this._newName(t))}_newName(t){let r=this._names[t]||this._nameGroup(t);return`${t}${r.index++}`}_nameGroup(t){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(t)||this._prefixes&&!this._prefixes.has(t))throw new Error(`CodeGen: prefix "${t}" is not allowed in this scope`);return this._names[t]={prefix:t,index:0}}};Tn.Scope=Uf;var Wf=class extends xn.Name{constructor(t,r){super(r),this.prefix=t}setValue(t,{property:r,itemIndex:n}){this.value=t,this.scopePath=(0,xn._)`.${new xn.Name(r)}[${n}]`}};Tn.ValueScopeName=Wf;var uL=(0,xn._)`\n`,Cy=class extends Uf{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?uL:xn.nil}}get(){return this._scope}name(t){return new Wf(t,this._newName(t))}value(t,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let i=this.toName(t),{prefix:o}=i,a=(n=r.key)!==null&&n!==void 0?n:r.ref,s=this._values[o];if(s){let u=s.get(a);if(u)return u}else s=this._values[o]=new Map;s.set(a,i);let l=this._scope[o]||(this._scope[o]=[]),d=l.length;return l[d]=r.ref,i.setValue(r,{property:o,itemIndex:d}),i}getValue(t,r){let n=this._values[t];if(n)return n.get(r)}scopeRefs(t,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,xn._)`${t}${n.scopePath}`})}scopeCode(t=this._values,r,n){return this._reduceValues(t,i=>{if(i.value===void 0)throw new Error(`CodeGen: name "${i}" has no value`);return i.value.code},r,n)}_reduceValues(t,r,n={},i){let o=xn.nil;for(let a in t){let s=t[a];if(!s)continue;let l=n[a]=n[a]||new Map;s.forEach(d=>{if(l.has(d))return;l.set(d,Lf.Started);let u=r(d);if(u){let c=this.opts.es5?Tn.varKinds.var:Tn.varKinds.const;o=(0,xn._)`${o}${c} ${d} = ${u};${this.opts._n}`}else if(u=i?.(d))o=(0,xn._)`${o}${u}${this.opts._n}`;else throw new Oy(d);l.set(d,Lf.Completed)})}return o}};Tn.ValueScope=Cy});var it=ce(ot=>{"use strict";Object.defineProperty(ot,"__esModule",{value:!0});ot.or=ot.and=ot.not=ot.CodeGen=ot.operators=ot.varKinds=ot.ValueScopeName=ot.ValueScope=ot.Scope=ot.Name=ot.regexpCode=ot.stringify=ot.getProperty=ot.nil=ot.strConcat=ot.str=ot._=void 0;var bt=Bd(),gi=Ey(),zo=Bd();Object.defineProperty(ot,"_",{enumerable:!0,get:function(){return zo._}});Object.defineProperty(ot,"str",{enumerable:!0,get:function(){return zo.str}});Object.defineProperty(ot,"strConcat",{enumerable:!0,get:function(){return zo.strConcat}});Object.defineProperty(ot,"nil",{enumerable:!0,get:function(){return zo.nil}});Object.defineProperty(ot,"getProperty",{enumerable:!0,get:function(){return zo.getProperty}});Object.defineProperty(ot,"stringify",{enumerable:!0,get:function(){return zo.stringify}});Object.defineProperty(ot,"regexpCode",{enumerable:!0,get:function(){return zo.regexpCode}});Object.defineProperty(ot,"Name",{enumerable:!0,get:function(){return zo.Name}});var Bf=Ey();Object.defineProperty(ot,"Scope",{enumerable:!0,get:function(){return Bf.Scope}});Object.defineProperty(ot,"ValueScope",{enumerable:!0,get:function(){return Bf.ValueScope}});Object.defineProperty(ot,"ValueScopeName",{enumerable:!0,get:function(){return Bf.ValueScopeName}});Object.defineProperty(ot,"varKinds",{enumerable:!0,get:function(){return Bf.varKinds}});ot.operators={GT:new bt._Code(">"),GTE:new bt._Code(">="),LT:new bt._Code("<"),LTE:new bt._Code("<="),EQ:new bt._Code("==="),NEQ:new bt._Code("!=="),NOT:new bt._Code("!"),OR:new bt._Code("||"),AND:new bt._Code("&&"),ADD:new bt._Code("+")};var so=class{optimizeNodes(){return this}optimizeNames(t,r){return this}},Py=class extends so{constructor(t,r,n){super(),this.varKind=t,this.name=r,this.rhs=n}render({es5:t,_n:r}){let n=t?gi.varKinds.var:this.varKind,i=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${i};`+r}optimizeNames(t,r){if(t[this.name.str])return this.rhs&&(this.rhs=il(this.rhs,t,r)),this}get names(){return this.rhs instanceof bt._CodeOrName?this.rhs.names:{}}},Zf=class extends so{constructor(t,r,n){super(),this.lhs=t,this.rhs=r,this.sideEffects=n}render({_n:t}){return`${this.lhs} = ${this.rhs};`+t}optimizeNames(t,r){if(!(this.lhs instanceof bt.Name&&!t[this.lhs.str]&&!this.sideEffects))return this.rhs=il(this.rhs,t,r),this}get names(){let t=this.lhs instanceof bt.Name?{}:{...this.lhs.names};return Hf(t,this.rhs)}},Ry=class extends Zf{constructor(t,r,n,i){super(t,n,i),this.op=r}render({_n:t}){return`${this.lhs} ${this.op}= ${this.rhs};`+t}},Iy=class extends so{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`${this.label}:`+t}},$y=class extends so{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`break${this.label?` ${this.label}`:""};`+t}},My=class extends so{constructor(t){super(),this.error=t}render({_n:t}){return`throw ${this.error};`+t}get names(){return this.error.names}},jy=class extends so{constructor(t){super(),this.code=t}render({_n:t}){return`${this.code};`+t}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(t,r){return this.code=il(this.code,t,r),this}get names(){return this.code instanceof bt._CodeOrName?this.code.names:{}}},Kd=class extends so{constructor(t=[]){super(),this.nodes=t}render(t){return this.nodes.reduce((r,n)=>r+n.render(t),"")}optimizeNodes(){let{nodes:t}=this,r=t.length;for(;r--;){let n=t[r].optimizeNodes();Array.isArray(n)?t.splice(r,1,...n):n?t[r]=n:t.splice(r,1)}return t.length>0?this:void 0}optimizeNames(t,r){let{nodes:n}=this,i=n.length;for(;i--;){let o=n[i];o.optimizeNames(t,r)||(cL(t,o.names),n.splice(i,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((t,r)=>Wa(t,r.names),{})}},lo=class extends Kd{render(t){return"{"+t._n+super.render(t)+"}"+t._n}},zy=class extends Kd{},nl=class extends lo{};nl.kind="else";var La=class e extends lo{constructor(t,r){super(r),this.condition=t}render(t){let r=`if(${this.condition})`+super.render(t);return this.else&&(r+="else "+this.else.render(t)),r}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new nl(n):n}if(r)return t===!1?r instanceof e?r:r.nodes:this.nodes.length?this:new e(eO(t),r instanceof e?[r]:r.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(t,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(t,r),!!(super.optimizeNames(t,r)||this.else))return this.condition=il(this.condition,t,r),this}get names(){let t=super.names;return Hf(t,this.condition),this.else&&Wa(t,this.else.names),t}};La.kind="if";var Ua=class extends lo{};Ua.kind="for";var Ny=class extends Ua{constructor(t){super(),this.iteration=t}render(t){return`for(${this.iteration})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iteration=il(this.iteration,t,r),this}get names(){return Wa(super.names,this.iteration.names)}},Gy=class extends Ua{constructor(t,r,n,i){super(),this.varKind=t,this.name=r,this.from=n,this.to=i}render(t){let r=t.es5?gi.varKinds.var:this.varKind,{name:n,from:i,to:o}=this;return`for(${r} ${n}=${i}; ${n}<${o}; ${n}++)`+super.render(t)}get names(){let t=Hf(super.names,this.from);return Hf(t,this.to)}},Vf=class extends Ua{constructor(t,r,n,i){super(),this.loop=t,this.varKind=r,this.name=n,this.iterable=i}render(t){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iterable=il(this.iterable,t,r),this}get names(){return Wa(super.names,this.iterable.names)}},Jd=class extends lo{constructor(t,r,n){super(),this.name=t,this.args=r,this.async=n}render(t){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(t)}};Jd.kind="func";var Yd=class extends Kd{render(t){return"return "+super.render(t)}};Yd.kind="return";var Fy=class extends lo{render(t){let r="try"+super.render(t);return this.catch&&(r+=this.catch.render(t)),this.finally&&(r+=this.finally.render(t)),r}optimizeNodes(){var t,r;return super.optimizeNodes(),(t=this.catch)===null||t===void 0||t.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(t,r){var n,i;return super.optimizeNames(t,r),(n=this.catch)===null||n===void 0||n.optimizeNames(t,r),(i=this.finally)===null||i===void 0||i.optimizeNames(t,r),this}get names(){let t=super.names;return this.catch&&Wa(t,this.catch.names),this.finally&&Wa(t,this.finally.names),t}},Xd=class extends lo{constructor(t){super(),this.error=t}render(t){return`catch(${this.error})`+super.render(t)}};Xd.kind="catch";var Qd=class extends lo{render(t){return"finally"+super.render(t)}};Qd.kind="finally";var Dy=class{constructor(t,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
4
4
|
`:""},this._extScope=t,this._scope=new gi.Scope({parent:t}),this._nodes=[new zy]}toString(){return this._root.render(this.opts)}name(t){return this._scope.name(t)}scopeName(t){return this._extScope.name(t)}scopeValue(t,r){let n=this._extScope.value(t,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(t,r){return this._extScope.getValue(t,r)}scopeRefs(t){return this._extScope.scopeRefs(t,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(t,r,n,i){let o=this._scope.toName(r);return n!==void 0&&i&&(this._constants[o.str]=n),this._leafNode(new Py(t,o,n)),o}const(t,r,n){return this._def(gi.varKinds.const,t,r,n)}let(t,r,n){return this._def(gi.varKinds.let,t,r,n)}var(t,r,n){return this._def(gi.varKinds.var,t,r,n)}assign(t,r,n){return this._leafNode(new Zf(t,r,n))}add(t,r){return this._leafNode(new Ry(t,ot.operators.ADD,r))}code(t){return typeof t=="function"?t():t!==bt.nil&&this._leafNode(new jy(t)),this}object(...t){let r=["{"];for(let[n,i]of t)r.length>1&&r.push(","),r.push(n),(n!==i||this.opts.es5)&&(r.push(":"),(0,bt.addCodeArg)(r,i));return r.push("}"),new bt._Code(r)}if(t,r,n){if(this._blockNode(new La(t)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(t){return this._elseNode(new La(t))}else(){return this._elseNode(new nl)}endIf(){return this._endBlockNode(La,nl)}_for(t,r){return this._blockNode(t),r&&this.code(r).endFor(),this}for(t,r){return this._for(new Ny(t),r)}forRange(t,r,n,i,o=this.opts.es5?gi.varKinds.var:gi.varKinds.let){let a=this._scope.toName(t);return this._for(new Gy(o,a,r,n),()=>i(a))}forOf(t,r,n,i=gi.varKinds.const){let o=this._scope.toName(t);if(this.opts.es5){let a=r instanceof bt.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,bt._)`${a}.length`,s=>{this.var(o,(0,bt._)`${a}[${s}]`),n(o)})}return this._for(new Vf("of",i,o,r),()=>n(o))}forIn(t,r,n,i=this.opts.es5?gi.varKinds.var:gi.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0,bt._)`Object.keys(${r})`,n);let o=this._scope.toName(t);return this._for(new Vf("in",i,o,r),()=>n(o))}endFor(){return this._endBlockNode(Ua)}label(t){return this._leafNode(new Iy(t))}break(t){return this._leafNode(new $y(t))}return(t){let r=new Yd;if(this._blockNode(r),this.code(t),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(Yd)}try(t,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let i=new Fy;if(this._blockNode(i),this.code(t),r){let o=this.name("e");this._currNode=i.catch=new Xd(o),r(o)}return n&&(this._currNode=i.finally=new Qd,this.code(n)),this._endBlockNode(Xd,Qd)}throw(t){return this._leafNode(new My(t))}block(t,r){return this._blockStarts.push(this._nodes.length),t&&this.code(t).endBlock(r),this}endBlock(t){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||t!==void 0&&n!==t)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${t} expected`);return this._nodes.length=r,this}func(t,r=bt.nil,n,i){return this._blockNode(new Jd(t,r,n)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(Jd)}optimize(t=1){for(;t-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(t){return this._currNode.nodes.push(t),this}_blockNode(t){this._currNode.nodes.push(t),this._nodes.push(t)}_endBlockNode(t,r){let n=this._currNode;if(n instanceof t||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${t.kind}/${r.kind}`:t.kind}"`)}_elseNode(t){let r=this._currNode;if(!(r instanceof La))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=t,this}get _root(){return this._nodes[0]}get _currNode(){let t=this._nodes;return t[t.length-1]}set _currNode(t){let r=this._nodes;r[r.length-1]=t}};ot.CodeGen=Dy;function Wa(e,t){for(let r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function Hf(e,t){return t instanceof bt._CodeOrName?Wa(e,t.names):e}function il(e,t,r){if(e instanceof bt.Name)return n(e);if(!i(e))return e;return new bt._Code(e._items.reduce((o,a)=>(a instanceof bt.Name&&(a=n(a)),a instanceof bt._Code?o.push(...a._items):o.push(a),o),[]));function n(o){let a=r[o.str];return a===void 0||t[o.str]!==1?o:(delete t[o.str],a)}function i(o){return o instanceof bt._Code&&o._items.some(a=>a instanceof bt.Name&&t[a.str]===1&&r[a.str]!==void 0)}}function cL(e,t){for(let r in t)e[r]=(e[r]||0)-(t[r]||0)}function eO(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0,bt._)`!${qy(e)}`}ot.not=eO;var fL=tO(ot.operators.AND);function mL(...e){return e.reduce(fL)}ot.and=mL;var pL=tO(ot.operators.OR);function hL(...e){return e.reduce(pL)}ot.or=hL;function tO(e){return(t,r)=>t===bt.nil?r:r===bt.nil?t:(0,bt._)`${qy(t)} ${e} ${qy(r)}`}function qy(e){return e instanceof bt.Name?e:(0,bt._)`(${e})`}});var Tt=ce(dt=>{"use strict";Object.defineProperty(dt,"__esModule",{value:!0});dt.checkStrictMode=dt.getErrorPath=dt.Type=dt.useFunc=dt.setEvaluated=dt.evaluatedPropsToName=dt.mergeEvaluated=dt.eachItem=dt.unescapeJsonPointer=dt.escapeJsonPointer=dt.escapeFragment=dt.unescapeFragment=dt.schemaRefOrVal=dt.schemaHasRulesButRef=dt.schemaHasRules=dt.checkUnknownRules=dt.alwaysValidSchema=dt.toHash=void 0;var Lt=it(),_L=Bd();function gL(e){let t={};for(let r of e)t[r]=!0;return t}dt.toHash=gL;function yL(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(iO(e,t),!oO(t,e.self.RULES.all))}dt.alwaysValidSchema=yL;function iO(e,t=e.schema){let{opts:r,self:n}=e;if(!r.strictSchema||typeof t=="boolean")return;let i=n.RULES.keywords;for(let o in t)i[o]||lO(e,`unknown keyword: "${o}"`)}dt.checkUnknownRules=iO;function oO(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(t[r])return!0;return!1}dt.schemaHasRules=oO;function bL(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}dt.schemaHasRulesButRef=bL;function vL({topSchemaRef:e,schemaPath:t},r,n,i){if(!i){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,Lt._)`${r}`}return(0,Lt._)`${e}${t}${(0,Lt.getProperty)(n)}`}dt.schemaRefOrVal=vL;function SL(e){return aO(decodeURIComponent(e))}dt.unescapeFragment=SL;function wL(e){return encodeURIComponent(Uy(e))}dt.escapeFragment=wL;function Uy(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}dt.escapeJsonPointer=Uy;function aO(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}dt.unescapeJsonPointer=aO;function kL(e,t){if(Array.isArray(e))for(let r of e)t(r);else t(e)}dt.eachItem=kL;function rO({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(i,o,a,s)=>{let l=a===void 0?o:a instanceof Lt.Name?(o instanceof Lt.Name?e(i,o,a):t(i,o,a),a):o instanceof Lt.Name?(t(i,a,o),o):r(o,a);return s===Lt.Name&&!(l instanceof Lt.Name)?n(i,l):l}}dt.mergeEvaluated={props:rO({mergeNames:(e,t,r)=>e.if((0,Lt._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,Lt._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,Lt._)`${r} || {}`).code((0,Lt._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,Lt._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,Lt._)`${r} || {}`),Wy(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:sO}),items:rO({mergeNames:(e,t,r)=>e.if((0,Lt._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,Lt._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,Lt._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,Lt._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function sO(e,t){if(t===!0)return e.var("props",!0);let r=e.var("props",(0,Lt._)`{}`);return t!==void 0&&Wy(e,r,t),r}dt.evaluatedPropsToName=sO;function Wy(e,t,r){Object.keys(r).forEach(n=>e.assign((0,Lt._)`${t}${(0,Lt.getProperty)(n)}`,!0))}dt.setEvaluated=Wy;var nO={};function xL(e,t){return e.scopeValue("func",{ref:t,code:nO[t.code]||(nO[t.code]=new _L._Code(t.code))})}dt.useFunc=xL;var Ly;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(Ly||(dt.Type=Ly={}));function TL(e,t,r){if(e instanceof Lt.Name){let n=t===Ly.Num;return r?n?(0,Lt._)`"[" + ${e} + "]"`:(0,Lt._)`"['" + ${e} + "']"`:n?(0,Lt._)`"/" + ${e}`:(0,Lt._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,Lt.getProperty)(e).toString():"/"+Uy(e)}dt.getErrorPath=TL;function lO(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}dt.checkStrictMode=lO});var uo=ce(Zy=>{"use strict";Object.defineProperty(Zy,"__esModule",{value:!0});var Yr=it(),AL={data:new Yr.Name("data"),valCxt:new Yr.Name("valCxt"),instancePath:new Yr.Name("instancePath"),parentData:new Yr.Name("parentData"),parentDataProperty:new Yr.Name("parentDataProperty"),rootData:new Yr.Name("rootData"),dynamicAnchors:new Yr.Name("dynamicAnchors"),vErrors:new Yr.Name("vErrors"),errors:new Yr.Name("errors"),this:new Yr.Name("this"),self:new Yr.Name("self"),scope:new Yr.Name("scope"),json:new Yr.Name("json"),jsonPos:new Yr.Name("jsonPos"),jsonLen:new Yr.Name("jsonLen"),jsonPart:new Yr.Name("jsonPart")};Zy.default=AL});var eu=ce(Xr=>{"use strict";Object.defineProperty(Xr,"__esModule",{value:!0});Xr.extendErrors=Xr.resetErrorsCount=Xr.reportExtraError=Xr.reportError=Xr.keyword$DataError=Xr.keywordError=void 0;var St=it(),Kf=Tt(),ln=uo();Xr.keywordError={message:({keyword:e})=>(0,St.str)`must pass "${e}" keyword validation`};Xr.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0,St.str)`"${e}" keyword must be ${t} ($data)`:(0,St.str)`"${e}" keyword is invalid ($data)`};function OL(e,t=Xr.keywordError,r,n){let{it:i}=e,{gen:o,compositeRule:a,allErrors:s}=i,l=cO(e,t,r);n??(a||s)?dO(o,l):uO(i,(0,St._)`[${l}]`)}Xr.reportError=OL;function CL(e,t=Xr.keywordError,r){let{it:n}=e,{gen:i,compositeRule:o,allErrors:a}=n,s=cO(e,t,r);dO(i,s),o||a||uO(n,ln.default.vErrors)}Xr.reportExtraError=CL;function EL(e,t){e.assign(ln.default.errors,t),e.if((0,St._)`${ln.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0,St._)`${ln.default.vErrors}.length`,t),()=>e.assign(ln.default.vErrors,null)))}Xr.resetErrorsCount=EL;function PL({gen:e,keyword:t,schemaValue:r,data:n,errsCount:i,it:o}){if(i===void 0)throw new Error("ajv implementation error");let a=e.name("err");e.forRange("i",i,ln.default.errors,s=>{e.const(a,(0,St._)`${ln.default.vErrors}[${s}]`),e.if((0,St._)`${a}.instancePath === undefined`,()=>e.assign((0,St._)`${a}.instancePath`,(0,St.strConcat)(ln.default.instancePath,o.errorPath))),e.assign((0,St._)`${a}.schemaPath`,(0,St.str)`${o.errSchemaPath}/${t}`),o.opts.verbose&&(e.assign((0,St._)`${a}.schema`,r),e.assign((0,St._)`${a}.data`,n))})}Xr.extendErrors=PL;function dO(e,t){let r=e.const("err",t);e.if((0,St._)`${ln.default.vErrors} === null`,()=>e.assign(ln.default.vErrors,(0,St._)`[${r}]`),(0,St._)`${ln.default.vErrors}.push(${r})`),e.code((0,St._)`${ln.default.errors}++`)}function uO(e,t){let{gen:r,validateName:n,schemaEnv:i}=e;i.$async?r.throw((0,St._)`new ${e.ValidationError}(${t})`):(r.assign((0,St._)`${n}.errors`,t),r.return(!1))}var Za={keyword:new St.Name("keyword"),schemaPath:new St.Name("schemaPath"),params:new St.Name("params"),propertyName:new St.Name("propertyName"),message:new St.Name("message"),schema:new St.Name("schema"),parentSchema:new St.Name("parentSchema")};function cO(e,t,r){let{createErrors:n}=e.it;return n===!1?(0,St._)`{}`:RL(e,t,r)}function RL(e,t,r={}){let{gen:n,it:i}=e,o=[IL(i,r),$L(e,r)];return ML(e,t,o),n.object(...o)}function IL({errorPath:e},{instancePath:t}){let r=t?(0,St.str)`${e}${(0,Kf.getErrorPath)(t,Kf.Type.Str)}`:e;return[ln.default.instancePath,(0,St.strConcat)(ln.default.instancePath,r)]}function $L({keyword:e,it:{errSchemaPath:t}},{schemaPath:r,parentSchema:n}){let i=n?t:(0,St.str)`${t}/${e}`;return r&&(i=(0,St.str)`${i}${(0,Kf.getErrorPath)(r,Kf.Type.Str)}`),[Za.schemaPath,i]}function ML(e,{params:t,message:r},n){let{keyword:i,data:o,schemaValue:a,it:s}=e,{opts:l,propertyName:d,topSchemaRef:u,schemaPath:c}=s;n.push([Za.keyword,i],[Za.params,typeof t=="function"?t(e):t||(0,St._)`{}`]),l.messages&&n.push([Za.message,typeof r=="function"?r(e):r]),l.verbose&&n.push([Za.schema,a],[Za.parentSchema,(0,St._)`${u}${c}`],[ln.default.data,o]),d&&n.push([Za.propertyName,d])}});var mO=ce(ol=>{"use strict";Object.defineProperty(ol,"__esModule",{value:!0});ol.boolOrEmptySchema=ol.topBoolOrEmptySchema=void 0;var jL=eu(),zL=it(),NL=uo(),GL={message:"boolean schema is false"};function FL(e){let{gen:t,schema:r,validateName:n}=e;r===!1?fO(e,!1):typeof r=="object"&&r.$async===!0?t.return(NL.default.data):(t.assign((0,zL._)`${n}.errors`,null),t.return(!0))}ol.topBoolOrEmptySchema=FL;function DL(e,t){let{gen:r,schema:n}=e;n===!1?(r.var(t,!1),fO(e)):r.var(t,!0)}ol.boolOrEmptySchema=DL;function fO(e,t){let{gen:r,data:n}=e,i={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,jL.reportError)(i,GL,void 0,t)}});var Vy=ce(al=>{"use strict";Object.defineProperty(al,"__esModule",{value:!0});al.getRules=al.isJSONType=void 0;var qL=["string","number","integer","boolean","null","object","array"],LL=new Set(qL);function UL(e){return typeof e=="string"&&LL.has(e)}al.isJSONType=UL;function WL(){let e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}al.getRules=WL});var Hy=ce(No=>{"use strict";Object.defineProperty(No,"__esModule",{value:!0});No.shouldUseRule=No.shouldUseGroup=No.schemaHasRulesForType=void 0;function ZL({schema:e,self:t},r){let n=t.RULES.types[r];return n&&n!==!0&&pO(e,n)}No.schemaHasRulesForType=ZL;function pO(e,t){return t.rules.some(r=>hO(e,r))}No.shouldUseGroup=pO;function hO(e,t){var r;return e[t.keyword]!==void 0||((r=t.definition.implements)===null||r===void 0?void 0:r.some(n=>e[n]!==void 0))}No.shouldUseRule=hO});var tu=ce(Qr=>{"use strict";Object.defineProperty(Qr,"__esModule",{value:!0});Qr.reportTypeError=Qr.checkDataTypes=Qr.checkDataType=Qr.coerceAndCheckDataType=Qr.getJSONTypes=Qr.getSchemaTypes=Qr.DataType=void 0;var VL=Vy(),HL=Hy(),BL=eu(),et=it(),_O=Tt(),sl;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(sl||(Qr.DataType=sl={}));function KL(e){let t=gO(e.type);if(t.includes("null")){if(e.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===!0&&t.push("null")}return t}Qr.getSchemaTypes=KL;function gO(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(VL.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}Qr.getJSONTypes=gO;function JL(e,t){let{gen:r,data:n,opts:i}=e,o=YL(t,i.coerceTypes),a=t.length>0&&!(o.length===0&&t.length===1&&(0,HL.schemaHasRulesForType)(e,t[0]));if(a){let s=Ky(t,n,i.strictNumbers,sl.Wrong);r.if(s,()=>{o.length?XL(e,t,o):Jy(e)})}return a}Qr.coerceAndCheckDataType=JL;var yO=new Set(["string","number","integer","boolean","null"]);function YL(e,t){return t?e.filter(r=>yO.has(r)||t==="array"&&r==="array"):[]}function XL(e,t,r){let{gen:n,data:i,opts:o}=e,a=n.let("dataType",(0,et._)`typeof ${i}`),s=n.let("coerced",(0,et._)`undefined`);o.coerceTypes==="array"&&n.if((0,et._)`${a} == 'object' && Array.isArray(${i}) && ${i}.length == 1`,()=>n.assign(i,(0,et._)`${i}[0]`).assign(a,(0,et._)`typeof ${i}`).if(Ky(t,i,o.strictNumbers),()=>n.assign(s,i))),n.if((0,et._)`${s} !== undefined`);for(let d of r)(yO.has(d)||d==="array"&&o.coerceTypes==="array")&&l(d);n.else(),Jy(e),n.endIf(),n.if((0,et._)`${s} !== undefined`,()=>{n.assign(i,s),QL(e,s)});function l(d){switch(d){case"string":n.elseIf((0,et._)`${a} == "number" || ${a} == "boolean"`).assign(s,(0,et._)`"" + ${i}`).elseIf((0,et._)`${i} === null`).assign(s,(0,et._)`""`);return;case"number":n.elseIf((0,et._)`${a} == "boolean" || ${i} === null
|
|
5
5
|
|| (${a} == "string" && ${i} && ${i} == +${i})`).assign(s,(0,et._)`+${i}`);return;case"integer":n.elseIf((0,et._)`${a} === "boolean" || ${i} === null
|
|
@@ -321,7 +321,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
321
321
|
`);if(t===-1)return null;let r=this._buffer.toString("utf8",0,t).replace(/\r$/,"");return this._buffer=this._buffer.subarray(t+1),XV(r)}clear(){this._buffer=void 0}};function XV(e){return aA.parse(JSON.parse(e))}function BE(e){return JSON.stringify(e)+`
|
|
322
322
|
`}var Pm=class{constructor(t=KE.stdin,r=KE.stdout){this._stdin=t,this._stdout=r,this._readBuffer=new Em,this._started=!1,this._ondata=n=>{this._readBuffer.append(n),this.processReadBuffer()},this._onerror=n=>{this.onerror?.(n)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let t=this._readBuffer.readMessage();if(t===null)break;this.onmessage?.(t)}catch(t){this.onerror?.(t)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(t){return new Promise(r=>{let n=BE(t);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};function e4(e){let t={};t.listChanged=!1;let r={};r.resources=t,e.server.registerCapabilities(r),e.server.setRequestHandler(Xs,()=>{let n={};return n.resources=[],n}),e.server.setRequestHandler(Qs,()=>{let n={};return n.resourceTemplates=[],n})}function t4(e){return{registerTool:(t,r,n,i)=>{e.tool(t,r,n,i)}}}async function vv(e){let t=e.delegationAuthFilePath;if(t!==void 0){let n=e.explicitToken,i=e.authFilePath;if(n!==void 0)return{TAG:"Error",_0:"--delegation-auth-file cannot be combined with --token or --auth-file"};if(i!==void 0)return{TAG:"Error",_0:"--delegation-auth-file cannot be combined with --token or --auth-file"};let o=V0(t,Date.now());return o.TAG==="Ok"?{TAG:"Ok",_0:{accessToken:o._0.accessToken,mode:"PersonalAgentDelegation"}}:{TAG:"Error",_0:o._0.summary}}let r=await gk(e.serviceUrl,e.explicitToken,e.authFilePath,e.workspaceSlug,e.channelSlug,void 0);return r.TAG==="Ok"?{TAG:"Ok",_0:{accessToken:r._0,mode:"LocalRunner"}}:{TAG:"Error",_0:r._0.summary}}function Sv(e,t){let r=wr(e,"token");return{serviceUrl:t,explicitToken:r!==void 0?r:process.env.LINZUMI_MCP_ACCESS_TOKEN,authFilePath:wr(e,"auth-file"),delegationAuthFilePath:wr(e,"delegation-auth-file"),workspaceSlug:wr(e,"workspace"),channelSlug:wr(e,"channel")}}async function r4(e){let t=ac(e);if(t.TAG!=="Ok")return{TAG:"Error",_0:t._0};let r=t._0;if(sc(r,"help"))return aa(uc()),{TAG:"Ok",_0:void 0};let n=lc(r,"api-url");if(n.TAG!=="Ok")return{TAG:"Error",_0:n._0};let i=n._0,o=await vv(Sv(r,i));if(o.TAG!=="Ok")return{TAG:"Error",_0:o._0};let a=o._0,s=dc(wr(r,"mode")),l=Up(wr(r,"tool-scope"));if(s.TAG!=="Ok")return{TAG:"Error",_0:s._0};let d=s._0;if(l.TAG!=="Ok")return{TAG:"Error",_0:l._0};let u=wr(r,"owner-username"),c=u!==void 0?u:process.env.LINZUMI_MCP_OWNER_USERNAME,f=wr(r,"cwd"),p=f!==void 0?f:process.cwd(),m=wr(r,"thread-id"),h=m!==void 0?m:process.env[$k],_=Bh({serviceUrl:i,accessToken:a.accessToken,authMode:a.mode,operatingMode:d});if(_.TAG!=="Ok")return{TAG:"Error",_0:_._0};let g=new Cm({name:"linzumi",version:"0.1.0"});return e4(g),lx(t4(g),{client:_._0,toolScope:l._0,operatingMode:d,cwd:p,serviceUrl:i,defaultThreadId:h,ownerUsername:c,agentSession:sc(r,"agent-session"),devServices:tx(process.env)}),await g.connect(new Pm),{TAG:"Ok",_0:void 0}}async function n4(e){let t=ac(e);if(t.TAG!=="Ok")return{TAG:"Error",_0:t._0};let r=t._0,n=lc(r,"api-url");if(n.TAG!=="Ok")return{TAG:"Error",_0:n._0};let i=n._0,o=wr(r,"format"),a=o!==void 0?o:"codex",s=dc(wr(r,"mode"));if(s.TAG!=="Ok")return{TAG:"Error",_0:s._0};let l;if(sc(r,"include-token")){let f=await vv(Sv(r,i));l=f.TAG==="Ok"?{TAG:"Ok",_0:f._0.accessToken}:{TAG:"Error",_0:f._0}}else l={TAG:"Ok",_0:void 0};if(l.TAG!=="Ok")return{TAG:"Error",_0:l._0};let d=Up(wr(r,"tool-scope"));if(d.TAG!=="Ok")return{TAG:"Error",_0:d._0};let u=wr(r,"owner-username"),c=Zs({command:wr(r,"command"),serviceUrl:i,accessToken:l._0,delegationAuthFilePath:wr(r,"delegation-auth-file"),ownerUsername:u!==void 0?u:process.env.LINZUMI_MCP_OWNER_USERNAME,operatingMode:s._0,toolScope:d._0});switch(a){case"claude-code":return aa(fx(c)),{TAG:"Ok",_0:void 0};case"codex":return aa(mx(c)),{TAG:"Ok",_0:void 0};default:return{TAG:"Error",_0:"--format must be codex or claude-code"}}}async function i4(e){let t=ac(e);if(t.TAG!=="Ok")return{TAG:"Error",_0:t._0};let r=t._0,n=lc(r,"api-url");if(n.TAG!=="Ok")return{TAG:"Error",_0:n._0};let i=n._0,o=await vv(Sv(r,i));if(o.TAG!=="Ok")return{TAG:"Error",_0:o._0};let a=o._0,s=a.mode,l;if(s==="LocalRunner"){let d=await Ms(i,a.accessToken,wr(r,"workspace"),wr(r,"channel"),void 0);if(d.TAG==="Ok")switch(d._0){case"Usable":l={TAG:"Ok",_0:void 0};break;case"Rejected":case"NotFound":l={TAG:"Error",_0:"Linzumi MCP auth validation failed"};break}else l={TAG:"Error",_0:d._0.summary}}else{let d=dc(wr(r,"mode"));if(d.TAG==="Ok"){let u=Bh({serviceUrl:i,accessToken:a.accessToken,authMode:a.mode,operatingMode:d._0});if(u.TAG==="Ok")try{await u._0.validateAuth(),l={TAG:"Ok",_0:void 0}}catch(c){let f=ee(c);l={TAG:"Error",_0:gs(f)}}else l={TAG:"Error",_0:u._0}}else l={TAG:"Error",_0:d._0}}return l.TAG!=="Ok"?{TAG:"Error",_0:l._0}:(aa(`Linzumi MCP auth OK
|
|
323
323
|
`),{TAG:"Ok",_0:void 0})}async function JE(e){let t=e.slice(1),r=e[0];if(r!==void 0)switch(r){case"--help":case"-h":return aa(uc()),{TAG:"Ok",_0:void 0};case"config":return await n4(t);case"doctor":return await i4(t);case"server":return await r4(t);default:return{TAG:"Error",_0:"unknown linzumi mcp command: "+r}}else return aa(uc()),{TAG:"Ok",_0:void 0}}import*as QE from"node:fs";import*as eP from"node:url";import*as un from"node:path";import*as tP from"node:module";var a4=[["linux","x64",{triple:"x86_64-unknown-linux-musl",packageName:"@openai/codex-linux-x64"}],["linux","arm64",{triple:"aarch64-unknown-linux-musl",packageName:"@openai/codex-linux-arm64"}],["android","x64",{triple:"x86_64-unknown-linux-musl",packageName:"@openai/codex-linux-x64"}],["android","arm64",{triple:"aarch64-unknown-linux-musl",packageName:"@openai/codex-linux-arm64"}],["darwin","x64",{triple:"x86_64-apple-darwin",packageName:"@openai/codex-darwin-x64"}],["darwin","arm64",{triple:"aarch64-apple-darwin",packageName:"@openai/codex-darwin-arm64"}],["win32","x64",{triple:"x86_64-pc-windows-msvc",packageName:"@openai/codex-win32-x64"}],["win32","arm64",{triple:"aarch64-pc-windows-msvc",packageName:"@openai/codex-win32-arm64"}]];function rP(e,t){return G(a4.find(r=>r[0]===e?r[1]===t:!1),r=>r[2])}function s4(e){try{return tP.createRequire(import.meta.url).resolve(e)}catch{return}}function l4(e){let t=hs(e);return t.TAG==="Ok"?t._0:[]}function Rm(){return{platform:process.platform,arch:process.arch,fileExists:e=>QE.existsSync(e),listDirectory:l4,resolveModulePath:s4,moduleDir:un.dirname(eP.fileURLToPath(import.meta.url))}}function nP(e,t,r){let n=t;for(;;){let i=n,o=un.join(...[i,"node_modules"].concat(e.split("/")));if(r(un.join(o,"package.json")))return o;let a=un.dirname(i);if(a===i)return;n=a}}function wv(e,t){let r=t.resolveModulePath(e+"/package.json");return r!==void 0?un.dirname(r):nP(e,t.moduleDir,t.fileExists)}function d4(e,t,r){let i=r.platform==="win32"?"codex.exe":"codex",o=un.join(e,t),s=[un.join(o,"codex",i),un.join(o,"bin",i),un.join(o,i)].find(l=>r.fileExists(l));return s!==void 0?s:r.listDirectory(o).map(l=>un.join(o,l,i)).find(l=>r.fileExists(l))}function u4(e){let t=rP(e.platform,e.arch);if(t===void 0)return;let r=[],n=wv(t.packageName,e);n!==void 0&&r.push(un.join(n,"vendor"));let i=wv("@openai/codex",e);return i!==void 0&&r.push(un.join(i,"vendor")),Ve(r,void 0,(o,a)=>o!==void 0?o:d4(a,t.triple,e))}function c4(e){let t=wv("@openai/codex",e);if(t===void 0)return;let r=Qt(un.join(t,"package.json"));if(r.TAG!=="Ok")return;let n;try{n=JSON.parse(r._0)}catch{n=void 0}if(n===void 0||typeof n!="object"||n===null||Array.isArray(n))return;let i=n.version;if(i!==void 0&&typeof i=="string"&&i.trim()!=="")return i.trim()}var f4=new RegExp("(\\d+\\.\\d+\\.\\d+)");function Im(e){let t=_s(e,["--version"],1e4,1048576);if(t.TAG!=="Ok")return;let r=f4.exec(t._0);if(r!=null)return k(r.slice(1)[0],n=>n)}function m4(e,t){return e!==void 0&&t!==void 0?e===t?{TAG:"Match",version:e}:{TAG:"Mismatch",pathVersion:e,pinnedVersion:t}:{TAG:"Unverified",pathVersion:e,pinnedVersion:t}}function p4(e){switch(e.TAG){case"Match":return"match";case"Mismatch":return"mismatch";case"Unverified":return"unverified"}}var kv="LINZUMI_ALLOW_HARNESS_MISMATCH",YE={contents:!1};var h4="Warning: the Codex engine bundled with @linzumi/cli could not be located in its install (@openai/codex platform binary missing). Falling back to `codex` from PATH - the engine version may not match this CLI release. Pass --codex-bin <path> to pin an engine explicitly.\n";function _4(e){if(!YE.contents)return YE.contents=!0,e(h4)}function XE(e,t){return"the codex engine bundled with @linzumi/cli is missing from this install and the `codex` on PATH is version "+e+", but this CLI release pins engine "+t+". "+("Running a mismatched engine breaks the wire protocol (codex "+t+" vocabulary), so refusing to start. ")+("Fix: reinstall the CLI (a fresh `npx -y @linzumi/cli@latest` restores the bundled engine), pass --codex-bin <path> to pin an engine deliberately, or set "+kv+"=1 to accept the skew.")}function g4(e,t){return"Warning: proceeding with the PATH codex "+e+" despite the CLI pinning engine "+t+" ("+kv+`=1). Engine/CLI version skew can break the wire protocol.
|
|
324
|
-
`}function y4(e,t){}function $m(e,t,r,n,i,o){let a=o!==void 0?o:y4;if(e!==void 0)return{TAG:"Ok",_0:{codexBin:e,source:"ExplicitFlag"}};let s=u4(t);if(s!==void 0){let f={};return f.codex_bin_path=s,f.codex_bin_source="bundled",a("codex.binary.resolved",f),{TAG:"Ok",_0:{codexBin:s,source:"Bundled"}}}_4(r);let l=c4(t),d=l!==void 0?n("codex"):void 0,u=m4(d,l),c={};switch(c.codex_bin_path="codex",c.codex_bin_source="path-fallback",c.harness_version_check=p4(u),u.TAG){case"Match":c.harness_version=u.version;break;case"Mismatch":c.path_harness_version=u.pathVersion,c.pinned_harness_version=u.pinnedVersion;break;case"Unverified":c.path_harness_version=rn(u.pathVersion,null,f=>f),c.pinned_harness_version=rn(u.pinnedVersion,null,f=>f);break}switch(a("codex.binary.resolved",c),u.TAG){case"Mismatch":let f=u.pinnedVersion,p=u.pathVersion,m=i[kv];return m===void 0?{TAG:"Error",_0:XE(p,f)}:m!=="1"?{TAG:"Error",_0:XE(p,f)}:(r(g4(p,f)),{TAG:"Ok",_0:{codexBin:"codex",source:"PathFallback"}});case"Match":case"Unverified":return{TAG:"Ok",_0:{codexBin:"codex",source:"PathFallback"}}}}function iP(e){if(typeof e=="number"&&e%1===0)return e}function b4(e){if(typeof e=="string")return e}function v4(e){let t=e.replaceAll("-","+").replaceAll("_","/");switch(t.length&3){case 2:return t+"==";case 3:return t+"=";default:return t}}function oP(e){let t=e.split(".")[1];if(t===void 0)return;let r=Buffer.from(v4(t),"base64").toString("utf8"),n;try{n=JSON.parse(r)}catch{n=void 0}if(typeof n=="object"&&n!==null&&!Array.isArray(n))return n}function wu(e){let t=oP(e);if(t===void 0)return{actorUserId:void 0,actorUsername:void 0};let r=iP(t.actor_id);return{actorUserId:r!==void 0?r:iP(t.sub),actorUsername:b4(t.actor_username)}}function aP(e){let t=k(oP(e),n=>n.workspace_scope),r=t!==void 0?Array.isArray(t)?$e(t,n=>{if(typeof n=="string"&&n.trim()!=="")return n}):[]:[];if(r.length===1)return r[0]}var Av=[["codex.agent_turn_narration_only_no_reply","harness.agent_turn_narration_only_no_reply"],["codex.cost_cap_402_seen","harness.cost_cap_402_seen"],["codex.edge_blocked_captured","harness.edge_blocked_captured"],["codex.empty_turn_auto_retry_suppressed_cost_cap","harness.empty_turn_auto_retry_suppressed_cost_cap"],["codex.empty_turn_loop_guard_tripped","harness.empty_turn_loop_guard_tripped"],["codex.error_without_http_status_captured","harness.error_without_http_status_captured"],["codex.mid_stream_stall_auto_resume_flagged","harness.mid_stream_stall_auto_resume_flagged"],["codex.mid_stream_stall_resume_suppressed_rate_limit","harness.mid_stream_stall_resume_suppressed_rate_limit"],["codex.mid_stream_stall_second_stall_after_resume","harness.mid_stream_stall_second_stall_after_resume"],["codex.pre_first_byte_stall_auto_retry_flagged","harness.pre_first_byte_stall_auto_retry_flagged"],["codex.pre_first_byte_stall_retry_suppressed_cost_cap","harness.pre_first_byte_stall_retry_suppressed_cost_cap"],["codex.provider_outage_flagged_captured","harness.provider_outage_flagged_captured"],["codex.reasoning_loop_breaker_tripped","harness.reasoning_loop_breaker_tripped"],["codex.tool_fatal_captured","harness.tool_fatal_captured"],["codex.turn_completed","job.turn_completed"],["codex.turn_completed_with_protocol_failure","job.turn_completed_with_protocol_failure"],["codex.turn_completed_with_unsupported_tool_call_ignored","job.turn_completed_with_unsupported_tool_call_ignored"],["codex.turn_completed_without_assistant_output","job.turn_completed_without_assistant_output"],["codex.turn_forward_failed","job.turn_forward_failed"],["codex.upstream_error_captured","harness.upstream_error_captured"],["codex.upstream_rejection_captured","harness.upstream_rejection_captured"],["codex.upstream_turn_error_captured","harness.upstream_turn_error_captured"],["kandan.chat_event","linzumi.chat_event"],["kandan.chat_event_abandoned","linzumi.chat_event_abandoned"],["kandan.chat_event_failed","linzumi.chat_event_failed"],["kandan.chat_event_failure_cleared","linzumi.chat_event_failure_cleared"],["kandan.claude_code_interrupt_state_push_failed","linzumi.claude_code_interrupt_state_push_failed"],["kandan.claude_code_stop_state_push_failed","linzumi.claude_code_stop_state_push_failed"],["kandan.claude_code_typing_heartbeat_failed","linzumi.claude_code_typing_heartbeat_failed"],["kandan.claude_code_typing_start_wait_timeout","linzumi.claude_code_typing_start_wait_timeout"],["kandan.claude_code_typing_stop_failed","linzumi.claude_code_typing_stop_failed"],["kandan.claude_code_user_input_abort_publish_failed","linzumi.claude_code_user_input_abort_publish_failed"],["kandan.claude_code_user_question_completed_publish_failed","linzumi.claude_code_user_question_completed_publish_failed"],["kandan.codex_command_output_forwarded","linzumi.codex_command_output_forwarded"],["kandan.codex_delta_forwarded","linzumi.codex_delta_forwarded"],["kandan.codex_file_change_forwarded","linzumi.codex_file_change_forwarded"],["kandan.codex_notification_push_failed","linzumi.codex_notification_push_failed"],["kandan.codex_output_forwarded","linzumi.codex_output_forwarded"],["kandan.codex_reasoning_delta_forwarded","linzumi.codex_reasoning_delta_forwarded"],["kandan.codex_web_search_progress_forwarded","linzumi.codex_web_search_progress_forwarded"],["kandan.connection_force_reconnect","linzumi.connection_force_reconnect"],["kandan.connection_force_reconnect_dispatched","linzumi.connection_force_reconnect_dispatched"],["kandan.connection_hard_reset","linzumi.connection_hard_reset"],["kandan.connection_hard_reset_exhausted","linzumi.connection_hard_reset_exhausted"],["kandan.connection_recovered","linzumi.connection_recovered"],["kandan.connection_stale","linzumi.connection_stale"],["kandan.connection_unrecoverable","linzumi.connection_unrecoverable"],["kandan.control","linzumi.control"],["kandan.control_ack_withheld_on_failure","linzumi.control_ack_withheld_on_failure"],["kandan.control_epoch_changed","linzumi.control_epoch_changed"],["kandan.control_handler_threw","linzumi.control_handler_threw"],["kandan.control_ignored","linzumi.control_ignored"],["kandan.control_response_push_failed","linzumi.control_response_push_failed"],["kandan.failed_seq_overflow","linzumi.failed_seq_overflow"],["kandan.forward_port_revoked_push_failed","linzumi.forward_port_revoked_push_failed"],["kandan.forward_response","linzumi.forward_response"],["kandan.forward_response_push_failed","linzumi.forward_response_push_failed"],["kandan.forward_tunnel_error","linzumi.forward_tunnel_error"],["kandan.forward_tunnel_open_failed","linzumi.forward_tunnel_open_failed"],["kandan.heartbeat_push_failed","linzumi.heartbeat_push_failed"],["kandan.local_editor_initial_status_failed","linzumi.local_editor_initial_status_failed"],["kandan.local_editor_status_push_failed","linzumi.local_editor_status_push_failed"],["kandan.message_duplicate_ignored","linzumi.message_duplicate_ignored"],["kandan.message_ignored","linzumi.message_ignored"],["kandan.message_queued","linzumi.message_queued"],["kandan.message_spawn_on_miss","linzumi.message_spawn_on_miss"],["kandan.message_spawn_on_miss_failed","linzumi.message_spawn_on_miss_failed"],["kandan.message_state_refresh_failed","linzumi.message_state_refresh_failed"],["kandan.optional_push_failed","linzumi.optional_push_failed"],["kandan.post_stop_queue_drain_failed","linzumi.post_stop_queue_drain_failed"],["kandan.queue_drain_blocked","linzumi.queue_drain_blocked"],["kandan.queue_drain_dead_worker_fail_publish_failed","linzumi.queue_drain_dead_worker_fail_publish_failed"],["kandan.queue_drain_dead_worker_rebuild","linzumi.queue_drain_dead_worker_rebuild"],["kandan.queue_drain_dead_worker_rebuild_exhausted","linzumi.queue_drain_dead_worker_rebuild_exhausted"],["kandan.queue_drain_dead_worker_rebuild_failed","linzumi.queue_drain_dead_worker_rebuild_failed"],["kandan.reconnect_handling_failed","linzumi.reconnect_handling_failed"],["kandan.reconnect_thread_context_fetch_failed","linzumi.reconnect_thread_context_fetch_failed"],["kandan.reconnect_thread_cwd_failed_state_push_failed","linzumi.reconnect_thread_cwd_failed_state_push_failed"],["kandan.reconnect_thread_failed","linzumi.reconnect_thread_failed"],["kandan.reconnect_thread_processing_state_push_failed","linzumi.reconnect_thread_processing_state_push_failed"],["kandan.reconnect_thread_queue_closed_state_push_failed","linzumi.reconnect_thread_queue_closed_state_push_failed"],["kandan.reconnect_thread_queue_failed_state_push_failed","linzumi.reconnect_thread_queue_failed_state_push_failed"],["kandan.reconnect_thread_queue_state_push_failed","linzumi.reconnect_thread_queue_state_push_failed"],["kandan.reconnect_thread_rehydrate_forced","linzumi.reconnect_thread_rehydrate_forced"],["kandan.reconnect_thread_rehydrated","linzumi.reconnect_thread_rehydrated"],["kandan.reconnect_thread_rehydrated_state_push_failed","linzumi.reconnect_thread_rehydrated_state_push_failed"],["kandan.reconnect_thread_rehydration_failed","linzumi.reconnect_thread_rehydration_failed"],["kandan.reconnect_thread_rehydration_ir_emitted","linzumi.reconnect_thread_rehydration_ir_emitted"],["kandan.reconnect_thread_rehydration_items_failed","linzumi.reconnect_thread_rehydration_items_failed"],["kandan.reconnect_thread_resume_failed","linzumi.reconnect_thread_resume_failed"],["kandan.reconnect_thread_seq_already_applied","linzumi.reconnect_thread_seq_already_applied"],["kandan.reconnect_thread_transcript_fetch_failed","linzumi.reconnect_thread_transcript_fetch_failed"],["kandan.reconnect_thread_unarchive_failed","linzumi.reconnect_thread_unarchive_failed"],["kandan.reconnect_thread_unarchive_resumed","linzumi.reconnect_thread_unarchive_resumed"],["kandan.reconnect_thread_unarchive_started","linzumi.reconnect_thread_unarchive_started"],["kandan.reconnect_thread_unavailable_state_push_failed","linzumi.reconnect_thread_unavailable_state_push_failed"],["kandan.reconnected","linzumi.reconnected"],["kandan.roster_seeded","linzumi.roster_seeded"],["kandan.session_app_server_lost_push_failed","linzumi.session_app_server_lost_push_failed"],["kandan.session_settings_publish_failed","linzumi.session_settings_publish_failed"],["kandan.start_instance_claude_code_attachment_failed_state_push_failed","linzumi.start_instance_claude_code_attachment_failed_state_push_failed"],["kandan.start_instance_codex_app_server_unavailable","linzumi.start_instance_codex_app_server_unavailable"],["kandan.start_instance_cwd_failed_state_push_failed","linzumi.start_instance_cwd_failed_state_push_failed"],["kandan.start_instance_cwd_rejected","linzumi.start_instance_cwd_rejected"],["kandan.start_instance_failed","linzumi.start_instance_failed"],["kandan.start_instance_processing_state_push_failed","linzumi.start_instance_processing_state_push_failed"],["kandan.start_instance_skipped_known_session","linzumi.start_instance_skipped_known_session"],["kandan.start_instance_stale_skipped","linzumi.start_instance_stale_skipped"],["kandan.start_instance_unavailable_state_push_failed","linzumi.start_instance_unavailable_state_push_failed"],["kandan.start_instance_wafer_state_push_failed","linzumi.start_instance_wafer_state_push_failed"],["kandan.start_turn_replay_skipped","linzumi.start_turn_replay_skipped"],["kandan.steer_duplicate_ignored","linzumi.steer_duplicate_ignored"],["kandan.steer_parked_as_own_turn","linzumi.steer_parked_as_own_turn"],["kandan.thread_bind_from_historical_reply_failed","linzumi.thread_bind_from_historical_reply_failed"],["kandan.thread_bound_from_historical_reply","linzumi.thread_bound_from_historical_reply"],["kandan.thread_sessions_reannounce_failed","linzumi.thread_sessions_reannounce_failed"],["kandan.thread_sessions_reannounced","linzumi.thread_sessions_reannounced"],["kandan.tui_input_mirrored","linzumi.tui_input_mirrored"],["kandan.typing_heartbeat_failed","linzumi.typing_heartbeat_failed"],["kandan.typing_stop_after_completion_failed","linzumi.typing_stop_after_completion_failed"]],sP=[["codexThreadId","harness_session_id"],["codex_thread_id","harness_session_id"],["kandanThreadId","thread_id"],["kandan_preview_ticket","linzumi_preview_ticket"],["kandan_thread_id","thread_id"],["linzumiThreadId","thread_id"],["linzumi_thread_id","thread_id"],["local_codex_runner","commander"],["runnerId","commander_id"],["runner_config","commander_config"],["runner_id","commander_id"]],Mm=[["commander","local_codex_runner"],["commander_config","runner_config"],["commander_id","runner_id"],["harness_session_id","codex_thread_id"],["linzumi_preview_ticket","kandan_preview_ticket"],["thread_id","kandan_thread_id"]],Ov=[["engine_boot_reconnect","harness_boot_reconnect"],["engine_for_runner_event_type","harness_for_commander_event_type"],["engine_rejected_steer","harness_rejected_steer"],["engine_unavailable","harness_unavailable"],["join_engine","join_harness"],["kandan-local-codex-runner","linzumi-commander"],["local_codex_runner","commander"],["original_engine","original_harness"],["resume_engine","resume_harness"]];function ku(){return x("1.0.146","0.0.0-unbundled")}function Ev(){return"linzumi "+x("1.0.146","0.0.0-unbundled")}function bl(e,t){let r=e.indexOf(t);if(r!==-1)return r}function Pv(){let e=process.env.LINZUMI_NAMING_DUAL_EMIT;if(e===void 0)return!0;let t=e.trim().toLowerCase();return t!=="0"?t!=="false":!1}function Rv(e){let t={};return e.forEach(r=>{t[r[0]]=r[1]}),t}function S4(e){let t={};return e.forEach(r=>{t[r[1]]=r[0]}),t}var uP=Rv(sP),cP=Rv(Mm),w4=Rv(Ov),k4=S4(Ov);function x4(e){return e.endsWith("_canonical")?!0:e.endsWith("_legacy")}function fP(e,t){return t>=32?e:Array.isArray(e)?e.map(r=>fP(r,t+1|0)):e===null?e:typeof e==="object"?mP(e,t):e}function mP(e,t){let r=Object.keys(e),n={};return r.forEach(i=>{let o=e[i];if(o!==void 0){n[i]=fP(o,t+1|0);return}}),r.forEach(i=>{if(x4(i))return;let o=n[i];if(o===void 0)return;let a=uP[i];if(a!==void 0)n[a]=o;else{let c=cP[i];c!==void 0&&(n[c]!==void 0||(n[c]=o))}let s=n[i];if(s===void 0||typeof s!="string")return;let l=w4[s];if(l!==void 0){if(n[i+"_canonical"]!==void 0)return;n[i+"_canonical"]=l;return}let d=k4[s];if(!(d===void 0||n[i+"_legacy"]!==void 0)){n[i+"_legacy"]=d;return}}),n}function jm(e){return Pv()?mP(e,0):e}function pP(e){let t=e.slice();return e.forEach(r=>{let n=uP[r];n!==void 0&&!t.includes(n)&&t.push(n);let i=cP[r];if(i!==void 0&&!t.includes(i)){t.push(i);return}}),t}var vl="<SENSITIVE_DATA>",T4=pP(["access_token","authorization","code","cookie","kandan_preview_ticket","refresh_token","token"]),A4=["--access-token","--api-key","--authorization","--cookie","--oauth-code","--password","--refresh-token","--secret","--token"],O4=new RegExp("^(authorization|cookie|set-cookie|password)$","i"),C4=new RegExp("(^|[_-])(access[_-]?token|api[_-]?key|auth[_-]?token|oauth[_-]?code|refresh[_-]?token|secret|token)$","i"),E4=new RegExp("\\beyJ[A-Za-z0-9_-]*\\.[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\b","g");function P4(e){return e!==void 0?O4.test(e)?!0:C4.test(e):!1}function hP(e){let t={contents:!1};return Gw(e).forEach(r=>{if(T4.includes(r.toLowerCase())){e.set(r,vl),t.contents=!0;return}}),t.contents}function R4(e){let t=bl(e,"?"),r=bl(e,"#");if(t===void 0||r!==void 0&&r<t)return e;let n=e.slice(0,t),i=r!==void 0?e.slice(t+1|0,r):e.slice(t+1|0),o=r!==void 0?e.slice(r):"",a=new URLSearchParams(i);return hP(a)?n+"?"+a.toString()+o:e}function I4(e){let t=Ln(e);if(t===void 0)return R4(e);let r=ue(t);return hP(r.searchParams),r.toString()}function _P(e){return I4(e).replace(E4,vl)}function $4(e){let t=bl(e,"=");return t!==void 0?[e.slice(0,t),e.slice(t+1|0)]:[e,void 0]}function $v(e,t){if(P4(t))return vl;if(Array.isArray(e))return t==="args"?M4(e):e.map(r=>$v(r,void 0));if(e===null)return e;switch(typeof e){case"string":return _P(e);case"object":return gP(e);default:return e}}function M4(e){let t={contents:!1};return e.map(r=>{if(typeof r=="string"){if(t.contents)return t.contents=!1,vl;let n=$4(r),i=n[0];return A4.includes(i)?n[1]!==void 0?i+"="+vl:(t.contents=!0,r):_P(r)}return t.contents=!1,$v(r,void 0)})}function gP(e){let t=e.name,r=typeof t=="string"?t.toLowerCase():void 0,n;if(r!==void 0)switch(r){case"authorization":case"cookie":case"set-cookie":n=!0;break;default:n=!1}else n=!1;let i={};return Object.entries(e).forEach(o=>{let a=o[0];if(a!=="runner_console"){i[a]=n&&a==="value"?vl:$v(o[1],a);return}}),i}var zm=gP;import*as ta from"node:os";import*as jp from"node:path";import*as gw from"node:crypto";function jn(e){let t=parseFloat(e);if(!Number.isNaN(t))return t}function bP(e){return"local_runner:"+e}var j4="kandan-local-codex-runner",z4="rescript";function vP(e){let t={};t.clientName=j4,t.clientId=e.clientId;let r=e.machineFingerprint;t.machineFingerprint=r!==void 0?r:null,Object.entries(ck(e.machineFingerprintV2)).forEach(a=>{t[a[0]]=a[1]}),t.runnerPid=e.runnerPid,t.version=e.version,t.hostname=e.hostname,t.cwd=e.cwd;let n=e.workspace;t.workspace=n!==void 0?n:null;let i=e.channel;t.channel=i!==void 0?i:null,t.capabilities=e.capabilities;let o=e.generationOverlapEpoch;if(o!==void 0){let a={};a.epoch=o,a.overlap=!0,t.generation=a}return t.commander_impl=z4,t}function SP(e,t,r){let n={};return n.last_seq=r,t!==void 0&&(n.runner_id=e,n.thread_id=t),n}function zn(e,t){return e.catch(r=>t(ee(r)))}function kP(){let e=[],t=[],r={contents:!1},n=()=>{let a=e.shift();return a!==void 0?Promise.resolve({done:!1,value:a}):r.contents?Promise.resolve({done:!0}):new Promise((s,l)=>{t.push(s)})},i=()=>(r.contents=!0,Promise.resolve({done:!0})),o={};return o[Symbol.asyncIterator]=()=>({next:n,return:i}),{iterable:o,push:a=>{if(r.contents)return!1;let s=t.shift();return s!==void 0?(s({done:!1,value:a}),!0):(e.push(a),!0)},close:()=>{r.contents=!0,(()=>{for(;;){let s=t.shift();if(s===void 0)return;s({done:!0})}})()}}}function xP(e){return import(e)}var G4="@anthropic-ai/claude-agent-sdk";function TP(e){return kP()}function F4(e){return{next:()=>e.next(),close:()=>{e.close()},interrupt:()=>e.interrupt(),setModel:t=>e.setModel(t),setPermissionMode:t=>e.setPermissionMode(t),applyFlagSettings:t=>e.applyFlagSettings(t),supportedCommands:()=>e.supportedCommands()}}async function AP(){let e=await xP(G4);return{query:t=>F4(e.query(t)),getSessionInfo:(t,r)=>e.getSessionInfo(t,r),listSessions:t=>e.listSessions(t),getSessionMessages:(t,r)=>e.getSessionMessages(t,r)}}var Mv=["codex","claude-code","pi","opencode"];function Ya(e){return e}function Nm(e){switch(e.TAG){case"SessionStarted":return"session_started";case"TurnStarted":return"turn_started";case"ItemStarted":return"item_started";case"ItemDelta":return"item_delta";case"ItemCompleted":return"item_completed";case"ApprovalRequested":return"approval_requested";case"UsageUpdated":return"usage_updated";case"RateLimitUpdated":return"rate_limit_updated";case"ActivityPulse":return"activity_pulse";case"TurnCompleted":return"turn_completed";case"TurnFailed":return"turn_failed";case"TurnInterrupted":return"turn_interrupted";case"HarnessDied":return"harness_died"}}function D4(e){switch(e){case"SocketOpen":return"open";case"SocketMessage":return"message";case"SocketClose":return"close";case"SocketError":return"error"}}function q4(e){let t=e.data,r;r=t==null||typeof t!="string"?void 0:t;let n=e.code,i;i=n==null||typeof n!="number"||(n|0)!==n?void 0:n|0;let o=e.reason,a;return a=o==null||typeof o!="string"?void 0:o,{data:r,code:i,reason:a}}function L4(e){return{readyState:()=>e.readyState,send:t=>{e.send(t)},close:()=>{e.close()},on:(t,r)=>{e.addEventListener(D4(t),n=>r(q4(n)),{})}}}function Gm(e,t){return L4(new WebSocket(e,t))}var CP=0,Xa=1;var jv="file",zv=["mcp_oauth_credentials_store","cli_auth_credentials_store"],U4=zv.flatMap(e=>["-c",e+'="'+jv+'"']),W4=["-c","features.apps=false"];function po(e){return JSON.stringify(e)}function Z4(e){let t=(r,n)=>r!==void 0?Object.entries(r).flatMap(i=>["-c","model_providers."+e.id+"."+n+"."+i[0]+"="+po(i[1])]):[];return[["-c","model_providers."+e.id+".name="+po(e.name),"-c","model_providers."+e.id+".base_url="+po(e.baseUrl),"-c","model_providers."+e.id+".env_key="+po(e.envKey),"-c","model_providers."+e.id+".wire_api="+po(e.wireApi)],t(e.httpHeaders,"http_headers"),t(e.envHttpHeaders,"env_http_headers"),["-c","model_provider="+po(e.id)]].flat()}function V4(e){let t=e.model,r=e.reasoningEffort,n=e.modelProvider;return[W4,U4,t!==void 0?["-c","model="+po(t)]:[],r!==void 0?["-c","model_reasoning_effort="+po(r)]:[],e.fast?["-c","service_tier="+po("fast")]:[],e.mcpConfigArgs.flat(),n!==void 0?Z4(n):[]].flat()}function PP(e,t){return[["app-server"],V4(t),["--listen",e]].flat()}var H4=["LINZUMI_MCP_ACCESS_TOKEN","LINZUMI_MCP_OWNER_USERNAME"];function RP(e,t,r){let n=r?Object.fromEntries(Object.entries(e)):{};return H4.forEach(i=>fr(n,i)),t.forEach(i=>{let o=i[1],a=i[0];if(o!==void 0){n[a]=o;return}else return fr(n,a)}),n}var IP=["ignore","pipe","pipe"];function $P(e){let t=e.length;return t>12e3?e.slice(t-12e3|0,t):e}function MP(e,t,r){return r<3&&e.includes("codex app-server exited before readyz")&&t.includes("EADDRINUSE")?t.includes("listen"):!1}function jP(e){let t=Ln(e);if(t===void 0)return;let r=ue(t),i=r.protocol==="wss:"?"https:":"http:";return r.protocol=i,r.pathname="/readyz",r.search="",r.hash="",r.toString()}var B4="kandan-local-codex-runner",K4="0.0.1";function zP(){return Object.fromEntries([["clientInfo",Object.fromEntries([["name",B4],["version",K4]])],["capabilities",Object.fromEntries([["experimentalApi",!0]])]])}var J4=new RegExp("\\bsession\\b.+\\bis archived\\b","i");function NP(e){return J4.test(e)}var Y4=new RegExp("^thread not found(?:\\s*:|\\b)","i");function GP(e){return Y4.test(e.trim())}var FP=2e3;function X4(e){try{e.unref();return}catch{return}}var DP="codex app-server websocket closed",Q4="codex app-server websocket is not open";function eH(e){let t=e.method;if(typeof t=="string")return t}function Nv(e){let t=e.error;if(t===void 0)return{TAG:"ResultReply",_0:x(e.result,null)};if(typeof t!="object"||t===null||Array.isArray(t))return{TAG:"ErrorReply",code:0,message:JSON.stringify(t)};let r=t.code,n=r!==void 0&&typeof r=="number"?r:0,i=t.message;return{TAG:"ErrorReply",code:n,message:typeof i=="string"?i:""}}function Dm(e,t,r,n){let i=JSON.stringify(n);t(r,i);try{return e.socket.send(i),{TAG:"Ok",_0:void 0}}catch(o){let a=ee(o);return{TAG:"Error",_0:Ne(a).message}}}function WP(e,t,r){try{return t(r)}catch(n){let i=ee(n);return e("codex.notification_callback_failed",Object.fromEntries([["purpose","codex.app_server"],["method",r.method],["message",Ne(i).message]]))}}function qP(e,t,r){try{return t(r)}catch(n){let i=ee(n);return e("codex.close_callback_failed",Object.fromEntries([["purpose","codex.app_server"],["message",Ne(i).message]]))}}function tH(e,t){let r;if(t.TAG==="Ok")r=[["jsonrpc","2.0"],["id",e],["result",t._0]];else{let n=t._0;r=[["jsonrpc","2.0"],["id",e],["error",Object.fromEntries([["code",n[0]],["message",n[1]]])]]}return Object.fromEntries(r)}async function rH(e,t,r,n){let i={TAG:"Error",_0:[-32601,"unhandled Codex app-server request: "+n.method]},o=e.requestCallbacks.slice(),a,s=0;for(;mn(a)&&s<o.length;){let d=o[s];if(d!==void 0){let u=0,c;try{c=await d(n),u=1}catch(f){let p=ee(f);a={TAG:"Error",_0:[-32e3,Ne(p).message]}}u===1&&c!==void 0&&(a={TAG:"Ok",_0:c})}s=s+1|0}let l=x(a,i);Dm(t,r,"outgoing",tH(n.id,l))}function nH(e,t,r,n,i){let o;try{o=JSON.parse(i)}catch(p){let m=ee(p);r("codex.app_server_frame_malformed",Object.fromEntries([["purpose","codex.app_server"],["message",Ne(m).message],["payload",i.slice(0,512)],["payloadChars",i.length]])),o=void 0}let a;if(o!==void 0){let p=0;typeof o=="object"&&o!==null&&!Array.isArray(o)?a=o:p=1,p===1&&(r("codex.app_server_frame_malformed",Object.fromEntries([["purpose","codex.app_server"],["message","codex app-server sent non-object JSON-RPC message"],["payload",i.slice(0,512)],["payloadChars",i.length]])),a=void 0)}else a=void 0;if(a===void 0)return;let s=Dt(a.id),l=s&&(Dt(a.result)||Dt(a.error)),d=eH(a);if(l){let p=x(a.id,null),m=JSON.stringify(p),h=e.pending[m];return h!==void 0?(fr(e.pending,m),h.resolvePending({TAG:"Ok",_0:Nv(a)})):void 0}if(s)if(d!==void 0){zn(rH(e,t,n,{id:x(a.id,null),method:d,params:a.params}),p=>Promise.resolve());return}else return;if(d===void 0)return;let u=a.params,c={method:d,params:u};e.notificationCallbacks.length!==0?e.notificationCallbacks.forEach(p=>WP(r,p,c)):e.pendingNotifications.push(c)}function iH(e,t,r){return Object.fromEntries(r!==void 0?[["jsonrpc","2.0"],["id",e],["method",t],["params",r]]:[["jsonrpc","2.0"],["id",e],["method",t]])}function LP(e,t){return Object.fromEntries(t!==void 0?[["jsonrpc","2.0"],["method",e],["params",t]]:[["jsonrpc","2.0"],["method",e]])}function UP(e,t,r,n,i,o){return t.socket.readyState()===Xa?new Promise((a,s)=>{e.pending[JSON.stringify(n)]={resolvePending:a};let l=Dm(t,r,"request",iH(n,i,o));l.TAG!=="Ok"&&(fr(e.pending,JSON.stringify(n)),a({TAG:"Error",_0:l._0}))}):Promise.resolve({TAG:"Error",_0:Q4})}async function qm(e,t,r,n){let i=t!==void 0?t:u=>({socket:Gm(u,[]),ping:void 0}),o=r!==void 0?r:2e3,a=n!==void 0?n:()=>Date.now(),s=a()+o,l,d="websocket open failed";for(;mn(l);){let u;try{u={TAG:"Ok",_0:i(e)}}catch(c){let f=ee(c);u={TAG:"Error",_0:Ne(f).message}}if(u.TAG==="Ok"){let c=u._0;if(await new Promise((f,p)=>{c.socket.on("SocketOpen",m=>f(!0)),c.socket.on("SocketError",m=>f(!1))}))l={TAG:"Ok",_0:c};else{try{c.socket.close()}catch{}a()>s&&(l={TAG:"Error",_0:d})}}else d=u._0,a()>s&&(l={TAG:"Error",_0:d})}return x(l,{TAG:"Error",_0:d})}async function Lm(e,t){let r={pending:{},notificationCallbacks:[],requestCallbacks:[],pendingNotifications:[],closeCallbacks:[],nextId:1,closeError:void 0},n=t.audit,i=t.onWire,o=setInterval(()=>{let d=e.ping;if(d!==void 0&&e.socket.readyState()===Xa)try{return d()}catch{return}},t.keepaliveIntervalMs);X4(o);let a=d=>{clearInterval(o);let u=Object.entries(r.pending);if(Object.entries(r.pending).forEach(p=>fr(r.pending,p[0])),u.forEach(p=>p[1].resolvePending({TAG:"Error",_0:d})),r.closeError!==void 0)return;r.closeError=d;let f=r.closeCallbacks.slice();r.closeCallbacks.splice(0,r.closeCallbacks.length),f.forEach(p=>qP(n,p,d))};e.socket.on("SocketClose",d=>a(DP)),e.socket.on("SocketError",d=>a(DP)),e.socket.on("SocketMessage",d=>{let u=d.data;if(u!==void 0)return i("incoming",u),nH(r,e,n,i,u)});let s=await UP(r,e,i,"initialize","initialize",zP());if(s.TAG!=="Ok")return{TAG:"Error",_0:s._0};let l=s._0;return l.TAG!=="ResultReply"?{TAG:"Error",_0:"codex initialize failed: "+l.message}:(Dm(e,i,"outgoing",LP("initialized",void 0)),{TAG:"Ok",_0:{request:(d,u)=>{let c=r.nextId;return r.nextId=r.nextId+1|0,UP(r,e,i,c,d,u)},notify:(d,u)=>{Dm(e,i,"outgoing",LP(d,u))},onNotification:d=>{r.notificationCallbacks.push(d);let u=r.pendingNotifications.slice();r.pendingNotifications.splice(0,r.pendingNotifications.length),u.forEach(c=>WP(n,d,c))},onRequest:d=>{r.requestCallbacks.push(d)},onClose:d=>{let u=r.closeError;if(u!==void 0)return qP(n,d,u);r.closeCallbacks.push(d)},isClosed:()=>Dt(r.closeError),close:()=>{clearInterval(o);try{return e.socket.close()}catch{return}}}})}function xl(e){if(typeof e=="object"&&e!==null&&!Array.isArray(e))return e}function Li(e){if(e!==void 0&&typeof e=="string"&&e.trim()!=="")return e.trim()}function kl(e){if(e!==void 0&&typeof e=="number"&&Ot(e))return e}function ZP(e){if(typeof e=="object"&&e!==null&&!Array.isArray(e))return e}var VP="linzumi_thread_codex_worker_ready",HP="linzumi_thread_codex_worker_session_closed",BP="linzumi_thread_codex_worker_request",KP="linzumi_thread_codex_worker_notify",qv="linzumi_thread_codex_worker_response",JP="linzumi_thread_codex_worker_notification",YP="linzumi_thread_codex_worker_server_request",XP="linzumi_thread_codex_worker_server_request_response";function QP(e,t){let r={};return r.type=VP,r.kandanThreadId=e,r.commanderManagedPorts=t.map(n=>{let i={};i.port=n.port;let o=n.pid;o!==void 0&&(i.pid=o);let a=n.processName;a!==void 0&&(i.processName=a);let s=n.processIconKey;s!==void 0&&(i.processIconKey=s);let l=n.agentProvider;return l!==void 0&&(i.agentProvider=l),i}),r}function eR(e,t){let r={};return r.type=HP,r.kandanThreadId=e,r.reason=t,r}function oH(e,t,r){let n={};return n.type=BP,n.id=e,n.method=t,r!==void 0&&(n.params=r),n}function aH(e,t){let r={};return r.type=KP,r.method=e,t!==void 0&&(r.params=t),r}function sH(e,t){let r={};return r.type=qv,r.id=e,r.response=t,r}function lH(e,t){let r={};return r.type=qv,r.id=e,r.error=t,r}function dH(e){let t={};return t.type=JP,t.notification=e,t}function uH(e,t){let r={};return r.type=YP,r.id=e,r.request=t,r}function Fv(e,t,r){let n={};return n.type=XP,n.id=e,t!==void 0&&(n.result=t),r!==void 0&&(n.error=r),n}function cH(e){if(e===void 0||typeof e!="object"||e===null||Array.isArray(e)||e.id===void 0)return;let r=e.result,n=e.error;if(r!==void 0||n!==void 0)return e}function fH(e){if(e===void 0||typeof e!="object"||e===null||Array.isArray(e))return;let t=e.id,r=e.method;if(!(t!==void 0||typeof r!="string"))return e}function mH(e){if(e===void 0||typeof e!="object"||e===null||Array.isArray(e))return;let t=e.id,r=e.method;if(t!==void 0&&typeof r=="string")return e}function pH(e){let t=xl(e);if(t===void 0)return;let r=t.type;if(r===void 0||typeof r!="string")return;if(r===BP){let i=kl(t.id),o=Li(t.method);return i!==void 0&&o!==void 0?{TAG:"ParentRequest",id:i,method_:o,params:ZP(t.params)}:void 0}if(r===KP){let i=Li(t.method);return i!==void 0?{TAG:"ParentNotify",method_:i,params:ZP(t.params)}:void 0}if(r!==XP)return;let n=kl(t.id);if(n!==void 0)return{TAG:"ParentServerRequestResponse",id:n,result:t.result,error:Li(t.error)}}function hH(e){let t=xl(e);if(t===void 0)return;let r=t.type;if(r===void 0||typeof r!="string")return;if(r===qv){let o=kl(t.id);return o!==void 0?{TAG:"ChildResponse",id:o,response:cH(t.response),error:Li(t.error)}:void 0}if(r===JP){let o=fH(t.notification);return o!==void 0?{TAG:"ChildNotification",notification:o}:void 0}if(r!==YP)return;let n=kl(t.id),i=mH(t.request);if(n!==void 0&&i!==void 0)return{TAG:"ChildServerRequest",id:n,request:i}}function tR(e){let t=xl(e);if(t===void 0)return;let r=t.type;if(typeof r=="string"&&r===HP)return[x(Li(t.kandanThreadId),""),x(Li(t.reason),"")]}var _H="thread Codex worker reported invalid ready payload";function gH(e){let t=Li(e);if(t!==void 0)switch(t){case"claude-code":return"claude-code";case"codex":return"codex";default:return}}function yH(e){return e!==void 0?Array.isArray(e)?$e(e,t=>{let r=xl(t);if(r===void 0)return;let n=kl(r.port);if(n!==void 0&&n>=1&&n<=65535)return{port:n,pid:kl(r.pid),processName:Li(r.processName),processIconKey:Li(r.processIconKey),agentProvider:gH(r.agentProvider)}}):[]:[]}function rR(e,t){let r=xl(e);if(r===void 0)return{TAG:"Ok",_0:void 0};let n=r.type;if(n===void 0)return{TAG:"Ok",_0:void 0};if(typeof n!="string")return{TAG:"Ok",_0:void 0};if(n!==VP)return{TAG:"Ok",_0:void 0};let i=Li(r.kandanThreadId);return i!==void 0&&i===t?{TAG:"Ok",_0:{kandanThreadId:i,commanderManagedPorts:yH(r.commanderManagedPorts)}}:{TAG:"Error",_0:_H}}function nR(e,t){}var iR="linzumi.thread_runner",bH="thread Codex worker requires a codex client with onRequest",Dv="thread Codex worker IPC channel closed";function oR(e,t,r){let n=r!==void 0?r:nR,i=e.onRequest;if(i===void 0)return{TAG:"Error",_0:bH};let o=new Map,a={contents:1},s={contents:!1},l=u=>{if(s.contents)return;s.contents=!0;let c={};c.purpose=iR,c.reason=u,n("thread_codex_worker.ipc_send_dropped",c)},d=u=>{let c=t.send,f=t.isConnected();if(c===void 0||!f)return l("ipc_channel_closed");let p=c(u);if(p.TAG!=="Ok")return l(p._0)};return t.onMessage(u=>{let c=pH(u);if(c!==void 0)switch(c.TAG){case"ParentRequest":let f=c.id;e.request(c.method_,c.params).then(_=>_.TAG==="Ok"?d(sH(f,_._0)):d(lH(f,_._0)));return;case"ParentNotify":return e.notify(c.method_,c.params);case"ParentServerRequestResponse":let p=c.error,m=c.id,h=o.get(m);return h!==void 0?(o.delete(m),h(p!==void 0?{TAG:"Error",_0:p}:{TAG:"Ok",_0:c.result})):void 0}}),e.onNotification(u=>d(dH(u))),i(u=>new Promise((c,f)=>{let p=a.contents;a.contents=p+1,o.set(p,c),d(uH(p,u))})),t.onceDisconnect(()=>{o.forEach(u=>u({TAG:"Error",_0:Dv})),o.clear()}),{TAG:"Ok",_0:void 0}}var vH="thread Codex worker IPC client is closed",SH="thread Codex worker response missing body",wH="thread Codex worker IPC client closed";async function kH(e,t,r,n,i,o){let a=d=>{let u=e(d);if(u.TAG==="Ok")return;let c={};c.purpose=iR,c.requestMethod=n,c.message=u._0,o("thread_codex_worker.ipc_response_dropped",c)},s=!1,l=0;for(;!s&&l<i.length;){let d=i[l];if(d!==void 0){let u=await d(r);if(u.TAG==="Ok"){let c=u._0;c!==void 0&&(s=!0,a(Fv(t,c,void 0)))}else s=!0,a(Fv(t,void 0,u._0))}l=l+1|0}if(!s)return a(Fv(t,void 0,"unhandled Codex app-server request: "+n))}function xH(e){let t=xl(e);if(t===void 0)return"";let r=t.method;return typeof r=="string"?r:""}function aR(e,t){let r=t!==void 0?t:nR,n=new Map,i=[],o=[],a=[],s={contents:1},l={contents:!1},d=_=>{n.forEach(g=>g({TAG:"Error",_0:_})),n.clear()},u=_=>{if(l.contents)return{TAG:"Error",_0:vH};let g=e.send,b=e.isConnected();return g!==void 0&&b?g(_):{TAG:"Error",_0:Dv}},c=_=>{let g=hH(_);if(g!==void 0)switch(g.TAG){case"ChildResponse":let b=g.error,y=g.response,v=g.id,S=n.get(v);return S!==void 0?(n.delete(v),S(b!==void 0?{TAG:"Error",_0:b}:y!==void 0?{TAG:"Ok",_0:y}:{TAG:"Error",_0:SH})):void 0;case"ChildNotification":let A=g.notification;i.length!==0?i.forEach(L=>L(A)):a.push(A);return;case"ChildServerRequest":let W=g.request;kH(u,g.id,W,xH(W),o,r);return}},f=e.onMessage(c),p=()=>{l.contents=!0,d(Dv)},m=e.onceExit(p),h=e.onceDisconnect(p);return{request:(_,g)=>new Promise((b,y)=>{let v=s.contents;s.contents=v+1,n.set(v,b);let S=u(oH(v,_,g));S.TAG!=="Ok"&&(n.delete(v),b({TAG:"Error",_0:S._0}))}),notify:(_,g)=>u(aH(_,g)),onNotification:_=>{i.push(_);let g=a.slice();a.splice(0,a.length),g.forEach(b=>_(b))},onRequest:_=>{o.push(_)},isClosed:()=>l.contents?!0:!e.isConnected(),close:()=>{l.contents=!0,f(),m(),h(),d(wH)}}}import*as Bv from"node:child_process";import*as lR from"node:os";import*as dR from"node:path";function uR(){return dR.join(lR.homedir(),".linzumi","protected-dev-listeners")}var TH=new RegExp("^(\\d+)\\s+(\\d+)$");function AH(e){return $e(e.split(`
|
|
324
|
+
`}function y4(e,t){}function $m(e,t,r,n,i,o){let a=o!==void 0?o:y4;if(e!==void 0)return{TAG:"Ok",_0:{codexBin:e,source:"ExplicitFlag"}};let s=u4(t);if(s!==void 0){let f={};return f.codex_bin_path=s,f.codex_bin_source="bundled",a("codex.binary.resolved",f),{TAG:"Ok",_0:{codexBin:s,source:"Bundled"}}}_4(r);let l=c4(t),d=l!==void 0?n("codex"):void 0,u=m4(d,l),c={};switch(c.codex_bin_path="codex",c.codex_bin_source="path-fallback",c.harness_version_check=p4(u),u.TAG){case"Match":c.harness_version=u.version;break;case"Mismatch":c.path_harness_version=u.pathVersion,c.pinned_harness_version=u.pinnedVersion;break;case"Unverified":c.path_harness_version=rn(u.pathVersion,null,f=>f),c.pinned_harness_version=rn(u.pinnedVersion,null,f=>f);break}switch(a("codex.binary.resolved",c),u.TAG){case"Mismatch":let f=u.pinnedVersion,p=u.pathVersion,m=i[kv];return m===void 0?{TAG:"Error",_0:XE(p,f)}:m!=="1"?{TAG:"Error",_0:XE(p,f)}:(r(g4(p,f)),{TAG:"Ok",_0:{codexBin:"codex",source:"PathFallback"}});case"Match":case"Unverified":return{TAG:"Ok",_0:{codexBin:"codex",source:"PathFallback"}}}}function iP(e){if(typeof e=="number"&&e%1===0)return e}function b4(e){if(typeof e=="string")return e}function v4(e){let t=e.replaceAll("-","+").replaceAll("_","/");switch(t.length&3){case 2:return t+"==";case 3:return t+"=";default:return t}}function oP(e){let t=e.split(".")[1];if(t===void 0)return;let r=Buffer.from(v4(t),"base64").toString("utf8"),n;try{n=JSON.parse(r)}catch{n=void 0}if(typeof n=="object"&&n!==null&&!Array.isArray(n))return n}function wu(e){let t=oP(e);if(t===void 0)return{actorUserId:void 0,actorUsername:void 0};let r=iP(t.actor_id);return{actorUserId:r!==void 0?r:iP(t.sub),actorUsername:b4(t.actor_username)}}function aP(e){let t=k(oP(e),n=>n.workspace_scope),r=t!==void 0?Array.isArray(t)?$e(t,n=>{if(typeof n=="string"&&n.trim()!=="")return n}):[]:[];if(r.length===1)return r[0]}var Av=[["codex.agent_turn_narration_only_no_reply","harness.agent_turn_narration_only_no_reply"],["codex.cost_cap_402_seen","harness.cost_cap_402_seen"],["codex.edge_blocked_captured","harness.edge_blocked_captured"],["codex.empty_turn_auto_retry_suppressed_cost_cap","harness.empty_turn_auto_retry_suppressed_cost_cap"],["codex.empty_turn_loop_guard_tripped","harness.empty_turn_loop_guard_tripped"],["codex.error_without_http_status_captured","harness.error_without_http_status_captured"],["codex.mid_stream_stall_auto_resume_flagged","harness.mid_stream_stall_auto_resume_flagged"],["codex.mid_stream_stall_resume_suppressed_rate_limit","harness.mid_stream_stall_resume_suppressed_rate_limit"],["codex.mid_stream_stall_second_stall_after_resume","harness.mid_stream_stall_second_stall_after_resume"],["codex.pre_first_byte_stall_auto_retry_flagged","harness.pre_first_byte_stall_auto_retry_flagged"],["codex.pre_first_byte_stall_retry_suppressed_cost_cap","harness.pre_first_byte_stall_retry_suppressed_cost_cap"],["codex.provider_outage_flagged_captured","harness.provider_outage_flagged_captured"],["codex.reasoning_loop_breaker_tripped","harness.reasoning_loop_breaker_tripped"],["codex.tool_fatal_captured","harness.tool_fatal_captured"],["codex.turn_completed","job.turn_completed"],["codex.turn_completed_with_protocol_failure","job.turn_completed_with_protocol_failure"],["codex.turn_completed_with_unsupported_tool_call_ignored","job.turn_completed_with_unsupported_tool_call_ignored"],["codex.turn_completed_without_assistant_output","job.turn_completed_without_assistant_output"],["codex.turn_forward_failed","job.turn_forward_failed"],["codex.upstream_error_captured","harness.upstream_error_captured"],["codex.upstream_rejection_captured","harness.upstream_rejection_captured"],["codex.upstream_turn_error_captured","harness.upstream_turn_error_captured"],["kandan.chat_event","linzumi.chat_event"],["kandan.chat_event_abandoned","linzumi.chat_event_abandoned"],["kandan.chat_event_failed","linzumi.chat_event_failed"],["kandan.chat_event_failure_cleared","linzumi.chat_event_failure_cleared"],["kandan.claude_code_interrupt_state_push_failed","linzumi.claude_code_interrupt_state_push_failed"],["kandan.claude_code_stop_state_push_failed","linzumi.claude_code_stop_state_push_failed"],["kandan.claude_code_typing_heartbeat_failed","linzumi.claude_code_typing_heartbeat_failed"],["kandan.claude_code_typing_start_wait_timeout","linzumi.claude_code_typing_start_wait_timeout"],["kandan.claude_code_typing_stop_failed","linzumi.claude_code_typing_stop_failed"],["kandan.claude_code_user_input_abort_publish_failed","linzumi.claude_code_user_input_abort_publish_failed"],["kandan.claude_code_user_question_completed_publish_failed","linzumi.claude_code_user_question_completed_publish_failed"],["kandan.codex_command_output_forwarded","linzumi.codex_command_output_forwarded"],["kandan.codex_delta_forwarded","linzumi.codex_delta_forwarded"],["kandan.codex_file_change_forwarded","linzumi.codex_file_change_forwarded"],["kandan.codex_notification_push_failed","linzumi.codex_notification_push_failed"],["kandan.codex_output_forwarded","linzumi.codex_output_forwarded"],["kandan.codex_reasoning_delta_forwarded","linzumi.codex_reasoning_delta_forwarded"],["kandan.codex_web_search_progress_forwarded","linzumi.codex_web_search_progress_forwarded"],["kandan.connection_force_reconnect","linzumi.connection_force_reconnect"],["kandan.connection_force_reconnect_dispatched","linzumi.connection_force_reconnect_dispatched"],["kandan.connection_hard_reset","linzumi.connection_hard_reset"],["kandan.connection_hard_reset_exhausted","linzumi.connection_hard_reset_exhausted"],["kandan.connection_recovered","linzumi.connection_recovered"],["kandan.connection_stale","linzumi.connection_stale"],["kandan.connection_unrecoverable","linzumi.connection_unrecoverable"],["kandan.control","linzumi.control"],["kandan.control_ack_withheld_on_failure","linzumi.control_ack_withheld_on_failure"],["kandan.control_epoch_changed","linzumi.control_epoch_changed"],["kandan.control_handler_threw","linzumi.control_handler_threw"],["kandan.control_ignored","linzumi.control_ignored"],["kandan.control_response_push_failed","linzumi.control_response_push_failed"],["kandan.failed_seq_overflow","linzumi.failed_seq_overflow"],["kandan.forward_port_revoked_push_failed","linzumi.forward_port_revoked_push_failed"],["kandan.forward_response","linzumi.forward_response"],["kandan.forward_response_push_failed","linzumi.forward_response_push_failed"],["kandan.forward_tunnel_error","linzumi.forward_tunnel_error"],["kandan.forward_tunnel_open_failed","linzumi.forward_tunnel_open_failed"],["kandan.heartbeat_push_failed","linzumi.heartbeat_push_failed"],["kandan.local_editor_initial_status_failed","linzumi.local_editor_initial_status_failed"],["kandan.local_editor_status_push_failed","linzumi.local_editor_status_push_failed"],["kandan.message_duplicate_ignored","linzumi.message_duplicate_ignored"],["kandan.message_ignored","linzumi.message_ignored"],["kandan.message_queued","linzumi.message_queued"],["kandan.message_spawn_on_miss","linzumi.message_spawn_on_miss"],["kandan.message_spawn_on_miss_failed","linzumi.message_spawn_on_miss_failed"],["kandan.message_state_refresh_failed","linzumi.message_state_refresh_failed"],["kandan.optional_push_failed","linzumi.optional_push_failed"],["kandan.post_stop_queue_drain_failed","linzumi.post_stop_queue_drain_failed"],["kandan.queue_drain_blocked","linzumi.queue_drain_blocked"],["kandan.queue_drain_dead_worker_fail_publish_failed","linzumi.queue_drain_dead_worker_fail_publish_failed"],["kandan.queue_drain_dead_worker_rebuild","linzumi.queue_drain_dead_worker_rebuild"],["kandan.queue_drain_dead_worker_rebuild_exhausted","linzumi.queue_drain_dead_worker_rebuild_exhausted"],["kandan.queue_drain_dead_worker_rebuild_failed","linzumi.queue_drain_dead_worker_rebuild_failed"],["kandan.reconnect_handling_failed","linzumi.reconnect_handling_failed"],["kandan.reconnect_thread_context_fetch_failed","linzumi.reconnect_thread_context_fetch_failed"],["kandan.reconnect_thread_cwd_failed_state_push_failed","linzumi.reconnect_thread_cwd_failed_state_push_failed"],["kandan.reconnect_thread_failed","linzumi.reconnect_thread_failed"],["kandan.reconnect_thread_processing_state_push_failed","linzumi.reconnect_thread_processing_state_push_failed"],["kandan.reconnect_thread_queue_closed_state_push_failed","linzumi.reconnect_thread_queue_closed_state_push_failed"],["kandan.reconnect_thread_queue_failed_state_push_failed","linzumi.reconnect_thread_queue_failed_state_push_failed"],["kandan.reconnect_thread_queue_state_push_failed","linzumi.reconnect_thread_queue_state_push_failed"],["kandan.reconnect_thread_rehydrate_forced","linzumi.reconnect_thread_rehydrate_forced"],["kandan.reconnect_thread_rehydrated","linzumi.reconnect_thread_rehydrated"],["kandan.reconnect_thread_rehydrated_state_push_failed","linzumi.reconnect_thread_rehydrated_state_push_failed"],["kandan.reconnect_thread_rehydration_failed","linzumi.reconnect_thread_rehydration_failed"],["kandan.reconnect_thread_rehydration_ir_emitted","linzumi.reconnect_thread_rehydration_ir_emitted"],["kandan.reconnect_thread_rehydration_items_failed","linzumi.reconnect_thread_rehydration_items_failed"],["kandan.reconnect_thread_resume_failed","linzumi.reconnect_thread_resume_failed"],["kandan.reconnect_thread_seq_already_applied","linzumi.reconnect_thread_seq_already_applied"],["kandan.reconnect_thread_transcript_fetch_failed","linzumi.reconnect_thread_transcript_fetch_failed"],["kandan.reconnect_thread_unarchive_failed","linzumi.reconnect_thread_unarchive_failed"],["kandan.reconnect_thread_unarchive_resumed","linzumi.reconnect_thread_unarchive_resumed"],["kandan.reconnect_thread_unarchive_started","linzumi.reconnect_thread_unarchive_started"],["kandan.reconnect_thread_unavailable_state_push_failed","linzumi.reconnect_thread_unavailable_state_push_failed"],["kandan.reconnected","linzumi.reconnected"],["kandan.roster_seeded","linzumi.roster_seeded"],["kandan.session_app_server_lost_push_failed","linzumi.session_app_server_lost_push_failed"],["kandan.session_settings_publish_failed","linzumi.session_settings_publish_failed"],["kandan.start_instance_claude_code_attachment_failed_state_push_failed","linzumi.start_instance_claude_code_attachment_failed_state_push_failed"],["kandan.start_instance_codex_app_server_unavailable","linzumi.start_instance_codex_app_server_unavailable"],["kandan.start_instance_cwd_failed_state_push_failed","linzumi.start_instance_cwd_failed_state_push_failed"],["kandan.start_instance_cwd_rejected","linzumi.start_instance_cwd_rejected"],["kandan.start_instance_failed","linzumi.start_instance_failed"],["kandan.start_instance_processing_state_push_failed","linzumi.start_instance_processing_state_push_failed"],["kandan.start_instance_skipped_known_session","linzumi.start_instance_skipped_known_session"],["kandan.start_instance_stale_skipped","linzumi.start_instance_stale_skipped"],["kandan.start_instance_unavailable_state_push_failed","linzumi.start_instance_unavailable_state_push_failed"],["kandan.start_instance_wafer_state_push_failed","linzumi.start_instance_wafer_state_push_failed"],["kandan.start_turn_replay_skipped","linzumi.start_turn_replay_skipped"],["kandan.steer_duplicate_ignored","linzumi.steer_duplicate_ignored"],["kandan.steer_parked_as_own_turn","linzumi.steer_parked_as_own_turn"],["kandan.thread_bind_from_historical_reply_failed","linzumi.thread_bind_from_historical_reply_failed"],["kandan.thread_bound_from_historical_reply","linzumi.thread_bound_from_historical_reply"],["kandan.thread_sessions_reannounce_failed","linzumi.thread_sessions_reannounce_failed"],["kandan.thread_sessions_reannounced","linzumi.thread_sessions_reannounced"],["kandan.tui_input_mirrored","linzumi.tui_input_mirrored"],["kandan.typing_heartbeat_failed","linzumi.typing_heartbeat_failed"],["kandan.typing_stop_after_completion_failed","linzumi.typing_stop_after_completion_failed"]],sP=[["codexThreadId","harness_session_id"],["codex_thread_id","harness_session_id"],["kandanThreadId","thread_id"],["kandan_preview_ticket","linzumi_preview_ticket"],["kandan_thread_id","thread_id"],["linzumiThreadId","thread_id"],["linzumi_thread_id","thread_id"],["local_codex_runner","commander"],["runnerId","commander_id"],["runner_config","commander_config"],["runner_id","commander_id"]],Mm=[["commander","local_codex_runner"],["commander_config","runner_config"],["commander_id","runner_id"],["harness_session_id","codex_thread_id"],["linzumi_preview_ticket","kandan_preview_ticket"],["thread_id","kandan_thread_id"]],Ov=[["engine_boot_reconnect","harness_boot_reconnect"],["engine_for_runner_event_type","harness_for_commander_event_type"],["engine_rejected_steer","harness_rejected_steer"],["engine_unavailable","harness_unavailable"],["join_engine","join_harness"],["kandan-local-codex-runner","linzumi-commander"],["local_codex_runner","commander"],["original_engine","original_harness"],["resume_engine","resume_harness"]];function ku(){return x("1.0.148","0.0.0-unbundled")}function Ev(){return"linzumi "+x("1.0.148","0.0.0-unbundled")}function bl(e,t){let r=e.indexOf(t);if(r!==-1)return r}function Pv(){let e=process.env.LINZUMI_NAMING_DUAL_EMIT;if(e===void 0)return!0;let t=e.trim().toLowerCase();return t!=="0"?t!=="false":!1}function Rv(e){let t={};return e.forEach(r=>{t[r[0]]=r[1]}),t}function S4(e){let t={};return e.forEach(r=>{t[r[1]]=r[0]}),t}var uP=Rv(sP),cP=Rv(Mm),w4=Rv(Ov),k4=S4(Ov);function x4(e){return e.endsWith("_canonical")?!0:e.endsWith("_legacy")}function fP(e,t){return t>=32?e:Array.isArray(e)?e.map(r=>fP(r,t+1|0)):e===null?e:typeof e==="object"?mP(e,t):e}function mP(e,t){let r=Object.keys(e),n={};return r.forEach(i=>{let o=e[i];if(o!==void 0){n[i]=fP(o,t+1|0);return}}),r.forEach(i=>{if(x4(i))return;let o=n[i];if(o===void 0)return;let a=uP[i];if(a!==void 0)n[a]=o;else{let c=cP[i];c!==void 0&&(n[c]!==void 0||(n[c]=o))}let s=n[i];if(s===void 0||typeof s!="string")return;let l=w4[s];if(l!==void 0){if(n[i+"_canonical"]!==void 0)return;n[i+"_canonical"]=l;return}let d=k4[s];if(!(d===void 0||n[i+"_legacy"]!==void 0)){n[i+"_legacy"]=d;return}}),n}function jm(e){return Pv()?mP(e,0):e}function pP(e){let t=e.slice();return e.forEach(r=>{let n=uP[r];n!==void 0&&!t.includes(n)&&t.push(n);let i=cP[r];if(i!==void 0&&!t.includes(i)){t.push(i);return}}),t}var vl="<SENSITIVE_DATA>",T4=pP(["access_token","authorization","code","cookie","kandan_preview_ticket","refresh_token","token"]),A4=["--access-token","--api-key","--authorization","--cookie","--oauth-code","--password","--refresh-token","--secret","--token"],O4=new RegExp("^(authorization|cookie|set-cookie|password)$","i"),C4=new RegExp("(^|[_-])(access[_-]?token|api[_-]?key|auth[_-]?token|oauth[_-]?code|refresh[_-]?token|secret|token)$","i"),E4=new RegExp("\\beyJ[A-Za-z0-9_-]*\\.[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\b","g");function P4(e){return e!==void 0?O4.test(e)?!0:C4.test(e):!1}function hP(e){let t={contents:!1};return Gw(e).forEach(r=>{if(T4.includes(r.toLowerCase())){e.set(r,vl),t.contents=!0;return}}),t.contents}function R4(e){let t=bl(e,"?"),r=bl(e,"#");if(t===void 0||r!==void 0&&r<t)return e;let n=e.slice(0,t),i=r!==void 0?e.slice(t+1|0,r):e.slice(t+1|0),o=r!==void 0?e.slice(r):"",a=new URLSearchParams(i);return hP(a)?n+"?"+a.toString()+o:e}function I4(e){let t=Ln(e);if(t===void 0)return R4(e);let r=ue(t);return hP(r.searchParams),r.toString()}function _P(e){return I4(e).replace(E4,vl)}function $4(e){let t=bl(e,"=");return t!==void 0?[e.slice(0,t),e.slice(t+1|0)]:[e,void 0]}function $v(e,t){if(P4(t))return vl;if(Array.isArray(e))return t==="args"?M4(e):e.map(r=>$v(r,void 0));if(e===null)return e;switch(typeof e){case"string":return _P(e);case"object":return gP(e);default:return e}}function M4(e){let t={contents:!1};return e.map(r=>{if(typeof r=="string"){if(t.contents)return t.contents=!1,vl;let n=$4(r),i=n[0];return A4.includes(i)?n[1]!==void 0?i+"="+vl:(t.contents=!0,r):_P(r)}return t.contents=!1,$v(r,void 0)})}function gP(e){let t=e.name,r=typeof t=="string"?t.toLowerCase():void 0,n;if(r!==void 0)switch(r){case"authorization":case"cookie":case"set-cookie":n=!0;break;default:n=!1}else n=!1;let i={};return Object.entries(e).forEach(o=>{let a=o[0];if(a!=="runner_console"){i[a]=n&&a==="value"?vl:$v(o[1],a);return}}),i}var zm=gP;import*as ta from"node:os";import*as jp from"node:path";import*as gw from"node:crypto";function jn(e){let t=parseFloat(e);if(!Number.isNaN(t))return t}function bP(e){return"local_runner:"+e}var j4="kandan-local-codex-runner",z4="rescript";function vP(e){let t={};t.clientName=j4,t.clientId=e.clientId;let r=e.machineFingerprint;t.machineFingerprint=r!==void 0?r:null,Object.entries(ck(e.machineFingerprintV2)).forEach(a=>{t[a[0]]=a[1]}),t.runnerPid=e.runnerPid,t.version=e.version,t.hostname=e.hostname,t.cwd=e.cwd;let n=e.workspace;t.workspace=n!==void 0?n:null;let i=e.channel;t.channel=i!==void 0?i:null,t.capabilities=e.capabilities;let o=e.generationOverlapEpoch;if(o!==void 0){let a={};a.epoch=o,a.overlap=!0,t.generation=a}return t.commander_impl=z4,t}function SP(e,t,r){let n={};return n.last_seq=r,t!==void 0&&(n.runner_id=e,n.thread_id=t),n}function zn(e,t){return e.catch(r=>t(ee(r)))}function kP(){let e=[],t=[],r={contents:!1},n=()=>{let a=e.shift();return a!==void 0?Promise.resolve({done:!1,value:a}):r.contents?Promise.resolve({done:!0}):new Promise((s,l)=>{t.push(s)})},i=()=>(r.contents=!0,Promise.resolve({done:!0})),o={};return o[Symbol.asyncIterator]=()=>({next:n,return:i}),{iterable:o,push:a=>{if(r.contents)return!1;let s=t.shift();return s!==void 0?(s({done:!1,value:a}),!0):(e.push(a),!0)},close:()=>{r.contents=!0,(()=>{for(;;){let s=t.shift();if(s===void 0)return;s({done:!0})}})()}}}function xP(e){return import(e)}var G4="@anthropic-ai/claude-agent-sdk";function TP(e){return kP()}function F4(e){return{next:()=>e.next(),close:()=>{e.close()},interrupt:()=>e.interrupt(),setModel:t=>e.setModel(t),setPermissionMode:t=>e.setPermissionMode(t),applyFlagSettings:t=>e.applyFlagSettings(t),supportedCommands:()=>e.supportedCommands()}}async function AP(){let e=await xP(G4);return{query:t=>F4(e.query(t)),getSessionInfo:(t,r)=>e.getSessionInfo(t,r),listSessions:t=>e.listSessions(t),getSessionMessages:(t,r)=>e.getSessionMessages(t,r)}}var Mv=["codex","claude-code","pi","opencode"];function Ya(e){return e}function Nm(e){switch(e.TAG){case"SessionStarted":return"session_started";case"TurnStarted":return"turn_started";case"ItemStarted":return"item_started";case"ItemDelta":return"item_delta";case"ItemCompleted":return"item_completed";case"ApprovalRequested":return"approval_requested";case"UsageUpdated":return"usage_updated";case"RateLimitUpdated":return"rate_limit_updated";case"ActivityPulse":return"activity_pulse";case"TurnCompleted":return"turn_completed";case"TurnFailed":return"turn_failed";case"TurnInterrupted":return"turn_interrupted";case"HarnessDied":return"harness_died"}}function D4(e){switch(e){case"SocketOpen":return"open";case"SocketMessage":return"message";case"SocketClose":return"close";case"SocketError":return"error"}}function q4(e){let t=e.data,r;r=t==null||typeof t!="string"?void 0:t;let n=e.code,i;i=n==null||typeof n!="number"||(n|0)!==n?void 0:n|0;let o=e.reason,a;return a=o==null||typeof o!="string"?void 0:o,{data:r,code:i,reason:a}}function L4(e){return{readyState:()=>e.readyState,send:t=>{e.send(t)},close:()=>{e.close()},on:(t,r)=>{e.addEventListener(D4(t),n=>r(q4(n)),{})}}}function Gm(e,t){return L4(new WebSocket(e,t))}var CP=0,Xa=1;var jv="file",zv=["mcp_oauth_credentials_store","cli_auth_credentials_store"],U4=zv.flatMap(e=>["-c",e+'="'+jv+'"']),W4=["-c","features.apps=false"];function po(e){return JSON.stringify(e)}function Z4(e){let t=(r,n)=>r!==void 0?Object.entries(r).flatMap(i=>["-c","model_providers."+e.id+"."+n+"."+i[0]+"="+po(i[1])]):[];return[["-c","model_providers."+e.id+".name="+po(e.name),"-c","model_providers."+e.id+".base_url="+po(e.baseUrl),"-c","model_providers."+e.id+".env_key="+po(e.envKey),"-c","model_providers."+e.id+".wire_api="+po(e.wireApi)],t(e.httpHeaders,"http_headers"),t(e.envHttpHeaders,"env_http_headers"),["-c","model_provider="+po(e.id)]].flat()}function V4(e){let t=e.model,r=e.reasoningEffort,n=e.modelProvider;return[W4,U4,t!==void 0?["-c","model="+po(t)]:[],r!==void 0?["-c","model_reasoning_effort="+po(r)]:[],e.fast?["-c","service_tier="+po("fast")]:[],e.mcpConfigArgs.flat(),n!==void 0?Z4(n):[]].flat()}function PP(e,t){return[["app-server"],V4(t),["--listen",e]].flat()}var H4=["LINZUMI_MCP_ACCESS_TOKEN","LINZUMI_MCP_OWNER_USERNAME"];function RP(e,t,r){let n=r?Object.fromEntries(Object.entries(e)):{};return H4.forEach(i=>fr(n,i)),t.forEach(i=>{let o=i[1],a=i[0];if(o!==void 0){n[a]=o;return}else return fr(n,a)}),n}var IP=["ignore","pipe","pipe"];function $P(e){let t=e.length;return t>12e3?e.slice(t-12e3|0,t):e}function MP(e,t,r){return r<3&&e.includes("codex app-server exited before readyz")&&t.includes("EADDRINUSE")?t.includes("listen"):!1}function jP(e){let t=Ln(e);if(t===void 0)return;let r=ue(t),i=r.protocol==="wss:"?"https:":"http:";return r.protocol=i,r.pathname="/readyz",r.search="",r.hash="",r.toString()}var B4="kandan-local-codex-runner",K4="0.0.1";function zP(){return Object.fromEntries([["clientInfo",Object.fromEntries([["name",B4],["version",K4]])],["capabilities",Object.fromEntries([["experimentalApi",!0]])]])}var J4=new RegExp("\\bsession\\b.+\\bis archived\\b","i");function NP(e){return J4.test(e)}var Y4=new RegExp("^thread not found(?:\\s*:|\\b)","i");function GP(e){return Y4.test(e.trim())}var FP=2e3;function X4(e){try{e.unref();return}catch{return}}var DP="codex app-server websocket closed",Q4="codex app-server websocket is not open";function eH(e){let t=e.method;if(typeof t=="string")return t}function Nv(e){let t=e.error;if(t===void 0)return{TAG:"ResultReply",_0:x(e.result,null)};if(typeof t!="object"||t===null||Array.isArray(t))return{TAG:"ErrorReply",code:0,message:JSON.stringify(t)};let r=t.code,n=r!==void 0&&typeof r=="number"?r:0,i=t.message;return{TAG:"ErrorReply",code:n,message:typeof i=="string"?i:""}}function Dm(e,t,r,n){let i=JSON.stringify(n);t(r,i);try{return e.socket.send(i),{TAG:"Ok",_0:void 0}}catch(o){let a=ee(o);return{TAG:"Error",_0:Ne(a).message}}}function WP(e,t,r){try{return t(r)}catch(n){let i=ee(n);return e("codex.notification_callback_failed",Object.fromEntries([["purpose","codex.app_server"],["method",r.method],["message",Ne(i).message]]))}}function qP(e,t,r){try{return t(r)}catch(n){let i=ee(n);return e("codex.close_callback_failed",Object.fromEntries([["purpose","codex.app_server"],["message",Ne(i).message]]))}}function tH(e,t){let r;if(t.TAG==="Ok")r=[["jsonrpc","2.0"],["id",e],["result",t._0]];else{let n=t._0;r=[["jsonrpc","2.0"],["id",e],["error",Object.fromEntries([["code",n[0]],["message",n[1]]])]]}return Object.fromEntries(r)}async function rH(e,t,r,n){let i={TAG:"Error",_0:[-32601,"unhandled Codex app-server request: "+n.method]},o=e.requestCallbacks.slice(),a,s=0;for(;mn(a)&&s<o.length;){let d=o[s];if(d!==void 0){let u=0,c;try{c=await d(n),u=1}catch(f){let p=ee(f);a={TAG:"Error",_0:[-32e3,Ne(p).message]}}u===1&&c!==void 0&&(a={TAG:"Ok",_0:c})}s=s+1|0}let l=x(a,i);Dm(t,r,"outgoing",tH(n.id,l))}function nH(e,t,r,n,i){let o;try{o=JSON.parse(i)}catch(p){let m=ee(p);r("codex.app_server_frame_malformed",Object.fromEntries([["purpose","codex.app_server"],["message",Ne(m).message],["payload",i.slice(0,512)],["payloadChars",i.length]])),o=void 0}let a;if(o!==void 0){let p=0;typeof o=="object"&&o!==null&&!Array.isArray(o)?a=o:p=1,p===1&&(r("codex.app_server_frame_malformed",Object.fromEntries([["purpose","codex.app_server"],["message","codex app-server sent non-object JSON-RPC message"],["payload",i.slice(0,512)],["payloadChars",i.length]])),a=void 0)}else a=void 0;if(a===void 0)return;let s=Dt(a.id),l=s&&(Dt(a.result)||Dt(a.error)),d=eH(a);if(l){let p=x(a.id,null),m=JSON.stringify(p),h=e.pending[m];return h!==void 0?(fr(e.pending,m),h.resolvePending({TAG:"Ok",_0:Nv(a)})):void 0}if(s)if(d!==void 0){zn(rH(e,t,n,{id:x(a.id,null),method:d,params:a.params}),p=>Promise.resolve());return}else return;if(d===void 0)return;let u=a.params,c={method:d,params:u};e.notificationCallbacks.length!==0?e.notificationCallbacks.forEach(p=>WP(r,p,c)):e.pendingNotifications.push(c)}function iH(e,t,r){return Object.fromEntries(r!==void 0?[["jsonrpc","2.0"],["id",e],["method",t],["params",r]]:[["jsonrpc","2.0"],["id",e],["method",t]])}function LP(e,t){return Object.fromEntries(t!==void 0?[["jsonrpc","2.0"],["method",e],["params",t]]:[["jsonrpc","2.0"],["method",e]])}function UP(e,t,r,n,i,o){return t.socket.readyState()===Xa?new Promise((a,s)=>{e.pending[JSON.stringify(n)]={resolvePending:a};let l=Dm(t,r,"request",iH(n,i,o));l.TAG!=="Ok"&&(fr(e.pending,JSON.stringify(n)),a({TAG:"Error",_0:l._0}))}):Promise.resolve({TAG:"Error",_0:Q4})}async function qm(e,t,r,n){let i=t!==void 0?t:u=>({socket:Gm(u,[]),ping:void 0}),o=r!==void 0?r:2e3,a=n!==void 0?n:()=>Date.now(),s=a()+o,l,d="websocket open failed";for(;mn(l);){let u;try{u={TAG:"Ok",_0:i(e)}}catch(c){let f=ee(c);u={TAG:"Error",_0:Ne(f).message}}if(u.TAG==="Ok"){let c=u._0;if(await new Promise((f,p)=>{c.socket.on("SocketOpen",m=>f(!0)),c.socket.on("SocketError",m=>f(!1))}))l={TAG:"Ok",_0:c};else{try{c.socket.close()}catch{}a()>s&&(l={TAG:"Error",_0:d})}}else d=u._0,a()>s&&(l={TAG:"Error",_0:d})}return x(l,{TAG:"Error",_0:d})}async function Lm(e,t){let r={pending:{},notificationCallbacks:[],requestCallbacks:[],pendingNotifications:[],closeCallbacks:[],nextId:1,closeError:void 0},n=t.audit,i=t.onWire,o=setInterval(()=>{let d=e.ping;if(d!==void 0&&e.socket.readyState()===Xa)try{return d()}catch{return}},t.keepaliveIntervalMs);X4(o);let a=d=>{clearInterval(o);let u=Object.entries(r.pending);if(Object.entries(r.pending).forEach(p=>fr(r.pending,p[0])),u.forEach(p=>p[1].resolvePending({TAG:"Error",_0:d})),r.closeError!==void 0)return;r.closeError=d;let f=r.closeCallbacks.slice();r.closeCallbacks.splice(0,r.closeCallbacks.length),f.forEach(p=>qP(n,p,d))};e.socket.on("SocketClose",d=>a(DP)),e.socket.on("SocketError",d=>a(DP)),e.socket.on("SocketMessage",d=>{let u=d.data;if(u!==void 0)return i("incoming",u),nH(r,e,n,i,u)});let s=await UP(r,e,i,"initialize","initialize",zP());if(s.TAG!=="Ok")return{TAG:"Error",_0:s._0};let l=s._0;return l.TAG!=="ResultReply"?{TAG:"Error",_0:"codex initialize failed: "+l.message}:(Dm(e,i,"outgoing",LP("initialized",void 0)),{TAG:"Ok",_0:{request:(d,u)=>{let c=r.nextId;return r.nextId=r.nextId+1|0,UP(r,e,i,c,d,u)},notify:(d,u)=>{Dm(e,i,"outgoing",LP(d,u))},onNotification:d=>{r.notificationCallbacks.push(d);let u=r.pendingNotifications.slice();r.pendingNotifications.splice(0,r.pendingNotifications.length),u.forEach(c=>WP(n,d,c))},onRequest:d=>{r.requestCallbacks.push(d)},onClose:d=>{let u=r.closeError;if(u!==void 0)return qP(n,d,u);r.closeCallbacks.push(d)},isClosed:()=>Dt(r.closeError),close:()=>{clearInterval(o);try{return e.socket.close()}catch{return}}}})}function xl(e){if(typeof e=="object"&&e!==null&&!Array.isArray(e))return e}function Li(e){if(e!==void 0&&typeof e=="string"&&e.trim()!=="")return e.trim()}function kl(e){if(e!==void 0&&typeof e=="number"&&Ot(e))return e}function ZP(e){if(typeof e=="object"&&e!==null&&!Array.isArray(e))return e}var VP="linzumi_thread_codex_worker_ready",HP="linzumi_thread_codex_worker_session_closed",BP="linzumi_thread_codex_worker_request",KP="linzumi_thread_codex_worker_notify",qv="linzumi_thread_codex_worker_response",JP="linzumi_thread_codex_worker_notification",YP="linzumi_thread_codex_worker_server_request",XP="linzumi_thread_codex_worker_server_request_response";function QP(e,t){let r={};return r.type=VP,r.kandanThreadId=e,r.commanderManagedPorts=t.map(n=>{let i={};i.port=n.port;let o=n.pid;o!==void 0&&(i.pid=o);let a=n.processName;a!==void 0&&(i.processName=a);let s=n.processIconKey;s!==void 0&&(i.processIconKey=s);let l=n.agentProvider;return l!==void 0&&(i.agentProvider=l),i}),r}function eR(e,t){let r={};return r.type=HP,r.kandanThreadId=e,r.reason=t,r}function oH(e,t,r){let n={};return n.type=BP,n.id=e,n.method=t,r!==void 0&&(n.params=r),n}function aH(e,t){let r={};return r.type=KP,r.method=e,t!==void 0&&(r.params=t),r}function sH(e,t){let r={};return r.type=qv,r.id=e,r.response=t,r}function lH(e,t){let r={};return r.type=qv,r.id=e,r.error=t,r}function dH(e){let t={};return t.type=JP,t.notification=e,t}function uH(e,t){let r={};return r.type=YP,r.id=e,r.request=t,r}function Fv(e,t,r){let n={};return n.type=XP,n.id=e,t!==void 0&&(n.result=t),r!==void 0&&(n.error=r),n}function cH(e){if(e===void 0||typeof e!="object"||e===null||Array.isArray(e)||e.id===void 0)return;let r=e.result,n=e.error;if(r!==void 0||n!==void 0)return e}function fH(e){if(e===void 0||typeof e!="object"||e===null||Array.isArray(e))return;let t=e.id,r=e.method;if(!(t!==void 0||typeof r!="string"))return e}function mH(e){if(e===void 0||typeof e!="object"||e===null||Array.isArray(e))return;let t=e.id,r=e.method;if(t!==void 0&&typeof r=="string")return e}function pH(e){let t=xl(e);if(t===void 0)return;let r=t.type;if(r===void 0||typeof r!="string")return;if(r===BP){let i=kl(t.id),o=Li(t.method);return i!==void 0&&o!==void 0?{TAG:"ParentRequest",id:i,method_:o,params:ZP(t.params)}:void 0}if(r===KP){let i=Li(t.method);return i!==void 0?{TAG:"ParentNotify",method_:i,params:ZP(t.params)}:void 0}if(r!==XP)return;let n=kl(t.id);if(n!==void 0)return{TAG:"ParentServerRequestResponse",id:n,result:t.result,error:Li(t.error)}}function hH(e){let t=xl(e);if(t===void 0)return;let r=t.type;if(r===void 0||typeof r!="string")return;if(r===qv){let o=kl(t.id);return o!==void 0?{TAG:"ChildResponse",id:o,response:cH(t.response),error:Li(t.error)}:void 0}if(r===JP){let o=fH(t.notification);return o!==void 0?{TAG:"ChildNotification",notification:o}:void 0}if(r!==YP)return;let n=kl(t.id),i=mH(t.request);if(n!==void 0&&i!==void 0)return{TAG:"ChildServerRequest",id:n,request:i}}function tR(e){let t=xl(e);if(t===void 0)return;let r=t.type;if(typeof r=="string"&&r===HP)return[x(Li(t.kandanThreadId),""),x(Li(t.reason),"")]}var _H="thread Codex worker reported invalid ready payload";function gH(e){let t=Li(e);if(t!==void 0)switch(t){case"claude-code":return"claude-code";case"codex":return"codex";default:return}}function yH(e){return e!==void 0?Array.isArray(e)?$e(e,t=>{let r=xl(t);if(r===void 0)return;let n=kl(r.port);if(n!==void 0&&n>=1&&n<=65535)return{port:n,pid:kl(r.pid),processName:Li(r.processName),processIconKey:Li(r.processIconKey),agentProvider:gH(r.agentProvider)}}):[]:[]}function rR(e,t){let r=xl(e);if(r===void 0)return{TAG:"Ok",_0:void 0};let n=r.type;if(n===void 0)return{TAG:"Ok",_0:void 0};if(typeof n!="string")return{TAG:"Ok",_0:void 0};if(n!==VP)return{TAG:"Ok",_0:void 0};let i=Li(r.kandanThreadId);return i!==void 0&&i===t?{TAG:"Ok",_0:{kandanThreadId:i,commanderManagedPorts:yH(r.commanderManagedPorts)}}:{TAG:"Error",_0:_H}}function nR(e,t){}var iR="linzumi.thread_runner",bH="thread Codex worker requires a codex client with onRequest",Dv="thread Codex worker IPC channel closed";function oR(e,t,r){let n=r!==void 0?r:nR,i=e.onRequest;if(i===void 0)return{TAG:"Error",_0:bH};let o=new Map,a={contents:1},s={contents:!1},l=u=>{if(s.contents)return;s.contents=!0;let c={};c.purpose=iR,c.reason=u,n("thread_codex_worker.ipc_send_dropped",c)},d=u=>{let c=t.send,f=t.isConnected();if(c===void 0||!f)return l("ipc_channel_closed");let p=c(u);if(p.TAG!=="Ok")return l(p._0)};return t.onMessage(u=>{let c=pH(u);if(c!==void 0)switch(c.TAG){case"ParentRequest":let f=c.id;e.request(c.method_,c.params).then(_=>_.TAG==="Ok"?d(sH(f,_._0)):d(lH(f,_._0)));return;case"ParentNotify":return e.notify(c.method_,c.params);case"ParentServerRequestResponse":let p=c.error,m=c.id,h=o.get(m);return h!==void 0?(o.delete(m),h(p!==void 0?{TAG:"Error",_0:p}:{TAG:"Ok",_0:c.result})):void 0}}),e.onNotification(u=>d(dH(u))),i(u=>new Promise((c,f)=>{let p=a.contents;a.contents=p+1,o.set(p,c),d(uH(p,u))})),t.onceDisconnect(()=>{o.forEach(u=>u({TAG:"Error",_0:Dv})),o.clear()}),{TAG:"Ok",_0:void 0}}var vH="thread Codex worker IPC client is closed",SH="thread Codex worker response missing body",wH="thread Codex worker IPC client closed";async function kH(e,t,r,n,i,o){let a=d=>{let u=e(d);if(u.TAG==="Ok")return;let c={};c.purpose=iR,c.requestMethod=n,c.message=u._0,o("thread_codex_worker.ipc_response_dropped",c)},s=!1,l=0;for(;!s&&l<i.length;){let d=i[l];if(d!==void 0){let u=await d(r);if(u.TAG==="Ok"){let c=u._0;c!==void 0&&(s=!0,a(Fv(t,c,void 0)))}else s=!0,a(Fv(t,void 0,u._0))}l=l+1|0}if(!s)return a(Fv(t,void 0,"unhandled Codex app-server request: "+n))}function xH(e){let t=xl(e);if(t===void 0)return"";let r=t.method;return typeof r=="string"?r:""}function aR(e,t){let r=t!==void 0?t:nR,n=new Map,i=[],o=[],a=[],s={contents:1},l={contents:!1},d=_=>{n.forEach(g=>g({TAG:"Error",_0:_})),n.clear()},u=_=>{if(l.contents)return{TAG:"Error",_0:vH};let g=e.send,b=e.isConnected();return g!==void 0&&b?g(_):{TAG:"Error",_0:Dv}},c=_=>{let g=hH(_);if(g!==void 0)switch(g.TAG){case"ChildResponse":let b=g.error,y=g.response,v=g.id,S=n.get(v);return S!==void 0?(n.delete(v),S(b!==void 0?{TAG:"Error",_0:b}:y!==void 0?{TAG:"Ok",_0:y}:{TAG:"Error",_0:SH})):void 0;case"ChildNotification":let A=g.notification;i.length!==0?i.forEach(L=>L(A)):a.push(A);return;case"ChildServerRequest":let W=g.request;kH(u,g.id,W,xH(W),o,r);return}},f=e.onMessage(c),p=()=>{l.contents=!0,d(Dv)},m=e.onceExit(p),h=e.onceDisconnect(p);return{request:(_,g)=>new Promise((b,y)=>{let v=s.contents;s.contents=v+1,n.set(v,b);let S=u(oH(v,_,g));S.TAG!=="Ok"&&(n.delete(v),b({TAG:"Error",_0:S._0}))}),notify:(_,g)=>u(aH(_,g)),onNotification:_=>{i.push(_);let g=a.slice();a.splice(0,a.length),g.forEach(b=>_(b))},onRequest:_=>{o.push(_)},isClosed:()=>l.contents?!0:!e.isConnected(),close:()=>{l.contents=!0,f(),m(),h(),d(wH)}}}import*as Bv from"node:child_process";import*as lR from"node:os";import*as dR from"node:path";function uR(){return dR.join(lR.homedir(),".linzumi","protected-dev-listeners")}var TH=new RegExp("^(\\d+)\\s+(\\d+)$");function AH(e){return $e(e.split(`
|
|
325
325
|
`),t=>{let r=TH.exec(t.trim());if(r==null)return;let n=r.slice(1);if(n.length!==2)return;let i=n[0];if(i===void 0)return;let o=n[1];if(o===void 0)return;let a=jn(i),s=jn(o);if(a!==void 0&&s!==void 0)return{pid:a,pgid:s}})}function OH(e){let t=_s("ps",["-axo","pid=,pgid="],5e3,16e6);if(t.TAG==="Ok")return AH(t._0).filter(r=>r.pgid===e).map(r=>r.pid)}function Um(e,t,r,n,i){let o=n!==void 0?n:OH,a;if(i.size>0){let l=o(e);if(l!==void 0){let d=l.filter(u=>i.has(u));if(d.length!==0){let u=[],c=new Set(l.filter(f=>!i.has(f)));c.add(e),Array.from(c).forEach(f=>{let p=r(f|0,t);if(p.TAG==="Ok")return;let m=p._0;if(!de(m.code,"ESRCH")){u.push({pid:f,code:m.code,message:m.message});return}}),a={mode:"IndividualSignals",sparedPids:d,failures:u,groupSignalError:void 0}}else a=void 0}else a=void 0}else a=void 0;if(a!==void 0)return a;let s=r(-e|0,t);return s.TAG==="Ok"?{mode:"GroupSignal",sparedPids:[],failures:[],groupSignalError:void 0}:{mode:"GroupSignal",sparedPids:[],failures:[],groupSignalError:s._0}}var mR={contents:(e,t)=>{}};var Lv="SIGKILL",Qa={children:new Set,handlersInstalled:!1,removeHandlers:void 0};function xu(e,t,r,n,i){let o=e.pid;mR.contents("process.reap_failed",Object.fromEntries([["purpose",e.kind],["pid",o!==void 0?o:null],["ownProcessGroup",e.ownProcessGroup],["reason",t],["stage",r],["code",n!==void 0?n:null],["message",i]]))}function CH(e,t,r,n){let i;try{e.stop(),i={TAG:"Ok",_0:void 0}}catch(l){i={TAG:"Error",_0:ee(l)}}if(i.TAG!=="Ok"){let l=Ne(i._0);xu(e,n,"stop",l.code,l.message)}let o=e.pid;if(o===void 0)return;if(e.ownProcessGroup){let l=Um(o,Lv,t,void 0,r);l.sparedPids.length!==0&&mR.contents("process.reap_spared_listeners",Object.fromEntries([["purpose",e.kind],["pid",o],["reason",n],["sparedPids",l.sparedPids.map(f=>f)]])),l.failures.forEach(f=>xu(e,n,"member_kill:"+f.pid.toString(),f.code,f.message));let d=l.groupSignalError;if(d===void 0||de(d.code,"ESRCH"))return;xu(e,n,"group_kill",d.code,d.message);let u=t(o,Lv);if(u.TAG==="Ok")return;let c=u._0;return de(c.code,"ESRCH")?void 0:xu(e,n,"pid_kill",c.code,c.message)}let a=t(o,Lv);if(a.TAG==="Ok")return;let s=a._0;if(!de(s.code,"ESRCH"))return xu(e,n,"pid_kill",s.code,s.message)}function Uv(e,t,r){let n=e!==void 0?e:Vi,i=t!==void 0?t:new Set,o=r!==void 0?r:"exit",a=Array.from(Qa.children);return Qa.children.clear(),a.forEach(s=>CH(s,n,i,o)),a.length}function fR(e,t){let r;return r=typeof t=="string"?t:JSON.stringify(t),"linzumi commander "+e+": "+r+`
|
|
326
326
|
`}function EH(){if(Qa.handlersInstalled)return;Qa.handlersInstalled=!0;let e=o=>{Uv(void 0,void 0,"process_exit")};process.on("exit",e);let t=process.listenerCount("uncaughtException")===0,r=process.listenerCount("unhandledRejection")===0,n=o=>{Uv(void 0,void 0,"uncaught_exception"),mr(fR("uncaughtException",o)),process.exit(1)},i=o=>{Uv(void 0,void 0,"unhandled_rejection"),mr(fR("unhandledRejection",o)),process.exit(1)};t&&process.on("uncaughtException",n),r&&process.on("unhandledRejection",i),Qa.removeHandlers=()=>{if(process.off("exit",e),t&&process.off("uncaughtException",n),r){process.off("unhandledRejection",i);return}}}function Wm(e){return Qa.children.add(e),EH(),{unregister:()=>{Qa.children.delete(e)}}}import*as Zo from"node:path";import*as hR from"node:net";function Tl(e,t){try{return e.kill(t)}catch{return!1}}function _R(){return new Promise((e,t)=>{let r=hR.createServer();r.on("error",n=>e({TAG:"Error",_0:n.message})),r.listen(0,"127.0.0.1",()=>{let n=r.address();if(n==null)return r.close(o=>{}),e({TAG:"Error",_0:"failed to allocate loopback port"});let i=n.port;r.close(o=>o==null?e({TAG:"Ok",_0:i}):e({TAG:"Error",_0:o.message}))})})}var xre=new RegExp("[^0-9A-Za-z._-]","g");var Mre=new RegExp("[\\\\/]");var gR="cannot fork thread runner without current CLI script path";var jre=15*6e4,zre=120*6e4,Nre=1440*6e4,Gre=2*6e4;var IH="this computer is updating its Linzumi runner",Fre=IH+" to a new version - nothing was started. Retry in a few minutes once the update finishes.";var Dre=15*6e4;var yR="this computer restarted its Linzumi runner for an update",qre=yR+" after waiting for this job past the drain timeout - the job was interrupted. Send your message again to continue.",Lre=yR+" while this job was waiting on your approval - the approval prompt was interrupted. Send your message again and answer the approval prompt to continue.";function MH(e,t){}var Zv="linzumi.thread_runner";function bR(e,t){return e!==void 0&&e.trim()!==""?{TAG:"Ok",_0:Zo.isAbsolute(e)?e:Zo.resolve(t,e)}:{TAG:"Error",_0:gR}}function jH(e){return["--require","-r","--import","--loader","--experimental-loader"].includes(e)}function zH(e){return["--require=","-r=","--import=","--loader=","--experimental-loader="].some(t=>e.startsWith(t))}function NH(e){let t=[],r=0;for(;r<e.length;){let n=e[r];if(n!==void 0){let i=jH(n),o=zH(n);if(i){let a=e[r+1|0];a!==void 0&&(t.push(n),t.push(a)),r=r+2|0}else o&&t.push(n),r=r+1|0}else r=r+1|0}return t}function Vv(e,t,r){return NH(r).concat([e].concat(t))}function cn(e,t){return t!==void 0?t!==""?[e,t]:[]:[]}function vR(e){let t=i=>{let o=i.join(",");if(o!=="")return o},r=e.codexModelProvider,n=e.runtimeDefaults;return[["--api-url",e.kandanUrl],["--cwd",e.cwd],["--codex-bin",e.codexBin],cn("--workspace",e.workspaceSlug),cn("--log-file",e.logFile),cn("--debug-trace-dir",G(e.debugTrace,i=>i.dir)),cn("--debug-trace-content",k(e.debugTrace,i=>i.contentMode)),e.fast?["--fast"]:[],cn("--allowed-cwd",t(e.allowedCwds)),cn("--forward-port",t(e.allowedForwardPorts.map(i=>i.toString()))),cn("--code-server-bin",e.codeServerBin),cn("--model",k(e.runtimeDefaults,i=>i.model)),cn("--reasoning-effort",k(e.runtimeDefaults,i=>i.reasoningEffort)),cn("--sandbox",k(e.runtimeDefaults,i=>i.sandbox)),cn("--approval-policy",k(e.runtimeDefaults,i=>i.approvalPolicy)),r!==void 0?["--model-provider",r.provider,"--llm-proxy-base-url",r.llmProxyBaseUrl]:[],e.vmExecution?["--vm-execution"]:[],cn("--execution-mode",e.executionMode),cn("--egress-mode",e.egressMode),cn("--project-public-id",e.projectPublicId),cn("--golden-image-id",e.goldenImagePublicId),n!==void 0?n.allowPortForwardingByDefault?["--allow-port-forwarding-by-default"]:["--no-allow-port-forwarding-by-default"]:[]].flat()}function SR(e){let t=[],r=0;for(;r<e.length;){let n=e[r];n!==void 0?n==="--token"?(t.push("--token"),t.push("<redacted>"),r=r+2|0):(t.push(n),r=r+1|0):r=r+1|0}return t}function wR(e,t,r){let n=[["LINZUMI_THREAD_RUNNER_ROLE","thread"],["LINZUMI_THREAD_RUNNER_KANDAN_THREAD_ID",e.kandanThreadId],["LINZUMI_THREAD_RUNNER_TOKEN",e.token],["LINZUMI_DEV_SERVICES_PARENT_PID",t.toString()]],i=e.codexModelProvider;return i!==void 0&&n.push(["LINZUMI_LLM_PROXY_TOKEN",i.llmProxyToken]),n.push(["LINZUMI_THREAD_RUNNER_AGENT_MCP_TOKEN",x(e.linzumiAgentMcpToken,"")]),r!==void 0&&n.push(["OPENAI_API_KEY",r]),n}function kR(e){let t=e.length;return t>12e3?e.slice(t-12e3|0,t):e}function Zm(e){let t=rn(e.code,"null",o=>o.toString()),r=x(e.signal,"null"),n="thread Codex worker exited before ready: code="+t+" signal="+r,i=e.capturedOutput.trim();return i===""?n:n+`
|
|
327
327
|
worker output: `+i}function xR(e,t){return"thread Codex worker did not report ready within "+t.toString()+"ms for Kandan thread "+e}var GH="thread runner ready timeout must be a non-negative number";function TR(e){let t=x(e,3e4);return isFinite(t)&&t>=0?{TAG:"Ok",_0:t}:{TAG:"Error",_0:GH}}var AR="thread worker start preflight failed";function FH(e){return Zo.isAbsolute(e)||new RegExp("^[A-Za-z]:[\\\\/]").test(e)?!0:e.startsWith("\\\\")}function DH(e){return e===""?!0:!FH(e)&&e!==".."&&!e.startsWith("../")&&!e.startsWith("..\\")&&!e.includes("/../")?!e.includes("\\..\\"):!1}function OR(e,t,r){if(e===void 0)return{TAG:"CwdRefused",reason:"missing_cwd"};if(e.trim()==="")return{TAG:"CwdRefused",reason:"missing_cwd"};if(t.length===0)return{TAG:"CwdRefused",reason:"no_allowed_cwd"};let i=Dn(Zo.resolve(e));if(i.TAG!=="Ok")return{TAG:"CwdRefused",reason:"cwd_not_found"};let o=i._0,a=t.find(s=>DH(Zo.relative(s,o)));return a!==void 0?r(o)?{TAG:"CwdRefused",reason:"cwd_dangerous"}:{TAG:"CwdAllowed",cwd:o,matchedRoot:a}:{TAG:"CwdRefused",reason:"cwd_not_allowed"}}function CR(e,t,r){if(r.TAG==="CwdAllowed")return;let n=r.reason,o=t.length!==0?t.join(", "):"none";return{reason:n,message:AR+" ("+n+"): working directory "+e+" cannot start a coding session on this runner (allowed roots: "+o+")"}}function qH(e){return e.split(`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';
|
|
2
|
-
const require =
|
|
1
|
+
import { createRequire as __linzumiBundleCreateRequire } from 'node:module';
|
|
2
|
+
const require = __linzumiBundleCreateRequire(import.meta.url);
|
|
3
3
|
var Sx=Object.create;var kl=Object.defineProperty;var $x=Object.getOwnPropertyDescriptor;var Tx=Object.getOwnPropertyNames;var zx=Object.getPrototypeOf,Ex=Object.prototype.hasOwnProperty;var E=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Sl=(e,t)=>{for(var r in t)kl(e,r,{get:t[r],enumerable:!0})},Ax=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Tx(t))!Ex.call(e,i)&&i!==r&&kl(e,i,{get:()=>t[i],enumerable:!(n=$x(t,i))||n.enumerable});return e};var sh=(e,t,r)=>(r=e!=null?Sx(zx(e)):{},Ax(t||!e||!e.__esModule?kl(r,"default",{value:e,enumerable:!0}):r,e));var $s=E(oe=>{"use strict";Object.defineProperty(oe,"__esModule",{value:!0});oe.regexpCode=oe.getEsmExportName=oe.getProperty=oe.safeStringify=oe.stringify=oe.strConcat=oe.addCodeArg=oe.str=oe._=oe.nil=oe._Code=oe.Name=oe.IDENTIFIER=oe._CodeOrName=void 0;var ks=class{};oe._CodeOrName=ks;oe.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var _i=class extends ks{constructor(t){if(super(),!oe.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};oe.Name=_i;var tr=class extends ks{constructor(t){super(),this._items=typeof t=="string"?[t]:t}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let t=this._items[0];return t===""||t==='""'}get str(){var t;return(t=this._str)!==null&&t!==void 0?t:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var t;return(t=this._names)!==null&&t!==void 0?t:this._names=this._items.reduce((r,n)=>(n instanceof _i&&(r[n.str]=(r[n.str]||0)+1),r),{})}};oe._Code=tr;oe.nil=new tr("");function bb(e,...t){let r=[e[0]],n=0;for(;n<t.length;)cp(r,t[n]),r.push(e[++n]);return new tr(r)}oe._=bb;var ap=new tr("+");function wb(e,...t){let r=[Ss(e[0])],n=0;for(;n<t.length;)r.push(ap),cp(r,t[n]),r.push(ap,Ss(e[++n]));return iP(r),new tr(r)}oe.str=wb;function cp(e,t){t instanceof tr?e.push(...t._items):t instanceof _i?e.push(t):e.push(aP(t))}oe.addCodeArg=cp;function iP(e){let t=1;for(;t<e.length-1;){if(e[t]===ap){let r=oP(e[t-1],e[t+1]);if(r!==void 0){e.splice(t-1,3,r);continue}e[t++]="+"}t++}}function oP(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof _i||e[e.length-1]!=='"'?void 0:typeof t!="string"?`${e.slice(0,-1)}${t}"`:t[0]==='"'?e.slice(0,-1)+t.slice(1):void 0;if(typeof t=="string"&&t[0]==='"'&&!(e instanceof _i))return`"${e}${t.slice(1)}`}function sP(e,t){return t.emptyStr()?e:e.emptyStr()?t:wb`${e}${t}`}oe.strConcat=sP;function aP(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:Ss(Array.isArray(e)?e.join(","):e)}function cP(e){return new tr(Ss(e))}oe.stringify=cP;function Ss(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}oe.safeStringify=Ss;function lP(e){return typeof e=="string"&&oe.IDENTIFIER.test(e)?new tr(`.${e}`):bb`[${e}]`}oe.getProperty=lP;function uP(e){if(typeof e=="string"&&oe.IDENTIFIER.test(e))return new tr(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}oe.getEsmExportName=uP;function dP(e){return new tr(e.toString())}oe.regexpCode=dP});var dp=E(It=>{"use strict";Object.defineProperty(It,"__esModule",{value:!0});It.ValueScope=It.ValueScopeName=It.Scope=It.varKinds=It.UsedValueState=void 0;var Rt=$s(),lp=class extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value}},Rc;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"})(Rc||(It.UsedValueState=Rc={}));It.varKinds={const:new Rt.Name("const"),let:new Rt.Name("let"),var:new Rt.Name("var")};var Ic=class{constructor({prefixes:t,parent:r}={}){this._names={},this._prefixes=t,this._parent=r}toName(t){return t instanceof Rt.Name?t:this.name(t)}name(t){return new Rt.Name(this._newName(t))}_newName(t){let r=this._names[t]||this._nameGroup(t);return`${t}${r.index++}`}_nameGroup(t){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(t)||this._prefixes&&!this._prefixes.has(t))throw new Error(`CodeGen: prefix "${t}" is not allowed in this scope`);return this._names[t]={prefix:t,index:0}}};It.Scope=Ic;var jc=class extends Rt.Name{constructor(t,r){super(r),this.prefix=t}setValue(t,{property:r,itemIndex:n}){this.value=t,this.scopePath=(0,Rt._)`.${new Rt.Name(r)}[${n}]`}};It.ValueScopeName=jc;var fP=(0,Rt._)`\n`,up=class extends Ic{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?fP:Rt.nil}}get(){return this._scope}name(t){return new jc(t,this._newName(t))}value(t,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let i=this.toName(t),{prefix:o}=i,s=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[o];if(a){let u=a.get(s);if(u)return u}else a=this._values[o]=new Map;a.set(s,i);let l=this._scope[o]||(this._scope[o]=[]),c=l.length;return l[c]=r.ref,i.setValue(r,{property:o,itemIndex:c}),i}getValue(t,r){let n=this._values[t];if(n)return n.get(r)}scopeRefs(t,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,Rt._)`${t}${n.scopePath}`})}scopeCode(t=this._values,r,n){return this._reduceValues(t,i=>{if(i.value===void 0)throw new Error(`CodeGen: name "${i}" has no value`);return i.value.code},r,n)}_reduceValues(t,r,n={},i){let o=Rt.nil;for(let s in t){let a=t[s];if(!a)continue;let l=n[s]=n[s]||new Map;a.forEach(c=>{if(l.has(c))return;l.set(c,Rc.Started);let u=r(c);if(u){let d=this.opts.es5?It.varKinds.var:It.varKinds.const;o=(0,Rt._)`${o}${d} ${c} = ${u};${this.opts._n}`}else if(u=i?.(c))o=(0,Rt._)`${o}${u}${this.opts._n}`;else throw new lp(c);l.set(c,Rc.Completed)})}return o}};It.ValueScope=up});var H=E(K=>{"use strict";Object.defineProperty(K,"__esModule",{value:!0});K.or=K.and=K.not=K.CodeGen=K.operators=K.varKinds=K.ValueScopeName=K.ValueScope=K.Scope=K.Name=K.regexpCode=K.stringify=K.getProperty=K.nil=K.strConcat=K.str=K._=void 0;var ne=$s(),mr=dp(),An=$s();Object.defineProperty(K,"_",{enumerable:!0,get:function(){return An._}});Object.defineProperty(K,"str",{enumerable:!0,get:function(){return An.str}});Object.defineProperty(K,"strConcat",{enumerable:!0,get:function(){return An.strConcat}});Object.defineProperty(K,"nil",{enumerable:!0,get:function(){return An.nil}});Object.defineProperty(K,"getProperty",{enumerable:!0,get:function(){return An.getProperty}});Object.defineProperty(K,"stringify",{enumerable:!0,get:function(){return An.stringify}});Object.defineProperty(K,"regexpCode",{enumerable:!0,get:function(){return An.regexpCode}});Object.defineProperty(K,"Name",{enumerable:!0,get:function(){return An.Name}});var Dc=dp();Object.defineProperty(K,"Scope",{enumerable:!0,get:function(){return Dc.Scope}});Object.defineProperty(K,"ValueScope",{enumerable:!0,get:function(){return Dc.ValueScope}});Object.defineProperty(K,"ValueScopeName",{enumerable:!0,get:function(){return Dc.ValueScopeName}});Object.defineProperty(K,"varKinds",{enumerable:!0,get:function(){return Dc.varKinds}});K.operators={GT:new ne._Code(">"),GTE:new ne._Code(">="),LT:new ne._Code("<"),LTE:new ne._Code("<="),EQ:new ne._Code("==="),NEQ:new ne._Code("!=="),NOT:new ne._Code("!"),OR:new ne._Code("||"),AND:new ne._Code("&&"),ADD:new ne._Code("+")};var tn=class{optimizeNodes(){return this}optimizeNames(t,r){return this}},fp=class extends tn{constructor(t,r,n){super(),this.varKind=t,this.name=r,this.rhs=n}render({es5:t,_n:r}){let n=t?mr.varKinds.var:this.varKind,i=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${i};`+r}optimizeNames(t,r){if(t[this.name.str])return this.rhs&&(this.rhs=lo(this.rhs,t,r)),this}get names(){return this.rhs instanceof ne._CodeOrName?this.rhs.names:{}}},Nc=class extends tn{constructor(t,r,n){super(),this.lhs=t,this.rhs=r,this.sideEffects=n}render({_n:t}){return`${this.lhs} = ${this.rhs};`+t}optimizeNames(t,r){if(!(this.lhs instanceof ne.Name&&!t[this.lhs.str]&&!this.sideEffects))return this.rhs=lo(this.rhs,t,r),this}get names(){let t=this.lhs instanceof ne.Name?{}:{...this.lhs.names};return Zc(t,this.rhs)}},pp=class extends Nc{constructor(t,r,n,i){super(t,n,i),this.op=r}render({_n:t}){return`${this.lhs} ${this.op}= ${this.rhs};`+t}},mp=class extends tn{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`${this.label}:`+t}},hp=class extends tn{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`break${this.label?` ${this.label}`:""};`+t}},gp=class extends tn{constructor(t){super(),this.error=t}render({_n:t}){return`throw ${this.error};`+t}get names(){return this.error.names}},_p=class extends tn{constructor(t){super(),this.code=t}render({_n:t}){return`${this.code};`+t}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(t,r){return this.code=lo(this.code,t,r),this}get names(){return this.code instanceof ne._CodeOrName?this.code.names:{}}},Ts=class extends tn{constructor(t=[]){super(),this.nodes=t}render(t){return this.nodes.reduce((r,n)=>r+n.render(t),"")}optimizeNodes(){let{nodes:t}=this,r=t.length;for(;r--;){let n=t[r].optimizeNodes();Array.isArray(n)?t.splice(r,1,...n):n?t[r]=n:t.splice(r,1)}return t.length>0?this:void 0}optimizeNames(t,r){let{nodes:n}=this,i=n.length;for(;i--;){let o=n[i];o.optimizeNames(t,r)||(pP(t,o.names),n.splice(i,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((t,r)=>bi(t,r.names),{})}},rn=class extends Ts{render(t){return"{"+t._n+super.render(t)+"}"+t._n}},yp=class extends Ts{},co=class extends rn{};co.kind="else";var yi=class e extends rn{constructor(t,r){super(r),this.condition=t}render(t){let r=`if(${this.condition})`+super.render(t);return this.else&&(r+="else "+this.else.render(t)),r}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new co(n):n}if(r)return t===!1?r instanceof e?r:r.nodes:this.nodes.length?this:new e(xb(t),r instanceof e?[r]:r.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(t,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(t,r),!!(super.optimizeNames(t,r)||this.else))return this.condition=lo(this.condition,t,r),this}get names(){let t=super.names;return Zc(t,this.condition),this.else&&bi(t,this.else.names),t}};yi.kind="if";var vi=class extends rn{};vi.kind="for";var vp=class extends vi{constructor(t){super(),this.iteration=t}render(t){return`for(${this.iteration})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iteration=lo(this.iteration,t,r),this}get names(){return bi(super.names,this.iteration.names)}},bp=class extends vi{constructor(t,r,n,i){super(),this.varKind=t,this.name=r,this.from=n,this.to=i}render(t){let r=t.es5?mr.varKinds.var:this.varKind,{name:n,from:i,to:o}=this;return`for(${r} ${n}=${i}; ${n}<${o}; ${n}++)`+super.render(t)}get names(){let t=Zc(super.names,this.from);return Zc(t,this.to)}},Mc=class extends vi{constructor(t,r,n,i){super(),this.loop=t,this.varKind=r,this.name=n,this.iterable=i}render(t){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iterable=lo(this.iterable,t,r),this}get names(){return bi(super.names,this.iterable.names)}},zs=class extends rn{constructor(t,r,n){super(),this.name=t,this.args=r,this.async=n}render(t){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(t)}};zs.kind="func";var Es=class extends Ts{render(t){return"return "+super.render(t)}};Es.kind="return";var wp=class extends rn{render(t){let r="try"+super.render(t);return this.catch&&(r+=this.catch.render(t)),this.finally&&(r+=this.finally.render(t)),r}optimizeNodes(){var t,r;return super.optimizeNodes(),(t=this.catch)===null||t===void 0||t.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(t,r){var n,i;return super.optimizeNames(t,r),(n=this.catch)===null||n===void 0||n.optimizeNames(t,r),(i=this.finally)===null||i===void 0||i.optimizeNames(t,r),this}get names(){let t=super.names;return this.catch&&bi(t,this.catch.names),this.finally&&bi(t,this.finally.names),t}},As=class extends rn{constructor(t){super(),this.error=t}render(t){return`catch(${this.error})`+super.render(t)}};As.kind="catch";var Ps=class extends rn{render(t){return"finally"+super.render(t)}};Ps.kind="finally";var xp=class{constructor(t,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
4
4
|
`:""},this._extScope=t,this._scope=new mr.Scope({parent:t}),this._nodes=[new yp]}toString(){return this._root.render(this.opts)}name(t){return this._scope.name(t)}scopeName(t){return this._extScope.name(t)}scopeValue(t,r){let n=this._extScope.value(t,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(t,r){return this._extScope.getValue(t,r)}scopeRefs(t){return this._extScope.scopeRefs(t,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(t,r,n,i){let o=this._scope.toName(r);return n!==void 0&&i&&(this._constants[o.str]=n),this._leafNode(new fp(t,o,n)),o}const(t,r,n){return this._def(mr.varKinds.const,t,r,n)}let(t,r,n){return this._def(mr.varKinds.let,t,r,n)}var(t,r,n){return this._def(mr.varKinds.var,t,r,n)}assign(t,r,n){return this._leafNode(new Nc(t,r,n))}add(t,r){return this._leafNode(new pp(t,K.operators.ADD,r))}code(t){return typeof t=="function"?t():t!==ne.nil&&this._leafNode(new _p(t)),this}object(...t){let r=["{"];for(let[n,i]of t)r.length>1&&r.push(","),r.push(n),(n!==i||this.opts.es5)&&(r.push(":"),(0,ne.addCodeArg)(r,i));return r.push("}"),new ne._Code(r)}if(t,r,n){if(this._blockNode(new yi(t)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(t){return this._elseNode(new yi(t))}else(){return this._elseNode(new co)}endIf(){return this._endBlockNode(yi,co)}_for(t,r){return this._blockNode(t),r&&this.code(r).endFor(),this}for(t,r){return this._for(new vp(t),r)}forRange(t,r,n,i,o=this.opts.es5?mr.varKinds.var:mr.varKinds.let){let s=this._scope.toName(t);return this._for(new bp(o,s,r,n),()=>i(s))}forOf(t,r,n,i=mr.varKinds.const){let o=this._scope.toName(t);if(this.opts.es5){let s=r instanceof ne.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,ne._)`${s}.length`,a=>{this.var(o,(0,ne._)`${s}[${a}]`),n(o)})}return this._for(new Mc("of",i,o,r),()=>n(o))}forIn(t,r,n,i=this.opts.es5?mr.varKinds.var:mr.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0,ne._)`Object.keys(${r})`,n);let o=this._scope.toName(t);return this._for(new Mc("in",i,o,r),()=>n(o))}endFor(){return this._endBlockNode(vi)}label(t){return this._leafNode(new mp(t))}break(t){return this._leafNode(new hp(t))}return(t){let r=new Es;if(this._blockNode(r),this.code(t),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(Es)}try(t,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let i=new wp;if(this._blockNode(i),this.code(t),r){let o=this.name("e");this._currNode=i.catch=new As(o),r(o)}return n&&(this._currNode=i.finally=new Ps,this.code(n)),this._endBlockNode(As,Ps)}throw(t){return this._leafNode(new gp(t))}block(t,r){return this._blockStarts.push(this._nodes.length),t&&this.code(t).endBlock(r),this}endBlock(t){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||t!==void 0&&n!==t)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${t} expected`);return this._nodes.length=r,this}func(t,r=ne.nil,n,i){return this._blockNode(new zs(t,r,n)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(zs)}optimize(t=1){for(;t-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(t){return this._currNode.nodes.push(t),this}_blockNode(t){this._currNode.nodes.push(t),this._nodes.push(t)}_endBlockNode(t,r){let n=this._currNode;if(n instanceof t||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${t.kind}/${r.kind}`:t.kind}"`)}_elseNode(t){let r=this._currNode;if(!(r instanceof yi))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=t,this}get _root(){return this._nodes[0]}get _currNode(){let t=this._nodes;return t[t.length-1]}set _currNode(t){let r=this._nodes;r[r.length-1]=t}};K.CodeGen=xp;function bi(e,t){for(let r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function Zc(e,t){return t instanceof ne._CodeOrName?bi(e,t.names):e}function lo(e,t,r){if(e instanceof ne.Name)return n(e);if(!i(e))return e;return new ne._Code(e._items.reduce((o,s)=>(s instanceof ne.Name&&(s=n(s)),s instanceof ne._Code?o.push(...s._items):o.push(s),o),[]));function n(o){let s=r[o.str];return s===void 0||t[o.str]!==1?o:(delete t[o.str],s)}function i(o){return o instanceof ne._Code&&o._items.some(s=>s instanceof ne.Name&&t[s.str]===1&&r[s.str]!==void 0)}}function pP(e,t){for(let r in t)e[r]=(e[r]||0)-(t[r]||0)}function xb(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0,ne._)`!${kp(e)}`}K.not=xb;var mP=kb(K.operators.AND);function hP(...e){return e.reduce(mP)}K.and=hP;var gP=kb(K.operators.OR);function _P(...e){return e.reduce(gP)}K.or=_P;function kb(e){return(t,r)=>t===ne.nil?r:r===ne.nil?t:(0,ne._)`${kp(t)} ${e} ${kp(r)}`}function kp(e){return e instanceof ne.Name?e:(0,ne._)`(${e})`}});var se=E(Y=>{"use strict";Object.defineProperty(Y,"__esModule",{value:!0});Y.checkStrictMode=Y.getErrorPath=Y.Type=Y.useFunc=Y.setEvaluated=Y.evaluatedPropsToName=Y.mergeEvaluated=Y.eachItem=Y.unescapeJsonPointer=Y.escapeJsonPointer=Y.escapeFragment=Y.unescapeFragment=Y.schemaRefOrVal=Y.schemaHasRulesButRef=Y.schemaHasRules=Y.checkUnknownRules=Y.alwaysValidSchema=Y.toHash=void 0;var ye=H(),yP=$s();function vP(e){let t={};for(let r of e)t[r]=!0;return t}Y.toHash=vP;function bP(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(Tb(e,t),!zb(t,e.self.RULES.all))}Y.alwaysValidSchema=bP;function Tb(e,t=e.schema){let{opts:r,self:n}=e;if(!r.strictSchema||typeof t=="boolean")return;let i=n.RULES.keywords;for(let o in t)i[o]||Pb(e,`unknown keyword: "${o}"`)}Y.checkUnknownRules=Tb;function zb(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(t[r])return!0;return!1}Y.schemaHasRules=zb;function wP(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}Y.schemaHasRulesButRef=wP;function xP({topSchemaRef:e,schemaPath:t},r,n,i){if(!i){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,ye._)`${r}`}return(0,ye._)`${e}${t}${(0,ye.getProperty)(n)}`}Y.schemaRefOrVal=xP;function kP(e){return Eb(decodeURIComponent(e))}Y.unescapeFragment=kP;function SP(e){return encodeURIComponent($p(e))}Y.escapeFragment=SP;function $p(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}Y.escapeJsonPointer=$p;function Eb(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}Y.unescapeJsonPointer=Eb;function $P(e,t){if(Array.isArray(e))for(let r of e)t(r);else t(e)}Y.eachItem=$P;function Sb({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(i,o,s,a)=>{let l=s===void 0?o:s instanceof ye.Name?(o instanceof ye.Name?e(i,o,s):t(i,o,s),s):o instanceof ye.Name?(t(i,s,o),o):r(o,s);return a===ye.Name&&!(l instanceof ye.Name)?n(i,l):l}}Y.mergeEvaluated={props:Sb({mergeNames:(e,t,r)=>e.if((0,ye._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,ye._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,ye._)`${r} || {}`).code((0,ye._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,ye._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,ye._)`${r} || {}`),Tp(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:Ab}),items:Sb({mergeNames:(e,t,r)=>e.if((0,ye._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,ye._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,ye._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,ye._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function Ab(e,t){if(t===!0)return e.var("props",!0);let r=e.var("props",(0,ye._)`{}`);return t!==void 0&&Tp(e,r,t),r}Y.evaluatedPropsToName=Ab;function Tp(e,t,r){Object.keys(r).forEach(n=>e.assign((0,ye._)`${t}${(0,ye.getProperty)(n)}`,!0))}Y.setEvaluated=Tp;var $b={};function TP(e,t){return e.scopeValue("func",{ref:t,code:$b[t.code]||($b[t.code]=new yP._Code(t.code))})}Y.useFunc=TP;var Sp;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(Sp||(Y.Type=Sp={}));function zP(e,t,r){if(e instanceof ye.Name){let n=t===Sp.Num;return r?n?(0,ye._)`"[" + ${e} + "]"`:(0,ye._)`"['" + ${e} + "']"`:n?(0,ye._)`"/" + ${e}`:(0,ye._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,ye.getProperty)(e).toString():"/"+$p(e)}Y.getErrorPath=zP;function Pb(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}Y.checkStrictMode=Pb});var nn=E(zp=>{"use strict";Object.defineProperty(zp,"__esModule",{value:!0});var dt=H(),EP={data:new dt.Name("data"),valCxt:new dt.Name("valCxt"),instancePath:new dt.Name("instancePath"),parentData:new dt.Name("parentData"),parentDataProperty:new dt.Name("parentDataProperty"),rootData:new dt.Name("rootData"),dynamicAnchors:new dt.Name("dynamicAnchors"),vErrors:new dt.Name("vErrors"),errors:new dt.Name("errors"),this:new dt.Name("this"),self:new dt.Name("self"),scope:new dt.Name("scope"),json:new dt.Name("json"),jsonPos:new dt.Name("jsonPos"),jsonLen:new dt.Name("jsonLen"),jsonPart:new dt.Name("jsonPart")};zp.default=EP});var Os=E(ft=>{"use strict";Object.defineProperty(ft,"__esModule",{value:!0});ft.extendErrors=ft.resetErrorsCount=ft.reportExtraError=ft.reportError=ft.keyword$DataError=ft.keywordError=void 0;var ie=H(),Lc=se(),wt=nn();ft.keywordError={message:({keyword:e})=>(0,ie.str)`must pass "${e}" keyword validation`};ft.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0,ie.str)`"${e}" keyword must be ${t} ($data)`:(0,ie.str)`"${e}" keyword is invalid ($data)`};function AP(e,t=ft.keywordError,r,n){let{it:i}=e,{gen:o,compositeRule:s,allErrors:a}=i,l=Rb(e,t,r);n??(s||a)?Ob(o,l):Cb(i,(0,ie._)`[${l}]`)}ft.reportError=AP;function PP(e,t=ft.keywordError,r){let{it:n}=e,{gen:i,compositeRule:o,allErrors:s}=n,a=Rb(e,t,r);Ob(i,a),o||s||Cb(n,wt.default.vErrors)}ft.reportExtraError=PP;function OP(e,t){e.assign(wt.default.errors,t),e.if((0,ie._)`${wt.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0,ie._)`${wt.default.vErrors}.length`,t),()=>e.assign(wt.default.vErrors,null)))}ft.resetErrorsCount=OP;function CP({gen:e,keyword:t,schemaValue:r,data:n,errsCount:i,it:o}){if(i===void 0)throw new Error("ajv implementation error");let s=e.name("err");e.forRange("i",i,wt.default.errors,a=>{e.const(s,(0,ie._)`${wt.default.vErrors}[${a}]`),e.if((0,ie._)`${s}.instancePath === undefined`,()=>e.assign((0,ie._)`${s}.instancePath`,(0,ie.strConcat)(wt.default.instancePath,o.errorPath))),e.assign((0,ie._)`${s}.schemaPath`,(0,ie.str)`${o.errSchemaPath}/${t}`),o.opts.verbose&&(e.assign((0,ie._)`${s}.schema`,r),e.assign((0,ie._)`${s}.data`,n))})}ft.extendErrors=CP;function Ob(e,t){let r=e.const("err",t);e.if((0,ie._)`${wt.default.vErrors} === null`,()=>e.assign(wt.default.vErrors,(0,ie._)`[${r}]`),(0,ie._)`${wt.default.vErrors}.push(${r})`),e.code((0,ie._)`${wt.default.errors}++`)}function Cb(e,t){let{gen:r,validateName:n,schemaEnv:i}=e;i.$async?r.throw((0,ie._)`new ${e.ValidationError}(${t})`):(r.assign((0,ie._)`${n}.errors`,t),r.return(!1))}var wi={keyword:new ie.Name("keyword"),schemaPath:new ie.Name("schemaPath"),params:new ie.Name("params"),propertyName:new ie.Name("propertyName"),message:new ie.Name("message"),schema:new ie.Name("schema"),parentSchema:new ie.Name("parentSchema")};function Rb(e,t,r){let{createErrors:n}=e.it;return n===!1?(0,ie._)`{}`:RP(e,t,r)}function RP(e,t,r={}){let{gen:n,it:i}=e,o=[IP(i,r),jP(e,r)];return NP(e,t,o),n.object(...o)}function IP({errorPath:e},{instancePath:t}){let r=t?(0,ie.str)`${e}${(0,Lc.getErrorPath)(t,Lc.Type.Str)}`:e;return[wt.default.instancePath,(0,ie.strConcat)(wt.default.instancePath,r)]}function jP({keyword:e,it:{errSchemaPath:t}},{schemaPath:r,parentSchema:n}){let i=n?t:(0,ie.str)`${t}/${e}`;return r&&(i=(0,ie.str)`${i}${(0,Lc.getErrorPath)(r,Lc.Type.Str)}`),[wi.schemaPath,i]}function NP(e,{params:t,message:r},n){let{keyword:i,data:o,schemaValue:s,it:a}=e,{opts:l,propertyName:c,topSchemaRef:u,schemaPath:d}=a;n.push([wi.keyword,i],[wi.params,typeof t=="function"?t(e):t||(0,ie._)`{}`]),l.messages&&n.push([wi.message,typeof r=="function"?r(e):r]),l.verbose&&n.push([wi.schema,s],[wi.parentSchema,(0,ie._)`${u}${d}`],[wt.default.data,o]),c&&n.push([wi.propertyName,c])}});var jb=E(uo=>{"use strict";Object.defineProperty(uo,"__esModule",{value:!0});uo.boolOrEmptySchema=uo.topBoolOrEmptySchema=void 0;var MP=Os(),ZP=H(),DP=nn(),LP={message:"boolean schema is false"};function FP(e){let{gen:t,schema:r,validateName:n}=e;r===!1?Ib(e,!1):typeof r=="object"&&r.$async===!0?t.return(DP.default.data):(t.assign((0,ZP._)`${n}.errors`,null),t.return(!0))}uo.topBoolOrEmptySchema=FP;function qP(e,t){let{gen:r,schema:n}=e;n===!1?(r.var(t,!1),Ib(e)):r.var(t,!0)}uo.boolOrEmptySchema=qP;function Ib(e,t){let{gen:r,data:n}=e,i={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,MP.reportError)(i,LP,void 0,t)}});var Ep=E(fo=>{"use strict";Object.defineProperty(fo,"__esModule",{value:!0});fo.getRules=fo.isJSONType=void 0;var UP=["string","number","integer","boolean","null","object","array"],VP=new Set(UP);function GP(e){return typeof e=="string"&&VP.has(e)}fo.isJSONType=GP;function BP(){let e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}fo.getRules=BP});var Ap=E(Pn=>{"use strict";Object.defineProperty(Pn,"__esModule",{value:!0});Pn.shouldUseRule=Pn.shouldUseGroup=Pn.schemaHasRulesForType=void 0;function JP({schema:e,self:t},r){let n=t.RULES.types[r];return n&&n!==!0&&Nb(e,n)}Pn.schemaHasRulesForType=JP;function Nb(e,t){return t.rules.some(r=>Mb(e,r))}Pn.shouldUseGroup=Nb;function Mb(e,t){var r;return e[t.keyword]!==void 0||((r=t.definition.implements)===null||r===void 0?void 0:r.some(n=>e[n]!==void 0))}Pn.shouldUseRule=Mb});var Cs=E(pt=>{"use strict";Object.defineProperty(pt,"__esModule",{value:!0});pt.reportTypeError=pt.checkDataTypes=pt.checkDataType=pt.coerceAndCheckDataType=pt.getJSONTypes=pt.getSchemaTypes=pt.DataType=void 0;var WP=Ep(),HP=Ap(),KP=Os(),B=H(),Zb=se(),po;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(po||(pt.DataType=po={}));function XP(e){let t=Db(e.type);if(t.includes("null")){if(e.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===!0&&t.push("null")}return t}pt.getSchemaTypes=XP;function Db(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(WP.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}pt.getJSONTypes=Db;function YP(e,t){let{gen:r,data:n,opts:i}=e,o=QP(t,i.coerceTypes),s=t.length>0&&!(o.length===0&&t.length===1&&(0,HP.schemaHasRulesForType)(e,t[0]));if(s){let a=Op(t,n,i.strictNumbers,po.Wrong);r.if(a,()=>{o.length?eO(e,t,o):Cp(e)})}return s}pt.coerceAndCheckDataType=YP;var Lb=new Set(["string","number","integer","boolean","null"]);function QP(e,t){return t?e.filter(r=>Lb.has(r)||t==="array"&&r==="array"):[]}function eO(e,t,r){let{gen:n,data:i,opts:o}=e,s=n.let("dataType",(0,B._)`typeof ${i}`),a=n.let("coerced",(0,B._)`undefined`);o.coerceTypes==="array"&&n.if((0,B._)`${s} == 'object' && Array.isArray(${i}) && ${i}.length == 1`,()=>n.assign(i,(0,B._)`${i}[0]`).assign(s,(0,B._)`typeof ${i}`).if(Op(t,i,o.strictNumbers),()=>n.assign(a,i))),n.if((0,B._)`${a} !== undefined`);for(let c of r)(Lb.has(c)||c==="array"&&o.coerceTypes==="array")&&l(c);n.else(),Cp(e),n.endIf(),n.if((0,B._)`${a} !== undefined`,()=>{n.assign(i,a),tO(e,a)});function l(c){switch(c){case"string":n.elseIf((0,B._)`${s} == "number" || ${s} == "boolean"`).assign(a,(0,B._)`"" + ${i}`).elseIf((0,B._)`${i} === null`).assign(a,(0,B._)`""`);return;case"number":n.elseIf((0,B._)`${s} == "boolean" || ${i} === null
|
|
5
5
|
|| (${s} == "string" && ${i} && ${i} == +${i})`).assign(a,(0,B._)`+${i}`);return;case"integer":n.elseIf((0,B._)`${s} === "boolean" || ${i} === null
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';
|
|
2
|
-
const require =
|
|
1
|
+
import { createRequire as __linzumiBundleCreateRequire } from 'node:module';
|
|
2
|
+
const require = __linzumiBundleCreateRequire(import.meta.url);
|
|
3
3
|
var lr=Object.create;var wn=Object.defineProperty;var ur=Object.getOwnPropertyDescriptor;var fr=Object.getOwnPropertyNames;var pr=Object.getPrototypeOf,gr=Object.prototype.hasOwnProperty;var E=(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 A=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports);var mr=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of fr(n))!gr.call(e,o)&&o!==t&&wn(e,o,{get:()=>n[o],enumerable:!(r=ur(n,o))||r.enumerable});return e};var fe=(e,n,t)=>(t=e!=null?lr(pr(e)):{},mr(n||!e||!e.__esModule?wn(t,"default",{value:e,enumerable:!0}):t,e));var F=A((Oi,On)=>{"use strict";var kn=["nodebuffer","arraybuffer","fragments"],Cn=typeof Blob<"u";Cn&&kn.push("blob");On.exports={BINARY_TYPES:kn,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:Cn,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var pe=A((Ei,Ce)=>{"use strict";var{EMPTY_BUFFER:hr}=F(),Ve=Buffer[Symbol.species];function yr(e,n){if(e.length===0)return hr;if(e.length===1)return e[0];let t=Buffer.allocUnsafe(n),r=0;for(let o=0;o<e.length;o++){let s=e[o];t.set(s,r),r+=s.length}return r<n?new Ve(t.buffer,t.byteOffset,r):t}function En(e,n,t,r,o){for(let s=0;s<o;s++)t[r+s]=e[s]^n[s&3]}function Pn(e,n){for(let t=0;t<e.length;t++)e[t]^=n[t&3]}function _r(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)}function Ge(e){if(Ge.readOnly=!0,Buffer.isBuffer(e))return e;let n;return e instanceof ArrayBuffer?n=new Ve(e):ArrayBuffer.isView(e)?n=new Ve(e.buffer,e.byteOffset,e.byteLength):(n=Buffer.from(e),Ge.readOnly=!1),n}Ce.exports={concat:yr,mask:En,toArrayBuffer:_r,toBuffer:Ge,unmask:Pn};if(!process.env.WS_NO_BUFFER_UTIL)try{let e=E("bufferutil");Ce.exports.mask=function(n,t,r,o,s){s<48?En(n,t,r,o,s):e.mask(n,t,r,o,s)},Ce.exports.unmask=function(n,t){n.length<32?Pn(n,t):e.unmask(n,t)}}catch{}});var An=A((Pi,In)=>{"use strict";var Tn=Symbol("kDone"),qe=Symbol("kRun"),Be=class{constructor(n){this[Tn]=()=>{this.pending--,this[qe]()},this.concurrency=n||1/0,this.jobs=[],this.pending=0}add(n){this.jobs.push(n),this[qe]()}[qe](){if(this.pending!==this.concurrency&&this.jobs.length){let n=this.jobs.shift();this.pending++,n(this[Tn])}}};In.exports=Be});var me=A((Ti,Nn)=>{"use strict";var ge=E("zlib"),Rn=pe(),xr=An(),{kStatusCode:Mn}=F(),br=Buffer[Symbol.species],vr=Buffer.from([0,0,255,255]),Ee=Symbol("permessage-deflate"),V=Symbol("total-length"),te=Symbol("callback"),B=Symbol("buffers"),re=Symbol("error"),Oe,We=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,!Oe){let o=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Oe=new xr(o)}}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[te];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(o=>!(t.serverNoContextTakeover===!1&&o.server_no_context_takeover||o.server_max_window_bits&&(t.serverMaxWindowBits===!1||typeof t.serverMaxWindowBits=="number"&&t.serverMaxWindowBits>o.server_max_window_bits)||typeof t.clientMaxWindowBits=="number"&&!o.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 o=t[r];if(o.length>1)throw new Error(`Parameter "${r}" must have only a single value`);if(o=o[0],r==="client_max_window_bits"){if(o!==!0){let s=+o;if(!Number.isInteger(s)||s<8||s>15)throw new TypeError(`Invalid value for parameter "${r}": ${o}`);o=s}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${r}": ${o}`)}else if(r==="server_max_window_bits"){let s=+o;if(!Number.isInteger(s)||s<8||s>15)throw new TypeError(`Invalid value for parameter "${r}": ${o}`);o=s}else if(r==="client_no_context_takeover"||r==="server_no_context_takeover"){if(o!==!0)throw new TypeError(`Invalid value for parameter "${r}": ${o}`)}else throw new Error(`Unknown parameter "${r}"`);t[r]=o})}),n}decompress(n,t,r){Oe.add(o=>{this._decompress(n,t,(s,i)=>{o(),r(s,i)})})}compress(n,t,r){Oe.add(o=>{this._compress(n,t,(s,i)=>{o(),r(s,i)})})}_decompress(n,t,r){let o=this._isServer?"client":"server";if(!this._inflate){let s=`${o}_max_window_bits`,i=typeof this.params[s]!="number"?ge.Z_DEFAULT_WINDOWBITS:this.params[s];this._inflate=ge.createInflateRaw({...this._options.zlibInflateOptions,windowBits:i}),this._inflate[Ee]=this,this._inflate[V]=0,this._inflate[B]=[],this._inflate.on("error",wr),this._inflate.on("data",jn)}this._inflate[te]=r,this._inflate.write(n),t&&this._inflate.write(vr),this._inflate.flush(()=>{let s=this._inflate[re];if(s){this._inflate.close(),this._inflate=null,r(s);return}let i=Rn.concat(this._inflate[B],this._inflate[V]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[V]=0,this._inflate[B]=[],t&&this.params[`${o}_no_context_takeover`]&&this._inflate.reset()),r(null,i)})}_compress(n,t,r){let o=this._isServer?"server":"client";if(!this._deflate){let s=`${o}_max_window_bits`,i=typeof this.params[s]!="number"?ge.Z_DEFAULT_WINDOWBITS:this.params[s];this._deflate=ge.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:i}),this._deflate[V]=0,this._deflate[B]=[],this._deflate.on("data",Sr)}this._deflate[te]=r,this._deflate.write(n),this._deflate.flush(ge.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let s=Rn.concat(this._deflate[B],this._deflate[V]);t&&(s=new br(s.buffer,s.byteOffset,s.length-4)),this._deflate[te]=null,this._deflate[V]=0,this._deflate[B]=[],t&&this.params[`${o}_no_context_takeover`]&&this._deflate.reset(),r(null,s)})}};Nn.exports=We;function Sr(e){this[B].push(e),this[V]+=e.length}function jn(e){if(this[V]+=e.length,this[Ee]._maxPayload<1||this[V]<=this[Ee]._maxPayload){this[B].push(e);return}this[re]=new RangeError("Max payload size exceeded"),this[re].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[re][Mn]=1009,this.removeListener("data",jn),this.reset()}function wr(e){if(this[Ee]._inflate=null,this[re]){this[te](this[re]);return}e[Mn]=1007,this[te](e)}});var oe=A((Ii,Pe)=>{"use strict";var{isUtf8:Ln}=E("buffer"),{hasBlob:kr}=F(),Cr=[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 Or(e){return e>=1e3&&e<=1014&&e!==1004&&e!==1005&&e!==1006||e>=3e3&&e<=4999}function Ke(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 Er(e){return kr&&typeof e=="object"&&typeof e.arrayBuffer=="function"&&typeof e.type=="string"&&typeof e.stream=="function"&&(e[Symbol.toStringTag]==="Blob"||e[Symbol.toStringTag]==="File")}Pe.exports={isBlob:Er,isValidStatusCode:Or,isValidUTF8:Ke,tokenChars:Cr};if(Ln)Pe.exports.isValidUTF8=function(e){return e.length<24?Ke(e):Ln(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let e=E("utf-8-validate");Pe.exports.isValidUTF8=function(n){return n.length<32?Ke(n):e(n)}}catch{}});var Qe=A((Ai,Vn)=>{"use strict";var{Writable:Pr}=E("stream"),Jn=me(),{BINARY_TYPES:Tr,EMPTY_BUFFER:$n,kStatusCode:Ir,kWebSocket:Ar}=F(),{concat:He,toArrayBuffer:Rr,unmask:Mr}=pe(),{isValidStatusCode:jr,isValidUTF8:Un}=oe(),Te=Buffer[Symbol.species],j=0,Dn=1,zn=2,Fn=3,Ze=4,Xe=5,Ie=6,Ye=class extends Pr{constructor(n={}){super(),this._allowSynchronousEvents=n.allowSynchronousEvents!==void 0?n.allowSynchronousEvents:!0,this._binaryType=n.binaryType||Tr[0],this._extensions=n.extensions||{},this._isServer=!!n.isServer,this._maxPayload=n.maxPayload|0,this._skipUTF8Validation=!!n.skipUTF8Validation,this[Ar]=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=j}_write(n,t,r){if(this._opcode===8&&this._state==j)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 Te(r.buffer,r.byteOffset+n,r.length-n),new Te(r.buffer,r.byteOffset,n)}let t=Buffer.allocUnsafe(n);do{let r=this._buffers[0],o=t.length-n;n>=r.length?t.set(this._buffers.shift(),o):(t.set(new Uint8Array(r.buffer,r.byteOffset,n),o),this._buffers[0]=new Te(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 j:this.getInfo(n);break;case Dn:this.getPayloadLength16(n);break;case zn:this.getPayloadLength64(n);break;case Fn:this.getMask();break;case Ze:this.getData(n);break;case Xe:case Ie: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 o=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");n(o);return}let r=(t[0]&64)===64;if(r&&!this._extensions[Jn.extensionName]){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");n(o);return}if(this._fin=(t[0]&128)===128,this._opcode=t[0]&15,this._payloadLength=t[1]&127,this._opcode===0){if(r){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");n(o);return}if(!this._fragmented){let o=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");n(o);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let o=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");n(o);return}this._compressed=r}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let o=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");n(o);return}if(r){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");n(o);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let o=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");n(o);return}}else{let o=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");n(o);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(t[1]&128)===128,this._isServer){if(!this._masked){let o=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");n(o);return}}else if(this._masked){let o=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");n(o);return}this._payloadLength===126?this._state=Dn:this._payloadLength===127?this._state=zn: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 o=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");n(o);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=Fn:this._state=Ze}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Ze}getData(n){let t=$n;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&&Mr(t,this._mask)}if(this._opcode>7){this.controlMessage(t,n);return}if(this._compressed){this._state=Xe,this.decompress(t,n);return}t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage(n)}decompress(n,t){this._extensions[Jn.extensionName].decompress(n,this._fin,(o,s)=>{if(o)return t(o);if(s.length){if(this._messageLength+=s.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let i=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");t(i);return}this._fragments.push(s)}this.dataMessage(t),this._state===j&&this.startLoop(t)})}dataMessage(n){if(!this._fin){this._state=j;return}let t=this._messageLength,r=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let o;this._binaryType==="nodebuffer"?o=He(r,t):this._binaryType==="arraybuffer"?o=Rr(He(r,t)):this._binaryType==="blob"?o=new Blob(r):o=r,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=j):(this._state=Ie,setImmediate(()=>{this.emit("message",o,!0),this._state=j,this.startLoop(n)}))}else{let o=He(r,t);if(!this._skipUTF8Validation&&!Un(o)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");n(s);return}this._state===Xe||this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=j):(this._state=Ie,setImmediate(()=>{this.emit("message",o,!1),this._state=j,this.startLoop(n)}))}}controlMessage(n,t){if(this._opcode===8){if(n.length===0)this._loop=!1,this.emit("conclude",1005,$n),this.end();else{let r=n.readUInt16BE(0);if(!jr(r)){let s=this.createError(RangeError,`invalid status code ${r}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");t(s);return}let o=new Te(n.buffer,n.byteOffset+2,n.length-2);if(!this._skipUTF8Validation&&!Un(o)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");t(s);return}this._loop=!1,this.emit("conclude",r,o),this.end()}this._state=j;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",n),this._state=j):(this._state=Ie,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",n),this._state=j,this.startLoop(t)}))}createError(n,t,r,o,s){this._loop=!1,this._errored=!0;let i=new n(r?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(i,this.createError),i.code=s,i[Ir]=o,i}};Vn.exports=Ye});var tn=A((Mi,Bn)=>{"use strict";var{Duplex:Ri}=E("stream"),{randomFillSync:Nr}=E("crypto"),Gn=me(),{EMPTY_BUFFER:Lr,kWebSocket:Jr,NOOP:$r}=F(),{isBlob:se,isValidStatusCode:Ur}=oe(),{mask:qn,toBuffer:H}=pe(),N=Symbol("kByteLength"),Dr=Buffer.alloc(4),Ae=8*1024,Z,ie=Ae,J=0,zr=1,Fr=2,en=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=J,this.onerror=$r,this[Jr]=void 0}static frame(n,t){let r,o=!1,s=2,i=!1;t.mask&&(r=t.maskBuffer||Dr,t.generateMask?t.generateMask(r):(ie===Ae&&(Z===void 0&&(Z=Buffer.alloc(Ae)),Nr(Z,0,Ae),ie=0),r[0]=Z[ie++],r[1]=Z[ie++],r[2]=Z[ie++],r[3]=Z[ie++]),i=(r[0]|r[1]|r[2]|r[3])===0,s=6);let a;typeof n=="string"?(!t.mask||i)&&t[N]!==void 0?a=t[N]:(n=Buffer.from(n),a=n.length):(a=n.length,o=t.mask&&t.readOnly&&!i);let c=a;a>=65536?(s+=8,c=127):a>125&&(s+=2,c=126);let d=Buffer.allocUnsafe(o?a+s:s);return d[0]=t.fin?t.opcode|128:t.opcode,t.rsv1&&(d[0]|=64),d[1]=c,c===126?d.writeUInt16BE(a,2):c===127&&(d[2]=d[3]=0,d.writeUIntBE(a,4,6)),t.mask?(d[1]|=128,d[s-4]=r[0],d[s-3]=r[1],d[s-2]=r[2],d[s-1]=r[3],i?[d,n]:o?(qn(n,r,d,s,a),[d]):(qn(n,r,n,0,a),[d,n])):[d,n]}close(n,t,r,o){let s;if(n===void 0)s=Lr;else{if(typeof n!="number"||!Ur(n))throw new TypeError("First argument must be a valid error code number");if(t===void 0||!t.length)s=Buffer.allocUnsafe(2),s.writeUInt16BE(n,0);else{let a=Buffer.byteLength(t);if(a>123)throw new RangeError("The message must not be greater than 123 bytes");s=Buffer.allocUnsafe(2+a),s.writeUInt16BE(n,0),typeof t=="string"?s.write(t,2):s.set(t,2)}}let i={[N]:s.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==J?this.enqueue([this.dispatch,s,!1,i,o]):this.sendFrame(e.frame(s,i),o)}ping(n,t,r){let o,s;if(typeof n=="string"?(o=Buffer.byteLength(n),s=!1):se(n)?(o=n.size,s=!1):(n=H(n),o=n.length,s=H.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let i={[N]:o,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:s,rsv1:!1};se(n)?this._state!==J?this.enqueue([this.getBlobData,n,!1,i,r]):this.getBlobData(n,!1,i,r):this._state!==J?this.enqueue([this.dispatch,n,!1,i,r]):this.sendFrame(e.frame(n,i),r)}pong(n,t,r){let o,s;if(typeof n=="string"?(o=Buffer.byteLength(n),s=!1):se(n)?(o=n.size,s=!1):(n=H(n),o=n.length,s=H.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let i={[N]:o,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:s,rsv1:!1};se(n)?this._state!==J?this.enqueue([this.getBlobData,n,!1,i,r]):this.getBlobData(n,!1,i,r):this._state!==J?this.enqueue([this.dispatch,n,!1,i,r]):this.sendFrame(e.frame(n,i),r)}send(n,t,r){let o=this._extensions[Gn.extensionName],s=t.binary?2:1,i=t.compress,a,c;typeof n=="string"?(a=Buffer.byteLength(n),c=!1):se(n)?(a=n.size,c=!1):(n=H(n),a=n.length,c=H.readOnly),this._firstFragment?(this._firstFragment=!1,i&&o&&o.params[o._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(i=a>=o._threshold),this._compress=i):(i=!1,s=0),t.fin&&(this._firstFragment=!0);let d={[N]:a,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:s,readOnly:c,rsv1:i};se(n)?this._state!==J?this.enqueue([this.getBlobData,n,this._compress,d,r]):this.getBlobData(n,this._compress,d,r):this._state!==J?this.enqueue([this.dispatch,n,this._compress,d,r]):this.dispatch(n,this._compress,d,r)}getBlobData(n,t,r,o){this._bufferedBytes+=r[N],this._state=Fr,n.arrayBuffer().then(s=>{if(this._socket.destroyed){let a=new Error("The socket was closed while the blob was being read");process.nextTick(nn,this,a,o);return}this._bufferedBytes-=r[N];let i=H(s);t?this.dispatch(i,t,r,o):(this._state=J,this.sendFrame(e.frame(i,r),o),this.dequeue())}).catch(s=>{process.nextTick(Vr,this,s,o)})}dispatch(n,t,r,o){if(!t){this.sendFrame(e.frame(n,r),o);return}let s=this._extensions[Gn.extensionName];this._bufferedBytes+=r[N],this._state=zr,s.compress(n,r.fin,(i,a)=>{if(this._socket.destroyed){let c=new Error("The socket was closed while data was being compressed");nn(this,c,o);return}this._bufferedBytes-=r[N],this._state=J,r.readOnly=!1,this.sendFrame(e.frame(a,r),o),this.dequeue()})}dequeue(){for(;this._state===J&&this._queue.length;){let n=this._queue.shift();this._bufferedBytes-=n[3][N],Reflect.apply(n[0],this,n.slice(1))}}enqueue(n){this._bufferedBytes+=n[3][N],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)}};Bn.exports=en;function nn(e,n,t){typeof t=="function"&&t(n);for(let r=0;r<e._queue.length;r++){let o=e._queue[r],s=o[o.length-1];typeof s=="function"&&s(n)}}function Vr(e,n,t){nn(e,n,t),e.onerror(n)}});var nt=A((ji,et)=>{"use strict";var{kForOnEventAttribute:he,kListener:rn}=F(),Wn=Symbol("kCode"),Kn=Symbol("kData"),Hn=Symbol("kError"),Zn=Symbol("kMessage"),Xn=Symbol("kReason"),ae=Symbol("kTarget"),Yn=Symbol("kType"),Qn=Symbol("kWasClean"),G=class{constructor(n){this[ae]=null,this[Yn]=n}get target(){return this[ae]}get type(){return this[Yn]}};Object.defineProperty(G.prototype,"target",{enumerable:!0});Object.defineProperty(G.prototype,"type",{enumerable:!0});var X=class extends G{constructor(n,t={}){super(n),this[Wn]=t.code===void 0?0:t.code,this[Xn]=t.reason===void 0?"":t.reason,this[Qn]=t.wasClean===void 0?!1:t.wasClean}get code(){return this[Wn]}get reason(){return this[Xn]}get wasClean(){return this[Qn]}};Object.defineProperty(X.prototype,"code",{enumerable:!0});Object.defineProperty(X.prototype,"reason",{enumerable:!0});Object.defineProperty(X.prototype,"wasClean",{enumerable:!0});var de=class extends G{constructor(n,t={}){super(n),this[Hn]=t.error===void 0?null:t.error,this[Zn]=t.message===void 0?"":t.message}get error(){return this[Hn]}get message(){return this[Zn]}};Object.defineProperty(de.prototype,"error",{enumerable:!0});Object.defineProperty(de.prototype,"message",{enumerable:!0});var ye=class extends G{constructor(n,t={}){super(n),this[Kn]=t.data===void 0?null:t.data}get data(){return this[Kn]}};Object.defineProperty(ye.prototype,"data",{enumerable:!0});var Gr={addEventListener(e,n,t={}){for(let o of this.listeners(e))if(!t[he]&&o[rn]===n&&!o[he])return;let r;if(e==="message")r=function(s,i){let a=new ye("message",{data:i?s:s.toString()});a[ae]=this,Re(n,this,a)};else if(e==="close")r=function(s,i){let a=new X("close",{code:s,reason:i.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});a[ae]=this,Re(n,this,a)};else if(e==="error")r=function(s){let i=new de("error",{error:s,message:s.message});i[ae]=this,Re(n,this,i)};else if(e==="open")r=function(){let s=new G("open");s[ae]=this,Re(n,this,s)};else return;r[he]=!!t[he],r[rn]=n,t.once?this.once(e,r):this.on(e,r)},removeEventListener(e,n){for(let t of this.listeners(e))if(t[rn]===n&&!t[he]){this.removeListener(e,t);break}}};et.exports={CloseEvent:X,ErrorEvent:de,Event:G,EventTarget:Gr,MessageEvent:ye};function Re(e,n,t){typeof e=="object"&&e.handleEvent?e.handleEvent.call(e,t):e.call(n,t)}});var on=A((Ni,tt)=>{"use strict";var{tokenChars:_e}=oe();function U(e,n,t){e[n]===void 0?e[n]=[t]:e[n].push(t)}function qr(e){let n=Object.create(null),t=Object.create(null),r=!1,o=!1,s=!1,i,a,c=-1,d=-1,f=-1,p=0;for(;p<e.length;p++)if(d=e.charCodeAt(p),i===void 0)if(f===-1&&_e[d]===1)c===-1&&(c=p);else if(p!==0&&(d===32||d===9))f===-1&&c!==-1&&(f=p);else if(d===59||d===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${p}`);f===-1&&(f=p);let u=e.slice(c,f);d===44?(U(n,u,t),t=Object.create(null)):i=u,c=f=-1}else throw new SyntaxError(`Unexpected character at index ${p}`);else if(a===void 0)if(f===-1&&_e[d]===1)c===-1&&(c=p);else if(d===32||d===9)f===-1&&c!==-1&&(f=p);else if(d===59||d===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${p}`);f===-1&&(f=p),U(t,e.slice(c,f),!0),d===44&&(U(n,i,t),t=Object.create(null),i=void 0),c=f=-1}else if(d===61&&c!==-1&&f===-1)a=e.slice(c,p),c=f=-1;else throw new SyntaxError(`Unexpected character at index ${p}`);else if(o){if(_e[d]!==1)throw new SyntaxError(`Unexpected character at index ${p}`);c===-1?c=p:r||(r=!0),o=!1}else if(s)if(_e[d]===1)c===-1&&(c=p);else if(d===34&&c!==-1)s=!1,f=p;else if(d===92)o=!0;else throw new SyntaxError(`Unexpected character at index ${p}`);else if(d===34&&e.charCodeAt(p-1)===61)s=!0;else if(f===-1&&_e[d]===1)c===-1&&(c=p);else if(c!==-1&&(d===32||d===9))f===-1&&(f=p);else if(d===59||d===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${p}`);f===-1&&(f=p);let u=e.slice(c,f);r&&(u=u.replace(/\\/g,""),r=!1),U(t,a,u),d===44&&(U(n,i,t),t=Object.create(null),i=void 0),a=void 0,c=f=-1}else throw new SyntaxError(`Unexpected character at index ${p}`);if(c===-1||s||d===32||d===9)throw new SyntaxError("Unexpected end of input");f===-1&&(f=p);let y=e.slice(c,f);return i===void 0?U(n,y,t):(a===void 0?U(t,y,!0):r?U(t,a,y.replace(/\\/g,"")):U(t,a,y),U(n,i,t)),n}function Br(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(o=>{let s=r[o];return Array.isArray(s)||(s=[s]),s.map(i=>i===!0?o:`${o}=${i}`).join("; ")})).join("; ")).join(", ")}).join(", ")}tt.exports={format:Br,parse:qr}});var Le=A(($i,gt)=>{"use strict";var Wr=E("events"),Kr=E("https"),Hr=E("http"),st=E("net"),Zr=E("tls"),{randomBytes:Xr,createHash:Yr}=E("crypto"),{Duplex:Li,Readable:Ji}=E("stream"),{URL:sn}=E("url"),W=me(),Qr=Qe(),eo=tn(),{isBlob:no}=oe(),{BINARY_TYPES:rt,EMPTY_BUFFER:Me,GUID:to,kForOnEventAttribute:an,kListener:ro,kStatusCode:oo,kWebSocket:P,NOOP:it}=F(),{EventTarget:{addEventListener:so,removeEventListener:io}}=nt(),{format:ao,parse:co}=on(),{toBuffer:lo}=pe(),uo=30*1e3,at=Symbol("kAborted"),dn=[8,13],q=["CONNECTING","OPEN","CLOSING","CLOSED"],fo=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,C=class e extends Wr{constructor(n,t,r){super(),this._binaryType=rt[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Me,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]),dt(this,n,t,r)):(this._autoPong=r.autoPong,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(n){rt.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 o=new Qr({allowSynchronousEvents:r.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation}),s=new eo(n,this._extensions,r.generateMask);this._receiver=o,this._sender=s,this._socket=n,o[P]=this,s[P]=this,n[P]=this,o.on("conclude",mo),o.on("drain",ho),o.on("error",yo),o.on("message",_o),o.on("ping",xo),o.on("pong",bo),s.onerror=vo,n.setTimeout&&n.setTimeout(0),n.setNoDelay&&n.setNoDelay(),t.length>0&&n.unshift(t),n.on("close",ut),n.on("data",Ne),n.on("end",ft),n.on("error",pt),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[W.extensionName]&&this._extensions[W.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){R(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())}),lt(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){cn(this,n,r);return}t===void 0&&(t=!this._isServer),this._sender.ping(n||Me,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){cn(this,n,r);return}t===void 0&&(t=!this._isServer),this._sender.pong(n||Me,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){cn(this,n,r);return}let o={binary:typeof n!="string",mask:!this._isServer,compress:!0,fin:!0,...t};this._extensions[W.extensionName]||(o.compress=!1),this._sender.send(n||Me,o,r)}terminate(){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){R(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=e.CLOSING,this._socket.destroy())}}};Object.defineProperty(C,"CONNECTING",{enumerable:!0,value:q.indexOf("CONNECTING")});Object.defineProperty(C.prototype,"CONNECTING",{enumerable:!0,value:q.indexOf("CONNECTING")});Object.defineProperty(C,"OPEN",{enumerable:!0,value:q.indexOf("OPEN")});Object.defineProperty(C.prototype,"OPEN",{enumerable:!0,value:q.indexOf("OPEN")});Object.defineProperty(C,"CLOSING",{enumerable:!0,value:q.indexOf("CLOSING")});Object.defineProperty(C.prototype,"CLOSING",{enumerable:!0,value:q.indexOf("CLOSING")});Object.defineProperty(C,"CLOSED",{enumerable:!0,value:q.indexOf("CLOSED")});Object.defineProperty(C.prototype,"CLOSED",{enumerable:!0,value:q.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(e=>{Object.defineProperty(C.prototype,e,{enumerable:!0})});["open","error","close","message"].forEach(e=>{Object.defineProperty(C.prototype,`on${e}`,{enumerable:!0,get(){for(let n of this.listeners(e))if(n[an])return n[ro];return null},set(n){for(let t of this.listeners(e))if(t[an]){this.removeListener(e,t);break}typeof n=="function"&&this.addEventListener(e,n,{[an]:!0})}})});C.prototype.addEventListener=so;C.prototype.removeEventListener=io;gt.exports=C;function dt(e,n,t,r){let o={allowSynchronousEvents:!0,autoPong:!0,protocolVersion:dn[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=o.autoPong,!dn.includes(o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${dn.join(", ")})`);let s;if(n instanceof sn)s=n;else try{s=new sn(n)}catch{throw new SyntaxError(`Invalid URL: ${n}`)}s.protocol==="http:"?s.protocol="ws:":s.protocol==="https:"&&(s.protocol="wss:"),e._url=s.href;let i=s.protocol==="wss:",a=s.protocol==="ws+unix:",c;if(s.protocol!=="ws:"&&!i&&!a?c=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:a&&!s.pathname?c="The URL's pathname is empty":s.hash&&(c="The URL contains a fragment identifier"),c){let l=new SyntaxError(c);if(e._redirects===0)throw l;je(e,l);return}let d=i?443:80,f=Xr(16).toString("base64"),p=i?Kr.request:Hr.request,y=new Set,u;if(o.createConnection=o.createConnection||(i?go:po),o.defaultPort=o.defaultPort||d,o.port=s.port||d,o.host=s.hostname.startsWith("[")?s.hostname.slice(1,-1):s.hostname,o.headers={...o.headers,"Sec-WebSocket-Version":o.protocolVersion,"Sec-WebSocket-Key":f,Connection:"Upgrade",Upgrade:"websocket"},o.path=s.pathname+s.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&(u=new W(o.perMessageDeflate!==!0?o.perMessageDeflate:{},!1,o.maxPayload),o.headers["Sec-WebSocket-Extensions"]=ao({[W.extensionName]:u.offer()})),t.length){for(let l of t){if(typeof l!="string"||!fo.test(l)||y.has(l))throw new SyntaxError("An invalid or duplicated subprotocol was specified");y.add(l)}o.headers["Sec-WebSocket-Protocol"]=t.join(",")}if(o.origin&&(o.protocolVersion<13?o.headers["Sec-WebSocket-Origin"]=o.origin:o.headers.Origin=o.origin),(s.username||s.password)&&(o.auth=`${s.username}:${s.password}`),a){let l=o.path.split(":");o.socketPath=l[0],o.path=l[1]}let g;if(o.followRedirects){if(e._redirects===0){e._originalIpc=a,e._originalSecure=i,e._originalHostOrSocketPath=a?o.socketPath:s.host;let l=r&&r.headers;if(r={...r,headers:{}},l)for(let[x,O]of Object.entries(l))r.headers[x.toLowerCase()]=O}else if(e.listenerCount("redirect")===0){let l=a?e._originalIpc?o.socketPath===e._originalHostOrSocketPath:!1:e._originalIpc?!1:s.host===e._originalHostOrSocketPath;(!l||e._originalSecure&&!i)&&(delete o.headers.authorization,delete o.headers.cookie,l||delete o.headers.host,o.auth=void 0)}o.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")),g=e._req=p(o),e._redirects&&e.emit("redirect",e.url,g)}else g=e._req=p(o);o.timeout&&g.on("timeout",()=>{R(e,g,"Opening handshake has timed out")}),g.on("error",l=>{g===null||g[at]||(g=e._req=null,je(e,l))}),g.on("response",l=>{let x=l.headers.location,O=l.statusCode;if(x&&o.followRedirects&&O>=300&&O<400){if(++e._redirects>o.maxRedirects){R(e,g,"Maximum redirects exceeded");return}g.abort();let M;try{M=new sn(x,n)}catch{let v=new SyntaxError(`Invalid URL: ${x}`);je(e,v);return}dt(e,M,t,r)}else e.emit("unexpected-response",g,l)||R(e,g,`Unexpected server response: ${l.statusCode}`)}),g.on("upgrade",(l,x,O)=>{if(e.emit("upgrade",l),e.readyState!==C.CONNECTING)return;g=e._req=null;let M=l.headers.upgrade;if(M===void 0||M.toLowerCase()!=="websocket"){R(e,x,"Invalid Upgrade header");return}let L=Yr("sha1").update(f+to).digest("base64");if(l.headers["sec-websocket-accept"]!==L){R(e,x,"Invalid Sec-WebSocket-Accept header");return}let v=l.headers["sec-websocket-protocol"],h;if(v!==void 0?y.size?y.has(v)||(h="Server sent an invalid subprotocol"):h="Server sent a subprotocol but none was requested":y.size&&(h="Server sent no subprotocol"),h){R(e,x,h);return}v&&(e._protocol=v);let S=l.headers["sec-websocket-extensions"];if(S!==void 0){if(!u){R(e,x,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let k;try{k=co(S)}catch{R(e,x,"Invalid Sec-WebSocket-Extensions header");return}let b=Object.keys(k);if(b.length!==1||b[0]!==W.extensionName){R(e,x,"Server indicated an extension that was not requested");return}try{u.accept(k[W.extensionName])}catch{R(e,x,"Invalid Sec-WebSocket-Extensions header");return}e._extensions[W.extensionName]=u}e.setSocket(x,O,{allowSynchronousEvents:o.allowSynchronousEvents,generateMask:o.generateMask,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(g,e):g.end()}function je(e,n){e._readyState=C.CLOSING,e._errorEmitted=!0,e.emit("error",n),e.emitClose()}function po(e){return e.path=e.socketPath,st.connect(e)}function go(e){return e.path=void 0,!e.servername&&e.servername!==""&&(e.servername=st.isIP(e.host)?"":e.host),Zr.connect(e)}function R(e,n,t){e._readyState=C.CLOSING;let r=new Error(t);Error.captureStackTrace(r,R),n.setHeader?(n[at]=!0,n.abort(),n.socket&&!n.socket.destroyed&&n.socket.destroy(),process.nextTick(je,e,r)):(n.destroy(r),n.once("error",e.emit.bind(e,"error")),n.once("close",e.emitClose.bind(e)))}function cn(e,n,t){if(n){let r=no(n)?n.size:lo(n).length;e._socket?e._sender._bufferedBytes+=r:e._bufferedAmount+=r}if(t){let r=new Error(`WebSocket is not open: readyState ${e.readyState} (${q[e.readyState]})`);process.nextTick(t,r)}}function mo(e,n){let t=this[P];t._closeFrameReceived=!0,t._closeMessage=n,t._closeCode=e,t._socket[P]!==void 0&&(t._socket.removeListener("data",Ne),process.nextTick(ct,t._socket),e===1005?t.close():t.close(e,n))}function ho(){let e=this[P];e.isPaused||e._socket.resume()}function yo(e){let n=this[P];n._socket[P]!==void 0&&(n._socket.removeListener("data",Ne),process.nextTick(ct,n._socket),n.close(e[oo])),n._errorEmitted||(n._errorEmitted=!0,n.emit("error",e))}function ot(){this[P].emitClose()}function _o(e,n){this[P].emit("message",e,n)}function xo(e){let n=this[P];n._autoPong&&n.pong(e,!this._isServer,it),n.emit("ping",e)}function bo(e){this[P].emit("pong",e)}function ct(e){e.resume()}function vo(e){let n=this[P];n.readyState!==C.CLOSED&&(n.readyState===C.OPEN&&(n._readyState=C.CLOSING,lt(n)),this._socket.end(),n._errorEmitted||(n._errorEmitted=!0,n.emit("error",e)))}function lt(e){e._closeTimer=setTimeout(e._socket.destroy.bind(e._socket),uo)}function ut(){let e=this[P];this.removeListener("close",ut),this.removeListener("data",Ne),this.removeListener("end",ft),e._readyState=C.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[P]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",ot),e._receiver.on("finish",ot))}function Ne(e){this[P]._receiver.write(e)||this.pause()}function ft(){let e=this[P];e._readyState=C.CLOSING,e._receiver.end(),this.end()}function pt(){let e=this[P];this.removeListener("error",pt),this.on("error",it),e&&(e._readyState=C.CLOSING,this.destroy())}});var _t=A((Di,yt)=>{"use strict";var Ui=Le(),{Duplex:So}=E("stream");function mt(e){e.emit("close")}function wo(){!this.destroyed&&this._writableState.finished&&this.destroy()}function ht(e){this.removeListener("error",ht),this.destroy(),this.listenerCount("error")===0&&this.emit("error",e)}function ko(e,n){let t=!0,r=new So({...n,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on("message",function(s,i){let a=!i&&r._readableState.objectMode?s.toString():s;r.push(a)||e.pause()}),e.once("error",function(s){r.destroyed||(t=!1,r.destroy(s))}),e.once("close",function(){r.destroyed||r.push(null)}),r._destroy=function(o,s){if(e.readyState===e.CLOSED){s(o),process.nextTick(mt,r);return}let i=!1;e.once("error",function(c){i=!0,s(c)}),e.once("close",function(){i||s(o),process.nextTick(mt,r)}),t&&e.terminate()},r._final=function(o){if(e.readyState===e.CONNECTING){e.once("open",function(){r._final(o)});return}e._socket!==null&&(e._socket._writableState.finished?(o(),r._readableState.endEmitted&&r.destroy()):(e._socket.once("finish",function(){o()}),e.close()))},r._read=function(){e.isPaused&&e.resume()},r._write=function(o,s,i){if(e.readyState===e.CONNECTING){e.once("open",function(){r._write(o,s,i)});return}e.send(o,i)},r.on("end",wo),r.on("error",ht),r}yt.exports=ko});var bt=A((zi,xt)=>{"use strict";var{tokenChars:Co}=oe();function Oo(e){let n=new Set,t=-1,r=-1,o=0;for(o;o<e.length;o++){let i=e.charCodeAt(o);if(r===-1&&Co[i]===1)t===-1&&(t=o);else if(o!==0&&(i===32||i===9))r===-1&&t!==-1&&(r=o);else if(i===44){if(t===-1)throw new SyntaxError(`Unexpected character at index ${o}`);r===-1&&(r=o);let a=e.slice(t,r);if(n.has(a))throw new SyntaxError(`The "${a}" subprotocol is duplicated`);n.add(a),t=r=-1}else throw new SyntaxError(`Unexpected character at index ${o}`)}if(t===-1||r!==-1)throw new SyntaxError("Unexpected end of input");let s=e.slice(t,o);if(n.has(s))throw new SyntaxError(`The "${s}" subprotocol is duplicated`);return n.add(s),n}xt.exports={parse:Oo}});var Et=A((Vi,Ot)=>{"use strict";var Eo=E("events"),Je=E("http"),{Duplex:Fi}=E("stream"),{createHash:Po}=E("crypto"),vt=on(),Y=me(),To=bt(),Io=Le(),{GUID:Ao,kWebSocket:Ro}=F(),Mo=/^[+/0-9A-Za-z]{22}==$/,St=0,wt=1,Ct=2,ln=class extends Eo{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:Io,...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=Je.createServer((r,o)=>{let s=Je.STATUS_CODES[426];o.writeHead(426,{"Content-Length":s.length,"Content-Type":"text/plain"}),o.end(s)}),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=jo(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(o,s,i)=>{this.handleUpgrade(o,s,i,r)}})}n.perMessageDeflate===!0&&(n.perMessageDeflate={}),n.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=n,this._state=St}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===Ct){n&&this.once("close",()=>{n(new Error("The server is not running"))}),process.nextTick(xe,this);return}if(n&&this.once("close",n),this._state!==wt)if(this._state=wt,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(xe,this):process.nextTick(xe,this);else{let t=this._server;this._removeListeners(),this._removeListeners=this._server=null,t.close(()=>{xe(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,o){t.on("error",kt);let s=n.headers["sec-websocket-key"],i=n.headers.upgrade,a=+n.headers["sec-websocket-version"];if(n.method!=="GET"){Q(this,n,t,405,"Invalid HTTP method");return}if(i===void 0||i.toLowerCase()!=="websocket"){Q(this,n,t,400,"Invalid Upgrade header");return}if(s===void 0||!Mo.test(s)){Q(this,n,t,400,"Missing or invalid Sec-WebSocket-Key header");return}if(a!==13&&a!==8){Q(this,n,t,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(n)){be(t,400);return}let c=n.headers["sec-websocket-protocol"],d=new Set;if(c!==void 0)try{d=To.parse(c)}catch{Q(this,n,t,400,"Invalid Sec-WebSocket-Protocol header");return}let f=n.headers["sec-websocket-extensions"],p={};if(this.options.perMessageDeflate&&f!==void 0){let y=new Y(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let u=vt.parse(f);u[Y.extensionName]&&(y.accept(u[Y.extensionName]),p[Y.extensionName]=y)}catch{Q(this,n,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let y={origin:n.headers[`${a===8?"sec-websocket-origin":"origin"}`],secure:!!(n.socket.authorized||n.socket.encrypted),req:n};if(this.options.verifyClient.length===2){this.options.verifyClient(y,(u,g,l,x)=>{if(!u)return be(t,g||401,l,x);this.completeUpgrade(p,s,d,n,t,r,o)});return}if(!this.options.verifyClient(y))return be(t,401)}this.completeUpgrade(p,s,d,n,t,r,o)}completeUpgrade(n,t,r,o,s,i,a){if(!s.readable||!s.writable)return s.destroy();if(s[Ro])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>St)return be(s,503);let d=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Po("sha1").update(t+Ao).digest("base64")}`],f=new this.options.WebSocket(null,void 0,this.options);if(r.size){let p=this.options.handleProtocols?this.options.handleProtocols(r,o):r.values().next().value;p&&(d.push(`Sec-WebSocket-Protocol: ${p}`),f._protocol=p)}if(n[Y.extensionName]){let p=n[Y.extensionName].params,y=vt.format({[Y.extensionName]:[p]});d.push(`Sec-WebSocket-Extensions: ${y}`),f._extensions=n}this.emit("headers",d,o),s.write(d.concat(`\r
|
|
4
4
|
`).join(`\r
|
|
5
5
|
`)),s.removeListener("error",kt),f.setSocket(s,i,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(f),f.on("close",()=>{this.clients.delete(f),this._shouldEmitClose&&!this.clients.size&&process.nextTick(xe,this)})),a(f,o)}};Ot.exports=ln;function jo(e,n){for(let t of Object.keys(n))e.on(t,n[t]);return function(){for(let r of Object.keys(n))e.removeListener(r,n[r])}}function xe(e){e._state=Ct,e.emit("close")}function kt(){this.destroy()}function be(e,n,t,r){t=t||Je.STATUS_CODES[n],r={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(t),...r},e.once("finish",e.destroy),e.end(`HTTP/1.1 ${n} ${Je.STATUS_CODES[n]}\r
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';
|
|
2
|
-
const require =
|
|
1
|
+
import { createRequire as __linzumiBundleCreateRequire } from 'node:module';
|
|
2
|
+
const require = __linzumiBundleCreateRequire(import.meta.url);
|
|
3
3
|
import{randomUUID as ce}from"node:crypto";import{mkdir as me,realpath as pe,writeFile as _e}from"node:fs/promises";import{homedir as J}from"node:os";import{join as L}from"node:path";function $(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 _(e){if(e===null||e.BS_PRIVATE_NESTED_SOME_NONE===void 0)return e;let t=e.BS_PRIVATE_NESTED_SOME_NONE;if(t!==0)return{BS_PRIVATE_NESTED_SOME_NONE:t-1|0}}function h(e,t){let r=e.length,i=new Array(r),n=0;for(let s=0;s<r;++s){let o=e[s],m=t(o);m!==void 0&&(i[n]=_(m),n=n+1|0)}return i.length=n,i}function g(e,t,r){return e!==void 0?r(_(e)):t}function k(e,t){if(e!==void 0)return $(t(_(e)))}function v(e,t){if(e!==void 0)return t(_(e))}function E(e,t){return e!==void 0?_(e):t}var R=["codex","claude-code","pi","opencode"];function M(e){return e}function D(e,t){let r=e[t];if(typeof r=="object"&&r!==null&&!Array.isArray(r))return r}function d(e,t){let r=e[t];if(typeof r=="string")return r}function T(e,t){let r=e[t];if(Array.isArray(r))return r}function I(e){return h(e,t=>{if(typeof t!="object"||t===null||Array.isArray(t))return;if(d(t,"type")==="text")return d(t,"text")}).join(`
|
|
4
4
|
`)}function j(e,t,r,i){return e+":"+t+":"+r+":"+i}function N(e,t){let r=t.split(":"),i=r[0],n=r[1],s=r[2];if(i===void 0||n===void 0||s===void 0||!(i===e&&n!==""&&s!==""&&r.length>=4))return;let o=r.slice(3,r.length).join(":");if(o!=="")return{keySessionId:n,keyTurnId:s,keyItemId:o}}function W(e,t){return{threadId:e,threadTitle:void 0,nodes:t,hasMore:!1,cursor:void 0,budget:void 0,session:void 0}}var V="codex";function ne(e,t,r){return j(V,e,t,r)}function ie(e){if(e===void 0)return"system_notice";switch(e){case"agentMessage":return"assistant_message";case"commandExecution":return"command_execution";case"fileChange":return"file_change";case"collabAgentToolCall":case"dynamicToolCall":case"mcpToolCall":return"tool_call";case"reasoning":return"reasoning";case"plan":case"subAgentActivity":return"agent_status";case"terminalInput":return"terminal_input";case"userMessage":return"user_message";default:return"system_notice"}}function B(e){return h(e,t=>{if(typeof t=="string")return t})}function se(e){let t=d(e,"type");if(t===void 0)return"";switch(t){case"collabAgentToolCall":return E(d(e,"prompt"),"");case"commandExecution":return E(d(e,"aggregatedOutput"),"");case"dynamicToolCall":return g(T(e,"contentItems"),"",I);case"fileChange":return g(T(e,"changes"),[],n=>h(n,s=>{if(typeof s=="object"&&s!==null&&!Array.isArray(s))return d(s,"path")})).join(`
|
|
5
5
|
`);case"mcpToolCall":return g(v(D(e,"result"),n=>T(n,"content")),"",I);case"reasoning":let r=g(T(e,"summary"),[],B),i=g(T(e,"content"),[],B);return r.concat(i).filter(n=>n!=="").join(`
|
package/dist/impl-ts/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';
|
|
2
|
-
const require =
|
|
1
|
+
import { createRequire as __linzumiBundleCreateRequire } from 'node:module';
|
|
2
|
+
const require = __linzumiBundleCreateRequire(import.meta.url);
|
|
3
3
|
var eoe=Object.create;var Mv=Object.defineProperty;var noe=Object.getOwnPropertyDescriptor;var toe=Object.getOwnPropertyNames;var roe=Object.getPrototypeOf,ooe=Object.prototype.hasOwnProperty;var ed=(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 q=(e,n)=>()=>(e&&(n=e(e=0)),n);var ee=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports),wo=(e,n)=>{for(var t in n)Mv(e,t,{get:n[t],enumerable:!0})},ioe=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of toe(n))!ooe.call(e,o)&&o!==t&&Mv(e,o,{get:()=>n[o],enumerable:!(r=noe(n,o))||r.enumerable});return e};var qr=(e,n,t)=>(t=e!=null?eoe(roe(e)):{},ioe(n||!e||!e.__esModule?Mv(t,"default",{value:e,enumerable:!0}):t,e));import{execFileSync as soe}from"node:child_process";import{createHash as w6}from"node:crypto";import{readFileSync as aoe}from"node:fs";function coe(e,n){return soe(e,[...n],{encoding:"utf8",timeout:5e3,maxBuffer:1024*1024})}function loe(e){return aoe(e,"utf8")}function yg(e={}){let n=e.platform??process.platform,t=e.execFile??coe,r=e.readFile??loe;try{if(n==="darwin"){let s=t("ioreg",["-rd1","-c","IOPlatformExpertDevice"]).match(/"IOPlatformUUID"\s*=\s*"([0-9A-Fa-f-]{36})"/)?.[1];return s===void 0?void 0:s.toLowerCase()}if(n==="linux"){for(let o of["/etc/machine-id","/var/lib/dbus/machine-id"])try{let i=r(o).trim().toLowerCase();if(/^[0-9a-f]{32}$/.test(i))return i}catch{}return}return}catch{return}}function xg(e={}){let n=yg(e);return n===void 0?void 0:`mfp-${w6("sha256").update(`${doe}${n}`).digest("hex").slice(0,32)}`}function v6(e={}){let n=yg(e);if(n===void 0)return;let r=w6("sha256").update(`${uoe}${n}`).digest("hex").slice(0,32).split("");r[12]="5",r[16]=(parseInt(r[16]??"0",16)&3|8).toString(16);let o=r.join("");return[o.slice(0,8),o.slice(8,12),o.slice(12,16),o.slice(16,20),o.slice(20,32)].join("-")}var doe,uoe,_g=q(()=>{"use strict";doe="linzumi-machine-fingerprint:v1:",uoe="linzumi-machine-id:v1:"});import{userInfo as poe}from"node:os";import{createHash as foe}from"node:crypto";function hoe(){return poe().username}function goe(e={}){let n=e.username??hoe;try{let t=n();return t===""?void 0:t}catch(t){console.warn("[machineFingerprintV2] username probe failed:",t);return}}function S6(e={}){let n=yg(e),t=goe(e);return n===void 0||t===void 0?void 0:`mfp2-${foe("sha256").update(`${moe}${n}:${t}`).digest("hex").slice(0,32)}`}function k6(e){return e===void 0?{}:{machineFingerprintV2:e}}var moe,Av=q(()=>{"use strict";_g();moe="linzumi-machine-fingerprint:v2:"});import{Worker as yoe}from"node:worker_threads";function bg(e,n={}){let t=n.timeoutMs??xoe;return n.probe!==void 0?n.probe(e,t):boe(e,t)}function boe(e,n){let t=new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT),r=new Int32Array(t);Atomics.store(r,0,Ov);let o;try{o=new yoe(_oe,{eval:!0,workerData:{sharedBuffer:t,path:e}})}catch{return!0}o.unref(),o.on("error",()=>{Atomics.load(r,0)===Ov&&(Atomics.store(r,0,C6),Atomics.notify(r,0))}),Atomics.wait(r,0,Ov,n);let i=Atomics.load(r,0);return o.terminate().catch(()=>{}),i===$v}var xoe,Ov,$v,C6,_oe,T6=q(()=>{"use strict";xoe=1e3,Ov=0,$v=1,C6=2,_oe=`
|
|
4
4
|
const { workerData, parentPort } = require('node:worker_threads');
|
|
5
5
|
const { statSync } = require('node:fs');
|
|
@@ -670,7 +670,7 @@ ${n}
|
|
|
670
670
|
`)}catch(o){n?.(o instanceof Error?o.message:String(o))}}}}function Kge(e,n){let t=e.trim();if(t.length<=n)return t;let r="... ";return`${r}${t.slice(t.length-(n-r.length))}`}function Vge(e){let n=Object.entries(e);return n.length<=JN?e:(n.sort(([,t],[,r])=>Date.parse(t.lastAt)-Date.parse(r.lastAt)),Object.fromEntries(n.slice(-JN)))}function GN(e,n,t,r,o=VN){let i=e.load(),s=(i[n]?.count??0)+1,a=t instanceof Error?t.message:String(t??"");return e.save(Vge({...i,[n]:{count:s,lastError:Kge(a===""?"the engine worker never started":a,Jge),lastAt:new Date(r).toISOString()}})),{count:s,tripped:s>=o}}function ZN(e,n){let t=e.load();if(t[n]===void 0)return!1;let{[n]:r,...o}=t;return e.save(o),!0}function QN(e,n,t=VN){let r=e.load()[n];return r!==void 0&&r.count>=t?r:void 0}function IC(e,n=PC){let t=XN.find(r=>e!==r&&e.startsWith(`${r}/`));if(t===void 0)return!1;try{return n(e).dev===n(t).dev}catch{return!1}}function YN(e,n=PC){let t=XN.find(i=>e!==i&&e.startsWith(`${i}/`));if(t===void 0)return!1;let r;try{r=n(t).dev}catch{return!1}let o=e;for(;o!==t;)try{return n(o).dev===r}catch(i){let s=typeof i=="object"&&i!==null&&"code"in i?i.code:void 0;if(s!=="ENOENT"&&s!=="ENOTDIR")return!1;let a=KN(o);if(a===o)break;o=a}return!0}function RC(e,n={}){let t=n.realpathFn??Fge,r;try{r=t(Bge($t(e)))}catch{return!1}return!IC(r,n.statFn??PC)}function e4(e,n=RC){let t=e.load(),r=[],o={};for(let[i,s]of Object.entries(t)){let a=!1;try{a=n(i)}catch{a=!1}a?r.push(i):o[i]=s}return r.length>0&&e.save(o),r}function EC(e){return(e instanceof Error?e.message:String(e??"")).startsWith(n4)}function t4(e,n){return`${n4}${e} on this computer: the last ${n.count} attempts there died during startup (most recent error: ${n.lastError}). Check that the folder exists and its disk/volume is mounted. The pause clears after one successful session, or on runner restart (\`linzumi connect\`) once the folder is present again.`}var VN,Jge,JN,XN,n4,r4=q(()=>{"use strict";_C();gs();VN=3,Jge=480,JN=50;XN=["/Volumes"];n4="coding sessions are paused for "});import{mkdirSync as Wge,rmSync as o4,writeFileSync as Hge,promises as i4}from"node:fs";import{join as Gge}from"node:path";import{StringDecoder as Zge}from"node:string_decoder";function Qge(e){return`'${e.replaceAll("'","'\\''")}'`}function Xge(e,n){return`__lz_live_out=${Qge(n)}; if ! : >> "$__lz_live_out" 2>/dev/null; then __lz_live_out=/dev/null; fi; { ${e}${wx}`}function Yge(e){return s4.test(e)&&e.endsWith(wx)}function a4(e){let n=e.match(s4)?.[0];return n===void 0||!e.endsWith(wx)?e:e.slice(n.length,e.length-wx.length)}function d4(e){let n=e.LINZUMI_CLAUDE_LIVE_BASH?.trim().toLowerCase();return!(n==="0"||n==="false"||n==="off"||n==="no")}function u4(e){let n=e.pollIntervalMs??eye,t=e.maxEmittedBytesPerTool??nye,r=new Map,o=!1,i=c=>{let l=r.get(c);if(l!==void 0){r.delete(c),l.timer!==void 0&&(clearInterval(l.timer),l.timer=void 0);try{o4(l.file,{force:!0})}catch{}}},s=async(c,l)=>{if(!l.reading){l.reading=!0;try{let p=await i4.stat(l.file);if(p.size<=l.offset)return;let m=Math.min(p.size-l.offset,tye,t-l.emittedBytes);if(m<=0){i(c);return}let f=await i4.open(l.file,"r");try{let y=Buffer.alloc(m),{bytesRead:x}=await f.read(y,0,m,l.offset);if(x<=0)return;l.offset+=x,l.emittedBytes+=x;let b=l.decoder.write(y.subarray(0,x));b!==""&&r.get(c)===l&&e.onOutputDelta(c,b),l.emittedBytes>=t&&(e.log?.("claude_live_bash.output_budget_exhausted",{tool_use_id:c,emitted_bytes:l.emittedBytes}),i(c))}finally{await f.close()}}catch(p){r.get(c)===l&&(e.log?.("claude_live_bash.tail_read_failed",{tool_use_id:c,message:p instanceof Error?p.message:String(p)}),i(c))}finally{l.reading=!1}}},a=(c,l)=>{i(c);let p={file:l,decoder:new Zge("utf8"),offset:0,emittedBytes:0,reading:!1,timer:void 0};r.set(c,p);let m=setInterval(()=>{s(c,p)},n);m.unref?.(),p.timer=m},d=(c,l)=>{if(o)return;let p=l.command;if(typeof p!="string"||p.trim()===""||l.run_in_background===!0||Yge(p))return;let m=Gge(e.captureDir,`${c.replaceAll(/[^\w-]/g,"_")}.out`);try{Wge(e.captureDir,{recursive:!0}),Hge(m,"")}catch(f){e.log?.("claude_live_bash.capture_file_failed",{tool_use_id:c,message:f instanceof Error?f.message:String(f)});return}return a(c,m),{...l,command:Xge(p,m)}};return{hookMatchers:[{matcher:"Bash",hooks:[async c=>{let l={continue:!0};if(typeof c!="object"||c===null)return l;let p=c;if(p.hook_event_name!=="PreToolUse"||p.tool_name!=="Bash"||typeof p.tool_use_id!="string"||p.tool_use_id===""||typeof p.tool_input!="object"||p.tool_input===null||p.permission_mode!=="bypassPermissions")return l;let m=d(p.tool_use_id,p.tool_input);return m===void 0?l:{continue:!0,hookSpecificOutput:{hookEventName:"PreToolUse",updatedInput:m}}}]}],wrapApprovedTool:d,settleTool:i,settleAll:()=>{for(let c of[...r.keys()])i(c)},close:()=>{o=!0;for(let c of[...r.keys()])i(c);try{o4(e.captureDir,{recursive:!0,force:!0})}catch{}}}}var s4,wx,eye,nye,tye,DC=q(()=>{"use strict";s4=/^__lz_live_out='(?:[^']|'\\'')*'; if ! : >> "\$__lz_live_out" 2>\/dev\/null; then __lz_live_out=\/dev\/null; fi; \{ /,wx=`
|
|
671
671
|
} > >(tee -a -- "$__lz_live_out") 2> >(tee -a -- "$__lz_live_out" >&2)`;eye=200,nye=262144,tye=65536});import{spawnSync as rye}from"node:child_process";import{existsSync as oye}from"node:fs";import{homedir as iye}from"node:os";import{basename as sye,posix as f4,win32 as aye}from"node:path";function OC(e){return e==="win32"?aye:f4}function dye(e,n){let t=sye(e).includes("fish")?`printf '%s%s%s' '${vx}' (string join ':' $PATH) '${AC}'`:`printf '%s%s%s' '${vx}' "$PATH" '${AC}'`;switch(n){case"interactive_login":return["-l","-i","-c",t];case"interactive":return["-i","-c",t];case"login":return["-l","-c",t]}}function uye(e,n){let t=rye(e,[...n],{encoding:"utf8",timeout:5e3,killSignal:"SIGKILL",stdio:["ignore","pipe","ignore"]});return{stdout:typeof t.stdout=="string"?t.stdout:void 0,error:t.error}}function jf(e){return{env:e?.env??process.env,platform:e?.platform??process.platform,homeDir:e?.homeDir??iye(),fileExists:e?.fileExists??oye,runLoginShell:e?.runLoginShell}}function cye(e){if(e===void 0)return;let n=e.lastIndexOf(vx),t=e.lastIndexOf(AC);if(n===-1||t===-1||t<=n)return;let r=e.slice(n+vx.length,t).trim();return r===""?void 0:r}function lye(e){let n=jf(e);if(n.platform==="win32")return;let t=e===void 0;if(e!==void 0&&e.runLoginShell===void 0||t&&process.env.VITEST!==void 0)return;if(t&&l4)return c4;let r=n.env.SHELL?.trim(),o=n.runLoginShell??uye,i=[];if(r!==void 0&&r!=="")for(let a of["interactive_login","interactive","login"]){let d=o(r,dye(r,a)),u=cye(d.stdout);if(u!==void 0)for(let c of u.split(":"))c!==""&&i.push(c)}let s=i.length===0?void 0:$C(i).join(":");return t&&(c4=s,l4=!0),s}function pye(e){let n=jf(e);if(n.platform==="win32")return[];let t=n.homeDir,r=f4.join,o=n.env.VOLTA_HOME?.trim(),i=n.env.BUN_INSTALL?.trim(),s=n.env.npm_config_prefix?.trim(),a=n.env.N_PREFIX?.trim();return $C([r(t,".local","bin"),r(t,".volta","bin"),o===void 0||o===""?void 0:r(o,"bin"),r(t,".bun","bin"),i===void 0||i===""?void 0:r(i,"bin"),r(t,".npm-global","bin"),s===void 0||s===""?void 0:r(s,"bin"),a===void 0||a===""?void 0:r(a,"bin"),r(t,".claude","local"),"/opt/homebrew/bin","/usr/local/bin"].filter(d=>d!==void 0))}function p4(e,n){return e===void 0?[]:e.split(OC(n).delimiter).filter(t=>t!=="")}function $C(e){return Array.from(new Set(e))}function m4(e){let n=jf(e);return $C([...p4(n.env.PATH,n.platform),...p4(lye(e),n.platform),...pye(e)])}function Sx(e){let n=e===void 0;if(n&&process.env.VITEST!==void 0)return process.env.PATH??"";if(n&&MC!==void 0)return MC;let t=jf(e),r=m4(e).join(OC(t.platform).delimiter);return r!==""&&(t.env.PATH=r),n&&(MC=r),r}function kx(e,n){let t=jf(n);if(e.includes("/")||e.includes("\\"))return t.fileExists(e)?e:void 0;let r=t.platform==="win32"?[`${e}.exe`,`${e}.cmd`,e]:[e],o=OC(t.platform).join;for(let i of m4(n))for(let s of r){let a=o(i,s);if(t.fileExists(a))return a}}function h4(e,n){return[`\`${e}\` was not found on this runner's PATH, the login-shell PATH, or the common install locations (~/.local/bin, ~/.volta/bin, ~/.bun/bin, npm-global, Homebrew).`,`If \`${e}\` works in your terminal, the runner process does not see your shell's PATH (common when the runner is launched from an app or service instead of a terminal).`,`Fix: pass ${n} "$(command -v ${e})" when starting the runner, or make sure ${e}'s directory is on your login-shell PATH.`].join(`
|
|
672
672
|
`)}var vx,AC,c4,l4,MC,LC=q(()=>{"use strict";vx="__LINZUMI_LOGIN_PATH_BEGIN__",AC="__LINZUMI_LOGIN_PATH_END__";l4=!1});import{closeSync as fye,openSync as mye,readSync as hye,statSync as gye}from"node:fs";function Sd(e){return typeof e!="string"||e===""?e:yye.reduce((n,t)=>t.source.startsWith("\\beyJ")?n.replace(t,"<redacted>"):n.replace(t,"$1<redacted>"),e)}function g4(e,n){if(typeof e!="string"||e==="")return;if(Buffer.byteLength(e,"utf8")<=n)return e;let t=Buffer.from(e,"utf8"),r=t.length-n;for(;r<t.length&&((t[r]??0)&192)===128;)r+=1;return t.subarray(r).toString("utf8")}function Sye(e,n){let t;try{let{size:r}=gye(e),o=r>n?r-n:0,i=r-o;if(i<=0)return"";let s=Buffer.allocUnsafe(i);t=mye(e,"r");let a=hye(t,s,0,i,o);return s.subarray(0,a).toString("utf8")}catch{return""}finally{if(t!==void 0)try{fye(t)}catch{}}}function y4(e){let n=e.now??Date.now,t=e.setIntervalImpl??setInterval,r=e.clearIntervalImpl??clearInterval,o=e.readTail??Sye,i=Math.max(_ye,e.intervalMs??xye),s=Math.max(1,e.maxTailBytes??bye),a=Math.max(1,e.maxLifecycleEvents??wye),d=[],u=!1,c,l=v=>{try{for(d.push(v);d.length>a;)d.shift()}catch{}},p=()=>{try{let v=e.backendStderrSnapshot?.();if(typeof v!="string"||v==="")return;let w=v.length>s?v.slice(v.length-s):v;return Sd(w)}catch{return}},m=()=>{let v=Sd(o(e.runnerLogFile,s)),w=p(),k={kind:"runner_diagnostic_log",captured_at:new Date(n()).toISOString(),lifecycle:d.map(I=>({event:I.event,at:I.atIso,...I.closeCode===void 0?{}:{close_code:I.closeCode},...I.closeReason===void 0?{}:{close_reason:Sd(I.closeReason)},...I.previousSessionDurationMs===void 0?{}:{previous_session_duration_ms:I.previousSessionDurationMs},...I.reconnectCount===void 0?{}:{reconnect_count:I.reconnectCount}})),runner_log_tail:v,...w===void 0?{}:{backend_stderr:w}};return{bundle_name:"runner-diagnostics",exported_at:new Date(n()).toISOString(),diagnostics:k,telemetry_ndjson:d.map(I=>JSON.stringify(I)).join(`
|
|
673
|
-
`)}},f=Math.max(256,e.spoolTailBytes??vye),y=(v,w)=>{let k=v.diagnostics!==null&&typeof v.diagnostics=="object"&&!Array.isArray(v.diagnostics)?{...v.diagnostics}:{},I=g4(k.runner_log_tail,f),T=g4(k.backend_stderr,f);return I!==void 0&&(k.runner_log_tail=I),T!==void 0&&(k.backend_stderr=T),k.spool_reason=w instanceof Error?w.message:String(w),{...v,diagnostics:k}},x=async()=>{let v=d.length,w=m();try{await Promise.resolve(e.upload(w)),d.splice(0,v)}catch(k){let I=!1;if(e.spool!==void 0&&v>0)try{I=e.spool.append(y(w,k))}catch{I=!1}I&&d.splice(0,v);try{e.log?.("runner_diagnostics.upload_failed",{buffered_events:d.length,spooled:I,error:k instanceof Error?k.message:String(k)})}catch{}}},b=()=>{u||c!==void 0||(c=t(()=>{x()},i),c.unref?.())},S=()=>{u=!0,c!==void 0&&(r(c),c=void 0)};try{e.log?.("runner_diagnostics.enabled",{destination:"linzumi",runner_log_file:e.runnerLogFile,interval_ms:i,note:"runner lifecycle + runner-log tail + backend stderr are uploaded to Linzumi for support diagnostics (auto-deleted after 4 days)"})}catch{}return b(),{recordLifecycle:l,flushNow:x,stop:S}}var yye,xye,_ye,bye,wye,vye,Cx=q(()=>{"use strict";yye=[/(--token[=\s]+)\S+/gi,/(bearer\s+)[^\s,;"'\]\}]+/gi,/((?:access[_-]?token|api[_-]?key|auth[_-]?token|authorization|secret|password|refresh[_-]?token|session[_-]?token|jwt|token)["']?\s*[:=]\s*["']?)[^\s,;"'\]\}]+/gi,/\beyJ[A-Za-z0-9_-]*\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\b/g];xye=45e3,_ye=5e3,bye=64*1024,wye=200,vye=16*1024});import kye from"blessed";function Cye(e){if(e.indexOf("%;")===-1)return e;let n=0,t="",r=0;for(;r<e.length;){let o=e[r],i=e[r+1];if(o==="%"&&i==="%"){t+="%%",r+=2;continue}if(o==="%"&&i==="?"){n+=1,t+="%?",r+=2;continue}if(o==="%"&&i===";"){n>0&&(n-=1,t+="%;"),r+=2;continue}t+=o,r+=1}return t}function _4(e=kye){let t=e.Tput?.prototype,r=t?._compile;if(t===void 0||typeof r!="function"||t[x4]===!0)return;let o=function(s,a,d){let u=typeof d=="string"?Cye(d):d;return r.call(this,s,a,u)};t._compile=o,Object.defineProperty(t,x4,{value:!0,enumerable:!1,configurable:!0,writable:!0})}var x4,b4=q(()=>{"use strict";x4="__linzumiSetulcShimInstalled"});function w4(e){return e===void 0?!1:(e.unicode=!0,e.features!==void 0&&(e.features.unicode=!0),e.brokenACS=!0,!0)}function v4(e){if(e===void 0)return;let n=e.tput,t=e.program?.tput;if(n===void 0&&t===void 0){console.warn("[blessedAcsCharsetShim] screen has no tput; ACS charset fix was NOT applied - dynamic cells may render garbled");return}w4(n),t!==void 0&&t!==n&&w4(t)}var S4=q(()=>{"use strict"});var k4,Tye,qf,Pye,C4,T4=q(()=>{"use strict";k4=Symbol.for("linzumi.blessedPartialScreenCrashGuard"),Tye=e=>{console.warn(e)},qf=(e,n)=>{n===void 0||process.removeListener(e,n)},Pye=(e,n)=>{let t=e.instances.indexOf(n);t===-1||(e.instances.splice(t,1),e.total-=1),e.global=e.instances[0]??null,e.total===0&&(qf("uncaughtException",e._exceptionHandler),qf("SIGTERM",e._sigtermHandler),qf("SIGINT",e._sigintHandler),qf("SIGQUIT",e._sigquitHandler),qf("exit",e._exitHandler),delete e._exceptionHandler,delete e._sigtermHandler,delete e._sigintHandler,delete e._sigquitHandler,delete e._exitHandler,delete e._bound),n.destroyed=!0},C4=(e,n={})=>{let t=e.prototype;switch(t[k4]){case!0:return;case void 0:break}let r=t.destroy;t[k4]=!0,t.destroy=function(){switch(this.program){case null:case void 0:(n.warn??Tye)({event:"runner.tui_partial_screen_teardown",branch:"screen_destroy_missing_program",program_present:!1,action:"cleanup_partial_screen_registration"}),Pye(e,this);break;default:r.call(this);break}}}});function P4(e){if(typeof e!="function")return;let n=e;if(!(!Array.isArray(n.instances)||typeof n.total!="number"))return n}function Ff(e,n){if(typeof n=="function")try{process.removeListener(e,n)}catch{}}function Iye(e,n){try{let t=e.instances.indexOf(n);return t===-1?!1:(e.instances.splice(t,1),e.total-=1,e.global=e.instances[0],e.total===0&&(e.global=null,Ff("uncaughtException",e._exceptionHandler),Ff("SIGTERM",e._sigtermHandler),Ff("SIGINT",e._sigintHandler),Ff("SIGQUIT",e._sigquitHandler),Ff("exit",e._exitHandler),delete e._exceptionHandler,delete e._sigtermHandler,delete e._sigintHandler,delete e._sigquitHandler,delete e._exitHandler,delete e._bound),!0)}catch{return!1}}function Rye(e,n,t,r){let o=0;for(let i of e.instances.slice()){if(n.has(i))continue;let s=i.program===void 0,a;if(!s&&typeof i.destroy=="function")try{i.destroy()}catch(d){a=d}Iye(e,i),o+=1,Po(t,"runner.tui_stranded_screen_swept",{partial_construction:s,destroy_error:a===void 0?null:a instanceof Error?a.message:String(a),...r})}return o}function I4(e,n,t={}){let r=t.sinks??{},o=t.context??{},i=new Set(e?.instances??[]);try{return n()}catch(s){let a=e===void 0?0:Rye(e,i,r,o);throw Po(r,"runner.tui_screen_construction_failed",{message:s instanceof Error?s.message:String(s),stack:s instanceof Error?s.stack??null:null,swept_screens:a,...o}),s}}var R4=q(()=>{"use strict";Pc()});var qt,jC,oa=q(()=>{"use strict";qt="1.0.
|
|
673
|
+
`)}},f=Math.max(256,e.spoolTailBytes??vye),y=(v,w)=>{let k=v.diagnostics!==null&&typeof v.diagnostics=="object"&&!Array.isArray(v.diagnostics)?{...v.diagnostics}:{},I=g4(k.runner_log_tail,f),T=g4(k.backend_stderr,f);return I!==void 0&&(k.runner_log_tail=I),T!==void 0&&(k.backend_stderr=T),k.spool_reason=w instanceof Error?w.message:String(w),{...v,diagnostics:k}},x=async()=>{let v=d.length,w=m();try{await Promise.resolve(e.upload(w)),d.splice(0,v)}catch(k){let I=!1;if(e.spool!==void 0&&v>0)try{I=e.spool.append(y(w,k))}catch{I=!1}I&&d.splice(0,v);try{e.log?.("runner_diagnostics.upload_failed",{buffered_events:d.length,spooled:I,error:k instanceof Error?k.message:String(k)})}catch{}}},b=()=>{u||c!==void 0||(c=t(()=>{x()},i),c.unref?.())},S=()=>{u=!0,c!==void 0&&(r(c),c=void 0)};try{e.log?.("runner_diagnostics.enabled",{destination:"linzumi",runner_log_file:e.runnerLogFile,interval_ms:i,note:"runner lifecycle + runner-log tail + backend stderr are uploaded to Linzumi for support diagnostics (auto-deleted after 4 days)"})}catch{}return b(),{recordLifecycle:l,flushNow:x,stop:S}}var yye,xye,_ye,bye,wye,vye,Cx=q(()=>{"use strict";yye=[/(--token[=\s]+)\S+/gi,/(bearer\s+)[^\s,;"'\]\}]+/gi,/((?:access[_-]?token|api[_-]?key|auth[_-]?token|authorization|secret|password|refresh[_-]?token|session[_-]?token|jwt|token)["']?\s*[:=]\s*["']?)[^\s,;"'\]\}]+/gi,/\beyJ[A-Za-z0-9_-]*\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\b/g];xye=45e3,_ye=5e3,bye=64*1024,wye=200,vye=16*1024});import kye from"blessed";function Cye(e){if(e.indexOf("%;")===-1)return e;let n=0,t="",r=0;for(;r<e.length;){let o=e[r],i=e[r+1];if(o==="%"&&i==="%"){t+="%%",r+=2;continue}if(o==="%"&&i==="?"){n+=1,t+="%?",r+=2;continue}if(o==="%"&&i===";"){n>0&&(n-=1,t+="%;"),r+=2;continue}t+=o,r+=1}return t}function _4(e=kye){let t=e.Tput?.prototype,r=t?._compile;if(t===void 0||typeof r!="function"||t[x4]===!0)return;let o=function(s,a,d){let u=typeof d=="string"?Cye(d):d;return r.call(this,s,a,u)};t._compile=o,Object.defineProperty(t,x4,{value:!0,enumerable:!1,configurable:!0,writable:!0})}var x4,b4=q(()=>{"use strict";x4="__linzumiSetulcShimInstalled"});function w4(e){return e===void 0?!1:(e.unicode=!0,e.features!==void 0&&(e.features.unicode=!0),e.brokenACS=!0,!0)}function v4(e){if(e===void 0)return;let n=e.tput,t=e.program?.tput;if(n===void 0&&t===void 0){console.warn("[blessedAcsCharsetShim] screen has no tput; ACS charset fix was NOT applied - dynamic cells may render garbled");return}w4(n),t!==void 0&&t!==n&&w4(t)}var S4=q(()=>{"use strict"});var k4,Tye,qf,Pye,C4,T4=q(()=>{"use strict";k4=Symbol.for("linzumi.blessedPartialScreenCrashGuard"),Tye=e=>{console.warn(e)},qf=(e,n)=>{n===void 0||process.removeListener(e,n)},Pye=(e,n)=>{let t=e.instances.indexOf(n);t===-1||(e.instances.splice(t,1),e.total-=1),e.global=e.instances[0]??null,e.total===0&&(qf("uncaughtException",e._exceptionHandler),qf("SIGTERM",e._sigtermHandler),qf("SIGINT",e._sigintHandler),qf("SIGQUIT",e._sigquitHandler),qf("exit",e._exitHandler),delete e._exceptionHandler,delete e._sigtermHandler,delete e._sigintHandler,delete e._sigquitHandler,delete e._exitHandler,delete e._bound),n.destroyed=!0},C4=(e,n={})=>{let t=e.prototype;switch(t[k4]){case!0:return;case void 0:break}let r=t.destroy;t[k4]=!0,t.destroy=function(){switch(this.program){case null:case void 0:(n.warn??Tye)({event:"runner.tui_partial_screen_teardown",branch:"screen_destroy_missing_program",program_present:!1,action:"cleanup_partial_screen_registration"}),Pye(e,this);break;default:r.call(this);break}}}});function P4(e){if(typeof e!="function")return;let n=e;if(!(!Array.isArray(n.instances)||typeof n.total!="number"))return n}function Ff(e,n){if(typeof n=="function")try{process.removeListener(e,n)}catch{}}function Iye(e,n){try{let t=e.instances.indexOf(n);return t===-1?!1:(e.instances.splice(t,1),e.total-=1,e.global=e.instances[0],e.total===0&&(e.global=null,Ff("uncaughtException",e._exceptionHandler),Ff("SIGTERM",e._sigtermHandler),Ff("SIGINT",e._sigintHandler),Ff("SIGQUIT",e._sigquitHandler),Ff("exit",e._exitHandler),delete e._exceptionHandler,delete e._sigtermHandler,delete e._sigintHandler,delete e._sigquitHandler,delete e._exitHandler,delete e._bound),!0)}catch{return!1}}function Rye(e,n,t,r){let o=0;for(let i of e.instances.slice()){if(n.has(i))continue;let s=i.program===void 0,a;if(!s&&typeof i.destroy=="function")try{i.destroy()}catch(d){a=d}Iye(e,i),o+=1,Po(t,"runner.tui_stranded_screen_swept",{partial_construction:s,destroy_error:a===void 0?null:a instanceof Error?a.message:String(a),...r})}return o}function I4(e,n,t={}){let r=t.sinks??{},o=t.context??{},i=new Set(e?.instances??[]);try{return n()}catch(s){let a=e===void 0?0:Rye(e,i,r,o);throw Po(r,"runner.tui_screen_construction_failed",{message:s instanceof Error?s.message:String(s),stack:s instanceof Error?s.stack??null:null,swept_screens:a,...o}),s}}var R4=q(()=>{"use strict";Pc()});var qt,jC,oa=q(()=>{"use strict";qt="1.0.148",jC=`linzumi ${qt}`});import sa from"blessed";function q4(e){return e.includes(Px)?e.replace(jye,"").replace(qye,"").includes(Px):!1}function Fye(e){return typeof e=="object"&&e!==null&&e.name==="escape"}function qC(e){return e.mode.type==="table"?!1:(e.mode={type:"table"},!0)}function Uye(e){return zye.test(e)}function F4(e){if(!e.includes(Px))return[];let n=[];for(let t of e.matchAll(Nye))n.push(t[1]==="A"?"up":"down");return n}function Bye(e){return Uye(e)?F4(e):[]}function Ex(e,n={}){let t=St.dashboard,r={trigger:e.trigger,had_tui:t!==void 0,stdin_was_tty_at_start:St.stdinWasTtyAtStart,stdout_was_tty_at_start:St.stdoutWasTtyAtStart};if(t===void 0)return Po(n,"runner.tui_teardown_ok",r),{hadTui:!1,ok:!0,swallowedErrorCode:void 0};St.dashboard=void 0,St.stop?.(),St.stop=void 0;try{return t.destroy(),Po(n,"runner.tui_teardown_ok",r),{hadTui:!0,ok:!0,swallowedErrorCode:void 0}}catch(o){let i=Rf(o);return Po(n,"runner.tui_teardown_tty_error",{...r,stage:"screen_destroy",code:i??null,message:o instanceof Error?o.message:String(o),swallowed:!0}),{hadTui:!0,ok:!1,swallowedErrorCode:i}}}function Hye(){Ex({trigger:"crash"},{log:dx})}function z4(e,n={log:dx}){if(St.degradedToHeadless)return;St.degradedToHeadless=!0;let t=Ex({trigger:"tty_write_error"},n);Po(n,"runner.tui_degraded_headless",{code:e.code??null,stage:e.stage,had_tui:t.hadTui,teardown_ok:t.ok,note:"terminal detached mid-run; console disabled, runner continues headless"});try{process.stderr.write(`linzumi runner: terminal lost (write ${e.code??"error"}); Commander TUI disabled, runner continues headless
|
|
674
674
|
`)}catch(r){xd(r)===void 0&&Po(n,"runner.tui_degrade_farewell_write_failed",{message:r instanceof Error?r.message:String(r),stage:e.stage,swallowed:!0})}}function Dx(e,n){if(N4()){let r=Txe(zf);if(Gye(zf,e,n,Date.now()),r!==void 0){r.render(Date.now());return}Sxe(zf),kxe(zf);let o=GC(zf,Date.now());if(o!==void 0){HC(o);return}}let t=G4(e,n);if(t!==void 0)try{process.stdout.write(`${t}
|
|
675
675
|
`)}catch(r){if(xd(r)===void 0)throw r}}function N4(){if(St.degradedToHeadless)return!1;switch(process.env.LINZUMI_RUNNER_CONSOLE){case"dashboard":return!0;case"lines":return!1;default:return process.stdout.isTTY===!0}}function Mx(){return N4()}function Gye(e,n,t,r){let o=ES(n);e.lastUpdateAtMs=r;let i=j4(e)?.key;switch(o){case"onboarding.discovery_agents_started":e.browserUrl=_e(t.kandanUrl),e.workspace=_e(t.workspace),e.runnerId=_e(At(t,"runnerId"));break;case"kandan.connection_stale":e.connectionStale=!0;break;case"kandan.connection_recovered":e.connectionStale=!1;break;case"runner.notice":{let s=_e(t.message);if(s===void 0)break;let a=_e(t.key)??s,d=e.notices.get(a),u=_e(t.severity)??"warning",c=Bn(t.count)??(d?.count??0)+1;if(d===void 0){e.notices.set(a,{key:a,severity:u,message:s,count:c,updatedAtMs:r});for(let l of e.notices.keys()){if(e.notices.size<=Dye)break;e.notices.delete(l)}}else d.severity=u,d.message=s,d.count=c,d.updatedAtMs=r;break}case"onboarding.discovery_status":{let s=_e(t.phase),a=_e(t.status),d=Tx(t.metadata),u=_e(d?.worker_id);if(s!==void 0&&a!==void 0){let c=s==="conversations",l=c?s:u??s,p=e.discovery.get(l),m=c?Yye(p?.metadata,d):d;e.discovery.set(l,{key:l,phase:s,status:c?exe(p,a,d):a,placesSearched:Math.max(p?.placesSearched??0,Bn(t.places_searched)??0),message:_e(t.message)??(c?p?.message:void 0),currentPlace:_e(t.current_place)??(c?p?.currentPlace:void 0),currentSource:_e(t.current_source)??(c?p?.currentSource:void 0),lastError:_e(t.last_error),metadata:m,updatedAtMs:r})}break}case"kandan.roster_seeded":{let s=Wxe(t.threads)??[];for(let a of s){let d=Tx(a),u=_e(At(d,"kandan_thread_id"));if(u===void 0)continue;let c=`linzumi:${u}`;if((e.jobs.get(c)??Array.from(e.jobs.values()).find(m=>m.linzumiThreadId===u))!==void 0)continue;let p=Bn(d?.last_activity_at_ms);e.jobs.set(c,{key:c,createdAtMs:p??0,createdOrdinal:YC(e),agentProvider:void 0,linzumiThreadId:u,linzumiThreadTitle:_e(d?.title),codexThreadId:void 0,tokenUsage:void 0,lastIncomingPreview:void 0,lastIncomingAtMs:void 0,lastAssistantPreview:void 0,lastAssistantAtMs:void 0,latestCodexEventId:void 0,eventType:"idle (server roster)",creditExhaustion:void 0,queueDepth:void 0,turnId:void 0,updatedAtMs:p??0})}e.rosterTruncated=Hxe(t.truncated)??e.rosterTruncated;break}case"kandan.message_queued":case"codex.turn_starting":{let s=VC(e,t,r);s.linzumiThreadId=_e(At(t,"linzumi_thread_id"))??s.linzumiThreadId,s.linzumiThreadTitle=eU(t)??s.linzumiThreadTitle,s.codexThreadId=_e(At(t,"codex_thread_id"))??s.codexThreadId,s.lastIncomingPreview=_e(t.body_preview)??s.lastIncomingPreview,s.lastIncomingAtMs=Bn(t.message_received_at_ms)??s.lastIncomingAtMs,s.queueDepth=Bn(t.queue_depth)??s.queueDepth,s.eventType=zxe(o),s.updatedAtMs=r;break}case"codex.notification":{let s=_e(t.token_usage_summary),a=_e(t.rate_limit_summary),d=_e(t.credit_exhaustion_summary);s!==void 0&&(e.tokenUsage=s),a!==void 0&&(e.rateLimit=A4(e.rateLimit,a)),d!==void 0&&(e.creditExhaustion=d);let u=_e(t.method),c=Tx(t.metadata);if(!(_e(c?.threadId)!==void 0||_e(c?.turnId)!==void 0||_e(c?.itemId)!==void 0))break;let p=_e(c?.threadId),m=p===void 0?j4(e):jxe(e,`codex:${p}`,r);m!==void 0&&(m.codexThreadId=p??m.codexThreadId,m.tokenUsage=s??m.tokenUsage,m.creditExhaustion=d??m.creditExhaustion,m.latestCodexEventId=Q4(t),m.eventType=t.credit_exhaustion_detected===!0?"credit_exhausted":u??o,m.turnId=_e(c?.turnId)??m.turnId,m.updatedAtMs=r);break}case"kandan.codex_output_forwarded":case"kandan.codex_delta_forwarded":case"kandan.codex_reasoning_delta_forwarded":case"kandan.codex_command_output_forwarded":case"kandan.codex_file_change_forwarded":case"kandan.codex_web_search_progress_forwarded":{let s=VC(e,t,r);s.latestCodexEventId=_e(t.item_key)??s.latestCodexEventId,s.eventType=Fxe(o,t),s.turnId=_e(t.turn_id)??s.turnId,_e(t.structured_kind)==="codex_assistant_message"&&(s.lastAssistantPreview=_e(t.body_preview)??s.lastAssistantPreview,s.lastAssistantAtMs=r),s.updatedAtMs=r;break}case"claude_code.turn_starting":case"claude_code.message_queued":{let s=Lc(e,t,r);s.lastIncomingPreview=_e(t.body_preview)??s.lastIncomingPreview,s.lastIncomingAtMs=Bn(t.message_received_at_ms)??s.lastIncomingAtMs,s.eventType=o==="claude_code.message_queued"?"message_queued":"turn_starting",s.updatedAtMs=r;break}case"claude_code.session_started":{let s=Lc(e,t,r);s.eventType="session_started",s.updatedAtMs=r;break}case"claude_code.turn_completed":{let s=Lc(e,t,r);s.lastAssistantPreview=_e(t.body_preview)??s.lastAssistantPreview,s.lastAssistantAtMs=r,s.eventType="turn_completed",s.updatedAtMs=r;break}case"claude_code.turn_terminal":{let s=Lc(e,t,r);s.turnId=_e(t.turn_id)??s.turnId,s.eventType=`turn_${_e(t.outcome)??"terminal"}`,s.updatedAtMs=r;break}case"claude_code.rate_limit":{let s=_e(t.rate_limit_summary);s!==void 0&&(e.rateLimit=A4(e.rateLimit,s));let a=Lc(e,t,r);a.eventType="rate_limit",a.updatedAtMs=r;break}case"claude_code.token_usage":{let s=_e(t.token_usage_summary),a=Lc(e,t,r);s!==void 0&&(e.tokenUsage=s,a.tokenUsage=s),a.eventType="token_usage",a.updatedAtMs=r;break}default:break}gxe(e,o,t,i)}function GC(e,n){if(e.jobs.size===0&&e.discovery.size===0&&e.notices.size===0&&e.tokenUsage===void 0&&e.rateLimit===void 0&&e.creditExhaustion===void 0)return;let t=kd(e);switch(e.mode.type){case"table":return e.jobs.size===0&&e.discovery.size>0?Zye(e,n):txe(e,t,n);case"raw_all":return zC(e,"Raw Stream",void 0,"esc/q: table",e.rawLines,n,"No raw events yet.");case"raw_job":{let r=e.mode.jobKey,o=e.jobs.get(r),i=`Raw Stream: ${eT(o?.linzumiThreadId)} / ${nT(o?.codexThreadId,o?.agentProvider)}`;return zC(e,i,o?.tokenUsage,"esc/q: table",e.rawLines.filter(s=>s.jobKey===r),n,"No raw events yet.")}case"audit_log":return zC(e,"Commander Audit Log",void 0,"esc/q: table",K4(e).map(r=>({jobKey:void 0,line:r})),n,"No audit events yet.")}}function Zye(e,n){let t=Array.from(e.discovery.values()).sort((s,a)=>Ix(s.phase).localeCompare(Ix(a.phase))),r=t.reduce((s,a)=>s+a.placesSearched,0),o=t.some(s=>["starting","running"].includes(s.status)),i=t.length===0?["Discovery starting 0 places Waiting for discovery agents"]:t.map(s=>[Ax(s.phase).padEnd(14),Ox(s.status).padEnd(10),`${String(s.placesSearched)} places`.padEnd(10),ZC(s)].join(" "));return[XC(),"","Linzumi setup","New computer connected","",`Continue in the browser: ${e.browserUrl??"open the Linzumi setup page"}`,"",Qye(t),`Workspace: ${e.workspace??"?"}`,`Runner: ${e.runnerId??"?"}`,`Status: ${o?"searching":"finished"} Places searched: ${r}`,`Last update: ${$i(e.lastUpdateAtMs,n)}${qc(e)}`,"","Phase Status Places Detail","------------- ---------- --------- ------------------------------",...i,""].join(`
|
|
676
676
|
`)}function Ix(e){switch(e){case"projects":return"1-projects";case"conversations":return"2-conversations";default:return`3-${e}`}}function Ax(e){switch(e){case"projects":return"Projects";case"conversations":return"Conversations";default:return"Discovery"}}function Ox(e){switch(e){case"starting":return"starting";case"running":return"searching";case"completed":return"done";case"failed":return"failed";default:return e}}function Qye(e){return e.length===0?"I'm waiting for the discovery agents to start.":e.some(t=>["starting","running"].includes(t.status))?"I'm scouting existing projects and coding-agent conversations.":"Discovery is finished and idle. Select a project in the browser or move on."}function ZC(e){if(e.lastError!==void 0)return e.lastError;let n=QC(e);if(n!==void 0)return n;let t=nxe(e.currentSource);return e.currentPlace!==void 0?t===void 0?e.currentPlace:`${t}: ${e.currentPlace}`:e.message??U4(e.phase)}function QC(e){if(e.phase!=="conversations"||!UC(e.metadata))return;let n=Bn(e.metadata?.total_count)??(Bn(e.metadata?.codex_count)??0)+(Bn(e.metadata?.claude_code_count)??0),t=Bn(e.metadata?.imported_count)??Bn(e.metadata?.reported_count);return t===void 0||n<=0?void 0:`${e.status==="completed"?"Imported":"Importing"} [${Xye(t,n)}] ${t} / ${n} Codex/Claude Code conversations`}function UC(e){return _e(e?.worker_id)==="conversations-local-import"||Bn(e?.imported_count)!==void 0||Bn(e?.failed_import_count)!==void 0||Bn(e?.total_count)!==void 0}function Xye(e,n){let r=Math.min(10,Math.max(0,Math.floor(e/n*10)));return`${"#".repeat(r)}${"-".repeat(10-r)}`}function Yye(e,n){return e===void 0?n:n===void 0?e:{...e,...n,...Nf(e,n,"codex_count"),...Nf(e,n,"claude_code_count"),...Nf(e,n,"reported_count"),...Nf(e,n,"imported_count"),...Nf(e,n,"total_count")}}function Nf(e,n,t){let r=Bn(e[t]),o=Bn(n[t]);return r===void 0&&o===void 0?{}:{[t]:Math.max(r??0,o??0)}}function exe(e,n,t){return e?.status==="running"&&UC(e.metadata)&&!UC(t)?e.status:n}function nxe(e){switch(e){case"git":return"Git";case"codex":return"Codex";case"claude_code":return"Claude Code";case void 0:return;default:return e}}function U4(e){switch(e){case"projects":return"Checking common project folders and Git worktrees.";case"conversations":return"Checking Codex and Claude Code sessions.";default:return"Checking local context."}}function txe(e,n,t){let r=V4(e,n,t);return[XC(),"","Linzumi Commander","",`Jobs: ${n.length}${e.rosterTruncated?" (first 200 of this node's roster)":""} Last update: ${$i(e.lastUpdateAtMs,t)}${qc(e)}`,...B4(e.creditExhaustion),`Overall Token Usage: ${e.tokenUsage??"?"}`,`Account rate limits: ${e.rateLimit??"?"}`,"Controls: up/down select | enter raw job | r raw stream | a audit log | esc table",...BC(e),"",Nxe(r.rows),""].join(`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';
|
|
2
|
-
const require =
|
|
1
|
+
import { createRequire as __linzumiBundleCreateRequire } from 'node:module';
|
|
2
|
+
const require = __linzumiBundleCreateRequire(import.meta.url);
|
|
3
3
|
var nv=Object.create;var Ii=Object.defineProperty;var ov=Object.getOwnPropertyDescriptor;var sv=Object.getOwnPropertyNames;var iv=Object.getPrototypeOf,av=Object.prototype.hasOwnProperty;var z=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Ei=(e,t)=>{for(var r in t)Ii(e,r,{get:t[r],enumerable:!0})},cv=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of sv(t))!av.call(e,o)&&o!==r&&Ii(e,o,{get:()=>t[o],enumerable:!(n=ov(t,o))||n.enumerable});return e};var Dl=(e,t,r)=>(r=e!=null?nv(iv(e)):{},cv(t||!e||!e.__esModule?Ii(r,"default",{value:e,enumerable:!0}):r,e));var eo=z(Q=>{"use strict";Object.defineProperty(Q,"__esModule",{value:!0});Q.regexpCode=Q.getEsmExportName=Q.getProperty=Q.safeStringify=Q.stringify=Q.strConcat=Q.addCodeArg=Q.str=Q._=Q.nil=Q._Code=Q.Name=Q.IDENTIFIER=Q._CodeOrName=void 0;var Yn=class{};Q._CodeOrName=Yn;Q.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Pr=class extends Yn{constructor(t){if(super(),!Q.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};Q.Name=Pr;var tt=class extends Yn{constructor(t){super(),this._items=typeof t=="string"?[t]:t}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let t=this._items[0];return t===""||t==='""'}get str(){var t;return(t=this._str)!==null&&t!==void 0?t:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var t;return(t=this._names)!==null&&t!==void 0?t:this._names=this._items.reduce((r,n)=>(n instanceof Pr&&(r[n.str]=(r[n.str]||0)+1),r),{})}};Q._Code=tt;Q.nil=new tt("");function Mf(e,...t){let r=[e[0]],n=0;for(;n<t.length;)mu(r,t[n]),r.push(e[++n]);return new tt(r)}Q._=Mf;var pu=new tt("+");function Nf(e,...t){let r=[Qn(e[0])],n=0;for(;n<t.length;)r.push(pu),mu(r,t[n]),r.push(pu,Qn(e[++n]));return i0(r),new tt(r)}Q.str=Nf;function mu(e,t){t instanceof tt?e.push(...t._items):t instanceof Pr?e.push(t):e.push(u0(t))}Q.addCodeArg=mu;function i0(e){let t=1;for(;t<e.length-1;){if(e[t]===pu){let r=a0(e[t-1],e[t+1]);if(r!==void 0){e.splice(t-1,3,r);continue}e[t++]="+"}t++}}function a0(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof Pr||e[e.length-1]!=='"'?void 0:typeof t!="string"?`${e.slice(0,-1)}${t}"`:t[0]==='"'?e.slice(0,-1)+t.slice(1):void 0;if(typeof t=="string"&&t[0]==='"'&&!(e instanceof Pr))return`"${e}${t.slice(1)}`}function c0(e,t){return t.emptyStr()?e:e.emptyStr()?t:Nf`${e}${t}`}Q.strConcat=c0;function u0(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:Qn(Array.isArray(e)?e.join(","):e)}function d0(e){return new tt(Qn(e))}Q.stringify=d0;function Qn(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}Q.safeStringify=Qn;function l0(e){return typeof e=="string"&&Q.IDENTIFIER.test(e)?new tt(`.${e}`):Mf`[${e}]`}Q.getProperty=l0;function p0(e){if(typeof e=="string"&&Q.IDENTIFIER.test(e))return new tt(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}Q.getEsmExportName=p0;function m0(e){return new tt(e.toString())}Q.regexpCode=m0});var gu=z(qe=>{"use strict";Object.defineProperty(qe,"__esModule",{value:!0});qe.ValueScope=qe.ValueScopeName=qe.Scope=qe.varKinds=qe.UsedValueState=void 0;var Ue=eo(),fu=class extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value}},Cs;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"})(Cs||(qe.UsedValueState=Cs={}));qe.varKinds={const:new Ue.Name("const"),let:new Ue.Name("let"),var:new Ue.Name("var")};var As=class{constructor({prefixes:t,parent:r}={}){this._names={},this._prefixes=t,this._parent=r}toName(t){return t instanceof Ue.Name?t:this.name(t)}name(t){return new Ue.Name(this._newName(t))}_newName(t){let r=this._names[t]||this._nameGroup(t);return`${t}${r.index++}`}_nameGroup(t){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(t)||this._prefixes&&!this._prefixes.has(t))throw new Error(`CodeGen: prefix "${t}" is not allowed in this scope`);return this._names[t]={prefix:t,index:0}}};qe.Scope=As;var Ms=class extends Ue.Name{constructor(t,r){super(r),this.prefix=t}setValue(t,{property:r,itemIndex:n}){this.value=t,this.scopePath=(0,Ue._)`.${new Ue.Name(r)}[${n}]`}};qe.ValueScopeName=Ms;var f0=(0,Ue._)`\n`,hu=class extends As{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?f0:Ue.nil}}get(){return this._scope}name(t){return new Ms(t,this._newName(t))}value(t,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let o=this.toName(t),{prefix:s}=o,i=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[s];if(a){let d=a.get(i);if(d)return d}else a=this._values[s]=new Map;a.set(i,o);let c=this._scope[s]||(this._scope[s]=[]),u=c.length;return c[u]=r.ref,o.setValue(r,{property:s,itemIndex:u}),o}getValue(t,r){let n=this._values[t];if(n)return n.get(r)}scopeRefs(t,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,Ue._)`${t}${n.scopePath}`})}scopeCode(t=this._values,r,n){return this._reduceValues(t,o=>{if(o.value===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return o.value.code},r,n)}_reduceValues(t,r,n={},o){let s=Ue.nil;for(let i in t){let a=t[i];if(!a)continue;let c=n[i]=n[i]||new Map;a.forEach(u=>{if(c.has(u))return;c.set(u,Cs.Started);let d=r(u);if(d){let l=this.opts.es5?qe.varKinds.var:qe.varKinds.const;s=(0,Ue._)`${s}${l} ${u} = ${d};${this.opts._n}`}else if(d=o?.(u))s=(0,Ue._)`${s}${d}${this.opts._n}`;else throw new fu(u);c.set(u,Cs.Completed)})}return s}};qe.ValueScope=hu});var F=z(V=>{"use strict";Object.defineProperty(V,"__esModule",{value:!0});V.or=V.and=V.not=V.CodeGen=V.operators=V.varKinds=V.ValueScopeName=V.ValueScope=V.Scope=V.Name=V.regexpCode=V.stringify=V.getProperty=V.nil=V.strConcat=V.str=V._=void 0;var X=eo(),ut=gu(),Kt=eo();Object.defineProperty(V,"_",{enumerable:!0,get:function(){return Kt._}});Object.defineProperty(V,"str",{enumerable:!0,get:function(){return Kt.str}});Object.defineProperty(V,"strConcat",{enumerable:!0,get:function(){return Kt.strConcat}});Object.defineProperty(V,"nil",{enumerable:!0,get:function(){return Kt.nil}});Object.defineProperty(V,"getProperty",{enumerable:!0,get:function(){return Kt.getProperty}});Object.defineProperty(V,"stringify",{enumerable:!0,get:function(){return Kt.stringify}});Object.defineProperty(V,"regexpCode",{enumerable:!0,get:function(){return Kt.regexpCode}});Object.defineProperty(V,"Name",{enumerable:!0,get:function(){return Kt.Name}});var Zs=gu();Object.defineProperty(V,"Scope",{enumerable:!0,get:function(){return Zs.Scope}});Object.defineProperty(V,"ValueScope",{enumerable:!0,get:function(){return Zs.ValueScope}});Object.defineProperty(V,"ValueScopeName",{enumerable:!0,get:function(){return Zs.ValueScopeName}});Object.defineProperty(V,"varKinds",{enumerable:!0,get:function(){return Zs.varKinds}});V.operators={GT:new X._Code(">"),GTE:new X._Code(">="),LT:new X._Code("<"),LTE:new X._Code("<="),EQ:new X._Code("==="),NEQ:new X._Code("!=="),NOT:new X._Code("!"),OR:new X._Code("||"),AND:new X._Code("&&"),ADD:new X._Code("+")};var jt=class{optimizeNodes(){return this}optimizeNames(t,r){return this}},yu=class extends jt{constructor(t,r,n){super(),this.varKind=t,this.name=r,this.rhs=n}render({es5:t,_n:r}){let n=t?ut.varKinds.var:this.varKind,o=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${o};`+r}optimizeNames(t,r){if(t[this.name.str])return this.rhs&&(this.rhs=an(this.rhs,t,r)),this}get names(){return this.rhs instanceof X._CodeOrName?this.rhs.names:{}}},Ns=class extends jt{constructor(t,r,n){super(),this.lhs=t,this.rhs=r,this.sideEffects=n}render({_n:t}){return`${this.lhs} = ${this.rhs};`+t}optimizeNames(t,r){if(!(this.lhs instanceof X.Name&&!t[this.lhs.str]&&!this.sideEffects))return this.rhs=an(this.rhs,t,r),this}get names(){let t=this.lhs instanceof X.Name?{}:{...this.lhs.names};return Ds(t,this.rhs)}},_u=class extends Ns{constructor(t,r,n,o){super(t,n,o),this.op=r}render({_n:t}){return`${this.lhs} ${this.op}= ${this.rhs};`+t}},vu=class extends jt{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`${this.label}:`+t}},bu=class extends jt{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`break${this.label?` ${this.label}`:""};`+t}},wu=class extends jt{constructor(t){super(),this.error=t}render({_n:t}){return`throw ${this.error};`+t}get names(){return this.error.names}},ku=class extends jt{constructor(t){super(),this.code=t}render({_n:t}){return`${this.code};`+t}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(t,r){return this.code=an(this.code,t,r),this}get names(){return this.code instanceof X._CodeOrName?this.code.names:{}}},to=class extends jt{constructor(t=[]){super(),this.nodes=t}render(t){return this.nodes.reduce((r,n)=>r+n.render(t),"")}optimizeNodes(){let{nodes:t}=this,r=t.length;for(;r--;){let n=t[r].optimizeNodes();Array.isArray(n)?t.splice(r,1,...n):n?t[r]=n:t.splice(r,1)}return t.length>0?this:void 0}optimizeNames(t,r){let{nodes:n}=this,o=n.length;for(;o--;){let s=n[o];s.optimizeNames(t,r)||(h0(t,s.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((t,r)=>Ir(t,r.names),{})}},Ct=class extends to{render(t){return"{"+t._n+super.render(t)+"}"+t._n}},xu=class extends to{},sn=class extends Ct{};sn.kind="else";var Tr=class e extends Ct{constructor(t,r){super(r),this.condition=t}render(t){let r=`if(${this.condition})`+super.render(t);return this.else&&(r+="else "+this.else.render(t)),r}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new sn(n):n}if(r)return t===!1?r instanceof e?r:r.nodes:this.nodes.length?this:new e(Lf(t),r instanceof e?[r]:r.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(t,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(t,r),!!(super.optimizeNames(t,r)||this.else))return this.condition=an(this.condition,t,r),this}get names(){let t=super.names;return Ds(t,this.condition),this.else&&Ir(t,this.else.names),t}};Tr.kind="if";var Rr=class extends Ct{};Rr.kind="for";var Su=class extends Rr{constructor(t){super(),this.iteration=t}render(t){return`for(${this.iteration})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iteration=an(this.iteration,t,r),this}get names(){return Ir(super.names,this.iteration.names)}},$u=class extends Rr{constructor(t,r,n,o){super(),this.varKind=t,this.name=r,this.from=n,this.to=o}render(t){let r=t.es5?ut.varKinds.var:this.varKind,{name:n,from:o,to:s}=this;return`for(${r} ${n}=${o}; ${n}<${s}; ${n}++)`+super.render(t)}get names(){let t=Ds(super.names,this.from);return Ds(t,this.to)}},Ls=class extends Rr{constructor(t,r,n,o){super(),this.loop=t,this.varKind=r,this.name=n,this.iterable=o}render(t){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iterable=an(this.iterable,t,r),this}get names(){return Ir(super.names,this.iterable.names)}},ro=class extends Ct{constructor(t,r,n){super(),this.name=t,this.args=r,this.async=n}render(t){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(t)}};ro.kind="func";var no=class extends to{render(t){return"return "+super.render(t)}};no.kind="return";var zu=class extends Ct{render(t){let r="try"+super.render(t);return this.catch&&(r+=this.catch.render(t)),this.finally&&(r+=this.finally.render(t)),r}optimizeNodes(){var t,r;return super.optimizeNodes(),(t=this.catch)===null||t===void 0||t.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(t,r){var n,o;return super.optimizeNames(t,r),(n=this.catch)===null||n===void 0||n.optimizeNames(t,r),(o=this.finally)===null||o===void 0||o.optimizeNames(t,r),this}get names(){let t=super.names;return this.catch&&Ir(t,this.catch.names),this.finally&&Ir(t,this.finally.names),t}},oo=class extends Ct{constructor(t){super(),this.error=t}render(t){return`catch(${this.error})`+super.render(t)}};oo.kind="catch";var so=class extends Ct{render(t){return"finally"+super.render(t)}};so.kind="finally";var Pu=class{constructor(t,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
4
4
|
`:""},this._extScope=t,this._scope=new ut.Scope({parent:t}),this._nodes=[new xu]}toString(){return this._root.render(this.opts)}name(t){return this._scope.name(t)}scopeName(t){return this._extScope.name(t)}scopeValue(t,r){let n=this._extScope.value(t,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(t,r){return this._extScope.getValue(t,r)}scopeRefs(t){return this._extScope.scopeRefs(t,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(t,r,n,o){let s=this._scope.toName(r);return n!==void 0&&o&&(this._constants[s.str]=n),this._leafNode(new yu(t,s,n)),s}const(t,r,n){return this._def(ut.varKinds.const,t,r,n)}let(t,r,n){return this._def(ut.varKinds.let,t,r,n)}var(t,r,n){return this._def(ut.varKinds.var,t,r,n)}assign(t,r,n){return this._leafNode(new Ns(t,r,n))}add(t,r){return this._leafNode(new _u(t,V.operators.ADD,r))}code(t){return typeof t=="function"?t():t!==X.nil&&this._leafNode(new ku(t)),this}object(...t){let r=["{"];for(let[n,o]of t)r.length>1&&r.push(","),r.push(n),(n!==o||this.opts.es5)&&(r.push(":"),(0,X.addCodeArg)(r,o));return r.push("}"),new X._Code(r)}if(t,r,n){if(this._blockNode(new Tr(t)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(t){return this._elseNode(new Tr(t))}else(){return this._elseNode(new sn)}endIf(){return this._endBlockNode(Tr,sn)}_for(t,r){return this._blockNode(t),r&&this.code(r).endFor(),this}for(t,r){return this._for(new Su(t),r)}forRange(t,r,n,o,s=this.opts.es5?ut.varKinds.var:ut.varKinds.let){let i=this._scope.toName(t);return this._for(new $u(s,i,r,n),()=>o(i))}forOf(t,r,n,o=ut.varKinds.const){let s=this._scope.toName(t);if(this.opts.es5){let i=r instanceof X.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,X._)`${i}.length`,a=>{this.var(s,(0,X._)`${i}[${a}]`),n(s)})}return this._for(new Ls("of",o,s,r),()=>n(s))}forIn(t,r,n,o=this.opts.es5?ut.varKinds.var:ut.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0,X._)`Object.keys(${r})`,n);let s=this._scope.toName(t);return this._for(new Ls("in",o,s,r),()=>n(s))}endFor(){return this._endBlockNode(Rr)}label(t){return this._leafNode(new vu(t))}break(t){return this._leafNode(new bu(t))}return(t){let r=new no;if(this._blockNode(r),this.code(t),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(no)}try(t,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new zu;if(this._blockNode(o),this.code(t),r){let s=this.name("e");this._currNode=o.catch=new oo(s),r(s)}return n&&(this._currNode=o.finally=new so,this.code(n)),this._endBlockNode(oo,so)}throw(t){return this._leafNode(new wu(t))}block(t,r){return this._blockStarts.push(this._nodes.length),t&&this.code(t).endBlock(r),this}endBlock(t){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||t!==void 0&&n!==t)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${t} expected`);return this._nodes.length=r,this}func(t,r=X.nil,n,o){return this._blockNode(new ro(t,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(ro)}optimize(t=1){for(;t-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(t){return this._currNode.nodes.push(t),this}_blockNode(t){this._currNode.nodes.push(t),this._nodes.push(t)}_endBlockNode(t,r){let n=this._currNode;if(n instanceof t||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${t.kind}/${r.kind}`:t.kind}"`)}_elseNode(t){let r=this._currNode;if(!(r instanceof Tr))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=t,this}get _root(){return this._nodes[0]}get _currNode(){let t=this._nodes;return t[t.length-1]}set _currNode(t){let r=this._nodes;r[r.length-1]=t}};V.CodeGen=Pu;function Ir(e,t){for(let r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function Ds(e,t){return t instanceof X._CodeOrName?Ir(e,t.names):e}function an(e,t,r){if(e instanceof X.Name)return n(e);if(!o(e))return e;return new X._Code(e._items.reduce((s,i)=>(i instanceof X.Name&&(i=n(i)),i instanceof X._Code?s.push(...i._items):s.push(i),s),[]));function n(s){let i=r[s.str];return i===void 0||t[s.str]!==1?s:(delete t[s.str],i)}function o(s){return s instanceof X._Code&&s._items.some(i=>i instanceof X.Name&&t[i.str]===1&&r[i.str]!==void 0)}}function h0(e,t){for(let r in t)e[r]=(e[r]||0)-(t[r]||0)}function Lf(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0,X._)`!${Tu(e)}`}V.not=Lf;var g0=Df(V.operators.AND);function y0(...e){return e.reduce(g0)}V.and=y0;var _0=Df(V.operators.OR);function v0(...e){return e.reduce(_0)}V.or=v0;function Df(e){return(t,r)=>t===X.nil?r:r===X.nil?t:(0,X._)`${Tu(t)} ${e} ${Tu(r)}`}function Tu(e){return e instanceof X.Name?e:(0,X._)`(${e})`}});var ee=z(B=>{"use strict";Object.defineProperty(B,"__esModule",{value:!0});B.checkStrictMode=B.getErrorPath=B.Type=B.useFunc=B.setEvaluated=B.evaluatedPropsToName=B.mergeEvaluated=B.eachItem=B.unescapeJsonPointer=B.escapeJsonPointer=B.escapeFragment=B.unescapeFragment=B.schemaRefOrVal=B.schemaHasRulesButRef=B.schemaHasRules=B.checkUnknownRules=B.alwaysValidSchema=B.toHash=void 0;var se=F(),b0=eo();function w0(e){let t={};for(let r of e)t[r]=!0;return t}B.toHash=w0;function k0(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(qf(e,t),!Jf(t,e.self.RULES.all))}B.alwaysValidSchema=k0;function qf(e,t=e.schema){let{opts:r,self:n}=e;if(!r.strictSchema||typeof t=="boolean")return;let o=n.RULES.keywords;for(let s in t)o[s]||Bf(e,`unknown keyword: "${s}"`)}B.checkUnknownRules=qf;function Jf(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(t[r])return!0;return!1}B.schemaHasRules=Jf;function x0(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}B.schemaHasRulesButRef=x0;function S0({topSchemaRef:e,schemaPath:t},r,n,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,se._)`${r}`}return(0,se._)`${e}${t}${(0,se.getProperty)(n)}`}B.schemaRefOrVal=S0;function $0(e){return Ff(decodeURIComponent(e))}B.unescapeFragment=$0;function z0(e){return encodeURIComponent(Iu(e))}B.escapeFragment=z0;function Iu(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}B.escapeJsonPointer=Iu;function Ff(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}B.unescapeJsonPointer=Ff;function P0(e,t){if(Array.isArray(e))for(let r of e)t(r);else t(e)}B.eachItem=P0;function Zf({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(o,s,i,a)=>{let c=i===void 0?s:i instanceof se.Name?(s instanceof se.Name?e(o,s,i):t(o,s,i),i):s instanceof se.Name?(t(o,i,s),s):r(s,i);return a===se.Name&&!(c instanceof se.Name)?n(o,c):c}}B.mergeEvaluated={props:Zf({mergeNames:(e,t,r)=>e.if((0,se._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,se._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,se._)`${r} || {}`).code((0,se._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,se._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,se._)`${r} || {}`),Eu(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:Vf}),items:Zf({mergeNames:(e,t,r)=>e.if((0,se._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,se._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,se._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,se._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function Vf(e,t){if(t===!0)return e.var("props",!0);let r=e.var("props",(0,se._)`{}`);return t!==void 0&&Eu(e,r,t),r}B.evaluatedPropsToName=Vf;function Eu(e,t,r){Object.keys(r).forEach(n=>e.assign((0,se._)`${t}${(0,se.getProperty)(n)}`,!0))}B.setEvaluated=Eu;var Uf={};function T0(e,t){return e.scopeValue("func",{ref:t,code:Uf[t.code]||(Uf[t.code]=new b0._Code(t.code))})}B.useFunc=T0;var Ru;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(Ru||(B.Type=Ru={}));function R0(e,t,r){if(e instanceof se.Name){let n=t===Ru.Num;return r?n?(0,se._)`"[" + ${e} + "]"`:(0,se._)`"['" + ${e} + "']"`:n?(0,se._)`"/" + ${e}`:(0,se._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,se.getProperty)(e).toString():"/"+Iu(e)}B.getErrorPath=R0;function Bf(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}B.checkStrictMode=Bf});var At=z(Ou=>{"use strict";Object.defineProperty(Ou,"__esModule",{value:!0});var Re=F(),I0={data:new Re.Name("data"),valCxt:new Re.Name("valCxt"),instancePath:new Re.Name("instancePath"),parentData:new Re.Name("parentData"),parentDataProperty:new Re.Name("parentDataProperty"),rootData:new Re.Name("rootData"),dynamicAnchors:new Re.Name("dynamicAnchors"),vErrors:new Re.Name("vErrors"),errors:new Re.Name("errors"),this:new Re.Name("this"),self:new Re.Name("self"),scope:new Re.Name("scope"),json:new Re.Name("json"),jsonPos:new Re.Name("jsonPos"),jsonLen:new Re.Name("jsonLen"),jsonPart:new Re.Name("jsonPart")};Ou.default=I0});var io=z(Ie=>{"use strict";Object.defineProperty(Ie,"__esModule",{value:!0});Ie.extendErrors=Ie.resetErrorsCount=Ie.reportExtraError=Ie.reportError=Ie.keyword$DataError=Ie.keywordError=void 0;var Y=F(),Us=ee(),Ae=At();Ie.keywordError={message:({keyword:e})=>(0,Y.str)`must pass "${e}" keyword validation`};Ie.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0,Y.str)`"${e}" keyword must be ${t} ($data)`:(0,Y.str)`"${e}" keyword is invalid ($data)`};function E0(e,t=Ie.keywordError,r,n){let{it:o}=e,{gen:s,compositeRule:i,allErrors:a}=o,c=Kf(e,t,r);n??(i||a)?Hf(s,c):Wf(o,(0,Y._)`[${c}]`)}Ie.reportError=E0;function O0(e,t=Ie.keywordError,r){let{it:n}=e,{gen:o,compositeRule:s,allErrors:i}=n,a=Kf(e,t,r);Hf(o,a),s||i||Wf(n,Ae.default.vErrors)}Ie.reportExtraError=O0;function j0(e,t){e.assign(Ae.default.errors,t),e.if((0,Y._)`${Ae.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0,Y._)`${Ae.default.vErrors}.length`,t),()=>e.assign(Ae.default.vErrors,null)))}Ie.resetErrorsCount=j0;function C0({gen:e,keyword:t,schemaValue:r,data:n,errsCount:o,it:s}){if(o===void 0)throw new Error("ajv implementation error");let i=e.name("err");e.forRange("i",o,Ae.default.errors,a=>{e.const(i,(0,Y._)`${Ae.default.vErrors}[${a}]`),e.if((0,Y._)`${i}.instancePath === undefined`,()=>e.assign((0,Y._)`${i}.instancePath`,(0,Y.strConcat)(Ae.default.instancePath,s.errorPath))),e.assign((0,Y._)`${i}.schemaPath`,(0,Y.str)`${s.errSchemaPath}/${t}`),s.opts.verbose&&(e.assign((0,Y._)`${i}.schema`,r),e.assign((0,Y._)`${i}.data`,n))})}Ie.extendErrors=C0;function Hf(e,t){let r=e.const("err",t);e.if((0,Y._)`${Ae.default.vErrors} === null`,()=>e.assign(Ae.default.vErrors,(0,Y._)`[${r}]`),(0,Y._)`${Ae.default.vErrors}.push(${r})`),e.code((0,Y._)`${Ae.default.errors}++`)}function Wf(e,t){let{gen:r,validateName:n,schemaEnv:o}=e;o.$async?r.throw((0,Y._)`new ${e.ValidationError}(${t})`):(r.assign((0,Y._)`${n}.errors`,t),r.return(!1))}var Er={keyword:new Y.Name("keyword"),schemaPath:new Y.Name("schemaPath"),params:new Y.Name("params"),propertyName:new Y.Name("propertyName"),message:new Y.Name("message"),schema:new Y.Name("schema"),parentSchema:new Y.Name("parentSchema")};function Kf(e,t,r){let{createErrors:n}=e.it;return n===!1?(0,Y._)`{}`:A0(e,t,r)}function A0(e,t,r={}){let{gen:n,it:o}=e,s=[M0(o,r),N0(e,r)];return L0(e,t,s),n.object(...s)}function M0({errorPath:e},{instancePath:t}){let r=t?(0,Y.str)`${e}${(0,Us.getErrorPath)(t,Us.Type.Str)}`:e;return[Ae.default.instancePath,(0,Y.strConcat)(Ae.default.instancePath,r)]}function N0({keyword:e,it:{errSchemaPath:t}},{schemaPath:r,parentSchema:n}){let o=n?t:(0,Y.str)`${t}/${e}`;return r&&(o=(0,Y.str)`${o}${(0,Us.getErrorPath)(r,Us.Type.Str)}`),[Er.schemaPath,o]}function L0(e,{params:t,message:r},n){let{keyword:o,data:s,schemaValue:i,it:a}=e,{opts:c,propertyName:u,topSchemaRef:d,schemaPath:l}=a;n.push([Er.keyword,o],[Er.params,typeof t=="function"?t(e):t||(0,Y._)`{}`]),c.messages&&n.push([Er.message,typeof r=="function"?r(e):r]),c.verbose&&n.push([Er.schema,i],[Er.parentSchema,(0,Y._)`${d}${l}`],[Ae.default.data,s]),u&&n.push([Er.propertyName,u])}});var Xf=z(cn=>{"use strict";Object.defineProperty(cn,"__esModule",{value:!0});cn.boolOrEmptySchema=cn.topBoolOrEmptySchema=void 0;var D0=io(),Z0=F(),U0=At(),q0={message:"boolean schema is false"};function J0(e){let{gen:t,schema:r,validateName:n}=e;r===!1?Gf(e,!1):typeof r=="object"&&r.$async===!0?t.return(U0.default.data):(t.assign((0,Z0._)`${n}.errors`,null),t.return(!0))}cn.topBoolOrEmptySchema=J0;function F0(e,t){let{gen:r,schema:n}=e;n===!1?(r.var(t,!1),Gf(e)):r.var(t,!0)}cn.boolOrEmptySchema=F0;function Gf(e,t){let{gen:r,data:n}=e,o={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,D0.reportError)(o,q0,void 0,t)}});var ju=z(un=>{"use strict";Object.defineProperty(un,"__esModule",{value:!0});un.getRules=un.isJSONType=void 0;var V0=["string","number","integer","boolean","null","object","array"],B0=new Set(V0);function H0(e){return typeof e=="string"&&B0.has(e)}un.isJSONType=H0;function W0(){let e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}un.getRules=W0});var Cu=z(Gt=>{"use strict";Object.defineProperty(Gt,"__esModule",{value:!0});Gt.shouldUseRule=Gt.shouldUseGroup=Gt.schemaHasRulesForType=void 0;function K0({schema:e,self:t},r){let n=t.RULES.types[r];return n&&n!==!0&&Yf(e,n)}Gt.schemaHasRulesForType=K0;function Yf(e,t){return t.rules.some(r=>Qf(e,r))}Gt.shouldUseGroup=Yf;function Qf(e,t){var r;return e[t.keyword]!==void 0||((r=t.definition.implements)===null||r===void 0?void 0:r.some(n=>e[n]!==void 0))}Gt.shouldUseRule=Qf});var ao=z(Ee=>{"use strict";Object.defineProperty(Ee,"__esModule",{value:!0});Ee.reportTypeError=Ee.checkDataTypes=Ee.checkDataType=Ee.coerceAndCheckDataType=Ee.getJSONTypes=Ee.getSchemaTypes=Ee.DataType=void 0;var G0=ju(),X0=Cu(),Y0=io(),q=F(),eh=ee(),dn;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(dn||(Ee.DataType=dn={}));function Q0(e){let t=th(e.type);if(t.includes("null")){if(e.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===!0&&t.push("null")}return t}Ee.getSchemaTypes=Q0;function th(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(G0.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}Ee.getJSONTypes=th;function eS(e,t){let{gen:r,data:n,opts:o}=e,s=tS(t,o.coerceTypes),i=t.length>0&&!(s.length===0&&t.length===1&&(0,X0.schemaHasRulesForType)(e,t[0]));if(i){let a=Mu(t,n,o.strictNumbers,dn.Wrong);r.if(a,()=>{s.length?rS(e,t,s):Nu(e)})}return i}Ee.coerceAndCheckDataType=eS;var rh=new Set(["string","number","integer","boolean","null"]);function tS(e,t){return t?e.filter(r=>rh.has(r)||t==="array"&&r==="array"):[]}function rS(e,t,r){let{gen:n,data:o,opts:s}=e,i=n.let("dataType",(0,q._)`typeof ${o}`),a=n.let("coerced",(0,q._)`undefined`);s.coerceTypes==="array"&&n.if((0,q._)`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,(0,q._)`${o}[0]`).assign(i,(0,q._)`typeof ${o}`).if(Mu(t,o,s.strictNumbers),()=>n.assign(a,o))),n.if((0,q._)`${a} !== undefined`);for(let u of r)(rh.has(u)||u==="array"&&s.coerceTypes==="array")&&c(u);n.else(),Nu(e),n.endIf(),n.if((0,q._)`${a} !== undefined`,()=>{n.assign(o,a),nS(e,a)});function c(u){switch(u){case"string":n.elseIf((0,q._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,q._)`"" + ${o}`).elseIf((0,q._)`${o} === null`).assign(a,(0,q._)`""`);return;case"number":n.elseIf((0,q._)`${i} == "boolean" || ${o} === null
|
|
5
5
|
|| (${i} == "string" && ${o} && ${o} == +${o})`).assign(a,(0,q._)`+${o}`);return;case"integer":n.elseIf((0,q._)`${i} === "boolean" || ${o} === null
|
package/dist/mcp-server.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';
|
|
2
|
-
const require =
|
|
1
|
+
import { createRequire as __linzumiBundleCreateRequire } from 'node:module';
|
|
2
|
+
const require = __linzumiBundleCreateRequire(import.meta.url);
|
|
3
3
|
var nv=Object.create;var Ii=Object.defineProperty;var ov=Object.getOwnPropertyDescriptor;var sv=Object.getOwnPropertyNames;var iv=Object.getPrototypeOf,av=Object.prototype.hasOwnProperty;var z=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Ei=(e,t)=>{for(var r in t)Ii(e,r,{get:t[r],enumerable:!0})},cv=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of sv(t))!av.call(e,o)&&o!==r&&Ii(e,o,{get:()=>t[o],enumerable:!(n=ov(t,o))||n.enumerable});return e};var Dl=(e,t,r)=>(r=e!=null?nv(iv(e)):{},cv(t||!e||!e.__esModule?Ii(r,"default",{value:e,enumerable:!0}):r,e));var eo=z(Q=>{"use strict";Object.defineProperty(Q,"__esModule",{value:!0});Q.regexpCode=Q.getEsmExportName=Q.getProperty=Q.safeStringify=Q.stringify=Q.strConcat=Q.addCodeArg=Q.str=Q._=Q.nil=Q._Code=Q.Name=Q.IDENTIFIER=Q._CodeOrName=void 0;var Yn=class{};Q._CodeOrName=Yn;Q.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Pr=class extends Yn{constructor(t){if(super(),!Q.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};Q.Name=Pr;var tt=class extends Yn{constructor(t){super(),this._items=typeof t=="string"?[t]:t}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let t=this._items[0];return t===""||t==='""'}get str(){var t;return(t=this._str)!==null&&t!==void 0?t:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var t;return(t=this._names)!==null&&t!==void 0?t:this._names=this._items.reduce((r,n)=>(n instanceof Pr&&(r[n.str]=(r[n.str]||0)+1),r),{})}};Q._Code=tt;Q.nil=new tt("");function Mf(e,...t){let r=[e[0]],n=0;for(;n<t.length;)mu(r,t[n]),r.push(e[++n]);return new tt(r)}Q._=Mf;var pu=new tt("+");function Nf(e,...t){let r=[Qn(e[0])],n=0;for(;n<t.length;)r.push(pu),mu(r,t[n]),r.push(pu,Qn(e[++n]));return i0(r),new tt(r)}Q.str=Nf;function mu(e,t){t instanceof tt?e.push(...t._items):t instanceof Pr?e.push(t):e.push(u0(t))}Q.addCodeArg=mu;function i0(e){let t=1;for(;t<e.length-1;){if(e[t]===pu){let r=a0(e[t-1],e[t+1]);if(r!==void 0){e.splice(t-1,3,r);continue}e[t++]="+"}t++}}function a0(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof Pr||e[e.length-1]!=='"'?void 0:typeof t!="string"?`${e.slice(0,-1)}${t}"`:t[0]==='"'?e.slice(0,-1)+t.slice(1):void 0;if(typeof t=="string"&&t[0]==='"'&&!(e instanceof Pr))return`"${e}${t.slice(1)}`}function c0(e,t){return t.emptyStr()?e:e.emptyStr()?t:Nf`${e}${t}`}Q.strConcat=c0;function u0(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:Qn(Array.isArray(e)?e.join(","):e)}function d0(e){return new tt(Qn(e))}Q.stringify=d0;function Qn(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}Q.safeStringify=Qn;function l0(e){return typeof e=="string"&&Q.IDENTIFIER.test(e)?new tt(`.${e}`):Mf`[${e}]`}Q.getProperty=l0;function p0(e){if(typeof e=="string"&&Q.IDENTIFIER.test(e))return new tt(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}Q.getEsmExportName=p0;function m0(e){return new tt(e.toString())}Q.regexpCode=m0});var gu=z(qe=>{"use strict";Object.defineProperty(qe,"__esModule",{value:!0});qe.ValueScope=qe.ValueScopeName=qe.Scope=qe.varKinds=qe.UsedValueState=void 0;var Ue=eo(),fu=class extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value}},Cs;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"})(Cs||(qe.UsedValueState=Cs={}));qe.varKinds={const:new Ue.Name("const"),let:new Ue.Name("let"),var:new Ue.Name("var")};var As=class{constructor({prefixes:t,parent:r}={}){this._names={},this._prefixes=t,this._parent=r}toName(t){return t instanceof Ue.Name?t:this.name(t)}name(t){return new Ue.Name(this._newName(t))}_newName(t){let r=this._names[t]||this._nameGroup(t);return`${t}${r.index++}`}_nameGroup(t){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(t)||this._prefixes&&!this._prefixes.has(t))throw new Error(`CodeGen: prefix "${t}" is not allowed in this scope`);return this._names[t]={prefix:t,index:0}}};qe.Scope=As;var Ms=class extends Ue.Name{constructor(t,r){super(r),this.prefix=t}setValue(t,{property:r,itemIndex:n}){this.value=t,this.scopePath=(0,Ue._)`.${new Ue.Name(r)}[${n}]`}};qe.ValueScopeName=Ms;var f0=(0,Ue._)`\n`,hu=class extends As{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?f0:Ue.nil}}get(){return this._scope}name(t){return new Ms(t,this._newName(t))}value(t,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let o=this.toName(t),{prefix:s}=o,i=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[s];if(a){let d=a.get(i);if(d)return d}else a=this._values[s]=new Map;a.set(i,o);let c=this._scope[s]||(this._scope[s]=[]),u=c.length;return c[u]=r.ref,o.setValue(r,{property:s,itemIndex:u}),o}getValue(t,r){let n=this._values[t];if(n)return n.get(r)}scopeRefs(t,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,Ue._)`${t}${n.scopePath}`})}scopeCode(t=this._values,r,n){return this._reduceValues(t,o=>{if(o.value===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return o.value.code},r,n)}_reduceValues(t,r,n={},o){let s=Ue.nil;for(let i in t){let a=t[i];if(!a)continue;let c=n[i]=n[i]||new Map;a.forEach(u=>{if(c.has(u))return;c.set(u,Cs.Started);let d=r(u);if(d){let l=this.opts.es5?qe.varKinds.var:qe.varKinds.const;s=(0,Ue._)`${s}${l} ${u} = ${d};${this.opts._n}`}else if(d=o?.(u))s=(0,Ue._)`${s}${d}${this.opts._n}`;else throw new fu(u);c.set(u,Cs.Completed)})}return s}};qe.ValueScope=hu});var F=z(V=>{"use strict";Object.defineProperty(V,"__esModule",{value:!0});V.or=V.and=V.not=V.CodeGen=V.operators=V.varKinds=V.ValueScopeName=V.ValueScope=V.Scope=V.Name=V.regexpCode=V.stringify=V.getProperty=V.nil=V.strConcat=V.str=V._=void 0;var X=eo(),ut=gu(),Kt=eo();Object.defineProperty(V,"_",{enumerable:!0,get:function(){return Kt._}});Object.defineProperty(V,"str",{enumerable:!0,get:function(){return Kt.str}});Object.defineProperty(V,"strConcat",{enumerable:!0,get:function(){return Kt.strConcat}});Object.defineProperty(V,"nil",{enumerable:!0,get:function(){return Kt.nil}});Object.defineProperty(V,"getProperty",{enumerable:!0,get:function(){return Kt.getProperty}});Object.defineProperty(V,"stringify",{enumerable:!0,get:function(){return Kt.stringify}});Object.defineProperty(V,"regexpCode",{enumerable:!0,get:function(){return Kt.regexpCode}});Object.defineProperty(V,"Name",{enumerable:!0,get:function(){return Kt.Name}});var Zs=gu();Object.defineProperty(V,"Scope",{enumerable:!0,get:function(){return Zs.Scope}});Object.defineProperty(V,"ValueScope",{enumerable:!0,get:function(){return Zs.ValueScope}});Object.defineProperty(V,"ValueScopeName",{enumerable:!0,get:function(){return Zs.ValueScopeName}});Object.defineProperty(V,"varKinds",{enumerable:!0,get:function(){return Zs.varKinds}});V.operators={GT:new X._Code(">"),GTE:new X._Code(">="),LT:new X._Code("<"),LTE:new X._Code("<="),EQ:new X._Code("==="),NEQ:new X._Code("!=="),NOT:new X._Code("!"),OR:new X._Code("||"),AND:new X._Code("&&"),ADD:new X._Code("+")};var jt=class{optimizeNodes(){return this}optimizeNames(t,r){return this}},yu=class extends jt{constructor(t,r,n){super(),this.varKind=t,this.name=r,this.rhs=n}render({es5:t,_n:r}){let n=t?ut.varKinds.var:this.varKind,o=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${o};`+r}optimizeNames(t,r){if(t[this.name.str])return this.rhs&&(this.rhs=an(this.rhs,t,r)),this}get names(){return this.rhs instanceof X._CodeOrName?this.rhs.names:{}}},Ns=class extends jt{constructor(t,r,n){super(),this.lhs=t,this.rhs=r,this.sideEffects=n}render({_n:t}){return`${this.lhs} = ${this.rhs};`+t}optimizeNames(t,r){if(!(this.lhs instanceof X.Name&&!t[this.lhs.str]&&!this.sideEffects))return this.rhs=an(this.rhs,t,r),this}get names(){let t=this.lhs instanceof X.Name?{}:{...this.lhs.names};return Ds(t,this.rhs)}},_u=class extends Ns{constructor(t,r,n,o){super(t,n,o),this.op=r}render({_n:t}){return`${this.lhs} ${this.op}= ${this.rhs};`+t}},vu=class extends jt{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`${this.label}:`+t}},bu=class extends jt{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`break${this.label?` ${this.label}`:""};`+t}},wu=class extends jt{constructor(t){super(),this.error=t}render({_n:t}){return`throw ${this.error};`+t}get names(){return this.error.names}},ku=class extends jt{constructor(t){super(),this.code=t}render({_n:t}){return`${this.code};`+t}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(t,r){return this.code=an(this.code,t,r),this}get names(){return this.code instanceof X._CodeOrName?this.code.names:{}}},to=class extends jt{constructor(t=[]){super(),this.nodes=t}render(t){return this.nodes.reduce((r,n)=>r+n.render(t),"")}optimizeNodes(){let{nodes:t}=this,r=t.length;for(;r--;){let n=t[r].optimizeNodes();Array.isArray(n)?t.splice(r,1,...n):n?t[r]=n:t.splice(r,1)}return t.length>0?this:void 0}optimizeNames(t,r){let{nodes:n}=this,o=n.length;for(;o--;){let s=n[o];s.optimizeNames(t,r)||(h0(t,s.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((t,r)=>Ir(t,r.names),{})}},Ct=class extends to{render(t){return"{"+t._n+super.render(t)+"}"+t._n}},xu=class extends to{},sn=class extends Ct{};sn.kind="else";var Tr=class e extends Ct{constructor(t,r){super(r),this.condition=t}render(t){let r=`if(${this.condition})`+super.render(t);return this.else&&(r+="else "+this.else.render(t)),r}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new sn(n):n}if(r)return t===!1?r instanceof e?r:r.nodes:this.nodes.length?this:new e(Lf(t),r instanceof e?[r]:r.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(t,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(t,r),!!(super.optimizeNames(t,r)||this.else))return this.condition=an(this.condition,t,r),this}get names(){let t=super.names;return Ds(t,this.condition),this.else&&Ir(t,this.else.names),t}};Tr.kind="if";var Rr=class extends Ct{};Rr.kind="for";var Su=class extends Rr{constructor(t){super(),this.iteration=t}render(t){return`for(${this.iteration})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iteration=an(this.iteration,t,r),this}get names(){return Ir(super.names,this.iteration.names)}},$u=class extends Rr{constructor(t,r,n,o){super(),this.varKind=t,this.name=r,this.from=n,this.to=o}render(t){let r=t.es5?ut.varKinds.var:this.varKind,{name:n,from:o,to:s}=this;return`for(${r} ${n}=${o}; ${n}<${s}; ${n}++)`+super.render(t)}get names(){let t=Ds(super.names,this.from);return Ds(t,this.to)}},Ls=class extends Rr{constructor(t,r,n,o){super(),this.loop=t,this.varKind=r,this.name=n,this.iterable=o}render(t){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iterable=an(this.iterable,t,r),this}get names(){return Ir(super.names,this.iterable.names)}},ro=class extends Ct{constructor(t,r,n){super(),this.name=t,this.args=r,this.async=n}render(t){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(t)}};ro.kind="func";var no=class extends to{render(t){return"return "+super.render(t)}};no.kind="return";var zu=class extends Ct{render(t){let r="try"+super.render(t);return this.catch&&(r+=this.catch.render(t)),this.finally&&(r+=this.finally.render(t)),r}optimizeNodes(){var t,r;return super.optimizeNodes(),(t=this.catch)===null||t===void 0||t.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(t,r){var n,o;return super.optimizeNames(t,r),(n=this.catch)===null||n===void 0||n.optimizeNames(t,r),(o=this.finally)===null||o===void 0||o.optimizeNames(t,r),this}get names(){let t=super.names;return this.catch&&Ir(t,this.catch.names),this.finally&&Ir(t,this.finally.names),t}},oo=class extends Ct{constructor(t){super(),this.error=t}render(t){return`catch(${this.error})`+super.render(t)}};oo.kind="catch";var so=class extends Ct{render(t){return"finally"+super.render(t)}};so.kind="finally";var Pu=class{constructor(t,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
4
4
|
`:""},this._extScope=t,this._scope=new ut.Scope({parent:t}),this._nodes=[new xu]}toString(){return this._root.render(this.opts)}name(t){return this._scope.name(t)}scopeName(t){return this._extScope.name(t)}scopeValue(t,r){let n=this._extScope.value(t,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(t,r){return this._extScope.getValue(t,r)}scopeRefs(t){return this._extScope.scopeRefs(t,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(t,r,n,o){let s=this._scope.toName(r);return n!==void 0&&o&&(this._constants[s.str]=n),this._leafNode(new yu(t,s,n)),s}const(t,r,n){return this._def(ut.varKinds.const,t,r,n)}let(t,r,n){return this._def(ut.varKinds.let,t,r,n)}var(t,r,n){return this._def(ut.varKinds.var,t,r,n)}assign(t,r,n){return this._leafNode(new Ns(t,r,n))}add(t,r){return this._leafNode(new _u(t,V.operators.ADD,r))}code(t){return typeof t=="function"?t():t!==X.nil&&this._leafNode(new ku(t)),this}object(...t){let r=["{"];for(let[n,o]of t)r.length>1&&r.push(","),r.push(n),(n!==o||this.opts.es5)&&(r.push(":"),(0,X.addCodeArg)(r,o));return r.push("}"),new X._Code(r)}if(t,r,n){if(this._blockNode(new Tr(t)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(t){return this._elseNode(new Tr(t))}else(){return this._elseNode(new sn)}endIf(){return this._endBlockNode(Tr,sn)}_for(t,r){return this._blockNode(t),r&&this.code(r).endFor(),this}for(t,r){return this._for(new Su(t),r)}forRange(t,r,n,o,s=this.opts.es5?ut.varKinds.var:ut.varKinds.let){let i=this._scope.toName(t);return this._for(new $u(s,i,r,n),()=>o(i))}forOf(t,r,n,o=ut.varKinds.const){let s=this._scope.toName(t);if(this.opts.es5){let i=r instanceof X.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,X._)`${i}.length`,a=>{this.var(s,(0,X._)`${i}[${a}]`),n(s)})}return this._for(new Ls("of",o,s,r),()=>n(s))}forIn(t,r,n,o=this.opts.es5?ut.varKinds.var:ut.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0,X._)`Object.keys(${r})`,n);let s=this._scope.toName(t);return this._for(new Ls("in",o,s,r),()=>n(s))}endFor(){return this._endBlockNode(Rr)}label(t){return this._leafNode(new vu(t))}break(t){return this._leafNode(new bu(t))}return(t){let r=new no;if(this._blockNode(r),this.code(t),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(no)}try(t,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new zu;if(this._blockNode(o),this.code(t),r){let s=this.name("e");this._currNode=o.catch=new oo(s),r(s)}return n&&(this._currNode=o.finally=new so,this.code(n)),this._endBlockNode(oo,so)}throw(t){return this._leafNode(new wu(t))}block(t,r){return this._blockStarts.push(this._nodes.length),t&&this.code(t).endBlock(r),this}endBlock(t){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||t!==void 0&&n!==t)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${t} expected`);return this._nodes.length=r,this}func(t,r=X.nil,n,o){return this._blockNode(new ro(t,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(ro)}optimize(t=1){for(;t-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(t){return this._currNode.nodes.push(t),this}_blockNode(t){this._currNode.nodes.push(t),this._nodes.push(t)}_endBlockNode(t,r){let n=this._currNode;if(n instanceof t||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${t.kind}/${r.kind}`:t.kind}"`)}_elseNode(t){let r=this._currNode;if(!(r instanceof Tr))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=t,this}get _root(){return this._nodes[0]}get _currNode(){let t=this._nodes;return t[t.length-1]}set _currNode(t){let r=this._nodes;r[r.length-1]=t}};V.CodeGen=Pu;function Ir(e,t){for(let r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function Ds(e,t){return t instanceof X._CodeOrName?Ir(e,t.names):e}function an(e,t,r){if(e instanceof X.Name)return n(e);if(!o(e))return e;return new X._Code(e._items.reduce((s,i)=>(i instanceof X.Name&&(i=n(i)),i instanceof X._Code?s.push(...i._items):s.push(i),s),[]));function n(s){let i=r[s.str];return i===void 0||t[s.str]!==1?s:(delete t[s.str],i)}function o(s){return s instanceof X._Code&&s._items.some(i=>i instanceof X.Name&&t[i.str]===1&&r[i.str]!==void 0)}}function h0(e,t){for(let r in t)e[r]=(e[r]||0)-(t[r]||0)}function Lf(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0,X._)`!${Tu(e)}`}V.not=Lf;var g0=Df(V.operators.AND);function y0(...e){return e.reduce(g0)}V.and=y0;var _0=Df(V.operators.OR);function v0(...e){return e.reduce(_0)}V.or=v0;function Df(e){return(t,r)=>t===X.nil?r:r===X.nil?t:(0,X._)`${Tu(t)} ${e} ${Tu(r)}`}function Tu(e){return e instanceof X.Name?e:(0,X._)`(${e})`}});var ee=z(B=>{"use strict";Object.defineProperty(B,"__esModule",{value:!0});B.checkStrictMode=B.getErrorPath=B.Type=B.useFunc=B.setEvaluated=B.evaluatedPropsToName=B.mergeEvaluated=B.eachItem=B.unescapeJsonPointer=B.escapeJsonPointer=B.escapeFragment=B.unescapeFragment=B.schemaRefOrVal=B.schemaHasRulesButRef=B.schemaHasRules=B.checkUnknownRules=B.alwaysValidSchema=B.toHash=void 0;var se=F(),b0=eo();function w0(e){let t={};for(let r of e)t[r]=!0;return t}B.toHash=w0;function k0(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(qf(e,t),!Jf(t,e.self.RULES.all))}B.alwaysValidSchema=k0;function qf(e,t=e.schema){let{opts:r,self:n}=e;if(!r.strictSchema||typeof t=="boolean")return;let o=n.RULES.keywords;for(let s in t)o[s]||Bf(e,`unknown keyword: "${s}"`)}B.checkUnknownRules=qf;function Jf(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(t[r])return!0;return!1}B.schemaHasRules=Jf;function x0(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}B.schemaHasRulesButRef=x0;function S0({topSchemaRef:e,schemaPath:t},r,n,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,se._)`${r}`}return(0,se._)`${e}${t}${(0,se.getProperty)(n)}`}B.schemaRefOrVal=S0;function $0(e){return Ff(decodeURIComponent(e))}B.unescapeFragment=$0;function z0(e){return encodeURIComponent(Iu(e))}B.escapeFragment=z0;function Iu(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}B.escapeJsonPointer=Iu;function Ff(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}B.unescapeJsonPointer=Ff;function P0(e,t){if(Array.isArray(e))for(let r of e)t(r);else t(e)}B.eachItem=P0;function Zf({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(o,s,i,a)=>{let c=i===void 0?s:i instanceof se.Name?(s instanceof se.Name?e(o,s,i):t(o,s,i),i):s instanceof se.Name?(t(o,i,s),s):r(s,i);return a===se.Name&&!(c instanceof se.Name)?n(o,c):c}}B.mergeEvaluated={props:Zf({mergeNames:(e,t,r)=>e.if((0,se._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,se._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,se._)`${r} || {}`).code((0,se._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,se._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,se._)`${r} || {}`),Eu(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:Vf}),items:Zf({mergeNames:(e,t,r)=>e.if((0,se._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,se._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,se._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,se._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function Vf(e,t){if(t===!0)return e.var("props",!0);let r=e.var("props",(0,se._)`{}`);return t!==void 0&&Eu(e,r,t),r}B.evaluatedPropsToName=Vf;function Eu(e,t,r){Object.keys(r).forEach(n=>e.assign((0,se._)`${t}${(0,se.getProperty)(n)}`,!0))}B.setEvaluated=Eu;var Uf={};function T0(e,t){return e.scopeValue("func",{ref:t,code:Uf[t.code]||(Uf[t.code]=new b0._Code(t.code))})}B.useFunc=T0;var Ru;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(Ru||(B.Type=Ru={}));function R0(e,t,r){if(e instanceof se.Name){let n=t===Ru.Num;return r?n?(0,se._)`"[" + ${e} + "]"`:(0,se._)`"['" + ${e} + "']"`:n?(0,se._)`"/" + ${e}`:(0,se._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,se.getProperty)(e).toString():"/"+Iu(e)}B.getErrorPath=R0;function Bf(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}B.checkStrictMode=Bf});var At=z(Ou=>{"use strict";Object.defineProperty(Ou,"__esModule",{value:!0});var Re=F(),I0={data:new Re.Name("data"),valCxt:new Re.Name("valCxt"),instancePath:new Re.Name("instancePath"),parentData:new Re.Name("parentData"),parentDataProperty:new Re.Name("parentDataProperty"),rootData:new Re.Name("rootData"),dynamicAnchors:new Re.Name("dynamicAnchors"),vErrors:new Re.Name("vErrors"),errors:new Re.Name("errors"),this:new Re.Name("this"),self:new Re.Name("self"),scope:new Re.Name("scope"),json:new Re.Name("json"),jsonPos:new Re.Name("jsonPos"),jsonLen:new Re.Name("jsonLen"),jsonPart:new Re.Name("jsonPart")};Ou.default=I0});var io=z(Ie=>{"use strict";Object.defineProperty(Ie,"__esModule",{value:!0});Ie.extendErrors=Ie.resetErrorsCount=Ie.reportExtraError=Ie.reportError=Ie.keyword$DataError=Ie.keywordError=void 0;var Y=F(),Us=ee(),Ae=At();Ie.keywordError={message:({keyword:e})=>(0,Y.str)`must pass "${e}" keyword validation`};Ie.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0,Y.str)`"${e}" keyword must be ${t} ($data)`:(0,Y.str)`"${e}" keyword is invalid ($data)`};function E0(e,t=Ie.keywordError,r,n){let{it:o}=e,{gen:s,compositeRule:i,allErrors:a}=o,c=Kf(e,t,r);n??(i||a)?Hf(s,c):Wf(o,(0,Y._)`[${c}]`)}Ie.reportError=E0;function O0(e,t=Ie.keywordError,r){let{it:n}=e,{gen:o,compositeRule:s,allErrors:i}=n,a=Kf(e,t,r);Hf(o,a),s||i||Wf(n,Ae.default.vErrors)}Ie.reportExtraError=O0;function j0(e,t){e.assign(Ae.default.errors,t),e.if((0,Y._)`${Ae.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0,Y._)`${Ae.default.vErrors}.length`,t),()=>e.assign(Ae.default.vErrors,null)))}Ie.resetErrorsCount=j0;function C0({gen:e,keyword:t,schemaValue:r,data:n,errsCount:o,it:s}){if(o===void 0)throw new Error("ajv implementation error");let i=e.name("err");e.forRange("i",o,Ae.default.errors,a=>{e.const(i,(0,Y._)`${Ae.default.vErrors}[${a}]`),e.if((0,Y._)`${i}.instancePath === undefined`,()=>e.assign((0,Y._)`${i}.instancePath`,(0,Y.strConcat)(Ae.default.instancePath,s.errorPath))),e.assign((0,Y._)`${i}.schemaPath`,(0,Y.str)`${s.errSchemaPath}/${t}`),s.opts.verbose&&(e.assign((0,Y._)`${i}.schema`,r),e.assign((0,Y._)`${i}.data`,n))})}Ie.extendErrors=C0;function Hf(e,t){let r=e.const("err",t);e.if((0,Y._)`${Ae.default.vErrors} === null`,()=>e.assign(Ae.default.vErrors,(0,Y._)`[${r}]`),(0,Y._)`${Ae.default.vErrors}.push(${r})`),e.code((0,Y._)`${Ae.default.errors}++`)}function Wf(e,t){let{gen:r,validateName:n,schemaEnv:o}=e;o.$async?r.throw((0,Y._)`new ${e.ValidationError}(${t})`):(r.assign((0,Y._)`${n}.errors`,t),r.return(!1))}var Er={keyword:new Y.Name("keyword"),schemaPath:new Y.Name("schemaPath"),params:new Y.Name("params"),propertyName:new Y.Name("propertyName"),message:new Y.Name("message"),schema:new Y.Name("schema"),parentSchema:new Y.Name("parentSchema")};function Kf(e,t,r){let{createErrors:n}=e.it;return n===!1?(0,Y._)`{}`:A0(e,t,r)}function A0(e,t,r={}){let{gen:n,it:o}=e,s=[M0(o,r),N0(e,r)];return L0(e,t,s),n.object(...s)}function M0({errorPath:e},{instancePath:t}){let r=t?(0,Y.str)`${e}${(0,Us.getErrorPath)(t,Us.Type.Str)}`:e;return[Ae.default.instancePath,(0,Y.strConcat)(Ae.default.instancePath,r)]}function N0({keyword:e,it:{errSchemaPath:t}},{schemaPath:r,parentSchema:n}){let o=n?t:(0,Y.str)`${t}/${e}`;return r&&(o=(0,Y.str)`${o}${(0,Us.getErrorPath)(r,Us.Type.Str)}`),[Er.schemaPath,o]}function L0(e,{params:t,message:r},n){let{keyword:o,data:s,schemaValue:i,it:a}=e,{opts:c,propertyName:u,topSchemaRef:d,schemaPath:l}=a;n.push([Er.keyword,o],[Er.params,typeof t=="function"?t(e):t||(0,Y._)`{}`]),c.messages&&n.push([Er.message,typeof r=="function"?r(e):r]),c.verbose&&n.push([Er.schema,i],[Er.parentSchema,(0,Y._)`${d}${l}`],[Ae.default.data,s]),u&&n.push([Er.propertyName,u])}});var Xf=z(cn=>{"use strict";Object.defineProperty(cn,"__esModule",{value:!0});cn.boolOrEmptySchema=cn.topBoolOrEmptySchema=void 0;var D0=io(),Z0=F(),U0=At(),q0={message:"boolean schema is false"};function J0(e){let{gen:t,schema:r,validateName:n}=e;r===!1?Gf(e,!1):typeof r=="object"&&r.$async===!0?t.return(U0.default.data):(t.assign((0,Z0._)`${n}.errors`,null),t.return(!0))}cn.topBoolOrEmptySchema=J0;function F0(e,t){let{gen:r,schema:n}=e;n===!1?(r.var(t,!1),Gf(e)):r.var(t,!0)}cn.boolOrEmptySchema=F0;function Gf(e,t){let{gen:r,data:n}=e,o={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,D0.reportError)(o,q0,void 0,t)}});var ju=z(un=>{"use strict";Object.defineProperty(un,"__esModule",{value:!0});un.getRules=un.isJSONType=void 0;var V0=["string","number","integer","boolean","null","object","array"],B0=new Set(V0);function H0(e){return typeof e=="string"&&B0.has(e)}un.isJSONType=H0;function W0(){let e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}un.getRules=W0});var Cu=z(Gt=>{"use strict";Object.defineProperty(Gt,"__esModule",{value:!0});Gt.shouldUseRule=Gt.shouldUseGroup=Gt.schemaHasRulesForType=void 0;function K0({schema:e,self:t},r){let n=t.RULES.types[r];return n&&n!==!0&&Yf(e,n)}Gt.schemaHasRulesForType=K0;function Yf(e,t){return t.rules.some(r=>Qf(e,r))}Gt.shouldUseGroup=Yf;function Qf(e,t){var r;return e[t.keyword]!==void 0||((r=t.definition.implements)===null||r===void 0?void 0:r.some(n=>e[n]!==void 0))}Gt.shouldUseRule=Qf});var ao=z(Ee=>{"use strict";Object.defineProperty(Ee,"__esModule",{value:!0});Ee.reportTypeError=Ee.checkDataTypes=Ee.checkDataType=Ee.coerceAndCheckDataType=Ee.getJSONTypes=Ee.getSchemaTypes=Ee.DataType=void 0;var G0=ju(),X0=Cu(),Y0=io(),q=F(),eh=ee(),dn;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(dn||(Ee.DataType=dn={}));function Q0(e){let t=th(e.type);if(t.includes("null")){if(e.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===!0&&t.push("null")}return t}Ee.getSchemaTypes=Q0;function th(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(G0.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}Ee.getJSONTypes=th;function eS(e,t){let{gen:r,data:n,opts:o}=e,s=tS(t,o.coerceTypes),i=t.length>0&&!(s.length===0&&t.length===1&&(0,X0.schemaHasRulesForType)(e,t[0]));if(i){let a=Mu(t,n,o.strictNumbers,dn.Wrong);r.if(a,()=>{s.length?rS(e,t,s):Nu(e)})}return i}Ee.coerceAndCheckDataType=eS;var rh=new Set(["string","number","integer","boolean","null"]);function tS(e,t){return t?e.filter(r=>rh.has(r)||t==="array"&&r==="array"):[]}function rS(e,t,r){let{gen:n,data:o,opts:s}=e,i=n.let("dataType",(0,q._)`typeof ${o}`),a=n.let("coerced",(0,q._)`undefined`);s.coerceTypes==="array"&&n.if((0,q._)`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,(0,q._)`${o}[0]`).assign(i,(0,q._)`typeof ${o}`).if(Mu(t,o,s.strictNumbers),()=>n.assign(a,o))),n.if((0,q._)`${a} !== undefined`);for(let u of r)(rh.has(u)||u==="array"&&s.coerceTypes==="array")&&c(u);n.else(),Nu(e),n.endIf(),n.if((0,q._)`${a} !== undefined`,()=>{n.assign(o,a),nS(e,a)});function c(u){switch(u){case"string":n.elseIf((0,q._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,q._)`"" + ${o}`).elseIf((0,q._)`${o} === null`).assign(a,(0,q._)`""`);return;case"number":n.elseIf((0,q._)`${i} == "boolean" || ${o} === null
|
|
5
5
|
|| (${i} == "string" && ${o} && ${o} == +${o})`).assign(a,(0,q._)`+${o}`);return;case"integer":n.elseIf((0,q._)`${i} === "boolean" || ${o} === null
|
package/package.json
CHANGED
package/scripts/build.mjs
CHANGED
|
@@ -17,8 +17,18 @@ const packageVersion = JSON.parse(
|
|
|
17
17
|
|
|
18
18
|
await rm(join(packageRoot, 'dist'), { recursive: true, force: true });
|
|
19
19
|
|
|
20
|
+
// Renamed banner import (the build-auth-parity-oracle.mjs convention, made
|
|
21
|
+
// load-bearing by prod RCA 2026-07-20): esbuild injects banners VERBATIM -
|
|
22
|
+
// outside symbol renaming - so a bare `createRequire` here collides with any
|
|
23
|
+
// source module's own top-level `import { createRequire } from 'node:module'`
|
|
24
|
+
// (bundledCodexBin.ts) and the bundle dies at load with "Identifier
|
|
25
|
+
// 'createRequire' has already been declared". These bundles are currently
|
|
26
|
+
// minified (which renames the source-side binding and masks the collision),
|
|
27
|
+
// but the identically-bannered UNMINIFIED nix image bundles shipped exactly
|
|
28
|
+
// that SyntaxError on 2026-07-11 and crash-looped the hosted @linzumi runner
|
|
29
|
+
// for 9 days. Keep the banner symbol collision-proof, never rely on minify.
|
|
20
30
|
const banner = {
|
|
21
|
-
js: "import { createRequire } from 'node:module';\nconst require =
|
|
31
|
+
js: "import { createRequire as __linzumiBundleCreateRequire } from 'node:module';\nconst require = __linzumiBundleCreateRequire(import.meta.url);",
|
|
22
32
|
};
|
|
23
33
|
|
|
24
34
|
// M3 cluster 15 (entry/packaging/selector): ONE package ships BOTH commander
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
// 1. pnpm bump-version <new-version> (for example: 1.2.3-beta)
|
|
9
9
|
// 2. Run the test suite: pnpm vitest run --config vitest.config.mjs
|
|
10
10
|
// 3. Commit with a "[deploy-commander]" title and merge to main (the
|
|
11
|
-
// deprecated "[deploy-cli]" marker
|
|
12
|
-
//
|
|
11
|
+
// deprecated "[deploy-cli]" marker was retired in the N3.9 window on
|
|
12
|
+
// 2026-07-20 and is now loudly inert - naming program).
|
|
13
13
|
// 4. The main publish workflow (.github/workflows/linzumi-cli-publish.yml)
|
|
14
14
|
// publishes @linzumi/cli@<new-version> to npm.
|
|
15
15
|
//
|