@whalent/agent 0.3.66 → 0.3.68
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/core.cjs +7 -7
- package/dist/index.cjs +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
'use strict';const a0_0xeb103c=a0_0x2b2a;(function(_0xec8f14,_0x5f1557){const _0x2d2ecc=a0_0x2b2a,_0x33b90a=_0xec8f14();while(!![]){try{const _0x2ea136=-parseInt(_0x2d2ecc(0x1ba))/0x1*(parseInt(_0x2d2ecc(0x1e6))/0x2)+parseInt(_0x2d2ecc(0x1e4))/0x3+parseInt(_0x2d2ecc(0x1f0))/0x4+-parseInt(_0x2d2ecc(0x1c6))/0x5*(-parseInt(_0x2d2ecc(0x1ea))/0x6)+-parseInt(_0x2d2ecc(0x182))/0x7*(parseInt(_0x2d2ecc(0x197))/0x8)+parseInt(_0x2d2ecc(0x1e3))/0x9*(-parseInt(_0x2d2ecc(0x1c0))/0xa)+parseInt(_0x2d2ecc(0x196))/0xb;if(_0x2ea136===_0x5f1557)break;else _0x33b90a['push'](_0x33b90a['shift']());}catch(_0x520dea){_0x33b90a['push'](_0x33b90a['shift']());}}}(a0_0x2180,0x771e1));var __create=Object['create'],__defProp=Object[a0_0xeb103c(0x1a7)],__getOwnPropDesc=Object[a0_0xeb103c(0x1d2)+'ptor'],__getOwnPropNames=Object[a0_0xeb103c(0x17e)],__getProtoOf=Object[a0_0xeb103c(0x1a8)],__hasOwnProp=Object[a0_0xeb103c(0x19e)][a0_0xeb103c(0x1d5)],__copyProps=(_0x596e77,_0x1348b3,_0x4b7825,_0x230c4f)=>{if(_0x1348b3&&typeof _0x1348b3==='object'||typeof _0x1348b3==='function'){for(let _0x4db399 of __getOwnPropNames(_0x1348b3))if(!__hasOwnProp['call'](_0x596e77,_0x4db399)&&_0x4db399!==_0x4b7825)__defProp(_0x596e77,_0x4db399,{'get':()=>_0x1348b3[_0x4db399],'enumerable':!(_0x230c4f=__getOwnPropDesc(_0x1348b3,_0x4db399))||_0x230c4f['enumerable']});}return _0x596e77;},__toESM=(_0x3490d1,_0xc7fce8,_0x4a2927)=>(_0x4a2927=_0x3490d1!=null?__create(__getProtoOf(_0x3490d1)):{},__copyProps(_0xc7fce8||!_0x3490d1||!_0x3490d1[a0_0xeb103c(0x1c2)]?__defProp(_0x4a2927,'default',{'value':_0x3490d1,'enumerable':!![]}):_0x4a2927,_0x3490d1)),import_child_process=require(a0_0xeb103c(0x1b6)),fs=__toESM(require('fs'),0x1),import_module=require('module'),os=__toESM(require('os'),0x1),path=__toESM(require('path'),0x1),WRAPPER_PKG_NAME='@whalent/agent',CORE_PKG_NAME='@whalent/agent-core',NPM_REGISTRY=a0_0xeb103c(0x18d)+'js.org',SUPERVISED_RESTART_CODE=0x4b,NPM_VIEW_TIMEOUT_MS=0x3a98,HEALTH_TIMEOUT_MS=0xafc8,MIN_RESTART_DELAY_MS=0x3e8,MAX_RESTART_DELAY_MS=0xea60,NPM_INSTALL_TIMEOUT_MS=0xa*0x3c*0x3e8,NPM_INSTALL_MAX_BUFFER=0x20*0x400*0x400,FATAL_PATTERN=/\[(?:agent|daemon|wrapper)\][^\n]*\bFatal error:[^\n]+|\[daemon\] Failed to start:[^\n]+|ENOSPC:[^\n]+|EACCES:[^\n]+|EPERM:[^\n]+|EAGAIN:[^\n]+|EMFILE:[^\n]+/,WRAPPER_VERSION=readWrapperVersion(),CHECKED_PTY_HELPERS=new Set();function wrapperBaseDir(){return __dirname;}function configDir(){const _0x5902db=a0_0xeb103c;return path['join'](os['homedir'](),_0x5902db(0x1af));}function upgradeStatePath(){return path['join'](configDir(),'core-upgrade.json');}function lastCrashFilePath(){const _0x2a27f0=a0_0xeb103c;return path[_0x2a27f0(0x187)](configDir(),_0x2a27f0(0x1a4));}function writeLastCrash(_0x5bba7b){const _0x3f84fb=a0_0xeb103c;try{fs[_0x3f84fb(0x1ac)](configDir(),{'recursive':!![]});const _0x3fdbab={..._0x5bba7b,'reported':![]};fs[_0x3f84fb(0x18e)](lastCrashFilePath(),JSON['stringify'](_0x3fdbab,null,0x2),'utf-8');}catch{}}function readWrapperVersion(){const _0x8cacaf=a0_0xeb103c;try{const _0x6041b2=JSON['parse'](fs['readFileSync'](path[_0x8cacaf(0x187)](wrapperBaseDir(),'..','package.json'),_0x8cacaf(0x1ca)));return String(_0x6041b2['version']||'0.0.0');}catch{return _0x8cacaf(0x1e5);}}function readUpgradeState(){const _0x2470ad=a0_0xeb103c;try{return JSON[_0x2470ad(0x18c)](fs['readFileSync'](upgradeStatePath(),'utf-8'));}catch{return null;}}function writeUpgradeState(_0x11fdf1){const _0x5c71d3=a0_0xeb103c;try{fs[_0x5c71d3(0x1ac)](configDir(),{'recursive':!![]}),fs[_0x5c71d3(0x18e)](upgradeStatePath(),JSON['stringify']({..._0x11fdf1,'updated_at':Date['now']()},null,0x2),_0x5c71d3(0x1ca));}catch{}}function run(_0x2c0a6a,_0xfa365b,_0x9c1e90=process.env){const _0x1bea60=a0_0xeb103c;return(0x0,import_child_process[_0x1bea60(0x1d1)])(_0x2c0a6a,_0xfa365b,{'encoding':'utf8','timeout':NPM_INSTALL_TIMEOUT_MS,'maxBuffer':NPM_INSTALL_MAX_BUFFER,'env':_0x9c1e90,'shell':![]});}function runNpmView(_0x125d58){const _0x4f82e6=a0_0xeb103c,_0x51557f=resolveExecutable(_0x4f82e6(0x1c7));if(!_0x51557f)return{'status':0x7f,'stdout':'','stderr':'npm\x20not\x20found','error':new Error(_0x4f82e6(0x185))};return(0x0,import_child_process[_0x4f82e6(0x1d1)])(_0x51557f,_0x125d58,{'encoding':'utf8','timeout':NPM_VIEW_TIMEOUT_MS,'maxBuffer':0x400*0x400,'env':process.env,'shell':![]});}function npmRootGlobal(){const _0x7de7e4=a0_0xeb103c,_0x35ab67=resolveExecutable('npm');if(!_0x35ab67)return'';const _0x5e59a0=run(_0x35ab67,['root','-g']);if(_0x5e59a0[_0x7de7e4(0x1b9)]!==0x0)return'';return String(_0x5e59a0['stdout']||'')[_0x7de7e4(0x1b1)]();}function compareSemver(_0x5f0d96,_0x8b481e){const _0x2b3cc3=a0_0xeb103c,_0x258c8a=String(_0x5f0d96||'')[_0x2b3cc3(0x19f)](/^v/,'')['split'](/[.-]/)['map'](_0x35251a=>Number['parseInt'](_0x35251a,0xa)||0x0),_0x394d62=String(_0x8b481e||'')[_0x2b3cc3(0x19f)](/^v/,'')['split'](/[.-]/)['map'](_0x58834b=>Number[_0x2b3cc3(0x1e9)](_0x58834b,0xa)||0x0);for(let _0x3ab6a9=0x0;_0x3ab6a9<Math['max'](_0x258c8a['length'],_0x394d62[_0x2b3cc3(0x1dd)],0x3);_0x3ab6a9++){const _0x118ba6=_0x258c8a[_0x3ab6a9]||0x0,_0x44fc4f=_0x394d62[_0x3ab6a9]||0x0;if(_0x118ba6>_0x44fc4f)return 0x1;if(_0x118ba6<_0x44fc4f)return-0x1;}return 0x0;}function resolveExecutable(_0xb75313){const _0x2c704e=a0_0xeb103c,_0x54cf9d=process[_0x2c704e(0x1cc)]===_0x2c704e(0x199)?_0x2c704e(0x192):'which';try{const _0x4c3c3d=(0x0,import_child_process['spawnSync'])(_0x54cf9d,[_0xb75313],{'encoding':_0x2c704e(0x19d),'timeout':0xbb8,'shell':![]});if(_0x4c3c3d['status']!==0x0)return'';return String(_0x4c3c3d['stdout']||'')['split'](/\r?\n/)[_0x2c704e(0x1bc)](_0x428ef9=>_0x428ef9[_0x2c704e(0x1b1)]())[_0x2c704e(0x1da)](Boolean)[0x0]||'';}catch{return'';}}function skipWrapperUpdateCheck(){const _0x4108c4=a0_0xeb103c,_0x23ee08=String(process.env.WHALENT_SKIP_UPDATE_CHECK||process.env.WHALENT_NO_UPDATE_CHECK||process.env.WHALENT_SKIP_WRAPPER_UPDATE||'')['trim']()[_0x4108c4(0x1cb)]();return _0x23ee08==='1'||_0x23ee08===_0x4108c4(0x18b)||_0x23ee08==='yes'||_0x23ee08==='on';}function latestWrapperVersion(){const _0x132c1a=a0_0xeb103c,_0x518ada=runNpmView(['view',WRAPPER_PKG_NAME+'@latest','version',_0x132c1a(0x191)+NPM_REGISTRY]);if(_0x518ada['status']!==0x0)return'';return String(_0x518ada['stdout']||'')[_0x132c1a(0x1b1)]()['split'](/\r?\n/)[_0x132c1a(0x1da)](Boolean)['pop']()||'';}function installWrapperVersion(_0x27c63f){const _0x31d367=a0_0xeb103c,_0x3d5744=resolveExecutable('npm');if(!_0x3d5744)return{'ok':![],'output':'npm\x20not\x20found\x20on\x20PAT'+'H'};const _0x5d844e=run(_0x3d5744,[_0x31d367(0x184),'-g',WRAPPER_PKG_NAME+'@'+_0x27c63f,'--registry='+NPM_REGISTRY]),_0x3a1309=((_0x5d844e[_0x31d367(0x1e2)]||'')+'\x0a'+(_0x5d844e[_0x31d367(0x1eb)]||''))['trim']();return{'ok':_0x5d844e['status']===0x0,'output':_0x3a1309};}function maybeUpdateWrapper(_0x55a240){const _0x35a1e8=a0_0xeb103c;if(skipWrapperUpdateCheck())return![];if(process.env.WHALENT_WRAPPER_UPDATE_ATTEMPTED)return![];const _0x150129=latestWrapperVersion();if(!_0x150129||compareSemver(_0x150129,WRAPPER_VERSION)<=0x0)return![];console[_0x35a1e8(0x1c9)]('[wrapper]\x20update\x20ava'+_0x35a1e8(0x194)+WRAPPER_VERSION+'\x20->\x20'+_0x150129),console[_0x35a1e8(0x1c9)]('[wrapper]\x20installing'+'\x20'+WRAPPER_PKG_NAME+'@'+_0x150129+('\x20from\x20npm\x20before\x20sta'+_0x35a1e8(0x1d0)));const _0x181b22=installWrapperVersion(_0x150129);if(!_0x181b22['ok']){console[_0x35a1e8(0x1c9)]('[wrapper]\x20wrapper\x20up'+'date\x20failed;\x20continu'+_0x35a1e8(0x1ab)+WRAPPER_VERSION);if(_0x181b22['output'])console[_0x35a1e8(0x1c9)](_0x181b22[_0x35a1e8(0x1e0)]['split'](/\r?\n/)[_0x35a1e8(0x1b3)](-0xc)['join']('\x0a'));return console[_0x35a1e8(0x1c9)]('[wrapper]\x20Manual\x20upd'+'ate:\x20npm\x20install\x20-g\x20'+WRAPPER_PKG_NAME+'@'+_0x150129+'\x20--registry='+NPM_REGISTRY),![];}console[_0x35a1e8(0x1c9)]('[wrapper]\x20wrapper\x20up'+_0x35a1e8(0x1e8)+_0x150129+';\x20restarting\x20wrapper');const _0x38accb=process['argv'][0x1],_0x69f076=(0x0,import_child_process['spawnSync'])(process['execPath'],[_0x38accb,..._0x55a240],{'stdio':'inherit','env':{...process.env,'WHALENT_WRAPPER_UPDATE_ATTEMPTED':_0x150129},'shell':![]});process['exit'](_0x69f076['status']??0x0);}function findCoreScript(){const _0xd4f2ea=a0_0xeb103c,_0x26a7a5=String(process.env.WHALENT_CORE_ENTRY||'')['trim'](),_0x4510e3=['1',_0xd4f2ea(0x18b),'yes','on']['includes'](String(process.env.WHALENT_FORCE_CORE_ENTRY||'')[_0xd4f2ea(0x1b1)]()['toLowerCase']());if(_0x26a7a5&&_0x4510e3&&fs['existsSync'](_0x26a7a5))return _0x26a7a5;const _0x38585f=[],_0x1f88f2=_0xcaa214=>{const _0x5019f8=_0xd4f2ea;if(fs[_0x5019f8(0x181)](_0xcaa214)&&!_0x38585f[_0x5019f8(0x1c3)](_0xcaa214))_0x38585f[_0x5019f8(0x1ad)](_0xcaa214);};if(_0x26a7a5)_0x1f88f2(_0x26a7a5);const _0x1e1f53=npmRootGlobal();if(_0x1e1f53){const _0x52e18d=path['join'](_0x1e1f53,_0xd4f2ea(0x1a0),_0xd4f2ea(0x180),'dist',_0xd4f2ea(0x1b7));_0x1f88f2(_0x52e18d);}const _0x20f803=path[_0xd4f2ea(0x187)](wrapperBaseDir(),'core.cjs');_0x1f88f2(_0x20f803);const _0x4f529c=path[_0xd4f2ea(0x187)](wrapperBaseDir(),'..','packages','core',_0xd4f2ea(0x17d),_0xd4f2ea(0x1b7));_0x1f88f2(_0x4f529c);if(_0x38585f['length']>0x0)return _0x38585f[_0xd4f2ea(0x1bc)]((_0x116a2d,_0x1ba183)=>({'candidate':_0x116a2d,'index':_0x1ba183,'version':coreVersion(_0x116a2d)}))['sort']((_0x5bb20b,_0x1f763b)=>{const _0x1882d6=_0xd4f2ea,_0x56fabc=compareSemver(_0x1f763b[_0x1882d6(0x1d9)],_0x5bb20b['version']);if(_0x56fabc!==0x0)return _0x56fabc;return _0x1f763b[_0x1882d6(0x1ed)]-_0x5bb20b[_0x1882d6(0x1ed)];})[0x0][_0xd4f2ea(0x195)];throw new Error('whalent\x20core\x20runtime'+_0xd4f2ea(0x18f)+'@whalent/agent-core\x20'+'or\x20rebuild\x20@whalent/'+'agent');}function a0_0x2180(){const _0x38ea39=['ywrK','mtiZotG1meLtrejfsW','BwnW','x19LC01VzhvSzq','Aw5JBhvKzxm','BM90igLUC3rHBgXLza','w3DYyxbWzxjDifj1BIb0AgLZig8','nxPgB1j5Ea','BNbT','ChjLyNvPBgrZ','D2fYBG','DxrMltG','Dg9mB3DLCKnHC2u','CgXHDgzVCM0','w3DYyxbWzxjDig1Hy09tig5Vzgu','w3DYyxbWzxjDiezHDgfSigvYCM8','A2LSBa','CNrPBMCGy29Yzs4UlG','C3bHD25tEw5J','z2v0t3DUuhjVCgvYDhLezxnJCMK','l3bLCM1PC3nPB25ZigjLzM9Yzsa','w3DYyxbWzxjDignVCMuGDxbNCMe','AgfZt3DUuhjVCgvYDhK','zxHPDa','C2LNBMfS','ywnR','DMvYC2LVBG','zMLSDgvY','w3DYyxbWzxjDig5LDYbJB3jLigq','ls12zxjZAw9U','BgvUz3rO','CgvUzgLUzW','Bwf0y2G','B3v0Chv0','zgf0yq','C3rKB3v0','nJnhwxjXA0m','mZi3mtu5y2TVugfH','mc4WlJa','nNL3qwDREa','BMnLihrVigzPEcb0zxjTAw5HBc8','zgf0zwqGDg8G','CgfYC2vjBNq','mJe3nduYnMHotxfYvW','C3rKzxjY','CM9SBgvKx2jHy2S','Aw5KzxG','j1WNjW','ywnJzxnZu3LUyW','mtu1ndaYogzsy0rNCW','zxHLy1bHDgG','w3DYyxbWzxjDihn0yxj0Aw5Nigm','y2HTB2rtEw5J','zxjYB3i','u0Lhsu5u','BwvZC2fNzq','BIb1BMTUB3DU','C3bHD24','CgLWzq','y29Yzsa','lxb0EsbZCgf3BI1OzwXWzxiGBM8','zgLZDa','z2v0t3DUuhjVCgvYDhLoyw1LCW','yxjNDG','ywDLBNqTy29Yzq','zxHPC3rZu3LUyW','mtmWndq1CxrmBvzb','D3jPDgu','Aw5ZDgfSBa','BNbTig5VDcbMB3vUza','r2f0zxDHEsbYzwDPC3rLCMvKig0','AM9PBG','Aw5ZDgfSBgvKx3zLCNnPB24','ls1QC29U','CMv0CNLPBMC','Dhj1zq','CgfYC2u','Ahr0Chm6lY9YzwDPC3rYEs5UCg0','D3jPDgvgAwXLu3LUyW','ig5VDcbMB3vUzdSGAw5ZDgfSBca','y29Kzq','ls1YzwDPC3rYEt0','D2HLCMuUzxHL','zcbJB2rLpq','AwXHyMXLoIa','y2fUzgLKyxrL','mte5mtyWmdn2BMvuu04','mtiWDvjVzgjf','C2HPzNq','D2LUmZi','ihnPz25HBd0','zgfLBw9Ulw1JCa','ChjLDMLVDxmGy29Yzsb2zxjZAw8','DxrMoa','ChjVDg90ExbL','CMvWBgfJzq','qhDOywXLBNq','AgvHBhrOEq','CMvZB2X2zq','y2SGy29Yzsb0BYa','BgfZDc1JCMfZAc5QC29U','ChjLDMLVDxnFy29Yzv92zxjZAw8','zgfYD2LUlq','zgvMAw5LuhjVCgvYDhK','z2v0uhjVDg90ExbLt2y','Aw5OzxjPDa','icbSCYaTBcaIjeHftfbfuIi','Aw5NihDPDgGG','BwTKAxjtEw5J','ChvZAa','y3jLyxrLuMvXDwLYzq','lNDOywXLBNqTywDLBNq','BM9Kzs1WDhK','DhjPBq','ls1OzwXW','C2XPy2u','B25Jzq','EsbPBIb0Aw1LoYbYB2XSAw5Nigi','y2HPBgrFChjVy2vZCW','Aw5KzxGUy2PZ','Bg9N','C3rHDhvZ','mtaYnJqZENDKsuTm','ls1Hz2vUDc1Pza','BwfW','w3DYyxbWzxjDignVCMuGAgfZigm','lxb0EsbZCgf3BI1OzwXWzxiGAxm'];a0_0x2180=function(){return _0x38ea39;};return a0_0x2180();}function coreVersion(_0x113007=findCoreScript()){const _0x122de7=a0_0xeb103c,_0x2d46e8=(0x0,import_child_process[_0x122de7(0x1d1)])(process[_0x122de7(0x1f1)],[_0x113007,_0x122de7(0x1dc)],{'encoding':_0x122de7(0x19d),'timeout':0x3a98,'env':{...process.env,'WHALENT_SKIP_UPDATE_CHECK':'1'},'shell':![]}),_0x2b31d6=(_0x2d46e8['stdout']||'')+'\x0a'+(_0x2d46e8[_0x122de7(0x1eb)]||'');return _0x2b31d6[_0x122de7(0x1df)](/(\d+\.\d+\.\d+(?:[-\w.]+)?)/)?.[0x1]||'';}function isExecutable(_0x255c35){const _0x141567=a0_0xeb103c;try{return fs[_0x141567(0x1ef)](_0x255c35,fs['constants']['X_OK']),!![];}catch{return![];}}function shellQuote(_0x4f610c){const _0x50c040=a0_0xeb103c;return'\x27'+_0x4f610c['replace'](/'/g,_0x50c040(0x1ee))+'\x27';}function coreNodePtySpawnHelperPath(_0x24f40c){const _0x572772=a0_0xeb103c;if(process[_0x572772(0x1cc)]!=='darwin')return'';try{const _0x180e5d=(0x0,import_module[_0x572772(0x1ae)])(_0x24f40c),_0x2b3ae4=_0x180e5d[_0x572772(0x1a2)](_0x572772(0x1b0)),_0x176d2e=path[_0x572772(0x1a2)](path['dirname'](_0x2b3ae4),'..');return path[_0x572772(0x187)](_0x176d2e,_0x572772(0x1c8),_0x572772(0x1a6)+process['arch'],'spawn-helper');}catch{return'';}}function checkMacNodePtySpawnHelper(_0x55fc9b){const _0xbfd4e5=a0_0xeb103c,_0x2e976f=coreNodePtySpawnHelperPath(_0x55fc9b);if(!_0x2e976f||CHECKED_PTY_HELPERS['has'](_0x2e976f))return;CHECKED_PTY_HELPERS[_0xbfd4e5(0x1bf)](_0x2e976f);if(!fs[_0xbfd4e5(0x181)](_0x2e976f)){console[_0xbfd4e5(0x1c9)]('[wrapper]\x20macOS\x20node'+_0xbfd4e5(0x1fb)+'t\x20found:\x20'+_0x2e976f);return;}if(isExecutable(_0x2e976f))return;try{const _0x3b5e0c=fs['statSync'](_0x2e976f)['mode'];fs[_0xbfd4e5(0x1f3)](_0x2e976f,_0x3b5e0c|0x1ed);}catch{}if(isExecutable(_0x2e976f)){console[_0xbfd4e5(0x1c9)]('[wrapper]\x20fixed\x20macO'+'S\x20node-pty\x20spawn-hel'+'per\x20executable\x20bit:\x20'+_0x2e976f);return;}console['warn'](_0xbfd4e5(0x1cd)+_0xbfd4e5(0x1be)+'\x20not\x20executable:\x20'+_0x2e976f),console['warn'](_0xbfd4e5(0x1c5)+_0xbfd4e5(0x1e7)+'PTY\x20startup:'),console[_0xbfd4e5(0x1c9)]('\x20\x20HELPER='+shellQuote(_0x2e976f)),console[_0xbfd4e5(0x1c9)](_0xbfd4e5(0x1aa)),console['warn']('\x20\x20chmod\x20+x\x20\x22$HELPER\x22');}function printVersion(){const _0x4f539c=a0_0xeb103c;let _0x13dd3c='';try{_0x13dd3c=coreVersion();}catch{}console[_0x4f539c(0x1b8)]('whalent-agent\x20'+WRAPPER_VERSION),console['log']('wrapper\x20'+WRAPPER_VERSION),console[_0x4f539c(0x1b8)]('core\x20'+(_0x13dd3c||_0x4f539c(0x1c4)));}function directCore(_0x22b4c4){const _0x5e92c2=a0_0xeb103c,_0x45d7cb=findCoreScript();checkMacNodePtySpawnHelper(_0x45d7cb);const _0x2196e3=(0x0,import_child_process['spawnSync'])(process[_0x5e92c2(0x1f1)],[_0x45d7cb,..._0x22b4c4],{'stdio':'inherit','env':{...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_CORE_ENTRY':_0x45d7cb},'shell':![]});process['exit'](_0x2196e3['status']??0x0);}function shouldSupervise(_0x2d4186){const _0x232304=a0_0xeb103c;if(_0x2d4186['includes'](_0x232304(0x1bb)))return![];const _0x1d26a6=_0x2d4186[0x0]||'';if(_0x1d26a6==='ls'||_0x1d26a6==='status'||_0x1d26a6==='ps')return![];if(_0x1d26a6===_0x232304(0x1c1)||_0x1d26a6===_0x232304(0x19b))return![];if(_0x2d4186['includes'](_0x232304(0x1b2))||_0x2d4186[_0x232304(0x1c3)]('-h'))return![];return!![];}function installCoreVersion(_0x23e81f){const _0x1cdb18=a0_0xeb103c,_0x1f0010=resolveExecutable('npm');if(!_0x1f0010)return{'ok':![],'output':'npm\x20not\x20found\x20on\x20PAT'+'H'};const _0x42cca2=CORE_PKG_NAME+'@'+_0x23e81f,_0x1e41bf=run(_0x1f0010,['install','-g',_0x42cca2,'--registry='+NPM_REGISTRY]),_0xd54565=((_0x1e41bf[_0x1cdb18(0x1e2)]||'')+'\x0a'+(_0x1e41bf[_0x1cdb18(0x1eb)]||''))['trim']();return{'ok':_0x1e41bf['status']===0x0,'output':_0xd54565};}async function superviseCore(_0x1b648e){const _0x47f0fe=a0_0xeb103c;let _0x14b5d8=![],_0x23d9d3=null,_0x3d01bf=0x0,_0x59b90f=MIN_RESTART_DELAY_MS;const _0x4c7371=()=>{const _0x15a592=a0_0x2b2a;_0x14b5d8=!![];if(_0x23d9d3&&!_0x23d9d3['killed'])try{_0x23d9d3[_0x15a592(0x1cf)]('SIGTERM');}catch{}else process['exit'](0x0);};process['on'](_0x47f0fe(0x1f5),_0x4c7371),process['on']('SIGTERM',_0x4c7371);while(!![]){const _0x48fa26=findCoreScript();checkMacNodePtySpawnHelper(_0x48fa26);const _0x4c9a1d={...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_WRAPPER_MANAGED':'1','WHALENT_CORE_ENTRY':_0x48fa26},_0x4af62a=readUpgradeState(),_0x2f43d6=!!_0x4af62a?.[_0x47f0fe(0x1de)];let _0x4009bb=![],_0x13675a=null,_0x58b370='';const _0x2f208c=[],_0x397503=0xc;console[_0x47f0fe(0x1b8)](_0x47f0fe(0x1f2)+'ore:\x20'+_0x48fa26),_0x23d9d3=(0x0,import_child_process[_0x47f0fe(0x1f8)])(process['execPath'],[_0x48fa26,..._0x1b648e],{'env':_0x4c9a1d,'stdio':[_0x47f0fe(0x1a9),'pipe',_0x47f0fe(0x1f9)]});const _0x2d0fc2=()=>{const _0xa60f2d=_0x47f0fe;if(_0x4009bb)return;_0x4009bb=!![];if(_0x13675a)clearTimeout(_0x13675a);_0x3d01bf=0x0,_0x59b90f=MIN_RESTART_DELAY_MS;const _0x4f5ea8=readUpgradeState();_0x4f5ea8?.['pending']&&(writeUpgradeState({..._0x4f5ea8,'pending':![],'rollback':![],'health_status':_0xa60f2d(0x1a1)}),console['log'](_0xa60f2d(0x1d4)+'de\x20healthy:\x20'+(_0x4f5ea8[_0xa60f2d(0x188)]||_0x4f5ea8['target_version']||'')));},_0x4c0f80=(_0x4b1d12,_0x26b04d=![])=>{const _0xa7225=_0x47f0fe,_0x56234c=_0x4b1d12['toString']();(_0x26b04d?process[_0xa7225(0x1eb)]:process['stdout'])[_0xa7225(0x183)](_0x56234c);if(_0x26b04d)for(const _0x1f2940 of _0x56234c['split'](/\r?\n/)){if(!_0x1f2940[_0xa7225(0x1b1)]())continue;_0x2f208c[_0xa7225(0x1ad)](_0x1f2940);if(_0x2f208c['length']>_0x397503)_0x2f208c[_0xa7225(0x198)]();const _0x46d822=_0x1f2940['match'](FATAL_PATTERN);if(_0x46d822)_0x58b370=_0x46d822[0x0];}(_0x56234c[_0xa7225(0x1c3)]('[gateway]\x20Connected')||_0x56234c[_0xa7225(0x1c3)](_0xa7225(0x186)+'achine')||_0x56234c['includes']('Gateway:\x20connected'))&&_0x2d0fc2();};_0x23d9d3['stdout']?.['on']('data',_0x12e774=>_0x4c0f80(_0x12e774,![])),_0x23d9d3[_0x47f0fe(0x1eb)]?.['on'](_0x47f0fe(0x1e1),_0x3dd155=>_0x4c0f80(_0x3dd155,!![]));_0x2f43d6&&(_0x13675a=setTimeout(()=>{const _0x200df5=_0x47f0fe;if(_0x4009bb||!_0x23d9d3||_0x23d9d3['killed'])return;console[_0x200df5(0x1f4)](_0x200df5(0x1db)+'id\x20not\x20become\x20health'+_0x200df5(0x1b5)+_0x200df5(0x1d8));try{_0x23d9d3[_0x200df5(0x1cf)]('SIGTERM');}catch{}},HEALTH_TIMEOUT_MS));const _0x1b12ff=await new Promise(_0x44c51e=>{const _0xb30480=_0x47f0fe;_0x23d9d3[_0xb30480(0x1b4)]('exit',(_0x27635c,_0x55ee31)=>_0x44c51e({'code':_0x27635c,'signal':_0x55ee31}));});if(_0x13675a)clearTimeout(_0x13675a);_0x23d9d3=null;if(_0x14b5d8)process['exit'](_0x1b12ff[_0x47f0fe(0x190)]??0x0);const _0xe62c52=readUpgradeState();if(_0xe62c52?.[_0x47f0fe(0x1de)]&&!_0x4009bb){const _0xd36571=String(_0xe62c52[_0x47f0fe(0x1a5)+'n']||'')[_0x47f0fe(0x1b1)]();if(_0xd36571){console['error']('[wrapper]\x20rolling\x20ba'+_0x47f0fe(0x1a3)+_0xd36571);const _0x4d2394=installCoreVersion(_0xd36571);writeUpgradeState({..._0xe62c52,'pending':![],'rollback':!![],'health_status':_0x4d2394['ok']?_0x47f0fe(0x1ec):'rollback_failed','error':_0x4d2394['ok']?'':_0x4d2394[_0x47f0fe(0x1e0)]});}else writeUpgradeState({..._0xe62c52,'pending':![],'rollback':!![],'health_status':'rollback_unavailable','error':_0x47f0fe(0x19c)+_0x47f0fe(0x1f7)});}const _0x4549c4=_0x1b12ff[_0x47f0fe(0x190)]===SUPERVISED_RESTART_CODE||_0xe62c52?.['pending'];if(!_0x4549c4&&_0x1b12ff['code']===0x0)process[_0x47f0fe(0x1d6)](0x0);_0x3d01bf+=0x1,writeLastCrash({'timestamp':Date['now'](),'exit_code':_0x1b12ff[_0x47f0fe(0x190)],'exit_signal':_0x1b12ff[_0x47f0fe(0x1d7)]||null,'fatal_line':_0x58b370,'raw_tail':_0x2f208c[_0x47f0fe(0x187)]('\x0a'),'consecutive_crashes':_0x3d01bf}),console['log']('[wrapper]\x20core\x20exite'+_0x47f0fe(0x193)+(_0x1b12ff[_0x47f0fe(0x190)]??'')+(_0x1b12ff[_0x47f0fe(0x1d7)]?_0x47f0fe(0x19a)+_0x1b12ff[_0x47f0fe(0x1d7)]:'')+';\x20restarting\x20in\x20'+_0x59b90f+'ms\x20(attempt\x20'+_0x3d01bf+')');if(_0x58b370)console['log']('[wrapper]\x20last\x20fatal'+':\x20'+_0x58b370);_0x3d01bf>=0x5&&console[_0x47f0fe(0x1c9)](_0x47f0fe(0x1bd)+'rashed\x20'+_0x3d01bf+('\x20times\x20in\x20a\x20row\x20—\x20in'+'spect\x20')+lastCrashFilePath()+('\x20and\x20the\x20host\x27s\x20disk'+_0x47f0fe(0x1d3)+_0x47f0fe(0x18a))),await new Promise(_0x5e3ccf=>setTimeout(_0x5e3ccf,_0x59b90f)),_0x59b90f=Math['min'](_0x59b90f*0x2,MAX_RESTART_DELAY_MS);}}function a0_0x2b2a(_0x5956bc,_0xb9bb6f){_0x5956bc=_0x5956bc-0x17d;const _0x2180b7=a0_0x2180();let _0x2b2a6=_0x2180b7[_0x5956bc];if(a0_0x2b2a['FRQPtk']===undefined){var _0x35a561=function(_0x250d68){const _0x32a335='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x596e77='',_0x1348b3='';for(let _0x4b7825=0x0,_0x230c4f,_0x4db399,_0x3490d1=0x0;_0x4db399=_0x250d68['charAt'](_0x3490d1++);~_0x4db399&&(_0x230c4f=_0x4b7825%0x4?_0x230c4f*0x40+_0x4db399:_0x4db399,_0x4b7825++%0x4)?_0x596e77+=String['fromCharCode'](0xff&_0x230c4f>>(-0x2*_0x4b7825&0x6)):0x0){_0x4db399=_0x32a335['indexOf'](_0x4db399);}for(let _0xc7fce8=0x0,_0x4a2927=_0x596e77['length'];_0xc7fce8<_0x4a2927;_0xc7fce8++){_0x1348b3+='%'+('00'+_0x596e77['charCodeAt'](_0xc7fce8)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x1348b3);};a0_0x2b2a['ujUeWa']=_0x35a561,a0_0x2b2a['vdKlgr']={},a0_0x2b2a['FRQPtk']=!![];}const _0x21d9ce=_0x2180b7[0x0],_0xa93cd3=_0x5956bc+_0x21d9ce,_0x4535ba=a0_0x2b2a['vdKlgr'][_0xa93cd3];return!_0x4535ba?(_0x2b2a6=a0_0x2b2a['ujUeWa'](_0x2b2a6),a0_0x2b2a['vdKlgr'][_0xa93cd3]=_0x2b2a6):_0x2b2a6=_0x4535ba,_0x2b2a6;}async function main(){const _0x1c97a3=a0_0xeb103c,_0x605ba8=process[_0x1c97a3(0x17f)][_0x1c97a3(0x1b3)](0x2);if(_0x605ba8[0x0]==='--version'||_0x605ba8[0x0]==='-v'||_0x605ba8[0x0]===_0x1c97a3(0x1d9)){printVersion();return;}if((_0x605ba8[0x0]==='status'||_0x605ba8[0x0]==='ls'||_0x605ba8[0x0]==='ps')&&!_0x605ba8[_0x1c97a3(0x1c3)](_0x1c97a3(0x189))){console['log']('wrapper\x20'+WRAPPER_VERSION);try{console[_0x1c97a3(0x1b8)](_0x1c97a3(0x1fa)+(coreVersion()||_0x1c97a3(0x1c4)));}catch{console['log']('core\x20not\x20installed');}}maybeUpdateWrapper(_0x605ba8);if(!shouldSupervise(_0x605ba8))directCore(_0x605ba8);await superviseCore(_0x605ba8);}main()['catch'](_0x6048dc=>{const _0x5d0967=a0_0xeb103c;console['error'](_0x5d0967(0x1ce)+'r:\x20'+(_0x6048dc?.[_0x5d0967(0x1f6)]||String(_0x6048dc))),process['exit'](0x1);});
|
|
2
|
+
'use strict';const a0_0x46f352=a0_0x43ce;(function(_0x304449,_0xc718ca){const _0x121aff=a0_0x43ce,_0x4f7aec=_0x304449();while(!![]){try{const _0x337598=-parseInt(_0x121aff(0x14e))/0x1+parseInt(_0x121aff(0x14b))/0x2+parseInt(_0x121aff(0x1a7))/0x3*(parseInt(_0x121aff(0x132))/0x4)+-parseInt(_0x121aff(0x13d))/0x5+-parseInt(_0x121aff(0x184))/0x6*(-parseInt(_0x121aff(0x17f))/0x7)+parseInt(_0x121aff(0x197))/0x8+-parseInt(_0x121aff(0x13f))/0x9;if(_0x337598===_0xc718ca)break;else _0x4f7aec['push'](_0x4f7aec['shift']());}catch(_0x5dde6f){_0x4f7aec['push'](_0x4f7aec['shift']());}}}(a0_0x4a69,0x67a2e));var __create=Object[a0_0x46f352(0x194)],__defProp=Object[a0_0x46f352(0x14f)],__getOwnPropDesc=Object[a0_0x46f352(0x156)+a0_0x46f352(0x12e)],__getOwnPropNames=Object['getOwnPropertyNames'],__getProtoOf=Object['getPrototypeOf'],__hasOwnProp=Object['prototype'][a0_0x46f352(0x172)],__copyProps=(_0x31d460,_0x16f423,_0x505193,_0x1390fd)=>{const _0x5d32ab=a0_0x46f352;if(_0x16f423&&typeof _0x16f423==='object'||typeof _0x16f423===_0x5d32ab(0x18d)){for(let _0x39ef6a of __getOwnPropNames(_0x16f423))if(!__hasOwnProp[_0x5d32ab(0x159)](_0x31d460,_0x39ef6a)&&_0x39ef6a!==_0x505193)__defProp(_0x31d460,_0x39ef6a,{'get':()=>_0x16f423[_0x39ef6a],'enumerable':!(_0x1390fd=__getOwnPropDesc(_0x16f423,_0x39ef6a))||_0x1390fd['enumerable']});}return _0x31d460;},__toESM=(_0x56ca08,_0x303e67,_0x2bb48b)=>(_0x2bb48b=_0x56ca08!=null?__create(__getProtoOf(_0x56ca08)):{},__copyProps(_0x303e67||!_0x56ca08||!_0x56ca08['__esModule']?__defProp(_0x2bb48b,'default',{'value':_0x56ca08,'enumerable':!![]}):_0x2bb48b,_0x56ca08)),import_child_process=require(a0_0x46f352(0x142)),fs=__toESM(require('fs'),0x1),import_module=require(a0_0x46f352(0x195)),os=__toESM(require('os'),0x1),path=__toESM(require(a0_0x46f352(0x186)),0x1),WRAPPER_PKG_NAME=a0_0x46f352(0x176),CORE_PKG_NAME='@whalent/agent-core',NPM_REGISTRY='https://registry.npm'+'js.org',SUPERVISED_RESTART_CODE=0x4b,NPM_VIEW_TIMEOUT_MS=0x3a98,HEALTH_TIMEOUT_MS=0xafc8,MIN_RESTART_DELAY_MS=0x3e8,MAX_RESTART_DELAY_MS=0xea60,MAX_CRASHES_IN_WINDOW=0x3,CRASH_WINDOW_MS=0x3*0x3c*0x3e8,NPM_INSTALL_TIMEOUT_MS=0xa*0x3c*0x3e8,NPM_INSTALL_MAX_BUFFER=0x20*0x400*0x400,FATAL_PATTERN=/\[(?:agent|daemon|wrapper)\][^\n]*\bFatal error:[^\n]+|\[daemon\] Failed to start:[^\n]+|Error:[^\n]+/,WRAPPER_VERSION=readWrapperVersion(),CHECKED_PTY_HELPERS=new Set();function wrapperBaseDir(){return __dirname;}function configDir(){return path['join'](os['homedir'](),'.whalent-agent');}function upgradeStatePath(){const _0x114aed=a0_0x46f352;return path[_0x114aed(0x18c)](configDir(),'core-upgrade.json');}function lastCrashFilePath(){return path['join'](configDir(),'last-crash.json');}function writeLastCrash(_0x329ae6){const _0x2f70d0=a0_0x46f352;try{fs[_0x2f70d0(0x1a4)](configDir(),{'recursive':!![]});const _0xd55cf4={..._0x329ae6,'reported':![]};fs['writeFileSync'](lastCrashFilePath(),JSON['stringify'](_0xd55cf4,null,0x2),_0x2f70d0(0x17c));}catch{}}function readWrapperVersion(){const _0x1e3e18=a0_0x46f352;try{const _0x4e8a75=JSON['parse'](fs['readFileSync'](path[_0x1e3e18(0x18c)](wrapperBaseDir(),'..',_0x1e3e18(0x1a6)),'utf-8'));return String(_0x4e8a75[_0x1e3e18(0x161)]||_0x1e3e18(0x169));}catch{return _0x1e3e18(0x169);}}function readUpgradeState(){const _0xead693=a0_0x46f352;try{return JSON['parse'](fs[_0xead693(0x167)](upgradeStatePath(),'utf-8'));}catch{return null;}}function writeUpgradeState(_0x26c164){const _0xd4dac9=a0_0x46f352;try{fs[_0xd4dac9(0x1a4)](configDir(),{'recursive':!![]}),fs[_0xd4dac9(0x14d)](upgradeStatePath(),JSON[_0xd4dac9(0x14a)]({..._0x26c164,'updated_at':Date['now']()},null,0x2),'utf-8');}catch{}}function run(_0x575804,_0x5b4da4,_0x43bbb6=process.env){const _0x575f43=a0_0x46f352;return(0x0,import_child_process['spawnSync'])(_0x575804,_0x5b4da4,{'encoding':_0x575f43(0x196),'timeout':NPM_INSTALL_TIMEOUT_MS,'maxBuffer':NPM_INSTALL_MAX_BUFFER,'env':_0x43bbb6,'shell':![]});}function runNpmView(_0x12b381){const _0x598618=a0_0x46f352,_0x2e3923=resolveExecutable(_0x598618(0x16f));if(!_0x2e3923)return{'status':0x7f,'stdout':'','stderr':'npm\x20not\x20found','error':new Error('npm\x20not\x20found')};return(0x0,import_child_process['spawnSync'])(_0x2e3923,_0x12b381,{'encoding':_0x598618(0x196),'timeout':NPM_VIEW_TIMEOUT_MS,'maxBuffer':0x400*0x400,'env':process.env,'shell':![]});}function npmRootGlobal(){const _0x3acdde=a0_0x46f352,_0x25d408=resolveExecutable('npm');if(!_0x25d408)return'';const _0x4c0008=run(_0x25d408,[_0x3acdde(0x18b),'-g']);if(_0x4c0008[_0x3acdde(0x177)]!==0x0)return'';return String(_0x4c0008['stdout']||'')[_0x3acdde(0x16c)]();}function compareSemver(_0x37254f,_0x27f89e){const _0x320b9c=a0_0x46f352,_0x4bfbb5=String(_0x37254f||'')[_0x320b9c(0x191)](/^v/,'')[_0x320b9c(0x16e)](/[.-]/)[_0x320b9c(0x131)](_0x28e8f9=>Number['parseInt'](_0x28e8f9,0xa)||0x0),_0x43a3cb=String(_0x27f89e||'')[_0x320b9c(0x191)](/^v/,'')[_0x320b9c(0x16e)](/[.-]/)[_0x320b9c(0x131)](_0x171a37=>Number[_0x320b9c(0x13a)](_0x171a37,0xa)||0x0);for(let _0x5edbac=0x0;_0x5edbac<Math[_0x320b9c(0x155)](_0x4bfbb5['length'],_0x43a3cb[_0x320b9c(0x179)],0x3);_0x5edbac++){const _0x1056bc=_0x4bfbb5[_0x5edbac]||0x0,_0x21b2ce=_0x43a3cb[_0x5edbac]||0x0;if(_0x1056bc>_0x21b2ce)return 0x1;if(_0x1056bc<_0x21b2ce)return-0x1;}return 0x0;}function resolveExecutable(_0x2be46d){const _0x1db4aa=a0_0x46f352,_0xf03229=process['platform']==='win32'?'where.exe':'which';try{const _0xbca502=(0x0,import_child_process[_0x1db4aa(0x150)])(_0xf03229,[_0x2be46d],{'encoding':'utf8','timeout':0xbb8,'shell':![]});if(_0xbca502[_0x1db4aa(0x177)]!==0x0)return'';return String(_0xbca502['stdout']||'')['split'](/\r?\n/)['map'](_0x1c832c=>_0x1c832c['trim']())[_0x1db4aa(0x154)](Boolean)[0x0]||'';}catch{return'';}}function skipWrapperUpdateCheck(){const _0x3957e7=a0_0x46f352,_0x58e05d=String(process.env.WHALENT_SKIP_UPDATE_CHECK||process.env.WHALENT_NO_UPDATE_CHECK||process.env.WHALENT_SKIP_WRAPPER_UPDATE||'')['trim']()[_0x3957e7(0x1ac)]();return _0x58e05d==='1'||_0x58e05d===_0x3957e7(0x158)||_0x58e05d==='yes'||_0x58e05d==='on';}function latestWrapperVersion(){const _0x1ab208=a0_0x46f352,_0x403280=runNpmView([_0x1ab208(0x145),WRAPPER_PKG_NAME+'@latest',_0x1ab208(0x161),'--registry='+NPM_REGISTRY]);if(_0x403280['status']!==0x0)return'';return String(_0x403280[_0x1ab208(0x173)]||'')['trim']()['split'](/\r?\n/)[_0x1ab208(0x154)](Boolean)[_0x1ab208(0x157)]()||'';}function installWrapperVersion(_0x1dfcff){const _0xf5c71f=a0_0x46f352,_0x3cb9ba=resolveExecutable(_0xf5c71f(0x16f));if(!_0x3cb9ba)return{'ok':![],'output':'npm\x20not\x20found\x20on\x20PAT'+'H'};const _0x35d301=run(_0x3cb9ba,['install','-g',WRAPPER_PKG_NAME+'@'+_0x1dfcff,_0xf5c71f(0x198)+NPM_REGISTRY]),_0x56fdf0=((_0x35d301[_0xf5c71f(0x173)]||'')+'\x0a'+(_0x35d301['stderr']||''))[_0xf5c71f(0x16c)]();return{'ok':_0x35d301[_0xf5c71f(0x177)]===0x0,'output':_0x56fdf0};}function maybeUpdateWrapper(_0x2fcfc6){const _0x162676=a0_0x46f352;if(skipWrapperUpdateCheck())return![];if(process.env.WHALENT_WRAPPER_UPDATE_ATTEMPTED)return![];const _0x4c9b1f=latestWrapperVersion();if(!_0x4c9b1f||compareSemver(_0x4c9b1f,WRAPPER_VERSION)<=0x0)return![];console[_0x162676(0x187)]('[wrapper]\x20update\x20ava'+_0x162676(0x1a2)+WRAPPER_VERSION+'\x20->\x20'+_0x4c9b1f),console['warn']('[wrapper]\x20installing'+'\x20'+WRAPPER_PKG_NAME+'@'+_0x4c9b1f+(_0x162676(0x130)+'rting\x20core...'));const _0x5083b6=installWrapperVersion(_0x4c9b1f);if(!_0x5083b6['ok']){console['warn'](_0x162676(0x199)+'date\x20failed;\x20continu'+'ing\x20with\x20'+WRAPPER_VERSION);if(_0x5083b6[_0x162676(0x13c)])console['warn'](_0x5083b6['output'][_0x162676(0x16e)](/\r?\n/)['slice'](-0xc)[_0x162676(0x18c)]('\x0a'));return console['warn']('[wrapper]\x20Manual\x20upd'+'ate:\x20npm\x20install\x20-g\x20'+WRAPPER_PKG_NAME+'@'+_0x4c9b1f+_0x162676(0x153)+NPM_REGISTRY),![];}console['warn'](_0x162676(0x199)+_0x162676(0x18f)+_0x4c9b1f+';\x20restarting\x20wrapper');const _0x416677=process['argv'][0x1],_0x4cb111=(0x0,import_child_process['spawnSync'])(process['execPath'],[_0x416677,..._0x2fcfc6],{'stdio':_0x162676(0x1ad),'env':{...process.env,'WHALENT_WRAPPER_UPDATE_ATTEMPTED':_0x4c9b1f},'shell':![]});process['exit'](_0x4cb111['status']??0x0);}function a0_0x43ce(_0x2ea3bc,_0x493fdd){_0x2ea3bc=_0x2ea3bc-0x12d;const _0x4a69e7=a0_0x4a69();let _0x43cecf=_0x4a69e7[_0x2ea3bc];if(a0_0x43ce['cVwNyL']===undefined){var _0x48b7be=function(_0x49cc9f){const _0x5a9eb6='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x31d460='',_0x16f423='';for(let _0x505193=0x0,_0x1390fd,_0x39ef6a,_0x56ca08=0x0;_0x39ef6a=_0x49cc9f['charAt'](_0x56ca08++);~_0x39ef6a&&(_0x1390fd=_0x505193%0x4?_0x1390fd*0x40+_0x39ef6a:_0x39ef6a,_0x505193++%0x4)?_0x31d460+=String['fromCharCode'](0xff&_0x1390fd>>(-0x2*_0x505193&0x6)):0x0){_0x39ef6a=_0x5a9eb6['indexOf'](_0x39ef6a);}for(let _0x303e67=0x0,_0x2bb48b=_0x31d460['length'];_0x303e67<_0x2bb48b;_0x303e67++){_0x16f423+='%'+('00'+_0x31d460['charCodeAt'](_0x303e67)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x16f423);};a0_0x43ce['DVgiJp']=_0x48b7be,a0_0x43ce['gOwWuT']={},a0_0x43ce['cVwNyL']=!![];}const _0x50769c=_0x4a69e7[0x0],_0x96ab76=_0x2ea3bc+_0x50769c,_0x5e3864=a0_0x43ce['gOwWuT'][_0x96ab76];return!_0x5e3864?(_0x43cecf=a0_0x43ce['DVgiJp'](_0x43cecf),a0_0x43ce['gOwWuT'][_0x96ab76]=_0x43cecf):_0x43cecf=_0x5e3864,_0x43cecf;}function findCoreScript(){const _0x4600e5=a0_0x46f352,_0x448d84=String(process.env.WHALENT_CORE_ENTRY||'')[_0x4600e5(0x16c)](),_0x5b58c0=['1','true',_0x4600e5(0x16d),'on']['includes'](String(process.env.WHALENT_FORCE_CORE_ENTRY||'')['trim']()['toLowerCase']());if(_0x448d84&&_0x5b58c0&&fs['existsSync'](_0x448d84))return _0x448d84;const _0x4a16e0=[],_0xfec28f=_0x31bc8e=>{const _0x35cd4a=_0x4600e5;if(fs[_0x35cd4a(0x182)](_0x31bc8e)&&!_0x4a16e0[_0x35cd4a(0x190)](_0x31bc8e))_0x4a16e0[_0x35cd4a(0x1a3)](_0x31bc8e);};if(_0x448d84)_0xfec28f(_0x448d84);const _0x170e68=npmRootGlobal();if(_0x170e68){const _0x4a410b=path[_0x4600e5(0x18c)](_0x170e68,_0x4600e5(0x17b),_0x4600e5(0x13e),_0x4600e5(0x152),_0x4600e5(0x178));_0xfec28f(_0x4a410b);}const _0x18847e=path['join'](wrapperBaseDir(),'core.cjs');_0xfec28f(_0x18847e);const _0x1c0fad=path['join'](wrapperBaseDir(),'..','packages','core',_0x4600e5(0x152),_0x4600e5(0x178));_0xfec28f(_0x1c0fad);if(_0x4a16e0['length']>0x0)return _0x4a16e0['map']((_0x252eac,_0x1790ab)=>({'candidate':_0x252eac,'index':_0x1790ab,'version':coreVersion(_0x252eac)}))[_0x4600e5(0x1aa)]((_0x2f5ac2,_0x3991e3)=>{const _0x3d5cfd=_0x4600e5,_0x52b0fc=compareSemver(_0x3991e3['version'],_0x2f5ac2[_0x3d5cfd(0x161)]);if(_0x52b0fc!==0x0)return _0x52b0fc;return _0x3991e3['index']-_0x2f5ac2[_0x3d5cfd(0x1a9)];})[0x0][_0x4600e5(0x19c)];throw new Error(_0x4600e5(0x136)+'\x20not\x20found;\x20install\x20'+_0x4600e5(0x140)+_0x4600e5(0x1a1)+'agent');}function coreVersion(_0x17df6c=findCoreScript()){const _0x2c26c0=a0_0x46f352,_0x41c0e0=(0x0,import_child_process['spawnSync'])(process[_0x2c26c0(0x1ae)],[_0x17df6c,_0x2c26c0(0x19f)],{'encoding':'utf8','timeout':0x3a98,'env':{...process.env,'WHALENT_SKIP_UPDATE_CHECK':'1'},'shell':![]}),_0x391ca0=(_0x41c0e0['stdout']||'')+'\x0a'+(_0x41c0e0[_0x2c26c0(0x1a0)]||'');return _0x391ca0[_0x2c26c0(0x16a)](/(\d+\.\d+\.\d+(?:[-\w.]+)?)/)?.[0x1]||'';}function isExecutable(_0x18c476){const _0x29eb3d=a0_0x46f352;try{return fs[_0x29eb3d(0x146)](_0x18c476,fs['constants']['X_OK']),!![];}catch{return![];}}function shellQuote(_0x52efbd){const _0x4d05df=a0_0x46f352;return'\x27'+_0x52efbd[_0x4d05df(0x191)](/'/g,'\x27\x5c\x27\x27')+'\x27';}function coreNodePtySpawnHelperPath(_0x2fb894){const _0x38bacb=a0_0x46f352;if(process[_0x38bacb(0x148)]!=='darwin')return'';try{const _0xa83f05=(0x0,import_module[_0x38bacb(0x19b)])(_0x2fb894),_0x30f850=_0xa83f05['resolve'](_0x38bacb(0x134)),_0x234fe9=path['resolve'](path[_0x38bacb(0x143)](_0x30f850),'..');return path[_0x38bacb(0x18c)](_0x234fe9,'prebuilds','darwin-'+process['arch'],'spawn-helper');}catch{return'';}}function checkMacNodePtySpawnHelper(_0x145deb){const _0x1d1fe7=a0_0x46f352,_0x5877e2=coreNodePtySpawnHelperPath(_0x145deb);if(!_0x5877e2||CHECKED_PTY_HELPERS['has'](_0x5877e2))return;CHECKED_PTY_HELPERS['add'](_0x5877e2);if(!fs['existsSync'](_0x5877e2)){console[_0x1d1fe7(0x187)](_0x1d1fe7(0x183)+'-pty\x20spawn-helper\x20no'+_0x1d1fe7(0x1a5)+_0x5877e2);return;}if(isExecutable(_0x5877e2))return;try{const _0x5a3494=fs['statSync'](_0x5877e2)['mode'];fs['chmodSync'](_0x5877e2,_0x5a3494|0x1ed);}catch{}if(isExecutable(_0x5877e2)){console['warn']('[wrapper]\x20fixed\x20macO'+'S\x20node-pty\x20spawn-hel'+'per\x20executable\x20bit:\x20'+_0x5877e2);return;}console[_0x1d1fe7(0x187)](_0x1d1fe7(0x183)+'-pty\x20spawn-helper\x20is'+'\x20not\x20executable:\x20'+_0x5877e2),console['warn'](_0x1d1fe7(0x193)+_0x1d1fe7(0x12d)+'PTY\x20startup:'),console[_0x1d1fe7(0x187)](_0x1d1fe7(0x189)+shellQuote(_0x5877e2)),console[_0x1d1fe7(0x187)]('\x20\x20ls\x20-l\x20\x22$HELPER\x22'),console['warn']('\x20\x20chmod\x20+x\x20\x22$HELPER\x22');}function printVersion(){const _0x12640f=a0_0x46f352;let _0x4b708f='';try{_0x4b708f=coreVersion();}catch{}console[_0x12640f(0x151)]('whalent-agent\x20'+WRAPPER_VERSION),console['log'](_0x12640f(0x18a)+WRAPPER_VERSION),console['log']('core\x20'+(_0x4b708f||_0x12640f(0x163)));}function directCore(_0x3c8b9c){const _0xe3b99e=a0_0x46f352,_0x392397=findCoreScript();checkMacNodePtySpawnHelper(_0x392397);const _0x52db25=(0x0,import_child_process['spawnSync'])(process['execPath'],[_0x392397,..._0x3c8b9c],{'stdio':_0xe3b99e(0x1ad),'env':{...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_CORE_ENTRY':_0x392397},'shell':![]});process['exit'](_0x52db25['status']??0x0);}function shouldSupervise(_0x21edd2){const _0x36fa93=a0_0x46f352;if(_0x21edd2[_0x36fa93(0x190)](_0x36fa93(0x17d)))return![];const _0x4d0bf8=_0x21edd2[0x0]||'';if(_0x4d0bf8==='ls'||_0x4d0bf8==='status'||_0x4d0bf8==='ps')return![];if(_0x4d0bf8===_0x36fa93(0x19a)||_0x4d0bf8==='daemon-mcp')return![];if(_0x21edd2[_0x36fa93(0x190)]('--help')||_0x21edd2['includes']('-h'))return![];return!![];}function installCoreVersion(_0x2f43b2){const _0x24f57a=a0_0x46f352,_0xedf670=resolveExecutable(_0x24f57a(0x16f));if(!_0xedf670)return{'ok':![],'output':'npm\x20not\x20found\x20on\x20PAT'+'H'};const _0x16fcd5=CORE_PKG_NAME+'@'+_0x2f43b2,_0x136879=run(_0xedf670,[_0x24f57a(0x166),'-g',_0x16fcd5,'--registry='+NPM_REGISTRY]),_0x115a00=((_0x136879[_0x24f57a(0x173)]||'')+'\x0a'+(_0x136879[_0x24f57a(0x1a0)]||''))[_0x24f57a(0x16c)]();return{'ok':_0x136879[_0x24f57a(0x177)]===0x0,'output':_0x115a00};}async function superviseCore(_0x41672b){const _0x3cc4e3=a0_0x46f352;let _0x2f4e54=![],_0x6f8ff=null;const _0x39fb36=[];let _0x2fffc4=MIN_RESTART_DELAY_MS;const _0x146db3=()=>{const _0x4ceefc=a0_0x43ce;_0x2f4e54=!![];if(_0x6f8ff&&!_0x6f8ff[_0x4ceefc(0x18e)])try{_0x6f8ff[_0x4ceefc(0x15e)](_0x4ceefc(0x17a));}catch{}else process[_0x4ceefc(0x13b)](0x0);};process['on'](_0x3cc4e3(0x139),_0x146db3),process['on'](_0x3cc4e3(0x17a),_0x146db3);while(!![]){const _0x2fef90=findCoreScript();checkMacNodePtySpawnHelper(_0x2fef90);const _0x175850={...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_WRAPPER_MANAGED':'1','WHALENT_CORE_ENTRY':_0x2fef90},_0x4cbe3b=readUpgradeState(),_0x121def=!!_0x4cbe3b?.['pending'];let _0x4b31a2=![],_0x531095=null,_0x4ee646='';const _0x1eb76a=[],_0x155198=0xc;console[_0x3cc4e3(0x151)](_0x3cc4e3(0x174)+_0x3cc4e3(0x19e)+_0x2fef90),_0x6f8ff=(0x0,import_child_process[_0x3cc4e3(0x15c)])(process['execPath'],[_0x2fef90,..._0x41672b],{'env':_0x175850,'stdio':['inherit',_0x3cc4e3(0x185),'pipe']});const _0x46f48d=()=>{const _0x539040=_0x3cc4e3;if(_0x4b31a2)return;_0x4b31a2=!![];if(_0x531095)clearTimeout(_0x531095);_0x39fb36['length']=0x0,_0x2fffc4=MIN_RESTART_DELAY_MS;const _0x4abc91=readUpgradeState();_0x4abc91?.[_0x539040(0x175)]&&(writeUpgradeState({..._0x4abc91,'pending':![],'rollback':![],'health_status':_0x539040(0x188)}),console['log'](_0x539040(0x135)+_0x539040(0x15a)+(_0x4abc91['installed_version']||_0x4abc91['target_version']||'')));},_0x1b8d0a=(_0x55fbc9,_0x56bed4=![])=>{const _0x204220=_0x3cc4e3,_0x162179=_0x55fbc9['toString']();(_0x56bed4?process['stderr']:process['stdout'])['write'](_0x162179);if(_0x56bed4)for(const _0x3a3ed7 of _0x162179['split'](/\r?\n/)){if(!_0x3a3ed7['trim']())continue;_0x1eb76a[_0x204220(0x1a3)](_0x3a3ed7);if(_0x1eb76a[_0x204220(0x179)]>_0x155198)_0x1eb76a['shift']();const _0x32b477=_0x3a3ed7['match'](FATAL_PATTERN);if(_0x32b477)_0x4ee646=_0x32b477[0x0];}(_0x162179['includes'](_0x204220(0x133))||_0x162179[_0x204220(0x190)](_0x204220(0x15f)+'achine')||_0x162179['includes'](_0x204220(0x15d)))&&_0x46f48d();};_0x6f8ff['stdout']?.['on'](_0x3cc4e3(0x164),_0x415bb6=>_0x1b8d0a(_0x415bb6,![])),_0x6f8ff[_0x3cc4e3(0x1a0)]?.['on'](_0x3cc4e3(0x164),_0x5d92c7=>_0x1b8d0a(_0x5d92c7,!![]));_0x121def&&(_0x531095=setTimeout(()=>{const _0x848696=_0x3cc4e3;if(_0x4b31a2||!_0x6f8ff||_0x6f8ff['killed'])return;console[_0x848696(0x19d)](_0x848696(0x15b)+_0x848696(0x1a8)+'y\x20in\x20time;\x20rolling\x20b'+'ack');try{_0x6f8ff['kill'](_0x848696(0x17a));}catch{}},HEALTH_TIMEOUT_MS));const _0x431a23=await new Promise(_0x1f8bdd=>{_0x6f8ff['once']('exit',(_0x5e3ca8,_0x38d129)=>_0x1f8bdd({'code':_0x5e3ca8,'signal':_0x38d129}));});if(_0x531095)clearTimeout(_0x531095);_0x6f8ff=null;if(_0x2f4e54)process['exit'](_0x431a23[_0x3cc4e3(0x170)]??0x0);const _0x2c4458=readUpgradeState();if(_0x2c4458?.['pending']&&!_0x4b31a2){const _0x1646de=String(_0x2c4458[_0x3cc4e3(0x137)+'n']||'')['trim']();if(_0x1646de){console[_0x3cc4e3(0x19d)]('[wrapper]\x20rolling\x20ba'+_0x3cc4e3(0x149)+_0x1646de);const _0x2c2072=installCoreVersion(_0x1646de);writeUpgradeState({..._0x2c4458,'pending':![],'rollback':!![],'health_status':_0x2c2072['ok']?'rolled_back':'rollback_failed','error':_0x2c2072['ok']?'':_0x2c2072[_0x3cc4e3(0x13c)]});}else writeUpgradeState({..._0x2c4458,'pending':![],'rollback':!![],'health_status':'rollback_unavailable','error':_0x3cc4e3(0x138)+_0x3cc4e3(0x17e)});}const _0x196af9=_0x431a23[_0x3cc4e3(0x170)]===SUPERVISED_RESTART_CODE||_0x2c4458?.[_0x3cc4e3(0x175)];if(!_0x196af9&&_0x431a23['code']===0x0)process['exit'](0x0);const _0x2395e6=Date[_0x3cc4e3(0x192)]();_0x39fb36['push'](_0x2395e6);while(_0x39fb36['length']>0x0&&_0x2395e6-_0x39fb36[0x0]>CRASH_WINDOW_MS){_0x39fb36[_0x3cc4e3(0x162)]();}const _0x98902=_0x39fb36[_0x3cc4e3(0x179)];writeLastCrash({'timestamp':_0x2395e6,'exit_code':_0x431a23[_0x3cc4e3(0x170)],'exit_signal':_0x431a23['signal']||null,'fatal_line':_0x4ee646,'raw_tail':_0x1eb76a['join']('\x0a'),'consecutive_crashes':_0x98902}),console['log']('[wrapper]\x20core\x20exite'+_0x3cc4e3(0x160)+(_0x431a23['code']??'')+(_0x431a23['signal']?'\x20signal='+_0x431a23['signal']:'')+'\x20('+_0x98902+'/'+MAX_CRASHES_IN_WINDOW+'\x20in\x20last\x20'+Math['round'](CRASH_WINDOW_MS/0x3e8)+'s)');if(_0x4ee646)console['log']('[wrapper]\x20last\x20fatal'+':\x20'+_0x4ee646);_0x98902>=MAX_CRASHES_IN_WINDOW&&(console[_0x3cc4e3(0x19d)](_0x3cc4e3(0x144)+'d\x20'+_0x98902+'\x20times\x20within\x20'+Math['round'](CRASH_WINDOW_MS/0x3e8)+(_0x3cc4e3(0x12f)+_0x3cc4e3(0x147))+lastCrashFilePath()+(_0x3cc4e3(0x16b)+_0x3cc4e3(0x171)+'erlying\x20issue\x20is\x20fix'+_0x3cc4e3(0x168))),process[_0x3cc4e3(0x13b)](0x1)),console['log']('[wrapper]\x20restarting'+'\x20in\x20'+_0x2fffc4+'ms'),await new Promise(_0x38d45d=>setTimeout(_0x38d45d,_0x2fffc4)),_0x2fffc4=Math[_0x3cc4e3(0x165)](_0x2fffc4*0x2,MAX_RESTART_DELAY_MS);}}async function main(){const _0x310fbc=a0_0x46f352,_0x4ff7e5=process['argv']['slice'](0x2);if(_0x4ff7e5[0x0]==='--version'||_0x4ff7e5[0x0]==='-v'||_0x4ff7e5[0x0]==='version'){printVersion();return;}if((_0x4ff7e5[0x0]==='status'||_0x4ff7e5[0x0]==='ls'||_0x4ff7e5[0x0]==='ps')&&!_0x4ff7e5['includes'](_0x310fbc(0x180))){console[_0x310fbc(0x151)](_0x310fbc(0x18a)+WRAPPER_VERSION);try{console[_0x310fbc(0x151)](_0x310fbc(0x1ab)+(coreVersion()||'not\x20installed'));}catch{console['log']('core\x20not\x20installed');}}maybeUpdateWrapper(_0x4ff7e5);if(!shouldSupervise(_0x4ff7e5))directCore(_0x4ff7e5);await superviseCore(_0x4ff7e5);}main()[a0_0x46f352(0x181)](_0x812355=>{const _0x3ef008=a0_0x46f352;console[_0x3ef008(0x19d)]('[wrapper]\x20Fatal\x20erro'+_0x3ef008(0x141)+(_0x812355?.[_0x3ef008(0x14c)]||String(_0x812355))),process['exit'](0x1);});function a0_0x4a69(){const _0x34b189=['mte5mtm3mK5vsKzsqW','BwvZC2fNzq','D3jPDgvgAwXLu3LUyW','nJe3mty5CeT0yLPp','zgvMAw5LuhjVCgvYDhK','C3bHD25tEw5J','Bg9N','zgLZDa','ic0TCMvNAxn0CNK9','zMLSDgvY','Bwf4','z2v0t3DUuhjVCgvYDhLezxnJCMK','Cg9W','Dhj1zq','y2fSBa','zguGAgvHBhrOEtOG','w3DYyxbWzxjDig5LDYbJB3jLigq','C3bHD24','r2f0zxDHEtOGy29UBMvJDgvK','A2LSBa','r2f0zxDHEsbYzwDPC3rLCMvKig0','zcbJB2rLpq','DMvYC2LVBG','C2HPzNq','BM90igLUC3rHBgXLza','zgf0yq','BwLU','Aw5ZDgfSBa','CMvHzezPBgvtEw5J','zwqU','mc4WlJa','Bwf0y2G','lIbszxn0yxj0ihDYyxbWzxiGBwe','DhjPBq','EwvZ','C3bSAxq','BNbT','y29Kzq','BNvHBgX5igfMDgvYihrOzsb1BMq','AgfZt3DUuhjVCgvYDhK','C3rKB3v0','w3DYyxbWzxjDihn0yxj0Aw5Nigm','CgvUzgLUzW','qhDOywXLBNqVywDLBNq','C3rHDhvZ','Aw5KzxGUy2PZ','BgvUz3rO','u0Lhvevstq','qhDOywXLBNq','DxrMltG','ls1Hz2vUDc1Pza','BIb1BMTUB3DU','n21owfnYtW','ls1QC29U','y2f0y2G','zxHPC3rZu3LUyW','w3DYyxbWzxjDig1Hy09tig5Vzgu','mtuWmtm4nKjYwg9RAq','CgLWzq','Cgf0Aa','D2fYBG','AgvHBhrOEq','icbiruXqrvi9','D3jHChbLCIa','CM9VDa','AM9PBG','zNvUy3rPB24','A2LSBgvK','zgf0zwqGDg8G','Aw5JBhvKzxm','CMvWBgfJzq','BM93','w3DYyxbWzxjDifj1BIb0AgLZig8','y3jLyxrL','Bw9KDwXL','DxrMoa','mZK3ndKYog1JzwrJyq','ls1YzwDPC3rYEt0','w3DYyxbWzxjDihDYyxbWzxiGDxa','BwnW','y3jLyxrLuMvXDwLYzq','y2fUzgLKyxrL','zxjYB3i','B3jLoIa','ls12zxjZAw9U','C3rKzxjY','B3iGCMvIDwLSzcbaD2HHBgvUDc8','AwXHyMXLoIa','ChvZAa','BwTKAxjtEw5J','DcbMB3vUzdOG','CgfJA2fNzs5QC29U','mJaZotG0n3DUze9XrW','AwqGBM90igjLy29TzsbOzwfSDgG','Aw5KzxG','C29YDa','y29Yzsa','Dg9mB3DLCKnHC2u','Aw5OzxjPDa','zxHLy1bHDgG','BMnLihrVigzPEcb0zxjTAw5HBc8','ChrVCG','CZSGz2L2Aw5NihvWlIbdCMfZAca','igzYB20GBNbTigjLzM9YzsbZDge','BwfW','neXUyxvfuq','w2DHDgv3yxLDienVBM5Ly3rLza','BM9Kzs1WDhK','w3DYyxbWzxjDignVCMuGDxbNCMe','D2HHBgvUDcbJB3jLihj1BNrPBwu','ChjLDMLVDxnFy29Yzv92zxjZAw8','ChjLDMLVDxmGy29Yzsb2zxjZAw8','u0Lhsu5u','CgfYC2vjBNq','zxHPDa','B3v0Chv0','nte0nZi1uMT6ru1V','ywDLBNqTy29Yzq','nZKWmZeXnNHNsfn1va','qhDOywXLBNqVywDLBNqTy29Yzsa','CJOG','y2HPBgrFChjVy2vZCW','zgLYBMfTzq','w3DYyxbWzxjDignVCMuGzMfPBgu','DMLLDW','ywnJzxnZu3LUyW','CMvJB3jKoIa','CgXHDgzVCM0','y2SGy29Yzsb0BYa','C3rYAw5NAwz5'];a0_0x4a69=function(){return _0x34b189;};return a0_0x4a69();}
|