coze-bridge 0.2.7-alpha.102 → 0.2.7-alpha.103
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/dist/index.js +92 -92
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5,34 +5,34 @@ import { dirname as __coze_dirname } from 'node:path';
|
|
|
5
5
|
const require = __coze_createRequire(import.meta.url);
|
|
6
6
|
const __filename = __coze_fileURLToPath(import.meta.url);
|
|
7
7
|
const __dirname = __coze_dirname(__filename);
|
|
8
|
-
var
|
|
9
|
-
`)),this.stream=
|
|
10
|
-
`),this.stream=void 0;return}this.currentDate!==void 0&&
|
|
11
|
-
`;
|
|
12
|
-
`;if(gs){let d=
|
|
13
|
-
`),{cause:o})}}async function
|
|
14
|
-
`,r)}var qt=nt(()=>{"use strict"});import{promises as Hl,readdirSync as vg}from"node:fs";import{homedir as Sg}from"node:os";import{sep as Ig,join as Te,resolve as ql}from"node:path";function J(t){let e=t??Sg(),r=Te(e,".coze"),i=Te(r,"bridge"),o=Te(i,"lib"),c=Te(i,"logs");return{cozeRoot:r,bridgeRoot:i,libDir:o,libEntry:Te(o,"index.js"),binDir:Te(i,"bin"),pidFile:Te(i,"bridge.pid"),portFile:Te(i,"bridge.port"),tokenFile:Te(i,"bridge.token"),patTokenFile:Te(i,"pat-token"),agentEnvFile:Te(i,"agent-env.json"),logFile:Te(i,"bridge.log"),bridgeLogsDir:c,daemonStdioLog:Te(c,"daemon-stdio.log"),installLock:Te(i,"install.lock"),configFile:Te(i,"config.json"),agentsRoot:Te(r,"agents")}}function Fe(t,e=J()){let r=Te(e.agentsRoot,t);return{root:r,config:Te(r,"config.json"),workspace:Te(r,"workspace"),logs:Te(r,"logs")}}function Es(t=J()){try{return vg(t.agentsRoot,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name)}catch{return[]}}async function si(t,e){let r=await Hl.realpath(ql(t)).catch(()=>null);if(!r)return!1;let i=await Hl.realpath(ql(e)).catch(()=>null);if(!i)return!1;let o=process.platform==="win32"?r.toLowerCase():r,c=process.platform==="win32"?i.toLowerCase():i;return o===c||o.startsWith(c+Ig)}var Re=nt(()=>{"use strict"});var vs={};Na(vs,{AGENT_CONFIG_FILE_MODE:()=>bs,enforceAgentConfigMode:()=>Tg,loadAgentConfig:()=>ve,persistAgentSessions:()=>oi,persistAgentSkills:()=>ai,saveAgentConfig:()=>ze});import{chmod as Ag,stat as kg}from"node:fs/promises";function ve(t,e){return lr(Fe(t,e).config)}function ze(t,e){return ur(Fe(t.agentId,e).config,t,{mode:bs})}async function Tg(t,e){if(process.platform==="win32")return;let r=Fe(t,e).config;try{let i=await kg(r);if(!i.isFile())return;let o=i.mode&511;o!==bs&&(await Ag(r,bs),jl.warn("agent config mode auto-corrected to 0600",{path:r,from:o.toString(8)}))}catch(i){if(i.code==="ENOENT")return;jl.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:r,err:String(i)})}}async function oi(t,e,r){let i=await ve(t,r);i&&(i.sessions=Object.fromEntries(e),await ze(i,r))}async function ai(t,e,r){let i=await ve(t,r);i&&(i.skills=e,await ze(i,r))}var jl,bs,jt=nt(()=>{"use strict";qt();te();Re();jl=G("agent-config"),bs=384});var ja=ae((II,$l)=>{$l.exports={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,END64HDR:20,END64SIG:117853008,END64START:4,END64OFF:8,END64NUMDISKS:16,ZIP64SIG:101075792,ZIP64HDR:56,ZIP64LEAD:12,ZIP64SIZE:4,ZIP64VEM:12,ZIP64VER:14,ZIP64DSK:16,ZIP64DSKDIR:20,ZIP64SUB:24,ZIP64TOT:32,ZIP64SIZB:40,ZIP64OFF:48,ZIP64EXTRA:56,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,AES_ENCRYPT:99,FLG_ENC:1,FLG_COMP1:2,FLG_COMP2:4,FLG_DESC:8,FLG_ENH:16,FLG_PATCH:32,FLG_STR:64,FLG_EFS:2048,FLG_MSK:4096,FILE:2,BUFFER:1,NONE:0,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24}});var Is=ae(Vl=>{var Yl={INVALID_LOC:"Invalid LOC header (bad signature)",INVALID_CEN:"Invalid CEN header (bad signature)",INVALID_END:"Invalid END header (bad signature)",DESCRIPTOR_NOT_EXIST:"No descriptor present",DESCRIPTOR_UNKNOWN:"Unknown descriptor format",DESCRIPTOR_FAULTY:"Descriptor data is malformed",NO_DATA:"Nothing to decompress",BAD_CRC:"CRC32 checksum failed {0}",FILE_IN_THE_WAY:"There is a file in the way: {0}",UNKNOWN_METHOD:"Invalid/unsupported compression method",AVAIL_DATA:"inflate::Available inflate data did not terminate",INVALID_DISTANCE:"inflate::Invalid literal/length or distance code in fixed or dynamic block",TO_MANY_CODES:"inflate::Dynamic block code description: too many length or distance codes",INVALID_REPEAT_LEN:"inflate::Dynamic block code description: repeat more than specified lengths",INVALID_REPEAT_FIRST:"inflate::Dynamic block code description: repeat lengths with no first length",INCOMPLETE_CODES:"inflate::Dynamic block code description: code lengths codes incomplete",INVALID_DYN_DISTANCE:"inflate::Dynamic block code description: invalid distance code lengths",INVALID_CODES_LEN:"inflate::Dynamic block code description: invalid literal/length code lengths",INVALID_STORE_BLOCK:"inflate::Stored block length did not match one's complement",INVALID_BLOCK_TYPE:"inflate::Invalid block type (type == 3)",CANT_EXTRACT_FILE:"Could not extract the file",CANT_OVERRIDE:"Target file already exists",DISK_ENTRY_TOO_LARGE:"Number of disk entries is too large",NO_ZIP:"No zip file was loaded",NO_ENTRY:"Entry doesn't exist",DIRECTORY_CONTENT_ERROR:"A directory cannot have content",FILE_NOT_FOUND:'File not found: "{0}"',NOT_IMPLEMENTED:"Not implemented",INVALID_FILENAME:"Invalid filename",INVALID_FORMAT:"Invalid or unsupported zip format. No END header found",INVALID_PASS_PARAM:"Incompatible password parameter",WRONG_PASSWORD:"Wrong Password",COMMENT_TOO_LONG:"Comment is too long",EXTRA_FIELD_PARSE_ERROR:"Extra field parsing error"};function Lg(t){return function(...e){return e.length&&(t=t.replace(/\{(\d)\}/g,(r,i)=>e[i]||"")),new Error("ADM-ZIP: "+t)}}for(let t of Object.keys(Yl))Vl[t]=Lg(Yl[t])});var eu=ae((kI,Ql)=>{var Ng=fe("fs"),Ne=fe("path"),Jl=ja(),Mg=Is(),Bg=typeof process=="object"&&process.platform==="win32",Zl=t=>typeof t=="object"&&t!==null,Xl=new Uint32Array(256).map((t,e)=>{for(let r=0;r<8;r++)(e&1)!==0?e=3988292384^e>>>1:e>>>=1;return e>>>0});function Se(t){this.sep=Ne.sep,this.fs=Ng,Zl(t)&&Zl(t.fs)&&typeof t.fs.statSync=="function"&&(this.fs=t.fs)}Ql.exports=Se;Se.prototype.makeDir=function(t){let e=this;function r(i){let o=i.split(e.sep)[0];i.split(e.sep).forEach(function(c){if(!(!c||c.substr(-1,1)===":")){o+=e.sep+c;var d;try{d=e.fs.statSync(o)}catch(u){if(u.message&&u.message.startsWith("ENOENT"))e.fs.mkdirSync(o);else throw u}if(d&&d.isFile())throw Mg.FILE_IN_THE_WAY(`"${o}"`)}})}r(t)};Se.prototype.writeFileTo=function(t,e,r,i){let o=this;if(o.fs.existsSync(t)){if(!r)return!1;var c=o.fs.statSync(t);if(c.isDirectory())return!1}var d=Ne.dirname(t);o.fs.existsSync(d)||o.makeDir(d);var u;try{u=o.fs.openSync(t,"w",438)}catch{o.fs.chmodSync(t,438),u=o.fs.openSync(t,"w",438)}if(u)try{o.fs.writeSync(u,e,0,e.length,0)}finally{o.fs.closeSync(u)}return o.fs.chmodSync(t,i||438),!0};Se.prototype.writeFileToAsync=function(t,e,r,i,o){typeof i=="function"&&(o=i,i=void 0);let c=this;c.fs.exists(t,function(d){if(d&&!r)return o(!1);c.fs.stat(t,function(u,f){if(d&&f.isDirectory())return o(!1);var x=Ne.dirname(t);c.fs.exists(x,function(g){g||c.makeDir(x),c.fs.open(t,"w",438,function(w,S){w?c.fs.chmod(t,438,function(){c.fs.open(t,"w",438,function(y,v){c.fs.write(v,e,0,e.length,0,function(){c.fs.close(v,function(){c.fs.chmod(t,i||438,function(){o(!0)})})})})}):S?c.fs.write(S,e,0,e.length,0,function(){c.fs.close(S,function(){c.fs.chmod(t,i||438,function(){o(!0)})})}):c.fs.chmod(t,i||438,function(){o(!0)})})})})})};Se.prototype.findFiles=function(t){let e=this;function r(i,o,c){typeof o=="boolean"&&(c=o,o=void 0);let d=[];return e.fs.readdirSync(i).forEach(function(u){let f=Ne.join(i,u),x=e.fs.statSync(f);(!o||o.test(f))&&d.push(Ne.normalize(f)+(x.isDirectory()?e.sep:"")),x.isDirectory()&&c&&(d=d.concat(r(f,o,c)))}),d}return r(t,void 0,!0)};Se.prototype.findFilesAsync=function(t,e){let r=this,i=[];r.fs.readdir(t,function(o,c){if(o)return e(o);let d=c.length;if(!d)return e(null,i);c.forEach(function(u){u=Ne.join(t,u),r.fs.stat(u,function(f,x){if(f)return e(f);x&&(i.push(Ne.normalize(u)+(x.isDirectory()?r.sep:"")),x.isDirectory()?r.findFilesAsync(u,function(g,w){if(g)return e(g);i=i.concat(w),--d||e(null,i)}):--d||e(null,i))})})})};Se.prototype.getAttributes=function(){};Se.prototype.setAttributes=function(){};Se.crc32update=function(t,e){return Xl[(t^e)&255]^t>>>8};Se.crc32=function(t){typeof t=="string"&&(t=Buffer.from(t,"utf8"));let e=t.length,r=-1;for(let i=0;i<e;)r=Se.crc32update(r,t[i++]);return~r>>>0};Se.methodToString=function(t){switch(t){case Jl.STORED:return"STORED ("+t+")";case Jl.DEFLATED:return"DEFLATED ("+t+")";default:return"UNSUPPORTED ("+t+")"}};Se.canonical=function(t){if(!t)return"";let e=Ne.posix.normalize("/"+t.split("\\").join("/"));return Ne.join(".",e)};Se.zipnamefix=function(t){if(!t)return"";let e=Ne.posix.normalize("/"+t.split("\\").join("/"));return Ne.posix.join(".",e)};Se.findLast=function(t,e){if(!Array.isArray(t))throw new TypeError("arr is not array");let r=t.length>>>0;for(let i=r-1;i>=0;i--)if(e(t[i],i,t))return t[i]};Se.sanitize=function(t,e){t=Ne.resolve(Ne.normalize(t));for(var r=e.split("/"),i=0,o=r.length;i<o;i++){var c=Ne.normalize(Ne.join(t,r.slice(i,o).join(Ne.sep)));if(c.indexOf(t)===0)return c}return Ne.normalize(Ne.join(t,Ne.basename(e)))};Se.toBuffer=function(e,r){return Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e):typeof e=="string"?r(e):Buffer.alloc(0)};Se.readBigUInt64LE=function(t,e){let r=t.readUInt32LE(e);return t.readUInt32LE(e+4)*4294967296+r};Se.fromDOS2Date=function(t){return new Date((t>>25&127)+1980,Math.max((t>>21&15)-1,0),Math.max(t>>16&31,1),t>>11&31,t>>5&63,(t&31)<<1)};Se.fromDate2DOS=function(t){let e=0,r=0;return t.getFullYear()>1979&&(e=(t.getFullYear()-1980&127)<<9|t.getMonth()+1<<5|t.getDate(),r=t.getHours()<<11|t.getMinutes()<<5|t.getSeconds()>>1),e<<16|r};Se.isWin=Bg;Se.crcTable=Xl});var nu=ae((TI,tu)=>{var Fg=fe("path");tu.exports=function(t,{fs:e}){var r=t||"",i=c(),o=null;function c(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}return r&&e.existsSync(r)?(o=e.statSync(r),i.directory=o.isDirectory(),i.mtime=o.mtime,i.atime=o.atime,i.executable=(73&o.mode)!==0,i.readonly=(128&o.mode)===0,i.hidden=Fg.basename(r)[0]==="."):console.warn("Invalid path: "+r),{get directory(){return i.directory},get readOnly(){return i.readonly},get hidden(){return i.hidden},get mtime(){return i.mtime},get atime(){return i.atime},get executable(){return i.executable},decodeAttributes:function(){},encodeAttributes:function(){},toJSON:function(){return{path:r,isDirectory:i.directory,isReadOnly:i.readonly,isHidden:i.hidden,isExecutable:i.executable,mTime:i.mtime,aTime:i.atime}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var iu=ae((RI,ru)=>{ru.exports={efs:!0,encode:t=>Buffer.from(t,"utf8"),decode:t=>t.toString("utf8")}});var xr=ae((CI,hr)=>{hr.exports=eu();hr.exports.Constants=ja();hr.exports.Errors=Is();hr.exports.FileAttr=nu();hr.exports.decoder=iu()});var ou=ae((PI,su)=>{var ln=xr(),U=ln.Constants;su.exports=function(){var t=20,e=10,r=0,i=0,o=0,c=0,d=0,u=0,f=0,x=0,g=0,w=0,S=0,y=0,v=0;t|=ln.isWin?2560:768,r|=U.FLG_EFS;let I={extraLen:0},A=b=>Math.max(0,b)>>>0,R=b=>Math.max(0,b)&65535,D=b=>Math.max(0,b)&255;return o=ln.fromDate2DOS(new Date),{get made(){return t},set made(b){t=b},get version(){return e},set version(b){e=b},get flags(){return r},set flags(b){r=b},get flags_efs(){return(r&U.FLG_EFS)>0},set flags_efs(b){b?r|=U.FLG_EFS:r&=~U.FLG_EFS},get flags_desc(){return(r&U.FLG_DESC)>0},set flags_desc(b){b?r|=U.FLG_DESC:r&=~U.FLG_DESC},get method(){return i},set method(b){switch(b){case U.STORED:this.version=10;case U.DEFLATED:default:this.version=20}i=b},get time(){return ln.fromDOS2Date(this.timeval)},set time(b){b=new Date(b),this.timeval=ln.fromDate2DOS(b)},get timeval(){return o},set timeval(b){o=A(b)},get timeHighByte(){return D(o>>>8)},get crc(){return c},set crc(b){c=A(b)},get compressedSize(){return d},set compressedSize(b){d=A(b)},get size(){return u},set size(b){u=A(b)},get fileNameLength(){return f},set fileNameLength(b){f=b},get extraLength(){return x},set extraLength(b){x=b},get extraLocalLength(){return I.extraLen},set extraLocalLength(b){I.extraLen=b},get commentLength(){return g},set commentLength(b){g=b},get diskNumStart(){return w},set diskNumStart(b){w=A(b)},get inAttr(){return S},set inAttr(b){S=A(b)},get attr(){return y},set attr(b){y=A(b)},get fileAttr(){return(y||0)>>16&4095},get offset(){return v},set offset(b){v=A(b)},get encrypted(){return(r&U.FLG_ENC)===U.FLG_ENC},get centralHeaderSize(){return U.CENHDR+f+x+g},get realDataOffset(){return v+U.LOCHDR+I.fnameLen+I.extraLen},get localHeader(){return I},loadLocalHeaderFromBinary:function(b){var P=b.slice(v,v+U.LOCHDR);if(P.readUInt32LE(0)!==U.LOCSIG)throw ln.Errors.INVALID_LOC();I.version=P.readUInt16LE(U.LOCVER),I.flags=P.readUInt16LE(U.LOCFLG),I.flags_desc=(I.flags&U.FLG_DESC)>0,I.method=P.readUInt16LE(U.LOCHOW),I.time=P.readUInt32LE(U.LOCTIM),I.crc=P.readUInt32LE(U.LOCCRC),I.compressedSize=P.readUInt32LE(U.LOCSIZ),I.size=P.readUInt32LE(U.LOCLEN),I.fnameLen=P.readUInt16LE(U.LOCNAM),I.extraLen=P.readUInt16LE(U.LOCEXT);let O=v+U.LOCHDR+I.fnameLen,B=O+I.extraLen;return b.slice(O,B)},loadFromBinary:function(b){if(b.length!==U.CENHDR||b.readUInt32LE(0)!==U.CENSIG)throw ln.Errors.INVALID_CEN();t=b.readUInt16LE(U.CENVEM),e=b.readUInt16LE(U.CENVER),r=b.readUInt16LE(U.CENFLG),i=b.readUInt16LE(U.CENHOW),o=b.readUInt32LE(U.CENTIM),c=b.readUInt32LE(U.CENCRC),d=b.readUInt32LE(U.CENSIZ),u=b.readUInt32LE(U.CENLEN),f=b.readUInt16LE(U.CENNAM),x=b.readUInt16LE(U.CENEXT),g=b.readUInt16LE(U.CENCOM),w=b.readUInt16LE(U.CENDSK),S=b.readUInt16LE(U.CENATT),y=b.readUInt32LE(U.CENATX),v=b.readUInt32LE(U.CENOFF)},localHeaderToBinary:function(){var b=Buffer.alloc(U.LOCHDR);return b.writeUInt32LE(U.LOCSIG,0),b.writeUInt16LE(e,U.LOCVER),b.writeUInt16LE(r,U.LOCFLG),b.writeUInt16LE(i,U.LOCHOW),b.writeUInt32LE(o,U.LOCTIM),b.writeUInt32LE(c,U.LOCCRC),b.writeUInt32LE(d,U.LOCSIZ),b.writeUInt32LE(u,U.LOCLEN),b.writeUInt16LE(f,U.LOCNAM),b.writeUInt16LE(I.extraLen,U.LOCEXT),b},centralHeaderToBinary:function(){var b=Buffer.alloc(U.CENHDR+f+x+g);return b.writeUInt32LE(U.CENSIG,0),b.writeUInt16LE(t,U.CENVEM),b.writeUInt16LE(e,U.CENVER),b.writeUInt16LE(r,U.CENFLG),b.writeUInt16LE(i,U.CENHOW),b.writeUInt32LE(o,U.CENTIM),b.writeUInt32LE(c,U.CENCRC),b.writeUInt32LE(d,U.CENSIZ),b.writeUInt32LE(u,U.CENLEN),b.writeUInt16LE(f,U.CENNAM),b.writeUInt16LE(x,U.CENEXT),b.writeUInt16LE(g,U.CENCOM),b.writeUInt16LE(w,U.CENDSK),b.writeUInt16LE(S,U.CENATT),b.writeUInt32LE(y,U.CENATX),b.writeUInt32LE(v,U.CENOFF),b},toJSON:function(){let b=function(P){return P+" bytes"};return{made:t,version:e,flags:r,method:ln.methodToString(i),time:this.time,crc:"0x"+c.toString(16).toUpperCase(),compressedSize:b(d),size:b(u),fileNameLength:b(f),extraLength:b(x),commentLength:b(g),diskNumStart:w,inAttr:S,attr:y,offset:v,centralHeaderSize:b(U.CENHDR+f+x+g)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var cu=ae((DI,au)=>{var pr=xr(),ye=pr.Constants;au.exports=function(){var t=0,e=0,r=0,i=0,o=0;return{get diskEntries(){return t},set diskEntries(c){t=e=c},get totalEntries(){return e},set totalEntries(c){e=t=c},get size(){return r},set size(c){r=c},get offset(){return i},set offset(c){i=c},get commentLength(){return o},set commentLength(c){o=c},get mainHeaderSize(){return ye.ENDHDR+o},loadFromBinary:function(c){if((c.length!==ye.ENDHDR||c.readUInt32LE(0)!==ye.ENDSIG)&&(c.length<ye.ZIP64HDR||c.readUInt32LE(0)!==ye.ZIP64SIG))throw pr.Errors.INVALID_END();c.readUInt32LE(0)===ye.ENDSIG?(t=c.readUInt16LE(ye.ENDSUB),e=c.readUInt16LE(ye.ENDTOT),r=c.readUInt32LE(ye.ENDSIZ),i=c.readUInt32LE(ye.ENDOFF),o=c.readUInt16LE(ye.ENDCOM)):(t=pr.readBigUInt64LE(c,ye.ZIP64SUB),e=pr.readBigUInt64LE(c,ye.ZIP64TOT),r=pr.readBigUInt64LE(c,ye.ZIP64SIZE),i=pr.readBigUInt64LE(c,ye.ZIP64OFF),o=0)},toBinary:function(){var c=Buffer.alloc(ye.ENDHDR+o);return c.writeUInt32LE(ye.ENDSIG,0),c.writeUInt32LE(0,4),c.writeUInt16LE(t,ye.ENDSUB),c.writeUInt16LE(e,ye.ENDTOT),c.writeUInt32LE(r,ye.ENDSIZ),c.writeUInt32LE(i,ye.ENDOFF),c.writeUInt16LE(o,ye.ENDCOM),c.fill(" ",ye.ENDHDR),c},toJSON:function(){let c=function(d,u){let f=d.toString(16).toUpperCase();for(;f.length<u;)f="0"+f;return"0x"+f};return{diskEntries:t,totalEntries:e,size:r+" bytes",offset:c(i,4),commentLength:o}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Ka=ae(Wa=>{Wa.EntryHeader=ou();Wa.MainHeader=cu()});var lu=ae((LI,du)=>{du.exports=function(t){var e=fe("zlib"),r={chunkSize:(parseInt(t.length/1024)+1)*1024};return{deflate:function(){return e.deflateRawSync(t,r)},deflateAsync:function(i){var o=e.createDeflateRaw(r),c=[],d=0;o.on("data",function(u){c.push(u),d+=u.length}),o.on("end",function(){var u=Buffer.alloc(d),f=0;u.fill(0);for(var x=0;x<c.length;x++){var g=c[x];g.copy(u,f),f+=g.length}i&&i(u)}),o.end(t)}}}});var fu=ae((NI,uu)=>{var zg=+(process.versions?process.versions.node:"").split(".")[0]||0;uu.exports=function(t,e){var r=fe("zlib");let i=zg>=15&&e>0?{maxOutputLength:e}:{};return{inflate:function(){return r.inflateRawSync(t,i)},inflateAsync:function(o){var c=r.createInflateRaw(i),d=[],u=0;c.on("data",function(f){d.push(f),u+=f.length}),c.on("end",function(){var f=Buffer.alloc(u),x=0;f.fill(0);for(var g=0;g<d.length;g++){var w=d[g];w.copy(f,x),x+=w.length}o&&o(f)}),c.end(t)}}}});var gu=ae((MI,mu)=>{"use strict";var{randomFillSync:hu}=fe("crypto"),Ug=Is(),Gg=new Uint32Array(256).map((t,e)=>{for(let r=0;r<8;r++)(e&1)!==0?e=e>>>1^3988292384:e>>>=1;return e>>>0}),pu=(t,e)=>Math.imul(t,e)>>>0,xu=(t,e)=>Gg[(t^e)&255]^t>>>8,ci=()=>typeof hu=="function"?hu(Buffer.alloc(12)):ci.node();ci.node=()=>{let t=Buffer.alloc(12),e=t.length;for(let r=0;r<e;r++)t[r]=Math.random()*256&255;return t};var As={genSalt:ci};function ks(t){let e=Buffer.isBuffer(t)?t:Buffer.from(t);this.keys=new Uint32Array([305419896,591751049,878082192]);for(let r=0;r<e.length;r++)this.updateKeys(e[r])}ks.prototype.updateKeys=function(t){let e=this.keys;return e[0]=xu(e[0],t),e[1]+=e[0]&255,e[1]=pu(e[1],134775813)+1,e[2]=xu(e[2],e[1]>>>24),t};ks.prototype.next=function(){let t=(this.keys[2]|2)>>>0;return pu(t,t^1)>>8&255};function Hg(t){let e=new ks(t);return function(r){let i=Buffer.alloc(r.length),o=0;for(let c of r)i[o++]=e.updateKeys(c^e.next());return i}}function qg(t){let e=new ks(t);return function(r,i,o=0){i||(i=Buffer.alloc(r.length));for(let c of r){let d=e.next();i[o++]=c^d,e.updateKeys(c)}return i}}function jg(t,e,r){if(!t||!Buffer.isBuffer(t)||t.length<12)return Buffer.alloc(0);let i=Hg(r),o=i(t.slice(0,12)),c=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(o[11]!==c)throw Ug.WRONG_PASSWORD();return i(t.slice(12))}function Wg(t){Buffer.isBuffer(t)&&t.length>=12?As.genSalt=function(){return t.slice(0,12)}:t==="node"?As.genSalt=ci.node:As.genSalt=ci}function Kg(t,e,r,i=!1){t==null&&(t=Buffer.alloc(0)),Buffer.isBuffer(t)||(t=Buffer.from(t.toString()));let o=qg(r),c=As.genSalt();c[11]=e.crc>>>24&255,i&&(c[10]=e.crc>>>16&255);let d=Buffer.alloc(t.length+12);return o(c,d),o(t,d,12)}mu.exports={decrypt:jg,encrypt:Kg,_salter:Wg}});var wu=ae(Ts=>{Ts.Deflater=lu();Ts.Inflater=fu();Ts.ZipCrypto=gu()});var Ya=ae((FI,_u)=>{var ce=xr(),$g=Ka(),Ie=ce.Constants,$a=wu();_u.exports=function(t,e){var r=new $g.EntryHeader,i=Buffer.alloc(0),o=Buffer.alloc(0),c=!1,d=null,u=Buffer.alloc(0),f=Buffer.alloc(0),x=!0;let g=t,w=typeof g.decoder=="object"?g.decoder:ce.decoder;x=w.hasOwnProperty("efs")?w.efs:!1;function S(){return!e||!(e instanceof Uint8Array)?Buffer.alloc(0):(f=r.loadLocalHeaderFromBinary(e),e.slice(r.realDataOffset,r.realDataOffset+r.compressedSize))}function y(b){if(!r.flags_desc&&!r.localHeader.flags_desc){if(ce.crc32(b)!==r.localHeader.crc)return!1}else{let P={},O=r.realDataOffset+r.compressedSize;if(e.readUInt32LE(O)==Ie.LOCSIG||e.readUInt32LE(O)==Ie.CENSIG)throw ce.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(O)==Ie.EXTSIG)P.crc=e.readUInt32LE(O+Ie.EXTCRC),P.compressedSize=e.readUInt32LE(O+Ie.EXTSIZ),P.size=e.readUInt32LE(O+Ie.EXTLEN);else if(e.readUInt16LE(O+12)===19280)P.crc=e.readUInt32LE(O+Ie.EXTCRC-4),P.compressedSize=e.readUInt32LE(O+Ie.EXTSIZ-4),P.size=e.readUInt32LE(O+Ie.EXTLEN-4);else throw ce.Errors.DESCRIPTOR_UNKNOWN();if(P.compressedSize!==r.compressedSize||P.size!==r.size||P.crc!==r.crc)throw ce.Errors.DESCRIPTOR_FAULTY();if(ce.crc32(b)!==P.crc)return!1}return!0}function v(b,P,O){if(typeof P>"u"&&typeof b=="string"&&(O=b,b=void 0),c)return b&&P&&P(Buffer.alloc(0),ce.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var B=S();if(B.length===0)return b&&P&&P(B),B;if(r.encrypted){if(typeof O!="string"&&!Buffer.isBuffer(O))throw ce.Errors.INVALID_PASS_PARAM();B=$a.ZipCrypto.decrypt(B,r,O)}var M=Buffer.alloc(r.size);switch(r.method){case ce.Constants.STORED:if(B.copy(M),y(M))return b&&P&&P(M),M;throw b&&P&&P(M,ce.Errors.BAD_CRC()),ce.Errors.BAD_CRC();case ce.Constants.DEFLATED:var V=new $a.Inflater(B,r.size);if(b)V.inflateAsync(function(K){K.copy(K,0),P&&(y(K)?P(K):P(K,ce.Errors.BAD_CRC()))});else{if(V.inflate(M).copy(M,0),!y(M))throw ce.Errors.BAD_CRC(`"${w.decode(i)}"`);return M}break;default:throw b&&P&&P(Buffer.alloc(0),ce.Errors.UNKNOWN_METHOD()),ce.Errors.UNKNOWN_METHOD()}}function I(b,P){if((!d||!d.length)&&Buffer.isBuffer(e))return b&&P&&P(S()),S();if(d.length&&!c){var O;switch(r.method){case ce.Constants.STORED:return r.compressedSize=r.size,O=Buffer.alloc(d.length),d.copy(O),b&&P&&P(O),O;default:case ce.Constants.DEFLATED:var B=new $a.Deflater(d);if(b)B.deflateAsync(function(V){O=Buffer.alloc(V.length),r.compressedSize=V.length,V.copy(O),P&&P(O)});else{var M=B.deflate();return r.compressedSize=M.length,M}B=null;break}}else if(b&&P)P(Buffer.alloc(0));else return Buffer.alloc(0)}function A(b,P){return ce.readBigUInt64LE(b,P)}function R(b){try{for(var P=0,O,B,M;P+4<b.length;)O=b.readUInt16LE(P),P+=2,B=b.readUInt16LE(P),P+=2,M=b.slice(P,P+B),P+=B,Ie.ID_ZIP64===O&&D(M)}catch{throw ce.Errors.EXTRA_FIELD_PARSE_ERROR()}}function D(b){var P,O,B,M;b.length>=Ie.EF_ZIP64_SCOMP&&(P=A(b,Ie.EF_ZIP64_SUNCOMP),r.size===Ie.EF_ZIP64_OR_32&&(r.size=P)),b.length>=Ie.EF_ZIP64_RHO&&(O=A(b,Ie.EF_ZIP64_SCOMP),r.compressedSize===Ie.EF_ZIP64_OR_32&&(r.compressedSize=O)),b.length>=Ie.EF_ZIP64_DSN&&(B=A(b,Ie.EF_ZIP64_RHO),r.offset===Ie.EF_ZIP64_OR_32&&(r.offset=B)),b.length>=Ie.EF_ZIP64_DSN+4&&(M=b.readUInt32LE(Ie.EF_ZIP64_DSN),r.diskNumStart===Ie.EF_ZIP64_OR_16&&(r.diskNumStart=M))}return{get entryName(){return w.decode(i)},get rawEntryName(){return i},set entryName(b){i=ce.toBuffer(b,w.encode);var P=i[i.length-1];c=P===47||P===92,r.fileNameLength=i.length},get efs(){return typeof x=="function"?x(this.entryName):x},get extra(){return u},set extra(b){u=b,r.extraLength=b.length,R(b)},get comment(){return w.decode(o)},set comment(b){if(o=ce.toBuffer(b,w.encode),r.commentLength=o.length,o.length>65535)throw ce.Errors.COMMENT_TOO_LONG()},get name(){var b=w.decode(i);return c?b.substr(b.length-1).split("/").pop():b.split("/").pop()},get isDirectory(){return c},getCompressedData:function(){return I(!1,null)},getCompressedDataAsync:function(b){I(!0,b)},setData:function(b){d=ce.toBuffer(b,ce.decoder.encode),!c&&d.length?(r.size=d.length,r.method=ce.Constants.DEFLATED,r.crc=ce.crc32(b),r.changed=!0):r.method=ce.Constants.STORED},getData:function(b){return r.changed?d:v(!1,null,b)},getDataAsync:function(b,P){r.changed?b(d):v(!0,b,P)},set attr(b){r.attr=b},get attr(){return r.attr},set header(b){r.loadFromBinary(b)},get header(){return r},packCentralHeader:function(){r.flags_efs=this.efs,r.extraLength=u.length;var b=r.centralHeaderToBinary(),P=ce.Constants.CENHDR;return i.copy(b,P),P+=i.length,u.copy(b,P),P+=r.extraLength,o.copy(b,P),b},packLocalHeader:function(){let b=0;r.flags_efs=this.efs,r.extraLocalLength=f.length;let P=r.localHeaderToBinary(),O=Buffer.alloc(P.length+i.length+r.extraLocalLength);return P.copy(O,b),b+=P.length,i.copy(O,b),b+=i.length,f.copy(O,b),b+=f.length,O},toJSON:function(){let b=function(P){return"<"+(P&&P.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:r.toJSON(),compressedData:b(e),data:b(d)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var bu=ae((zI,Eu)=>{var yu=Ya(),Yg=Ka(),$e=xr();Eu.exports=function(t,e){var r=[],i={},o=Buffer.alloc(0),c=new Yg.MainHeader,d=!1,u=null;let f=new Set,x=e,{noSort:g,decoder:w}=x;t?v(x.readEntries):d=!0;function S(){let A=new Set;for(let R of Object.keys(i)){let D=R.split("/");if(D.pop(),!!D.length)for(let b=0;b<D.length;b++){let P=D.slice(0,b+1).join("/")+"/";A.add(P)}}for(let R of A)if(!(R in i)){let D=new yu(x);D.entryName=R,D.attr=16,D.temporary=!0,r.push(D),i[D.entryName]=D,f.add(D)}}function y(){if(d=!0,i={},c.diskEntries>(t.length-c.offset)/$e.Constants.CENHDR)throw $e.Errors.DISK_ENTRY_TOO_LARGE();r=new Array(c.diskEntries);for(var A=c.offset,R=0;R<r.length;R++){var D=A,b=new yu(x,t);b.header=t.slice(D,D+=$e.Constants.CENHDR),b.entryName=t.slice(D,D+=b.header.fileNameLength),b.header.extraLength&&(b.extra=t.slice(D,D+=b.header.extraLength)),b.header.commentLength&&(b.comment=t.slice(D,D+b.header.commentLength)),A+=b.header.centralHeaderSize,r[R]=b,i[b.entryName]=b}f.clear(),S()}function v(A){var R=t.length-$e.Constants.ENDHDR,D=Math.max(0,R-65535),b=D,P=t.length,O=-1,B=0;for(typeof x.trailingSpace=="boolean"&&x.trailingSpace&&(D=0),R;R>=b;R--)if(t[R]===80){if(t.readUInt32LE(R)===$e.Constants.ENDSIG){O=R,B=R,P=R+$e.Constants.ENDHDR,b=R-$e.Constants.END64HDR;continue}if(t.readUInt32LE(R)===$e.Constants.END64SIG){b=D;continue}if(t.readUInt32LE(R)===$e.Constants.ZIP64SIG){O=R,P=R+$e.readBigUInt64LE(t,R+$e.Constants.ZIP64SIZE)+$e.Constants.ZIP64LEAD;break}}if(O==-1)throw $e.Errors.INVALID_FORMAT();c.loadFromBinary(t.slice(O,P)),c.commentLength&&(o=t.slice(B+$e.Constants.ENDHDR)),A&&y()}function I(){r.length>1&&!g&&r.sort((A,R)=>A.entryName.toLowerCase().localeCompare(R.entryName.toLowerCase()))}return{get entries(){return d||y(),r.filter(A=>!f.has(A))},get comment(){return w.decode(o)},set comment(A){o=$e.toBuffer(A,w.encode),c.commentLength=o.length},getEntryCount:function(){return d?r.length:c.diskEntries},forEach:function(A){this.entries.forEach(A)},getEntry:function(A){return d||y(),i[A]||null},setEntry:function(A){d||y(),r.push(A),i[A.entryName]=A,c.totalEntries=r.length},deleteFile:function(A,R=!0){d||y();let D=i[A];this.getEntryChildren(D,R).map(P=>P.entryName).forEach(this.deleteEntry)},deleteEntry:function(A){d||y();let R=i[A],D=r.indexOf(R);D>=0&&(r.splice(D,1),delete i[A],c.totalEntries=r.length)},getEntryChildren:function(A,R=!0){if(d||y(),typeof A=="object")if(A.isDirectory&&R){let D=[],b=A.entryName;for(let P of r)P.entryName.startsWith(b)&&D.push(P);return D}else return[A];return[]},getChildCount:function(A){if(A&&A.isDirectory){let R=this.getEntryChildren(A);return R.includes(A)?R.length-1:R.length}return 0},compressToBuffer:function(){d||y(),I();let A=[],R=[],D=0,b=0;c.size=0,c.offset=0;let P=0;for(let M of this.entries){let V=M.getCompressedData();M.header.offset=b;let K=M.packLocalHeader(),re=K.length+V.length;b+=re,A.push(K),A.push(V);let X=M.packCentralHeader();R.push(X),c.size+=X.length,D+=re+X.length,P++}D+=c.mainHeaderSize,c.offset=b,c.totalEntries=P,b=0;let O=Buffer.alloc(D);for(let M of A)M.copy(O,b),b+=M.length;for(let M of R)M.copy(O,b),b+=M.length;let B=c.toBinary();return o&&o.copy(B,$e.Constants.ENDHDR),B.copy(O,b),t=O,d=!1,O},toAsyncBuffer:function(A,R,D,b){try{d||y(),I();let P=[],O=[],B=0,M=0,V=0;c.size=0,c.offset=0;let K=function(re){if(re.length>0){let X=re.shift(),se=X.entryName+X.extra.toString();D&&D(se),X.getCompressedDataAsync(function(oe){b&&b(se),X.header.offset=M;let C=X.packLocalHeader(),z=C.length+oe.length;M+=z,P.push(C),P.push(oe);let H=X.packCentralHeader();O.push(H),c.size+=H.length,B+=z+H.length,V++,K(re)})}else{B+=c.mainHeaderSize,c.offset=M,c.totalEntries=V,M=0;let X=Buffer.alloc(B);P.forEach(function(oe){oe.copy(X,M),M+=oe.length}),O.forEach(function(oe){oe.copy(X,M),M+=oe.length});let se=c.toBinary();o&&o.copy(se,$e.Constants.ENDHDR),se.copy(X,M),t=X,d=!1,A(X)}};K(Array.from(this.entries))}catch(P){R(P)}}}}});var Iu=ae((UI,Su)=>{var be=xr(),Ee=fe("path"),Vg=Ya(),Jg=bu(),Dn=(...t)=>be.findLast(t,e=>typeof e=="boolean"),vu=(...t)=>be.findLast(t,e=>typeof e=="string"),Zg=(...t)=>be.findLast(t,e=>typeof e=="function"),Xg={noSort:!1,readEntries:!1,method:be.Constants.NONE,fs:null};Su.exports=function(t,e){let r=null,i=Object.assign(Object.create(null),Xg);t&&typeof t=="object"&&(t instanceof Uint8Array||(Object.assign(i,t),t=i.input?i.input:void 0,i.input&&delete i.input),Buffer.isBuffer(t)&&(r=t,i.method=be.Constants.BUFFER,t=void 0)),Object.assign(i,e);let o=new be(i);if((typeof i.decoder!="object"||typeof i.decoder.encode!="function"||typeof i.decoder.decode!="function")&&(i.decoder=be.decoder),t&&typeof t=="string")if(o.fs.existsSync(t))i.method=be.Constants.FILE,i.filename=t,r=o.fs.readFileSync(t);else throw be.Errors.INVALID_FILENAME();let c=new Jg(r,i),{canonical:d,sanitize:u,zipnamefix:f}=be;function x(y){if(y&&c){var v;if(typeof y=="string"&&(v=c.getEntry(Ee.posix.normalize(y))),typeof y=="object"&&typeof y.entryName<"u"&&typeof y.header<"u"&&(v=c.getEntry(y.entryName)),v)return v}return null}function g(y){let{join:v,normalize:I,sep:A}=Ee.posix;return v(Ee.isAbsolute(y)?"/":".",I(A+y.split("\\").join(A)+A))}function w(y){return y instanceof RegExp?(function(v){return function(I){return v.test(I)}})(y):typeof y!="function"?()=>!0:y}let S=(y,v)=>{let I=v.slice(-1);return I=I===o.sep?o.sep:"",Ee.relative(y,v)+I};return{readFile:function(y,v){var I=x(y);return I&&I.getData(v)||null},childCount:function(y){let v=x(y);if(v)return c.getChildCount(v)},readFileAsync:function(y,v){var I=x(y);I?I.getDataAsync(v):v(null,"getEntry failed for:"+y)},readAsText:function(y,v){var I=x(y);if(I){var A=I.getData();if(A&&A.length)return A.toString(v||"utf8")}return""},readAsTextAsync:function(y,v,I){var A=x(y);A?A.getDataAsync(function(R,D){if(D){v(R,D);return}R&&R.length?v(R.toString(I||"utf8")):v("")}):v("")},deleteFile:function(y,v=!0){var I=x(y);I&&c.deleteFile(I.entryName,v)},deleteEntry:function(y){var v=x(y);v&&c.deleteEntry(v.entryName)},addZipComment:function(y){c.comment=y},getZipComment:function(){return c.comment||""},addZipEntryComment:function(y,v){var I=x(y);I&&(I.comment=v)},getZipEntryComment:function(y){var v=x(y);return v&&v.comment||""},updateFile:function(y,v){var I=x(y);I&&I.setData(v)},addLocalFile:function(y,v,I,A){if(o.fs.existsSync(y)){v=v?g(v):"";let R=Ee.win32.basename(Ee.win32.normalize(y));v+=I||R;let D=o.fs.statSync(y),b=D.isFile()?o.fs.readFileSync(y):Buffer.alloc(0);D.isDirectory()&&(v+=o.sep),this.addFile(v,b,A,D)}else throw be.Errors.FILE_NOT_FOUND(y)},addLocalFileAsync:function(y,v){y=typeof y=="object"?y:{localPath:y};let I=Ee.resolve(y.localPath),{comment:A}=y,{zipPath:R,zipName:D}=y,b=this;o.fs.stat(I,function(P,O){if(P)return v(P,!1);R=R?g(R):"";let B=Ee.win32.basename(Ee.win32.normalize(I));if(R+=D||B,O.isFile())o.fs.readFile(I,function(M,V){return M?v(M,!1):(b.addFile(R,V,A,O),setImmediate(v,void 0,!0))});else if(O.isDirectory())return R+=o.sep,b.addFile(R,Buffer.alloc(0),A,O),setImmediate(v,void 0,!0)})},addLocalFolder:function(y,v,I){if(I=w(I),v=v?g(v):"",y=Ee.normalize(y),o.fs.existsSync(y)){let A=o.findFiles(y),R=this;if(A.length)for(let D of A){let b=Ee.join(v,S(y,D));I(b)&&R.addLocalFile(D,Ee.dirname(b))}}else throw be.Errors.FILE_NOT_FOUND(y)},addLocalFolderAsync:function(y,v,I,A){A=w(A),I=I?g(I):"",y=Ee.normalize(y);var R=this;o.fs.open(y,"r",function(D){if(D&&D.code==="ENOENT")v(void 0,be.Errors.FILE_NOT_FOUND(y));else if(D)v(void 0,D);else{var b=o.findFiles(y),P=-1,O=function(){if(P+=1,P<b.length){var B=b[P],M=S(y,B).split("\\").join("/");M=M.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),A(M)?o.fs.stat(B,function(V,K){V&&v(void 0,V),K.isFile()?o.fs.readFile(B,function(re,X){re?v(void 0,re):(R.addFile(I+M,X,"",K),O())}):(R.addFile(I+M+"/",Buffer.alloc(0),"",K),O())}):process.nextTick(()=>{O()})}else v(!0,void 0)};O()}})},addLocalFolderAsync2:function(y,v){let I=this;y=typeof y=="object"?y:{localPath:y},localPath=Ee.resolve(g(y.localPath));let{zipPath:A,filter:R,namefix:D}=y;R instanceof RegExp?R=(function(O){return function(B){return O.test(B)}})(R):typeof R!="function"&&(R=function(){return!0}),A=A?g(A):"",D=="latin1"&&(D=O=>O.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof D!="function"&&(D=O=>O);let b=O=>Ee.join(A,D(S(localPath,O))),P=O=>Ee.win32.basename(Ee.win32.normalize(D(O)));o.fs.open(localPath,"r",function(O){O&&O.code==="ENOENT"?v(void 0,be.Errors.FILE_NOT_FOUND(localPath)):O?v(void 0,O):o.findFilesAsync(localPath,function(B,M){if(B)return v(B);M=M.filter(V=>R(b(V))),M.length||v(void 0,!1),setImmediate(M.reverse().reduce(function(V,K){return function(re,X){if(re||X===!1)return setImmediate(V,re,!1);I.addLocalFileAsync({localPath:K,zipPath:Ee.dirname(b(K)),zipName:P(K)},V)}},v))})})},addLocalFolderPromise:function(y,v){return new Promise((I,A)=>{this.addLocalFolderAsync2(Object.assign({localPath:y},v),(R,D)=>{R&&A(R),D&&I(this)})})},addFile:function(y,v,I,A){y=f(y);let R=x(y),D=R!=null;D||(R=new Vg(i),R.entryName=y),R.comment=I||"";let b=typeof A=="object"&&A instanceof o.fs.Stats;b&&(R.header.time=A.mtime);var P=R.isDirectory?16:0;let O=R.isDirectory?16384:32768;return b?O|=4095&A.mode:typeof A=="number"?O|=4095&A:O|=R.isDirectory?493:420,P=(P|O<<16)>>>0,R.attr=P,R.setData(v),D||c.setEntry(R),R},getEntries:function(y){return c.password=y,c?c.entries:[]},getEntry:function(y){return x(y)},getEntryCount:function(){return c.getEntryCount()},forEach:function(y){return c.forEach(y)},extractEntryTo:function(y,v,I,A,R,D){A=Dn(!1,A),R=Dn(!1,R),I=Dn(!0,I),D=vu(R,D);var b=x(y);if(!b)throw be.Errors.NO_ENTRY();var P=d(b.entryName),O=u(v,D&&!b.isDirectory?D:I?P:Ee.basename(P));if(b.isDirectory){var B=c.getEntryChildren(b);return B.forEach(function(K){if(K.isDirectory)return;var re=K.getData();if(!re)throw be.Errors.CANT_EXTRACT_FILE();var X=d(K.entryName),se=u(v,I?X:Ee.basename(X));let oe=R?K.header.fileAttr:void 0;o.writeFileTo(se,re,A,oe)}),!0}var M=b.getData(c.password);if(!M)throw be.Errors.CANT_EXTRACT_FILE();if(o.fs.existsSync(O)&&!A)throw be.Errors.CANT_OVERRIDE();let V=R?y.header.fileAttr:void 0;return o.writeFileTo(O,M,A,V),!0},test:function(y){if(!c)return!1;for(var v in c.entries)try{if(v.isDirectory)continue;var I=c.entries[v].getData(y);if(!I)return!1}catch{return!1}return!0},extractAllTo:function(y,v,I,A){if(I=Dn(!1,I),A=vu(I,A),v=Dn(!1,v),!c)throw be.Errors.NO_ZIP();c.entries.forEach(function(R){var D=u(y,d(R.entryName));if(R.isDirectory){o.makeDir(D);return}var b=R.getData(A);if(!b)throw be.Errors.CANT_EXTRACT_FILE();let P=I?R.header.fileAttr:void 0;o.writeFileTo(D,b,v,P);try{o.fs.utimesSync(D,R.header.time,R.header.time)}catch{throw be.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(y,v,I,A){if(A=Zg(v,I,A),I=Dn(!1,I),v=Dn(!1,v),!A)return new Promise((O,B)=>{this.extractAllToAsync(y,v,I,function(M){M?B(M):O(this)})});if(!c){A(be.Errors.NO_ZIP());return}y=Ee.resolve(y);let R=O=>u(y,Ee.normalize(d(O.entryName))),D=(O,B)=>new Error(O+': "'+B+'"'),b=[],P=[];c.entries.forEach(O=>{O.isDirectory?b.push(O):P.push(O)});for(let O of b){let B=R(O),M=I?O.header.fileAttr:void 0;try{o.makeDir(B),M&&o.fs.chmodSync(B,M),o.fs.utimesSync(B,O.header.time,O.header.time)}catch{A(D("Unable to create folder",B))}}P.reverse().reduce(function(O,B){return function(M){if(M)O(M);else{let V=Ee.normalize(d(B.entryName)),K=u(y,V);B.getDataAsync(function(re,X){if(X)O(X);else if(!re)O(be.Errors.CANT_EXTRACT_FILE());else{let se=I?B.header.fileAttr:void 0;o.writeFileToAsync(K,re,v,se,function(oe){oe||O(D("Unable to write file",K)),o.fs.utimes(K,B.header.time,B.header.time,function(C){C?O(D("Unable to set times",K)):O()})})}})}}},A)()},writeZip:function(y,v){if(arguments.length===1&&typeof y=="function"&&(v=y,y=""),!y&&i.filename&&(y=i.filename),!!y){var I=c.compressToBuffer();if(I){var A=o.writeFileTo(y,I,!0);typeof v=="function"&&v(A?null:new Error("failed"),"")}}},writeZipPromise:function(y,v){let{overwrite:I,perm:A}=Object.assign({overwrite:!0},v);return new Promise((R,D)=>{!y&&i.filename&&(y=i.filename),y||D("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(b=>{let P=O=>O?R(O):D("ADM-ZIP: Wasn't able to write zip file");o.writeFileToAsync(y,b,I,A,P)},D)})},toBufferPromise:function(){return new Promise((y,v)=>{c.toAsyncBuffer(y,v)})},toBuffer:function(y,v,I,A){return typeof y=="function"?(c.toAsyncBuffer(y,v,I,A),null):c.compressToBuffer()}}}});import{execFile as iy,spawn as sy,spawnSync as ik}from"node:child_process";import{promisify as oy}from"node:util";function cy(t){if(process.platform!=="win32")return!1;if(Wf.test(t))return!0;let r=(t.split(/[/\\]/).pop()??t).replace(Wf,"").toLowerCase();return ay.has(r)}function Kf(t,e){if(process.platform!=="win32")return e??{};let r={...e??{}};return cy(t)&&r.shell===void 0&&(r.shell=!0),r.windowsHide===void 0&&(r.windowsHide=!0),r}function st(t,e=[],r={}){return sy(t,e,Kf(t,r))}function $f(t,e=[],r={}){return dy(t,e,Kf(t,r))}var ay,Wf,dy,Zt=nt(()=>{"use strict";ay=new Set(["npm","npx","yarn","pnpm","coze","tsx","claude-agent-acp","codex-acp","openclaw"]),Wf=/\.(cmd|bat|ps1)$/i;dy=oy(iy)});var Qt=ae((cC,Gh)=>{"use strict";var zh=["nodebuffer","arraybuffer","fragments"],Uh=typeof Blob<"u";Uh&&zh.push("blob");Gh.exports={BINARY_TYPES:zh,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:Uh,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var Xi=ae((dC,Uo)=>{"use strict";var{EMPTY_BUFFER:Kb}=Qt(),Sd=Buffer[Symbol.species];function $b(t,e){if(t.length===0)return Kb;if(t.length===1)return t[0];let r=Buffer.allocUnsafe(e),i=0;for(let o=0;o<t.length;o++){let c=t[o];r.set(c,i),i+=c.length}return i<e?new Sd(r.buffer,r.byteOffset,i):r}function Hh(t,e,r,i,o){for(let c=0;c<o;c++)r[i+c]=t[c]^e[c&3]}function qh(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function Yb(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function Id(t){if(Id.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new Sd(t):ArrayBuffer.isView(t)?e=new Sd(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),Id.readOnly=!1),e}Uo.exports={concat:$b,mask:Hh,toArrayBuffer:Yb,toBuffer:Id,unmask:qh};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=fe("bufferutil");Uo.exports.mask=function(e,r,i,o,c){c<48?Hh(e,r,i,o,c):t.mask(e,r,i,o,c)},Uo.exports.unmask=function(e,r){e.length<32?qh(e,r):t.unmask(e,r)}}catch{}});var Kh=ae((lC,Wh)=>{"use strict";var jh=Symbol("kDone"),Ad=Symbol("kRun"),kd=class{constructor(e){this[jh]=()=>{this.pending--,this[Ad]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Ad]()}[Ad](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[jh])}}};Wh.exports=kd});var Hr=ae((uC,Jh)=>{"use strict";var Qi=fe("zlib"),$h=Xi(),Vb=Kh(),{kStatusCode:Yh}=Qt(),Jb=Buffer[Symbol.species],Zb=Buffer.from([0,0,255,255]),Ho=Symbol("permessage-deflate"),en=Symbol("total-length"),Ur=Symbol("callback"),kn=Symbol("buffers"),Gr=Symbol("error"),Go,Td=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!Go){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Go=new Vb(r)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[Ur];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let r=this._options,i=e.find(o=>!(r.serverNoContextTakeover===!1&&o.server_no_context_takeover||o.server_max_window_bits&&(r.serverMaxWindowBits===!1||typeof r.serverMaxWindowBits=="number"&&r.serverMaxWindowBits>o.server_max_window_bits)||typeof r.clientMaxWindowBits=="number"&&!o.client_max_window_bits));if(!i)throw new Error("None of the extension offers can be accepted");return r.serverNoContextTakeover&&(i.server_no_context_takeover=!0),r.clientNoContextTakeover&&(i.client_no_context_takeover=!0),typeof r.serverMaxWindowBits=="number"&&(i.server_max_window_bits=r.serverMaxWindowBits),typeof r.clientMaxWindowBits=="number"?i.client_max_window_bits=r.clientMaxWindowBits:(i.client_max_window_bits===!0||r.clientMaxWindowBits===!1)&&delete i.client_max_window_bits,i}acceptAsClient(e){let r=e[0];if(this._options.clientNoContextTakeover===!1&&r.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!r.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(r.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&r.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return r}normalizeParams(e){return e.forEach(r=>{Object.keys(r).forEach(i=>{let o=r[i];if(o.length>1)throw new Error(`Parameter "${i}" must have only a single value`);if(o=o[0],i==="client_max_window_bits"){if(o!==!0){let c=+o;if(!Number.isInteger(c)||c<8||c>15)throw new TypeError(`Invalid value for parameter "${i}": ${o}`);o=c}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${i}": ${o}`)}else if(i==="server_max_window_bits"){let c=+o;if(!Number.isInteger(c)||c<8||c>15)throw new TypeError(`Invalid value for parameter "${i}": ${o}`);o=c}else if(i==="client_no_context_takeover"||i==="server_no_context_takeover"){if(o!==!0)throw new TypeError(`Invalid value for parameter "${i}": ${o}`)}else throw new Error(`Unknown parameter "${i}"`);r[i]=o})}),e}decompress(e,r,i){Go.add(o=>{this._decompress(e,r,(c,d)=>{o(),i(c,d)})})}compress(e,r,i){Go.add(o=>{this._compress(e,r,(c,d)=>{o(),i(c,d)})})}_decompress(e,r,i){let o=this._isServer?"client":"server";if(!this._inflate){let c=`${o}_max_window_bits`,d=typeof this.params[c]!="number"?Qi.Z_DEFAULT_WINDOWBITS:this.params[c];this._inflate=Qi.createInflateRaw({...this._options.zlibInflateOptions,windowBits:d}),this._inflate[Ho]=this,this._inflate[en]=0,this._inflate[kn]=[],this._inflate.on("error",Qb),this._inflate.on("data",Vh)}this._inflate[Ur]=i,this._inflate.write(e),r&&this._inflate.write(Zb),this._inflate.flush(()=>{let c=this._inflate[Gr];if(c){this._inflate.close(),this._inflate=null,i(c);return}let d=$h.concat(this._inflate[kn],this._inflate[en]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[en]=0,this._inflate[kn]=[],r&&this.params[`${o}_no_context_takeover`]&&this._inflate.reset()),i(null,d)})}_compress(e,r,i){let o=this._isServer?"server":"client";if(!this._deflate){let c=`${o}_max_window_bits`,d=typeof this.params[c]!="number"?Qi.Z_DEFAULT_WINDOWBITS:this.params[c];this._deflate=Qi.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:d}),this._deflate[en]=0,this._deflate[kn]=[],this._deflate.on("data",Xb)}this._deflate[Ur]=i,this._deflate.write(e),this._deflate.flush(Qi.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let c=$h.concat(this._deflate[kn],this._deflate[en]);r&&(c=new Jb(c.buffer,c.byteOffset,c.length-4)),this._deflate[Ur]=null,this._deflate[en]=0,this._deflate[kn]=[],r&&this.params[`${o}_no_context_takeover`]&&this._deflate.reset(),i(null,c)})}};Jh.exports=Td;function Xb(t){this[kn].push(t),this[en]+=t.length}function Vh(t){if(this[en]+=t.length,this[Ho]._maxPayload<1||this[en]<=this[Ho]._maxPayload){this[kn].push(t);return}this[Gr]=new RangeError("Max payload size exceeded"),this[Gr].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Gr][Yh]=1009,this.removeListener("data",Vh),this.reset()}function Qb(t){if(this[Ho]._inflate=null,this[Gr]){this[Ur](this[Gr]);return}t[Yh]=1007,this[Ur](t)}});var qr=ae((fC,qo)=>{"use strict";var{isUtf8:Zh}=fe("buffer"),{hasBlob:ev}=Qt(),tv=[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 nv(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function Rd(t){let e=t.length,r=0;for(;r<e;)if((t[r]&128)===0)r++;else if((t[r]&224)===192){if(r+1===e||(t[r+1]&192)!==128||(t[r]&254)===192)return!1;r+=2}else if((t[r]&240)===224){if(r+2>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||t[r]===224&&(t[r+1]&224)===128||t[r]===237&&(t[r+1]&224)===160)return!1;r+=3}else if((t[r]&248)===240){if(r+3>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||(t[r+3]&192)!==128||t[r]===240&&(t[r+1]&240)===128||t[r]===244&&t[r+1]>143||t[r]>244)return!1;r+=4}else return!1;return!0}function rv(t){return ev&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}qo.exports={isBlob:rv,isValidStatusCode:nv,isValidUTF8:Rd,tokenChars:tv};if(Zh)qo.exports.isValidUTF8=function(t){return t.length<24?Rd(t):Zh(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=fe("utf-8-validate");qo.exports.isValidUTF8=function(e){return e.length<32?Rd(e):t(e)}}catch{}});var Ld=ae((hC,ix)=>{"use strict";var{Writable:iv}=fe("stream"),Xh=Hr(),{BINARY_TYPES:sv,EMPTY_BUFFER:Qh,kStatusCode:ov,kWebSocket:av}=Qt(),{concat:Cd,toArrayBuffer:cv,unmask:dv}=Xi(),{isValidStatusCode:lv,isValidUTF8:ex}=qr(),jo=Buffer[Symbol.species],mt=0,tx=1,nx=2,rx=3,Pd=4,Dd=5,Wo=6,Od=class extends iv{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||sv[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxBufferedChunks=e.maxBufferedChunks|0,this._maxFragments=e.maxFragments|0,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[av]=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=mt}_write(e,r,i){if(this._opcode===8&&this._state==mt)return i();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){i(this.createError(RangeError,"Too many buffered chunks",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));return}this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(i)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let i=this._buffers[0];return this._buffers[0]=new jo(i.buffer,i.byteOffset+e,i.length-e),new jo(i.buffer,i.byteOffset,e)}let r=Buffer.allocUnsafe(e);do{let i=this._buffers[0],o=r.length-e;e>=i.length?r.set(this._buffers.shift(),o):(r.set(new Uint8Array(i.buffer,i.byteOffset,e),o),this._buffers[0]=new jo(i.buffer,i.byteOffset+e,i.length-e)),e-=i.length}while(e>0);return r}startLoop(e){this._loop=!0;do switch(this._state){case mt:this.getInfo(e);break;case tx:this.getPayloadLength16(e);break;case nx:this.getPayloadLength64(e);break;case rx:this.getMask();break;case Pd:this.getData(e);break;case Dd:case Wo:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let r=this.consume(2);if((r[0]&48)!==0){let o=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(o);return}let i=(r[0]&64)===64;if(i&&!this._extensions[Xh.extensionName]){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(o);return}if(this._fin=(r[0]&128)===128,this._opcode=r[0]&15,this._payloadLength=r[1]&127,this._opcode===0){if(i){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(o);return}if(!this._fragmented){let o=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(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");e(o);return}this._compressed=i}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");e(o);return}if(i){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(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");e(o);return}}else{let o=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(o);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(r[1]&128)===128,this._isServer){if(!this._masked){let o=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(o);return}}else if(this._masked){let o=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(o);return}this._payloadLength===126?this._state=tx:this._payloadLength===127?this._state=nx:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let r=this.consume(8),i=r.readUInt32BE(0);if(i>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");e(o);return}this._payloadLength=i*Math.pow(2,32)+r.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let r=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(r);return}this._masked?this._state=rx:this._state=Pd}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Pd}getData(e){let r=Qh;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}r=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&dv(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._compressed){this._state=Dd,this.decompress(r,e);return}if(r.length){if(this._maxFragments>0&&this._fragments.length>=this._maxFragments){let i=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");e(i);return}this._messageLength=this._totalPayloadLength,this._fragments.push(r)}this.dataMessage(e)}decompress(e,r){this._extensions[Xh.extensionName].decompress(e,this._fin,(o,c)=>{if(o)return r(o);if(c.length){if(this._messageLength+=c.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let d=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");r(d);return}if(this._maxFragments>0&&this._fragments.length>=this._maxFragments){let d=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");r(d);return}this._fragments.push(c)}this.dataMessage(r),this._state===mt&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=mt;return}let r=this._messageLength,i=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let o;this._binaryType==="nodebuffer"?o=Cd(i,r):this._binaryType==="arraybuffer"?o=cv(Cd(i,r)):this._binaryType==="blob"?o=new Blob(i):o=i,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=mt):(this._state=Wo,setImmediate(()=>{this.emit("message",o,!0),this._state=mt,this.startLoop(e)}))}else{let o=Cd(i,r);if(!this._skipUTF8Validation&&!ex(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(c);return}this._state===Dd||this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=mt):(this._state=Wo,setImmediate(()=>{this.emit("message",o,!1),this._state=mt,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,Qh),this.end();else{let i=e.readUInt16BE(0);if(!lv(i)){let c=this.createError(RangeError,`invalid status code ${i}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(c);return}let o=new jo(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!ex(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");r(c);return}this._loop=!1,this.emit("conclude",i,o),this.end()}this._state=mt;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=mt):(this._state=Wo,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=mt,this.startLoop(r)}))}createError(e,r,i,o,c){this._loop=!1,this._errored=!0;let d=new e(i?`Invalid WebSocket frame: ${r}`:r);return Error.captureStackTrace(d,this.createError),d.code=c,d[ov]=o,d}};ix.exports=Od});var Bd=ae((pC,ax)=>{"use strict";var{Duplex:xC}=fe("stream"),{randomFillSync:uv}=fe("crypto"),{types:{isUint8Array:fv}}=fe("util"),sx=Hr(),{EMPTY_BUFFER:hv,kWebSocket:xv,NOOP:pv}=Qt(),{isBlob:jr,isValidStatusCode:mv}=qr(),{mask:ox,toBuffer:Jn}=Xi(),gt=Symbol("kByteLength"),gv=Buffer.alloc(4),Ko=8*1024,Zn,Wr=Ko,At=0,wv=1,_v=2,Nd=class t{constructor(e,r,i){this._extensions=r||{},i&&(this._generateMask=i,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=At,this.onerror=pv,this[xv]=void 0}static frame(e,r){let i,o=!1,c=2,d=!1;r.mask&&(i=r.maskBuffer||gv,r.generateMask?r.generateMask(i):(Wr===Ko&&(Zn===void 0&&(Zn=Buffer.alloc(Ko)),uv(Zn,0,Ko),Wr=0),i[0]=Zn[Wr++],i[1]=Zn[Wr++],i[2]=Zn[Wr++],i[3]=Zn[Wr++]),d=(i[0]|i[1]|i[2]|i[3])===0,c=6);let u;typeof e=="string"?(!r.mask||d)&&r[gt]!==void 0?u=r[gt]:(e=Buffer.from(e),u=e.length):(u=e.length,o=r.mask&&r.readOnly&&!d);let f=u;u>=65536?(c+=8,f=127):u>125&&(c+=2,f=126);let x=Buffer.allocUnsafe(o?u+c:c);return x[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(x[0]|=64),x[1]=f,f===126?x.writeUInt16BE(u,2):f===127&&(x[2]=x[3]=0,x.writeUIntBE(u,4,6)),r.mask?(x[1]|=128,x[c-4]=i[0],x[c-3]=i[1],x[c-2]=i[2],x[c-1]=i[3],d?[x,e]:o?(ox(e,i,x,c,u),[x]):(ox(e,i,e,0,u),[x,e])):[x,e]}close(e,r,i,o){let c;if(e===void 0)c=hv;else{if(typeof e!="number"||!mv(e))throw new TypeError("First argument must be a valid error code number");if(r===void 0||!r.length)c=Buffer.allocUnsafe(2),c.writeUInt16BE(e,0);else{let u=Buffer.byteLength(r);if(u>123)throw new RangeError("The message must not be greater than 123 bytes");if(c=Buffer.allocUnsafe(2+u),c.writeUInt16BE(e,0),typeof r=="string")c.write(r,2);else if(fv(r))c.set(r,2);else throw new TypeError("Second argument must be a string or a Uint8Array")}}let d={[gt]:c.length,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==At?this.enqueue([this.dispatch,c,!1,d,o]):this.sendFrame(t.frame(c,d),o)}ping(e,r,i){let o,c;if(typeof e=="string"?(o=Buffer.byteLength(e),c=!1):jr(e)?(o=e.size,c=!1):(e=Jn(e),o=e.length,c=Jn.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let d={[gt]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:c,rsv1:!1};jr(e)?this._state!==At?this.enqueue([this.getBlobData,e,!1,d,i]):this.getBlobData(e,!1,d,i):this._state!==At?this.enqueue([this.dispatch,e,!1,d,i]):this.sendFrame(t.frame(e,d),i)}pong(e,r,i){let o,c;if(typeof e=="string"?(o=Buffer.byteLength(e),c=!1):jr(e)?(o=e.size,c=!1):(e=Jn(e),o=e.length,c=Jn.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let d={[gt]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:c,rsv1:!1};jr(e)?this._state!==At?this.enqueue([this.getBlobData,e,!1,d,i]):this.getBlobData(e,!1,d,i):this._state!==At?this.enqueue([this.dispatch,e,!1,d,i]):this.sendFrame(t.frame(e,d),i)}send(e,r,i){let o=this._extensions[sx.extensionName],c=r.binary?2:1,d=r.compress,u,f;typeof e=="string"?(u=Buffer.byteLength(e),f=!1):jr(e)?(u=e.size,f=!1):(e=Jn(e),u=e.length,f=Jn.readOnly),this._firstFragment?(this._firstFragment=!1,d&&o&&o.params[o._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(d=u>=o._threshold),this._compress=d):(d=!1,c=0),r.fin&&(this._firstFragment=!0);let x={[gt]:u,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:c,readOnly:f,rsv1:d};jr(e)?this._state!==At?this.enqueue([this.getBlobData,e,this._compress,x,i]):this.getBlobData(e,this._compress,x,i):this._state!==At?this.enqueue([this.dispatch,e,this._compress,x,i]):this.dispatch(e,this._compress,x,i)}getBlobData(e,r,i,o){this._bufferedBytes+=i[gt],this._state=_v,e.arrayBuffer().then(c=>{if(this._socket.destroyed){let u=new Error("The socket was closed while the blob was being read");process.nextTick(Md,this,u,o);return}this._bufferedBytes-=i[gt];let d=Jn(c);r?this.dispatch(d,r,i,o):(this._state=At,this.sendFrame(t.frame(d,i),o),this.dequeue())}).catch(c=>{process.nextTick(yv,this,c,o)})}dispatch(e,r,i,o){if(!r){this.sendFrame(t.frame(e,i),o);return}let c=this._extensions[sx.extensionName];this._bufferedBytes+=i[gt],this._state=wv,c.compress(e,i.fin,(d,u)=>{if(this._socket.destroyed){let f=new Error("The socket was closed while data was being compressed");Md(this,f,o);return}this._bufferedBytes-=i[gt],this._state=At,i.readOnly=!1,this.sendFrame(t.frame(u,i),o),this.dequeue()})}dequeue(){for(;this._state===At&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][gt],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][gt],this._queue.push(e)}sendFrame(e,r){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],r),this._socket.uncork()):this._socket.write(e[0],r)}};ax.exports=Nd;function Md(t,e,r){typeof r=="function"&&r(e);for(let i=0;i<t._queue.length;i++){let o=t._queue[i],c=o[o.length-1];typeof c=="function"&&c(e)}}function yv(t,e,r){Md(t,e,r),t.onerror(e)}});var mx=ae((mC,px)=>{"use strict";var{kForOnEventAttribute:es,kListener:Fd}=Qt(),cx=Symbol("kCode"),dx=Symbol("kData"),lx=Symbol("kError"),ux=Symbol("kMessage"),fx=Symbol("kReason"),Kr=Symbol("kTarget"),hx=Symbol("kType"),xx=Symbol("kWasClean"),tn=class{constructor(e){this[Kr]=null,this[hx]=e}get target(){return this[Kr]}get type(){return this[hx]}};Object.defineProperty(tn.prototype,"target",{enumerable:!0});Object.defineProperty(tn.prototype,"type",{enumerable:!0});var Xn=class extends tn{constructor(e,r={}){super(e),this[cx]=r.code===void 0?0:r.code,this[fx]=r.reason===void 0?"":r.reason,this[xx]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[cx]}get reason(){return this[fx]}get wasClean(){return this[xx]}};Object.defineProperty(Xn.prototype,"code",{enumerable:!0});Object.defineProperty(Xn.prototype,"reason",{enumerable:!0});Object.defineProperty(Xn.prototype,"wasClean",{enumerable:!0});var $r=class extends tn{constructor(e,r={}){super(e),this[lx]=r.error===void 0?null:r.error,this[ux]=r.message===void 0?"":r.message}get error(){return this[lx]}get message(){return this[ux]}};Object.defineProperty($r.prototype,"error",{enumerable:!0});Object.defineProperty($r.prototype,"message",{enumerable:!0});var ts=class extends tn{constructor(e,r={}){super(e),this[dx]=r.data===void 0?null:r.data}get data(){return this[dx]}};Object.defineProperty(ts.prototype,"data",{enumerable:!0});var Ev={addEventListener(t,e,r={}){for(let o of this.listeners(t))if(!r[es]&&o[Fd]===e&&!o[es])return;let i;if(t==="message")i=function(c,d){let u=new ts("message",{data:d?c:c.toString()});u[Kr]=this,$o(e,this,u)};else if(t==="close")i=function(c,d){let u=new Xn("close",{code:c,reason:d.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});u[Kr]=this,$o(e,this,u)};else if(t==="error")i=function(c){let d=new $r("error",{error:c,message:c.message});d[Kr]=this,$o(e,this,d)};else if(t==="open")i=function(){let c=new tn("open");c[Kr]=this,$o(e,this,c)};else return;i[es]=!!r[es],i[Fd]=e,r.once?this.once(t,i):this.on(t,i)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[Fd]===e&&!r[es]){this.removeListener(t,r);break}}};px.exports={CloseEvent:Xn,ErrorEvent:$r,Event:tn,EventTarget:Ev,MessageEvent:ts};function $o(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var Yo=ae((gC,gx)=>{"use strict";var{tokenChars:ns}=qr();function Ft(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function bv(t){let e=Object.create(null),r=Object.create(null),i=!1,o=!1,c=!1,d,u,f=-1,x=-1,g=-1,w=0;for(;w<t.length;w++)if(x=t.charCodeAt(w),d===void 0)if(g===-1&&ns[x]===1)f===-1&&(f=w);else if(w!==0&&(x===32||x===9))g===-1&&f!==-1&&(g=w);else if(x===59||x===44){if(f===-1)throw new SyntaxError(`Unexpected character at index ${w}`);g===-1&&(g=w);let y=t.slice(f,g);x===44?(Ft(e,y,r),r=Object.create(null)):d=y,f=g=-1}else throw new SyntaxError(`Unexpected character at index ${w}`);else if(u===void 0)if(g===-1&&ns[x]===1)f===-1&&(f=w);else if(x===32||x===9)g===-1&&f!==-1&&(g=w);else if(x===59||x===44){if(f===-1)throw new SyntaxError(`Unexpected character at index ${w}`);g===-1&&(g=w),Ft(r,t.slice(f,g),!0),x===44&&(Ft(e,d,r),r=Object.create(null),d=void 0),f=g=-1}else if(x===61&&f!==-1&&g===-1)u=t.slice(f,w),f=g=-1;else throw new SyntaxError(`Unexpected character at index ${w}`);else if(o){if(ns[x]!==1)throw new SyntaxError(`Unexpected character at index ${w}`);f===-1?f=w:i||(i=!0),o=!1}else if(c)if(ns[x]===1)f===-1&&(f=w);else if(x===34&&f!==-1)c=!1,g=w;else if(x===92)o=!0;else throw new SyntaxError(`Unexpected character at index ${w}`);else if(x===34&&t.charCodeAt(w-1)===61)c=!0;else if(g===-1&&ns[x]===1)f===-1&&(f=w);else if(f!==-1&&(x===32||x===9))g===-1&&(g=w);else if(x===59||x===44){if(f===-1)throw new SyntaxError(`Unexpected character at index ${w}`);g===-1&&(g=w);let y=t.slice(f,g);i&&(y=y.replace(/\\/g,""),i=!1),Ft(r,u,y),x===44&&(Ft(e,d,r),r=Object.create(null),d=void 0),u=void 0,f=g=-1}else throw new SyntaxError(`Unexpected character at index ${w}`);if(f===-1||c||x===32||x===9)throw new SyntaxError("Unexpected end of input");g===-1&&(g=w);let S=t.slice(f,g);return d===void 0?Ft(e,S,r):(u===void 0?Ft(r,S,!0):i?Ft(r,u,S.replace(/\\/g,"")):Ft(r,u,S),Ft(e,d,r)),e}function vv(t){return Object.keys(t).map(e=>{let r=t[e];return Array.isArray(r)||(r=[r]),r.map(i=>[e].concat(Object.keys(i).map(o=>{let c=i[o];return Array.isArray(c)||(c=[c]),c.map(d=>d===!0?o:`${o}=${d}`).join("; ")})).join("; ")).join(", ")}).join(", ")}gx.exports={format:vv,parse:bv}});var Xo=ae((yC,Cx)=>{"use strict";var Sv=fe("events"),Iv=fe("https"),Av=fe("http"),Ex=fe("net"),kv=fe("tls"),{randomBytes:Tv,createHash:Rv}=fe("crypto"),{Duplex:wC,Readable:_C}=fe("stream"),{URL:zd}=fe("url"),Tn=Hr(),Cv=Ld(),Pv=Bd(),{isBlob:Dv}=qr(),{BINARY_TYPES:_x,CLOSE_TIMEOUT:Ov,EMPTY_BUFFER:Vo,GUID:Lv,kForOnEventAttribute:Ud,kListener:Nv,kStatusCode:Mv,kWebSocket:je,NOOP:bx}=Qt(),{EventTarget:{addEventListener:Bv,removeEventListener:Fv}}=mx(),{format:zv,parse:Uv}=Yo(),{toBuffer:Gv}=Xi(),vx=Symbol("kAborted"),Gd=[8,13],nn=["CONNECTING","OPEN","CLOSING","CLOSED"],Hv=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,ge=class t extends Sv{constructor(e,r,i){super(),this._binaryType=_x[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Vo,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=t.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,r===void 0?r=[]:Array.isArray(r)||(typeof r=="object"&&r!==null?(i=r,r=[]):r=[r]),Sx(this,e,r,i)):(this._autoPong=i.autoPong,this._closeTimeout=i.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){_x.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}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(e,r,i){let o=new Cv({allowSynchronousEvents:i.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxBufferedChunks:i.maxBufferedChunks,maxFragments:i.maxFragments,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation}),c=new Pv(e,this._extensions,i.generateMask);this._receiver=o,this._sender=c,this._socket=e,o[je]=this,c[je]=this,e[je]=this,o.on("conclude",Wv),o.on("drain",Kv),o.on("error",$v),o.on("message",Yv),o.on("ping",Vv),o.on("pong",Jv),c.onerror=Zv,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",kx),e.on("data",Zo),e.on("end",Tx),e.on("error",Rx),this._readyState=t.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[Tn.extensionName]&&this._extensions[Tn.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,r){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){dt(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===t.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=t.CLOSING,this._sender.close(e,r,!this._isServer,i=>{i||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),Ax(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,r,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(i=e,e=r=void 0):typeof r=="function"&&(i=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Hd(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||Vo,r,i)}pong(e,r,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(i=e,e=r=void 0):typeof r=="function"&&(i=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Hd(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||Vo,r,i)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,r,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof r=="function"&&(i=r,r={}),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Hd(this,e,i);return}let o={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[Tn.extensionName]||(o.compress=!1),this._sender.send(e||Vo,o,i)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){dt(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(ge,"CONNECTING",{enumerable:!0,value:nn.indexOf("CONNECTING")});Object.defineProperty(ge.prototype,"CONNECTING",{enumerable:!0,value:nn.indexOf("CONNECTING")});Object.defineProperty(ge,"OPEN",{enumerable:!0,value:nn.indexOf("OPEN")});Object.defineProperty(ge.prototype,"OPEN",{enumerable:!0,value:nn.indexOf("OPEN")});Object.defineProperty(ge,"CLOSING",{enumerable:!0,value:nn.indexOf("CLOSING")});Object.defineProperty(ge.prototype,"CLOSING",{enumerable:!0,value:nn.indexOf("CLOSING")});Object.defineProperty(ge,"CLOSED",{enumerable:!0,value:nn.indexOf("CLOSED")});Object.defineProperty(ge.prototype,"CLOSED",{enumerable:!0,value:nn.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(ge.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(ge.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[Ud])return e[Nv];return null},set(e){for(let r of this.listeners(t))if(r[Ud]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[Ud]:!0})}})});ge.prototype.addEventListener=Bv;ge.prototype.removeEventListener=Fv;Cx.exports=ge;function Sx(t,e,r,i){let o={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:Ov,protocolVersion:Gd[1],maxBufferedChunks:1048576,maxFragments:131072,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...i,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=o.autoPong,t._closeTimeout=o.closeTimeout,!Gd.includes(o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${Gd.join(", ")})`);let c;if(e instanceof zd)c=e;else try{c=new zd(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}c.protocol==="http:"?c.protocol="ws:":c.protocol==="https:"&&(c.protocol="wss:"),t._url=c.href;let d=c.protocol==="wss:",u=c.protocol==="ws+unix:",f;if(c.protocol!=="ws:"&&!d&&!u?f=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:u&&!c.pathname?f="The URL's pathname is empty":c.hash&&(f="The URL contains a fragment identifier"),f){let I=new SyntaxError(f);if(t._redirects===0)throw I;Jo(t,I);return}let x=d?443:80,g=Tv(16).toString("base64"),w=d?Iv.request:Av.request,S=new Set,y;if(o.createConnection=o.createConnection||(d?jv:qv),o.defaultPort=o.defaultPort||x,o.port=c.port||x,o.host=c.hostname.startsWith("[")?c.hostname.slice(1,-1):c.hostname,o.headers={...o.headers,"Sec-WebSocket-Version":o.protocolVersion,"Sec-WebSocket-Key":g,Connection:"Upgrade",Upgrade:"websocket"},o.path=c.pathname+c.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&(y=new Tn({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers["Sec-WebSocket-Extensions"]=zv({[Tn.extensionName]:y.offer()})),r.length){for(let I of r){if(typeof I!="string"||!Hv.test(I)||S.has(I))throw new SyntaxError("An invalid or duplicated subprotocol was specified");S.add(I)}o.headers["Sec-WebSocket-Protocol"]=r.join(",")}if(o.origin&&(o.protocolVersion<13?o.headers["Sec-WebSocket-Origin"]=o.origin:o.headers.Origin=o.origin),(c.username||c.password)&&(o.auth=`${c.username}:${c.password}`),u){let I=o.path.split(":");o.socketPath=I[0],o.path=I[1]}let v;if(o.followRedirects){if(t._redirects===0){t._originalIpc=u,t._originalSecure=d,t._originalHostOrSocketPath=u?o.socketPath:c.host;let I=i&&i.headers;if(i={...i,headers:{}},I)for(let[A,R]of Object.entries(I))i.headers[A.toLowerCase()]=R}else if(t.listenerCount("redirect")===0){let I=u?t._originalIpc?o.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:c.host===t._originalHostOrSocketPath;(!I||t._originalSecure&&!d)&&(delete o.headers.authorization,delete o.headers.cookie,I||delete o.headers.host,o.auth=void 0)}o.auth&&!i.headers.authorization&&(i.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")),v=t._req=w(o),t._redirects&&t.emit("redirect",t.url,v)}else v=t._req=w(o);o.timeout&&v.on("timeout",()=>{dt(t,v,"Opening handshake has timed out")}),v.on("error",I=>{v===null||v[vx]||(v=t._req=null,Jo(t,I))}),v.on("response",I=>{let A=I.headers.location,R=I.statusCode;if(A&&o.followRedirects&&R>=300&&R<400){if(++t._redirects>o.maxRedirects){dt(t,v,"Maximum redirects exceeded");return}v.abort();let D;try{D=new zd(A,e)}catch{let P=new SyntaxError(`Invalid URL: ${A}`);Jo(t,P);return}Sx(t,D,r,i)}else t.emit("unexpected-response",v,I)||dt(t,v,`Unexpected server response: ${I.statusCode}`)}),v.on("upgrade",(I,A,R)=>{if(t.emit("upgrade",I),t.readyState!==ge.CONNECTING)return;v=t._req=null;let D=I.headers.upgrade;if(D===void 0||D.toLowerCase()!=="websocket"){dt(t,A,"Invalid Upgrade header");return}let b=Rv("sha1").update(g+Lv).digest("base64");if(I.headers["sec-websocket-accept"]!==b){dt(t,A,"Invalid Sec-WebSocket-Accept header");return}let P=I.headers["sec-websocket-protocol"],O;if(P!==void 0?S.size?S.has(P)||(O="Server sent an invalid subprotocol"):O="Server sent a subprotocol but none was requested":S.size&&(O="Server sent no subprotocol"),O){dt(t,A,O);return}P&&(t._protocol=P);let B=I.headers["sec-websocket-extensions"];if(B!==void 0){if(!y){dt(t,A,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let M;try{M=Uv(B)}catch{dt(t,A,"Invalid Sec-WebSocket-Extensions header");return}let V=Object.keys(M);if(V.length!==1||V[0]!==Tn.extensionName){dt(t,A,"Server indicated an extension that was not requested");return}try{y.accept(M[Tn.extensionName])}catch{dt(t,A,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[Tn.extensionName]=y}t.setSocket(A,R,{allowSynchronousEvents:o.allowSynchronousEvents,generateMask:o.generateMask,maxBufferedChunks:o.maxBufferedChunks,maxFragments:o.maxFragments,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(v,t):v.end()}function Jo(t,e){t._readyState=ge.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function qv(t){return t.path=t.socketPath,Ex.connect(t)}function jv(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Ex.isIP(t.host)?"":t.host),kv.connect(t)}function dt(t,e,r){t._readyState=ge.CLOSING;let i=new Error(r);Error.captureStackTrace(i,dt),e.setHeader?(e[vx]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(Jo,t,i)):(e.destroy(i),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function Hd(t,e,r){if(e){let i=Dv(e)?e.size:Gv(e).length;t._socket?t._sender._bufferedBytes+=i:t._bufferedAmount+=i}if(r){let i=new Error(`WebSocket is not open: readyState ${t.readyState} (${nn[t.readyState]})`);process.nextTick(r,i)}}function Wv(t,e){let r=this[je];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[je]!==void 0&&(r._socket.removeListener("data",Zo),process.nextTick(Ix,r._socket),t===1005?r.close():r.close(t,e))}function Kv(){let t=this[je];t.isPaused||t._socket.resume()}function $v(t){let e=this[je];e._socket[je]!==void 0&&(e._socket.removeListener("data",Zo),process.nextTick(Ix,e._socket),e.close(t[Mv])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function yx(){this[je].emitClose()}function Yv(t,e){this[je].emit("message",t,e)}function Vv(t){let e=this[je];e._autoPong&&e.pong(t,!this._isServer,bx),e.emit("ping",t)}function Jv(t){this[je].emit("pong",t)}function Ix(t){t.resume()}function Zv(t){let e=this[je];e.readyState!==ge.CLOSED&&(e.readyState===ge.OPEN&&(e._readyState=ge.CLOSING,Ax(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function Ax(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function kx(){let t=this[je];if(this.removeListener("close",kx),this.removeListener("data",Zo),this.removeListener("end",Tx),t._readyState=ge.CLOSING,!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[je]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",yx),t._receiver.on("finish",yx))}function Zo(t){this[je]._receiver.write(t)||this.pause()}function Tx(){let t=this[je];t._readyState=ge.CLOSING,t._receiver.end(),this.end()}function Rx(){let t=this[je];this.removeListener("error",Rx),this.on("error",bx),t&&(t._readyState=ge.CLOSING,this.destroy())}});var Lx=ae((bC,Ox)=>{"use strict";var EC=Xo(),{Duplex:Xv}=fe("stream");function Px(t){t.emit("close")}function Qv(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Dx(t){this.removeListener("error",Dx),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function eS(t,e){let r=!0,i=new Xv({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(c,d){let u=!d&&i._readableState.objectMode?c.toString():c;i.push(u)||t.pause()}),t.once("error",function(c){i.destroyed||(r=!1,i.destroy(c))}),t.once("close",function(){i.destroyed||i.push(null)}),i._destroy=function(o,c){if(t.readyState===t.CLOSED){c(o),process.nextTick(Px,i);return}let d=!1;t.once("error",function(f){d=!0,c(f)}),t.once("close",function(){d||c(o),process.nextTick(Px,i)}),r&&t.terminate()},i._final=function(o){if(t.readyState===t.CONNECTING){t.once("open",function(){i._final(o)});return}t._socket!==null&&(t._socket._writableState.finished?(o(),i._readableState.endEmitted&&i.destroy()):(t._socket.once("finish",function(){o()}),t.close()))},i._read=function(){t.isPaused&&t.resume()},i._write=function(o,c,d){if(t.readyState===t.CONNECTING){t.once("open",function(){i._write(o,c,d)});return}t.send(o,d)},i.on("end",Qv),i.on("error",Dx),i}Ox.exports=eS});var qd=ae((vC,Nx)=>{"use strict";var{tokenChars:tS}=qr();function nS(t){let e=new Set,r=-1,i=-1,o=0;for(o;o<t.length;o++){let d=t.charCodeAt(o);if(i===-1&&tS[d]===1)r===-1&&(r=o);else if(o!==0&&(d===32||d===9))i===-1&&r!==-1&&(i=o);else if(d===44){if(r===-1)throw new SyntaxError(`Unexpected character at index ${o}`);i===-1&&(i=o);let u=t.slice(r,i);if(e.has(u))throw new SyntaxError(`The "${u}" subprotocol is duplicated`);e.add(u),r=i=-1}else throw new SyntaxError(`Unexpected character at index ${o}`)}if(r===-1||i!==-1)throw new SyntaxError("Unexpected end of input");let c=t.slice(r,o);if(e.has(c))throw new SyntaxError(`The "${c}" subprotocol is duplicated`);return e.add(c),e}Nx.exports={parse:nS}});var Hx=ae((IC,Gx)=>{"use strict";var rS=fe("events"),Qo=fe("http"),{Duplex:SC}=fe("stream"),{createHash:iS}=fe("crypto"),Mx=Yo(),Qn=Hr(),sS=qd(),oS=Xo(),{CLOSE_TIMEOUT:aS,GUID:cS,kWebSocket:dS}=Qt(),lS=/^[+/0-9A-Za-z]{22}==$/,Bx=0,Fx=1,Ux=2,jd=class extends rS{constructor(e,r){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:1024*1024,maxFragments:128*1024,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:aS,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:oS,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=Qo.createServer((i,o)=>{let c=Qo.STATUS_CODES[426];o.writeHead(426,{"Content-Length":c.length,"Content-Type":"text/plain"}),o.end(c)}),this._server.listen(e.port,e.host,e.backlog,r)):e.server&&(this._server=e.server),this._server){let i=this.emit.bind(this,"connection");this._removeListeners=uS(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(o,c,d)=>{this.handleUpgrade(o,c,d,i)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=Bx}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(this._state===Ux){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(rs,this);return}if(e&&this.once("close",e),this._state!==Fx)if(this._state=Fx,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(rs,this):process.nextTick(rs,this);else{let r=this._server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{rs(this)})}}shouldHandle(e){if(this.options.path){let r=e.url.indexOf("?");if((r!==-1?e.url.slice(0,r):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,r,i,o){r.on("error",zx);let c=e.headers["sec-websocket-key"],d=e.headers.upgrade,u=+e.headers["sec-websocket-version"];if(e.method!=="GET"){er(this,e,r,405,"Invalid HTTP method");return}if(d===void 0||d.toLowerCase()!=="websocket"){er(this,e,r,400,"Invalid Upgrade header");return}if(c===void 0||!lS.test(c)){er(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(u!==13&&u!==8){er(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){is(r,400);return}let f=e.headers["sec-websocket-protocol"],x=new Set;if(f!==void 0)try{x=sS.parse(f)}catch{er(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let g=e.headers["sec-websocket-extensions"],w={};if(this.options.perMessageDeflate&&g!==void 0){let S=new Qn({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let y=Mx.parse(g);y[Qn.extensionName]&&(S.accept(y[Qn.extensionName]),w[Qn.extensionName]=S)}catch{er(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let S={origin:e.headers[`${u===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(S,(y,v,I,A)=>{if(!y)return is(r,v||401,I,A);this.completeUpgrade(w,c,x,e,r,i,o)});return}if(!this.options.verifyClient(S))return is(r,401)}this.completeUpgrade(w,c,x,e,r,i,o)}completeUpgrade(e,r,i,o,c,d,u){if(!c.readable||!c.writable)return c.destroy();if(c[dS])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Bx)return is(c,503);let x=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${iS("sha1").update(r+cS).digest("base64")}`],g=new this.options.WebSocket(null,void 0,this.options);if(i.size){let w=this.options.handleProtocols?this.options.handleProtocols(i,o):i.values().next().value;w&&(x.push(`Sec-WebSocket-Protocol: ${w}`),g._protocol=w)}if(e[Qn.extensionName]){let w=e[Qn.extensionName].params,S=Mx.format({[Qn.extensionName]:[w]});x.push(`Sec-WebSocket-Extensions: ${S}`),g._extensions=e}this.emit("headers",x,o),c.write(x.concat(`\r
|
|
8
|
+
var qg=Object.create;var Da=Object.defineProperty;var jg=Object.getOwnPropertyDescriptor;var Wg=Object.getOwnPropertyNames;var Kg=Object.getPrototypeOf,$g=Object.prototype.hasOwnProperty;var xe=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var nt=(t,e)=>()=>(t&&(e=t(t=0)),e);var ce=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Oa=(t,e)=>{for(var n in e)Da(t,n,{get:e[n],enumerable:!0})},Vg=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Wg(e))!$g.call(t,o)&&o!==n&&Da(t,o,{get:()=>e[o],enumerable:!(i=jg(e,o))||i.enumerable});return t};var Gt=(t,e,n)=>(n=t!=null?qg(Kg(t)):{},Vg(e||!t||!t.__esModule?Da(n,"default",{value:t,enumerable:!0}):n,t));function Ze(t,e){let n=process.env[t];if(!n)return e;let i=Number(n);return Number.isFinite(i)&&i>0?i:e}var or=nt(()=>{"use strict"});import{createWriteStream as Jg,mkdirSync as Zg,readdirSync as Yg,unlinkSync as Xg}from"node:fs";import{join as Tl}from"node:path";function Cn(t){let e=n=>String(n).padStart(2,"0");return`${t.getFullYear()}-${e(t.getMonth()+1)}-${e(t.getDate())}`}function ar(t,e){return`${t}-${e}.log`}function La(t,e){let n=t.match(/^(.+)-(\d{4}-\d{2}-\d{2})\.log$/);return!n||n[1]!==e?null:n[2]??null}function Qg(t,e,n){let i=c=>{let[d,u,f]=c.split("-").map(Number);return Date.UTC(d??0,(u??1)-1,f??1)};return Math.floor((i(e)-i(t))/864e5)>n}function xs(t,e,n,i){let o;try{o=Yg(t)}catch{return}for(let c of o){let d=La(c,e);if(d&&Qg(d,n,i))try{Xg(Tl(t,c))}catch{}}}var ri,Na=nt(()=>{"use strict";ri=class{constructor(e,n,i){this.dir=e;this.prefix=n;this.opts=i;this.clock=i.clock??(()=>Cn(new Date))}dir;prefix;opts;currentDate;stream;clock;write(e){let n=this.clock();n!==this.currentDate&&this.rotate(n),this.stream?.write(e)}rotate(e){this.stream?.end();try{Zg(this.dir,{recursive:!0});let n=Jg(Tl(this.dir,ar(this.prefix,e)),{flags:"a"});n.on("error",i=>process.stderr.write(`[log-sink] stream error: ${String(i)}
|
|
9
|
+
`)),this.stream=n}catch(n){process.stderr.write(`[log-sink] rotate failed: ${String(n)}
|
|
10
|
+
`),this.stream=void 0;return}this.currentDate!==void 0&&xs(this.dir,this.prefix,e,this.opts.retentionDays),this.currentDate=e}close(){this.stream?.end(),this.stream=void 0,this.currentDate=void 0}}});import{appendFileSync as em,mkdirSync as tm}from"node:fs";import{join as nm}from"node:path";function Rl(t){let e=t.retentionDays??sm,n=t.clock??(()=>Cn(new Date));gs={bridgeSink:new ri(t.bridgeLogsDir,"bridge",{retentionDays:e,clock:n}),agentSinks:new Map,makeAgentSink:o=>new ri(t.agentLogsDir(o),"agent",{retentionDays:e,clock:n})};let i=n();xs(t.bridgeLogsDir,"bridge",i,e);for(let o of t.listAgentIds?.()??[])xs(t.agentLogsDir(o),"agent",i,e)}function om(t,e){let n=t.agentSinks.get(e);return n||(n=t.makeAgentSink(e),t.agentSinks.set(e,n)),n}function Cl(t){Ma=t}function Dl(t){return cr[Ma]<=cr[t]}function Ol(t,e){let n=cr[t];return n===void 0?!0:n>=cr[e]}function ms(t){Pl={...t}}function Ll(t){let e=(u,f=2)=>String(u).padStart(f,"0"),n=-t.getTimezoneOffset(),i=n>=0?"+":"-",o=Math.abs(n),c=e(Math.floor(o/60)),d=e(o%60);return`${Cn(t)}T${e(t.getHours())}:${e(t.getMinutes())}:${e(t.getSeconds())}.${e(t.getMilliseconds(),3)}${i}${c}:${d}`}function rt(t,e,n,i,o){try{let c=`${JSON.stringify({ts:Ll(new Date),level:e,module:n,msg:i,...o})}
|
|
11
|
+
`;tm(t,{recursive:!0}),em(nm(t,ar("bridge",Cn(new Date))),c)}catch{}}function am(t,e){if(t)return t;let n=e?.agentId;return typeof n=="string"&&n.length>0?n:void 0}function ps(t,e,n,i,o){if(cr[t]<cr[Ma])return;let c=`${JSON.stringify({ts:Ll(new Date),level:t,module:e,msg:n,...Pl,...i})}
|
|
12
|
+
`;if(gs){let d=am(o,i),u=d?om(gs,d):gs.bridgeSink;try{u.write(c)}catch{process.stderr.write(c)}return}t==="error"||t==="warn"?im.write(c):rm.write(c)}function q(t,e){return{debug:(n,i)=>ps("debug",t,n,i,e),info:(n,i)=>ps("info",t,n,i,e),warn:(n,i)=>ps("warn",t,n,i,e),error:(n,i)=>ps("error",t,n,i,e),child:n=>q(`${t}.${n}`,e),forAgent:n=>q(t,n)}}var cr,Ma,rm,im,Pl,sm,gs,ne=nt(()=>{"use strict";or();Na();cr={debug:10,info:20,warn:30,error:40},Ma=(()=>{let t=process.env.COZE_BRIDGE_LOG_LEVEL;return t==="debug"||t==="info"||t==="warn"||t==="error"?t:"info"})(),rm=process.stdout,im=process.stderr,Pl={},sm=Ze("COZE_BRIDGE_LOG_RETENTION_DAYS",30),gs=null});var k,$e=nt(()=>{"use strict";k=class extends Error{code;retriable;cause;constructor(e,n,i){super(n),this.name="BridgeError",this.code=e,this.retriable=i?.retriable??!1,i?.cause!==void 0&&(this.cause=i.cause)}}});var Fl={};Oa(Fl,{ACP_WRAPPER_NPM_PACKAGES:()=>ws,_resetAcpInstallerForTests:()=>hm,_setBinaryPathCacheForTests:()=>xm,buildAcpSpawn:()=>si,ensureAcpInstalled:()=>dr,getAcpBinaryPath:()=>_s,pickWhichLine:()=>za,probeAcpVersion:()=>fm,resolveAcpCommand:()=>Bl});import{readFileSync as Nl}from"node:fs";import{createRequire as cm}from"node:module";import{dirname as dm,resolve as lm}from"node:path";function za(t){let e=t.split(/\r?\n/).map(i=>i.trim()).filter(Boolean);if(e.length===0)return;if(process.platform!=="win32")return e[0];let n=i=>e.find(o=>o.toLowerCase().endsWith(i));return n(".cmd")??n(".exe")??n(".bat")??n(".ps1")??e[0]}function um(t){let e=Ml.resolve(`${t.npmPackage}/package.json`),n=dm(e),i=JSON.parse(Nl(e,"utf8")),o=typeof i.bin=="string"?i.bin:i.bin?.[t.binary];if(!o)throw new Error(`${t.npmPackage} package.json \u7F3A bin[${t.binary}]`);return lm(n,o)}async function dr(t,e){let n=Fa[t];if(!n)throw new k("BRIDGE_INTERNAL",`ensureAcpInstalled called for non-npm framework: ${t}`);let i=ii.get(t);if(i)return i;try{let o=um(n);return ii.set(t,o),Ba.info("acp wrapper resolved",{framework:t,binary:n.binary,path:o}),o}catch(o){throw Ba.warn("acp wrapper \u89E3\u6790\u5931\u8D25 (\u672A\u968F\u5305\u56FA\u5316\u5230 lib/node_modules?)",{framework:t,npmPackage:n.npmPackage,err:String(o)}),new k("AGENT_DEPENDENCY_INSTALL_FAILED",[`ACP wrapper \u672A\u5C31\u7EEA: ${n.npmPackage} (framework=${t})`,"\u8BE5 wrapper \u968F coze-bridge \u4E00\u8D77\u5B89\u88C5 (\u56FA\u5316\u5230 ~/.coze/bridge/lib/node_modules)\u3002","\u8BF7\u91CD\u8DD1 `coze-bridge pair` / `connect` \u89E6\u53D1\u56FA\u5316\u5B89\u88C5; \u82E5\u4ECD\u5931\u8D25, \u68C0\u67E5\u7F51\u7EDC / npm \u7F13\u5B58\u3002"].join(`
|
|
13
|
+
`),{cause:o})}}async function fm(t){let e=Fa[t];if(e)try{let n=Ml.resolve(`${e.npmPackage}/package.json`),i=JSON.parse(Nl(n,"utf8"));return typeof i.version=="string"&&i.version.length>0?i.version:void 0}catch(n){Ba.warn("acp wrapper probe: \u89E3\u6790 package.json \u5931\u8D25",{framework:t,npmPackage:e.npmPackage,err:String(n)});return}}function _s(t){return ii.get(t)}function Bl(t,e){if(e)return e;let n=_s(t);if(!n)throw new k("BRIDGE_INTERNAL",`${t} ACP wrapper \u8DEF\u5F84\u672A\u89E3\u6790 (ensureAcpInstalled \u672A\u5728\u6784\u9020\u524D\u8DD1\u901A)`);return n}function si(t,e,n){if(e)return{command:e,args:[...n]};let i=Bl(t);return{command:process.execPath,args:[i,...n]}}function hm(){ii.clear()}function xm(t,e){ii.set(t,e)}var Ba,Fa,ws,Ml,ii,dn=nt(()=>{"use strict";$e();ne();Ba=q("agents.acp-installer"),Fa={"claude-code":{npmPackage:"@agentclientprotocol/claude-agent-acp",binary:"claude-agent-acp"},codex:{npmPackage:"@agentclientprotocol/codex-acp",binary:"codex-acp"}},ws=Object.values(Fa).filter(t=>t!==void 0).map(t=>t.npmPackage),Ml=cm(import.meta.url),ii=new Map});import{chmod as gm,mkdir as mm,readFile as wm,rename as _m,rm as ym,writeFile as Em}from"node:fs/promises";import{dirname as bm}from"node:path";async function lr(t){try{let e=await wm(t,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function ut(t,e,n){await mm(bm(t),{recursive:!0});let i=`${t}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{await Em(i,e,{encoding:"utf8",mode:n?.mode}),await _m(i,t),n?.mode!==void 0&&await gm(t,n.mode)}catch(o){throw await ym(i,{force:!0}).catch(()=>{}),o}}async function ur(t,e,n){await ut(t,`${JSON.stringify(e,null,2)}
|
|
14
|
+
`,n)}var Ht=nt(()=>{"use strict"});import{promises as Gl,readdirSync as vm}from"node:fs";import{homedir as Sm}from"node:os";import{sep as Im,join as Pe,resolve as Hl}from"node:path";function Y(t){let e=t??Sm(),n=Pe(e,".coze"),i=Pe(n,"bridge"),o=Pe(i,"lib"),c=Pe(i,"logs");return{cozeRoot:n,bridgeRoot:i,libDir:o,libEntry:Pe(o,"index.js"),binDir:Pe(i,"bin"),pidFile:Pe(i,"bridge.pid"),portFile:Pe(i,"bridge.port"),tokenFile:Pe(i,"bridge.token"),patTokenFile:Pe(i,"pat-token"),agentEnvFile:Pe(i,"agent-env.json"),logFile:Pe(i,"bridge.log"),bridgeLogsDir:c,daemonStdioLog:Pe(c,"daemon-stdio.log"),installLock:Pe(i,"install.lock"),configFile:Pe(i,"config.json"),agentsRoot:Pe(n,"agents")}}function ze(t,e=Y()){let n=Pe(e.agentsRoot,t);return{root:n,config:Pe(n,"config.json"),workspace:Pe(n,"workspace"),logs:Pe(n,"logs")}}function ys(t=Y()){try{return vm(t.agentsRoot,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name)}catch{return[]}}async function oi(t,e){let n=await Gl.realpath(Hl(t)).catch(()=>null);if(!n)return!1;let i=await Gl.realpath(Hl(e)).catch(()=>null);if(!i)return!1;let o=process.platform==="win32"?n.toLowerCase():n,c=process.platform==="win32"?i.toLowerCase():i;return o===c||o.startsWith(c+Im)}var Re=nt(()=>{"use strict"});var bs={};Oa(bs,{AGENT_CONFIG_FILE_MODE:()=>Es,enforceAgentConfigMode:()=>Tm,loadAgentConfig:()=>Se,persistAgentSessions:()=>ai,persistAgentSkills:()=>ci,saveAgentConfig:()=>Ue});import{chmod as Am,stat as km}from"node:fs/promises";function Se(t,e){return lr(ze(t,e).config)}function Ue(t,e){return ur(ze(t.agentId,e).config,t,{mode:Es})}async function Tm(t,e){if(process.platform==="win32")return;let n=ze(t,e).config;try{let i=await km(n);if(!i.isFile())return;let o=i.mode&511;o!==Es&&(await Am(n,Es),ql.warn("agent config mode auto-corrected to 0600",{path:n,from:o.toString(8)}))}catch(i){if(i.code==="ENOENT")return;ql.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:n,err:String(i)})}}async function ai(t,e,n){let i=await Se(t,n);i&&(i.sessions=Object.fromEntries(e),await Ue(i,n))}async function ci(t,e,n){let i=await Se(t,n);i&&(i.skills=e,await Ue(i,n))}var ql,Es,qt=nt(()=>{"use strict";Ht();ne();Re();ql=q("agent-config"),Es=384});var Ha=ce((A2,Kl)=>{Kl.exports={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,END64HDR:20,END64SIG:117853008,END64START:4,END64OFF:8,END64NUMDISKS:16,ZIP64SIG:101075792,ZIP64HDR:56,ZIP64LEAD:12,ZIP64SIZE:4,ZIP64VEM:12,ZIP64VER:14,ZIP64DSK:16,ZIP64DSKDIR:20,ZIP64SUB:24,ZIP64TOT:32,ZIP64SIZB:40,ZIP64OFF:48,ZIP64EXTRA:56,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,AES_ENCRYPT:99,FLG_ENC:1,FLG_COMP1:2,FLG_COMP2:4,FLG_DESC:8,FLG_ENH:16,FLG_PATCH:32,FLG_STR:64,FLG_EFS:2048,FLG_MSK:4096,FILE:2,BUFFER:1,NONE:0,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24}});var Ss=ce(Vl=>{var $l={INVALID_LOC:"Invalid LOC header (bad signature)",INVALID_CEN:"Invalid CEN header (bad signature)",INVALID_END:"Invalid END header (bad signature)",DESCRIPTOR_NOT_EXIST:"No descriptor present",DESCRIPTOR_UNKNOWN:"Unknown descriptor format",DESCRIPTOR_FAULTY:"Descriptor data is malformed",NO_DATA:"Nothing to decompress",BAD_CRC:"CRC32 checksum failed {0}",FILE_IN_THE_WAY:"There is a file in the way: {0}",UNKNOWN_METHOD:"Invalid/unsupported compression method",AVAIL_DATA:"inflate::Available inflate data did not terminate",INVALID_DISTANCE:"inflate::Invalid literal/length or distance code in fixed or dynamic block",TO_MANY_CODES:"inflate::Dynamic block code description: too many length or distance codes",INVALID_REPEAT_LEN:"inflate::Dynamic block code description: repeat more than specified lengths",INVALID_REPEAT_FIRST:"inflate::Dynamic block code description: repeat lengths with no first length",INCOMPLETE_CODES:"inflate::Dynamic block code description: code lengths codes incomplete",INVALID_DYN_DISTANCE:"inflate::Dynamic block code description: invalid distance code lengths",INVALID_CODES_LEN:"inflate::Dynamic block code description: invalid literal/length code lengths",INVALID_STORE_BLOCK:"inflate::Stored block length did not match one's complement",INVALID_BLOCK_TYPE:"inflate::Invalid block type (type == 3)",CANT_EXTRACT_FILE:"Could not extract the file",CANT_OVERRIDE:"Target file already exists",DISK_ENTRY_TOO_LARGE:"Number of disk entries is too large",NO_ZIP:"No zip file was loaded",NO_ENTRY:"Entry doesn't exist",DIRECTORY_CONTENT_ERROR:"A directory cannot have content",FILE_NOT_FOUND:'File not found: "{0}"',NOT_IMPLEMENTED:"Not implemented",INVALID_FILENAME:"Invalid filename",INVALID_FORMAT:"Invalid or unsupported zip format. No END header found",INVALID_PASS_PARAM:"Incompatible password parameter",WRONG_PASSWORD:"Wrong Password",COMMENT_TOO_LONG:"Comment is too long",EXTRA_FIELD_PARSE_ERROR:"Extra field parsing error"};function Lm(t){return function(...e){return e.length&&(t=t.replace(/\{(\d)\}/g,(n,i)=>e[i]||"")),new Error("ADM-ZIP: "+t)}}for(let t of Object.keys($l))Vl[t]=Lm($l[t])});var Ql=ce((T2,Xl)=>{var Nm=xe("fs"),Me=xe("path"),Jl=Ha(),Mm=Ss(),Bm=typeof process=="object"&&process.platform==="win32",Zl=t=>typeof t=="object"&&t!==null,Yl=new Uint32Array(256).map((t,e)=>{for(let n=0;n<8;n++)(e&1)!==0?e=3988292384^e>>>1:e>>>=1;return e>>>0});function Ie(t){this.sep=Me.sep,this.fs=Nm,Zl(t)&&Zl(t.fs)&&typeof t.fs.statSync=="function"&&(this.fs=t.fs)}Xl.exports=Ie;Ie.prototype.makeDir=function(t){let e=this;function n(i){let o=i.split(e.sep)[0];i.split(e.sep).forEach(function(c){if(!(!c||c.substr(-1,1)===":")){o+=e.sep+c;var d;try{d=e.fs.statSync(o)}catch(u){if(u.message&&u.message.startsWith("ENOENT"))e.fs.mkdirSync(o);else throw u}if(d&&d.isFile())throw Mm.FILE_IN_THE_WAY(`"${o}"`)}})}n(t)};Ie.prototype.writeFileTo=function(t,e,n,i){let o=this;if(o.fs.existsSync(t)){if(!n)return!1;var c=o.fs.statSync(t);if(c.isDirectory())return!1}var d=Me.dirname(t);o.fs.existsSync(d)||o.makeDir(d);var u;try{u=o.fs.openSync(t,"w",438)}catch{o.fs.chmodSync(t,438),u=o.fs.openSync(t,"w",438)}if(u)try{o.fs.writeSync(u,e,0,e.length,0)}finally{o.fs.closeSync(u)}return o.fs.chmodSync(t,i||438),!0};Ie.prototype.writeFileToAsync=function(t,e,n,i,o){typeof i=="function"&&(o=i,i=void 0);let c=this;c.fs.exists(t,function(d){if(d&&!n)return o(!1);c.fs.stat(t,function(u,f){if(d&&f.isDirectory())return o(!1);var x=Me.dirname(t);c.fs.exists(x,function(m){m||c.makeDir(x),c.fs.open(t,"w",438,function(_,v){_?c.fs.chmod(t,438,function(){c.fs.open(t,"w",438,function(y,b){c.fs.write(b,e,0,e.length,0,function(){c.fs.close(b,function(){c.fs.chmod(t,i||438,function(){o(!0)})})})})}):v?c.fs.write(v,e,0,e.length,0,function(){c.fs.close(v,function(){c.fs.chmod(t,i||438,function(){o(!0)})})}):c.fs.chmod(t,i||438,function(){o(!0)})})})})})};Ie.prototype.findFiles=function(t){let e=this;function n(i,o,c){typeof o=="boolean"&&(c=o,o=void 0);let d=[];return e.fs.readdirSync(i).forEach(function(u){let f=Me.join(i,u),x=e.fs.statSync(f);(!o||o.test(f))&&d.push(Me.normalize(f)+(x.isDirectory()?e.sep:"")),x.isDirectory()&&c&&(d=d.concat(n(f,o,c)))}),d}return n(t,void 0,!0)};Ie.prototype.findFilesAsync=function(t,e){let n=this,i=[];n.fs.readdir(t,function(o,c){if(o)return e(o);let d=c.length;if(!d)return e(null,i);c.forEach(function(u){u=Me.join(t,u),n.fs.stat(u,function(f,x){if(f)return e(f);x&&(i.push(Me.normalize(u)+(x.isDirectory()?n.sep:"")),x.isDirectory()?n.findFilesAsync(u,function(m,_){if(m)return e(m);i=i.concat(_),--d||e(null,i)}):--d||e(null,i))})})})};Ie.prototype.getAttributes=function(){};Ie.prototype.setAttributes=function(){};Ie.crc32update=function(t,e){return Yl[(t^e)&255]^t>>>8};Ie.crc32=function(t){typeof t=="string"&&(t=Buffer.from(t,"utf8"));let e=t.length,n=-1;for(let i=0;i<e;)n=Ie.crc32update(n,t[i++]);return~n>>>0};Ie.methodToString=function(t){switch(t){case Jl.STORED:return"STORED ("+t+")";case Jl.DEFLATED:return"DEFLATED ("+t+")";default:return"UNSUPPORTED ("+t+")"}};Ie.canonical=function(t){if(!t)return"";let e=Me.posix.normalize("/"+t.split("\\").join("/"));return Me.join(".",e)};Ie.zipnamefix=function(t){if(!t)return"";let e=Me.posix.normalize("/"+t.split("\\").join("/"));return Me.posix.join(".",e)};Ie.findLast=function(t,e){if(!Array.isArray(t))throw new TypeError("arr is not array");let n=t.length>>>0;for(let i=n-1;i>=0;i--)if(e(t[i],i,t))return t[i]};Ie.sanitize=function(t,e){t=Me.resolve(Me.normalize(t));for(var n=e.split("/"),i=0,o=n.length;i<o;i++){var c=Me.normalize(Me.join(t,n.slice(i,o).join(Me.sep)));if(c.indexOf(t)===0)return c}return Me.normalize(Me.join(t,Me.basename(e)))};Ie.toBuffer=function(e,n){return Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e):typeof e=="string"?n(e):Buffer.alloc(0)};Ie.readBigUInt64LE=function(t,e){let n=t.readUInt32LE(e);return t.readUInt32LE(e+4)*4294967296+n};Ie.fromDOS2Date=function(t){return new Date((t>>25&127)+1980,Math.max((t>>21&15)-1,0),Math.max(t>>16&31,1),t>>11&31,t>>5&63,(t&31)<<1)};Ie.fromDate2DOS=function(t){let e=0,n=0;return t.getFullYear()>1979&&(e=(t.getFullYear()-1980&127)<<9|t.getMonth()+1<<5|t.getDate(),n=t.getHours()<<11|t.getMinutes()<<5|t.getSeconds()>>1),e<<16|n};Ie.isWin=Bm;Ie.crcTable=Yl});var tu=ce((P2,eu)=>{var Fm=xe("path");eu.exports=function(t,{fs:e}){var n=t||"",i=c(),o=null;function c(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}return n&&e.existsSync(n)?(o=e.statSync(n),i.directory=o.isDirectory(),i.mtime=o.mtime,i.atime=o.atime,i.executable=(73&o.mode)!==0,i.readonly=(128&o.mode)===0,i.hidden=Fm.basename(n)[0]==="."):console.warn("Invalid path: "+n),{get directory(){return i.directory},get readOnly(){return i.readonly},get hidden(){return i.hidden},get mtime(){return i.mtime},get atime(){return i.atime},get executable(){return i.executable},decodeAttributes:function(){},encodeAttributes:function(){},toJSON:function(){return{path:n,isDirectory:i.directory,isReadOnly:i.readonly,isHidden:i.hidden,isExecutable:i.executable,mTime:i.mtime,aTime:i.atime}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var ru=ce((R2,nu)=>{nu.exports={efs:!0,encode:t=>Buffer.from(t,"utf8"),decode:t=>t.toString("utf8")}});var xr=ce((C2,hr)=>{hr.exports=Ql();hr.exports.Constants=Ha();hr.exports.Errors=Ss();hr.exports.FileAttr=tu();hr.exports.decoder=ru()});var su=ce((D2,iu)=>{var ln=xr(),G=ln.Constants;iu.exports=function(){var t=20,e=10,n=0,i=0,o=0,c=0,d=0,u=0,f=0,x=0,m=0,_=0,v=0,y=0,b=0;t|=ln.isWin?2560:768,n|=G.FLG_EFS;let I={extraLen:0},A=E=>Math.max(0,E)>>>0,P=E=>Math.max(0,E)&65535,D=E=>Math.max(0,E)&255;return o=ln.fromDate2DOS(new Date),{get made(){return t},set made(E){t=E},get version(){return e},set version(E){e=E},get flags(){return n},set flags(E){n=E},get flags_efs(){return(n&G.FLG_EFS)>0},set flags_efs(E){E?n|=G.FLG_EFS:n&=~G.FLG_EFS},get flags_desc(){return(n&G.FLG_DESC)>0},set flags_desc(E){E?n|=G.FLG_DESC:n&=~G.FLG_DESC},get method(){return i},set method(E){switch(E){case G.STORED:this.version=10;case G.DEFLATED:default:this.version=20}i=E},get time(){return ln.fromDOS2Date(this.timeval)},set time(E){E=new Date(E),this.timeval=ln.fromDate2DOS(E)},get timeval(){return o},set timeval(E){o=A(E)},get timeHighByte(){return D(o>>>8)},get crc(){return c},set crc(E){c=A(E)},get compressedSize(){return d},set compressedSize(E){d=A(E)},get size(){return u},set size(E){u=A(E)},get fileNameLength(){return f},set fileNameLength(E){f=E},get extraLength(){return x},set extraLength(E){x=E},get extraLocalLength(){return I.extraLen},set extraLocalLength(E){I.extraLen=E},get commentLength(){return m},set commentLength(E){m=E},get diskNumStart(){return _},set diskNumStart(E){_=A(E)},get inAttr(){return v},set inAttr(E){v=A(E)},get attr(){return y},set attr(E){y=A(E)},get fileAttr(){return(y||0)>>16&4095},get offset(){return b},set offset(E){b=A(E)},get encrypted(){return(n&G.FLG_ENC)===G.FLG_ENC},get centralHeaderSize(){return G.CENHDR+f+x+m},get realDataOffset(){return b+G.LOCHDR+I.fnameLen+I.extraLen},get localHeader(){return I},loadLocalHeaderFromBinary:function(E){var C=E.slice(b,b+G.LOCHDR);if(C.readUInt32LE(0)!==G.LOCSIG)throw ln.Errors.INVALID_LOC();I.version=C.readUInt16LE(G.LOCVER),I.flags=C.readUInt16LE(G.LOCFLG),I.flags_desc=(I.flags&G.FLG_DESC)>0,I.method=C.readUInt16LE(G.LOCHOW),I.time=C.readUInt32LE(G.LOCTIM),I.crc=C.readUInt32LE(G.LOCCRC),I.compressedSize=C.readUInt32LE(G.LOCSIZ),I.size=C.readUInt32LE(G.LOCLEN),I.fnameLen=C.readUInt16LE(G.LOCNAM),I.extraLen=C.readUInt16LE(G.LOCEXT);let L=b+G.LOCHDR+I.fnameLen,F=L+I.extraLen;return E.slice(L,F)},loadFromBinary:function(E){if(E.length!==G.CENHDR||E.readUInt32LE(0)!==G.CENSIG)throw ln.Errors.INVALID_CEN();t=E.readUInt16LE(G.CENVEM),e=E.readUInt16LE(G.CENVER),n=E.readUInt16LE(G.CENFLG),i=E.readUInt16LE(G.CENHOW),o=E.readUInt32LE(G.CENTIM),c=E.readUInt32LE(G.CENCRC),d=E.readUInt32LE(G.CENSIZ),u=E.readUInt32LE(G.CENLEN),f=E.readUInt16LE(G.CENNAM),x=E.readUInt16LE(G.CENEXT),m=E.readUInt16LE(G.CENCOM),_=E.readUInt16LE(G.CENDSK),v=E.readUInt16LE(G.CENATT),y=E.readUInt32LE(G.CENATX),b=E.readUInt32LE(G.CENOFF)},localHeaderToBinary:function(){var E=Buffer.alloc(G.LOCHDR);return E.writeUInt32LE(G.LOCSIG,0),E.writeUInt16LE(e,G.LOCVER),E.writeUInt16LE(n,G.LOCFLG),E.writeUInt16LE(i,G.LOCHOW),E.writeUInt32LE(o,G.LOCTIM),E.writeUInt32LE(c,G.LOCCRC),E.writeUInt32LE(d,G.LOCSIZ),E.writeUInt32LE(u,G.LOCLEN),E.writeUInt16LE(f,G.LOCNAM),E.writeUInt16LE(I.extraLen,G.LOCEXT),E},centralHeaderToBinary:function(){var E=Buffer.alloc(G.CENHDR+f+x+m);return E.writeUInt32LE(G.CENSIG,0),E.writeUInt16LE(t,G.CENVEM),E.writeUInt16LE(e,G.CENVER),E.writeUInt16LE(n,G.CENFLG),E.writeUInt16LE(i,G.CENHOW),E.writeUInt32LE(o,G.CENTIM),E.writeUInt32LE(c,G.CENCRC),E.writeUInt32LE(d,G.CENSIZ),E.writeUInt32LE(u,G.CENLEN),E.writeUInt16LE(f,G.CENNAM),E.writeUInt16LE(x,G.CENEXT),E.writeUInt16LE(m,G.CENCOM),E.writeUInt16LE(_,G.CENDSK),E.writeUInt16LE(v,G.CENATT),E.writeUInt32LE(y,G.CENATX),E.writeUInt32LE(b,G.CENOFF),E},toJSON:function(){let E=function(C){return C+" bytes"};return{made:t,version:e,flags:n,method:ln.methodToString(i),time:this.time,crc:"0x"+c.toString(16).toUpperCase(),compressedSize:E(d),size:E(u),fileNameLength:E(f),extraLength:E(x),commentLength:E(m),diskNumStart:_,inAttr:v,attr:y,offset:b,centralHeaderSize:E(G.CENHDR+f+x+m)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var au=ce((O2,ou)=>{var pr=xr(),Ee=pr.Constants;ou.exports=function(){var t=0,e=0,n=0,i=0,o=0;return{get diskEntries(){return t},set diskEntries(c){t=e=c},get totalEntries(){return e},set totalEntries(c){e=t=c},get size(){return n},set size(c){n=c},get offset(){return i},set offset(c){i=c},get commentLength(){return o},set commentLength(c){o=c},get mainHeaderSize(){return Ee.ENDHDR+o},loadFromBinary:function(c){if((c.length!==Ee.ENDHDR||c.readUInt32LE(0)!==Ee.ENDSIG)&&(c.length<Ee.ZIP64HDR||c.readUInt32LE(0)!==Ee.ZIP64SIG))throw pr.Errors.INVALID_END();c.readUInt32LE(0)===Ee.ENDSIG?(t=c.readUInt16LE(Ee.ENDSUB),e=c.readUInt16LE(Ee.ENDTOT),n=c.readUInt32LE(Ee.ENDSIZ),i=c.readUInt32LE(Ee.ENDOFF),o=c.readUInt16LE(Ee.ENDCOM)):(t=pr.readBigUInt64LE(c,Ee.ZIP64SUB),e=pr.readBigUInt64LE(c,Ee.ZIP64TOT),n=pr.readBigUInt64LE(c,Ee.ZIP64SIZE),i=pr.readBigUInt64LE(c,Ee.ZIP64OFF),o=0)},toBinary:function(){var c=Buffer.alloc(Ee.ENDHDR+o);return c.writeUInt32LE(Ee.ENDSIG,0),c.writeUInt32LE(0,4),c.writeUInt16LE(t,Ee.ENDSUB),c.writeUInt16LE(e,Ee.ENDTOT),c.writeUInt32LE(n,Ee.ENDSIZ),c.writeUInt32LE(i,Ee.ENDOFF),c.writeUInt16LE(o,Ee.ENDCOM),c.fill(" ",Ee.ENDHDR),c},toJSON:function(){let c=function(d,u){let f=d.toString(16).toUpperCase();for(;f.length<u;)f="0"+f;return"0x"+f};return{diskEntries:t,totalEntries:e,size:n+" bytes",offset:c(i,4),commentLength:o}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var ja=ce(qa=>{qa.EntryHeader=su();qa.MainHeader=au()});var du=ce((N2,cu)=>{cu.exports=function(t){var e=xe("zlib"),n={chunkSize:(parseInt(t.length/1024)+1)*1024};return{deflate:function(){return e.deflateRawSync(t,n)},deflateAsync:function(i){var o=e.createDeflateRaw(n),c=[],d=0;o.on("data",function(u){c.push(u),d+=u.length}),o.on("end",function(){var u=Buffer.alloc(d),f=0;u.fill(0);for(var x=0;x<c.length;x++){var m=c[x];m.copy(u,f),f+=m.length}i&&i(u)}),o.end(t)}}}});var uu=ce((M2,lu)=>{var zm=+(process.versions?process.versions.node:"").split(".")[0]||0;lu.exports=function(t,e){var n=xe("zlib");let i=zm>=15&&e>0?{maxOutputLength:e}:{};return{inflate:function(){return n.inflateRawSync(t,i)},inflateAsync:function(o){var c=n.createInflateRaw(i),d=[],u=0;c.on("data",function(f){d.push(f),u+=f.length}),c.on("end",function(){var f=Buffer.alloc(u),x=0;f.fill(0);for(var m=0;m<d.length;m++){var _=d[m];_.copy(f,x),x+=_.length}o&&o(f)}),c.end(t)}}}});var gu=ce((B2,pu)=>{"use strict";var{randomFillSync:fu}=xe("crypto"),Um=Ss(),Gm=new Uint32Array(256).map((t,e)=>{for(let n=0;n<8;n++)(e&1)!==0?e=e>>>1^3988292384:e>>>=1;return e>>>0}),xu=(t,e)=>Math.imul(t,e)>>>0,hu=(t,e)=>Gm[(t^e)&255]^t>>>8,di=()=>typeof fu=="function"?fu(Buffer.alloc(12)):di.node();di.node=()=>{let t=Buffer.alloc(12),e=t.length;for(let n=0;n<e;n++)t[n]=Math.random()*256&255;return t};var Is={genSalt:di};function As(t){let e=Buffer.isBuffer(t)?t:Buffer.from(t);this.keys=new Uint32Array([305419896,591751049,878082192]);for(let n=0;n<e.length;n++)this.updateKeys(e[n])}As.prototype.updateKeys=function(t){let e=this.keys;return e[0]=hu(e[0],t),e[1]+=e[0]&255,e[1]=xu(e[1],134775813)+1,e[2]=hu(e[2],e[1]>>>24),t};As.prototype.next=function(){let t=(this.keys[2]|2)>>>0;return xu(t,t^1)>>8&255};function Hm(t){let e=new As(t);return function(n){let i=Buffer.alloc(n.length),o=0;for(let c of n)i[o++]=e.updateKeys(c^e.next());return i}}function qm(t){let e=new As(t);return function(n,i,o=0){i||(i=Buffer.alloc(n.length));for(let c of n){let d=e.next();i[o++]=c^d,e.updateKeys(c)}return i}}function jm(t,e,n){if(!t||!Buffer.isBuffer(t)||t.length<12)return Buffer.alloc(0);let i=Hm(n),o=i(t.slice(0,12)),c=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(o[11]!==c)throw Um.WRONG_PASSWORD();return i(t.slice(12))}function Wm(t){Buffer.isBuffer(t)&&t.length>=12?Is.genSalt=function(){return t.slice(0,12)}:t==="node"?Is.genSalt=di.node:Is.genSalt=di}function Km(t,e,n,i=!1){t==null&&(t=Buffer.alloc(0)),Buffer.isBuffer(t)||(t=Buffer.from(t.toString()));let o=qm(n),c=Is.genSalt();c[11]=e.crc>>>24&255,i&&(c[10]=e.crc>>>16&255);let d=Buffer.alloc(t.length+12);return o(c,d),o(t,d,12)}pu.exports={decrypt:jm,encrypt:Km,_salter:Wm}});var mu=ce(ks=>{ks.Deflater=du();ks.Inflater=uu();ks.ZipCrypto=gu()});var Ka=ce((z2,wu)=>{var de=xr(),$m=ja(),Ae=de.Constants,Wa=mu();wu.exports=function(t,e){var n=new $m.EntryHeader,i=Buffer.alloc(0),o=Buffer.alloc(0),c=!1,d=null,u=Buffer.alloc(0),f=Buffer.alloc(0),x=!0;let m=t,_=typeof m.decoder=="object"?m.decoder:de.decoder;x=_.hasOwnProperty("efs")?_.efs:!1;function v(){return!e||!(e instanceof Uint8Array)?Buffer.alloc(0):(f=n.loadLocalHeaderFromBinary(e),e.slice(n.realDataOffset,n.realDataOffset+n.compressedSize))}function y(E){if(!n.flags_desc&&!n.localHeader.flags_desc){if(de.crc32(E)!==n.localHeader.crc)return!1}else{let C={},L=n.realDataOffset+n.compressedSize;if(e.readUInt32LE(L)==Ae.LOCSIG||e.readUInt32LE(L)==Ae.CENSIG)throw de.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(L)==Ae.EXTSIG)C.crc=e.readUInt32LE(L+Ae.EXTCRC),C.compressedSize=e.readUInt32LE(L+Ae.EXTSIZ),C.size=e.readUInt32LE(L+Ae.EXTLEN);else if(e.readUInt16LE(L+12)===19280)C.crc=e.readUInt32LE(L+Ae.EXTCRC-4),C.compressedSize=e.readUInt32LE(L+Ae.EXTSIZ-4),C.size=e.readUInt32LE(L+Ae.EXTLEN-4);else throw de.Errors.DESCRIPTOR_UNKNOWN();if(C.compressedSize!==n.compressedSize||C.size!==n.size||C.crc!==n.crc)throw de.Errors.DESCRIPTOR_FAULTY();if(de.crc32(E)!==C.crc)return!1}return!0}function b(E,C,L){if(typeof C>"u"&&typeof E=="string"&&(L=E,E=void 0),c)return E&&C&&C(Buffer.alloc(0),de.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var F=v();if(F.length===0)return E&&C&&C(F),F;if(n.encrypted){if(typeof L!="string"&&!Buffer.isBuffer(L))throw de.Errors.INVALID_PASS_PARAM();F=Wa.ZipCrypto.decrypt(F,n,L)}var B=Buffer.alloc(n.size);switch(n.method){case de.Constants.STORED:if(F.copy(B),y(B))return E&&C&&C(B),B;throw E&&C&&C(B,de.Errors.BAD_CRC()),de.Errors.BAD_CRC();case de.Constants.DEFLATED:var Z=new Wa.Inflater(F,n.size);if(E)Z.inflateAsync(function(J){J.copy(J,0),C&&(y(J)?C(J):C(J,de.Errors.BAD_CRC()))});else{if(Z.inflate(B).copy(B,0),!y(B))throw de.Errors.BAD_CRC(`"${_.decode(i)}"`);return B}break;default:throw E&&C&&C(Buffer.alloc(0),de.Errors.UNKNOWN_METHOD()),de.Errors.UNKNOWN_METHOD()}}function I(E,C){if((!d||!d.length)&&Buffer.isBuffer(e))return E&&C&&C(v()),v();if(d.length&&!c){var L;switch(n.method){case de.Constants.STORED:return n.compressedSize=n.size,L=Buffer.alloc(d.length),d.copy(L),E&&C&&C(L),L;default:case de.Constants.DEFLATED:var F=new Wa.Deflater(d);if(E)F.deflateAsync(function(Z){L=Buffer.alloc(Z.length),n.compressedSize=Z.length,Z.copy(L),C&&C(L)});else{var B=F.deflate();return n.compressedSize=B.length,B}F=null;break}}else if(E&&C)C(Buffer.alloc(0));else return Buffer.alloc(0)}function A(E,C){return de.readBigUInt64LE(E,C)}function P(E){try{for(var C=0,L,F,B;C+4<E.length;)L=E.readUInt16LE(C),C+=2,F=E.readUInt16LE(C),C+=2,B=E.slice(C,C+F),C+=F,Ae.ID_ZIP64===L&&D(B)}catch{throw de.Errors.EXTRA_FIELD_PARSE_ERROR()}}function D(E){var C,L,F,B;E.length>=Ae.EF_ZIP64_SCOMP&&(C=A(E,Ae.EF_ZIP64_SUNCOMP),n.size===Ae.EF_ZIP64_OR_32&&(n.size=C)),E.length>=Ae.EF_ZIP64_RHO&&(L=A(E,Ae.EF_ZIP64_SCOMP),n.compressedSize===Ae.EF_ZIP64_OR_32&&(n.compressedSize=L)),E.length>=Ae.EF_ZIP64_DSN&&(F=A(E,Ae.EF_ZIP64_RHO),n.offset===Ae.EF_ZIP64_OR_32&&(n.offset=F)),E.length>=Ae.EF_ZIP64_DSN+4&&(B=E.readUInt32LE(Ae.EF_ZIP64_DSN),n.diskNumStart===Ae.EF_ZIP64_OR_16&&(n.diskNumStart=B))}return{get entryName(){return _.decode(i)},get rawEntryName(){return i},set entryName(E){i=de.toBuffer(E,_.encode);var C=i[i.length-1];c=C===47||C===92,n.fileNameLength=i.length},get efs(){return typeof x=="function"?x(this.entryName):x},get extra(){return u},set extra(E){u=E,n.extraLength=E.length,P(E)},get comment(){return _.decode(o)},set comment(E){if(o=de.toBuffer(E,_.encode),n.commentLength=o.length,o.length>65535)throw de.Errors.COMMENT_TOO_LONG()},get name(){var E=_.decode(i);return c?E.substr(E.length-1).split("/").pop():E.split("/").pop()},get isDirectory(){return c},getCompressedData:function(){return I(!1,null)},getCompressedDataAsync:function(E){I(!0,E)},setData:function(E){d=de.toBuffer(E,de.decoder.encode),!c&&d.length?(n.size=d.length,n.method=de.Constants.DEFLATED,n.crc=de.crc32(E),n.changed=!0):n.method=de.Constants.STORED},getData:function(E){return n.changed?d:b(!1,null,E)},getDataAsync:function(E,C){n.changed?E(d):b(!0,E,C)},set attr(E){n.attr=E},get attr(){return n.attr},set header(E){n.loadFromBinary(E)},get header(){return n},packCentralHeader:function(){n.flags_efs=this.efs,n.extraLength=u.length;var E=n.centralHeaderToBinary(),C=de.Constants.CENHDR;return i.copy(E,C),C+=i.length,u.copy(E,C),C+=n.extraLength,o.copy(E,C),E},packLocalHeader:function(){let E=0;n.flags_efs=this.efs,n.extraLocalLength=f.length;let C=n.localHeaderToBinary(),L=Buffer.alloc(C.length+i.length+n.extraLocalLength);return C.copy(L,E),E+=C.length,i.copy(L,E),E+=i.length,f.copy(L,E),E+=f.length,L},toJSON:function(){let E=function(C){return"<"+(C&&C.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:n.toJSON(),compressedData:E(e),data:E(d)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Eu=ce((U2,yu)=>{var _u=Ka(),Vm=ja(),Ve=xr();yu.exports=function(t,e){var n=[],i={},o=Buffer.alloc(0),c=new Vm.MainHeader,d=!1,u=null;let f=new Set,x=e,{noSort:m,decoder:_}=x;t?b(x.readEntries):d=!0;function v(){let A=new Set;for(let P of Object.keys(i)){let D=P.split("/");if(D.pop(),!!D.length)for(let E=0;E<D.length;E++){let C=D.slice(0,E+1).join("/")+"/";A.add(C)}}for(let P of A)if(!(P in i)){let D=new _u(x);D.entryName=P,D.attr=16,D.temporary=!0,n.push(D),i[D.entryName]=D,f.add(D)}}function y(){if(d=!0,i={},c.diskEntries>(t.length-c.offset)/Ve.Constants.CENHDR)throw Ve.Errors.DISK_ENTRY_TOO_LARGE();n=new Array(c.diskEntries);for(var A=c.offset,P=0;P<n.length;P++){var D=A,E=new _u(x,t);E.header=t.slice(D,D+=Ve.Constants.CENHDR),E.entryName=t.slice(D,D+=E.header.fileNameLength),E.header.extraLength&&(E.extra=t.slice(D,D+=E.header.extraLength)),E.header.commentLength&&(E.comment=t.slice(D,D+E.header.commentLength)),A+=E.header.centralHeaderSize,n[P]=E,i[E.entryName]=E}f.clear(),v()}function b(A){var P=t.length-Ve.Constants.ENDHDR,D=Math.max(0,P-65535),E=D,C=t.length,L=-1,F=0;for(typeof x.trailingSpace=="boolean"&&x.trailingSpace&&(D=0),P;P>=E;P--)if(t[P]===80){if(t.readUInt32LE(P)===Ve.Constants.ENDSIG){L=P,F=P,C=P+Ve.Constants.ENDHDR,E=P-Ve.Constants.END64HDR;continue}if(t.readUInt32LE(P)===Ve.Constants.END64SIG){E=D;continue}if(t.readUInt32LE(P)===Ve.Constants.ZIP64SIG){L=P,C=P+Ve.readBigUInt64LE(t,P+Ve.Constants.ZIP64SIZE)+Ve.Constants.ZIP64LEAD;break}}if(L==-1)throw Ve.Errors.INVALID_FORMAT();c.loadFromBinary(t.slice(L,C)),c.commentLength&&(o=t.slice(F+Ve.Constants.ENDHDR)),A&&y()}function I(){n.length>1&&!m&&n.sort((A,P)=>A.entryName.toLowerCase().localeCompare(P.entryName.toLowerCase()))}return{get entries(){return d||y(),n.filter(A=>!f.has(A))},get comment(){return _.decode(o)},set comment(A){o=Ve.toBuffer(A,_.encode),c.commentLength=o.length},getEntryCount:function(){return d?n.length:c.diskEntries},forEach:function(A){this.entries.forEach(A)},getEntry:function(A){return d||y(),i[A]||null},setEntry:function(A){d||y(),n.push(A),i[A.entryName]=A,c.totalEntries=n.length},deleteFile:function(A,P=!0){d||y();let D=i[A];this.getEntryChildren(D,P).map(C=>C.entryName).forEach(this.deleteEntry)},deleteEntry:function(A){d||y();let P=i[A],D=n.indexOf(P);D>=0&&(n.splice(D,1),delete i[A],c.totalEntries=n.length)},getEntryChildren:function(A,P=!0){if(d||y(),typeof A=="object")if(A.isDirectory&&P){let D=[],E=A.entryName;for(let C of n)C.entryName.startsWith(E)&&D.push(C);return D}else return[A];return[]},getChildCount:function(A){if(A&&A.isDirectory){let P=this.getEntryChildren(A);return P.includes(A)?P.length-1:P.length}return 0},compressToBuffer:function(){d||y(),I();let A=[],P=[],D=0,E=0;c.size=0,c.offset=0;let C=0;for(let B of this.entries){let Z=B.getCompressedData();B.header.offset=E;let J=B.packLocalHeader(),ie=J.length+Z.length;E+=ie,A.push(J),A.push(Z);let Q=B.packCentralHeader();P.push(Q),c.size+=Q.length,D+=ie+Q.length,C++}D+=c.mainHeaderSize,c.offset=E,c.totalEntries=C,E=0;let L=Buffer.alloc(D);for(let B of A)B.copy(L,E),E+=B.length;for(let B of P)B.copy(L,E),E+=B.length;let F=c.toBinary();return o&&o.copy(F,Ve.Constants.ENDHDR),F.copy(L,E),t=L,d=!1,L},toAsyncBuffer:function(A,P,D,E){try{d||y(),I();let C=[],L=[],F=0,B=0,Z=0;c.size=0,c.offset=0;let J=function(ie){if(ie.length>0){let Q=ie.shift(),oe=Q.entryName+Q.extra.toString();D&&D(oe),Q.getCompressedDataAsync(function(ae){E&&E(oe),Q.header.offset=B;let R=Q.packLocalHeader(),z=R.length+ae.length;B+=z,C.push(R),C.push(ae);let j=Q.packCentralHeader();L.push(j),c.size+=j.length,F+=z+j.length,Z++,J(ie)})}else{F+=c.mainHeaderSize,c.offset=B,c.totalEntries=Z,B=0;let Q=Buffer.alloc(F);C.forEach(function(ae){ae.copy(Q,B),B+=ae.length}),L.forEach(function(ae){ae.copy(Q,B),B+=ae.length});let oe=c.toBinary();o&&o.copy(oe,Ve.Constants.ENDHDR),oe.copy(Q,B),t=Q,d=!1,A(Q)}};J(Array.from(this.entries))}catch(C){P(C)}}}}});var Su=ce((G2,vu)=>{var ve=xr(),be=xe("path"),Jm=Ka(),Zm=Eu(),Dn=(...t)=>ve.findLast(t,e=>typeof e=="boolean"),bu=(...t)=>ve.findLast(t,e=>typeof e=="string"),Ym=(...t)=>ve.findLast(t,e=>typeof e=="function"),Xm={noSort:!1,readEntries:!1,method:ve.Constants.NONE,fs:null};vu.exports=function(t,e){let n=null,i=Object.assign(Object.create(null),Xm);t&&typeof t=="object"&&(t instanceof Uint8Array||(Object.assign(i,t),t=i.input?i.input:void 0,i.input&&delete i.input),Buffer.isBuffer(t)&&(n=t,i.method=ve.Constants.BUFFER,t=void 0)),Object.assign(i,e);let o=new ve(i);if((typeof i.decoder!="object"||typeof i.decoder.encode!="function"||typeof i.decoder.decode!="function")&&(i.decoder=ve.decoder),t&&typeof t=="string")if(o.fs.existsSync(t))i.method=ve.Constants.FILE,i.filename=t,n=o.fs.readFileSync(t);else throw ve.Errors.INVALID_FILENAME();let c=new Zm(n,i),{canonical:d,sanitize:u,zipnamefix:f}=ve;function x(y){if(y&&c){var b;if(typeof y=="string"&&(b=c.getEntry(be.posix.normalize(y))),typeof y=="object"&&typeof y.entryName<"u"&&typeof y.header<"u"&&(b=c.getEntry(y.entryName)),b)return b}return null}function m(y){let{join:b,normalize:I,sep:A}=be.posix;return b(be.isAbsolute(y)?"/":".",I(A+y.split("\\").join(A)+A))}function _(y){return y instanceof RegExp?(function(b){return function(I){return b.test(I)}})(y):typeof y!="function"?()=>!0:y}let v=(y,b)=>{let I=b.slice(-1);return I=I===o.sep?o.sep:"",be.relative(y,b)+I};return{readFile:function(y,b){var I=x(y);return I&&I.getData(b)||null},childCount:function(y){let b=x(y);if(b)return c.getChildCount(b)},readFileAsync:function(y,b){var I=x(y);I?I.getDataAsync(b):b(null,"getEntry failed for:"+y)},readAsText:function(y,b){var I=x(y);if(I){var A=I.getData();if(A&&A.length)return A.toString(b||"utf8")}return""},readAsTextAsync:function(y,b,I){var A=x(y);A?A.getDataAsync(function(P,D){if(D){b(P,D);return}P&&P.length?b(P.toString(I||"utf8")):b("")}):b("")},deleteFile:function(y,b=!0){var I=x(y);I&&c.deleteFile(I.entryName,b)},deleteEntry:function(y){var b=x(y);b&&c.deleteEntry(b.entryName)},addZipComment:function(y){c.comment=y},getZipComment:function(){return c.comment||""},addZipEntryComment:function(y,b){var I=x(y);I&&(I.comment=b)},getZipEntryComment:function(y){var b=x(y);return b&&b.comment||""},updateFile:function(y,b){var I=x(y);I&&I.setData(b)},addLocalFile:function(y,b,I,A){if(o.fs.existsSync(y)){b=b?m(b):"";let P=be.win32.basename(be.win32.normalize(y));b+=I||P;let D=o.fs.statSync(y),E=D.isFile()?o.fs.readFileSync(y):Buffer.alloc(0);D.isDirectory()&&(b+=o.sep),this.addFile(b,E,A,D)}else throw ve.Errors.FILE_NOT_FOUND(y)},addLocalFileAsync:function(y,b){y=typeof y=="object"?y:{localPath:y};let I=be.resolve(y.localPath),{comment:A}=y,{zipPath:P,zipName:D}=y,E=this;o.fs.stat(I,function(C,L){if(C)return b(C,!1);P=P?m(P):"";let F=be.win32.basename(be.win32.normalize(I));if(P+=D||F,L.isFile())o.fs.readFile(I,function(B,Z){return B?b(B,!1):(E.addFile(P,Z,A,L),setImmediate(b,void 0,!0))});else if(L.isDirectory())return P+=o.sep,E.addFile(P,Buffer.alloc(0),A,L),setImmediate(b,void 0,!0)})},addLocalFolder:function(y,b,I){if(I=_(I),b=b?m(b):"",y=be.normalize(y),o.fs.existsSync(y)){let A=o.findFiles(y),P=this;if(A.length)for(let D of A){let E=be.join(b,v(y,D));I(E)&&P.addLocalFile(D,be.dirname(E))}}else throw ve.Errors.FILE_NOT_FOUND(y)},addLocalFolderAsync:function(y,b,I,A){A=_(A),I=I?m(I):"",y=be.normalize(y);var P=this;o.fs.open(y,"r",function(D){if(D&&D.code==="ENOENT")b(void 0,ve.Errors.FILE_NOT_FOUND(y));else if(D)b(void 0,D);else{var E=o.findFiles(y),C=-1,L=function(){if(C+=1,C<E.length){var F=E[C],B=v(y,F).split("\\").join("/");B=B.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),A(B)?o.fs.stat(F,function(Z,J){Z&&b(void 0,Z),J.isFile()?o.fs.readFile(F,function(ie,Q){ie?b(void 0,ie):(P.addFile(I+B,Q,"",J),L())}):(P.addFile(I+B+"/",Buffer.alloc(0),"",J),L())}):process.nextTick(()=>{L()})}else b(!0,void 0)};L()}})},addLocalFolderAsync2:function(y,b){let I=this;y=typeof y=="object"?y:{localPath:y},localPath=be.resolve(m(y.localPath));let{zipPath:A,filter:P,namefix:D}=y;P instanceof RegExp?P=(function(L){return function(F){return L.test(F)}})(P):typeof P!="function"&&(P=function(){return!0}),A=A?m(A):"",D=="latin1"&&(D=L=>L.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof D!="function"&&(D=L=>L);let E=L=>be.join(A,D(v(localPath,L))),C=L=>be.win32.basename(be.win32.normalize(D(L)));o.fs.open(localPath,"r",function(L){L&&L.code==="ENOENT"?b(void 0,ve.Errors.FILE_NOT_FOUND(localPath)):L?b(void 0,L):o.findFilesAsync(localPath,function(F,B){if(F)return b(F);B=B.filter(Z=>P(E(Z))),B.length||b(void 0,!1),setImmediate(B.reverse().reduce(function(Z,J){return function(ie,Q){if(ie||Q===!1)return setImmediate(Z,ie,!1);I.addLocalFileAsync({localPath:J,zipPath:be.dirname(E(J)),zipName:C(J)},Z)}},b))})})},addLocalFolderPromise:function(y,b){return new Promise((I,A)=>{this.addLocalFolderAsync2(Object.assign({localPath:y},b),(P,D)=>{P&&A(P),D&&I(this)})})},addFile:function(y,b,I,A){y=f(y);let P=x(y),D=P!=null;D||(P=new Jm(i),P.entryName=y),P.comment=I||"";let E=typeof A=="object"&&A instanceof o.fs.Stats;E&&(P.header.time=A.mtime);var C=P.isDirectory?16:0;let L=P.isDirectory?16384:32768;return E?L|=4095&A.mode:typeof A=="number"?L|=4095&A:L|=P.isDirectory?493:420,C=(C|L<<16)>>>0,P.attr=C,P.setData(b),D||c.setEntry(P),P},getEntries:function(y){return c.password=y,c?c.entries:[]},getEntry:function(y){return x(y)},getEntryCount:function(){return c.getEntryCount()},forEach:function(y){return c.forEach(y)},extractEntryTo:function(y,b,I,A,P,D){A=Dn(!1,A),P=Dn(!1,P),I=Dn(!0,I),D=bu(P,D);var E=x(y);if(!E)throw ve.Errors.NO_ENTRY();var C=d(E.entryName),L=u(b,D&&!E.isDirectory?D:I?C:be.basename(C));if(E.isDirectory){var F=c.getEntryChildren(E);return F.forEach(function(J){if(J.isDirectory)return;var ie=J.getData();if(!ie)throw ve.Errors.CANT_EXTRACT_FILE();var Q=d(J.entryName),oe=u(b,I?Q:be.basename(Q));let ae=P?J.header.fileAttr:void 0;o.writeFileTo(oe,ie,A,ae)}),!0}var B=E.getData(c.password);if(!B)throw ve.Errors.CANT_EXTRACT_FILE();if(o.fs.existsSync(L)&&!A)throw ve.Errors.CANT_OVERRIDE();let Z=P?y.header.fileAttr:void 0;return o.writeFileTo(L,B,A,Z),!0},test:function(y){if(!c)return!1;for(var b in c.entries)try{if(b.isDirectory)continue;var I=c.entries[b].getData(y);if(!I)return!1}catch{return!1}return!0},extractAllTo:function(y,b,I,A){if(I=Dn(!1,I),A=bu(I,A),b=Dn(!1,b),!c)throw ve.Errors.NO_ZIP();c.entries.forEach(function(P){var D=u(y,d(P.entryName));if(P.isDirectory){o.makeDir(D);return}var E=P.getData(A);if(!E)throw ve.Errors.CANT_EXTRACT_FILE();let C=I?P.header.fileAttr:void 0;o.writeFileTo(D,E,b,C);try{o.fs.utimesSync(D,P.header.time,P.header.time)}catch{throw ve.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(y,b,I,A){if(A=Ym(b,I,A),I=Dn(!1,I),b=Dn(!1,b),!A)return new Promise((L,F)=>{this.extractAllToAsync(y,b,I,function(B){B?F(B):L(this)})});if(!c){A(ve.Errors.NO_ZIP());return}y=be.resolve(y);let P=L=>u(y,be.normalize(d(L.entryName))),D=(L,F)=>new Error(L+': "'+F+'"'),E=[],C=[];c.entries.forEach(L=>{L.isDirectory?E.push(L):C.push(L)});for(let L of E){let F=P(L),B=I?L.header.fileAttr:void 0;try{o.makeDir(F),B&&o.fs.chmodSync(F,B),o.fs.utimesSync(F,L.header.time,L.header.time)}catch{A(D("Unable to create folder",F))}}C.reverse().reduce(function(L,F){return function(B){if(B)L(B);else{let Z=be.normalize(d(F.entryName)),J=u(y,Z);F.getDataAsync(function(ie,Q){if(Q)L(Q);else if(!ie)L(ve.Errors.CANT_EXTRACT_FILE());else{let oe=I?F.header.fileAttr:void 0;o.writeFileToAsync(J,ie,b,oe,function(ae){ae||L(D("Unable to write file",J)),o.fs.utimes(J,F.header.time,F.header.time,function(R){R?L(D("Unable to set times",J)):L()})})}})}}},A)()},writeZip:function(y,b){if(arguments.length===1&&typeof y=="function"&&(b=y,y=""),!y&&i.filename&&(y=i.filename),!!y){var I=c.compressToBuffer();if(I){var A=o.writeFileTo(y,I,!0);typeof b=="function"&&b(A?null:new Error("failed"),"")}}},writeZipPromise:function(y,b){let{overwrite:I,perm:A}=Object.assign({overwrite:!0},b);return new Promise((P,D)=>{!y&&i.filename&&(y=i.filename),y||D("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(E=>{let C=L=>L?P(L):D("ADM-ZIP: Wasn't able to write zip file");o.writeFileToAsync(y,E,I,A,C)},D)})},toBufferPromise:function(){return new Promise((y,b)=>{c.toAsyncBuffer(y,b)})},toBuffer:function(y,b,I,A){return typeof y=="function"?(c.toAsyncBuffer(y,b,I,A),null):c.compressToBuffer()}}}});import{execFile as iy,spawn as sy,spawnSync as sT}from"node:child_process";import{promisify as oy}from"node:util";function cy(t){if(process.platform!=="win32")return!1;if(jf.test(t))return!0;let n=(t.split(/[/\\]/).pop()??t).replace(jf,"").toLowerCase();return ay.has(n)}function Wf(t,e){if(process.platform!=="win32")return e??{};let n={...e??{}};return cy(t)&&n.shell===void 0&&(n.shell=!0),n.windowsHide===void 0&&(n.windowsHide=!0),n}function st(t,e=[],n={}){return sy(t,e,Wf(t,n))}function Kf(t,e=[],n={}){return dy(t,e,Wf(t,n))}var ay,jf,dy,Zt=nt(()=>{"use strict";ay=new Set(["npm","npx","yarn","pnpm","coze","tsx","claude-agent-acp","codex-acp","openclaw"]),jf=/\.(cmd|bat|ps1)$/i;dy=oy(iy)});var Xt=ce((dC,Uh)=>{"use strict";var Fh=["nodebuffer","arraybuffer","fragments"],zh=typeof Blob<"u";zh&&Fh.push("blob");Uh.exports={BINARY_TYPES:Fh,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:zh,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var Qi=ce((lC,zo)=>{"use strict";var{EMPTY_BUFFER:$b}=Xt(),bd=Buffer[Symbol.species];function Vb(t,e){if(t.length===0)return $b;if(t.length===1)return t[0];let n=Buffer.allocUnsafe(e),i=0;for(let o=0;o<t.length;o++){let c=t[o];n.set(c,i),i+=c.length}return i<e?new bd(n.buffer,n.byteOffset,i):n}function Gh(t,e,n,i,o){for(let c=0;c<o;c++)n[i+c]=t[c]^e[c&3]}function Hh(t,e){for(let n=0;n<t.length;n++)t[n]^=e[n&3]}function Jb(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function vd(t){if(vd.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new bd(t):ArrayBuffer.isView(t)?e=new bd(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),vd.readOnly=!1),e}zo.exports={concat:Vb,mask:Gh,toArrayBuffer:Jb,toBuffer:vd,unmask:Hh};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=xe("bufferutil");zo.exports.mask=function(e,n,i,o,c){c<48?Gh(e,n,i,o,c):t.mask(e,n,i,o,c)},zo.exports.unmask=function(e,n){e.length<32?Hh(e,n):t.unmask(e,n)}}catch{}});var Wh=ce((uC,jh)=>{"use strict";var qh=Symbol("kDone"),Sd=Symbol("kRun"),Id=class{constructor(e){this[qh]=()=>{this.pending--,this[Sd]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Sd]()}[Sd](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[qh])}}};jh.exports=Id});var Hr=ce((fC,Jh)=>{"use strict";var es=xe("zlib"),Kh=Qi(),Zb=Wh(),{kStatusCode:$h}=Xt(),Yb=Buffer[Symbol.species],Xb=Buffer.from([0,0,255,255]),Go=Symbol("permessage-deflate"),Qt=Symbol("total-length"),Ur=Symbol("callback"),kn=Symbol("buffers"),Gr=Symbol("error"),Uo,Ad=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!Uo){let n=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Uo=new Zb(n)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[Ur];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let n=this._options,i=e.find(o=>!(n.serverNoContextTakeover===!1&&o.server_no_context_takeover||o.server_max_window_bits&&(n.serverMaxWindowBits===!1||typeof n.serverMaxWindowBits=="number"&&n.serverMaxWindowBits>o.server_max_window_bits)||typeof n.clientMaxWindowBits=="number"&&!o.client_max_window_bits));if(!i)throw new Error("None of the extension offers can be accepted");return n.serverNoContextTakeover&&(i.server_no_context_takeover=!0),n.clientNoContextTakeover&&(i.client_no_context_takeover=!0),typeof n.serverMaxWindowBits=="number"&&(i.server_max_window_bits=n.serverMaxWindowBits),typeof n.clientMaxWindowBits=="number"?i.client_max_window_bits=n.clientMaxWindowBits:(i.client_max_window_bits===!0||n.clientMaxWindowBits===!1)&&delete i.client_max_window_bits,i}acceptAsClient(e){let n=e[0];if(this._options.clientNoContextTakeover===!1&&n.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!n.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(n.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&n.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return n}normalizeParams(e){return e.forEach(n=>{Object.keys(n).forEach(i=>{let o=n[i];if(o.length>1)throw new Error(`Parameter "${i}" must have only a single value`);if(o=o[0],i==="client_max_window_bits"){if(o!==!0){let c=+o;if(!Number.isInteger(c)||c<8||c>15)throw new TypeError(`Invalid value for parameter "${i}": ${o}`);o=c}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${i}": ${o}`)}else if(i==="server_max_window_bits"){let c=+o;if(!Number.isInteger(c)||c<8||c>15)throw new TypeError(`Invalid value for parameter "${i}": ${o}`);o=c}else if(i==="client_no_context_takeover"||i==="server_no_context_takeover"){if(o!==!0)throw new TypeError(`Invalid value for parameter "${i}": ${o}`)}else throw new Error(`Unknown parameter "${i}"`);n[i]=o})}),e}decompress(e,n,i){Uo.add(o=>{this._decompress(e,n,(c,d)=>{o(),i(c,d)})})}compress(e,n,i){Uo.add(o=>{this._compress(e,n,(c,d)=>{o(),i(c,d)})})}_decompress(e,n,i){let o=this._isServer?"client":"server";if(!this._inflate){let c=`${o}_max_window_bits`,d=typeof this.params[c]!="number"?es.Z_DEFAULT_WINDOWBITS:this.params[c];this._inflate=es.createInflateRaw({...this._options.zlibInflateOptions,windowBits:d}),this._inflate[Go]=this,this._inflate[Qt]=0,this._inflate[kn]=[],this._inflate.on("error",ev),this._inflate.on("data",Vh)}this._inflate[Ur]=i,this._inflate.write(e),n&&this._inflate.write(Xb),this._inflate.flush(()=>{let c=this._inflate[Gr];if(c){this._inflate.close(),this._inflate=null,i(c);return}let d=Kh.concat(this._inflate[kn],this._inflate[Qt]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Qt]=0,this._inflate[kn]=[],n&&this.params[`${o}_no_context_takeover`]&&this._inflate.reset()),i(null,d)})}_compress(e,n,i){let o=this._isServer?"server":"client";if(!this._deflate){let c=`${o}_max_window_bits`,d=typeof this.params[c]!="number"?es.Z_DEFAULT_WINDOWBITS:this.params[c];this._deflate=es.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:d}),this._deflate[Qt]=0,this._deflate[kn]=[],this._deflate.on("data",Qb)}this._deflate[Ur]=i,this._deflate.write(e),this._deflate.flush(es.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let c=Kh.concat(this._deflate[kn],this._deflate[Qt]);n&&(c=new Yb(c.buffer,c.byteOffset,c.length-4)),this._deflate[Ur]=null,this._deflate[Qt]=0,this._deflate[kn]=[],n&&this.params[`${o}_no_context_takeover`]&&this._deflate.reset(),i(null,c)})}};Jh.exports=Ad;function Qb(t){this[kn].push(t),this[Qt]+=t.length}function Vh(t){if(this[Qt]+=t.length,this[Go]._maxPayload<1||this[Qt]<=this[Go]._maxPayload){this[kn].push(t);return}this[Gr]=new RangeError("Max payload size exceeded"),this[Gr].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Gr][$h]=1009,this.removeListener("data",Vh),this.reset()}function ev(t){if(this[Go]._inflate=null,this[Gr]){this[Ur](this[Gr]);return}t[$h]=1007,this[Ur](t)}});var qr=ce((hC,Ho)=>{"use strict";var{isUtf8:Zh}=xe("buffer"),{hasBlob:tv}=Xt(),nv=[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 rv(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function kd(t){let e=t.length,n=0;for(;n<e;)if((t[n]&128)===0)n++;else if((t[n]&224)===192){if(n+1===e||(t[n+1]&192)!==128||(t[n]&254)===192)return!1;n+=2}else if((t[n]&240)===224){if(n+2>=e||(t[n+1]&192)!==128||(t[n+2]&192)!==128||t[n]===224&&(t[n+1]&224)===128||t[n]===237&&(t[n+1]&224)===160)return!1;n+=3}else if((t[n]&248)===240){if(n+3>=e||(t[n+1]&192)!==128||(t[n+2]&192)!==128||(t[n+3]&192)!==128||t[n]===240&&(t[n+1]&240)===128||t[n]===244&&t[n+1]>143||t[n]>244)return!1;n+=4}else return!1;return!0}function iv(t){return tv&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}Ho.exports={isBlob:iv,isValidStatusCode:rv,isValidUTF8:kd,tokenChars:nv};if(Zh)Ho.exports.isValidUTF8=function(t){return t.length<24?kd(t):Zh(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=xe("utf-8-validate");Ho.exports.isValidUTF8=function(e){return e.length<32?kd(e):t(e)}}catch{}});var Dd=ce((xC,rx)=>{"use strict";var{Writable:sv}=xe("stream"),Yh=Hr(),{BINARY_TYPES:ov,EMPTY_BUFFER:Xh,kStatusCode:av,kWebSocket:cv}=Xt(),{concat:Td,toArrayBuffer:dv,unmask:lv}=Qi(),{isValidStatusCode:uv,isValidUTF8:Qh}=qr(),qo=Buffer[Symbol.species],gt=0,ex=1,tx=2,nx=3,Pd=4,Rd=5,jo=6,Cd=class extends sv{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||ov[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxBufferedChunks=e.maxBufferedChunks|0,this._maxFragments=e.maxFragments|0,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[cv]=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=gt}_write(e,n,i){if(this._opcode===8&&this._state==gt)return i();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){i(this.createError(RangeError,"Too many buffered chunks",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));return}this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(i)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let i=this._buffers[0];return this._buffers[0]=new qo(i.buffer,i.byteOffset+e,i.length-e),new qo(i.buffer,i.byteOffset,e)}let n=Buffer.allocUnsafe(e);do{let i=this._buffers[0],o=n.length-e;e>=i.length?n.set(this._buffers.shift(),o):(n.set(new Uint8Array(i.buffer,i.byteOffset,e),o),this._buffers[0]=new qo(i.buffer,i.byteOffset+e,i.length-e)),e-=i.length}while(e>0);return n}startLoop(e){this._loop=!0;do switch(this._state){case gt:this.getInfo(e);break;case ex:this.getPayloadLength16(e);break;case tx:this.getPayloadLength64(e);break;case nx:this.getMask();break;case Pd:this.getData(e);break;case Rd:case jo:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let n=this.consume(2);if((n[0]&48)!==0){let o=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(o);return}let i=(n[0]&64)===64;if(i&&!this._extensions[Yh.extensionName]){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(o);return}if(this._fin=(n[0]&128)===128,this._opcode=n[0]&15,this._payloadLength=n[1]&127,this._opcode===0){if(i){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(o);return}if(!this._fragmented){let o=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(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");e(o);return}this._compressed=i}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");e(o);return}if(i){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(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");e(o);return}}else{let o=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(o);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(n[1]&128)===128,this._isServer){if(!this._masked){let o=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(o);return}}else if(this._masked){let o=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(o);return}this._payloadLength===126?this._state=ex:this._payloadLength===127?this._state=tx:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let n=this.consume(8),i=n.readUInt32BE(0);if(i>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");e(o);return}this._payloadLength=i*Math.pow(2,32)+n.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let n=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(n);return}this._masked?this._state=nx:this._state=Pd}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Pd}getData(e){let n=Xh;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}n=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&lv(n,this._mask)}if(this._opcode>7){this.controlMessage(n,e);return}if(this._compressed){this._state=Rd,this.decompress(n,e);return}if(n.length){if(this._maxFragments>0&&this._fragments.length>=this._maxFragments){let i=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");e(i);return}this._messageLength=this._totalPayloadLength,this._fragments.push(n)}this.dataMessage(e)}decompress(e,n){this._extensions[Yh.extensionName].decompress(e,this._fin,(o,c)=>{if(o)return n(o);if(c.length){if(this._messageLength+=c.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let d=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");n(d);return}if(this._maxFragments>0&&this._fragments.length>=this._maxFragments){let d=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");n(d);return}this._fragments.push(c)}this.dataMessage(n),this._state===gt&&this.startLoop(n)})}dataMessage(e){if(!this._fin){this._state=gt;return}let n=this._messageLength,i=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let o;this._binaryType==="nodebuffer"?o=Td(i,n):this._binaryType==="arraybuffer"?o=dv(Td(i,n)):this._binaryType==="blob"?o=new Blob(i):o=i,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=gt):(this._state=jo,setImmediate(()=>{this.emit("message",o,!0),this._state=gt,this.startLoop(e)}))}else{let o=Td(i,n);if(!this._skipUTF8Validation&&!Qh(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(c);return}this._state===Rd||this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=gt):(this._state=jo,setImmediate(()=>{this.emit("message",o,!1),this._state=gt,this.startLoop(e)}))}}controlMessage(e,n){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,Xh),this.end();else{let i=e.readUInt16BE(0);if(!uv(i)){let c=this.createError(RangeError,`invalid status code ${i}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");n(c);return}let o=new qo(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!Qh(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");n(c);return}this._loop=!1,this.emit("conclude",i,o),this.end()}this._state=gt;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=gt):(this._state=jo,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=gt,this.startLoop(n)}))}createError(e,n,i,o,c){this._loop=!1,this._errored=!0;let d=new e(i?`Invalid WebSocket frame: ${n}`:n);return Error.captureStackTrace(d,this.createError),d.code=c,d[av]=o,d}};rx.exports=Cd});var Nd=ce((gC,ox)=>{"use strict";var{Duplex:pC}=xe("stream"),{randomFillSync:fv}=xe("crypto"),{types:{isUint8Array:hv}}=xe("util"),ix=Hr(),{EMPTY_BUFFER:xv,kWebSocket:pv,NOOP:gv}=Xt(),{isBlob:jr,isValidStatusCode:mv}=qr(),{mask:sx,toBuffer:Zn}=Qi(),mt=Symbol("kByteLength"),wv=Buffer.alloc(4),Wo=8*1024,Yn,Wr=Wo,At=0,_v=1,yv=2,Od=class t{constructor(e,n,i){this._extensions=n||{},i&&(this._generateMask=i,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=At,this.onerror=gv,this[pv]=void 0}static frame(e,n){let i,o=!1,c=2,d=!1;n.mask&&(i=n.maskBuffer||wv,n.generateMask?n.generateMask(i):(Wr===Wo&&(Yn===void 0&&(Yn=Buffer.alloc(Wo)),fv(Yn,0,Wo),Wr=0),i[0]=Yn[Wr++],i[1]=Yn[Wr++],i[2]=Yn[Wr++],i[3]=Yn[Wr++]),d=(i[0]|i[1]|i[2]|i[3])===0,c=6);let u;typeof e=="string"?(!n.mask||d)&&n[mt]!==void 0?u=n[mt]:(e=Buffer.from(e),u=e.length):(u=e.length,o=n.mask&&n.readOnly&&!d);let f=u;u>=65536?(c+=8,f=127):u>125&&(c+=2,f=126);let x=Buffer.allocUnsafe(o?u+c:c);return x[0]=n.fin?n.opcode|128:n.opcode,n.rsv1&&(x[0]|=64),x[1]=f,f===126?x.writeUInt16BE(u,2):f===127&&(x[2]=x[3]=0,x.writeUIntBE(u,4,6)),n.mask?(x[1]|=128,x[c-4]=i[0],x[c-3]=i[1],x[c-2]=i[2],x[c-1]=i[3],d?[x,e]:o?(sx(e,i,x,c,u),[x]):(sx(e,i,e,0,u),[x,e])):[x,e]}close(e,n,i,o){let c;if(e===void 0)c=xv;else{if(typeof e!="number"||!mv(e))throw new TypeError("First argument must be a valid error code number");if(n===void 0||!n.length)c=Buffer.allocUnsafe(2),c.writeUInt16BE(e,0);else{let u=Buffer.byteLength(n);if(u>123)throw new RangeError("The message must not be greater than 123 bytes");if(c=Buffer.allocUnsafe(2+u),c.writeUInt16BE(e,0),typeof n=="string")c.write(n,2);else if(hv(n))c.set(n,2);else throw new TypeError("Second argument must be a string or a Uint8Array")}}let d={[mt]:c.length,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==At?this.enqueue([this.dispatch,c,!1,d,o]):this.sendFrame(t.frame(c,d),o)}ping(e,n,i){let o,c;if(typeof e=="string"?(o=Buffer.byteLength(e),c=!1):jr(e)?(o=e.size,c=!1):(e=Zn(e),o=e.length,c=Zn.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let d={[mt]:o,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:9,readOnly:c,rsv1:!1};jr(e)?this._state!==At?this.enqueue([this.getBlobData,e,!1,d,i]):this.getBlobData(e,!1,d,i):this._state!==At?this.enqueue([this.dispatch,e,!1,d,i]):this.sendFrame(t.frame(e,d),i)}pong(e,n,i){let o,c;if(typeof e=="string"?(o=Buffer.byteLength(e),c=!1):jr(e)?(o=e.size,c=!1):(e=Zn(e),o=e.length,c=Zn.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let d={[mt]:o,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:10,readOnly:c,rsv1:!1};jr(e)?this._state!==At?this.enqueue([this.getBlobData,e,!1,d,i]):this.getBlobData(e,!1,d,i):this._state!==At?this.enqueue([this.dispatch,e,!1,d,i]):this.sendFrame(t.frame(e,d),i)}send(e,n,i){let o=this._extensions[ix.extensionName],c=n.binary?2:1,d=n.compress,u,f;typeof e=="string"?(u=Buffer.byteLength(e),f=!1):jr(e)?(u=e.size,f=!1):(e=Zn(e),u=e.length,f=Zn.readOnly),this._firstFragment?(this._firstFragment=!1,d&&o&&o.params[o._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(d=u>=o._threshold),this._compress=d):(d=!1,c=0),n.fin&&(this._firstFragment=!0);let x={[mt]:u,fin:n.fin,generateMask:this._generateMask,mask:n.mask,maskBuffer:this._maskBuffer,opcode:c,readOnly:f,rsv1:d};jr(e)?this._state!==At?this.enqueue([this.getBlobData,e,this._compress,x,i]):this.getBlobData(e,this._compress,x,i):this._state!==At?this.enqueue([this.dispatch,e,this._compress,x,i]):this.dispatch(e,this._compress,x,i)}getBlobData(e,n,i,o){this._bufferedBytes+=i[mt],this._state=yv,e.arrayBuffer().then(c=>{if(this._socket.destroyed){let u=new Error("The socket was closed while the blob was being read");process.nextTick(Ld,this,u,o);return}this._bufferedBytes-=i[mt];let d=Zn(c);n?this.dispatch(d,n,i,o):(this._state=At,this.sendFrame(t.frame(d,i),o),this.dequeue())}).catch(c=>{process.nextTick(Ev,this,c,o)})}dispatch(e,n,i,o){if(!n){this.sendFrame(t.frame(e,i),o);return}let c=this._extensions[ix.extensionName];this._bufferedBytes+=i[mt],this._state=_v,c.compress(e,i.fin,(d,u)=>{if(this._socket.destroyed){let f=new Error("The socket was closed while data was being compressed");Ld(this,f,o);return}this._bufferedBytes-=i[mt],this._state=At,i.readOnly=!1,this.sendFrame(t.frame(u,i),o),this.dequeue()})}dequeue(){for(;this._state===At&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][mt],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][mt],this._queue.push(e)}sendFrame(e,n){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],n),this._socket.uncork()):this._socket.write(e[0],n)}};ox.exports=Od;function Ld(t,e,n){typeof n=="function"&&n(e);for(let i=0;i<t._queue.length;i++){let o=t._queue[i],c=o[o.length-1];typeof c=="function"&&c(e)}}function Ev(t,e,n){Ld(t,e,n),t.onerror(e)}});var px=ce((mC,xx)=>{"use strict";var{kForOnEventAttribute:ts,kListener:Md}=Xt(),ax=Symbol("kCode"),cx=Symbol("kData"),dx=Symbol("kError"),lx=Symbol("kMessage"),ux=Symbol("kReason"),Kr=Symbol("kTarget"),fx=Symbol("kType"),hx=Symbol("kWasClean"),en=class{constructor(e){this[Kr]=null,this[fx]=e}get target(){return this[Kr]}get type(){return this[fx]}};Object.defineProperty(en.prototype,"target",{enumerable:!0});Object.defineProperty(en.prototype,"type",{enumerable:!0});var Xn=class extends en{constructor(e,n={}){super(e),this[ax]=n.code===void 0?0:n.code,this[ux]=n.reason===void 0?"":n.reason,this[hx]=n.wasClean===void 0?!1:n.wasClean}get code(){return this[ax]}get reason(){return this[ux]}get wasClean(){return this[hx]}};Object.defineProperty(Xn.prototype,"code",{enumerable:!0});Object.defineProperty(Xn.prototype,"reason",{enumerable:!0});Object.defineProperty(Xn.prototype,"wasClean",{enumerable:!0});var $r=class extends en{constructor(e,n={}){super(e),this[dx]=n.error===void 0?null:n.error,this[lx]=n.message===void 0?"":n.message}get error(){return this[dx]}get message(){return this[lx]}};Object.defineProperty($r.prototype,"error",{enumerable:!0});Object.defineProperty($r.prototype,"message",{enumerable:!0});var ns=class extends en{constructor(e,n={}){super(e),this[cx]=n.data===void 0?null:n.data}get data(){return this[cx]}};Object.defineProperty(ns.prototype,"data",{enumerable:!0});var bv={addEventListener(t,e,n={}){for(let o of this.listeners(t))if(!n[ts]&&o[Md]===e&&!o[ts])return;let i;if(t==="message")i=function(c,d){let u=new ns("message",{data:d?c:c.toString()});u[Kr]=this,Ko(e,this,u)};else if(t==="close")i=function(c,d){let u=new Xn("close",{code:c,reason:d.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});u[Kr]=this,Ko(e,this,u)};else if(t==="error")i=function(c){let d=new $r("error",{error:c,message:c.message});d[Kr]=this,Ko(e,this,d)};else if(t==="open")i=function(){let c=new en("open");c[Kr]=this,Ko(e,this,c)};else return;i[ts]=!!n[ts],i[Md]=e,n.once?this.once(t,i):this.on(t,i)},removeEventListener(t,e){for(let n of this.listeners(t))if(n[Md]===e&&!n[ts]){this.removeListener(t,n);break}}};xx.exports={CloseEvent:Xn,ErrorEvent:$r,Event:en,EventTarget:bv,MessageEvent:ns};function Ko(t,e,n){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,n):t.call(e,n)}});var $o=ce((wC,gx)=>{"use strict";var{tokenChars:rs}=qr();function Bt(t,e,n){t[e]===void 0?t[e]=[n]:t[e].push(n)}function vv(t){let e=Object.create(null),n=Object.create(null),i=!1,o=!1,c=!1,d,u,f=-1,x=-1,m=-1,_=0;for(;_<t.length;_++)if(x=t.charCodeAt(_),d===void 0)if(m===-1&&rs[x]===1)f===-1&&(f=_);else if(_!==0&&(x===32||x===9))m===-1&&f!==-1&&(m=_);else if(x===59||x===44){if(f===-1)throw new SyntaxError(`Unexpected character at index ${_}`);m===-1&&(m=_);let y=t.slice(f,m);x===44?(Bt(e,y,n),n=Object.create(null)):d=y,f=m=-1}else throw new SyntaxError(`Unexpected character at index ${_}`);else if(u===void 0)if(m===-1&&rs[x]===1)f===-1&&(f=_);else if(x===32||x===9)m===-1&&f!==-1&&(m=_);else if(x===59||x===44){if(f===-1)throw new SyntaxError(`Unexpected character at index ${_}`);m===-1&&(m=_),Bt(n,t.slice(f,m),!0),x===44&&(Bt(e,d,n),n=Object.create(null),d=void 0),f=m=-1}else if(x===61&&f!==-1&&m===-1)u=t.slice(f,_),f=m=-1;else throw new SyntaxError(`Unexpected character at index ${_}`);else if(o){if(rs[x]!==1)throw new SyntaxError(`Unexpected character at index ${_}`);f===-1?f=_:i||(i=!0),o=!1}else if(c)if(rs[x]===1)f===-1&&(f=_);else if(x===34&&f!==-1)c=!1,m=_;else if(x===92)o=!0;else throw new SyntaxError(`Unexpected character at index ${_}`);else if(x===34&&t.charCodeAt(_-1)===61)c=!0;else if(m===-1&&rs[x]===1)f===-1&&(f=_);else if(f!==-1&&(x===32||x===9))m===-1&&(m=_);else if(x===59||x===44){if(f===-1)throw new SyntaxError(`Unexpected character at index ${_}`);m===-1&&(m=_);let y=t.slice(f,m);i&&(y=y.replace(/\\/g,""),i=!1),Bt(n,u,y),x===44&&(Bt(e,d,n),n=Object.create(null),d=void 0),u=void 0,f=m=-1}else throw new SyntaxError(`Unexpected character at index ${_}`);if(f===-1||c||x===32||x===9)throw new SyntaxError("Unexpected end of input");m===-1&&(m=_);let v=t.slice(f,m);return d===void 0?Bt(e,v,n):(u===void 0?Bt(n,v,!0):i?Bt(n,u,v.replace(/\\/g,"")):Bt(n,u,v),Bt(e,d,n)),e}function Sv(t){return Object.keys(t).map(e=>{let n=t[e];return Array.isArray(n)||(n=[n]),n.map(i=>[e].concat(Object.keys(i).map(o=>{let c=i[o];return Array.isArray(c)||(c=[c]),c.map(d=>d===!0?o:`${o}=${d}`).join("; ")})).join("; ")).join(", ")}).join(", ")}gx.exports={format:Sv,parse:vv}});var Yo=ce((EC,Px)=>{"use strict";var Iv=xe("events"),Av=xe("https"),kv=xe("http"),yx=xe("net"),Tv=xe("tls"),{randomBytes:Pv,createHash:Rv}=xe("crypto"),{Duplex:_C,Readable:yC}=xe("stream"),{URL:Bd}=xe("url"),Tn=Hr(),Cv=Dd(),Dv=Nd(),{isBlob:Ov}=qr(),{BINARY_TYPES:mx,CLOSE_TIMEOUT:Lv,EMPTY_BUFFER:Vo,GUID:Nv,kForOnEventAttribute:Fd,kListener:Mv,kStatusCode:Bv,kWebSocket:We,NOOP:Ex}=Xt(),{EventTarget:{addEventListener:Fv,removeEventListener:zv}}=px(),{format:Uv,parse:Gv}=$o(),{toBuffer:Hv}=Qi(),bx=Symbol("kAborted"),zd=[8,13],tn=["CONNECTING","OPEN","CLOSING","CLOSED"],qv=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,_e=class t extends Iv{constructor(e,n,i){super(),this._binaryType=mx[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Vo,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=t.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,n===void 0?n=[]:Array.isArray(n)||(typeof n=="object"&&n!==null?(i=n,n=[]):n=[n]),vx(this,e,n,i)):(this._autoPong=i.autoPong,this._closeTimeout=i.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){mx.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}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(e,n,i){let o=new Cv({allowSynchronousEvents:i.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxBufferedChunks:i.maxBufferedChunks,maxFragments:i.maxFragments,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation}),c=new Dv(e,this._extensions,i.generateMask);this._receiver=o,this._sender=c,this._socket=e,o[We]=this,c[We]=this,e[We]=this,o.on("conclude",Kv),o.on("drain",$v),o.on("error",Vv),o.on("message",Jv),o.on("ping",Zv),o.on("pong",Yv),c.onerror=Xv,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),n.length>0&&e.unshift(n),e.on("close",Ax),e.on("data",Zo),e.on("end",kx),e.on("error",Tx),this._readyState=t.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[Tn.extensionName]&&this._extensions[Tn.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,n){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){dt(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===t.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=t.CLOSING,this._sender.close(e,n,!this._isServer,i=>{i||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),Ix(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,n,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(i=e,e=n=void 0):typeof n=="function"&&(i=n,n=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Ud(this,e,i);return}n===void 0&&(n=!this._isServer),this._sender.ping(e||Vo,n,i)}pong(e,n,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(i=e,e=n=void 0):typeof n=="function"&&(i=n,n=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Ud(this,e,i);return}n===void 0&&(n=!this._isServer),this._sender.pong(e||Vo,n,i)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,n,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof n=="function"&&(i=n,n={}),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Ud(this,e,i);return}let o={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...n};this._extensions[Tn.extensionName]||(o.compress=!1),this._sender.send(e||Vo,o,i)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){dt(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(_e,"CONNECTING",{enumerable:!0,value:tn.indexOf("CONNECTING")});Object.defineProperty(_e.prototype,"CONNECTING",{enumerable:!0,value:tn.indexOf("CONNECTING")});Object.defineProperty(_e,"OPEN",{enumerable:!0,value:tn.indexOf("OPEN")});Object.defineProperty(_e.prototype,"OPEN",{enumerable:!0,value:tn.indexOf("OPEN")});Object.defineProperty(_e,"CLOSING",{enumerable:!0,value:tn.indexOf("CLOSING")});Object.defineProperty(_e.prototype,"CLOSING",{enumerable:!0,value:tn.indexOf("CLOSING")});Object.defineProperty(_e,"CLOSED",{enumerable:!0,value:tn.indexOf("CLOSED")});Object.defineProperty(_e.prototype,"CLOSED",{enumerable:!0,value:tn.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(_e.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(_e.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[Fd])return e[Mv];return null},set(e){for(let n of this.listeners(t))if(n[Fd]){this.removeListener(t,n);break}typeof e=="function"&&this.addEventListener(t,e,{[Fd]:!0})}})});_e.prototype.addEventListener=Fv;_e.prototype.removeEventListener=zv;Px.exports=_e;function vx(t,e,n,i){let o={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:Lv,protocolVersion:zd[1],maxBufferedChunks:1048576,maxFragments:131072,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...i,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=o.autoPong,t._closeTimeout=o.closeTimeout,!zd.includes(o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${zd.join(", ")})`);let c;if(e instanceof Bd)c=e;else try{c=new Bd(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}c.protocol==="http:"?c.protocol="ws:":c.protocol==="https:"&&(c.protocol="wss:"),t._url=c.href;let d=c.protocol==="wss:",u=c.protocol==="ws+unix:",f;if(c.protocol!=="ws:"&&!d&&!u?f=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:u&&!c.pathname?f="The URL's pathname is empty":c.hash&&(f="The URL contains a fragment identifier"),f){let I=new SyntaxError(f);if(t._redirects===0)throw I;Jo(t,I);return}let x=d?443:80,m=Pv(16).toString("base64"),_=d?Av.request:kv.request,v=new Set,y;if(o.createConnection=o.createConnection||(d?Wv:jv),o.defaultPort=o.defaultPort||x,o.port=c.port||x,o.host=c.hostname.startsWith("[")?c.hostname.slice(1,-1):c.hostname,o.headers={...o.headers,"Sec-WebSocket-Version":o.protocolVersion,"Sec-WebSocket-Key":m,Connection:"Upgrade",Upgrade:"websocket"},o.path=c.pathname+c.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&(y=new Tn({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers["Sec-WebSocket-Extensions"]=Uv({[Tn.extensionName]:y.offer()})),n.length){for(let I of n){if(typeof I!="string"||!qv.test(I)||v.has(I))throw new SyntaxError("An invalid or duplicated subprotocol was specified");v.add(I)}o.headers["Sec-WebSocket-Protocol"]=n.join(",")}if(o.origin&&(o.protocolVersion<13?o.headers["Sec-WebSocket-Origin"]=o.origin:o.headers.Origin=o.origin),(c.username||c.password)&&(o.auth=`${c.username}:${c.password}`),u){let I=o.path.split(":");o.socketPath=I[0],o.path=I[1]}let b;if(o.followRedirects){if(t._redirects===0){t._originalIpc=u,t._originalSecure=d,t._originalHostOrSocketPath=u?o.socketPath:c.host;let I=i&&i.headers;if(i={...i,headers:{}},I)for(let[A,P]of Object.entries(I))i.headers[A.toLowerCase()]=P}else if(t.listenerCount("redirect")===0){let I=u?t._originalIpc?o.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:c.host===t._originalHostOrSocketPath;(!I||t._originalSecure&&!d)&&(delete o.headers.authorization,delete o.headers.cookie,I||delete o.headers.host,o.auth=void 0)}o.auth&&!i.headers.authorization&&(i.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")),b=t._req=_(o),t._redirects&&t.emit("redirect",t.url,b)}else b=t._req=_(o);o.timeout&&b.on("timeout",()=>{dt(t,b,"Opening handshake has timed out")}),b.on("error",I=>{b===null||b[bx]||(b=t._req=null,Jo(t,I))}),b.on("response",I=>{let A=I.headers.location,P=I.statusCode;if(A&&o.followRedirects&&P>=300&&P<400){if(++t._redirects>o.maxRedirects){dt(t,b,"Maximum redirects exceeded");return}b.abort();let D;try{D=new Bd(A,e)}catch{let C=new SyntaxError(`Invalid URL: ${A}`);Jo(t,C);return}vx(t,D,n,i)}else t.emit("unexpected-response",b,I)||dt(t,b,`Unexpected server response: ${I.statusCode}`)}),b.on("upgrade",(I,A,P)=>{if(t.emit("upgrade",I),t.readyState!==_e.CONNECTING)return;b=t._req=null;let D=I.headers.upgrade;if(D===void 0||D.toLowerCase()!=="websocket"){dt(t,A,"Invalid Upgrade header");return}let E=Rv("sha1").update(m+Nv).digest("base64");if(I.headers["sec-websocket-accept"]!==E){dt(t,A,"Invalid Sec-WebSocket-Accept header");return}let C=I.headers["sec-websocket-protocol"],L;if(C!==void 0?v.size?v.has(C)||(L="Server sent an invalid subprotocol"):L="Server sent a subprotocol but none was requested":v.size&&(L="Server sent no subprotocol"),L){dt(t,A,L);return}C&&(t._protocol=C);let F=I.headers["sec-websocket-extensions"];if(F!==void 0){if(!y){dt(t,A,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let B;try{B=Gv(F)}catch{dt(t,A,"Invalid Sec-WebSocket-Extensions header");return}let Z=Object.keys(B);if(Z.length!==1||Z[0]!==Tn.extensionName){dt(t,A,"Server indicated an extension that was not requested");return}try{y.accept(B[Tn.extensionName])}catch{dt(t,A,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[Tn.extensionName]=y}t.setSocket(A,P,{allowSynchronousEvents:o.allowSynchronousEvents,generateMask:o.generateMask,maxBufferedChunks:o.maxBufferedChunks,maxFragments:o.maxFragments,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(b,t):b.end()}function Jo(t,e){t._readyState=_e.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function jv(t){return t.path=t.socketPath,yx.connect(t)}function Wv(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=yx.isIP(t.host)?"":t.host),Tv.connect(t)}function dt(t,e,n){t._readyState=_e.CLOSING;let i=new Error(n);Error.captureStackTrace(i,dt),e.setHeader?(e[bx]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(Jo,t,i)):(e.destroy(i),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function Ud(t,e,n){if(e){let i=Ov(e)?e.size:Hv(e).length;t._socket?t._sender._bufferedBytes+=i:t._bufferedAmount+=i}if(n){let i=new Error(`WebSocket is not open: readyState ${t.readyState} (${tn[t.readyState]})`);process.nextTick(n,i)}}function Kv(t,e){let n=this[We];n._closeFrameReceived=!0,n._closeMessage=e,n._closeCode=t,n._socket[We]!==void 0&&(n._socket.removeListener("data",Zo),process.nextTick(Sx,n._socket),t===1005?n.close():n.close(t,e))}function $v(){let t=this[We];t.isPaused||t._socket.resume()}function Vv(t){let e=this[We];e._socket[We]!==void 0&&(e._socket.removeListener("data",Zo),process.nextTick(Sx,e._socket),e.close(t[Bv])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function _x(){this[We].emitClose()}function Jv(t,e){this[We].emit("message",t,e)}function Zv(t){let e=this[We];e._autoPong&&e.pong(t,!this._isServer,Ex),e.emit("ping",t)}function Yv(t){this[We].emit("pong",t)}function Sx(t){t.resume()}function Xv(t){let e=this[We];e.readyState!==_e.CLOSED&&(e.readyState===_e.OPEN&&(e._readyState=_e.CLOSING,Ix(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function Ix(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function Ax(){let t=this[We];if(this.removeListener("close",Ax),this.removeListener("data",Zo),this.removeListener("end",kx),t._readyState=_e.CLOSING,!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[We]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",_x),t._receiver.on("finish",_x))}function Zo(t){this[We]._receiver.write(t)||this.pause()}function kx(){let t=this[We];t._readyState=_e.CLOSING,t._receiver.end(),this.end()}function Tx(){let t=this[We];this.removeListener("error",Tx),this.on("error",Ex),t&&(t._readyState=_e.CLOSING,this.destroy())}});var Ox=ce((vC,Dx)=>{"use strict";var bC=Yo(),{Duplex:Qv}=xe("stream");function Rx(t){t.emit("close")}function eS(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Cx(t){this.removeListener("error",Cx),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function tS(t,e){let n=!0,i=new Qv({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(c,d){let u=!d&&i._readableState.objectMode?c.toString():c;i.push(u)||t.pause()}),t.once("error",function(c){i.destroyed||(n=!1,i.destroy(c))}),t.once("close",function(){i.destroyed||i.push(null)}),i._destroy=function(o,c){if(t.readyState===t.CLOSED){c(o),process.nextTick(Rx,i);return}let d=!1;t.once("error",function(f){d=!0,c(f)}),t.once("close",function(){d||c(o),process.nextTick(Rx,i)}),n&&t.terminate()},i._final=function(o){if(t.readyState===t.CONNECTING){t.once("open",function(){i._final(o)});return}t._socket!==null&&(t._socket._writableState.finished?(o(),i._readableState.endEmitted&&i.destroy()):(t._socket.once("finish",function(){o()}),t.close()))},i._read=function(){t.isPaused&&t.resume()},i._write=function(o,c,d){if(t.readyState===t.CONNECTING){t.once("open",function(){i._write(o,c,d)});return}t.send(o,d)},i.on("end",eS),i.on("error",Cx),i}Dx.exports=tS});var Gd=ce((SC,Lx)=>{"use strict";var{tokenChars:nS}=qr();function rS(t){let e=new Set,n=-1,i=-1,o=0;for(o;o<t.length;o++){let d=t.charCodeAt(o);if(i===-1&&nS[d]===1)n===-1&&(n=o);else if(o!==0&&(d===32||d===9))i===-1&&n!==-1&&(i=o);else if(d===44){if(n===-1)throw new SyntaxError(`Unexpected character at index ${o}`);i===-1&&(i=o);let u=t.slice(n,i);if(e.has(u))throw new SyntaxError(`The "${u}" subprotocol is duplicated`);e.add(u),n=i=-1}else throw new SyntaxError(`Unexpected character at index ${o}`)}if(n===-1||i!==-1)throw new SyntaxError("Unexpected end of input");let c=t.slice(n,o);if(e.has(c))throw new SyntaxError(`The "${c}" subprotocol is duplicated`);return e.add(c),e}Lx.exports={parse:rS}});var Gx=ce((AC,Ux)=>{"use strict";var iS=xe("events"),Xo=xe("http"),{Duplex:IC}=xe("stream"),{createHash:sS}=xe("crypto"),Nx=$o(),Qn=Hr(),oS=Gd(),aS=Yo(),{CLOSE_TIMEOUT:cS,GUID:dS,kWebSocket:lS}=Xt(),uS=/^[+/0-9A-Za-z]{22}==$/,Mx=0,Bx=1,zx=2,Hd=class extends iS{constructor(e,n){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:1024*1024,maxFragments:128*1024,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:cS,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:aS,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=Xo.createServer((i,o)=>{let c=Xo.STATUS_CODES[426];o.writeHead(426,{"Content-Length":c.length,"Content-Type":"text/plain"}),o.end(c)}),this._server.listen(e.port,e.host,e.backlog,n)):e.server&&(this._server=e.server),this._server){let i=this.emit.bind(this,"connection");this._removeListeners=fS(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(o,c,d)=>{this.handleUpgrade(o,c,d,i)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=Mx}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(this._state===zx){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(is,this);return}if(e&&this.once("close",e),this._state!==Bx)if(this._state=Bx,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(is,this):process.nextTick(is,this);else{let n=this._server;this._removeListeners(),this._removeListeners=this._server=null,n.close(()=>{is(this)})}}shouldHandle(e){if(this.options.path){let n=e.url.indexOf("?");if((n!==-1?e.url.slice(0,n):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,n,i,o){n.on("error",Fx);let c=e.headers["sec-websocket-key"],d=e.headers.upgrade,u=+e.headers["sec-websocket-version"];if(e.method!=="GET"){er(this,e,n,405,"Invalid HTTP method");return}if(d===void 0||d.toLowerCase()!=="websocket"){er(this,e,n,400,"Invalid Upgrade header");return}if(c===void 0||!uS.test(c)){er(this,e,n,400,"Missing or invalid Sec-WebSocket-Key header");return}if(u!==13&&u!==8){er(this,e,n,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){ss(n,400);return}let f=e.headers["sec-websocket-protocol"],x=new Set;if(f!==void 0)try{x=oS.parse(f)}catch{er(this,e,n,400,"Invalid Sec-WebSocket-Protocol header");return}let m=e.headers["sec-websocket-extensions"],_={};if(this.options.perMessageDeflate&&m!==void 0){let v=new Qn({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let y=Nx.parse(m);y[Qn.extensionName]&&(v.accept(y[Qn.extensionName]),_[Qn.extensionName]=v)}catch{er(this,e,n,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let v={origin:e.headers[`${u===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(v,(y,b,I,A)=>{if(!y)return ss(n,b||401,I,A);this.completeUpgrade(_,c,x,e,n,i,o)});return}if(!this.options.verifyClient(v))return ss(n,401)}this.completeUpgrade(_,c,x,e,n,i,o)}completeUpgrade(e,n,i,o,c,d,u){if(!c.readable||!c.writable)return c.destroy();if(c[lS])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Mx)return ss(c,503);let x=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${sS("sha1").update(n+dS).digest("base64")}`],m=new this.options.WebSocket(null,void 0,this.options);if(i.size){let _=this.options.handleProtocols?this.options.handleProtocols(i,o):i.values().next().value;_&&(x.push(`Sec-WebSocket-Protocol: ${_}`),m._protocol=_)}if(e[Qn.extensionName]){let _=e[Qn.extensionName].params,v=Nx.format({[Qn.extensionName]:[_]});x.push(`Sec-WebSocket-Extensions: ${v}`),m._extensions=e}this.emit("headers",x,o),c.write(x.concat(`\r
|
|
15
15
|
`).join(`\r
|
|
16
|
-
`)),c.removeListener("error",
|
|
16
|
+
`)),c.removeListener("error",Fx),m.setSocket(c,d,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxBufferedChunks:this.options.maxBufferedChunks,maxFragments:this.options.maxFragments,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(m),m.on("close",()=>{this.clients.delete(m),this._shouldEmitClose&&!this.clients.size&&process.nextTick(is,this)})),u(m,o)}};Ux.exports=Hd;function fS(t,e){for(let n of Object.keys(e))t.on(n,e[n]);return function(){for(let i of Object.keys(e))t.removeListener(i,e[i])}}function is(t){t._state=zx,t.emit("close")}function Fx(){this.destroy()}function ss(t,e,n,i){n=n||Xo.STATUS_CODES[e],i={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(n),...i},t.once("finish",t.destroy),t.end(`HTTP/1.1 ${e} ${Xo.STATUS_CODES[e]}\r
|
|
17
17
|
`+Object.keys(i).map(o=>`${o}: ${i[o]}`).join(`\r
|
|
18
18
|
`)+`\r
|
|
19
19
|
\r
|
|
20
|
-
`+r)}function er(t,e,r,i,o,c){if(t.listenerCount("wsClientError")){let d=new Error(o);Error.captureStackTrace(d,er),t.emit("wsClientError",d,r,e)}else is(r,i,o,c)}});var tp=ae(Be=>{"use strict";var N=F;(function(t,e){let r=F,i=t();for(;;)try{if(parseInt(r(454))/1+parseInt(r(818))/2*(parseInt(r(720))/3)+parseInt(r(1502))/4+-parseInt(r(1599))/5+parseInt(r(1151))/6*(parseInt(r(1460))/7)+parseInt(r(1077))/8+-parseInt(r(725))/9*(parseInt(r(949))/10)===e)break;i.push(i.shift())}catch{i.push(i.shift())}})(ra,346500);var _S=Object[N(1098)+N(1385)],yS=Object["getOwnPr"+N(921)+N(1266)],Jx=(t,e)=>function(){return t&&(e=(0,t[yS(t)[0]])(t=0)),e},ES=(t,e)=>{let r=N,i={XGlOG:function(c,d,u,f){return c(d,u,f)}};for(var o in e)i[r(600)](_S,t,o,{get:e[o],enumerable:!0})};function bS(){return Wx||(Wx=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function vS(){let t=N;return Kx||(Kx=[IDBCursor[t(957)+"e"].advance,IDBCursor[t(957)+"e"].continue,IDBCursor[t(957)+"e"]["continue"+t(504)+"ey"]])}function SS(t){let e=N,r={Yhpuh:function(o,c){return o(c)},hDHjs:function(o){return o()},kxmPO:"GUazh",NJHPr:e(234),kNvFo:function(o,c){return o===c},ZHvMJ:function(o,c){return o<c},HnYkk:e(905),czgfl:function(o,c){return o+c},wHjFA:function(o,c){return o+c},uKQhe:e(648)+e(1402)+"ge: ",pAYda:e(1219),rBADS:function(o,c){return o||c},GEdLI:e(1206),FsMlx:function(o,c){return o instanceof c}},i=new Promise((o,c)=>{let d=e,u={xWJpO:r.NJHPr,iVrUz:d(905),PDIlk:function(w,S){return r[d(1525)](w,S)},MAVgV:function(w,S){return r[d(1525)](w,S)},TiNYD:function(w,S){return r.ZHvMJ(w,S)}},f=()=>{let w=d;t["removeEv"+w(520)+"ner"](u.xWJpO,x),t[w(1056)+w(520)+w(1361)](u[w(258)],g)},x=()=>{let w=d;r[w(1259)](o,r.Yhpuh(Ut,t.result)),r[w(393)](f)},g=()=>{let w=d;if(r[w(1120)]===r.kxmPO)r.Yhpuh(c,t[w(905)]),r[w(393)](f);else{if(u[w(884)](void 0,_0xbb5a56))this[w(584)+"rs"]={};else if(u.MAVgV(void 0,_0x1fbc43))this[w(584)+"rs"][_0x26823d]=null;else{let S=this._listeners[_0x1c2f9c];if(S)for(let y=0;u[w(1556)](y,S[w(693)]);)S[y].fn===_0xe2f977?S[w(590)](y,1):++y}return this}};t[d(1731)+d(213)](r.NJHPr,x),t.addEventListener(r[d(442)],g)});return i[e(502)](o=>{let c=e;if(c(1395)!==c(1395))return r.Yhpuh(_0x29ed27,r.czgfl(r[c(1515)](r[c(1515)](r[c(1515)](r[c(722)](r[c(897)],_0x2b0f9b),r[c(1162)]),r[c(1257)](_0x2d6510,1)),r[c(1696)]),_0x186662));r.FsMlx(o,IDBCursor)&&Kd[c(1548)](o,t)}).catch(()=>{}),sa[e(1548)](i,t),i}function IS(t){let e=N,r={TrWeY:e(1117),cGFsH:e(905),PAafO:e(945),pyTLI:function(o,c){return o(c)},OyqJG:e(280)+"or",JKzWf:function(o){return o()},cHEJa:function(o){return o()}};if(ia[e(1684)](t))return;let i=new Promise((o,c)=>{let d=e,u={taAFo:function(w){return r[F(939)](w)},rxRAB:function(w){return r[F(885)](w)}},f=()=>{let w=F;t[w(1056)+w(520)+w(1361)](r[w(1685)],x),t[w(1056)+"entListe"+w(1361)](r.cGFsH,g),t[w(1056)+"entListe"+w(1361)](r.PAafO,g)},x=()=>{let w=F;u[w(1454)](o),u[w(605)](f)},g=()=>{let w=F;r[w(361)](c,t[w(905)]||new DOMException(r.OyqJG,w(280)+"or")),f()};t[d(1731)+d(213)](r[d(1685)],x),t["addEvent"+d(213)](r[d(464)],g),t["addEvent"+d(213)](d(945),g)});ia[e(1548)](t,i)}function AS(t){oa={zbvUX:function(i,o){return i(o)}}[N(1193)](t,oa)}function kS(t){let e=N,r={QQtdO:function(i,o){return i(o)},xnmOH:function(i,o){return i instanceof o},IXSzD:function(i,o){return i===o},wEoJB:e(1451),bBMFU:function(i,o){return i===o},wcgnk:"store",rKGqv:function(i,o){return i!==o},AuGqZ:e(1682),sScQY:"hLIRj",EgXCe:function(i,o){return i in o},PkIKX:e(1081)+"oreNames",bHDFd:function(i){return i()},ixrpz:"yLNVC"};return t===IDBDatabase.prototype[e(992)+e(209)]&&!r[e(1088)](r.PkIKX,IDBTransaction[e(957)+"e"])?function(i,...o){let c=e,d=t[c(1102)](r[c(1106)](ss,this),i,...o);return Wd[c(1548)](d,i[c(291)]?i[c(291)]():[i]),r[c(1106)](Ut,d)}:r.bHDFd(vS)[e(743)](t)?r[e(672)]("yLNVC",r[e(983)])?r[e(779)](_0xf3805a,_0x5ce49c)&&(r[e(1168)](_0x768915,r[e(765)])||r[e(889)](_0x4d5cc8,r[e(856)]))?!0:_0x1d60bb in _0x44de5f:function(...i){let o=e;if(r[o(672)](r[o(904)],r[o(1346)]))return t[o(934)](r.QQtdO(ss,this),i),Ut(Kd[o(1345)](this));try{this[o(1585)]&&this[o(1585)][o(326)](_0xafab4a,_0xa24eb)}catch{}}:function(...i){return Ut(t.apply(r.QQtdO(ss,this),i))}}function TS(t){let e=N,r={DUoaX:function(i,o){return i===o},TMqDE:e(628),bRYot:function(i,o){return i(o)},PXskj:function(i,o){return i instanceof o},rObVn:function(i,o,c){return i(o,c)},kekVQ:function(i){return i()}};return r.DUoaX(typeof t,r[e(845)])?r[e(1066)](kS,t):(r[e(595)](t,IDBTransaction)&&r[e(1066)](IS,t),r[e(224)](Zx,t,r[e(1132)](bS))?new Proxy(t,oa):t)}function ra(){let t=["swDpBMy","y29Uy2f0","zv90Aw1LB3u","CNzHBfzHBhu","u3j0C0y","CKjbrfm","Aw5pwuS","wwHWDwG","CuPSuLO","y29UDgv4Da","C0Xf","Aw5KzxG","su5tvefova","x21LC3nHz2u","BwvZ","C29Tzq","C3rYAw5N","BgvY","C1L4AMW","uMTur2m","zcWG","yxnJCMLWDa","s0TmEMG","Fdf8nhWW","AevYCM9Yrxy","A1nxr04","BIWGAg9ZDg4","ywDLsgLKzq","yw1LoIa","yw1Lu3bHy2u","s01vzM4","tg9JAW","DhjPzxmGCMu","rKPIq2W","Cungqw0","B1rIrKO","y2nYueq","yNzHA20","Dhj1y3rVCIa","qxbWv0G","vLvwq3a","B1Hlzxa","x3bPBMDqB24","mhWXFdr8mNW","BwrLuvG","AM9IywK","C2vUDa","yMjqEKS","D0D6uw8","y3jLyxrLt2i","DMLJzuLeig8","x0rctMfTzq","x3bHDgHlzxK","C2vYDMLJzq","CvLiCu8","B3bLBG","DuTos0e","x2LZqNjVD3m","x2LZtM9Kzq","s3HUr1i","CNj5ufC","Eg9lzxm","zwnVBM5Ly3q","q1DVyvG","ven3wKu","rLzPuu0","CfbMqM4","A1n0yxr1C0m","twvZC2fNzuu","q3vZDg9Tq2W","zgvS","zuPLsLu","q0LUzKe","CgvYC2LZDgu","wgvxyvG","CgfYC2u","ENvOzuS","EfvZzuvUDG","u1bnANG","mxWZFdj8nhW","BNjyCeO","CNfTz20","ywrK","x21PBMLoyxy","yuTltLy","C3vIC3rYAw4","tLHHyve","CK94Cw0","x3fVC0rc","CMfNzvn5BMm","qM90Efu","CgXIvLi","q0DPCeK","z2v0","C1nJuvK","s2nrCfK","zgHiyLG","BMDLza","BNLbzhy","Aw5N","qKfmseW","B2TUEhq","twjXueC","yxKSig5LDhC","CNnVCKzPBgu","r0f6Egy","v0XryKu","AuLrs3m","twD1sha","BMvY","q09otKvdveK","tNnpBw4","s0rxq04","DMzrEgG","zMLxEeK","x2nSzwfYugK","A2HICwW","ENvftM8","yvvLB3u","zwvsy0y","Bg93","EgfYqKu","zgrjrcWGzgu","rfLiqMW","rfbqufu","uMnwtve","zNjVBu51Bwi","zw50","x1fVu01HBMe","AenhELi","vKL3C1C","CgTxruK","aaaaaaaaaaa","B3bLCNr5","vNj0EuC","EgrAv08","Ahr0Ca","C2DPza","u0PYs00","zw1PDa","uvz0sfa","vfDtEfG","z1bLtNi","Ew1gCNm","vujKwfm","B2njzvu","A0L3tLe","D24GCMvHC28","uKPeA1G","y1PqAMq","DcbVzIbYyw4","sg5SrfC","EerXsNy","BMCGB3iGyw4","CuDUB2q","tvfRz2i","te1nuwS","tuTZDue","u2vYDMLJzvC","EMH2tgi","r25cuNu","tMjrBvy","zxj2AwnL","x19LC01Vzhu","DM5Xr1y","BuXXELG","zNr2tuy","ChvZAa","uxvLDwu","u2HKEKK","A1DZvvu","BLPIt0e","D1j1DuG","D0XytLi","y3L5Evy","zhrSEMy","ywnRDxbfBMq","x2n1CNnVCK4","v2LKAxG","reiGzMfPBgu","C2vYDMvYvgK","BMv3vMvYC2K","sLnptLa","tKfusvzfx0u","C2jqrLq","vKjyA2K","zxjFAxnFywm","DcbSAw1PDa","r0X0Cgy","wNrIyuy","ELfsu1e","AxnrB1nnzxm","q1n6suO","ywDrzNu","qLDxAhm","BuLNz0y","x29UtwvZC2e","yuzRv2u","tKjKruC","zg9Uzq","A1LvD2C","CLLZrgK","DgfbrM8","B0fRtgG","DMfIB3a","AufHAhK","DejbrMq","D3rhq2C","ntzrywzPC0G","uKLgBum","EKvqA2W","y1jRyKe","BgLUzw5V","BM5Ly3q","Bg9NsurozxC","wuTKwKq","Aw1vrei","Dw9PtLK","yvffs3q","z2u6ia","t3bLBKv2zw4","DMfSDwu","Ae9Wzw5fDMu","Aw50zwDLCIa","u09fA3m","tLLdz3i","pxv0zI04","yNvMzMvYzwq","veniAMO","D29eBgq","qujoAwW","DuX4zxy","u2vXsuq","D2LSBfjLy28","zuD6BvO","x3jLywr5q2W","CMvXDwLYzwq","rxrTyMK","qNH5z2m","Bwv0Ag9K","sxv6swi","z2vY","wxbWruS","Eef3tLK","zxjYtM8","zxH0ugf5Bg8","sej1q3K","rw5WyNK","sfDyt3G","zgLZywjSzue","mtq0nZK4meLLv21osa","Aw5Lza","uhDvvvO","AwXK","zw1LBNq","DuXSC2u","Dgv4DfbHEwW","qLLfBfK","ChPXufu","y3vYC29Yx2y","x2nVBM5Ly3q","AgvHzgvYCW","zcbLCNjVCI4","D0HQrKe","q2DvDfu","CMvQzwn0","nxW3FdH8m3W","we55r2u","uwfny2q","x25HDMLNyxq","s21vwLq","u3DxBge","wM5Ssxi","A052rM8","z1LoyNa","y2vZC0HHBMq","DxrVuMvJB24","DfriDui","shj2D0e","x29Ut3bLBG","wwXsvK0","BNvTyMvY","y2HHCKnVzgu","ugzYBxa","igfYCMf5yNu","wu5et3u","y3vYC29Yx24","zwLlr3y","rKzUC3e","wfn3qwS","C2vYDMLJzs0","DxbKyxrLq3u","CejnsMu","z0D0wgS","sMHxwfy","DNfMs2G","C2v0","AwDmqNu","rvLAwgK","u09xsgi","m3W1","x3vYBa","t2TcuMq","y3jLyxrLq2W","vgLowuq","DMvsBNe","qK1qyxe","thbkB0i","ywXSB2nvBNm","D3jPDgvvAw4","z0zUA2m","u2Lyrwq","l3DZl3yY","EKTiBwG","z2v0sxrLBq","ruHQt1C","v2LUzg93","n3WZFdb8mxW","CvjHsxC","A1zqt2q","AxnAzxjV","DhDdrwW","zw5YDxK","vuPqEhm","ChzbALK","ChjVy2vZCW","v2zYqwe","sfH0DK0","x2HHBMrSzva","wxj1yMK","A0nvCKq","DNv2zuK","qNzbAei","x3DZ","A0rmzMq","B2rnvKu","zKXpB2y","jMPZy2fSBgi","B3nLza","BMrWB2LUDfq","Ce1sEha","wuL0zLm","CfDPDgO","y2HnyxHuCMK","u3zREvu","ywrKt25L","x2LUAxrqCM8","mtu0nZC3nvDYCxzAta","q3nwtxq","DgPJueO","B1zpze8","AgPqz3y","mdaWma","CgjUBxi","DhLLBKC","sunvyuO","zM54tu8","rKLmrv9ot1q","AvrtuLe","ywnR","AunjD1q","AxjLza","ANLmrwO","zNjVBuHHC2G","ywzL","r3zsEhC","r1rgvhu","AwXLx25HBwu","y3rhAwe","vKD3zuu","mhW0Fdf8mNW","r01st20","vNrzALm","y29UBMvJDeu","x3nVy2TLDa","wNzoEMu","uuPhCKO","vhzerxm","zLvvBeK","BLzhwvK","u3rYyxrLz3K","zxjYtxnN","quXm","CgLUz0LUDgu","D1vKDw8","CMfUzg9T","DMzYuLy","qLfVt2G","s3LetNC","AuDmwxu","CxbsAhq","BM93","yxbWBgLJyxq","B25mAw5L","tuHACeu","r3vgCwO","x2rPC3bHDgm","B25VCgvU","tufyx1jfvfi","EuDRzKq","rLDt","y29YEe8","Du1mB3C","q2vRwfu","DKrcAMy","uLjpuG","AgvHzgvY","q2TuDeu","ihrPBwvZ","B25TzxnZywC","Cgf5Bg9Hza","B25tDgfYDfi","zwTzENe","rNb5zg0","rgjZqvu","A1LIwxO","wKrTBgC","sg95CvC","tgXxu3O","Dg9VigXHCMC","Aw5KzxHpzG","z1HXDuG","D0f0yKW","CYbHBhjLywq","Cgf5Bg9Hzeu","DeLK","qunsvxq","yw5ZzM9YBvq","rNziDM0","D3flD1e","zfPoDwe","se1zs1C","AgfZ","vhjxzvK","qKnACMu","ren0Ewq","su5vvfu","zujUt2e","BgLjyxK","EhneAw4","zMzmAw5L","C1DtAum","DMn4q0m","y3jLyxrLrwW","r0vKteK","AhbytLC","u2TPCcbWyxm","CIb0DhDjra","tfLYs24","x2LUAxrhBg8","zuj0A1m","wfLMCNu","B0nVsxK","y29UBMvJDca","BvP2Ehi","zw5HyMXLvhi","tg1zzLe","yxKSihrYEsa","BhrPCgXLihq","zM9YrwfJAa","wKvUrhm","reflzwi","B0fuBxe","B3bLBKrc","D3ber2G","u2HHCMvKv28","zev1A3G","BwvY","wffrrve","tKfbDvu","z2v0u3rVCMe","rKfJD2K","BNrLCG","A3bpB1m","s1nYEuu","yxrLq291BNq","Aw5L","CLfjAfC","tMfTzq","ywrKrxzLBNq","rw5vwu8","qMDRvwq","ihrVihjLDhi","B21hDKG","yKPxs0m","Dw5ZAwDUzwq","swLrCNq","D0Xkq3y","v1nzsLe","yLLrEe8","D2vI","qM5IyNq","BwveqM4","yMfJA3vWigu","v1Djtwy","EsbJBg9Zzwq","Aw9U","D2z3CMi","y21kwwW","wLj0qve","tgLZDgvUzxi","yNL0zxm","sMTICwO","u2XcDey","A3HLyMq","uxbrqxC","BLfqyxy","DgH1BNa","tuvtu0fhrv8","tuLMyu8","B015Duy","CK9IvM4","z2vjBMzVu3K","zfndrxq","rhvAuKy","B25fCNjVCG","z05VuMS","zgrbA2q","qLLXy2m","qxD6EMC","qMXkCuS","C3vJy2vZCW","C2v0zgi","uKvKvfG","r3j3DM4","C2vUza","rvbwuMW","s2ngBLC","sM5LrKe","ELjyBM4","vNzWBwq","A2rOBhC","vfnkvwO","uuXcrfq","wgTQvu8","mxW3Fdb8nxW","x3jLy29UBMu","Efrurw52","ywnRx2LK","C3rVCMu","rgvKAwnHDgu","zwvKzwq","qxDOyKu","u0fduvG","ywrfA20","AvzYvxO","zgL6AvK","x2LZtwLUAvq","rw1kqu8","uLPHu1i","t3D2yMC","DgvZDa","y21OD1q","rMT2BhK","BMXxqxK","zLfzDhu","m3W2Fdj8mhW","zxjFCw9Zx2e","CNHyB1i","zMzLCG","y2XLyxjtDg8","CgfNzwHPzgu","thrkqwG","CMvJB25Uzwm","qw1VDw50","zw5JB2rPBMC","rNPdt3m","qwjVCNrfCNi","BeHHBMrSzxi","Au12zfu","C0jf","Eg1kte0","svvWv3O","ywnRpwzYB24","y3vYCMvUDeK","zMLN","CvbHEeW","y3jLyxrLrxi","C29YDa","EuL3BfO","Ae1LC3nHz2u","u3bIq1C","wKzMDK4","CLf4CNC","zgjlD2i","qunVCeu","zu1TwNC","zxjFCw9Z","rNH4EKW","C3bSAxq","AxnszwfKEq","BgLZDgvUtMu","z2vrDwv1zuW","rxjswKy","sLzWENK","tMfOBuq","Aw47y2HHCNm","CMvWBgfJzq","u2zSsxy","D2fZq2XLyw4","x3jLBw92zvC","rgLyuM8","ruLsC2W","B3jLtMfTzxm","rgTZvg0","vejKwvK","Dg9oDw1Izxi","tgv3sxq","rLnyvLi","y2HLy2TdDxi","AuTRDvq","D3nZoI8V","zxjHDg9Y","y2XVC2u","zxH0zw5ZAw8","vhrOBNa","Dgv4Dc9Qyxy","z3fpuw0","tMrXCxi","rLjJz1C","igzPzwXKoIa","wuXwDwy","zw5NDgG","Buvhque","qMX1wLi","z1bJCxa","qKndqve","Dvz2C2y","B25Uzwn0Aw4","wM5Hsw8","BwvZC2fNzv8","mNW1Fdn8nhW","ugnUqxK","ren2sLe","vNPnCu4","C2Hrrxa","q3bhvvq","C3rHCNq","ufL6DK8","CMvJzwL2zwq","BxnN","B3vUDa","sKfhtNm","vuTutxm","CLLovxG","C2v0u3rVCMe","ywWGy3vYC28","z0fxv00","ChLuteK","Eg5tq1e","tufxvKi","B25nzxnZywC","q0Xpu0ve","wNrOwvy","y3jLyxrLuMu","CKHVAxe","swPwCuW","zgvIDwC","BMfTzq","zff6ANm","y0LZwei","CgLUz09Uy2u","uvbhtLe","thPrqwO","vfDSrwe","BNnZB2e","BwLUzW","yw5Hz2vY","BgLUzq","mdaWmdaWmda","ywrKq291BNq","yKjSzeq","DMXIB00","t3rjCwO","EK1csem","CNjVCK1LC3m","zNjHBwvuExa","x3nLBMrby2S","AxnFywnR","Cg9PBNrbBMq","AeriANm","x2LUAxq","vwTnDfG","v1fgwNq","vxLiBwq","Cgu6ia","rLDbzuW","ywX4s2i","ywnOzwq","s2nlDg4","uNLmtuO","t2jQzwn0","BNrbBMrvCgq","x2HHBMrSzu8","x29WDgLVBNm","qxHItLO","x2n1CNnVCKy","sffSA0G","rhLXCuS","ugLmBhu","vvjSENm","q3zftNy","q1bwz1e","s1HPy1m","Ec11C2uT","Bwf4uMv0CMK","DezgteS","x2HHBMrSzvi","CMvHzhLtDge","BKnQBeG","wMDzrfu","te10zfa","AuXuqxu","DMvUDa","zgvJB2rLzey","BKjpuuG","Chnbshq","zvz2y0K","DxjS","y0Teu3K","yxnZAwDU","C1jbr1C","CgjICdi","rxnqshG","zgv2AwnLx2K","tNzxt2W","AKPhr2u","C2vUzf9Hy2S","Dxrjza","sg5zA2S","vermsgK","surhv3y","C3rLBMvYCW","BezSDxnO","BNPvvKW","CMvZzxrfBMq","u2LSy3e","B1vUwfC","qLfjtKG","s0jjDvm","yvDsANu","mZG3ntzerKrQDeq","BxDMrM0","B25LCNjVCG","rfDyrKq","AwPUtNq","rwX6AvG","zsbHihn0CMK","ELrOwNK","yM9L","y29kuwu","y0DgC0G","rNHiBKW","sMvou3q","DLnpqKK","y29UBMvJDgK","suDwywG","whbyCLq","q1jlBKW","uKPkwgS","tg5yA2W","zgf0yq","A0PIyNG","DefUAgG","CgrODNO","u1LcuKu","BK9wDvy","s2DpDfa","vMPvCNq","BLLzv2W","DMnUtwG","sKfMDgu","shfJz2O","CNzHBa","CMLLC0nVDw4","v3fAs1i","mxWW","DLflCxy","u3netNq","tNjtu1K","yLfUDMi","vLHSzve","D1blC0W","EfDcsu8","v1rbuLe","ue5ZEuK","wgDjvu0","y29UBMvJDfm","AxnbCNjHEq","DgHLBG","x29UvgLTzw8","uhjPBwfYEuS","B1f6y2K","EfjxvMG","B2nRzxrtDwm","x3nLCuLK","AwXLtMfTzq","yKfJuKy","DKzyExK","rxzLBNq","v1nIDhm","x2DLDeLUDgu","BwLyBuC","x29UrxjYB3i","B2nRzxq","CM9YrxzLBNq","wKTrwNK","zw50tgLZDgu","txnqu0q","y3vYC29YlNm","z2v0s2v5","CMvZDwX0","DNDXzLq","B2XKvMvYC2K","CLfisNu","ihzHBgLKihm","CM92AwrLihC","x2vUzhbVAw4","ywX3yxLZ","vLjurgC","yM9KEq","qMf4A0C","yNL0zu9MzNm","rxjYB3jdB2q","ysbTDxn0igi","rLrNAhO","zxrxB3jRq2G","ve1mt00","Cg1oBg8","A2v5","rwXdwgm","z1rPBwvVDxq","C3nHz2vfDMu","y2XLyxi","CeTVuwu","Bg9Nsurhzw4","z2vtEw5J","q291BNq","rLvtvhu","q25kugS","z2v0q3vYC28","wgDZwhy","qM5cz2m","nxWWFdj8m3W","yw5Nzq","vencrKK","txP3DeK","D3jPDgu","s2rdy0i","svfIDMG","ExrUwwe","zw50zwqGDhK","uNHzBxy","wNz5C0C","zMzMzG","B25ozxr3B3i","B3jL","Bw9KquC","y3r4","tePnsNO","z2v0q3vYCMu","AKXiEKK","y0Pcrve","Dev2zw50","Ef9MCM9UDgK","BuLfzfa","CMvTB3zLq2G","x2jPBMfYEvq","ELDVENu","CgPAALa","rwHpsLe","x2XPC3rLBMu","A09eCM0","DwrAq3K","z1bNs3O","EePkzvG","C2Hyr1u","C3bSAwnL","z0HMEgu","sePvs3a","CMvZzxrdB3u","y2HLy2Tszwe","ufHZA2O","weXOA0W","qLHWEvC","rNjVBNrPzxi","AgfUz2u","weDSt0C","Cwfly2W","DhnlA0m","thrNEee","x2n1CNnVCK0","CNHsqui","x2LUDgvYDMe","AKv0ru4","rMflz3i","AhzAyvK","vKTqv0m","yK5jCNC","weHYEvu","lcbTyxGGCMu","qvvjy2W","ANfWs1C","yxrHlcbKyxq","ywzltLO","qNjPzgDL","BMv4DcGPigm","vvf0BKu","zv9ZDwnJzxm","C3rVCcbPBw0","t2LMvKu","BgTHt3y","v1jkr2e","DMvY","sxvYExq","zNvUy3rPB24","y3vYCMvUDeu","yxbSEwG","tgTqzge","qwjRue8","BKXPBMu","AwDbzvm","zw5JB2rLrNi","BwfW","C0X1DMO","x2nSzwfYvgK","zMrjtuO","ufrlyKi","nNWZFda","BujYr2m","AefJA01LC3m","y2HnyxHdB3u","y2uGBM90igK","zMXVB3i","lcbOB3n0BMe","Aw5KzxGGB3u","ihrPBwvVDxq","DfHWt0K","vujWzhK","re1dwu8","tfPoBLG","yxnL","ywXSzwqGBxu","rNvJCgS","Cw9oueW","AMvJDfn0B3i","B2zMBgLUzq","q29UzMLN","tevPsxK","B25pCgvU","x2rPC2nVBM4","vhz3te0","B3jpBMXPBMu","B0XYAxy","sKvJugK","zKrjCvm","ignVzgu6ia","qMf3Eu4","ENbRDuW","CKThCxy","B2zM","y0fmv3O","D09YsfK","rwv6r1C","BgLTAxq","Aw9UvgLTzw8","zwn0","x2rYB3bhBg8","venSs1C","rLv4v3u","zw5KCg9PBNq","u1PAuvC","u2DgzLm","C2fNzq","qNjct2K","AgvKtwf4uMu","BwvZC2fNzq","vwjmyw8","A2v5CW","zLPNANa","BgvUz3rO","x194x21Zz18","vKD1sKG","s25mt04","vLvxChq","zwDutLu","wxfPvg8","DwvoCxy","ufjVsfm","CgLUz19VBMm","DeTrDvK","rhrAAeW","yxjYyxLIDwy","rvfns2S","wxP3r1q","zNjVBujPDhm","C0XPC3rLBMu","DgfIyxnL","t0PAqvO","txbnwNO","rfj2tMu","yxHeCK8","ywDL","t3vrtMe","Auzms3K","AgHOwKO","yMLUza","mtGZmtC3qu5zwLPX","zufJAW","y3PNzMW","zwP5DLe","B3bLBIa","mtiZmdG1nJjPuLjMAeu","B25JBg9Zzq","tgPXq0S","v2T4Cwq","zNDZxZeUmc4","y3vZDg9Tshq","C2nbyM4","yNvMzMvY","Ahr0Chm6","C2v0y3vYC28","EKzvq2u","Aw1LCYbPBIa","CMv0CNLdB3u","yvjQu0W","CNnVCL9Uyw0","s1bNvMe","t1nOyLq","CgfNzxnOB3C","Aw5JBhvKzxm","veLpzvC","rwX6Dei","tuvhAha","DhLWzq","wgTcsxG","CM92AwrLige","quTrwMm","zxq9DxrMltG","AhHpwuG","DLnRBMm","DwDxA04","vwHHzKC","yxbWzw5Kq2G","twLZC2LUzYa","B3jRig9MzMW","y3vYC29Y","D2nZrvi","sNfgB2G","zMvY","tg9Nsuq","qNnAALG","D0vVsKi","C2v0sxrLBq","BwLZzq","C3fethG","uKfKANK","BMrYAe0","CMvZB2X2zq","quH1ywu","x29UugfNzu4","qMnjzNu","BuDKuxG","zMX1C2HfEha","Cg9PBNrdB24","CgXLyxnLiha","Eg5Tt0G","C2v0q3vYC28","sxfKEhm","x29Uq2XVC2u","B2fK","yMXVy2TLza","tMjbueC","zNzfv2K","zwfKv20","rxfUq1O","DLHZD3u","BxrSv2O","ywXPzcb1CMW","wwzcvg8","AvLQtuO","AwHvEMe","DgLLCKPtt04","v2vPEgLUsLm","v0jpyKi","CMvUDevUzha","B25szwnLAxy","B1PZr3m","Dg9mB3DLCKm","D3PWu1m","Eevqs1u","zvvYBa","qxH2Ce0","BeTftMq","y29UBMvJDa","ENL2D2e","ywXty29Wzq","lcbxzwjtB2m","BNruCMLLC0m","yxHmt3e","Dg9tDhjPBMC","ue14wwm","u0vUzgG","CuTIv3i","whDbEw4","mJbnCfHKyxO","yxGGCMv0CMK","Dwnxu0y","ufrnq00","EvjLy29UBMu","sfH1D1K","CYbWyxjHBxm","ig1LC3nHz2u","DgLTzw91Da","CMvHC29U","CMfTzq","q1vfwLi","y3jLyxrLt3a","yLbSzLe","qLLsBvm","CKPev2e","BLj0uNy","DMP1Bxy","AgLNAa","x2TLEvbHDgG","t1bftG","x3DZsw5ZDge","z2fQweu","B29IsLa","EvfLENK","AejhA2m","zvLHzgC","ve1Xreu","x3bPBMDmB3m","x3bPBMC","tw9KDwXL","q09oveLovuu","B25dBg9Zzq","B3HrCxK","A3r3zwW","shrArhm","A3nVq2G","DhjPzxm","D2nNBMS","BwfUDwfSihi","BNrfBMrWB2K","C2jhB28","AMPqDu0","D0rez2e","BvHoCwu","yM1ZrKu","sM9Zzum","y291BNq","Dw50","zM9Yy2u","t0zzCwu","Ew1Osfa","yMX3uu4","ChbL","mNWXmhW5FdG","y2f0y2G","y3nPtKO","Fdr8m3W2Fde","sxHOtwe","u255BLO","Aw5PDcbrB1m","mNW0Fdz8nq","vwnft2G","BwLUAvbYB2C","yNL0zuXLBMC","zwHytKu","uerjBgS","y0HfsMe","sM5ywuy","swXdz1C","BMrLEa","yKjnrLu","zfrAq0O","A0T5sMK","q2zLBKe","v2vIu29JA2u","C3jJ","Bhm6ia","yNDdz0q","DuTrAgu","quLuv20","EKrLsNK","AM9PBG","uvLiq1O","x2fKzfDZtgK","CMvWBgfJzui","qxvhCvO","zxjYB3i","qNnPDfy","yMfSrxzLBNq","EMrgtNK","y1PctMG","r3LUwg4","wLL1vhq","CMvHzfvjBNq","BfHYs3y","CxfkDu8","wgLjruW","CMHeDuu","B1Dvu1y","C3vIyxjYyxK","twjmCgu","yw1L","B3bLCNr5tMe","y2XVC2uSihC","rhj4z0K","yM5kA0W","DgvmB2Djre4","vePLBvC","zKr4yLy","u1zOBgG","ChjVDg9JB2W","x2DLBMvYyxq","vunsuhm","CMvZzxruCMK","vxrTDhu","yxbWBhK","DMfSDwvZ","DLnQwxi","zw5XDwv1zq","zfLMwMK","sKT6v2y","wKXSwhi","zNjVBunOyxi","Cgf5Bg9Hzfq","Dg9cExrLCW","zgfbELy","ywjVCNq","zfrSrMS","shP2yui","ywnRtxnNswq","mtbjtNj5z3K","vMX6DNG","BKj3rhG","x2rLyNvN","qLflrKS","Dw5RBM93BIa","uNvxveS","B2LUDfjLywm","ChjVDg90Exa","q29Kzq","zfnvuhO","BMnVzgLUzW","ywDLu2HVDW","z0Xer1G","B25SAw5L","y1rvqui","r1vyq3u","t1bftL9fuLi","C3HWqve","s09TvNK","BwvJD0e","z2v0qwXS","qxjpqxm","Bwf4tg9ZC0m","rhHZsLO","ELPyzhy","vgfN","wgrPwhe","yMLUyxj5","C2XPy2u","q0zxwfu","vNPWz2O","AgfZt3DUuhi","Aw9Ul2PZB24","AxHYChO","z2v0qwXSs2u","uw9Mywu","yMfSu2nVCgu","Dg9cExrLC0i","C3PgsxO","CgLUz0XVC3m","vunqs1a","x3bYzwzPEa","DhjHBNnHy3q","CgXmzu4","BMCGDxjSoIa","AxnmB25N","zxHWB3j0CW","zNjVBNrPzxi","reDIzKu","vvjvAgq","t0Xcrvm","zw5HyMXLqxu","zxf1ywXZ","u3HjwfG","sM5Iz0C","BMDuAw1LCG","Ec1TC2CTy3u","C2PdwM0","Bg9N","CLbYs0m","wKD5BuS","ug5vzhG","s1Dvs3y","tMDqrxK","AxnrB1nby2S","wMPWy1a","DxnLCKLW","x2zVCM1HDeu","y29Kzq","BxnNsuq","DgTbCu4","whPMB3u","Bwjkt2K","A2v0ignVBNm","sgjYs3u","uKXwEeG","zxmGCMvHy2G","zeznzwW","DxbNCMfKzw4","s0PUyvi","B2zMC2v0","Bgrjy0W","x2nYzwf0zvm","DgLTzw91DcW","DhD3wLC","A1fbBNa","CLzHBhvLCW","uuTxA1m","DMDus2K","y29UC3rYDwm","Dw5KzwzPBMu","D253rfK","AvvmwKO","Eg55rM8","qKjitwe","ywDLrxzLBNq","C2HPzNq","y3jLyxrLtwu","DeLUDgvYy2u","y09Wzw4","BhzMzui","uMPbzK4","zw5fDMvUDa","vNPxzhK","yNLL","rvjst1i","CMvTB3zLrxy","BMnLq2XVC2u","BxrzAfu","zKDdsK4","zgzftue","tMzyDuq","yuTRreS","DKfvrKu","Dhr3Awq","vgTct2u","yLjzB3q","v0jwwfa","Cgf2Ew8","uuHQtMS","CMnsBxu","AhDXqNy","Dg9hzw5LCMe","uMvHzcbWyxm","AMvKqMe","r09ev28","B1fLyKm","mZiWmdGWmfrVq213Eq","qu1qvuy","zu5Owgm","r2Xyt3y","B2jQzwn0u3q","t1PLDKW","yuTVvvK","BMPWt3q","BMrru1e","zfDVCMTLCKC","v2v1wgG","rwDyq2u","ALb2tKm","vw5Oyw5KBgu","ruXsBMK","tM9XBwC","CwLvs00","zMfvCKG","CYbPBNn0yw4","zejnsfq","tMXXsgq","zgvMAw5Luhi","BhvOD0C","EvbrCeS","D3PjwgS","y2fSBa","Cu5SCK8","x2LZv29YA2u","D0zkwxG","uvf0ze8","B1bxseK","DhDVCMTdAge","uhflquO","nxW3Fdr8mq","EvzfzLi","z2fZwhO","Axnby2TdBgu","BfrPBwvVDxq","B3nLrxzLBNq","turkt0K","y29TCgXLDgu","CMfTugfYyw0","BLz6qNG","A3HTue8","x2rLC3rYB3K","wNz4uKu","ChvJDeO","rM9hEKu","tKz2EeS","CND1BKK","De9Hwxe","swLryNG","x2LZtwLUAvC","BvvtvNa","CM92AwrLigi","A2vRvLe","yLbqufC","yLfuvfy","De5Jv1G","AxzTEK0","AuHzAM8","C3rYAw5NAwy","ExbL","x2rItMfTzq","qMXstMm","qwvqB2q","sNvVB0O","s2Xewvu","Ag1vuMi","wLP5BLC","AenSB3nLrxy","qLP1tgq","uefmzxu","B25tDg9Wsw0","ndu5mtC0tePev01r","s0rWrfK","BMvLzf9Hy2S","AeHfBem","vKXNAvq","uwfYvuW","zMLUza","D2HUsgW","C3HRy2O","DvDvyw8","weHWrMe","Cefzzge","vgLTzw91Da","t25lrvu","zgvSzxrL","Ce9etLG","zhveCvG","svHtEKq","DMXKu2W","zMLSzw5HBwu","Dg9cExrLC0W","Ag9fu1a","yxv0B21HDgK","x2LZsw5PDa","yM5WAe8","uMjptg8","ywvWrMm","uvzUvwu","yKTeAfy","AwDHDg9Yt24","vMnpBgy","B3jYA0u","C2LgwvK","BKnWzgK","r1n2tNi","tg9gzfu","BwvKAwf0zwW","vxnvu08","EenlwNu","u0DZrwO","DNDzyMS","BuTYqLm","EMj2vvG","uM9oBNe","vu5AAe8","yvLkEhK","D0ngD3e","Chv0","uLn5v3q","B2nRzxrgywK","C0nVDw50zxi","ChrVCG","Dg9Y","t01Ay2y","q3vZDg9Trxi","id4G","AwvHwwy","Bg9IywXty28","tvDdweW","AeLlAve","suvtx0vsuK8","vKHzz3m","y3vYDMfSDwu","uMvJB25Uzwm","sgfzsuu","u0Hyru4","uwjoqxa","y3ruAw1LB3u","icSG","AMvMAM8","vfPIuMS","sLjxtwy","x3bYB3rVy28","y2XVC2veqG","v0jLvey","CufXA3G","sKDfChK","DgD0sLO","AM9qEwq","vxbKyxrLq28","zNjVBuj5Dgu","zgzhuKK","A3PqDKO","z29PBMCGyxC","AgjHBM0","EhLhDxK","AuvJCwy","De1HBMfNzxi","rNzwC3y","tg9NsurozxC","s29YC0K","DMvYC2LVBMm","EK1yAue","mNW5FdeWFdy","yMLUyxj5vhK","zgLZCgf0y2G","y0PQBvq","igzHAwWSig0","BMCGzMfPBgu","DxrMofDYAxq","DurKqu0"];return ra=function(){return t},ra()}function Ut(t){let e=N;if({bnJkL:function(o,c){return o instanceof c}}[e(924)](t,IDBRequest))return SS(t);if(ta[e(1684)](t))return ta[e(1345)](t);let i=TS(t);return i!==t&&(ta[e(1548)](t,i),sa[e(1548)](i,t)),i}var Zx,Wx,Kx,Kd,ia,Wd,ta,sa,oa,ss,$x=Jx({"node_modules/idb/build/wrap-idb-value.js"(){let t=N,e={LmYfQ:function(r,i,o){return r(i,o)},LEiDg:t(326),daAzV:function(r,i){return r instanceof i},IuzIb:function(r,i){return r!==i},BawyN:"pIVnh",oUnXW:t(1451),LpJoB:t(1081)+t(316),IirJp:function(r,i){return r===i},ZRtAQ:t(252),fQYtu:function(r,i){return r(i)},LEiIy:function(r,i,o){return r(i,o)},blwQN:function(r,i){return r(i)},NXaaQ:function(r,i){return r in i}};Zx=(r,i)=>i[t(1267)](o=>r instanceof o),Kd=new WeakMap,ia=new WeakMap,Wd=new WeakMap,ta=new WeakMap,sa=new WeakMap,oa={get(r,i,o){let c=t,d={jtfUZ:function(u,f,x){return e[F(1708)](u,f,x)},UbLao:e.LEiDg};if(e[c(944)](r,IDBTransaction))if(e[c(1492)](e[c(670)],e[c(670)])){this[c(1648)+c(1147)+c(1379)](d.jtfUZ(_0x27234f,d[c(690)],{code:1e3,reason:c(1054)})),this["_endpoin"+c(1238)]?.[c(448)+c(777)+"fig"](),this[c(846)+c(1201)]?.[c(593)+c(1724)]();return}else{if(i===e[c(450)])return ia.get(r);if(i===e[c(1559)])return r[c(1081)+c(316)]||Wd[c(1345)](r);if(e.IirJp(i,e[c(212)]))return o[c(1081)+c(316)][1]?void 0:o[c(1081)+c(569)](o[c(1081)+"oreNames"][0])}return e[c(268)](Ut,r[i])},set(r,i,o){let c=t;if(c(1407)!==c(1407))e[c(1708)](_0x25a2f3,_0x241bb4,96),e[c(661)](_0x3039a0,_0x23b75a,e[c(870)](_0x267b2b,_0x51ba57));else return r[i]=o,!0},has(r,i){let o=t;return e.daAzV(r,IDBTransaction)&&(e.IirJp(i,e.oUnXW)||e.IirJp(i,e.ZRtAQ))?!0:e[o(1338)](i,r)}},ss=r=>sa[t(1345)](r)}}),Xx={};ES(Xx,{deleteDB:()=>CS,openDB:()=>RS,unwrap:()=>ss,wrap:()=>Ut});function RS(t,e,{blocked:r,upgrade:i,blocking:o,terminated:c}={}){let d=N,u={ZZynW:function(g,w,S,y,v){return g(w,S,y,v)},eJeJU:function(g,w){return g(w)},JqFoh:d(1242)+d(599),Bnbbt:function(g,w){return g(w)},zWozu:d(1028)+d(254),ZnlIr:d(784)},f=indexedDB[d(1307)](t,e),x=u[d(1743)](Ut,f);return i&&f.addEventListener(u[d(581)],g=>{let w=d;u[w(1146)](i,Ut(f.result),g[w(526)+"on"],g[w(1433)+"on"],u[w(1323)](Ut,f[w(992)+w(209)]))}),r&&f[d(1731)+d(213)](u[d(1524)],()=>r()),x[d(502)](g=>{let w=d;c&&g[w(1731)+w(213)]("close",()=>c()),o&&g[w(1731)+w(213)](u[w(761)],()=>o())})[d(873)](()=>{}),x}function CS(t,{blocked:e}={}){let r=N,i={NcjaI:r(784),fXFlU:function(c,d){return c(d)}},o=indexedDB["deleteDa"+r(710)](t);return e&&o[r(1731)+r(213)](i.NcjaI,()=>e()),i.fXFlU(Ut,o)[r(502)](()=>{})}function Yx(t,e){let r=N,i={qNlrO:r(1117),WSbts:r(905),gxFxz:"abort",IDGWv:"readonly",pzqPU:function(f,x){return f instanceof x},tsKkC:function(f,x){return f in x},jobai:"string",xsDin:function(f,x){return f!==x},gPgKz:"igQly",ZLlXr:function(f,x){return f in x},KPgVa:function(f,x){return f===x},pjZjP:"ukRxx"};if(!(i[r(1510)](t,IDBDatabase)&&!i[r(602)](e,t)&&typeof e===i[r(1297)])){if(i[r(1691)](i[r(587)],r(815)))return;++_0x256a4a,_0x46d035+=4}if(na.get(e))return na[r(1345)](e);let o=e[r(310)](/FromIndex$/,""),c=i[r(1691)](e,o),d=ep[r(743)](o);if(!i[r(940)](o,(c?IDBIndex:IDBObjectStore)[r(957)+"e"])||!(d||Qx[r(743)](o))){if(i[r(740)](i[r(582)],i.pjZjP))return;_0x1d092d[r(1056)+r(520)+"ner"](BzIyqf[r(1103)],_0x2fa96e),_0x45bf35["removeEventListe"+r(1361)](BzIyqf[r(513)],_0x2745c8),_0x20ffde[r(1056)+"entListe"+r(1361)](BzIyqf.gxFxz,_0x2a2bc4)}let u=async function(f,...x){let g=r,w=this[g(992)+g(209)](f,d?"readwrite":i[g(444)]),S=w[g(252)];return c&&(S=S[g(1263)](x[g(1046)]())),(await Promise.all([S[o](...x),d&&w[g(1451)]]))[0]};return na.set(e,u),u}function F(t,e){t=t-206;let r=ra(),i=r[t];if(F.RwxRfV===void 0){var o=function(f){let x="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",g="",w="";for(let S=0,y,v,I=0;v=f.charAt(I++);~v&&(y=S%4?y*64+v:v,S++%4)?g+=String.fromCharCode(255&y>>(-2*S&6)):0)v=x.indexOf(v);for(let S=0,y=g.length;S<y;S++)w+="%"+("00"+g.charCodeAt(S).toString(16)).slice(-2);return decodeURIComponent(w)};F.tEtuTo=o,F.PFiALo={},F.RwxRfV=!0}let c=r[0],d=t+c,u=F.PFiALo[d];return u?i=u:(i=F.tEtuTo(i),F.PFiALo[d]=i),i}var Qx,ep,na,PS=Jx({"node_modules/idb/build/index.js"(){let t=N,e={Qofae:t(556)+"1|4",QHjNk:function(o){return o()},TvwLM:t(1345),TDLHi:t(523),bYQxO:t(984)+"ys",Iuryt:t(865),TSJUj:t(1334),mZvxr:t(1165),nCpdi:t(546),pPfBn:function(o){return o()}},r=e[t(985)][t(302)]("|"),i=0;for(;;){switch(r[i++]){case"0":e[t(1069)]($x);continue;case"1":na=new Map;continue;case"2":Qx=[e[t(664)],e[t(443)],t(970),e[t(1741)],e[t(627)]];continue;case"3":ep=[t(1198),e[t(245)],e[t(1706)],e[t(1184)]];continue;case"4":AS(o=>({...o,get:(c,d,u)=>Yx(c,d)||o[t(1345)](c,d,u),has:(c,d)=>!!Yx(c,d)||o[t(1684)](c,d)}));continue;case"5":e[t(1318)]($x);continue}break}}}),DS={idb:function(t){let e=N;t.exports=Promise.resolve()[e(502)](()=>(PS(),Xx))[e(502)](function(r){return r})}},Vx={};function zt(t){let e=N,r={HzvaB:function(c,d){return c!==d}};var i=Vx[t];if(r[e(947)](void 0,i))return i[e(996)];var o=Vx[t]={exports:{}};return DS[t](o,o[e(996)],zt),o[e(996)]}zt.d=(t,e)=>{let r=F;for(var i in e)zt.o(e,i)&&!zt.o(t,i)&&Object[r(1098)+r(1385)](t,i,{enumerable:!0,get:e[i]})},(()=>{let t=N;zt.o=(e,r)=>Object[t(957)+"e"][t(981)+t(1385)].call(e,r)})(),(()=>{let t=N,e={Msapl:function(r,i){return r-i},xEPKU:t(713),cIBVp:"undefined",lkaOv:t(848),HXuwY:"__esModule"};zt.r=r=>{let i=t,o={elGhc:function(c,d){return e.Msapl(c,d)}};if(e[i(803)]!==e[i(803)]){let c=_0x4ba936[i(1337)+"g"](0,o.elGhc(4,_0x327a7f[i(693)])),d=c[i(1253)](_0x48663c);_0x265284.push(d)}else e.cIBVp!=typeof Symbol&&Symbol[i(813)+i(975)]&&Object[i(1098)+i(1385)](r,Symbol[i(813)+i(975)],{value:e[i(624)]}),Object[i(1098)+i(1385)](r,e[i(823)],{value:!0})}})();var Pe={};(()=>{let t=N,e={Awzzg:function(a,n){return a(n)},alxKb:function(a,n){return a+n},xDqJv:function(a,n){return a===n},igAeS:t(1051),CkTtE:function(a,n){return a*n},MzwtI:function(a,n){return a+n},IjVqL:function(a,n,s){return a(n,s)},jLHzI:function(a,n){return a(n)},Widix:function(a,n){return a(n)},pvAjY:function(a,n){return a+n},tgtJZ:t(1604),tKQuY:function(a,n){return a!==n},qqJuO:t(993),tkAqN:t(382)+t(382)+t(382)+t(382),EhOJQ:"idb",aFkWe:function(a,n){return a!==n},FWAeL:function(a,n){return a>>>n},bJWKC:function(a,n){return a&n},Etmbi:function(a,n){return a&n},dfEMA:function(a,n){return a>>>n},cALWz:function(a,n){return a&n},BlRNc:function(a,n){return a>n},hoESP:function(a,n){return a<n},nQPav:function(a,n){return a-n},ZthYV:t(1288),HJUKp:function(a,n){return a!==n},EnUYO:t(1143),pBMJe:t(1486),VBXki:function(a,n){return a===n},YNDOu:t(1440),iTSRQ:function(a,n){return a!==n},KlDYU:function(a,n){return a-n},LkPda:function(a,n){return a!==n},RoNnq:function(a,n){return a(n)},XgIUM:function(a,n){return a(n)},EsPHx:function(a,n,s){return a(n,s)},SlBtF:function(a,n){return a(n)},KcKtn:function(a,n){return a&n},twCEl:function(a,n){return a===n},yGoJz:t(757)+t(1488)+t(333)+t(1473),FUxWu:function(a){return a()},cmJYl:function(a,n,s){return a(n,s)},xCKZu:function(a,n){return a!==n},wzpSS:"ASrvr",BnBgc:function(a,n,s){return a(n,s)},aUeou:function(a,n){return a(n)},SPMjx:function(a,n,s){return a(n,s)},FAcwi:function(a,n){return a(n)},gFnkc:function(a,n){return a!==n},wFJYx:function(a,n,s){return a(n,s)},EezGW:function(a,n,s){return a(n,s)},rOxqm:function(a,n){return a(n)},tAnhh:function(a,n){return a!==n},TIOeW:function(a,n,s){return a(n,s)},CUEZR:function(a,n,s){return a(n,s)},SrtsF:function(a,n){return a!==n},ivmzM:function(a,n,s){return a(n,s)},DAKeb:function(a,n,s){return a(n,s)},qpRht:function(a,n,s){return a(n,s)},tXpOI:function(a,n){return a(n)},VtYjS:function(a,n){return a===n},dFMel:t(531),Silcq:t(702)+"e_success",FvHvm:t(234),JeNSt:function(a,n,s){return a(n,s)},gNoRk:function(a,n){return a===n},dQzjs:function(a,n,s,l){return a(n,s,l)},Owvbg:function(a,n,s){return a(n,s)},dSUPz:"error",rHoiq:t(447),GynXn:function(a,n){return a(n)},BvAhB:function(a,n){return a|n},qoNPL:function(a,n){return a<<n},HWXOx:function(a,n){return a(n)},EqnCZ:function(a,n){return a!==n},UQtnE:t(728),IGVah:function(a,n){return a(n)},dxmCL:"Zjeej",WfrAa:"Ivzwf",KXicS:function(a,n){return a(n)},LZNnX:function(a,n,s){return a(n,s)},Pfrmp:function(a,n){return a(n)},xVGjt:function(a,n){return a(n)},kYUwg:t(1342),ZjpcP:function(a,n){return a(n)},aRjSL:function(a,n){return a(n)},rYNUx:function(a,n,s){return a(n,s)},CWoaX:function(a,n){return a(n)},pavyo:function(a,n){return a(n)},BZuLd:function(a,n){return a(n)},xRWVh:t(757)+t(1488)+t(333)+"SeqID",BluZR:t(757)+t(1488)+" field: "+t(763),gLDGX:function(a,n){return a===n},KnLON:function(a,n){return a===n},SJrKM:t(757)+"required"+t(333)+t(1491),DxsJZ:function(a,n){return a(n)},nRtRv:function(a,n){return a+n},fYaul:function(a,n){return a!==n},SgFfS:t(919),DrxgI:function(a,n){return a(n)},wLXNR:function(a,n,s){return a(n,s)},ArOAs:function(a,n){return a(n)},qJlRZ:function(a,n){return a+n},RpKIj:"Unimplem"+t(564)+t(398),kVPOd:t(274),kIwNQ:t(742),ocIeU:function(a,n){return a!==n},DiXRo:"qPoxE",LOBrD:t(899),FzCOs:function(a,n){return a>n},JAGNs:function(a,n){return a>=n},XNyGe:function(a,n){return a>>n},Jkbqj:function(a,n){return a===n},ZxjRf:t(1186),thunp:function(a,n){return a+n},DMCYO:"ydBxn",QMgJI:t(630),FTghz:function(a,n){return a*n},GuFqj:function(a,n){return a&n},shQEp:function(a,n){return a===n},vwqfT:function(a,n){return a>=n},shXGU:function(a,n){return a+n},DfhZN:function(a,n){return a+n},KorsI:function(a,n){return a&n},HtZDs:function(a,n){return a|n},XkBIx:function(a,n){return a<<n},UkMtX:function(a,n){return a<n},xarBE:function(a,n){return a==n},IlCgW:function(a,n){return a>=n},fLOof:function(a,n){return a+n},FFnsq:function(a,n){return a!==n},ElztB:function(a,n){return a&n},SflIv:function(a,n){return a<<n},SwWla:function(a,n){return a<<n},rryPW:function(a,n){return a&n},BQINH:function(a,n){return a&n},HaYIE:function(a,n){return a&n},agQfu:function(a,n){return a+n},Vzpgj:function(a,n){return a+n},CGipI:function(a,n){return a!==n},FUSTu:function(a,n){return a<<n},vXswu:function(a,n){return a|n},BQKFK:function(a,n){return a|n},xoKes:function(a,n){return a&n},VjUrt:function(a,n){return a<<n},vfQxh:function(a,n){return a&n},AppWH:function(a,n){return a&n},dTZCJ:function(a,n){return a&n},coJQe:function(a,n){return a>n},VHYgs:function(a,n,s){return a(n,s)},TZbRk:function(a,n){return a+n},qiUKM:function(a,n){return a+n},bPlfQ:function(a,n){return a<n},mjzHN:function(a,n){return a+n},qPaxL:function(a,n){return a<n},cZPjd:function(a,n){return a<n},jJGGe:function(a,n){return a!==n},NGrji:t(1226),BkhKg:function(a,n){return a<=n},zQRSQ:function(a,n){return a+n},sWSiC:function(a,n){return a-n},uKNKA:function(a,n){return a+n},TkBOe:function(a,n){return a<<n},ZvysG:function(a,n){return a&n},uDdAM:function(a,n){return a>>n},XiIEL:function(a,n){return a>>n},Bxygc:function(a,n){return a|n},GvRxw:function(a,n){return a&n},ijnNt:function(a,n){return a|n},bBldD:function(a,n){return a&n},bnphO:function(a,n){return a>>n},gYNbp:function(a,n){return a|n},LJMJz:function(a,n){return a&n},iAahy:function(a,n){return a<n},KcQpY:function(a,n){return a+n},ACopE:function(a,n){return a<n},hwqBv:function(a,n){return a>n},vcxCC:function(a,n){return a||n},DtZhL:function(a,n){return a>>>n},KyDNw:function(a,n){return a===n},FxxzL:t(1614),FsOJD:t(1688),kQAnp:function(a,n){return a<n},gPcqp:function(a,n){return a&n},SOWHb:function(a,n){return a&n},rcRmu:function(a,n){return a&n},bQTTV:function(a,n){return a>>>n},mtlWj:function(a,n){return a>>>n},YIraQ:function(a,n){return a>>>n},EPVRl:function(a,n,s){return a(n,s)},ELRni:function(a,n){return a===n},LtgxA:function(a,n){return a&n},ZnaIo:function(a,n){return a&n},uhAGH:function(a,n){return a<<n},ZtbaF:function(a,n){return a&n},NvWOl:function(a,n){return a(n)},XuVnU:function(a,n){return a<<n},PTKbB:t(1504),dtlzf:function(a,n){return a&n},mdeQX:function(a,n){return a&n},KcFnW:function(a,n){return a<<n},EHjOW:function(a,n){return a&n},VIwsW:t(717),gyuFd:function(a,n){return a!==n},rwunI:t(1721),oobJP:t(452),mUSVp:function(a,n){return a(n)},orrkE:function(a,n){return a&n},kSWGN:function(a,n){return a&n},Vlzvx:function(a,n){return a|n},OMZcf:function(a,n){return a<<n},WLQbE:function(a,n){return a<n},vSOBI:function(a,n){return a<n},eicaY:function(a,n){return a<n},TJemW:function(a,n){return a!==n},wqKwQ:function(a,n){return a|n},rhDuE:function(a,n){return a&n},axLOq:function(a,n){return a|n},nrXpJ:function(a,n){return a>>>n},cZBNh:function(a,n){return a>>>n},diziY:function(a,n){return a!==n},adEkm:function(a,n){return a&n},zZXdv:function(a,n){return a|n},ZEnDs:function(a,n){return a>>>n},PRoHS:function(a,n){return a&n},vwYbk:function(a,n){return a&n},lvfeB:function(a,n){return a>>>n},ZDmlg:function(a,n){return a!==n},hhhZJ:function(a,n){return a>>>n},zyvwa:function(a,n){return a+n},cLZaM:function(a,n){return a!==n},BMPaq:function(a,n){return a|n},AwhbE:function(a,n){return a>>>n},ihUza:function(a,n){return a&n},DPPPU:function(a,n){return a>>>n},kxebd:function(a,n){return a(n)},CvENv:t(262),UhafG:t(1704),sRAGW:function(a,n){return a(n)},XwAyn:function(a,n){return a|n},ZvNze:function(a,n){return a|n},khbql:function(a,n){return a===n},RcVMQ:t(1061),ieaYf:function(a,n){return a|n},ihVhY:function(a,n){return a|n},GAzxf:function(a,n){return a|n},YKdZD:function(a,n){return a|n},MsPSD:function(a,n){return a|n},npqOh:function(a,n){return a<<n},hHElC:function(a,n){return a|n},KxnGR:function(a,n){return a|n},cjjpy:function(a,n){return a>>>n},ueNqv:function(a,n){return a|n},oxQqy:function(a,n){return a|n},ZYuTt:function(a,n){return a|n},MbqPG:function(a,n){return a>>>n},kODrm:function(a,n){return a|n},oVOdO:function(a,n){return a&n},njpOt:function(a,n){return a&n},OLBES:function(a,n){return a>>>n},NgPEy:function(a,n){return a&n},NnlCT:function(a,n){return a>>>n},RxYmv:function(a,n){return a>>>n},IiQbx:function(a,n){return a|n},Hqcgj:function(a,n){return a%n},XgsXv:function(a,n){return a/n},vfrRV:function(a,n){return a(n)},wLJCv:function(a,n,s,l){return a(n,s,l)},aKoUY:t(1299),XdiXq:function(a,n){return a+n},jEtEN:function(a,n){return a>>>n},ZFfvN:function(a,n){return a*n},LnXkl:function(a,n){return a>>>n},odMVE:function(a,n){return a&n},zKHmh:function(a,n){return a>>>n},BCZre:function(a,n){return a>>>n},SZZQW:function(a,n){return a+n},hvZaY:function(a,n){return a+n},GnBRu:function(a,n){return a|n},MAWVB:function(a,n){return a|n},sYxjl:function(a,n){return a>>>n},rQxrw:function(a,n){return a===n},KgOtP:function(a,n){return a+n},VcOlf:function(a,n){return a!==n},SYBRE:t(1112),OuQNa:t(356),OJZAZ:function(a,n){return a&n},sgEZQ:function(a,n){return a>>>n},BBHMa:function(a,n){return a&n},SwFyc:function(a,n){return a>>>n},UUkpm:function(a,n){return a>>>n},zuheK:t(344)+t(489),zuENo:"NATIVE_E"+t(1657),zMBHC:t(1650)+t(1211)+"R",MHZpE:"CONNECTING_ERROR",PnUdx:function(a,n){return a!=n},VGuJH:t(1040)+"d",qYHqO:t(848),aKKNV:t(1415)+"le",HoyqW:function(a,n){return a===n},iCIwT:t(965),PYzvO:"sUBkC",rQHJu:function(a,n){return a!==n},Tthnp:"ffjcL",gZalS:t(1726),OkBRd:function(a,n,s){return a(n,s)},PqKAJ:t(349),hKlEv:t(1155),eeRcF:function(a,n){return a|n},KmUZT:function(a,n){return a===n},QVtHP:"SuceB",XHryU:t(1085),VlXxq:function(a,n){return a(n)},HrvwA:function(a,n){return a===n},XHpFa:t(1363),ElziX:function(a,n){return a<n},fnxMO:function(a,n){return a===n},RIpJS:function(a,n){return a&n},tNcWX:function(a,n){return a!==n},UNZhO:"AUAgm",pkWEI:t(373),yIwlZ:function(a,n){return a===n},MKsuA:function(a,n,s){return a(n,s)},XYfru:function(a,n){return a!==n},vDiRm:"lngVO",WqZKR:function(a,n){return a==n},BXpyW:t(484),wGzQo:function(a,n){return a instanceof n},sxkcj:function(a,n){return a+n},fUUlI:function(a,n){return a+n},wOrHY:function(a,n){return a===n},DbsAU:function(a,n){return a===n},mGdQx:"LoMkE",kpOoS:"kwJas",DGbfE:t(326),REdTX:t(1307),mtYhU:function(a,n,s){return a(n,s)},imUDB:t(689),AePod:t(619)+t(655)+t(1710)+t(736)+t(1577),Xzfou:"FktsW",oQebC:"IJtSb",QVnUe:function(a,n){return a===n},kzPvJ:t(1210),BALHL:t(462),jjPuM:t(871),GTZYp:t(429),jPvNC:"wwfDi",nOVuV:function(a,n){return a===n},Enpby:t(1359),JhWXV:function(a,n){return a||n},meDBn:function(a,n,s,l,h){return a(n,s,l,h)},enruy:t(1164),SxIXX:function(a,n){return a||n},ddAkd:t(1569)+t(879),udZCy:t(922)+t(1095)+t(645)+"nitialized",KJnaR:function(a,n){return a===n},eZSuP:t(922)+t(1675)+t(208),dWCwW:t(505),CfenA:function(a,n){return a(n)},tjcPJ:function(a,n){return a<n},rqVpq:function(a,n){return a===n},IQbvh:function(a,n){return a&n},gHfxe:function(a,n){return a<n},wFkOg:function(a,n){return a<n},AUIcl:function(a,n){return a>=n},vuveI:function(a,n){return a<n},fiWxI:function(a,n){return a&n},dfGRI:function(a,n){return a&n},XQQEQ:function(a,n){return a<<n},vSjYr:function(a,n){return a&n},PSleZ:function(a,n){return a|n},vlboM:function(a,n){return a&n},wzIXk:function(a,n){return a<<n},DfHvm:function(a,n){return a+n},sbGoo:function(a,n){return a<n},brfEx:function(a,n){return a<n},rYsDi:function(a,n){return a|n},pzyXE:function(a,n){return a&n},KKLzh:function(a,n){return a===n},tOaYq:function(a,n){return a===n},vVYts:function(a,n){return a&n},gXquH:function(a,n){return a&n},PMxYc:function(a,n){return a|n},zpkuL:function(a,n){return a|n},dhVQb:function(a,n){return a&n},xJJeX:function(a,n){return a|n},bvakm:function(a,n){return a|n},TCBFI:"string",uWUao:function(a,n){return a instanceof n},wpDGh:function(a,n){return a instanceof n},RLVxH:"applicat"+t(982),NYCgr:function(a,n){return a+n},vcnMh:function(a,n){return a+n},ZGymK:t(793),xyGuy:function(a,n){return a(n)},kdhlw:t(954)+t(827),sxpAQ:function(a,n){return a(n)},gPeNr:t(329)+t(1273),sqDLx:function(a,n){return a+n},uLxev:t(1388),MguHp:t(1589)+t(286)+t(795)+"P",lKENd:t(857)+t(1314)+t(1351),bQnvb:"mqbEk",RSyWt:"hiGtQ",VRTDg:function(a,n,s){return a(n,s)},JRWMf:t(543),FxHnL:function(a){return a()},SsDNt:function(a,n,s,l){return a(n,s,l)},NFvxK:function(a,n){return a!==n},SvkyU:t(1080),rOJXd:t(1461),oPWHI:function(a,n){return a*n},dSCEt:"FqbgK",aYJxy:t(1062),nVzBx:function(a,n){return a!==n},rqmgm:function(a,n){return a<=n},SOEks:function(a,n){return a-n},corxO:function(a,n){return a|n},KOmVy:function(a,n){return a|n},luhwG:function(a,n){return a&n},AKQZc:function(a,n){return a>>n},xnSCQ:function(a,n){return a===n},ZvxRE:t(1667),tTHuB:"kxPOR",uMLow:function(a,n){return a||n},YqiTo:function(a,n,s){return a(n,s)},vHbth:t(1092),zEPkl:t(547),rPrKC:function(a,n){return a||n},yPQpK:t(472),nbeui:function(a,n){return a||n},NrSSY:t(712),JoseC:function(a,n){return a||n},hjPgv:function(a,n){return a||n},whnHl:function(a,n){return a!==n},RAdjy:t(1179),vqfKh:function(a,n,s){return a(n,s)},MWCXL:"qos",qdcBq:t(343)+"id",FaKgr:function(a,n,s){return a(n,s)},KWITq:t(1348),RuWTK:"0|2|3|4|1",PcnAy:function(a,n){return a!==n},kyqiN:t(601),uUDMF:t(1518)+t(1244)+t(1275),nVGYY:t(1213),plbVR:function(a,n,s,l){return a(n,s,l)},QJGrJ:t(522)+t(1414),AbkPO:t(1621),JZETT:t(552),TWlEa:t(577)+t(300),zThZy:t(577)+t(1438)+"k",modAG:"x_frontier_ack_m"+t(1389),Fkvly:t(1090)+"d error.",LzQAj:t(1153),eadWm:function(a,n,s,l){return a(n,s,l)},eBnOa:function(a,n){return a&&n},HuTsA:function(a,n){return a!==n},ymhHP:"is_ack",VEPSb:t(251),mecwA:function(a,n){return a||n},IUpWz:function(a){return a()},YItfS:function(a,n){return a==n},eaTjP:function(a,n){return a(n)},ksoCh:function(a,n){return a===n},cKDSy:t(1183),BQoOh:function(a,n){return a(n)},QYHCZ:"text/plain;chars"+t(751),YlRVM:t(1644)+t(982)+";charset"+t(1478),WeuXh:"none_none",OZevL:function(a){return a()},eNhXc:function(a,n){return a>n},mbJOi:function(a,n){return a(n)},mBrGc:function(a,n){return a&n},IiQrt:"lFFPj",MEGhp:function(a,n){return a(n)},GMROm:function(a,n){return a+n},WBVXP:function(a,n){return a+n},AxvpM:function(a,n){return a+n},wAtbL:t(648)+t(1402)+t(1471),szFIz:t(1219),BlJqK:t(1206),BgkUd:t(1475)+t(1671)+"e",oPBkJ:function(a,n){return a>=n},xjYSq:function(a,n){return a<n},OShbT:function(a,n){return a===n},yGkfD:t(1605),OifVE:"2|1|3|4|0",rxXoR:function(a,n){return a+n},JEcPi:function(a,n,s,l){return a(n,s,l)},GSvNr:function(a,n){return a+n},wUduo:function(a,n){return a|n},pNNxn:function(a,n){return a+n},fGCJN:function(a,n){return a<<n},AITWm:function(a,n){return a+n},XkjUO:function(a,n){return a+n},xnyFo:function(a,n){return a|n},veRnq:function(a,n){return a+n},vSknc:function(a,n){return a+n},ACRUt:function(a,n){return a<<n},rxanG:function(a,n){return a+n},bNIrw:function(a,n){return a>>>n},QKWkS:function(a,n){return a&n},DCtyd:function(a,n){return a&n},HXtvM:function(a,n){return a+n},dTlFk:function(a,n){return a&n},yJYYO:function(a,n){return a>>>n},igLBu:function(a,n){return a&n},XnwWb:function(a,n){return a+n},ugWkN:function(a,n,s){return a(n,s)},hpXNW:function(a,n){return a+n},ozGrN:t(318),Utmtu:t(1459),kKyJi:t(248)+t(872)+t(875)+"1",KDpDY:function(a,n){return a>>>n},kJbbx:function(a,n){return a|n},rJDWa:function(a,n){return a<n},eMLcM:function(a,n){return a&n},oXKep:function(a,n){return a<n},zMXiA:function(a,n){return a|n},gGtXk:function(a,n){return a&n},GTFTu:function(a,n){return a|n},WWIMf:t(702)+t(1254)+"t",BcIfu:t(1516),VKPWC:"JWNLJ",kxEjT:function(a,n){return a(n)},hBGkc:function(a,n){return a+n},TvDEs:function(a,n,s,l){return a(n,s,l)},nBOQH:t(1658),RbOLo:function(a,n,s,l){return a(n,s,l)},NeLbF:t(1542)+t(371),KMUfn:t(371),RJDkX:function(a,n,s,l){return a(n,s,l)},FJbCl:t(1511)+t(1619),PiLlu:function(a,n,s){return a(n,s)},hxOYH:function(a,n,s,l){return a(n,s,l)},QarUL:function(a,n){return a+n},eBtkS:function(a,n,s){return a(n,s)},XLhkL:t(1609)+"_EXIST",mOhND:function(a,n,s){return a(n,s)},iGLYu:t(1145),BCCAQ:t(797),WSYJQ:t(1264),DWXFD:t(849),UsUSO:function(a,n,s,l){return a(n,s,l)},NBdEG:function(a){return a()},jxVEy:t(235),dBMHT:function(a,n){return a(n)},xdZWO:t(734)+"r",VzMqN:t(423),bwCgD:t(963),vFXyy:t(659),bPPPW:t(282),HnlDW:function(a,n){return a||n},CFWXU:function(a,n){return a!==n},ctGia:"XeWaX",zhvLb:function(a,n,s){return a(n,s)},woDld:t(1054),ucWSF:t(1018),tyCcN:function(a,n,s,l){return a(n,s,l)},LMtdP:function(a,n){return a(n)},VXleQ:t(577)+"er_ttl",WTARQ:function(a,n,s,l){return a(n,s,l)},MIfaO:"x-msg-qos",ncqif:t(1006)+"rsor_value",nYYWl:function(a){return a()},BWWhs:function(a,n){return a===n},jedBa:t(386),kYXbi:function(a,n){return a+n},VrtyG:function(a){return a()},gqOQm:function(a){return a()},MZUoO:function(a){return a()},mKrBS:function(a,n){return a===n},DuZRF:function(a,n){return a&&n},LkAdF:function(a,n){return a(n)},vDBjf:function(a,n){return a(n)},xAwNY:function(a){return a()},scAbn:function(a,n){return a<n},nyAdv:function(a,n,s){return a(n,s)},EXTVW:function(a){return a()},DCvJQ:function(a,n){return a!==n},FSXVR:t(1111),HbrKu:function(a,n,s,l){return a(n,s,l)},uVvsf:function(a,n){return a!==n},AxbNZ:function(a,n,s){return a(n,s)},TMLOM:t(705)+t(762),iEcqf:t(435),EYZXi:"auto",qUzmf:function(a,n){return a==n},XVgxZ:"please p"+t(529)+t(824)+t(810)+t(1023)+t(1290)+"is undef"+t(1503),uVSZb:t(276)+"t",cmhwT:t(622)+"ediately reconnect",xWBIO:function(a,n){return a&n},wCFwq:function(a,n){return a(n)},mLqzX:function(a,n){return a(n)},pWitj:function(a,n){return a&n},oTbFJ:function(a,n){return a&n},SpbCW:t(692),rVKgZ:"tzume",eYadg:function(a,n){return a!==n},wPKsL:"OIMVW",ShdzI:"KEsSL",SGsEj:function(a,n){return a!==n},hbanm:function(a,n){return a!==n},YLVuf:t(733),tyenG:t(324),fDIqS:"bd_did",BrBOi:t(1064),fZNOp:function(a,n){return a==n},FvVsv:t(628),oLriv:function(a){return a()},QbNAp:function(a,n,s){return a(n,s)},vldSl:t(1742),oAkLh:t(729)+"0",CPVgQ:function(a,n,s){return a(n,s)},CzENa:function(a,n,s){return a(n,s)},FyGwq:function(a,n){return a>n},ssqmw:function(a,n){return a-n},LtJAh:function(a,n){return a(n)},ZTHKP:"FRONTIER>",SACQX:function(a,n){return a*n},mymsn:t(430),FKgoS:function(a,n,s){return a(n,s)},nssoa:function(a,n){return a!==n},tFFLK:"going aw"+t(1709)+t(276)+"ting ser"+t(626),afKNZ:"AhdpG",FoGzE:function(a,n){return a(n)},NahmD:t(440),KDWCN:function(a,n){return a!==n},DvHBa:t(908),egTNU:t(656),nZbOA:t(1331)+"0",bDgFw:function(a,n){return a>>>n},qGnod:function(a,n){return a>>>n},vQKqv:function(a,n){return a===n},bAcRF:function(a,n){return a===n},JVpzy:function(a,n){return a<n},ICUaJ:function(a,n){return a<n},RkTGc:function(a,n){return a&n},joPyd:function(a,n){return a!==n},sjCZm:function(a,n){return a!==n},oATmq:function(a,n){return a|n},MDJOI:function(a,n){return a+n},vAUFE:function(a,n){return a>>>n},FViQM:function(a,n){return a+n},ftvMF:function(a,n){return a|n},eMmZw:function(a,n){return a&n},LjqCK:t(1482),LMMQk:t(1149),uoiNY:t(1247),mLjgP:t(1470),yQezy:function(a,n,s){return a(n,s)},UyHmd:"going aw"+t(1355)+t(758)+t(1728),SnynZ:function(a,n){return a+n},OFYqe:t(269)+t(1110),BxMVT:function(a,n){return a===n},TBYLQ:function(a,n){return a===n},SPRQw:t(778)+t(749)+" valid d"+t(616)+t(537)+t(460)+t(1405)+t(1536)+t(272),phMTX:t(1533),QaMcd:function(a,n){return a!=n},LewIt:function(a,n){return a instanceof n},pMRxp:function(a,n){return a instanceof n},UJPxs:function(a,n){return a(n)},QpQAw:function(a,n){return a||n},UHUhm:function(a,n){return a instanceof n},iHYjo:t(1298),axDrO:t(937),KdCcB:function(a,n){return a!==n},cTUAB:"KYSCd",kCUrD:"iDIPe",gajXE:t(826),Vvpmd:t(1384),XpXrT:function(a,n){return a*n},CRKnL:t(1568),WeEhp:function(a,n){return a!=n},kWsUU:function(a,n){return a===n},DyqqK:t(404),EmJAO:t(253)+t(1086)+t(1208)+"pe",BYqcc:function(a,n){return a===n},BYElY:function(a,n){return a==n},IgOnf:function(a,n){return a!=n},csiNJ:function(a,n){return a===n},QxJcO:t(1717)+"rkerGlob"+t(809),omGvH:t(1410)+"orkerGlo"+t(986),dypJl:function(a,n){return a===n},lXrKv:function(a,n){return a!=n},tsoSA:function(a,n){return a!=n},KKAhT:function(a,n){return a!=n},puctJ:t(694)+"qos__"};zt.r(Pe),zt.d(Pe,{FWS:()=>Um,CustomErrorEvent:()=>fl,createCloseEvent:()=>_t,ReconnectEvent:()=>ul,createErrorEvent:()=>lt,decodedFrame:()=>sn,createOpenEvent:()=>wl,CustomCloseEvent:()=>hl,createReconnectEvent:()=>va,FrontierMessageEvent:()=>pl,encodeFrame:()=>Gt,createMessageEvent:()=>gl,OpenEvent:()=>ml,ErrorCode:()=>an,Event:()=>rr,MessageEvent:()=>xl});let r="";function i(a=""){let n=t,s="02",l=""+Date[n(1643)](),h=r||(r=e[n(232)](f,a)),p=Math.random()[n(813)](16)[n(978)](-6);return e[n(400)](s+l+h,p)}function o(){let a=t;if(e[a(1404)](e[a(634)],a(1004)))_0x5032b9+=e.Awzzg(_0x2ebb6f,_0x59d6af),_0x27d263+=2;else return e[a(400)](e[a(1659)](1e4,Date[a(1643)]()),Math[a(646)](e[a(1659)](1e4,Math[a(1637)]())))}function c(a){let n=t;return e[n(559)](e[n(232)](Array,8).join("0"),e[n(369)](parseInt,a,10)[n(813)](2))[n(978)](-8)}function d(a){let n=t;return e[n(400)](e[n(574)](Array,4)[n(900)]("0"),e[n(369)](parseInt,a,2)[n(813)](16)).slice(-4)}function u(a){let n=t,s=a[n(302)](/\./)[n(636)](p=>c(p)),l=[];return l[0]=e[n(1430)](d,e.alxKb(s[0],s[1])),l[1]=e[n(232)](d,e.pvAjY(s[2],s[3])),[n(1604),e.tgtJZ,e[n(1228)],"0000",e[n(1228)],n(567),l[0],l[1]].join("")}function f(a){let n=t;if(e[n(703)](e[n(914)],e[n(914)]))_0x5a9f99[n(1548)](_0xb79c98,_0x577f20),_0x1b8620[n(1548)](_0x30d6d7,_0x25bee5);else{let s=/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/[n(264)](a),l=/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/[n(264)](a);return s?u(a):l?e[n(1430)](x,a):e[n(1020)]}}function x(a){let n=t,s="",l=[],h=0,p=0,_=!0,E=e[n(1228)];if(e.BlRNc(a[n(1672)]("::"),-1)){let m=a[n(302)]("::");for(let L=0;e[n(1172)](L,m[n(693)]);L++){let j=m[L];if(j.indexOf(":")>0){let $=j.split(":");_&&(h=$.length),p+=$[n(693)];for(let Y=0;Y<$[n(693)];Y++)if($[Y][n(693)]!==4){let _e=E[n(1337)+"g"](0,e[n(219)](4,$[Y][n(693)])),et=_e.concat($[Y]);l.push(et)}else l[n(1419)]($[Y]);_=!1}else if(e[n(366)]===e[n(366)]){if(e[n(592)](4,j.length))if(e[n(703)](e[n(1732)],e[n(1544)])){let $=E[n(1337)+"g"](0,e[n(219)](4,j[n(693)])),Y=$[n(1253)](j);l[n(1419)](Y)}else return _0x18e649||(_0x2817b5=_0x327333.resolve()[n(502)](_0x5795db[n(719)](_0x38860d,e.EhOJQ))),_0x493ea2;else l[n(1419)](j);_&&(h+=1),p+=1,_=!1}else{if(e[n(1449)](4,_0x22dcd1[n(693)])){let $=_0x237304[n(1337)+"g"](0,4-_0x5c6617.length),Y=$[n(1253)](_0x3a5b34);_0x1eb269.push(Y)}else _0x3d3371[n(1419)](_0x1f13a5);_0x261fa3&&(_0x1cb2bf+=1),_0x5a9aac+=1,_0x18b6eb=!1}}let T="";for(let L=0;e[n(1172)](L,e[n(219)](8,p));L++)T=T[n(1253)](E);for(let L=0;L<l.length;L++)e[n(1437)](L,h)&&(s=s[n(1253)](T)),s=s[n(1253)](l[L]);return s}{let m=a.split(":");for(let T=0;e[n(1172)](T,m.length);T++)if(e[n(1437)](e[n(1537)],e[n(1537)])){let L=m[T];if(e.iTSRQ(4,m[T][n(693)])){let j=E.substring(0,e[n(1144)](4,m[T][n(693)])),$=j[n(1253)](L);s=s[n(1253)]($)}else s=s[n(1253)](L)}else{let L=this.high,j=this[n(1372)];return[e[n(399)](L,24),e[n(1736)](L>>>16,255),e[n(399)](L,8)&255,255&L,e[n(399)](j,24),e[n(1736)](e[n(399)](j,16),255),e[n(1489)](e[n(1060)](j,8),255),e[n(674)](255,j)]}return s}}function g(a,n){let s=t,l=a[s(542)];e.aFkWe(void 0,l)&&(e.IjVqL(pe,n,10),e[s(369)](z,n,l));let h=a[s(1473)];e[s(631)](void 0,h)&&(e[s(369)](pe,n,18),e[s(369)](z,n,h))}function w(a){let n=t,s={};e:for(;!e[n(1194)](K,a);){let l=e[n(232)](xe,a);switch(e.dfEMA(l,3)){case 0:break e;case 1:s[n(542)]=e[n(369)](C,a,e[n(499)](xe,a));break;case 2:s[n(1473)]=e[n(436)](C,a,e[n(216)](xe,a));break;default:e[n(369)](R,a,e.KcKtn(7,l))}}if(e[n(1404)](void 0,s[n(542)]))throw new Error(n(757)+"required"+n(333)+n(542));if(e[n(1573)](void 0,s[n(1473)]))throw new Error(e.yGoJz);return s}function S(a){let n=t,s=e[n(682)](P);return e[n(211)](y,a,s),M(s)}function y(a,n){let s=t,l=a[s(1484)];e[s(1610)](void 0,l)&&(e[s(369)](pe,n,8),e[s(436)](wt,n,l));let h=a[s(763)];if(e[s(1189)](void 0,h))if(e[s(802)]!==s(886))pe(n,16),e[s(211)](wt,n,h);else return this[s(1626)].protocol;let p=a[s(1305)];e.aFkWe(void 0,p)&&(e[s(369)](pe,n,24),e.BnBgc(wt,n,e[s(1370)](D,p)));let _=a[s(1491)];_!==void 0&&(e[s(1330)](pe,n,32),wt(n,e[s(1723)](D,_)));let E=a[s(1513)];if(e.gFnkc(void 0,E))for(let et of E){e[s(1105)](pe,n,42);let Tt=e[s(682)](P);e[s(211)](g,et,Tt),e[s(211)](pe,n,Tt[s(677)]),e[s(676)](H,n,Tt),e[s(1339)](O,Tt)}let m=a[s(1676)+s(960)];e[s(476)](void 0,m)&&(pe(n,50),z(n,m));let T=a[s(942)+"ype"];e[s(703)](void 0,T)&&(e.EsPHx(pe,n,58),e.TIOeW(z,n,T));let L=a[s(1662)];e[s(592)](void 0,L)&&(pe(n,66),pe(n,L[s(693)]),e[s(829)](oe,n,L));let j=a[s(1240)];e[s(1256)](void 0,j)&&(e[s(369)](pe,n,74),z(n,j));let $=a[s(1432)+"ming"];$!==void 0&&(e[s(744)](pe,n,82),e[s(1136)](z,n,$));let Y=a[s(1019)];e[s(703)](void 0,Y)&&(e[s(1713)](pe,n,90),e[s(1642)](z,n,Y));let _e=a[s(389)+"e"];_e!==void 0&&(e[s(211)](pe,n,96),wt(n,e[s(650)](D,_e)))}function v(a){let n=t;if(e[n(368)]===n(447))return e[n(910)](I,e[n(574)](B,a));{let{pingInterval:s,pingFrequency:l}=this[n(407)];if((e[n(1624)]("hi",_0x599fff[n(474)])&&e[n(1027)]===l||e.VBXki("auto",l))&&(this[n(1367)+n(1005)](),this[n(1391)](e[n(449)],e[n(1680)]),this["_pingPon"+n(544)+"Id"]=e[n(466)](_0x47f5a4,this._ping[n(719)](this),s)),e[n(229)]("hi",_0x2be402[n(474)]))return;try{e[n(372)](_0xbe8c65,this,_0x3ebeee,[_0x24719a,_0x3e7cf1,_0x1024b6,_0x95e446,_0x1b5783,_0x1c7460])}catch(h){let p=e[n(263)](_0x2154c2,e[n(959)],{message:h.message,code:_0x8363b3[n(221)+n(1055)],error:h});this[n(1648)+n(1276)+n(1379)](p)}}}function I(a){let n=t;if(e[n(788)](e[n(620)],e[n(620)]))this.on(_0x13d335,_0x2fce6d);else{let s={};e:for(;!e[n(469)](K,a);)if(e.dxmCL!==e[n(1578)]){let l=e[n(416)](xe,a);switch(l>>>3){case 0:break e;case 1:s[n(1484)]=kt(a,!0);break;case 2:s[n(763)]=e[n(653)](kt,a,!0);break;case 3:s[n(1305)]=e.Pfrmp(xe,a);break;case 4:s[n(1491)]=e.xVGjt(xe,a);break;case 5:if(e[n(631)](e[n(1452)],e[n(1452)]))_0xa724(_0x399601,10),e[n(829)](_0x2b815f,_0x8fc362,_0x5591bb);else{let h=e[n(1370)](A,a);(s[n(1513)]||(s[n(1513)]=[]))[n(1419)](e[n(1015)](w,a)),a[n(677)]=h;break}case 6:s["payloadE"+n(960)]=C(a,e[n(738)](xe,a));break;case 7:s[n(942)+n(1139)]=e[n(357)](C,a,e[n(1315)](xe,a));break;case 8:s.payload=e[n(436)](se,a,e[n(1068)](xe,a));break;case 9:s[n(1240)]=e[n(436)](C,a,xe(a));break;case 10:s[n(1432)+n(379)]=e[n(1642)](C,a,e[n(1148)](xe,a));break;case 11:s[n(1019)]=C(a,e[n(1430)](xe,a));break;case 12:s.frameType=e[n(1500)](xe,a);break;default:e[n(211)](R,a,7&l)}}else _0x132454=e[n(1584)](e.qoNPL(e[n(1736)](31,_0x23d68b),6),e[n(1489)](63,_0x4f73ba)),e[n(1172)](_0x3b5139,128)?_0x468f96+=_0x41433f:(_0x14a8f3+=e[n(1500)](_0x459f43,_0x5a7fdf),_0x1478d7++);if(s[n(1484)]===void 0)throw new Error(e[n(506)]);if(e[n(1404)](void 0,s.LogID))throw new Error(e[n(337)]);if(e[n(962)](void 0,s.service))throw new Error(n(757)+"required"+n(333)+n(1305));if(e[n(696)](void 0,s[n(1491)]))throw new Error(e[n(1390)]);return s}}function A(a){let n=t,s=e[n(973)](xe,a),l=a.limit;return a[n(677)]=e[n(834)](a[n(1030)],s),l}function R(a,n){let s=t;if(e.fYaul(s(835),e[s(685)]))switch(n){case 0:for(;e[s(402)](128,e[s(923)](ee,a)););break;case 2:e[s(1425)](V,a,e[s(971)](xe,a));break;case 5:e[s(369)](V,a,4);break;case 1:e[s(1425)](V,a,8);break;default:throw new Error(e[s(1260)](e.RpKIj,n))}else return this._ws?this[s(1585)].binaryType:this["_binaryT"+s(1139)]}function D(a){return a|=0,{low:a,high:a>>31,unsigned:a>=0}}let b=[];function P(){let a=t,n=b.pop();return n?(n[a(1030)]=n[a(677)]=0,n):{bytes:new Uint8Array(64),offset:0,limit:0}}function O(a){b[t(1419)](a)}function B(a){let n=t;if(e[n(1397)](e[n(314)],e.LOBrD))return{bytes:a,offset:0,limit:a.length};this[n(1309)+"er"]&&_0xdb6f06[n(1056)+"entListener"](e[n(1571)],this[n(1580)+n(1279)]),this[n(1309)+"er"]&&_0x534c34[n(1056)+n(520)+"ner"](e[n(1398)],this["_handleP"+n(961)]),this[n(326)]()}function M(a){let n=t,s=a[n(214)],l=a[n(677)];return e[n(1573)](s.length,l)?s:s[n(918)](0,l)}function V(a,n){let s=t;if(e[s(279)](a[s(1030)]+n,a[s(677)]))throw new Error(s(1698)+s(1439));a.offset+=n}function K(a){let n=t;return e[n(355)](a[n(1030)],a.limit)}function re(a,n){let s=t,l={wDDga:function(h,p){return e[F(1584)](h,p)},bmsFE:function(h,p){return h>>p},WBeTF:function(h,p){return h&p},miXmG:function(h,p){return e[F(1519)](h,p)}};if(e[s(215)](s(1186),e.ZxjRf)){let h=a[s(214)],p=a[s(1030)],_=a[s(677)],E=e[s(220)](p,n);if(e.FzCOs(E,h[s(693)]))if(e[s(652)]===e.QMgJI)_0x2b8dbf[_0xf2dbec++]=l[s(861)](l[s(863)](_0x2a8573,12),224),_0x2d057e[_0x165ef6++]=l[s(1225)](l[s(515)](_0x3ca33b,6),63)|128,_0x122eca[_0x36ada8++]=l.wDDga(l[s(1225)](63,_0x3315ab),128);else{let m=new Uint8Array(e[s(538)](2,E));m.set(h),a[s(214)]=m}return a[s(1030)]=E,e[s(279)](E,_)&&(a[s(677)]=E),p}else return new _0x1b7f77(_0x14769f,{data:_0x2abd46})}function X(a,n){let s=t,l=a[s(1030)];if(l+n>a[s(677)])throw new Error(s(1073)+s(1439));return a[s(1030)]+=n,l}function se(a,n){let s=t,l=e[s(369)](X,a,n);return a[s(214)][s(918)](l,e[s(559)](l,n))}function oe(a,n){let s=t,l=e[s(1642)](re,a,n[s(693)]);a[s(214)][s(1548)](n,l)}function C(a,n){let s=t,l=X(a,n),h=String[s(941)+s(958)],p=a[s(214)],_="\uFFFD",E="";for(let m=0;e[s(1172)](m,n);m++){let T=p[m+l],L,j,$,Y;e.GuFqj(128,T)===0?E+=e[s(1370)](h,T):e[s(348)](e[s(402)](224,T),192)?e[s(525)](e[s(400)](m,1),n)?E+=_:(L=p[e[s(589)](e.DfhZN(m,l),1)],e[s(788)](e.KorsI(192,L),128)?E+=_:(Y=e[s(853)](e[s(748)](e[s(674)](31,T),6),e.Etmbi(63,L)),e[s(395)](Y,128)?E+=_:(E+=h(Y),m++))):e[s(1373)](e[s(402)](240,T),224)?e[s(887)](e[s(834)](m,2),n)?E+=_:(L=p[e.fLOof(m+l,1)],j=p[e[s(220)](m+l,2)],e[s(1540)](e[s(745)](L|e[s(311)](j,8),49344),32896)?E+=_:(Y=e[s(853)](e[s(853)](e[s(1523)](15&T,12),e[s(748)](e[s(1312)](63,L),6)),e[s(451)](63,j)),Y<2048||Y>=55296&&Y<=57343?E+=_:(E+=e.IGVah(h,Y),m+=2))):e[s(1373)](e[s(1215)](248,T),240)?e.JAGNs(e[s(589)](m,3),n)?E+=_:(L=p[e.qJlRZ(e.thunp(m,l),1)],j=p[e[s(1445)](m+l,2)],$=p[e[s(980)](e[s(589)](m,l),3)],e[s(1344)](e[s(1241)](e[s(853)](L,e[s(551)](j,8))|e.SflIv($,16),12632256),8421504)?E+=_:(Y=e.vXswu(e[s(1584)](e[s(953)](e[s(1313)](7,T)<<18,e.VjUrt(e[s(1365)](63,L),12)),e[s(1291)](63,j)<<6),e[s(890)](63,$)),e[s(395)](Y,65536)||e[s(463)](Y,1114111)?E+=_:(Y-=65536,E+=e.VHYgs(h,e[s(1221)](e[s(1519)](Y,10),55296),e.qiUKM(1023&Y,56320)),m+=3))):E+=_}return E}function z(a,n){let s=t,l={sqJHt:function(m,T,L){return m(T,L)}},h=n[s(693)],p=0;for(let m=0;m<h;m++){let T=n[s(1534)+"At"](m);T>=55296&&T<=56319&&e[s(831)](e.mjzHN(m,1),h)&&(T=e[s(1144)](e[s(1576)](e[s(1523)](T,10),n.charCodeAt(++m)),56613888)),p+=T<128?1:e[s(1172)](T,2048)?2:e[s(289)](T,65536)?3:4}pe(a,p);let _=re(a,p),E=a.bytes;for(let m=0;e.cZPjd(m,h);m++)if(e[s(439)](e.NGrji,"qAqkx")){let T=xwztad.sqJHt(_0x519d2c,_0x1e9053,_0x1007d8[s(693)]);_0x258726[s(214)][s(1548)](_0x3412f5,T)}else{let T=n[s(1534)+"At"](m);e[s(525)](T,55296)&&e.BkhKg(T,56319)&&e[s(395)](e[s(1442)](m,1),h)&&(T=e[s(1693)](e[s(1308)](e[s(1065)](T,10),n[s(1534)+"At"](++m)),56613888)),T<128?E[_++]=T:(e[s(395)](T,2048)?E[_++]=e.vXswu(e[s(566)](e[s(1251)](T,6),31),192):(T<65536?E[_++]=e[s(1584)](e[s(890)](e[s(915)](T,12),15),224):(E[_++]=e.Bxygc(e[s(1617)](e[s(915)](T,18),7),240),E[_++]=e[s(1584)](e[s(890)](T>>12,63),128)),E[_++]=e[s(458)](e[s(384)](e[s(1175)](T,6),63),128)),E[_++]=e[s(1526)](e[s(572)](63,T),128))}}function H(a,n){let s=t,l=re(a,n[s(677)]),h=a.bytes,p=n.bytes;for(let _=0,E=n[s(677)];e[s(1457)](_,E);_++)h[e[s(1347)](_,l)]=p[_]}function ee(a){let n=t;if(e[n(1640)](e[n(301)],e.FsOJD)){let s={oknxt:function(E,m){return e[n(298)](E,m)},nCjlH:function(E,m){return e[n(1071)](E,m)},HBuCy:function(E,m){return E(m)},IxhMa:function(E,m){return e[n(1347)](E,m)},AYsar:function(E,m){return e.HWXOx(E,m)},EIRsl:function(E,m){return e[n(1647)](E,m)},xmJLM:function(E,m){return e[n(1347)](E,m)},zRXnn:function(E,m){return e[n(458)](E,m)}},l=e[n(1694)](_0x48303d,8192),h=e[n(704)](l,1),p=null,_=l;return function(E){let m=n;if(s[m(1353)](E,1)||s[m(422)](E,h))return s[m(1498)](_0x4ee787,E);s[m(876)](_,E)>l&&(p=s.AYsar(_0x105c8f,l),_=0);let T=_0x26b669[m(1102)](p,_,_+=E);return s[m(315)](7,_)&&(_=s[m(284)](s[m(242)](7,_),1)),T}}else return a[n(214)][e[n(1330)](X,a,1)]}function Ye(a,n){let s=t,l=re(a,1);a[s(214)][l]=n}function xe(a){let n=t,s=0,l=0,h;do h=ee(a),e[n(1035)](s,32)&&(l|=e.SflIv(e.ZvysG(127,h),s)),s+=7;while(e[n(1241)](128,h));return l}function pe(a,n){let s=t;for(n>>>=0;n>=128;)Ye(a,e[s(1647)](127,n)|128),n>>>=7;Ye(a,n)}function kt(a,n){let s=t,l={Iqdxs:function(m,T,L){return e[F(239)](m,T,L)},pdhvz:"error",duDqX:function(m,T){return e.ELRni(m,T)}},h=0,p=0,_=0,E;if(E=e.GynXn(ee,a),h=e[s(603)](127,E),e[s(342)](128,E)&&(E=e[s(216)](ee,a),h|=e[s(1313)](127,E)<<7,e[s(1551)](128,E)&&(E=e[s(973)](ee,a),h|=e.uhAGH(e[s(1441)](127,E),14),e.ZvysG(128,E)&&(E=e[s(438)](ee,a),h|=e.XuVnU(127&E,21),e[s(451)](128,E))))){if(e[s(229)](s(1416),e[s(640)])){let m=this[s(530)+s(1238)]?.[s(594)+"chMaxTries"](),T=this[s(530)+s(1238)]?.[s(573)+s(858)+"nt"]();if(m&&!_0x5d1d95[s(689)]){let L=s(1705)+T+(s(1248)+s(819)+s(1026)+"ed");this[s(1648)+s(1276)+s(1379)](l[s(781)](_0x288b38,l[s(477)],{message:L,code:_0x34af73[s(1650)+s(1211)+"R"],error:_0xba17aa}));return}this[s(1585)]&&l[s(1167)](this._ws[s(421)+"te"],this[s(838)])&&this[s(663)+s(679)](),this[s(1648)+s(1276)+"ent"](l.Iqdxs(_0x47263c,l[s(477)],{message:_0x434f41.message,code:_0x19739f[s(1435)+"RROR"],error:_0x40e4c8}))}else if(E=e[s(910)](ee,a),p=e[s(1427)](127,E),e.KorsI(128,E)&&(E=ee(a),p|=e[s(1296)](127,E)<<7,128&E&&(E=ee(a),p|=e[s(240)](e.bBldD(127,E),14),e[s(1567)](128,E)))){if(e[s(1610)](e[s(1382)],e[s(1382)]))_0x399e18[_0x27f70c++]=e[s(458)](e[s(338)](e[s(1519)](_0x255f6d,18),7),240),_0x200f3c[_0x16a9dd++]=e[s(953)](e[s(1551)](e[s(1251)](_0x1127da,12),63),128);else if(E=e[s(1194)](ee,a),p|=e[s(481)](127&E,21),128&E)if(e.gyuFd(e[s(1126)],e[s(841)]))E=e[s(1130)](ee,a),_=e.vfQxh(127,E),e[s(1182)](128,E)&&(E=e[s(1535)](ee,a),_|=e[s(748)](e[s(1277)](127,E),7));else return _0x4076dc[s(941)+s(958)](e[s(1070)](255,this[s(1372)]),e[s(704)](this[s(1372)],8)&255,e[s(572)](e[s(1134)](this[s(1372)],16),255),e[s(790)](this.low,24),e[s(1647)](255,this[s(836)]),e.YIraQ(this[s(836)],8)&255,e.Etmbi(e.FWAeL(this.high,16),255),this[s(836)]>>>24)}}return{low:e[s(1584)](h,e[s(311)](p,28)),high:e[s(950)](e[s(790)](p,4),e.OMZcf(_,24)),unsigned:n}}function wt(a,n){let s=t,l=e[s(790)](n.low,0),h=e[s(953)](e[s(1060)](n[s(1372)],28),e[s(1523)](n[s(836)],4))>>>0,p=n[s(836)]>>>24,_=e[s(1624)](0,p)?h===0?e[s(1401)](l,16384)?e[s(1358)](l,128)?1:2:e[s(1035)](l,2097152)?3:4:e[s(467)](h,16384)?e.eicaY(h,128)?5:6:e.WLQbE(h,2097152)?7:8:p<128?9:10,E=e[s(1330)](re,a,_),m=a.bytes;switch(_){case 10:m[e[s(1347)](E,9)]=p>>>7&1;case 9:m[e[s(1260)](E,8)]=e[s(926)](9,_)?e[s(1681)](128,p):e[s(916)](127,p);case 8:m[E+7]=e.gyuFd(8,_)?e[s(812)](e[s(1332)](h,21),128):e.cZBNh(h,21)&127;case 7:m[e[s(1588)](E,6)]=e[s(259)](7,_)?e.wqKwQ(e[s(704)](h,14),128):e[s(257)](e.cZBNh(h,14),127);case 6:m[e[s(1093)](E,5)]=e.tKQuY(6,_)?e[s(974)](e.DtZhL(h,7),128):e[s(1712)](h,7)&127;case 5:m[E+4]=e[s(1562)](5,_)?e[s(950)](128,h):e[s(701)](127,h);case 4:m[E+3]=_!==4?e.FWAeL(l,21)|128:e[s(1191)](e[s(1050)](l,21),127);case 3:m[e[s(1093)](E,2)]=e[s(1668)](3,_)?l>>>14|128:e[s(1215)](e[s(718)](l,14),127);case 2:m[e[s(808)](E,1)]=e.cLZaM(2,_)?e[s(1558)](e[s(255)](l,7),128):e[s(794)](e[s(1376)](l,7),127);case 1:m[E]=_!==1?e[s(950)](128,l):127&l}}function sn(a){return e[t(217)](v,a)}function Gt(a){let n=t;if(e[n(414)]!==e[n(755)])return e[n(434)](S,a);this._listeners={}}let on=65536,Qr=e[t(243)],we=e.oPWHI(on,on),ke=e[t(470)](we,we),nr=ke/2,Le=String[t(957)+"e"][t(1534)+"At"];class he{constructor(n,s,l){let h=t;this[h(995)]=!0,this[h(1372)]=e[h(817)](0,n),this.high=e[h(1627)](0,s),this[h(1737)]=!!l}static[t(995)](n){let s=t;return n&&e[s(1368)](!0,n[s(995)])}static[t(708)](n,s,l){let h=t;if(e.EqnCZ(e[h(1377)],h(563)))return new he(n,s,l);_0x354c97[h(1008)](_0x2d6a70)}static fromBytes(n,s,l){let h=t;return l?he[h(1231)+h(1262)](n,s):he["fromByte"+h(283)](n,s)}static[t(1231)+t(1262)](n,s){let l=t;return new he(e[l(1207)](e.ihVhY(e[l(1207)](n[0],n[1]<<8),e.FUSTu(n[2],16)),e.XuVnU(n[3],24)),e[l(1357)](e.Vlzvx(e[l(1467)](n[4],e.uhAGH(n[5],8)),e[l(1204)](n[6],16)),n[7]<<24),s)}static[t(1231)+"sBE"](n,s){let l=t;return new he(e[l(521)](e[l(1467)](n[4]<<24,e.npqOh(n[5],16)),e.OMZcf(n[6],8))|n[7],e[l(789)](e[l(1154)](e[l(1311)](e[l(481)](n[0],24),e.SflIv(n[1],16)),e[l(657)](n[2],8)),n[3]),s)}static[t(1615)](n){let s=t;return e[s(1573)](n,Qr)?ll:new he(e.cjjpy(e[s(700)](e[s(851)](e[s(911)](Le[s(1102)](n,0),e[s(657)](Le.call(n,1),8)),e[s(1065)](Le[s(1102)](n,2),16)),e.SflIv(Le[s(1102)](n,3),24)),0),e[s(1354)](e[s(1357)](e.kODrm(Le[s(1102)](n,4),e[s(657)](Le[s(1102)](n,5),8)),e.TkBOe(Le[s(1102)](n,6),16))|e[s(1065)](Le[s(1102)](n,7),24),0),!0)}toHash(){let n=t;return String["fromChar"+n(958)](e[n(1602)](255,this.low),e[n(1084)](e[n(909)](this[n(1372)],8),255),e[n(745)](e[n(1050)](this[n(1372)],16),255),e[n(1e3)](this.low,24),e[n(1013)](255,this[n(836)]),e[n(603)](e[n(909)](this[n(836)],8),255),e.AppWH(e.NnlCT(this[n(836)],16),255),e[n(565)](this[n(836)],24))}static fromNumber(n,s=!0){let l=t;if(isNaN(n))return s?Xp:ll;if(s){if(n>=ke)return em}else{if(n<=-nr)return tm;if(e[l(887)](e[l(834)](n,1),nr))return Qp}return he[l(708)](e[l(1128)](e[l(485)](n,we),0),e[l(1584)](e.XgsXv(n,we),0),s)}[t(319)](){let n=t,s={VUWpt:function(l,h){return e[F(1638)](l,h)},FRcgW:function(l,h,p,_){return e[F(1739)](l,h,p,_)}};if(e[n(439)](e[n(1083)],n(999)))return this[n(1737)]?e[n(976)](e.jEtEN(this[n(836)],0)*we,this[n(1372)]>>>0):e[n(834)](e[n(295)](this[n(836)],we),e.LnXkl(this.low,0));{let l=new _0x34757c(s[n(697)](_0x47711a,_0x59fb3a));return s[n(332)](_0x22897c,_0x30b9c8,l,0),l}}[t(1572)](){let n=t;return e[n(348)](0,this[n(836)])&&this[n(1372)]===0}[t(1334)](n){let s=t;he[s(995)](n)||(n=he[s(1378)+"er"](n));let l=e[s(399)](this[s(836)],16),h=e[s(1587)](65535,this[s(836)]),p=e[s(1050)](this.low,16),_=65535&this.low,E=n.high>>>16,m=65535&n[s(836)],T=e[s(1565)](n[s(1372)],16),L=e[s(384)](65535,n[s(1372)]),j=0,$=0,Y=0,_e=0;return _e+=e[s(1093)](_,L),Y+=e[s(1686)](_e,16),_e&=65535,Y+=e.SZZQW(p,T),$+=e[s(718)](Y,16),Y&=65535,$+=e[s(1576)](h,m),j+=e.YIraQ($,16),$&=65535,j+=e[s(609)](l,E),j&=65535,he[s(708)](e[s(1412)](Y<<16,_e),e[s(363)](e[s(1523)](j,16),$),this[s(1737)])}[t(1002)](n){let s=t;return he.isLong(n)||(n=he[s(1378)+"er"](n)),this[s(1737)]!==n[s(1737)]&&e.lvfeB(this.high,31)===1&&e[s(215)](e[s(1270)](n[s(836)],31),1)?!1:e.KnLON(this[s(836)],n[s(836)])&&e[s(215)](this[s(1372)],n[s(1372)])}[t(1597)](){let n=t;return e[n(1404)](-1,this[n(1372)])&&e[n(296)](-1,this[n(836)])?he[n(708)](0,0,this[n(1737)]):this.low===-1?he.fromBits(0,e[n(480)](this[n(836)],1),this[n(1737)]):he[n(708)](e[n(684)](this.low,1),this[n(836)],this.unsigned)}[t(943)](n){return n?this[t(1171)+"E"]():this.toBytesBE()}[t(1171)+"E"](){let n=t;if(e[n(1181)](e[n(478)],e[n(716)])){let s=this[n(836)],l=this[n(1372)];return[e[n(711)](255,l),e.sgEZQ(l,8)&255,e[n(1044)](e.SwFyc(l,16),255),l>>>24,e[n(1602)](255,s),e[n(399)](s,8)&255,e[n(1277)](e.UUkpm(s,16),255),s>>>24]}else e[n(1068)](_0xa68758,this[n(1512)+n(678)+n(441)]),this["_connect"+n(678)+n(441)]=null}[t(987)+"E"](){let n=t,s=this[n(836)],l=this[n(1372)];return[e[n(473)](s,24),e[n(1013)](s>>>16,255),e[n(1296)](e[n(607)](s,8),255),255&s,e.OLBES(l,24),e[n(572)](l>>>16,255),e.UUkpm(l,8)&255,e[n(1312)](255,l)]}}let ll=new he(0,0,!1),Xp=new he(0,0,!0),Qp=he[t(708)](-1,2147483647,!1),em=he.fromBits(-1,-1,!0),tm=he[t(708)](0,-2147483648,!1);var an=(function(a){let n=t,s=e[n(1328)][n(302)]("|"),l=0;for(;;){switch(s[l++]){case"0":return a;case"1":a[a.OPEN_ERROR=5005]=n(966)+"OR";continue;case"2":a[a[n(1435)+n(1657)]=5001]=e[n(1369)];continue;case"3":a[a[e.zMBHC]=5003]=e[n(387)];continue;case"4":a[a[n(221)+n(1055)]=5004]=n(221)+"ERROR";continue;case"5":a[a[e[n(1646)]]=5002]=e[n(1646)];continue}break}})({});class rr{constructor(n){let s=t;this[s(747)]=n,this.target=null}}class ul extends rr{constructor(n,s){let l=t;super(n),this[l(689)]=s&&s[l(689)]||null}}class fl extends rr{constructor(n,s){let l=t,h={EheIM:function(p,_){return e[F(1011)](p,_)},GaBcI:e.VGuJH,twwZW:e[l(1306)],HKaYV:e[l(1336)]};if(e[l(1669)](e[l(1612)],e[l(351)]))_0x522b71.r=p=>{let _=l;TYhTDk.EheIM(TYhTDk.GaBcI,typeof _0x1063c8)&&_0x383700[_(813)+_(975)]&&_0x1d63a1["definePr"+_(1385)](p,_0x576f5e[_(813)+_(975)],{value:TYhTDk[_(1034)]}),_0x222f0a[_(1098)+_(1385)](p,TYhTDk.HKaYV,{value:!0})};else{let p=("2|4|5|1|"+l(641))[l(302)]("|"),_=0;for(;;){switch(p[_++]){case"0":this[l(1018)]=s&&s[l(1018)]||5001;continue;case"1":this[l(1170)]=s&&s.filename||"";continue;case"2":super(n);continue;case"3":this[l(689)]=s&&s[l(689)]||"";continue;case"4":this[l(905)]=s&&s[l(905)]||null;continue;case"5":this.colno=s&&s.colno||0;continue;case"6":this.lineno=s&&s[l(1464)]||0;continue}break}}}}class hl extends rr{constructor(n,s){let l=t;super(n),this[l(1018)]=s&&s[l(1018)]||0,this[l(827)]=s&&s[l(827)]||"",this.wasClean=s&&s[l(312)]||!1,this[l(1485)+"nnect"]=s&&s[l(1485)+l(1465)]||!1}}class xl extends rr{constructor(n,s){let l=t;super(n),this[l(474)]=s&&s[l(474)]||null}}class pl extends xl{constructor(n,s){let l=t;super(n),this[l(474)]=s&&s[l(474)]||null,this[l(689)]=s&&s[l(689)]||null}}class ml extends rr{constructor(n,s){let l=t;if(e[l(527)](e[l(328)],e.gZalS))super(n),this[l(474)]=s&&s[l(474)]||null;else return this[l(683)+"s"][this[l(287)+l(888)]]}}function lt(a,{message:n,code:s,error:l}){return new fl(a,{message:n,code:s,error:l})}function _t(a,{code:n,reason:s,wasClean:l,willReconnect:h}){return new hl(a,{code:n,reason:s,wasClean:l,willReconnect:h})}function gl(a,{data:n,message:s}){return new pl(a,{data:n,message:s})}function wl(a,{data:n}){return new ml(a,{data:n})}function va(a,{message:n}){let s=t;if(e[s(1109)]===e.hKlEv)e[s(1500)](_0x288379,this[s(606)+"lTimeoutId"]),this[s(606)+s(1114)+"Id"]=e.OkBRd(_0x4e536c,()=>{this["flushExp"+s(1613)]()},this._interval);else return new ul(a,{message:n})}class _l{constructor(n,s){let l=t;e[l(1522)](e[l(1392)],e[l(612)])?(this[l(995)]=!0,this.low=e[l(1412)](0,_0x284f7f),this[l(836)]=e[l(1371)](0,_0x16d65d),this[l(1737)]=!!_0x2e507c):(this[l(683)+"s"]=n,this.maxRetries=s,this[l(287)+"ndex"]=0,this[l(629)+l(1591)+l(487)+"t"]=0)}[t(448)+"pointCon"+t(288)](){let n=t;this[n(287)+n(888)]=0,this["currentE"+n(1591)+n(487)+"t"]=0}[t(932)+"es"](){let n=t;this[n(629)+n(1591)+n(487)+"t"]=0}[t(573)+t(858)+"nt"](){let n=t;return this[n(683)+"s"][this[n(287)+n(888)]]}[t(573)+t(858)+"ntTriesC"+t(354)](){let n=t;if(e[n(1530)](e[n(1161)],n(425)))_0x36da46=_0x54f5c1(_0x341af9),_0x40d427|=e.VjUrt(127&_0x7cba43,21),e[n(890)](128,_0x32f9f0)&&(_0x42259d=_0x5bebbc(_0x1e1546),_0x31ecf3=127&_0x2ef00f,e[n(794)](128,_0x279e35)&&(_0x5a038b=e.VlXxq(_0x4a4620,_0xe7517f),_0x3880d5|=e[n(551)](e[n(1312)](127,_0x2eba7d),7)));else return this[n(629)+n(1591)+n(487)+"t"]}[t(594)+"chMaxTries"](){let n=t,s={cyyyV:function(l,h){return e[F(459)](l,h)},QLBDT:function(l,h){return e[F(1608)](l,h)},wfwrb:function(l,h){return l&h},WRJGa:function(l,h){return e.RIpJS(l,h)},mIggF:function(l,h){return e[F(834)](l,h)}};if(e[n(1135)](e[n(1195)],e[n(1383)]))return!!(e[n(887)](this["currentI"+n(888)],this[n(683)+"s"][n(693)])||e.KmUZT(this[n(287)+n(888)],e[n(219)](this[n(683)+"s"][n(693)],1))&&e[n(292)](this[n(629)+n(1591)+"riesCount"],this[n(418)+"es"]));_0x21172c=_0x1ddd40[n(1534)+"At"](_0x596991),s[n(1426)](_0x3da6f6,128)?_0x482aa4+=1:_0x197015<2048?_0x4660bc+=2:s[n(246)](s[n(210)](64512,_0x1dc96f),55296)&&s[n(246)](s[n(625)](64512,_0x55dab0.charCodeAt(s[n(1447)](_0x45245b,1))),56320)?(++_0x33cd8e,_0x3b6f2d+=4):_0x58f524+=3}[t(322)+t(798)+t(956)+"hedMaxRe"+t(855)](){let n=t,s={dYfZi:function(l,h,p){return e[F(1409)](l,h,p)}};if(e[n(1703)](e.vDiRm,e.vDiRm))dnmXMb[n(938)](_0x340dc1,_0x5933ea,32),dnmXMb[n(938)](_0x3836ae,_0x2373cc,_0x1e4be5(_0x4f26c5));else return e[n(488)](this[n(287)+n(888)],this.endpoints[n(693)])?!0:this[n(629)+n(1591)+n(487)+"t"]>this[n(418)+"es"]}[t(903)+t(1428)+t(392)+"UpdateCo"+t(866)](){let n=t;return this[n(629)+n(1591)+n(487)+"t"]=1,this["currentI"+n(888)]++,this[n(683)+"s"][this[n(287)+"ndex"]]}["getCurre"+t(858)+t(405)+t(1727)](){let n=t;return this[n(629)+n(1591)+n(487)+"t"]++,this[n(573)+n(858)+"nt"]()}}let ir=(e[t(1011)](e[t(695)],typeof globalThis)&&e[t(362)](e[t(471)],globalThis[t(1039)+t(1203)].name)||e.WeEhp("undefined",typeof window)&&e[t(1422)](e.CRKnL,window[t(1039)+"tor"][t(371)]))&&e.VGuJH!=typeof document,Cn=e.VGuJH!=typeof globalThis&&(e[t(411)]===globalThis[t(1039)+t(1203)].name||e[t(362)](e[t(261)],globalThis[t(1039)+"tor"].name))&&e[t(695)]!=typeof tt,ei=(e[t(695)]!=typeof globalThis&&e[t(231)](e[t(411)],globalThis[t(1039)+"tor"][t(371)])||e[t(1509)](e[t(695)],typeof globalThis)||e.VGuJH!=typeof globalThis&&!!globalThis[t(796)+t(618)])&&e[t(695)]!=typeof wx,ti=e[t(1252)]("undefined",typeof globalThis)&&(e[t(874)](e[t(261)],globalThis[t(1039)+t(1203)][t(371)])||e[t(1666)](e.QxJcO,globalThis[t(1039)+t(1203)].name)||e[t(229)](e[t(1735)],globalThis[t(1039)+t(1203)].name))&&e[t(695)]!=typeof self,nm=e[t(695)]!=typeof globalThis&&e.dypJl(t(404),globalThis[t(1039)+t(1203)][t(371)])&&e[t(913)](e.VGuJH,typeof global)&&e[t(411)]===global[t(1039)+t(1203)][t(371)]&&e.tsoSA(e[t(695)],typeof process)&&!!process.version;class Sa{constructor(){let n=t;this[n(584)+"rs"]={}}[t(1391)](n,...s){let l=t,h=this[l(584)+"rs"][n];if(h)h[l(978)]()[l(1711)](p=>p.fn.apply(p[l(571)],s));else if(e.VtYjS(e[l(959)],n)&&!this.onerror){if(e.ocIeU(e[l(597)],"JAfte"))return _0x65797d?this.toBytesLE():this.toBytesBE();{let p=s[l(693)]&&s[0];if(e[l(1300)](p,Error))throw p;let _=new Error(e.mjzHN(l(1090)+l(1514),p?e[l(1159)](e[l(1630)](" (",p[l(689)]),")"):""));throw _[l(1261)]=p,p}}return this}[t(673)](n,s){let l=t;if(e[l(675)](void 0,n))this[l(584)+"rs"]={};else if(e[l(296)](void 0,s))this[l(584)+"rs"][n]=null;else if(e[l(1666)](e[l(775)],e[l(775)])){let h=this[l(584)+"rs"][n];if(h)for(let p=0;e[l(289)](p,h[l(693)]);)e[l(1640)](h[p].fn,s)?h[l(590)](p,1):++p}else return!!(e[l(525)](this[l(287)+"ndex"],this.endpoints[l(693)])||e[l(1573)](this[l(287)+l(888)],this[l(683)+"s"][l(693)]-1)&&e[l(1437)](this[l(629)+l(1591)+l(487)+"t"],this[l(418)+"es"]));return this}on(n,s,l){let h=t;return(this[h(584)+"rs"][n]||(this[h(584)+"rs"][n]=[])).push({fn:s,ctx:l||this}),this}}class rm extends Sa{_formatErrorMessage(n){let s=t;return n[s(1633)]||n[s(1496)]?("message: "+(n[s(1633)]||"")+s(669)+(n.errNo||"")).trim():JSON[s(1138)+"y"](n)}constructor(n,s,l){let h=t;if(e.gNoRk(e[h(1725)],h(410)))return e.JAGNs(_0x14da37[h(1030)],_0x4986a7.limit);super(),this[h(1626)]=null,ei&&wx["connectS"+h(517)]&&(this[h(1626)]=wx[h(500)+"ocket"]({url:n,protocols:s,header:l,fail:this["_createS"+h(1200)+h(281)].bind(this),success:this["_createS"+h(507)+h(1527)+"ler"][h(719)](this)})),Cn&&tt[h(500)+h(517)]&&(this._socket=tt[h(500)+"ocket"]({url:n,protocols:s,header:l,fail:this[h(1032)+h(1200)+h(281)][h(719)](this),success:this["_createSocketSuccessHand"+h(1269)].bind(this)}))}[t(1032)+"ocketSuc"+t(1527)+t(1269)](){let n=t;Promise[n(771)]().then(()=>{let s=n;this[s(902)+s(445)]()})}[t(1032)+t(1200)+t(281)](n){let s=t,l={iULZJ:function(h,p,_){return h(p,_)},KWUKv:e.DGbfE};Promise[s(771)]().then(()=>{let h=s,p=l[h(1042)](lt,"error",{message:this[h(1017)+h(388)+h(715)](n)});this[h(1391)]("error",p);let _=l.iULZJ(_t,h(326),{reason:this[h(1017)+"rrorMess"+h(715)](n)});this.emit(l[h(1012)],_)})}[t(902)+t(445)](){let n=t,s={oWUSV:function(l,h,p){return e[F(1058)](l,h,p)},ErRZF:e[n(1468)],CInfA:n(905)};this._socket[n(662)](l=>{let h=n;this[h(1391)](h(1307),e.VHYgs(wl,e[h(236)],{...l,data:l[h(1633)]||""}))}),this[n(1626)][n(850)](l=>{this.emit("close",s.oWUSV(_t,"close",{...l}))}),this._socket[n(364)+"e"](l=>{let h=n;this[h(1391)](h(689),gl(s[h(306)],{...l}))}),this[n(1626)][n(228)](l=>{let h=n;this[h(1391)](s[h(1324)],s[h(917)](lt,h(905),{...l,message:l[h(1633)]||""}))})}[t(238)](n){let s=t;if(e[s(1300)](n,Uint8Array)){let l=n[s(732)][s(978)](n[s(535)+"et"],n.byteLength+n[s(535)+"et"]);this[s(1626)]&&this[s(1626)][s(238)]({data:l,fail:h=>{let p=s;this[p(1391)](e[p(959)],lt(e[p(959)],{message:this[p(1017)+p(388)+p(715)](h)}))}})}else this[s(1626)]&&this._socket[s(238)]({data:n,fail:l=>{let h=s,p={sbPFT:function(_,E){return _<=E},nBwDx:e[h(1142)],yGpdc:function(_,E){return e[h(609)](_,E)}};if(e[h(1562)](e[h(1021)],e[h(1076)]))this.emit(e[h(959)],e.EezGW(lt,e[h(959)],{message:this["_formatErrorMess"+h(715)](l)}));else return p[h(1436)](_0x447adf,_0x139bb5)?_0x5e72e8[h(1517)](new _0x2bdecb(p[h(951)])):(_0x114830=_0x227358,_0x575aeb===_0x3f3469.length?_0xf25fef[h(771)]():_0x19e206[_0x3b247c].bind(_0x143244)(_0x36abda,_0x4317fa.bind(null,p.yGpdc(_0x2ed912,1))))}})}close(n,s){let l=t;this[l(1626)]&&this[l(1626)][l(326)]({code:n,reason:s})}[t(1731)+t(213)](n,s){this.on(n,s)}[t(1056)+t(520)+"ner"](n,s){this[t(673)](n,s)}get readyState(){let n=t,s={NbQmV:function(l,h,p){return e[F(676)](l,h,p)}};if(e[n(1178)](e[n(1233)],e[n(1233)]))return this._socket.readyState;mmUXcy[n(1413)](_0x3f7bf0,_0xf67adf,66),mmUXcy[n(1413)](_0x471b3b,_0x24dc32,_0x232e90[n(693)]),mmUXcy.NbQmV(_0x5ea458,_0x593024,_0x5795a7)}get[t(1245)+"pe"](){let n=t,s={hhovJ:e[n(1352)],Grwvn:e[n(860)]};if(e.GTZYp===e[n(1089)])switch(_0xc00848){case s.hhovJ:case s[n(237)]:return{[n(417)+_0x335fa9]:1,"x-tt-env":_0x5994f7};default:return{}}else return this[n(1626)].binaryType}set[t(1245)+"pe"](n){}get[t(431)](){let n=t,s={fvEWi:e[n(236)],NlqHd:function(l,h,p){return l(h,p)}};if(e[n(479)](e[n(1499)],e[n(1499)]))return this[n(1626)].url;this[n(1391)](cJSnAV[n(786)],cJSnAV[n(1097)](_0xa5b746,cJSnAV[n(786)],{..._0x312a28,data:_0x22a7f3[n(1633)]||""}))}get protocol(){let n=t;return this[n(1626)][n(929)]}get[t(327)+"ns"](){let n=t;return this[n(1626)][n(327)+"ns"]}get[t(1479)+t(277)](){return 0}}function im(a,n){let s=t;if(n)return new n(a[s(431)],a[s(929)]);if(e[s(1546)](ei,Cn))return new rm(a[s(431)],a[s(929)],a[s(1513)]);if((ir||ti)&&e[s(1011)](e[s(695)],typeof WebSocket)&&WebSocket)return new WebSocket(a[s(431)],a.protocols)}function sm(a){let n=t;if(e.EqnCZ(e[n(1574)],"UVTIM")){let s=(n(1622)+"3")[n(302)]("|"),l=0;for(;;){switch(s[l++]){case"0":if(a)return!0;continue;case"1":if(Cn&&tt[n(500)+n(517)])return!0;continue;case"2":if(e[n(1003)](ir,ti)&&e[n(695)]!=typeof WebSocket&&WebSocket)return!0;continue;case"3":return!1;case"4":if(ei&&wx.connectSocket)return!0;continue}break}}else BTZUvY[n(1744)](_0x312ee1,BTZUvY[n(1130)](_0x4f8266,_0xfa7370[n(524)]),_0x4660c8[n(526)+"on"],_0x567bdc.newVersion,_0x3c35a5(_0x4836f1[n(992)+n(209)]))}function yl(a,n,s){let l=t,h={DYHBl:function(p,_){return e.BkhKg(p,_)},ekYzq:e[l(1142)],sLuvj:function(p,_){return e.XdiXq(p,_)}};if(e[l(1368)](e.dWCwW,e.dWCwW)){let p=-1;async function _(E){let m=l;return h[m(1375)](E,p)?Promise.reject(new Error(h[m(1664)])):(p=E,E===s[m(693)]?Promise[m(771)]():s[E][m(719)](a)(n,_[m(719)](null,h[m(637)](E,1))))}e[l(892)](_,0)}else{let p=e[l(230)][l(302)]("|"),_=0;for(;;){switch(p[_++]){case"0":this[l(1367)+l(1005)]();continue;case"1":this["_dropGlo"+l(907)+"Listener"]();continue;case"2":this[l(1380)+l(1493)]?.[l(1224)]();continue;case"3":this[l(638)+l(1719)]();continue;case"4":if(!this[l(1585)])return void this[l(952)](e.udZCy);continue;case"5":this[l(1121)+"WebSocket"](_0x10efa4,_0x122ee8);continue;case"6":if(e[l(1029)](this[l(1585)][l(421)+"te"],this.CLOSED)||this[l(1585)][l(421)+"te"]===this.CLOSING)return void this[l(952)](e.eZSuP);continue;case"7":this[l(1487)+"osed"]=!0;continue}break}}}function El(a){let n=t,s=0,l=0;for(let h=0;e.qPaxL(h,a[n(693)]);++h)l=a[n(1534)+"At"](h),e[n(1601)](l,128)?s+=1:e[n(1035)](l,2048)?s+=2:(64512&l)===55296&&e.rqVpq(e[n(562)](64512,a[n(1534)+"At"](e[n(400)](h,1))),56320)?(++h,s+=4):s+=3;return s}function bl(a,n,s){let l=t;if(e[l(591)](e[l(219)](s,n),1))return"";let h="";for(let p=n;e.wFkOg(p,s);){let _=a[p++];if(_<=127)h+=String[l(941)+"Code"](_);else if(e.AUIcl(_,192)&&e[l(1583)](_,224))h+=String["fromChar"+l(958)](e.SwWla(e[l(1366)](31,_),6)|e[l(1551)](63,a[p++]));else if(_>=224&&_<240)h+=String["fromChar"+l(958)](e[l(851)](e[l(1232)](15,_)<<12|e[l(1720)](e.vSjYr(63,a[p++]),6),e.kSWGN(63,a[p++])));else if(e.IlCgW(_,240)){let E=e[l(1693)](e.oxQqy(e.PSleZ(e.XuVnU(e[l(385)](7,_),18),e[l(1101)](63&a[p++],12))|e.KcFnW(e[l(257)](63,a[p++]),6),63&a[p++]),65536);h+=String["fromChar"+l(958)](e.DfHvm(55296,e.uDdAM(E,10))),h+=String["fromChar"+l(958)](e[l(1442)](56320,1023&E))}}return h}function Ia(a,n,s){let l=t,h=s,p,_;for(let E=0;e[l(859)](E,a[l(693)]);++E)if(p=a[l(1534)+"At"](E),e.brfEx(p,128))n[s++]=p;else if(e[l(831)](p,2048))n[s++]=e[l(1453)](e.XNyGe(p,6),192),n[s++]=e.pzyXE(63,p)|128;else if(e.KKLzh(e[l(1365)](64512,p),55296)&&e[l(1127)](64512&(_=a.charCodeAt(e[l(1093)](E,1))),56320)){let m=(l(1295)+l(1552)).split("|"),T=0;for(;;){switch(m[T++]){case"0":p=e[l(1159)](65536+(e.vVYts(1023,p)<<10),e.dTZCJ(1023,_));continue;case"1":++E;continue;case"2":n[s++]=e[l(1490)](e[l(1673)](p>>12,63),128);continue;case"3":n[s++]=e[l(814)](e[l(936)](e[l(1519)](p,6),63),128);continue;case"4":n[s++]=e[l(1251)](p,18)|240;continue;case"5":n[s++]=e.zpkuL(e.dhVQb(63,p),128);continue}break}}else n[s++]=e[l(588)](e[l(915)](p,12),224),n[s++]=e[l(1289)](e[l(1084)](e[l(1175)](p,6),63),128),n[s++]=e[l(1489)](63,p)|128;return s-h}async function vl(a){let n=t;if(e.TCBFI==typeof a){let s=new Uint8Array(e[n(469)](El,a));return Ia(a,s,0),s}return a instanceof ArrayBuffer?new Uint8Array(a):new Uint8Array(a.buffer,a[n(535)+"et"],a.byteLength)}function om(a){let n=t;try{return e.PnUdx(n(1268),typeof a)&&(e[n(1160)](a,ArrayBuffer)||a[n(732)]&&e[n(1716)](a.buffer,ArrayBuffer))||e[n(558)]!=typeof a?"":(JSON[n(1327)](a),e[n(1025)])}catch{return e[n(1373)](e[n(558)],typeof a)?"text/pla"+n(309)+n(751):""}}let am=(a,n)=>{let s=t;switch(a){case e[s(1352)]:case s(871):return{["x-use-"+a]:1,"x-tt-env":n};default:return{}}};class cm{constructor(n){let s=t;this[s(972)+s(354)]=n,this[s(865)]=0}[t(383)](){this.count++}[t(594)+t(644)+"nt"](){let n=t;return e[n(614)](this[n(865)],this[n(972)+n(354)])}[t(593)+t(1724)](n=0){let s=t;if(e[s(1010)]==="nibXe"){let h=""+_0x2b4143.now(),p=_0x2c93a6||(_0x4bf393=e[s(1315)](_0x16d26a,_0x1efcaf)),_=_0x1923a2[s(1637)]()[s(813)](16)[s(978)](-6);return e.mjzHN(e.NYCgr(e[s(483)]("02",h),p),_)}else this[s(972)+s(354)]=n,this.count=0}}async function dm(a){return new Promise(n=>{let s=F,l={VmcMP:function(h,p){return e[F(1236)](h,p)},LrXIk:e.kdhlw};if(!ir)return e[s(967)](n,e[s(244)]);try{let h=document[s(1695)+s(1506)]("script");window["frontier"+s(1434)]=p=>{let _=s;document[_(533)].removeChild(h),window[_(997)+_(1434)]=void 0,l.VmcMP(n,p&&p[_(353)]||l.LrXIk)},h[s(747)]=e[s(1394)],h[s(894)]=e[s(768)](a.replace(/^ws/,e[s(1483)]),e[s(1360)]);try{document[s(533)][s(756)+"ild"](h)}catch{document[s(533)][s(579)+s(1505)](h)}}catch{window["frontier"+s(1434)]=void 0,e[s(923)](n,e[s(244)])}})}function cn(a,n,s){let l=t,h={BYRmS:function(p,_){return e[F(1694)](p,_)},JmQjL:function(p,_){return e[F(1373)](p,_)},qCFAm:e.TCBFI,LWhCU:function(p,_){return p!==_},Fpydm:e[l(806)]};if(e[l(1437)](e[l(493)],e[l(1199)])){let{url:p}=h[l(832)](_0x286b5c,{}),_=_0x15f656[l(501)](p)?p:h.JmQjL(h[l(1286)],typeof p)?[p]:[];_0x560ea2&&_0x4aef97[l(433)](this[l(407)],_0xad3db4),_&&_[l(693)]?this[l(530)+l(1238)]=new _0x57e042(_,this._options[l(418)+"es"]):this[l(530)+l(1238)]?.[l(448)+l(777)+l(288)](),this[l(846)+l(1201)]?.[l(593)+"nter"](this[l(407)][l(989)+l(550)]),this[l(1487)+"osed"]=!1,this._ws&&h.LWhCU(this._ws[l(421)+"te"],this[l(365)])?this[l(663)+l(679)](1e3,h[l(1665)],!0):(this[l(1174)]=!0,this._connect())}else return!!a?.[l(1157)](p=>p[l(542)]===n&&p[l(1473)]===s)}function sr(a,n){let s=t;return a?.[s(1157)](l=>l.key===n)?.[s(1473)]}let Aa=null;async function lm(){let a=t;return Aa||(Aa=Promise[a(771)]().then(zt[a(719)](zt,e[a(583)]))),Aa}class um extends Sa{constructor(n,s){let l=t;super(),this[l(1140)]=n,this._keyPath=s,this[l(1340)]=void 0,this[l(1598)+"mise"]=null}async openDB(){let n=t,s={HMYKW:function(l,h,p){return e[F(532)](l,h,p)},bUIhC:"cursor_n"+n(920)};e[n(1222)]===e.JRWMf?await this[n(394)]():(this[n(1429)+n(1281)]=_0x2faf30,this._cursorFileName=_0x1bb641,this[n(1265)+n(1632)]=_0x26dde3,this[n(1340)]=s[n(1683)](_0x42b204,this["_cursorN"+n(1281)],s.bUIhC))}async[t(394)](){let n=t;if(!this[n(1340)]){if(this[n(1598)+n(767)])return this[n(1598)+n(767)];try{let s=this[n(1140)],l=this[n(837)];this[n(1598)+n(767)]=(async()=>{let h=n,{openDB:p}=await e[h(465)](lm);this[h(1340)]=await e[h(491)](p,h(997)+"_"+s,1,{upgrade(_){let E=h;_[E(1301)+E(658)+"e"](s,{keyPath:l})}})})(),await this[n(1598)+n(767)]}catch(s){if(e.NFvxK(e[n(1596)],e.rOJXd))console[n(1008)](s);else return this._qosDB?.[n(1345)](_0x1d44ab)}finally{this[n(1598)+"mise"]=null}}}async get(n){let s=t;try{return await this[s(394)](),this[s(1340)]?.[s(1345)](this[s(1140)],n)}catch(l){console.log(l)}}async[t(1548)](n,s){let l=t;return await this[l(394)](),this[l(1340)]?.[l(1198)](this[l(1140)],n)}async del(n){let s=t;try{return await this._init(),this[s(1340)]?.[s(1165)](this[s(1140)],n)}catch(l){console[s(1008)](l)}}async[t(546)](){let n=t,s={cJBEQ:function(l,h){return e[F(976)](l,h)},URlzs:function(l,h){return e[F(1107)](l,h)},WOrFL:function(l,h){return e[F(538)](l,h)},SHXEN:function(l,h,p,_){return e[F(372)](l,h,p,_)},iKkuT:function(l,h,p){return e[F(263)](l,h,p)},NrmWS:n(905)};if(e[n(1091)](e[n(226)],e.dSCEt))try{return await this[n(394)](),this[n(1340)]?.[n(546)](this[n(1140)])}catch(l){if(e[n(1608)](e[n(1196)],n(1062)))console[n(1008)](l);else return TivLKp[n(575)](TivLKp[n(413)](1e4,_0x113d7c[n(1643)]()),_0x235f80[n(646)](TivLKp.WOrFL(1e4,_0x2c4688.random())))}else try{s[n(1216)](_0x164655,this,_0x3e3591,[_0x796b5e,_0xc9bf38,_0x5432b6])}catch(l){let h=s[n(323)](_0x5a4749,s.NrmWS,{message:l.message,code:_0x3b9f1b[n(966)+"OR"],error:l});this["_dispatchErrorEv"+n(1379)](h)}}async keys(){let n=t;return await this._init(),this[n(1340)]?.[n(984)+"ys"](this[n(1140)])}async getAll(){let n=t;return await this._init(),this[n(1340)]?.[n(970)](this[n(1140)])}async[t(1224)](){let n=t;try{this._qosDB?.close(),this._qosDB=void 0}catch(s){e[n(1119)](n(1581),"INWgC")?console[n(1008)](s):(this._DBName=_0x5f5737,this[n(1304)]=_0x45fcc2,this[n(1340)]=_0x13f02e)}}get isReady(){let n=t;try{return!!this[n(1340)]}catch(s){return console[n(1008)](s),!1}}}class fm{constructor(n,s){let l=t;this[l(1303)]=n,this[l(1304)]=s,this[l(1340)]=localStorage}async openDB(){}get[t(991)](){return t(997)+"_"+this._DBName}async[t(1345)](n){let s=t,l=this[s(1340)][s(1566)](this._prefix);return JSON[s(1327)](e[s(1546)](l,"{}"))[n]}async[t(1548)](n,s){let l=t;if(e.xnSCQ(e[l(1122)],e[l(1529)])){let h=_0x35d7f3.charCodeAt(_0x285817);h>=55296&&e[l(1333)](h,56319)&&e[l(1347)](_0x97a9a7,1)<_0x5ebfeb&&(h=e[l(1476)](e[l(976)](h<<10,_0x43aabd[l(1534)+"At"](++_0x640b04)),56613888)),e[l(1583)](h,128)?_0xf22a82[_0x198d80++]=h:(h<2048?_0x4550ac[_0x320867++]=e[l(1653)](e[l(1251)](h,6)&31,192):(e[l(1583)](h,65536)?_0x3b6f95[_0x52b937++]=e[l(1519)](h,12)&15|224:(_0x249a41[_0x382b31++]=e[l(1357)](e[l(562)](e[l(1175)](h,18),7),240),_0x321d5b[_0x217ac4++]=e[l(968)](e[l(1099)](e[l(1519)](h,12),63),128)),_0x97a29[_0x3d6eeb++]=e[l(750)](h,6)&63|128),_0x402f3c[_0xad953c++]=e.ZvysG(63,h)|128)}else{let h=this[l(1340)][l(1566)](this[l(991)]),p=JSON.parse(e.uMLow(h,"{}"));return p[s||n[this[l(1304)]]]=n,this[l(1340)].setItem(this[l(991)],JSON[l(1138)+"y"](p)),s||n[this[l(1304)]]}}async[t(1322)](n){let s=t,l=this._qosDB[s(1566)](this[s(991)]),h=JSON[s(1327)](e[s(1003)](l,"{}"));return h[n]=void 0,this._qosDB[s(766)](this[s(991)],JSON[s(1138)+"y"](h))}async[t(546)](){let n=t,s={SVhlh:function(l,h,p){return e[F(699)](l,h,p)}};return e[n(1530)](e.vHbth,e[n(1462)])?new _0x159f8c(l=>{let h=n;s[h(928)](_0x3c8d75,l,this[h(514)+h(1255)+"e"](_0x1f5e50))}):this[n(1340)][n(546)]()}async[t(691)](){let n=t;if(e[n(1178)](n(800),"AViFj"))return _0x489481[n(1008)](_0x272ebc),!1;{let s=this._qosDB[n(1566)](this._prefix),l=JSON[n(1327)](e[n(1654)](s,"{}"));return Object[n(691)](l)}}async[t(970)](){let n=t,s=this[n(1340)].getItem(this._prefix),l=JSON[n(1327)](e[n(1009)](s,"{}"));return Object[n(935)](l)}[t(1224)](){return Promise[t(771)]()}get[t(303)](){return!!this[t(1340)]}}class hm{constructor(n,s){let l=t;e[l(1125)](e[l(1100)],e[l(1100)])?this[l(409)+l(509)]=_0x557b2b:(this[l(1303)]=n,this[l(1304)]=s,this[l(1340)]=Cn?tt:ei?wx:null)}async[t(1715)](){}get[t(991)](){let n=t;return n(997)+"_"+this[n(1303)]}async get(n){let s=t,l=this[s(1340)].getStorageSync(this[s(991)]);return JSON[s(1327)](e.nbeui(l,"{}"))[n]}async set(n,s){let l=t;if(e.NrSSY!==e[l(492)])this[l(683)+"s"]=_0x13a117,this[l(418)+"es"]=_0x4fc8c2,this[l(287)+l(888)]=0,this[l(629)+l(1591)+l(487)+"t"]=0;else{let h=this._qosDB[l(1722)+"geSync"](this[l(991)]),p=JSON.parse(e[l(864)](h,"{}"));return p[s||n[this[l(1304)]]]=n,this[l(1340)]["setStora"+l(549)](this[l(991)],JSON[l(1138)+"y"](p)),s||n[this[l(1304)]]}}async del(n){let s=t,l=this._qosDB[s(1722)+s(549)](this._prefix),h=JSON[s(1327)](l||"{}");return h[n]=void 0,this._qosDB[s(358)+s(549)](this[s(991)],JSON[s(1138)+"y"](h))}async[t(546)](){let n=t;return this._qosDB[n(273)+n(1341)]()}async[t(691)](){let n=t,s=this[n(1340)]["getStora"+n(225)+"nc"](this._prefix),l=JSON.parse(e[n(1603)](s,"{}"));return Object.keys(l)}async[t(970)](){let n=t,s=this[n(1340)].getStorageInfoSync(this._prefix),l=JSON[n(1327)](e[n(864)](s,"{}"));return Object[n(935)](l)}closeDB(){return Promise[t(771)]()}get isReady(){let n=t;if(e[n(1158)](e[n(769)],n(990)))return!!this._qosDB;throw this[n(1512)+n(1283)]=!1,_0x1d9b06}}function Sl(a,n){let s=t;if(Cn||Cn)return new hm(a,n);if(e.JhWXV(ir,ti)&&e[s(1011)](e[s(695)],typeof indexedDB))return new um(a,n);if(e.uMLow(ir,ti)&&e[s(1011)](e[s(695)],typeof localStorage))return new fm(a,n);throw new Error(s(878)+s(1431)+"d")}class xm{constructor(){let n=t;this[n(606)+"lTimeoutId"]=null,this[n(606)+"l"]=36e5,this[n(1340)]=e[n(1547)](Sl,e[n(1209)],e.qdcBq)}async[t(606)+t(446)](){let n=t;clearInterval(this[n(606)+n(1114)+"Id"]),this[n(606)+"lTimeoutId"]=e[n(608)](setInterval,()=>{let s=n,l={pmNlo:function(h,p,_){return h(p,_)}};if(s(1507)===s(1507))this[s(776)+"ired"]();else{let h=l[s(541)](_0x4c3451,s(905),{message:_0x4cf135[s(689)],code:_0x58acfc["MESSAGE_"+s(1055)],error:_0x213051});this[s(1648)+"hErrorEv"+s(1379)](h)}},this._interval)}async[t(1715)](){let n=t,s={UBdXS:"3|4|0|1|2",nlWAy:e[n(998)],OzOMg:e[n(1468)],PTMCM:e[n(959)],mIEdP:n(1307),AHuae:function(l,h){return e[n(1624)](l,h)},zFUCe:e.KWITq};await this[n(1340)].openDB().then(()=>{let l=n;if(s[l(772)](s[l(735)],l(396))){let h=s[l(1396)][l(302)]("|"),p=0;for(;;){switch(h[p++]){case"0":this[l(1585)][l(1056)+"entListe"+l(1361)](s[l(267)],this[l(782)]);continue;case"1":this._ws[l(1056)+l(520)+"ner"](s.OzOMg,this._onMessage);continue;case"2":this[l(1585)][l(1056)+l(520)+"ner"](s[l(821)],this[l(516)]);continue;case"3":if(!this[l(1585)])return;continue;case"4":this[l(1585)][l(1056)+l(520)+l(1361)](s[l(578)],this[l(1531)]);continue}break}}else this[l(606)+l(446)]()})}async[t(776)+t(1613)](){let n=t;(await this[n(1340)]?.[n(970)]()||[]).filter(({timestamp:h})=>h<Date[n(1643)]()).forEach(h=>{let p=n;this[p(1340)]?.[p(1322)](h[p(343)+"id"])})}async[t(1322)](n){let s=t;if(e[s(345)](s(601),e.kyqiN)){let l=e[s(955)][s(302)]("|"),h=0;for(;;){switch(l[h++]){case"0":if(!this[s(1585)])return;continue;case"1":this[s(1585)][s(1731)+s(213)](e[s(959)],this[s(516)]);continue;case"2":this._ws[s(1731)+s(213)](e[s(236)],this[s(1531)]);continue;case"3":this[s(1585)][s(1731)+s(213)](e[s(998)],this[s(782)]);continue;case"4":this[s(1585)]["addEvent"+s(213)](e.imUDB,this[s(1448)+"ge"]);continue}break}}else return this._qosDB?.[s(1322)](n)}async[t(1548)](n,s){let l=t;return this[l(1340)]?.[l(1548)]({message_id:n,timestamp:s})}async[t(1345)](n){let s=t;return this._qosDB?.[s(1345)](n)}async[t(1224)](){let n=t;e[n(1638)](clearInterval,this[n(606)+n(1114)+"Id"]),await this._qosDB?.[n(1224)]()}get isReady(){let n=t,s={VUVCp:e.uUDMF,HkBki:e[n(1631)],CsVMt:"name",UCRPs:n(1305),YzwGT:function(l,h,p,_){return e[n(1343)](l,h,p,_)},CekXU:e[n(1628)],SeodK:n(1658)};if(e[n(1189)](e[n(632)],n(1621))){let l=s[n(1292)][n(302)]("|"),h=0;for(;;){switch(l[h++]){case"0":_0x3a8144[n(1008)](s.HkBki,_0x50d9d2);continue;case"1":_0x1036de[n(1008)](s[n(1600)],_0x48f7a0);continue;case"2":_0x301a57[n(1008)](s[n(931)],_0x436d22);continue;case"3":_0x30c59b=s.YzwGT(_0x3521ea,_0x145038,_0x49978b,_0x54b819[n(1305)]||0);continue;case"4":_0x187d82=s[n(707)](_0x2a93ea,_0x5468af[n(1378)+"er"](_0x1fb12e.cursor||_0x52b06a),_0x47d96c,_0x4e0035);continue;case"5":_0x562904[n(1008)](s[n(1655)],_0x3939b4,_0x3c31fd.service);continue;case"6":_0x4d58b0=s.YzwGT(_0x23e755,_0x4a75fa["cursor_n"+n(920)],_0x7146ee,_0x361d4f);continue;case"7":_0x31f2a5=s[n(707)](_0x18da6,0,_0x55bc42,_0x145253);continue;case"8":_0x3fa542.log(s.SeodK,_0x50b3c1);continue;case"9":_0x5551d5=_0x4f96d1(_0x5f0612[_0x38eed0[n(1538)+n(920)]],_0xe3eedc,_0x492b9d);continue;case"10":_0x4c329c[n(1008)](n(1542)+"name",_0x969ef6);continue}break}}else return this[n(1340)]?.[n(303)]}}function ka(a){let n=t;if(e.JZETT===n(552)){let s=!!this[n(407)].enableQoS;if(!s)return{enabled:s,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let l=e[n(372)](cn,a.message[n(1513)],e[n(377)],"2"),h=l&&e.dQzjs(cn,a.message[n(1513)],n(577)+n(270)+"ck","1"),p=l&&cn(a[n(689)][n(1513)],e[n(461)],"1"),_=p?sr(a.message[n(1513)],e[n(570)])?.[n(302)](",").filter(Boolean)||[]:[];return{enabled:s,isQoSMessage:l,isQoSAck:h,isAckCleanupMessage:p,ackMsgIds:_}}else _0x2badb3[n(996)]=_0x47c2d4.resolve().then(()=>(_0x3aec79(),_0x3a5de9))[n(502)](function(s){return s})}async function Il(){let a=t;return this[a(1380)+a(1493)]||(this["_QoSMana"+a(1493)]=new xm),this[a(1380)+a(1493)][a(303)]||await this[a(1380)+a(1493)][a(1715)](),this[a(1380)+"ger"]}async function pm(a,n){let s=t,{enableAutoAck:l}=this[s(407)],h=e.wLJCv(cn,a[s(689)][s(1513)],e[s(376)],"1"),p=e[s(787)](cn,a[s(689)].headers,"is_ack","1"),_=ka[s(1102)](this,a);if(e[s(1689)](l,h))if(e.HuTsA(s(317),s(706))){let{SeqID:E,LogID:m,service:T,LogIDNew:L,method:j}=a[s(689)];this[s(390)]({SeqID:E,LogID:m,LogIDNew:L,service:T,method:j,headers:[{key:e[s(869)],value:"1"},{key:e.VEPSb,value:e[s(969)](L,"")},{key:"ack_code",value:"0"}]})}else{let E=_0x1cc5bd[s(693)]&&_0x55e07c[0];if(e[s(1300)](E,_0x492564))throw E;let m=new _0x4e4a08(e[s(266)]+(E?" ("+E.message+")":""));throw m[s(1261)]=E,E}p&&!_[s(1014)]&&this["_dispatc"+s(643)+s(1045)](a),e[s(465)](n)}async function mm(a,n){let s=t;this[s(952)](s(352),a[s(689)]),e[s(285)](n)}async function gm(a,n){let s=t,l={ktwel:function(h,p){return e.YItfS(h,p)},qRaIw:function(h,p){return e.eaTjP(h,p)},TWSxX:function(h,p){return h instanceof p}};if(e[s(854)](e[s(432)],e[s(432)])){let h=e[s(1148)](sn,await e[s(1639)](vl,a[s(474)]));try{if(h[s(1662)]instanceof Uint8Array){let p=this[s(407)][s(1676)+s(960)]instanceof Object?{force:!!this[s(407)]["payloadE"+s(960)][s(867)],encoding:this._options.payloadEncoding[s(278)]?this._options[s(1676)+s(960)][s(278)].replace(/\s/g,"")[s(801)+"ase"]():""}:{force:!1,encoding:this[s(407)][s(1676)+s(960)]?this[s(407)][s(1676)+s(960)][s(310)](/\s/g,"")[s(801)+"ase"]():""},_=h["payloadE"+s(960)]?h[s(1676)+"ncoding"].replace(/\s/g,"")[s(801)+"ase"]():"",E=this[s(407)][s(942)+s(1139)]instanceof Object?{force:!!this[s(407)][s(942)+s(1139)].force,type:this[s(407)].payloadType[s(747)]?this[s(407)][s(942)+s(1139)][s(747)].replace(/\s/g,"")[s(801)+"ase"]():""}:{force:!1,type:this._options[s(942)+"ype"]?this._options[s(942)+s(1139)][s(310)](/\s/g,"")["toLowerC"+s(654)]():""},m=h[s(942)+s(1139)]?h["payloadT"+s(1139)][s(310)](/\s/g,"")[s(801)+s(654)]():"",T=E[s(867)]?E.type:m||E[s(747)],L=p[s(867)]?p.encoding:_||p.encoding,j=[e[s(901)],e[s(1025)],e[s(1532)],e[s(558)]],$=[e[s(1087)],s(977)];this[s(407)][s(1707)+s(1679)+s(1497)+"ad"]&&j[s(743)](T)&&(!L||$.includes(L))?h[s(1508)+s(783)]=e[s(1343)](bl,h[s(1662)],0,h[s(1662)][s(882)+"th"]):h[s(1508)+s(783)]=""}else h["textPayl"+s(783)]=""}catch(p){h.textPayload="",console[s(1008)](p)}a[s(689)]=h,e[s(1082)](n)}else{if(Inkerh[s(852)]("string",typeof _0x1a847c)){let h=new _0x421723(Inkerh[s(1570)](_0x31ce98,_0x11f39d));return _0x156f16(_0x3f7ff1,h,0),h}return Inkerh[s(1393)](_0x3d9d46,_0x53c9cd)?new _0x2e7945(_0x1676e6):new _0x1fd374(_0x1ebde6[s(732)],_0x4c360a[s(535)+"et"],_0x4ef9bb[s(882)+"th"])}}function wm(a,n,s){let l={LYrKn:function(m,T){return e[F(1601)](m,T)},wRuuH:function(m,T){return e[F(1079)](m,T)},rQIhW:function(m,T){return e[F(1022)](m,T)},wcsER:function(m,T){return m+T},pODNX:function(m,T){return e[F(642)](m,T)},Ggycz:function(m,T){return e[F(585)](m,T)}},h=s||8192,p=h>>>1,_=null,E=h;return function(m){let T=F;if(l[T(1700)](m,1)||l[T(1424)](m,p))return l[T(1729)](a,m);l[T(1424)](l[T(760)](E,m),h)&&(_=l.rQIhW(a,h),E=0);let L=n[T(1102)](_,E,E+=m);return l[T(1166)](7,E)&&(E=l.Ggycz(7,E)+1),L}}let _m=4294967295;function ym(a,n,s){let l=t,h={NbAPG:function(p,_,E){return e[F(1554)](p,_,E)},cRkbA:e.DGbfE};if(e[l(476)](e[l(1738)],e[l(1738)])){if(this[l(530)+l(1238)]?.[l(594)+l(1595)+"es"]()){let _=this[l(530)+l(1238)]?.[l(573)+l(858)+"nt"]();this[l(1648)+l(1147)+"ent"](h[l(785)](_0x475524,h[l(1463)],{code:1006,reason:l(1705)+_+(" timeout"+l(613)+l(1284)+l(401)),wasClean:!0}))}else{let _=this[l(407)][l(276)+l(1048)+l(1202)](_0x3ec788,_0x117ebd);this["_dispatc"+l(1147)+"ent"](_0x58e060(h[l(1463)],{code:_0x226ca2,reason:_0x14b746,wasClean:!0,willReconnect:_})),_&&this[l(1512)]()}return}else return e[l(746)](RangeError,e[l(1623)](e[l(1067)](e[l(805)](e[l(1576)](e[l(1630)](e[l(1674)],a),e[l(988)]),n||1),e[l(233)]),s))}function Em(a,n,s){let l=t;if(e[l(1141)](s,_m))throw new Error(e[l(1733)]);let h=3;for(;e.oPBkJ(h,0);){let p=255&s;e[l(787)](Ra,p,a,e[l(684)](n,h)),s>>>=8,h--}return e[l(768)](n,4)}function bm(a,n){let s=t,l=0,h=n,p=e[s(1477)](n,4);for(;e.xjYSq(h,p);){let{value:_,offset:E}=Ta(a,h);h=E,l=l<<8>>>0,l+=_}return{value:l,offset:p}}function vm(a,n,s){let l=t;if(e[l(741)](e[l(1651)],e[l(1651)])){let h=e[l(623)].split("|"),p=0;for(;;){switch(h[p++]){case"0":return e[l(271)](e[l(667)](Ia,a,n,s),s);case"1":if(a[l(693)]<40)return e[l(1185)](Ia(a,n,s),s);continue;case"2":if(!a)return s;continue;case"3":if(n[l(1250)+"e"])return n[l(1250)+"e"](a,s)+s;continue;case"4":if(n[l(560)])return n[l(560)](a,s)+s;continue}break}}else e[l(1343)](_0x5113c4,this,_0x1b0878,[_0x3f1bf6,_0x5f18e2,_0x2e1d38,_0x857bf8,_0x3c3a93,_0x3571fd])}function Sm(a,n){let s=t,l=new he(e.PSleZ(e[s(817)](e[s(1636)](a[e.pNNxn(n,4)]<<24,e[s(1059)](a[e[s(898)](n,5)],16)),e[s(481)](a[n+6],8)),a[e[s(247)](n,7)]),e[s(1043)](e.wUduo(e.npqOh(a[e[s(1557)](n,0)],24),e.FUSTu(a[e[s(753)](n,1)],16)),e[s(1678)](a[e.rxanG(n,2)],8))|a[e[s(753)](n,3)],!0);return n+=8,{value:l,offset:n+8}}function Im(a,n,s){let l=t,h=a[l(1372)],p=a[l(836)];return n[s]=e[l(611)](p,24),n[e[l(1185)](s,1)]=e[l(1037)](p>>>16,255),n[s+2]=e[l(1687)](e[l(1354)](p,8),255),n[s+3]=255&p,n[s+4]=e.UUkpm(h,24),n[e[l(1579)](s,5)]=e[l(946)](h>>>16,255),n[e[l(834)](s,6)]=e.EHjOW(e.yJYYO(h,8),255),n[e[l(1442)](s,7)]=e[l(1549)](255,h),s+=8,s}function Ta(a,n){let s=t;return a[s(912)+"8"]?{value:a[s(912)+"8"](n),offset:e.XnwWb(n,1)}:{value:255&a[n],offset:n+1}}function Ra(a,n,s){let l=t;return n[l(1561)+"t8"]?n[l(1561)+"t8"](a,s):n[s]=255&a,e[l(559)](s,1)}let Am=function(a){return new Uint8Array(a)},km=e.KKAhT(e[t(695)],typeof Buffer)?Buffer[t(1560)+t(1616)]:e[t(436)](wm,Am,Uint8Array.prototype[t(918)]),Tm=16,Ca=32;function Rm(a){let n=t,s=0,l={};for(let h=0;e[n(289)](h,a[n(693)]);h++)e[n(774)]!==e[n(610)]?(l[a[h][n(1538)+n(920)]]=e.kxEjT(El,a[h][n(1538)+n(920)]),s+=e[n(843)](14,l[a[h][n(1538)+n(920)]])):(e[n(1638)](_0x1286e1,e[n(1680)]),this[n(673)](e[n(449)],_0x4b0618),this[n(673)](e[n(207)],_0x1a9dec));return[s,l]}function Al(a,n,s){let l=t,[h,p]=e.CfenA(Rm,a),_=e[l(232)](km,h),E=0;return a.forEach(m=>{let T=l;console[T(1008)](e[T(1628)],m,m.service),E=e[T(1629)](Ra,0,_,E),console[T(1008)](e[T(428)],E),E=e[T(667)](Em,_,E,m.service||0),console[T(1008)](T(1305),E),E=e[T(1176)](Ra,p[m["cursor_n"+T(920)]],_,E),console[T(1008)](e.NeLbF,E),E=e.eadWm(vm,m["cursor_n"+T(920)],_,E),console[T(1008)](e[T(1282)],E),E=e[T(1400)](Im,he[T(1378)+"er"](m[T(759)]||n),_,E),console[T(1008)](e[T(1631)],E)}),{frameType:Ca,headers:[{key:e.FJbCl,value:s}],payload:_}}function Cm(a){let n=t,s=0,l=[];for(;s<a[n(882)+"th"];){let{offset:h}=e[n(412)](Ta,a,s);s=h;let p={cursor_name:"",cursor:0,service:0},{value:_,offset:E}=e[n(263)](bm,a,s);p[n(1305)]=_,s=E;let{value:m,offset:T}=Ta(a,s);s=T,p[n(1538)+"ame"]=e[n(752)](bl,a,s,e[n(1156)](s,m)),s+=m;let{value:L,offset:j}=e[n(1702)](Sm,a,s);p[n(759)]=L[n(319)](),s=j,l[n(1419)](p)}return l}function Pm(){let a=t;return{frameType:Ca,headers:[{key:e[a(1285)],value:e[a(596)]}],payload:void 0}}class Dm{constructor(n,s,l){let h=t;this[h(1429)+h(1281)]=n,this[h(409)+h(509)]=s,this[h(1265)+h(1632)]=l,this[h(1340)]=e.mOhND(Sl,this[h(1429)+h(1281)],"cursor_n"+h(920))}async[t(1715)](){let n=t;e[n(1608)](e[n(1641)],e[n(339)])?(_0x37dd3e=e[n(438)](_0x9f4b3d,_0x3e4bfb),_0x384562=127&_0x95a000,e.PRoHS(128,_0x437d45)&&(_0x435b0e=e[n(1068)](_0x1f4d68,_0x3ab349),_0x24611c|=e[n(657)](127&_0x44fd1e,7))):await this[n(1340)][n(1715)]()}async getCursors(){let n=t;if(!this._qosDB.isReady)return;let s=this[n(1265)+n(1632)],l=await this[n(1340)][n(970)]();switch(console[n(1008)]("allCurso"+n(1036),l),s){case n(1634):return l&&l[n(693)]?Al(l,0,this[n(409)+"ileName"]):void 0;case e[n(1740)]:return;case e[n(457)]:return l&&l[n(693)]?e[n(1188)](Al,l,0,this["_cursorF"+n(509)]):e[n(1450)](Pm)}}async[t(1548)](n,s,l){let h=t;return console[h(1008)](e.jxVEy,n,s,l),this[h(1340)].set({cursor_name:n,cursor:s,service:l})}async[t(780)+"rs"](n){let s=t,l=e[s(1096)](Cm,n);for(let h of l)console[s(1008)](e[s(1387)],l),await this[s(1340)][s(1548)](h)}async[t(1345)](n){let s=t;return(await this[s(1340)][s(1345)](n))?.[s(759)]}async[t(1224)](){let n=t;if(e[n(1610)](e[n(347)],n(423)))return(this[n(584)+"rs"][_0x41636c]||(this[n(584)+"rs"][_0x41a680]=[]))[n(1419)]({fn:_0xd7737e,ctx:_0x4c5165||this}),this;await this[n(1340)][n(1224)]()}[t(1543)+"rsorFile"+t(1730)](n){let s=t;this[s(409)+"ileName"]=n}get[t(303)](){let n=t,s={oNyrA:e[n(896)],inOYK:e.vFXyy,liIay:e[n(1571)]};if(e[n(1573)](e[n(1133)],n(1177)))this[n(1309)+"er"]&&_0x3fe09c[n(1056)+n(520)+n(1361)](s.oNyrA,this._handleOnLine),this[n(1309)+"er"]&&_0x193715["removeEv"+n(520)+n(1361)](s[n(1258)],this["_handleO"+n(1692)]),this._isBrowser&&_0x31fc03[n(1056)+"entListener"](s[n(1690)],this[n(1580)+n(1279)]),this[n(1309)+"er"]&&_0x4a4a9f[n(1056)+n(520)+n(1361)](n(742),this[n(1580)+n(961)]);else return this[n(1340)][n(303)]}}let Om=e[t(1123)];async function kl(a){let n=t;if(!this._options.enableQoS)return null;let{aID:s,fpID:l,messageStrategy:h}=this._options,p=e[n(1403)](a,Om);try{if(this[n(604)+n(380)])if(e[n(979)](e[n(1620)],n(1326))){let _=_0x6fb757[n(689)][n(1662)];_&&_0x2d21b6.setCursors(_)}else a&&this[n(604)+n(380)][n(1543)+n(1356)+n(1730)](a);else this[n(604)+"anager"]=new Dm(l+"_"+s+"_"+p,p,h);return this[n(604)+n(380)][n(303)]||await this["_cursorM"+n(380)][n(1715)](),this[n(604)+n(380)]}catch{return null}}async function Lm(a,n){let s=t,l=e[s(372)](cn,a[s(689)][s(1513)],e[s(820)],"-1"),h=e.tyCcN(cn,a[s(689)].headers,s(391),"1"),p=e[s(466)](sr,a.message[s(1513)],s(577)+"er_msgid"),_=e[s(424)](Number,e[s(829)](sr,a.message[s(1513)],e[s(494)]))||0,E=ka.call(this,a),m=e[s(497)](cn,a.message.headers,e[s(222)],"2"),T=e.MKsuA(sr,a.message[s(1513)],s(1006)+s(739)+"e"),L=e[s(434)](Number,e[s(466)](sr,a[s(689)][s(1513)],e.ncqif));if(E[s(1014)])return e[s(482)](n);let j=E[s(1443)+s(686)]?await Il.call(this):null;if(a[s(689)].service>0&&h&&!l||e[s(1071)](a.message[s(1305)],0)){if(p&&E[s(1443)+s(686)]&&j){if(!!!await j[s(1345)](p))if(e[s(1446)](e[s(1074)],e[s(1074)]))this[s(1648)+"hMessage"+s(512)](a),await j[s(1548)](p,e.kYXbi(Date[s(1643)](),_));else{if(this["_clearPi"+s(1005)](),this["_clearTi"+s(1719)](),this[s(313)+s(709)+"rs"](),this[s(839)+"nceClose"](1e3,_0x5824ed),this[s(1512)+s(1283)]=!1,_0x1b0382&&this[s(1521)+s(665)]()&&!this["_readyCl"+s(1590)]){if(this._endpointManager?.[s(594)+"chMaxTries"]()){let _e=this[s(530)+s(1238)]?.["getCurre"+s(858)+"nt"]();this[s(1648)+s(1147)+s(1379)](e[s(1411)](_0x316819,e[s(998)],{code:1006,reason:s(1705)+_e+(s(649)+s(613)+s(1284)+s(401)),wasClean:!0}))}else{let _e=this[s(407)][s(276)+s(1048)+s(1202)](_0x80f64c,_0x4c025b);this[s(1648)+s(1147)+s(1379)](e[s(555)](_0x2c61eb,e[s(998)],{code:_0x487be3,reason:_0x10c8fc,wasClean:!0,willReconnect:_e})),_e&&this[s(1512)]()}return}this[s(1521)+s(665)]()||this[s(1487)+s(1590)]?this[s(1648)+s(1147)+s(1379)](e[s(1425)](_0x5de74a,e[s(998)],{code:_0x26f5df,reason:e[s(1481)]})):this["_dispatc"+s(1147)+s(1379)](e[s(357)](_0x3b34e8,e[s(998)],{code:1006,reason:s(1234)+s(1355)+s(758)+s(1728)})),this[s(1585)]=null,this[s(530)+s(1238)]?.[s(448)+"pointCon"+s(288)](),this[s(846)+s(1201)]?.[s(593)+s(1724)]()}return n()}if(m){let $=await kl.call(this);if(!$)return this[s(1648)+"hMessage"+s(512)](a),e[s(1386)](n);let Y=await $[s(1345)](T)??-1;if(Y<L)this[s(1648)+s(293)+"Event"](a),$[s(1548)](T,L,a[s(689)][s(1305)]);else throw new Error("recevied"+s(825)+" cursor "+L+(" larger than loc"+s(359)+"r ")+Y);return e[s(330)](n)}return this[s(1648)+"hMessage"+s(512)](a),e.FxHnL(n)}}async function Nm(a,n){let s=t,l=ka[s(1102)](this,a);if(!l[s(1443)+s(686)])return e.MZUoO(n);let h=await Il[s(1102)](this);if(l[s(1113)+"anupMess"+s(715)]&&l.ackMsgIds.length)for(let p of l[s(948)+"s"])await h.del(p);e[s(1450)](n)}async function Mm(a,n){let s=t,l=e[s(1192)](a[s(689)][s(389)+"e"],Tm),h=e[s(1624)](a[s(689)].frameType,Ca);if(e[s(227)](!l,!h))return e[s(482)](n);let p=e[s(1554)](sr,a[s(689)][s(1513)],s(1511)+s(1619));if(!p)return n();let _=await kl.call(this,p);if(!_)return n();if(l){let E=await _[s(553)+"rs"](),m={frameType:E?.[s(389)+"e"],SeqID:he[s(1378)+"er"](this[s(508)]++),LogID:he[s(1378)+"er"](this[s(407)][s(548)+s(325)]()),service:9e3,method:5,headers:E?.[s(1513)],payload:E?.payload},T=e.LkAdF(S,m);this[s(1585)]&&this[s(1585)][s(421)+"te"]&&this[s(1585)].send(T)}if(h){let E=a.message[s(1662)];E&&_[s(780)+"rs"](E)}}let Bm=async function(a,n){let s=t;this._isInit=!1,e[s(1656)](clearTimeout,this[s(1512)+s(678)+s(441)]),e[s(1450)](n)},Fm=async function(a,n){let s=t;if(!this[s(1585)]||e[s(1125)](this[s(1585)][s(421)+"te"],this.OPEN))return e[s(1495)](n);let{pingInterval:l}=this[s(407)];this[s(530)+s(1238)]?.[s(448)+"pointCon"+s(288)]();for(let p=0;e[s(731)](p,this[s(1265)+s(1420)][s(693)]);p++){let _=this["_message"+s(1420)][p];if(this[s(1585)][s(421)+"te"]===this[s(838)]&&_!==null)this[s(1585)]&&this[s(1585)][s(238)](_),this[s(1265)+s(1420)][p]=null;else break}this[s(1265)+s(1420)]=this[s(1265)+s(1420)].filter(p=>!!p),this._pingPongTimeoutId=e[s(699)](setTimeout,()=>this._ping(),l),this[s(1648)+s(1474)+"nt"](a),this[s(1309)+"er"]&&this[s(1585)]&&(this[s(1585)][s(1245)+"pe"]=this[s(580)+s(1139)]);let h=this[s(530)+s(1238)]?.[s(573)+s(858)+"nt"]();this[s(952)](s(724)+h+" success"),n()},zm=async function(a,n){let s=t,l=this[s(530)+s(1238)]?.[s(573)+"ntEndpoint"]();this[s(952)](s(724)+l),e[s(482)](n)};class Um extends Sa{constructor(n){let s=t,l={jefjo:function(E){return e.EXTVW(E)},nbOVR:function(E,m,T,L){return e[F(1629)](E,m,T,L)},ldIcL:function(E,m){return e[F(346)](E,m)},JGEpy:e[s(321)],LlWSz:function(E,m,T){return e[s(744)](E,m,T)},aWRju:s(905),TCwZE:function(E,m){return e.gNoRk(E,m)},dbKwb:"auto",mwfFm:function(E,m,T,L){return e[s(1024)](E,m,T,L)},wBOIq:function(E,m){return e[s(340)](E,m)},UBpdy:e.DGbfE,YfBTo:e[s(1481)],YppEK:function(E,m,T){return e[s(408)](E,m,T)}};super(),this[s(1335)+s(1180)+s(381)]=!0,this[s(1309)+"er"]=ir,this[s(1310)]=nm,this[s(260)+"T"]=Cn,this._isMiniWX=ei,this[s(1104)+"r"]=ti,this[s(1265)+"Queue"]=[],this[s(530)+"tManager"]=null,this[s(1487)+s(1590)]=!1,this[s(580)+s(1139)]=e[s(540)],this[s(1512)+s(1283)]=!1,this[s(1512)+s(678)+s(441)]=null,this[s(249)+s(1218)+"tId"]=null,this["_pingPon"+s(544)+"Id"]=null,this[s(508)]=0,this._isInit=!1,this._url="",this[s(1380)+s(1493)]=null,this[s(604)+s(380)]=null,this[s(846)+"sCounter"]=null,this._protocols=e[s(1237)],this[s(365)]=3,this.CONNECTING=0,this[s(838)]=1,this.CLOSING=2,this._onOpen=E=>{let m=s;try{l.nbOVR(yl,this,E,[Bm,Fm,zm])}catch(T){if(l.ldIcL(l[m(1227)],l[m(1227)]))doXRmK[m(1220)](_0x1898ef),doXRmK[m(1220)](_0x3785c7);else{let L=l[m(1670)](lt,l[m(453)],{message:T[m(689)],code:an[m(966)+"OR"],error:T});this[m(1648)+m(1276)+m(1379)](L)}}},this[s(1448)+"ge"]=async E=>{let m=s,{pingInterval:T,pingFrequency:L}=this[m(407)];if((l[m(1316)]("hi",E[m(474)])&&m(531)===L||l.TCwZE(l[m(297)],L))&&(this[m(1367)+m(1005)](),this.emit(m(702)+m(621)+"s",m(234)),this[m(1294)+m(544)+"Id"]=l.LlWSz(setTimeout,this[m(847)].bind(this),T)),!l[m(1316)]("hi",E[m(474)]))try{l[m(455)](yl,this,E,[gm,pm,Nm,Mm,Lm,mm])}catch(j){let $=l[m(1670)](lt,"error",{message:j.message,code:an[m(221)+"ERROR"],error:j});this[m(1648)+m(1276)+m(1379)]($)}},this._onError=E=>{let m=s,T=this[m(530)+m(1238)]?.[m(594)+m(1595)+"es"](),L=this[m(530)+m(1238)]?.[m(573)+m(858)+"nt"]();if(T&&!E[m(689)]){let j=m(1705)+L+(m(1248)+"ax retries reached");this[m(1648)+"hErrorEv"+m(1379)](e[m(754)](lt,e[m(959)],{message:j,code:an[m(1650)+m(1211)+"R"],error:E}));return}this._ws&&e[m(1368)](this._ws.readyState,this[m(838)])&&this[m(663)+m(679)](),this[m(1648)+"hErrorEvent"](e[m(1350)](lt,e.dSUPz,{message:E.message,code:an[m(1435)+m(1657)],error:E}))},this._onClose=async E=>{let m=s;this["_clearTi"+m(1719)](),this[m(1367)+"ngTimer"](),this[m(313)+m(709)+"rs"](),this[m(1585)]=null,this[m(1512)+m(1283)]=!1;let T=this[m(530)+"tManager"]?.[m(594)+m(1595)+"es"]();if(!T&&this["_navigat"+m(665)]()&&!this[m(1487)+m(1590)]){let L=this[m(530)+m(1238)]?.[m(573)+"ntEndpoint"](),j=this[m(407)][m(276)+m(1048)+m(1202)](E[m(1018)],E.reason);this[m(1648)+m(1147)+m(1379)](l.LlWSz(_t,"close",{code:1006,reason:E[m(827)]||m(468)+"ng failed, unkno"+m(1399)+m(1278)+m(1280)+L,willReconnect:j})),j&&this[m(1512)]();return}if(l.wBOIq(1e3,E.code)&&this[m(1487)+m(1590)]){this["_dispatc"+m(1147)+"ent"](_t(l[m(651)],{code:1e3,reason:l[m(792)]})),this["_endpoin"+m(1238)]?.[m(448)+m(777)+m(288)](),this[m(846)+"sCounter"]?.[m(593)+m(1724)]();return}if(l[m(1031)](1e3,E[m(1018)])&&T){let L=this[m(530)+m(1238)]?.[m(573)+"ntEndpoint"](),j=E[m(827)];j||(j=await dm(this._url)),j=m(468)+m(1249)+m(1272)+j+(m(647)+"me: ")+L+(m(613)+m(1284)+m(401)),this[m(1648)+m(1147)+m(1379)](l[m(1494)](_t,"close",{code:E.code,reason:j}));let $=m(1705)+L+(" fail, m"+m(819)+m(1026)+"ed");this[m(1648)+m(1276)+m(1379)](l[m(1670)](lt,l[m(453)],{message:$,code:an["MAX_RETR"+m(1211)+"R"]})),this[m(530)+m(1238)]?.[m(448)+"pointCon"+m(288)](),this["_pingLos"+m(1201)]?.[m(593)+m(1724)]();return}if(E.code!==1e3&&!E.reason){let L=this._endpointManager?.[m(573)+m(858)+"nt"]();this["_dispatc"+m(1147)+m(1379)](l[m(1670)](_t,l[m(651)],{code:E[m(1018)],reason:m(468)+m(1249)+"d, unkno"+m(1399)+m(1278)+m(1280)+L})),this[m(530)+m(1238)]?.[m(448)+m(777)+"fig"](),this["_pingLos"+m(1201)]?.["resetCou"+m(1724)]();return}this["_dispatc"+m(1147)+"ent"](E),this["_endpoin"+m(1238)]?.[m(448)+m(777)+m(288)](),this[m(846)+m(1201)]?.["resetCou"+m(1724)]()},this[s(726)]=null,this[s(456)]=null,this[s(1661)+"e"]=null,this[s(1649)]=null,this[s(1663)+s(1314)]=null,this["onReceiv"+s(721)]=null,this[s(1150)+s(1187)+s(822)+"ct"]=null,this[s(406)+s(633)]=this[s(406)+s(633)][s(719)](this),this[s(406)+"ffLine"]=this["_handleO"+s(1692)][s(719)](this),this[s(1580)+s(1279)]=this["_handleP"+s(1279)][s(719)](this),this[s(1580)+"ageShow"]=this[s(1580)+s(961)][s(719)](this),this[s(407)]={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e[s(554)](1,0),service:0,logIDGenerator:o,headers:void 0,payloadEncoding:"",payloadType:"",fpID:"",deviceID:"",accessKey:"",ttwID:"",bddID:"",aID:"",disableAutoReconnect:!1,customParams:{},pingInterval:15e3,pingTimeoutInterval:4e3,pingFrequency:e[s(1550)],pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e[s(457)],env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:h,ws:p}=n,_=Array[s(501)](h)?h:e.qUzmf(s(1268),typeof h)?[h]:[];if(!_||e[s(696)](0,_.length))throw new Error(s(778)+"rovide v"+s(791));if(!sm(p))throw new Error(e.XVgxZ);Object[s(433)](this._options,n),this[s(530)+s(1238)]=new _l(_,this[s(407)][s(418)+"es"]),this[s(846)+s(1201)]=new cm(this[s(407)][s(989)+s(550)]),this._options[s(1173)+s(1049)]&&(this[s(1174)]=!0,this[s(1512)]()),this[s(407)][s(304)+s(1108)+"nged"]&&(this[s(260)+"T"]||this[s(1129)+"X"]?this[s(773)+s(539)+s(557)]():this[s(1309)+"er"]&&this["_initGlo"+s(907)+"Listener"]())}["_handleO"+t(633)](){let n=t;this[n(407)][n(1501)+n(1528)+"nect"]||this[n(1487)+n(1590)]||this[n(420)+n(1314)]()}["_handleO"+t(1692)](){let n=t;this["_destroy"+n(893)+"t"]();let s=va(e.uVSZb,{message:e[n(265)]});this[n(1150)+"mediatel"+n(822)+"ct"]&&this[n(1150)+"mediatel"+n(822)+"ct"](s)}[t(1701)+t(907)+"Listener"](){let n=t;e.uVvsf(e[n(294)],e.rVKgZ)?(this._isBrowser&&window.addEventListener(e[n(896)],this[n(406)+n(633)]),this[n(1309)+"er"]&&window[n(1731)+n(213)](n(659),this[n(406)+n(1692)]),this[n(1309)+"er"]&&window.addEventListener(e.kVPOd,this[n(1580)+"ageHide"]),this[n(1309)+"er"]&&window[n(1731)+n(213)](n(742),this[n(1580)+n(961)])):(_0x8ac3d0=e[n(1639)](_0x2a061d,_0x58e43f),_0x23349b|=e[n(481)](127&_0x442aa7,14),e[n(496)](128,_0xb0f516)&&(_0x3ead51=e[n(1197)](_0x18ce1b,_0x396df6),_0x1e752a|=e[n(1720)](e[n(338)](127,_0x510083),21),e[n(1313)](128,_0x48a70c)&&(_0x4d8d1e=e[n(1417)](_0x532e38,_0x44fd19),_0xc7590c=e[n(1594)](127,_0x30a512),e[n(1287)](128,_0x37ea35)&&(_0x5aa9a7=e[n(1370)](_0x1f67c0,_0x4d5415),_0x567d9f|=e.uhAGH(127&_0x1cd996,7)))))}["_dropGlo"+t(907)+"Listener"](){let n=t;this._isBrowser&&window[n(1056)+n(520)+"ner"](e[n(896)],this[n(406)+n(633)]),this[n(1309)+"er"]&&window["removeEv"+n(520)+n(1361)](e.vFXyy,this[n(406)+n(1692)]),this[n(1309)+"er"]&&window[n(1056)+n(520)+n(1361)](n(274),this[n(1580)+n(1279)]),this[n(1309)+"er"]&&window[n(1056)+"entListener"](e[n(1398)],this._handlePageShow)}[t(1580)+t(1279)](n){let s=t;if(e[s(844)](e[s(495)],e[s(1421)]))!n[s(1325)+"d"]&&(this[s(1309)+"er"]&&window["removeEv"+s(520)+s(1361)](e[s(1571)],this[s(1580)+s(1279)]),this[s(1309)+"er"]&&window["removeEv"+s(520)+s(1361)]("pageshow",this._handlePageShow),this.close()),this._isBrowser&&window[s(1056)+s(520)+s(1361)](s(963),this[s(406)+s(633)]),this[s(1309)+"er"]&&window[s(1056)+s(520)+s(1361)](e[s(511)],this["_handleO"+s(1692)]);else return null}[t(1580)+t(961)](n){let s=t;n[s(1325)+"d"]&&(this[s(1521)+s(665)]()&&(!this[s(1585)]||e[s(1190)](this._ws.readyState,this[s(838)])||e[s(1235)](this[s(1585)][s(421)+"te"],this[s(1362)+"NG"]))&&this["_handleO"+s(633)](),this._isBrowser&&window[s(1731)+s(213)](e.bwCgD,this[s(406)+s(633)]),this[s(1309)+"er"]&&window[s(1731)+"Listener"](e.vFXyy,this[s(406)+s(1692)]))}async["_generat"+t(804)](n){let s=t,{fpID:l,deviceID:h,bddID:p,ttwID:_,accessKey:E,aID:m,customParams:T={},enableAutoAck:L,enableQoS:j,QoSLevel:$,env:Y}=this[s(407)],_e,et,Tt;this[s(1309)+"er"]||this._isMiniWX||this[s(260)+"T"]?(_e=location&&e.WqZKR(e[s(334)],location[s(929)])?e[s(1606)]:"ws://",et=n[s(310)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),Tt=/^wss(.*:\/\/)/.test(n)?n:""+_e+et):(_e="wss://",et=n[s(310)](/(^http)((?:[s]*:\/\/))/,""),Tt=/(^ws)((?:[s]*:\/\/))/.test(et)?et:""+_e+et);let hs=p?e[s(668)]:_?e[s(687)]:s(437)+"d",xs=p||_||h;if(!xs||!hs)throw new Error(s(778)+s(1131)+s(1374)+s(1302)+s(1699));let Tl=e.fZNOp(e[s(1239)],typeof T)?await e[s(666)](T):T,Gm=Y?e.QbNAp(am,Y[s(1329)],Y[s(250)]):{},Pa=Object[s(433)]({device_platform:e[s(1169)],version_code:e[s(1455)],access_key:E,fpid:l,aid:m,[hs]:xs,xsack:L?1:0,xaack:L?1:0,xsqos:j?1:0,qos_level:j?$:void 0,qos_sdk_version:2,...Gm},Tl),Hm=Object[s(691)](Pa).reduce((Da,Oa)=>Pa[Oa]!==void 0?""+Da+(Da?"&":"?")+Oa+"="+Pa[Oa]:Da,"");return Tt+s(1564)+Hm}async[t(1512)](){let n=t;if(!(this[n(1512)+n(1283)]||this[n(1487)+"osed"])){this[n(1512)+n(1283)]=!0;try{let s=this[n(530)+n(1238)]?.[n(322)+n(798)+n(956)+n(688)+n(855)](),{timeoutInterval:l}=this._options;if(s){let p=this[n(530)+n(1238)]?.[n(573)+"ntEndpoint"](),_=this["_endpoin"+n(1238)]?.[n(903)+n(1428)+n(392)+n(1230)+n(866)](),E=this[n(530)+"tManager"]?.[n(573)+"ntEndpoi"+n(811)+n(354)]();if(_){let m=n(1705)+p+(n(649)+n(613)+n(1284)+"ached, will use "+n(206)+"ndpoint ")+_+(n(1734)+"y"),T=e[n(415)](lt,e[n(959)],{message:m,code:an[n(1650)+"IES_ERROR"]});this._debug(m),this[n(1648)+n(1276)+n(1379)](T),this[n(1553)]=await this[n(930)+"eUrl"](_),this._debug(n(1705)+_+" "+E+n(1660)),this[n(313)+n(709)+"rs"]()}else{let m=n(1705)+p+(n(649)+n(613)+"tries re"+n(401));this[n(952)](m),this[n(1648)+n(1276)+n(1379)](e[n(1411)](lt,n(905),{message:m,code:an[n(1650)+n(1211)+"R"]}));return}}else{let p=this[n(530)+n(1238)]?.[n(573)+n(858)+n(405)+"ateCount"](),_=this["_endpoin"+n(1238)]?.[n(573)+n(858)+n(811)+n(354)]();this._url=await this["_generat"+n(804)](p||""),this._debug(n(1705)+p+" "+_+n(1660)),this["_removeW"+n(709)+"rs"]()}if(this._isInit)this[n(1174)]=!1;else{let p=e.CzENa(va,n(276)+"t",{message:n(350)});this["onStartR"+n(1314)]&&this[n(1663)+"econnect"](p)}let h=this["_endpoin"+n(1238)]?.[n(573)+n(858)+n(811)+"ount"]()||0;e.FyGwq(h,1)&&await this._wait(e.ssqmw(h,1)),this._debug(n(468)+n(994)+this[n(1553)]+(" protoco"+n(895))+this[n(1223)+"ls"]),this[n(1585)]=e[n(1554)](im,{url:this[n(1553)],protocols:[this[n(1223)+"ls"]],headers:this[n(407)][n(881)+n(1118)+"s"][n(730)+"tpHeader"]},this[n(407)].ws),(this[n(1309)+"er"]||this[n(1104)+"r"])&&this[n(1585)]&&(this[n(1585)][n(1245)+"pe"]=this[n(580)+n(1139)]),this[n(902)+n(445)](),this[n(1512)+"ionTimeoutId"]=e[n(608)](setTimeout,this[n(503)+"ut"].bind(this),l)}catch(s){throw this["_connect"+n(1283)]=!1,s}}}[t(638)+t(1719)](){let n=t;e.dBMHT(clearTimeout,this["_connect"+n(678)+"utId"]),this[n(1512)+n(678)+n(441)]=null}[t(1367)+"ngTimer"](){let n=t;e[n(275)](clearTimeout,this[n(1294)+n(544)+"Id"]),e.LMtdP(clearTimeout,this[n(249)+"ctTimeoutId"]),this[n(1294)+n(544)+"Id"]=null,this["_reconne"+n(1218)+"tId"]=null}[t(952)](...n){let s=t;this[s(407)][s(370)]&&console.log.apply(console,[e.ZTHKP,...n])}[t(514)+t(1255)+"e"](n){let s=t,{initReconnectInterval:l,maxReconnectInterval:h,reconnectIntervalGrowFactor:p}=this[s(407)],_=e[s(256)](l,Math.pow(p,n-1));return _>h?h:_}[t(847)](){let n=t;if(this._ws&&e[n(1127)](this[n(1585)].readyState,this[n(1362)+"NG"]))if(e.KnLON(e.mymsn,n(1041)))try{this[n(1340)]?.close(),this[n(1340)]=void 0}catch(s){_0x44c944.log(s)}else{this[n(1367)+"ngTimer"](),this[n(1294)+"gTimeoutId"]=e.FKgoS(setTimeout,this[n(847)][n(719)](this),this._options["pingInte"+n(486)]);return}if(!this[n(1585)]||e[n(378)](this[n(1585)].readyState,this[n(838)]))return void this[n(420)+"econnect"]();this._ws&&this[n(1585)][n(238)]("hi"),this[n(249)+"ctTimeou"+n(1677)]=e[n(408)](setTimeout,this[n(420)+n(1314)+n(1163)][n(719)](this),this[n(407)].pingTimeoutInterval)}[t(420)+t(1314)+t(1163)](){let n=t;this[n(846)+"sCounter"]?.[n(383)](),this.emit(e.WWIMf,n(826)),this[n(846)+n(1201)]?.[n(594)+"chMaxCount"]()?this["_handleR"+n(1314)]():this._ping()}_navigatorOnline(){let n=t;return this[n(260)+"T"]||this[n(1129)+"X"]?this[n(1335)+n(1180)+n(381)]:(this[n(1309)+"er"]||this._isWorker)&&this._options[n(304)+"tworkCha"+n(1349)]?navigator[n(1645)]:!0}_handleReconnect(){let n=t;!this[n(1521)+n(665)]()||this[n(1487)+n(1590)]||(this["_endpoin"+n(1238)]?.[n(448)+n(777)+"fig"](),this[n(846)+n(1201)]?.[n(593)+"nter"](),this._ws?this[n(663)+n(679)](1001,e[n(419)],!0):this[n(1512)]())}[t(773)+t(539)+t(557)](){let n=t;e[n(617)]!=="LkrHu"?this._isMiniTT?tt[n(568)+n(1319)+n(599)](({isConnected:s})=>{let l=n;this[l(1335)+l(1180)+l(381)]=s,s?this["_handleO"+l(633)]():this["_handleO"+l(1692)]()}):this[n(1129)+"X"]&&wx[n(568)+"kStatusC"+n(599)](({isConnected:s})=>{let l=n;this["_miniNav"+l(1180)+l(381)]=s,s?this[l(406)+l(633)]():this[l(406)+l(1692)]()}):this[n(606)+n(446)]()}_wait(n){return new Promise(s=>{let l=F;e[l(532)](setTimeout,s,this[l(514)+"rvalValue"](n))})}[t(663)+t(679)](n=1e3,s="",l=!1){let h=t;this[h(1585)]&&this[h(1121)+h(893)+"t"](n,s,l)}_onTimeout(){let n=t,s=this[n(530)+n(1238)]?.[n(573)+n(858)+"nt"]();this[n(952)](n(1705)+s+n(649)),this[n(663)+n(679)](1001,n(1033)+" try rec"+n(341)+"g",!0)}[t(390)](n){let s=t,l=e.FoGzE(Gt,n);this[s(1585)]&&this._ws.readyState===this.OPEN&&(this[s(1585)]&&this[s(1585)].send(l),this._debug(e[s(308)],n))}[t(313)+t(709)+"rs"](){let n=t,s={QPGNQ:e[n(998)],mEGAA:function(l,h,p){return e[n(436)](l,h,p)}};if(e[n(1364)](e.DvHBa,e[n(698)])){if(!this[n(1585)])return;this[n(1585)].removeEventListener(n(1307),this._onOpen),this[n(1585)][n(1056)+"entListener"](n(326),this[n(782)]),this[n(1585)]["removeEv"+n(520)+n(1361)](e[n(1468)],this[n(1448)+"ge"]),this[n(1585)]["removeEventListe"+n(1361)](e[n(959)],this[n(516)])}else this[n(1391)](nyRFgu[n(375)],nyRFgu[n(336)](_0x1ac20b,nyRFgu[n(375)],{..._0x314be0}))}_addWsListeners(){let n=t,s=e[n(1423)][n(302)]("|"),l=0;for(;;){switch(s[l++]){case"0":this[n(1585)][n(1731)+n(213)](e[n(959)],this[n(516)]);continue;case"1":if(!this._ws)return;continue;case"2":this[n(1585)][n(1731)+n(213)](n(326),this._onClose);continue;case"3":this._ws[n(1731)+n(213)](e[n(236)],this._onOpen);continue;case"4":this[n(1585)][n(1731)+n(213)](e[n(1468)],this[n(1448)+"ge"]);continue}break}}["_wsInsta"+t(1057)](n=1e3,s=""){let l=t,h={dEukx:function(p,_){return e.bDgFw(p,_)},BsitV:function(p,_){return p|_},tBAFd:function(p,_){return e[F(1406)](p,_)},Ndqqr:function(p,_){return p<<_},GODWo:function(p,_){return e.qGnod(p,_)},qKbWr:function(p,_){return e[F(490)](p,_)},gAWWM:function(p,_){return e[F(510)](p,_)},ehXNE:function(p,_){return e[F(307)](p,_)},BaxkG:function(p,_){return p<_},AMPUF:function(p,_){return p<_},oMyuF:function(p,_){return e[F(1607)](p,_)},ApuuW:function(p,_,E){return e[F(1212)](p,_,E)},fDxbV:function(p,_){return p+_},CSzIJ:function(p,_){return e[F(1271)](p,_)},HCUZa:function(p,_){return e[F(1229)](p,_)},BsZjX:function(p,_){return e.xWBIO(p,_)},RyLMJ:function(p,_){return e[F(1007)](p,_)},vabop:function(p,_){return e[F(1714)](p,_)},TCHjj:function(p,_){return e[F(745)](p,_)},kDLfd:function(p,_){return e[F(1152)](p,_)},VmGjq:function(p,_){return e[F(1116)](p,_)},ejyvQ:function(p,_){return e[F(1406)](p,_)},vgTKi:function(p,_){return p+_},UcEOh:function(p,_){return e[F(1063)](p,_)},TClKW:function(p,_){return e[F(1449)](p,_)},XSwAk:function(p,_){return p|_},SiXEd:function(p,_){return e[F(1317)](p,_)},QZFGk:function(p,_){return p!==_},mXNqe:function(p,_){return e[F(1418)](p,_)},MduZa:function(p,_){return p>>>_},ZJdXI:function(p,_){return e[F(299)](p,_)},qqljC:function(p,_){return p!==_},PNsyI:function(p,_){return p!==_},aVniS:function(p,_){return e[F(911)](p,_)}};if(e[l(727)]!=="ujBka")try{this[l(1585)]&&this._ws[l(326)](n,s)}catch{}else{let p=yjLYYT[l(1718)](_0x34c944.low,0),_=yjLYYT[l(906)](yjLYYT[l(1458)](_0x5218cd[l(1372)],28),yjLYYT[l(331)](_0xc28fa1[l(836)],4))>>>0,E=yjLYYT[l(1075)](_0x21b0b0[l(836)],24),m=yjLYYT[l(816)](0,E)?yjLYYT[l(360)](0,_)?p<16384?yjLYYT[l(883)](p,128)?1:2:yjLYYT[l(534)](p,2097152)?3:4:yjLYYT[l(1078)](_,16384)?yjLYYT[l(223)](_,128)?5:6:yjLYYT.AMPUF(_,2097152)?7:8:E<128?9:10,T=yjLYYT.ApuuW(_0x127e7f,_0x38eba7,m),L=_0x70be96[l(214)];switch(m){case 10:L[yjLYYT[l(927)](T,9)]=yjLYYT.CSzIJ(yjLYYT[l(1718)](E,7),1);case 9:L[yjLYYT[l(927)](T,8)]=yjLYYT.HCUZa(9,m)?yjLYYT[l(906)](128,E):yjLYYT[l(764)](127,E);case 8:L[yjLYYT.fDxbV(T,7)]=yjLYYT[l(403)](8,m)?yjLYYT[l(1456)](yjLYYT[l(1718)](_,21),128):yjLYYT[l(1480)](yjLYYT[l(1586)](_,21),127);case 7:L[yjLYYT.VmGjq(T,6)]=m!==7?yjLYYT.vabop(_>>>14,128):yjLYYT[l(723)](_,14)&127;case 6:L[yjLYYT[l(1038)](T,5)]=m!==6?_>>>7|128:yjLYYT[l(880)](_,7)&127;case 5:L[T+4]=yjLYYT[l(681)](5,m)?yjLYYT[l(1541)](128,_):yjLYYT[l(764)](127,_);case 4:L[yjLYYT.vgTKi(T,3)]=m!==4?yjLYYT[l(1541)](yjLYYT[l(880)](p,21),128):yjLYYT[l(1444)](yjLYYT[l(1075)](p,21),127);case 3:L[yjLYYT[l(1563)](T,2)]=yjLYYT.QZFGk(3,m)?yjLYYT[l(862)](yjLYYT.MduZa(p,14),128):yjLYYT.ZJdXI(yjLYYT.GODWo(p,14),127);case 2:L[yjLYYT.VmGjq(T,1)]=yjLYYT.qqljC(2,m)?yjLYYT[l(1586)](p,7)|128:yjLYYT[l(1444)](p>>>7,127);case 1:L[T]=yjLYYT[l(498)](1,m)?yjLYYT.aVniS(128,p):yjLYYT.BsZjX(127,p)}}}[t(1121)+t(893)+"t"](n=1e3,s="",l=!1){let h=t,p={lyptV:function(_,E){return e[F(1401)](_,E)},faUrH:function(_,E){return e[F(1332)](_,E)}};if(this[h(1367)+"ngTimer"](),this[h(638)+h(1719)](),this[h(313)+h(709)+"rs"](),this[h(839)+"nceClose"](1e3,s),this._connectLock=!1,l&&this[h(1521)+"orOnline"]()&&!this[h(1487)+"osed"])if(e[h(1274)](e[h(1408)],e[h(1469)])){let _=0,E=_0x3c7fe1,m=_0x532def+4;for(;ortRfs.lyptV(E,m);){let{value:T,offset:L}=_0x5b2405(_0x1a6197,E);E=L,_=ortRfs[h(1094)](_<<8,0),_+=T}return{value:_,offset:m}}else{if(this._endpointManager?.["checkRea"+h(1595)+"es"]()){let E=this[h(530)+h(1238)]?.getCurrentEndpoint();this["_dispatc"+h(1147)+"ent"](e[h(1058)](_t,e[h(998)],{code:1006,reason:h(1705)+E+(h(649)+h(613)+h(1284)+h(401)),wasClean:!0}))}else if(e.mLjgP!=="olcfk"){let E=this._options[h(276)+h(1048)+h(1202)](n,s);this[h(1648)+h(1147)+"ent"](e[h(842)](_t,e[h(998)],{code:n,reason:s,wasClean:!0,willReconnect:E})),E&&this._connect()}else this[h(1174)]=!0,this._connect();return}this[h(1521)+h(665)]()||this[h(1487)+h(1590)]?this[h(1648)+h(1147)+h(1379)](e[h(1217)](_t,h(326),{code:n,reason:e[h(1481)]})):this[h(1648)+"hCloseEv"+h(1379)](e[h(211)](_t,h(326),{code:1006,reason:e[h(397)]})),this[h(1585)]=null,this._endpointManager?.[h(448)+"pointCon"+h(288)](),this[h(846)+"sCounter"]?.[h(593)+h(1724)]()}["_dispatc"+t(1474)+"nt"](n){let s=t;this[s(1391)](e[s(236)],n),this[s(1649)]&&this[s(1649)](n)}[t(1648)+t(293)+t(512)](n){let s=t;this[s(1391)](e[s(1468)],n),this.onmessage&&this[s(1661)+"e"](n)}[t(1648)+t(643)+t(1045)](n){let s=t;this[s(1391)](s(1611),n),this[s(799)+s(721)]&&this[s(799)+s(721)](n)}[t(1648)+t(1276)+t(1379)](n){let s=t;this.emit(e[s(959)],n),this[s(456)]&&this[s(456)](n)}[t(1648)+t(1147)+t(1379)](n){let s=t;this.emit(e[s(998)],n),this[s(726)]&&this.onclose(n)}get[t(1245)+"pe"](){let n=t;return this._ws?this._ws[n(1245)+"pe"]:this[n(580)+n(1139)]}set[t(1245)+"pe"](n){let s=t;this[s(580)+s(1139)]=n,this[s(1585)]&&(this._ws[s(1245)+"pe"]=n)}get[t(737)+"nt"](){let n=t;return this["_endpoin"+n(1238)]?.[n(573)+n(858)+n(811)+n(354)]()||0}get bufferedAmount(){let n=t,s=this._messageQueue.reduce((l,h)=>(l+=h&&h[F(882)+"th"]||0,l),0);return e[n(877)](s,this[n(1585)]?this[n(1585)][n(1479)+"Amount"]:0)}get[t(327)+"ns"](){let n=t;return this[n(1585)]?this[n(1585)][n(327)+"ns"]:""}get[t(929)](){let n=t;return this[n(1585)]?this[n(1585)][n(929)]:""}get[t(421)+"te"](){let n=t;return this[n(1585)]?this[n(1585)].readyState:this[n(407)][n(1173)+n(1049)]?this[n(1362)+"NG"]:this.CLOSED}get[t(431)](){let n=t;return this[n(1585)]?this._ws[n(431)]:this._url}[t(326)](n=1e3,s){let l=t,h=e[l(868)][l(302)]("|"),p=0;for(;;){switch(h[p++]){case"0":this[l(680)+"balEvent"+l(213)]();continue;case"1":this["_destroy"+l(893)+"t"](n,s);continue;case"2":this[l(1367)+l(1005)]();continue;case"3":this[l(1487)+l(1590)]=!0;continue;case"4":if(e.BxMVT(this[l(1585)][l(421)+"te"],this[l(365)])||e.TBYLQ(this[l(1585)].readyState,this.CLOSING))return void this._debug("close, ws alread"+l(208));continue;case"5":this._QoSManager?.closeDB();continue;case"6":this["_clearTi"+l(1719)]();continue;case"7":if(!this[l(1585)])return void this[l(952)](e[l(586)]);continue}break}}async[t(238)](n,s){let l=t,h={eiKGv:function(Tt,hs,xs){return e[F(699)](Tt,hs,xs)}};if(e[l(1593)](null,n))throw new Error(e.SPRQw);e.phMTX==typeof n&&(n=JSON[l(1138)+"y"](n)),e[l(1520)](e[l(558)],typeof n)&&!e[l(320)](n,ArrayBuffer)&&!(n.buffer&&e[l(1592)](n.buffer,ArrayBuffer))&&(n=JSON[l(1138)+"y"](n));let p=await e.xyGuy(vl,n),_=e[l(1417)](om,n),{method:E=0,service:m=this[l(407)][l(1305)],logID:T=this[l(407)]["logIDGen"+l(325)](),headers:L=this[l(407)][l(1513)],payloadEncoding:j=this[l(407)][l(1676)+l(960)],payloadType:$=this[l(407)][l(942)+l(1139)],logIDNew:Y=this[l(407)].logIDNewConfig[l(1001)+l(1072)+l(925)+"ew"]?e[l(1575)](i,this[l(407)][l(1466)+l(660)][l(1016)]):""}=e[l(218)](s,{});if(!m)throw new Error("please p"+l(749)+l(528)+l(1414));let _e={SeqID:he.fromNumber(this[l(508)]++),LogID:he[l(1378)+"er"](T),service:m,method:E,headers:L,payloadEncoding:e[l(1300)](j,Object)?j.encoding?j[l(278)]:"":j,payloadType:e.UHUhm($,Object)?$[l(747)]?$[l(747)]:_:$||_,payload:p,LogIDNew:Y},et=e[l(1124)](Gt,_e);return this[l(1585)]&&e[l(292)](this[l(1585)][l(421)+"te"],this.OPEN)?(this[l(1585)]&&this._ws[l(238)](et),this._debug(e[l(1137)],_e)):this["_message"+l(1420)][l(693)]<this[l(407)]["maxMessa"+l(305)+l(335)]?(this["_message"+l(1420)][l(1419)](et),this[l(952)](e[l(714)],_e)):e[l(561)](e[l(964)],l(1053))?(this[l(1265)+l(1420)].shift(),this[l(1265)+"Queue"][l(1419)](et)):(_0x3f7365(_0x21d689,18),KMkKjr[l(1539)](_0x4904fb,_0x20ecfc,_0xe25876)),{seqID:this[l(508)],logID:T,logIDNew:Y}}async[t(276)+"t"](n){let s=t,{url:l}=e[s(1403)](n,{}),h=Array[s(501)](l)?l:e[s(558)]==typeof l?[l]:[];n&&Object[s(433)](this._options,n),h&&h[s(693)]?this[s(530)+s(1238)]=new _l(h,this[s(407)][s(418)+"es"]):this[s(530)+"tManager"]?.[s(448)+"pointCon"+s(288)](),this[s(846)+"sCounter"]?.[s(593)+s(1724)](this._options[s(989)+s(550)]),this[s(1487)+s(1590)]=!1,this[s(1585)]&&e[s(1562)](this._ws.readyState,this[s(365)])?this[s(663)+s(679)](1e3,e.lKENd,!0):(this._isInit=!0,this._connect())}async[t(807)](){let n=t;if(!this[n(1512)+n(1283)]){if(e.tKQuY(e[n(1582)],"iDIPe"))return"frontier_"+this[n(1303)];this[n(530)+n(1238)]?.["resetEndpointCon"+n(288)](),this["_pingLos"+n(1201)]?.[n(593)+n(1724)](),this[n(1487)+n(1590)]=!1,this._isInit=!0,this._connect()}}[t(1731)+t(213)](n,s){this.on(n,s)}[t(1246)+"Event"](n){let{type:s}=n;this.emit(s,n)}["removeEventListe"+t(1361)](n,s){this[t(673)](n,s)}[t(374)](){let n=t,s={fdIMJ:e[n(449)],ndrhM:e.WWIMf,ZKQZy:function(l,h){return l(h)},hCGzR:e[n(840)],jqpKW:function(l,h,p){return e[n(369)](l,h,p)}};return new Promise((l,h)=>{let p=n;this[p(1367)+"ngTimer"](),this[p(1294)+p(544)+"Id"]=s[p(615)](setTimeout,this._ping.bind(this),this._options[p(1635)+p(486)]);let _=()=>{let m=p;l(m(234)),this[m(673)](s.fdIMJ,_),this[m(673)](s[m(770)],E)},E=()=>{let m=p;s[m(519)](h,s[m(1381)]),this[m(673)](s[m(639)],_),this[m(673)](s.ndrhM,E)};this.on(s[p(639)],_),this.on(s.ndrhM,E),this[p(847)]()})}}})(),Be[N(1321)+N(1115)]=Pe[N(1321)+N(1115)],Be[N(1205)+N(518)]=Pe[N(1205)+N(518)],Be[N(536)+"e"]=Pe[N(536)+"e"],Be[N(512)]=Pe.Event,Be[N(1652)]=Pe[N(1652)],Be[N(598)+N(1320)+"vent"]=Pe["FrontierMessageE"+N(426)],Be.MessageEvent=Pe["MessageE"+N(426)],Be[N(1472)+"t"]=Pe.OpenEvent,Be[N(1214)+N(576)]=Pe["Reconnec"+N(576)],Be[N(1555)+N(1115)]=Pe[N(1555)+N(1115)],Be.createErrorEvent=Pe[N(290)+N(518)],Be[N(1047)+N(545)+"nt"]=Pe[N(1047)+N(545)+"nt"],Be[N(830)+N(1052)]=Pe[N(830)+N(1052)],Be[N(367)+N(1625)+N(426)]=Pe[N(367)+N(1625)+N(426)],Be["decodedF"+N(828)]=Pe[N(427)+N(828)],Be[N(635)+"ame"]=Pe[N(635)+N(920)];for(ea in Pe)[N(1321)+"oseEvent",N(1205)+N(518),N(536)+"e",N(512),N(1652),N(598)+N(1320)+N(426),"MessageE"+N(426),"OpenEvent",N(1214)+N(576),N(1555)+N(1115),N(290)+"rorEvent",N(1047)+N(545)+"nt","createOp"+N(1052),N(367)+N(1625)+N(426),N(427)+"rame",N(635)+N(920)][N(1672)](ea)===-1&&(Be[ea]=Pe[ea]);var ea;Object[N(1098)+N(1385)](Be,"__esModule",{value:!0})});import{existsSync as QS,openSync as e1}from"node:fs";import{mkdir as t1}from"node:fs/promises";import{dirname as n1}from"node:path";import{fileURLToPath as r1}from"node:url";function s1(t,e){return e==="legacy"?t.logFile:t.daemonStdioLog}function Zd(t=J()){return QS(t.libEntry)?t.libEntry:r1(new URL("../index.ts",import.meta.url))}async function hp(t={}){let e=t.paths??J(),r=t.entryOverride??Zd(e),i=s1(e,process.env.COZE_BRIDGE_LOG_MODE);await t1(n1(i),{recursive:!0});let o=e1(i,"a"),d=r.endsWith(".ts")?["--import","tsx/esm",r,"--daemon"]:[r,"--daemon"],u=st(process.execPath,d,{detached:!0,stdio:["ignore",o,o],env:{...process.env,[cs]:"1"}});if(u.unref(),typeof u.pid!="number")throw new Error("failed to spawn daemon (no pid)");return i1.info("daemon spawned",{pid:u.pid,entry:r}),{pid:u.pid,entry:r}}var i1,cs,ua=nt(()=>{"use strict";Zt();te();Re();i1=G("spawn-daemon"),cs="COZE_BRIDGE_DAEMON"});import{spawn as n2}from"node:child_process";import{mkdir as r2,unlink as i2,writeFile as s2}from"node:fs/promises";import{dirname as o2,join as a2}from"node:path";function Zr(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function c2(t){if(!t)return"";let e=Object.entries(t).map(([r,i])=>` <key>${Zr(r)}</key>
|
|
21
|
-
<string>${
|
|
20
|
+
`+n)}function er(t,e,n,i,o,c){if(t.listenerCount("wsClientError")){let d=new Error(o);Error.captureStackTrace(d,er),t.emit("wsClientError",d,n,e)}else ss(n,i,o,c)}});var ep=ce(Fe=>{"use strict";var N=V;(function(t,e){let n=V,i=t();for(;;)try{if(-parseInt(n(1253))/1+-parseInt(n(1332))/2*(parseInt(n(1683))/3)+parseInt(n(1246))/4+-parseInt(n(1392))/5+-parseInt(n(1880))/6+parseInt(n(512))/7*(-parseInt(n(1952))/8)+-parseInt(n(1942))/9*(-parseInt(n(1317))/10)===e)break;i.push(i.shift())}catch{i.push(i.shift())}})(na,205674);var yS=Object[N(811)+N(1362)],ES=Object[N(617)+N(1199)+N(1546)],Jx=(t,e)=>function(){return t&&(e=(0,t[{IMhlx:function(c,d){return c(d)}}[N(1498)](ES,t)[0]])(t=0)),e},bS=(t,e)=>{for(var n in e)yS(t,n,{get:e[n],enumerable:!0})};function vS(){return jx||(jx=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function SS(){let t=N;return Wx||(Wx=[IDBCursor.prototype[t(1509)],IDBCursor.prototype[t(1064)],IDBCursor.prototype[t(1064)+t(1723)+"ey"]])}function IS(t){let e=N,n={IACxN:e(917),PLTKG:e(962),mmaEr:function(o,c){return o(c)},sAeHn:function(o){return o()},WBTGc:function(o,c){return o===c},tXXbL:e(937),OrQmk:function(o,c){return o instanceof c}},i=new Promise((o,c)=>{let d=e,u={xZvmk:n.IACxN,bSDWF:n[d(850)],VaKil:function(f,x){return n[d(1009)](f,x)},wjDPG:function(f,x){return n[d(1009)](f,x)},QJICX:function(f){return n[d(1903)](f)},iwzmw:"xYTQJ",BkipJ:d(1420),NnARm:function(f,x){return f(x)}};if(n.WBTGc(n[d(507)],n[d(507)])){let f=()=>{let _=d;t["removeEventListe"+_(1365)](u[_(1221)],x),t[_(860)+_(1904)+_(1365)](u[_(1649)],m)},x=()=>{let _=d;u[_(1622)](o,u[_(1198)](zt,t[_(776)])),u[_(1324)](f)},m=()=>{let _=d;if(u[_(865)]===u.BkipJ)return this._qosDB[_(1197)];u[_(1806)](c,t[_(962)]),f()};t[d(1608)+"Listener"](d(917),x),t[d(1608)+d(1261)](d(962),m)}else _0x9684c8&&this[d(1195)+d(1505)][d(1694)+d(812)+d(1805)](_0x546020)});return i[e(729)](o=>{n.OrQmk(o,IDBCursor)&&jd.set(o,t)}).catch(()=>{}),ia[e(940)](i,t),i}function AS(t){let e=N,n={LPKBu:function(o){return o()},hIjrA:e(517),eFXHw:e(962),laJnB:function(o,c){return o(c)},QHiUv:e(861)+"or",sIWne:"success",jDOTT:function(o){return o()},rSefz:function(o,c){return o===c},EcSpC:e(690),gRNQj:e(1743)};if(ra.has(t))return;let i=new Promise((o,c)=>{let d=e,u={dPBZw:n[d(547)],xKhxJ:n[d(1168)],NNMFd:function(f,x){return n[d(741)](f,x)},OaHct:n[d(540)],iHmPC:function(f){return n.LPKBu(f)},nhmdK:n.sIWne,TcbBT:function(f,x){return n[d(741)](f,x)},xvaGG:function(f){return n[d(1821)](f)}};if(n[d(1667)](d(690),n.EcSpC)){let f=()=>{let _=d;t[_(860)+_(1904)+_(1365)](u.dPBZw,x),t[_(860)+_(1904)+"ner"](u.xKhxJ,m),t[_(860)+_(1904)+_(1365)](_(1743),m)},x=()=>{let _=d;n.LPKBu(o),n[_(1092)](f)},m=()=>{let _=d;u[_(1504)](c,t[_(962)]||new DOMException(u[_(824)],_(861)+"or")),u[_(648)](f)};t[d(1608)+d(1261)]("complete",x),t[d(1608)+d(1261)](n[d(1168)],m),t[d(1608)+d(1261)](n[d(1620)],m)}else{let f={uQcGK:qEGzzE.nhmdK,NTtoi:function(v,y){let b=d;return qEGzzE[b(710)](v,y)},stOTR:function(v){return qEGzzE.xvaGG(v)},LEiga:function(v,y){let b=d;return qEGzzE[b(710)](v,y)}},x=()=>{let v=d;_0x25e516[v(860)+v(1904)+v(1365)](f[v(1082)],m),_0xb402cd["removeEv"+v(1904)+"ner"](v(962),_)},m=()=>{let v=d;f[v(1911)](_0x113f01,f[v(1911)](_0x3d06ce,_0x2f4a10[v(776)])),f.stOTR(x)},_=()=>{let v=d;f[v(1697)](_0x2ee973,_0x5f3019[v(962)]),f.stOTR(x)};_0x5d025f[d(1608)+d(1261)](qEGzzE[d(1236)],m),_0x3017e5[d(1608)+"Listener"](qEGzzE[d(1519)],_)}});ra[e(940)](t,i)}function kS(t){sa={vPXts:function(i,o){return i(o)}}[N(759)](t,sa)}function na(){let t=["yNL0zxm","zgvSzxrL","EsbJBg9Zzwq","z2v0","ELbQv0G","u0Piveu","s1jXshC","wg1dqw8","Dg9cExrLC0i","B25SAw5L","CujhzLK","AfH0thy","qMjlt0y","ywrKq291BNq","zxjYtxnN","sKTdtg0","uuTdwu0","ywjVCNq","u2X2rKu","uLLkuu8","ChPJA2i","x2fKzfDZtgK","igzHAwWSig0","AMLzsxG","DejKzxC","nxW2Fdf8mhW","BMnLq2XVC2u","A1rzuLu","sKTpvKO","vKXgAfK","Avb6zeu","qMDdD3u","A1n0yxr1C0m","aaaaaaaaaaa","y3zpvMi","mdaWma","uev5vK4","BM9Uzv9UB24","zsbHihn0CMK","C2vUDa","y29UBMvJDgK","uef2Cui","C2LJruy","z2v0qwXS","wvftr1G","ExbL","C3rVCcbPBw0","x2LUAxrhBg8","vMjUBKy","BMfTzq","qxr3AgK","qMzvEfy","DMvY","AM9PBG","C2fNzq","sxzIzLa","BwXSA3q","B3jLtMfTzxm","yKnlAMC","DhLWzq","Dg9tDhjPBMC","CMvZzxrfBMq","Dw50","y3jLyxrLrwW","B2HOthi","rwDVDuO","o2nOyxjZzxq","CMzKv20","Aw9Ul2PZB24","txbYuMu","yMfSu2nVCgu","mNWX","Aw50zwDLCIa","zNDZxZeUmc4","rMPoAxm","uMvvvNG","DMfSDwvZ","u25du1e","yw1LoIa","tMfTzq","tM5buM0","ChvZAa","rLbqwfy","zw5fDMvUDa","zcWG","z29PBMCGyxC","C0Xf","BMvJDa","z0L2y00","Dw5RBM93BIa","Aw5JBhvKzxm","x3nVy2TLDa","rxzLBNq","Bg9Zq3y","x21PBMLoyxy","AKrpvfq","tvPWCvK","y29SBM8","q3viz2e","tMDKAxq","B25TzxnZywC","z3zPwwq","tvjuCM4","z1zPEMW","ueDXCxC","yMrFzgLK","r2P3ueO","EwjOCNC","q3n6svG","rvn3s2K","igzPzwXKoIa","r2nvwwu","zMPREM4","q29jAeW","A1jmDNa","ChbL","ENLVsxu","Bg55BKy","CMP5y1e","B1zLB3m","q0LRzxC","jMPZy2fSBgi","zM9YrwfJAa","ihzHBgLKigq","AK1vtvC","BKD6q0m","DKLWtui","AMTitM0","sgnzDxm","BezSDxnO","DuzvDxa","rfbuEwy","zNzxrxe","y2XVC2uSihC","AMDiA3e","vu1eteW","wNHQC1q","Bfb3Afq","B25tDg9Wsw0","y3vYCMvUDeu","AxjvA20","sM1hDKS","tg1lr1m","y3jLyxrLtwu","Eu92Cgy","Bg9Nsurhzw4","swnRDu4","Cu51DwO","vMTksuK","rvzRvLO","Egv6v2e","A1rythe","rxPxB2C","zNjVBujPDhm","nJi4odCYtwvpr0fy","x3bHDgHlzxK","txfUzei","BNnwuwq","B25ozxr3B3i","A2v5CW","yxPmu00","Cwzkq2e","zgf0yq","DMHUB0O","mNW0Fdn8mhW","mxWYFdb8m3W","ywHUz1u","CMv0CNLdB3u","CeLOsNK","zxH0zw5ZAw8","uKrvr3m","DwT1zwC","y2LTEve","Cg93","BwvZC2fNztO","CeTMqKK","CvHUBNa","C0fLsg4","zw50tgLZDgu","yuvQzMq","zxHWB3j0CW","uwn6tKm","C21ADuW","uhHdy3e","zKzIzui","tLr0B2K","DxzUzMC","ywnOzwqSihC","yLDdBei","yxKSihrYEsa","AvHMDg4","CNjVCK1LC3m","wvr4ww8","wM1my28","zMHQD0W","B1zbD0e","zgvSzxrLrge","wxndsvq","ENbmvKW","EKPHvgK","y29UBMvJDca","q0Xpu0LorW","AejZzfu","CM92AwrLige","A1bfELa","se1AvgW","Cur3q3q","v3PVs2W","uw5dA3i","BMnvtfa","AxmGDw5Kzwy","nxW4Fdr8mxW","qw5cteS","Cwv3s1a","y1H4t1G","B2jQzwn0u3q","mtH5ugDes0K","Aw5KzxGGB3u","CNHfu0G","reXbrMi","BNrfBMrWB2K","uwfoAM8","DcbSAw1PDa","yxbWzw5Kq2G","AenSB3nLrxy","BwLUAvbYB2C","mZiXmJuZnNPjrKfqtW","qMruu20","EwfgDKG","CNzHBfzHBhu","rMDiru0","BNfUt3e","C2vYDMLJzq","qu54uw4","DhDVCMTdAge","z1DzvMy","DvLICwy","vLPdEu4","BwvKAwf0zwW","Eu1dy0K","CNPAr3C","DxrVuMvJB24","yuvotxe","vKvWzKq","igfYCMf5yNu","CMTLCKDSB2i","vLPIr1m","Bg9NsurozxC","x2LZtM9Kzq","tuvtu0fhrv8","zeDwA0C","DePxwhy","Dg9cExrLCW","rLfwzfi","r0DPEwC","lcbTyxGGCMu","swnpqNK","sfbqq1C","zeP2wxm","t3f4wxO","DxbNCMfKzw4","C3rLBMvYCW","refjD0W","C3rYAw5N","wMzhtxe","q1D0ALy","yLbrAu4","tuTkr3u","AgvKtwf4uMu","ChLjq04","AgfZ","r01xB0G","wwfMsw8","AKrVrwu","r2rqyxa","qw1VDw50","r2Dtrwe","Dgv4Dc9WBge","zK9lwvG","z1vRzvO","AwXLtMfTzq","y1rMrxy","DfHyyKW","seDLze4","zufJAW","ChHQEM8","zw1LBNq","n2Hoq2rfta","C3rYAw5NAwy","Au1Itue","t1L3t1C","B3vADeq","y29TCgXLDgu","vxHbtK0","AxnbCNjHEq","z2v0u3rVCMe","zfDVCMTLCKC","q0Xpu0ve","Bg9IywXty28","q09otKvdveK","ruPqCva","sgz4AKy","BMv3vMvYC2K","DfnevM8","zMvY","tg9Nuvi","A3ndDMm","ANjrsuq","Dgv4DfbHEwW","q1vfAvy","x2HHBMrSzva","D24GCMvHC28","C2vYDMvYvgK","C2HPzNq","wgzuuhq","uuHPvxy","q3LpCve","s21TzuS","yw1Lu3bHy2u","yMfSrxzLBNq","ywjNCgy","whbnz1e","AeLQCKe","q3nytum","DhjPBq","DgLLCKPtt04","B2nRzxrtDwm","CKXqvxu","l3DZl3yY","rLjptLrjrvi","zw5HyMXLvhi","B3bLBKrc","BMv4DcGPigm","zMzmAw5L","s0Dfqvq","zMTnD0e","sKfXr2K","B3jRig9MzMW","BMPIwhy","yNL0zuXLBMC","EhzNquO","Aw5Lza","mdaWmdaWmda","x2XPC3rLBMu","rLnZswK","Dfzmtfi","ywXPzcb1CMW","EfvZzuvUDG","uMXTuM0","zwrPyxrLBhK","tgzkzg0","B25tDgfYDfi","tg9NsurozxC","zxb5yMm","x3bPBMDqB24","ANzJBu0","zhLbvMe","Bg93","yxGGCMv0CMK","ugfArhu","z2vtEw5J","vg9Xzfi","BMrWB2LUDca","uev0s3K","yvD1tLC","sKD1DeO","wfHjzhm","x3jLy29UBMu","vfndChC","s2rPvNu","x2LZv29YA2u","u1vdv2K","zxj2AwnL","EwXjDe8","yxnQwgK","y3nzyMe","yxrHlcbKyxq","CMvUDevUzha","DKrsz2W","DxvyzNK","wxbOt2O","ANn5rhC","rKDJqvK","r0jWsgu","ywHvrMm","uwLRr0O","y3jLyxrLrxi","B3jpBMXPBMu","DfbSr0u","zxH0CK8","wNn5yLa","v2LUzg93","z2v0t3DUuhi","DKrvAgu","D3b5t3q","BM5Ly3q","r3nuEuy","yu9Vwwe","Agjly2G","q2fZCNG","suneAuO","yxHJEMK","rhHutva","vLH4BNC","CNnVCL9Uyw0","rMDJEfG","x2nVBM5Ly3q","CejOsMW","zvviswi","x25HDMLNyxq","x3nLBMrby2S","CM92AwrLihy","DvD3C2O","y3r4","AgDWBNu","yw1L","z2v0s2v5","CMvZB2X2zq","ELL0B00","wvvhC2S","DfjIEg4","tgzWDgG","zKTbBLi","AuHTuem","DgfIyxnL","B25Uzwn0Aw4","rNL5r1m","Cen0sgy","yM9KEq","CMvJzxzPzwq","C29YDa","CgfNzxnOB3C","C0XPC3rLBMu","B2LUDfjLywm","vKXos0e","x29Ut3bLBG","n3W2FdeW","BxLhuKe","B3nLrxzLBNq","A1rwu0K","quHHBuO","yNbADM0","x0vysvnu","tw5tq2S","EujUu2O","ywXty29Wzq","AxDMBg8","z3LKywW","EKvOC0W","vg1LseW","u2rSB3G","ig1LC3nHz2u","yw51Ce1LC3m","A2HQteO","z2v0sxrLBq","Cgf5Bg9Hzeu","zw50","t1P2tgK","Cev3u1e","EgHIBfC","Dev2zw50","ywnRtxnNswq","ChjVDg90Exa","y3vYC29Yx2y","sKHQELm","tM5Jrwy","zcWGDw5RBM8","sw5bCgq","B1Lrugm","rxjYB3jdB2q","zvvYBa","ywXS","r2Xdt3q","yNL0zu9MzNm","qLnYuKS","rfLUreK","B0vmy0G","uhvjBe8","v2vPEgLUsLm","z0f0rhi","zMzMzG","wvbeuLK","CxPRtgC","vK1Tyvm","vurvrMO","vgnIqLq","BuHvsKW","vuzTAhi","B2fK","BevZB2G","DhfvwNu","zxjFAxnFywm","BNrLCG","t2LZvfG","BNrrB2u","Ee1tsge","q291BNq","qxzyv0m","qKDRrMu","y3jLyxrLq2W","ww1iswO","t0zVv2S","DhbizwfKzxi","shrwv1a","DgHLBG","rLPOuhC","ALLYrvi","Cg9PBNrdB24","x2nSzwfYugK","ALvNr0C","BLrowLy","x29WDgLVBNm","ruf3uKK","A1Puywi","DMfS","mNWZFdf8mhW","BgfkBKi","t2vAu1u","Dgfwq1y","yKXbqxG","yLjyCKq","y29Kzq","AeL4Dfu","mhW5Fdn8mNW","CNzqBMu","wxLkz0K","AMn1uha","zwnVBM5Ly3q","Cw9Zx18","u2vYDMLJzvC","y09Wzw4","uMrnq28","zM1ZEMG","CevQvgC","DLbyDhm","qxPZvKO","DgvZDa","AwXSihvZzsa","Eejcs3e","x194x21Zz18","z2u6ia","B1PcC0q","zNnAyLG","tvn0r0C","BgLZDgvUtMu","q0vPBhy","q29Kzq","zuTWrK0","suHhA2y","Bg9N","s1fkseC","CMvZDwX0","tMzQz3q","zK52qwC","CejluwC","ihrPBwvZ","BxnTA0y","B2zMC2v0","sMTIsu4","BxnN","BeHHBMrSzxi","zxDjzLq","Dw5KzwzPBMu","CMvWBgfJzq","BwLZzq","uxvLDwu","BNrbBMrvCgq","vxjqBfe","ufvnq0m","rvrRDu4","sxvfrxa","zvPuzLO","x29UvgLTzw8","rNrutLO","B25nzxnZywC","quDSueu","qNjPzgDL","DMvYC2LVBMm","z0z4vuy","y2Tyr0y","qNjnueO","BfHfr3e","AgzOyxq","CMvZzxrdB3u","wKXIzw4","AefJA01LC3m","zgvMAw5Luhi","CNnVCKzPBgu","ywDrwMK","wu9NvwS","z1fUweG","whrtzfm","B25JBg9Zzq","AKjIrgG","CMvTB3zLq2G","C3vIC3rYAw4","sMzMsuu","B3rUB1i","BgPrtfa","t2fiy3q","AKfWteq","x2zVCM1HDeu","sNjltxi","FdeWFdL8mxW","z2v0qwXSs2u","A2v5","AxjLza","yxbWBhK","Awj6r0m","x29UugfNzu4","yxD1Aeq","vhrer0W","sK5pz00","tefPtfm","yK5Jv0q","AeLktKy","Cgf5Bg9Hzfq","Dg9hzw5LCMe","C3nHz2vfDMu","B2vKqM4","wu5zsLm","BgHJrMi","DKP3sw0","Agzpueq","yMLUyxj5vhK","ueXus0C","CM9YrxzLBNq","EwrgCvy","AwrI","BMrLEa","x29UtwvZC2e","y2XLyxi","zgv2AwnLx2K","zNPgtxq","y0v3rxa","CMvTB3zLrxy","qwjVCNrfCNi","DLbQrLG","ywWGy3vYC28","A2TXwKy","AxD6BxC","uKrAs24","tMP6ugu","BMjbuhi","C3bSAwnL","AKnLDg4","sfHoCw8","B3DMswK","CgLUz19VBMm","x2LZtwLUAvq","BvbvuNK","BLLtt20","EvjAsNu","uLjpuG","BvHosM0","z01uuKK","DgLUzYbZzxi","zgvS","C0vxz1e","D2fZq2XLyw4","CgXhqwe","qLbewLy","rvD4z0q","DwHst3G","DgLTzw91Da","rKLmrv9ot1q","DgfYz2v0","B3vUDa","D01cDvq","D3jPDgvvAw4","DxbRBw4","DxjS","B2ncDey","x2nSzwfYvgK","EhDusKK","zNjVBunOyxi","CMLLC0nVDw4","terpEhK","zhviExG","zMXVB3i","wM9srvu","x2LUAxrqCM8","Dfrhtwm","zwf4sNa","s25Kwwm","vez3sg0","Cg9W","x21LC3nHz2u","mxW0Fdn8mhW","tKPjwxu","ru9IqLC","vuHHrum","C3vJy2vZCW","BwHiwwW","wLbZuwO","uxjJvvK","Bvvdr2W","BgLUzw5V","tfD2Auu","Dg9cExrLC0W","DhnezKG","BM93","wMTbsg8","D3bUt1K","wfDjqKC","AwXLx25HBwu","BMCGzMfPBgu","q0virMO","v0rmywu","r2ryDvi","ChHdqNi","zwnwzfe","zu9gBgu","Cvrrswi","zw5NDgG","C2v0","DeLUDgvYy2u","DuTjs0W","zgTUCKi","zKnQCxa","C2zfBfa","zNjVBu51Bwi","tLfKDvO","vuTOvwK","CxzVyui","y2rly1u","zw5HyMXLqxu","zNb1ve4","nhWYFdv8m3W","EwTdv1O","vgfN","y0TQEwy","r1njC3u","C2v0sxrLBq","u2vXsuq","EgLqv1u","shHiCha","zxjYB3i","svvjuue","s0rdyK0","BNf4zgi","CfD4t2q","B3bLBG","zfbOvMq","C2vUza","uvPiChm","t0LTBui","Ahr0Ca","zwjLvxe","ChrlyKW","x3bPBMDmB3m","CeLIrLe","zxmGCMvHy2G","DenQsKu","qKnJuvu","ugfrBeO","mhWXmxW4FdC","x3bYzwzPEa","rhPuBLq","C3vIyxjYyxK","ENP2wg8","x3DZ","v01iwvO","ELbRy2S","AuzfD0m","y3vYC29Yx24","zw5XDwv1zq","BgvY","y0vQy1u","BgvlqMK","DNzXBem","y3vYC29Y","uMTHzKe","Ae5szfq","CMvHzfvjBNq","CM92AwrLigi","ruX3vLi","DM94D00","BMnVzgLUzW","CNvpyxq","rK5YCuC","u2vytKO","vw5Oyw5KBgu","BMrWB2LUDfq","Bw1Hrxi","CvzIu0m","CMTkANi","q3vZDg9Tq2W","quXm","y2HLy2Tszwe","yM5nB1y","BgnQEwm","C3bSAxq","y2vZEe8","zv9ZDwnJzxm","ywrK","x3bYB3rVy28","wg16wfG","yvzjz0K","tKDFrvjst1i","t1bftG","DhjHBNnHy3q","C0vwvwu","CMvOCfa","tfbmCha","AfrQzfK","qvHby00","DcbVzIbYyw4","x2DLDeLUDgu","CMvJB25Uzwm","zNjVBuj5Dgu","EKnXDKS","thHMENq","yNvMzMvYzwq","wLj6BuO","BufbA1G","zw5JB2rLrNi","rvfpr3u","twzxwgy","vgnoqva","qKfyq0K","z2vY","vePZB2C","C1nSz1y","Chv0","rgrSDvq","vgzPvLm","zxjHDg9Y","x2HHBMrSzvi","zMLSzw5HBwu","Au9vwNC","zMLN","x29UrxjYB3i","BNr2Bxu","x19LC01Vzhu","zM9eC2q","sK14r0i","qLPnt1i","zM5owg0","y29UDgLUDwu","r0rhuxm","rNHqte0","tMLcs0S","ww1jruK","CMXzzeW","zxb3rvO","Aw5L","AxnrB1nby2S","De5WrgO","x3jLBw92zvC","y2vZC0HHBMq","CMvHzhLtDge","yNvJs1m","z2v0q3vYC28","BgvUz3rO","A0XmqxK","z2fxyuq","DvfJr0S","AwDHDg9Yt24","zMLSDgvY","ign1CNnVCIa","u2DwELO","sNj0zNu","vvPZwgy","t1bKsuS","ywnR","EwTpy1y","tfblqNu","ELbWv3i","id4G","AvnqEfy","zwT4yNu","DuDyCeO","ywDLsgLKzq","Aw5N","x2LZqNjVD3m","zKXqs0q","zNjVBuHHC2G","zKLeEgq","B09iz2S","EwXfBw0","vunqshy","zxf1ywXZ","yvDuvuO","AhjxvMe","zwvKzwq","v2vTzfi","vxHXqNC","CeDVAMy","Dg9oDw1Izxi","zhr5rLu","Bu95sKi","y2X1DKW","DvbNDM0","zvzur3u","B3v0sw50zxi","Ec1TC2CTy3u","B2zMBgLUzq","yLz2BgK","CgLUz1rPBwu","icSG","v0fqv2C","Bwf4uMv0CMK","reiGzMfPBgu","rLDt","r3HYsgK","D3jPDgu","Du5Kt1q","qvPsAwC","CgjICdi","C3jJ","rurkr1y","tw9KDwXL","zw50zwqGDhK","B25mAw5L","uwfZtxq","rKPIAg8","twvZC2fNzuu","Den2A2S","rgjdtKO","r0zRDeq","B3jRzxjhBg8","z2v0q3vYCMu","y0Pjv0S","A0LNDem","CMvXDwLYzwq","rMzgD3i","DMvUDa","Eu5etw8","A0nssNe","ENfuuKG","x2LZsw5PDa","zKXXCgG","y0HrDKS","DxrMofDYAxq","mNWWFdr8mxW","BwvZC2fNzv8","vgLTzw91Da","zxH0ugf5Bg8","CNLTu2K","ywnRDxbfBMq","zcbLCNjVCI4","Dhj1y3rVCIa","zuzyshC","vMrAse0","y2XVC2u","yw5Nzq","tuz1B08","y29UC3rYDwm","x3DHAxq","teDUqxG","B3npBu0","qNHrzNm","vgHSvNm","zuvXExu","Cgf5Bg9Hza","tK1ZrNi","zwn0","ihjLy29UBMu","y2jLExm","q0fxEeG","u09rB00","B3jmA1m","BML0AwfSAxO","B2nRzxrgywK","yM1vvg8","C2XPy2u","D2zXq08","lcbxzwjtB2m","AgvHzgvY","x2n1CNnVCK0","svDiz3K","AxnszwfKEq","D2PeueC","B3bLCNr5tMe","ruLWCgK","sunWtgy","DxnLCKLW","zLD2Efq","rM5SEva","ywrKt25L","y0z2y0S","zML6A1K","A09HCfi","CgvYC2LZDgu","ywfut1q","D3zss1G","AwXK","B2zM","Du5OweK","r1DKy1m","A2LxEwy","thDYt0C","ueH6wge","tKz2yNa","y1PUC1q","EfP2BwS","CgLUz0XVC3m","su5iCNq","BNruCMLLC0m","ELPMv0S","vu9dsNm","yLfYzee","v0XcAuu","C3rHCNq","CYbPBNn0yw4","D1DNsfu","B1brwvq","CwXgt1m","Aw50wwu","su5tvefova","BMHTzeS","Dg9mB3DLCKm","y29UBMvJDeu","s1PIuKG","ALPwquy","zNjVBNrPzxi","y3vYCMvUDeK","uNzQqNu","sLnjAeO","yxv0BW","mZK3ndrjD2nstwW","mxW0Fdn8mNW","sg9qDge","tM9LBue","ywXSB2nvBNm","AKjky24","yxnJCMLWDa","mta3mJi3D2PUz25O","t2XjCNC","wuzTCLe","wxHXC2e","uezYrwi","wgv0wLu","rKLzAuO","DgHHBIbSB2m","tgLZDgvUzxi","wKzqEMy","C2DPza","wgnmBhq","uujXChi","x2jPBMfYEvq","u3r0ufe","C2vYDMLJzs0","zKfPDuq","zwPHD3K","yMXVy2TLza","x3nLCuLK","zg9Uzq","A0fiwM4","y2fSBa","ru1Wreq","ChrVCG","yMLUza","wxDkthG","z3nMshO","tLvHsxu","rvjst1i","y2jSCKe","ugHlC0e","yuflse8","DgLuse4","BKXPBMu","yxv0B21HDgK","vw5PBxbSzw0","DhjPzxmGCMu","tLrqtNa","rgvKAwnHDgu","x29Uq2XVC2u","wxDrt3K","u2PIAui","q3vZDg9Trxi","q0fizuu","txjbqK0","Du52CMW","u2TPCcbWyxm","EhnorKy","DezHsMC","ywDLrxzLBNq","Ag1iwxy","r2nNDKS","x2rPC2nVBM4","AejQBLC","suvtx0vsuK8","svL6wMm","uhPRsxy","zevXBLq","ihrPBwvVDxq","wxHVDxK","rLzJzee","yKD3zu8","zMLUza","nti0mJCXmff5uK95BW","x2LUDgvYDMe","ihrYEsbYzwm","Cg9PBNrbBMq","ChjVDg9JB2W","yMfJA3vWigu","sLnptLa","uuPjq1G","C0jf","AevYCM9Yrxy","s1LzEg8","x3vYBa","y3vYC29YlNm","tKfusvzfx0u","BgjSAxq","mNrQEu12Dq","vhfNsgu","sMH2sLy","Ce9pr2W","zxq9DxrMltG","B2nRzxq","sKzJzhq","qxnPwLq","zxjYtM8","rfLKvuW","qvrJtMC","CenPqxi","ywnRx2nVzgu","DeLK","ywHht2y","CNzHBa","AwjozNG","re9zCLm","ve92qu4","AgLNAa","sxLSsuS","pxv0zI04","CMvWBgfJzui","s3Pcwhq","uNz5EgK","v0PtzLG","r0TZy3y","ugDMD0q","wMfiyw4","AuLKqxq","B3bLCNr5","uxbYqwy","EezqrNy","BMvY","zwHLB0u","AwTwvKK","y2HnyxHuCMK","revIzfG","sxzxDue","z3LKEuy","uvbzEe8","ExjmAue","Ef9MCM9UDgK","zvvHEfq","B0n1ug4","y0rJv0O","u3rYyxrLz3K","y291BNq","CNncs1K","C0HeEMm","A2v0ignVBNm","BNjLBeq","x3jLywr5q2W","C2v0q3vYC28","z213uxa","BMDLza","Aw1LCYbPBIa","q2fiwLC","CMfUzg9T","vg1HELq","ndm4mJa1Cerbt1Hs","uhvgzu8","Dgv4Dc9Qyxy","y3jLyxrLt3a","Efrurw52","uLLgCLa","thfhCuu","whHuCMi","uhDlBg0","BgLTAxq","ANb1vui","ENvhCfa","zLr5BM8","weLbCuS","rLnqwhO","y3vYDMfSDwu","rw13yxy","vxz3qMC","yxnZAwDU","Aw9svwW","CMfNzvn5BMm","q09oveLovuu","y3jLyxrLuMu","D2LSBfjLy28","qu5iEhO","vuHevwq","Bvnpsvm","ywDL","wffXD0W","tgH3rg4","C1rpzue","x2rYB3bhBg8","y2f0y2G","BwfUDwfSihi","uu51wg8","zxfmyw4","C2v0u3rVCMe","Cgr5q2u","tg9Nsuq","wg5Wuwe","t3DZrMS","u2nhBem","C0nVDw50zxi","surcCeO","BMDuAw1LCG","zv90Aw1LB3u","B25LCNjVCG","zxjFywnRx20","x2n1CNnVCKy","z0r5AhO","zw5JB2rPBMC","AxnAzxjV","Axrgy1e","twLZC2LUzYa","ywnOzwq","x3DZsw5ZDge","DKHHqKq","vMXbEei","x2HHBMrSzu8","q29qt0u","yKvxrhK","vLDXvva","wNPfuKy","y216rMu","B3bLBIa","EgHzDxm","ywDLu2HVDW","A3DmENi","twP4zfq","B0jMqwW","tKzkuwy","BMCGB3iGyw4","t3DJyM8","rNjVBNrPzxi","BvbruxO","CgXLyxnLiha","AgfUz2u","yKn0su0","Dg5rsue","BhnRAMC","wM9cCu8","Ae1LC3nHz2u","sg5Azvq","qur1rwq","Dw5ZAwDUzwq","x2LUAxq","B25VCgvU","AgvHzgvYCW","vKToq0C","uvviAhq","DMfSDwu","t1vOEM0","B3nLza","yuH2qu4","CgLUz0LUDgu","DMvYC2LVBG","BevqwKi","x2rPC3bHDgm","zMX1C2HfEha","qNvqqK0","uMvHzcbWyxm","y3vZDg9Tshq","DgzUu1e","t29UC1i","t2jQzwn0","sLPbzfO","su1OBhG","AMvJDfn0B3i","t3bLBKv2zw4","EMvwq1K","Dhr3Awq","BhnTy0y","tK5nrMq","yw5Hz2vY","twHWr1K","A2X6zKy","EwnOEM0","ywr2yw5Jzq","B09Pvee","q3LxCMe","y1rlChG","AxnrB1nnzxm","ENzREMi","uMvJB25Uzwm","zffqvvO","sK5nseq","wMzjC1e","EeTOEeO","BgLUzq","BxnNsuq","rfzRAgK","BwvY","Aw9U","DwPssxi","Cw9Z","s0vVCKm","x1fVu01HBMe","wvbwvKK","z0LWEuy","AMPMueC","ywzmvey","AffQrha","y1Puv0S","Aw9UvgLTzw8","yM9L","tg9JAW","y1Dgz1C","yMjuCvq","EfPTCuW","B25szwnLAxy","v2vIu29JA2u","yNvMzMvY","Bwf4tg9ZC0m","t1Pqs0u","BwvZ","Fdv8nhWYFdm","vfnoteu","v1rkthG","D2LbuNO","qxLPzwW","zgL5B1K","C2nYAxb0","BwLUzW","A3fiEuy","vxbKyxrLq28","zwnYB3q","shbxqxK","CMvYqvi","wKTStNy","rLzkEuW","swPpDfm","zNvUy3rPB24","z3Hiv2G","z1rPBwvVDxq","r3bLB2C","y29Uy2f0","BMCGDxjSoIa","yKDSu0W","x2vUzhbVAw4","DKHIswO","CMvHC29U","re9zrNa","ihbYB3rVy28","mxWZFdb8nhW","uNnsz3K","yufMy0e","wMDetKK","vxn4q2S","CMvKDwnL","AxnmB25N","ignVzgu6ia","BfrPBwvVDxq","x2n1CNnVCK4","wvnLrKu","CMvHzhDYAxq","CMfTugfYyw0","EwvIzem","AgfZt3DUuhi","C2vUzf9Hy2S","AMDZrw0","svDSwfm","vhfODMi","B25fCNjVCG","qvvYwfm","DwXsDeG","twjtuey","zxjFDhrS","zw5KCg9PBNq","Bvb1q1a","zM9Yy2u","sMvxtu4","x2DLBMvYyxq","wuT0uvO","Ew5kuNu","EvjLy29UBMu","x2rItMfTzq","ywrKrxzLBNq","EuDNz1K","BIWGAg9ZDg4","yxKSig5LDhC","ze1gzeu","wLDvA20","y2uGBM90igK","seXvDe8","ysbTDxn0igi","B25dBg9Zzq","BNvTyMvY","wMDcv2u","z1jouwO","CNnVCL92ywW","vMflAwW","DhjPzxm","y29UBMvJDfm","tufyx1jfvfi","vw9wEMW","wu94yLK","qu9bue8","DuDlsgW","x2rLyNvN","uLnJv1u","x2rLC3rYB3K","Dhfrruu","uMrkwKe","DgLTzw91DcW","DgjrDfu","EKPhAue","CLbyzwC","DMTorhi","thDivKO","y2HHCKnVzgu","BNHSvMO","wfrUtfy","zefuAg0","De1HBMfNzxi","z2nxvu4","ihn1y2nLC3m","A0frtue","yLnev0y","C3rVCMu","D3nZoI8V","y2fbqLK","rg9KCK0","y0XJvNy","y1jpt1e","zufTv1e","BKHuugO","CMLlAfK","EvfZBgS","zLzxzeC","Ae9Wzw5fDMu","vhb1B1C","yMTKuum","B1zpDxi","z3bKreS","Cu9luvy","CLnLzNO","yxbWBgLJyxq","CgfYC2u","Dxrjza","x2TLEvbHDgG","uur4wM0","AffYvLK","tNb6uNu","yxnL","EgfQz20","B3jL","x2nYzwf0zvm","sxjNsNu","uKXyweW","Bxrkzwq","x3bPBMC","ndu0nJCXDxroyNbs","ANrjuhm","tKXPDLi","qKfLD3q","x3fVC0rc","vhDttfK","AvPzEwS","sfPLtxG","y2jxCNi","CK1ZB3i","zgvIDwC","DxbKyxrLq3u","vgn1tNu","EhrOsxq","tevPz2e","vxrWsLO","BwvZC2fNzq","r0PxsKS","zgvJB2rLzey","vwngr0G","yxf0v1m","yuT2reu","s1bdEgO","x0rctMfTzq","zNjHBwvuExa","uxvLBKi","y2XVC2veqG","EMfJyKW","qvfVBxK","y3Dcu1y","ihrVihjLDhi","yw5ZzM9YBvq","q0vkDvK","zgLZywjSzue","CMfTzq","Aw5KzxHpzG","Dg9Y","y3ruAw1LB3u","zw1PDa","Aw5KzxG","uhjPBwfYEuS","x2LZtwLUAvC","wNDTCMG"];return na=function(){return t},na()}function TS(t){let e=N,n={tnQIA:function(i,o){return i(o)},sEWgQ:function(i,o){return i(o)},CEJuY:e(1941)+"oreNames",DAIwL:function(i){return i()}};return t===IDBDatabase[e(687)+"e"][e(1026)+e(1524)]&&!(n[e(1715)]in IDBTransaction[e(687)+"e"])?function(i,...o){let c=e,d=t[c(1275)](n[c(1470)](os,this),i,...o);return qd[c(940)](d,i.sort?i[c(655)]():[i]),n[c(883)](zt,d)}:n[e(487)](SS).includes(t)?function(...i){let o=e;return t[o(832)](n.sEWgQ(os,this),i),zt(jd[o(1729)](this))}:function(...i){let o=e;return n[o(883)](zt,t.apply(n[o(1470)](os,this),i))}}function PS(t){let e=N,n={hIxtU:function(i,o){return i===o},ckXGF:e(1563),GRpqt:function(i,o){return i(o)},PKZBY:function(i,o,c){return i(o,c)}};return n[e(747)](typeof t,n[e(804)])?n.GRpqt(TS,t):(t instanceof IDBTransaction&&AS(t),n.PKZBY(Zx,t,vS())?new Proxy(t,sa):t)}function zt(t){let e=N,n={TpuoW:function(o,c){return o instanceof c},kPEzP:function(o,c){return o(c)},jjfPG:function(o,c){return o(c)},srvzE:function(o,c){return o!==c}};if(n[e(1662)](t,IDBRequest))return n[e(1930)](IS,t);if(ea.has(t))return ea[e(1729)](t);let i=n[e(1531)](PS,t);return n.srvzE(i,t)&&(ea[e(940)](t,i),ia[e(940)](i,t)),i}var Zx,jx,Wx,jd,ra,qd,ea,ia,sa,os,Kx=Jx({"node_modules/idb/build/wrap-idb-value.js"(){let t=N,e={PEyVN:function(n,i){return n instanceof i},cluvL:function(n,i){return n===i},eUHIb:t(1273),PEtKy:"objectSt"+t(1783),vkNDr:function(n,i){return n===i},gcWUN:t(1650),nrelD:function(n,i){return n(i)},VMmaS:function(n,i){return n in i}};Zx=(n,i)=>i.some(o=>n instanceof o),jd=new WeakMap,ra=new WeakMap,qd=new WeakMap,ea=new WeakMap,ia=new WeakMap,sa={get(n,i,o){let c=t;if(e[c(1762)](n,IDBTransaction)){if(e[c(1117)](i,e[c(633)]))return ra.get(n);if(e[c(1117)](i,e[c(588)]))return n[c(1941)+c(1783)]||qd.get(n);if(e[c(1639)](i,e[c(1646)]))return o["objectSt"+c(1783)][1]?void 0:o[c(1941)+c(1677)](o[c(1941)+"oreNames"][0])}return e[c(1383)](zt,n[i])},set(n,i,o){return n[i]=o,!0},has(n,i){let o=t;return e[o(1762)](n,IDBTransaction)&&(i===o(1273)||i===e[o(1646)])?!0:e[o(708)](i,n)}},os=n=>ia[t(1729)](n)}}),Yx={};bS(Yx,{deleteDB:()=>CS,openDB:()=>RS,unwrap:()=>os,wrap:()=>zt});function RS(t,e,{blocked:n,upgrade:i,blocking:o,terminated:c}={}){let d=N,u={IWlXS:function(m,_,v,y,b){return m(_,v,y,b)},tJWXv:function(m,_){return m(_)},LjACb:function(m,_){return m(_)},jZVAF:"close",ksCvc:d(1271)},f=indexedDB[d(967)](t,e),x=u[d(476)](zt,f);return i&&f["addEvent"+d(1261)](d(485)+d(1110),m=>{let _=d;u[_(1592)](i,u[_(476)](zt,f.result),m.oldVersion,m[_(527)+"on"],u.LjACb(zt,f[_(1026)+_(1524)]))}),n&&f["addEvent"+d(1261)](u[d(531)],()=>n()),x.then(m=>{let _=d;c&&m[_(1608)+_(1261)](u[_(1240)],()=>c()),o&&m[_(1608)+_(1261)](_(802)+_(1468),()=>o())})[d(1424)](()=>{}),x}function CS(t,{blocked:e}={}){let n=N,i={xZmqL:"blocked"},o=indexedDB[n(1922)+n(649)](t);return e&&o.addEventListener(i[n(1540)],()=>e()),zt(o).then(()=>{})}function $x(t,e){let n=N,i={ZLben:function(f,x){return f instanceof x},GKscv:function(f,x){return f in x},SOmor:function(f,x){return f!==x}};if(!(i[n(809)](t,IDBDatabase)&&!i[n(1358)](e,t)&&typeof e===n(488)))return;if(ta[n(1729)](e))return ta[n(1729)](e);let o=e[n(788)](/FromIndex$/,""),c=i.SOmor(e,o),d=Qx[n(1816)](o);if(!(o in(c?IDBIndex:IDBObjectStore)[n(687)+"e"])||!(d||Xx[n(1816)](o)))return;let u=async function(f,...x){let m=n,_=this["transact"+m(1524)](f,d?m(1586)+"e":"readonly"),v=_[m(1650)];return c&&(v=v[m(1722)](x.shift())),(await Promise[m(696)]([v[o](...x),d&&_[m(1273)]]))[0]};return ta.set(e,u),u}var Xx,Qx,ta,DS=Jx({"node_modules/idb/build/index.js"(){let t=N,e={jBbDh:function(o,c){return o(c)},HMZTl:function(o){return o()},Lfpth:"put",FxPLM:t(1727),ZPsQj:"clear",wvRKX:t(1729),fAiuD:t(641),OUhzm:t(1769),TfiVS:t(829)+"ys",YPTYb:t(1379)},n=(t(953)+"0|1")[t(1017)]("|"),i=0;for(;;){switch(n[i++]){case"0":ta=new Map;continue;case"1":e[t(818)](kS,o=>({...o,get:(c,d,u)=>$x(c,d)||o.get(c,d,u),has:(c,d)=>!!$x(c,d)||o[t(495)](c,d)}));continue;case"2":e[t(1931)](Kx);continue;case"3":Qx=[e[t(646)],t(1020),e[t(1066)],e[t(919)]];continue;case"4":Kx();continue;case"5":Xx=[e[t(1211)],e[t(1269)],e[t(1483)],e[t(1051)],e.YPTYb];continue}break}}}),OS={idb:function(t){let e=N;t[e(1906)]=Promise[e(642)]()[e(729)](()=>(DS(),Yx)).then(function(n){return n})}},Vx={};function Ft(t){let e=N,n={kfAnP:function(c,d){return c!==d}};var i=Vx[t];if(n.kfAnP(void 0,i))return i[e(1906)];var o=Vx[t]={exports:{}};return OS[t](o,o.exports,Ft),o.exports}Ft.d=(t,e)=>{let n=V;for(var i in e)Ft.o(e,i)&&!Ft.o(t,i)&&Object[n(811)+"operty"](t,i,{enumerable:!0,get:e[i]})},(()=>{let t=N;Ft.o=(e,n)=>Object[t(687)+"e"][t(1589)+t(1362)].call(e,n)})(),(()=>{let t=N,e={JAqGi:function(n,i){return n!=i},yMBJy:t(1137),rPXeg:"__esModule"};Ft.r=n=>{let i=t;e[i(561)]("undefined",typeof Symbol)&&Symbol[i(1786)+i(955)]&&Object["definePr"+i(1362)](n,Symbol[i(1786)+i(955)],{value:e.yMBJy}),Object[i(811)+"operty"](n,e[i(1638)],{value:!0})}})();function V(t,e){t=t-453;let n=na(),i=n[t];if(V.yMaNlo===void 0){var o=function(f){let x="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",m="",_="";for(let v=0,y,b,I=0;b=f.charAt(I++);~b&&(y=v%4?y*64+b:b,v++%4)?m+=String.fromCharCode(255&y>>(-2*v&6)):0)b=x.indexOf(b);for(let v=0,y=m.length;v<y;v++)_+="%"+("00"+m.charCodeAt(v).toString(16)).slice(-2);return decodeURIComponent(_)};V.ycfipF=o,V.cZrZkX={},V.yMaNlo=!0}let c=n[0],d=t+c,u=V.cZrZkX[d];return u?i=u:(i=V.ycfipF(i),V.cZrZkX[d]=i),i}var De={};(()=>{let t=N,e={UDUFj:function(a,r){return a+r},GdXuR:function(a,r){return a+r},GjwPJ:function(a,r){return a+r},OwsFk:function(a,r){return a*r},xMSHa:function(a,r){return a(r)},leKBi:function(a,r){return a(r)},ScGlC:function(a,r,s){return a(r,s)},tRbxn:t(1761),qRDpg:t(705),oyqXb:t(567)+"00000000"+t(567)+t(567),xiPWU:function(a,r){return a>r},pWxOd:function(a,r){return a===r},PUMCC:t(1846),eheoE:function(a,r){return a<r},gydal:function(a,r){return a!==r},rxESH:function(a,r){return a-r},OFoWk:function(a,r){return a<r},IjOtS:function(a,r){return a===r},ujRIr:t(1373),BfUxV:function(a,r){return a-r},VKNCG:function(a,r,s){return a(r,s)},CWtjV:function(a,r,s){return a(r,s)},GFktD:function(a,r){return a>>>r},KPCxj:function(a,r,s){return a(r,s)},JKOVJ:function(a,r){return a(r)},HPPCW:"Missing "+t(1150)+" field: "+t(830),hmHYv:t(1445)+"required field: "+t(1482),yQslk:function(a){return a()},oPQYT:function(a,r){return a(r)},iIdAt:function(a,r,s){return a(r,s)},JeWMN:function(a,r){return a!==r},mSOIS:function(a,r,s){return a(r,s)},bWClB:function(a,r){return a!==r},JEUNi:function(a,r,s){return a(r,s)},JrKMr:function(a,r){return a!==r},tBdew:function(a,r){return a!==r},XTnLV:function(a,r,s){return a(r,s)},apXiA:function(a,r,s){return a(r,s)},XsYNM:function(a,r,s){return a(r,s)},tVLLR:function(a,r){return a!==r},IHGkf:function(a,r){return a!==r},VLNKA:"NiQOR",Zxxwc:t(1452),QZHps:function(a,r){return a(r)},vDUhe:function(a,r,s){return a(r,s)},dMFdE:function(a,r,s){return a(r,s)},GGiyg:function(a,r){return a===r},cTfEv:"kIAKw",RxFhC:"XeChv",lXEGq:function(a,r){return a(r)},Evpfo:function(a,r,s){return a(r,s)},QaNjo:function(a,r,s){return a(r,s)},ptKbL:function(a,r){return a(r)},UsxCk:function(a,r,s){return a(r,s)},BdTSm:function(a,r){return a&r},jsyDw:function(a,r){return a===r},tSDVo:function(a,r){return a===r},DEbdX:t(1445)+t(1150)+" field: method",qvoaB:t(1859)+"s alread"+t(1728),Ndtkh:function(a,r){return a(r)},TmazT:function(a,r,s){return a(r,s)},zyoIu:function(a,r){return a+r},LDOxy:t(1289)+t(1138)+"pe: ",DxTMP:function(a,r){return a>>r},irUkm:function(a,r){return a>=r},Yxqsa:function(a,r){return a!==r},ICDiJ:t(1741),DYdUL:t(1730),OqxYz:function(a,r){return a===r},hBjnW:t(1300)+"t limit",AsiZT:t(1143),ylEmm:function(a,r){return a+r},IMVxS:function(a,r){return a>r},UMDLL:function(a,r){return a>r},Svaco:function(a,r){return a+r},TcNAP:t(1492)+t(1948),pCtHf:function(a,r,s){return a(r,s)},FjNis:function(a,r){return a+r},bGweO:function(a,r){return a(r)},CuHga:function(a,r){return a instanceof r},DipNV:t(1273),ZWUkm:function(a,r,s){return a(r,s)},HpWAy:function(a,r){return a&r},XWIBG:function(a,r){return a>=r},kiWyf:function(a,r){return a+r},wzdrM:function(a,r){return a!==r},GJWJK:t(920),sEVUe:function(a,r){return a|r},ZxjsT:function(a,r){return a<<r},XfTPt:function(a,r){return a&r},kTYRU:function(a,r){return a&r},asjXi:function(a,r){return a<r},mUCGl:function(a,r){return a(r)},ZzERF:function(a,r){return a+r},ybhrw:function(a,r){return a+r},PzkIv:function(a,r){return a<<r},GMWoH:function(a,r){return a|r},IWHgy:function(a,r){return a&r},ukueg:function(a,r){return a<<r},rsBKY:function(a,r){return a>=r},ZfGMq:function(a,r){return a<=r},gxHWh:function(a,r){return a(r)},oVOur:function(a,r){return a==r},bVvli:function(a,r){return a&r},fizkY:function(a,r){return a>=r},dQPUZ:function(a,r){return a+r},dEqnT:function(a,r){return a+r},Owcbo:function(a,r){return a+r},pEwSQ:function(a,r){return a!==r},ifAgU:function(a,r){return a<<r},gDyhz:function(a,r){return a<<r},aHvAN:function(a,r){return a&r},CoPOE:function(a,r){return a<<r},ObFlT:function(a,r){return a&r},fWvxT:function(a,r){return a<r},ALWTk:t(1736),awuhD:t(632),EObBW:function(a,r){return a+r},VWAjs:function(a,r){return a<=r},jrQID:function(a,r){return a<r},PAEth:function(a,r){return a+r},oBfAl:function(a,r){return a<<r},Yxouy:function(a,r){return a<r},duHyx:function(a,r,s){return a(r,s)},yebdC:function(a,r,s){return a(r,s)},hfhat:"zPvpP",oCuPn:function(a,r){return a>=r},jgsEm:function(a,r){return a<r},gGXdp:"BqDzQ",CAWxH:"zVKOG",sSlgV:function(a,r){return a|r},IYzZc:function(a,r){return a|r},bCtIM:function(a,r){return a|r},xthIt:function(a,r){return a&r},Rvyxi:function(a,r,s){return a(r,s)},ZoBqO:"JOYOo",DFwdn:t(1557),zacbL:function(a,r){return a(r)},HtVWP:function(a,r){return a&r},aEjfd:"hTCjJ",DOYFp:function(a,r,s){return a(r,s)},FgHEM:function(a,r){return a|r},UHDUd:function(a,r){return a(r)},LhwDn:function(a,r){return a&r},ZsybP:function(a,r){return a(r)},XetZU:"aOoYa",gUkeZ:function(a,r){return a(r)},ToqdR:function(a,r){return a&r},OZvLi:function(a,r){return a&r},KYYxo:function(a,r){return a(r)},FSPXz:function(a,r){return a&r},Sdlox:function(a,r){return a&r},fLqph:function(a,r){return a&r},dpMMq:t(1286),nbAPr:function(a,r){return a(r)},EIppi:function(a,r){return a&r},OPdIK:function(a,r){return a(r)},vJwIm:function(a,r){return a&r},jBJcn:function(a,r){return a<<r},pdyCe:function(a,r){return a>>>r},pIhJy:function(a,r){return a|r},lNZJa:function(a,r){return a<<r},uGKHl:function(a,r){return a>>>r},GgSEa:function(a,r){return a===r},LrqOK:function(a,r){return a<r},AzsVJ:function(a,r){return a<r},OlIrw:function(a,r){return a<r},yMCcI:function(a,r,s){return a(r,s)},ykOcV:function(a,r){return a>>>r},zYtoM:function(a,r){return a!==r},BuPBM:function(a,r){return a>>>r},gMTRI:function(a,r){return a+r},YyJgI:function(a,r){return a|r},wiARz:function(a,r){return a+r},xFPFv:function(a,r){return a+r},ZkAHo:function(a,r){return a!==r},HAChC:function(a,r){return a|r},diyoY:function(a,r){return a|r},DLAFb:function(a,r){return a>>>r},IrgJu:function(a,r){return a!==r},rerAR:function(a,r){return a>>>r},smZuL:function(a,r){return a&r},ADuEd:function(a,r){return a>>>r},UFmhr:function(a,r){return a|r},nqnOq:function(a,r){return a>>>r},hfOPD:function(a,r){return a!==r},PhKsA:function(a,r){return a|r},NihjI:function(a,r){return a&r},khjLJ:function(a,r){return a|r},FZhPw:function(a,r){return a|r},mPURy:function(a,r){return a<<r},zllRG:function(a,r){return a|r},DodrM:function(a,r){return a|r},SttPQ:function(a,r){return a<<r},DPTyf:function(a,r){return a<<r},ecVdQ:function(a,r){return a|r},QczNC:function(a,r){return a<<r},dRlHR:function(a,r){return a<<r},cmzFe:function(a,r){return a<<r},jtIPs:function(a,r){return a|r},Iaarh:function(a,r){return a<<r},BEfrF:function(a,r){return a===r},fCjqp:function(a,r){return a>>>r},UKhUi:function(a,r){return a<<r},CUEiV:function(a,r){return a<<r},KMPhB:function(a,r){return a<<r},aKvDE:function(a,r){return a|r},uvnfg:function(a,r){return a<<r},FFKuL:function(a,r){return a<<r},RXUuu:function(a,r){return a>>>r},fNvAg:function(a,r){return a>>>r},UCPHv:function(a,r){return a&r},DbCNJ:function(a,r){return a>>>r},dyAVa:function(a,r){return a>>>r},oZBsD:function(a,r){return a>>>r},dGVkG:function(a,r){return a(r)},fnNXm:function(a,r){return a===r},HcYus:t(870),aplKg:t(1853),PaZDu:function(a,r){return a|r},BrMPJ:function(a,r){return a%r},AGlPE:function(a,r){return a/r},ioRUl:function(a,r){return a*r},nTNZV:function(a,r){return a>>>r},BZMOR:function(a,r){return a*r},lcjyc:"close",YPVVI:function(a,r){return a===r},iFEwC:t(1916),lEsoh:function(a,r){return a&r},QNuXo:function(a,r){return a&r},kIgtC:function(a,r){return a>>>r},myGRA:function(a,r){return a&r},tRpzp:function(a,r){return a+r},xzCNw:function(a,r){return a>>>r},eVTGu:function(a,r){return a|r},EMpDD:function(a,r){return a|r},RvjBu:function(a,r){return a!==r},tsDfH:function(a,r){return a===r},qewKP:function(a,r){return a>>>r},dtyFU:function(a,r){return a===r},gAtDr:function(a,r){return a===r},QasMt:function(a,r){return a>>>r},FJbho:function(a,r){return a&r},EDJGV:function(a,r){return a&r},KrsaF:function(a,r){return a>>>r},GWdcS:function(a,r){return a&r},EeaBh:function(a,r){return a>>>r},mHUJL:"5|3|0|4|"+t(1797),pxCBr:t(1625)+t(1308)+"R",MRTrn:"OPEN_ERROR",jUgGG:t(524)+t(1024),lnynF:t(474)+t(1282),EJPqP:function(a,r){return a!==r},PgfwD:"UiGGs",wWgHU:function(a,r){return a&r},OisTX:function(a,r,s,l){return a(r,s,l)},tnrYW:function(a,r){return a<<r},QprAf:function(a,r){return a>>>r},YFmrQ:function(a,r){return a<<r},fpuTN:function(a,r){return a<r},rkJjr:t(1103),aGmSD:t(1743),EAwRI:function(a,r){return a===r},orLkS:t(751),TuLgE:t(624),RsRgy:function(a,r){return a>r},Zwmrh:t(1007)+t(1166),epwEZ:function(a,r){return a+r},JRNNv:function(a,r){return a+r},QKCYM:function(a,r){return a===r},Vmuqc:function(a,r){return a+r},bnMoV:function(a,r,s,l){return a(r,s,l)},iiqfy:function(a,r){return a+r},MrABM:t(722),kCRJq:function(a,r){return a===r},oYQPc:function(a,r){return a+r},DzTnT:"kJMWc",nYrAU:t(971),LuPsm:function(a,r){return a+r},QikGJ:function(a,r){return a+r},FVJyL:"LWviE",TSCpw:function(a,r,s){return a(r,s)},LPLpp:t(962),MhpGY:function(a,r,s){return a(r,s)},taVCV:t(530),xqoha:function(a,r,s){return a(r,s)},DNbcL:function(a,r,s){return a(r,s)},Emwav:t(967),vHaBD:function(a,r){return a!==r},intYe:function(a,r){return a===r},KZbRH:t(821),yOvpf:"KndYc",WJSfX:function(a,r,s){return a(r,s)},ZgBWe:function(a,r){return a instanceof r},lEPZB:function(a,r){return a(r)},IylIK:t(861)+"or",yNDMo:"kwLzr",rymSi:function(a,r){return a!==r},Ngdit:t(1043),JGutJ:function(a,r){return a||r},GsTyF:"undefined",pGojf:t(1891)+"4",cFvcK:function(a,r){return a!=r},YNYJS:t(557)+"alled multiple t"+t(1388)+"process",gotdC:function(a,r){return a+r},FnlyP:function(a,r){return a>>r},jYrER:t(783),flHYa:"NZIfJ",qOKQV:function(a,r){return a<r},UrPlQ:t(1225),extrO:t(897),BPDZV:function(a,r){return a+r},NUaIu:function(a,r){return a<r},cROOQ:function(a,r){return a<r},wMBuT:function(a,r){return a<=r},zvkzb:function(a,r){return a<r},HZeMx:function(a,r){return a|r},UZsXf:function(a,r){return a<<r},oOHgk:function(a,r){return a-r},JhvJV:function(a,r){return a<<r},BCcQU:function(a,r){return a&r},pIbFQ:function(a,r){return a<<r},zJaTi:function(a,r){return a&r},zATwX:function(a,r){return a&r},VdZHM:function(a,r){return a>>r},VkJII:function(a,r){return a+r},hbKch:function(a,r){return a&r},RlmRm:function(a,r){return a(r)},eKpFM:t(1815)+"reason",mxTgJ:t(1553),HoPta:t(972),NMsFr:t(1847)+"ack=fron"+t(550)+"P",lhTSI:function(a,r){return a&r},bPQiN:function(a,r){return a>>>r},VvciS:t(1402),OBVki:function(a,r){return a<r},jDoEe:function(a,r){return a===r},kZTab:function(a,r){return a&r},XXIds:function(a,r){return a+r},LGnAx:t(968),eUaxT:function(a,r){return a&r},fvWEq:function(a,r){return a>>r},WwAbZ:function(a,r){return a|r},EyNjT:function(a,r){return a>>r},TOvAN:function(a,r){return a|r},uhROx:function(a,r){return a&r},hNRdT:function(a,r){return a|r},EQOGu:function(a,r){return a|r},gVizl:function(a,r){return a>>r},jApLD:function(a,r){return a&r},bGlSL:function(a,r){return a|r},cLcVv:function(a,r){return a==r},AnBLK:function(a,r){return a!==r},sHDzc:t(1803),pbeEq:t(1883),jMUMW:function(a,r){return a(r)},uNhXI:t(1873),NTPNp:function(a,r){return a!=r},cesxO:t(488),XmCAo:t(1536),zPpWr:t(1841),KEorC:t(1394)+t(1252),UtpJZ:"oENkn",UHaEC:function(a,r){return a>r},GopLH:"XDYOn",iOUZw:"ZrAzs",ZFPzf:t(853),ibNfx:function(a){return a()},gsfHz:function(a,r,s,l){return a(r,s,l)},gIvcM:"dhIbP",ouZtD:t(467),ikVVI:t(1400),HGedN:function(a,r){return a!==r},CAHeE:"rLPUu",AZRig:t(839),FGcAY:t(1494),rMsor:function(a,r){return a!==r},JHjzS:t(1389),LAiLS:function(a,r){return a||r},aWZGn:function(a,r){return a||r},UoVzl:function(a,r){return a!==r},dJvYs:t(1852),mXNJm:function(a,r){return a||r},cTKpx:t(1735),rfdWm:t(1122),HXNqo:"pagehide",SgVzZ:t(656),NLivR:function(a,r){return a===r},msmkF:t(1338),CsXMC:function(a,r,s){return a(r,s)},XxTrb:t(1628),imFbo:function(a,r){return a!==r},KmmeK:function(a,r){return a!==r},KDCbM:function(a,r){return a===r},kAQMA:"fcKto",ewIfT:function(a,r){return a!=r},hrWVa:function(a,r){return a||r},nxlVj:function(a,r,s){return a(r,s)},InZUM:t(1526),VLFhY:function(a,r){return a(r)},PuFeO:function(a,r,s,l){return a(r,s,l)},klzfF:t(1374)+"er_qos",iMbMA:function(a,r,s,l){return a(r,s,l)},nWEzo:function(a,r,s,l){return a(r,s,l)},ZfIsQ:t(1374)+t(716)+"k",onLei:t(1374)+t(1439)+t(1263),TSNLE:function(a,r){return a===r},kRLvp:"function",Xrjyo:function(a,r){return a(r)},mtmHH:function(a,r){return a instanceof r},xhblW:function(a,r,s){return a(r,s)},xsNFF:"eHPzn",FSsIi:"need_ack",fVWdG:"is_ack",IDBpJ:function(a,r){return a&&r},gpdDK:t(1344),OYwOW:function(a){return a()},TwSLY:t(1941)+t(1783),lskjg:function(a,r){return a===r},WDLae:t(1650),uKIKL:t(1532),YphOj:t(1295),Ygzah:"received",uYbqf:t(917),xajgm:t(1760),MZpqY:function(a,r){return a(r)},GgNFa:function(a,r){return a(r)},pBKQg:"JnVBJ",uNdOT:"text/plain;chars"+t(1336),losCv:t(1668)+"ion/json",DOYrS:t(1668)+"ion/json"+t(1792)+t(1353),TtDGL:"binary",OonsR:function(a,r,s,l){return a(r,s,l)},ahGOf:"YafIo",rehpP:function(a,r){return a<r},VtvMY:function(a,r){return a+r},RYJQO:function(a,r){return a||r},HfxjF:function(a,r){return a>>>r},ebeUq:function(a,r){return a(r)},mllkt:function(a,r){return a+r},aaTOT:t(1943)+t(1032)+t(765),zOLAL:t(1125),qDwCt:t(1094),bQrdA:function(a,r){return a>r},agQZi:function(a,r){return a!==r},ynJRu:"gQnXH",JSIhJ:function(a,r,s,l){return a(r,s,l)},nGzCC:function(a,r){return a+r},EgouJ:function(a,r){return a&r},DFXkK:function(a,r){return a===r},WtaQZ:t(644),jvcmM:function(a,r){return a>>>r},gaWaD:function(a,r){return a<<r},EzWog:function(a,r){return a+r},SeXNJ:function(a,r,s,l){return a(r,s,l)},CyOqQ:function(a,r){return a<r},rzZGw:function(a,r){return a+r},VXxnw:function(a,r){return a<<r},dDdOS:function(a,r){return a<<r},LFqek:function(a,r){return a+r},csYba:function(a,r){return a+r},coCDZ:function(a,r){return a+r},ZKlNv:function(a,r){return a|r},xvgAJ:function(a,r){return a+r},zuGpP:function(a,r){return a<<r},rlYdL:function(a,r){return a<<r},YsCIT:function(a,r){return a+r},RdMCo:function(a,r){return a&r},ZmLco:function(a,r){return a+r},BSrRK:function(a,r){return a>>>r},pEjTg:function(a,r){return a+r},JmGvK:function(a,r){return a&r},QUHht:function(a,r){return a>>>r},TFwHm:function(a,r){return a&r},foDsd:function(a,r){return a>>>r},hTjdY:function(a,r){return a+r},DXmYf:function(a,r){return a&r},KGEAT:function(a,r){return a(r)},ZvJpk:t(1672),MprRe:t(668),QPYxO:function(a,r){return a>>>r},YwNXS:function(a,r){return a&r},nHTPj:function(a,r){return a|r},cblrA:function(a,r){return a>>>r},lscsc:function(a,r){return a<<r},sicEF:function(a,r){return a&r},rNclZ:function(a,r){return a<r},lblit:function(a,r){return a|r},EWxgD:function(a,r){return a<<r},IvWuA:function(a,r){return a<r},voxwM:function(a,r){return a|r},GcgvK:function(a,r){return a>>>r},BAewt:function(a,r){return a|r},LwHVJ:function(a,r){return a<<r},aqtWS:function(a,r){return a|r},OkLFT:function(a,r){return a>>>r},zqTRH:function(a,r){return a&r},cXxOX:function(a,r){return a|r},YTxYo:t(1689),FfFwr:function(a,r,s,l){return a(r,s,l)},vDGoG:function(a,r){return a<r},LqGqE:function(a,r){return a+r},zPkck:function(a,r){return a(r)},bRXrD:function(a,r){return a&r},udlFe:t(1937)+t(748)+t(661),wJXyo:t(457),ntQoe:function(a,r,s,l){return a(r,s,l)},cbeys:t(1268)+t(1775),VCDgG:t(1194),IcOBy:t(1329)+t(597),owfIi:"name",opqDk:function(a,r,s,l){return a(r,s,l)},yRZJu:function(a,r,s,l){return a(r,s,l)},zECwV:t(1407),UcFGH:t(1595),IUIQA:function(a,r){return a(r)},JZkDF:t(1271),LDRro:t(1274),fTQwQ:t(608),hXtLv:function(a,r,s){return a(r,s)},fkMwA:function(a,r,s){return a(r,s)},YOgUk:function(a,r,s){return a(r,s)},UxqBw:function(a,r,s,l){return a(r,s,l)},GlCOt:t(688)+t(930),VCUDF:t(890)+t(667),YibKC:t(990)+t(640),AIGRr:"allCursorValues",GSIsu:t(1235),lsmcF:t(1413),oedBn:function(a,r,s,l){return a(r,s,l)},meDxK:function(a){return a()},wmhIi:"setdb",OZPKE:function(a,r){return a(r)},BVgbu:"setcursor",ohhLr:t(1101),XIAqK:t(1597),kTXLq:function(a,r){return a===r},bmUTo:function(a,r){return a===r},KRqHw:"always",dknrB:function(a,r,s,l){return a(r,s,l)},cuiek:t(742),BgCwu:function(a,r){return a||r},WMHYZ:function(a,r){return a>>>r},uMCar:t(746),qlFOS:function(a,r,s){return a(r,s)},lhcFb:function(a,r){return a(r)},cNtlK:t(1374)+t(1598),eMHKS:"x-msg-qos",iSoGk:function(a,r,s){return a(r,s)},ykCWZ:"x-msg-cu"+t(629)+"e",hQjDp:function(a,r){return a(r)},pKfBI:function(a,r,s){return a(r,s)},ljQLP:function(a,r){return a>r},smBkS:t(578),itFcQ:function(a){return a()},MFuoO:function(a,r){return a<r},FVcdA:"Ytakq",AQomy:t(1892),tNpDj:function(a){return a()},rZOzZ:function(a,r){return a(r)},YSeFE:function(a,r){return a&r},GDGQs:function(a,r){return a!==r},MKJGu:t(1935),nqxdb:function(a,r){return a===r},KQJHG:function(a,r,s){return a(r,s)},DdluT:function(a){return a()},ThlVs:function(a){return a()},ypXZj:"send_ack",sTOeA:"lAyBR",mPQQz:t(1087),Empwi:function(a,r){return a!==r},LVtMJ:t(1596),rvPne:function(a,r,s){return a(r,s)},GXdZT:function(a,r){return a===r},QoSpN:function(a,r){return a===r},tPlGE:t(873)+t(1019)+"s",ANxQn:function(a,r,s){return a(r,s)},vPjFX:t(1571),OjNdt:function(a,r,s,l){return a(r,s,l)},dgLQK:function(a,r,s){return a(r,s)},CEilv:"ping_onc"+t(1437)+"t",pOOGl:function(a,r,s){return a(r,s)},upkmn:function(a,r){return a!==r},zzvXo:"bye",CyWra:"arraybuf"+t(529),gWYVf:t(1134),WzoKl:"auto",OtQsR:"please p"+t(636)+t(571),aWTUJ:t(1467)+"rovide ws params"+t(1193)+t(1382)+t(1167)+t(1936)+t(566),YmIEI:"hvLiC",wpnOY:t(796),RDUGs:"message",fjkzn:t(1856),jiYIx:t(1772)+t(574)+t(1183)+"ct",GdPap:function(a,r){return a>=r},CsYgI:function(a,r){return a+r},VlAxB:function(a,r){return a<<r},pCiAr:function(a,r){return a<r},VbnnF:function(a,r){return a===r},RdJZA:t(1691),mAAkX:t(1593),ahUFc:function(a,r){return a!==r},PHzXa:function(a,r){return a!==r},sfElP:t(1061),uuXfy:"https:",ZoREU:t(1651),eoCXa:"ws://",WAPWg:t(1831),mhHYl:t(1467)+t(1e3)+"ddID, deviceID or ttwID",infTt:function(a,r,s){return a(r,s)},fwpbF:"web",XtSdS:t(1799)+"0",InApd:function(a,r){return a&r},bucKS:function(a,r){return a&r},oVeos:function(a,r){return a>>>r},NNXwg:function(a,r){return a|r},GzFYx:function(a,r){return a&r},axczi:function(a,r){return a!==r},ZRzmJ:"tBctk",rftpg:t(1229),DYnDI:function(a,r,s){return a(r,s)},XmzXX:function(a,r){return a(r)},aVIgI:function(a,r){return a(r)},UvwBg:function(a,r){return a*r},ATcNg:function(a,r){return a===r},RDZKn:function(a,r,s){return a(r,s)},gFxUF:t(889),pzckb:t(1386),vvqlC:t(1656),oOiTA:t(1811)+t(1915)+t(1034)+t(881)+t(1778),SJHTE:function(a,r){return a(r)},uWwsj:t(1431),FvaaY:t(1635)+" try rec"+t(650)+"g",vhnoJ:function(a,r){return a===r},cKjyf:t(1257),QBqpr:"dylGK",ychzm:function(a,r,s,l){return a(r,s,l)},ELwVR:function(a,r,s){return a(r,s)},SlvFE:function(a,r){return a!==r},fzFMt:t(1179),GcUYe:t(1811)+t(1611)+t(562)+t(1071),bkdQC:t(1045),CoIhL:t(1090),RSJeZ:t(669),IvbfP:function(a,r){return a!==r},cEjcU:t(1872),pyICN:t(1609),YmHIj:function(a,r){return a===r},Gpeog:t(840),xBBKq:function(a,r){return a(r)},GALYI:function(a,r){return a|r},caABY:function(a,r){return a/r},Dprvb:function(a,r){return a===r},aAKHO:t(938),iPzdE:t(1377),rjycQ:function(a,r){return a+r},gydyF:function(a,r){return a!==r},cwBSV:t(1037),oELcH:t(1784),ETkuN:t(1751)+"7|4|3|2",eqLan:function(a,r){return a===r},qXnnp:"close, w"+t(1230)+t(1614)+t(1188)+"ed",vDRgl:t(510),ajsDX:function(a,r){return a==r},PaQlJ:t(1467)+t(1929)+t(1849)+t(601)+t(1616)+t(1764)+t(1463)+t(469)+"ffer",PxCcq:t(1618),EVkVZ:function(a,r){return a!=r},YKtQZ:function(a,r){return a instanceof r},YwQOy:t(1467)+t(1929)+" valid s"+t(597),tbQtU:function(a,r){return a instanceof r},PHnrc:function(a,r){return a instanceof r},KgsuY:function(a,r){return a(r)},KzBXt:function(a,r){return a===r},eaxJp:t(991),qHFTJ:function(a,r){return a!==r},NlBem:function(a,r){return a||r},fKAnR:function(a,r){return a==r},MjxdT:function(a,r){return a!==r},SeeiJ:t(1425)+t(752)+t(1099),twYsv:"kOapR",ssTWc:t(740)+"4",Atwhi:function(a,r){return a!==r},fhjwL:t(723),cWFgW:function(a,r){return a/r},zfQap:function(a,r){return a!=r},fTyno:t(616),CszIX:function(a,r){return a===r},bpZvm:t(1496),oVAwA:t(1292)+t(521)+t(523)+"pe",abgpf:function(a,r){return a!=r},NFJQf:function(a,r){return a===r},SaeRq:function(a,r){return a==r},zJGiA:function(a,r){return a!=r},FPPXV:t(754)+t(1146)+t(1796),cZnsT:function(a,r){return a!=r},KAeTd:function(a,r){return a!=r},tTGMc:function(a,r){return a===r},bLAAx:t(764)+t(753)};Ft.r(De),Ft.d(De,{FWS:()=>zg,CustomErrorEvent:()=>ll,createCloseEvent:()=>_t,ReconnectEvent:()=>dl,createErrorEvent:()=>lt,decodedFrame:()=>rn,createOpenEvent:()=>gl,CustomCloseEvent:()=>ul,createReconnectEvent:()=>ba,FrontierMessageEvent:()=>hl,encodeFrame:()=>Ut,createMessageEvent:()=>pl,OpenEvent:()=>xl,ErrorCode:()=>on,Event:()=>rr,MessageEvent:()=>fl});let n="";function i(a=""){let r=t,s="02",l=""+Date[r(926)](),h=n||(n=f(a)),g=Math[r(1390)]()[r(1786)](16)[r(1191)](-6);return e[r(709)](e[r(934)](s+l,h),g)}function o(){let a=t;return e.GjwPJ(1e4*Date[a(926)](),Math[a(904)](e[a(1432)](1e4,Math[a(1390)]())))}function c(a){let r=t;return e.GdXuR(e[r(720)](Array,8)[r(1779)]("0"),parseInt(a,10).toString(2)).slice(-8)}function d(a){let r=t;return e.GjwPJ(e[r(994)](Array,4)[r(1779)]("0"),e[r(1433)](parseInt,a,2)[r(1786)](16)).slice(-4)}function u(a){let r=t,s=a[r(1017)](/\./).map(g=>c(g)),l=[];return l[0]=d(e[r(1832)](s[0],s[1])),l[1]=d(s[2]+s[3]),[e[r(645)],e[r(645)],"0000",r(1761),e[r(645)],e.qRDpg,l[0],l[1]][r(1779)]("")}function f(a){let r=t,s=/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/[r(761)](a),l=/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/[r(761)](a);return s?e[r(720)](u,a):l?e[r(994)](x,a):e.oyqXb}function x(a){let r=t,s="",l=[],h=0,g=0,w=!0,S=r(1761);if(e[r(960)](a[r(1718)]("::"),-1)){let p=a[r(1017)]("::");for(let O=0;O<p[r(1079)];O++){let M=p[O];if(M[r(1718)](":")>0)if(e[r(966)](e[r(793)],e[r(793)])){let U=M.split(":");w&&(h=U[r(1079)]),g+=U[r(1079)];for(let H=0;e[r(1366)](H,U[r(1079)]);H++)if(e[r(672)](4,U[H][r(1079)])){let W=S[r(820)+"g"](0,e[r(1944)](4,U[H][r(1079)])),he=W[r(1567)](U[H]);l[r(1807)](he)}else l.push(U[H]);w=!1}else{let U=this._qosDB[r(679)](this[r(982)]),H=_0x293171[r(1669)](U||"{}");return H[_0xb2728c||_0x5c69be[this[r(1881)]]]=_0x2564e9,this[r(1687)].setItem(this[r(982)],_0x41cfd7[r(513)+"y"](H)),_0x1ccb4c||_0x47d36a[this._pathKey]}else{if(e[r(672)](4,M.length)){let U=S[r(820)+"g"](0,e[r(1944)](4,M[r(1079)])),H=U[r(1567)](M);l[r(1807)](H)}else l.push(M);w&&(h+=1),g+=1,w=!1}}let T="";for(let O=0;e[r(726)](O,e[r(1944)](8,g));O++)T=T[r(1567)](S);for(let O=0;O<l.length;O++)e.IjOtS(O,h)?(s=s[r(1567)](T),s=s.concat(l[O])):s=s[r(1567)](l[O]);return s}{let p=a[r(1017)](":");for(let T=0;T<p[r(1079)];T++)if(e[r(1525)]==="yrLiA"){let O=p[T];if(e[r(672)](4,p[T].length)){let M=S[r(820)+"g"](0,e[r(1777)](4,p[T][r(1079)])),U=M[r(1567)](O);s=s[r(1567)](U)}else s=s.concat(O)}else{if(this._options["disableA"+r(466)+r(1813)]||this[r(1384)+r(1484)])return;this["_handleR"+r(752)]()}return s}}function m(a,r){let s=t,l=a.key;e[s(672)](void 0,l)&&(me(r,10),e[s(1480)](z,r,l));let h=a[s(1482)];e[s(672)](void 0,h)&&(e[s(490)](me,r,18),z(r,h))}function _(a){let r=t,s={};e:for(;!e.leKBi(J,a);){let l=e[r(720)](ge,a);switch(e[r(1145)](l,3)){case 0:break e;case 1:s[r(830)]=e[r(1705)](R,a,ge(a));break;case 2:s[r(1482)]=e[r(1705)](R,a,e[r(1754)](ge,a));break;default:P(a,7&l)}}if(e.pWxOd(void 0,s[r(830)]))throw new Error(e[r(482)]);if(s[r(1482)]===void 0)throw new Error(e[r(1304)]);return s}function v(a){let r=t,s=e.yQslk(C);return y(a,s),e[r(1232)](B,s)}function y(a,r){let s=t,l=a[s(959)];e[s(672)](void 0,l)&&(e[s(1361)](me,r,8),e.ScGlC(wt,r,l));let h=a[s(1430)];e[s(1602)](void 0,h)&&(e.CWtjV(me,r,16),e[s(1418)](wt,r,h));let g=a[s(457)];e.bWClB(void 0,g)&&(me(r,24),e.JEUNi(wt,r,e[s(720)](D,g)));let w=a.method;e[s(827)](void 0,w)&&(e[s(1433)](me,r,32),wt(r,e[s(720)](D,w)));let S=a[s(1479)];if(e[s(1750)](void 0,S))for(let he of S){e.JEUNi(me,r,42);let cn=e[s(1659)](C);e[s(490)](m,he,cn),e[s(1480)](me,r,cn.limit),j(r,cn),L(cn)}let p=a[s(680)+s(1003)];p!==void 0&&(e[s(1643)](me,r,50),e.KPCxj(z,r,p));let T=a[s(841)+s(1771)];e[s(672)](void 0,T)&&(e.KPCxj(me,r,58),e.apXiA(z,r,T));let O=a[s(1180)];O!==void 0&&(e.iIdAt(me,r,66),e[s(490)](me,r,O[s(1079)]),ae(r,O));let M=a[s(577)];e.gydal(void 0,M)&&(e[s(1480)](me,r,74),z(r,M));let U=a["serverTi"+s(1554)];U!==void 0&&(e[s(1643)](me,r,82),e.apXiA(z,r,U));let H=a[s(1521)];e.tBdew(void 0,H)&&(e[s(1643)](me,r,90),e.XsYNM(z,r,H));let W=a[s(1707)+"e"];e.tVLLR(void 0,W)&&(e[s(773)](e.VLNKA,e[s(659)])?this[s(1817)]&&this[s(1817)][s(1170)]({code:_0x568321,reason:_0x448842}):(me(r,96),e[s(1418)](wt,r,D(W))))}function b(a){return e[t(1232)](I,F(a))}function I(a){let r=t,s={};e:for(;!e.oPQYT(J,a);)if(e[r(827)](e.Zxxwc,r(1886))){let l=e[r(970)](ge,a);switch(e.GFktD(l,3)){case 0:break e;case 1:s[r(959)]=e.vDUhe(kt,a,!0);break;case 2:s[r(1430)]=e[r(1612)](kt,a,!0);break;case 3:s[r(457)]=ge(a);break;case 4:s.method=e[r(720)](ge,a);break;case 5:{if(e[r(479)](e[r(506)],e.RxFhC))return new _0x22017b(_0x5043e0);{let h=e.lXEGq(A,a);(s.headers||(s[r(1479)]=[]))[r(1807)](_(a)),a[r(1401)]=h;break}}case 6:s["payloadE"+r(1003)]=e.iIdAt(R,a,ge(a));break;case 7:s[r(841)+"ype"]=e.CWtjV(R,a,e[r(720)](ge,a));break;case 8:s.payload=e.Evpfo(oe,a,e[r(806)](ge,a));break;case 9:s[r(577)]=R(a,e.JKOVJ(ge,a));break;case 10:s[r(537)+r(1554)]=e[r(1947)](R,a,e[r(720)](ge,a));break;case 11:s[r(1521)]=e[r(490)](R,a,ge(a));break;case 12:s[r(1707)+"e"]=e[r(974)](ge,a);break;default:e[r(1579)](P,a,e[r(1953)](7,l))}}else return this._qosDB?.[r(1197)];if(e[r(606)](void 0,s[r(959)]))throw new Error(r(1445)+r(1150)+r(1836)+r(959));if(e[r(528)](void 0,s[r(1430)]))throw new Error(r(1445)+"required"+r(1836)+r(1430));if(e[r(606)](void 0,s[r(457)]))throw new Error("Missing "+r(1150)+r(1836)+r(457));if(e[r(1562)](void 0,s.method))throw new Error(e[r(1369)]);return s}function A(a){let r=t;if(e[r(570)](r(1259),r(1333))){let s=e.QZHps(ge,a),l=a[r(1401)];return a[r(1401)]=a[r(782)]+s,l}else{if(this[r(1384)+r(1484)]=!0,this[r(898)+"mer"](),this[r(733)+r(1436)](),this[r(1423)+r(544)+r(1261)](),this[r(1528)+r(1046)]?.[r(1709)](),!this[r(986)])return void this[r(1630)](r(1859)+"s instan"+r(1614)+"nitialized");if(this[r(986)][r(1076)+"te"]===this[r(522)]||e[r(528)](this._ws[r(1076)+"te"],this[r(1927)]))return void this[r(1630)](e[r(949)]);this[r(1632)+r(1542)+"t"](_0x213858,_0x18a44b)}}function P(a,r){let s=t;switch(r){case 0:for(;e[s(1953)](128,e.Ndtkh(te,a)););break;case 2:Z(a,ge(a));break;case 5:e[s(1391)](Z,a,4);break;case 1:e[s(1361)](Z,a,8);break;default:throw new Error(e[s(1842)](e[s(902)],r))}}function D(a){let r=t;return a|=0,{low:a,high:e[r(627)](a,31),unsigned:e.irUkm(a,0)}}let E=[];function C(){let a=t,r=E[a(911)]();return r?(r[a(782)]=r.limit=0,r):{bytes:new Uint8Array(64),offset:0,limit:0}}function L(a){E.push(a)}function F(a){let r=t;if(e[r(1256)](e[r(625)],e[r(1341)]))return{bytes:a,offset:0,limit:a.length};this[r(1747)+"steners"]()}function B(a){let r=t,s=a.bytes,l=a[r(1401)];return e.OqxYz(s[r(1079)],l)?s:s[r(984)](0,l)}function Z(a,r){let s=t;if(a[s(782)]+r>a[s(1401)])throw new Error(e[s(1307)]);a[s(782)]+=r}function J(a){let r=t;return e[r(1866)](a[r(782)],a[r(1401)])}function ie(a,r){let s=t;if(e[s(966)](e[s(1339)],e[s(1339)])){let l=a[s(1726)],h=a[s(782)],g=a[s(1401)],w=e[s(1105)](h,r);if(e.IMVxS(w,l.length)){let S=new Uint8Array(2*w);S[s(940)](l),a[s(1726)]=S}return a[s(782)]=w,e[s(960)](w,g)&&(a[s(1401)]=w),h}else return!!this[s(1687)]}function Q(a,r){let s=t,l=a.offset;if(e[s(1861)](e.Svaco(l,r),a[s(1401)]))throw new Error(e[s(1044)]);return a[s(782)]+=r,l}function oe(a,r){let s=t,l=e.pCtHf(Q,a,r);return a[s(1726)][s(984)](l,e[s(1800)](l,r))}function ae(a,r){let s=t,l=e.VKNCG(ie,a,r[s(1079)]);a[s(1726)].set(r,l)}function R(a,r){let s=t,l={IuEEp:function(T,O){return e[V(1824)](T,O)},qBGiL:function(T,O){return e[V(528)](T,O)},uGXpJ:e.DipNV,YwJLx:function(T,O){return T===O},YPDRY:"store",wpyOt:function(T,O){return T(O)}},h=e[s(1613)](Q,a,r),g=String["fromChar"+s(771)],w=a.bytes,S="\uFFFD",p="";for(let T=0;e[s(726)](T,r);T++){let O=w[T+h],M,U,H,W;if(e[s(528)](e[s(1558)](128,O),0))p+=e[s(806)](g,O);else if((224&O)===192)if(e[s(929)](e[s(1216)](T,1),r))p+=S;else{if(e.wzdrM(e[s(1700)],s(920)))return RazDsA[s(795)](_0x28de10,_0x158571)&&(RazDsA.qBGiL(_0x50a9e7,RazDsA[s(1097)])||RazDsA[s(1279)](_0x4aab55,RazDsA[s(706)]))?!0:_0x582752 in _0x3f4f8b;M=w[T+h+1],e.HpWAy(192,M)!==128?p+=S:(W=e[s(1027)](e.ZxjsT(e[s(539)](31,O),6),e[s(1753)](63,M)),e[s(599)](W,128)?p+=S:(p+=e.mUCGl(g,W),T++))}else if(e[s(1558)](240,O)==224)e[s(1866)](T+2,r)?p+=S:(M=w[T+h+1],U=w[e[s(1454)](e[s(1833)](T,h),2)],e[s(672)](e[s(1027)](M,e.PzkIv(U,8))&49344,32896)?p+=S:(W=e[s(496)](e[s(1310)](e[s(1196)](15,O),12),e[s(1897)](e[s(1753)](63,M),6))|63&U,e[s(1366)](W,2048)||e[s(1380)](W,55296)&&e[s(489)](W,57343)?p+=S:(p+=e[s(1564)](g,W),T+=2)));else if(e[s(1664)](e[s(1123)](248,O),240))if(e[s(1207)](T+3,r))p+=S;else if(M=w[e.FjNis(T+h,1)],U=w[e[s(1516)](e[s(1311)](T,h),2)],H=w[e[s(1464)](e[s(1216)](T,h),3)],e[s(683)](e[s(1123)](e[s(1027)](M,e[s(1310)](U,8))|e.ifAgU(H,16),12632256),8421504))p+=S;else if(e[s(528)]("NJlPo","NJlPo"))W=e[s(1027)](e[s(1897)](7&O,18)|e.gDyhz(e.aHvAN(63,M),12),e[s(1451)](e.ObFlT(63,U),6))|e[s(1123)](63,H),e[s(1203)](W,65536)||e[s(960)](W,1114111)?p+=S:e.ALWTk!==e[s(835)]?(W-=65536,p+=e.XsYNM(g,e[s(1842)](e[s(627)](W,10),55296),e[s(915)](1023&W,56320)),T+=3):(l[s(619)](_0xcadab2,this[s(579)+s(1565)+"Id"]),_0x5a978c(this[s(592)+s(1720)+s(1345)]),this[s(579)+"gTimeoutId"]=null,this["_reconne"+s(1720)+s(1345)]=null);else return e[s(1315)](_0x45d474,_0x700100(_0xf6a7ed));else p+=S}return p}function z(a,r){let s=t,l={ANHxz:function(p,T){return p||T}},h=r[s(1079)],g=0;for(let p=0;e[s(1366)](p,h);p++){let T=r[s(1641)+"At"](p);e[s(1380)](T,55296)&&e.VWAjs(T,56319)&&e[s(532)](e.PAEth(p,1),h)&&(T=e[s(1944)](e[s(1832)](e.oBfAl(T,10),r[s(1641)+"At"](++p)),56613888)),g+=T<128?1:e[s(1313)](T,2048)?2:T<65536?3:4}e[s(903)](me,a,g);let w=e[s(1588)](ie,a,g),S=a[s(1726)];for(let p=0;e[s(599)](p,h);p++)if(s(1226)!==e[s(807)]){let T=r[s(1641)+"At"](p);if(e[s(1376)](T,55296)&&T<=56319&&e[s(1366)](p+1,h)&&(T=e[s(1944)](e[s(1105)](T<<10,r.charCodeAt(++p)),56613888)),T<128)S[w++]=T;else{if(e[s(1591)](T,2048))S[w++]=e.DxTMP(T,6)&31|192;else if(e.JeWMN(e.gGXdp,e[s(1185)]))T<65536?S[w++]=e[s(627)](T,12)&15|224:(S[w++]=e[s(1048)](e.BdTSm(T>>18,7),240),S[w++]=e[s(1309)](e[s(627)](T,12)&63,128)),S[w++]=e[s(1469)](e[s(1696)](e[s(627)](T,6),63),128);else{let O=this[s(1687)][s(520)+s(585)](this._prefix),M=_0x3b1410[s(1669)](l[s(1416)](O,"{}"));return M[_0x249811||_0x3fab4b[this._pathKey]]=_0x1903f4,this[s(1687)][s(1428)+"geSync"](this[s(982)],_0x21ff5c[s(513)+"y"](M)),_0x2f147f||_0x7f9317[this[s(1881)]]}S[w++]=e[s(1309)](e[s(1558)](63,T),128)}}else{let{initReconnectInterval:T,maxReconnectInterval:O,reconnectIntervalGrowFactor:M}=this[s(736)],U=T*_0x3a9058.pow(M,_0x57f65a-1);return U>O?O:U}}function j(a,r){let s=t,l=e[s(1356)](ie,a,r.limit),h=a[s(1726)],g=r[s(1726)];for(let w=0,S=r[s(1401)];e.fWvxT(w,S);w++)h[e[s(915)](w,l)]=g[w]}function te(a){let r=t;return a[r(1726)][e[r(652)](Q,a,1)]}function Je(a,r){let s=t;if(e[s(606)](e[s(1472)],e.DFwdn)){let l=_0x330a1b[_0x278de1];if(e[s(1750)](4,_0x2715ae[_0x1fca27][s(1079)])){let h=_0x3ac733[s(820)+"g"](0,e[s(1944)](4,_0x36b338[_0x1dbd44][s(1079)])),g=h.concat(l);_0x3453b=_0x203262.concat(g)}else _0x50b5f4=_0x2baab0.concat(l)}else{let l=e[s(1643)](ie,a,1);a[s(1726)][l]=r}}function ge(a){let r=t,s=0,l=0,h;do h=e[r(1710)](te,a),e[r(1366)](s,32)&&(l|=e[r(1461)](e[r(1753)](127,h),s)),s+=7;while(e[r(728)](128,h));return l}function me(a,r){let s=t;if(e[s(479)](e[s(1905)],s(1680)))return e[s(974)](_0xac436e,_0x46247e);for(r>>>=0;r>=128;)e[s(1573)](Je,a,e[s(455)](127&r,128)),r>>>=7;Je(a,r)}function kt(a,r){let s=t,l=0,h=0,g=0,w;if(w=e[s(1754)](te,a),l=e[s(1123)](127,w),128&w&&(w=e[s(615)](te,a),l|=e[s(1310)](e.HpWAy(127,w),7),e[s(539)](128,w)&&(w=te(a),l|=e[s(1441)](127&w,14),128&w))){if(e[s(1258)]!==s(622))return this._ws?this[s(986)].extensions:"";w=e[s(504)](te,a),l|=e.PzkIv(e[s(586)](127,w),21),128&w&&(w=te(a),h=e[s(682)](127,w),128&w&&(w=e.KYYxo(te,a),h|=e.ukueg(e[s(1406)](127,w),7),e[s(675)](128,w)&&(w=e[s(1327)](te,a),h|=(127&w)<<14,e[s(682)](128,w)&&(w=te(a),h|=e[s(1406)](127,w)<<21,e[s(1157)](128,w)&&(e.dpMMq!==e.dpMMq?(_0x38a0e7=e[s(1417)](_0x13432e,_0x12d806),_0x5e5833|=e[s(1421)](127,_0x416561)<<7):(w=e[s(868)](te,a),g=e.HtVWP(127,w),e[s(1200)](128,w)&&(w=e[s(1089)](te,a),g|=e[s(1451)](e[s(847)](127,w),7))))))))}return{low:e[s(1469)](l,e.jBJcn(h,28)),high:e[s(1429)](h,4)|e[s(1461)](g,24),unsigned:r}}function wt(a,r){let s=t,l=r.low>>>0,h=e.pIhJy(r.low>>>28,e.lNZJa(r[s(1351)],4))>>>0,g=e.uGKHl(r[s(1351)],24),w=g===0?e[s(501)](0,h)?l<16384?l<128?1:2:e.LrqOK(l,2097152)?3:4:e[s(760)](h,16384)?e[s(1254)](h,128)?5:6:e[s(1313)](h,2097152)?7:8:e.jgsEm(g,128)?9:10,S=e[s(464)](ie,a,w),p=a[s(1726)];switch(w){case 10:p[S+9]=e[s(1753)](e[s(1091)](g,7),1);case 9:p[e.dQPUZ(S,8)]=e[s(643)](9,w)?128|g:127&g;case 8:p[S+7]=e[s(827)](8,w)?e[s(1491)](h,21)|128:e[s(1145)](h,21)&127;case 7:p[e[s(880)](S,6)]=e[s(570)](7,w)?e.YyJgI(e.ykOcV(h,14),128):h>>>14&127;case 6:p[e[s(1550)](S,5)]=e[s(1914)](6,w)?e[s(1469)](e[s(1429)](h,7),128):e[s(1091)](h,7)&127;case 5:p[e[s(1364)](S,4)]=e[s(927)](5,w)?e.HAChC(128,h):127&h;case 4:p[S+3]=e.IHGkf(4,w)?e[s(1552)](e.DLAFb(l,21),128):e[s(1200)](l>>>21,127);case 3:p[e[s(934)](S,2)]=e[s(1679)](3,w)?e[s(1894)](e[s(1559)](l,14),128):e.smZuL(e[s(1475)](l,14),127);case 2:p[S+1]=w!==2?e[s(712)](e[s(456)](l,7),128):e[s(1091)](l,7)&127;case 1:p[S]=e[s(848)](1,w)?e[s(1284)](128,l):e.NihjI(127,l)}}function rn(a){return e.xMSHa(b,a)}function Ut(a){return e[t(1417)](v,a)}let sn=65536,Qr=t(1759),ye=e.ioRUl(sn,sn),Te=e[t(1062)](ye,ye),nr=e[t(1538)](Te,2),Ne=String.prototype.charCodeAt;class pe{constructor(r,s,l){let h=t;this[h(1581)]=!0,this.low=e[h(678)](0,r),this.high=e[h(730)](0,s),this.unsigned=!!l}static[t(1581)](r){let s=t;return r&&e[s(484)](!0,r[s(1581)])}static[t(1879)](r,s,l){return new pe(r,s,l)}static fromBytes(r,s,l){let h=t;return l?pe["fromByte"+h(1812)](r,s):pe[h(1035)+h(1325)](r,s)}static[t(1035)+t(1812)](r,s){let l=t;return new pe(e[l(455)](e[l(496)](e[l(750)](r[0],r[1]<<8),r[2]<<16),e[l(875)](r[3],24)),e[l(1027)](e.zllRG(e[l(1653)](r[4],e[l(1267)](r[5],8)),e[l(1451)](r[6],16)),e[l(1857)](r[7],24)),s)}static[t(1035)+t(1325)](r,s){let l=t;return new pe(e.zllRG(e[l(1309)](e[l(936)](e[l(1907)](r[4],24),e.dRlHR(r[5],16)),e[l(1455)](r[6],8)),r[7]),e[l(1469)](e[l(678)](e[l(1684)](e.Iaarh(r[0],24),e[l(1267)](r[1],16)),r[2]<<8),r[3]),s)}static[t(1102)](r){let s=t;return e.BEfrF(r,Qr)?cl:new pe(e[s(944)](e[s(1552)](e[s(1048)](e[s(712)](Ne[s(1275)](r,0),e[s(948)](Ne.call(r,1),8)),e[s(534)](Ne[s(1275)](r,2),16)),e.KMPhB(Ne[s(1275)](r,3),24)),0),e[s(1491)](e[s(1704)](e[s(1704)](e.UFmhr(Ne[s(1275)](r,4),Ne[s(1275)](r,5)<<8),e[s(1912)](Ne[s(1275)](r,6),16)),e.FFKuL(Ne[s(1275)](r,7),24)),0),!0)}toHash(){let r=t;return String["fromChar"+r(771)](e[r(682)](255,this[r(582)]),e.LhwDn(e.RXUuu(this[r(582)],8),255),this[r(582)]>>>16&255,e[r(778)](this.low,24),e[r(1106)](255,this.high),e[r(847)](e[r(1144)](this[r(1351)],8),255),e[r(682)](e[r(581)](this[r(1351)],16),255),e[r(766)](this[r(1351)],24))}static[t(946)+"er"](r,s=!0){let l=t;if(e[l(475)](isNaN,r))return s?Yp:cl;if(s){if(e[l(1063)](e[l(1854)],e.aplKg)){let w=(l(1247)+"0")[l(1017)]("|"),S=0;for(;;){switch(w[S++]){case"0":return g.exports;case"1":var h=_0x5456a5[_0x29132d];continue;case"2":_0x29a8ca[_0x2a3cba](g,g[l(1906)],_0x252be4);continue;case"3":var g=_0x57dfce[_0xb187b9]={exports:{}};continue;case"4":if(h!==void 0)return h.exports;continue}break}}else if(r>=Te)return Qp}else{if(r<=-nr)return eg;if(e[l(1376)](e[l(1311)](r,1),nr))return Xp}return pe.fromBits(e[l(584)](e[l(805)](r,ye),0),e[l(800)](r,ye)|0,s)}toNumber(){let r=t;return this[r(1476)]?e.Svaco(e[r(1411)](e[r(735)](this[r(1351)],0),ye),e.DLAFb(this[r(582)],0)):e[r(1832)](e.BZMOR(this[r(1351)],ye),e[r(1945)](this[r(582)],0))}[t(1443)](){return this[t(1351)]===0&&e.fnNXm(0,this.low)}[t(1020)](r){let s=t,l={QnCkr:function(h,g,w){return h(g,w)},hBsdU:e[s(1016)]};if(e[s(1529)]("jFcyi",e[s(989)])){if(this["_endpoin"+s(1645)]?.["checkRea"+s(1368)+"es"]()){let g=this[s(1570)+s(1645)]?.[s(1147)+s(1946)+"nt"]();this._dispatchCloseEvent(l.QnCkr(_0x387a06,l[s(1928)],{code:1006,reason:"connect "+g+(s(1312)+", max re"+s(1290)+s(1446)),wasClean:!0}))}else{let g=this[s(736)][s(1034)+s(941)+"ptor"](_0x1ebf4a,_0x599858);this[s(1489)+s(1950)+s(681)](l[s(1934)](_0x4da6cc,l[s(1928)],{code:_0x271f0e,reason:_0xb6226f,wasClean:!0,willReconnect:g})),g&&this[s(631)]()}return}else{pe.isLong(r)||(r=pe.fromNumber(r));let h=e[s(581)](this[s(1351)],16),g=e[s(714)](65535,this.high),w=this[s(582)]>>>16,S=e[s(1953)](65535,this[s(582)]),p=e[s(1091)](r[s(1351)],16),T=e[s(1426)](65535,r[s(1351)]),O=e[s(1149)](r[s(582)],16),M=e[s(662)](65535,r.low),U=0,H=0,W=0,he=0;return he+=e[s(1216)](S,M),W+=he>>>16,he&=65535,W+=w+O,H+=W>>>16,W&=65535,H+=e.tRpzp(g,T),U+=e.xzCNw(H,16),H&=65535,U+=h+p,U&=65535,pe.fromBits(e[s(1119)](e[s(1862)](W,16),he),e.EMpDD(U<<16,H),this[s(1476)])}}[t(1107)](r){let s=t;return pe[s(1581)](r)||(r=pe[s(946)+"er"](r)),e[s(1243)](this[s(1476)],r.unsigned)&&e[s(925)](e[s(1939)](this[s(1351)],31),1)&&e.dtyFU(e[s(581)](r[s(1351)],31),1)?!1:e[s(606)](this.high,r[s(1351)])&&e[s(1115)](this[s(582)],r[s(582)])}[t(1205)](){let r=t;return this[r(582)]===-1&&this.high===-1?pe[r(1879)](0,0,this[r(1476)]):e[r(704)](-1,this[r(582)])?pe[r(1879)](0,e[r(1842)](this.high,1),this[r(1476)]):pe.fromBits(this[r(582)]+1,this.high,this[r(1476)])}[t(477)](r){return r?this[t(924)+"E"]():this.toBytesBE()}[t(924)+"E"](){let r=t,s=this[r(1351)],l=this[r(582)];return[255&l,e[r(675)](e[r(1140)](l,8),255),e.FJbho(l>>>16,255),e[r(944)](l,24),e[r(1136)](255,s),e[r(682)](e.KrsaF(s,8),255),e[r(1215)](e.EeaBh(s,16),255),e[r(766)](s,24)]}[t(1734)+"E"](){let r=t,s=this.high,l=this.low;return[e[r(1145)](s,24),e[r(1200)](s>>>16,255),e[r(1136)](e[r(1149)](s,8),255),e.HtVWP(255,s),e.nqnOq(l,24),e[r(1629)](l,16)&255,l>>>8&255,255&l]}}let cl=new pe(0,0,!1),Yp=new pe(0,0,!0),Xp=pe[t(1879)](-1,2147483647,!1),Qp=pe[t(1879)](-1,-1,!0),eg=pe[t(1879)](0,-2147483648,!1);var on=(function(a){let r=t,s=e[r(711)].split("|"),l=0;for(;;){switch(s[l++]){case"0":a[a[r(1625)+"IES_ERROR"]=5003]=e[r(935)];continue;case"1":return a;case"2":a[a[e[r(1828)]]=5005]=e.MRTrn;continue;case"3":a[a[e[r(734)]]=5002]=r(524)+r(1024);continue;case"4":a[a[r(474)+r(1282)]=5004]=e[r(1843)];continue;case"5":a[a[r(1330)+r(878)]=5001]="NATIVE_E"+r(878);continue}break}})({});class rr{constructor(r){let s=t;this[s(1785)]=r,this[s(891)]=null}}class dl extends rr{constructor(r,s){let l=t;if(e[l(525)](e[l(1359)],l(1708)))super(r),this[l(1699)]=s&&s[l(1699)]||null;else return this[l(1865)+l(1008)+l(901)+"t"]=1,this[l(1242)+l(854)]++,this[l(1599)+"s"][this[l(1242)+"ndex"]]}}class ll extends rr{constructor(r,s){let l=t;super(r),this[l(962)]=s&&s[l(962)]||null,this[l(1823)]=s&&s[l(1823)]||0,this[l(1054)]=s&&s[l(1054)]||"",this[l(922)]=s&&s[l(922)]||0,this[l(1699)]=s&&s[l(1699)]||"",this[l(746)]=s&&s.code||5001}}class ul extends rr{constructor(r,s){let l=t;super(r),this[l(746)]=s&&s.code||0,this[l(1572)]=s&&s[l(1572)]||"",this[l(884)]=s&&s.wasClean||!1,this[l(1415)+l(620)]=s&&s[l(1415)+l(620)]||!1}}class fl extends rr{constructor(r,s){let l=t;super(r),this[l(1888)]=s&&s[l(1888)]||null}}class hl extends fl{constructor(r,s){let l=t;super(r),this[l(1888)]=s&&s[l(1888)]||null,this[l(1699)]=s&&s[l(1699)]||null}}class xl extends rr{constructor(r,s){let l=t;super(r),this[l(1888)]=s&&s[l(1888)]||null}}function lt(a,{message:r,code:s,error:l}){return new ll(a,{message:r,code:s,error:l})}function _t(a,{code:r,reason:s,wasClean:l,willReconnect:h}){return new ul(a,{code:r,reason:s,wasClean:l,willReconnect:h})}function pl(a,{data:r,message:s}){return new hl(a,{data:r,message:s})}function gl(a,{data:r}){let s=t;if(e[s(1011)]==="bKVCD"){let l={ydFqV:s(981)+s(1547)+s(828)+"6",WemdR:function(g,w){return e[s(581)](g,w)},ruOat:function(g,w){return e[s(1231)](g,w)},LwrOG:function(g,w,S,p){return e[s(718)](g,w,S,p)},Nfjgt:function(g,w){return g<<w},DVkhi:function(g,w){return g|w},zeVCY:function(g,w){return e[s(760)](g,w)},JKpyQ:function(g,w){return e.tnrYW(g,w)},GxrHi:function(g,w){return e[s(936)](g,w)},YwbNV:function(g,w){return e[s(1363)](g,w)},INHrt:function(g,w){return e[s(1119)](g,w)},CEHFj:function(g,w){return e[s(1255)](g,w)},PAvqB:function(g,w){return e[s(952)](g,w)},JNOgM:function(g,w){return g|w}},h=4294967295;return function(g,w,S=!0){let p=s,T=l[p(852)][p(1017)]("|"),O=0;for(;;){switch(T[O++]){case"0":h=l[p(1111)](l[p(1004)](127,g[w]),0);continue;case"1":if((w+=5)>g[p(1079)])throw w=g.length,l[p(1217)](_0x30bc78,w,10,g.length);continue;case"2":h=(h|l[p(777)](l.ruOat(127,g[w]),21))>>>0;continue;case"3":if(g[w++]<128)return{value:S?h:l[p(1522)](0,h),offset:w};continue;case"4":if(l[p(1501)](g[w++],128))return{value:S?h:l[p(1522)](0,h),offset:w};continue;case"5":h=l[p(1111)](l[p(1522)](h,l.JKpyQ(l[p(1004)](127,g[w]),14)),0);continue;case"6":return{value:S?h:l[p(1522)](0,h),offset:w};case"7":if(l.zeVCY(g[w++],128))return{value:S?h:l[p(1130)](0,h),offset:w};continue;case"8":h=l.YwbNV(h|l[p(777)](127&g[w],7),0);continue;case"9":if(g[w++]<128)return{value:S?h:l[p(1130)](0,h),offset:w};continue;case"10":h=l[p(1111)](l[p(1223)](h,l[p(932)](l.ruOat(15,g[w]),28)),0);continue;case"11":if(l[p(1767)](g[w++],128))return{value:S?h:l[p(837)](0,h),offset:w};continue}break}}}else return new xl(a,{data:r})}function ba(a,{message:r}){return new dl(a,{message:r})}class ml{constructor(r,s){let l=t;this[l(1599)+"s"]=r,this.maxRetries=s,this[l(1242)+l(854)]=0,this["currentE"+l(1008)+l(901)+"t"]=0}["resetEnd"+t(732)+"fig"](){let r=t;this[r(1242)+r(854)]=0,this[r(1865)+r(1008)+r(901)+"t"]=0}resetTries(){let r=t;this[r(1865)+"ndpointT"+r(901)+"t"]=0}["getCurre"+t(1946)+"nt"](){let r=t;return this.endpoints[this[r(1242)+r(854)]]}[t(1147)+t(1946)+t(1224)+t(892)](){let r=t;return this[r(1865)+"ndpointT"+r(901)+"t"]}["checkRea"+t(1368)+"es"](){let r=t;return!!(this[r(1242)+r(854)]>=this.endpoints[r(1079)]||e.GGiyg(this["currentI"+r(854)],e.BfUxV(this[r(1599)+"s"][r(1079)],1))&&e.BEfrF(this["currentE"+r(1008)+"riesCount"],this[r(1127)+"es"]))}["checkCurrentEndp"+t(658)+"hedMaxRetries"](){let r=t;if(e[r(737)](e[r(1187)],e.TuLgE))_0x58405d[r(860)+"entListener"](r(517),_0x33a06e),_0x4943e6["removeEv"+r(1904)+r(1365)](r(962),_0x55f17c),_0x10873c[r(860)+r(1904)+"ner"](VanGqX.aGmSD,_0x1b26ee);else return e[r(1664)](this[r(1242)+r(854)],this[r(1599)+"s"].length)?!0:e[r(1576)](this[r(1865)+r(1008)+r(901)+"t"],this[r(1127)+"es"])}[t(1354)+t(1165)+t(1320)+t(1556)+"unt"](){let r=t;return this["currentE"+r(1008)+r(901)+"t"]=1,this[r(1242)+r(854)]++,this[r(1599)+"s"][this[r(1242)+r(854)]]}[t(1147)+t(1946)+t(791)+"ateCount"](){let r=t;return this["currentE"+r(1008)+"riesCount"]++,this[r(1147)+r(1946)+"nt"]()}}let ir=(e.zfQap(e.GsTyF,typeof globalThis)&&e.fTyno===globalThis[t(1173)+t(1719)][t(1775)]||e[t(1291)](e[t(621)],typeof window)&&e[t(1063)](e[t(1404)],window[t(1173)+t(1719)][t(1775)]))&&e[t(1206)](t(787)+"d",typeof document),Rn=t(787)+"d"!=typeof globalThis&&(e[t(1834)](e[t(666)],globalThis[t(1173)+"tor"].name)||e[t(1921)]===globalThis[t(1173)+t(1719)][t(1775)])&&e[t(545)](e[t(621)],typeof tt),ei=(e[t(1291)]("undefined",typeof globalThis)&&e[t(1462)](e.bpZvm,globalThis["construc"+t(1719)][t(1775)])||e.SaeRq(e[t(621)],typeof globalThis)||e[t(1206)](t(787)+"d",typeof globalThis)&&!!globalThis[t(703)+t(801)])&&e[t(621)]!=typeof wx,ti=e[t(1637)](e[t(621)],typeof globalThis)&&(e.pWxOd("Dedicate"+t(521)+t(523)+"pe",globalThis[t(1173)+t(1719)][t(1775)])||"SharedWo"+t(470)+t(670)===globalThis[t(1173)+t(1719)].name||e[t(725)](e[t(1808)],globalThis["construc"+t(1719)][t(1775)]))&&e[t(1220)](e[t(621)],typeof self),tg=e.KAeTd(e[t(621)],typeof globalThis)&&e[t(907)](t(1496),globalThis.constructor[t(1775)])&&e[t(621)]!=typeof global&&e[t(965)](t(1496),global[t(1173)+t(1719)].name)&&e[t(1220)](t(787)+"d",typeof process)&&!!process[t(1487)];class va{constructor(){let r=t;this[r(568)+"rs"]={}}[t(1721)](r,...s){let l=t,h=this[l(568)+"rs"][r];if(h)h[l(1191)]()[l(1848)](g=>g.fn.apply(g[l(638)],s));else if(r==="error"&&!this[l(1438)]){let g=s[l(1079)]&&s[0];if(e[l(1824)](g,Error))throw g;let w=new Error(e[l(1725)]+(g?e[l(1070)](e.JRNNv(" (",g[l(1699)]),")"):""));throw w.context=g,g}return this}[t(1213)](r,s){let l=t;if(e[l(1742)](void 0,r))this[l(568)+"rs"]={};else if(e.EAwRI(void 0,s))this[l(568)+"rs"][r]=null;else{let h=this[l(568)+"rs"][r];if(h)for(let g=0;e[l(1313)](g,h[l(1079)]);)h[g].fn===s?h[l(869)](g,1):++g}return this}on(r,s,l){let h=t,g={tsWeM:function(w,S){return w<S},cJIWK:function(w,S){return e.Vmuqc(w,S)},WiGPw:function(w,S,p,T){return e[V(718)](w,S,p,T)},LmKGS:function(w,S,p,T){return e[V(1015)](w,S,p,T)},DmPsU:function(w,S){return e.iiqfy(w,S)}};if(e[h(966)](e.MrABM,e[h(1298)]))return(this[h(568)+"rs"][r]||(this[h(568)+"rs"][r]=[]))[h(1807)]({fn:s,ctx:l||this}),this;{let w=(h(1160)+"3")[h(1017)]("|"),S=0;for(;;){switch(w[S++]){case"0":if(g.tsWeM(_0xda947c[h(1079)],40))return g[h(1148)](g.WiGPw(_0x7f47d7,_0x487043,_0x8381c1,_0x5a58a3),_0xb8fbbb);continue;case"1":if(_0x2dc471.write)return g[h(1148)](_0x19b23e[h(1131)](_0xd0420c,_0x36d0c5),_0x4a70e3);continue;case"2":if(!_0x44dfd3)return _0x3145b3;continue;case"3":return g[h(1148)](g[h(1868)](_0xd8a634,_0x33d231,_0x39abf2,_0x3c675a),_0x3a4ed2);case"4":if(_0x2307c9[h(1159)+"e"])return g.DmPsU(_0x51e0df.utf8Write(_0x5f1416,_0x2e20e6),_0x43c37c);continue}break}}}}class ng extends va{[t(826)+t(1917)+t(1419)](r){let s=t;return e[s(983)]!==e[s(983)]?e[s(1154)](-1,this.low)&&this[s(1351)]===-1?_0x29dabf[s(1879)](0,0,this[s(1476)]):e.GGiyg(-1,this[s(582)])?_0x57b2e4[s(1879)](0,e[s(693)](this[s(1351)],1),this[s(1476)]):_0xbe87ec[s(1879)](this.low+1,this[s(1351)],this[s(1476)]):r[s(1740)]||r[s(1340)]?(s(1900)+" "+(r.errMsg||"")+s(1582)+(r[s(1340)]||""))[s(549)]():JSON[s(513)+"y"](r)}constructor(r,s,l){let h=t;super(),this._socket=null,ei&&wx[h(1624)+h(1337)]&&(this[h(1817)]=wx[h(1624)+h(1337)]({url:r,protocols:s,header:l,fail:this[h(1678)+h(1189)+h(785)][h(1278)](this),success:this[h(1678)+"ocketSuc"+h(1075)+h(992)].bind(this)})),Rn&&tt[h(1624)+h(1337)]&&(this._socket=tt[h(1624)+h(1337)]({url:r,protocols:s,header:l,fail:this[h(1678)+h(1189)+h(785)][h(1278)](this),success:this["_createS"+h(551)+"cessHand"+h(992)].bind(this)}))}[t(1678)+t(551)+t(1075)+t(992)](){let r=t,s={ntNFA:function(l,h){return e.LuPsm(l,h)},MyVlo:function(l,h){return e.DxTMP(l,h)},WTJLx:function(l,h){return e[V(610)](l,h)},TJsog:function(l,h){return e[V(539)](l,h)}};if(r(923)!==e[r(1561)])return _0x1f5fd5[r(1941)+"oreNames"]||_0x47937a[r(1729)](_0x4c89ff);Promise[r(642)]()[r(729)](()=>{let l=r;e[l(966)](e.nYrAU,l(971))?this[l(1747)+"steners"]():(_0x2b9d6f-=65536,_0x7e94ab+=_0x40b9e3(NkCClO.ntNFA(NkCClO.MyVlo(_0x3cfedb,10),55296),NkCClO[l(1549)](NkCClO[l(1047)](1023,_0x1c4e97),56320)),_0x28c4ea+=3)})}[t(1678)+"ocketFai"+t(785)](r){let s=t;Promise[s(642)]()[s(729)](()=>{let l=s,h=e.TSCpw(lt,e.LPLpp,{message:this["_formatE"+l(1917)+l(1419)](r)});this.emit(l(962),h);let g=e[l(1506)](_t,e[l(1016)],{reason:this[l(826)+"rrorMess"+l(1419)](r)});this[l(1721)](e[l(1016)],g)})}["_addWsLi"+t(486)](){let r=t,s={HLUtO:e.Emwav,oBPtf:function(l,h,g){return e.Evpfo(l,h,g)},aWuNW:function(l,h){return l<h},kTVSI:function(l,h){return e[V(1448)](l,h)},VZCyN:function(l,h){return e[V(1234)](l,h)},tFaJg:e[r(1239)],ZaHan:r(1186),ZgDNI:"message",UxANM:function(l,h,g){return e[r(1705)](l,h,g)}};r(909)!==e[r(1870)]?this[r(1318)+r(1855)]():(this[r(1817)].onOpen(l=>{let h=r;this[h(1721)](s[h(1615)],s.oBPtf(gl,s[h(1615)],{...l,data:l[h(1740)]||""}))}),this[r(1817)][r(1617)](l=>{let h=r;if(e[h(479)](e[h(743)],e[h(743)]))this[h(1721)](e[h(1016)],e.xqoha(_t,h(1170),{...l}));else{let g=_0x361124[h(1017)](":");_0x21e8eb&&(_0x5b34d8=g[h(1079)]),_0x3e4906+=g[h(1079)];for(let w=0;yEBlVg[h(589)](w,g[h(1079)]);w++)if(yEBlVg[h(664)](4,g[w].length)){let S=_0x461423[h(820)+"g"](0,4-g[w].length),p=S.concat(g[w]);_0x15da58[h(1807)](p)}else _0x385409.push(g[w]);_0x4c8743=!1}}),this[r(1817)][r(799)+"e"](l=>{let h=r;if(s[h(462)](s[h(1302)],s[h(1360)])){let g=this._qosDB[h(520)+h(585)](this[h(982)]);return _0x4e524f[h(1669)](g||"{}")[_0x868f54]}else this.emit(s[h(1578)],s[h(518)](pl,s.ZgDNI,{...l}))}),this[r(1817)][r(1594)](l=>{let h=r;this[h(1721)](e[h(1029)],e.DNbcL(lt,e[h(1029)],{...l,message:l[h(1740)]||""}))}))}[t(969)](r){let s=t,l={fFbeB:e.LPLpp,mOyJB:function(h,g,w){return e[V(1357)](h,g,w)}};if(e[s(1619)](r,Uint8Array)){let h=r[s(1543)].slice(r[s(698)+"et"],r.byteLength+r[s(698)+"et"]);this[s(1817)]&&this[s(1817)][s(969)]({data:h,fail:g=>{let w=s;this[w(1721)](e.LPLpp,lt(e[w(1029)],{message:this[w(826)+"rrorMessage"](g)}))}})}else this[s(1817)]&&this._socket[s(969)]({data:r,fail:h=>{let g=s;this[g(1721)](l.fFbeB,l[g(1116)](lt,l[g(1910)],{message:this["_formatE"+g(1917)+g(1419)](h)}))}})}close(r,s){let l=t;this._socket&&this[l(1817)][l(1170)]({code:r,reason:s})}[t(1608)+t(1261)](r,s){this.on(r,s)}[t(860)+t(1904)+t(1365)](r,s){let l=t,h={ejawy:function(g,w){return e[V(1488)](g,w)},AHamJ:e[l(1352)],gIpyF:function(g){return g()}};e[l(1562)](e[l(1153)],l(1459))?this.off(r,s):(XWlFiZ[l(1270)](_0x2b5278,_0x4c1168[l(962)]||new _0x5bef05(XWlFiZ[l(665)],XWlFiZ.AHamJ)),XWlFiZ[l(1530)](_0x11dc15))}get[t(1076)+"te"](){let r=t;return this[r(1817)][r(1076)+"te"]}get[t(849)+"pe"](){let r=t;if(e[r(1164)](e.Ngdit,e[r(1825)])){let s=e[r(1433)](_0x11c007,e[r(1029)],{message:_0x16b9b1[r(1699)],code:_0x5e3626[r(474)+"ERROR"],error:_0x575452});this[r(1489)+"hErrorEvent"](s)}else return this[r(1817)][r(849)+"pe"]}set[t(849)+"pe"](r){}get[t(896)](){return this._socket.url}get[t(1321)](){let r=t;return this[r(1817)][r(1321)]}get[t(1895)+"ns"](){let r=t;return this[r(1817)][r(1895)+"ns"]}get[t(1038)+t(500)](){return 0}}function rg(a,r){let s=t;if(r)return new r(a[s(896)],a[s(1321)]);if(e.JGutJ(ei,Rn))return new ng(a[s(896)],a.protocol,a[s(1479)]);if((ir||ti)&&e.GsTyF!=typeof WebSocket&&WebSocket)return new WebSocket(a[s(896)],a[s(1321)+"s"])}function ig(a){let r=t,s=e[r(1113)][r(1017)]("|"),l=0;for(;;){switch(s[l++]){case"0":if(Rn&&tt["connectS"+r(1337)])return!0;continue;case"1":if(a)return!0;continue;case"2":if(ei&&wx[r(1624)+r(1337)])return!0;continue;case"3":if((ir||ti)&&e[r(1206)](e.GsTyF,typeof WebSocket)&&WebSocket)return!0;continue;case"4":return!1}break}}function wl(a,r,s){let l=t,h=-1;async function g(w){let S=V;return e[S(489)](w,h)?Promise.reject(new Error(e[S(845)])):(h=w,w===s[S(1079)]?Promise[S(642)]():s[w][S(1278)](a)(r,g[S(1278)](null,e.gotdC(w,1))))}e[l(1754)](g,0)}function _l(a){let r=t;if(e[r(731)]===e.flHYa)return _0xdd203d[r(642)]();{let s=0,l=0;for(let h=0;e[r(1666)](h,a[r(1079)]);++h){if(e[r(792)]===e[r(614)])return _0x39aea4|=0,{low:_0x1132a7,high:e[r(1204)](_0xc3eefd,31),unsigned:e.rsBKY(_0x1bb70d,0)};l=a[r(1641)+"At"](h),e[r(1254)](l,128)?s+=1:l<2048?s+=2:e[r(714)](64512,l)===55296&&e[r(925)](e[r(1908)](64512,a[r(1641)+"At"](e[r(886)](h,1))),56320)?(++h,s+=4):s+=3}return s}}function yl(a,r,s){let l=t;if(e[l(1281)](e[l(1944)](s,r),1))return"";let h="";for(let g=r;e[l(1655)](g,s);){let w=a[g++];if(e[l(893)](w,127))h+=String[l(900)+l(771)](w);else if(e[l(1866)](w,192)&&e[l(1591)](w,224))h+=String[l(900)+"Code"](e[l(455)](e.YFmrQ(31&w,6),e[l(714)](63,a[g++])));else if(e[l(1207)](w,224)&&e[l(1514)](w,240))h+=String[l(900)+"Code"](e[l(1690)](e[l(1276)](e[l(1088)](e[l(1485)](15,w),12),e[l(948)](e.HpWAy(63,a[g++]),6)),e[l(539)](63,a[g++])));else if(e[l(1376)](w,240)){let S=e[l(1104)](e.jtIPs(e.HAChC(e[l(496)](e[l(1334)](e[l(979)](7,w),18),e[l(976)](e[l(1925)](63,a[g++]),12)),e[l(1451)](e[l(979)](63,a[g++]),6)),e.zATwX(63,a[g++])),65536);h+=String[l(900)+"Code"](e.ZzERF(55296,e[l(1169)](S,10))),h+=String[l(900)+"Code"](e[l(1874)](56320,e[l(623)](1023,S)))}}return h}function Sa(a,r,s){let l=t,h=s,g,w;for(let S=0;S<a[l(1079)];++S)if(e[l(1154)](l(1118),e.VvciS)){let p={SUCWi:function(O,M){return e[l(573)](O,M)},kLLAy:e[l(772)]},T=_0x291388[l(1789)+l(511)](e.mxTgJ);_0xd7ae51.frontierJSONP=O=>{let M=l;_0x1691d7[M(653)][M(819)+M(1212)](T),_0x34092e[M(1241)+"JSONP"]=void 0,p[M(596)](_0x4c988a,O&&O.msg||p[M(1080)])},T[l(1785)]="text/jav"+l(1252),T[l(1135)]=_0x3aacbd[l(788)](/^ws/,e[l(1248)])+e.NMsFr;try{_0x464d76[l(653)][l(1949)+l(1212)](T)}catch{_0x3c0d36[l(653)][l(819)+l(1212)](T)}}else if(g=a.charCodeAt(S),g<128)r[s++]=g;else if(e.OBVki(g,2048))r[s++]=e[l(584)](e.DxTMP(g,6),192),r[s++]=e[l(1309)](63&g,128);else if(e[l(498)](e[l(1200)](64512,g),55296)&&e[l(738)](64512,w=a.charCodeAt(e[l(591)](S,1)))===56320)if(e[l(1175)]===l(1924)){let p={kkqZF:function(H,W){return H>W},wfqCO:function(H,W){return e.iiqfy(H,W)},cEwEp:function(H,W){return e.lhTSI(H,W)},VEpfD:function(H,W){return H+W}},T=e[l(590)](_0x3bce97,8192),O=e.bPQiN(T,1),M=null,U=T;return function(H){let W=l;if(H<1||p[W(864)](H,O))return _0x1920c9(H);p[W(1192)](U,H)>T&&(M=_0x415642(T),U=0);let he=_0x5289a4[W(1275)](M,U,U+=H);return p[W(859)](7,U)&&(U=p[W(468)](7|U,1)),he}}else g=e.GdXuR(65536+e[l(1912)](e[l(1375)](1023,g),10),e[l(1421)](1023,w)),++S,r[s++]=e[l(1858)](g,18)|240,r[s++]=e.WwAbZ(e[l(539)](e.EyNjT(g,12),63),128),r[s++]=e[l(1350)](e[l(888)](g>>6,63),128),r[s++]=e[l(998)](63&g,128);else r[s++]=e[l(1042)](e[l(1829)](g,12),224),r[s++]=e[l(1704)](e[l(825)](g>>6,63),128),r[s++]=e[l(1569)](e[l(1953)](63,g),128);return e.rxESH(s,h)}async function El(a){let r=t,s={wAwIP:function(l,h){return l-h}};if(e[r(1654)](r(488),typeof a))if(e[r(1938)](e[r(1381)],e.pbeEq)){let l=new Uint8Array(e[r(1850)](_l,a));return Sa(a,l,0),l}else{let l=_0x3b5e4b[r(820)+"g"](0,uCDrFS.wAwIP(4,_0x288849[r(1079)])),h=l[r(1567)](_0x5ce3e3);_0x34be07[r(1807)](h)}return a instanceof ArrayBuffer?new Uint8Array(a):new Uint8Array(a[r(1543)],a[r(698)+"et"],a[r(564)+"th"])}function sg(a){let r=t;try{return r(1644)!==e[r(1214)]?r(488)!=typeof a&&(e[r(1824)](a,ArrayBuffer)||a[r(1543)]&&e[r(1824)](a[r(1543)],ArrayBuffer))||e[r(1291)](e[r(1018)],typeof a)?"":(JSON[r(1669)](a),r(1668)+r(1794)):_0x476a1f[r(642)]()}catch{return e.cesxO==typeof a?r(502)+"in;charset=utf-8":""}}let og=(a,r)=>{let s=t;switch(a){case e[s(1733)]:case e[s(1093)]:return{["x-use-"+a]:1,"x-tt-env":r};default:return{}}};class ag{constructor(r){let s=t;this[s(1544)+"ount"]=r,this.count=0}[t(1739)](){this.count++}[t(1014)+"chMaxCount"](){let r=t;return e[r(929)](this[r(1379)],this[r(1544)+r(892)])}[t(808)+"nter"](r=0){let s=t;this[s(1544)+s(892)]=r,this[s(1379)]=0}}async function cg(a){return new Promise(r=>{let s=V,l={JNMHD:function(h,g){return h(g)},tRjTM:s(913)+"2",NFvbp:e[s(621)]};if(!ir)return r(e.eKpFM);try{let h=document[s(1789)+s(511)](e.mxTgJ);window[s(1241)+s(1323)]=g=>{let w=s;document[w(653)][w(819)+"ild"](h),window[w(1241)+w(1323)]=void 0,l[w(1517)](r,g&&g[w(784)]||w(1815)+"reason")},h[s(1785)]=e[s(1527)],h[s(1135)]=e[s(1105)](a[s(788)](/^ws/,e[s(1248)]),e[s(1181)]);try{document[s(653)]["appendCh"+s(1212)](h)}catch{if(e[s(1698)]==="GvVnw"){let g=l.tRjTM.split("|"),w=0;for(;;){switch(g[w++]){case"0":if((_0x446b52||_0x396dde)&&tAipvo[s(1219)]!=typeof _0x5985c4&&_0x289d60)return!0;continue;case"1":if(_0x3c8aaa)return!0;continue;case"2":return!1;case"3":if(_0x141cc9&&_0x4b6c0e[s(1624)+s(1337)])return!0;continue;case"4":if(_0x2ccc1a&&_0x259fe4["connectS"+s(1337)])return!0;continue}break}}else document[s(653)][s(819)+s(1212)](h)}}catch{window[s(1241)+s(1323)]=void 0,r(e[s(772)])}})}function an(a,r,s){let l=t,h={zEhsL:function(g,w){return e[V(916)](g,w)},PGqqw:function(g,w){return g+w},WLBiE:e[l(1044)]};if(e.GopLH===e[l(1055)]){let g=_0x572ac9[l(782)];if(UIoSrA[l(673)](UIoSrA[l(1830)](g,_0x5b1427),_0x20c469[l(1401)]))throw new _0x39c068(UIoSrA[l(1228)]);return _0x19d519[l(782)]+=_0x2cb041,g}else return!!a?.[l(1316)](g=>g[l(830)]===r&&g[l(1482)]===s)}function sr(a,r){return a?.[t(1316)](l=>l.key===r)?.value}let Ia=null;async function dg(){let a=t;return Ia||(Ia=Promise.resolve()[a(729)](Ft[a(1278)](Ft,e[a(1262)]))),Ia}class lg extends va{constructor(r,s){let l=t;super(),this[l(1607)]=r,this[l(1671)]=s,this[l(1687)]=void 0,this[l(906)+l(789)]=null}async[t(556)](){await this._init()}async _init(){let r=t;if(!this[r(1687)]){if(this[r(906)+r(789)])return this[r(906)+r(789)];try{let s=this._dbName,l=this._keyPath;this[r(906)+r(789)]=(async()=>{let h=r,{openDB:g}=await e[h(1348)](dg);this[h(1687)]=await e.gsfHz(g,h(1241)+"_"+s,1,{upgrade(w){w["createOb"+h(1499)+"e"](s,{keyPath:l})}})})(),await this[r(906)+r(789)]}catch(s){console[r(774)](s)}finally{this._initPromise=null}}}async[t(1729)](r){let s=t;try{return await this[s(1477)](),this[s(1687)]?.get(this[s(1607)],r)}catch(l){if(e.gAtDr(e[s(1814)],e[s(516)]))return function(...h){let g=s;return _0x35dd75[g(832)](_0x825cb5(this),h),_0xaabea6(_0x1c8adb[g(1729)](this))};console[s(774)](l)}}async[t(940)](r,s){let l=t;return await this._init(),this._qosDB?.[l(1049)](this[l(1607)],r)}async[t(882)](r){let s=t;if(e[s(1063)](e[s(1367)],s(671)))_0x87d7c2.resolve()[s(729)](()=>{let l=s;this[l(1747)+l(486)]()});else try{return e[s(508)](s(552),e[s(1297)])?this[s(986)]?this[s(986)][s(849)+"pe"]:this["_binaryT"+s(1771)]:(await this[s(1477)](),this[s(1687)]?.[s(1727)](this[s(1607)],r))}catch(l){console[s(774)](l)}}async[t(856)](){let r=t;try{return await this._init(),this[r(1687)]?.[r(856)](this[r(1607)])}catch(s){console[r(774)](s)}}async keys(){let r=t;return await this[r(1477)](),this[r(1687)]?.getAllKeys(this[r(1607)])}async[t(1769)](){let r=t;return await this[r(1477)](),this._qosDB?.[r(1769)](this[r(1607)])}async closeDB(){let r=t,s={xwTJI:function(l,h,g,w){return l(h,g,w)}};if(e[r(1115)](e[r(1133)],e[r(1133)]))try{if(e[r(1938)]("tfnSQ",e[r(607)]))return!!_0x1f0e1f?.find(l=>l[r(830)]===_0x10a955&&l[r(1482)]===_0x1432ac);this._qosDB?.close(),this[r(1687)]=void 0}catch(l){e[r(1692)](e[r(689)],r(503))?console[r(774)](l):(this._DBName=_0x44271b,this._pathKey=_0x4555f9,this._qosDB=_0x1bd382?_0x10ce63:_0x4ac1dd?_0x182c48:null)}else s[r(899)](_0x3701d4,this,_0x3ffa64,[_0x536ae5,_0x1a8cb2,_0x1bd1b5,_0x1617d6,_0x547a46,_0x18b243])}get[t(1197)](){let r=t;try{return!!this[r(1687)]}catch(s){return console[r(774)](s),!1}}}class ug{constructor(r,s){let l=t;this[l(1706)]=r,this._pathKey=s,this[l(1687)]=localStorage}async[t(556)](){}get[t(982)](){let r=t;return r(1241)+"_"+this[r(1706)]}async[t(1729)](r){let s=t,l=this[s(1687)].getItem(this._prefix);return JSON.parse(e.LAiLS(l,"{}"))[r]}async[t(940)](r,s){let l=t,h=this[l(1687)][l(679)](this[l(982)]),g=JSON[l(1669)](h||"{}");return g[s||r[this._pathKey]]=r,this[l(1687)][l(958)](this[l(982)],JSON[l(513)+"y"](g)),s||r[this._pathKey]}async del(r){let s=t,l=this[s(1687)][s(679)](this[s(982)]),h=JSON[s(1669)](l||"{}");return h[r]=void 0,this[s(1687)][s(958)](this[s(982)],JSON[s(513)+"y"](h))}async clear(){let r=t;return this[r(1687)][r(856)]()}async[t(1885)](){let r=t,s=this[r(1687)][r(679)](this[r(982)]),l=JSON.parse(e.aWZGn(s,"{}"));return Object[r(1885)](l)}async[t(1769)](){let r=t,s=this[r(1687)][r(679)](this[r(982)]),l=JSON[r(1669)](s||"{}");return Object[r(1802)](l)}closeDB(){return Promise[t(642)]()}get[t(1197)](){return!!this._qosDB}}class fg{constructor(r,s){let l=t;this[l(1706)]=r,this[l(1881)]=s,this[l(1687)]=Rn?tt:ei?wx:null}async[t(556)](){}get _prefix(){let r=t;return r(1241)+"_"+this[r(1706)]}async[t(1729)](r){let s=t,l=this[s(1687)][s(520)+s(585)](this[s(982)]);return JSON[s(1669)](l||"{}")[r]}async[t(940)](r,s){let l=t;if(e[l(1626)](l(1860),e[l(483)])){let h=this._qosDB[l(520)+"geSync"](this[l(982)]),g=JSON[l(1669)](e[l(879)](h,"{}"));return g[s||r[this[l(1881)]]]=r,this[l(1687)][l(1428)+"geSync"](this[l(982)],JSON[l(513)+"y"](g)),s||r[this[l(1881)]]}else return this._qosDB?.get(_0x3c43e7)}async[t(882)](r){let s=t,l=this[s(1687)][s(520)+s(585)](this[s(982)]),h=JSON.parse(l||"{}");return h[r]=void 0,this._qosDB[s(1428)+s(585)](this[s(982)],JSON[s(513)+"y"](h))}async[t(856)](){let r=t;return this[r(1687)]["clearSto"+r(1412)]()}async keys(){let r=t;if(e.NLivR(e[r(781)],e.msmkF)){let s=this[r(1687)][r(520)+"geInfoSync"](this._prefix),l=JSON[r(1669)](s||"{}");return Object[r(1885)](l)}else this[r(1100)+"er"]&&_0x5b0b37[r(860)+r(1904)+"ner"](e[r(1512)],this["_handleO"+r(1287)]),this[r(1100)+"er"]&&_0x1daf7b[r(860)+r(1904)+"ner"](e.rfdWm,this[r(1450)+r(558)]),this[r(1100)+"er"]&&_0x37d817[r(860)+r(1904)+"ner"](e[r(871)],this[r(535)+r(1098)]),this[r(1100)+"er"]&&_0x20bdfa[r(860)+"entListe"+r(1365)](e.SgVzZ,this[r(535)+r(1458)])}async[t(1769)](){let r=t,s=this[r(1687)][r(520)+"geInfoSync"](this._prefix),l=JSON[r(1669)](e[r(590)](s,"{}"));return Object.values(l)}[t(1709)](){return Promise[t(642)]()}get isReady(){let r=t;if(e[r(525)](e[r(1399)],e.XxTrb))_0xcd7102(this[r(1318)+"lTimeoutId"]),this[r(1318)+"lTimeoutId"]=e[r(548)](_0x25bcc8,()=>{this["flushExp"+r(831)]()},this._interval);else return!!this[r(1687)]}}function bl(a,r){let s=t;if(e[s(964)](e[s(1648)],e[s(1648)])){if(e.mXNJm(Rn,Rn))return new fg(a,r);if((ir||ti)&&e[s(786)](e[s(621)],typeof indexedDB))return new lg(a,r);if(e.hrWVa(ir,ti)&&e[s(1206)](s(787)+"d",typeof localStorage))return new ug(a,r);throw new Error("init QoS"+s(1128)+"d")}else this[s(634)+s(612)]()&&(!this[s(986)]||e.imFbo(this[s(986)][s(1076)+"te"],this[s(1025)])||e[s(542)](this[s(986)][s(1076)+"te"],this.CONNECTING))&&this[s(1450)+s(1287)](),this[s(1100)+"er"]&&_0x3cf0ed[s(1608)+"Listener"](s(1735),this[s(1450)+s(1287)]),this[s(1100)+"er"]&&_0x19ad10.addEventListener(e[s(1793)],this[s(1450)+s(558)])}class hg{constructor(){let r=t;this[r(1318)+"lTimeoutId"]=null,this[r(1318)+"l"]=36e5,this[r(1687)]=e[r(1642)](bl,e.InZUM,r(1161)+"id")}async _intervalFlush(){let r=t;e[r(1327)](clearInterval,this[r(1318)+r(1583)+"Id"]),this[r(1318)+"lTimeoutId"]=setInterval(()=>{let s=r;this[s(1490)+s(831)]()},this[r(1318)+"l"])}async[t(556)](){let r=t;await this[r(1687)][r(556)]()[r(729)](()=>{let s=r;this[s(1318)+s(1855)]()})}async[t(1490)+t(831)](){let r=t;(await this[r(1687)]?.[r(1769)]()||[])[r(1084)](({timestamp:h})=>h<Date[r(926)]())[r(1848)](h=>{let g=r;this[g(1687)]?.[g(882)](h[g(1161)+"id"])})}async[t(882)](r){return this[t(1687)]?.del(r)}async[t(940)](r,s){let l=t;return this._qosDB?.[l(940)]({message_id:r,timestamp:s})}async[t(1729)](r){return this._qosDB?.get(r)}async[t(1709)](){let r=t;e[r(1755)](clearInterval,this["_interva"+r(1583)+"Id"]),await this._qosDB?.[r(1709)]()}get[t(1197)](){let r=t;return this[r(1687)]?.[r(1197)]}}function Aa(a){let r=t,s=!!this[r(736)].enableQoS;if(!s)return{enabled:s,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let l=e.PuFeO(an,a[r(1699)][r(1479)],e[r(1507)],"2"),h=l&&e[r(514)](an,a[r(1699)][r(1479)],r(1374)+"er_qos_ack","1"),g=l&&e.nWEzo(an,a[r(1699)][r(1479)],e[r(1518)],"1"),w=g?sr(a[r(1699)].headers,e.onLei)?.split(",").filter(Boolean)||[]:[];return{enabled:s,isQoSMessage:l,isQoSAck:h,isAckCleanupMessage:g,ackMsgIds:w}}async function vl(){let a=t;return this[a(1528)+"ger"]||(this[a(1528)+a(1046)]=new hg),this._QoSManager[a(1197)]||await this["_QoSMana"+a(1046)][a(556)](),this[a(1528)+a(1046)]}async function xg(a,r){let s=t,l={PuIlO:function(h,g){return e[V(1548)](h,g)},zcaKM:e[s(1840)],OOYgi:function(h,g){return e.Xrjyo(h,g)},RDljw:function(h,g){return e.mtmHH(h,g)},lPwhT:function(h,g){return h(g)},AuVKq:function(h,g,w){return e[s(684)](h,g,w)},KKvyu:function(h){return e[s(1659)](h)}};if(e[s(643)](e[s(1301)],s(876))){let{enableAutoAck:h}=this[s(736)],g=an(a[s(1699)][s(1479)],e[s(569)],"1"),w=e[s(1393)](an,a.message[s(1479)],e[s(1660)],"1"),S=Aa[s(1275)](this,a);if(e[s(1435)](h,g)){let{SeqID:p,LogID:T,service:O,LogIDNew:M,method:U}=a[s(1699)];this[s(635)]({SeqID:p,LogID:T,LogIDNew:M,service:O,method:U,headers:[{key:e[s(1660)],value:"1"},{key:"ack_id",value:e.aWZGn(M,"")},{key:e[s(1665)],value:"0"}]})}w&&!S[s(1072)]&&this[s(1489)+s(810)+"ageEvent"](a),e[s(515)](r)}else return fzGFcH[s(702)](typeof _0x1ee01d,fzGFcH.zcaKM)?fzGFcH.OOYgi(_0x35f7e3,_0x4a0043):(fzGFcH.RDljw(_0x753bf0,_0x2aa111)&&fzGFcH[s(1863)](_0x2f5004,_0x30fc40),fzGFcH.AuVKq(_0x2de165,_0x57d74c,fzGFcH.KKvyu(_0x2ed5ec))?new _0x3982c4(_0x7bc735,_0x1ae605):_0x1ffbbd)}async function pg(a,r){let s=t,l={qfJCa:e[s(1688)],NiBKK:function(h,g){return e[s(1471)](h,g)},TcuNu:e[s(933)]};if(e[s(1685)](e[s(942)],e[s(605)])){if(_0x2930b1===s(1273))return _0x53850d.get(_0x4effc5);if(_0x45be5d===VoAjmm[s(1887)])return _0x57f5d3[s(1941)+s(1783)]||_0xec2df9.get(_0x1f90b7);if(VoAjmm[s(1067)](_0x39ad79,VoAjmm[s(1695)]))return _0x2f1e88["objectSt"+s(1783)][1]?void 0:_0x26a205.objectStore(_0x448d99[s(1941)+s(1783)][0])}else this[s(1630)](e.Ygzah,a[s(1699)]),e[s(1659)](r)}async function gg(a,r){let s=t,l={bbTqT:e[s(461)],Mawki:e[s(1029)]};if(e[s(1676)]!==e.xajgm)_0x1bb299[s(860)+"entListe"+s(1365)](CnyUMG[s(1539)],_0x2204e7),_0x357012[s(860)+s(1904)+"ner"](CnyUMG.Mawki,_0x3175ee);else{let h=e.MZpqY(rn,await e.GgNFa(El,a.data));try{if(h[s(1180)]instanceof Uint8Array)if(e[s(704)](e[s(779)],e[s(779)])){let g=this[s(736)]["payloadE"+s(1003)]instanceof Object?{force:!!this[s(736)][s(680)+s(1003)].force,encoding:this[s(736)][s(680)+s(1003)][s(1442)]?this[s(736)][s(680)+"ncoding"][s(1442)].replace(/\s/g,"")["toLowerC"+s(1675)]():""}:{force:!1,encoding:this[s(736)]["payloadE"+s(1003)]?this._options[s(680)+"ncoding"][s(788)](/\s/g,"")["toLowerC"+s(1675)]():""},w=h[s(680)+s(1003)]?h[s(680)+"ncoding"][s(788)](/\s/g,"")["toLowerC"+s(1675)]():"",S=e.mtmHH(this[s(736)][s(841)+s(1771)],Object)?{force:!!this._options["payloadT"+s(1771)][s(1601)],type:this[s(736)][s(841)+s(1771)][s(1785)]?this[s(736)][s(841)+s(1771)][s(1785)].replace(/\s/g,"")[s(1237)+s(1675)]():""}:{force:!1,type:this[s(736)][s(841)+"ype"]?this[s(736)][s(841)+s(1771)][s(788)](/\s/g,"")["toLowerC"+s(1675)]():""},p=h[s(841)+s(1771)]?h[s(841)+s(1771)][s(788)](/\s/g,"")[s(1237)+"ase"]():"",T=S.force?S[s(1785)]:p||S[s(1785)],O=g[s(1601)]?g.encoding:w||g[s(1442)],M=[e[s(1132)],e[s(1819)],e[s(1349)],e[s(1018)]],U=[s(1763)+"e",e[s(836)]];this[s(736)][s(555)+s(1714)+s(1163)+"ad"]&&M.includes(T)&&(!O||U[s(1816)](O))?h[s(533)+"oad"]=e[s(1495)](yl,h[s(1180)],0,h[s(1180)][s(564)+"th"]):h[s(533)+s(713)]=""}else _0x375592.d=(g,w)=>{let S=s;for(var p in w)_0x303574.o(w,p)&&!_0x59f5b9.o(g,p)&&_0x4f9f41[S(811)+"operty"](g,p,{enumerable:!0,get:w[p]})};else h[s(533)+s(713)]=""}catch(g){e[s(683)](s(497),e[s(1346)])?(this[s(1489)+"hMessage"+s(1818)](_0x4098f9),_0x6a6860[s(940)](_0x482026,_0x3f8381,_0x315b86[s(1699)][s(457)])):(h[s(533)+"oad"]="",console[s(774)](g))}a[s(1699)]=h,r()}}function mg(a,r,s){let l=t,h={otnoR:function(T,O){return e[V(1028)](T,O)},lzKSG:function(T,O){return e[V(1327)](T,O)},xhYus:function(T,O){return e.xiPWU(T,O)},plGAa:function(T,O){return e.VtvMY(T,O)}},g=e[l(1745)](s,8192),w=e[l(526)](g,1),S=null,p=g;return function(T){let O=l;if(h[O(822)](T,1)||T>w)return h.lzKSG(a,T);h[O(1457)](p+T,g)&&(S=a(g),p=0);let M=r[O(1275)](S,p,p+=T);return 7&p&&(p=h[O(885)](7|p,1)),M}}let wg=4294967295;function _g(a,r,s){let l=t;return e[l(973)](RangeError,e[l(1782)](e[l(1782)](e[l(880)](e[l(591)](e.FjNis(e[l(1210)],a),e.zOLAL),e[l(838)](r,1)),e[l(1932)]),s))}function yg(a,r,s){let l=t,h={uNvrl:function(g,w){return e[V(1109)](g,w)}};if(e[l(773)](l(1534),l(1534))){let g=_0x189d8f[l(911)]();return g?(g[l(782)]=g.limit=0,g):{bytes:new _0x441de9(64),offset:0,limit:0}}else{if(e.bQrdA(s,wg))throw new Error(l(1798)+"too large");let g=3;for(;e.irUkm(g,0);)if(e[l(813)](l(815),e[l(1605)])){let w=this._qosDB[l(679)](this._prefix),S=_0x554b1b[l(1669)](CyvGbF[l(1299)](w,"{}"));return _0x26230f[l(1885)](S)}else{let w=e[l(1753)](255,s);e.JSIhJ(Ta,w,a,r+g),s>>>=8,g--}return e[l(1851)](r,4)}}function Eg(a,r){let s=t;if(e.DFXkK("njNBH",e.WtaQZ))_0x1eeeee=_0x291c97(_0x211ee1),_0x5d4e54|=e.BCcQU(127,_0x11a5b3)<<21,e[s(1791)](128,_0xded554)&&(_0x7b59f7=_0x56384f(_0x16a312),_0x23e44b=127&_0xf51bdb,128&_0x1bb02b&&(_0x256dcf=e[s(1232)](_0x4d9dd4,_0x4336af),_0x5cf5e4|=e.dRlHR(e[s(675)](127,_0x1228d1),7)));else{let l=0,h=r,g=r+4;for(;h<g;){let{value:w,offset:S}=e[s(684)](ka,a,h);h=S,l=e[s(580)](e[s(1081)](l,8),0),l+=w}return{value:l,offset:g}}}function bg(a,r,s){let l=t,h=(l(1890)+"1").split("|"),g=0;for(;;){switch(h[g++]){case"0":if(r[l(1131)])return e[l(1878)](r[l(1131)](a,s),s);continue;case"1":return e[l(1006)](Sa,a,r,s)+s;case"2":if(!a)return s;continue;case"3":if(r.utf8Write)return r[l(1159)+"e"](a,s)+s;continue;case"4":if(e[l(541)](a[l(1079)],40))return e[l(465)](e[l(1006)](Sa,a,r,s),s);continue}break}}function vg(a,r){let s=t,l=new pe(e[s(1684)](e[s(455)](e[s(628)](a[r+4],24),e.dDdOS(a[e.LFqek(r,5)],16)),e[s(1310)](a[e[s(600)](r,6)],8))|a[e.coCDZ(r,7)],e[s(1560)](e[s(1309)](e[s(1894)](e[s(1251)](a[e[s(565)](r,0)],24),e[s(1403)](a[r+1],16)),e[s(1069)](a[r+2],8)),a[r+3]),!0);return r+=8,{value:l,offset:r+8}}function Sg(a,r,s){let l=t,h=a[l(582)],g=a.high;return r[s]=e[l(526)](g,24),r[e[l(1923)](s,1)]=e.EgouJ(e[l(1559)](g,16),255),r[s+2]=e[l(756)](g>>>8,255),r[s+3]=255&g,r[e[l(1919)](s,4)]=e[l(699)](h,24),r[e[l(758)](s,5)]=e[l(1867)](e[l(1481)](h,16),255),r[s+6]=e[l(910)](e[l(1060)](h,8),255),r[e[l(1105)](s,7)]=e[l(586)](255,h),s+=8,s}function ka(a,r){let s=t;return a[s(999)+"8"]?{value:a.readUInt8(r),offset:e[s(1800)](r,1)}:{value:255&a[r],offset:e[s(1030)](r,1)}}function Ta(a,r,s){return r[t(894)+"t8"]?r.writeUint8(a,s):r[s]=e.DXmYf(255,a),s+1}let Ig=function(a){let r=t;if(e.ZvJpk!=="QDxZm")_0x230940[r(1241)+r(1323)]=void 0,e[r(559)](_0x5a7376,e[r(772)]);else return new Uint8Array(a)},Ag=e.zfQap("undefined",typeof Buffer)?Buffer[t(1250)+"afe"]:e[t(618)](mg,Ig,Uint8Array[t(687)+"e"][t(984)]);(()=>{let a=t,r={NJIYu:function(l,h,g){return e.CWtjV(l,h,g)},BeYtO:function(l,h){return e[V(1822)](l,h)},sLBzu:a(1635)+a(1319)+"onnecting"},s=4294967295;return function(l,h,g=!0){let w=a;if(e[w(1795)]===e.MprRe){if(s=e[w(1372)](e.YwNXS(127,l[h]),0),e.qOKQV(l[h++],128))return{value:g?s:e.nHTPj(0,s),offset:h};if(s=e[w(1283)](s|e.lscsc(e[w(1768)](127,l[h]),7),0),e.rNclZ(l[h++],128))return{value:g?s:e[w(1657)](0,s),offset:h};if(s=e[w(699)](e[w(1331)](s,e[w(887)](e[w(1123)](127,l[h]),14)),0),e[w(1370)](l[h++],128))return{value:g?s:e[w(1002)](0,s),offset:h};if(s=e[w(1305)](e[w(1686)](s,e[w(1640)](e[w(1215)](127,l[h]),21)),0),l[h++]<128)return{value:g?s:e[w(1703)](0,s),offset:h};if(s=e.OkLFT(e[w(1690)](s,e.zuGpP(e[w(1155)](15,l[h]),28)),0),l[h++]<128)return{value:g?s:e[w(1940)](0,s),offset:h};if(e[w(1227)](h+=5,l.length))if(e.AnBLK(e[w(1918)],w(1689)))_0x12f58b(_0x45a37e,96),ANSzuy[w(914)](_0x356077,_0x4220f4,ANSzuy.BeYtO(_0x1fe155,_0x540615));else throw h=l[w(1079)],e[w(1151)](_g,h,10,l[w(1079)]);return{value:g?s:e.zllRG(0,s),offset:h}}else{let S=this[w(1570)+w(1645)]?.[w(1147)+w(1946)+"nt"]();this._debug(w(1926)+S+w(1312)),this["_disconn"+w(1182)](1001,r.sLBzu,!0)}}})();let kg=16,Pa=32;function Tg(a){let r=t,s=0,l={};for(let h=0;e.vDGoG(h,a[r(1079)]);h++)l[a[h]["cursor_n"+r(640)]]=e[r(1822)](_l,a[h].cursor_name),s+=e[r(1398)](14,l[a[h][r(990)+r(640)]]);return[s,l]}function Sl(a,r,s){let l=t,h={zjcvI:function(g,w){return e.zPkck(g,w)},ICpLf:function(g,w){return g<w},LfJdm:function(g,w){return e[V(745)](g,w)},tqUZu:e.udlFe,nxOuy:e.wJXyo,hQrVY:function(g,w,S,p){return e[V(1244)](g,w,S,p)},NpzRu:function(g,w,S,p){return e[V(719)](g,w,S,p)},TmeHL:e[l(1184)],ReUVx:e.VCDgG,mtJed:e[l(481)],VWqUP:e[l(872)],RYFrP:function(g,w,S,p){return e.opqDk(g,w,S,p)},aAfcA:function(g,w,S,p){return e[l(877)](g,w,S,p)},fsZbX:e.zECwV};if(e[l(1234)](e[l(1702)],"pvPKl"))_0x439a2d=AeoAtn.zjcvI(_0x56fe02,_0x4ecbed),AeoAtn[l(1201)](_0x69c71d,32)&&(_0x486e75|=AeoAtn[l(575)](127,_0x247ef5)<<_0x3e574c),_0x5cab1d+=7;else{let[g,w]=e[l(963)](Tg,a),S=e[l(1754)](Ag,g),p=0;return a[l(1848)](T=>{let O=l,M=h[O(715)][O(1017)]("|"),U=0;for(;;){switch(M[U++]){case"0":console[O(774)](h.nxOuy,p);continue;case"1":p=h[O(1673)](yg,S,p,T[O(457)]||0);continue;case"2":p=h[O(1674)](bg,T[O(990)+"ame"],S,p);continue;case"3":console[O(774)](h[O(674)],p);continue;case"4":console[O(774)](h[O(1801)],p);continue;case"5":console[O(774)](h[O(1681)],T,T[O(457)]);continue;case"6":p=Sg(pe[O(946)+"er"](T[O(996)]||r),S,p);continue;case"7":console[O(774)](h[O(1453)],p);continue;case"8":p=h[O(1397)](Ta,0,S,p);continue;case"9":p=h[O(1577)](Ta,w[T["cursor_n"+O(640)]],S,p);continue;case"10":console[O(774)](h[O(767)],p);continue}break}}),{frameType:Pa,headers:[{key:l(688)+l(930),value:s}],payload:S}}}function Pg(a){let r=t,s={ekxbu:e.JZkDF,cHQvK:function(l,h){return l(h)}};if(e[r(848)](e.LDRro,e.fTQwQ)){let l=0,h=[];for(;e[r(532)](l,a[r(564)+"th"]);){let{offset:g}=e[r(1737)](ka,a,l);l=g;let w={cursor_name:"",cursor:0,service:0},{value:S,offset:p}=e[r(560)](Eg,a,l);w[r(457)]=S,l=p;let{value:T,offset:O}=e.YOgUk(ka,a,l);l=O,w[r(990)+r(640)]=e[r(1112)](yl,a,l,e[r(915)](l,T)),l+=T;let{value:M,offset:U}=vg(a,l);w[r(996)]=M[r(1114)](),l=U,h[r(1807)](w)}return h}else{let l=_0x36b204[r(1922)+"tabase"](_0x393a22);return _0x56892c&&l[r(1608)+r(1261)](waNVhh[r(1096)],()=>_0x59b03b()),waNVhh[r(1158)](_0x1ddce9,l).then(()=>{})}}function Rg(){return{frameType:Pa,headers:[{key:e[t(697)],value:e.VCUDF}],payload:void 0}}class Cg{constructor(r,s,l){let h=t;this[h(1584)+h(543)]=r,this[h(1440)+h(505)]=s,this[h(912)+h(1378)]=l,this[h(1687)]=e[h(1588)](bl,this[h(1584)+h(543)],e.YibKC)}async[t(556)](){let r=t;await this._qosDB[r(556)]()}async[t(1078)+"rs"](){let r=t;if(!this[r(1687)][r(1197)])return;let s=this[r(912)+"Strategy"],l=await this._qosDB.getAll();switch(console[r(774)](e.AIGRr,l),s){case r(1013):return l&&l.length?e[r(718)](Sl,l,0,this["_cursorF"+r(505)]):void 0;case e[r(957)]:return;case e[r(1503)]:return l&&l[r(1079)]?e[r(844)](Sl,l,0,this[r(1440)+"ileName"]):e.meDxK(Rg)}}async[t(940)](r,s,l){let h=t;return console[h(774)](e.wmhIi,r,s,l),this[h(1687)][h(940)]({cursor_name:r,cursor:s,service:l})}async[t(1385)+"rs"](r){let s=t,l=e[s(1545)](Pg,r);for(let h of l)console[s(774)](e.BVgbu,l),await this[s(1687)][s(940)](h)}async get(r){let s=t;return e.tSDVo(e[s(1790)],e[s(1405)])?s(1241)+"_"+this[s(1706)]:(await this[s(1687)][s(1729)](r))?.cursor}async closeDB(){let r=t;if(e.cuiek!==r(1095))await this._qosDB[r(1709)]();else{let{pingInterval:s,pingFrequency:l}=this._options;if((e[r(1877)]("hi",_0x46560a[r(1888)])&&e[r(1190)](e[r(1732)],l)||r(1245)===l)&&(this[r(733)+r(1436)](),this[r(1721)]("ping_once_success",e[r(461)]),this[r(579)+r(1565)+"Id"]=e[r(814)](_0x5ac1c6,this._ping[r(1278)](this),s)),_0x2bc347[r(1888)]==="hi")return;try{e[r(943)](_0x2cf775,this,_0x4285de,[_0x307e93,_0x4227d7,_0x34ae96,_0x131ae3,_0x220e31,_0x54ab3f])}catch(h){let g=_0xe33289(e.LPLpp,{message:h[r(1699)],code:_0x14b94a[r(474)+r(1282)],error:h});this[r(1489)+"hErrorEvent"](g)}}}["updateCu"+t(812)+t(1805)](r){let s=t;this[s(1440)+s(505)]=r}get isReady(){return this[t(1687)].isReady}}let Dg=e[t(744)];async function Il(a){let r=t;if(!this._options.enableQoS)return null;let{aID:s,fpID:l,messageStrategy:h}=this._options,g=e[r(1757)](a,Dg);try{return this[r(1195)+"anager"]?a&&this[r(1195)+r(1505)][r(1694)+r(812)+r(1805)](a):this[r(1195)+"anager"]=new Cg(l+"_"+s+"_"+g,g,h),this[r(1195)+r(1505)].isReady||await this[r(1195)+"anager"].openDB(),this[r(1195)+r(1505)]}catch{return null}}async function Og(a,r){let s=t,l={bfAtJ:function(H,W){return H===W},KdiVu:function(H,W){return e[V(987)](H,W)},tqQEE:function(H,W){return e[V(936)](H,W)},fmszh:function(H,W){return e[V(1350)](H,W)},ylItO:function(H,W){return H|W},cdKcU:function(H,W){return e[V(1441)](H,W)},GwaBJ:function(H,W){return H|W}},h=e[s(514)](an,a[s(1699)][s(1479)],e.uMCar,"-1"),g=an(a[s(1699)][s(1479)],e[s(1660)],"1"),w=e[s(1233)](sr,a.message[s(1479)],s(1374)+"er_msgid"),S=e[s(846)](Number,e[s(560)](sr,a[s(1699)][s(1479)],e.cNtlK))||0,p=Aa[s(1275)](this,a),T=an(a[s(1699)][s(1479)],e.eMHKS,"2"),O=e.iSoGk(sr,a[s(1699)].headers,e[s(954)]),M=e[s(1533)](Number,e.pKfBI(sr,a[s(1699)][s(1479)],s(1121)+s(1621)+"ue"));if(p[s(1072)])return e.yQslk(r);let U=p[s(1513)+"sage"]?await vl[s(1275)](this):null;if(e.UHaEC(a.message[s(457)],0)&&g&&!h||e[s(823)](a[s(1699)][s(457)],0)){if(e.smBkS!=="epybc")return rVsSJu.bfAtJ(_0x4ef342,_0x52692d)?_0x243952:new _0x1244b3(rVsSJu[s(594)](rVsSJu.tqQEE(rVsSJu[s(757)](rVsSJu[s(598)](_0x9b4a65.call(_0x3db59a,0),rVsSJu[s(950)](_0x1c99c7[s(1275)](_0x3ebcb9,1),8)),rVsSJu[s(950)](_0x28100c[s(1275)](_0x2c3a1a,2),16)),rVsSJu[s(950)](_0x44a6ba[s(1275)](_0x483e4c,3),24)),0),(rVsSJu[s(1633)](rVsSJu.GwaBJ(_0x41d163[s(1275)](_0x237bc9,4),_0x306ac5[s(1275)](_0x2cc8a8,5)<<8),rVsSJu[s(950)](_0x5d5453[s(1275)](_0x2fb5bc,6),16))|rVsSJu[s(950)](_0x1f471e[s(1275)](_0x562267,7),24))>>>0,!0);if(w&&p[s(1513)+s(1780)]&&U)return!!!await U[s(1729)](w)&&(this[s(1489)+s(1473)+s(1818)](a),await U[s(940)](w,Date[s(926)]()+S)),e.itFcQ(r);if(T){let H=await Il[s(1275)](this);if(!H)return this[s(1489)+s(1473)+s(1818)](a),r();let W=await H[s(1729)](O)??-1;if(e[s(1172)](W,M))if(e[s(1529)](e[s(1314)],e[s(1711)])){let he=new _0x22e55a(e.UHDUd(_0xf912eb,_0x5cc83c));return _0x57fb65(_0x1a5baa,he,0),he}else this[s(1489)+s(1473)+s(1818)](a),H[s(940)](O,M,a[s(1699)][s(457)]);else throw new Error(s(654)+s(676)+s(1085)+M+(" larger "+s(1260)+s(863)+"r ")+W);return r()}return this[s(1489)+"hMessageEvent"](a),e[s(1444)](r)}}async function Lg(a,r){let s=t,l=Aa[s(1275)](this,a);if(!l[s(1513)+s(1780)])return e.tNpDj(r);let h=await vl[s(1275)](this);if(l["isAckCle"+s(677)+s(1419)]&&l[s(686)+"s"].length)for(let g of l[s(686)+"s"])await h.del(g);r()}async function Ng(a,r){let s=t;if(e[s(1065)](e.MKJGu,e[s(492)]))_0x87a8a8=e.rZOzZ(_0x226a74,_0x45ab84),_0x298bb5=e[s(1141)](127,_0x25f942),e[s(623)](128,_0x525373)&&(_0x325347=e[s(1754)](_0x5d6b75,_0x24070f),_0x10acf4|=e[s(1403)](e[s(1585)](127,_0xa45821),7));else{let l=e[s(965)](a[s(1699)][s(1707)+"e"],kg),h=a[s(1699)][s(1707)+"e"]===Pa;if(e[s(1435)](!l,!h))return e.tNpDj(r);let g=e[s(775)](sr,a[s(1699)][s(1479)],s(688)+"ile_name");if(!g)return e[s(1073)](r);let w=await Il[s(1275)](this,g);if(!w)return e[s(1050)](r);if(l){let S=await w[s(1078)+"rs"](),p={frameType:S?.["frameType"],SeqID:pe[s(946)+"er"](this[s(1272)]++),LogID:pe[s(946)+"er"](this[s(736)]["logIDGen"+s(1052)]()),service:9e3,method:5,headers:S?.headers,payload:S?.[s(1180)]},T=e[s(1327)](v,p);this._ws&&this[s(986)][s(1076)+"te"]&&this[s(986)][s(969)](T)}if(h){let S=a.message[s(1180)];S&&w.setCursors(S)}}}let Mg=async function(a,r){let s=t;this[s(1156)]=!1,e[s(1710)](clearTimeout,this._connectionTimeoutId),e.ThlVs(r)},Bg=async function(a,r){let s=t;if(!this[s(986)]||e[s(508)](this[s(986)].readyState,this[s(1025)]))return r();let{pingInterval:l}=this._options;this[s(1570)+s(1645)]?.[s(1787)+s(732)+s(1056)]();for(let g=0;e.rehpP(g,this[s(912)+"Queue"][s(1079)]);g++)if(e[s(479)](e[s(1422)],e[s(1466)])){let w=e[s(1488)](_0x12f0c8,_0xa4dde6);this[s(986)]&&e[s(1471)](this[s(986)][s(1076)+"te"],this[s(1025)])&&(this[s(986)]&&this._ws[s(969)](w),this._debug(e.ypXZj,_0x35163f))}else{let w=this[s(912)+"Queue"][g];if(e.pWxOd(this[s(986)].readyState,this[s(1025)])&&e.Empwi(null,w))this[s(986)]&&this[s(986)][s(969)](w),this["_message"+s(790)][g]=null;else break}this["_message"+s(790)]=this[s(912)+s(790)][s(1084)](g=>!!g),this._pingPongTimeoutId=e.apXiA(setTimeout,()=>this._ping(),l),this["_dispatc"+s(1661)+"nt"](a),this[s(1100)+"er"]&&this._ws&&(this._ws.binaryType=this[s(1266)+s(1771)]);let h=this[s(1570)+"tManager"]?.[s(1147)+s(1946)+"nt"]();this[s(1630)](s(1456)+h+s(1647)),e.itFcQ(r)},Fg=async function(a,r){let s=t,l=this[s(1570)+s(1645)]?.[s(1147)+s(1946)+"nt"]();this[s(1630)](s(1456)+l),e[s(1178)](r)};class zg extends va{constructor(r){let s=t,l={NQduZ:function(S,p){return e[V(1655)](S,p)},FgcxX:function(S,p){return S<p},cimyQ:function(S,p){return e[V(1548)](S,p)},VZbGS:function(S,p){return S&p},MqndB:function(S,p){return e[V(1919)](S,p)},xezWa:function(S,p,T){return e[V(684)](S,p,T)},qVbSC:e[s(1029)],QUPYH:function(S,p,T){return e[s(1335)](S,p,T)},YQSGX:function(S,p){return e[s(895)](S,p)},XpMgQ:e.lcjyc,MVkXh:e[s(985)],ntvmu:function(S,p,T){return S(p,T)},gaglm:function(S,p,T){return e[s(903)](S,p,T)}};super(),this[s(1820)+"igatorOn"+s(1520)]=!0,this[s(1100)+"er"]=ir,this[s(473)]=tg,this[s(874)+"T"]=Rn,this[s(1724)+"X"]=ei,this[s(595)+"r"]=ti,this["_message"+s(790)]=[],this[s(1570)+s(1645)]=null,this[s(1384)+s(1484)]=!1,this[s(1266)+s(1771)]=e[s(1511)],this[s(631)+"Lock"]=!1,this["_connectionTimeo"+s(1670)]=null,this[s(592)+s(1720)+"tId"]=null,this[s(579)+s(1565)+"Id"]=null,this[s(1272)]=0,this._isInit=!1,this._url="",this[s(1528)+s(1046)]=null,this["_cursorM"+s(1505)]=null,this[s(975)+s(1434)]=null,this[s(1021)+"ls"]=e[s(460)],this[s(522)]=3,this[s(524)+"NG"]=0,this[s(1025)]=1,this.CLOSING=2,this[s(660)]=S=>{let p=s;if(p(1596)===e.LVtMJ)try{e[p(1280)](wl,this,S,[Mg,Bg,Fg])}catch(T){let O=e[p(749)](lt,e.LPLpp,{message:T[p(1699)],code:on.OPEN_ERROR,error:T});this[p(1489)+p(1326)+p(681)](O)}else{let T=0,O=0;for(let M=0;gtHBxm[p(947)](M,_0x52047a[p(1079)]);++M)O=_0x43ab94[p(1641)+"At"](M),O<128?T+=1:gtHBxm[p(630)](O,2048)?T+=2:gtHBxm[p(1898)](64512&O,55296)&>HBxm[p(471)](64512,_0x495884[p(1641)+"At"](gtHBxm[p(1882)](M,1)))===56320?(++M,T+=4):T+=3;return T}},this[s(855)+"ge"]=async S=>{let p=s,{pingInterval:T,pingFrequency:O}=this[p(736)];if((e[p(528)]("hi",S[p(1888)])&&e.GXdZT(e[p(1732)],O)||e.QoSpN(p(1245),O))&&(this["_clearPi"+p(1436)](),this.emit(e[p(613)],e[p(461)]),this["_pingPon"+p(1565)+"Id"]=e[p(458)](setTimeout,this[p(1682)].bind(this),T)),S[p(1888)]!=="hi")try{if(p(833)!==e[p(862)])e.OjNdt(wl,this,S,[gg,xg,Lg,Ng,Og,pg]);else return this[p(986)]?this[p(986)][p(1321)]:""}catch(M){if(p(1497)==="JZAdZ"){let U=e.dgLQK(lt,e[p(1029)],{message:M[p(1699)],code:on[p(474)+p(1282)],error:M});this[p(1489)+p(1326)+p(681)](U)}else{let U=l[p(1876)](_0x2b878b,l[p(1010)],{message:_0xa852e7[p(1699)],code:_0x4671a3.OPEN_ERROR,error:_0x38d87a});this["_dispatchErrorEv"+p(681)](U)}}},this._onError=S=>{let p=s,T=this["_endpoin"+p(1645)]?.checkReachMaxTries(),O=this[p(1570)+p(1645)]?.["getCurre"+p(1946)+"nt"]();if(T&&!S.message){let M=p(1926)+O+(p(1748)+"ax retri"+p(977)+"ed");this["_dispatc"+p(1326)+p(681)](e[p(1506)](lt,e[p(1029)],{message:M,code:on[p(1625)+p(1308)+"R"],error:S}));return}this[p(986)]&&e[p(528)](this[p(986)][p(1076)+"te"],this.OPEN)&&this[p(1306)+p(1182)](),this[p(1489)+"hErrorEvent"](lt(e[p(1029)],{message:S[p(1699)],code:on[p(1330)+p(878)],error:S}))},this[s(1293)]=async S=>{let p=s;this[p(898)+p(1523)](),this[p(733)+p(1436)](),this["_removeW"+p(657)+"rs"](),this[p(986)]=null,this[p(631)+p(1537)]=!1;let T=this[p(1570)+"tManager"]?.[p(1014)+p(1368)+"es"]();if(!T&&this[p(634)+p(612)]()&&!this["_readyCl"+p(1484)]){let O=this[p(1570)+p(1645)]?.[p(1147)+p(1946)+"nt"](),M=this._options["reconnec"+p(941)+"ptor"](S.code,S[p(1572)]);this[p(1489)+p(1950)+"ent"](l.QUPYH(_t,p(1170),{code:1006,reason:S[p(1572)]||p(1766)+p(931)+p(691)+"wn reaso"+p(1610)+p(1804)+O,willReconnect:M})),M&&this[p(631)]();return}if(l[p(1770)](1e3,S[p(746)])&&this[p(1384)+"osed"]){this["_dispatchCloseEv"+p(681)](_t(l.XpMgQ,{code:1e3,reason:l.MVkXh})),this[p(1570)+p(1645)]?.[p(1787)+p(732)+p(1056)](),this[p(975)+p(1434)]?.["resetCou"+p(717)]();return}if(S[p(746)]!==1e3&&T){let O=this[p(1570)+"tManager"]?.[p(1147)+p(1946)+"nt"](),M=S.reason;M||(M=await cg(this[p(1328)])),M=p(1766)+p(931)+p(1810)+M+", hostname: "+O+(p(480)+p(1290)+p(1446)),this[p(1489)+p(1950)+p(681)](l[p(1876)](_t,"close",{code:S[p(746)],reason:M}));let U=p(1926)+O+(p(1748)+p(583)+p(977)+"ed");this[p(1489)+p(1326)+p(681)](l[p(1058)](lt,l[p(1010)],{message:U,code:on[p(1625)+p(1308)+"R"]})),this[p(1570)+p(1645)]?.[p(1787)+p(732)+p(1056)](),this[p(975)+p(1434)]?.[p(808)+p(717)]();return}if(S[p(746)]!==1e3&&!S[p(1572)]){let O=this[p(1570)+p(1645)]?.[p(1147)+p(1946)+"nt"]();this[p(1489)+"hCloseEvent"](l.gaglm(_t,l[p(546)],{code:S[p(746)],reason:"connecting faile"+p(691)+p(536)+"n, hostn"+p(1804)+O})),this[p(1570)+"tManager"]?.["resetEnd"+p(732)+p(1056)](),this[p(975)+"sCounter"]?.[p(808)+p(717)]();return}this[p(1489)+p(1950)+"ent"](S),this[p(1570)+p(1645)]?.[p(1787)+p(732)+"fig"](),this._pingLossCounter?.[p(808)+p(717)]()},this[s(817)]=null,this[s(1438)]=null,this[s(1826)+"e"]=null,this[s(1478)]=null,this[s(576)+s(752)]=null,this["onReceiv"+s(509)]=null,this[s(1864)+s(463)+s(1606)+"ct"]=null,this[s(1450)+s(1287)]=this[s(1450)+s(1287)][s(1278)](this),this[s(1450)+"ffLine"]=this[s(1450)+s(558)][s(1278)](this),this[s(535)+s(1098)]=this[s(535)+s(1098)].bind(this),this[s(535)+s(1458)]=this[s(535)+s(1458)][s(1278)](this),this[s(736)]={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e[s(800)](1,0),service:0,logIDGenerator:o,headers:void 0,payloadEncoding:"",payloadType:"",fpID:"",deviceID:"",accessKey:"",ttwID:"",bddID:"",aID:"",disableAutoReconnect:!1,customParams:{},pingInterval:15e3,pingTimeoutInterval:4e3,pingFrequency:e[s(1933)],pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e.lsmcF,env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:h,ws:g}=r,w=Array[s(519)](h)?h:e.cesxO==typeof h?[h]:[];if(!w||e.NLivR(0,w[s(1079)]))throw new Error(e.OtQsR);if(!e[s(921)](ig,g))throw new Error(e[s(1108)]);Object[s(1410)](this[s(736)],r),this["_endpoin"+s(1645)]=new ml(w,this[s(736)][s(1127)+"es"]),this[s(975)+"sCounter"]=new ag(this[s(736)][s(1222)+"Count"]),this[s(736)]["automati"+s(755)]&&(e[s(1164)](e[s(1068)],e[s(928)])?(this._isInit=!0,this[s(631)]()):(e[s(1755)](_0xf0637c,e[s(461)]),this[s(1213)](e[s(613)],_0x291d09),this[s(1213)](e.CEilv,_0x10f5b7))),this[s(736)]["listenNetworkCha"+s(1387)]&&(this[s(874)+"T"]||this[s(1724)+"X"]?this[s(834)+"etWorkCh"+s(1171)]():this._isBrowser&&this[s(1773)+s(544)+s(1261)]())}[t(1450)+"nLine"](){let r=t;this[r(736)][r(1716)+r(466)+r(1813)]||this[r(1384)+r(1484)]||this[r(1053)+r(752)]()}["_handleO"+t(558)](){let r=t,s={osOmM:e.RDUGs};if(e[r(965)](e[r(1838)],e[r(1838)])){this["_destroy"+r(1542)+"t"]();let l=e[r(1901)](ba,r(1034)+"t",{message:e[r(1749)]});this[r(1864)+r(463)+"yReconnect"]&&this[r(1864)+"mediatel"+r(1606)+"ct"](l)}else this.emit("message",_0x3fd8a9(ElbROe[r(1176)],{..._0x3c4628}))}[t(1773)+t(544)+t(1261)](){let r=t;this[r(1100)+"er"]&&window[r(1608)+"Listener"](r(1735),this[r(1450)+"nLine"]),this[r(1100)+"er"]&&window[r(1608)+"Listener"](e[r(1793)],this[r(1450)+r(558)]),this[r(1100)+"er"]&&window[r(1608)+"Listener"](e[r(871)],this[r(535)+"ageHide"]),this[r(1100)+"er"]&&window[r(1608)+r(1261)](r(656),this["_handleP"+r(1458)])}[t(1423)+"balEvent"+t(1261)](){let r=t;this._isBrowser&&window[r(860)+"entListener"](r(1735),this._handleOnLine),this._isBrowser&&window[r(860)+r(1904)+r(1365)](r(1122),this._handleOffLine),this._isBrowser&&window[r(860)+r(1904)+r(1365)](e[r(871)],this[r(535)+r(1098)]),this[r(1100)+"er"]&&window["removeEv"+r(1904)+r(1365)](e[r(1086)],this[r(535)+r(1458)])}[t(535)+t(1098)](r){let s=t;!r.persisted&&(this._isBrowser&&window[s(860)+s(1904)+s(1365)](e[s(871)],this[s(535)+s(1098)]),this[s(1100)+"er"]&&window[s(860)+s(1904)+s(1365)](e[s(1086)],this[s(535)+s(1458)]),this.close()),this[s(1100)+"er"]&&window[s(860)+s(1904)+"ner"](e[s(1512)],this["_handleO"+s(1287)]),this[s(1100)+"er"]&&window[s(860)+s(1904)+"ner"](e[s(1793)],this["_handleO"+s(558)])}[t(535)+t(1458)](r){let s=t,l={SJVkS:function(h,g){return e[V(499)](h,g)},BxQfs:function(h,g){return e[V(893)](h,g)},OENgS:function(h,g){return h+g},WapVJ:function(h,g){return e.CsYgI(h,g)},riKhY:function(h,g){return e[V(1449)](h,g)},yaFvH:function(h,g){return h<g},kqHyF:function(h,g){return e[V(1343)](h,g)}};if(e[s(1774)](e[s(1634)],s(478)))_0x16d863.log(_0x27730a);else if(r[s(1209)+"d"])if(e.mAAkX!==e[s(1040)]){let h=_0x1c9a98[s(1641)+"At"](_0x36ab67);FUlhEt.SJVkS(h,55296)&&FUlhEt[s(1177)](h,56319)&&FUlhEt.OENgS(_0xafadd2,1)<_0x1ff751&&(h=FUlhEt.WapVJ(FUlhEt[s(1658)](h,10),_0x39bf41[s(1641)+"At"](++_0xda8403))-56613888),_0x2c422d+=FUlhEt[s(453)](h,128)?1:FUlhEt.kqHyF(h,2048)?2:FUlhEt[s(1555)](h,65536)?3:4}else this["_navigat"+s(612)]()&&(!this[s(986)]||e[s(609)](this[s(986)][s(1076)+"te"],this[s(1025)])||this[s(986)][s(1076)+"te"]!==this[s(524)+"NG"])&&this[s(1450)+s(1287)](),this[s(1100)+"er"]&&window[s(1608)+"Listener"](s(1735),this[s(1450)+s(1287)]),this._isBrowser&&window[s(1608)+s(1261)](s(1122),this[s(1450)+s(558)])}async[t(1603)+t(695)](r){let s=t,{fpID:l,deviceID:h,bddID:g,ttwID:w,accessKey:S,aID:p,customParams:T={},enableAutoAck:O,enableQoS:M,QoSLevel:U,env:H}=this[s(736)],W,he,cn;if(this[s(1100)+"er"]||this[s(1724)+"X"]||this._isMiniTT)if(e[s(1218)](e[s(945)],"PBiHR"))W=location&&e[s(1664)](e[s(604)],location[s(1321)])?e[s(905)]:e.eoCXa,he=r[s(788)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),cn=/^wss(.*:\/\/)/.test(r)?r:""+W+he;else{let ni=this[s(1570)+s(1645)]?.[s(1147)+s(1946)+"nt"]();this[s(1489)+s(1950)+"ent"](e[s(593)](_0x59fda6,e[s(1016)],{code:_0x492acc[s(746)],reason:s(1766)+s(931)+s(691)+s(536)+"n, hostname: "+ni})),this[s(1570)+s(1645)]?.[s(1787)+s(732)+s(1056)](),this[s(975)+s(1434)]?.["resetCou"+s(717)]();return}else W=e[s(905)],he=r[s(788)](/(^http)((?:[s]*:\/\/))/,""),cn=/(^ws)((?:[s]*:\/\/))/.test(he)?he:""+W+he;let Al=g?e[s(1126)]:w?s(1502):s(857)+"d",kl=g||w||h;if(!kl||!Al)throw new Error(e[s(918)]);let Ug=e[s(1840)]==typeof T?await e[s(1050)](T):T,Gg=H?e.infTt(og,H[s(572)],H[s(1396)]):{},Ra=Object.assign({device_platform:e.fwpbF,version_code:e[s(816)],access_key:S,fpid:l,aid:p,[Al]:kl,xsack:O?1:0,xaack:O?1:0,xsqos:M?1:0,qos_level:M?U:void 0,qos_sdk_version:2,...Gg},Ug),Hg=Object[s(1885)](Ra)[s(1580)]((ni,Ca)=>Ra[Ca]!==void 0?""+ni+(ni?"&":"?")+Ca+"="+Ra[Ca]:ni,"");return cn+s(553)+Hg}async[t(631)](){let r=t;if(!(this[r(631)+r(1537)]||this[r(1384)+"osed"])){this[r(631)+r(1537)]=!0;try{if(e[r(626)]("tBctk",e[r(1039)])){_0x4b377a[r(1581)](_0x5b15bf)||(_0x49eb43=_0x35cc87.fromNumber(_0xc9c778));let s=e[r(491)](this.high,16),l=e[r(692)](65535,this[r(1351)]),h=e[r(581)](this[r(582)],16),g=e.ObFlT(65535,this[r(582)]),w=e.OkLFT(_0x49f889.high,16),S=e.fLqph(65535,_0x355696.high),p=e.fNvAg(_0x2e98ea.low,16),T=e[r(1077)](65535,_0x3661d4.low),O=0,M=0,U=0,H=0;return H+=e[r(1516)](g,T),U+=e[r(1845)](H,16),H&=65535,U+=h+p,M+=e[r(526)](U,16),U&=65535,M+=l+S,O+=e[r(1149)](M,16),M&=65535,O+=e[r(915)](s,w),O&=65535,_0x204faa[r(1879)](e.NNXwg(e[r(1912)](U,16),H),e[r(1552)](O<<16,M),this[r(1476)])}else{let s=this[r(1570)+r(1645)]?.["checkCur"+r(602)+r(658)+r(493)+r(1623)](),{timeoutInterval:l}=this._options;if(s){let g=this[r(1570)+"tManager"]?.[r(1147)+r(1946)+"nt"](),w=this[r(1570)+r(1645)]?.[r(1354)+"ackupEnd"+r(1320)+r(1556)+r(1788)](),S=this[r(1570)+r(1645)]?.["getCurre"+r(1946)+r(1224)+r(892)]();if(w){let p=r(1926)+g+(r(1312)+r(480)+"tries re"+r(1913)+r(762)+r(1322)+r(587))+w+(r(1713)+"y"),T=e[r(464)](lt,e[r(1029)],{message:p,code:on[r(1625)+r(1308)+"R"]});this[r(1630)](p),this[r(1489)+r(1326)+r(681)](T),this[r(1328)]=await this[r(1603)+r(695)](w),this._debug(r(1926)+w+" "+S+" times"),this["_removeW"+r(657)+"rs"]()}else{let p=r(1926)+g+(" timeout"+r(480)+r(1290)+"ached");this._debug(p),this["_dispatc"+r(1326)+"ent"](lt("error",{message:p,code:on[r(1625)+"IES_ERROR"]}));return}}else{if(r(1827)===r(1264))return _0x501361[r(894)+"t8"]?_0x36cdd8[r(894)+"t8"](_0x54ac11,_0x3cd16d):_0x141031[_0x521596]=e.GzFYx(255,_0x2695ca),e.xvgAJ(_0x460f13,1);{let g=this["_endpoin"+r(1645)]?.[r(1147)+r(1946)+r(791)+"ateCount"](),w=this[r(1570)+"tManager"]?.[r(1147)+r(1946)+r(1224)+"ount"]();this[r(1328)]=await this[r(1603)+r(695)](g||""),this[r(1630)](r(1926)+g+" "+w+r(780)),this["_removeW"+r(657)+"rs"]()}}if(this._isInit)this[r(1156)]=!1;else{let g=ba("reconnect",{message:e.rftpg});this[r(576)+r(752)]&&this.onStartReconnect(g)}let h=this[r(1570)+r(1645)]?.["getCurrentEndpoi"+r(1224)+r(892)]()||0;h>1&&await this[r(1174)](e[r(1944)](h,1)),this[r(1630)](r(1766)+r(1568)+this[r(1328)]+(r(1574)+"ls: ")+this._protocols),this._ws=e[r(700)](rg,{url:this[r(1328)],protocols:[this[r(1021)+"ls"]],headers:this[r(736)][r(1951)+r(1587)+"s"][r(1493)+r(727)]},this._options.ws),(this._isBrowser||this[r(595)+"r"])&&this[r(986)]&&(this._ws[r(849)+"pe"]=this[r(1266)+"ype"]),this["_addWsLi"+r(486)](),this[r(631)+r(1535)+r(1670)]=e[r(700)](setTimeout,this[r(797)+"ut"][r(1278)](this),l)}}catch(s){throw this[r(631)+"Lock"]=!1,s}}}[t(898)+t(1523)](){let r=t;e[r(1022)](clearTimeout,this[r(631)+r(1535)+"utId"]),this["_connect"+r(1535)+"utId"]=null}[t(733)+"ngTimer"](){let r=t;e[r(1023)](clearTimeout,this[r(579)+r(1565)+"Id"]),e[r(1850)](clearTimeout,this[r(592)+r(1720)+"tId"]),this._pingPongTimeoutId=null,this[r(592)+"ctTimeou"+r(1345)]=null}[t(1630)](...r){let s=t;this._options[s(1693)]&&console[s(774)][s(832)](console,[s(554)+">",...r])}[t(1033)+t(454)+"e"](r){let s=t,{initReconnectInterval:l,maxReconnectInterval:h,reconnectIntervalGrowFactor:g}=this[s(736)],w=e[s(1409)](l,Math[s(1899)](g,e[s(1777)](r,1)));return e.UHaEC(w,h)?h:w}_ping(){let r=t;if(this[r(986)]&&e[r(1342)](this._ws[r(1076)+"te"],this[r(524)+"NG"])){this[r(733)+r(1436)](),this[r(579)+r(1565)+"Id"]=e[r(866)](setTimeout,this._ping[r(1278)](this),this[r(736)][r(1486)+r(1347)]);return}if(!this[r(986)]||this[r(986)][r(1076)+"te"]!==this[r(1025)])return void this[r(1053)+"econnect"]();this[r(986)]&&this[r(986)][r(969)]("hi"),this[r(592)+r(1720)+r(1345)]=setTimeout(this._handleReconnectTimeout.bind(this),this[r(736)][r(1124)+r(1120)+r(739)])}[t(1053)+t(752)+t(1162)](){let r=t;this["_pingLos"+r(1434)]?.[r(1739)](),this[r(1721)](e[r(770)],e[r(803)]),this[r(975)+r(1434)]?.checkReachMaxCount()?this[r(1053)+"econnect"]():this[r(1682)]()}["_navigat"+t(612)](){let r=t;return this._isMiniTT||this[r(1724)+"X"]?this[r(1820)+r(1083)+"line"]:(this[r(1100)+"er"]||this[r(595)+"r"])&&this[r(736)][r(769)+r(459)+"nged"]?navigator[r(1139)]:!0}[t(1053)+t(752)](){let r=t;if(e[r(1746)]===e[r(995)]){let s=this[r(1687)][r(679)](this[r(982)]),l=_0x131d6b[r(1669)](s||"{}");return _0x4cc4d4[r(1802)](l)}else{if(!this[r(634)+r(612)]()||this[r(1384)+r(1484)])return;this[r(1570)+r(1645)]?.[r(1787)+r(732)+r(1056)](),this[r(975)+r(1434)]?.[r(808)+"nter"](),this[r(986)]?this[r(1306)+"ect"](1001,e[r(1510)],!0):this._connect()}}[t(834)+"etWorkCh"+t(1171)](){let r=t,s={qeHiw:function(l,h){return e[V(1731)](l,h)},NoemA:function(l){return e.itFcQ(l)}};e.uWwsj===e[r(637)]?this[r(874)+"T"]?tt[r(1884)+r(1758)+r(1468)](({isConnected:l})=>{let h=r;this[h(1820)+"igatorOnline"]=l,l?this[h(1450)+h(1287)]():this["_handleO"+h(558)]()}):this[r(1724)+"X"]&&wx[r(1884)+r(1758)+r(1468)](({isConnected:l})=>{let h=r;this["_miniNav"+h(1083)+"line"]=l,l?this[h(1450)+h(1287)]():this[h(1450)+"ffLine"]()}):(MOhZZF.qeHiw(_0x3d46c2,_0x3356fd(_0x301d22[r(776)])),MOhZZF[r(1249)](_0x567382))}_wait(r){return new Promise(s=>{let l=V;setTimeout(s,this[l(1033)+l(454)+"e"](r))})}[t(1306)+t(1182)](r=1e3,s="",l=!1){let h=t;this._ws&&this["_destroy"+h(1542)+"t"](r,s,l)}[t(797)+"ut"](){let r=t,s=this[r(1570)+r(1645)]?.[r(1147)+r(1946)+"nt"]();this[r(1630)](r(1926)+s+r(1312)),this[r(1306)+r(1182)](1001,e.FvaaY,!0)}[t(635)](r){let s=t,l={FyyGS:function(g,w,S){return e.pCtHf(g,w,S)}},h=e[s(974)](Ut,r);this[s(986)]&&e[s(1889)](this[s(986)][s(1076)+"te"],this[s(1025)])&&(e[s(1626)](e[s(956)],e[s(1265)])?(this[s(986)]&&this[s(986)].send(h),this._debug(s(1590),r)):(_0x56b1cf(_0x21bc86,10),tPktjx[s(651)](_0x26d01e,_0x12ad62,_0x7744f8)))}[t(1074)+t(657)+"rs"](){let r=t;this[r(986)]&&(this[r(986)][r(860)+r(1904)+r(1365)](e[r(1408)],this[r(660)]),this[r(986)][r(860)+"entListe"+r(1365)](e[r(1016)],this[r(1293)]),this._ws[r(860)+r(1904)+r(1365)](e[r(1896)],this[r(855)+"ge"]),this[r(986)][r(860)+r(1904)+r(1365)](e[r(1029)],this[r(1057)]))}[t(1747)+"steners"](){let r=t,s=(r(1575)+"2")[r(1017)]("|"),l=0;for(;;){switch(s[l++]){case"0":this[r(986)][r(1608)+r(1261)](e[r(1016)],this[r(1293)]);continue;case"1":if(!this[r(986)])return;continue;case"2":this[r(986)].addEventListener(e[r(1029)],this[r(1057)]);continue;case"3":this[r(986)][r(1608)+r(1261)](e[r(1408)],this[r(660)]);continue;case"4":this[r(986)]["addEvent"+r(1261)](e[r(1896)],this[r(855)+"ge"]);continue}break}}[t(1447)+t(1752)](r=1e3,s=""){let l=t;try{this[l(986)]&&this[l(986)].close(r,s)}catch{}}["_destroy"+t(1542)+"t"](r=1e3,s="",l=!1){let h=t;if(this[h(733)+h(1436)](),this[h(898)+h(1523)](),this[h(1074)+h(657)+"rs"](),this[h(1447)+"nceClose"](1e3,s),this["_connect"+h(1537)]=!1,l&&this["_navigat"+h(612)]()&&!this[h(1384)+"osed"]){if(this[h(1570)+h(1645)]?.[h(1014)+"chMaxTries"]()){let w=this[h(1570)+h(1645)]?.[h(1147)+h(1946)+"nt"]();this[h(1489)+h(1950)+h(681)](e[h(1001)](_t,e[h(1016)],{code:1006,reason:h(1926)+w+(" timeout, max retries re"+h(1446)),wasClean:!0}))}else if(e[h(1744)]("eEqyu",e[h(858)]))e[h(1508)](_0x39d2b4,this,_0x5d4cc5,[_0x394b36,_0x75ea7b,_0x481436]);else{let w=this[h(736)][h(1034)+h(941)+h(1277)](r,s);this["_dispatc"+h(1950)+"ent"](e[h(1356)](_t,"close",{code:r,reason:s,wasClean:!0,willReconnect:w})),w&&this._connect()}return}this["_navigat"+h(612)]()||this[h(1384)+h(1484)]?this[h(1489)+h(1950)+"ent"](e.XsYNM(_t,e[h(1016)],{code:r,reason:e.zzvXo})):this["_dispatc"+h(1950)+"ent"](e[h(1588)](_t,e[h(1016)],{code:1006,reason:e[h(1837)]})),this[h(986)]=null,this["_endpoin"+h(1645)]?.["resetEnd"+h(732)+h(1056)](),this[h(975)+"sCounter"]?.[h(808)+h(717)]()}[t(1489)+t(1661)+"nt"](r){let s=t;if(e[s(1685)](s(1045),e[s(1663)]))this[s(1721)](e[s(1408)],r),this[s(1478)]&&this[s(1478)](r);else return this[s(1865)+s(1008)+s(901)+"t"]}["_dispatc"+t(1473)+t(1818)](r){let s=t;this[s(1721)](e[s(1896)],r),this.onmessage&&this[s(1826)+"e"](r)}[t(1489)+t(810)+t(1303)](r){let s=t;this.emit(e[s(1839)],r),this[s(1541)+s(509)]&&this[s(1541)+s(509)](r)}["_dispatchErrorEv"+t(681)](r){let s=t;this[s(1721)](s(962),r),this[s(1438)]&&this[s(1438)](r)}[t(1489)+"hCloseEv"+t(681)](r){let s=t;this[s(1721)](e[s(1016)],r),this[s(817)]&&this[s(817)](r)}get[t(849)+"pe"](){let r=t;if(e[r(1938)](e.RSJeZ,r(669)))_0x316a7c.o=(s,l)=>_0x22b365.prototype[r(1589)+r(1362)].call(s,l);else return this[r(986)]?this._ws.binaryType:this[r(1266)+r(1771)]}set[t(849)+"pe"](r){let s=t;if(e[s(1781)](e[s(993)],e[s(494)]))this[s(1266)+s(1771)]=r,this[s(986)]&&(this._ws[s(849)+"pe"]=r);else return this._ws?this[s(986)].readyState:this[s(736)]["automati"+s(755)]?this[s(524)+"NG"]:this[s(522)]}get[t(1893)+"nt"](){let r=t;if(e[r(1566)]!==e[r(1566)]){if(VanGqX[r(1824)](_0x4b8572,_0x453724)){if(VanGqX[r(498)](_0x29733a,VanGqX.DipNV))return _0x5be2e3[r(1729)](_0x20b088);if(VanGqX[r(725)](_0x1468f7,VanGqX.TwSLY))return _0x4a3303[r(1941)+r(1783)]||_0x5aedc4[r(1729)](_0x16a33b);if(VanGqX.ATcNg(_0x20b018,VanGqX[r(933)]))return _0x1a2db0.objectStoreNames[1]?void 0:_0x352ceb[r(1941)+r(1677)](_0x1cfa5b.objectStoreNames[0])}return VanGqX[r(973)](_0x560a5c,_0x158b3e[_0x142ae0])}else return this["_endpoin"+r(1645)]?.[r(1147)+r(1946)+r(1224)+"ount"]()||0}get bufferedAmount(){let r=t,s={MStGG:function(h,g){return e[V(763)](h,g)},AXAcM:function(h,g){return e.GALYI(h,g)},YOxbY:function(h,g){return e[V(1652)](h,g)},hgpnu:function(h,g){return e.Dprvb(h,g)},RkafA:e[r(1285)],SQNIx:e[r(1756)]},l=this[r(912)+r(790)][r(1580)]((h,g)=>{let w=r,S={Pezhw:function(p,T){return s[V(768)](p,T)},HxHpp:function(p,T){return p>=T},qXRAS:function(p,T){return p+T},ESwKi:function(p,T){return s[V(1031)](p,T)},FtTNZ:function(p,T){return s[V(1627)](p,T)}};if(s[w(639)](s[w(997)],s.SQNIx)){if(cTyfWa.Pezhw(_0x1799af,_0x314c77))return _0x1bbdd8?_0x5752e9:_0xfca98b;if(_0x4951d5){if(cTyfWa[w(961)](_0x5c1353,_0x385191))return _0x8ca05b}else{if(_0x4da769<=-_0x13e88e)return _0x5a96b5;if(cTyfWa[w(961)](cTyfWa.qXRAS(_0x51f8c9,1),_0x25becc))return _0x31a79a}return _0x2b7243[w(1879)](_0x216224%_0x2bd0a8|0,cTyfWa[w(1835)](cTyfWa[w(798)](_0x29d9b2,_0x6ba337),0),_0x1d8dfa)}else return h+=g&&g[w(564)+"th"]||0,h},0);return e[r(1844)](l,this[r(986)]?this[r(986)][r(1038)+"Amount"]:0)}get[t(1895)+"ns"](){let r=t;if(e[r(1371)](e[r(1712)],e[r(701)]))return this[r(986)]?this[r(986)][r(1895)+"ns"]:"";_0x58972c=_0x5e5ac8.concat(_0x44b804),_0x43eb8d=_0x590d58.concat(_0x1f0950[_0x3a0875])}get protocol(){let r=t;return this._ws?this[r(986)][r(1321)]:""}get readyState(){let r=t;return this[r(986)]?this[r(986)][r(1076)+"te"]:this[r(736)][r(1288)+r(755)]?this[r(524)+"NG"]:this[r(522)]}get url(){let r=t;return this[r(986)]?this[r(986)].url:this[r(1328)]}[t(1170)](r=1e3,s){let l=t,h=e[l(794)][l(1017)]("|"),g=0;for(;;){switch(h[g++]){case"0":this[l(1423)+l(544)+l(1261)]();continue;case"1":this[l(733)+l(1436)]();continue;case"2":this[l(1632)+l(1542)+"t"](r,s);continue;case"3":if(e[l(1427)](this[l(986)][l(1076)+"te"],this[l(522)])||this._ws[l(1076)+"te"]===this[l(1927)])return void this._debug(e[l(949)]);continue;case"4":if(!this[l(986)])return void this[l(1630)](e[l(1902)]);continue;case"5":this["_readyCl"+l(1484)]=!0;continue;case"6":this[l(898)+l(1523)]();continue;case"7":this[l(1528)+l(1046)]?.[l(1709)]();continue}break}}async send(r,s){let l=t,h={BbKOF:e[l(871)],RScWU:e.SgVzZ,zCqvK:e[l(1512)]};if(l(510)!==e[l(603)])!_0x493459[l(1209)+"d"]&&(this[l(1100)+"er"]&&_0x55af20["removeEv"+l(1904)+"ner"](aISvFS[l(1738)],this[l(535)+l(1098)]),this[l(1100)+"er"]&&_0x37675f[l(860)+l(1904)+l(1365)](aISvFS[l(1631)],this._handlePageShow),this[l(1170)]()),this._isBrowser&&_0x1c3dcc[l(860)+l(1904)+l(1365)](aISvFS[l(1036)],this[l(1450)+"nLine"]),this[l(1100)+"er"]&&_0x537598[l(860)+l(1904)+l(1365)]("offline",this[l(1450)+"ffLine"]);else{if(e.ajsDX(null,r))throw new Error(e[l(980)]);e.cLcVv(e[l(1909)],typeof r)&&(r=JSON.stringify(r)),e[l(1875)](e[l(1018)],typeof r)&&!e[l(1604)](r,ArrayBuffer)&&!(r[l(1543)]&&r[l(1543)]instanceof ArrayBuffer)&&(r=JSON.stringify(r));let g=await e[l(994)](El,r),w=e[l(988)](sg,r),{method:S=0,service:p=this[l(736)].service,logID:T=this[l(736)][l(1871)+l(1052)](),headers:O=this[l(736)][l(1479)],payloadEncoding:M=this[l(736)]["payloadE"+l(1003)],payloadType:U=this[l(736)][l(841)+l(1771)],logIDNew:H=this[l(736)].logIDNewConfig[l(951)+l(842)+"teLogIDNew"]?i(this._options[l(472)+"Config"][l(1202)]):""}=e.JGutJ(s,{});if(!p)throw new Error(e[l(1294)]);let W={SeqID:pe[l(946)+"er"](this[l(1272)]++),LogID:pe[l(946)+"er"](T),service:p,method:S,headers:O,payloadEncoding:e[l(1636)](M,Object)?M[l(1442)]?M[l(1442)]:"":M,payloadType:e.PHnrc(U,Object)?U.type?U.type:w:U||w,payload:g,LogIDNew:H},he=e.KgsuY(Ut,W);return this[l(986)]&&e[l(1355)](this._ws[l(1076)+"te"],this[l(1025)])?(this._ws&&this[l(986)][l(969)](he),this._debug(l(1765),W)):e.eheoE(this[l(912)+l(790)].length,this[l(736)]["maxMessageQueueL"+l(939)])?(this["_message"+l(790)].push(he),this[l(1630)](e[l(908)],W)):(this[l(912)+l(790)][l(538)](),this[l(912)+"Queue"][l(1807)](he)),{seqID:this[l(1272)],logID:T,logIDNew:H}}}async[t(1034)+"t"](r){let s=t;if(e.qHFTJ(s(1600),"mPuCP"))return new _0x2b76c4(_0x232ab4,_0x59e3ec,_0xb4bb2c);{let{url:l}=e.NlBem(r,{}),h=Array[s(519)](l)?l:e[s(647)]("string",typeof l)?[l]:[];r&&Object.assign(this[s(736)],r),h&&h[s(1079)]?this["_endpoin"+s(1645)]=new ml(h,this[s(736)].maxRetries):this[s(1570)+s(1645)]?.[s(1787)+"pointCon"+s(1056)](),this[s(975)+"sCounter"]?.[s(808)+s(717)](this._options[s(1222)+s(721)]),this[s(1384)+"osed"]=!1,this[s(986)]&&e[s(1460)](this[s(986)].readyState,this[s(522)])?this[s(1306)+s(1182)](1e3,e.SeeiJ,!0):e[s(1256)](e.twYsv,s(1208))?(this["maxLossC"+s(892)]=_0x27a8df,this[s(1379)]=0):(this[s(1156)]=!0,this._connect())}}async connect(){let r=t;if(!this._connectLock){let s=e.ssTWc.split("|"),l=0;for(;;){switch(s[l++]){case"0":this[r(1156)]=!0;continue;case"1":this[r(1384)+r(1484)]=!1;continue;case"2":this[r(1570)+r(1645)]?.[r(1787)+"pointCon"+r(1056)]();continue;case"3":this[r(975)+"sCounter"]?.[r(808)+"nter"]();continue;case"4":this._connect();continue}break}}}["addEvent"+t(1261)](r,s){this.on(r,s)}["dispatch"+t(1818)](r){let s=t,{type:l}=r;this[s(1721)](l,r)}[t(860)+t(1904)+t(1365)](r,s){this[t(1213)](r,s)}pingOnce(){return new Promise((r,s)=>{let l=V,h={Ayiel:function(S,p){return e[V(1776)](S,p)},tCjJE:function(S,p){return S(p)},FNrqG:e[l(461)],njbXv:l(873)+l(1019)+"s",XhhPi:"vpxYi",HnZeT:e[l(1920)],NjzPe:e[l(803)],zmLDy:e.CEilv};this[l(733)+l(1436)](),this[l(579)+l(1565)+"Id"]=setTimeout(this[l(1682)][l(1278)](this),this[l(736)].pingInterval);let g=()=>{let S=l;if(h[S(1551)](S(707),"qzkLg"))return _0xb718c2?this[S(924)+"E"]():this[S(1734)+"E"]();h[S(978)](r,h[S(1005)]),this[S(1213)](h[S(563)],g),this.off(S(873)+S(1437)+"t",w)},w=()=>{let S=l;h[S(1551)](h.XhhPi,h[S(1474)])?(h[S(978)](s,h[S(867)]),this.off(h[S(563)],g),this[S(1213)](h.zmLDy,w)):_0x26a2d6.log(_0x5a1ddc)};this.on(e[l(613)],g),this.on(e.CEilv,w),this[l(1682)]()})}}})(),Fe[N(1012)+N(663)]=De[N(1012)+N(663)],Fe["CustomEr"+N(851)]=De[N(1296)+N(851)],Fe[N(694)+"e"]=De.ErrorCode,Fe[N(1818)]=De[N(1818)],Fe.FWS=De[N(1129)],Fe[N(1465)+N(1142)+N(1152)]=De["Frontier"+N(1142)+"vent"],Fe[N(1142)+"vent"]=De[N(1142)+N(1152)],Fe[N(1500)+"t"]=De[N(1500)+"t"],Fe["Reconnec"+N(685)]=De[N(1515)+N(685)],Fe[N(724)+N(663)]=De["createCl"+N(663)],Fe["createEr"+N(851)]=De[N(611)+N(851)],Fe[N(1869)+N(843)+"nt"]=De[N(1869)+N(843)+"nt"],Fe[N(1395)+N(1809)]=De[N(1395)+N(1809)],Fe[N(1414)+"connectE"+N(1152)]=De[N(1414)+N(1238)+N(1152)],Fe[N(1701)+"rame"]=De[N(1701)+N(1717)],Fe.encodeFrame=De["encodeFr"+N(640)];for(Qo in De)[N(1012)+N(663),N(1296)+"rorEvent",N(694)+"e",N(1818),N(1129),N(1465)+N(1142)+"vent","MessageEvent",N(1500)+"t",N(1515)+N(685),"createCloseEvent",N(611)+"rorEvent","createMe"+N(843)+"nt",N(1395)+N(1809),N(1414)+N(1238)+N(1152),N(1701)+N(1717),N(1041)+"ame"][N(1718)](Qo)===-1&&(Fe[Qo]=De[Qo]);var Qo;Object[N(811)+N(1362)](Fe,N(1059)+"le",{value:!0})});import{existsSync as eI,openSync as tI}from"node:fs";import{mkdir as nI}from"node:fs/promises";import{dirname as rI}from"node:path";import{fileURLToPath as iI}from"node:url";function oI(t,e){return e==="legacy"?t.logFile:t.daemonStdioLog}function Jd(t=Y()){return eI(t.libEntry)?t.libEntry:iI(new URL("../index.ts",import.meta.url))}async function fp(t={}){let e=t.paths??Y(),n=t.entryOverride??Jd(e),i=oI(e,process.env.COZE_BRIDGE_LOG_MODE);await nI(rI(i),{recursive:!0});let o=tI(i,"a"),d=n.endsWith(".ts")?["--import","tsx/esm",n,"--daemon"]:[n,"--daemon"],u=st(process.execPath,d,{detached:!0,stdio:["ignore",o,o],env:{...process.env,[ds]:"1"}});if(u.unref(),typeof u.pid!="number")throw new Error("failed to spawn daemon (no pid)");return sI.info("daemon spawned",{pid:u.pid,entry:n}),{pid:u.pid,entry:n}}var sI,ds,la=nt(()=>{"use strict";Zt();ne();Re();sI=q("spawn-daemon"),ds="COZE_BRIDGE_DAEMON"});import{spawn as rA}from"node:child_process";import{mkdir as iA,unlink as sA,writeFile as oA}from"node:fs/promises";import{dirname as aA,join as cA}from"node:path";function Yr(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function dA(t){if(!t)return"";let e=Object.entries(t).map(([n,i])=>` <key>${Yr(n)}</key>
|
|
21
|
+
<string>${Yr(i)}</string>`).join(`
|
|
22
22
|
`);return e?`
|
|
23
23
|
<key>EnvironmentVariables</key>
|
|
24
24
|
<dict>
|
|
25
25
|
${e}
|
|
26
|
-
</dict>`:""}function
|
|
26
|
+
</dict>`:""}function lA(t,e){return new Promise((n,i)=>{let o=rA(t,e,{stdio:["ignore","pipe","pipe"]}),c="";o.stderr?.on("data",d=>{c+=d.toString("utf8")}),o.on("error",i),o.on("close",d=>{d===0?n():i(new Error(`${t} ${e.join(" ")} exited ${d}: ${c.trim()}`))})})}var Zr,fs,ga,il,Np=nt(()=>{"use strict";ne();Zr=q("supervisor.launchd"),fs="ai.coze.bridge",ga=lA,il={platform:"darwin",renderConfig(t){return`<?xml version="1.0" encoding="UTF-8"?>
|
|
27
27
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
28
28
|
<plist version="1.0">
|
|
29
29
|
<dict>
|
|
30
30
|
<key>Label</key>
|
|
31
|
-
<string>${
|
|
31
|
+
<string>${fs}</string>
|
|
32
32
|
<key>ProgramArguments</key>
|
|
33
33
|
<array>
|
|
34
|
-
<string>${
|
|
35
|
-
<string>${
|
|
34
|
+
<string>${Yr(t.nodeBin)}</string>
|
|
35
|
+
<string>${Yr(t.entry)}</string>
|
|
36
36
|
<string>--daemon</string>
|
|
37
37
|
</array>
|
|
38
38
|
<key>RunAtLoad</key>
|
|
@@ -42,13 +42,13 @@ ${e}
|
|
|
42
42
|
<key>ThrottleInterval</key>
|
|
43
43
|
<integer>10</integer>
|
|
44
44
|
<key>StandardOutPath</key>
|
|
45
|
-
<string>${
|
|
45
|
+
<string>${Yr(t.logFile)}</string>
|
|
46
46
|
<key>StandardErrorPath</key>
|
|
47
|
-
<string>${
|
|
47
|
+
<string>${Yr(t.logFile)}</string>${dA(t.env)}
|
|
48
48
|
</dict>
|
|
49
49
|
</plist>
|
|
50
|
-
`},configPath(t){return
|
|
51
|
-
`):""}function
|
|
50
|
+
`},configPath(t){return cA(t.homeDir,"Library","LaunchAgents",`${fs}.plist`)},async install(t,e){let n=e?.activate!==!1,i=this.configPath(t);if(await iA(aA(i),{recursive:!0}),await oA(i,this.renderConfig(t),"utf8"),Zr.info("plist written",{plistPath:i,activate:n}),!n)return;await ga("launchctl",["unload","-w",i]).catch(c=>Zr.info("launchctl unload before load (ignored, likely not loaded yet)",{err:String(c)})),await ga("launchctl",["load","-w",i]),Zr.info("launchd job loaded",{label:fs});let o=process.getuid?.()??0;await ga("launchctl",["kickstart","-k",`gui/${o}/${fs}`]),Zr.info("launchd job kickstarted",{label:fs,uid:o})},async uninstall(t){let e=this.configPath(t);await ga("launchctl",["unload","-w",e]).catch(n=>Zr.warn("launchctl unload failed (ignored)",{err:String(n)})),await sA(e).catch(n=>{if(n.code!=="ENOENT")throw n}),Zr.info("launchd job removed",{plistPath:e})}}});import{spawn as uA}from"node:child_process";import{mkdir as fA,unlink as hA,writeFile as xA}from"node:fs/promises";import{dirname as pA,join as Mp}from"node:path";function wa(t,e){return t.isRoot?e:["--user",...e]}function mA(t){return t?Object.entries(t).map(([e,n])=>{let i=n.replace(/\\/g,"\\\\").replace(/"/g,'\\"');return`Environment="${e}=${i}"`}).join(`
|
|
51
|
+
`):""}function _a(t,e){return new Promise((n,i)=>{let o=uA(t,e,{stdio:["ignore","pipe","pipe"]}),c="";o.stderr?.on("data",d=>{c+=d.toString("utf8")}),o.on("error",i),o.on("close",d=>{d===0?n():i(new Error(`${t} ${e.join(" ")} exited ${d}: ${c.trim()}`))})})}var ma,Xr,gA,sl,Bp=nt(()=>{"use strict";ne();ma=q("supervisor.systemd"),Xr="coze-bridge.service",gA="/etc/systemd/system";sl={platform:"linux",renderConfig(t){let e=t.isRoot?"multi-user.target":"default.target";return`[Unit]
|
|
52
52
|
Description=Coze Bridge daemon
|
|
53
53
|
After=network.target
|
|
54
54
|
|
|
@@ -59,10 +59,10 @@ Restart=always
|
|
|
59
59
|
RestartSec=3
|
|
60
60
|
StandardOutput=append:${t.logFile}
|
|
61
61
|
StandardError=append:${t.logFile}
|
|
62
|
-
${
|
|
62
|
+
${mA(t.env)}
|
|
63
63
|
[Install]
|
|
64
64
|
WantedBy=${e}
|
|
65
|
-
`},configPath(t){return t.isRoot?
|
|
65
|
+
`},configPath(t){return t.isRoot?Mp(gA,Xr):Mp(t.homeDir,".config","systemd","user",Xr)},async install(t,e){let n=e?.activate!==!1,i=this.configPath(t),o=t.isRoot?"system":"user";await fA(pA(i),{recursive:!0}),await xA(i,this.renderConfig(t),"utf8"),ma.info("systemd unit written",{unitPath:i,mode:o,activate:n}),await _a("systemctl",wa(t,["daemon-reload"])),await _a("systemctl",wa(t,n?["enable","--now",Xr]:["enable",Xr])),ma.info("systemd unit enabled",{unitName:Xr,mode:o,activate:n})},async uninstall(t){let e=this.configPath(t);await _a("systemctl",wa(t,["disable","--now",Xr])).catch(n=>ma.warn("systemctl disable failed (ignored)",{err:String(n)})),await hA(e).catch(n=>{if(n.code!=="ENOENT")throw n}),await _a("systemctl",wa(t,["daemon-reload"])).catch(()=>{}),ma.info("systemd unit removed",{unitPath:e})}}});import{spawn as wA}from"node:child_process";import{join as _A}from"node:path";function Fp(t,e){return new Promise((n,i)=>{let o=wA(t,e,{stdio:["ignore","pipe","pipe"],shell:!1}),c="";o.stderr?.on("data",d=>{c+=d.toString("utf8")}),o.on("error",i),o.on("close",d=>{d===0?n():i(new Error(`${t} ${e.join(" ")} exited ${d}: ${c.trim()}`))})})}var ol,ya,al,zp=nt(()=>{"use strict";ne();ol=q("supervisor.taskscheduler"),ya="CozeBridge",al={platform:"win32",renderConfig(t){return`<?xml version="1.0" encoding="UTF-16"?>
|
|
66
66
|
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
|
|
67
67
|
<RegistrationInfo>
|
|
68
68
|
<Description>Coze Bridge daemon</Description>
|
|
@@ -86,55 +86,55 @@ WantedBy=${e}
|
|
|
86
86
|
</Exec>
|
|
87
87
|
</Actions>
|
|
88
88
|
</Task>
|
|
89
|
-
`},configPath(t){return w2(t.homeDir,".coze","bridge","task.xml")},async install(t){let r=`cmd.exe /c ${[`^"${t.nodeBin}^"`,`^"${t.entry}^"`,"--daemon",`>> ^"${t.logFile}^" 2>&1`].join(" ")}`;await zp("schtasks",["/Create","/SC","ONLOGON","/TN",Ea,"/TR",r,"/RU",t.userName,"/F"]),cl.info("task scheduler entry created",{task:Ea,logFile:t.logFile})},async uninstall(t){await zp("schtasks",["/Delete","/TN",Ea,"/F"]).catch(e=>cl.warn("schtasks /Delete failed (ignored)",{err:String(e)})),cl.info("task scheduler entry removed",{task:Ea})}}});var Gp={};Na(Gp,{buildContext:()=>S2,getSupervisor:()=>E2,launchdSupervisor:()=>ol,systemdSupervisor:()=>al,taskSchedulerSupervisor:()=>dl});import{homedir as _2,userInfo as y2}from"node:os";function E2(t=process.platform){switch(t){case"darwin":return ol;case"linux":return al;case"win32":return dl;default:throw new Error(`unsupported platform for OS supervisor: ${t}`)}}function v2(){let t={};for(let e of b2){let r=process.env[e];r&&(t[e]=r)}return t}function S2(){let t=J();return{nodeBin:process.execPath,entry:Zd(t),logFile:t.logFile,homeDir:_2(),userName:y2().username,isRoot:process.getuid?.()===0,env:v2()}}var b2,Hp=nt(()=>{"use strict";Re();ua();Mp();Fp();Up();b2=["PATH","HOME","HTTP_PROXY","HTTPS_PROXY","NO_PROXY","ALL_PROXY","http_proxy","https_proxy","no_proxy","all_proxy","NODE_EXTRA_CA_CERTS"]});te();dn();var Ul=G("acp-installer-warmup"),pg=["claude-code","codex"];async function Gl(t={}){let e=t.ensure??dr,i=(await Promise.allSettled(pg.map(async o=>{let c=await e(o);Ul.info("acp wrapper warmup ok",{framework:o,path:c})}))).filter(o=>o.status==="rejected");i.length>0&&Ul.warn("acp wrapper warmup partial failure (\u5C06\u5728\u4E0B\u6B21 createAgent \u65F6\u91CD\u8BD5\u5E76\u629B\u9519\u7ED9\u7528\u6237)",{failedCount:i.length,reasons:i.map(o=>o.reason instanceof Error?o.reason.message:String(o.reason))})}jt();te();import{readdir as Pg}from"node:fs/promises";import{mkdir as Wl,readFile as Rg,writeFile as Kl}from"node:fs/promises";import{join as Ha}from"node:path";var Cg={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md",hermes:"AGENTS.md"};async function fr(t,e,r){await Wl(t,{recursive:!0});let i=Cg[e],o=Ha(t,i);return await Kl(o,r??"","utf8"),o}async function qa(t,e,r){let i=Ha(t,".claude");await Wl(i,{recursive:!0});let o=Ha(i,"settings.local.json"),c={};try{let u=await Rg(o,"utf8"),f=JSON.parse(u);typeof f=="object"&&f!==null&&!Array.isArray(f)&&(c=f)}catch{}let d=typeof c.permissions=="object"&&c.permissions!==null&&!Array.isArray(c.permissions)?c.permissions:{};if(e==="cloud")d.defaultMode="bypassPermissions",c.autoCompactWindow=15e4;else{if(!r)throw new Error("writeCcPermissionSettings: local deployType requires permissionMode (caller bug)");d.defaultMode===void 0&&(d.defaultMode=r)}return c.permissions=d,await Kl(o,JSON.stringify(c,null,2),"utf8"),o}var Ze=G("agent-detail-sync"),Dg=6e4,Og=5*6e4,Ss=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let r=this.opts.paths.agentsRoot,i;try{i=await Pg(r)}catch(o){Ze.info("agents dir not found, skip detail sync",{root:r,err:String(o)});return}Ze.info("starting detail sync",{reason:e,count:i.length}),await Promise.allSettled(i.map(async o=>{let c=await ve(o,this.opts.paths).catch(()=>null);if(c){if(c.disconnectedAt){Ze.debug("detail sync: skip disconnected agent",{agentId:o});return}try{await this.syncOne(o,c)}catch(d){Ze.warn("detail sync failed for agent, skipping",{agentId:o,err:String(d)})}}})),Ze.info("detail sync done",{reason:e})}async retryPending(){if(this.retryQueue.size===0)return;let e=Date.now(),r=[];for(let[i,o]of this.retryQueue)e>=o.dueAt&&r.push(i);if(r.length!==0){Ze.info("retrying pending detail syncs",{count:r.length});for(let i of r)try{await this.syncOne(i)}catch(o){Ze.debug("detail sync retry still failing, will try again",{agentId:i,err:String(o)})}}}async syncOne(e,r){let i=r??await ve(e,this.opts.paths);if(!i){Ze.info("detail sync: agent config missing, skip",{agentId:e});return}let o;try{o=await this.opts.sendDetail({_meta:{cozeAgentId:e}}),this.retryQueue.delete(e)}catch(f){Ze.warn("detail RPC failed, using local data",{agentId:e,err:String(f)});let x=this.retryQueue.get(e),g=x?Math.min(x.currentDelay*2,Og):Dg;this.retryQueue.set(e,{dueAt:Date.now()+g,currentDelay:g});return}if(o.agentId&&o.agentId!==e){Ze.warn("detail response agentId mismatch, ignoring",{agentId:e,responseAgentId:o.agentId});return}let c=!1,d=!1;o.agentName&&o.agentName!==i.agentName&&(i.agentName=o.agentName,c=!0),o.description!==void 0&&o.description!==i.description&&(i.description=o.description,c=!0),o.cozeIdentity&&o.cozeIdentity!==i.cozeIdentity&&(i.cozeIdentity=o.cozeIdentity,c=!0,d=!0);let u=!1;if(o.deployType==="cloud"&&i.deployType!=="cloud"?(Ze.warn("detail sync: agent demoted to local, repairing to cloud",{agentId:e}),i.deployType="cloud",c=!0,u=!0):o.deployType&&Ze.info("detail.deployType",{agentId:e,deployType:o.deployType}),!c){Ze.debug("detail sync: no diff",{agentId:e});return}await ze(i,this.opts.paths),Ze.info("detail sync: config updated",{agentId:e,identityChanged:d,agentName:i.agentName}),u?(await this.opts.agentManager.createAgent({agentId:e,framework:i.framework,_meta:{cozeDeployType:"cloud"},cozeIdentity:i.cozeIdentity,model:i.model}),Ze.info("detail sync: repaired demoted agent back to cloud",{agentId:e})):d&&(await fr(i.workspace,i.framework,i.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};var xd=Ht(Iu(),1);import{createHash as yy}from"node:crypto";import{lstat as od,mkdir as ad,readFile as yo,readdir as g0,rm as cd,stat as fd,writeFile as dd}from"node:fs/promises";import{homedir as Ey}from"node:os";import{basename as x0,dirname as by,join as le,normalize as vy,relative as hd,resolve as ld,sep as w0}from"node:path";import{Readable as _0}from"node:stream";import{pipeline as y0}from"node:stream/promises";import tw from"events";import it from"fs";import{EventEmitter as Hc}from"node:events";import af from"node:stream";import{StringDecoder as nw}from"node:string_decoder";import lf from"node:path";import Sr from"node:fs";import{dirname as pw,parse as mw}from"path";import{EventEmitter as Sw}from"events";import vc from"assert";import{Buffer as Hn}from"buffer";import*as Cu from"zlib";import Iw from"zlib";import{posix as gr}from"node:path";import{basename as Xw}from"node:path";import no from"fs";import Dt from"fs";import Bu from"path";import{win32 as l_}from"node:path";import ju from"path";import If from"node:fs";import k_ from"node:assert";import{randomBytes as Af}from"node:crypto";import ie from"node:fs";import Me from"node:path";import kf from"fs";import fo from"node:fs";import Ai from"node:path";import ct from"node:fs";import L_ from"node:fs/promises";import so from"node:path";import{join as Ff}from"node:path";import at from"node:fs";import Gf from"node:path";var Qg=Object.defineProperty,ew=(t,e)=>{for(var r in e)Qg(t,r,{get:e[r],enumerable:!0})},Au=typeof process=="object"&&process?process:{stdout:null,stderr:null},rw=t=>!!t&&typeof t=="object"&&(t instanceof Wn||t instanceof af||iw(t)||sw(t)),iw=t=>!!t&&typeof t=="object"&&t instanceof Hc&&typeof t.pipe=="function"&&t.pipe!==af.Writable.prototype.pipe,sw=t=>!!t&&typeof t=="object"&&t instanceof Hc&&typeof t.write=="function"&&typeof t.end=="function",Wt=Symbol("EOF"),Kt=Symbol("maybeEmitEnd"),un=Symbol("emittedEnd"),Rs=Symbol("emittingEnd"),di=Symbol("emittedError"),Cs=Symbol("closed"),ku=Symbol("read"),Ps=Symbol("flush"),Tu=Symbol("flushChunk"),yt=Symbol("encoding"),mr=Symbol("decoder"),Ue=Symbol("flowing"),li=Symbol("paused"),Er=Symbol("resume"),Ge=Symbol("buffer"),Xe=Symbol("pipes"),He=Symbol("bufferLength"),Va=Symbol("bufferPush"),Ds=Symbol("bufferShift"),Je=Symbol("objectMode"),Ae=Symbol("destroyed"),Ja=Symbol("error"),Za=Symbol("emitData"),Ru=Symbol("emitEnd"),Xa=Symbol("emitEnd2"),Rt=Symbol("async"),Qa=Symbol("abort"),Os=Symbol("aborted"),ui=Symbol("signal"),On=Symbol("dataListeners"),ot=Symbol("discarded"),fi=t=>Promise.resolve().then(t),ow=t=>t(),aw=t=>t==="end"||t==="finish"||t==="prefinish",cw=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,dw=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),cf=class{src;dest;opts;ondrain;constructor(t,e,r){this.src=t,this.dest=e,this.opts=r,this.ondrain=()=>t[Er](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},lw=class extends cf{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,e,r){super(t,e,r),this.proxyErrors=i=>this.dest.emit("error",i),t.on("error",this.proxyErrors)}},uw=t=>!!t.objectMode,fw=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",Wn=class extends Hc{[Ue]=!1;[li]=!1;[Xe]=[];[Ge]=[];[Je];[yt];[Rt];[mr];[Wt]=!1;[un]=!1;[Rs]=!1;[Cs]=!1;[di]=null;[He]=0;[Ae]=!1;[ui];[Os]=!1;[On]=0;[ot]=!1;writable=!0;readable=!0;constructor(...t){let e=t[0]||{};if(super(),e.objectMode&&typeof e.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");uw(e)?(this[Je]=!0,this[yt]=null):fw(e)?(this[yt]=e.encoding,this[Je]=!1):(this[Je]=!1,this[yt]=null),this[Rt]=!!e.async,this[mr]=this[yt]?new nw(this[yt]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[Ge]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Xe]});let{signal:r}=e;r&&(this[ui]=r,r.aborted?this[Qa]():r.addEventListener("abort",()=>this[Qa]()))}get bufferLength(){return this[He]}get encoding(){return this[yt]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[Je]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[Rt]}set async(t){this[Rt]=this[Rt]||!!t}[Qa](){this[Os]=!0,this.emit("abort",this[ui]?.reason),this.destroy(this[ui]?.reason)}get aborted(){return this[Os]}set aborted(t){}write(t,e,r){if(this[Os])return!1;if(this[Wt])throw new Error("write after end");if(this[Ae])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof e=="function"&&(r=e,e="utf8"),e||(e="utf8");let i=this[Rt]?fi:ow;if(!this[Je]&&!Buffer.isBuffer(t)){if(dw(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(cw(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[Je]?(this[Ue]&&this[He]!==0&&this[Ps](!0),this[Ue]?this.emit("data",t):this[Va](t),this[He]!==0&&this.emit("readable"),r&&i(r),this[Ue]):t.length?(typeof t=="string"&&!(e===this[yt]&&!this[mr]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[yt]&&(t=this[mr].write(t)),this[Ue]&&this[He]!==0&&this[Ps](!0),this[Ue]?this.emit("data",t):this[Va](t),this[He]!==0&&this.emit("readable"),r&&i(r),this[Ue]):(this[He]!==0&&this.emit("readable"),r&&i(r),this[Ue])}read(t){if(this[Ae])return null;if(this[ot]=!1,this[He]===0||t===0||t&&t>this[He])return this[Kt](),null;this[Je]&&(t=null),this[Ge].length>1&&!this[Je]&&(this[Ge]=[this[yt]?this[Ge].join(""):Buffer.concat(this[Ge],this[He])]);let e=this[ku](t||null,this[Ge][0]);return this[Kt](),e}[ku](t,e){if(this[Je])this[Ds]();else{let r=e;t===r.length||t===null?this[Ds]():typeof r=="string"?(this[Ge][0]=r.slice(t),e=r.slice(0,t),this[He]-=t):(this[Ge][0]=r.subarray(t),e=r.subarray(0,t),this[He]-=t)}return this.emit("data",e),!this[Ge].length&&!this[Wt]&&this.emit("drain"),e}end(t,e,r){return typeof t=="function"&&(r=t,t=void 0),typeof e=="function"&&(r=e,e="utf8"),t!==void 0&&this.write(t,e),r&&this.once("end",r),this[Wt]=!0,this.writable=!1,(this[Ue]||!this[li])&&this[Kt](),this}[Er](){this[Ae]||(!this[On]&&!this[Xe].length&&(this[ot]=!0),this[li]=!1,this[Ue]=!0,this.emit("resume"),this[Ge].length?this[Ps]():this[Wt]?this[Kt]():this.emit("drain"))}resume(){return this[Er]()}pause(){this[Ue]=!1,this[li]=!0,this[ot]=!1}get destroyed(){return this[Ae]}get flowing(){return this[Ue]}get paused(){return this[li]}[Va](t){this[Je]?this[He]+=1:this[He]+=t.length,this[Ge].push(t)}[Ds](){return this[Je]?this[He]-=1:this[He]-=this[Ge][0].length,this[Ge].shift()}[Ps](t=!1){do;while(this[Tu](this[Ds]())&&this[Ge].length);!t&&!this[Ge].length&&!this[Wt]&&this.emit("drain")}[Tu](t){return this.emit("data",t),this[Ue]}pipe(t,e){if(this[Ae])return t;this[ot]=!1;let r=this[un];return e=e||{},t===Au.stdout||t===Au.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,r?e.end&&t.end():(this[Xe].push(e.proxyErrors?new lw(this,t,e):new cf(this,t,e)),this[Rt]?fi(()=>this[Er]()):this[Er]()),t}unpipe(t){let e=this[Xe].find(r=>r.dest===t);e&&(this[Xe].length===1?(this[Ue]&&this[On]===0&&(this[Ue]=!1),this[Xe]=[]):this[Xe].splice(this[Xe].indexOf(e),1),e.unpipe())}addListener(t,e){return this.on(t,e)}on(t,e){let r=super.on(t,e);if(t==="data")this[ot]=!1,this[On]++,!this[Xe].length&&!this[Ue]&&this[Er]();else if(t==="readable"&&this[He]!==0)super.emit("readable");else if(aw(t)&&this[un])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[di]){let i=e;this[Rt]?fi(()=>i.call(this,this[di])):i.call(this,this[di])}return r}removeListener(t,e){return this.off(t,e)}off(t,e){let r=super.off(t,e);return t==="data"&&(this[On]=this.listeners("data").length,this[On]===0&&!this[ot]&&!this[Xe].length&&(this[Ue]=!1)),r}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[On]=0,!this[ot]&&!this[Xe].length&&(this[Ue]=!1)),e}get emittedEnd(){return this[un]}[Kt](){!this[Rs]&&!this[un]&&!this[Ae]&&this[Ge].length===0&&this[Wt]&&(this[Rs]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Cs]&&this.emit("close"),this[Rs]=!1)}emit(t,...e){let r=e[0];if(t!=="error"&&t!=="close"&&t!==Ae&&this[Ae])return!1;if(t==="data")return!this[Je]&&!r?!1:this[Rt]?(fi(()=>this[Za](r)),!0):this[Za](r);if(t==="end")return this[Ru]();if(t==="close"){if(this[Cs]=!0,!this[un]&&!this[Ae])return!1;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[di]=r,super.emit(Ja,r);let o=!this[ui]||this.listeners("error").length?super.emit("error",r):!1;return this[Kt](),o}else if(t==="resume"){let o=super.emit("resume");return this[Kt](),o}else if(t==="finish"||t==="prefinish"){let o=super.emit(t);return this.removeAllListeners(t),o}let i=super.emit(t,...e);return this[Kt](),i}[Za](t){for(let r of this[Xe])r.dest.write(t)===!1&&this.pause();let e=this[ot]?!1:super.emit("data",t);return this[Kt](),e}[Ru](){return this[un]?!1:(this[un]=!0,this.readable=!1,this[Rt]?(fi(()=>this[Xa]()),!0):this[Xa]())}[Xa](){if(this[mr]){let e=this[mr].end();if(e){for(let r of this[Xe])r.dest.write(e);this[ot]||super.emit("data",e)}}for(let e of this[Xe])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[Je]||(t.dataLength=0);let e=this.promise();return this.on("data",r=>{t.push(r),this[Je]||(t.dataLength+=r.length)}),await e,t}async concat(){if(this[Je])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[yt]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(Ae,()=>e(new Error("stream destroyed"))),this.on("error",r=>e(r)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[ot]=!1;let t=!1,e=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return e();let r=this.read();if(r!==null)return Promise.resolve({done:!1,value:r});if(this[Wt])return e();let i,o,c=x=>{this.off("data",d),this.off("end",u),this.off(Ae,f),e(),o(x)},d=x=>{this.off("error",c),this.off("end",u),this.off(Ae,f),this.pause(),i({value:x,done:!!this[Wt]})},u=()=>{this.off("error",c),this.off("data",d),this.off(Ae,f),e(),i({done:!0,value:void 0})},f=()=>c(new Error("stream destroyed"));return new Promise((x,g)=>{o=g,i=x,this.once(Ae,f),this.once("error",c),this.once("end",u),this.once("data",d)})},throw:e,return:e,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[ot]=!1;let t=!1,e=()=>(this.pause(),this.off(Ja,e),this.off(Ae,e),this.off("end",e),t=!0,{done:!0,value:void 0}),r=()=>{if(t)return e();let i=this.read();return i===null?e():{done:!1,value:i}};return this.once("end",e),this.once(Ja,e),this.once(Ae,e),{next:r,throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[Ae])return t?this.emit("error",t):this.emit(Ae),this;this[Ae]=!0,this[ot]=!0,this[Ge].length=0,this[He]=0;let e=this;return typeof e.close=="function"&&!this[Cs]&&e.close(),t?this.emit("error",t):this.emit(Ae),this}static get isStream(){return rw}},hw=it.writev,En=Symbol("_autoClose"),St=Symbol("_close"),hi=Symbol("_ended"),de=Symbol("_fd"),ec=Symbol("_finished"),Jt=Symbol("_flags"),tc=Symbol("_flush"),Ec=Symbol("_handleChunk"),bc=Symbol("_makeBuf"),Si=Symbol("_mode"),Ls=Symbol("_needDrain"),Ar=Symbol("_onerror"),kr=Symbol("_onopen"),nc=Symbol("_onread"),br=Symbol("_onwrite"),bn=Symbol("_open"),vt=Symbol("_path"),mn=Symbol("_pos"),Ct=Symbol("_queue"),vr=Symbol("_read"),rc=Symbol("_readSize"),Vt=Symbol("_reading"),xi=Symbol("_remain"),ic=Symbol("_size"),js=Symbol("_write"),Ln=Symbol("_writing"),Ws=Symbol("_defaultFlag"),Gn=Symbol("_errored"),qc=class extends Wn{[Gn]=!1;[de];[vt];[rc];[Vt]=!1;[ic];[xi];[En];constructor(t,e){if(e=e||{},super(e),this.readable=!0,this.writable=!1,typeof t!="string")throw new TypeError("path must be a string");this[Gn]=!1,this[de]=typeof e.fd=="number"?e.fd:void 0,this[vt]=t,this[rc]=e.readSize||16*1024*1024,this[Vt]=!1,this[ic]=typeof e.size=="number"?e.size:1/0,this[xi]=this[ic],this[En]=typeof e.autoClose=="boolean"?e.autoClose:!0,typeof this[de]=="number"?this[vr]():this[bn]()}get fd(){return this[de]}get path(){return this[vt]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[bn](){it.open(this[vt],"r",(t,e)=>this[kr](t,e))}[kr](t,e){t?this[Ar](t):(this[de]=e,this.emit("open",e),this[vr]())}[bc](){return Buffer.allocUnsafe(Math.min(this[rc],this[xi]))}[vr](){if(!this[Vt]){this[Vt]=!0;let t=this[bc]();if(t.length===0)return process.nextTick(()=>this[nc](null,0,t));it.read(this[de],t,0,t.length,null,(e,r,i)=>this[nc](e,r,i))}}[nc](t,e,r){this[Vt]=!1,t?this[Ar](t):this[Ec](e,r)&&this[vr]()}[St](){if(this[En]&&typeof this[de]=="number"){let t=this[de];this[de]=void 0,it.close(t,e=>e?this.emit("error",e):this.emit("close"))}}[Ar](t){this[Vt]=!0,this[St](),this.emit("error",t)}[Ec](t,e){let r=!1;return this[xi]-=t,t>0&&(r=super.write(t<e.length?e.subarray(0,t):e)),(t===0||this[xi]<=0)&&(r=!1,this[St](),super.end()),r}emit(t,...e){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[de]=="number"&&this[vr](),!1;case"error":return this[Gn]?!1:(this[Gn]=!0,super.emit(t,...e));default:return super.emit(t,...e)}}},xw=class extends qc{[bn](){let t=!0;try{this[kr](null,it.openSync(this[vt],"r")),t=!1}finally{t&&this[St]()}}[vr](){let t=!0;try{if(!this[Vt]){this[Vt]=!0;do{let e=this[bc](),r=e.length===0?0:it.readSync(this[de],e,0,e.length,null);if(!this[Ec](r,e))break}while(!0);this[Vt]=!1}t=!1}finally{t&&this[St]()}}[St](){if(this[En]&&typeof this[de]=="number"){let t=this[de];this[de]=void 0,it.closeSync(t),this.emit("close")}}},oo=class extends tw{readable=!1;writable=!0;[Gn]=!1;[Ln]=!1;[hi]=!1;[Ct]=[];[Ls]=!1;[vt];[Si];[En];[de];[Ws];[Jt];[ec]=!1;[mn];constructor(t,e){e=e||{},super(e),this[vt]=t,this[de]=typeof e.fd=="number"?e.fd:void 0,this[Si]=e.mode===void 0?438:e.mode,this[mn]=typeof e.start=="number"?e.start:void 0,this[En]=typeof e.autoClose=="boolean"?e.autoClose:!0;let r=this[mn]!==void 0?"r+":"w";this[Ws]=e.flags===void 0,this[Jt]=e.flags===void 0?r:e.flags,this[de]===void 0&&this[bn]()}emit(t,...e){if(t==="error"){if(this[Gn])return!1;this[Gn]=!0}return super.emit(t,...e)}get fd(){return this[de]}get path(){return this[vt]}[Ar](t){this[St](),this[Ln]=!0,this.emit("error",t)}[bn](){it.open(this[vt],this[Jt],this[Si],(t,e)=>this[kr](t,e))}[kr](t,e){this[Ws]&&this[Jt]==="r+"&&t&&t.code==="ENOENT"?(this[Jt]="w",this[bn]()):t?this[Ar](t):(this[de]=e,this.emit("open",e),this[Ln]||this[tc]())}end(t,e){return t&&this.write(t,e),this[hi]=!0,!this[Ln]&&!this[Ct].length&&typeof this[de]=="number"&&this[br](null,0),this}write(t,e){return typeof t=="string"&&(t=Buffer.from(t,e)),this[hi]?(this.emit("error",new Error("write() after end()")),!1):this[de]===void 0||this[Ln]||this[Ct].length?(this[Ct].push(t),this[Ls]=!0,!1):(this[Ln]=!0,this[js](t),!0)}[js](t){it.write(this[de],t,0,t.length,this[mn],(e,r)=>this[br](e,r))}[br](t,e){t?this[Ar](t):(this[mn]!==void 0&&typeof e=="number"&&(this[mn]+=e),this[Ct].length?this[tc]():(this[Ln]=!1,this[hi]&&!this[ec]?(this[ec]=!0,this[St](),this.emit("finish")):this[Ls]&&(this[Ls]=!1,this.emit("drain"))))}[tc](){if(this[Ct].length===0)this[hi]&&this[br](null,0);else if(this[Ct].length===1)this[js](this[Ct].pop());else{let t=this[Ct];this[Ct]=[],hw(this[de],t,this[mn],(e,r)=>this[br](e,r))}}[St](){if(this[En]&&typeof this[de]=="number"){let t=this[de];this[de]=void 0,it.close(t,e=>e?this.emit("error",e):this.emit("close"))}}},df=class extends oo{[bn](){let t;if(this[Ws]&&this[Jt]==="r+")try{t=it.openSync(this[vt],this[Jt],this[Si])}catch(e){if(e?.code==="ENOENT")return this[Jt]="w",this[bn]();throw e}else t=it.openSync(this[vt],this[Jt],this[Si]);this[kr](null,t)}[St](){if(this[En]&&typeof this[de]=="number"){let t=this[de];this[de]=void 0,it.closeSync(t),this.emit("close")}}[js](t){let e=!0;try{this[br](null,it.writeSync(this[de],t,0,t.length,this[mn])),e=!1}finally{if(e)try{this[St]()}catch{}}}},gw=new Map([["C","cwd"],["f","file"],["z","gzip"],["P","preservePaths"],["U","unlink"],["strip-components","strip"],["stripComponents","strip"],["keep-newer","newer"],["keepNewer","newer"],["keep-newer-files","newer"],["keepNewerFiles","newer"],["k","keep"],["keep-existing","keep"],["keepExisting","keep"],["m","noMtime"],["no-mtime","noMtime"],["p","preserveOwner"],["L","follow"],["h","follow"],["onentry","onReadEntry"]]),ww=t=>!!t.sync&&!!t.file,_w=t=>!t.sync&&!!t.file,yw=t=>!!t.sync&&!t.file,Ew=t=>!t.sync&&!t.file,bw=t=>!!t.file,vw=t=>gw.get(t)||t,jc=(t={})=>{if(!t)return{};let e={};for(let[r,i]of Object.entries(t)){let o=vw(r);e[o]=i}return e.chmod===void 0&&e.noChmod===!1&&(e.chmod=!0),delete e.noChmod,e},Oi=(t,e,r,i,o)=>Object.assign((c=[],d,u)=>{Array.isArray(c)&&(d=c,c={}),typeof d=="function"&&(u=d,d=void 0),d=d?Array.from(d):[];let f=jc(c);if(o?.(f,d),ww(f)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return t(f,d)}else if(_w(f)){let x=e(f,d);return u?x.then(()=>u(),u):x}else if(yw(f)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return r(f,d)}else if(Ew(f)){if(typeof u=="function")throw new TypeError("callback only supported with file option");return i(f,d)}throw new Error("impossible options??")},{syncFile:t,asyncFile:e,syncNoFile:r,asyncNoFile:i,validate:o}),Aw=Iw.constants||{ZLIB_VERNUM:4736},Lt=Object.freeze(Object.assign(Object.create(null),{Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_VERSION_ERROR:-6,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,DEFLATE:1,INFLATE:2,GZIP:3,GUNZIP:4,DEFLATERAW:5,INFLATERAW:6,UNZIP:7,BROTLI_DECODE:8,BROTLI_ENCODE:9,Z_MIN_WINDOWBITS:8,Z_MAX_WINDOWBITS:15,Z_DEFAULT_WINDOWBITS:15,Z_MIN_CHUNK:64,Z_MAX_CHUNK:1/0,Z_DEFAULT_CHUNK:16384,Z_MIN_MEMLEVEL:1,Z_MAX_MEMLEVEL:9,Z_DEFAULT_MEMLEVEL:8,Z_MIN_LEVEL:-1,Z_MAX_LEVEL:9,Z_DEFAULT_LEVEL:-1,BROTLI_OPERATION_PROCESS:0,BROTLI_OPERATION_FLUSH:1,BROTLI_OPERATION_FINISH:2,BROTLI_OPERATION_EMIT_METADATA:3,BROTLI_MODE_GENERIC:0,BROTLI_MODE_TEXT:1,BROTLI_MODE_FONT:2,BROTLI_DEFAULT_MODE:0,BROTLI_MIN_QUALITY:0,BROTLI_MAX_QUALITY:11,BROTLI_DEFAULT_QUALITY:11,BROTLI_MIN_WINDOW_BITS:10,BROTLI_MAX_WINDOW_BITS:24,BROTLI_LARGE_MAX_WINDOW_BITS:30,BROTLI_DEFAULT_WINDOW:22,BROTLI_MIN_INPUT_BLOCK_BITS:16,BROTLI_MAX_INPUT_BLOCK_BITS:24,BROTLI_PARAM_MODE:0,BROTLI_PARAM_QUALITY:1,BROTLI_PARAM_LGWIN:2,BROTLI_PARAM_LGBLOCK:3,BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING:4,BROTLI_PARAM_SIZE_HINT:5,BROTLI_PARAM_LARGE_WINDOW:6,BROTLI_PARAM_NPOSTFIX:7,BROTLI_PARAM_NDIRECT:8,BROTLI_DECODER_RESULT_ERROR:0,BROTLI_DECODER_RESULT_SUCCESS:1,BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT:2,BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION:0,BROTLI_DECODER_PARAM_LARGE_WINDOW:1,BROTLI_DECODER_NO_ERROR:0,BROTLI_DECODER_SUCCESS:1,BROTLI_DECODER_NEEDS_MORE_INPUT:2,BROTLI_DECODER_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE:-1,BROTLI_DECODER_ERROR_FORMAT_RESERVED:-2,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE:-3,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET:-4,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME:-5,BROTLI_DECODER_ERROR_FORMAT_CL_SPACE:-6,BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE:-7,BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT:-8,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1:-9,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2:-10,BROTLI_DECODER_ERROR_FORMAT_TRANSFORM:-11,BROTLI_DECODER_ERROR_FORMAT_DICTIONARY:-12,BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS:-13,BROTLI_DECODER_ERROR_FORMAT_PADDING_1:-14,BROTLI_DECODER_ERROR_FORMAT_PADDING_2:-15,BROTLI_DECODER_ERROR_FORMAT_DISTANCE:-16,BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET:-19,BROTLI_DECODER_ERROR_INVALID_ARGUMENTS:-20,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES:-21,BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS:-22,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP:-25,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1:-26,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2:-27,BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES:-30,BROTLI_DECODER_ERROR_UNREACHABLE:-31},Aw)),kw=Hn.concat,Pu=Object.getOwnPropertyDescriptor(Hn,"concat"),Tw=t=>t,sc=Pu?.writable===!0||Pu?.set!==void 0?t=>{Hn.concat=t?Tw:kw}:t=>{},qn=Symbol("_superWrite"),Ns=class extends Error{code;errno;constructor(t,e){super("zlib: "+t.message,{cause:t}),this.code=t.code,this.errno=t.errno,this.code||(this.code="ZLIB_ERROR"),this.message="zlib: "+t.message,Error.captureStackTrace(this,e??this.constructor)}get name(){return"ZlibError"}},oc=Symbol("flushFlag"),Wc=class extends Wn{#e=!1;#n=!1;#r;#s;#i;#t;#o;get sawError(){return this.#e}get handle(){return this.#t}get flushFlag(){return this.#r}constructor(t,e){if(!t||typeof t!="object")throw new TypeError("invalid options for ZlibBase constructor");if(super(t),this.#r=t.flush??0,this.#s=t.finishFlush??0,this.#i=t.fullFlushFlag??0,typeof Cu[e]!="function")throw new TypeError("Compression method not supported: "+e);try{this.#t=new Cu[e](t)}catch(r){throw new Ns(r,this.constructor)}this.#o=r=>{this.#e||(this.#e=!0,this.close(),this.emit("error",r))},this.#t?.on("error",r=>this.#o(new Ns(r))),this.once("end",()=>this.close)}close(){this.#t&&(this.#t.close(),this.#t=void 0,this.emit("close"))}reset(){if(!this.#e)return vc(this.#t,"zlib binding closed"),this.#t.reset?.()}flush(t){this.ended||(typeof t!="number"&&(t=this.#i),this.write(Object.assign(Hn.alloc(0),{[oc]:t})))}end(t,e,r){return typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),t&&(e?this.write(t,e):this.write(t)),this.flush(this.#s),this.#n=!0,super.end(r)}get ended(){return this.#n}[qn](t){return super.write(t)}write(t,e,r){if(typeof e=="function"&&(r=e,e="utf8"),typeof t=="string"&&(t=Hn.from(t,e)),this.#e)return;vc(this.#t,"zlib binding closed");let i=this.#t._handle,o=i.close;i.close=()=>{};let c=this.#t.close;this.#t.close=()=>{},sc(!0);let d;try{let f=typeof t[oc]=="number"?t[oc]:this.#r;d=this.#t._processChunk(t,f),sc(!1)}catch(f){sc(!1),this.#o(new Ns(f,this.write))}finally{this.#t&&(this.#t._handle=i,i.close=o,this.#t.close=c,this.#t.removeAllListeners("error"))}this.#t&&this.#t.on("error",f=>this.#o(new Ns(f,this.write)));let u;if(d)if(Array.isArray(d)&&d.length>0){let f=d[0];u=this[qn](Hn.from(f));for(let x=1;x<d.length;x++)u=this[qn](d[x])}else u=this[qn](Hn.from(d));return r&&r(),u}},uf=class extends Wc{#e;#n;constructor(t,e){t=t||{},t.flush=t.flush||Lt.Z_NO_FLUSH,t.finishFlush=t.finishFlush||Lt.Z_FINISH,t.fullFlushFlag=Lt.Z_FULL_FLUSH,super(t,e),this.#e=t.level,this.#n=t.strategy}params(t,e){if(!this.sawError){if(!this.handle)throw new Error("cannot switch params when binding is closed");if(!this.handle.params)throw new Error("not supported in this implementation");if(this.#e!==t||this.#n!==e){this.flush(Lt.Z_SYNC_FLUSH),vc(this.handle,"zlib binding closed");let r=this.handle.flush;this.handle.flush=(i,o)=>{typeof i=="function"&&(o=i,i=this.flushFlag),this.flush(i),o?.()};try{this.handle.params(t,e)}finally{this.handle.flush=r}this.handle&&(this.#e=t,this.#n=e)}}}},Rw=class extends uf{#e;constructor(t){super(t,"Gzip"),this.#e=t&&!!t.portable}[qn](t){return this.#e?(this.#e=!1,t[9]=255,super[qn](t)):super[qn](t)}},Cw=class extends uf{constructor(t){super(t,"Unzip")}},ff=class extends Wc{constructor(t,e){t=t||{},t.flush=t.flush||Lt.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||Lt.BROTLI_OPERATION_FINISH,t.fullFlushFlag=Lt.BROTLI_OPERATION_FLUSH,super(t,e)}},Pw=class extends ff{constructor(t){super(t,"BrotliCompress")}},Dw=class extends ff{constructor(t){super(t,"BrotliDecompress")}},hf=class extends Wc{constructor(t,e){t=t||{},t.flush=t.flush||Lt.ZSTD_e_continue,t.finishFlush=t.finishFlush||Lt.ZSTD_e_end,t.fullFlushFlag=Lt.ZSTD_e_flush,super(t,e)}},Ow=class extends hf{constructor(t){super(t,"ZstdCompress")}},Lw=class extends hf{constructor(t){super(t,"ZstdDecompress")}},Nw=(t,e)=>{if(Number.isSafeInteger(t))t<0?Bw(t,e):Mw(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},Mw=(t,e)=>{e[0]=128;for(var r=e.length;r>1;r--)e[r-1]=t&255,t=Math.floor(t/256)},Bw=(t,e)=>{e[0]=255;var r=!1;t=t*-1;for(var i=e.length;i>1;i--){var o=t&255;t=Math.floor(t/256),r?e[i-1]=xf(o):o===0?e[i-1]=0:(r=!0,e[i-1]=pf(o))}},Fw=t=>{let e=t[0],r=e===128?Uw(t.subarray(1,t.length)):e===255?zw(t):null;if(r===null)throw Error("invalid base256 encoding");if(!Number.isSafeInteger(r))throw Error("parsed number outside of javascript safe integer range");return r},zw=t=>{for(var e=t.length,r=0,i=!1,o=e-1;o>-1;o--){var c=Number(t[o]),d;i?d=xf(c):c===0?d=c:(i=!0,d=pf(c)),d!==0&&(r-=d*Math.pow(256,e-o-1))}return r},Uw=t=>{for(var e=t.length,r=0,i=e-1;i>-1;i--){var o=Number(t[i]);o!==0&&(r+=o*Math.pow(256,e-i-1))}return r},xf=t=>(255^t)&255,pf=t=>(255^t)+1&255,Gw={};ew(Gw,{code:()=>Kc,isCode:()=>Ks,isName:()=>Hw,name:()=>ao,normalFsTypes:()=>mf});var Ks=t=>ao.has(t),Hw=t=>Kc.has(t),mf=new Set(["0","","1","2","3","4","5","6","7","D"]),ao=new Map([["0","File"],["","OldFile"],["1","Link"],["2","SymbolicLink"],["3","CharacterDevice"],["4","BlockDevice"],["5","Directory"],["6","FIFO"],["7","ContiguousFile"],["g","GlobalExtendedHeader"],["x","ExtendedHeader"],["A","SolarisACL"],["D","GNUDumpDir"],["I","Inode"],["K","NextFileHasLongLinkpath"],["L","NextFileHasLongPath"],["M","ContinuationFile"],["N","OldGnuLongPath"],["S","SparseFile"],["V","TapeVolumeHeader"],["X","OldExtendedHeader"]]),Kc=new Map(Array.from(ao).map(t=>[t[1],t[0]])),jn=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#e="Unsupported";linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(t,e=0,r,i){Buffer.isBuffer(t)?this.decode(t,e||0,r,i):t&&this.#n(t)}decode(t,e,r,i){if(e||(e=0),!t||!(t.length>=e+512))throw new Error("need 512 bytes for header");let o=Nn(t,e+156,1),c=mf.has(o),d=c?r:void 0,u=c?i:void 0;if(this.path=d?.path??Nn(t,e,100),this.mode=d?.mode??u?.mode??gn(t,e+100,8),this.uid=d?.uid??u?.uid??gn(t,e+108,8),this.gid=d?.gid??u?.gid??gn(t,e+116,8),this.size=d?.size??u?.size??gn(t,e+124,12),this.mtime=d?.mtime??u?.mtime??ac(t,e+136,12),this.cksum=gn(t,e+148,12),u&&this.#n(u,!0),d&&this.#n(d),Ks(o)&&(this.#e=o||"0"),this.#e==="0"&&this.path.slice(-1)==="/"&&(this.#e="5"),this.#e==="5"&&(this.size=0),this.linkpath=Nn(t,e+157,100),t.subarray(e+257,e+265).toString()==="ustar\x0000")if(this.uname=d?.uname??u?.uname??Nn(t,e+265,32),this.gname=d?.gname??u?.gname??Nn(t,e+297,32),this.devmaj=d?.devmaj??u?.devmaj??gn(t,e+329,8)??0,this.devmin=d?.devmin??u?.devmin??gn(t,e+337,8)??0,t[e+475]!==0){let x=Nn(t,e+345,155);this.path=x+"/"+this.path}else{let x=Nn(t,e+345,130);x&&(this.path=x+"/"+this.path),this.atime=r?.atime??i?.atime??ac(t,e+476,12),this.ctime=r?.ctime??i?.ctime??ac(t,e+488,12)}let f=256;for(let x=e;x<e+148;x++)f+=t[x];for(let x=e+156;x<e+512;x++)f+=t[x];this.cksumValid=f===this.cksum,this.cksum===void 0&&f===256&&(this.nullBlock=!0)}#n(t,e=!1){Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,i])=>!(i==null||r==="path"&&e||r==="linkpath"&&e||r==="global"))))}encode(t,e=0){if(t||(t=this.block=Buffer.alloc(512)),this.#e==="Unsupported"&&(this.#e="0"),!(t.length>=e+512))throw new Error("need 512 bytes for header");let r=this.ctime||this.atime?130:155,i=qw(this.path||"",r),o=i[0],c=i[1];this.needPax=!!i[2],this.needPax=Mn(t,e,100,o)||this.needPax,this.needPax=wn(t,e+100,8,this.mode)||this.needPax,this.needPax=wn(t,e+108,8,this.uid)||this.needPax,this.needPax=wn(t,e+116,8,this.gid)||this.needPax,this.needPax=wn(t,e+124,12,this.size)||this.needPax,this.needPax=cc(t,e+136,12,this.mtime)||this.needPax,t[e+156]=Number(this.#e.codePointAt(0)),this.needPax=Mn(t,e+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",e+257,8),this.needPax=Mn(t,e+265,32,this.uname)||this.needPax,this.needPax=Mn(t,e+297,32,this.gname)||this.needPax,this.needPax=wn(t,e+329,8,this.devmaj)||this.needPax,this.needPax=wn(t,e+337,8,this.devmin)||this.needPax,this.needPax=Mn(t,e+345,r,c)||this.needPax,t[e+475]!==0?this.needPax=Mn(t,e+345,155,c)||this.needPax:(this.needPax=Mn(t,e+345,130,c)||this.needPax,this.needPax=cc(t,e+476,12,this.atime)||this.needPax,this.needPax=cc(t,e+488,12,this.ctime)||this.needPax);let d=256;for(let u=e;u<e+148;u++)d+=t[u];for(let u=e+156;u<e+512;u++)d+=t[u];return this.cksum=d,wn(t,e+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#e==="Unsupported"?this.#e:ao.get(this.#e)}get typeKey(){return this.#e}set type(t){let e=String(Kc.get(t));if(Ks(e)||e==="Unsupported")this.#e=e;else if(Ks(t))this.#e=t;else throw new TypeError("invalid entry type: "+t)}},qw=(t,e)=>{let r=t,i="",o,c=gr.parse(t).root||".";if(Buffer.byteLength(r)<100)o=[r,i,!1];else{i=gr.dirname(r),r=gr.basename(r);do Buffer.byteLength(r)<=100&&Buffer.byteLength(i)<=e?o=[r,i,!1]:Buffer.byteLength(r)>100&&Buffer.byteLength(i)<=e?o=[r.slice(0,99),i,!0]:(r=gr.join(gr.basename(i),r),i=gr.dirname(i));while(i!==c&&o===void 0);o||(o=[t.slice(0,99),"",!0])}return o},Nn=(t,e,r)=>t.subarray(e,e+r).toString("utf8").replace(/\0.*/,""),ac=(t,e,r)=>jw(gn(t,e,r)),jw=t=>t===void 0?void 0:new Date(t*1e3),gn=(t,e,r)=>Number(t[e])&128?Fw(t.subarray(e,e+r)):Kw(t,e,r),Ww=t=>isNaN(t)?void 0:t,Kw=(t,e,r)=>Ww(parseInt(t.subarray(e,e+r).toString("utf8").replace(/\0.*$/,"").trim(),8)),$w={12:8589934591,8:2097151},wn=(t,e,r,i)=>i===void 0?!1:i>$w[r]||i<0?(Nw(i,t.subarray(e,e+r)),!0):(Yw(t,e,r,i),!1),Yw=(t,e,r,i)=>t.write(Vw(i,r),e,r,"ascii"),Vw=(t,e)=>Jw(Math.floor(t).toString(8),e),Jw=(t,e)=>(t.length===e-1?t:new Array(e-t.length-1).join("0")+t+" ")+"\0",cc=(t,e,r,i)=>i===void 0?!1:wn(t,e,r,i.getTime()/1e3),Zw=new Array(156).join("\0"),Mn=(t,e,r,i)=>i===void 0?!1:(t.write(i+Zw,e,r,"utf8"),i.length!==Buffer.byteLength(i)||i.length>r),to=class gf{atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor(e,r=!1){this.atime=e.atime,this.charset=e.charset,this.comment=e.comment,this.ctime=e.ctime,this.dev=e.dev,this.gid=e.gid,this.global=r,this.gname=e.gname,this.ino=e.ino,this.linkpath=e.linkpath,this.mtime=e.mtime,this.nlink=e.nlink,this.path=e.path,this.size=e.size,this.uid=e.uid,this.uname=e.uname}encode(){let e=this.encodeBody();if(e==="")return Buffer.allocUnsafe(0);let r=Buffer.byteLength(e),i=512*Math.ceil(1+r/512),o=Buffer.allocUnsafe(i);for(let c=0;c<512;c++)o[c]=0;new jn({path:("PaxHeader/"+Xw(this.path??"")).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:r,mtime:this.mtime,type:this.global?"GlobalExtendedHeader":"ExtendedHeader",linkpath:"",uname:this.uname||"",gname:this.gname||"",devmaj:0,devmin:0,atime:this.atime,ctime:this.ctime}).encode(o),o.write(e,512,r,"utf8");for(let c=r+512;c<o.length;c++)o[c]=0;return o}encodeBody(){return this.encodeField("path")+this.encodeField("ctime")+this.encodeField("atime")+this.encodeField("dev")+this.encodeField("ino")+this.encodeField("nlink")+this.encodeField("charset")+this.encodeField("comment")+this.encodeField("gid")+this.encodeField("gname")+this.encodeField("linkpath")+this.encodeField("mtime")+this.encodeField("size")+this.encodeField("uid")+this.encodeField("uname")}encodeField(e){if(this[e]===void 0)return"";let r=this[e],i=r instanceof Date?r.getTime()/1e3:r,o=" "+(e==="dev"||e==="ino"||e==="nlink"?"SCHILY.":"")+e+"="+i+`
|
|
90
|
-
`,c=Buffer.byteLength(o),d=Math.floor(Math.log(c)/Math.log(10))+1;return c+d>=Math.pow(10,d)&&(d+=1),d+c+o}static parse(e,
|
|
91
|
-
`).reduce(t_,Object.create(null)),t_=(t,e)=>{let r=parseInt(e,10);if(r!==Buffer.byteLength(e)+1)return t;e=e.slice((r+" ").length);let i=e.split("="),o=i.shift();if(!o)return t;let c=o.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),d=i.join("=");return t[c]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(c)?new Date(Number(d)*1e3):/^[0-9]+$/.test(d)?+d:d,t},n_=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Q=n_!=="win32"?t=>t:t=>t&&t.replaceAll(/\\/g,"/"),r_=class extends Wn{extended;globalExtended;header;startBlockSize;blockRemain;remain;type;meta=!1;ignore=!1;path;mode;uid;gid;uname;gname;size=0;mtime;atime;ctime;linkpath;dev;ino;nlink;invalid=!1;absolute;unsupported=!1;constructor(t,e,r){switch(super({}),this.pause(),this.extended=e,this.globalExtended=r,this.header=t,this.remain=t.size??0,this.startBlockSize=512*Math.ceil(this.remain/512),this.blockRemain=this.startBlockSize,this.type=t.type,this.type){case"File":case"OldFile":case"Link":case"SymbolicLink":case"CharacterDevice":case"BlockDevice":case"Directory":case"FIFO":case"ContiguousFile":case"GNUDumpDir":break;case"NextFileHasLongLinkpath":case"NextFileHasLongPath":case"OldGnuLongPath":case"GlobalExtendedHeader":case"ExtendedHeader":case"OldExtendedHeader":this.meta=!0;break;default:this.ignore=!0}if(!t.path)throw new Error("no path provided for tar.ReadEntry");this.path=Q(t.path),this.mode=t.mode,this.mode&&(this.mode=this.mode&4095),this.uid=t.uid,this.gid=t.gid,this.uname=t.uname,this.gname=t.gname,this.size=this.remain,this.mtime=t.mtime,this.atime=t.atime,this.ctime=t.ctime,this.linkpath=t.linkpath?Q(t.linkpath):void 0,this.uname=t.uname,this.gname=t.gname,e&&this.#e(e),r&&this.#e(r,!0)}write(t){let e=t.length;if(e>this.blockRemain)throw new Error("writing more to entry than is appropriate");let r=this.remain,i=this.blockRemain;return this.remain=Math.max(0,r-e),this.blockRemain=Math.max(0,i-e),this.ignore?!0:r>=e?super.write(t):super.write(t.subarray(0,r))}#e(t,e=!1){t.path&&(t.path=Q(t.path)),t.linkpath&&(t.linkpath=Q(t.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,i])=>!(i==null||r==="path"&&e))))}},co=(t,e,r,i={})=>{t.file&&(i.file=t.file),t.cwd&&(i.cwd=t.cwd),i.code=r instanceof Error&&r.code||e,i.tarCode=e,!t.strict&&i.recoverable!==!1?(r instanceof Error&&(i=Object.assign(r,i),r=r.message),t.emit("warn",e,r,i)):r instanceof Error?t.emit("error",Object.assign(r,i)):t.emit("error",Object.assign(new Error(`${e}: ${r}`),i))},i_=1024*1024,Sc=Buffer.from([31,139]),Ic=Buffer.from([40,181,47,253]),s_=Math.max(Sc.length,Ic.length),ft=Symbol("state"),Bn=Symbol("writeEntry"),$t=Symbol("readEntry"),dc=Symbol("nextEntry"),Du=Symbol("processEntry"),Pt=Symbol("extendedHeader"),pi=Symbol("globalExtendedHeader"),fn=Symbol("meta"),Ou=Symbol("emitMeta"),me=Symbol("buffer"),Yt=Symbol("queue"),hn=Symbol("ended"),lc=Symbol("emittedEnd"),Fn=Symbol("emit"),Ce=Symbol("unzip"),Ms=Symbol("consumeChunk"),Bs=Symbol("consumeChunkSub"),uc=Symbol("consumeBody"),Lu=Symbol("consumeMeta"),Nu=Symbol("consumeHeader"),mi=Symbol("consuming"),fc=Symbol("bufferConcat"),Fs=Symbol("maybeEnd"),wr=Symbol("writing"),xn=Symbol("aborted"),zs=Symbol("onDone"),zn=Symbol("sawValidEntry"),Us=Symbol("sawNullBlock"),Gs=Symbol("sawEOF"),Mu=Symbol("closeStream"),o_=()=>!0,Di=class extends Sw{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[Yt]=[];[me];[$t];[Bn];[ft]="begin";[fn]="";[Pt];[pi];[hn]=!1;[Ce];[xn]=!1;[zn];[Us]=!1;[Gs]=!1;[wr]=!1;[mi]=!1;[lc]=!1;constructor(t={}){super(),this.file=t.file||"",this.on(zs,()=>{(this[ft]==="begin"||this[zn]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),t.ondone?this.on(zs,t.ondone):this.on(zs,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!t.strict,this.maxMetaEntrySize=t.maxMetaEntrySize||i_,this.filter=typeof t.filter=="function"?t.filter:o_;let e=t.file&&(t.file.endsWith(".tar.br")||t.file.endsWith(".tbr"));this.brotli=!(t.gzip||t.zstd)&&t.brotli!==void 0?t.brotli:e?void 0:!1;let r=t.file&&(t.file.endsWith(".tar.zst")||t.file.endsWith(".tzst"));this.zstd=!(t.gzip||t.brotli)&&t.zstd!==void 0?t.zstd:r?!0:void 0,this.on("end",()=>this[Mu]()),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,e,r={}){co(this,t,e,r)}[Nu](t,e){this[zn]===void 0&&(this[zn]=!1);let r;try{r=new jn(t,e,this[Pt],this[pi])}catch(i){return this.warn("TAR_ENTRY_INVALID",i)}if(r.nullBlock)this[Us]?(this[Gs]=!0,this[ft]==="begin"&&(this[ft]="header"),this[Fn]("eof")):(this[Us]=!0,this[Fn]("nullBlock"));else if(this[Us]=!1,!r.cksumValid)this.warn("TAR_ENTRY_INVALID","checksum failure",{header:r});else if(!r.path)this.warn("TAR_ENTRY_INVALID","path is required",{header:r});else{let i=r.type;if(/^(Symbolic)?Link$/.test(i)&&!r.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath required",{header:r});else if(!/^(Symbolic)?Link$/.test(i)&&!/^(Global)?ExtendedHeader$/.test(i)&&r.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath forbidden",{header:r});else{let o=this[Bn]=new r_(r,this[Pt],this[pi]);if(!this[zn])if(o.remain){let c=()=>{o.invalid||(this[zn]=!0)};o.on("end",c)}else this[zn]=!0;o.meta?o.size>this.maxMetaEntrySize?(o.ignore=!0,this[Fn]("ignoredEntry",o),this[ft]="ignore",o.resume()):o.size>0&&(this[fn]="",o.on("data",c=>this[fn]+=c),this[ft]="meta"):(this[Pt]=void 0,o.ignore=o.ignore||!this.filter(o.path,o),o.ignore?(this[Fn]("ignoredEntry",o),this[ft]=o.remain?"ignore":"header",o.resume()):(o.remain?this[ft]="body":(this[ft]="header",o.end()),this[$t]?this[Yt].push(o):(this[Yt].push(o),this[dc]())))}}}[Mu](){queueMicrotask(()=>this.emit("close"))}[Du](t){let e=!0;if(!t)this[$t]=void 0,e=!1;else if(Array.isArray(t)){let[r,...i]=t;this.emit(r,...i)}else this[$t]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",()=>this[dc]()),e=!1);return e}[dc](){do;while(this[Du](this[Yt].shift()));if(this[Yt].length===0){let t=this[$t];!t||t.flowing||t.size===t.remain?this[wr]||this.emit("drain"):t.once("drain",()=>this.emit("drain"))}}[uc](t,e){let r=this[Bn];if(!r)throw new Error("attempt to consume body without entry??");let i=r.blockRemain??0,o=i>=t.length&&e===0?t:t.subarray(e,e+i);return r.write(o),r.blockRemain||(this[ft]="header",this[Bn]=void 0,r.end()),o.length}[Lu](t,e){let r=this[Bn],i=this[uc](t,e);return!this[Bn]&&r&&this[Ou](r),i}[Fn](t,e,r){this[Yt].length===0&&!this[$t]?this.emit(t,e,r):this[Yt].push([t,e,r])}[Ou](t){switch(this[Fn]("meta",this[fn]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[Pt]=to.parse(this[fn],this[Pt],!1);break;case"GlobalExtendedHeader":this[pi]=to.parse(this[fn],this[pi],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let e=this[Pt]??Object.create(null);this[Pt]=e,e.path=this[fn].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let e=this[Pt]||Object.create(null);this[Pt]=e,e.linkpath=this[fn].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){this[xn]=!0,this.emit("abort",t),this.warn("TAR_ABORT",t,{recoverable:!1})}write(t,e,r){if(typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8")),this[xn])return r?.(),!1;if((this[Ce]===void 0||this.brotli===void 0&&this[Ce]===!1)&&t){if(this[me]&&(t=Buffer.concat([this[me],t]),this[me]=void 0),t.length<s_)return this[me]=t,r?.(),!0;for(let d=0;this[Ce]===void 0&&d<Sc.length;d++)t[d]!==Sc[d]&&(this[Ce]=!1);let o=!1;if(this[Ce]===!1&&this.zstd!==!1){o=!0;for(let d=0;d<Ic.length;d++)if(t[d]!==Ic[d]){o=!1;break}}let c=this.brotli===void 0&&!o;if(this[Ce]===!1&&c)if(t.length<512)if(this[hn])this.brotli=!0;else return this[me]=t,r?.(),!0;else try{new jn(t.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[Ce]===void 0||this[Ce]===!1&&(this.brotli||o)){let d=this[hn];this[hn]=!1,this[Ce]=this[Ce]===void 0?new Cw({}):o?new Lw({}):new Dw({}),this[Ce].on("data",f=>this[Ms](f)),this[Ce].on("error",f=>this.abort(f)),this[Ce].on("end",()=>{this[hn]=!0,this[Ms]()}),this[wr]=!0;let u=!!this[Ce][d?"end":"write"](t);return this[wr]=!1,r?.(),u}}this[wr]=!0,this[Ce]?this[Ce].write(t):this[Ms](t),this[wr]=!1;let i=this[Yt].length>0?!1:this[$t]?this[$t].flowing:!0;return!i&&this[Yt].length===0&&this[$t]?.once("drain",()=>this.emit("drain")),r?.(),i}[fc](t){t&&!this[xn]&&(this[me]=this[me]?Buffer.concat([this[me],t]):t)}[Fs](){if(this[hn]&&!this[lc]&&!this[xn]&&!this[mi]){this[lc]=!0;let t=this[Bn];if(t&&t.blockRemain){let e=this[me]?this[me].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`,{entry:t}),this[me]&&t.write(this[me]),t.end()}this[Fn](zs)}}[Ms](t){if(this[mi]&&t)this[fc](t);else if(!t&&!this[me])this[Fs]();else if(t){if(this[mi]=!0,this[me]){this[fc](t);let e=this[me];this[me]=void 0,this[Bs](e)}else this[Bs](t);for(;this[me]&&this[me]?.length>=512&&!this[xn]&&!this[Gs];){let e=this[me];this[me]=void 0,this[Bs](e)}this[mi]=!1}(!this[me]||this[hn])&&this[Fs]()}[Bs](t){let e=0,r=t.length;for(;e+512<=r&&!this[xn]&&!this[Gs];)switch(this[ft]){case"begin":case"header":this[Nu](t,e),e+=512;break;case"ignore":case"body":e+=this[uc](t,e);break;case"meta":e+=this[Lu](t,e);break;default:throw new Error("invalid state: "+this[ft])}e<r&&(this[me]=this[me]?Buffer.concat([t.subarray(e),this[me]]):t.subarray(e))}end(t,e,r){return typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,e)),r&&this.once("finish",r),this[xn]||(this[Ce]?(t&&this[Ce].write(t),this[Ce].end()):(this[hn]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t=t||Buffer.alloc(0)),t&&this.write(t),this[Fs]())),this}},Ii=t=>{let e=t.length-1,r=-1;for(;e>-1&&t.charAt(e)==="/";)r=e,e--;return r===-1?t:t.slice(0,r)},a_=t=>{let e=t.onReadEntry;t.onReadEntry=e?r=>{e(r),r.resume()}:r=>r.resume()},wf=(t,e)=>{let r=new Map(e.map(c=>[Ii(c),!0])),i=t.filter,o=(c,d="")=>{let u=d||mw(c).root||".",f;if(c===u)f=!1;else{let x=r.get(c);f=x!==void 0?x:o(pw(c),u)}return r.set(c,f),f};t.filter=i?(c,d)=>i(c,d)&&o(Ii(c)):c=>o(Ii(c))},c_=t=>{let e=new Di(t),r=t.file,i;try{i=Sr.openSync(r,"r");let o=Sr.fstatSync(i),c=t.maxReadSize||16*1024*1024;if(o.size<c){let d=Buffer.allocUnsafe(o.size),u=Sr.readSync(i,d,0,o.size,0);e.end(u===d.byteLength?d:d.subarray(0,u))}else{let d=0,u=Buffer.allocUnsafe(c);for(;d<o.size;){let f=Sr.readSync(i,u,0,c,d);if(f===0)break;d+=f,e.write(u.subarray(0,f))}e.end()}}finally{if(typeof i=="number")try{Sr.closeSync(i)}catch{}}},d_=(t,e)=>{let r=new Di(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,d)=>{r.on("error",d),r.on("end",c),Sr.stat(o,(u,f)=>{if(u)d(u);else{let x=new qc(o,{readSize:i,size:f.size});x.on("error",d),x.pipe(r)}})})},Tr=Oi(c_,d_,t=>new Di(t),t=>new Di(t),(t,e)=>{e?.length&&wf(t,e),t.noResume||a_(t)}),_f=(t,e,r)=>(t&=4095,r&&(t=(t|384)&-19),e&&(t&256&&(t|=64),t&32&&(t|=8),t&4&&(t|=1)),t),{isAbsolute:u_,parse:Fu}=l_,$c=t=>{let e="",r=Fu(t);for(;u_(t)||r.root;){let i=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":r.root;t=t.slice(i.length),e+=i,r=Fu(t)}return[e,t]},lo=["|","<",">","?",":"],Yc=lo.map(t=>String.fromCodePoint(61440+Number(t.codePointAt(0)))),f_=new Map(lo.map((t,e)=>[t,Yc[e]])),h_=new Map(Yc.map((t,e)=>[t,lo[e]])),zu=t=>lo.reduce((e,r)=>e.split(r).join(f_.get(r)),t),x_=t=>Yc.reduce((e,r)=>e.split(r).join(h_.get(r)),t),yf=(t,e)=>e?(t=Q(t).replace(/^\.(\/|$)/,""),Ii(e)+"/"+t):Q(t),p_=16*1024*1024,Uu=Symbol("process"),Gu=Symbol("file"),Hu=Symbol("directory"),Ac=Symbol("symlink"),qu=Symbol("hardlink"),gi=Symbol("header"),$s=Symbol("read"),kc=Symbol("lstat"),Ys=Symbol("onlstat"),Tc=Symbol("onread"),Rc=Symbol("onreadlink"),Cc=Symbol("openfile"),Pc=Symbol("onopenfile"),_n=Symbol("close"),ro=Symbol("mode"),Dc=Symbol("awaitDrain"),hc=Symbol("ondrain"),Ot=Symbol("prefix"),Ef=class extends Wn{path;portable;myuid=process.getuid&&process.getuid()||0;myuser=process.env.USER||"";maxReadSize;linkCache;statCache;preservePaths;cwd;strict;mtime;noPax;noMtime;prefix;fd;blockLen=0;blockRemain=0;buf;pos=0;remain=0;length=0;offset=0;win32;absolute;header;type;linkpath;stat;onWriteEntry;#e=!1;constructor(t,e={}){let r=jc(e);super(),this.path=Q(t),this.portable=!!r.portable,this.maxReadSize=r.maxReadSize||p_,this.linkCache=r.linkCache||new Map,this.statCache=r.statCache||new Map,this.preservePaths=!!r.preservePaths,this.cwd=Q(r.cwd||process.cwd()),this.strict=!!r.strict,this.noPax=!!r.noPax,this.noMtime=!!r.noMtime,this.mtime=r.mtime,this.prefix=r.prefix?Q(r.prefix):void 0,this.onWriteEntry=r.onWriteEntry,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let i=!1;if(!this.preservePaths){let[c,d]=$c(this.path);c&&typeof d=="string"&&(this.path=d,i=c)}this.win32=!!r.win32||process.platform==="win32",this.win32&&(this.path=x_(this.path.replaceAll(/\\/g,"/")),t=t.replaceAll(/\\/g,"/")),this.absolute=Q(r.absolute||Bu.resolve(this.cwd,t)),this.path===""&&(this.path="./"),i&&this.warn("TAR_ENTRY_INFO",`stripping ${i} from absolute path`,{entry:this,path:i+this.path});let o=this.statCache.get(this.absolute);o?this[Ys](o):this[kc]()}warn(t,e,r={}){return co(this,t,e,r)}emit(t,...e){return t==="error"&&(this.#e=!0),super.emit(t,...e)}[kc](){Dt.lstat(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[Ys](e)})}[Ys](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=w_(t),this.emit("stat",t),this[Uu]()}[Uu](){switch(this.type){case"File":return this[Gu]();case"Directory":return this[Hu]();case"SymbolicLink":return this[Ac]();default:return this.end()}}[ro](t){return _f(t,this.type==="Directory",this.portable)}[Ot](t){return yf(t,this.prefix)}[gi](){if(!this.stat)throw new Error("cannot write header before stat");this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.onWriteEntry?.(this),this.header=new jn({path:this[Ot](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Ot](this.linkpath):this.linkpath,mode:this[ro](this.stat.mode),uid:this.portable?void 0:this.stat.uid,gid:this.portable?void 0:this.stat.gid,size:this.stat.size,mtime:this.noMtime?void 0:this.mtime||this.stat.mtime,type:this.type==="Unsupported"?void 0:this.type,uname:this.portable?void 0:this.stat.uid===this.myuid?this.myuser:"",atime:this.portable?void 0:this.stat.atime,ctime:this.portable?void 0:this.stat.ctime}),this.header.encode()&&!this.noPax&&super.write(new to({atime:this.portable?void 0:this.header.atime,ctime:this.portable?void 0:this.header.ctime,gid:this.portable?void 0:this.header.gid,mtime:this.noMtime?void 0:this.mtime||this.header.mtime,path:this[Ot](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Ot](this.linkpath):this.linkpath,size:this.header.size,uid:this.portable?void 0:this.header.uid,uname:this.portable?void 0:this.header.uname,dev:this.portable?void 0:this.stat.dev,ino:this.portable?void 0:this.stat.ino,nlink:this.portable?void 0:this.stat.nlink}).encode());let t=this.header?.block;if(!t)throw new Error("failed to encode header");super.write(t)}[Hu](){if(!this.stat)throw new Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[gi](),this.end()}[Ac](){Dt.readlink(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[Rc](e)})}[Rc](t){this.linkpath=Q(t),this[gi](),this.end()}[qu](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=Q(Bu.relative(this.cwd,t)),this.stat.size=0,this[gi](),this.end()}[Gu](){if(!this.stat)throw new Error("cannot create file entry without stat");if(this.stat.nlink>1){let t=`${this.stat.dev}:${this.stat.ino}`,e=this.linkCache.get(t);if(e?.indexOf(this.cwd)===0)return this[qu](e);this.linkCache.set(t,this.absolute)}if(this[gi](),this.stat.size===0)return this.end();this[Cc]()}[Cc](){Dt.open(this.absolute,"r",(t,e)=>{if(t)return this.emit("error",t);this[Pc](e)})}[Pc](t){if(this.fd=t,this.#e)return this[_n]();if(!this.stat)throw new Error("should stat before calling onopenfile");this.blockLen=512*Math.ceil(this.stat.size/512),this.blockRemain=this.blockLen;let e=Math.min(this.blockLen,this.maxReadSize);this.buf=Buffer.allocUnsafe(e),this.offset=0,this.pos=0,this.remain=this.stat.size,this.length=this.buf.length,this[$s]()}[$s](){let{fd:t,buf:e,offset:r,length:i,pos:o}=this;if(t===void 0||e===void 0)throw new Error("cannot read file without first opening");Dt.read(t,e,r,i,o,(c,d)=>{if(c)return this[_n](()=>this.emit("error",c));this[Tc](d)})}[_n](t=()=>{}){this.fd!==void 0&&Dt.close(this.fd,t)}[Tc](t){if(t<=0&&this.remain>0){let r=Object.assign(new Error("encountered unexpected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[_n](()=>this.emit("error",r))}if(t>this.remain){let r=Object.assign(new Error("did not encounter expected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[_n](()=>this.emit("error",r))}if(!this.buf)throw new Error("should have created buffer prior to reading");if(t===this.remain)for(let r=t;r<this.length&&t<this.blockRemain;r++)this.buf[r+this.offset]=0,t++,this.remain++;let e=this.offset===0&&t===this.buf.length?this.buf:this.buf.subarray(this.offset,this.offset+t);this.write(e)?this[hc]():this[Dc](()=>this[hc]())}[Dc](t){this.once("drain",t)}write(t,e,r){if(typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8")),this.blockRemain<t.length){let i=Object.assign(new Error("writing more data than expected"),{path:this.absolute});return this.emit("error",i)}return this.remain-=t.length,this.blockRemain-=t.length,this.pos+=t.length,this.offset+=t.length,super.write(t,null,r)}[hc](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[_n](t=>t?this.emit("error",t):this.end());if(!this.buf)throw new Error("buffer lost somehow in ONDRAIN");this.offset>=this.length&&(this.buf=Buffer.allocUnsafe(Math.min(this.blockRemain,this.buf.length)),this.offset=0),this.length=this.buf.length-this.offset,this[$s]()}},m_=class extends Ef{sync=!0;[kc](){this[Ys](Dt.lstatSync(this.absolute))}[Ac](){this[Rc](Dt.readlinkSync(this.absolute))}[Cc](){this[Pc](Dt.openSync(this.absolute,"r"))}[$s](){let t=!0;try{let{fd:e,buf:r,offset:i,length:o,pos:c}=this;if(e===void 0||r===void 0)throw new Error("fd and buf must be set in READ method");let d=Dt.readSync(e,r,i,o,c);this[Tc](d),t=!1}finally{if(t)try{this[_n](()=>{})}catch{}}}[Dc](t){t()}[_n](t=()=>{}){this.fd!==void 0&&Dt.closeSync(this.fd),t()}},g_=class extends Wn{blockLen=0;blockRemain=0;buf=0;pos=0;remain=0;length=0;preservePaths;portable;strict;noPax;noMtime;readEntry;type;prefix;path;mode;uid;gid;uname;gname;header;mtime;atime;ctime;linkpath;size;onWriteEntry;warn(t,e,r={}){return co(this,t,e,r)}constructor(t,e={}){let r=jc(e);super(),this.preservePaths=!!r.preservePaths,this.portable=!!r.portable,this.strict=!!r.strict,this.noPax=!!r.noPax,this.noMtime=!!r.noMtime,this.onWriteEntry=r.onWriteEntry,this.readEntry=t;let{type:i}=t;if(i==="Unsupported")throw new Error("writing entry that should be ignored");this.type=i,this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.prefix=r.prefix,this.path=Q(t.path),this.mode=t.mode!==void 0?this[ro](t.mode):void 0,this.uid=this.portable?void 0:t.uid,this.gid=this.portable?void 0:t.gid,this.uname=this.portable?void 0:t.uname,this.gname=this.portable?void 0:t.gname,this.size=t.size,this.mtime=this.noMtime?void 0:r.mtime||t.mtime,this.atime=this.portable?void 0:t.atime,this.ctime=this.portable?void 0:t.ctime,this.linkpath=t.linkpath!==void 0?Q(t.linkpath):void 0,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let o=!1;if(!this.preservePaths){let[d,u]=$c(this.path);d&&typeof u=="string"&&(this.path=u,o=d)}this.remain=t.size,this.blockRemain=t.startBlockSize,this.onWriteEntry?.(this),this.header=new jn({path:this[Ot](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Ot](this.linkpath):this.linkpath,mode:this.mode,uid:this.portable?void 0:this.uid,gid:this.portable?void 0:this.gid,size:this.size,mtime:this.noMtime?void 0:this.mtime,type:this.type,uname:this.portable?void 0:this.uname,atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime}),o&&this.warn("TAR_ENTRY_INFO",`stripping ${o} from absolute path`,{entry:this,path:o+this.path}),this.header.encode()&&!this.noPax&&super.write(new to({atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime,gid:this.portable?void 0:this.gid,mtime:this.noMtime?void 0:this.mtime,path:this[Ot](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Ot](this.linkpath):this.linkpath,size:this.size,uid:this.portable?void 0:this.uid,uname:this.portable?void 0:this.uname,dev:this.portable?void 0:this.readEntry.dev,ino:this.portable?void 0:this.readEntry.ino,nlink:this.portable?void 0:this.readEntry.nlink}).encode());let c=this.header?.block;if(!c)throw new Error("failed to encode header");super.write(c),t.pipe(this)}[Ot](t){return yf(t,this.prefix)}[ro](t){return _f(t,this.type==="Directory",this.portable)}write(t,e,r){typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8"));let i=t.length;if(i>this.blockRemain)throw new Error("writing more to entry than is appropriate");return this.blockRemain-=i,super.write(t,r)}end(t,e,r){return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,e??"utf8")),r&&this.once("finish",r),t?super.end(t,r):super.end(r),this}},w_=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported",__=class Ir{tail;head;length=0;static create(e=[]){return new Ir(e)}constructor(e=[]){for(let r of e)this.push(r)}*[Symbol.iterator](){for(let e=this.head;e;e=e.next)yield e.value}removeNode(e){if(e.list!==this)throw new Error("removing node which does not belong to this list");let r=e.next,i=e.prev;return r&&(r.prev=i),i&&(i.next=r),e===this.head&&(this.head=r),e===this.tail&&(this.tail=i),this.length--,e.next=void 0,e.prev=void 0,e.list=void 0,r}unshiftNode(e){if(e===this.head)return;e.list&&e.list.removeNode(e);let r=this.head;e.list=this,e.next=r,r&&(r.prev=e),this.head=e,this.tail||(this.tail=e),this.length++}pushNode(e){if(e===this.tail)return;e.list&&e.list.removeNode(e);let r=this.tail;e.list=this,e.prev=r,r&&(r.next=e),this.tail=e,this.head||(this.head=e),this.length++}push(...e){for(let r=0,i=e.length;r<i;r++)E_(this,e[r]);return this.length}unshift(...e){for(var r=0,i=e.length;r<i;r++)b_(this,e[r]);return this.length}pop(){if(!this.tail)return;let e=this.tail.value,r=this.tail;return this.tail=this.tail.prev,this.tail?this.tail.next=void 0:this.head=void 0,r.list=void 0,this.length--,e}shift(){if(!this.head)return;let e=this.head.value,r=this.head;return this.head=this.head.next,this.head?this.head.prev=void 0:this.tail=void 0,r.list=void 0,this.length--,e}forEach(e,r){r=r||this;for(let i=this.head,o=0;i;o++)e.call(r,i.value,o,this),i=i.next}forEachReverse(e,r){r=r||this;for(let i=this.tail,o=this.length-1;i;o--)e.call(r,i.value,o,this),i=i.prev}get(e){let r=0,i=this.head;for(;i&&r<e;r++)i=i.next;if(r===e&&i)return i.value}getReverse(e){let r=0,i=this.tail;for(;i&&r<e;r++)i=i.prev;if(r===e&&i)return i.value}map(e,r){r=r||this;let i=new Ir;for(let o=this.head;o;)i.push(e.call(r,o.value,this)),o=o.next;return i}mapReverse(e,r){r=r||this;var i=new Ir;for(let o=this.tail;o;)i.push(e.call(r,o.value,this)),o=o.prev;return i}reduce(e,r){let i,o=this.head;if(arguments.length>1)i=r;else if(this.head)o=this.head.next,i=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var c=0;o;c++)i=e(i,o.value,c),o=o.next;return i}reduceReverse(e,r){let i,o=this.tail;if(arguments.length>1)i=r;else if(this.tail)o=this.tail.prev,i=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(let c=this.length-1;o;c--)i=e(i,o.value,c),o=o.prev;return i}toArray(){let e=new Array(this.length);for(let r=0,i=this.head;i;r++)e[r]=i.value,i=i.next;return e}toArrayReverse(){let e=new Array(this.length);for(let r=0,i=this.tail;i;r++)e[r]=i.value,i=i.prev;return e}slice(e=0,r=this.length){r<0&&(r+=this.length),e<0&&(e+=this.length);let i=new Ir;if(r<e||r<0)return i;e<0&&(e=0),r>this.length&&(r=this.length);let o=this.head,c=0;for(c=0;o&&c<e;c++)o=o.next;for(;o&&c<r;c++,o=o.next)i.push(o.value);return i}sliceReverse(e=0,r=this.length){r<0&&(r+=this.length),e<0&&(e+=this.length);let i=new Ir;if(r<e||r<0)return i;e<0&&(e=0),r>this.length&&(r=this.length);let o=this.length,c=this.tail;for(;c&&o>r;o--)c=c.prev;for(;c&&o>e;o--,c=c.prev)i.push(c.value);return i}splice(e,r=0,...i){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);let o=this.head;for(let d=0;o&&d<e;d++)o=o.next;let c=[];for(let d=0;o&&d<r;d++)c.push(o.value),o=this.removeNode(o);o?o!==this.tail&&(o=o.prev):o=this.tail;for(let d of i)o=y_(this,o,d);return c}reverse(){let e=this.head,r=this.tail;for(let i=e;i;i=i.prev){let o=i.prev;i.prev=i.next,i.next=o}return this.head=r,this.tail=e,this}};function y_(t,e,r){let i=e,o=e?e.next:t.head,c=new Vc(r,i,o,t);return c.next===void 0&&(t.tail=c),c.prev===void 0&&(t.head=c),t.length++,c}function E_(t,e){t.tail=new Vc(e,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function b_(t,e){t.head=new Vc(e,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}var Vc=class{list;next;prev;value;constructor(t,e,r,i){this.list=i,this.value=t,e?(e.next=this,this.prev=e):this.prev=void 0,r?(r.prev=this,this.next=r):this.next=void 0}},Wu=class{path;absolute;entry;stat;readdir;pending=!1;pendingLink=!1;ignore=!1;piped=!1;constructor(t,e){this.path=t||"./",this.absolute=e}},Ku=Buffer.alloc(1024),Vs=Symbol("onStat"),wi=Symbol("ended"),Et=Symbol("queue"),_i=Symbol("pendingLinks"),pn=Symbol("current"),Un=Symbol("process"),yi=Symbol("processing"),Hs=Symbol("processJob"),bt=Symbol("jobs"),xc=Symbol("jobDone"),Js=Symbol("addFSEntry"),$u=Symbol("addTarEntry"),Oc=Symbol("stat"),Lc=Symbol("readdir"),Zs=Symbol("onreaddir"),Xs=Symbol("pipe"),Yu=Symbol("entry"),pc=Symbol("entryOpt"),Qs=Symbol("writeEntryClass"),bf=Symbol("write"),mc=Symbol("ondrain"),uo=class extends Wn{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[Qs];onWriteEntry;[Et];[_i]=new Map;[bt]=0;[yi]=!1;[wi]=!1;constructor(t={}){if(super(),this.opt=t,this.file=t.file||"",this.cwd=t.cwd||process.cwd(),this.maxReadSize=t.maxReadSize,this.preservePaths=!!t.preservePaths,this.strict=!!t.strict,this.noPax=!!t.noPax,this.prefix=Q(t.prefix||""),this.linkCache=t.linkCache||new Map,this.statCache=t.statCache||new Map,this.readdirCache=t.readdirCache||new Map,this.onWriteEntry=t.onWriteEntry,this[Qs]=Ef,typeof t.onwarn=="function"&&this.on("warn",t.onwarn),this.portable=!!t.portable,t.gzip||t.brotli||t.zstd){if((t.gzip?1:0)+(t.brotli?1:0)+(t.zstd?1:0)>1)throw new TypeError("gzip, brotli, zstd are mutually exclusive");if(t.gzip&&(typeof t.gzip!="object"&&(t.gzip={}),this.portable&&(t.gzip.portable=!0),this.zip=new Rw(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new Pw(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new Ow(t.zstd)),!this.zip)throw new Error("impossible");let e=this.zip;e.on("data",r=>super.write(r)),e.on("end",()=>super.end()),e.on("drain",()=>this[mc]()),this.on("resume",()=>e.resume())}else this.on("drain",this[mc]);this.noDirRecurse=!!t.noDirRecurse,this.follow=!!t.follow,this.noMtime=!!t.noMtime,t.mtime&&(this.mtime=t.mtime),this.filter=typeof t.filter=="function"?t.filter:()=>!0,this[Et]=new __,this[bt]=0,this.jobs=Number(t.jobs)||4,this[yi]=!1,this[wi]=!1}[bf](t){return super.write(t)}add(t){return this.write(t),this}end(t,e,r){return typeof t=="function"&&(r=t,t=void 0),typeof e=="function"&&(r=e,e=void 0),t&&this.add(t),this[wi]=!0,this[Un](),r&&r(),this}write(t){if(this[wi])throw new Error("write after end");return typeof t=="string"?this[Js](t):this[$u](t),this.flowing}[$u](t){let e=Q(ju.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let r=new Wu(t.path,e);r.entry=new g_(t,this[pc](r)),r.entry.on("end",()=>this[xc](r)),this[bt]+=1,this[Et].push(r)}this[Un]()}[Js](t){let e=Q(ju.resolve(this.cwd,t));this[Et].push(new Wu(t,e)),this[Un]()}[Oc](t){t.pending=!0,this[bt]+=1;let e=this.follow?"stat":"lstat";no[e](t.absolute,(r,i)=>{t.pending=!1,this[bt]-=1,r?this.emit("error",r):this[Vs](t,i)})}[Vs](t,e){if(this.statCache.set(t.absolute,e),t.stat=e,!this.filter(t.path,e))t.ignore=!0;else if(e.isFile()&&e.nlink>1&&!this.linkCache.get(`${e.dev}:${e.ino}`)&&!this.sync)if(t===this[pn])this[Hs](t);else{let r=`${e.dev}:${e.ino}`,i=this[_i].get(r);i?i.push(t):this[_i].set(r,[t]),t.pendingLink=!0,t.pending=!0}this[Un]()}[Lc](t){t.pending=!0,this[bt]+=1,no.readdir(t.absolute,(e,r)=>{if(t.pending=!1,this[bt]-=1,e)return this.emit("error",e);this[Zs](t,r)})}[Zs](t,e){this.readdirCache.set(t.absolute,e),t.readdir=e,this[Un]()}[Un](){if(!this[yi]){this[yi]=!0;for(let t=this[Et].head;t&&this[bt]<this.jobs;t=t.next)if(this[Hs](t.value),t.value.ignore){let e=t.next;this[Et].removeNode(t),t.next=e}this[yi]=!1,this[wi]&&this[Et].length===0&&this[bt]===0&&(this.zip?this.zip.end(Ku):(super.write(Ku),super.end()))}}get[pn](){return this[Et]&&this[Et].head&&this[Et].head.value}[xc](t){this[Et].shift(),this[bt]-=1;let{stat:e}=t;if(e&&e.isFile()&&e.nlink>1){let r=`${e.dev}:${e.ino}`,i=this[_i].get(r);if(i){this[_i].delete(r);for(let o of i)o.pending=!1,this[Hs](o)}}this[Un]()}[Hs](t){if(t.pending&&t.pendingLink&&t===this[pn]&&(t.pending=!1,t.pendingLink=!1),!t.pending){if(t.entry){t===this[pn]&&!t.piped&&this[Xs](t);return}if(!t.stat){let e=this.statCache.get(t.absolute);e?this[Vs](t,e):this[Oc](t)}if(t.stat&&!t.ignore){if(!this.noDirRecurse&&t.stat.isDirectory()&&!t.readdir){let e=this.readdirCache.get(t.absolute);if(e?this[Zs](t,e):this[Lc](t),!t.readdir)return}if(t.entry=this[Yu](t),!t.entry){t.ignore=!0;return}t===this[pn]&&!t.piped&&this[Xs](t)}}}[pc](t){return{onwarn:(e,r,i)=>this.warn(e,r,i),noPax:this.noPax,cwd:this.cwd,absolute:t.absolute,preservePaths:this.preservePaths,maxReadSize:this.maxReadSize,strict:this.strict,portable:this.portable,linkCache:this.linkCache,statCache:this.statCache,noMtime:this.noMtime,mtime:this.mtime,prefix:this.prefix,onWriteEntry:this.onWriteEntry}}[Yu](t){this[bt]+=1;try{return new this[Qs](t.path,this[pc](t)).on("end",()=>this[xc](t)).on("error",e=>this.emit("error",e))}catch(e){this.emit("error",e)}}[mc](){this[pn]&&this[pn].entry&&this[pn].entry.resume()}[Xs](t){t.piped=!0,t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[Js](c+i)});let e=t.entry,r=this.zip;if(!e)throw new Error("cannot pipe without source");r?e.on("data",i=>{r.write(i)||e.pause()}):e.on("data",i=>{super.write(i)||e.pause()})}pause(){return this.zip&&this.zip.pause(),super.pause()}warn(t,e,r={}){co(this,t,e,r)}},Jc=class extends uo{sync=!0;constructor(t){super(t),this[Qs]=m_}pause(){}resume(){}[Oc](t){let e=this.follow?"statSync":"lstatSync";this[Vs](t,no[e](t.absolute))}[Lc](t){this[Zs](t,no.readdirSync(t.absolute))}[Xs](t){let e=t.entry,r=this.zip;if(t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[Js](c+i)}),!e)throw new Error("Cannot pipe without source");r?e.on("data",i=>{r.write(i)}):e.on("data",i=>{super[bf](i)})}},v_=(t,e)=>{let r=new Jc(t),i=new df(t.file,{mode:t.mode||438});r.pipe(i),vf(r,e)},S_=(t,e)=>{let r=new uo(t),i=new oo(t.file,{mode:t.mode||438});r.pipe(i);let o=new Promise((c,d)=>{i.on("error",d),i.on("close",c),r.on("error",d)});return Sf(r,e).catch(c=>r.emit("error",c)),o},vf=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?Tr({file:lf.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},Sf=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await Tr({file:lf.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>{t.add(i)}}):t.add(r);t.end()},I_=(t,e)=>{let r=new Jc(t);return vf(r,e),r},A_=(t,e)=>{let r=new uo(t);return Sf(r,e).catch(i=>r.emit("error",i)),r},oA=Oi(v_,S_,I_,A_,(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")}),T_=process.env.__FAKE_PLATFORM__||process.platform,Tf=T_==="win32",{O_CREAT:Rf,O_NOFOLLOW:Vu,O_TRUNC:Cf,O_WRONLY:Pf}=kf.constants,Df=Number(process.env.__FAKE_FS_O_FILENAME__)||kf.constants.UV_FS_O_FILEMAP||0,R_=Tf&&!!Df,C_=512*1024,P_=Df|Cf|Rf|Pf,Ju=!Tf&&typeof Vu=="number"?Vu|Cf|Rf|Pf:null,Of=Ju!==null?()=>Ju:R_?t=>t<C_?P_:"w":()=>"w",Nc=(t,e,r)=>{try{return fo.lchownSync(t,e,r)}catch(i){if(i?.code!=="ENOENT")throw i}},io=(t,e,r,i)=>{fo.lchown(t,e,r,o=>{i(o&&o?.code!=="ENOENT"?o:null)})},D_=(t,e,r,i,o)=>{if(e.isDirectory())Lf(Ai.resolve(t,e.name),r,i,c=>{if(c)return o(c);let d=Ai.resolve(t,e.name);io(d,r,i,o)});else{let c=Ai.resolve(t,e.name);io(c,r,i,o)}},Lf=(t,e,r,i)=>{fo.readdir(t,{withFileTypes:!0},(o,c)=>{if(o){if(o.code==="ENOENT")return i();if(o.code!=="ENOTDIR"&&o.code!=="ENOTSUP")return i(o)}if(o||!c.length)return io(t,e,r,i);let d=c.length,u=null,f=x=>{if(!u){if(x)return i(u=x);if(--d===0)return io(t,e,r,i)}};for(let x of c)D_(t,x,e,r,f)})},O_=(t,e,r,i)=>{e.isDirectory()&&Nf(Ai.resolve(t,e.name),r,i),Nc(Ai.resolve(t,e.name),r,i)},Nf=(t,e,r)=>{let i;try{i=fo.readdirSync(t,{withFileTypes:!0})}catch(o){let c=o;if(c?.code==="ENOENT")return;if(c?.code==="ENOTDIR"||c?.code==="ENOTSUP")return Nc(t,e,r);throw c}for(let o of i)O_(t,o,e,r);return Nc(t,e,r)},Mf=class extends Error{path;code;syscall="chdir";constructor(t,e){super(`${e}: Cannot cd into '${t}'`),this.path=t,this.code=e}get name(){return"CwdError"}},ho=class extends Error{path;symlink;syscall="symlink";code="TAR_SYMLINK_ERROR";constructor(t,e){super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"),this.symlink=t,this.path=e}get name(){return"SymlinkError"}},N_=(t,e)=>{ct.stat(t,(r,i)=>{(r||!i.isDirectory())&&(r=new Mf(t,r?.code||"ENOTDIR")),e(r)})},M_=(t,e,r)=>{t=Q(t);let i=e.umask??18,o=e.mode|448,c=(o&i)!==0,d=e.uid,u=e.gid,f=typeof d=="number"&&typeof u=="number"&&(d!==e.processUid||u!==e.processGid),x=e.preserve,g=e.unlink,w=Q(e.cwd),S=(v,I)=>{v?r(v):I&&f?Lf(I,d,u,A=>S(A)):c?ct.chmod(t,o,r):r()};if(t===w)return N_(t,S);if(x)return L_.mkdir(t,{mode:o,recursive:!0}).then(v=>S(null,v??void 0),S);let y=Q(so.relative(w,t)).split("/");Mc(w,y,o,g,w,void 0,S)},Mc=(t,e,r,i,o,c,d)=>{if(e.length===0)return d(null,c);let u=e.shift(),f=Q(so.resolve(t+"/"+u));ct.mkdir(f,r,Bf(f,e,r,i,o,c,d))},Bf=(t,e,r,i,o,c,d)=>u=>{u?ct.lstat(t,(f,x)=>{if(f)f.path=f.path&&Q(f.path),d(f);else if(x.isDirectory())Mc(t,e,r,i,o,c,d);else if(i)ct.unlink(t,g=>{if(g)return d(g);ct.mkdir(t,r,Bf(t,e,r,i,o,c,d))});else{if(x.isSymbolicLink())return d(new ho(t,t+"/"+e.join("/")));d(u)}}):(c=c||t,Mc(t,e,r,i,o,c,d))},B_=t=>{let e=!1,r;try{e=ct.statSync(t).isDirectory()}catch(i){r=i?.code}finally{if(!e)throw new Mf(t,r??"ENOTDIR")}},F_=(t,e)=>{t=Q(t);let r=e.umask??18,i=e.mode|448,o=(i&r)!==0,c=e.uid,d=e.gid,u=typeof c=="number"&&typeof d=="number"&&(c!==e.processUid||d!==e.processGid),f=e.preserve,x=e.unlink,g=Q(e.cwd),w=v=>{v&&u&&Nf(v,c,d),o&&ct.chmodSync(t,i)};if(t===g)return B_(g),w();if(f)return w(ct.mkdirSync(t,{mode:i,recursive:!0})??void 0);let S=Q(so.relative(g,t)).split("/"),y;for(let v=S.shift(),I=g;v&&(I+="/"+v);v=S.shift()){I=Q(so.resolve(I));try{ct.mkdirSync(I,i),y=y||I}catch{let A=ct.lstatSync(I);if(A.isDirectory())continue;if(x){ct.unlinkSync(I),ct.mkdirSync(I,i),y=y||I;continue}else if(A.isSymbolicLink())return new ho(I,I+"/"+S.join("/"))}}return w(y)},gc=Object.create(null),Zu=1e4,_r=new Set,z_=t=>{_r.has(t)?_r.delete(t):gc[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),_r.add(t);let e=gc[t],r=_r.size-Zu;if(r>Zu/10){for(let i of _r)if(_r.delete(i),delete gc[i],--r<=0)break}return e},U_=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,G_=U_==="win32",H_=t=>t.split("/").slice(0,-1).reduce((e,r)=>{let i=e.at(-1);return i!==void 0&&(r=Ff(i,r)),e.push(r||"/"),e},[]),q_=class{#e=new Map;#n=new Map;#r=new Set;reserve(t,e){t=G_?["win32 parallelization disabled"]:t.map(i=>Ii(Ff(z_(i))));let r=new Set(t.map(i=>H_(i)).reduce((i,o)=>i.concat(o)));this.#n.set(e,{dirs:r,paths:t});for(let i of t){let o=this.#e.get(i);o?o.push(e):this.#e.set(i,[e])}for(let i of r){let o=this.#e.get(i);if(!o)this.#e.set(i,[new Set([e])]);else{let c=o.at(-1);c instanceof Set?c.add(e):o.push(new Set([e]))}}return this.#i(e)}#s(t){let e=this.#n.get(t);if(!e)throw new Error("function does not have any path reservations");return{paths:e.paths.map(r=>this.#e.get(r)),dirs:[...e.dirs].map(r=>this.#e.get(r))}}check(t){let{paths:e,dirs:r}=this.#s(t);return e.every(i=>i&&i[0]===t)&&r.every(i=>i&&i[0]instanceof Set&&i[0].has(t))}#i(t){return this.#r.has(t)||!this.check(t)?!1:(this.#r.add(t),t(()=>this.#t(t)),!0)}#t(t){if(!this.#r.has(t))return!1;let e=this.#n.get(t);if(!e)throw new Error("invalid reservation");let{paths:r,dirs:i}=e,o=new Set;for(let c of r){let d=this.#e.get(c);if(!d||d?.[0]!==t)continue;let u=d[1];if(!u){this.#e.delete(c);continue}if(d.shift(),typeof u=="function")o.add(u);else for(let f of u)o.add(f)}for(let c of i){let d=this.#e.get(c),u=d?.[0];if(!(!d||!(u instanceof Set)))if(u.size===1&&d.length===1){this.#e.delete(c);continue}else if(u.size===1){d.shift();let f=d[0];typeof f=="function"&&o.add(f)}else u.delete(t)}return this.#r.delete(t),o.forEach(c=>this.#i(c)),!0}},j_=()=>process.umask(),Xu=Symbol("onEntry"),Bc=Symbol("checkFs"),Qu=Symbol("checkFs2"),Fc=Symbol("isReusable"),ht=Symbol("makeFs"),zc=Symbol("file"),Uc=Symbol("directory"),eo=Symbol("link"),ef=Symbol("symlink"),tf=Symbol("hardlink"),vi=Symbol("ensureNoSymlink"),nf=Symbol("unsupported"),rf=Symbol("checkPath"),wc=Symbol("stripAbsolutePath"),yn=Symbol("mkdir"),qe=Symbol("onError"),qs=Symbol("pending"),sf=Symbol("pend"),yr=Symbol("unpend"),_c=Symbol("ended"),yc=Symbol("maybeClose"),Gc=Symbol("skip"),ki=Symbol("doChown"),Ti=Symbol("uid"),Ri=Symbol("gid"),Ci=Symbol("checkedCwd"),W_=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Pi=W_==="win32",K_=1024,$_=(t,e)=>{if(!Pi)return ie.unlink(t,e);let r=t+".DELETE."+Af(16).toString("hex");ie.rename(t,r,i=>{if(i)return e(i);ie.unlink(r,e)})},Y_=t=>{if(!Pi)return ie.unlinkSync(t);let e=t+".DELETE."+Af(16).toString("hex");ie.renameSync(t,e),ie.unlinkSync(e)},of=(t,e,r)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:r,Zc=class extends Di{[_c]=!1;[Ci]=!1;[qs]=0;reservations=new q_;transform;writable=!0;readable=!1;uid;gid;setOwner;preserveOwner;processGid;processUid;maxDepth;forceChown;win32;newer;keep;noMtime;preservePaths;unlink;cwd;strip;processUmask;umask;dmode;fmode;chmod;constructor(t={}){if(t.ondone=()=>{this[_c]=!0,this[yc]()},super(t),this.transform=t.transform,this.chmod=!!t.chmod,typeof t.uid=="number"||typeof t.gid=="number"){if(typeof t.uid!="number"||typeof t.gid!="number")throw new TypeError("cannot set owner without number uid and gid");if(t.preserveOwner)throw new TypeError("cannot preserve owner in archive and also set owner explicitly");this.uid=t.uid,this.gid=t.gid,this.setOwner=!0}else this.uid=void 0,this.gid=void 0,this.setOwner=!1;this.preserveOwner=t.preserveOwner===void 0&&typeof t.uid!="number"?!!(process.getuid&&process.getuid()===0):!!t.preserveOwner,this.processUid=(this.preserveOwner||this.setOwner)&&process.getuid?process.getuid():void 0,this.processGid=(this.preserveOwner||this.setOwner)&&process.getgid?process.getgid():void 0,this.maxDepth=typeof t.maxDepth=="number"?t.maxDepth:K_,this.forceChown=t.forceChown===!0,this.win32=!!t.win32||Pi,this.newer=!!t.newer,this.keep=!!t.keep,this.noMtime=!!t.noMtime,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.cwd=Q(Me.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:j_():0,this.umask=typeof t.umask=="number"?t.umask:this.processUmask,this.dmode=t.dmode||511&~this.umask,this.fmode=t.fmode||438&~this.umask,this.on("entry",e=>this[Xu](e))}warn(t,e,r={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(r.recoverable=!1),super.warn(t,e,r)}[yc](){this[_c]&&this[qs]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[wc](t,e){let r=t[e],{type:i}=t;if(!r||this.preservePaths)return!0;let[o,c]=$c(r),d=c.replaceAll(/\\/g,"/").split("/");if(d.includes("..")||Pi&&/^[a-z]:\.\.$/i.test(d[0]??"")){if(e==="path"||i==="Link")return this.warn("TAR_ENTRY_ERROR",`${e} contains '..'`,{entry:t,[e]:r}),!1;let u=Me.posix.dirname(t.path),f=Me.posix.normalize(Me.posix.join(u,d.join("/")));if(f.startsWith("../")||f==="..")return this.warn("TAR_ENTRY_ERROR",`${e} escapes extraction directory`,{entry:t,[e]:r}),!1}return o&&(t[e]=String(c),this.warn("TAR_ENTRY_INFO",`stripping ${o} from absolute ${e}`,{entry:t,[e]:r})),!0}[rf](t){let e=Q(t.path),r=e.split("/");if(this.strip){if(r.length<this.strip)return!1;if(t.type==="Link"){let i=Q(String(t.linkpath)).split("/");if(i.length>=this.strip)t.linkpath=i.slice(this.strip).join("/");else return!1}r.splice(0,this.strip),t.path=r.join("/")}if(isFinite(this.maxDepth)&&r.length>this.maxDepth)return this.warn("TAR_ENTRY_ERROR","path excessively deep",{entry:t,path:e,depth:r.length,maxDepth:this.maxDepth}),!1;if(!this[wc](t,"path")||!this[wc](t,"linkpath"))return!1;if(t.absolute=Me.isAbsolute(t.path)?Q(Me.resolve(t.path)):Q(Me.resolve(this.cwd,t.path)),!this.preservePaths&&typeof t.absolute=="string"&&t.absolute.indexOf(this.cwd+"/")!==0&&t.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:t,path:Q(t.path),resolvedPath:t.absolute,cwd:this.cwd}),!1;if(t.absolute===this.cwd&&t.type!=="Directory"&&t.type!=="GNUDumpDir")return!1;if(this.win32){let{root:i}=Me.win32.parse(String(t.absolute));t.absolute=i+zu(String(t.absolute).slice(i.length));let{root:o}=Me.win32.parse(t.path);t.path=o+zu(t.path.slice(o.length))}return!0}[Xu](t){if(!this[rf](t))return t.resume();switch(k_.equal(typeof t.absolute,"string"),t.type){case"Directory":case"GNUDumpDir":t.mode&&(t.mode=t.mode|448);case"File":case"OldFile":case"ContiguousFile":case"Link":case"SymbolicLink":return this[Bc](t);default:return this[nf](t)}}[qe](t,e){t.name==="CwdError"?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:e}),this[yr](),e.resume())}[yn](t,e,r){M_(Q(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:e},r)}[ki](t){return this.forceChown||this.preserveOwner&&(typeof t.uid=="number"&&t.uid!==this.processUid||typeof t.gid=="number"&&t.gid!==this.processGid)||typeof this.uid=="number"&&this.uid!==this.processUid||typeof this.gid=="number"&&this.gid!==this.processGid}[Ti](t){return of(this.uid,t.uid,this.processUid)}[Ri](t){return of(this.gid,t.gid,this.processGid)}[zc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=new oo(String(t.absolute),{flags:Of(t.size),mode:r,autoClose:!1});i.on("error",u=>{i.fd&&ie.close(i.fd,()=>{}),i.write=()=>!0,this[qe](u,t),e()});let o=1,c=u=>{if(u){i.fd&&ie.close(i.fd,()=>{}),this[qe](u,t),e();return}--o===0&&i.fd!==void 0&&ie.close(i.fd,f=>{f?this[qe](f,t):this[yr](),e()})};i.on("finish",()=>{let u=String(t.absolute),f=i.fd;if(typeof f=="number"&&t.mtime&&!this.noMtime){o++;let x=t.atime||new Date,g=t.mtime;ie.futimes(f,x,g,w=>w?ie.utimes(u,x,g,S=>c(S&&w)):c())}if(typeof f=="number"&&this[ki](t)){o++;let x=this[Ti](t),g=this[Ri](t);typeof x=="number"&&typeof g=="number"&&ie.fchown(f,x,g,w=>w?ie.chown(u,x,g,S=>c(S&&w)):c())}c()});let d=this.transform&&this.transform(t)||t;d!==t&&(d.on("error",u=>{this[qe](u,t),e()}),t.pipe(d)),d.pipe(i)}[Uc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode;this[yn](String(t.absolute),r,i=>{if(i){this[qe](i,t),e();return}let o=1,c=()=>{--o===0&&(e(),this[yr](),t.resume())};t.mtime&&!this.noMtime&&(o++,ie.utimes(String(t.absolute),t.atime||new Date,t.mtime,c)),this[ki](t)&&(o++,ie.chown(String(t.absolute),Number(this[Ti](t)),Number(this[Ri](t)),c)),c()})}[nf](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[ef](t,e){let r=Q(Me.relative(this.cwd,Me.resolve(Me.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[vi](t,this.cwd,r,()=>this[eo](t,String(t.linkpath),"symlink",e),i=>{this[qe](i,t),e()})}[tf](t,e){let r=Q(Me.resolve(this.cwd,String(t.linkpath))),i=Q(String(t.linkpath)).split("/");this[vi](t,this.cwd,i,()=>this[eo](t,r,"link",e),o=>{this[qe](o,t),e()})}[vi](t,e,r,i,o){let c=r.shift();if(this.preservePaths||c===void 0)return i();let d=Me.resolve(e,c);ie.lstat(d,(u,f)=>{if(u)return i();if(f?.isSymbolicLink())return o(new ho(d,Me.resolve(d,r.join("/"))));this[vi](t,d,r,i,o)})}[sf](){this[qs]++}[yr](){this[qs]--,this[yc]()}[Gc](t){this[yr](),t.resume()}[Fc](t,e){return t.type==="File"&&!this.unlink&&e.isFile()&&e.nlink<=1&&!Pi}[Bc](t){this[sf]();let e=[t.path];t.linkpath&&e.push(t.linkpath),this.reservations.reserve(e,r=>this[Qu](t,r))}[Qu](t,e){let r=d=>{e(d)},i=()=>{this[yn](this.cwd,this.dmode,d=>{if(d){this[qe](d,t),r();return}this[Ci]=!0,o()})},o=()=>{if(t.absolute!==this.cwd){let d=Q(Me.dirname(String(t.absolute)));if(d!==this.cwd)return this[yn](d,this.dmode,u=>{if(u){this[qe](u,t),r();return}c()})}c()},c=()=>{ie.lstat(String(t.absolute),(d,u)=>{if(u&&(this.keep||this.newer&&u.mtime>(t.mtime??u.mtime))){this[Gc](t),r();return}if(d||this[Fc](t,u))return this[ht](null,t,r);if(u.isDirectory()){if(t.type==="Directory"){let f=this.chmod&&t.mode&&(u.mode&4095)!==t.mode,x=g=>this[ht](g??null,t,r);return f?ie.chmod(String(t.absolute),Number(t.mode),x):x()}if(t.absolute!==this.cwd)return ie.rmdir(String(t.absolute),f=>this[ht](f??null,t,r))}if(t.absolute===this.cwd)return this[ht](null,t,r);$_(String(t.absolute),f=>this[ht](f??null,t,r))})};this[Ci]?o():i()}[ht](t,e,r){if(t){this[qe](t,e),r();return}switch(e.type){case"File":case"OldFile":case"ContiguousFile":return this[zc](e,r);case"Link":return this[tf](e,r);case"SymbolicLink":return this[ef](e,r);case"Directory":case"GNUDumpDir":return this[Uc](e,r)}}[eo](t,e,r,i){ie[r](e,String(t.absolute),o=>{o?this[qe](o,t):(this[yr](),t.resume()),i()})}},Ei=t=>{try{return[null,t()]}catch(e){return[e,null]}},zf=class extends Zc{sync=!0;[ht](t,e){return super[ht](t,e,()=>{})}[Bc](t){if(!this[Ci]){let o=this[yn](this.cwd,this.dmode);if(o)return this[qe](o,t);this[Ci]=!0}if(t.absolute!==this.cwd){let o=Q(Me.dirname(String(t.absolute)));if(o!==this.cwd){let c=this[yn](o,this.dmode);if(c)return this[qe](c,t)}}let[e,r]=Ei(()=>ie.lstatSync(String(t.absolute)));if(r&&(this.keep||this.newer&&r.mtime>(t.mtime??r.mtime)))return this[Gc](t);if(e||this[Fc](t,r))return this[ht](null,t);if(r.isDirectory()){if(t.type==="Directory"){let c=this.chmod&&t.mode&&(r.mode&4095)!==t.mode,[d]=c?Ei(()=>{ie.chmodSync(String(t.absolute),Number(t.mode))}):[];return this[ht](d,t)}let[o]=Ei(()=>ie.rmdirSync(String(t.absolute)));this[ht](o,t)}let[i]=t.absolute===this.cwd?[]:Ei(()=>Y_(String(t.absolute)));this[ht](i,t)}[zc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=d=>{let u;try{ie.closeSync(o)}catch(f){u=f}(d||u)&&this[qe](d||u,t),e()},o;try{o=ie.openSync(String(t.absolute),Of(t.size),r)}catch(d){return i(d)}let c=this.transform&&this.transform(t)||t;c!==t&&(c.on("error",d=>this[qe](d,t)),t.pipe(c)),c.on("data",d=>{try{ie.writeSync(o,d,0,d.length)}catch(u){i(u)}}),c.on("end",()=>{let d=null;if(t.mtime&&!this.noMtime){let u=t.atime||new Date,f=t.mtime;try{ie.futimesSync(o,u,f)}catch(x){try{ie.utimesSync(String(t.absolute),u,f)}catch{d=x}}}if(this[ki](t)){let u=this[Ti](t),f=this[Ri](t);try{ie.fchownSync(o,Number(u),Number(f))}catch(x){try{ie.chownSync(String(t.absolute),Number(u),Number(f))}catch{d=d||x}}}i(d)})}[Uc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode,i=this[yn](String(t.absolute),r);if(i){this[qe](i,t),e();return}if(t.mtime&&!this.noMtime)try{ie.utimesSync(String(t.absolute),t.atime||new Date,t.mtime)}catch{}if(this[ki](t))try{ie.chownSync(String(t.absolute),Number(this[Ti](t)),Number(this[Ri](t)))}catch{}e(),t.resume()}[yn](t,e){try{return F_(Q(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:e})}catch(r){return r}}[vi](t,e,r,i,o){if(this.preservePaths||r.length===0)return i();let c=e;for(let d of r){c=Me.resolve(c,d);let[u,f]=Ei(()=>ie.lstatSync(c));if(u)return i();if(f.isSymbolicLink())return o(new ho(c,Me.resolve(e,r.join("/"))))}i()}[eo](t,e,r,i){let o=`${r}Sync`;try{ie[o](e,String(t.absolute)),i(),t.resume()}catch(c){return this[qe](c,t)}}},V_=t=>{let e=new zf(t),r=t.file,i=If.statSync(r),o=t.maxReadSize||16*1024*1024;new xw(r,{readSize:o,size:i.size}).pipe(e)},J_=(t,e)=>{let r=new Zc(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,d)=>{r.on("error",d),r.on("close",c),If.stat(o,(u,f)=>{if(u)d(u);else{let x=new qc(o,{readSize:i,size:f.size});x.on("error",d),x.pipe(r)}})})},Uf=Oi(V_,J_,t=>new zf(t),t=>new Zc(t),(t,e)=>{e?.length&&wf(t,e)}),Z_=(t,e)=>{let r=new Jc(t),i=!0,o,c;try{try{o=at.openSync(t.file,"r+")}catch(f){if(f?.code==="ENOENT")o=at.openSync(t.file,"w+");else throw f}let d=at.fstatSync(o),u=Buffer.alloc(512);e:for(c=0;c<d.size;c+=512){for(let g=0,w=0;g<512;g+=w){if(w=at.readSync(o,u,g,u.length-g,c+g),c===0&&u[0]===31&&u[1]===139)throw new Error("cannot append to compressed archives");if(!w)break e}let f=new jn(u);if(!f.cksumValid)break;let x=512*Math.ceil((f.size||0)/512);if(c+x+512>d.size)break;c+=x,t.mtimeCache&&f.mtime&&t.mtimeCache.set(String(f.path),f.mtime)}i=!1,X_(t,r,c,o,e)}finally{if(i)try{at.closeSync(o)}catch{}}},X_=(t,e,r,i,o)=>{let c=new df(t.file,{fd:i,start:r});e.pipe(c),ey(e,o)},Q_=(t,e)=>{e=Array.from(e);let r=new uo(t),i=(o,c,d)=>{let u=(S,y)=>{S?at.close(o,v=>d(S)):d(null,y)},f=0;if(c===0)return u(null,0);let x=0,g=Buffer.alloc(512),w=(S,y)=>{if(S||y===void 0)return u(S);if(x+=y,x<512&&y)return at.read(o,g,x,g.length-x,f+x,w);if(f===0&&g[0]===31&&g[1]===139)return u(new Error("cannot append to compressed archives"));if(x<512)return u(null,f);let v=new jn(g);if(!v.cksumValid)return u(null,f);let I=512*Math.ceil((v.size??0)/512);if(f+I+512>c||(f+=I+512,f>=c))return u(null,f);t.mtimeCache&&v.mtime&&t.mtimeCache.set(String(v.path),v.mtime),x=0,at.read(o,g,0,512,f,w)};at.read(o,g,0,512,f,w)};return new Promise((o,c)=>{r.on("error",c);let d="r+",u=(f,x)=>{if(f&&f.code==="ENOENT"&&d==="r+")return d="w+",at.open(t.file,d,u);if(f||!x)return c(f);at.fstat(x,(g,w)=>{if(g)return at.close(x,()=>c(g));i(x,w.size,(S,y)=>{if(S)return c(S);let v=new oo(t.file,{fd:x,start:y});r.pipe(v),v.on("error",c),v.on("close",o),ty(r,e)})})};at.open(t.file,d,u)})},ey=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?Tr({file:Gf.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},ty=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await Tr({file:Gf.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r);t.end()},bi=Oi(Z_,Q_,()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},(t,e)=>{if(!bw(t))throw new TypeError("file is required");if(t.gzip||t.brotli||t.zstd||t.file.endsWith(".br")||t.file.endsWith(".tbr"))throw new TypeError("cannot append to compressed archives");if(!e?.length)throw new TypeError("no paths specified to add/replace")}),EA=Oi(bi.syncFile,bi.asyncFile,bi.syncNoFile,bi.asyncNoFile,(t,e=[])=>{bi.validate?.(t,e),ny(t)}),ny=t=>{let e=t.filter;t.mtimeCache||(t.mtimeCache=new Map),t.filter=e?(r,i)=>e(r,i)&&!((t.mtimeCache?.get(r)??i.mtime??0)>(i.mtime??0)):(r,i)=>!((t.mtimeCache?.get(r)??i.mtime??0)>(i.mtime??0))};jt();var xt={PAIR:"_agent/pair",CREATE:"_agent/create",HEALTH:"_agent/health",LIST_SKILLS:"_agent/listSkills",ADD_SKILLS:"_agent/addSkills",REMOVE_SKILLS:"_agent/removeSkills",GET_FILE_TREE:"_agent/getFileTree",GET_FILE_CONTENT:"_agent/getFileContent",DETAIL:"_agent/detail",UPDATE:"_agent/update",DISCONNECT:"_agent/disconnect",SWITCH_MODEL:"_agent/switchModel",GEN_MODEL_TOKEN:"_agent/genModelToken",RESET:"_agent/reset",REPAIR:"_agent/repair",UPGRADE:"_agent/upgrade",DELETE:"_agent/delete",PUBLISH_SKILL:"_agent/publishSkill"};function xo(t){return t?.cozeDeployType==="cloud"?"cloud":"local"}function Hf(t){let e=t?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function po(t){let e=t?.cozeGroupId?.trim();if(!(!e||e==="0"))return e}function qf(t){let e=t?.permissionMode;if(typeof e!="string")return;let r=e.trim();return r===""?void 0:r}function jf(t){let{_meta:e,...r}=t;return{stripped:r,meta:e}}function Kn(t){if(!t?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return t.cozeAgentId}Zt();Ke();te();Re();Ke();function Rr(t,e){if(xo(t)!=="cloud")throw new k("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function Li(t){return t.startsWith("http://")||t.startsWith("https://")}function Cr(t){return t.endsWith("/")?t.slice(0,-1):t}import{readFileSync as fk}from"node:fs";import{dirname as xk,join as pk}from"node:path";import{fileURLToPath as gk}from"node:url";var Nt="0.2.7-alpha.102";import{mkdir as wy,rm as d0}from"node:fs/promises";import{join as zi}from"node:path";qt();import{readFileSync as ly}from"node:fs";var uy=384;async function Xc(t,e=process.env){let r={};for(let[i,o]of Object.entries(e))typeof o=="string"&&(r[i]=o);await ur(t.agentEnvFile,r,{mode:uy})}function Ni(t){try{let e=JSON.parse(ly(t,"utf8"));return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function Yf(t,e,r={},i=o=>o){return{...i({...t,...Ni(e)}),...r}}qt();function Mi(t){let e=[],r=Object.keys(t).sort();for(let i of r){let o=t[i];o!==void 0&&(fy(o)||e.push(`${i}=${o}`))}return e.length===0?"":`${e.join(`
|
|
89
|
+
`},configPath(t){return _A(t.homeDir,".coze","bridge","task.xml")},async install(t){let n=`cmd.exe /c ${[`^"${t.nodeBin}^"`,`^"${t.entry}^"`,"--daemon",`>> ^"${t.logFile}^" 2>&1`].join(" ")}`;await Fp("schtasks",["/Create","/SC","ONLOGON","/TN",ya,"/TR",n,"/RU",t.userName,"/F"]),ol.info("task scheduler entry created",{task:ya,logFile:t.logFile})},async uninstall(t){await Fp("schtasks",["/Delete","/TN",ya,"/F"]).catch(e=>ol.warn("schtasks /Delete failed (ignored)",{err:String(e)})),ol.info("task scheduler entry removed",{task:ya})}}});var Up={};Oa(Up,{buildContext:()=>IA,getSupervisor:()=>bA,launchdSupervisor:()=>il,systemdSupervisor:()=>sl,taskSchedulerSupervisor:()=>al});import{homedir as yA,userInfo as EA}from"node:os";function bA(t=process.platform){switch(t){case"darwin":return il;case"linux":return sl;case"win32":return al;default:throw new Error(`unsupported platform for OS supervisor: ${t}`)}}function SA(){let t={};for(let e of vA){let n=process.env[e];n&&(t[e]=n)}return t}function IA(){let t=Y();return{nodeBin:process.execPath,entry:Jd(t),logFile:t.logFile,homeDir:yA(),userName:EA().username,isRoot:process.getuid?.()===0,env:SA()}}var vA,Gp=nt(()=>{"use strict";Re();la();Np();Bp();zp();vA=["PATH","HOME","HTTP_PROXY","HTTPS_PROXY","NO_PROXY","ALL_PROXY","http_proxy","https_proxy","no_proxy","all_proxy","NODE_EXTRA_CA_CERTS"]});ne();dn();var zl=q("acp-installer-warmup"),pm=["claude-code","codex"];async function Ul(t={}){let e=t.ensure??dr,i=(await Promise.allSettled(pm.map(async o=>{let c=await e(o);zl.info("acp wrapper warmup ok",{framework:o,path:c})}))).filter(o=>o.status==="rejected");i.length>0&&zl.warn("acp wrapper warmup partial failure (\u5C06\u5728\u4E0B\u6B21 createAgent \u65F6\u91CD\u8BD5\u5E76\u629B\u9519\u7ED9\u7528\u6237)",{failedCount:i.length,reasons:i.map(o=>o.reason instanceof Error?o.reason.message:String(o.reason))})}qt();ne();import{readdir as Cm}from"node:fs/promises";import{mkdir as jl,readFile as Pm,writeFile as Wl}from"node:fs/promises";import{join as Ua}from"node:path";var Rm={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md",hermes:"AGENTS.md"};async function fr(t,e,n){await jl(t,{recursive:!0});let i=Rm[e],o=Ua(t,i);return await Wl(o,n??"","utf8"),o}async function Ga(t,e,n){let i=Ua(t,".claude");await jl(i,{recursive:!0});let o=Ua(i,"settings.local.json"),c={};try{let u=await Pm(o,"utf8"),f=JSON.parse(u);typeof f=="object"&&f!==null&&!Array.isArray(f)&&(c=f)}catch{}let d=typeof c.permissions=="object"&&c.permissions!==null&&!Array.isArray(c.permissions)?c.permissions:{};if(e==="cloud")d.defaultMode="bypassPermissions",c.autoCompactWindow=15e4;else{if(!n)throw new Error("writeCcPermissionSettings: local deployType requires permissionMode (caller bug)");d.defaultMode===void 0&&(d.defaultMode=n)}return c.permissions=d,await Wl(o,JSON.stringify(c,null,2),"utf8"),o}var Xe=q("agent-detail-sync"),Dm=6e4,Om=5*6e4,vs=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let n=this.opts.paths.agentsRoot,i;try{i=await Cm(n)}catch(o){Xe.info("agents dir not found, skip detail sync",{root:n,err:String(o)});return}Xe.info("starting detail sync",{reason:e,count:i.length}),await Promise.allSettled(i.map(async o=>{let c=await Se(o,this.opts.paths).catch(()=>null);if(c){if(c.disconnectedAt){Xe.debug("detail sync: skip disconnected agent",{agentId:o});return}try{await this.syncOne(o,c)}catch(d){Xe.warn("detail sync failed for agent, skipping",{agentId:o,err:String(d)})}}})),Xe.info("detail sync done",{reason:e})}async retryPending(){if(this.retryQueue.size===0)return;let e=Date.now(),n=[];for(let[i,o]of this.retryQueue)e>=o.dueAt&&n.push(i);if(n.length!==0){Xe.info("retrying pending detail syncs",{count:n.length});for(let i of n)try{await this.syncOne(i)}catch(o){Xe.debug("detail sync retry still failing, will try again",{agentId:i,err:String(o)})}}}async syncOne(e,n){let i=n??await Se(e,this.opts.paths);if(!i){Xe.info("detail sync: agent config missing, skip",{agentId:e});return}let o;try{o=await this.opts.sendDetail({_meta:{cozeAgentId:e}}),this.retryQueue.delete(e)}catch(f){Xe.warn("detail RPC failed, using local data",{agentId:e,err:String(f)});let x=this.retryQueue.get(e),m=x?Math.min(x.currentDelay*2,Om):Dm;this.retryQueue.set(e,{dueAt:Date.now()+m,currentDelay:m});return}if(o.agentId&&o.agentId!==e){Xe.warn("detail response agentId mismatch, ignoring",{agentId:e,responseAgentId:o.agentId});return}let c=!1,d=!1;o.agentName&&o.agentName!==i.agentName&&(i.agentName=o.agentName,c=!0),o.description!==void 0&&o.description!==i.description&&(i.description=o.description,c=!0),o.cozeIdentity&&o.cozeIdentity!==i.cozeIdentity&&(i.cozeIdentity=o.cozeIdentity,c=!0,d=!0);let u=!1;if(o.deployType==="cloud"&&i.deployType!=="cloud"?(Xe.warn("detail sync: agent demoted to local, repairing to cloud",{agentId:e}),i.deployType="cloud",c=!0,u=!0):o.deployType&&Xe.info("detail.deployType",{agentId:e,deployType:o.deployType}),!c){Xe.debug("detail sync: no diff",{agentId:e});return}await Ue(i,this.opts.paths),Xe.info("detail sync: config updated",{agentId:e,identityChanged:d,agentName:i.agentName}),u?(await this.opts.agentManager.createAgent({agentId:e,framework:i.framework,_meta:{cozeDeployType:"cloud"},cozeIdentity:i.cozeIdentity,model:i.model}),Xe.info("detail sync: repaired demoted agent back to cloud",{agentId:e})):d&&(await fr(i.workspace,i.framework,i.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};var fd=Gt(Su(),1);import{createHash as Ey}from"node:crypto";import{lstat as id,mkdir as sd,readFile as _o,readdir as g0,rm as od,stat as ld,writeFile as ad}from"node:fs/promises";import{homedir as by}from"node:os";import{basename as h0,dirname as vy,join as ue,normalize as Sy,relative as ud,resolve as cd,sep as m0}from"node:path";import{Readable as w0}from"node:stream";import{pipeline as _0}from"node:stream/promises";import tw from"events";import it from"fs";import{EventEmitter as Uc}from"node:events";import of from"node:stream";import{StringDecoder as nw}from"node:string_decoder";import df from"node:path";import Sr from"node:fs";import{dirname as pw,parse as gw}from"path";import{EventEmitter as Sw}from"events";import Ec from"assert";import{Buffer as Hn}from"buffer";import*as Pu from"zlib";import Iw from"zlib";import{posix as mr}from"node:path";import{basename as Xw}from"node:path";import to from"fs";import Ct from"fs";import Mu from"path";import{win32 as l_}from"node:path";import qu from"path";import Sf from"node:fs";import k_ from"node:assert";import{randomBytes as If}from"node:crypto";import se from"node:fs";import Be from"node:path";import Af from"fs";import uo from"node:fs";import ki from"node:path";import ct from"node:fs";import L_ from"node:fs/promises";import io from"node:path";import{join as Bf}from"node:path";import at from"node:fs";import Uf from"node:path";var Qm=Object.defineProperty,ew=(t,e)=>{for(var n in e)Qm(t,n,{get:e[n],enumerable:!0})},Iu=typeof process=="object"&&process?process:{stdout:null,stderr:null},rw=t=>!!t&&typeof t=="object"&&(t instanceof Wn||t instanceof of||iw(t)||sw(t)),iw=t=>!!t&&typeof t=="object"&&t instanceof Uc&&typeof t.pipe=="function"&&t.pipe!==of.Writable.prototype.pipe,sw=t=>!!t&&typeof t=="object"&&t instanceof Uc&&typeof t.write=="function"&&typeof t.end=="function",jt=Symbol("EOF"),Wt=Symbol("maybeEmitEnd"),un=Symbol("emittedEnd"),Ts=Symbol("emittingEnd"),li=Symbol("emittedError"),Ps=Symbol("closed"),Au=Symbol("read"),Rs=Symbol("flush"),ku=Symbol("flushChunk"),yt=Symbol("encoding"),gr=Symbol("decoder"),Ge=Symbol("flowing"),ui=Symbol("paused"),Er=Symbol("resume"),He=Symbol("buffer"),Qe=Symbol("pipes"),qe=Symbol("bufferLength"),$a=Symbol("bufferPush"),Cs=Symbol("bufferShift"),Ye=Symbol("objectMode"),ke=Symbol("destroyed"),Va=Symbol("error"),Ja=Symbol("emitData"),Tu=Symbol("emitEnd"),Za=Symbol("emitEnd2"),Tt=Symbol("async"),Ya=Symbol("abort"),Ds=Symbol("aborted"),fi=Symbol("signal"),On=Symbol("dataListeners"),ot=Symbol("discarded"),hi=t=>Promise.resolve().then(t),ow=t=>t(),aw=t=>t==="end"||t==="finish"||t==="prefinish",cw=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,dw=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),af=class{src;dest;opts;ondrain;constructor(t,e,n){this.src=t,this.dest=e,this.opts=n,this.ondrain=()=>t[Er](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},lw=class extends af{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,e,n){super(t,e,n),this.proxyErrors=i=>this.dest.emit("error",i),t.on("error",this.proxyErrors)}},uw=t=>!!t.objectMode,fw=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",Wn=class extends Uc{[Ge]=!1;[ui]=!1;[Qe]=[];[He]=[];[Ye];[yt];[Tt];[gr];[jt]=!1;[un]=!1;[Ts]=!1;[Ps]=!1;[li]=null;[qe]=0;[ke]=!1;[fi];[Ds]=!1;[On]=0;[ot]=!1;writable=!0;readable=!0;constructor(...t){let e=t[0]||{};if(super(),e.objectMode&&typeof e.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");uw(e)?(this[Ye]=!0,this[yt]=null):fw(e)?(this[yt]=e.encoding,this[Ye]=!1):(this[Ye]=!1,this[yt]=null),this[Tt]=!!e.async,this[gr]=this[yt]?new nw(this[yt]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[He]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Qe]});let{signal:n}=e;n&&(this[fi]=n,n.aborted?this[Ya]():n.addEventListener("abort",()=>this[Ya]()))}get bufferLength(){return this[qe]}get encoding(){return this[yt]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[Ye]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[Tt]}set async(t){this[Tt]=this[Tt]||!!t}[Ya](){this[Ds]=!0,this.emit("abort",this[fi]?.reason),this.destroy(this[fi]?.reason)}get aborted(){return this[Ds]}set aborted(t){}write(t,e,n){if(this[Ds])return!1;if(this[jt])throw new Error("write after end");if(this[ke])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof e=="function"&&(n=e,e="utf8"),e||(e="utf8");let i=this[Tt]?hi:ow;if(!this[Ye]&&!Buffer.isBuffer(t)){if(dw(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(cw(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[Ye]?(this[Ge]&&this[qe]!==0&&this[Rs](!0),this[Ge]?this.emit("data",t):this[$a](t),this[qe]!==0&&this.emit("readable"),n&&i(n),this[Ge]):t.length?(typeof t=="string"&&!(e===this[yt]&&!this[gr]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[yt]&&(t=this[gr].write(t)),this[Ge]&&this[qe]!==0&&this[Rs](!0),this[Ge]?this.emit("data",t):this[$a](t),this[qe]!==0&&this.emit("readable"),n&&i(n),this[Ge]):(this[qe]!==0&&this.emit("readable"),n&&i(n),this[Ge])}read(t){if(this[ke])return null;if(this[ot]=!1,this[qe]===0||t===0||t&&t>this[qe])return this[Wt](),null;this[Ye]&&(t=null),this[He].length>1&&!this[Ye]&&(this[He]=[this[yt]?this[He].join(""):Buffer.concat(this[He],this[qe])]);let e=this[Au](t||null,this[He][0]);return this[Wt](),e}[Au](t,e){if(this[Ye])this[Cs]();else{let n=e;t===n.length||t===null?this[Cs]():typeof n=="string"?(this[He][0]=n.slice(t),e=n.slice(0,t),this[qe]-=t):(this[He][0]=n.subarray(t),e=n.subarray(0,t),this[qe]-=t)}return this.emit("data",e),!this[He].length&&!this[jt]&&this.emit("drain"),e}end(t,e,n){return typeof t=="function"&&(n=t,t=void 0),typeof e=="function"&&(n=e,e="utf8"),t!==void 0&&this.write(t,e),n&&this.once("end",n),this[jt]=!0,this.writable=!1,(this[Ge]||!this[ui])&&this[Wt](),this}[Er](){this[ke]||(!this[On]&&!this[Qe].length&&(this[ot]=!0),this[ui]=!1,this[Ge]=!0,this.emit("resume"),this[He].length?this[Rs]():this[jt]?this[Wt]():this.emit("drain"))}resume(){return this[Er]()}pause(){this[Ge]=!1,this[ui]=!0,this[ot]=!1}get destroyed(){return this[ke]}get flowing(){return this[Ge]}get paused(){return this[ui]}[$a](t){this[Ye]?this[qe]+=1:this[qe]+=t.length,this[He].push(t)}[Cs](){return this[Ye]?this[qe]-=1:this[qe]-=this[He][0].length,this[He].shift()}[Rs](t=!1){do;while(this[ku](this[Cs]())&&this[He].length);!t&&!this[He].length&&!this[jt]&&this.emit("drain")}[ku](t){return this.emit("data",t),this[Ge]}pipe(t,e){if(this[ke])return t;this[ot]=!1;let n=this[un];return e=e||{},t===Iu.stdout||t===Iu.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,n?e.end&&t.end():(this[Qe].push(e.proxyErrors?new lw(this,t,e):new af(this,t,e)),this[Tt]?hi(()=>this[Er]()):this[Er]()),t}unpipe(t){let e=this[Qe].find(n=>n.dest===t);e&&(this[Qe].length===1?(this[Ge]&&this[On]===0&&(this[Ge]=!1),this[Qe]=[]):this[Qe].splice(this[Qe].indexOf(e),1),e.unpipe())}addListener(t,e){return this.on(t,e)}on(t,e){let n=super.on(t,e);if(t==="data")this[ot]=!1,this[On]++,!this[Qe].length&&!this[Ge]&&this[Er]();else if(t==="readable"&&this[qe]!==0)super.emit("readable");else if(aw(t)&&this[un])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[li]){let i=e;this[Tt]?hi(()=>i.call(this,this[li])):i.call(this,this[li])}return n}removeListener(t,e){return this.off(t,e)}off(t,e){let n=super.off(t,e);return t==="data"&&(this[On]=this.listeners("data").length,this[On]===0&&!this[ot]&&!this[Qe].length&&(this[Ge]=!1)),n}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[On]=0,!this[ot]&&!this[Qe].length&&(this[Ge]=!1)),e}get emittedEnd(){return this[un]}[Wt](){!this[Ts]&&!this[un]&&!this[ke]&&this[He].length===0&&this[jt]&&(this[Ts]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Ps]&&this.emit("close"),this[Ts]=!1)}emit(t,...e){let n=e[0];if(t!=="error"&&t!=="close"&&t!==ke&&this[ke])return!1;if(t==="data")return!this[Ye]&&!n?!1:this[Tt]?(hi(()=>this[Ja](n)),!0):this[Ja](n);if(t==="end")return this[Tu]();if(t==="close"){if(this[Ps]=!0,!this[un]&&!this[ke])return!1;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[li]=n,super.emit(Va,n);let o=!this[fi]||this.listeners("error").length?super.emit("error",n):!1;return this[Wt](),o}else if(t==="resume"){let o=super.emit("resume");return this[Wt](),o}else if(t==="finish"||t==="prefinish"){let o=super.emit(t);return this.removeAllListeners(t),o}let i=super.emit(t,...e);return this[Wt](),i}[Ja](t){for(let n of this[Qe])n.dest.write(t)===!1&&this.pause();let e=this[ot]?!1:super.emit("data",t);return this[Wt](),e}[Tu](){return this[un]?!1:(this[un]=!0,this.readable=!1,this[Tt]?(hi(()=>this[Za]()),!0):this[Za]())}[Za](){if(this[gr]){let e=this[gr].end();if(e){for(let n of this[Qe])n.dest.write(e);this[ot]||super.emit("data",e)}}for(let e of this[Qe])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[Ye]||(t.dataLength=0);let e=this.promise();return this.on("data",n=>{t.push(n),this[Ye]||(t.dataLength+=n.length)}),await e,t}async concat(){if(this[Ye])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[yt]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(ke,()=>e(new Error("stream destroyed"))),this.on("error",n=>e(n)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[ot]=!1;let t=!1,e=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return e();let n=this.read();if(n!==null)return Promise.resolve({done:!1,value:n});if(this[jt])return e();let i,o,c=x=>{this.off("data",d),this.off("end",u),this.off(ke,f),e(),o(x)},d=x=>{this.off("error",c),this.off("end",u),this.off(ke,f),this.pause(),i({value:x,done:!!this[jt]})},u=()=>{this.off("error",c),this.off("data",d),this.off(ke,f),e(),i({done:!0,value:void 0})},f=()=>c(new Error("stream destroyed"));return new Promise((x,m)=>{o=m,i=x,this.once(ke,f),this.once("error",c),this.once("end",u),this.once("data",d)})},throw:e,return:e,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[ot]=!1;let t=!1,e=()=>(this.pause(),this.off(Va,e),this.off(ke,e),this.off("end",e),t=!0,{done:!0,value:void 0}),n=()=>{if(t)return e();let i=this.read();return i===null?e():{done:!1,value:i}};return this.once("end",e),this.once(Va,e),this.once(ke,e),{next:n,throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[ke])return t?this.emit("error",t):this.emit(ke),this;this[ke]=!0,this[ot]=!0,this[He].length=0,this[qe]=0;let e=this;return typeof e.close=="function"&&!this[Ps]&&e.close(),t?this.emit("error",t):this.emit(ke),this}static get isStream(){return rw}},hw=it.writev,En=Symbol("_autoClose"),St=Symbol("_close"),xi=Symbol("_ended"),le=Symbol("_fd"),Xa=Symbol("_finished"),Jt=Symbol("_flags"),Qa=Symbol("_flush"),_c=Symbol("_handleChunk"),yc=Symbol("_makeBuf"),Ii=Symbol("_mode"),Os=Symbol("_needDrain"),Ar=Symbol("_onerror"),kr=Symbol("_onopen"),ec=Symbol("_onread"),br=Symbol("_onwrite"),bn=Symbol("_open"),vt=Symbol("_path"),gn=Symbol("_pos"),Pt=Symbol("_queue"),vr=Symbol("_read"),tc=Symbol("_readSize"),Vt=Symbol("_reading"),pi=Symbol("_remain"),nc=Symbol("_size"),qs=Symbol("_write"),Ln=Symbol("_writing"),js=Symbol("_defaultFlag"),Gn=Symbol("_errored"),Gc=class extends Wn{[Gn]=!1;[le];[vt];[tc];[Vt]=!1;[nc];[pi];[En];constructor(t,e){if(e=e||{},super(e),this.readable=!0,this.writable=!1,typeof t!="string")throw new TypeError("path must be a string");this[Gn]=!1,this[le]=typeof e.fd=="number"?e.fd:void 0,this[vt]=t,this[tc]=e.readSize||16*1024*1024,this[Vt]=!1,this[nc]=typeof e.size=="number"?e.size:1/0,this[pi]=this[nc],this[En]=typeof e.autoClose=="boolean"?e.autoClose:!0,typeof this[le]=="number"?this[vr]():this[bn]()}get fd(){return this[le]}get path(){return this[vt]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[bn](){it.open(this[vt],"r",(t,e)=>this[kr](t,e))}[kr](t,e){t?this[Ar](t):(this[le]=e,this.emit("open",e),this[vr]())}[yc](){return Buffer.allocUnsafe(Math.min(this[tc],this[pi]))}[vr](){if(!this[Vt]){this[Vt]=!0;let t=this[yc]();if(t.length===0)return process.nextTick(()=>this[ec](null,0,t));it.read(this[le],t,0,t.length,null,(e,n,i)=>this[ec](e,n,i))}}[ec](t,e,n){this[Vt]=!1,t?this[Ar](t):this[_c](e,n)&&this[vr]()}[St](){if(this[En]&&typeof this[le]=="number"){let t=this[le];this[le]=void 0,it.close(t,e=>e?this.emit("error",e):this.emit("close"))}}[Ar](t){this[Vt]=!0,this[St](),this.emit("error",t)}[_c](t,e){let n=!1;return this[pi]-=t,t>0&&(n=super.write(t<e.length?e.subarray(0,t):e)),(t===0||this[pi]<=0)&&(n=!1,this[St](),super.end()),n}emit(t,...e){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[le]=="number"&&this[vr](),!1;case"error":return this[Gn]?!1:(this[Gn]=!0,super.emit(t,...e));default:return super.emit(t,...e)}}},xw=class extends Gc{[bn](){let t=!0;try{this[kr](null,it.openSync(this[vt],"r")),t=!1}finally{t&&this[St]()}}[vr](){let t=!0;try{if(!this[Vt]){this[Vt]=!0;do{let e=this[yc](),n=e.length===0?0:it.readSync(this[le],e,0,e.length,null);if(!this[_c](n,e))break}while(!0);this[Vt]=!1}t=!1}finally{t&&this[St]()}}[St](){if(this[En]&&typeof this[le]=="number"){let t=this[le];this[le]=void 0,it.closeSync(t),this.emit("close")}}},so=class extends tw{readable=!1;writable=!0;[Gn]=!1;[Ln]=!1;[xi]=!1;[Pt]=[];[Os]=!1;[vt];[Ii];[En];[le];[js];[Jt];[Xa]=!1;[gn];constructor(t,e){e=e||{},super(e),this[vt]=t,this[le]=typeof e.fd=="number"?e.fd:void 0,this[Ii]=e.mode===void 0?438:e.mode,this[gn]=typeof e.start=="number"?e.start:void 0,this[En]=typeof e.autoClose=="boolean"?e.autoClose:!0;let n=this[gn]!==void 0?"r+":"w";this[js]=e.flags===void 0,this[Jt]=e.flags===void 0?n:e.flags,this[le]===void 0&&this[bn]()}emit(t,...e){if(t==="error"){if(this[Gn])return!1;this[Gn]=!0}return super.emit(t,...e)}get fd(){return this[le]}get path(){return this[vt]}[Ar](t){this[St](),this[Ln]=!0,this.emit("error",t)}[bn](){it.open(this[vt],this[Jt],this[Ii],(t,e)=>this[kr](t,e))}[kr](t,e){this[js]&&this[Jt]==="r+"&&t&&t.code==="ENOENT"?(this[Jt]="w",this[bn]()):t?this[Ar](t):(this[le]=e,this.emit("open",e),this[Ln]||this[Qa]())}end(t,e){return t&&this.write(t,e),this[xi]=!0,!this[Ln]&&!this[Pt].length&&typeof this[le]=="number"&&this[br](null,0),this}write(t,e){return typeof t=="string"&&(t=Buffer.from(t,e)),this[xi]?(this.emit("error",new Error("write() after end()")),!1):this[le]===void 0||this[Ln]||this[Pt].length?(this[Pt].push(t),this[Os]=!0,!1):(this[Ln]=!0,this[qs](t),!0)}[qs](t){it.write(this[le],t,0,t.length,this[gn],(e,n)=>this[br](e,n))}[br](t,e){t?this[Ar](t):(this[gn]!==void 0&&typeof e=="number"&&(this[gn]+=e),this[Pt].length?this[Qa]():(this[Ln]=!1,this[xi]&&!this[Xa]?(this[Xa]=!0,this[St](),this.emit("finish")):this[Os]&&(this[Os]=!1,this.emit("drain"))))}[Qa](){if(this[Pt].length===0)this[xi]&&this[br](null,0);else if(this[Pt].length===1)this[qs](this[Pt].pop());else{let t=this[Pt];this[Pt]=[],hw(this[le],t,this[gn],(e,n)=>this[br](e,n))}}[St](){if(this[En]&&typeof this[le]=="number"){let t=this[le];this[le]=void 0,it.close(t,e=>e?this.emit("error",e):this.emit("close"))}}},cf=class extends so{[bn](){let t;if(this[js]&&this[Jt]==="r+")try{t=it.openSync(this[vt],this[Jt],this[Ii])}catch(e){if(e?.code==="ENOENT")return this[Jt]="w",this[bn]();throw e}else t=it.openSync(this[vt],this[Jt],this[Ii]);this[kr](null,t)}[St](){if(this[En]&&typeof this[le]=="number"){let t=this[le];this[le]=void 0,it.closeSync(t),this.emit("close")}}[qs](t){let e=!0;try{this[br](null,it.writeSync(this[le],t,0,t.length,this[gn])),e=!1}finally{if(e)try{this[St]()}catch{}}}},mw=new Map([["C","cwd"],["f","file"],["z","gzip"],["P","preservePaths"],["U","unlink"],["strip-components","strip"],["stripComponents","strip"],["keep-newer","newer"],["keepNewer","newer"],["keep-newer-files","newer"],["keepNewerFiles","newer"],["k","keep"],["keep-existing","keep"],["keepExisting","keep"],["m","noMtime"],["no-mtime","noMtime"],["p","preserveOwner"],["L","follow"],["h","follow"],["onentry","onReadEntry"]]),ww=t=>!!t.sync&&!!t.file,_w=t=>!t.sync&&!!t.file,yw=t=>!!t.sync&&!t.file,Ew=t=>!t.sync&&!t.file,bw=t=>!!t.file,vw=t=>mw.get(t)||t,Hc=(t={})=>{if(!t)return{};let e={};for(let[n,i]of Object.entries(t)){let o=vw(n);e[o]=i}return e.chmod===void 0&&e.noChmod===!1&&(e.chmod=!0),delete e.noChmod,e},Li=(t,e,n,i,o)=>Object.assign((c=[],d,u)=>{Array.isArray(c)&&(d=c,c={}),typeof d=="function"&&(u=d,d=void 0),d=d?Array.from(d):[];let f=Hc(c);if(o?.(f,d),ww(f)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return t(f,d)}else if(_w(f)){let x=e(f,d);return u?x.then(()=>u(),u):x}else if(yw(f)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return n(f,d)}else if(Ew(f)){if(typeof u=="function")throw new TypeError("callback only supported with file option");return i(f,d)}throw new Error("impossible options??")},{syncFile:t,asyncFile:e,syncNoFile:n,asyncNoFile:i,validate:o}),Aw=Iw.constants||{ZLIB_VERNUM:4736},Ot=Object.freeze(Object.assign(Object.create(null),{Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_VERSION_ERROR:-6,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,DEFLATE:1,INFLATE:2,GZIP:3,GUNZIP:4,DEFLATERAW:5,INFLATERAW:6,UNZIP:7,BROTLI_DECODE:8,BROTLI_ENCODE:9,Z_MIN_WINDOWBITS:8,Z_MAX_WINDOWBITS:15,Z_DEFAULT_WINDOWBITS:15,Z_MIN_CHUNK:64,Z_MAX_CHUNK:1/0,Z_DEFAULT_CHUNK:16384,Z_MIN_MEMLEVEL:1,Z_MAX_MEMLEVEL:9,Z_DEFAULT_MEMLEVEL:8,Z_MIN_LEVEL:-1,Z_MAX_LEVEL:9,Z_DEFAULT_LEVEL:-1,BROTLI_OPERATION_PROCESS:0,BROTLI_OPERATION_FLUSH:1,BROTLI_OPERATION_FINISH:2,BROTLI_OPERATION_EMIT_METADATA:3,BROTLI_MODE_GENERIC:0,BROTLI_MODE_TEXT:1,BROTLI_MODE_FONT:2,BROTLI_DEFAULT_MODE:0,BROTLI_MIN_QUALITY:0,BROTLI_MAX_QUALITY:11,BROTLI_DEFAULT_QUALITY:11,BROTLI_MIN_WINDOW_BITS:10,BROTLI_MAX_WINDOW_BITS:24,BROTLI_LARGE_MAX_WINDOW_BITS:30,BROTLI_DEFAULT_WINDOW:22,BROTLI_MIN_INPUT_BLOCK_BITS:16,BROTLI_MAX_INPUT_BLOCK_BITS:24,BROTLI_PARAM_MODE:0,BROTLI_PARAM_QUALITY:1,BROTLI_PARAM_LGWIN:2,BROTLI_PARAM_LGBLOCK:3,BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING:4,BROTLI_PARAM_SIZE_HINT:5,BROTLI_PARAM_LARGE_WINDOW:6,BROTLI_PARAM_NPOSTFIX:7,BROTLI_PARAM_NDIRECT:8,BROTLI_DECODER_RESULT_ERROR:0,BROTLI_DECODER_RESULT_SUCCESS:1,BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT:2,BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION:0,BROTLI_DECODER_PARAM_LARGE_WINDOW:1,BROTLI_DECODER_NO_ERROR:0,BROTLI_DECODER_SUCCESS:1,BROTLI_DECODER_NEEDS_MORE_INPUT:2,BROTLI_DECODER_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE:-1,BROTLI_DECODER_ERROR_FORMAT_RESERVED:-2,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE:-3,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET:-4,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME:-5,BROTLI_DECODER_ERROR_FORMAT_CL_SPACE:-6,BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE:-7,BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT:-8,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1:-9,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2:-10,BROTLI_DECODER_ERROR_FORMAT_TRANSFORM:-11,BROTLI_DECODER_ERROR_FORMAT_DICTIONARY:-12,BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS:-13,BROTLI_DECODER_ERROR_FORMAT_PADDING_1:-14,BROTLI_DECODER_ERROR_FORMAT_PADDING_2:-15,BROTLI_DECODER_ERROR_FORMAT_DISTANCE:-16,BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET:-19,BROTLI_DECODER_ERROR_INVALID_ARGUMENTS:-20,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES:-21,BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS:-22,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP:-25,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1:-26,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2:-27,BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES:-30,BROTLI_DECODER_ERROR_UNREACHABLE:-31},Aw)),kw=Hn.concat,Ru=Object.getOwnPropertyDescriptor(Hn,"concat"),Tw=t=>t,rc=Ru?.writable===!0||Ru?.set!==void 0?t=>{Hn.concat=t?Tw:kw}:t=>{},qn=Symbol("_superWrite"),Ls=class extends Error{code;errno;constructor(t,e){super("zlib: "+t.message,{cause:t}),this.code=t.code,this.errno=t.errno,this.code||(this.code="ZLIB_ERROR"),this.message="zlib: "+t.message,Error.captureStackTrace(this,e??this.constructor)}get name(){return"ZlibError"}},ic=Symbol("flushFlag"),qc=class extends Wn{#e=!1;#n=!1;#r;#s;#i;#t;#o;get sawError(){return this.#e}get handle(){return this.#t}get flushFlag(){return this.#r}constructor(t,e){if(!t||typeof t!="object")throw new TypeError("invalid options for ZlibBase constructor");if(super(t),this.#r=t.flush??0,this.#s=t.finishFlush??0,this.#i=t.fullFlushFlag??0,typeof Pu[e]!="function")throw new TypeError("Compression method not supported: "+e);try{this.#t=new Pu[e](t)}catch(n){throw new Ls(n,this.constructor)}this.#o=n=>{this.#e||(this.#e=!0,this.close(),this.emit("error",n))},this.#t?.on("error",n=>this.#o(new Ls(n))),this.once("end",()=>this.close)}close(){this.#t&&(this.#t.close(),this.#t=void 0,this.emit("close"))}reset(){if(!this.#e)return Ec(this.#t,"zlib binding closed"),this.#t.reset?.()}flush(t){this.ended||(typeof t!="number"&&(t=this.#i),this.write(Object.assign(Hn.alloc(0),{[ic]:t})))}end(t,e,n){return typeof t=="function"&&(n=t,e=void 0,t=void 0),typeof e=="function"&&(n=e,e=void 0),t&&(e?this.write(t,e):this.write(t)),this.flush(this.#s),this.#n=!0,super.end(n)}get ended(){return this.#n}[qn](t){return super.write(t)}write(t,e,n){if(typeof e=="function"&&(n=e,e="utf8"),typeof t=="string"&&(t=Hn.from(t,e)),this.#e)return;Ec(this.#t,"zlib binding closed");let i=this.#t._handle,o=i.close;i.close=()=>{};let c=this.#t.close;this.#t.close=()=>{},rc(!0);let d;try{let f=typeof t[ic]=="number"?t[ic]:this.#r;d=this.#t._processChunk(t,f),rc(!1)}catch(f){rc(!1),this.#o(new Ls(f,this.write))}finally{this.#t&&(this.#t._handle=i,i.close=o,this.#t.close=c,this.#t.removeAllListeners("error"))}this.#t&&this.#t.on("error",f=>this.#o(new Ls(f,this.write)));let u;if(d)if(Array.isArray(d)&&d.length>0){let f=d[0];u=this[qn](Hn.from(f));for(let x=1;x<d.length;x++)u=this[qn](d[x])}else u=this[qn](Hn.from(d));return n&&n(),u}},lf=class extends qc{#e;#n;constructor(t,e){t=t||{},t.flush=t.flush||Ot.Z_NO_FLUSH,t.finishFlush=t.finishFlush||Ot.Z_FINISH,t.fullFlushFlag=Ot.Z_FULL_FLUSH,super(t,e),this.#e=t.level,this.#n=t.strategy}params(t,e){if(!this.sawError){if(!this.handle)throw new Error("cannot switch params when binding is closed");if(!this.handle.params)throw new Error("not supported in this implementation");if(this.#e!==t||this.#n!==e){this.flush(Ot.Z_SYNC_FLUSH),Ec(this.handle,"zlib binding closed");let n=this.handle.flush;this.handle.flush=(i,o)=>{typeof i=="function"&&(o=i,i=this.flushFlag),this.flush(i),o?.()};try{this.handle.params(t,e)}finally{this.handle.flush=n}this.handle&&(this.#e=t,this.#n=e)}}}},Pw=class extends lf{#e;constructor(t){super(t,"Gzip"),this.#e=t&&!!t.portable}[qn](t){return this.#e?(this.#e=!1,t[9]=255,super[qn](t)):super[qn](t)}},Rw=class extends lf{constructor(t){super(t,"Unzip")}},uf=class extends qc{constructor(t,e){t=t||{},t.flush=t.flush||Ot.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||Ot.BROTLI_OPERATION_FINISH,t.fullFlushFlag=Ot.BROTLI_OPERATION_FLUSH,super(t,e)}},Cw=class extends uf{constructor(t){super(t,"BrotliCompress")}},Dw=class extends uf{constructor(t){super(t,"BrotliDecompress")}},ff=class extends qc{constructor(t,e){t=t||{},t.flush=t.flush||Ot.ZSTD_e_continue,t.finishFlush=t.finishFlush||Ot.ZSTD_e_end,t.fullFlushFlag=Ot.ZSTD_e_flush,super(t,e)}},Ow=class extends ff{constructor(t){super(t,"ZstdCompress")}},Lw=class extends ff{constructor(t){super(t,"ZstdDecompress")}},Nw=(t,e)=>{if(Number.isSafeInteger(t))t<0?Bw(t,e):Mw(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},Mw=(t,e)=>{e[0]=128;for(var n=e.length;n>1;n--)e[n-1]=t&255,t=Math.floor(t/256)},Bw=(t,e)=>{e[0]=255;var n=!1;t=t*-1;for(var i=e.length;i>1;i--){var o=t&255;t=Math.floor(t/256),n?e[i-1]=hf(o):o===0?e[i-1]=0:(n=!0,e[i-1]=xf(o))}},Fw=t=>{let e=t[0],n=e===128?Uw(t.subarray(1,t.length)):e===255?zw(t):null;if(n===null)throw Error("invalid base256 encoding");if(!Number.isSafeInteger(n))throw Error("parsed number outside of javascript safe integer range");return n},zw=t=>{for(var e=t.length,n=0,i=!1,o=e-1;o>-1;o--){var c=Number(t[o]),d;i?d=hf(c):c===0?d=c:(i=!0,d=xf(c)),d!==0&&(n-=d*Math.pow(256,e-o-1))}return n},Uw=t=>{for(var e=t.length,n=0,i=e-1;i>-1;i--){var o=Number(t[i]);o!==0&&(n+=o*Math.pow(256,e-i-1))}return n},hf=t=>(255^t)&255,xf=t=>(255^t)+1&255,Gw={};ew(Gw,{code:()=>jc,isCode:()=>Ws,isName:()=>Hw,name:()=>oo,normalFsTypes:()=>pf});var Ws=t=>oo.has(t),Hw=t=>jc.has(t),pf=new Set(["0","","1","2","3","4","5","6","7","D"]),oo=new Map([["0","File"],["","OldFile"],["1","Link"],["2","SymbolicLink"],["3","CharacterDevice"],["4","BlockDevice"],["5","Directory"],["6","FIFO"],["7","ContiguousFile"],["g","GlobalExtendedHeader"],["x","ExtendedHeader"],["A","SolarisACL"],["D","GNUDumpDir"],["I","Inode"],["K","NextFileHasLongLinkpath"],["L","NextFileHasLongPath"],["M","ContinuationFile"],["N","OldGnuLongPath"],["S","SparseFile"],["V","TapeVolumeHeader"],["X","OldExtendedHeader"]]),jc=new Map(Array.from(oo).map(t=>[t[1],t[0]])),jn=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#e="Unsupported";linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(t,e=0,n,i){Buffer.isBuffer(t)?this.decode(t,e||0,n,i):t&&this.#n(t)}decode(t,e,n,i){if(e||(e=0),!t||!(t.length>=e+512))throw new Error("need 512 bytes for header");let o=Nn(t,e+156,1),c=pf.has(o),d=c?n:void 0,u=c?i:void 0;if(this.path=d?.path??Nn(t,e,100),this.mode=d?.mode??u?.mode??mn(t,e+100,8),this.uid=d?.uid??u?.uid??mn(t,e+108,8),this.gid=d?.gid??u?.gid??mn(t,e+116,8),this.size=d?.size??u?.size??mn(t,e+124,12),this.mtime=d?.mtime??u?.mtime??sc(t,e+136,12),this.cksum=mn(t,e+148,12),u&&this.#n(u,!0),d&&this.#n(d),Ws(o)&&(this.#e=o||"0"),this.#e==="0"&&this.path.slice(-1)==="/"&&(this.#e="5"),this.#e==="5"&&(this.size=0),this.linkpath=Nn(t,e+157,100),t.subarray(e+257,e+265).toString()==="ustar\x0000")if(this.uname=d?.uname??u?.uname??Nn(t,e+265,32),this.gname=d?.gname??u?.gname??Nn(t,e+297,32),this.devmaj=d?.devmaj??u?.devmaj??mn(t,e+329,8)??0,this.devmin=d?.devmin??u?.devmin??mn(t,e+337,8)??0,t[e+475]!==0){let x=Nn(t,e+345,155);this.path=x+"/"+this.path}else{let x=Nn(t,e+345,130);x&&(this.path=x+"/"+this.path),this.atime=n?.atime??i?.atime??sc(t,e+476,12),this.ctime=n?.ctime??i?.ctime??sc(t,e+488,12)}let f=256;for(let x=e;x<e+148;x++)f+=t[x];for(let x=e+156;x<e+512;x++)f+=t[x];this.cksumValid=f===this.cksum,this.cksum===void 0&&f===256&&(this.nullBlock=!0)}#n(t,e=!1){Object.assign(this,Object.fromEntries(Object.entries(t).filter(([n,i])=>!(i==null||n==="path"&&e||n==="linkpath"&&e||n==="global"))))}encode(t,e=0){if(t||(t=this.block=Buffer.alloc(512)),this.#e==="Unsupported"&&(this.#e="0"),!(t.length>=e+512))throw new Error("need 512 bytes for header");let n=this.ctime||this.atime?130:155,i=qw(this.path||"",n),o=i[0],c=i[1];this.needPax=!!i[2],this.needPax=Mn(t,e,100,o)||this.needPax,this.needPax=wn(t,e+100,8,this.mode)||this.needPax,this.needPax=wn(t,e+108,8,this.uid)||this.needPax,this.needPax=wn(t,e+116,8,this.gid)||this.needPax,this.needPax=wn(t,e+124,12,this.size)||this.needPax,this.needPax=oc(t,e+136,12,this.mtime)||this.needPax,t[e+156]=Number(this.#e.codePointAt(0)),this.needPax=Mn(t,e+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",e+257,8),this.needPax=Mn(t,e+265,32,this.uname)||this.needPax,this.needPax=Mn(t,e+297,32,this.gname)||this.needPax,this.needPax=wn(t,e+329,8,this.devmaj)||this.needPax,this.needPax=wn(t,e+337,8,this.devmin)||this.needPax,this.needPax=Mn(t,e+345,n,c)||this.needPax,t[e+475]!==0?this.needPax=Mn(t,e+345,155,c)||this.needPax:(this.needPax=Mn(t,e+345,130,c)||this.needPax,this.needPax=oc(t,e+476,12,this.atime)||this.needPax,this.needPax=oc(t,e+488,12,this.ctime)||this.needPax);let d=256;for(let u=e;u<e+148;u++)d+=t[u];for(let u=e+156;u<e+512;u++)d+=t[u];return this.cksum=d,wn(t,e+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#e==="Unsupported"?this.#e:oo.get(this.#e)}get typeKey(){return this.#e}set type(t){let e=String(jc.get(t));if(Ws(e)||e==="Unsupported")this.#e=e;else if(Ws(t))this.#e=t;else throw new TypeError("invalid entry type: "+t)}},qw=(t,e)=>{let n=t,i="",o,c=mr.parse(t).root||".";if(Buffer.byteLength(n)<100)o=[n,i,!1];else{i=mr.dirname(n),n=mr.basename(n);do Buffer.byteLength(n)<=100&&Buffer.byteLength(i)<=e?o=[n,i,!1]:Buffer.byteLength(n)>100&&Buffer.byteLength(i)<=e?o=[n.slice(0,99),i,!0]:(n=mr.join(mr.basename(i),n),i=mr.dirname(i));while(i!==c&&o===void 0);o||(o=[t.slice(0,99),"",!0])}return o},Nn=(t,e,n)=>t.subarray(e,e+n).toString("utf8").replace(/\0.*/,""),sc=(t,e,n)=>jw(mn(t,e,n)),jw=t=>t===void 0?void 0:new Date(t*1e3),mn=(t,e,n)=>Number(t[e])&128?Fw(t.subarray(e,e+n)):Kw(t,e,n),Ww=t=>isNaN(t)?void 0:t,Kw=(t,e,n)=>Ww(parseInt(t.subarray(e,e+n).toString("utf8").replace(/\0.*$/,"").trim(),8)),$w={12:8589934591,8:2097151},wn=(t,e,n,i)=>i===void 0?!1:i>$w[n]||i<0?(Nw(i,t.subarray(e,e+n)),!0):(Vw(t,e,n,i),!1),Vw=(t,e,n,i)=>t.write(Jw(i,n),e,n,"ascii"),Jw=(t,e)=>Zw(Math.floor(t).toString(8),e),Zw=(t,e)=>(t.length===e-1?t:new Array(e-t.length-1).join("0")+t+" ")+"\0",oc=(t,e,n,i)=>i===void 0?!1:wn(t,e,n,i.getTime()/1e3),Yw=new Array(156).join("\0"),Mn=(t,e,n,i)=>i===void 0?!1:(t.write(i+Yw,e,n,"utf8"),i.length!==Buffer.byteLength(i)||i.length>n),eo=class gf{atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor(e,n=!1){this.atime=e.atime,this.charset=e.charset,this.comment=e.comment,this.ctime=e.ctime,this.dev=e.dev,this.gid=e.gid,this.global=n,this.gname=e.gname,this.ino=e.ino,this.linkpath=e.linkpath,this.mtime=e.mtime,this.nlink=e.nlink,this.path=e.path,this.size=e.size,this.uid=e.uid,this.uname=e.uname}encode(){let e=this.encodeBody();if(e==="")return Buffer.allocUnsafe(0);let n=Buffer.byteLength(e),i=512*Math.ceil(1+n/512),o=Buffer.allocUnsafe(i);for(let c=0;c<512;c++)o[c]=0;new jn({path:("PaxHeader/"+Xw(this.path??"")).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:n,mtime:this.mtime,type:this.global?"GlobalExtendedHeader":"ExtendedHeader",linkpath:"",uname:this.uname||"",gname:this.gname||"",devmaj:0,devmin:0,atime:this.atime,ctime:this.ctime}).encode(o),o.write(e,512,n,"utf8");for(let c=n+512;c<o.length;c++)o[c]=0;return o}encodeBody(){return this.encodeField("path")+this.encodeField("ctime")+this.encodeField("atime")+this.encodeField("dev")+this.encodeField("ino")+this.encodeField("nlink")+this.encodeField("charset")+this.encodeField("comment")+this.encodeField("gid")+this.encodeField("gname")+this.encodeField("linkpath")+this.encodeField("mtime")+this.encodeField("size")+this.encodeField("uid")+this.encodeField("uname")}encodeField(e){if(this[e]===void 0)return"";let n=this[e],i=n instanceof Date?n.getTime()/1e3:n,o=" "+(e==="dev"||e==="ino"||e==="nlink"?"SCHILY.":"")+e+"="+i+`
|
|
90
|
+
`,c=Buffer.byteLength(o),d=Math.floor(Math.log(c)/Math.log(10))+1;return c+d>=Math.pow(10,d)&&(d+=1),d+c+o}static parse(e,n,i=!1){return new gf(Qw(e_(e),n),i)}},Qw=(t,e)=>e?Object.assign({},e,t):t,e_=t=>t.replace(/\n$/,"").split(`
|
|
91
|
+
`).reduce(t_,Object.create(null)),t_=(t,e)=>{let n=parseInt(e,10);if(n!==Buffer.byteLength(e)+1)return t;e=e.slice((n+" ").length);let i=e.split("="),o=i.shift();if(!o)return t;let c=o.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),d=i.join("=");return t[c]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(c)?new Date(Number(d)*1e3):/^[0-9]+$/.test(d)?+d:d,t},n_=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,ee=n_!=="win32"?t=>t:t=>t&&t.replaceAll(/\\/g,"/"),r_=class extends Wn{extended;globalExtended;header;startBlockSize;blockRemain;remain;type;meta=!1;ignore=!1;path;mode;uid;gid;uname;gname;size=0;mtime;atime;ctime;linkpath;dev;ino;nlink;invalid=!1;absolute;unsupported=!1;constructor(t,e,n){switch(super({}),this.pause(),this.extended=e,this.globalExtended=n,this.header=t,this.remain=t.size??0,this.startBlockSize=512*Math.ceil(this.remain/512),this.blockRemain=this.startBlockSize,this.type=t.type,this.type){case"File":case"OldFile":case"Link":case"SymbolicLink":case"CharacterDevice":case"BlockDevice":case"Directory":case"FIFO":case"ContiguousFile":case"GNUDumpDir":break;case"NextFileHasLongLinkpath":case"NextFileHasLongPath":case"OldGnuLongPath":case"GlobalExtendedHeader":case"ExtendedHeader":case"OldExtendedHeader":this.meta=!0;break;default:this.ignore=!0}if(!t.path)throw new Error("no path provided for tar.ReadEntry");this.path=ee(t.path),this.mode=t.mode,this.mode&&(this.mode=this.mode&4095),this.uid=t.uid,this.gid=t.gid,this.uname=t.uname,this.gname=t.gname,this.size=this.remain,this.mtime=t.mtime,this.atime=t.atime,this.ctime=t.ctime,this.linkpath=t.linkpath?ee(t.linkpath):void 0,this.uname=t.uname,this.gname=t.gname,e&&this.#e(e),n&&this.#e(n,!0)}write(t){let e=t.length;if(e>this.blockRemain)throw new Error("writing more to entry than is appropriate");let n=this.remain,i=this.blockRemain;return this.remain=Math.max(0,n-e),this.blockRemain=Math.max(0,i-e),this.ignore?!0:n>=e?super.write(t):super.write(t.subarray(0,n))}#e(t,e=!1){t.path&&(t.path=ee(t.path)),t.linkpath&&(t.linkpath=ee(t.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(t).filter(([n,i])=>!(i==null||n==="path"&&e))))}},ao=(t,e,n,i={})=>{t.file&&(i.file=t.file),t.cwd&&(i.cwd=t.cwd),i.code=n instanceof Error&&n.code||e,i.tarCode=e,!t.strict&&i.recoverable!==!1?(n instanceof Error&&(i=Object.assign(n,i),n=n.message),t.emit("warn",e,n,i)):n instanceof Error?t.emit("error",Object.assign(n,i)):t.emit("error",Object.assign(new Error(`${e}: ${n}`),i))},i_=1024*1024,bc=Buffer.from([31,139]),vc=Buffer.from([40,181,47,253]),s_=Math.max(bc.length,vc.length),ft=Symbol("state"),Bn=Symbol("writeEntry"),Kt=Symbol("readEntry"),ac=Symbol("nextEntry"),Cu=Symbol("processEntry"),Rt=Symbol("extendedHeader"),gi=Symbol("globalExtendedHeader"),fn=Symbol("meta"),Du=Symbol("emitMeta"),we=Symbol("buffer"),$t=Symbol("queue"),hn=Symbol("ended"),cc=Symbol("emittedEnd"),Fn=Symbol("emit"),Ce=Symbol("unzip"),Ns=Symbol("consumeChunk"),Ms=Symbol("consumeChunkSub"),dc=Symbol("consumeBody"),Ou=Symbol("consumeMeta"),Lu=Symbol("consumeHeader"),mi=Symbol("consuming"),lc=Symbol("bufferConcat"),Bs=Symbol("maybeEnd"),wr=Symbol("writing"),xn=Symbol("aborted"),Fs=Symbol("onDone"),zn=Symbol("sawValidEntry"),zs=Symbol("sawNullBlock"),Us=Symbol("sawEOF"),Nu=Symbol("closeStream"),o_=()=>!0,Oi=class extends Sw{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[$t]=[];[we];[Kt];[Bn];[ft]="begin";[fn]="";[Rt];[gi];[hn]=!1;[Ce];[xn]=!1;[zn];[zs]=!1;[Us]=!1;[wr]=!1;[mi]=!1;[cc]=!1;constructor(t={}){super(),this.file=t.file||"",this.on(Fs,()=>{(this[ft]==="begin"||this[zn]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),t.ondone?this.on(Fs,t.ondone):this.on(Fs,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!t.strict,this.maxMetaEntrySize=t.maxMetaEntrySize||i_,this.filter=typeof t.filter=="function"?t.filter:o_;let e=t.file&&(t.file.endsWith(".tar.br")||t.file.endsWith(".tbr"));this.brotli=!(t.gzip||t.zstd)&&t.brotli!==void 0?t.brotli:e?void 0:!1;let n=t.file&&(t.file.endsWith(".tar.zst")||t.file.endsWith(".tzst"));this.zstd=!(t.gzip||t.brotli)&&t.zstd!==void 0?t.zstd:n?!0:void 0,this.on("end",()=>this[Nu]()),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,e,n={}){ao(this,t,e,n)}[Lu](t,e){this[zn]===void 0&&(this[zn]=!1);let n;try{n=new jn(t,e,this[Rt],this[gi])}catch(i){return this.warn("TAR_ENTRY_INVALID",i)}if(n.nullBlock)this[zs]?(this[Us]=!0,this[ft]==="begin"&&(this[ft]="header"),this[Fn]("eof")):(this[zs]=!0,this[Fn]("nullBlock"));else if(this[zs]=!1,!n.cksumValid)this.warn("TAR_ENTRY_INVALID","checksum failure",{header:n});else if(!n.path)this.warn("TAR_ENTRY_INVALID","path is required",{header:n});else{let i=n.type;if(/^(Symbolic)?Link$/.test(i)&&!n.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath required",{header:n});else if(!/^(Symbolic)?Link$/.test(i)&&!/^(Global)?ExtendedHeader$/.test(i)&&n.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath forbidden",{header:n});else{let o=this[Bn]=new r_(n,this[Rt],this[gi]);if(!this[zn])if(o.remain){let c=()=>{o.invalid||(this[zn]=!0)};o.on("end",c)}else this[zn]=!0;o.meta?o.size>this.maxMetaEntrySize?(o.ignore=!0,this[Fn]("ignoredEntry",o),this[ft]="ignore",o.resume()):o.size>0&&(this[fn]="",o.on("data",c=>this[fn]+=c),this[ft]="meta"):(this[Rt]=void 0,o.ignore=o.ignore||!this.filter(o.path,o),o.ignore?(this[Fn]("ignoredEntry",o),this[ft]=o.remain?"ignore":"header",o.resume()):(o.remain?this[ft]="body":(this[ft]="header",o.end()),this[Kt]?this[$t].push(o):(this[$t].push(o),this[ac]())))}}}[Nu](){queueMicrotask(()=>this.emit("close"))}[Cu](t){let e=!0;if(!t)this[Kt]=void 0,e=!1;else if(Array.isArray(t)){let[n,...i]=t;this.emit(n,...i)}else this[Kt]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",()=>this[ac]()),e=!1);return e}[ac](){do;while(this[Cu](this[$t].shift()));if(this[$t].length===0){let t=this[Kt];!t||t.flowing||t.size===t.remain?this[wr]||this.emit("drain"):t.once("drain",()=>this.emit("drain"))}}[dc](t,e){let n=this[Bn];if(!n)throw new Error("attempt to consume body without entry??");let i=n.blockRemain??0,o=i>=t.length&&e===0?t:t.subarray(e,e+i);return n.write(o),n.blockRemain||(this[ft]="header",this[Bn]=void 0,n.end()),o.length}[Ou](t,e){let n=this[Bn],i=this[dc](t,e);return!this[Bn]&&n&&this[Du](n),i}[Fn](t,e,n){this[$t].length===0&&!this[Kt]?this.emit(t,e,n):this[$t].push([t,e,n])}[Du](t){switch(this[Fn]("meta",this[fn]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[Rt]=eo.parse(this[fn],this[Rt],!1);break;case"GlobalExtendedHeader":this[gi]=eo.parse(this[fn],this[gi],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let e=this[Rt]??Object.create(null);this[Rt]=e,e.path=this[fn].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let e=this[Rt]||Object.create(null);this[Rt]=e,e.linkpath=this[fn].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){this[xn]=!0,this.emit("abort",t),this.warn("TAR_ABORT",t,{recoverable:!1})}write(t,e,n){if(typeof e=="function"&&(n=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8")),this[xn])return n?.(),!1;if((this[Ce]===void 0||this.brotli===void 0&&this[Ce]===!1)&&t){if(this[we]&&(t=Buffer.concat([this[we],t]),this[we]=void 0),t.length<s_)return this[we]=t,n?.(),!0;for(let d=0;this[Ce]===void 0&&d<bc.length;d++)t[d]!==bc[d]&&(this[Ce]=!1);let o=!1;if(this[Ce]===!1&&this.zstd!==!1){o=!0;for(let d=0;d<vc.length;d++)if(t[d]!==vc[d]){o=!1;break}}let c=this.brotli===void 0&&!o;if(this[Ce]===!1&&c)if(t.length<512)if(this[hn])this.brotli=!0;else return this[we]=t,n?.(),!0;else try{new jn(t.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[Ce]===void 0||this[Ce]===!1&&(this.brotli||o)){let d=this[hn];this[hn]=!1,this[Ce]=this[Ce]===void 0?new Rw({}):o?new Lw({}):new Dw({}),this[Ce].on("data",f=>this[Ns](f)),this[Ce].on("error",f=>this.abort(f)),this[Ce].on("end",()=>{this[hn]=!0,this[Ns]()}),this[wr]=!0;let u=!!this[Ce][d?"end":"write"](t);return this[wr]=!1,n?.(),u}}this[wr]=!0,this[Ce]?this[Ce].write(t):this[Ns](t),this[wr]=!1;let i=this[$t].length>0?!1:this[Kt]?this[Kt].flowing:!0;return!i&&this[$t].length===0&&this[Kt]?.once("drain",()=>this.emit("drain")),n?.(),i}[lc](t){t&&!this[xn]&&(this[we]=this[we]?Buffer.concat([this[we],t]):t)}[Bs](){if(this[hn]&&!this[cc]&&!this[xn]&&!this[mi]){this[cc]=!0;let t=this[Bn];if(t&&t.blockRemain){let e=this[we]?this[we].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`,{entry:t}),this[we]&&t.write(this[we]),t.end()}this[Fn](Fs)}}[Ns](t){if(this[mi]&&t)this[lc](t);else if(!t&&!this[we])this[Bs]();else if(t){if(this[mi]=!0,this[we]){this[lc](t);let e=this[we];this[we]=void 0,this[Ms](e)}else this[Ms](t);for(;this[we]&&this[we]?.length>=512&&!this[xn]&&!this[Us];){let e=this[we];this[we]=void 0,this[Ms](e)}this[mi]=!1}(!this[we]||this[hn])&&this[Bs]()}[Ms](t){let e=0,n=t.length;for(;e+512<=n&&!this[xn]&&!this[Us];)switch(this[ft]){case"begin":case"header":this[Lu](t,e),e+=512;break;case"ignore":case"body":e+=this[dc](t,e);break;case"meta":e+=this[Ou](t,e);break;default:throw new Error("invalid state: "+this[ft])}e<n&&(this[we]=this[we]?Buffer.concat([t.subarray(e),this[we]]):t.subarray(e))}end(t,e,n){return typeof t=="function"&&(n=t,e=void 0,t=void 0),typeof e=="function"&&(n=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,e)),n&&this.once("finish",n),this[xn]||(this[Ce]?(t&&this[Ce].write(t),this[Ce].end()):(this[hn]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t=t||Buffer.alloc(0)),t&&this.write(t),this[Bs]())),this}},Ai=t=>{let e=t.length-1,n=-1;for(;e>-1&&t.charAt(e)==="/";)n=e,e--;return n===-1?t:t.slice(0,n)},a_=t=>{let e=t.onReadEntry;t.onReadEntry=e?n=>{e(n),n.resume()}:n=>n.resume()},mf=(t,e)=>{let n=new Map(e.map(c=>[Ai(c),!0])),i=t.filter,o=(c,d="")=>{let u=d||gw(c).root||".",f;if(c===u)f=!1;else{let x=n.get(c);f=x!==void 0?x:o(pw(c),u)}return n.set(c,f),f};t.filter=i?(c,d)=>i(c,d)&&o(Ai(c)):c=>o(Ai(c))},c_=t=>{let e=new Oi(t),n=t.file,i;try{i=Sr.openSync(n,"r");let o=Sr.fstatSync(i),c=t.maxReadSize||16*1024*1024;if(o.size<c){let d=Buffer.allocUnsafe(o.size),u=Sr.readSync(i,d,0,o.size,0);e.end(u===d.byteLength?d:d.subarray(0,u))}else{let d=0,u=Buffer.allocUnsafe(c);for(;d<o.size;){let f=Sr.readSync(i,u,0,c,d);if(f===0)break;d+=f,e.write(u.subarray(0,f))}e.end()}}finally{if(typeof i=="number")try{Sr.closeSync(i)}catch{}}},d_=(t,e)=>{let n=new Oi(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,d)=>{n.on("error",d),n.on("end",c),Sr.stat(o,(u,f)=>{if(u)d(u);else{let x=new Gc(o,{readSize:i,size:f.size});x.on("error",d),x.pipe(n)}})})},Tr=Li(c_,d_,t=>new Oi(t),t=>new Oi(t),(t,e)=>{e?.length&&mf(t,e),t.noResume||a_(t)}),wf=(t,e,n)=>(t&=4095,n&&(t=(t|384)&-19),e&&(t&256&&(t|=64),t&32&&(t|=8),t&4&&(t|=1)),t),{isAbsolute:u_,parse:Bu}=l_,Wc=t=>{let e="",n=Bu(t);for(;u_(t)||n.root;){let i=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":n.root;t=t.slice(i.length),e+=i,n=Bu(t)}return[e,t]},co=["|","<",">","?",":"],Kc=co.map(t=>String.fromCodePoint(61440+Number(t.codePointAt(0)))),f_=new Map(co.map((t,e)=>[t,Kc[e]])),h_=new Map(Kc.map((t,e)=>[t,co[e]])),Fu=t=>co.reduce((e,n)=>e.split(n).join(f_.get(n)),t),x_=t=>Kc.reduce((e,n)=>e.split(n).join(h_.get(n)),t),_f=(t,e)=>e?(t=ee(t).replace(/^\.(\/|$)/,""),Ai(e)+"/"+t):ee(t),p_=16*1024*1024,zu=Symbol("process"),Uu=Symbol("file"),Gu=Symbol("directory"),Sc=Symbol("symlink"),Hu=Symbol("hardlink"),wi=Symbol("header"),Ks=Symbol("read"),Ic=Symbol("lstat"),$s=Symbol("onlstat"),Ac=Symbol("onread"),kc=Symbol("onreadlink"),Tc=Symbol("openfile"),Pc=Symbol("onopenfile"),_n=Symbol("close"),no=Symbol("mode"),Rc=Symbol("awaitDrain"),uc=Symbol("ondrain"),Dt=Symbol("prefix"),yf=class extends Wn{path;portable;myuid=process.getuid&&process.getuid()||0;myuser=process.env.USER||"";maxReadSize;linkCache;statCache;preservePaths;cwd;strict;mtime;noPax;noMtime;prefix;fd;blockLen=0;blockRemain=0;buf;pos=0;remain=0;length=0;offset=0;win32;absolute;header;type;linkpath;stat;onWriteEntry;#e=!1;constructor(t,e={}){let n=Hc(e);super(),this.path=ee(t),this.portable=!!n.portable,this.maxReadSize=n.maxReadSize||p_,this.linkCache=n.linkCache||new Map,this.statCache=n.statCache||new Map,this.preservePaths=!!n.preservePaths,this.cwd=ee(n.cwd||process.cwd()),this.strict=!!n.strict,this.noPax=!!n.noPax,this.noMtime=!!n.noMtime,this.mtime=n.mtime,this.prefix=n.prefix?ee(n.prefix):void 0,this.onWriteEntry=n.onWriteEntry,typeof n.onwarn=="function"&&this.on("warn",n.onwarn);let i=!1;if(!this.preservePaths){let[c,d]=Wc(this.path);c&&typeof d=="string"&&(this.path=d,i=c)}this.win32=!!n.win32||process.platform==="win32",this.win32&&(this.path=x_(this.path.replaceAll(/\\/g,"/")),t=t.replaceAll(/\\/g,"/")),this.absolute=ee(n.absolute||Mu.resolve(this.cwd,t)),this.path===""&&(this.path="./"),i&&this.warn("TAR_ENTRY_INFO",`stripping ${i} from absolute path`,{entry:this,path:i+this.path});let o=this.statCache.get(this.absolute);o?this[$s](o):this[Ic]()}warn(t,e,n={}){return ao(this,t,e,n)}emit(t,...e){return t==="error"&&(this.#e=!0),super.emit(t,...e)}[Ic](){Ct.lstat(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[$s](e)})}[$s](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=w_(t),this.emit("stat",t),this[zu]()}[zu](){switch(this.type){case"File":return this[Uu]();case"Directory":return this[Gu]();case"SymbolicLink":return this[Sc]();default:return this.end()}}[no](t){return wf(t,this.type==="Directory",this.portable)}[Dt](t){return _f(t,this.prefix)}[wi](){if(!this.stat)throw new Error("cannot write header before stat");this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.onWriteEntry?.(this),this.header=new jn({path:this[Dt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Dt](this.linkpath):this.linkpath,mode:this[no](this.stat.mode),uid:this.portable?void 0:this.stat.uid,gid:this.portable?void 0:this.stat.gid,size:this.stat.size,mtime:this.noMtime?void 0:this.mtime||this.stat.mtime,type:this.type==="Unsupported"?void 0:this.type,uname:this.portable?void 0:this.stat.uid===this.myuid?this.myuser:"",atime:this.portable?void 0:this.stat.atime,ctime:this.portable?void 0:this.stat.ctime}),this.header.encode()&&!this.noPax&&super.write(new eo({atime:this.portable?void 0:this.header.atime,ctime:this.portable?void 0:this.header.ctime,gid:this.portable?void 0:this.header.gid,mtime:this.noMtime?void 0:this.mtime||this.header.mtime,path:this[Dt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Dt](this.linkpath):this.linkpath,size:this.header.size,uid:this.portable?void 0:this.header.uid,uname:this.portable?void 0:this.header.uname,dev:this.portable?void 0:this.stat.dev,ino:this.portable?void 0:this.stat.ino,nlink:this.portable?void 0:this.stat.nlink}).encode());let t=this.header?.block;if(!t)throw new Error("failed to encode header");super.write(t)}[Gu](){if(!this.stat)throw new Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[wi](),this.end()}[Sc](){Ct.readlink(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[kc](e)})}[kc](t){this.linkpath=ee(t),this[wi](),this.end()}[Hu](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=ee(Mu.relative(this.cwd,t)),this.stat.size=0,this[wi](),this.end()}[Uu](){if(!this.stat)throw new Error("cannot create file entry without stat");if(this.stat.nlink>1){let t=`${this.stat.dev}:${this.stat.ino}`,e=this.linkCache.get(t);if(e?.indexOf(this.cwd)===0)return this[Hu](e);this.linkCache.set(t,this.absolute)}if(this[wi](),this.stat.size===0)return this.end();this[Tc]()}[Tc](){Ct.open(this.absolute,"r",(t,e)=>{if(t)return this.emit("error",t);this[Pc](e)})}[Pc](t){if(this.fd=t,this.#e)return this[_n]();if(!this.stat)throw new Error("should stat before calling onopenfile");this.blockLen=512*Math.ceil(this.stat.size/512),this.blockRemain=this.blockLen;let e=Math.min(this.blockLen,this.maxReadSize);this.buf=Buffer.allocUnsafe(e),this.offset=0,this.pos=0,this.remain=this.stat.size,this.length=this.buf.length,this[Ks]()}[Ks](){let{fd:t,buf:e,offset:n,length:i,pos:o}=this;if(t===void 0||e===void 0)throw new Error("cannot read file without first opening");Ct.read(t,e,n,i,o,(c,d)=>{if(c)return this[_n](()=>this.emit("error",c));this[Ac](d)})}[_n](t=()=>{}){this.fd!==void 0&&Ct.close(this.fd,t)}[Ac](t){if(t<=0&&this.remain>0){let n=Object.assign(new Error("encountered unexpected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[_n](()=>this.emit("error",n))}if(t>this.remain){let n=Object.assign(new Error("did not encounter expected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[_n](()=>this.emit("error",n))}if(!this.buf)throw new Error("should have created buffer prior to reading");if(t===this.remain)for(let n=t;n<this.length&&t<this.blockRemain;n++)this.buf[n+this.offset]=0,t++,this.remain++;let e=this.offset===0&&t===this.buf.length?this.buf:this.buf.subarray(this.offset,this.offset+t);this.write(e)?this[uc]():this[Rc](()=>this[uc]())}[Rc](t){this.once("drain",t)}write(t,e,n){if(typeof e=="function"&&(n=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8")),this.blockRemain<t.length){let i=Object.assign(new Error("writing more data than expected"),{path:this.absolute});return this.emit("error",i)}return this.remain-=t.length,this.blockRemain-=t.length,this.pos+=t.length,this.offset+=t.length,super.write(t,null,n)}[uc](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[_n](t=>t?this.emit("error",t):this.end());if(!this.buf)throw new Error("buffer lost somehow in ONDRAIN");this.offset>=this.length&&(this.buf=Buffer.allocUnsafe(Math.min(this.blockRemain,this.buf.length)),this.offset=0),this.length=this.buf.length-this.offset,this[Ks]()}},g_=class extends yf{sync=!0;[Ic](){this[$s](Ct.lstatSync(this.absolute))}[Sc](){this[kc](Ct.readlinkSync(this.absolute))}[Tc](){this[Pc](Ct.openSync(this.absolute,"r"))}[Ks](){let t=!0;try{let{fd:e,buf:n,offset:i,length:o,pos:c}=this;if(e===void 0||n===void 0)throw new Error("fd and buf must be set in READ method");let d=Ct.readSync(e,n,i,o,c);this[Ac](d),t=!1}finally{if(t)try{this[_n](()=>{})}catch{}}}[Rc](t){t()}[_n](t=()=>{}){this.fd!==void 0&&Ct.closeSync(this.fd),t()}},m_=class extends Wn{blockLen=0;blockRemain=0;buf=0;pos=0;remain=0;length=0;preservePaths;portable;strict;noPax;noMtime;readEntry;type;prefix;path;mode;uid;gid;uname;gname;header;mtime;atime;ctime;linkpath;size;onWriteEntry;warn(t,e,n={}){return ao(this,t,e,n)}constructor(t,e={}){let n=Hc(e);super(),this.preservePaths=!!n.preservePaths,this.portable=!!n.portable,this.strict=!!n.strict,this.noPax=!!n.noPax,this.noMtime=!!n.noMtime,this.onWriteEntry=n.onWriteEntry,this.readEntry=t;let{type:i}=t;if(i==="Unsupported")throw new Error("writing entry that should be ignored");this.type=i,this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.prefix=n.prefix,this.path=ee(t.path),this.mode=t.mode!==void 0?this[no](t.mode):void 0,this.uid=this.portable?void 0:t.uid,this.gid=this.portable?void 0:t.gid,this.uname=this.portable?void 0:t.uname,this.gname=this.portable?void 0:t.gname,this.size=t.size,this.mtime=this.noMtime?void 0:n.mtime||t.mtime,this.atime=this.portable?void 0:t.atime,this.ctime=this.portable?void 0:t.ctime,this.linkpath=t.linkpath!==void 0?ee(t.linkpath):void 0,typeof n.onwarn=="function"&&this.on("warn",n.onwarn);let o=!1;if(!this.preservePaths){let[d,u]=Wc(this.path);d&&typeof u=="string"&&(this.path=u,o=d)}this.remain=t.size,this.blockRemain=t.startBlockSize,this.onWriteEntry?.(this),this.header=new jn({path:this[Dt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Dt](this.linkpath):this.linkpath,mode:this.mode,uid:this.portable?void 0:this.uid,gid:this.portable?void 0:this.gid,size:this.size,mtime:this.noMtime?void 0:this.mtime,type:this.type,uname:this.portable?void 0:this.uname,atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime}),o&&this.warn("TAR_ENTRY_INFO",`stripping ${o} from absolute path`,{entry:this,path:o+this.path}),this.header.encode()&&!this.noPax&&super.write(new eo({atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime,gid:this.portable?void 0:this.gid,mtime:this.noMtime?void 0:this.mtime,path:this[Dt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Dt](this.linkpath):this.linkpath,size:this.size,uid:this.portable?void 0:this.uid,uname:this.portable?void 0:this.uname,dev:this.portable?void 0:this.readEntry.dev,ino:this.portable?void 0:this.readEntry.ino,nlink:this.portable?void 0:this.readEntry.nlink}).encode());let c=this.header?.block;if(!c)throw new Error("failed to encode header");super.write(c),t.pipe(this)}[Dt](t){return _f(t,this.prefix)}[no](t){return wf(t,this.type==="Directory",this.portable)}write(t,e,n){typeof e=="function"&&(n=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8"));let i=t.length;if(i>this.blockRemain)throw new Error("writing more to entry than is appropriate");return this.blockRemain-=i,super.write(t,n)}end(t,e,n){return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),typeof t=="function"&&(n=t,e=void 0,t=void 0),typeof e=="function"&&(n=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,e??"utf8")),n&&this.once("finish",n),t?super.end(t,n):super.end(n),this}},w_=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported",__=class Ir{tail;head;length=0;static create(e=[]){return new Ir(e)}constructor(e=[]){for(let n of e)this.push(n)}*[Symbol.iterator](){for(let e=this.head;e;e=e.next)yield e.value}removeNode(e){if(e.list!==this)throw new Error("removing node which does not belong to this list");let n=e.next,i=e.prev;return n&&(n.prev=i),i&&(i.next=n),e===this.head&&(this.head=n),e===this.tail&&(this.tail=i),this.length--,e.next=void 0,e.prev=void 0,e.list=void 0,n}unshiftNode(e){if(e===this.head)return;e.list&&e.list.removeNode(e);let n=this.head;e.list=this,e.next=n,n&&(n.prev=e),this.head=e,this.tail||(this.tail=e),this.length++}pushNode(e){if(e===this.tail)return;e.list&&e.list.removeNode(e);let n=this.tail;e.list=this,e.prev=n,n&&(n.next=e),this.tail=e,this.head||(this.head=e),this.length++}push(...e){for(let n=0,i=e.length;n<i;n++)E_(this,e[n]);return this.length}unshift(...e){for(var n=0,i=e.length;n<i;n++)b_(this,e[n]);return this.length}pop(){if(!this.tail)return;let e=this.tail.value,n=this.tail;return this.tail=this.tail.prev,this.tail?this.tail.next=void 0:this.head=void 0,n.list=void 0,this.length--,e}shift(){if(!this.head)return;let e=this.head.value,n=this.head;return this.head=this.head.next,this.head?this.head.prev=void 0:this.tail=void 0,n.list=void 0,this.length--,e}forEach(e,n){n=n||this;for(let i=this.head,o=0;i;o++)e.call(n,i.value,o,this),i=i.next}forEachReverse(e,n){n=n||this;for(let i=this.tail,o=this.length-1;i;o--)e.call(n,i.value,o,this),i=i.prev}get(e){let n=0,i=this.head;for(;i&&n<e;n++)i=i.next;if(n===e&&i)return i.value}getReverse(e){let n=0,i=this.tail;for(;i&&n<e;n++)i=i.prev;if(n===e&&i)return i.value}map(e,n){n=n||this;let i=new Ir;for(let o=this.head;o;)i.push(e.call(n,o.value,this)),o=o.next;return i}mapReverse(e,n){n=n||this;var i=new Ir;for(let o=this.tail;o;)i.push(e.call(n,o.value,this)),o=o.prev;return i}reduce(e,n){let i,o=this.head;if(arguments.length>1)i=n;else if(this.head)o=this.head.next,i=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var c=0;o;c++)i=e(i,o.value,c),o=o.next;return i}reduceReverse(e,n){let i,o=this.tail;if(arguments.length>1)i=n;else if(this.tail)o=this.tail.prev,i=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(let c=this.length-1;o;c--)i=e(i,o.value,c),o=o.prev;return i}toArray(){let e=new Array(this.length);for(let n=0,i=this.head;i;n++)e[n]=i.value,i=i.next;return e}toArrayReverse(){let e=new Array(this.length);for(let n=0,i=this.tail;i;n++)e[n]=i.value,i=i.prev;return e}slice(e=0,n=this.length){n<0&&(n+=this.length),e<0&&(e+=this.length);let i=new Ir;if(n<e||n<0)return i;e<0&&(e=0),n>this.length&&(n=this.length);let o=this.head,c=0;for(c=0;o&&c<e;c++)o=o.next;for(;o&&c<n;c++,o=o.next)i.push(o.value);return i}sliceReverse(e=0,n=this.length){n<0&&(n+=this.length),e<0&&(e+=this.length);let i=new Ir;if(n<e||n<0)return i;e<0&&(e=0),n>this.length&&(n=this.length);let o=this.length,c=this.tail;for(;c&&o>n;o--)c=c.prev;for(;c&&o>e;o--,c=c.prev)i.push(c.value);return i}splice(e,n=0,...i){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);let o=this.head;for(let d=0;o&&d<e;d++)o=o.next;let c=[];for(let d=0;o&&d<n;d++)c.push(o.value),o=this.removeNode(o);o?o!==this.tail&&(o=o.prev):o=this.tail;for(let d of i)o=y_(this,o,d);return c}reverse(){let e=this.head,n=this.tail;for(let i=e;i;i=i.prev){let o=i.prev;i.prev=i.next,i.next=o}return this.head=n,this.tail=e,this}};function y_(t,e,n){let i=e,o=e?e.next:t.head,c=new $c(n,i,o,t);return c.next===void 0&&(t.tail=c),c.prev===void 0&&(t.head=c),t.length++,c}function E_(t,e){t.tail=new $c(e,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function b_(t,e){t.head=new $c(e,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}var $c=class{list;next;prev;value;constructor(t,e,n,i){this.list=i,this.value=t,e?(e.next=this,this.prev=e):this.prev=void 0,n?(n.prev=this,this.next=n):this.next=void 0}},ju=class{path;absolute;entry;stat;readdir;pending=!1;pendingLink=!1;ignore=!1;piped=!1;constructor(t,e){this.path=t||"./",this.absolute=e}},Wu=Buffer.alloc(1024),Vs=Symbol("onStat"),_i=Symbol("ended"),Et=Symbol("queue"),yi=Symbol("pendingLinks"),pn=Symbol("current"),Un=Symbol("process"),Ei=Symbol("processing"),Gs=Symbol("processJob"),bt=Symbol("jobs"),fc=Symbol("jobDone"),Js=Symbol("addFSEntry"),Ku=Symbol("addTarEntry"),Cc=Symbol("stat"),Dc=Symbol("readdir"),Zs=Symbol("onreaddir"),Ys=Symbol("pipe"),$u=Symbol("entry"),hc=Symbol("entryOpt"),Xs=Symbol("writeEntryClass"),Ef=Symbol("write"),xc=Symbol("ondrain"),lo=class extends Wn{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[Xs];onWriteEntry;[Et];[yi]=new Map;[bt]=0;[Ei]=!1;[_i]=!1;constructor(t={}){if(super(),this.opt=t,this.file=t.file||"",this.cwd=t.cwd||process.cwd(),this.maxReadSize=t.maxReadSize,this.preservePaths=!!t.preservePaths,this.strict=!!t.strict,this.noPax=!!t.noPax,this.prefix=ee(t.prefix||""),this.linkCache=t.linkCache||new Map,this.statCache=t.statCache||new Map,this.readdirCache=t.readdirCache||new Map,this.onWriteEntry=t.onWriteEntry,this[Xs]=yf,typeof t.onwarn=="function"&&this.on("warn",t.onwarn),this.portable=!!t.portable,t.gzip||t.brotli||t.zstd){if((t.gzip?1:0)+(t.brotli?1:0)+(t.zstd?1:0)>1)throw new TypeError("gzip, brotli, zstd are mutually exclusive");if(t.gzip&&(typeof t.gzip!="object"&&(t.gzip={}),this.portable&&(t.gzip.portable=!0),this.zip=new Pw(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new Cw(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new Ow(t.zstd)),!this.zip)throw new Error("impossible");let e=this.zip;e.on("data",n=>super.write(n)),e.on("end",()=>super.end()),e.on("drain",()=>this[xc]()),this.on("resume",()=>e.resume())}else this.on("drain",this[xc]);this.noDirRecurse=!!t.noDirRecurse,this.follow=!!t.follow,this.noMtime=!!t.noMtime,t.mtime&&(this.mtime=t.mtime),this.filter=typeof t.filter=="function"?t.filter:()=>!0,this[Et]=new __,this[bt]=0,this.jobs=Number(t.jobs)||4,this[Ei]=!1,this[_i]=!1}[Ef](t){return super.write(t)}add(t){return this.write(t),this}end(t,e,n){return typeof t=="function"&&(n=t,t=void 0),typeof e=="function"&&(n=e,e=void 0),t&&this.add(t),this[_i]=!0,this[Un](),n&&n(),this}write(t){if(this[_i])throw new Error("write after end");return typeof t=="string"?this[Js](t):this[Ku](t),this.flowing}[Ku](t){let e=ee(qu.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let n=new ju(t.path,e);n.entry=new m_(t,this[hc](n)),n.entry.on("end",()=>this[fc](n)),this[bt]+=1,this[Et].push(n)}this[Un]()}[Js](t){let e=ee(qu.resolve(this.cwd,t));this[Et].push(new ju(t,e)),this[Un]()}[Cc](t){t.pending=!0,this[bt]+=1;let e=this.follow?"stat":"lstat";to[e](t.absolute,(n,i)=>{t.pending=!1,this[bt]-=1,n?this.emit("error",n):this[Vs](t,i)})}[Vs](t,e){if(this.statCache.set(t.absolute,e),t.stat=e,!this.filter(t.path,e))t.ignore=!0;else if(e.isFile()&&e.nlink>1&&!this.linkCache.get(`${e.dev}:${e.ino}`)&&!this.sync)if(t===this[pn])this[Gs](t);else{let n=`${e.dev}:${e.ino}`,i=this[yi].get(n);i?i.push(t):this[yi].set(n,[t]),t.pendingLink=!0,t.pending=!0}this[Un]()}[Dc](t){t.pending=!0,this[bt]+=1,to.readdir(t.absolute,(e,n)=>{if(t.pending=!1,this[bt]-=1,e)return this.emit("error",e);this[Zs](t,n)})}[Zs](t,e){this.readdirCache.set(t.absolute,e),t.readdir=e,this[Un]()}[Un](){if(!this[Ei]){this[Ei]=!0;for(let t=this[Et].head;t&&this[bt]<this.jobs;t=t.next)if(this[Gs](t.value),t.value.ignore){let e=t.next;this[Et].removeNode(t),t.next=e}this[Ei]=!1,this[_i]&&this[Et].length===0&&this[bt]===0&&(this.zip?this.zip.end(Wu):(super.write(Wu),super.end()))}}get[pn](){return this[Et]&&this[Et].head&&this[Et].head.value}[fc](t){this[Et].shift(),this[bt]-=1;let{stat:e}=t;if(e&&e.isFile()&&e.nlink>1){let n=`${e.dev}:${e.ino}`,i=this[yi].get(n);if(i){this[yi].delete(n);for(let o of i)o.pending=!1,this[Gs](o)}}this[Un]()}[Gs](t){if(t.pending&&t.pendingLink&&t===this[pn]&&(t.pending=!1,t.pendingLink=!1),!t.pending){if(t.entry){t===this[pn]&&!t.piped&&this[Ys](t);return}if(!t.stat){let e=this.statCache.get(t.absolute);e?this[Vs](t,e):this[Cc](t)}if(t.stat&&!t.ignore){if(!this.noDirRecurse&&t.stat.isDirectory()&&!t.readdir){let e=this.readdirCache.get(t.absolute);if(e?this[Zs](t,e):this[Dc](t),!t.readdir)return}if(t.entry=this[$u](t),!t.entry){t.ignore=!0;return}t===this[pn]&&!t.piped&&this[Ys](t)}}}[hc](t){return{onwarn:(e,n,i)=>this.warn(e,n,i),noPax:this.noPax,cwd:this.cwd,absolute:t.absolute,preservePaths:this.preservePaths,maxReadSize:this.maxReadSize,strict:this.strict,portable:this.portable,linkCache:this.linkCache,statCache:this.statCache,noMtime:this.noMtime,mtime:this.mtime,prefix:this.prefix,onWriteEntry:this.onWriteEntry}}[$u](t){this[bt]+=1;try{return new this[Xs](t.path,this[hc](t)).on("end",()=>this[fc](t)).on("error",e=>this.emit("error",e))}catch(e){this.emit("error",e)}}[xc](){this[pn]&&this[pn].entry&&this[pn].entry.resume()}[Ys](t){t.piped=!0,t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[Js](c+i)});let e=t.entry,n=this.zip;if(!e)throw new Error("cannot pipe without source");n?e.on("data",i=>{n.write(i)||e.pause()}):e.on("data",i=>{super.write(i)||e.pause()})}pause(){return this.zip&&this.zip.pause(),super.pause()}warn(t,e,n={}){ao(this,t,e,n)}},Vc=class extends lo{sync=!0;constructor(t){super(t),this[Xs]=g_}pause(){}resume(){}[Cc](t){let e=this.follow?"statSync":"lstatSync";this[Vs](t,to[e](t.absolute))}[Dc](t){this[Zs](t,to.readdirSync(t.absolute))}[Ys](t){let e=t.entry,n=this.zip;if(t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[Js](c+i)}),!e)throw new Error("Cannot pipe without source");n?e.on("data",i=>{n.write(i)}):e.on("data",i=>{super[Ef](i)})}},v_=(t,e)=>{let n=new Vc(t),i=new cf(t.file,{mode:t.mode||438});n.pipe(i),bf(n,e)},S_=(t,e)=>{let n=new lo(t),i=new so(t.file,{mode:t.mode||438});n.pipe(i);let o=new Promise((c,d)=>{i.on("error",d),i.on("close",c),n.on("error",d)});return vf(n,e).catch(c=>n.emit("error",c)),o},bf=(t,e)=>{e.forEach(n=>{n.charAt(0)==="@"?Tr({file:df.resolve(t.cwd,n.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(n)}),t.end()},vf=async(t,e)=>{for(let n of e)n.charAt(0)==="@"?await Tr({file:df.resolve(String(t.cwd),n.slice(1)),noResume:!0,onReadEntry:i=>{t.add(i)}}):t.add(n);t.end()},I_=(t,e)=>{let n=new Vc(t);return bf(n,e),n},A_=(t,e)=>{let n=new lo(t);return vf(n,e).catch(i=>n.emit("error",i)),n},ak=Li(v_,S_,I_,A_,(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")}),T_=process.env.__FAKE_PLATFORM__||process.platform,kf=T_==="win32",{O_CREAT:Tf,O_NOFOLLOW:Vu,O_TRUNC:Pf,O_WRONLY:Rf}=Af.constants,Cf=Number(process.env.__FAKE_FS_O_FILENAME__)||Af.constants.UV_FS_O_FILEMAP||0,P_=kf&&!!Cf,R_=512*1024,C_=Cf|Pf|Tf|Rf,Ju=!kf&&typeof Vu=="number"?Vu|Pf|Tf|Rf:null,Df=Ju!==null?()=>Ju:P_?t=>t<R_?C_:"w":()=>"w",Oc=(t,e,n)=>{try{return uo.lchownSync(t,e,n)}catch(i){if(i?.code!=="ENOENT")throw i}},ro=(t,e,n,i)=>{uo.lchown(t,e,n,o=>{i(o&&o?.code!=="ENOENT"?o:null)})},D_=(t,e,n,i,o)=>{if(e.isDirectory())Of(ki.resolve(t,e.name),n,i,c=>{if(c)return o(c);let d=ki.resolve(t,e.name);ro(d,n,i,o)});else{let c=ki.resolve(t,e.name);ro(c,n,i,o)}},Of=(t,e,n,i)=>{uo.readdir(t,{withFileTypes:!0},(o,c)=>{if(o){if(o.code==="ENOENT")return i();if(o.code!=="ENOTDIR"&&o.code!=="ENOTSUP")return i(o)}if(o||!c.length)return ro(t,e,n,i);let d=c.length,u=null,f=x=>{if(!u){if(x)return i(u=x);if(--d===0)return ro(t,e,n,i)}};for(let x of c)D_(t,x,e,n,f)})},O_=(t,e,n,i)=>{e.isDirectory()&&Lf(ki.resolve(t,e.name),n,i),Oc(ki.resolve(t,e.name),n,i)},Lf=(t,e,n)=>{let i;try{i=uo.readdirSync(t,{withFileTypes:!0})}catch(o){let c=o;if(c?.code==="ENOENT")return;if(c?.code==="ENOTDIR"||c?.code==="ENOTSUP")return Oc(t,e,n);throw c}for(let o of i)O_(t,o,e,n);return Oc(t,e,n)},Nf=class extends Error{path;code;syscall="chdir";constructor(t,e){super(`${e}: Cannot cd into '${t}'`),this.path=t,this.code=e}get name(){return"CwdError"}},fo=class extends Error{path;symlink;syscall="symlink";code="TAR_SYMLINK_ERROR";constructor(t,e){super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"),this.symlink=t,this.path=e}get name(){return"SymlinkError"}},N_=(t,e)=>{ct.stat(t,(n,i)=>{(n||!i.isDirectory())&&(n=new Nf(t,n?.code||"ENOTDIR")),e(n)})},M_=(t,e,n)=>{t=ee(t);let i=e.umask??18,o=e.mode|448,c=(o&i)!==0,d=e.uid,u=e.gid,f=typeof d=="number"&&typeof u=="number"&&(d!==e.processUid||u!==e.processGid),x=e.preserve,m=e.unlink,_=ee(e.cwd),v=(b,I)=>{b?n(b):I&&f?Of(I,d,u,A=>v(A)):c?ct.chmod(t,o,n):n()};if(t===_)return N_(t,v);if(x)return L_.mkdir(t,{mode:o,recursive:!0}).then(b=>v(null,b??void 0),v);let y=ee(io.relative(_,t)).split("/");Lc(_,y,o,m,_,void 0,v)},Lc=(t,e,n,i,o,c,d)=>{if(e.length===0)return d(null,c);let u=e.shift(),f=ee(io.resolve(t+"/"+u));ct.mkdir(f,n,Mf(f,e,n,i,o,c,d))},Mf=(t,e,n,i,o,c,d)=>u=>{u?ct.lstat(t,(f,x)=>{if(f)f.path=f.path&&ee(f.path),d(f);else if(x.isDirectory())Lc(t,e,n,i,o,c,d);else if(i)ct.unlink(t,m=>{if(m)return d(m);ct.mkdir(t,n,Mf(t,e,n,i,o,c,d))});else{if(x.isSymbolicLink())return d(new fo(t,t+"/"+e.join("/")));d(u)}}):(c=c||t,Lc(t,e,n,i,o,c,d))},B_=t=>{let e=!1,n;try{e=ct.statSync(t).isDirectory()}catch(i){n=i?.code}finally{if(!e)throw new Nf(t,n??"ENOTDIR")}},F_=(t,e)=>{t=ee(t);let n=e.umask??18,i=e.mode|448,o=(i&n)!==0,c=e.uid,d=e.gid,u=typeof c=="number"&&typeof d=="number"&&(c!==e.processUid||d!==e.processGid),f=e.preserve,x=e.unlink,m=ee(e.cwd),_=b=>{b&&u&&Lf(b,c,d),o&&ct.chmodSync(t,i)};if(t===m)return B_(m),_();if(f)return _(ct.mkdirSync(t,{mode:i,recursive:!0})??void 0);let v=ee(io.relative(m,t)).split("/"),y;for(let b=v.shift(),I=m;b&&(I+="/"+b);b=v.shift()){I=ee(io.resolve(I));try{ct.mkdirSync(I,i),y=y||I}catch{let A=ct.lstatSync(I);if(A.isDirectory())continue;if(x){ct.unlinkSync(I),ct.mkdirSync(I,i),y=y||I;continue}else if(A.isSymbolicLink())return new fo(I,I+"/"+v.join("/"))}}return _(y)},pc=Object.create(null),Zu=1e4,_r=new Set,z_=t=>{_r.has(t)?_r.delete(t):pc[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),_r.add(t);let e=pc[t],n=_r.size-Zu;if(n>Zu/10){for(let i of _r)if(_r.delete(i),delete pc[i],--n<=0)break}return e},U_=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,G_=U_==="win32",H_=t=>t.split("/").slice(0,-1).reduce((e,n)=>{let i=e.at(-1);return i!==void 0&&(n=Bf(i,n)),e.push(n||"/"),e},[]),q_=class{#e=new Map;#n=new Map;#r=new Set;reserve(t,e){t=G_?["win32 parallelization disabled"]:t.map(i=>Ai(Bf(z_(i))));let n=new Set(t.map(i=>H_(i)).reduce((i,o)=>i.concat(o)));this.#n.set(e,{dirs:n,paths:t});for(let i of t){let o=this.#e.get(i);o?o.push(e):this.#e.set(i,[e])}for(let i of n){let o=this.#e.get(i);if(!o)this.#e.set(i,[new Set([e])]);else{let c=o.at(-1);c instanceof Set?c.add(e):o.push(new Set([e]))}}return this.#i(e)}#s(t){let e=this.#n.get(t);if(!e)throw new Error("function does not have any path reservations");return{paths:e.paths.map(n=>this.#e.get(n)),dirs:[...e.dirs].map(n=>this.#e.get(n))}}check(t){let{paths:e,dirs:n}=this.#s(t);return e.every(i=>i&&i[0]===t)&&n.every(i=>i&&i[0]instanceof Set&&i[0].has(t))}#i(t){return this.#r.has(t)||!this.check(t)?!1:(this.#r.add(t),t(()=>this.#t(t)),!0)}#t(t){if(!this.#r.has(t))return!1;let e=this.#n.get(t);if(!e)throw new Error("invalid reservation");let{paths:n,dirs:i}=e,o=new Set;for(let c of n){let d=this.#e.get(c);if(!d||d?.[0]!==t)continue;let u=d[1];if(!u){this.#e.delete(c);continue}if(d.shift(),typeof u=="function")o.add(u);else for(let f of u)o.add(f)}for(let c of i){let d=this.#e.get(c),u=d?.[0];if(!(!d||!(u instanceof Set)))if(u.size===1&&d.length===1){this.#e.delete(c);continue}else if(u.size===1){d.shift();let f=d[0];typeof f=="function"&&o.add(f)}else u.delete(t)}return this.#r.delete(t),o.forEach(c=>this.#i(c)),!0}},j_=()=>process.umask(),Yu=Symbol("onEntry"),Nc=Symbol("checkFs"),Xu=Symbol("checkFs2"),Mc=Symbol("isReusable"),ht=Symbol("makeFs"),Bc=Symbol("file"),Fc=Symbol("directory"),Qs=Symbol("link"),Qu=Symbol("symlink"),ef=Symbol("hardlink"),Si=Symbol("ensureNoSymlink"),tf=Symbol("unsupported"),nf=Symbol("checkPath"),gc=Symbol("stripAbsolutePath"),yn=Symbol("mkdir"),je=Symbol("onError"),Hs=Symbol("pending"),rf=Symbol("pend"),yr=Symbol("unpend"),mc=Symbol("ended"),wc=Symbol("maybeClose"),zc=Symbol("skip"),Ti=Symbol("doChown"),Pi=Symbol("uid"),Ri=Symbol("gid"),Ci=Symbol("checkedCwd"),W_=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Di=W_==="win32",K_=1024,$_=(t,e)=>{if(!Di)return se.unlink(t,e);let n=t+".DELETE."+If(16).toString("hex");se.rename(t,n,i=>{if(i)return e(i);se.unlink(n,e)})},V_=t=>{if(!Di)return se.unlinkSync(t);let e=t+".DELETE."+If(16).toString("hex");se.renameSync(t,e),se.unlinkSync(e)},sf=(t,e,n)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:n,Jc=class extends Oi{[mc]=!1;[Ci]=!1;[Hs]=0;reservations=new q_;transform;writable=!0;readable=!1;uid;gid;setOwner;preserveOwner;processGid;processUid;maxDepth;forceChown;win32;newer;keep;noMtime;preservePaths;unlink;cwd;strip;processUmask;umask;dmode;fmode;chmod;constructor(t={}){if(t.ondone=()=>{this[mc]=!0,this[wc]()},super(t),this.transform=t.transform,this.chmod=!!t.chmod,typeof t.uid=="number"||typeof t.gid=="number"){if(typeof t.uid!="number"||typeof t.gid!="number")throw new TypeError("cannot set owner without number uid and gid");if(t.preserveOwner)throw new TypeError("cannot preserve owner in archive and also set owner explicitly");this.uid=t.uid,this.gid=t.gid,this.setOwner=!0}else this.uid=void 0,this.gid=void 0,this.setOwner=!1;this.preserveOwner=t.preserveOwner===void 0&&typeof t.uid!="number"?!!(process.getuid&&process.getuid()===0):!!t.preserveOwner,this.processUid=(this.preserveOwner||this.setOwner)&&process.getuid?process.getuid():void 0,this.processGid=(this.preserveOwner||this.setOwner)&&process.getgid?process.getgid():void 0,this.maxDepth=typeof t.maxDepth=="number"?t.maxDepth:K_,this.forceChown=t.forceChown===!0,this.win32=!!t.win32||Di,this.newer=!!t.newer,this.keep=!!t.keep,this.noMtime=!!t.noMtime,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.cwd=ee(Be.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:j_():0,this.umask=typeof t.umask=="number"?t.umask:this.processUmask,this.dmode=t.dmode||511&~this.umask,this.fmode=t.fmode||438&~this.umask,this.on("entry",e=>this[Yu](e))}warn(t,e,n={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(n.recoverable=!1),super.warn(t,e,n)}[wc](){this[mc]&&this[Hs]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[gc](t,e){let n=t[e],{type:i}=t;if(!n||this.preservePaths)return!0;let[o,c]=Wc(n),d=c.replaceAll(/\\/g,"/").split("/");if(d.includes("..")||Di&&/^[a-z]:\.\.$/i.test(d[0]??"")){if(e==="path"||i==="Link")return this.warn("TAR_ENTRY_ERROR",`${e} contains '..'`,{entry:t,[e]:n}),!1;let u=Be.posix.dirname(t.path),f=Be.posix.normalize(Be.posix.join(u,d.join("/")));if(f.startsWith("../")||f==="..")return this.warn("TAR_ENTRY_ERROR",`${e} escapes extraction directory`,{entry:t,[e]:n}),!1}return o&&(t[e]=String(c),this.warn("TAR_ENTRY_INFO",`stripping ${o} from absolute ${e}`,{entry:t,[e]:n})),!0}[nf](t){let e=ee(t.path),n=e.split("/");if(this.strip){if(n.length<this.strip)return!1;if(t.type==="Link"){let i=ee(String(t.linkpath)).split("/");if(i.length>=this.strip)t.linkpath=i.slice(this.strip).join("/");else return!1}n.splice(0,this.strip),t.path=n.join("/")}if(isFinite(this.maxDepth)&&n.length>this.maxDepth)return this.warn("TAR_ENTRY_ERROR","path excessively deep",{entry:t,path:e,depth:n.length,maxDepth:this.maxDepth}),!1;if(!this[gc](t,"path")||!this[gc](t,"linkpath"))return!1;if(t.absolute=Be.isAbsolute(t.path)?ee(Be.resolve(t.path)):ee(Be.resolve(this.cwd,t.path)),!this.preservePaths&&typeof t.absolute=="string"&&t.absolute.indexOf(this.cwd+"/")!==0&&t.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:t,path:ee(t.path),resolvedPath:t.absolute,cwd:this.cwd}),!1;if(t.absolute===this.cwd&&t.type!=="Directory"&&t.type!=="GNUDumpDir")return!1;if(this.win32){let{root:i}=Be.win32.parse(String(t.absolute));t.absolute=i+Fu(String(t.absolute).slice(i.length));let{root:o}=Be.win32.parse(t.path);t.path=o+Fu(t.path.slice(o.length))}return!0}[Yu](t){if(!this[nf](t))return t.resume();switch(k_.equal(typeof t.absolute,"string"),t.type){case"Directory":case"GNUDumpDir":t.mode&&(t.mode=t.mode|448);case"File":case"OldFile":case"ContiguousFile":case"Link":case"SymbolicLink":return this[Nc](t);default:return this[tf](t)}}[je](t,e){t.name==="CwdError"?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:e}),this[yr](),e.resume())}[yn](t,e,n){M_(ee(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:e},n)}[Ti](t){return this.forceChown||this.preserveOwner&&(typeof t.uid=="number"&&t.uid!==this.processUid||typeof t.gid=="number"&&t.gid!==this.processGid)||typeof this.uid=="number"&&this.uid!==this.processUid||typeof this.gid=="number"&&this.gid!==this.processGid}[Pi](t){return sf(this.uid,t.uid,this.processUid)}[Ri](t){return sf(this.gid,t.gid,this.processGid)}[Bc](t,e){let n=typeof t.mode=="number"?t.mode&4095:this.fmode,i=new so(String(t.absolute),{flags:Df(t.size),mode:n,autoClose:!1});i.on("error",u=>{i.fd&&se.close(i.fd,()=>{}),i.write=()=>!0,this[je](u,t),e()});let o=1,c=u=>{if(u){i.fd&&se.close(i.fd,()=>{}),this[je](u,t),e();return}--o===0&&i.fd!==void 0&&se.close(i.fd,f=>{f?this[je](f,t):this[yr](),e()})};i.on("finish",()=>{let u=String(t.absolute),f=i.fd;if(typeof f=="number"&&t.mtime&&!this.noMtime){o++;let x=t.atime||new Date,m=t.mtime;se.futimes(f,x,m,_=>_?se.utimes(u,x,m,v=>c(v&&_)):c())}if(typeof f=="number"&&this[Ti](t)){o++;let x=this[Pi](t),m=this[Ri](t);typeof x=="number"&&typeof m=="number"&&se.fchown(f,x,m,_=>_?se.chown(u,x,m,v=>c(v&&_)):c())}c()});let d=this.transform&&this.transform(t)||t;d!==t&&(d.on("error",u=>{this[je](u,t),e()}),t.pipe(d)),d.pipe(i)}[Fc](t,e){let n=typeof t.mode=="number"?t.mode&4095:this.dmode;this[yn](String(t.absolute),n,i=>{if(i){this[je](i,t),e();return}let o=1,c=()=>{--o===0&&(e(),this[yr](),t.resume())};t.mtime&&!this.noMtime&&(o++,se.utimes(String(t.absolute),t.atime||new Date,t.mtime,c)),this[Ti](t)&&(o++,se.chown(String(t.absolute),Number(this[Pi](t)),Number(this[Ri](t)),c)),c()})}[tf](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[Qu](t,e){let n=ee(Be.relative(this.cwd,Be.resolve(Be.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[Si](t,this.cwd,n,()=>this[Qs](t,String(t.linkpath),"symlink",e),i=>{this[je](i,t),e()})}[ef](t,e){let n=ee(Be.resolve(this.cwd,String(t.linkpath))),i=ee(String(t.linkpath)).split("/");this[Si](t,this.cwd,i,()=>this[Qs](t,n,"link",e),o=>{this[je](o,t),e()})}[Si](t,e,n,i,o){let c=n.shift();if(this.preservePaths||c===void 0)return i();let d=Be.resolve(e,c);se.lstat(d,(u,f)=>{if(u)return i();if(f?.isSymbolicLink())return o(new fo(d,Be.resolve(d,n.join("/"))));this[Si](t,d,n,i,o)})}[rf](){this[Hs]++}[yr](){this[Hs]--,this[wc]()}[zc](t){this[yr](),t.resume()}[Mc](t,e){return t.type==="File"&&!this.unlink&&e.isFile()&&e.nlink<=1&&!Di}[Nc](t){this[rf]();let e=[t.path];t.linkpath&&e.push(t.linkpath),this.reservations.reserve(e,n=>this[Xu](t,n))}[Xu](t,e){let n=d=>{e(d)},i=()=>{this[yn](this.cwd,this.dmode,d=>{if(d){this[je](d,t),n();return}this[Ci]=!0,o()})},o=()=>{if(t.absolute!==this.cwd){let d=ee(Be.dirname(String(t.absolute)));if(d!==this.cwd)return this[yn](d,this.dmode,u=>{if(u){this[je](u,t),n();return}c()})}c()},c=()=>{se.lstat(String(t.absolute),(d,u)=>{if(u&&(this.keep||this.newer&&u.mtime>(t.mtime??u.mtime))){this[zc](t),n();return}if(d||this[Mc](t,u))return this[ht](null,t,n);if(u.isDirectory()){if(t.type==="Directory"){let f=this.chmod&&t.mode&&(u.mode&4095)!==t.mode,x=m=>this[ht](m??null,t,n);return f?se.chmod(String(t.absolute),Number(t.mode),x):x()}if(t.absolute!==this.cwd)return se.rmdir(String(t.absolute),f=>this[ht](f??null,t,n))}if(t.absolute===this.cwd)return this[ht](null,t,n);$_(String(t.absolute),f=>this[ht](f??null,t,n))})};this[Ci]?o():i()}[ht](t,e,n){if(t){this[je](t,e),n();return}switch(e.type){case"File":case"OldFile":case"ContiguousFile":return this[Bc](e,n);case"Link":return this[ef](e,n);case"SymbolicLink":return this[Qu](e,n);case"Directory":case"GNUDumpDir":return this[Fc](e,n)}}[Qs](t,e,n,i){se[n](e,String(t.absolute),o=>{o?this[je](o,t):(this[yr](),t.resume()),i()})}},bi=t=>{try{return[null,t()]}catch(e){return[e,null]}},Ff=class extends Jc{sync=!0;[ht](t,e){return super[ht](t,e,()=>{})}[Nc](t){if(!this[Ci]){let o=this[yn](this.cwd,this.dmode);if(o)return this[je](o,t);this[Ci]=!0}if(t.absolute!==this.cwd){let o=ee(Be.dirname(String(t.absolute)));if(o!==this.cwd){let c=this[yn](o,this.dmode);if(c)return this[je](c,t)}}let[e,n]=bi(()=>se.lstatSync(String(t.absolute)));if(n&&(this.keep||this.newer&&n.mtime>(t.mtime??n.mtime)))return this[zc](t);if(e||this[Mc](t,n))return this[ht](null,t);if(n.isDirectory()){if(t.type==="Directory"){let c=this.chmod&&t.mode&&(n.mode&4095)!==t.mode,[d]=c?bi(()=>{se.chmodSync(String(t.absolute),Number(t.mode))}):[];return this[ht](d,t)}let[o]=bi(()=>se.rmdirSync(String(t.absolute)));this[ht](o,t)}let[i]=t.absolute===this.cwd?[]:bi(()=>V_(String(t.absolute)));this[ht](i,t)}[Bc](t,e){let n=typeof t.mode=="number"?t.mode&4095:this.fmode,i=d=>{let u;try{se.closeSync(o)}catch(f){u=f}(d||u)&&this[je](d||u,t),e()},o;try{o=se.openSync(String(t.absolute),Df(t.size),n)}catch(d){return i(d)}let c=this.transform&&this.transform(t)||t;c!==t&&(c.on("error",d=>this[je](d,t)),t.pipe(c)),c.on("data",d=>{try{se.writeSync(o,d,0,d.length)}catch(u){i(u)}}),c.on("end",()=>{let d=null;if(t.mtime&&!this.noMtime){let u=t.atime||new Date,f=t.mtime;try{se.futimesSync(o,u,f)}catch(x){try{se.utimesSync(String(t.absolute),u,f)}catch{d=x}}}if(this[Ti](t)){let u=this[Pi](t),f=this[Ri](t);try{se.fchownSync(o,Number(u),Number(f))}catch(x){try{se.chownSync(String(t.absolute),Number(u),Number(f))}catch{d=d||x}}}i(d)})}[Fc](t,e){let n=typeof t.mode=="number"?t.mode&4095:this.dmode,i=this[yn](String(t.absolute),n);if(i){this[je](i,t),e();return}if(t.mtime&&!this.noMtime)try{se.utimesSync(String(t.absolute),t.atime||new Date,t.mtime)}catch{}if(this[Ti](t))try{se.chownSync(String(t.absolute),Number(this[Pi](t)),Number(this[Ri](t)))}catch{}e(),t.resume()}[yn](t,e){try{return F_(ee(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:e})}catch(n){return n}}[Si](t,e,n,i,o){if(this.preservePaths||n.length===0)return i();let c=e;for(let d of n){c=Be.resolve(c,d);let[u,f]=bi(()=>se.lstatSync(c));if(u)return i();if(f.isSymbolicLink())return o(new fo(c,Be.resolve(e,n.join("/"))))}i()}[Qs](t,e,n,i){let o=`${n}Sync`;try{se[o](e,String(t.absolute)),i(),t.resume()}catch(c){return this[je](c,t)}}},J_=t=>{let e=new Ff(t),n=t.file,i=Sf.statSync(n),o=t.maxReadSize||16*1024*1024;new xw(n,{readSize:o,size:i.size}).pipe(e)},Z_=(t,e)=>{let n=new Jc(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,d)=>{n.on("error",d),n.on("close",c),Sf.stat(o,(u,f)=>{if(u)d(u);else{let x=new Gc(o,{readSize:i,size:f.size});x.on("error",d),x.pipe(n)}})})},zf=Li(J_,Z_,t=>new Ff(t),t=>new Jc(t),(t,e)=>{e?.length&&mf(t,e)}),Y_=(t,e)=>{let n=new Vc(t),i=!0,o,c;try{try{o=at.openSync(t.file,"r+")}catch(f){if(f?.code==="ENOENT")o=at.openSync(t.file,"w+");else throw f}let d=at.fstatSync(o),u=Buffer.alloc(512);e:for(c=0;c<d.size;c+=512){for(let m=0,_=0;m<512;m+=_){if(_=at.readSync(o,u,m,u.length-m,c+m),c===0&&u[0]===31&&u[1]===139)throw new Error("cannot append to compressed archives");if(!_)break e}let f=new jn(u);if(!f.cksumValid)break;let x=512*Math.ceil((f.size||0)/512);if(c+x+512>d.size)break;c+=x,t.mtimeCache&&f.mtime&&t.mtimeCache.set(String(f.path),f.mtime)}i=!1,X_(t,n,c,o,e)}finally{if(i)try{at.closeSync(o)}catch{}}},X_=(t,e,n,i,o)=>{let c=new cf(t.file,{fd:i,start:n});e.pipe(c),ey(e,o)},Q_=(t,e)=>{e=Array.from(e);let n=new lo(t),i=(o,c,d)=>{let u=(v,y)=>{v?at.close(o,b=>d(v)):d(null,y)},f=0;if(c===0)return u(null,0);let x=0,m=Buffer.alloc(512),_=(v,y)=>{if(v||y===void 0)return u(v);if(x+=y,x<512&&y)return at.read(o,m,x,m.length-x,f+x,_);if(f===0&&m[0]===31&&m[1]===139)return u(new Error("cannot append to compressed archives"));if(x<512)return u(null,f);let b=new jn(m);if(!b.cksumValid)return u(null,f);let I=512*Math.ceil((b.size??0)/512);if(f+I+512>c||(f+=I+512,f>=c))return u(null,f);t.mtimeCache&&b.mtime&&t.mtimeCache.set(String(b.path),b.mtime),x=0,at.read(o,m,0,512,f,_)};at.read(o,m,0,512,f,_)};return new Promise((o,c)=>{n.on("error",c);let d="r+",u=(f,x)=>{if(f&&f.code==="ENOENT"&&d==="r+")return d="w+",at.open(t.file,d,u);if(f||!x)return c(f);at.fstat(x,(m,_)=>{if(m)return at.close(x,()=>c(m));i(x,_.size,(v,y)=>{if(v)return c(v);let b=new so(t.file,{fd:x,start:y});n.pipe(b),b.on("error",c),b.on("close",o),ty(n,e)})})};at.open(t.file,d,u)})},ey=(t,e)=>{e.forEach(n=>{n.charAt(0)==="@"?Tr({file:Uf.resolve(t.cwd,n.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(n)}),t.end()},ty=async(t,e)=>{for(let n of e)n.charAt(0)==="@"?await Tr({file:Uf.resolve(String(t.cwd),n.slice(1)),noResume:!0,onReadEntry:i=>t.add(i)}):t.add(n);t.end()},vi=Li(Y_,Q_,()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},(t,e)=>{if(!bw(t))throw new TypeError("file is required");if(t.gzip||t.brotli||t.zstd||t.file.endsWith(".br")||t.file.endsWith(".tbr"))throw new TypeError("cannot append to compressed archives");if(!e?.length)throw new TypeError("no paths specified to add/replace")}),bk=Li(vi.syncFile,vi.asyncFile,vi.syncNoFile,vi.asyncNoFile,(t,e=[])=>{vi.validate?.(t,e),ny(t)}),ny=t=>{let e=t.filter;t.mtimeCache||(t.mtimeCache=new Map),t.filter=e?(n,i)=>e(n,i)&&!((t.mtimeCache?.get(n)??i.mtime??0)>(i.mtime??0)):(n,i)=>!((t.mtimeCache?.get(n)??i.mtime??0)>(i.mtime??0))};qt();var xt={PAIR:"_agent/pair",CREATE:"_agent/create",HEALTH:"_agent/health",LIST_SKILLS:"_agent/listSkills",ADD_SKILLS:"_agent/addSkills",REMOVE_SKILLS:"_agent/removeSkills",GET_FILE_TREE:"_agent/getFileTree",GET_FILE_CONTENT:"_agent/getFileContent",DETAIL:"_agent/detail",UPDATE:"_agent/update",DISCONNECT:"_agent/disconnect",SWITCH_MODEL:"_agent/switchModel",GEN_MODEL_TOKEN:"_agent/genModelToken",RESET:"_agent/reset",REPAIR:"_agent/repair",UPGRADE:"_agent/upgrade",DELETE:"_agent/delete",PUBLISH_SKILL:"_agent/publishSkill"};function ho(t){return t?.cozeDeployType==="cloud"?"cloud":"local"}function Gf(t){let e=t?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function xo(t){let e=t?.cozeGroupId?.trim();if(!(!e||e==="0"))return e}function Hf(t){let e=t?.permissionMode;if(typeof e!="string")return;let n=e.trim();return n===""?void 0:n}function qf(t){let{_meta:e,...n}=t;return{stripped:n,meta:e}}function Kn(t){if(!t?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return t.cozeAgentId}Zt();$e();ne();Re();$e();function Pr(t,e){if(ho(t)!=="cloud")throw new k("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function Ni(t){return t.startsWith("http://")||t.startsWith("https://")}function Rr(t){return t.endsWith("/")?t.slice(0,-1):t}import{readFileSync as hT}from"node:fs";import{dirname as pT,join as gT}from"node:path";import{fileURLToPath as wT}from"node:url";var Lt="0.2.7-alpha.103";import{mkdir as _y,rm as c0}from"node:fs/promises";import{join as Ui}from"node:path";Ht();import{readFileSync as ly}from"node:fs";var uy=384;async function Zc(t,e=process.env){let n={};for(let[i,o]of Object.entries(e))typeof o=="string"&&(n[i]=o);await ur(t.agentEnvFile,n,{mode:uy})}function Mi(t){try{let e=JSON.parse(ly(t,"utf8"));return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function $f(t,e,n={},i=o=>o){return{...i({...t,...Mi(e)}),...n}}Ht();function Bi(t){let e=[],n=Object.keys(t).sort();for(let i of n){let o=t[i];o!==void 0&&(fy(o)||e.push(`${i}=${o}`))}return e.length===0?"":`${e.join(`
|
|
92
92
|
`)}
|
|
93
93
|
`}function fy(t){if(t.includes(`
|
|
94
|
-
`)||t.includes("\r")||t.includes("$")||t.includes("#"))return!0;let e=t[0];return e==="'"||e==='"'}
|
|
95
|
-
`)}}function
|
|
94
|
+
`)||t.includes("\r")||t.includes("$")||t.includes("#"))return!0;let e=t[0];return e==="'"||e==='"'}ne();Re();import{homedir as py}from"node:os";import{join as gy}from"node:path";$e();ne();var po="1008033",Vf="1289";var Jf="pbbp2",Zf="https://www.coze.cn",Yf="/api/coze_claw/resource/get_frontier_key",hy="https://www.coze.cn",xy="wss://frontier.coze.cn";function Cr(t){return t??process.env.COZE_BRIDGE_HANDSHAKE_URL??hy}function Xf(t){return t??process.env.COZE_BRIDGE_FRONTIER_URL??xy}function vn(t){let e={},n=t?.ttEnv??process.env.COZE_BRIDGE_TT_ENV,i=t?.usePpe??process.env.COZE_BRIDGE_USE_PPE;return n&&(e["x-tt-env"]=n),i&&(e["x-use-ppe"]=i),e}function zi(t){return t?t.startsWith("boe_")?{ttEnv:t}:{ttEnv:t,usePpe:"1"}:{}}var Fi=q("handshake");async function Yc(t){let e=Cr(t.endpoint),n=t.timeoutMs??1e4,i=`${Rr(e)}${Yf}?aid=${encodeURIComponent(po)}`,o={Authorization:`Bearer ${t.privatecode}`,Accept:"application/json",...vn(t.ppeOverride)},c=new AbortController,d=setTimeout(()=>c.abort(),n);Fi.info("frontier key handshake",{base:e});try{let u=await fetch(i,{method:"GET",headers:o,signal:c.signal}),f=u.headers.get("x-tt-logid")??"",x=u.headers.get("x-tt-trace-id")??"";if(!u.ok){let b=await u.text().catch(()=>"");throw new k("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${u.status} logid=${f}: ${b.slice(0,200)}`)}let m=await u.json();if(m.code!==void 0&&m.code!==0)throw new k("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${m.code} msg=${m.msg??"-"} logid=${f}`);let _=m.data??{},v=typeof _.access_key=="string"&&_.access_key||typeof _.accessKey=="string"&&_.accessKey||void 0,y=typeof _.device_id=="string"&&_.device_id||typeof _.deviceId=="string"&&_.deviceId||void 0;if(!v||!y){let b=JSON.stringify(m).slice(0,500);throw new k("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${f}: ${b}`)}return Fi.info("handshake ok",{remoteDeviceId:y,logid:f,traceId:x}),{accessKey:v,deviceId:y}}catch(u){if(u instanceof k)throw Fi.error("handshake failed (bridge error)",{base:e,message:u.message,code:u.code}),u;if(u.name==="AbortError")throw Fi.warn("handshake timeout",{base:e,timeoutMs:n}),new k("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${n}ms)`,{cause:u});let f=u.cause;throw Fi.error("handshake error",{base:e,message:u instanceof Error?u.message:String(u),errno:f?.code,syscall:f?.syscall,cause:String(u).slice(0,300)}),new k("UPSTREAM_HANDSHAKE_FAILED",String(u),{cause:u})}finally{clearTimeout(d)}}var mo=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",It="auto",go=19e4,Qf=8192;function t0(t){return{model:Xc(t.model)??It,...t.modelToken?{modelToken:t.modelToken}:{}}}function n0(t){return!t||t===It}var my=new Set(["auto","\u81EA\u52A8"]);function Xc(t){let e=t?.trim();if(e)return my.has(e.toLowerCase())?It:e}function r0(t){let e={};if(t.modelToken){e.ANTHROPIC_BASE_URL=mo,e.ANTHROPIC_AUTH_TOKEN=t.modelToken;let n=t.model||It;e.ANTHROPIC_MODEL=n,e.ANTHROPIC_SMALL_FAST_MODEL=n,e.ANTHROPIC_DEFAULT_HAIKU_MODEL=n,e.ANTHROPIC_DEFAULT_OPUS_MODEL=n,e.ANTHROPIC_DEFAULT_SONNET_MODEL=n,e.CLAUDE_CODE_SUBAGENT_MODEL=n,e.CLAUDE_CODE_ATTRIBUTION_HEADER="0",t.modelInfo?.contextWindow&&(e.CLAUDE_CODE_MAX_CONTEXT_TOKENS=String(t.modelInfo.contextWindow)),t.modelInfo?.maxOutput&&(e.CLAUDE_CODE_MAX_OUTPUT_TOKENS=String(t.modelInfo.maxOutput))}else n0(t.model)||(e.ANTHROPIC_MODEL=t.model);return e}function i0(t,e,n){let i={};if(t.modelToken?i.model=t.model||It:n0(t.model)||(i.model=t.model),t.modelToken){let o={name:"coze",base_url:`${mo}/v1`,env_key:"CODEX_API_KEY",wire_api:"responses",requires_openai_auth:!1,supports_websockets:!1},c=wo(e,n);Object.keys(c).length>0&&(o.http_headers=c),i.model_providers={coze:o},i.model_context_window=t.modelInfo?.contextWindow??go}return Object.keys(i).length===0?{}:{CODEX_CONFIG:JSON.stringify(i),...t.modelToken?{MODEL_PROVIDER:"coze"}:{}}}function s0(t){return t.modelToken?{CODEX_API_KEY:t.modelToken,OPENAI_API_KEY:t.modelToken}:{}}function wo(t,e){let{ttEnv:n,usePpe:i}=zi(t),o={};return n&&(o["x-tt-env"]=n),i&&(o["x-use-ppe"]=i),e&&(o["x-mock-scenario"]=e),o}function o0(t,e,n){if(!t.modelToken)return{};let i=wo(e,n);return Object.keys(i).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(i).map(([c,d])=>`${c}:${d}`).join(`
|
|
95
|
+
`)}}function Qc(t){return`coze-session-${t.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function ed(t){return t.model||It}function e0(t,e,n,i){return{id:t,name:t,reasoning:!1,input:e,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:n,maxTokens:i,api:"openai-completions"}}function a0(t,e,n,i){if(!t.modelToken)return null;let o=ed(t),c=wo(e,n),d=["text"];t.modelInfo?.capabilities?.image===!0&&d.push("image");let u=[e0(o,d,t.modelInfo?.contextWindow??go,t.modelInfo?.maxOutput??Qf)],f=new Set([o]);for(let m of i??[])!m||f.has(m)||(f.add(m),u.push(e0(m,["text"],go,Qf)));let x={baseUrl:`${mo}/v1`,api:"openai-completions",apiKey:t.modelToken,models:u};return Object.keys(c).length>0&&(x.headers=c),x}function wy(t){if(t!==void 0)return t?"auto":"text"}function td(t,e,n){let i=wo(e,n),o=t.modelInfo?.contextWindow??go,c=t.model||It,d=["model:"," provider: custom",` default: ${JSON.stringify(c)}`,` base_url: ${mo}/v1`,` context_length: ${o}`];if(t.modelInfo?.maxOutput&&d.push(` max_tokens: ${t.modelInfo.maxOutput}`),t.modelToken&&d.push(` api_key: ${JSON.stringify(t.modelToken)}`),Object.keys(i).length>0){d.push(" default_headers:");for(let[f,x]of Object.entries(i))d.push(` ${f}: ${JSON.stringify(x)}`)}d.push("compression:"),d.push(" threshold: 0.8"),d.push("approvals:"),d.push(` mode: ${JSON.stringify("off")}`),d.push(` cron_mode: ${JSON.stringify("approve")}`);let u=wy(t.modelInfo?.capabilities?.image);return u&&(d.push("agent:"),d.push(` image_input_mode: ${JSON.stringify(u)}`)),d.push("skills:"),d.push(" external_dirs:"),d.push(` - ${gy(py(),".hermes","skills")}`),`${d.join(`
|
|
96
96
|
`)}
|
|
97
|
-
`}var $n=
|
|
98
|
-
`).slice(1,6).join(" | ")}),await
|
|
99
|
-
`).slice(1,6).join(" | ")}),await
|
|
100
|
-
`).slice(1,6).join(" | ")});let i=await
|
|
101
|
-
---`,3);if(e<0)return{};let
|
|
102
|
-
`)){let c=/^\s*(name|description)\s*:\s*(.+?)\s*$/.exec(o);if(!c||!c[2])continue;let d=c[1],u=c[2].trim();(u.startsWith('"')&&u.endsWith('"')||u.startsWith("'")&&u.endsWith("'"))&&(u=u.slice(1,-1)),u&&(i[d]=u)}return i}async function I0(t,e,r,i){let o=await g0(e,{withFileTypes:!0}).catch(()=>null);if(!o)return[];let c=[];for(let d of o){let u=d.isDirectory();if(!u&&d.isSymbolicLink()&&(u=!!(await fd(le(e,d.name)).catch(()=>null))?.isDirectory()),!u)continue;let f=d.name,x=le(r,f),g=le(e,f,"SKILL.md"),w=await yo(g,{encoding:"utf8"}).catch(()=>null);if(w===null)continue;let S=S0(w);c.push({relPath:x,skill:{skillId:v0(t,x),skillName:S.name||f,...S.description?{description:S.description}:{},...i?{isGlobal:!0}:{}}})}return c}async function A0(t,e,r,i){let{base:o,subdir:c}=Or(r,t,e,i);return I0(t,le(o,c),c,!1)}async function k0(t,e){let r=[],i=new Set;for(let o of b0(e)){let c=await I0(t,o,o,!0);for(let d of c)i.has(d.relPath)||(i.add(d.relPath),r.push(d))}return r}var Ly=3e4,Ny=50*1024*1024,m0=10*1024*1024,Dr=3e4;async function bo(t){let{agentId:e,workspace:r,framework:i,skill:o,paths:c}=t;if(!o.skillName)throw new k("IPC_BAD_REQUEST","skill missing skillName");let d=typeof o.content=="string"&&o.content.length>0,u=typeof o.downloadUrl=="string"&&o.downloadUrl.length>0;if(!d&&!u)throw new k("IPC_BAD_REQUEST",`skill ${o.skillId} missing both content and downloadUrl`);let f=E0(o.skillName),{base:x,subdir:g}=Or(i,e,r,c),w=le(g,f),S=le(x,w);if(await ad(S,{recursive:!0}),d){let v=Buffer.from(o.content,"utf8");Ui(v.length),await dd(le(S,"SKILL.md"),v,"utf8")}else{let v=await Fy(o.downloadUrl);Uy(v)?await jy(v,S):Gy(v)?await Hy(v,S):await dd(le(S,"SKILL.md"),v.toString("utf8"),"utf8")}let y={skillId:o.skillId,skillName:o.skillName,relPath:w,installedAt:Date.now(),...o.description?{description:o.description}:{},...o.icon?{icon:o.icon}:{},...o.version?{version:o.version}:{},...o.downloadUrl?{downloadUrl:o.downloadUrl}:{},...o.config?{config:o.config}:{},...o.builtin?{builtin:o.builtin}:{}};return ne.info("skill installed",{agentId:e,skillId:o.skillId,skillName:o.skillName,relPath:w,source:d?"content":"downloadUrl"}),y}function vo(t,e,r){let i=e.get(r.skillId);if(i!==void 0){t[i]=r;return}e.set(r.skillId,t.length),t.push(r)}function My(t){return{skillId:t.skillId,skillName:t.skillName,...t.description?{description:t.description}:{},...t.icon?{icon:t.icon}:{},...t.version?{version:t.version}:{},...t.config?{config:t.config}:{},...t.builtin?{builtin:t.builtin}:{}}}function By(t){return{skillId:t.skillId,skillName:t.skillName,...t.downloadUrl?{downloadUrl:t.downloadUrl}:{},...t.description?{description:t.description}:{},...t.icon?{icon:t.icon}:{},...t.version?{version:t.version}:{},...t.config?{config:t.config}:{},...t.builtin?{builtin:t.builtin}:{}}}async function T0(t,e){let r=await ve(t,e);if(!r)return{status:"skipped",count:0};if(r.disconnectedAt)return{status:"skipped",count:0};let i=Nt,o=r.skillsRefreshedForVersion;if(o===i)return{status:"noop",count:0};if(!o)return r.skillsRefreshedForVersion=i,await ze(r,e),{status:"seeded",count:0};let c=[...r.skills??[]],d=new Map(c.map((w,S)=>[w.skillId,S])),u=c.filter(w=>w.builtin===!0&&!!w.downloadUrl);if(u.length===0)return r.skillsRefreshedForVersion=i,await ze(r,e),{status:"noop",count:0};let f=0,x=0,{base:g}=Or(r.framework,t,r.workspace,e);ne.warn("[AUDIT] refreshBuiltinSkills triggered (version bump)",{src:"agent-handlers.refreshAgentBuiltinSkillsOnUpgrade",agentId:t,framework:r.framework,prev:o,current:i,skillBase:g,builtinCount:u.length,builtinRelPaths:u.map(w=>w.relPath)});for(let w of u)try{let S=le(g,w.relPath);ne.warn("[AUDIT] ABOUT TO RM builtin skill dir (refreshBuiltinSkills)",{src:"agent-handlers.refreshAgentBuiltinSkillsOnUpgrade",agentId:t,skillId:w.skillId,relPath:w.relPath,rmTarget:S}),await cd(S,{recursive:!0,force:!0});let y=await bo({agentId:t,workspace:r.workspace,framework:r.framework,skill:By(w),...e?{paths:e}:{}});vo(c,d,y),f+=1}catch(S){x+=1,ne.warn("refresh builtin skill failed (skipping)",{agentId:t,skillId:w.skillId,skillName:w.skillName,err:String(S)})}return r.skills=c,x===0&&(r.skillsRefreshedForVersion=i),await ze(r,e),ne.info("builtin skills refreshed after bridge upgrade",{agentId:t,from:o,to:i,ok:f,failed:x}),{status:"refreshed",count:f}}async function Fy(t){if(!t)throw new k("IPC_BAD_REQUEST","skill missing downloadUrl");if(t.startsWith("data:")){let e=Math.floor(t.length*3/4);Ui(e);let r=zy(t);return Ui(r.length),r}if(t.startsWith("file:")){let e=new URL(t).pathname,r=await yo(e);return Ui(r.length),r}if(Li(t)){let e=new AbortController,r=setTimeout(()=>e.abort(),Ly);try{let i=await fetch(t,{signal:e.signal});if(!i.ok)throw new k("IPC_BAD_REQUEST",`fetch skill failed HTTP ${i.status} ${t}`);let o=await i.arrayBuffer();return Ui(o.byteLength),Buffer.from(o)}finally{clearTimeout(r)}}throw new k("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${t.slice(0,80)}`)}function Ui(t){if(t>Ny)throw new k("IPC_BAD_REQUEST",`skill too large: ${t} bytes`)}function zy(t){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(t);if(!e)throw new k("IPC_BAD_REQUEST","bad data URL");let r=!!e[2],i=e[3]??"";return r?Buffer.from(i,"base64"):Buffer.from(decodeURIComponent(i),"utf8")}function Uy(t){return t.length>=2&&t[0]===31&&t[1]===139}function Gy(t){if(t.length<4||t[0]!==80||t[1]!==75)return!1;let e=t[2],r=t[3];return e===3&&r===4||e===5&&r===6}function ud(t){return t==="__MACOSX"||t.startsWith("__MACOSX/")}async function Hy(t,e){let r,i;try{r=new xd.default(t),i=r.getEntries()}catch(d){throw new k("IPC_BAD_REQUEST",`zip parse failed: ${d.message}`,{cause:d})}for(let d of i){let u=d.entryName;if(!u||ud(u))continue;if(u.startsWith("/")||/^[A-Za-z]:[\\/]/.test(u))throw new k("IPC_BAD_REQUEST",`zip entry absolute path: ${u}`);if(u.split(/[/\\]/).some(x=>x===".."))throw new k("IPC_BAD_REQUEST",`zip entry contains '..' (traversal): ${u}`);let f=d.header.attr>>>16&61440;if(f!==0&&f!==32768&&f!==16384)throw new k("IPC_BAD_REQUEST",`zip entry kind 0x${f.toString(16)} not allowed (symlink/hardlink/special): ${u}`)}let o=qy(i),c=ld(e);for(let d of i){if(ud(d.entryName))continue;let u=d.entryName;if(o&&u.startsWith(o)&&(u=u.slice(o.length)),!u)continue;let f=ld(e,u),x=hd(c,f);if(x.startsWith("..")||x==="..")throw new k("IPC_BAD_REQUEST",`zip entry escapes destDir: ${u}`);if(d.isDirectory){await ad(f,{recursive:!0});continue}await ad(by(f),{recursive:!0});let g;try{g=d.getData()}catch(w){throw new k("IPC_BAD_REQUEST",`zip entry getData failed (${d.entryName}): ${w.message}`,{cause:w})}await dd(f,g)}}function qy(t){let e;for(let r of t){let i=r.entryName;if(!i||ud(i))continue;let o=i.indexOf("/");if(o<=0)return;let c=i.slice(0,o+1);if(e===void 0)e=c;else if(e!==c)return}return e}async function jy(t,e){await Wy(t);let r=Uf({cwd:e,strip:1}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new k("IPC_BAD_REQUEST",`tar extract timeout (${Dr}ms)`))},Dr);try{await y0(_0.from(t),r)}catch(c){throw c instanceof k?c:i?new k("IPC_BAD_REQUEST",`tar extract timeout (${Dr}ms)`):new k("IPC_BAD_REQUEST",`tar extract failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}}async function Wy(t){let e=[],r=Tr({onReadEntry:c=>{let d=c.path,u=c.type;if(u!=="File"&&u!=="Directory"){e.push(`tar entry kind '${u}' not allowed (symlink/hardlink/special): ${d.slice(0,100)}`);return}if(d.startsWith("/")||d.startsWith("\\")||/^[a-zA-Z]:[\\/]/.test(d)){e.push(`tar entry absolute path: ${d}`);return}d.split(/[/\\]/).some(x=>x==="..")&&e.push(`tar entry contains '..': ${d}`)}}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new k("IPC_BAD_REQUEST",`tar list timeout (${Dr}ms)`))},Dr);try{await y0(_0.from(t),r)}catch(c){throw i?new k("IPC_BAD_REQUEST",`tar list timeout (${Dr}ms)`):new k("IPC_BAD_REQUEST",`tar list failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}if(e.length>0)throw new k("IPC_BAD_REQUEST",e[0]??"tar entry validation failed")}var Ky=5e3;async function $y(t,e,r,i){return R0(t,e,r,i,{count:0})}async function R0(t,e,r,i,o){if(i<=0)return[];let c;try{c=await g0(e,{withFileTypes:!0})}catch{return[]}let d=[];for(let u of c){if(Ay.has(u.name)||u.isSymbolicLink())continue;if(o.count>=Ky){d.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let f=le(e,u.name),x=vy(le(r,u.name)),g=null;try{g=await od(f)}catch{continue}if(g.isSymbolicLink())continue;o.count++;let w={name:u.name,path:C0(hd(t,f)),isDir:g.isDirectory(),size:g.size,modifiedAt:Math.floor(g.mtimeMs)};g.isDirectory()&&i>1&&(w.children=await R0(t,f,x,i-1,o)),d.push(w)}return d.sort((u,f)=>u.isDir!==f.isDir?u.isDir?-1:1:u.name.localeCompare(f.name)),d}function Yy(t){return!t||t<=0?Sy:Math.min(t,Iy)}function Vy(t){if(!t||t==="."||t==="/")return".";let e=t.split(/[/\\]/);return e[e.length-1]||"."}function C0(t){return t.split(w0).join("/")}te();var Sn=G("agent-health-reporter"),Jy=1e4,Zy=3,Gi=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??Jy,this.livenessFailureThreshold=e.livenessFailureThreshold??Zy}opts;timer=null;inFlight=!1;unsubscribeRegister=null;intervalMs;livenessFailureThreshold;consecutiveFailures=0;isLivenessLost(){return this.consecutiveFailures>=this.livenessFailureThreshold}start(){this.timer||(this.timer=setInterval(()=>{this.tick()},this.intervalMs),this.timer.unref?.(),this.unsubscribeRegister=this.opts.core.onAgentRegister(()=>{this.tick()}),Sn.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),Sn.info("heartbeat stopped"))}async tick(){if(this.inFlight){Sn.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){this.consecutiveFailures=0,Sn.debug("deviceId not available, skip tick (\u5C1A\u672A pair)");return}this.inFlight=!0;try{let r=[];for(let d of this.opts.core.agents.values()){let u=Xy(d);if(!u)continue;let f={agentId:d.agentId,status:u};d.patToken&&(f.patToken=d.patToken),d.accountId&&(f.accountId=d.accountId),r.push(f)}if(r.length===0){this.consecutiveFailures=0;return}let i={agents:r,bridgeVersion:Nt,_meta:{cozeDeviceId:e}},o;try{o=await this.opts.core.sendRequest("_agent/health",i,5e3),this.consecutiveFailures=0}catch(d){this.consecutiveFailures+=1,Sn.warn("heartbeat batch send failed",{count:r.length,consecutiveFailures:this.consecutiveFailures,err:String(d)})}let c=o?.authFailures;if(c&&c.length>0&&(Sn.warn("heartbeat received authFailures from cloud",{count:c.length,agentIds:c.map(d=>d.agentId)}),this.opts.onAuthFailures))try{await this.opts.onAuthFailures(c)}catch(d){Sn.warn("onAuthFailures callback failed (ignored)",{err:String(d)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(r){Sn.warn("onTickEnd hook failed",{err:String(r)})}}};function Xy(t){return t.status==="error"?"error":t.activeTriggers.size>0?"busy":t.status==="ok"?"online":null}jt();import{mkdir as wd,rm as jE,stat as WE}from"node:fs/promises";import{homedir as KE}from"node:os";import{join as ah}from"node:path";dn();import{existsSync as dE}from"node:fs";import{release as lE}from"node:os";import{basename as uE,isAbsolute as fE}from"node:path";function Hi(t,e,r){return r===void 0?{jsonrpc:"2.0",id:t,method:e}:{jsonrpc:"2.0",id:t,method:e,params:r}}function Lr(t,e){return e===void 0?{jsonrpc:"2.0",method:t}:{jsonrpc:"2.0",method:t,params:e}}function Nr(t,e){return{jsonrpc:"2.0",id:t,result:e}}function In(t,e){return{jsonrpc:"2.0",id:t,error:e}}Ke();var So=class extends Error{code;data;constructor(e){super(`JSON-RPC error code=${e.code} ${e.message}`),this.name="RemoteRpcError",this.code=e.code,e.data!==void 0&&(this.data=e.data)}},Z={PARSE_ERROR:-32700,INVALID_REQUEST:-32600,METHOD_NOT_FOUND:-32601,INVALID_PARAMS:-32602,INTERNAL_ERROR:-32603,AGENT_NOT_FOUND:-32001,AGENT_BUSY:-32002,AGENT_TIMEOUT:-32003,AGENT_SPAWN_FAILED:-32004,OPERATION_NOT_ALLOWED_FOR_LOCAL:-32005,AGENT_DISCONNECTED:-32006,MODEL_TOKEN_GEN_FAILED:-32009,PATH_OUTSIDE_WORKSPACE:-32010,FILE_TOO_LARGE:-32011,UNSUPPORTED_MIME:-32012,UPLOAD_FAILED:-32013,UPSTREAM_NOT_READY:-32014,AGENT_FRAME_IDLE_TIMEOUT:-32016,MODEL_MODALITY_UNSUPPORTED:-32017,AGENT_DEPENDENCY_INSTALL_FAILED:-32018,AGENT_APPROVAL_TIMEOUT:-32019,AGENT_TURN_ABORTED:-32020,AGENT_ENV_NOT_READY:-32021,SKILL_NOT_FOUND:-32022,SKILL_ZIP_TOO_LARGE:-32023,OPERATION_NOT_ALLOWED_FOR_CLOUD:-32024};function P0(t){return"method"in t&&"id"in t&&t.id!==void 0}function D0(t){return"method"in t&&!("id"in t)}function Io(t){return!("method"in t)&&"id"in t}var Qy={AGENT_NOT_FOUND:Z.AGENT_NOT_FOUND,AGENT_BUSY:Z.AGENT_BUSY,AGENT_DISCONNECTED:Z.AGENT_DISCONNECTED,AGENT_TIMEOUT:Z.AGENT_TIMEOUT,AGENT_FRAME_IDLE_TIMEOUT:Z.AGENT_FRAME_IDLE_TIMEOUT,AGENT_SPAWN_FAILED:Z.AGENT_SPAWN_FAILED,AGENT_PROTOCOL_ERROR:Z.INTERNAL_ERROR,BRIDGE_CONFIG_INVALID:Z.INTERNAL_ERROR,BRIDGE_INTERNAL:Z.INTERNAL_ERROR,IPC_AUTH_FAILED:Z.INTERNAL_ERROR,IPC_BAD_REQUEST:Z.INVALID_REQUEST,METHOD_NOT_FOUND:Z.METHOD_NOT_FOUND,MODEL_TOKEN_GEN_FAILED:Z.MODEL_TOKEN_GEN_FAILED,MODEL_MODALITY_UNSUPPORTED:Z.MODEL_MODALITY_UNSUPPORTED,OPERATION_NOT_ALLOWED_FOR_LOCAL:Z.OPERATION_NOT_ALLOWED_FOR_LOCAL,OPERATION_NOT_ALLOWED_FOR_CLOUD:Z.OPERATION_NOT_ALLOWED_FOR_CLOUD,UPSTREAM_DISCONNECTED:Z.INTERNAL_ERROR,UPSTREAM_HANDSHAKE_FAILED:Z.INTERNAL_ERROR,PATH_OUTSIDE_WORKSPACE:Z.PATH_OUTSIDE_WORKSPACE,FILE_TOO_LARGE:Z.FILE_TOO_LARGE,UNSUPPORTED_MIME:Z.UNSUPPORTED_MIME,UPLOAD_FAILED:Z.UPLOAD_FAILED,UPSTREAM_NOT_READY:Z.UPSTREAM_NOT_READY,AGENT_DEPENDENCY_INSTALL_FAILED:Z.AGENT_DEPENDENCY_INSTALL_FAILED,AGENT_APPROVAL_TIMEOUT:Z.AGENT_APPROVAL_TIMEOUT,AGENT_TURN_ABORTED:Z.AGENT_TURN_ABORTED,AGENT_ENV_NOT_READY:Z.AGENT_ENV_NOT_READY,SKILL_NOT_FOUND:Z.SKILL_NOT_FOUND,SKILL_ZIP_TOO_LARGE:Z.SKILL_ZIP_TOO_LARGE};function eE(t){if(t!=null)return t instanceof Error?{name:t.name,message:qi(t.message)}:typeof t=="string"?qi(t):typeof t=="object"?nE(t):t}var tE=[[/\/Users\/[^/\s'"`)]+/g,"/Users/<redacted>"],[/\/home\/[^/\s'"`)]+/g,"/home/<redacted>"],[/[A-Za-z]:\\Users\\[^\\\s'"`)]+/g,"C:\\Users\\<redacted>"],[/(Bearer|Token|Authorization:)\s+[\w._-]+/gi,"$1 <redacted>"],[/\b(sk|pat|ak)[-_][A-Za-z0-9_-]{20,}\b/g,"<redacted-key>"]];function qi(t){let e=t;for(let[r,i]of tE)e=e.replace(r,i);return e}function nE(t){let e={};for(let[r,i]of Object.entries(t))typeof i=="string"?e[r]=qi(i):e[r]=i;return e}function ji(t){if(t instanceof k){let e=eE(t.cause),r={bridgeCode:t.code,retriable:t.retriable};return e!==void 0&&(r.cause=e),e&&typeof e=="object"&&"reason"in e&&typeof e.reason=="string"&&(r.reason=e.reason),{code:Qy[t.code]??Z.INTERNAL_ERROR,message:qi(t.message),data:r}}return{code:Z.INTERNAL_ERROR,message:qi(t instanceof Error?t.message:String(t))}}function O0(t){let e=t.data,r=e?.bridgeCode??"AGENT_PROTOCOL_ERROR",i=!!e&&typeof e.message=="string"&&!!e.message,o=i?e?.message:t.message,c=t.data;if(i&&e){let{message:d,...u}=e;c=u}return new k(r,o,{retriable:e?.retriable??!1,cause:c})}function N0(t){return`${JSON.stringify(t)}
|
|
103
|
-
`}var
|
|
104
|
-
`);this.buffer=
|
|
105
|
-
`).map(o=>Number.parseInt(o.trim(),10)).filter(o=>Number.isFinite(o)&&o>0&&o!==i)}async function H0(t,e){if(t.length===0)return;let r=e?.killFn??Ki,i=e?.isAliveFn??Wi,o=e?.sleepFn??(u=>new Promise(f=>setTimeout(f,u))),c=e?.graceMs??3e3,d=e?.pollMs??100;for(let u of t)r(u,"SIGTERM");for(let u=0;u<c&&t.some(f=>i(f));u+=d)await o(Math.min(d,c-u));for(let u of t)i(u)&&r(u,"SIGKILL")}var cE=[{reason:"openclaw_scope_approval_pending",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/scope upgrade pending approval/i,message:"openclaw \u9700\u8981\u4F60\u5728\u672C\u673A\u6279\u51C6\u4E00\u6B21\u6743\u9650\u5347\u7EA7 (scope upgrade)\uFF0C\u8BF7\u5728\u672C\u673A openclaw \u5B8C\u6210\u6388\u6743\u540E\u91CD\u8BD5"},{reason:"openclaw_pairing_required",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/pairing required/i,message:"openclaw \u5C1A\u672A\u5B8C\u6210\u914D\u5BF9\uFF0C\u8BF7\u5148\u5728\u672C\u673A\u5B8C\u6210 openclaw \u914D\u5BF9\u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_token_unavailable",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/gateway\.auth\.token.*(unavailable|secret reference)/i,message:"openclaw gateway token \u914D\u7F6E\u4E0D\u53EF\u7528 (\u914D\u6210\u4E86 secret \u5F15\u7528\u4F46\u5F53\u524D\u8DEF\u5F84\u53D6\u4E0D\u5230)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A openclaw \u7684 gateway.auth.token \u914D\u7F6E"},{reason:"openclaw_version_mismatch",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/protocol mismatch/i,message:"openclaw \u7248\u672C\u4E0E\u672C\u673A gateway \u4E0D\u517C\u5BB9 (protocol mismatch)\uFF0C\u8BF7\u5347\u7EA7\u672C\u673A openclaw \u5230\u6700\u65B0\u7248\u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_not_ready",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/gateway closed (before ready|\(\d+\))/i,message:"openclaw gateway \u672A\u5C31\u7EEA (\u53EF\u80FD\u6B63\u5728\u542F\u52A8)\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"},{reason:"openclaw_config_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/OpenClaw config is invalid|Config invalid|Invalid config at|config was written by version/i,message:"\u4F60\u7684\u672C\u673A openclaw \u914D\u7F6E\u975E\u6CD5 (~/.openclaw/openclaw.json)\uFF0C\u8BF7\u8FD0\u884C `openclaw doctor --fix` \u6216 `openclaw config validate` \u4FEE\u590D\u540E\u91CD\u8BD5"},{reason:"openclaw_tls_self_signed",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/self-signed certificate/i,message:"openclaw \u8FDE\u63A5\u88AB\u81EA\u7B7E\u8BC1\u4E66/\u4F01\u4E1A\u4EE3\u7406\u62E6\u622A (self-signed certificate)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A\u7F51\u7EDC/\u4EE3\u7406\u6216\u8BC1\u4E66\u914D\u7F6E\u540E\u91CD\u8BD5"},{reason:"openclaw_node_binary_not_found",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/\[qclaw-cli\] Error: (Node binary not found|QCLAW_CLI_NODE_BINARY not set)/i,message:"\u672C\u673A\u627E\u4E0D\u5230 node \u4E8C\u8FDB\u5236 (qclaw \u542F\u52A8\u5931\u8D25)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A Node \u5B89\u88C5\u4E0E PATH \u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_unavailable",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/ECONNREFUSED|\[object ErrorEvent\]|gateway connect failed|gateway (not connected|disconnected)/i,message:"openclaw gateway \u672A\u8FD0\u884C/\u672A\u8FDE\u63A5 (\u8FDE\u63A5\u672C\u673A gateway \u88AB\u62D2\u6216\u4F1A\u8BDD\u671F\u95F4\u65AD\u5F00)\uFF0C\u8BF7\u5728\u672C\u673A\u542F\u52A8 openclaw gateway \u540E\u91CD\u8BD5"},{reason:"openclaw_shim_bug",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["openclaw"],match:/openclaw-shim\/bin\/openclaw.*unbound variable/i,message:"openclaw \u542F\u52A8 shim \u811A\u672C\u5F02\u5E38 (unbound variable)\uFF0C\u8BF7\u53CD\u9988\u73AF\u5883\u7EF4\u62A4\u65B9\u4FEE\u590D shim"},{reason:"codex_user_config_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/error loading config:.*config\.toml|model_catalog_json|wire_api/i,message:"\u4F60\u7684\u672C\u673A ~/.codex/config.toml \u914D\u7F6E\u6709\u8BEF\uFF0C\u8BF7\u6309 codex \u62A5\u9519\u63D0\u793A\u4FEE\u6B63\u540E\u91CD\u8BD5"},{reason:"codex_provider_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/error loading config: Model provider .* not found/i,message:"\u4F60\u7684\u672C\u673A codex \u914D\u7F6E\u5F15\u7528\u4E86\u4E0D\u5B58\u5728\u7684 model provider\uFF0C\u8BF7\u4FEE\u6B63 ~/.codex \u914D\u7F6E\u540E\u91CD\u8BD5"},{reason:"codex_path_update_failed",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/could not update PATH[\s\S]*Operation not permitted/i,message:"codex \u56E0\u672C\u673A\u6743\u9650\u9650\u5236\u65E0\u6CD5\u66F4\u65B0 PATH/\u8BFB\u53D6\u914D\u7F6E (Operation not permitted)\uFF0C\u8BF7\u68C0\u67E5 ~/.codex \u76EE\u5F55\u6743\u9650\u6216\u91CD\u65B0\u6388\u4E88\u7EC8\u7AEF\u5B8C\u5168\u78C1\u76D8\u8BBF\u95EE\u540E\u91CD\u8BD5"},{reason:"node_version_too_old",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/import\.meta\.resolve is not a function|\.resolve is not a function/i,message:"\u672C\u673A Node \u7248\u672C\u8FC7\u4F4E (codex ACP \u9700\u8981 import.meta.resolve)\uFF0C\u8BF7\u5347\u7EA7 Node \u5230 \u2265 20 \u540E\u91CD\u8BD5"},{reason:"codex_acp_exec_failed",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["codex"],match:/Failed to execute[\s\S]*codex-acp|spawnSync[\s\S]*codex-acp/i,message:"codex ACP \u4E8C\u8FDB\u5236\u6267\u884C\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect \u89E6\u53D1\u4F9D\u8D56\u5B89\u88C5"},{reason:"codex_platform_binary_missing",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["codex"],match:/Failed to locate @zed-industries\/codex-acp|optional dependency was not installed/i,message:"codex ACP \u4F9D\u8D56\u7684\u5E73\u53F0\u4E8C\u8FDB\u5236\u7F3A\u5931\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect \u89E6\u53D1\u4F9D\u8D56\u5B89\u88C5"},{reason:"acp_module_missing",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["claude-code","codex"],match:/Cannot find (module|package)[^\n]*node_modules[\\/]@(agentclientprotocol[\\/](claude-agent-acp|codex-acp)|openai[\\/]codex|zed-industries[\\/]codex-acp)|Cannot find package ['"]@openai[\\/]codex['"][\s\S]*node_modules[\\/]@agentclientprotocol[\\/]codex-acp/i,message:"ACP \u4F9D\u8D56\u672A\u6B63\u786E\u5B89\u88C5 (wrapper \u5165\u53E3\u7F3A\u5931)\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect \u89E6\u53D1\u4F9D\u8D56\u91CD\u88C5"},{reason:"node_version_too_old",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["claude-code","openclaw"],match:/import .* with \{ type: ["']json["'] \}|import assertion|import attribute|openclaw\.mjs[\s\S]*Unexpected token '\.'/i,message:"\u672C\u673A Node \u7248\u672C\u8FC7\u4F4E (ACP \u9700\u8981\u8F83\u65B0 Node \u624D\u652F\u6301 import attributes / \u53EF\u9009\u94FE)\uFF0C\u8BF7\u5347\u7EA7 Node \u5230 \u2265 20.10 \u540E\u91CD\u8BD5"},{reason:"acp_cmd_misexec",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["claude-code"],match:/claude-agent-acp\.cmd.*@ECHO off|\.cmd:\d+/i,message:"claude ACP wrapper \u542F\u52A8\u65B9\u5F0F\u5F02\u5E38 (Windows .cmd \u88AB\u8BEF\u5F53\u811A\u672C\u6267\u884C)\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect"},{reason:"hermes_provider_not_configured",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["hermes"],match:/(no.*openai.*provider|OPENAI_API_KEY.*(not set|missing)|(provider|model).*(not configured|misconfigured)|hermes.*setup.*required)/i,message:"hermes provider/API key \u672A\u914D\u7F6E\u597D, \u8BF7\u68C0\u67E5 <HERMES_HOME>/config.yaml + .env \u540E\u91CD\u8BD5"},{reason:"prompt_too_long",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["claude-code"],match:/Prompt is too long|bad request: failed to read body: length limit exceeded/i,message:"\u672C\u8F6E\u8F93\u5165\u8FC7\u957F\uFF0C\u8D85\u8FC7\u6A21\u578B\u4E0A\u4E0B\u6587\u4E0A\u9650\uFF0C\u8BF7\u7CBE\u7B80\u8F93\u5165\u6216\u5F00\u542F\u65B0\u4F1A\u8BDD\u540E\u91CD\u8BD5"}];function q0(t,e){if(!e)return null;for(let r of cE)if(!(r.frameworks&&!r.frameworks.includes(t))&&r.match.test(e))return{bridgeCode:r.bridgeCode,reason:r.reason,message:r.message};return null}function j0(t,e){return q0(t,e)}function W0(t,e){return q0(t,e)}function Fr(t,e,r){return!e&&r.firstUpdateMs>0&&t<r.firstUpdateMs?Math.max(1,r.firstUpdateMs-t):t<r.phase2GateMs?Math.max(1,r.phase2GateMs-t):Math.max(1,r.livenessWindowMs)}function K0(t,e,r){let o=r-t.armedAt-t.expectedIntervalMs;if(o>e.suspendThresholdMs){let x=t.suspendedMs+o,g=r-t.startedAt-x;return{action:"suspend",suspendedDeltaMs:o,rearmMs:Fr(g,t.firstFrameSeen,e)}}let c=r-t.startedAt-t.suspendedMs,d=t.awaitingApproval?e.approvalMaxMs:e.absoluteMaxMs;return c>=d?{action:"reject-backstop",awaitingApproval:t.awaitingApproval}:t.firstFrameSeen?c<e.phase2GateMs?{action:"continue",rearmMs:Fr(c,!0,e)}:r-t.lastActivityAt<e.livenessWindowMs||t.hasActiveTool||t.awaitingApproval?{action:"continue",rearmMs:Fr(c,!0,e)}:{action:"reject-idle"}:e.firstUpdateMs>0&&c>=e.firstUpdateMs&&!t.awaitingApproval?{action:"reject-idle"}:{action:"continue",rearmMs:Fr(c,!1,e)}}var $0=Ve("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),hE=200,xE=40,pE=Ve("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),mE=Ve("COZE_BRIDGE_SESSION_PROMPT_IDLE_MS",600*1e3),gE=Ve("COZE_BRIDGE_SESSION_PROMPT_ABSOLUTE_MAX_MS",7200*1e3),wE=Ve("COZE_BRIDGE_SUSPEND_THRESHOLD_MS",60*1e3),_E=Ve("COZE_BRIDGE_SESSION_PROMPT_FIRST_UPDATE_MS",600*1e3),yE=Ve("COZE_BRIDGE_SESSION_PROMPT_APPROVAL_MAX_MS",1440*60*1e3),Y0=500;function EE(t){try{let e=JSON.stringify(t);return e===void 0||e.length<=Y0?t:`${e.slice(0,Y0)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function bE(t){let e=[];typeof t.message=="string"&&e.push(t.message);let{data:r}=t;if(typeof r=="string")e.push(r);else if(r&&typeof r=="object")try{e.push(JSON.stringify(r))}catch{}return e.join(" ")}function V0(t){try{return dE(t)}catch{return}}function vE(t,e){return{platform:process.platform,osRelease:lE(),code:t.code,errno:t.errno,syscall:t.syscall,errPath:t.path,command:e.command,commandExists:fE(e.command)?V0(e.command):void 0,cwd:e.cwd,cwdExists:V0(e.cwd),envKeys:e.envKeys}}function SE(t,e){return`${t.message} [diag: platform=${e.platform} os=${e.osRelease} code=${e.code} errno=${e.errno} syscall=${e.syscall} cmd=${uE(e.command)} cmdExists=${e.commandExists} cwdExists=${e.cwdExists} envKeys=${e.envKeys}]`}var pt=class{constructor(e){this.opts=e;this.log=G(`downstream.${this.constructor.name}`,this.opts.agentId),this.decoder=new Ao({onError:r=>this.log.warn("decode line failed",{line:r.line})})}opts;child;decoder;pending=new Map;inflightAgentRequests=new Map;idAllocator=new Mr;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stopReason;stderrRing=[];now=Date.now;sanitizeEnv(e){return e}async start(){if(this.child)throw new k("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",r=Yf(process.env,this.opts.agentEnvFile??J().agentEnvFile,this.opts.env,o=>this.sanitizeEnv(o)),i=st(this.opts.command,this.opts.args,{cwd:this.opts.cwd,env:r,stdio:["pipe","pipe","pipe"],detached:e});this.child=i,F0(i.pid),i.stdout?.setEncoding("utf8"),i.stdout?.on("data",o=>{try{for(let c of this.decoder.push(o))this.dispatch(c)}catch(c){this.log.warn("stdout dispatch threw, swallowed to keep daemon alive",{err:String(c)})}}),i.stderr?.setEncoding("utf8"),i.stderr?.on("data",o=>{let c=o.trimEnd();this.stderrRing.push(c),this.stderrRing.length>hE&&this.stderrRing.shift(),this.log.debug("stderr",{text:c})}),i.stdin?.on("error",o=>{this.log.warn("child stdin error",{err:String(o)})}),i.stdout?.on("error",o=>{this.log.warn("child stdout error",{err:String(o)})}),i.stderr?.on("error",o=>{this.log.warn("child stderr error",{err:String(o)})}),i.on("exit",(o,c)=>{this.stopped=!0,z0(i.pid),(o!==0||c!==null)&&this.stderrRing.length>0&&this.log.warn("downstream exited abnormally, recent stderr",{code:o,signal:c,recentStderr:[...this.stderrRing]});try{for(let u of this.decoder.flush())this.dispatch(u)}catch(u){this.log.debug("decoder.flush on exit threw (ignored)",{err:String(u)})}this.failAllPending(this.buildExitError(o,c));for(let u of this.exitHandlers)u(o,c)}),i.on("error",o=>{let c=o,d=vE(c,{command:this.opts.command,cwd:this.opts.cwd,envKeys:Object.keys(r).length});this.log.error("child error",{err:String(o),diag:d}),this.failAllPending(new k("AGENT_SPAWN_FAILED",SE(c,d),{cause:d}))}),this.log.info("downstream started",{command:this.opts.command,pid:i.pid,cwd:this.opts.cwd})}async stop(e){if(!this.child||this.stopped)return;this.stopped=!0,this.stopReason=e??"stopped",this.log.info("downstream stopping",{reason:e});let r=this.child,i=new Promise(c=>r.once("exit",()=>c()));Ki(r.pid,"SIGTERM");let o=setTimeout(()=>{r.killed||Ki(r.pid,"SIGKILL")},5e3);try{await i}finally{clearTimeout(o)}}pid(){return this.child?.pid}isAlive(){return!!this.child&&!this.stopped}getStderrTail(e){return e===void 0?[...this.stderrRing]:this.stderrRing.slice(-e)}initialize(e){return this.call("initialize",e)}sessionNew(e){return this.call("session/new",{mcpServers:[],...e})}sessionLoad(e){return this.call("session/load",{mcpServers:[],...e})}sessionPrompt(e,r){let i={firstUpdateMs:_E,phase2GateMs:pE,livenessWindowMs:mE,absoluteMaxMs:gE,approvalMaxMs:yE,suspendThresholdMs:wE,...r};return this.call("session/prompt",e,$0,i)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(Lr("session/cancel",e))}setSessionMode(e){return this.call("session/set_mode",e)}setSessionModel(e){return this.call("session/set_model",e)}onUpdate(e){this.updateHandlers.push(e)}onAgentRequest(e){this.agentRequestHandlers.push(e)}respondAgentRequest(e,r){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(Nr(e,r))}catch(i){this.log.warn("respondAgentRequest write failed",{id:e,err:String(i)})}}respondAgentRequestError(e,r){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(In(e,r))}catch(i){this.log.warn("respondAgentRequestError write failed",{id:e,err:String(i)})}}onExit(e){this.exitHandlers.push(e)}call(e,r,i=$0,o){if(!this.child||this.stopped)return Promise.reject(new k("AGENT_PROTOCOL_ERROR","downstream not started"));let c=this.idAllocator.next(e),d=Hi(c,e,r),u=(()=>{if(typeof r!="object"||r===null)return;let f=r.sessionId;return typeof f=="string"?f:void 0})();return new Promise((f,x)=>{let g={resolve:f,reject:x,timer:null,method:e,promptTimeout:null};if(o){let w=this.now(),S={cfg:o,startedAt:w,lastActivityAt:w,firstFrameSeen:!1,activeToolCalls:new Set,suspendedMs:0,armedAt:w,expectedIntervalMs:Fr(0,!1,o),sessionId:u};g.promptTimeout=S;let y=()=>{let v={startedAt:S.startedAt,lastActivityAt:S.lastActivityAt,firstFrameSeen:S.firstFrameSeen,hasActiveTool:S.activeToolCalls.size>0,awaitingApproval:this.inflightAgentRequests.size>0,suspendedMs:S.suspendedMs,armedAt:S.armedAt,expectedIntervalMs:S.expectedIntervalMs},I=this.now(),A=K0(v,S.cfg,I),R=D=>{S.armedAt=I,S.expectedIntervalMs=D,g.timer=setTimeout(y,D)};if(A.action==="suspend"){S.suspendedMs+=A.suspendedDeltaMs,S.lastActivityAt=I,this.log.warn("downstream prompt timer: suspend detected",{id:c,method:e,gapMs:A.suspendedDeltaMs,suspendedMs:S.suspendedMs,...S.sessionId?{sessionId:S.sessionId}:{}}),R(A.rearmMs);return}if(A.action==="continue"){R(A.rearmMs);return}this.pending.delete(c),A.action==="reject-backstop"?(this.log.warn("downstream prompt absolute timeout",{id:c,method:e,awaitingApproval:A.awaitingApproval,...S.sessionId?{sessionId:S.sessionId}:{}}),x(A.awaitingApproval?new k("AGENT_APPROVAL_TIMEOUT",`${e} awaiting permission timed out after ${S.cfg.approvalMaxMs}ms`):new k("AGENT_TIMEOUT",`${e} timed out after ${S.cfg.absoluteMaxMs}ms`))):(this.log.warn("downstream prompt idle timeout",{id:c,method:e,...S.sessionId?{sessionId:S.sessionId}:{}}),x(new k("AGENT_FRAME_IDLE_TIMEOUT",`${e} no progress within ${S.cfg.livenessWindowMs}ms`)))};g.timer=setTimeout(y,S.expectedIntervalMs)}else i>0&&Number.isFinite(i)&&(g.timer=setTimeout(()=>{this.pending.delete(c),this.log.warn("downstream call timeout",{id:c,method:e,timeoutMs:i}),x(new k("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i));this.pending.set(c,g);try{this.writeFrame(d)}catch(w){g.timer&&clearTimeout(g.timer),this.pending.delete(c),x(w)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new k("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(N0(e),r=>{r&&this.log.warn("stdin write callback err",{err:String(r)})})}dispatch(e){if(Io(e)){let r=e.id!==null?this.pending.get(e.id):void 0;if(!r){this.log.warn("orphan response",{id:e.id});return}this.pending.delete(e.id),r.timer&&clearTimeout(r.timer),e.error?(this.log.warn("downstream returned error frame",{id:e.id,method:r.method,code:e.error.code,message:e.error.message,data:e.error.data}),r.reject(this.wireErrorToBridge(e.error))):e.result===void 0?(this.log.warn("downstream response missing both result and error",{id:e.id,method:r.method}),r.reject(new k("AGENT_PROTOCOL_ERROR",`${r.method} response missing both result and error`))):(this.log.info("downstream returned result",{id:e.id,method:r.method,result:EE(e.result)}),r.resolve(e.result));return}if(D0(e)){if(e.method==="session/update"){let r=e.params;for(let i of this.pending.values()){let o=i.promptTimeout;o&&(o.firstFrameSeen=!0,o.lastActivityAt=this.now(),this.trackToolCall(o,r))}for(let i of this.updateHandlers)try{Promise.resolve(i(r)).catch(o=>this.log.warn("update handler failed (async)",{err:String(o)}))}catch(o){this.log.warn("update handler threw sync, swallowed",{err:String(o)})}}else this.log.info("unknown notification (drop, not forwarded)",{method:e.method});return}if(P0(e)){let r=e;try{this.handleAgentRequest(r).catch(i=>this.log.error("agent request handler failed (async)",{method:r.method,err:String(i)}))}catch(i){this.log.warn("handleAgentRequest threw sync, swallowed",{method:r.method,err:String(i)})}}}trackToolCall(e,r){let i=r.update,o=i?.sessionUpdate;if(o!=="tool_call"&&o!=="tool_call_update")return;let c=typeof i.toolCallId=="string"?i.toolCallId:void 0;if(!c)return;let d=typeof i.status=="string"?i.status:void 0,u=d==="completed"||d==="failed"||d==="cancelled";o==="tool_call"&&!u?e.activeToolCalls.add(c):u&&e.activeToolCalls.delete(c)}async handleAgentRequest(e){if(this.agentRequestHandlers.length===0){this.writeFrame(In(e.id,{code:-32601,message:`method not handled by Bridge: ${e.method}`}));return}this.inflightAgentRequests.set(e.id,e.method);for(let r of this.agentRequestHandlers)try{await r(e)}catch(i){this.log.error("agentRequestHandler threw",{method:e.method,err:String(i)});try{this.writeFrame(In(e.id,ji(i)))}catch{}this.inflightAgentRequests.delete(e.id)}}wireErrorToBridge(e){let r=O0(e);if(r.code!=="AGENT_PROTOCOL_ERROR")return r;let i=W0(this.framework,bE(e));return i?new k(i.bridgeCode,i.message,{cause:{reason:i.reason,wireCode:e.code,wireMessage:e.message,wireData:e.data}}):r}buildExitError(e,r){if(this.stopReason!==void 0)return new k("AGENT_TURN_ABORTED",`turn aborted: ${this.stopReason}`,{cause:{reason:this.stopReason}});let i=this.getStderrTail(xE).join(`
|
|
106
|
-
`),o=j0(this.framework,i);return o?new k(o.bridgeCode,o.message,{cause:{reason:o.reason,code:e,signal:r,stderrTail:i}}):new k("AGENT_PROTOCOL_ERROR",`agent exited (${e}/${r})`,{cause:{code:e,signal:r,stderrTail:i}})}failAllPending(e){for(let r of this.pending.values())r.timer&&clearTimeout(r.timer),r.reject(e);this.pending.clear(),this.inflightAgentRequests.clear()}};function IE(t){let e={};for(let[r,i]of Object.entries(t))i!==void 0&&(r.startsWith("CLAUDE")||r==="AI_AGENT"||r==="BAGGAGE"||(e[r]=i));return e}var ko=class extends pt{framework="claude-code";constructor(e){let{command:r,args:i}=ii("claude-code",e.command,e.args??[]),o={command:r,args:i,cwd:e.cwd,agentId:e.agentId,...e.env?{env:e.env}:{}};super(o)}sanitizeEnv(e){return IE(e)}};dn();import{mkdtempSync as AE,rmSync as kE}from"node:fs";import{tmpdir as TE}from"node:os";import{join as RE}from"node:path";var J0=["default","acceptEdits","plan","auto","bypassPermissions"],Z0=["read-only","auto","full-access"];var X0=["default","accept_edits","dont_ask"];function Mt(t,e){if(typeof e!="string")return!1;switch(t){case"claude-code":return J0.includes(e);case"codex":return Z0.includes(e);case"hermes":return X0.includes(e);case"openclaw":return!1}}function To(t){switch(t){case"read-only":return"read-only";case"auto":return"agent";case"full-access":return"agent-full-access"}}function Q0(t){switch(t){case"read-only":return"read-only";case"agent":return"auto";case"agent-full-access":return"full-access";default:return}}function md(t){switch(t){case"claude-code":return J0.join("/");case"codex":return Z0.join("/");case"hermes":return X0.join("/");case"openclaw":return""}}var Ro=class extends pt{framework="codex";authMethodId;codexHomeDir;constructor(e){let r=e.args??[],i=e.extraArgs?[...r,...e.extraArgs]:r,{command:o,args:c}=ii("codex",e.command,i),d=e.isolateCodexHome?AE(RE(TE(),"coze-bridge-codex-home-")):void 0,u=d?{...e.env??{},CODEX_HOME:d}:e.env,f={command:o,args:c,cwd:e.cwd,agentId:e.agentId,...u?{env:u}:{}};super(f),this.authMethodId=e.authMethodId,this.codexHomeDir=d}async initialize(e){let r=await super.initialize(e);return this.authMethodId&&await this.call("authenticate",{methodId:this.authMethodId}),r}setSessionMode(e){let r=Mt("codex",e.modeId)?To(e.modeId):e.modeId;return super.setSessionMode({...e,modeId:r})}onUpdate(e){super.onUpdate(r=>e(CE(r)))}async stop(e){if(await super.stop(e),this.codexHomeDir)try{kE(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};function CE(t){let e=t.update;if(e.sessionUpdate!=="current_mode_update"||typeof e.currentModeId!="string")return t;let r=Q0(e.currentModeId);return!r||r===e.currentModeId?t:{...t,update:{...t.update,currentModeId:r}}}te();var PE=G("hermes-downstream"),Co=class extends pt{framework="hermes";modelId;constructor(e){let r={command:e.command,args:[],cwd:e.cwd,agentId:e.agentId,...e.env?{env:e.env}:{}};super(r),e.modelId&&(this.modelId=e.modelId)}async afterSessionEstablished(e){if(this.modelId)try{await this.setSessionModel({sessionId:e,modelId:this.modelId})}catch(r){PE.warn("hermes session/set_model post-establish failed (ignored)",{sessionId:e,modelId:this.modelId,err:String(r)})}}};Ke();var DE=3e4,zr=class extends pt{framework="openclaw";agentId;sessionName;slashModelOnStart;constructor(e){let r=e.sessionName??"default",i=["acp","--session",`agent:${e.agentId}:${r}`];e.gatewayToken&&i.push("--token",e.gatewayToken);let o={command:e.command,args:i,cwd:e.cwd,agentId:e.agentId,...e.env?{env:e.env}:{}};super(o),this.agentId=e.agentId,this.sessionName=r,this.slashModelOnStart=e.slashModelOnStart}async afterSessionEstablished(e){this.slashModelOnStart&&(this.log.info("switching session to per-session provider via /model",{agentId:this.agentId,sessionName:this.sessionName,slash:this.slashModelOnStart}),await this.call("session/prompt",{sessionId:e,prompt:[{type:"text",text:`/model ${this.slashModelOnStart}`}]},DE))}get acpSessionName(){return this.sessionName}setSessionMode(e){return Promise.reject(new k("METHOD_NOT_FOUND","session/set_mode not supported on openclaw"))}};qt();Ke();te();Re();function gd(t){return t.replace(/[^A-Za-z0-9._-]+/g,"-")}dn();var An=class{slots=[];running=!1;closed=!1;disposed=!1;enqueue(e){return this.disposed?Promise.reject(new Error("AsyncQueue disposed")):this.closed?Promise.reject(new Error("AsyncQueue closed")):new Promise((r,i)=>{this.slots.push({task:e,resolve:r,reject:i}),this.drain()})}close(){this.closed=!0}dispose(e=new Error("AsyncQueue disposed")){for(this.disposed=!0,this.closed=!0;this.slots.length>0;)this.slots.shift()?.reject(e)}get size(){return this.slots.length}get isRunning(){return this.running}get isDisposed(){return this.disposed}async drain(){if(!this.running){this.running=!0;try{for(;this.slots.length>0&&!this.disposed;){let e=this.slots.shift();if(!e)break;try{let r=await e.task();e.resolve(r)}catch(r){e.reject(r)}}}finally{this.running=!1}}}};var Po=class{agentId;framework;workspace;deployType;accountId;patToken;modelInfo;sessions=new Map;sessionQueues=new Map;activeTriggers=new Map;activeGroupIds=new Map;status="ok";model;lastActiveAt=Date.now();constructor(e){this.agentId=e.agentId,this.framework=e.framework,this.workspace=e.workspace,this.model=e.model,this.deployType=e.deployType??"local",e.accountId&&(this.accountId=e.accountId),e.patToken&&(this.patToken=e.patToken),e.modelInfo&&(this.modelInfo=e.modelInfo)}setPatToken(e){this.patToken=e}setModelInfo(e){this.modelInfo=e}getSessionQueue(e){let r=this.sessionQueues.get(e);return(!r||r.isDisposed)&&(r=new An,this.sessionQueues.set(e,r)),r}allSessionQueues(){return this.sessionQueues.entries()}hasSessionQueue(e){let r=this.sessionQueues.get(e);return!!r&&!r.isDisposed}async dispose(e){this.status="stopped";let r=new Error(`AgentSession disposed${e?`: ${e}`:""}`);for(let i of this.sessionQueues.values())i.dispose(r);this.sessionQueues.clear(),await this.killAllRuntimes(e??"dispose")}async killAllRuntimes(e){let r=[];for(let[,i]of this.sessions)$i(i),i.downstream&&(r.push(i.downstream.stop(e).catch(()=>{})),i.downstream=void 0);await Promise.all(r),this.activeTriggers.clear(),this.activeGroupIds.clear()}};function $i(t){t.idleTimer&&(clearTimeout(t.idleTimer),t.idleTimer=void 0)}function Xt(t){return t.framework==="hermes"?!0:t.deployType!=="local"?!1:t.framework==="claude-code"||t.framework==="codex"}Zt();te();import{constants as eh}from"node:fs";import{access as OE,readFile as LE}from"node:fs/promises";import{delimiter as NE,dirname as ME,join as th}from"node:path";var Qe=G("framework-detector"),nh={"claude-code":"claude",codex:"codex",openclaw:"openclaw",hermes:"hermes-acp"},BE=[".exe",".cmd",".bat",".ps1"],Vn=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??st,access:e.access??OE,readFile:e.readFile??LE}}async detect(e){let r=nh[e],i=await this.which(r);if(!i&&e==="hermes"&&(i=await this.resolveHermesAcpViaHermesShim()),!i)return Qe.debug("framework binary not found",{framework:e,bin:r}),null;let o=e==="openclaw"?["--log-level","silent"]:[],[c,d]=await Promise.all([this.probeVersion(i,o),e==="openclaw"?this.probeOpenclawDefaultAgent(i):Promise.resolve(null)]),u={path:i,version:c};return d&&(u.defaultAgent=d),u}async detectAll(){let e=await Promise.all(Object.keys(nh).map(async i=>[i,await this.detect(i)])),r={};for(let[i,o]of e)o&&(r[i]=o);return r}async which(e){let r=this.env.pathEnv.split(NE).filter(Boolean),i=this.env.platform==="win32"?["",...BE]:[""];for(let o of r)for(let c of i){let d=th(o,e+c);if(await this.isExecutable(d))return d}return null}async isExecutable(e){try{let r=this.env.platform==="win32"?eh.F_OK:eh.X_OK;return await this.env.access(e,r),!0}catch{return!1}}async resolveHermesAcpViaHermesShim(){if(this.env.platform==="win32")return null;let e=await this.which("hermes");if(!e)return null;let r;try{r=await this.env.readFile(e,"utf8")}catch(d){return Qe.debug("hermes shim fallback: readFile failed",{hermesPath:e,err:String(d)}),null}let o=r.match(/exec\s+["']?(\/[^\s"']+\/bin\/hermes)["']?/)?.[1];if(!o)return Qe.debug("hermes shim fallback: no exec line matched",{hermesPath:e}),null;let c=th(ME(o),"hermes-acp");return await this.isExecutable(c)?(Qe.info("hermes-acp resolved via hermes shim fallback",{hermesPath:e,candidate:c}),c):(Qe.debug("hermes shim fallback: hermes-acp not executable at inferred path",{hermesPath:e,candidate:c}),null)}async probeOpenclawDefaultAgent(e){let r=await this.runProbe(e,["--log-level","silent","agents","list","--json"]);if(!r)return Qe.warn("openclaw default agent probe: runProbe returned null (spawn err / timeout)",{path:e}),null;if(r.code!==0)return Qe.warn("openclaw default agent probe: non-zero exit",{path:e,code:r.code,stdoutHead:r.stdout.slice(0,200)}),null;let i=r.stdout.match(/\[\s*\{[\s\S]*\}\s*\]/);if(!i)return Qe.warn("openclaw default agent probe: regex no match (no JSON array in stdout)",{path:e,stdoutHead:r.stdout.slice(0,200)}),null;try{let o=JSON.parse(i[0]);if(!Array.isArray(o))return Qe.warn("openclaw default agent probe: JSON parsed but not an array",{path:e}),null;let c=o.find(d=>d?.isDefault===!0);return c?!c.id||!c.workspace?(Qe.warn("openclaw default agent probe: default agent missing id or workspace",{path:e,hasId:!!c.id,hasWorkspace:!!c.workspace}),null):{id:c.id,workspace:c.workspace}:(Qe.info("openclaw default agent probe: no agent has isDefault=true",{path:e,agentCount:o.length}),null)}catch(o){return Qe.warn("openclaw default agent probe: JSON.parse failed",{path:e,err:String(o),matchHead:i[0].slice(0,200)}),null}}async probeOpenclawGateway(e){let r=await this.runProbe(e,["--log-level","silent","gateway","status","--json","--require-rpc","--timeout","5000"]);if(!r)return Qe.warn("openclaw gateway probe: runProbe returned null (spawn err / timeout)",{path:e}),{reachable:!1};let i=r.code===0;i||Qe.warn("openclaw gateway probe: non-zero exit (gateway unreachable)",{path:e,code:r.code,stdoutHead:r.stdout.slice(0,200)});let o={reachable:i},c=r.stdout.match(/\{[\s\S]*\}/);if(c)try{let d=JSON.parse(c[0]);typeof d.gateway?.port=="number"&&(o.port=d.gateway.port),typeof d.service?.runtime?.status=="string"&&(o.runtime=d.service.runtime.status),!i&&typeof d.rpc?.error=="string"&&(o.detail=d.rpc.error)}catch(d){Qe.warn("openclaw gateway probe: JSON.parse failed (detail omitted, gate by exit code)",{path:e,err:String(d)})}return o}async probeVersion(e,r=[]){let i=await this.runProbe(e,[...r,"--version"]);return i&&(zE(i.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,r){return new Promise(i=>{let o="",c=!1,d,u=f=>{c||(c=!0,d&&clearTimeout(d),i(f))};try{let f=this.env.spawn(e,r,{stdio:["ignore","pipe","pipe"]});d=setTimeout(()=>{f.kill("SIGKILL"),u(null)},15e3),f.stdout?.on("data",x=>{o+=x.toString("utf8")}),f.on("error",()=>u(null)),f.on("close",x=>u({code:x,stdout:o}))}catch{u(null)}})}},FE=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function zE(t){return t.replace(FE,"")}import{homedir as UE}from"node:os";import{join as GE}from"node:path";qt();Zt();or();Ke();te();async function sh(){let t=GE(UE(),".openclaw/openclaw.json");return lr(t)}async function oh(){return(await sh())?.gateway?.auth?.token??""}var rh=G("openclaw.config"),HE=[0,5e3,5e3],qE=Ve("COZE_BRIDGE_OPENCLAW_CLI_TIMEOUT_MS",15e3),ih="models.providers.",Do="agents.defaults.models",Oo=class{command;env;retryDelaysMs;cliTimeoutMs;queue=new An;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??HE,this.cliTimeoutMs=e.cliTimeoutMs??qE}async withRetry(e,r){let i;for(let o=0;o<this.retryDelaysMs.length;o++){let c=this.retryDelaysMs[o]??0;c>0&&await new Promise(d=>setTimeout(d,c));try{return await r()}catch(d){i=d,rh.warn("openclaw cli failed, will retry",{label:e,attempt:o+1,err:String(d)})}}throw new k("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${i?.message??"unknown"}`)}runCli(e){return new Promise((r,i)=>{let o=st(this.command,e,{stdio:["ignore","ignore","pipe"],env:this.env}),c="",d=!1,u=x=>{d||(d=!0,clearTimeout(f),x())};o.stderr?.on("data",x=>{c+=x.toString("utf8")});let f=setTimeout(()=>{u(()=>{o.kill("SIGTERM"),setTimeout(()=>o.kill("SIGKILL"),250).unref(),i(new Error(`timeout after ${this.cliTimeoutMs}ms: ${e.join(" ")}`))})},this.cliTimeoutMs);f.unref(),o.on("error",x=>u(()=>i(x))),o.on("close",x=>u(()=>{x===0?r():i(new Error(`exit ${x}: ${c.trim().slice(0,500)}`))}))})}async runCliTolerant(e,r){try{await this.runCli(e)}catch(i){let o=String(i);if(r.some(c=>o.includes(c)))return;throw i}}async bestEffortUnset(e,r){try{await this.queue.enqueue(()=>this.withRetry(e,()=>this.runCliTolerant(["config","unset",r],["Config path not found","Nothing was changed"])))}catch(i){rh.warn(`${e} failed (best-effort)`,{configPath:r,err:String(i)})}}ensureProvider(e,r){return this.queue.enqueue(()=>this.withRetry(`config set models.providers.${e}`,()=>this.runCli(["config","set",`${ih}${e}`,JSON.stringify(r),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${ih}${e}`)}addModelToAllowlist(e,r){let i={[e]:r?{alias:r}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${Do}[${e}]`,()=>this.runCli(["config","set",Do,JSON.stringify(i),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${Do}[${e}]`,`${Do}.${e}`)}async getAllowlistModelsForProvider(e){let i=(await sh())?.agents?.defaults?.models;if(!i||typeof i!="object")return[];let o=`${e}/`,c=[];for(let d of Object.keys(i))d.startsWith(o)&&c.push(d.slice(o.length));return c}ensureAgent(e,r,i){let o=["agents","add",e,"--workspace",r,"--non-interactive"];return i&&o.push("--model",i),this.queue.enqueue(()=>this.withRetry(`agents add ${e}`,()=>this.runCliTolerant(o,["already exists","already registered"])))}restartGateway(){return this.queue.enqueue(()=>this.withRetry("gateway restart",()=>this.runCli(["gateway","restart"])))}deleteAgent(e){return this.queue.enqueue(()=>this.withRetry(`agents delete ${e}`,()=>this.runCliTolerant(["agents","delete",e,"--force"],["not found","does not exist"])))}};var ue=G("agent-manager"),yd="acceptEdits",lh="full-access",uh="read-only";function $E(t){return{INITIAL_AGENT_MODE:To(t)}}var YE=(t,e,r,i,o,c,d,u,f,x)=>{switch(t){case"claude-code":{let g={...o?{...i0(o),...a0(o,d,u)}:{},...f??{},IS_SANDBOX:"1"};return new ko({cwd:r,env:g,agentId:i})}case"codex":{let g=lh;x!==void 0&&(Mt("codex",x)?g=x:ue.warn("codex spawn: invalid codexPermissionMode, falling back to full-access",{agentId:i,received:x}));let w=!!o,S={...o?{...o0(o),...s0(o,d,u)}:{},...$E(g),...w?{NO_BROWSER:"1"}:{},...f??{}};return new Ro({cwd:r,agentId:i,...Object.keys(S).length>0?{env:S}:{},...w?{authMethodId:"api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new zr({command:e,cwd:r,agentId:i,...c?{sessionName:gd(c)}:{}});case"hermes":return new Co({command:e,cwd:r,agentId:i,...f&&Object.keys(f).length>0?{env:{...f}}:{},...o?.model?{modelId:o.model}:{}})}};function _d(t){return t==="claude-code"||t==="codex"}var VE={path:"",version:"cloud-deployed"},ch="openclaw_gateway_unavailable",JE="openclaw_default_agent_missing";function dh(t){let e=[t.port!==void 0?`port=${t.port}`:"",t.runtime?`runtime=${t.runtime}`:"",t.detail??""].filter(Boolean).join(", ");return`openclaw gateway \u672A\u8FD0\u884C/\u4E0D\u53EF\u8FBE${e?` (${e})`:""}; \u8BF7\u542F\u52A8 openclaw gateway`}var ZE={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},XE=6e4,Lo=class{paths;config;registry;factory;createTimeoutMs;openclawConfigCache;ensuredProviders=new Set;detectorFactory;openclawEnvBootstrapPromise;openclawConfigFactory;openclawConfigDir;constructor(e){this.paths=e.paths,this.config=e.config,this.registry=e.registry,this.factory=e.downstreamFactory??YE,this.createTimeoutMs=e.createTimeoutMs??XE,this.detectorFactory=e.detectorFactory??(()=>new Vn),this.openclawConfigFactory=e.openclawConfigFactory??(r=>new Oo({command:r})),this.openclawConfigDir=e.openclawConfigDir??ah(KE(),".openclaw")}buildBinShimPathEnv(){let e=process.platform==="win32"?";":":";return{PATH:`${this.paths.binDir}${e}${process.env.PATH??""}`}}getOpenclawConfig(){if(!this.openclawConfigCache){let e=this.config.frameworksCache?.openclaw;if(!e?.path)throw new k("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");this.openclawConfigCache=this.openclawConfigFactory(e.path)}return this.openclawConfigCache}bootstrapOpenclawEnvIfNeeded(){return this.openclawEnvBootstrapPromise?this.openclawEnvBootstrapPromise:(this.openclawEnvBootstrapPromise=this.doBootstrapOpenclawEnv().catch(e=>{ue.warn("openclaw env bootstrap failed (ignored)",{err:String(e)}),this.openclawEnvBootstrapPromise=void 0}),this.openclawEnvBootstrapPromise)}async doBootstrapOpenclawEnv(){let e=this.openclawConfigDir,r=ah(e,".env");if(await WE(r).then(c=>c.isFile()).catch(()=>!1)){ue.debug("openclaw .env exists, skip bootstrap",{envFile:r});return}let o=Mi({...process.env,...Ni(this.paths.agentEnvFile)});await ut(r,o,{mode:384}),ue.info("openclaw .env bootstrapped",{envFile:r,bytes:o.length}),await this.getOpenclawConfig().restartGateway(),ue.info("openclaw gateway restarted after env bootstrap")}async createAgent(e,r){if(!e.agentId)throw new k("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new k("IPC_BAD_REQUEST","framework required");let i=await ve(e.agentId,this.paths).catch(()=>null),o=xo(e._meta)==="cloud"||i?.deployType==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let c=this.registry.get(e.agentId);if(c){if(c.framework!==e.framework)throw new k("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${c.framework})`);if(c.status==="error")ue.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await c.dispose("rebuild after error").catch(R=>ue.warn("dispose stale agent failed (ignored)",{err:String(R)})),this.registry.unregister(e.agentId);else if(o&&c.deployType!=="cloud")ue.warn("existing agent deployType drifted to local, rebuilding as cloud",{agentId:e.agentId}),await c.dispose("rebuild after deployType drift").catch(R=>ue.warn("dispose drifted agent failed (ignored)",{err:String(R)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==c.patToken){ue.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),c.setPatToken(e.patToken);let R=await ve(e.agentId,this.paths).catch(()=>null);R&&(R.patToken=e.patToken,await ze(R,this.paths))}if(c.deployType==="cloud"&&e.modelInfo){ue.info("updating agent modelInfo on re-create",{agentId:e.agentId}),c.setModelInfo(e.modelInfo);let R=await ve(e.agentId,this.paths).catch(()=>null);R&&(R.modelInfo=e.modelInfo,await ze(R,this.paths))}return ue.info("agent already exists, return current",{agentId:e.agentId}),{ok:!0,agentId:c.agentId,workspace:c.workspace,framework:c.framework}}}if(!o&&!this.config.frameworksCache?.[e.framework]){let D=e.framework==="hermes"?"; install with `pipx install hermes-agent` and rerun daemon to refresh frameworks_cache":"; rerun daemon to refresh frameworks_cache";throw new k("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine${D}`)}let u=Fe(e.agentId,this.paths),f=o?"cloud":"local",x=e.framework==="openclaw"&&f==="local",g;x&&!r?.revive&&(g=(await this.ensureOpenclawDefaultAgent()).workspace,await this.ensureOpenclawGatewayReachable());let w=g??(x?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0),S=e.workspace??w??u.workspace,y=new AbortController,v=setTimeout(()=>y.abort(new k("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),I,A=!1;try{o&&_d(e.framework)&&await dr(e.framework,y.signal);let R=()=>{if(y.signal.aborted)throw y.signal.reason instanceof Error?y.signal.reason:new k("AGENT_TIMEOUT","_agent/create aborted")};await wd(u.root,{recursive:!0}),await wd(S,{recursive:!0}),await wd(u.logs,{recursive:!0}),R(),x||await fr(S,e.framework,e.cozeIdentity),e.framework==="claude-code"&&(f==="cloud"?await qa(S,"cloud"):await qa(S,"local",yd)),R();let D=i,b=n0({model:e.model??D?.model}),P=Hf(e._meta)??D?.accountId,O=e.patToken??D?.patToken,B=f==="cloud"?e.modelInfo??D?.modelInfo:void 0;if(I=new Po({agentId:e.agentId,framework:e.framework,workspace:S,model:b.model??It,deployType:f,...P?{accountId:P}:{},...O?{patToken:O}:{},...B?{modelInfo:B}:{}}),I.status="ok",D?.sessions){let K=e.framework==="hermes"||f==="local"&&(e.framework==="claude-code"||e.framework==="codex");for(let[X,se]of Object.entries(D.sessions)){let oe={acpSessionId:se.acpSessionId,modelToken:se.modelToken,tokenGeneratedAt:se.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};K?se.permissionMode===void 0?(oe.permissionMode=e.framework==="claude-code"?"bypassPermissions":e.framework==="codex"?"full-access":"default",ue.info("autoRevive: legacy session (no permissionMode) \u2192 fallback to D80/D84 default",{agentId:e.agentId,cloudId:X,framework:e.framework,fallback:oe.permissionMode})):Mt(e.framework,se.permissionMode)?oe.permissionMode=se.permissionMode:ue.warn("autoRevive: dropping invalid persisted permissionMode",{agentId:e.agentId,cloudId:X,framework:e.framework,value:se.permissionMode}):se.permissionMode!==void 0&&ue.info("autoRevive: dropping persisted permissionMode (gate disabled)",{agentId:e.agentId,cloudId:X,framework:e.framework,deployType:f}),se.cozeGroupId&&(oe.cozeGroupId=se.cozeGroupId),I.sessions.set(X,oe)}let re=Object.keys(D.sessions).length;re>0&&ue.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:re})}this.registry.register(I),A=!0;let M={agentId:e.agentId,framework:e.framework,workspace:S,cozeIdentity:e.cozeIdentity,createdAt:D?.createdAt??Date.now(),sessions:D?.sessions??{},model:b.model};f==="cloud"&&(M.deployType="cloud"),P&&(M.accountId=P),O&&(M.patToken=O),B&&(M.modelInfo=B),D?.skills&&(M.skills=D.skills),D?.agentName&&(M.agentName=D.agentName),D?.description&&(M.description=D.description),M.skillsRefreshedForVersion=D?.skillsRefreshedForVersion??Nt,e.framework==="openclaw"&&f==="cloud"&&(this.config.frameworksCache?.openclaw?.path?(await this.bootstrapOpenclawEnvIfNeeded(),await this.getOpenclawConfig().ensureAgent(e.agentId,S)):ue.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let V=e.initialSkills??[];if(V.length>0){let K=[...M.skills??[]],re=new Map(K.map((oe,C)=>[oe.skillId,C])),X=await Promise.allSettled(V.map(oe=>bo({agentId:e.agentId,workspace:S,framework:e.framework,skill:oe,paths:this.paths}))),se=0;for(let[oe,C]of X.entries()){let z=V[oe];z&&(C.status==="fulfilled"?(vo(K,re,C.value),se++):ue.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:z.skillId,skillName:z.skillName,err:String(C.reason)}))}se>0&&(M.skills=K,ue.info("initialSkills installed",{agentId:e.agentId,installed:se,requested:V.length}))}return await ze(M,this.paths),ue.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:f}),{ok:!0,agentId:e.agentId,workspace:S,framework:e.framework}}catch(R){throw ue.error("agent create failed, rolling back",{agentId:e.agentId,err:String(R)}),A&&I&&(await I.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),ue.error("[AUDIT] ROLLBACK: about to rm dirs.root",{src:"agent-manager.createAgent.catch",agentId:e.agentId,path:u.root,revive:r?.revive===!0,framework:e.framework,errStack:R instanceof Error?R.stack:String(R)}),await jE(u.root,{recursive:!0,force:!0}).catch(D=>ue.warn("rm agent dir failed (ignored)",{err:String(D)})),R instanceof k?R:new k("AGENT_SPAWN_FAILED",String(R),{cause:R})}finally{clearTimeout(v)}}async spawnSessionDownstream(e,r,i,o,c){let u=this.config.frameworksCache?.[e.framework];if(!u)if(e.deployType==="cloud"&&_d(e.framework))u=VE;else throw e.framework==="hermes"?new k("AGENT_SPAWN_FAILED","hermes-acp not detected on this machine; install with `pipx install hermes-agent` and rerun daemon to refresh frameworks_cache"):new k("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);_d(e.framework)&&!ys(e.framework)&&(ue.info("spawn: resolving acp wrapper",{agentId:e.agentId,framework:e.framework}),await dr(e.framework));let f=e.deployType==="cloud"?{model:e.model,modelToken:r,...e.modelInfo?{modelInfo:e.modelInfo}:{}}:void 0,x;if(e.framework==="openclaw")x=await this.buildOpenclawDownstream({session:e,modelConfig:f,cloudSessionId:i,cozeEnv:o,mockScenario:c,command:u.path});else if(e.framework==="hermes"){let g={...this.buildBinShimPathEnv()};f&&(await h0({paths:this.paths,agentId:e.agentId,modelConfig:f,cozeEnv:o,mockScenario:c}),g.HERMES_HOME=Yn(e.agentId,this.paths)),x=this.factory(e.framework,u.path,e.workspace,e.agentId,f,i,o,c,g)}else{let g=e.sessions.get(i),w=Xt(e)?g?.permissionMode??lh:"full-access";x=this.factory(e.framework,u.path,e.workspace,e.agentId,f,i,o,c,this.buildBinShimPathEnv(),w)}try{return await x.start(),await x.initialize(ZE),x}catch(g){let w=x instanceof pt?x.getStderrTail():[];throw w.length>0&&ue.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:g instanceof k?g.code:"unknown",recentStderr:w}),await x.stop("spawnSessionDownstream failed").catch(()=>{}),await this.resolveSpawnFailure(e,u.path,g)}}async resolveSpawnFailure(e,r,i){if(e.framework==="openclaw"&&e.deployType==="local"&&r)try{let o=await this.detectorFactory().probeOpenclawGateway(r);if(!o.reachable)return new k("AGENT_ENV_NOT_READY",dh(o),{cause:{reason:ch}})}catch(o){ue.warn("openclaw gateway diagnose failed (ignored, fall through to original error)",{agentId:e.agentId,err:String(o)})}return i instanceof k?i:new k("AGENT_SPAWN_FAILED",i instanceof Error?i.message:String(i),{cause:i})}async ensureOpenclawDefaultAgent(){let e=this.config.frameworksCache?.openclaw?.defaultAgent;if(e?.id&&e.workspace)return{id:e.id,workspace:e.workspace};ue.warn("openclaw default agent stale or missing, attempting lazy re-detect");let r=await this.detectorFactory().detect("openclaw");if(r?.defaultAgent?.id&&r.defaultAgent.workspace)return ue.info("openclaw lazy re-detect success",{agentId:r.defaultAgent.id,workspace:r.defaultAgent.workspace}),this.config.frameworksCache||(this.config.frameworksCache={}),this.config.frameworksCache.openclaw=r,{id:r.defaultAgent.id,workspace:r.defaultAgent.workspace};throw new k("AGENT_ENV_NOT_READY","openclaw default agent \u672A\u63A2\u6D4B\u5230; \u8BF7\u5148\u8DD1 `openclaw setup` \u6216 `openclaw agents add` \u521B\u5EFA\u9ED8\u8BA4 agent",{cause:{reason:JE}})}async ensureOpenclawGatewayReachable(){let e=this.config.frameworksCache?.openclaw?.path;if(!e)throw new k("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");let r=await this.detectorFactory().probeOpenclawGateway(e);if(!r.reachable)throw new k("AGENT_ENV_NOT_READY",dh(r),{cause:{reason:ch}})}async buildOpenclawDownstream(e){let{session:r,modelConfig:i,cloudSessionId:o,cozeEnv:c,mockScenario:d,command:u}=e,f=gd(o);if(r.deployType==="local"){let w=await this.ensureOpenclawDefaultAgent();return new zr({command:u,cwd:w.workspace,agentId:w.id,sessionName:f})}let x=await oh(),g;if(i?.modelToken){let w=td(o),S=nd(i),y=`${w}/${S}`;if(!this.ensuredProviders.has(y)){let v=this.getOpenclawConfig(),I=await v.getAllowlistModelsForProvider(w),A=c0(i,c,d,I);A&&(await v.ensureProvider(w,A),await v.addModelToAllowlist(y),this.ensuredProviders.add(y))}g=y}return new zr({command:u,cwd:r.workspace,agentId:r.agentId,sessionName:f,...x?{gatewayToken:x}:{},...g?{slashModelOnStart:g}:{}})}async openclawRepair(e,r){let i=this.getOpenclawConfig();await i.deleteAgent(e),await i.ensureAgent(e,r)}async cleanupOpenclawSessionProviders(e,r){if(e.framework!=="openclaw"||!this.openclawConfigCache)return;let i=this.openclawConfigCache,o=r??e.model;for(let c of e.sessions.keys()){let d=td(c),u=`${d}/${o}`,f=!0;try{await i.removeProvider(d)}catch(x){f=!1,ue.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:d,err:String(x)})}try{await i.removeModelFromAllowlist(u)}catch(x){f=!1,ue.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:u,err:String(x)})}f&&this.ensuredProviders.delete(u)}}};import{randomUUID as mh}from"node:crypto";import{promises as sb}from"node:fs";import{basename as gh}from"node:path";Ke();te();import{promises as QE}from"node:fs";import{basename as eb}from"node:path";var fh=G("file-upload"),tb="/api/coze_claw/file/agent_upload",nb=6e4;async function hh(t,e={}){let i=`${Cr(Pr(e.handshakeBase))}${tb}`,o=e.timeoutMs??nb,c=await QE.readFile(t.path),d=new FormData;d.append("agent_id",t.agentId),d.append("session_id",t.sessionId),d.append("file_name",t.name),d.append("file_content",new Blob([c],{type:t.mimeType}),t.name);let u={Authorization:`Bearer ${t.patToken}`,Accept:"application/json","x-coze-version":"3.0",...vn(e.ppeOverride),...t.accountId?{"x-coze-account":t.accountId}:{}},f=new AbortController,x=setTimeout(()=>f.abort(),o);fh.info("file upload start",{url:i,agentId:t.agentId,sessionId:t.sessionId,name:t.name,bytes:t.sizeBytes,mime:t.mimeType});try{let g=await fetch(i,{method:"POST",headers:u,body:d,signal:f.signal}),w=g.headers.get("x-tt-logid")??"";if(!g.ok){let v=await g.text().catch(()=>"");throw new k("UPLOAD_FAILED",`upload HTTP ${g.status} logid=${w}: ${v.slice(0,200)}`)}let S=await g.json();if(S.code!==void 0&&S.code!==0)throw new k("UPLOAD_FAILED",`upload code=${S.code} msg=${S.msg??"-"} logid=${w}`);let y=S.data?.file?.file_url;if(!y)throw new k("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${w}: ${JSON.stringify(S).slice(0,200)}`);return fh.info("file upload ok",{uri:y,logid:w}),{uri:y}}catch(g){throw g instanceof k?g:g.name==="AbortError"?new k("UPLOAD_FAILED",`upload timeout (${o}ms) for ${eb(t.path)}`):new k("UPLOAD_FAILED",String(g),{cause:g})}finally{clearTimeout(x)}}Ke();te();import{extname as rb}from"node:path";var ib={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".svg":"image/svg+xml",".bmp":"image/bmp",".ico":"image/x-icon",".heic":"image/heic",".heif":"image/heif",".pdf":"application/pdf",".doc":"application/msword",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".xls":"application/vnd.ms-excel",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".ppt":"application/vnd.ms-powerpoint",".pptx":"application/vnd.openxmlformats-officedocument.presentationml.presentation",".txt":"text/plain",".md":"text/markdown",".markdown":"text/markdown",".json":"application/json",".yaml":"text/yaml",".yml":"text/yaml",".csv":"text/csv",".html":"text/html",".htm":"text/html",".xml":"application/xml",".log":"text/plain",".zip":"application/zip",".tar":"application/x-tar",".gz":"application/gzip",".tgz":"application/gzip",".mp3":"audio/mpeg",".wav":"audio/wav",".mp4":"video/mp4",".mov":"video/quicktime",".webm":"video/webm"};async function xh(t){let e=rb(t).toLowerCase();return ib[e]??"application/octet-stream"}Re();var No=G("agent-send"),ph=50*1024*1024;function wh(t,e,r){let i=t.get(e);if(!i)throw new k("AGENT_NOT_FOUND",`agent=${e}`);if(t.disconnectedAgents.has(e))throw new k("AGENT_DISCONNECTED",`agent=${e} was disconnected by cloud`);let o=i.sessions.get(r);if(!o)throw new k("AGENT_NOT_FOUND",`session=${r} not active in agent=${e}`);return{session:i,runtime:o}}async function _h(t,e,r,i,o,c){let u;for(let f=0;f<=2;f++)try{await t.core.sendAgentFileUpdate(e,r,i,o);return}catch(x){u=x,f<2&&(No.warn("sendAgentFileUpdate failed, retrying",{attempt:f+1,err:String(x)}),await new Promise(g=>setTimeout(g,5e3)))}throw new k("UPSTREAM_NOT_READY",`${c} after 3 attempts: ${String(u)}`,{cause:u})}async function yh(t,e){let{session:r,runtime:i}=wh(e.core,t.agentId,t.sessionId);if(!await si(t.path,r.workspace))throw new k("PATH_OUTSIDE_WORKSPACE",`path=${t.path} not under workspace=${r.workspace}`);let o=await sb.stat(t.path).catch(()=>null);if(!o||!o.isFile())throw new k("IPC_BAD_REQUEST",`path is not a regular file: ${t.path}`);if(o.size>ph)throw new k("FILE_TOO_LARGE",`${o.size} bytes > limit ${ph}`);let c=await xh(t.path);if(t.kind==="image"&&!c.startsWith("image/"))throw new k("UNSUPPORTED_MIME",`kind=image but mime=${c}`);if(!e.core.upstream.isConnected())throw new k("UPSTREAM_NOT_READY","cloud WS not connected");let d=t.name??gh(t.path),u;try{u=await hh({patToken:r.patToken??e.patToken,agentId:t.agentId,sessionId:t.sessionId,path:t.path,mimeType:c,name:d,sizeBytes:o.size,...r.accountId?{accountId:r.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride})}catch(x){throw No.warn("agent file upload failed",{agentId:t.agentId,sessionId:t.sessionId,path:t.path,sizeBytes:o.size,mime:c,code:x instanceof k?x.code:"UNKNOWN",message:x instanceof Error?x.message:String(x)}),x}let f={sessionUpdate:"agent_file",messageId:mh(),content:{type:t.kind==="image"?"image":"resource",uri:u.uri,mimeType:c,name:d,sizeBytes:o.size,...u.fileId!==void 0?{fileId:u.fileId}:{},...t.caption!==void 0?{caption:t.caption}:{}}};return await _h(e,r,i,t.sessionId,f,"agent file uploaded to cloud but sendAgentFileUpdate failed"),No.info("agent file sent",{agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,name:d,bytes:o.size,mime:c,uri:u.uri}),{ok:!0,uri:u.uri,bytes:o.size,mimeType:c,...u.fileId!==void 0?{fileId:u.fileId}:{}}}async function Eh(t,e){let{session:r,runtime:i}=wh(e.core,t.agentId,t.sessionId);if(!t.mimeType)throw new k("IPC_BAD_REQUEST","group-file requires mimeType");if(!e.core.upstream.isConnected())throw new k("UPSTREAM_NOT_READY","cloud WS not connected");let o=t.name??gh(t.path),c={sessionUpdate:"group_file",messageId:mh(),content:{uri:t.path,name:o,mimeType:t.mimeType,...t.caption!==void 0?{caption:t.caption}:{}}};return await _h(e,r,i,t.sessionId,c,"agent group file sendAgentFileUpdate failed"),No.info("agent group file sent",{agentId:t.agentId,sessionId:t.sessionId,uri:t.path,name:o,mime:t.mimeType}),{ok:!0,uri:t.path,bytes:0,mimeType:t.mimeType}}function bh(t,e){let r=t.split(".").map(Number),i=e.split(".").map(Number),o=Math.max(r.length,i.length);for(let c=0;c<o;c++){let d=r[c]??0,u=i[c]??0;if(d<u)return!0;if(d>u)return!1}return!1}Zt();te();dn();var Bt=G("coze-cli-installer"),vh="@coze/cli@latest",ob="coze",Sh="0.1.8",ab=5e3,cb=5e3,db=9e4,Ih=1e4,Yi=null,Mo=!1;async function bd(t,e={}){if(Mo)return;if(Yi)return Yi;let r=e.exec??$f;return Yi=(async()=>{try{let i=await lb(ob,r),o=!1;if(i){let d=await ub(r);if(d===void 0)Bt.warn("coze-cli found but version unparseable, fall through to full install",{path:i});else if(bh(d,Sh))Bt.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:i,version:d,min:Sh}),o=!0;else{Bt.info("coze-cli already on PATH with sufficient version, skip",{path:i,version:d}),Mo=!0;return}}let c=o?"upgrade-only":"full";Bt.info("coze-cli install start",{package:vh,mode:c});try{await r("npm",["i","-g","--prefer-online",vh],{timeout:db,maxBuffer:10*1024*1024}),Bt.info("coze-cli install ok")}catch(d){Bt.warn("coze-cli install failed (skip subsequent steps)",{err:String(d)});return}if(o){Mo=!0;return}if(t.env)try{await r("coze",["config","set","xTTEnv",t.env],{timeout:Ih}),Bt.info("coze config set xTTEnv ok",{env:t.env})}catch(d){Bt.warn("coze config set failed (continue to auth login)",{err:String(d)})}try{await r("coze",["auth","login","--token",t.patToken],{timeout:Ih}),Bt.info("coze auth login ok")}catch(d){Bt.warn("coze auth login failed",{err:String(d)});return}Mo=!0}finally{Yi=null}})(),Yi}async function lb(t,e){let r=process.platform==="win32"?"where":"which";try{let{stdout:i}=await e(r,[t],{timeout:ab});return Ga(i)}catch{return}}async function ub(t){try{let{stdout:e,stderr:r}=await t("coze",["--version"],{timeout:cb});return(e||r).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}jt();qt();Re();var fb=10*6e4;function Ah(t){let e=t?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?fb:e}function Bo(t){return lr(t??J().configFile)}function Vi(t,e){return ur(e??J().configFile,t)}import{randomBytes as Db}from"node:crypto";or();Ke();te();import{createReadStream as hb}from"node:fs";import{mkdir as xb,readFile as pb,realpath as mb,stat as gb,writeFile as wb}from"node:fs/promises";import{basename as _b,dirname as vd,isAbsolute as yb,join as Eb,relative as bb,resolve as kh,sep as vb}from"node:path";import{createInterface as Sb}from"node:readline";var Rh=G("fs-rpc"),Ji=Ve("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function Ch(t,e){let r=Buffer.byteLength(t.content,"utf8");if(r>Ji)throw new k("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${r} bytes > limit ${Ji} bytes`);let i=await Dh(t.path,e);return await xb(vd(i),{recursive:!0}),await wb(i,t.content,"utf8"),Rh.info("fs/write_text_file ok",{path:i,size:t.content.length}),null}async function Ph(t,e){let r=await Dh(t.path,e),i=await gb(r),o=typeof t.line=="number"||typeof t.limit=="number";if(i.size>Ji&&!o)throw new k("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${i.size} bytes > ${Ji} bytes`);let c;if(o&&i.size>Ji)c=await Ib(r,t.line??1,t.limit);else{let d=await pb(r,"utf8");if(o){let u=d.split(`
|
|
97
|
+
`}var $n=q("hermes-config"),d0="dont_ask",l0="default";function Vn(t,e){return Ui(ze(t,e).root,"hermes-home")}async function yy(t){let e=Vn(t.agentId,t.paths);await _y(e,{recursive:!0,mode:448});let n=Bi({...process.env,...Mi(t.paths.agentEnvFile)});await ut(Ui(e,".env"),n,{mode:384});let i=td(t.modelConfig,t.cozeEnv,t.mockScenario);await ut(Ui(e,"config.yaml"),i,{mode:384}),$n.info("hermes home bootstrapped",{agentId:t.agentId,home:e,envBytes:n.length,yamlBytes:i.length})}async function u0(t){let e=Vn(t.agentId,t.paths),n=Ui(e,"state.db"),i=Ui(e,"config.yaml");$n.warn("[AUDIT] ABOUT TO RM hermes state.db (resetHermesHome)",{src:"hermes-config.resetHermesHome",agentId:t.agentId,home:e,stateDb:n,callerStack:new Error("resetHermesHome-caller").stack?.split(`
|
|
98
|
+
`).slice(1,6).join(" | ")}),await c0(n,{force:!0}).catch(c=>$n.warn("hermes reset: rm state.db failed (ignored)",{agentId:t.agentId,err:String(c)}));let o=td({model:t.model,modelInfo:t.modelInfo},t.cozeEnv,t.mockScenario);await ut(i,o,{mode:384}).catch(c=>$n.warn("hermes reset: write config.yaml failed (ignored)",{agentId:t.agentId,err:String(c)})),$n.info("hermes reset complete",{agentId:t.agentId,removed:["state.db"],rewrote:["config.yaml"]})}async function rd(t,e){let n=Vn(t,e);$n.warn("[AUDIT] ABOUT TO RM hermes-home (cleanupHermesHome)",{src:"hermes-config.cleanupHermesHome",agentId:t,home:n,callerStack:new Error("cleanupHermesHome-caller").stack?.split(`
|
|
99
|
+
`).slice(1,6).join(" | ")}),await c0(n,{recursive:!0,force:!0}).catch(i=>$n.warn("hermes-home cleanup failed (ignored)",{agentId:t,err:String(i)}))}var nd=new Map;function f0(t){let e=nd.get(t.agentId);if(e)return e;let n=yy(t).finally(()=>nd.delete(t.agentId));return nd.set(t.agentId,n),n}var re=q("agent-handlers"),x0=5*1024*1024,Iy=1,Ay=6,ky=new Set(["node_modules",".git",".coze","dist","build",".next"]),Ty=/^(ppe|boe)_[A-Za-z0-9_-]{1,120}$/,Py=/^[A-Za-z][A-Za-z0-9._-]{0,63}$/,Ry=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z][0-9A-Za-z.-]*)?(?:\+[0-9A-Za-z][0-9A-Za-z.-]*)?$/;function Cy(t){let e=t?.trim();return e?Ry.test(e)||Py.test(e)?e:(re.warn("_agent/upgrade: invalid targetVersion, fallback to latest",{targetVersion:t}),"latest"):"latest"}function Dy(t){return new Promise((e,n)=>{let i=st("npx",t,{detached:!0,stdio:"ignore",windowsHide:!0}),o=!1,c=d=>{o||(o=!0,d?n(d):e(i.pid??0))};i.once("spawn",()=>{i.unref(),c()}),i.once("error",d=>c(d))})}var yo=class{constructor(e){this.opts=e}opts;get paths(){return this.opts.paths??Y()}async listSkills(e){e._meta;let n=Kn(e._meta),i=await this.loadAgentCfg(n),o=i?.workspace??ze(n,this.paths).workspace,c=i?.framework??"claude-code",d=i?.skills??[],{base:u}=Or(c,n,o,this.paths),f=[],x=new Set;for(let m of d){let _=ue(u,m.relPath,"SKILL.md");await ld(_).then(y=>y.isFile()).catch(()=>!1)&&(f.push(By(m)),x.add(m.relPath))}if(e.scanLocal){let m=await I0(n,o,c,this.paths),_=await A0(n,c);for(let v of[...m,..._])x.has(v.relPath)||(x.add(v.relPath),f.push(v.skill))}return{skills:f}}async addSkills(e){e._meta;let n=Kn(e._meta),i=await this.requireAgentCfg(n),o=e.skills??[],c=[...i.skills??[]],d=new Map(c.map((f,x)=>[f.skillId,x])),u=[];for(let f of o){let x=await Eo({agentId:n,workspace:i.workspace,framework:i.framework,skill:f,paths:this.paths});bo(c,d,x),u.push(f)}return await ci(n,c),this.reloadAgentSessions(n,"skills-added"),{installedSkills:u}}async removeSkills(e){e._meta;let n=Kn(e._meta),i=await this.requireAgentCfg(n),o=new Set(e.skillIds??[]),c=i.skills??[],d=[],{base:u}=Or(i.framework,n,i.workspace,this.paths);for(let f of c){if(!o.has(f.skillId)){d.push(f);continue}let x=ue(u,f.relPath);re.warn("[AUDIT] ABOUT TO RM skill dir (removeSkills)",{src:"agent-handlers.removeSkills",agentId:n,skillId:f.skillId,relPath:f.relPath,skillBase:u,absDir:x}),await od(x,{recursive:!0,force:!0}),re.info("skill removed",{agentId:n,skillId:f.skillId,relPath:f.relPath})}return await ci(n,d),this.reloadAgentSessions(n,"skills-removed"),{ok:!0}}async publishSkill(e){e._meta;let n=Kn(e._meta);if(!e.skillName)throw new k("IPC_BAD_REQUEST","_agent/publishSkill: missing skillName");re.info("_agent/publishSkill start",{agentId:n,skillId:e.skillId??"",skillName:e.skillName,userId:e.userId??"",accountId:e.accountId??""});let i=await this.loadAgentCfg(n),o=i?.workspace??ze(n,this.paths).workspace,c=i?.framework??"claude-code",d=e.isGlobal??!1,u=await Ly(n,o,c,e.skillName,d,this.paths);if(!u){let D=d?"global":"workspace";throw new k("SKILL_NOT_FOUND",`skill not found in ${D}: ${e.skillName}`)}let{absDir:f,relPath:x,dirName:m}=u,_=ue(f,"SKILL.md"),v=new fd.default;v.addLocalFolder(f,m);let y=v.toBuffer();if(y.length>p0)throw new k("SKILL_ZIP_TOO_LARGE",`skill zip ${y.length} bytes exceeds limit ${p0}`);let b=await _o(_,{encoding:"utf8"}).then(D=>v0(D).description).catch(()=>{}),I={};this.opts.publishSkillToMarketplace?I=await this.opts.publishSkillToMarketplace({zip:y,...e.skillId?{skillId:e.skillId}:{},skillName:e.skillName,...b?{description:b}:{},agentId:n,...e.userId?{userId:e.userId}:{},...e.accountId?{accountId:e.accountId}:{}}):re.warn("_agent/publishSkill: publishSkillToMarketplace not injected, skip upload",{agentId:n,skillName:e.skillName});let A=I.version??"v1.0",P=I.skillId??e.skillId??b0(n,x);if(i&&!d){let D=i.skills??[],E=D.find(C=>C.relPath===x);E?(E.version=A,E.skillId=P):D.push({skillId:P,skillName:e.skillName,relPath:x,version:A,installedAt:Date.now(),...b?{description:b}:{}}),await ci(n,D)}return re.info("skill published",{agentId:n,skillName:e.skillName,relPath:x,zipBytes:y.length,skillId:P,version:A}),{ok:!0,skillId:P,version:A}}reloadAgentSessionsPublic(e,n){this.reloadAgentSessions(e,n)}reloadAgentSessions(e,n){let i=this.opts.agents.get(e);if(i)for(let[o,c]of i.sessions){if(!c.downstream)continue;let d=c.acpSessionId;if(d&&i.activeTriggers.has(d)||this.isRuntimePendingPermission(c)){c.reloadAfterTurn=!0,re.info("downstream busy, scheduling reload after turn",{reason:n,agentId:e,framework:i.framework,cloudId:o,acpId:d});continue}let f=c.downstream;c.downstream=void 0,re.info("killing downstream for workspace reload (idle)",{reason:n,agentId:e,framework:i.framework,cloudId:o,acpId:d}),f.stop(n).catch(x=>re.warn("downstream stop failed during reload (ignored)",{reason:n,agentId:e,cloudId:o,err:String(x)}))}}isRuntimePendingPermission(e){let n=this.opts.isRuntimePendingPermission;return!n||!e.downstream?!1:n(e.downstream)}async updateAgent(e){if(!e.cozeIdentity?.trim())return re.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let n=e.agentId,i=await Se(n);if(!i)throw new k("AGENT_NOT_FOUND",`agent not found: ${n}`);if(i.cozeIdentity===e.cozeIdentity)return re.info("_agent/update: cozeIdentity unchanged, noop",{agentId:n}),{ok:!0};try{await fr(i.workspace,i.framework,e.cozeIdentity)}catch(o){throw re.error("_agent/update: writeInstructionFile failed, aborting update",{agentId:n,framework:i.framework,workspace:i.workspace,err:String(o)}),new k("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${n}: ${String(o)}`,{cause:o})}return i.cozeIdentity=e.cozeIdentity,await Ue(i),re.info("_agent/update: cozeIdentity rewritten",{agentId:n,framework:i.framework}),this.reloadAgentSessions(n,"identity-changed"),{ok:!0}}async upgradeBridge(e){let n=e.agentId||e._meta?.cozeAgentId;if(!n)throw new k("IPC_BAD_REQUEST","_agent/upgrade: missing agentId");if(!await Se(n))throw new k("AGENT_NOT_FOUND",`agent not found: ${n}`);let o=["-y"];e.registry&&Ni(e.registry)&&o.push(`--registry=${e.registry}`);let c=Cy(e.targetVersion);o.push("--ignore-existing",`coze-bridge@${c}`,"connect");let d=e._meta?.cozeEnv;d&&Ty.test(d)&&o.push("--env",d);let u=await Dy(o);return re.info("_agent/upgrade: spawned bridge upgrade process",{agentId:n,pid:u,targetVersion:c,currentVersion:e.currentVersion??"",reason:e.reason??""}),{ok:!0,accepted:!0,pid:u,message:"bridge upgrade started"}}async disconnectAgent(e){let n=e.agentId;if(!n)throw new k("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let i=await Se(n);return i?(i.disconnectedAt=Date.now(),i.disconnectReason=e.reason??"",await Ue(i),re.info("agent disconnected",{agentId:n,reason:e.reason??"",force:e.force??!1}),this.opts.disposeAndMarkDisconnected&&await this.opts.disposeAndMarkDisconnected(n,e.reason??"disconnect"),{ok:!0}):(re.warn("_agent/disconnect: agent not found, ignoring",{agentId:n}),{ok:!0})}async deleteAgent(e){let n=e.agentId;if(!n)throw new k("IPC_BAD_REQUEST",`${xt.DELETE}: missing agentId`);re.warn("[AUDIT] deleteAgent handler entry",{agentId:n,reason:e.reason??"",forceParamDeployType:e.deployType,metaDeployType:e._meta?.cozeDeployType,callerStack:new Error("deleteAgent-caller").stack?.split(`
|
|
100
|
+
`).slice(1,6).join(" | ")});let i=await Se(n),o=e._meta?.cozeDeployType==="cloud"||e._meta?.cozeDeployType==="local"?e._meta.cozeDeployType:void 0,c=e.deployType??o??i?.deployType??"local";this.opts.disposeForDelete&&await this.opts.disposeForDelete(n,e.reason??"delete");let d=ze(n);return c==="cloud"?(re.warn("[AUDIT] ABOUT TO RM agent dir (deleteAgent cloud path)",{src:"agent-handlers.deleteAgent",agentId:n,path:d.root,deployType:c,reason:e.reason??""}),await od(d.root,{recursive:!0,force:!0})):i&&(i.deletedAt=Date.now(),i.deleteReason=e.reason??"deleted",await Ue(i)),re.info("agent deleted",{agentId:n,reason:e.reason??"",deployType:c,configFound:!!i}),{ok:!0}}async switchModel(e){if(Pr(e._meta,"_agent/switchModel"),!e.agentId)throw new k("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let n=Xc(e.model)??It,i=await Se(e.agentId);if(!i)throw new k("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);i.model=n,e.modelInfo&&(i.modelInfo=e.modelInfo),await Ue(i),re.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:n,reason:e.reason??""});let o=this.opts.agents.get(e.agentId);if(!o)return re.info("_agent/switchModel: agent not running, config persisted only",{agentId:e.agentId}),{ok:!0};let c=o.model;if(o.model=n,e.modelInfo&&o.setModelInfo(e.modelInfo),this.opts.cleanupOpenclawProviders&&await this.opts.cleanupOpenclawProviders(o,c).catch(u=>re.warn("cleanupOpenclawProviders before switchModel failed (ignored)",{agentId:e.agentId,err:String(u)})),o.framework==="hermes"){let u=[];for(let[f,x]of o.allSessionQueues())u.push(x.enqueue(async()=>{let m=o.sessions.get(f);if(!(!m?.downstream||!m.acpSessionId))try{await m.downstream.setSessionModel?.({sessionId:m.acpSessionId,modelId:n})}catch(_){re.warn("_agent/switchModel: hermes session/set_model failed (ignored)",{agentId:e.agentId,cloudId:f,acpId:m.acpSessionId,err:String(_)})}}));return await Promise.all(u),re.info("_agent/switchModel: hermes sessions updated via session/set_model",{agentId:e.agentId,model:n,cloudSessions:u.length}),{ok:!0}}let d=[];for(let[u,f]of o.allSessionQueues())d.push(f.enqueue(async()=>{let x=o.sessions.get(u);x?.downstream&&(await x.downstream.stop(`switchModel: ${n}`).catch(()=>{}),x.downstream=void 0)}));return await Promise.all(d),re.info("_agent/switchModel: all session runtimes killed, next prompt will respawn",{agentId:e.agentId,model:n,cloudSessions:d.length}),{ok:!0}}async resetAgent(e){if(Pr(e._meta,xt.RESET),!e.agentId)throw new k("IPC_BAD_REQUEST",`${xt.RESET}: missing agentId`);return await this.clearSessionMappings(e.agentId,xt.RESET),this.opts.hermesReset&&await this.opts.hermesReset(e.agentId,e._meta?.cozeEnv).catch(n=>re.warn("hermes reset hook failed (ignored)",{agentId:e.agentId,err:String(n)})),await this.runDetailSync(e.agentId,xt.RESET,e.reason),{ok:!0}}async clearSessionMappings(e,n){let i=this.opts.agents.get(e);if(!i){await this.clearPersistedAcpSessionIds(e),re.info("reset: agent not in memory, cleared persisted acpSessionIds only",{agentId:e});return}await i.killAllRuntimes(n);for(let c of i.sessions.values())c.acpSessionId=void 0,c.replySeq=0,c.loadingSession=!1,c.spawnFailCount=void 0,c.spawnFailedAt=void 0;let o=new Map;for(let[c,d]of i.sessions)o.set(c,{modelToken:d.modelToken,tokenGeneratedAt:d.tokenGeneratedAt,permissionMode:d.permissionMode,cozeGroupId:d.cozeGroupId});await ai(e,o)}async clearPersistedAcpSessionIds(e){let n=await Se(e).catch(()=>null);if(!n?.sessions)return;let i=!1;for(let o of Object.values(n.sessions))o.acpSessionId&&(o.acpSessionId=void 0,i=!0);i&&await Ue(n)}async repairAgent(e){if(Pr(e._meta,xt.REPAIR),!e.agentId)throw new k("IPC_BAD_REQUEST",`${xt.REPAIR}: missing agentId`);let n=await this.loadAgentCfg(e.agentId);if(n&&n.framework!=="openclaw")throw new k("IPC_BAD_REQUEST",`${xt.REPAIR} only allowed for openclaw, got ${n.framework}`);if(n&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,n.workspace)}catch(i){re.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(i)})}return await this.runDetailSync(e.agentId,xt.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,n,i){if(!this.opts.detailSyncer){re.warn("detailSyncer not wired, skipping sync",{method:n,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(o){re.warn("detail sync failed (ignored)",{method:n,agentId:e,reason:i,err:String(o)})}}async getFileTree(e){Pr(e._meta,"_agent/getFileTree");let n=e._meta,i=Kn(n),o=await this.resolveWorkspace(i),c=e.filePath??"",d=this.safeJoin(o,c),u=await id(d).catch(()=>null);if(!u)throw new k("IPC_BAD_REQUEST",`path not found: ${c}`);if(u.isSymbolicLink())throw new k("IPC_BAD_REQUEST",`symlink not allowed: ${c}`);if(!await oi(d,o))throw new k("IPC_BAD_REQUEST",`path escapes workspace: ${c}`);let f=Jy(e.depth);return u.isDirectory()?{tree:await Vy(o,d,c,f)}:{tree:[{name:Zy(c),path:P0(c||"."),isDir:!1,size:u.size,modifiedAt:Math.floor(u.mtimeMs)}]}}async getFileContent(e){Pr(e._meta,"_agent/getFileContent");let n=Kn(e._meta),i=await this.resolveWorkspace(n);if(!e.filePath)throw new k("IPC_BAD_REQUEST","filePath required");let o=this.safeJoin(i,e.filePath),c=await id(o).catch(()=>null);if(!c||!c.isFile())throw new k("IPC_BAD_REQUEST",`not a file: ${e.filePath}`);if(c.isSymbolicLink())throw new k("IPC_BAD_REQUEST",`symlink not allowed: ${e.filePath}`);if(!await oi(o,i))throw new k("IPC_BAD_REQUEST",`path escapes workspace: ${e.filePath}`);if(c.size>x0)throw new k("IPC_BAD_REQUEST",`file too large: ${c.size} bytes (max ${x0})`);let d=await _o(o);return d.includes(0)?{content:d.toString("base64"),encoding:"base64",size:c.size}:{content:d.toString("utf8"),encoding:"utf-8",size:c.size}}async resolveWorkspace(e){let n=this.opts.agents.get(e);return n?n.workspace:(await Se(e).catch(()=>null))?.workspace??ze(e).workspace}safeJoin(e,n){let i=cd(e,n||"."),o=ud(e,i);if(o.startsWith("..")||o===".."||o.startsWith(`..${m0}`))throw new k("IPC_BAD_REQUEST",`path escapes workspace: ${n}`);return i}loadAgentCfg(e){return Se(e)}async requireAgentCfg(e){let n=await this.loadAgentCfg(e);if(!n)throw new k("AGENT_NOT_FOUND",`no config for agent: ${e}`);return n}};function y0(t){let e=t.trim().replace(/[\x00-\x1f<>:"|?*/\\]+/g,"-").replace(/^[\s.-]+|[\s.-]+$/g,"").slice(0,64);if(!e||e==="."||e==="..")throw new k("IPC_BAD_REQUEST",`invalid skill name: ${t}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new k("IPC_BAD_REQUEST",`reserved windows filename: ${t}`);return e}function Or(t,e,n,i){switch(t){case"claude-code":return{base:n,subdir:ue(".claude","skills")};case"codex":case"openclaw":return{base:n,subdir:ue(".agents","skills")};case"hermes":return{base:Vn(e,i??Y()),subdir:"skills"}}}function E0(t){let e=by();if(t==="claude-code")return[ue(e,".claude","skills")];if(t==="codex")return[ue(e,".agents","skills"),ue(e,".codex","skills")];if(t==="openclaw")return[ue(e,".agents","skills"),ue(e,".openclaw","skills")];if(t==="hermes"){if(process.platform==="win32"){let n=process.env.LOCALAPPDATA||ue(e,"AppData","Local");return[ue(n,"hermes","skills"),ue(e,".hermes","skills")]}return[ue(e,".hermes","skills")]}return[]}async function Oy(t,e,n,i,o,c){let d=async u=>ld(ue(u,"SKILL.md")).then(f=>f.isFile()).catch(()=>!1);if(!o){let{base:u,subdir:f}=Or(n,t,e,c),x=ue(f,i),m=ue(u,x);return await d(m)?{absDir:m,relPath:x}:null}for(let u of E0(n)){let f=ue(u,i);if(await d(f))return{absDir:f,relPath:f}}return null}async function Ly(t,e,n,i,o,c){let d=y0(i),u=await Oy(t,e,n,d,o,c);if(u)return{...u,dirName:d};let x=(o?await A0(t,n):await I0(t,e,n,c)).filter(v=>v.skill.skillName===i);if(x.length>1)throw new k("SKILL_NOT_FOUND",`multiple skills named "${i}" in ${o?"global":"workspace"}: ${x.map(v=>h0(v.relPath)).join(", ")} \u2014 rename or remove duplicates`);let m=x[0];return m?{absDir:o?m.relPath:ue(e,m.relPath),relPath:m.relPath,dirName:h0(m.relPath)}:null}function b0(t,e){return(Ey("sha256").update(`${t}\0${e}`).digest().readBigUInt64BE(0)&0x7fffffffffffffffn).toString()}function v0(t){if(!t.startsWith("---"))return{};let e=t.indexOf(`
|
|
101
|
+
---`,3);if(e<0)return{};let n=t.slice(3,e),i={};for(let o of n.split(`
|
|
102
|
+
`)){let c=/^\s*(name|description)\s*:\s*(.+?)\s*$/.exec(o);if(!c||!c[2])continue;let d=c[1],u=c[2].trim();(u.startsWith('"')&&u.endsWith('"')||u.startsWith("'")&&u.endsWith("'"))&&(u=u.slice(1,-1)),u&&(i[d]=u)}return i}async function S0(t,e,n,i){let o=await g0(e,{withFileTypes:!0}).catch(()=>null);if(!o)return[];let c=[];for(let d of o){let u=d.isDirectory();if(!u&&d.isSymbolicLink()&&(u=!!(await ld(ue(e,d.name)).catch(()=>null))?.isDirectory()),!u)continue;let f=d.name,x=ue(n,f),m=ue(e,f,"SKILL.md"),_=await _o(m,{encoding:"utf8"}).catch(()=>null);if(_===null)continue;let v=v0(_);c.push({relPath:x,skill:{skillId:b0(t,x),skillName:v.name||f,...v.description?{description:v.description}:{},...i?{isGlobal:!0}:{}}})}return c}async function I0(t,e,n,i){let{base:o,subdir:c}=Or(n,t,e,i);return S0(t,ue(o,c),c,!1)}async function A0(t,e){let n=[],i=new Set;for(let o of E0(e)){let c=await S0(t,o,o,!0);for(let d of c)i.has(d.relPath)||(i.add(d.relPath),n.push(d))}return n}var Ny=3e4,My=50*1024*1024,p0=10*1024*1024,Dr=3e4;async function Eo(t){let{agentId:e,workspace:n,framework:i,skill:o,paths:c}=t;if(!o.skillName)throw new k("IPC_BAD_REQUEST","skill missing skillName");let d=typeof o.content=="string"&&o.content.length>0,u=typeof o.downloadUrl=="string"&&o.downloadUrl.length>0;if(!d&&!u)throw new k("IPC_BAD_REQUEST",`skill ${o.skillId} missing both content and downloadUrl`);let f=y0(o.skillName),{base:x,subdir:m}=Or(i,e,n,c),_=ue(m,f),v=ue(x,_);if(await sd(v,{recursive:!0}),d){let b=Buffer.from(o.content,"utf8");Gi(b.length),await ad(ue(v,"SKILL.md"),b,"utf8")}else{let b=await zy(o.downloadUrl);Gy(b)?await Wy(b,v):Hy(b)?await qy(b,v):await ad(ue(v,"SKILL.md"),b.toString("utf8"),"utf8")}let y={skillId:o.skillId,skillName:o.skillName,relPath:_,installedAt:Date.now(),...o.description?{description:o.description}:{},...o.icon?{icon:o.icon}:{},...o.version?{version:o.version}:{},...o.downloadUrl?{downloadUrl:o.downloadUrl}:{},...o.config?{config:o.config}:{},...o.builtin?{builtin:o.builtin}:{}};return re.info("skill installed",{agentId:e,skillId:o.skillId,skillName:o.skillName,relPath:_,source:d?"content":"downloadUrl"}),y}function bo(t,e,n){let i=e.get(n.skillId);if(i!==void 0){t[i]=n;return}e.set(n.skillId,t.length),t.push(n)}function By(t){return{skillId:t.skillId,skillName:t.skillName,...t.description?{description:t.description}:{},...t.icon?{icon:t.icon}:{},...t.version?{version:t.version}:{},...t.config?{config:t.config}:{},...t.builtin?{builtin:t.builtin}:{}}}function Fy(t){return{skillId:t.skillId,skillName:t.skillName,...t.downloadUrl?{downloadUrl:t.downloadUrl}:{},...t.description?{description:t.description}:{},...t.icon?{icon:t.icon}:{},...t.version?{version:t.version}:{},...t.config?{config:t.config}:{},...t.builtin?{builtin:t.builtin}:{}}}async function k0(t,e){let n=await Se(t,e);if(!n)return{status:"skipped",count:0};if(n.disconnectedAt)return{status:"skipped",count:0};let i=Lt,o=n.skillsRefreshedForVersion;if(o===i)return{status:"noop",count:0};if(!o)return n.skillsRefreshedForVersion=i,await Ue(n,e),{status:"seeded",count:0};let c=[...n.skills??[]],d=new Map(c.map((_,v)=>[_.skillId,v])),u=c.filter(_=>_.builtin===!0&&!!_.downloadUrl);if(u.length===0)return n.skillsRefreshedForVersion=i,await Ue(n,e),{status:"noop",count:0};let f=0,x=0,{base:m}=Or(n.framework,t,n.workspace,e);re.warn("[AUDIT] refreshBuiltinSkills triggered (version bump)",{src:"agent-handlers.refreshAgentBuiltinSkillsOnUpgrade",agentId:t,framework:n.framework,prev:o,current:i,skillBase:m,builtinCount:u.length,builtinRelPaths:u.map(_=>_.relPath)});for(let _ of u)try{let v=ue(m,_.relPath);re.warn("[AUDIT] ABOUT TO RM builtin skill dir (refreshBuiltinSkills)",{src:"agent-handlers.refreshAgentBuiltinSkillsOnUpgrade",agentId:t,skillId:_.skillId,relPath:_.relPath,rmTarget:v}),await od(v,{recursive:!0,force:!0});let y=await Eo({agentId:t,workspace:n.workspace,framework:n.framework,skill:Fy(_),...e?{paths:e}:{}});bo(c,d,y),f+=1}catch(v){x+=1,re.warn("refresh builtin skill failed (skipping)",{agentId:t,skillId:_.skillId,skillName:_.skillName,err:String(v)})}return n.skills=c,x===0&&(n.skillsRefreshedForVersion=i),await Ue(n,e),re.info("builtin skills refreshed after bridge upgrade",{agentId:t,from:o,to:i,ok:f,failed:x}),{status:"refreshed",count:f}}async function zy(t){if(!t)throw new k("IPC_BAD_REQUEST","skill missing downloadUrl");if(t.startsWith("data:")){let e=Math.floor(t.length*3/4);Gi(e);let n=Uy(t);return Gi(n.length),n}if(t.startsWith("file:")){let e=new URL(t).pathname,n=await _o(e);return Gi(n.length),n}if(Ni(t)){let e=new AbortController,n=setTimeout(()=>e.abort(),Ny);try{let i=await fetch(t,{signal:e.signal});if(!i.ok)throw new k("IPC_BAD_REQUEST",`fetch skill failed HTTP ${i.status} ${t}`);let o=await i.arrayBuffer();return Gi(o.byteLength),Buffer.from(o)}finally{clearTimeout(n)}}throw new k("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${t.slice(0,80)}`)}function Gi(t){if(t>My)throw new k("IPC_BAD_REQUEST",`skill too large: ${t} bytes`)}function Uy(t){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(t);if(!e)throw new k("IPC_BAD_REQUEST","bad data URL");let n=!!e[2],i=e[3]??"";return n?Buffer.from(i,"base64"):Buffer.from(decodeURIComponent(i),"utf8")}function Gy(t){return t.length>=2&&t[0]===31&&t[1]===139}function Hy(t){if(t.length<4||t[0]!==80||t[1]!==75)return!1;let e=t[2],n=t[3];return e===3&&n===4||e===5&&n===6}function dd(t){return t==="__MACOSX"||t.startsWith("__MACOSX/")}async function qy(t,e){let n,i;try{n=new fd.default(t),i=n.getEntries()}catch(d){throw new k("IPC_BAD_REQUEST",`zip parse failed: ${d.message}`,{cause:d})}for(let d of i){let u=d.entryName;if(!u||dd(u))continue;if(u.startsWith("/")||/^[A-Za-z]:[\\/]/.test(u))throw new k("IPC_BAD_REQUEST",`zip entry absolute path: ${u}`);if(u.split(/[/\\]/).some(x=>x===".."))throw new k("IPC_BAD_REQUEST",`zip entry contains '..' (traversal): ${u}`);let f=d.header.attr>>>16&61440;if(f!==0&&f!==32768&&f!==16384)throw new k("IPC_BAD_REQUEST",`zip entry kind 0x${f.toString(16)} not allowed (symlink/hardlink/special): ${u}`)}let o=jy(i),c=cd(e);for(let d of i){if(dd(d.entryName))continue;let u=d.entryName;if(o&&u.startsWith(o)&&(u=u.slice(o.length)),!u)continue;let f=cd(e,u),x=ud(c,f);if(x.startsWith("..")||x==="..")throw new k("IPC_BAD_REQUEST",`zip entry escapes destDir: ${u}`);if(d.isDirectory){await sd(f,{recursive:!0});continue}await sd(vy(f),{recursive:!0});let m;try{m=d.getData()}catch(_){throw new k("IPC_BAD_REQUEST",`zip entry getData failed (${d.entryName}): ${_.message}`,{cause:_})}await ad(f,m)}}function jy(t){let e;for(let n of t){let i=n.entryName;if(!i||dd(i))continue;let o=i.indexOf("/");if(o<=0)return;let c=i.slice(0,o+1);if(e===void 0)e=c;else if(e!==c)return}return e}async function Wy(t,e){await Ky(t);let n=zf({cwd:e,strip:1}),i=!1,o=setTimeout(()=>{i=!0,n.destroy(new k("IPC_BAD_REQUEST",`tar extract timeout (${Dr}ms)`))},Dr);try{await _0(w0.from(t),n)}catch(c){throw c instanceof k?c:i?new k("IPC_BAD_REQUEST",`tar extract timeout (${Dr}ms)`):new k("IPC_BAD_REQUEST",`tar extract failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}}async function Ky(t){let e=[],n=Tr({onReadEntry:c=>{let d=c.path,u=c.type;if(u!=="File"&&u!=="Directory"){e.push(`tar entry kind '${u}' not allowed (symlink/hardlink/special): ${d.slice(0,100)}`);return}if(d.startsWith("/")||d.startsWith("\\")||/^[a-zA-Z]:[\\/]/.test(d)){e.push(`tar entry absolute path: ${d}`);return}d.split(/[/\\]/).some(x=>x==="..")&&e.push(`tar entry contains '..': ${d}`)}}),i=!1,o=setTimeout(()=>{i=!0,n.destroy(new k("IPC_BAD_REQUEST",`tar list timeout (${Dr}ms)`))},Dr);try{await _0(w0.from(t),n)}catch(c){throw i?new k("IPC_BAD_REQUEST",`tar list timeout (${Dr}ms)`):new k("IPC_BAD_REQUEST",`tar list failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}if(e.length>0)throw new k("IPC_BAD_REQUEST",e[0]??"tar entry validation failed")}var $y=5e3;async function Vy(t,e,n,i){return T0(t,e,n,i,{count:0})}async function T0(t,e,n,i,o){if(i<=0)return[];let c;try{c=await g0(e,{withFileTypes:!0})}catch{return[]}let d=[];for(let u of c){if(ky.has(u.name)||u.isSymbolicLink())continue;if(o.count>=$y){d.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let f=ue(e,u.name),x=Sy(ue(n,u.name)),m=null;try{m=await id(f)}catch{continue}if(m.isSymbolicLink())continue;o.count++;let _={name:u.name,path:P0(ud(t,f)),isDir:m.isDirectory(),size:m.size,modifiedAt:Math.floor(m.mtimeMs)};m.isDirectory()&&i>1&&(_.children=await T0(t,f,x,i-1,o)),d.push(_)}return d.sort((u,f)=>u.isDir!==f.isDir?u.isDir?-1:1:u.name.localeCompare(f.name)),d}function Jy(t){return!t||t<=0?Iy:Math.min(t,Ay)}function Zy(t){if(!t||t==="."||t==="/")return".";let e=t.split(/[/\\]/);return e[e.length-1]||"."}function P0(t){return t.split(m0).join("/")}ne();var Sn=q("agent-health-reporter"),Yy=1e4,Xy=3,Hi=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??Yy,this.livenessFailureThreshold=e.livenessFailureThreshold??Xy}opts;timer=null;inFlight=!1;unsubscribeRegister=null;intervalMs;livenessFailureThreshold;consecutiveFailures=0;isLivenessLost(){return this.consecutiveFailures>=this.livenessFailureThreshold}start(){this.timer||(this.timer=setInterval(()=>{this.tick()},this.intervalMs),this.timer.unref?.(),this.unsubscribeRegister=this.opts.core.onAgentRegister(()=>{this.tick()}),Sn.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),Sn.info("heartbeat stopped"))}async tick(){if(this.inFlight){Sn.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){this.consecutiveFailures=0,Sn.debug("deviceId not available, skip tick (\u5C1A\u672A pair)");return}this.inFlight=!0;try{let n=[];for(let d of this.opts.core.agents.values()){let u=Qy(d);if(!u)continue;let f={agentId:d.agentId,status:u};d.patToken&&(f.patToken=d.patToken),d.accountId&&(f.accountId=d.accountId),n.push(f)}if(n.length===0){this.consecutiveFailures=0;return}let i={agents:n,bridgeVersion:Lt,_meta:{cozeDeviceId:e}},o;try{o=await this.opts.core.sendRequest("_agent/health",i,5e3),this.consecutiveFailures=0}catch(d){this.consecutiveFailures+=1,Sn.warn("heartbeat batch send failed",{count:n.length,consecutiveFailures:this.consecutiveFailures,err:String(d)})}let c=o?.authFailures;if(c&&c.length>0&&(Sn.warn("heartbeat received authFailures from cloud",{count:c.length,agentIds:c.map(d=>d.agentId)}),this.opts.onAuthFailures))try{await this.opts.onAuthFailures(c)}catch(d){Sn.warn("onAuthFailures callback failed (ignored)",{err:String(d)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(n){Sn.warn("onTickEnd hook failed",{err:String(n)})}}};function Qy(t){return t.status==="error"?"error":t.activeTriggers.size>0?"busy":t.status==="ok"?"online":null}qt();import{mkdir as gd,rm as WE,stat as KE}from"node:fs/promises";import{homedir as $E}from"node:os";import{join as oh}from"node:path";dn();import{existsSync as lE}from"node:fs";import{release as uE}from"node:os";import{basename as fE,isAbsolute as hE}from"node:path";function qi(t,e,n){return n===void 0?{jsonrpc:"2.0",id:t,method:e}:{jsonrpc:"2.0",id:t,method:e,params:n}}function Lr(t,e){return e===void 0?{jsonrpc:"2.0",method:t}:{jsonrpc:"2.0",method:t,params:e}}function Nr(t,e){return{jsonrpc:"2.0",id:t,result:e}}function In(t,e){return{jsonrpc:"2.0",id:t,error:e}}$e();var vo=class extends Error{code;data;constructor(e){super(`JSON-RPC error code=${e.code} ${e.message}`),this.name="RemoteRpcError",this.code=e.code,e.data!==void 0&&(this.data=e.data)}},X={PARSE_ERROR:-32700,INVALID_REQUEST:-32600,METHOD_NOT_FOUND:-32601,INVALID_PARAMS:-32602,INTERNAL_ERROR:-32603,AGENT_NOT_FOUND:-32001,AGENT_BUSY:-32002,AGENT_TIMEOUT:-32003,AGENT_SPAWN_FAILED:-32004,OPERATION_NOT_ALLOWED_FOR_LOCAL:-32005,AGENT_DISCONNECTED:-32006,MODEL_TOKEN_GEN_FAILED:-32009,PATH_OUTSIDE_WORKSPACE:-32010,FILE_TOO_LARGE:-32011,UNSUPPORTED_MIME:-32012,UPLOAD_FAILED:-32013,UPSTREAM_NOT_READY:-32014,AGENT_FRAME_IDLE_TIMEOUT:-32016,MODEL_MODALITY_UNSUPPORTED:-32017,AGENT_DEPENDENCY_INSTALL_FAILED:-32018,AGENT_APPROVAL_TIMEOUT:-32019,AGENT_TURN_ABORTED:-32020,AGENT_ENV_NOT_READY:-32021,SKILL_NOT_FOUND:-32022,SKILL_ZIP_TOO_LARGE:-32023,OPERATION_NOT_ALLOWED_FOR_CLOUD:-32024};function R0(t){return"method"in t&&"id"in t&&t.id!==void 0}function C0(t){return"method"in t&&!("id"in t)}function So(t){return!("method"in t)&&"id"in t}var eE={AGENT_NOT_FOUND:X.AGENT_NOT_FOUND,AGENT_BUSY:X.AGENT_BUSY,AGENT_DISCONNECTED:X.AGENT_DISCONNECTED,AGENT_TIMEOUT:X.AGENT_TIMEOUT,AGENT_FRAME_IDLE_TIMEOUT:X.AGENT_FRAME_IDLE_TIMEOUT,AGENT_SPAWN_FAILED:X.AGENT_SPAWN_FAILED,AGENT_PROTOCOL_ERROR:X.INTERNAL_ERROR,BRIDGE_CONFIG_INVALID:X.INTERNAL_ERROR,BRIDGE_INTERNAL:X.INTERNAL_ERROR,IPC_AUTH_FAILED:X.INTERNAL_ERROR,IPC_BAD_REQUEST:X.INVALID_REQUEST,METHOD_NOT_FOUND:X.METHOD_NOT_FOUND,MODEL_TOKEN_GEN_FAILED:X.MODEL_TOKEN_GEN_FAILED,MODEL_MODALITY_UNSUPPORTED:X.MODEL_MODALITY_UNSUPPORTED,OPERATION_NOT_ALLOWED_FOR_LOCAL:X.OPERATION_NOT_ALLOWED_FOR_LOCAL,OPERATION_NOT_ALLOWED_FOR_CLOUD:X.OPERATION_NOT_ALLOWED_FOR_CLOUD,UPSTREAM_DISCONNECTED:X.INTERNAL_ERROR,UPSTREAM_HANDSHAKE_FAILED:X.INTERNAL_ERROR,PATH_OUTSIDE_WORKSPACE:X.PATH_OUTSIDE_WORKSPACE,FILE_TOO_LARGE:X.FILE_TOO_LARGE,UNSUPPORTED_MIME:X.UNSUPPORTED_MIME,UPLOAD_FAILED:X.UPLOAD_FAILED,UPSTREAM_NOT_READY:X.UPSTREAM_NOT_READY,AGENT_DEPENDENCY_INSTALL_FAILED:X.AGENT_DEPENDENCY_INSTALL_FAILED,AGENT_APPROVAL_TIMEOUT:X.AGENT_APPROVAL_TIMEOUT,AGENT_TURN_ABORTED:X.AGENT_TURN_ABORTED,AGENT_ENV_NOT_READY:X.AGENT_ENV_NOT_READY,SKILL_NOT_FOUND:X.SKILL_NOT_FOUND,SKILL_ZIP_TOO_LARGE:X.SKILL_ZIP_TOO_LARGE};function tE(t){if(t!=null)return t instanceof Error?{name:t.name,message:ji(t.message)}:typeof t=="string"?ji(t):typeof t=="object"?rE(t):t}var nE=[[/\/Users\/[^/\s'"`)]+/g,"/Users/<redacted>"],[/\/home\/[^/\s'"`)]+/g,"/home/<redacted>"],[/[A-Za-z]:\\Users\\[^\\\s'"`)]+/g,"C:\\Users\\<redacted>"],[/(Bearer|Token|Authorization:)\s+[\w._-]+/gi,"$1 <redacted>"],[/\b(sk|pat|ak)[-_][A-Za-z0-9_-]{20,}\b/g,"<redacted-key>"]];function ji(t){let e=t;for(let[n,i]of nE)e=e.replace(n,i);return e}function rE(t){let e={};for(let[n,i]of Object.entries(t))typeof i=="string"?e[n]=ji(i):e[n]=i;return e}function Wi(t){if(t instanceof k){let e=tE(t.cause),n={bridgeCode:t.code,retriable:t.retriable};return e!==void 0&&(n.cause=e),e&&typeof e=="object"&&"reason"in e&&typeof e.reason=="string"&&(n.reason=e.reason),{code:eE[t.code]??X.INTERNAL_ERROR,message:ji(t.message),data:n}}return{code:X.INTERNAL_ERROR,message:ji(t instanceof Error?t.message:String(t))}}function D0(t){let e=t.data,n=e?.bridgeCode??"AGENT_PROTOCOL_ERROR",i=!!e&&typeof e.message=="string"&&!!e.message,o=i?e?.message:t.message,c=t.data;if(i&&e){let{message:d,...u}=e;c=u}return new k(n,o,{retriable:e?.retriable??!1,cause:c})}function L0(t){return`${JSON.stringify(t)}
|
|
103
|
+
`}var O0=10*1024*1024,Io=class{buffer="";onError;constructor(e={}){this.onError=e.onError}push(e){if(this.buffer+=typeof e=="string"?e:e.toString("utf8"),this.buffer.length>O0){let o=this.buffer.length;return this.buffer="",this.onError?.({line:`<buffer overflow: ${o} bytes, dropped>`,error:new Error(`LdjsonDecoder buffer exceeded ${O0} bytes`)}),[]}let n=this.buffer.split(`
|
|
104
|
+
`);this.buffer=n.pop()??"";let i=[];for(let o of n){let c=o.replace(/\r$/,"").trim();if(c)try{i.push(JSON.parse(c))}catch(d){this.onError?.({line:c,error:d})}}return i}flush(){if(!this.buffer)return[];let e=this.buffer.replace(/\r$/,"").trim();if(this.buffer="",!e)return[];try{return[JSON.parse(e)]}catch(n){return this.onError?.({line:e,error:n}),[]}}};var M0={"session/prompt":"session.prompt","session/cancel":"session.cancel","session/new":"session.new","session/load":"session.load","_agent/create":"agent.create","_agent/health":"agent.health","_agent/pair":"agent.pair","_agent/listSkills":"agent.listSkills","_agent/addSkills":"agent.addSkills","_agent/removeSkills":"agent.removeSkills","_agent/getFileTree":"agent.getFileTree","_agent/getFileContent":"agent.getFileContent","_agent/detail":"agent.detail","_agent/update":"agent.update","_agent/disconnect":"agent.disconnect","_agent/switchModel":"agent.switchModel","_agent/genModelToken":"agent.genModelToken","_agent/reset":"agent.reset","_agent/repair":"agent.repair","session/request_permission":"session.requestPermission","session/set_mode":"session.setMode",initialize:"initialize"},_1=Object.fromEntries(Object.entries(M0).map(([t,e])=>[e,t])),iE={"session.prompt":["agentId","triggerMsgId","sessionId"],"session.cancel":["agentId","triggerMsgId","sessionId"],"session.new":["agentId"],"session.load":["agentId"],"agent.create":["agentId"],"agent.health":[],"agent.listSkills":["agentId"],"agent.addSkills":["agentId"],"agent.removeSkills":["agentId"],"agent.getFileTree":["agentId"],"agent.getFileContent":["agentId"],"agent.detail":["agentId"],"agent.update":["agentId"],"agent.disconnect":["agentId"],"agent.switchModel":["agentId"],"agent.genModelToken":["agentId","sessionId"],"agent.reset":["agentId"],"agent.repair":["agentId"],"session.requestPermission":["agentId","sessionId"],"session.setMode":["agentId","sessionId"],"agent.pair":[],initialize:[]},Mr=class{seq=0;next(e,n){this.seq+=1;let i=M0[e]??sE(e),o=iE[i]??[],c=[i,String(this.seq)];if(o.length>0){let d=o.map(f=>N0(n?.[f]??"")),u=oE(d).join(":");u&&c.push(u)}else n&&Object.values(n).some(d=>d)&&c.push(Object.values(n).filter(Boolean).map(d=>N0(String(d))).join(":"));return c.join("_")}reset(){this.seq=0}};function sE(t){return t.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function N0(t){return t.replace(/[:_\s]+/g,"-")}function oE(t){let e=t.length;for(;e>0&&!t[e-1];)e-=1;return t.slice(0,e)}Zt();or();$e();ne();Re();import{execFileSync as aE,spawnSync as cE}from"node:child_process";function Ki(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}function $i(t,e){if(!(typeof t!="number"||t<=0))try{if(process.platform==="win32"){let n=["/PID",String(t),"/T"];e==="SIGKILL"&&n.push("/F"),cE("taskkill",n,{stdio:"ignore",windowsHide:!0})}else process.kill(-t,e)}catch{}}var hd=new Set;function B0(t){typeof t=="number"&&t>0&&hd.add(t)}function F0(t){typeof t=="number"&&hd.delete(t)}function z0(){for(let t of hd)$i(t,"SIGKILL")}var Br="coze-bridge-daemon";function U0(t){let e=t?.execFn??(()=>{if(process.platform==="win32")return"";let o=process.getuid?.()??0;return aE("pgrep",["-U",String(o),"-f",Br],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:2e3})}),n;try{n=e()}catch{return[]}let i=process.pid;return n.split(`
|
|
105
|
+
`).map(o=>Number.parseInt(o.trim(),10)).filter(o=>Number.isFinite(o)&&o>0&&o!==i)}async function G0(t,e){if(t.length===0)return;let n=e?.killFn??$i,i=e?.isAliveFn??Ki,o=e?.sleepFn??(u=>new Promise(f=>setTimeout(f,u))),c=e?.graceMs??3e3,d=e?.pollMs??100;for(let u of t)n(u,"SIGTERM");for(let u=0;u<c&&t.some(f=>i(f));u+=d)await o(Math.min(d,c-u));for(let u of t)i(u)&&n(u,"SIGKILL")}var dE=[{reason:"openclaw_scope_approval_pending",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/scope upgrade pending approval/i,message:"openclaw \u9700\u8981\u4F60\u5728\u672C\u673A\u6279\u51C6\u4E00\u6B21\u6743\u9650\u5347\u7EA7 (scope upgrade)\uFF0C\u8BF7\u5728\u672C\u673A openclaw \u5B8C\u6210\u6388\u6743\u540E\u91CD\u8BD5"},{reason:"openclaw_pairing_required",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/pairing required/i,message:"openclaw \u5C1A\u672A\u5B8C\u6210\u914D\u5BF9\uFF0C\u8BF7\u5148\u5728\u672C\u673A\u5B8C\u6210 openclaw \u914D\u5BF9\u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_token_unavailable",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/gateway\.auth\.token.*(unavailable|secret reference)/i,message:"openclaw gateway token \u914D\u7F6E\u4E0D\u53EF\u7528 (\u914D\u6210\u4E86 secret \u5F15\u7528\u4F46\u5F53\u524D\u8DEF\u5F84\u53D6\u4E0D\u5230)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A openclaw \u7684 gateway.auth.token \u914D\u7F6E"},{reason:"openclaw_version_mismatch",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/protocol mismatch/i,message:"openclaw \u7248\u672C\u4E0E\u672C\u673A gateway \u4E0D\u517C\u5BB9 (protocol mismatch)\uFF0C\u8BF7\u5347\u7EA7\u672C\u673A openclaw \u5230\u6700\u65B0\u7248\u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_not_ready",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/gateway closed (before ready|\(\d+\))/i,message:"openclaw gateway \u672A\u5C31\u7EEA (\u53EF\u80FD\u6B63\u5728\u542F\u52A8)\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"},{reason:"openclaw_config_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/OpenClaw config is invalid|Config invalid|Invalid config at|config was written by version/i,message:"\u4F60\u7684\u672C\u673A openclaw \u914D\u7F6E\u975E\u6CD5 (~/.openclaw/openclaw.json)\uFF0C\u8BF7\u8FD0\u884C `openclaw doctor --fix` \u6216 `openclaw config validate` \u4FEE\u590D\u540E\u91CD\u8BD5"},{reason:"openclaw_tls_self_signed",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/self-signed certificate/i,message:"openclaw \u8FDE\u63A5\u88AB\u81EA\u7B7E\u8BC1\u4E66/\u4F01\u4E1A\u4EE3\u7406\u62E6\u622A (self-signed certificate)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A\u7F51\u7EDC/\u4EE3\u7406\u6216\u8BC1\u4E66\u914D\u7F6E\u540E\u91CD\u8BD5"},{reason:"openclaw_node_binary_not_found",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/\[qclaw-cli\] Error: (Node binary not found|QCLAW_CLI_NODE_BINARY not set)/i,message:"\u672C\u673A\u627E\u4E0D\u5230 node \u4E8C\u8FDB\u5236 (qclaw \u542F\u52A8\u5931\u8D25)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A Node \u5B89\u88C5\u4E0E PATH \u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_unavailable",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/ECONNREFUSED|\[object ErrorEvent\]|gateway connect failed|gateway (not connected|disconnected)/i,message:"openclaw gateway \u672A\u8FD0\u884C/\u672A\u8FDE\u63A5 (\u8FDE\u63A5\u672C\u673A gateway \u88AB\u62D2\u6216\u4F1A\u8BDD\u671F\u95F4\u65AD\u5F00)\uFF0C\u8BF7\u5728\u672C\u673A\u542F\u52A8 openclaw gateway \u540E\u91CD\u8BD5"},{reason:"openclaw_shim_bug",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["openclaw"],match:/openclaw-shim\/bin\/openclaw.*unbound variable/i,message:"openclaw \u542F\u52A8 shim \u811A\u672C\u5F02\u5E38 (unbound variable)\uFF0C\u8BF7\u53CD\u9988\u73AF\u5883\u7EF4\u62A4\u65B9\u4FEE\u590D shim"},{reason:"codex_user_config_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/error loading config:.*config\.toml|model_catalog_json|wire_api/i,message:"\u4F60\u7684\u672C\u673A ~/.codex/config.toml \u914D\u7F6E\u6709\u8BEF\uFF0C\u8BF7\u6309 codex \u62A5\u9519\u63D0\u793A\u4FEE\u6B63\u540E\u91CD\u8BD5"},{reason:"codex_provider_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/error loading config: Model provider .* not found/i,message:"\u4F60\u7684\u672C\u673A codex \u914D\u7F6E\u5F15\u7528\u4E86\u4E0D\u5B58\u5728\u7684 model provider\uFF0C\u8BF7\u4FEE\u6B63 ~/.codex \u914D\u7F6E\u540E\u91CD\u8BD5"},{reason:"codex_path_update_failed",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/could not update PATH[\s\S]*Operation not permitted/i,message:"codex \u56E0\u672C\u673A\u6743\u9650\u9650\u5236\u65E0\u6CD5\u66F4\u65B0 PATH/\u8BFB\u53D6\u914D\u7F6E (Operation not permitted)\uFF0C\u8BF7\u68C0\u67E5 ~/.codex \u76EE\u5F55\u6743\u9650\u6216\u91CD\u65B0\u6388\u4E88\u7EC8\u7AEF\u5B8C\u5168\u78C1\u76D8\u8BBF\u95EE\u540E\u91CD\u8BD5"},{reason:"node_version_too_old",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/import\.meta\.resolve is not a function|\.resolve is not a function/i,message:"\u672C\u673A Node \u7248\u672C\u8FC7\u4F4E (codex ACP \u9700\u8981 import.meta.resolve)\uFF0C\u8BF7\u5347\u7EA7 Node \u5230 \u2265 20 \u540E\u91CD\u8BD5"},{reason:"codex_acp_exec_failed",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["codex"],match:/Failed to execute[\s\S]*codex-acp|spawnSync[\s\S]*codex-acp/i,message:"codex ACP \u4E8C\u8FDB\u5236\u6267\u884C\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect \u89E6\u53D1\u4F9D\u8D56\u5B89\u88C5"},{reason:"codex_platform_binary_missing",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["codex"],match:/Failed to locate @zed-industries\/codex-acp|optional dependency was not installed/i,message:"codex ACP \u4F9D\u8D56\u7684\u5E73\u53F0\u4E8C\u8FDB\u5236\u7F3A\u5931\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect \u89E6\u53D1\u4F9D\u8D56\u5B89\u88C5"},{reason:"acp_module_missing",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["claude-code","codex"],match:/Cannot find (module|package)[^\n]*node_modules[\\/]@(agentclientprotocol[\\/](claude-agent-acp|codex-acp)|openai[\\/]codex|zed-industries[\\/]codex-acp)|Cannot find package ['"]@openai[\\/]codex['"][\s\S]*node_modules[\\/]@agentclientprotocol[\\/]codex-acp/i,message:"ACP \u4F9D\u8D56\u672A\u6B63\u786E\u5B89\u88C5 (wrapper \u5165\u53E3\u7F3A\u5931)\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect \u89E6\u53D1\u4F9D\u8D56\u91CD\u88C5"},{reason:"node_version_too_old",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["claude-code","openclaw"],match:/import .* with \{ type: ["']json["'] \}|import assertion|import attribute|openclaw\.mjs[\s\S]*Unexpected token '\.'/i,message:"\u672C\u673A Node \u7248\u672C\u8FC7\u4F4E (ACP \u9700\u8981\u8F83\u65B0 Node \u624D\u652F\u6301 import attributes / \u53EF\u9009\u94FE)\uFF0C\u8BF7\u5347\u7EA7 Node \u5230 \u2265 20.10 \u540E\u91CD\u8BD5"},{reason:"acp_cmd_misexec",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["claude-code"],match:/claude-agent-acp\.cmd.*@ECHO off|\.cmd:\d+/i,message:"claude ACP wrapper \u542F\u52A8\u65B9\u5F0F\u5F02\u5E38 (Windows .cmd \u88AB\u8BEF\u5F53\u811A\u672C\u6267\u884C)\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect"},{reason:"hermes_provider_not_configured",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["hermes"],match:/(no.*openai.*provider|OPENAI_API_KEY.*(not set|missing)|(provider|model).*(not configured|misconfigured)|hermes.*setup.*required)/i,message:"hermes provider/API key \u672A\u914D\u7F6E\u597D, \u8BF7\u68C0\u67E5 <HERMES_HOME>/config.yaml + .env \u540E\u91CD\u8BD5"},{reason:"prompt_too_long",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["claude-code"],match:/Prompt is too long|bad request: failed to read body: length limit exceeded/i,message:"\u672C\u8F6E\u8F93\u5165\u8FC7\u957F\uFF0C\u8D85\u8FC7\u6A21\u578B\u4E0A\u4E0B\u6587\u4E0A\u9650\uFF0C\u8BF7\u7CBE\u7B80\u8F93\u5165\u6216\u5F00\u542F\u65B0\u4F1A\u8BDD\u540E\u91CD\u8BD5"}];function H0(t,e){if(!e)return null;for(let n of dE)if(!(n.frameworks&&!n.frameworks.includes(t))&&n.match.test(e))return{bridgeCode:n.bridgeCode,reason:n.reason,message:n.message};return null}function q0(t,e){return H0(t,e)}function j0(t,e){return H0(t,e)}function Fr(t,e,n){return!e&&n.firstUpdateMs>0&&t<n.firstUpdateMs?Math.max(1,n.firstUpdateMs-t):t<n.phase2GateMs?Math.max(1,n.phase2GateMs-t):Math.max(1,n.livenessWindowMs)}function W0(t,e,n){let o=n-t.armedAt-t.expectedIntervalMs;if(o>e.suspendThresholdMs){let x=t.suspendedMs+o,m=n-t.startedAt-x;return{action:"suspend",suspendedDeltaMs:o,rearmMs:Fr(m,t.firstFrameSeen,e)}}let c=n-t.startedAt-t.suspendedMs,d=t.awaitingApproval?e.approvalMaxMs:e.absoluteMaxMs;return c>=d?{action:"reject-backstop",awaitingApproval:t.awaitingApproval}:t.firstFrameSeen?c<e.phase2GateMs?{action:"continue",rearmMs:Fr(c,!0,e)}:n-t.lastActivityAt<e.livenessWindowMs||t.hasActiveTool||t.awaitingApproval?{action:"continue",rearmMs:Fr(c,!0,e)}:{action:"reject-idle"}:e.firstUpdateMs>0&&c>=e.firstUpdateMs&&!t.awaitingApproval?{action:"reject-idle"}:{action:"continue",rearmMs:Fr(c,!1,e)}}var K0=Ze("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),xE=200,pE=40,gE=Ze("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),mE=Ze("COZE_BRIDGE_SESSION_PROMPT_IDLE_MS",600*1e3),wE=Ze("COZE_BRIDGE_SESSION_PROMPT_ABSOLUTE_MAX_MS",7200*1e3),_E=Ze("COZE_BRIDGE_SUSPEND_THRESHOLD_MS",60*1e3),yE=Ze("COZE_BRIDGE_SESSION_PROMPT_FIRST_UPDATE_MS",600*1e3),EE=Ze("COZE_BRIDGE_SESSION_PROMPT_APPROVAL_MAX_MS",1440*60*1e3),$0=500;function bE(t){try{let e=JSON.stringify(t);return e===void 0||e.length<=$0?t:`${e.slice(0,$0)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function vE(t){let e=[];typeof t.message=="string"&&e.push(t.message);let{data:n}=t;if(typeof n=="string")e.push(n);else if(n&&typeof n=="object")try{e.push(JSON.stringify(n))}catch{}return e.join(" ")}function V0(t){try{return lE(t)}catch{return}}function SE(t,e){return{platform:process.platform,osRelease:uE(),code:t.code,errno:t.errno,syscall:t.syscall,errPath:t.path,command:e.command,commandExists:hE(e.command)?V0(e.command):void 0,cwd:e.cwd,cwdExists:V0(e.cwd),envKeys:e.envKeys}}function IE(t,e){return`${t.message} [diag: platform=${e.platform} os=${e.osRelease} code=${e.code} errno=${e.errno} syscall=${e.syscall} cmd=${fE(e.command)} cmdExists=${e.commandExists} cwdExists=${e.cwdExists} envKeys=${e.envKeys}]`}var pt=class{constructor(e){this.opts=e;this.log=q(`downstream.${this.constructor.name}`,this.opts.agentId),this.decoder=new Io({onError:n=>this.log.warn("decode line failed",{line:n.line})})}opts;child;decoder;pending=new Map;inflightAgentRequests=new Map;idAllocator=new Mr;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stopReason;stderrRing=[];now=Date.now;sanitizeEnv(e){return e}async start(){if(this.child)throw new k("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",n=$f(process.env,this.opts.agentEnvFile??Y().agentEnvFile,this.opts.env,o=>this.sanitizeEnv(o)),i=st(this.opts.command,this.opts.args,{cwd:this.opts.cwd,env:n,stdio:["pipe","pipe","pipe"],detached:e});this.child=i,B0(i.pid),i.stdout?.setEncoding("utf8"),i.stdout?.on("data",o=>{try{for(let c of this.decoder.push(o))this.dispatch(c)}catch(c){this.log.warn("stdout dispatch threw, swallowed to keep daemon alive",{err:String(c)})}}),i.stderr?.setEncoding("utf8"),i.stderr?.on("data",o=>{let c=o.trimEnd();this.stderrRing.push(c),this.stderrRing.length>xE&&this.stderrRing.shift(),this.log.debug("stderr",{text:c})}),i.stdin?.on("error",o=>{this.log.warn("child stdin error",{err:String(o)})}),i.stdout?.on("error",o=>{this.log.warn("child stdout error",{err:String(o)})}),i.stderr?.on("error",o=>{this.log.warn("child stderr error",{err:String(o)})}),i.on("exit",(o,c)=>{this.stopped=!0,F0(i.pid),(o!==0||c!==null)&&this.stderrRing.length>0&&this.log.warn("downstream exited abnormally, recent stderr",{code:o,signal:c,recentStderr:[...this.stderrRing]});try{for(let u of this.decoder.flush())this.dispatch(u)}catch(u){this.log.debug("decoder.flush on exit threw (ignored)",{err:String(u)})}this.failAllPending(this.buildExitError(o,c));for(let u of this.exitHandlers)u(o,c)}),i.on("error",o=>{let c=o,d=SE(c,{command:this.opts.command,cwd:this.opts.cwd,envKeys:Object.keys(n).length});this.log.error("child error",{err:String(o),diag:d}),this.failAllPending(new k("AGENT_SPAWN_FAILED",IE(c,d),{cause:d}))}),this.log.info("downstream started",{command:this.opts.command,pid:i.pid,cwd:this.opts.cwd})}async stop(e){if(!this.child||this.stopped)return;this.stopped=!0,this.stopReason=e??"stopped",this.log.info("downstream stopping",{reason:e});let n=this.child,i=new Promise(c=>n.once("exit",()=>c()));$i(n.pid,"SIGTERM");let o=setTimeout(()=>{n.killed||$i(n.pid,"SIGKILL")},5e3);try{await i}finally{clearTimeout(o)}}pid(){return this.child?.pid}isAlive(){return!!this.child&&!this.stopped}getStderrTail(e){return e===void 0?[...this.stderrRing]:this.stderrRing.slice(-e)}initialize(e){return this.call("initialize",e)}sessionNew(e){return this.call("session/new",{mcpServers:[],...e})}sessionLoad(e){return this.call("session/load",{mcpServers:[],...e})}sessionPrompt(e,n){let i={firstUpdateMs:yE,phase2GateMs:gE,livenessWindowMs:mE,absoluteMaxMs:wE,approvalMaxMs:EE,suspendThresholdMs:_E,...n};return this.call("session/prompt",e,K0,i)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(Lr("session/cancel",e))}setSessionMode(e){return this.call("session/set_mode",e)}setSessionModel(e){return this.call("session/set_model",e)}onUpdate(e){this.updateHandlers.push(e)}onAgentRequest(e){this.agentRequestHandlers.push(e)}respondAgentRequest(e,n){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(Nr(e,n))}catch(i){this.log.warn("respondAgentRequest write failed",{id:e,err:String(i)})}}respondAgentRequestError(e,n){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(In(e,n))}catch(i){this.log.warn("respondAgentRequestError write failed",{id:e,err:String(i)})}}onExit(e){this.exitHandlers.push(e)}call(e,n,i=K0,o){if(!this.child||this.stopped)return Promise.reject(new k("AGENT_PROTOCOL_ERROR","downstream not started"));let c=this.idAllocator.next(e),d=qi(c,e,n),u=(()=>{if(typeof n!="object"||n===null)return;let f=n.sessionId;return typeof f=="string"?f:void 0})();return new Promise((f,x)=>{let m={resolve:f,reject:x,timer:null,method:e,promptTimeout:null};if(o){let _=this.now(),v={cfg:o,startedAt:_,lastActivityAt:_,firstFrameSeen:!1,activeToolCalls:new Set,suspendedMs:0,armedAt:_,expectedIntervalMs:Fr(0,!1,o),sessionId:u};m.promptTimeout=v;let y=()=>{let b={startedAt:v.startedAt,lastActivityAt:v.lastActivityAt,firstFrameSeen:v.firstFrameSeen,hasActiveTool:v.activeToolCalls.size>0,awaitingApproval:this.inflightAgentRequests.size>0,suspendedMs:v.suspendedMs,armedAt:v.armedAt,expectedIntervalMs:v.expectedIntervalMs},I=this.now(),A=W0(b,v.cfg,I),P=D=>{v.armedAt=I,v.expectedIntervalMs=D,m.timer=setTimeout(y,D)};if(A.action==="suspend"){v.suspendedMs+=A.suspendedDeltaMs,v.lastActivityAt=I,this.log.warn("downstream prompt timer: suspend detected",{id:c,method:e,gapMs:A.suspendedDeltaMs,suspendedMs:v.suspendedMs,...v.sessionId?{sessionId:v.sessionId}:{}}),P(A.rearmMs);return}if(A.action==="continue"){P(A.rearmMs);return}this.pending.delete(c),A.action==="reject-backstop"?(this.log.warn("downstream prompt absolute timeout",{id:c,method:e,awaitingApproval:A.awaitingApproval,...v.sessionId?{sessionId:v.sessionId}:{}}),x(A.awaitingApproval?new k("AGENT_APPROVAL_TIMEOUT",`${e} awaiting permission timed out after ${v.cfg.approvalMaxMs}ms`):new k("AGENT_TIMEOUT",`${e} timed out after ${v.cfg.absoluteMaxMs}ms`))):(this.log.warn("downstream prompt idle timeout",{id:c,method:e,...v.sessionId?{sessionId:v.sessionId}:{}}),x(new k("AGENT_FRAME_IDLE_TIMEOUT",`${e} no progress within ${v.cfg.livenessWindowMs}ms`)))};m.timer=setTimeout(y,v.expectedIntervalMs)}else i>0&&Number.isFinite(i)&&(m.timer=setTimeout(()=>{this.pending.delete(c),this.log.warn("downstream call timeout",{id:c,method:e,timeoutMs:i}),x(new k("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i));this.pending.set(c,m);try{this.writeFrame(d)}catch(_){m.timer&&clearTimeout(m.timer),this.pending.delete(c),x(_)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new k("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(L0(e),n=>{n&&this.log.warn("stdin write callback err",{err:String(n)})})}dispatch(e){if(So(e)){let n=e.id!==null?this.pending.get(e.id):void 0;if(!n){this.log.warn("orphan response",{id:e.id});return}this.pending.delete(e.id),n.timer&&clearTimeout(n.timer),e.error?(this.log.warn("downstream returned error frame",{id:e.id,method:n.method,code:e.error.code,message:e.error.message,data:e.error.data}),n.reject(this.wireErrorToBridge(e.error))):e.result===void 0?(this.log.warn("downstream response missing both result and error",{id:e.id,method:n.method}),n.reject(new k("AGENT_PROTOCOL_ERROR",`${n.method} response missing both result and error`))):(this.log.info("downstream returned result",{id:e.id,method:n.method,result:bE(e.result)}),n.resolve(e.result));return}if(C0(e)){if(e.method==="session/update"){let n=e.params;for(let i of this.pending.values()){let o=i.promptTimeout;o&&(o.firstFrameSeen=!0,o.lastActivityAt=this.now(),this.trackToolCall(o,n))}for(let i of this.updateHandlers)try{Promise.resolve(i(n)).catch(o=>this.log.warn("update handler failed (async)",{err:String(o)}))}catch(o){this.log.warn("update handler threw sync, swallowed",{err:String(o)})}}else this.log.info("unknown notification (drop, not forwarded)",{method:e.method});return}if(R0(e)){let n=e;try{this.handleAgentRequest(n).catch(i=>this.log.error("agent request handler failed (async)",{method:n.method,err:String(i)}))}catch(i){this.log.warn("handleAgentRequest threw sync, swallowed",{method:n.method,err:String(i)})}}}trackToolCall(e,n){let i=n.update,o=i?.sessionUpdate;if(o!=="tool_call"&&o!=="tool_call_update")return;let c=typeof i.toolCallId=="string"?i.toolCallId:void 0;if(!c)return;let d=typeof i.status=="string"?i.status:void 0,u=d==="completed"||d==="failed"||d==="cancelled";o==="tool_call"&&!u?e.activeToolCalls.add(c):u&&e.activeToolCalls.delete(c)}async handleAgentRequest(e){if(this.agentRequestHandlers.length===0){this.writeFrame(In(e.id,{code:-32601,message:`method not handled by Bridge: ${e.method}`}));return}this.inflightAgentRequests.set(e.id,e.method);for(let n of this.agentRequestHandlers)try{await n(e)}catch(i){this.log.error("agentRequestHandler threw",{method:e.method,err:String(i)});try{this.writeFrame(In(e.id,Wi(i)))}catch{}this.inflightAgentRequests.delete(e.id)}}wireErrorToBridge(e){let n=D0(e);if(n.code!=="AGENT_PROTOCOL_ERROR")return n;let i=j0(this.framework,vE(e));return i?new k(i.bridgeCode,i.message,{cause:{reason:i.reason,wireCode:e.code,wireMessage:e.message,wireData:e.data}}):n}buildExitError(e,n){if(this.stopReason!==void 0)return new k("AGENT_TURN_ABORTED",`turn aborted: ${this.stopReason}`,{cause:{reason:this.stopReason}});let i=this.getStderrTail(pE).join(`
|
|
106
|
+
`),o=q0(this.framework,i);return o?new k(o.bridgeCode,o.message,{cause:{reason:o.reason,code:e,signal:n,stderrTail:i}}):new k("AGENT_PROTOCOL_ERROR",`agent exited (${e}/${n})`,{cause:{code:e,signal:n,stderrTail:i}})}failAllPending(e){for(let n of this.pending.values())n.timer&&clearTimeout(n.timer),n.reject(e);this.pending.clear(),this.inflightAgentRequests.clear()}};function AE(t){let e={};for(let[n,i]of Object.entries(t))i!==void 0&&(n.startsWith("CLAUDE")||n==="AI_AGENT"||n==="BAGGAGE"||(e[n]=i));return e}var Ao=class extends pt{framework="claude-code";constructor(e){let{command:n,args:i}=si("claude-code",e.command,e.args??[]),o={command:n,args:i,cwd:e.cwd,agentId:e.agentId,...e.env?{env:e.env}:{}};super(o)}sanitizeEnv(e){return AE(e)}};dn();import{mkdtempSync as kE,rmSync as TE}from"node:fs";import{tmpdir as PE}from"node:os";import{join as RE}from"node:path";var J0=["default","acceptEdits","plan","auto","bypassPermissions"],Z0=["read-only","auto","full-access"];var Y0=["default","accept_edits","dont_ask"];function Nt(t,e){if(typeof e!="string")return!1;switch(t){case"claude-code":return J0.includes(e);case"codex":return Z0.includes(e);case"hermes":return Y0.includes(e);case"openclaw":return!1}}function ko(t){switch(t){case"read-only":return"read-only";case"auto":return"agent";case"full-access":return"agent-full-access"}}function X0(t){switch(t){case"read-only":return"read-only";case"agent":return"auto";case"agent-full-access":return"full-access";default:return}}function xd(t){switch(t){case"claude-code":return J0.join("/");case"codex":return Z0.join("/");case"hermes":return Y0.join("/");case"openclaw":return""}}var To=class extends pt{framework="codex";authMethodId;codexHomeDir;constructor(e){let n=e.args??[],i=e.extraArgs?[...n,...e.extraArgs]:n,{command:o,args:c}=si("codex",e.command,i),d=e.isolateCodexHome?kE(RE(PE(),"coze-bridge-codex-home-")):void 0,u=d?{...e.env??{},CODEX_HOME:d}:e.env,f={command:o,args:c,cwd:e.cwd,agentId:e.agentId,...u?{env:u}:{}};super(f),this.authMethodId=e.authMethodId,this.codexHomeDir=d}async initialize(e){let n=await super.initialize(e);return this.authMethodId&&await this.call("authenticate",{methodId:this.authMethodId}),n}setSessionMode(e){let n=Nt("codex",e.modeId)?ko(e.modeId):e.modeId;return super.setSessionMode({...e,modeId:n})}onUpdate(e){super.onUpdate(n=>e(CE(n)))}async stop(e){if(await super.stop(e),this.codexHomeDir)try{TE(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};function CE(t){let e=t.update;if(e.sessionUpdate!=="current_mode_update"||typeof e.currentModeId!="string")return t;let n=X0(e.currentModeId);return!n||n===e.currentModeId?t:{...t,update:{...t.update,currentModeId:n}}}ne();var DE=q("hermes-downstream"),Po=class extends pt{framework="hermes";modelId;constructor(e){let n={command:e.command,args:[],cwd:e.cwd,agentId:e.agentId,...e.env?{env:e.env}:{}};super(n),e.modelId&&(this.modelId=e.modelId)}async afterSessionEstablished(e){if(this.modelId)try{await this.setSessionModel({sessionId:e,modelId:this.modelId})}catch(n){DE.warn("hermes session/set_model post-establish failed (ignored)",{sessionId:e,modelId:this.modelId,err:String(n)})}}};$e();var OE=3e4,zr=class extends pt{framework="openclaw";agentId;sessionName;slashModelOnStart;constructor(e){let n=e.sessionName??"default",i=["acp","--session",`agent:${e.agentId}:${n}`];e.gatewayToken&&i.push("--token",e.gatewayToken);let o={command:e.command,args:i,cwd:e.cwd,agentId:e.agentId,...e.env?{env:e.env}:{}};super(o),this.agentId=e.agentId,this.sessionName=n,this.slashModelOnStart=e.slashModelOnStart}async afterSessionEstablished(e){this.slashModelOnStart&&(this.log.info("switching session to per-session provider via /model",{agentId:this.agentId,sessionName:this.sessionName,slash:this.slashModelOnStart}),await this.call("session/prompt",{sessionId:e,prompt:[{type:"text",text:`/model ${this.slashModelOnStart}`}]},OE))}get acpSessionName(){return this.sessionName}setSessionMode(e){return Promise.reject(new k("METHOD_NOT_FOUND","session/set_mode not supported on openclaw"))}};Ht();$e();ne();Re();function pd(t){return t.replace(/[^A-Za-z0-9._-]+/g,"-")}dn();var An=class{slots=[];running=!1;closed=!1;disposed=!1;enqueue(e){return this.disposed?Promise.reject(new Error("AsyncQueue disposed")):this.closed?Promise.reject(new Error("AsyncQueue closed")):new Promise((n,i)=>{this.slots.push({task:e,resolve:n,reject:i}),this.drain()})}close(){this.closed=!0}dispose(e=new Error("AsyncQueue disposed")){for(this.disposed=!0,this.closed=!0;this.slots.length>0;)this.slots.shift()?.reject(e)}get size(){return this.slots.length}get isRunning(){return this.running}get isDisposed(){return this.disposed}async drain(){if(!this.running){this.running=!0;try{for(;this.slots.length>0&&!this.disposed;){let e=this.slots.shift();if(!e)break;try{let n=await e.task();e.resolve(n)}catch(n){e.reject(n)}}}finally{this.running=!1}}}};var Ro=class{agentId;framework;workspace;deployType;accountId;patToken;modelInfo;sessions=new Map;sessionQueues=new Map;activeTriggers=new Map;activeGroupIds=new Map;status="ok";model;lastActiveAt=Date.now();constructor(e){this.agentId=e.agentId,this.framework=e.framework,this.workspace=e.workspace,this.model=e.model,this.deployType=e.deployType??"local",e.accountId&&(this.accountId=e.accountId),e.patToken&&(this.patToken=e.patToken),e.modelInfo&&(this.modelInfo=e.modelInfo)}setPatToken(e){this.patToken=e}setModelInfo(e){this.modelInfo=e}getSessionQueue(e){let n=this.sessionQueues.get(e);return(!n||n.isDisposed)&&(n=new An,this.sessionQueues.set(e,n)),n}allSessionQueues(){return this.sessionQueues.entries()}hasSessionQueue(e){let n=this.sessionQueues.get(e);return!!n&&!n.isDisposed}async dispose(e){this.status="stopped";let n=new Error(`AgentSession disposed${e?`: ${e}`:""}`);for(let i of this.sessionQueues.values())i.dispose(n);this.sessionQueues.clear(),await this.killAllRuntimes(e??"dispose")}async killAllRuntimes(e){let n=[];for(let[,i]of this.sessions)Vi(i),i.downstream&&(n.push(i.downstream.stop(e).catch(()=>{})),i.downstream=void 0);await Promise.all(n),this.activeTriggers.clear(),this.activeGroupIds.clear()}};function Vi(t){t.idleTimer&&(clearTimeout(t.idleTimer),t.idleTimer=void 0)}function Yt(t){return t.framework==="hermes"?!0:t.deployType!=="local"?!1:t.framework==="claude-code"||t.framework==="codex"}Zt();ne();import{constants as Q0}from"node:fs";import{access as LE,readFile as NE}from"node:fs/promises";import{delimiter as ME,dirname as BE,join as eh}from"node:path";var et=q("framework-detector"),th={"claude-code":"claude",codex:"codex",openclaw:"openclaw",hermes:"hermes-acp"},FE=[".exe",".cmd",".bat",".ps1"],Jn=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??st,access:e.access??LE,readFile:e.readFile??NE}}async detect(e){let n=th[e],i=await this.which(n);if(!i&&e==="hermes"&&(i=await this.resolveHermesAcpViaHermesShim()),!i)return et.debug("framework binary not found",{framework:e,bin:n}),null;let o=e==="openclaw"?["--log-level","silent"]:[],[c,d]=await Promise.all([this.probeVersion(i,o),e==="openclaw"?this.probeOpenclawDefaultAgent(i):Promise.resolve(null)]),u={path:i,version:c};return d&&(u.defaultAgent=d),u}async detectAll(){let e=await Promise.all(Object.keys(th).map(async i=>[i,await this.detect(i)])),n={};for(let[i,o]of e)o&&(n[i]=o);return n}async which(e){let n=this.env.pathEnv.split(ME).filter(Boolean),i=this.env.platform==="win32"?["",...FE]:[""];for(let o of n)for(let c of i){let d=eh(o,e+c);if(await this.isExecutable(d))return d}return null}async isExecutable(e){try{let n=this.env.platform==="win32"?Q0.F_OK:Q0.X_OK;return await this.env.access(e,n),!0}catch{return!1}}async resolveHermesAcpViaHermesShim(){if(this.env.platform==="win32")return null;let e=await this.which("hermes");if(!e)return null;let n;try{n=await this.env.readFile(e,"utf8")}catch(d){return et.debug("hermes shim fallback: readFile failed",{hermesPath:e,err:String(d)}),null}let o=n.match(/exec\s+["']?(\/[^\s"']+\/bin\/hermes)["']?/)?.[1];if(!o)return et.debug("hermes shim fallback: no exec line matched",{hermesPath:e}),null;let c=eh(BE(o),"hermes-acp");return await this.isExecutable(c)?(et.info("hermes-acp resolved via hermes shim fallback",{hermesPath:e,candidate:c}),c):(et.debug("hermes shim fallback: hermes-acp not executable at inferred path",{hermesPath:e,candidate:c}),null)}async probeOpenclawDefaultAgent(e){let n=await this.runProbe(e,["--log-level","silent","agents","list","--json"]);if(!n)return et.warn("openclaw default agent probe: runProbe returned null (spawn err / timeout)",{path:e}),null;if(n.code!==0)return et.warn("openclaw default agent probe: non-zero exit",{path:e,code:n.code,stdoutHead:n.stdout.slice(0,200)}),null;let i=n.stdout.match(/\[\s*\{[\s\S]*\}\s*\]/);if(!i)return et.warn("openclaw default agent probe: regex no match (no JSON array in stdout)",{path:e,stdoutHead:n.stdout.slice(0,200)}),null;try{let o=JSON.parse(i[0]);if(!Array.isArray(o))return et.warn("openclaw default agent probe: JSON parsed but not an array",{path:e}),null;let c=o.find(d=>d?.isDefault===!0);return c?!c.id||!c.workspace?(et.warn("openclaw default agent probe: default agent missing id or workspace",{path:e,hasId:!!c.id,hasWorkspace:!!c.workspace}),null):{id:c.id,workspace:c.workspace}:(et.info("openclaw default agent probe: no agent has isDefault=true",{path:e,agentCount:o.length}),null)}catch(o){return et.warn("openclaw default agent probe: JSON.parse failed",{path:e,err:String(o),matchHead:i[0].slice(0,200)}),null}}async probeOpenclawGateway(e){let n=await this.runProbe(e,["--log-level","silent","gateway","status","--json","--require-rpc","--timeout","5000"]);if(!n)return et.warn("openclaw gateway probe: runProbe returned null (spawn err / timeout)",{path:e}),{reachable:!1};let i=n.code===0;i||et.warn("openclaw gateway probe: non-zero exit (gateway unreachable)",{path:e,code:n.code,stdoutHead:n.stdout.slice(0,200)});let o={reachable:i},c=n.stdout.match(/\{[\s\S]*\}/);if(c)try{let d=JSON.parse(c[0]);typeof d.gateway?.port=="number"&&(o.port=d.gateway.port),typeof d.service?.runtime?.status=="string"&&(o.runtime=d.service.runtime.status),!i&&typeof d.rpc?.error=="string"&&(o.detail=d.rpc.error)}catch(d){et.warn("openclaw gateway probe: JSON.parse failed (detail omitted, gate by exit code)",{path:e,err:String(d)})}return o}async probeVersion(e,n=[]){let i=await this.runProbe(e,[...n,"--version"]);return i&&(UE(i.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,n){return new Promise(i=>{let o="",c=!1,d,u=f=>{c||(c=!0,d&&clearTimeout(d),i(f))};try{let f=this.env.spawn(e,n,{stdio:["ignore","pipe","pipe"]});d=setTimeout(()=>{f.kill("SIGKILL"),u(null)},15e3),f.stdout?.on("data",x=>{o+=x.toString("utf8")}),f.on("error",()=>u(null)),f.on("close",x=>u({code:x,stdout:o}))}catch{u(null)}})}},zE=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function UE(t){return t.replace(zE,"")}import{homedir as GE}from"node:os";import{join as HE}from"node:path";Ht();Zt();or();$e();ne();async function ih(){let t=HE(GE(),".openclaw/openclaw.json");return lr(t)}async function sh(){return(await ih())?.gateway?.auth?.token??""}var nh=q("openclaw.config"),qE=[0,5e3,5e3],jE=Ze("COZE_BRIDGE_OPENCLAW_CLI_TIMEOUT_MS",15e3),rh="models.providers.",Co="agents.defaults.models",Do=class{command;env;retryDelaysMs;cliTimeoutMs;queue=new An;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??qE,this.cliTimeoutMs=e.cliTimeoutMs??jE}async withRetry(e,n){let i;for(let o=0;o<this.retryDelaysMs.length;o++){let c=this.retryDelaysMs[o]??0;c>0&&await new Promise(d=>setTimeout(d,c));try{return await n()}catch(d){i=d,nh.warn("openclaw cli failed, will retry",{label:e,attempt:o+1,err:String(d)})}}throw new k("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${i?.message??"unknown"}`)}runCli(e){return new Promise((n,i)=>{let o=st(this.command,e,{stdio:["ignore","ignore","pipe"],env:this.env}),c="",d=!1,u=x=>{d||(d=!0,clearTimeout(f),x())};o.stderr?.on("data",x=>{c+=x.toString("utf8")});let f=setTimeout(()=>{u(()=>{o.kill("SIGTERM"),setTimeout(()=>o.kill("SIGKILL"),250).unref(),i(new Error(`timeout after ${this.cliTimeoutMs}ms: ${e.join(" ")}`))})},this.cliTimeoutMs);f.unref(),o.on("error",x=>u(()=>i(x))),o.on("close",x=>u(()=>{x===0?n():i(new Error(`exit ${x}: ${c.trim().slice(0,500)}`))}))})}async runCliTolerant(e,n){try{await this.runCli(e)}catch(i){let o=String(i);if(n.some(c=>o.includes(c)))return;throw i}}async bestEffortUnset(e,n){try{await this.queue.enqueue(()=>this.withRetry(e,()=>this.runCliTolerant(["config","unset",n],["Config path not found","Nothing was changed"])))}catch(i){nh.warn(`${e} failed (best-effort)`,{configPath:n,err:String(i)})}}ensureProvider(e,n){return this.queue.enqueue(()=>this.withRetry(`config set models.providers.${e}`,()=>this.runCli(["config","set",`${rh}${e}`,JSON.stringify(n),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${rh}${e}`)}addModelToAllowlist(e,n){let i={[e]:n?{alias:n}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${Co}[${e}]`,()=>this.runCli(["config","set",Co,JSON.stringify(i),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${Co}[${e}]`,`${Co}.${e}`)}async getAllowlistModelsForProvider(e){let i=(await ih())?.agents?.defaults?.models;if(!i||typeof i!="object")return[];let o=`${e}/`,c=[];for(let d of Object.keys(i))d.startsWith(o)&&c.push(d.slice(o.length));return c}ensureAgent(e,n,i){let o=["agents","add",e,"--workspace",n,"--non-interactive"];return i&&o.push("--model",i),this.queue.enqueue(()=>this.withRetry(`agents add ${e}`,()=>this.runCliTolerant(o,["already exists","already registered"])))}restartGateway(){return this.queue.enqueue(()=>this.withRetry("gateway restart",()=>this.runCli(["gateway","restart"])))}deleteAgent(e){return this.queue.enqueue(()=>this.withRetry(`agents delete ${e}`,()=>this.runCliTolerant(["agents","delete",e,"--force"],["not found","does not exist"])))}};var fe=q("agent-manager"),wd="acceptEdits",dh="full-access",lh="read-only";function VE(t){return{INITIAL_AGENT_MODE:ko(t)}}var JE=(t,e,n,i,o,c,d,u,f,x)=>{switch(t){case"claude-code":{let m={...o?{...r0(o),...o0(o,d,u)}:{},...f??{},IS_SANDBOX:"1"};return new Ao({cwd:n,env:m,agentId:i})}case"codex":{let m=dh;x!==void 0&&(Nt("codex",x)?m=x:fe.warn("codex spawn: invalid codexPermissionMode, falling back to full-access",{agentId:i,received:x}));let _=!!o,v={...o?{...s0(o),...i0(o,d,u)}:{},...VE(m),..._?{NO_BROWSER:"1"}:{},...f??{}};return new To({cwd:n,agentId:i,...Object.keys(v).length>0?{env:v}:{},..._?{authMethodId:"api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new zr({command:e,cwd:n,agentId:i,...c?{sessionName:pd(c)}:{}});case"hermes":return new Po({command:e,cwd:n,agentId:i,...f&&Object.keys(f).length>0?{env:{...f}}:{},...o?.model?{modelId:o.model}:{}})}};function md(t){return t==="claude-code"||t==="codex"}var ZE={path:"",version:"cloud-deployed"},ah="openclaw_gateway_unavailable",YE="openclaw_default_agent_missing";function ch(t){let e=[t.port!==void 0?`port=${t.port}`:"",t.runtime?`runtime=${t.runtime}`:"",t.detail??""].filter(Boolean).join(", ");return`openclaw gateway \u672A\u8FD0\u884C/\u4E0D\u53EF\u8FBE${e?` (${e})`:""}; \u8BF7\u542F\u52A8 openclaw gateway`}var XE={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},QE=6e4,Oo=class{paths;config;registry;factory;createTimeoutMs;openclawConfigCache;ensuredProviders=new Set;detectorFactory;openclawEnvBootstrapPromise;openclawConfigFactory;openclawConfigDir;constructor(e){this.paths=e.paths,this.config=e.config,this.registry=e.registry,this.factory=e.downstreamFactory??JE,this.createTimeoutMs=e.createTimeoutMs??QE,this.detectorFactory=e.detectorFactory??(()=>new Jn),this.openclawConfigFactory=e.openclawConfigFactory??(n=>new Do({command:n})),this.openclawConfigDir=e.openclawConfigDir??oh($E(),".openclaw")}buildBinShimPathEnv(){let e=process.platform==="win32"?";":":";return{PATH:`${this.paths.binDir}${e}${process.env.PATH??""}`}}getOpenclawConfig(){if(!this.openclawConfigCache){let e=this.config.frameworksCache?.openclaw;if(!e?.path)throw new k("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");this.openclawConfigCache=this.openclawConfigFactory(e.path)}return this.openclawConfigCache}bootstrapOpenclawEnvIfNeeded(){return this.openclawEnvBootstrapPromise?this.openclawEnvBootstrapPromise:(this.openclawEnvBootstrapPromise=this.doBootstrapOpenclawEnv().catch(e=>{fe.warn("openclaw env bootstrap failed (ignored)",{err:String(e)}),this.openclawEnvBootstrapPromise=void 0}),this.openclawEnvBootstrapPromise)}async doBootstrapOpenclawEnv(){let e=this.openclawConfigDir,n=oh(e,".env");if(await KE(n).then(c=>c.isFile()).catch(()=>!1)){fe.debug("openclaw .env exists, skip bootstrap",{envFile:n});return}let o=Bi({...process.env,...Mi(this.paths.agentEnvFile)});await ut(n,o,{mode:384}),fe.info("openclaw .env bootstrapped",{envFile:n,bytes:o.length}),await this.getOpenclawConfig().restartGateway(),fe.info("openclaw gateway restarted after env bootstrap")}async createAgent(e,n){if(!e.agentId)throw new k("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new k("IPC_BAD_REQUEST","framework required");let i=await Se(e.agentId,this.paths).catch(()=>null),o=ho(e._meta)==="cloud"||i?.deployType==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let c=this.registry.get(e.agentId);if(c){if(c.framework!==e.framework)throw new k("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${c.framework})`);if(c.status==="error")fe.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await c.dispose("rebuild after error").catch(P=>fe.warn("dispose stale agent failed (ignored)",{err:String(P)})),this.registry.unregister(e.agentId);else if(o&&c.deployType!=="cloud")fe.warn("existing agent deployType drifted to local, rebuilding as cloud",{agentId:e.agentId}),await c.dispose("rebuild after deployType drift").catch(P=>fe.warn("dispose drifted agent failed (ignored)",{err:String(P)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==c.patToken){fe.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),c.setPatToken(e.patToken);let P=await Se(e.agentId,this.paths).catch(()=>null);P&&(P.patToken=e.patToken,await Ue(P,this.paths))}if(c.deployType==="cloud"&&e.modelInfo){fe.info("updating agent modelInfo on re-create",{agentId:e.agentId}),c.setModelInfo(e.modelInfo);let P=await Se(e.agentId,this.paths).catch(()=>null);P&&(P.modelInfo=e.modelInfo,await Ue(P,this.paths))}return fe.info("agent already exists, return current",{agentId:e.agentId}),{ok:!0,agentId:c.agentId,workspace:c.workspace,framework:c.framework}}}if(!o&&!this.config.frameworksCache?.[e.framework]){let D=e.framework==="hermes"?"; install with `pipx install hermes-agent` and rerun daemon to refresh frameworks_cache":"; rerun daemon to refresh frameworks_cache";throw new k("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine${D}`)}let u=ze(e.agentId,this.paths),f=o?"cloud":"local",x=e.framework==="openclaw"&&f==="local",m;x&&!n?.revive&&(m=(await this.ensureOpenclawDefaultAgent()).workspace,await this.ensureOpenclawGatewayReachable());let _=m??(x?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0),v=e.workspace??_??u.workspace,y=new AbortController,b=setTimeout(()=>y.abort(new k("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),I,A=!1;try{o&&md(e.framework)&&await dr(e.framework,y.signal);let P=()=>{if(y.signal.aborted)throw y.signal.reason instanceof Error?y.signal.reason:new k("AGENT_TIMEOUT","_agent/create aborted")};await gd(u.root,{recursive:!0}),await gd(v,{recursive:!0}),await gd(u.logs,{recursive:!0}),P(),x||await fr(v,e.framework,e.cozeIdentity),e.framework==="claude-code"&&(f==="cloud"?await Ga(v,"cloud"):await Ga(v,"local",wd)),P();let D=i,E=t0({model:e.model??D?.model}),C=Gf(e._meta)??D?.accountId,L=e.patToken??D?.patToken,F=f==="cloud"?e.modelInfo??D?.modelInfo:void 0;if(I=new Ro({agentId:e.agentId,framework:e.framework,workspace:v,model:E.model??It,deployType:f,...C?{accountId:C}:{},...L?{patToken:L}:{},...F?{modelInfo:F}:{}}),I.status="ok",D?.sessions){let J=e.framework==="hermes"||f==="local"&&(e.framework==="claude-code"||e.framework==="codex");for(let[Q,oe]of Object.entries(D.sessions)){let ae={acpSessionId:oe.acpSessionId,modelToken:oe.modelToken,tokenGeneratedAt:oe.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};J?oe.permissionMode===void 0?(ae.permissionMode=e.framework==="claude-code"?"bypassPermissions":e.framework==="codex"?"full-access":"default",fe.info("autoRevive: legacy session (no permissionMode) \u2192 fallback to D80/D84 default",{agentId:e.agentId,cloudId:Q,framework:e.framework,fallback:ae.permissionMode})):Nt(e.framework,oe.permissionMode)?ae.permissionMode=oe.permissionMode:fe.warn("autoRevive: dropping invalid persisted permissionMode",{agentId:e.agentId,cloudId:Q,framework:e.framework,value:oe.permissionMode}):oe.permissionMode!==void 0&&fe.info("autoRevive: dropping persisted permissionMode (gate disabled)",{agentId:e.agentId,cloudId:Q,framework:e.framework,deployType:f}),oe.cozeGroupId&&(ae.cozeGroupId=oe.cozeGroupId),I.sessions.set(Q,ae)}let ie=Object.keys(D.sessions).length;ie>0&&fe.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:ie})}this.registry.register(I),A=!0;let B={agentId:e.agentId,framework:e.framework,workspace:v,cozeIdentity:e.cozeIdentity,createdAt:D?.createdAt??Date.now(),sessions:D?.sessions??{},model:E.model};f==="cloud"&&(B.deployType="cloud"),C&&(B.accountId=C),L&&(B.patToken=L),F&&(B.modelInfo=F),D?.skills&&(B.skills=D.skills),D?.agentName&&(B.agentName=D.agentName),D?.description&&(B.description=D.description),B.skillsRefreshedForVersion=D?.skillsRefreshedForVersion??Lt,e.framework==="openclaw"&&f==="cloud"&&(this.config.frameworksCache?.openclaw?.path?(await this.bootstrapOpenclawEnvIfNeeded(),await this.getOpenclawConfig().ensureAgent(e.agentId,v)):fe.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let Z=e.initialSkills??[];if(Z.length>0){let J=[...B.skills??[]],ie=new Map(J.map((ae,R)=>[ae.skillId,R])),Q=await Promise.allSettled(Z.map(ae=>Eo({agentId:e.agentId,workspace:v,framework:e.framework,skill:ae,paths:this.paths}))),oe=0;for(let[ae,R]of Q.entries()){let z=Z[ae];z&&(R.status==="fulfilled"?(bo(J,ie,R.value),oe++):fe.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:z.skillId,skillName:z.skillName,err:String(R.reason)}))}oe>0&&(B.skills=J,fe.info("initialSkills installed",{agentId:e.agentId,installed:oe,requested:Z.length}))}return await Ue(B,this.paths),fe.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:f}),{ok:!0,agentId:e.agentId,workspace:v,framework:e.framework}}catch(P){throw fe.error("agent create failed, rolling back",{agentId:e.agentId,err:String(P)}),A&&I&&(await I.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),fe.error("[AUDIT] ROLLBACK: about to rm dirs.root",{src:"agent-manager.createAgent.catch",agentId:e.agentId,path:u.root,revive:n?.revive===!0,framework:e.framework,errStack:P instanceof Error?P.stack:String(P)}),await WE(u.root,{recursive:!0,force:!0}).catch(D=>fe.warn("rm agent dir failed (ignored)",{err:String(D)})),P instanceof k?P:new k("AGENT_SPAWN_FAILED",String(P),{cause:P})}finally{clearTimeout(b)}}async spawnSessionDownstream(e,n,i,o,c){let u=this.config.frameworksCache?.[e.framework];if(!u)if(e.deployType==="cloud"&&md(e.framework))u=ZE;else throw e.framework==="hermes"?new k("AGENT_SPAWN_FAILED","hermes-acp not detected on this machine; install with `pipx install hermes-agent` and rerun daemon to refresh frameworks_cache"):new k("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);md(e.framework)&&!_s(e.framework)&&(fe.info("spawn: resolving acp wrapper",{agentId:e.agentId,framework:e.framework}),await dr(e.framework));let f=e.deployType==="cloud"?{model:e.model,modelToken:n,...e.modelInfo?{modelInfo:e.modelInfo}:{}}:void 0,x;if(e.framework==="openclaw")x=await this.buildOpenclawDownstream({session:e,modelConfig:f,cloudSessionId:i,cozeEnv:o,mockScenario:c,command:u.path});else if(e.framework==="hermes"){let m={...this.buildBinShimPathEnv()};f&&(await f0({paths:this.paths,agentId:e.agentId,modelConfig:f,cozeEnv:o,mockScenario:c}),m.HERMES_HOME=Vn(e.agentId,this.paths)),x=this.factory(e.framework,u.path,e.workspace,e.agentId,f,i,o,c,m)}else{let m=e.sessions.get(i),_=Yt(e)?m?.permissionMode??dh:"full-access";x=this.factory(e.framework,u.path,e.workspace,e.agentId,f,i,o,c,this.buildBinShimPathEnv(),_)}try{return await x.start(),await x.initialize(XE),x}catch(m){let _=x instanceof pt?x.getStderrTail():[];throw _.length>0&&fe.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:m instanceof k?m.code:"unknown",recentStderr:_}),await x.stop("spawnSessionDownstream failed").catch(()=>{}),await this.resolveSpawnFailure(e,u.path,m)}}async resolveSpawnFailure(e,n,i){if(e.framework==="openclaw"&&e.deployType==="local"&&n)try{let o=await this.detectorFactory().probeOpenclawGateway(n);if(!o.reachable)return new k("AGENT_ENV_NOT_READY",ch(o),{cause:{reason:ah}})}catch(o){fe.warn("openclaw gateway diagnose failed (ignored, fall through to original error)",{agentId:e.agentId,err:String(o)})}return i instanceof k?i:new k("AGENT_SPAWN_FAILED",i instanceof Error?i.message:String(i),{cause:i})}async ensureOpenclawDefaultAgent(){let e=this.config.frameworksCache?.openclaw?.defaultAgent;if(e?.id&&e.workspace)return{id:e.id,workspace:e.workspace};fe.warn("openclaw default agent stale or missing, attempting lazy re-detect");let n=await this.detectorFactory().detect("openclaw");if(n?.defaultAgent?.id&&n.defaultAgent.workspace)return fe.info("openclaw lazy re-detect success",{agentId:n.defaultAgent.id,workspace:n.defaultAgent.workspace}),this.config.frameworksCache||(this.config.frameworksCache={}),this.config.frameworksCache.openclaw=n,{id:n.defaultAgent.id,workspace:n.defaultAgent.workspace};throw new k("AGENT_ENV_NOT_READY","openclaw default agent \u672A\u63A2\u6D4B\u5230; \u8BF7\u5148\u8DD1 `openclaw setup` \u6216 `openclaw agents add` \u521B\u5EFA\u9ED8\u8BA4 agent",{cause:{reason:YE}})}async ensureOpenclawGatewayReachable(){let e=this.config.frameworksCache?.openclaw?.path;if(!e)throw new k("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");let n=await this.detectorFactory().probeOpenclawGateway(e);if(!n.reachable)throw new k("AGENT_ENV_NOT_READY",ch(n),{cause:{reason:ah}})}async buildOpenclawDownstream(e){let{session:n,modelConfig:i,cloudSessionId:o,cozeEnv:c,mockScenario:d,command:u}=e,f=pd(o);if(n.deployType==="local"){let _=await this.ensureOpenclawDefaultAgent();return new zr({command:u,cwd:_.workspace,agentId:_.id,sessionName:f})}let x=await sh(),m;if(i?.modelToken){let _=Qc(o),v=ed(i),y=`${_}/${v}`;if(!this.ensuredProviders.has(y)){let b=this.getOpenclawConfig(),I=await b.getAllowlistModelsForProvider(_),A=a0(i,c,d,I);A&&(await b.ensureProvider(_,A),await b.addModelToAllowlist(y),this.ensuredProviders.add(y))}m=y}return new zr({command:u,cwd:n.workspace,agentId:n.agentId,sessionName:f,...x?{gatewayToken:x}:{},...m?{slashModelOnStart:m}:{}})}async openclawRepair(e,n){let i=this.getOpenclawConfig();await i.deleteAgent(e),await i.ensureAgent(e,n)}async cleanupOpenclawSessionProviders(e,n){if(e.framework!=="openclaw"||!this.openclawConfigCache)return;let i=this.openclawConfigCache,o=n??e.model;for(let c of e.sessions.keys()){let d=Qc(c),u=`${d}/${o}`,f=!0;try{await i.removeProvider(d)}catch(x){f=!1,fe.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:d,err:String(x)})}try{await i.removeModelFromAllowlist(u)}catch(x){f=!1,fe.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:u,err:String(x)})}f&&this.ensuredProviders.delete(u)}}};import{randomUUID as ph}from"node:crypto";import{promises as ob}from"node:fs";import{basename as gh}from"node:path";$e();ne();import{promises as eb}from"node:fs";import{basename as tb}from"node:path";var uh=q("file-upload"),nb="/api/coze_claw/file/agent_upload",rb=6e4;async function fh(t,e={}){let i=`${Rr(Cr(e.handshakeBase))}${nb}`,o=e.timeoutMs??rb,c=await eb.readFile(t.path),d=new FormData;d.append("agent_id",t.agentId),d.append("session_id",t.sessionId),d.append("file_name",t.name),d.append("file_content",new Blob([c],{type:t.mimeType}),t.name);let u={Authorization:`Bearer ${t.patToken}`,Accept:"application/json","x-coze-version":"3.0",...vn(e.ppeOverride),...t.accountId?{"x-coze-account":t.accountId}:{}},f=new AbortController,x=setTimeout(()=>f.abort(),o);uh.info("file upload start",{url:i,agentId:t.agentId,sessionId:t.sessionId,name:t.name,bytes:t.sizeBytes,mime:t.mimeType});try{let m=await fetch(i,{method:"POST",headers:u,body:d,signal:f.signal}),_=m.headers.get("x-tt-logid")??"";if(!m.ok){let b=await m.text().catch(()=>"");throw new k("UPLOAD_FAILED",`upload HTTP ${m.status} logid=${_}: ${b.slice(0,200)}`)}let v=await m.json();if(v.code!==void 0&&v.code!==0)throw new k("UPLOAD_FAILED",`upload code=${v.code} msg=${v.msg??"-"} logid=${_}`);let y=v.data?.file?.file_url;if(!y)throw new k("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${_}: ${JSON.stringify(v).slice(0,200)}`);return uh.info("file upload ok",{uri:y,logid:_}),{uri:y}}catch(m){throw m instanceof k?m:m.name==="AbortError"?new k("UPLOAD_FAILED",`upload timeout (${o}ms) for ${tb(t.path)}`):new k("UPLOAD_FAILED",String(m),{cause:m})}finally{clearTimeout(x)}}$e();ne();import{extname as ib}from"node:path";var sb={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".svg":"image/svg+xml",".bmp":"image/bmp",".ico":"image/x-icon",".heic":"image/heic",".heif":"image/heif",".pdf":"application/pdf",".doc":"application/msword",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".xls":"application/vnd.ms-excel",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".ppt":"application/vnd.ms-powerpoint",".pptx":"application/vnd.openxmlformats-officedocument.presentationml.presentation",".txt":"text/plain",".md":"text/markdown",".markdown":"text/markdown",".json":"application/json",".yaml":"text/yaml",".yml":"text/yaml",".csv":"text/csv",".html":"text/html",".htm":"text/html",".xml":"application/xml",".log":"text/plain",".zip":"application/zip",".tar":"application/x-tar",".gz":"application/gzip",".tgz":"application/gzip",".mp3":"audio/mpeg",".wav":"audio/wav",".mp4":"video/mp4",".mov":"video/quicktime",".webm":"video/webm"};async function hh(t){let e=ib(t).toLowerCase();return sb[e]??"application/octet-stream"}Re();var Lo=q("agent-send"),xh=50*1024*1024;function mh(t,e,n){let i=t.get(e);if(!i)throw new k("AGENT_NOT_FOUND",`agent=${e}`);if(t.disconnectedAgents.has(e))throw new k("AGENT_DISCONNECTED",`agent=${e} was disconnected by cloud`);let o=i.sessions.get(n);if(!o)throw new k("AGENT_NOT_FOUND",`session=${n} not active in agent=${e}`);return{session:i,runtime:o}}async function wh(t,e,n,i,o,c){let u;for(let f=0;f<=2;f++)try{await t.core.sendAgentFileUpdate(e,n,i,o);return}catch(x){u=x,f<2&&(Lo.warn("sendAgentFileUpdate failed, retrying",{attempt:f+1,err:String(x)}),await new Promise(m=>setTimeout(m,5e3)))}throw new k("UPSTREAM_NOT_READY",`${c} after 3 attempts: ${String(u)}`,{cause:u})}async function _h(t,e){let{session:n,runtime:i}=mh(e.core,t.agentId,t.sessionId);if(!await oi(t.path,n.workspace))throw new k("PATH_OUTSIDE_WORKSPACE",`path=${t.path} not under workspace=${n.workspace}`);let o=await ob.stat(t.path).catch(()=>null);if(!o||!o.isFile())throw new k("IPC_BAD_REQUEST",`path is not a regular file: ${t.path}`);if(o.size>xh)throw new k("FILE_TOO_LARGE",`${o.size} bytes > limit ${xh}`);let c=await hh(t.path);if(t.kind==="image"&&!c.startsWith("image/"))throw new k("UNSUPPORTED_MIME",`kind=image but mime=${c}`);if(!e.core.upstream.isConnected())throw new k("UPSTREAM_NOT_READY","cloud WS not connected");let d=t.name??gh(t.path),u;try{u=await fh({patToken:n.patToken??e.patToken,agentId:t.agentId,sessionId:t.sessionId,path:t.path,mimeType:c,name:d,sizeBytes:o.size,...n.accountId?{accountId:n.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride})}catch(x){throw Lo.warn("agent file upload failed",{agentId:t.agentId,sessionId:t.sessionId,path:t.path,sizeBytes:o.size,mime:c,code:x instanceof k?x.code:"UNKNOWN",message:x instanceof Error?x.message:String(x)}),x}let f={sessionUpdate:"agent_file",messageId:ph(),content:{type:t.kind==="image"?"image":"resource",uri:u.uri,mimeType:c,name:d,sizeBytes:o.size,...u.fileId!==void 0?{fileId:u.fileId}:{},...t.caption!==void 0?{caption:t.caption}:{}}};return await wh(e,n,i,t.sessionId,f,"agent file uploaded to cloud but sendAgentFileUpdate failed"),Lo.info("agent file sent",{agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,name:d,bytes:o.size,mime:c,uri:u.uri}),{ok:!0,uri:u.uri,bytes:o.size,mimeType:c,...u.fileId!==void 0?{fileId:u.fileId}:{}}}async function yh(t,e){let{session:n,runtime:i}=mh(e.core,t.agentId,t.sessionId);if(!t.mimeType)throw new k("IPC_BAD_REQUEST","group-file requires mimeType");if(!e.core.upstream.isConnected())throw new k("UPSTREAM_NOT_READY","cloud WS not connected");let o=t.name??gh(t.path),c={sessionUpdate:"group_file",messageId:ph(),content:{uri:t.path,name:o,mimeType:t.mimeType,...t.caption!==void 0?{caption:t.caption}:{}}};return await wh(e,n,i,t.sessionId,c,"agent group file sendAgentFileUpdate failed"),Lo.info("agent group file sent",{agentId:t.agentId,sessionId:t.sessionId,uri:t.path,name:o,mime:t.mimeType}),{ok:!0,uri:t.path,bytes:0,mimeType:t.mimeType}}function Eh(t,e){let n=t.split(".").map(Number),i=e.split(".").map(Number),o=Math.max(n.length,i.length);for(let c=0;c<o;c++){let d=n[c]??0,u=i[c]??0;if(d<u)return!0;if(d>u)return!1}return!1}Zt();ne();dn();var Mt=q("coze-cli-installer"),bh="@coze/cli@latest",ab="coze",vh="0.1.8",cb=5e3,db=5e3,lb=9e4,Sh=1e4,Ji=null,No=!1;async function yd(t,e={}){if(No)return;if(Ji)return Ji;let n=e.exec??Kf;return Ji=(async()=>{try{let i=await ub(ab,n),o=!1;if(i){let d=await fb(n);if(d===void 0)Mt.warn("coze-cli found but version unparseable, fall through to full install",{path:i});else if(Eh(d,vh))Mt.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:i,version:d,min:vh}),o=!0;else{Mt.info("coze-cli already on PATH with sufficient version, skip",{path:i,version:d}),No=!0;return}}let c=o?"upgrade-only":"full";Mt.info("coze-cli install start",{package:bh,mode:c});try{await n("npm",["i","-g","--prefer-online",bh],{timeout:lb,maxBuffer:10*1024*1024}),Mt.info("coze-cli install ok")}catch(d){Mt.warn("coze-cli install failed (skip subsequent steps)",{err:String(d)});return}if(o){No=!0;return}if(t.env)try{await n("coze",["config","set","xTTEnv",t.env],{timeout:Sh}),Mt.info("coze config set xTTEnv ok",{env:t.env})}catch(d){Mt.warn("coze config set failed (continue to auth login)",{err:String(d)})}try{await n("coze",["auth","login","--token",t.patToken],{timeout:Sh}),Mt.info("coze auth login ok")}catch(d){Mt.warn("coze auth login failed",{err:String(d)});return}No=!0}finally{Ji=null}})(),Ji}async function ub(t,e){let n=process.platform==="win32"?"where":"which";try{let{stdout:i}=await e(n,[t],{timeout:cb});return za(i)}catch{return}}async function fb(t){try{let{stdout:e,stderr:n}=await t("coze",["--version"],{timeout:db});return(e||n).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}qt();Ht();Re();var hb=10*6e4;function Ih(t){let e=t?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?hb:e}function Mo(t){return lr(t??Y().configFile)}function Zi(t,e){return ur(e??Y().configFile,t)}import{randomBytes as Ob}from"node:crypto";or();$e();ne();import{createReadStream as xb}from"node:fs";import{mkdir as pb,readFile as gb,realpath as mb,stat as wb,writeFile as _b}from"node:fs/promises";import{basename as yb,dirname as Ed,isAbsolute as Eb,join as bb,relative as vb,resolve as Ah,sep as Sb}from"node:path";import{createInterface as Ib}from"node:readline";var Th=q("fs-rpc"),Yi=Ze("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function Ph(t,e){let n=Buffer.byteLength(t.content,"utf8");if(n>Yi)throw new k("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${n} bytes > limit ${Yi} bytes`);let i=await Ch(t.path,e);return await pb(Ed(i),{recursive:!0}),await _b(i,t.content,"utf8"),Th.info("fs/write_text_file ok",{path:i,size:t.content.length}),null}async function Rh(t,e){let n=await Ch(t.path,e),i=await wb(n),o=typeof t.line=="number"||typeof t.limit=="number";if(i.size>Yi&&!o)throw new k("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${i.size} bytes > ${Yi} bytes`);let c;if(o&&i.size>Yi)c=await Ab(n,t.line??1,t.limit);else{let d=await gb(n,"utf8");if(o){let u=d.split(`
|
|
107
107
|
`),f=Math.max(0,(t.line??1)-1),x=typeof t.limit=="number"?f+t.limit:void 0;c=u.slice(f,x).join(`
|
|
108
|
-
`)}else c=d}return
|
|
109
|
-
`)}async function Dh(t,e){if(typeof t!="string"||t.length===0)throw new k("IPC_BAD_REQUEST","path must be a non-empty string");let[r,i]=await Promise.all([Th(kh(e)),Th(kh(t))]),o=bb(r,i);if(Ab(o,vb,yb(o)))throw new k("IPC_BAD_REQUEST",`path escapes workspace: ${t}`);return i}function Ab(t,e,r){return t===""?!1:r?!0:t===".."||t.startsWith(`..${e}`)}async function Th(t){let e=[],r=t;for(;r!==vd(r);)try{let i=await mb(r);return e.length?Eb(i,...e.reverse()):i}catch{e.push(_b(r)),r=vd(r)}return t}te();var Oh=G("prompt-multimodal"),Lh=10*1024*1024,kb=15e3,Tb=6;async function Nh(t){let e=new Array(t.length),r=0;async function i(){for(;r<t.length;){let c=r++,d=t[c];d!==void 0&&(e[c]=await Rb(d))}}let o=Array.from({length:Math.min(Tb,t.length)},()=>i());return await Promise.all(o),e}function Mh(t){return t.some(e=>e.type==="image")}async function Rb(t){if(t.type!=="image")return t;let e=t;if(e.data||!e.uri||!Li(e.uri))return t;try{let{buf:r,contentType:i}=await Pb(e.uri),o=e.mimeType||Cb(i)||"application/octet-stream";return Oh.info("image uri fetched and inlined",{uri:e.uri,bytes:r.length,mimeType:o}),{type:"image",data:r.toString("base64"),mimeType:o}}catch(r){return Oh.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(r)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function Cb(t){if(!t)return;let e=t.indexOf(";");return(e===-1?t:t.slice(0,e)).trim()||void 0}async function Pb(t){let e=new AbortController,r=setTimeout(()=>e.abort(),kb);try{let i=await fetch(t,{signal:e.signal});if(!i.ok)throw new Error(`HTTP ${i.status} ${i.statusText}`);let o=await i.arrayBuffer();if(o.byteLength>Lh)throw new Error(`image too large: ${o.byteLength} bytes (max ${Lh})`);return{buf:Buffer.from(o),contentType:i.headers.get("content-type")??void 0}}finally{clearTimeout(r)}}jt();Ke();te();var W=G("core"),Ob=3e4,Lb=/^(boe|ppe)_[A-Za-z0-9_-]+$/,Nb="\u6211\u6B63\u5728\u7B49\u5F85\u5BA1\u6279\uFF0C\u8BF7\u7A0D\u540E\u518D\u8054\u7CFB\u6211",Mb="\u5BA1\u6279\u5DF2\u8D85\u65F6",Bb=3e4,Fo=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upstreamIds=new Mr;pendingUpstream=new Map;pendingBridge=new Map;currentCozeEnv;currentMockScenario;constructor(e){this.upstream=e.upstream,this.extensions=e.extensions??{},this.paths=e.paths,this.sessionSpawner=e.sessionSpawner,this.sessionIdleTimeoutMs=Ah(e.bridgeConfig)}registerExtension(e,r){this.extensions[e]=r}getCozeEnv(){return this.currentCozeEnv}getMockScenario(){return this.currentMockScenario}setMockScenario(e){this.currentMockScenario=e&&e.length>0?e:void 0}async start(){this.upstream.onFrame(e=>this.handleFrame(e)),this.upstream.onConnect?.(({initial:e})=>{e||this.rejectAllPendingOnReconnect()}),await this.upstream.start(),W.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){W.info("Core stopping",{reason:e}),await Promise.all([...this.agents.values()].map(r=>r.dispose(e))),this.agents.clear(),await this.upstream.stop(e)}async reloadAgents(e){let r=e?this.agents.has(e)?[e]:[]:[...this.agents.keys()];for(let i of r)await this.agents.get(i)?.killAllRuntimes("reload");return r}get(e){return this.agents.get(e)}register(e){this.agents.set(e.agentId,e),W.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let r of this.registerHandlers)try{r(e.agentId)}catch(i){W.warn("onAgentRegister handler threw (ignored)",{agentId:e.agentId,err:String(i)})}}onAgentRegister(e){return this.registerHandlers.add(e),()=>this.registerHandlers.delete(e)}registerHandlers=new Set;unregister(e){this.agents.delete(e)}reviveIfDisconnected(e){this.disconnectedAgents.delete(e)&&W.info("agent revived from disconnect",{agentId:e})}attachRuntimeHooks(e,r,i){let o=i.downstream;o&&(o.onUpdate(c=>{i.loadingSession||this.forwardUpdate(e,c)}),o.onAgentRequest(c=>{this.handleAgentRequest(e,o,c)}),o.onExit((c,d)=>{W.info("session runtime exited",{agentId:e.agentId,cloudId:r,code:c,signal:d}),$i(i),i.downstream=void 0,i.replySeq=0,i.acpSessionId&&e.activeTriggers.delete(i.acpSessionId),this.rejectPendingForDownstream(o,"downstream exited")}))}hasPendingPermissionFor(e){for(let r of this.pendingUpstream.values())if(r.downstream===e)return!0;return!1}rejectPendingForDownstream(e,r){let i=[];for(let[o,c]of this.pendingUpstream)c.downstream===e&&i.push(o);if(i.length!==0){W.info("reject pendingUpstream entries (downstream gone)",{reason:r,count:i.length});for(let o of i){let c=this.pendingUpstream.get(o);if(c){this.pendingUpstream.delete(o),this.upstream.send(In(o,{code:Z.INTERNAL_ERROR,message:`bridge downstream gone: ${r}`})).catch(d=>W.debug("send error response to upstream failed (ignored)",{err:String(d)}));try{c.downstream.respondAgentRequestError(c.agentRequestId,{code:Z.INTERNAL_ERROR,message:`bridge: ${r}`})}catch{}}}}}rejectAllPendingOnReconnect(){let e=this.pendingUpstream.size,r=this.pendingBridge.size;if(!(e===0&&r===0)){W.warn("upstream reconnected, rejecting stale pending requests",{pendingUpstream:e,pendingBridge:r});for(let[,i]of this.pendingUpstream){try{i.downstream.respondAgentRequestError(i.agentRequestId,{code:Z.INTERNAL_ERROR,message:"upstream reconnected; please retry"})}catch{}this.clearPendingPermissionFor(i)}this.pendingUpstream.clear();for(let[,i]of this.pendingBridge)clearTimeout(i.timer),i.reject(new k("UPSTREAM_DISCONNECTED",`${i.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(Io(e)){this.handleUpstreamResponse(e);return}if(!("method"in e)||typeof e.method!="string")return;let r="id"in e&&e.id!==void 0?e.id:null,i=e.params?._meta?.cozeEnv;i&&Lb.test(i)?this.currentCozeEnv=i:i&&W.warn("rejecting cozeEnv with invalid shape, keeping previous",{rejected:i});try{if(e.method.startsWith("_agent/")){let o=this.extensions[e.method];if(!o){r!==null?await this.sendError(r,Z.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):W.warn("drop notification: extension not registered",{method:e.method});return}let c=await o(e,this);r!==null&&await this.upstream.send(Nr(r,c));return}if(e.method.startsWith("session/")){let o=await this.routeSessionMethod(e);r!==null&&await this.upstream.send(Nr(r,o));return}if(e.method==="initialize"){r!==null&&await this.upstream.send(Nr(r,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}r!==null?await this.sendError(r,Z.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):W.warn("drop unknown notification",{method:e.method})}catch(o){W.error("handleFrame failed",{method:e.method,err:String(o)}),r!==null&&await this.upstream.send(In(r,ji(o)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new k("IPC_BAD_REQUEST",`${e.method} requires params`);let r=e.params,i=r._meta?.cozeAgentId;if(!i)throw new k("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let o=this.agents.get(i);if(!o)throw this.disconnectedAgents.has(i)?new k("AGENT_DISCONNECTED",`agent ${i} has been disconnected; cloud must _agent/create to revive`):new k("AGENT_NOT_FOUND",`agent not found: ${i}`);let c=typeof r.sessionId=="string"?r.sessionId:void 0;if(e.method==="session/cancel"||e.method==="session/new"||e.method==="session/set_mode"||!c)return this.dispatchSessionCall(o,e.method,r);if(e.method==="session/prompt"){let f=o.sessions.get(c);if(f?.pendingPermission){let x=r._meta?.cozeTriggerMsgId,g=po(r._meta);return W.info("session in pendingPermission, bouncing new prompt",{agentId:o.agentId,cloudSessionId:c}),this.synthesizePromptReply(o,f,c,Nb,x,g)}}let d=Date.now(),u=!1;try{let f=await o.getSessionQueue(c).enqueue(()=>this.dispatchSessionCall(o,e.method,r));return u=!0,f}finally{W.info("session call done",{agentId:o.agentId,method:e.method,durationMs:Date.now()-d,ok:u})}}async dispatchSessionCall(e,r,i){e.lastActiveAt=Date.now();let{stripped:o}=jf(i);switch(r){case"session/new":{let c=Fb();return W.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:c}),{sessionId:c}}case"session/load":{let c=o;return W.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:c.sessionId}),{}}case"session/prompt":{let c=o,d=c.sessionId;if(!d)throw new k("IPC_BAD_REQUEST","session/prompt: missing sessionId");let u=Xt(e)?qf(i._meta):void 0;if(u!==void 0&&!Mt(e.framework,u))throw new k("IPC_BAD_REQUEST",`unsupported permissionMode for ${e.framework}: ${u}; allowed: ${md(e.framework)}`);let f=await this.ensureRuntime(e,d);if(u!==void 0&&f.permissionMode===void 0&&(f.permissionMode=u,await this.persistSessionMapping(e)),f.replySeq=0,await this.ensureDownstream(e,d,f),!f.downstream||!f.acpSessionId)throw new k("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");if(u!==void 0&&f.permissionMode!==void 0&&f.permissionMode!==u){let S=f.permissionMode;f.permissionMode=u,await this.persistSessionMapping(e);try{await f.downstream.setSessionMode({sessionId:f.acpSessionId,modeId:u})}catch(y){throw f.permissionMode=S,await this.persistSessionMapping(e).catch(()=>{}),y}}let x=i._meta?.cozeTriggerMsgId;x?e.activeTriggers.set(f.acpSessionId,x):e.activeTriggers.delete(f.acpSessionId);let g=po(i._meta);if(g?e.activeGroupIds.set(f.acpSessionId,g):e.activeGroupIds.delete(f.acpSessionId),g&&f.cozeGroupId!==g&&(f.cozeGroupId=g,await this.persistSessionMapping(e)),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&Mh(c.prompt))throw new k("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let w=await Nh(c.prompt);try{let S=await f.downstream.sessionPrompt({...c,sessionId:f.acpSessionId,prompt:w});return f.lastActiveAt=Date.now(),S}catch(S){if(S instanceof k&&S.code==="AGENT_APPROVAL_TIMEOUT"){let y=f.pendingPermission;y&&(y.downstream.respondAgentRequest(y.agentRequestId,{outcome:{outcome:"cancelled"}}),this.pendingUpstream.delete(y.upstreamId),f.pendingPermission=void 0);let v=f.acpSessionId,I=v?e.activeTriggers.get(v):void 0,A=v?e.activeGroupIds.get(v):void 0;return W.warn("approval timed out, synthesizing \u5BA1\u6279\u5DF2\u8D85\u65F6 reply + recovering session",{agentId:e.agentId,cloudId:d}),await this.synthesizePromptReply(e,f,d,Mb,I,A)}throw S}finally{if(e.activeTriggers.delete(f.acpSessionId),e.activeGroupIds.delete(f.acpSessionId),f.pendingPermission=void 0,f.reloadAfterTurn){f.reloadAfterTurn=!1;let S=f.downstream;S&&(f.downstream=void 0,W.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:d,acpId:f.acpSessionId}),S.stop("reload-after-turn").catch(y=>W.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:d,err:String(y)})))}else f.downstream?.isAlive()&&this.armIdleTimer(e,d,f)}}case"session/cancel":{let d=o.sessionId;if(!d)throw new k("IPC_BAD_REQUEST","session/cancel: missing sessionId");let u=e.sessions.get(d);if(e.hasSessionQueue(d)){let f=e.getSessionQueue(d);f.size>0&&(W.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:d,queuedCount:f.size}),f.dispose(new k("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${d}`)))}return u?.downstream?.isAlive()&&u.acpSessionId&&await u.downstream.sessionCancel({sessionId:u.acpSessionId}),{ok:!0}}case"session/set_mode":{let c=o,d=c.sessionId,u=c.modeId,f=po(i._meta);if(!d)throw new k("IPC_BAD_REQUEST","session/set_mode: missing sessionId");if(!Xt(e))throw e.framework==="openclaw"?new k("METHOD_NOT_FOUND","session/set_mode not supported on openclaw"):new k("OPERATION_NOT_ALLOWED_FOR_CLOUD","session/set_mode is local-deploy only in this iteration");if(!Mt(e.framework,u))throw new k("IPC_BAD_REQUEST",`unsupported modeId for ${e.framework}: ${String(u)}; allowed: ${md(e.framework)}`);if(f)return await this.handleGroupSetMode(e,f,u);let x=e.sessions.get(d)??await this.ensureRuntime(e,d);if(x.permissionMode===u)return{};let g=x.permissionMode;if(x.permissionMode=u,await this.persistSessionMapping(e),x.downstream?.isAlive()&&x.acpSessionId)try{await x.downstream.setSessionMode({sessionId:x.acpSessionId,modeId:u})}catch(w){throw x.permissionMode=g,await this.persistSessionMapping(e).catch(()=>{}),w}else W.info("session/set_mode: runtime not active, persisted only",{framework:e.framework,agentId:e.agentId,cloudId:d,modeId:u});return{}}default:throw new k("IPC_BAD_REQUEST",`session method not supported: ${r}`)}}async handleGroupSetMode(e,r,i){let o=[];for(let[d,u]of e.sessions)u.cozeGroupId===r&&u.permissionMode!==i&&o.push({cloudId:d,runtime:u,oldMode:u.permissionMode});if(o.length===0)return W.info("group session/set_mode: no active runtime (db-only path)",{framework:e.framework,agentId:e.agentId,groupId:r,modeId:i}),{};W.info("group session/set_mode: applying to runtimes",{framework:e.framework,agentId:e.agentId,groupId:r,modeId:i,targets:o.length});for(let d of o)d.runtime.permissionMode=i;await this.persistSessionMapping(e);let c=[];for(let d of o){let u=d.runtime.downstream,f=d.runtime.acpSessionId;u?.isAlive()&&f&&c.push({downstream:u,acpSessionId:f,oldMode:d.oldMode,runtime:d.runtime})}for(let d of c)try{await d.downstream.setSessionMode({sessionId:d.acpSessionId,modeId:i})}catch(u){for(let f of o)f.runtime.permissionMode=f.oldMode;throw await this.persistSessionMapping(e).catch(()=>{}),u}return{}}async ensureRuntime(e,r){let i=e.sessions.get(r);if(i)return i;let c={modelToken:e.deployType==="cloud"?await this.requestSessionToken(e.agentId,r):"",tokenGeneratedAt:Date.now(),lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};return Xt(e)&&(e.framework==="hermes"?c.permissionMode=e.deployType==="cloud"?l0:u0:c.permissionMode=e.framework==="claude-code"?yd:uh),e.sessions.set(r,c),await this.persistSessionMapping(e),c}async requestSessionToken(e,r){let i={sessionId:r,_meta:{cozeAgentId:e}};try{let o=await this.sendRequest(xt.GEN_MODEL_TOKEN,i,Bb);if(!o?.modelToken)throw new k("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${r})`);return o.modelToken}catch(o){throw o instanceof k&&o.code==="MODEL_TOKEN_GEN_FAILED"?o:new k("MODEL_TOKEN_GEN_FAILED",o instanceof Error?o.message:String(o),{cause:o})}}async ensureDownstream(e,r,i){if($i(i),i.downstream?.isAlive())return;if(!this.sessionSpawner)throw new k("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let o=3,c=3e4,d=i.spawnFailCount??0,u=i.spawnFailedAt??0;if(d>=o&&Date.now()-u<c)throw new k("AGENT_SPAWN_FAILED",`agent ${e.agentId} session ${r} spawn failed ${d} times in a row; please check framework binary / network and retry after ${Math.ceil((c-(Date.now()-u))/1e3)}s`);let f;try{f=await this.sessionSpawner(e,i.modelToken,r,this.currentCozeEnv,this.currentMockScenario)}catch(x){throw i.spawnFailCount=d+1,i.spawnFailedAt=Date.now(),i.spawnFailCount>=o&&i.acpSessionId&&(W.warn("clearing stale acpSessionId after repeated spawn failures",{agentId:e.agentId,cloudId:r,staleAcpId:i.acpSessionId}),i.acpSessionId=void 0),x}i.spawnFailCount=0,i.spawnFailedAt=void 0,i.downstream=f,this.attachRuntimeHooks(e,r,i);try{if(i.acpSessionId){i.loadingSession=!0;try{await f.sessionLoad({sessionId:i.acpSessionId,cwd:e.workspace}),W.info("session restored via session/load",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId})}catch(x){W.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId,err:String(x)}),i.acpSessionId=void 0;let g=await f.sessionNew({cwd:e.workspace});i.acpSessionId=g.sessionId,await this.persistSessionMapping(e)}finally{i.loadingSession=!1}}else{let x=await f.sessionNew({cwd:e.workspace});i.acpSessionId=x.sessionId,await this.persistSessionMapping(e)}}catch(x){throw W.warn("session init failed after spawn, tearing down half-spawned runtime",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId,err:String(x)}),await f.stop("session-init-failed").catch(()=>{}),i.downstream=void 0,i.acpSessionId=void 0,x}if(f.afterSessionEstablished&&i.acpSessionId&&await f.afterSessionEstablished(i.acpSessionId),Xt(e)&&i.acpSessionId&&i.permissionMode)try{await f.setSessionMode({sessionId:i.acpSessionId,modeId:i.permissionMode})}catch(x){W.warn("post-spawn set_mode failed, framework using its own startup default",{framework:e.framework,agentId:e.agentId,cloudId:r,mode:i.permissionMode,err:String(x)})}}armIdleTimer(e,r,i){if($i(i),this.isRuntimeBusy(e,i)){W.debug("skip idle timer: runtime busy (in-flight turn / pending permission)",{agentId:e.agentId,cloudId:r});return}i.idleTimer=setTimeout(()=>{if(i.idleTimer=void 0,this.isRuntimeBusy(e,i)){W.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:r}),this.armIdleTimer(e,r,i);return}W.info("session runtime idle timeout, killing downstream",{agentId:e.agentId,cloudId:r});let o=i.downstream;i.downstream=void 0,i.acpSessionId&&e.activeTriggers.delete(i.acpSessionId),o&&o.stop("idle timeout").catch(c=>W.warn("idle stop failed (ignored)",{agentId:e.agentId,cloudId:r,err:String(c)}))},this.sessionIdleTimeoutMs),i.idleTimer.unref?.()}isRuntimeBusy(e,r){if(r.acpSessionId&&e.activeTriggers.has(r.acpSessionId))return!0;let i=r.downstream;if(!i)return!1;for(let o of this.pendingUpstream.values())if(o.downstream===i)return!0;return!1}async sendAgentFileUpdate(e,r,i,o){let c={cozeAgentId:e.agentId,cozeReplySeqID:++r.replySeq};if(r.acpSessionId){let d=e.activeTriggers.get(r.acpSessionId);d&&(c.cozeTriggerMsgId=d);let u=e.activeGroupIds.get(r.acpSessionId);u&&(c.cozeGroupId=u)}await this.upstream.send(Lr("session/update",{sessionId:i,update:o,_meta:c}))}async synthesizePromptReply(e,r,i,o,c,d){let u={cozeAgentId:e.agentId,cozeReplySeqID:++r.replySeq};return c&&(u.cozeTriggerMsgId=c),d&&(u.cozeGroupId=d),await this.upstream.send(Lr("session/update",{sessionId:i,update:{sessionUpdate:"agent_message_chunk",content:{type:"text",text:o}},_meta:u})).catch(f=>W.warn("synthesizePromptReply update send failed (ignored)",{err:String(f)})),{stopReason:"end_turn"}}forwardUpdate(e,r){let i=r.sessionId,o=this.reverseSessionId(e,i);if(!o){W.debug("drop update for unknown session",{agentId:e.agentId,acpId:i});return}let c=e.sessions.get(o);if(!c){W.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:o});return}if(Gb(r)){W.debug("drop codex noise chunk",{agentId:e.agentId,acpId:i});return}let d=r.update;if(d&&typeof d=="object"&&d.sessionUpdate==="current_mode_update"&&Xt(e)){let g=d.currentModeId;Mt(e.framework,g)&&c.permissionMode!==g?(c.permissionMode=g,this.persistSessionMapping(e).catch(w=>W.warn("persist mode (from current_mode_update) failed",{framework:e.framework,agentId:e.agentId,err:String(w)}))):typeof g=="string"&&!Mt(e.framework,g)&&W.warn("current_mode_update with invalid modeId for framework, not persisting",{framework:e.framework,agentId:e.agentId,modeId:g})}let u={cozeAgentId:e.agentId,cozeReplySeqID:++c.replySeq},f=e.activeTriggers.get(i);f&&(u.cozeTriggerMsgId=f);let x=e.activeGroupIds.get(i);x&&(u.cozeGroupId=x),this.upstream.send(Lr("session/update",{...r,sessionId:o,_meta:u})).catch(g=>W.warn("forward update failed",{agentId:e.agentId,err:String(g)}))}handleAgentRequest(e,r,i){if(i.method==="session/request_permission"){this.forwardPermissionRequest(e,r,i);return}if(i.method==="fs/write_text_file"||i.method==="fs/read_text_file"){this.handleFsRpcRequest(e,r,i);return}W.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:i.method}),r.respondAgentRequestError(i.id,{code:Z.METHOD_NOT_FOUND,message:`method not handled by Bridge: ${i.method}`})}async handleFsRpcRequest(e,r,i){try{let o=e.workspace;if(i.method==="fs/write_text_file"){let c=i.params??{},d=await Ch(c,o);r.respondAgentRequest(i.id,d)}else{let c=i.params??{},d=await Ph(c,o);r.respondAgentRequest(i.id,d)}}catch(o){W.warn("fs rpc handler failed",{agentId:e.agentId,method:i.method,err:String(o)}),r.respondAgentRequestError(i.id,ji(o))}}clearPendingPermissionFor(e){if(e.method!=="session/request_permission"||!e.cloudSessionId)return;let r=this.agents.get(e.agentId)?.sessions.get(e.cloudSessionId);r&&(r.pendingPermission=void 0)}forwardPermissionRequest(e,r,i){let o=this.upstreamIds.next("session/request_permission"),c=i.params??{},u=c.sessionId,f=u?e.activeTriggers.get(u):void 0,x={cozeAgentId:e.agentId};f&&(x.cozeTriggerMsgId=f);let g=u?e.activeGroupIds.get(u):void 0;g&&(x.cozeGroupId=g);let w=u?this.reverseSessionId(e,u):void 0,S=w?e.sessions.get(w):void 0;S&&(S.pendingPermission={downstream:r,agentRequestId:i.id,upstreamId:o});let y={...c,...w?{sessionId:w}:{},_meta:x};this.pendingUpstream.set(o,{agentRequestId:i.id,agentId:e.agentId,downstream:r,method:i.method,cloudSessionId:w}),W.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:o,acpSessionId:u,cloudSessionId:w,toolCallId:c.toolCall?.toolCallId,options:c.options?.map(v=>({optionId:v.optionId,kind:v.kind,name:v.name}))}),this.upstream.send(Hi(o,"session/request_permission",y)).catch(v=>{this.pendingUpstream.delete(o),W.error("forward permission request failed",{agentId:e.agentId,err:String(v)}),r.respondAgentRequestError(i.id,{code:Z.INTERNAL_ERROR,message:`upstream send failed: ${String(v)}`})})}handleUpstreamResponse(e){if(e.id===null)return;let r=this.lookupPending(this.pendingUpstream,e.id,"upstream");if(r){this.pendingUpstream.delete(r.key);let o=r.value;this.clearPendingPermissionFor(o),e.error?(W.info("upstream \u2192 permission response (error)",{agentId:o.agentId,upstreamId:e.id,method:o.method,error:e.error}),o.downstream.respondAgentRequestError(o.agentRequestId,e.error)):(o.method==="session/request_permission"&&zb(e.result,o),W.info("upstream \u2192 permission response (result)",{agentId:o.agentId,upstreamId:e.id,method:o.method,result:e.result}),o.downstream.respondAgentRequest(o.agentRequestId,e.result));return}let i=this.lookupPending(this.pendingBridge,e.id,"bridge");if(i){this.pendingBridge.delete(i.key),clearTimeout(i.value.timer),e.error?i.value.reject(new So(e.error)):i.value.resolve(e.result);return}W.debug("orphan upstream response (no pending)",{id:e.id})}lookupPending(e,r,i){let o=e.get(r);if(o)return{value:o,key:r};if(typeof r=="number"){let c=String(r),d=e.get(c);if(d)return W.warn(`${i} id type mismatch: number received but Bridge expected string`,{rawId:r,normalizedId:c}),{value:d,key:c}}}sendRequest(e,r,i=Ob){let o=this.upstreamIds.next(e);return new Promise((c,d)=>{let u=setTimeout(()=>{this.pendingBridge.delete(o),d(new k("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i);this.pendingBridge.set(o,{method:e,resolve:c,reject:d,timer:u}),this.upstream.send(Hi(o,e,r)).catch(f=>{let x=this.pendingBridge.get(o);x&&(clearTimeout(x.timer),this.pendingBridge.delete(o)),d(f)})})}async persistSessionMapping(e){if(this.paths)try{let r=new Map;for(let[i,o]of e.sessions){let c={modelToken:o.modelToken,tokenGeneratedAt:o.tokenGeneratedAt};o.acpSessionId&&(c.acpSessionId=o.acpSessionId),o.permissionMode&&Xt(e)&&(c.permissionMode=o.permissionMode),o.cozeGroupId&&(c.cozeGroupId=o.cozeGroupId),r.set(i,c)}await oi(e.agentId,r,this.paths)}catch(r){W.warn("persist session mapping failed",{agentId:e.agentId,err:String(r)})}}reverseSessionId(e,r){for(let[i,o]of e.sessions.entries())if(o.acpSessionId===r)return i}sendError(e,r,i){return this.upstream.send(In(e,{code:r,message:i,data:{bridgeVersion:Nt}}))}};function Fb(){return Db(16).toString("hex")}function zb(t,e){if(!t||typeof t!="object"){W.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:t});return}let r=t;if("kind"in r&&!("outcome"in r)){W.warn('permission response: top-level "kind" field (D66 historical bug shape)',{agentId:e.agentId,result:t});return}let i=r.outcome;if(!i||typeof i!="object"){W.warn("permission response: missing or non-object outcome field",{agentId:e.agentId,result:t});return}let c=i.outcome;(typeof c!="string"||c!=="selected"&&c!=="cancelled")&&W.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:c,result:t})}var Ub=["Model metadata for `","Falling back from WebSockets to HTTPS transport.","Heads up: Long threads and multiple compactions can cause the model to be less accurate."],Bh="Warning: ";function Gb(t){let e=t.update;if(e?.sessionUpdate!=="agent_message_chunk")return!1;let r=e.content;if(!r||typeof r!="object")return!1;let i=r;if(i.type!=="text"||typeof i.text!="string")return!1;let o=i.text.startsWith(Bh)?i.text.slice(Bh.length):i.text;return Ub.some(c=>o.startsWith(c))}qt();te();Re();import{randomBytes as Hb}from"node:crypto";import{createServer as qb}from"node:http";var jb=1e6,Fh=G("ipc"),zo=class{server=null;port=0;token="";routes;paths;constructor(e){this.routes=new Map(e.routes.map(r=>[`${r.method} ${r.path}`,r])),this.paths=e.paths??J()}async start(){this.token=Hb(32).toString("hex");let e=qb((i,o)=>{this.dispatch(i,o)});this.server=e,await new Promise((i,o)=>{e.once("error",o),e.listen(0,"127.0.0.1",()=>i())});let r=e.address();if(!r||typeof r!="object")throw new Error("failed to obtain IPC port");return this.port=r.port,await this.persistAuthFiles(),Fh.info("IPC listening",{port:this.port}),{port:this.port,token:this.token}}async stop(){let e=this.server;e&&(await new Promise((r,i)=>{e.close(o=>o?i(o):r())}),this.server=null)}async persistAuthFiles(){await ut(this.paths.portFile,String(this.port)),await ut(this.paths.tokenFile,this.token,{mode:384})}async dispatch(e,r){if(e.headers.authorization!==`Bearer ${this.token}`){Zi(r,401,{error:"unauthorized"});return}let o=`${e.method} ${(e.url??"").split("?")[0]}`,c=this.routes.get(o);if(!c){Zi(r,404,{error:"not found"});return}let d=null;if(e.method==="POST")try{d=await Wb(e)}catch(u){Zi(r,400,{error:"invalid json",detail:String(u)});return}try{let u=await c.handler(d,e);Zi(r,200,u??{ok:!0})}catch(u){Fh.error("IPC handler failed",{key:o,err:String(u)}),Zi(r,500,{error:u instanceof Error?u.message:String(u)})}}};function Zi(t,e,r){t.statusCode=e,t.setHeader("content-type","application/json"),t.end(JSON.stringify(r))}async function Wb(t){let e=[],r=0;for await(let o of t){let c=o;if(r+=c.length,r>jb)throw new Error("body too large");e.push(c)}let i=Buffer.concat(e).toString("utf8");return i?JSON.parse(i):null}import"node:module";var fS=Ht(Lx(),1),hS=Ht(Yo(),1),xS=Ht(Hr(),1),pS=Ht(Ld(),1),mS=Ht(Bd(),1),gS=Ht(qd(),1),qx=Ht(Xo(),1),wS=Ht(Hx(),1);var jx=qx.default;Ke();te();var{FWS:LS}=tp(),De=G("upstream.frontier"),rp="application/json",ip="none",NS=15e3;function MS(t){class e extends jx{constructor(i){super(i,Jf,{headers:t})}guardTeardown(){this.listenerCount("error")===0&&this.on("error",i=>De.warn("frontier ws error during teardown (handled, prevents daemon crash)",{err:i instanceof Error?i.message:String(i)}))}close(i,o){this.guardTeardown(),super.close(i,o)}terminate(){this.guardTeardown(),super.terminate()}send(i,...o){if(Ol("debug"))try{let c;typeof i=="string"?c=Buffer.from(i,"utf8"):i instanceof Buffer?c=i:i instanceof ArrayBuffer?c=new Uint8Array(i):ArrayBuffer.isView(i)?c=new Uint8Array(i.buffer,i.byteOffset,i.byteLength):c=new Uint8Array(0);let d=Buffer.from(c.slice(0,128)).toString("hex");De.debug("WS raw frame out",{bytes:c.byteLength,headHex:d})}catch(c){De.warn("WS raw frame dump failed",{err:String(c)})}super.send(i,...o)}}return e}var os=class{constructor(e){this.opts=e}opts;fws=null;handler=null;connectHandlers=[];opened=!1;lastSendRefusedLogAt=0;sendRefusedSuppressed=0;openCount=0;async start(){if(this.fws){De.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:Zf,...vn(this.opts.ppeOverride)},r=MS(e),i=Qf(this.opts.urlOverride),o={url:i,ws:r,fpID:Vf,aID:mo,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:rp,force:!0},payloadEncoding:{encoding:ip,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},c=new LS(o),d=!1,u=null,f,x,g=new Promise((y,v)=>{f=y,x=v}),w=y=>{d||(d=!0,u&&(clearTimeout(u),u=null),y?x(y):f())};c.onopen=()=>{this.opened=!0,this.openCount+=1;let y=this.openCount===1;De.info("frontier opened",{url:i,remoteDeviceId:this.opts.handshake.deviceId,initial:y,openCount:this.openCount}),y&&w();for(let v of this.connectHandlers)Promise.resolve(v({initial:y})).catch(I=>De.warn("onConnect handler threw (ignored)",{err:String(I)}))},c.onclose=y=>{this.opened=!1,De.info("frontier closed",{code:y.code,reason:y.reason,willReconnect:y.willReconnect})},c.onerror=y=>{De.warn("frontier error",{code:y.code,msg:y.message}),w(new k("UPSTREAM_DISCONNECTED",`frontier connect error before open: code=${y.code} msg=${y.message??""}`))},c.onmessage=y=>this.handleMessage(y),this.fws=c;let S=this.opts.openTimeoutMs??NS;u=setTimeout(()=>{w(new k("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${S}ms (handshake or upgrade slow)`))},S),await c.connect();try{await g}catch(y){try{c.close(1e3,"open failed")}catch(v){De.warn("fws close during start failure threw (ignored)",{err:String(v)})}throw this.fws=null,this.opened=!1,y}}async stop(e){let r=this.fws;if(r){this.fws=null,this.opened=!1;try{r.close(1e3,e??"bridge shutdown")}catch(i){De.warn("frontier close threw (ignored)",{err:String(i)})}}}async send(e){let r=this.fws,i=e.method;if(!r)throw De.warn("frontier send refused: upstream not started",{method:i}),new k("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected()){let u=Date.now();throw u-this.lastSendRefusedLogAt>1e3?(De.warn("frontier send refused: ws not open",{method:i,opened:this.opened,readyState:r.readyState,...this.sendRefusedSuppressed>0?{suppressedSinceLast:this.sendRefusedSuppressed}:{}}),this.lastSendRefusedLogAt=u,this.sendRefusedSuppressed=0):this.sendRefusedSuppressed+=1,new k("UPSTREAM_DISCONNECTED",`frontier ws not open (opened=${this.opened}, readyState=${r.readyState}); refusing to silently buffer`)}this.injectAgentPatToken(e);let o=JSON.stringify(e),c=e;sp(c)||De.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:o.length});try{await r.send(o,{service:33555712,method:1,payloadType:rp,payloadEncoding:ip})}catch(u){throw De.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(u)}),new k("UPSTREAM_DISCONNECTED",`frontier send failed: ${String(u)}`,{cause:u})}}onFrame(e){this.handler=e}onConnect(e){this.connectHandlers.push(e)}isConnected(){return this.opened&&this.fws?.readyState===1}injectAgentPatToken(e){let r=this.opts.getPatTokenForAgent;if(!r)return;let i=e.params?._meta;if(!i?.cozeAgentId)return;let o=r(i.cozeAgentId);o&&(i.cozePatToken=o)}handleMessage(e){let r=e.message?.service;if(r!==33555712){De.debug("drop non-adapter frontier frame",{service:r});return}let i=zS(e);if(!i){De.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){De.debug("frame received but no onFrame handler",{size:i.length});return}let o;try{o=JSON.parse(i)}catch(d){De.warn("frontier message JSON parse failed",{err:String(d),head:i.slice(0,80)});return}let c=o;sp(c)||De.info("frontier frame in",{logid:FS(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:c.id,method:c.method,body:BS(i)}),Promise.resolve(this.handler(o)).catch(d=>De.warn("frontier frame handler threw",{err:String(d)}))}};function sp(t){return t.method==="_agent/health"?!0:typeof t.id=="string"&&t.id.startsWith("agent.health_")}var op=2e3;function BS(t){return t.length<=op?t:`${t.slice(0,op)}...<truncated, total ${t.length} chars>`}function FS(t){return t?t.high===0?String(t.low>>>0):`${t.high.toString(16)}${(t.low>>>0).toString(16).padStart(8,"0")}`:""}function zS(t){let e=t.message;if(e?.textPayload)return e.textPayload;let r=e?.payload;if(!r)return null;try{return Buffer.from(r).toString("utf8")}catch{return null}}Ke();te();var $d=G("skill-publish"),US="/api/marketplace/product/skill/publish_with_assets",GS=15e4;async function ap(t,e={}){let i=`${Cr(Pr(e.handshakeBase))}${US}`,o=e.timeoutMs??GS,c=new FormData;c.append("skill_id",t.skillId??""),c.append("skill_name",t.skillName),c.append("skill_description",t.description??""),c.append("agent_id",t.agentId),c.append("zip_file",new Blob([t.zip],{type:"application/zip"}),"skill.zip");let d={Authorization:`Bearer ${t.patToken}`,Accept:"application/json","x-coze-version":"3.0",...vn(e.ppeOverride),...t.accountId&&t.accountId!=="0"?{"x-coze-account":t.accountId}:{}},u=new AbortController,f=setTimeout(()=>u.abort(),o);$d.info("skill publish start",{url:i,method:"POST",form:{skill_id:t.skillId??"",skill_name:t.skillName,skill_description:t.description??"",agent_id:t.agentId,zip_file_bytes:t.zip.length},headers:{...d,Authorization:`Bearer ${t.patToken.slice(0,8)}...`}});try{let x=await fetch(i,{method:"POST",headers:d,body:c,signal:u.signal}),g=x.headers.get("x-tt-logid")??"";if(!x.ok){let y=await x.text().catch(()=>"");throw new k("UPLOAD_FAILED",`skill publish HTTP ${x.status} logid=${g}: ${y.slice(0,200)}`)}let w=await x.json();if($d.info("skill publish response",{logid:g,httpStatus:x.status,code:w.code,msg:w.msg,dataSkillId:w.data?.skill_id??"",dataVersion:w.data?.version??""}),w.code!==void 0&&w.code!==0)throw new k("UPLOAD_FAILED",`skill publish code=${w.code} msg=${w.msg??"-"} logid=${g}`);let S={};return w.data?.skill_id!==void 0&&w.data.skill_id!==""&&(S.skillId=String(w.data.skill_id)),w.data?.version&&(S.version=w.data.version),$d.info("skill publish ok",{logid:g,skillId:S.skillId??"",version:S.version??""}),S}catch(x){throw x instanceof k?x:x.name==="AbortError"?new k("UPLOAD_FAILED",`skill publish timeout (${o}ms): ${t.skillName}`):new k("UPLOAD_FAILED",String(x),{cause:x})}finally{clearTimeout(f)}}te();var Yd=G("upstream.switchable"),aa=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,r){if(this.inner===e)return;Yd.info("swap upstream",{reason:r});let i=this.inner;if(this.inner=e,this.handler&&e.onFrame(this.handler),e.onConnect)for(let o of this.connectHandlers)e.onConnect(o);try{await e.start()}catch(o){throw Yd.error("swap target start failed, reverting",{err:String(o)}),this.inner=i,o}await i.stop(r??"swapped").catch(o=>Yd.warn("previous upstream stop threw (ignored)",{err:String(o)}))}current(){return this.inner}start(){return this.inner.start()}stop(e){return this.inner.stop(e)}send(e){return this.inner.send(e)}onFrame(e){this.handler=e,this.inner.onFrame(e)}onConnect(e){this.connectHandlers.push(e),this.inner.onConnect?.(e)}isConnected(){return this.inner.isConnected()}};te();var Vd=G("upstream"),Yr=class{handler=null;async start(){Vd.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){Vd.info("NoopUpstream stopped",{reason:e})}async send(e){Vd.debug("NoopUpstream.send (dropped)",{method:"method"in e?e.method:void 0})}onFrame(e){this.handler=e}isConnected(){return!1}async injectFrame(e){this.handler&&await this.handler(e)}};Ke();te();qt();te();Re();import{promises as HS}from"node:fs";var cp=G("pat-token-store");async function ca(t=J()){try{let r=(await HS.readFile(t.patTokenFile,"utf8")).trim();return r.length===0?(cp.warn("pat-token exists but empty (treating as missing; likely interrupted write)",{path:t.patTokenFile}),null):r}catch(e){let r=e?.code;return r!=="ENOENT"&&cp.warn("read pat-token failed (treating as missing)",{path:t.patTokenFile,code:r,message:e.message}),null}}async function as(t,e=J()){if(!t)throw new Error("writePatToken: empty patToken");await ut(e.patTokenFile,t,{mode:384})}Re();Re();import{promises as da}from"node:fs";import{join as qS}from"node:path";function jS(t,e){return`#!/bin/sh
|
|
108
|
+
`)}else c=d}return Th.info("fs/read_text_file ok",{path:n,size:c.length}),{content:c}}async function Ab(t,e,n){let i=Ib({input:xb(t,{encoding:"utf8"}),crlfDelay:Number.POSITIVE_INFINITY}),o=Math.max(0,e-1),c=typeof n=="number"?o+n:Number.POSITIVE_INFINITY,d=[],u=0;try{for await(let f of i)if(u>=o&&u<c&&d.push(f),u++,u>=c)break}finally{i.close()}return d.join(`
|
|
109
|
+
`)}async function Ch(t,e){if(typeof t!="string"||t.length===0)throw new k("IPC_BAD_REQUEST","path must be a non-empty string");let[n,i]=await Promise.all([kh(Ah(e)),kh(Ah(t))]),o=vb(n,i);if(kb(o,Sb,Eb(o)))throw new k("IPC_BAD_REQUEST",`path escapes workspace: ${t}`);return i}function kb(t,e,n){return t===""?!1:n?!0:t===".."||t.startsWith(`..${e}`)}async function kh(t){let e=[],n=t;for(;n!==Ed(n);)try{let i=await mb(n);return e.length?bb(i,...e.reverse()):i}catch{e.push(yb(n)),n=Ed(n)}return t}ne();var Dh=q("prompt-multimodal"),Oh=10*1024*1024,Tb=15e3,Pb=6;async function Lh(t){let e=new Array(t.length),n=0;async function i(){for(;n<t.length;){let c=n++,d=t[c];d!==void 0&&(e[c]=await Rb(d))}}let o=Array.from({length:Math.min(Pb,t.length)},()=>i());return await Promise.all(o),e}function Nh(t){return t.some(e=>e.type==="image")}async function Rb(t){if(t.type!=="image")return t;let e=t;if(e.data||!e.uri||!Ni(e.uri))return t;try{let{buf:n,contentType:i}=await Db(e.uri),o=e.mimeType||Cb(i)||"application/octet-stream";return Dh.info("image uri fetched and inlined",{uri:e.uri,bytes:n.length,mimeType:o}),{type:"image",data:n.toString("base64"),mimeType:o}}catch(n){return Dh.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(n)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function Cb(t){if(!t)return;let e=t.indexOf(";");return(e===-1?t:t.slice(0,e)).trim()||void 0}async function Db(t){let e=new AbortController,n=setTimeout(()=>e.abort(),Tb);try{let i=await fetch(t,{signal:e.signal});if(!i.ok)throw new Error(`HTTP ${i.status} ${i.statusText}`);let o=await i.arrayBuffer();if(o.byteLength>Oh)throw new Error(`image too large: ${o.byteLength} bytes (max ${Oh})`);return{buf:Buffer.from(o),contentType:i.headers.get("content-type")??void 0}}finally{clearTimeout(n)}}qt();$e();ne();var $=q("core"),Lb=3e4,Nb=/^(boe|ppe)_[A-Za-z0-9_-]+$/,Mb="\u6211\u6B63\u5728\u7B49\u5F85\u5BA1\u6279\uFF0C\u8BF7\u7A0D\u540E\u518D\u8054\u7CFB\u6211",Bb="\u5BA1\u6279\u5DF2\u8D85\u65F6",Fb=3e4,Bo=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upstreamIds=new Mr;pendingUpstream=new Map;pendingBridge=new Map;currentCozeEnv;currentMockScenario;constructor(e){this.upstream=e.upstream,this.extensions=e.extensions??{},this.paths=e.paths,this.sessionSpawner=e.sessionSpawner,this.sessionIdleTimeoutMs=Ih(e.bridgeConfig)}registerExtension(e,n){this.extensions[e]=n}getCozeEnv(){return this.currentCozeEnv}getMockScenario(){return this.currentMockScenario}setMockScenario(e){this.currentMockScenario=e&&e.length>0?e:void 0}async start(){this.upstream.onFrame(e=>this.handleFrame(e)),this.upstream.onConnect?.(({initial:e})=>{e||this.rejectAllPendingOnReconnect()}),await this.upstream.start(),$.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){$.info("Core stopping",{reason:e}),await Promise.all([...this.agents.values()].map(n=>n.dispose(e))),this.agents.clear(),await this.upstream.stop(e)}async reloadAgents(e){let n=e?this.agents.has(e)?[e]:[]:[...this.agents.keys()];for(let i of n)await this.agents.get(i)?.killAllRuntimes("reload");return n}get(e){return this.agents.get(e)}register(e){this.agents.set(e.agentId,e),$.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let n of this.registerHandlers)try{n(e.agentId)}catch(i){$.warn("onAgentRegister handler threw (ignored)",{agentId:e.agentId,err:String(i)})}}onAgentRegister(e){return this.registerHandlers.add(e),()=>this.registerHandlers.delete(e)}registerHandlers=new Set;unregister(e){this.agents.delete(e)}reviveIfDisconnected(e){this.disconnectedAgents.delete(e)&&$.info("agent revived from disconnect",{agentId:e})}attachRuntimeHooks(e,n,i){let o=i.downstream;o&&(o.onUpdate(c=>{i.loadingSession||this.forwardUpdate(e,c)}),o.onAgentRequest(c=>{this.handleAgentRequest(e,o,c)}),o.onExit((c,d)=>{$.info("session runtime exited",{agentId:e.agentId,cloudId:n,code:c,signal:d}),Vi(i),i.downstream=void 0,i.replySeq=0,i.acpSessionId&&e.activeTriggers.delete(i.acpSessionId),this.rejectPendingForDownstream(o,"downstream exited")}))}hasPendingPermissionFor(e){for(let n of this.pendingUpstream.values())if(n.downstream===e)return!0;return!1}rejectPendingForDownstream(e,n){let i=[];for(let[o,c]of this.pendingUpstream)c.downstream===e&&i.push(o);if(i.length!==0){$.info("reject pendingUpstream entries (downstream gone)",{reason:n,count:i.length});for(let o of i){let c=this.pendingUpstream.get(o);if(c){this.pendingUpstream.delete(o),this.upstream.send(In(o,{code:X.INTERNAL_ERROR,message:`bridge downstream gone: ${n}`})).catch(d=>$.debug("send error response to upstream failed (ignored)",{err:String(d)}));try{c.downstream.respondAgentRequestError(c.agentRequestId,{code:X.INTERNAL_ERROR,message:`bridge: ${n}`})}catch{}}}}}rejectAllPendingOnReconnect(){let e=this.pendingUpstream.size,n=this.pendingBridge.size;if(!(e===0&&n===0)){$.warn("upstream reconnected, rejecting stale pending requests",{pendingUpstream:e,pendingBridge:n});for(let[,i]of this.pendingUpstream){try{i.downstream.respondAgentRequestError(i.agentRequestId,{code:X.INTERNAL_ERROR,message:"upstream reconnected; please retry"})}catch{}this.clearPendingPermissionFor(i)}this.pendingUpstream.clear();for(let[,i]of this.pendingBridge)clearTimeout(i.timer),i.reject(new k("UPSTREAM_DISCONNECTED",`${i.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(So(e)){this.handleUpstreamResponse(e);return}if(!("method"in e)||typeof e.method!="string")return;let n="id"in e&&e.id!==void 0?e.id:null,i=e.params?._meta?.cozeEnv;i&&Nb.test(i)?this.currentCozeEnv=i:i&&$.warn("rejecting cozeEnv with invalid shape, keeping previous",{rejected:i});try{if(e.method.startsWith("_agent/")){let o=this.extensions[e.method];if(!o){n!==null?await this.sendError(n,X.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):$.warn("drop notification: extension not registered",{method:e.method});return}let c=await o(e,this);n!==null&&await this.upstream.send(Nr(n,c));return}if(e.method.startsWith("session/")){let o=await this.routeSessionMethod(e);n!==null&&await this.upstream.send(Nr(n,o));return}if(e.method==="initialize"){n!==null&&await this.upstream.send(Nr(n,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}n!==null?await this.sendError(n,X.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):$.warn("drop unknown notification",{method:e.method})}catch(o){$.error("handleFrame failed",{method:e.method,err:String(o)}),n!==null&&await this.upstream.send(In(n,Wi(o)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new k("IPC_BAD_REQUEST",`${e.method} requires params`);let n=e.params,i=n._meta?.cozeAgentId;if(!i)throw new k("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let o=this.agents.get(i);if(!o)throw this.disconnectedAgents.has(i)?new k("AGENT_DISCONNECTED",`agent ${i} has been disconnected; cloud must _agent/create to revive`):new k("AGENT_NOT_FOUND",`agent not found: ${i}`);let c=typeof n.sessionId=="string"?n.sessionId:void 0;if(e.method==="session/cancel"||e.method==="session/new"||e.method==="session/set_mode"||!c)return this.dispatchSessionCall(o,e.method,n);if(e.method==="session/prompt"){let f=o.sessions.get(c);if(f?.pendingPermission){let x=n._meta?.cozeTriggerMsgId,m=xo(n._meta);return $.info("session in pendingPermission, bouncing new prompt",{agentId:o.agentId,cloudSessionId:c}),this.synthesizePromptReply(o,f,c,Mb,x,m)}}let d=Date.now(),u=!1;try{let f=await o.getSessionQueue(c).enqueue(()=>this.dispatchSessionCall(o,e.method,n));return u=!0,f}finally{$.info("session call done",{agentId:o.agentId,method:e.method,durationMs:Date.now()-d,ok:u})}}async dispatchSessionCall(e,n,i){e.lastActiveAt=Date.now();let{stripped:o}=qf(i);switch(n){case"session/new":{let c=zb();return $.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:c}),{sessionId:c}}case"session/load":{let c=o;return $.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:c.sessionId}),{}}case"session/prompt":{let c=o,d=c.sessionId;if(!d)throw new k("IPC_BAD_REQUEST","session/prompt: missing sessionId");let u=Yt(e)?Hf(i._meta):void 0;if(u!==void 0&&!Nt(e.framework,u))throw new k("IPC_BAD_REQUEST",`unsupported permissionMode for ${e.framework}: ${u}; allowed: ${xd(e.framework)}`);let f=await this.ensureRuntime(e,d);if(u!==void 0&&f.permissionMode===void 0&&(f.permissionMode=u,await this.persistSessionMapping(e)),f.replySeq=0,await this.ensureDownstream(e,d,f),!f.downstream||!f.acpSessionId)throw new k("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");if(u!==void 0&&f.permissionMode!==void 0&&f.permissionMode!==u){let v=f.permissionMode;f.permissionMode=u,await this.persistSessionMapping(e);try{await f.downstream.setSessionMode({sessionId:f.acpSessionId,modeId:u})}catch(y){throw f.permissionMode=v,await this.persistSessionMapping(e).catch(()=>{}),y}}let x=i._meta?.cozeTriggerMsgId;x?e.activeTriggers.set(f.acpSessionId,x):e.activeTriggers.delete(f.acpSessionId);let m=xo(i._meta);if(m?e.activeGroupIds.set(f.acpSessionId,m):e.activeGroupIds.delete(f.acpSessionId),m&&f.cozeGroupId!==m&&(f.cozeGroupId=m,await this.persistSessionMapping(e)),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&Nh(c.prompt))throw new k("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let _=await Lh(c.prompt);try{let v=await f.downstream.sessionPrompt({...c,sessionId:f.acpSessionId,prompt:_});return f.lastActiveAt=Date.now(),v}catch(v){if(v instanceof k&&v.code==="AGENT_APPROVAL_TIMEOUT"){let y=f.pendingPermission;y&&(y.downstream.respondAgentRequest(y.agentRequestId,{outcome:{outcome:"cancelled"}}),this.pendingUpstream.delete(y.upstreamId),f.pendingPermission=void 0);let b=f.acpSessionId,I=b?e.activeTriggers.get(b):void 0,A=b?e.activeGroupIds.get(b):void 0;return $.warn("approval timed out, synthesizing \u5BA1\u6279\u5DF2\u8D85\u65F6 reply + recovering session",{agentId:e.agentId,cloudId:d}),await this.synthesizePromptReply(e,f,d,Bb,I,A)}throw v}finally{if(e.activeTriggers.delete(f.acpSessionId),e.activeGroupIds.delete(f.acpSessionId),f.pendingPermission=void 0,f.reloadAfterTurn){f.reloadAfterTurn=!1;let v=f.downstream;v&&(f.downstream=void 0,$.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:d,acpId:f.acpSessionId}),v.stop("reload-after-turn").catch(y=>$.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:d,err:String(y)})))}else f.downstream?.isAlive()&&this.armIdleTimer(e,d,f)}}case"session/cancel":{let d=o.sessionId;if(!d)throw new k("IPC_BAD_REQUEST","session/cancel: missing sessionId");let u=e.sessions.get(d);if(e.hasSessionQueue(d)){let f=e.getSessionQueue(d);f.size>0&&($.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:d,queuedCount:f.size}),f.dispose(new k("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${d}`)))}return u?.downstream?.isAlive()&&u.acpSessionId&&await u.downstream.sessionCancel({sessionId:u.acpSessionId}),{ok:!0}}case"session/set_mode":{let c=o,d=c.sessionId,u=c.modeId,f=xo(i._meta);if(!d)throw new k("IPC_BAD_REQUEST","session/set_mode: missing sessionId");if(!Yt(e))throw e.framework==="openclaw"?new k("METHOD_NOT_FOUND","session/set_mode not supported on openclaw"):new k("OPERATION_NOT_ALLOWED_FOR_CLOUD","session/set_mode is local-deploy only in this iteration");if(!Nt(e.framework,u))throw new k("IPC_BAD_REQUEST",`unsupported modeId for ${e.framework}: ${String(u)}; allowed: ${xd(e.framework)}`);if(f)return await this.handleGroupSetMode(e,f,u);let x=e.sessions.get(d)??await this.ensureRuntime(e,d);if(x.permissionMode===u)return{};let m=x.permissionMode;if(x.permissionMode=u,await this.persistSessionMapping(e),x.downstream?.isAlive()&&x.acpSessionId)try{await x.downstream.setSessionMode({sessionId:x.acpSessionId,modeId:u})}catch(_){throw x.permissionMode=m,await this.persistSessionMapping(e).catch(()=>{}),_}else $.info("session/set_mode: runtime not active, persisted only",{framework:e.framework,agentId:e.agentId,cloudId:d,modeId:u});return{}}default:throw new k("IPC_BAD_REQUEST",`session method not supported: ${n}`)}}async handleGroupSetMode(e,n,i){let o=[];for(let[d,u]of e.sessions)u.cozeGroupId===n&&u.permissionMode!==i&&o.push({cloudId:d,runtime:u,oldMode:u.permissionMode});if(o.length===0)return $.info("group session/set_mode: no active runtime (db-only path)",{framework:e.framework,agentId:e.agentId,groupId:n,modeId:i}),{};$.info("group session/set_mode: applying to runtimes",{framework:e.framework,agentId:e.agentId,groupId:n,modeId:i,targets:o.length});for(let d of o)d.runtime.permissionMode=i;await this.persistSessionMapping(e);let c=[];for(let d of o){let u=d.runtime.downstream,f=d.runtime.acpSessionId;u?.isAlive()&&f&&c.push({downstream:u,acpSessionId:f,oldMode:d.oldMode,runtime:d.runtime})}for(let d of c)try{await d.downstream.setSessionMode({sessionId:d.acpSessionId,modeId:i})}catch(u){for(let f of o)f.runtime.permissionMode=f.oldMode;throw await this.persistSessionMapping(e).catch(()=>{}),u}return{}}async ensureRuntime(e,n){let i=e.sessions.get(n);if(i)return i;let c={modelToken:e.deployType==="cloud"?await this.requestSessionToken(e.agentId,n):"",tokenGeneratedAt:Date.now(),lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};return Yt(e)&&(e.framework==="hermes"?c.permissionMode=e.deployType==="cloud"?d0:l0:c.permissionMode=e.framework==="claude-code"?wd:lh),e.sessions.set(n,c),await this.persistSessionMapping(e),c}async requestSessionToken(e,n){let i={sessionId:n,_meta:{cozeAgentId:e}};try{let o=await this.sendRequest(xt.GEN_MODEL_TOKEN,i,Fb);if(!o?.modelToken)throw new k("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${n})`);return o.modelToken}catch(o){throw o instanceof k&&o.code==="MODEL_TOKEN_GEN_FAILED"?o:new k("MODEL_TOKEN_GEN_FAILED",o instanceof Error?o.message:String(o),{cause:o})}}async ensureDownstream(e,n,i){if(Vi(i),i.downstream?.isAlive())return;if(!this.sessionSpawner)throw new k("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let o=3,c=3e4,d=i.spawnFailCount??0,u=i.spawnFailedAt??0;if(d>=o&&Date.now()-u<c)throw new k("AGENT_SPAWN_FAILED",`agent ${e.agentId} session ${n} spawn failed ${d} times in a row; please check framework binary / network and retry after ${Math.ceil((c-(Date.now()-u))/1e3)}s`);let f;try{f=await this.sessionSpawner(e,i.modelToken,n,this.currentCozeEnv,this.currentMockScenario)}catch(x){throw i.spawnFailCount=d+1,i.spawnFailedAt=Date.now(),i.spawnFailCount>=o&&i.acpSessionId&&($.warn("clearing stale acpSessionId after repeated spawn failures",{agentId:e.agentId,cloudId:n,staleAcpId:i.acpSessionId}),i.acpSessionId=void 0),x}i.spawnFailCount=0,i.spawnFailedAt=void 0,i.downstream=f,this.attachRuntimeHooks(e,n,i);try{if(i.acpSessionId){i.loadingSession=!0;try{await f.sessionLoad({sessionId:i.acpSessionId,cwd:e.workspace}),$.info("session restored via session/load",{agentId:e.agentId,cloudId:n,acpId:i.acpSessionId})}catch(x){$.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:n,acpId:i.acpSessionId,err:String(x)}),i.acpSessionId=void 0;let m=await f.sessionNew({cwd:e.workspace});i.acpSessionId=m.sessionId,await this.persistSessionMapping(e)}finally{i.loadingSession=!1}}else{let x=await f.sessionNew({cwd:e.workspace});i.acpSessionId=x.sessionId,await this.persistSessionMapping(e)}}catch(x){throw $.warn("session init failed after spawn, tearing down half-spawned runtime",{agentId:e.agentId,cloudId:n,acpId:i.acpSessionId,err:String(x)}),await f.stop("session-init-failed").catch(()=>{}),i.downstream=void 0,i.acpSessionId=void 0,x}if(f.afterSessionEstablished&&i.acpSessionId&&await f.afterSessionEstablished(i.acpSessionId),Yt(e)&&i.acpSessionId&&i.permissionMode)try{await f.setSessionMode({sessionId:i.acpSessionId,modeId:i.permissionMode})}catch(x){$.warn("post-spawn set_mode failed, framework using its own startup default",{framework:e.framework,agentId:e.agentId,cloudId:n,mode:i.permissionMode,err:String(x)})}}armIdleTimer(e,n,i){if(Vi(i),this.isRuntimeBusy(e,i)){$.debug("skip idle timer: runtime busy (in-flight turn / pending permission)",{agentId:e.agentId,cloudId:n});return}i.idleTimer=setTimeout(()=>{if(i.idleTimer=void 0,this.isRuntimeBusy(e,i)){$.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:n}),this.armIdleTimer(e,n,i);return}$.info("session runtime idle timeout, killing downstream",{agentId:e.agentId,cloudId:n});let o=i.downstream;i.downstream=void 0,i.acpSessionId&&e.activeTriggers.delete(i.acpSessionId),o&&o.stop("idle timeout").catch(c=>$.warn("idle stop failed (ignored)",{agentId:e.agentId,cloudId:n,err:String(c)}))},this.sessionIdleTimeoutMs),i.idleTimer.unref?.()}isRuntimeBusy(e,n){if(n.acpSessionId&&e.activeTriggers.has(n.acpSessionId))return!0;let i=n.downstream;if(!i)return!1;for(let o of this.pendingUpstream.values())if(o.downstream===i)return!0;return!1}async sendAgentFileUpdate(e,n,i,o){let c={cozeAgentId:e.agentId,cozeReplySeqID:++n.replySeq};if(n.acpSessionId){let d=e.activeTriggers.get(n.acpSessionId);d&&(c.cozeTriggerMsgId=d);let u=e.activeGroupIds.get(n.acpSessionId);u&&(c.cozeGroupId=u)}await this.upstream.send(Lr("session/update",{sessionId:i,update:o,_meta:c}))}async synthesizePromptReply(e,n,i,o,c,d){let u={cozeAgentId:e.agentId,cozeReplySeqID:++n.replySeq};return c&&(u.cozeTriggerMsgId=c),d&&(u.cozeGroupId=d),await this.upstream.send(Lr("session/update",{sessionId:i,update:{sessionUpdate:"agent_message_chunk",content:{type:"text",text:o}},_meta:u})).catch(f=>$.warn("synthesizePromptReply update send failed (ignored)",{err:String(f)})),{stopReason:"end_turn"}}forwardUpdate(e,n){let i=n.sessionId,o=this.reverseSessionId(e,i);if(!o){$.debug("drop update for unknown session",{agentId:e.agentId,acpId:i});return}let c=e.sessions.get(o);if(!c){$.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:o});return}if(Hb(n)){$.debug("drop codex noise chunk",{agentId:e.agentId,acpId:i});return}let d=n.update;if(d&&typeof d=="object"&&d.sessionUpdate==="current_mode_update"&&Yt(e)){let m=d.currentModeId;Nt(e.framework,m)&&c.permissionMode!==m?(c.permissionMode=m,this.persistSessionMapping(e).catch(_=>$.warn("persist mode (from current_mode_update) failed",{framework:e.framework,agentId:e.agentId,err:String(_)}))):typeof m=="string"&&!Nt(e.framework,m)&&$.warn("current_mode_update with invalid modeId for framework, not persisting",{framework:e.framework,agentId:e.agentId,modeId:m})}let u={cozeAgentId:e.agentId,cozeReplySeqID:++c.replySeq},f=e.activeTriggers.get(i);f&&(u.cozeTriggerMsgId=f);let x=e.activeGroupIds.get(i);x&&(u.cozeGroupId=x),this.upstream.send(Lr("session/update",{...n,sessionId:o,_meta:u})).catch(m=>$.warn("forward update failed",{agentId:e.agentId,err:String(m)}))}handleAgentRequest(e,n,i){if(i.method==="session/request_permission"){this.forwardPermissionRequest(e,n,i);return}if(i.method==="fs/write_text_file"||i.method==="fs/read_text_file"){this.handleFsRpcRequest(e,n,i);return}$.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:i.method}),n.respondAgentRequestError(i.id,{code:X.METHOD_NOT_FOUND,message:`method not handled by Bridge: ${i.method}`})}async handleFsRpcRequest(e,n,i){try{let o=e.workspace;if(i.method==="fs/write_text_file"){let c=i.params??{},d=await Ph(c,o);n.respondAgentRequest(i.id,d)}else{let c=i.params??{},d=await Rh(c,o);n.respondAgentRequest(i.id,d)}}catch(o){$.warn("fs rpc handler failed",{agentId:e.agentId,method:i.method,err:String(o)}),n.respondAgentRequestError(i.id,Wi(o))}}clearPendingPermissionFor(e){if(e.method!=="session/request_permission"||!e.cloudSessionId)return;let n=this.agents.get(e.agentId)?.sessions.get(e.cloudSessionId);n&&(n.pendingPermission=void 0)}forwardPermissionRequest(e,n,i){let o=this.upstreamIds.next("session/request_permission"),c=i.params??{},u=c.sessionId,f=u?e.activeTriggers.get(u):void 0,x={cozeAgentId:e.agentId};f&&(x.cozeTriggerMsgId=f);let m=u?e.activeGroupIds.get(u):void 0;m&&(x.cozeGroupId=m);let _=u?this.reverseSessionId(e,u):void 0,v=_?e.sessions.get(_):void 0;v&&(v.pendingPermission={downstream:n,agentRequestId:i.id,upstreamId:o});let y={...c,..._?{sessionId:_}:{},_meta:x};this.pendingUpstream.set(o,{agentRequestId:i.id,agentId:e.agentId,downstream:n,method:i.method,cloudSessionId:_}),$.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:o,acpSessionId:u,cloudSessionId:_,toolCallId:c.toolCall?.toolCallId,options:c.options?.map(b=>({optionId:b.optionId,kind:b.kind,name:b.name}))}),this.upstream.send(qi(o,"session/request_permission",y)).catch(b=>{this.pendingUpstream.delete(o),$.error("forward permission request failed",{agentId:e.agentId,err:String(b)}),n.respondAgentRequestError(i.id,{code:X.INTERNAL_ERROR,message:`upstream send failed: ${String(b)}`})})}handleUpstreamResponse(e){if(e.id===null)return;let n=this.lookupPending(this.pendingUpstream,e.id,"upstream");if(n){this.pendingUpstream.delete(n.key);let o=n.value;this.clearPendingPermissionFor(o),e.error?($.info("upstream \u2192 permission response (error)",{agentId:o.agentId,upstreamId:e.id,method:o.method,error:e.error}),o.downstream.respondAgentRequestError(o.agentRequestId,e.error)):(o.method==="session/request_permission"&&Ub(e.result,o),$.info("upstream \u2192 permission response (result)",{agentId:o.agentId,upstreamId:e.id,method:o.method,result:e.result}),o.downstream.respondAgentRequest(o.agentRequestId,e.result));return}let i=this.lookupPending(this.pendingBridge,e.id,"bridge");if(i){this.pendingBridge.delete(i.key),clearTimeout(i.value.timer),e.error?i.value.reject(new vo(e.error)):i.value.resolve(e.result);return}$.debug("orphan upstream response (no pending)",{id:e.id})}lookupPending(e,n,i){let o=e.get(n);if(o)return{value:o,key:n};if(typeof n=="number"){let c=String(n),d=e.get(c);if(d)return $.warn(`${i} id type mismatch: number received but Bridge expected string`,{rawId:n,normalizedId:c}),{value:d,key:c}}}sendRequest(e,n,i=Lb){let o=this.upstreamIds.next(e);return new Promise((c,d)=>{let u=setTimeout(()=>{this.pendingBridge.delete(o),d(new k("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i);this.pendingBridge.set(o,{method:e,resolve:c,reject:d,timer:u}),this.upstream.send(qi(o,e,n)).catch(f=>{let x=this.pendingBridge.get(o);x&&(clearTimeout(x.timer),this.pendingBridge.delete(o)),d(f)})})}async persistSessionMapping(e){if(this.paths)try{let n=new Map;for(let[i,o]of e.sessions){let c={modelToken:o.modelToken,tokenGeneratedAt:o.tokenGeneratedAt};o.acpSessionId&&(c.acpSessionId=o.acpSessionId),o.permissionMode&&Yt(e)&&(c.permissionMode=o.permissionMode),o.cozeGroupId&&(c.cozeGroupId=o.cozeGroupId),n.set(i,c)}await ai(e.agentId,n,this.paths)}catch(n){$.warn("persist session mapping failed",{agentId:e.agentId,err:String(n)})}}reverseSessionId(e,n){for(let[i,o]of e.sessions.entries())if(o.acpSessionId===n)return i}sendError(e,n,i){return this.upstream.send(In(e,{code:n,message:i,data:{bridgeVersion:Lt}}))}};function zb(){return Ob(16).toString("hex")}function Ub(t,e){if(!t||typeof t!="object"){$.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:t});return}let n=t;if("kind"in n&&!("outcome"in n)){$.warn('permission response: top-level "kind" field (D66 historical bug shape)',{agentId:e.agentId,result:t});return}let i=n.outcome;if(!i||typeof i!="object"){$.warn("permission response: missing or non-object outcome field",{agentId:e.agentId,result:t});return}let c=i.outcome;(typeof c!="string"||c!=="selected"&&c!=="cancelled")&&$.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:c,result:t})}var Gb=["Model metadata for `","Falling back from WebSockets to HTTPS transport.","Heads up: Long threads and multiple compactions can cause the model to be less accurate."],Mh="Warning: ";function Hb(t){let e=t.update;if(e?.sessionUpdate!=="agent_message_chunk")return!1;let n=e.content;if(!n||typeof n!="object")return!1;let i=n;if(i.type!=="text"||typeof i.text!="string")return!1;let o=i.text.startsWith(Mh)?i.text.slice(Mh.length):i.text;return Gb.some(c=>o.startsWith(c))}Ht();ne();Re();import{randomBytes as qb}from"node:crypto";import{createServer as jb}from"node:http";var Wb=1e6,Bh=q("ipc"),Fo=class{server=null;port=0;token="";routes;paths;constructor(e){this.routes=new Map(e.routes.map(n=>[`${n.method} ${n.path}`,n])),this.paths=e.paths??Y()}async start(){this.token=qb(32).toString("hex");let e=jb((i,o)=>{this.dispatch(i,o)});this.server=e,await new Promise((i,o)=>{e.once("error",o),e.listen(0,"127.0.0.1",()=>i())});let n=e.address();if(!n||typeof n!="object")throw new Error("failed to obtain IPC port");return this.port=n.port,await this.persistAuthFiles(),Bh.info("IPC listening",{port:this.port}),{port:this.port,token:this.token}}async stop(){let e=this.server;e&&(await new Promise((n,i)=>{e.close(o=>o?i(o):n())}),this.server=null)}async persistAuthFiles(){await ut(this.paths.portFile,String(this.port)),await ut(this.paths.tokenFile,this.token,{mode:384})}async dispatch(e,n){if(e.headers.authorization!==`Bearer ${this.token}`){Xi(n,401,{error:"unauthorized"});return}let o=`${e.method} ${(e.url??"").split("?")[0]}`,c=this.routes.get(o);if(!c){Xi(n,404,{error:"not found"});return}let d=null;if(e.method==="POST")try{d=await Kb(e)}catch(u){Xi(n,400,{error:"invalid json",detail:String(u)});return}try{let u=await c.handler(d,e);Xi(n,200,u??{ok:!0})}catch(u){Bh.error("IPC handler failed",{key:o,err:String(u)}),Xi(n,500,{error:u instanceof Error?u.message:String(u)})}}};function Xi(t,e,n){t.statusCode=e,t.setHeader("content-type","application/json"),t.end(JSON.stringify(n))}async function Kb(t){let e=[],n=0;for await(let o of t){let c=o;if(n+=c.length,n>Wb)throw new Error("body too large");e.push(c)}let i=Buffer.concat(e).toString("utf8");return i?JSON.parse(i):null}import"node:module";var hS=Gt(Ox(),1),xS=Gt($o(),1),pS=Gt(Hr(),1),gS=Gt(Dd(),1),mS=Gt(Nd(),1),wS=Gt(Gd(),1),Hx=Gt(Yo(),1),_S=Gt(Gx(),1);var qx=Hx.default;$e();ne();var{FWS:NS}=ep(),Oe=q("upstream.frontier"),np="application/json",rp="none",MS=15e3;function BS(t){class e extends qx{constructor(i){super(i,Jf,{headers:t})}guardTeardown(){this.listenerCount("error")===0&&this.on("error",i=>Oe.warn("frontier ws error during teardown (handled, prevents daemon crash)",{err:i instanceof Error?i.message:String(i)}))}close(i,o){this.guardTeardown(),super.close(i,o)}terminate(){this.guardTeardown(),super.terminate()}send(i,...o){if(Dl("debug"))try{let c;typeof i=="string"?c=Buffer.from(i,"utf8"):i instanceof Buffer?c=i:i instanceof ArrayBuffer?c=new Uint8Array(i):ArrayBuffer.isView(i)?c=new Uint8Array(i.buffer,i.byteOffset,i.byteLength):c=new Uint8Array(0);let d=Buffer.from(c.slice(0,128)).toString("hex");Oe.debug("WS raw frame out",{bytes:c.byteLength,headHex:d})}catch(c){Oe.warn("WS raw frame dump failed",{err:String(c)})}super.send(i,...o)}}return e}var as=class{constructor(e){this.opts=e}opts;fws=null;handler=null;connectHandlers=[];opened=!1;lastSendRefusedLogAt=0;sendRefusedSuppressed=0;openCount=0;async start(){if(this.fws){Oe.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:Zf,...vn(this.opts.ppeOverride)},n=BS(e),i=Xf(this.opts.urlOverride),o={url:i,ws:n,fpID:Vf,aID:po,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:np,force:!0},payloadEncoding:{encoding:rp,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},c=new NS(o),d=!1,u=null,f,x,m=new Promise((y,b)=>{f=y,x=b}),_=y=>{d||(d=!0,u&&(clearTimeout(u),u=null),y?x(y):f())};c.onopen=()=>{this.opened=!0,this.openCount+=1;let y=this.openCount===1;Oe.info("frontier opened",{url:i,remoteDeviceId:this.opts.handshake.deviceId,initial:y,openCount:this.openCount}),y&&_();for(let b of this.connectHandlers)Promise.resolve(b({initial:y})).catch(I=>Oe.warn("onConnect handler threw (ignored)",{err:String(I)}))},c.onclose=y=>{this.opened=!1,Oe.info("frontier closed",{code:y.code,reason:y.reason,willReconnect:y.willReconnect})},c.onerror=y=>{Oe.warn("frontier error",{code:y.code,msg:y.message}),_(new k("UPSTREAM_DISCONNECTED",`frontier connect error before open: code=${y.code} msg=${y.message??""}`))},c.onmessage=y=>this.handleMessage(y),this.fws=c;let v=this.opts.openTimeoutMs??MS;u=setTimeout(()=>{_(new k("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${v}ms (handshake or upgrade slow)`))},v),await c.connect();try{await m}catch(y){try{c.close(1e3,"open failed")}catch(b){Oe.warn("fws close during start failure threw (ignored)",{err:String(b)})}throw this.fws=null,this.opened=!1,y}}async stop(e){let n=this.fws;if(n){this.fws=null,this.opened=!1;try{n.close(1e3,e??"bridge shutdown")}catch(i){Oe.warn("frontier close threw (ignored)",{err:String(i)})}}}async send(e){let n=this.fws,i=e.method;if(!n)throw Oe.warn("frontier send refused: upstream not started",{method:i}),new k("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected()){let u=Date.now();throw u-this.lastSendRefusedLogAt>1e3?(Oe.warn("frontier send refused: ws not open",{method:i,opened:this.opened,readyState:n.readyState,...this.sendRefusedSuppressed>0?{suppressedSinceLast:this.sendRefusedSuppressed}:{}}),this.lastSendRefusedLogAt=u,this.sendRefusedSuppressed=0):this.sendRefusedSuppressed+=1,new k("UPSTREAM_DISCONNECTED",`frontier ws not open (opened=${this.opened}, readyState=${n.readyState}); refusing to silently buffer`)}this.injectAgentPatToken(e);let o=JSON.stringify(e),c=e;ip(c)||Oe.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:o.length});try{await n.send(o,{service:33555712,method:1,payloadType:np,payloadEncoding:rp})}catch(u){throw Oe.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(u)}),new k("UPSTREAM_DISCONNECTED",`frontier send failed: ${String(u)}`,{cause:u})}}onFrame(e){this.handler=e}onConnect(e){this.connectHandlers.push(e)}isConnected(){return this.opened&&this.fws?.readyState===1}injectAgentPatToken(e){let n=this.opts.getPatTokenForAgent;if(!n)return;let i=e.params?._meta;if(!i?.cozeAgentId)return;let o=n(i.cozeAgentId);o&&(i.cozePatToken=o)}handleMessage(e){let n=e.message?.service;if(n!==33555712){Oe.debug("drop non-adapter frontier frame",{service:n});return}let i=US(e);if(!i){Oe.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){Oe.debug("frame received but no onFrame handler",{size:i.length});return}let o;try{o=JSON.parse(i)}catch(d){Oe.warn("frontier message JSON parse failed",{err:String(d),head:i.slice(0,80)});return}let c=o;ip(c)||Oe.info("frontier frame in",{logid:zS(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:c.id,method:c.method,body:FS(i)}),Promise.resolve(this.handler(o)).catch(d=>Oe.warn("frontier frame handler threw",{err:String(d)}))}};function ip(t){return t.method==="_agent/health"?!0:typeof t.id=="string"&&t.id.startsWith("agent.health_")}var sp=2e3;function FS(t){return t.length<=sp?t:`${t.slice(0,sp)}...<truncated, total ${t.length} chars>`}function zS(t){return t?t.high===0?String(t.low>>>0):`${t.high.toString(16)}${(t.low>>>0).toString(16).padStart(8,"0")}`:""}function US(t){let e=t.message;if(e?.textPayload)return e.textPayload;let n=e?.payload;if(!n)return null;try{return Buffer.from(n).toString("utf8")}catch{return null}}$e();ne();var Wd=q("skill-publish"),GS="/api/marketplace/product/skill/publish_with_assets",HS=15e4;async function op(t,e={}){let i=`${Rr(Cr(e.handshakeBase))}${GS}`,o=e.timeoutMs??HS,c=new FormData;c.append("skill_id",t.skillId??""),c.append("skill_name",t.skillName),c.append("skill_description",t.description??""),c.append("agent_id",t.agentId),c.append("zip_file",new Blob([t.zip],{type:"application/zip"}),"skill.zip");let d={Authorization:`Bearer ${t.patToken}`,Accept:"application/json","x-coze-version":"3.0",...vn(e.ppeOverride),...t.accountId&&t.accountId!=="0"?{"x-coze-account":t.accountId}:{}},u=new AbortController,f=setTimeout(()=>u.abort(),o);Wd.info("skill publish start",{url:i,method:"POST",form:{skill_id:t.skillId??"",skill_name:t.skillName,skill_description:t.description??"",agent_id:t.agentId,zip_file_bytes:t.zip.length},headers:{...d,Authorization:`Bearer ${t.patToken.slice(0,8)}...`}});try{let x=await fetch(i,{method:"POST",headers:d,body:c,signal:u.signal}),m=x.headers.get("x-tt-logid")??"";if(!x.ok){let y=await x.text().catch(()=>"");throw new k("UPLOAD_FAILED",`skill publish HTTP ${x.status} logid=${m}: ${y.slice(0,200)}`)}let _=await x.json();if(Wd.info("skill publish response",{logid:m,httpStatus:x.status,code:_.code,msg:_.msg,dataSkillId:_.data?.skill_id??"",dataVersion:_.data?.version??""}),_.code!==void 0&&_.code!==0)throw new k("UPLOAD_FAILED",`skill publish code=${_.code} msg=${_.msg??"-"} logid=${m}`);let v={};return _.data?.skill_id!==void 0&&_.data.skill_id!==""&&(v.skillId=String(_.data.skill_id)),_.data?.version&&(v.version=_.data.version),Wd.info("skill publish ok",{logid:m,skillId:v.skillId??"",version:v.version??""}),v}catch(x){throw x instanceof k?x:x.name==="AbortError"?new k("UPLOAD_FAILED",`skill publish timeout (${o}ms): ${t.skillName}`):new k("UPLOAD_FAILED",String(x),{cause:x})}finally{clearTimeout(f)}}ne();var Kd=q("upstream.switchable"),oa=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,n){if(this.inner===e)return;Kd.info("swap upstream",{reason:n});let i=this.inner;if(this.inner=e,this.handler&&e.onFrame(this.handler),e.onConnect)for(let o of this.connectHandlers)e.onConnect(o);try{await e.start()}catch(o){throw Kd.error("swap target start failed, reverting",{err:String(o)}),this.inner=i,o}await i.stop(n??"swapped").catch(o=>Kd.warn("previous upstream stop threw (ignored)",{err:String(o)}))}current(){return this.inner}start(){return this.inner.start()}stop(e){return this.inner.stop(e)}send(e){return this.inner.send(e)}onFrame(e){this.handler=e,this.inner.onFrame(e)}onConnect(e){this.connectHandlers.push(e),this.inner.onConnect?.(e)}isConnected(){return this.inner.isConnected()}};ne();var $d=q("upstream"),Vr=class{handler=null;async start(){$d.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){$d.info("NoopUpstream stopped",{reason:e})}async send(e){$d.debug("NoopUpstream.send (dropped)",{method:"method"in e?e.method:void 0})}onFrame(e){this.handler=e}isConnected(){return!1}async injectFrame(e){this.handler&&await this.handler(e)}};$e();ne();Ht();ne();Re();import{promises as qS}from"node:fs";var ap=q("pat-token-store");async function aa(t=Y()){try{let n=(await qS.readFile(t.patTokenFile,"utf8")).trim();return n.length===0?(ap.warn("pat-token exists but empty (treating as missing; likely interrupted write)",{path:t.patTokenFile}),null):n}catch(e){let n=e?.code;return n!=="ENOENT"&&ap.warn("read pat-token failed (treating as missing)",{path:t.patTokenFile,code:n,message:e.message}),null}}async function cs(t,e=Y()){if(!t)throw new Error("writePatToken: empty patToken");await ut(e.patTokenFile,t,{mode:384})}Re();Re();import{promises as ca}from"node:fs";import{join as jS}from"node:path";function WS(t,e){return`#!/bin/sh
|
|
110
110
|
exec ${JSON.stringify(e)} ${JSON.stringify(t)} "$@"
|
|
111
|
-
`}function
|
|
111
|
+
`}function KS(t,e){return`@echo off\r
|
|
112
112
|
"${e}" "${t}" %*\r
|
|
113
|
-
`}async function
|
|
113
|
+
`}async function cp(t,e=Y()){let n=e.binDir;await ca.mkdir(n,{recursive:!0});let i=jS(n,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),o=process.execPath,c=process.platform==="win32"?KS(t,o):WS(t,o);return await ca.readFile(i,"utf8").catch(()=>null)===c||(await ca.writeFile(i,c,"utf8"),process.platform!=="win32"&&await ca.chmod(i,493)),n}ne();Re();import{execSync as dp}from"node:child_process";import{readFileSync as lp,unlinkSync as $S}from"node:fs";import{mkdir as VS,open as JS,readFile as up,unlink as Vd,writeFile as ZS}from"node:fs/promises";import{dirname as YS}from"node:path";var XS=q("single-instance"),QS=t=>new Promise(e=>setTimeout(e,t)),da=class{pidFile;selfPid;probe;claimLockMaxAttempts;claimLockIntervalMs;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??Y().pidFile,this.selfPid=e.selfPid??process.pid,this.claimLockMaxAttempts=e.claimLockMaxAttempts??50,this.claimLockIntervalMs=e.claimLockIntervalMs??20,this.probe=e.probe??{isAlive:n=>Ki(n),isDaemon:n=>this.matchesDaemonTitle(n)},e.processTitle&&(process.title=e.processTitle)}async acquire(){let e=await this.readExistingPid();if(e!==null&&e!==this.selfPid&&this.isLiveDaemon(e))return{kind:"already-running",pid:e};let n=await this.withClaimLock(async()=>{let i=await this.readExistingPid();return i!==null&&i!==this.selfPid&&this.isLiveDaemon(i)?{kind:"already-running",pid:i}:(i!==null&&i!==this.selfPid&&XS.warn("removing stale pid file",{stalePid:i}),await ZS(this.pidFile,String(this.selfPid),"utf8"),{kind:"acquired"})});return n.kind==="acquired"&&(this.acquired=!0,this.installCleanupHooks()),n}async release(){if(this.acquired){try{(await up(this.pidFile,"utf8")).trim()===String(this.selfPid)&&await Vd(this.pidFile)}catch{}this.acquired=!1}}isLiveDaemon(e){return this.probe.isAlive(e)&&this.probe.isDaemon(e)}async readExistingPid(){return this.readPidFrom(this.pidFile)}async readPidFrom(e){try{let n=await up(e,"utf8"),i=Number.parseInt(n.trim(),10);return Number.isFinite(i)&&i>0?i:null}catch(n){if(n.code==="ENOENT")return null;throw n}}async withClaimLock(e){let n=`${this.pidFile}.lock`;await VS(YS(n),{recursive:!0});for(let i=0;i<this.claimLockMaxAttempts;i++){let o;try{o=await JS(n,"wx")}catch(c){if(c.code!=="EEXIST")throw c;let d=await this.readPidFrom(n);if(d!==null&&d!==this.selfPid&&this.probe.isAlive(d)){await QS(this.claimLockIntervalMs);continue}await Vd(n).catch(()=>{});continue}try{return await o.writeFile(String(this.selfPid)),await e()}finally{await o.close().catch(()=>{}),await Vd(n).catch(()=>{})}}throw new Error(`failed to acquire claim lock: ${n} (after ${this.claimLockMaxAttempts} attempts)`)}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let n=lp(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(n.includes(Br)||n.includes("lib/index.js"))}catch{}try{let n=dp(`ps -o command= -p ${e}`,{stdio:["ignore","pipe","ignore"],timeout:1e3}).toString();return n.trim()?n.includes(Br)||n.includes("lib/index.js"):!1}catch{return!0}}matchesDaemonTitleWindows(e){try{let i=dp(`tasklist /FI "PID eq ${e}" /FO CSV /NH`,{stdio:["ignore","pipe","ignore"],timeout:2e3}).toString().trim();if(!i||/^(INFO|信息)[::]/.test(i))return!1;let o=i.split(",",1)[0]?.replace(/^"|"$/g,"").toLowerCase()??"";return o.includes("node")||o.includes("coze-bridge")}catch{return!0}}installCleanupHooks(){process.once("exit",()=>{if(this.acquired)try{lp(this.pidFile,"utf8").trim()===String(this.selfPid)&&$S(this.pidFile)}catch{}})}};la();ne();var tr=q("daemon.upstream-watchdog"),aI=12e4,cI=9e5,dI=3e4;function Zd(t,e){let n=process.env[t];if(!n)return e;let i=Number(n);return Number.isFinite(i)&&i>0?i:e}var ua=class{constructor(e){this.opts=e;this.softMs=e.softMs??Zd("COZE_BRIDGE_UPSTREAM_WATCHDOG_SOFT_MS",aI),this.hardMs=e.hardMs??Zd("COZE_BRIDGE_UPSTREAM_WATCHDOG_HARD_MS",cI),this.intervalMs=e.intervalMs??Zd("COZE_BRIDGE_UPSTREAM_WATCHDOG_INTERVAL_MS",dI),this.now=e.now??Date.now}opts;softMs;hardMs;intervalMs;now;timer=null;downSince=null;forcedAt=null;forcing=!1;lastTickAt=null;start(){this.timer||(this.timer=setInterval(()=>this.tick(),this.intervalMs),this.timer.unref?.(),tr.info("upstream watchdog started",{softMs:this.softMs,hardMs:this.hardMs,intervalMs:this.intervalMs}))}stop(){this.timer&&(clearInterval(this.timer),this.timer=null),this.downSince=null,this.forcedAt=null,this.lastTickAt=null}tick(){let e=this.now();if(this.lastTickAt!==null&&e-this.lastTickAt>this.intervalMs*3&&(this.downSince!==null&&tr.warn("upstream watchdog: large tick gap (likely sleep/suspend), resetting downSince",{gapMs:e-this.lastTickAt}),this.downSince=null,this.forcedAt=null),this.lastTickAt=e,this.opts.isConnected()){this.downSince!==null&&tr.info("upstream watchdog: reconnected, reset",{downMs:this.now()-this.downSince}),this.downSince=null,this.forcedAt=null;return}if(this.downSince===null){this.downSince=e,tr.warn("upstream watchdog: disconnect detected, arming",{softMs:this.softMs,hardMs:this.hardMs});return}let n=e-this.downSince;if(n>=this.hardMs){tr.error("upstream watchdog: disconnected too long, exiting for supervisor restart",{downMs:n,hardMs:this.hardMs}),this.opts.onFatal(n);return}n>=this.softMs&&this.shouldForceNow(e)&&(this.forcedAt=e,this.forcing=!0,tr.warn("upstream watchdog: forcing reconnect",{downMs:n,softMs:this.softMs}),Promise.resolve().then(()=>this.opts.forceReconnect()).catch(i=>tr.warn("upstream watchdog: forceReconnect error (ignored)",{err:String(i)})).finally(()=>{this.forcing=!1}))}shouldForceNow(e){return!(this.forcing||this.forcedAt!==null&&e-this.forcedAt<this.softMs)}};var K=q("daemon");async function xp(){let t=Y();if(process.env.COZE_BRIDGE_LOG_MODE!=="legacy"){Rl({bridgeLogsDir:t.bridgeLogsDir,agentLogsDir:R=>ze(R,t).logs,listAgentIds:()=>ys(t)});try{let{writeFileSync:R}=await import("node:fs");R(t.logFile,`\u8FD0\u884C\u65E5\u5FD7\u5DF2\u8FC1\u79FB\u5230 dated \u6587\u4EF6, \u6B64\u6587\u4EF6 (bridge.log) \u4E0D\u518D\u5199\u5165\u8FD0\u884C\u65E5\u5FD7\u3002
|
|
114
114
|
\u8BF7\u67E5\u770B: ${t.bridgeLogsDir}/bridge-<YYYY-MM-DD>.log
|
|
115
115
|
\u6216\u4F7F\u7528: coze-bridge log [-f] [--lines N]
|
|
116
|
-
`)}catch{}}let e=new la({processTitle:Br}),r=await e.acquire();if(r.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${r.pid})`);let i=await Bo(),o=i??{};ws({pid:process.pid}),q.info(i?"loaded bridge config":"initialized bridge config");let c=new aa(new Yr),d=null,u=new Fo({upstream:c,paths:t,bridgeConfig:o,sessionSpawner:async(C,z,H,ee)=>{if(!d)throw new Error("agentManager not ready");return d.spawnSessionDownstream(C,z,H,ee)}}),f=new Lo({paths:t,config:o,registry:u});d=f;let x,g,w=null,S={},y,v=null,I=null,A=null,R=new An;function D(C,z){return R.enqueue(()=>P(C,z))}function b(){I||(I=new fa({isConnected:()=>c.isConnected()&&!(v?.isLivenessLost()??!1),forceReconnect:()=>A?D(A,{force:!0}):void 0,onFatal:C=>{if(process.env[cs]==="1"){q.error("upstream watchdog fatal, but daemon is unmanaged (CLI-spawned) \u2014 staying alive for soft-reconnect instead of exiting",{downMs:C});return}q.error("upstream watchdog fatal: exiting for supervisor restart",{downMs:C}),process.exit(1)}})),I.start()}async function P(C,z){let H=C,ee=H?.privatecode;if(!ee)throw new k("IPC_BAD_REQUEST","/connect requires privatecode");let Ye=Fi(H.env),xe=H.handshake_url,pe=H.frontier_url,kt=xp(H.env,xe,pe);if(A=H,!z?.force&&x===ee&&g===kt){let we=await d1(t);return u.agents.size===0&&we?(q.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),xa(t,f).catch(ke=>q.warn("connect-noop auto-revive error (ignored)",{err:String(ke)}))):q.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let wt=!!x&&x!==ee,sn=g!==void 0&&g!==kt,Gt=wt||sn,on=await Qc({privatecode:ee,...xe?{endpoint:xe}:{},ppeOverride:Ye});if(Gt){q.warn("connect config switched, resetting agents",{pcChanged:wt,envChanged:sn,previousPc:x?ha(x):"",nextPc:ha(ee)});for(let we of[...u.agents.values()])await we.dispose("connect config switch").catch(()=>{}),u.agents.delete(we.agentId);u.disconnectedAgents.size>0&&(q.info("clearing disconnectedAgents set on connect config switch",{count:u.disconnectedAgents.size}),u.disconnectedAgents.clear()),await c.swap(new Yr,"connect switch").catch(()=>{})}w=on.deviceId,ws({deviceId:w,pid:process.pid}),bd({patToken:ee,env:H.env}).catch(we=>q.warn("coze-cli setup error (ignored)",{err:String(we)}));let Qr=new os({handshake:on,privatecode:ee,...pe?{urlOverride:pe}:{},ppeOverride:Ye,getPatTokenForAgent:we=>u.agents.get(we)?.patToken});return await c.swap(Qr,"connect"),x=ee,g=kt,S=Ye,y=xe,H.mock_scenario!==void 0&&(u.setMockScenario(H.mock_scenario),q.info("mock scenario set",{scenario:H.mock_scenario})),v||(v=new Gi({core:u,getDeviceId:()=>w??"",onTickEnd:()=>M.retryPending().catch(we=>q.warn("detailSync.retryPending failed (ignored)",{err:String(we)})),onAuthFailures:V})),v.start(),b(),Gt&&xa(t,f).catch(we=>q.warn("post-connect-switch auto-revive error (ignored)",{err:String(we)})),as(ee,t).catch(we=>q.warn("writePatToken after /connect failed (ignored)",{err:String(we)})),q.info("/connect: WS established",{deviceId:w}),{ok:!0,note:"connected"}}u.registerExtension("_agent/create",async C=>f.createAgent(C.params)),u.registerExtension("_agent/health",async()=>({ok:!0}));let O={},B=new Eo({agents:u.agents,paths:t,publishSkillToMarketplace:async C=>{let z=u.agents.get(C.agentId)?.patToken??x;if(!z)throw new k("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");return ap({patToken:z,zip:C.zip,...C.skillId?{skillId:C.skillId}:{},skillName:C.skillName,...C.description?{description:C.description}:{},agentId:C.agentId,...C.accountId?{accountId:C.accountId}:{}},{handshakeBase:y,ppeOverride:S})},disposeAndMarkDisconnected:async(C,z)=>{let H=u.agents.get(C);if(H){await f.cleanupOpenclawSessionProviders(H).catch(Ye=>q.warn("cleanup openclaw providers failed (ignored)",{agentId:C,err:String(Ye)})),H.framework==="hermes"&&H.deployType==="cloud"&&await sd(C,t).catch(Ye=>q.warn("cleanup hermes-home failed (ignored)",{agentId:C,err:String(Ye)}));let ee=!0;try{await H.dispose(`disconnect: ${z}`)}catch(Ye){ee=!1,q.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:C,err:String(Ye)}),H.status="error"}ee&&(H.status="disconnected",u.unregister(C),u.disconnectedAgents.add(C))}else u.disconnectedAgents.add(C)},disposeForDelete:async(C,z)=>{let H=u.agents.get(C);H&&(await f.cleanupOpenclawSessionProviders(H).catch(ee=>q.warn("cleanup openclaw providers during delete failed (ignored)",{agentId:C,err:String(ee)})),H.framework==="hermes"&&H.deployType==="cloud"&&await sd(C,t).catch(ee=>q.warn("cleanup hermes-home during delete failed (ignored)",{agentId:C,err:String(ee)})),await H.dispose(`delete: ${z}`).catch(ee=>q.warn("dispose during delete failed (ignored)",{agentId:C,err:String(ee)})),u.unregister(C)),u.disconnectedAgents.delete(C)},detailSyncer:async C=>{if(!O.ref)throw new Error("agent-detail-sync not initialized yet");await O.ref.syncOne(C)},cleanupOpenclawProviders:async(C,z)=>{await f.cleanupOpenclawSessionProviders(C,z)},openclawRepair:async(C,z)=>{await f.openclawRepair(C,z)},hermesReset:async(C,z)=>{let H=await ve(C).catch(()=>null);!H||H.framework!=="hermes"||H.deployType!=="cloud"||await f0({paths:t,agentId:C,model:H.model,modelInfo:H.modelInfo,cozeEnv:z,mockScenario:u.getMockScenario()})},isRuntimePendingPermission:C=>u.hasPendingPermissionFor(C)});u.registerExtension("_agent/listSkills",C=>B.listSkills(C.params)),u.registerExtension("_agent/addSkills",C=>B.addSkills(C.params)),u.registerExtension("_agent/removeSkills",C=>B.removeSkills(C.params)),u.registerExtension("_agent/publishSkill",C=>B.publishSkill(C.params)),u.registerExtension("_agent/getFileTree",C=>B.getFileTree(C.params)),u.registerExtension("_agent/getFileContent",C=>B.getFileContent(C.params)),u.registerExtension("_agent/update",C=>B.updateAgent(C.params)),u.registerExtension("_agent/disconnect",C=>B.disconnectAgent(C.params)),u.registerExtension("_agent/switchModel",C=>B.switchModel(C.params)),u.registerExtension("_agent/reset",C=>B.resetAgent(C.params)),u.registerExtension("_agent/repair",C=>B.repairAgent(C.params)),u.registerExtension("_agent/delete",C=>B.deleteAgent(C.params)),u.registerExtension("_agent/upgrade",C=>B.upgradeBridge(C.params));let M=new Ss({paths:t,handlers:B,agentManager:f,sendDetail:C=>u.sendRequest("_agent/detail",C)});O.ref=M;let V=async C=>{await Promise.allSettled(C.map(async z=>{try{await B.disconnectAgent({agentId:z.agentId,reason:`auth_failure: code=${z.code} ${z.message}`}),q.info("agent disconnected due to auth failure from heartbeat response",{agentId:z.agentId,code:z.code,message:z.message})}catch(H){q.warn("disconnect during authFailure handling failed (ignored)",{agentId:z.agentId,err:String(H)})}}))};c.onConnect(({initial:C})=>{q.info("frontier upstream connected, triggering detail sync",{initial:C}),M.syncAll(C?"initial-connect":"reconnect").catch(z=>q.warn("detail sync top-level error (ignored)",{err:String(z)}))});let K=new zo({paths:t,routes:[{method:"GET",path:"/status",handler:async()=>{let C=u.getMockScenario();return{running:!0,pid:process.pid,nodeExecPath:process.execPath,nodeVersion:process.version,nodeArch:process.arch,spawnedBy:process.env[cs]==="1"?"manual":"supervisor",agents:[...u.agents.keys()],deviceId:w??"",frameworksCache:o.frameworksCache??{},...C?{mockScenario:C}:{}}}},{method:"POST",path:"/pair",handler:async C=>{let z=C,H=z?.privatecode,ee=z?.pairing_code;if(!H||!ee)throw new k("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let Ye=Fi(z.env),xe=z.handshake_url,pe=z.frontier_url,kt=xp(z.env,xe,pe),wt=!!x&&x!==H,sn=g!==void 0&&g!==kt,Gt=wt||sn,on=await Qc({privatecode:H,...xe?{endpoint:xe}:{},ppeOverride:Ye});if(Gt){q.warn("pair config switched, resetting agents",{pcChanged:wt,envChanged:sn,previousPc:x?ha(x):"",nextPc:ha(H),previousEnvKey:g??"",nextEnvKey:kt});for(let ke of[...u.agents.values()])await ke.dispose("pair config switch").catch(()=>{}),u.agents.delete(ke.agentId);u.disconnectedAgents.size>0&&(q.info("clearing disconnectedAgents set on pair config switch",{count:u.disconnectedAgents.size}),u.disconnectedAgents.clear()),await c.swap(new Yr,"pair switch").catch(()=>{})}w=on.deviceId,ws({deviceId:w,pid:process.pid}),bd({patToken:H,env:z.env}).catch(ke=>q.warn("coze-cli setup error (ignored)",{err:String(ke)}));let Qr=new os({handshake:on,privatecode:H,...pe?{urlOverride:pe}:{},ppeOverride:Ye,getPatTokenForAgent:ke=>u.agents.get(ke)?.patToken});await c.swap(Qr,"pair");try{let ke=new Vn;o.frameworksCache=await ke.detectAll(),await Vi(o),q.info("frameworks_cache refreshed before pair",{detected:Object.keys(o.frameworksCache)})}catch(ke){q.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(ke)})}let we=Object.keys(o.frameworksCache??{});try{let ke=await u.sendRequest("_agent/pair",{pairCode:ee,patToken:H,frameworks:we,_meta:{cozeDeviceId:w}});q.info("_agent/pair ok",{pairResult:ke}),x=H,g=kt,S=Ye,y=xe,z.mock_scenario!==void 0&&(u.setMockScenario(z.mock_scenario),q.info("mock scenario set",{scenario:z.mock_scenario})),as(H,t).catch(Le=>q.warn("writePatToken after /pair failed (ignored)",{err:String(Le)})),v||(v=new Gi({core:u,getDeviceId:()=>w??"",onTickEnd:()=>M.retryPending().catch(Le=>q.warn("detailSync.retryPending failed (ignored)",{err:String(Le)})),onAuthFailures:V})),v.start(),b(),Gt&&xa(t,f).catch(Le=>q.warn("post-pair-switch auto-revive error (ignored)",{err:String(Le)}));let nr;return z.agent_id&&(nr=await u1(z.agent_id,t,f,Le=>u.sendRequest("_agent/detail",Le),H).catch(Le=>(q.error("--agent-id ensureAgent failed",{agentId:z.agent_id,err:String(Le)}),{ok:!1,agentId:z.agent_id??"",note:String(Le)}))),{ok:!0,note:"paired with cloud",...nr?{agent:nr}:{}}}catch(ke){return q.error("_agent/pair failed",{err:String(ke)}),{ok:!1,note:`pair failed: ${String(ke)}`}}}},{method:"POST",path:"/connect",handler:C=>D(C)},{method:"POST",path:"/_agent/create",handler:async C=>{let z=C;return{ok:!0,result:await f.createAgent(z)}}},{method:"POST",path:"/agent/send",handler:async C=>{let z=C;if(!z?.agentId||!z?.sessionId||!z?.kind||!z?.path)throw new k("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!x)throw new k("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{let H=z;return await(H.groupFile?Eh:yh)(H,{core:u,patToken:x,handshakeBase:y,ppeOverride:S})}catch(H){if(H instanceof k)return{ok:!1,code:H.code,message:H.message};throw H}}},{method:"POST",path:"/reload",handler:async C=>{let z=C?.agent_id,H=await u.reloadAgents(z);return q.info("IPC /reload: recycled agent subprocesses",{agentId:z??"(all)",recycled:H}),{ok:!0,recycled:H}}},{method:"POST",path:"/shutdown",handler:async()=>(q.info("IPC /shutdown received"),setImmediate(()=>{oe.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:re,token:X}=await K.start();try{await dp(t.libEntry,t)}catch(C){q.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(C)})}await u.start(),f1({paths:t,core:u,agentManager:f,detectAll:async()=>(o.frameworksCache=await new Vn().detectAll(),await Vi(o),o.frameworksCache)}).catch(C=>q.warn("startup warmup error (ignored)",{err:String(C)})),Gl().then(async()=>{let{probeAcpVersion:C}=await Promise.resolve().then(()=>(dn(),zl));for(let z of["claude-code","codex"]){let H=await C(z);H&&q.info("acp wrapper version",{framework:z,version:H})}}).catch(C=>q.warn("acp wrapper warmup / probe top-level error (ignored)",{err:String(C)}));let se=null,oe={port:re,token:X,core:u,ipc:K,shutdown(C){return se||(q.info("daemon shutdown",{reason:C}),se=(async()=>{v?.stop(),I?.stop(),await u.stop(C),await K.stop(),await e.release()})(),se)}};for(let C of["SIGTERM","SIGINT"])process.on(C,()=>{oe.shutdown(C).then(()=>process.exit(0))});return process.on("exit",()=>U0()),process.on("unhandledRejection",C=>{q.error("unhandledRejection",{reason:C instanceof Error?C.message:String(C),stack:C instanceof Error?C.stack:void 0})}),process.on("uncaughtException",C=>{q.error("uncaughtException (will exit, supervisor will restart)",{message:C.message,stack:C.stack,name:C.name});try{process.stderr.write(`FATAL uncaughtException: ${C.stack??C.message}
|
|
117
|
-
`)}catch{}process.exit(1)}),
|
|
118
|
-
`)){let u=d.indexOf("=");u<=0||(c[d.slice(0,u)]=d.slice(u+1))}return c}function
|
|
119
|
-
`;await
|
|
120
|
-
`).filter(d=>d.length>0).filter(d=>
|
|
121
|
-
`)}async function
|
|
116
|
+
`)}catch{}}let e=new da({processTitle:Br}),n=await e.acquire();if(n.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${n.pid})`);let i=await Mo(),o=i??{};ms({pid:process.pid}),K.info(i?"loaded bridge config":"initialized bridge config");let c=new oa(new Vr),d=null,u=new Bo({upstream:c,paths:t,bridgeConfig:o,sessionSpawner:async(R,z,j,te)=>{if(!d)throw new Error("agentManager not ready");return d.spawnSessionDownstream(R,z,j,te)}}),f=new Oo({paths:t,config:o,registry:u});d=f;let x,m,_=null,v={},y,b=null,I=null,A=null,P=new An;function D(R,z){return P.enqueue(()=>C(R,z))}function E(){I||(I=new ua({isConnected:()=>c.isConnected()&&!(b?.isLivenessLost()??!1),forceReconnect:()=>A?D(A,{force:!0}):void 0,onFatal:R=>{if(process.env[ds]==="1"){K.error("upstream watchdog fatal, but daemon is unmanaged (CLI-spawned) \u2014 staying alive for soft-reconnect instead of exiting",{downMs:R});return}K.error("upstream watchdog fatal: exiting for supervisor restart",{downMs:R}),process.exit(1)}})),I.start()}async function C(R,z){let j=R,te=j?.privatecode;if(!te)throw new k("IPC_BAD_REQUEST","/connect requires privatecode");let Je=zi(j.env),ge=j.handshake_url,me=j.frontier_url,kt=hp(j.env,ge,me);if(A=j,!z?.force&&x===te&&m===kt){let ye=await lI(t);return u.agents.size===0&&ye?(K.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),ha(t,f).catch(Te=>K.warn("connect-noop auto-revive error (ignored)",{err:String(Te)}))):K.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let wt=!!x&&x!==te,rn=m!==void 0&&m!==kt,Ut=wt||rn,sn=await Yc({privatecode:te,...ge?{endpoint:ge}:{},ppeOverride:Je});if(Ut){K.warn("connect config switched, resetting agents",{pcChanged:wt,envChanged:rn,previousPc:x?fa(x):"",nextPc:fa(te)});for(let ye of[...u.agents.values()])await ye.dispose("connect config switch").catch(()=>{}),u.agents.delete(ye.agentId);u.disconnectedAgents.size>0&&(K.info("clearing disconnectedAgents set on connect config switch",{count:u.disconnectedAgents.size}),u.disconnectedAgents.clear()),await c.swap(new Vr,"connect switch").catch(()=>{})}_=sn.deviceId,ms({deviceId:_,pid:process.pid}),yd({patToken:te,env:j.env}).catch(ye=>K.warn("coze-cli setup error (ignored)",{err:String(ye)}));let Qr=new as({handshake:sn,privatecode:te,...me?{urlOverride:me}:{},ppeOverride:Je,getPatTokenForAgent:ye=>u.agents.get(ye)?.patToken});return await c.swap(Qr,"connect"),x=te,m=kt,v=Je,y=ge,j.mock_scenario!==void 0&&(u.setMockScenario(j.mock_scenario),K.info("mock scenario set",{scenario:j.mock_scenario})),b||(b=new Hi({core:u,getDeviceId:()=>_??"",onTickEnd:()=>B.retryPending().catch(ye=>K.warn("detailSync.retryPending failed (ignored)",{err:String(ye)})),onAuthFailures:Z})),b.start(),E(),Ut&&ha(t,f).catch(ye=>K.warn("post-connect-switch auto-revive error (ignored)",{err:String(ye)})),cs(te,t).catch(ye=>K.warn("writePatToken after /connect failed (ignored)",{err:String(ye)})),K.info("/connect: WS established",{deviceId:_}),{ok:!0,note:"connected"}}u.registerExtension("_agent/create",async R=>f.createAgent(R.params)),u.registerExtension("_agent/health",async()=>({ok:!0}));let L={},F=new yo({agents:u.agents,paths:t,publishSkillToMarketplace:async R=>{let z=u.agents.get(R.agentId)?.patToken??x;if(!z)throw new k("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");return op({patToken:z,zip:R.zip,...R.skillId?{skillId:R.skillId}:{},skillName:R.skillName,...R.description?{description:R.description}:{},agentId:R.agentId,...R.accountId?{accountId:R.accountId}:{}},{handshakeBase:y,ppeOverride:v})},disposeAndMarkDisconnected:async(R,z)=>{let j=u.agents.get(R);if(j){await f.cleanupOpenclawSessionProviders(j).catch(Je=>K.warn("cleanup openclaw providers failed (ignored)",{agentId:R,err:String(Je)})),j.framework==="hermes"&&j.deployType==="cloud"&&await rd(R,t).catch(Je=>K.warn("cleanup hermes-home failed (ignored)",{agentId:R,err:String(Je)}));let te=!0;try{await j.dispose(`disconnect: ${z}`)}catch(Je){te=!1,K.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:R,err:String(Je)}),j.status="error"}te&&(j.status="disconnected",u.unregister(R),u.disconnectedAgents.add(R))}else u.disconnectedAgents.add(R)},disposeForDelete:async(R,z)=>{let j=u.agents.get(R);j&&(await f.cleanupOpenclawSessionProviders(j).catch(te=>K.warn("cleanup openclaw providers during delete failed (ignored)",{agentId:R,err:String(te)})),j.framework==="hermes"&&j.deployType==="cloud"&&await rd(R,t).catch(te=>K.warn("cleanup hermes-home during delete failed (ignored)",{agentId:R,err:String(te)})),await j.dispose(`delete: ${z}`).catch(te=>K.warn("dispose during delete failed (ignored)",{agentId:R,err:String(te)})),u.unregister(R)),u.disconnectedAgents.delete(R)},detailSyncer:async R=>{if(!L.ref)throw new Error("agent-detail-sync not initialized yet");await L.ref.syncOne(R)},cleanupOpenclawProviders:async(R,z)=>{await f.cleanupOpenclawSessionProviders(R,z)},openclawRepair:async(R,z)=>{await f.openclawRepair(R,z)},hermesReset:async(R,z)=>{let j=await Se(R).catch(()=>null);!j||j.framework!=="hermes"||j.deployType!=="cloud"||await u0({paths:t,agentId:R,model:j.model,modelInfo:j.modelInfo,cozeEnv:z,mockScenario:u.getMockScenario()})},isRuntimePendingPermission:R=>u.hasPendingPermissionFor(R)});u.registerExtension("_agent/listSkills",R=>F.listSkills(R.params)),u.registerExtension("_agent/addSkills",R=>F.addSkills(R.params)),u.registerExtension("_agent/removeSkills",R=>F.removeSkills(R.params)),u.registerExtension("_agent/publishSkill",R=>F.publishSkill(R.params)),u.registerExtension("_agent/getFileTree",R=>F.getFileTree(R.params)),u.registerExtension("_agent/getFileContent",R=>F.getFileContent(R.params)),u.registerExtension("_agent/update",R=>F.updateAgent(R.params)),u.registerExtension("_agent/disconnect",R=>F.disconnectAgent(R.params)),u.registerExtension("_agent/switchModel",R=>F.switchModel(R.params)),u.registerExtension("_agent/reset",R=>F.resetAgent(R.params)),u.registerExtension("_agent/repair",R=>F.repairAgent(R.params)),u.registerExtension("_agent/delete",R=>F.deleteAgent(R.params)),u.registerExtension("_agent/upgrade",R=>F.upgradeBridge(R.params));let B=new vs({paths:t,handlers:F,agentManager:f,sendDetail:R=>u.sendRequest("_agent/detail",R)});L.ref=B;let Z=async R=>{await Promise.allSettled(R.map(async z=>{try{await F.disconnectAgent({agentId:z.agentId,reason:`auth_failure: code=${z.code} ${z.message}`}),K.info("agent disconnected due to auth failure from heartbeat response",{agentId:z.agentId,code:z.code,message:z.message})}catch(j){K.warn("disconnect during authFailure handling failed (ignored)",{agentId:z.agentId,err:String(j)})}}))};c.onConnect(({initial:R})=>{K.info("frontier upstream connected, triggering detail sync",{initial:R}),B.syncAll(R?"initial-connect":"reconnect").catch(z=>K.warn("detail sync top-level error (ignored)",{err:String(z)}))});let J=new Fo({paths:t,routes:[{method:"GET",path:"/status",handler:async()=>{let R=u.getMockScenario();return{running:!0,pid:process.pid,nodeExecPath:process.execPath,nodeVersion:process.version,nodeArch:process.arch,spawnedBy:process.env[ds]==="1"?"manual":"supervisor",agents:[...u.agents.keys()],deviceId:_??"",frameworksCache:o.frameworksCache??{},...R?{mockScenario:R}:{}}}},{method:"POST",path:"/pair",handler:async R=>{let z=R,j=z?.privatecode,te=z?.pairing_code;if(!j||!te)throw new k("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let Je=zi(z.env),ge=z.handshake_url,me=z.frontier_url,kt=hp(z.env,ge,me),wt=!!x&&x!==j,rn=m!==void 0&&m!==kt,Ut=wt||rn,sn=await Yc({privatecode:j,...ge?{endpoint:ge}:{},ppeOverride:Je});if(Ut){K.warn("pair config switched, resetting agents",{pcChanged:wt,envChanged:rn,previousPc:x?fa(x):"",nextPc:fa(j),previousEnvKey:m??"",nextEnvKey:kt});for(let Te of[...u.agents.values()])await Te.dispose("pair config switch").catch(()=>{}),u.agents.delete(Te.agentId);u.disconnectedAgents.size>0&&(K.info("clearing disconnectedAgents set on pair config switch",{count:u.disconnectedAgents.size}),u.disconnectedAgents.clear()),await c.swap(new Vr,"pair switch").catch(()=>{})}_=sn.deviceId,ms({deviceId:_,pid:process.pid}),yd({patToken:j,env:z.env}).catch(Te=>K.warn("coze-cli setup error (ignored)",{err:String(Te)}));let Qr=new as({handshake:sn,privatecode:j,...me?{urlOverride:me}:{},ppeOverride:Je,getPatTokenForAgent:Te=>u.agents.get(Te)?.patToken});await c.swap(Qr,"pair");try{let Te=new Jn;o.frameworksCache=await Te.detectAll(),await Zi(o),K.info("frameworks_cache refreshed before pair",{detected:Object.keys(o.frameworksCache)})}catch(Te){K.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(Te)})}let ye=Object.keys(o.frameworksCache??{});try{let Te=await u.sendRequest("_agent/pair",{pairCode:te,patToken:j,frameworks:ye,_meta:{cozeDeviceId:_}});K.info("_agent/pair ok",{pairResult:Te}),x=j,m=kt,v=Je,y=ge,z.mock_scenario!==void 0&&(u.setMockScenario(z.mock_scenario),K.info("mock scenario set",{scenario:z.mock_scenario})),cs(j,t).catch(Ne=>K.warn("writePatToken after /pair failed (ignored)",{err:String(Ne)})),b||(b=new Hi({core:u,getDeviceId:()=>_??"",onTickEnd:()=>B.retryPending().catch(Ne=>K.warn("detailSync.retryPending failed (ignored)",{err:String(Ne)})),onAuthFailures:Z})),b.start(),E(),Ut&&ha(t,f).catch(Ne=>K.warn("post-pair-switch auto-revive error (ignored)",{err:String(Ne)}));let nr;return z.agent_id&&(nr=await fI(z.agent_id,t,f,Ne=>u.sendRequest("_agent/detail",Ne),j).catch(Ne=>(K.error("--agent-id ensureAgent failed",{agentId:z.agent_id,err:String(Ne)}),{ok:!1,agentId:z.agent_id??"",note:String(Ne)}))),{ok:!0,note:"paired with cloud",...nr?{agent:nr}:{}}}catch(Te){return K.error("_agent/pair failed",{err:String(Te)}),{ok:!1,note:`pair failed: ${String(Te)}`}}}},{method:"POST",path:"/connect",handler:R=>D(R)},{method:"POST",path:"/_agent/create",handler:async R=>{let z=R;return{ok:!0,result:await f.createAgent(z)}}},{method:"POST",path:"/agent/send",handler:async R=>{let z=R;if(!z?.agentId||!z?.sessionId||!z?.kind||!z?.path)throw new k("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!x)throw new k("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{let j=z;return await(j.groupFile?yh:_h)(j,{core:u,patToken:x,handshakeBase:y,ppeOverride:v})}catch(j){if(j instanceof k)return{ok:!1,code:j.code,message:j.message};throw j}}},{method:"POST",path:"/reload",handler:async R=>{let z=R?.agent_id,j=await u.reloadAgents(z);return K.info("IPC /reload: recycled agent subprocesses",{agentId:z??"(all)",recycled:j}),{ok:!0,recycled:j}}},{method:"POST",path:"/shutdown",handler:async()=>(K.info("IPC /shutdown received"),setImmediate(()=>{ae.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:ie,token:Q}=await J.start();try{await cp(t.libEntry,t)}catch(R){K.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(R)})}await u.start(),hI({paths:t,core:u,agentManager:f,detectAll:async()=>(o.frameworksCache=await new Jn().detectAll(),await Zi(o),o.frameworksCache)}).catch(R=>K.warn("startup warmup error (ignored)",{err:String(R)})),Ul().then(async()=>{let{probeAcpVersion:R}=await Promise.resolve().then(()=>(dn(),Fl));for(let z of["claude-code","codex"]){let j=await R(z);j&&K.info("acp wrapper version",{framework:z,version:j})}}).catch(R=>K.warn("acp wrapper warmup / probe top-level error (ignored)",{err:String(R)}));let oe=null,ae={port:ie,token:Q,core:u,ipc:J,shutdown(R){return oe||(K.info("daemon shutdown",{reason:R}),oe=(async()=>{b?.stop(),I?.stop(),await u.stop(R),await J.stop(),await e.release()})(),oe)}};for(let R of["SIGTERM","SIGINT"])process.on(R,()=>{ae.shutdown(R).then(()=>process.exit(0))});return process.on("exit",()=>z0()),process.on("unhandledRejection",R=>{K.error("unhandledRejection",{reason:R instanceof Error?R.message:String(R),stack:R instanceof Error?R.stack:void 0})}),process.on("uncaughtException",R=>{K.error("uncaughtException (will exit, supervisor will restart)",{message:R.message,stack:R.stack,name:R.name});try{process.stderr.write(`FATAL uncaughtException: ${R.stack??R.message}
|
|
117
|
+
`)}catch{}process.exit(1)}),K.info("daemon ready",{port:ie,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(o.frameworksCache??{}),libVersion:o.libVersion??"dev"}),pI({cliSpawned:process.env[ds]==="1",readPatToken:()=>aa(t),connect:D}).catch(R=>K.warn("maybeAutoConnectOnStartup error (ignored)",{err:String(R)})),ae}async function lI(t){return ys(t).length>0}function fa(t){return t.length<=8?"***":`${t.slice(0,4)}***${t.slice(-4)}`}function hp(t,e,n){return`${t??""}|${e??""}|${n??""}`}async function uI(t,e){let n=ys(t);if(n.length===0)return;let{loadAgentConfig:i,enforceAgentConfigMode:o}=await Promise.resolve().then(()=>(qt(),bs));for(let c of n){await o(c,t).catch(d=>K.warn("enforceAgentConfigMode failed (ignored)",{agentId:c,err:String(d)}));try{let d=await i(c,t);d?.deletedAt?(e.disconnectedAgents.add(c),K.info("agent marked deleted on startup",{agentId:c,deletedAt:d.deletedAt,reason:d.deleteReason??""})):d?.disconnectedAt&&(e.disconnectedAgents.add(c),K.info("agent marked disconnected on startup",{agentId:c,disconnectedAt:d.disconnectedAt,reason:d.disconnectReason??""}))}catch(d){K.warn("failed to load agent config on startup, skipping",{agentId:c,err:String(d)})}}}async function fI(t,e,n,i,o){let{loadAgentConfig:c}=await Promise.resolve().then(()=>(qt(),bs)),d=await c(t,e);if(d){if(d.deletedAt)throw new k("AGENT_NOT_FOUND",`agent ${t} \u5DF2\u88AB\u5220\u9664 (deletedAt=${d.deletedAt}), \u4E0D\u80FD\u901A\u8FC7 --agent-id \u590D\u6D3B`);K.info("--agent-id: local config found, reconnecting",{agentId:t,framework:d.framework,hadDisconnect:!!d.disconnectedAt});let m=pp(d),_={agentId:d.agentId,framework:d.framework,...d.cozeIdentity?{cozeIdentity:d.cozeIdentity}:{},...d.model?{model:d.model}:{},...o?{patToken:o}:{},...m?{_meta:m}:{}};return await n.createAgent(_),{ok:!0,agentId:t,note:d.disconnectedAt?"revived from local config":"connected from local config"}}K.info("--agent-id: local config missing, pulling _agent/detail from cloud",{agentId:t});let u=await i({_meta:{cozeAgentId:t}});if(!u.framework)throw new k("AGENT_NOT_FOUND",`agent ${t} \u4E0D\u5728\u672C\u5730; \u4E91\u7AEF _agent/detail \u54CD\u5E94\u7F3A framework \u5B57\u6BB5 (D36 \u534F\u8BAE\u6269\u5C55\u672A\u751F\u6548), \u65E0\u6CD5\u5728\u672C\u673A\u65B0\u5EFA`);let f={agentId:u.agentId,framework:u.framework,...u.cozeIdentity?{cozeIdentity:u.cozeIdentity}:{},...u.model?{model:u.model}:{},...o?{patToken:o}:{},...u.deployType?{_meta:{cozeDeployType:u.deployType}}:{}};await n.createAgent(f);let x=u.deployType==="cloud"&&u.framework==="openclaw";return{ok:!0,agentId:t,note:x?"cloud agent acknowledged":"created from cloud detail"}}async function hI(t){let e=t.logger??K;try{let n=await t.detectAll();e.info("refreshed frameworks_cache",{detected:Object.keys(n??{})})}catch(n){e.warn("framework detection failed (using cached)",{err:String(n)})}await uI(t.paths,t.core).catch(n=>e.warn("scanAgentsOnStartup failed (ignored)",{err:String(n)})),await ha(t.paths,t.agentManager).catch(n=>e.warn("auto-revive top-level error (ignored)",{err:String(n)})),await xI(t.paths).catch(n=>e.warn("builtin skill refresh top-level error (ignored)",{err:String(n)}))}async function ha(t,e){let{readdir:n}=await import("node:fs/promises"),i;try{i=await n(t.agentsRoot)}catch{return{revived:0,skipped:0,total:0}}if(i.length===0)return{revived:0,skipped:0,total:0};let{loadAgentConfig:o}=await Promise.resolve().then(()=>(qt(),bs));K.info("auto-revive: scanning local agents on startup",{count:i.length});let c=0,d=0;for(let u of i){let f;try{f=await o(u,t)}catch(x){K.warn("auto-revive: load config failed (skipping)",{agentId:u,err:String(x)}),d+=1;continue}if(!f){d+=1;continue}if(f.deletedAt){K.info("auto-revive: skip deleted agent",{agentId:u,deletedAt:f.deletedAt}),d+=1;continue}if(f.disconnectedAt){K.info("auto-revive: skip disconnected agent",{agentId:u,disconnectedAt:f.disconnectedAt}),d+=1;continue}try{K.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:u,framework:f.framework});let x=pp(f);await e.createAgent({agentId:f.agentId,framework:f.framework,...f.cozeIdentity?{cozeIdentity:f.cozeIdentity}:{},...f.model?{model:f.model}:{},...x?{_meta:x}:{}},{revive:!0}),c+=1}catch(x){K.warn("auto-revive: createAgent failed (skipping)",{agentId:u,framework:f.framework,err:String(x)}),d+=1}}return K.info("auto-revive: done",{revived:c,skipped:d,total:i.length}),{revived:c,skipped:d,total:i.length}}async function xI(t){let{readdir:e}=await import("node:fs/promises"),n;try{n=await e(t.agentsRoot)}catch{return{refreshed:0,total:0}}if(n.length===0)return{refreshed:0,total:0};let i=0;for(let o of n)try{(await k0(o,t)).status==="refreshed"&&(i+=1)}catch(c){K.warn("refresh builtin skills failed (skipping agent)",{agentId:o,err:String(c)})}return i>0&&K.info("builtin skills refresh on startup done",{refreshed:i,total:n.length}),{refreshed:i,total:n.length}}async function pI(t){let e=t.logger??K;if(t.cliSpawned)return"skipped-cli";let n=await t.readPatToken();return n?(e.info("supervisor-spawned daemon, auto-connecting with stored PAT"),t.connect({privatecode:n}).catch(i=>e.warn("startup auto-connect failed (staying idle)",{err:String(i)})),"connecting"):(e.info("no stored PAT, skip startup auto-connect"),"skipped-no-pat")}function pp(t){let e={};return t.deployType&&(e.cozeDeployType=t.deployType),t.accountId&&(e.cozeAccountId=t.accountId),Object.keys(e).length>0?e:void 0}la();Re();import{readFile as gp}from"node:fs/promises";var nn=class{paths;constructor(e){this.paths=e??Y()}async probe(e=1e3){let n=await xa(this.paths);if(!n)return{kind:"not-running"};try{let i=await this.fetch(n,{method:"GET",path:"/status",timeoutMs:e});return i.status===200?{kind:"connected",...n,body:i.body}:{kind:"stale",reason:`unexpected status ${i.status}`}}catch(i){return{kind:"stale",reason:mI(i)}}}async request(e){let n=await xa(this.paths);if(!n)throw new Error("coze-bridge daemon not running (no port/token files)");return this.fetch(n,e)}async fetch(e,n){let i=n.body!==void 0,o={Authorization:`Bearer ${e.token}`};i&&(o["content-type"]="application/json");let c=new AbortController,d=setTimeout(()=>c.abort(),n.timeoutMs??5e3);try{let u=await fetch(`http://127.0.0.1:${e.port}${n.path}`,{method:n.method,headers:o,body:i?JSON.stringify(n.body):void 0,signal:c.signal}),f=await u.text();return{status:u.status,body:gI(f)}}finally{clearTimeout(d)}}};async function xa(t){try{let[e,n]=await Promise.all([gp(t.portFile,"utf8"),gp(t.tokenFile,"utf8")]),i=Number.parseInt(e.trim(),10),o=n.trim();return!Number.isFinite(i)||i<=0||!o?null:{port:i,token:o}}catch(e){if(e.code==="ENOENT")return null;throw e}}function gI(t){if(!t)return null;try{return JSON.parse(t)}catch{return t}}function mI(t){return t instanceof Error?t.message:String(t)}Zt();ne();or();import{spawn as wI}from"node:child_process";import{userInfo as wp}from"node:os";var Yd="__COZE_BRIDGE_ENV_SENTINEL_5f3c91__",_I=new Set(["bash","zsh","sh","dash","ksh"]),mp=Ze("COZE_BRIDGE_SHELLENV_TIMEOUT_MS",1e4),yI=2e3;function EI(t,e=Yd){let n=t.indexOf(e);if(n===-1)return null;let i=t.indexOf(e,n+e.length);if(i===-1)return null;let o=t.slice(n+e.length,i),c={};for(let d of o.split(`
|
|
118
|
+
`)){let u=d.indexOf("=");u<=0||(c[d.slice(0,u)]=d.slice(u+1))}return c}function bI(){let t=(process.env.SHELL??"").trim()||(wp().shell??"").trim();if(!t)return null;let e=t.slice(t.lastIndexOf("/")+1);return _I.has(e)?t:null}function vI(t){return new Promise(e=>{let n=`printf '%s' '${Yd}'; env; printf '%s' '${Yd}'`,i;try{i=wI(t,["-ilc",n],{detached:!0,stdio:["ignore","pipe","ignore"],env:{...process.env,HOME:process.env.HOME??wp().homedir}})}catch{e(null);return}let o="",c=!1,d=m=>{try{i.pid&&process.kill(-i.pid,m)}catch{}},u=m=>{c||(c=!0,clearTimeout(f),clearTimeout(x),e(m))};i.stdout?.on("data",m=>{o+=m.toString("utf8")}),i.on("error",()=>u(null)),i.on("close",()=>u(o.length>0?o:null));let f=setTimeout(()=>d("SIGTERM"),mp),x=setTimeout(()=>{d("SIGKILL"),u(o.length>0?o:null)},mp+yI)})}async function Xd(t={}){if((t.platform??process.platform)==="win32")return{kind:"skipped",reason:"windows"};let n=bI();if(!n)return{kind:"skipped",reason:"no-supported-login-shell"};let i=await(t.run??vI)(n);if(i==null)return{kind:"failed",reason:"shell-timeout-or-error"};let o=EI(i);return o==null?{kind:"failed",reason:"unparseable-output"}:{kind:"ok",env:o}}Re();function Pn(t,...e){let n=[],i;for(let o=0;o<t.length;o++){let c=t[o],d=!1;for(let u of e){if(c===u){i=t[o+1],o+=1,d=!0;break}if(c.startsWith(`${u}=`)){i=c.slice(u.length+1),d=!0;break}}d||n.push(c)}return{value:i,rest:n}}dn();import{chmod as SI,copyFile as _p,mkdir as Ep,readFile as us,rename as yp,rm as tl,stat as bp,writeFile as II}from"node:fs/promises";import{homedir as rO}from"node:os";import{dirname as AI,join as Le,resolve as nl,sep as ls}from"node:path";import{fileURLToPath as kI}from"node:url";Zt();ne();Re();function Jr(t,e,n,i){rt(t.bridgeLogsDir,e,"dist-install",n,i)}function vp(){return{darwin:{arm64:"@openai/codex-darwin-arm64",x64:"@openai/codex-darwin-x64"},linux:{arm64:"@openai/codex-linux-arm64",x64:"@openai/codex-linux-x64"},win32:{arm64:"@openai/codex-win32-arm64",x64:"@openai/codex-win32-x64"}}[process.platform]?.[process.arch]}function TI(){return{darwin:{arm64:Le("vendor","aarch64-apple-darwin","bin","codex"),x64:Le("vendor","x86_64-apple-darwin","bin","codex")},linux:{arm64:Le("vendor","aarch64-unknown-linux-musl","bin","codex"),x64:Le("vendor","x86_64-unknown-linux-musl","bin","codex")},win32:{arm64:Le("vendor","aarch64-pc-windows-msvc","bin","codex.exe"),x64:Le("vendor","x86_64-pc-windows-msvc","bin","codex.exe")}}[process.platform]?.[process.arch]}function PI(t){let e=kI(t),n=AI(e),i=`${ls}src${ls}`;if(n.includes(i)||n.endsWith(`${ls}src${ls}cli`))return null;let o=nl(n,"index.js"),c=nl(n,"..","package.json");return{dist:o,pkgJson:c}}async function rl(t={}){let e=t.paths??Y(),n=PI(import.meta.url),i=t.sourceDist??n?.dist,o=t.sourcePackageJson??n?.pkgJson;if(!i||!o)return{kind:"dev-mode-skip",reason:"running from src/(tsx loader);no dist/ to install"};if(i===e.libEntry)return{kind:"dev-mode-skip",reason:"running from installed lib path; no re-install needed"};let c,d;try{let b=JSON.parse(await us(o,"utf8"));c=b.version??"unknown",d=b.dependencies??{}}catch(b){throw Jr(e,"error","cannot read source package.json",{err:String(b)}),new Error(`cannot read source package.json: ${String(b)}`,{cause:b})}let u=ws.map(b=>({name:b,spec:d[b]??"latest"})),f=u.map(({name:b,spec:I})=>`${b}@${I}`),x=await Mo(e.configFile)??{},m=x.libVersion,_=await us(e.libEntry).then(()=>!0).catch(()=>!1),v=m===c,y=await Sp(e,u);if(v&&_&&y)return{kind:"already-current",libVersion:c};if(!v||!_){await Ep(e.libDir,{recursive:!0}),await _p(i,e.libEntry),await _p(`${i}.map`,`${e.libEntry}.map`).catch(()=>{});let b=nl(e.libDir,"package.json"),I=`${JSON.stringify({type:"module"},null,2)}
|
|
119
|
+
`;await us(b,"utf8").catch(()=>null)!==I&&await II(b,I)}return y||(t.installWrappers?await t.installWrappers(e,f):await DI(e,f,u)),x.libVersion=c,await Zi(x,e.configFile),Jr(e,"info","dist installed",{libEntry:e.libEntry,fromVersion:m,toVersion:c}),v&&_?{kind:"already-current",libVersion:c}:m?{kind:"version-changed",fromVersion:m,toVersion:c,libEntry:e.libEntry}:{kind:"first-install",libVersion:c,libEntry:e.libEntry}}async function Sp(t,e){for(let n of e){let i=Le(t.libDir,"node_modules",...n.name.split("/"),"package.json"),o;try{o=JSON.parse(await us(i,"utf8"))}catch(d){return Jr(t,"debug","wrapper not ready: package.json read failed",{package:n.name,expected:n.spec,pkgJson:i,err:String(d)}),!1}let c=o.version;if(!c)return Jr(t,"debug","wrapper not ready: package.json \u7F3A version",{package:n.name,expected:n.spec,pkgJson:i}),!1;if(!RI(c,n.spec))return Jr(t,"debug","wrapper not ready: installed version does not satisfy expected range",{package:n.name,installed:c,expected:n.spec}),!1}return!!await Ip(Le(t.libDir,"node_modules"))}function RI(t,e){let n=Qd(t);if(!n)return!0;let i=e.trim();if(!i||i==="*"||i==="latest")return!0;if(i.startsWith("^")){let c=Qd(i.slice(1));if(!c)return!0;if(el(n,c)<0)return!1;let d=CI(c);return el(n,d)<0}let o=Qd(i);return o?el(n,o)===0:!0}function CI(t){return t[0]>0?[t[0]+1,0,0]:t[1]>0?[0,t[1]+1,0]:[0,0,t[2]+1]}function Qd(t){let e=t.match(/^v?(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:[-+].*)?$/);return e?[Number(e[1]),Number(e[2]??0),Number(e[3]??0)]:null}function el(t,e){for(let n=0;n<3;n++){let i=(t[n]??0)-(e[n]??0);if(i!==0)return i}return 0}async function DI(t,e,n){await NI(t.installLock,async()=>{if(await Sp(t,n))return;let i=Math.random().toString(36).slice(2,10),o=`${t.libDir}${ls}.staging-${process.pid}-${i}`,c=Le(o,"node_modules"),d=Le(t.libDir,"node_modules");try{await Ep(o,{recursive:!0}),await OI(e,o),await LI(c);let u=`${d}.trash-${i}`;await yp(d,u).catch(()=>{}),await yp(c,d),await tl(u,{recursive:!0,force:!0}).catch(()=>{}),Jr(t,"info","wrapper closure installed",{liveNm:d,specs:e})}finally{await tl(o,{recursive:!0,force:!0}).catch(()=>{})}})}function OI(t,e){let n=["install",...t,"--prefix",e,"--omit=dev","--include=optional","--prefer-offline","--no-audit","--no-fund"];return new Promise((i,o)=>{let c=st("npm",n,{stdio:["ignore","pipe","pipe"]}),d="";c.stderr?.on("data",f=>{d.length<8192&&(d+=f.toString("utf8"))});let u=setTimeout(()=>c.kill("SIGKILL"),18e4);c.once("error",f=>{clearTimeout(u),o(new Error(`spawn npm failed: ${String(f)}`))}),c.once("close",f=>{clearTimeout(u),f===0?i():o(new Error(`npm install \u9000\u51FA\u7801 ${f}: ${d.trim().slice(0,2e3)}`))})})}async function LI(t){for(let e of ws){let n=Le(t,...e.split("/")),i=JSON.parse(await us(Le(n,"package.json"),"utf8"));if(!i.version)throw new Error(`${e}: package.json \u7F3A version`);let o=typeof i.bin=="string"?e.split("/").pop():Object.keys(i.bin??{})[0];if(!o)throw new Error(`${e}: package.json \u7F3A bin`);let c=Le(t,".bin",o),d=await bp(c);process.platform!=="win32"&&!(d.mode&73)&&await SI(c,d.mode|73).catch(()=>{})}if(!await Ip(t)){let e=vp()??"<unsupported-platform>";throw new Error(`${e}: \u5F53\u524D\u5E73\u53F0 codex binary \u7F3A\u5931`)}}async function Ip(t){let e=vp(),n=TI();if(!e||!n)return!0;let i=Le(t,"@openai","codex"),o=Le(t,...e.split("/")),c=[Le(i,"package.json"),Le(i,"bin","codex.js"),Le(t,".bin",process.platform==="win32"?"codex.cmd":"codex"),Le(o,"package.json"),Le(o,n)];return(await Promise.all(c.map(u=>bp(u).then(f=>f.isFile()).catch(()=>!1)))).every(Boolean)}async function NI(t,e){let{open:n}=await import("node:fs/promises"),i=!1;for(let o=0;o<60&&!i;o++)try{await(await n(t,"wx")).close(),i=!0}catch{await new Promise(c=>setTimeout(c,500))}try{return await e()}finally{i&&await tl(t,{force:!0}).catch(()=>{})}}Na();ne();Re();import{closeSync as kp,fstatSync as Tp,openSync as Pp,readFileSync as MI,readSync as BI,readdirSync as FI,statSync as zI}from"node:fs";import{join as pa}from"node:path";var UI=new Set(["debug","info","warn","error"]);function Rp(t){let e=t,n=Pn(e,"--agent-id");e=n.rest;let i=Pn(e,"--date");e=i.rest;let o=Pn(e,"-n","--lines");e=o.rest;let c=Pn(e,"--level");e=c.rest;let d=Pn(e,"--grep");e=d.rest;let u=o.value===void 0?200:Number(o.value),f=Number.isInteger(u)&&u>=0?u:200,x=c.value&&UI.has(c.value)?c.value:void 0,m={lines:f,follow:e.includes("-f")||e.includes("--follow"),raw:e.includes("--raw"),list:e.includes("--list")};return n.value&&(m.agentId=n.value),i.value&&(m.date=i.value),x&&(m.level=x),d.value&&(m.grep=d.value),m}function GI(t,e){return t.agentId?pa(ze(t.agentId,e).logs,ar("agent",t.date)):pa(e.bridgeLogsDir,ar("bridge",t.date))}function HI(t,e){return e<=0||e>=t.length?t:t.slice(t.length-e)}function qI(t,e){let n;try{n=FI(t)}catch{return[]}let i=[];for(let o of n){let c=La(o,e);if(!c)continue;let d=0;try{d=zI(pa(t,o)).size}catch{}i.push({file:pa(t,o),date:c,size:d})}return i.sort((o,c)=>c.date.localeCompare(o.date)),i}function Cp(t,e){if(e.grep&&!t.includes(e.grep))return!1;if(e.level){let n;try{n=JSON.parse(t).level}catch{return!0}if(typeof n=="string"&&!Ol(n,e.level))return!1}return!0}var Ap={debug:"90",info:"36",warn:"33",error:"31"},jI=new Set(["ts","level","module","msg"]);function WI(t){if(typeof t!="string")return"";let e=t.split("T")[1];return e?e.slice(0,12):""}function Dp(t,e){if(e.raw)return t;let n;try{n=JSON.parse(t)}catch{return t}let i=WI(n.ts),o=typeof n.level=="string"?n.level:"",c=o.toUpperCase().padEnd(5);e.color&&Ap[o]&&(c=`\x1B[${Ap[o]}m${c}\x1B[0m`);let d=typeof n.module=="string"?n.module:"",u=typeof n.msg=="string"?n.msg:"",f=Object.entries(n).filter(([x])=>!jI.has(x)).map(([x,m])=>` ${x}=${typeof m=="string"?m:JSON.stringify(m)}`).join("");return`${i} ${c} ${d} ${u}${f}`}function KI(t,e,n){let c=MI(t,"utf8").split(`
|
|
120
|
+
`).filter(d=>d.length>0).filter(d=>Cp(d,{level:e.level,grep:e.grep}));for(let d of HI(c,e.lines))process.stdout.write(`${Dp(d,{raw:e.raw,color:n})}
|
|
121
|
+
`)}async function Op(t,e){let n=e.paths??Y(),i=process.stdout.isTTY===!0;if(t.list){let d=t.agentId?ze(t.agentId,n).logs:n.bridgeLogsDir,u=t.agentId?"agent":"bridge",f=qI(d,u);if(f.length===0)return process.stderr.write(`coze-bridge log: \u65E0\u65E5\u5FD7\u6587\u4EF6\u4E8E ${d}
|
|
122
122
|
`),1;for(let x of f)process.stdout.write(`${x.date} ${(x.size/1024).toFixed(1)}KB ${x.file}
|
|
123
|
-
`);return 0}let o=t.date??
|
|
123
|
+
`);return 0}let o=t.date??Cn(new Date),c=GI({agentId:t.agentId,date:o},n);try{KI(c,t,i)}catch{return process.stderr.write(`coze-bridge log: \u627E\u4E0D\u5230\u65E5\u5FD7 ${c}
|
|
124
124
|
\u7528 'coze-bridge log${t.agentId?` --agent-id ${t.agentId}`:""} --list' \u770B\u6709\u54EA\u4E9B\u65E5\u671F\u3002
|
|
125
|
-
(legacy \u6A21\u5F0F\u65E0 dated \u6587\u4EF6, \u89C1 ${
|
|
126
|
-
`),1}return t.follow&&await
|
|
127
|
-
`);o=f.pop()??"";for(let x of f)x.length>0&&
|
|
128
|
-
`)}await new Promise(f=>setTimeout(f
|
|
125
|
+
(legacy \u6A21\u5F0F\u65E0 dated \u6587\u4EF6, \u89C1 ${n.logFile})
|
|
126
|
+
`),1}return t.follow&&await JI(c,t,i),0}var $I=500;function VI(t){try{let e=Pp(t,"r");try{return Tp(e).size}finally{kp(e)}}catch{return 0}}async function JI(t,e,n){let i=VI(t),o="",c=!1,d=()=>{c=!0};process.on("SIGINT",d);try{for(;!c;){let u="";try{let f=Pp(t,"r");try{let x=Tp(f).size;if(x>i){let m=Buffer.allocUnsafe(x-i),_=BI(f,m,0,m.length,i);u=m.subarray(0,_).toString("utf8"),i+=_}}finally{kp(f)}}catch{}if(u){let f=(o+u).split(`
|
|
127
|
+
`);o=f.pop()??"";for(let x of f)x.length>0&&Cp(x,{level:e.level,grep:e.grep})&&process.stdout.write(`${Dp(x,{raw:e.raw,color:n})}
|
|
128
|
+
`)}await new Promise(f=>setTimeout(f,$I))}}finally{process.off("SIGINT",d)}}import{basename as ZI,resolve as YI}from"node:path";Re();var XI=9e4,QI={PATH_OUTSIDE_WORKSPACE:3,FILE_TOO_LARGE:3,UNSUPPORTED_MIME:3,MODEL_MODALITY_UNSUPPORTED:3,IPC_BAD_REQUEST:3,AGENT_NOT_FOUND:4,IPC_AUTH_FAILED:4,AGENT_DISCONNECTED:5,UPLOAD_FAILED:5,UPSTREAM_NOT_READY:5,UPSTREAM_DISCONNECTED:5,UPSTREAM_HANDSHAKE_FAILED:5,AGENT_BUSY:1,AGENT_SPAWN_FAILED:1,AGENT_TIMEOUT:1,AGENT_FRAME_IDLE_TIMEOUT:1,AGENT_PROTOCOL_ERROR:1,AGENT_TURN_ABORTED:1,BRIDGE_CONFIG_INVALID:1,BRIDGE_INTERNAL:1,MODEL_TOKEN_GEN_FAILED:1,OPERATION_NOT_ALLOWED_FOR_LOCAL:1,OPERATION_NOT_ALLOWED_FOR_CLOUD:1,METHOD_NOT_FOUND:1,AGENT_DEPENDENCY_INSTALL_FAILED:1,AGENT_APPROVAL_TIMEOUT:1,AGENT_ENV_NOT_READY:1,SKILL_NOT_FOUND:1,SKILL_ZIP_TOO_LARGE:1};function eA(t){return QI[t]??1}async function Lp(t,e={}){let n=e.paths??Y();if(!t.agentId||!t.sessionId)return process.stderr.write(`Error: missing --agent-id and/or --session-id. These IDs come from the <coze-context> block injected at the top of each prompt \u2014 extract agentId and sessionId from there and pass them as flags. Example: coze-bridge send image x.png --agent-id <id> --session-id <id>
|
|
129
129
|
`),4;if(t.groupFile&&!t.mimeType)return process.stderr.write(`Error: --group-file requires --mime <mimeType> (e.g. application/pdf, image/png). No local file is read in group-file mode, mime cannot be auto-detected.
|
|
130
|
-
`),3;let i=await
|
|
131
|
-
`),4;let o={agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,path:t.groupFile?t.path:
|
|
130
|
+
`),3;let i=await xa(n).catch(()=>null);if(!i)return process.stderr.write(`Error: coze-bridge daemon not running (cannot read ${n.portFile} / ${n.tokenFile}). Make sure you are inside an agent session spawned by the daemon.
|
|
131
|
+
`),4;let o={agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,path:t.groupFile?t.path:YI(process.cwd(),t.path),...t.caption?{caption:t.caption}:{},...t.name?{name:t.name}:{},...t.groupFile?{groupFile:!0}:{},...t.mimeType?{mimeType:t.mimeType}:{}},c;try{c=await tA(i,"/agent/send",o,XI)}catch(d){return process.stderr.write(`Error: daemon IPC failed: ${d instanceof Error?d.message:String(d)}
|
|
132
132
|
`),4}if(!c.ok)return process.stderr.write(`Error: ${c.code}: ${c.message}
|
|
133
|
-
`),
|
|
134
|
-
`);else{let d=t.name??
|
|
135
|
-
`)}else process.stdout.write(`Sent ${t.kind} ${d} (${
|
|
136
|
-
`)}return 0}async function
|
|
137
|
-
`)}function
|
|
133
|
+
`),eA(c.code);if(t.json)process.stdout.write(`${JSON.stringify(c)}
|
|
134
|
+
`);else{let d=t.name??ZI(o.path);if(t.groupFile){let u=c.uri.length>60?`${c.uri.slice(0,57)}...`:c.uri;process.stdout.write(`Sent group file ${d} (uri=${u})
|
|
135
|
+
`)}else process.stdout.write(`Sent ${t.kind} ${d} (${nA(c.bytes)})
|
|
136
|
+
`)}return 0}async function tA(t,e,n,i){let o=new AbortController,c=setTimeout(()=>o.abort(),i);try{let d=await fetch(`http://127.0.0.1:${t.port}${e}`,{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"content-type":"application/json"},body:JSON.stringify(n),signal:o.signal}),u=await d.text(),f=u?JSON.parse(u):null;return f&&typeof f=="object"&&"ok"in f?f:{ok:!1,code:"BRIDGE_INTERNAL",message:`unexpected daemon response (status=${d.status}): ${u.slice(0,200)}`}}finally{clearTimeout(c)}}function nA(t){return t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(1)}KB`:`${(t/1024/1024).toFixed(1)}MB`}var jp=q("cli");function Ke(t,e){let{value:n,rest:i}=Pn(t,e);return{value:n,rest:i}}function Ea(t,e){process.stderr.write(`[deprecated] '${t}' will be removed in a future release, use '${e}' instead
|
|
137
|
+
`)}function AA(t){let e=t.slice(2);if(e.includes("--version")||e.includes("-v"))return{mode:"version"};if(e.includes("--daemon"))return{mode:"daemon"};if(e[0]==="status")return{mode:"status"};if(e[0]==="stop")return{mode:"stop"};if(e[0]==="reload"){let{value:D}=Ke(e.slice(1),"--agent-id");return D?{mode:"reload",agentId:D}:{mode:"reload"}}if(e[0]==="update")return{mode:"update"};if(e[0]==="purge")return{mode:"purge"};if(e[0]==="service")return e[1]==="install"?{mode:"service-install"}:e[1]==="uninstall"?{mode:"service-uninstall"}:{mode:"help"};if(e[0]==="send")return kA(e.slice(1));if(e[0]==="log")return{mode:"log",...Rp(e.slice(1))};if(e[0]==="connect")return TA(e.slice(1));if(e.includes("--status"))return Ea("--status","coze-bridge status"),{mode:"status"};if(e.includes("--stop"))return Ea("--stop","coze-bridge stop"),{mode:"stop"};if(e.includes("--uninstall"))return Ea("--uninstall","coze-bridge purge"),{mode:"purge"};if(e.includes("--install-service"))return Ea("--install-service","coze-bridge service install"),{mode:"service-install"};if(e.includes("--help")||e.includes("-h")||e.length===0)return{mode:"help"};let n=e,{value:i,rest:o}=Ke(n,"--pat-token");n=o;let{value:c,rest:d}=Ke(n,"--pair-code");n=d;let{value:u,rest:f}=Ke(n,"--env");n=f;let{value:x,rest:m}=Ke(n,"--handshake-url");n=m;let{value:_,rest:v}=Ke(n,"--frontier-url");n=v;let{value:y,rest:b}=Ke(n,"--mock-scenario");n=b;let{value:I}=Ke(n,"--agent-id"),A=n.includes("--skip-rebuild-env");if(!i||!c)return{mode:"help"};let P={mode:"pair",privatecode:i,pairingCode:c};return u&&(P.env=u),x&&(P.handshakeUrl=x),_&&(P.frontierUrl=_),y&&(P.mockScenario=y),I&&(P.agentId=I),A&&(P.skipRebuildEnv=!0),P}function kA(t){let e=t[0],n=t[1];if(e!=="image"&&e!=="file")return{mode:"help"};if(!n||n.startsWith("--"))return{mode:"help"};let i=t.slice(2),{value:o,rest:c}=Ke(i,"--caption");i=c;let{value:d,rest:u}=Ke(i,"--name");i=u;let{value:f,rest:x}=Ke(i,"--agent-id");i=x;let{value:m,rest:_}=Ke(i,"--session-id");i=_;let{value:v,rest:y}=Ke(i,"--mime");i=y;let b=i.includes("--group-file");i=i.filter(P=>P!=="--group-file");let I=i.includes("--json"),A={mode:"send",kind:e,path:n,json:I};return o&&(A.caption=o),d&&(A.name=d),f&&(A.agentId=f),m&&(A.sessionId=m),b&&(A.groupFile=!0),v&&(A.mimeType=v),A}function TA(t){let e=t,{value:n,rest:i}=Ke(e,"--pat-token");e=i;let{value:o,rest:c}=Ke(e,"--env");e=c;let{value:d,rest:u}=Ke(e,"--handshake-url");e=u;let{value:f,rest:x}=Ke(e,"--frontier-url");e=x;let{value:m,rest:_}=Ke(e,"--mock-scenario");e=_;let v=e.includes("--skip-rebuild-env"),y={mode:"connect"};return n&&(y.privatecode=n),o&&(y.env=o),d&&(y.handshakeUrl=d),f&&(y.frontierUrl=f),m&&(y.mockScenario=m),v&&(y.skipRebuildEnv=!0),y}var PA=`
|
|
138
138
|
coze-bridge - local bridge daemon for cloud Agent Service
|
|
139
139
|
|
|
140
140
|
Pair (paste from cloud UI; start/reuse daemon and deliver pair-code):
|
|
@@ -215,57 +215,57 @@ Deprecated flags (still work, but emit a warning; will be removed in a future re
|
|
|
215
215
|
|
|
216
216
|
Internal:
|
|
217
217
|
<node> <entry> --daemon daemon mode (OS supervisor only)
|
|
218
|
-
`.trimStart();async function
|
|
219
|
-
`),0;case"daemon":{try{await
|
|
220
|
-
`),1;if(i.kind==="stale")return await
|
|
221
|
-
`),1;let o=await
|
|
218
|
+
`.trimStart();async function Wp(t=process.argv,e={}){let n=AA(t);switch(n.mode){case"help":return process.stdout.write(PA),0;case"version":return process.stdout.write(`${Lt}
|
|
219
|
+
`),0;case"daemon":{try{await xp()}catch(i){return jp.error("daemon start failed",{err:String(i)}),1}return new Promise(()=>{})}case"status":return RA(e);case"stop":return $p(e);case"reload":return OA(n.agentId,e);case"log":return Op(n,e);case"update":return CA(e);case"purge":return NA(e);case"service-install":return MA(e);case"service-uninstall":return BA(e);case"pair":{let i={};return n.env&&(i.env=n.env),n.handshakeUrl&&(i.handshakeUrl=n.handshakeUrl),n.frontierUrl&&(i.frontierUrl=n.frontierUrl),n.mockScenario&&(i.mockScenario=n.mockScenario),FA(n.privatecode,n.pairingCode,e,i,n.agentId,n.skipRebuildEnv)}case"connect":{let i={};return n.env&&(i.env=n.env),n.handshakeUrl&&(i.handshakeUrl=n.handshakeUrl),n.frontierUrl&&(i.frontierUrl=n.frontierUrl),n.mockScenario&&(i.mockScenario=n.mockScenario),zA(n.privatecode,e,i,n.skipRebuildEnv)}case"send":return Lp({kind:n.kind,path:n.path,...n.agentId?{agentId:n.agentId}:{},...n.sessionId?{sessionId:n.sessionId}:{},...n.caption?{caption:n.caption}:{},...n.name?{name:n.name}:{},...n.groupFile?{groupFile:!0}:{},...n.mimeType?{mimeType:n.mimeType}:{},json:n.json},e)}}async function Kp(t){let{unlink:e}=await import("node:fs/promises");await Promise.all([e(t.pidFile).catch(()=>{}),e(t.portFile).catch(()=>{}),e(t.tokenFile).catch(()=>{})])}async function RA(t){let e=t.paths??Y(),n=new nn(e),i=await n.probe();if(i.kind==="not-running")return process.stdout.write(`coze-bridge: not running
|
|
220
|
+
`),1;if(i.kind==="stale")return await Kp(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
|
|
221
|
+
`),1;let o=await n.request({method:"GET",path:"/status"});return process.stdout.write(`coze-bridge: running
|
|
222
222
|
${JSON.stringify(o.body,null,2)}
|
|
223
|
-
`),0}async function
|
|
224
|
-
`)}let u=await
|
|
223
|
+
`),0}async function $p(t){let e=t.paths??Y(),n=new nn(e),i=t.daemonSweep??(async()=>{let f=U0();return await G0(f),f}),o=async()=>{t.skipProcessKill||await i(e)},c=await hs(t),d=!1;if(c)try{await c.uninstall(),d=!0}catch(f){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(f)}
|
|
224
|
+
`)}let u=await n.probe();if(u.kind==="not-running")return await o(),process.stdout.write(d?`coze-bridge: stopped
|
|
225
225
|
`:`coze-bridge: not running
|
|
226
|
-
`),0;if(u.kind==="stale")return await
|
|
227
|
-
`),0;try{return await
|
|
228
|
-
`),0}catch(f){return(await
|
|
226
|
+
`),0;if(u.kind==="stale")return await Kp(e),await o(),process.stdout.write(`coze-bridge: not running (cleaned stale state)
|
|
227
|
+
`),0;try{return await n.request({method:"POST",path:"/shutdown"}),await o(),process.stdout.write(`coze-bridge: stopped
|
|
228
|
+
`),0}catch(f){return(await n.probe()).kind!=="connected"?(await o(),process.stdout.write(`coze-bridge: stopped
|
|
229
229
|
`),0):(await o(),process.stdout.write(`coze-bridge: stop failed: ${String(f)}
|
|
230
|
-
`),1)}}async function
|
|
231
|
-
`),e(1)})})}async function
|
|
232
|
-
`),1;try{let o=await
|
|
230
|
+
`),1)}}async function CA(t){return await $p(t),(t.spawnNpx??DA)(["-y","--ignore-existing","coze-bridge@latest","connect"])}function DA(t){return new Promise(e=>{let n=st("npx",t,{stdio:"inherit"});n.on("exit",i=>e(i??1)),n.on("error",i=>{process.stderr.write(`coze-bridge: spawn npx failed: ${String(i)}
|
|
231
|
+
`),e(1)})})}async function OA(t,e){let n=new nn(e.paths);if((await n.probe()).kind==="not-running")return process.stdout.write(`coze-bridge: not running (start daemon first)
|
|
232
|
+
`),1;try{let o=await n.request({method:"POST",path:"/reload",body:t?{agent_id:t}:{},timeoutMs:35e3});if(o.status===200&&o.body?.ok){let c=o.body.recycled??[];return t&&c.length===0?process.stdout.write(`coze-bridge: agent ${t} \u65E0\u8FD0\u884C\u4E2D\u5B50\u8FDB\u7A0B\u53EF\u56DE\u6536 (\u672A\u6CE8\u518C / \u5DF2 idle)
|
|
233
233
|
`):process.stdout.write(`coze-bridge: reloaded ${c.length} agent(s): ${c.join(", ")||"(none)"}
|
|
234
234
|
`),0}return process.stderr.write(`coze-bridge: reload failed: ${JSON.stringify(o.body)}
|
|
235
235
|
`),1}catch(o){return process.stderr.write(`coze-bridge: reload failed: ${String(o)}
|
|
236
|
-
`),1}}async function
|
|
236
|
+
`),1}}async function hs(t){if(t.supervisor){let c=t.supervisor,d={nodeBin:"",entry:"",logFile:"",homeDir:"",userName:""};return{platform:c.platform,install:u=>c.install(d,u),uninstall:()=>c.uninstall(d)}}if(t.skipSupervisor)return;let{getSupervisor:e,buildContext:n}=await Promise.resolve().then(()=>(Gp(),Up)),i=e(),o=n();return{platform:i.platform,install:c=>i.install(o,c),uninstall:()=>i.uninstall(o)}}async function Vp(t,e){let n=await e.probe(),i=t.waitTimeoutMs??15e3,o=t.sleep??UA,c=t.paths??Y();if(n.kind==="connected"){if(!LA(n.body))return n;rt(c.bridgeLogsDir,"warn","cli","daemon Node \u4E0E\u5F53\u524D CLI \u4E0D\u4E00\u81F4, \u91CD\u542F daemon",{currentNode:process.execPath,currentArch:process.arch,daemon:n.body}),await e.request({method:"POST",path:"/shutdown"}).catch(f=>rt(c.bridgeLogsDir,"warn","cli","restart for Node drift: shutdown failed",{err:String(f)})),await qp(c.pidFile,o)}let d=t.spawnDaemon??fp,u=await hs(t);if(u&&(u.platform==="darwin"||u.platform==="linux")){try{await u.install({activate:!0});let f=await Hp(e,i,o);if(f.kind==="connected")return f;rt(c.bridgeLogsDir,"warn","cli","supervisor \u8D77 daemon \u8D85\u65F6, \u56DE\u9000\u624B\u52A8 spawn (\u672C\u6B21\u65E0\u5D29\u6E83\u4FDD\u6D3B)",{waitMs:i})}catch(f){rt(c.bridgeLogsDir,"warn","cli","supervisor \u63A5\u7BA1\u5931\u8D25, \u56DE\u9000\u624B\u52A8 spawn",{err:String(f)})}rt(c.bridgeLogsDir,"warn","cli","\u79FB\u9664\u5F00\u673A\u81EA\u542F\u914D\u7F6E (supervisor \u63A5\u7BA1\u672A\u6210\u529F, \u56DE\u9000\u624B\u52A8 spawn; \u4E0B\u6B21\u91CD\u542F\u4E0D\u518D\u81EA\u542F, \u9700\u91CD\u65B0 service install)",{platform:u.platform}),await u.uninstall().catch(()=>{}),await qp(c.pidFile,o)}else u&&await u.install({activate:!1}).catch(f=>process.stderr.write(`coze-bridge: \u81EA\u542F\u6CE8\u518C\u5931\u8D25(\u4E0D\u5F71\u54CD\u672C\u6B21): ${String(f)}
|
|
237
237
|
`));return process.stdout.write(`coze-bridge: starting daemon...
|
|
238
|
-
`),await d({paths:t.paths}),
|
|
238
|
+
`),await d({paths:t.paths}),Hp(e,i,o)}function LA(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.nodeExecPath!="string"||typeof e.nodeArch!="string"?!1:e.nodeExecPath!==process.execPath||e.nodeArch!==process.arch}async function NA(t){let e=new nn(t.paths);if((await e.probe()).kind==="connected"){process.stdout.write(`coze-bridge: stopping daemon...
|
|
239
239
|
`);try{await e.request({method:"POST",path:"/shutdown"})}catch(d){process.stderr.write(`coze-bridge: stop failed (continuing): ${String(d)}
|
|
240
|
-
`)}await new Promise(d=>setTimeout(d,500))}let i=await
|
|
240
|
+
`)}await new Promise(d=>setTimeout(d,500))}let i=await hs(t);if(i)try{await i.uninstall(),process.stdout.write(`coze-bridge: ${i.platform} supervisor unregistered
|
|
241
241
|
`)}catch(d){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(d)}
|
|
242
|
-
`)}let o=t.paths??
|
|
242
|
+
`)}let o=t.paths??Y(),{rm:c}=await import("node:fs/promises");try{await c(o.bridgeRoot,{recursive:!0,force:!0}),process.stdout.write(`coze-bridge: removed ${o.bridgeRoot}
|
|
243
243
|
`)}catch(d){return process.stderr.write(`coze-bridge: remove failed: ${String(d)}
|
|
244
244
|
`),1}return process.stdout.write(`coze-bridge: purged (agents workspaces preserved under ~/.coze/agents)
|
|
245
|
-
`),0}async function
|
|
245
|
+
`),0}async function MA(t){let e=await hs(t);if(!e)return 0;try{return process.stdout.write(`coze-bridge: installing ${e.platform} supervisor...
|
|
246
246
|
`),await e.install(),process.stdout.write(`coze-bridge: supervisor installed (daemon will auto-start on login)
|
|
247
|
-
`),0}catch(
|
|
248
|
-
`),1}}async function
|
|
249
|
-
`),0}catch(
|
|
250
|
-
`),1}}async function Jp(t,e,
|
|
251
|
-
`),rt(t.bridgeLogsDir,"warn","cli","reconstructLoginShellEnv failed, fell back to process.env",{reason:i.reason}),process.env)}async function
|
|
252
|
-
`),(await d.probe()).kind==="connected"&&(await d.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(y=>setTimeout(y,500)))):
|
|
253
|
-
`)}let x=await Vp(
|
|
254
|
-
`),1;let
|
|
247
|
+
`),0}catch(n){return process.stderr.write(`coze-bridge: service install failed: ${String(n)}
|
|
248
|
+
`),1}}async function BA(t){let e=await hs(t);if(!e)return 0;try{return await e.uninstall(),process.stdout.write(`coze-bridge: ${e.platform} supervisor unregistered
|
|
249
|
+
`),0}catch(n){return process.stderr.write(`coze-bridge: service uninstall failed: ${String(n)}
|
|
250
|
+
`),1}}async function Jp(t,e,n){if(e)return rt(t.bridgeLogsDir,"info","cli","agent-env: skip rebuild, use process.env",{}),process.env;let i=await n();return i.kind==="ok"?(rt(t.bridgeLogsDir,"info","cli","agent-env: rebuilt from login shell",{vars:Object.keys(i.env).length}),i.env):i.kind==="skipped"?(rt(t.bridgeLogsDir,"info","cli","agent-env: rebuild not applicable, use process.env",{reason:i.reason}),process.env):(process.stderr.write(`coze-bridge: \u91CD\u5EFA shell \u73AF\u5883\u5931\u8D25, \u56DE\u9000\u5F53\u524D\u8FDB\u7A0B\u73AF\u5883 (\u53EF\u7528 --skip-rebuild-env \u663E\u5F0F\u8DF3\u8FC7)
|
|
251
|
+
`),rt(t.bridgeLogsDir,"warn","cli","reconstructLoginShellEnv failed, fell back to process.env",{reason:i.reason}),process.env)}async function FA(t,e,n,i={},o,c){let d=new nn(n.paths),u=n.paths??Y(),f=await Jp(u,c,n.reconstructEnv??Xd);if(await Zc(u,f).catch(_=>rt(u.bridgeLogsDir,"warn","cli","writeAgentEnv failed (ignored)",{err:String(_)})),!n.skipDistInstall){let _=await rl({paths:n.paths});_.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${_.fromVersion} \u2192 ${_.toVersion}
|
|
252
|
+
`),(await d.probe()).kind==="connected"&&(await d.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(y=>setTimeout(y,500)))):_.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${_.libVersion}
|
|
253
|
+
`)}let x=await Vp(n,d);if(x.kind!=="connected")return process.stderr.write(`coze-bridge: daemon did not come up: ${x.kind}
|
|
254
|
+
`),1;let m={privatecode:t,pairing_code:e};i.env&&(m.env=i.env),i.handshakeUrl&&(m.handshake_url=i.handshakeUrl),i.frontierUrl&&(m.frontier_url=i.frontierUrl),i.mockScenario&&(m.mock_scenario=i.mockScenario),o&&(m.agent_id=o);try{let _=await d.request({method:"POST",path:"/pair",body:m,timeoutMs:35e3});if(_.status===200&&_.body?.ok){let v=_.body.agent;return v&&!v.ok?(process.stderr.write(`coze-bridge: paired but agent ensure failed (agentId=${v.agentId}): ${v.note}
|
|
255
255
|
`),1):(process.stdout.write(`\u5DF2\u914D\u5BF9\u8FDE\u63A5\u5B8C\u6210\uFF0C\u8BF7\u8FD4\u56DE\u5230 coze \u5E73\u53F0\u4E0A\u70B9\u51FB "\u6211\u5DF2\u6267\u884C"
|
|
256
|
-
`),0)}return process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(
|
|
257
|
-
`),1}catch(
|
|
258
|
-
`),1}}async function
|
|
259
|
-
`),(await d.probe()).kind==="connected"&&(await d.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(
|
|
256
|
+
`),0)}return process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(_.body)}
|
|
257
|
+
`),1}catch(_){return process.stderr.write(`coze-bridge: pair failed: ${String(_)}
|
|
258
|
+
`),1}}async function zA(t,e,n={},i){let o=e.paths??Y(),c=t??await aa(o);if(!c)return process.stderr.write("coze-bridge: \u627E\u4E0D\u5230 patToken \u2014 \u5148\u8DD1\u4E00\u6B21 `coze-bridge --pat-token=<sat_xxx> --pair-code=<xxx>` \u914D\u5BF9, \u6216\u672C\u6B21\u7528 `--pat-token` \u6307\u5B9A\n"),1;let d=new nn(e.paths),u=await Jp(o,i,e.reconstructEnv??Xd);if(await Zc(o,u).catch(m=>rt(o.bridgeLogsDir,"warn","cli","writeAgentEnv failed (ignored)",{err:String(m)})),!e.skipDistInstall){let m=await rl({paths:e.paths});m.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${m.fromVersion} \u2192 ${m.toVersion}
|
|
259
|
+
`),(await d.probe()).kind==="connected"&&(await d.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(v=>setTimeout(v,500)))):m.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${m.libVersion}
|
|
260
260
|
`)}let f=await Vp(e,d);if(f.kind!=="connected")return process.stderr.write(`coze-bridge: daemon did not come up: ${f.kind}
|
|
261
|
-
`),1;let x={privatecode:c};
|
|
262
|
-
`),t!==void 0&&await
|
|
263
|
-
`),1)}catch(
|
|
264
|
-
`),1}}async function
|
|
265
|
-
`),
|
|
261
|
+
`),1;let x={privatecode:c};n.env&&(x.env=n.env),n.handshakeUrl&&(x.handshake_url=n.handshakeUrl),n.frontierUrl&&(x.frontier_url=n.frontierUrl),n.mockScenario&&(x.mock_scenario=n.mockScenario);try{let m=await d.request({method:"POST",path:"/connect",body:x,timeoutMs:35e3});return m.status===200&&m.body?.ok?(process.stdout.write(`coze-bridge: connected (${m.body.note??"ok"})
|
|
262
|
+
`),t!==void 0&&await cs(c,o).catch(_=>jp.warn("writePatToken after connect failed (ignored)",{err:String(_)})),0):(process.stderr.write(`coze-bridge: connect failed: ${JSON.stringify(m.body)}
|
|
263
|
+
`),1)}catch(m){return process.stderr.write(`coze-bridge: connect failed: ${String(m)}
|
|
264
|
+
`),1}}async function Hp(t,e,n){let i=Date.now()+e;for(;Date.now()<i;){let o=await t.probe(500);if(o.kind==="connected")return o;await n(200)}return t.probe(500)}async function qp(t,e,n=60,i=200){let{readFile:o}=await import("node:fs/promises");for(let c=0;c<n;c++){let d;try{d=await o(t,"utf8")}catch{return}let u=Number.parseInt(d.trim(),10);if(!Number.isFinite(u)||u<=0||!Ki(u))return;await e(i)}}function UA(t){return new Promise(e=>setTimeout(e,t))}ne();function GA(t){let e=/^v?(\d+)(?:\.(\d+))?/.exec(t.trim());if(!e)return"ok";let n=Number(e[1]),i=Number(e[2]??0);return n<18||n===18&&i<4?"fatal":n<20?"warn":"ok"}function Zp(t=process.versions.node,e=i=>{process.stderr.write(i)},n=i=>process.exit(i)){let i=GA(t);if(i==="ok")return;let o=t.replace(/^v/,"");i==="fatal"?(e(`[coze-bridge] \u5F53\u524D Node.js \u7248\u672C v${o} \u8FC7\u4F4E,\u65E0\u6CD5\u8FD0\u884C(\u6700\u4F4E v18.4.0,\u63A8\u8350 v20+)\u3002\u8BF7\u5347\u7EA7\u540E\u91CD\u8BD5:https://nodejs.org(\u6216\u7528 nvm/fnm)\u3002
|
|
265
|
+
`),n(1)):e(`[coze-bridge] \u68C0\u6D4B\u5230 Node.js v${o},\u672C\u9879\u76EE\u63A8\u8350 v20+,\u4F4E\u4E8E v20 \u540E\u7EED\u5347\u7EA7\u53EF\u80FD\u6709\u517C\u5BB9\u95EE\u9898,\u5EFA\u8BAE\u5347\u7EA7\u3002
|
|
266
266
|
\u5347\u7EA7\u5B8C\u540E\u9700\u8981\u6267\u884C\u4EE5\u4E0B\u547D\u4EE4\u91CD\u65B0\u8FDE\u63A5:
|
|
267
267
|
npx -y coze-bridge@latest stop
|
|
268
268
|
npx -y coze-bridge@latest connect
|
|
269
269
|
|
|
270
|
-
`)}Zp();!process.argv.includes("--daemon")&&!process.env.COZE_BRIDGE_LOG_LEVEL&&
|
|
270
|
+
`)}Zp();!process.argv.includes("--daemon")&&!process.env.COZE_BRIDGE_LOG_LEVEL&&Cl("warn");Wp(process.argv).then(t=>process.exit(t),t=>{process.stderr.write(`fatal: ${t instanceof Error?t.stack??t.message:String(t)}
|
|
271
271
|
`),process.exit(1)});
|