@whalent/agent 0.3.51 → 0.3.52
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_0x49a098=a0_0x169a;(function(_0x5e34b4,_0x506112){const _0x5d40ab=a0_0x169a,_0x50a6a2=_0x5e34b4();while(!![]){try{const _0x1bf66a=parseInt(_0x5d40ab(0xd5))/0x1*(-parseInt(_0x5d40ab(0x118))/0x2)+-parseInt(_0x5d40ab(0xeb))/0x3+parseInt(_0x5d40ab(0xf3))/0x4*(parseInt(_0x5d40ab(0xa1))/0x5)+parseInt(_0x5d40ab(0xf8))/0x6+-parseInt(_0x5d40ab(0xf6))/0x7*(-parseInt(_0x5d40ab(0xa6))/0x8)+parseInt(_0x5d40ab(0x100))/0x9+parseInt(_0x5d40ab(0xcc))/0xa;if(_0x1bf66a===_0x506112)break;else _0x50a6a2['push'](_0x50a6a2['shift']());}catch(_0x3975a5){_0x50a6a2['push'](_0x50a6a2['shift']());}}}(a0_0x7417,0xb5b38));function a0_0x7417(){const _0x4507e0=['ywDLBNqTy29Yzq','w3DYyxbWzxjDig5LDYbJB3jLigq','y2fUzgLKyxrL','DcbMB3vUzdOG','CgLWzq','zxHLy1bHDgG','zgvMAw5LuhjVCgvYDhK','yxjNDG','x19LC01VzhvSzq','CMvWBgfJzq','BgvUz3rO','CgvUzgLUzW','lxb0EsbZCgf3BI1OzwXWzxiGAxm','zxHPC3rZu3LUyW','r2f0zxDHEsbYzwDPC3rLCMvKig0','C2XPy2u','DMvYC2LVBG','zNvUy3rPB24','w3DYyxbWzxjDihvWzgf0zsbHDMe','DxrMltG','CM9VDa','DMLLDW','BMnLihrVigzPEcb0zxjTAw5HBc8','ls12zxjZAw9U','zxjYB3i','ls1Hz2vUDc1Pza','A2LSBgvK','C3bSAxq','Bg9N','CgXHDgzVCM0','w3DYyxbWzxjDihjVBgXPBMCGyMe','y29Yzsa','qhDOywXLBNq','Aw5KzxG','A2LSBa','Dg9mB3DLCKnHC2u','ChjVDg90ExbL','mte2otC0nJbRrKjyugG','BNbTig5VDcbMB3vUza','Aw5ZDgfSBa','C3bHD24TAgvSCgvY','y29Kzq','Ahr0Chm6lY9YzwDPC3rYEs5UCg0','oYbYzxn0yxj0Aw5NigLUia','Bwf4','zcbJB2rLpq','mJa5m2XuBwzpwG','y29Yzs5JANm','zgvMyxvSDa','C2LNBMfS','C3rHDhvZ','ls1YzwDPC3rYEt0','mc4WlJa','C3bHD25tEw5J','CJOG','qhDOywXLBNqVywDLBNqTy29Yzq','BM9Kzs1WDhK','DhjPBq','D2HHBgvUDcbJB3jLihj1BNrPBwu','zxHPDa','u0Lhsu5u','ig5VDcbMB3vUzdSGAw5ZDgfSBca','CgfYC2vjBNq','Dg9tDhjPBMC','lxb0EsbZCgf3BI1OzwXWzxiGBM8','ChjLDMLVDxmGy29Yzsb2zxjZAw8','BNbTig5VDcbMB3vUzcbVBIbqqvq','igzYB20GBNbTigjLzM9YzsbZDge','mZi5ntq0nLPAq3Lwwq','C3rKB3v0','lNDOywXLBNqTywDLBNq','EwvZ','zgf0yq','D2HLCMuUzxHL','DgfYz2v0x3zLCNnPB24','ls1QC29U','nhDKsffcqG','Aw5KzxGUy2PZ','ywnOAw5L','odi4mdnqCKz0sgO','z2v0t3DUuhjVCgvYDhLoyw1LCW','mJqYndy2AwP1DerK','D3jHChbLCIa','qhDOywXLBNqVywDLBNq','CNrPBMCGy29Yzs4UlG','ufrzihn0yxj0Dxa6','B3v0Chv0','BwTKAxjtEw5J','ChrVCG','ntmYotu5m1PTBKvUrW','BwfW','Ag9TzwrPCG','C3rKzxjY','Dhj1zq','EsbPBIb0Aw1LoYbYB2XSAw5Nigi','BM93','Bw9Kzq','Aw5JBhvKzxm','D2HHBgvUDc1Hz2vUDca','CgfJA2fNzs5QC29U','BNbT','CM9SBgjHy2TFDw5HDMfPBgfIBgu','zMLSDgvY','ywDLBNq','ChjLDMLVDxnFy29Yzv92zxjZAw8','CMvHzezPBgvtEw5J','ic0TCMvNAxn0CNK9','y29UC3rHBNrZ','yxjJAa','D2fYBG','AM9PBG','y2SGy29Yzsb0BYa','Cg9W','mte2mKzAy2zVtG','qhDOywXLBNqVywDLBNqTy29Yzsa','BwvZC2fNzq','nJa0ntu2nw93qKrvza','zgLYBMfTzq','Aw5OzxjPDa','y3jLyxrLuMvXDwLYzq','ChvZAa','mZjfEefSzeC'];a0_0x7417=function(){return _0x4507e0;};return a0_0x7417();}var __create=Object['create'],__defProp=Object[a0_0x49a098(0xad)],__getOwnPropDesc=Object['getOwnPropertyDescri'+a0_0x49a098(0xff)],__getOwnPropNames=Object[a0_0x49a098(0xf7)],__getProtoOf=Object['getPrototypeOf'],__hasOwnProp=Object[a0_0x49a098(0xcb)]['hasOwnProperty'],__copyProps=(_0x438519,_0x454e88,_0x39ec0e,_0x9f11fb)=>{const _0x2bb400=a0_0x49a098;if(_0x454e88&&typeof _0x454e88==='object'||typeof _0x454e88===_0x2bb400(0xb8)){for(let _0x11efc3 of __getOwnPropNames(_0x454e88))if(!__hasOwnProp['call'](_0x438519,_0x11efc3)&&_0x11efc3!==_0x39ec0e)__defProp(_0x438519,_0x11efc3,{'get':()=>_0x454e88[_0x11efc3],'enumerable':!(_0x9f11fb=__getOwnPropDesc(_0x454e88,_0x11efc3))||_0x9f11fb['enumerable']});}return _0x438519;},__toESM=(_0x3739cc,_0x161c61,_0x1aa17f)=>(_0x1aa17f=_0x3739cc!=null?__create(__getProtoOf(_0x3739cc)):{},__copyProps(_0x161c61||!_0x3739cc||!_0x3739cc[a0_0x49a098(0xaf)]?__defProp(_0x1aa17f,a0_0x49a098(0xd7),{'value':_0x3739cc,'enumerable':!![]}):_0x1aa17f,_0x3739cc)),import_child_process=require('child_process'),fs=__toESM(require('fs'),0x1),import_module=require('module'),os=__toESM(require('os'),0x1),path=__toESM(require('path'),0x1),WRAPPER_PKG_NAME=a0_0x49a098(0xfa),CORE_PKG_NAME=a0_0x49a098(0xde),NPM_REGISTRY=a0_0x49a098(0xd1)+'js.org',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 _0x463684=a0_0x49a098;return path[_0x463684(0x115)](os[_0x463684(0x102)](),_0x463684(0xed));}function upgradeStatePath(){const _0x1b4db1=a0_0x49a098;return path[_0x1b4db1(0x115)](configDir(),'core-upgrade.json');}function readWrapperVersion(){const _0x1fa249=a0_0x49a098;try{const _0x438c4e=JSON['parse'](fs[_0x1fa249(0x110)](path[_0x1fa249(0x115)](wrapperBaseDir(),'..',_0x1fa249(0x10a)),_0x1fa249(0xba)));return String(_0x438c4e['version']||'0.0.0');}catch{return _0x1fa249(0xdb);}}function readUpgradeState(){const _0x1f6535=a0_0x49a098;try{return JSON['parse'](fs['readFileSync'](upgradeStatePath(),_0x1f6535(0xba)));}catch{return null;}}function writeUpgradeState(_0x346dc7){const _0x3d162b=a0_0x49a098;try{fs[_0x3d162b(0xfe)](configDir(),{'recursive':!![]}),fs['writeFileSync'](upgradeStatePath(),JSON['stringify']({..._0x346dc7,'updated_at':Date[_0x3d162b(0x106)]()},null,0x2),'utf-8');}catch{}}function a0_0x169a(_0x33cf78,_0x2eeb8e){_0x33cf78=_0x33cf78-0xa0;const _0x74173e=a0_0x7417();let _0x169a68=_0x74173e[_0x33cf78];if(a0_0x169a['XiqXkB']===undefined){var _0x16834f=function(_0x4e2a81){const _0x2ff261='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x438519='',_0x454e88='';for(let _0x39ec0e=0x0,_0x9f11fb,_0x11efc3,_0x3739cc=0x0;_0x11efc3=_0x4e2a81['charAt'](_0x3739cc++);~_0x11efc3&&(_0x9f11fb=_0x39ec0e%0x4?_0x9f11fb*0x40+_0x11efc3:_0x11efc3,_0x39ec0e++%0x4)?_0x438519+=String['fromCharCode'](0xff&_0x9f11fb>>(-0x2*_0x39ec0e&0x6)):0x0){_0x11efc3=_0x2ff261['indexOf'](_0x11efc3);}for(let _0x161c61=0x0,_0x1aa17f=_0x438519['length'];_0x161c61<_0x1aa17f;_0x161c61++){_0x454e88+='%'+('00'+_0x438519['charCodeAt'](_0x161c61)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x454e88);};a0_0x169a['rwrWQO']=_0x16834f,a0_0x169a['HFLyXW']={},a0_0x169a['XiqXkB']=!![];}const _0x5fc276=_0x74173e[0x0],_0x352576=_0x33cf78+_0x5fc276,_0x52c31d=a0_0x169a['HFLyXW'][_0x352576];return!_0x52c31d?(_0x169a68=a0_0x169a['rwrWQO'](_0x169a68),a0_0x169a['HFLyXW'][_0x352576]=_0x169a68):_0x169a68=_0x52c31d,_0x169a68;}function run(_0x2e09dc,_0x3e8374,_0x226fff=process.env){const _0x41104a=a0_0x49a098;return(0x0,import_child_process[_0x41104a(0xdc)])(_0x2e09dc,_0x3e8374,{'encoding':'utf8','timeout':NPM_INSTALL_TIMEOUT_MS,'maxBuffer':NPM_INSTALL_MAX_BUFFER,'env':_0x226fff,'shell':![]});}function runNpmView(_0x2cc202){const _0x19769c=a0_0x49a098,_0x30b40a=resolveExecutable(_0x19769c(0x10b));if(!_0x30b40a)return{'status':0x7f,'stdout':'','stderr':'npm\x20not\x20found','error':new Error(_0x19769c(0xcd))};return(0x0,import_child_process[_0x19769c(0xdc)])(_0x30b40a,_0x2cc202,{'encoding':'utf8','timeout':NPM_VIEW_TIMEOUT_MS,'maxBuffer':0x400*0x400,'env':process.env,'shell':![]});}function npmRootGlobal(){const _0x41388d=a0_0x49a098,_0x439ab6=resolveExecutable('npm');if(!_0x439ab6)return'';const _0x531da3=run(_0x439ab6,[_0x41388d(0xbb),'-g']);if(_0x531da3['status']!==0x0)return'';return String(_0x531da3[_0x41388d(0xec)]||'')[_0x41388d(0xe0)]();}function compareSemver(_0x3085b1,_0x23c048){const _0x21bc3c=a0_0x49a098,_0x3f26d6=String(_0x3085b1||'')['replace'](/^v/,'')['split'](/[.-]/)['map'](_0xe34f40=>Number['parseInt'](_0xe34f40,0xa)||0x0),_0x2f575b=String(_0x23c048||'')['replace'](/^v/,'')['split'](/[.-]/)['map'](_0x1e0163=>Number[_0x21bc3c(0xe5)](_0x1e0163,0xa)||0x0);for(let _0x47a854=0x0;_0x47a854<Math[_0x21bc3c(0xd3)](_0x3f26d6['length'],_0x2f575b[_0x21bc3c(0xb1)],0x3);_0x47a854++){const _0x23d47c=_0x3f26d6[_0x47a854]||0x0,_0x90f290=_0x2f575b[_0x47a854]||0x0;if(_0x23d47c>_0x90f290)return 0x1;if(_0x23d47c<_0x90f290)return-0x1;}return 0x0;}function resolveExecutable(_0x2770df){const _0xb52962=a0_0x49a098,_0x1aee16=process['platform']==='win32'?_0xb52962(0xf0):'which';try{const _0x515582=(0x0,import_child_process['spawnSync'])(_0x1aee16,[_0x2770df],{'encoding':'utf8','timeout':0xbb8,'shell':![]});if(_0x515582[_0xb52962(0xd9)]!==0x0)return'';return String(_0x515582[_0xb52962(0xec)]||'')['split'](/\r?\n/)[_0xb52962(0x101)](_0x369fea=>_0x369fea[_0xb52962(0xe0)]())['filter'](Boolean)[0x0]||'';}catch{return'';}}function skipWrapperUpdateCheck(){const _0xad77=a0_0x49a098,_0x569d46=String(process.env.WHALENT_SKIP_UPDATE_CHECK||process.env.WHALENT_NO_UPDATE_CHECK||process.env.WHALENT_SKIP_WRAPPER_UPDATE||'')[_0xad77(0xe0)]()['toLowerCase']();return _0x569d46==='1'||_0x569d46==='true'||_0x569d46===_0xad77(0xee)||_0x569d46==='on';}function latestWrapperVersion(){const _0x5b5ce4=a0_0x49a098,_0x538124=runNpmView([_0x5b5ce4(0xbc),WRAPPER_PKG_NAME+'@latest','version',_0x5b5ce4(0xda)+NPM_REGISTRY]);if(_0x538124['status']!==0x0)return'';return String(_0x538124[_0x5b5ce4(0xec)]||'')['trim']()[_0x5b5ce4(0xc2)](/\r?\n/)[_0x5b5ce4(0x10d)](Boolean)[_0x5b5ce4(0x117)]()||'';}function installWrapperVersion(_0x2dd4ee){const _0x232c83=a0_0x49a098,_0x2b80ec=resolveExecutable(_0x232c83(0x10b));if(!_0x2b80ec)return{'ok':![],'output':_0x232c83(0xe9)+'H'};const _0x528bfc=run(_0x2b80ec,[_0x232c83(0xce),'-g',WRAPPER_PKG_NAME+'@'+_0x2dd4ee,_0x232c83(0xda)+NPM_REGISTRY]),_0x34087b=((_0x528bfc[_0x232c83(0xec)]||'')+'\x0a'+(_0x528bfc['stderr']||''))[_0x232c83(0xe0)]();return{'ok':_0x528bfc['status']===0x0,'output':_0x34087b};}function maybeUpdateWrapper(_0x515ef6){const _0x56f77d=a0_0x49a098;if(skipWrapperUpdateCheck())return![];if(process.env.WHALENT_WRAPPER_UPDATE_ATTEMPTED)return![];const _0x16b2bd=latestWrapperVersion();if(!_0x16b2bd||compareSemver(_0x16b2bd,WRAPPER_VERSION)<=0x0)return![];console['warn'](_0x56f77d(0xb9)+'ilable:\x20'+WRAPPER_VERSION+'\x20->\x20'+_0x16b2bd),console[_0x56f77d(0x114)]('[wrapper]\x20installing'+'\x20'+WRAPPER_PKG_NAME+'@'+_0x16b2bd+(_0x56f77d(0xea)+_0x56f77d(0xfb)));const _0x36fa51=installWrapperVersion(_0x16b2bd);if(!_0x36fa51['ok']){console['warn']('[wrapper]\x20wrapper\x20up'+'date\x20failed;\x20continu'+'ing\x20with\x20'+WRAPPER_VERSION);if(_0x36fa51[_0x56f77d(0xfd)])console[_0x56f77d(0x114)](_0x36fa51['output'][_0x56f77d(0xc2)](/\r?\n/)[_0x56f77d(0xb6)](-0xc)[_0x56f77d(0x115)]('\x0a'));return console[_0x56f77d(0x114)]('[wrapper]\x20Manual\x20upd'+'ate:\x20npm\x20install\x20-g\x20'+WRAPPER_PKG_NAME+'@'+_0x16b2bd+_0x56f77d(0x111)+NPM_REGISTRY),![];}console[_0x56f77d(0x114)]('[wrapper]\x20wrapper\x20up'+'dated\x20to\x20'+_0x16b2bd+';\x20restarting\x20wrapper');const _0x517196=process[_0x56f77d(0xae)][0x1],_0x4f916e=(0x0,import_child_process[_0x56f77d(0xdc)])(process['execPath'],[_0x517196,..._0x515ef6],{'stdio':_0x56f77d(0xa3),'env':{...process.env,'WHALENT_WRAPPER_UPDATE_ATTEMPTED':_0x16b2bd},'shell':![]});process['exit'](_0x4f916e['status']??0x0);}function findCoreScript(){const _0x24b5f7=a0_0x49a098,_0x42b289=String(process.env.WHALENT_CORE_ENTRY||'')['trim'](),_0x575b42=['1',_0x24b5f7(0x104),_0x24b5f7(0xee),'on']['includes'](String(process.env.WHALENT_FORCE_CORE_ENTRY||'')[_0x24b5f7(0xe0)]()[_0x24b5f7(0xca)]());if(_0x42b289&&_0x575b42&&fs[_0x24b5f7(0xb4)](_0x42b289))return _0x42b289;const _0x35fe3e=[],_0x50e369=_0x1ca7f6=>{const _0x32e083=_0x24b5f7;if(fs['existsSync'](_0x1ca7f6)&&!_0x35fe3e['includes'](_0x1ca7f6))_0x35fe3e[_0x32e083(0xa5)](_0x1ca7f6);};if(_0x42b289)_0x50e369(_0x42b289);const _0x48f3a1=npmRootGlobal();if(_0x48f3a1){const _0x5160bd=path['join'](_0x48f3a1,_0x24b5f7(0xc7),_0x24b5f7(0xa7),'dist','index.cjs');_0x50e369(_0x5160bd);}const _0x484b5e=path['join'](wrapperBaseDir(),_0x24b5f7(0xd6));_0x50e369(_0x484b5e);const _0x412d0c=path['join'](wrapperBaseDir(),'..','packages','core','dist',_0x24b5f7(0xf4));_0x50e369(_0x412d0c);if(_0x35fe3e[_0x24b5f7(0xb1)]>0x0)return _0x35fe3e[_0x24b5f7(0x101)]((_0x284915,_0x68e15b)=>({'candidate':_0x284915,'index':_0x68e15b,'version':coreVersion(_0x284915)}))['sort']((_0x5e420e,_0x915b87)=>{const _0x2c6b0e=_0x24b5f7,_0xa3159a=compareSemver(_0x915b87['version'],_0x5e420e[_0x2c6b0e(0xb7)]);if(_0xa3159a!==0x0)return _0xa3159a;return _0x915b87[_0x2c6b0e(0xc8)]-_0x5e420e['index'];})[0x0][_0x24b5f7(0xa9)];throw new Error(_0x24b5f7(0xe1)+_0x24b5f7(0xe4)+_0x24b5f7(0x119)+'or\x20rebuild\x20@whalent/'+_0x24b5f7(0x10e));}function coreVersion(_0x32b21a=findCoreScript()){const _0x440789=a0_0x49a098,_0x27b318=(0x0,import_child_process['spawnSync'])(process[_0x440789(0xac)],[_0x32b21a,_0x440789(0xbe)],{'encoding':'utf8','timeout':0x3a98,'env':{...process.env,'WHALENT_SKIP_UPDATE_CHECK':'1'},'shell':![]}),_0x5b8665=(_0x27b318['stdout']||'')+'\x0a'+(_0x27b318[_0x440789(0x103)]||'');return _0x5b8665['match'](/(\d+\.\d+\.\d+(?:[-\w.]+)?)/)?.[0x1]||'';}function isExecutable(_0x3e3904){const _0x2843fb=a0_0x49a098;try{return fs['accessSync'](_0x3e3904,fs[_0x2843fb(0x112)]['X_OK']),!![];}catch{return![];}}function shellQuote(_0x229b05){const _0x446185=a0_0x49a098;return'\x27'+_0x229b05[_0x446185(0xb0)](/'/g,'\x27\x5c\x27\x27')+'\x27';}function coreNodePtySpawnHelperPath(_0x37d60b){const _0x4eac74=a0_0x49a098;if(process[_0x4eac74(0xc4)]!=='darwin')return'';try{const _0x5c3e6c=(0x0,import_module[_0x4eac74(0xa4)])(_0x37d60b),_0x565546=_0x5c3e6c['resolve'](_0x4eac74(0xdf)),_0x5d9f29=path['resolve'](path[_0x4eac74(0xa2)](_0x565546),'..');return path[_0x4eac74(0x115)](_0x5d9f29,'prebuilds','darwin-'+process[_0x4eac74(0x113)],_0x4eac74(0xcf));}catch{return'';}}function checkMacNodePtySpawnHelper(_0x594510){const _0x144c0a=a0_0x49a098,_0x189266=coreNodePtySpawnHelperPath(_0x594510);if(!_0x189266||CHECKED_PTY_HELPERS['has'](_0x189266))return;CHECKED_PTY_HELPERS['add'](_0x189266);if(!fs['existsSync'](_0x189266)){console[_0x144c0a(0x114)]('[wrapper]\x20macOS\x20node'+_0x144c0a(0xe7)+_0x144c0a(0xaa)+_0x189266);return;}if(isExecutable(_0x189266))return;try{const _0x1cc14a=fs['statSync'](_0x189266)[_0x144c0a(0x107)];fs['chmodSync'](_0x189266,_0x1cc14a|0x1ed);}catch{}if(isExecutable(_0x189266)){console[_0x144c0a(0x114)]('[wrapper]\x20fixed\x20macO'+'S\x20node-pty\x20spawn-hel'+'per\x20executable\x20bit:\x20'+_0x189266);return;}console['warn']('[wrapper]\x20macOS\x20node'+_0x144c0a(0xb3)+'\x20not\x20executable:\x20'+_0x189266),console[_0x144c0a(0x114)]('[wrapper]\x20Run\x20this\x20o'+_0x144c0a(0xbd)+_0x144c0a(0xfc)),console['warn']('\x20\x20HELPER='+shellQuote(_0x189266)),console['warn']('\x20\x20ls\x20-l\x20\x22$HELPER\x22'),console['warn']('\x20\x20chmod\x20+x\x20\x22$HELPER\x22');}function printVersion(){const _0x505c3e=a0_0x49a098;let _0x31bfb1='';try{_0x31bfb1=coreVersion();}catch{}console['log'](_0x505c3e(0x109)+WRAPPER_VERSION),console['log'](_0x505c3e(0xf9)+WRAPPER_VERSION),console['log'](_0x505c3e(0xc6)+(_0x31bfb1||'not\x20installed'));}function directCore(_0x2a044e){const _0x30bbd7=a0_0x49a098,_0x5bc320=findCoreScript();checkMacNodePtySpawnHelper(_0x5bc320);const _0x4f9539=(0x0,import_child_process[_0x30bbd7(0xdc)])(process[_0x30bbd7(0xac)],[_0x5bc320,..._0x2a044e],{'stdio':'inherit','env':{...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_CORE_ENTRY':_0x5bc320},'shell':![]});process['exit'](_0x4f9539[_0x30bbd7(0xd9)]??0x0);}function shouldSupervise(_0x4ace43){const _0x5587eb=a0_0x49a098;if(_0x4ace43[_0x5587eb(0x108)](_0x5587eb(0xc0)))return![];const _0x36e09c=_0x4ace43[0x0]||'';if(_0x36e09c==='ls'||_0x36e09c==='status'||_0x36e09c==='ps')return![];if(_0x36e09c==='mcp'||_0x36e09c==='daemon-mcp')return![];if(_0x4ace43['includes']('--help')||_0x4ace43['includes']('-h'))return![];return!![];}function installCoreVersion(_0x1574d7){const _0x5960c3=a0_0x49a098,_0x699472=resolveExecutable('npm');if(!_0x699472)return{'ok':![],'output':'npm\x20not\x20found\x20on\x20PAT'+'H'};const _0x432948=CORE_PKG_NAME+'@'+_0x1574d7,_0x59db53=run(_0x699472,[_0x5960c3(0xce),'-g',_0x432948,_0x5960c3(0xda)+NPM_REGISTRY]),_0x4744de=((_0x59db53['stdout']||'')+'\x0a'+(_0x59db53['stderr']||''))[_0x5960c3(0xe0)]();return{'ok':_0x59db53['status']===0x0,'output':_0x4744de};}async function superviseCore(_0x48581a){const _0x3d8ad7=a0_0x49a098;let _0x26db45=![],_0x5eee37=null;const _0x51fa7b=()=>{const _0x1d620d=a0_0x169a;_0x26db45=!![];if(_0x5eee37&&!_0x5eee37[_0x1d620d(0xc1)])try{_0x5eee37[_0x1d620d(0xc9)]('SIGTERM');}catch{}else process[_0x1d620d(0xe2)](0x0);};process['on'](_0x3d8ad7(0xe3),_0x51fa7b),process['on']('SIGTERM',_0x51fa7b);while(!![]){const _0x38bde6=findCoreScript();checkMacNodePtySpawnHelper(_0x38bde6);const _0x13a082={...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_WRAPPER_MANAGED':'1','WHALENT_CORE_ENTRY':_0x38bde6},_0x5a635c=readUpgradeState(),_0x36c419=!!_0x5a635c?.['pending'];let _0x564f5d=![],_0x1a470c=null;console[_0x3d8ad7(0xc3)]('[wrapper]\x20starting\x20c'+'ore:\x20'+_0x38bde6),_0x5eee37=(0x0,import_child_process['spawn'])(process[_0x3d8ad7(0xac)],[_0x38bde6,..._0x48581a],{'env':_0x13a082,'stdio':[_0x3d8ad7(0xa3),_0x3d8ad7(0xab),'pipe']});const _0x3e7704=()=>{const _0x1bd998=_0x3d8ad7;if(_0x564f5d)return;_0x564f5d=!![];if(_0x1a470c)clearTimeout(_0x1a470c);const _0x19c5dd=readUpgradeState();_0x19c5dd?.[_0x1bd998(0xb2)]&&(writeUpgradeState({..._0x19c5dd,'pending':![],'rollback':![],'health_status':'healthy'}),console[_0x1bd998(0xc3)]('[wrapper]\x20core\x20upgra'+'de\x20healthy:\x20'+(_0x19c5dd['installed_version']||_0x19c5dd[_0x1bd998(0xf1)]||'')));},_0x4becb5=(_0x35bb63,_0x499a72=![])=>{const _0x234756=_0x3d8ad7,_0x188c9b=_0x35bb63[_0x234756(0xe6)]();(_0x499a72?process['stderr']:process[_0x234756(0xec)])['write'](_0x188c9b),(_0x188c9b['includes']('[gateway]\x20Connected')||_0x188c9b[_0x234756(0x108)](_0x234756(0xb5)+_0x234756(0xf5))||_0x188c9b[_0x234756(0x108)]('Gateway:\x20connected'))&&_0x3e7704();};_0x5eee37['stdout']?.['on']('data',_0x26ea9a=>_0x4becb5(_0x26ea9a,![])),_0x5eee37['stderr']?.['on'](_0x3d8ad7(0xef),_0x7695b5=>_0x4becb5(_0x7695b5,!![]));_0x36c419&&(_0x1a470c=setTimeout(()=>{const _0x41fb2a=_0x3d8ad7;if(_0x564f5d||!_0x5eee37||_0x5eee37['killed'])return;console[_0x41fb2a(0xbf)](_0x41fb2a(0xa8)+'id\x20not\x20become\x20health'+_0x41fb2a(0x105)+'ack');try{_0x5eee37['kill']('SIGTERM');}catch{}},HEALTH_TIMEOUT_MS));const _0xf3776a=await new Promise(_0x3c9d00=>{const _0x109e79=_0x3d8ad7;_0x5eee37['once'](_0x109e79(0xe2),(_0x4acf2f,_0x3db4cc)=>_0x3c9d00({'code':_0x4acf2f,'signal':_0x3db4cc}));});if(_0x1a470c)clearTimeout(_0x1a470c);_0x5eee37=null;if(_0x26db45)process['exit'](_0xf3776a['code']??0x0);const _0x495850=readUpgradeState();if(_0x495850?.['pending']&&!_0x564f5d){const _0xc680a3=String(_0x495850[_0x3d8ad7(0x10f)+'n']||'')[_0x3d8ad7(0xe0)]();if(_0xc680a3){console[_0x3d8ad7(0xbf)](_0x3d8ad7(0xc5)+_0x3d8ad7(0x116)+_0xc680a3);const _0x3aa86d=installCoreVersion(_0xc680a3);writeUpgradeState({..._0x495850,'pending':![],'rollback':!![],'health_status':_0x3aa86d['ok']?'rolled_back':'rollback_failed','error':_0x3aa86d['ok']?'':_0x3aa86d['output']});}else writeUpgradeState({..._0x495850,'pending':![],'rollback':!![],'health_status':_0x3d8ad7(0x10c),'error':_0x3d8ad7(0xe8)+'n\x20unknown'});}const _0x50ff04=_0xf3776a[_0x3d8ad7(0xd0)]===SUPERVISED_RESTART_CODE||_0x495850?.[_0x3d8ad7(0xb2)];if(!_0x50ff04&&_0xf3776a[_0x3d8ad7(0xd0)]===0x0)process['exit'](0x0);console[_0x3d8ad7(0xc3)]('[wrapper]\x20core\x20exite'+_0x3d8ad7(0xd4)+(_0xf3776a[_0x3d8ad7(0xd0)]??'')+(_0xf3776a[_0x3d8ad7(0xd8)]?'\x20signal='+_0xf3776a[_0x3d8ad7(0xd8)]:'')+_0x3d8ad7(0xd2)+RESTART_DELAY_MS+'ms'),await new Promise(_0x1b8d9a=>setTimeout(_0x1b8d9a,RESTART_DELAY_MS));}}async function main(){const _0xd27603=a0_0x49a098,_0x15d0ab=process[_0xd27603(0xae)]['slice'](0x2);if(_0x15d0ab[0x0]==='--version'||_0x15d0ab[0x0]==='-v'||_0x15d0ab[0x0]==='version'){printVersion();return;}if((_0x15d0ab[0x0]==='status'||_0x15d0ab[0x0]==='ls'||_0x15d0ab[0x0]==='ps')&&!_0x15d0ab['includes'](_0xd27603(0xf2))){console['log'](_0xd27603(0xf9)+WRAPPER_VERSION);try{console['log']('core\x20'+(coreVersion()||'not\x20installed'));}catch{console[_0xd27603(0xc3)]('core\x20not\x20installed');}}maybeUpdateWrapper(_0x15d0ab);if(!shouldSupervise(_0x15d0ab))directCore(_0x15d0ab);await superviseCore(_0x15d0ab);}main()['catch'](_0x24e1e2=>{const _0x1dfcec=a0_0x49a098;console['error']('[wrapper]\x20Fatal\x20erro'+_0x1dfcec(0xdd)+(_0x24e1e2?.[_0x1dfcec(0xa0)]||String(_0x24e1e2))),process['exit'](0x1);});
|
|
2
|
+
'use strict';const a0_0x11b559=a0_0x21e3;(function(_0xc1a60,_0xde4ae7){const _0x579953=a0_0x21e3,_0x124533=_0xc1a60();while(!![]){try{const _0xe20c3e=-parseInt(_0x579953(0xcc))/0x1*(parseInt(_0x579953(0xc9))/0x2)+-parseInt(_0x579953(0x110))/0x3+-parseInt(_0x579953(0xd4))/0x4*(parseInt(_0x579953(0xe9))/0x5)+-parseInt(_0x579953(0xdb))/0x6+parseInt(_0x579953(0x13e))/0x7+parseInt(_0x579953(0xf4))/0x8+parseInt(_0x579953(0x138))/0x9*(parseInt(_0x579953(0xd0))/0xa);if(_0xe20c3e===_0xde4ae7)break;else _0x124533['push'](_0x124533['shift']());}catch(_0x5ed736){_0x124533['push'](_0x124533['shift']());}}}(a0_0x3ad5,0x81236));var __create=Object[a0_0x11b559(0x11a)],__defProp=Object['defineProperty'],__getOwnPropDesc=Object['getOwnPropertyDescri'+a0_0x11b559(0x128)],__getOwnPropNames=Object['getOwnPropertyNames'],__getProtoOf=Object[a0_0x11b559(0x132)],__hasOwnProp=Object['prototype']['hasOwnProperty'],__copyProps=(_0xd66e6,_0xac4c23,_0x5ae352,_0x229e8b)=>{const _0x1ed969=a0_0x11b559;if(_0xac4c23&&typeof _0xac4c23===_0x1ed969(0x12c)||typeof _0xac4c23==='function'){for(let _0x5a4b30 of __getOwnPropNames(_0xac4c23))if(!__hasOwnProp[_0x1ed969(0x13b)](_0xd66e6,_0x5a4b30)&&_0x5a4b30!==_0x5ae352)__defProp(_0xd66e6,_0x5a4b30,{'get':()=>_0xac4c23[_0x5a4b30],'enumerable':!(_0x229e8b=__getOwnPropDesc(_0xac4c23,_0x5a4b30))||_0x229e8b['enumerable']});}return _0xd66e6;},__toESM=(_0x2f1abb,_0x190699,_0xe5d249)=>(_0xe5d249=_0x2f1abb!=null?__create(__getProtoOf(_0x2f1abb)):{},__copyProps(_0x190699||!_0x2f1abb||!_0x2f1abb[a0_0x11b559(0xf1)]?__defProp(_0xe5d249,a0_0x11b559(0x115),{'value':_0x2f1abb,'enumerable':!![]}):_0xe5d249,_0x2f1abb)),import_child_process=require('child_process'),fs=__toESM(require('fs'),0x1),import_module=require('module'),os=__toESM(require('os'),0x1),path=__toESM(require('path'),0x1),WRAPPER_PKG_NAME=a0_0x11b559(0x102),CORE_PKG_NAME=a0_0x11b559(0x119),NPM_REGISTRY='https://registry.npm'+a0_0x11b559(0xf2),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 _0xb8650c=a0_0x11b559;return path[_0xb8650c(0xe6)](os['homedir'](),'.whalent-agent');}function upgradeStatePath(){const _0x17a78c=a0_0x11b559;return path[_0x17a78c(0xe6)](configDir(),'core-upgrade.json');}function readWrapperVersion(){const _0x1368c5=a0_0x11b559;try{const _0x3e72ff=JSON[_0x1368c5(0xe7)](fs[_0x1368c5(0x133)](path['join'](wrapperBaseDir(),'..','package.json'),_0x1368c5(0x106)));return String(_0x3e72ff[_0x1368c5(0xd8)]||_0x1368c5(0xeb));}catch{return _0x1368c5(0xeb);}}function readUpgradeState(){try{return JSON['parse'](fs['readFileSync'](upgradeStatePath(),'utf-8'));}catch{return null;}}function a0_0x21e3(_0x1f430d,_0x2f9df2){_0x1f430d=_0x1f430d-0xc8;const _0x3ad542=a0_0x3ad5();let _0x21e38f=_0x3ad542[_0x1f430d];if(a0_0x21e3['GfGULp']===undefined){var _0x31b96d=function(_0x2f0097){const _0x17f55a='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0xd66e6='',_0xac4c23='';for(let _0x5ae352=0x0,_0x229e8b,_0x5a4b30,_0x2f1abb=0x0;_0x5a4b30=_0x2f0097['charAt'](_0x2f1abb++);~_0x5a4b30&&(_0x229e8b=_0x5ae352%0x4?_0x229e8b*0x40+_0x5a4b30:_0x5a4b30,_0x5ae352++%0x4)?_0xd66e6+=String['fromCharCode'](0xff&_0x229e8b>>(-0x2*_0x5ae352&0x6)):0x0){_0x5a4b30=_0x17f55a['indexOf'](_0x5a4b30);}for(let _0x190699=0x0,_0xe5d249=_0xd66e6['length'];_0x190699<_0xe5d249;_0x190699++){_0xac4c23+='%'+('00'+_0xd66e6['charCodeAt'](_0x190699)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0xac4c23);};a0_0x21e3['ujEgrB']=_0x31b96d,a0_0x21e3['NSfbcb']={},a0_0x21e3['GfGULp']=!![];}const _0x2518f7=_0x3ad542[0x0],_0x2fc59b=_0x1f430d+_0x2518f7,_0x461e75=a0_0x21e3['NSfbcb'][_0x2fc59b];return!_0x461e75?(_0x21e38f=a0_0x21e3['ujEgrB'](_0x21e38f),a0_0x21e3['NSfbcb'][_0x2fc59b]=_0x21e38f):_0x21e38f=_0x461e75,_0x21e38f;}function writeUpgradeState(_0x5b092a){const _0x4ff7b2=a0_0x11b559;try{fs[_0x4ff7b2(0x144)](configDir(),{'recursive':!![]}),fs['writeFileSync'](upgradeStatePath(),JSON['stringify']({..._0x5b092a,'updated_at':Date['now']()},null,0x2),'utf-8');}catch{}}function run(_0x2f987b,_0x30ee45,_0x2e3a06=process.env){const _0xabfe35=a0_0x11b559;return(0x0,import_child_process[_0xabfe35(0x113)])(_0x2f987b,_0x30ee45,{'encoding':'utf8','timeout':NPM_INSTALL_TIMEOUT_MS,'maxBuffer':NPM_INSTALL_MAX_BUFFER,'env':_0x2e3a06,'shell':![]});}function runNpmView(_0x51b3a9){const _0x50be92=a0_0x11b559,_0x2d7edf=resolveExecutable(_0x50be92(0x12a));if(!_0x2d7edf)return{'status':0x7f,'stdout':'','stderr':_0x50be92(0x13f),'error':new Error(_0x50be92(0x13f))};return(0x0,import_child_process[_0x50be92(0x113)])(_0x2d7edf,_0x51b3a9,{'encoding':'utf8','timeout':NPM_VIEW_TIMEOUT_MS,'maxBuffer':0x400*0x400,'env':process.env,'shell':![]});}function npmRootGlobal(){const _0x36e465=a0_0x11b559,_0x38df14=resolveExecutable(_0x36e465(0x12a));if(!_0x38df14)return'';const _0x244057=run(_0x38df14,[_0x36e465(0xe5),'-g']);if(_0x244057[_0x36e465(0xe8)]!==0x0)return'';return String(_0x244057[_0x36e465(0xf5)]||'')[_0x36e465(0x135)]();}function compareSemver(_0x387918,_0x26c421){const _0x1251a7=a0_0x11b559,_0x400ffc=String(_0x387918||'')[_0x1251a7(0x117)](/^v/,'')['split'](/[.-]/)['map'](_0x431365=>Number['parseInt'](_0x431365,0xa)||0x0),_0x5aec6d=String(_0x26c421||'')[_0x1251a7(0x117)](/^v/,'')['split'](/[.-]/)['map'](_0x4325d7=>Number['parseInt'](_0x4325d7,0xa)||0x0);for(let _0x1c0b03=0x0;_0x1c0b03<Math['max'](_0x400ffc['length'],_0x5aec6d[_0x1251a7(0xc8)],0x3);_0x1c0b03++){const _0x618dba=_0x400ffc[_0x1c0b03]||0x0,_0x408915=_0x5aec6d[_0x1c0b03]||0x0;if(_0x618dba>_0x408915)return 0x1;if(_0x618dba<_0x408915)return-0x1;}return 0x0;}function resolveExecutable(_0x314323){const _0x50a5f5=a0_0x11b559,_0x4342de=process['platform']==='win32'?_0x50a5f5(0xf8):'which';try{const _0x5212f6=(0x0,import_child_process['spawnSync'])(_0x4342de,[_0x314323],{'encoding':_0x50a5f5(0x10f),'timeout':0xbb8,'shell':![]});if(_0x5212f6[_0x50a5f5(0xe8)]!==0x0)return'';return String(_0x5212f6['stdout']||'')['split'](/\r?\n/)[_0x50a5f5(0x139)](_0x4bbc3a=>_0x4bbc3a['trim']())['filter'](Boolean)[0x0]||'';}catch{return'';}}function skipWrapperUpdateCheck(){const _0x3b1aee=a0_0x11b559,_0x5c6c05=String(process.env.WHALENT_SKIP_UPDATE_CHECK||process.env.WHALENT_NO_UPDATE_CHECK||process.env.WHALENT_SKIP_WRAPPER_UPDATE||'')[_0x3b1aee(0x135)]()[_0x3b1aee(0xef)]();return _0x5c6c05==='1'||_0x5c6c05==='true'||_0x5c6c05==='yes'||_0x5c6c05==='on';}function a0_0x3ad5(){const _0x39685a=['zMLSDgvY','w3DYyxbWzxjDig5LDYbJB3jLigq','ls1YzwDPC3rYEt0','C2LNBMfS','w3DYyxbWzxjDigLUC3rHBgXPBMC','CM9VDa','AM9PBG','CgfYC2u','C3rHDhvZ','ndeZnurqsvL2Ba','ywnOAw5L','mc4WlJa','BMnLihrVigzPEcb0zxjTAw5HBc8','w3DYyxbWzxjDihjVBgXPBMCGyMe','w2DHDgv3yxLDienVBM5Ly3rLza','Dg9mB3DLCKnHC2u','CgfJA2fNzxm','x19LC01VzhvSzq','ANmUB3jN','ywnR','mJG4mJGWDMHfwwD5','C3rKB3v0','zxHPC3rZu3LUyW','ChjLDMLVDxmGy29Yzsb2zxjZAw8','D2HLCMuUzxHL','Dg9tDhjPBMC','ls12zxjZAw9U','CgLWzq','Dhj1zq','ChvZAa','y29Yzs5JANm','y29Kzq','qgXHDgvZDa','Aw5JBhvKzxm','qhDOywXLBNqVywDLBNq','zgfYD2LU','zguGAgvHBhrOEtOG','B25Jzq','DxrMltG','BwnW','ChjLDMLVDxnFy29Yzv92zxjZAw8','B3v0Chv0','BM90igLUC3rHBgXLza','C3bSAxq','Cg9W','wf9psW','ls1QC29U','DxrMoa','nJm5mJCWA3zfugDM','y29UC3rHBNrZ','Aw5OzxjPDa','C3bHD25tEw5J','AgvHBhrOEq','zgvMyxvSDa','C2XPy2u','CMvWBgfJzq','CM9SBgjHy2TFDw5HDMfPBgfIBgu','qhDOywXLBNqVywDLBNqTy29Yzq','y3jLyxrL','D3jHChbLCIa','AwqGBM90igjLy29TzsbOzwfSDgG','DMLLDW','ihnPz25HBd0','zgf0yq','CgXHDgzVCM0','icbJAg1VzcaREcaIjeHftfbfuIi','w3DYyxbWzxjDignVCMuGDxbNCMe','y29Yzq','C3rKzxjY','w3DYyxbWzxjDihn0yxj0Aw5Nigm','zxHLy1bHDgG','Aw5ZDgfSBa','ChrVCG','CNrPBMCGy29Yzs4UlG','BNbT','ufrzihn0yxj0Dxa6','B2jQzwn0','y2fUzgLKyxrL','EwvZ','ywDLBNqTy29Yzq','D2fYBG','zcbJB2rLpq','z2v0uhjVDg90ExbLt2y','CMvHzezPBgvtEw5J','CgvUzgLUzW','DhjPBq','BIb1BMTUB3DU','zxHPDa','otLVC21LB2K','BwfW','zgfYD2LUlq','y2fSBa','D2HHBgvUDc1Hz2vUDca','ChjLyNvPBgrZ','ntG2nty4nvzttevLDa','BNbTig5VDcbMB3vUza','w3DYyxbWzxjDifj1BIb0AgLZig8','u0Lhvevstq','y2HTB2rtEw5J','lxb0EsbZCgf3BI1OzwXWzxiGAxm','BwTKAxjtEw5J','BNbTig5VDcbMB3vUzcbVBIbqqvq','BgvUz3rO','nZzxDg9gv3O','qhDOywXLBNq','icbiruXqrvi9','odG2m3D6rgrwuW','y29Yzsa','ig5VDcbMB3vUzdSGAw5ZDgfSBca','w3DYyxbWzxjDie1HBNvHBcb1Cgq','nZm3ndeWyKnhtgLe','B3jLoIa','Bwf0y2G','BM9Kzs1WDhK','ndbHwuLyAg0','w3DYyxbWzxjDihDYyxbWzxiGDxa','zxjYB3i','ls1OzwXW','DMvYC2LVBG','ic0TCMvNAxn0CNK9','Bg9N','mZu4odiYmLzlBuP1Ba','qhDOywXLBNqVywDLBNqTy29Yzsa','r2f0zxDHEsbYzwDPC3rLCMvKig0','yxjNDG','yxjJAa'];a0_0x3ad5=function(){return _0x39685a;};return a0_0x3ad5();}function latestWrapperVersion(){const _0x2edafb=a0_0x11b559,_0x3b222c=runNpmView([_0x2edafb(0x11d),WRAPPER_PKG_NAME+_0x2edafb(0x100),_0x2edafb(0xd8),_0x2edafb(0xe2)+NPM_REGISTRY]);if(_0x3b222c[_0x2edafb(0xe8)]!==0x0)return'';return String(_0x3b222c['stdout']||'')['trim']()[_0x2edafb(0x10b)](/\r?\n/)[_0x2edafb(0xe0)](Boolean)[_0x2edafb(0x10c)]()||'';}function installWrapperVersion(_0x1c3eba){const _0x3b0bdf=a0_0x11b559,_0x4a58f0=resolveExecutable(_0x3b0bdf(0x12a));if(!_0x4a58f0)return{'ok':![],'output':_0x3b0bdf(0x145)+'H'};const _0x1cd796=run(_0x4a58f0,[_0x3b0bdf(0x127),'-g',WRAPPER_PKG_NAME+'@'+_0x1c3eba,_0x3b0bdf(0xe2)+NPM_REGISTRY]),_0x28537d=((_0x1cd796['stdout']||'')+'\x0a'+(_0x1cd796[_0x3b0bdf(0x124)]||''))[_0x3b0bdf(0x135)]();return{'ok':_0x1cd796[_0x3b0bdf(0xe8)]===0x0,'output':_0x28537d};}function maybeUpdateWrapper(_0x2c0c41){const _0x47d182=a0_0x11b559;if(skipWrapperUpdateCheck())return![];if(process.env.WHALENT_WRAPPER_UPDATE_ATTEMPTED)return![];const _0x5196c4=latestWrapperVersion();if(!_0x5196c4||compareSemver(_0x5196c4,WRAPPER_VERSION)<=0x0)return![];console[_0x47d182(0x130)]('[wrapper]\x20update\x20ava'+'ilable:\x20'+WRAPPER_VERSION+'\x20->\x20'+_0x5196c4),console[_0x47d182(0x130)](_0x47d182(0xe4)+'\x20'+WRAPPER_PKG_NAME+'@'+_0x5196c4+('\x20from\x20npm\x20before\x20sta'+_0x47d182(0x129)));const _0x439bbb=installWrapperVersion(_0x5196c4);if(!_0x439bbb['ok']){console['warn']('[wrapper]\x20wrapper\x20up'+'date\x20failed;\x20continu'+'ing\x20with\x20'+WRAPPER_VERSION);if(_0x439bbb[_0x47d182(0x109)])console['warn'](_0x439bbb['output']['split'](/\r?\n/)[_0x47d182(0x116)](-0xc)[_0x47d182(0xe6)]('\x0a'));return console[_0x47d182(0x130)](_0x47d182(0xcf)+'ate:\x20npm\x20install\x20-g\x20'+WRAPPER_PKG_NAME+'@'+_0x5196c4+_0x47d182(0xd9)+NPM_REGISTRY),![];}console[_0x47d182(0x130)](_0x47d182(0xd5)+'dated\x20to\x20'+_0x5196c4+';\x20restarting\x20wrapper');const _0x3a1b91=process['argv'][0x1],_0x275c31=(0x0,import_child_process['spawnSync'])(process[_0x47d182(0x126)],[_0x3a1b91,..._0x2c0c41],{'stdio':'inherit','env':{...process.env,'WHALENT_WRAPPER_UPDATE_ATTEMPTED':_0x5196c4},'shell':![]});process[_0x47d182(0x137)](_0x275c31['status']??0x0);}function findCoreScript(){const _0x3195f1=a0_0x11b559,_0x1e7fa8=String(process.env.WHALENT_CORE_ENTRY||'')[_0x3195f1(0x135)](),_0x5d8ae2=['1',_0x3195f1(0xfc),_0x3195f1(0x12e),'on']['includes'](String(process.env.WHALENT_FORCE_CORE_ENTRY||'')[_0x3195f1(0x135)]()['toLowerCase']());if(_0x1e7fa8&&_0x5d8ae2&&fs['existsSync'](_0x1e7fa8))return _0x1e7fa8;const _0x5a0740=[],_0xd786a5=_0x3ceeae=>{const _0x34281b=_0x3195f1;if(fs[_0x34281b(0xf6)](_0x3ceeae)&&!_0x5a0740[_0x34281b(0x101)](_0x3ceeae))_0x5a0740[_0x34281b(0xfd)](_0x3ceeae);};if(_0x1e7fa8)_0xd786a5(_0x1e7fa8);const _0x2a1706=npmRootGlobal();if(_0x2a1706){const _0xc90df5=path[_0x3195f1(0xe6)](_0x2a1706,_0x3195f1(0xca),_0x3195f1(0x12f),'dist','index.cjs');_0xd786a5(_0xc90df5);}const _0x33d0db=path['join'](wrapperBaseDir(),_0x3195f1(0xfe));_0xd786a5(_0x33d0db);const _0x2d9156=path['join'](wrapperBaseDir(),'..',_0x3195f1(0xf0),_0x3195f1(0x123),'dist','index.cjs');_0xd786a5(_0x2d9156);if(_0x5a0740[_0x3195f1(0xc8)]>0x0)return _0x5a0740[_0x3195f1(0x139)]((_0x35890c,_0x51a795)=>({'candidate':_0x35890c,'index':_0x51a795,'version':coreVersion(_0x35890c)}))['sort']((_0x42859f,_0x502e2c)=>{const _0x8183e4=compareSemver(_0x502e2c['version'],_0x42859f['version']);if(_0x8183e4!==0x0)return _0x8183e4;return _0x502e2c['index']-_0x42859f['index'];})[0x0][_0x3195f1(0x12d)];throw new Error('whalent\x20core\x20runtime'+_0x3195f1(0xce)+_0x3195f1(0xdc)+'or\x20rebuild\x20@whalent/'+'agent');}function coreVersion(_0x438467=findCoreScript()){const _0x440b89=a0_0x11b559,_0x1e2c22=(0x0,import_child_process[_0x440b89(0x113)])(process['execPath'],[_0x438467,'--version'],{'encoding':_0x440b89(0x10f),'timeout':0x3a98,'env':{...process.env,'WHALENT_SKIP_UPDATE_CHECK':'1'},'shell':![]}),_0x974a57=(_0x1e2c22[_0x440b89(0xf5)]||'')+'\x0a'+(_0x1e2c22[_0x440b89(0x124)]||'');return _0x974a57[_0x440b89(0xd2)](/(\d+\.\d+\.\d+(?:[-\w.]+)?)/)?.[0x1]||'';}function isExecutable(_0x4f76fd){const _0x57a5ee=a0_0x11b559;try{return fs['accessSync'](_0x4f76fd,fs[_0x57a5ee(0x111)][_0x57a5ee(0x10d)]),!![];}catch{return![];}}function shellQuote(_0x4a4d3a){return'\x27'+_0x4a4d3a['replace'](/'/g,'\x27\x5c\x27\x27')+'\x27';}function coreNodePtySpawnHelperPath(_0x541e78){const _0x564c32=a0_0x11b559;if(process[_0x564c32(0x120)]!==_0x564c32(0x103))return'';try{const _0x42dcaf=(0x0,import_module['createRequire'])(_0x541e78),_0x4d7085=_0x42dcaf['resolve'](_0x564c32(0xd3)),_0x147979=path['resolve'](path['dirname'](_0x4d7085),'..');return path['join'](_0x147979,_0x564c32(0x13d),_0x564c32(0x13a)+process[_0x564c32(0xdf)],'spawn-helper');}catch{return'';}}function checkMacNodePtySpawnHelper(_0x435f7e){const _0x39bc55=a0_0x11b559,_0x14dd0e=coreNodePtySpawnHelperPath(_0x435f7e);if(!_0x14dd0e||CHECKED_PTY_HELPERS['has'](_0x14dd0e))return;CHECKED_PTY_HELPERS['add'](_0x14dd0e);if(!fs['existsSync'](_0x14dd0e)){console['warn']('[wrapper]\x20macOS\x20node'+'-pty\x20spawn-helper\x20no'+'t\x20found:\x20'+_0x14dd0e);return;}if(isExecutable(_0x14dd0e))return;try{const _0x488092=fs['statSync'](_0x14dd0e)['mode'];fs[_0x39bc55(0x142)](_0x14dd0e,_0x488092|0x1ed);}catch{}if(isExecutable(_0x14dd0e)){console[_0x39bc55(0x130)]('[wrapper]\x20fixed\x20macO'+'S\x20node-pty\x20spawn-hel'+'per\x20executable\x20bit:\x20'+_0x14dd0e);return;}console['warn']('[wrapper]\x20macOS\x20node'+_0x39bc55(0x143)+'\x20not\x20executable:\x20'+_0x14dd0e),console['warn'](_0x39bc55(0x140)+_0x39bc55(0xec)+_0x39bc55(0x12b)),console['warn'](_0x39bc55(0xcb)+shellQuote(_0x14dd0e)),console[_0x39bc55(0x130)]('\x20\x20ls\x20-l\x20\x22$HELPER\x22'),console[_0x39bc55(0x130)](_0x39bc55(0x121));}function printVersion(){const _0x571f8a=a0_0x11b559;let _0xfa27fe='';try{_0xfa27fe=coreVersion();}catch{}console[_0x571f8a(0xda)](_0x571f8a(0x13c)+WRAPPER_VERSION),console[_0x571f8a(0xda)](_0x571f8a(0x11b)+WRAPPER_VERSION),console[_0x571f8a(0xda)](_0x571f8a(0xcd)+(_0xfa27fe||_0x571f8a(0x10a)));}function directCore(_0x5a47f7){const _0x3e2af4=a0_0x11b559,_0x77a4eb=findCoreScript();checkMacNodePtySpawnHelper(_0x77a4eb);const _0x37adbd=(0x0,import_child_process[_0x3e2af4(0x113)])(process['execPath'],[_0x77a4eb,..._0x5a47f7],{'stdio':_0x3e2af4(0x112),'env':{...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_CORE_ENTRY':_0x77a4eb},'shell':![]});process[_0x3e2af4(0x137)](_0x37adbd['status']??0x0);}function shouldSupervise(_0x17292b){const _0x3e98c8=a0_0x11b559;if(_0x17292b[_0x3e98c8(0x101)]('--agent-id'))return![];const _0xbcc25=_0x17292b[0x0]||'';if(_0xbcc25==='ls'||_0xbcc25===_0x3e98c8(0xe8)||_0xbcc25==='ps')return![];if(_0xbcc25===_0x3e98c8(0x107)||_0xbcc25==='daemon-mcp')return![];if(_0x17292b['includes'](_0x3e98c8(0xd7))||_0x17292b[_0x3e98c8(0x101)]('-h'))return![];return!![];}function installCoreVersion(_0x28433a){const _0x59bfa2=a0_0x11b559,_0x4fc735=resolveExecutable(_0x59bfa2(0x12a));if(!_0x4fc735)return{'ok':![],'output':_0x59bfa2(0x145)+'H'};const _0x694bbe=CORE_PKG_NAME+'@'+_0x28433a,_0x5ebb49=run(_0x4fc735,[_0x59bfa2(0x127),'-g',_0x694bbe,_0x59bfa2(0xe2)+NPM_REGISTRY]),_0x1ea273=((_0x5ebb49[_0x59bfa2(0xf5)]||'')+'\x0a'+(_0x5ebb49[_0x59bfa2(0x124)]||''))['trim']();return{'ok':_0x5ebb49[_0x59bfa2(0xe8)]===0x0,'output':_0x1ea273};}async function superviseCore(_0x26f31e){const _0x4af9f0=a0_0x11b559;let _0x256760=![],_0x3f9c3b=null;const _0x5b478a=()=>{_0x256760=!![];if(_0x3f9c3b&&!_0x3f9c3b['killed'])try{_0x3f9c3b['kill']('SIGTERM');}catch{}else process['exit'](0x0);};process['on']('SIGINT',_0x5b478a),process['on'](_0x4af9f0(0x141),_0x5b478a);while(!![]){const _0x312d56=findCoreScript();checkMacNodePtySpawnHelper(_0x312d56);const _0x12cb3d={...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_WRAPPER_MANAGED':'1','WHALENT_CORE_ENTRY':_0x312d56},_0x4cc444=readUpgradeState(),_0x4f57c8=!!_0x4cc444?.[_0x4af9f0(0x134)];let _0x2fed78=![],_0x42732f=null;console[_0x4af9f0(0xda)](_0x4af9f0(0x125)+_0x4af9f0(0xd1)+_0x312d56),_0x3f9c3b=(0x0,import_child_process['spawn'])(process['execPath'],[_0x312d56,..._0x26f31e],{'env':_0x12cb3d,'stdio':['inherit','pipe',_0x4af9f0(0xfb)]});const _0x155745=()=>{const _0x537ee2=_0x4af9f0;if(_0x2fed78)return;_0x2fed78=!![];if(_0x42732f)clearTimeout(_0x42732f);const _0x503da7=readUpgradeState();_0x503da7?.[_0x537ee2(0x134)]&&(writeUpgradeState({..._0x503da7,'pending':![],'rollback':![],'health_status':_0x537ee2(0x114)}),console['log'](_0x537ee2(0x122)+_0x537ee2(0x104)+(_0x503da7['installed_version']||_0x503da7['target_version']||'')));},_0x28e496=(_0x3c34ab,_0x4fb13a=![])=>{const _0x270fde=_0x4af9f0,_0x5434ad=_0x3c34ab[_0x270fde(0xf9)]();(_0x4fb13a?process[_0x270fde(0x124)]:process[_0x270fde(0xf5)])['write'](_0x5434ad),(_0x5434ad['includes'](_0x270fde(0xee))||_0x5434ad[_0x270fde(0x101)](_0x270fde(0xdd)+_0x270fde(0xea))||_0x5434ad['includes']('Gateway:\x20connected'))&&_0x155745();};_0x3f9c3b[_0x4af9f0(0xf5)]?.['on'](_0x4af9f0(0x11f),_0x59ba6c=>_0x28e496(_0x59ba6c,![])),_0x3f9c3b[_0x4af9f0(0x124)]?.['on']('data',_0x5ea1f6=>_0x28e496(_0x5ea1f6,!![]));_0x4f57c8&&(_0x42732f=setTimeout(()=>{const _0x47af6a=_0x4af9f0;if(_0x2fed78||!_0x3f9c3b||_0x3f9c3b['killed'])return;console[_0x47af6a(0xd6)](_0x47af6a(0xe1)+_0x47af6a(0x11c)+'y\x20in\x20time;\x20rolling\x20b'+_0x47af6a(0xf3));try{_0x3f9c3b['kill']('SIGTERM');}catch{}},HEALTH_TIMEOUT_MS));const _0x59f82d=await new Promise(_0x4bcbdb=>{const _0x3134a4=_0x4af9f0;_0x3f9c3b[_0x3134a4(0x105)](_0x3134a4(0x137),(_0x53faeb,_0x592f78)=>_0x4bcbdb({'code':_0x53faeb,'signal':_0x592f78}));});if(_0x42732f)clearTimeout(_0x42732f);_0x3f9c3b=null;if(_0x256760)process[_0x4af9f0(0x137)](_0x59f82d[_0x4af9f0(0xff)]??0x0);const _0x2f0a50=readUpgradeState();if(_0x2f0a50?.[_0x4af9f0(0x134)]&&!_0x2fed78){const _0x4d720a=String(_0x2f0a50[_0x4af9f0(0x108)+'n']||'')[_0x4af9f0(0x135)]();if(_0x4d720a){console[_0x4af9f0(0xd6)](_0x4af9f0(0xed)+'ck\x20core\x20to\x20'+_0x4d720a);const _0xf85309=installCoreVersion(_0x4d720a);writeUpgradeState({..._0x2f0a50,'pending':![],'rollback':!![],'health_status':_0xf85309['ok']?'rolled_back':'rollback_failed','error':_0xf85309['ok']?'':_0xf85309[_0x4af9f0(0x109)]});}else writeUpgradeState({..._0x2f0a50,'pending':![],'rollback':!![],'health_status':_0x4af9f0(0x118),'error':_0x4af9f0(0xf7)+_0x4af9f0(0x136)});}const _0x103151=_0x59f82d['code']===SUPERVISED_RESTART_CODE||_0x2f0a50?.['pending'];if(!_0x103151&&_0x59f82d['code']===0x0)process[_0x4af9f0(0x137)](0x0);console[_0x4af9f0(0xda)]('[wrapper]\x20core\x20exite'+_0x4af9f0(0x131)+(_0x59f82d['code']??'')+(_0x59f82d[_0x4af9f0(0xe3)]?_0x4af9f0(0x11e)+_0x59f82d[_0x4af9f0(0xe3)]:'')+';\x20restarting\x20in\x20'+RESTART_DELAY_MS+'ms'),await new Promise(_0x35646a=>setTimeout(_0x35646a,RESTART_DELAY_MS));}}async function main(){const _0x1ef9df=a0_0x11b559,_0x45d52f=process[_0x1ef9df(0xde)][_0x1ef9df(0x116)](0x2);if(_0x45d52f[0x0]===_0x1ef9df(0xfa)||_0x45d52f[0x0]==='-v'||_0x45d52f[0x0]===_0x1ef9df(0xd8)){printVersion();return;}if((_0x45d52f[0x0]===_0x1ef9df(0xe8)||_0x45d52f[0x0]==='ls'||_0x45d52f[0x0]==='ps')&&!_0x45d52f[_0x1ef9df(0x101)](_0x1ef9df(0x10e))){console[_0x1ef9df(0xda)]('wrapper\x20'+WRAPPER_VERSION);try{console[_0x1ef9df(0xda)]('core\x20'+(coreVersion()||'not\x20installed'));}catch{console[_0x1ef9df(0xda)]('core\x20not\x20installed');}}maybeUpdateWrapper(_0x45d52f);if(!shouldSupervise(_0x45d52f))directCore(_0x45d52f);await superviseCore(_0x45d52f);}main()['catch'](_0x1196b8=>{console['error']('[wrapper]\x20Fatal\x20erro'+'r:\x20'+(_0x1196b8?.['message']||String(_0x1196b8))),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.52",
|
|
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.52"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/node": "^20.0.0",
|