@whalent/agent 0.3.49 → 0.3.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- 'use strict';const a0_0x13f168=a0_0x4409;(function(_0x200b42,_0x48116a){const _0x24e75b=a0_0x4409,_0x90a896=_0x200b42();while(!![]){try{const _0x4c5b76=-parseInt(_0x24e75b(0x162))/0x1+-parseInt(_0x24e75b(0x148))/0x2*(-parseInt(_0x24e75b(0x121))/0x3)+parseInt(_0x24e75b(0x131))/0x4+-parseInt(_0x24e75b(0x108))/0x5*(-parseInt(_0x24e75b(0x12d))/0x6)+-parseInt(_0x24e75b(0x159))/0x7*(-parseInt(_0x24e75b(0xfd))/0x8)+-parseInt(_0x24e75b(0x15d))/0x9*(-parseInt(_0x24e75b(0x101))/0xa)+-parseInt(_0x24e75b(0x150))/0xb*(parseInt(_0x24e75b(0x14b))/0xc);if(_0x4c5b76===_0x48116a)break;else _0x90a896['push'](_0x90a896['shift']());}catch(_0x5a0a51){_0x90a896['push'](_0x90a896['shift']());}}}(a0_0x3fce,0x5c039));var __create=Object['create'],__defProp=Object['defineProperty'],__getOwnPropDesc=Object['getOwnPropertyDescri'+a0_0x13f168(0x163)],__getOwnPropNames=Object[a0_0x13f168(0x11f)],__getProtoOf=Object[a0_0x13f168(0x14d)],__hasOwnProp=Object['prototype'][a0_0x13f168(0x149)],__copyProps=(_0x44eb06,_0x3549af,_0x5877a3,_0x40041e)=>{const _0x5c18d7=a0_0x13f168;if(_0x3549af&&typeof _0x3549af==='object'||typeof _0x3549af==='function'){for(let _0x9aa6a3 of __getOwnPropNames(_0x3549af))if(!__hasOwnProp[_0x5c18d7(0xee)](_0x44eb06,_0x9aa6a3)&&_0x9aa6a3!==_0x5877a3)__defProp(_0x44eb06,_0x9aa6a3,{'get':()=>_0x3549af[_0x9aa6a3],'enumerable':!(_0x40041e=__getOwnPropDesc(_0x3549af,_0x9aa6a3))||_0x40041e['enumerable']});}return _0x44eb06;},__toESM=(_0x5a0897,_0x25c8a3,_0x14e75c)=>(_0x14e75c=_0x5a0897!=null?__create(__getProtoOf(_0x5a0897)):{},__copyProps(_0x25c8a3||!_0x5a0897||!_0x5a0897['__esModule']?__defProp(_0x14e75c,'default',{'value':_0x5a0897,'enumerable':!![]}):_0x14e75c,_0x5a0897)),import_child_process=require('child_process'),fs=__toESM(require('fs'),0x1),import_module=require(a0_0x13f168(0x10a)),os=__toESM(require('os'),0x1),path=__toESM(require(a0_0x13f168(0x12f)),0x1),WRAPPER_PKG_NAME='@whalent/agent',CORE_PKG_NAME=a0_0x13f168(0xec),NPM_REGISTRY='https://registry.npm'+a0_0x13f168(0xe9),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(){return path['join'](os['homedir'](),'.whalent-agent');}function upgradeStatePath(){const _0x3da52f=a0_0x13f168;return path['join'](configDir(),_0x3da52f(0x109));}function a0_0x3fce(){const _0x10a580=['BNbT','DMvYC2LVBG','CMvHzezPBgvtEw5J','A2LSBgvK','j1WNjW','y29Yzs5JANm','ChjLDMLVDxnFy29Yzv92zxjZAw8','z2v0t3DUuhjVCgvYDhLoyw1LCW','D3jPDgu','mtuYnJeZrNfgEfvo','BM90igLUC3rHBgXLza','DcbMB3vUzdOG','D2LUmZi','ywDLBNq','CgvYigv4zwn1DgfIBguGyML0oIa','zgfYD2LUlq','D2fYBG','r2f0zxDHEsbYzwDPC3rLCMvKig0','zxHLy1bHDgG','D2HPy2G','Cg9W','mtyYz1zzAKvd','zgLYBMfTzq','Cgf0Aa','BM9Kzs1WDhK','mtK1mZq3nNjmshPREG','ufrzihn0yxj0Dxa6','w3DYyxbWzxjDig1Hy09tig5Vzgu','CMvZB2X2zq','BwTKAxjtEw5J','B3v0Chv0','A2LSBa','zgfYD2LU','y2HTB2rtEw5J','C3rHDhvZ','w3DYyxbWzxjDig5LDYbJB3jLigq','BM93','icbiruXqrvi9','DMLLDW','D3jHChbLCIa','C3rKB3v0','CJOG','ChvZAa','AgvHBhrOEq','zgf0yq','oYbYzxn0yxj0Aw5NigLUia','Dhj1zq','y2SGy29Yzsb0BYa','nNPxuenfqq','AgfZt3DUuhjVCgvYDhK','BNbTig5VDcbMB3vUza','mZyXnJmZmLbUrxPXyq','ig5VDcbMB3vUzdSGAw5ZDgfSBca','z2v0uhjVDg90ExbLt2y','icbSCYaTBcaIjeHftfbfuIi','BMnLihrVigzPEcb0zxjTAw5HBc8','mtfiBK9MzK8','ic0+ia','Aw5ZDgfSBa','Bwf0y2G','BwfW','BwnW','B3jLoIa','D2HHBgvUDcbJB3jLihj1BNrPBwu','wf9psW','nJq1nZaXELDhz2Xd','y29YzsbUB3qGAw5ZDgfSBgvK','y29Kzq','Dg9mB3DLCKnHC2u','mJu4nZC3ELvJC3HP','ChjLyNvPBgrZ','CMvWBgfJzq','CgfJA2fNzs5QC29U','AM9PBG','ntG0mta3D0fSuvjs','ChrVCG','CM9VDa','C3bHD24TAgvSCgvY','C3bHD25tEw5J','y2fUzgLKyxrL','w3DYyxbWzxjDihjVBgXPBMCGyMe','oYbYzxn0yxj0Aw5NihDYyxbWzxi','C3rKzxjY','C3bSAxq','u0Lhsu5u','ANmUB3jN','CgfYC2vjBNq','AwXHyMXLoIa','qhDOywXLBNqVywDLBNqTy29Yzq','CgfYC2u','y2fSBa','w3DYyxbWzxjDie1HBNvHBcb1Cgq','y29Yzq','zgf0zwqGDg8G','y29UC3rHBNrZ','ls1Hz2vUDc1Pza','DxrMltG','ChjLDMLVDxmGy29Yzsb2zxjZAw8','ls1OzwXW','CgXHDgzVCM0','CM9SBgjHy2TFzMfPBgvK','lxb0EsbZCgf3BI1OzwXWzxiGAxm','BgvUz3rO','Aw5KzxGUy2PZ','CgvUzgLUzW','ofr0Ce9zBa','C2XPy2u','C3rYAw5NAwz5','qgXHDgvZDa','nZb5EK5xru0','zgfLBw9Ulw1JCa','w3DYyxbWzxjDiezHDgfSigvYCM8','EwvZ','Bg9N','ls1YzwDPC3rYEt0','CgfJA2fNzxm','nJa3mtvesgPrtMK','y29Yzs11CgDYywrLlMPZB24','Bw9KDwXL','D2HLCMuUzxHL','zxHPDa','C2LNBMfS','Aw5OzxjPDa','igzYB20GBNbTigjLzM9YzsbZDge','zxHPC3rZu3LUyW','DxrMoa','ywnR','zxjYB3i','B3iGCMvIDwLSzcbaD2HHBgvUDc8','yxrLoIbUCg0GAw5ZDgfSBcaTzYa','Aw5JBhvKzxm','w3DYyxbWzxjDihvWzgf0zsbHDMe'];a0_0x3fce=function(){return _0x10a580;};return a0_0x3fce();}function readWrapperVersion(){const _0x4ed792=a0_0x13f168;try{const _0x1b397e=JSON[_0x4ed792(0xed)](fs[_0x4ed792(0x11a)](path[_0x4ed792(0x161)](wrapperBaseDir(),'..',_0x4ed792(0x160)),_0x4ed792(0xf4)));return String(_0x1b397e['version']||'0.0.0');}catch{return'0.0.0';}}function readUpgradeState(){const _0x2dca77=a0_0x13f168;try{return JSON['parse'](fs[_0x2dca77(0x11a)](upgradeStatePath(),_0x2dca77(0xf4)));}catch{return null;}}function writeUpgradeState(_0xc54a1d){const _0x680a63=a0_0x13f168;try{fs[_0x680a63(0x135)](configDir(),{'recursive':!![]}),fs['writeFileSync'](upgradeStatePath(),JSON[_0x680a63(0xff)]({..._0xc54a1d,'updated_at':Date[_0x680a63(0x13c)]()},null,0x2),_0x680a63(0xf4));}catch{}}function run(_0x5126ae,_0x59358d,_0x19aac1=process.env){const _0xa68a4e=a0_0x13f168;return(0x0,import_child_process['spawnSync'])(_0x5126ae,_0x59358d,{'encoding':_0xa68a4e(0x111),'timeout':NPM_INSTALL_TIMEOUT_MS,'maxBuffer':NPM_INSTALL_MAX_BUFFER,'env':_0x19aac1,'shell':![]});}function runNpmView(_0x4edd2f){const _0x5e43de=a0_0x13f168,_0x36d7e4=resolveExecutable(_0x5e43de(0x118));if(!_0x36d7e4)return{'status':0x7f,'stdout':'','stderr':_0x5e43de(0x14a),'error':new Error(_0x5e43de(0x14a))};return(0x0,import_child_process['spawnSync'])(_0x36d7e4,_0x4edd2f,{'encoding':'utf8','timeout':NPM_VIEW_TIMEOUT_MS,'maxBuffer':0x400*0x400,'env':process.env,'shell':![]});}function npmRootGlobal(){const _0x2a7cd2=a0_0x13f168,_0x2686b4=resolveExecutable('npm');if(!_0x2686b4)return'';const _0x259952=run(_0x2686b4,[_0x2a7cd2(0x164),'-g']);if(_0x259952[_0x2a7cd2(0x13a)]!==0x0)return'';return String(_0x259952['stdout']||'')['trim']();}function compareSemver(_0x4e8d49,_0x1468fa){const _0x4f109f=a0_0x13f168,_0x40f0ed=String(_0x4e8d49||'')['replace'](/^v/,'')['split'](/[.-]/)[_0x4f109f(0x154)](_0x1d35c3=>Number[_0x4f109f(0xea)](_0x1d35c3,0xa)||0x0),_0x5309c3=String(_0x1468fa||'')[_0x4f109f(0x15f)](/^v/,'')['split'](/[.-]/)[_0x4f109f(0x154)](_0x2a3d1e=>Number['parseInt'](_0x2a3d1e,0xa)||0x0);for(let _0x3f990f=0x0;_0x3f990f<Math['max'](_0x40f0ed[_0x4f109f(0xfa)],_0x5309c3[_0x4f109f(0xfa)],0x3);_0x3f990f++){const _0x56fa4c=_0x40f0ed[_0x3f990f]||0x0,_0x398b72=_0x5309c3[_0x3f990f]||0x0;if(_0x56fa4c>_0x398b72)return 0x1;if(_0x56fa4c<_0x398b72)return-0x1;}return 0x0;}function resolveExecutable(_0x169c5c){const _0x2fdf0a=a0_0x13f168,_0x162ca5=process[_0x2fdf0a(0xf7)]===_0x2fdf0a(0x124)?_0x2fdf0a(0x10b):_0x2fdf0a(0x12b);try{const _0x571468=(0x0,import_child_process[_0x2fdf0a(0x166)])(_0x162ca5,[_0x169c5c],{'encoding':'utf8','timeout':0xbb8,'shell':![]});if(_0x571468[_0x2fdf0a(0x13a)]!==0x0)return'';return String(_0x571468['stdout']||'')[_0x2fdf0a(0xe7)](/\r?\n/)['map'](_0x55f3df=>_0x55f3df['trim']())['filter'](Boolean)[0x0]||'';}catch{return'';}}function skipWrapperUpdateCheck(){const _0x546b01=a0_0x13f168,_0xfbb054=String(process.env.WHALENT_SKIP_UPDATE_CHECK||process.env.WHALENT_NO_UPDATE_CHECK||process.env.WHALENT_SKIP_WRAPPER_UPDATE||'')['trim']()[_0x546b01(0x15c)]();return _0xfbb054==='1'||_0xfbb054===_0x546b01(0x146)||_0xfbb054===_0x546b01(0x104)||_0xfbb054==='on';}function latestWrapperVersion(){const _0x3b6473=a0_0x13f168,_0x371126=runNpmView([_0x3b6473(0x13e),WRAPPER_PKG_NAME+_0x3b6473(0x100),_0x3b6473(0x119),'--registry='+NPM_REGISTRY]);if(_0x371126[_0x3b6473(0x13a)]!==0x0)return'';return String(_0x371126[_0x3b6473(0x140)]||'')['trim']()['split'](/\r?\n/)['filter'](Boolean)[_0x3b6473(0x12c)]()||'';}function installWrapperVersion(_0x38b2f1){const _0x1d7244=a0_0x13f168,_0x2f4ebb=resolveExecutable(_0x1d7244(0x118));if(!_0x2f4ebb)return{'ok':![],'output':'npm\x20not\x20found\x20on\x20PAT'+'H'};const _0x3a0a0f=run(_0x2f4ebb,['install','-g',WRAPPER_PKG_NAME+'@'+_0x38b2f1,'--registry='+NPM_REGISTRY]),_0x565733=((_0x3a0a0f['stdout']||'')+'\x0a'+(_0x3a0a0f['stderr']||''))['trim']();return{'ok':_0x3a0a0f[_0x1d7244(0x13a)]===0x0,'output':_0x565733};}function maybeUpdateWrapper(_0x24d5df){const _0x3c67f9=a0_0x13f168;if(skipWrapperUpdateCheck())return![];if(process.env.WHALENT_WRAPPER_UPDATE_ATTEMPTED)return![];const _0x325f26=latestWrapperVersion();if(!_0x325f26||compareSemver(_0x325f26,WRAPPER_VERSION)<=0x0)return![];console[_0x3c67f9(0x128)](_0x3c67f9(0x117)+_0x3c67f9(0xeb)+WRAPPER_VERSION+_0x3c67f9(0x151)+_0x325f26),console[_0x3c67f9(0x128)]('[wrapper]\x20installing'+'\x20'+WRAPPER_PKG_NAME+'@'+_0x325f26+(_0x3c67f9(0x10f)+'rting\x20core...'));const _0x1f840b=installWrapperVersion(_0x325f26);if(!_0x1f840b['ok']){console['warn']('[wrapper]\x20wrapper\x20up'+'date\x20failed;\x20continu'+'ing\x20with\x20'+WRAPPER_VERSION);if(_0x1f840b[_0x3c67f9(0x136)])console[_0x3c67f9(0x128)](_0x1f840b[_0x3c67f9(0x136)]['split'](/\r?\n/)[_0x3c67f9(0xfe)](-0xc)[_0x3c67f9(0x161)]('\x0a'));return console[_0x3c67f9(0x128)](_0x3c67f9(0xef)+_0x3c67f9(0x115)+WRAPPER_PKG_NAME+'@'+_0x325f26+'\x20--registry='+NPM_REGISTRY),![];}console['warn']('[wrapper]\x20wrapper\x20up'+_0x3c67f9(0xf1)+_0x325f26+_0x3c67f9(0xe5));const _0x1645c1=process['argv'][0x1],_0x20e61f=(0x0,import_child_process['spawnSync'])(process['execPath'],[_0x1645c1,..._0x24d5df],{'stdio':_0x3c67f9(0x10e),'env':{...process.env,'WHALENT_WRAPPER_UPDATE_ATTEMPTED':_0x325f26},'shell':![]});process['exit'](_0x20e61f[_0x3c67f9(0x13a)]??0x0);}function findCoreScript(){const _0x20d7e5=a0_0x13f168,_0x5badbc=String(process.env.WHALENT_CORE_ENTRY||'')['trim'](),_0x2b8138=['1',_0x20d7e5(0x146),'yes','on']['includes'](String(process.env.WHALENT_FORCE_CORE_ENTRY||'')['trim']()['toLowerCase']());if(_0x5badbc&&_0x2b8138&&fs[_0x20d7e5(0x110)](_0x5badbc))return _0x5badbc;const _0x241c77=[],_0x1ee211=_0x3abc6b=>{const _0x3b7302=_0x20d7e5;if(fs[_0x3b7302(0x110)](_0x3abc6b)&&!_0x241c77['includes'](_0x3abc6b))_0x241c77[_0x3b7302(0x142)](_0x3abc6b);};if(_0x5badbc)_0x1ee211(_0x5badbc);const _0x41bad7=npmRootGlobal();if(_0x41bad7){const _0x30153b=path[_0x20d7e5(0x161)](_0x41bad7,'@whalent','agent-core','dist',_0x20d7e5(0xfb));_0x1ee211(_0x30153b);}const _0x566ec1=path['join'](wrapperBaseDir(),_0x20d7e5(0x11d));_0x1ee211(_0x566ec1);const _0x1d92cb=path['join'](wrapperBaseDir(),'..',_0x20d7e5(0x107),_0x20d7e5(0xf0),'dist',_0x20d7e5(0xfb));_0x1ee211(_0x1d92cb);if(_0x241c77[_0x20d7e5(0xfa)]>0x0)return _0x241c77['map']((_0x10b15a,_0x5215a7)=>({'candidate':_0x10b15a,'index':_0x5215a7,'version':coreVersion(_0x10b15a)}))['sort']((_0x323dc9,_0x4722b5)=>{const _0x10b653=_0x20d7e5,_0x2f519d=compareSemver(_0x4722b5['version'],_0x323dc9[_0x10b653(0x119)]);if(_0x2f519d!==0x0)return _0x2f519d;return _0x4722b5['index']-_0x323dc9['index'];})[0x0][_0x20d7e5(0x167)];throw new Error(_0x20d7e5(0x157)+_0x20d7e5(0x14c)+'@whalent/agent-core\x20'+_0x20d7e5(0x114)+_0x20d7e5(0x125));}function coreVersion(_0x35b827=findCoreScript()){const _0x1f2bb9=a0_0x13f168,_0x116d4d=(0x0,import_child_process[_0x1f2bb9(0x166)])(process['execPath'],[_0x35b827,'--version'],{'encoding':'utf8','timeout':0x3a98,'env':{...process.env,'WHALENT_SKIP_UPDATE_CHECK':'1'},'shell':![]}),_0x5c63ce=(_0x116d4d[_0x1f2bb9(0x140)]||'')+'\x0a'+(_0x116d4d[_0x1f2bb9(0xe6)]||'');return _0x5c63ce[_0x1f2bb9(0x153)](/(\d+\.\d+\.\d+(?:[-\w.]+)?)/)?.[0x1]||'';}function isExecutable(_0x117e30){const _0x35a491=a0_0x13f168;try{return fs['accessSync'](_0x117e30,fs[_0x35a491(0xf2)][_0x35a491(0x158)]),!![];}catch{return![];}}function shellQuote(_0x4bd893){const _0x2e10f3=a0_0x13f168;return'\x27'+_0x4bd893[_0x2e10f3(0x15f)](/'/g,_0x2e10f3(0x11c))+'\x27';}function coreNodePtySpawnHelperPath(_0x239376){const _0x2fc194=a0_0x13f168;if(process[_0x2fc194(0xf7)]!==_0x2fc194(0x138))return'';try{const _0x5554ec=(0x0,import_module['createRequire'])(_0x239376),_0x4c4ec4=_0x5554ec['resolve'](_0x2fc194(0x130)),_0x14c5c0=path[_0x2fc194(0x134)](path[_0x2fc194(0x12e)](_0x4c4ec4),'..');return path[_0x2fc194(0x161)](_0x14c5c0,_0x2fc194(0x15e),_0x2fc194(0x127)+process['arch'],_0x2fc194(0x165));}catch{return'';}}function checkMacNodePtySpawnHelper(_0x5ac057){const _0x19d04b=a0_0x13f168,_0xe4d7ee=coreNodePtySpawnHelperPath(_0x5ac057);if(!_0xe4d7ee||CHECKED_PTY_HELPERS['has'](_0xe4d7ee))return;CHECKED_PTY_HELPERS['add'](_0xe4d7ee);if(!fs[_0x19d04b(0x110)](_0xe4d7ee)){console[_0x19d04b(0x128)](_0x19d04b(0x133)+'-pty\x20spawn-helper\x20no'+_0x19d04b(0x123)+_0xe4d7ee);return;}if(isExecutable(_0xe4d7ee))return;try{const _0x283b0a=fs['statSync'](_0xe4d7ee)['mode'];fs[_0x19d04b(0x139)](_0xe4d7ee,_0x283b0a|0x1ed);}catch{}if(isExecutable(_0xe4d7ee)){console[_0x19d04b(0x128)]('[wrapper]\x20fixed\x20macO'+'S\x20node-pty\x20spawn-hel'+_0x19d04b(0x126)+_0xe4d7ee);return;}console['warn']('[wrapper]\x20macOS\x20node'+_0x19d04b(0xf9)+'\x20not\x20executable:\x20'+_0xe4d7ee),console[_0x19d04b(0x128)]('[wrapper]\x20Run\x20this\x20o'+_0x19d04b(0x14f)+_0x19d04b(0x132)),console['warn'](_0x19d04b(0x13d)+shellQuote(_0xe4d7ee)),console['warn'](_0x19d04b(0x14e)),console['warn']('\x20\x20chmod\x20+x\x20\x22$HELPER\x22');}function printVersion(){const _0x11799c=a0_0x13f168;let _0x5b8e43='';try{_0x5b8e43=coreVersion();}catch{}console[_0x11799c(0x105)]('whalent-agent\x20'+WRAPPER_VERSION),console['log']('wrapper\x20'+WRAPPER_VERSION),console['log']('core\x20'+(_0x5b8e43||'not\x20installed'));}function directCore(_0x207f09){const _0x20af7c=a0_0x13f168,_0x3a2905=findCoreScript();checkMacNodePtySpawnHelper(_0x3a2905);const _0x2779ca=(0x0,import_child_process['spawnSync'])(process[_0x20af7c(0x12a)],[_0x3a2905,..._0x207f09],{'stdio':_0x20af7c(0x10e),'env':{...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_CORE_ENTRY':_0x3a2905},'shell':![]});process['exit'](_0x2779ca[_0x20af7c(0x13a)]??0x0);}function shouldSupervise(_0xe3f4bc){const _0x1989b9=a0_0x13f168;if(_0xe3f4bc[_0x1989b9(0x116)](_0x1989b9(0xf3)))return![];const _0x1a1925=_0xe3f4bc[0x0]||'';if(_0x1a1925==='ls'||_0x1a1925===_0x1989b9(0x13a)||_0x1a1925==='ps')return![];if(_0x1a1925===_0x1989b9(0x155)||_0x1a1925===_0x1989b9(0x102))return![];if(_0xe3f4bc['includes'](_0x1989b9(0xf6))||_0xe3f4bc[_0x1989b9(0x116)]('-h'))return![];return!![];}function installCoreVersion(_0x36cf46){const _0x4176e8=a0_0x13f168,_0x4282c6=resolveExecutable(_0x4176e8(0x118));if(!_0x4282c6)return{'ok':![],'output':'npm\x20not\x20found\x20on\x20PAT'+'H'};const _0x4d6aa3=CORE_PKG_NAME+'@'+_0x36cf46,_0x3facce=run(_0x4282c6,[_0x4176e8(0x152),'-g',_0x4d6aa3,_0x4176e8(0x106)+NPM_REGISTRY]),_0x3a8b84=((_0x3facce['stdout']||'')+'\x0a'+(_0x3facce[_0x4176e8(0xe6)]||''))['trim']();return{'ok':_0x3facce['status']===0x0,'output':_0x3a8b84};}function a0_0x4409(_0x5a29ae,_0x4236ba){_0x5a29ae=_0x5a29ae-0xe4;const _0x3fce21=a0_0x3fce();let _0x44094c=_0x3fce21[_0x5a29ae];if(a0_0x4409['CxcvkS']===undefined){var _0x3e2216=function(_0x29abea){const _0x221b82='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x44eb06='',_0x3549af='';for(let _0x5877a3=0x0,_0x40041e,_0x9aa6a3,_0x5a0897=0x0;_0x9aa6a3=_0x29abea['charAt'](_0x5a0897++);~_0x9aa6a3&&(_0x40041e=_0x5877a3%0x4?_0x40041e*0x40+_0x9aa6a3:_0x9aa6a3,_0x5877a3++%0x4)?_0x44eb06+=String['fromCharCode'](0xff&_0x40041e>>(-0x2*_0x5877a3&0x6)):0x0){_0x9aa6a3=_0x221b82['indexOf'](_0x9aa6a3);}for(let _0x25c8a3=0x0,_0x14e75c=_0x44eb06['length'];_0x25c8a3<_0x14e75c;_0x25c8a3++){_0x3549af+='%'+('00'+_0x44eb06['charCodeAt'](_0x25c8a3)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x3549af);};a0_0x4409['GbkBVj']=_0x3e2216,a0_0x4409['QicWpP']={},a0_0x4409['CxcvkS']=!![];}const _0x55d3d5=_0x3fce21[0x0],_0x76a2c5=_0x5a29ae+_0x55d3d5,_0x1b46b0=a0_0x4409['QicWpP'][_0x76a2c5];return!_0x1b46b0?(_0x44094c=a0_0x4409['GbkBVj'](_0x44094c),a0_0x4409['QicWpP'][_0x76a2c5]=_0x44094c):_0x44094c=_0x1b46b0,_0x44094c;}async function superviseCore(_0x384569){const _0x14be8f=a0_0x13f168;let _0x458f60=![],_0x61b07=null;const _0x126968=()=>{const _0x1e4a66=a0_0x4409;_0x458f60=!![];if(_0x61b07&&!_0x61b07[_0x1e4a66(0x11b)])try{_0x61b07[_0x1e4a66(0x137)]('SIGTERM');}catch{}else process['exit'](0x0);};process['on'](_0x14be8f(0xe8),_0x126968),process['on']('SIGTERM',_0x126968);while(!![]){const _0x2fffc6=findCoreScript();checkMacNodePtySpawnHelper(_0x2fffc6);const _0x1ca172={...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_WRAPPER_MANAGED':'1','WHALENT_CORE_ENTRY':_0x2fffc6},_0x2e160f=readUpgradeState(),_0x1d95c8=!!_0x2e160f?.[_0x14be8f(0xfc)];let _0x28ad31=![],_0x21a689=null;console[_0x14be8f(0x105)]('[wrapper]\x20starting\x20c'+_0x14be8f(0x156)+_0x2fffc6),_0x61b07=(0x0,import_child_process['spawn'])(process[_0x14be8f(0x12a)],[_0x2fffc6,..._0x384569],{'env':_0x1ca172,'stdio':[_0x14be8f(0x10e),'pipe','pipe']});const _0x421f48=()=>{const _0x1b5f90=_0x14be8f;if(_0x28ad31)return;_0x28ad31=!![];if(_0x21a689)clearTimeout(_0x21a689);const _0x4e972e=readUpgradeState();_0x4e972e?.[_0x1b5f90(0xfc)]&&(writeUpgradeState({..._0x4e972e,'pending':![],'rollback':![],'health_status':_0x1b5f90(0x143)}),console['log']('[wrapper]\x20core\x20upgra'+'de\x20healthy:\x20'+(_0x4e972e['installed_version']||_0x4e972e['target_version']||'')));},_0x49ab8d=(_0x4b3f0d,_0x623371=![])=>{const _0x1c8be3=_0x14be8f,_0x2cf4a2=_0x4b3f0d['toString']();(_0x623371?process['stderr']:process[_0x1c8be3(0x140)])[_0x1c8be3(0x120)](_0x2cf4a2),(_0x2cf4a2['includes']('[gateway]\x20Connected')||_0x2cf4a2['includes'](_0x1c8be3(0x129)+'achine')||_0x2cf4a2['includes']('Gateway:\x20connected'))&&_0x421f48();};_0x61b07[_0x14be8f(0x140)]?.['on']('data',_0x395f16=>_0x49ab8d(_0x395f16,![])),_0x61b07['stderr']?.['on'](_0x14be8f(0x144),_0x21f98a=>_0x49ab8d(_0x21f98a,!![]));_0x1d95c8&&(_0x21a689=setTimeout(()=>{const _0x47317b=_0x14be8f;if(_0x28ad31||!_0x61b07||_0x61b07['killed'])return;console['error'](_0x47317b(0x13b)+'id\x20not\x20become\x20health'+'y\x20in\x20time;\x20rolling\x20b'+_0x47317b(0x112));try{_0x61b07['kill']('SIGTERM');}catch{}},HEALTH_TIMEOUT_MS));const _0x350454=await new Promise(_0x4dab8e=>{_0x61b07['once']('exit',(_0x5ca459,_0x34a965)=>_0x4dab8e({'code':_0x5ca459,'signal':_0x34a965}));});if(_0x21a689)clearTimeout(_0x21a689);_0x61b07=null;if(_0x458f60)process[_0x14be8f(0x10c)](_0x350454['code']??0x0);const _0x55545d=readUpgradeState();if(_0x55545d?.[_0x14be8f(0xfc)]&&!_0x28ad31){const _0x8e296f=String(_0x55545d[_0x14be8f(0x11e)+'n']||'')['trim']();if(_0x8e296f){console['error'](_0x14be8f(0xe4)+_0x14be8f(0x147)+_0x8e296f);const _0x1c6de5=installCoreVersion(_0x8e296f);writeUpgradeState({..._0x55545d,'pending':![],'rollback':!![],'health_status':_0x1c6de5['ok']?'rolled_back':_0x14be8f(0xf8),'error':_0x1c6de5['ok']?'':_0x1c6de5['output']});}else writeUpgradeState({..._0x55545d,'pending':![],'rollback':!![],'health_status':'rollback_unavailable','error':_0x14be8f(0xf5)+'n\x20unknown'});}const _0x39372f=_0x350454['code']===SUPERVISED_RESTART_CODE||_0x55545d?.['pending'];if(!_0x39372f&&_0x350454[_0x14be8f(0x15b)]===0x0)process['exit'](0x0);console[_0x14be8f(0x105)]('[wrapper]\x20core\x20exite'+'d\x20code='+(_0x350454['code']??'')+(_0x350454['signal']?'\x20signal='+_0x350454[_0x14be8f(0x10d)]:'')+_0x14be8f(0x145)+RESTART_DELAY_MS+'ms'),await new Promise(_0x25b497=>setTimeout(_0x25b497,RESTART_DELAY_MS));}}async function main(){const _0x1068b3=a0_0x13f168,_0x3a39fd=process['argv']['slice'](0x2);if(_0x3a39fd[0x0]==='--version'||_0x3a39fd[0x0]==='-v'||_0x3a39fd[0x0]==='version'){printVersion();return;}if((_0x3a39fd[0x0]===_0x1068b3(0x13a)||_0x3a39fd[0x0]==='ls'||_0x3a39fd[0x0]==='ps')&&!_0x3a39fd[_0x1068b3(0x116)]('--json')){console['log'](_0x1068b3(0x13f)+WRAPPER_VERSION);try{console[_0x1068b3(0x105)]('core\x20'+(coreVersion()||_0x1068b3(0x122)));}catch{console['log'](_0x1068b3(0x15a));}}maybeUpdateWrapper(_0x3a39fd);if(!shouldSupervise(_0x3a39fd))directCore(_0x3a39fd);await superviseCore(_0x3a39fd);}main()['catch'](_0x2e0b0b=>{const _0xa17997=a0_0x13f168;console[_0xa17997(0x113)](_0xa17997(0x103)+_0xa17997(0x141)+(_0x2e0b0b?.['message']||String(_0x2e0b0b))),process[_0xa17997(0x10c)](0x1);});
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);});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whalent/agent",
3
- "version": "0.3.49",
3
+ "version": "0.3.51",
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.49"
41
+ "@whalent/agent-core": "0.3.51"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/node": "^20.0.0",