coze-bridge 0.2.3-alpha.1 → 0.2.3-alpha.2
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 +80 -80
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5,30 +5,30 @@ 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 Og=Object.create;var
|
|
8
|
+
var Og=Object.create;var Da=Object.defineProperty;var Lg=Object.getOwnPropertyDescriptor;var Ng=Object.getOwnPropertyNames;var Mg=Object.getPrototypeOf,Bg=Object.prototype.hasOwnProperty;var he=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var rt=(t,e)=>()=>(t&&(e=t(t=0)),e);var le=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Pa=(t,e)=>{for(var r in e)Da(t,r,{get:e[r],enumerable:!0})},Fg=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ng(e))!Bg.call(t,o)&&o!==r&&Da(t,o,{get:()=>e[o],enumerable:!(i=Lg(e,o))||i.enumerable});return t};var Gt=(t,e,r)=>(r=t!=null?Og(Mg(t)):{},Fg(e||!t||!t.__esModule?Da(r,"default",{value:t,enumerable:!0}):r,t));function Ye(t,e){let r=process.env[t];if(!r)return e;let i=Number(r);return Number.isFinite(i)&&i>0?i:e}var sr=rt(()=>{"use strict"});import{createWriteStream as zg,mkdirSync as Ug,readdirSync as Gg,unlinkSync as Hg}from"node:fs";import{join as Id}from"node:path";function Dn(t){let e=r=>String(r).padStart(2,"0");return`${t.getFullYear()}-${e(t.getMonth()+1)}-${e(t.getDate())}`}function or(t,e){return`${t}-${e}.log`}function Oa(t,e){let r=t.match(/^(.+)-(\d{4}-\d{2}-\d{2})\.log$/);return!r||r[1]!==e?null:r[2]??null}function qg(t,e,r){let i=c=>{let[d,u,x]=c.split("-").map(Number);return Date.UTC(d??0,(u??1)-1,x??1)};return Math.floor((i(e)-i(t))/864e5)>r}function ps(t,e,r,i){let o;try{o=Gg(t)}catch{return}for(let c of o){let d=Oa(c,e);if(d&&qg(d,r,i))try{Hg(Id(t,c))}catch{}}}var ni,La=rt(()=>{"use strict";ni=class{constructor(e,r,i){this.dir=e;this.prefix=r;this.opts=i;this.clock=i.clock??(()=>Dn(new Date))}dir;prefix;opts;currentDate;stream;clock;write(e){let r=this.clock();r!==this.currentDate&&this.rotate(r),this.stream?.write(e)}rotate(e){this.stream?.end();try{Ug(this.dir,{recursive:!0});let r=zg(Id(this.dir,or(this.prefix,e)),{flags:"a"});r.on("error",i=>process.stderr.write(`[log-sink] stream error: ${String(i)}
|
|
9
9
|
`)),this.stream=r}catch(r){process.stderr.write(`[log-sink] rotate failed: ${String(r)}
|
|
10
|
-
`),this.stream=void 0;return}this.currentDate!==void 0&&
|
|
11
|
-
`;Wg(t,{recursive:!0}),jg(Kg(t,
|
|
12
|
-
`;if(
|
|
13
|
-
`),{cause:o})}}async function nm(t){let e=
|
|
14
|
-
`,r)}var Ut=et(()=>{"use strict"});import{promises as Fd,readdirSync as hm}from"node:fs";import{homedir as xm}from"node:os";import{sep as pm,join as ke,resolve as zd}from"node:path";function J(t){let e=t??xm(),r=ke(e,".coze"),i=ke(r,"bridge"),o=ke(i,"lib"),c=ke(i,"logs");return{cozeRoot:r,bridgeRoot:i,libDir:o,libEntry:ke(o,"index.js"),binDir:ke(i,"bin"),pidFile:ke(i,"bridge.pid"),portFile:ke(i,"bridge.port"),tokenFile:ke(i,"bridge.token"),patTokenFile:ke(i,"pat-token"),agentEnvFile:ke(i,"agent-env.json"),logFile:ke(i,"bridge.log"),bridgeLogsDir:c,daemonStdioLog:ke(c,"daemon-stdio.log"),installLock:ke(i,"install.lock"),configFile:ke(i,"config.json"),agentsRoot:ke(r,"agents")}}function Be(t,e=J()){let r=ke(e.agentsRoot,t);return{root:r,config:ke(r,"config.json"),workspace:ke(r,"workspace"),logs:ke(r,"logs")}}function ms(t=J()){try{return hm(t.agentsRoot,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name)}catch{return[]}}async function ii(t,e){let r=await Fd.realpath(zd(t)).catch(()=>null);if(!r)return!1;let i=await Fd.realpath(zd(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+pm)}var Ce=et(()=>{"use strict"});var _s={};Ra(_s,{AGENT_CONFIG_FILE_MODE:()=>ws,enforceAgentConfigMode:()=>wm,loadAgentConfig:()=>Ee,persistAgentSessions:()=>si,persistAgentSkills:()=>oi,saveAgentConfig:()=>Fe});import{chmod as gm,stat as mm}from"node:fs/promises";function Ee(t,e){return cr(Be(t,e).config)}function Fe(t,e){return lr(Be(t.agentId,e).config,t,{mode:ws})}async function wm(t,e){if(process.platform==="win32")return;let r=Be(t,e).config;try{let i=await mm(r);if(!i.isFile())return;let o=i.mode&511;o!==ws&&(await gm(r,ws),Ud.warn("agent config mode auto-corrected to 0600",{path:r,from:o.toString(8)}))}catch(i){if(i.code==="ENOENT")return;Ud.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:r,err:String(i)})}}async function si(t,e,r){let i=await Ee(t,r);i&&(i.sessions=Object.fromEntries(e),await Fe(i,r))}async function oi(t,e,r){let i=await Ee(t,r);i&&(i.skills=e,await Fe(i,r))}var Ud,ws,Ht=et(()=>{"use strict";Ut();te();Ce();Ud=H("agent-config"),ws=384});var za=ae((d2,qd)=>{qd.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 bs=ae(Wd=>{var jd={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 Sm(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(jd))Wd[t]=Sm(jd[t])});var Zd=ae((f2,Jd)=>{var Im=ue("fs"),Le=ue("path"),Kd=za(),Am=bs(),Tm=typeof process=="object"&&process.platform==="win32",$d=t=>typeof t=="object"&&t!==null,Vd=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 ve(t){this.sep=Le.sep,this.fs=Im,$d(t)&&$d(t.fs)&&typeof t.fs.statSync=="function"&&(this.fs=t.fs)}Jd.exports=ve;ve.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 l;try{l=e.fs.statSync(o)}catch(u){if(u.message&&u.message.startsWith("ENOENT"))e.fs.mkdirSync(o);else throw u}if(l&&l.isFile())throw Am.FILE_IN_THE_WAY(`"${o}"`)}})}r(t)};ve.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 l=Le.dirname(t);o.fs.existsSync(l)||o.makeDir(l);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};ve.prototype.writeFileToAsync=function(t,e,r,i,o){typeof i=="function"&&(o=i,i=void 0);let c=this;c.fs.exists(t,function(l){if(l&&!r)return o(!1);c.fs.stat(t,function(u,f){if(l&&f.isDirectory())return o(!1);var x=Le.dirname(t);c.fs.exists(x,function(p){p||c.makeDir(x),c.fs.open(t,"w",438,function(m,v){m?c.fs.chmod(t,438,function(){c.fs.open(t,"w",438,function(_,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)})})})})})};ve.prototype.findFiles=function(t){let e=this;function r(i,o,c){typeof o=="boolean"&&(c=o,o=void 0);let l=[];return e.fs.readdirSync(i).forEach(function(u){let f=Le.join(i,u),x=e.fs.statSync(f);(!o||o.test(f))&&l.push(Le.normalize(f)+(x.isDirectory()?e.sep:"")),x.isDirectory()&&c&&(l=l.concat(r(f,o,c)))}),l}return r(t,void 0,!0)};ve.prototype.findFilesAsync=function(t,e){let r=this,i=[];r.fs.readdir(t,function(o,c){if(o)return e(o);let l=c.length;if(!l)return e(null,i);c.forEach(function(u){u=Le.join(t,u),r.fs.stat(u,function(f,x){if(f)return e(f);x&&(i.push(Le.normalize(u)+(x.isDirectory()?r.sep:"")),x.isDirectory()?r.findFilesAsync(u,function(p,m){if(p)return e(p);i=i.concat(m),--l||e(null,i)}):--l||e(null,i))})})})};ve.prototype.getAttributes=function(){};ve.prototype.setAttributes=function(){};ve.crc32update=function(t,e){return Vd[(t^e)&255]^t>>>8};ve.crc32=function(t){typeof t=="string"&&(t=Buffer.from(t,"utf8"));let e=t.length,r=-1;for(let i=0;i<e;)r=ve.crc32update(r,t[i++]);return~r>>>0};ve.methodToString=function(t){switch(t){case Kd.STORED:return"STORED ("+t+")";case Kd.DEFLATED:return"DEFLATED ("+t+")";default:return"UNSUPPORTED ("+t+")"}};ve.canonical=function(t){if(!t)return"";let e=Le.posix.normalize("/"+t.split("\\").join("/"));return Le.join(".",e)};ve.zipnamefix=function(t){if(!t)return"";let e=Le.posix.normalize("/"+t.split("\\").join("/"));return Le.posix.join(".",e)};ve.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]};ve.sanitize=function(t,e){t=Le.resolve(Le.normalize(t));for(var r=e.split("/"),i=0,o=r.length;i<o;i++){var c=Le.normalize(Le.join(t,r.slice(i,o).join(Le.sep)));if(c.indexOf(t)===0)return c}return Le.normalize(Le.join(t,Le.basename(e)))};ve.toBuffer=function(e,r){return Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e):typeof e=="string"?r(e):Buffer.alloc(0)};ve.readBigUInt64LE=function(t,e){let r=t.readUInt32LE(e);return t.readUInt32LE(e+4)*4294967296+r};ve.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)};ve.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};ve.isWin=Tm;ve.crcTable=Vd});var Xd=ae((h2,Yd)=>{var km=ue("path");Yd.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=km.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 eu=ae((x2,Qd)=>{Qd.exports={efs:!0,encode:t=>Buffer.from(t,"utf8"),decode:t=>t.toString("utf8")}});var fr=ae((p2,ur)=>{ur.exports=Zd();ur.exports.Constants=za();ur.exports.Errors=bs();ur.exports.FileAttr=Xd();ur.exports.decoder=eu()});var nu=ae((g2,tu)=>{var cn=fr(),z=cn.Constants;tu.exports=function(){var t=20,e=10,r=0,i=0,o=0,c=0,l=0,u=0,f=0,x=0,p=0,m=0,v=0,_=0,b=0;t|=cn.isWin?2560:768,r|=z.FLG_EFS;let I={extraLen:0},A=y=>Math.max(0,y)>>>0,k=y=>Math.max(0,y)&65535,P=y=>Math.max(0,y)&255;return o=cn.fromDate2DOS(new Date),{get made(){return t},set made(y){t=y},get version(){return e},set version(y){e=y},get flags(){return r},set flags(y){r=y},get flags_efs(){return(r&z.FLG_EFS)>0},set flags_efs(y){y?r|=z.FLG_EFS:r&=~z.FLG_EFS},get flags_desc(){return(r&z.FLG_DESC)>0},set flags_desc(y){y?r|=z.FLG_DESC:r&=~z.FLG_DESC},get method(){return i},set method(y){switch(y){case z.STORED:this.version=10;case z.DEFLATED:default:this.version=20}i=y},get time(){return cn.fromDOS2Date(this.timeval)},set time(y){y=new Date(y),this.timeval=cn.fromDate2DOS(y)},get timeval(){return o},set timeval(y){o=A(y)},get timeHighByte(){return P(o>>>8)},get crc(){return c},set crc(y){c=A(y)},get compressedSize(){return l},set compressedSize(y){l=A(y)},get size(){return u},set size(y){u=A(y)},get fileNameLength(){return f},set fileNameLength(y){f=y},get extraLength(){return x},set extraLength(y){x=y},get extraLocalLength(){return I.extraLen},set extraLocalLength(y){I.extraLen=y},get commentLength(){return p},set commentLength(y){p=y},get diskNumStart(){return m},set diskNumStart(y){m=A(y)},get inAttr(){return v},set inAttr(y){v=A(y)},get attr(){return _},set attr(y){_=A(y)},get fileAttr(){return(_||0)>>16&4095},get offset(){return b},set offset(y){b=A(y)},get encrypted(){return(r&z.FLG_ENC)===z.FLG_ENC},get centralHeaderSize(){return z.CENHDR+f+x+p},get realDataOffset(){return b+z.LOCHDR+I.fnameLen+I.extraLen},get localHeader(){return I},loadLocalHeaderFromBinary:function(y){var R=y.slice(b,b+z.LOCHDR);if(R.readUInt32LE(0)!==z.LOCSIG)throw cn.Errors.INVALID_LOC();I.version=R.readUInt16LE(z.LOCVER),I.flags=R.readUInt16LE(z.LOCFLG),I.flags_desc=(I.flags&z.FLG_DESC)>0,I.method=R.readUInt16LE(z.LOCHOW),I.time=R.readUInt32LE(z.LOCTIM),I.crc=R.readUInt32LE(z.LOCCRC),I.compressedSize=R.readUInt32LE(z.LOCSIZ),I.size=R.readUInt32LE(z.LOCLEN),I.fnameLen=R.readUInt16LE(z.LOCNAM),I.extraLen=R.readUInt16LE(z.LOCEXT);let O=b+z.LOCHDR+I.fnameLen,F=O+I.extraLen;return y.slice(O,F)},loadFromBinary:function(y){if(y.length!==z.CENHDR||y.readUInt32LE(0)!==z.CENSIG)throw cn.Errors.INVALID_CEN();t=y.readUInt16LE(z.CENVEM),e=y.readUInt16LE(z.CENVER),r=y.readUInt16LE(z.CENFLG),i=y.readUInt16LE(z.CENHOW),o=y.readUInt32LE(z.CENTIM),c=y.readUInt32LE(z.CENCRC),l=y.readUInt32LE(z.CENSIZ),u=y.readUInt32LE(z.CENLEN),f=y.readUInt16LE(z.CENNAM),x=y.readUInt16LE(z.CENEXT),p=y.readUInt16LE(z.CENCOM),m=y.readUInt16LE(z.CENDSK),v=y.readUInt16LE(z.CENATT),_=y.readUInt32LE(z.CENATX),b=y.readUInt32LE(z.CENOFF)},localHeaderToBinary:function(){var y=Buffer.alloc(z.LOCHDR);return y.writeUInt32LE(z.LOCSIG,0),y.writeUInt16LE(e,z.LOCVER),y.writeUInt16LE(r,z.LOCFLG),y.writeUInt16LE(i,z.LOCHOW),y.writeUInt32LE(o,z.LOCTIM),y.writeUInt32LE(c,z.LOCCRC),y.writeUInt32LE(l,z.LOCSIZ),y.writeUInt32LE(u,z.LOCLEN),y.writeUInt16LE(f,z.LOCNAM),y.writeUInt16LE(I.extraLen,z.LOCEXT),y},centralHeaderToBinary:function(){var y=Buffer.alloc(z.CENHDR+f+x+p);return y.writeUInt32LE(z.CENSIG,0),y.writeUInt16LE(t,z.CENVEM),y.writeUInt16LE(e,z.CENVER),y.writeUInt16LE(r,z.CENFLG),y.writeUInt16LE(i,z.CENHOW),y.writeUInt32LE(o,z.CENTIM),y.writeUInt32LE(c,z.CENCRC),y.writeUInt32LE(l,z.CENSIZ),y.writeUInt32LE(u,z.CENLEN),y.writeUInt16LE(f,z.CENNAM),y.writeUInt16LE(x,z.CENEXT),y.writeUInt16LE(p,z.CENCOM),y.writeUInt16LE(m,z.CENDSK),y.writeUInt16LE(v,z.CENATT),y.writeUInt32LE(_,z.CENATX),y.writeUInt32LE(b,z.CENOFF),y},toJSON:function(){let y=function(R){return R+" bytes"};return{made:t,version:e,flags:r,method:cn.methodToString(i),time:this.time,crc:"0x"+c.toString(16).toUpperCase(),compressedSize:y(l),size:y(u),fileNameLength:y(f),extraLength:y(x),commentLength:y(p),diskNumStart:m,inAttr:v,attr:_,offset:b,centralHeaderSize:y(z.CENHDR+f+x+p)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var iu=ae((m2,ru)=>{var hr=fr(),_e=hr.Constants;ru.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 _e.ENDHDR+o},loadFromBinary:function(c){if((c.length!==_e.ENDHDR||c.readUInt32LE(0)!==_e.ENDSIG)&&(c.length<_e.ZIP64HDR||c.readUInt32LE(0)!==_e.ZIP64SIG))throw hr.Errors.INVALID_END();c.readUInt32LE(0)===_e.ENDSIG?(t=c.readUInt16LE(_e.ENDSUB),e=c.readUInt16LE(_e.ENDTOT),r=c.readUInt32LE(_e.ENDSIZ),i=c.readUInt32LE(_e.ENDOFF),o=c.readUInt16LE(_e.ENDCOM)):(t=hr.readBigUInt64LE(c,_e.ZIP64SUB),e=hr.readBigUInt64LE(c,_e.ZIP64TOT),r=hr.readBigUInt64LE(c,_e.ZIP64SIZE),i=hr.readBigUInt64LE(c,_e.ZIP64OFF),o=0)},toBinary:function(){var c=Buffer.alloc(_e.ENDHDR+o);return c.writeUInt32LE(_e.ENDSIG,0),c.writeUInt32LE(0,4),c.writeUInt16LE(t,_e.ENDSUB),c.writeUInt16LE(e,_e.ENDTOT),c.writeUInt32LE(r,_e.ENDSIZ),c.writeUInt32LE(i,_e.ENDOFF),c.writeUInt16LE(o,_e.ENDCOM),c.fill(" ",_e.ENDHDR),c},toJSON:function(){let c=function(l,u){let f=l.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 Ha=ae(Ua=>{Ua.EntryHeader=nu();Ua.MainHeader=iu()});var ou=ae((_2,su)=>{su.exports=function(t){var e=ue("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=[],l=0;o.on("data",function(u){c.push(u),l+=u.length}),o.on("end",function(){var u=Buffer.alloc(l),f=0;u.fill(0);for(var x=0;x<c.length;x++){var p=c[x];p.copy(u,f),f+=p.length}i&&i(u)}),o.end(t)}}}});var cu=ae((y2,au)=>{var Cm=+(process.versions?process.versions.node:"").split(".")[0]||0;au.exports=function(t,e){var r=ue("zlib");let i=Cm>=15&&e>0?{maxOutputLength:e}:{};return{inflate:function(){return r.inflateRawSync(t,i)},inflateAsync:function(o){var c=r.createInflateRaw(i),l=[],u=0;c.on("data",function(f){l.push(f),u+=f.length}),c.on("end",function(){var f=Buffer.alloc(u),x=0;f.fill(0);for(var p=0;p<l.length;p++){var m=l[p];m.copy(f,x),x+=m.length}o&&o(f)}),c.end(t)}}}});var hu=ae((b2,fu)=>{"use strict";var{randomFillSync:lu}=ue("crypto"),Rm=bs(),Pm=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}),uu=(t,e)=>Math.imul(t,e)>>>0,du=(t,e)=>Pm[(t^e)&255]^t>>>8,ai=()=>typeof lu=="function"?lu(Buffer.alloc(12)):ai.node();ai.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 Es={genSalt:ai};function vs(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])}vs.prototype.updateKeys=function(t){let e=this.keys;return e[0]=du(e[0],t),e[1]+=e[0]&255,e[1]=uu(e[1],134775813)+1,e[2]=du(e[2],e[1]>>>24),t};vs.prototype.next=function(){let t=(this.keys[2]|2)>>>0;return uu(t,t^1)>>8&255};function Dm(t){let e=new vs(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 Om(t){let e=new vs(t);return function(r,i,o=0){i||(i=Buffer.alloc(r.length));for(let c of r){let l=e.next();i[o++]=c^l,e.updateKeys(c)}return i}}function Lm(t,e,r){if(!t||!Buffer.isBuffer(t)||t.length<12)return Buffer.alloc(0);let i=Dm(r),o=i(t.slice(0,12)),c=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(o[11]!==c)throw Rm.WRONG_PASSWORD();return i(t.slice(12))}function Nm(t){Buffer.isBuffer(t)&&t.length>=12?Es.genSalt=function(){return t.slice(0,12)}:t==="node"?Es.genSalt=ai.node:Es.genSalt=ai}function Mm(t,e,r,i=!1){t==null&&(t=Buffer.alloc(0)),Buffer.isBuffer(t)||(t=Buffer.from(t.toString()));let o=Om(r),c=Es.genSalt();c[11]=e.crc>>>24&255,i&&(c[10]=e.crc>>>16&255);let l=Buffer.alloc(t.length+12);return o(c,l),o(t,l,12)}fu.exports={decrypt:Lm,encrypt:Mm,_salter:Nm}});var xu=ae(Ss=>{Ss.Deflater=ou();Ss.Inflater=cu();Ss.ZipCrypto=hu()});var qa=ae((v2,pu)=>{var ce=fr(),Bm=Ha(),Se=ce.Constants,Ga=xu();pu.exports=function(t,e){var r=new Bm.EntryHeader,i=Buffer.alloc(0),o=Buffer.alloc(0),c=!1,l=null,u=Buffer.alloc(0),f=Buffer.alloc(0),x=!0;let p=t,m=typeof p.decoder=="object"?p.decoder:ce.decoder;x=m.hasOwnProperty("efs")?m.efs:!1;function v(){return!e||!(e instanceof Uint8Array)?Buffer.alloc(0):(f=r.loadLocalHeaderFromBinary(e),e.slice(r.realDataOffset,r.realDataOffset+r.compressedSize))}function _(y){if(!r.flags_desc&&!r.localHeader.flags_desc){if(ce.crc32(y)!==r.localHeader.crc)return!1}else{let R={},O=r.realDataOffset+r.compressedSize;if(e.readUInt32LE(O)==Se.LOCSIG||e.readUInt32LE(O)==Se.CENSIG)throw ce.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(O)==Se.EXTSIG)R.crc=e.readUInt32LE(O+Se.EXTCRC),R.compressedSize=e.readUInt32LE(O+Se.EXTSIZ),R.size=e.readUInt32LE(O+Se.EXTLEN);else if(e.readUInt16LE(O+12)===19280)R.crc=e.readUInt32LE(O+Se.EXTCRC-4),R.compressedSize=e.readUInt32LE(O+Se.EXTSIZ-4),R.size=e.readUInt32LE(O+Se.EXTLEN-4);else throw ce.Errors.DESCRIPTOR_UNKNOWN();if(R.compressedSize!==r.compressedSize||R.size!==r.size||R.crc!==r.crc)throw ce.Errors.DESCRIPTOR_FAULTY();if(ce.crc32(y)!==R.crc)return!1}return!0}function b(y,R,O){if(typeof R>"u"&&typeof y=="string"&&(O=y,y=void 0),c)return y&&R&&R(Buffer.alloc(0),ce.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var F=v();if(F.length===0)return y&&R&&R(F),F;if(r.encrypted){if(typeof O!="string"&&!Buffer.isBuffer(O))throw ce.Errors.INVALID_PASS_PARAM();F=Ga.ZipCrypto.decrypt(F,r,O)}var M=Buffer.alloc(r.size);switch(r.method){case ce.Constants.STORED:if(F.copy(M),_(M))return y&&R&&R(M),M;throw y&&R&&R(M,ce.Errors.BAD_CRC()),ce.Errors.BAD_CRC();case ce.Constants.DEFLATED:var V=new Ga.Inflater(F,r.size);if(y)V.inflateAsync(function($){$.copy($,0),R&&(_($)?R($):R($,ce.Errors.BAD_CRC()))});else{if(V.inflate(M).copy(M,0),!_(M))throw ce.Errors.BAD_CRC(`"${m.decode(i)}"`);return M}break;default:throw y&&R&&R(Buffer.alloc(0),ce.Errors.UNKNOWN_METHOD()),ce.Errors.UNKNOWN_METHOD()}}function I(y,R){if((!l||!l.length)&&Buffer.isBuffer(e))return y&&R&&R(v()),v();if(l.length&&!c){var O;switch(r.method){case ce.Constants.STORED:return r.compressedSize=r.size,O=Buffer.alloc(l.length),l.copy(O),y&&R&&R(O),O;default:case ce.Constants.DEFLATED:var F=new Ga.Deflater(l);if(y)F.deflateAsync(function(V){O=Buffer.alloc(V.length),r.compressedSize=V.length,V.copy(O),R&&R(O)});else{var M=F.deflate();return r.compressedSize=M.length,M}F=null;break}}else if(y&&R)R(Buffer.alloc(0));else return Buffer.alloc(0)}function A(y,R){return ce.readBigUInt64LE(y,R)}function k(y){try{for(var R=0,O,F,M;R+4<y.length;)O=y.readUInt16LE(R),R+=2,F=y.readUInt16LE(R),R+=2,M=y.slice(R,R+F),R+=F,Se.ID_ZIP64===O&&P(M)}catch{throw ce.Errors.EXTRA_FIELD_PARSE_ERROR()}}function P(y){var R,O,F,M;y.length>=Se.EF_ZIP64_SCOMP&&(R=A(y,Se.EF_ZIP64_SUNCOMP),r.size===Se.EF_ZIP64_OR_32&&(r.size=R)),y.length>=Se.EF_ZIP64_RHO&&(O=A(y,Se.EF_ZIP64_SCOMP),r.compressedSize===Se.EF_ZIP64_OR_32&&(r.compressedSize=O)),y.length>=Se.EF_ZIP64_DSN&&(F=A(y,Se.EF_ZIP64_RHO),r.offset===Se.EF_ZIP64_OR_32&&(r.offset=F)),y.length>=Se.EF_ZIP64_DSN+4&&(M=y.readUInt32LE(Se.EF_ZIP64_DSN),r.diskNumStart===Se.EF_ZIP64_OR_16&&(r.diskNumStart=M))}return{get entryName(){return m.decode(i)},get rawEntryName(){return i},set entryName(y){i=ce.toBuffer(y,m.encode);var R=i[i.length-1];c=R===47||R===92,r.fileNameLength=i.length},get efs(){return typeof x=="function"?x(this.entryName):x},get extra(){return u},set extra(y){u=y,r.extraLength=y.length,k(y)},get comment(){return m.decode(o)},set comment(y){if(o=ce.toBuffer(y,m.encode),r.commentLength=o.length,o.length>65535)throw ce.Errors.COMMENT_TOO_LONG()},get name(){var y=m.decode(i);return c?y.substr(y.length-1).split("/").pop():y.split("/").pop()},get isDirectory(){return c},getCompressedData:function(){return I(!1,null)},getCompressedDataAsync:function(y){I(!0,y)},setData:function(y){l=ce.toBuffer(y,ce.decoder.encode),!c&&l.length?(r.size=l.length,r.method=ce.Constants.DEFLATED,r.crc=ce.crc32(y),r.changed=!0):r.method=ce.Constants.STORED},getData:function(y){return r.changed?l:b(!1,null,y)},getDataAsync:function(y,R){r.changed?y(l):b(!0,y,R)},set attr(y){r.attr=y},get attr(){return r.attr},set header(y){r.loadFromBinary(y)},get header(){return r},packCentralHeader:function(){r.flags_efs=this.efs,r.extraLength=u.length;var y=r.centralHeaderToBinary(),R=ce.Constants.CENHDR;return i.copy(y,R),R+=i.length,u.copy(y,R),R+=r.extraLength,o.copy(y,R),y},packLocalHeader:function(){let y=0;r.flags_efs=this.efs,r.extraLocalLength=f.length;let R=r.localHeaderToBinary(),O=Buffer.alloc(R.length+i.length+r.extraLocalLength);return R.copy(O,y),y+=R.length,i.copy(O,y),y+=i.length,f.copy(O,y),y+=f.length,O},toJSON:function(){let y=function(R){return"<"+(R&&R.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:r.toJSON(),compressedData:y(e),data:y(l)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var wu=ae((S2,mu)=>{var gu=qa(),Fm=Ha(),Ke=fr();mu.exports=function(t,e){var r=[],i={},o=Buffer.alloc(0),c=new Fm.MainHeader,l=!1,u=null;let f=new Set,x=e,{noSort:p,decoder:m}=x;t?b(x.readEntries):l=!0;function v(){let A=new Set;for(let k of Object.keys(i)){let P=k.split("/");if(P.pop(),!!P.length)for(let y=0;y<P.length;y++){let R=P.slice(0,y+1).join("/")+"/";A.add(R)}}for(let k of A)if(!(k in i)){let P=new gu(x);P.entryName=k,P.attr=16,P.temporary=!0,r.push(P),i[P.entryName]=P,f.add(P)}}function _(){if(l=!0,i={},c.diskEntries>(t.length-c.offset)/Ke.Constants.CENHDR)throw Ke.Errors.DISK_ENTRY_TOO_LARGE();r=new Array(c.diskEntries);for(var A=c.offset,k=0;k<r.length;k++){var P=A,y=new gu(x,t);y.header=t.slice(P,P+=Ke.Constants.CENHDR),y.entryName=t.slice(P,P+=y.header.fileNameLength),y.header.extraLength&&(y.extra=t.slice(P,P+=y.header.extraLength)),y.header.commentLength&&(y.comment=t.slice(P,P+y.header.commentLength)),A+=y.header.centralHeaderSize,r[k]=y,i[y.entryName]=y}f.clear(),v()}function b(A){var k=t.length-Ke.Constants.ENDHDR,P=Math.max(0,k-65535),y=P,R=t.length,O=-1,F=0;for(typeof x.trailingSpace=="boolean"&&x.trailingSpace&&(P=0),k;k>=y;k--)if(t[k]===80){if(t.readUInt32LE(k)===Ke.Constants.ENDSIG){O=k,F=k,R=k+Ke.Constants.ENDHDR,y=k-Ke.Constants.END64HDR;continue}if(t.readUInt32LE(k)===Ke.Constants.END64SIG){y=P;continue}if(t.readUInt32LE(k)===Ke.Constants.ZIP64SIG){O=k,R=k+Ke.readBigUInt64LE(t,k+Ke.Constants.ZIP64SIZE)+Ke.Constants.ZIP64LEAD;break}}if(O==-1)throw Ke.Errors.INVALID_FORMAT();c.loadFromBinary(t.slice(O,R)),c.commentLength&&(o=t.slice(F+Ke.Constants.ENDHDR)),A&&_()}function I(){r.length>1&&!p&&r.sort((A,k)=>A.entryName.toLowerCase().localeCompare(k.entryName.toLowerCase()))}return{get entries(){return l||_(),r.filter(A=>!f.has(A))},get comment(){return m.decode(o)},set comment(A){o=Ke.toBuffer(A,m.encode),c.commentLength=o.length},getEntryCount:function(){return l?r.length:c.diskEntries},forEach:function(A){this.entries.forEach(A)},getEntry:function(A){return l||_(),i[A]||null},setEntry:function(A){l||_(),r.push(A),i[A.entryName]=A,c.totalEntries=r.length},deleteFile:function(A,k=!0){l||_();let P=i[A];this.getEntryChildren(P,k).map(R=>R.entryName).forEach(this.deleteEntry)},deleteEntry:function(A){l||_();let k=i[A],P=r.indexOf(k);P>=0&&(r.splice(P,1),delete i[A],c.totalEntries=r.length)},getEntryChildren:function(A,k=!0){if(l||_(),typeof A=="object")if(A.isDirectory&&k){let P=[],y=A.entryName;for(let R of r)R.entryName.startsWith(y)&&P.push(R);return P}else return[A];return[]},getChildCount:function(A){if(A&&A.isDirectory){let k=this.getEntryChildren(A);return k.includes(A)?k.length-1:k.length}return 0},compressToBuffer:function(){l||_(),I();let A=[],k=[],P=0,y=0;c.size=0,c.offset=0;let R=0;for(let M of this.entries){let V=M.getCompressedData();M.header.offset=y;let $=M.packLocalHeader(),ne=$.length+V.length;y+=ne,A.push($),A.push(V);let Y=M.packCentralHeader();k.push(Y),c.size+=Y.length,P+=ne+Y.length,R++}P+=c.mainHeaderSize,c.offset=y,c.totalEntries=R,y=0;let O=Buffer.alloc(P);for(let M of A)M.copy(O,y),y+=M.length;for(let M of k)M.copy(O,y),y+=M.length;let F=c.toBinary();return o&&o.copy(F,Ke.Constants.ENDHDR),F.copy(O,y),t=O,l=!1,O},toAsyncBuffer:function(A,k,P,y){try{l||_(),I();let R=[],O=[],F=0,M=0,V=0;c.size=0,c.offset=0;let $=function(ne){if(ne.length>0){let Y=ne.shift(),se=Y.entryName+Y.extra.toString();P&&P(se),Y.getCompressedDataAsync(function(oe){y&&y(se),Y.header.offset=M;let C=Y.packLocalHeader(),U=C.length+oe.length;M+=U,R.push(C),R.push(oe);let G=Y.packCentralHeader();O.push(G),c.size+=G.length,F+=U+G.length,V++,$(ne)})}else{F+=c.mainHeaderSize,c.offset=M,c.totalEntries=V,M=0;let Y=Buffer.alloc(F);R.forEach(function(oe){oe.copy(Y,M),M+=oe.length}),O.forEach(function(oe){oe.copy(Y,M),M+=oe.length});let se=c.toBinary();o&&o.copy(se,Ke.Constants.ENDHDR),se.copy(Y,M),t=Y,l=!1,A(Y)}};$(Array.from(this.entries))}catch(R){k(R)}}}}});var bu=ae((I2,yu)=>{var be=fr(),ye=ue("path"),zm=qa(),Um=wu(),Pn=(...t)=>be.findLast(t,e=>typeof e=="boolean"),_u=(...t)=>be.findLast(t,e=>typeof e=="string"),Hm=(...t)=>be.findLast(t,e=>typeof e=="function"),Gm={noSort:!1,readEntries:!1,method:be.Constants.NONE,fs:null};yu.exports=function(t,e){let r=null,i=Object.assign(Object.create(null),Gm);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 Um(r,i),{canonical:l,sanitize:u,zipnamefix:f}=be;function x(_){if(_&&c){var b;if(typeof _=="string"&&(b=c.getEntry(ye.posix.normalize(_))),typeof _=="object"&&typeof _.entryName<"u"&&typeof _.header<"u"&&(b=c.getEntry(_.entryName)),b)return b}return null}function p(_){let{join:b,normalize:I,sep:A}=ye.posix;return b(ye.isAbsolute(_)?"/":".",I(A+_.split("\\").join(A)+A))}function m(_){return _ instanceof RegExp?(function(b){return function(I){return b.test(I)}})(_):typeof _!="function"?()=>!0:_}let v=(_,b)=>{let I=b.slice(-1);return I=I===o.sep?o.sep:"",ye.relative(_,b)+I};return{readFile:function(_,b){var I=x(_);return I&&I.getData(b)||null},childCount:function(_){let b=x(_);if(b)return c.getChildCount(b)},readFileAsync:function(_,b){var I=x(_);I?I.getDataAsync(b):b(null,"getEntry failed for:"+_)},readAsText:function(_,b){var I=x(_);if(I){var A=I.getData();if(A&&A.length)return A.toString(b||"utf8")}return""},readAsTextAsync:function(_,b,I){var A=x(_);A?A.getDataAsync(function(k,P){if(P){b(k,P);return}k&&k.length?b(k.toString(I||"utf8")):b("")}):b("")},deleteFile:function(_,b=!0){var I=x(_);I&&c.deleteFile(I.entryName,b)},deleteEntry:function(_){var b=x(_);b&&c.deleteEntry(b.entryName)},addZipComment:function(_){c.comment=_},getZipComment:function(){return c.comment||""},addZipEntryComment:function(_,b){var I=x(_);I&&(I.comment=b)},getZipEntryComment:function(_){var b=x(_);return b&&b.comment||""},updateFile:function(_,b){var I=x(_);I&&I.setData(b)},addLocalFile:function(_,b,I,A){if(o.fs.existsSync(_)){b=b?p(b):"";let k=ye.win32.basename(ye.win32.normalize(_));b+=I||k;let P=o.fs.statSync(_),y=P.isFile()?o.fs.readFileSync(_):Buffer.alloc(0);P.isDirectory()&&(b+=o.sep),this.addFile(b,y,A,P)}else throw be.Errors.FILE_NOT_FOUND(_)},addLocalFileAsync:function(_,b){_=typeof _=="object"?_:{localPath:_};let I=ye.resolve(_.localPath),{comment:A}=_,{zipPath:k,zipName:P}=_,y=this;o.fs.stat(I,function(R,O){if(R)return b(R,!1);k=k?p(k):"";let F=ye.win32.basename(ye.win32.normalize(I));if(k+=P||F,O.isFile())o.fs.readFile(I,function(M,V){return M?b(M,!1):(y.addFile(k,V,A,O),setImmediate(b,void 0,!0))});else if(O.isDirectory())return k+=o.sep,y.addFile(k,Buffer.alloc(0),A,O),setImmediate(b,void 0,!0)})},addLocalFolder:function(_,b,I){if(I=m(I),b=b?p(b):"",_=ye.normalize(_),o.fs.existsSync(_)){let A=o.findFiles(_),k=this;if(A.length)for(let P of A){let y=ye.join(b,v(_,P));I(y)&&k.addLocalFile(P,ye.dirname(y))}}else throw be.Errors.FILE_NOT_FOUND(_)},addLocalFolderAsync:function(_,b,I,A){A=m(A),I=I?p(I):"",_=ye.normalize(_);var k=this;o.fs.open(_,"r",function(P){if(P&&P.code==="ENOENT")b(void 0,be.Errors.FILE_NOT_FOUND(_));else if(P)b(void 0,P);else{var y=o.findFiles(_),R=-1,O=function(){if(R+=1,R<y.length){var F=y[R],M=v(_,F).split("\\").join("/");M=M.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),A(M)?o.fs.stat(F,function(V,$){V&&b(void 0,V),$.isFile()?o.fs.readFile(F,function(ne,Y){ne?b(void 0,ne):(k.addFile(I+M,Y,"",$),O())}):(k.addFile(I+M+"/",Buffer.alloc(0),"",$),O())}):process.nextTick(()=>{O()})}else b(!0,void 0)};O()}})},addLocalFolderAsync2:function(_,b){let I=this;_=typeof _=="object"?_:{localPath:_},localPath=ye.resolve(p(_.localPath));let{zipPath:A,filter:k,namefix:P}=_;k instanceof RegExp?k=(function(O){return function(F){return O.test(F)}})(k):typeof k!="function"&&(k=function(){return!0}),A=A?p(A):"",P=="latin1"&&(P=O=>O.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof P!="function"&&(P=O=>O);let y=O=>ye.join(A,P(v(localPath,O))),R=O=>ye.win32.basename(ye.win32.normalize(P(O)));o.fs.open(localPath,"r",function(O){O&&O.code==="ENOENT"?b(void 0,be.Errors.FILE_NOT_FOUND(localPath)):O?b(void 0,O):o.findFilesAsync(localPath,function(F,M){if(F)return b(F);M=M.filter(V=>k(y(V))),M.length||b(void 0,!1),setImmediate(M.reverse().reduce(function(V,$){return function(ne,Y){if(ne||Y===!1)return setImmediate(V,ne,!1);I.addLocalFileAsync({localPath:$,zipPath:ye.dirname(y($)),zipName:R($)},V)}},b))})})},addLocalFolderPromise:function(_,b){return new Promise((I,A)=>{this.addLocalFolderAsync2(Object.assign({localPath:_},b),(k,P)=>{k&&A(k),P&&I(this)})})},addFile:function(_,b,I,A){_=f(_);let k=x(_),P=k!=null;P||(k=new zm(i),k.entryName=_),k.comment=I||"";let y=typeof A=="object"&&A instanceof o.fs.Stats;y&&(k.header.time=A.mtime);var R=k.isDirectory?16:0;let O=k.isDirectory?16384:32768;return y?O|=4095&A.mode:typeof A=="number"?O|=4095&A:O|=k.isDirectory?493:420,R=(R|O<<16)>>>0,k.attr=R,k.setData(b),P||c.setEntry(k),k},getEntries:function(_){return c.password=_,c?c.entries:[]},getEntry:function(_){return x(_)},getEntryCount:function(){return c.getEntryCount()},forEach:function(_){return c.forEach(_)},extractEntryTo:function(_,b,I,A,k,P){A=Pn(!1,A),k=Pn(!1,k),I=Pn(!0,I),P=_u(k,P);var y=x(_);if(!y)throw be.Errors.NO_ENTRY();var R=l(y.entryName),O=u(b,P&&!y.isDirectory?P:I?R:ye.basename(R));if(y.isDirectory){var F=c.getEntryChildren(y);return F.forEach(function($){if($.isDirectory)return;var ne=$.getData();if(!ne)throw be.Errors.CANT_EXTRACT_FILE();var Y=l($.entryName),se=u(b,I?Y:ye.basename(Y));let oe=k?$.header.fileAttr:void 0;o.writeFileTo(se,ne,A,oe)}),!0}var M=y.getData(c.password);if(!M)throw be.Errors.CANT_EXTRACT_FILE();if(o.fs.existsSync(O)&&!A)throw be.Errors.CANT_OVERRIDE();let V=k?_.header.fileAttr:void 0;return o.writeFileTo(O,M,A,V),!0},test:function(_){if(!c)return!1;for(var b in c.entries)try{if(b.isDirectory)continue;var I=c.entries[b].getData(_);if(!I)return!1}catch{return!1}return!0},extractAllTo:function(_,b,I,A){if(I=Pn(!1,I),A=_u(I,A),b=Pn(!1,b),!c)throw be.Errors.NO_ZIP();c.entries.forEach(function(k){var P=u(_,l(k.entryName));if(k.isDirectory){o.makeDir(P);return}var y=k.getData(A);if(!y)throw be.Errors.CANT_EXTRACT_FILE();let R=I?k.header.fileAttr:void 0;o.writeFileTo(P,y,b,R);try{o.fs.utimesSync(P,k.header.time,k.header.time)}catch{throw be.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(_,b,I,A){if(A=Hm(b,I,A),I=Pn(!1,I),b=Pn(!1,b),!A)return new Promise((O,F)=>{this.extractAllToAsync(_,b,I,function(M){M?F(M):O(this)})});if(!c){A(be.Errors.NO_ZIP());return}_=ye.resolve(_);let k=O=>u(_,ye.normalize(l(O.entryName))),P=(O,F)=>new Error(O+': "'+F+'"'),y=[],R=[];c.entries.forEach(O=>{O.isDirectory?y.push(O):R.push(O)});for(let O of y){let F=k(O),M=I?O.header.fileAttr:void 0;try{o.makeDir(F),M&&o.fs.chmodSync(F,M),o.fs.utimesSync(F,O.header.time,O.header.time)}catch{A(P("Unable to create folder",F))}}R.reverse().reduce(function(O,F){return function(M){if(M)O(M);else{let V=ye.normalize(l(F.entryName)),$=u(_,V);F.getDataAsync(function(ne,Y){if(Y)O(Y);else if(!ne)O(be.Errors.CANT_EXTRACT_FILE());else{let se=I?F.header.fileAttr:void 0;o.writeFileToAsync($,ne,b,se,function(oe){oe||O(P("Unable to write file",$)),o.fs.utimes($,F.header.time,F.header.time,function(C){C?O(P("Unable to set times",$)):O()})})}})}}},A)()},writeZip:function(_,b){if(arguments.length===1&&typeof _=="function"&&(b=_,_=""),!_&&i.filename&&(_=i.filename),!!_){var I=c.compressToBuffer();if(I){var A=o.writeFileTo(_,I,!0);typeof b=="function"&&b(A?null:new Error("failed"),"")}}},writeZipPromise:function(_,b){let{overwrite:I,perm:A}=Object.assign({overwrite:!0},b);return new Promise((k,P)=>{!_&&i.filename&&(_=i.filename),_||P("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(y=>{let R=O=>O?k(O):P("ADM-ZIP: Wasn't able to write zip file");o.writeFileToAsync(_,y,I,A,R)},P)})},toBufferPromise:function(){return new Promise((_,b)=>{c.toAsyncBuffer(_,b)})},toBuffer:function(_,b,I,A){return typeof _=="function"?(c.toAsyncBuffer(_,b,I,A),null):c.compressToBuffer()}}}});import{execFile as V_,spawn as J_,spawnSync as qA}from"node:child_process";import{promisify as Z_}from"node:util";function X_(t){if(process.platform!=="win32")return!1;if(Hf.test(t))return!0;let r=(t.split(/[/\\]/).pop()??t).replace(Hf,"").toLowerCase();return Y_.has(r)}function Gf(t,e){if(process.platform!=="win32")return e??{};let r={...e??{}};return X_(t)&&r.shell===void 0&&(r.shell=!0),r.windowsHide===void 0&&(r.windowsHide=!0),r}function rt(t,e=[],r={}){return J_(t,e,Gf(t,r))}function qf(t,e=[],r={}){return Q_(t,e,Gf(t,r))}var Y_,Hf,Q_,Vt=et(()=>{"use strict";Y_=new Set(["npm","npx","yarn","pnpm","coze","tsx","claude-agent-acp","codex-acp","openclaw"]),Hf=/\.(cmd|bat|ps1)$/i;Q_=Z_(V_)});var Zt=ae((VR,Lh)=>{"use strict";var Dh=["nodebuffer","arraybuffer","fragments"],Oh=typeof Blob<"u";Oh&&Dh.push("blob");Lh.exports={BINARY_TYPES:Dh,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:Oh,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var Xi=ae((JR,Lo)=>{"use strict";var{EMPTY_BUFFER:LE}=Zt(),_l=Buffer[Symbol.species];function NE(t,e){if(t.length===0)return LE;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 _l(r.buffer,r.byteOffset,i):r}function Nh(t,e,r,i,o){for(let c=0;c<o;c++)r[i+c]=t[c]^e[c&3]}function Mh(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function ME(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function yl(t){if(yl.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new _l(t):ArrayBuffer.isView(t)?e=new _l(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),yl.readOnly=!1),e}Lo.exports={concat:NE,mask:Nh,toArrayBuffer:ME,toBuffer:yl,unmask:Mh};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=ue("bufferutil");Lo.exports.mask=function(e,r,i,o,c){c<48?Nh(e,r,i,o,c):t.mask(e,r,i,o,c)},Lo.exports.unmask=function(e,r){e.length<32?Mh(e,r):t.unmask(e,r)}}catch{}});var zh=ae((ZR,Fh)=>{"use strict";var Bh=Symbol("kDone"),bl=Symbol("kRun"),El=class{constructor(e){this[Bh]=()=>{this.pending--,this[bl]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[bl]()}[bl](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[Bh])}}};Fh.exports=El});var Ur=ae((YR,qh)=>{"use strict";var Qi=ue("zlib"),Uh=Xi(),BE=zh(),{kStatusCode:Hh}=Zt(),FE=Buffer[Symbol.species],zE=Buffer.from([0,0,255,255]),Mo=Symbol("permessage-deflate"),Yt=Symbol("total-length"),Fr=Symbol("callback"),An=Symbol("buffers"),zr=Symbol("error"),No,vl=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,!No){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;No=new BE(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[Fr];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){No.add(o=>{this._decompress(e,r,(c,l)=>{o(),i(c,l)})})}compress(e,r,i){No.add(o=>{this._compress(e,r,(c,l)=>{o(),i(c,l)})})}_decompress(e,r,i){let o=this._isServer?"client":"server";if(!this._inflate){let c=`${o}_max_window_bits`,l=typeof this.params[c]!="number"?Qi.Z_DEFAULT_WINDOWBITS:this.params[c];this._inflate=Qi.createInflateRaw({...this._options.zlibInflateOptions,windowBits:l}),this._inflate[Mo]=this,this._inflate[Yt]=0,this._inflate[An]=[],this._inflate.on("error",HE),this._inflate.on("data",Gh)}this._inflate[Fr]=i,this._inflate.write(e),r&&this._inflate.write(zE),this._inflate.flush(()=>{let c=this._inflate[zr];if(c){this._inflate.close(),this._inflate=null,i(c);return}let l=Uh.concat(this._inflate[An],this._inflate[Yt]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Yt]=0,this._inflate[An]=[],r&&this.params[`${o}_no_context_takeover`]&&this._inflate.reset()),i(null,l)})}_compress(e,r,i){let o=this._isServer?"server":"client";if(!this._deflate){let c=`${o}_max_window_bits`,l=typeof this.params[c]!="number"?Qi.Z_DEFAULT_WINDOWBITS:this.params[c];this._deflate=Qi.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:l}),this._deflate[Yt]=0,this._deflate[An]=[],this._deflate.on("data",UE)}this._deflate[Fr]=i,this._deflate.write(e),this._deflate.flush(Qi.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let c=Uh.concat(this._deflate[An],this._deflate[Yt]);r&&(c=new FE(c.buffer,c.byteOffset,c.length-4)),this._deflate[Fr]=null,this._deflate[Yt]=0,this._deflate[An]=[],r&&this.params[`${o}_no_context_takeover`]&&this._deflate.reset(),i(null,c)})}};qh.exports=vl;function UE(t){this[An].push(t),this[Yt]+=t.length}function Gh(t){if(this[Yt]+=t.length,this[Mo]._maxPayload<1||this[Yt]<=this[Mo]._maxPayload){this[An].push(t);return}this[zr]=new RangeError("Max payload size exceeded"),this[zr].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[zr][Hh]=1009,this.removeListener("data",Gh),this.reset()}function HE(t){if(this[Mo]._inflate=null,this[zr]){this[Fr](this[zr]);return}t[Hh]=1007,this[Fr](t)}});var Hr=ae((XR,Bo)=>{"use strict";var{isUtf8:jh}=ue("buffer"),{hasBlob:GE}=Zt(),qE=[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 jE(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function Sl(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 WE(t){return GE&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}Bo.exports={isBlob:WE,isValidStatusCode:jE,isValidUTF8:Sl,tokenChars:qE};if(jh)Bo.exports.isValidUTF8=function(t){return t.length<24?Sl(t):jh(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=ue("utf-8-validate");Bo.exports.isValidUTF8=function(e){return e.length<32?Sl(e):t(e)}}catch{}});var Cl=ae((QR,Yh)=>{"use strict";var{Writable:KE}=ue("stream"),Wh=Ur(),{BINARY_TYPES:$E,EMPTY_BUFFER:Kh,kStatusCode:VE,kWebSocket:JE}=Zt(),{concat:Il,toArrayBuffer:ZE,unmask:YE}=Xi(),{isValidStatusCode:XE,isValidUTF8:$h}=Hr(),Fo=Buffer[Symbol.species],xt=0,Vh=1,Jh=2,Zh=3,Al=4,Tl=5,zo=6,kl=class extends KE{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||$E[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[JE]=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=xt}_write(e,r,i){if(this._opcode===8&&this._state==xt)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 Fo(i.buffer,i.byteOffset+e,i.length-e),new Fo(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 Fo(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 xt:this.getInfo(e);break;case Vh:this.getPayloadLength16(e);break;case Jh:this.getPayloadLength64(e);break;case Zh:this.getMask();break;case Al:this.getData(e);break;case Tl:case zo: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[Wh.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=Vh:this._payloadLength===127?this._state=Jh: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=Zh:this._state=Al}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Al}getData(e){let r=Kh;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&&YE(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._compressed){this._state=Tl,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[Wh.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 l=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");r(l);return}if(this._maxFragments>0&&this._fragments.length>=this._maxFragments){let l=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");r(l);return}this._fragments.push(c)}this.dataMessage(r),this._state===xt&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=xt;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=Il(i,r):this._binaryType==="arraybuffer"?o=ZE(Il(i,r)):this._binaryType==="blob"?o=new Blob(i):o=i,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=xt):(this._state=zo,setImmediate(()=>{this.emit("message",o,!0),this._state=xt,this.startLoop(e)}))}else{let o=Il(i,r);if(!this._skipUTF8Validation&&!$h(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(c);return}this._state===Tl||this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=xt):(this._state=zo,setImmediate(()=>{this.emit("message",o,!1),this._state=xt,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,Kh),this.end();else{let i=e.readUInt16BE(0);if(!XE(i)){let c=this.createError(RangeError,`invalid status code ${i}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(c);return}let o=new Fo(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!$h(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=xt;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=xt):(this._state=zo,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=xt,this.startLoop(r)}))}createError(e,r,i,o,c){this._loop=!1,this._errored=!0;let l=new e(i?`Invalid WebSocket frame: ${r}`:r);return Error.captureStackTrace(l,this.createError),l.code=c,l[VE]=o,l}};Yh.exports=kl});var Dl=ae((tP,ex)=>{"use strict";var{Duplex:eP}=ue("stream"),{randomFillSync:QE}=ue("crypto"),{types:{isUint8Array:ev}}=ue("util"),Xh=Ur(),{EMPTY_BUFFER:tv,kWebSocket:nv,NOOP:rv}=Zt(),{isBlob:Gr,isValidStatusCode:iv}=Hr(),{mask:Qh,toBuffer:Vn}=Xi(),pt=Symbol("kByteLength"),sv=Buffer.alloc(4),Uo=8*1024,Jn,qr=Uo,St=0,ov=1,av=2,Rl=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=St,this.onerror=rv,this[nv]=void 0}static frame(e,r){let i,o=!1,c=2,l=!1;r.mask&&(i=r.maskBuffer||sv,r.generateMask?r.generateMask(i):(qr===Uo&&(Jn===void 0&&(Jn=Buffer.alloc(Uo)),QE(Jn,0,Uo),qr=0),i[0]=Jn[qr++],i[1]=Jn[qr++],i[2]=Jn[qr++],i[3]=Jn[qr++]),l=(i[0]|i[1]|i[2]|i[3])===0,c=6);let u;typeof e=="string"?(!r.mask||l)&&r[pt]!==void 0?u=r[pt]:(e=Buffer.from(e),u=e.length):(u=e.length,o=r.mask&&r.readOnly&&!l);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],l?[x,e]:o?(Qh(e,i,x,c,u),[x]):(Qh(e,i,e,0,u),[x,e])):[x,e]}close(e,r,i,o){let c;if(e===void 0)c=tv;else{if(typeof e!="number"||!iv(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(ev(r))c.set(r,2);else throw new TypeError("Second argument must be a string or a Uint8Array")}}let l={[pt]:c.length,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==St?this.enqueue([this.dispatch,c,!1,l,o]):this.sendFrame(t.frame(c,l),o)}ping(e,r,i){let o,c;if(typeof e=="string"?(o=Buffer.byteLength(e),c=!1):Gr(e)?(o=e.size,c=!1):(e=Vn(e),o=e.length,c=Vn.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let l={[pt]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:c,rsv1:!1};Gr(e)?this._state!==St?this.enqueue([this.getBlobData,e,!1,l,i]):this.getBlobData(e,!1,l,i):this._state!==St?this.enqueue([this.dispatch,e,!1,l,i]):this.sendFrame(t.frame(e,l),i)}pong(e,r,i){let o,c;if(typeof e=="string"?(o=Buffer.byteLength(e),c=!1):Gr(e)?(o=e.size,c=!1):(e=Vn(e),o=e.length,c=Vn.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let l={[pt]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:c,rsv1:!1};Gr(e)?this._state!==St?this.enqueue([this.getBlobData,e,!1,l,i]):this.getBlobData(e,!1,l,i):this._state!==St?this.enqueue([this.dispatch,e,!1,l,i]):this.sendFrame(t.frame(e,l),i)}send(e,r,i){let o=this._extensions[Xh.extensionName],c=r.binary?2:1,l=r.compress,u,f;typeof e=="string"?(u=Buffer.byteLength(e),f=!1):Gr(e)?(u=e.size,f=!1):(e=Vn(e),u=e.length,f=Vn.readOnly),this._firstFragment?(this._firstFragment=!1,l&&o&&o.params[o._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(l=u>=o._threshold),this._compress=l):(l=!1,c=0),r.fin&&(this._firstFragment=!0);let x={[pt]:u,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:c,readOnly:f,rsv1:l};Gr(e)?this._state!==St?this.enqueue([this.getBlobData,e,this._compress,x,i]):this.getBlobData(e,this._compress,x,i):this._state!==St?this.enqueue([this.dispatch,e,this._compress,x,i]):this.dispatch(e,this._compress,x,i)}getBlobData(e,r,i,o){this._bufferedBytes+=i[pt],this._state=av,e.arrayBuffer().then(c=>{if(this._socket.destroyed){let u=new Error("The socket was closed while the blob was being read");process.nextTick(Pl,this,u,o);return}this._bufferedBytes-=i[pt];let l=Vn(c);r?this.dispatch(l,r,i,o):(this._state=St,this.sendFrame(t.frame(l,i),o),this.dequeue())}).catch(c=>{process.nextTick(cv,this,c,o)})}dispatch(e,r,i,o){if(!r){this.sendFrame(t.frame(e,i),o);return}let c=this._extensions[Xh.extensionName];this._bufferedBytes+=i[pt],this._state=ov,c.compress(e,i.fin,(l,u)=>{if(this._socket.destroyed){let f=new Error("The socket was closed while data was being compressed");Pl(this,f,o);return}this._bufferedBytes-=i[pt],this._state=St,i.readOnly=!1,this.sendFrame(t.frame(u,i),o),this.dequeue()})}dequeue(){for(;this._state===St&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][pt],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][pt],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)}};ex.exports=Rl;function Pl(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 cv(t,e,r){Pl(t,e,r),t.onerror(e)}});var lx=ae((nP,cx)=>{"use strict";var{kForOnEventAttribute:es,kListener:Ol}=Zt(),tx=Symbol("kCode"),nx=Symbol("kData"),rx=Symbol("kError"),ix=Symbol("kMessage"),sx=Symbol("kReason"),jr=Symbol("kTarget"),ox=Symbol("kType"),ax=Symbol("kWasClean"),Xt=class{constructor(e){this[jr]=null,this[ox]=e}get target(){return this[jr]}get type(){return this[ox]}};Object.defineProperty(Xt.prototype,"target",{enumerable:!0});Object.defineProperty(Xt.prototype,"type",{enumerable:!0});var Zn=class extends Xt{constructor(e,r={}){super(e),this[tx]=r.code===void 0?0:r.code,this[sx]=r.reason===void 0?"":r.reason,this[ax]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[tx]}get reason(){return this[sx]}get wasClean(){return this[ax]}};Object.defineProperty(Zn.prototype,"code",{enumerable:!0});Object.defineProperty(Zn.prototype,"reason",{enumerable:!0});Object.defineProperty(Zn.prototype,"wasClean",{enumerable:!0});var Wr=class extends Xt{constructor(e,r={}){super(e),this[rx]=r.error===void 0?null:r.error,this[ix]=r.message===void 0?"":r.message}get error(){return this[rx]}get message(){return this[ix]}};Object.defineProperty(Wr.prototype,"error",{enumerable:!0});Object.defineProperty(Wr.prototype,"message",{enumerable:!0});var ts=class extends Xt{constructor(e,r={}){super(e),this[nx]=r.data===void 0?null:r.data}get data(){return this[nx]}};Object.defineProperty(ts.prototype,"data",{enumerable:!0});var lv={addEventListener(t,e,r={}){for(let o of this.listeners(t))if(!r[es]&&o[Ol]===e&&!o[es])return;let i;if(t==="message")i=function(c,l){let u=new ts("message",{data:l?c:c.toString()});u[jr]=this,Ho(e,this,u)};else if(t==="close")i=function(c,l){let u=new Zn("close",{code:c,reason:l.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});u[jr]=this,Ho(e,this,u)};else if(t==="error")i=function(c){let l=new Wr("error",{error:c,message:c.message});l[jr]=this,Ho(e,this,l)};else if(t==="open")i=function(){let c=new Xt("open");c[jr]=this,Ho(e,this,c)};else return;i[es]=!!r[es],i[Ol]=e,r.once?this.once(t,i):this.on(t,i)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[Ol]===e&&!r[es]){this.removeListener(t,r);break}}};cx.exports={CloseEvent:Zn,ErrorEvent:Wr,Event:Xt,EventTarget:lv,MessageEvent:ts};function Ho(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var Go=ae((rP,dx)=>{"use strict";var{tokenChars:ns}=Hr();function Nt(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function dv(t){let e=Object.create(null),r=Object.create(null),i=!1,o=!1,c=!1,l,u,f=-1,x=-1,p=-1,m=0;for(;m<t.length;m++)if(x=t.charCodeAt(m),l===void 0)if(p===-1&&ns[x]===1)f===-1&&(f=m);else if(m!==0&&(x===32||x===9))p===-1&&f!==-1&&(p=m);else if(x===59||x===44){if(f===-1)throw new SyntaxError(`Unexpected character at index ${m}`);p===-1&&(p=m);let _=t.slice(f,p);x===44?(Nt(e,_,r),r=Object.create(null)):l=_,f=p=-1}else throw new SyntaxError(`Unexpected character at index ${m}`);else if(u===void 0)if(p===-1&&ns[x]===1)f===-1&&(f=m);else if(x===32||x===9)p===-1&&f!==-1&&(p=m);else if(x===59||x===44){if(f===-1)throw new SyntaxError(`Unexpected character at index ${m}`);p===-1&&(p=m),Nt(r,t.slice(f,p),!0),x===44&&(Nt(e,l,r),r=Object.create(null),l=void 0),f=p=-1}else if(x===61&&f!==-1&&p===-1)u=t.slice(f,m),f=p=-1;else throw new SyntaxError(`Unexpected character at index ${m}`);else if(o){if(ns[x]!==1)throw new SyntaxError(`Unexpected character at index ${m}`);f===-1?f=m:i||(i=!0),o=!1}else if(c)if(ns[x]===1)f===-1&&(f=m);else if(x===34&&f!==-1)c=!1,p=m;else if(x===92)o=!0;else throw new SyntaxError(`Unexpected character at index ${m}`);else if(x===34&&t.charCodeAt(m-1)===61)c=!0;else if(p===-1&&ns[x]===1)f===-1&&(f=m);else if(f!==-1&&(x===32||x===9))p===-1&&(p=m);else if(x===59||x===44){if(f===-1)throw new SyntaxError(`Unexpected character at index ${m}`);p===-1&&(p=m);let _=t.slice(f,p);i&&(_=_.replace(/\\/g,""),i=!1),Nt(r,u,_),x===44&&(Nt(e,l,r),r=Object.create(null),l=void 0),u=void 0,f=p=-1}else throw new SyntaxError(`Unexpected character at index ${m}`);if(f===-1||c||x===32||x===9)throw new SyntaxError("Unexpected end of input");p===-1&&(p=m);let v=t.slice(f,p);return l===void 0?Nt(e,v,r):(u===void 0?Nt(r,v,!0):i?Nt(r,u,v.replace(/\\/g,"")):Nt(r,u,v),Nt(e,l,r)),e}function uv(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(l=>l===!0?o:`${o}=${l}`).join("; ")})).join("; ")).join(", ")}).join(", ")}dx.exports={format:uv,parse:dv}});var Ko=ae((oP,vx)=>{"use strict";var fv=ue("events"),hv=ue("https"),xv=ue("http"),hx=ue("net"),pv=ue("tls"),{randomBytes:gv,createHash:mv}=ue("crypto"),{Duplex:iP,Readable:sP}=ue("stream"),{URL:Ll}=ue("url"),Tn=Ur(),wv=Cl(),_v=Dl(),{isBlob:yv}=Hr(),{BINARY_TYPES:ux,CLOSE_TIMEOUT:bv,EMPTY_BUFFER:qo,GUID:Ev,kForOnEventAttribute:Nl,kListener:vv,kStatusCode:Sv,kWebSocket:qe,NOOP:xx}=Zt(),{EventTarget:{addEventListener:Iv,removeEventListener:Av}}=lx(),{format:Tv,parse:kv}=Go(),{toBuffer:Cv}=Xi(),px=Symbol("kAborted"),Ml=[8,13],Qt=["CONNECTING","OPEN","CLOSING","CLOSED"],Rv=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,me=class t extends fv{constructor(e,r,i){super(),this._binaryType=ux[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=qo,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]),gx(this,e,r,i)):(this._autoPong=i.autoPong,this._closeTimeout=i.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){ux.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 wv({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 _v(e,this._extensions,i.generateMask);this._receiver=o,this._sender=c,this._socket=e,o[qe]=this,c[qe]=this,e[qe]=this,o.on("conclude",Ov),o.on("drain",Lv),o.on("error",Nv),o.on("message",Mv),o.on("ping",Bv),o.on("pong",Fv),c.onerror=zv,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",yx),e.on("data",Wo),e.on("end",bx),e.on("error",Ex),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){at(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())}),_x(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){Bl(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||qo,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){Bl(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||qo,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){Bl(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||qo,o,i)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){at(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(me,"CONNECTING",{enumerable:!0,value:Qt.indexOf("CONNECTING")});Object.defineProperty(me.prototype,"CONNECTING",{enumerable:!0,value:Qt.indexOf("CONNECTING")});Object.defineProperty(me,"OPEN",{enumerable:!0,value:Qt.indexOf("OPEN")});Object.defineProperty(me.prototype,"OPEN",{enumerable:!0,value:Qt.indexOf("OPEN")});Object.defineProperty(me,"CLOSING",{enumerable:!0,value:Qt.indexOf("CLOSING")});Object.defineProperty(me.prototype,"CLOSING",{enumerable:!0,value:Qt.indexOf("CLOSING")});Object.defineProperty(me,"CLOSED",{enumerable:!0,value:Qt.indexOf("CLOSED")});Object.defineProperty(me.prototype,"CLOSED",{enumerable:!0,value:Qt.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(me.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(me.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[Nl])return e[vv];return null},set(e){for(let r of this.listeners(t))if(r[Nl]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[Nl]:!0})}})});me.prototype.addEventListener=Iv;me.prototype.removeEventListener=Av;vx.exports=me;function gx(t,e,r,i){let o={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:bv,protocolVersion:Ml[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,!Ml.includes(o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${Ml.join(", ")})`);let c;if(e instanceof Ll)c=e;else try{c=new Ll(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 l=c.protocol==="wss:",u=c.protocol==="ws+unix:",f;if(c.protocol!=="ws:"&&!l&&!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=l?443:80,p=gv(16).toString("base64"),m=l?hv.request:xv.request,v=new Set,_;if(o.createConnection=o.createConnection||(l?Dv:Pv),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":p,Connection:"Upgrade",Upgrade:"websocket"},o.path=c.pathname+c.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&(_=new Tn({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers["Sec-WebSocket-Extensions"]=Tv({[Tn.extensionName]:_.offer()})),r.length){for(let I of r){if(typeof I!="string"||!Rv.test(I)||v.has(I))throw new SyntaxError("An invalid or duplicated subprotocol was specified");v.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 b;if(o.followRedirects){if(t._redirects===0){t._originalIpc=u,t._originalSecure=l,t._originalHostOrSocketPath=u?o.socketPath:c.host;let I=i&&i.headers;if(i={...i,headers:{}},I)for(let[A,k]of Object.entries(I))i.headers[A.toLowerCase()]=k}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&&!l)&&(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=m(o),t._redirects&&t.emit("redirect",t.url,b)}else b=t._req=m(o);o.timeout&&b.on("timeout",()=>{at(t,b,"Opening handshake has timed out")}),b.on("error",I=>{b===null||b[px]||(b=t._req=null,jo(t,I))}),b.on("response",I=>{let A=I.headers.location,k=I.statusCode;if(A&&o.followRedirects&&k>=300&&k<400){if(++t._redirects>o.maxRedirects){at(t,b,"Maximum redirects exceeded");return}b.abort();let P;try{P=new Ll(A,e)}catch{let R=new SyntaxError(`Invalid URL: ${A}`);jo(t,R);return}gx(t,P,r,i)}else t.emit("unexpected-response",b,I)||at(t,b,`Unexpected server response: ${I.statusCode}`)}),b.on("upgrade",(I,A,k)=>{if(t.emit("upgrade",I),t.readyState!==me.CONNECTING)return;b=t._req=null;let P=I.headers.upgrade;if(P===void 0||P.toLowerCase()!=="websocket"){at(t,A,"Invalid Upgrade header");return}let y=mv("sha1").update(p+Ev).digest("base64");if(I.headers["sec-websocket-accept"]!==y){at(t,A,"Invalid Sec-WebSocket-Accept header");return}let R=I.headers["sec-websocket-protocol"],O;if(R!==void 0?v.size?v.has(R)||(O="Server sent an invalid subprotocol"):O="Server sent a subprotocol but none was requested":v.size&&(O="Server sent no subprotocol"),O){at(t,A,O);return}R&&(t._protocol=R);let F=I.headers["sec-websocket-extensions"];if(F!==void 0){if(!_){at(t,A,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let M;try{M=kv(F)}catch{at(t,A,"Invalid Sec-WebSocket-Extensions header");return}let V=Object.keys(M);if(V.length!==1||V[0]!==Tn.extensionName){at(t,A,"Server indicated an extension that was not requested");return}try{_.accept(M[Tn.extensionName])}catch{at(t,A,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[Tn.extensionName]=_}t.setSocket(A,k,{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=me.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function Pv(t){return t.path=t.socketPath,hx.connect(t)}function Dv(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=hx.isIP(t.host)?"":t.host),pv.connect(t)}function at(t,e,r){t._readyState=me.CLOSING;let i=new Error(r);Error.captureStackTrace(i,at),e.setHeader?(e[px]=!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 Bl(t,e,r){if(e){let i=yv(e)?e.size:Cv(e).length;t._socket?t._sender._bufferedBytes+=i:t._bufferedAmount+=i}if(r){let i=new Error(`WebSocket is not open: readyState ${t.readyState} (${Qt[t.readyState]})`);process.nextTick(r,i)}}function Ov(t,e){let r=this[qe];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[qe]!==void 0&&(r._socket.removeListener("data",Wo),process.nextTick(mx,r._socket),t===1005?r.close():r.close(t,e))}function Lv(){let t=this[qe];t.isPaused||t._socket.resume()}function Nv(t){let e=this[qe];e._socket[qe]!==void 0&&(e._socket.removeListener("data",Wo),process.nextTick(mx,e._socket),e.close(t[Sv])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function fx(){this[qe].emitClose()}function Mv(t,e){this[qe].emit("message",t,e)}function Bv(t){let e=this[qe];e._autoPong&&e.pong(t,!this._isServer,xx),e.emit("ping",t)}function Fv(t){this[qe].emit("pong",t)}function mx(t){t.resume()}function zv(t){let e=this[qe];e.readyState!==me.CLOSED&&(e.readyState===me.OPEN&&(e._readyState=me.CLOSING,_x(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function _x(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function yx(){let t=this[qe];if(this.removeListener("close",yx),this.removeListener("data",Wo),this.removeListener("end",bx),t._readyState=me.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[qe]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",fx),t._receiver.on("finish",fx))}function Wo(t){this[qe]._receiver.write(t)||this.pause()}function bx(){let t=this[qe];t._readyState=me.CLOSING,t._receiver.end(),this.end()}function Ex(){let t=this[qe];this.removeListener("error",Ex),this.on("error",xx),t&&(t._readyState=me.CLOSING,this.destroy())}});var Tx=ae((cP,Ax)=>{"use strict";var aP=Ko(),{Duplex:Uv}=ue("stream");function Sx(t){t.emit("close")}function Hv(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Ix(t){this.removeListener("error",Ix),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function Gv(t,e){let r=!0,i=new Uv({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(c,l){let u=!l&&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(Sx,i);return}let l=!1;t.once("error",function(f){l=!0,c(f)}),t.once("close",function(){l||c(o),process.nextTick(Sx,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,l){if(t.readyState===t.CONNECTING){t.once("open",function(){i._write(o,c,l)});return}t.send(o,l)},i.on("end",Hv),i.on("error",Ix),i}Ax.exports=Gv});var Fl=ae((lP,kx)=>{"use strict";var{tokenChars:qv}=Hr();function jv(t){let e=new Set,r=-1,i=-1,o=0;for(o;o<t.length;o++){let l=t.charCodeAt(o);if(i===-1&&qv[l]===1)r===-1&&(r=o);else if(o!==0&&(l===32||l===9))i===-1&&r!==-1&&(i=o);else if(l===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}kx.exports={parse:jv}});var Nx=ae((uP,Lx)=>{"use strict";var Wv=ue("events"),$o=ue("http"),{Duplex:dP}=ue("stream"),{createHash:Kv}=ue("crypto"),Cx=Go(),Yn=Ur(),$v=Fl(),Vv=Ko(),{CLOSE_TIMEOUT:Jv,GUID:Zv,kWebSocket:Yv}=Zt(),Xv=/^[+/0-9A-Za-z]{22}==$/,Rx=0,Px=1,Ox=2,zl=class extends Wv{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:Jv,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:Vv,...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=$o.createServer((i,o)=>{let c=$o.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=Qv(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(o,c,l)=>{this.handleUpgrade(o,c,l,i)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=Rx}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===Ox){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!==Px)if(this._state=Px,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",Dx);let c=e.headers["sec-websocket-key"],l=e.headers.upgrade,u=+e.headers["sec-websocket-version"];if(e.method!=="GET"){Xn(this,e,r,405,"Invalid HTTP method");return}if(l===void 0||l.toLowerCase()!=="websocket"){Xn(this,e,r,400,"Invalid Upgrade header");return}if(c===void 0||!Xv.test(c)){Xn(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(u!==13&&u!==8){Xn(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=$v.parse(f)}catch{Xn(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let p=e.headers["sec-websocket-extensions"],m={};if(this.options.perMessageDeflate&&p!==void 0){let v=new Yn({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let _=Cx.parse(p);_[Yn.extensionName]&&(v.accept(_[Yn.extensionName]),m[Yn.extensionName]=v)}catch{Xn(this,e,r,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,(_,b,I,A)=>{if(!_)return is(r,b||401,I,A);this.completeUpgrade(m,c,x,e,r,i,o)});return}if(!this.options.verifyClient(v))return is(r,401)}this.completeUpgrade(m,c,x,e,r,i,o)}completeUpgrade(e,r,i,o,c,l,u){if(!c.readable||!c.writable)return c.destroy();if(c[Yv])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Rx)return is(c,503);let x=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Kv("sha1").update(r+Zv).digest("base64")}`],p=new this.options.WebSocket(null,void 0,this.options);if(i.size){let m=this.options.handleProtocols?this.options.handleProtocols(i,o):i.values().next().value;m&&(x.push(`Sec-WebSocket-Protocol: ${m}`),p._protocol=m)}if(e[Yn.extensionName]){let m=e[Yn.extensionName].params,v=Cx.format({[Yn.extensionName]:[m]});x.push(`Sec-WebSocket-Extensions: ${v}`),p._extensions=e}this.emit("headers",x,o),c.write(x.concat(`\r
|
|
10
|
+
`),this.stream=void 0;return}this.currentDate!==void 0&&ps(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 jg,mkdirSync as Wg}from"node:fs";import{join as Kg}from"node:path";function kd(t){let e=t.retentionDays??Zg,r=t.clock??(()=>Dn(new Date));ms={bridgeSink:new ni(t.bridgeLogsDir,"bridge",{retentionDays:e,clock:r}),agentSinks:new Map,makeAgentSink:o=>new ni(t.agentLogsDir(o),"agent",{retentionDays:e,clock:r})};let i=r();ps(t.bridgeLogsDir,"bridge",i,e);for(let o of t.listAgentIds?.()??[])ps(t.agentLogsDir(o),"agent",i,e)}function Jg(t,e){let r=t.agentSinks.get(e);return r||(r=t.makeAgentSink(e),t.agentSinks.set(e,r)),r}function Td(t){Na=t}function Rd(t){return ar[Na]<=ar[t]}function Cd(t,e){let r=ar[t];return r===void 0?!0:r>=ar[e]}function ws(t){Ad={...t}}function Dd(t){let e=(u,x=2)=>String(u).padStart(x,"0"),r=-t.getTimezoneOffset(),i=r>=0?"+":"-",o=Math.abs(r),c=e(Math.floor(o/60)),d=e(o%60);return`${Dn(t)}T${e(t.getHours())}:${e(t.getMinutes())}:${e(t.getSeconds())}.${e(t.getMilliseconds(),3)}${i}${c}:${d}`}function Tt(t,e,r,i,o){try{let c=`${JSON.stringify({ts:Dd(new Date),level:e,module:r,msg:i,...o})}
|
|
11
|
+
`;Wg(t,{recursive:!0}),jg(Kg(t,or("bridge",Dn(new Date))),c)}catch{}}function Yg(t,e){if(t)return t;let r=e?.agentId;return typeof r=="string"&&r.length>0?r:void 0}function gs(t,e,r,i,o){if(ar[t]<ar[Na])return;let c=`${JSON.stringify({ts:Dd(new Date),level:t,module:e,msg:r,...Ad,...i})}
|
|
12
|
+
`;if(ms){let d=Yg(o,i),u=d?Jg(ms,d):ms.bridgeSink;try{u.write(c)}catch{process.stderr.write(c)}return}t==="error"||t==="warn"?Vg.write(c):$g.write(c)}function j(t,e){return{debug:(r,i)=>gs("debug",t,r,i,e),info:(r,i)=>gs("info",t,r,i,e),warn:(r,i)=>gs("warn",t,r,i,e),error:(r,i)=>gs("error",t,r,i,e),child:r=>j(`${t}.${r}`,e),forAgent:r=>j(t,r)}}var ar,Na,$g,Vg,Ad,Zg,ms,re=rt(()=>{"use strict";sr();La();ar={debug:10,info:20,warn:30,error:40},Na=(()=>{let t=process.env.COZE_BRIDGE_LOG_LEVEL;return t==="debug"||t==="info"||t==="warn"||t==="error"?t:"info"})(),$g=process.stdout,Vg=process.stderr,Ad={},Zg=Ye("COZE_BRIDGE_LOG_RETENTION_DAYS",30),ms=null});var k,$e=rt(()=>{"use strict";k=class extends Error{code;retriable;cause;constructor(e,r,i){super(r),this.name="BridgeError",this.code=e,this.retriable=i?.retriable??!1,i?.cause!==void 0&&(this.cause=i.cause)}}});var Nd={};Pa(Nd,{ACP_WRAPPER_NPM_PACKAGES:()=>ii,_resetAcpInstallerForTests:()=>rm,_setBinaryPathCacheForTests:()=>im,buildAcpSpawn:()=>si,ensureAcpInstalled:()=>cr,getAcpBinaryPath:()=>_s,pickWhichLine:()=>Fa,probeAcpVersion:()=>nm,resolveAcpCommand:()=>Ld});import{readFileSync as Pd}from"node:fs";import{createRequire as Xg}from"node:module";import{dirname as Qg,resolve as em}from"node:path";function Fa(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 r=i=>e.find(o=>o.toLowerCase().endsWith(i));return r(".cmd")??r(".exe")??r(".bat")??r(".ps1")??e[0]}function tm(t){let e=Od.resolve(`${t.npmPackage}/package.json`),r=Qg(e),i=JSON.parse(Pd(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 em(r,o)}async function cr(t,e){let r=Ba[t];if(!r)throw new k("BRIDGE_INTERNAL",`ensureAcpInstalled called for non-npm framework: ${t}`);let i=ri.get(t);if(i)return i;try{let o=tm(r);return ri.set(t,o),Ma.info("acp wrapper resolved",{framework:t,binary:r.binary,path:o}),o}catch(o){throw Ma.warn("acp wrapper \u89E3\u6790\u5931\u8D25 (\u672A\u968F\u5305\u56FA\u5316\u5230 lib/node_modules?)",{framework:t,npmPackage:r.npmPackage,err:String(o)}),new k("AGENT_DEPENDENCY_INSTALL_FAILED",[`ACP wrapper \u672A\u5C31\u7EEA: ${r.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 nm(t){let e=Ba[t];if(e)try{let r=Od.resolve(`${e.npmPackage}/package.json`),i=JSON.parse(Pd(r,"utf8"));return typeof i.version=="string"&&i.version.length>0?i.version:void 0}catch(r){Ma.warn("acp wrapper probe: \u89E3\u6790 package.json \u5931\u8D25",{framework:t,npmPackage:e.npmPackage,err:String(r)});return}}function _s(t){return ri.get(t)}function Ld(t,e){if(e)return e;let r=_s(t);if(!r)throw new k("BRIDGE_INTERNAL",`${t} ACP wrapper \u8DEF\u5F84\u672A\u89E3\u6790 (ensureAcpInstalled \u672A\u5728\u6784\u9020\u524D\u8DD1\u901A)`);return r}function si(t,e,r){if(e)return{command:e,args:[...r]};let i=Ld(t);return{command:process.execPath,args:[i,...r]}}function rm(){ri.clear()}function im(t,e){ri.set(t,e)}var Ma,Ba,ii,Od,ri,cn=rt(()=>{"use strict";$e();re();Ma=j("agents.acp-installer"),Ba={"claude-code":{npmPackage:"@agentclientprotocol/claude-agent-acp",binary:"claude-agent-acp"},codex:{npmPackage:"@agentclientprotocol/codex-acp",binary:"codex-acp"}},ii=Object.values(Ba).filter(t=>t!==void 0).map(t=>t.npmPackage),Od=Xg(import.meta.url),ri=new Map});import{chmod as om,mkdir as am,readFile as cm,rename as lm,rm as dm,writeFile as um}from"node:fs/promises";import{dirname as fm}from"node:path";async function lr(t){try{let e=await cm(t,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function ut(t,e,r){await am(fm(t),{recursive:!0});let i=`${t}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{await um(i,e,{encoding:"utf8",mode:r?.mode}),await lm(i,t),r?.mode!==void 0&&await om(t,r.mode)}catch(o){throw await dm(i,{force:!0}).catch(()=>{}),o}}async function dr(t,e,r){await ut(t,`${JSON.stringify(e,null,2)}
|
|
14
|
+
`,r)}var Ht=rt(()=>{"use strict"});import{promises as Fd,readdirSync as xm}from"node:fs";import{homedir as hm}from"node:os";import{sep as pm,join as Ce,resolve as zd}from"node:path";function J(t){let e=t??hm(),r=Ce(e,".coze"),i=Ce(r,"bridge"),o=Ce(i,"lib"),c=Ce(i,"logs");return{cozeRoot:r,bridgeRoot:i,libDir:o,libEntry:Ce(o,"index.js"),binDir:Ce(i,"bin"),pidFile:Ce(i,"bridge.pid"),portFile:Ce(i,"bridge.port"),tokenFile:Ce(i,"bridge.token"),patTokenFile:Ce(i,"pat-token"),agentEnvFile:Ce(i,"agent-env.json"),logFile:Ce(i,"bridge.log"),bridgeLogsDir:c,daemonStdioLog:Ce(c,"daemon-stdio.log"),installLock:Ce(i,"install.lock"),configFile:Ce(i,"config.json"),agentsRoot:Ce(r,"agents")}}function ze(t,e=J()){let r=Ce(e.agentsRoot,t);return{root:r,config:Ce(r,"config.json"),workspace:Ce(r,"workspace"),logs:Ce(r,"logs")}}function ys(t=J()){try{return xm(t.agentsRoot,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name)}catch{return[]}}async function oi(t,e){let r=await Fd.realpath(zd(t)).catch(()=>null);if(!r)return!1;let i=await Fd.realpath(zd(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+pm)}var De=rt(()=>{"use strict"});var bs={};Pa(bs,{AGENT_CONFIG_FILE_MODE:()=>Es,enforceAgentConfigMode:()=>wm,loadAgentConfig:()=>Ie,persistAgentSessions:()=>ai,persistAgentSkills:()=>ci,saveAgentConfig:()=>Ue});import{chmod as gm,stat as mm}from"node:fs/promises";function Ie(t,e){return lr(ze(t,e).config)}function Ue(t,e){return dr(ze(t.agentId,e).config,t,{mode:Es})}async function wm(t,e){if(process.platform==="win32")return;let r=ze(t,e).config;try{let i=await mm(r);if(!i.isFile())return;let o=i.mode&511;o!==Es&&(await gm(r,Es),Ud.warn("agent config mode auto-corrected to 0600",{path:r,from:o.toString(8)}))}catch(i){if(i.code==="ENOENT")return;Ud.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:r,err:String(i)})}}async function ai(t,e,r){let i=await Ie(t,r);i&&(i.sessions=Object.fromEntries(e),await Ue(i,r))}async function ci(t,e,r){let i=await Ie(t,r);i&&(i.skills=e,await Ue(i,r))}var Ud,Es,qt=rt(()=>{"use strict";Ht();re();De();Ud=j("agent-config"),Es=384});var Ga=le((dI,qd)=>{qd.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=le(Wd=>{var jd={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 Sm(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(jd))Wd[t]=Sm(jd[t])});var Jd=le((fI,Zd)=>{var Im=he("fs"),Me=he("path"),Kd=Ga(),Am=Ss(),km=typeof process=="object"&&process.platform==="win32",$d=t=>typeof t=="object"&&t!==null,Vd=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 Ae(t){this.sep=Me.sep,this.fs=Im,$d(t)&&$d(t.fs)&&typeof t.fs.statSync=="function"&&(this.fs=t.fs)}Zd.exports=Ae;Ae.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 Am.FILE_IN_THE_WAY(`"${o}"`)}})}r(t)};Ae.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=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};Ae.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,x){if(d&&x.isDirectory())return o(!1);var h=Me.dirname(t);c.fs.exists(h,function(m){m||c.makeDir(h),c.fs.open(t,"w",438,function(w,S){w?c.fs.chmod(t,438,function(){c.fs.open(t,"w",438,function(_,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)})})})})})};Ae.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 x=Me.join(i,u),h=e.fs.statSync(x);(!o||o.test(x))&&d.push(Me.normalize(x)+(h.isDirectory()?e.sep:"")),h.isDirectory()&&c&&(d=d.concat(r(x,o,c)))}),d}return r(t,void 0,!0)};Ae.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=Me.join(t,u),r.fs.stat(u,function(x,h){if(x)return e(x);h&&(i.push(Me.normalize(u)+(h.isDirectory()?r.sep:"")),h.isDirectory()?r.findFilesAsync(u,function(m,w){if(m)return e(m);i=i.concat(w),--d||e(null,i)}):--d||e(null,i))})})})};Ae.prototype.getAttributes=function(){};Ae.prototype.setAttributes=function(){};Ae.crc32update=function(t,e){return Vd[(t^e)&255]^t>>>8};Ae.crc32=function(t){typeof t=="string"&&(t=Buffer.from(t,"utf8"));let e=t.length,r=-1;for(let i=0;i<e;)r=Ae.crc32update(r,t[i++]);return~r>>>0};Ae.methodToString=function(t){switch(t){case Kd.STORED:return"STORED ("+t+")";case Kd.DEFLATED:return"DEFLATED ("+t+")";default:return"UNSUPPORTED ("+t+")"}};Ae.canonical=function(t){if(!t)return"";let e=Me.posix.normalize("/"+t.split("\\").join("/"));return Me.join(".",e)};Ae.zipnamefix=function(t){if(!t)return"";let e=Me.posix.normalize("/"+t.split("\\").join("/"));return Me.posix.join(".",e)};Ae.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]};Ae.sanitize=function(t,e){t=Me.resolve(Me.normalize(t));for(var r=e.split("/"),i=0,o=r.length;i<o;i++){var c=Me.normalize(Me.join(t,r.slice(i,o).join(Me.sep)));if(c.indexOf(t)===0)return c}return Me.normalize(Me.join(t,Me.basename(e)))};Ae.toBuffer=function(e,r){return Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e):typeof e=="string"?r(e):Buffer.alloc(0)};Ae.readBigUInt64LE=function(t,e){let r=t.readUInt32LE(e);return t.readUInt32LE(e+4)*4294967296+r};Ae.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)};Ae.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};Ae.isWin=km;Ae.crcTable=Vd});var Xd=le((xI,Yd)=>{var Tm=he("path");Yd.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=Tm.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 eu=le((hI,Qd)=>{Qd.exports={efs:!0,encode:t=>Buffer.from(t,"utf8"),decode:t=>t.toString("utf8")}});var xr=le((pI,fr)=>{fr.exports=Jd();fr.exports.Constants=Ga();fr.exports.Errors=Ss();fr.exports.FileAttr=Xd();fr.exports.decoder=eu()});var nu=le((gI,tu)=>{var ln=xr(),H=ln.Constants;tu.exports=function(){var t=20,e=10,r=0,i=0,o=0,c=0,d=0,u=0,x=0,h=0,m=0,w=0,S=0,_=0,v=0;t|=ln.isWin?2560:768,r|=H.FLG_EFS;let I={extraLen:0},A=y=>Math.max(0,y)>>>0,T=y=>Math.max(0,y)&65535,P=y=>Math.max(0,y)&255;return o=ln.fromDate2DOS(new Date),{get made(){return t},set made(y){t=y},get version(){return e},set version(y){e=y},get flags(){return r},set flags(y){r=y},get flags_efs(){return(r&H.FLG_EFS)>0},set flags_efs(y){y?r|=H.FLG_EFS:r&=~H.FLG_EFS},get flags_desc(){return(r&H.FLG_DESC)>0},set flags_desc(y){y?r|=H.FLG_DESC:r&=~H.FLG_DESC},get method(){return i},set method(y){switch(y){case H.STORED:this.version=10;case H.DEFLATED:default:this.version=20}i=y},get time(){return ln.fromDOS2Date(this.timeval)},set time(y){y=new Date(y),this.timeval=ln.fromDate2DOS(y)},get timeval(){return o},set timeval(y){o=A(y)},get timeHighByte(){return P(o>>>8)},get crc(){return c},set crc(y){c=A(y)},get compressedSize(){return d},set compressedSize(y){d=A(y)},get size(){return u},set size(y){u=A(y)},get fileNameLength(){return x},set fileNameLength(y){x=y},get extraLength(){return h},set extraLength(y){h=y},get extraLocalLength(){return I.extraLen},set extraLocalLength(y){I.extraLen=y},get commentLength(){return m},set commentLength(y){m=y},get diskNumStart(){return w},set diskNumStart(y){w=A(y)},get inAttr(){return S},set inAttr(y){S=A(y)},get attr(){return _},set attr(y){_=A(y)},get fileAttr(){return(_||0)>>16&4095},get offset(){return v},set offset(y){v=A(y)},get encrypted(){return(r&H.FLG_ENC)===H.FLG_ENC},get centralHeaderSize(){return H.CENHDR+x+h+m},get realDataOffset(){return v+H.LOCHDR+I.fnameLen+I.extraLen},get localHeader(){return I},loadLocalHeaderFromBinary:function(y){var C=y.slice(v,v+H.LOCHDR);if(C.readUInt32LE(0)!==H.LOCSIG)throw ln.Errors.INVALID_LOC();I.version=C.readUInt16LE(H.LOCVER),I.flags=C.readUInt16LE(H.LOCFLG),I.flags_desc=(I.flags&H.FLG_DESC)>0,I.method=C.readUInt16LE(H.LOCHOW),I.time=C.readUInt32LE(H.LOCTIM),I.crc=C.readUInt32LE(H.LOCCRC),I.compressedSize=C.readUInt32LE(H.LOCSIZ),I.size=C.readUInt32LE(H.LOCLEN),I.fnameLen=C.readUInt16LE(H.LOCNAM),I.extraLen=C.readUInt16LE(H.LOCEXT);let O=v+H.LOCHDR+I.fnameLen,z=O+I.extraLen;return y.slice(O,z)},loadFromBinary:function(y){if(y.length!==H.CENHDR||y.readUInt32LE(0)!==H.CENSIG)throw ln.Errors.INVALID_CEN();t=y.readUInt16LE(H.CENVEM),e=y.readUInt16LE(H.CENVER),r=y.readUInt16LE(H.CENFLG),i=y.readUInt16LE(H.CENHOW),o=y.readUInt32LE(H.CENTIM),c=y.readUInt32LE(H.CENCRC),d=y.readUInt32LE(H.CENSIZ),u=y.readUInt32LE(H.CENLEN),x=y.readUInt16LE(H.CENNAM),h=y.readUInt16LE(H.CENEXT),m=y.readUInt16LE(H.CENCOM),w=y.readUInt16LE(H.CENDSK),S=y.readUInt16LE(H.CENATT),_=y.readUInt32LE(H.CENATX),v=y.readUInt32LE(H.CENOFF)},localHeaderToBinary:function(){var y=Buffer.alloc(H.LOCHDR);return y.writeUInt32LE(H.LOCSIG,0),y.writeUInt16LE(e,H.LOCVER),y.writeUInt16LE(r,H.LOCFLG),y.writeUInt16LE(i,H.LOCHOW),y.writeUInt32LE(o,H.LOCTIM),y.writeUInt32LE(c,H.LOCCRC),y.writeUInt32LE(d,H.LOCSIZ),y.writeUInt32LE(u,H.LOCLEN),y.writeUInt16LE(x,H.LOCNAM),y.writeUInt16LE(I.extraLen,H.LOCEXT),y},centralHeaderToBinary:function(){var y=Buffer.alloc(H.CENHDR+x+h+m);return y.writeUInt32LE(H.CENSIG,0),y.writeUInt16LE(t,H.CENVEM),y.writeUInt16LE(e,H.CENVER),y.writeUInt16LE(r,H.CENFLG),y.writeUInt16LE(i,H.CENHOW),y.writeUInt32LE(o,H.CENTIM),y.writeUInt32LE(c,H.CENCRC),y.writeUInt32LE(d,H.CENSIZ),y.writeUInt32LE(u,H.CENLEN),y.writeUInt16LE(x,H.CENNAM),y.writeUInt16LE(h,H.CENEXT),y.writeUInt16LE(m,H.CENCOM),y.writeUInt16LE(w,H.CENDSK),y.writeUInt16LE(S,H.CENATT),y.writeUInt32LE(_,H.CENATX),y.writeUInt32LE(v,H.CENOFF),y},toJSON:function(){let y=function(C){return C+" bytes"};return{made:t,version:e,flags:r,method:ln.methodToString(i),time:this.time,crc:"0x"+c.toString(16).toUpperCase(),compressedSize:y(d),size:y(u),fileNameLength:y(x),extraLength:y(h),commentLength:y(m),diskNumStart:w,inAttr:S,attr:_,offset:v,centralHeaderSize:y(H.CENHDR+x+h+m)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var iu=le((mI,ru)=>{var hr=xr(),be=hr.Constants;ru.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 be.ENDHDR+o},loadFromBinary:function(c){if((c.length!==be.ENDHDR||c.readUInt32LE(0)!==be.ENDSIG)&&(c.length<be.ZIP64HDR||c.readUInt32LE(0)!==be.ZIP64SIG))throw hr.Errors.INVALID_END();c.readUInt32LE(0)===be.ENDSIG?(t=c.readUInt16LE(be.ENDSUB),e=c.readUInt16LE(be.ENDTOT),r=c.readUInt32LE(be.ENDSIZ),i=c.readUInt32LE(be.ENDOFF),o=c.readUInt16LE(be.ENDCOM)):(t=hr.readBigUInt64LE(c,be.ZIP64SUB),e=hr.readBigUInt64LE(c,be.ZIP64TOT),r=hr.readBigUInt64LE(c,be.ZIP64SIZE),i=hr.readBigUInt64LE(c,be.ZIP64OFF),o=0)},toBinary:function(){var c=Buffer.alloc(be.ENDHDR+o);return c.writeUInt32LE(be.ENDSIG,0),c.writeUInt32LE(0,4),c.writeUInt16LE(t,be.ENDSUB),c.writeUInt16LE(e,be.ENDTOT),c.writeUInt32LE(r,be.ENDSIZ),c.writeUInt32LE(i,be.ENDOFF),c.writeUInt16LE(o,be.ENDCOM),c.fill(" ",be.ENDHDR),c},toJSON:function(){let c=function(d,u){let x=d.toString(16).toUpperCase();for(;x.length<u;)x="0"+x;return"0x"+x};return{diskEntries:t,totalEntries:e,size:r+" bytes",offset:c(i,4),commentLength:o}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var qa=le(Ha=>{Ha.EntryHeader=nu();Ha.MainHeader=iu()});var ou=le((_I,su)=>{su.exports=function(t){var e=he("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),x=0;u.fill(0);for(var h=0;h<c.length;h++){var m=c[h];m.copy(u,x),x+=m.length}i&&i(u)}),o.end(t)}}}});var cu=le((yI,au)=>{var Rm=+(process.versions?process.versions.node:"").split(".")[0]||0;au.exports=function(t,e){var r=he("zlib");let i=Rm>=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(x){d.push(x),u+=x.length}),c.on("end",function(){var x=Buffer.alloc(u),h=0;x.fill(0);for(var m=0;m<d.length;m++){var w=d[m];w.copy(x,h),h+=w.length}o&&o(x)}),c.end(t)}}}});var xu=le((EI,fu)=>{"use strict";var{randomFillSync:lu}=he("crypto"),Cm=Ss(),Dm=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}),uu=(t,e)=>Math.imul(t,e)>>>0,du=(t,e)=>Dm[(t^e)&255]^t>>>8,li=()=>typeof lu=="function"?lu(Buffer.alloc(12)):li.node();li.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 Is={genSalt:li};function As(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])}As.prototype.updateKeys=function(t){let e=this.keys;return e[0]=du(e[0],t),e[1]+=e[0]&255,e[1]=uu(e[1],134775813)+1,e[2]=du(e[2],e[1]>>>24),t};As.prototype.next=function(){let t=(this.keys[2]|2)>>>0;return uu(t,t^1)>>8&255};function Pm(t){let e=new As(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 Om(t){let e=new As(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 Lm(t,e,r){if(!t||!Buffer.isBuffer(t)||t.length<12)return Buffer.alloc(0);let i=Pm(r),o=i(t.slice(0,12)),c=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(o[11]!==c)throw Cm.WRONG_PASSWORD();return i(t.slice(12))}function Nm(t){Buffer.isBuffer(t)&&t.length>=12?Is.genSalt=function(){return t.slice(0,12)}:t==="node"?Is.genSalt=li.node:Is.genSalt=li}function Mm(t,e,r,i=!1){t==null&&(t=Buffer.alloc(0)),Buffer.isBuffer(t)||(t=Buffer.from(t.toString()));let o=Om(r),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)}fu.exports={decrypt:Lm,encrypt:Mm,_salter:Nm}});var hu=le(ks=>{ks.Deflater=ou();ks.Inflater=cu();ks.ZipCrypto=xu()});var Wa=le((vI,pu)=>{var de=xr(),Bm=qa(),ke=de.Constants,ja=hu();pu.exports=function(t,e){var r=new Bm.EntryHeader,i=Buffer.alloc(0),o=Buffer.alloc(0),c=!1,d=null,u=Buffer.alloc(0),x=Buffer.alloc(0),h=!0;let m=t,w=typeof m.decoder=="object"?m.decoder:de.decoder;h=w.hasOwnProperty("efs")?w.efs:!1;function S(){return!e||!(e instanceof Uint8Array)?Buffer.alloc(0):(x=r.loadLocalHeaderFromBinary(e),e.slice(r.realDataOffset,r.realDataOffset+r.compressedSize))}function _(y){if(!r.flags_desc&&!r.localHeader.flags_desc){if(de.crc32(y)!==r.localHeader.crc)return!1}else{let C={},O=r.realDataOffset+r.compressedSize;if(e.readUInt32LE(O)==ke.LOCSIG||e.readUInt32LE(O)==ke.CENSIG)throw de.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(O)==ke.EXTSIG)C.crc=e.readUInt32LE(O+ke.EXTCRC),C.compressedSize=e.readUInt32LE(O+ke.EXTSIZ),C.size=e.readUInt32LE(O+ke.EXTLEN);else if(e.readUInt16LE(O+12)===19280)C.crc=e.readUInt32LE(O+ke.EXTCRC-4),C.compressedSize=e.readUInt32LE(O+ke.EXTSIZ-4),C.size=e.readUInt32LE(O+ke.EXTLEN-4);else throw de.Errors.DESCRIPTOR_UNKNOWN();if(C.compressedSize!==r.compressedSize||C.size!==r.size||C.crc!==r.crc)throw de.Errors.DESCRIPTOR_FAULTY();if(de.crc32(y)!==C.crc)return!1}return!0}function v(y,C,O){if(typeof C>"u"&&typeof y=="string"&&(O=y,y=void 0),c)return y&&C&&C(Buffer.alloc(0),de.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var z=S();if(z.length===0)return y&&C&&C(z),z;if(r.encrypted){if(typeof O!="string"&&!Buffer.isBuffer(O))throw de.Errors.INVALID_PASS_PARAM();z=ja.ZipCrypto.decrypt(z,r,O)}var F=Buffer.alloc(r.size);switch(r.method){case de.Constants.STORED:if(z.copy(F),_(F))return y&&C&&C(F),F;throw y&&C&&C(F,de.Errors.BAD_CRC()),de.Errors.BAD_CRC();case de.Constants.DEFLATED:var Z=new ja.Inflater(z,r.size);if(y)Z.inflateAsync(function(V){V.copy(V,0),C&&(_(V)?C(V):C(V,de.Errors.BAD_CRC()))});else{if(Z.inflate(F).copy(F,0),!_(F))throw de.Errors.BAD_CRC(`"${w.decode(i)}"`);return F}break;default:throw y&&C&&C(Buffer.alloc(0),de.Errors.UNKNOWN_METHOD()),de.Errors.UNKNOWN_METHOD()}}function I(y,C){if((!d||!d.length)&&Buffer.isBuffer(e))return y&&C&&C(S()),S();if(d.length&&!c){var O;switch(r.method){case de.Constants.STORED:return r.compressedSize=r.size,O=Buffer.alloc(d.length),d.copy(O),y&&C&&C(O),O;default:case de.Constants.DEFLATED:var z=new ja.Deflater(d);if(y)z.deflateAsync(function(Z){O=Buffer.alloc(Z.length),r.compressedSize=Z.length,Z.copy(O),C&&C(O)});else{var F=z.deflate();return r.compressedSize=F.length,F}z=null;break}}else if(y&&C)C(Buffer.alloc(0));else return Buffer.alloc(0)}function A(y,C){return de.readBigUInt64LE(y,C)}function T(y){try{for(var C=0,O,z,F;C+4<y.length;)O=y.readUInt16LE(C),C+=2,z=y.readUInt16LE(C),C+=2,F=y.slice(C,C+z),C+=z,ke.ID_ZIP64===O&&P(F)}catch{throw de.Errors.EXTRA_FIELD_PARSE_ERROR()}}function P(y){var C,O,z,F;y.length>=ke.EF_ZIP64_SCOMP&&(C=A(y,ke.EF_ZIP64_SUNCOMP),r.size===ke.EF_ZIP64_OR_32&&(r.size=C)),y.length>=ke.EF_ZIP64_RHO&&(O=A(y,ke.EF_ZIP64_SCOMP),r.compressedSize===ke.EF_ZIP64_OR_32&&(r.compressedSize=O)),y.length>=ke.EF_ZIP64_DSN&&(z=A(y,ke.EF_ZIP64_RHO),r.offset===ke.EF_ZIP64_OR_32&&(r.offset=z)),y.length>=ke.EF_ZIP64_DSN+4&&(F=y.readUInt32LE(ke.EF_ZIP64_DSN),r.diskNumStart===ke.EF_ZIP64_OR_16&&(r.diskNumStart=F))}return{get entryName(){return w.decode(i)},get rawEntryName(){return i},set entryName(y){i=de.toBuffer(y,w.encode);var C=i[i.length-1];c=C===47||C===92,r.fileNameLength=i.length},get efs(){return typeof h=="function"?h(this.entryName):h},get extra(){return u},set extra(y){u=y,r.extraLength=y.length,T(y)},get comment(){return w.decode(o)},set comment(y){if(o=de.toBuffer(y,w.encode),r.commentLength=o.length,o.length>65535)throw de.Errors.COMMENT_TOO_LONG()},get name(){var y=w.decode(i);return c?y.substr(y.length-1).split("/").pop():y.split("/").pop()},get isDirectory(){return c},getCompressedData:function(){return I(!1,null)},getCompressedDataAsync:function(y){I(!0,y)},setData:function(y){d=de.toBuffer(y,de.decoder.encode),!c&&d.length?(r.size=d.length,r.method=de.Constants.DEFLATED,r.crc=de.crc32(y),r.changed=!0):r.method=de.Constants.STORED},getData:function(y){return r.changed?d:v(!1,null,y)},getDataAsync:function(y,C){r.changed?y(d):v(!0,y,C)},set attr(y){r.attr=y},get attr(){return r.attr},set header(y){r.loadFromBinary(y)},get header(){return r},packCentralHeader:function(){r.flags_efs=this.efs,r.extraLength=u.length;var y=r.centralHeaderToBinary(),C=de.Constants.CENHDR;return i.copy(y,C),C+=i.length,u.copy(y,C),C+=r.extraLength,o.copy(y,C),y},packLocalHeader:function(){let y=0;r.flags_efs=this.efs,r.extraLocalLength=x.length;let C=r.localHeaderToBinary(),O=Buffer.alloc(C.length+i.length+r.extraLocalLength);return C.copy(O,y),y+=C.length,i.copy(O,y),y+=i.length,x.copy(O,y),y+=x.length,O},toJSON:function(){let y=function(C){return"<"+(C&&C.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:r.toJSON(),compressedData:y(e),data:y(d)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var wu=le((SI,mu)=>{var gu=Wa(),Fm=qa(),Ve=xr();mu.exports=function(t,e){var r=[],i={},o=Buffer.alloc(0),c=new Fm.MainHeader,d=!1,u=null;let x=new Set,h=e,{noSort:m,decoder:w}=h;t?v(h.readEntries):d=!0;function S(){let A=new Set;for(let T of Object.keys(i)){let P=T.split("/");if(P.pop(),!!P.length)for(let y=0;y<P.length;y++){let C=P.slice(0,y+1).join("/")+"/";A.add(C)}}for(let T of A)if(!(T in i)){let P=new gu(h);P.entryName=T,P.attr=16,P.temporary=!0,r.push(P),i[P.entryName]=P,x.add(P)}}function _(){if(d=!0,i={},c.diskEntries>(t.length-c.offset)/Ve.Constants.CENHDR)throw Ve.Errors.DISK_ENTRY_TOO_LARGE();r=new Array(c.diskEntries);for(var A=c.offset,T=0;T<r.length;T++){var P=A,y=new gu(h,t);y.header=t.slice(P,P+=Ve.Constants.CENHDR),y.entryName=t.slice(P,P+=y.header.fileNameLength),y.header.extraLength&&(y.extra=t.slice(P,P+=y.header.extraLength)),y.header.commentLength&&(y.comment=t.slice(P,P+y.header.commentLength)),A+=y.header.centralHeaderSize,r[T]=y,i[y.entryName]=y}x.clear(),S()}function v(A){var T=t.length-Ve.Constants.ENDHDR,P=Math.max(0,T-65535),y=P,C=t.length,O=-1,z=0;for(typeof h.trailingSpace=="boolean"&&h.trailingSpace&&(P=0),T;T>=y;T--)if(t[T]===80){if(t.readUInt32LE(T)===Ve.Constants.ENDSIG){O=T,z=T,C=T+Ve.Constants.ENDHDR,y=T-Ve.Constants.END64HDR;continue}if(t.readUInt32LE(T)===Ve.Constants.END64SIG){y=P;continue}if(t.readUInt32LE(T)===Ve.Constants.ZIP64SIG){O=T,C=T+Ve.readBigUInt64LE(t,T+Ve.Constants.ZIP64SIZE)+Ve.Constants.ZIP64LEAD;break}}if(O==-1)throw Ve.Errors.INVALID_FORMAT();c.loadFromBinary(t.slice(O,C)),c.commentLength&&(o=t.slice(z+Ve.Constants.ENDHDR)),A&&_()}function I(){r.length>1&&!m&&r.sort((A,T)=>A.entryName.toLowerCase().localeCompare(T.entryName.toLowerCase()))}return{get entries(){return d||_(),r.filter(A=>!x.has(A))},get comment(){return w.decode(o)},set comment(A){o=Ve.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||_(),i[A]||null},setEntry:function(A){d||_(),r.push(A),i[A.entryName]=A,c.totalEntries=r.length},deleteFile:function(A,T=!0){d||_();let P=i[A];this.getEntryChildren(P,T).map(C=>C.entryName).forEach(this.deleteEntry)},deleteEntry:function(A){d||_();let T=i[A],P=r.indexOf(T);P>=0&&(r.splice(P,1),delete i[A],c.totalEntries=r.length)},getEntryChildren:function(A,T=!0){if(d||_(),typeof A=="object")if(A.isDirectory&&T){let P=[],y=A.entryName;for(let C of r)C.entryName.startsWith(y)&&P.push(C);return P}else return[A];return[]},getChildCount:function(A){if(A&&A.isDirectory){let T=this.getEntryChildren(A);return T.includes(A)?T.length-1:T.length}return 0},compressToBuffer:function(){d||_(),I();let A=[],T=[],P=0,y=0;c.size=0,c.offset=0;let C=0;for(let F of this.entries){let Z=F.getCompressedData();F.header.offset=y;let V=F.packLocalHeader(),ie=V.length+Z.length;y+=ie,A.push(V),A.push(Z);let X=F.packCentralHeader();T.push(X),c.size+=X.length,P+=ie+X.length,C++}P+=c.mainHeaderSize,c.offset=y,c.totalEntries=C,y=0;let O=Buffer.alloc(P);for(let F of A)F.copy(O,y),y+=F.length;for(let F of T)F.copy(O,y),y+=F.length;let z=c.toBinary();return o&&o.copy(z,Ve.Constants.ENDHDR),z.copy(O,y),t=O,d=!1,O},toAsyncBuffer:function(A,T,P,y){try{d||_(),I();let C=[],O=[],z=0,F=0,Z=0;c.size=0,c.offset=0;let V=function(ie){if(ie.length>0){let X=ie.shift(),oe=X.entryName+X.extra.toString();P&&P(oe),X.getCompressedDataAsync(function(ae){y&&y(oe),X.header.offset=F;let R=X.packLocalHeader(),q=R.length+ae.length;F+=q,C.push(R),C.push(ae);let W=X.packCentralHeader();O.push(W),c.size+=W.length,z+=q+W.length,Z++,V(ie)})}else{z+=c.mainHeaderSize,c.offset=F,c.totalEntries=Z,F=0;let X=Buffer.alloc(z);C.forEach(function(ae){ae.copy(X,F),F+=ae.length}),O.forEach(function(ae){ae.copy(X,F),F+=ae.length});let oe=c.toBinary();o&&o.copy(oe,Ve.Constants.ENDHDR),oe.copy(X,F),t=X,d=!1,A(X)}};V(Array.from(this.entries))}catch(C){T(C)}}}}});var Eu=le((II,yu)=>{var Se=xr(),ve=he("path"),zm=Wa(),Um=wu(),Pn=(...t)=>Se.findLast(t,e=>typeof e=="boolean"),_u=(...t)=>Se.findLast(t,e=>typeof e=="string"),Gm=(...t)=>Se.findLast(t,e=>typeof e=="function"),Hm={noSort:!1,readEntries:!1,method:Se.Constants.NONE,fs:null};yu.exports=function(t,e){let r=null,i=Object.assign(Object.create(null),Hm);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=Se.Constants.BUFFER,t=void 0)),Object.assign(i,e);let o=new Se(i);if((typeof i.decoder!="object"||typeof i.decoder.encode!="function"||typeof i.decoder.decode!="function")&&(i.decoder=Se.decoder),t&&typeof t=="string")if(o.fs.existsSync(t))i.method=Se.Constants.FILE,i.filename=t,r=o.fs.readFileSync(t);else throw Se.Errors.INVALID_FILENAME();let c=new Um(r,i),{canonical:d,sanitize:u,zipnamefix:x}=Se;function h(_){if(_&&c){var v;if(typeof _=="string"&&(v=c.getEntry(ve.posix.normalize(_))),typeof _=="object"&&typeof _.entryName<"u"&&typeof _.header<"u"&&(v=c.getEntry(_.entryName)),v)return v}return null}function m(_){let{join:v,normalize:I,sep:A}=ve.posix;return v(ve.isAbsolute(_)?"/":".",I(A+_.split("\\").join(A)+A))}function w(_){return _ instanceof RegExp?(function(v){return function(I){return v.test(I)}})(_):typeof _!="function"?()=>!0:_}let S=(_,v)=>{let I=v.slice(-1);return I=I===o.sep?o.sep:"",ve.relative(_,v)+I};return{readFile:function(_,v){var I=h(_);return I&&I.getData(v)||null},childCount:function(_){let v=h(_);if(v)return c.getChildCount(v)},readFileAsync:function(_,v){var I=h(_);I?I.getDataAsync(v):v(null,"getEntry failed for:"+_)},readAsText:function(_,v){var I=h(_);if(I){var A=I.getData();if(A&&A.length)return A.toString(v||"utf8")}return""},readAsTextAsync:function(_,v,I){var A=h(_);A?A.getDataAsync(function(T,P){if(P){v(T,P);return}T&&T.length?v(T.toString(I||"utf8")):v("")}):v("")},deleteFile:function(_,v=!0){var I=h(_);I&&c.deleteFile(I.entryName,v)},deleteEntry:function(_){var v=h(_);v&&c.deleteEntry(v.entryName)},addZipComment:function(_){c.comment=_},getZipComment:function(){return c.comment||""},addZipEntryComment:function(_,v){var I=h(_);I&&(I.comment=v)},getZipEntryComment:function(_){var v=h(_);return v&&v.comment||""},updateFile:function(_,v){var I=h(_);I&&I.setData(v)},addLocalFile:function(_,v,I,A){if(o.fs.existsSync(_)){v=v?m(v):"";let T=ve.win32.basename(ve.win32.normalize(_));v+=I||T;let P=o.fs.statSync(_),y=P.isFile()?o.fs.readFileSync(_):Buffer.alloc(0);P.isDirectory()&&(v+=o.sep),this.addFile(v,y,A,P)}else throw Se.Errors.FILE_NOT_FOUND(_)},addLocalFileAsync:function(_,v){_=typeof _=="object"?_:{localPath:_};let I=ve.resolve(_.localPath),{comment:A}=_,{zipPath:T,zipName:P}=_,y=this;o.fs.stat(I,function(C,O){if(C)return v(C,!1);T=T?m(T):"";let z=ve.win32.basename(ve.win32.normalize(I));if(T+=P||z,O.isFile())o.fs.readFile(I,function(F,Z){return F?v(F,!1):(y.addFile(T,Z,A,O),setImmediate(v,void 0,!0))});else if(O.isDirectory())return T+=o.sep,y.addFile(T,Buffer.alloc(0),A,O),setImmediate(v,void 0,!0)})},addLocalFolder:function(_,v,I){if(I=w(I),v=v?m(v):"",_=ve.normalize(_),o.fs.existsSync(_)){let A=o.findFiles(_),T=this;if(A.length)for(let P of A){let y=ve.join(v,S(_,P));I(y)&&T.addLocalFile(P,ve.dirname(y))}}else throw Se.Errors.FILE_NOT_FOUND(_)},addLocalFolderAsync:function(_,v,I,A){A=w(A),I=I?m(I):"",_=ve.normalize(_);var T=this;o.fs.open(_,"r",function(P){if(P&&P.code==="ENOENT")v(void 0,Se.Errors.FILE_NOT_FOUND(_));else if(P)v(void 0,P);else{var y=o.findFiles(_),C=-1,O=function(){if(C+=1,C<y.length){var z=y[C],F=S(_,z).split("\\").join("/");F=F.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),A(F)?o.fs.stat(z,function(Z,V){Z&&v(void 0,Z),V.isFile()?o.fs.readFile(z,function(ie,X){ie?v(void 0,ie):(T.addFile(I+F,X,"",V),O())}):(T.addFile(I+F+"/",Buffer.alloc(0),"",V),O())}):process.nextTick(()=>{O()})}else v(!0,void 0)};O()}})},addLocalFolderAsync2:function(_,v){let I=this;_=typeof _=="object"?_:{localPath:_},localPath=ve.resolve(m(_.localPath));let{zipPath:A,filter:T,namefix:P}=_;T instanceof RegExp?T=(function(O){return function(z){return O.test(z)}})(T):typeof T!="function"&&(T=function(){return!0}),A=A?m(A):"",P=="latin1"&&(P=O=>O.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof P!="function"&&(P=O=>O);let y=O=>ve.join(A,P(S(localPath,O))),C=O=>ve.win32.basename(ve.win32.normalize(P(O)));o.fs.open(localPath,"r",function(O){O&&O.code==="ENOENT"?v(void 0,Se.Errors.FILE_NOT_FOUND(localPath)):O?v(void 0,O):o.findFilesAsync(localPath,function(z,F){if(z)return v(z);F=F.filter(Z=>T(y(Z))),F.length||v(void 0,!1),setImmediate(F.reverse().reduce(function(Z,V){return function(ie,X){if(ie||X===!1)return setImmediate(Z,ie,!1);I.addLocalFileAsync({localPath:V,zipPath:ve.dirname(y(V)),zipName:C(V)},Z)}},v))})})},addLocalFolderPromise:function(_,v){return new Promise((I,A)=>{this.addLocalFolderAsync2(Object.assign({localPath:_},v),(T,P)=>{T&&A(T),P&&I(this)})})},addFile:function(_,v,I,A){_=x(_);let T=h(_),P=T!=null;P||(T=new zm(i),T.entryName=_),T.comment=I||"";let y=typeof A=="object"&&A instanceof o.fs.Stats;y&&(T.header.time=A.mtime);var C=T.isDirectory?16:0;let O=T.isDirectory?16384:32768;return y?O|=4095&A.mode:typeof A=="number"?O|=4095&A:O|=T.isDirectory?493:420,C=(C|O<<16)>>>0,T.attr=C,T.setData(v),P||c.setEntry(T),T},getEntries:function(_){return c.password=_,c?c.entries:[]},getEntry:function(_){return h(_)},getEntryCount:function(){return c.getEntryCount()},forEach:function(_){return c.forEach(_)},extractEntryTo:function(_,v,I,A,T,P){A=Pn(!1,A),T=Pn(!1,T),I=Pn(!0,I),P=_u(T,P);var y=h(_);if(!y)throw Se.Errors.NO_ENTRY();var C=d(y.entryName),O=u(v,P&&!y.isDirectory?P:I?C:ve.basename(C));if(y.isDirectory){var z=c.getEntryChildren(y);return z.forEach(function(V){if(V.isDirectory)return;var ie=V.getData();if(!ie)throw Se.Errors.CANT_EXTRACT_FILE();var X=d(V.entryName),oe=u(v,I?X:ve.basename(X));let ae=T?V.header.fileAttr:void 0;o.writeFileTo(oe,ie,A,ae)}),!0}var F=y.getData(c.password);if(!F)throw Se.Errors.CANT_EXTRACT_FILE();if(o.fs.existsSync(O)&&!A)throw Se.Errors.CANT_OVERRIDE();let Z=T?_.header.fileAttr:void 0;return o.writeFileTo(O,F,A,Z),!0},test:function(_){if(!c)return!1;for(var v in c.entries)try{if(v.isDirectory)continue;var I=c.entries[v].getData(_);if(!I)return!1}catch{return!1}return!0},extractAllTo:function(_,v,I,A){if(I=Pn(!1,I),A=_u(I,A),v=Pn(!1,v),!c)throw Se.Errors.NO_ZIP();c.entries.forEach(function(T){var P=u(_,d(T.entryName));if(T.isDirectory){o.makeDir(P);return}var y=T.getData(A);if(!y)throw Se.Errors.CANT_EXTRACT_FILE();let C=I?T.header.fileAttr:void 0;o.writeFileTo(P,y,v,C);try{o.fs.utimesSync(P,T.header.time,T.header.time)}catch{throw Se.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(_,v,I,A){if(A=Gm(v,I,A),I=Pn(!1,I),v=Pn(!1,v),!A)return new Promise((O,z)=>{this.extractAllToAsync(_,v,I,function(F){F?z(F):O(this)})});if(!c){A(Se.Errors.NO_ZIP());return}_=ve.resolve(_);let T=O=>u(_,ve.normalize(d(O.entryName))),P=(O,z)=>new Error(O+': "'+z+'"'),y=[],C=[];c.entries.forEach(O=>{O.isDirectory?y.push(O):C.push(O)});for(let O of y){let z=T(O),F=I?O.header.fileAttr:void 0;try{o.makeDir(z),F&&o.fs.chmodSync(z,F),o.fs.utimesSync(z,O.header.time,O.header.time)}catch{A(P("Unable to create folder",z))}}C.reverse().reduce(function(O,z){return function(F){if(F)O(F);else{let Z=ve.normalize(d(z.entryName)),V=u(_,Z);z.getDataAsync(function(ie,X){if(X)O(X);else if(!ie)O(Se.Errors.CANT_EXTRACT_FILE());else{let oe=I?z.header.fileAttr:void 0;o.writeFileToAsync(V,ie,v,oe,function(ae){ae||O(P("Unable to write file",V)),o.fs.utimes(V,z.header.time,z.header.time,function(R){R?O(P("Unable to set times",V)):O()})})}})}}},A)()},writeZip:function(_,v){if(arguments.length===1&&typeof _=="function"&&(v=_,_=""),!_&&i.filename&&(_=i.filename),!!_){var I=c.compressToBuffer();if(I){var A=o.writeFileTo(_,I,!0);typeof v=="function"&&v(A?null:new Error("failed"),"")}}},writeZipPromise:function(_,v){let{overwrite:I,perm:A}=Object.assign({overwrite:!0},v);return new Promise((T,P)=>{!_&&i.filename&&(_=i.filename),_||P("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(y=>{let C=O=>O?T(O):P("ADM-ZIP: Wasn't able to write zip file");o.writeFileToAsync(_,y,I,A,C)},P)})},toBufferPromise:function(){return new Promise((_,v)=>{c.toAsyncBuffer(_,v)})},toBuffer:function(_,v,I,A){return typeof _=="function"?(c.toAsyncBuffer(_,v,I,A),null):c.compressToBuffer()}}}});import{execFile as V_,spawn as Z_,spawnSync as qA}from"node:child_process";import{promisify as J_}from"node:util";function X_(t){if(process.platform!=="win32")return!1;if(Gf.test(t))return!0;let r=(t.split(/[/\\]/).pop()??t).replace(Gf,"").toLowerCase();return Y_.has(r)}function Hf(t,e){if(process.platform!=="win32")return e??{};let r={...e??{}};return X_(t)&&r.shell===void 0&&(r.shell=!0),r.windowsHide===void 0&&(r.windowsHide=!0),r}function st(t,e=[],r={}){return Z_(t,e,Hf(t,r))}function qf(t,e=[],r={}){return Q_(t,e,Hf(t,r))}var Y_,Gf,Q_,Jt=rt(()=>{"use strict";Y_=new Set(["npm","npx","yarn","pnpm","coze","tsx","claude-agent-acp","codex-acp","openclaw"]),Gf=/\.(cmd|bat|ps1)$/i;Q_=J_(V_)});var Xt=le((VC,Nx)=>{"use strict";var Ox=["nodebuffer","arraybuffer","fragments"],Lx=typeof Blob<"u";Lx&&Ox.push("blob");Nx.exports={BINARY_TYPES:Ox,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:Lx,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var ts=le((ZC,Mo)=>{"use strict";var{EMPTY_BUFFER:Lb}=Xt(),El=Buffer[Symbol.species];function Nb(t,e){if(t.length===0)return Lb;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 El(r.buffer,r.byteOffset,i):r}function Mx(t,e,r,i,o){for(let c=0;c<o;c++)r[i+c]=t[c]^e[c&3]}function Bx(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function Mb(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function bl(t){if(bl.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new El(t):ArrayBuffer.isView(t)?e=new El(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),bl.readOnly=!1),e}Mo.exports={concat:Nb,mask:Mx,toArrayBuffer:Mb,toBuffer:bl,unmask:Bx};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=he("bufferutil");Mo.exports.mask=function(e,r,i,o,c){c<48?Mx(e,r,i,o,c):t.mask(e,r,i,o,c)},Mo.exports.unmask=function(e,r){e.length<32?Bx(e,r):t.unmask(e,r)}}catch{}});var Ux=le((JC,zx)=>{"use strict";var Fx=Symbol("kDone"),vl=Symbol("kRun"),Sl=class{constructor(e){this[Fx]=()=>{this.pending--,this[vl]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[vl]()}[vl](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[Fx])}}};zx.exports=Sl});var Gr=le((YC,jx)=>{"use strict";var ns=he("zlib"),Gx=ts(),Bb=Ux(),{kStatusCode:Hx}=Xt(),Fb=Buffer[Symbol.species],zb=Buffer.from([0,0,255,255]),Fo=Symbol("permessage-deflate"),Qt=Symbol("total-length"),zr=Symbol("callback"),kn=Symbol("buffers"),Ur=Symbol("error"),Bo,Il=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,!Bo){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Bo=new Bb(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[zr];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){Bo.add(o=>{this._decompress(e,r,(c,d)=>{o(),i(c,d)})})}compress(e,r,i){Bo.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"?ns.Z_DEFAULT_WINDOWBITS:this.params[c];this._inflate=ns.createInflateRaw({...this._options.zlibInflateOptions,windowBits:d}),this._inflate[Fo]=this,this._inflate[Qt]=0,this._inflate[kn]=[],this._inflate.on("error",Gb),this._inflate.on("data",qx)}this._inflate[zr]=i,this._inflate.write(e),r&&this._inflate.write(zb),this._inflate.flush(()=>{let c=this._inflate[Ur];if(c){this._inflate.close(),this._inflate=null,i(c);return}let d=Gx.concat(this._inflate[kn],this._inflate[Qt]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Qt]=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"?ns.Z_DEFAULT_WINDOWBITS:this.params[c];this._deflate=ns.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:d}),this._deflate[Qt]=0,this._deflate[kn]=[],this._deflate.on("data",Ub)}this._deflate[zr]=i,this._deflate.write(e),this._deflate.flush(ns.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let c=Gx.concat(this._deflate[kn],this._deflate[Qt]);r&&(c=new Fb(c.buffer,c.byteOffset,c.length-4)),this._deflate[zr]=null,this._deflate[Qt]=0,this._deflate[kn]=[],r&&this.params[`${o}_no_context_takeover`]&&this._deflate.reset(),i(null,c)})}};jx.exports=Il;function Ub(t){this[kn].push(t),this[Qt]+=t.length}function qx(t){if(this[Qt]+=t.length,this[Fo]._maxPayload<1||this[Qt]<=this[Fo]._maxPayload){this[kn].push(t);return}this[Ur]=new RangeError("Max payload size exceeded"),this[Ur].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Ur][Hx]=1009,this.removeListener("data",qx),this.reset()}function Gb(t){if(this[Fo]._inflate=null,this[Ur]){this[zr](this[Ur]);return}t[Hx]=1007,this[zr](t)}});var Hr=le((XC,zo)=>{"use strict";var{isUtf8:Wx}=he("buffer"),{hasBlob:Hb}=Xt(),qb=[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 jb(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function Al(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 Wb(t){return Hb&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}zo.exports={isBlob:Wb,isValidStatusCode:jb,isValidUTF8:Al,tokenChars:qb};if(Wx)zo.exports.isValidUTF8=function(t){return t.length<24?Al(t):Wx(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=he("utf-8-validate");zo.exports.isValidUTF8=function(e){return e.length<32?Al(e):t(e)}}catch{}});var Dl=le((QC,Xx)=>{"use strict";var{Writable:Kb}=he("stream"),Kx=Gr(),{BINARY_TYPES:$b,EMPTY_BUFFER:$x,kStatusCode:Vb,kWebSocket:Zb}=Xt(),{concat:kl,toArrayBuffer:Jb,unmask:Yb}=ts(),{isValidStatusCode:Xb,isValidUTF8:Vx}=Hr(),Uo=Buffer[Symbol.species],mt=0,Zx=1,Jx=2,Yx=3,Tl=4,Rl=5,Go=6,Cl=class extends Kb{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||$b[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[Zb]=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 Uo(i.buffer,i.byteOffset+e,i.length-e),new Uo(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 Uo(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 Zx:this.getPayloadLength16(e);break;case Jx:this.getPayloadLength64(e);break;case Yx:this.getMask();break;case Tl:this.getData(e);break;case Rl:case Go: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[Kx.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=Zx:this._payloadLength===127?this._state=Jx: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=Yx:this._state=Tl}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Tl}getData(e){let r=$x;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&&Yb(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._compressed){this._state=Rl,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[Kx.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=kl(i,r):this._binaryType==="arraybuffer"?o=Jb(kl(i,r)):this._binaryType==="blob"?o=new Blob(i):o=i,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=mt):(this._state=Go,setImmediate(()=>{this.emit("message",o,!0),this._state=mt,this.startLoop(e)}))}else{let o=kl(i,r);if(!this._skipUTF8Validation&&!Vx(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(c);return}this._state===Rl||this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=mt):(this._state=Go,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,$x),this.end();else{let i=e.readUInt16BE(0);if(!Xb(i)){let c=this.createError(RangeError,`invalid status code ${i}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(c);return}let o=new Uo(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!Vx(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=Go,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[Vb]=o,d}};Xx.exports=Cl});var Ll=le((tD,th)=>{"use strict";var{Duplex:eD}=he("stream"),{randomFillSync:Qb}=he("crypto"),{types:{isUint8Array:ev}}=he("util"),Qx=Gr(),{EMPTY_BUFFER:tv,kWebSocket:nv,NOOP:rv}=Xt(),{isBlob:qr,isValidStatusCode:iv}=Hr(),{mask:eh,toBuffer:Zn}=ts(),wt=Symbol("kByteLength"),sv=Buffer.alloc(4),Ho=8*1024,Jn,jr=Ho,At=0,ov=1,av=2,Pl=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=rv,this[nv]=void 0}static frame(e,r){let i,o=!1,c=2,d=!1;r.mask&&(i=r.maskBuffer||sv,r.generateMask?r.generateMask(i):(jr===Ho&&(Jn===void 0&&(Jn=Buffer.alloc(Ho)),Qb(Jn,0,Ho),jr=0),i[0]=Jn[jr++],i[1]=Jn[jr++],i[2]=Jn[jr++],i[3]=Jn[jr++]),d=(i[0]|i[1]|i[2]|i[3])===0,c=6);let u;typeof e=="string"?(!r.mask||d)&&r[wt]!==void 0?u=r[wt]:(e=Buffer.from(e),u=e.length):(u=e.length,o=r.mask&&r.readOnly&&!d);let x=u;u>=65536?(c+=8,x=127):u>125&&(c+=2,x=126);let h=Buffer.allocUnsafe(o?u+c:c);return h[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(h[0]|=64),h[1]=x,x===126?h.writeUInt16BE(u,2):x===127&&(h[2]=h[3]=0,h.writeUIntBE(u,4,6)),r.mask?(h[1]|=128,h[c-4]=i[0],h[c-3]=i[1],h[c-2]=i[2],h[c-1]=i[3],d?[h,e]:o?(eh(e,i,h,c,u),[h]):(eh(e,i,e,0,u),[h,e])):[h,e]}close(e,r,i,o){let c;if(e===void 0)c=tv;else{if(typeof e!="number"||!iv(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(ev(r))c.set(r,2);else throw new TypeError("Second argument must be a string or a Uint8Array")}}let d={[wt]: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):qr(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={[wt]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:c,rsv1:!1};qr(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):qr(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={[wt]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:c,rsv1:!1};qr(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[Qx.extensionName],c=r.binary?2:1,d=r.compress,u,x;typeof e=="string"?(u=Buffer.byteLength(e),x=!1):qr(e)?(u=e.size,x=!1):(e=Zn(e),u=e.length,x=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),r.fin&&(this._firstFragment=!0);let h={[wt]:u,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:c,readOnly:x,rsv1:d};qr(e)?this._state!==At?this.enqueue([this.getBlobData,e,this._compress,h,i]):this.getBlobData(e,this._compress,h,i):this._state!==At?this.enqueue([this.dispatch,e,this._compress,h,i]):this.dispatch(e,this._compress,h,i)}getBlobData(e,r,i,o){this._bufferedBytes+=i[wt],this._state=av,e.arrayBuffer().then(c=>{if(this._socket.destroyed){let u=new Error("The socket was closed while the blob was being read");process.nextTick(Ol,this,u,o);return}this._bufferedBytes-=i[wt];let d=Zn(c);r?this.dispatch(d,r,i,o):(this._state=At,this.sendFrame(t.frame(d,i),o),this.dequeue())}).catch(c=>{process.nextTick(cv,this,c,o)})}dispatch(e,r,i,o){if(!r){this.sendFrame(t.frame(e,i),o);return}let c=this._extensions[Qx.extensionName];this._bufferedBytes+=i[wt],this._state=ov,c.compress(e,i.fin,(d,u)=>{if(this._socket.destroyed){let x=new Error("The socket was closed while data was being compressed");Ol(this,x,o);return}this._bufferedBytes-=i[wt],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][wt],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][wt],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)}};th.exports=Pl;function Ol(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 cv(t,e,r){Ol(t,e,r),t.onerror(e)}});var dh=le((nD,lh)=>{"use strict";var{kForOnEventAttribute:rs,kListener:Nl}=Xt(),nh=Symbol("kCode"),rh=Symbol("kData"),ih=Symbol("kError"),sh=Symbol("kMessage"),oh=Symbol("kReason"),Wr=Symbol("kTarget"),ah=Symbol("kType"),ch=Symbol("kWasClean"),en=class{constructor(e){this[Wr]=null,this[ah]=e}get target(){return this[Wr]}get type(){return this[ah]}};Object.defineProperty(en.prototype,"target",{enumerable:!0});Object.defineProperty(en.prototype,"type",{enumerable:!0});var Yn=class extends en{constructor(e,r={}){super(e),this[nh]=r.code===void 0?0:r.code,this[oh]=r.reason===void 0?"":r.reason,this[ch]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[nh]}get reason(){return this[oh]}get wasClean(){return this[ch]}};Object.defineProperty(Yn.prototype,"code",{enumerable:!0});Object.defineProperty(Yn.prototype,"reason",{enumerable:!0});Object.defineProperty(Yn.prototype,"wasClean",{enumerable:!0});var Kr=class extends en{constructor(e,r={}){super(e),this[ih]=r.error===void 0?null:r.error,this[sh]=r.message===void 0?"":r.message}get error(){return this[ih]}get message(){return this[sh]}};Object.defineProperty(Kr.prototype,"error",{enumerable:!0});Object.defineProperty(Kr.prototype,"message",{enumerable:!0});var is=class extends en{constructor(e,r={}){super(e),this[rh]=r.data===void 0?null:r.data}get data(){return this[rh]}};Object.defineProperty(is.prototype,"data",{enumerable:!0});var lv={addEventListener(t,e,r={}){for(let o of this.listeners(t))if(!r[rs]&&o[Nl]===e&&!o[rs])return;let i;if(t==="message")i=function(c,d){let u=new is("message",{data:d?c:c.toString()});u[Wr]=this,qo(e,this,u)};else if(t==="close")i=function(c,d){let u=new Yn("close",{code:c,reason:d.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});u[Wr]=this,qo(e,this,u)};else if(t==="error")i=function(c){let d=new Kr("error",{error:c,message:c.message});d[Wr]=this,qo(e,this,d)};else if(t==="open")i=function(){let c=new en("open");c[Wr]=this,qo(e,this,c)};else return;i[rs]=!!r[rs],i[Nl]=e,r.once?this.once(t,i):this.on(t,i)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[Nl]===e&&!r[rs]){this.removeListener(t,r);break}}};lh.exports={CloseEvent:Yn,ErrorEvent:Kr,Event:en,EventTarget:lv,MessageEvent:is};function qo(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var jo=le((rD,uh)=>{"use strict";var{tokenChars:ss}=Hr();function Bt(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function dv(t){let e=Object.create(null),r=Object.create(null),i=!1,o=!1,c=!1,d,u,x=-1,h=-1,m=-1,w=0;for(;w<t.length;w++)if(h=t.charCodeAt(w),d===void 0)if(m===-1&&ss[h]===1)x===-1&&(x=w);else if(w!==0&&(h===32||h===9))m===-1&&x!==-1&&(m=w);else if(h===59||h===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${w}`);m===-1&&(m=w);let _=t.slice(x,m);h===44?(Bt(e,_,r),r=Object.create(null)):d=_,x=m=-1}else throw new SyntaxError(`Unexpected character at index ${w}`);else if(u===void 0)if(m===-1&&ss[h]===1)x===-1&&(x=w);else if(h===32||h===9)m===-1&&x!==-1&&(m=w);else if(h===59||h===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${w}`);m===-1&&(m=w),Bt(r,t.slice(x,m),!0),h===44&&(Bt(e,d,r),r=Object.create(null),d=void 0),x=m=-1}else if(h===61&&x!==-1&&m===-1)u=t.slice(x,w),x=m=-1;else throw new SyntaxError(`Unexpected character at index ${w}`);else if(o){if(ss[h]!==1)throw new SyntaxError(`Unexpected character at index ${w}`);x===-1?x=w:i||(i=!0),o=!1}else if(c)if(ss[h]===1)x===-1&&(x=w);else if(h===34&&x!==-1)c=!1,m=w;else if(h===92)o=!0;else throw new SyntaxError(`Unexpected character at index ${w}`);else if(h===34&&t.charCodeAt(w-1)===61)c=!0;else if(m===-1&&ss[h]===1)x===-1&&(x=w);else if(x!==-1&&(h===32||h===9))m===-1&&(m=w);else if(h===59||h===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${w}`);m===-1&&(m=w);let _=t.slice(x,m);i&&(_=_.replace(/\\/g,""),i=!1),Bt(r,u,_),h===44&&(Bt(e,d,r),r=Object.create(null),d=void 0),u=void 0,x=m=-1}else throw new SyntaxError(`Unexpected character at index ${w}`);if(x===-1||c||h===32||h===9)throw new SyntaxError("Unexpected end of input");m===-1&&(m=w);let S=t.slice(x,m);return d===void 0?Bt(e,S,r):(u===void 0?Bt(r,S,!0):i?Bt(r,u,S.replace(/\\/g,"")):Bt(r,u,S),Bt(e,d,r)),e}function uv(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(", ")}uh.exports={format:uv,parse:dv}});var Vo=le((oD,vh)=>{"use strict";var fv=he("events"),xv=he("https"),hv=he("http"),hh=he("net"),pv=he("tls"),{randomBytes:gv,createHash:mv}=he("crypto"),{Duplex:iD,Readable:sD}=he("stream"),{URL:Ml}=he("url"),Tn=Gr(),wv=Dl(),_v=Ll(),{isBlob:yv}=Hr(),{BINARY_TYPES:fh,CLOSE_TIMEOUT:Ev,EMPTY_BUFFER:Wo,GUID:bv,kForOnEventAttribute:Bl,kListener:vv,kStatusCode:Sv,kWebSocket:We,NOOP:ph}=Xt(),{EventTarget:{addEventListener:Iv,removeEventListener:Av}}=dh(),{format:kv,parse:Tv}=jo(),{toBuffer:Rv}=ts(),gh=Symbol("kAborted"),Fl=[8,13],tn=["CONNECTING","OPEN","CLOSING","CLOSED"],Cv=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,ye=class t extends fv{constructor(e,r,i){super(),this._binaryType=fh[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Wo,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]),mh(this,e,r,i)):(this._autoPong=i.autoPong,this._closeTimeout=i.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){fh.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 wv({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 _v(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",Ov),o.on("drain",Lv),o.on("error",Nv),o.on("message",Mv),o.on("ping",Bv),o.on("pong",Fv),c.onerror=zv,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",yh),e.on("data",$o),e.on("end",Eh),e.on("error",bh),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){lt(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())}),_h(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){zl(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||Wo,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){zl(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||Wo,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){zl(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||Wo,o,i)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){lt(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(ye,"CONNECTING",{enumerable:!0,value:tn.indexOf("CONNECTING")});Object.defineProperty(ye.prototype,"CONNECTING",{enumerable:!0,value:tn.indexOf("CONNECTING")});Object.defineProperty(ye,"OPEN",{enumerable:!0,value:tn.indexOf("OPEN")});Object.defineProperty(ye.prototype,"OPEN",{enumerable:!0,value:tn.indexOf("OPEN")});Object.defineProperty(ye,"CLOSING",{enumerable:!0,value:tn.indexOf("CLOSING")});Object.defineProperty(ye.prototype,"CLOSING",{enumerable:!0,value:tn.indexOf("CLOSING")});Object.defineProperty(ye,"CLOSED",{enumerable:!0,value:tn.indexOf("CLOSED")});Object.defineProperty(ye.prototype,"CLOSED",{enumerable:!0,value:tn.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(ye.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(ye.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[Bl])return e[vv];return null},set(e){for(let r of this.listeners(t))if(r[Bl]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[Bl]:!0})}})});ye.prototype.addEventListener=Iv;ye.prototype.removeEventListener=Av;vh.exports=ye;function mh(t,e,r,i){let o={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:Ev,protocolVersion:Fl[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,!Fl.includes(o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${Fl.join(", ")})`);let c;if(e instanceof Ml)c=e;else try{c=new Ml(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:",x;if(c.protocol!=="ws:"&&!d&&!u?x=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:u&&!c.pathname?x="The URL's pathname is empty":c.hash&&(x="The URL contains a fragment identifier"),x){let I=new SyntaxError(x);if(t._redirects===0)throw I;Ko(t,I);return}let h=d?443:80,m=gv(16).toString("base64"),w=d?xv.request:hv.request,S=new Set,_;if(o.createConnection=o.createConnection||(d?Pv:Dv),o.defaultPort=o.defaultPort||h,o.port=c.port||h,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&&(_=new Tn({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers["Sec-WebSocket-Extensions"]=kv({[Tn.extensionName]:_.offer()})),r.length){for(let I of r){if(typeof I!="string"||!Cv.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,T]of Object.entries(I))i.headers[A.toLowerCase()]=T}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",()=>{lt(t,v,"Opening handshake has timed out")}),v.on("error",I=>{v===null||v[gh]||(v=t._req=null,Ko(t,I))}),v.on("response",I=>{let A=I.headers.location,T=I.statusCode;if(A&&o.followRedirects&&T>=300&&T<400){if(++t._redirects>o.maxRedirects){lt(t,v,"Maximum redirects exceeded");return}v.abort();let P;try{P=new Ml(A,e)}catch{let C=new SyntaxError(`Invalid URL: ${A}`);Ko(t,C);return}mh(t,P,r,i)}else t.emit("unexpected-response",v,I)||lt(t,v,`Unexpected server response: ${I.statusCode}`)}),v.on("upgrade",(I,A,T)=>{if(t.emit("upgrade",I),t.readyState!==ye.CONNECTING)return;v=t._req=null;let P=I.headers.upgrade;if(P===void 0||P.toLowerCase()!=="websocket"){lt(t,A,"Invalid Upgrade header");return}let y=mv("sha1").update(m+bv).digest("base64");if(I.headers["sec-websocket-accept"]!==y){lt(t,A,"Invalid Sec-WebSocket-Accept header");return}let C=I.headers["sec-websocket-protocol"],O;if(C!==void 0?S.size?S.has(C)||(O="Server sent an invalid subprotocol"):O="Server sent a subprotocol but none was requested":S.size&&(O="Server sent no subprotocol"),O){lt(t,A,O);return}C&&(t._protocol=C);let z=I.headers["sec-websocket-extensions"];if(z!==void 0){if(!_){lt(t,A,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let F;try{F=Tv(z)}catch{lt(t,A,"Invalid Sec-WebSocket-Extensions header");return}let Z=Object.keys(F);if(Z.length!==1||Z[0]!==Tn.extensionName){lt(t,A,"Server indicated an extension that was not requested");return}try{_.accept(F[Tn.extensionName])}catch{lt(t,A,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[Tn.extensionName]=_}t.setSocket(A,T,{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 Ko(t,e){t._readyState=ye.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function Dv(t){return t.path=t.socketPath,hh.connect(t)}function Pv(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=hh.isIP(t.host)?"":t.host),pv.connect(t)}function lt(t,e,r){t._readyState=ye.CLOSING;let i=new Error(r);Error.captureStackTrace(i,lt),e.setHeader?(e[gh]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(Ko,t,i)):(e.destroy(i),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function zl(t,e,r){if(e){let i=yv(e)?e.size:Rv(e).length;t._socket?t._sender._bufferedBytes+=i:t._bufferedAmount+=i}if(r){let i=new Error(`WebSocket is not open: readyState ${t.readyState} (${tn[t.readyState]})`);process.nextTick(r,i)}}function Ov(t,e){let r=this[We];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[We]!==void 0&&(r._socket.removeListener("data",$o),process.nextTick(wh,r._socket),t===1005?r.close():r.close(t,e))}function Lv(){let t=this[We];t.isPaused||t._socket.resume()}function Nv(t){let e=this[We];e._socket[We]!==void 0&&(e._socket.removeListener("data",$o),process.nextTick(wh,e._socket),e.close(t[Sv])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function xh(){this[We].emitClose()}function Mv(t,e){this[We].emit("message",t,e)}function Bv(t){let e=this[We];e._autoPong&&e.pong(t,!this._isServer,ph),e.emit("ping",t)}function Fv(t){this[We].emit("pong",t)}function wh(t){t.resume()}function zv(t){let e=this[We];e.readyState!==ye.CLOSED&&(e.readyState===ye.OPEN&&(e._readyState=ye.CLOSING,_h(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function _h(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function yh(){let t=this[We];if(this.removeListener("close",yh),this.removeListener("data",$o),this.removeListener("end",Eh),t._readyState=ye.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",xh),t._receiver.on("finish",xh))}function $o(t){this[We]._receiver.write(t)||this.pause()}function Eh(){let t=this[We];t._readyState=ye.CLOSING,t._receiver.end(),this.end()}function bh(){let t=this[We];this.removeListener("error",bh),this.on("error",ph),t&&(t._readyState=ye.CLOSING,this.destroy())}});var kh=le((cD,Ah)=>{"use strict";var aD=Vo(),{Duplex:Uv}=he("stream");function Sh(t){t.emit("close")}function Gv(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Ih(t){this.removeListener("error",Ih),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function Hv(t,e){let r=!0,i=new Uv({...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(Sh,i);return}let d=!1;t.once("error",function(x){d=!0,c(x)}),t.once("close",function(){d||c(o),process.nextTick(Sh,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",Gv),i.on("error",Ih),i}Ah.exports=Hv});var Ul=le((lD,Th)=>{"use strict";var{tokenChars:qv}=Hr();function jv(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&&qv[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}Th.exports={parse:jv}});var Nh=le((uD,Lh)=>{"use strict";var Wv=he("events"),Zo=he("http"),{Duplex:dD}=he("stream"),{createHash:Kv}=he("crypto"),Rh=jo(),Xn=Gr(),$v=Ul(),Vv=Vo(),{CLOSE_TIMEOUT:Zv,GUID:Jv,kWebSocket:Yv}=Xt(),Xv=/^[+/0-9A-Za-z]{22}==$/,Ch=0,Dh=1,Oh=2,Gl=class extends Wv{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:Zv,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:Vv,...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=Zo.createServer((i,o)=>{let c=Zo.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=Qv(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=Ch}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===Oh){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(os,this);return}if(e&&this.once("close",e),this._state!==Dh)if(this._state=Dh,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(os,this):process.nextTick(os,this);else{let r=this._server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{os(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",Ph);let c=e.headers["sec-websocket-key"],d=e.headers.upgrade,u=+e.headers["sec-websocket-version"];if(e.method!=="GET"){Qn(this,e,r,405,"Invalid HTTP method");return}if(d===void 0||d.toLowerCase()!=="websocket"){Qn(this,e,r,400,"Invalid Upgrade header");return}if(c===void 0||!Xv.test(c)){Qn(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(u!==13&&u!==8){Qn(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){as(r,400);return}let x=e.headers["sec-websocket-protocol"],h=new Set;if(x!==void 0)try{h=$v.parse(x)}catch{Qn(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let m=e.headers["sec-websocket-extensions"],w={};if(this.options.perMessageDeflate&&m!==void 0){let S=new Xn({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let _=Rh.parse(m);_[Xn.extensionName]&&(S.accept(_[Xn.extensionName]),w[Xn.extensionName]=S)}catch{Qn(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,(_,v,I,A)=>{if(!_)return as(r,v||401,I,A);this.completeUpgrade(w,c,h,e,r,i,o)});return}if(!this.options.verifyClient(S))return as(r,401)}this.completeUpgrade(w,c,h,e,r,i,o)}completeUpgrade(e,r,i,o,c,d,u){if(!c.readable||!c.writable)return c.destroy();if(c[Yv])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Ch)return as(c,503);let h=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Kv("sha1").update(r+Jv).digest("base64")}`],m=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&&(h.push(`Sec-WebSocket-Protocol: ${w}`),m._protocol=w)}if(e[Xn.extensionName]){let w=e[Xn.extensionName].params,S=Rh.format({[Xn.extensionName]:[w]});h.push(`Sec-WebSocket-Extensions: ${S}`),m._extensions=e}this.emit("headers",h,o),c.write(h.concat(`\r
|
|
15
15
|
`).join(`\r
|
|
16
|
-
`)),c.removeListener("error",
|
|
16
|
+
`)),c.removeListener("error",Ph),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(os,this)})),u(m,o)}};Lh.exports=Gl;function Qv(t,e){for(let r of Object.keys(e))t.on(r,e[r]);return function(){for(let i of Object.keys(e))t.removeListener(i,e[i])}}function os(t){t._state=Oh,t.emit("close")}function Ph(){this.destroy()}function as(t,e,r,i){r=r||Zo.STATUS_CODES[e],i={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(r),...i},t.once("finish",t.destroy),t.end(`HTTP/1.1 ${e} ${Zo.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 Xn(t,e,r,i,o,c){if(t.listenerCount("wsClientError")){let l=new Error(o);Error.captureStackTrace(l,Xn),t.emit("wsClientError",l,r,e)}else is(r,i,o,c)}});var Vx=ae(Me=>{"use strict";var N=j;(function(t,e){let r=j,i=t();for(;;)try{if(-parseInt(r(399))/1+-parseInt(r(497))/2+parseInt(r(1579))/3+-parseInt(r(674))/4*(parseInt(r(1023))/5)+parseInt(r(1270))/6+parseInt(r(1098))/7*(parseInt(r(1539))/8)+-parseInt(r(1714))/9*(-parseInt(r(1632))/10)===e)break;i.push(i.shift())}catch{i.push(i.shift())}})(Yo,799130);function Yo(){let t=["u2TPCcbWyxm","rhLTteq","y2HnyxHuCMK","Fdn8mxW1Fde","DgvmB2Djre4","sNLUyLi","C2v0u3rVCMe","vNPsCem","txrxtLO","rwjqzxO","q0v4Chm","BLPxBxe","DMfSDwvZ","AxnrB1nnzxm","zuX2CwK","m3W1Fdy","q2vJshu","txj0DLK","B2jQzwn0u3q","DNn2qKq","y09Wzw4","BNrLCG","s01Vz2u","Dg5rwgu","AgfZ","BKDqtwK","whj1s2S","sNDOz2m","C3PHDei","ruHPzfG","zMjfD2i","BMv3vMvYC2K","ChrVCG","tw9iBKq","CMjir0i","Afrqveu","Aw5Lza","CezjseG","B25ozxr3B3i","u3Lzuwu","yxrLq291BNq","CMvXDwLYzwq","vw1jDuy","Exz5tuu","z2u6ia","x29Uq2XVC2u","Bwu6ia","x2TLEvbHDgG","x3jLywr5q2W","Dev2zw50","DKnQuuS","CvrisgS","C3vJy2vZCW","B25szwnLAxy","qNz0C0i","uK9Irxq","vhbmD1i","C0Xf","ywjVCNq","icSG","mZi2ode3s1jHrhju","zvDKzue","tNnJEuy","terhBhy","s0rdC24","mdaWmdaWmda","CMvJzxzPzwq","C3bSAxq","y29UBMvJDa","ANHUEwC","Bg9N","ENrrv3m","uxPPBNC","rKL4Ceu","zhf1CMO","ENneBg4","DgvZDa","qunIEKG","x2LZsw5PDa","DxbKyxrLq3u","DhDVCMTdAge","sKrYz2W","Dg9cExrLC0W","D3rizfm","yxbWBhK","id4G","D3jPDgvvAw4","sNPlsMu","s2vrrMe","yMLUyxj5","r2vNANC","Bev2wgy","z2vtEw5J","DMLJzuLeig8","zxjFBxnNAwq","DMD4uKq","Befzshm","zNjVBuj5Dgu","ChfhBuK","EKztze0","qufyvey","vhnHz2S","AvvgqLe","Bwf4twvZC2e","B3jpBMXPBMu","B2XKvMvYC2K","sxPlvum","x2zVCM1HDeu","zuXzEg4","BeHHBMrSzxi","BezvAMm","u3jPBKC","ChjVDg90Exa","vNvzzM4","vuPQu0u","x2HHBMrSzu8","vLHpyvi","y3vYC29Yx24","uNLLuK4","rvPstue","DLvVzKK","AKnfwNK","v0LZA28","B25dBg9Zzq","DvHyEfy","Avj0qve","qNnOqNu","uhfOuKe","v2LUzg93","EfD0wgG","AxnFywnR","vfr2C1a","sxzgDwS","x2LUAxrhBg8","wgnmAhK","r3HPB2y","zw5JB2rPBMC","vKDdA3O","pxv0zI04","D2fZq2XLyw4","AxnszwfKEq","B3zTz28","C2v0","EMvZt3e","DvPiEgy","BefoAvK","CxDxDxe","vLbMzMG","Aw5KzxGGB3u","v1f2v0u","ChbL","CfHKrMq","yLfWugy","yMfSrxzLBNq","y3vYCMvUDeu","yw5Hz2vY","AxH3wKi","tgLZDgvUzxi","Aw5JBhvKzxm","AuTxD1K","Cg9PBNrdB24","CYbWyxjHBxm","B2D3t2u","sKL6vMO","B2nRzxq","zxjprgi","u2vXsuq","x2XPC3rLBMu","zfbzvhC","CNfZsvq","te5AA1C","CMfTzq","A0TqA2i","C3rLBMvYCW","y29UC3rYDwm","twvZC2fNzuu","AhHgwM0","CM92AwrLihC","B3DvrLe","B2zM","x3DZsw5ZDge","CMfUzg9T","qwjWC2K","ihrVihjLDhi","BwfzseC","x25HDMLNyxq","DcbVzIbYyw4","x2vUzhbVAw4","qLD4qNy","svvPC0y","CNnVCKzPBgu","yuPxBNa","rgnVs0e","u05LtMi","CMvZDwX0","v3DrwwK","AwXK","y3jzsfO","z1rTwvK","B25nzxnZywC","CwzXtu0","CM92AwrLige","ExDZCuu","ueTJsLu","zNjHBwvuExa","A1zSCg8","B3nLrxzLBNq","zv90Aw1LB3u","qw5VEeS","uhDqzNC","ugDbzNq","zgvSzxrL","zgvJB2rLzey","Cunbteu","q3P5Deq","CMvJzwL2zwq","Efrurw52","s1fKBKC","rLLRuw0","quvuBLu","ywnRx2nVzgu","rM5YB1K","zw1LBNq","Dxrjza","yxv0BW","ChLHBxi","AezzsuC","qw1AAxq","C0POCNe","mtq1nZm2mwjWsNfhBW","AgvHzgvY","BM9lAMi","r2j3uw4","AK1TAum","thjyAe0","CNnVCL9Uyw0","BwvKAwf0zwW","sxnrCLy","t0TTALq","yM9TAMS","zw5fDMvUDa","rM5LA1u","A0n0uuG","m3WWFdf8mNW","uuzIwKK","zKvXDxq","BMrWB2LUDfq","Dg9oDw1Izxi","zxnXBwm","ywX3yxLZ","D3DQChm","Bg93","vg1MtfK","wuf4yM8","DgLLCKPtt04","ywrKq291BNq","BeD0zgu","Aw9Ul2PZB24","y3vYCMvUDeK","ig1LC3nHz2u","D3jPDgu","uuDXtfa","BMnLq2XVC2u","wg1JAvy","x3bYB3rVy28","zxjYB3i","x3DHAxq","x2rLyNvN","sLnptLa","BMDLza","wgvqzvG","CMvHzfvjBNq","tevJqKS","Bw9Hzuu","twLZC2LUzYa","EunhBvm","x21PBMLoyxy","x2rYB3bhBg8","tLDODMW","A09jthy","BwvZC2fNzv8","C2v0zgi","AxDYBK4","CgjICdi","wwDvrgS","CgLUz0XVC3m","C3rVCMu","DhLWzq","quXm","z2vxCNK","tgvUzKG","C2fNzq","AMrLELq","CK5WrNC","CMvjwgq","AfvxDeC","x29UrxjYB3i","BM9OuMm","y05nEfm","BgvY","CxLpufi","DhjHBNnHy3q","sfD4twm","zK91Ag4","EKjLBKq","Bwf4tg9ZC0m","C2v0sxrLBq","DNL4vKe","CfPbsu0","vMPLAgS","Ae5sr04","uMLhzKG","EfHdB1q","BMCGDxjSoIa","CMvWBgfJzq","x29UtwvZC2e","vgfN","tKTJuw8","rxjYB3jdB2q","Dfr1A3u","q291BNq","r01Aq3i","shLACwi","Exn6sxm","AKruDuO","x2rItMfTzq","rxvJq0u","mJC2mdjpC2zRCKO","BgLTAxq","x2fKzfDZtgK","zuf3qwO","y3jLyxrLt3a","y0Tgrui","EuXPqK4","uLjpuG","igXHCMDLCIa","uuzuv3a","z2vrDwv1zuW","sMrQEMW","C1LKAwy","AMvJDfn0B3i","vxv1D1q","x3DZ","CMvTB3zLq2G","q2jqzNy","wLbAD3a","Axnby2TdBgu","ignVzgu6ia","Cgf5Bg9Hzfq","x2DLDeLUDgu","zuLzqu8","AfvbwM0","BNbTt3e","Cu9qEKG","CMvKDwnL","vM5sBMu","r1nkC2G","z0Xluwu","ywDLsgLKzq","zgvMAw5Luhi","zKXls0m","tKXXDKe","y2XVC2u","Ahr0Ca","AevvCuG","CMTLCKDSB2i","BMTcquy","y29UBMvJDfm","x2LZtM9Kzq","z3fMBfe","Aw9U","tNPeB0e","BLHoBMK","teLet1u","DxnLCKLW","CeHqDvi","x3bPBMC","tLj0rKi","Bvj5ugO","qxrgvMy","B3v2qvu","yM9KEq","DfzVCgK","t1jiwwq","A2TfreC","t1LUu2C","ywjZAgW","qxnTBxu","y3jLyxrLtwu","BM9Uzv9UB24","yvPkBha","u1LyCem","rKLJCuu","tvbpq2K","rNjVBNrPzxi","ihbYB3rVy28","rwjtvLa","CujduM4","x2HHBMrSzva","qM9UtMm","D0HwtNe","vM1nzxu","Ee9Lt1a","yKrfquy","sMHptMC","zMLUza","D24GCMvHC28","rxvvsKK","x2nSzwfYugK","rLrQALa","rff0ue8","DcbSAw1PDa","y1jnqxu","BvjyBLq","uu5Kv2S","rg5gtvG","u0PdDu8","rvrSBg0","uwX6Cvi","r2rNuLe","q29UzMLN","A05PDuK","BMvLzf9Hy2S","AgfZt3DUuhi","r3Hqsee","BwvY","z2v0q3vYCMu","wNnjvvq","zMX1C2HfEha","yw51Ce1LC3m","BgLZDgvUtMu","t2DzrLG","C2vYDMvYvgK","svrfBLi","yxP2wfK","A0H2vw0","qvL4AxC","tfviCK0","x3bPBMDmB3m","zwLvAeC","r0zRD3m","yxKSig5LDhC","tuLzEfi","AwvpyuW","Cuf3yNi","y0TvyKq","zw5JB2rLrNi","AwXLx25HBwu","C29YDa","sw9WCge","ueHxCNe","CNb4wLq","ihzHBgLKihm","qM1Hz3G","BxDhwLm","wuj1rhe","De1mshq","suvtx0vsuK8","qxbdy2m","rfnoCKC","sKnrBu8","Dw50","zuXtsvy","yxKSihrYEsa","CYbHBhjLywq","sg9csfy","EvffCxi","DNbXAeO","ywXSq3vYC28","B3fSsum","CMvHC29U","sensEgq","D2vI","zwvKzwq","DhvsqvK","De9wAvy","zMLN","CMvZzxrdB3u","rwDSELm","igfYCMf5yNu","CMLdswO","vwHSAKC","z2v0","yxbWBgLJyxq","AvDRtxq","y291BNq","mNWZFdr8mxW","rvjRq2i","zuvnvei","EM5gyNq","zNLKzwC","BNrbBMrvCgq","DeLK","DhHJvwm","zKjMrgy","rhrbAxe","qwzWzwi","C1LTB0G","AvLKwgq","AgvKtwf4uMu","yuXbveO","Bvrnvvy","vfjUt24","sNPTCeS","mZuWnJyXmLnVwgvMCW","EvjLy29UBMu","zuLtvfq","rvjst1i","tMfTzq","zw50zwqGDhK","BKTMEeK","Agv0B2m","mdaWma","zw5NDgG","q3DoD28","y3vYC29Yx2y","zxjYtxnN","BMCGzMfPBgu","Cw5ysMe","EMnZquC","x2LZv29YA2u","y2f0y2G","ywDLu2HVDW","mhWZFdD8mq","Dhbyzhm","wef4CKW","vMTZyMS","v0fbCu0","zNjVBuHHC2G","ANPxwLO","BK5YD0O","C3v4AuS","D1jVtxK","x3jLy29UBMu","sfPdCLq","yNr6wMO","tNLzCNq","sxzytMG","Ae1LC3nHz2u","u3rYyxrLz3K","EKnuu2y","EerQAKu","y29TCgXLDgu","s0rht2e","zNjVBunOyxi","EhrRqve","rLjAwKy","Ae1AB3G","lcbTyxGGCMu","zvnWB2e","De1HBMfNzxi","x2jPBMfYEvq","vK15rui","z2vY","y2XLyxjtDg8","AwTxufy","zxH0ugf5Bg8","sM9pzhi","y0zzweO","y1Pgq2C","z2r5t1u","wMzADK8","CMvWBgfJzui","AevYCM9Yrxy","zhDkruu","Ew1pCKe","ww9Jthu","zxj2AwnL","uhvJDvC","zfbys0y","t3foELq","qLvRB3i","rwvWCvi","y3jLyxrLrxi","x21LC3nHz2u","y29UDgv4Da","q1HqAvy","DMfSDwu","vu5VteS","BfrPBwvVDxq","mtb8mxW5Fdu","DeTZCKO","zvztDvO","yNHJzhO","uufpzMm","x2rPC3bHDgm","uhDWEvu","z2vjBMzVu3K","C3rYAw5N","vuLTzha","BwLUAvbYB2C","DM9bEuq","CYbPBNn0yw4","Ec1TC2CTy3u","DuXcDvG","svDIAha","CxPizxa","Aw9UvgLTzw8","seHpsKi","B25JBg9Zzq","ywnRx2LK","zuT6ENG","x2rLC3rYB3K","zuv3u1y","r0jXuMW","Aw1LCYbPBIa","zw50tgLZDgu","ihn1y2nLC3m","r0vYzNu","y2uGBM90igK","q3rjEfG","EKnrzMy","vufxqNK","mNWXFdr8m3W","y0P0Cfy","vxjAu1y","s3PMAM0","rhDbwMm","wMf6wxq","zwrhDxO","EfvZzuvUDG","qNjPzgDL","tKDFrvjst1i","D3Dbsem","z2zbBu4","x2DLBMvYyxq","yxnJCMLWDa","B0HvugC","CMvQzwn0","y2HLy2TdDxi","BML0AwfSAxO","rvbLrLy","tKrjB04","x29WDgLVBNm","wwrqvLu","wwnitMO","Aw5KzxG","B0HAvgy","nhWYFdf8m3W","tNLPwhi","tg9NsurozxC","y2XVC2uSihC","y0LNzue","BM5Ly3q","zgLZCgf0y2G","BMrWB2LUDca","rvvyzfi","Bg9TvKG","C3rZrw8","Cgf5Bg9Hzeu","tgvLD1a","sM1uzeG","DMLKuLq","rxzLBNq","Cg9IzKG","uMfgrLm","AxnmB25N","zw5HyMXLvhi","EgTcAhi","zMLSDgvY","zxjFAxnFywm","C0XPC3rLBMu","yLvjD2K","CNH0rhO","EvjLsNC","BwfUDwfSihi","ELzftgm","yxv0B21HDgK","ihrYEsbYzwm","zKXMrfu","q0Xpu0LorW","CgnUCe8","vgDoDxq","CK9HA2y","zxjHDg9Y","Bez1y0W","AM5mteG","CxrfCvu","zwn0","BMDVz08","C3LAD2K","vfbeDuW","CfbrA2O","BhDKDLu","zg9Uzq","ywDLrxzLBNq","CxvywwS","B3jRig9MzMW","yNvMzMvY","q29Kzq","x3jLBw92zvC","Dg9mB3DLCKm","B25TzxnZywC","AM9PBG","B1n4A1q","tvjnAxO","ywXSzwqGBxu","C2rJyvu","C0nVDw50zxi","vvbhtve","x2LZtwLUAvC","y2HnyxHdB3u","uvzuz3y","C2vYDMLJzs0","CwnlA1u","Dg9cExrLC0i","B3jRzxjhBg8","ue5fvgC","u2HHCMvKv28","ueDHsMW","wvfpru4","AefJA01LC3m","uw1yzLm","ANP2Dgy","B3jLtMfTzxm","D1bwwfa","B2nRzxrgywK","C3nHz2vfDMu","Cgf5Bg9Hza","vKPbqMK","rev5C08","DLj5Bg4","m3WWFdf8nhW","rvL3Bhq","CgvYC2LZDgu","y2HHCKnVzgu","x1fVu01HBMe","rwzsEgW","y3ruAw1LB3u","rLzlBey","B2zMBgLUzq","swTIqM0","DhjPzxm","zePnCLa","tuvtu0fhrv8","z0fQt2u","Eff5Bu8","thrTweG","x3bHDgHlzxK","zw5HyMXLuw8","qKvYtNO","x3nVy2TLDa","Eg92Ehe","wefUvKS","Cg93","CNnVCL92ywW","x2n1CNnVCK0","zM9Yy2u","yK1yDue","rLr5wxC","x2nYzwf0zvm","ywnRtxnNswq","yNPeC3m","yw5Nzq","zv9ZDwnJzxm","q0PMDgu","zcWG","v3vnsfu","ihrPBwvVDxq","Dvjctfq","C0jnBK4","v1PtAhC","BMfTzq","CNrtzwq","BMvJDa","x2LUAxq","qujRDLC","lcbxzwjtB2m","uMvJB25Uzwm","yujPEue","BeP4yxy","B3bLBKrc","x2LUAxrqCM8","B2XuyKC","Ec11C2uT","uuHAB3m","Bwf4uMv0CMK","Bg9IywXty28","yxGGCMv0CMK","C3rHCNq","C21Ysg4","sgvfDeS","DMTZwwG","wKPqyvG","yNvMzMvYzwq","v2Trwfy","u2HQqMi","su5tvefova","CMvHzhLtDge","z2TmtfO","y3jLyxrLq2W","Dhj1y3rVCIa","q0LTDMG","s2PhqLC","vKrLBxi","AgnTzwC","Cw9Zx18","vuDUs3m","A1n0yxr1C0m","z1jRC3i","wMvQB2i","Aw50zwDLCIa","y3jLyxrLt2i","z2v0u3rVCMe","Cxz1Dxi","mhW0Fdj8m3W","uhjPBwfYEuS","zLzHr2m","C3jJ","rfv5uMm","ExbL","yNL0zxm","rwP4v1O","BxnN","tvzfBhi","D2zvAeq","rgT0vfK","CMvHzhDYAxq","CwPnyKy","zxHTqwi","BNrfBMrWB2K","A0zTse0","rLHmv1q","BKXPBMu","DMvY","BeT5C2G","zwnVBM5Ly3q","Bvvtvee","C2fmDeC","DKDbrKS","CM92AwrLigi","zxjYtM8","y29SBM8","DgHLBG","B3vUDa","BMPyzuy","zeLzA2i","wM9Su3i","vgLTzw91Da","EK9NrLq","B2fK","Ee5qBwe","u1vxD04","zgf0yq","C3vIyxjYyxK","z2v0sxrLBq","qvHjqxK","o2nOyxjZzxq","D016vhG","zgvIDwC","vhfSz2O","zxzOyuG","B25VCgvU","nvreEfLbtW","uxvLDwu","yxnL","AeHdBLG","ywrK","yNHqCxO","tuzpqvC","C3bSAwnL","x2LZqNjVD3m","uLbUzMe","wwvRwhK","A2rnyKi","DeLUDgvYy2u","zunjwNi","BvPAC2C","svH0sMO","Fdb8n3WZFdy","Ec1TC2CTCw8","AenSB3nLrxy","B2nRzxrtDwm","CMfNzvn5BMm","C2v0q3vYC28","ywLhwKy","r1vmB0m","wfrvr0C","yuXbvNq","t25guwG","CwnxwNm","EeTzrvC","zw5KCg9PBNq","r1LnzgC","DgHHBIbSB2m","wgH6A2S","C2XPy2u","mxWWFdn8nxW","zNDZxZeUmc4","zwfxtui","tePdANe","wxrdzKm","u1jQqva","EgvWEvu","ywXty29Wzq","DKnrqxC","ww5SsgO","A3fHBwq","CMvJB25Uzwm","q2XTwhO","BvvrAKq","zw50","AgfUz2u","BNruCMLLC0m","DgLTzw91DcW","zxHWB3j0CW","BKX5DeO","BKTizvq","qKjSCNi","tuTLthy","CxPlBfy","z29PBMCGyxC","v1Dpu0e","wgL6qNq","yMLUyxj5vhK","Cujhy3G","qKjnCg8","tg9Nsuq","BNDWCLq","DLfHtMu","ywzRuLG","Ahr0Chm6","rw9ctMW","BMfjquq","sKfirgy","zgnkB2W","x2n1CNnVCKy","rMDzy0m","n2DhCvDpAa","CNjcrKW","B25pCgvU","AwXSihvZzsa","y1LswMy","zw5XDwv1zq","AfbqwM4","Dw5KzwzPBMu","u1D6shq","nhW1","x2LUDgvYDMe","wfj2Chm","veHKAwe","uwXcz2K","zxDuAKG","zMzmAw5L","s0rxrxO","CvbUwKW","uuXZENm","D2LSBfjLy28","yLbqt0S","wuDbCfe","B3bLBIa","y2XVC2veqG","DfzpuhG","BNjkyuC","Eu9UC3C","nhW2Fdj8nxW","qwXOuhy","zNvUy3rPB24","Bwv0Ag9K","ywDL","reiGzMfPBgu","EuPsBKO","zwHWAw0","qMnMwgq","x29Ut3bLBG","yK5SwKG","BIWGAg9ZDg4","q3zRs3m","B21rDfa","ywvRzMG","ChvZAa","DhDlz3e","tKfusvzfx0u","tNj2CK0","qxbkrM0","AhvuDKG","qMXbD3C","B01vvNm","DhjPBq","C2DwyNO","y3vYC29Y","yvLwr1G","r2Dttum","qxDmv0O","sgfjvg4","Dw5RBM93BIa","yxnZAwDU","Bhm6ia","uhr3vuS","Ef9MCM9UDgK","Dg9VigXHCMC","qLLOtNu","vvjWtey","B3nLza","C2vUDa","wufOD3G","CM92AwrLihy","CMvZzxrfBMq","C29Tzq","wuPYqKy","suLor1u","rhHxz0C","uMLMAve","CwnyAwe","yw1Lu3bHy2u","zujSEfu","DxHhqKG","zejtuue","DMfUr0C","DgvSBe8","CM9YrxzLBNq","CgLbrgO","BwLUzW","uuHizwW","AhfjDMG","BMDuAw1LCG","x3bPBMDqB24","B25SAw5L","BvnYvKO","q2L1B1a","t3bLBKv2zw4","x29UugfNzu4","whvYy08","BwvZC2fNzq","EMr5zfu","z2v0t3DUuhi","x2rPC2nVBM4","DwDbBfO","vKzxsu4","CMvZzxruCMK","zgvS","sMjbEMm","BgPxsMG","x2LZtwLUAvq","mNW0","yMfSu2nVCgu","zxjFDhrS","B3LuELa","Aw5N","s1nxv0K","x3nLCuLK","s2f5v2W","ufvYEvq","r2TlvLO","A2v5","zcWGDw5RBM8","yw1L","C3rYAw5NAwy","AvLvD3u","uLbhDeG","qNjmuMO","vLfjtvG","wLnPExa","C2vUza","u3ffA2S","wg53z3m","tMvAA2K","ywrKrxzLBNq","A0zwDxC","y3jLyxrLrwW","C2HPzNq","Dg9Y","zuLizwO","zxjFCw9Zx2e","mhWYFdf8nhW","A1vdzuq","uxvrvvO","tejvq3u","EvrLuKy","yLPvC0S","zNLiBKC","tuD0z3a","uK9Qq0q","sxrpwLK","v3vYA3a","wMjzA1K","yNLL","y2nVrwu","uxDnAvG","x19LC01Vzhu","Fdr8ohWY","B2LUDfjLywm","CNzHBa","y29UBMvJDgK","vwfZCxu","CNj5wwK","A1PIy2u","zhDYtK0","Bw9OANa","y0HMz3C","BMvY","sefNvg8","BgLUzw5V","v2D0vKu","ELrXD2K","BeHTChC","C1Dyswe","BhrPCgXLihq","tg9JAW","AMfxuhu","mtm2mtm0nKHWsKn0Ca","te5QD3C","ALfctMC","y29Kzq","C2vYDMLJzq","y29Uy2f0","DMvUDa","y0TSqNi","z2D0veW","CMfTugfYyw0","ihzHBgLKigq","C2XSEKW","zxH0zw5ZAw8","r2DTu3y","y2HLy2Tszwe","z2rVB2C","DxrMofDYAxq","Evviuuu","z1rPBwvVDxq","wervreu","DMvYC2LVBMm","CgXLyxnLiha","D0zOy2u","y2vZC0HHBMq","rK5At2C","rKzly04","Ae9Wzw5fDMu","CKP5u3O","wKfkAMK","vfbswem","vw5Oyw5KBgu","tw9KDwXL","z2v0q3vYC28","zMLSzw5HBwu","CgLUz19VBMm","zxjFCw9Z","tMDXrhi","x0rctMfTzq","B25tDg9Wsw0","Cw1XwxK","twXbwMG","t29PCeK","vhDIDMS","DLPyEvy","AxjLza","t2jQzwn0","rgvKAwnHDgu","ChjVDg9JB2W","BNvTyMvY","qMfHtKG","tgDNCNO","AKfHELu","z2j0yuu","DgHZtNe","Ee13BM0","sLnqCLK","CwPSugi","wuTMqLm","Dg9tDhjPBMC","s2D6rfy","y29UBMvJDca","tw1Tr0G","wKDXANO","x2n1CNnVCK4","Cg9PBNrbBMq","CMvUDevUzha","zxjmCei","DKf1AMG","yMfJA3vWigu","AursEgS","BLbhteG","DhbQu3u","Bg1Js0e","BwvZ","wu5xs3q","Dw5ZAwDUzwq","y2XLyxi","DxjS","Bg9Nsurhzw4","BurqExG","yw5ZzM9YBvq","q3vZDg9Tq2W","zxrxB3jRq2G","q3vZDg9Trxi","C2vUzf9Hy2S","x3fVC0rc","EMTmwgi","Dgv4DfbHEwW","EwXHu04","rLDt","x3vYBa","mhW0Fdf8m3W","ywzL","EuP1yxa","rw9useW","qLjnzva","CMvHzg9UBhK","qw1VDw50","BeLIA1a","s0DwBKW","tvLWA0m","zNjVBujPDhm","rvfvt1m","B2zMC2v0","rvbjvg0","Dgv4Dc9Qyxy","ywWGy3vYC28","qwj1uui","wgX2rKi","zNHSq2y","Dg9iyxnO","AMzPEhC","uujQAgy","y0reD3y","wvzHzKe","AxnAzxjV","t21nsLm","tgHysfC","qvHqwxe","BgLUzq","zufJAW","Aw5KzxHpzG","ELrXyLq","rNjdre0","rKDQyMC","DLrzB2S","tNvyBMm","vMPWAu0","Cg9W","uePZthi","wMXXvui","x2HHBMrSzvi","zK5ZzvK","z052Avq","CgLUz1rPBwu","qu9Yzhe","AhD5z0e","rvHwt1y","vhvMvha","wNn5ve4","CNzHBfzHBhu","AgLNAa","uK1xEha","BM9vAfu","qNnmrhG","A2ntALi","Dgv4Dc9WBge","DMvYC2LVBG","tgLVtfa","wLzize0","AxnrB1nby2S","CNjVCK1LC3m","tgrxtMy","AeLPrxa","y3jLyxrLuMu","yMLUza","r2v1y1m","zsbHihn0CMK","ExvlELC","B3bLBG","sK5xBMK","D01vr1G","CgfNzxnOB3C","AgvHzgvYCW","uNjJDhO","CMvTB3zLrxy","C3vIC3rYAw4","vhb6Bfy","BezSDxnO","CNHRCM8","vufOshC","Chv0","BeHMrwi","rfHctMK","CwjRqwW","ihrPBwvZ","zxf1ywXZ","Dhr3Awq","zMXVB3i","CgfNzwHPzgu","D3fmD0W","zvvYBa","zhLPrgi","r21JEKG","ywDjCLO","wefRvfa","zvHWChC","jMPZy2fSBgi","y3bPywi","uNPgtgS","t0fWr3u","B25LCNjVCG","CgfYC2u","z1boC2O","AxnbCNjHEq","twjUEhG","CMLLC0nVDw4","yw1LoIa","CMntt0i","ywnRDxbfBMq","mhW1","BwLZzq","ywnRpwzYB24","tNLJzeG","qxHRvNG","tKHfBwK","tufyx1jfvfi","x2nVBM5Ly3q","y0jvuxe","AMDdBw4","zxmGCMvHy2G","B25tDgfYDfi","sfnisuu","zg14Avu","ywXS","y3znz0G","B3bLCNr5tMe","suTHvva","zKrgD2S","wvvquLy","lcbOB3n0BMe","yNL0zu9MzNm","Aw5PDcbrB1m","vhHlshi","uNH3AKK","x29UvgLTzw8","AKrKqNm","tLvkveC","q0vPA3G","BKvIy0K","CvvlDNG","zfDVCMTLCKC","y2fSBa","wNrSD0u","q09oveLovuu","BM93","DhjPzxmGCMu","vKr5Chu","q0Xpu0ve","q1PVt2e","swPZwei","zwrPyxrLBhK","y29UBMvJDeu","v2vIu29JA2u","rMvyAxy","yLP1sfG","zxq9DxrMltG","zw1PDa","igzHAwWSig0","vfnMA3K","ugPKENy","zw1iyKe","ANHAB3C","BLPyD1i","yKLyv3q","Dg5oDve","CwXjwve","BNviu3K","Eu1dvvu","ywr2yw5Jzq","u3vkseG","yM9L","yuzms08","A2v5CW","vwjiwfu","Bg9NsurozxC","zNvdwve","vhrOuu0","wMnyAxG","odu5nduWne9buvjtuq","ywnOzwq","C3bes1C","Dg9cExrLCW","x3nLBMrby2S","DhbizwfKzxi","sejdv08","q09ete8","Dwf3yKW","B254svu","CMvZB2X2zq","yNv3B0K","y3rsy00","rMHxAuG","zNjVBu51Bwi","ANncAfm","qNneD2e","sK1Xr2C","twj3vwq","zM9YrwfJAa","quL2u1i","ueroy1K","igzPzwXKoIa","runKzva","yu5nreC","ysbTDxn0igi","rLjptLrjrvi","yurAthe","CgLUz0LUDgu","BxnNsuq","AMjrrKi","seDKDuK","zgrjrcWGzgu","yxrHlcbKyxq","EgTwwNm","B0vVrMG","z2v0qwXS","DgjTDvy","u1DMEeW","yNL0zuXLBMC","mJi2ota1m2HluMvvEa","t1bftL9fuLi","r3zSCey","EfnYsxC","zKH2rfC","wfPtzgW","tfLbCue","ign1CNnVCIa","rKLmrv9ot1q","z2f1zLu","vxbKyxrLq28","seTbtwC","vNfNsMq","BgvUz3rO","BMrLEa","CKndvw4","sgvSBNq","Dg9hzw5LCMe","ywXPzcb1CMW","suLVwxO","CxrfwMK","sgLOsKq","CLzHBhvLCW","x2nSzwfYvgK","B25mAw5L","Dgv3shO","x3bYzwzPEa","ihjLy29UBMu","t1bftG","zNjVBNrPzxi","sxPhvxu","yLPSAK0","D3nLqKS","A2v0ignVBNm","z2v0qwXSs2u","uM5utem","v3bQzhy","zMzMzG","BwvZC2fNztO","txfKqwS","uevTruy","C3rVCcbPBw0","BMnVzgLUzW","uMfRywe","EwHMu1u","DgfIyxnL","yKvJzvC","BxbnDwi","y3r4","wKnKB3O","B1PIuMK","BKzZDKG","D0T5rKu","mZaWEenZtKfT","ugHuvwy","q0j4tvG","C0jf","rePAtMu","wxnvAwi","vhPWzKy","vuXjEvu","C2nYAxb0","sM9LtgC","vgDjwMm","vKPiENe","wefAsKq","AwXLtMfTzq","sefHBeK","Dez1zKe","aaaaaaaaaaa","B3bLCNr5","wfL5se0","EgL2BMm","q09otKvdveK","uwrPqu0"];return Yo=function(){return t},Yo()}var aS=Object[N(529)+"operty"],cS=Object[N(1195)+N(1486)+N(1343)],qx=(t,e)=>function(){return t&&(e=(0,t[{VQIMX:function(c,l){return c(l)}}[N(1221)](cS,t)[0]])(t=0)),e},lS=(t,e)=>{let r=N,i={tVopi:function(c,l,u,f){return c(l,u,f)}};for(var o in e)i[r(552)](aS,t,o,{get:e[o],enumerable:!0})};function dS(){return Fx||(Fx=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function uS(){let t=N;return zx||(zx=[IDBCursor[t(1766)+"e"][t(1529)],IDBCursor[t(1766)+"e"].continue,IDBCursor[t(1766)+"e"]["continue"+t(976)+"ey"]])}function fS(t){let e=N,r={kUCeD:function(o,c){return o(c)},NUJTG:function(o){return o()},ovmgo:e(435),bDEAF:function(o,c){return o+c},kdMbB:e(797),zCQff:e(1123),Zejob:function(o,c){return o(c)},BonNc:function(o,c){return o(c)},lEvXf:function(o){return o()},MIYxR:e(1706),bZUsK:function(o,c){return o instanceof c}},i=new Promise((o,c)=>{let l=e,u={EepqR:r.ovmgo,tVOPx:function(m,v){return m>v},aZJlp:function(m,v){return r[j(573)](m,v)},jkPOJ:function(m,v){return m===v},XAZJD:r[l(1034)],wwjps:r[l(781)],MrtvY:function(m,v){return r[l(970)](m,v)},yszIs:function(m,v){return r[l(569)](m,v)},EbPez:function(m){return r[l(1745)](m)}},f=()=>{let m=l;t[m(1435)+m(776)+m(1260)]("success",x),t["removeEv"+m(776)+"ner"](u[m(742)],p)},x=()=>{let m=l,v={tOVOH:function(_,b){return u[j(1122)](_,b)},UAWBy:function(_,b){return u[j(560)](_,b)},bUTZF:"Read pas"+m(581)};if(u.jkPOJ(u[m(1644)],u[m(420)])){let _=_0x1aaddc[m(1373)];if(v.tOVOH(v[m(782)](_,_0xa08893),_0x42f9e6.limit))throw new _0x29e32e(v.bUTZF);return _0x45b862[m(1373)]+=_0x486f2f,_}else u[m(1671)](o,u[m(493)](Bt,t[m(364)])),u[m(1663)](f)},p=()=>{let m=l;r[m(1235)](c,t[m(435)]),r[m(1497)](f)};t["addEvent"+l(1811)](r[l(612)],x),t[l(1227)+l(1811)](r[l(1795)],p)});return i.then(o=>{let c=e;r[c(1239)](o,IDBCursor)&&Hl[c(1796)](o,t)})[e(691)](()=>{}),Qo.set(i,t),i}function hS(t){let e=N,r={nPGLH:function(o,c){return o(c)},xkBhr:"AbortError",KFNCu:function(o){return o()},xMwnm:e(712),WQvWE:e(435),lJxav:e(1712)};if(Xo[e(1678)](t))return;let i=new Promise((o,c)=>{let l=e,u={rgeea:r[l(1324)],FnekU:r[l(1803)],dmxiU:r[l(940)],nNrwJ:function(m){return r.KFNCu(m)}},f=()=>{let m=l;t[m(1435)+m(776)+m(1260)](u.rgeea,x),t["removeEventListe"+m(1260)](u[m(411)],p),t[m(1435)+m(776)+m(1260)](u[m(1483)],p)},x=()=>{let m=l;u[m(700)](o),u[m(700)](f)},p=()=>{let m=l;r[m(1340)](c,t[m(435)]||new DOMException(r.xkBhr,r[m(828)])),r.KFNCu(f)};t[l(1227)+l(1811)](l(712),x),t["addEvent"+l(1811)](r.WQvWE,p),t[l(1227)+l(1811)](r[l(940)],p)});Xo[e(1796)](t,i)}function xS(t){ea={JIkeh:function(r,i){return r(i)}}.JIkeh(t,ea)}function pS(t){let e=N,r={TzpfF:function(i,o){return i(o)},GvlpF:function(i,o){return i(o)},PcyNO:function(i,o){return i!==o},XQzXP:"yiNJC",fEqut:function(i,o){return i(o)},BUkor:function(i,o){return i(o)},EYwlt:function(i,o){return i===o},GIwwO:function(i,o){return i in o},SNeNb:e(1672)+e(884),YAxbo:function(i){return i()}};return r[e(893)](t,IDBDatabase[e(1766)+"e"][e(471)+e(540)])&&!r.GIwwO(r[e(363)],IDBTransaction[e(1766)+"e"])?function(i,...o){let c=e,l=t[c(1502)](r[c(1638)](ss,this),i,...o);return Ul[c(1796)](l,i.sort?i[c(618)]():[i]),r[c(1638)](Bt,l)}:r[e(423)](uS).includes(t)?function(...i){let o=e,c={VclBI:function(l,u){return r[j(1581)](l,u)},zTqwi:function(l,u){return r[j(1638)](l,u)}};if(r.PcyNO(o(956),r.XQzXP))return t[o(1738)](r[o(415)](ss,this),i),Bt(Hl[o(652)](this));{let l={mPQlT:function(u,f){return uCTMps.VclBI(u,f)},ZJPaX:function(u,f){let x=o;return uCTMps[x(1264)](u,f)}};return function(...u){let f=o;return _0x4e4dac[f(1738)](l.mPQlT(_0x591e21,this),u),l[f(953)](_0x26b771,_0x3be290[f(652)](this))}}}:function(...i){let o=e;return r[o(741)](Bt,t[o(1738)](ss(this),i))}}function gS(t){let e=N,r={JSPrY:function(i,o){return i===o},gqflQ:function(i,o){return i(o)},VwFcW:function(i,o){return i instanceof o},BeezL:function(i,o,c){return i(o,c)},Yswze:function(i){return i()}};return r[e(1325)](typeof t,e(1127))?r[e(539)](pS,t):(r.VwFcW(t,IDBTransaction)&&hS(t),r.BeezL(jx,t,r.Yswze(dS))?new Proxy(t,ea):t)}function Bt(t){let e=N,r={TthQM:function(o,c){return o instanceof c},YBuDq:function(o,c){return o(c)}};if(r[e(1537)](t,IDBRequest))return r.YBuDq(fS,t);if(Jo[e(1678)](t))return Jo[e(652)](t);let i=r[e(625)](gS,t);return i!==t&&(Jo[e(1796)](t,i),Qo[e(1796)](i,t)),i}var jx,Fx,zx,Hl,Xo,Ul,Jo,Qo,ea,ss,Ux=qx({"node_modules/idb/build/wrap-idb-value.js"(){let t=N,e={emHbA:function(r,i){return r===i},gTUuY:"done",IyYex:t(1672)+t(884),amRTD:function(r,i){return r instanceof i},SRjAP:"EAnnf",ggtTL:function(r,i){return r in i}};jx=(r,i)=>i[t(1168)](o=>r instanceof o),Hl=new WeakMap,Xo=new WeakMap,Ul=new WeakMap,Jo=new WeakMap,Qo=new WeakMap,ea={get(r,i,o){let c=t;if(r instanceof IDBTransaction){if(e[c(1521)](i,e.gTUuY))return Xo[c(652)](r);if(e[c(1521)](i,e.IyYex))return r[c(1672)+c(884)]||Ul[c(652)](r);if(i===c(456))return o[c(1672)+c(884)][1]?void 0:o[c(1672)+"ore"](o[c(1672)+c(884)][0])}return Bt(r[i])},set(r,i,o){return r[i]=o,!0},has(r,i){let o=t;if(e.amRTD(r,IDBTransaction)&&(e[o(1521)](i,o(854))||i==="store")){if(e.emHbA(e[o(1062)],e[o(1062)]))return!0;++_0x4edd85,_0x36fa66+=4}return e[o(1278)](i,r)}},ss=r=>Qo[t(652)](r)}}),Wx={};function j(t,e){t=t-345;let r=Yo(),i=r[t];if(j.lPqjvZ===void 0){var o=function(f){let x="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",p="",m="";for(let v=0,_,b,I=0;b=f.charAt(I++);~b&&(_=v%4?_*64+b:b,v++%4)?p+=String.fromCharCode(255&_>>(-2*v&6)):0)b=x.indexOf(b);for(let v=0,_=p.length;v<_;v++)m+="%"+("00"+p.charCodeAt(v).toString(16)).slice(-2);return decodeURIComponent(m)};j.wkBXHa=o,j.UPevKW={},j.lPqjvZ=!0}let c=r[0],l=t+c,u=j.UPevKW[l];return u?i=u:(i=j.wkBXHa(i),j.UPevKW[l]=i),i}lS(Wx,{deleteDB:()=>wS,openDB:()=>mS,unwrap:()=>ss,wrap:()=>Bt});function mS(t,e,{blocked:r,upgrade:i,blocking:o,terminated:c}={}){let l=N,u={zpcJg:function(p,m,v,_,b){return p(m,v,_,b)},JhouP:function(p,m){return p(m)},xWtXh:function(p,m){return p(m)},esqmc:l(532),RxwjI:function(p,m){return p(m)},QFbZI:"upgraden"+l(643),LdWNf:"blocked"},f=indexedDB.open(t,e),x=u[l(1494)](Bt,f);return i&&f[l(1227)+"Listener"](u[l(414)],p=>{let m=l;u.zpcJg(i,u.JhouP(Bt,f[m(364)]),p[m(1759)+"on"],p[m(1685)+"on"],u[m(1783)](Bt,f["transact"+m(540)]))}),r&&f["addEvent"+l(1811)](u[l(1422)],()=>r()),x.then(p=>{let m=l;c&&p[m(1227)+m(1811)](u[m(418)],()=>c()),o&&p[m(1227)+m(1811)](m(1290)+"hange",()=>o())})[l(691)](()=>{}),x}function wS(t,{blocked:e}={}){let r=N,i={CZoOa:"blocked",PUryT:function(c,l){return c(l)}},o=indexedDB["deleteDa"+r(1624)](t);return e&&o[r(1227)+"Listener"](i[r(1509)],()=>e()),i[r(1212)](Bt,o).then(()=>{})}function Hx(t,e){let r=N,i={QDdRh:r(1706),LrWFS:r(1304)+r(377)+"t",uLBuX:r(532),NWhvl:r(1290)+r(1072),VJHzq:r(987)+"e",maYHG:function(f,x){return f instanceof x},TgIZc:function(f,x){return f in x},VXOaR:function(f,x){return f===x},xOeOP:r(758),PhTUf:r(701),tOViV:r(1651),dwJEE:function(f,x){return f!==x},QAOfc:r(511)};if(!(i[r(354)](t,IDBDatabase)&&!i[r(1642)](e,t)&&i.VXOaR(typeof e,i[r(572)])))if(i[r(1770)](i[r(1633)],i[r(645)]))_0x157b7b(i.QDdRh),this[r(349)](r(1304)+"e_success",_0x584880),this[r(349)](i.LrWFS,_0x26c114);else return;if(Zo.get(e))return Zo[r(652)](e);let o=e.replace(/FromIndex$/,""),c=i[r(734)](e,o),l=$x[r(1812)](o);if(!(o in(c?IDBIndex:IDBObjectStore).prototype)||!(l||Kx[r(1812)](o)))if(i[r(754)]!==i[r(754)])_0x2d5003&&_0x563841[r(1227)+"Listener"](CWGxti[r(764)],()=>_0x537607()),_0x3eb999&&_0xd0df02[r(1227)+r(1811)](CWGxti[r(448)],()=>_0x50a559());else return;let u=async function(f,...x){let p=r,m=this[p(471)+"ion"](f,l?i[p(1643)]:p(1366)),v=m.store;return c&&(v=v[p(806)](x[p(1230)]())),(await Promise[p(1484)]([v[o](...x),l&&m[p(854)]]))[0]};return Zo[r(1796)](e,u),u}var Kx,$x,Zo,_S=qx({"node_modules/idb/build/index.js"(){let t=N,e={kKPkb:function(o){return o()},qIhrK:t(652),iYUwu:"getKey",FEExk:t(1575),VGCkz:t(1613)+"ys",Asmmu:"count",pqGmI:function(o,c){return o(c)},eHxIH:t(1441),GUNMD:t(1027),QVTgv:"delete",VuYfn:"clear"},r=(t(1057)+t(1204))[t(1721)]("|"),i=0;for(;;){switch(r[i++]){case"0":e[t(1826)](Ux);continue;case"1":e[t(1826)](Ux);continue;case"2":Zo=new Map;continue;case"3":Kx=[e.qIhrK,e[t(1218)],e.FEExk,e[t(1791)],e[t(557)]];continue;case"4":e[t(1752)](xS,o=>({...o,get:(c,l,u)=>Hx(c,l)||o[t(652)](c,l,u),has:(c,l)=>!!Hx(c,l)||o[t(1678)](c,l)}));continue;case"5":$x=[e.eHxIH,e.GUNMD,e[t(872)],e[t(1767)]];continue}break}}}),yS={idb:function(t){let e=N;t[e(1075)]=Promise[e(1549)]().then(()=>(_S(),Wx))[e(1003)](function(r){return r})}},Gx={};function Mt(t){let e=N,r={dPYTw:function(u,f){return u!==f}},i=(e(892)+"2")[e(1721)]("|"),o=0;for(;;){switch(i[o++]){case"0":if(r[e(1822)](void 0,l))return l[e(1075)];continue;case"1":var c=Gx[t]={exports:{}};continue;case"2":return c[e(1075)];case"3":var l=Gx[t];continue;case"4":yS[t](c,c[e(1075)],Mt);continue}break}}(()=>{let t=N,e={pXdFd:t(975)+"1",umIMb:function(r,i){return r!==i},Helnt:function(r,i){return r!==i},qcXia:t(1240)};Mt.d=(r,i)=>{let o=t,c={NeZki:e[o(1805)],YQOEN:function(x,p){return e.umIMb(x,p)}};if(e[o(1595)](e[o(1173)],o(1005)))for(var l in i)Mt.o(i,l)&&!Mt.o(r,l)&&Object[o(529)+o(1649)](r,l,{enumerable:!0,get:i[l]});else{let x=c[o(1226)][o(1721)]("|"),p=0;for(;;){switch(x[p++]){case"0":var u=_0x49c011[_0x1b1fbe];continue;case"1":return f[o(1075)];case"2":var f=_0x4db61d[_0x20e3d0]={exports:{}};continue;case"3":_0x2dfa6d[_0x2e2695](f,f[o(1075)],_0x34b616);continue;case"4":if(IMohMu[o(880)](void 0,u))return u.exports;continue}break}}}})(),(()=>{let t=N;Mt.o=(e,r)=>Object[t(1766)+"e"][t(593)+t(1649)][t(1502)](e,r)})(),(()=>{let t=N,e={hwygA:function(r,i){return r!=i},BBMpo:t(1105)+"d",KQdnG:t(1301)};Mt.r=r=>{let i=t;e[i(1406)](e[i(1086)],typeof Symbol)&&Symbol[i(1328)+i(486)]&&Object[i(529)+i(1649)](r,Symbol[i(1328)+i(486)],{value:e[i(387)]}),Object[i(529)+i(1649)](r,i(1249)+"le",{value:!0})}})();var Pe={};(()=>{let t=N,e={tellO:function(a,n){return a+n},aFLKO:function(a,n){return a*n},Rakaa:function(a,n,s){return a(n,s)},PDuaq:t(738),YVafA:function(a,n,s){return a(n,s)},fHvDW:function(a,n){return a(n)},QBjhf:function(a,n){return a(n)},exmAb:function(a,n){return a+n},iUFBQ:function(a,n){return a(n)},mSrVJ:t(682),XZSdl:t(1616),QlBgi:function(a,n){return a===n},QHZos:"BshBu",MmmGH:function(a,n){return a(n)},saLtG:t(1719)+t(1719)+t(1719)+t(1719),VFWIN:function(a,n){return a===n},QlzqR:"JUhPL",WZShw:function(a,n){return a<n},nFsvH:function(a,n){return a!==n},HihJD:function(a,n){return a-n},jnLLH:function(a,n){return a!==n},qCALE:function(a,n){return a<n},LNjww:function(a,n){return a===n},HHOJB:function(a,n){return a<n},JynbR:function(a,n){return a!==n},Wpjdv:function(a,n,s){return a(n,s)},OoipI:function(a,n,s){return a(n,s)},EfRxl:function(a,n){return a(n)},cFYXJ:function(a,n){return a>>>n},QJyRA:function(a,n,s){return a(n,s)},rNpFw:function(a,n,s){return a(n,s)},TpzlV:function(a,n){return a&n},oHZTf:t(444)+t(1695)+t(1561)+t(1214),JoOdr:function(a){return a()},Wurkp:function(a,n){return a|n},qzKlV:function(a,n){return a|n},AXIAy:function(a,n){return a<<n},ORHYd:function(a,n){return a&n},rOakf:function(a,n){return a<<n},yJuap:function(a,n){return a&n},qfqMM:function(a,n){return a&n},zdydU:function(a,n){return a>>n},moaeE:function(a,n){return a&n},erODb:function(a,n){return a!==n},rtSed:t(1705),mwGZS:t(992),GeucS:function(a,n,s){return a(n,s)},PwpyU:function(a,n,s){return a(n,s)},sozit:function(a,n,s){return a(n,s)},QNdWk:function(a,n){return a(n)},CiuoP:t(361),IzKUC:function(a,n,s){return a(n,s)},gdyOU:function(a,n,s){return a(n,s)},MtWNZ:function(a,n,s){return a(n,s)},PgAft:function(a,n){return a(n)},eaWMB:function(a,n){return a!==n},xXCoT:"RbEYx",YdPVU:function(a,n,s){return a(n,s)},nKfxI:function(a,n){return a!==n},ECdeP:function(a,n,s){return a(n,s)},BlSqA:function(a,n,s){return a(n,s)},jgCmn:function(a,n,s){return a(n,s)},HKAMg:function(a,n,s){return a(n,s)},DSNrG:function(a,n,s){return a(n,s)},MRMiz:function(a,n){return a+n},CODLO:t(1070),EoBNl:function(a,n){return a(n)},qtEqU:function(a,n){return a(n)},Lggrz:function(a,n,s){return a(n,s)},IINGU:function(a,n,s){return a(n,s)},fzylE:function(a,n){return a(n)},qnXJa:function(a,n){return a(n)},aDZLq:function(a,n){return a(n)},Hmaoj:function(a,n){return a(n)},hqIvh:function(a,n,s){return a(n,s)},vyxVA:function(a,n,s){return a(n,s)},kXXIP:function(a,n){return a(n)},cpiab:function(a,n){return a===n},oZbRi:t(444)+t(1695)+t(1561)+t(1820),XAnVK:function(a,n){return a===n},NyiXr:t(444)+t(1695)+t(1561)+"LogID",ZtlwE:function(a,n){return a===n},kVKcW:t(444)+"required"+t(1561)+"service",thsNq:function(a,n){return a(n)},LhXHW:function(a,n){return a+n},jQBNg:function(a,n){return a+n},vGAFK:"Unimplem"+t(679)+"pe: ",yQEqr:t(1141),dPXKF:t(1569),XAkTP:function(a,n){return a>>n},qPnZL:function(a,n){return a>=n},NyYrt:function(a,n){return a>>>n},sWXIa:function(a,n){return a|n},UYPmh:function(a,n){return a<<n},bJxFv:function(a,n){return a<<n},vUofI:function(a,n){return a!==n},wtDeu:"MBbYp",Tqlgj:t(479),idkVN:function(a,n){return a===n},wMzTx:"error",FeXiv:t(532),fydeg:t(1800),RPnfa:function(a,n){return a>n},ARBlZ:t(1654)+t(581),BvtsB:function(a,n){return a*n},pcnpO:function(a,n){return a>n},VmMeu:"Read pas"+t(581),GYMdg:function(a,n,s){return a(n,s)},qbkAl:function(a,n){return a&n},bxcdz:function(a,n){return a>>>n},NKcQo:function(a,n){return a&n},HyZqb:function(a,n){return a>>>n},NzDoA:function(a,n,s){return a(n,s)},ndPhx:function(a,n){return a<n},FTjjP:t(842),ETllm:function(a,n){return a+n},vCQAw:function(a,n){return a===n},JoeLg:function(a,n){return a&n},eWdeA:function(a,n){return a(n)},QGqLP:function(a,n){return a===n},kOILv:function(a,n){return a&n},CecHu:function(a,n){return a>=n},DtAiq:function(a,n){return a+n},iRUIP:function(a,n){return a+n},PEmEF:function(a,n){return a&n},DymLD:function(a,n){return a|n},bNlZH:function(a,n){return a<<n},VPffh:function(a,n){return a(n)},KgzDV:function(a,n){return a==n},NscyF:function(a,n){return a+n},sdcaU:function(a,n){return a+n},yLiBN:function(a,n){return a+n},uXXxV:function(a,n){return a+n},syZwi:function(a,n){return a!==n},EbSVP:function(a,n){return a&n},cKUbD:function(a,n){return a<<n},CwNwo:function(a,n){return a|n},ylaSN:function(a,n){return a&n},PqhRA:function(a,n){return a&n},vibvS:function(a,n){return a<=n},Ubmqy:function(a,n){return a>=n},smrHn:function(a,n){return a+n},aYVGX:function(a,n){return a!==n},PGaJl:function(a,n){return a+n},ywsqE:function(a,n){return a+n},DEysO:function(a,n){return a+n},ctRcM:function(a,n){return a+n},hUAZm:function(a,n){return a<<n},tewHz:function(a,n){return a|n},MGtgp:function(a,n){return a|n},eePuJ:function(a,n){return a&n},vanGG:function(a,n){return a<<n},SxMkd:function(a,n){return a&n},Gxiof:function(a,n){return a<<n},VJABi:function(a,n){return a>n},gbtaE:function(a,n,s){return a(n,s)},MYpkC:function(a,n){return a>>n},RMWxp:function(a,n){return a<n},EmmsR:function(a,n){return a>=n},TpLwR:function(a,n){return a<=n},VMyEB:function(a,n){return a<<n},eSpoa:function(a,n){return a<n},BrLRj:function(a,n,s){return a(n,s)},pnzAT:function(a,n,s){return a(n,s)},Abpsi:function(a,n){return a>=n},yUHQE:function(a,n){return a-n},rcSOB:function(a,n){return a+n},dyiDb:function(a,n){return a<n},FFKcN:function(a,n){return a<n},kCtQH:function(a,n){return a&n},bIXWt:"teHbP",XruKk:function(a,n){return a>>n},tFufA:function(a,n){return a|n},RiGfH:function(a,n){return a&n},xtkAQ:function(a,n,s){return a(n,s)},Vksbk:function(a,n,s){return a(n,s)},gLKQe:function(a,n){return a<<n},ljWJh:function(a,n){return a&n},guVJC:function(a,n){return a>=n},VqgJd:function(a,n,s){return a(n,s)},xSrIw:function(a,n){return a|n},ayKNC:function(a,n,s){return a(n,s)},IWbhp:function(a,n,s){return a(n,s)},RnTLC:function(a,n,s){return a(n,s)},wwAHC:function(a,n){return a!==n},tpXds:t(397),ZlqUB:function(a,n){return a(n)},dBSQA:function(a,n){return a<<n},rrBFL:function(a,n){return a&n},BcfXd:function(a,n){return a&n},eLvqi:function(a,n){return a!==n},edUXc:"EwCrY",LioLP:function(a,n){return a&n},tbmuV:function(a,n){return a&n},lFucL:function(a,n){return a(n)},vCjQK:function(a,n){return a&n},yTeRF:function(a,n){return a(n)},ZbYkY:function(a,n){return a(n)},uxGBH:function(a,n){return a(n)},geWry:function(a,n){return a&n},nXNni:function(a,n){return a<<n},abshl:function(a,n){return a<<n},cKFEB:function(a,n){return a|n},fOuhn:function(a,n){return a>>>n},CExps:function(a,n){return a|n},ZAJji:function(a,n){return a>>>n},cNMxS:function(a,n){return a===n},cZFCg:function(a,n){return a<n},bPPOK:function(a,n){return a<n},eEwSV:function(a,n){return a<n},wKyFE:function(a,n){return a<n},EoTHL:function(a,n,s){return a(n,s)},lomVH:function(a,n){return a&n},ItOZY:function(a,n){return a|n},MKeLv:function(a,n){return a+n},lwdvU:function(a,n){return a|n},uZHxf:function(a,n){return a>>>n},JMqGg:function(a,n){return a+n},yJRnJ:function(a,n){return a>>>n},RaFFS:function(a,n){return a>>>n},gPNsj:function(a,n){return a+n},pFIHH:function(a,n){return a!==n},UbHXU:function(a,n){return a|n},bUIwi:function(a,n){return a&n},KDWEz:function(a,n){return a>>>n},xTmxH:function(a,n){return a+n},JIzVj:function(a,n){return a!==n},nZXwR:function(a,n){return a&n},JhONg:function(a,n){return a>>>n},OApGu:function(a,n){return a!==n},GSfCz:function(a,n){return a&n},lgVPU:"LZYBW",nfObE:t(478),nKHeT:function(a,n){return a(n)},oMUVs:function(a,n){return a===n},KDGOa:t(1500),AYxiw:function(a,n){return a|n},HBCWO:function(a,n){return a<<n},vRyln:function(a,n){return a<<n},vidRT:function(a,n){return a<<n},zTqbT:function(a,n){return a|n},mTMUV:function(a,n){return a<<n},noKjb:function(a,n){return a<<n},zAcWO:function(a,n){return a|n},cvMgH:function(a,n){return a|n},gRksr:function(a,n){return a<<n},AtFVf:function(a,n){return a===n},ZazYt:function(a,n){return a<<n},NrvrM:function(a,n){return a>>>n},bYxFd:function(a,n){return a|n},XizBt:function(a,n){return a<<n},LJCjq:function(a,n){return a>>>n},jxZow:function(a,n){return a&n},iYdXd:function(a,n){return a&n},bMXuA:function(a,n){return a(n)},GgmSv:function(a,n){return a<=n},lIbkP:function(a,n){return a|n},rxtDz:function(a,n){return a+n},HSHIE:function(a,n){return a>>>n},qcWZs:function(a,n){return a>>>n},xkVZs:function(a,n){return a>>>n},eLSIV:t(1706),LBUCu:function(a,n){return a===n},xapTC:t(816),HaITn:function(a,n){return a&n},Jwhgc:function(a,n){return a>>>n},hEWNU:"YkMeI",oRBZN:t(1679),hNRGN:function(a,n){return a&n},yMCUU:function(a,n){return a&n},BBlrr:function(a,n){return a>>>n},vglom:function(a,n){return a&n},KDCsn:function(a,n){return a+n},PDNcY:function(a,n){return a>>>n},eISTT:function(a,n){return a+n},KSWWI:function(a,n){return a+n},xKYEW:function(a,n){return a|n},nZWmq:function(a,n){return a<<n},WgtVE:function(a,n){return a!==n},HWYqK:function(a,n){return a>>>n},vQaNe:function(a,n){return a===n},naIAD:function(a,n){return a===n},QdiAM:function(a,n,s){return a(n,s)},QLszs:function(a,n,s){return a(n,s)},wyrbf:function(a,n){return a===n},Pjdzv:t(1799),jAazU:"cBVjZ",JbAzc:function(a,n){return a&n},HGduI:function(a,n){return a>>>n},TRnOn:function(a,n){return a>>>n},XAxrL:function(a,n){return a>>>n},edGuz:function(a,n){return a&n},wseBK:t(1326),tnNuQ:"shzPe",FVKlF:"3|2|1|0|"+t(1107),IvFuk:"MESSAGE_"+t(677),EPeFV:t(1476)+"IES_ERROR",wMMPd:t(1652)+t(792),ABkvW:"NATIVE_E"+t(504),VBWvv:t(1580)+"OR",UAhHw:function(a,n){return a===n},gaufU:"JvYEP",jfixw:function(a,n){return a===n},LNZkW:function(a,n){return a===n},ztQWs:function(a,n){return a==n},iDRxk:function(a,n){return a>n},HAalI:t(534),FIxpE:function(a,n){return a===n},TmfLY:t(1300)+"d error.",PtwUK:function(a,n){return a+n},XePeX:function(a,n){return a+n},KayWl:function(a,n){return a===n},KObYF:function(a,n){return a===n},JmTdH:function(a,n,s){return a(n,s)},pIbKo:t(630),mRXnT:t(1232),erLpB:function(a,n,s){return a(n,s)},riCIj:t(1429),oqlIC:function(a,n){return a===n},dJMrP:t(1327),VzRpC:function(a,n,s){return a(n,s)},ULIyU:function(a,n,s){return a(n,s)},cDDwv:function(a,n){return a instanceof n},piADj:function(a,n){return a===n},CzytD:t(1085),oEoFh:function(a,n){return a===n},yvyME:t(1749),TTvsP:function(a,n){return a||n},yReJw:"undefined",eiUhG:function(a,n){return a<<n},xovxq:function(a,n){return a!=n},ZVHdM:function(a,n){return a<=n},IkbBm:"next() c"+t(866)+t(1267)+t(775)+"process",OqNzT:t(1797),VjpiM:function(a,n){return a===n},onxIU:function(a,n){return a===n},ewTjH:function(a,n){return a+n},qlIYQ:function(a,n){return a<n},EucCE:function(a,n){return a>=n},Twbvk:function(a,n){return a<n},ERkCb:function(a,n){return a|n},UJjSE:function(a,n){return a<<n},CEikx:function(a,n){return a&n},HreFb:function(a,n){return a<n},ftKDR:function(a,n){return a&n},XRvps:function(a,n){return a-n},LeewP:function(a,n){return a|n},bzDss:function(a,n){return a<<n},vksYh:function(a,n){return a&n},tMLHt:function(a,n){return a&n},ccoEe:t(577),WnFdC:t(1137),ZCdoz:function(a,n){return a>>n},zcsAG:function(a,n){return a|n},BlAww:function(a,n){return a===n},ytYTd:function(a,n){return a&n},vDIuB:t(808)+t(1470),YJrBF:function(a,n){return a+n},YocLu:function(a,n){return a&n},cRMAu:function(a,n){return a>>n},fMcnf:function(a,n){return a&n},WkQXV:function(a,n){return a|n},HZCrT:function(a,n){return a&n},fLKKC:function(a,n){return a-n},rJySz:t(758),QuQUZ:function(a,n){return a instanceof n},UrZSV:t(717),GFkws:"ZCTuk",NuXnc:function(a,n){return a!=n},PJsLr:t(653)+"ion/json",TPDuL:t(1416)+"in;chars"+t(1516),nkBAF:"ppe",MVElr:"idb",YgUDk:t(1310),WWOSA:function(a,n){return a(n)},JzmpK:t(1155)+t(640),PlmCT:t(1375)+t(796),NycdH:"start",PKcJU:function(a,n){return a|n},RifiQ:function(a,n){return a|n},fxlCf:function(a,n){return a+n},rbIgC:function(a,n){return a|n},olxrz:function(a,n){return a+n},WuMHU:function(a,n){return a<<n},vewIy:function(a,n){return a+n},nuHSy:function(a,n){return a!==n},AnoxK:t(1344),Kpvzw:t(1255),ymcDp:t(1393),mDPyx:t(1332),dVdbg:"2|4|0|1|3",Ioppa:t(731),Uasqu:"TuRbR",bZljM:function(a,n){return a||n},XJbWf:"KMoge",kZbce:function(a,n,s){return a(n,s)},Rbwaq:function(a,n){return a!==n},RPGtH:t(1388),sYdif:function(a,n){return a||n},MFOAW:"reconnect",iWkMt:t(491),qAwbr:t(613),NLqvA:function(a,n){return a||n},SrinG:function(a,n){return a||n},hFYIG:function(a,n){return a===n},IvXNh:t(1737),hIiEp:function(a,n){return a||n},CCjWc:t(766),dIYkb:function(a,n){return a!=n},amfgm:t(1492)+t(1130)+"d",pocFk:t(413)+"4",zVELc:"message",aJyet:t(1413),ouvAU:t(930),kkEDG:function(a,n){return a!==n},YUPRV:t(1021),VnhgC:function(a,n){return a*n},IKaUP:"CqGlD",fJVnF:t(1248),afkRX:function(a,n){return a(n)},vAujh:function(a,n,s,d){return a(n,s,d)},Xnwgs:t(1159)+t(1305),BRMeP:t(1159)+t(1233)+"ck",BaaNH:"x_fronti"+t(830)+"k",ITEnR:function(a,n){return a(n)},FgYcC:function(a,n,s,d){return a(n,s,d)},kHvUm:function(a,n){return a!==n},lHfEb:"ElBOo",hetoc:t(592),URpLF:function(a,n,s,d){return a(n,s,d)},cYRZf:t(1784),pBzHk:function(a,n){return a&&n},cBUQq:t(770),SUWwN:function(a,n){return a||n},aNMDG:t(390),HCRxd:function(a){return a()},qcKkU:t(385),nHZEN:function(a,n){return a===n},Gegjw:"ZFUDb",wPVXP:function(a,n){return a(n)},omQtP:function(a,n){return a instanceof n},gNviT:t(653)+t(427)+t(1017)+t(1792),QFTWp:t(559)+"e",LtmXH:t(1743),lKysh:function(a,n){return a(n)},EglzS:function(a,n){return a+n},fuCYQ:t(1739),WjisH:t(783)+"0",azvXY:t(1066),njwtN:function(a,n){return a>=n},AwLWJ:function(a,n,s,d){return a(n,s,d)},JzKJe:function(a,n){return a+n},UPGMQ:t(794),vsvBD:t(1414),tMfrb:function(a,n){return a+n},ApJFm:function(a,n){return a<n},qjMbF:function(a,n,s){return a(n,s)},RObEt:function(a,n){return a<<n},rHPQw:"0|2|4|1|3",VDypu:function(a,n){return a+n},DcoKA:function(a,n){return a<n},npmOq:function(a,n){return a|n},vxKfP:function(a,n){return a+n},oyTzP:function(a,n){return a|n},CJfte:function(a,n){return a|n},wRoMy:function(a,n){return a<<n},bEceW:function(a,n){return a+n},BKRsK:function(a,n){return a+n},yhfSU:function(a,n){return a+n},nohRc:function(a,n){return a+n},XlvFB:function(a,n){return a>>>n},xepyU:function(a,n){return a>>>n},eKzzx:function(a,n){return a===n},aBiyA:t(1292),zXqWj:t(1806),GgSMC:function(a,n){return a+n},IIoYz:function(a,n){return a&n},YAhwx:function(a,n){return a<n},IjsXB:function(a,n){return a|n},vpqhJ:function(a,n){return a<<n},nbGFW:function(a,n){return a<n},aNgYW:function(a,n){return a+n},LGBlz:t(750)+t(1039)+t(1250),QmXfS:t(1274),PwPfw:function(a,n,s,d){return a(n,s,d)},oSxkT:"curvalue",uRBLT:t(400),HeEtK:"cursor.s"+t(737),psvjV:function(a,n){return a(n)},qvuur:function(a,n,s){return a(n,s)},OmMJS:function(a,n){return a+n},CtIxX:t(685)+t(617),akDfE:t(1771)+t(1216),ZcXix:t(638)+t(1601),SWfxL:t(458),GdgRQ:t(957),ogwOe:t(1504),hUWtG:function(a){return a()},dcJol:"setcursor",fLfDU:t(1717),UXvYC:t(1106),RzFLk:function(a,n){return a!==n},fDFwk:t(919),ehpim:t(494),ROjCD:t(489),nwprT:function(a,n,s){return a(n,s)},LEcBK:function(a,n){return a(n)},tKsrJ:t(1599),eVSuZ:function(a,n,s){return a(n,s)},stsEo:function(a,n,s){return a(n,s)},QtZAj:"x_fronti"+t(1206),dDESF:t(1040)+"s",hTPTE:function(a,n,s){return a(n,s)},ZSiyp:t(763)+t(405)+"e",DktTY:function(a,n){return a(n)},FGjbg:t(763)+t(915)+"ue",TSfky:function(a){return a()},GwWvF:function(a,n){return a>n},DxWgG:t(1309),EBXJE:function(a,n){return a!==n},kYiGV:t(906),lAYHs:t(561),AIvSR:function(a){return a()},Xhzkk:function(a){return a()},XYyHM:function(a,n){return a+n},AbuQB:t(1823),VnRne:function(a,n){return a&&n},SbGAz:function(a){return a()},Vxrpx:function(a,n){return a(n)},mRyPj:function(a){return a()},LUHrM:function(a,n){return a===n},yuKzW:function(a,n){return a!==n},buwoI:function(a,n){return a===n},AlhPv:t(419),mohjp:function(a,n){return a===n},ngogO:function(a,n,s){return a(n,s)},FjHJH:function(a,n){return a===n},owUFQ:t(1007),Tsagk:function(a,n,s){return a(n,s)},ggLak:function(a,n,s){return a(n,s)},pPQkj:function(a,n,s){return a(n,s)},bZuHX:function(a,n,s){return a(n,s)},pobfH:t(1246),mUSTA:function(a,n){return a(n)},eCIZr:t(1415),Jdjzl:"arraybuffer",DJZNe:t(453),YGApQ:function(a,n){return a/n},iQwJV:t(394),jrOmJ:function(a,n){return a==n},SqEkk:function(a,n){return a===n},OnFQh:t(1291)+t(1166)+t(1597),FeVNZ:t(1291)+t(347)+t(1815)+t(937)+t(1612)+t(961)+"is undef"+t(1690),CImvh:t(1620)+"ediately"+t(1606)+"ct",Mbnxx:t(1187),sYmoH:t(900),LrXhM:t(1449),quXYk:"pageshow",AAXTF:function(a,n){return a!==n},QOLMs:t(1530),txcUc:function(a,n){return a!==n},DRDtu:function(a,n){return a===n},dqurj:"ALvcb",QHHel:function(a,n){return a==n},BWxBv:"ws://",GxPHA:"wss://",gTmYY:t(1447),jCEZy:t(1291)+t(1e3)+t(1571)+t(1747)+"r ttwID",TufTp:t(1127),RyeRN:function(a){return a()},JAHDf:function(a,n,s){return a(n,s)},WAAqM:t(642),PNETg:function(a,n){return a===n},NRtFB:t(965),hPPZn:t(1554),BYhNu:function(a,n,s){return a(n,s)},YekXy:function(a,n){return a||n},wfUhD:function(a,n,s){return a(n,s)},zkLXb:function(a,n){return a-n},nozXO:function(a,n,s){return a(n,s)},YtCfC:function(a,n){return a!==n},aekfh:function(a,n){return a===n},ymOrA:t(1037),TxKHr:function(a,n){return a(n)},wqLwL:t(1565)+">",ACbzH:function(a,n){return a-n},lGtde:function(a,n){return a>n},YfQgD:function(a,n,s){return a(n,s)},aiGZF:function(a,n,s){return a(n,s)},yOnsw:t(1304)+t(377)+"t",ZPZwp:"timeout",VDemr:t(1531),LYAqA:"VusXs",SJCuO:"going aw"+t(633)+t(1068)+"ting ser"+t(994),eXppw:function(a,n){return a!==n},UNoLK:t(1038),GSJsh:t(402),hHCnX:function(a,n){return a(n)},uawbL:function(a,n){return a(n)},MqdAk:t(1299),spDKW:"TJOio",xDjjE:t(1074)+t(838)+"onnecting",qOPzH:function(a,n){return a(n)},RaFEb:t(1354),IVbGl:"4|0|2|3|1",HilTg:function(a,n){return a>=n},lYEHA:function(a,n){return a<n},iwrnN:function(a,n){return a&n},aLAVt:function(a,n){return a>=n},DjhWR:function(a,n){return a-n},REyVK:function(a,n){return a|n},PMKas:function(a,n){return a<<n},ZHFIJ:function(a,n){return a<<n},FsqSN:function(a,n){return a<<n},mGnxT:function(a,n){return a>>n},DQtPO:function(a,n){return a===n},FnroY:"EYfSl",tnQXe:t(656)+"0",Bmagx:function(a,n){return a(n)},GULoC:t(1688),NtzDb:t(651),jzWZZ:t(1257),IPEsQ:function(a,n){return a(n)},DUyRc:"FzSqe",reIXd:"ack",ugAlZ:function(a,n,s){return a(n,s)},cJtpV:function(a,n){return a===n},FeVbQ:t(1149),Rrctz:function(a,n){return a!==n},DEBXU:t(1773),vTYok:function(a,n){return a+n},aLATJ:t(811)+t(762)+t(779)+t(800)+"ed",bomjk:function(a,n){return a===n},LenfH:t(811)+t(634)+"y closed",KZwQq:function(a,n){return a==n},lHmpw:t(1291)+t(371)+t(1280)+t(1572)+t(1564)+t(1427)+"ng or an"+t(649)+"ffer",MbwUd:function(a,n){return a==n},qyCEp:t(1318),CBxMX:function(a,n){return a instanceof n},zBenD:function(a,n){return a instanceof n},FNZOg:t(1291)+t(371)+t(622)+t(737),ZsIUT:function(a,n){return a===n},cIgeA:t(1164),mpMub:t(1103),gAjOe:function(a,n){return a||n},UGnKs:function(a,n){return a!==n},NgqDr:t(835)+t(996)+t(1208),SVgBQ:function(a,n,s){return a(n,s)},pyamr:function(a,n,s){return a(n,s)},KGVnL:function(a,n){return a!==n},OQSze:t(1430),zOgFT:function(a,n){return a instanceof n},DnFMX:function(a,n,s,d){return a(n,s,d)},iRtAQ:t(514),xsccc:function(a,n){return a>>>n},lFUjc:t(982),yWAfK:function(a,n){return a(n)},nLytJ:t(1304)+"e_success",hxFZm:t(1648),dupvD:function(a,n){return a/n},pHPuR:function(a,n){return a!=n},zsDln:function(a,n){return a===n},nEbcI:t(1782),EPITm:t(1315),MabHS:function(a,n){return a===n},LIDOU:function(a,n){return a!=n},GErfu:function(a,n){return a!=n},bxxdy:function(a,n){return a===n},NHEmi:function(a,n){return a===n},eAwAj:"ServiceW"+t(876)+t(1205),THdia:function(a,n){return a===n},FDJAf:function(a,n){return a!=n},LIcJm:function(a,n,s){return a(n,s)}};Mt.r(Pe),Mt.d(Pe,{FWS:()=>Cg,CustomErrorEvent:()=>ad,createCloseEvent:()=>mt,ReconnectEvent:()=>od,createErrorEvent:()=>ct,decodedFrame:()=>tn,createOpenEvent:()=>hd,CustomCloseEvent:()=>cd,createReconnectEvent:()=>wa,FrontierMessageEvent:()=>dd,encodeFrame:()=>Ft,createMessageEvent:()=>fd,OpenEvent:()=>ud,ErrorCode:()=>rn,Event:()=>tr,MessageEvent:()=>ld});let r="";function i(a=""){let n=t,s="02",d=""+Date[n(1505)](),h=r||(r=f(a)),w=Math[n(351)]()[n(1328)](16)[n(1056)](-6);return e.tellO(e.tellO(s,d)+h,w)}function o(){let a=t;return e.tellO(e[a(1532)](1e4,Date[a(1505)]()),Math[a(1448)](e[a(1532)](1e4,Math[a(351)]())))}function c(a){let n=t,s={XTUGG:function(d,h,w){return e[j(1622)](d,h,w)}};return n(738)!==e.PDuaq?new _0x5e13bc(d=>{let h=n;s[h(1047)](_0x18daf2,d,this[h(519)+h(1410)+"e"](_0x4d3b77))}):(Array(8)[n(863)]("0")+e[n(1384)](parseInt,a,10).toString(2))[n(1056)](-8)}function l(a){let n=t;return(e[n(1583)](Array,4)[n(863)]("0")+e.YVafA(parseInt,a,2)[n(1328)](16))[n(1056)](-4)}function u(a){let n=t,s=a[n(1721)](/\./).map(w=>c(w)),d=[];return d[0]=e[n(1382)](l,e[n(989)](s[0],s[1])),d[1]=e[n(1756)](l,e[n(989)](s[2],s[3])),[e[n(1188)],n(682),e[n(1188)],n(682),e[n(1188)],e[n(1584)],d[0],d[1]][n(863)]("")}function f(a){let n=t;if(e[n(1111)](e[n(945)],n(1780))){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(1730)](a),d=/(([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(1730)](a);return s?e[n(1331)](u,a):d?x(a):e[n(998)]}else{let s=this._endpointManager?.[n(596)+"ntEndpoint"]();this[n(437)](n(1120)+s),_0x10e390()}}function x(a){let n=t;if(e[n(1198)](e[n(588)],e.QlzqR)){let s="",d=[],h=0,w=0,S=!0,E=e[n(1188)];if(a.indexOf("::")>-1){let g=a[n(1721)]("::");for(let L=0;e[n(931)](L,g[n(1592)]);L++){let B=g[L];if(B.indexOf(":")>0){let W=B[n(1721)](":");S&&(h=W[n(1592)]),w+=W.length;for(let X=0;X<W.length;X++)if(e[n(1630)](4,W[X][n(1592)])){let re=E[n(1436)+"g"](0,e[n(1600)](4,W[X][n(1592)])),Te=re[n(1275)](W[X]);d[n(1140)](Te)}else d[n(1140)](W[X]);S=!1}else{if(e[n(846)](4,B[n(1592)])){let W=E[n(1436)+"g"](0,4-B[n(1592)]),X=W[n(1275)](B);d[n(1140)](X)}else d[n(1140)](B);S&&(h+=1),w+=1,S=!1}}let D="";for(let L=0;e.qCALE(L,8-w);L++)D=D[n(1275)](E);for(let L=0;L<d[n(1592)];L++)e[n(1271)](L,h)&&(s=s[n(1275)](D)),s=s[n(1275)](d[L]);return s}{let g=a.split(":");for(let D=0;e[n(768)](D,g.length);D++){let L=g[D];if(e[n(1659)](4,g[D][n(1592)])){let B=E.substring(0,4-g[D][n(1592)]),W=B[n(1275)](L);s=s[n(1275)](W)}else s=s[n(1275)](L)}return s}}else{let s=_0x20f1e2[n(1436)+"g"](0,4-_0xe1234[_0x21a5b9].length),d=s[n(1275)](_0x2f9aff[_0x5d2110]);_0x4eea72[n(1140)](d)}}function p(a,n){let s=t,d=a[s(1214)];e[s(846)](void 0,d)&&(pe(n,10),e[s(1615)](U,n,d));let h=a[s(747)];e[s(1630)](void 0,h)&&(e[s(1311)](pe,n,18),e[s(1311)](U,n,h))}function m(a){let n=t,s={};e:for(;!e[n(897)]($,a);){let d=e[n(1331)](xe,a);switch(e[n(728)](d,3)){case 0:break e;case 1:s[n(1214)]=e.QJyRA(C,a,xe(a));break;case 2:s[n(747)]=e.rNpFw(C,a,e[n(1756)](xe,a));break;default:e[n(463)](k,a,e[n(1437)](7,d))}}if(e.VFWIN(void 0,s[n(1214)]))throw new Error(e[n(807)]);if(e[n(1271)](void 0,s[n(747)]))throw new Error(n(444)+n(1695)+n(1561)+n(747));return s}function v(a){let n=t,s=e[n(727)](R);return _(a,s),e[n(1331)](M,s)}function _(a,n){let s=t;if(e.erODb(e[s(933)],e[s(624)])){let d=a[s(1820)];e[s(846)](void 0,d)&&(e[s(1426)](pe,n,8),gt(n,d));let h=a[s(1087)];e.JynbR(void 0,h)&&(pe(n,16),e[s(756)](gt,n,h));let w=a[s(1274)];w!==void 0&&(pe(n,24),e[s(1384)](gt,n,e[s(1756)](P,w)));let S=a.method;S!==void 0&&(e.sozit(pe,n,32),e[s(1311)](gt,n,e[s(584)](P,S)));let E=a[s(1433)];if(e[s(1819)](void 0,E))for(let Te of E)if(e[s(846)](e[s(1189)],s(361)))this._isMiniTT||this[s(870)+"X"]?this[s(1191)+s(1352)+s(923)]():this[s(1031)+"er"]&&this["_initGlo"+s(1807)+"Listener"]();else{e[s(1760)](pe,n,42);let on=e[s(727)](R);e[s(730)](p,Te,on),pe(n,on[s(498)]),e.MtWNZ(G,n,on),e[s(380)](O,on)}let g=a[s(819)+s(1621)];if(e[s(1059)](void 0,g))if(e.nFsvH(e[s(482)],e[s(482)])){let Te=e[s(1244)](e[s(1080)](e.Wurkp(e[s(1016)](e[s(553)](7,_0x25ab9c),18),e[s(1437)](63,_0x87446[_0x21ed3a++])<<12),e[s(843)](e[s(1363)](63,_0x5a92da[_0x68c30f++]),6)),e[s(370)](63,_0x49070f[_0xf44053++]))-65536;_0x5522c9+=_0x53617a[s(714)+"Code"](e[s(989)](55296,e.zdydU(Te,10))),_0x56bc50+=_0x240fd1[s(714)+s(859)](e[s(1179)](56320,e[s(443)](1023,Te)))}else e[s(1622)](pe,n,50),U(n,g);let D=a[s(518)+"ype"];e[s(1659)](void 0,D)&&(pe(n,58),e[s(804)](U,n,D));let L=a[s(888)];e[s(680)](void 0,L)&&(pe(n,66),e[s(1662)](pe,n,L[s(1592)]),e[s(1562)](oe,n,L));let B=a[s(810)];e[s(1630)](void 0,B)&&(pe(n,74),U(n,B));let W=a[s(602)+s(1182)];W!==void 0&&(e.BlSqA(pe,n,82),e[s(1479)](U,n,W));let X=a[s(1568)];X!==void 0&&(e[s(1590)](pe,n,90),e[s(629)](U,n,X));let re=a[s(374)+"e"];e[s(1059)](void 0,re)&&(e[s(756)](pe,n,96),e[s(629)](gt,n,e.fHvDW(P,re)))}else return new _0x2354af(_0x5ed2c5,{data:_0x4ffee1})}function b(a){let n=t;return e[n(897)](I,e[n(1382)](F,a))}function I(a){let n=t;if(e[n(1198)](e[n(1546)],e[n(1546)])){let s={};e:for(;!e[n(1092)]($,a);){let d=e[n(847)](xe,a);switch(d>>>3){case 0:break e;case 1:s[n(1820)]=e[n(1320)](It,a,!0);break;case 2:s[n(1087)]=e[n(1170)](It,a,!0);break;case 3:s[n(1274)]=e.fzylE(xe,a);break;case 4:s[n(1128)]=e.QBjhf(xe,a);break;case 5:{let h=e[n(688)](A,a);(s[n(1433)]||(s[n(1433)]=[])).push(e[n(584)](m,a)),a.limit=h;break}case 6:s[n(819)+n(1621)]=e[n(1320)](C,a,e[n(1566)](xe,a));break;case 7:s[n(518)+"ype"]=C(a,e.Hmaoj(xe,a));break;case 8:s[n(888)]=se(a,e[n(1331)](xe,a));break;case 9:s[n(810)]=e[n(629)](C,a,e[n(897)](xe,a));break;case 10:s[n(602)+n(1182)]=e[n(1184)](C,a,xe(a));break;case 11:s[n(1568)]=e.vyxVA(C,a,e.kXXIP(xe,a));break;case 12:s[n(374)+"e"]=xe(a);break;default:k(a,e[n(370)](7,d))}}if(e.cpiab(void 0,s[n(1820)]))throw new Error(e[n(1629)]);if(e.XAnVK(void 0,s.LogID))throw new Error(e[n(809)]);if(e.ZtlwE(void 0,s[n(1274)]))throw new Error(e.kVKcW);if(e.QlBgi(void 0,s[n(1128)]))throw new Error("Missing "+n(1695)+n(1561)+n(1128));return s}else _0x3efe72=_0x3049e2.charCodeAt(_0x34465c),_0x5a4be5<128?_0x2c3cb7+=1:e[n(768)](_0x175701,2048)?_0x1b11f4+=2:e[n(1198)](e[n(1363)](64512,_0x735cc2),55296)&&e[n(443)](64512,_0x486be4[n(895)+"At"](e[n(865)](_0x7242c,1)))===56320?(++_0x3881e2,_0x4bbb41+=4):_0x4b0af1+=3}function A(a){let n=t,s=e[n(1323)](xe,a),d=a[n(498)];return a.limit=e[n(1387)](a.offset,s),d}function k(a,n){let s=t;switch(n){case 0:for(;e.TpzlV(128,ee(a)););break;case 2:e[s(1562)](V,a,xe(a));break;case 5:e[s(1320)](V,a,4);break;case 1:e[s(1184)](V,a,8);break;default:throw new Error(e[s(1272)](e[s(999)],n))}}function P(a){let n=t;return e[n(636)]!==e[n(739)]?(a|=0,{low:a,high:e.XAkTP(a,31),unsigned:e.qPnZL(a,0)}):this[n(357)+n(720)]?.[n(596)+"ntEndpoi"+n(1073)+n(1004)]()||0}let y=[];function R(){let a=t,n=y[a(1398)]();return n?(n[a(1373)]=n[a(498)]=0,n):{bytes:new Uint8Array(64),offset:0,limit:0}}function O(a){y.push(a)}function F(a){let n=t;if(e[n(1774)](e.wtDeu,e[n(1020)]))return{bytes:a,offset:0,limit:a[n(1592)]};{_0x170e6e[n(826)](_0x1e145f)||(_0x9f175b=_0x20a618[n(1553)+"er"](_0x5f429f));let s=this.high>>>16,d=e.yJuap(65535,this[n(1411)]),h=e.cFYXJ(this[n(421)],16),w=e[n(553)](65535,this.low),S=e[n(728)](_0x138505[n(1411)],16),E=e[n(443)](65535,_0x76dd81[n(1411)]),g=_0x577255.low>>>16,D=e[n(1363)](65535,_0x10fdf7[n(421)]),L=0,B=0,W=0,X=0;return X+=e[n(1272)](w,D),W+=e[n(728)](X,16),X&=65535,W+=h+g,B+=e[n(706)](W,16),W&=65535,B+=d+E,L+=B>>>16,B&=65535,L+=s+S,L&=65535,_0x219767.fromBits(e[n(1266)](e.UYPmh(W,16),X),e.bJxFv(L,16)|B,this.unsigned)}}function M(a){let n=t,s=a[n(981)],d=a.limit;return e.idkVN(s[n(1592)],d)?s:s[n(1014)](0,d)}function V(a,n){let s=t;if(e[s(913)](e[s(660)],e[s(660)])){if(e[s(1032)](a[s(1373)]+n,a[s(498)]))throw new Error(e.ARBlZ);a[s(1373)]+=n}else{let d=_0x582a9a(e[s(1018)],{message:this[s(1761)+s(1421)+s(1129)](_0x53f764)});this[s(1517)]("error",d);let h=e.Wpjdv(_0xd56cbc,"close",{reason:this[s(1761)+s(1421)+s(1129)](_0xc79e3f)});this.emit(e[s(1514)],h)}}function $(a){let n=t;return e[n(1115)](a[n(1373)],a[n(498)])}function ne(a,n){let s=t,d=a[s(981)],h=a[s(1373)],w=a.limit,S=h+n;if(e[s(1032)](S,d[s(1592)])){let E=new Uint8Array(e[s(1708)](2,S));E.set(d),a[s(981)]=E}return a.offset=S,e[s(841)](S,w)&&(a[s(498)]=S),h}function Y(a,n){let s=t,d=a[s(1373)];if(e[s(841)](e[s(989)](d,n),a[s(498)]))throw new Error(e[s(571)]);return a.offset+=n,d}function se(a,n){let s=t,d=e.vyxVA(Y,a,n);return a[s(981)][s(1014)](d,e.MRMiz(d,n))}function oe(a,n){let s=t,d=e[s(1053)](ne,a,n[s(1592)]);a.bytes[s(1796)](n,d)}function C(a,n){let s=t,d={vZXyV:function(D,L){return e[j(1444)](D,L)},OgYFX:function(D,L){return e[j(753)](D,L)},wHVNq:function(D,L){return e[j(487)](D,L)},szatB:function(D,L){return e[j(492)](D,L)},kFVuw:function(D,L){return e[j(1437)](D,L)},KeQFa:function(D,L){return e[j(728)](D,L)},GHset:function(D,L,B){return e[j(541)](D,L,B)}},h=e[s(1311)](Y,a,n),w=String[s(714)+s(859)],S=a[s(981)],E="\uFFFD",g="";for(let D=0;e.ndPhx(D,n);D++)if(e[s(1774)](e[s(579)],e[s(579)])){let L=this[s(1411)],B=this.low;return[255&B,d[s(1313)](d[s(601)](B,8),255),d[s(570)](B>>>16,255),d[s(1682)](B,24),d[s(1313)](255,L),d[s(1228)](d[s(601)](L,8),255),d.wHVNq(d[s(601)](L,16),255),d[s(1742)](L,24)]}else{let L=S[e[s(587)](D,h)],B,W,X,re;if(e[s(1065)](e.JoeLg(128,L),0))g+=e[s(1715)](w,L);else if(e[s(431)](e.kOILv(224,L),192))e[s(1670)](D+1,n)?g+=E:(B=S[e[s(665)](e.iRUIP(D,h),1)],e[s(1619)](192,B)!==128?g+=E:(re=e.DymLD(e[s(1135)](31&L,6),e[s(1437)](63,B)),e[s(383)](re,128)?g+=E:(g+=e[s(1801)](w,re),D++)));else if(e.KgzDV(e[s(1437)](240,L),224))e.CecHu(e[s(665)](D,2),n)?g+=E:(B=S[e[s(1716)](e[s(867)](D,h),1)],W=S[e.yLiBN(e[s(1778)](D,h),2)],e[s(850)](e[s(566)](e[s(1244)](B,e[s(615)](W,8)),49344),32896)?g+=E:(re=e[s(684)](e[s(1266)](e.AXIAy(e[s(1358)](15,L),12),e[s(615)](63&B,6)),e[s(1781)](63,W)),e.WZShw(re,2048)||re>=55296&&e.vibvS(re,57343)?g+=E:(g+=e[s(1756)](w,re),D+=2)));else if(e[s(1329)](e[s(1444)](248,L),240))if(e.Ubmqy(e.smrHn(D,3),n))g+=E;else if(e[s(1151)](s(567),s(567))){let Te=d.GHset(_0x24beb5,s(435),{message:_0x33e1ed[s(1193)],code:_0x42ad24.OPEN_ERROR,error:_0x4e0132});this[s(755)+s(733)+s(1071)](Te)}else B=S[e[s(879)](e[s(372)](D,h),1)],W=S[e[s(890)](e[s(989)](D,h),2)],X=S[e[s(1551)](D,h)+3],e[s(1151)](e[s(1437)](e[s(1655)](B|W<<8,e[s(521)](X,16)),12632256),8421504)?g+=E:(re=e[s(1604)](e.MGtgp(e[s(684)](e[s(1135)](e.eePuJ(7,L),18),e[s(1178)](e.SxMkd(63,B),12)),e.Gxiof(e.kOILv(63,W),6)),e[s(1444)](63,X)),re<65536||e[s(889)](re,1114111)?g+=E:(re-=65536,g+=e[s(1322)](w,e[s(587)](e[s(1370)](re,10),55296),e[s(867)](1023&re,56320)),D+=3));else g+=E}return g}function U(a,n){let s=t,d={PHWrq:function(g,D,L,B){return g(D,L,B)}},h=n.length,w=0;for(let g=0;e.RMWxp(g,h);g++){let D=n[s(895)+"At"](g);e.EmmsR(D,55296)&&e[s(1710)](D,56319)&&e[s(1412)](e.jQBNg(g,1),h)&&(D=e[s(1600)](e[s(722)](D,10)+n[s(895)+"At"](++g),56613888)),w+=e[s(719)](D,128)?1:D<2048?2:D<65536?3:4}e.BrLRj(pe,a,w);let S=e.pnzAT(ne,a,w),E=a[s(981)];for(let g=0;g<h;g++){let D=n.charCodeAt(g);if(e[s(352)](D,55296)&&e[s(1710)](D,56319)&&e.exmAb(g,1)<h&&(D=e[s(1287)](e[s(1468)](D<<10,n.charCodeAt(++g)),56613888)),e[s(1452)](D,128))E[S++]=D;else{if(e[s(1295)](D,2048))E[S++]=e[s(412)](D>>6,31)|192;else if(e[s(1524)]!==e[s(1524)]){let L=255&_0x62bcf6;d[s(620)](_0x3f6b51,L,_0x4c9e60,_0x443981+_0x335ff2),_0x370bd5>>>=8,_0x5ed7d1--}else e.WZShw(D,65536)?E[S++]=e[s(1680)](D,12)&15|224:(E[S++]=e[s(1647)](e.RiGfH(D>>18,7),240),E[S++]=e[s(1647)](D>>12&63,128)),E[S++]=e.Wurkp(e[s(1363)](e[s(1194)](D,6),63),128);E[S++]=e[s(1604)](e[s(566)](63,D),128)}}}function G(a,n){let s=t,d=e[s(715)](ne,a,n.limit),h=a[s(981)],w=n[s(981)];for(let S=0,E=n[s(498)];e[s(768)](S,E);S++)h[S+d]=w[S]}function ee(a){let n=t;return a.bytes[e[n(696)](Y,a,1)]}function Ve(a,n){let s=t,d=e[s(1426)](ne,a,1);a.bytes[d]=n}function xe(a){let n=t,s=0,d=0,h;do h=e.qtEqU(ee,a),e[n(931)](s,32)&&(d|=e[n(527)](127&h,s)),s+=7;while(e[n(1202)](128,h));return d}function pe(a,n){let s=t;for(n>>>=0;e.guVJC(n,128);)e[s(1591)](Ve,a,e[s(1582)](127&n,128)),n>>>=7;e.ayKNC(Ve,a,n)}function It(a,n){let s=t,d={voAyD:function(h,w,S){return e[j(765)](h,w,S)},XDUDE:function(h,w,S){return e[j(1614)](h,w,S)},XurcO:function(h,w){return e[j(1801)](h,w)}};if(e.wwAHC(e[s(694)],"mWnbo")){let h=0,w=0,S=0,E;if(E=e[s(1400)](ee,a),h=e[s(370)](127,E),128&E&&(E=ee(a),h|=e[s(1177)](127&E,7),e.rrBFL(128,E)&&(E=ee(a),h|=e[s(615)](127&E,14),e.BcfXd(128,E)))){if(e[s(1668)](e.edUXc,e.edUXc))return this[s(1808)+"ndpointTriesCount"]++,this[s(596)+s(990)+"nt"]();E=ee(a),h|=e[s(1177)](e[s(1418)](127,E),21),e[s(1576)](128,E)&&(E=e[s(845)](ee,a),w=e[s(1358)](127,E),e[s(1704)](128,E)&&(E=e[s(1238)](ee,a),w|=(127&E)<<7,128&E&&(E=e[s(1245)](ee,a),w|=e.rOakf(127&E,14),e[s(1704)](128,E)&&(E=e[s(1176)](ee,a),w|=e[s(459)](127,E)<<21,e[s(553)](128,E)&&(E=ee(a),S=127&E,128&E&&(E=e.EoBNl(ee,a),S|=e[s(542)](e[s(1641)](127,E),7)))))))}return{low:e.Wurkp(h,e[s(556)](w,28)),high:e[s(502)](w>>>4,S<<24),unsigned:n}}else xYqHER[s(761)](_0x44adfa,_0x139ac4,96),xYqHER[s(1289)](_0x499b53,_0x5ccc78,xYqHER[s(1192)](_0x5902e8,_0x3cb616))}function gt(a,n){let s=t,d=e[s(492)](n[s(421)],0),h=e[s(473)](e[s(1664)](e.ZAJji(n[s(421)],28),n[s(1411)]<<4),0),w=n[s(1411)]>>>24,S=e[s(1065)](0,w)?e[s(468)](0,h)?e[s(729)](d,16384)?d<128?1:2:e[s(1118)](d,2097152)?3:4:e.WZShw(h,16384)?e[s(773)](h,128)?5:6:e[s(1631)](h,2097152)?7:8:w<128?9:10,E=e[s(1364)](ne,a,S),g=a[s(981)];switch(S){case 10:g[e.ctRcM(E,9)]=e.lomVH(e[s(1298)](w,7),1);case 9:g[E+8]=e[s(1151)](9,S)?e[s(1243)](128,w):e[s(370)](127,w);case 8:g[e[s(1079)](E,7)]=e[s(793)](8,S)?e.lwdvU(e[s(492)](h,21),128):e[s(443)](e[s(1798)](h,21),127);case 7:g[e[s(1556)](E,6)]=e[s(1659)](7,S)?e[s(684)](e[s(1131)](h,14),128):e[s(825)](h,14)&127;case 6:g[e.gPNsj(E,5)]=e[s(1691)](6,S)?e[s(1534)](h>>>7,128):e[s(832)](e[s(1298)](h,7),127);case 5:g[E+4]=S!==5?e[s(1647)](128,h):e[s(1444)](127,h);case 4:g[E+3]=e[s(1819)](4,S)?e[s(1298)](d,21)|128:e[s(1576)](e[s(1114)](d,21),127);case 3:g[e.xTmxH(E,2)]=e[s(1817)](3,S)?e.CExps(e[s(728)](d,14),128):e[s(1523)](e[s(753)](d,14),127);case 2:g[e.tellO(E,1)]=e.syZwi(2,S)?e[s(1582)](d>>>7,128):e[s(574)](d,7)&127;case 1:g[E]=e.OApGu(1,S)?e[s(684)](128,d):e.GSfCz(127,d)}}function tn(a){let n=t;if(e.lgVPU!==e.nfObE)return e[n(1077)](b,a);this["_initPro"+n(1471)]=null}function Ft(a){let n=t;return e[n(1147)](e[n(713)],n(1145))?_0x46b90b.resolve():v(a)}let nn=65536,Yr=e[t(346)],we=nn*nn,Ae=we*we,er=e.dupvD(Ae,2),Oe=String[t(1766)+"e"][t(895)+"At"];class he{constructor(n,s,d){let h=t;this[h(826)]=!0,this[h(421)]=e[h(606)](0,n),this[h(1411)]=e[h(1664)](0,s),this[h(1345)]=!!d}static[t(826)](n){return n&&n.isLong===!0}static fromBits(n,s,d){return new he(n,s,d)}static[t(1751)+"s"](n,s,d){return d?he[t(1751)+"sLE"](n,s):he.fromBytesBE(n,s)}static[t(1751)+t(1711)](n,s){let d=t;return new he(e[d(1241)](n[0]|e.HBCWO(n[1],8)|n[2]<<16,e.vRyln(n[3],24)),e.ItOZY(n[4],n[5]<<8)|e.vidRT(n[6],16)|e[d(615)](n[7],24),s)}static["fromByte"+t(1635)](n,s){let d=t;return new he(e[d(1392)](e[d(606)](e[d(1392)](n[4]<<24,e.mTMUV(n[5],16)),e.noKjb(n[6],8)),n[7]),e.zAcWO(e.cvMgH(e[d(969)](n[0],24)|n[1]<<16,e.noKjb(n[2],8)),n[3]),s)}static[t(698)](n){let s=t;return e[s(549)](n,Yr)?sd:new he(e[s(606)](e[s(1655)](e.CwNwo(Oe[s(1502)](n,0),e[s(671)](Oe[s(1502)](n,1),8)),e[s(401)](Oe[s(1502)](n,2),16)),e[s(788)](Oe.call(n,3),24))>>>0,e[s(1143)](e.bYxFd(Oe[s(1502)](n,4)|Oe[s(1502)](n,5)<<8,e.XizBt(Oe[s(1502)](n,6),16))|e[s(843)](Oe[s(1502)](n,7),24),0),!0)}[t(1380)](){let n=t;return String[n(714)+n(859)](255&this[n(421)],e[n(817)](e[n(1060)](this[n(421)],8),255),e[n(1522)](e.LJCjq(this.low,16),255),e[n(574)](this.low,24),255&this[n(1411)],e[n(825)](this[n(1411)],8)&255,e[n(668)](e.HyZqb(this[n(1411)],16),255),e[n(706)](this[n(1411)],24))}static[t(1553)+"er"](n,s=!0){let d=t;if(e.bMXuA(isNaN,n))return s?Hp:sd;if(s){if(e.EmmsR(n,Ae))return qp}else{if(e[d(1283)](n,-er))return jp;if(e[d(503)](n,1)>=er)return Gp}return he[d(1371)](e.MGtgp(n%we,0),e[d(1368)](n/we,0),s)}[t(417)](){let n=t;return this[n(1345)]?e[n(833)](e[n(1482)](this[n(1411)],0)*we,e[n(1050)](this[n(421)],0)):e[n(503)](e.BvtsB(this.high,we),e[n(1573)](this[n(421)],0))}[t(1385)](){let n=t;if(e[n(1237)]("IbrqW",e.xapTC))this[n(578)+n(1185)](),this[n(1517)]("ping_onc"+n(924)+"s",e.eLSIV),this[n(1186)+n(1288)+"Id"]=e[n(463)](_0x1fd3c1,this._ping[n(1425)](this),_0xa7ce9);else return this[n(1411)]===0&&e[n(1458)](0,this[n(421)])}add(n){let s=t,d={kFmHM:function(h,w){return h>>>w},fNseY:function(h,w){return e.HaITn(h,w)},AxkVx:function(h,w){return e[j(1681)](h,w)},NDIoN:function(h,w){return e[j(1099)](h,w)},MPOCi:function(h,w){return e[j(728)](h,w)}};if(e[s(1059)](e.hEWNU,e.oRBZN)){he[s(826)](n)||(n=he[s(1553)+"er"](n));let h=e.NyYrt(this[s(1411)],16),w=65535&this[s(1411)],S=e[s(1482)](this[s(421)],16),E=e.hNRGN(65535,this[s(421)]),g=e[s(1143)](n[s(1411)],16),D=e[s(1528)](65535,n[s(1411)]),L=e[s(1078)](n[s(421)],16),B=e.vglom(65535,n[s(421)]),W=0,X=0,re=0,Te=0;return Te+=e[s(1718)](E,B),re+=Te>>>16,Te&=65535,re+=S+L,X+=e[s(1560)](re,16),re&=65535,X+=e[s(676)](w,D),W+=e[s(1143)](X,16),X&=65535,W+=e.KSWWI(h,g),W&=65535,he[s(1371)](e[s(1051)](e[s(1665)](re,16),Te),e[s(1789)](W,16)|X,this[s(1345)])}else{let h=this[s(1411)],w=this[s(421)];return[d[s(991)](h,24),d[s(1402)](d.kFmHM(h,16),255),d[s(1402)](d[s(991)](h,8),255),d.fNseY(255,h),d[s(1474)](w,24),d.NDIoN(d[s(563)](w,16),255),d[s(802)](d[s(1474)](w,8),255),d[s(802)](255,w)]}}[t(1446)](n){let s=t;return he[s(826)](n)||(n=he.fromNumber(n)),e[s(1263)](this[s(1345)],n[s(1345)])&&e.HWYqK(this[s(1411)],31)===1&&e.KDWEz(n[s(1411)],31)===1?!1:e[s(1089)](this.high,n[s(1411)])&&this.low===n[s(421)]}addOne(){let n=t;return e[n(1093)](-1,this[n(421)])&&e[n(1503)](-1,this[n(1411)])?he[n(1371)](0,0,this[n(1345)]):e[n(1271)](-1,this[n(421)])?he.fromBits(0,e[n(1778)](this[n(1411)],1),this[n(1345)]):he[n(1371)](e[n(1387)](this[n(421)],1),this[n(1411)],this[n(1345)])}[t(1542)](n){let s=t;if(e.wyrbf(e[s(1520)],e[s(1321)]))e[s(1653)](_0x11a7a5,_0x24d9d1,24),e[s(1116)](_0x9cd898,_0x22f0ad,e[s(380)](_0x3a65a5,_0xd8e093));else return n?this[s(1736)+"E"]():this[s(875)+"E"]()}[t(1736)+"E"](){let n=t,s=this[n(1411)],d=this[n(421)];return[e[n(1444)](255,d),e.kCtQH(d>>>8,255),e[n(668)](e.fOuhn(d,16),255),e[n(728)](d,24),e.jxZow(255,s),s>>>8&255,e[n(1201)](e[n(1570)](s,16),255),s>>>24]}toBytesBE(){let n=t,s=this.high,d=this[n(421)];return[e.xkVZs(s,24),e[n(449)](e[n(1681)](s,16),255),e[n(672)](s,8)&255,255&s,e[n(1482)](d,24),e.HyZqb(d,16)&255,e[n(459)](e[n(695)](d,8),255),e[n(789)](255,d)]}}let sd=new he(0,0,!1),Hp=new he(0,0,!0),Gp=he.fromBits(-1,2147483647,!1),qp=he[t(1371)](-1,-1,!0),jp=he.fromBits(0,-2147483648,!1);var rn=(function(a){let n=t;if(e[n(1611)]!==e[n(1525)]){let s=e[n(899)][n(1721)]("|"),d=0;for(;;){switch(s[d++]){case"0":a[a[e[n(1786)]]=5004]=n(904)+n(677);continue;case"1":a[a[e[n(801)]]=5003]=e[n(801)];continue;case"2":a[a[e.wMMPd]=5002]=n(1652)+n(792);continue;case"3":a[a[e[n(936)]]=5001]=e[n(936)];continue;case"4":a[a[e.VBWvv]=5005]=n(1580)+"OR";continue;case"5":return a}break}}else return this._qosDB[n(1346)]()})({});class tr{constructor(n){let s=t;this[s(457)]=n,this.target=null}}class od extends tr{constructor(n,s){let d=t;super(n),this[d(1193)]=s&&s[d(1193)]||null}}class ad extends tr{constructor(n,s){let d=t,h=(d(1234)+d(1669))[d(1721)]("|"),w=0;for(;;){switch(h[w++]){case"0":super(n);continue;case"1":this[d(1002)]=s&&s[d(1002)]||0;continue;case"2":this[d(435)]=s&&s[d(435)]||null;continue;case"3":this[d(1262)]=s&&s[d(1262)]||0;continue;case"4":this[d(1303)]=s&&s[d(1303)]||"";continue;case"5":this.message=s&&s[d(1193)]||"";continue;case"6":this[d(1273)]=s&&s[d(1273)]||5001;continue}break}}}class cd extends tr{constructor(n,s){let d=t,h=(d(1361)+"2")[d(1721)]("|"),w=0;for(;;){switch(h[w++]){case"0":super(n);continue;case"1":this[d(640)]=s&&s[d(640)]||"";continue;case"2":this["willReco"+d(813)]=s&&s[d(1117)+d(813)]||!1;continue;case"3":this[d(1793)]=s&&s.wasClean||!1;continue;case"4":this[d(1273)]=s&&s[d(1273)]||0;continue}break}}}class ld extends tr{constructor(n,s){let d=t;super(n),this[d(1013)]=s&&s[d(1013)]||null}}class dd extends ld{constructor(n,s){let d=t;super(n),this[d(1013)]=s&&s.data||null,this[d(1193)]=s&&s[d(1193)]||null}}class ud extends tr{constructor(n,s){let d=t;super(n),this[d(1013)]=s&&s[d(1013)]||null}}function ct(a,{message:n,code:s,error:d}){return new ad(a,{message:n,code:s,error:d})}function mt(a,{code:n,reason:s,wasClean:d,willReconnect:h}){return new cd(a,{code:n,reason:s,wasClean:d,willReconnect:h})}function fd(a,{data:n,message:s}){return new dd(a,{data:n,message:s})}function hd(a,{data:n}){return new ud(a,{data:n})}function wa(a,{message:n}){return new od(a,{message:n})}class xd{constructor(n,s){let d=t;this.endpoints=n,this[d(946)+"es"]=s,this[d(428)+d(1593)]=0,this[d(1808)+"ndpointT"+d(1466)+"t"]=0}[t(1167)+t(1814)+t(646)](){let n=t;if(e[n(1440)](e[n(1588)],e.gaufU))this["currentI"+n(1593)]=0,this[n(1808)+n(416)+n(1466)+"t"]=0;else return _0x10d216?_0x19fb57.fromBytesLE(_0x2f788e,_0x1dfc1e):_0x3c4821[n(1751)+n(1635)](_0x45bb3b,_0x31a70e)}[t(1199)+"es"](){let n=t;this[n(1808)+n(416)+n(1466)+"t"]=0}["getCurre"+t(990)+"nt"](){let n=t;return this.endpoints[this[n(428)+"ndex"]]}[t(596)+"ntEndpoi"+t(1073)+t(1004)](){let n=t;return this[n(1808)+n(416)+"riesCount"]}[t(1284)+t(1656)+"es"](){let n=t;return!!(this[n(428)+n(1593)]>=this.endpoints[n(1592)]||e[n(1381)](this["currentI"+n(1593)],this[n(1052)+"s"].length-1)&&e[n(1824)](this[n(1808)+"ndpointTriesCount"],this.maxRetries))}[t(799)+"rentEndp"+t(1251)+t(669)+"tries"](){let n=t;return e[n(1725)](this[n(428)+"ndex"],this[n(1052)+"s"][n(1592)])?!0:e[n(1339)](this["currentE"+n(416)+n(1466)+"t"],this[n(946)+"es"])}[t(732)+t(1469)+t(1334)+t(1589)+t(631)](){let n=t;if(e[n(1646)]!==e[n(1646)])this["_binaryT"+n(980)]=_0x19c413,this._ws&&(this[n(512)][n(1084)+"pe"]=_0x42eb1b);else return this[n(1808)+n(416)+"riesCount"]=1,this[n(428)+n(1593)]++,this[n(1052)+"s"][this[n(428)+"ndex"]]}[t(596)+"ntEndpointAndUpd"+t(1694)](){let n=t;return this["currentE"+n(416)+n(1466)+"t"]++,this.getCurrentEndpoint()}}let nr=(e[t(545)](t(1105)+"d",typeof globalThis)&&t(1782)===globalThis[t(1828)+"tor"].name||e.pHPuR(e[t(834)],typeof window)&&e[t(1729)](e[t(1499)],window["construc"+t(1231)][t(932)]))&&e[t(545)](e[t(834)],typeof document),Cn=e[t(912)](t(1105)+"d",typeof globalThis)&&(e[t(1374)]===globalThis["construc"+t(1231)][t(932)]||e.MabHS(t(1316)+t(1501)+t(947)+"pe",globalThis[t(1828)+t(1231)].name))&&e[t(543)](t(1105)+"d",typeof tt),Xr=(e[t(834)]!=typeof globalThis&&e[t(1211)](e[t(1374)],globalThis[t(1828)+"tor"][t(932)])||e[t(834)]==typeof globalThis||e[t(1006)](e[t(834)],typeof globalThis)&&!!globalThis["WeixinJS"+t(791)])&&e[t(1396)](e[t(834)],typeof wx),Qr=e[t(778)](e[t(834)],typeof globalThis)&&(e.bxxdy(t(1316)+"dWorkerG"+t(947)+"pe",globalThis[t(1828)+"tor"][t(932)])||t(878)+t(535)+t(1064)===globalThis[t(1828)+t(1231)][t(932)]||e[t(1475)](e[t(500)],globalThis[t(1828)+t(1231)].name))&&e[t(1006)](e[t(834)],typeof self),Wp=e[t(834)]!=typeof globalThis&&e[t(1110)](e.EPITm,globalThis["construc"+t(1231)].name)&&e.NuXnc(e[t(834)],typeof global)&&e[t(1374)]===global[t(1828)+t(1231)][t(932)]&&e[t(834)]!=typeof process&&!!process[t(1417)];class _a{constructor(){this._listeners={}}emit(n,...s){let d=t,h=this._listeners[n];if(h)h[d(1056)]().forEach(w=>w.fn[d(1738)](w[d(1627)],s));else if(e[d(1727)](e[d(1018)],n)&&!this[d(1461)]){let w=s.length&&s[0];if(w instanceof Error)throw w;let S=new Error(e[d(1209)](e[d(422)],w?e[d(1158)](e[d(440)](" (",w[d(1193)]),")"):""));throw S[d(745)]=w,w}return this}[t(349)](n,s){let d=t;if(e[d(1211)](void 0,n))this._listeners={};else if(s===void 0)this[d(1821)+"rs"][n]=null;else{let h=this._listeners[n];if(h)for(let w=0;e[d(1295)](w,h[d(1592)]);)e.KObYF(h[w].fn,s)?h[d(1030)](w,1):++w}return this}on(n,s,d){let h=t;return(this[h(1821)+"rs"][n]||(this[h(1821)+"rs"][n]=[])).push({fn:s,ctx:d||this}),this}}class Kp extends _a{[t(1761)+t(1421)+t(1129)](n){let s=t;return n.errMsg||n.errNo?(s(1617)+" "+(n[s(686)]||"")+" code: "+(n[s(1001)]||""))[s(1148)]():JSON.stringify(n)}constructor(n,s,d){let h=t;super(),this[h(911)]=null,Xr&&wx["connectS"+h(1818)]&&(this[h(911)]=wx[h(537)+"ocket"]({url:n,protocols:s,header:d,fail:this[h(920)+h(886)+h(1763)][h(1425)](this),success:this[h(920)+h(1042)+h(1293)+h(469)][h(1425)](this)})),Cn&&tt[h(537)+h(1818)]&&(this[h(911)]=tt["connectS"+h(1818)]({url:n,protocols:s,header:d,fail:this["_createS"+h(886)+h(1763)][h(1425)](this),success:this[h(920)+h(1042)+h(1293)+"ler"][h(1425)](this)}))}[t(920)+t(1042)+t(1293)+t(469)](){let n=t,s={ikWPV:function(d,h,w){return e[j(821)](d,h,w)},gkLLZ:function(d,h){return d!==h},UImdp:e.pIbKo};e.VFWIN(n(407),e[n(583)])?this["flushExp"+n(1314)]():Promise[n(1549)]()[n(1003)](()=>{let d=n;s[d(959)]("UhQaV",s[d(759)])?this[d(499)+d(1827)]():this[d(1517)](d(1429),s[d(725)](_0x14faa9,"open",{..._0x513182,data:_0x524ebb[d(686)]||""}))})}[t(920)+t(886)+t(1763)](n){let s=t,d={KjGBW:function(h,w,S){return e[j(1336)](h,w,S)},IzGUu:e[s(1018)],HWxMc:e[s(1514)]};Promise[s(1549)]()[s(1003)](()=>{let h=s,w=d[h(963)](ct,h(435),{message:this[h(1761)+"rrorMess"+h(1129)](n)});this[h(1517)](d[h(1609)],w);let S=mt(d[h(472)],{reason:this[h(1761)+"rrorMess"+h(1129)](n)});this[h(1517)](h(532),S)})}[t(499)+"steners"](){let n=t,s={eEMTB:e[n(650)],fVaGc:function(d,h){return e[n(639)](d,h)},MvXaQ:e[n(903)],iGwAX:n(1193),lmcKA:function(d,h,w){return e[n(1661)](d,h,w)}};this[n(911)][n(1100)](d=>{let h=n;this.emit(s.eEMTB,hd(s[h(658)],{...d,data:d[h(686)]||""}))}),this[n(911)][n(1777)](d=>{let h=n;this.emit(e[h(1514)],e.ECdeP(mt,h(532),{...d}))}),this._socket[n(369)+"e"](d=>{let h=n;if(s[h(977)](s.MvXaQ,s.MvXaQ))this[h(1517)](s.iGwAX,s[h(1342)](fd,h(1193),{...d}));else return this[h(1355)]?.get(_0x209f59)}),this._socket.onError(d=>{let h=n;this.emit(e[h(1018)],ct(e[h(1018)],{...d,message:d[h(686)]||""}))})}[t(1223)](n){let s=t,d={MoHnD:e.wMzTx,BErNz:function(h,w,S){return e[j(1322)](h,w,S)}};if(e.cDDwv(n,Uint8Array)){let h=n.buffer[s(1056)](n.byteOffset,e[s(1551)](n[s(1578)+"th"],n.byteOffset));this[s(911)]&&this[s(911)][s(1223)]({data:h,fail:w=>{let S=s;this[S(1517)](e[S(1018)],e[S(1639)](ct,e[S(1018)],{message:this["_formatErrorMess"+S(1129)](w)}))}})}else this[s(911)]&&this[s(911)][s(1223)]({data:n,fail:h=>{let w=s;this[w(1517)](d[w(1687)],d[w(910)](ct,d[w(1687)],{message:this[w(1761)+w(1421)+w(1129)](h)}))}})}[t(532)](n,s){let d=t,h={crYHZ:function(w,S){return e[j(1704)](w,S)}};e[d(1181)](e[d(384)],e[d(384)])?this[d(911)]&&this[d(911)][d(532)]({code:n,reason:s}):(_0x47e70e(_0x18f79f,zfUOBP[d(367)](127,_0x456c3c)|128),_0x2b68e8>>>=7)}[t(1227)+t(1811)](n,s){this.on(n,s)}[t(1435)+t(776)+"ner"](n,s){this[t(349)](n,s)}get[t(958)+"te"](){let n=t;return this[n(911)][n(958)+"te"]}get[t(1084)+"pe"](){let n=t;return this[n(911)][n(1084)+"pe"]}set[t(1084)+"pe"](n){}get url(){let n=t;return this[n(911)][n(1347)]}get protocol(){let n=t;if(e.oEoFh(e[n(1697)],e[n(1697)]))return this[n(911)][n(1317)];_0xabcdaf[n(1549)]().then(()=>{this["_addWsLi"+n(1827)]()})}get[t(1282)+"ns"](){let n=t;return this[n(911)][n(1282)+"ns"]}get[t(954)+t(1367)](){return 0}}function $p(a,n){let s=t;if(n)return new n(a[s(1347)],a[s(1317)]);if(e[s(1785)](Xr,Cn))return new Kp(a[s(1347)],a.protocol,a[s(1433)]);if(e[s(1785)](nr,Qr)&&e[s(834)]!=typeof WebSocket&&WebSocket)return new WebSocket(a[s(1347)],a[s(1317)+"s"])}function Vp(a){let n=t,s={retJC:function(d,h){return e[j(768)](d,h)},jzvtf:function(d,h){return e[j(1060)](d,h)},ClmXz:function(d,h){return e[j(609)](d,h)}};if(e[n(1630)](n(1175),n(1175))){let d=0,h=_0x240642,w=_0x19abab+4;for(;s.retJC(h,w);){let{value:S,offset:E}=_0x33c8c7(_0x39284a,h);h=E,d=s[n(883)](s[n(1069)](d,8),0),d+=S}return{value:d,offset:w}}else return!!(a||Xr&&wx[n(537)+n(1818)]||Cn&&tt["connectS"+n(1818)]||e[n(1785)](nr,Qr)&&e[n(912)](e.yReJw,typeof WebSocket)&&WebSocket)}function pd(a,n,s){let d=t,h={sllzL:function(E,g){return e[j(1419)](E,g)},jdezT:e[d(901)],UNTMI:function(E,g){return E===g},tuRAY:function(E,g){return e.LhXHW(E,g)}},w=-1;async function S(E){let g=d;return h[g(1281)](E,w)?Promise[g(798)](new Error(h[g(462)])):(w=E,h.UNTMI(E,s[g(1592)])?Promise[g(1549)]():s[E][g(1425)](a)(n,S.bind(null,h[g(644)](E,1))))}e[d(1400)](S,0)}function gd(a){let n=t;if(e[n(1691)](n(1341),e[n(740)])){let s=0,d=0;for(let h=0;h<a[n(1592)];++h)d=a.charCodeAt(h),e[n(729)](d,128)?s+=1:e[n(1452)](d,2048)?s+=2:e[n(1397)](e.rrBFL(64512,d),55296)&&e[n(1548)](64512&a.charCodeAt(e[n(1112)](h,1)),56320)?(++h,s+=4):s+=3;return s}else _0x4ebf27.o=(s,d)=>_0x3fce0f[n(1766)+"e"][n(593)+n(1649)][n(1502)](s,d)}function md(a,n,s){let d=t;if(e[d(1526)](s-n,1))return"";let h="";for(let w=n;e[d(931)](w,s);){let S=a[w++];if(e[d(1710)](S,127))h+=String["fromChar"+d(859)](S);else if(e[d(496)](S,192)&&e.Twbvk(S,224))h+=String[d(714)+d(859)](e[d(657)](e[d(1768)](e[d(1498)](31,S),6),e[d(443)](63,a[w++])));else if(S>=224&&e.HreFb(S,240))h+=String[d(714)+"Code"](e.eiUhG(e.ftKDR(15,S),12)|(63&a[w++])<<6|e[d(817)](63,a[w++]));else if(S>=240){let E=e[d(1109)](e[d(820)](e[d(922)](e[d(952)](7,S),18)|e[d(671)](e.edGuz(63,a[w++]),12),e[d(1177)](63&a[w++],6))|e[d(789)](63,a[w++]),65536);h+=String[d(714)+d(859)](e[d(440)](55296,e[d(1455)](E,10))),h+=String[d(714)+d(859)](e[d(665)](56320,e[d(626)](1023,E)))}}return h}function ya(a,n,s){let d=t,h=s,w,S;for(let E=0;e[d(1452)](E,a[d(1592)]);++E)if(e[d(1247)]!==e.WnFdC)if(w=a[d(895)+"At"](E),e[d(931)](w,128))n[s++]=w;else if(w<2048)n[s++]=e[d(1628)](w,6)|192,n[s++]=e[d(689)](e.ylaSN(63,w),128);else if(e[d(1146)](e.ytYTd(64512,w),55296)&&e.AtFVf(64512&(S=a[d(895)+"At"](E+1)),56320)){let g=e.vDIuB[d(1721)]("|"),D=0;for(;;){switch(g[D++]){case"0":n[s++]=e[d(1266)](e[d(1781)](w>>6,63),128);continue;case"1":n[s++]=e[d(1664)](e.zdydU(w,18),240);continue;case"2":++E;continue;case"3":n[s++]=e[d(1485)](e.edGuz(e[d(1455)](w,12),63),128);continue;case"4":w=e.YJrBF(65536,e[d(1177)](1023&w,10))+e[d(736)](1023,S);continue;case"5":n[s++]=63&w|128;continue}break}}else n[s++]=e[d(1392)](e[d(582)](w,12),224),n[s++]=e[d(1243)](e.fMcnf(e.cRMAu(w,6),63),128),n[s++]=e[d(955)](e.HZCrT(63,w),128);else return;return e[d(530)](s,h)}async function wd(a){let n=t;if(e.KgzDV(e[n(1297)],typeof a)){let s=new Uint8Array(gd(a));return ya(a,s,0),s}return e[n(1236)](a,ArrayBuffer)?new Uint8Array(a):new Uint8Array(a[n(858)],a.byteOffset,a[n(1578)+"th"])}function Jp(a){let n=t;try{if(e.vCQAw(e[n(785)],e[n(610)]))this[n(1307)]=_0x2bf05c,this[n(908)]=_0xccba6f,this[n(1355)]=_0x5f2fd9;else return e.xovxq(e[n(1297)],typeof a)&&(a instanceof ArrayBuffer||a.buffer&&e[n(1383)](a[n(858)],ArrayBuffer))||e[n(1396)](e.rJySz,typeof a)?"":(JSON[n(1462)](a),e[n(1399)])}catch{return e[n(1329)]("string",typeof a)?e[n(851)]:""}}let Zp=(a,n)=>{let s=t;switch(a){case s(1531):case e[s(536)]:return{[s(944)+a]:1,"x-tt-env":n};default:return{}}};class Yp{constructor(n){let s=t;this[s(475)+s(1004)]=n,this[s(655)]=0}[t(425)](){this.count++}[t(1284)+"chMaxCount"](){let n=t;return e[n(1115)](this[n(655)],this[n(475)+n(1004)])}[t(647)+"nter"](n=0){let s=t,d={Xvzhe:e[s(984)]};if(e.piADj(e[s(454)],e[s(454)]))this[s(475)+"ount"]=n,this[s(655)]=0;else return _0x3a4e21||(_0x233d8f=_0x617ff6[s(1549)]().then(_0x41d471[s(1425)](_0x367806,d.Xvzhe))),_0x2b348b}}async function Xp(a){let n=t,s={BsDwa:function(d,h){return e[j(1082)](d,h)},rpxZT:e[n(673)],WNOcV:e.PlmCT,zvHfp:n(533)};return new Promise(d=>{let h=n;if(!nr)return d(s[h(621)]);try{let w=document[h(1229)+h(392)](h(1640));window["frontier"+h(438)]=S=>{let E=h;document[E(551)].removeChild(w),window[E(1608)+E(438)]=void 0,s[E(1555)](d,S&&S[E(983)]||s.rpxZT)},w[h(457)]=s.WNOcV,w[h(978)]=a[h(484)](/^ws/,s.zvHfp)+(h(1457)+h(1472)+h(424)+"P");try{document[h(551)]["appendCh"+h(366)](w)}catch{document[h(551)][h(513)+h(366)](w)}}catch{window[h(1608)+h(438)]=void 0,d(s.rpxZT)}})}function sn(a,n,s){let d=t;if(d(388)===d(388))return!!a?.find(h=>h[d(1214)]===n&&h[d(747)]===s);{let h=_0x2846ab(d(1068)+"t",{message:e[d(1473)]});this[d(1481)+d(996)]&&this["onStartR"+d(996)](h)}}function rr(a,n){let s=t;return a?.[s(575)](d=>d[s(1214)]===n)?.[s(747)]}let ba=null;async function Qp(){let a=t;return ba||(ba=Promise[a(1549)]()[a(1003)](Mt[a(1425)](Mt,e[a(984)]))),ba}class eg extends _a{constructor(n,s){let d=t;super(),this._dbName=n,this._keyPath=s,this._qosDB=void 0,this[d(942)+"mise"]=null}async[t(941)](){await this[t(935)]()}async[t(935)](){let n=t,s={Qzinw:function(d){return d()}};if(!this._qosDB){if(this["_initPro"+n(1471)])return this[n(942)+n(1471)];try{let d=this[n(495)],h=this[n(1701)];this["_initPro"+n(1471)]=(async()=>{let w=n,{openDB:S}=await s[w(1726)](Qp);this[w(1355)]=await S(w(1608)+"_"+d,1,{upgrade(E){let g=w;E[g(972)+g(510)+"e"](d,{keyPath:h})}})})(),await this._initPromise}catch(d){console[n(1724)](d)}finally{this[n(942)+n(1471)]=null}}}async[t(652)](n){let s=t;try{return await this._init(),this[s(1355)]?.[s(652)](this[s(495)],n)}catch(d){console[s(1724)](d)}}async[t(1796)](n,s){let d=t;if(e[d(1527)]("YNWKt",e[d(378)])){let h=new _0x3b9b1c(e[d(373)](e[d(1172)](e[d(689)](e[d(1665)](_0x1bf3fe[e[d(1379)](_0x3eea11,4)],24),e[d(1177)](_0x181cef[_0x10e86d+5],16)),_0x29a004[e[d(1556)](_0x5b2834,6)]<<8),_0x2497c6[e[d(867)](_0x57d229,7)]),e[d(373)](e.rbIgC(e.abshl(_0x353b8d[e.olxrz(_0x3a1393,0)],24),e[d(927)](_0x391423[e.vewIy(_0x1baf50,1)],16)),e.gLKQe(_0x2e70f7[e[d(867)](_0x34edb2,2)],8))|_0x4c5c01[e[d(1468)](_0x30be80,3)],!0);return _0x5a6976+=8,{value:h,offset:e.yLiBN(_0x1503c2,8)}}else return await this[d(935)](),this._qosDB?.[d(1441)](this[d(495)],n)}async[t(1200)](n){let s=t;try{return await this[s(935)](),this._qosDB?.[s(381)](this[s(495)],n)}catch(d){console[s(1724)](d)}}async[t(1346)](){let n=t;try{return await this[n(935)](),this[n(1355)]?.[n(1346)](this._dbName)}catch(s){e.Kpvzw!==e.ymcDp?console[n(1724)](s):(this[n(1517)]("message",_0x3c9626),this.onmessage&&this[n(862)+"e"](_0x7986ee))}}async[t(1533)](){let n=t;return await this[n(935)](),this[n(1355)]?.[n(1613)+"ys"](this[n(495)])}async getAll(){let n=t;if(e[n(913)](e[n(1349)],e[n(1349)]))return await this[n(935)](),this[n(1355)]?.[n(1575)](this[n(495)]);try{this._ws&&this[n(512)].close(_0x4f047d,_0x1abb49)}catch{}}async[t(1121)](){let n=t;try{this[n(1355)]?.close(),this[n(1355)]=void 0}catch(s){console[n(1724)](s)}}get[t(1794)](){let n=t;try{return!!this[n(1355)]}catch(s){return console[n(1724)](s),!1}}}class tg{constructor(n,s){let d=t;this[d(1307)]=n,this[d(908)]=s,this._qosDB=localStorage}async openDB(){}get _prefix(){return"frontier_"+this[t(1307)]}async[t(652)](n){let s=t,d=this[s(1355)][s(1015)](this[s(1605)]);return JSON.parse(e[s(1785)](d,"{}"))[n]}async[t(1796)](n,s){let d=t,h={Kzfjm:e.dVdbg,gDFPG:e[d(1514)],satjc:d(1193),jaWPu:e[d(1018)],qZuPJ:e[d(650)]};if(e[d(619)]===e[d(1254)]){let w=h[d(786)][d(1721)]("|"),S=0;for(;;){switch(w[S++]){case"0":this[d(512)][d(1227)+"Listener"](h.gDFPG,this[d(1699)]);continue;case"1":this[d(512)][d(1227)+d(1811)](h.satjc,this[d(485)+"ge"]);continue;case"2":if(!this[d(512)])return;continue;case"3":this[d(512)][d(1227)+d(1811)](h[d(1269)],this[d(466)]);continue;case"4":this[d(512)][d(1227)+d(1811)](h.qZuPJ,this[d(1134)]);continue}break}}else{let w=this._qosDB[d(1015)](this[d(1605)]),S=JSON.parse(e[d(1610)](w,"{}"));return S[s||n[this[d(908)]]]=n,this[d(1355)].setItem(this[d(1605)],JSON[d(1217)+"y"](S)),s||n[this[d(908)]]}}async[t(1200)](n){let s=t;if(e[s(1727)](e.XJbWf,s(1676))){let d=this[s(1355)][s(1015)](this[s(1605)]),h=JSON[s(1462)](d||"{}");return h[n]=void 0,this._qosDB[s(476)](this[s(1605)],JSON[s(1217)+"y"](h))}else this[s(1355)]?.[s(1200)](_0x58db14[s(450)+"id"])}async[t(1346)](){let n=t;if(e.Rbwaq(e[n(1219)],e.RPGtH))this[n(1517)](e.wMzTx,e[n(1256)](_0x3f9fb5,e.wMzTx,{message:this["_formatErrorMess"+n(1129)](_0x25a881)}));else return this[n(1355)][n(1346)]()}async[t(1533)](){let n=t,s=this[n(1355)][n(1015)](this[n(1605)]),d=JSON[n(1462)](e[n(509)](s,"{}"));return Object[n(1533)](d)}async getAll(){let n=t,s=this._qosDB[n(1015)](this[n(1605)]),d=JSON.parse(e[n(1785)](s,"{}"));return Object[n(1666)](d)}[t(1121)](){return Promise.resolve()}get[t(1794)](){return!!this[t(1355)]}}class ng{constructor(n,s){let d=t;this._DBName=n,this[d(908)]=s,this[d(1355)]=Cn?tt:Xr?wx:null}async openDB(){}get[t(1605)](){let n=t;if(e[n(1381)](e[n(654)],e[n(614)])){this[n(772)+n(1513)+"t"]();let s=e[n(1184)](_0xbdad86,e.MFOAW,{message:n(1620)+n(1511)+n(1606)+"ct"});this["onStopIm"+n(406)+"yReconnect"]&&this[n(1308)+n(406)+n(675)+"ct"](s)}else return n(1608)+"_"+this[n(1307)]}async[t(652)](n){let s=t,d=this[s(1355)].getStorageSync(this[s(1605)]);return JSON[s(1462)](d||"{}")[n]}async[t(1796)](n,s){let d=t,h=this[d(1355)][d(973)+d(1746)](this[d(1605)]),w=JSON[d(1462)](e[d(531)](h,"{}"));return w[s||n[this[d(908)]]]=n,this[d(1355)]["setStora"+d(1746)](this[d(1605)],JSON[d(1217)+"y"](w)),s||n[this[d(908)]]}async del(n){let s=t,d=this._qosDB["getStora"+s(1746)](this[s(1605)]),h=JSON.parse(e.SrinG(d,"{}"));return h[n]=void 0,this[s(1355)][s(1660)+"geSync"](this[s(1605)],JSON[s(1217)+"y"](h))}async clear(){let n=t;return this[n(1355)][n(724)+n(1043)]()}async keys(){let n=t,s=this[n(1355)]["getStora"+n(757)+"nc"](this._prefix),d=JSON[n(1462)](e[n(1785)](s,"{}"));return Object[n(1533)](d)}async getAll(){let n=t;if(e[n(396)](e.IvXNh,e[n(707)])){let s=this[n(1355)][n(973)+"geInfoSync"](this[n(1605)]),d=JSON[n(1462)](e[n(1423)](s,"{}"));return Object[n(1666)](d)}else{let s=e.EoBNl(_0x36f65e,_0x31725a),d=_0x33ee16[n(498)];return _0x228734.limit=e.eISTT(_0x1965eb[n(1373)],s),d}}[t(1121)](){let n=t;return e[n(1440)](e.CCjWc,n(766))?Promise.resolve():_0x4bb0d9||(_0x15903a=[_0x41486f,_0x2929ab,_0x6529d2,_0xf357ac,_0x1e2f6c])}get[t(1794)](){return!!this[t(1355)]}}function _d(a,n){let s=t;if(e[s(1765)](Cn,Cn))return new ng(a,n);if((nr||Qr)&&e[s(1006)](e.yReJw,typeof indexedDB))return new eg(a,n);if(e[s(1423)](nr,Qr)&&s(1105)+"d"!=typeof localStorage)return new tg(a,n);throw new Error(e.amfgm)}class rg{constructor(){let n=t;this[n(1108)+n(749)+"Id"]=null,this[n(1108)+"l"]=36e5,this[n(1355)]=_d("qos",n(450)+"id")}async[t(1108)+t(1438)](){let n=t,s={bjrfE:e.pocFk,Afpeb:e[n(650)],DXBNi:e[n(1514)],AOrdq:e[n(836)],wMUGX:e[n(1018)]};if(e.eLvqi(e.aJyet,e[n(550)]))e[n(1082)](clearInterval,this._intervalTimeoutId),this[n(1108)+"lTimeoutId"]=e[n(1311)](setInterval,()=>{let d=n;this[d(598)+d(1314)]()},this[n(1108)+"l"]);else{let d=s.bjrfE.split("|"),h=0;for(;;){switch(d[h++]){case"0":this[n(512)][n(1435)+n(776)+"ner"](s[n(666)],this[n(1134)]);continue;case"1":this[n(512)][n(1435)+n(776)+n(1260)](s[n(1443)],this[n(1699)]);continue;case"2":this[n(512)][n(1435)+n(776)+n(1260)](s[n(1405)],this[n(485)+"ge"]);continue;case"3":if(!this[n(512)])return;continue;case"4":this._ws["removeEv"+n(776)+"ner"](s[n(1431)],this[n(466)]);continue}break}}}async[t(941)](){let n=t;await this[n(1355)][n(941)]()[n(1003)](()=>{let s=n;this[s(1108)+s(1438)]()})}async[t(598)+t(1314)](){let n=t,s={agIrZ:function(w,S){return e.VnhgC(w,S)}};(await this._qosDB?.[n(1575)]()||[])[n(829)](({timestamp:w})=>w<Date.now())[n(1558)](w=>{let S=n;if(e[S(554)](e[S(1489)],e[S(1489)])){let E=new _0x59482c(iLQZYN[S(1454)](2,_0x45d7a4));E[S(1796)](_0x320f25),_0x15bc3c[S(981)]=E}else this[S(1355)]?.[S(1200)](w[S(450)+"id"])})}async[t(1200)](n){if(e[t(1487)]!==e.fJVnF)return this._qosDB?.del(n)}async[t(1796)](n,s){let d=t;return this[d(1355)]?.[d(1796)]({message_id:n,timestamp:s})}async[t(652)](n){let s=t;return this._qosDB?.[s(652)](n)}async closeDB(){let n=t;e[n(1090)](clearInterval,this["_interva"+n(749)+"Id"]),await this[n(1355)]?.[n(1121)]()}get[t(1794)](){let n=t;return this[n(1355)]?.[n(1794)]}}function Ea(a){let n=t,s=!!this[n(803)][n(909)+"S"];if(!s)return{enabled:s,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let d=e[n(1337)](sn,a.message[n(1433)],e[n(1225)],"2"),h=d&&sn(a[n(1193)].headers,e[n(1365)],"1"),w=d&&e[n(1337)](sn,a[n(1193)][n(1433)],e[n(1319)],"1"),S=w?rr(a[n(1193)][n(1433)],n(1159)+"er_ack_msgid")?.[n(1721)](",")[n(829)](Boolean)||[]:[];return{enabled:s,isQoSMessage:d,isQoSAck:h,isAckCleanupMessage:w,ackMsgIds:S}}async function yd(){let a=t;return this[a(896)+a(723)]||(this[a(896)+a(723)]=new rg),this[a(896)+a(723)][a(1794)]||await this[a(896)+a(723)][a(941)](),this[a(896)+a(723)]}async function ig(a,n){let s=t;if(e[s(605)](e[s(1442)],"ElBOo")){if(e[s(1725)](e.rJySz,typeof _0x1480d1)){let d=new _0x1b945b(e[s(603)](_0x3400aa,_0x26fe1e));return e.FgYcC(_0x5b5c16,_0x5e07a6,d,0),d}return e[s(1236)](_0x4d1860,_0x4f6b08)?new _0x165765(_0x5a77b5):new _0x2c08c5(_0x2aa12d[s(858)],_0x3473d1[s(1491)+"et"],_0x50feb0.byteLength)}else{let{enableAutoAck:d}=this[s(803)],h=sn(a[s(1193)][s(1433)],e[s(681)],"1"),w=e[s(1162)](sn,a.message.headers,e[s(1102)],"1"),S=Ea[s(1502)](this,a);if(e.pBzHk(d,h)){let{SeqID:E,LogID:g,service:D,LogIDNew:L,method:B}=a[s(1193)];this[s(1543)]({SeqID:E,LogID:g,LogIDNew:L,service:D,method:B,headers:[{key:"is_ack",value:"1"},{key:e[s(1478)],value:e[s(1012)](L,"")},{key:e[s(1563)],value:"0"}]})}w&&!S[s(1420)]&&this[s(755)+s(881)+s(855)](a),e[s(641)](n)}}async function sg(a,n){let s=t;this[s(437)](e[s(874)],a.message),n()}async function og(a,n){let s=t;if(e[s(1824)](e[s(1744)],e.Gegjw)){let d=e[s(885)](tn,await e[s(584)](wd,a[s(1013)]));try{if(d[s(888)]instanceof Uint8Array){let h=this[s(803)][s(819)+"ncoding"]instanceof Object?{force:!!this[s(803)][s(819)+"ncoding"][s(917)],encoding:this._options["payloadE"+s(1621)][s(1790)]?this[s(803)].payloadEncoding[s(1790)][s(484)](/\s/g,"")["toLowerC"+s(1025)]():""}:{force:!1,encoding:this[s(803)][s(819)+s(1621)]?this[s(803)][s(819)+"ncoding"].replace(/\s/g,"")[s(861)+s(1025)]():""},w=d[s(819)+s(1621)]?d[s(819)+s(1621)][s(484)](/\s/g,"")[s(861)+"ase"]():"",S=e[s(1138)](this[s(803)][s(518)+s(980)],Object)?{force:!!this[s(803)].payloadType[s(917)],type:this[s(803)].payloadType[s(457)]?this[s(803)].payloadType.type[s(484)](/\s/g,"")[s(861)+s(1025)]():""}:{force:!1,type:this[s(803)][s(518)+s(980)]?this._options["payloadT"+s(980)][s(484)](/\s/g,"")[s(861)+"ase"]():""},E=d[s(518)+s(980)]?d["payloadT"+s(980)][s(484)](/\s/g,"")[s(861)+s(1025)]():"",g=S[s(917)]?S[s(457)]:E||S[s(457)],D=h[s(917)]?h.encoding:w||h[s(1790)],L=[e[s(851)],e[s(1399)],e[s(1403)],e.rJySz],B=[e.QFTWp,e.LtmXH];this[s(803)][s(827)+s(1350)+s(726)+"ad"]&&L[s(1812)](g)&&(!D||B[s(1812)](D))?d["textPayl"+s(1010)]=md(d[s(888)],0,d[s(888)][s(1578)+"th"]):d[s(1357)+s(1010)]=""}else d[s(1357)+s(1010)]=""}catch(h){d[s(1357)+s(1010)]="",console.log(h)}a[s(1193)]=d,e[s(641)](n)}else return!!(e[s(1670)](this[s(428)+s(1593)],this.endpoints[s(1592)])||e.wyrbf(this[s(428)+s(1593)],e[s(530)](this[s(1052)+"s"][s(1592)],1))&&e.nHZEN(this[s(1808)+"ndpointT"+s(1466)+"t"],this[s(946)+"es"]))}function ag(a,n,s){let d=t,h=e[d(1785)](s,8192),w=e[d(672)](h,1),S=null,E=h;return function(g){let D=d;if(g<1||e[D(889)](g,w))return e[D(995)](a,g);E+g>h&&(S=a(h),E=0);let L=n.call(S,E,E+=g);return 7&E&&(E=e[D(648)](e.lwdvU(7,E),1)),L}}let cg=4294967295;function lg(a,n,s){let d=t;return RangeError(e[d(648)](e.tellO(e[d(587)](d(1802)+d(356)+d(1698),a)+d(1713)+(n||1),e[d(1536)]),s))}function dg(a,n,s){let d=t,h={mRBNx:e.WjisH,ApCcc:function(w,S){return w!=S},gdoog:e[d(834)]};if(e[d(604)]!==e[d(604)]){let w=h.mRBNx[d(1721)]("|"),S=0;for(;;){switch(w[S++]){case"0":return!1;case"1":if(_0x593ef3&&_0x59c448[d(537)+d(1818)])return!0;continue;case"2":if(_0x235884)return!0;continue;case"3":if((_0x5034ed||_0x444979)&&cVLHry[d(628)](cVLHry[d(1285)],typeof _0x5584b2)&&_0x1d6e45)return!0;continue;case"4":if(_0x22b537&&_0x2a7b54[d(537)+d(1818)])return!0;continue}break}}else{if(e[d(841)](s,cg))throw new Error(d(971)+d(1160)+"e");let w=3;for(;e.njwtN(w,0);){let S=255&s;e[d(1153)](Sa,S,a,e[d(1741)](n,w)),s>>>=8,w--}return e[d(950)](n,4)}}function ug(a,n){let s=t;if(e[s(1460)](e[s(869)],e[s(1673)])){let d=0,h=n,w=e.tMfrb(n,4);for(;e[s(1144)](h,w);){let{value:S,offset:E}=e[s(988)](va,a,h);h=E,d=e[s(1482)](e[s(1709)](d,8),0),d+=S}return{value:d,offset:w}}else{let d=_0xb7a905.bytes,h=_0x294b19[s(498)];return d[s(1592)]===h?d:d[s(1014)](0,h)}}function fg(a,n,s){let d=t,h=e.rHPQw.split("|"),w=0;for(;;){switch(h[w++]){case"0":if(!a)return s;continue;case"1":if(n[d(430)])return e[d(1507)](n[d(430)](a,s),s);continue;case"2":if(e[d(362)](a[d(1592)],40))return e.tMfrb(e[d(1097)](ya,a,n,s),s);continue;case"3":return e[d(1112)](ya(a,n,s),s);case"4":if(n[d(1286)+"e"])return n.utf8Write(a,s)+s;continue}break}}function hg(a,n){let s=t,d=new he(e[s(1655)](e[s(522)](e[s(1368)](a[e[s(1179)](n,4)]<<24,e[s(822)](a[n+5],16)),e.nZWmq(a[e.vxKfP(n,6)],8)),a[n+7]),e[s(1207)](e[s(1604)](e[s(925)](a[e[s(1387)](n,0)]<<24,e[s(702)](a[e[s(1625)](n,1)],16)),a[e[s(665)](n,2)]<<8),a[e.BKRsK(n,3)]),!0);return n+=8,{value:d,offset:e[s(1623)](n,8)}}function xg(a,n,s){let d=t,h=a[d(421)],w=a[d(1411)];return n[s]=e[d(1143)](w,24),n[e[d(467)](s,1)]=e[d(1154)](w>>>16,255),n[e[d(676)](s,2)]=e.qbkAl(e[d(1378)](w,8),255),n[s+3]=e[d(704)](255,w),n[e[d(1463)](s,4)]=e[d(473)](h,24),n[s+5]=h>>>16&255,n[e[d(1556)](s,6)]=e[d(1437)](e[d(1063)](h,8),255),n[s+7]=e[d(1202)](255,h),s+=8,s}function va(a,n){let s=t;return e[s(771)](e[s(939)],e.zXqWj)?this[s(911)][s(958)+"te"]:a[s(441)+"8"]?{value:a[s(441)+"8"](n),offset:e[s(1152)](n,1)}:{value:e[s(1598)](255,a[n]),offset:n+1}}function Sa(a,n,s){let d=t;return n[d(1740)+"t8"]?n[d(1740)+"t8"](a,s):n[s]=e[d(481)](255,a),e.EglzS(s,1)}let pg=function(a){return new Uint8Array(a)},gg=e.FDJAf(e[t(834)],typeof Buffer)?Buffer["allocUns"+t(1362)]:e.LIcJm(ag,pg,Uint8Array[t(1766)+"e"][t(1014)]),mg=16,Ia=32;function wg(a){let n=t,s=0,d={};for(let h=0;e.nbGFW(h,a[n(1592)]);h++)d[a[h][n(1771)+n(1216)]]=e[n(918)](gd,a[h][n(1771)+n(1216)]),s+=e.aNgYW(14,d[a[h][n(1771)+"ame"]]);return[s,d]}function bd(a,n,s){let d=t,h={dCpmj:e.LGBlz,CrMvK:e[d(882)],bxPqz:function(D,L,B,W){return e[d(379)](D,L,B,W)},kqamd:e[d(864)],jMmiC:"name",vGJBY:e[d(929)],kNiuI:e[d(951)]},[w,S]=e.psvjV(wg,a),E=e[d(1801)](gg,w),g=0;return a[d(1558)](D=>{let L=d,B=h.dCpmj.split("|"),W=0;for(;;){switch(B[W++]){case"0":console[L(1724)](h.CrMvK,g);continue;case"1":g=h[L(1028)](Sa,0,E,g);continue;case"2":console[L(1724)](h[L(1067)],g);continue;case"3":console.log(L(873)+L(932),g);continue;case"4":console.log(h[L(403)],g);continue;case"5":g=dg(E,g,D.service||0);continue;case"6":g=fg(D[L(1771)+L(1216)],E,g);continue;case"7":g=Sa(S[D[L(1771)+L(1216)]],E,g);continue;case"8":g=h[L(1028)](xg,he.fromNumber(D[L(1150)]||n),E,g);continue;case"9":console[L(1724)](h.vGJBY,g);continue;case"10":console[L(1724)](h[L(591)],D,D[L(1274)]);continue}break}}),{frameType:Ia,headers:[{key:d(685)+d(617),value:s}],payload:E}}function _g(a){let n=t,s=0,d=[];for(;e[n(1312)](s,a[n(1578)+"th"]);){let{offset:h}=e[n(1336)](va,a,s);s=h;let w={cursor_name:"",cursor:0,service:0},{value:S,offset:E}=e[n(974)](ug,a,s);w[n(1274)]=S,s=E;let{value:g,offset:D}=va(a,s);s=D,w[n(1771)+n(1216)]=e.URpLF(md,a,s,e[n(1386)](s,g)),s+=g;let{value:L,offset:B}=e.RnTLC(hg,a,s);w[n(1150)]=L[n(417)](),s=B,d[n(1140)](w)}return d}function yg(){let a=t;return{frameType:Ia,headers:[{key:e[a(780)],value:a(1587)+"_EXIST"}],payload:void 0}}class bg{constructor(n,s,d){let h=t;this[h(1333)+h(1174)]=n,this[h(1096)+h(1645)]=s,this["_message"+h(709)]=d,this[h(1355)]=e.qjMbF(_d,this[h(1333)+h(1174)],e.akDfE)}async[t(941)](){let n=t;await this[n(1355)][n(941)]()}async[t(1302)+"rs"](){let n=t;if(!this[n(1355)].isReady)return;let s=this[n(744)+"Strategy"],d=await this._qosDB.getAll();switch(console[n(1724)](e[n(1538)],d),s){case e[n(1577)]:return d&&d[n(1592)]?e[n(1337)](bd,d,0,this[n(1096)+n(1645)]):void 0;case e[n(589)]:return;case e[n(1816)]:return d&&d[n(1592)]?e[n(1097)](bd,d,0,this[n(1096)+n(1645)]):e.hUWtG(yg)}}async[t(1796)](n,s,d){let h=t;return console.log(h(451),n,s,d),this._qosDB[h(1796)]({cursor_name:n,cursor:s,service:d})}async[t(1044)+"rs"](n){let s=t,d=e.ZbYkY(_g,n);for(let h of d)console[s(1724)](e[s(1095)],d),await this._qosDB[s(1796)](h)}async[t(652)](n){let s=t;return(await this[s(1355)][s(652)](n))?.cursor}async[t(1121)](){let n=t;await this._qosDB[n(1121)]()}[t(1733)+t(360)+t(678)](n){let s=t;this[s(1096)+s(1645)]=n}get isReady(){let n=t;if(e.erODb(e[n(839)],e.UXvYC))return this[n(1355)][n(1794)];try{return!!this[n(1355)]}catch(s){return _0x3b61c7[n(1724)](s),!1}}}let Eg="__x_msg_"+t(966);async function Ed(a){let n=t,s={WwQYi:function(E,g,D){return E(g,D)},jDdBs:e[n(1514)],WIsko:n(1246)};if(!this._options[n(909)+"S"])return null;let{aID:d,fpID:h,messageStrategy:w}=this[n(803)],S=e.SrinG(a,Eg);try{if(this[n(916)+n(1809)])if(e.RzFLk(e[n(1488)],e[n(1132)]))a&&this[n(916)+n(1809)][n(1733)+n(360)+n(678)](a);else{let E=_0x211134(_0x21c1eb,_0x1bf95e[n(1592)]);_0x404484[n(981)].set(_0x30cada,E)}else this["_cursorM"+n(1809)]=new bg(h+"_"+d+"_"+S,S,w);return this[n(916)+n(1809)][n(1794)]||await this[n(916)+n(1809)].openDB(),this._cursorManager}catch{if(e[n(1527)](e[n(1242)],n(489))){this["_dispatc"+n(1041)+"ent"](s[n(365)](_0x549eed,s[n(1496)],{code:1e3,reason:s[n(1776)]})),this[n(357)+n(720)]?.[n(1167)+n(1814)+n(646)](),this[n(608)+n(868)]?.["resetCou"+n(1675)]();return}else return null}}async function vg(a,n){let s=t;if(e[s(1691)](e[s(751)],e[s(751)]))_0xd3e5ef[_0x55a7e1++]=_0x1467ad>>6|192,_0x5e78f4[_0x342190++]=63&_0x1df197|128;else{let d=e.FgYcC(sn,a[s(1193)].headers,s(1273),"-1"),h=sn(a[s(1193)][s(1433)],e[s(1102)],"1"),w=e[s(752)](rr,a.message.headers,"x_fronti"+s(1748)),S=Number(e[s(818)](rr,a[s(1193)][s(1433)],e.QtZAj))||0,E=Ea.call(this,a),g=e[s(1097)](sn,a[s(1193)].headers,e.dDESF,"2"),D=e[s(1689)](rr,a[s(1193)][s(1433)],e[s(1222)]),L=e[s(986)](Number,rr(a[s(1193)][s(1433)],e[s(1394)]));if(E[s(1420)])return e[s(1519)](n);let B=E[s(1667)+s(461)]?await yd[s(1502)](this):null;if(e.GwWvF(a[s(1193)].service,0)&&h&&!d||e[s(841)](a[s(1193)][s(1274)],0)){if(w&&E[s(1667)+s(461)]&&B)return!!!await B[s(652)](w)&&(e[s(793)](s(1309),e[s(1171)])?(e[s(1088)](_0x1fb80b,_0x15db14,32),_0x31ee65(_0x2e3afe,e[s(442)](_0x10c06c,_0x504cbd))):(this._dispatchMessageEvent(a),await B[s(1796)](w,e[s(676)](Date[s(1505)](),S)))),n();if(g)if(e.EBXJE(e.kYiGV,e[s(1750)])){let W=await Ed.call(this);if(!W)return this[s(755)+s(708)+s(823)](a),e[s(465)](n);let X=await W[s(652)](D)??-1;if(e.ndPhx(X,L))this[s(755)+s(708)+s(823)](a),W[s(1796)](D,L,a[s(1193)].service);else throw new Error(s(1720)+s(429)+s(1586)+L+(s(505)+s(1054)+s(1376)+"r ")+X);return n()}else _0xdd3dd2(this[s(1477)+s(767)+s(393)]),this._connectionTimeoutId=null;return this[s(755)+s(708)+s(823)](a),e[s(1559)](n)}}}async function Sg(a,n){let s=t,d=Ea[s(1502)](this,a);if(!d[s(1667)+s(461)])return e[s(727)](n);let h=await yd[s(1502)](this);if(d[s(516)+s(599)+s(1129)]&&d[s(921)+"s"].length)for(let w of d[s(921)+"s"])await h[s(1200)](w);e[s(1055)](n)}async function Ig(a,n){let s=t,d={XmciV:function(h,w){return e[j(1339)](h,w)},CXPiV:function(h,w){return e[j(1583)](h,w)},YcHNj:function(h,w){return e[j(1650)](h,w)},cHfgw:function(h,w){return h&w},JbCAN:function(h,w){return e.bYxFd(h,w)}};if(e[s(1377)]!=="rqsIT"){if(_0x3315fa<1||rNoQcG[s(433)](_0x51ea77,_0x265383))return rNoQcG[s(746)](_0x138e7b,_0x1e6d71);rNoQcG[s(805)](_0x67b7c9,_0x971504)>_0x5e2a27&&(_0xf6e46e=rNoQcG[s(746)](_0x2f6941,_0x23902a),_0x165a34=0);let h=_0x3f4827[s(1502)](_0x2511a3,_0x5cfd8f,_0xbaf6f5+=_0x49ce8c);return rNoQcG[s(1259)](7,_0x780de)&&(_0x2a87b0=rNoQcG[s(805)](rNoQcG.JbCAN(7,_0x5b0baa),1)),h}else{let h=e[s(1503)](a[s(1193)].frameType,mg),w=e[s(1503)](a[s(1193)][s(374)+"e"],Ia);if(e[s(525)](!h,!w))return e[s(641)](n);let S=rr(a.message[s(1433)],e[s(780)]);if(!S)return e.SbGAz(n);let E=await Ed.call(this,S);if(!E)return e[s(641)](n);if(h){let g=await E[s(1302)+"rs"](),D={frameType:g?.["frameType"],SeqID:he[s(1553)+"er"](this[s(1210)]++),LogID:he[s(1553)+"er"](this[s(803)]["logIDGen"+s(844)]()),service:9e3,method:5,headers:g?.[s(1433)],payload:g?.[s(888)]},L=v(D);this[s(512)]&&this[s(512)][s(958)+"te"]&&this[s(512)][s(1223)](L)}if(w){let g=a[s(1193)][s(888)];g&&E[s(1044)+"rs"](g)}}}let Ag=async function(a,n){let s=t;this[s(1732)]=!1,e.Vxrpx(clearTimeout,this[s(1477)+s(767)+"utId"]),n()},Tg=async function(a,n){let s=t;if(!this[s(512)]||e[s(1459)](this[s(512)].readyState,this[s(1607)]))return e[s(548)](n);let{pingInterval:d}=this[s(803)];this[s(357)+"tManager"]?.[s(1167)+s(1814)+s(646)]();for(let w=0;e[s(1526)](w,this[s(744)+s(1024)].length);w++){let S=this._messageQueue[w];if(e[s(607)](this._ws[s(958)+"te"],this[s(1607)])&&e[s(1428)](null,S))this[s(512)]&&this[s(512)][s(1223)](S),this._messageQueue[w]=null;else break}this[s(744)+s(1024)]=this[s(744)+s(1024)][s(829)](w=>!!w),this["_pingPon"+s(1288)+"Id"]=setTimeout(()=>this._ping(),d),this[s(755)+s(1296)+"nt"](a),this[s(1031)+"er"]&&this._ws&&(this._ws[s(1084)+"pe"]=this[s(721)+s(980)]);let h=this[s(357)+"tManager"]?.[s(596)+s(990)+"nt"]();this[s(437)](s(1120)+h+s(777)),e[s(1559)](n)},kg=async function(a,n){let s=t,d=this[s(357)+s(720)]?.["getCurre"+s(990)+"nt"]();this[s(437)](s(1120)+d),n()};class Cg extends _a{constructor(n){let s=t,d={HMHhN:function(h,w,S,E){return e[j(379)](h,w,S,E)},sJhrq:function(h,w,S){return e.stsEo(h,w,S)},zCTSf:"error"};if(e.KObYF(e[s(1036)],e.eCIZr)){super(),this[s(446)+"igatorOn"+s(1389)]=!0,this._isBrowser=nr,this[s(538)]=Wp,this._isMiniTT=Cn,this[s(870)+"X"]=Xr,this[s(690)+"r"]=Qr,this[s(744)+s(1024)]=[],this[s(357)+s(720)]=null,this[s(1702)+s(1163)]=!1,this[s(721)+s(980)]=e[s(508)],this[s(1477)+s(1268)]=!1,this[s(1477)+s(767)+s(393)]=null,this["_reconne"+s(898)+s(662)]=null,this["_pingPon"+s(1288)+"Id"]=null,this[s(1210)]=0,this[s(1732)]=!1,this._url="",this[s(896)+s(723)]=null,this[s(916)+s(1809)]=null,this._pingLossCounter=null,this._protocols=e[s(1636)],this.CLOSED=3,this[s(1652)+"NG"]=0,this[s(1607)]=1,this[s(840)]=2,this[s(1134)]=E=>{let g=s;try{d.HMHhN(pd,this,E,[Ag,Tg,kg])}catch(D){let L=d[g(398)](ct,d[g(710)],{message:D[g(1193)],code:rn[g(1580)+"OR"],error:D});this[g(755)+g(733)+g(1071)](L)}},this[s(485)+"ge"]=async E=>{let g=s,{pingInterval:D,pingFrequency:L}=this[g(803)];if((e[g(1550)]("hi",E.data)&&e[g(549)](e[g(1126)],L)||e[g(1258)](g(394),L))&&(this[g(578)+g(1185)](),this[g(1517)]("ping_onc"+g(924)+"s",g(1706)),this[g(1186)+"gTimeoutId"]=e[g(849)](setTimeout,this[g(546)][g(1425)](this),D)),!e.FjHJH("hi",E[g(1013)]))try{pd(this,E,[og,ig,Sg,Ig,vg,sg])}catch(B){let W=e[g(477)](ct,g(435),{message:B[g(1193)],code:rn[g(904)+g(677)],error:B});this["_dispatc"+g(733)+g(1071)](W)}},this[s(466)]=E=>{let g=s,D={OYnSg:function(L,B,W){return e[j(756)](L,B,W)},GmczH:e[g(1018)]};if(e[g(1774)](e[g(348)],e[g(348)])){let L="connect "+_0x305eb0+(g(928)+", max re"+g(1506)+g(1540));this[g(437)](L),this[g(755)+g(733)+"ent"](D[g(555)](_0x2d3273,D[g(1453)],{message:L,code:_0xde061e[g(1476)+g(627)+"R"]}));return}else{let L=this[g(357)+g(720)]?.["checkRea"+g(1656)+"es"](),B=this[g(357)+g(720)]?.[g(596)+"ntEndpoint"]();if(L&&!E[g(1193)]){let W="connect "+B+(g(1518)+g(948)+g(1480)+"ed");this[g(755)+"hErrorEvent"](e[g(1755)](ct,e[g(1018)],{message:W,code:rn["MAX_RETR"+g(627)+"R"],error:E}));return}this[g(512)]&&this[g(512)][g(958)+"te"]===this[g(1607)]&&this[g(1196)+g(848)](),this[g(755)+g(733)+g(1071)](e.ggLak(ct,g(435),{message:E[g(1193)],code:rn[g(1142)+"RROR"],error:E}))}},this[s(1699)]=async E=>{let g=s;this[g(1602)+g(595)](),this[g(578)+"ngTimer"](),this[g(860)+g(831)+"rs"](),this[g(512)]=null,this[g(1477)+"Lock"]=!1;let D=this[g(357)+g(720)]?.["checkRea"+g(1656)+"es"]();if(!D&&this[g(355)+g(1758)]()&&!this._readyClosed){let L=this[g(357)+g(720)]?.["getCurre"+g(990)+"nt"](),B=this[g(803)][g(1068)+"tInterce"+g(1686)](E.code,E[g(640)]);this[g(755)+"hCloseEvent"](e[g(852)](mt,e[g(1514)],{code:1006,reason:E[g(640)]||g(1253)+g(687)+"d, unkno"+g(576)+g(1136)+g(1467)+L,willReconnect:B})),B&&this[g(1477)]();return}if(E[g(1273)]!==1e3&&this[g(1702)+g(1163)]){this[g(755)+g(1041)+g(1071)](e[g(1515)](mt,e[g(1514)],{code:1e3,reason:e[g(824)]})),this[g(357)+g(720)]?.["resetEndpointCon"+g(646)](),this["_pingLos"+g(868)]?.[g(647)+g(1675)]();return}if(e.pFIHH(1e3,E[g(1273)])&&D){let L=this[g(357)+"tManager"]?.[g(596)+g(990)+"nt"](),B=E[g(640)];B||(B=await e[g(997)](Xp,this[g(1360)])),B=g(1253)+"ng faile"+g(926)+B+(g(1490)+g(1700))+L+(g(718)+"tries re"+g(1540)),this[g(755)+g(1041)+g(1071)](e.erLpB(mt,e.FeXiv,{code:E[g(1273)],reason:B}));let W=g(1330)+L+(" fail, m"+g(948)+"es reached");this[g(755)+g(733)+g(1071)](e[g(1515)](ct,e.wMzTx,{message:W,code:rn[g(1476)+g(627)+"R"]})),this[g(357)+g(720)]?.["resetEnd"+g(1814)+g(646)](),this[g(608)+g(868)]?.resetCounter();return}if(E.code!==1e3&&!E[g(640)]){let L=this[g(357)+g(720)]?.["getCurre"+g(990)+"nt"]();this["_dispatc"+g(1041)+g(1071)](mt(g(532),{code:E[g(1273)],reason:g(1253)+"ng faile"+g(1215)+g(576)+g(1136)+g(1467)+L})),this[g(357)+"tManager"]?.[g(1167)+g(1814)+g(646)](),this[g(608)+"sCounter"]?.["resetCou"+g(1675)]();return}this[g(755)+g(1041)+"ent"](E),this["_endpoin"+g(720)]?.["resetEndpointCon"+g(646)](),this[g(608)+"sCounter"]?.[g(647)+g(1675)]()},this.onclose=null,this[s(1461)]=null,this[s(862)+"e"]=null,this[s(1022)]=null,this[s(1481)+s(996)]=null,this[s(1707)+s(1390)]=null,this.onStopImmediatelyReconnect=null,this[s(1769)+s(993)]=this[s(1769)+"nLine"][s(1425)](this),this[s(1769)+s(1113)]=this[s(1769)+s(1113)][s(1425)](this),this["_handleP"+s(528)]=this[s(568)+s(528)][s(1425)](this),this[s(568)+s(692)]=this["_handleP"+s(692)][s(1425)](this),this[s(803)]={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e[s(1119)](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.iQwJV,pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:s(1504),env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:h,ws:w}=n,S=Array[s(1464)](h)?h:e.jrOmJ(s(758),typeof h)?[h]:[];if(!S||e[s(1224)](0,S[s(1592)]))throw new Error(e[s(1049)]);if(!e.QBjhf(Vp,w))throw new Error(e.FeVNZ);Object[s(1156)](this[s(803)],n),this._endpointManager=new xd(S,this[s(803)][s(946)+"es"]),this._pingLossCounter=new Yp(this[s(803)][s(455)+s(490)]),this[s(803)][s(837)+s(1674)]&&(this[s(1732)]=!0,this[s(1477)]()),this[s(803)][s(600)+s(1734)+"nged"]&&(this[s(1203)+"T"]||this[s(870)+"X"]?this[s(1191)+s(1352)+s(923)]():this._isBrowser&&this[s(1787)+"balEventListener"]())}else return this[s(911)].binaryType}[t(1769)+t(993)](){let n=t;this._options["disableAutoRecon"+n(934)]||this[n(1702)+"osed"]||this[n(1401)+n(996)]()}[t(1769)+t(1113)](){let n=t;this[n(772)+n(1513)+"t"]();let s=wa(e[n(1029)],{message:e[n(962)]});this["onStopIm"+n(406)+n(675)+"ct"]&&this[n(1308)+n(406)+n(675)+"ct"](s)}[t(1787)+t(1807)+"Listener"](){let n=t;this[n(1031)+"er"]&&window[n(1227)+n(1811)](e[n(1465)],this["_handleO"+n(993)]),this[n(1031)+"er"]&&window["addEvent"+n(1811)](e[n(667)],this["_handleO"+n(1113)]),this[n(1031)+"er"]&&window[n(1227)+n(1811)](e[n(404)],this[n(568)+"ageHide"]),this[n(1031)+"er"]&&window[n(1227)+n(1811)](e[n(856)],this[n(568)+"ageShow"])}["_dropGlobalEvent"+t(1811)](){let n=t;this[n(1031)+"er"]&&window[n(1435)+n(776)+n(1260)](n(1187),this[n(1769)+"nLine"]),this[n(1031)+"er"]&&window["removeEv"+n(776)+n(1260)](e[n(667)],this[n(1769)+n(1113)]),this[n(1031)+"er"]&&window[n(1435)+n(776)+n(1260)](n(1449),this[n(568)+n(528)]),this[n(1031)+"er"]&&window[n(1435)+n(776)+n(1260)](n(1432),this[n(568)+"ageShow"])}[t(568)+t(528)](n){let s=t;!n[s(894)+"d"]&&(this[s(1031)+"er"]&&window["removeEv"+s(776)+s(1260)](s(1449),this[s(568)+"ageHide"]),this[s(1031)+"er"]&&window["removeEventListe"+s(1260)](e[s(856)],this[s(568)+s(692)]),this.close()),this[s(1031)+"er"]&&window["removeEv"+s(776)+s(1260)](e.Mbnxx,this[s(1769)+s(993)]),this[s(1031)+"er"]&&window[s(1435)+s(776)+s(1260)](s(900),this[s(1769)+s(1113)])}["_handleP"+t(692)](n){let s=t;if(e[s(1754)](s(1696),e.QOLMs))n.persisted&&(this[s(355)+s(1758)]()&&(!this[s(512)]||e.eaWMB(this[s(512)][s(958)+"te"],this[s(1607)])||e[s(663)](this[s(512)][s(958)+"te"],this.CONNECTING))&&this["_handleO"+s(993)](),this._isBrowser&&window["addEvent"+s(1811)](e[s(1465)],this[s(1769)+s(993)]),this[s(1031)+"er"]&&window[s(1227)+s(1811)](s(900),this[s(1769)+s(1113)]));else return this["currentEndpointT"+s(1466)+"t"]=1,this[s(428)+s(1593)]++,this[s(1052)+"s"][this[s(428)+s(1593)]]}async["_generat"+t(1451)](n){let s=t;if(e[s(1728)]!=="ALvcb"){let d=this[s(357)+s(720)]?.["checkRea"+s(1656)+"es"](),h=this[s(357)+"tManager"]?.["getCurre"+s(990)+"nt"]();if(d&&!_0x167865[s(1193)]){let w=s(1330)+h+(s(1518)+s(948)+s(1480)+"ed");this[s(755)+s(733)+s(1071)](_0x2dfa1c(e[s(1018)],{message:w,code:_0x5e2727[s(1476)+s(627)+"R"],error:_0xf4eaa3}));return}this[s(512)]&&e.DRDtu(this[s(512)][s(958)+"te"],this[s(1607)])&&this[s(1196)+"ect"](),this["_dispatchErrorEv"+s(1071)](e.Tsagk(_0x2a7cc3,s(435),{message:_0x5b48cc[s(1193)],code:_0x5b8db1["NATIVE_E"+s(504)],error:_0x53ef5a}))}else{let{fpID:d,deviceID:h,bddID:w,ttwID:S,accessKey:E,aID:g,customParams:D={},enableAutoAck:L,enableQoS:B,QoSLevel:W,env:X}=this[s(803)],re,Te,on;this[s(1031)+"er"]||this._isMiniWX||this._isMiniTT?(re=location&&e[s(1183)](s(1091),location.protocol)?"wss://":e[s(358)],Te=n[s(484)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),on=/^wss(.*:\/\/)/[s(1730)](n)?n:""+re+Te):(re=e[s(594)],Te=n[s(484)](/(^http)((?:[s]*:\/\/))/,""),on=/(^ws)((?:[s]*:\/\/))/[s(1730)](Te)?Te:""+re+Te);let vd=w?"bd_did":S?e[s(368)]:"device_id",Sd=w||S||h;if(!Sd||!vd)throw new Error(e[s(1775)]);let Rg=e[s(1408)]==typeof D?await e[s(1772)](D):D,Pg=X?e[s(1094)](Zp,X[s(790)],X[s(386)]):{},Aa=Object[s(1156)]({device_platform:e[s(697)],version_code:s(1058)+"0",access_key:E,fpid:d,aid:g,[vd]:Sd,xsack:L?1:0,xaack:L?1:0,xsqos:B?1:0,qos_level:B?W:void 0,qos_sdk_version:2,...Pg},Rg),Dg=Object[s(1533)](Aa).reduce((Ta,ka)=>Aa[ka]!==void 0?""+Ta+(Ta?"&":"?")+ka+"="+Aa[ka]:Ta,"");return on+"/ws/v2"+Dg}}async[t(1477)](){let n=t;if(!(this._connectLock||this[n(1702)+n(1163)])){this[n(1477)+n(1268)]=!0;try{if(e[n(1428)]("iVdnd",n(1788))){let s=this[n(357)+n(720)]?.[n(799)+n(1335)+n(1251)+n(669)+n(902)](),{timeoutInterval:d}=this[n(803)];if(s)if(e[n(877)](e[n(547)],e[n(547)])){let w=this[n(357)+n(720)]?.[n(596)+n(990)+"nt"](),S=this[n(357)+n(720)]?.[n(732)+n(1469)+"pointAnd"+n(1589)+"unt"](),E=this[n(357)+"tManager"]?.[n(596)+n(990)+n(1073)+n(1004)]();if(S)if(e[n(1104)]===e.hPPZn){let g="connect "+w+(n(928)+n(718)+n(1506)+"ached, w"+n(1101)+n(1338)+n(815))+S+(n(353)+"y"),D=e[n(1161)](ct,e[n(1018)],{message:g,code:rn[n(1476)+n(627)+"R"]});this[n(437)](g),this[n(755)+n(733)+n(1071)](D),this[n(1360)]=await this._generateUrl(S),this._debug("connect "+S+" "+E+" times"),this[n(860)+n(831)+"rs"]()}else return _0x471bbb[n(686)]||_0x1da01e[n(1001)]?(n(1617)+" "+(_0x4de877[n(686)]||"")+n(517)+(_0x5727d2[n(1001)]||""))[n(1148)]():_0x5c1f8c[n(1217)+"y"](_0x2cdd8a);else{let g="connect "+w+(" timeout"+n(718)+n(1506)+n(1540));this._debug(g),this[n(755)+"hErrorEv"+n(1071)](ct("error",{message:g,code:rn[n(1476)+"IES_ERROR"]}));return}}else _0xa103e5+=_0x1c088a(_0x24a87a),_0x3055f8++;else{let w=this["_endpoin"+n(720)]?.[n(596)+n(990)+n(661)+n(1694)](),S=this[n(357)+n(720)]?.["getCurre"+n(990)+n(1073)+"ount"]();this._url=await this[n(795)+n(1451)](e[n(1033)](w,"")),this[n(437)](n(1330)+w+" "+S+n(1445)),this["_removeW"+n(831)+"rs"]()}if(this[n(1732)])this[n(1732)]=!1;else{let w=e[n(985)](wa,e.MFOAW,{message:n(949)});this[n(1481)+n(996)]&&this[n(1481)+n(996)](w)}let h=this[n(357)+n(720)]?.[n(596)+"ntEndpoi"+n(1073)+n(1004)]()||0;e[n(889)](h,1)&&await this._wait(e[n(1356)](h,1)),this[n(437)](n(1253)+n(483)+this[n(1360)]+(n(565)+n(1157))+this[n(434)+"ls"]),this[n(512)]=e[n(1220)]($p,{url:this[n(1360)],protocols:[this[n(434)+"ls"]],headers:this._options[n(760)+n(1279)+"s"]["customHt"+n(1544)]},this[n(803)].ws),(this._isBrowser||this._isWorker)&&this[n(512)]&&(this._ws.binaryType=this[n(721)+n(980)]),this[n(499)+n(1827)](),this[n(1477)+n(767)+n(393)]=e.nozXO(setTimeout,this._onTimeout[n(1425)](this),d)}else return this[n(512)]?this[n(512)][n(1084)+"pe"]:this[n(721)+n(980)]}catch(s){if(e[n(1061)](n(1684),n(1684)))_0x222fba[n(1724)](_0x352244);else throw this["_connect"+n(1268)]=!1,s}}}[t(1602)+t(595)](){let n=t;if(e[n(1139)](e.ymOrA,e[n(735)]))clearTimeout(this[n(1477)+n(767)+n(393)]),this[n(1477)+n(767)+n(393)]=null;else return _0x215588+=_0x1fdc78&&_0x284e25.byteLength||0,_0x1b0033}[t(578)+"ngTimer"](){let n=t;e[n(1493)](clearTimeout,this[n(1186)+n(1288)+"Id"]),clearTimeout(this["_reconne"+n(898)+n(662)]),this[n(1186)+n(1288)+"Id"]=null,this[n(703)+n(898)+n(662)]=null}_debug(...n){let s=t;this._options[s(1019)]&&console.log.apply(console,[e[s(1450)],...n])}[t(519)+t(1410)+"e"](n){let s=t,{initReconnectInterval:d,maxReconnectInterval:h,reconnectIntervalGrowFactor:w}=this[s(803)],S=d*Math[s(914)](w,e[s(1731)](n,1));return e[s(426)](S,h)?h:S}[t(546)](){let n=t;if(this[n(512)]&&e.vCQAw(this[n(512)][n(958)+"te"],this[n(1652)+"NG"])){this[n(578)+n(1185)](),this[n(1186)+n(1288)+"Id"]=e.YfQgD(setTimeout,this[n(546)][n(1425)](this),this._options[n(1567)+n(1252)]);return}if(!this[n(512)]||this[n(512)].readyState!==this[n(1607)])return void this._handleReconnect();this[n(512)]&&this[n(512)].send("hi"),this["_reconne"+n(898)+"tId"]=e[n(1045)](setTimeout,this["_handleR"+n(996)+n(1008)].bind(this),this[n(803)][n(1404)+"outInterval"])}[t(1401)+t(996)+t(1008)](){let n=t;this[n(608)+n(868)]?.addCount(),this[n(1517)](e[n(1124)],e[n(515)]),this._pingLossCounter?.[n(1284)+n(871)+"nt"]()?this[n(1401)+n(996)]():this[n(546)]()}[t(355)+"orOnline"](){let n=t;return this[n(1203)+"T"]||this[n(870)+"X"]?this[n(446)+"igatorOnline"]:(this[n(1031)+"er"]||this[n(690)+"r"])&&this[n(803)]["listenNetworkCha"+n(439)]?navigator[n(1603)]:!0}[t(1401)+t(996)](){let n=t,s={ZsyTN:e[n(964)]};if(e.eKzzx(e[n(1585)],e[n(1585)])){if(!this._navigatorOnline()||this["_readyCl"+n(1163)])return;this[n(357)+n(720)]?.[n(1167)+n(1814)+n(646)](),this[n(608)+n(868)]?.["resetCou"+n(1675)](),this[n(512)]?this["_disconn"+n(848)](1001,e[n(586)],!0):this[n(1477)]()}else switch(_0x4a27ad){case fqozqh[n(1409)]:case n(1804):return{[n(944)+_0x106c82]:1,"x-tt-env":_0x2fbf39};default:return{}}}["_onPageN"+t(1352)+t(923)](){let n=t,s={eIYAO:"abort"};this._isMiniTT?tt[n(1692)+n(968)+n(1072)](({isConnected:d})=>{let h=n;this[h(446)+"igatorOn"+h(1389)]=d,d?this["_handleO"+h(993)]():this[h(1769)+h(1113)]()}):this[n(870)+"X"]&&wx[n(1692)+"kStatusC"+n(1072)](({isConnected:d})=>{let h=n;e[h(1456)](e[h(748)],h(716))?(this[h(446)+"igatorOn"+h(1389)]=d,d?this[h(1769)+h(993)]():this[h(1769)+h(1113)]()):(_0x2ff637[h(1435)+h(776)+"ner"](h(712),_0x5dcfcf),_0x34be31[h(1435)+h(776)+h(1260)](h(435),_0x2d7c64),_0x3ed0b9[h(1435)+h(776)+h(1260)](CdgTre[h(520)],_0x18d0ac))})}[t(436)](n){let s=t,d={fBfDf:function(h,w){return h===w},EHidX:e[s(526)],zFSdM:function(h,w,S){return e.ayKNC(h,w,S)}};return new Promise(h=>{let w=s;d[w(664)](d[w(1683)],d.EHidX)?d[w(1753)](setTimeout,h,this[w(519)+w(1410)+"e"](n)):_0x3ebda0[w(1140)](_0x3f05fc)})}[t(1196)+t(848)](n=1e3,s="",d=!1){let h=t,w={olTbG:function(S,E){return e[j(1026)](S,E)},EXVOV:function(S,E){return e[j(1547)](S,E)}};if(e[h(850)](e[h(1618)],e[h(1541)])){if(!this[h(512)])return;this[h(772)+h(1513)+"t"](n,s,d)}else AirJBL[h(943)](_0x22d585,this["_pingPon"+h(1288)+"Id"]),AirJBL[h(1407)](_0x4ee682,this[h(703)+h(898)+"tId"]),this[h(1186)+h(1288)+"Id"]=null,this[h(703)+h(898)+h(662)]=null}[t(1495)+"ut"](){let n=t,s=this[n(357)+n(720)]?.["getCurre"+n(990)+"nt"]();this[n(437)]("connect "+s+n(928)),this[n(1196)+n(848)](1001,e[n(711)],!0)}[t(1543)](n){let s=t,d=e[s(523)](Ft,n);this._ws&&this[s(512)][s(958)+"te"]===this[s(1607)]&&(this._ws&&this[s(512)][s(1223)](d),this[s(437)](e.RaFEb,n))}["_removeW"+t(831)+"rs"](){let n=t,s=e.IVbGl.split("|"),d=0;for(;;){switch(s[d++]){case"0":this[n(512)][n(1435)+n(776)+n(1260)](e.riCIj,this[n(1134)]);continue;case"1":this._ws[n(1435)+"entListe"+n(1260)](e[n(1018)],this[n(466)]);continue;case"2":this[n(512)][n(1435)+n(776)+n(1260)](e[n(1514)],this._onClose);continue;case"3":this[n(512)][n(1435)+"entListe"+n(1260)]("message",this[n(485)+"ge"]);continue;case"4":if(!this[n(512)])return;continue}break}}[t(499)+"steners"](){let n=t;if(e[n(580)](e[n(391)],e[n(391)])){let s=e[n(1677)][n(1721)]("|"),d=0;for(;;){switch(s[d++]){case"0":this._ws.addEventListener("error",this[n(466)]);continue;case"1":this[n(512)][n(1227)+n(1811)](e[n(836)],this[n(485)+"ge"]);continue;case"2":if(!this[n(512)])return;continue;case"3":this._ws[n(1227)+"Listener"](e[n(650)],this[n(1134)]);continue;case"4":this._ws["addEvent"+n(1811)](e[n(1514)],this._onClose);continue}break}}else{if(e.HihJD(_0x29e874,_0x5f4428)<1)return"";let s="";for(let d=_0x26c143;e[n(1312)](d,_0x431fbd);){let h=_0x333091[d++];if(h<=127)s+=_0x51ac27["fromChar"+n(859)](h);else if(e.HilTg(h,192)&&e.lYEHA(h,224))s+=_0x26ff0c[n(714)+n(859)](e[n(684)](e.nXNni(e[n(452)](31,h),6),e.NKcQo(63,_0x22eb51[d++])));else if(h>=224&&e[n(931)](h,240))s+=_0x2f4f4f[n(714)+n(859)](e.LeewP(e[n(1051)](e[n(1083)](e[n(1528)](15,h),12),(63&_0x522f7a[d++])<<6),e[n(1133)](63,_0x381b81[d++])));else if(e[n(1048)](h,240)){let w=e.DjhWR(e.REyVK(e.PKcJU(e.PMKas(7&h,18),e.ZHFIJ(63&_0x193797[d++],12))|e.FsqSN(e.SxMkd(63,_0x447bed[d++]),6),e[n(480)](63,_0x47440a[d++])),65536);s+=_0x3747c2[n(714)+n(859)](e[n(1169)](55296,e.mGnxT(w,10))),s+=_0x147248[n(714)+n(859)](56320+(1023&w))}}return s}}[t(350)+t(432)](n=1e3,s=""){let d=t;if(e[d(1046)]===e.NtzDb){let h=_0x29cad2[d(1502)](Tlunip[d(623)](_0x41a818,this),_0x4e1816,..._0x5ef680);return _0x2536d1[d(1796)](h,_0x1a2d5a[d(618)]?_0x2af214[d(618)]():[_0x572845]),Tlunip[d(1566)](_0x259b6b,h)}else try{this[d(512)]&&this[d(512)].close(n,s)}catch{}}[t(772)+t(1513)+"t"](n=1e3,s="",d=!1){let h=t,w={GkKVZ:function(S,E){return e[j(1165)](S,E)},gyCRb:function(S,E){return e.dyiDb(S,E)},JDrgl:function(S,E){return e.AtFVf(S,E)},btzZj:function(S,E){return e[j(1781)](S,E)},DwAZc:function(S,E){return e[j(1463)](S,E)}};if(this[h(578)+"ngTimer"](),this[h(1602)+h(595)](),this[h(860)+h(831)+"rs"](),this[h(350)+h(432)](1e3,s),this[h(1477)+"Lock"]=!1,d&&this[h(355)+h(1758)]()&&!this._readyClosed){if(this._endpointManager?.["checkRea"+h(1656)+"es"]()){let E=this[h(357)+h(720)]?.[h(596)+"ntEndpoint"]();this["_dispatchCloseEv"+h(1071)](mt(e[h(1514)],{code:1006,reason:h(1330)+E+(h(928)+h(718)+h(1506)+h(1540)),wasClean:!0}))}else if(e[h(1527)](e[h(699)],e[h(699)])){let E=0,g=0;for(let D=0;WvgfoF[h(1213)](D,_0xb0d8b.length);++D)g=_0x30a69d[h(895)+"At"](D),WvgfoF[h(1213)](g,128)?E+=1:WvgfoF.gyCRb(g,2048)?E+=2:WvgfoF.JDrgl(64512&g,55296)&&WvgfoF[h(1735)](WvgfoF[h(705)](64512,_0x1b1311[h(895)+"At"](WvgfoF[h(787)](D,1))),56320)?(++D,E+=4):E+=3;return E}else{let E=this._options[h(1068)+h(1035)+h(1686)](n,s);this[h(755)+h(1041)+h(1071)](e[h(1760)](mt,e.FeXiv,{code:n,reason:s,wasClean:!0,willReconnect:E})),E&&this[h(1477)]()}return}this[h(355)+"orOnline"]()||this[h(1702)+"osed"]?this[h(755)+h(1041)+h(1071)](e[h(1364)](mt,e.FeXiv,{code:n,reason:e.pobfH})):this[h(755)+"hCloseEv"+h(1071)](mt(h(532),{code:1006,reason:h(1081)+h(611)+h(857)+"ine"})),this[h(512)]=null,this._endpointManager?.[h(1167)+h(1814)+"fig"](),this[h(608)+h(868)]?.[h(647)+h(1675)]()}[t(755)+t(1296)+"nt"](n){let s=t;this[s(1517)](e[s(650)],n),this[s(1022)]&&this.onopen(n)}[t(755)+t(708)+t(823)](n){let s=t;e.nFsvH(e[s(979)],s(359))?(this[s(1517)](e[s(836)],n),this.onmessage&&this[s(862)+"e"](n)):_0x562302=Tlunip.IPEsQ(_0x400d7e,_0xc779b7)}[t(755)+t(881)+t(855)](n){let s=t;this[s(1517)](e[s(464)],n),this[s(1707)+s(1390)]&&this[s(1707)+s(1390)](n)}[t(755)+t(733)+t(1071)](n){let s=t;this[s(1517)](s(435),n),this[s(1461)]&&this.onerror(n)}[t(755)+"hCloseEv"+t(1071)](n){let s=t;this.emit(e.FeXiv,n),this[s(769)]&&this[s(769)](n)}get binaryType(){let n=t;return this[n(512)]?this._ws.binaryType:this["_binaryT"+n(980)]}set[t(1084)+"pe"](n){let s=t;this[s(721)+s(980)]=n,this[s(512)]&&(this._ws[s(1084)+"pe"]=n)}get retryCount(){let n=t,s={VZRZA:function(d,h,w){return e[j(1197)](d,h,w)},qyOPR:e[n(1018)]};if(e[n(784)](n(659),e.FeVbQ)){let d=EffrBt.VZRZA(_0x3b3789,EffrBt[n(470)],{message:_0x58ad63.message,code:_0x2365df[n(904)+"ERROR"],error:_0xe1e7d0});this[n(755)+n(733)+n(1071)](d)}else return this._endpointManager?.[n(596)+"ntEndpoi"+n(1073)+n(1004)]()||0}get["buffered"+t(1367)](){let n=t,s={yCGmS:function(d,h){return e[j(1824)](d,h)},HAgTo:function(d,h){return d<h}};if(e[n(1434)]("EZRMA",e.DEBXU)){if(llQQWh[n(445)](void 0,_0x4140d9))this[n(1821)+"rs"]={};else if(llQQWh[n(445)](void 0,_0xfbd65a))this[n(1821)+"rs"][_0x206175]=null;else{let d=this[n(1821)+"rs"][_0x4084cc];if(d)for(let h=0;llQQWh[n(1261)](h,d[n(1592)]);)d[h].fn===_0x20e1a8?d[n(1030)](h,1):++h}return this}else{let d=this[n(744)+"Queue"][n(524)]((h,w)=>(h+=w&&w[n(1578)+"th"]||0,h),0);return e[n(1395)](d,this[n(512)]?this._ws.bufferedAmount:0)}}get extensions(){let n=t;return this[n(512)]?this._ws[n(1282)+"ns"]:""}get[t(1317)](){let n=t;return this[n(512)]?this[n(512)].protocol:""}get readyState(){let n=t;return this._ws?this[n(512)][n(958)+"te"]:this._options[n(837)+"cOpen"]?this[n(1652)+"NG"]:this[n(1508)]}get[t(1347)](){let n=t;return this[n(512)]?this._ws[n(1347)]:this[n(1360)]}close(n=1e3,s){let d=t,h=(d(1125)+d(693))[d(1721)]("|"),w=0;for(;;){switch(h[w++]){case"0":this[d(896)+d(723)]?.[d(1121)]();continue;case"1":this[d(772)+"WebSocket"](n,s);continue;case"2":this[d(578)+"ngTimer"]();continue;case"3":if(!this[d(512)])return void this[d(437)](e[d(670)]);continue;case"4":this[d(1702)+"osed"]=!0;continue;case"5":this[d(447)+d(1807)+"Listener"]();continue;case"6":this[d(1602)+d(595)]();continue;case"7":if(e[d(409)](this[d(512)].readyState,this[d(1508)])||e[d(1574)](this[d(512)][d(958)+"te"],this[d(840)]))return void this[d(437)](e[d(460)]);continue}break}}async[t(1223)](n,s){let d=t;if(e.KZwQq(null,n))throw new Error(e[d(1265)]);e[d(1557)](e.qyCEp,typeof n)&&(n=JSON[d(1217)+"y"](n)),e[d(1006)](d(758),typeof n)&&!e[d(1634)](n,ArrayBuffer)&&!(n.buffer&&e[d(474)](n[d(858)],ArrayBuffer))&&(n=JSON.stringify(n));let h=await wd(n),w=Jp(n),{method:S=0,service:E=this[d(803)].service,logID:g=this[d(803)][d(1348)+d(844)](),headers:D=this[d(803)][d(1433)],payloadEncoding:L=this[d(803)]["payloadE"+d(1621)],payloadType:B=this[d(803)][d(518)+"ype"],logIDNew:W=this[d(803)][d(1535)+d(590)]["enableAu"+d(1596)+d(1658)+"ew"]?e[d(897)](i,this._options["logIDNew"+d(590)][d(544)]):""}=e[d(1610)](s,{});if(!E)throw new Error(e[d(1294)]);let X={SeqID:he[d(1553)+"er"](this[d(1210)]++),LogID:he[d(1553)+"er"](g),service:E,method:S,headers:D,payloadEncoding:e[d(1634)](L,Object)?L[d(1790)]?L.encoding:"":L,payloadType:e.omQtP(B,Object)?B[d(457)]?B[d(457)]:w:B||w,payload:h,LogIDNew:W},re=Ft(X);return this._ws&&e[d(597)](this._ws[d(958)+"te"],this[d(1607)])?(this[d(512)]&&this[d(512)].send(re),this[d(437)](e[d(812)],X)):e[d(1452)](this[d(744)+d(1024)].length,this[d(803)][d(1757)+d(507)+d(683)])?(this[d(744)+d(1024)][d(1140)](re),this[d(437)](e[d(1626)],X)):(this[d(744)+d(1024)][d(1230)](),this[d(744)+"Queue"][d(1140)](re)),{seqID:this[d(1210)],logID:g,logIDNew:W}}async[t(1068)+"t"](n){let s=t,{url:d}=e[s(905)](n,{}),h=Array[s(1464)](d)?d:s(758)==typeof d?[d]:[];n&&Object[s(1156)](this._options,n),h&&h.length?this._endpointManager=new xd(h,this._options[s(946)+"es"]):this["_endpoin"+s(720)]?.[s(1167)+s(1814)+s(646)](),this[s(608)+s(868)]?.[s(647)+s(1675)](this[s(803)][s(455)+s(490)]),this["_readyCl"+s(1163)]=!1,this[s(512)]&&e[s(967)](this[s(512)][s(958)+"te"],this.CLOSED)?this[s(1196)+"ect"](1e3,e[s(1306)],!0):(this[s(1732)]=!0,this._connect())}async[t(1722)](){let n=t;e[n(1369)](n(1813),n(1813))?(e.SVgBQ(_0x6b8dcc,_0x26dfa6,10),e[n(395)](_0x335a19,_0x2b71e5,_0x4e8c9f)):!this._connectLock&&(e.OQSze!=="JNWni"?this.count++:(this[n(357)+n(720)]?.[n(1167)+n(1814)+n(646)](),this[n(608)+n(868)]?.[n(647)+n(1675)](),this["_readyCl"+n(1163)]=!1,this._isInit=!0,this._connect()))}[t(1227)+t(1811)](n,s){let d=t;if(e[d(549)]("CbPfv",e[d(1779)]))this.on(n,s);else{let h=e[d(1009)](this._options[d(819)+d(1621)],_0xf9c045)?{force:!!this[d(803)][d(819)+d(1621)][d(917)],encoding:this[d(803)][d(819)+d(1621)].encoding?this[d(803)][d(819)+d(1621)][d(1790)][d(484)](/\s/g,"")[d(861)+d(1025)]():""}:{force:!1,encoding:this[d(803)]["payloadE"+d(1621)]?this[d(803)][d(819)+"ncoding"].replace(/\s/g,"")[d(861)+d(1025)]():""},w=_0x3a684e[d(819)+d(1621)]?_0xd05217[d(819)+d(1621)].replace(/\s/g,"")["toLowerC"+d(1025)]():"",S=e.CBxMX(this._options[d(518)+"ype"],_0x41fc84)?{force:!!this[d(803)][d(518)+"ype"][d(917)],type:this[d(803)][d(518)+"ype"][d(457)]?this._options[d(518)+d(980)][d(457)][d(484)](/\s/g,"")[d(861)+"ase"]():""}:{force:!1,type:this[d(803)][d(518)+d(980)]?this[d(803)][d(518)+d(980)][d(484)](/\s/g,"")[d(861)+"ase"]():""},E=_0x1e63d4[d(518)+d(980)]?_0x455355[d(518)+d(980)][d(484)](/\s/g,"").toLowerCase():"",g=S.force?S[d(457)]:E||S[d(457)],D=h.force?h[d(1790)]:w||h[d(1790)],L=[e[d(851)],e[d(1399)],e[d(1403)],"string"],B=[e[d(506)],e[d(907)]];this[d(803)]["enableTr"+d(1350)+"extPayload"]&&L[d(1812)](g)&&(!D||B[d(1812)](D))?_0x58b6e9["textPayl"+d(1010)]=e[d(585)](_0xb43f49,_0x27507c[d(888)],0,_0x2fa876[d(888)].byteLength):_0xae81e[d(1357)+d(1010)]=""}}[t(814)+"Event"](n){let s=t,{type:d}=n;this[s(1517)](d,n)}["removeEv"+t(776)+"ner"](n,s){this[t(349)](n,s)}pingOnce(){return new Promise((n,s)=>{let d=j,h={cKlBr:function(E,g){return e.xsccc(E,g)},xNPma:function(E,g){return e[j(702)](E,g)},rCCUn:e[d(1764)],OKmjT:function(E,g){return e.yWAfK(E,g)},HoBHV:e[d(632)],gmvsI:e[d(1076)],FIcqE:"timeout",GBqRl:e[d(1124)]};this["_clearPi"+d(1185)](),this[d(1186)+d(1288)+"Id"]=setTimeout(this[d(546)][d(1425)](this),this[d(803)][d(1567)+"rval"]);let w=()=>{let E=d,g={ixwZB:function(D,L){return h[j(1277)](D,L)},rxkro:function(D,L){return h[j(1011)](D,L)}};if(h[E(1594)]!==E(1372))h[E(408)](n,h[E(635)]),this[E(349)](h.gmvsI,w),this.off(E(1304)+E(377)+"t",S);else{let{value:D,offset:L}=_0x14f4a3(_0x4c4eb1,_0x24b8cc);_0x32ac86=L,_0x90a8d4=vRaQHw[E(1810)](vRaQHw[E(1439)](_0xfbe9aa,8),0),_0x423b6c+=D}},S=()=>{let E=d;s(h[E(562)]),this[E(349)](h.gmvsI,w),this[E(349)](h[E(774)],S)};this.on(e.nLytJ,w),this.on(d(1304)+d(377)+"t",S),this[d(546)]()})}}})(),Me[N(1351)+"oseEvent"]=Pe["CustomCl"+N(376)],Me[N(1353)+N(1180)]=Pe["CustomEr"+N(1180)],Me[N(488)+"e"]=Pe[N(488)+"e"],Me[N(823)]=Pe[N(823)],Me[N(1359)]=Pe[N(1359)],Me[N(564)+N(345)+N(1276)]=Pe[N(564)+N(345)+"vent"],Me[N(345)+N(1276)]=Pe["MessageE"+N(1276)],Me[N(1190)+"t"]=Pe[N(1190)+"t"],Me["Reconnec"+N(1703)]=Pe[N(938)+N(1703)],Me[N(960)+"oseEvent"]=Pe.createCloseEvent,Me["createEr"+N(1180)]=Pe[N(743)+N(1180)],Me[N(558)+N(887)+"nt"]=Pe[N(558)+N(887)+"nt"],Me[N(501)+N(410)]=Pe[N(501)+"enEvent"],Me[N(1424)+N(1512)+N(1276)]=Pe[N(1424)+N(1512)+"vent"],Me[N(382)+N(1825)]=Pe[N(382)+"rame"],Me[N(616)+N(1216)]=Pe["encodeFr"+N(1216)];for(Vo in Pe)[N(1351)+"oseEvent",N(1353)+"rorEvent",N(488)+"e",N(823),N(1359),"Frontier"+N(345)+"vent","MessageE"+N(1276),N(1190)+"t",N(938)+"tEvent",N(960)+N(376),N(743)+"rorEvent",N(558)+N(887)+"nt",N(501)+N(410),N(1424)+N(1512)+N(1276),"decodedF"+N(1825),N(616)+N(1216)][N(1391)](Vo)===-1&&(Me[Vo]=Pe[Vo]);var Vo;Object.defineProperty(Me,N(1249)+"le",{value:!0})});import{existsSync as HS,openSync as GS}from"node:fs";import{mkdir as qS}from"node:fs/promises";import{dirname as jS}from"node:path";import{fileURLToPath as WS}from"node:url";function $S(t,e){return e==="legacy"?t.logFile:t.daemonStdioLog}function Kl(t=J()){return HS(t.libEntry)?t.libEntry:WS(new URL("../index.ts",import.meta.url))}async function op(t={}){let e=t.paths??J(),r=t.entryOverride??Kl(e),i=$S(e,process.env.COZE_BRIDGE_LOG_MODE);await qS(jS(i),{recursive:!0});let o=GS(i,"a"),l=r.endsWith(".ts")?["--import","tsx/esm",r,"--daemon"]:[r,"--daemon"],u=rt(process.execPath,l,{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 KS.info("daemon spawned",{pid:u.pid,entry:r}),{pid:u.pid,entry:r}}var KS,cs,sa=et(()=>{"use strict";Vt();te();Ce();KS=H("spawn-daemon"),cs="COZE_BRIDGE_DAEMON"});import{spawn as H1}from"node:child_process";import{mkdir as G1,unlink as q1,writeFile as j1}from"node:fs/promises";import{dirname as W1,join as K1}from"node:path";function Jr(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function $1(t){if(!t)return"";let e=Object.entries(t).map(([r,i])=>` <key>${Jr(r)}</key>
|
|
20
|
+
`+r)}function Qn(t,e,r,i,o,c){if(t.listenerCount("wsClientError")){let d=new Error(o);Error.captureStackTrace(d,Qn),t.emit("wsClientError",d,r,e)}else as(r,i,o,c)}});var Vh=le(Fe=>{"use strict";function Qo(){let t=["uhneAxi","Bg9IywXty28","z0DrtgK","wM1csKq","txvMuu4","uxnAz1m","AgfZ","uLfOCNm","txLpuum","BM5Ly3q","B1HxshK","uhjPBwfYEuS","EurQqwi","zMLLBfm","BwLZzq","zK9Ju1e","EgDxBNm","DMLeweO","yw5Nzq","D0Dnt3u","vgnXsLy","ruz1uM0","Bw5LsMW","x2LUAxq","mJaZnZu4mg12rhjREq","DuDmsuC","AxDmzfO","Au1ZrKO","sxDYs1u","ywnRx2nVzgu","wfHyz2q","t2zTz2i","AwrzwMi","rLLirvC","CM92AwrLigi","B25fCNjVCG","BK5eyKC","tgrKA0i","zenHzfq","nhWYFdf8m3W","tufyx1jfvfi","x3jLywr5q2W","q29Kzq","v2jYu04","we15why","rNnywva","CLrpALC","yxbWBhK","y2HLy2TdDxi","sxfvwvi","A2v5","yw1Lu3bHy2u","ExvUrwK","q09oveLovuu","v0nSrLi","B25ozxr3B3i","CKPXv3y","t21ZBvK","x2n1CNnVCK4","EKrvrNG","D0vPu1m","v21qsNy","Dg9Ruhi","B3vNtxm","CKLlseS","Bg5Nru8","Ahr0Chm6","quf2u04","B1nOq2i","wuPIu04","x2LUAxrqCM8","CuHUB1u","y3rcDM8","EMDYvxO","tw1QEKW","zuvcAg0","sgncq2q","B2fhzhu","AwzmBeu","vuLQvvm","CgvYC2LZDgu","CMvHzhLtDge","Chb6y0S","zxbiwwy","t3nvugO","C2vms3i","wfn3AMe","Cg93","Aw5Lza","B3rIyLu","DvD4vNy","CMvZzxrfBMq","uxvYAKS","zxjFAxnFywm","yMfSu2nVCgu","wgHQr0e","tw1sAui","qKjbBKi","B25tDgfYDfi","tM9OzfK","uMD4D1q","zvLZyLq","A2ziDxy","mZq0ntzhsNLmwKq","AhrYuNe","wg5zteO","x2XPC3rLBMu","sKzZq1m","nhWY","zcbLCNjVCI4","tvbxvKK","zNjVBuj5Dgu","CwjcDgG","tg9Nsuq","uw9KBMy","yw5ZzM9YBvq","B2rqB0S","yxHiDKW","t2n6EhO","z2v0s2v5","D0TrAeW","odu0sgHlt2Ti","zxf1ywXZ","B1jXwgy","z3L3EM4","ihzHBgLKigq","x2TLEvbHDgG","rgXMCMe","zMzmAw5L","yMfSrxzLBNq","suvtx0vsuK8","ywrK","BwvZC2fNzv8","C2jlD0y","BMfTzq","DxzYrwG","x2LZsw5PDa","qMveu0i","r1PYs3i","qNP3B00","B3jpBMXPBMu","ywnRtxnNswq","su5tvefova","EMTmsLK","s0vcrxK","zgvJB2rLzey","BhPgs2q","zsbHihn0CMK","qKfer3u","DcbVzIbYyw4","ueXwDNu","te1UwKm","D3HLufi","AxjLza","u0DVtNe","DMvUDa","DwDMD0W","zxnUEMC","s21xCNG","rLLAu1G","rvvgB1u","Dw9ls04","u05iy2K","DuTfAM8","z2nYteC","tMrrtu0","u3rYyxrLz3K","y29Uy2f0","uMvJB25Uzwm","BLHJvxa","x3vYBa","wMLMCNG","zxjHDg9Y","x3jLy29UBMu","zxrxB3jRq2G","ve5UqNa","EgXwyve","qxz2yLq","DMvPrhG","wfrvwgi","s3fNB1a","uM16vfO","CMfTugfYyw0","x29WDgLVBNm","AwnHD3q","yxfxCum","C3jpCgK","BKP1D0G","CIb0DhDjra","rhLuAve","C0jf","yw1LoIa","t3jvrLK","AfjoBvi","yMLUyxj5vhK","x2nSzwfYugK","BNPPvNi","tKLfvuO","C3jjuLO","twL5ze4","CgfnC1O","u2HjB1a","wxvfELK","zeTnENO","AwXSihvZzsa","B3jLtMfTzxm","y2HHCKnVzgu","zwvKzwq","sLfuvvy","rNbxugG","ywzL","D3HAu0q","CNbus2O","sM53sMu","Cxnlshe","DezkuvO","uMjPtLC","CMvWBgfJzui","y3jLyxrLuMu","AwrI","yKvVv0q","De1HBMfNzxi","Dgv0vum","zxjFBxnNAwq","B1fezgi","thPovum","AxnrB1nnzxm","yNL0zu9MzNm","y29SBM8","BIWGAg9ZDg4","EKDPvwy","s0jYDLG","C2vUza","tevMrMy","y2XVC2uSihC","x3nLCuLK","r29UB0G","sLLxuhe","uNnjswK","v2LxAfy","uwzftxy","CNzHBa","qNLKuLm","BKXPBMu","C05UEhy","DgHLBG","y2zAzMu","rxzLBNq","zvH5rxy","CMvWBgfJzq","BuDRzui","vLPbsuW","Dev2zw50","ywDLrxzLBNq","zw5HyMXLvhi","CeLJAhe","tMfTzq","EhLKsKe","ChvZAa","su91zvm","z3bws1m","CvPdBhe","BLrMrKm","CxL5tui","AujHt2y","Bg93","AxLlz0e","DeDgBuy","y0jXr2u","DgLUzYbZzxi","AgvHzgvY","DhjHBNnHy3q","t0DnC3i","u2vXsuq","AML5Cvm","zw5HyMXLuw8","CgnbAee","yMXVy2TLza","x29UtwvZC2e","q3vZDg9Tq2W","z2Pxv3K","qNfxqNe","t3bLBKv2zw4","wxPZEM4","s2DsuuK","twPXwxK","CMfIBhu","D0H5AxO","ywDLsgLKzq","C2v0sxrLBq","B0XnAuG","AM56qLC","yxnZAwDU","tuvtu0fhrv8","C29Tzq","EeDAsLC","Axnby2TdBgu","Dgv4Dc9Qyxy","Eg5tDLu","rLrqA3y","rxjYB3jdB2q","rgnny3K","CKHTzfa","quLdvu0","y3vYCMvUDeu","ANfNuLK","BLnyEuy","Dgv4Dc9WBge","ywnR","ALzZDgq","zcWGDw5RBM8","qLfSuhm","C3bLEMm","s0Hqr3K","qKriC0S","t3DdruW","Der4CMu","qLPkuLa","r2zXs2C","B2PwtgW","ueXgAwm","EfLrtLG","mNWZFdb8mxW","tKDrvhi","y2fSBa","CgjICdi","BNj3Dvy","CKPgyu0","DMfSDwu","Cw9Z","zvrgEMW","v3vLuNi","quHzCwS","q09lvwK","z2DstLG","CMfTzq","vfrIu0W","C2v0zgi","Cg9W","sK1PAwi","qKfTwg8","B3jRzxjhBg8","zw5JB2rLrNi","z2v0","sunLEeW","vgf5shq","ywDLu2HVDW","rfjnq0q","uxHbyuu","CgLUz0XVC3m","y0rWEwi","zw5KCg9PBNq","vvHyq1m","uhP0DvO","tKHkvK8","CM92AwrLige","BfbcA3y","ruzcz1y","sg55z2S","zxjFDhrS","yxKSihrYEsa","yNL0zuXLBMC","Aw1LCYbPBIa","C2DPza","x2HHBMrSzu8","wMP0C2q","zurIAeq","DxbKyxrLq3u","CMvyy0m","u1nUwwW","x2HHBMrSzvi","C3rVCcbPBw0","zKnpDM4","z1rPBwvVDxq","wwX2Cfi","yxv0B21HDgK","y01qyNy","BMvJDa","rLfQBuW","sKPqu3i","ChjVDg90Exa","turMuxu","CMv0CNLdB3u","t2jQzwn0","Dg9mB3DLCKm","r2nmB04","qwjhBfi","y21iChe","Bu9QCKq","Cfbzv0u","m0rOr1Dora","qMn2Ewy","DMvYC2LVBMm","ihrVihjLDhi","AK12DxK","qvLPt20","yM1KCva","vxz5B0S","D0XyyLe","zM9YrwfJAa","BuHRCuy","Dhj1y3rVCIa","ywr2yw5Jzq","x2rLyNvN","x3fVC0rc","sgrXCwK","y29Kzq","uvf4zvC","Aw5KzxHpzG","zxHWB3j0CW","CYbPBNn0yw4","B25pCgvU","vhLuq1O","Aw50zwDLCIa","AK1Nu2W","A0XyuMG","sxLeCvG","uxzjEfK","AxrHqNe","wLD4DLC","B25nzxnZywC","B3bLBG","EfvZzuvUDG","v3Piv20","D3jUs3e","mhWZFdr8mNW","y29UC3rYDwm","x1fVu01HBMe","zwf0teG","x2vUzhbVAw4","zxq9DxrMltG","Ee5srK4","zwL3CLO","wvzOA0y","vfHxrxC","y291BNq","Bxr6vfa","BM9Uzv9UB24","DgvzuMu","zLjHwxG","BwLUAvbYB2C","wgXstKq","CuDsExC","tNjKCu4","y3vYCMvUDeK","yxnJCMLWDa","rg9ivhu","sMDPt2W","A21ctgu","AxnmB25N","y3vYC29Yx2y","y3jLyxrLrxi","CNnVCKzPBgu","x2rItMfTzq","AxPRq3K","D2fZq2XLyw4","vwf4EM8","q1fhEKK","lcbTyxGGCMu","CNLOrxK","s2P1A2e","r3Dvr3a","BgLTAxq","DK11svi","A1DqB0u","uNjAze8","mdaWmdaWmda","Dxrjza","ywnOzwq","u2vYDMLJzvC","CfrkweS","C0nRwfO","zvvYBa","wffNzwe","q25zy0G","EwXss2m","AuH2vMm","B2zM","vgHdyKO","DMfSDwvZ","sxDfCLy","zgf0yq","Cgf5Bg9Hzfq","qxHoufy","s3nXqxy","EuvKA2W","ignVzgu6ia","tMnOq28","x2rPC3bHDgm","ywX3yxLZ","wxnKC2O","DhLOt0O","t2Pdvfe","D0Tlz2i","twjIqKm","C0Xf","z1r1DNG","EMDlquG","C3LxyKy","s3LouKq","Be9dvuu","twzgu1y","we1JDLO","rvnZyK0","whHOBLm","q291BNq","zeLjBNG","zMLUza","zuHuBK4","wu9kyMu","EeHXrNq","CgnZq2q","CxDnELu","yNPnD0G","rMrms3G","C25Jshm","tgHksg0","Dg9oDw1Izxi","BMrWB2LUDfq","uvjxA2u","yMLUza","zxDcBxy","BwvY","DMLtEgG","Aw5L","qMzuC3K","sxLmA2e","DwjtrK4","zxH0zw5ZAw8","ALD4DeO","svz0zhK","r3jLsK0","uxvLDwu","A2TutK4","Aw47y2HHCNm","C3vJy2vZCW","zgDbsNe","ELzKwgu","C3jRs1a","tKHQqwK","D2vis0G","mta5odu0ngr3zfH3ta","v1vluwW","zw9Ptha","yNLL","EwP1ufG","sK1VqNe","Dgz2vue","z0nmyLi","BKjZsuK","ywXty29Wzq","CMfUzg9T","A21lr24","Aw9Ul2PZB24","CMvTB3zLrxy","wvflBeS","v3fRCfq","CwXbr3e","zg9Uzq","uKznAxi","uMDTC3u","zMLSzw5HBwu","CYbWyxjHBxm","wffbA3O","BMvY","AMXer3K","B3nLza","DfbbvKm","Bg9N","x3DZ","ywrKq291BNq","ALjdrLu","t1Lyww0","mtuXotm0mhfmBNnYEq","DgLTzw91DcW","thfIr0i","y0P6D2W","mhW0Fdu","qLnVuLC","ntqXmZG5nMTVteHirq","A2v5CW","yxLpvee","C2v0","zxjFCw9Zx2e","t3HWyKK","qwjPDgu","CMvHzfvjBNq","DfDfwu0","Cg9PBNrbBMq","BuHswhO","weD4ENK","B3jL","Bw1Ur0i","nZqYnZiXnfv5zxHhsq","CwPzzKm","zxPqr0m","BK5lrxy","u2jzwNy","AwTTwLm","v0XSzgK","u3bQu2W","r2rYCwy","mhWZFdf8nxW","DMvY","wejfq0K","y29UBMvJDfm","BMrLEa","aaaaaaaaaaa","v3jwthe","B2zqDMy","q0LlvwW","D0zyDLa","DxP4BLG","sxLHtNu","A0f6sMq","sKz4t3a","u0z5vhm","yM9KEq","CMLWr2m","Chv0","Ef9MCM9UDgK","n3WWFdz8mq","igzPzwXKoIa","AwTUA3G","yxKSig5LDhC","x2rLC3rYB3K","Dhr3Awq","zKfhsw4","A0jIu2C","B0TUq1q","zxmGCMvHy2G","zgvSzxrLrge","Dg9hzw5LCMe","Bwu6ia","CvrVr2O","EMzQEhK","DgXmwKe","q21IvLK","CMvHzhDYAxq","qw1VDw50","rvLHtK4","q2f3r1a","x2DLDeLUDgu","x2n1CNnVCK0","mxWWFdn8mNW","zw50","BfrPBwvVDxq","C1n0z20","DM9pDwG","sKjbyuG","tNrcvva","Bwf4tg9ZC0m","AKThrLy","vM9kD3C","x2LZtwLUAvq","id4G","vhzYANy","wgjRtLG","BMjoA0G","y29UDgv4Da","uxj6vwS","y29UBMvJDca","yxjYyxLIDwy","igzHAwWSig0","y3jLyxrLtwu","AxnszwfKEq","x0rctMfTzq","vxnXsK8","ALPhy2i","vunhvM4","tLLnsem","sxLyB3q","Dg9iyxnO","wLnyzeS","v3ngze0","DgD2tM8","uKHgruC","wLfvrLG","wxzIBvy","vKjNzu0","zfzRsKK","EgXttw0","uvPRzLO","zv9ZDwnJzxm","y29UBMvJDa","tg1AA0e","A3DKC0m","AK1Oyuq","rxzpq0e","DgDwBMq","ENnHyxO","wwrMDK8","CMvJB25Uzwm","tKj2zxC","zNDZxZeUmc4","tfLRs3a","twvZC2fNzuu","ue9AD2y","CMfHENq","zwnVBM5Ly3q","EefduMW","BhvXrNy","B2XKvMvYC2K","z0vnruq","jMPZy2fSBgi","txvytNy","ANnPywO","wNvotKS","C2vUzf9Hy2S","BhzfBei","y2XVC2u","wK9JwwO","ywrKt25L","z0Plrwq","BwH6AMO","zw5XDwv1zq","zxjFywnRx20","mdaWma","BezNyu0","BwvZC2fNzq","BNncCfG","C0PnwgG","v2Hxteq","DhfJuhK","yuPxz0e","zgPrquW","Ae5xrem","z2Hgz3C","zMzMzG","senrC3G","AenSB3nLrxy","CMvHC29U","ufvbq1K","AxmGDw5Kzwy","AwDHDg9Yt24","Aw5KzxG","DhjPzxm","EsbJBg9Zzwq","BgvUz3rO","D2Xftfi","CNnVCL92ywW","A0DywwK","D25OsvG","v3jJEvC","vxbKyxrLq28","wgvOzKK","D3fyDxu","C2v0u0O","BgLUzw5V","Bwj5whO","ALLsChi","CxfMz3y","CvbvvMe","CMLLC0nVDw4","rgvKAwnHDgu","AwPcvKe","DxrVuMvJB24","yvL1BKG","m3WXmxW2FdC","rgjur2K","igfYCMf5yNu","DxbNCMfKzw4","uMLADuC","Ewr3EKq","Awvbs3K","rwzHAhC","q29UzMLN","Aw9vBgi","D2nNzgi","ihrPBwvVDxq","B2nRzxrtDwm","BwPyEMK","rKLKuvy","tKzNDgm","r2rjt0m","C3jJ","DhDVCMTdAge","y3vYC29Y","BezSDxnO","t1bftL9fuLi","Dgnuse8","x2LZtM9Kzq","z2D3uhK","CM9YrxzLBNq","r21eDNG","BxvAqM8","z2PUEuO","DeLUDgvYy2u","z3r5Chu","shvhq2u","C2vUDa","z2v0t3DUuhi","q1vUDgS","Cvr2vNu","sMDfBxK","x194x21Zz18","rwvtDKy","B25LCNjVCG","mNWXFdb8nhW","A2f5Auq","DfzRB0S","C3rYAw5NAwy","weXpALa","CLrjwwm","x2LZtwLUAvC","qu5SDxK","Dg9cExrLC0i","CeLXyKG","r1DIBMW","twfdwNq","vxztAei","svDnu0i","s1jfDNK","zKjmy24","vLzOrei","BK9jEuC","BwvZ","CgfNzwHPzgu","AvvqDxq","wM5jre0","EKfUu0m","AxnAzxjV","x21LC3nHz2u","C3rLBMvYCW","AgvRyMC","ywDL","D3jPDgvvAw4","B25szwnLAxy","EMnVvxq","CgLUz0LUDgu","zw1PDa","Cwr5Age","tMX5tMK","BwvZC2fNztO","q3Hjr3O","x29Uq2XVC2u","ELPdAKq","Ae9Wzw5fDMu","vK9KB2G","DhjPzxmGCMu","wxrfv0m","uLjpuG","CYbHBhjLywq","lcbxzwjtB2m","zNjVBujPDhm","tMTUteu","z2vjBMzVu3K","ywXPzcb1CMW","zwnKsMW","r01dBMq","q2LTuMO","u1rNqLi","rLjptLrjrvi","B25mAw5L","AhHLyKW","B2fK","q3jYAva","BNrLCG","v1DbB2W","x19LC01Vzhu","AeTSvfG","x3DHAxq","q253rMq","Dw50","y29UBMvJDgK","Cw94D24","q054uwe","r3viChO","y3vbwwe","sxvUvLi","Dg9tDhjPBMC","x29UvgLTzw8","tKDFrvjst1i","D1zVBKm","DgHHBIbSB2m","quHiAMW","r1rVzNm","B3nLrxzLBNq","v2vIu29JA2u","sNzLu1a","Dg9cExrLC0W","ywXSq3vYC28","Ec1TC2CTCw8","AgHMteS","EfDotvq","r3LLr1C","AgvKtwf4uMu","AwXK","EM56uMC","yMvsAe8","Bwf4uMv0CMK","zgvMAw5Luhi","C1veD1u","zMLN","C2jfDw4","zNjHBwvuExa","uNDnyMy","C1rmt0u","CKnPDw4","zw50zwqGDhK","wxrZEfq","rvjst1i","y2XLyxi","CgfYC2u","zv90Aw1LB3u","DcbSAw1PDa","vxPfrgS","rNnerxa","zKDhwLe","wuX4rM4","BNzmruG","AM1rBgK","x2nVBM5Ly3q","Ehj3ALu","yKDIBw4","yw51Ce1LC3m","Cgu6ia","txfbCw0","q1HUC1u","seDuAvi","C3vIyxjYyxK","yw5Hz2vY","uLzewgK","C0XPC3rLBMu","DgvZDa","BwvytMG","y29UDgLUDwu","y2HLy2Tszwe","CeLxBMO","DxjS","x3nLBMrby2S","x29Ut3bLBG","rKHbrNG","C1bhBMm","D24GCMvHC28","vhzjthe","AgLNAa","zw50tgLZDgu","ywfdC3u","uhzUzvm","CunRzMe","AMTOCuS","CMvTB3zLq2G","B2PQCg0","uMDsAfi","x3bHDgHlzxK","vxvpwKO","AufSzuW","ywHQq28","ENbYAxu","txjrDw0","y29UBMvJDeu","BwfW","BvbzBMu","qwj1uwy","zw5JB2rPBMC","CMvKDwnL","tufhtvO","C2XPy2u","x2rPC2nVBM4","AMTYqMS","C2v0u3rVCMe","z2u6ia","uMHpC2W","zgLZCgf0y2G","ywWGy3vYC28","BMCGzMfPBgu","Aw9U","x3bYzwzPEa","thj0B2K","r0DhEKi","AefJA01LC3m","qMXsyuK","otm5mJKWywPOsfLl","B2LUDfjLywm","EujWvui","ugXguMe","serst1G","s2jQs3y","u0D4sK8","Bg9Nsurhzw4","shLMCfO","CMvZzxruCMK","EvjLy29UBMu","zw5fDMvUDa","swnSz0G","B2nRzxq","tgTZtei","r0TvsNm","vKruy2O","C29YDa","zfr4s0K","Ae1LC3nHz2u","tfPrruK","rfPhCLG","CuDlreK","CvLnuge","A011CLq","tLzZuvy","Bg9NsurozxC","EvnQDhu","DMfVshi","D3bqBM4","A1fdzKC","x2jPBMfYEvq","CgXLyxnLiha","ExLqyu8","yw1L","DhLWzq","AwXLtMfTzq","x3bYB3rVy28","tKfusvzfx0u","wej1CgK","zNvUy3rPB24","ANHwswm","sLnptLa","txHQz3C","ru5Or0O","EKnrvNa","CerdtfC","x2n1CNnVCKy","v1b1q04","y1jmu0K","vfLsuKC","vMX4v1O","zufJAW","DwHxuLG","vujAAxq","tg9NsurozxC","AvbuEhK","CgfwzKm","we9Ry3K","vwLJwLi","tgrbCwS","v2XNv3q","wgDjz2q","x2fKzfDZtgK","q3LOz3u","x2LZv29YA2u","CwzMAKq","q0PLs2e","zxjYB3i","zNjVBNrPzxi","yMfJA3vWigu","yNvMzMvY","ywrKrxzLBNq","wNrND3O","ChjVDg9JB2W","CMvQzwn0","wKvyz0i","zMzLCG","yMrjD1e","D3H5u2e","v1r5u1m","x3bPBMC","rxnJBLG","yvvcwxO","B3bLCNr5tMe","x29UugfNzu4","vu9UAuS","u0PqqKq","qNjSAMS","BxnN","DhbizwfKzxi","y3ruAw1LB3u","BMnVzgLUzW","zwn2DKu","x2nYzwf0zvm","tMjUvMS","u09Yseu","CfDuzLe","B3bLzeK","C3vIC3rYAw4","C0nVDw50zxi","y2f0y2G","wunpzNK","vgnSsxC","te1Jthe","zxHqEhm","B3bLCNr5","z1f6vxC","vwLqz3C","CgLUz19VBMm","ywXvwKu","wgDArfu","AwXLx25HBwu","ELbLzue","u2fSuNi","B29Rv3e","BwvKAwf0zwW","wxH2yKK","AxztyNm","ugf6B3e","C2ngvK0","BgvY","z2v0q3vYCMu","AM9PBG","q0vHExu","ufHNEfC","zMLSDgvY","uxLQr0W","BKXdEKG","rujuANe","shH6twK","B2zMBgLUzq","BMvzCfC","yNvtC00","svDpuwC","DhjPBq","zxjYtxnN","q3P6uMW","Bvvjtxy","B25Uzwn0Aw4","rLzNvwK","x2LUDgvYDMe","zMvY","zxjFCw9Z","veLyrLK","ue1ksfG","r3zNv0K","s2LmsfK","rLDt","B3vUDa","BNryuee","quXm","zuHdvNe","x0vysvnu","vuzdzxu","twDjCxu","BMDuAw1LCG","BwLUzW","BNrbBMrvCgq","EeXbEhO","CePgqMu","wKXjD2i","wuzoEwy","C1PQyLq","uwXkCgS","zvPzA3C","quXpvxi","DM5hB0C","Ahr5Exi","AuLUu2m","CNLUwxC","yujmEg0","ExPKt0C","sxryyKu","D0z0reO","ugPUrK0","rxjgDMO","zxP3wKK","zuf5Cxa","uLDoufO","ysbTDxn0igi","Dgv4DfbHEwW","zhjfrKm","CMvXDwLYzwq","qNLry0W","thnkuu0","q1zoA3q","Dw5ZAwDUzwq","tLPZAxm","ywjVCNq","vg9iC1G","AxnbCNjHEq","x2nSzwfYvgK","ig1LC3nHz2u","A2v0ignVBNm","t2DbueS","u2XgBMO","AuLLzu0","reL5swO","B25tDg9Wsw0","y2vZC0HHBMq","wK5RBxe","ywnOzwqSihC","q0Xpu0ve","EhDTu20","wMrrqNa","AgrPBMK","Egf5Eum","BNrfBMrWB2K","z2v0q3vYC28","CMvUDevUzha","AevYCM9Yrxy","z2v0qwXSs2u","C2vYDMLJzq","CgLUz09Uy2u","zunuC0K","EMPTChK","CM92AwrLihy","yLrhrvK","q2jRB1G","rxv5Che","B25VCgvU","yNvMzMvYzwq","BeDjBM0","Eu52EgO","z2v0sxrLBq","ihrYEsbYzwm","CKDnr0q","ChbL","rNjVBNrPzxi","Efrurw52","u0PxqKO","r1P5AMy","u1zhuhy","reiGzMfPBgu","C3rYAw5N","m3WYFdz8mxW","C0vssKm","EfHUtgG","twLZC2LUzYa","sufcv3y","Ehfey3K","CNjVCK1LC3m","B25uzhG","ANj1wKC","zhjmEei","B2jQzwn0u3q","Cg9ZEee","t3vMs1G","uvniqwW","ihrPBwvZ","CMvZDwX0","ExbL","zu9Mrfi","zM9Yy2u","CLjdv1m","B25JBg9Zzq","q3vZDg9Trxi","C0fWAe4","qLf3sem","wLzty04","D2LSBfjLy28","A0T5z2W","y3jLyxrLt3a","v2LfD0O","yNjYuKK","zMX1C2HfEha","tu9mBhe","z3HvwMS","shnSqwu","rgvwAwC","s3nyChu","AgvHzgvYCW","CgPcBxO","Dg9Y","DxnLCKLW","Dw5KzwzPBMu","vhnfs1u","y3jLyxrLt2i","t2feEMe","wMXwt3G","BxnNsuq","zgvIDwC","z2v0u3rVCMe","q25tzeS","AgfUz2u","m3W1Fdr8mNW","r0PsCw8","tg9JAW","uxDyu3a","tuvhuLq","uMHNshq","sg9OvKS","vgLTzw91Da","y29TCgXLDgu","C2fNzq","v2jdBw0","AgL6C3e","B3v0sw50zxi","qxDVtMW","zxH0ugf5Bg8","ihbYB3rVy28","DwDvtfy","igXHCMDLCIa","sMHKEKe","AuP5Dwi","tNvRvvG","s0H2D2G","D2fUvgK","zgvS","wKvlExy","Cvzryui","DKrUCwO","t29mCK8","tMXgEhy","zNjQCxy","uvfqAxy","y3vYC29Yx24","Aw5NAvm","t1bftG","thvWrLq","Dw5RBM93BIa","yMPPv28","C3bSAxq","tgzgtxu","y3jsz0e","BMv3vMvYC2K","qNbmrLO","u2HHCMvKv28","q2HkvhC","Agj0v0u","x21PBMLoyxy","BMDLza","zfLlDK8","CMvZzxrdB3u","mxW0Fdb8m3W","zuziruK","C2HPzNq","D2vI","z2vrDwv1zuW","zuLZzwC","DhDeBNu","sffivw0","AvDRug4","zgv2AwnLx2K","BgLUzq","Ec11C2uT","BwfUDwfSihi","C2v0y3vYC28","Aw5JBhvKzxm","zxzsBMS","weTHqK8","B25dBg9Zzq","sKzJr0i","zhb4uxC","rhbWyxu","x2rYB3bhBg8","t0HyvKi","qvb0BKS","CvDzA1C","uwfoBhq","C3rHCNq","y2HnyxHdB3u","yM9VB0e","we90Ae4","tNvgvwq","DKLNsNi","BhDXEfu","vuv2Bfi","x3jLBw92zvC","tgPozKe","sfvmyNG","yK1SwKC","x2zVCM1HDeu","CNfMDxO","vfjSuxi","Cg1fwfa","x3bPBMDqB24","ChrVCG","BvfWz2C","s1fUteO","AvrMDei","sMrpt0q","B25SAw5L","vLPrtKO","Cg9PBNrdB24","y3jLyxrLrwW","AxnFywnR","yNL0zxm","zNjVBunOyxi","DMDNA0C","Be55veq","BMrisM0","zwn0","r2jAvKm","z2v0qwXS","z2jJveS","y3vYDMfSDwu","BhrKDg4","rLL3B2i","BNvTyMvY","BvferNu","tfvZCK4","D0Hiy1C","munmrLPpCG","t2rZreW","DgLTzw91Da","zfDHr1i","uMXAzMi","BhnHwMW","C3nHz2vfDMu","u09lENq","sKD0svm","txv3CxG","zMHdDKy","vLjLCfC","v0f3vuy","A1n0yxr1C0m","yxbWBgLJyxq","A05Xswq","AgrNCwG","y3HrAei","EgjeA3u","zvrqvee","C2vYDMvYvgK","ywnRx2LK","q09otKvdveK","yNPKzxO","lcbOB3n0BMe","txLewvK","u2DHt3u","r1rzA24","DenMBeC","Buv6vwW","tw9cCxa","zNjVBu51Bwi","t2Hjr04","yNjtzNy","DeLK","C3rVCMu","tM9euLG","D3nZoI8V","y0fyDLK","B2zMC2v0","AvfJvuC","r0npuhi","x29UrxjYB3i","A2vQBvK","tfrSr1G","DgfIyxnL","t1DyzNO","x25HDMLNyxq","t2PRqMW","Au5tufK","BNruCMLLC0m","x3DZsw5ZDge","A1LKCfu","x2LUAxrhBg8","re5OreG","DNrbu3u","Cgf5Bg9Hza","ChHtzuK","y09Wzw4","vuvuvwO","yM9L","ign1CNnVCIa","DgjUzNC","AeTbqui","B25TzxnZywC","DffJEKO","BMnLq2XVC2u","uwvOqMe","se5mzMi","CMvZB2X2zq","x2DLBMvYyxq","s1fVA1G","AujMvuO","t1jwCeO","vw5Oyw5KBgu","yxrLq291BNq","quvMwhq","qwjVCNrfCNi","ruzNBMu","B3bLBIa","B1PuDNK","x3bPBMDmB3m","DgLLCKPtt04","vhvVz04","qvvysLG","wLjxB04","CLrLvgm","B2TkELC","C2v0q3vYC28","Ehr0Ewy","veDgthe","Dgv2v3m","yNLlvuy","AeLABfi","vgPbve8","rvrcBMq","y2HnyxHuCMK","sKXizwu","zxjYtM8","yxnL","Cgf5Bg9Hzeu","EMDsExe","t0rYqKi","y0rNBfC","uMn5CKS","Cw9Vvg4","x2LZqNjVD3m","B3bLBKrc","yxbWzw5Kq2G","yKL5q2q","whbdzee","q0zbA3q","ENPxqNG","B3jRig9MzMW","wLrQvKi","yMLUyxj5","Dg9VigXHCMC","zMXVB3i","y0D6u2i","CgfNzxnOB3C","y2XVC2veqG","BxLqz2S","BM93","vuj6CuW","x3nVy2TLDa","y3jLyxrLq2W","AeD0BLq","AxrYqK4","CK1MwxG","vgfN","z2L0u2K","yLjXu3C","EeH6sM8","AfrcyNi","DM5KBMe","swnrugS","ExLpufO","CwfJsvq","DxrMofDYAxq","rhrpwxC","DgDdAxO","Aw5N","uMTmvwW","ALvRvLK","t0rJsgC","svriwgS","vfvlDei","tKXirNi","uvDjvfq","zxj2AwnL","yvfnzuG","zgLZywjSzue","wg9SA0W","EfHPBKq","y2vZC0i","Bwv0Ag9K","A2vnueC","tNPOCKS","tgLZDgvUzxi","z2vtEw5J","Aw9UvgLTzw8","z2vY","ChziwKe","t3rIseK","qKPgBuK","CM92AwrLihC","BgLZDgvUtMu","z0nRAhK","BeHHBMrSzxi","x2HHBMrSzva","qu9uBxK","y3vYC29YlNm","vgXHvNy","DeDAA0i","z3HxCgy","ywnRDxbfBMq","vuLnEeu","sfnYt0W","DgTjqxi","DeXVqvy"];return Qo=function(){return t},Qo()}var B=U;(function(t,e){let r=U,i=t();for(;;)try{if(parseInt(r(1387))/1*(parseInt(r(551))/2)+-parseInt(r(400))/3*(parseInt(r(1591))/4)+parseInt(r(983))/5+-parseInt(r(589))/6+-parseInt(r(1688))/7*(-parseInt(r(1670))/8)+parseInt(r(603))/9+-parseInt(r(583))/10===e)break;i.push(i.shift())}catch{i.push(i.shift())}})(Qo,524185);var a1=Object[B(901)+"operty"],c1=Object[B(801)+B(1067)+B(826)],qh=(t,e)=>function(){return t&&(e=(0,t[{EBTjq:function(c,d){return c(d)}}[B(1112)](c1,t)[0]])(t=0)),e},l1=(t,e)=>{let r={xySpQ:function(o,c,d,u){return o(c,d,u)}};for(var i in e)r.xySpQ(a1,t,i,{get:e[i],enumerable:!0})};function d1(){return Fh||(Fh=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function u1(){let t=B;return zh||(zh=[IDBCursor.prototype[t(412)],IDBCursor[t(390)+"e"][t(936)],IDBCursor.prototype[t(936)+t(1578)+"ey"]])}function f1(t){let e=B,r={ivSbs:"success",HxzMi:function(o,c){return o(c)},RBIPE:function(o){return o()},IWOQg:function(o,c){return o||c},dCadT:function(o,c){return o!==c},MaCZt:e(1362),wVonC:"wvAGT",ingiS:e(1051),mzBsk:function(o,c){return o instanceof c}},i=new Promise((o,c)=>{let d=e,u={gxUZk:function(x){return r.RBIPE(x)},XnYLJ:function(x,h){return r[U(1117)](x,h)}};if(r[d(1605)](r[d(819)],r[d(883)])){let x=()=>{let w=d;t[w(564)+w(947)+w(574)](r[w(1101)],h),t[w(564)+w(947)+w(574)](w(1051),m)},h=()=>{let w=d;r[w(1113)](o,r.HxzMi(zt,t[w(1234)])),r.RBIPE(x)},m=()=>{let w=d;c(t[w(1051)]),u[w(1251)](x)};t[d(1055)+d(1545)](r[d(1101)],h),t["addEvent"+d(1545)](r[d(1301)],m)}else{let x=this[d(414)][d(1208)](this[d(978)]),h=_0x59f5fb.parse(u[d(1672)](x,"{}"));return h[_0x51ef78]=void 0,this._qosDB[d(299)](this[d(978)],_0x5de347[d(811)+"y"](h))}});return i[e(255)](o=>{r.mzBsk(o,IDBCursor)&&ql.set(o,t)})[e(1084)](()=>{}),ta.set(i,t),i}function x1(t){let e=B,r={srOpi:function(o){return o()},eAyqp:e(282),vBsJn:e(1347),RWNPZ:e(1464)+"or",JlHur:function(o,c){return o===c},bMBXU:e(954),FpWPh:e(294),JBAaH:e(1172),gjnyJ:e(1277)};if(ea.has(t))return;let i=new Promise((o,c)=>{let d=e,u={zZCjD:function(w,S){return r.JlHur(w,S)},rGMGD:r.bMBXU,RrZdO:r[d(219)],TNnBp:d(1277),AHYqk:r[d(659)]},x=()=>{let w=d;u[w(846)](u[w(1210)],u[w(475)])?(this[w(579)]&&this._ws.send(_0x2594a5),this[w(832)+w(542)][_0x542f6d]=null):(t[w(564)+"entListe"+w(574)](u[w(185)],h),t["removeEventListe"+w(574)](w(1051),m),t[w(564)+"entListe"+w(574)](u[w(342)],m))},h=()=>{let w=d;o(),r[w(196)](x)},m=()=>{let w=d;r[w(1161)]!==r.vBsJn?(c(t[w(1051)]||new DOMException(r[w(1162)],"AbortError")),r[w(196)](x)):this[w(1511)]&&this._socket[w(720)]({code:_0xc599ea,reason:_0x290850})};t.addEventListener(r[d(796)],h),t[d(1055)+d(1545)](d(1051),m),t[d(1055)+d(1545)](r[d(659)],m)});ea[e(592)](t,i)}function h1(t){na={BpLFZ:function(i,o){return i(o)}}[B(1310)](t,na)}function p1(t){let e=B,r={CUntk:function(i,o){return i(o)},okJzW:function(i,o){return i(o)},QylYR:function(i,o){return i===o},MwCaD:function(i,o){return i in o},rTOjW:e(1229)+"oreNames",uzOQW:function(i){return i()}};return r.QylYR(t,IDBDatabase[e(390)+"e"][e(281)+e(977)])&&!r.MwCaD(r[e(1613)],IDBTransaction[e(390)+"e"])?function(i,...o){let c=e,d=t.call(r.CUntk(cs,this),i,...o);return Hl.set(d,i[c(1e3)]?i[c(1e3)]():[i]),r[c(802)](zt,d)}:r.uzOQW(u1).includes(t)?function(...i){let o=e;return t.apply(cs(this),i),r[o(1474)](zt,ql[o(353)](this))}:function(...i){let o=e;return r[o(1474)](zt,t[o(1614)](r.CUntk(cs,this),i))}}function g1(t){let e=B,r={VoJww:function(i,o){return i===o},sJMXh:e(1023),BqWBq:function(i,o){return i(o)},muZBo:function(i,o){return i instanceof o},bEoWD:function(i,o,c){return i(o,c)},TtktP:function(i){return i()}};return r[e(663)](typeof t,r[e(731)])?r[e(291)](p1,t):(r[e(795)](t,IDBTransaction)&&x1(t),r[e(230)](jh,t,r.TtktP(d1))?new Proxy(t,na):t)}function zt(t){let e=B,r={tkIAr:function(o,c){return o instanceof c},iAleL:function(o,c){return o(c)},OufKX:function(o,c){return o!==c}};if(r[e(1565)](t,IDBRequest))return f1(t);if(Yo[e(1573)](t))return Yo[e(353)](t);let i=r[e(957)](g1,t);return r[e(1231)](i,t)&&(Yo[e(592)](t,i),ta[e(592)](i,t)),i}var jh,Fh,zh,ql,ea,Hl,Yo,ta,na,cs,Uh=qh({"node_modules/idb/build/wrap-idb-value.js"(){let t=B,e={YKKrP:function(r,i){return r&i},KHvwh:function(r,i){return r|i},qqfgv:function(r,i){return r instanceof i},WiWhV:t(1543),vMuIR:function(r,i){return r===i},ByQcL:"objectStoreNames",yDjAb:t(1725),MuXNv:t(1422),gDZQz:function(r,i){return r(i)},jKGFV:t(1726),wnhIX:function(r,i){return r>=i},lOCUE:function(r,i){return r-i},syBEa:function(r,i){return r!==i},vnGoG:t(1375),NlFxv:t(568),zkLJY:function(r,i){return r in i}};jh=(r,i)=>i[t(304)](o=>r instanceof o),ql=new WeakMap,ea=new WeakMap,Hl=new WeakMap,Yo=new WeakMap,ta=new WeakMap,na={get(r,i,o){let c=t,d={JnwJe:function(u,x){return u+x},YQKlK:function(u,x){return e.YKKrP(u,x)},WueRr:function(u,x){return u>>x},bzdez:function(u,x){return e[U(1290)](u,x)},XQgea:function(u,x){return u>>x},FYHEW:function(u,x){return u|x},iInSc:function(u,x){return u&x}};if(e.qqfgv(r,IDBTransaction))if(e[c(249)]===c(812))_0x4afa84=d[c(223)](65536,(1023&_0x5885fc)<<10)+d[c(565)](1023,_0x35b2f8),++_0x415947,_0x4702c4[_0x36261a++]=d[c(341)](_0x331ff4,18)|240,_0x562187[_0x1e539d++]=d[c(1410)](d[c(565)](d.XQgea(_0x1bf569,12),63),128),_0x2cfd16[_0x391968++]=d[c(1600)](d[c(565)](d[c(483)](_0x52bbc4,6),63),128),_0x17a412[_0x5a7a08++]=d[c(1600)](d[c(1152)](63,_0x449f55),128);else{if(e[c(473)](i,c(568)))return ea[c(353)](r);if(i===e[c(1167)])return e[c(473)](e[c(1579)],e[c(1579)])?r[c(1229)+c(215)]||Hl[c(353)](r):_0x3c6747[c(1119)]||_0x348a5e[c(1485)]?(c(843)+" "+(_0x47e2ed.errMsg||"")+c(496)+(_0x37595d[c(1485)]||"")).trim():_0x216ae4[c(811)+"y"](_0x21ffd4);if(e[c(473)](i,e[c(715)]))return o[c(1229)+"oreNames"][1]?void 0:o[c(1229)+"ore"](o["objectSt"+c(215)][0])}return e.gDZQz(zt,r[i])},set(r,i,o){let c=t;return e[c(662)]===e[c(662)]?(r[i]=o,!0):this[c(414)].clear()},has(r,i){let o=t;return e.syBEa(o(1010),e[o(1150)])?e[o(761)](r,IDBTransaction)&&(e.vMuIR(i,e[o(1297)])||e[o(473)](i,o(1422)))?!0:e[o(1710)](i,r):!!(e[o(752)](this[o(454)+o(616)],this[o(361)+"s"].length)||e[o(473)](this["currentI"+o(616)],e[o(510)](this.endpoints[o(748)],1))&&e[o(473)](this[o(314)+"ndpointT"+o(763)+"t"],this.maxRetries))}},cs=r=>ta[t(353)](r)}}),Wh={};l1(Wh,{deleteDB:()=>w1,openDB:()=>m1,unwrap:()=>cs,wrap:()=>zt});function m1(t,e,{blocked:r,upgrade:i,blocking:o,terminated:c}={}){let d=B,u={sCkXZ:function(m,w){return m(w)},UEvlR:function(m,w){return m!==w},JLHee:d(1630),ezwZI:"HHEhn",sERJC:d(771)+d(217),frjqv:d(287)},x=indexedDB[d(431)](t,e),h=u[d(481)](zt,x);if(i)if(u[d(1351)](u[d(1484)],u[d(1160)]))x["addEvent"+d(1545)](u[d(1220)],m=>{let w=d;i(u.sCkXZ(zt,x[w(1234)]),m[w(712)+"on"],m.newVersion,u.sCkXZ(zt,x["transact"+w(977)]))});else return _0x1f80d1[d(1614)](_0x3f588d(this),_0x4ae57c),_0x301706(_0x54b010.get(this));return r&&x[d(1055)+d(1545)](u[d(1298)],()=>r()),h[d(255)](m=>{let w=d;c&&m[w(1055)+w(1545)](w(720),()=>c()),o&&m[w(1055)+"Listener"](w(402)+w(1268),()=>o())})[d(1084)](()=>{}),h}function w1(t,{blocked:e}={}){let r=B,i={mQDFu:function(c,d){return c(d)}},o=indexedDB[r(641)+r(1432)](t);return e&&o[r(1055)+"Listener"](r(287),()=>e()),i[r(1384)](zt,o)[r(255)](()=>{})}function Gh(t,e){let r=B,i={NqKRf:function(x,h){return x>=h},cDglW:function(x,h){return x!==h},dZSSN:r(753),FsDEp:r(648)+"e",xEfQq:"readonly",viDXJ:function(x,h){return x instanceof h},JhdzA:function(x,h){return x===h},ecvvE:function(x,h){return x!==h},VBgeM:function(x,h){return x in h}};if(!(i[r(1584)](t,IDBDatabase)&&!(e in t)&&i[r(1287)](typeof e,r(1218))))return i[r(1490)](r(953),r(644))?void 0:i.NqKRf(_0x29d4e9[r(1426)],_0x215ba7[r(472)]);if(Xo.get(e))return Xo.get(e);let o=e.replace(/FromIndex$/,""),c=i[r(1076)](e,o),d=$h[r(1332)](o);if(!i[r(689)](o,(c?IDBIndex:IDBObjectStore).prototype)||!(d||Kh[r(1332)](o)))return;let u=async function(x,...h){let m=r;if(i[m(1490)](m(1128),i.dZSSN)){let w=this[m(281)+m(977)](x,d?i[m(917)]:i.xEfQq),S=w[m(1422)];return c&&(S=S[m(745)](h[m(1320)]())),(await Promise.all([S[o](...h),d&&w[m(568)]]))[0]}else _0x900d0e.body.removeChild(_0x41bae0)};return Xo.set(e,u),u}var Kh,$h,Xo,_1=qh({"node_modules/idb/build/index.js"(){let t=B,e={wFtDJ:function(r){return r()},uGLIG:t(353),tgCiz:t(1378),JJPSr:"getAllKeys",KUTOz:t(445),Bcvyf:t(1698),GgBDF:"delete",NlyNi:function(r,i){return r(i)}};e[t(1157)](Uh),Uh(),Kh=[e[t(1592)],t(1686),e[t(1527)],e[t(389)],e.KUTOz],$h=[t(629),e[t(401)],e.GgBDF,t(912)],Xo=new Map,e[t(842)](h1,r=>({...r,get:(i,o,c)=>Gh(i,o)||r[t(353)](i,o,c),has:(i,o)=>!!Gh(i,o)||r[t(1573)](i,o)}))}}),y1={idb:function(t){let e=B;t[e(419)]=Promise[e(1456)]()[e(255)](()=>(_1(),Wh))[e(255)](function(r){return r})}},Hh={};function Ft(t){let e=B,r={MEGRT:e(435)+"1",iVnqW:function(u,x){return u!==x}},i=r[e(1273)].split("|"),o=0;for(;;){switch(i[o++]){case"0":var c=Hh[t];continue;case"1":return d[e(419)];case"2":y1[t](d,d[e(419)],Ft);continue;case"3":if(r.iVnqW(void 0,c))return c[e(419)];continue;case"4":var d=Hh[t]={exports:{}};continue}break}}Ft.d=(t,e)=>{let r=U;for(var i in e)Ft.o(e,i)&&!Ft.o(t,i)&&Object["definePr"+r(1089)](t,i,{enumerable:!0,get:e[i]})},(()=>{let t=B;Ft.o=(e,r)=>Object[t(390)+"e"]["hasOwnPr"+t(1089)][t(334)](e,r)})(),(()=>{let t=B,e={eoiLp:function(r,i){return r!==i},cMPbv:t(1338),qacIT:t(222),MbbBC:t(1259)+"d",cTTmb:"Module",aMklU:t(869)+"le"};Ft.r=r=>{let i=t;if(e[i(553)](e[i(386)],e[i(1524)]))e[i(504)]!=typeof Symbol&&Symbol[i(880)+i(1516)]&&Object[i(901)+i(1089)](r,Symbol[i(880)+i(1516)],{value:e.cTTmb}),Object["definePr"+i(1089)](r,e.aMklU,{value:!0});else{let o=_0x12d3dd.message.payload;o&&_0x4142c2[i(1475)+"rs"](o)}}})();var Oe={};(()=>{let t=B,e={eHTnN:function(a,n){return a(n)},wanTi:function(a,n){return a+n},crRgA:function(a,n){return a+n},iHvVc:function(a,n){return a+n},esnzg:function(a,n){return a(n)},GfqKg:function(a,n,s){return a(n,s)},YlvpR:function(a,n){return a<=n},XMyXv:function(a,n){return a>=n},spezc:function(a,n){return a<n},NohdY:function(a,n){return a|n},BBAnB:function(a,n){return a&n},GTYkn:function(a,n){return a<<n},OhIGN:function(a,n){return a>=n},srkKP:function(a,n){return a-n},XXXgd:function(a,n){return a|n},eiwrZ:function(a,n){return a+n},zjmpy:function(a,n){return a!==n},NrdqN:t(1717),lvElB:t(1127),tpiGw:function(a,n){return a+n},kWPoE:function(a,n){return a===n},VDTcj:t(1394),xXnLh:t(405),tCflG:function(a,n){return a(n)},kAzJd:function(a,n){return a+n},KREvy:t(727),rTeTc:t(738),oRqXf:t(781),XKaBO:t(1431),ItXbE:"done",scFVM:function(a,n){return a===n},tFJQZ:function(a,n){return a>>>n},DcMcy:function(a,n){return a|n},zcoUt:function(a,n){return a===n},GKUJs:function(a,n){return a<n},XBupi:function(a,n){return a<n},OrUFY:function(a,n){return a<n},Yzszn:function(a,n){return a<n},PUACY:function(a,n,s){return a(n,s)},ZmBJD:function(a,n){return a>>>n},wxySa:function(a,n){return a+n},gjWWy:function(a,n){return a|n},DeVig:function(a,n){return a&n},dVkJI:function(a,n){return a+n},jlDGy:function(a,n){return a>>>n},BlRaI:function(a,n){return a&n},ieAKy:function(a,n){return a>>>n},ALOUr:function(a,n){return a>>>n},ruHKN:function(a,n){return a+n},EscnX:function(a,n){return a!==n},jMgSl:function(a,n){return a&n},zDUFx:function(a,n){return a+n},aqWqC:function(a,n){return a!==n},kGXYi:function(a,n){return a|n},dTxKI:function(a,n){return a!==n},NBvew:function(a,n){return a&n},drLxB:function(a,n){return a|n},DRMCD:function(a,n){return a>>>n},CxIGz:function(a,n){return a!==n},kQCfG:function(a,n,s,l){return a(n,s,l)},AUXJX:"error",Uaxzo:function(a,n){return a<n},setSJ:function(a,n){return a===n},xGZJW:t(1653),ofPvf:function(a,n){return a>n},qPUVa:t(1706),RkLUl:function(a,n){return a-n},CawGP:function(a,n){return a===n},IABWv:t(1679),yjuPX:function(a,n){return a!==n},rablu:function(a,n){return a>>>n},seLKr:function(a,n){return a(n)},vggkG:function(a,n){return a(n)},alUZE:function(a,n,s){return a(n,s)},KEBEy:function(a,n){return a&n},JveSP:t(1222)+t(1166)+" field: "+t(1617),IOPxL:t(1222)+t(1166)+t(632)+t(338),uhWRX:function(a){return a()},kwdsC:function(a,n,s){return a(n,s)},JFcGB:function(a,n){return a(n)},MjqYy:function(a,n){return a<n},UOniK:function(a,n){return a|n},wKKgb:function(a,n){return a<<n},pPYWE:function(a,n){return a&n},fielS:function(a,n){return a|n},iQcUG:function(a,n){return a<<n},yAtJR:function(a,n){return a&n},OHXVB:function(a,n){return a|n},wEiSS:function(a,n){return a&n},TYRRG:function(a,n){return a<n},mmnGB:function(a,n){return a|n},iJyub:function(a,n){return a>n},WTySS:function(a,n,s,l){return a(n,s,l)},boooA:function(a,n){return a|n},SgaOu:function(a,n){return a>>n},KQokX:function(a,n){return a&n},qoxwn:function(a,n){return a>>n},JFxOp:function(a,n){return a|n},QurjK:function(a,n){return a|n},ripGc:function(a,n){return a===n},DZGrX:t(1379),nweWK:function(a,n,s){return a(n,s)},nXcUp:function(a,n){return a!==n},MmjzL:function(a,n,s){return a(n,s)},GTofs:function(a,n){return a===n},iknkx:t(1496),TTbSL:function(a,n){return a!==n},DbTGi:t(894),uWxVv:function(a,n,s){return a(n,s)},xYQNX:function(a,n,s){return a(n,s)},Hnygk:function(a,n,s){return a(n,s)},lwqxU:function(a,n,s){return a(n,s)},GMCnd:function(a,n){return a!==n},BADGu:t(817),Rgmsu:function(a,n,s){return a(n,s)},qHnoU:function(a,n){return a!==n},eHCVq:function(a,n,s){return a(n,s)},UBzqL:function(a,n,s){return a(n,s)},IyaNu:function(a,n){return a!==n},FsXYP:function(a,n,s){return a(n,s)},luqFv:function(a,n){return a!==n},wLXbQ:t(539),SRhlf:t(823),tVkoK:function(a,n){return a(n)},LsJQM:t(1092)+t(693)+"s",ETBnd:function(a,n,s){return a(n,s)},HyfpZ:t(1092)+t(914)+"t",UiPgw:function(a,n){return a(n)},SGoNq:function(a,n){return a===n},pWTfQ:t(899),EYaNN:function(a,n){return a(n)},xqDcy:function(a,n){return a<n},mbyXz:function(a,n){return a<=n},rJFaM:function(a,n){return a|n},HslAe:function(a,n){return a-n},hKAAB:function(a,n){return a<<n},TayHt:function(a,n){return a+n},wrnKq:t(858),htrRq:function(a,n){return a(n)},ETINs:function(a,n,s){return a(n,s)},kejmY:function(a,n){return a(n)},nTfFC:function(a,n){return a(n)},LEfFf:function(a,n,s){return a(n,s)},kLXRh:function(a,n,s){return a(n,s)},NoDRX:function(a,n,s){return a(n,s)},YIkCp:function(a,n){return a(n)},mhzjj:function(a,n,s){return a(n,s)},VVhDB:function(a,n){return a&n},zpriu:t(1222)+"required"+t(632)+"SeqID",Oczxz:function(a,n){return a===n},UsqJO:t(1222)+t(1166)+t(632)+"LogID",SlFnj:t(1222)+t(1166)+t(632)+"service",ookWq:t(1222)+t(1166)+t(632)+t(1542),JFsCS:function(a,n){return a(n)},kmBLe:function(a,n,s){return a(n,s)},mEzUl:function(a,n){return a(n)},Pazoq:function(a,n,s){return a(n,s)},oLMiH:"Unimplem"+t(909)+t(926),QSHAl:function(a,n){return a>=n},onTdx:function(a,n){return a>>>n},qyyMB:function(a,n){return a&n},HCQsx:function(a,n){return a<<n},Ztgwz:"BFbpm",MfFSV:function(a,n){return a===n},GWbnl:function(a,n){return a===n},Lrtoi:"PXTmG",RlZfb:function(a,n){return a===n},IWMSB:function(a,n){return a>n},bGbmn:function(a,n){return a+n},EFBgV:function(a,n,s){return a(n,s)},WsFdM:function(a,n){return a(n)},dHkeq:function(a,n){return a===n},WzHWm:function(a,n){return a+n},srIRZ:function(a,n){return a!==n},yXvbs:function(a,n){return a<<n},hRNmR:function(a,n){return a&n},XGxzy:function(a,n){return a==n},tWEYM:function(a,n){return a&n},kmKGn:function(a,n){return a+n},LUsrN:function(a,n){return a+n},XbkNX:function(a,n){return a&n},RhmQX:function(a,n){return a<<n},CEayu:function(a,n){return a|n},jruZG:function(a,n){return a|n},ZEKyv:function(a,n){return a<<n},nOIyG:function(a,n){return a&n},IunVR:function(a,n){return a&n},htyyr:function(a,n){return a>=n},GGGzB:function(a,n){return a+n},wGMOu:function(a,n){return a+n},SbYZv:function(a,n){return a+n},jSQIT:function(a,n){return a+n},vMRps:function(a,n){return a!==n},rIKHK:function(a,n){return a&n},LddkB:function(a,n){return a<<n},hNWDC:function(a,n){return a|n},lZHDi:function(a,n){return a&n},YuEzY:function(a,n){return a&n},BAmXo:function(a,n){return a>n},puosq:function(a,n){return a+n},PXgxW:function(a,n){return a<n},GCOPr:function(a,n){return a<<n},xLAxz:function(a,n){return a<n},GvgWI:function(a,n,s){return a(n,s)},OxpbI:function(a,n,s){return a(n,s)},VnDlh:function(a,n){return a<=n},IyXot:function(a,n){return a<n},CbkoX:function(a,n){return a&n},YJbSN:function(a,n){return a<n},YLxFn:function(a,n){return a>>n},BQlPs:function(a,n){return a>>n},wqXuu:function(a,n){return a|n},enayh:function(a,n){return a&n},mneJl:function(a,n){return a>>n},qjYfC:function(a,n){return a&n},pmEXP:function(a,n){return a&n},PjnFM:function(a,n){return a===n},ojVLl:t(1086),sncHs:function(a,n,s){return a(n,s)},IclgH:function(a,n){return a&n},MyDYY:function(a,n,s){return a(n,s)},zsaaz:function(a,n,s){return a(n,s)},Hdqqi:t(1040),eFHEI:t(591),Tufce:function(a,n,s){return a(n,s)},RwMbf:function(a,n,s){return a(n,s)},ZLIwb:function(a,n){return a(n)},YOJbe:function(a,n){return a instanceof n},PztuZ:t(1401)+t(563),fCYhz:"applicat"+t(563)+";charset=utf-8",oaGdu:t(1218),iTftB:function(a,n,s,l){return a(n,s,l)},fKYPb:function(a,n){return a(n)},AAvSN:function(a,n){return a&n},tgVnd:function(a,n){return a&n},ESsbM:function(a,n){return a<<n},AHHjl:function(a,n){return a&n},wLpNX:function(a,n){return a&n},OmsmY:function(a,n){return a!==n},yEdkl:t(1155),bdIwQ:function(a,n){return a(n)},SvkPc:function(a,n){return a&n},YtsxT:function(a,n){return a&n},uoKKN:function(a,n){return a(n)},TuogN:function(a,n){return a<<n},RzJRA:function(a,n){return a&n},cXNUG:function(a,n){return a(n)},syWbF:function(a,n){return a<<n},lNyTD:function(a,n){return a&n},pPkgp:function(a,n){return a&n},tDxre:function(a,n){return a(n)},VgbGG:function(a,n){return a&n},STgBR:t(398),gCkhy:"mbbUw",QZkfZ:function(a,n){return a&n},xydJA:"EdIdw",nfyXl:function(a,n){return a>>>n},HFWxY:function(a,n){return a>>>n},YVhkF:function(a,n){return a>>>n},PsDir:function(a,n){return a<n},iMsFJ:function(a,n){return a<n},JMoBq:function(a,n,s){return a(n,s)},cJzwl:function(a,n){return a+n},rRCWS:function(a,n){return a+n},zhjaE:function(a,n){return a>>>n},iIeeM:function(a,n){return a>>>n},zVdXe:function(a,n){return a+n},GreJM:function(a,n){return a!==n},posxA:function(a,n){return a>>>n},PlFRa:function(a,n){return a|n},kayiD:function(a,n){return a+n},nJuwH:function(a,n){return a&n},eLAiq:function(a,n){return a+n},cRLSI:function(a,n){return a&n},zgrUz:function(a,n){return a>>>n},izkCy:function(a,n){return a&n},xHqFt:function(a,n){return a!==n},Ofmgb:t(566),bsMmb:function(a,n){return a(n)},eTFzl:function(a,n){return a|n},WAwUF:function(a,n){return a===n},XTUXb:function(a,n){return a|n},JgiOl:function(a,n){return a<<n},SruCC:function(a,n){return a<<n},gEMED:function(a,n){return a|n},raazt:function(a,n){return a<<n},OdsDL:function(a,n){return a|n},oQDdb:function(a,n){return a<<n},HxliO:function(a,n){return a<<n},NHjAi:function(a,n){return a<<n},kfHuv:function(a,n){return a===n},IyDqX:function(a,n){return a|n},mHkqF:function(a,n){return a|n},teYRe:function(a,n){return a|n},TXWEw:function(a,n){return a<<n},MufQN:function(a,n){return a|n},CimRj:function(a,n){return a|n},JbgiS:function(a,n){return a&n},GyeGW:function(a,n){return a&n},EZkNI:function(a,n){return a>>>n},JgEmy:function(a,n){return a&n},lXNTe:function(a,n){return a&n},tokPr:function(a,n){return a>>>n},gGQLi:function(a,n){return a!==n},WbrSN:t(1656),xnSvU:function(a,n){return a+n},wKQhL:function(a,n){return a%n},aJWgA:function(a,n){return a/n},kMurT:function(a,n){return a*n},RhgHt:function(a,n){return a*n},OgAPK:function(a,n){return a>>>n},icawt:function(a,n){return a>>>n},lsaZl:function(a,n){return a&n},QAqSU:function(a,n){return a>>>n},SJWBJ:function(a,n){return a&n},cAXvY:function(a,n){return a+n},HohVK:function(a,n){return a+n},NukUX:function(a,n){return a|n},QehBa:function(a,n){return a!==n},QsZgS:function(a,n){return a===n},ngEox:function(a,n){return a>>>n},yYRHg:function(a,n){return a===n},jkhqK:function(a,n){return a===n},pvHZA:function(a,n){return a===n},ewBmv:function(a,n){return a+n},WlrEf:function(a,n){return a&n},aBLxm:function(a,n){return a>>>n},dWaGR:function(a,n){return a&n},FdLKx:function(a,n){return a&n},CnYcH:function(a,n){return a&n},rmMYt:function(a,n){return a>>>n},eTPTA:function(a,n){return a&n},gCLbR:function(a,n){return a&n},nWQMT:function(a,n){return a>>>n},CIKUl:function(a,n){return a>>>n},ZVScN:function(a,n){return a&n},WrVLq:t(612)+t(1675),ZRWoN:t(1021)+t(851),Abite:"MAX_RETR"+t(1697)+"R",MiydN:t(1409)+t(882),OaDza:t(789)+"OR",SGxJO:t(303)+t(911),Lixbu:t(1219)+t(587),fAGIn:"close",XpCdA:function(a,n){return a!==n},GZyjf:"glqCL",XlRND:t(332)+"4",TRlQr:t(687),qlAGq:t(815),twDnu:t(1066),buSsM:function(a,n){return a-n},eatLH:function(a,n){return a==n},oShCb:function(a,n){return a>n},rHmdP:function(a,n){return a+n},djQAL:t(1461)+t(1676),exPxs:function(a,n){return a===n},WSuQO:function(a,n){return a===n},Tvrjv:t(718),NtBUP:"Mxjgw",tevWs:function(a,n,s){return a(n,s)},SpjSl:function(a,n){return a||n},ZSXdK:"ubSFN",eZYkw:"open",FHAFx:function(a,n){return a!==n},OoLrO:function(a,n){return a instanceof n},MyOQC:function(a,n){return a instanceof n},ZdQBp:function(a,n){return a===n},VOdoh:"zgRyq",yBpUB:t(1489),reXcC:function(a,n){return a||n},qWYkW:"undefined",jxVIc:function(a,n){return a!=n},ToHsX:"next() called multiple t"+t(372)+"process",ePOki:t(1081),OjCTQ:t(1530),HNLfb:function(a,n){return a<n},hdgqh:t(1285),IVtdy:function(a,n){return a<n},gQzUw:function(a,n){return a===n},vIgJr:function(a,n){return a&n},ntXPA:function(a,n){return a===n},KoICq:function(a,n){return a&n},xACRl:function(a,n){return a-n},OwCEL:function(a,n){return a<n},NbnVk:function(a,n){return a<=n},XgIgd:function(a,n){return a>=n},ikmZS:function(a,n){return a<<n},iwLdZ:function(a,n){return a&n},ctBvo:function(a,n){return a>=n},MDfQu:function(a,n){return a|n},ogvTT:function(a,n){return a<<n},tmjqA:function(a,n){return a&n},bmdqP:function(a,n){return a<<n},oZTvy:function(a,n){return a&n},ZuNNK:function(a,n){return a|n},EvOCA:function(a,n){return a|n},drEFC:function(a,n){return a&n},RmzTZ:function(a,n){return a&n},lFgaM:function(a,n){return a&n},WKBXz:function(a,n){return a&n},rTIYc:function(a,n){return a>>n},jmQli:function(a,n){return a+n},BJFmI:function(a,n){return a>>n},nvLEH:function(a,n){return a&n},sAphN:function(a,n){return a&n},yyPaO:function(a,n){return a&n},zAnSC:function(a,n){return a+n},SVGPv:function(a,n){return a+n},xbDku:function(a,n){return a&n},meXNh:function(a,n){return a|n},jnzBW:function(a,n){return a>>n},UBZit:function(a,n){return a|n},BSoRW:function(a,n){return a>>n},jUOsD:function(a,n){return a|n},JMiib:function(a,n){return a&n},pIWnj:function(a,n){return a|n},GZrKr:function(a,n){return a>>n},Gdrqf:function(a,n){return a==n},mPYne:t(364),WClFR:function(a,n){return a(n)},zGiUf:function(a,n){return a instanceof n},OjkBl:function(a,n){return a instanceof n},KiLHY:function(a,n){return a!=n},tcTHO:t(1211),qTvVu:function(a,n){return a|n},NZsis:function(a,n){return a<n},CXnsU:t(904),okabB:t(1398),NchCo:t(1304)+t(741),jkrBk:"http",xOqRe:t(714)+"ack=fron"+t(1469)+"P",bRqSw:function(a,n){return a===n},GcLoN:function(a,n){return a(n)},LMcLq:t(229),XxhnS:t(358),jFCJI:t(287),DtOYw:t(1181),tGFmF:function(a,n,s){return a(n,s)},NCzjb:function(a,n){return a===n},bzMwH:t(737),lzFKd:"eNmXV",cfZfe:function(a,n,s,l){return a(n,s,l)},CNxQa:"mdGya",mtzTP:function(a,n){return a||n},AvvbT:t(1300)+t(1017),WmPJv:function(a,n){return a!==n},sZjbT:t(456),dIInx:t(1577),WLldi:t(777),ugfwL:t(945),qGRyw:function(a,n){return a||n},ODcHg:function(a,n){return a||n},bMlZG:function(a,n){return a!=n},ZnIDM:"init QoS"+t(1217)+"d",HaqOY:function(a,n){return a(n)},FYwob:t(246),ZEXgB:function(a,n,s){return a(n,s)},Cyhgu:t(339),cxQhB:function(a,n){return a(n)},QyjGL:t(729),ynBSI:function(a,n){return a!==n},HuGCe:t(1207),qGKDI:function(a,n){return a+n},hvNUQ:function(a,n){return a+n},ZcBxR:"crcZf",Qodnf:function(a,n){return a!==n},pVdaP:t(221),JdOOD:t(1583),eYsbT:function(a,n){return a<n},HIBTW:function(a,n,s){return a(n,s)},fGGZQ:t(755),qVQaB:function(a,n,s,l){return a(n,s,l)},CmbVY:t(630)+t(1126),EFgne:function(a,n,s,l){return a(n,s,l)},ydwzD:t(630)+t(593)+"ck",EFuRm:function(a,n,s,l){return a(n,s,l)},AOTmy:function(a,n,s){return a(n,s)},OhXDL:t(630)+t(726)+t(373),WUKQl:"need_ack",hbtWE:function(a,n,s,l){return a(n,s,l)},QaNlt:"is_ack",GmDvx:function(a,n){return a&&n},JpqDy:t(1408),McfUe:t(1596),iyKgA:function(a){return a()},rqfuz:t(1533),Wiiwg:t(1323),MwEOs:"received",iUPut:function(a){return a()},hizsq:function(a,n){return a(n)},tgvNo:function(a,n){return a instanceof n},XUlyY:function(a,n){return a instanceof n},RFMir:t(317)+"in;chars"+t(440),weHKH:t(447)+"e",yfqtd:t(1502),CrriP:function(a,n){return a+n},GAnEg:function(a,n){return a>>>n},fRaYx:function(a,n){return a<<n},VZQNJ:function(a,n){return a|n},qhwmH:function(a,n){return a<<n},DsKlB:function(a,n){return a<<n},QfEMv:function(a,n){return a!==n},RVDXi:function(a,n){return a+n},voOis:function(a,n){return a+n},iNSPY:function(a,n){return a+n},mVEsz:"index ou"+t(1716)+t(972),XVSUI:" + ",IyLka:function(a,n){return a||n},xrwjU:t(665),wlELR:t(1606)+"0",WlDGj:t(898),OtbHI:t(423)+t(1503)+"e",DyTiQ:function(a,n,s,l){return a(n,s,l)},hxebL:function(a,n){return a+n},xXinD:function(a,n){return a+n},gJKEd:function(a,n){return a<n},AICUM:function(a,n,s){return a(n,s)},TcqJV:function(a,n,s,l){return a(n,s,l)},mGkeB:function(a,n){return a|n},EpUHl:function(a,n){return a<<n},dpxQw:function(a,n){return a+n},KlznS:function(a,n){return a<<n},xbbIN:function(a,n){return a|n},nBsII:function(a,n){return a|n},KHPGy:function(a,n){return a<<n},CFAkt:function(a,n){return a<<n},TyTCZ:function(a,n){return a+n},QQxeW:function(a,n){return a&n},RgxwT:function(a,n){return a+n},QwXSp:function(a,n){return a>>>n},WCiEG:function(a,n){return a+n},hTBbr:function(a,n){return a>>>n},BZJRP:function(a,n){return a&n},vcnul:function(a,n){return a&n},sQbZK:function(a,n){return a&n},DXxNW:function(a,n){return a+n},KBrvX:t(768)+"|8|1|10|0|2|5|9|4",Zjtsd:function(a,n){return a|n},QPlgV:function(a,n){return a<<n},itrBN:function(a,n){return a<<n},bZOmr:function(a,n){return a===n},CbkrQ:t(1535),JQTUV:function(a,n){return a<n},GJRqo:t(1558)+t(1536),idYZb:t(280),ITHXk:function(a,n,s,l){return a(n,s,l)},HULbx:t(1196),veiDx:"service-"+t(1701),Atoel:t(1701),IcQPk:function(a,n,s,l){return a(n,s,l)},eDbhD:t(1380),bTGEY:function(a,n){return a(n)},KsXpu:t(347),MUOVB:t(893),itaBq:"GBuNi",MoBqp:function(a,n,s){return a(n,s)},sNnxv:function(a,n,s,l){return a(n,s,l)},SOrHE:function(a,n){return a+n},WPuCN:function(a,n,s){return a(n,s)},RHFEG:function(a,n){return a===n},PLFic:t(309),kkTNN:"FILE_NOT"+t(1136),pcAhA:t(1623),YCOfy:t(1295),lONkh:"CONTINUE",wHHcW:function(a){return a()},NGZoY:t(1331)+"r",qooTn:t(707),tyhOJ:"code",LhJHm:function(a,n,s,l){return a(n,s,l)},NYMHC:"x_fronti"+t(233),TaQzO:function(a,n,s){return a(n,s)},ivDcM:function(a,n,s,l){return a(n,s,l)},AEfXt:t(892)+"s",ZlVOx:"x-msg-cursor_name",CnSdK:"x-msg-cu"+t(750)+"ue",wjGng:function(a){return a()},hywpZ:function(a,n){return a>n},tqcPy:function(a){return a()},wFXvP:function(a,n){return a===n},lGInm:function(a,n,s){return a(n,s)},nrwuV:t(460)+t(1095),XazvQ:function(a){return a()},GbZVC:"jzYyv",YtEWC:function(a,n){return a!==n},NoqoM:t(499),tQczJ:function(a,n){return a===n},RcyrK:"auto",vndna:function(a,n){return a===n},jRmtv:t(429),KQnLJ:"success",Kjuka:function(a,n,s,l){return a(n,s,l)},LfFMu:function(a,n){return a<=n},ggRNX:function(a,n){return a|n},NGQTr:function(a,n){return a|n},WlgWt:function(a,n,s,l){return a(n,s,l)},ErFvj:function(a,n,s){return a(n,s)},dMaku:function(a,n,s){return a(n,s)},nsBpX:function(a,n){return a!==n},wnxJm:t(335),sPGnc:function(a,n){return a==n},gTuvx:function(a,n){return a===n},tlLZA:"please p"+t(1200)+t(857),YvbmV:function(a,n){return a(n)},ksVSv:"please p"+t(1552)+t(572)+t(853)+t(1177)+t(411)+t(743)+t(1655),UCGVn:t(1517),NVsQV:t(224),XBECI:function(a,n,s){return a(n,s)},pDCLW:"reconnect",qCkfa:t(381)+"ediately reconnect",qYMPa:t(1366),tGZkB:"offline",TlaVv:t(827),gxWpf:t(1506),brrRI:function(a,n){return a<n},IOueS:function(a,n){return a|n},xlVaQ:function(a,n){return a&n},tLoAV:function(a,n){return a<n},QlJpk:function(a,n){return a&n},UvyoK:t(960),PdyDQ:t(1633),jsiaj:"ws://",hekbg:t(1424),ENhGJ:"bd_did",dYKvO:t(636),aYunH:t(1327)+"d",jYRpr:t(1015)+t(1601)+"ddID, deviceID o"+t(198),NknLE:t(1023),RbiNW:function(a){return a()},ryhEy:t(1321),hIZlR:t(704)+"0",iBaOf:t(808)+"3",IwrKU:t(557),sStgm:t(362),pxSeI:function(a,n){return a||n},zwThA:function(a,n){return a===n},GuHpz:t(1071),TsEKU:t(907),yyOPZ:t(1344),xwmSm:function(a,n,s){return a(n,s)},MgIqu:function(a,n){return a(n)},azfrC:t(379),JYWPq:t(862)+">",jMvuy:t(1505),pTJXK:t(1389),cDpyb:"going aw"+t(370)+t(702)+t(279)+t(613),APtnK:function(a,n){return a!==n},aaCsu:t(584)+t(1209)+t(1122)+"g",HcBCd:function(a,n,s){return a(n,s)},uvrEh:t(1442),TppXI:"YHsEd",ltdtn:function(a,n){return a===n},SalRr:t(654)+"4",axHvL:"2|3|1|4|0",rMfYx:function(a,n,s,l){return a(n,s,l)},ZTjVB:function(a,n){return a(n)},XQAkz:"00000000"+t(476)+t(476)+t(476),myPgk:t(1043),UvShB:t(1203),lngEO:"rOsJP",nbNkH:function(a,n,s){return a(n,s)},SFyTs:t(554),CzzRl:function(a,n,s){return a(n,s)},wJyyF:function(a,n,s){return a(n,s)},ByppI:"going aw"+t(634)+t(1500)+t(534),DZDwl:"COKUi",bkxLJ:t(318),neYpW:t(1574),Muwqx:t(1269)+t(631),QQPiv:t(244)+t(420)+"ce not initialized",LmZkA:t(244)+t(852)+t(747),ICexL:function(a,n){return a>>n},LYkKp:"please p"+t(365)+t(1692)+"ata, dat"+t(1163)+t(1714)+"ng or an"+t(770)+t(1060),nNDbG:function(a,n){return a==n},eLiHt:t(1383),SNHci:function(a,n){return a!=n},BQwHC:function(a,n){return a instanceof n},kYdpU:function(a,n){return a(n)},sSKnu:function(a,n){return a(n)},LZQEI:function(a,n){return a<n},Qzbwf:function(a,n){return a!==n},BisOK:t(725),VZAIL:function(a,n){return a===n},zCQVp:t(173),NuFUd:t(175),YpimR:function(a,n){return a||n},WWAol:function(a,n){return a!==n},ZOcYj:t(1330)+"econnect"+t(1528),RiZuG:function(a,n){return a(n)},wcgdb:function(a,n){return a!==n},BfTsy:t(606),LMnZC:t(617),zfjxy:function(a,n){return a*n},DsqGh:function(a,n){return a===n},ylRKc:"Window",hdini:"Object",lPBkv:function(a,n){return a===n},wHyiz:t(764)+"dWorkerG"+t(1568)+"pe",wpPnn:function(a,n){return a!=n},sirdt:function(a,n){return a===n},PvneS:function(a,n){return a!=n},WbCmm:function(a,n){return a===n},pjBmz:t(1311)+"rkerGlob"+t(560),UvMUD:t(479)+t(351)+t(1661),siWcJ:function(a,n){return a===n},BydRS:function(a,n){return a!=n},dKMzz:function(a,n){return a!=n},qZClq:t(805)+"qos__"};Ft.r(Oe),Ft.d(Oe,{FWS:()=>Rg,CustomErrorEvent:()=>ld,createCloseEvent:()=>yt,ReconnectEvent:()=>cd,createErrorEvent:()=>dt,decodedFrame:()=>rn,createOpenEvent:()=>pd,CustomCloseEvent:()=>dd,createReconnectEvent:()=>ya,FrontierMessageEvent:()=>fd,encodeFrame:()=>Ut,createMessageEvent:()=>hd,OpenEvent:()=>xd,ErrorCode:()=>on,Event:()=>nr,MessageEvent:()=>ud});let r="";function i(a=""){let n=t,s="02",l=""+Date.now(),f=r||(r=e[n(518)](x,a)),g=Math[n(561)]()[n(880)](16)[n(968)](-6);return e[n(1291)](e[n(1308)](e[n(1308)](s,l),f),g)}function o(){let a=t;return e[a(486)](1e4*Date.now(),Math[a(1504)](1e4*Math[a(561)]()))}function c(a){let n=t;return e[n(1308)](e[n(1724)](Array,8)[n(1106)]("0"),e[n(328)](parseInt,a,10)[n(880)](2)).slice(-8)}function d(a){let n=t,s={aQMeH:function(l,f){return e[U(384)](l,f)},XMcvZ:function(l,f){return e.XMyXv(l,f)},MqAqm:function(l,f){return e[U(322)](l,f)},jqgRY:function(l,f){return e[U(1666)](l,f)},ThCbJ:function(l,f){return e[U(1664)](l,f)},MmRiB:function(l,f){return e[U(1611)](l,f)},EveMh:function(l,f){return l|f},NzhrK:function(l,f){return e[U(1414)](l,f)},tPAVC:function(l,f){return l&f},uAJFJ:function(l,f){return e.OhIGN(l,f)},YiTGX:function(l,f){return e[U(548)](l,f)},viSxh:function(l,f){return e[U(1597)](l,f)},uzxnX:function(l,f){return e[U(1666)](l,f)},LqbGB:function(l,f){return l<<f},qdyha:function(l,f){return e[U(442)](l,f)},YdfvO:function(l,f){return e[U(1664)](l,f)}};if(e[n(1199)](e[n(453)],e[n(719)]))return e.tpiGw(Array(4)[n(1106)]("0"),e[n(328)](parseInt,a,2).toString(16))[n(968)](-4);{let l=_0x286029[_0x4b187c++];if(s[n(1537)](l,127))_0x1ba485+=_0xa153ea[n(1372)+"Code"](l);else if(s[n(512)](l,192)&&s[n(927)](l,224))_0x11ee6f+=_0x3fb56f["fromChar"+n(1609)](s[n(315)](s.ThCbJ(31,l)<<6,63&_0x69e607[_0x3d97cb++]));else if(s[n(1663)](l,224)&&s[n(927)](l,240))_0x379d44+=_0x2360ed[n(1372)+"Code"](s.EveMh(s[n(1544)](s[n(488)](15,l),12),s[n(1544)](s[n(577)](63,_0x3fefa8[_0x37e233++]),6))|s[n(488)](63,_0x56d91e[_0x1ef1a7++]));else if(s.uAJFJ(l,240)){let f=s.YiTGX(s[n(533)](s[n(315)](s[n(622)](s[n(1544)](7&l,18),s[n(585)](63&_0x2d196f[_0x1e5e59++],12)),s[n(488)](63,_0x2d927b[_0x4ca86d++])<<6),63&_0xad7627[_0xbcfb6f++]),65536);_0x5b050f+=_0x34598b[n(1372)+"Code"](s[n(841)](55296,f>>10)),_0x1f3a14+=_0x39578d[n(1372)+n(1609)](s[n(841)](56320,s[n(701)](1023,f)))}}}function u(a){let n=t;if(e.kWPoE(e[n(999)],e[n(1221)]))return _0x510658;{let s=a[n(1306)](/\./)[n(962)](g=>c(g)),l=[];return l[0]=e[n(518)](d,s[0]+s[1]),l[1]=e[n(1415)](d,e[n(624)](s[2],s[3])),[e[n(822)],n(727),e[n(822)],e[n(822)],e[n(822)],e[n(1473)],l[0],l[1]][n(1106)]("")}}function x(a){let n=t;if(e[n(474)](e[n(1690)],e[n(1334)]))return _0x2acde1+=_0x196653&&_0x2f68a0[n(371)+"th"]||0,_0x2e9b84;{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(934)](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(934)](a);return s?u(a):l?e.esnzg(h,a):n(476)+n(476)+n(476)+n(476)}}function h(a){let n=t,s={BeDSB:function(D,L,N,M){return e[U(1013)](D,L,N,M)},ORVpJ:function(D,L,N){return e[U(328)](D,L,N)},pJFBe:e[n(1471)]},l="",f=[],g=0,b=0,E=!0,p=e.KREvy;if(a[n(418)]("::")>-1){let D=a[n(1306)]("::");for(let N=0;e.Uaxzo(N,D[n(748)]);N++)if(e[n(757)](e[n(305)],e[n(305)])){let M=D[N];if(e[n(619)](M[n(418)](":"),0)){let G=M.split(":");E&&(g=G[n(748)]),b+=G.length;for(let ee=0;e[n(202)](ee,G[n(748)]);ee++)if(e[n(1001)](4,G[ee][n(748)]))if(e.qPUVa===e[n(762)]){let ce=p[n(1082)+"g"](0,4-G[ee][n(748)]),ne=ce[n(177)](G[ee]);f.push(ne)}else{if(nWANkM[n(474)](_0x474baa,nWANkM[n(1156)]))return _0x178d98[n(353)](_0x362d6a);if(nWANkM[n(474)](_0x123f18,n(1229)+n(215)))return _0x3e42d9[n(1229)+n(215)]||_0x988758[n(353)](_0x3b1338);if(nWANkM[n(1103)](_0x1c6fa9,"store"))return _0x4b11ec[n(1229)+n(215)][1]?void 0:_0xd5549d[n(1229)+n(601)](_0x75ff42[n(1229)+n(215)][0])}else f.push(G[ee]);E=!1}else{if(M[n(748)]!==4){let G=p[n(1082)+"g"](0,e[n(1529)](4,M[n(748)])),ee=G[n(177)](M);f[n(268)](ee)}else f[n(268)](M);E&&(g+=1),b+=1,E=!1}}else{let M=_0x23f6b4.low>>>0,G=e[n(225)](e[n(311)](_0x519014[n(275)]>>>28,e[n(1414)](_0x12e38b[n(946)],4)),0),ee=e.tFJQZ(_0x5d0a7a[n(946)],24),ce=e[n(838)](0,ee)?e.scFVM(0,G)?e[n(998)](M,16384)?e[n(1022)](M,128)?1:2:M<2097152?3:4:e.spezc(G,16384)?G<128?5:6:e.OrUFY(G,2097152)?7:8:e[n(293)](ee,128)?9:10,ne=e.PUACY(_0x4b3825,_0x29c8f8,ce),xe=_0x374c43[n(1371)];switch(ce){case 10:xe[e.tpiGw(ne,9)]=e.BBAnB(e[n(1570)](ee,7),1);case 9:xe[e[n(1062)](ne,8)]=ce!==9?e[n(290)](128,ee):e[n(1253)](127,ee);case 8:xe[e.dVkJI(ne,7)]=e[n(1199)](8,ce)?e[n(1597)](e.jlDGy(G,21),128):e.BlRaI(e[n(774)](G,21),127);case 7:xe[e[n(690)](ne,6)]=e[n(1199)](7,ce)?e[n(1149)](G,14)|128:e[n(575)](G,14)&127;case 6:xe[e.ruHKN(ne,5)]=ce!==6?e[n(1666)](G>>>7,128):e[n(1664)](e[n(774)](G,7),127);case 5:xe[e[n(1062)](ne,4)]=e[n(1065)](5,ce)?e.gjWWy(128,G):e.jMgSl(127,G);case 4:xe[e[n(1626)](ne,3)]=e[n(195)](4,ce)?e[n(751)](M>>>21,128):e.BlRaI(e[n(1570)](M,21),127);case 3:xe[e.wxySa(ne,2)]=e[n(1001)](3,ce)?e[n(290)](M>>>14,128):e[n(703)](M>>>14,127);case 2:xe[e[n(690)](ne,1)]=ce!==2?e[n(1228)](e.ALOUr(M,7),128):e.BBAnB(e[n(357)](M,7),127);case 1:xe[ne]=e[n(844)](1,ce)?e[n(1228)](128,M):e.jMgSl(127,M)}}let L="";for(let N=0;e.spezc(N,e.RkLUl(8,b));N++)L=L[n(177)](p);for(let N=0;e[n(998)](N,f[n(748)]);N++)e[n(651)](N,g)?(l=l[n(177)](L),l=l.concat(f[N])):l=l[n(177)](f[N]);return l}if(e.scFVM(n(471),n(1070)))try{s[n(1704)](_0x1c520b,this,_0x10be8f,[_0x52f240,_0x196956,_0x1bc924])}catch(D){let L=s[n(1460)](_0x167b92,s[n(1143)],{message:D[n(729)],code:_0x12528a[n(789)+"OR"],error:D});this[n(498)+n(1194)+n(655)](L)}else{let D=a[n(1306)](":");for(let L=0;e.Yzszn(L,D.length);L++){let N=D[L];if(e[n(1001)](4,D[L].length))if(e.aqWqC(e[n(1223)],n(1679))){let M=_0x128321[n(348)]();return M?(M.offset=M[n(472)]=0,M):{bytes:new _0x2a3a4e(64),offset:0,limit:0}}else{let M=p[n(1082)+"g"](0,e[n(548)](4,D[L][n(748)])),G=M[n(177)](N);l=l[n(177)](G)}else l=l.concat(N)}return l}}function m(a,n){let s=t,l=a[s(1617)];e[s(1199)](void 0,l)&&(e[s(328)](we,n,10),e[s(742)](q,n,l));let f=a[s(338)];e[s(555)](void 0,f)&&(we(n,18),e[s(742)](q,n,f))}function w(a){let n=t,s={};e:for(;!V(a);){let l=me(a);switch(e[n(296)](l,3)){case 0:break e;case 1:s.key=e.PUACY(R,a,e[n(1652)](me,a));break;case 2:s[n(338)]=R(a,e[n(1373)](me,a));break;default:e.alUZE(T,a,e[n(1711)](7,l))}}if(e[n(651)](void 0,s[n(1617)]))throw new Error(e[n(889)]);if(e.scFVM(void 0,s[n(338)]))throw new Error(e.IOPxL);return s}function S(a){let n=t,s=e.uhWRX(C);return e[n(696)](_,a,s),e[n(1336)](F,s)}function _(a,n){let s=t;if(e.ripGc(e[s(1004)],e[s(1004)])){let l=a.SeqID;l!==void 0&&(e[s(696)](we,n,8),e.nweWK(_t,n,l));let f=a[s(1680)];e[s(179)](void 0,f)&&(e[s(1641)](we,n,16),e[s(696)](_t,n,f));let g=a[s(1196)];if(e[s(179)](void 0,g))if(e[s(886)](e[s(633)],s(278))){let{type:ce}=_0xd18d84;this[s(840)](ce,_0x35c225)}else e[s(328)](we,n,24),e[s(328)](_t,n,e[s(1336)](P,g));let b=a[s(1542)];e[s(179)](void 0,b)&&(e[s(346)](e[s(769)],s(765))?(e[s(1657)](we,n,32),e[s(696)](_t,n,P(b))):_0x109b27&&this[s(653)+s(931)][s(377)+s(462)+s(266)](_0x399db4));let E=a[s(1255)];if(e[s(1065)](void 0,E))for(let ce of E){e[s(328)](we,n,42);let ne=C();e.xYQNX(m,ce,ne),e.Hnygk(we,n,ne[s(472)]),e[s(1350)](W,n,ne),O(ne)}let p=a[s(1487)+s(1075)];e[s(859)](void 0,p)&&(e[s(1065)]("xYdzY",e[s(1715)])?(we(n,50),e[s(570)](q,n,p)):this.on(_0x149be0,_0x45ffa4));let D=a[s(492)+s(1235)];e.qHnoU(void 0,D)&&(e[s(1135)](we,n,58),e.xYQNX(q,n,D));let L=a.payload;e[s(555)](void 0,L)&&(we(n,66),e[s(570)](we,n,L[s(748)]),e[s(1641)](ae,n,L));let N=a.LogIDNew;e[s(1065)](void 0,N)&&(we(n,74),e[s(1510)](q,n,N));let M=a[s(1407)+s(1140)];e[s(623)](void 0,M)&&(we(n,82),e.FsXYP(q,n,M));let G=a.msgID;e[s(711)](void 0,G)&&(e[s(1657)](we,n,90),q(n,G));let ee=a.frameType;if(ee!==void 0)if(e[s(711)](e[s(408)],e.SRhlf))e[s(331)](we,n,96),e[s(1612)](_t,n,e[s(810)](P,ee));else{if(_0x480a58=e[s(357)](e[s(1664)](127,_0x26cec8[_0x44d7f0]),0),e[s(295)](_0x5424c5[_0x407c46++],128))return{value:_0x51cbb4?_0x2428a1:e[s(1666)](0,_0x4dd435),offset:_0xa2c98b};if(_0x4beef6=e[s(575)](e[s(1069)](_0x469c6e,e[s(503)](e[s(399)](127,_0x14b08b[_0x1bdd1d]),7)),0),_0x38a99d[_0x25b469++]<128)return{value:_0x87d092?_0x108c96:e[s(1580)](0,_0x10bc83),offset:_0x36e011};if(_0x29b9b3=e[s(774)](e.gjWWy(_0x4c34f7,e[s(1427)](e.yAtJR(127,_0x20b9b1[_0x47ca8f]),14)),0),e.XBupi(_0x1f41cd[_0x147177++],128))return{value:_0x326ac2?_0x31c4d7:e[s(1340)](0,_0x3a7aab),offset:_0x148472};if(_0x31281f=e.tFJQZ(e[s(1069)](_0x225c98,e.wEiSS(127,_0x30b5c5[_0x218e0d])<<21),0),_0x53b92c[_0x46a5bd++]<128)return{value:_0x19934f?_0x35291a:e[s(1597)](0,_0x5efea7),offset:_0x308a70};if(_0x437380=e[s(1597)](_0x27ac59,e[s(1414)](e[s(399)](15,_0x17d8dc[_0x303417]),28))>>>0,e[s(1033)](_0x1ad03a[_0x24f91e++],128))return{value:_0x57d716?_0x3177c5:e.mmnGB(0,_0x3ece75),offset:_0x39d6cd};if(e[s(1288)](_0x59d1da+=5,_0x54394e[s(748)]))throw _0x414337=_0xaaa9f2[s(748)],e[s(1063)](_0xeaf57,_0x141b51,10,_0x4f5015[s(748)]);return{value:_0x2ed0d2?_0x54ef42:e[s(290)](0,_0x14bdbe),offset:_0x198464}}}else _0x34e564<2048?_0x32200e[_0x1e4c0c++]=e[s(1346)](e[s(399)](e[s(1413)](_0x440ac1,6),31),192):(_0x2abf32<65536?_0x4c827a[_0x550f9c++]=e[s(1346)](e[s(1458)](e[s(875)](_0xb909ca,12),15),224):(_0x29d3ad[_0x36600e++]=e[s(625)](e[s(982)](e[s(875)](_0x1e9963,18),7),240),_0x195a13[_0x82c57e++]=e[s(1659)](e[s(875)](_0xf74043,12)&63,128)),_0x49f261[_0x538386++]=e[s(1228)](e[s(424)](_0x5aa659>>6,63),128)),_0x3c5ef1[_0x413956++]=e[s(602)](e[s(424)](63,_0x312c0b),128)}function v(a){let n=t,s={xHzJo:e[n(1168)],KsqAv:function(l,f,g){return e.ETBnd(l,f,g)},CnwFd:e[n(991)],eEBhm:function(l,f){return e[n(1091)](l,f)}};if(e[n(1721)](e[n(1080)],e.pWTfQ))return e[n(650)](I,e[n(810)](z,a));{let l={xttyf:function(f,g){return s[n(1642)](f,g)},vGHII:n(1389),NLHFr:s[n(872)]};return new _0x57a471((f,g)=>{let b=n,E={KyNRD:function(L,N){return L(N)},dgAJq:s[b(1519)],FYmul:b(1092)+b(914)+"t"};this[b(205)+b(1139)](),this[b(1360)+"gTimeoutId"]=s[b(494)](_0x5194d9,this[b(1064)][b(530)](this),this[b(193)][b(839)+b(251)]);let p=()=>{let L=b;E[L(509)](f,L(545)),this[L(487)](E[L(546)],p),this[L(487)](E.FYmul,D)},D=()=>{let L=b;l[L(1476)](g,l.vGHII),this[L(487)]("ping_once_success",p),this[L(487)](l[L(1534)],D)};this.on(b(1092)+"e_success",p),this.on(s[b(872)],D),this[b(1064)]()})}}function I(a){let n=t,s={eOfDR:function(l,f){return e[U(1224)](l,f)},odPoK:function(l,f){return e[U(759)](l,f)},rCiun:function(l,f){return e[U(1419)](l,f)},AbuQf:function(l,f){return e[U(1022)](l,f)},CVNkt:function(l,f){return e.kGXYi(l,f)},QvIxY:function(l,f){return e.wKKgb(l,f)},jiyqS:function(l,f){return e[U(1458)](l,f)},GuePG:function(l,f){return e[U(337)](l,f)},yunEi:function(l,f){return l&f},xNRFN:function(l,f){return e[U(1252)](l,f)},RhOsl:function(l,f){return e.iQcUG(l,f)},cmHpq:function(l,f){return e[U(1450)](l,f)},KoLsd:function(l,f){return e[U(982)](l,f)},AwoNl:function(l,f){return e[U(1427)](l,f)},Dlfra:function(l,f){return e[U(875)](l,f)},WhWLD:function(l,f){return e[U(355)](l,f)}};if(e.wrnKq!==e[n(434)]){if(s[n(1236)](_0x5dce9b-_0x4bcfdf,1))return"";let l="";for(let f=_0x10bff1;f<_0x45a63d;){let g=_0x493a8f[f++];if(s[n(1683)](g,127))l+=_0x493e5a[n(1372)+n(1609)](g);else if(s[n(908)](g,192)&&s.AbuQf(g,224))l+=_0x4fed45[n(1372)+n(1609)](s[n(1169)](s[n(427)](s[n(284)](31,g),6),s[n(284)](63,_0x17015c[f++])));else if(g>=224&&s[n(964)](g,240))l+=_0x3e5a64["fromChar"+n(1609)](s.CVNkt(s.GuePG(s[n(427)](15&g,12),s[n(427)](s[n(1619)](63,_0x1d9470[f++]),6)),s[n(284)](63,_0x12261e[f++])));else if(s.rCiun(g,240)){let b=s[n(441)](s.GuePG(s[n(973)](7&g,18)|s[n(397)](s.KoLsd(63,_0x3d31c8[f++]),12),s[n(1282)](s.yunEi(63,_0x3ff010[f++]),6))|63&_0x4897f5[f++],65536);l+=_0x2d5096[n(1372)+"Code"](55296+s[n(1694)](b,10)),l+=_0x168b60[n(1372)+n(1609)](s[n(732)](56320,s[n(1619)](1023,b)))}}return l}else{let l={};e:for(;!e[n(650)](V,a);){let f=e[n(1671)](me,a);switch(e[n(774)](f,3)){case 0:break e;case 1:l[n(283)]=e.ETINs(kt,a,!0);break;case 2:l[n(1680)]=e[n(1641)](kt,a,!0);break;case 3:l[n(1196)]=e[n(1430)](me,a);break;case 4:l[n(1542)]=e[n(1724)](me,a);break;case 5:{let g=e[n(1415)](A,a);(l.headers||(l.headers=[]))[n(268)](e[n(272)](w,a)),a[n(472)]=g;break}case 6:l[n(1487)+"ncoding"]=R(a,me(a));break;case 7:l[n(492)+"ype"]=e.LEfFf(R,a,me(a));break;case 8:l.payload=e[n(243)](oe,a,e[n(1430)](me,a));break;case 9:l[n(1038)]=e[n(425)](R,a,e[n(810)](me,a));break;case 10:l["serverTi"+n(1140)]=e[n(696)](R,a,me(a));break;case 11:l[n(1264)]=e[n(1423)](R,a,e.YIkCp(me,a));break;case 12:l[n(905)+"e"]=e[n(650)](me,a);break;default:e[n(724)](T,a,e.VVhDB(7,f))}}if(e.scFVM(void 0,l[n(283)]))throw new Error(e[n(959)]);if(e[n(1685)](void 0,l[n(1680)]))throw new Error(e[n(677)]);if(l[n(1196)]===void 0)throw new Error(e[n(1179)]);if(e.CawGP(void 0,l.method))throw new Error(e[n(1098)]);return l}}function A(a){let n=t,s=e[n(1674)](me,a),l=a.limit;return a[n(472)]=e.tpiGw(a.offset,s),l}function T(a,n){let s=t;switch(n){case 0:for(;128&e[s(1415)](te,a););break;case 2:e[s(458)](Z,a,e[s(1416)](me,a));break;case 5:e[s(1102)](Z,a,4);break;case 1:e[s(1482)](Z,a,8);break;default:throw new Error(e[s(300)]+n)}}function P(a){let n=t;return a|=0,{low:a,high:a>>31,unsigned:e[n(1232)](a,0)}}let y=[];function C(){let a=t,n=y[a(348)]();return n?(n[a(1426)]=n[a(472)]=0,n):{bytes:new Uint8Array(64),offset:0,limit:0}}function O(a){let n=t,s={LjNfA:function(l,f){return e[U(1226)](l,f)},evRnk:function(l,f){return l&f},DNhDH:function(l,f){return e[U(273)](l,f)},cessB:function(l,f){return e[U(357)](l,f)},effBC:function(l,f){return e[U(739)](l,f)},IwErV:function(l,f){return l<<f}};if(e[n(555)](e[n(1056)],e[n(1056)])){_0xa3d0de[n(459)](_0x3a5663)||(_0x281ac6=_0x484338[n(1418)+"er"](_0xc6a41c));let l=s[n(1353)](this[n(946)],16),f=65535&this[n(946)],g=s.LjNfA(this[n(275)],16),b=s.evRnk(65535,this[n(275)]),E=_0x5146ec[n(946)]>>>16,p=s[n(1441)](65535,_0x38eacc[n(946)]),D=s.LjNfA(_0x88c605[n(275)],16),L=s[n(1333)](65535,_0x59dac2[n(275)]),N=0,M=0,G=0,ee=0;return ee+=b+L,G+=s[n(1353)](ee,16),ee&=65535,G+=g+D,M+=G>>>16,G&=65535,M+=f+p,N+=s[n(1541)](M,16),M&=65535,N+=l+E,N&=65535,_0x294ef7[n(854)](s.effBC(G,16)|ee,s[n(490)](N,16)|M,this[n(1170)])}else y[n(268)](a)}function z(a){return{bytes:a,offset:0,limit:a[t(748)]}}function F(a){let n=t;if(e.MfFSV(e[n(979)],e.Lrtoi)){let s=a[n(1371)],l=a[n(472)];return e[n(1391)](s[n(748)],l)?s:s.subarray(0,l)}else return _0x1372d4.isLong(_0x210425)||(_0x1c279f=_0xb35acb[n(1418)+"er"](_0x3476be)),this[n(1170)]!==_0x189e08[n(1170)]&&e[n(511)](e[n(1570)](this.high,31),1)&&e[n(651)](_0x251c13.high>>>31,1)?!1:e[n(818)](this[n(946)],_0x5c2688[n(946)])&&e[n(838)](this[n(275)],_0xf45fb6.low)}function Z(a,n){let s=t;if(e.ofPvf(a[s(1426)]+n,a[s(472)]))throw new Error("Skip past limit");a[s(1426)]+=n}function V(a){let n=t;return a[n(1426)]>=a[n(472)]}function ie(a,n){let s=t,l=a[s(1371)],f=a[s(1426)],g=a.limit,b=e[s(1626)](f,n);if(e[s(1288)](b,l[s(748)])){let E=new Uint8Array(2*b);E[s(592)](l),a[s(1371)]=E}return a[s(1426)]=b,e[s(821)](b,g)&&(a[s(472)]=b),f}function X(a,n){let s=t,l=a[s(1426)];if(e.ofPvf(e[s(924)](l,n),a[s(472)]))throw new Error("Read pas"+s(915));return a[s(1426)]+=n,l}function oe(a,n){let s=t,l=e.lwqxU(X,a,n);return a[s(1371)][s(930)](l,l+n)}function ae(a,n){let s=t,l=ie(a,n[s(748)]);a[s(1371)][s(592)](n,l)}function R(a,n){let s=t,l=e.EFBgV(X,a,n),f=String.fromCharCode,g=a[s(1371)],b="\uFFFD",E="";for(let p=0;p<n;p++){let D=g[p+l],L,N,M,G;e[s(511)](e[s(703)](128,D),0)?E+=e[s(684)](f,D):e.dHkeq(224&D,192)?p+1>=n?E+=b:(L=g[e.TayHt(e[s(433)](p,l),1)],e[s(208)](192&L,128)?E+=b:(G=e.yXvbs(31&D,6)|e[s(203)](63,L),e[s(322)](G,128)?E+=b:(E+=e.htrRq(f,G),p++))):e[s(600)](e[s(597)](240,D),224)?e[s(1419)](p+2,n)?E+=b:(L=g[e[s(562)](p,l)+1],N=g[e[s(1385)](e[s(1291)](p,l),2)],e[s(195)](e[s(667)](L|e.RhmQX(N,8),49344),32896)?E+=b:(G=e[s(1107)](e[s(1227)](e[s(1293)](e[s(825)](15,D),12),e[s(1293)](e[s(879)](63,L),6)),e[s(879)](63,N)),e[s(1022)](G,2048)||e[s(1151)](G,55296)&&G<=57343?E+=b:(E+=e[s(1430)](f,G),p+=2))):e.DeVig(248,D)==240?e[s(980)](p,3)>=n?E+=b:(L=g[e[s(1586)](e[s(607)](p,l),1)],N=g[e.jSQIT(e[s(607)](p,l),2)],M=g[p+l+3],e.vMRps(e[s(1631)](e.jruZG(L|e.LddkB(N,8),M<<16),12632256),8421504)?E+=b:(G=e.mmnGB(e[s(736)](e[s(1659)](e.lZHDi(7,D)<<18,(63&L)<<12),e[s(1414)](e[s(667)](63,N),6)),e[s(212)](63,M)),G<65536||e[s(350)](G,1114111)?E+=b:(G-=65536,E+=e[s(724)](f,e.puosq(e.qoxwn(G,10),55296),e.hRNmR(1023,G)+56320),p+=3))):E+=b}return E}function q(a,n){let s=t,l=n[s(748)],f=0;for(let E=0;e[s(295)](E,l);E++){let p=n[s(216)+"At"](E);e[s(1232)](p,55296)&&e.YlvpR(p,56319)&&e.PXgxW(E+1,l)&&(p=e[s(355)](e[s(1428)](p,10),n[s(216)+"At"](++E))-56613888),f+=e.Yzszn(p,128)?1:e[s(1142)](p,2048)?2:e[s(466)](p,65536)?3:4}e[s(1129)](we,a,f);let g=e[s(594)](ie,a,f),b=a.bytes;for(let E=0;e[s(295)](E,l);E++){let p=n[s(216)+"At"](E);p>=55296&&e.VnDlh(p,56319)&&e[s(624)](E,1)<l&&(p=e[s(1308)](e[s(1427)](p,10),n[s(216)+"At"](++E))-56613888),e[s(681)](p,128)?b[g++]=p:(e[s(322)](p,2048)?b[g++]=e[s(1202)](p>>6,31)|192:(e[s(1636)](p,65536)?b[g++]=e.fielS(e[s(1627)](e[s(919)](p,12),15),224):(b[g++]=e[s(1666)](e.BBAnB(e[s(321)](p,18),7),240),b[g++]=e.wqXuu(e.enayh(e[s(1589)](p,12),63),128)),b[g++]=e[s(1340)](e[s(604)](p>>6,63),128)),b[g++]=e[s(1359)](63,p)|128)}}function W(a,n){let s=t,l=ie(a,n[s(472)]),f=a[s(1371)],g=n[s(1371)];for(let b=0,E=n[s(472)];e.OrUFY(b,E);b++)f[b+l]=g[b]}function te(a){return a[t(1371)][e.alUZE(X,a,1)]}function Je(a,n){let s=t;if(e[s(1158)](e[s(329)],e[s(329)])){let l=e[s(525)](ie,a,1);a[s(1371)][l]=n}else this[s(661)+s(1132)]=_0x20d6de,this.count=0}function me(a){let n=t,s=0,l=0,f;do f=e[n(518)](te,a),e[n(1108)](s,32)&&(l|=e[n(1450)](127&f,s)),s+=7;while(e[n(995)](128,f));return l}function we(a,n){let s=t;for(n>>>=0;e[s(1151)](n,128);)e[s(208)](e[s(415)],e[s(1319)])?(e.Tufce(Je,a,e.hNWDC(e.hRNmR(127,n),128)),n>>>=7):(e[s(1412)](_0x1f21f0,_0x1c4e66,50),e[s(700)](_0x5ecb66,_0xa0ed8f,_0x1ae5dd));e[s(906)](Je,a,n)}function kt(a,n){let s=t,l={OsUPj:function(p,D){return e[U(519)](p,D)},XgZDU:e[s(363)],Zifrx:e.fCYhz,mUIMv:e[s(1644)],byKUF:function(p,D,L,N){return e[s(1364)](p,D,L,N)}},f=0,g=0,b=0,E;if(E=e.fKYPb(te,a),f=e[s(1634)](127,E),e[s(699)](128,E)&&(E=e[s(684)](te,a),f|=e[s(513)](e[s(885)](127,E),7),e.wLpNX(128,E)))if(e[s(1624)](e[s(495)],s(798))){if(E=e[s(1061)](te,a),f|=e[s(203)](127,E)<<14,e.IunVR(128,E)&&(E=e.kejmY(te,a),f|=e[s(739)](e.SvkPc(127,E),21),e[s(910)](128,E)&&(E=te(a),g=e[s(1711)](127,E),128&E&&(E=e[s(1728)](te,a),g|=e[s(1470)](e.RzJRA(127,E),7),e[s(604)](128,E)&&(E=e.cXNUG(te,a),g|=e[s(508)](e[s(703)](127,E),14),e[s(1374)](128,E)&&(E=te(a),g|=e[s(1414)](e.pPkgp(127,E),21),e.SvkPc(128,E)&&(E=e[s(326)](te,a),b=127&E,e.VgbGG(128,E))))))))if(e[s(1685)](e[s(861)],e[s(1554)])){let p=0,D={};for(let L=0;e[s(1224)](L,_0x1bc342.length);L++)D[_0x57ceb8[L][s(1300)+s(1017)]]=e[s(1144)](_0x410388,_0x2ac9d6[L][s(1300)+s(1017)]),p+=e[s(1586)](14,D[_0xc8c63e[L]["cursor_n"+s(1017)]]);return[p,D]}else E=e[s(1416)](te,a),b|=e[s(1470)](e[s(692)](127,E),7)}else if(l[s(1651)](_0x159fef.payload,_0x5beaa2)){let p=l[s(1651)](this[s(193)][s(1487)+s(1075)],_0x129ac1)?{force:!!this[s(193)][s(1487)+"ncoding"][s(1237)],encoding:this[s(193)][s(1487)+s(1075)][s(965)]?this[s(193)][s(1487)+s(1075)].encoding[s(259)](/\s/g,"")[s(394)+s(1486)]():""}:{force:!1,encoding:this[s(193)]["payloadE"+s(1075)]?this[s(193)].payloadEncoding[s(259)](/\s/g,"")["toLowerC"+s(1486)]():""},D=_0x2ff0aa.payloadEncoding?_0x18c565[s(1487)+"ncoding"][s(259)](/\s/g,"")[s(394)+s(1486)]():"",L=l[s(1651)](this[s(193)][s(492)+s(1235)],_0x2834c5)?{force:!!this[s(193)][s(492)+s(1235)][s(1237)],type:this[s(193)][s(492)+s(1235)].type?this[s(193)][s(492)+s(1235)][s(1018)].replace(/\s/g,"")[s(394)+s(1486)]():""}:{force:!1,type:this._options.payloadType?this[s(193)][s(492)+s(1235)][s(259)](/\s/g,"")[s(394)+s(1486)]():""},N=_0x876561["payloadT"+s(1235)]?_0x4e0b51[s(492)+"ype"].replace(/\s/g,"")[s(394)+"ase"]():"",M=L[s(1237)]?L[s(1018)]:N||L[s(1018)],G=p[s(1237)]?p.encoding:D||p.encoding,ee=["text/plain;charset=utf-8",l[s(1094)],l[s(181)],l[s(1121)]],ce=[s(447)+"e","binary"];this[s(193)][s(264)+"ansformT"+s(1283)+"ad"]&&ee[s(1332)](M)&&(!G||ce.includes(G))?_0x497845[s(1164)+"oad"]=l[s(1479)](_0x1cd5d9,_0x57fa7c[s(1443)],0,_0xde2ba[s(1443)].byteLength):_0x39d905[s(1164)+s(865)]=""}else _0x1a294e[s(1164)+"oad"]="";return{low:e[s(1340)](f,g<<28),high:e[s(1570)](g,4)|e[s(1604)](b,24),unsigned:n}}function _t(a,n){let s=t;if(e[s(651)](e[s(267)],e.xydJA)){let l=e[s(1570)](n[s(275)],0),f=e.nfyXl(e[s(1666)](e.HFWxY(n.low,28),e[s(508)](n[s(946)],4)),0),g=e.YVhkF(n[s(946)],24),b=e[s(1721)](0,g)?e[s(628)](0,f)?l<16384?l<128?1:2:e[s(466)](l,2097152)?3:4:f<16384?e[s(1567)](f,128)?5:6:e.iMsFJ(f,2097152)?7:8:e[s(1022)](g,128)?9:10,E=e[s(556)](ie,a,b),p=a[s(1371)];switch(b){case 10:p[E+9]=g>>>7&1;case 9:p[e[s(586)](E,8)]=e[s(1065)](9,b)?128|g:127&g;case 8:p[e[s(1238)](E,7)]=e.nXcUp(8,b)?f>>>21|128:e.zhjaE(f,21)&127;case 7:p[e.kmKGn(E,6)]=e[s(1638)](7,b)?e[s(602)](f>>>14,128):e[s(1180)](f,14)&127;case 6:p[e[s(547)](E,5)]=e.GreJM(6,b)?f>>>7|128:e[s(1634)](e[s(1230)](f,7),127);case 5:p[e[s(980)](E,4)]=b!==5?e.PlFRa(128,f):e[s(203)](127,f);case 4:p[E+3]=e[s(859)](4,b)?e[s(774)](l,21)|128:e[s(1180)](l,21)&127;case 3:p[e[s(809)](E,2)]=b!==3?e[s(625)](e.ieAKy(l,14),128):e[s(197)](e[s(1230)](l,14),127);case 2:p[e.eLAiq(E,1)]=e.yjuPX(2,b)?e[s(625)](e[s(357)](l,7),128):e[s(1032)](e[s(1640)](l,7),127);case 1:p[E]=e[s(859)](1,b)?e[s(1580)](128,l):e[s(464)](127,l)}}else _0x5809c3[s(578)](_0x18033c)}function rn(a){return e[t(1671)](v,a)}function Ut(a){let n=t;if(e[n(520)](n(566),e[n(1598)])){let s={fCOvn:function(l,f){return l(f)}};return function(l,...f){let g=n,b=_0x13e38c[g(334)](s[g(382)](_0x221396,this),l,...f);return _0xd00c5[g(592)](b,l[g(1e3)]?l[g(1e3)]():[l]),s.fCOvn(_0x373e19,b)}}else return e.bsMmb(S,a)}let sn=65536,Xr=e[t(1718)],Ee=e[t(645)](sn,sn),Re=e[t(645)](Ee,Ee),tr=Re/2,Ne=String[t(390)+"e"][t(216)+"At"];class ge{constructor(n,s,l){let f=t;this[f(459)]=!0,this[f(275)]=e.eTFzl(0,n),this[f(946)]=e[f(986)](0,s),this[f(1170)]=!!l}static isLong(n){let s=t;return n&&e[s(1399)](!0,n[s(459)])}static fromBits(n,s,l){return new ge(n,s,l)}static[t(1678)+"s"](n,s,l){let f=t;return l?ge["fromByte"+f(505)](n,s):ge[f(1678)+f(200)](n,s)}static["fromByte"+t(505)](n,s){let l=t;return new ge(e[l(1666)](e[l(189)](n[0],e[l(457)](n[1],8)),e.SruCC(n[2],16))|n[3]<<24,e.gEMED(e.eTFzl(e.DcMcy(n[4],e[l(513)](n[5],8)),e[l(1428)](n[6],16)),e[l(708)](n[7],24)),s)}static[t(1678)+t(200)](n,s){let l=t;return new ge(e.OdsDL(e[l(340)](e[l(986)](n[4]<<24,e[l(234)](n[5],16)),e.HxliO(n[6],8)),n[7]),e[l(756)](e[l(1580)](n[0]<<24|e.ZEKyv(n[1],16),e[l(549)](n[2],8)),n[3]),s)}static fromHash(n){let s=t;return e[s(1669)](n,Xr)?ad:new ge(e[s(357)](e[s(426)](e[s(410)](e[s(448)](Ne[s(334)](n,0),e.TXWEw(Ne[s(334)](n,1),8)),Ne[s(334)](n,2)<<16),e[s(549)](Ne[s(334)](n,3),24)),0),e[s(225)](e[s(1571)](e[s(1227)](e[s(860)](Ne[s(334)](n,4),Ne[s(334)](n,5)<<8),e[s(1450)](Ne.call(n,6),16)),Ne[s(334)](n,7)<<24),0),!0)}[t(682)](){let n=t;return String[n(1372)+n(1609)](255&this.low,e.JbgiS(e.posxA(this[n(275)],8),255),e[n(895)](e[n(443)](this[n(275)],16),255),e.EZkNI(this[n(275)],24),e.JgEmy(255,this[n(946)]),e.lXNTe(this[n(946)]>>>8,255),e[n(1634)](e[n(1226)](this[n(946)],16),255),e[n(1629)](this.high,24))}static fromNumber(n,s=!0){let l=t;if(e[l(1728)](isNaN,n))return s?Gp:ad;if(s){if(n>=Re)return qp}else if(e[l(1569)](l(697),e[l(1610)])){if(e[l(759)](n,-tr))return jp;if(e.OhIGN(e[l(308)](n,1),tr))return Hp}else this[l(840)](l(431),_0x16cd43),this[l(1204)]&&this.onopen(_0x403e74);return ge[l(854)](e[l(1687)](n,Ee)|0,e[l(1388)](e[l(734)](n,Ee),0),s)}[t(527)](){let n=t;return this[n(1170)]?e.kmKGn(e[n(1007)](this[n(946)]>>>0,Ee),e[n(1570)](this[n(275)],0)):e[n(308)](e[n(1274)](this[n(946)],Ee),e[n(1178)](this[n(275)],0))}[t(831)](){let n=t;return e.GTofs(0,this[n(946)])&&this.low===0}add(n){let s=t;ge.isLong(n)||(n=ge[s(1418)+"er"](n));let l=e[s(194)](this[s(946)],16),f=e[s(1392)](65535,this[s(946)]),g=e.QAqSU(this[s(275)],16),b=65535&this[s(275)],E=n.high>>>16,p=e[s(1214)](65535,n[s(946)]),D=e[s(1180)](n.low,16),L=e.nJuwH(65535,n[s(275)]),N=0,M=0,G=0,ee=0;return ee+=e[s(586)](b,L),G+=e[s(194)](ee,16),ee&=65535,G+=e[s(1425)](g,D),M+=e[s(443)](G,16),G&=65535,M+=e[s(1626)](f,p),N+=e[s(1149)](M,16),M&=65535,N+=e[s(1275)](l,E),N&=65535,ge[s(854)](e[s(1289)](G<<16,ee),e[s(1571)](e[s(1427)](N,16),M),this[s(1170)])}[t(1689)](n){let s=t;return ge[s(459)](n)||(n=ge[s(1418)+"er"](n)),e[s(1454)](this[s(1170)],n.unsigned)&&e[s(1572)](e.ngEox(this[s(946)],31),1)&&e.yYRHg(e.ALOUr(n[s(946)],31),1)?!1:e.jkhqK(this[s(946)],n[s(946)])&&e[s(1685)](this.low,n[s(275)])}[t(722)](){let n=t;return e.GWbnl(-1,this[n(275)])&&e.GWbnl(-1,this[n(946)])?ge[n(854)](0,0,this[n(1170)]):e[n(1549)](-1,this.low)?ge[n(854)](0,this[n(946)]+1,this[n(1170)]):ge[n(854)](e[n(531)](this[n(275)],1),this[n(946)],this[n(1170)])}toBytes(n){let s=t;return n?this[s(890)+"E"]():this[s(816)+"E"]()}[t(890)+"E"](){let n=t,s=this[n(946)],l=this[n(275)];return[255&l,e.WlrEf(l>>>8,255),e[n(667)](l>>>16,255),e[n(1154)](l,24),e[n(1390)](255,s),e[n(524)](s>>>8,255),e[n(484)](s>>>16,255),e.rmMYt(s,24)]}[t(816)+"E"](){let n=t,s=this.high,l=this[n(275)];return[s>>>24,e[n(1406)](e[n(1154)](s,16),255),e[n(558)](e.nWQMT(s,8),255),255&s,e[n(620)](l,24),l>>>16&255,e[n(1243)](l>>>8,255),255&l]}}let ad=new ge(0,0,!1),Gp=new ge(0,0,!0),Hp=ge[t(854)](-1,2147483647,!1),qp=ge[t(854)](-1,-1,!0),jp=ge[t(854)](0,-2147483648,!1);var on=(function(a){let n=t,s=e[n(618)].split("|"),l=0;for(;;){switch(s[l++]){case"0":a[a[n(1021)+"RROR"]=5001]=e[n(1472)];continue;case"1":a[a[e.Abite]=5003]=e[n(595)];continue;case"2":return a;case"3":a[a[n(1409)+n(882)]=5002]=e[n(209)];continue;case"4":a[a[n(789)+"OR"]=5005]=e[n(1262)];continue;case"5":a[a[e[n(989)]]=5004]=e[n(989)];continue}break}})({});class nr{constructor(n){let s=t;this[s(1018)]=n,this.target=null}}class cd extends nr{constructor(n,s){let l=t;super(n),this[l(729)]=s&&s[l(729)]||null}}class ld extends nr{constructor(n,s){let l=t,f=e.Lixbu[l(1306)]("|"),g=0;for(;;){switch(f[g++]){case"0":this.lineno=s&&s[l(758)]||0;continue;case"1":this[l(571)]=s&&s.filename||"";continue;case"2":this[l(1051)]=s&&s[l(1051)]||null;continue;case"3":super(n);continue;case"4":this[l(729)]=s&&s.message||"";continue;case"5":this[l(416)]=s&&s[l(416)]||5001;continue;case"6":this[l(238)]=s&&s[l(238)]||0;continue}break}}}class dd extends nr{constructor(n,s){let l=t;if(e[l(1497)](e[l(1215)],e[l(1215)])){let f=this[l(193)][l(702)+l(797)+l(1361)](_0x4b68a7,_0x2d82fc);this[l(498)+l(740)+l(655)](_0x3ca5d1(e.fAGIn,{code:_0x439789,reason:_0x3a6e70,wasClean:!0,willReconnect:f})),f&&this._connect()}else{let f=e[l(451)][l(1306)]("|"),g=0;for(;;){switch(f[g++]){case"0":this[l(741)]=s&&s.reason||"";continue;case"1":this[l(465)]=s&&s[l(465)]||!1;continue;case"2":super(n);continue;case"3":this[l(416)]=s&&s.code||0;continue;case"4":this[l(1244)+l(1576)]=s&&s[l(1244)+l(1576)]||!1;continue}break}}}}class ud extends nr{constructor(n,s){let l=t;super(n),this[l(491)]=s&&s[l(491)]||null}}class fd extends ud{constructor(n,s){let l=t;super(n),this.data=s&&s.data||null,this.message=s&&s[l(729)]||null}}class xd extends nr{constructor(n,s){let l=t;super(n),this[l(491)]=s&&s.data||null}}function dt(a,{message:n,code:s,error:l}){return new ld(a,{message:n,code:s,error:l})}function yt(a,{code:n,reason:s,wasClean:l,willReconnect:f}){return new dd(a,{code:n,reason:s,wasClean:l,willReconnect:f})}function hd(a,{data:n,message:s}){return new fd(a,{data:n,message:s})}function pd(a,{data:n}){return new xd(a,{data:n})}function ya(a,{message:n}){return new cd(a,{message:n})}class gd{constructor(n,s){let l=t;if(e[l(1358)]!==e[l(567)])this[l(361)+"s"]=n,this.maxRetries=s,this[l(454)+l(616)]=0,this[l(314)+l(528)+l(763)+"t"]=0;else return this._isMiniTT||this[l(814)+"X"]?this["_miniNav"+l(744)+l(1328)]:(this[l(1493)+"er"]||this._isWorker)&&this[l(193)]["listenNe"+l(786)+"nged"]?_0x38fb92[l(863)]:!0}[t(1658)+t(1368)+t(903)](){let n=t;this[n(454)+n(616)]=0,this[n(314)+"ndpointT"+n(763)+"t"]=0}[t(992)+"es"](){let n=t;n(1449)===e[n(1324)]?(this[n(1703)]=!0,this._connect()):this[n(314)+n(528)+n(763)+"t"]=0}[t(1105)+"ntEndpoint"](){return this[t(361)+"s"][this.currentIndex]}[t(1105)+"ntEndpointTriesC"+t(1132)](){let n=t;return this[n(314)+n(528)+n(763)+"t"]}[t(937)+t(1483)+"es"](){let n=t;return!!(e[n(1611)](this[n(454)+n(616)],this[n(361)+"s"][n(748)])||e.ripGc(this[n(454)+n(616)],e[n(1116)](this[n(361)+"s"][n(748)],1))&&e[n(1391)](this["currentEndpointT"+n(763)+"t"],this[n(900)+"es"]))}[t(1615)+t(1193)+t(984)+t(896)+t(746)](){let n=t;return e[n(438)](this[n(454)+n(616)],this[n(361)+"s"][n(748)])?!0:e[n(1635)](this[n(314)+n(528)+n(763)+"t"],this[n(900)+"es"])}[t(227)+t(1562)+t(598)+t(754)+t(873)](){let n=t;return this[n(314)+"ndpointT"+n(763)+"t"]=1,this[n(454)+n(616)]++,this.endpoints[this[n(454)+n(616)]]}[t(1105)+t(1191)+t(1141)+t(1462)](){let n=t;return this["currentE"+n(528)+"riesCount"]++,this[n(1105)+n(1191)+"nt"]()}}let rr=(e[t(1729)](e.qWYkW,typeof globalThis)&&e.DsqGh(e.ylRKc,globalThis[t(436)+t(1257)].name)||e.KiLHY(t(1259)+"d",typeof window)&&e[t(485)]===window[t(436)+t(1257)].name)&&e[t(1729)](e[t(1342)],typeof document),Cn=e[t(1342)]!=typeof globalThis&&(e[t(1103)](e.hdini,globalThis[t(436)+"tor"][t(1701)])||e[t(366)](e[t(297)],globalThis["construc"+t(1257)][t(1701)]))&&e.wpPnn(e[t(1342)],typeof tt),Qr=(e[t(1355)](e.qWYkW,typeof globalThis)&&e.sirdt(e[t(1189)],globalThis[t(436)+t(1257)].name)||e[t(943)](e[t(1342)],typeof globalThis)||typeof globalThis<"u"&&!!globalThis.WeixinJSBridge)&&e[t(949)](e.qWYkW,typeof wx),ei=t(1259)+"d"!=typeof globalThis&&(e[t(1279)](e[t(297)],globalThis["construc"+t(1257)][t(1701)])||e[t(1256)]===globalThis["construc"+t(1257)].name||e.GTofs(e.UvMUD,globalThis[t(436)+"tor"][t(1701)]))&&e[t(1130)](e[t(1342)],typeof self),Wp=e[t(1012)](t(1259)+"d",typeof globalThis)&&e[t(1189)]===globalThis[t(436)+t(1257)].name&&e[t(949)](t(1259)+"d",typeof global)&&e.siWcJ(t(393),global[t(436)+t(1257)].name)&&e[t(252)](e[t(1342)],typeof process)&&!!process.version;class Ea{constructor(){let n=t;this[n(1673)+"rs"]={}}[t(840)](n,...s){let l=t,f=this[l(1673)+"rs"][n];if(f)f[l(968)]()[l(409)](g=>g.fn.apply(g.ctx,s));else if(e[l(1572)](e[l(1471)],n)&&!this.onerror){let g=s.length&&s[0];if(g instanceof Error)throw g;let b=new Error(e[l(312)](e[l(735)],g?e[l(1308)](e[l(624)](" (",g[l(729)]),")"):""));throw b[l(669)]=g,g}return this}[t(487)](n,s){let l=t;if(e.exPxs(void 0,n))this[l(1673)+"rs"]={};else if(e[l(511)](void 0,s))this[l(1673)+"rs"][n]=null;else{let f=this[l(1673)+"rs"][n];if(f)for(let g=0;g<f[l(748)];)e.WSuQO(f[g].fn,s)?f.splice(g,1):++g}return this}on(n,s,l){let f=t;return(this._listeners[n]||(this[f(1673)+"rs"][n]=[]))[f(268)]({fn:s,ctx:l||this}),this}}class Kp extends Ea{[t(1356)+t(1225)+t(835)](n){let s=t;return n[s(1119)]||n[s(1485)]?(s(843)+" "+(n.errMsg||"")+s(496)+(n.errNo||""))[s(1118)]():JSON[s(811)+"y"](n)}constructor(n,s,l){let f=t;super(),this[f(1511)]=null,Qr&&wx[f(615)+f(996)]&&(this[f(1511)]=wx[f(615)+"ocket"]({url:n,protocols:s,header:l,fail:this["_createSocketFai"+f(1555)][f(530)](this),success:this["_createS"+f(780)+f(1183)+"ler"][f(530)](this)})),Cn&&tt[f(615)+f(996)]&&(this[f(1511)]=tt.connectSocket({url:n,protocols:s,header:l,fail:this._createSocketFailHandler[f(530)](this),success:this[f(1077)+f(780)+f(1183)+f(1104)][f(530)](this)}))}[t(1077)+t(780)+t(1183)+"ler"](){Promise.resolve().then(()=>{let n=U;this[n(1046)+n(833)]()})}[t(1077)+"ocketFai"+t(1555)](n){let s=t;Promise[s(1456)]().then(()=>{let l=s,f={NYztR:e[l(666)]};if(e[l(651)](l(1026),e[l(660)])){let g=e[l(1478)](dt,e[l(1471)],{message:this[l(1356)+"rrorMessage"](n)});this[l(840)](e.AUXJX,g);let b=yt(e.fAGIn,{reason:this["_formatE"+l(1225)+"age"](n)});this[l(840)](e[l(637)],b)}else this[l(579)]&&this[l(579)][l(242)](_0x4aa05c),this[l(413)](f.NYztR,_0x3ade40)})}[t(1046)+t(833)](){let n=t,s={cuAYa:function(l,f,g){return e[U(1423)](l,f,g)},XOZlW:e[n(637)],AxNPV:n(1051)};this[n(1511)][n(421)](l=>{let f=n,g={bQkgy:function(b,E){return e.xLAxz(b,E)},MAGMZ:function(b,E){return e[U(1635)](b,E)},Ysdsj:function(b,E){return b(E)},nLCzH:function(b,E){return b+E},XOkcy:function(b,E){return e[U(610)](b,E)}};if(e[f(1001)](e[f(683)],f(537))){let b={eXyEv:function(N,M){return g.bQkgy(N,M)},Efahw:function(N,M){return g[f(967)](N,M)},HSrOL:function(N,M){return N(M)},pIchq:function(N,M){return g[f(967)](N,M)},ggwPy:function(N,M){return g[f(500)](N,M)},qVOUn:function(N,M){return N&M},IWekz:function(N,M){return g[f(1111)](N,M)},MOLlq:function(N,M){return N|M}},E=g[f(1041)](_0x2f3bfe,8192),p=E>>>1,D=null,L=E;return function(N){let M=f;if(b[M(258)](N,1)||b[M(775)](N,p))return b[M(1564)](_0xe791fe,N);b[M(265)](L+N,E)&&(D=b[M(792)](_0x4391b8,E),L=0);let G=_0x3a9f8a[M(334)](D,L,L+=N);return b.qVOUn(7,L)&&(L=b.IWekz(b[M(1250)](7,L),1)),G}}else this[f(840)](e[f(1148)],e[f(906)](pd,e.eZYkw,{...l,data:l[f(1119)]||""}))}),this[n(1511)][n(1335)](l=>{let f=n;this[f(840)](f(720),s.cuAYa(yt,s.XOZlW,{...l}))}),this[n(1511)][n(430)+"e"](l=>{let f=n;this[f(840)](f(729),s[f(878)](hd,f(729),{...l}))}),this._socket[n(1602)](l=>{let f=n;this[f(840)](s[f(493)],s[f(878)](dt,s.AxNPV,{...l,message:l.errMsg||""}))})}[t(242)](n){let s=t,l={kktVt:function(f,g){return e[U(942)](f,g)},WNyAL:"PnkSu",ChJTw:e[s(1471)],MPWVI:function(f,g,b){return e.PUACY(f,g,b)}};if(e[s(1296)](n,Uint8Array)){let f=n.buffer[s(968)](n[s(237)+"et"],e[s(547)](n[s(371)+"th"],n[s(237)+"et"]));this[s(1511)]&&this._socket.send({data:f,fail:g=>{let b=s;this[b(840)]("error",dt(e[b(1471)],{message:this[b(1356)+b(1225)+b(835)](g)}))}})}else this[s(1511)]&&this[s(1511)][s(242)]({data:n,fail:f=>{let g=s,b={lnYuC:function(E,p){return E(p)}};l.kktVt(l.WNyAL,l.WNyAL)?_0x4b4fd8[g(1055)+g(1545)]("upgraden"+g(217),E=>{let p=g;_0x279bc7(_0x537d28(_0x57c5de.result),E[p(712)+"on"],E[p(1309)+"on"],ZdIWlg.lnYuC(_0x5d0064,_0x553364[p(281)+p(977)]))}):this[g(840)](l[g(1312)],l[g(1677)](dt,"error",{message:this[g(1356)+g(1225)+g(835)](f)}))}})}[t(720)](n,s){let l=t;this._socket&&this[l(1511)][l(720)]({code:n,reason:s})}["addEvent"+t(1545)](n,s){let l=t,f={WiEwJ:function(g,b){return e.MyOQC(g,b)}};e[l(1188)](e[l(848)],l(1488))?this.on(n,s):lGvOjO[l(1247)](_0x81f87f,_0xb2ef4d)&&_0x503696[l(592)](_0x45f2cb,_0x5274f3)}[t(564)+t(947)+t(574)](n,s){this[t(487)](n,s)}get readyState(){let n=t;return this._socket[n(1648)+"te"]}get[t(204)+"pe"](){let n=t;return this[n(1511)][n(204)+"pe"]}set[t(204)+"pe"](n){}get[t(939)](){return this[t(1511)].url}get[t(1057)](){return this._socket.protocol}get[t(538)+"ns"](){let n=t;if(e[n(623)](e[n(985)],e.yBpUB))_0x20dafd=_0x5ae891.concat(_0x1e389c),_0x361ded=_0x51be40.concat(_0x11d788[_0x4c5292]);else return this[n(1511)].extensions}get[t(1205)+t(649)](){return 0}}function $p(a,n){let s=t;if(n)return new n(a[s(939)],a[s(1057)]);if(e[s(610)](Qr,Cn))return new Kp(a.url,a[s(1057)],a[s(1255)]);if(e.reXcC(rr,ei)&&e.qWYkW!=typeof WebSocket&&WebSocket)return new WebSocket(a[s(939)],a[s(1057)+"s"])}function Vp(a){let n=t,s="2|3|4|1|0"[n(1306)]("|"),l=0;for(;;){switch(s[l++]){case"0":return!1;case"1":if((rr||ei)&&e[n(1024)](e[n(1342)],typeof WebSocket)&&WebSocket)return!0;continue;case"2":if(a)return!0;continue;case"3":if(Qr&&wx["connectS"+n(996)])return!0;continue;case"4":if(Cn&&tt[n(615)+n(996)])return!0;continue}break}}function md(a,n,s){let l=t,f={gywzn:e[l(1173)],aRfix:function(E,p){return e[l(1399)](E,p)}},g=-1;async function b(E){let p=l;return E<=g?Promise[p(1058)](new Error(f[p(1691)])):(g=E,f.aRfix(E,s.length)?Promise[p(1456)]():s[E].bind(a)(n,b[p(530)](null,E+1)))}b(0)}function wd(a){let n=t;if(e.IyaNu(e.ePOki,e[n(502)])){let s=0,l=0;for(let f=0;e[n(1455)](f,a[n(748)]);++f)if(e[n(1403)]!==e.hdgqh){let g=this["_endpoin"+n(231)]?.[n(1105)+n(1191)+"nt"]();this[n(498)+"hCloseEv"+n(655)](e[n(1093)](_0x46eda0,e[n(637)],{code:_0x3b2d99[n(416)],reason:n(874)+n(976)+n(320)+"wn reaso"+n(239)+n(201)+g})),this[n(439)+"tManager"]?.[n(1658)+n(1368)+n(903)](),this[n(1468)+n(1083)]?.[n(1317)+"nter"]();return}else l=a[n(216)+"At"](f),e[n(540)](l,128)?s+=1:e.PsDir(l,2048)?s+=2:e[n(1090)](e[n(1349)](64512,l),55296)&&e.ntXPA(e.KoICq(64512,a.charCodeAt(e.wGMOu(f,1))),56320)?(++f,s+=4):s+=3;return s}else return this[n(361)+"s"][this[n(454)+n(616)]]}function _d(a,n,s){let l=t;if(e[l(710)](s,n)<1)return"";let f="";for(let g=n;e[l(325)](g,s);){let b=a[g++];if(e[l(1078)](b,127))f+=String["fromChar"+l(1609)](b);else if(e[l(1045)](b,192)&&e[l(1224)](b,224))f+=String[l(1372)+l(1609)](e[l(608)](e[l(604)](31,b),6)|e[l(1593)](63,a[g++]));else if(e[l(1639)](b,224)&&e[l(1033)](b,240))f+=String[l(1372)+"Code"](e.MDfQu(e.wqXuu(e.ogvTT(e.tmjqA(15,b),12),e[l(406)](e[l(1467)](63,a[g++]),6)),e.QZkfZ(63,a[g++])));else if(e[l(1232)](b,240)){let E=e[l(717)](e.EvOCA(e.XTUXb(e[l(503)](e[l(1165)](7,b),18),e[l(444)](e.RmzTZ(63,a[g++]),12)),e.ogvTT(e[l(728)](63,a[g++]),6)),e.WKBXz(63,a[g++]))-65536;f+=String[l(1372)+l(1609)](e[l(355)](55296,e[l(813)](E,10))),f+=String[l(1372)+l(1609)](e[l(921)](56320,e[l(1458)](1023,E)))}}return f}function ba(a,n,s){let l=t,f=s,g,b;for(let E=0;E<a[l(748)];++E)g=a.charCodeAt(E),e[l(1022)](g,128)?n[s++]=g:e[l(1142)](g,2048)?(n[s++]=e[l(713)](e[l(1551)](g,6),192),n[s++]=e[l(290)](e[l(920)](63,g),128)):e[l(651)](e[l(1241)](64512,g),55296)&&e[l(1016)](64512,b=a[l(216)+"At"](e[l(830)](E,1)))===56320?(g=e[l(1216)](e[l(1238)](65536,(1023&g)<<10),e[l(1405)](1023,b)),++E,n[s++]=e.ZuNNK(e.BJFmI(g,18),240),n[s++]=e[l(935)](e[l(301)](g,12)&63,128),n[s++]=e[l(1037)](e[l(703)](e[l(588)](g,6),63),128),n[s++]=e.jUOsD(e[l(349)](63,g),128)):(n[s++]=g>>12|224,n[s++]=e[l(938)](e[l(1705)](g,6)&63,128),n[s++]=e[l(1069)](63&g,128));return s-f}async function yd(a){let n=t,s={hUIEk:function(l,f){return e[U(1061)](l,f)}};if(e.Gdrqf(e[n(1644)],typeof a))if(e[n(963)]!==e.mPYne)_0x472c47=BVvVDp.hUIEk(_0x20b179,_0x8c6227);else{let l=new Uint8Array(e[n(1621)](wd,a));return ba(a,l,0),l}return e.zGiUf(a,ArrayBuffer)?new Uint8Array(a):new Uint8Array(a[n(1054)],a[n(237)+"et"],a[n(371)+"th"])}function Zp(a){let n=t;try{return e[n(1024)](n(1218),typeof a)&&(a instanceof ArrayBuffer||a[n(1054)]&&e.OjkBl(a[n(1054)],ArrayBuffer))||e[n(1130)](e.oaGdu,typeof a)?"":(JSON[n(913)](a),e[n(363)])}catch{return e.oaGdu==typeof a?n(317)+n(544)+n(440):""}}let Jp=(a,n)=>{let s=t;switch(a){case s(1447):case e[s(790)]:return{[s(1329)+a]:1,"x-tt-env":n};default:return{}}};class Yp{constructor(n){let s=t;this[s(661)+s(1132)]=n,this[s(445)]=0}addCount(){let n=t;this[n(445)]++}checkReachMaxCount(){let n=t;return e[n(1045)](this.count,this[n(661)+n(1132)])}["resetCou"+t(867)](n=0){let s=t,l={cARce:function(f,g){return e[U(1385)](f,g)},UzEDk:function(f,g){return e.gGQLi(f,g)},hGtnT:function(f,g){return e.qyyMB(f,g)},XhjGA:function(f,g){return e[U(803)](f,g)},eSLsf:function(f,g){return e.JgiOl(f,g)},LzNUC:function(f,g){return f&g},UETUj:function(f,g){return e.NZsis(f,g)},NMyuZ:function(f,g){return f(g)}};e[s(928)]==="IyxGY"?(_0x1d05d8=_0x427a97[oZzuAv.cARce(oZzuAv.cARce(_0x24d50c,_0x3aad2f),1)],oZzuAv[s(916)](oZzuAv[s(1513)](192,_0x3edb25),128)?_0x31e282+=_0x2fd377:(_0x4ca529=oZzuAv[s(1662)](oZzuAv.eSLsf(31&_0x23b65b,6),oZzuAv[s(235)](63,_0x24941d)),oZzuAv[s(1446)](_0x242a8b,128)?_0x1ac0de+=_0x18efcc:(_0xa8aece+=oZzuAv.NMyuZ(_0x5c4e54,_0x35eef0),_0x1f0bdd++))):(this[s(661)+s(1132)]=n,this[s(445)]=0)}}async function Xp(a){let n=t,s={LksLB:function(l,f){return e[U(1569)](l,f)},nSXyF:e.okabB,kKygl:e[n(497)],AbGlR:function(l,f){return l+f},Vapst:e[n(970)],QRWke:e.xOqRe,TLAbg:function(l,f){return e[n(1518)](l,f)},voOuh:"FKbuA",gpVKS:function(l,f){return e[n(395)](l,f)}};return new Promise(l=>{let f=n,g={TjATO:"received",mHRXz:function(b,E){return s[U(997)](b,E)},kBbSg:s[f(316)],HpQEx:s[f(1245)]};if(!rr)return l(s[f(1245)]);try{let b=document[f(1369)+"ement"]("script");window[f(1052)+f(1025)]=E=>{let p=f,D={DfOIM:g[p(1481)],zgKAH:function(L){return L()}};g[p(599)](g[p(638)],g[p(638)])?(this._debug(D.DfOIM,_0x23b847[p(729)]),D[p(507)](_0x40285c)):(document[p(627)][p(952)+p(897)](b),window[p(1052)+p(1025)]=void 0,l(E&&E[p(1072)]||g.HpQEx))},b[f(1018)]=f(307)+f(455),b[f(785)]=s[f(396)](a[f(259)](/^ws/,s.Vapst),s[f(529)]);try{document.body[f(1495)+f(897)](b)}catch{document.body[f(952)+f(897)](b)}}catch{if(s.TLAbg(s[f(658)],s.voOuh))window[f(1052)+"JSONP"]=void 0,s[f(270)](l,s[f(1245)]);else return!!this[f(414)]}})}function an(a,n,s){let l=t;return!!a?.[l(517)](f=>f[l(1617)]===n&&f[l(338)]===s)}function ir(a,n){let s=t;return a?.[s(517)](l=>l[s(1617)]===n)?.value}let va=null;async function Qp(){let a=t;return va||(va=Promise[a(1456)]()[a(255)](Ft.bind(Ft,e[a(1087)]))),va}class eg extends Ea{constructor(n,s){let l=t;super(),this[l(463)]=n,this[l(1693)]=s,this[l(414)]=void 0,this[l(1637)+"mise"]=null}async[t(1494)](){await this[t(1590)]()}async[t(1590)](){let n=t;if(!this[n(414)]){if(this[n(1637)+n(1581)])return this[n(1637)+n(1581)];try{if(e[n(1103)](n(1011),n(210)))_0x31ad75[n(268)](_0x183f86);else{let s=this[n(463)],l=this[n(1693)];this[n(1637)+n(1581)]=(async()=>{let f=n,{openDB:g}=await e.uhWRX(Qp);this[f(414)]=await e[f(1063)](g,f(1052)+"_"+s,1,{upgrade(b){b[f(1261)+"jectStore"](s,{keyPath:l})}})})(),await this[n(1637)+n(1581)]}}catch(s){console.log(s)}finally{this[n(1637)+n(1581)]=null}}}async[t(353)](n){let s=t;try{return await this[s(1590)](),this[s(414)]?.get(this[s(463)],n)}catch(l){console[s(578)](l)}}async[t(592)](n,s){let l=t;return await this[l(1590)](),this[l(414)]?.[l(629)](this[l(463)],n)}async del(n){let s=t;try{return await this[s(1590)](),this._qosDB?.delete(this[s(463)],n)}catch(l){console[s(578)](l)}}async[t(912)](){let n=t;try{return await this._init(),this._qosDB?.[n(912)](this._dbName)}catch(s){console.log(s)}}async keys(){let n=t;return await this._init(),this._qosDB?.[n(1195)+"ys"](this[n(463)])}async[t(1378)](){let n=t;return await this[n(1590)](),this._qosDB?.getAll(this[n(463)])}async[t(1507)](){let n=t,s={ahjCo:function(l,f){return l||f}};try{this[n(414)]?.[n(720)](),this._qosDB=void 0}catch(l){if(e.pvHZA(n(1719),e[n(514)])){let f=this[n(414)][n(1266)+n(1546)](this[n(978)]),g=_0x1d2ac0[n(913)](s[n(958)](f,"{}"));return g[_0x3a4cf0||_0x2289a1[this._pathKey]]=_0xa6c741,this[n(414)][n(971)+"geSync"](this[n(978)],_0x4c327e[n(811)+"y"](g)),_0x18fc49||_0x2a9f3f[this._pathKey]}else console[n(578)](l)}}get[t(675)](){let n=t;try{return!!this[n(414)]}catch(s){return console[n(578)](s),!1}}}class tg{constructor(n,s){let l=t;this._DBName=n,this[l(955)]=s,this[l(414)]=localStorage}async[t(1494)](){}get[t(978)](){return"frontier_"+this[t(676)]}async[t(353)](n){let s=t,l=this[s(414)][s(1208)](this[s(978)]);return JSON[s(913)](l||"{}")[n]}async[t(592)](n,s){let l=t,f=this._qosDB[l(1208)](this[l(978)]),g=JSON[l(913)](f||"{}");return g[s||n[this._pathKey]]=n,this[l(414)][l(299)](this[l(978)],JSON.stringify(g)),s||n[this._pathKey]}async[t(1292)](n){let s=t,l=this._qosDB.getItem(this._prefix),f=JSON[s(913)](e[s(378)](l,"{}"));return f[n]=void 0,this._qosDB[s(299)](this[s(978)],JSON.stringify(f))}async[t(912)](){let n=t;return this[n(414)][n(912)]()}async[t(590)](){let n=t,s=this[n(414)].getItem(this[n(978)]),l=JSON.parse(s||"{}");return Object.keys(l)}async[t(1378)](){let n=t,s={pcsCd:e.jFCJI,AmvJY:function(l,f){return l(f)}};if(e[n(1624)](e[n(1526)],e[n(1526)])){let l=_0x1641c6[n(641)+n(1432)](_0x44f0f2);return _0x55a836&&l[n(1055)+"Listener"](KqeVSc[n(521)],()=>_0x1ebcf5()),KqeVSc.AmvJY(_0x422b32,l)[n(255)](()=>{})}else{let l=this[n(414)][n(1208)](this[n(978)]),f=JSON[n(913)](e[n(610)](l,"{}"));return Object[n(489)](f)}}closeDB(){return Promise.resolve()}get[t(675)](){return!!this[t(414)]}}class ng{constructor(n,s){let l=t;if(e.NCzjb(e[l(523)],e[l(1713)]))return _0xdee54[l(1371)][e[l(277)](_0x50cbde,_0x5ce947,1)];this[l(676)]=n,this[l(955)]=s,this[l(414)]=Cn?tt:Qr?wx:null}async[t(1494)](){}get[t(978)](){let n=t;return n(1052)+"_"+this[n(676)]}async get(n){let s=t;if(e[s(1399)](e[s(876)],e[s(876)])){let l=this._qosDB[s(1266)+s(1546)](this[s(978)]);return JSON[s(913)](e[s(446)](l,"{}"))[n]}else e.cfZfe(_0x34c27e,this,_0x37d5ed,[_0x421699,_0xa627fe,_0x5ea597,_0x33d754,_0x484279,_0x351615])}async[t(592)](n,s){let l=t,f={vqaXo:function(g,b,E){return g(b,E)},jVstd:e[l(187)]};if(e[l(1628)](e[l(1146)],e[l(516)])){let g=this._qosDB[l(1266)+l(1546)](this[l(978)]),b=JSON[l(913)](e.reXcC(g,"{}"));return b[s||n[this[l(955)]]]=n,this[l(414)][l(971)+l(1546)](this[l(978)],JSON[l(811)+"y"](b)),s||n[this[l(955)]]}else this[l(1625)+l(1618)]=_0x1c94f7,this[l(1030)+l(1019)]=_0x552bec,this[l(832)+l(176)]=_0x249a87,this._qosDB=f.vqaXo(_0x4f5bb8,this[l(1625)+l(1618)],f[l(319)])}async[t(1292)](n){let s=t,l=this[s(414)]["getStora"+s(1546)](this[s(978)]),f=JSON[s(913)](e[s(378)](l,"{}"));return f[n]=void 0,this._qosDB[s(971)+s(1546)](this._prefix,JSON[s(811)+"y"](f))}async[t(912)](){return this[t(414)].clearStorageSync()}async[t(590)](){let n=t,s=this[n(414)].getStorageInfoSync(this[n(978)]),l=JSON.parse(s||"{}");return Object[n(590)](l)}async[t(1378)](){let n=t,s={LupFT:function(l,f){return e[U(1415)](l,f)}};if(e[n(609)]===e[n(1723)])_0x479dad+=ucHIqQ[n(1303)](_0x3650cd,_0x5df31a),_0xbed07d++;else{let l=this[n(414)]["getStora"+n(856)+"nc"](this._prefix),f=JSON.parse(e[n(452)](l,"{}"));return Object[n(489)](f)}}[t(1507)](){return Promise[t(1456)]()}get[t(675)](){return!!this._qosDB}}function Ed(a,n){let s=t;if(e[s(1531)](Cn,Cn))return new ng(a,n);if((rr||ei)&&s(1259)+"d"!=typeof indexedDB)return new eg(a,n);if((rr||ei)&&e[s(1355)](s(1259)+"d",typeof localStorage))return new tg(a,n);throw new Error(e[s(829)])}class rg{constructor(){let n=t;if(e.GreJM(e.FYwob,e[n(1382)]))return nWANkM.HaqOY(_0x123515,_0x18476f[n(1614)](_0x1b8516(this),_0x4436fd));this._intervalTimeoutId=null,this._interval=36e5,this[n(414)]=e[n(1059)](Ed,e[n(1047)],"message_id")}async["_interva"+t(788)](){let n=t;e[n(1404)](clearInterval,this["_interva"+n(656)+"Id"]),this._intervalTimeoutId=setInterval(()=>{let s=n;this[s(1249)+s(1720)]()},this[n(1124)+"l"])}async[t(1494)](){let n=t,s={UIMxE:e[n(1110)],UuOZJ:function(l,f){return e.ynBSI(l,f)},YFNyf:e[n(799)],KbjKv:n(1433)};await this[n(414)][n(1494)]()[n(255)](()=>{let l=n;s[l(956)](s[l(1145)],s[l(988)])?this._intervalFlush():(this[l(840)](s[l(1563)],_0x910c17),this.onmessage&&this[l(1451)+"e"](_0x36efbe))})}async[t(1249)+"ired"](){let n=t;if(e.ZdQBp("crcZf",e.ZcBxR))(await this[n(414)]?.[n(1378)]()||[]).filter(({timestamp:f})=>f<Date[n(1509)]())[n(409)](f=>{let g=n;this[g(414)]?.[g(1292)](f[g(1699)+"id"])});else{let s=_0x46ea44[n(748)]&&_0xaa3c25[0];if(e[n(1435)](s,_0x3a2afc))throw s;let l=new _0x30ca06(e[n(1005)](e[n(735)],s?e.hvNUQ(" (",s[n(729)])+")":""));throw l[n(669)]=s,s}}async[t(1292)](n){let s=t;if(e[s(1681)](e.pVdaP,e[s(1365)]))return this[s(414)]?.[s(1292)](n);this[s(579)]&&this._ws[s(720)](_0x387e89,_0x321c7b)}async[t(592)](n,s){let l=t;if(e[l(918)]!==e[l(918)]){let f=0,g=[];for(;e[l(1668)](f,_0x179189[l(371)+"th"]);){let{offset:b}=e.HIBTW(_0x3f1753,_0x2f8c20,f);f=b;let E={cursor_name:"",cursor:0,service:0},{value:p,offset:D}=_0x2d693b(_0x5bc3a8,f);E[l(1196)]=p,f=D;let{value:L,offset:N}=e.GvgWI(_0x5245a4,_0x3506e7,f);f=N,E[l(1300)+l(1017)]=e[l(256)](_0x58a399,_0x3513f0,f,f+L),f+=L;let{value:M,offset:G}=_0x3c9206(_0x485f9e,f);E[l(787)]=M[l(527)](),f=G,g[l(268)](E)}return g}else return this[l(414)]?.[l(592)]({message_id:n,timestamp:s})}async[t(353)](n){let s=t;return this[s(414)]?.[s(353)](n)}async[t(1507)](){let n=t;e.kejmY(clearInterval,this[n(1124)+n(656)+"Id"]),await this[n(414)]?.[n(1507)]()}get[t(675)](){let n=t;return this[n(414)]?.[n(675)]}}function Sa(a){let n=t,s=!!this._options[n(285)+"S"];if(!s)return{enabled:s,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let l=e[n(1294)](an,a[n(729)].headers,e[n(647)],"2"),f=l&&e[n(1465)](an,a[n(729)][n(1255)],e[n(773)],"1"),g=l&&e[n(1588)](an,a.message[n(1255)],n(630)+n(1660)+"k","1"),b=g?e[n(1557)](ir,a[n(729)][n(1255)],e.OhXDL)?.[n(1306)](",")[n(1109)](Boolean)||[]:[];return{enabled:s,isQoSMessage:l,isQoSAck:f,isAckCleanupMessage:g,ackMsgIds:b}}async function bd(){let a=t;return this[a(437)+a(1548)]||(this[a(437)+a(1548)]=new rg),this[a(437)+a(1548)][a(675)]||await this[a(437)+a(1548)].openDB(),this[a(437)+"ger"]}async function ig(a,n){let s=t,{enableAutoAck:l}=this[s(193)],f=e[s(256)](an,a[s(729)].headers,e[s(552)],"1"),g=e[s(1313)](an,a[s(729)][s(1255)],e.QaNlt,"1"),b=Sa[s(334)](this,a);if(e[s(794)](l,f)){let{SeqID:E,LogID:p,service:D,LogIDNew:L,method:N}=a.message;this[s(940)]({SeqID:E,LogID:p,LogIDNew:L,service:D,method:N,headers:[{key:e[s(1343)],value:"1"},{key:e.JpqDy,value:e[s(452)](L,"")},{key:e.McfUe,value:"0"}]})}g&&!b.isQoSAck&&this["_dispatc"+s(981)+s(263)](a),e[s(276)](n)}async function sg(a,n){let s=t;e.NCzjb(e[s(1357)],e.Wiiwg)?(this[s(414)]?.[s(720)](),this[s(414)]=void 0):(this[s(413)](e.MwEOs,a.message),e[s(828)](n))}async function og(a,n){let s=t,l=rn(await e.hizsq(yd,a[s(491)]));try{if(l.payload instanceof Uint8Array){let f=e[s(685)](this[s(193)][s(1487)+s(1075)],Object)?{force:!!this[s(193)][s(1487)+"ncoding"][s(1237)],encoding:this[s(193)][s(1487)+s(1075)][s(965)]?this[s(193)][s(1487)+s(1075)].encoding[s(259)](/\s/g,"")[s(394)+s(1486)]():""}:{force:!1,encoding:this[s(193)][s(1487)+"ncoding"]?this[s(193)][s(1487)+"ncoding"].replace(/\s/g,"")["toLowerC"+s(1486)]():""},g=l[s(1487)+"ncoding"]?l[s(1487)+s(1075)].replace(/\s/g,"")[s(394)+"ase"]():"",b=e.XUlyY(this[s(193)][s(492)+s(1235)],Object)?{force:!!this._options[s(492)+s(1235)].force,type:this._options[s(492)+"ype"][s(1018)]?this[s(193)]["payloadT"+s(1235)].type[s(259)](/\s/g,"")["toLowerC"+s(1486)]():""}:{force:!1,type:this[s(193)].payloadType?this[s(193)].payloadType[s(259)](/\s/g,"")[s(394)+s(1486)]():""},E=l[s(492)+"ype"]?l["payloadT"+s(1235)][s(259)](/\s/g,"")[s(394)+s(1486)]():"",p=b[s(1237)]?b[s(1018)]:E||b[s(1018)],D=f.force?f[s(965)]:g||f[s(965)],L=[e[s(569)],e[s(363)],"application/json;charset=utf-8",s(1218)],N=[e[s(550)],e.yfqtd];this._options[s(264)+s(1682)+s(1283)+"ad"]&&L.includes(p)&&(!D||N[s(1332)](D))?l["textPayl"+s(865)]=e.hbtWE(_d,l.payload,0,l.payload.byteLength):l[s(1164)+s(865)]=""}else l.textPayload=""}catch(f){l["textPayl"+s(865)]="",console[s(578)](f)}a[s(729)]=l,e[s(1036)](n)}function ag(a,n,s){let l={FIdQV:function(p,D){return e[U(1635)](p,D)},ppzcK:function(p,D){return e[U(866)](p,D)},nTTxy:function(p,D){return e[U(1404)](p,D)},ODdVl:function(p,D){return p&D},fhCvF:function(p,D){return p+D},HQHUm:function(p,D){return e[U(1666)](p,D)}},f=s||8192,g=e.GAnEg(f,1),b=null,E=f;return function(p){let D=U;if(p<1||l[D(782)](p,g))return a(p);l[D(782)](l[D(1649)](E,p),f)&&(b=l.nTTxy(a,f),E=0);let L=n[D(334)](b,E,E+=p);return l.ODdVl(7,E)&&(E=l[D(1397)](l[D(1325)](7,E),1)),L}}let cg=4294967295;function lg(a,n,s){let l=t;return e[l(250)](l(1153),l(1153))?new _0x5f4f4b(e[l(391)](e[l(311)](e[l(1666)](e.raazt(_0x3bdb32[4],24),e[l(449)](_0x19f7d9[5],16)),e[l(608)](_0x4152e1[6],8)),_0x1b8038[7]),e[l(698)](e[l(1367)](_0x192dcc[0]<<24,e.qhwmH(_0x150710[1],16)),e.DsKlB(_0x93b1ec[2],8))|_0x251f4f[3],_0x50b46):RangeError(e.WzHWm(e[l(932)](e.voOis(e.iNSPY(e.mVEsz,a),e.XVSUI),e[l(536)](n,1))+e[l(923)],s))}function dg(a,n,s){let l=t,f={CJeKa:e[l(749)],YublX:e[l(1471)],FQjmL:e[l(637)],WagJp:e[l(1148)],fOcSQ:l(729)};if(e.scFVM(e.WlDGj,l(898))){if(e[l(350)](s,cg))throw new Error(e[l(1550)]);let g=3;for(;g>=0;){let b=e.JgEmy(255,s);e[l(199)](Aa,b,a,n+g),s>>>=8,g--}return e[l(864)](n,4)}else{let g=f[l(1050)][l(1306)]("|"),b=0;for(;;){switch(g[b++]){case"0":this[l(579)][l(564)+"entListe"+l(574)](f.YublX,this[l(1429)]);continue;case"1":this[l(579)]["removeEventListe"+l(574)](f[l(388)],this._onClose);continue;case"2":this[l(579)][l(564)+l(947)+l(574)](f.WagJp,this._onOpen);continue;case"3":this[l(579)][l(564)+l(947)+l(574)](f[l(1582)],this[l(288)+"ge"]);continue;case"4":if(!this[l(579)])return;continue}break}}}function ug(a,n){let s=t,l=0,f=n,g=e[s(1540)](n,4);for(;e[s(723)](f,g);){let{value:b,offset:E}=e[s(313)](Ia,a,f);f=E,l=e.SruCC(l,8)>>>0,l+=b}return{value:l,offset:g}}function fg(a,n,s){let l=t,f=(l(1318)+"2")[l(1306)]("|"),g=0;for(;;){switch(f[g++]){case"0":if(n.utf8Write)return e[l(864)](n[l(1525)+"e"](a,s),s);continue;case"1":if(!a)return s;continue;case"2":return e[l(433)](e[l(1587)](ba,a,n,s),s);case"3":if(n.write)return e[l(586)](n.write(a,s),s);continue;case"4":if(a[l(748)]<40)return e[l(690)](e.EFgne(ba,a,n,s),s);continue}break}}function xg(a,n){let s=t,l=new ge(e[s(756)](e[s(260)](e[s(736)](e.EpUHl(a[e[s(1337)](n,4)],24),a[e[s(1216)](n,5)]<<16),e.KlznS(a[n+6],8)),a[e.TayHt(n,7)]),e.xbbIN(e[s(559)](e[s(323)](a[e[s(486)](n,0)],24),e[s(1498)](a[e[s(422)](n,1)],16)),a[n+2]<<8)|a[n+3],!0);return n+=8,{value:l,offset:e[s(1337)](n,8)}}function hg(a,n,s){let l=t,f=a.low,g=a.high;return n[s]=g>>>24,n[e[l(809)](s,1)]=e[l(417)](g>>>16,255),n[e.RgxwT(s,2)]=e[l(524)](e[l(1272)](g,8),255),n[e.xXinD(s,3)]=e[l(1349)](255,g),n[s+4]=f>>>24,n[e.WCiEG(s,5)]=e[l(804)](e[l(296)](f,16),255),n[s+6]=e[l(1520)](f,8)&255,n[e[l(607)](s,7)]=e.tWEYM(255,f),s+=8,s}function Ia(a,n){let s=t;return a[s(596)+"8"]?{value:a[s(596)+"8"](n),offset:e[s(547)](n,1)}:{value:e[s(327)](255,a[n]),offset:e[s(1667)](n,1)}}function Aa(a,n,s){let l=t;return n[l(836)+"t8"]?n[l(836)+"t8"](a,s):n[s]=e.vcnul(255,a),e[l(312)](s,1)}let pg=function(a){return new Uint8Array(a)},gg=e[t(213)](e[t(1342)],typeof Buffer)?Buffer["allocUns"+t(220)]:e[t(1510)](ag,pg,Uint8Array[t(390)+"e"][t(930)]);(()=>{let a=t,n={epHYf:e[a(241)],StAdo:function(s,l){return s<l},VlxWZ:function(s,l){return e[a(375)](s,l)},oKnCT:function(s,l){return e[a(1594)](s,l)},ifLlE:function(s,l){return s>>>l},sbKwF:function(s,l){return e.QPlgV(s,l)},zPeeA:function(s,l){return e.dWaGR(s,l)},jZGcb:function(s,l){return s<l},eCTsI:function(s,l){return s<<l},hlLDc:function(s,l){return e[a(998)](s,l)},UFCeu:function(s,l){return e[a(1514)](s,l)},IqUYR:function(s,l){return e.QAqSU(s,l)},UicZR:function(s,l){return s&l}};if(e.bZOmr(e.CbkrQ,a(522)))return _0x18ccc4[a(836)+"t8"]?_0x4ef581[a(836)+"t8"](_0x29a78e,_0x3808ac):_0x561fd8[_0x35c680]=e.sQbZK(255,_0xd0b794),e.DXxNW(_0x48b8f7,1);{let s=4294967295;return function(l,f,g=!0){let b=a,E=n[b(1650)].split("|"),p=0;for(;;){switch(E[p++]){case"0":if(n.StAdo(l[f++],128))return{value:g?s:n[b(1034)](0,s),offset:f};continue;case"1":if(n[b(639)](l[f++],128))return{value:g?s:0|s,offset:f};continue;case"2":s=n[b(1645)](n[b(1034)](s,n[b(1700)](n[b(1096)](15,l[f]),28)),0);continue;case"3":s=n[b(1096)](127,l[f])>>>0;continue;case"4":return{value:g?s:0|s,offset:f};case"5":if(n[b(678)](l[f++],128))return{value:g?s:n[b(1034)](0,s),offset:f};continue;case"6":s=n[b(1034)](s,n.eCTsI(127&l[f],7))>>>0;continue;case"7":if(n.hlLDc(l[f++],128))return{value:g?s:n[b(1034)](0,s),offset:f};continue;case"8":s=n[b(1645)](n[b(1034)](s,n[b(1137)](n[b(1096)](127,l[f]),14)),0);continue;case"9":if((f+=5)>l[b(748)])throw f=l[b(748)],lg(f,10,l[b(748)]);continue;case"10":s=n[b(1616)](s|n[b(1198)](n[b(1042)](127,l[f]),21),0);continue;case"11":if(l[f++]<128)return{value:g?s:0|s,offset:f};continue}break}}}})();let mg=16,ka=32;function wg(a){let n=t,s=0,l={};for(let f=0;e[n(218)](f,a[n(748)]);f++)l[a[f][n(1300)+n(1017)]]=e[n(272)](wd,a[f][n(1300)+"ame"]),s+=14+l[a[f]["cursor_n"+n(1017)]];return[s,l]}function vd(a,n,s){let l=t,[f,g]=wg(a),b=e[l(1201)](gg,f),E=0;return a.forEach(p=>{let D=l;console[D(578)](e[D(1270)],p,p[D(1196)]),E=Aa(0,b,E),console[D(578)](e[D(1599)],E),E=e[D(1532)](dg,b,E,p[D(1196)]||0),console[D(578)](e[D(1354)],E),E=Aa(g[p["cursor_n"+D(1017)]],b,E),console.log(e[D(188)],E),E=fg(p["cursor_n"+D(1017)],b,E),console.log(e.Atoel,E),E=e[D(1522)](hg,ge[D(1418)+"er"](p[D(787)]||n),b,E),console.log(e[D(376)],E)}),{frameType:ka,headers:[{key:l(460)+l(1095),value:s}],payload:b}}function _g(a){let n=t;if(e.MUOVB===e[n(428)])return _0x386c38[n(578)](e[n(1254)],_0x48aaff,_0x387243,_0x558e5e),this[n(414)][n(592)]({cursor_name:_0xbce350,cursor:_0xf7d618,service:_0x1e1ce2});{let s=0,l=[];for(;e[n(1033)](s,a[n(371)+"th"]);){let{offset:f}=e[n(277)](Ia,a,s);s=f;let g={cursor_name:"",cursor:0,service:0},{value:b,offset:E}=ug(a,s);g[n(1196)]=b,s=E;let{value:p,offset:D}=e.MoBqp(Ia,a,s);s=D,g[n(1300)+n(1017)]=e[n(254)](_d,a,s,e[n(1079)](s,p)),s+=p;let{value:L,offset:N}=e[n(243)](xg,a,s);g[n(787)]=L[n(527)](),s=N,l.push(g)}return l}}function yg(){let a=t;if(e[a(686)](e[a(330)],e[a(330)]))return{frameType:ka,headers:[{key:"cursor_f"+a(1095),value:e[a(543)]}],payload:void 0};{let n=e[a(1031)](_0x5822cc,a(1051),{message:_0x28d0d3[a(729)],code:_0x2407ad[a(789)+"OR"],error:_0x420074});this[a(498)+a(1194)+a(655)](n)}}class Eg{constructor(n,s,l){let f=t;this._cursorNameSpace=n,this[f(1030)+f(1019)]=s,this[f(832)+"Strategy"]=l,this[f(414)]=Ed(this[f(1625)+f(1618)],e[f(187)])}async[t(1494)](){let n=t;if(e.ZdQBp(e[n(286)],e[n(1085)])){if(this[n(193)][n(1538)+n(766)+n(387)]||this[n(1608)+n(576)])return;this[n(380)+"econnect"]()}else await this[n(414)][n(1494)]()}async[t(1192)+"rs"](){let n=t;if(!this[n(414)][n(675)])return;let s=this[n(832)+n(176)],l=await this[n(414)][n(1378)]();switch(console.log(n(891)+"rValues",l),s){case n(1134):return l&&l[n(748)]?e[n(1522)](vd,l,0,this[n(1030)+n(1019)]):void 0;case n(1709):return;case e.lONkh:return l&&l[n(748)]?e[n(1522)](vd,l,0,this[n(1030)+n(1019)]):e[n(1386)](yg)}}async set(n,s,l){let f=t;return console[f(578)](e.KsXpu,n,s,l),this._qosDB[f(592)]({cursor_name:n,cursor:s,service:l})}async[t(1475)+"rs"](n){let s=t,l=_g(n);for(let f of l)console[s(578)](e.NGZoY,l),await this[s(414)][s(592)](f)}async get(n){let s=t;return(await this[s(414)][s(353)](n))?.cursor}async[t(1507)](){let n=t;await this[n(414)][n(1507)]()}[t(377)+t(462)+t(266)](n){let s=t;this[s(1030)+"ileName"]=n}get isReady(){let n=t;return this[n(414)][n(675)]}}let bg=e[t(271)];async function Sd(a){let n=t;if(!this[n(193)][n(285)+"S"])return null;let{aID:s,fpID:l,messageStrategy:f}=this[n(193)],g=a||bg;try{return this[n(653)+n(931)]?a&&this[n(653)+n(931)][n(377)+n(462)+n(266)](a):this[n(653)+"anager"]=new Eg(l+"_"+s+"_"+g,g,f),this[n(653)+n(931)][n(675)]||await this[n(653)+n(931)].openDB(),this[n(653)+n(931)]}catch{if(e[n(1492)]!==n(232))return null;this[n(487)](_0x4020a9,_0x500ad3)}}async function vg(a,n){let s=t,l=e[s(1588)](an,a.message[s(1255)],e[s(501)],"-1"),f=e[s(526)](an,a[s(729)][s(1255)],s(1370),"1"),g=e[s(696)](ir,a.message.headers,e[s(680)]),b=Number(e.TaQzO(ir,a[s(729)][s(1255)],s(630)+s(369)))||0,E=Sa[s(334)](this,a),p=e.ivDcM(an,a[s(729)][s(1255)],e[s(1463)],"2"),D=e[s(594)](ir,a.message.headers,e[s(1263)]),L=e[s(1336)](Number,e[s(368)](ir,a.message.headers,e[s(1267)]));if(E.isQoSAck)return e.wjGng(n);let N=E["isQoSMes"+s(1278)]?await bd.call(this):null;if(e.hywpZ(a[s(729)].service,0)&&f&&!l||e[s(619)](a.message[s(1196)],0)){if(g&&E["isQoSMes"+s(1278)]&&N)return!!!await N.get(g)&&(this[s(498)+s(1002)+s(257)](a),await N.set(g,e[s(1436)](Date[s(1509)](),b))),e[s(828)](n);if(p){let M=await Sd.call(this);if(!M)return this[s(498)+s(1002)+s(257)](a),e[s(276)](n);let G=await M[s(353)](D)??-1;if(e.JQTUV(G,L))this[s(498)+s(1002)+"Event"](a),M[s(592)](D,L,a.message[s(1196)]);else throw new Error("recevied"+s(1176)+s(1448)+L+(s(1286)+s(884)+s(975)+"r ")+G);return n()}return this[s(498)+"hMessageEvent"](a),n()}}async function Sg(a,n){let s=t,l=Sa.call(this,a);if(!l[s(236)+"sage"])return n();let f=await bd.call(this);if(l[s(306)+s(925)+s(835)]&&l.ackMsgIds[s(748)])for(let g of l[s(1708)+"s"])await f[s(1292)](g);e[s(733)](n)}async function Ig(a,n){let s=t,l=e[s(1188)](a[s(729)][s(905)+"e"],mg),f=e[s(621)](a.message[s(905)+"e"],ka);if(e[s(794)](!l,!f))return e.iUPut(n);let g=e[s(1206)](ir,a.message[s(1255)],e[s(336)]);if(!g)return e[s(828)](n);let b=await Sd.call(this,g);if(!b)return n();if(l){let E=await b[s(1192)+"rs"](),p={frameType:E?.[s(905)+"e"],SeqID:ge[s(1418)+"er"](this._seqId++),LogID:ge.fromNumber(this[s(193)]["logIDGen"+s(182)]()),service:9e3,method:5,headers:E?.[s(1255)],payload:E?.payload},D=S(p);this[s(579)]&&this[s(579)].readyState&&this._ws[s(242)](D)}if(f){let E=a[s(729)].payload;E&&b[s(1475)+"rs"](E)}}let Ag=async function(a,n){let s=t;this[s(1703)]=!1,e[s(1144)](clearTimeout,this._connectionTimeoutId),e.XazvQ(n)},kg=async function(a,n){let s=t;if(e[s(1133)](e[s(1377)],"eKMRS"))return!!this[s(414)];{if(!this[s(579)]||e.IyaNu(this[s(579)].readyState,this[s(1302)]))return e.XazvQ(n);let{pingInterval:l}=this[s(193)];this[s(439)+s(231)]?.[s(1658)+s(1368)+"fig"]();for(let g=0;e[s(1171)](g,this["_message"+s(542)][s(748)]);g++){let b=this[s(832)+s(542)][g];if(this._ws.readyState===this.OPEN&&e[s(850)](null,b))this[s(579)]&&this._ws.send(b),this["_message"+s(542)][g]=null;else break}this[s(832)+s(542)]=this[s(832)+"Queue"][s(1109)](g=>!!g),this[s(1360)+"gTimeoutId"]=e[s(1612)](setTimeout,()=>this._ping(),l),this["_dispatc"+s(847)+"nt"](a),this[s(1493)+"er"]&&this[s(579)]&&(this._ws[s(204)+"pe"]=this[s(1014)+"ype"]);let f=this[s(439)+s(231)]?.[s(1105)+"ntEndpoint"]();this._debug(s(1466)+f+" success"),e.iUPut(n)}},Tg=async function(a,n){let s=t,l=this[s(439)+s(231)]?.[s(1105)+s(1191)+"nt"]();this[s(413)](s(1466)+l),e.wHHcW(n)};class Rg extends Ea{constructor(n){let s=t,l={EUFoU:function(E,p,D,L){return e[U(1044)](E,p,D,L)},RsIIi:function(E,p,D){return e[U(1159)](E,p,D)},vLVRe:e[s(1363)],gcrLG:s(1051),HGTiR:function(E,p,D){return E(p,D)},PjpqH:e.fAGIn,XolkL:function(E,p){return E!==p},iBfUJ:function(E,p,D){return e.dMaku(E,p,D)},TGFLq:"bye",EeSvF:function(E,p){return e[s(730)](E,p)},iPTxy:function(E,p){return e.ZLIwb(E,p)},KqgoP:function(E,p,D){return e[s(328)](E,p,D)},VpkZe:function(E,p,D){return E(p,D)},DVdyS:function(E,p,D){return e[s(425)](E,p,D)}};super(),this["_miniNav"+s(744)+s(1328)]=!0,this._isBrowser=rr,this[s(791)]=Wp,this[s(664)+"T"]=Cn,this[s(814)+"X"]=Qr,this[s(1048)+"r"]=ei,this[s(832)+"Queue"]=[],this["_endpoin"+s(231)]=null,this[s(1608)+s(576)]=!1,this["_binaryT"+s(1235)]=s(672)+s(1125),this[s(922)+s(1271)]=!1,this._connectionTimeoutId=null,this[s(183)+"ctTimeou"+s(1421)]=null,this[s(1360)+s(383)+"Id"]=null,this[s(245)]=0,this[s(1703)]=!1,this[s(180)]="",this[s(437)+s(1548)]=null,this[s(653)+s(931)]=null,this[s(1468)+s(1083)]=null,this[s(1020)+"ls"]=e.wnxJm,this[s(1186)]=3,this[s(1409)+"NG"]=0,this[s(1302)]=1,this.CLOSING=2,this[s(941)]=E=>{let p=s;try{l[p(1727)](md,this,E,[Ag,kg,Tg])}catch(D){let L=l[p(248)](dt,p(1051),{message:D[p(729)],code:on[p(789)+"OR"],error:D});this[p(498)+p(1194)+p(655)](L)}},this[s(288)+"ge"]=async E=>{let p=s,{pingInterval:D,pingFrequency:L}=this[p(193)];if((e[p(818)]("hi",E.data)&&e[p(686)](e.NoqoM,L)||e[p(1452)](e[p(1491)],L))&&(e[p(1521)](e.jRmtv,"ZWxvW")?(this[p(205)+p(1139)](),this[p(840)](e.LsJQM,e[p(1363)]),this[p(1360)+"gTimeoutId"]=e[p(1059)](setTimeout,this[p(1064)].bind(this),D)):(this[p(205)+p(1139)](),this[p(840)](p(1092)+"e_success",l.vLVRe),this[p(1360)+p(383)+"Id"]=l[p(248)](_0x1bcd03,this[p(1064)][p(530)](this),_0x1d7097))),!e[p(951)]("hi",E[p(491)]))try{e[p(470)](md,this,E,[og,ig,Sg,Ig,vg,sg])}catch(N){let M=e[p(556)](dt,e[p(1471)],{message:N[p(729)],code:on[p(303)+p(911)],error:N});this[p(498)+p(1194)+p(655)](M)}},this._onError=E=>{let p=s,D=this[p(439)+p(231)]?.[p(937)+p(1483)+"es"](),L=this[p(439)+"tManager"]?.[p(1105)+p(1191)+"nt"]();if(D&&!E.message){let N="connect "+L+(" fail, max retri"+p(640)+"ed");this[p(498)+p(1194)+p(655)](l[p(248)](dt,l.gcrLG,{message:N,code:on.MAX_RETRIES_ERROR,error:E}));return}this[p(579)]&&this[p(579)][p(1648)+"te"]===this[p(1302)]&&this[p(969)+p(1376)](),this["_dispatc"+p(1194)+"ent"](l[p(929)](dt,l[p(174)],{message:E[p(729)],code:on["NATIVE_E"+p(851)],error:E}))},this[s(845)]=async E=>{let p=s;this[p(1175)+p(532)](),this["_clearPi"+p(1139)](),this[p(1352)+p(933)+"rs"](),this[p(579)]=null,this._connectLock=!1;let D=this[p(439)+"tManager"]?.[p(937)+p(1483)+"es"]();if(!D&&this["_navigat"+p(1707)]()&&!this[p(1608)+p(576)]){let L=this._endpointManager?.[p(1105)+"ntEndpoint"](),N=this._options["reconnectInterce"+p(1361)](E[p(416)],E[p(741)]);this[p(498)+p(740)+"ent"](yt(l.PjpqH,{code:1006,reason:E[p(741)]||"connecti"+p(976)+p(320)+p(944)+p(239)+p(201)+L,willReconnect:N})),N&&this[p(922)]();return}if(l[p(1539)](1e3,E[p(416)])&&this[p(1608)+"osed"]){this[p(498)+p(740)+p(655)](l[p(1459)](yt,p(720),{code:1e3,reason:l[p(1477)]})),this[p(439)+p(231)]?.["resetEnd"+p(1368)+"fig"](),this["_pingLos"+p(1083)]?.[p(1317)+p(867)]();return}if(l[p(806)](1e3,E.code)&&D){let L=this[p(439)+p(231)]?.[p(1105)+p(1191)+"nt"](),N=E[p(741)];N||(N=await l[p(1039)](Xp,this[p(180)])),N="connecti"+p(976)+"d, "+N+(p(1411)+p(643))+L+(", max re"+p(849)+p(478)),this[p(498)+"hCloseEvent"](l[p(190)](yt,"close",{code:E[p(416)],reason:N}));let M="connect "+L+(p(673)+"ax retri"+p(640)+"ed");this["_dispatc"+p(1194)+p(655)](l.VpkZe(dt,l[p(174)],{message:M,code:on[p(1607)+p(1697)+"R"]})),this[p(439)+p(231)]?.["resetEnd"+p(1368)+p(903)](),this["_pingLos"+p(1083)]?.[p(1317)+p(867)]();return}if(E[p(416)]!==1e3&&!E[p(741)]){let L=this[p(439)+"tManager"]?.[p(1105)+p(1191)+"nt"]();this[p(498)+p(740)+p(655)](l.DVdyS(yt,p(720),{code:E[p(416)],reason:p(874)+p(976)+p(320)+p(944)+p(239)+"ame: "+L})),this[p(439)+p(231)]?.[p(1658)+p(1368)+p(903)](),this[p(1468)+p(1083)]?.[p(1317)+p(867)]();return}this[p(498)+p(740)+p(655)](E),this[p(439)+p(231)]?.["resetEnd"+p(1368)+p(903)](),this[p(1468)+p(1083)]?.[p(1317)+p(867)]()},this.onclose=null,this.onerror=null,this[s(1451)+"e"]=null,this[s(1204)]=null,this[s(1665)+s(709)]=null,this[s(837)+"eAck"]=null,this[s(1182)+s(1099)+s(993)+"ct"]=null,this[s(374)+s(253)]=this[s(374)+s(253)][s(530)](this),this[s(374)+s(1695)]=this[s(374)+"ffLine"][s(530)](this),this[s(1556)+"ageHide"]=this["_handleP"+s(298)][s(530)](this),this["_handleP"+s(356)]=this[s(1556)+s(356)].bind(this),this[s(193)]={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength: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(1491)],pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:s(1620),env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:f,ws:g}=n,b=Array.isArray(f)?f:e[s(943)](e[s(1644)],typeof f)?[f]:[];if(!b||e[s(506)](0,b[s(748)]))throw new Error(e[s(646)]);if(!e[s(688)](Vp,g))throw new Error(e.ksVSv);if(Object.assign(this[s(193)],n),this[s(439)+s(231)]=new gd(b,this[s(193)].maxRetries),this["_pingLos"+s(1083)]=new Yp(this[s(193)][s(359)+s(515)]),this[s(193)][s(385)+s(1445)])if(e[s(250)](e[s(679)],e[s(1008)]))this._isInit=!0,this[s(922)]();else{if(e[s(1674)](_0x38601b,_0x867dce))return _0x49b19d?_0x594f03:_0x4a50ad;if(_0x547017){if(e[s(1151)](_0x264f45,_0x15b9db))return _0x461df8}else{if(e[s(1307)](_0x57eef1,-_0x1b3048))return _0xb78d1b;if(_0x575813+1>=_0x1970fd)return _0x528ec9}return _0x32c92b[s(854)](e[s(344)](_0x486f11%_0x3e35b4,0),e[s(333)](_0x5013ee/_0x2a6860,0),_0x884b6f)}this[s(193)][s(1553)+s(786)+"nged"]&&(this[s(664)+"T"]||this[s(814)+"X"]?this[s(1068)+"etWorkCh"+s(1585)]():this._isBrowser&&this["_initGlo"+s(1696)+s(1545)]())}[t(374)+"nLine"](){let n=t;this._options["disableAutoRecon"+n(387)]||this[n(1608)+n(576)]||this[n(380)+n(709)]()}[t(374)+t(1695)](){let n=t;this[n(635)+n(888)+"t"]();let s=e[n(614)](ya,e[n(1029)],{message:e[n(950)]});this[n(1182)+"mediatelyReconnect"]&&this[n(1182)+n(1099)+n(993)+"ct"](s)}[t(1440)+t(1696)+"Listener"](){let n=t;this[n(1493)+"er"]&&window[n(1055)+n(1545)](e[n(1006)],this["_handleO"+n(253)]),this[n(1493)+"er"]&&window[n(1055)+"Listener"](e[n(1560)],this["_handleO"+n(1695)]),this._isBrowser&&window[n(1055)+"Listener"](e[n(1559)],this[n(1556)+"ageHide"]),this[n(1493)+"er"]&&window[n(1055)+n(1545)](e.gxWpf,this[n(1556)+n(356)])}[t(1339)+t(1696)+"Listener"](){let n=t,s={OYXYm:function(l,f){return e[U(1230)](l,f)},xayyC:function(l,f){return e[U(1248)](l,f)},bjiWo:function(l,f){return e[U(269)](l,f)},qffjD:function(l,f){return e.ESsbM(l,f)},nziVr:function(l,f){return e[U(186)](l,f)},iWkPn:function(l,f){return l>>>f},NIEUJ:function(l,f){return l|f},HDROX:function(l,f){return e.QAqSU(l,f)},BsfLZ:function(l,f){return l&f},Ayvvy:function(l,f){return e[U(1566)](l,f)},sUDwU:function(l,f){return e.NGQTr(l,f)},kNqId:function(l,f){return l>>>f},ppZXB:function(l,f){return e[U(1147)](l,f)},CQGzI:function(l,f){return l|f},eLKoG:function(l,f){return e[U(350)](l,f)}};if(e[n(407)]!==n(581))this._isBrowser&&window[n(564)+n(947)+n(574)](e.qYMPa,this[n(374)+n(253)]),this._isBrowser&&window[n(564)+"entListe"+n(574)](n(1114),this[n(374)+n(1695)]),this._isBrowser&&window["removeEv"+n(947)+n(574)](e[n(1559)],this[n(1556)+n(298)]),this[n(1493)+"er"]&&window[n(564)+n(947)+n(574)](e[n(1561)],this[n(1556)+n(356)]);else{let l=4294967295;return function(f,g,b=!0){let E=n;if(l=hulDMc[E(582)](127&f[g],0),hulDMc[E(1190)](f[g++],128))return{value:b?l:0|l,offset:g};if(l=hulDMc.bjiWo(l,hulDMc[E(1049)](hulDMc[E(206)](127,f[g]),7))>>>0,hulDMc[E(1190)](f[g++],128))return{value:b?l:hulDMc[E(1305)](0,l),offset:g};if(l=hulDMc[E(1326)](hulDMc[E(1305)](l,(127&f[g])<<14),0),f[g++]<128)return{value:b?l:hulDMc[E(207)](0,l),offset:g};if(l=hulDMc[E(987)](hulDMc[E(1305)](l,hulDMc.qffjD(hulDMc.BsfLZ(127,f[g]),21)),0),hulDMc.Ayvvy(f[g++],128))return{value:b?l:hulDMc.sUDwU(0,l),offset:g};if(l=hulDMc[E(1402)](hulDMc[E(902)](l,hulDMc.ppZXB(15,f[g])<<28),0),hulDMc.xayyC(f[g++],128))return{value:b?l:hulDMc[E(467)](0,l),offset:g};if(hulDMc.eLKoG(g+=5,f.length))throw g=f.length,_0x22055a(g,10,f.length);return{value:b?l:hulDMc[E(207)](0,l),offset:g}}}}[t(1556)+t(298)](n){let s=t;!n[s(1647)+"d"]&&(this[s(1493)+"er"]&&window[s(564)+s(947)+s(574)](e[s(1559)],this[s(1556)+s(298)]),this[s(1493)+"er"]&&window["removeEv"+s(947)+"ner"]("pageshow",this[s(1556)+"ageShow"]),this[s(720)]()),this[s(1493)+"er"]&&window[s(564)+"entListe"+s(574)](e[s(1006)],this[s(374)+"nLine"]),this[s(1493)+"er"]&&window["removeEventListe"+s(574)](s(1114),this["_handleO"+s(1695)])}[t(1556)+t(356)](n){let s=t;n[s(1647)+"d"]&&(this[s(1434)+s(1707)]()&&(!this._ws||this._ws[s(1648)+"te"]!==this[s(1302)]||e.FHAFx(this._ws.readyState,this.CONNECTING))&&this[s(374)+s(253)](),this._isBrowser&&window[s(1055)+"Listener"](s(1366),this["_handleO"+s(253)]),this[s(1493)+"er"]&&window["addEvent"+s(1545)](e[s(1560)],this[s(374)+s(1695)]))}async[t(1457)+t(482)](n){let s=t,{fpID:l,deviceID:f,bddID:g,ttwID:b,accessKey:E,aID:p,customParams:D={},enableAutoAck:L,enableQoS:N,QoSLevel:M,env:G}=this[s(193)],ee,ce,ne;this[s(1493)+"er"]||this._isMiniWX||this._isMiniTT?(ee=location&&e.XGxzy(e.PdyDQ,location[s(1057)])?"wss://":e[s(716)],ce=n[s(259)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),ne=/^wss(.*:\/\/)/.test(n)?n:""+ee+ce):(ee=e[s(834)],ce=n[s(259)](/(^http)((?:[s]*:\/\/))/,""),ne=/(^ws)((?:[s]*:\/\/))/[s(934)](ce)?ce:""+ee+ce);let xe=g?e[s(1027)]:b?e[s(1316)]:e[s(767)],ti=g||b||f;if(!ti||!xe)throw new Error(e[s(760)]);let Cg=e.XGxzy(e[s(855)],typeof D)?await e[s(226)](D):D,Dg=G?e[s(328)](Jp,G[s(432)],G[s(1213)]):{},Ta=Object[s(302)]({device_platform:e[s(469)],version_code:e[s(1480)],access_key:E,fpid:l,aid:p,[xe]:ti,xsack:L?1:0,xaack:L?1:0,xsqos:N?1:0,qos_level:N?M:void 0,qos_sdk_version:2,...Dg},Cg),Pg=Object[s(590)](Ta)[s(966)]((Ra,Ca)=>Ta[Ca]!==void 0?""+Ra+(Ra?"&":"?")+Ca+"="+Ta[Ca]:Ra,"");return ne+"/ws/v2"+Pg}async[t(922)](){let n=t;if(!(this[n(922)+"Lock"]||this[n(1608)+n(576)])){this[n(922)+n(1271)]=!0;try{let s=this[n(439)+"tManager"]?.[n(1615)+"rentEndpointReac"+n(896)+n(746)](),{timeoutInterval:l}=this[n(193)];if(s){let g=this["_endpoin"+n(231)]?.["getCurre"+n(1191)+"nt"](),b=this[n(439)+n(231)]?.[n(227)+n(1562)+n(598)+n(754)+n(873)](),E=this[n(439)+n(231)]?.[n(1105)+n(1191)+n(1437)+n(1132)]();if(b)if(e[n(1088)](e[n(1595)],e[n(657)])){if(!this["_connect"+n(1271)]){let p=e[n(274)].split("|"),D=0;for(;;){switch(p[D++]){case"0":this["_readyCl"+n(576)]=!1;continue;case"1":this[n(1468)+n(1083)]?.[n(1317)+"nter"]();continue;case"2":this[n(439)+n(231)]?.[n(1658)+n(1368)+n(903)]();continue;case"3":this[n(922)]();continue;case"4":this._isInit=!0;continue}break}}}else{let p=n(671)+g+(n(779)+n(468)+n(849)+n(1185)+n(214)+n(1053)+"ndpoint ")+b+(n(403)+"y"),D=e[n(1557)](dt,e[n(1471)],{message:p,code:on["MAX_RETR"+n(1697)+"R"]});this[n(413)](p),this[n(498)+n(1194)+n(655)](D),this[n(180)]=await this[n(1457)+"eUrl"](b),this[n(413)](n(671)+b+" "+E+n(1233)),this[n(1352)+"sListeners"]()}else{let p=n(671)+g+(n(779)+n(468)+"tries re"+n(478));this[n(413)](p),this[n(498)+"hErrorEvent"](dt(e[n(1471)],{message:p,code:on[n(1607)+n(1697)+"R"]}));return}}else{let g=this[n(439)+n(231)]?.[n(1105)+"ntEndpoi"+n(1141)+n(1462)](),b=this["_endpoin"+n(231)]?.[n(1105)+"ntEndpoi"+n(1437)+n(1132)]();this[n(180)]=await this[n(1457)+n(482)](e[n(1444)](g,"")),this._debug(n(671)+g+" "+b+n(1233)),this[n(1352)+n(933)+"rs"]()}if(this[n(1703)])this._isInit=!1;else{if(e.zwThA(e[n(877)],e[n(1260)]))return new _0x13b20f(g=>{_0x2cf0a4(g,this._getIntervalValue(_0x50ad93))});{let g=ya(e[n(1029)],{message:e[n(1523)]});this[n(1665)+n(709)]&&this[n(1665)+n(709)](g)}}let f=this[n(439)+n(231)]?.["getCurrentEndpointTriesC"+n(1132)]()||0;e[n(1288)](f,1)&&await this._wait(e[n(710)](f,1)),this._debug(n(874)+"ng url: "+this[n(180)]+(n(1284)+"ls: ")+this[n(1020)+"ls"]),this._ws=$p({url:this._url,protocols:[this[n(1020)+"ls"]],headers:this[n(193)][n(450)+n(192)+"s"]["customHt"+n(1073)]},this[n(193)].ws),(this[n(1493)+"er"]||this[n(1048)+"r"])&&this._ws&&(this[n(579)][n(204)+"pe"]=this[n(1014)+n(1235)]),this[n(1046)+"steners"](),this[n(922)+"ionTimeo"+n(477)]=e[n(1187)](setTimeout,this[n(881)+"ut"][n(530)](this),l)}catch(s){throw this[n(922)+"Lock"]=!1,s}}}_clearTimer(){let n=t;e[n(1138)](clearTimeout,this["_connect"+n(1547)+n(477)]),this[n(922)+n(1547)+n(477)]=null}["_clearPi"+t(1139)](){let n=t;if(e[n(1158)](e.azfrC,"SSnYl"))e[n(1430)](clearTimeout,this[n(1360)+n(383)+"Id"]),e[n(650)](clearTimeout,this[n(183)+n(1074)+n(1421)]),this[n(1360)+n(383)+"Id"]=null,this["_reconnectTimeou"+n(1421)]=null;else return new _0x290535(_0x37c9f7,{code:_0x213056,reason:_0xa89a87,wasClean:_0x4a634d,willReconnect:_0x34fc48})}[t(413)](...n){let s=t;this._options[s(1265)]&&console.log[s(1614)](console,[e[s(247)],...n])}_getIntervalValue(n){let s=t,{initReconnectInterval:l,maxReconnectInterval:f,reconnectIntervalGrowFactor:g}=this[s(193)],b=e[s(1007)](l,Math[s(1654)](g,e[s(710)](n,1)));return e[s(1288)](b,f)?f:b}_ping(){let n=t;if(this[n(579)]&&this._ws[n(1648)+"te"]===this[n(1409)+"NG"]){this._clearPingTimer(),this[n(1360)+n(383)+"Id"]=e[n(570)](setTimeout,this[n(1064)][n(530)](this),this[n(193)]["pingInte"+n(251)]);return}if(!this[n(579)]||this[n(579)][n(1648)+"te"]!==this[n(1302)])return void this["_handleR"+n(709)]();this[n(579)]&&this[n(579)][n(242)]("hi"),this[n(183)+n(1074)+n(1421)]=e[n(1417)](setTimeout,this["_handleReconnect"+n(1276)][n(530)](this),this[n(193)]["pingTime"+n(1281)+"val"])}[t(380)+t(709)+t(1276)](){let n=t,s={FVgUi:function(l,f){return e[U(1138)](l,f)}};e[n(404)]===n(1505)?(this[n(1468)+n(1083)]?.[n(580)](),this.emit(e[n(991)],e[n(480)]),this[n(1468)+n(1083)]?.[n(937)+n(1345)+"nt"]()?this[n(380)+n(709)]():this._ping()):(_0x197491+=TzUjGg[n(1123)](_0x2716bd,_0x52d043),_0x35fe5f+=2)}[t(1434)+t(1707)](){let n=t;return this[n(664)+"T"]||this._isMiniWX?this[n(1314)+n(744)+n(1328)]:(this[n(1493)+"er"]||this[n(1048)+"r"])&&this[n(193)][n(1553)+n(786)+n(1315)]?navigator.onLine:!0}[t(380)+t(709)](){let n=t;!this[n(1434)+"orOnline"]()||this[n(1608)+n(576)]||(this[n(439)+n(231)]?.[n(1658)+n(1368)+n(903)](),this[n(1468)+n(1083)]?.[n(1317)+"nter"](),this._ws?this[n(969)+n(1376)](1001,e[n(360)],!0):this[n(922)]())}[t(1068)+t(184)+t(1585)](){let n=t,s={ShIoP:function(l,f){return e[U(1280)](l,f)},BDHsK:function(l,f){return e[U(824)](l,f)},QrzUk:function(l,f){return e[U(1341)](l,f)},GdIOC:n(783)};this[n(664)+"T"]?tt[n(1622)+n(1400)+n(1268)](({isConnected:l})=>{let f=n;s[f(670)](s[f(784)],s[f(784)])?(_0x45397d=DcbcIO[f(211)](_0xfd9f05,_0x23676e),_0x1debc1|=DcbcIO[f(324)](127,_0x2c5535)<<7):(this[f(1314)+f(744)+f(1328)]=l,l?this[f(374)+"nLine"]():this[f(374)+f(1695)]())}):this._isMiniWX&&wx["onNetwor"+n(1400)+"hange"](({isConnected:l})=>{let f=n;this[f(1314)+f(744)+f(1328)]=l,l?this[f(374)+f(253)]():this[f(374)+f(1695)]()})}[t(871)](n){return new Promise(s=>{setTimeout(s,this[U(652)+"rvalValue"](n))})}[t(969)+t(1376)](n=1e3,s="",l=!1){let f=t;this[f(579)]&&this[f(635)+f(888)+"t"](n,s,l)}[t(881)+"ut"](){let n=t,s=this[n(439)+"tManager"]?.["getCurre"+n(1191)+"nt"]();this[n(413)]("connect "+s+n(779)),this[n(969)+n(1376)](1001,e[n(948)],!0)}[t(940)](n){let s=t;if(e[s(541)](e[s(1702)],e.TppXI)){let l=e.htrRq(Ut,n);this[s(579)]&&e[s(1381)](this._ws[s(1648)+"te"],this[s(1302)])&&(this[s(579)]&&this[s(579)][s(242)](l),this[s(413)](e[s(666)],n))}else e[s(1643)](_0x580db5,_0x34ceb0,90),_0x53894d(_0x5600eb,_0x548b58)}[t(1352)+t(933)+"rs"](){let n=t,s=e[n(1097)][n(1306)]("|"),l=0;for(;;){switch(s[l++]){case"0":this[n(579)][n(564)+n(947)+n(574)](e[n(1148)],this[n(941)]);continue;case"1":if(!this._ws)return;continue;case"2":this[n(579)]["removeEv"+n(947)+n(574)](n(729),this[n(288)+"ge"]);continue;case"3":this[n(579)][n(564)+n(947)+n(574)](n(720),this[n(845)]);continue;case"4":this[n(579)][n(564)+n(947)+"ner"](e[n(1471)],this._onError);continue}break}}[t(1046)+t(833)](){let n=t,s=e[n(1684)][n(1306)]("|"),l=0;for(;;){switch(s[l++]){case"0":this[n(579)][n(1055)+n(1545)](e[n(1471)],this[n(1429)]);continue;case"1":this[n(579)][n(1055)+"Listener"](e[n(637)],this[n(845)]);continue;case"2":if(!this[n(579)])return;continue;case"3":this._ws[n(1055)+n(1545)](e[n(1148)],this[n(941)]);continue;case"4":this._ws["addEvent"+n(1545)](e[n(1110)],this[n(288)+"ge"]);continue}break}}[t(1438)+t(1453)](n=1e3,s=""){let l=t,f={UIjUS:function(b,E){return e.ZLIwb(b,E)},brSfv:function(b,E){return e[U(1501)](b,E)},WLFFT:e[l(573)]};if(e[l(1508)]!==e[l(1508)])for(var g in _0x327ce2)nWANkM[l(1515)](_0x3c1a7c,_0xc27ae7,g,{get:_0x362fc0[g],enumerable:!0});else try{if(e[l(820)]!==e[l(820)]){let b=/(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}/.test(_0x228c32),E=/(([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]))/.test(_0x1eecec);return b?gLFlEU[l(1646)](_0x147977,_0x3d8d61):E?gLFlEU[l(1420)](_0xad60e9,_0x1cb8dc):gLFlEU.WLFFT}else this[l(579)]&&this[l(579)][l(720)](n,s)}catch{}}["_destroy"+t(888)+"t"](n=1e3,s="",l=!1){let f=t;if(this[f(205)+f(1139)](),this[f(1175)+"mer"](),this[f(1352)+f(933)+"rs"](),this[f(1438)+f(1453)](1e3,s),this[f(922)+f(1271)]=!1,l&&this[f(1434)+"orOnline"]()&&!this[f(1608)+"osed"])if(e.Qodnf(e[f(1632)],e[f(1632)]))_0x1aee0e[f(627)][f(952)+"ild"](_0x339121),_0x2bc1a0[f(1052)+f(1025)]=void 0,e.HaqOY(_0x2f4fc2,_0x322b08&&_0x387377.msg||f(1304)+f(741));else{if(this[f(439)+f(231)]?.[f(937)+"chMaxTries"]()){let b=this[f(439)+f(231)]?.[f(1105)+f(1191)+"nt"]();this[f(498)+f(740)+f(655)](e[f(696)](yt,e[f(637)],{code:1006,reason:f(671)+b+(" timeout"+f(468)+f(849)+f(478)),wasClean:!0}))}else{let b=this[f(193)]["reconnectInterce"+f(1361)](n,s);this[f(498)+"hCloseEvent"](yt(e[f(637)],{code:n,reason:s,wasClean:!0,willReconnect:b})),b&&this._connect()}return}this[f(1434)+f(1707)]()||this[f(1608)+f(576)]?this[f(498)+"hCloseEvent"](e[f(668)](yt,e.fAGIn,{code:n,reason:e[f(626)]})):this[f(498)+f(740)+f(655)](yt(f(720),{code:1006,reason:"going aw"+f(634)+f(1500)+f(534)})),this[f(579)]=null,this["_endpoin"+f(231)]?.["resetEnd"+f(1368)+f(903)](),this[f(1468)+f(1083)]?.[f(1317)+f(867)]()}[t(498)+t(847)+"nt"](n){let s=t;this[s(840)](s(431),n),this[s(1204)]&&this[s(1204)](n)}[t(498)+"hMessage"+t(257)](n){let s=t;this[s(840)](e[s(1110)],n),this[s(1451)+"e"]&&this.onmessage(n)}[t(498)+t(981)+"ageEvent"](n){let s=t;if(e.DZDwl===s(343))this[s(840)](e.bkxLJ,n),this[s(837)+s(1035)]&&this[s(837)+s(1035)](n);else{if(this[s(205)+s(1139)](),this[s(1175)+s(532)](),this[s(1352)+s(933)+"rs"](),this._wsInstanceClose(1e3,_0x50bed7),this[s(922)+s(1271)]=!1,_0x7b51b3&&this["_navigat"+s(1707)]()&&!this[s(1608)+s(576)]){if(this[s(439)+s(231)]?.[s(937)+s(1483)+"es"]()){let f=this[s(439)+"tManager"]?.[s(1105)+s(1191)+"nt"]();this[s(498)+"hCloseEv"+s(655)](e.kLXRh(_0x21d12e,e[s(637)],{code:1006,reason:s(671)+f+(s(779)+s(468)+s(849)+s(478)),wasClean:!0}))}else{let f=this[s(193)]["reconnectInterce"+s(1361)](_0xc7c94a,_0x248a14);this[s(498)+"hCloseEv"+s(655)](e[s(1120)](_0x1b93f6,s(720),{code:_0xc02bca,reason:_0x57273c,wasClean:!0,willReconnect:f})),f&&this[s(922)]()}return}this[s(1434)+s(1707)]()||this[s(1608)+s(576)]?this["_dispatchCloseEv"+s(655)](e.wJyyF(_0x448e75,e[s(637)],{code:_0x293a6a,reason:e[s(626)]})):this[s(498)+"hCloseEv"+s(655)](e[s(367)](_0x224cb5,e[s(637)],{code:1006,reason:e.ByppI})),this[s(579)]=null,this[s(439)+s(231)]?.[s(1658)+"pointCon"+s(903)](),this[s(1468)+s(1083)]?.[s(1317)+s(867)]()}}[t(498)+t(1194)+"ent"](n){let s=t;this.emit(e[s(1471)],n),this[s(807)]&&this.onerror(n)}["_dispatc"+t(740)+t(655)](n){let s=t;this[s(840)](e[s(637)],n),this[s(1239)]&&this[s(1239)](n)}get binaryType(){let n=t;if(e[n(1115)]===e[n(1115)])return this._ws?this[n(579)].binaryType:this["_binaryT"+n(1235)]}set[t(204)+"pe"](n){let s=t;this["_binaryT"+s(1235)]=n,this[s(579)]&&(this[s(579)][s(204)+"pe"]=n)}get[t(392)+"nt"](){let n=t;return this[n(439)+n(231)]?.[n(1105)+n(1191)+"ntTriesCount"]()||0}get[t(1205)+"Amount"](){let n=t;return this[n(832)+n(542)][n(966)]((l,f)=>(l+=f&&f.byteLength||0,l),0)+(this[n(579)]?this[n(579)][n(1205)+"Amount"]:0)}get extensions(){let n=t;return this[n(579)]?this._ws[n(538)+"ns"]:""}get[t(1057)](){let n=t;return this[n(579)]?this[n(579)][n(1057)]:""}get readyState(){let n=t;return this[n(579)]?this[n(579)][n(1648)+"te"]:this[n(193)][n(385)+"cOpen"]?this[n(1409)+"NG"]:this[n(1186)]}get[t(939)](){let n=t;return this[n(579)]?this._ws[n(939)]:this[n(180)]}close(n=1e3,s){let l=t,f=e[l(1396)][l(1306)]("|"),g=0;for(;;){switch(f[g++]){case"0":if(!this[l(579)])return void this[l(413)](e[l(1299)]);continue;case"1":this["_destroy"+l(888)+"t"](n,s);continue;case"2":this[l(1339)+"balEvent"+l(1545)]();continue;case"3":this._readyClosed=!0;continue;case"4":this[l(205)+l(1139)]();continue;case"5":this["_clearTi"+l(532)]();continue;case"6":if(this[l(579)].readyState===this.CLOSED||e[l(838)](this[l(579)][l(1648)+"te"],this.CLOSING))return void this[l(413)](e[l(695)]);continue;case"7":this[l(437)+l(1548)]?.[l(1507)]();continue}break}}async[t(242)](n,s){let l=t,f={YxvbI:function(ne,xe){return ne<xe},NHQmV:function(ne,xe){return e[U(1669)](ne,xe)},xlSMm:function(ne,xe){return e.boooA(ne,xe)},hKlTX:function(ne,xe){return e[U(354)](ne,xe)},zzWBx:function(ne,xe){return e[U(191)](ne,xe)}};if(e[l(611)](null,n))throw new Error(e[l(705)]);e[l(1603)](e.eLiHt,typeof n)&&(n=JSON[l(811)+"y"](n)),e[l(1729)](e[l(1644)],typeof n)&&!e[l(240)](n,ArrayBuffer)&&!(n[l(1054)]&&e[l(1242)](n[l(1054)],ArrayBuffer))&&(n=JSON[l(811)+"y"](n));let g=await yd(n),b=e[l(1439)](Zp,n),{method:E=0,service:p=this[l(193)].service,logID:D=this[l(193)][l(990)+l(182)](),headers:L=this[l(193)][l(1255)],payloadEncoding:N=this[l(193)][l(1487)+l(1075)],payloadType:M=this[l(193)]["payloadT"+l(1235)],logIDNew:G=this._options[l(1009)+l(776)]["enableAu"+l(642)+"teLogIDNew"]?e.sSKnu(i,this._options[l(1009)+"Config"][l(1258)]):""}=e[l(446)](s,{});if(!p)throw new Error(l(1015)+l(365)+" valid service");let ee={SeqID:ge[l(1418)+"er"](this[l(245)]++),LogID:ge[l(1418)+"er"](D),service:p,method:E,headers:L,payloadEncoding:e[l(1575)](N,Object)?N.encoding?N[l(965)]:"":N,payloadType:e[l(240)](M,Object)?M[l(1018)]?M[l(1018)]:b:M||b,payload:g,LogIDNew:G},ce=Ut(ee);if(this[l(579)]&&e.setSJ(this[l(579)][l(1648)+"te"],this.OPEN))this[l(579)]&&this[l(579)][l(242)](ce),this[l(413)](l(800),ee);else if(e[l(1003)](this[l(832)+l(542)][l(748)],this[l(193)]["maxMessa"+l(1322)+"ength"]))if(e.Qzbwf(l(605),"gSqDz"))this[l(832)+l(542)].push(ce),this[l(413)](e.BisOK,ee);else{if(_0x484c2a===void 0)this[l(1673)+"rs"]={};else if(_0x5cc369===void 0)this[l(1673)+"rs"][_0x3c9a4e]=null;else{let ne=this[l(1673)+"rs"][_0x44bb3f];if(ne)for(let xe=0;BFpAVx[l(1100)](xe,ne[l(748)]);)BFpAVx.NHQmV(ne[xe].fn,_0x262158)?ne.splice(xe,1):++xe}return this}else e[l(261)](e[l(1028)],e[l(1348)])?(_0x54f77d[_0x5f00c4++]=BFpAVx[l(691)](_0x50b337>>12,224),_0x17fa92[_0xd30b0b++]=BFpAVx[l(870)](_0x48d343,6)&63|128,_0x16fcca[_0x37b4d4++]=BFpAVx[l(1499)](63,_0x421547)|128):(this[l(832)+"Queue"][l(1320)](),this[l(832)+l(542)][l(268)](ce));return{seqID:this[l(245)],logID:D,logIDNew:G}}async[t(702)+"t"](n){let s=t,{url:l}=e.YpimR(n,{}),f=Array[s(1174)](l)?l:e[s(1644)]==typeof l?[l]:[];n&&Object[s(302)](this[s(193)],n),f&&f[s(748)]?this["_endpoin"+s(231)]=new gd(f,this._options[s(900)+"es"]):this[s(439)+s(231)]?.[s(1658)+s(1368)+s(903)](),this[s(1468)+s(1083)]?.[s(1317)+s(867)](this[s(193)][s(359)+s(515)]),this._readyClosed=!1,this[s(579)]&&e[s(868)](this[s(579)][s(1648)+"te"],this[s(1186)])?this[s(969)+s(1376)](1e3,e[s(721)],!0):(this[s(1703)]=!0,this[s(922)]())}async[t(694)](){let n=t;!this[n(922)+n(1271)]&&(e[n(778)](e[n(535)],e[n(535)])?(e[n(772)](_0x83d62b,this["_pingPon"+n(383)+"Id"]),_0x4832b6(this[n(183)+n(1074)+"tId"]),this._pingPongTimeoutId=null,this[n(183)+n(1074)+n(1421)]=null):(this[n(439)+"tManager"]?.["resetEnd"+n(1368)+n(903)](),this[n(1468)+n(1083)]?.[n(1317)+n(867)](),this[n(1608)+n(576)]=!1,this._isInit=!0,this._connect()))}[t(1055)+t(1545)](n,s){this.on(n,s)}[t(974)+t(257)](n){let s=t,{type:l}=n;this[s(840)](l,n)}["removeEv"+t(947)+"ner"](n,s){this.off(n,s)}[t(1197)](){let n=t,s={ZNkmq:function(l,f){return e[U(326)](l,f)},JGtIS:e[n(991)]};return new Promise((l,f)=>{let g=n;this[g(205)+g(1139)](),this[g(1360)+g(383)+"Id"]=e[g(313)](setTimeout,this._ping[g(530)](this),this._options[g(839)+"rval"]);let b=()=>{let p=g;s[p(1184)](l,"success"),this[p(487)]("ping_onc"+p(693)+"s",b),this.off(s[p(1395)],E)},E=()=>{let p=g;f(p(1389)),this.off(p(1092)+"e_success",b),this[p(487)]("ping_once_timeout",E)};this.on(e[g(1168)],b),this.on(g(1092)+g(914)+"t",E),this[g(1064)]()})}}})(),Fe[B(289)+B(887)]=Oe["CustomCl"+B(887)],Fe["CustomEr"+B(793)]=Oe[B(1240)+B(793)],Fe[B(310)+"e"]=Oe.ErrorCode,Fe[B(257)]=Oe[B(257)],Fe.FWS=Oe.FWS,Fe[B(1212)+"MessageE"+B(1722)]=Oe.FrontierMessageEvent,Fe[B(706)+B(1722)]=Oe[B(706)+B(1722)],Fe[B(292)+"t"]=Oe[B(292)+"t"],Fe[B(178)+B(262)]=Oe[B(178)+B(262)],Fe[B(1512)+B(887)]=Oe[B(1512)+"oseEvent"],Fe[B(461)+"rorEvent"]=Oe[B(461)+B(793)],Fe[B(674)+B(1393)+"nt"]=Oe["createMe"+B(1393)+"nt"],Fe["createOp"+B(994)]=Oe[B(1246)+B(994)],Fe[B(228)+B(961)+B(1722)]=Oe[B(228)+B(961)+B(1722)],Fe[B(1712)+"rame"]=Oe[B(1712)+B(345)],Fe[B(352)+B(1017)]=Oe[B(352)+"ame"];for(Jo in Oe)[B(289)+B(887),B(1240)+B(793),B(310)+"e",B(257),B(1131),"Frontier"+B(706)+B(1722),"MessageE"+B(1722),B(292)+"t","Reconnec"+B(262),B(1512)+B(887),"createErrorEvent",B(674)+B(1393)+"nt",B(1246)+"enEvent",B(228)+"connectE"+B(1722),"decodedF"+B(345),B(352)+B(1017)][B(418)](Jo)===-1&&(Fe[Jo]=Oe[Jo]);function U(t,e){t=t-173;let r=Qo(),i=r[t];if(U.yqxfqN===void 0){var o=function(x){let h="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",m="",w="";for(let S=0,_,v,I=0;v=x.charAt(I++);~v&&(_=S%4?_*64+v:v,S++%4)?m+=String.fromCharCode(255&_>>(-2*S&6)):0)v=h.indexOf(v);for(let S=0,_=m.length;S<_;S++)w+="%"+("00"+m.charCodeAt(S).toString(16)).slice(-2);return decodeURIComponent(w)};U.sWZAva=o,U.leUdSg={},U.yqxfqN=!0}let c=r[0],d=t+c,u=U.leUdSg[d];return u?i=u:(i=U.sWZAva(i),U.leUdSg[d]=i),i}var Jo;Object[B(901)+B(1089)](Fe,"__esModule",{value:!0})});import{existsSync as G1,openSync as H1}from"node:fs";import{mkdir as q1}from"node:fs/promises";import{dirname as j1}from"node:path";import{fileURLToPath as W1}from"node:url";function $1(t,e){return e==="legacy"?t.logFile:t.daemonStdioLog}function Vl(t=J()){return G1(t.libEntry)?t.libEntry:W1(new URL("../index.ts",import.meta.url))}async function op(t={}){let e=t.paths??J(),r=t.entryOverride??Vl(e),i=$1(e,process.env.COZE_BRIDGE_LOG_MODE);await q1(j1(i),{recursive:!0});let o=H1(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,[us]:"1"}});if(u.unref(),typeof u.pid!="number")throw new Error("failed to spawn daemon (no pid)");return K1.info("daemon spawned",{pid:u.pid,entry:r}),{pid:u.pid,entry:r}}var K1,us,aa=rt(()=>{"use strict";Jt();re();De();K1=j("spawn-daemon"),us="COZE_BRIDGE_DAEMON"});import{spawn as GS}from"node:child_process";import{mkdir as HS,unlink as qS,writeFile as jS}from"node:fs/promises";import{dirname as WS,join as KS}from"node:path";function Jr(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function $S(t){if(!t)return"";let e=Object.entries(t).map(([r,i])=>` <key>${Jr(r)}</key>
|
|
21
21
|
<string>${Jr(i)}</string>`).join(`
|
|
22
22
|
`);return e?`
|
|
23
23
|
<key>EnvironmentVariables</key>
|
|
24
24
|
<dict>
|
|
25
25
|
${e}
|
|
26
|
-
</dict>`:""}function
|
|
26
|
+
</dict>`:""}function VS(t,e){return new Promise((r,i)=>{let o=GS(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?r():i(new Error(`${t} ${e.join(" ")} exited ${d}: ${c.trim()}`))})})}var Zr,xs,ha,rd,Ap=rt(()=>{"use strict";re();Zr=j("supervisor.launchd"),xs="ai.coze.bridge",ha=VS,rd={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>${xs}</string>
|
|
32
32
|
<key>ProgramArguments</key>
|
|
33
33
|
<array>
|
|
34
34
|
<string>${Jr(t.nodeBin)}</string>
|
|
@@ -44,11 +44,11 @@ ${e}
|
|
|
44
44
|
<key>StandardOutPath</key>
|
|
45
45
|
<string>${Jr(t.logFile)}</string>
|
|
46
46
|
<key>StandardErrorPath</key>
|
|
47
|
-
<string>${Jr(t.logFile)}</string>${$
|
|
47
|
+
<string>${Jr(t.logFile)}</string>${$S(t.env)}
|
|
48
48
|
</dict>
|
|
49
49
|
</plist>
|
|
50
|
-
`},configPath(t){return
|
|
51
|
-
`):""}function
|
|
50
|
+
`},configPath(t){return KS(t.homeDir,"Library","LaunchAgents",`${xs}.plist`)},async install(t,e){let r=e?.activate!==!1,i=this.configPath(t);if(await HS(WS(i),{recursive:!0}),await jS(i,this.renderConfig(t),"utf8"),Zr.info("plist written",{plistPath:i,activate:r}),!r)return;await ha("launchctl",["unload","-w",i]).catch(c=>Zr.info("launchctl unload before load (ignored, likely not loaded yet)",{err:String(c)})),await ha("launchctl",["load","-w",i]),Zr.info("launchd job loaded",{label:xs});let o=process.getuid?.()??0;await ha("launchctl",["kickstart","-k",`gui/${o}/${xs}`]),Zr.info("launchd job kickstarted",{label:xs,uid:o})},async uninstall(t){let e=this.configPath(t);await ha("launchctl",["unload","-w",e]).catch(r=>Zr.warn("launchctl unload failed (ignored)",{err:String(r)})),await qS(e).catch(r=>{if(r.code!=="ENOENT")throw r}),Zr.info("launchd job removed",{plistPath:e})}}});import{spawn as ZS}from"node:child_process";import{mkdir as JS,unlink as YS,writeFile as XS}from"node:fs/promises";import{dirname as QS,join as kp}from"node:path";function ga(t,e){return t.isRoot?e:["--user",...e]}function t2(t){return t?Object.entries(t).map(([e,r])=>{let i=r.replace(/\\/g,"\\\\").replace(/"/g,'\\"');return`Environment="${e}=${i}"`}).join(`
|
|
51
|
+
`):""}function ma(t,e){return new Promise((r,i)=>{let o=ZS(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?r():i(new Error(`${t} ${e.join(" ")} exited ${d}: ${c.trim()}`))})})}var pa,Yr,e2,id,Tp=rt(()=>{"use strict";re();pa=j("supervisor.systemd"),Yr="coze-bridge.service",e2="/etc/systemd/system";id={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
|
+
${t2(t.env)}
|
|
63
63
|
[Install]
|
|
64
64
|
WantedBy=${e}
|
|
65
|
-
`},configPath(t){return t.isRoot?
|
|
65
|
+
`},configPath(t){return t.isRoot?kp(e2,Yr):kp(t.homeDir,".config","systemd","user",Yr)},async install(t,e){let r=e?.activate!==!1,i=this.configPath(t),o=t.isRoot?"system":"user";await JS(QS(i),{recursive:!0}),await XS(i,this.renderConfig(t),"utf8"),pa.info("systemd unit written",{unitPath:i,mode:o,activate:r}),await ma("systemctl",ga(t,["daemon-reload"])),await ma("systemctl",ga(t,r?["enable","--now",Yr]:["enable",Yr])),pa.info("systemd unit enabled",{unitName:Yr,mode:o,activate:r})},async uninstall(t){let e=this.configPath(t);await ma("systemctl",ga(t,["disable","--now",Yr])).catch(r=>pa.warn("systemctl disable failed (ignored)",{err:String(r)})),await YS(e).catch(r=>{if(r.code!=="ENOENT")throw r}),await ma("systemctl",ga(t,["daemon-reload"])).catch(()=>{}),pa.info("systemd unit removed",{unitPath:e})}}});import{spawn as n2}from"node:child_process";import{join as r2}from"node:path";function Rp(t,e){return new Promise((r,i)=>{let o=n2(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?r():i(new Error(`${t} ${e.join(" ")} exited ${d}: ${c.trim()}`))})})}var sd,wa,od,Cp=rt(()=>{"use strict";re();sd=j("supervisor.taskscheduler"),wa="CozeBridge",od={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,52 +86,52 @@ WantedBy=${e}
|
|
|
86
86
|
</Exec>
|
|
87
87
|
</Actions>
|
|
88
88
|
</Task>
|
|
89
|
-
`},configPath(t){return rI(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 Cp("schtasks",["/Create","/SC","ONLOGON","/TN",ga,"/TR",r,"/RU",t.userName,"/F"]),rd.info("task scheduler entry created",{task:ga,logFile:t.logFile})},async uninstall(t){await Cp("schtasks",["/Delete","/TN",ga,"/F"]).catch(e=>rd.warn("schtasks /Delete failed (ignored)",{err:String(e)})),rd.info("task scheduler entry removed",{task:ga})}}});var Pp={};Ra(Pp,{buildContext:()=>lI,getSupervisor:()=>oI,launchdSupervisor:()=>td,systemdSupervisor:()=>nd,taskSchedulerSupervisor:()=>id});import{homedir as iI,userInfo as sI}from"node:os";function oI(t=process.platform){switch(t){case"darwin":return td;case"linux":return nd;case"win32":return id;default:throw new Error(`unsupported platform for OS supervisor: ${t}`)}}function cI(){let t={};for(let e of aI){let r=process.env[e];r&&(t[e]=r)}return t}function lI(){let t=J();return{nodeBin:process.execPath,entry:Kl(t),logFile:t.logFile,homeDir:iI(),userName:sI().username,isRoot:process.getuid?.()===0,env:cI()}}var aI,Dp=et(()=>{"use strict";Ce();sa();Ap();kp();Rp();aI=["PATH","HOME","HTTP_PROXY","HTTPS_PROXY","NO_PROXY","ALL_PROXY","http_proxy","https_proxy","no_proxy","all_proxy","NODE_EXTRA_CA_CERTS"]});te();an();var Md=H("acp-installer-warmup"),sm=["claude-code","codex"];async function Bd(t={}){let e=t.ensure??ar,i=(await Promise.allSettled(sm.map(async o=>{let c=await e(o);Md.info("acp wrapper warmup ok",{framework:o,path:c})}))).filter(o=>o.status==="rejected");i.length>0&&Md.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))})}Ht();te();import{readdir as bm}from"node:fs/promises";import{mkdir as Hd,readFile as _m,writeFile as Gd}from"node:fs/promises";import{join as Ba}from"node:path";var ym={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md",hermes:"AGENTS.md"};async function dr(t,e,r){await Hd(t,{recursive:!0});let i=ym[e],o=Ba(t,i);return await Gd(o,r??"","utf8"),o}async function Fa(t,e,r){let i=Ba(t,".claude");await Hd(i,{recursive:!0});let o=Ba(i,"settings.local.json"),c={};try{let u=await _m(o,"utf8"),f=JSON.parse(u);typeof f=="object"&&f!==null&&!Array.isArray(f)&&(c=f)}catch{}let l=typeof c.permissions=="object"&&c.permissions!==null&&!Array.isArray(c.permissions)?c.permissions:{};if(e==="cloud")l.defaultMode="bypassPermissions",c.autoCompactWindow=15e4;else{if(!r)throw new Error("writeCcPermissionSettings: local deployType requires permissionMode (caller bug)");l.defaultMode===void 0&&(l.defaultMode=r)}return c.permissions=l,await Gd(o,JSON.stringify(c,null,2),"utf8"),o}var Ye=H("agent-detail-sync"),Em=6e4,vm=5*6e4,ys=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let r=this.opts.paths.agentsRoot,i;try{i=await bm(r)}catch(o){Ye.info("agents dir not found, skip detail sync",{root:r,err:String(o)});return}Ye.info("starting detail sync",{reason:e,count:i.length}),await Promise.allSettled(i.map(async o=>{let c=await Ee(o,this.opts.paths).catch(()=>null);if(c){if(c.disconnectedAt){Ye.debug("detail sync: skip disconnected agent",{agentId:o});return}try{await this.syncOne(o,c)}catch(l){Ye.warn("detail sync failed for agent, skipping",{agentId:o,err:String(l)})}}})),Ye.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){Ye.info("retrying pending detail syncs",{count:r.length});for(let i of r)try{await this.syncOne(i)}catch(o){Ye.debug("detail sync retry still failing, will try again",{agentId:i,err:String(o)})}}}async syncOne(e,r){let i=r??await Ee(e,this.opts.paths);if(!i){Ye.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){Ye.warn("detail RPC failed, using local data",{agentId:e,err:String(f)});let x=this.retryQueue.get(e),p=x?Math.min(x.currentDelay*2,vm):Em;this.retryQueue.set(e,{dueAt:Date.now()+p,currentDelay:p});return}if(o.agentId&&o.agentId!==e){Ye.warn("detail response agentId mismatch, ignoring",{agentId:e,responseAgentId:o.agentId});return}let c=!1,l=!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,l=!0);let u=!1;if(o.deployType==="cloud"&&i.deployType!=="cloud"?(Ye.warn("detail sync: agent demoted to local, repairing to cloud",{agentId:e}),i.deployType="cloud",c=!0,u=!0):o.deployType&&Ye.info("detail.deployType",{agentId:e,deployType:o.deployType}),!c){Ye.debug("detail sync: no diff",{agentId:e});return}await Fe(i,this.opts.paths),Ye.info("detail sync: config updated",{agentId:e,identityChanged:l,agentName:i.agentName}),u?(await this.opts.agentManager.createAgent({agentId:e,framework:i.framework,_meta:{cozeDeployType:"cloud"},cozeIdentity:i.cozeIdentity,model:i.model}),Ye.info("detail sync: repaired demoted agent back to cloud",{agentId:e})):l&&(await dr(i.workspace,i.framework,i.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};var cl=zt(bu(),1);import{createHash as ly}from"node:crypto";import{lstat as tl,mkdir as nl,readFile as po,readdir as u0,rm as rl,stat as c0,writeFile as il}from"node:fs/promises";import{dirname as dy,join as $e,normalize as uy,relative as al,resolve as sl,sep as f0}from"node:path";import{Readable as h0}from"node:stream";import{pipeline as x0}from"node:stream/promises";import Wm from"events";import nt from"fs";import{EventEmitter as Bc}from"node:events";import nf from"node:stream";import{StringDecoder as Km}from"node:string_decoder";import of from"node:path";import Er from"node:fs";import{dirname as sw,parse as ow}from"path";import{EventEmitter as xw}from"events";import wc from"assert";import{Buffer as Hn}from"buffer";import*as Au from"zlib";import pw from"zlib";import{posix as pr}from"node:path";import{basename as Gw}from"node:path";import Xs from"fs";import Rt from"fs";import Ou from"path";import{win32 as e_}from"node:path";import Uu from"path";import bf from"node:fs";import m_ from"node:assert";import{randomBytes as Ef}from"node:crypto";import ie from"node:fs";import Ne from"node:path";import vf from"fs";import ao from"node:fs";import Ii from"node:path";import ot from"node:fs";import S_ from"node:fs/promises";import to from"node:path";import{join as Lf}from"node:path";import st from"node:fs";import Bf from"node:path";var qm=Object.defineProperty,jm=(t,e)=>{for(var r in e)qm(t,r,{get:e[r],enumerable:!0})},Eu=typeof process=="object"&&process?process:{stdout:null,stderr:null},$m=t=>!!t&&typeof t=="object"&&(t instanceof jn||t instanceof nf||Vm(t)||Jm(t)),Vm=t=>!!t&&typeof t=="object"&&t instanceof Bc&&typeof t.pipe=="function"&&t.pipe!==nf.Writable.prototype.pipe,Jm=t=>!!t&&typeof t=="object"&&t instanceof Bc&&typeof t.write=="function"&&typeof t.end=="function",Gt=Symbol("EOF"),qt=Symbol("maybeEmitEnd"),ln=Symbol("emittedEnd"),Is=Symbol("emittingEnd"),ci=Symbol("emittedError"),As=Symbol("closed"),vu=Symbol("read"),Ts=Symbol("flush"),Su=Symbol("flushChunk"),wt=Symbol("encoding"),xr=Symbol("decoder"),ze=Symbol("flowing"),li=Symbol("paused"),_r=Symbol("resume"),Ue=Symbol("buffer"),Xe=Symbol("pipes"),He=Symbol("bufferLength"),ja=Symbol("bufferPush"),ks=Symbol("bufferShift"),Ze=Symbol("objectMode"),Ie=Symbol("destroyed"),Wa=Symbol("error"),Ka=Symbol("emitData"),Iu=Symbol("emitEnd"),$a=Symbol("emitEnd2"),Tt=Symbol("async"),Va=Symbol("abort"),Cs=Symbol("aborted"),di=Symbol("signal"),Dn=Symbol("dataListeners"),it=Symbol("discarded"),ui=t=>Promise.resolve().then(t),Zm=t=>t(),Ym=t=>t==="end"||t==="finish"||t==="prefinish",Xm=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,Qm=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),rf=class{src;dest;opts;ondrain;constructor(t,e,r){this.src=t,this.dest=e,this.opts=r,this.ondrain=()=>t[_r](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},ew=class extends rf{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)}},tw=t=>!!t.objectMode,nw=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",jn=class extends Bc{[ze]=!1;[li]=!1;[Xe]=[];[Ue]=[];[Ze];[wt];[Tt];[xr];[Gt]=!1;[ln]=!1;[Is]=!1;[As]=!1;[ci]=null;[He]=0;[Ie]=!1;[di];[Cs]=!1;[Dn]=0;[it]=!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");tw(e)?(this[Ze]=!0,this[wt]=null):nw(e)?(this[wt]=e.encoding,this[Ze]=!1):(this[Ze]=!1,this[wt]=null),this[Tt]=!!e.async,this[xr]=this[wt]?new Km(this[wt]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[Ue]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Xe]});let{signal:r}=e;r&&(this[di]=r,r.aborted?this[Va]():r.addEventListener("abort",()=>this[Va]()))}get bufferLength(){return this[He]}get encoding(){return this[wt]}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[Ze]}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}[Va](){this[Cs]=!0,this.emit("abort",this[di]?.reason),this.destroy(this[di]?.reason)}get aborted(){return this[Cs]}set aborted(t){}write(t,e,r){if(this[Cs])return!1;if(this[Gt])throw new Error("write after end");if(this[Ie])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[Tt]?ui:Zm;if(!this[Ze]&&!Buffer.isBuffer(t)){if(Qm(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(Xm(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[Ze]?(this[ze]&&this[He]!==0&&this[Ts](!0),this[ze]?this.emit("data",t):this[ja](t),this[He]!==0&&this.emit("readable"),r&&i(r),this[ze]):t.length?(typeof t=="string"&&!(e===this[wt]&&!this[xr]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[wt]&&(t=this[xr].write(t)),this[ze]&&this[He]!==0&&this[Ts](!0),this[ze]?this.emit("data",t):this[ja](t),this[He]!==0&&this.emit("readable"),r&&i(r),this[ze]):(this[He]!==0&&this.emit("readable"),r&&i(r),this[ze])}read(t){if(this[Ie])return null;if(this[it]=!1,this[He]===0||t===0||t&&t>this[He])return this[qt](),null;this[Ze]&&(t=null),this[Ue].length>1&&!this[Ze]&&(this[Ue]=[this[wt]?this[Ue].join(""):Buffer.concat(this[Ue],this[He])]);let e=this[vu](t||null,this[Ue][0]);return this[qt](),e}[vu](t,e){if(this[Ze])this[ks]();else{let r=e;t===r.length||t===null?this[ks]():typeof r=="string"?(this[Ue][0]=r.slice(t),e=r.slice(0,t),this[He]-=t):(this[Ue][0]=r.subarray(t),e=r.subarray(0,t),this[He]-=t)}return this.emit("data",e),!this[Ue].length&&!this[Gt]&&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[Gt]=!0,this.writable=!1,(this[ze]||!this[li])&&this[qt](),this}[_r](){this[Ie]||(!this[Dn]&&!this[Xe].length&&(this[it]=!0),this[li]=!1,this[ze]=!0,this.emit("resume"),this[Ue].length?this[Ts]():this[Gt]?this[qt]():this.emit("drain"))}resume(){return this[_r]()}pause(){this[ze]=!1,this[li]=!0,this[it]=!1}get destroyed(){return this[Ie]}get flowing(){return this[ze]}get paused(){return this[li]}[ja](t){this[Ze]?this[He]+=1:this[He]+=t.length,this[Ue].push(t)}[ks](){return this[Ze]?this[He]-=1:this[He]-=this[Ue][0].length,this[Ue].shift()}[Ts](t=!1){do;while(this[Su](this[ks]())&&this[Ue].length);!t&&!this[Ue].length&&!this[Gt]&&this.emit("drain")}[Su](t){return this.emit("data",t),this[ze]}pipe(t,e){if(this[Ie])return t;this[it]=!1;let r=this[ln];return e=e||{},t===Eu.stdout||t===Eu.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,r?e.end&&t.end():(this[Xe].push(e.proxyErrors?new ew(this,t,e):new rf(this,t,e)),this[Tt]?ui(()=>this[_r]()):this[_r]()),t}unpipe(t){let e=this[Xe].find(r=>r.dest===t);e&&(this[Xe].length===1?(this[ze]&&this[Dn]===0&&(this[ze]=!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[it]=!1,this[Dn]++,!this[Xe].length&&!this[ze]&&this[_r]();else if(t==="readable"&&this[He]!==0)super.emit("readable");else if(Ym(t)&&this[ln])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[ci]){let i=e;this[Tt]?ui(()=>i.call(this,this[ci])):i.call(this,this[ci])}return r}removeListener(t,e){return this.off(t,e)}off(t,e){let r=super.off(t,e);return t==="data"&&(this[Dn]=this.listeners("data").length,this[Dn]===0&&!this[it]&&!this[Xe].length&&(this[ze]=!1)),r}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[Dn]=0,!this[it]&&!this[Xe].length&&(this[ze]=!1)),e}get emittedEnd(){return this[ln]}[qt](){!this[Is]&&!this[ln]&&!this[Ie]&&this[Ue].length===0&&this[Gt]&&(this[Is]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[As]&&this.emit("close"),this[Is]=!1)}emit(t,...e){let r=e[0];if(t!=="error"&&t!=="close"&&t!==Ie&&this[Ie])return!1;if(t==="data")return!this[Ze]&&!r?!1:this[Tt]?(ui(()=>this[Ka](r)),!0):this[Ka](r);if(t==="end")return this[Iu]();if(t==="close"){if(this[As]=!0,!this[ln]&&!this[Ie])return!1;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[ci]=r,super.emit(Wa,r);let o=!this[di]||this.listeners("error").length?super.emit("error",r):!1;return this[qt](),o}else if(t==="resume"){let o=super.emit("resume");return this[qt](),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[qt](),i}[Ka](t){for(let r of this[Xe])r.dest.write(t)===!1&&this.pause();let e=this[it]?!1:super.emit("data",t);return this[qt](),e}[Iu](){return this[ln]?!1:(this[ln]=!0,this.readable=!1,this[Tt]?(ui(()=>this[$a]()),!0):this[$a]())}[$a](){if(this[xr]){let e=this[xr].end();if(e){for(let r of this[Xe])r.dest.write(e);this[it]||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[Ze]||(t.dataLength=0);let e=this.promise();return this.on("data",r=>{t.push(r),this[Ze]||(t.dataLength+=r.length)}),await e,t}async concat(){if(this[Ze])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[wt]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(Ie,()=>e(new Error("stream destroyed"))),this.on("error",r=>e(r)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[it]=!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[Gt])return e();let i,o,c=x=>{this.off("data",l),this.off("end",u),this.off(Ie,f),e(),o(x)},l=x=>{this.off("error",c),this.off("end",u),this.off(Ie,f),this.pause(),i({value:x,done:!!this[Gt]})},u=()=>{this.off("error",c),this.off("data",l),this.off(Ie,f),e(),i({done:!0,value:void 0})},f=()=>c(new Error("stream destroyed"));return new Promise((x,p)=>{o=p,i=x,this.once(Ie,f),this.once("error",c),this.once("end",u),this.once("data",l)})},throw:e,return:e,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[it]=!1;let t=!1,e=()=>(this.pause(),this.off(Wa,e),this.off(Ie,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(Wa,e),this.once(Ie,e),{next:r,throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[Ie])return t?this.emit("error",t):this.emit(Ie),this;this[Ie]=!0,this[it]=!0,this[Ue].length=0,this[He]=0;let e=this;return typeof e.close=="function"&&!this[As]&&e.close(),t?this.emit("error",t):this.emit(Ie),this}static get isStream(){return $m}},rw=nt.writev,_n=Symbol("_autoClose"),Et=Symbol("_close"),fi=Symbol("_ended"),le=Symbol("_fd"),Ja=Symbol("_finished"),$t=Symbol("_flags"),Za=Symbol("_flush"),gc=Symbol("_handleChunk"),mc=Symbol("_makeBuf"),vi=Symbol("_mode"),Rs=Symbol("_needDrain"),Sr=Symbol("_onerror"),Ir=Symbol("_onopen"),Ya=Symbol("_onread"),yr=Symbol("_onwrite"),yn=Symbol("_open"),bt=Symbol("_path"),xn=Symbol("_pos"),kt=Symbol("_queue"),br=Symbol("_read"),Xa=Symbol("_readSize"),Kt=Symbol("_reading"),hi=Symbol("_remain"),Qa=Symbol("_size"),Us=Symbol("_write"),On=Symbol("_writing"),Hs=Symbol("_defaultFlag"),Un=Symbol("_errored"),Fc=class extends jn{[Un]=!1;[le];[bt];[Xa];[Kt]=!1;[Qa];[hi];[_n];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[Un]=!1,this[le]=typeof e.fd=="number"?e.fd:void 0,this[bt]=t,this[Xa]=e.readSize||16*1024*1024,this[Kt]=!1,this[Qa]=typeof e.size=="number"?e.size:1/0,this[hi]=this[Qa],this[_n]=typeof e.autoClose=="boolean"?e.autoClose:!0,typeof this[le]=="number"?this[br]():this[yn]()}get fd(){return this[le]}get path(){return this[bt]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[yn](){nt.open(this[bt],"r",(t,e)=>this[Ir](t,e))}[Ir](t,e){t?this[Sr](t):(this[le]=e,this.emit("open",e),this[br]())}[mc](){return Buffer.allocUnsafe(Math.min(this[Xa],this[hi]))}[br](){if(!this[Kt]){this[Kt]=!0;let t=this[mc]();if(t.length===0)return process.nextTick(()=>this[Ya](null,0,t));nt.read(this[le],t,0,t.length,null,(e,r,i)=>this[Ya](e,r,i))}}[Ya](t,e,r){this[Kt]=!1,t?this[Sr](t):this[gc](e,r)&&this[br]()}[Et](){if(this[_n]&&typeof this[le]=="number"){let t=this[le];this[le]=void 0,nt.close(t,e=>e?this.emit("error",e):this.emit("close"))}}[Sr](t){this[Kt]=!0,this[Et](),this.emit("error",t)}[gc](t,e){let r=!1;return this[hi]-=t,t>0&&(r=super.write(t<e.length?e.subarray(0,t):e)),(t===0||this[hi]<=0)&&(r=!1,this[Et](),super.end()),r}emit(t,...e){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[le]=="number"&&this[br](),!1;case"error":return this[Un]?!1:(this[Un]=!0,super.emit(t,...e));default:return super.emit(t,...e)}}},iw=class extends Fc{[yn](){let t=!0;try{this[Ir](null,nt.openSync(this[bt],"r")),t=!1}finally{t&&this[Et]()}}[br](){let t=!0;try{if(!this[Kt]){this[Kt]=!0;do{let e=this[mc](),r=e.length===0?0:nt.readSync(this[le],e,0,e.length,null);if(!this[gc](r,e))break}while(!0);this[Kt]=!1}t=!1}finally{t&&this[Et]()}}[Et](){if(this[_n]&&typeof this[le]=="number"){let t=this[le];this[le]=void 0,nt.closeSync(t),this.emit("close")}}},no=class extends Wm{readable=!1;writable=!0;[Un]=!1;[On]=!1;[fi]=!1;[kt]=[];[Rs]=!1;[bt];[vi];[_n];[le];[Hs];[$t];[Ja]=!1;[xn];constructor(t,e){e=e||{},super(e),this[bt]=t,this[le]=typeof e.fd=="number"?e.fd:void 0,this[vi]=e.mode===void 0?438:e.mode,this[xn]=typeof e.start=="number"?e.start:void 0,this[_n]=typeof e.autoClose=="boolean"?e.autoClose:!0;let r=this[xn]!==void 0?"r+":"w";this[Hs]=e.flags===void 0,this[$t]=e.flags===void 0?r:e.flags,this[le]===void 0&&this[yn]()}emit(t,...e){if(t==="error"){if(this[Un])return!1;this[Un]=!0}return super.emit(t,...e)}get fd(){return this[le]}get path(){return this[bt]}[Sr](t){this[Et](),this[On]=!0,this.emit("error",t)}[yn](){nt.open(this[bt],this[$t],this[vi],(t,e)=>this[Ir](t,e))}[Ir](t,e){this[Hs]&&this[$t]==="r+"&&t&&t.code==="ENOENT"?(this[$t]="w",this[yn]()):t?this[Sr](t):(this[le]=e,this.emit("open",e),this[On]||this[Za]())}end(t,e){return t&&this.write(t,e),this[fi]=!0,!this[On]&&!this[kt].length&&typeof this[le]=="number"&&this[yr](null,0),this}write(t,e){return typeof t=="string"&&(t=Buffer.from(t,e)),this[fi]?(this.emit("error",new Error("write() after end()")),!1):this[le]===void 0||this[On]||this[kt].length?(this[kt].push(t),this[Rs]=!0,!1):(this[On]=!0,this[Us](t),!0)}[Us](t){nt.write(this[le],t,0,t.length,this[xn],(e,r)=>this[yr](e,r))}[yr](t,e){t?this[Sr](t):(this[xn]!==void 0&&typeof e=="number"&&(this[xn]+=e),this[kt].length?this[Za]():(this[On]=!1,this[fi]&&!this[Ja]?(this[Ja]=!0,this[Et](),this.emit("finish")):this[Rs]&&(this[Rs]=!1,this.emit("drain"))))}[Za](){if(this[kt].length===0)this[fi]&&this[yr](null,0);else if(this[kt].length===1)this[Us](this[kt].pop());else{let t=this[kt];this[kt]=[],rw(this[le],t,this[xn],(e,r)=>this[yr](e,r))}}[Et](){if(this[_n]&&typeof this[le]=="number"){let t=this[le];this[le]=void 0,nt.close(t,e=>e?this.emit("error",e):this.emit("close"))}}},sf=class extends no{[yn](){let t;if(this[Hs]&&this[$t]==="r+")try{t=nt.openSync(this[bt],this[$t],this[vi])}catch(e){if(e?.code==="ENOENT")return this[$t]="w",this[yn]();throw e}else t=nt.openSync(this[bt],this[$t],this[vi]);this[Ir](null,t)}[Et](){if(this[_n]&&typeof this[le]=="number"){let t=this[le];this[le]=void 0,nt.closeSync(t),this.emit("close")}}[Us](t){let e=!0;try{this[yr](null,nt.writeSync(this[le],t,0,t.length,this[xn])),e=!1}finally{if(e)try{this[Et]()}catch{}}}},aw=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"]]),cw=t=>!!t.sync&&!!t.file,lw=t=>!t.sync&&!!t.file,dw=t=>!!t.sync&&!t.file,uw=t=>!t.sync&&!t.file,fw=t=>!!t.file,hw=t=>aw.get(t)||t,zc=(t={})=>{if(!t)return{};let e={};for(let[r,i]of Object.entries(t)){let o=hw(r);e[o]=i}return e.chmod===void 0&&e.noChmod===!1&&(e.chmod=!0),delete e.noChmod,e},Di=(t,e,r,i,o)=>Object.assign((c=[],l,u)=>{Array.isArray(c)&&(l=c,c={}),typeof l=="function"&&(u=l,l=void 0),l=l?Array.from(l):[];let f=zc(c);if(o?.(f,l),cw(f)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return t(f,l)}else if(lw(f)){let x=e(f,l);return u?x.then(()=>u(),u):x}else if(dw(f)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return r(f,l)}else if(uw(f)){if(typeof u=="function")throw new TypeError("callback only supported with file option");return i(f,l)}throw new Error("impossible options??")},{syncFile:t,asyncFile:e,syncNoFile:r,asyncNoFile:i,validate:o}),gw=pw.constants||{ZLIB_VERNUM:4736},Dt=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},gw)),mw=Hn.concat,Tu=Object.getOwnPropertyDescriptor(Hn,"concat"),ww=t=>t,ec=Tu?.writable===!0||Tu?.set!==void 0?t=>{Hn.concat=t?ww:mw}:t=>{},Gn=Symbol("_superWrite"),Ps=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"}},tc=Symbol("flushFlag"),Uc=class extends jn{#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 Au[e]!="function")throw new TypeError("Compression method not supported: "+e);try{this.#t=new Au[e](t)}catch(r){throw new Ps(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 Ps(r))),this.once("end",()=>this.close)}close(){this.#t&&(this.#t.close(),this.#t=void 0,this.emit("close"))}reset(){if(!this.#e)return wc(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),{[tc]: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}[Gn](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;wc(this.#t,"zlib binding closed");let i=this.#t._handle,o=i.close;i.close=()=>{};let c=this.#t.close;this.#t.close=()=>{},ec(!0);let l;try{let f=typeof t[tc]=="number"?t[tc]:this.#r;l=this.#t._processChunk(t,f),ec(!1)}catch(f){ec(!1),this.#o(new Ps(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 Ps(f,this.write)));let u;if(l)if(Array.isArray(l)&&l.length>0){let f=l[0];u=this[Gn](Hn.from(f));for(let x=1;x<l.length;x++)u=this[Gn](l[x])}else u=this[Gn](Hn.from(l));return r&&r(),u}},af=class extends Uc{#e;#n;constructor(t,e){t=t||{},t.flush=t.flush||Dt.Z_NO_FLUSH,t.finishFlush=t.finishFlush||Dt.Z_FINISH,t.fullFlushFlag=Dt.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(Dt.Z_SYNC_FLUSH),wc(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)}}}},_w=class extends af{#e;constructor(t){super(t,"Gzip"),this.#e=t&&!!t.portable}[Gn](t){return this.#e?(this.#e=!1,t[9]=255,super[Gn](t)):super[Gn](t)}},yw=class extends af{constructor(t){super(t,"Unzip")}},cf=class extends Uc{constructor(t,e){t=t||{},t.flush=t.flush||Dt.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||Dt.BROTLI_OPERATION_FINISH,t.fullFlushFlag=Dt.BROTLI_OPERATION_FLUSH,super(t,e)}},bw=class extends cf{constructor(t){super(t,"BrotliCompress")}},Ew=class extends cf{constructor(t){super(t,"BrotliDecompress")}},lf=class extends Uc{constructor(t,e){t=t||{},t.flush=t.flush||Dt.ZSTD_e_continue,t.finishFlush=t.finishFlush||Dt.ZSTD_e_end,t.fullFlushFlag=Dt.ZSTD_e_flush,super(t,e)}},vw=class extends lf{constructor(t){super(t,"ZstdCompress")}},Sw=class extends lf{constructor(t){super(t,"ZstdDecompress")}},Iw=(t,e)=>{if(Number.isSafeInteger(t))t<0?Tw(t,e):Aw(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},Aw=(t,e)=>{e[0]=128;for(var r=e.length;r>1;r--)e[r-1]=t&255,t=Math.floor(t/256)},Tw=(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]=df(o):o===0?e[i-1]=0:(r=!0,e[i-1]=uf(o))}},kw=t=>{let e=t[0],r=e===128?Rw(t.subarray(1,t.length)):e===255?Cw(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},Cw=t=>{for(var e=t.length,r=0,i=!1,o=e-1;o>-1;o--){var c=Number(t[o]),l;i?l=df(c):c===0?l=c:(i=!0,l=uf(c)),l!==0&&(r-=l*Math.pow(256,e-o-1))}return r},Rw=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},df=t=>(255^t)&255,uf=t=>(255^t)+1&255,Pw={};jm(Pw,{code:()=>Hc,isCode:()=>Gs,isName:()=>Dw,name:()=>ro,normalFsTypes:()=>ff});var Gs=t=>ro.has(t),Dw=t=>Hc.has(t),ff=new Set(["0","","1","2","3","4","5","6","7","D"]),ro=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"]]),Hc=new Map(Array.from(ro).map(t=>[t[1],t[0]])),qn=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=Ln(t,e+156,1),c=ff.has(o),l=c?r:void 0,u=c?i:void 0;if(this.path=l?.path??Ln(t,e,100),this.mode=l?.mode??u?.mode??pn(t,e+100,8),this.uid=l?.uid??u?.uid??pn(t,e+108,8),this.gid=l?.gid??u?.gid??pn(t,e+116,8),this.size=l?.size??u?.size??pn(t,e+124,12),this.mtime=l?.mtime??u?.mtime??nc(t,e+136,12),this.cksum=pn(t,e+148,12),u&&this.#n(u,!0),l&&this.#n(l),Gs(o)&&(this.#e=o||"0"),this.#e==="0"&&this.path.slice(-1)==="/"&&(this.#e="5"),this.#e==="5"&&(this.size=0),this.linkpath=Ln(t,e+157,100),t.subarray(e+257,e+265).toString()==="ustar\x0000")if(this.uname=l?.uname??u?.uname??Ln(t,e+265,32),this.gname=l?.gname??u?.gname??Ln(t,e+297,32),this.devmaj=l?.devmaj??u?.devmaj??pn(t,e+329,8)??0,this.devmin=l?.devmin??u?.devmin??pn(t,e+337,8)??0,t[e+475]!==0){let x=Ln(t,e+345,155);this.path=x+"/"+this.path}else{let x=Ln(t,e+345,130);x&&(this.path=x+"/"+this.path),this.atime=r?.atime??i?.atime??nc(t,e+476,12),this.ctime=r?.ctime??i?.ctime??nc(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=Ow(this.path||"",r),o=i[0],c=i[1];this.needPax=!!i[2],this.needPax=Nn(t,e,100,o)||this.needPax,this.needPax=gn(t,e+100,8,this.mode)||this.needPax,this.needPax=gn(t,e+108,8,this.uid)||this.needPax,this.needPax=gn(t,e+116,8,this.gid)||this.needPax,this.needPax=gn(t,e+124,12,this.size)||this.needPax,this.needPax=rc(t,e+136,12,this.mtime)||this.needPax,t[e+156]=Number(this.#e.codePointAt(0)),this.needPax=Nn(t,e+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",e+257,8),this.needPax=Nn(t,e+265,32,this.uname)||this.needPax,this.needPax=Nn(t,e+297,32,this.gname)||this.needPax,this.needPax=gn(t,e+329,8,this.devmaj)||this.needPax,this.needPax=gn(t,e+337,8,this.devmin)||this.needPax,this.needPax=Nn(t,e+345,r,c)||this.needPax,t[e+475]!==0?this.needPax=Nn(t,e+345,155,c)||this.needPax:(this.needPax=Nn(t,e+345,130,c)||this.needPax,this.needPax=rc(t,e+476,12,this.atime)||this.needPax,this.needPax=rc(t,e+488,12,this.ctime)||this.needPax);let l=256;for(let u=e;u<e+148;u++)l+=t[u];for(let u=e+156;u<e+512;u++)l+=t[u];return this.cksum=l,gn(t,e+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#e==="Unsupported"?this.#e:ro.get(this.#e)}get typeKey(){return this.#e}set type(t){let e=String(Hc.get(t));if(Gs(e)||e==="Unsupported")this.#e=e;else if(Gs(t))this.#e=t;else throw new TypeError("invalid entry type: "+t)}},Ow=(t,e)=>{let r=t,i="",o,c=pr.parse(t).root||".";if(Buffer.byteLength(r)<100)o=[r,i,!1];else{i=pr.dirname(r),r=pr.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=pr.join(pr.basename(i),r),i=pr.dirname(i));while(i!==c&&o===void 0);o||(o=[t.slice(0,99),"",!0])}return o},Ln=(t,e,r)=>t.subarray(e,e+r).toString("utf8").replace(/\0.*/,""),nc=(t,e,r)=>Lw(pn(t,e,r)),Lw=t=>t===void 0?void 0:new Date(t*1e3),pn=(t,e,r)=>Number(t[e])&128?kw(t.subarray(e,e+r)):Mw(t,e,r),Nw=t=>isNaN(t)?void 0:t,Mw=(t,e,r)=>Nw(parseInt(t.subarray(e,e+r).toString("utf8").replace(/\0.*$/,"").trim(),8)),Bw={12:8589934591,8:2097151},gn=(t,e,r,i)=>i===void 0?!1:i>Bw[r]||i<0?(Iw(i,t.subarray(e,e+r)),!0):(Fw(t,e,r,i),!1),Fw=(t,e,r,i)=>t.write(zw(i,r),e,r,"ascii"),zw=(t,e)=>Uw(Math.floor(t).toString(8),e),Uw=(t,e)=>(t.length===e-1?t:new Array(e-t.length-1).join("0")+t+" ")+"\0",rc=(t,e,r,i)=>i===void 0?!1:gn(t,e,r,i.getTime()/1e3),Hw=new Array(156).join("\0"),Nn=(t,e,r,i)=>i===void 0?!1:(t.write(i+Hw,e,r,"utf8"),i.length!==Buffer.byteLength(i)||i.length>r),Ys=class hf{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 qn({path:("PaxHeader/"+Gw(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),
|
|
91
|
-
`).reduce(Ww,Object.create(null)),Ww=(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"),l=i.join("=");return t[c]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(c)?new Date(Number(l)*1e3):/^[0-9]+$/.test(l)?+l:l,t},Kw=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Q=Kw!=="win32"?t=>t:t=>t&&t.replaceAll(/\\/g,"/"),$w=class extends jn{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))))}},io=(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))},Vw=1024*1024,_c=Buffer.from([31,139]),yc=Buffer.from([40,181,47,253]),Jw=Math.max(_c.length,yc.length),dt=Symbol("state"),Mn=Symbol("writeEntry"),jt=Symbol("readEntry"),ic=Symbol("nextEntry"),ku=Symbol("processEntry"),Ct=Symbol("extendedHeader"),xi=Symbol("globalExtendedHeader"),dn=Symbol("meta"),Cu=Symbol("emitMeta"),ge=Symbol("buffer"),Wt=Symbol("queue"),un=Symbol("ended"),sc=Symbol("emittedEnd"),Bn=Symbol("emit"),Re=Symbol("unzip"),Ds=Symbol("consumeChunk"),Os=Symbol("consumeChunkSub"),oc=Symbol("consumeBody"),Ru=Symbol("consumeMeta"),Pu=Symbol("consumeHeader"),pi=Symbol("consuming"),ac=Symbol("bufferConcat"),Ls=Symbol("maybeEnd"),gr=Symbol("writing"),fn=Symbol("aborted"),Ns=Symbol("onDone"),Fn=Symbol("sawValidEntry"),Ms=Symbol("sawNullBlock"),Bs=Symbol("sawEOF"),Du=Symbol("closeStream"),Zw=()=>!0,Pi=class extends xw{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[Wt]=[];[ge];[jt];[Mn];[dt]="begin";[dn]="";[Ct];[xi];[un]=!1;[Re];[fn]=!1;[Fn];[Ms]=!1;[Bs]=!1;[gr]=!1;[pi]=!1;[sc]=!1;constructor(t={}){super(),this.file=t.file||"",this.on(Ns,()=>{(this[dt]==="begin"||this[Fn]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),t.ondone?this.on(Ns,t.ondone):this.on(Ns,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!t.strict,this.maxMetaEntrySize=t.maxMetaEntrySize||Vw,this.filter=typeof t.filter=="function"?t.filter:Zw;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[Du]()),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,e,r={}){io(this,t,e,r)}[Pu](t,e){this[Fn]===void 0&&(this[Fn]=!1);let r;try{r=new qn(t,e,this[Ct],this[xi])}catch(i){return this.warn("TAR_ENTRY_INVALID",i)}if(r.nullBlock)this[Ms]?(this[Bs]=!0,this[dt]==="begin"&&(this[dt]="header"),this[Bn]("eof")):(this[Ms]=!0,this[Bn]("nullBlock"));else if(this[Ms]=!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[Mn]=new $w(r,this[Ct],this[xi]);if(!this[Fn])if(o.remain){let c=()=>{o.invalid||(this[Fn]=!0)};o.on("end",c)}else this[Fn]=!0;o.meta?o.size>this.maxMetaEntrySize?(o.ignore=!0,this[Bn]("ignoredEntry",o),this[dt]="ignore",o.resume()):o.size>0&&(this[dn]="",o.on("data",c=>this[dn]+=c),this[dt]="meta"):(this[Ct]=void 0,o.ignore=o.ignore||!this.filter(o.path,o),o.ignore?(this[Bn]("ignoredEntry",o),this[dt]=o.remain?"ignore":"header",o.resume()):(o.remain?this[dt]="body":(this[dt]="header",o.end()),this[jt]?this[Wt].push(o):(this[Wt].push(o),this[ic]())))}}}[Du](){queueMicrotask(()=>this.emit("close"))}[ku](t){let e=!0;if(!t)this[jt]=void 0,e=!1;else if(Array.isArray(t)){let[r,...i]=t;this.emit(r,...i)}else this[jt]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",()=>this[ic]()),e=!1);return e}[ic](){do;while(this[ku](this[Wt].shift()));if(this[Wt].length===0){let t=this[jt];!t||t.flowing||t.size===t.remain?this[gr]||this.emit("drain"):t.once("drain",()=>this.emit("drain"))}}[oc](t,e){let r=this[Mn];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[dt]="header",this[Mn]=void 0,r.end()),o.length}[Ru](t,e){let r=this[Mn],i=this[oc](t,e);return!this[Mn]&&r&&this[Cu](r),i}[Bn](t,e,r){this[Wt].length===0&&!this[jt]?this.emit(t,e,r):this[Wt].push([t,e,r])}[Cu](t){switch(this[Bn]("meta",this[dn]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[Ct]=Ys.parse(this[dn],this[Ct],!1);break;case"GlobalExtendedHeader":this[xi]=Ys.parse(this[dn],this[xi],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let e=this[Ct]??Object.create(null);this[Ct]=e,e.path=this[dn].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let e=this[Ct]||Object.create(null);this[Ct]=e,e.linkpath=this[dn].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){this[fn]=!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[fn])return r?.(),!1;if((this[Re]===void 0||this.brotli===void 0&&this[Re]===!1)&&t){if(this[ge]&&(t=Buffer.concat([this[ge],t]),this[ge]=void 0),t.length<Jw)return this[ge]=t,r?.(),!0;for(let l=0;this[Re]===void 0&&l<_c.length;l++)t[l]!==_c[l]&&(this[Re]=!1);let o=!1;if(this[Re]===!1&&this.zstd!==!1){o=!0;for(let l=0;l<yc.length;l++)if(t[l]!==yc[l]){o=!1;break}}let c=this.brotli===void 0&&!o;if(this[Re]===!1&&c)if(t.length<512)if(this[un])this.brotli=!0;else return this[ge]=t,r?.(),!0;else try{new qn(t.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[Re]===void 0||this[Re]===!1&&(this.brotli||o)){let l=this[un];this[un]=!1,this[Re]=this[Re]===void 0?new yw({}):o?new Sw({}):new Ew({}),this[Re].on("data",f=>this[Ds](f)),this[Re].on("error",f=>this.abort(f)),this[Re].on("end",()=>{this[un]=!0,this[Ds]()}),this[gr]=!0;let u=!!this[Re][l?"end":"write"](t);return this[gr]=!1,r?.(),u}}this[gr]=!0,this[Re]?this[Re].write(t):this[Ds](t),this[gr]=!1;let i=this[Wt].length>0?!1:this[jt]?this[jt].flowing:!0;return!i&&this[Wt].length===0&&this[jt]?.once("drain",()=>this.emit("drain")),r?.(),i}[ac](t){t&&!this[fn]&&(this[ge]=this[ge]?Buffer.concat([this[ge],t]):t)}[Ls](){if(this[un]&&!this[sc]&&!this[fn]&&!this[pi]){this[sc]=!0;let t=this[Mn];if(t&&t.blockRemain){let e=this[ge]?this[ge].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`,{entry:t}),this[ge]&&t.write(this[ge]),t.end()}this[Bn](Ns)}}[Ds](t){if(this[pi]&&t)this[ac](t);else if(!t&&!this[ge])this[Ls]();else if(t){if(this[pi]=!0,this[ge]){this[ac](t);let e=this[ge];this[ge]=void 0,this[Os](e)}else this[Os](t);for(;this[ge]&&this[ge]?.length>=512&&!this[fn]&&!this[Bs];){let e=this[ge];this[ge]=void 0,this[Os](e)}this[pi]=!1}(!this[ge]||this[un])&&this[Ls]()}[Os](t){let e=0,r=t.length;for(;e+512<=r&&!this[fn]&&!this[Bs];)switch(this[dt]){case"begin":case"header":this[Pu](t,e),e+=512;break;case"ignore":case"body":e+=this[oc](t,e);break;case"meta":e+=this[Ru](t,e);break;default:throw new Error("invalid state: "+this[dt])}e<r&&(this[ge]=this[ge]?Buffer.concat([t.subarray(e),this[ge]]):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[fn]||(this[Re]?(t&&this[Re].write(t),this[Re].end()):(this[un]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t=t||Buffer.alloc(0)),t&&this.write(t),this[Ls]())),this}},Si=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)},Yw=t=>{let e=t.onReadEntry;t.onReadEntry=e?r=>{e(r),r.resume()}:r=>r.resume()},xf=(t,e)=>{let r=new Map(e.map(c=>[Si(c),!0])),i=t.filter,o=(c,l="")=>{let u=l||ow(c).root||".",f;if(c===u)f=!1;else{let x=r.get(c);f=x!==void 0?x:o(sw(c),u)}return r.set(c,f),f};t.filter=i?(c,l)=>i(c,l)&&o(Si(c)):c=>o(Si(c))},Xw=t=>{let e=new Pi(t),r=t.file,i;try{i=Er.openSync(r,"r");let o=Er.fstatSync(i),c=t.maxReadSize||16*1024*1024;if(o.size<c){let l=Buffer.allocUnsafe(o.size),u=Er.readSync(i,l,0,o.size,0);e.end(u===l.byteLength?l:l.subarray(0,u))}else{let l=0,u=Buffer.allocUnsafe(c);for(;l<o.size;){let f=Er.readSync(i,u,0,c,l);if(f===0)break;l+=f,e.write(u.subarray(0,f))}e.end()}}finally{if(typeof i=="number")try{Er.closeSync(i)}catch{}}},Qw=(t,e)=>{let r=new Pi(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,l)=>{r.on("error",l),r.on("end",c),Er.stat(o,(u,f)=>{if(u)l(u);else{let x=new Fc(o,{readSize:i,size:f.size});x.on("error",l),x.pipe(r)}})})},Ar=Di(Xw,Qw,t=>new Pi(t),t=>new Pi(t),(t,e)=>{e?.length&&xf(t,e),t.noResume||Yw(t)}),pf=(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:t_,parse:Lu}=e_,Gc=t=>{let e="",r=Lu(t);for(;t_(t)||r.root;){let i=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":r.root;t=t.slice(i.length),e+=i,r=Lu(t)}return[e,t]},so=["|","<",">","?",":"],qc=so.map(t=>String.fromCodePoint(61440+Number(t.codePointAt(0)))),n_=new Map(so.map((t,e)=>[t,qc[e]])),r_=new Map(qc.map((t,e)=>[t,so[e]])),Nu=t=>so.reduce((e,r)=>e.split(r).join(n_.get(r)),t),i_=t=>qc.reduce((e,r)=>e.split(r).join(r_.get(r)),t),gf=(t,e)=>e?(t=Q(t).replace(/^\.(\/|$)/,""),Si(e)+"/"+t):Q(t),s_=16*1024*1024,Mu=Symbol("process"),Bu=Symbol("file"),Fu=Symbol("directory"),bc=Symbol("symlink"),zu=Symbol("hardlink"),gi=Symbol("header"),qs=Symbol("read"),Ec=Symbol("lstat"),js=Symbol("onlstat"),vc=Symbol("onread"),Sc=Symbol("onreadlink"),Ic=Symbol("openfile"),Ac=Symbol("onopenfile"),mn=Symbol("close"),Qs=Symbol("mode"),Tc=Symbol("awaitDrain"),cc=Symbol("ondrain"),Pt=Symbol("prefix"),mf=class extends jn{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=zc(e);super(),this.path=Q(t),this.portable=!!r.portable,this.maxReadSize=r.maxReadSize||s_,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,l]=Gc(this.path);c&&typeof l=="string"&&(this.path=l,i=c)}this.win32=!!r.win32||process.platform==="win32",this.win32&&(this.path=i_(this.path.replaceAll(/\\/g,"/")),t=t.replaceAll(/\\/g,"/")),this.absolute=Q(r.absolute||Ou.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[js](o):this[Ec]()}warn(t,e,r={}){return io(this,t,e,r)}emit(t,...e){return t==="error"&&(this.#e=!0),super.emit(t,...e)}[Ec](){Rt.lstat(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[js](e)})}[js](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=c_(t),this.emit("stat",t),this[Mu]()}[Mu](){switch(this.type){case"File":return this[Bu]();case"Directory":return this[Fu]();case"SymbolicLink":return this[bc]();default:return this.end()}}[Qs](t){return pf(t,this.type==="Directory",this.portable)}[Pt](t){return gf(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 qn({path:this[Pt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Pt](this.linkpath):this.linkpath,mode:this[Qs](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 Ys({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[Pt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Pt](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)}[Fu](){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()}[bc](){Rt.readlink(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[Sc](e)})}[Sc](t){this.linkpath=Q(t),this[gi](),this.end()}[zu](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=Q(Ou.relative(this.cwd,t)),this.stat.size=0,this[gi](),this.end()}[Bu](){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[zu](e);this.linkCache.set(t,this.absolute)}if(this[gi](),this.stat.size===0)return this.end();this[Ic]()}[Ic](){Rt.open(this.absolute,"r",(t,e)=>{if(t)return this.emit("error",t);this[Ac](e)})}[Ac](t){if(this.fd=t,this.#e)return this[mn]();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[qs]()}[qs](){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");Rt.read(t,e,r,i,o,(c,l)=>{if(c)return this[mn](()=>this.emit("error",c));this[vc](l)})}[mn](t=()=>{}){this.fd!==void 0&&Rt.close(this.fd,t)}[vc](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[mn](()=>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[mn](()=>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[cc]():this[Tc](()=>this[cc]())}[Tc](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)}[cc](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[mn](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[qs]()}},o_=class extends mf{sync=!0;[Ec](){this[js](Rt.lstatSync(this.absolute))}[bc](){this[Sc](Rt.readlinkSync(this.absolute))}[Ic](){this[Ac](Rt.openSync(this.absolute,"r"))}[qs](){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 l=Rt.readSync(e,r,i,o,c);this[vc](l),t=!1}finally{if(t)try{this[mn](()=>{})}catch{}}}[Tc](t){t()}[mn](t=()=>{}){this.fd!==void 0&&Rt.closeSync(this.fd),t()}},a_=class extends jn{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 io(this,t,e,r)}constructor(t,e={}){let r=zc(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[Qs](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[l,u]=Gc(this.path);l&&typeof u=="string"&&(this.path=u,o=l)}this.remain=t.size,this.blockRemain=t.startBlockSize,this.onWriteEntry?.(this),this.header=new qn({path:this[Pt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Pt](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 Ys({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[Pt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Pt](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)}[Pt](t){return gf(t,this.prefix)}[Qs](t){return pf(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}},c_=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported",l_=class vr{tail;head;length=0;static create(e=[]){return new vr(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++)u_(this,e[r]);return this.length}unshift(...e){for(var r=0,i=e.length;r<i;r++)f_(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 vr;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 vr;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 vr;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 vr;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 l=0;o&&l<e;l++)o=o.next;let c=[];for(let l=0;o&&l<r;l++)c.push(o.value),o=this.removeNode(o);o?o!==this.tail&&(o=o.prev):o=this.tail;for(let l of i)o=d_(this,o,l);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 d_(t,e,r){let i=e,o=e?e.next:t.head,c=new jc(r,i,o,t);return c.next===void 0&&(t.tail=c),c.prev===void 0&&(t.head=c),t.length++,c}function u_(t,e){t.tail=new jc(e,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function f_(t,e){t.head=new jc(e,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}var jc=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}},Hu=class{path;absolute;entry;stat;readdir;pending=!1;pendingLink=!1;ignore=!1;piped=!1;constructor(t,e){this.path=t||"./",this.absolute=e}},Gu=Buffer.alloc(1024),Ws=Symbol("onStat"),mi=Symbol("ended"),_t=Symbol("queue"),wi=Symbol("pendingLinks"),hn=Symbol("current"),zn=Symbol("process"),_i=Symbol("processing"),Fs=Symbol("processJob"),yt=Symbol("jobs"),lc=Symbol("jobDone"),Ks=Symbol("addFSEntry"),qu=Symbol("addTarEntry"),kc=Symbol("stat"),Cc=Symbol("readdir"),$s=Symbol("onreaddir"),Vs=Symbol("pipe"),ju=Symbol("entry"),dc=Symbol("entryOpt"),Js=Symbol("writeEntryClass"),wf=Symbol("write"),uc=Symbol("ondrain"),oo=class extends jn{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[Js];onWriteEntry;[_t];[wi]=new Map;[yt]=0;[_i]=!1;[mi]=!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[Js]=mf,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 _w(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new bw(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new vw(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[uc]()),this.on("resume",()=>e.resume())}else this.on("drain",this[uc]);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[_t]=new l_,this[yt]=0,this.jobs=Number(t.jobs)||4,this[_i]=!1,this[mi]=!1}[wf](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[mi]=!0,this[zn](),r&&r(),this}write(t){if(this[mi])throw new Error("write after end");return typeof t=="string"?this[Ks](t):this[qu](t),this.flowing}[qu](t){let e=Q(Uu.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let r=new Hu(t.path,e);r.entry=new a_(t,this[dc](r)),r.entry.on("end",()=>this[lc](r)),this[yt]+=1,this[_t].push(r)}this[zn]()}[Ks](t){let e=Q(Uu.resolve(this.cwd,t));this[_t].push(new Hu(t,e)),this[zn]()}[kc](t){t.pending=!0,this[yt]+=1;let e=this.follow?"stat":"lstat";Xs[e](t.absolute,(r,i)=>{t.pending=!1,this[yt]-=1,r?this.emit("error",r):this[Ws](t,i)})}[Ws](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[hn])this[Fs](t);else{let r=`${e.dev}:${e.ino}`,i=this[wi].get(r);i?i.push(t):this[wi].set(r,[t]),t.pendingLink=!0,t.pending=!0}this[zn]()}[Cc](t){t.pending=!0,this[yt]+=1,Xs.readdir(t.absolute,(e,r)=>{if(t.pending=!1,this[yt]-=1,e)return this.emit("error",e);this[$s](t,r)})}[$s](t,e){this.readdirCache.set(t.absolute,e),t.readdir=e,this[zn]()}[zn](){if(!this[_i]){this[_i]=!0;for(let t=this[_t].head;t&&this[yt]<this.jobs;t=t.next)if(this[Fs](t.value),t.value.ignore){let e=t.next;this[_t].removeNode(t),t.next=e}this[_i]=!1,this[mi]&&this[_t].length===0&&this[yt]===0&&(this.zip?this.zip.end(Gu):(super.write(Gu),super.end()))}}get[hn](){return this[_t]&&this[_t].head&&this[_t].head.value}[lc](t){this[_t].shift(),this[yt]-=1;let{stat:e}=t;if(e&&e.isFile()&&e.nlink>1){let r=`${e.dev}:${e.ino}`,i=this[wi].get(r);if(i){this[wi].delete(r);for(let o of i)o.pending=!1,this[Fs](o)}}this[zn]()}[Fs](t){if(t.pending&&t.pendingLink&&t===this[hn]&&(t.pending=!1,t.pendingLink=!1),!t.pending){if(t.entry){t===this[hn]&&!t.piped&&this[Vs](t);return}if(!t.stat){let e=this.statCache.get(t.absolute);e?this[Ws](t,e):this[kc](t)}if(t.stat&&!t.ignore){if(!this.noDirRecurse&&t.stat.isDirectory()&&!t.readdir){let e=this.readdirCache.get(t.absolute);if(e?this[$s](t,e):this[Cc](t),!t.readdir)return}if(t.entry=this[ju](t),!t.entry){t.ignore=!0;return}t===this[hn]&&!t.piped&&this[Vs](t)}}}[dc](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}}[ju](t){this[yt]+=1;try{return new this[Js](t.path,this[dc](t)).on("end",()=>this[lc](t)).on("error",e=>this.emit("error",e))}catch(e){this.emit("error",e)}}[uc](){this[hn]&&this[hn].entry&&this[hn].entry.resume()}[Vs](t){t.piped=!0,t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[Ks](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={}){io(this,t,e,r)}},Wc=class extends oo{sync=!0;constructor(t){super(t),this[Js]=o_}pause(){}resume(){}[kc](t){let e=this.follow?"statSync":"lstatSync";this[Ws](t,Xs[e](t.absolute))}[Cc](t){this[$s](t,Xs.readdirSync(t.absolute))}[Vs](t){let e=t.entry,r=this.zip;if(t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[Ks](c+i)}),!e)throw new Error("Cannot pipe without source");r?e.on("data",i=>{r.write(i)}):e.on("data",i=>{super[wf](i)})}},h_=(t,e)=>{let r=new Wc(t),i=new sf(t.file,{mode:t.mode||438});r.pipe(i),_f(r,e)},x_=(t,e)=>{let r=new oo(t),i=new no(t.file,{mode:t.mode||438});r.pipe(i);let o=new Promise((c,l)=>{i.on("error",l),i.on("close",c),r.on("error",l)});return yf(r,e).catch(c=>r.emit("error",c)),o},_f=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?Ar({file:of.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},yf=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await Ar({file:of.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>{t.add(i)}}):t.add(r);t.end()},p_=(t,e)=>{let r=new Wc(t);return _f(r,e),r},g_=(t,e)=>{let r=new oo(t);return yf(r,e).catch(i=>r.emit("error",i)),r},W2=Di(h_,x_,p_,g_,(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")}),w_=process.env.__FAKE_PLATFORM__||process.platform,Sf=w_==="win32",{O_CREAT:If,O_NOFOLLOW:Wu,O_TRUNC:Af,O_WRONLY:Tf}=vf.constants,kf=Number(process.env.__FAKE_FS_O_FILENAME__)||vf.constants.UV_FS_O_FILEMAP||0,__=Sf&&!!kf,y_=512*1024,b_=kf|Af|If|Tf,Ku=!Sf&&typeof Wu=="number"?Wu|Af|If|Tf:null,Cf=Ku!==null?()=>Ku:__?t=>t<y_?b_:"w":()=>"w",Rc=(t,e,r)=>{try{return ao.lchownSync(t,e,r)}catch(i){if(i?.code!=="ENOENT")throw i}},eo=(t,e,r,i)=>{ao.lchown(t,e,r,o=>{i(o&&o?.code!=="ENOENT"?o:null)})},E_=(t,e,r,i,o)=>{if(e.isDirectory())Rf(Ii.resolve(t,e.name),r,i,c=>{if(c)return o(c);let l=Ii.resolve(t,e.name);eo(l,r,i,o)});else{let c=Ii.resolve(t,e.name);eo(c,r,i,o)}},Rf=(t,e,r,i)=>{ao.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 eo(t,e,r,i);let l=c.length,u=null,f=x=>{if(!u){if(x)return i(u=x);if(--l===0)return eo(t,e,r,i)}};for(let x of c)E_(t,x,e,r,f)})},v_=(t,e,r,i)=>{e.isDirectory()&&Pf(Ii.resolve(t,e.name),r,i),Rc(Ii.resolve(t,e.name),r,i)},Pf=(t,e,r)=>{let i;try{i=ao.readdirSync(t,{withFileTypes:!0})}catch(o){let c=o;if(c?.code==="ENOENT")return;if(c?.code==="ENOTDIR"||c?.code==="ENOTSUP")return Rc(t,e,r);throw c}for(let o of i)v_(t,o,e,r);return Rc(t,e,r)},Df=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"}},co=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"}},I_=(t,e)=>{ot.stat(t,(r,i)=>{(r||!i.isDirectory())&&(r=new Df(t,r?.code||"ENOTDIR")),e(r)})},A_=(t,e,r)=>{t=Q(t);let i=e.umask??18,o=e.mode|448,c=(o&i)!==0,l=e.uid,u=e.gid,f=typeof l=="number"&&typeof u=="number"&&(l!==e.processUid||u!==e.processGid),x=e.preserve,p=e.unlink,m=Q(e.cwd),v=(b,I)=>{b?r(b):I&&f?Rf(I,l,u,A=>v(A)):c?ot.chmod(t,o,r):r()};if(t===m)return I_(t,v);if(x)return S_.mkdir(t,{mode:o,recursive:!0}).then(b=>v(null,b??void 0),v);let _=Q(to.relative(m,t)).split("/");Pc(m,_,o,p,m,void 0,v)},Pc=(t,e,r,i,o,c,l)=>{if(e.length===0)return l(null,c);let u=e.shift(),f=Q(to.resolve(t+"/"+u));ot.mkdir(f,r,Of(f,e,r,i,o,c,l))},Of=(t,e,r,i,o,c,l)=>u=>{u?ot.lstat(t,(f,x)=>{if(f)f.path=f.path&&Q(f.path),l(f);else if(x.isDirectory())Pc(t,e,r,i,o,c,l);else if(i)ot.unlink(t,p=>{if(p)return l(p);ot.mkdir(t,r,Of(t,e,r,i,o,c,l))});else{if(x.isSymbolicLink())return l(new co(t,t+"/"+e.join("/")));l(u)}}):(c=c||t,Pc(t,e,r,i,o,c,l))},T_=t=>{let e=!1,r;try{e=ot.statSync(t).isDirectory()}catch(i){r=i?.code}finally{if(!e)throw new Df(t,r??"ENOTDIR")}},k_=(t,e)=>{t=Q(t);let r=e.umask??18,i=e.mode|448,o=(i&r)!==0,c=e.uid,l=e.gid,u=typeof c=="number"&&typeof l=="number"&&(c!==e.processUid||l!==e.processGid),f=e.preserve,x=e.unlink,p=Q(e.cwd),m=b=>{b&&u&&Pf(b,c,l),o&&ot.chmodSync(t,i)};if(t===p)return T_(p),m();if(f)return m(ot.mkdirSync(t,{mode:i,recursive:!0})??void 0);let v=Q(to.relative(p,t)).split("/"),_;for(let b=v.shift(),I=p;b&&(I+="/"+b);b=v.shift()){I=Q(to.resolve(I));try{ot.mkdirSync(I,i),_=_||I}catch{let A=ot.lstatSync(I);if(A.isDirectory())continue;if(x){ot.unlinkSync(I),ot.mkdirSync(I,i),_=_||I;continue}else if(A.isSymbolicLink())return new co(I,I+"/"+v.join("/"))}}return m(_)},fc=Object.create(null),$u=1e4,mr=new Set,C_=t=>{mr.has(t)?mr.delete(t):fc[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),mr.add(t);let e=fc[t],r=mr.size-$u;if(r>$u/10){for(let i of mr)if(mr.delete(i),delete fc[i],--r<=0)break}return e},R_=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,P_=R_==="win32",D_=t=>t.split("/").slice(0,-1).reduce((e,r)=>{let i=e.at(-1);return i!==void 0&&(r=Lf(i,r)),e.push(r||"/"),e},[]),O_=class{#e=new Map;#n=new Map;#r=new Set;reserve(t,e){t=P_?["win32 parallelization disabled"]:t.map(i=>Si(Lf(C_(i))));let r=new Set(t.map(i=>D_(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 l=this.#e.get(c);if(!l||l?.[0]!==t)continue;let u=l[1];if(!u){this.#e.delete(c);continue}if(l.shift(),typeof u=="function")o.add(u);else for(let f of u)o.add(f)}for(let c of i){let l=this.#e.get(c),u=l?.[0];if(!(!l||!(u instanceof Set)))if(u.size===1&&l.length===1){this.#e.delete(c);continue}else if(u.size===1){l.shift();let f=l[0];typeof f=="function"&&o.add(f)}else u.delete(t)}return this.#r.delete(t),o.forEach(c=>this.#i(c)),!0}},L_=()=>process.umask(),Vu=Symbol("onEntry"),Dc=Symbol("checkFs"),Ju=Symbol("checkFs2"),Oc=Symbol("isReusable"),ut=Symbol("makeFs"),Lc=Symbol("file"),Nc=Symbol("directory"),Zs=Symbol("link"),Zu=Symbol("symlink"),Yu=Symbol("hardlink"),Ei=Symbol("ensureNoSymlink"),Xu=Symbol("unsupported"),Qu=Symbol("checkPath"),hc=Symbol("stripAbsolutePath"),wn=Symbol("mkdir"),Ge=Symbol("onError"),zs=Symbol("pending"),ef=Symbol("pend"),wr=Symbol("unpend"),xc=Symbol("ended"),pc=Symbol("maybeClose"),Mc=Symbol("skip"),Ai=Symbol("doChown"),Ti=Symbol("uid"),ki=Symbol("gid"),Ci=Symbol("checkedCwd"),N_=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Ri=N_==="win32",M_=1024,B_=(t,e)=>{if(!Ri)return ie.unlink(t,e);let r=t+".DELETE."+Ef(16).toString("hex");ie.rename(t,r,i=>{if(i)return e(i);ie.unlink(r,e)})},F_=t=>{if(!Ri)return ie.unlinkSync(t);let e=t+".DELETE."+Ef(16).toString("hex");ie.renameSync(t,e),ie.unlinkSync(e)},tf=(t,e,r)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:r,Kc=class extends Pi{[xc]=!1;[Ci]=!1;[zs]=0;reservations=new O_;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[xc]=!0,this[pc]()},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:M_,this.forceChown=t.forceChown===!0,this.win32=!!t.win32||Ri,this.newer=!!t.newer,this.keep=!!t.keep,this.noMtime=!!t.noMtime,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.cwd=Q(Ne.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:L_():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[Vu](e))}warn(t,e,r={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(r.recoverable=!1),super.warn(t,e,r)}[pc](){this[xc]&&this[zs]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[hc](t,e){let r=t[e],{type:i}=t;if(!r||this.preservePaths)return!0;let[o,c]=Gc(r),l=c.replaceAll(/\\/g,"/").split("/");if(l.includes("..")||Ri&&/^[a-z]:\.\.$/i.test(l[0]??"")){if(e==="path"||i==="Link")return this.warn("TAR_ENTRY_ERROR",`${e} contains '..'`,{entry:t,[e]:r}),!1;let u=Ne.posix.dirname(t.path),f=Ne.posix.normalize(Ne.posix.join(u,l.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}[Qu](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[hc](t,"path")||!this[hc](t,"linkpath"))return!1;if(t.absolute=Ne.isAbsolute(t.path)?Q(Ne.resolve(t.path)):Q(Ne.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}=Ne.win32.parse(String(t.absolute));t.absolute=i+Nu(String(t.absolute).slice(i.length));let{root:o}=Ne.win32.parse(t.path);t.path=o+Nu(t.path.slice(o.length))}return!0}[Vu](t){if(!this[Qu](t))return t.resume();switch(m_.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[Dc](t);default:return this[Xu](t)}}[Ge](t,e){t.name==="CwdError"?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:e}),this[wr](),e.resume())}[wn](t,e,r){A_(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)}[Ai](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 tf(this.uid,t.uid,this.processUid)}[ki](t){return tf(this.gid,t.gid,this.processGid)}[Lc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=new no(String(t.absolute),{flags:Cf(t.size),mode:r,autoClose:!1});i.on("error",u=>{i.fd&&ie.close(i.fd,()=>{}),i.write=()=>!0,this[Ge](u,t),e()});let o=1,c=u=>{if(u){i.fd&&ie.close(i.fd,()=>{}),this[Ge](u,t),e();return}--o===0&&i.fd!==void 0&&ie.close(i.fd,f=>{f?this[Ge](f,t):this[wr](),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,p=t.mtime;ie.futimes(f,x,p,m=>m?ie.utimes(u,x,p,v=>c(v&&m)):c())}if(typeof f=="number"&&this[Ai](t)){o++;let x=this[Ti](t),p=this[ki](t);typeof x=="number"&&typeof p=="number"&&ie.fchown(f,x,p,m=>m?ie.chown(u,x,p,v=>c(v&&m)):c())}c()});let l=this.transform&&this.transform(t)||t;l!==t&&(l.on("error",u=>{this[Ge](u,t),e()}),t.pipe(l)),l.pipe(i)}[Nc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode;this[wn](String(t.absolute),r,i=>{if(i){this[Ge](i,t),e();return}let o=1,c=()=>{--o===0&&(e(),this[wr](),t.resume())};t.mtime&&!this.noMtime&&(o++,ie.utimes(String(t.absolute),t.atime||new Date,t.mtime,c)),this[Ai](t)&&(o++,ie.chown(String(t.absolute),Number(this[Ti](t)),Number(this[ki](t)),c)),c()})}[Xu](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[Zu](t,e){let r=Q(Ne.relative(this.cwd,Ne.resolve(Ne.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[Ei](t,this.cwd,r,()=>this[Zs](t,String(t.linkpath),"symlink",e),i=>{this[Ge](i,t),e()})}[Yu](t,e){let r=Q(Ne.resolve(this.cwd,String(t.linkpath))),i=Q(String(t.linkpath)).split("/");this[Ei](t,this.cwd,i,()=>this[Zs](t,r,"link",e),o=>{this[Ge](o,t),e()})}[Ei](t,e,r,i,o){let c=r.shift();if(this.preservePaths||c===void 0)return i();let l=Ne.resolve(e,c);ie.lstat(l,(u,f)=>{if(u)return i();if(f?.isSymbolicLink())return o(new co(l,Ne.resolve(l,r.join("/"))));this[Ei](t,l,r,i,o)})}[ef](){this[zs]++}[wr](){this[zs]--,this[pc]()}[Mc](t){this[wr](),t.resume()}[Oc](t,e){return t.type==="File"&&!this.unlink&&e.isFile()&&e.nlink<=1&&!Ri}[Dc](t){this[ef]();let e=[t.path];t.linkpath&&e.push(t.linkpath),this.reservations.reserve(e,r=>this[Ju](t,r))}[Ju](t,e){let r=l=>{e(l)},i=()=>{this[wn](this.cwd,this.dmode,l=>{if(l){this[Ge](l,t),r();return}this[Ci]=!0,o()})},o=()=>{if(t.absolute!==this.cwd){let l=Q(Ne.dirname(String(t.absolute)));if(l!==this.cwd)return this[wn](l,this.dmode,u=>{if(u){this[Ge](u,t),r();return}c()})}c()},c=()=>{ie.lstat(String(t.absolute),(l,u)=>{if(u&&(this.keep||this.newer&&u.mtime>(t.mtime??u.mtime))){this[Mc](t),r();return}if(l||this[Oc](t,u))return this[ut](null,t,r);if(u.isDirectory()){if(t.type==="Directory"){let f=this.chmod&&t.mode&&(u.mode&4095)!==t.mode,x=p=>this[ut](p??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[ut](f??null,t,r))}if(t.absolute===this.cwd)return this[ut](null,t,r);B_(String(t.absolute),f=>this[ut](f??null,t,r))})};this[Ci]?o():i()}[ut](t,e,r){if(t){this[Ge](t,e),r();return}switch(e.type){case"File":case"OldFile":case"ContiguousFile":return this[Lc](e,r);case"Link":return this[Yu](e,r);case"SymbolicLink":return this[Zu](e,r);case"Directory":case"GNUDumpDir":return this[Nc](e,r)}}[Zs](t,e,r,i){ie[r](e,String(t.absolute),o=>{o?this[Ge](o,t):(this[wr](),t.resume()),i()})}},yi=t=>{try{return[null,t()]}catch(e){return[e,null]}},Nf=class extends Kc{sync=!0;[ut](t,e){return super[ut](t,e,()=>{})}[Dc](t){if(!this[Ci]){let o=this[wn](this.cwd,this.dmode);if(o)return this[Ge](o,t);this[Ci]=!0}if(t.absolute!==this.cwd){let o=Q(Ne.dirname(String(t.absolute)));if(o!==this.cwd){let c=this[wn](o,this.dmode);if(c)return this[Ge](c,t)}}let[e,r]=yi(()=>ie.lstatSync(String(t.absolute)));if(r&&(this.keep||this.newer&&r.mtime>(t.mtime??r.mtime)))return this[Mc](t);if(e||this[Oc](t,r))return this[ut](null,t);if(r.isDirectory()){if(t.type==="Directory"){let c=this.chmod&&t.mode&&(r.mode&4095)!==t.mode,[l]=c?yi(()=>{ie.chmodSync(String(t.absolute),Number(t.mode))}):[];return this[ut](l,t)}let[o]=yi(()=>ie.rmdirSync(String(t.absolute)));this[ut](o,t)}let[i]=t.absolute===this.cwd?[]:yi(()=>F_(String(t.absolute)));this[ut](i,t)}[Lc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=l=>{let u;try{ie.closeSync(o)}catch(f){u=f}(l||u)&&this[Ge](l||u,t),e()},o;try{o=ie.openSync(String(t.absolute),Cf(t.size),r)}catch(l){return i(l)}let c=this.transform&&this.transform(t)||t;c!==t&&(c.on("error",l=>this[Ge](l,t)),t.pipe(c)),c.on("data",l=>{try{ie.writeSync(o,l,0,l.length)}catch(u){i(u)}}),c.on("end",()=>{let l=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{l=x}}}if(this[Ai](t)){let u=this[Ti](t),f=this[ki](t);try{ie.fchownSync(o,Number(u),Number(f))}catch(x){try{ie.chownSync(String(t.absolute),Number(u),Number(f))}catch{l=l||x}}}i(l)})}[Nc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode,i=this[wn](String(t.absolute),r);if(i){this[Ge](i,t),e();return}if(t.mtime&&!this.noMtime)try{ie.utimesSync(String(t.absolute),t.atime||new Date,t.mtime)}catch{}if(this[Ai](t))try{ie.chownSync(String(t.absolute),Number(this[Ti](t)),Number(this[ki](t)))}catch{}e(),t.resume()}[wn](t,e){try{return k_(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}}[Ei](t,e,r,i,o){if(this.preservePaths||r.length===0)return i();let c=e;for(let l of r){c=Ne.resolve(c,l);let[u,f]=yi(()=>ie.lstatSync(c));if(u)return i();if(f.isSymbolicLink())return o(new co(c,Ne.resolve(e,r.join("/"))))}i()}[Zs](t,e,r,i){let o=`${r}Sync`;try{ie[o](e,String(t.absolute)),i(),t.resume()}catch(c){return this[Ge](c,t)}}},z_=t=>{let e=new Nf(t),r=t.file,i=bf.statSync(r),o=t.maxReadSize||16*1024*1024;new iw(r,{readSize:o,size:i.size}).pipe(e)},U_=(t,e)=>{let r=new Kc(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,l)=>{r.on("error",l),r.on("close",c),bf.stat(o,(u,f)=>{if(u)l(u);else{let x=new Fc(o,{readSize:i,size:f.size});x.on("error",l),x.pipe(r)}})})},Mf=Di(z_,U_,t=>new Nf(t),t=>new Kc(t),(t,e)=>{e?.length&&xf(t,e)}),H_=(t,e)=>{let r=new Wc(t),i=!0,o,c;try{try{o=st.openSync(t.file,"r+")}catch(f){if(f?.code==="ENOENT")o=st.openSync(t.file,"w+");else throw f}let l=st.fstatSync(o),u=Buffer.alloc(512);e:for(c=0;c<l.size;c+=512){for(let p=0,m=0;p<512;p+=m){if(m=st.readSync(o,u,p,u.length-p,c+p),c===0&&u[0]===31&&u[1]===139)throw new Error("cannot append to compressed archives");if(!m)break e}let f=new qn(u);if(!f.cksumValid)break;let x=512*Math.ceil((f.size||0)/512);if(c+x+512>l.size)break;c+=x,t.mtimeCache&&f.mtime&&t.mtimeCache.set(String(f.path),f.mtime)}i=!1,G_(t,r,c,o,e)}finally{if(i)try{st.closeSync(o)}catch{}}},G_=(t,e,r,i,o)=>{let c=new sf(t.file,{fd:i,start:r});e.pipe(c),j_(e,o)},q_=(t,e)=>{e=Array.from(e);let r=new oo(t),i=(o,c,l)=>{let u=(v,_)=>{v?st.close(o,b=>l(v)):l(null,_)},f=0;if(c===0)return u(null,0);let x=0,p=Buffer.alloc(512),m=(v,_)=>{if(v||_===void 0)return u(v);if(x+=_,x<512&&_)return st.read(o,p,x,p.length-x,f+x,m);if(f===0&&p[0]===31&&p[1]===139)return u(new Error("cannot append to compressed archives"));if(x<512)return u(null,f);let b=new qn(p);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,st.read(o,p,0,512,f,m)};st.read(o,p,0,512,f,m)};return new Promise((o,c)=>{r.on("error",c);let l="r+",u=(f,x)=>{if(f&&f.code==="ENOENT"&&l==="r+")return l="w+",st.open(t.file,l,u);if(f||!x)return c(f);st.fstat(x,(p,m)=>{if(p)return st.close(x,()=>c(p));i(x,m.size,(v,_)=>{if(v)return c(v);let b=new no(t.file,{fd:x,start:_});r.pipe(b),b.on("error",c),b.on("close",o),W_(r,e)})})};st.open(t.file,l,u)})},j_=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?Ar({file:Bf.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},W_=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await Ar({file:Bf.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r);t.end()},bi=Di(H_,q_,()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},(t,e)=>{if(!fw(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")}),oA=Di(bi.syncFile,bi.asyncFile,bi.syncNoFile,bi.asyncNoFile,(t,e=[])=>{bi.validate?.(t,e),K_(t)}),K_=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))};Ht();var ft={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 lo(t){return t?.cozeDeployType==="cloud"?"cloud":"local"}function Ff(t){let e=t?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function uo(t){let e=t?.cozeGroupId?.trim();if(!(!e||e==="0"))return e}function zf(t){let e=t?.permissionMode;if(typeof e!="string")return;let r=e.trim();return r===""?void 0:r}function Uf(t){let{_meta:e,...r}=t;return{stripped:r,meta:e}}function Wn(t){if(!t?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return t.cozeAgentId}Vt();We();te();Ce();We();function Tr(t,e){if(lo(t)!=="cloud")throw new T("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function Oi(t){return t.startsWith("http://")||t.startsWith("https://")}function kr(t){return t.endsWith("/")?t.slice(0,-1):t}import{readFileSync as YA}from"node:fs";import{dirname as QA,join as eT}from"node:path";import{fileURLToPath as nT}from"node:url";var Ot="0.2.3-alpha.1";import{mkdir as ay,rm as r0}from"node:fs/promises";import{join as zi}from"node:path";Ut();import{readFileSync as ey}from"node:fs";var ty=384;async function $c(t,e=process.env){let r={};for(let[i,o]of Object.entries(e))typeof o=="string"&&(r[i]=o);await lr(t.agentEnvFile,r,{mode:ty})}function Li(t){try{let e=JSON.parse(ey(t,"utf8"));return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function jf(t,e,r={},i=o=>o){return{...i({...t,...Li(e)}),...r}}Ut();function Ni(t){let e=[],r=Object.keys(t).sort();for(let i of r){let o=t[i];o!==void 0&&(ny(o)||e.push(`${i}=${o}`))}return e.length===0?"":`${e.join(`
|
|
89
|
+
`},configPath(t){return r2(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 Rp("schtasks",["/Create","/SC","ONLOGON","/TN",wa,"/TR",r,"/RU",t.userName,"/F"]),sd.info("task scheduler entry created",{task:wa,logFile:t.logFile})},async uninstall(t){await Rp("schtasks",["/Delete","/TN",wa,"/F"]).catch(e=>sd.warn("schtasks /Delete failed (ignored)",{err:String(e)})),sd.info("task scheduler entry removed",{task:wa})}}});var Dp={};Pa(Dp,{buildContext:()=>l2,getSupervisor:()=>o2,launchdSupervisor:()=>rd,systemdSupervisor:()=>id,taskSchedulerSupervisor:()=>od});import{homedir as i2,userInfo as s2}from"node:os";function o2(t=process.platform){switch(t){case"darwin":return rd;case"linux":return id;case"win32":return od;default:throw new Error(`unsupported platform for OS supervisor: ${t}`)}}function c2(){let t={};for(let e of a2){let r=process.env[e];r&&(t[e]=r)}return t}function l2(){let t=J();return{nodeBin:process.execPath,entry:Vl(t),logFile:t.logFile,homeDir:i2(),userName:s2().username,isRoot:process.getuid?.()===0,env:c2()}}var a2,Pp=rt(()=>{"use strict";De();aa();Ap();Tp();Cp();a2=["PATH","HOME","HTTP_PROXY","HTTPS_PROXY","NO_PROXY","ALL_PROXY","http_proxy","https_proxy","no_proxy","all_proxy","NODE_EXTRA_CA_CERTS"]});re();cn();var Md=j("acp-installer-warmup"),sm=["claude-code","codex"];async function Bd(t={}){let e=t.ensure??cr,i=(await Promise.allSettled(sm.map(async o=>{let c=await e(o);Md.info("acp wrapper warmup ok",{framework:o,path:c})}))).filter(o=>o.status==="rejected");i.length>0&&Md.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();re();import{readdir as Em}from"node:fs/promises";import{mkdir as Gd,readFile as _m,writeFile as Hd}from"node:fs/promises";import{join as za}from"node:path";var ym={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md",hermes:"AGENTS.md"};async function ur(t,e,r){await Gd(t,{recursive:!0});let i=ym[e],o=za(t,i);return await Hd(o,r??"","utf8"),o}async function Ua(t,e,r){let i=za(t,".claude");await Gd(i,{recursive:!0});let o=za(i,"settings.local.json"),c={};try{let u=await _m(o,"utf8"),x=JSON.parse(u);typeof x=="object"&&x!==null&&!Array.isArray(x)&&(c=x)}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 Hd(o,JSON.stringify(c,null,2),"utf8"),o}var Qe=j("agent-detail-sync"),bm=6e4,vm=5*6e4,vs=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let r=this.opts.paths.agentsRoot,i;try{i=await Em(r)}catch(o){Qe.info("agents dir not found, skip detail sync",{root:r,err:String(o)});return}Qe.info("starting detail sync",{reason:e,count:i.length}),await Promise.allSettled(i.map(async o=>{let c=await Ie(o,this.opts.paths).catch(()=>null);if(c){if(c.disconnectedAt){Qe.debug("detail sync: skip disconnected agent",{agentId:o});return}try{await this.syncOne(o,c)}catch(d){Qe.warn("detail sync failed for agent, skipping",{agentId:o,err:String(d)})}}})),Qe.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){Qe.info("retrying pending detail syncs",{count:r.length});for(let i of r)try{await this.syncOne(i)}catch(o){Qe.debug("detail sync retry still failing, will try again",{agentId:i,err:String(o)})}}}async syncOne(e,r){let i=r??await Ie(e,this.opts.paths);if(!i){Qe.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(x){Qe.warn("detail RPC failed, using local data",{agentId:e,err:String(x)});let h=this.retryQueue.get(e),m=h?Math.min(h.currentDelay*2,vm):bm;this.retryQueue.set(e,{dueAt:Date.now()+m,currentDelay:m});return}if(o.agentId&&o.agentId!==e){Qe.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"?(Qe.warn("detail sync: agent demoted to local, repairing to cloud",{agentId:e}),i.deployType="cloud",c=!0,u=!0):o.deployType&&Qe.info("detail.deployType",{agentId:e,deployType:o.deployType}),!c){Qe.debug("detail sync: no diff",{agentId:e});return}await Ue(i,this.opts.paths),Qe.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}),Qe.info("detail sync: repaired demoted agent back to cloud",{agentId:e})):d&&(await ur(i.workspace,i.framework,i.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};var dl=Gt(Eu(),1);import{createHash as ly}from"node:crypto";import{lstat as rl,mkdir as il,readFile as mo,readdir as u0,rm as sl,stat as c0,writeFile as ol}from"node:fs/promises";import{dirname as dy,join as Ze,normalize as uy,relative as ll,resolve as al,sep as f0}from"node:path";import{Readable as x0}from"node:stream";import{pipeline as h0}from"node:stream/promises";import Wm from"events";import it from"fs";import{EventEmitter as zc}from"node:events";import nf from"node:stream";import{StringDecoder as Km}from"node:string_decoder";import of from"node:path";import vr from"node:fs";import{dirname as sw,parse as ow}from"path";import{EventEmitter as hw}from"events";import yc from"assert";import{Buffer as Hn}from"buffer";import*as Au from"zlib";import pw from"zlib";import{posix as gr}from"node:path";import{basename as Hw}from"node:path";import to from"fs";import Pt from"fs";import Ou from"path";import{win32 as e_}from"node:path";import Uu from"path";import Ef from"node:fs";import m_ from"node:assert";import{randomBytes as bf}from"node:crypto";import se from"node:fs";import Be from"node:path";import vf from"fs";import uo from"node:fs";import ki from"node:path";import ct from"node:fs";import S_ from"node:fs/promises";import io from"node:path";import{join as Lf}from"node:path";import at from"node:fs";import Bf from"node:path";var qm=Object.defineProperty,jm=(t,e)=>{for(var r in e)qm(t,r,{get:e[r],enumerable:!0})},bu=typeof process=="object"&&process?process:{stdout:null,stderr:null},$m=t=>!!t&&typeof t=="object"&&(t instanceof Wn||t instanceof nf||Vm(t)||Zm(t)),Vm=t=>!!t&&typeof t=="object"&&t instanceof zc&&typeof t.pipe=="function"&&t.pipe!==nf.Writable.prototype.pipe,Zm=t=>!!t&&typeof t=="object"&&t instanceof zc&&typeof t.write=="function"&&typeof t.end=="function",jt=Symbol("EOF"),Wt=Symbol("maybeEmitEnd"),dn=Symbol("emittedEnd"),Ts=Symbol("emittingEnd"),di=Symbol("emittedError"),Rs=Symbol("closed"),vu=Symbol("read"),Cs=Symbol("flush"),Su=Symbol("flushChunk"),Et=Symbol("encoding"),pr=Symbol("decoder"),Ge=Symbol("flowing"),ui=Symbol("paused"),yr=Symbol("resume"),He=Symbol("buffer"),et=Symbol("pipes"),qe=Symbol("bufferLength"),Ka=Symbol("bufferPush"),Ds=Symbol("bufferShift"),Xe=Symbol("objectMode"),Te=Symbol("destroyed"),$a=Symbol("error"),Va=Symbol("emitData"),Iu=Symbol("emitEnd"),Za=Symbol("emitEnd2"),Rt=Symbol("async"),Ja=Symbol("abort"),Ps=Symbol("aborted"),fi=Symbol("signal"),On=Symbol("dataListeners"),ot=Symbol("discarded"),xi=t=>Promise.resolve().then(t),Jm=t=>t(),Ym=t=>t==="end"||t==="finish"||t==="prefinish",Xm=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,Qm=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),rf=class{src;dest;opts;ondrain;constructor(t,e,r){this.src=t,this.dest=e,this.opts=r,this.ondrain=()=>t[yr](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},ew=class extends rf{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)}},tw=t=>!!t.objectMode,nw=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",Wn=class extends zc{[Ge]=!1;[ui]=!1;[et]=[];[He]=[];[Xe];[Et];[Rt];[pr];[jt]=!1;[dn]=!1;[Ts]=!1;[Rs]=!1;[di]=null;[qe]=0;[Te]=!1;[fi];[Ps]=!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");tw(e)?(this[Xe]=!0,this[Et]=null):nw(e)?(this[Et]=e.encoding,this[Xe]=!1):(this[Xe]=!1,this[Et]=null),this[Rt]=!!e.async,this[pr]=this[Et]?new Km(this[Et]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[He]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[et]});let{signal:r}=e;r&&(this[fi]=r,r.aborted?this[Ja]():r.addEventListener("abort",()=>this[Ja]()))}get bufferLength(){return this[qe]}get encoding(){return this[Et]}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[Xe]}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}[Ja](){this[Ps]=!0,this.emit("abort",this[fi]?.reason),this.destroy(this[fi]?.reason)}get aborted(){return this[Ps]}set aborted(t){}write(t,e,r){if(this[Ps])return!1;if(this[jt])throw new Error("write after end");if(this[Te])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]?xi:Jm;if(!this[Xe]&&!Buffer.isBuffer(t)){if(Qm(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(Xm(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[Xe]?(this[Ge]&&this[qe]!==0&&this[Cs](!0),this[Ge]?this.emit("data",t):this[Ka](t),this[qe]!==0&&this.emit("readable"),r&&i(r),this[Ge]):t.length?(typeof t=="string"&&!(e===this[Et]&&!this[pr]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[Et]&&(t=this[pr].write(t)),this[Ge]&&this[qe]!==0&&this[Cs](!0),this[Ge]?this.emit("data",t):this[Ka](t),this[qe]!==0&&this.emit("readable"),r&&i(r),this[Ge]):(this[qe]!==0&&this.emit("readable"),r&&i(r),this[Ge])}read(t){if(this[Te])return null;if(this[ot]=!1,this[qe]===0||t===0||t&&t>this[qe])return this[Wt](),null;this[Xe]&&(t=null),this[He].length>1&&!this[Xe]&&(this[He]=[this[Et]?this[He].join(""):Buffer.concat(this[He],this[qe])]);let e=this[vu](t||null,this[He][0]);return this[Wt](),e}[vu](t,e){if(this[Xe])this[Ds]();else{let r=e;t===r.length||t===null?this[Ds]():typeof r=="string"?(this[He][0]=r.slice(t),e=r.slice(0,t),this[qe]-=t):(this[He][0]=r.subarray(t),e=r.subarray(0,t),this[qe]-=t)}return this.emit("data",e),!this[He].length&&!this[jt]&&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[jt]=!0,this.writable=!1,(this[Ge]||!this[ui])&&this[Wt](),this}[yr](){this[Te]||(!this[On]&&!this[et].length&&(this[ot]=!0),this[ui]=!1,this[Ge]=!0,this.emit("resume"),this[He].length?this[Cs]():this[jt]?this[Wt]():this.emit("drain"))}resume(){return this[yr]()}pause(){this[Ge]=!1,this[ui]=!0,this[ot]=!1}get destroyed(){return this[Te]}get flowing(){return this[Ge]}get paused(){return this[ui]}[Ka](t){this[Xe]?this[qe]+=1:this[qe]+=t.length,this[He].push(t)}[Ds](){return this[Xe]?this[qe]-=1:this[qe]-=this[He][0].length,this[He].shift()}[Cs](t=!1){do;while(this[Su](this[Ds]())&&this[He].length);!t&&!this[He].length&&!this[jt]&&this.emit("drain")}[Su](t){return this.emit("data",t),this[Ge]}pipe(t,e){if(this[Te])return t;this[ot]=!1;let r=this[dn];return e=e||{},t===bu.stdout||t===bu.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,r?e.end&&t.end():(this[et].push(e.proxyErrors?new ew(this,t,e):new rf(this,t,e)),this[Rt]?xi(()=>this[yr]()):this[yr]()),t}unpipe(t){let e=this[et].find(r=>r.dest===t);e&&(this[et].length===1?(this[Ge]&&this[On]===0&&(this[Ge]=!1),this[et]=[]):this[et].splice(this[et].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[et].length&&!this[Ge]&&this[yr]();else if(t==="readable"&&this[qe]!==0)super.emit("readable");else if(Ym(t)&&this[dn])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[di]){let i=e;this[Rt]?xi(()=>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[et].length&&(this[Ge]=!1)),r}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[On]=0,!this[ot]&&!this[et].length&&(this[Ge]=!1)),e}get emittedEnd(){return this[dn]}[Wt](){!this[Ts]&&!this[dn]&&!this[Te]&&this[He].length===0&&this[jt]&&(this[Ts]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Rs]&&this.emit("close"),this[Ts]=!1)}emit(t,...e){let r=e[0];if(t!=="error"&&t!=="close"&&t!==Te&&this[Te])return!1;if(t==="data")return!this[Xe]&&!r?!1:this[Rt]?(xi(()=>this[Va](r)),!0):this[Va](r);if(t==="end")return this[Iu]();if(t==="close"){if(this[Rs]=!0,!this[dn]&&!this[Te])return!1;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[di]=r,super.emit($a,r);let o=!this[fi]||this.listeners("error").length?super.emit("error",r):!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}[Va](t){for(let r of this[et])r.dest.write(t)===!1&&this.pause();let e=this[ot]?!1:super.emit("data",t);return this[Wt](),e}[Iu](){return this[dn]?!1:(this[dn]=!0,this.readable=!1,this[Rt]?(xi(()=>this[Za]()),!0):this[Za]())}[Za](){if(this[pr]){let e=this[pr].end();if(e){for(let r of this[et])r.dest.write(e);this[ot]||super.emit("data",e)}}for(let e of this[et])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[Xe]||(t.dataLength=0);let e=this.promise();return this.on("data",r=>{t.push(r),this[Xe]||(t.dataLength+=r.length)}),await e,t}async concat(){if(this[Xe])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[Et]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(Te,()=>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[jt])return e();let i,o,c=h=>{this.off("data",d),this.off("end",u),this.off(Te,x),e(),o(h)},d=h=>{this.off("error",c),this.off("end",u),this.off(Te,x),this.pause(),i({value:h,done:!!this[jt]})},u=()=>{this.off("error",c),this.off("data",d),this.off(Te,x),e(),i({done:!0,value:void 0})},x=()=>c(new Error("stream destroyed"));return new Promise((h,m)=>{o=m,i=h,this.once(Te,x),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($a,e),this.off(Te,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($a,e),this.once(Te,e),{next:r,throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[Te])return t?this.emit("error",t):this.emit(Te),this;this[Te]=!0,this[ot]=!0,this[He].length=0,this[qe]=0;let e=this;return typeof e.close=="function"&&!this[Rs]&&e.close(),t?this.emit("error",t):this.emit(Te),this}static get isStream(){return $m}},rw=it.writev,yn=Symbol("_autoClose"),It=Symbol("_close"),hi=Symbol("_ended"),ue=Symbol("_fd"),Ya=Symbol("_finished"),Zt=Symbol("_flags"),Xa=Symbol("_flush"),wc=Symbol("_handleChunk"),_c=Symbol("_makeBuf"),Ii=Symbol("_mode"),Os=Symbol("_needDrain"),Ir=Symbol("_onerror"),Ar=Symbol("_onopen"),Qa=Symbol("_onread"),Er=Symbol("_onwrite"),En=Symbol("_open"),St=Symbol("_path"),pn=Symbol("_pos"),Ct=Symbol("_queue"),br=Symbol("_read"),ec=Symbol("_readSize"),Vt=Symbol("_reading"),pi=Symbol("_remain"),tc=Symbol("_size"),qs=Symbol("_write"),Ln=Symbol("_writing"),js=Symbol("_defaultFlag"),Gn=Symbol("_errored"),Uc=class extends Wn{[Gn]=!1;[ue];[St];[ec];[Vt]=!1;[tc];[pi];[yn];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[ue]=typeof e.fd=="number"?e.fd:void 0,this[St]=t,this[ec]=e.readSize||16*1024*1024,this[Vt]=!1,this[tc]=typeof e.size=="number"?e.size:1/0,this[pi]=this[tc],this[yn]=typeof e.autoClose=="boolean"?e.autoClose:!0,typeof this[ue]=="number"?this[br]():this[En]()}get fd(){return this[ue]}get path(){return this[St]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[En](){it.open(this[St],"r",(t,e)=>this[Ar](t,e))}[Ar](t,e){t?this[Ir](t):(this[ue]=e,this.emit("open",e),this[br]())}[_c](){return Buffer.allocUnsafe(Math.min(this[ec],this[pi]))}[br](){if(!this[Vt]){this[Vt]=!0;let t=this[_c]();if(t.length===0)return process.nextTick(()=>this[Qa](null,0,t));it.read(this[ue],t,0,t.length,null,(e,r,i)=>this[Qa](e,r,i))}}[Qa](t,e,r){this[Vt]=!1,t?this[Ir](t):this[wc](e,r)&&this[br]()}[It](){if(this[yn]&&typeof this[ue]=="number"){let t=this[ue];this[ue]=void 0,it.close(t,e=>e?this.emit("error",e):this.emit("close"))}}[Ir](t){this[Vt]=!0,this[It](),this.emit("error",t)}[wc](t,e){let r=!1;return this[pi]-=t,t>0&&(r=super.write(t<e.length?e.subarray(0,t):e)),(t===0||this[pi]<=0)&&(r=!1,this[It](),super.end()),r}emit(t,...e){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[ue]=="number"&&this[br](),!1;case"error":return this[Gn]?!1:(this[Gn]=!0,super.emit(t,...e));default:return super.emit(t,...e)}}},iw=class extends Uc{[En](){let t=!0;try{this[Ar](null,it.openSync(this[St],"r")),t=!1}finally{t&&this[It]()}}[br](){let t=!0;try{if(!this[Vt]){this[Vt]=!0;do{let e=this[_c](),r=e.length===0?0:it.readSync(this[ue],e,0,e.length,null);if(!this[wc](r,e))break}while(!0);this[Vt]=!1}t=!1}finally{t&&this[It]()}}[It](){if(this[yn]&&typeof this[ue]=="number"){let t=this[ue];this[ue]=void 0,it.closeSync(t),this.emit("close")}}},so=class extends Wm{readable=!1;writable=!0;[Gn]=!1;[Ln]=!1;[hi]=!1;[Ct]=[];[Os]=!1;[St];[Ii];[yn];[ue];[js];[Zt];[Ya]=!1;[pn];constructor(t,e){e=e||{},super(e),this[St]=t,this[ue]=typeof e.fd=="number"?e.fd:void 0,this[Ii]=e.mode===void 0?438:e.mode,this[pn]=typeof e.start=="number"?e.start:void 0,this[yn]=typeof e.autoClose=="boolean"?e.autoClose:!0;let r=this[pn]!==void 0?"r+":"w";this[js]=e.flags===void 0,this[Zt]=e.flags===void 0?r:e.flags,this[ue]===void 0&&this[En]()}emit(t,...e){if(t==="error"){if(this[Gn])return!1;this[Gn]=!0}return super.emit(t,...e)}get fd(){return this[ue]}get path(){return this[St]}[Ir](t){this[It](),this[Ln]=!0,this.emit("error",t)}[En](){it.open(this[St],this[Zt],this[Ii],(t,e)=>this[Ar](t,e))}[Ar](t,e){this[js]&&this[Zt]==="r+"&&t&&t.code==="ENOENT"?(this[Zt]="w",this[En]()):t?this[Ir](t):(this[ue]=e,this.emit("open",e),this[Ln]||this[Xa]())}end(t,e){return t&&this.write(t,e),this[hi]=!0,!this[Ln]&&!this[Ct].length&&typeof this[ue]=="number"&&this[Er](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[ue]===void 0||this[Ln]||this[Ct].length?(this[Ct].push(t),this[Os]=!0,!1):(this[Ln]=!0,this[qs](t),!0)}[qs](t){it.write(this[ue],t,0,t.length,this[pn],(e,r)=>this[Er](e,r))}[Er](t,e){t?this[Ir](t):(this[pn]!==void 0&&typeof e=="number"&&(this[pn]+=e),this[Ct].length?this[Xa]():(this[Ln]=!1,this[hi]&&!this[Ya]?(this[Ya]=!0,this[It](),this.emit("finish")):this[Os]&&(this[Os]=!1,this.emit("drain"))))}[Xa](){if(this[Ct].length===0)this[hi]&&this[Er](null,0);else if(this[Ct].length===1)this[qs](this[Ct].pop());else{let t=this[Ct];this[Ct]=[],rw(this[ue],t,this[pn],(e,r)=>this[Er](e,r))}}[It](){if(this[yn]&&typeof this[ue]=="number"){let t=this[ue];this[ue]=void 0,it.close(t,e=>e?this.emit("error",e):this.emit("close"))}}},sf=class extends so{[En](){let t;if(this[js]&&this[Zt]==="r+")try{t=it.openSync(this[St],this[Zt],this[Ii])}catch(e){if(e?.code==="ENOENT")return this[Zt]="w",this[En]();throw e}else t=it.openSync(this[St],this[Zt],this[Ii]);this[Ar](null,t)}[It](){if(this[yn]&&typeof this[ue]=="number"){let t=this[ue];this[ue]=void 0,it.closeSync(t),this.emit("close")}}[qs](t){let e=!0;try{this[Er](null,it.writeSync(this[ue],t,0,t.length,this[pn])),e=!1}finally{if(e)try{this[It]()}catch{}}}},aw=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"]]),cw=t=>!!t.sync&&!!t.file,lw=t=>!t.sync&&!!t.file,dw=t=>!!t.sync&&!t.file,uw=t=>!t.sync&&!t.file,fw=t=>!!t.file,xw=t=>aw.get(t)||t,Gc=(t={})=>{if(!t)return{};let e={};for(let[r,i]of Object.entries(t)){let o=xw(r);e[o]=i}return e.chmod===void 0&&e.noChmod===!1&&(e.chmod=!0),delete e.noChmod,e},Li=(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 x=Gc(c);if(o?.(x,d),cw(x)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return t(x,d)}else if(lw(x)){let h=e(x,d);return u?h.then(()=>u(),u):h}else if(dw(x)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return r(x,d)}else if(uw(x)){if(typeof u=="function")throw new TypeError("callback only supported with file option");return i(x,d)}throw new Error("impossible options??")},{syncFile:t,asyncFile:e,syncNoFile:r,asyncNoFile:i,validate:o}),gw=pw.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},gw)),mw=Hn.concat,ku=Object.getOwnPropertyDescriptor(Hn,"concat"),ww=t=>t,nc=ku?.writable===!0||ku?.set!==void 0?t=>{Hn.concat=t?ww:mw}: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"}},rc=Symbol("flushFlag"),Hc=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 Au[e]!="function")throw new TypeError("Compression method not supported: "+e);try{this.#t=new Au[e](t)}catch(r){throw new Ls(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 Ls(r))),this.once("end",()=>this.close)}close(){this.#t&&(this.#t.close(),this.#t=void 0,this.emit("close"))}reset(){if(!this.#e)return yc(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),{[rc]: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;yc(this.#t,"zlib binding closed");let i=this.#t._handle,o=i.close;i.close=()=>{};let c=this.#t.close;this.#t.close=()=>{},nc(!0);let d;try{let x=typeof t[rc]=="number"?t[rc]:this.#r;d=this.#t._processChunk(t,x),nc(!1)}catch(x){nc(!1),this.#o(new Ls(x,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",x=>this.#o(new Ls(x,this.write)));let u;if(d)if(Array.isArray(d)&&d.length>0){let x=d[0];u=this[qn](Hn.from(x));for(let h=1;h<d.length;h++)u=this[qn](d[h])}else u=this[qn](Hn.from(d));return r&&r(),u}},af=class extends Hc{#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),yc(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)}}}},_w=class extends af{#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)}},yw=class extends af{constructor(t){super(t,"Unzip")}},cf=class extends Hc{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)}},Ew=class extends cf{constructor(t){super(t,"BrotliCompress")}},bw=class extends cf{constructor(t){super(t,"BrotliDecompress")}},lf=class extends Hc{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)}},vw=class extends lf{constructor(t){super(t,"ZstdCompress")}},Sw=class extends lf{constructor(t){super(t,"ZstdDecompress")}},Iw=(t,e)=>{if(Number.isSafeInteger(t))t<0?kw(t,e):Aw(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},Aw=(t,e)=>{e[0]=128;for(var r=e.length;r>1;r--)e[r-1]=t&255,t=Math.floor(t/256)},kw=(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]=df(o):o===0?e[i-1]=0:(r=!0,e[i-1]=uf(o))}},Tw=t=>{let e=t[0],r=e===128?Cw(t.subarray(1,t.length)):e===255?Rw(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},Rw=t=>{for(var e=t.length,r=0,i=!1,o=e-1;o>-1;o--){var c=Number(t[o]),d;i?d=df(c):c===0?d=c:(i=!0,d=uf(c)),d!==0&&(r-=d*Math.pow(256,e-o-1))}return r},Cw=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},df=t=>(255^t)&255,uf=t=>(255^t)+1&255,Dw={};jm(Dw,{code:()=>qc,isCode:()=>Ws,isName:()=>Pw,name:()=>oo,normalFsTypes:()=>ff});var Ws=t=>oo.has(t),Pw=t=>qc.has(t),ff=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"]]),qc=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,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=ff.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??ic(t,e+136,12),this.cksum=gn(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??gn(t,e+329,8)??0,this.devmin=d?.devmin??u?.devmin??gn(t,e+337,8)??0,t[e+475]!==0){let h=Nn(t,e+345,155);this.path=h+"/"+this.path}else{let h=Nn(t,e+345,130);h&&(this.path=h+"/"+this.path),this.atime=r?.atime??i?.atime??ic(t,e+476,12),this.ctime=r?.ctime??i?.ctime??ic(t,e+488,12)}let x=256;for(let h=e;h<e+148;h++)x+=t[h];for(let h=e+156;h<e+512;h++)x+=t[h];this.cksumValid=x===this.cksum,this.cksum===void 0&&x===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=Ow(this.path||"",r),o=i[0],c=i[1];this.needPax=!!i[2],this.needPax=Mn(t,e,100,o)||this.needPax,this.needPax=mn(t,e+100,8,this.mode)||this.needPax,this.needPax=mn(t,e+108,8,this.uid)||this.needPax,this.needPax=mn(t,e+116,8,this.gid)||this.needPax,this.needPax=mn(t,e+124,12,this.size)||this.needPax,this.needPax=sc(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=mn(t,e+329,8,this.devmaj)||this.needPax,this.needPax=mn(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=sc(t,e+476,12,this.atime)||this.needPax,this.needPax=sc(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,mn(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(qc.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)}},Ow=(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.*/,""),ic=(t,e,r)=>Lw(gn(t,e,r)),Lw=t=>t===void 0?void 0:new Date(t*1e3),gn=(t,e,r)=>Number(t[e])&128?Tw(t.subarray(e,e+r)):Mw(t,e,r),Nw=t=>isNaN(t)?void 0:t,Mw=(t,e,r)=>Nw(parseInt(t.subarray(e,e+r).toString("utf8").replace(/\0.*$/,"").trim(),8)),Bw={12:8589934591,8:2097151},mn=(t,e,r,i)=>i===void 0?!1:i>Bw[r]||i<0?(Iw(i,t.subarray(e,e+r)),!0):(Fw(t,e,r,i),!1),Fw=(t,e,r,i)=>t.write(zw(i,r),e,r,"ascii"),zw=(t,e)=>Uw(Math.floor(t).toString(8),e),Uw=(t,e)=>(t.length===e-1?t:new Array(e-t.length-1).join("0")+t+" ")+"\0",sc=(t,e,r,i)=>i===void 0?!1:mn(t,e,r,i.getTime()/1e3),Gw=new Array(156).join("\0"),Mn=(t,e,r,i)=>i===void 0?!1:(t.write(i+Gw,e,r,"utf8"),i.length!==Buffer.byteLength(i)||i.length>r),eo=class xf{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/"+Hw(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,r,i=!1){return new xf(qw(jw(e),r),i)}},qw=(t,e)=>e?Object.assign({},e,t):t,jw=t=>t.replace(/\n$/,"").split(`
|
|
91
|
+
`).reduce(Ww,Object.create(null)),Ww=(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},Kw=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Q=Kw!=="win32"?t=>t:t=>t&&t.replaceAll(/\\/g,"/"),$w=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))))}},ao=(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))},Vw=1024*1024,Ec=Buffer.from([31,139]),bc=Buffer.from([40,181,47,253]),Zw=Math.max(Ec.length,bc.length),ft=Symbol("state"),Bn=Symbol("writeEntry"),Kt=Symbol("readEntry"),oc=Symbol("nextEntry"),Tu=Symbol("processEntry"),Dt=Symbol("extendedHeader"),gi=Symbol("globalExtendedHeader"),un=Symbol("meta"),Ru=Symbol("emitMeta"),_e=Symbol("buffer"),$t=Symbol("queue"),fn=Symbol("ended"),ac=Symbol("emittedEnd"),Fn=Symbol("emit"),Pe=Symbol("unzip"),Ns=Symbol("consumeChunk"),Ms=Symbol("consumeChunkSub"),cc=Symbol("consumeBody"),Cu=Symbol("consumeMeta"),Du=Symbol("consumeHeader"),mi=Symbol("consuming"),lc=Symbol("bufferConcat"),Bs=Symbol("maybeEnd"),mr=Symbol("writing"),xn=Symbol("aborted"),Fs=Symbol("onDone"),zn=Symbol("sawValidEntry"),zs=Symbol("sawNullBlock"),Us=Symbol("sawEOF"),Pu=Symbol("closeStream"),Jw=()=>!0,Oi=class extends hw{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[$t]=[];[_e];[Kt];[Bn];[ft]="begin";[un]="";[Dt];[gi];[fn]=!1;[Pe];[xn]=!1;[zn];[zs]=!1;[Us]=!1;[mr]=!1;[mi]=!1;[ac]=!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||Vw,this.filter=typeof t.filter=="function"?t.filter:Jw;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[Pu]()),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,e,r={}){ao(this,t,e,r)}[Du](t,e){this[zn]===void 0&&(this[zn]=!1);let r;try{r=new jn(t,e,this[Dt],this[gi])}catch(i){return this.warn("TAR_ENTRY_INVALID",i)}if(r.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,!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 $w(r,this[Dt],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[un]="",o.on("data",c=>this[un]+=c),this[ft]="meta"):(this[Dt]=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[oc]())))}}}[Pu](){queueMicrotask(()=>this.emit("close"))}[Tu](t){let e=!0;if(!t)this[Kt]=void 0,e=!1;else if(Array.isArray(t)){let[r,...i]=t;this.emit(r,...i)}else this[Kt]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",()=>this[oc]()),e=!1);return e}[oc](){do;while(this[Tu](this[$t].shift()));if(this[$t].length===0){let t=this[Kt];!t||t.flowing||t.size===t.remain?this[mr]||this.emit("drain"):t.once("drain",()=>this.emit("drain"))}}[cc](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}[Cu](t,e){let r=this[Bn],i=this[cc](t,e);return!this[Bn]&&r&&this[Ru](r),i}[Fn](t,e,r){this[$t].length===0&&!this[Kt]?this.emit(t,e,r):this[$t].push([t,e,r])}[Ru](t){switch(this[Fn]("meta",this[un]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[Dt]=eo.parse(this[un],this[Dt],!1);break;case"GlobalExtendedHeader":this[gi]=eo.parse(this[un],this[gi],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let e=this[Dt]??Object.create(null);this[Dt]=e,e.path=this[un].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let e=this[Dt]||Object.create(null);this[Dt]=e,e.linkpath=this[un].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[Pe]===void 0||this.brotli===void 0&&this[Pe]===!1)&&t){if(this[_e]&&(t=Buffer.concat([this[_e],t]),this[_e]=void 0),t.length<Zw)return this[_e]=t,r?.(),!0;for(let d=0;this[Pe]===void 0&&d<Ec.length;d++)t[d]!==Ec[d]&&(this[Pe]=!1);let o=!1;if(this[Pe]===!1&&this.zstd!==!1){o=!0;for(let d=0;d<bc.length;d++)if(t[d]!==bc[d]){o=!1;break}}let c=this.brotli===void 0&&!o;if(this[Pe]===!1&&c)if(t.length<512)if(this[fn])this.brotli=!0;else return this[_e]=t,r?.(),!0;else try{new jn(t.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[Pe]===void 0||this[Pe]===!1&&(this.brotli||o)){let d=this[fn];this[fn]=!1,this[Pe]=this[Pe]===void 0?new yw({}):o?new Sw({}):new bw({}),this[Pe].on("data",x=>this[Ns](x)),this[Pe].on("error",x=>this.abort(x)),this[Pe].on("end",()=>{this[fn]=!0,this[Ns]()}),this[mr]=!0;let u=!!this[Pe][d?"end":"write"](t);return this[mr]=!1,r?.(),u}}this[mr]=!0,this[Pe]?this[Pe].write(t):this[Ns](t),this[mr]=!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")),r?.(),i}[lc](t){t&&!this[xn]&&(this[_e]=this[_e]?Buffer.concat([this[_e],t]):t)}[Bs](){if(this[fn]&&!this[ac]&&!this[xn]&&!this[mi]){this[ac]=!0;let t=this[Bn];if(t&&t.blockRemain){let e=this[_e]?this[_e].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`,{entry:t}),this[_e]&&t.write(this[_e]),t.end()}this[Fn](Fs)}}[Ns](t){if(this[mi]&&t)this[lc](t);else if(!t&&!this[_e])this[Bs]();else if(t){if(this[mi]=!0,this[_e]){this[lc](t);let e=this[_e];this[_e]=void 0,this[Ms](e)}else this[Ms](t);for(;this[_e]&&this[_e]?.length>=512&&!this[xn]&&!this[Us];){let e=this[_e];this[_e]=void 0,this[Ms](e)}this[mi]=!1}(!this[_e]||this[fn])&&this[Bs]()}[Ms](t){let e=0,r=t.length;for(;e+512<=r&&!this[xn]&&!this[Us];)switch(this[ft]){case"begin":case"header":this[Du](t,e),e+=512;break;case"ignore":case"body":e+=this[cc](t,e);break;case"meta":e+=this[Cu](t,e);break;default:throw new Error("invalid state: "+this[ft])}e<r&&(this[_e]=this[_e]?Buffer.concat([t.subarray(e),this[_e]]):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[Pe]?(t&&this[Pe].write(t),this[Pe].end()):(this[fn]=!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,r=-1;for(;e>-1&&t.charAt(e)==="/";)r=e,e--;return r===-1?t:t.slice(0,r)},Yw=t=>{let e=t.onReadEntry;t.onReadEntry=e?r=>{e(r),r.resume()}:r=>r.resume()},hf=(t,e)=>{let r=new Map(e.map(c=>[Ai(c),!0])),i=t.filter,o=(c,d="")=>{let u=d||ow(c).root||".",x;if(c===u)x=!1;else{let h=r.get(c);x=h!==void 0?h:o(sw(c),u)}return r.set(c,x),x};t.filter=i?(c,d)=>i(c,d)&&o(Ai(c)):c=>o(Ai(c))},Xw=t=>{let e=new Oi(t),r=t.file,i;try{i=vr.openSync(r,"r");let o=vr.fstatSync(i),c=t.maxReadSize||16*1024*1024;if(o.size<c){let d=Buffer.allocUnsafe(o.size),u=vr.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 x=vr.readSync(i,u,0,c,d);if(x===0)break;d+=x,e.write(u.subarray(0,x))}e.end()}}finally{if(typeof i=="number")try{vr.closeSync(i)}catch{}}},Qw=(t,e)=>{let r=new Oi(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,d)=>{r.on("error",d),r.on("end",c),vr.stat(o,(u,x)=>{if(u)d(u);else{let h=new Uc(o,{readSize:i,size:x.size});h.on("error",d),h.pipe(r)}})})},kr=Li(Xw,Qw,t=>new Oi(t),t=>new Oi(t),(t,e)=>{e?.length&&hf(t,e),t.noResume||Yw(t)}),pf=(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:t_,parse:Lu}=e_,jc=t=>{let e="",r=Lu(t);for(;t_(t)||r.root;){let i=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":r.root;t=t.slice(i.length),e+=i,r=Lu(t)}return[e,t]},co=["|","<",">","?",":"],Wc=co.map(t=>String.fromCodePoint(61440+Number(t.codePointAt(0)))),n_=new Map(co.map((t,e)=>[t,Wc[e]])),r_=new Map(Wc.map((t,e)=>[t,co[e]])),Nu=t=>co.reduce((e,r)=>e.split(r).join(n_.get(r)),t),i_=t=>Wc.reduce((e,r)=>e.split(r).join(r_.get(r)),t),gf=(t,e)=>e?(t=Q(t).replace(/^\.(\/|$)/,""),Ai(e)+"/"+t):Q(t),s_=16*1024*1024,Mu=Symbol("process"),Bu=Symbol("file"),Fu=Symbol("directory"),vc=Symbol("symlink"),zu=Symbol("hardlink"),wi=Symbol("header"),Ks=Symbol("read"),Sc=Symbol("lstat"),$s=Symbol("onlstat"),Ic=Symbol("onread"),Ac=Symbol("onreadlink"),kc=Symbol("openfile"),Tc=Symbol("onopenfile"),wn=Symbol("close"),no=Symbol("mode"),Rc=Symbol("awaitDrain"),dc=Symbol("ondrain"),Ot=Symbol("prefix"),mf=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=Gc(e);super(),this.path=Q(t),this.portable=!!r.portable,this.maxReadSize=r.maxReadSize||s_,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]=jc(this.path);c&&typeof d=="string"&&(this.path=d,i=c)}this.win32=!!r.win32||process.platform==="win32",this.win32&&(this.path=i_(this.path.replaceAll(/\\/g,"/")),t=t.replaceAll(/\\/g,"/")),this.absolute=Q(r.absolute||Ou.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[Sc]()}warn(t,e,r={}){return ao(this,t,e,r)}emit(t,...e){return t==="error"&&(this.#e=!0),super.emit(t,...e)}[Sc](){Pt.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=c_(t),this.emit("stat",t),this[Mu]()}[Mu](){switch(this.type){case"File":return this[Bu]();case"Directory":return this[Fu]();case"SymbolicLink":return this[vc]();default:return this.end()}}[no](t){return pf(t,this.type==="Directory",this.portable)}[Ot](t){return gf(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[Ot](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Ot](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[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)}[Fu](){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()}[vc](){Pt.readlink(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[Ac](e)})}[Ac](t){this.linkpath=Q(t),this[wi](),this.end()}[zu](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=Q(Ou.relative(this.cwd,t)),this.stat.size=0,this[wi](),this.end()}[Bu](){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[zu](e);this.linkCache.set(t,this.absolute)}if(this[wi](),this.stat.size===0)return this.end();this[kc]()}[kc](){Pt.open(this.absolute,"r",(t,e)=>{if(t)return this.emit("error",t);this[Tc](e)})}[Tc](t){if(this.fd=t,this.#e)return this[wn]();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:r,length:i,pos:o}=this;if(t===void 0||e===void 0)throw new Error("cannot read file without first opening");Pt.read(t,e,r,i,o,(c,d)=>{if(c)return this[wn](()=>this.emit("error",c));this[Ic](d)})}[wn](t=()=>{}){this.fd!==void 0&&Pt.close(this.fd,t)}[Ic](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[wn](()=>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[wn](()=>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[dc]():this[Rc](()=>this[dc]())}[Rc](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)}[dc](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[wn](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]()}},o_=class extends mf{sync=!0;[Sc](){this[$s](Pt.lstatSync(this.absolute))}[vc](){this[Ac](Pt.readlinkSync(this.absolute))}[kc](){this[Tc](Pt.openSync(this.absolute,"r"))}[Ks](){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=Pt.readSync(e,r,i,o,c);this[Ic](d),t=!1}finally{if(t)try{this[wn](()=>{})}catch{}}}[Rc](t){t()}[wn](t=()=>{}){this.fd!==void 0&&Pt.closeSync(this.fd),t()}},a_=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 ao(this,t,e,r)}constructor(t,e={}){let r=Gc(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[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: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]=jc(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 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[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 gf(t,this.prefix)}[no](t){return pf(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}},c_=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported",l_=class Sr{tail;head;length=0;static create(e=[]){return new Sr(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++)u_(this,e[r]);return this.length}unshift(...e){for(var r=0,i=e.length;r<i;r++)f_(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 Sr;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 Sr;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 Sr;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 Sr;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=d_(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 d_(t,e,r){let i=e,o=e?e.next:t.head,c=new Kc(r,i,o,t);return c.next===void 0&&(t.tail=c),c.prev===void 0&&(t.head=c),t.length++,c}function u_(t,e){t.tail=new Kc(e,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function f_(t,e){t.head=new Kc(e,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}var Kc=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}},Gu=class{path;absolute;entry;stat;readdir;pending=!1;pendingLink=!1;ignore=!1;piped=!1;constructor(t,e){this.path=t||"./",this.absolute=e}},Hu=Buffer.alloc(1024),Vs=Symbol("onStat"),_i=Symbol("ended"),bt=Symbol("queue"),yi=Symbol("pendingLinks"),hn=Symbol("current"),Un=Symbol("process"),Ei=Symbol("processing"),Gs=Symbol("processJob"),vt=Symbol("jobs"),uc=Symbol("jobDone"),Zs=Symbol("addFSEntry"),qu=Symbol("addTarEntry"),Cc=Symbol("stat"),Dc=Symbol("readdir"),Js=Symbol("onreaddir"),Ys=Symbol("pipe"),ju=Symbol("entry"),fc=Symbol("entryOpt"),Xs=Symbol("writeEntryClass"),wf=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;[bt];[yi]=new Map;[vt]=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=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[Xs]=mf,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 _w(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new Ew(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new vw(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[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[bt]=new l_,this[vt]=0,this.jobs=Number(t.jobs)||4,this[Ei]=!1,this[_i]=!1}[wf](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[_i]=!0,this[Un](),r&&r(),this}write(t){if(this[_i])throw new Error("write after end");return typeof t=="string"?this[Zs](t):this[qu](t),this.flowing}[qu](t){let e=Q(Uu.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let r=new Gu(t.path,e);r.entry=new a_(t,this[fc](r)),r.entry.on("end",()=>this[uc](r)),this[vt]+=1,this[bt].push(r)}this[Un]()}[Zs](t){let e=Q(Uu.resolve(this.cwd,t));this[bt].push(new Gu(t,e)),this[Un]()}[Cc](t){t.pending=!0,this[vt]+=1;let e=this.follow?"stat":"lstat";to[e](t.absolute,(r,i)=>{t.pending=!1,this[vt]-=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[hn])this[Gs](t);else{let r=`${e.dev}:${e.ino}`,i=this[yi].get(r);i?i.push(t):this[yi].set(r,[t]),t.pendingLink=!0,t.pending=!0}this[Un]()}[Dc](t){t.pending=!0,this[vt]+=1,to.readdir(t.absolute,(e,r)=>{if(t.pending=!1,this[vt]-=1,e)return this.emit("error",e);this[Js](t,r)})}[Js](t,e){this.readdirCache.set(t.absolute,e),t.readdir=e,this[Un]()}[Un](){if(!this[Ei]){this[Ei]=!0;for(let t=this[bt].head;t&&this[vt]<this.jobs;t=t.next)if(this[Gs](t.value),t.value.ignore){let e=t.next;this[bt].removeNode(t),t.next=e}this[Ei]=!1,this[_i]&&this[bt].length===0&&this[vt]===0&&(this.zip?this.zip.end(Hu):(super.write(Hu),super.end()))}}get[hn](){return this[bt]&&this[bt].head&&this[bt].head.value}[uc](t){this[bt].shift(),this[vt]-=1;let{stat:e}=t;if(e&&e.isFile()&&e.nlink>1){let r=`${e.dev}:${e.ino}`,i=this[yi].get(r);if(i){this[yi].delete(r);for(let o of i)o.pending=!1,this[Gs](o)}}this[Un]()}[Gs](t){if(t.pending&&t.pendingLink&&t===this[hn]&&(t.pending=!1,t.pendingLink=!1),!t.pending){if(t.entry){t===this[hn]&&!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[Js](t,e):this[Dc](t),!t.readdir)return}if(t.entry=this[ju](t),!t.entry){t.ignore=!0;return}t===this[hn]&&!t.piped&&this[Ys](t)}}}[fc](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}}[ju](t){this[vt]+=1;try{return new this[Xs](t.path,this[fc](t)).on("end",()=>this[uc](t)).on("error",e=>this.emit("error",e))}catch(e){this.emit("error",e)}}[xc](){this[hn]&&this[hn].entry&&this[hn].entry.resume()}[Ys](t){t.piped=!0,t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[Zs](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={}){ao(this,t,e,r)}},$c=class extends lo{sync=!0;constructor(t){super(t),this[Xs]=o_}pause(){}resume(){}[Cc](t){let e=this.follow?"statSync":"lstatSync";this[Vs](t,to[e](t.absolute))}[Dc](t){this[Js](t,to.readdirSync(t.absolute))}[Ys](t){let e=t.entry,r=this.zip;if(t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[Zs](c+i)}),!e)throw new Error("Cannot pipe without source");r?e.on("data",i=>{r.write(i)}):e.on("data",i=>{super[wf](i)})}},x_=(t,e)=>{let r=new $c(t),i=new sf(t.file,{mode:t.mode||438});r.pipe(i),_f(r,e)},h_=(t,e)=>{let r=new lo(t),i=new so(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 yf(r,e).catch(c=>r.emit("error",c)),o},_f=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?kr({file:of.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},yf=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await kr({file:of.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>{t.add(i)}}):t.add(r);t.end()},p_=(t,e)=>{let r=new $c(t);return _f(r,e),r},g_=(t,e)=>{let r=new lo(t);return yf(r,e).catch(i=>r.emit("error",i)),r},WI=Li(x_,h_,p_,g_,(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")}),w_=process.env.__FAKE_PLATFORM__||process.platform,Sf=w_==="win32",{O_CREAT:If,O_NOFOLLOW:Wu,O_TRUNC:Af,O_WRONLY:kf}=vf.constants,Tf=Number(process.env.__FAKE_FS_O_FILENAME__)||vf.constants.UV_FS_O_FILEMAP||0,__=Sf&&!!Tf,y_=512*1024,E_=Tf|Af|If|kf,Ku=!Sf&&typeof Wu=="number"?Wu|Af|If|kf:null,Rf=Ku!==null?()=>Ku:__?t=>t<y_?E_:"w":()=>"w",Pc=(t,e,r)=>{try{return uo.lchownSync(t,e,r)}catch(i){if(i?.code!=="ENOENT")throw i}},ro=(t,e,r,i)=>{uo.lchown(t,e,r,o=>{i(o&&o?.code!=="ENOENT"?o:null)})},b_=(t,e,r,i,o)=>{if(e.isDirectory())Cf(ki.resolve(t,e.name),r,i,c=>{if(c)return o(c);let d=ki.resolve(t,e.name);ro(d,r,i,o)});else{let c=ki.resolve(t,e.name);ro(c,r,i,o)}},Cf=(t,e,r,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,r,i);let d=c.length,u=null,x=h=>{if(!u){if(h)return i(u=h);if(--d===0)return ro(t,e,r,i)}};for(let h of c)b_(t,h,e,r,x)})},v_=(t,e,r,i)=>{e.isDirectory()&&Df(ki.resolve(t,e.name),r,i),Pc(ki.resolve(t,e.name),r,i)},Df=(t,e,r)=>{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 Pc(t,e,r);throw c}for(let o of i)v_(t,o,e,r);return Pc(t,e,r)},Pf=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"}},I_=(t,e)=>{ct.stat(t,(r,i)=>{(r||!i.isDirectory())&&(r=new Pf(t,r?.code||"ENOTDIR")),e(r)})},A_=(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,x=typeof d=="number"&&typeof u=="number"&&(d!==e.processUid||u!==e.processGid),h=e.preserve,m=e.unlink,w=Q(e.cwd),S=(v,I)=>{v?r(v):I&&x?Cf(I,d,u,A=>S(A)):c?ct.chmod(t,o,r):r()};if(t===w)return I_(t,S);if(h)return S_.mkdir(t,{mode:o,recursive:!0}).then(v=>S(null,v??void 0),S);let _=Q(io.relative(w,t)).split("/");Oc(w,_,o,m,w,void 0,S)},Oc=(t,e,r,i,o,c,d)=>{if(e.length===0)return d(null,c);let u=e.shift(),x=Q(io.resolve(t+"/"+u));ct.mkdir(x,r,Of(x,e,r,i,o,c,d))},Of=(t,e,r,i,o,c,d)=>u=>{u?ct.lstat(t,(x,h)=>{if(x)x.path=x.path&&Q(x.path),d(x);else if(h.isDirectory())Oc(t,e,r,i,o,c,d);else if(i)ct.unlink(t,m=>{if(m)return d(m);ct.mkdir(t,r,Of(t,e,r,i,o,c,d))});else{if(h.isSymbolicLink())return d(new fo(t,t+"/"+e.join("/")));d(u)}}):(c=c||t,Oc(t,e,r,i,o,c,d))},k_=t=>{let e=!1,r;try{e=ct.statSync(t).isDirectory()}catch(i){r=i?.code}finally{if(!e)throw new Pf(t,r??"ENOTDIR")}},T_=(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),x=e.preserve,h=e.unlink,m=Q(e.cwd),w=v=>{v&&u&&Df(v,c,d),o&&ct.chmodSync(t,i)};if(t===m)return k_(m),w();if(x)return w(ct.mkdirSync(t,{mode:i,recursive:!0})??void 0);let S=Q(io.relative(m,t)).split("/"),_;for(let v=S.shift(),I=m;v&&(I+="/"+v);v=S.shift()){I=Q(io.resolve(I));try{ct.mkdirSync(I,i),_=_||I}catch{let A=ct.lstatSync(I);if(A.isDirectory())continue;if(h){ct.unlinkSync(I),ct.mkdirSync(I,i),_=_||I;continue}else if(A.isSymbolicLink())return new fo(I,I+"/"+S.join("/"))}}return w(_)},hc=Object.create(null),$u=1e4,wr=new Set,R_=t=>{wr.has(t)?wr.delete(t):hc[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),wr.add(t);let e=hc[t],r=wr.size-$u;if(r>$u/10){for(let i of wr)if(wr.delete(i),delete hc[i],--r<=0)break}return e},C_=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,D_=C_==="win32",P_=t=>t.split("/").slice(0,-1).reduce((e,r)=>{let i=e.at(-1);return i!==void 0&&(r=Lf(i,r)),e.push(r||"/"),e},[]),O_=class{#e=new Map;#n=new Map;#r=new Set;reserve(t,e){t=D_?["win32 parallelization disabled"]:t.map(i=>Ai(Lf(R_(i))));let r=new Set(t.map(i=>P_(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 x of u)o.add(x)}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 x=d[0];typeof x=="function"&&o.add(x)}else u.delete(t)}return this.#r.delete(t),o.forEach(c=>this.#i(c)),!0}},L_=()=>process.umask(),Vu=Symbol("onEntry"),Lc=Symbol("checkFs"),Zu=Symbol("checkFs2"),Nc=Symbol("isReusable"),xt=Symbol("makeFs"),Mc=Symbol("file"),Bc=Symbol("directory"),Qs=Symbol("link"),Ju=Symbol("symlink"),Yu=Symbol("hardlink"),Si=Symbol("ensureNoSymlink"),Xu=Symbol("unsupported"),Qu=Symbol("checkPath"),pc=Symbol("stripAbsolutePath"),_n=Symbol("mkdir"),je=Symbol("onError"),Hs=Symbol("pending"),ef=Symbol("pend"),_r=Symbol("unpend"),gc=Symbol("ended"),mc=Symbol("maybeClose"),Fc=Symbol("skip"),Ti=Symbol("doChown"),Ri=Symbol("uid"),Ci=Symbol("gid"),Di=Symbol("checkedCwd"),N_=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Pi=N_==="win32",M_=1024,B_=(t,e)=>{if(!Pi)return se.unlink(t,e);let r=t+".DELETE."+bf(16).toString("hex");se.rename(t,r,i=>{if(i)return e(i);se.unlink(r,e)})},F_=t=>{if(!Pi)return se.unlinkSync(t);let e=t+".DELETE."+bf(16).toString("hex");se.renameSync(t,e),se.unlinkSync(e)},tf=(t,e,r)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:r,Vc=class extends Oi{[gc]=!1;[Di]=!1;[Hs]=0;reservations=new O_;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[gc]=!0,this[mc]()},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:M_,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(Be.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:L_():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[Vu](e))}warn(t,e,r={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(r.recoverable=!1),super.warn(t,e,r)}[mc](){this[gc]&&this[Hs]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[pc](t,e){let r=t[e],{type:i}=t;if(!r||this.preservePaths)return!0;let[o,c]=jc(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=Be.posix.dirname(t.path),x=Be.posix.normalize(Be.posix.join(u,d.join("/")));if(x.startsWith("../")||x==="..")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}[Qu](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[pc](t,"path")||!this[pc](t,"linkpath"))return!1;if(t.absolute=Be.isAbsolute(t.path)?Q(Be.resolve(t.path)):Q(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: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}=Be.win32.parse(String(t.absolute));t.absolute=i+Nu(String(t.absolute).slice(i.length));let{root:o}=Be.win32.parse(t.path);t.path=o+Nu(t.path.slice(o.length))}return!0}[Vu](t){if(!this[Qu](t))return t.resume();switch(m_.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[Lc](t);default:return this[Xu](t)}}[je](t,e){t.name==="CwdError"?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:e}),this[_r](),e.resume())}[_n](t,e,r){A_(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)}[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}[Ri](t){return tf(this.uid,t.uid,this.processUid)}[Ci](t){return tf(this.gid,t.gid,this.processGid)}[Mc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=new so(String(t.absolute),{flags:Rf(t.size),mode:r,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,x=>{x?this[je](x,t):this[_r](),e()})};i.on("finish",()=>{let u=String(t.absolute),x=i.fd;if(typeof x=="number"&&t.mtime&&!this.noMtime){o++;let h=t.atime||new Date,m=t.mtime;se.futimes(x,h,m,w=>w?se.utimes(u,h,m,S=>c(S&&w)):c())}if(typeof x=="number"&&this[Ti](t)){o++;let h=this[Ri](t),m=this[Ci](t);typeof h=="number"&&typeof m=="number"&&se.fchown(x,h,m,w=>w?se.chown(u,h,m,S=>c(S&&w)):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)}[Bc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode;this[_n](String(t.absolute),r,i=>{if(i){this[je](i,t),e();return}let o=1,c=()=>{--o===0&&(e(),this[_r](),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[Ri](t)),Number(this[Ci](t)),c)),c()})}[Xu](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[Ju](t,e){let r=Q(Be.relative(this.cwd,Be.resolve(Be.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[Si](t,this.cwd,r,()=>this[Qs](t,String(t.linkpath),"symlink",e),i=>{this[je](i,t),e()})}[Yu](t,e){let r=Q(Be.resolve(this.cwd,String(t.linkpath))),i=Q(String(t.linkpath)).split("/");this[Si](t,this.cwd,i,()=>this[Qs](t,r,"link",e),o=>{this[je](o,t),e()})}[Si](t,e,r,i,o){let c=r.shift();if(this.preservePaths||c===void 0)return i();let d=Be.resolve(e,c);se.lstat(d,(u,x)=>{if(u)return i();if(x?.isSymbolicLink())return o(new fo(d,Be.resolve(d,r.join("/"))));this[Si](t,d,r,i,o)})}[ef](){this[Hs]++}[_r](){this[Hs]--,this[mc]()}[Fc](t){this[_r](),t.resume()}[Nc](t,e){return t.type==="File"&&!this.unlink&&e.isFile()&&e.nlink<=1&&!Pi}[Lc](t){this[ef]();let e=[t.path];t.linkpath&&e.push(t.linkpath),this.reservations.reserve(e,r=>this[Zu](t,r))}[Zu](t,e){let r=d=>{e(d)},i=()=>{this[_n](this.cwd,this.dmode,d=>{if(d){this[je](d,t),r();return}this[Di]=!0,o()})},o=()=>{if(t.absolute!==this.cwd){let d=Q(Be.dirname(String(t.absolute)));if(d!==this.cwd)return this[_n](d,this.dmode,u=>{if(u){this[je](u,t),r();return}c()})}c()},c=()=>{se.lstat(String(t.absolute),(d,u)=>{if(u&&(this.keep||this.newer&&u.mtime>(t.mtime??u.mtime))){this[Fc](t),r();return}if(d||this[Nc](t,u))return this[xt](null,t,r);if(u.isDirectory()){if(t.type==="Directory"){let x=this.chmod&&t.mode&&(u.mode&4095)!==t.mode,h=m=>this[xt](m??null,t,r);return x?se.chmod(String(t.absolute),Number(t.mode),h):h()}if(t.absolute!==this.cwd)return se.rmdir(String(t.absolute),x=>this[xt](x??null,t,r))}if(t.absolute===this.cwd)return this[xt](null,t,r);B_(String(t.absolute),x=>this[xt](x??null,t,r))})};this[Di]?o():i()}[xt](t,e,r){if(t){this[je](t,e),r();return}switch(e.type){case"File":case"OldFile":case"ContiguousFile":return this[Mc](e,r);case"Link":return this[Yu](e,r);case"SymbolicLink":return this[Ju](e,r);case"Directory":case"GNUDumpDir":return this[Bc](e,r)}}[Qs](t,e,r,i){se[r](e,String(t.absolute),o=>{o?this[je](o,t):(this[_r](),t.resume()),i()})}},bi=t=>{try{return[null,t()]}catch(e){return[e,null]}},Nf=class extends Vc{sync=!0;[xt](t,e){return super[xt](t,e,()=>{})}[Lc](t){if(!this[Di]){let o=this[_n](this.cwd,this.dmode);if(o)return this[je](o,t);this[Di]=!0}if(t.absolute!==this.cwd){let o=Q(Be.dirname(String(t.absolute)));if(o!==this.cwd){let c=this[_n](o,this.dmode);if(c)return this[je](c,t)}}let[e,r]=bi(()=>se.lstatSync(String(t.absolute)));if(r&&(this.keep||this.newer&&r.mtime>(t.mtime??r.mtime)))return this[Fc](t);if(e||this[Nc](t,r))return this[xt](null,t);if(r.isDirectory()){if(t.type==="Directory"){let c=this.chmod&&t.mode&&(r.mode&4095)!==t.mode,[d]=c?bi(()=>{se.chmodSync(String(t.absolute),Number(t.mode))}):[];return this[xt](d,t)}let[o]=bi(()=>se.rmdirSync(String(t.absolute)));this[xt](o,t)}let[i]=t.absolute===this.cwd?[]:bi(()=>F_(String(t.absolute)));this[xt](i,t)}[Mc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=d=>{let u;try{se.closeSync(o)}catch(x){u=x}(d||u)&&this[je](d||u,t),e()},o;try{o=se.openSync(String(t.absolute),Rf(t.size),r)}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,x=t.mtime;try{se.futimesSync(o,u,x)}catch(h){try{se.utimesSync(String(t.absolute),u,x)}catch{d=h}}}if(this[Ti](t)){let u=this[Ri](t),x=this[Ci](t);try{se.fchownSync(o,Number(u),Number(x))}catch(h){try{se.chownSync(String(t.absolute),Number(u),Number(x))}catch{d=d||h}}}i(d)})}[Bc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode,i=this[_n](String(t.absolute),r);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[Ri](t)),Number(this[Ci](t)))}catch{}e(),t.resume()}[_n](t,e){try{return T_(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}}[Si](t,e,r,i,o){if(this.preservePaths||r.length===0)return i();let c=e;for(let d of r){c=Be.resolve(c,d);let[u,x]=bi(()=>se.lstatSync(c));if(u)return i();if(x.isSymbolicLink())return o(new fo(c,Be.resolve(e,r.join("/"))))}i()}[Qs](t,e,r,i){let o=`${r}Sync`;try{se[o](e,String(t.absolute)),i(),t.resume()}catch(c){return this[je](c,t)}}},z_=t=>{let e=new Nf(t),r=t.file,i=Ef.statSync(r),o=t.maxReadSize||16*1024*1024;new iw(r,{readSize:o,size:i.size}).pipe(e)},U_=(t,e)=>{let r=new Vc(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,d)=>{r.on("error",d),r.on("close",c),Ef.stat(o,(u,x)=>{if(u)d(u);else{let h=new Uc(o,{readSize:i,size:x.size});h.on("error",d),h.pipe(r)}})})},Mf=Li(z_,U_,t=>new Nf(t),t=>new Vc(t),(t,e)=>{e?.length&&hf(t,e)}),G_=(t,e)=>{let r=new $c(t),i=!0,o,c;try{try{o=at.openSync(t.file,"r+")}catch(x){if(x?.code==="ENOENT")o=at.openSync(t.file,"w+");else throw x}let d=at.fstatSync(o),u=Buffer.alloc(512);e:for(c=0;c<d.size;c+=512){for(let m=0,w=0;m<512;m+=w){if(w=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(!w)break e}let x=new jn(u);if(!x.cksumValid)break;let h=512*Math.ceil((x.size||0)/512);if(c+h+512>d.size)break;c+=h,t.mtimeCache&&x.mtime&&t.mtimeCache.set(String(x.path),x.mtime)}i=!1,H_(t,r,c,o,e)}finally{if(i)try{at.closeSync(o)}catch{}}},H_=(t,e,r,i,o)=>{let c=new sf(t.file,{fd:i,start:r});e.pipe(c),j_(e,o)},q_=(t,e)=>{e=Array.from(e);let r=new lo(t),i=(o,c,d)=>{let u=(S,_)=>{S?at.close(o,v=>d(S)):d(null,_)},x=0;if(c===0)return u(null,0);let h=0,m=Buffer.alloc(512),w=(S,_)=>{if(S||_===void 0)return u(S);if(h+=_,h<512&&_)return at.read(o,m,h,m.length-h,x+h,w);if(x===0&&m[0]===31&&m[1]===139)return u(new Error("cannot append to compressed archives"));if(h<512)return u(null,x);let v=new jn(m);if(!v.cksumValid)return u(null,x);let I=512*Math.ceil((v.size??0)/512);if(x+I+512>c||(x+=I+512,x>=c))return u(null,x);t.mtimeCache&&v.mtime&&t.mtimeCache.set(String(v.path),v.mtime),h=0,at.read(o,m,0,512,x,w)};at.read(o,m,0,512,x,w)};return new Promise((o,c)=>{r.on("error",c);let d="r+",u=(x,h)=>{if(x&&x.code==="ENOENT"&&d==="r+")return d="w+",at.open(t.file,d,u);if(x||!h)return c(x);at.fstat(h,(m,w)=>{if(m)return at.close(h,()=>c(m));i(h,w.size,(S,_)=>{if(S)return c(S);let v=new so(t.file,{fd:h,start:_});r.pipe(v),v.on("error",c),v.on("close",o),W_(r,e)})})};at.open(t.file,d,u)})},j_=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?kr({file:Bf.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},W_=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await kr({file:Bf.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r);t.end()},vi=Li(G_,q_,()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},(t,e)=>{if(!fw(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")}),oA=Li(vi.syncFile,vi.asyncFile,vi.syncNoFile,vi.asyncNoFile,(t,e=[])=>{vi.validate?.(t,e),K_(t)}),K_=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))};qt();var ht={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 Ff(t){let e=t?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function ho(t){let e=t?.cozeGroupId?.trim();if(!(!e||e==="0"))return e}function zf(t){let e=t?.permissionMode;if(typeof e!="string")return;let r=e.trim();return r===""?void 0:r}function Uf(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}Jt();$e();re();De();$e();function Tr(t,e){if(xo(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 YA}from"node:fs";import{dirname as QA,join as ek}from"node:path";import{fileURLToPath as nk}from"node:url";var Nt="0.2.3-alpha.2";import{mkdir as ay,rm as r0}from"node:fs/promises";import{join as Hi}from"node:path";Ht();import{readFileSync as ey}from"node:fs";var ty=384;async function Zc(t,e=process.env){let r={};for(let[i,o]of Object.entries(e))typeof o=="string"&&(r[i]=o);await dr(t.agentEnvFile,r,{mode:ty})}function Mi(t){try{let e=JSON.parse(ey(t,"utf8"));return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function jf(t,e,r={},i=o=>o){return{...i({...t,...Mi(e)}),...r}}Ht();function Bi(t){let e=[],r=Object.keys(t).sort();for(let i of r){let o=t[i];o!==void 0&&(ny(o)||e.push(`${i}=${o}`))}return e.length===0?"":`${e.join(`
|
|
92
92
|
`)}
|
|
93
93
|
`}function ny(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==='"'}re();De();$e();re();var po="1008033",Wf="1289";var Kf="pbbp2",$f="https://www.coze.cn",Vf="/api/coze_claw/resource/get_frontier_key",ry="https://www.coze.cn",iy="wss://frontier.coze.cn";function Cr(t){return t??process.env.COZE_BRIDGE_HANDSHAKE_URL??ry}function Zf(t){return t??process.env.COZE_BRIDGE_FRONTIER_URL??iy}function bn(t){let e={},r=t?.ttEnv??process.env.COZE_BRIDGE_TT_ENV,i=t?.usePpe??process.env.COZE_BRIDGE_USE_PPE;return r&&(e["x-tt-env"]=r),i&&(e["x-use-ppe"]=i),e}function zi(t){return t?t.startsWith("boe_")?{ttEnv:t}:{ttEnv:t,usePpe:"1"}:{}}var Fi=j("handshake");async function Jc(t){let e=Cr(t.endpoint),r=t.timeoutMs??1e4,i=`${Rr(e)}${Vf}?aid=${encodeURIComponent(po)}`,o={Authorization:`Bearer ${t.privatecode}`,Accept:"application/json",...bn(t.ppeOverride)},c=new AbortController,d=setTimeout(()=>c.abort(),r);Fi.info("frontier key handshake",{base:e});try{let u=await fetch(i,{method:"GET",headers:o,signal:c.signal}),x=u.headers.get("x-tt-logid")??"",h=u.headers.get("x-tt-trace-id")??"";if(!u.ok){let v=await u.text().catch(()=>"");throw new k("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${u.status} logid=${x}: ${v.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=${x}`);let w=m.data??{},S=typeof w.access_key=="string"&&w.access_key||typeof w.accessKey=="string"&&w.accessKey||void 0,_=typeof w.device_id=="string"&&w.device_id||typeof w.deviceId=="string"&&w.deviceId||void 0;if(!S||!_){let v=JSON.stringify(m).slice(0,500);throw new k("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${x}: ${v}`)}return Fi.info("handshake ok",{remoteDeviceId:_,logid:x,traceId:h}),{accessKey:S,deviceId:_}}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:r}),new k("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${r}ms)`,{cause:u});let x=u.cause;throw Fi.error("handshake error",{base:e,message:u instanceof Error?u.message:String(u),errno:x?.code,syscall:x?.syscall,cause:String(u).slice(0,300)}),new k("UPSTREAM_HANDSHAKE_FAILED",String(u),{cause:u})}finally{clearTimeout(d)}}var Ui=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",pt="auto",Yc=15e4;function Jf(t){return{model:Xc(t.model)??pt,...t.modelToken?{modelToken:t.modelToken}:{}}}function sy(t){return!t||t===pt}var oy=new Set(["auto","\u81EA\u52A8"]);function Xc(t){let e=t?.trim();if(e)return oy.has(e.toLowerCase())?pt:e}function Yf(t){let e={};if(t.modelToken){e.ANTHROPIC_BASE_URL=Ui,e.ANTHROPIC_AUTH_TOKEN=t.modelToken;let r=t.model||pt;e.ANTHROPIC_MODEL=r,e.ANTHROPIC_SMALL_FAST_MODEL=r,e.ANTHROPIC_DEFAULT_HAIKU_MODEL=r,e.ANTHROPIC_DEFAULT_OPUS_MODEL=r,e.ANTHROPIC_DEFAULT_SONNET_MODEL=r,e.CLAUDE_CODE_SUBAGENT_MODEL=r,e.CLAUDE_CODE_ATTRIBUTION_HEADER="0",t.modelInfo?.contextWindow&&(e.CLAUDE_CODE_MAX_CONTEXT_TOKENS=String(t.modelInfo.contextWindow))}else sy(t.model)||(e.ANTHROPIC_MODEL=t.model);return e}function Xf(t,e,r){return t.modelToken?{baseUrl:`${Ui}/v1`,providerName:"coze",headers:{Authorization:`Bearer ${t.modelToken}`,...go(e,r)}}:null}function Qf(t){if(!t.modelToken)return{};let e={model:t.model||pt,model_context_window:t.modelInfo?.contextWindow??Yc};return{CODEX_CONFIG:JSON.stringify(e)}}function go(t,e){let{ttEnv:r,usePpe:i}=zi(t),o={};return r&&(o["x-tt-env"]=r),i&&(o["x-use-ppe"]=i),e&&(o["x-mock-scenario"]=e),o}function e0(t,e,r){if(!t.modelToken)return{};let i=go(e,r);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 t0(t,e,r){if(!t.modelToken)return null;let i=t.model||pt,o=go(e,r),c=["text"];t.modelInfo?.capabilities?.image===!0&&c.push("image");let d={baseUrl:`${Ui}/v1`,api:"openai-completions",apiKey:t.modelToken,models:[{id:i,name:i,reasoning:!1,input:c,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:t.modelInfo?.contextWindow??Yc,maxTokens:8192,api:"openai-completions"}]};return Object.keys(o).length>0&&(d.headers=o),d}function n0(t){return t.modelToken?{OPENAI_API_KEY:t.modelToken,OPENAI_BASE_URL:`${Ui}/v1`}:{}}function el(t,e,r){let i=go(e,r),o=t.modelInfo?.contextWindow??Yc,d=["model:"," provider: openai",` model: ${t.model||pt}`,` base_url: ${Ui}/v1`,` context_length: ${o}`];if(Object.keys(i).length>0){d.push(" default_headers:");for(let[u,x]of Object.entries(i))d.push(` ${u}: ${JSON.stringify(x)}`)}return`${d.join(`
|
|
96
96
|
`)}
|
|
97
|
-
`}var Fi=H("hermes-config"),i0="dont_ask",s0="default";function Kn(t,e){return zi(Be(t,e).root,"hermes-home")}async function cy(t){let e=Kn(t.agentId,t.paths);await ay(e,{recursive:!0,mode:448});let r=Ni({...process.env,...Li(t.paths.agentEnvFile),...n0(t.modelConfig)});await lt(zi(e,".env"),r,{mode:384});let i=Xc(t.modelConfig,t.cozeEnv,t.mockScenario);await lt(zi(e,"config.yaml"),i,{mode:384}),Fi.debug("hermes home bootstrapped",{agentId:t.agentId,home:e,envBytes:r.length,yamlBytes:i.length})}async function o0(t){let e=Kn(t.agentId,t.paths),r=zi(e,"state.db"),i=zi(e,"config.yaml");await r0(r,{force:!0}).catch(c=>Fi.warn("hermes reset: rm state.db failed (ignored)",{agentId:t.agentId,err:String(c)}));let o=Xc({modelInfo:t.modelInfo},t.cozeEnv,t.mockScenario);await lt(i,o,{mode:384}).catch(c=>Fi.warn("hermes reset: write config.yaml failed (ignored)",{agentId:t.agentId,err:String(c)})),Fi.info("hermes reset complete",{agentId:t.agentId,removed:["state.db"],rewrote:["config.yaml"]})}async function el(t,e){let r=Kn(t,e);await r0(r,{recursive:!0,force:!0}).catch(i=>Fi.warn("hermes-home cleanup failed (ignored)",{agentId:t,err:String(i)}))}var Qc=new Map;function a0(t){let e=Qc.get(t.agentId);if(e)return e;let r=cy(t).finally(()=>Qc.delete(t.agentId));return Qc.set(t.agentId,r),r}var fe=H("agent-handlers"),l0=5*1024*1024,fy=1,hy=6,xy=new Set(["node_modules",".git",".coze","dist","build",".next"]),py=/^(ppe|boe)_[A-Za-z0-9_-]{1,120}$/,gy=/^[A-Za-z][A-Za-z0-9._-]{0,63}$/,my=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z][0-9A-Za-z.-]*)?(?:\+[0-9A-Za-z][0-9A-Za-z.-]*)?$/;function wy(t){let e=t?.trim();return e?my.test(e)||gy.test(e)?e:(fe.warn("_agent/upgrade: invalid targetVersion, fallback to latest",{targetVersion:t}),"latest"):"latest"}function _y(t){return new Promise((e,r)=>{let i=rt("npx",t,{detached:!0,stdio:"ignore",windowsHide:!0}),o=!1,c=l=>{o||(o=!0,l?r(l):e(i.pid??0))};i.once("spawn",()=>{i.unref(),c()}),i.once("error",l=>c(l))})}var go=class{constructor(e){this.opts=e}opts;get paths(){return this.opts.paths??J()}async listSkills(e){e._meta;let r=Wn(e._meta),i=await this.loadAgentCfg(r),o=i?.workspace??Be(r,this.paths).workspace,c=i?.framework??"claude-code",l=i?.skills??[],{base:u}=Rr(c,r,o,this.paths),f=[],x=new Set;for(let p of l){let m=$e(u,p.relPath,"SKILL.md");await c0(m).then(_=>_.isFile()).catch(()=>!1)&&(f.push(vy(p)),x.add(p.relPath))}if(e.scanLocal){let p=await yy(r,o,c,this.paths);for(let m of p)x.has(m.relPath)||(x.add(m.relPath),f.push(m.skill))}return{skills:f}}async addSkills(e){e._meta;let r=Wn(e._meta),i=await this.requireAgentCfg(r),o=e.skills??[],c=[...i.skills??[]],l=new Map(c.map((f,x)=>[f.skillId,x])),u=[];for(let f of o){let x=await mo({agentId:r,workspace:i.workspace,framework:i.framework,skill:f,paths:this.paths});wo(c,l,x),u.push(f)}return await oi(r,c),this.reloadAgentSessions(r,"skills-added"),{installedSkills:u}}async removeSkills(e){e._meta;let r=Wn(e._meta),i=await this.requireAgentCfg(r),o=new Set(e.skillIds??[]),c=i.skills??[],l=[],{base:u}=Rr(i.framework,r,i.workspace,this.paths);for(let f of c){if(!o.has(f.skillId)){l.push(f);continue}let x=$e(u,f.relPath);await rl(x,{recursive:!0,force:!0}),fe.info("skill removed",{agentId:r,skillId:f.skillId,relPath:f.relPath})}return await oi(r,l),this.reloadAgentSessions(r,"skills-removed"),{ok:!0}}async publishSkill(e){e._meta;let r=Wn(e._meta);if(!e.skillName)throw new T("IPC_BAD_REQUEST","_agent/publishSkill: missing skillName");fe.info("_agent/publishSkill start",{agentId:r,skillId:e.skillId??"",skillName:e.skillName,userId:e.userId??"",accountId:e.accountId??""});let i=await this.loadAgentCfg(r),o=i?.workspace??Be(r,this.paths).workspace,c=i?.framework??"claude-code",l=p0(e.skillName),{base:u,subdir:f}=Rr(c,r,o,this.paths),x=$e(f,l),p=$e(u,x),m=$e(p,"SKILL.md");if(!await c0(m).then(y=>y.isFile()).catch(()=>!1))throw new T("SKILL_NOT_FOUND",`skill not found locally: ${e.skillName} (${x})`);let _=new cl.default;_.addLocalFolder(p,l);let b=_.toBuffer();if(b.length>d0)throw new T("SKILL_ZIP_TOO_LARGE",`skill zip ${b.length} bytes exceeds limit ${d0}`);let I=await po(m,{encoding:"utf8"}).then(y=>m0(y).description).catch(()=>{}),A={};this.opts.publishSkillToMarketplace?A=await this.opts.publishSkillToMarketplace({zip:b,...e.skillId?{skillId:e.skillId}:{},skillName:e.skillName,...I?{description:I}:{},agentId:r,...e.userId?{userId:e.userId}:{},...e.accountId?{accountId:e.accountId}:{}}):fe.warn("_agent/publishSkill: publishSkillToMarketplace not injected, skip upload",{agentId:r,skillName:e.skillName});let k=A.version??"v1.0",P=A.skillId??e.skillId??g0(r,x);if(i){let y=i.skills??[],R=y.find(O=>O.relPath===x);R?(R.version=k,R.skillId=P):y.push({skillId:P,skillName:e.skillName,relPath:x,version:k,installedAt:Date.now(),...I?{description:I}:{}}),await oi(r,y)}return fe.info("skill published",{agentId:r,skillName:e.skillName,relPath:x,zipBytes:b.length,skillId:P,version:k}),{ok:!0,skillId:P,version:k}}reloadAgentSessionsPublic(e,r){this.reloadAgentSessions(e,r)}reloadAgentSessions(e,r){let i=this.opts.agents.get(e);if(i)for(let[o,c]of i.sessions){if(!c.downstream)continue;let l=c.acpSessionId;if(l&&i.activeTriggers.has(l)||this.isRuntimePendingPermission(c)){c.reloadAfterTurn=!0,fe.info("downstream busy, scheduling reload after turn",{reason:r,agentId:e,framework:i.framework,cloudId:o,acpId:l});continue}let f=c.downstream;c.downstream=void 0,fe.info("killing downstream for workspace reload (idle)",{reason:r,agentId:e,framework:i.framework,cloudId:o,acpId:l}),f.stop(r).catch(x=>fe.warn("downstream stop failed during reload (ignored)",{reason:r,agentId:e,cloudId:o,err:String(x)}))}}isRuntimePendingPermission(e){let r=this.opts.isRuntimePendingPermission;return!r||!e.downstream?!1:r(e.downstream)}async updateAgent(e){if(!e.cozeIdentity?.trim())return fe.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let r=e.agentId,i=await Ee(r);if(!i)throw new T("AGENT_NOT_FOUND",`agent not found: ${r}`);if(i.cozeIdentity===e.cozeIdentity)return fe.info("_agent/update: cozeIdentity unchanged, noop",{agentId:r}),{ok:!0};try{await dr(i.workspace,i.framework,e.cozeIdentity)}catch(o){throw fe.error("_agent/update: writeInstructionFile failed, aborting update",{agentId:r,framework:i.framework,workspace:i.workspace,err:String(o)}),new T("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${r}: ${String(o)}`,{cause:o})}return i.cozeIdentity=e.cozeIdentity,await Fe(i),fe.info("_agent/update: cozeIdentity rewritten",{agentId:r,framework:i.framework}),this.reloadAgentSessions(r,"identity-changed"),{ok:!0}}async upgradeBridge(e){let r=e.agentId||e._meta?.cozeAgentId;if(!r)throw new T("IPC_BAD_REQUEST","_agent/upgrade: missing agentId");if(!await Ee(r))throw new T("AGENT_NOT_FOUND",`agent not found: ${r}`);let o=["-y"];e.registry&&Oi(e.registry)&&o.push(`--registry=${e.registry}`);let c=wy(e.targetVersion);o.push("--ignore-existing",`coze-bridge@${c}`,"connect");let l=e._meta?.cozeEnv;l&&py.test(l)&&o.push("--env",l);let u=await _y(o);return fe.info("_agent/upgrade: spawned bridge upgrade process",{agentId:r,pid:u,targetVersion:c,currentVersion:e.currentVersion??"",reason:e.reason??""}),{ok:!0,accepted:!0,pid:u,message:"bridge upgrade started"}}async disconnectAgent(e){let r=e.agentId;if(!r)throw new T("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let i=await Ee(r);return i?(i.disconnectedAt=Date.now(),i.disconnectReason=e.reason??"",await Fe(i),fe.info("agent disconnected",{agentId:r,reason:e.reason??"",force:e.force??!1}),this.opts.disposeAndMarkDisconnected&&await this.opts.disposeAndMarkDisconnected(r,e.reason??"disconnect"),{ok:!0}):(fe.warn("_agent/disconnect: agent not found, ignoring",{agentId:r}),{ok:!0})}async deleteAgent(e){let r=e.agentId;if(!r)throw new T("IPC_BAD_REQUEST",`${ft.DELETE}: missing agentId`);let i=await Ee(r),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(r,e.reason??"delete");let l=Be(r);return c==="cloud"?await rl(l.root,{recursive:!0,force:!0}):i&&(i.deletedAt=Date.now(),i.deleteReason=e.reason??"deleted",await Fe(i)),fe.info("agent deleted",{agentId:r,reason:e.reason??"",deployType:c,configFound:!!i}),{ok:!0}}async switchModel(e){if(Tr(e._meta,"_agent/switchModel"),!e.agentId)throw new T("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let r=Zc(e.model)??vt,i=await Ee(e.agentId);if(!i)throw new T("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);i.model=r,e.modelInfo&&(i.modelInfo=e.modelInfo),await Fe(i),fe.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:r,reason:e.reason??""});let o=this.opts.agents.get(e.agentId);if(!o)return fe.info("_agent/switchModel: agent not running, config persisted only",{agentId:e.agentId}),{ok:!0};o.model=r,e.modelInfo&&o.setModelInfo(e.modelInfo),this.opts.cleanupOpenclawProviders&&await this.opts.cleanupOpenclawProviders(o).catch(l=>fe.warn("cleanupOpenclawProviders before switchModel failed (ignored)",{agentId:e.agentId,err:String(l)}));let c=[];for(let[l,u]of o.allSessionQueues())c.push(u.enqueue(async()=>{let f=o.sessions.get(l);f?.downstream&&(await f.downstream.stop(`switchModel: ${r}`).catch(()=>{}),f.downstream=void 0)}));return await Promise.all(c),fe.info("_agent/switchModel: all session runtimes killed, next prompt will respawn",{agentId:e.agentId,model:r,cloudSessions:c.length}),{ok:!0}}async resetAgent(e){if(Tr(e._meta,ft.RESET),!e.agentId)throw new T("IPC_BAD_REQUEST",`${ft.RESET}: missing agentId`);return await this.clearSessionMappings(e.agentId,ft.RESET),this.opts.hermesReset&&await this.opts.hermesReset(e.agentId,e._meta?.cozeEnv).catch(r=>fe.warn("hermes reset hook failed (ignored)",{agentId:e.agentId,err:String(r)})),await this.runDetailSync(e.agentId,ft.RESET,e.reason),{ok:!0}}async clearSessionMappings(e,r){let i=this.opts.agents.get(e);if(!i){await this.clearPersistedAcpSessionIds(e),fe.info("reset: agent not in memory, cleared persisted acpSessionIds only",{agentId:e});return}await i.killAllRuntimes(r);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,l]of i.sessions)o.set(c,{modelToken:l.modelToken,tokenGeneratedAt:l.tokenGeneratedAt});await si(e,o)}async clearPersistedAcpSessionIds(e){let r=await Ee(e).catch(()=>null);if(!r?.sessions)return;let i=!1;for(let o of Object.values(r.sessions))o.acpSessionId&&(o.acpSessionId=void 0,i=!0);i&&await Fe(r)}async repairAgent(e){if(Tr(e._meta,ft.REPAIR),!e.agentId)throw new T("IPC_BAD_REQUEST",`${ft.REPAIR}: missing agentId`);let r=await this.loadAgentCfg(e.agentId);if(r&&r.framework!=="openclaw")throw new T("IPC_BAD_REQUEST",`${ft.REPAIR} only allowed for openclaw, got ${r.framework}`);if(r&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,r.workspace)}catch(i){fe.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(i)})}return await this.runDetailSync(e.agentId,ft.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,r,i){if(!this.opts.detailSyncer){fe.warn("detailSyncer not wired, skipping sync",{method:r,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(o){fe.warn("detail sync failed (ignored)",{method:r,agentId:e,reason:i,err:String(o)})}}async getFileTree(e){Tr(e._meta,"_agent/getFileTree");let r=e._meta,i=Wn(r),o=await this.resolveWorkspace(i),c=e.filePath??"",l=this.safeJoin(o,c),u=await tl(l).catch(()=>null);if(!u)throw new T("IPC_BAD_REQUEST",`path not found: ${c}`);if(u.isSymbolicLink())throw new T("IPC_BAD_REQUEST",`symlink not allowed: ${c}`);if(!await ii(l,o))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${c}`);let f=Ny(e.depth);return u.isDirectory()?{tree:await Ly(o,l,c,f)}:{tree:[{name:My(c),path:y0(c||"."),isDir:!1,size:u.size,modifiedAt:Math.floor(u.mtimeMs)}]}}async getFileContent(e){Tr(e._meta,"_agent/getFileContent");let r=Wn(e._meta),i=await this.resolveWorkspace(r);if(!e.filePath)throw new T("IPC_BAD_REQUEST","filePath required");let o=this.safeJoin(i,e.filePath),c=await tl(o).catch(()=>null);if(!c||!c.isFile())throw new T("IPC_BAD_REQUEST",`not a file: ${e.filePath}`);if(c.isSymbolicLink())throw new T("IPC_BAD_REQUEST",`symlink not allowed: ${e.filePath}`);if(!await ii(o,i))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${e.filePath}`);if(c.size>l0)throw new T("IPC_BAD_REQUEST",`file too large: ${c.size} bytes (max ${l0})`);let l=await po(o);return l.includes(0)?{content:l.toString("base64"),encoding:"base64",size:c.size}:{content:l.toString("utf8"),encoding:"utf-8",size:c.size}}async resolveWorkspace(e){let r=this.opts.agents.get(e);return r?r.workspace:(await Ee(e).catch(()=>null))?.workspace??Be(e).workspace}safeJoin(e,r){let i=sl(e,r||"."),o=al(e,i);if(o.startsWith("..")||o===".."||o.startsWith(`..${f0}`))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${r}`);return i}loadAgentCfg(e){return Ee(e)}async requireAgentCfg(e){let r=await this.loadAgentCfg(e);if(!r)throw new T("AGENT_NOT_FOUND",`no config for agent: ${e}`);return r}};function p0(t){let e=t.trim().replace(/[\x00-\x1f<>:"|?*/\\]+/g,"-").replace(/^[\s.-]+|[\s.-]+$/g,"").slice(0,64);if(!e||e==="."||e==="..")throw new T("IPC_BAD_REQUEST",`invalid skill name: ${t}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new T("IPC_BAD_REQUEST",`reserved windows filename: ${t}`);return e}function Rr(t,e,r,i){switch(t){case"claude-code":return{base:r,subdir:$e(".claude","skills")};case"codex":case"openclaw":return{base:r,subdir:$e(".agents","skills")};case"hermes":return{base:Kn(e,i??J()),subdir:"skills"}}}function g0(t,e){return(ly("sha256").update(`${t}\0${e}`).digest().readBigUInt64BE(0)&0x7fffffffffffffffn).toString()}function m0(t){if(!t.startsWith("---"))return{};let e=t.indexOf(`
|
|
97
|
+
`}var Gi=j("hermes-config"),i0="dont_ask",s0="default";function $n(t,e){return Hi(ze(t,e).root,"hermes-home")}async function cy(t){let e=$n(t.agentId,t.paths);await ay(e,{recursive:!0,mode:448});let r=Bi({...process.env,...Mi(t.paths.agentEnvFile),...n0(t.modelConfig)});await ut(Hi(e,".env"),r,{mode:384});let i=el(t.modelConfig,t.cozeEnv,t.mockScenario);await ut(Hi(e,"config.yaml"),i,{mode:384}),Gi.debug("hermes home bootstrapped",{agentId:t.agentId,home:e,envBytes:r.length,yamlBytes:i.length})}async function o0(t){let e=$n(t.agentId,t.paths),r=Hi(e,"state.db"),i=Hi(e,"config.yaml");await r0(r,{force:!0}).catch(c=>Gi.warn("hermes reset: rm state.db failed (ignored)",{agentId:t.agentId,err:String(c)}));let o=el({model:t.model,modelInfo:t.modelInfo},t.cozeEnv,t.mockScenario);await ut(i,o,{mode:384}).catch(c=>Gi.warn("hermes reset: write config.yaml failed (ignored)",{agentId:t.agentId,err:String(c)})),Gi.info("hermes reset complete",{agentId:t.agentId,removed:["state.db"],rewrote:["config.yaml"]})}async function nl(t,e){let r=$n(t,e);await r0(r,{recursive:!0,force:!0}).catch(i=>Gi.warn("hermes-home cleanup failed (ignored)",{agentId:t,err:String(i)}))}var tl=new Map;function a0(t){let e=tl.get(t.agentId);if(e)return e;let r=cy(t).finally(()=>tl.delete(t.agentId));return tl.set(t.agentId,r),r}var pe=j("agent-handlers"),l0=5*1024*1024,fy=1,xy=6,hy=new Set(["node_modules",".git",".coze","dist","build",".next"]),py=/^(ppe|boe)_[A-Za-z0-9_-]{1,120}$/,gy=/^[A-Za-z][A-Za-z0-9._-]{0,63}$/,my=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z][0-9A-Za-z.-]*)?(?:\+[0-9A-Za-z][0-9A-Za-z.-]*)?$/;function wy(t){let e=t?.trim();return e?my.test(e)||gy.test(e)?e:(pe.warn("_agent/upgrade: invalid targetVersion, fallback to latest",{targetVersion:t}),"latest"):"latest"}function _y(t){return new Promise((e,r)=>{let i=st("npx",t,{detached:!0,stdio:"ignore",windowsHide:!0}),o=!1,c=d=>{o||(o=!0,d?r(d):e(i.pid??0))};i.once("spawn",()=>{i.unref(),c()}),i.once("error",d=>c(d))})}var wo=class{constructor(e){this.opts=e}opts;get paths(){return this.opts.paths??J()}async listSkills(e){e._meta;let r=Kn(e._meta),i=await this.loadAgentCfg(r),o=i?.workspace??ze(r,this.paths).workspace,c=i?.framework??"claude-code",d=i?.skills??[],{base:u}=Dr(c,r,o,this.paths),x=[],h=new Set;for(let m of d){let w=Ze(u,m.relPath,"SKILL.md");await c0(w).then(_=>_.isFile()).catch(()=>!1)&&(x.push(vy(m)),h.add(m.relPath))}if(e.scanLocal){let m=await yy(r,o,c,this.paths);for(let w of m)h.has(w.relPath)||(h.add(w.relPath),x.push(w.skill))}return{skills:x}}async addSkills(e){e._meta;let r=Kn(e._meta),i=await this.requireAgentCfg(r),o=e.skills??[],c=[...i.skills??[]],d=new Map(c.map((x,h)=>[x.skillId,h])),u=[];for(let x of o){let h=await _o({agentId:r,workspace:i.workspace,framework:i.framework,skill:x,paths:this.paths});yo(c,d,h),u.push(x)}return await ci(r,c),this.reloadAgentSessions(r,"skills-added"),{installedSkills:u}}async removeSkills(e){e._meta;let r=Kn(e._meta),i=await this.requireAgentCfg(r),o=new Set(e.skillIds??[]),c=i.skills??[],d=[],{base:u}=Dr(i.framework,r,i.workspace,this.paths);for(let x of c){if(!o.has(x.skillId)){d.push(x);continue}let h=Ze(u,x.relPath);await sl(h,{recursive:!0,force:!0}),pe.info("skill removed",{agentId:r,skillId:x.skillId,relPath:x.relPath})}return await ci(r,d),this.reloadAgentSessions(r,"skills-removed"),{ok:!0}}async publishSkill(e){e._meta;let r=Kn(e._meta);if(!e.skillName)throw new k("IPC_BAD_REQUEST","_agent/publishSkill: missing skillName");pe.info("_agent/publishSkill start",{agentId:r,skillId:e.skillId??"",skillName:e.skillName,userId:e.userId??"",accountId:e.accountId??""});let i=await this.loadAgentCfg(r),o=i?.workspace??ze(r,this.paths).workspace,c=i?.framework??"claude-code",d=p0(e.skillName),{base:u,subdir:x}=Dr(c,r,o,this.paths),h=Ze(x,d),m=Ze(u,h),w=Ze(m,"SKILL.md");if(!await c0(w).then(y=>y.isFile()).catch(()=>!1))throw new k("SKILL_NOT_FOUND",`skill not found locally: ${e.skillName} (${h})`);let _=new dl.default;_.addLocalFolder(m,d);let v=_.toBuffer();if(v.length>d0)throw new k("SKILL_ZIP_TOO_LARGE",`skill zip ${v.length} bytes exceeds limit ${d0}`);let I=await mo(w,{encoding:"utf8"}).then(y=>m0(y).description).catch(()=>{}),A={};this.opts.publishSkillToMarketplace?A=await this.opts.publishSkillToMarketplace({zip:v,...e.skillId?{skillId:e.skillId}:{},skillName:e.skillName,...I?{description:I}:{},agentId:r,...e.userId?{userId:e.userId}:{},...e.accountId?{accountId:e.accountId}:{}}):pe.warn("_agent/publishSkill: publishSkillToMarketplace not injected, skip upload",{agentId:r,skillName:e.skillName});let T=A.version??"v1.0",P=A.skillId??e.skillId??g0(r,h);if(i){let y=i.skills??[],C=y.find(O=>O.relPath===h);C?(C.version=T,C.skillId=P):y.push({skillId:P,skillName:e.skillName,relPath:h,version:T,installedAt:Date.now(),...I?{description:I}:{}}),await ci(r,y)}return pe.info("skill published",{agentId:r,skillName:e.skillName,relPath:h,zipBytes:v.length,skillId:P,version:T}),{ok:!0,skillId:P,version:T}}reloadAgentSessionsPublic(e,r){this.reloadAgentSessions(e,r)}reloadAgentSessions(e,r){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,pe.info("downstream busy, scheduling reload after turn",{reason:r,agentId:e,framework:i.framework,cloudId:o,acpId:d});continue}let x=c.downstream;c.downstream=void 0,pe.info("killing downstream for workspace reload (idle)",{reason:r,agentId:e,framework:i.framework,cloudId:o,acpId:d}),x.stop(r).catch(h=>pe.warn("downstream stop failed during reload (ignored)",{reason:r,agentId:e,cloudId:o,err:String(h)}))}}isRuntimePendingPermission(e){let r=this.opts.isRuntimePendingPermission;return!r||!e.downstream?!1:r(e.downstream)}async updateAgent(e){if(!e.cozeIdentity?.trim())return pe.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let r=e.agentId,i=await Ie(r);if(!i)throw new k("AGENT_NOT_FOUND",`agent not found: ${r}`);if(i.cozeIdentity===e.cozeIdentity)return pe.info("_agent/update: cozeIdentity unchanged, noop",{agentId:r}),{ok:!0};try{await ur(i.workspace,i.framework,e.cozeIdentity)}catch(o){throw pe.error("_agent/update: writeInstructionFile failed, aborting update",{agentId:r,framework:i.framework,workspace:i.workspace,err:String(o)}),new k("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${r}: ${String(o)}`,{cause:o})}return i.cozeIdentity=e.cozeIdentity,await Ue(i),pe.info("_agent/update: cozeIdentity rewritten",{agentId:r,framework:i.framework}),this.reloadAgentSessions(r,"identity-changed"),{ok:!0}}async upgradeBridge(e){let r=e.agentId||e._meta?.cozeAgentId;if(!r)throw new k("IPC_BAD_REQUEST","_agent/upgrade: missing agentId");if(!await Ie(r))throw new k("AGENT_NOT_FOUND",`agent not found: ${r}`);let o=["-y"];e.registry&&Ni(e.registry)&&o.push(`--registry=${e.registry}`);let c=wy(e.targetVersion);o.push("--ignore-existing",`coze-bridge@${c}`,"connect");let d=e._meta?.cozeEnv;d&&py.test(d)&&o.push("--env",d);let u=await _y(o);return pe.info("_agent/upgrade: spawned bridge upgrade process",{agentId:r,pid:u,targetVersion:c,currentVersion:e.currentVersion??"",reason:e.reason??""}),{ok:!0,accepted:!0,pid:u,message:"bridge upgrade started"}}async disconnectAgent(e){let r=e.agentId;if(!r)throw new k("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let i=await Ie(r);return i?(i.disconnectedAt=Date.now(),i.disconnectReason=e.reason??"",await Ue(i),pe.info("agent disconnected",{agentId:r,reason:e.reason??"",force:e.force??!1}),this.opts.disposeAndMarkDisconnected&&await this.opts.disposeAndMarkDisconnected(r,e.reason??"disconnect"),{ok:!0}):(pe.warn("_agent/disconnect: agent not found, ignoring",{agentId:r}),{ok:!0})}async deleteAgent(e){let r=e.agentId;if(!r)throw new k("IPC_BAD_REQUEST",`${ht.DELETE}: missing agentId`);let i=await Ie(r),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(r,e.reason??"delete");let d=ze(r);return c==="cloud"?await sl(d.root,{recursive:!0,force:!0}):i&&(i.deletedAt=Date.now(),i.deleteReason=e.reason??"deleted",await Ue(i)),pe.info("agent deleted",{agentId:r,reason:e.reason??"",deployType:c,configFound:!!i}),{ok:!0}}async switchModel(e){if(Tr(e._meta,"_agent/switchModel"),!e.agentId)throw new k("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let r=Xc(e.model)??pt,i=await Ie(e.agentId);if(!i)throw new k("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);i.model=r,e.modelInfo&&(i.modelInfo=e.modelInfo),await Ue(i),pe.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:r,reason:e.reason??""});let o=this.opts.agents.get(e.agentId);if(!o)return pe.info("_agent/switchModel: agent not running, config persisted only",{agentId:e.agentId}),{ok:!0};o.model=r,e.modelInfo&&o.setModelInfo(e.modelInfo),this.opts.cleanupOpenclawProviders&&await this.opts.cleanupOpenclawProviders(o).catch(d=>pe.warn("cleanupOpenclawProviders before switchModel failed (ignored)",{agentId:e.agentId,err:String(d)}));let c=[];for(let[d,u]of o.allSessionQueues())c.push(u.enqueue(async()=>{let x=o.sessions.get(d);x?.downstream&&(await x.downstream.stop(`switchModel: ${r}`).catch(()=>{}),x.downstream=void 0)}));return await Promise.all(c),pe.info("_agent/switchModel: all session runtimes killed, next prompt will respawn",{agentId:e.agentId,model:r,cloudSessions:c.length}),{ok:!0}}async resetAgent(e){if(Tr(e._meta,ht.RESET),!e.agentId)throw new k("IPC_BAD_REQUEST",`${ht.RESET}: missing agentId`);return await this.clearSessionMappings(e.agentId,ht.RESET),this.opts.hermesReset&&await this.opts.hermesReset(e.agentId,e._meta?.cozeEnv).catch(r=>pe.warn("hermes reset hook failed (ignored)",{agentId:e.agentId,err:String(r)})),await this.runDetailSync(e.agentId,ht.RESET,e.reason),{ok:!0}}async clearSessionMappings(e,r){let i=this.opts.agents.get(e);if(!i){await this.clearPersistedAcpSessionIds(e),pe.info("reset: agent not in memory, cleared persisted acpSessionIds only",{agentId:e});return}await i.killAllRuntimes(r);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});await ai(e,o)}async clearPersistedAcpSessionIds(e){let r=await Ie(e).catch(()=>null);if(!r?.sessions)return;let i=!1;for(let o of Object.values(r.sessions))o.acpSessionId&&(o.acpSessionId=void 0,i=!0);i&&await Ue(r)}async repairAgent(e){if(Tr(e._meta,ht.REPAIR),!e.agentId)throw new k("IPC_BAD_REQUEST",`${ht.REPAIR}: missing agentId`);let r=await this.loadAgentCfg(e.agentId);if(r&&r.framework!=="openclaw")throw new k("IPC_BAD_REQUEST",`${ht.REPAIR} only allowed for openclaw, got ${r.framework}`);if(r&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,r.workspace)}catch(i){pe.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(i)})}return await this.runDetailSync(e.agentId,ht.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,r,i){if(!this.opts.detailSyncer){pe.warn("detailSyncer not wired, skipping sync",{method:r,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(o){pe.warn("detail sync failed (ignored)",{method:r,agentId:e,reason:i,err:String(o)})}}async getFileTree(e){Tr(e._meta,"_agent/getFileTree");let r=e._meta,i=Kn(r),o=await this.resolveWorkspace(i),c=e.filePath??"",d=this.safeJoin(o,c),u=await rl(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 x=Ny(e.depth);return u.isDirectory()?{tree:await Ly(o,d,c,x)}:{tree:[{name:My(c),path:y0(c||"."),isDir:!1,size:u.size,modifiedAt:Math.floor(u.mtimeMs)}]}}async getFileContent(e){Tr(e._meta,"_agent/getFileContent");let r=Kn(e._meta),i=await this.resolveWorkspace(r);if(!e.filePath)throw new k("IPC_BAD_REQUEST","filePath required");let o=this.safeJoin(i,e.filePath),c=await rl(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>l0)throw new k("IPC_BAD_REQUEST",`file too large: ${c.size} bytes (max ${l0})`);let d=await mo(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 r=this.opts.agents.get(e);return r?r.workspace:(await Ie(e).catch(()=>null))?.workspace??ze(e).workspace}safeJoin(e,r){let i=al(e,r||"."),o=ll(e,i);if(o.startsWith("..")||o===".."||o.startsWith(`..${f0}`))throw new k("IPC_BAD_REQUEST",`path escapes workspace: ${r}`);return i}loadAgentCfg(e){return Ie(e)}async requireAgentCfg(e){let r=await this.loadAgentCfg(e);if(!r)throw new k("AGENT_NOT_FOUND",`no config for agent: ${e}`);return r}};function p0(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 Dr(t,e,r,i){switch(t){case"claude-code":return{base:r,subdir:Ze(".claude","skills")};case"codex":case"openclaw":return{base:r,subdir:Ze(".agents","skills")};case"hermes":return{base:$n(e,i??J()),subdir:"skills"}}}function g0(t,e){return(ly("sha256").update(`${t}\0${e}`).digest().readBigUInt64BE(0)&0x7fffffffffffffffn).toString()}function m0(t){if(!t.startsWith("---"))return{};let e=t.indexOf(`
|
|
98
98
|
---`,3);if(e<0)return{};let r=t.slice(3,e),i={};for(let o of r.split(`
|
|
99
|
-
`)){let c=/^\s*(name|description)\s*:\s*(.+?)\s*$/.exec(o);if(!c||!c[2])continue;let l=c[1],u=c[2].trim();(u.startsWith('"')&&u.endsWith('"')||u.startsWith("'")&&u.endsWith("'"))&&(u=u.slice(1,-1)),u&&(i[l]=u)}return i}async function yy(t,e,r,i){let{base:o,subdir:c}=Rr(r,t,e,i),l=$e(o,c),u=await u0(l,{withFileTypes:!0}).catch(()=>null);if(!u)return[];let f=[];for(let x of u){if(!x.isDirectory())continue;let p=x.name,m=$e(c,p),v=$e(l,p,"SKILL.md"),_=await po(v,{encoding:"utf8"}).catch(()=>null);if(_===null)continue;let b=m0(_);f.push({relPath:m,skill:{skillId:g0(t,m),skillName:b.name||p,...b.description?{description:b.description}:{}}})}return f}var by=3e4,Ey=50*1024*1024,d0=10*1024*1024,Pr=3e4;async function mo(t){let{agentId:e,workspace:r,framework:i,skill:o,paths:c}=t;if(!o.skillName)throw new T("IPC_BAD_REQUEST","skill missing skillName");let l=typeof o.content=="string"&&o.content.length>0,u=typeof o.downloadUrl=="string"&&o.downloadUrl.length>0;if(!l&&!u)throw new T("IPC_BAD_REQUEST",`skill ${o.skillId} missing both content and downloadUrl`);let f=p0(o.skillName),{base:x,subdir:p}=Rr(i,e,r,c),m=$e(p,f),v=$e(x,m);if(await nl(v,{recursive:!0}),l){let b=Buffer.from(o.content,"utf8");Ui(b.length),await il($e(v,"SKILL.md"),b,"utf8")}else{let b=await Iy(o.downloadUrl);Ty(b)?await Py(b,v):ky(b)?await Cy(b,v):await il($e(v,"SKILL.md"),b.toString("utf8"),"utf8")}let _={skillId:o.skillId,skillName:o.skillName,relPath:m,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 fe.info("skill installed",{agentId:e,skillId:o.skillId,skillName:o.skillName,relPath:m,source:l?"content":"downloadUrl"}),_}function wo(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 vy(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 Sy(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 w0(t,e){let r=await Ee(t,e);if(!r)return{status:"skipped",count:0};if(r.disconnectedAt)return{status:"skipped",count:0};let i=Ot,o=r.skillsRefreshedForVersion;if(o===i)return{status:"noop",count:0};if(!o)return r.skillsRefreshedForVersion=i,await Fe(r,e),{status:"seeded",count:0};let c=[...r.skills??[]],l=new Map(c.map((m,v)=>[m.skillId,v])),u=c.filter(m=>m.builtin===!0&&!!m.downloadUrl);if(u.length===0)return r.skillsRefreshedForVersion=i,await Fe(r,e),{status:"noop",count:0};let f=0,x=0,{base:p}=Rr(r.framework,t,r.workspace,e);for(let m of u)try{await rl($e(p,m.relPath),{recursive:!0,force:!0});let v=await mo({agentId:t,workspace:r.workspace,framework:r.framework,skill:Sy(m),...e?{paths:e}:{}});wo(c,l,v),f+=1}catch(v){x+=1,fe.warn("refresh builtin skill failed (skipping)",{agentId:t,skillId:m.skillId,skillName:m.skillName,err:String(v)})}return r.skills=c,x===0&&(r.skillsRefreshedForVersion=i),await Fe(r,e),fe.info("builtin skills refreshed after bridge upgrade",{agentId:t,from:o,to:i,ok:f,failed:x}),{status:"refreshed",count:f}}async function Iy(t){if(!t)throw new T("IPC_BAD_REQUEST","skill missing downloadUrl");if(t.startsWith("data:")){let e=Math.floor(t.length*3/4);Ui(e);let r=Ay(t);return Ui(r.length),r}if(t.startsWith("file:")){let e=new URL(t).pathname,r=await po(e);return Ui(r.length),r}if(Oi(t)){let e=new AbortController,r=setTimeout(()=>e.abort(),by);try{let i=await fetch(t,{signal:e.signal});if(!i.ok)throw new T("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 T("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${t.slice(0,80)}`)}function Ui(t){if(t>Ey)throw new T("IPC_BAD_REQUEST",`skill too large: ${t} bytes`)}function Ay(t){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(t);if(!e)throw new T("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 Ty(t){return t.length>=2&&t[0]===31&&t[1]===139}function ky(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 ol(t){return t==="__MACOSX"||t.startsWith("__MACOSX/")}async function Cy(t,e){let r,i;try{r=new cl.default(t),i=r.getEntries()}catch(l){throw new T("IPC_BAD_REQUEST",`zip parse failed: ${l.message}`,{cause:l})}for(let l of i){let u=l.entryName;if(!u||ol(u))continue;if(u.startsWith("/")||/^[A-Za-z]:[\\/]/.test(u))throw new T("IPC_BAD_REQUEST",`zip entry absolute path: ${u}`);if(u.split(/[/\\]/).some(x=>x===".."))throw new T("IPC_BAD_REQUEST",`zip entry contains '..' (traversal): ${u}`);let f=l.header.attr>>>16&61440;if(f!==0&&f!==32768&&f!==16384)throw new T("IPC_BAD_REQUEST",`zip entry kind 0x${f.toString(16)} not allowed (symlink/hardlink/special): ${u}`)}let o=Ry(i),c=sl(e);for(let l of i){if(ol(l.entryName))continue;let u=l.entryName;if(o&&u.startsWith(o)&&(u=u.slice(o.length)),!u)continue;let f=sl(e,u),x=al(c,f);if(x.startsWith("..")||x==="..")throw new T("IPC_BAD_REQUEST",`zip entry escapes destDir: ${u}`);if(l.isDirectory){await nl(f,{recursive:!0});continue}await nl(dy(f),{recursive:!0});let p;try{p=l.getData()}catch(m){throw new T("IPC_BAD_REQUEST",`zip entry getData failed (${l.entryName}): ${m.message}`,{cause:m})}await il(f,p)}}function Ry(t){let e;for(let r of t){let i=r.entryName;if(!i||ol(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 Py(t,e){await Dy(t);let r=Mf({cwd:e,strip:1}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new T("IPC_BAD_REQUEST",`tar extract timeout (${Pr}ms)`))},Pr);try{await x0(h0.from(t),r)}catch(c){throw c instanceof T?c:i?new T("IPC_BAD_REQUEST",`tar extract timeout (${Pr}ms)`):new T("IPC_BAD_REQUEST",`tar extract failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}}async function Dy(t){let e=[],r=Ar({onReadEntry:c=>{let l=c.path,u=c.type;if(u!=="File"&&u!=="Directory"){e.push(`tar entry kind '${u}' not allowed (symlink/hardlink/special): ${l.slice(0,100)}`);return}if(l.startsWith("/")||l.startsWith("\\")||/^[a-zA-Z]:[\\/]/.test(l)){e.push(`tar entry absolute path: ${l}`);return}l.split(/[/\\]/).some(x=>x==="..")&&e.push(`tar entry contains '..': ${l}`)}}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new T("IPC_BAD_REQUEST",`tar list timeout (${Pr}ms)`))},Pr);try{await x0(h0.from(t),r)}catch(c){throw i?new T("IPC_BAD_REQUEST",`tar list timeout (${Pr}ms)`):new T("IPC_BAD_REQUEST",`tar list failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}if(e.length>0)throw new T("IPC_BAD_REQUEST",e[0]??"tar entry validation failed")}var Oy=5e3;async function Ly(t,e,r,i){return _0(t,e,r,i,{count:0})}async function _0(t,e,r,i,o){if(i<=0)return[];let c;try{c=await u0(e,{withFileTypes:!0})}catch{return[]}let l=[];for(let u of c){if(xy.has(u.name)||u.isSymbolicLink())continue;if(o.count>=Oy){l.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let f=$e(e,u.name),x=uy($e(r,u.name)),p=null;try{p=await tl(f)}catch{continue}if(p.isSymbolicLink())continue;o.count++;let m={name:u.name,path:y0(al(t,f)),isDir:p.isDirectory(),size:p.size,modifiedAt:Math.floor(p.mtimeMs)};p.isDirectory()&&i>1&&(m.children=await _0(t,f,x,i-1,o)),l.push(m)}return l.sort((u,f)=>u.isDir!==f.isDir?u.isDir?-1:1:u.name.localeCompare(f.name)),l}function Ny(t){return!t||t<=0?fy:Math.min(t,hy)}function My(t){if(!t||t==="."||t==="/")return".";let e=t.split(/[/\\]/);return e[e.length-1]||"."}function y0(t){return t.split(f0).join("/")}te();var En=H("agent-health-reporter"),By=1e4,Fy=3,Hi=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??By,this.livenessFailureThreshold=e.livenessFailureThreshold??Fy}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()}),En.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),En.info("heartbeat stopped"))}async tick(){if(this.inFlight){En.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){this.consecutiveFailures=0,En.debug("deviceId not available, skip tick (\u5C1A\u672A pair)");return}this.inFlight=!0;try{let r=[];for(let l of this.opts.core.agents.values()){let u=zy(l);if(!u)continue;let f={agentId:l.agentId,status:u};l.patToken&&(f.patToken=l.patToken),l.accountId&&(f.accountId=l.accountId),r.push(f)}if(r.length===0){this.consecutiveFailures=0;return}let i={agents:r,bridgeVersion:Ot,_meta:{cozeDeviceId:e}},o;try{o=await this.opts.core.sendRequest("_agent/health",i,5e3),this.consecutiveFailures=0}catch(l){this.consecutiveFailures+=1,En.warn("heartbeat batch send failed",{count:r.length,consecutiveFailures:this.consecutiveFailures,err:String(l)})}let c=o?.authFailures;if(c&&c.length>0&&(En.warn("heartbeat received authFailures from cloud",{count:c.length,agentIds:c.map(l=>l.agentId)}),this.opts.onAuthFailures))try{await this.opts.onAuthFailures(c)}catch(l){En.warn("onAuthFailures callback failed (ignored)",{err:String(l)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(r){En.warn("onTickEnd hook failed",{err:String(r)})}}};function zy(t){return t.status==="error"?"error":t.activeTriggers.size>0?"busy":t.status==="ok"?"online":null}Ht();import{mkdir as fl,rm as Db,stat as Ob}from"node:fs/promises";import{homedir as Lb}from"node:os";import{join as xl}from"node:path";an();import{existsSync as Zy}from"node:fs";import{release as Yy}from"node:os";import{basename as Xy,isAbsolute as Qy}from"node:path";function Gi(t,e,r){return r===void 0?{jsonrpc:"2.0",id:t,method:e}:{jsonrpc:"2.0",id:t,method:e,params:r}}function Dr(t,e){return e===void 0?{jsonrpc:"2.0",method:t}:{jsonrpc:"2.0",method:t,params:e}}function Or(t,e){return{jsonrpc:"2.0",id:t,result:e}}function vn(t,e){return{jsonrpc:"2.0",id:t,error:e}}We();var _o=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 b0(t){return"method"in t&&"id"in t&&t.id!==void 0}function E0(t){return"method"in t&&!("id"in t)}function yo(t){return!("method"in t)&&"id"in t}var Uy={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 Hy(t){if(t!=null)return t instanceof Error?{name:t.name,message:qi(t.message)}:typeof t=="string"?qi(t):typeof t=="object"?qy(t):t}var Gy=[[/\/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 Gy)e=e.replace(r,i);return e}function qy(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 T){let e=Hy(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:Uy[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 v0(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:l,...u}=e;c=u}return new T(r,o,{retriable:e?.retriable??!1,cause:c})}function I0(t){return`${JSON.stringify(t)}
|
|
100
|
-
`}var S0=10*1024*1024,
|
|
101
|
-
`);this.buffer=r.pop()??"";let i=[];for(let o of r){let c=o.replace(/\r$/,"").trim();if(c)try{i.push(JSON.parse(c))}catch(
|
|
102
|
-
`).map(o=>Number.parseInt(o.trim(),10)).filter(o=>Number.isFinite(o)&&o>0&&o!==i)}async function D0(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,l=e?.pollMs??100;for(let u of t)r(u,"SIGTERM");for(let u=0;u<c&&t.some(f=>i(f));u+=l)await o(Math.min(l,c-u));for(let u of t)i(u)&&r(u,"SIGKILL")}var Jy=[{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:"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|agentclientprotocol)\/codex-acp|optional dependency was not installed|\.resolve is not a function/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[^\n]*node_modules[\\/]@(agentclientprotocol[\\/](claude-agent-acp|codex-acp)|zed-industries[\\/]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 O0(t,e){if(!e)return null;for(let r of Jy)if(!(r.frameworks&&!r.frameworks.includes(t))&&r.match.test(e))return{bridgeCode:r.bridgeCode,reason:r.reason,message:r.message};return null}function L0(t,e){return O0(t,e)}function N0(t,e){return O0(t,e)}function Mr(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 M0(t,e,r){let o=r-t.armedAt-t.expectedIntervalMs;if(o>e.suspendThresholdMs){let x=t.suspendedMs+o,p=r-t.startedAt-x;return{action:"suspend",suspendedDeltaMs:o,rearmMs:Mr(p,t.firstFrameSeen,e)}}let c=r-t.startedAt-t.suspendedMs,l=t.awaitingApproval?e.approvalMaxMs:e.absoluteMaxMs;return c>=l?{action:"reject-backstop",awaitingApproval:t.awaitingApproval}:t.firstFrameSeen?c<e.phase2GateMs?{action:"continue",rearmMs:Mr(c,!0,e)}:r-t.lastActivityAt<e.livenessWindowMs||t.hasActiveTool||t.awaitingApproval?{action:"continue",rearmMs:Mr(c,!0,e)}:{action:"reject-idle"}:e.firstUpdateMs>0&&c>=e.firstUpdateMs&&!t.awaitingApproval?{action:"reject-idle"}:{action:"continue",rearmMs:Mr(c,!1,e)}}var B0=Je("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),eb=200,tb=40,nb=Je("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),rb=Je("COZE_BRIDGE_SESSION_PROMPT_IDLE_MS",600*1e3),ib=Je("COZE_BRIDGE_SESSION_PROMPT_ABSOLUTE_MAX_MS",7200*1e3),sb=Je("COZE_BRIDGE_SUSPEND_THRESHOLD_MS",60*1e3),ob=Je("COZE_BRIDGE_SESSION_PROMPT_FIRST_UPDATE_MS",600*1e3),ab=Je("COZE_BRIDGE_SESSION_PROMPT_APPROVAL_MAX_MS",1440*60*1e3),F0=500;function cb(t){try{let e=JSON.stringify(t);return e===void 0||e.length<=F0?t:`${e.slice(0,F0)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function lb(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 z0(t){try{return Zy(t)}catch{return}}function db(t,e){return{platform:process.platform,osRelease:Yy(),code:t.code,errno:t.errno,syscall:t.syscall,errPath:t.path,command:e.command,commandExists:Qy(e.command)?z0(e.command):void 0,cwd:e.cwd,cwdExists:z0(e.cwd),envKeys:e.envKeys}}function ub(t,e){return`${t.message} [diag: platform=${e.platform} os=${e.osRelease} code=${e.code} errno=${e.errno} syscall=${e.syscall} cmd=${Xy(e.command)} cmdExists=${e.commandExists} cwdExists=${e.cwdExists} envKeys=${e.envKeys}]`}var ht=class{constructor(e){this.opts=e;this.log=H(`downstream.${this.constructor.name}`,this.opts.agentId),this.decoder=new bo({onError:r=>this.log.warn("decode line failed",{line:r.line})})}opts;child;decoder;pending=new Map;inflightAgentRequests=new Map;idAllocator=new Lr;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stopReason;stderrRing=[];now=Date.now;spawnEnv={};sanitizeEnv(e){return e}async start(){if(this.child)throw new T("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",r=jf(process.env,this.opts.agentEnvFile??J().agentEnvFile,this.opts.env,o=>this.sanitizeEnv(o));this.spawnEnv=r;let i=rt(this.opts.command,this.opts.args,{cwd:this.opts.cwd,env:r,stdio:["pipe","pipe","pipe"],detached:e});this.child=i,k0(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>eb&&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,C0(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,l=db(c,{command:this.opts.command,cwd:this.opts.cwd,envKeys:Object.keys(r).length});this.log.error("child error",{err:String(o),diag:l}),this.failAllPending(new T("AGENT_SPAWN_FAILED",ub(c,l),{cause:l}))}),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:ob,phase2GateMs:nb,livenessWindowMs:rb,absoluteMaxMs:ib,approvalMaxMs:ab,suspendThresholdMs:sb,...r};return this.call("session/prompt",e,B0,i)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(Dr("session/cancel",e))}setSessionMode(e){return this.call("session/set_mode",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(Or(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(vn(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=B0,o){if(!this.child||this.stopped)return Promise.reject(new T("AGENT_PROTOCOL_ERROR","downstream not started"));let c=this.idAllocator.next(e),l=Gi(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 p={resolve:f,reject:x,timer:null,method:e,promptTimeout:null};if(o){let m=this.now(),v={cfg:o,startedAt:m,lastActivityAt:m,firstFrameSeen:!1,activeToolCalls:new Set,suspendedMs:0,armedAt:m,expectedIntervalMs:Mr(0,!1,o),sessionId:u};p.promptTimeout=v;let _=()=>{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=M0(b,v.cfg,I),k=P=>{v.armedAt=I,v.expectedIntervalMs=P,p.timer=setTimeout(_,P)};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}:{}}),k(A.rearmMs);return}if(A.action==="continue"){k(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 T("AGENT_APPROVAL_TIMEOUT",`${e} awaiting permission timed out after ${v.cfg.approvalMaxMs}ms`):new T("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 T("AGENT_FRAME_IDLE_TIMEOUT",`${e} no progress within ${v.cfg.livenessWindowMs}ms`)))};p.timer=setTimeout(_,v.expectedIntervalMs)}else i>0&&Number.isFinite(i)&&(p.timer=setTimeout(()=>{this.pending.delete(c),this.log.warn("downstream call timeout",{id:c,method:e,timeoutMs:i}),x(new T("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i));this.pending.set(c,p);try{this.writeFrame(l)}catch(m){p.timer&&clearTimeout(p.timer),this.pending.delete(c),x(m)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new T("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(I0(e),r=>{r&&this.log.warn("stdin write callback err",{err:String(r)})})}dispatch(e){if(yo(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 T("AGENT_PROTOCOL_ERROR",`${r.method} response missing both result and error`))):(this.log.info("downstream returned result",{id:e.id,method:r.method,result:cb(e.result)}),r.resolve(e.result));return}if(E0(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(b0(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 l=typeof i.status=="string"?i.status:void 0,u=l==="completed"||l==="failed"||l==="cancelled";o==="tool_call"&&!u?e.activeToolCalls.add(c):u&&e.activeToolCalls.delete(c)}async handleAgentRequest(e){if(this.agentRequestHandlers.length===0){this.writeFrame(vn(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(vn(e.id,ji(i)))}catch{}this.inflightAgentRequests.delete(e.id)}}wireErrorToBridge(e){let r=v0(e);if(r.code!=="AGENT_PROTOCOL_ERROR")return r;let i=N0(this.framework,lb(e));return i?new T(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 T("AGENT_TURN_ABORTED",`turn aborted: ${this.stopReason}`,{cause:{reason:this.stopReason}});let i=this.getStderrTail(tb).join(`
|
|
103
|
-
`),o=L0(this.framework,i);return o?new T(o.bridgeCode,o.message,{cause:{reason:o.reason,code:e,signal:r,stderrTail:i}}):new T("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 fb(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 Eo=class extends ht{framework="claude-code";constructor(e){let{command:r,args:i}=ri("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 fb(e)}};an();import{mkdtempSync as gb,rmSync as mb}from"node:fs";import{tmpdir as wb}from"node:os";import{join as _b}from"node:path";import{readFileSync as H0}from"node:fs";import{homedir as hb}from"node:os";import{join as U0}from"node:path";function G0(t){let e=t.CODEX_HOME?.trim()||U0(t.HOME?.trim()||hb(),".codex");return U0(e,"config.toml")}function xb(t){let e=null;for(let r=0;r<t.length;r++){let i=t[r];if(e)i===e&&(e=null);else if(i==='"'||i==="'")e=i;else if(i==="#")return t.slice(0,r)}return t}function pb(t){let e=t.trim();if(e.length>=2){let r=e[0];if((r==='"'||r==="'")&&e[e.length-1]===r)return e.slice(1,-1)}return e}function q0(t){let e={},r={},i=e;for(let o of t.split(/\r?\n/)){let c=xb(o).trim();if(!c)continue;let l=/^\[([^\]]+)\]$/.exec(c);if(l){let x=(l[1]??"").trim(),p=r[x]??{};r[x]=p,i=p;continue}let u=c.indexOf("=");if(u<=0)continue;let f=c.slice(0,u).trim();f&&(i[f]=pb(c.slice(u+1)))}return{root:e,tables:r}}function j0(t){let e=t.root.model_provider;if(!e||e==="openai")return null;let r=t.tables[`model_providers.${e}`];return r?{providerId:e,baseUrl:r.base_url,envKey:r.env_key,bearerToken:r.experimental_bearer_token}:null}function W0(t){let e;try{e=H0(G0(t),"utf8")}catch{return null}return j0(q0(e))?.providerId??null}function K0(t){let e;try{e=H0(G0(t),"utf8")}catch{return null}let r=j0(q0(e));if(!r?.baseUrl)return null;let i=r.bearerToken||(r.envKey?t[r.envKey]?.trim():void 0);return i?{baseUrl:r.baseUrl,providerName:r.providerId,headers:{Authorization:`Bearer ${i}`}}:null}var vo=class t extends ht{framework="codex";authRequest;resolveLocalGatewayAuth;codexHomeDir;constructor(e){let r=e.args??[],i=e.extraArgs?[...r,...e.extraArgs]:r,{command:o,args:c}=ri("codex",e.command,i),l=e.isolateCodexHome?gb(_b(wb(),"coze-bridge-codex-home-")):void 0,u=l?{...e.env??{},CODEX_HOME:l}:e.env,f={command:o,args:c,cwd:e.cwd,agentId:e.agentId,...u?{env:u}:{}};super(f),this.authRequest=e.authRequest,this.resolveLocalGatewayAuth=e.resolveLocalGatewayAuth??!1,this.codexHomeDir=l}async initialize(e){let r=await super.initialize(e),i=this.authRequest??this.localGatewayAuthRequest();return i&&await this.call("authenticate",i),r}localGatewayAuthRequest(){if(!this.resolveLocalGatewayAuth)return null;let e=K0(this.spawnEnv);return e?(this.log.info("codex local: \u7528 config.toml custom provider \u8D70 gateway \u8BA4\u8BC1",{providerName:e.providerName,baseUrl:e.baseUrl}),{methodId:"gateway",_meta:{gateway:e}}):null}static MODE_ID_MAP={"read-only":"read-only",auto:"agent","full-access":"agent-full-access"};setSessionMode(e){let r=t.MODE_ID_MAP[e.modeId]??e.modeId;return super.setSessionMode({...e,modeId:r})}async stop(e){if(await super.stop(e),this.codexHomeDir)try{mb(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var So=class extends ht{framework="hermes";constructor(e){let r={command:e.command,args:[],cwd:e.cwd,agentId:e.agentId,...e.env?{env:e.env}:{}};super(r)}};We();var yb=3e4,Br=class extends ht{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}`}]},yb))}get acpSessionName(){return this.sessionName}setSessionMode(e){return Promise.reject(new T("METHOD_NOT_FOUND","session/set_mode not supported on openclaw"))}};var $0=["default","acceptEdits","plan","auto","bypassPermissions"],V0=["read-only","auto","full-access"],J0=["default","accept_edits","dont_ask"];function Sn(t,e){if(typeof e!="string")return!1;switch(t){case"claude-code":return $0.includes(e);case"codex":return V0.includes(e);case"hermes":return J0.includes(e);case"openclaw":return!1}}function dl(t){switch(t){case"claude-code":return $0.join("/");case"codex":return V0.join("/");case"hermes":return J0.join("/");case"openclaw":return""}}Ut();We();te();Ce();function ul(t){return t.replace(/[^A-Za-z0-9._-]+/g,"-")}an();var In=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 Io=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 In,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 Jt(t){return t.framework==="hermes"?!0:t.deployType!=="local"?!1:t.framework==="claude-code"||t.framework==="codex"}Vt();te();import{constants as Z0}from"node:fs";import{access as bb,readFile as Eb}from"node:fs/promises";import{delimiter as vb,dirname as Sb,join as Y0}from"node:path";var Qe=H("framework-detector"),X0={"claude-code":"claude",codex:"codex",openclaw:"openclaw",hermes:"hermes-acp"},Ib=[".exe",".cmd",".bat",".ps1"],$n=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??rt,access:e.access??bb,readFile:e.readFile??Eb}}async detect(e){let r=X0[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,l]=await Promise.all([this.probeVersion(i,o),e==="openclaw"?this.probeOpenclawDefaultAgent(i):Promise.resolve(null)]),u={path:i,version:c};return l&&(u.defaultAgent=l),u}async detectAll(){let e=await Promise.all(Object.keys(X0).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(vb).filter(Boolean),i=this.env.platform==="win32"?["",...Ib]:[""];for(let o of r)for(let c of i){let l=Y0(o,e+c);if(await this.isExecutable(l))return l}return null}async isExecutable(e){try{let r=this.env.platform==="win32"?Z0.F_OK:Z0.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(l){return Qe.debug("hermes shim fallback: readFile failed",{hermesPath:e,err:String(l)}),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=Y0(Sb(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(l=>l?.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 l=JSON.parse(c[0]);typeof l.gateway?.port=="number"&&(o.port=l.gateway.port),typeof l.service?.runtime?.status=="string"&&(o.runtime=l.service.runtime.status),!i&&typeof l.rpc?.error=="string"&&(o.detail=l.rpc.error)}catch(l){Qe.warn("openclaw gateway probe: JSON.parse failed (detail omitted, gate by exit code)",{path:e,err:String(l)})}return o}async probeVersion(e,r=[]){let i=await this.runProbe(e,[...r,"--version"]);return i&&(Tb(i.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,r){return new Promise(i=>{let o="",c=!1,l,u=f=>{c||(c=!0,l&&clearTimeout(l),i(f))};try{let f=this.env.spawn(e,r,{stdio:["ignore","pipe","pipe"]});l=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)}})}},Ab=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function Tb(t){return t.replace(Ab,"")}import{homedir as kb}from"node:os";import{join as Cb}from"node:path";Ut();Vt();ir();We();te();async function th(){let t=Cb(kb(),".openclaw/openclaw.json");return(await cr(t))?.gateway?.auth?.token??""}var Q0=H("openclaw.config"),Rb=[0,5e3,5e3],Pb=Je("COZE_BRIDGE_OPENCLAW_CLI_TIMEOUT_MS",15e3),eh="models.providers.",Ao="agents.defaults.models",To=class{command;env;retryDelaysMs;cliTimeoutMs;queue=new In;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??Rb,this.cliTimeoutMs=e.cliTimeoutMs??Pb}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(l=>setTimeout(l,c));try{return await r()}catch(l){i=l,Q0.warn("openclaw cli failed, will retry",{label:e,attempt:o+1,err:String(l)})}}throw new T("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${i?.message??"unknown"}`)}runCli(e){return new Promise((r,i)=>{let o=rt(this.command,e,{stdio:["ignore","ignore","pipe"],env:this.env}),c="",l=!1,u=x=>{l||(l=!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.runCli(["config","unset",r])))}catch(i){Q0.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",`${eh}${e}`,JSON.stringify(r),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${eh}${e}`)}addModelToAllowlist(e,r){let i={[e]:r?{alias:r}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${Ao}[${e}]`,()=>this.runCli(["config","set",Ao,JSON.stringify(i),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${Ao}[${e}]`,`${Ao}.${e}`)}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 de=H("agent-manager"),pl="acceptEdits",ih="full-access",sh="read-only";function Nb(t){switch(t){case"read-only":return"read-only";case"auto":return"agent";case"full-access":return"agent-full-access"}}var Mb=(t,e,r,i,o,c,l,u,f,x)=>{switch(t){case"claude-code":{let p={...o?{...Yf(o),...e0(o,l,u)}:{},...f??{},IS_SANDBOX:"1"};return new Eo({cwd:r,env:p,agentId:i})}case"codex":{let p=ih;x!==void 0&&(Sn("codex",x)?p=x:de.warn("codex spawn: invalid codexPermissionMode, falling back to full-access",{agentId:i,received:x}));let m=o?null:W0(process.env),v={...o?Qf(o):{},INITIAL_AGENT_MODE:Nb(p),...process.env.COZE_BRIDGE_CODEX_APP_SERVER_LOGS==="1"?{APP_SERVER_LOGS:xl(r,"..","logs","codex-app-server")}:{},...m?{MODEL_PROVIDER:m}:{},...f??{}},_=o?Xf(o,l,u):null,b=_?{methodId:"gateway",_meta:{gateway:_}}:void 0,I=!!o,A=!I&&process.env.COZE_BRIDGE_CODEX_LOCAL_GATEWAY_AUTH==="1";return new vo({cwd:r,agentId:i,...Object.keys(v).length>0?{env:v}:{},...b?{authRequest:b}:{},...I?{isolateCodexHome:!0}:{},...A?{resolveLocalGatewayAuth:!0}:{}})}case"openclaw":return new Br({command:e,cwd:r,agentId:i,...c?{sessionName:ul(c)}:{}});case"hermes":return new So({command:e,cwd:r,agentId:i,...f&&Object.keys(f).length>0?{env:{...f}}:{}})}};function hl(t){return t==="claude-code"||t==="codex"}var Bb={path:"",version:"cloud-deployed"},nh="openclaw_gateway_unavailable",Fb="openclaw_default_agent_missing";function rh(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 zb={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},Ub=6e4,ko=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??Mb,this.createTimeoutMs=e.createTimeoutMs??Ub,this.detectorFactory=e.detectorFactory??(()=>new $n),this.openclawConfigFactory=e.openclawConfigFactory??(r=>new To({command:r})),this.openclawConfigDir=e.openclawConfigDir??xl(Lb(),".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 T("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=>{de.warn("openclaw env bootstrap failed (ignored)",{err:String(e)}),this.openclawEnvBootstrapPromise=void 0}),this.openclawEnvBootstrapPromise)}async doBootstrapOpenclawEnv(){let e=this.openclawConfigDir,r=xl(e,".env");if(await Ob(r).then(c=>c.isFile()).catch(()=>!1)){de.debug("openclaw .env exists, skip bootstrap",{envFile:r});return}let o=Ni({...process.env,...Li(this.paths.agentEnvFile)});await lt(r,o,{mode:384}),de.info("openclaw .env bootstrapped",{envFile:r,bytes:o.length}),await this.getOpenclawConfig().restartGateway(),de.info("openclaw gateway restarted after env bootstrap")}async createAgent(e,r){if(!e.agentId)throw new T("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new T("IPC_BAD_REQUEST","framework required");let i=await Ee(e.agentId,this.paths).catch(()=>null),o=lo(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 T("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${c.framework})`);if(c.status==="error")de.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await c.dispose("rebuild after error").catch(k=>de.warn("dispose stale agent failed (ignored)",{err:String(k)})),this.registry.unregister(e.agentId);else if(o&&c.deployType!=="cloud")de.warn("existing agent deployType drifted to local, rebuilding as cloud",{agentId:e.agentId}),await c.dispose("rebuild after deployType drift").catch(k=>de.warn("dispose drifted agent failed (ignored)",{err:String(k)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==c.patToken){de.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),c.setPatToken(e.patToken);let k=await Ee(e.agentId,this.paths).catch(()=>null);k&&(k.patToken=e.patToken,await Fe(k,this.paths))}if(c.deployType==="cloud"&&e.modelInfo){de.info("updating agent modelInfo on re-create",{agentId:e.agentId}),c.setModelInfo(e.modelInfo);let k=await Ee(e.agentId,this.paths).catch(()=>null);k&&(k.modelInfo=e.modelInfo,await Fe(k,this.paths))}return de.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 P=e.framework==="hermes"?"; install with `pipx install hermes-agent` and rerun daemon to refresh frameworks_cache":"; rerun daemon to refresh frameworks_cache";throw new T("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine${P}`)}let u=Be(e.agentId,this.paths),f=o?"cloud":"local",x=e.framework==="openclaw"&&f==="local",p;x&&!r?.revive&&(p=(await this.ensureOpenclawDefaultAgent()).workspace,await this.ensureOpenclawGatewayReachable());let m=p??(x?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0),v=e.workspace??m??u.workspace,_=new AbortController,b=setTimeout(()=>_.abort(new T("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),I,A=!1;try{o&&hl(e.framework)&&await ar(e.framework,_.signal);let k=()=>{if(_.signal.aborted)throw _.signal.reason instanceof Error?_.signal.reason:new T("AGENT_TIMEOUT","_agent/create aborted")};await fl(u.root,{recursive:!0}),await fl(v,{recursive:!0}),await fl(u.logs,{recursive:!0}),k(),x||await dr(v,e.framework,e.cozeIdentity),e.framework==="claude-code"&&(f==="cloud"?await Fa(v,"cloud"):await Fa(v,"local",pl)),k();let P=i,y=Zf({model:e.model??P?.model}),R=Ff(e._meta)??P?.accountId,O=e.patToken??P?.patToken,F=f==="cloud"?e.modelInfo??P?.modelInfo:void 0;if(I=new Io({agentId:e.agentId,framework:e.framework,workspace:v,model:y.model??vt,deployType:f,...R?{accountId:R}:{},...O?{patToken:O}:{},...F?{modelInfo:F}:{}}),I.status="ok",P?.sessions){let $=e.framework==="hermes"||f==="local"&&(e.framework==="claude-code"||e.framework==="codex");for(let[Y,se]of Object.entries(P.sessions)){let oe={acpSessionId:se.acpSessionId,modelToken:se.modelToken,tokenGeneratedAt:se.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};$?se.permissionMode===void 0?(oe.permissionMode=e.framework==="claude-code"?"bypassPermissions":e.framework==="codex"?"full-access":"default",de.info("autoRevive: legacy session (no permissionMode) \u2192 fallback to D80/D84 default",{agentId:e.agentId,cloudId:Y,framework:e.framework,fallback:oe.permissionMode})):Sn(e.framework,se.permissionMode)?oe.permissionMode=se.permissionMode:de.warn("autoRevive: dropping invalid persisted permissionMode",{agentId:e.agentId,cloudId:Y,framework:e.framework,value:se.permissionMode}):se.permissionMode!==void 0&&de.info("autoRevive: dropping persisted permissionMode (gate disabled)",{agentId:e.agentId,cloudId:Y,framework:e.framework,deployType:f}),se.cozeGroupId&&(oe.cozeGroupId=se.cozeGroupId),I.sessions.set(Y,oe)}let ne=Object.keys(P.sessions).length;ne>0&&de.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:ne})}this.registry.register(I),A=!0;let M={agentId:e.agentId,framework:e.framework,workspace:v,cozeIdentity:e.cozeIdentity,createdAt:P?.createdAt??Date.now(),sessions:P?.sessions??{},model:y.model};f==="cloud"&&(M.deployType="cloud"),R&&(M.accountId=R),O&&(M.patToken=O),F&&(M.modelInfo=F),P?.skills&&(M.skills=P.skills),P?.agentName&&(M.agentName=P.agentName),P?.description&&(M.description=P.description),M.skillsRefreshedForVersion=P?.skillsRefreshedForVersion??Ot,e.framework==="openclaw"&&f==="cloud"&&(this.config.frameworksCache?.openclaw?.path?(await this.bootstrapOpenclawEnvIfNeeded(),await this.getOpenclawConfig().ensureAgent(e.agentId,v)):de.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 $=[...M.skills??[]],ne=new Map($.map((oe,C)=>[oe.skillId,C])),Y=await Promise.allSettled(V.map(oe=>mo({agentId:e.agentId,workspace:v,framework:e.framework,skill:oe,paths:this.paths}))),se=0;for(let[oe,C]of Y.entries()){let U=V[oe];U&&(C.status==="fulfilled"?(wo($,ne,C.value),se++):de.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:U.skillId,skillName:U.skillName,err:String(C.reason)}))}se>0&&(M.skills=$,de.info("initialSkills installed",{agentId:e.agentId,installed:se,requested:V.length}))}return await Fe(M,this.paths),de.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(k){throw de.error("agent create failed, rolling back",{agentId:e.agentId,err:String(k)}),A&&I&&(await I.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await Db(u.root,{recursive:!0,force:!0}).catch(P=>de.warn("rm agent dir failed (ignored)",{err:String(P)})),k instanceof T?k:new T("AGENT_SPAWN_FAILED",String(k),{cause:k})}finally{clearTimeout(b)}}async spawnSessionDownstream(e,r,i,o,c){let u=this.config.frameworksCache?.[e.framework];if(!u)if(e.deployType==="cloud"&&hl(e.framework))u=Bb;else throw e.framework==="hermes"?new T("AGENT_SPAWN_FAILED","hermes-acp not detected on this machine; install with `pipx install hermes-agent` and rerun daemon to refresh frameworks_cache"):new T("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);hl(e.framework)&&!gs(e.framework)&&(de.info("spawn: resolving acp wrapper",{agentId:e.agentId,framework:e.framework}),await ar(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 p={...this.buildBinShimPathEnv()};f&&(await a0({paths:this.paths,agentId:e.agentId,modelConfig:f,cozeEnv:o,mockScenario:c}),p.HERMES_HOME=Kn(e.agentId,this.paths)),x=this.factory(e.framework,u.path,e.workspace,e.agentId,f,i,o,c,p)}else{let p=e.sessions.get(i),m=Jt(e)?p?.permissionMode??ih:"full-access";x=this.factory(e.framework,u.path,e.workspace,e.agentId,f,i,o,c,this.buildBinShimPathEnv(),m)}try{return await x.start(),await x.initialize(zb),x}catch(p){let m=x instanceof ht?x.getStderrTail():[];throw m.length>0&&de.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:p instanceof T?p.code:"unknown",recentStderr:m}),await x.stop("spawnSessionDownstream failed").catch(()=>{}),await this.resolveSpawnFailure(e,u.path,p)}}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 T("AGENT_ENV_NOT_READY",rh(o),{cause:{reason:nh}})}catch(o){de.warn("openclaw gateway diagnose failed (ignored, fall through to original error)",{agentId:e.agentId,err:String(o)})}return i instanceof T?i:new T("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};de.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 de.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 T("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:Fb}})}async ensureOpenclawGatewayReachable(){let e=this.config.frameworksCache?.openclaw?.path;if(!e)throw new T("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");let r=await this.detectorFactory().probeOpenclawGateway(e);if(!r.reachable)throw new T("AGENT_ENV_NOT_READY",rh(r),{cause:{reason:nh}})}async buildOpenclawDownstream(e){let{session:r,modelConfig:i,cloudSessionId:o,cozeEnv:c,mockScenario:l,command:u}=e,f=ul(o);if(r.deployType==="local"){let v=await this.ensureOpenclawDefaultAgent();return new Br({command:u,cwd:v.workspace,agentId:v.id,sessionName:f})}let x=await th(),p=i?t0(i,c,l):null,m;if(p){let v=Yc(o),b=p.models[0]?.id??vt,I=`${v}/${b}`;if(!this.ensuredProviders.has(I)){let A=this.getOpenclawConfig();await A.ensureProvider(v,p),await A.addModelToAllowlist(I),this.ensuredProviders.add(I)}m=I}return new Br({command:u,cwd:r.workspace,agentId:r.agentId,sessionName:f,...x?{gatewayToken:x}:{},...m?{slashModelOnStart:m}:{}})}async openclawRepair(e,r){let i=this.getOpenclawConfig();await i.deleteAgent(e),await i.ensureAgent(e,r)}async cleanupOpenclawSessionProviders(e){if(e.framework!=="openclaw"||!this.openclawConfigCache)return;let r=this.openclawConfigCache;for(let i of e.sessions.keys()){let o=Yc(i),c=`${o}/${e.model}`,l=!0;try{await r.removeProvider(o)}catch(u){l=!1,de.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:o,err:String(u)})}try{await r.removeModelFromAllowlist(c)}catch(u){l=!1,de.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:c,err:String(u)})}l&&this.ensuredProviders.delete(c)}}};import{randomUUID as dh}from"node:crypto";import{promises as $b}from"node:fs";import{basename as uh}from"node:path";We();te();import{promises as Hb}from"node:fs";import{basename as Gb}from"node:path";var oh=H("file-upload"),qb="/api/coze_claw/file/agent_upload",jb=6e4;async function ah(t,e={}){let i=`${kr(Cr(e.handshakeBase))}${qb}`,o=e.timeoutMs??jb,c=await Hb.readFile(t.path),l=new FormData;l.append("agent_id",t.agentId),l.append("session_id",t.sessionId),l.append("file_name",t.name),l.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",...bn(e.ppeOverride),...t.accountId?{"x-coze-account":t.accountId}:{}},f=new AbortController,x=setTimeout(()=>f.abort(),o);oh.info("file upload start",{url:i,agentId:t.agentId,sessionId:t.sessionId,name:t.name,bytes:t.sizeBytes,mime:t.mimeType});try{let p=await fetch(i,{method:"POST",headers:u,body:l,signal:f.signal}),m=p.headers.get("x-tt-logid")??"";if(!p.ok){let b=await p.text().catch(()=>"");throw new T("UPLOAD_FAILED",`upload HTTP ${p.status} logid=${m}: ${b.slice(0,200)}`)}let v=await p.json();if(v.code!==void 0&&v.code!==0)throw new T("UPLOAD_FAILED",`upload code=${v.code} msg=${v.msg??"-"} logid=${m}`);let _=v.data?.file?.file_url;if(!_)throw new T("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${m}: ${JSON.stringify(v).slice(0,200)}`);return oh.info("file upload ok",{uri:_,logid:m}),{uri:_}}catch(p){throw p instanceof T?p:p.name==="AbortError"?new T("UPLOAD_FAILED",`upload timeout (${o}ms) for ${Gb(t.path)}`):new T("UPLOAD_FAILED",String(p),{cause:p})}finally{clearTimeout(x)}}We();te();import{extname as Wb}from"node:path";var Kb={".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 ch(t){let e=Wb(t).toLowerCase();return Kb[e]??"application/octet-stream"}Ce();var Co=H("agent-send"),lh=50*1024*1024;function fh(t,e,r){let i=t.get(e);if(!i)throw new T("AGENT_NOT_FOUND",`agent=${e}`);if(t.disconnectedAgents.has(e))throw new T("AGENT_DISCONNECTED",`agent=${e} was disconnected by cloud`);let o=i.sessions.get(r);if(!o)throw new T("AGENT_NOT_FOUND",`session=${r} not active in agent=${e}`);return{session:i,runtime:o}}async function hh(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&&(Co.warn("sendAgentFileUpdate failed, retrying",{attempt:f+1,err:String(x)}),await new Promise(p=>setTimeout(p,5e3)))}throw new T("UPSTREAM_NOT_READY",`${c} after 3 attempts: ${String(u)}`,{cause:u})}async function xh(t,e){let{session:r,runtime:i}=fh(e.core,t.agentId,t.sessionId);if(!await ii(t.path,r.workspace))throw new T("PATH_OUTSIDE_WORKSPACE",`path=${t.path} not under workspace=${r.workspace}`);let o=await $b.stat(t.path).catch(()=>null);if(!o||!o.isFile())throw new T("IPC_BAD_REQUEST",`path is not a regular file: ${t.path}`);if(o.size>lh)throw new T("FILE_TOO_LARGE",`${o.size} bytes > limit ${lh}`);let c=await ch(t.path);if(t.kind==="image"&&!c.startsWith("image/"))throw new T("UNSUPPORTED_MIME",`kind=image but mime=${c}`);if(!e.core.upstream.isConnected())throw new T("UPSTREAM_NOT_READY","cloud WS not connected");let l=t.name??uh(t.path),u;try{u=await ah({patToken:r.patToken??e.patToken,agentId:t.agentId,sessionId:t.sessionId,path:t.path,mimeType:c,name:l,sizeBytes:o.size,...r.accountId?{accountId:r.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride})}catch(x){throw Co.warn("agent file upload failed",{agentId:t.agentId,sessionId:t.sessionId,path:t.path,sizeBytes:o.size,mime:c,code:x instanceof T?x.code:"UNKNOWN",message:x instanceof Error?x.message:String(x)}),x}let f={sessionUpdate:"agent_file",messageId:dh(),content:{type:t.kind==="image"?"image":"resource",uri:u.uri,mimeType:c,name:l,sizeBytes:o.size,...u.fileId!==void 0?{fileId:u.fileId}:{},...t.caption!==void 0?{caption:t.caption}:{}}};return await hh(e,r,i,t.sessionId,f,"agent file uploaded to cloud but sendAgentFileUpdate failed"),Co.info("agent file sent",{agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,name:l,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 ph(t,e){let{session:r,runtime:i}=fh(e.core,t.agentId,t.sessionId);if(!t.mimeType)throw new T("IPC_BAD_REQUEST","group-file requires mimeType");if(!e.core.upstream.isConnected())throw new T("UPSTREAM_NOT_READY","cloud WS not connected");let o=t.name??uh(t.path),c={sessionUpdate:"group_file",messageId:dh(),content:{uri:t.path,name:o,mimeType:t.mimeType,...t.caption!==void 0?{caption:t.caption}:{}}};return await hh(e,r,i,t.sessionId,c,"agent group file sendAgentFileUpdate failed"),Co.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 gh(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 l=r[c]??0,u=i[c]??0;if(l<u)return!0;if(l>u)return!1}return!1}an();Vt();te();var Lt=H("coze-cli-installer"),mh="@coze/cli@latest",Vb="coze",wh="0.1.8",Jb=5e3,Zb=5e3,Yb=9e4,_h=1e4,Vi=null,Ro=!1;async function ml(t,e={}){if(Ro)return;if(Vi)return Vi;let r=e.exec??qf;return Vi=(async()=>{try{let i=await Xb(Vb,r),o=!1;if(i){let l=await Qb(r);if(l===void 0)Lt.warn("coze-cli found but version unparseable, fall through to full install",{path:i});else if(gh(l,wh))Lt.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:i,version:l,min:wh}),o=!0;else{Lt.info("coze-cli already on PATH with sufficient version, skip",{path:i,version:l}),Ro=!0;return}}let c=o?"upgrade-only":"full";Lt.info("coze-cli install start",{package:mh,mode:c});try{await r("npm",["i","-g","--prefer-online",mh],{timeout:Yb,maxBuffer:10*1024*1024}),Lt.info("coze-cli install ok")}catch(l){Lt.warn("coze-cli install failed (skip subsequent steps)",{err:String(l)});return}if(o){Ro=!0;return}if(t.env)try{await r("coze",["config","set","xTTEnv",t.env],{timeout:_h}),Lt.info("coze config set xTTEnv ok",{env:t.env})}catch(l){Lt.warn("coze config set failed (continue to auth login)",{err:String(l)})}try{await r("coze",["auth","login","--token",t.patToken],{timeout:_h}),Lt.info("coze auth login ok")}catch(l){Lt.warn("coze auth login failed",{err:String(l)});return}Ro=!0}finally{Vi=null}})(),Vi}async function Xb(t,e){let r=process.platform==="win32"?"where":"which";try{let{stdout:i}=await e(r,[t],{timeout:Jb});return Ma(i)}catch{return}}async function Qb(t){try{let{stdout:e,stderr:r}=await t("coze",["--version"],{timeout:Zb});return(e||r).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}Ht();Ut();Ce();var eE=10*6e4;function yh(t){let e=t?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?eE:e}function Po(t){return cr(t??J().configFile)}function Ji(t,e){return lr(e??J().configFile,t)}import{randomBytes as yE}from"node:crypto";ir();We();te();import{createReadStream as tE}from"node:fs";import{mkdir as nE,readFile as rE,realpath as iE,stat as sE,writeFile as oE}from"node:fs/promises";import{basename as aE,dirname as wl,isAbsolute as cE,join as lE,relative as dE,resolve as bh,sep as uE}from"node:path";import{createInterface as fE}from"node:readline";var vh=H("fs-rpc"),Zi=Je("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function Sh(t,e){let r=Buffer.byteLength(t.content,"utf8");if(r>Zi)throw new T("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${r} bytes > limit ${Zi} bytes`);let i=await Ah(t.path,e);return await nE(wl(i),{recursive:!0}),await oE(i,t.content,"utf8"),vh.info("fs/write_text_file ok",{path:i,size:t.content.length}),null}async function Ih(t,e){let r=await Ah(t.path,e),i=await sE(r),o=typeof t.line=="number"||typeof t.limit=="number";if(i.size>Zi&&!o)throw new T("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${i.size} bytes > ${Zi} bytes`);let c;if(o&&i.size>Zi)c=await hE(r,t.line??1,t.limit);else{let l=await rE(r,"utf8");if(o){let u=l.split(`
|
|
104
|
-
`),
|
|
105
|
-
`)}else c=
|
|
106
|
-
`)}async function Ah(t,e){if(typeof t!="string"||t.length===0)throw new T("IPC_BAD_REQUEST","path must be a non-empty string");let[r,i]=await Promise.all([Eh(bh(e)),Eh(bh(t))]),o=dE(r,i);if(xE(o,uE,cE(o)))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${t}`);return i}function xE(t,e,r){return t===""?!1:r?!0:t===".."||t.startsWith(`..${e}`)}async function Eh(t){let e=[],r=t;for(;r!==wl(r);)try{let i=await iE(r);return e.length?lE(i,...e.reverse()):i}catch{e.push(aE(r)),r=wl(r)}return t}te();var Th=H("prompt-multimodal"),kh=10*1024*1024,pE=15e3,gE=6;async function Ch(t){let e=new Array(t.length),r=0;async function i(){for(;r<t.length;){let c=r++,l=t[c];l!==void 0&&(e[c]=await mE(l))}}let o=Array.from({length:Math.min(gE,t.length)},()=>i());return await Promise.all(o),e}function Rh(t){return t.some(e=>e.type==="image")}async function mE(t){if(t.type!=="image")return t;let e=t;if(e.data||!e.uri||!Oi(e.uri))return t;try{let{buf:r,contentType:i}=await _E(e.uri),o=e.mimeType||wE(i)||"application/octet-stream";return Th.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 Th.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(r)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function wE(t){if(!t)return;let e=t.indexOf(";");return(e===-1?t:t.slice(0,e)).trim()||void 0}async function _E(t){let e=new AbortController,r=setTimeout(()=>e.abort(),pE);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>kh)throw new Error(`image too large: ${o.byteLength} bytes (max ${kh})`);return{buf:Buffer.from(o),contentType:i.headers.get("content-type")??void 0}}finally{clearTimeout(r)}}Ht();We();te();var K=H("core"),bE=3e4,EE=/^(boe|ppe)_[A-Za-z0-9_-]+$/,vE="\u6211\u6B63\u5728\u7B49\u5F85\u5BA1\u6279\uFF0C\u8BF7\u7A0D\u540E\u518D\u8054\u7CFB\u6211",SE="\u5BA1\u6279\u5DF2\u8D85\u65F6",IE=3e4,Do=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upstreamIds=new Lr;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=yh(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(),K.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){K.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),K.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let r of this.registerHandlers)try{r(e.agentId)}catch(i){K.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)&&K.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,l)=>{K.info("session runtime exited",{agentId:e.agentId,cloudId:r,code:c,signal:l}),$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){K.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(vn(o,{code:Z.INTERNAL_ERROR,message:`bridge downstream gone: ${r}`})).catch(l=>K.debug("send error response to upstream failed (ignored)",{err:String(l)}));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)){K.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 T("UPSTREAM_DISCONNECTED",`${i.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(yo(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&&EE.test(i)?this.currentCozeEnv=i:i&&K.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}`):K.warn("drop notification: extension not registered",{method:e.method});return}let c=await o(e,this);r!==null&&await this.upstream.send(Or(r,c));return}if(e.method.startsWith("session/")){let o=await this.routeSessionMethod(e);r!==null&&await this.upstream.send(Or(r,o));return}if(e.method==="initialize"){r!==null&&await this.upstream.send(Or(r,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}r!==null?await this.sendError(r,Z.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):K.warn("drop unknown notification",{method:e.method})}catch(o){K.error("handleFrame failed",{method:e.method,err:String(o)}),r!==null&&await this.upstream.send(vn(r,ji(o)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new T("IPC_BAD_REQUEST",`${e.method} requires params`);let r=e.params,i=r._meta?.cozeAgentId;if(!i)throw new T("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let o=this.agents.get(i);if(!o)throw this.disconnectedAgents.has(i)?new T("AGENT_DISCONNECTED",`agent ${i} has been disconnected; cloud must _agent/create to revive`):new T("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,p=uo(r._meta);return K.info("session in pendingPermission, bouncing new prompt",{agentId:o.agentId,cloudSessionId:c}),this.synthesizePromptReply(o,f,c,vE,x,p)}}let l=Date.now(),u=!1;try{let f=await o.getSessionQueue(c).enqueue(()=>this.dispatchSessionCall(o,e.method,r));return u=!0,f}finally{K.info("session call done",{agentId:o.agentId,method:e.method,durationMs:Date.now()-l,ok:u})}}async dispatchSessionCall(e,r,i){e.lastActiveAt=Date.now();let{stripped:o}=Uf(i);switch(r){case"session/new":{let c=AE();return K.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:c}),{sessionId:c}}case"session/load":{let c=o;return K.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:c.sessionId}),{}}case"session/prompt":{let c=o,l=c.sessionId;if(!l)throw new T("IPC_BAD_REQUEST","session/prompt: missing sessionId");let u=Jt(e)?zf(i._meta):void 0;if(u!==void 0&&!Sn(e.framework,u))throw new T("IPC_BAD_REQUEST",`unsupported permissionMode for ${e.framework}: ${u}; allowed: ${dl(e.framework)}`);let f=await this.ensureRuntime(e,l);if(u!==void 0&&f.permissionMode===void 0&&(f.permissionMode=u,await this.persistSessionMapping(e)),f.replySeq=0,await this.ensureDownstream(e,l,f),!f.downstream||!f.acpSessionId)throw new T("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(_){throw f.permissionMode=v,await this.persistSessionMapping(e).catch(()=>{}),_}}let x=i._meta?.cozeTriggerMsgId;x?e.activeTriggers.set(f.acpSessionId,x):e.activeTriggers.delete(f.acpSessionId);let p=uo(i._meta);if(p?e.activeGroupIds.set(f.acpSessionId,p):e.activeGroupIds.delete(f.acpSessionId),p&&f.cozeGroupId!==p&&(f.cozeGroupId=p,await this.persistSessionMapping(e)),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&Rh(c.prompt))throw new T("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let m=await Ch(c.prompt);try{let v=await f.downstream.sessionPrompt({...c,sessionId:f.acpSessionId,prompt:m});return f.lastActiveAt=Date.now(),v}catch(v){if(v instanceof T&&v.code==="AGENT_APPROVAL_TIMEOUT"){let _=f.pendingPermission;_&&(_.downstream.respondAgentRequest(_.agentRequestId,{outcome:{outcome:"cancelled"}}),this.pendingUpstream.delete(_.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 K.warn("approval timed out, synthesizing \u5BA1\u6279\u5DF2\u8D85\u65F6 reply + recovering session",{agentId:e.agentId,cloudId:l}),await this.synthesizePromptReply(e,f,l,SE,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,K.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:l,acpId:f.acpSessionId}),v.stop("reload-after-turn").catch(_=>K.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:l,err:String(_)})))}else f.downstream?.isAlive()&&this.armIdleTimer(e,l,f)}}case"session/cancel":{let l=o.sessionId;if(!l)throw new T("IPC_BAD_REQUEST","session/cancel: missing sessionId");let u=e.sessions.get(l);if(e.hasSessionQueue(l)){let f=e.getSessionQueue(l);f.size>0&&(K.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:l,queuedCount:f.size}),f.dispose(new T("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${l}`)))}return u?.downstream?.isAlive()&&u.acpSessionId&&await u.downstream.sessionCancel({sessionId:u.acpSessionId}),{ok:!0}}case"session/set_mode":{let c=o,l=c.sessionId,u=c.modeId,f=uo(i._meta);if(!l)throw new T("IPC_BAD_REQUEST","session/set_mode: missing sessionId");if(!Jt(e))throw e.framework==="openclaw"?new T("METHOD_NOT_FOUND","session/set_mode not supported on openclaw"):new T("OPERATION_NOT_ALLOWED_FOR_CLOUD","session/set_mode is local-deploy only in this iteration");if(!Sn(e.framework,u))throw new T("IPC_BAD_REQUEST",`unsupported modeId for ${e.framework}: ${String(u)}; allowed: ${dl(e.framework)}`);if(f)return await this.handleGroupSetMode(e,f,u);let x=e.sessions.get(l)??await this.ensureRuntime(e,l);if(x.permissionMode===u)return{};let p=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(m){throw x.permissionMode=p,await this.persistSessionMapping(e).catch(()=>{}),m}else K.info("session/set_mode: runtime not active, persisted only",{framework:e.framework,agentId:e.agentId,cloudId:l,modeId:u});return{}}default:throw new T("IPC_BAD_REQUEST",`session method not supported: ${r}`)}}async handleGroupSetMode(e,r,i){let o=[];for(let[l,u]of e.sessions)u.cozeGroupId===r&&u.permissionMode!==i&&o.push({cloudId:l,runtime:u,oldMode:u.permissionMode});if(o.length===0)return K.info("group session/set_mode: no active runtime (db-only path)",{framework:e.framework,agentId:e.agentId,groupId:r,modeId:i}),{};K.info("group session/set_mode: applying to runtimes",{framework:e.framework,agentId:e.agentId,groupId:r,modeId:i,targets:o.length});for(let l of o)l.runtime.permissionMode=i;await this.persistSessionMapping(e);let c=[];for(let l of o){let u=l.runtime.downstream,f=l.runtime.acpSessionId;u?.isAlive()&&f&&c.push({downstream:u,acpSessionId:f,oldMode:l.oldMode,runtime:l.runtime})}for(let l of c)try{await l.downstream.setSessionMode({sessionId:l.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 Jt(e)&&(e.framework==="hermes"?c.permissionMode=e.deployType==="cloud"?i0:s0:c.permissionMode=e.framework==="claude-code"?pl:sh),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(ft.GEN_MODEL_TOKEN,i,IE);if(!o?.modelToken)throw new T("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${r})`);return o.modelToken}catch(o){throw o instanceof T&&o.code==="MODEL_TOKEN_GEN_FAILED"?o:new T("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 T("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let o=3,c=3e4,l=i.spawnFailCount??0,u=i.spawnFailedAt??0;if(l>=o&&Date.now()-u<c)throw new T("AGENT_SPAWN_FAILED",`agent ${e.agentId} session ${r} spawn failed ${l} 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=l+1,i.spawnFailedAt=Date.now(),i.spawnFailCount>=o&&i.acpSessionId&&(K.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}),K.info("session restored via session/load",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId})}catch(x){K.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId,err:String(x)}),i.acpSessionId=void 0;let p=await f.sessionNew({cwd:e.workspace});i.acpSessionId=p.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 K.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),Jt(e)&&i.acpSessionId&&i.permissionMode)try{await f.setSessionMode({sessionId:i.acpSessionId,modeId:i.permissionMode})}catch(x){K.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)){K.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)){K.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:r}),this.armIdleTimer(e,r,i);return}K.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=>K.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 l=e.activeTriggers.get(r.acpSessionId);l&&(c.cozeTriggerMsgId=l);let u=e.activeGroupIds.get(r.acpSessionId);u&&(c.cozeGroupId=u)}await this.upstream.send(Dr("session/update",{sessionId:i,update:o,_meta:c}))}async synthesizePromptReply(e,r,i,o,c,l){let u={cozeAgentId:e.agentId,cozeReplySeqID:++r.replySeq};return c&&(u.cozeTriggerMsgId=c),l&&(u.cozeGroupId=l),await this.upstream.send(Dr("session/update",{sessionId:i,update:{sessionUpdate:"agent_message_chunk",content:{type:"text",text:o}},_meta:u})).catch(f=>K.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){K.debug("drop update for unknown session",{agentId:e.agentId,acpId:i});return}let c=e.sessions.get(o);if(!c){K.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:o});return}if(CE(r)){K.debug("drop codex noise chunk",{agentId:e.agentId,acpId:i});return}let l=r.update;if(l&&typeof l=="object"&&l.sessionUpdate==="current_mode_update"&&Jt(e)){let p=l.currentModeId;Sn(e.framework,p)&&c.permissionMode!==p?(c.permissionMode=p,this.persistSessionMapping(e).catch(m=>K.warn("persist mode (from current_mode_update) failed",{framework:e.framework,agentId:e.agentId,err:String(m)}))):typeof p=="string"&&!Sn(e.framework,p)&&K.warn("current_mode_update with invalid modeId for framework, not persisting",{framework:e.framework,agentId:e.agentId,modeId:p})}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(Dr("session/update",{...r,sessionId:o,_meta:u})).catch(p=>K.warn("forward update failed",{agentId:e.agentId,err:String(p)}))}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}K.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??{},l=await Sh(c,o);r.respondAgentRequest(i.id,l)}else{let c=i.params??{},l=await Ih(c,o);r.respondAgentRequest(i.id,l)}}catch(o){K.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 p=u?e.activeGroupIds.get(u):void 0;p&&(x.cozeGroupId=p);let m=u?this.reverseSessionId(e,u):void 0,v=m?e.sessions.get(m):void 0;v&&(v.pendingPermission={downstream:r,agentRequestId:i.id,upstreamId:o});let _={...c,...m?{sessionId:m}:{},_meta:x};this.pendingUpstream.set(o,{agentRequestId:i.id,agentId:e.agentId,downstream:r,method:i.method,cloudSessionId:m}),K.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:o,acpSessionId:u,cloudSessionId:m,toolCallId:c.toolCall?.toolCallId,options:c.options?.map(b=>({optionId:b.optionId,kind:b.kind,name:b.name}))}),this.upstream.send(Gi(o,"session/request_permission",_)).catch(b=>{this.pendingUpstream.delete(o),K.error("forward permission request failed",{agentId:e.agentId,err:String(b)}),r.respondAgentRequestError(i.id,{code:Z.INTERNAL_ERROR,message:`upstream send failed: ${String(b)}`})})}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?(K.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"&&TE(e.result,o),K.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 _o(e.error)):i.value.resolve(e.result);return}K.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),l=e.get(c);if(l)return K.warn(`${i} id type mismatch: number received but Bridge expected string`,{rawId:r,normalizedId:c}),{value:l,key:c}}}sendRequest(e,r,i=bE){let o=this.upstreamIds.next(e);return new Promise((c,l)=>{let u=setTimeout(()=>{this.pendingBridge.delete(o),l(new T("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i);this.pendingBridge.set(o,{method:e,resolve:c,reject:l,timer:u}),this.upstream.send(Gi(o,e,r)).catch(f=>{let x=this.pendingBridge.get(o);x&&(clearTimeout(x.timer),this.pendingBridge.delete(o)),l(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&&Jt(e)&&(c.permissionMode=o.permissionMode),o.cozeGroupId&&(c.cozeGroupId=o.cozeGroupId),r.set(i,c)}await si(e.agentId,r,this.paths)}catch(r){K.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(vn(e,{code:r,message:i,data:{bridgeVersion:Ot}}))}};function AE(){return yE(16).toString("hex")}function TE(t,e){if(!t||typeof t!="object"){K.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:t});return}let r=t;if("kind"in r&&!("outcome"in r)){K.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"){K.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")&&K.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:c,result:t})}var kE=["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."];function CE(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{text:o}=i;return kE.some(c=>o.startsWith(c))}Ut();te();Ce();import{randomBytes as RE}from"node:crypto";import{createServer as PE}from"node:http";var DE=1e6,Ph=H("ipc"),Oo=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=RE(32).toString("hex");let e=PE((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(),Ph.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 lt(this.paths.portFile,String(this.port)),await lt(this.paths.tokenFile,this.token,{mode:384})}async dispatch(e,r){if(e.headers.authorization!==`Bearer ${this.token}`){Yi(r,401,{error:"unauthorized"});return}let o=`${e.method} ${(e.url??"").split("?")[0]}`,c=this.routes.get(o);if(!c){Yi(r,404,{error:"not found"});return}let l=null;if(e.method==="POST")try{l=await OE(e)}catch(u){Yi(r,400,{error:"invalid json",detail:String(u)});return}try{let u=await c.handler(l,e);Yi(r,200,u??{ok:!0})}catch(u){Ph.error("IPC handler failed",{key:o,err:String(u)}),Yi(r,500,{error:u instanceof Error?u.message:String(u)})}}};function Yi(t,e,r){t.statusCode=e,t.setHeader("content-type","application/json"),t.end(JSON.stringify(r))}async function OE(t){let e=[],r=0;for await(let o of t){let c=o;if(r+=c.length,r>DE)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 eS=zt(Tx(),1),tS=zt(Go(),1),nS=zt(Ur(),1),rS=zt(Cl(),1),iS=zt(Dl(),1),sS=zt(Fl(),1),Mx=zt(Ko(),1),oS=zt(Nx(),1);var Bx=Mx.default;We();te();var{FWS:ES}=Vx(),De=H("upstream.frontier"),Zx="application/json",Yx="none",vS=15e3;function SS(t){class e extends Bx{constructor(i){super(i,Kf,{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(Cd("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 l=Buffer.from(c.slice(0,128)).toString("hex");De.debug("WS raw frame out",{bytes:c.byteLength,headHex:l})}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:$f,...bn(this.opts.ppeOverride)},r=SS(e),i=Jf(this.opts.urlOverride),o={url:i,ws:r,fpID:Wf,aID:fo,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:Zx,force:!0},payloadEncoding:{encoding:Yx,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},c=new ES(o),l=!1,u=null,f,x,p=new Promise((_,b)=>{f=_,x=b}),m=_=>{l||(l=!0,u&&(clearTimeout(u),u=null),_?x(_):f())};c.onopen=()=>{this.opened=!0,this.openCount+=1;let _=this.openCount===1;De.info("frontier opened",{url:i,remoteDeviceId:this.opts.handshake.deviceId,initial:_,openCount:this.openCount}),_&&m();for(let b of this.connectHandlers)Promise.resolve(b({initial:_})).catch(I=>De.warn("onConnect handler threw (ignored)",{err:String(I)}))},c.onclose=_=>{this.opened=!1,De.info("frontier closed",{code:_.code,reason:_.reason,willReconnect:_.willReconnect})},c.onerror=_=>{De.warn("frontier error",{code:_.code,msg:_.message}),m(new T("UPSTREAM_DISCONNECTED",`frontier connect error before open: code=${_.code} msg=${_.message??""}`))},c.onmessage=_=>this.handleMessage(_),this.fws=c;let v=this.opts.openTimeoutMs??vS;u=setTimeout(()=>{m(new T("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${v}ms (handshake or upgrade slow)`))},v),await c.connect();try{await p}catch(_){try{c.close(1e3,"open failed")}catch(b){De.warn("fws close during start failure threw (ignored)",{err:String(b)})}throw this.fws=null,this.opened=!1,_}}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 T("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 T("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;Xx(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:Zx,payloadEncoding:Yx})}catch(u){throw De.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(u)}),new T("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=TS(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(l){De.warn("frontier message JSON parse failed",{err:String(l),head:i.slice(0,80)});return}let c=o;Xx(c)||De.info("frontier frame in",{logid:AS(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:c.id,method:c.method,body:IS(i)}),Promise.resolve(this.handler(o)).catch(l=>De.warn("frontier frame handler threw",{err:String(l)}))}};function Xx(t){return t.method==="_agent/health"?!0:typeof t.id=="string"&&t.id.startsWith("agent.health_")}var Qx=2e3;function IS(t){return t.length<=Qx?t:`${t.slice(0,Qx)}...<truncated, total ${t.length} chars>`}function AS(t){return t?t.high===0?String(t.low>>>0):`${t.high.toString(16)}${(t.low>>>0).toString(16).padStart(8,"0")}`:""}function TS(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}}We();te();var Gl=H("skill-publish"),kS="/api/marketplace/product/skill/publish_with_assets",CS=15e4;async function ep(t,e={}){let i=`${kr(Cr(e.handshakeBase))}${kS}`,o=e.timeoutMs??CS,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 l={Authorization:`Bearer ${t.patToken}`,Accept:"application/json","x-coze-version":"3.0",...bn(e.ppeOverride),...t.accountId&&t.accountId!=="0"?{"x-coze-account":t.accountId}:{}},u=new AbortController,f=setTimeout(()=>u.abort(),o);Gl.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:{...l,Authorization:`Bearer ${t.patToken.slice(0,8)}...`}});try{let x=await fetch(i,{method:"POST",headers:l,body:c,signal:u.signal}),p=x.headers.get("x-tt-logid")??"";if(!x.ok){let _=await x.text().catch(()=>"");throw new T("UPLOAD_FAILED",`skill publish HTTP ${x.status} logid=${p}: ${_.slice(0,200)}`)}let m=await x.json();if(Gl.info("skill publish response",{logid:p,httpStatus:x.status,code:m.code,msg:m.msg,dataSkillId:m.data?.skill_id??"",dataVersion:m.data?.version??""}),m.code!==void 0&&m.code!==0)throw new T("UPLOAD_FAILED",`skill publish code=${m.code} msg=${m.msg??"-"} logid=${p}`);let v={};return m.data?.skill_id!==void 0&&m.data.skill_id!==""&&(v.skillId=String(m.data.skill_id)),m.data?.version&&(v.version=m.data.version),Gl.info("skill publish ok",{logid:p,skillId:v.skillId??"",version:v.version??""}),v}catch(x){throw x instanceof T?x:x.name==="AbortError"?new T("UPLOAD_FAILED",`skill publish timeout (${o}ms): ${t.skillName}`):new T("UPLOAD_FAILED",String(x),{cause:x})}finally{clearTimeout(f)}}te();var ql=H("upstream.switchable"),ta=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,r){if(this.inner===e)return;ql.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 ql.error("swap target start failed, reverting",{err:String(o)}),this.inner=i,o}await i.stop(r??"swapped").catch(o=>ql.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 jl=H("upstream"),Kr=class{handler=null;async start(){jl.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){jl.info("NoopUpstream stopped",{reason:e})}async send(e){jl.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)}};We();te();Ut();te();Ce();import{promises as RS}from"node:fs";var tp=H("pat-token-store");async function na(t=J()){try{let r=(await RS.readFile(t.patTokenFile,"utf8")).trim();return r.length===0?(tp.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"&&tp.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 lt(e.patTokenFile,t,{mode:384})}Ce();Ce();import{promises as ra}from"node:fs";import{join as PS}from"node:path";function DS(t,e){return`#!/bin/sh
|
|
99
|
+
`)){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 yy(t,e,r,i){let{base:o,subdir:c}=Dr(r,t,e,i),d=Ze(o,c),u=await u0(d,{withFileTypes:!0}).catch(()=>null);if(!u)return[];let x=[];for(let h of u){if(!h.isDirectory())continue;let m=h.name,w=Ze(c,m),S=Ze(d,m,"SKILL.md"),_=await mo(S,{encoding:"utf8"}).catch(()=>null);if(_===null)continue;let v=m0(_);x.push({relPath:w,skill:{skillId:g0(t,w),skillName:v.name||m,...v.description?{description:v.description}:{}}})}return x}var Ey=3e4,by=50*1024*1024,d0=10*1024*1024,Pr=3e4;async function _o(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 x=p0(o.skillName),{base:h,subdir:m}=Dr(i,e,r,c),w=Ze(m,x),S=Ze(h,w);if(await il(S,{recursive:!0}),d){let v=Buffer.from(o.content,"utf8");qi(v.length),await ol(Ze(S,"SKILL.md"),v,"utf8")}else{let v=await Iy(o.downloadUrl);ky(v)?await Dy(v,S):Ty(v)?await Ry(v,S):await ol(Ze(S,"SKILL.md"),v.toString("utf8"),"utf8")}let _={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 pe.info("skill installed",{agentId:e,skillId:o.skillId,skillName:o.skillName,relPath:w,source:d?"content":"downloadUrl"}),_}function yo(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 vy(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 Sy(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 w0(t,e){let r=await Ie(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 Ue(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 Ue(r,e),{status:"noop",count:0};let x=0,h=0,{base:m}=Dr(r.framework,t,r.workspace,e);for(let w of u)try{await sl(Ze(m,w.relPath),{recursive:!0,force:!0});let S=await _o({agentId:t,workspace:r.workspace,framework:r.framework,skill:Sy(w),...e?{paths:e}:{}});yo(c,d,S),x+=1}catch(S){h+=1,pe.warn("refresh builtin skill failed (skipping)",{agentId:t,skillId:w.skillId,skillName:w.skillName,err:String(S)})}return r.skills=c,h===0&&(r.skillsRefreshedForVersion=i),await Ue(r,e),pe.info("builtin skills refreshed after bridge upgrade",{agentId:t,from:o,to:i,ok:x,failed:h}),{status:"refreshed",count:x}}async function Iy(t){if(!t)throw new k("IPC_BAD_REQUEST","skill missing downloadUrl");if(t.startsWith("data:")){let e=Math.floor(t.length*3/4);qi(e);let r=Ay(t);return qi(r.length),r}if(t.startsWith("file:")){let e=new URL(t).pathname,r=await mo(e);return qi(r.length),r}if(Ni(t)){let e=new AbortController,r=setTimeout(()=>e.abort(),Ey);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 qi(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 qi(t){if(t>by)throw new k("IPC_BAD_REQUEST",`skill too large: ${t} bytes`)}function Ay(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 ky(t){return t.length>=2&&t[0]===31&&t[1]===139}function Ty(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 cl(t){return t==="__MACOSX"||t.startsWith("__MACOSX/")}async function Ry(t,e){let r,i;try{r=new dl.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||cl(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(h=>h===".."))throw new k("IPC_BAD_REQUEST",`zip entry contains '..' (traversal): ${u}`);let x=d.header.attr>>>16&61440;if(x!==0&&x!==32768&&x!==16384)throw new k("IPC_BAD_REQUEST",`zip entry kind 0x${x.toString(16)} not allowed (symlink/hardlink/special): ${u}`)}let o=Cy(i),c=al(e);for(let d of i){if(cl(d.entryName))continue;let u=d.entryName;if(o&&u.startsWith(o)&&(u=u.slice(o.length)),!u)continue;let x=al(e,u),h=ll(c,x);if(h.startsWith("..")||h==="..")throw new k("IPC_BAD_REQUEST",`zip entry escapes destDir: ${u}`);if(d.isDirectory){await il(x,{recursive:!0});continue}await il(dy(x),{recursive:!0});let m;try{m=d.getData()}catch(w){throw new k("IPC_BAD_REQUEST",`zip entry getData failed (${d.entryName}): ${w.message}`,{cause:w})}await ol(x,m)}}function Cy(t){let e;for(let r of t){let i=r.entryName;if(!i||cl(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 Dy(t,e){await Py(t);let r=Mf({cwd:e,strip:1}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new k("IPC_BAD_REQUEST",`tar extract timeout (${Pr}ms)`))},Pr);try{await h0(x0.from(t),r)}catch(c){throw c instanceof k?c:i?new k("IPC_BAD_REQUEST",`tar extract timeout (${Pr}ms)`):new k("IPC_BAD_REQUEST",`tar extract failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}}async function Py(t){let e=[],r=kr({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(h=>h==="..")&&e.push(`tar entry contains '..': ${d}`)}}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new k("IPC_BAD_REQUEST",`tar list timeout (${Pr}ms)`))},Pr);try{await h0(x0.from(t),r)}catch(c){throw i?new k("IPC_BAD_REQUEST",`tar list timeout (${Pr}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 Oy=5e3;async function Ly(t,e,r,i){return _0(t,e,r,i,{count:0})}async function _0(t,e,r,i,o){if(i<=0)return[];let c;try{c=await u0(e,{withFileTypes:!0})}catch{return[]}let d=[];for(let u of c){if(hy.has(u.name)||u.isSymbolicLink())continue;if(o.count>=Oy){d.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let x=Ze(e,u.name),h=uy(Ze(r,u.name)),m=null;try{m=await rl(x)}catch{continue}if(m.isSymbolicLink())continue;o.count++;let w={name:u.name,path:y0(ll(t,x)),isDir:m.isDirectory(),size:m.size,modifiedAt:Math.floor(m.mtimeMs)};m.isDirectory()&&i>1&&(w.children=await _0(t,x,h,i-1,o)),d.push(w)}return d.sort((u,x)=>u.isDir!==x.isDir?u.isDir?-1:1:u.name.localeCompare(x.name)),d}function Ny(t){return!t||t<=0?fy:Math.min(t,xy)}function My(t){if(!t||t==="."||t==="/")return".";let e=t.split(/[/\\]/);return e[e.length-1]||"."}function y0(t){return t.split(f0).join("/")}re();var vn=j("agent-health-reporter"),By=1e4,Fy=3,ji=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??By,this.livenessFailureThreshold=e.livenessFailureThreshold??Fy}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()}),vn.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),vn.info("heartbeat stopped"))}async tick(){if(this.inFlight){vn.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){this.consecutiveFailures=0,vn.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=zy(d);if(!u)continue;let x={agentId:d.agentId,status:u};d.patToken&&(x.patToken=d.patToken),d.accountId&&(x.accountId=d.accountId),r.push(x)}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,vn.warn("heartbeat batch send failed",{count:r.length,consecutiveFailures:this.consecutiveFailures,err:String(d)})}let c=o?.authFailures;if(c&&c.length>0&&(vn.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){vn.warn("onAuthFailures callback failed (ignored)",{err:String(d)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(r){vn.warn("onTickEnd hook failed",{err:String(r)})}}};function zy(t){return t.status==="error"?"error":t.activeTriggers.size>0?"busy":t.status==="ok"?"online":null}qt();import{mkdir as hl,rm as PE,stat as OE}from"node:fs/promises";import{homedir as LE}from"node:os";import{join as gl}from"node:path";cn();import{existsSync as Jy}from"node:fs";import{release as Yy}from"node:os";import{basename as Xy,isAbsolute as Qy}from"node:path";function Wi(t,e,r){return r===void 0?{jsonrpc:"2.0",id:t,method:e}:{jsonrpc:"2.0",id:t,method:e,params:r}}function Or(t,e){return e===void 0?{jsonrpc:"2.0",method:t}:{jsonrpc:"2.0",method:t,params:e}}function Lr(t,e){return{jsonrpc:"2.0",id:t,result:e}}function Sn(t,e){return{jsonrpc:"2.0",id:t,error:e}}$e();var Eo=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)}},Y={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 E0(t){return"method"in t&&"id"in t&&t.id!==void 0}function b0(t){return"method"in t&&!("id"in t)}function bo(t){return!("method"in t)&&"id"in t}var Uy={AGENT_NOT_FOUND:Y.AGENT_NOT_FOUND,AGENT_BUSY:Y.AGENT_BUSY,AGENT_DISCONNECTED:Y.AGENT_DISCONNECTED,AGENT_TIMEOUT:Y.AGENT_TIMEOUT,AGENT_FRAME_IDLE_TIMEOUT:Y.AGENT_FRAME_IDLE_TIMEOUT,AGENT_SPAWN_FAILED:Y.AGENT_SPAWN_FAILED,AGENT_PROTOCOL_ERROR:Y.INTERNAL_ERROR,BRIDGE_CONFIG_INVALID:Y.INTERNAL_ERROR,BRIDGE_INTERNAL:Y.INTERNAL_ERROR,IPC_AUTH_FAILED:Y.INTERNAL_ERROR,IPC_BAD_REQUEST:Y.INVALID_REQUEST,METHOD_NOT_FOUND:Y.METHOD_NOT_FOUND,MODEL_TOKEN_GEN_FAILED:Y.MODEL_TOKEN_GEN_FAILED,MODEL_MODALITY_UNSUPPORTED:Y.MODEL_MODALITY_UNSUPPORTED,OPERATION_NOT_ALLOWED_FOR_LOCAL:Y.OPERATION_NOT_ALLOWED_FOR_LOCAL,OPERATION_NOT_ALLOWED_FOR_CLOUD:Y.OPERATION_NOT_ALLOWED_FOR_CLOUD,UPSTREAM_DISCONNECTED:Y.INTERNAL_ERROR,UPSTREAM_HANDSHAKE_FAILED:Y.INTERNAL_ERROR,PATH_OUTSIDE_WORKSPACE:Y.PATH_OUTSIDE_WORKSPACE,FILE_TOO_LARGE:Y.FILE_TOO_LARGE,UNSUPPORTED_MIME:Y.UNSUPPORTED_MIME,UPLOAD_FAILED:Y.UPLOAD_FAILED,UPSTREAM_NOT_READY:Y.UPSTREAM_NOT_READY,AGENT_DEPENDENCY_INSTALL_FAILED:Y.AGENT_DEPENDENCY_INSTALL_FAILED,AGENT_APPROVAL_TIMEOUT:Y.AGENT_APPROVAL_TIMEOUT,AGENT_TURN_ABORTED:Y.AGENT_TURN_ABORTED,AGENT_ENV_NOT_READY:Y.AGENT_ENV_NOT_READY,SKILL_NOT_FOUND:Y.SKILL_NOT_FOUND,SKILL_ZIP_TOO_LARGE:Y.SKILL_ZIP_TOO_LARGE};function Gy(t){if(t!=null)return t instanceof Error?{name:t.name,message:Ki(t.message)}:typeof t=="string"?Ki(t):typeof t=="object"?qy(t):t}var Hy=[[/\/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 Ki(t){let e=t;for(let[r,i]of Hy)e=e.replace(r,i);return e}function qy(t){let e={};for(let[r,i]of Object.entries(t))typeof i=="string"?e[r]=Ki(i):e[r]=i;return e}function $i(t){if(t instanceof k){let e=Gy(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:Uy[t.code]??Y.INTERNAL_ERROR,message:Ki(t.message),data:r}}return{code:Y.INTERNAL_ERROR,message:Ki(t instanceof Error?t.message:String(t))}}function v0(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 I0(t){return`${JSON.stringify(t)}
|
|
100
|
+
`}var S0=10*1024*1024,vo=class{buffer="";onError;constructor(e={}){this.onError=e.onError}push(e){if(this.buffer+=typeof e=="string"?e:e.toString("utf8"),this.buffer.length>S0){let o=this.buffer.length;return this.buffer="",this.onError?.({line:`<buffer overflow: ${o} bytes, dropped>`,error:new Error(`LdjsonDecoder buffer exceeded ${S0} bytes`)}),[]}let r=this.buffer.split(`
|
|
101
|
+
`);this.buffer=r.pop()??"";let i=[];for(let o of r){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(r){return this.onError?.({line:e,error:r}),[]}}};var k0={"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"},eT=Object.fromEntries(Object.entries(k0).map(([t,e])=>[e,t])),jy={"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:[]},Nr=class{seq=0;next(e,r){this.seq+=1;let i=k0[e]??Wy(e),o=jy[i]??[],c=[i,String(this.seq)];if(o.length>0){let d=o.map(x=>A0(r?.[x]??"")),u=Ky(d).join(":");u&&c.push(u)}else r&&Object.values(r).some(d=>d)&&c.push(Object.values(r).filter(Boolean).map(d=>A0(String(d))).join(":"));return c.join("_")}reset(){this.seq=0}};function Wy(t){return t.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function A0(t){return t.replace(/[:_\s]+/g,"-")}function Ky(t){let e=t.length;for(;e>0&&!t[e-1];)e-=1;return t.slice(0,e)}Jt();sr();$e();re();De();import{execFileSync as $y,spawnSync as Vy}from"node:child_process";function Vi(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}function Zi(t,e){if(!(typeof t!="number"||t<=0))try{if(process.platform==="win32"){let r=["/PID",String(t),"/T"];e==="SIGKILL"&&r.push("/F"),Vy("taskkill",r,{stdio:"ignore",windowsHide:!0})}else process.kill(-t,e)}catch{}}var ul=new Set;function T0(t){typeof t=="number"&&t>0&&ul.add(t)}function R0(t){typeof t=="number"&&ul.delete(t)}function C0(){for(let t of ul)Zi(t,"SIGKILL")}var Mr="coze-bridge-daemon";function D0(t){let e=t?.execFn??(()=>{if(process.platform==="win32")return"";let o=process.getuid?.()??0;return $y("pgrep",["-U",String(o),"-f",Mr],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:2e3})}),r;try{r=e()}catch{return[]}let i=process.pid;return r.split(`
|
|
102
|
+
`).map(o=>Number.parseInt(o.trim(),10)).filter(o=>Number.isFinite(o)&&o>0&&o!==i)}async function P0(t,e){if(t.length===0)return;let r=e?.killFn??Zi,i=e?.isAliveFn??Vi,o=e?.sleepFn??(u=>new Promise(x=>setTimeout(x,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(x=>i(x));u+=d)await o(Math.min(d,c-u));for(let u of t)i(u)&&r(u,"SIGKILL")}var Zy=[{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:"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|agentclientprotocol)\/codex-acp|optional dependency was not installed|\.resolve is not a function/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[^\n]*node_modules[\\/]@(agentclientprotocol[\\/](claude-agent-acp|codex-acp)|zed-industries[\\/]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 O0(t,e){if(!e)return null;for(let r of Zy)if(!(r.frameworks&&!r.frameworks.includes(t))&&r.match.test(e))return{bridgeCode:r.bridgeCode,reason:r.reason,message:r.message};return null}function L0(t,e){return O0(t,e)}function N0(t,e){return O0(t,e)}function Br(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 M0(t,e,r){let o=r-t.armedAt-t.expectedIntervalMs;if(o>e.suspendThresholdMs){let h=t.suspendedMs+o,m=r-t.startedAt-h;return{action:"suspend",suspendedDeltaMs:o,rearmMs:Br(m,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:Br(c,!0,e)}:r-t.lastActivityAt<e.livenessWindowMs||t.hasActiveTool||t.awaitingApproval?{action:"continue",rearmMs:Br(c,!0,e)}:{action:"reject-idle"}:e.firstUpdateMs>0&&c>=e.firstUpdateMs&&!t.awaitingApproval?{action:"reject-idle"}:{action:"continue",rearmMs:Br(c,!1,e)}}var B0=Ye("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),eE=200,tE=40,nE=Ye("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),rE=Ye("COZE_BRIDGE_SESSION_PROMPT_IDLE_MS",600*1e3),iE=Ye("COZE_BRIDGE_SESSION_PROMPT_ABSOLUTE_MAX_MS",7200*1e3),sE=Ye("COZE_BRIDGE_SUSPEND_THRESHOLD_MS",60*1e3),oE=Ye("COZE_BRIDGE_SESSION_PROMPT_FIRST_UPDATE_MS",600*1e3),aE=Ye("COZE_BRIDGE_SESSION_PROMPT_APPROVAL_MAX_MS",1440*60*1e3),F0=500;function cE(t){try{let e=JSON.stringify(t);return e===void 0||e.length<=F0?t:`${e.slice(0,F0)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function lE(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 z0(t){try{return Jy(t)}catch{return}}function dE(t,e){return{platform:process.platform,osRelease:Yy(),code:t.code,errno:t.errno,syscall:t.syscall,errPath:t.path,command:e.command,commandExists:Qy(e.command)?z0(e.command):void 0,cwd:e.cwd,cwdExists:z0(e.cwd),envKeys:e.envKeys}}function uE(t,e){return`${t.message} [diag: platform=${e.platform} os=${e.osRelease} code=${e.code} errno=${e.errno} syscall=${e.syscall} cmd=${Xy(e.command)} cmdExists=${e.commandExists} cwdExists=${e.cwdExists} envKeys=${e.envKeys}]`}var gt=class{constructor(e){this.opts=e;this.log=j(`downstream.${this.constructor.name}`,this.opts.agentId),this.decoder=new vo({onError:r=>this.log.warn("decode line failed",{line:r.line})})}opts;child;decoder;pending=new Map;inflightAgentRequests=new Map;idAllocator=new Nr;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stopReason;stderrRing=[];now=Date.now;spawnEnv={};sanitizeEnv(e){return e}async start(){if(this.child)throw new k("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",r=jf(process.env,this.opts.agentEnvFile??J().agentEnvFile,this.opts.env,o=>this.sanitizeEnv(o));this.spawnEnv=r;let i=st(this.opts.command,this.opts.args,{cwd:this.opts.cwd,env:r,stdio:["pipe","pipe","pipe"],detached:e});this.child=i,T0(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>eE&&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,R0(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=dE(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",uE(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()));Zi(r.pid,"SIGTERM");let o=setTimeout(()=>{r.killed||Zi(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:oE,phase2GateMs:nE,livenessWindowMs:rE,absoluteMaxMs:iE,approvalMaxMs:aE,suspendThresholdMs:sE,...r};return this.call("session/prompt",e,B0,i)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(Or("session/cancel",e))}setSessionMode(e){return this.call("session/set_mode",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(Lr(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(Sn(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=B0,o){if(!this.child||this.stopped)return Promise.reject(new k("AGENT_PROTOCOL_ERROR","downstream not started"));let c=this.idAllocator.next(e),d=Wi(c,e,r),u=(()=>{if(typeof r!="object"||r===null)return;let x=r.sessionId;return typeof x=="string"?x:void 0})();return new Promise((x,h)=>{let m={resolve:x,reject:h,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:Br(0,!1,o),sessionId:u};m.promptTimeout=S;let _=()=>{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=M0(v,S.cfg,I),T=P=>{S.armedAt=I,S.expectedIntervalMs=P,m.timer=setTimeout(_,P)};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}:{}}),T(A.rearmMs);return}if(A.action==="continue"){T(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}:{}}),h(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}:{}}),h(new k("AGENT_FRAME_IDLE_TIMEOUT",`${e} no progress within ${S.cfg.livenessWindowMs}ms`)))};m.timer=setTimeout(_,S.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}),h(new k("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i));this.pending.set(c,m);try{this.writeFrame(d)}catch(w){m.timer&&clearTimeout(m.timer),this.pending.delete(c),h(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(I0(e),r=>{r&&this.log.warn("stdin write callback err",{err:String(r)})})}dispatch(e){if(bo(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:cE(e.result)}),r.resolve(e.result));return}if(b0(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(E0(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(Sn(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(Sn(e.id,$i(i)))}catch{}this.inflightAgentRequests.delete(e.id)}}wireErrorToBridge(e){let r=v0(e);if(r.code!=="AGENT_PROTOCOL_ERROR")return r;let i=N0(this.framework,lE(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(tE).join(`
|
|
103
|
+
`),o=L0(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 fE(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 So=class extends gt{framework="claude-code";constructor(e){let{command:r,args:i}=si("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 fE(e)}};cn();import{mkdtempSync as gE,rmSync as mE}from"node:fs";import{tmpdir as wE}from"node:os";import{join as _E}from"node:path";import{readFileSync as G0}from"node:fs";import{homedir as xE}from"node:os";import{join as U0}from"node:path";function H0(t){let e=t.CODEX_HOME?.trim()||U0(t.HOME?.trim()||xE(),".codex");return U0(e,"config.toml")}function hE(t){let e=null;for(let r=0;r<t.length;r++){let i=t[r];if(e)i===e&&(e=null);else if(i==='"'||i==="'")e=i;else if(i==="#")return t.slice(0,r)}return t}function pE(t){let e=t.trim();if(e.length>=2){let r=e[0];if((r==='"'||r==="'")&&e[e.length-1]===r)return e.slice(1,-1)}return e}function q0(t){let e={},r={},i=e;for(let o of t.split(/\r?\n/)){let c=hE(o).trim();if(!c)continue;let d=/^\[([^\]]+)\]$/.exec(c);if(d){let h=(d[1]??"").trim(),m=r[h]??{};r[h]=m,i=m;continue}let u=c.indexOf("=");if(u<=0)continue;let x=c.slice(0,u).trim();x&&(i[x]=pE(c.slice(u+1)))}return{root:e,tables:r}}function j0(t){let e=t.root.model_provider;if(!e||e==="openai")return null;let r=t.tables[`model_providers.${e}`];return r?{providerId:e,baseUrl:r.base_url,envKey:r.env_key,bearerToken:r.experimental_bearer_token}:null}function W0(t){let e;try{e=G0(H0(t),"utf8")}catch{return null}return j0(q0(e))?.providerId??null}function K0(t){let e;try{e=G0(H0(t),"utf8")}catch{return null}let r=j0(q0(e));if(!r?.baseUrl)return null;let i=r.bearerToken||(r.envKey?t[r.envKey]?.trim():void 0);return i?{baseUrl:r.baseUrl,providerName:r.providerId,headers:{Authorization:`Bearer ${i}`}}:null}var Io=class t extends gt{framework="codex";authRequest;resolveLocalGatewayAuth;codexHomeDir;constructor(e){let r=e.args??[],i=e.extraArgs?[...r,...e.extraArgs]:r,{command:o,args:c}=si("codex",e.command,i),d=e.isolateCodexHome?gE(_E(wE(),"coze-bridge-codex-home-")):void 0,u=d?{...e.env??{},CODEX_HOME:d}:e.env,x={command:o,args:c,cwd:e.cwd,agentId:e.agentId,...u?{env:u}:{}};super(x),this.authRequest=e.authRequest,this.resolveLocalGatewayAuth=e.resolveLocalGatewayAuth??!1,this.codexHomeDir=d}async initialize(e){let r=await super.initialize(e),i=this.authRequest??this.localGatewayAuthRequest();return i&&await this.call("authenticate",i),r}localGatewayAuthRequest(){if(!this.resolveLocalGatewayAuth)return null;let e=K0(this.spawnEnv);return e?(this.log.info("codex local: \u7528 config.toml custom provider \u8D70 gateway \u8BA4\u8BC1",{providerName:e.providerName,baseUrl:e.baseUrl}),{methodId:"gateway",_meta:{gateway:e}}):null}static MODE_ID_MAP={"read-only":"read-only",auto:"agent","full-access":"agent-full-access"};setSessionMode(e){let r=t.MODE_ID_MAP[e.modeId]??e.modeId;return super.setSessionMode({...e,modeId:r})}async stop(e){if(await super.stop(e),this.codexHomeDir)try{mE(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var Ao=class extends gt{framework="hermes";constructor(e){let r={command:e.command,args:[],cwd:e.cwd,agentId:e.agentId,...e.env?{env:e.env}:{}};super(r)}};$e();var yE=3e4,Fr=class extends gt{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}`}]},yE))}get acpSessionName(){return this.sessionName}setSessionMode(e){return Promise.reject(new k("METHOD_NOT_FOUND","session/set_mode not supported on openclaw"))}};var $0=["default","acceptEdits","plan","auto","bypassPermissions"],V0=["read-only","auto","full-access"],Z0=["default","accept_edits","dont_ask"];function In(t,e){if(typeof e!="string")return!1;switch(t){case"claude-code":return $0.includes(e);case"codex":return V0.includes(e);case"hermes":return Z0.includes(e);case"openclaw":return!1}}function fl(t){switch(t){case"claude-code":return $0.join("/");case"codex":return V0.join("/");case"hermes":return Z0.join("/");case"openclaw":return""}}Ht();$e();re();De();function xl(t){return t.replace(/[^A-Za-z0-9._-]+/g,"-")}cn();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 ko=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)Ji(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 Ji(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"}Jt();re();import{constants as J0}from"node:fs";import{access as EE,readFile as bE}from"node:fs/promises";import{delimiter as vE,dirname as SE,join as Y0}from"node:path";var nt=j("framework-detector"),X0={"claude-code":"claude",codex:"codex",openclaw:"openclaw",hermes:"hermes-acp"},IE=[".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??EE,readFile:e.readFile??bE}}async detect(e){let r=X0[e],i=await this.which(r);if(!i&&e==="hermes"&&(i=await this.resolveHermesAcpViaHermesShim()),!i)return nt.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(X0).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(vE).filter(Boolean),i=this.env.platform==="win32"?["",...IE]:[""];for(let o of r)for(let c of i){let d=Y0(o,e+c);if(await this.isExecutable(d))return d}return null}async isExecutable(e){try{let r=this.env.platform==="win32"?J0.F_OK:J0.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 nt.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 nt.debug("hermes shim fallback: no exec line matched",{hermesPath:e}),null;let c=Y0(SE(o),"hermes-acp");return await this.isExecutable(c)?(nt.info("hermes-acp resolved via hermes shim fallback",{hermesPath:e,candidate:c}),c):(nt.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 nt.warn("openclaw default agent probe: runProbe returned null (spawn err / timeout)",{path:e}),null;if(r.code!==0)return nt.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 nt.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 nt.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?(nt.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}:(nt.info("openclaw default agent probe: no agent has isDefault=true",{path:e,agentCount:o.length}),null)}catch(o){return nt.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 nt.warn("openclaw gateway probe: runProbe returned null (spawn err / timeout)",{path:e}),{reachable:!1};let i=r.code===0;i||nt.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){nt.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&&(kE(i.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,r){return new Promise(i=>{let o="",c=!1,d,u=x=>{c||(c=!0,d&&clearTimeout(d),i(x))};try{let x=this.env.spawn(e,r,{stdio:["ignore","pipe","pipe"]});d=setTimeout(()=>{x.kill("SIGKILL"),u(null)},15e3),x.stdout?.on("data",h=>{o+=h.toString("utf8")}),x.on("error",()=>u(null)),x.on("close",h=>u({code:h,stdout:o}))}catch{u(null)}})}},AE=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function kE(t){return t.replace(AE,"")}import{homedir as TE}from"node:os";import{join as RE}from"node:path";Ht();Jt();sr();$e();re();async function tx(){let t=RE(TE(),".openclaw/openclaw.json");return(await lr(t))?.gateway?.auth?.token??""}var Q0=j("openclaw.config"),CE=[0,5e3,5e3],DE=Ye("COZE_BRIDGE_OPENCLAW_CLI_TIMEOUT_MS",15e3),ex="models.providers.",To="agents.defaults.models",Ro=class{command;env;retryDelaysMs;cliTimeoutMs;queue=new An;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??CE,this.cliTimeoutMs=e.cliTimeoutMs??DE}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,Q0.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=h=>{d||(d=!0,clearTimeout(x),h())};o.stderr?.on("data",h=>{c+=h.toString("utf8")});let x=setTimeout(()=>{u(()=>{o.kill("SIGTERM"),setTimeout(()=>o.kill("SIGKILL"),250).unref(),i(new Error(`timeout after ${this.cliTimeoutMs}ms: ${e.join(" ")}`))})},this.cliTimeoutMs);x.unref(),o.on("error",h=>u(()=>i(h))),o.on("close",h=>u(()=>{h===0?r():i(new Error(`exit ${h}: ${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.runCli(["config","unset",r])))}catch(i){Q0.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",`${ex}${e}`,JSON.stringify(r),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${ex}${e}`)}addModelToAllowlist(e,r){let i={[e]:r?{alias:r}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${To}[${e}]`,()=>this.runCli(["config","set",To,JSON.stringify(i),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${To}[${e}]`,`${To}.${e}`)}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 fe=j("agent-manager"),ml="acceptEdits",ix="full-access",sx="read-only";function NE(t){switch(t){case"read-only":return"read-only";case"auto":return"agent";case"full-access":return"agent-full-access"}}var ME=(t,e,r,i,o,c,d,u,x,h)=>{switch(t){case"claude-code":{let m={...o?{...Yf(o),...e0(o,d,u)}:{},...x??{},IS_SANDBOX:"1"};return new So({cwd:r,env:m,agentId:i})}case"codex":{let m=ix;h!==void 0&&(In("codex",h)?m=h:fe.warn("codex spawn: invalid codexPermissionMode, falling back to full-access",{agentId:i,received:h}));let w=o?null:W0(process.env),S={...o?Qf(o):{},INITIAL_AGENT_MODE:NE(m),...process.env.COZE_BRIDGE_CODEX_APP_SERVER_LOGS==="1"?{APP_SERVER_LOGS:gl(r,"..","logs","codex-app-server")}:{},...w?{MODEL_PROVIDER:w}:{},...x??{}},_=o?Xf(o,d,u):null,v=_?{methodId:"gateway",_meta:{gateway:_}}:void 0,I=!!o,A=!I&&process.env.COZE_BRIDGE_CODEX_LOCAL_GATEWAY_AUTH==="1";return new Io({cwd:r,agentId:i,...Object.keys(S).length>0?{env:S}:{},...v?{authRequest:v}:{},...I?{isolateCodexHome:!0}:{},...A?{resolveLocalGatewayAuth:!0}:{}})}case"openclaw":return new Fr({command:e,cwd:r,agentId:i,...c?{sessionName:xl(c)}:{}});case"hermes":return new Ao({command:e,cwd:r,agentId:i,...x&&Object.keys(x).length>0?{env:{...x}}:{}})}};function pl(t){return t==="claude-code"||t==="codex"}var BE={path:"",version:"cloud-deployed"},nx="openclaw_gateway_unavailable",FE="openclaw_default_agent_missing";function rx(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}}},UE=6e4,Co=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??ME,this.createTimeoutMs=e.createTimeoutMs??UE,this.detectorFactory=e.detectorFactory??(()=>new Vn),this.openclawConfigFactory=e.openclawConfigFactory??(r=>new Ro({command:r})),this.openclawConfigDir=e.openclawConfigDir??gl(LE(),".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,r=gl(e,".env");if(await OE(r).then(c=>c.isFile()).catch(()=>!1)){fe.debug("openclaw .env exists, skip bootstrap",{envFile:r});return}let o=Bi({...process.env,...Mi(this.paths.agentEnvFile)});await ut(r,o,{mode:384}),fe.info("openclaw .env bootstrapped",{envFile:r,bytes:o.length}),await this.getOpenclawConfig().restartGateway(),fe.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 Ie(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")fe.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await c.dispose("rebuild after error").catch(T=>fe.warn("dispose stale agent failed (ignored)",{err:String(T)})),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(T=>fe.warn("dispose drifted agent failed (ignored)",{err:String(T)})),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 T=await Ie(e.agentId,this.paths).catch(()=>null);T&&(T.patToken=e.patToken,await Ue(T,this.paths))}if(c.deployType==="cloud"&&e.modelInfo){fe.info("updating agent modelInfo on re-create",{agentId:e.agentId}),c.setModelInfo(e.modelInfo);let T=await Ie(e.agentId,this.paths).catch(()=>null);T&&(T.modelInfo=e.modelInfo,await Ue(T,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 P=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${P}`)}let u=ze(e.agentId,this.paths),x=o?"cloud":"local",h=e.framework==="openclaw"&&x==="local",m;h&&!r?.revive&&(m=(await this.ensureOpenclawDefaultAgent()).workspace,await this.ensureOpenclawGatewayReachable());let w=m??(h?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0),S=e.workspace??w??u.workspace,_=new AbortController,v=setTimeout(()=>_.abort(new k("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),I,A=!1;try{o&&pl(e.framework)&&await cr(e.framework,_.signal);let T=()=>{if(_.signal.aborted)throw _.signal.reason instanceof Error?_.signal.reason:new k("AGENT_TIMEOUT","_agent/create aborted")};await hl(u.root,{recursive:!0}),await hl(S,{recursive:!0}),await hl(u.logs,{recursive:!0}),T(),h||await ur(S,e.framework,e.cozeIdentity),e.framework==="claude-code"&&(x==="cloud"?await Ua(S,"cloud"):await Ua(S,"local",ml)),T();let P=i,y=Jf({model:e.model??P?.model}),C=Ff(e._meta)??P?.accountId,O=e.patToken??P?.patToken,z=x==="cloud"?e.modelInfo??P?.modelInfo:void 0;if(I=new ko({agentId:e.agentId,framework:e.framework,workspace:S,model:y.model??pt,deployType:x,...C?{accountId:C}:{},...O?{patToken:O}:{},...z?{modelInfo:z}:{}}),I.status="ok",P?.sessions){let V=e.framework==="hermes"||x==="local"&&(e.framework==="claude-code"||e.framework==="codex");for(let[X,oe]of Object.entries(P.sessions)){let ae={acpSessionId:oe.acpSessionId,modelToken:oe.modelToken,tokenGeneratedAt:oe.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};V?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:X,framework:e.framework,fallback:ae.permissionMode})):In(e.framework,oe.permissionMode)?ae.permissionMode=oe.permissionMode:fe.warn("autoRevive: dropping invalid persisted permissionMode",{agentId:e.agentId,cloudId:X,framework:e.framework,value:oe.permissionMode}):oe.permissionMode!==void 0&&fe.info("autoRevive: dropping persisted permissionMode (gate disabled)",{agentId:e.agentId,cloudId:X,framework:e.framework,deployType:x}),oe.cozeGroupId&&(ae.cozeGroupId=oe.cozeGroupId),I.sessions.set(X,ae)}let ie=Object.keys(P.sessions).length;ie>0&&fe.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:ie})}this.registry.register(I),A=!0;let F={agentId:e.agentId,framework:e.framework,workspace:S,cozeIdentity:e.cozeIdentity,createdAt:P?.createdAt??Date.now(),sessions:P?.sessions??{},model:y.model};x==="cloud"&&(F.deployType="cloud"),C&&(F.accountId=C),O&&(F.patToken=O),z&&(F.modelInfo=z),P?.skills&&(F.skills=P.skills),P?.agentName&&(F.agentName=P.agentName),P?.description&&(F.description=P.description),F.skillsRefreshedForVersion=P?.skillsRefreshedForVersion??Nt,e.framework==="openclaw"&&x==="cloud"&&(this.config.frameworksCache?.openclaw?.path?(await this.bootstrapOpenclawEnvIfNeeded(),await this.getOpenclawConfig().ensureAgent(e.agentId,S)):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 V=[...F.skills??[]],ie=new Map(V.map((ae,R)=>[ae.skillId,R])),X=await Promise.allSettled(Z.map(ae=>_o({agentId:e.agentId,workspace:S,framework:e.framework,skill:ae,paths:this.paths}))),oe=0;for(let[ae,R]of X.entries()){let q=Z[ae];q&&(R.status==="fulfilled"?(yo(V,ie,R.value),oe++):fe.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:q.skillId,skillName:q.skillName,err:String(R.reason)}))}oe>0&&(F.skills=V,fe.info("initialSkills installed",{agentId:e.agentId,installed:oe,requested:Z.length}))}return await Ue(F,this.paths),fe.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:x}),{ok:!0,agentId:e.agentId,workspace:S,framework:e.framework}}catch(T){throw fe.error("agent create failed, rolling back",{agentId:e.agentId,err:String(T)}),A&&I&&(await I.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await PE(u.root,{recursive:!0,force:!0}).catch(P=>fe.warn("rm agent dir failed (ignored)",{err:String(P)})),T instanceof k?T:new k("AGENT_SPAWN_FAILED",String(T),{cause:T})}finally{clearTimeout(v)}}async spawnSessionDownstream(e,r,i,o,c){let u=this.config.frameworksCache?.[e.framework];if(!u)if(e.deployType==="cloud"&&pl(e.framework))u=BE;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`);pl(e.framework)&&!_s(e.framework)&&(fe.info("spawn: resolving acp wrapper",{agentId:e.agentId,framework:e.framework}),await cr(e.framework));let x=e.deployType==="cloud"?{model:e.model,modelToken:r,...e.modelInfo?{modelInfo:e.modelInfo}:{}}:void 0,h;if(e.framework==="openclaw")h=await this.buildOpenclawDownstream({session:e,modelConfig:x,cloudSessionId:i,cozeEnv:o,mockScenario:c,command:u.path});else if(e.framework==="hermes"){let m={...this.buildBinShimPathEnv()};x&&(await a0({paths:this.paths,agentId:e.agentId,modelConfig:x,cozeEnv:o,mockScenario:c}),m.HERMES_HOME=$n(e.agentId,this.paths)),h=this.factory(e.framework,u.path,e.workspace,e.agentId,x,i,o,c,m)}else{let m=e.sessions.get(i),w=Yt(e)?m?.permissionMode??ix:"full-access";h=this.factory(e.framework,u.path,e.workspace,e.agentId,x,i,o,c,this.buildBinShimPathEnv(),w)}try{return await h.start(),await h.initialize(zE),h}catch(m){let w=h instanceof gt?h.getStderrTail():[];throw w.length>0&&fe.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:m instanceof k?m.code:"unknown",recentStderr:w}),await h.stop("spawnSessionDownstream failed").catch(()=>{}),await this.resolveSpawnFailure(e,u.path,m)}}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",rx(o),{cause:{reason:nx}})}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 r=await this.detectorFactory().detect("openclaw");if(r?.defaultAgent?.id&&r.defaultAgent.workspace)return fe.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:FE}})}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",rx(r),{cause:{reason:nx}})}async buildOpenclawDownstream(e){let{session:r,modelConfig:i,cloudSessionId:o,cozeEnv:c,mockScenario:d,command:u}=e,x=xl(o);if(r.deployType==="local"){let S=await this.ensureOpenclawDefaultAgent();return new Fr({command:u,cwd:S.workspace,agentId:S.id,sessionName:x})}let h=await tx(),m=i?t0(i,c,d):null,w;if(m){let S=Qc(o),v=m.models[0]?.id??pt,I=`${S}/${v}`;if(!this.ensuredProviders.has(I)){let A=this.getOpenclawConfig();await A.ensureProvider(S,m),await A.addModelToAllowlist(I),this.ensuredProviders.add(I)}w=I}return new Fr({command:u,cwd:r.workspace,agentId:r.agentId,sessionName:x,...h?{gatewayToken:h}:{},...w?{slashModelOnStart:w}:{}})}async openclawRepair(e,r){let i=this.getOpenclawConfig();await i.deleteAgent(e),await i.ensureAgent(e,r)}async cleanupOpenclawSessionProviders(e){if(e.framework!=="openclaw"||!this.openclawConfigCache)return;let r=this.openclawConfigCache;for(let i of e.sessions.keys()){let o=Qc(i),c=`${o}/${e.model}`,d=!0;try{await r.removeProvider(o)}catch(u){d=!1,fe.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:o,err:String(u)})}try{await r.removeModelFromAllowlist(c)}catch(u){d=!1,fe.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:c,err:String(u)})}d&&this.ensuredProviders.delete(c)}}};import{randomUUID as dx}from"node:crypto";import{promises as $E}from"node:fs";import{basename as ux}from"node:path";$e();re();import{promises as GE}from"node:fs";import{basename as HE}from"node:path";var ox=j("file-upload"),qE="/api/coze_claw/file/agent_upload",jE=6e4;async function ax(t,e={}){let i=`${Rr(Cr(e.handshakeBase))}${qE}`,o=e.timeoutMs??jE,c=await GE.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",...bn(e.ppeOverride),...t.accountId?{"x-coze-account":t.accountId}:{}},x=new AbortController,h=setTimeout(()=>x.abort(),o);ox.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:x.signal}),w=m.headers.get("x-tt-logid")??"";if(!m.ok){let v=await m.text().catch(()=>"");throw new k("UPLOAD_FAILED",`upload HTTP ${m.status} logid=${w}: ${v.slice(0,200)}`)}let S=await m.json();if(S.code!==void 0&&S.code!==0)throw new k("UPLOAD_FAILED",`upload code=${S.code} msg=${S.msg??"-"} logid=${w}`);let _=S.data?.file?.file_url;if(!_)throw new k("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${w}: ${JSON.stringify(S).slice(0,200)}`);return ox.info("file upload ok",{uri:_,logid:w}),{uri:_}}catch(m){throw m instanceof k?m:m.name==="AbortError"?new k("UPLOAD_FAILED",`upload timeout (${o}ms) for ${HE(t.path)}`):new k("UPLOAD_FAILED",String(m),{cause:m})}finally{clearTimeout(h)}}$e();re();import{extname as WE}from"node:path";var KE={".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 cx(t){let e=WE(t).toLowerCase();return KE[e]??"application/octet-stream"}De();var Do=j("agent-send"),lx=50*1024*1024;function fx(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 xx(t,e,r,i,o,c){let u;for(let x=0;x<=2;x++)try{await t.core.sendAgentFileUpdate(e,r,i,o);return}catch(h){u=h,x<2&&(Do.warn("sendAgentFileUpdate failed, retrying",{attempt:x+1,err:String(h)}),await new Promise(m=>setTimeout(m,5e3)))}throw new k("UPSTREAM_NOT_READY",`${c} after 3 attempts: ${String(u)}`,{cause:u})}async function hx(t,e){let{session:r,runtime:i}=fx(e.core,t.agentId,t.sessionId);if(!await oi(t.path,r.workspace))throw new k("PATH_OUTSIDE_WORKSPACE",`path=${t.path} not under workspace=${r.workspace}`);let o=await $E.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>lx)throw new k("FILE_TOO_LARGE",`${o.size} bytes > limit ${lx}`);let c=await cx(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??ux(t.path),u;try{u=await ax({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(h){throw Do.warn("agent file upload failed",{agentId:t.agentId,sessionId:t.sessionId,path:t.path,sizeBytes:o.size,mime:c,code:h instanceof k?h.code:"UNKNOWN",message:h instanceof Error?h.message:String(h)}),h}let x={sessionUpdate:"agent_file",messageId:dx(),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 xx(e,r,i,t.sessionId,x,"agent file uploaded to cloud but sendAgentFileUpdate failed"),Do.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 px(t,e){let{session:r,runtime:i}=fx(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??ux(t.path),c={sessionUpdate:"group_file",messageId:dx(),content:{uri:t.path,name:o,mimeType:t.mimeType,...t.caption!==void 0?{caption:t.caption}:{}}};return await xx(e,r,i,t.sessionId,c,"agent group file sendAgentFileUpdate failed"),Do.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 gx(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}cn();Jt();re();var Mt=j("coze-cli-installer"),mx="@coze/cli@latest",VE="coze",_x="0.1.8",ZE=5e3,JE=5e3,YE=9e4,yx=1e4,Yi=null,Po=!1;async function _l(t,e={}){if(Po)return;if(Yi)return Yi;let r=e.exec??qf;return Yi=(async()=>{try{let i=await XE(VE,r),o=!1;if(i){let d=await QE(r);if(d===void 0)Mt.warn("coze-cli found but version unparseable, fall through to full install",{path:i});else if(gx(d,_x))Mt.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:i,version:d,min:_x}),o=!0;else{Mt.info("coze-cli already on PATH with sufficient version, skip",{path:i,version:d}),Po=!0;return}}let c=o?"upgrade-only":"full";Mt.info("coze-cli install start",{package:mx,mode:c});try{await r("npm",["i","-g","--prefer-online",mx],{timeout:YE,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){Po=!0;return}if(t.env)try{await r("coze",["config","set","xTTEnv",t.env],{timeout:yx}),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 r("coze",["auth","login","--token",t.patToken],{timeout:yx}),Mt.info("coze auth login ok")}catch(d){Mt.warn("coze auth login failed",{err:String(d)});return}Po=!0}finally{Yi=null}})(),Yi}async function XE(t,e){let r=process.platform==="win32"?"where":"which";try{let{stdout:i}=await e(r,[t],{timeout:ZE});return Fa(i)}catch{return}}async function QE(t){try{let{stdout:e,stderr:r}=await t("coze",["--version"],{timeout:JE});return(e||r).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}qt();Ht();De();var eb=10*6e4;function Ex(t){let e=t?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?eb:e}function Oo(t){return lr(t??J().configFile)}function Xi(t,e){return dr(e??J().configFile,t)}import{randomBytes as yb}from"node:crypto";sr();$e();re();import{createReadStream as tb}from"node:fs";import{mkdir as nb,readFile as rb,realpath as ib,stat as sb,writeFile as ob}from"node:fs/promises";import{basename as ab,dirname as yl,isAbsolute as cb,join as lb,relative as db,resolve as bx,sep as ub}from"node:path";import{createInterface as fb}from"node:readline";var Sx=j("fs-rpc"),Qi=Ye("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function Ix(t,e){let r=Buffer.byteLength(t.content,"utf8");if(r>Qi)throw new k("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${r} bytes > limit ${Qi} bytes`);let i=await kx(t.path,e);return await nb(yl(i),{recursive:!0}),await ob(i,t.content,"utf8"),Sx.info("fs/write_text_file ok",{path:i,size:t.content.length}),null}async function Ax(t,e){let r=await kx(t.path,e),i=await sb(r),o=typeof t.line=="number"||typeof t.limit=="number";if(i.size>Qi&&!o)throw new k("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${i.size} bytes > ${Qi} bytes`);let c;if(o&&i.size>Qi)c=await xb(r,t.line??1,t.limit);else{let d=await rb(r,"utf8");if(o){let u=d.split(`
|
|
104
|
+
`),x=Math.max(0,(t.line??1)-1),h=typeof t.limit=="number"?x+t.limit:void 0;c=u.slice(x,h).join(`
|
|
105
|
+
`)}else c=d}return Sx.info("fs/read_text_file ok",{path:r,size:c.length}),{content:c}}async function xb(t,e,r){let i=fb({input:tb(t,{encoding:"utf8"}),crlfDelay:Number.POSITIVE_INFINITY}),o=Math.max(0,e-1),c=typeof r=="number"?o+r:Number.POSITIVE_INFINITY,d=[],u=0;try{for await(let x of i)if(u>=o&&u<c&&d.push(x),u++,u>=c)break}finally{i.close()}return d.join(`
|
|
106
|
+
`)}async function kx(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([vx(bx(e)),vx(bx(t))]),o=db(r,i);if(hb(o,ub,cb(o)))throw new k("IPC_BAD_REQUEST",`path escapes workspace: ${t}`);return i}function hb(t,e,r){return t===""?!1:r?!0:t===".."||t.startsWith(`..${e}`)}async function vx(t){let e=[],r=t;for(;r!==yl(r);)try{let i=await ib(r);return e.length?lb(i,...e.reverse()):i}catch{e.push(ab(r)),r=yl(r)}return t}re();var Tx=j("prompt-multimodal"),Rx=10*1024*1024,pb=15e3,gb=6;async function Cx(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 mb(d))}}let o=Array.from({length:Math.min(gb,t.length)},()=>i());return await Promise.all(o),e}function Dx(t){return t.some(e=>e.type==="image")}async function mb(t){if(t.type!=="image")return t;let e=t;if(e.data||!e.uri||!Ni(e.uri))return t;try{let{buf:r,contentType:i}=await _b(e.uri),o=e.mimeType||wb(i)||"application/octet-stream";return Tx.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 Tx.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(r)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function wb(t){if(!t)return;let e=t.indexOf(";");return(e===-1?t:t.slice(0,e)).trim()||void 0}async function _b(t){let e=new AbortController,r=setTimeout(()=>e.abort(),pb);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>Rx)throw new Error(`image too large: ${o.byteLength} bytes (max ${Rx})`);return{buf:Buffer.from(o),contentType:i.headers.get("content-type")??void 0}}finally{clearTimeout(r)}}qt();$e();re();var $=j("core"),Eb=3e4,bb=/^(boe|ppe)_[A-Za-z0-9_-]+$/,vb="\u6211\u6B63\u5728\u7B49\u5F85\u5BA1\u6279\uFF0C\u8BF7\u7A0D\u540E\u518D\u8054\u7CFB\u6211",Sb="\u5BA1\u6279\u5DF2\u8D85\u65F6",Ib=3e4,Lo=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upstreamIds=new Nr;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=Ex(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(),$.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){$.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),$.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let r of this.registerHandlers)try{r(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,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)=>{$.info("session runtime exited",{agentId:e.agentId,cloudId:r,code:c,signal:d}),Ji(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){$.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(Sn(o,{code:Y.INTERNAL_ERROR,message:`bridge downstream gone: ${r}`})).catch(d=>$.debug("send error response to upstream failed (ignored)",{err:String(d)}));try{c.downstream.respondAgentRequestError(c.agentRequestId,{code:Y.INTERNAL_ERROR,message:`bridge: ${r}`})}catch{}}}}}rejectAllPendingOnReconnect(){let e=this.pendingUpstream.size,r=this.pendingBridge.size;if(!(e===0&&r===0)){$.warn("upstream reconnected, rejecting stale pending requests",{pendingUpstream:e,pendingBridge:r});for(let[,i]of this.pendingUpstream){try{i.downstream.respondAgentRequestError(i.agentRequestId,{code:Y.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(bo(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&&bb.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){r!==null?await this.sendError(r,Y.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):$.warn("drop notification: extension not registered",{method:e.method});return}let c=await o(e,this);r!==null&&await this.upstream.send(Lr(r,c));return}if(e.method.startsWith("session/")){let o=await this.routeSessionMethod(e);r!==null&&await this.upstream.send(Lr(r,o));return}if(e.method==="initialize"){r!==null&&await this.upstream.send(Lr(r,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}r!==null?await this.sendError(r,Y.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)}),r!==null&&await this.upstream.send(Sn(r,$i(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 x=o.sessions.get(c);if(x?.pendingPermission){let h=r._meta?.cozeTriggerMsgId,m=ho(r._meta);return $.info("session in pendingPermission, bouncing new prompt",{agentId:o.agentId,cloudSessionId:c}),this.synthesizePromptReply(o,x,c,vb,h,m)}}let d=Date.now(),u=!1;try{let x=await o.getSessionQueue(c).enqueue(()=>this.dispatchSessionCall(o,e.method,r));return u=!0,x}finally{$.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}=Uf(i);switch(r){case"session/new":{let c=Ab();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)?zf(i._meta):void 0;if(u!==void 0&&!In(e.framework,u))throw new k("IPC_BAD_REQUEST",`unsupported permissionMode for ${e.framework}: ${u}; allowed: ${fl(e.framework)}`);let x=await this.ensureRuntime(e,d);if(u!==void 0&&x.permissionMode===void 0&&(x.permissionMode=u,await this.persistSessionMapping(e)),x.replySeq=0,await this.ensureDownstream(e,d,x),!x.downstream||!x.acpSessionId)throw new k("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");if(u!==void 0&&x.permissionMode!==void 0&&x.permissionMode!==u){let S=x.permissionMode;x.permissionMode=u,await this.persistSessionMapping(e);try{await x.downstream.setSessionMode({sessionId:x.acpSessionId,modeId:u})}catch(_){throw x.permissionMode=S,await this.persistSessionMapping(e).catch(()=>{}),_}}let h=i._meta?.cozeTriggerMsgId;h?e.activeTriggers.set(x.acpSessionId,h):e.activeTriggers.delete(x.acpSessionId);let m=ho(i._meta);if(m?e.activeGroupIds.set(x.acpSessionId,m):e.activeGroupIds.delete(x.acpSessionId),m&&x.cozeGroupId!==m&&(x.cozeGroupId=m,await this.persistSessionMapping(e)),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&Dx(c.prompt))throw new k("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let w=await Cx(c.prompt);try{let S=await x.downstream.sessionPrompt({...c,sessionId:x.acpSessionId,prompt:w});return x.lastActiveAt=Date.now(),S}catch(S){if(S instanceof k&&S.code==="AGENT_APPROVAL_TIMEOUT"){let _=x.pendingPermission;_&&(_.downstream.respondAgentRequest(_.agentRequestId,{outcome:{outcome:"cancelled"}}),this.pendingUpstream.delete(_.upstreamId),x.pendingPermission=void 0);let v=x.acpSessionId,I=v?e.activeTriggers.get(v):void 0,A=v?e.activeGroupIds.get(v):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,x,d,Sb,I,A)}throw S}finally{if(e.activeTriggers.delete(x.acpSessionId),e.activeGroupIds.delete(x.acpSessionId),x.pendingPermission=void 0,x.reloadAfterTurn){x.reloadAfterTurn=!1;let S=x.downstream;S&&(x.downstream=void 0,$.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:d,acpId:x.acpSessionId}),S.stop("reload-after-turn").catch(_=>$.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:d,err:String(_)})))}else x.downstream?.isAlive()&&this.armIdleTimer(e,d,x)}}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 x=e.getSessionQueue(d);x.size>0&&($.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:d,queuedCount:x.size}),x.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,x=ho(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(!In(e.framework,u))throw new k("IPC_BAD_REQUEST",`unsupported modeId for ${e.framework}: ${String(u)}; allowed: ${fl(e.framework)}`);if(x)return await this.handleGroupSetMode(e,x,u);let h=e.sessions.get(d)??await this.ensureRuntime(e,d);if(h.permissionMode===u)return{};let m=h.permissionMode;if(h.permissionMode=u,await this.persistSessionMapping(e),h.downstream?.isAlive()&&h.acpSessionId)try{await h.downstream.setSessionMode({sessionId:h.acpSessionId,modeId:u})}catch(w){throw h.permissionMode=m,await this.persistSessionMapping(e).catch(()=>{}),w}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: ${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 $.info("group session/set_mode: no active runtime (db-only path)",{framework:e.framework,agentId:e.agentId,groupId:r,modeId:i}),{};$.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,x=d.runtime.acpSessionId;u?.isAlive()&&x&&c.push({downstream:u,acpSessionId:x,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 x of o)x.runtime.permissionMode=x.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 Yt(e)&&(e.framework==="hermes"?c.permissionMode=e.deployType==="cloud"?i0:s0:c.permissionMode=e.framework==="claude-code"?ml:sx),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(ht.GEN_MODEL_TOKEN,i,Ib);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(Ji(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 x;try{x=await this.sessionSpawner(e,i.modelToken,r,this.currentCozeEnv,this.currentMockScenario)}catch(h){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:r,staleAcpId:i.acpSessionId}),i.acpSessionId=void 0),h}i.spawnFailCount=0,i.spawnFailedAt=void 0,i.downstream=x,this.attachRuntimeHooks(e,r,i);try{if(i.acpSessionId){i.loadingSession=!0;try{await x.sessionLoad({sessionId:i.acpSessionId,cwd:e.workspace}),$.info("session restored via session/load",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId})}catch(h){$.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId,err:String(h)}),i.acpSessionId=void 0;let m=await x.sessionNew({cwd:e.workspace});i.acpSessionId=m.sessionId,await this.persistSessionMapping(e)}finally{i.loadingSession=!1}}else{let h=await x.sessionNew({cwd:e.workspace});i.acpSessionId=h.sessionId,await this.persistSessionMapping(e)}}catch(h){throw $.warn("session init failed after spawn, tearing down half-spawned runtime",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId,err:String(h)}),await x.stop("session-init-failed").catch(()=>{}),i.downstream=void 0,i.acpSessionId=void 0,h}if(x.afterSessionEstablished&&i.acpSessionId&&await x.afterSessionEstablished(i.acpSessionId),Yt(e)&&i.acpSessionId&&i.permissionMode)try{await x.setSessionMode({sessionId:i.acpSessionId,modeId:i.permissionMode})}catch(h){$.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(h)})}}armIdleTimer(e,r,i){if(Ji(i),this.isRuntimeBusy(e,i)){$.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)){$.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:r}),this.armIdleTimer(e,r,i);return}$.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=>$.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(Or("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(Or("session/update",{sessionId:i,update:{sessionUpdate:"agent_message_chunk",content:{type:"text",text:o}},_meta:u})).catch(x=>$.warn("synthesizePromptReply update send failed (ignored)",{err:String(x)})),{stopReason:"end_turn"}}forwardUpdate(e,r){let i=r.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(Rb(r)){$.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"&&Yt(e)){let m=d.currentModeId;In(e.framework,m)&&c.permissionMode!==m?(c.permissionMode=m,this.persistSessionMapping(e).catch(w=>$.warn("persist mode (from current_mode_update) failed",{framework:e.framework,agentId:e.agentId,err:String(w)}))):typeof m=="string"&&!In(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},x=e.activeTriggers.get(i);x&&(u.cozeTriggerMsgId=x);let h=e.activeGroupIds.get(i);h&&(u.cozeGroupId=h),this.upstream.send(Or("session/update",{...r,sessionId:o,_meta:u})).catch(m=>$.warn("forward update failed",{agentId:e.agentId,err:String(m)}))}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}$.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:i.method}),r.respondAgentRequestError(i.id,{code:Y.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 Ix(c,o);r.respondAgentRequest(i.id,d)}else{let c=i.params??{},d=await Ax(c,o);r.respondAgentRequest(i.id,d)}}catch(o){$.warn("fs rpc handler failed",{agentId:e.agentId,method:i.method,err:String(o)}),r.respondAgentRequestError(i.id,$i(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,x=u?e.activeTriggers.get(u):void 0,h={cozeAgentId:e.agentId};x&&(h.cozeTriggerMsgId=x);let m=u?e.activeGroupIds.get(u):void 0;m&&(h.cozeGroupId=m);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 _={...c,...w?{sessionId:w}:{},_meta:h};this.pendingUpstream.set(o,{agentRequestId:i.id,agentId:e.agentId,downstream:r,method:i.method,cloudSessionId: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(Wi(o,"session/request_permission",_)).catch(v=>{this.pendingUpstream.delete(o),$.error("forward permission request failed",{agentId:e.agentId,err:String(v)}),r.respondAgentRequestError(i.id,{code:Y.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?($.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"&&kb(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 Eo(e.error)):i.value.resolve(e.result);return}$.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 $.warn(`${i} id type mismatch: number received but Bridge expected string`,{rawId:r,normalizedId:c}),{value:d,key:c}}}sendRequest(e,r,i=Eb){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(Wi(o,e,r)).catch(x=>{let h=this.pendingBridge.get(o);h&&(clearTimeout(h.timer),this.pendingBridge.delete(o)),d(x)})})}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&&Yt(e)&&(c.permissionMode=o.permissionMode),o.cozeGroupId&&(c.cozeGroupId=o.cozeGroupId),r.set(i,c)}await ai(e.agentId,r,this.paths)}catch(r){$.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(Sn(e,{code:r,message:i,data:{bridgeVersion:Nt}}))}};function Ab(){return yb(16).toString("hex")}function kb(t,e){if(!t||typeof t!="object"){$.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:t});return}let r=t;if("kind"in r&&!("outcome"in r)){$.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"){$.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 Tb=["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."];function Rb(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{text:o}=i;return Tb.some(c=>o.startsWith(c))}Ht();re();De();import{randomBytes as Cb}from"node:crypto";import{createServer as Db}from"node:http";var Pb=1e6,Px=j("ipc"),No=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=Cb(32).toString("hex");let e=Db((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(),Px.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}`){es(r,401,{error:"unauthorized"});return}let o=`${e.method} ${(e.url??"").split("?")[0]}`,c=this.routes.get(o);if(!c){es(r,404,{error:"not found"});return}let d=null;if(e.method==="POST")try{d=await Ob(e)}catch(u){es(r,400,{error:"invalid json",detail:String(u)});return}try{let u=await c.handler(d,e);es(r,200,u??{ok:!0})}catch(u){Px.error("IPC handler failed",{key:o,err:String(u)}),es(r,500,{error:u instanceof Error?u.message:String(u)})}}};function es(t,e,r){t.statusCode=e,t.setHeader("content-type","application/json"),t.end(JSON.stringify(r))}async function Ob(t){let e=[],r=0;for await(let o of t){let c=o;if(r+=c.length,r>Pb)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 e1=Gt(kh(),1),t1=Gt(jo(),1),n1=Gt(Gr(),1),r1=Gt(Dl(),1),i1=Gt(Ll(),1),s1=Gt(Ul(),1),Mh=Gt(Vo(),1),o1=Gt(Nh(),1);var Bh=Mh.default;$e();re();var{FWS:b1}=Vh(),Le=j("upstream.frontier"),Jh="application/json",Yh="none",v1=15e3;function S1(t){class e extends Bh{constructor(i){super(i,Kf,{headers:t})}guardTeardown(){this.listenerCount("error")===0&&this.on("error",i=>Le.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(Rd("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");Le.debug("WS raw frame out",{bytes:c.byteLength,headHex:d})}catch(c){Le.warn("WS raw frame dump failed",{err:String(c)})}super.send(i,...o)}}return e}var ls=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){Le.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:$f,...bn(this.opts.ppeOverride)},r=S1(e),i=Zf(this.opts.urlOverride),o={url:i,ws:r,fpID:Wf,aID:po,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:Jh,force:!0},payloadEncoding:{encoding:Yh,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},c=new b1(o),d=!1,u=null,x,h,m=new Promise((_,v)=>{x=_,h=v}),w=_=>{d||(d=!0,u&&(clearTimeout(u),u=null),_?h(_):x())};c.onopen=()=>{this.opened=!0,this.openCount+=1;let _=this.openCount===1;Le.info("frontier opened",{url:i,remoteDeviceId:this.opts.handshake.deviceId,initial:_,openCount:this.openCount}),_&&w();for(let v of this.connectHandlers)Promise.resolve(v({initial:_})).catch(I=>Le.warn("onConnect handler threw (ignored)",{err:String(I)}))},c.onclose=_=>{this.opened=!1,Le.info("frontier closed",{code:_.code,reason:_.reason,willReconnect:_.willReconnect})},c.onerror=_=>{Le.warn("frontier error",{code:_.code,msg:_.message}),w(new k("UPSTREAM_DISCONNECTED",`frontier connect error before open: code=${_.code} msg=${_.message??""}`))},c.onmessage=_=>this.handleMessage(_),this.fws=c;let S=this.opts.openTimeoutMs??v1;u=setTimeout(()=>{w(new k("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${S}ms (handshake or upgrade slow)`))},S),await c.connect();try{await m}catch(_){try{c.close(1e3,"open failed")}catch(v){Le.warn("fws close during start failure threw (ignored)",{err:String(v)})}throw this.fws=null,this.opened=!1,_}}async stop(e){let r=this.fws;if(r){this.fws=null,this.opened=!1;try{r.close(1e3,e??"bridge shutdown")}catch(i){Le.warn("frontier close threw (ignored)",{err:String(i)})}}}async send(e){let r=this.fws,i=e.method;if(!r)throw Le.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?(Le.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;Xh(c)||Le.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:o.length});try{await r.send(o,{service:33555712,method:1,payloadType:Jh,payloadEncoding:Yh})}catch(u){throw Le.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){Le.debug("drop non-adapter frontier frame",{service:r});return}let i=k1(e);if(!i){Le.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){Le.debug("frame received but no onFrame handler",{size:i.length});return}let o;try{o=JSON.parse(i)}catch(d){Le.warn("frontier message JSON parse failed",{err:String(d),head:i.slice(0,80)});return}let c=o;Xh(c)||Le.info("frontier frame in",{logid:A1(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:c.id,method:c.method,body:I1(i)}),Promise.resolve(this.handler(o)).catch(d=>Le.warn("frontier frame handler threw",{err:String(d)}))}};function Xh(t){return t.method==="_agent/health"?!0:typeof t.id=="string"&&t.id.startsWith("agent.health_")}var Qh=2e3;function I1(t){return t.length<=Qh?t:`${t.slice(0,Qh)}...<truncated, total ${t.length} chars>`}function A1(t){return t?t.high===0?String(t.low>>>0):`${t.high.toString(16)}${(t.low>>>0).toString(16).padStart(8,"0")}`:""}function k1(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}}$e();re();var jl=j("skill-publish"),T1="/api/marketplace/product/skill/publish_with_assets",R1=15e4;async function ep(t,e={}){let i=`${Rr(Cr(e.handshakeBase))}${T1}`,o=e.timeoutMs??R1,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",...bn(e.ppeOverride),...t.accountId&&t.accountId!=="0"?{"x-coze-account":t.accountId}:{}},u=new AbortController,x=setTimeout(()=>u.abort(),o);jl.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 h=await fetch(i,{method:"POST",headers:d,body:c,signal:u.signal}),m=h.headers.get("x-tt-logid")??"";if(!h.ok){let _=await h.text().catch(()=>"");throw new k("UPLOAD_FAILED",`skill publish HTTP ${h.status} logid=${m}: ${_.slice(0,200)}`)}let w=await h.json();if(jl.info("skill publish response",{logid:m,httpStatus:h.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=${m}`);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),jl.info("skill publish ok",{logid:m,skillId:S.skillId??"",version:S.version??""}),S}catch(h){throw h instanceof k?h:h.name==="AbortError"?new k("UPLOAD_FAILED",`skill publish timeout (${o}ms): ${t.skillName}`):new k("UPLOAD_FAILED",String(h),{cause:h})}finally{clearTimeout(x)}}re();var Wl=j("upstream.switchable"),ra=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,r){if(this.inner===e)return;Wl.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 Wl.error("swap target start failed, reverting",{err:String(o)}),this.inner=i,o}await i.stop(r??"swapped").catch(o=>Wl.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()}};re();var Kl=j("upstream"),$r=class{handler=null;async start(){Kl.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){Kl.info("NoopUpstream stopped",{reason:e})}async send(e){Kl.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();re();Ht();re();De();import{promises as C1}from"node:fs";var tp=j("pat-token-store");async function ia(t=J()){try{let r=(await C1.readFile(t.patTokenFile,"utf8")).trim();return r.length===0?(tp.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"&&tp.warn("read pat-token failed (treating as missing)",{path:t.patTokenFile,code:r,message:e.message}),null}}async function ds(t,e=J()){if(!t)throw new Error("writePatToken: empty patToken");await ut(e.patTokenFile,t,{mode:384})}De();De();import{promises as sa}from"node:fs";import{join as D1}from"node:path";function P1(t,e){return`#!/bin/sh
|
|
107
107
|
exec ${JSON.stringify(e)} ${JSON.stringify(t)} "$@"
|
|
108
|
-
`}function
|
|
108
|
+
`}function O1(t,e){return`@echo off\r
|
|
109
109
|
"${e}" "${t}" %*\r
|
|
110
|
-
`}async function np(t,e=J()){let r=e.binDir;await
|
|
110
|
+
`}async function np(t,e=J()){let r=e.binDir;await sa.mkdir(r,{recursive:!0});let i=D1(r,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),o=process.execPath,c=process.platform==="win32"?O1(t,o):P1(t,o);return await sa.readFile(i,"utf8").catch(()=>null)===c||(await sa.writeFile(i,c,"utf8"),process.platform!=="win32"&&await sa.chmod(i,493)),r}re();De();import{execSync as rp}from"node:child_process";import{readFileSync as ip,unlinkSync as L1}from"node:fs";import{mkdir as N1,open as M1,readFile as sp,unlink as $l,writeFile as B1}from"node:fs/promises";import{dirname as F1}from"node:path";var z1=j("single-instance"),U1=t=>new Promise(e=>setTimeout(e,t)),oa=class{pidFile;selfPid;probe;claimLockMaxAttempts;claimLockIntervalMs;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??J().pidFile,this.selfPid=e.selfPid??process.pid,this.claimLockMaxAttempts=e.claimLockMaxAttempts??50,this.claimLockIntervalMs=e.claimLockIntervalMs??20,this.probe=e.probe??{isAlive:r=>Vi(r),isDaemon:r=>this.matchesDaemonTitle(r)},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 r=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&&z1.warn("removing stale pid file",{stalePid:i}),await B1(this.pidFile,String(this.selfPid),"utf8"),{kind:"acquired"})});return r.kind==="acquired"&&(this.acquired=!0,this.installCleanupHooks()),r}async release(){if(this.acquired){try{(await sp(this.pidFile,"utf8")).trim()===String(this.selfPid)&&await $l(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 r=await sp(e,"utf8"),i=Number.parseInt(r.trim(),10);return Number.isFinite(i)&&i>0?i:null}catch(r){if(r.code==="ENOENT")return null;throw r}}async withClaimLock(e){let r=`${this.pidFile}.lock`;await N1(F1(r),{recursive:!0});for(let i=0;i<this.claimLockMaxAttempts;i++){let o;try{o=await M1(r,"wx")}catch(c){if(c.code!=="EEXIST")throw c;let d=await this.readPidFrom(r);if(d!==null&&d!==this.selfPid&&this.probe.isAlive(d)){await U1(this.claimLockIntervalMs);continue}await $l(r).catch(()=>{});continue}try{return await o.writeFile(String(this.selfPid)),await e()}finally{await o.close().catch(()=>{}),await $l(r).catch(()=>{})}}throw new Error(`failed to acquire claim lock: ${r} (after ${this.claimLockMaxAttempts} attempts)`)}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let r=ip(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(r.includes(Mr)||r.includes("lib/index.js"))}catch{}try{let r=rp(`ps -o command= -p ${e}`,{stdio:["ignore","pipe","ignore"],timeout:1e3}).toString();return r.trim()?r.includes(Mr)||r.includes("lib/index.js"):!1}catch{return!0}}matchesDaemonTitleWindows(e){try{let i=rp(`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{ip(this.pidFile,"utf8").trim()===String(this.selfPid)&&L1(this.pidFile)}catch{}})}};aa();re();var er=j("daemon.upstream-watchdog"),V1=12e4,Z1=9e5,J1=3e4;function Zl(t,e){let r=process.env[t];if(!r)return e;let i=Number(r);return Number.isFinite(i)&&i>0?i:e}var ca=class{constructor(e){this.opts=e;this.softMs=e.softMs??Zl("COZE_BRIDGE_UPSTREAM_WATCHDOG_SOFT_MS",V1),this.hardMs=e.hardMs??Zl("COZE_BRIDGE_UPSTREAM_WATCHDOG_HARD_MS",Z1),this.intervalMs=e.intervalMs??Zl("COZE_BRIDGE_UPSTREAM_WATCHDOG_INTERVAL_MS",J1),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?.(),er.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&&er.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&&er.info("upstream watchdog: reconnected, reset",{downMs:this.now()-this.downSince}),this.downSince=null,this.forcedAt=null;return}if(this.downSince===null){this.downSince=e,er.warn("upstream watchdog: disconnect detected, arming",{softMs:this.softMs,hardMs:this.hardMs});return}let r=e-this.downSince;if(r>=this.hardMs){er.error("upstream watchdog: disconnected too long, exiting for supervisor restart",{downMs:r,hardMs:this.hardMs}),this.opts.onFatal(r);return}r>=this.softMs&&this.shouldForceNow(e)&&(this.forcedAt=e,this.forcing=!0,er.warn("upstream watchdog: forcing reconnect",{downMs:r,softMs:this.softMs}),Promise.resolve().then(()=>this.opts.forceReconnect()).catch(i=>er.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=j("daemon");async function cp(){let t=J();if(process.env.COZE_BRIDGE_LOG_MODE!=="legacy"){kd({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
|
|
111
111
|
\u8BF7\u67E5\u770B: ${t.bridgeLogsDir}/bridge-<YYYY-MM-DD>.log
|
|
112
112
|
\u6216\u4F7F\u7528: coze-bridge log [-f] [--lines N]
|
|
113
|
-
`)}catch{}}let e=new ia({processTitle:Nr}),r=await e.acquire();if(r.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${r.pid})`);let i=await Po(),o=i??{};ps({pid:process.pid}),q.info(i?"loaded bridge config":"initialized bridge config");let c=new ta(new Kr),l=null,u=new Do({upstream:c,paths:t,bridgeConfig:o,sessionSpawner:async(C,U,G,ee)=>{if(!l)throw new Error("agentManager not ready");return l.spawnSessionDownstream(C,U,G,ee)}}),f=new ko({paths:t,config:o,registry:u});l=f;let x,p,m=null,v={},_,b=null,I=null,A=null,k=new In;function P(C,U){return k.enqueue(()=>R(C,U))}function y(){I||(I=new oa({isConnected:()=>c.isConnected()&&!(b?.isLivenessLost()??!1),forceReconnect:()=>A?P(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 R(C,U){let G=C,ee=G?.privatecode;if(!ee)throw new T("IPC_BAD_REQUEST","/connect requires privatecode");let Ve=Bi(G.env),xe=G.handshake_url,pe=G.frontier_url,It=ap(G.env,xe,pe);if(A=G,!U?.force&&x===ee&&p===It){let we=await YS(t);return u.agents.size===0&&we?(q.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),ca(t,f).catch(Ae=>q.warn("connect-noop auto-revive error (ignored)",{err:String(Ae)}))):q.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let gt=!!x&&x!==ee,tn=p!==void 0&&p!==It,Ft=gt||tn,nn=await Vc({privatecode:ee,...xe?{endpoint:xe}:{},ppeOverride:Ve});if(Ft){q.warn("connect config switched, resetting agents",{pcChanged:gt,envChanged:tn,previousPc:x?aa(x):"",nextPc:aa(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 Kr,"connect switch").catch(()=>{})}m=nn.deviceId,ps({deviceId:m,pid:process.pid}),ml({patToken:ee,env:G.env}).catch(we=>q.warn("coze-cli setup error (ignored)",{err:String(we)}));let Yr=new os({handshake:nn,privatecode:ee,...pe?{urlOverride:pe}:{},ppeOverride:Ve,getPatTokenForAgent:we=>u.agents.get(we)?.patToken});return await c.swap(Yr,"connect"),x=ee,p=It,v=Ve,_=xe,G.mock_scenario!==void 0&&(u.setMockScenario(G.mock_scenario),q.info("mock scenario set",{scenario:G.mock_scenario})),b||(b=new Hi({core:u,getDeviceId:()=>m??"",onTickEnd:()=>M.retryPending().catch(we=>q.warn("detailSync.retryPending failed (ignored)",{err:String(we)})),onAuthFailures:V})),b.start(),y(),Ft&&ca(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:m}),{ok:!0,note:"connected"}}u.registerExtension("_agent/create",async C=>f.createAgent(C.params)),u.registerExtension("_agent/health",async()=>({ok:!0}));let O={},F=new go({agents:u.agents,paths:t,publishSkillToMarketplace:async C=>{let U=u.agents.get(C.agentId)?.patToken??x;if(!U)throw new T("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");return ep({patToken:U,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:_,ppeOverride:v})},disposeAndMarkDisconnected:async(C,U)=>{let G=u.agents.get(C);if(G){await f.cleanupOpenclawSessionProviders(G).catch(Ve=>q.warn("cleanup openclaw providers failed (ignored)",{agentId:C,err:String(Ve)})),G.framework==="hermes"&&G.deployType==="cloud"&&await el(C,t).catch(Ve=>q.warn("cleanup hermes-home failed (ignored)",{agentId:C,err:String(Ve)}));let ee=!0;try{await G.dispose(`disconnect: ${U}`)}catch(Ve){ee=!1,q.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:C,err:String(Ve)}),G.status="error"}ee&&(G.status="disconnected",u.unregister(C),u.disconnectedAgents.add(C))}else u.disconnectedAgents.add(C)},disposeForDelete:async(C,U)=>{let G=u.agents.get(C);G&&(await f.cleanupOpenclawSessionProviders(G).catch(ee=>q.warn("cleanup openclaw providers during delete failed (ignored)",{agentId:C,err:String(ee)})),G.framework==="hermes"&&G.deployType==="cloud"&&await el(C,t).catch(ee=>q.warn("cleanup hermes-home during delete failed (ignored)",{agentId:C,err:String(ee)})),await G.dispose(`delete: ${U}`).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=>{await f.cleanupOpenclawSessionProviders(C)},openclawRepair:async(C,U)=>{await f.openclawRepair(C,U)},hermesReset:async(C,U)=>{let G=await Ee(C).catch(()=>null);!G||G.framework!=="hermes"||G.deployType!=="cloud"||await o0({paths:t,agentId:C,modelInfo:G.modelInfo,cozeEnv:U,mockScenario:u.getMockScenario()})},isRuntimePendingPermission:C=>u.hasPendingPermissionFor(C)});u.registerExtension("_agent/listSkills",C=>F.listSkills(C.params)),u.registerExtension("_agent/addSkills",C=>F.addSkills(C.params)),u.registerExtension("_agent/removeSkills",C=>F.removeSkills(C.params)),u.registerExtension("_agent/publishSkill",C=>F.publishSkill(C.params)),u.registerExtension("_agent/getFileTree",C=>F.getFileTree(C.params)),u.registerExtension("_agent/getFileContent",C=>F.getFileContent(C.params)),u.registerExtension("_agent/update",C=>F.updateAgent(C.params)),u.registerExtension("_agent/disconnect",C=>F.disconnectAgent(C.params)),u.registerExtension("_agent/switchModel",C=>F.switchModel(C.params)),u.registerExtension("_agent/reset",C=>F.resetAgent(C.params)),u.registerExtension("_agent/repair",C=>F.repairAgent(C.params)),u.registerExtension("_agent/delete",C=>F.deleteAgent(C.params)),u.registerExtension("_agent/upgrade",C=>F.upgradeBridge(C.params));let M=new ys({paths:t,handlers:F,agentManager:f,sendDetail:C=>u.sendRequest("_agent/detail",C)});O.ref=M;let V=async C=>{await Promise.allSettled(C.map(async U=>{try{await F.disconnectAgent({agentId:U.agentId,reason:`auth_failure: code=${U.code} ${U.message}`}),q.info("agent disconnected due to auth failure from heartbeat response",{agentId:U.agentId,code:U.code,message:U.message})}catch(G){q.warn("disconnect during authFailure handling failed (ignored)",{agentId:U.agentId,err:String(G)})}}))};c.onConnect(({initial:C})=>{q.info("frontier upstream connected, triggering detail sync",{initial:C}),M.syncAll(C?"initial-connect":"reconnect").catch(U=>q.warn("detail sync top-level error (ignored)",{err:String(U)}))});let $=new Oo({paths:t,routes:[{method:"GET",path:"/status",handler:async()=>{let C=u.getMockScenario();return{running:!0,pid:process.pid,spawnedBy:process.env[cs]==="1"?"manual":"supervisor",agents:[...u.agents.keys()],deviceId:m??"",frameworksCache:o.frameworksCache??{},...C?{mockScenario:C}:{}}}},{method:"POST",path:"/pair",handler:async C=>{let U=C,G=U?.privatecode,ee=U?.pairing_code;if(!G||!ee)throw new T("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let Ve=Bi(U.env),xe=U.handshake_url,pe=U.frontier_url,It=ap(U.env,xe,pe),gt=!!x&&x!==G,tn=p!==void 0&&p!==It,Ft=gt||tn,nn=await Vc({privatecode:G,...xe?{endpoint:xe}:{},ppeOverride:Ve});if(Ft){q.warn("pair config switched, resetting agents",{pcChanged:gt,envChanged:tn,previousPc:x?aa(x):"",nextPc:aa(G),previousEnvKey:p??"",nextEnvKey:It});for(let Ae of[...u.agents.values()])await Ae.dispose("pair config switch").catch(()=>{}),u.agents.delete(Ae.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 Kr,"pair switch").catch(()=>{})}m=nn.deviceId,ps({deviceId:m,pid:process.pid}),ml({patToken:G,env:U.env}).catch(Ae=>q.warn("coze-cli setup error (ignored)",{err:String(Ae)}));let Yr=new os({handshake:nn,privatecode:G,...pe?{urlOverride:pe}:{},ppeOverride:Ve,getPatTokenForAgent:Ae=>u.agents.get(Ae)?.patToken});await c.swap(Yr,"pair");try{let Ae=new $n;o.frameworksCache=await Ae.detectAll(),await Ji(o),q.info("frameworks_cache refreshed before pair",{detected:Object.keys(o.frameworksCache)})}catch(Ae){q.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(Ae)})}let we=Object.keys(o.frameworksCache??{});try{let Ae=await u.sendRequest("_agent/pair",{pairCode:ee,patToken:G,frameworks:we,_meta:{cozeDeviceId:m}});q.info("_agent/pair ok",{pairResult:Ae}),x=G,p=It,v=Ve,_=xe,U.mock_scenario!==void 0&&(u.setMockScenario(U.mock_scenario),q.info("mock scenario set",{scenario:U.mock_scenario})),as(G,t).catch(Oe=>q.warn("writePatToken after /pair failed (ignored)",{err:String(Oe)})),b||(b=new Hi({core:u,getDeviceId:()=>m??"",onTickEnd:()=>M.retryPending().catch(Oe=>q.warn("detailSync.retryPending failed (ignored)",{err:String(Oe)})),onAuthFailures:V})),b.start(),y(),Ft&&ca(t,f).catch(Oe=>q.warn("post-pair-switch auto-revive error (ignored)",{err:String(Oe)}));let er;return U.agent_id&&(er=await QS(U.agent_id,t,f,Oe=>u.sendRequest("_agent/detail",Oe),G).catch(Oe=>(q.error("--agent-id ensureAgent failed",{agentId:U.agent_id,err:String(Oe)}),{ok:!1,agentId:U.agent_id??"",note:String(Oe)}))),{ok:!0,note:"paired with cloud",...er?{agent:er}:{}}}catch(Ae){return q.error("_agent/pair failed",{err:String(Ae)}),{ok:!1,note:`pair failed: ${String(Ae)}`}}}},{method:"POST",path:"/connect",handler:C=>P(C)},{method:"POST",path:"/_agent/create",handler:async C=>{let U=C;return{ok:!0,result:await f.createAgent(U)}}},{method:"POST",path:"/agent/send",handler:async C=>{let U=C;if(!U?.agentId||!U?.sessionId||!U?.kind||!U?.path)throw new T("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!x)throw new T("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{let G=U;return await(G.groupFile?ph:xh)(G,{core:u,patToken:x,handshakeBase:_,ppeOverride:v})}catch(G){if(G instanceof T)return{ok:!1,code:G.code,message:G.message};throw G}}},{method:"POST",path:"/reload",handler:async C=>{let U=C?.agent_id,G=await u.reloadAgents(U);return q.info("IPC /reload: recycled agent subprocesses",{agentId:U??"(all)",recycled:G}),{ok:!0,recycled:G}}},{method:"POST",path:"/shutdown",handler:async()=>(q.info("IPC /shutdown received"),setImmediate(()=>{oe.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:ne,token:Y}=await $.start();try{await np(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(),e1({paths:t,core:u,agentManager:f,detectAll:async()=>(o.frameworksCache=await new $n().detectAll(),await Ji(o),o.frameworksCache)}).catch(C=>q.warn("startup warmup error (ignored)",{err:String(C)})),Bd().then(async()=>{let{probeAcpVersion:C}=await Promise.resolve().then(()=>(an(),Nd));for(let U of["claude-code","codex"]){let G=await C(U);G&&q.info("acp wrapper version",{framework:U,version:G})}}).catch(C=>q.warn("acp wrapper warmup / probe top-level error (ignored)",{err:String(C)}));let se=null,oe={port:ne,token:Y,core:u,ipc:$,shutdown(C){return se||(q.info("daemon shutdown",{reason:C}),se=(async()=>{b?.stop(),I?.stop(),await u.stop(C),await $.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",()=>R0()),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}
|
|
114
|
-
`)}catch{}process.exit(1)}),
|
|
115
|
-
`)){let u=
|
|
116
|
-
`;await
|
|
117
|
-
`).filter(
|
|
118
|
-
`)}async function Sp(t,e){let r=e.paths??J(),i=process.stdout.isTTY===!0;if(t.list){let
|
|
119
|
-
`),1;for(let
|
|
120
|
-
`);return 0}let o=t.date??
|
|
113
|
+
`)}catch{}}let e=new oa({processTitle:Mr}),r=await e.acquire();if(r.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${r.pid})`);let i=await Oo(),o=i??{};ws({pid:process.pid}),K.info(i?"loaded bridge config":"initialized bridge config");let c=new ra(new $r),d=null,u=new Lo({upstream:c,paths:t,bridgeConfig:o,sessionSpawner:async(R,q,W,te)=>{if(!d)throw new Error("agentManager not ready");return d.spawnSessionDownstream(R,q,W,te)}}),x=new Co({paths:t,config:o,registry:u});d=x;let h,m,w=null,S={},_,v=null,I=null,A=null,T=new An;function P(R,q){return T.enqueue(()=>C(R,q))}function y(){I||(I=new ca({isConnected:()=>c.isConnected()&&!(v?.isLivenessLost()??!1),forceReconnect:()=>A?P(A,{force:!0}):void 0,onFatal:R=>{if(process.env[us]==="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,q){let W=R,te=W?.privatecode;if(!te)throw new k("IPC_BAD_REQUEST","/connect requires privatecode");let Je=zi(W.env),me=W.handshake_url,we=W.frontier_url,kt=ap(W.env,me,we);if(A=W,!q?.force&&h===te&&m===kt){let Ee=await Y1(t);return u.agents.size===0&&Ee?(K.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),da(t,x).catch(Re=>K.warn("connect-noop auto-revive error (ignored)",{err:String(Re)}))):K.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let _t=!!h&&h!==te,rn=m!==void 0&&m!==kt,Ut=_t||rn,sn=await Jc({privatecode:te,...me?{endpoint:me}:{},ppeOverride:Je});if(Ut){K.warn("connect config switched, resetting agents",{pcChanged:_t,envChanged:rn,previousPc:h?la(h):"",nextPc:la(te)});for(let Ee of[...u.agents.values()])await Ee.dispose("connect config switch").catch(()=>{}),u.agents.delete(Ee.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 $r,"connect switch").catch(()=>{})}w=sn.deviceId,ws({deviceId:w,pid:process.pid}),_l({patToken:te,env:W.env}).catch(Ee=>K.warn("coze-cli setup error (ignored)",{err:String(Ee)}));let Xr=new ls({handshake:sn,privatecode:te,...we?{urlOverride:we}:{},ppeOverride:Je,getPatTokenForAgent:Ee=>u.agents.get(Ee)?.patToken});return await c.swap(Xr,"connect"),h=te,m=kt,S=Je,_=me,W.mock_scenario!==void 0&&(u.setMockScenario(W.mock_scenario),K.info("mock scenario set",{scenario:W.mock_scenario})),v||(v=new ji({core:u,getDeviceId:()=>w??"",onTickEnd:()=>F.retryPending().catch(Ee=>K.warn("detailSync.retryPending failed (ignored)",{err:String(Ee)})),onAuthFailures:Z})),v.start(),y(),Ut&&da(t,x).catch(Ee=>K.warn("post-connect-switch auto-revive error (ignored)",{err:String(Ee)})),ds(te,t).catch(Ee=>K.warn("writePatToken after /connect failed (ignored)",{err:String(Ee)})),K.info("/connect: WS established",{deviceId:w}),{ok:!0,note:"connected"}}u.registerExtension("_agent/create",async R=>x.createAgent(R.params)),u.registerExtension("_agent/health",async()=>({ok:!0}));let O={},z=new wo({agents:u.agents,paths:t,publishSkillToMarketplace:async R=>{let q=u.agents.get(R.agentId)?.patToken??h;if(!q)throw new k("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");return ep({patToken:q,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:_,ppeOverride:S})},disposeAndMarkDisconnected:async(R,q)=>{let W=u.agents.get(R);if(W){await x.cleanupOpenclawSessionProviders(W).catch(Je=>K.warn("cleanup openclaw providers failed (ignored)",{agentId:R,err:String(Je)})),W.framework==="hermes"&&W.deployType==="cloud"&&await nl(R,t).catch(Je=>K.warn("cleanup hermes-home failed (ignored)",{agentId:R,err:String(Je)}));let te=!0;try{await W.dispose(`disconnect: ${q}`)}catch(Je){te=!1,K.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:R,err:String(Je)}),W.status="error"}te&&(W.status="disconnected",u.unregister(R),u.disconnectedAgents.add(R))}else u.disconnectedAgents.add(R)},disposeForDelete:async(R,q)=>{let W=u.agents.get(R);W&&(await x.cleanupOpenclawSessionProviders(W).catch(te=>K.warn("cleanup openclaw providers during delete failed (ignored)",{agentId:R,err:String(te)})),W.framework==="hermes"&&W.deployType==="cloud"&&await nl(R,t).catch(te=>K.warn("cleanup hermes-home during delete failed (ignored)",{agentId:R,err:String(te)})),await W.dispose(`delete: ${q}`).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(!O.ref)throw new Error("agent-detail-sync not initialized yet");await O.ref.syncOne(R)},cleanupOpenclawProviders:async R=>{await x.cleanupOpenclawSessionProviders(R)},openclawRepair:async(R,q)=>{await x.openclawRepair(R,q)},hermesReset:async(R,q)=>{let W=await Ie(R).catch(()=>null);!W||W.framework!=="hermes"||W.deployType!=="cloud"||await o0({paths:t,agentId:R,model:W.model,modelInfo:W.modelInfo,cozeEnv:q,mockScenario:u.getMockScenario()})},isRuntimePendingPermission:R=>u.hasPendingPermissionFor(R)});u.registerExtension("_agent/listSkills",R=>z.listSkills(R.params)),u.registerExtension("_agent/addSkills",R=>z.addSkills(R.params)),u.registerExtension("_agent/removeSkills",R=>z.removeSkills(R.params)),u.registerExtension("_agent/publishSkill",R=>z.publishSkill(R.params)),u.registerExtension("_agent/getFileTree",R=>z.getFileTree(R.params)),u.registerExtension("_agent/getFileContent",R=>z.getFileContent(R.params)),u.registerExtension("_agent/update",R=>z.updateAgent(R.params)),u.registerExtension("_agent/disconnect",R=>z.disconnectAgent(R.params)),u.registerExtension("_agent/switchModel",R=>z.switchModel(R.params)),u.registerExtension("_agent/reset",R=>z.resetAgent(R.params)),u.registerExtension("_agent/repair",R=>z.repairAgent(R.params)),u.registerExtension("_agent/delete",R=>z.deleteAgent(R.params)),u.registerExtension("_agent/upgrade",R=>z.upgradeBridge(R.params));let F=new vs({paths:t,handlers:z,agentManager:x,sendDetail:R=>u.sendRequest("_agent/detail",R)});O.ref=F;let Z=async R=>{await Promise.allSettled(R.map(async q=>{try{await z.disconnectAgent({agentId:q.agentId,reason:`auth_failure: code=${q.code} ${q.message}`}),K.info("agent disconnected due to auth failure from heartbeat response",{agentId:q.agentId,code:q.code,message:q.message})}catch(W){K.warn("disconnect during authFailure handling failed (ignored)",{agentId:q.agentId,err:String(W)})}}))};c.onConnect(({initial:R})=>{K.info("frontier upstream connected, triggering detail sync",{initial:R}),F.syncAll(R?"initial-connect":"reconnect").catch(q=>K.warn("detail sync top-level error (ignored)",{err:String(q)}))});let V=new No({paths:t,routes:[{method:"GET",path:"/status",handler:async()=>{let R=u.getMockScenario();return{running:!0,pid:process.pid,spawnedBy:process.env[us]==="1"?"manual":"supervisor",agents:[...u.agents.keys()],deviceId:w??"",frameworksCache:o.frameworksCache??{},...R?{mockScenario:R}:{}}}},{method:"POST",path:"/pair",handler:async R=>{let q=R,W=q?.privatecode,te=q?.pairing_code;if(!W||!te)throw new k("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let Je=zi(q.env),me=q.handshake_url,we=q.frontier_url,kt=ap(q.env,me,we),_t=!!h&&h!==W,rn=m!==void 0&&m!==kt,Ut=_t||rn,sn=await Jc({privatecode:W,...me?{endpoint:me}:{},ppeOverride:Je});if(Ut){K.warn("pair config switched, resetting agents",{pcChanged:_t,envChanged:rn,previousPc:h?la(h):"",nextPc:la(W),previousEnvKey:m??"",nextEnvKey:kt});for(let Re of[...u.agents.values()])await Re.dispose("pair config switch").catch(()=>{}),u.agents.delete(Re.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 $r,"pair switch").catch(()=>{})}w=sn.deviceId,ws({deviceId:w,pid:process.pid}),_l({patToken:W,env:q.env}).catch(Re=>K.warn("coze-cli setup error (ignored)",{err:String(Re)}));let Xr=new ls({handshake:sn,privatecode:W,...we?{urlOverride:we}:{},ppeOverride:Je,getPatTokenForAgent:Re=>u.agents.get(Re)?.patToken});await c.swap(Xr,"pair");try{let Re=new Vn;o.frameworksCache=await Re.detectAll(),await Xi(o),K.info("frameworks_cache refreshed before pair",{detected:Object.keys(o.frameworksCache)})}catch(Re){K.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(Re)})}let Ee=Object.keys(o.frameworksCache??{});try{let Re=await u.sendRequest("_agent/pair",{pairCode:te,patToken:W,frameworks:Ee,_meta:{cozeDeviceId:w}});K.info("_agent/pair ok",{pairResult:Re}),h=W,m=kt,S=Je,_=me,q.mock_scenario!==void 0&&(u.setMockScenario(q.mock_scenario),K.info("mock scenario set",{scenario:q.mock_scenario})),ds(W,t).catch(Ne=>K.warn("writePatToken after /pair failed (ignored)",{err:String(Ne)})),v||(v=new ji({core:u,getDeviceId:()=>w??"",onTickEnd:()=>F.retryPending().catch(Ne=>K.warn("detailSync.retryPending failed (ignored)",{err:String(Ne)})),onAuthFailures:Z})),v.start(),y(),Ut&&da(t,x).catch(Ne=>K.warn("post-pair-switch auto-revive error (ignored)",{err:String(Ne)}));let tr;return q.agent_id&&(tr=await Q1(q.agent_id,t,x,Ne=>u.sendRequest("_agent/detail",Ne),W).catch(Ne=>(K.error("--agent-id ensureAgent failed",{agentId:q.agent_id,err:String(Ne)}),{ok:!1,agentId:q.agent_id??"",note:String(Ne)}))),{ok:!0,note:"paired with cloud",...tr?{agent:tr}:{}}}catch(Re){return K.error("_agent/pair failed",{err:String(Re)}),{ok:!1,note:`pair failed: ${String(Re)}`}}}},{method:"POST",path:"/connect",handler:R=>P(R)},{method:"POST",path:"/_agent/create",handler:async R=>{let q=R;return{ok:!0,result:await x.createAgent(q)}}},{method:"POST",path:"/agent/send",handler:async R=>{let q=R;if(!q?.agentId||!q?.sessionId||!q?.kind||!q?.path)throw new k("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!h)throw new k("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{let W=q;return await(W.groupFile?px:hx)(W,{core:u,patToken:h,handshakeBase:_,ppeOverride:S})}catch(W){if(W instanceof k)return{ok:!1,code:W.code,message:W.message};throw W}}},{method:"POST",path:"/reload",handler:async R=>{let q=R?.agent_id,W=await u.reloadAgents(q);return K.info("IPC /reload: recycled agent subprocesses",{agentId:q??"(all)",recycled:W}),{ok:!0,recycled:W}}},{method:"POST",path:"/shutdown",handler:async()=>(K.info("IPC /shutdown received"),setImmediate(()=>{ae.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:ie,token:X}=await V.start();try{await np(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(),eS({paths:t,core:u,agentManager:x,detectAll:async()=>(o.frameworksCache=await new Vn().detectAll(),await Xi(o),o.frameworksCache)}).catch(R=>K.warn("startup warmup error (ignored)",{err:String(R)})),Bd().then(async()=>{let{probeAcpVersion:R}=await Promise.resolve().then(()=>(cn(),Nd));for(let q of["claude-code","codex"]){let W=await R(q);W&&K.info("acp wrapper version",{framework:q,version:W})}}).catch(R=>K.warn("acp wrapper warmup / probe top-level error (ignored)",{err:String(R)}));let oe=null,ae={port:ie,token:X,core:u,ipc:V,shutdown(R){return oe||(K.info("daemon shutdown",{reason:R}),oe=(async()=>{v?.stop(),I?.stop(),await u.stop(R),await V.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",()=>C0()),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}
|
|
114
|
+
`)}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"}),nS({cliSpawned:process.env[us]==="1",readPatToken:()=>ia(t),connect:P}).catch(R=>K.warn("maybeAutoConnectOnStartup error (ignored)",{err:String(R)})),ae}async function Y1(t){return ys(t).length>0}function la(t){return t.length<=8?"***":`${t.slice(0,4)}***${t.slice(-4)}`}function ap(t,e,r){return`${t??""}|${e??""}|${r??""}`}async function X1(t,e){let r=ys(t);if(r.length===0)return;let{loadAgentConfig:i,enforceAgentConfigMode:o}=await Promise.resolve().then(()=>(qt(),bs));for(let c of r){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 Q1(t,e,r,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=lp(d),w={agentId:d.agentId,framework:d.framework,...d.cozeIdentity?{cozeIdentity:d.cozeIdentity}:{},...d.model?{model:d.model}:{},...o?{patToken:o}:{},...m?{_meta:m}:{}};return await r.createAgent(w),{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 x={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 r.createAgent(x);let h=u.deployType==="cloud"&&u.framework==="openclaw";return{ok:!0,agentId:t,note:h?"cloud agent acknowledged":"created from cloud detail"}}async function eS(t){let e=t.logger??K;try{let r=await t.detectAll();e.info("refreshed frameworks_cache",{detected:Object.keys(r??{})})}catch(r){e.warn("framework detection failed (using cached)",{err:String(r)})}await X1(t.paths,t.core).catch(r=>e.warn("scanAgentsOnStartup failed (ignored)",{err:String(r)})),await da(t.paths,t.agentManager).catch(r=>e.warn("auto-revive top-level error (ignored)",{err:String(r)})),await tS(t.paths).catch(r=>e.warn("builtin skill refresh top-level error (ignored)",{err:String(r)}))}async function da(t,e){let{readdir:r}=await import("node:fs/promises"),i;try{i=await r(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 x;try{x=await o(u,t)}catch(h){K.warn("auto-revive: load config failed (skipping)",{agentId:u,err:String(h)}),d+=1;continue}if(!x){d+=1;continue}if(x.deletedAt){K.info("auto-revive: skip deleted agent",{agentId:u,deletedAt:x.deletedAt}),d+=1;continue}if(x.disconnectedAt){K.info("auto-revive: skip disconnected agent",{agentId:u,disconnectedAt:x.disconnectedAt}),d+=1;continue}try{K.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:u,framework:x.framework});let h=lp(x);await e.createAgent({agentId:x.agentId,framework:x.framework,...x.cozeIdentity?{cozeIdentity:x.cozeIdentity}:{},...x.model?{model:x.model}:{},...h?{_meta:h}:{}},{revive:!0}),c+=1}catch(h){K.warn("auto-revive: createAgent failed (skipping)",{agentId:u,framework:x.framework,err:String(h)}),d+=1}}return K.info("auto-revive: done",{revived:c,skipped:d,total:i.length}),{revived:c,skipped:d,total:i.length}}async function tS(t){let{readdir:e}=await import("node:fs/promises"),r;try{r=await e(t.agentsRoot)}catch{return{refreshed:0,total:0}}if(r.length===0)return{refreshed:0,total:0};let i=0;for(let o of r)try{(await w0(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:r.length}),{refreshed:i,total:r.length}}async function nS(t){let e=t.logger??K;if(t.cliSpawned)return"skipped-cli";let r=await t.readPatToken();return r?(e.info("supervisor-spawned daemon, auto-connecting with stored PAT"),t.connect({privatecode:r}).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 lp(t){let e={};return t.deployType&&(e.cozeDeployType=t.deployType),t.accountId&&(e.cozeAccountId=t.accountId),Object.keys(e).length>0?e:void 0}aa();De();import{readFile as dp}from"node:fs/promises";var nn=class{paths;constructor(e){this.paths=e??J()}async probe(e=1e3){let r=await ua(this.paths);if(!r)return{kind:"not-running"};try{let i=await this.fetch(r,{method:"GET",path:"/status",timeoutMs:e});return i.status===200?{kind:"connected",...r}:{kind:"stale",reason:`unexpected status ${i.status}`}}catch(i){return{kind:"stale",reason:iS(i)}}}async request(e){let r=await ua(this.paths);if(!r)throw new Error("coze-bridge daemon not running (no port/token files)");return this.fetch(r,e)}async fetch(e,r){let i=r.body!==void 0,o={Authorization:`Bearer ${e.token}`};i&&(o["content-type"]="application/json");let c=new AbortController,d=setTimeout(()=>c.abort(),r.timeoutMs??5e3);try{let u=await fetch(`http://127.0.0.1:${e.port}${r.path}`,{method:r.method,headers:o,body:i?JSON.stringify(r.body):void 0,signal:c.signal}),x=await u.text();return{status:u.status,body:rS(x)}}finally{clearTimeout(d)}}};async function ua(t){try{let[e,r]=await Promise.all([dp(t.portFile,"utf8"),dp(t.tokenFile,"utf8")]),i=Number.parseInt(e.trim(),10),o=r.trim();return!Number.isFinite(i)||i<=0||!o?null:{port:i,token:o}}catch(e){if(e.code==="ENOENT")return null;throw e}}function rS(t){if(!t)return null;try{return JSON.parse(t)}catch{return t}}function iS(t){return t instanceof Error?t.message:String(t)}Jt();re();sr();import{spawn as sS}from"node:child_process";import{userInfo as fp}from"node:os";var Jl="__COZE_BRIDGE_ENV_SENTINEL_5f3c91__",oS=new Set(["bash","zsh","sh","dash","ksh"]),up=Ye("COZE_BRIDGE_SHELLENV_TIMEOUT_MS",1e4),aS=2e3;function cS(t,e=Jl){let r=t.indexOf(e);if(r===-1)return null;let i=t.indexOf(e,r+e.length);if(i===-1)return null;let o=t.slice(r+e.length,i),c={};for(let d of o.split(`
|
|
115
|
+
`)){let u=d.indexOf("=");u<=0||(c[d.slice(0,u)]=d.slice(u+1))}return c}function lS(){let t=(process.env.SHELL??"").trim()||(fp().shell??"").trim();if(!t)return null;let e=t.slice(t.lastIndexOf("/")+1);return oS.has(e)?t:null}function dS(t){return new Promise(e=>{let r=`printf '%s' '${Jl}'; env; printf '%s' '${Jl}'`,i;try{i=sS(t,["-ilc",r],{detached:!0,stdio:["ignore","pipe","ignore"],env:{...process.env,HOME:process.env.HOME??fp().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(x),clearTimeout(h),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 x=setTimeout(()=>d("SIGTERM"),up),h=setTimeout(()=>{d("SIGKILL"),u(o.length>0?o:null)},up+aS)})}async function Yl(t={}){if((t.platform??process.platform)==="win32")return{kind:"skipped",reason:"windows"};let r=lS();if(!r)return{kind:"skipped",reason:"no-supported-login-shell"};let i=await(t.run??dS)(r);if(i==null)return{kind:"failed",reason:"shell-timeout-or-error"};let o=cS(i);return o==null?{kind:"failed",reason:"unparseable-output"}:{kind:"ok",env:o}}De();function Rn(t,...e){let r=[],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||r.push(c)}return{value:i,rest:r}}cn();import{chmod as uS,copyFile as xp,mkdir as pp,readFile as fa,rename as hp,rm as Xl,stat as gp,writeFile as fS}from"node:fs/promises";import{homedir as HP}from"node:os";import{dirname as xS,join as Vr,resolve as Ql,sep as fs}from"node:path";import{fileURLToPath as hS}from"node:url";Jt();re();De();var ed=j("dist-install");function pS(t){let e=hS(t),r=xS(e),i=`${fs}src${fs}`;if(r.includes(i)||r.endsWith(`${fs}src${fs}cli`))return null;let o=Ql(r,"index.js"),c=Ql(r,"..","package.json");return{dist:o,pkgJson:c}}async function nd(t={}){let e=t.paths??J(),r=pS(import.meta.url),i=t.sourceDist??r?.dist,o=t.sourcePackageJson??r?.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 S=JSON.parse(await fa(o,"utf8"));c=S.version??"unknown",d=S.dependencies??{}}catch(S){return ed.warn("cannot read source package.json,skip dist install",{err:String(S)}),{kind:"dev-mode-skip",reason:`package.json read failed: ${String(S)}`}}let u=ii.map(S=>`${S}@${d[S]??"latest"}`),x=await Oo(e.configFile)??{},h=x.libVersion,m=await fa(e.libEntry).then(()=>!0).catch(()=>!1),w=h===c;if(w&&m&&await td(e))return{kind:"already-current",libVersion:c};if(!w||!m){await pp(e.libDir,{recursive:!0}),await xp(i,e.libEntry),await xp(`${i}.map`,`${e.libEntry}.map`).catch(()=>{});let S=Ql(e.libDir,"package.json"),_=`${JSON.stringify({type:"module"},null,2)}
|
|
116
|
+
`;await fa(S,"utf8").catch(()=>null)!==_&&await fS(S,_)}return(!w||!await td(e))&&await(t.installWrappers??gS)(e,u),x.libVersion=c,await Xi(x,e.configFile),ed.info("dist installed",{libEntry:e.libEntry,fromVersion:h,toVersion:c}),w&&m?{kind:"already-current",libVersion:c}:h?{kind:"version-changed",fromVersion:h,toVersion:c,libEntry:e.libEntry}:{kind:"first-install",libVersion:c,libEntry:e.libEntry}}async function td(t){for(let e of ii){let r=Vr(t.libDir,"node_modules",...e.split("/"),"package.json");if(!await gp(r).then(o=>o.isFile()).catch(()=>!1))return!1}return!0}async function gS(t,e){await _S(t.installLock,async()=>{if(await td(t))return;let r=Math.random().toString(36).slice(2,10),i=`${t.libDir}${fs}.staging-${process.pid}-${r}`,o=Vr(i,"node_modules"),c=Vr(t.libDir,"node_modules");try{await pp(i,{recursive:!0}),await mS(e,i),await wS(o);let d=`${c}.trash-${r}`;await hp(c,d).catch(()=>{}),await hp(o,c),await Xl(d,{recursive:!0,force:!0}).catch(()=>{}),ed.info("wrapper closure installed",{liveNm:c,specs:e})}finally{await Xl(i,{recursive:!0,force:!0}).catch(()=>{})}})}function mS(t,e){let r=["install",...t,"--prefix",e,"--omit=dev","--prefer-offline","--no-audit","--no-fund"];return new Promise((i,o)=>{let c=st("npm",r,{stdio:["ignore","pipe","pipe"]}),d="";c.stderr?.on("data",x=>{d.length<8192&&(d+=x.toString("utf8"))});let u=setTimeout(()=>c.kill("SIGKILL"),18e4);c.once("error",x=>{clearTimeout(u),o(new Error(`spawn npm failed: ${String(x)}`))}),c.once("close",x=>{clearTimeout(u),x===0?i():o(new Error(`npm install \u9000\u51FA\u7801 ${x}: ${d.trim().slice(0,2e3)}`))})})}async function wS(t){for(let e of ii){let r=Vr(t,...e.split("/")),i=JSON.parse(await fa(Vr(r,"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=Vr(t,".bin",o),d=await gp(c);process.platform!=="win32"&&!(d.mode&73)&&await uS(c,d.mode|73).catch(()=>{})}}async function _S(t,e){let{open:r}=await import("node:fs/promises"),i=!1;for(let o=0;o<60&&!i;o++)try{await(await r(t,"wx")).close(),i=!0}catch{await new Promise(c=>setTimeout(c,500))}try{return await e()}finally{i&&await Xl(t,{force:!0}).catch(()=>{})}}La();re();De();import{closeSync as wp,fstatSync as _p,openSync as yp,readFileSync as yS,readSync as ES,readdirSync as bS,statSync as vS}from"node:fs";import{join as xa}from"node:path";var SS=new Set(["debug","info","warn","error"]);function Ep(t){let e=t,r=Rn(e,"--agent-id");e=r.rest;let i=Rn(e,"--date");e=i.rest;let o=Rn(e,"-n","--lines");e=o.rest;let c=Rn(e,"--level");e=c.rest;let d=Rn(e,"--grep");e=d.rest;let u=o.value===void 0?200:Number(o.value),x=Number.isInteger(u)&&u>=0?u:200,h=c.value&&SS.has(c.value)?c.value:void 0,m={lines:x,follow:e.includes("-f")||e.includes("--follow"),raw:e.includes("--raw"),list:e.includes("--list")};return r.value&&(m.agentId=r.value),i.value&&(m.date=i.value),h&&(m.level=h),d.value&&(m.grep=d.value),m}function IS(t,e){return t.agentId?xa(ze(t.agentId,e).logs,or("agent",t.date)):xa(e.bridgeLogsDir,or("bridge",t.date))}function AS(t,e){return e<=0||e>=t.length?t:t.slice(t.length-e)}function kS(t,e){let r;try{r=bS(t)}catch{return[]}let i=[];for(let o of r){let c=Oa(o,e);if(!c)continue;let d=0;try{d=vS(xa(t,o)).size}catch{}i.push({file:xa(t,o),date:c,size:d})}return i.sort((o,c)=>c.date.localeCompare(o.date)),i}function bp(t,e){if(e.grep&&!t.includes(e.grep))return!1;if(e.level){let r;try{r=JSON.parse(t).level}catch{return!0}if(typeof r=="string"&&!Cd(r,e.level))return!1}return!0}var mp={debug:"90",info:"36",warn:"33",error:"31"},TS=new Set(["ts","level","module","msg"]);function RS(t){if(typeof t!="string")return"";let e=t.split("T")[1];return e?e.slice(0,12):""}function vp(t,e){if(e.raw)return t;let r;try{r=JSON.parse(t)}catch{return t}let i=RS(r.ts),o=typeof r.level=="string"?r.level:"",c=o.toUpperCase().padEnd(5);e.color&&mp[o]&&(c=`\x1B[${mp[o]}m${c}\x1B[0m`);let d=typeof r.module=="string"?r.module:"",u=typeof r.msg=="string"?r.msg:"",x=Object.entries(r).filter(([h])=>!TS.has(h)).map(([h,m])=>` ${h}=${typeof m=="string"?m:JSON.stringify(m)}`).join("");return`${i} ${c} ${d} ${u}${x}`}function CS(t,e,r){let c=yS(t,"utf8").split(`
|
|
117
|
+
`).filter(d=>d.length>0).filter(d=>bp(d,{level:e.level,grep:e.grep}));for(let d of AS(c,e.lines))process.stdout.write(`${vp(d,{raw:e.raw,color:r})}
|
|
118
|
+
`)}async function Sp(t,e){let r=e.paths??J(),i=process.stdout.isTTY===!0;if(t.list){let d=t.agentId?ze(t.agentId,r).logs:r.bridgeLogsDir,u=t.agentId?"agent":"bridge",x=kS(d,u);if(x.length===0)return process.stderr.write(`coze-bridge log: \u65E0\u65E5\u5FD7\u6587\u4EF6\u4E8E ${d}
|
|
119
|
+
`),1;for(let h of x)process.stdout.write(`${h.date} ${(h.size/1024).toFixed(1)}KB ${h.file}
|
|
120
|
+
`);return 0}let o=t.date??Dn(new Date),c=IS({agentId:t.agentId,date:o},r);try{CS(c,t,i)}catch{return process.stderr.write(`coze-bridge log: \u627E\u4E0D\u5230\u65E5\u5FD7 ${c}
|
|
121
121
|
\u7528 'coze-bridge log${t.agentId?` --agent-id ${t.agentId}`:""} --list' \u770B\u6709\u54EA\u4E9B\u65E5\u671F\u3002
|
|
122
122
|
(legacy \u6A21\u5F0F\u65E0 dated \u6587\u4EF6, \u89C1 ${r.logFile})
|
|
123
|
-
`),1}return t.follow&&await
|
|
124
|
-
`);o=
|
|
125
|
-
`)}await new Promise(
|
|
123
|
+
`),1}return t.follow&&await OS(c,t,i),0}var DS=500;function PS(t){try{let e=yp(t,"r");try{return _p(e).size}finally{wp(e)}}catch{return 0}}async function OS(t,e,r){let i=PS(t),o="",c=!1,d=()=>{c=!0};process.on("SIGINT",d);try{for(;!c;){let u="";try{let x=yp(t,"r");try{let h=_p(x).size;if(h>i){let m=Buffer.allocUnsafe(h-i),w=ES(x,m,0,m.length,i);u=m.subarray(0,w).toString("utf8"),i+=w}}finally{wp(x)}}catch{}if(u){let x=(o+u).split(`
|
|
124
|
+
`);o=x.pop()??"";for(let h of x)h.length>0&&bp(h,{level:e.level,grep:e.grep})&&process.stdout.write(`${vp(h,{raw:e.raw,color:r})}
|
|
125
|
+
`)}await new Promise(x=>setTimeout(x,DS))}}finally{process.off("SIGINT",d)}}import{basename as LS,resolve as NS}from"node:path";De();var MS=9e4,BS={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 FS(t){return BS[t]??1}async function Ip(t,e={}){let r=e.paths??J();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>
|
|
126
126
|
`),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.
|
|
127
|
-
`),3;let i=await
|
|
128
|
-
`),4;let o={agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,path:t.groupFile?t.path:
|
|
127
|
+
`),3;let i=await ua(r).catch(()=>null);if(!i)return process.stderr.write(`Error: coze-bridge daemon not running (cannot read ${r.portFile} / ${r.tokenFile}). Make sure you are inside an agent session spawned by the daemon.
|
|
128
|
+
`),4;let o={agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,path:t.groupFile?t.path:NS(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 zS(i,"/agent/send",o,MS)}catch(d){return process.stderr.write(`Error: daemon IPC failed: ${d instanceof Error?d.message:String(d)}
|
|
129
129
|
`),4}if(!c.ok)return process.stderr.write(`Error: ${c.code}: ${c.message}
|
|
130
|
-
`),
|
|
131
|
-
`);else{let
|
|
132
|
-
`)}else process.stdout.write(`Sent ${t.kind} ${
|
|
133
|
-
`)}return 0}async function
|
|
134
|
-
`)}function
|
|
130
|
+
`),FS(c.code);if(t.json)process.stdout.write(`${JSON.stringify(c)}
|
|
131
|
+
`);else{let d=t.name??LS(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})
|
|
132
|
+
`)}else process.stdout.write(`Sent ${t.kind} ${d} (${US(c.bytes)})
|
|
133
|
+
`)}return 0}async function zS(t,e,r,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(r),signal:o.signal}),u=await d.text(),x=u?JSON.parse(u):null;return x&&typeof x=="object"&&"ok"in x?x:{ok:!1,code:"BRIDGE_INTERNAL",message:`unexpected daemon response (status=${d.status}): ${u.slice(0,200)}`}}finally{clearTimeout(c)}}function US(t){return t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(1)}KB`:`${(t/1024/1024).toFixed(1)}MB`}var Lp=j("cli");function Ke(t,e){let{value:r,rest:i}=Rn(t,e);return{value:r,rest:i}}function _a(t,e){process.stderr.write(`[deprecated] '${t}' will be removed in a future release, use '${e}' instead
|
|
134
|
+
`)}function d2(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:P}=Ke(e.slice(1),"--agent-id");return P?{mode:"reload",agentId:P}:{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 u2(e.slice(1));if(e[0]==="log")return{mode:"log",...Ep(e.slice(1))};if(e[0]==="connect")return f2(e.slice(1));if(e.includes("--status"))return _a("--status","coze-bridge status"),{mode:"status"};if(e.includes("--stop"))return _a("--stop","coze-bridge stop"),{mode:"stop"};if(e.includes("--uninstall"))return _a("--uninstall","coze-bridge purge"),{mode:"purge"};if(e.includes("--install-service"))return _a("--install-service","coze-bridge service install"),{mode:"service-install"};if(e.includes("--help")||e.includes("-h")||e.length===0)return{mode:"help"};let r=e,{value:i,rest:o}=Ke(r,"--pat-token");r=o;let{value:c,rest:d}=Ke(r,"--pair-code");r=d;let{value:u,rest:x}=Ke(r,"--env");r=x;let{value:h,rest:m}=Ke(r,"--handshake-url");r=m;let{value:w,rest:S}=Ke(r,"--frontier-url");r=S;let{value:_,rest:v}=Ke(r,"--mock-scenario");r=v;let{value:I}=Ke(r,"--agent-id"),A=r.includes("--skip-rebuild-env");if(!i||!c)return{mode:"help"};let T={mode:"pair",privatecode:i,pairingCode:c};return u&&(T.env=u),h&&(T.handshakeUrl=h),w&&(T.frontierUrl=w),_&&(T.mockScenario=_),I&&(T.agentId=I),A&&(T.skipRebuildEnv=!0),T}function u2(t){let e=t[0],r=t[1];if(e!=="image"&&e!=="file")return{mode:"help"};if(!r||r.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:x,rest:h}=Ke(i,"--agent-id");i=h;let{value:m,rest:w}=Ke(i,"--session-id");i=w;let{value:S,rest:_}=Ke(i,"--mime");i=_;let v=i.includes("--group-file");i=i.filter(T=>T!=="--group-file");let I=i.includes("--json"),A={mode:"send",kind:e,path:r,json:I};return o&&(A.caption=o),d&&(A.name=d),x&&(A.agentId=x),m&&(A.sessionId=m),v&&(A.groupFile=!0),S&&(A.mimeType=S),A}function f2(t){let e=t,{value:r,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:x,rest:h}=Ke(e,"--frontier-url");e=h;let{value:m,rest:w}=Ke(e,"--mock-scenario");e=w;let S=e.includes("--skip-rebuild-env"),_={mode:"connect"};return r&&(_.privatecode=r),o&&(_.env=o),d&&(_.handshakeUrl=d),x&&(_.frontierUrl=x),m&&(_.mockScenario=m),S&&(_.skipRebuildEnv=!0),_}var x2=`
|
|
135
135
|
coze-bridge - local bridge daemon for cloud Agent Service
|
|
136
136
|
|
|
137
137
|
Pair (paste from cloud UI; start/reuse daemon and deliver pair-code):
|
|
@@ -212,57 +212,57 @@ Deprecated flags (still work, but emit a warning; will be removed in a future re
|
|
|
212
212
|
|
|
213
213
|
Internal:
|
|
214
214
|
<node> <entry> --daemon daemon mode (OS supervisor only)
|
|
215
|
-
`.trimStart();async function Np(t=process.argv,e={}){let r=
|
|
216
|
-
`),0;case"daemon":{try{await cp()}catch(i){return Lp.error("daemon start failed",{err:String(i)}),1}return new Promise(()=>{})}case"status":return
|
|
215
|
+
`.trimStart();async function Np(t=process.argv,e={}){let r=d2(t);switch(r.mode){case"help":return process.stdout.write(x2),0;case"version":return process.stdout.write(`${Nt}
|
|
216
|
+
`),0;case"daemon":{try{await cp()}catch(i){return Lp.error("daemon start failed",{err:String(i)}),1}return new Promise(()=>{})}case"status":return h2(e);case"stop":return Bp(e);case"reload":return m2(r.agentId,e);case"log":return Sp(r,e);case"update":return p2(e);case"purge":return w2(e);case"service-install":return _2(e);case"service-uninstall":return y2(e);case"pair":{let i={};return r.env&&(i.env=r.env),r.handshakeUrl&&(i.handshakeUrl=r.handshakeUrl),r.frontierUrl&&(i.frontierUrl=r.frontierUrl),r.mockScenario&&(i.mockScenario=r.mockScenario),E2(r.privatecode,r.pairingCode,e,i,r.agentId,r.skipRebuildEnv)}case"connect":{let i={};return r.env&&(i.env=r.env),r.handshakeUrl&&(i.handshakeUrl=r.handshakeUrl),r.frontierUrl&&(i.frontierUrl=r.frontierUrl),r.mockScenario&&(i.mockScenario=r.mockScenario),b2(r.privatecode,e,i,r.skipRebuildEnv)}case"send":return Ip({kind:r.kind,path:r.path,...r.agentId?{agentId:r.agentId}:{},...r.sessionId?{sessionId:r.sessionId}:{},...r.caption?{caption:r.caption}:{},...r.name?{name:r.name}:{},...r.groupFile?{groupFile:!0}:{},...r.mimeType?{mimeType:r.mimeType}:{},json:r.json},e)}}async function Mp(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 h2(t){let e=t.paths??J(),r=new nn(e),i=await r.probe();if(i.kind==="not-running")return process.stdout.write(`coze-bridge: not running
|
|
217
217
|
`),1;if(i.kind==="stale")return await Mp(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
|
|
218
218
|
`),1;let o=await r.request({method:"GET",path:"/status"});return process.stdout.write(`coze-bridge: running
|
|
219
219
|
${JSON.stringify(o.body,null,2)}
|
|
220
|
-
`),0}async function Bp(t){let e=t.paths??J(),r=new
|
|
221
|
-
`)}let u=await r.probe();if(u.kind==="not-running")return await o(),process.stdout.write(
|
|
220
|
+
`),0}async function Bp(t){let e=t.paths??J(),r=new nn(e),i=t.daemonSweep??(async()=>{let x=D0();return await P0(x),x}),o=async()=>{t.skipProcessKill||await i(e)},c=await hs(t),d=!1;if(c)try{await c.uninstall(),d=!0}catch(x){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(x)}
|
|
221
|
+
`)}let u=await r.probe();if(u.kind==="not-running")return await o(),process.stdout.write(d?`coze-bridge: stopped
|
|
222
222
|
`:`coze-bridge: not running
|
|
223
223
|
`),0;if(u.kind==="stale")return await Mp(e),await o(),process.stdout.write(`coze-bridge: not running (cleaned stale state)
|
|
224
224
|
`),0;try{return await r.request({method:"POST",path:"/shutdown"}),await o(),process.stdout.write(`coze-bridge: stopped
|
|
225
|
-
`),0}catch(
|
|
226
|
-
`),0):(await o(),process.stdout.write(`coze-bridge: stop failed: ${String(
|
|
227
|
-
`),1)}}async function
|
|
228
|
-
`),e(1)})})}async function
|
|
225
|
+
`),0}catch(x){return(await r.probe()).kind!=="connected"?(await o(),process.stdout.write(`coze-bridge: stopped
|
|
226
|
+
`),0):(await o(),process.stdout.write(`coze-bridge: stop failed: ${String(x)}
|
|
227
|
+
`),1)}}async function p2(t){return await Bp(t),(t.spawnNpx??g2)(["-y","--ignore-existing","coze-bridge@latest","connect"])}function g2(t){return new Promise(e=>{let r=st("npx",t,{stdio:"inherit"});r.on("exit",i=>e(i??1)),r.on("error",i=>{process.stderr.write(`coze-bridge: spawn npx failed: ${String(i)}
|
|
228
|
+
`),e(1)})})}async function m2(t,e){let r=new nn(e.paths);if((await r.probe()).kind==="not-running")return process.stdout.write(`coze-bridge: not running (start daemon first)
|
|
229
229
|
`),1;try{let o=await r.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)
|
|
230
230
|
`):process.stdout.write(`coze-bridge: reloaded ${c.length} agent(s): ${c.join(", ")||"(none)"}
|
|
231
231
|
`),0}return process.stderr.write(`coze-bridge: reload failed: ${JSON.stringify(o.body)}
|
|
232
232
|
`),1}catch(o){return process.stderr.write(`coze-bridge: reload failed: ${String(o)}
|
|
233
|
-
`),1}}async function
|
|
233
|
+
`),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:r}=await Promise.resolve().then(()=>(Pp(),Dp)),i=e(),o=r();return{platform:i.platform,install:c=>i.install(o,c),uninstall:()=>i.uninstall(o)}}async function Fp(t,e){let r=await e.probe();if(r.kind==="connected")return r;let i=t.spawnDaemon??op,o=t.waitTimeoutMs??15e3,c=t.sleep??S2,d=t.paths??J(),u=await hs(t);if(u&&(u.platform==="darwin"||u.platform==="linux")){try{await u.install({activate:!0});let x=await Op(e,o,c);if(x.kind==="connected")return x;Tt(d.bridgeLogsDir,"warn","cli","supervisor \u8D77 daemon \u8D85\u65F6, \u56DE\u9000\u624B\u52A8 spawn (\u672C\u6B21\u65E0\u5D29\u6E83\u4FDD\u6D3B)",{waitMs:o})}catch(x){Tt(d.bridgeLogsDir,"warn","cli","supervisor \u63A5\u7BA1\u5931\u8D25, \u56DE\u9000\u624B\u52A8 spawn",{err:String(x)})}Tt(d.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 v2(d.pidFile,c)}else u&&await u.install({activate:!1}).catch(x=>process.stderr.write(`coze-bridge: \u81EA\u542F\u6CE8\u518C\u5931\u8D25(\u4E0D\u5F71\u54CD\u672C\u6B21): ${String(x)}
|
|
234
234
|
`));return process.stdout.write(`coze-bridge: starting daemon...
|
|
235
|
-
`),await i({paths:t.paths}),Op(e,o,c)}async function
|
|
236
|
-
`);try{await e.request({method:"POST",path:"/shutdown"})}catch(
|
|
237
|
-
`)}await new Promise(
|
|
238
|
-
`)}catch(
|
|
235
|
+
`),await i({paths:t.paths}),Op(e,o,c)}async function w2(t){let e=new nn(t.paths);if((await e.probe()).kind==="connected"){process.stdout.write(`coze-bridge: stopping daemon...
|
|
236
|
+
`);try{await e.request({method:"POST",path:"/shutdown"})}catch(d){process.stderr.write(`coze-bridge: stop failed (continuing): ${String(d)}
|
|
237
|
+
`)}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
|
|
238
|
+
`)}catch(d){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(d)}
|
|
239
239
|
`)}let o=t.paths??J(),{rm:c}=await import("node:fs/promises");try{await c(o.bridgeRoot,{recursive:!0,force:!0}),process.stdout.write(`coze-bridge: removed ${o.bridgeRoot}
|
|
240
|
-
`)}catch(
|
|
240
|
+
`)}catch(d){return process.stderr.write(`coze-bridge: remove failed: ${String(d)}
|
|
241
241
|
`),1}return process.stdout.write(`coze-bridge: purged (agents workspaces preserved under ~/.coze/agents)
|
|
242
|
-
`),0}async function
|
|
242
|
+
`),0}async function _2(t){let e=await hs(t);if(!e)return 0;try{return process.stdout.write(`coze-bridge: installing ${e.platform} supervisor...
|
|
243
243
|
`),await e.install(),process.stdout.write(`coze-bridge: supervisor installed (daemon will auto-start on login)
|
|
244
244
|
`),0}catch(r){return process.stderr.write(`coze-bridge: service install failed: ${String(r)}
|
|
245
|
-
`),1}}async function
|
|
245
|
+
`),1}}async function y2(t){let e=await hs(t);if(!e)return 0;try{return await e.uninstall(),process.stdout.write(`coze-bridge: ${e.platform} supervisor unregistered
|
|
246
246
|
`),0}catch(r){return process.stderr.write(`coze-bridge: service uninstall failed: ${String(r)}
|
|
247
|
-
`),1}}async function zp(t,e,r){if(e)return
|
|
248
|
-
`),
|
|
249
|
-
`),(await
|
|
250
|
-
`)}let
|
|
251
|
-
`),1;let
|
|
247
|
+
`),1}}async function zp(t,e,r){if(e)return Tt(t.bridgeLogsDir,"info","cli","agent-env: skip rebuild, use process.env",{}),process.env;let i=await r();return i.kind==="ok"?(Tt(t.bridgeLogsDir,"info","cli","agent-env: rebuilt from login shell",{vars:Object.keys(i.env).length}),i.env):i.kind==="skipped"?(Tt(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)
|
|
248
|
+
`),Tt(t.bridgeLogsDir,"warn","cli","reconstructLoginShellEnv failed, fell back to process.env",{reason:i.reason}),process.env)}async function E2(t,e,r,i={},o,c){let d=new nn(r.paths),u=r.paths??J(),x=await zp(u,c,r.reconstructEnv??Yl);if(await Zc(u,x).catch(w=>Tt(u.bridgeLogsDir,"warn","cli","writeAgentEnv failed (ignored)",{err:String(w)})),!r.skipDistInstall){let w=await nd({paths:r.paths});w.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${w.fromVersion} \u2192 ${w.toVersion}
|
|
249
|
+
`),(await d.probe()).kind==="connected"&&(await d.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(_=>setTimeout(_,500)))):w.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${w.libVersion}
|
|
250
|
+
`)}let h=await Fp(r,d);if(h.kind!=="connected")return process.stderr.write(`coze-bridge: daemon did not come up: ${h.kind}
|
|
251
|
+
`),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 w=await d.request({method:"POST",path:"/pair",body:m,timeoutMs:35e3});if(w.status===200&&w.body?.ok){let S=w.body.agent;return S&&!S.ok?(process.stderr.write(`coze-bridge: paired but agent ensure failed (agentId=${S.agentId}): ${S.note}
|
|
252
252
|
`),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"
|
|
253
|
-
`),0)}return process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(
|
|
254
|
-
`),1}catch(
|
|
255
|
-
`),1}}async function
|
|
256
|
-
`),(await
|
|
257
|
-
`)}let
|
|
258
|
-
`),1;let
|
|
259
|
-
`),t!==void 0&&await
|
|
260
|
-
`),1)}catch(
|
|
261
|
-
`),1}}async function Op(t,e,r){let i=Date.now()+e;for(;Date.now()<i;){let o=await t.probe(500);if(o.kind==="connected")return o;await r(200)}return t.probe(500)}async function
|
|
253
|
+
`),0)}return process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(w.body)}
|
|
254
|
+
`),1}catch(w){return process.stderr.write(`coze-bridge: pair failed: ${String(w)}
|
|
255
|
+
`),1}}async function b2(t,e,r={},i){let o=e.paths??J(),c=t??await ia(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 zp(o,i,e.reconstructEnv??Yl);if(await Zc(o,u).catch(m=>Tt(o.bridgeLogsDir,"warn","cli","writeAgentEnv failed (ignored)",{err:String(m)})),!e.skipDistInstall){let m=await nd({paths:e.paths});m.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${m.fromVersion} \u2192 ${m.toVersion}
|
|
256
|
+
`),(await d.probe()).kind==="connected"&&(await d.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(S=>setTimeout(S,500)))):m.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${m.libVersion}
|
|
257
|
+
`)}let x=await Fp(e,d);if(x.kind!=="connected")return process.stderr.write(`coze-bridge: daemon did not come up: ${x.kind}
|
|
258
|
+
`),1;let h={privatecode:c};r.env&&(h.env=r.env),r.handshakeUrl&&(h.handshake_url=r.handshakeUrl),r.frontierUrl&&(h.frontier_url=r.frontierUrl),r.mockScenario&&(h.mock_scenario=r.mockScenario);try{let m=await d.request({method:"POST",path:"/connect",body:h,timeoutMs:35e3});return m.status===200&&m.body?.ok?(process.stdout.write(`coze-bridge: connected (${m.body.note??"ok"})
|
|
259
|
+
`),t!==void 0&&await ds(c,o).catch(w=>Lp.warn("writePatToken after connect failed (ignored)",{err:String(w)})),0):(process.stderr.write(`coze-bridge: connect failed: ${JSON.stringify(m.body)}
|
|
260
|
+
`),1)}catch(m){return process.stderr.write(`coze-bridge: connect failed: ${String(m)}
|
|
261
|
+
`),1}}async function Op(t,e,r){let i=Date.now()+e;for(;Date.now()<i;){let o=await t.probe(500);if(o.kind==="connected")return o;await r(200)}return t.probe(500)}async function v2(t,e,r=60,i=200){let{readFile:o}=await import("node:fs/promises");for(let c=0;c<r;c++){let d;try{d=await o(t,"utf8")}catch{return}let u=Number.parseInt(d.trim(),10);if(!Number.isFinite(u)||u<=0||!Vi(u))return;await e(i)}}function S2(t){return new Promise(e=>setTimeout(e,t))}re();function I2(t){let e=/^v?(\d+)(?:\.(\d+))?/.exec(t.trim());if(!e)return"ok";let r=Number(e[1]),i=Number(e[2]??0);return r<18||r===18&&i<4?"fatal":r<20?"warn":"ok"}function Up(t=process.versions.node,e=i=>{process.stderr.write(i)},r=i=>process.exit(i)){let i=I2(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
|
|
262
262
|
`),r(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
|
|
263
263
|
\u5347\u7EA7\u5B8C\u540E\u9700\u8981\u6267\u884C\u4EE5\u4E0B\u547D\u4EE4\u91CD\u65B0\u8FDE\u63A5:
|
|
264
264
|
npx -y coze-bridge@latest stop
|
|
265
265
|
npx -y coze-bridge@latest connect
|
|
266
266
|
|
|
267
|
-
`)}Up();!process.argv.includes("--daemon")&&!process.env.COZE_BRIDGE_LOG_LEVEL&&
|
|
267
|
+
`)}Up();!process.argv.includes("--daemon")&&!process.env.COZE_BRIDGE_LOG_LEVEL&&Td("warn");Np(process.argv).then(t=>process.exit(t),t=>{process.stderr.write(`fatal: ${t instanceof Error?t.stack??t.message:String(t)}
|
|
268
268
|
`),process.exit(1)});
|