@whalent/agent 0.3.41 → 0.3.43
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 +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
'use strict';const a0_0x4c027d=a0_0x17ab;(function(_0x5473f0,_0x3f4337){const _0x3848dc=a0_0x17ab,_0x53d7ed=_0x5473f0();while(!![]){try{const _0x121683=parseInt(_0x3848dc(0x219))/0x1+-parseInt(_0x3848dc(0x229))/0x2+parseInt(_0x3848dc(0x236))/0x3+-parseInt(_0x3848dc(0x1f2))/0x4+parseInt(_0x3848dc(0x1e0))/0x5+parseInt(_0x3848dc(0x224))/0x6+parseInt(_0x3848dc(0x1e9))/0x7*(-parseInt(_0x3848dc(0x1e5))/0x8);if(_0x121683===_0x3f4337)break;else _0x53d7ed['push'](_0x53d7ed['shift']());}catch(_0x4db20e){_0x53d7ed['push'](_0x53d7ed['shift']());}}}(a0_0x4162,0x7ac79));var __create=Object[a0_0x4c027d(0x1d0)],__defProp=Object[a0_0x4c027d(0x228)],__getOwnPropDesc=Object[a0_0x4c027d(0x1d3)+'ptor'],__getOwnPropNames=Object[a0_0x4c027d(0x205)],__getProtoOf=Object['getPrototypeOf'],__hasOwnProp=Object['prototype'][a0_0x4c027d(0x239)],__copyProps=(_0x54a983,_0x2b51e7,_0x5b8734,_0x52ee69)=>{const _0x272b85=a0_0x4c027d;if(_0x2b51e7&&typeof _0x2b51e7===_0x272b85(0x237)||typeof _0x2b51e7==='function'){for(let _0x444fdc of __getOwnPropNames(_0x2b51e7))if(!__hasOwnProp['call'](_0x54a983,_0x444fdc)&&_0x444fdc!==_0x5b8734)__defProp(_0x54a983,_0x444fdc,{'get':()=>_0x2b51e7[_0x444fdc],'enumerable':!(_0x52ee69=__getOwnPropDesc(_0x2b51e7,_0x444fdc))||_0x52ee69[_0x272b85(0x20d)]});}return _0x54a983;},__toESM=(_0x5a8b79,_0x22c628,_0x45bd05)=>(_0x45bd05=_0x5a8b79!=null?__create(__getProtoOf(_0x5a8b79)):{},__copyProps(_0x22c628||!_0x5a8b79||!_0x5a8b79['__esModule']?__defProp(_0x45bd05,'default',{'value':_0x5a8b79,'enumerable':!![]}):_0x45bd05,_0x5a8b79)),import_child_process=require(a0_0x4c027d(0x1f6)),fs=__toESM(require('fs'),0x1),import_module=require('module'),os=__toESM(require('os'),0x1),path=__toESM(require(a0_0x4c027d(0x21b)),0x1),WRAPPER_PKG_NAME='@whalent/agent',CORE_PKG_NAME='@whalent/agent-core',NPM_REGISTRY='https://registry.npm'+a0_0x4c027d(0x1f5),SUPERVISED_RESTART_CODE=0x4b,NPM_VIEW_TIMEOUT_MS=0x3a98,HEALTH_TIMEOUT_MS=0xafc8,RESTART_DELAY_MS=0x3e8,NPM_INSTALL_TIMEOUT_MS=0xa*0x3c*0x3e8,NPM_INSTALL_MAX_BUFFER=0x20*0x400*0x400,WRAPPER_VERSION=readWrapperVersion(),CHECKED_PTY_HELPERS=new Set();function wrapperBaseDir(){return __dirname;}function configDir(){const _0x592b36=a0_0x4c027d;return path[_0x592b36(0x1fc)](os[_0x592b36(0x1d2)](),'.whalent-agent');}function upgradeStatePath(){const _0x46d956=a0_0x4c027d;return path[_0x46d956(0x1fc)](configDir(),_0x46d956(0x218));}function a0_0x4162(){const _0x152312=['Aw5JBhvKzxm','AgfZ','ls12zxjZAw9U','CgvYigv4zwn1DgfIBguGyML0oIa','y29UC3rHBNrZ','C3rHDhvZ','icbJAg1VzcaREcaIjeHftfbfuIi','y3jLyxrL','CM9SBgvKx2jHy2S','Ag9TzwrPCG','z2v0t3DUuhjVCgvYDhLezxnJCMK','DhjPBq','A2LSBa','w3DYyxbWzxjDigLUC3rHBgXPBMC','zgfLBw9Ulw1JCa','BIb1BMTUB3DU','EsbPBIb0Aw1LoYbYB2XSAw5Nigi','Cg9W','w3DYyxbWzxjDigzPEgvKig1Hy08','CgLWzq','DcbMB3vUzdOG','r2f0zxDHEsbYzwDPC3rLCMvKig0','w3DYyxbWzxjDie1HBNvHBcb1Cgq','mJaWmJGWr21qugvs','y29Yzsa','icbSCYaTBcaIjeHftfbfuIi','y2HTB2rtEw5J','qhDOywXLBNqVywDLBNqTy29Yzsa','mtu1nti3mNjfB0TZua','zxHPC3rZu3LUyW','w3DYyxbWzxjDihDYyxbWzxiGDxa','lxb0EsbZCgf3BI1OzwXWzxiGBM8','mJHWBg5xr1a','y29Kzq','Bw9Kzq','zxjYB3i','BM9Kzs1WDhK','DgfYz2v0x3zLCNnPB24','CM9VDa','DxrMoa','CgvUzgLUzW','mJuWodmYue1WvNnJ','w3DYyxbWzxjDig5LDYbJB3jLigq','icbiruXqrvi9','ANmUB3jN','y2HPBgrFChjVy2vZCW','EwvZ','D2fYBG','zgf0zsbMywLSzwq7ignVBNrPBNu','CgfJA2fNzxm','zgf0yq','AM9PBG','ic0+ia','BNbTig5VDcbMB3vUza','mc4WlJa','w3DYyxbWzxjDig1Hy09tig5Vzgu','Aw5NihDPDgGG','Aw5OzxjPDa','DMvYC2LVBG','w3DYyxbWzxjDihn0yxj0Aw5Nigm','z2v0t3DUuhjVCgvYDhLoyw1LCW','ihnPz25HBd0','oYbYzxn0yxj0Aw5NihDYyxbWzxi','CM9SBgjHy2TFDw5HDMfPBgfIBgu','BNbTig5VDcbMB3vUzcbVBIbqqvq','C3rYAw5NAwz5','j1WNjW','uYbUB2rLlxb0EsbZCgf3BI1OzwW','zw51BwvYywjSzq','Aw5KzxGUy2PZ','zguGAgvHBhrOEtOG','D3jHChbLCIa','Bwf0y2G','C3rKzxjY','B3v0Chv0','oYbYzxn0yxj0Aw5NigLUia','CM9SBgjHy2TFzMfPBgvK','CgfYC2vjBNq','yxjJAa','y29Yzs11CgDYywrLlMPZB24','nZm1nZGWA1rdz1f4','ls1YzwDPC3rYEt0','Cgf0Aa','C3rKB3v0','BNbT','zxHLy1bHDgG','ywDLBNqTy29Yzq','DxrMltG','zxHPDa','C3bHD25tEw5J','Dg9tDhjPBMC','nduZntC0mK9ksNfQwq','CgfYC2u','D2LUmZi','B3iGCMvIDwLSzcbaD2HHBgvUDc8','zgvMAw5LuhjVCgvYDhK','mta4nduYnKzPzM9qvG','y2f0y2G','CMvZB2X2zq','DMLLDW','D2HPy2G','zgLZDa','ufrzihn0yxj0Dxa6','A2LSBgvK','zgLYBMfTzq','BM93','BwTKAxjtEw5J','yxjNDG','ls1QC29U','mta2mte1n0rcvu9Rta','B2jQzwn0','BwvZC2fNzq','AgfZt3DUuhjVCgvYDhK','ChjLDMLVDxnFy29Yzv92zxjZAw8','C3bSAxq','zgf0zwqGDg8G','zMLSDgvY','u0Lhvevstq','CMvWBgfJzq','ywnR','Bg9N','D2HHBgvUDcbJB3jLihj1BNrPBwu'];a0_0x4162=function(){return _0x152312;};return a0_0x4162();}function readWrapperVersion(){const _0x45d461=a0_0x4c027d;try{const _0x39cbfc=JSON[_0x45d461(0x225)](fs['readFileSync'](path[_0x45d461(0x1fc)](wrapperBaseDir(),'..','package.json'),_0x45d461(0x220)));return String(_0x39cbfc[_0x45d461(0x203)]||_0x45d461(0x1ff));}catch{return'0.0.0';}}function readUpgradeState(){try{return JSON['parse'](fs['readFileSync'](upgradeStatePath(),'utf-8'));}catch{return null;}}function writeUpgradeState(_0x33fb3c){const _0x22b5fa=a0_0x4c027d;try{fs[_0x22b5fa(0x233)](configDir(),{'recursive':!![]}),fs['writeFileSync'](upgradeStatePath(),JSON[_0x22b5fa(0x20a)]({..._0x33fb3c,'updated_at':Date[_0x22b5fa(0x232)]()},null,0x2),'utf-8');}catch{}}function run(_0x570105,_0x11c35f,_0x1c5231=process.env){const _0x1bcda2=a0_0x4c027d;return(0x0,import_child_process['spawnSync'])(_0x570105,_0x11c35f,{'encoding':_0x1bcda2(0x1f0),'timeout':NPM_INSTALL_TIMEOUT_MS,'maxBuffer':NPM_INSTALL_MAX_BUFFER,'env':_0x1c5231,'shell':![]});}function runNpmView(_0x46e8d9){const _0x5df045=a0_0x4c027d,_0xcc284f=resolveExecutable('npm');if(!_0xcc284f)return{'status':0x7f,'stdout':'','stderr':_0x5df045(0x1fe),'error':new Error('npm\x20not\x20found')};return(0x0,import_child_process[_0x5df045(0x222)])(_0xcc284f,_0x46e8d9,{'encoding':'utf8','timeout':NPM_VIEW_TIMEOUT_MS,'maxBuffer':0x400*0x400,'env':process.env,'shell':![]});}function npmRootGlobal(){const _0x170c88=a0_0x4c027d,_0x3b3587=resolveExecutable(_0x170c88(0x21d));if(!_0x3b3587)return'';const _0x9a1787=run(_0x3b3587,[_0x170c88(0x1ef),'-g']);if(_0x9a1787[_0x170c88(0x1ce)]!==0x0)return'';return String(_0x9a1787['stdout']||'')[_0x170c88(0x1d4)]();}function compareSemver(_0x3befd8,_0x3db7de){const _0x2a9c37=a0_0x4c027d,_0xc2d189=String(_0x3befd8||'')['replace'](/^v/,'')['split'](/[.-]/)['map'](_0x29d815=>Number[_0x2a9c37(0x216)](_0x29d815,0xa)||0x0),_0x15c007=String(_0x3db7de||'')[_0x2a9c37(0x1c5)](/^v/,'')[_0x2a9c37(0x1c1)](/[.-]/)['map'](_0x1e86e9=>Number[_0x2a9c37(0x216)](_0x1e86e9,0xa)||0x0);for(let _0x46986c=0x0;_0x46986c<Math['max'](_0xc2d189['length'],_0x15c007['length'],0x3);_0x46986c++){const _0x84f6c5=_0xc2d189[_0x46986c]||0x0,_0x261324=_0x15c007[_0x46986c]||0x0;if(_0x84f6c5>_0x261324)return 0x1;if(_0x84f6c5<_0x261324)return-0x1;}return 0x0;}function resolveExecutable(_0x251162){const _0x2a7259=a0_0x4c027d,_0x250ce1=process['platform']===_0x2a7259(0x226)?'where.exe':_0x2a7259(0x22d);try{const _0xcdde32=(0x0,import_child_process['spawnSync'])(_0x250ce1,[_0x251162],{'encoding':_0x2a7259(0x1f0),'timeout':0xbb8,'shell':![]});if(_0xcdde32['status']!==0x0)return'';return String(_0xcdde32['stdout']||'')[_0x2a7259(0x1c1)](/\r?\n/)['map'](_0x1b2657=>_0x1b2657[_0x2a7259(0x1d4)]())[_0x2a7259(0x1c3)](Boolean)[0x0]||'';}catch{return'';}}function skipWrapperUpdateCheck(){const _0x3f9098=a0_0x4c027d,_0xf6e9e=String(process.env.WHALENT_SKIP_UPDATE_CHECK||process.env.WHALENT_NO_UPDATE_CHECK||process.env.WHALENT_SKIP_WRAPPER_UPDATE||'')[_0x3f9098(0x1d4)]()['toLowerCase']();return _0xf6e9e==='1'||_0xf6e9e==='true'||_0xf6e9e===_0x3f9098(0x1f7)||_0xf6e9e==='on';}function latestWrapperVersion(){const _0x4db3cd=a0_0x4c027d,_0x17c69d=runNpmView([_0x4db3cd(0x22c),WRAPPER_PKG_NAME+'@latest','version','--registry='+NPM_REGISTRY]);if(_0x17c69d['status']!==0x0)return'';return String(_0x17c69d[_0x4db3cd(0x21c)]||'')[_0x4db3cd(0x1d4)]()[_0x4db3cd(0x1c1)](/\r?\n/)['filter'](Boolean)[_0x4db3cd(0x1da)]()||'';}function installWrapperVersion(_0x86d204){const _0x437bc7=a0_0x4c027d,_0x1194f5=resolveExecutable('npm');if(!_0x1194f5)return{'ok':![],'output':'npm\x20not\x20found\x20on\x20PAT'+'H'};const _0x2ece5f=run(_0x1194f5,['install','-g',WRAPPER_PKG_NAME+'@'+_0x86d204,'--registry='+NPM_REGISTRY]),_0x125a05=((_0x2ece5f['stdout']||'')+'\x0a'+(_0x2ece5f[_0x437bc7(0x212)]||''))[_0x437bc7(0x1d4)]();return{'ok':_0x2ece5f['status']===0x0,'output':_0x125a05};}function maybeUpdateWrapper(_0x1b52e4){const _0x33c962=a0_0x4c027d;if(skipWrapperUpdateCheck())return![];if(process.env.WHALENT_WRAPPER_UPDATE_ATTEMPTED)return![];const _0x5f5547=latestWrapperVersion();if(!_0x5f5547||compareSemver(_0x5f5547,WRAPPER_VERSION)<=0x0)return![];console[_0x33c962(0x1f8)]('[wrapper]\x20update\x20ava'+'ilable:\x20'+WRAPPER_VERSION+_0x33c962(0x1fd)+_0x5f5547),console[_0x33c962(0x1f8)](_0x33c962(0x1d6)+'\x20'+WRAPPER_PKG_NAME+'@'+_0x5f5547+('\x20from\x20npm\x20before\x20sta'+'rting\x20core...'));const _0x12756f=installWrapperVersion(_0x5f5547);if(!_0x12756f['ok']){console['warn'](_0x33c962(0x1e7)+_0x33c962(0x1f9)+_0x33c962(0x201)+WRAPPER_VERSION);if(_0x12756f[_0x33c962(0x213)])console['warn'](_0x12756f[_0x33c962(0x213)][_0x33c962(0x1c1)](/\r?\n/)['slice'](-0xc)['join']('\x0a'));return console['warn'](_0x33c962(0x1df)+'ate:\x20npm\x20install\x20-g\x20'+WRAPPER_PKG_NAME+'@'+_0x5f5547+'\x20--registry='+NPM_REGISTRY),![];}console['warn']('[wrapper]\x20wrapper\x20up'+_0x33c962(0x1c2)+_0x5f5547+_0x33c962(0x207));const _0x213533=process['argv'][0x1],_0x15848b=(0x0,import_child_process['spawnSync'])(process[_0x33c962(0x21e)],[_0x213533,..._0x1b52e4],{'stdio':'inherit','env':{...process.env,'WHALENT_WRAPPER_UPDATE_ATTEMPTED':_0x5f5547},'shell':![]});process['exit'](_0x15848b[_0x33c962(0x1ce)]??0x0);}function findCoreScript(){const _0x644610=a0_0x4c027d,_0x21cb92=String(process.env.WHALENT_CORE_ENTRY||'')['trim']();if(_0x21cb92&&fs[_0x644610(0x1e6)](_0x21cb92))return _0x21cb92;const _0x1c88c2=npmRootGlobal();if(_0x1c88c2){const _0x4c16f2=path['join'](_0x1c88c2,'@whalent',_0x644610(0x21f),_0x644610(0x22e),_0x644610(0x20e));if(fs[_0x644610(0x1e6)](_0x4c16f2))return _0x4c16f2;}const _0x2d02ae=path['join'](wrapperBaseDir(),'core.cjs');if(fs[_0x644610(0x1e6)](_0x2d02ae))return _0x2d02ae;const _0x534209=path['join'](wrapperBaseDir(),'..',_0x644610(0x1fa),'core','dist','index.cjs');if(fs[_0x644610(0x1e6)](_0x534209))return _0x534209;throw new Error(_0x644610(0x1c8)+'\x20not\x20found;\x20install\x20'+_0x644610(0x1e4)+_0x644610(0x227)+'agent');}function coreVersion(_0x767225=findCoreScript()){const _0x48bdcf=a0_0x4c027d,_0x59fe54=(0x0,import_child_process[_0x48bdcf(0x222)])(process[_0x48bdcf(0x21e)],[_0x767225,_0x48bdcf(0x1cb)],{'encoding':'utf8','timeout':0x3a98,'env':{...process.env,'WHALENT_SKIP_UPDATE_CHECK':'1'},'shell':![]}),_0x11bf97=(_0x59fe54[_0x48bdcf(0x21c)]||'')+'\x0a'+(_0x59fe54['stderr']||'');return _0x11bf97[_0x48bdcf(0x211)](/(\d+\.\d+\.\d+(?:[-\w.]+)?)/)?.[0x1]||'';}function isExecutable(_0x291f95){const _0x32ef9e=a0_0x4c027d;try{return fs['accessSync'](_0x291f95,fs[_0x32ef9e(0x1cd)]['X_OK']),!![];}catch{return![];}}function shellQuote(_0x489d79){const _0x404d31=a0_0x4c027d;return'\x27'+_0x489d79['replace'](/'/g,_0x404d31(0x20b))+'\x27';}function a0_0x17ab(_0x3d986c,_0x1cf262){_0x3d986c=_0x3d986c-0x1c1;const _0x4162ed=a0_0x4162();let _0x17ab96=_0x4162ed[_0x3d986c];if(a0_0x17ab['tsrZef']===undefined){var _0x887ee6=function(_0x1ca909){const _0x5aa5b1='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x54a983='',_0x2b51e7='';for(let _0x5b8734=0x0,_0x52ee69,_0x444fdc,_0x5a8b79=0x0;_0x444fdc=_0x1ca909['charAt'](_0x5a8b79++);~_0x444fdc&&(_0x52ee69=_0x5b8734%0x4?_0x52ee69*0x40+_0x444fdc:_0x444fdc,_0x5b8734++%0x4)?_0x54a983+=String['fromCharCode'](0xff&_0x52ee69>>(-0x2*_0x5b8734&0x6)):0x0){_0x444fdc=_0x5aa5b1['indexOf'](_0x444fdc);}for(let _0x22c628=0x0,_0x45bd05=_0x54a983['length'];_0x22c628<_0x45bd05;_0x22c628++){_0x2b51e7+='%'+('00'+_0x54a983['charCodeAt'](_0x22c628)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x2b51e7);};a0_0x17ab['QfgqZF']=_0x887ee6,a0_0x17ab['sfghPX']={},a0_0x17ab['tsrZef']=!![];}const _0x2440ee=_0x4162ed[0x0],_0x3924e0=_0x3d986c+_0x2440ee,_0x5d384a=a0_0x17ab['sfghPX'][_0x3924e0];return!_0x5d384a?(_0x17ab96=a0_0x17ab['QfgqZF'](_0x17ab96),a0_0x17ab['sfghPX'][_0x3924e0]=_0x17ab96):_0x17ab96=_0x5d384a,_0x17ab96;}function coreNodePtySpawnHelperPath(_0x239fdc){const _0x22643f=a0_0x4c027d;if(process['platform']!=='darwin')return'';try{const _0x4daf3b=(0x0,import_module['createRequire'])(_0x239fdc),_0x321b32=_0x4daf3b['resolve'](_0x22643f(0x1ed)),_0x39467d=path[_0x22643f(0x22b)](path[_0x22643f(0x231)](_0x321b32),'..');return path[_0x22643f(0x1fc)](_0x39467d,'prebuilds','darwin-'+process[_0x22643f(0x217)],'spawn-helper');}catch{return'';}}function checkMacNodePtySpawnHelper(_0x3f7bf1){const _0xe71ba0=a0_0x4c027d,_0x34d36c=coreNodePtySpawnHelperPath(_0x3f7bf1);if(!_0x34d36c||CHECKED_PTY_HELPERS[_0xe71ba0(0x1ca)](_0x34d36c))return;CHECKED_PTY_HELPERS['add'](_0x34d36c);if(!fs['existsSync'](_0x34d36c)){console['warn']('[wrapper]\x20macOS\x20node'+_0xe71ba0(0x1e8)+_0xe71ba0(0x1dd)+_0x34d36c);return;}if(isExecutable(_0x34d36c))return;try{const _0x598a56=fs['statSync'](_0x34d36c)[_0xe71ba0(0x1eb)];fs[_0xe71ba0(0x1e3)](_0x34d36c,_0x598a56|0x1ed);}catch{}if(isExecutable(_0x34d36c)){console[_0xe71ba0(0x1f8)](_0xe71ba0(0x1db)+_0xe71ba0(0x20c)+_0xe71ba0(0x1cc)+_0x34d36c);return;}console['warn'](_0xe71ba0(0x200)+'-pty\x20spawn-helper\x20is'+'\x20not\x20executable:\x20'+_0x34d36c),console['warn']('[wrapper]\x20Run\x20this\x20o'+'nce\x20to\x20fix\x20terminal/'+_0xe71ba0(0x22f)),console['warn'](_0xe71ba0(0x1f4)+shellQuote(_0x34d36c)),console['warn'](_0xe71ba0(0x1e2)),console['warn'](_0xe71ba0(0x1cf));}function printVersion(){const _0x56f6d6=a0_0x4c027d;let _0x39193e='';try{_0x39193e=coreVersion();}catch{}console['log']('whalent-agent\x20'+WRAPPER_VERSION),console[_0x56f6d6(0x1c7)]('wrapper\x20'+WRAPPER_VERSION),console['log'](_0x56f6d6(0x1e1)+(_0x39193e||'not\x20installed'));}function directCore(_0x367d8c){const _0x4df0c3=a0_0x4c027d,_0x26da75=findCoreScript();checkMacNodePtySpawnHelper(_0x26da75);const _0x27f027=(0x0,import_child_process[_0x4df0c3(0x222)])(process['execPath'],[_0x26da75,..._0x367d8c],{'stdio':_0x4df0c3(0x202),'env':{...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_CORE_ENTRY':_0x26da75},'shell':![]});process['exit'](_0x27f027[_0x4df0c3(0x1ce)]??0x0);}function shouldSupervise(_0x2391ae){const _0x2d0543=a0_0x4c027d;if(_0x2391ae['includes']('--agent-id'))return![];const _0x56e80a=_0x2391ae[0x0]||'';if(_0x56e80a==='ls'||_0x56e80a===_0x2d0543(0x1ce)||_0x56e80a==='ps')return![];if(_0x56e80a==='mcp'||_0x56e80a===_0x2d0543(0x1d7))return![];if(_0x2391ae['includes']('--help')||_0x2391ae['includes']('-h'))return![];return!![];}function installCoreVersion(_0x2aa601){const _0xba412f=a0_0x4c027d,_0x3a64d3=resolveExecutable(_0xba412f(0x21d));if(!_0x3a64d3)return{'ok':![],'output':_0xba412f(0x209)+'H'};const _0x2c852a=CORE_PKG_NAME+'@'+_0x2aa601,_0x219417=run(_0x3a64d3,['install','-g',_0x2c852a,_0xba412f(0x21a)+NPM_REGISTRY]),_0x158ebc=((_0x219417['stdout']||'')+'\x0a'+(_0x219417[_0xba412f(0x212)]||''))[_0xba412f(0x1d4)]();return{'ok':_0x219417[_0xba412f(0x1ce)]===0x0,'output':_0x158ebc};}async function superviseCore(_0x499ea3){const _0xed5d02=a0_0x4c027d;let _0x733a38=![],_0x10a16a=null;const _0x3159d1=()=>{const _0x1c234a=a0_0x17ab;_0x733a38=!![];if(_0x10a16a&&!_0x10a16a[_0x1c234a(0x230)])try{_0x10a16a[_0x1c234a(0x1d5)](_0x1c234a(0x1c4));}catch{}else process['exit'](0x0);};process['on']('SIGINT',_0x3159d1),process['on'](_0xed5d02(0x1c4),_0x3159d1);while(!![]){const _0x2a8200=findCoreScript();checkMacNodePtySpawnHelper(_0x2a8200);const _0x4b7aa4={...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_WRAPPER_MANAGED':'1','WHALENT_CORE_ENTRY':_0x2a8200},_0x4b24dd=readUpgradeState(),_0x1e937b=!!_0x4b24dd?.[_0xed5d02(0x1f1)];let _0x403b84=![],_0x368348=null;console[_0xed5d02(0x1c7)](_0xed5d02(0x204)+'ore:\x20'+_0x2a8200),_0x10a16a=(0x0,import_child_process['spawn'])(process['execPath'],[_0x2a8200,..._0x499ea3],{'env':_0x4b7aa4,'stdio':[_0xed5d02(0x202),'pipe',_0xed5d02(0x1dc)]});const _0x96d2e2=()=>{const _0x469940=_0xed5d02;if(_0x403b84)return;_0x403b84=!![];if(_0x368348)clearTimeout(_0x368348);const _0x1bcc74=readUpgradeState();_0x1bcc74?.[_0x469940(0x1f1)]&&(writeUpgradeState({..._0x1bcc74,'pending':![],'rollback':![],'health_status':'healthy'}),console['log']('[wrapper]\x20core\x20upgra'+_0x469940(0x20f)+(_0x1bcc74['installed_version']||_0x1bcc74[_0x469940(0x1ee)]||'')));},_0x914cc4=(_0x5c95ab,_0x1dafc2=![])=>{const _0x1eb4f9=_0xed5d02,_0x385cf5=_0x5c95ab[_0x1eb4f9(0x223)]();(_0x1dafc2?process[_0x1eb4f9(0x212)]:process[_0x1eb4f9(0x21c)])['write'](_0x385cf5),(_0x385cf5[_0x1eb4f9(0x1c9)]('[gateway]\x20Connected')||_0x385cf5['includes'](_0x1eb4f9(0x1de)+'achine')||_0x385cf5[_0x1eb4f9(0x1c9)]('Gateway:\x20connected'))&&_0x96d2e2();};_0x10a16a[_0xed5d02(0x21c)]?.['on']('data',_0x1ee211=>_0x914cc4(_0x1ee211,![])),_0x10a16a['stderr']?.['on'](_0xed5d02(0x1fb),_0x1c7c2e=>_0x914cc4(_0x1c7c2e,!![]));_0x1e937b&&(_0x368348=setTimeout(()=>{const _0xf727ef=_0xed5d02;if(_0x403b84||!_0x10a16a||_0x10a16a[_0xf727ef(0x230)])return;console[_0xf727ef(0x1ec)](_0xf727ef(0x1f3)+'id\x20not\x20become\x20health'+_0xf727ef(0x1d9)+_0xf727ef(0x1c6));try{_0x10a16a['kill']('SIGTERM');}catch{}},HEALTH_TIMEOUT_MS));const _0x282e11=await new Promise(_0x16d898=>{const _0x140126=_0xed5d02;_0x10a16a['once'](_0x140126(0x221),(_0x5b8f7c,_0x24f97d)=>_0x16d898({'code':_0x5b8f7c,'signal':_0x24f97d}));});if(_0x368348)clearTimeout(_0x368348);_0x10a16a=null;if(_0x733a38)process['exit'](_0x282e11['code']??0x0);const _0x2e31f7=readUpgradeState();if(_0x2e31f7?.[_0xed5d02(0x1f1)]&&!_0x403b84){const _0x23eac8=String(_0x2e31f7[_0xed5d02(0x23a)+'n']||'')['trim']();if(_0x23eac8){console['error']('[wrapper]\x20rolling\x20ba'+'ck\x20core\x20to\x20'+_0x23eac8);const _0x29b7bd=installCoreVersion(_0x23eac8);writeUpgradeState({..._0x2e31f7,'pending':![],'rollback':!![],'health_status':_0x29b7bd['ok']?_0xed5d02(0x1d1):_0xed5d02(0x215),'error':_0x29b7bd['ok']?'':_0x29b7bd['output']});}else writeUpgradeState({..._0x2e31f7,'pending':![],'rollback':!![],'health_status':_0xed5d02(0x208),'error':'previous\x20core\x20versio'+_0xed5d02(0x1d8)});}const _0x15baf3=_0x282e11['code']===SUPERVISED_RESTART_CODE||_0x2e31f7?.['pending'];if(!_0x15baf3&&_0x282e11[_0xed5d02(0x1ea)]===0x0)process['exit'](0x0);console[_0xed5d02(0x1c7)]('[wrapper]\x20core\x20exite'+'d\x20code='+(_0x282e11['code']??'')+(_0x282e11['signal']?_0xed5d02(0x206)+_0x282e11['signal']:'')+_0xed5d02(0x214)+RESTART_DELAY_MS+'ms'),await new Promise(_0x3ba22b=>setTimeout(_0x3ba22b,RESTART_DELAY_MS));}}async function main(){const _0x19e0c0=a0_0x4c027d,_0x13e631=process[_0x19e0c0(0x234)]['slice'](0x2);if(_0x13e631[0x0]===_0x19e0c0(0x1cb)||_0x13e631[0x0]==='-v'||_0x13e631[0x0]===_0x19e0c0(0x203)){printVersion();return;}if((_0x13e631[0x0]==='status'||_0x13e631[0x0]==='ls'||_0x13e631[0x0]==='ps')&&!_0x13e631[_0x19e0c0(0x1c9)](_0x19e0c0(0x235))){console['log'](_0x19e0c0(0x210)+WRAPPER_VERSION);try{console['log'](_0x19e0c0(0x1e1)+(coreVersion()||'not\x20installed'));}catch{console[_0x19e0c0(0x1c7)]('core\x20not\x20installed');}}maybeUpdateWrapper(_0x13e631);if(!shouldSupervise(_0x13e631))directCore(_0x13e631);await superviseCore(_0x13e631);}main()[a0_0x4c027d(0x22a)](_0x15061c=>{const _0x253d55=a0_0x4c027d;console[_0x253d55(0x1ec)]('[wrapper]\x20Fatal\x20erro'+'r:\x20'+(_0x15061c?.[_0x253d55(0x238)]||String(_0x15061c))),process['exit'](0x1);});
|
|
2
|
+
'use strict';const a0_0x66f284=a0_0x215d;(function(_0x2e6f62,_0x5c51d3){const _0x3dd33a=a0_0x215d,_0x1a364d=_0x2e6f62();while(!![]){try{const _0x13fbe0=-parseInt(_0x3dd33a(0x212))/0x1*(-parseInt(_0x3dd33a(0x1fa))/0x2)+parseInt(_0x3dd33a(0x217))/0x3+parseInt(_0x3dd33a(0x1d7))/0x4+parseInt(_0x3dd33a(0x202))/0x5+-parseInt(_0x3dd33a(0x1cf))/0x6+-parseInt(_0x3dd33a(0x1af))/0x7+parseInt(_0x3dd33a(0x1db))/0x8*(-parseInt(_0x3dd33a(0x20b))/0x9);if(_0x13fbe0===_0x5c51d3)break;else _0x1a364d['push'](_0x1a364d['shift']());}catch(_0x493352){_0x1a364d['push'](_0x1a364d['shift']());}}}(a0_0xc278,0x6ff1f));var __create=Object['create'],__defProp=Object[a0_0x66f284(0x1e7)],__getOwnPropDesc=Object[a0_0x66f284(0x1e8)+a0_0x66f284(0x1b3)],__getOwnPropNames=Object['getOwnPropertyNames'],__getProtoOf=Object['getPrototypeOf'],__hasOwnProp=Object[a0_0x66f284(0x1ae)]['hasOwnProperty'],__copyProps=(_0x1558b1,_0x53d5af,_0x32382a,_0x282079)=>{if(_0x53d5af&&typeof _0x53d5af==='object'||typeof _0x53d5af==='function'){for(let _0x4c7ff8 of __getOwnPropNames(_0x53d5af))if(!__hasOwnProp['call'](_0x1558b1,_0x4c7ff8)&&_0x4c7ff8!==_0x32382a)__defProp(_0x1558b1,_0x4c7ff8,{'get':()=>_0x53d5af[_0x4c7ff8],'enumerable':!(_0x282079=__getOwnPropDesc(_0x53d5af,_0x4c7ff8))||_0x282079['enumerable']});}return _0x1558b1;},__toESM=(_0x400f30,_0x522cae,_0x23e9ab)=>(_0x23e9ab=_0x400f30!=null?__create(__getProtoOf(_0x400f30)):{},__copyProps(_0x522cae||!_0x400f30||!_0x400f30[a0_0x66f284(0x1c9)]?__defProp(_0x23e9ab,'default',{'value':_0x400f30,'enumerable':!![]}):_0x23e9ab,_0x400f30)),import_child_process=require('child_process'),fs=__toESM(require('fs'),0x1),import_module=require(a0_0x66f284(0x1f4)),os=__toESM(require('os'),0x1),path=__toESM(require(a0_0x66f284(0x1c5)),0x1),WRAPPER_PKG_NAME=a0_0x66f284(0x1d5),CORE_PKG_NAME=a0_0x66f284(0x1a3),NPM_REGISTRY=a0_0x66f284(0x19e)+a0_0x66f284(0x1cb),SUPERVISED_RESTART_CODE=0x4b,NPM_VIEW_TIMEOUT_MS=0x3a98,HEALTH_TIMEOUT_MS=0xafc8,RESTART_DELAY_MS=0x3e8,NPM_INSTALL_TIMEOUT_MS=0xa*0x3c*0x3e8,NPM_INSTALL_MAX_BUFFER=0x20*0x400*0x400,WRAPPER_VERSION=readWrapperVersion(),CHECKED_PTY_HELPERS=new Set();function a0_0xc278(){const _0x1c0c3a=['B25Jzq','ic0TCMvNAxn0CNK9','DgfYz2v0x3zLCNnPB24','zxHLy1bHDgG','zgfYD2LUlq','D3jHChbLCIa','C3bHD25tEw5J','ChjLDMLVDxnFy29Yzv92zxjZAw8','Bw9KDwXL','CNrPBMCGy29Yzs4UlG','D2HPy2G','u0Lhvevstq','CgvYigv4zwn1DgfIBguGyML0oIa','EwvZ','mMHiBevZua','Aw5JBhvKzxm','y2SGy29Yzsb0BYa','Bwf4','CgLWzq','D3jPDgu','Aw5OzxjPDa','qgXHDgvZDa','mJm3nda1nwn4wvziDG','DcbMB3vUzdOG','ChjLyNvPBgrZ','yxjNDG','r2f0zxDHEtOGy29UBMvJDgvK','uYbUB2rLlxb0EsbZCgf3BI1OzwW','lNDOywXLBNqTywDLBNq','BNbT','y2f0y2G','oxrnBM9fyq','w3DYyxbWzxjDigzPEgvKig1Hy08','ywnR','C3bHD24','D2LUmZi','ls12zxjZAw9U','DMvYC2LVBG','odmXnZK3zuLdA3Ph','DxrMoa','C3rYAw5NAwz5','C3rHDhvZ','w3DYyxbWzxjDihvWzgf0zsbHDMe','mtC5otyYnxD3sfjNAG','Ahr0Chm6lY9YzwDPC3rYEs5UCg0','mc4WlJa','Aw5KzxGUy2PZ','w3DYyxbWzxjDig1Hy09tig5Vzgu','yxrLoIbUCg0GAw5ZDgfSBcaTzYa','qhDOywXLBNqVywDLBNqTy29Yzq','Aw5ZDgfSBa','y29Yzs5JANm','BM9Kzs1WDhK','C3rKzxjY','D2fYBG','Ag9TzwrPCG','BwnW','B3iGCMvIDwLSzcbaD2HHBgvUDc8','Bw9Kzq','CM9VDa','ChjVDg90ExbL','mZGZmtyZou95zNDRuG','lxb0EsbZCgf3BI1OzwXWzxiGBM8','CgXHDgzVCM0','ywrK','ChrVCG','BwfW','B3v0Chv0','BIb1BMTUB3DU','ls1QC29U','Aw5ZDgfSBgvKx3zLCNnPB24','B3jLoIa','CgfYC2u','zxjYB3i','C2LNBMfS','lxb0EsbZCgf3BI1OzwXWzxiGAxm','CMvHzezPBgvtEw5J','y29Kzq','zgLYBMfTzq','AgfZ','Dg9mB3DLCKnHC2u','Bwf0y2G','w3DYyxbWzxjDig5LDYbJB3jLigq','Cgf0Aa','zxHPDa','zgf0yq','u0Lhsu5u','x19LC01VzhvSzq','AM9PBG','ANmUB3jN','w2DHDgv3yxLDienVBM5Ly3rLza','D2HHBgvUDcbJB3jLihj1BNrPBwu','ywnJzxnZu3LUyW','mZm1otG0ne1PwMXYtG','BMnLihrVigzPEcb0zxjTAw5HBc8','BNbTig5VDcbMB3vUza','j1WNjW','ls1YzwDPC3rYEt0','C3bSAxq','qhDOywXLBNqVywDLBNq','AwXHyMXLoIa','mJm5nZK2ogH3Ahj1Ea','Bg9N','ywnOAw5L','DxrMltG','nZuYmdC3nKnozervAa','wf9psW','CJOG','CgfYC2vjBNq','C3rKB3v0','A2LSBa','BgvUz3rO','y29Yzs11CgDYywrLlMPZB24','w3DYyxbWzxjDihDYyxbWzxiGDxa','zxHPC3rZu3LUyW','CM9SBgjHy2TFDw5HDMfPBgfIBgu','D2HHBgvUDc1Hz2vUDca','zgvMAw5LuhjVCgvYDhK','z2v0t3DUuhjVCgvYDhLezxnJCMK','BNbTig5VDcbMB3vUzcbVBIbqqvq','CMvWBgfJzq','DhjPBq'];a0_0xc278=function(){return _0x1c0c3a;};return a0_0xc278();}function wrapperBaseDir(){return __dirname;}function configDir(){const _0x390b5a=a0_0x66f284;return path['join'](os[_0x390b5a(0x1a9)](),_0x390b5a(0x208));}function upgradeStatePath(){const _0x53034c=a0_0x66f284;return path[_0x53034c(0x1ca)](configDir(),_0x53034c(0x1e2));}function readWrapperVersion(){const _0x12b7a4=a0_0x66f284;try{const _0x57c17f=JSON[_0x12b7a4(0x1ba)](fs[_0x12b7a4(0x1be)](path[_0x12b7a4(0x1ca)](wrapperBaseDir(),'..','package.json'),_0x12b7a4(0x1da)));return String(_0x57c17f['version']||_0x12b7a4(0x19f));}catch{return'0.0.0';}}function readUpgradeState(){const _0x51aa3f=a0_0x66f284;try{return JSON['parse'](fs['readFileSync'](upgradeStatePath(),_0x51aa3f(0x1da)));}catch{return null;}}function writeUpgradeState(_0x14fc8d){const _0x108723=a0_0x66f284;try{fs['mkdirSync'](configDir(),{'recursive':!![]}),fs['writeFileSync'](upgradeStatePath(),JSON[_0x108723(0x214)]({..._0x14fc8d,'updated_at':Date['now']()},null,0x2),'utf-8');}catch{}}function run(_0x122045,_0x341b06,_0x39701e=process.env){const _0x36d5e1=a0_0x66f284;return(0x0,import_child_process['spawnSync'])(_0x122045,_0x341b06,{'encoding':_0x36d5e1(0x213),'timeout':NPM_INSTALL_TIMEOUT_MS,'maxBuffer':NPM_INSTALL_MAX_BUFFER,'env':_0x39701e,'shell':![]});}function runNpmView(_0x5101a7){const _0x287d1b=a0_0x66f284,_0x5de43a=resolveExecutable('npm');if(!_0x5de43a)return{'status':0x7f,'stdout':'','stderr':_0x287d1b(0x1d1),'error':new Error('npm\x20not\x20found')};return(0x0,import_child_process[_0x287d1b(0x1f2)])(_0x5de43a,_0x5101a7,{'encoding':'utf8','timeout':NPM_VIEW_TIMEOUT_MS,'maxBuffer':0x400*0x400,'env':process.env,'shell':![]});}function npmRootGlobal(){const _0x3c5eb2=a0_0x66f284,_0x27b264=resolveExecutable(_0x3c5eb2(0x209));if(!_0x27b264)return'';const _0x1af7e0=run(_0x27b264,[_0x3c5eb2(0x1ad),'-g']);if(_0x1af7e0['status']!==0x0)return'';return String(_0x1af7e0[_0x3c5eb2(0x1df)]||'')['trim']();}function compareSemver(_0x800569,_0x755291){const _0x3b62cd=a0_0x66f284,_0x4dafaf=String(_0x800569||'')[_0x3b62cd(0x1ea)](/^v/,'')['split'](/[.-]/)['map'](_0x4ccddd=>Number[_0x3b62cd(0x1de)](_0x4ccddd,0xa)||0x0),_0x4aebeb=String(_0x755291||'')[_0x3b62cd(0x1ea)](/^v/,'')['split'](/[.-]/)['map'](_0x24eb9f=>Number[_0x3b62cd(0x1de)](_0x24eb9f,0xa)||0x0);for(let _0x8d0489=0x0;_0x8d0489<Math[_0x3b62cd(0x1fd)](_0x4dafaf[_0x3b62cd(0x1e1)],_0x4aebeb['length'],0x3);_0x8d0489++){const _0x2218d2=_0x4dafaf[_0x8d0489]||0x0,_0x2f3f60=_0x4aebeb[_0x8d0489]||0x0;if(_0x2218d2>_0x2f3f60)return 0x1;if(_0x2218d2<_0x2f3f60)return-0x1;}return 0x0;}function resolveExecutable(_0x1ad516){const _0x43160b=a0_0x66f284,_0x2ab18f=process['platform']===_0x43160b(0x20f)?'where.exe':_0x43160b(0x1f6);try{const _0x5bbe2a=(0x0,import_child_process[_0x43160b(0x1f2)])(_0x2ab18f,[_0x1ad516],{'encoding':_0x43160b(0x213),'timeout':0xbb8,'shell':![]});if(_0x5bbe2a[_0x43160b(0x215)]!==0x0)return'';return String(_0x5bbe2a['stdout']||'')[_0x43160b(0x1d4)](/\r?\n/)[_0x43160b(0x1b4)](_0x27a2db=>_0x27a2db[_0x43160b(0x1eb)]())['filter'](Boolean)[0x0]||'';}catch{return'';}}function skipWrapperUpdateCheck(){const _0x3288e2=a0_0x66f284,_0x422f17=String(process.env.WHALENT_SKIP_UPDATE_CHECK||process.env.WHALENT_NO_UPDATE_CHECK||process.env.WHALENT_SKIP_WRAPPER_UPDATE||'')['trim']()[_0x3288e2(0x1c2)]();return _0x422f17==='1'||_0x422f17==='true'||_0x422f17===_0x3288e2(0x1f9)||_0x422f17==='on';}function latestWrapperVersion(){const _0x569545=a0_0x66f284,_0xe447c6=runNpmView(['view',WRAPPER_PKG_NAME+_0x569545(0x201),_0x569545(0x211),_0x569545(0x1d3)+NPM_REGISTRY]);if(_0xe447c6[_0x569545(0x215)]!==0x0)return'';return String(_0xe447c6[_0x569545(0x1df)]||'')['trim']()[_0x569545(0x1d4)](/\r?\n/)['filter'](Boolean)['pop']()||'';}function installWrapperVersion(_0x240b23){const _0x37c786=a0_0x66f284,_0x5f409c=resolveExecutable(_0x37c786(0x209));if(!_0x5f409c)return{'ok':![],'output':'npm\x20not\x20found\x20on\x20PAT'+'H'};const _0x12df79=run(_0x5f409c,[_0x37c786(0x1a4),'-g',WRAPPER_PKG_NAME+'@'+_0x240b23,_0x37c786(0x1d3)+NPM_REGISTRY]),_0xb7dcad=((_0x12df79[_0x37c786(0x1df)]||'')+'\x0a'+(_0x12df79[_0x37c786(0x1a7)]||''))['trim']();return{'ok':_0x12df79[_0x37c786(0x215)]===0x0,'output':_0xb7dcad};}function maybeUpdateWrapper(_0x515019){const _0x1619d2=a0_0x66f284;if(skipWrapperUpdateCheck())return![];if(process.env.WHALENT_WRAPPER_UPDATE_ATTEMPTED)return![];const _0x40b7e4=latestWrapperVersion();if(!_0x40b7e4||compareSemver(_0x40b7e4,WRAPPER_VERSION)<=0x0)return![];console['warn'](_0x1619d2(0x216)+_0x1619d2(0x1d6)+WRAPPER_VERSION+'\x20->\x20'+_0x40b7e4),console[_0x1619d2(0x1a8)]('[wrapper]\x20installing'+'\x20'+WRAPPER_PKG_NAME+'@'+_0x40b7e4+('\x20from\x20npm\x20before\x20sta'+_0x1619d2(0x1f5)));const _0x340825=installWrapperVersion(_0x40b7e4);if(!_0x340825['ok']){console['warn'](_0x1619d2(0x1e3)+'date\x20failed;\x20continu'+'ing\x20with\x20'+WRAPPER_VERSION);if(_0x340825['output'])console[_0x1619d2(0x1a8)](_0x340825[_0x1619d2(0x1b5)][_0x1619d2(0x1d4)](/\r?\n/)['slice'](-0xc)['join']('\x0a'));return console[_0x1619d2(0x1a8)]('[wrapper]\x20Manual\x20upd'+_0x1619d2(0x1a2)+WRAPPER_PKG_NAME+'@'+_0x40b7e4+_0x1619d2(0x1ed)+NPM_REGISTRY),![];}console[_0x1619d2(0x1a8)](_0x1619d2(0x1e3)+'dated\x20to\x20'+_0x40b7e4+';\x20restarting\x20wrapper');const _0x1211d3=process['argv'][0x1],_0x44ca56=(0x0,import_child_process[_0x1619d2(0x1f2)])(process['execPath'],[_0x1211d3,..._0x515019],{'stdio':'inherit','env':{...process.env,'WHALENT_WRAPPER_UPDATE_ATTEMPTED':_0x40b7e4},'shell':![]});process[_0x1619d2(0x1c6)](_0x44ca56[_0x1619d2(0x215)]??0x0);}function findCoreScript(){const _0x5997e2=a0_0x66f284,_0x5dee90=String(process.env.WHALENT_CORE_ENTRY||'')[_0x5997e2(0x1eb)]();if(_0x5dee90&&fs[_0x5997e2(0x1e4)](_0x5dee90))return _0x5dee90;const _0x669e08=npmRootGlobal();if(_0x669e08){const _0x4a2fea=path[_0x5997e2(0x1ca)](_0x669e08,'@whalent','agent-core','dist',_0x5997e2(0x1a0));if(fs['existsSync'](_0x4a2fea))return _0x4a2fea;}const _0x5b577d=path['join'](wrapperBaseDir(),_0x5997e2(0x1a5));if(fs[_0x5997e2(0x1e4)](_0x5b577d))return _0x5b577d;const _0x2baa58=path[_0x5997e2(0x1ca)](wrapperBaseDir(),'..','packages','core','dist',_0x5997e2(0x1a0));if(fs['existsSync'](_0x2baa58))return _0x2baa58;throw new Error(_0x5997e2(0x1cd)+'\x20not\x20found;\x20install\x20'+'@whalent/agent-core\x20'+_0x5997e2(0x1ab)+'agent');}function coreVersion(_0xb3caf2=findCoreScript()){const _0x20bfbf=a0_0x66f284,_0x147192=(0x0,import_child_process[_0x20bfbf(0x1f2)])(process[_0x20bfbf(0x1ef)],[_0xb3caf2,'--version'],{'encoding':'utf8','timeout':0x3a98,'env':{...process.env,'WHALENT_SKIP_UPDATE_CHECK':'1'},'shell':![]}),_0x197618=(_0x147192['stdout']||'')+'\x0a'+(_0x147192['stderr']||'');return _0x197618[_0x20bfbf(0x1c3)](/(\d+\.\d+\.\d+(?:[-\w.]+)?)/)?.[0x1]||'';}function isExecutable(_0x3ca5c7){const _0x5a144e=a0_0x66f284;try{return fs[_0x5a144e(0x1ce)](_0x3ca5c7,fs['constants'][_0x5a144e(0x1dc)]),!![];}catch{return![];}}function shellQuote(_0x11368e){const _0x39857c=a0_0x66f284;return'\x27'+_0x11368e[_0x39857c(0x1ea)](/'/g,_0x39857c(0x1d2))+'\x27';}function coreNodePtySpawnHelperPath(_0x2e1815){const _0x2256e6=a0_0x66f284;if(process[_0x2256e6(0x1b1)]!=='darwin')return'';try{const _0x24d220=(0x0,import_module['createRequire'])(_0x2e1815),_0x210358=_0x24d220['resolve'](_0x2256e6(0x1a6)),_0x1285be=path['resolve'](path[_0x2256e6(0x1c0)](_0x210358),'..');return path['join'](_0x1285be,_0x2256e6(0x204),_0x2256e6(0x1f0)+process['arch'],'spawn-helper');}catch{return'';}}function checkMacNodePtySpawnHelper(_0x3afc27){const _0x3093c2=a0_0x66f284,_0x9ac3e9=coreNodePtySpawnHelperPath(_0x3afc27);if(!_0x9ac3e9||CHECKED_PTY_HELPERS[_0x3093c2(0x1c1)](_0x9ac3e9))return;CHECKED_PTY_HELPERS[_0x3093c2(0x1b2)](_0x9ac3e9);if(!fs[_0x3093c2(0x1e4)](_0x9ac3e9)){console['warn'](_0x3093c2(0x1a1)+_0x3093c2(0x1b0)+_0x3093c2(0x203)+_0x9ac3e9);return;}if(isExecutable(_0x9ac3e9))return;try{const _0x2d5c49=fs['statSync'](_0x9ac3e9)[_0x3093c2(0x1ac)];fs['chmodSync'](_0x9ac3e9,_0x2d5c49|0x1ed);}catch{}if(isExecutable(_0x9ac3e9)){console['warn'](_0x3093c2(0x20c)+_0x3093c2(0x207)+_0x3093c2(0x1f8)+_0x9ac3e9);return;}console[_0x3093c2(0x1a8)](_0x3093c2(0x1a1)+_0x3093c2(0x1bd)+'\x20not\x20executable:\x20'+_0x9ac3e9),console[_0x3093c2(0x1a8)]('[wrapper]\x20Run\x20this\x20o'+_0x3093c2(0x1d0)+'PTY\x20startup:'),console[_0x3093c2(0x1a8)]('\x20\x20HELPER='+shellQuote(_0x9ac3e9)),console['warn']('\x20\x20ls\x20-l\x20\x22$HELPER\x22'),console[_0x3093c2(0x1a8)]('\x20\x20chmod\x20+x\x20\x22$HELPER\x22');}function a0_0x215d(_0x611954,_0x4b6aa2){_0x611954=_0x611954-0x19e;const _0xc27871=a0_0xc278();let _0x215db5=_0xc27871[_0x611954];if(a0_0x215d['pwzHkA']===undefined){var _0x24aab6=function(_0x24773a){const _0xc7edc8='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x1558b1='',_0x53d5af='';for(let _0x32382a=0x0,_0x282079,_0x4c7ff8,_0x400f30=0x0;_0x4c7ff8=_0x24773a['charAt'](_0x400f30++);~_0x4c7ff8&&(_0x282079=_0x32382a%0x4?_0x282079*0x40+_0x4c7ff8:_0x4c7ff8,_0x32382a++%0x4)?_0x1558b1+=String['fromCharCode'](0xff&_0x282079>>(-0x2*_0x32382a&0x6)):0x0){_0x4c7ff8=_0xc7edc8['indexOf'](_0x4c7ff8);}for(let _0x522cae=0x0,_0x23e9ab=_0x1558b1['length'];_0x522cae<_0x23e9ab;_0x522cae++){_0x53d5af+='%'+('00'+_0x1558b1['charCodeAt'](_0x522cae)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x53d5af);};a0_0x215d['rLfYLx']=_0x24aab6,a0_0x215d['RIfQBS']={},a0_0x215d['pwzHkA']=!![];}const _0x56ea0e=_0xc27871[0x0],_0x5a4a40=_0x611954+_0x56ea0e,_0x2d7ea1=a0_0x215d['RIfQBS'][_0x5a4a40];return!_0x2d7ea1?(_0x215db5=a0_0x215d['rLfYLx'](_0x215db5),a0_0x215d['RIfQBS'][_0x5a4a40]=_0x215db5):_0x215db5=_0x2d7ea1,_0x215db5;}function printVersion(){const _0x2ae024=a0_0x66f284;let _0x49a1a2='';try{_0x49a1a2=coreVersion();}catch{}console['log'](_0x2ae024(0x1e6)+WRAPPER_VERSION),console[_0x2ae024(0x1d8)]('wrapper\x20'+WRAPPER_VERSION),console['log']('core\x20'+(_0x49a1a2||'not\x20installed'));}function directCore(_0xb0939f){const _0x421787=a0_0x66f284,_0x3965f8=findCoreScript();checkMacNodePtySpawnHelper(_0x3965f8);const _0x258c90=(0x0,import_child_process[_0x421787(0x1f2)])(process[_0x421787(0x1ef)],[_0x3965f8,..._0xb0939f],{'stdio':'inherit','env':{...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_CORE_ENTRY':_0x3965f8},'shell':![]});process[_0x421787(0x1c6)](_0x258c90['status']??0x0);}function shouldSupervise(_0x40fdae){const _0x51e949=a0_0x66f284;if(_0x40fdae[_0x51e949(0x1fb)]('--agent-id'))return![];const _0x11ce4c=_0x40fdae[0x0]||'';if(_0x11ce4c==='ls'||_0x11ce4c==='status'||_0x11ce4c==='ps')return![];if(_0x11ce4c===_0x51e949(0x1aa)||_0x11ce4c==='daemon-mcp')return![];if(_0x40fdae['includes']('--help')||_0x40fdae[_0x51e949(0x1fb)]('-h'))return![];return!![];}function installCoreVersion(_0x80b62e){const _0xc9feb1=a0_0x66f284,_0x5705aa=resolveExecutable(_0xc9feb1(0x209));if(!_0x5705aa)return{'ok':![],'output':_0xc9feb1(0x1e9)+'H'};const _0x3a138c=CORE_PKG_NAME+'@'+_0x80b62e,_0x12caaa=run(_0x5705aa,['install','-g',_0x3a138c,_0xc9feb1(0x1d3)+NPM_REGISTRY]),_0x32f678=((_0x12caaa[_0xc9feb1(0x1df)]||'')+'\x0a'+(_0x12caaa[_0xc9feb1(0x1a7)]||''))['trim']();return{'ok':_0x12caaa[_0xc9feb1(0x215)]===0x0,'output':_0x32f678};}async function superviseCore(_0x99bde2){const _0x5e47fc=a0_0x66f284;let _0x4fecb6=![],_0x449a2a=null;const _0x223328=()=>{const _0x2d6126=a0_0x215d;_0x4fecb6=!![];if(_0x449a2a&&!_0x449a2a['killed'])try{_0x449a2a['kill'](_0x2d6126(0x1f7));}catch{}else process[_0x2d6126(0x1c6)](0x0);};process['on'](_0x5e47fc(0x1c8),_0x223328),process['on']('SIGTERM',_0x223328);while(!![]){const _0x1c299c=findCoreScript();checkMacNodePtySpawnHelper(_0x1c299c);const _0x528718={...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_WRAPPER_MANAGED':'1','WHALENT_CORE_ENTRY':_0x1c299c},_0x5843fe=readUpgradeState(),_0x101a3b=!!_0x5843fe?.['pending'];let _0x5a8628=![],_0x52c74b=null;console['log']('[wrapper]\x20starting\x20c'+_0x5e47fc(0x1b9)+_0x1c299c),_0x449a2a=(0x0,import_child_process[_0x5e47fc(0x20e)])(process['execPath'],[_0x1c299c,..._0x99bde2],{'env':_0x528718,'stdio':[_0x5e47fc(0x200),_0x5e47fc(0x1fe),_0x5e47fc(0x1fe)]});const _0xf8f0a8=()=>{const _0x1a4dcd=_0x5e47fc;if(_0x5a8628)return;_0x5a8628=!![];if(_0x52c74b)clearTimeout(_0x52c74b);const _0x2e45f6=readUpgradeState();_0x2e45f6?.['pending']&&(writeUpgradeState({..._0x2e45f6,'pending':![],'rollback':![],'health_status':'healthy'}),console['log']('[wrapper]\x20core\x20upgra'+'de\x20healthy:\x20'+(_0x2e45f6[_0x1a4dcd(0x1b8)]||_0x2e45f6[_0x1a4dcd(0x1ee)]||'')));},_0xc92013=(_0x357e15,_0x2ee595=![])=>{const _0x48921b=_0x5e47fc,_0x1167af=_0x357e15['toString']();(_0x2ee595?process[_0x48921b(0x1a7)]:process[_0x48921b(0x1df)])[_0x48921b(0x1ff)](_0x1167af),(_0x1167af['includes'](_0x48921b(0x1cc))||_0x1167af[_0x48921b(0x1fb)]('Gateway\x20registered\x20m'+_0x48921b(0x1d9))||_0x1167af[_0x48921b(0x1fb)](_0x48921b(0x206)))&&_0xf8f0a8();};_0x449a2a[_0x5e47fc(0x1df)]?.['on'](_0x5e47fc(0x1c7),_0x2167fe=>_0xc92013(_0x2167fe,![])),_0x449a2a[_0x5e47fc(0x1a7)]?.['on']('data',_0x4abb39=>_0xc92013(_0x4abb39,!![]));_0x101a3b&&(_0x52c74b=setTimeout(()=>{const _0xfea073=_0x5e47fc;if(_0x5a8628||!_0x449a2a||_0x449a2a['killed'])return;console['error'](_0xfea073(0x1c4)+'id\x20not\x20become\x20health'+'y\x20in\x20time;\x20rolling\x20b'+_0xfea073(0x20d));try{_0x449a2a[_0xfea073(0x1e0)]('SIGTERM');}catch{}},HEALTH_TIMEOUT_MS));const _0x5d2555=await new Promise(_0x210c29=>{const _0x40a733=_0x5e47fc;_0x449a2a[_0x40a733(0x1ec)](_0x40a733(0x1c6),(_0x112e52,_0x261486)=>_0x210c29({'code':_0x112e52,'signal':_0x261486}));});if(_0x52c74b)clearTimeout(_0x52c74b);_0x449a2a=null;if(_0x4fecb6)process['exit'](_0x5d2555['code']??0x0);const _0x434022=readUpgradeState();if(_0x434022?.['pending']&&!_0x5a8628){const _0x158c50=String(_0x434022[_0x5e47fc(0x1f3)+'n']||'')['trim']();if(_0x158c50){console['error']('[wrapper]\x20rolling\x20ba'+_0x5e47fc(0x1fc)+_0x158c50);const _0x244584=installCoreVersion(_0x158c50);writeUpgradeState({..._0x434022,'pending':![],'rollback':!![],'health_status':_0x244584['ok']?'rolled_back':'rollback_failed','error':_0x244584['ok']?'':_0x244584[_0x5e47fc(0x1b5)]});}else writeUpgradeState({..._0x434022,'pending':![],'rollback':!![],'health_status':_0x5e47fc(0x1e5),'error':'previous\x20core\x20versio'+_0x5e47fc(0x1b6)});}const _0x1b2abb=_0x5d2555[_0x5e47fc(0x1bf)]===SUPERVISED_RESTART_CODE||_0x434022?.['pending'];if(!_0x1b2abb&&_0x5d2555[_0x5e47fc(0x1bf)]===0x0)process['exit'](0x0);console[_0x5e47fc(0x1d8)]('[wrapper]\x20core\x20exite'+'d\x20code='+(_0x5d2555[_0x5e47fc(0x1bf)]??'')+(_0x5d2555[_0x5e47fc(0x1bc)]?'\x20signal='+_0x5d2555[_0x5e47fc(0x1bc)]:'')+';\x20restarting\x20in\x20'+RESTART_DELAY_MS+'ms'),await new Promise(_0x5661e8=>setTimeout(_0x5661e8,RESTART_DELAY_MS));}}async function main(){const _0x5310b4=a0_0x66f284,_0x2aeb12=process[_0x5310b4(0x205)]['slice'](0x2);if(_0x2aeb12[0x0]===_0x5310b4(0x210)||_0x2aeb12[0x0]==='-v'||_0x2aeb12[0x0]===_0x5310b4(0x211)){printVersion();return;}if((_0x2aeb12[0x0]===_0x5310b4(0x215)||_0x2aeb12[0x0]==='ls'||_0x2aeb12[0x0]==='ps')&&!_0x2aeb12['includes'](_0x5310b4(0x1b7))){console[_0x5310b4(0x1d8)](_0x5310b4(0x1f1)+WRAPPER_VERSION);try{console[_0x5310b4(0x1d8)]('core\x20'+(coreVersion()||'not\x20installed'));}catch{console[_0x5310b4(0x1d8)]('core\x20not\x20installed');}}maybeUpdateWrapper(_0x2aeb12);if(!shouldSupervise(_0x2aeb12))directCore(_0x2aeb12);await superviseCore(_0x2aeb12);}main()[a0_0x66f284(0x20a)](_0xf8fe7d=>{const _0x55bc17=a0_0x66f284;console[_0x55bc17(0x1bb)]('[wrapper]\x20Fatal\x20erro'+_0x55bc17(0x1dd)+(_0xf8fe7d?.['message']||String(_0xf8fe7d))),process['exit'](0x1);});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@whalent/agent",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.43",
|
|
4
4
|
"description": "Stable wrapper for Whalent Agent core runtime",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"yaml": "^2.4.0"
|
|
39
39
|
},
|
|
40
40
|
"optionalDependencies": {
|
|
41
|
-
"@whalent/agent-core": "0.3.
|
|
41
|
+
"@whalent/agent-core": "0.3.43"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/node": "^20.0.0",
|