@whalent/agent 0.3.61 → 0.3.63

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_0x314265=a0_0x2a4f;(function(_0x1e671e,_0x25f740){const _0x105a7a=a0_0x2a4f,_0x5900d3=_0x1e671e();while(!![]){try{const _0x23dc43=-parseInt(_0x105a7a(0x1cb))/0x1*(-parseInt(_0x105a7a(0x195))/0x2)+parseInt(_0x105a7a(0x188))/0x3*(-parseInt(_0x105a7a(0x1d1))/0x4)+parseInt(_0x105a7a(0x1a7))/0x5+-parseInt(_0x105a7a(0x19f))/0x6*(-parseInt(_0x105a7a(0x180))/0x7)+-parseInt(_0x105a7a(0x17a))/0x8*(parseInt(_0x105a7a(0x1c3))/0x9)+parseInt(_0x105a7a(0x1a4))/0xa+-parseInt(_0x105a7a(0x1c7))/0xb;if(_0x23dc43===_0x25f740)break;else _0x5900d3['push'](_0x5900d3['shift']());}catch(_0x4f2c0f){_0x5900d3['push'](_0x5900d3['shift']());}}}(a0_0x588e,0xa4549));var __create=Object['create'],__defProp=Object[a0_0x314265(0x1c2)],__getOwnPropDesc=Object[a0_0x314265(0x1c0)+a0_0x314265(0x187)],__getOwnPropNames=Object['getOwnPropertyNames'],__getProtoOf=Object[a0_0x314265(0x199)],__hasOwnProp=Object['prototype']['hasOwnProperty'],__copyProps=(_0x128f65,_0x208db7,_0x5b5a61,_0x371d14)=>{const _0x1349b3=a0_0x314265;if(_0x208db7&&typeof _0x208db7===_0x1349b3(0x191)||typeof _0x208db7===_0x1349b3(0x175)){for(let _0x561f5b of __getOwnPropNames(_0x208db7))if(!__hasOwnProp['call'](_0x128f65,_0x561f5b)&&_0x561f5b!==_0x5b5a61)__defProp(_0x128f65,_0x561f5b,{'get':()=>_0x208db7[_0x561f5b],'enumerable':!(_0x371d14=__getOwnPropDesc(_0x208db7,_0x561f5b))||_0x371d14[_0x1349b3(0x1a0)]});}return _0x128f65;},__toESM=(_0x53c133,_0x3e8452,_0x20bfad)=>(_0x20bfad=_0x53c133!=null?__create(__getProtoOf(_0x53c133)):{},__copyProps(_0x3e8452||!_0x53c133||!_0x53c133[a0_0x314265(0x1ce)]?__defProp(_0x20bfad,'default',{'value':_0x53c133,'enumerable':!![]}):_0x20bfad,_0x53c133)),import_child_process=require(a0_0x314265(0x184)),fs=__toESM(require('fs'),0x1),import_module=require(a0_0x314265(0x16c)),os=__toESM(require('os'),0x1),path=__toESM(require(a0_0x314265(0x1d0)),0x1),WRAPPER_PKG_NAME=a0_0x314265(0x1b6),CORE_PKG_NAME=a0_0x314265(0x1bd),NPM_REGISTRY=a0_0x314265(0x1ac)+a0_0x314265(0x1c9),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 _0x482030=a0_0x314265;return path[_0x482030(0x18f)](os[_0x482030(0x18d)](),_0x482030(0x170));}function upgradeStatePath(){const _0x413e36=a0_0x314265;return path[_0x413e36(0x18f)](configDir(),'core-upgrade.json');}function readWrapperVersion(){const _0x3fb879=a0_0x314265;try{const _0x4921ca=JSON[_0x3fb879(0x1be)](fs['readFileSync'](path[_0x3fb879(0x18f)](wrapperBaseDir(),'..','package.json'),_0x3fb879(0x1a6)));return String(_0x4921ca[_0x3fb879(0x190)]||'0.0.0');}catch{return'0.0.0';}}function readUpgradeState(){const _0x12cae9=a0_0x314265;try{return JSON['parse'](fs['readFileSync'](upgradeStatePath(),_0x12cae9(0x1a6)));}catch{return null;}}function writeUpgradeState(_0x53f548){const _0x31ed58=a0_0x314265;try{fs['mkdirSync'](configDir(),{'recursive':!![]}),fs['writeFileSync'](upgradeStatePath(),JSON[_0x31ed58(0x16d)]({..._0x53f548,'updated_at':Date['now']()},null,0x2),_0x31ed58(0x1a6));}catch{}}function run(_0x4dbeda,_0x2604b9,_0x402646=process.env){const _0x177579=a0_0x314265;return(0x0,import_child_process[_0x177579(0x1b0)])(_0x4dbeda,_0x2604b9,{'encoding':_0x177579(0x1c8),'timeout':NPM_INSTALL_TIMEOUT_MS,'maxBuffer':NPM_INSTALL_MAX_BUFFER,'env':_0x402646,'shell':![]});}function a0_0x2a4f(_0x1e444c,_0x3ee2a8){_0x1e444c=_0x1e444c-0x15a;const _0x588e5d=a0_0x588e();let _0x2a4fc3=_0x588e5d[_0x1e444c];if(a0_0x2a4f['rUkUsE']===undefined){var _0x2baeda=function(_0x50399f){const _0x5e8d85='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x128f65='',_0x208db7='';for(let _0x5b5a61=0x0,_0x371d14,_0x561f5b,_0x53c133=0x0;_0x561f5b=_0x50399f['charAt'](_0x53c133++);~_0x561f5b&&(_0x371d14=_0x5b5a61%0x4?_0x371d14*0x40+_0x561f5b:_0x561f5b,_0x5b5a61++%0x4)?_0x128f65+=String['fromCharCode'](0xff&_0x371d14>>(-0x2*_0x5b5a61&0x6)):0x0){_0x561f5b=_0x5e8d85['indexOf'](_0x561f5b);}for(let _0x3e8452=0x0,_0x20bfad=_0x128f65['length'];_0x3e8452<_0x20bfad;_0x3e8452++){_0x208db7+='%'+('00'+_0x128f65['charCodeAt'](_0x3e8452)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x208db7);};a0_0x2a4f['UrWVuP']=_0x2baeda,a0_0x2a4f['shBHqF']={},a0_0x2a4f['rUkUsE']=!![];}const _0x4a49e9=_0x588e5d[0x0],_0xc7a241=_0x1e444c+_0x4a49e9,_0x274297=a0_0x2a4f['shBHqF'][_0xc7a241];return!_0x274297?(_0x2a4fc3=a0_0x2a4f['UrWVuP'](_0x2a4fc3),a0_0x2a4f['shBHqF'][_0xc7a241]=_0x2a4fc3):_0x2a4fc3=_0x274297,_0x2a4fc3;}function runNpmView(_0x24ec0e){const _0x58a67a=a0_0x314265,_0x2137e1=resolveExecutable(_0x58a67a(0x166));if(!_0x2137e1)return{'status':0x7f,'stdout':'','stderr':_0x58a67a(0x17f),'error':new Error('npm\x20not\x20found')};return(0x0,import_child_process['spawnSync'])(_0x2137e1,_0x24ec0e,{'encoding':_0x58a67a(0x1c8),'timeout':NPM_VIEW_TIMEOUT_MS,'maxBuffer':0x400*0x400,'env':process.env,'shell':![]});}function npmRootGlobal(){const _0x596179=a0_0x314265,_0x3b8dd8=resolveExecutable('npm');if(!_0x3b8dd8)return'';const _0x41afca=run(_0x3b8dd8,['root','-g']);if(_0x41afca['status']!==0x0)return'';return String(_0x41afca['stdout']||'')[_0x596179(0x15e)]();}function compareSemver(_0x30be5f,_0x2acd66){const _0x5a11af=a0_0x314265,_0x514d9b=String(_0x30be5f||'')[_0x5a11af(0x194)](/^v/,'')[_0x5a11af(0x197)](/[.-]/)['map'](_0x489a8a=>Number['parseInt'](_0x489a8a,0xa)||0x0),_0x3a4852=String(_0x2acd66||'')['replace'](/^v/,'')[_0x5a11af(0x197)](/[.-]/)[_0x5a11af(0x15a)](_0x5f2389=>Number[_0x5a11af(0x15d)](_0x5f2389,0xa)||0x0);for(let _0x150402=0x0;_0x150402<Math['max'](_0x514d9b[_0x5a11af(0x160)],_0x3a4852[_0x5a11af(0x160)],0x3);_0x150402++){const _0x18d57a=_0x514d9b[_0x150402]||0x0,_0x45fe35=_0x3a4852[_0x150402]||0x0;if(_0x18d57a>_0x45fe35)return 0x1;if(_0x18d57a<_0x45fe35)return-0x1;}return 0x0;}function resolveExecutable(_0x5343e8){const _0x1c2816=a0_0x314265,_0x55cd29=process[_0x1c2816(0x196)]===_0x1c2816(0x15f)?'where.exe':_0x1c2816(0x15c);try{const _0x45ff43=(0x0,import_child_process[_0x1c2816(0x1b0)])(_0x55cd29,[_0x5343e8],{'encoding':_0x1c2816(0x1c8),'timeout':0xbb8,'shell':![]});if(_0x45ff43['status']!==0x0)return'';return String(_0x45ff43['stdout']||'')[_0x1c2816(0x197)](/\r?\n/)[_0x1c2816(0x15a)](_0x1cbe1a=>_0x1cbe1a['trim']())[_0x1c2816(0x182)](Boolean)[0x0]||'';}catch{return'';}}function skipWrapperUpdateCheck(){const _0x353044=a0_0x314265,_0x1e9b6d=String(process.env.WHALENT_SKIP_UPDATE_CHECK||process.env.WHALENT_NO_UPDATE_CHECK||process.env.WHALENT_SKIP_WRAPPER_UPDATE||'')[_0x353044(0x15e)]()[_0x353044(0x185)]();return _0x1e9b6d==='1'||_0x1e9b6d===_0x353044(0x192)||_0x1e9b6d==='yes'||_0x1e9b6d==='on';}function latestWrapperVersion(){const _0x36e56d=a0_0x314265,_0x29fd2b=runNpmView(['view',WRAPPER_PKG_NAME+'@latest','version',_0x36e56d(0x1a5)+NPM_REGISTRY]);if(_0x29fd2b[_0x36e56d(0x167)]!==0x0)return'';return String(_0x29fd2b[_0x36e56d(0x181)]||'')['trim']()[_0x36e56d(0x197)](/\r?\n/)[_0x36e56d(0x182)](Boolean)[_0x36e56d(0x168)]()||'';}function installWrapperVersion(_0x10edad){const _0x1381dc=a0_0x314265,_0x28b93a=resolveExecutable('npm');if(!_0x28b93a)return{'ok':![],'output':'npm\x20not\x20found\x20on\x20PAT'+'H'};const _0xca29bc=run(_0x28b93a,['install','-g',WRAPPER_PKG_NAME+'@'+_0x10edad,_0x1381dc(0x1a5)+NPM_REGISTRY]),_0x20222e=((_0xca29bc['stdout']||'')+'\x0a'+(_0xca29bc['stderr']||''))['trim']();return{'ok':_0xca29bc[_0x1381dc(0x167)]===0x0,'output':_0x20222e};}function maybeUpdateWrapper(_0x4c458b){const _0x3bc5d2=a0_0x314265;if(skipWrapperUpdateCheck())return![];if(process.env.WHALENT_WRAPPER_UPDATE_ATTEMPTED)return![];const _0x1b28a3=latestWrapperVersion();if(!_0x1b28a3||compareSemver(_0x1b28a3,WRAPPER_VERSION)<=0x0)return![];console['warn'](_0x3bc5d2(0x171)+'ilable:\x20'+WRAPPER_VERSION+'\x20->\x20'+_0x1b28a3),console['warn'](_0x3bc5d2(0x176)+'\x20'+WRAPPER_PKG_NAME+'@'+_0x1b28a3+(_0x3bc5d2(0x19a)+'rting\x20core...'));const _0x5ece56=installWrapperVersion(_0x1b28a3);if(!_0x5ece56['ok']){console[_0x3bc5d2(0x1ad)](_0x3bc5d2(0x174)+_0x3bc5d2(0x165)+'ing\x20with\x20'+WRAPPER_VERSION);if(_0x5ece56[_0x3bc5d2(0x1cc)])console['warn'](_0x5ece56['output'][_0x3bc5d2(0x197)](/\r?\n/)['slice'](-0xc)['join']('\x0a'));return console['warn']('[wrapper]\x20Manual\x20upd'+_0x3bc5d2(0x1cf)+WRAPPER_PKG_NAME+'@'+_0x1b28a3+'\x20--registry='+NPM_REGISTRY),![];}console['warn']('[wrapper]\x20wrapper\x20up'+_0x3bc5d2(0x1ae)+_0x1b28a3+_0x3bc5d2(0x1c5));const _0x26b456=process['argv'][0x1],_0x50ecc9=(0x0,import_child_process['spawnSync'])(process[_0x3bc5d2(0x18a)],[_0x26b456,..._0x4c458b],{'stdio':_0x3bc5d2(0x169),'env':{...process.env,'WHALENT_WRAPPER_UPDATE_ATTEMPTED':_0x1b28a3},'shell':![]});process[_0x3bc5d2(0x1b2)](_0x50ecc9[_0x3bc5d2(0x167)]??0x0);}function findCoreScript(){const _0x45d624=a0_0x314265,_0x259838=String(process.env.WHALENT_CORE_ENTRY||'')[_0x45d624(0x15e)](),_0x4829aa=['1',_0x45d624(0x192),'yes','on']['includes'](String(process.env.WHALENT_FORCE_CORE_ENTRY||'')['trim']()['toLowerCase']());if(_0x259838&&_0x4829aa&&fs[_0x45d624(0x198)](_0x259838))return _0x259838;const _0x28ba11=[],_0x3829d1=_0x299ff7=>{const _0x2df05c=_0x45d624;if(fs[_0x2df05c(0x198)](_0x299ff7)&&!_0x28ba11[_0x2df05c(0x173)](_0x299ff7))_0x28ba11['push'](_0x299ff7);};if(_0x259838)_0x3829d1(_0x259838);const _0x205f33=npmRootGlobal();if(_0x205f33){const _0x11ecdf=path['join'](_0x205f33,'@whalent','agent-core','dist',_0x45d624(0x17e));_0x3829d1(_0x11ecdf);}const _0x4731b1=path['join'](wrapperBaseDir(),_0x45d624(0x172));_0x3829d1(_0x4731b1);const _0x58da07=path['join'](wrapperBaseDir(),'..','packages','core','dist',_0x45d624(0x17e));_0x3829d1(_0x58da07);if(_0x28ba11['length']>0x0)return _0x28ba11[_0x45d624(0x15a)]((_0x5d44d3,_0x207a9f)=>({'candidate':_0x5d44d3,'index':_0x207a9f,'version':coreVersion(_0x5d44d3)}))['sort']((_0x7c836,_0x56e7ec)=>{const _0x5819ac=_0x45d624,_0x40f839=compareSemver(_0x56e7ec['version'],_0x7c836[_0x5819ac(0x190)]);if(_0x40f839!==0x0)return _0x40f839;return _0x56e7ec['index']-_0x7c836['index'];})[0x0][_0x45d624(0x1b7)];throw new Error('whalent\x20core\x20runtime'+'\x20not\x20found;\x20install\x20'+'@whalent/agent-core\x20'+'or\x20rebuild\x20@whalent/'+_0x45d624(0x1bc));}function coreVersion(_0xd95c3=findCoreScript()){const _0x4bd3ab=a0_0x314265,_0x504540=(0x0,import_child_process[_0x4bd3ab(0x1b0)])(process[_0x4bd3ab(0x18a)],[_0xd95c3,_0x4bd3ab(0x1d4)],{'encoding':'utf8','timeout':0x3a98,'env':{...process.env,'WHALENT_SKIP_UPDATE_CHECK':'1'},'shell':![]}),_0x14fbbd=(_0x504540[_0x4bd3ab(0x181)]||'')+'\x0a'+(_0x504540[_0x4bd3ab(0x16b)]||'');return _0x14fbbd['match'](/(\d+\.\d+\.\d+(?:[-\w.]+)?)/)?.[0x1]||'';}function isExecutable(_0x26cb74){const _0x1455e1=a0_0x314265;try{return fs['accessSync'](_0x26cb74,fs[_0x1455e1(0x1b8)][_0x1455e1(0x1c4)]),!![];}catch{return![];}}function shellQuote(_0xa19508){const _0x3c750a=a0_0x314265;return'\x27'+_0xa19508[_0x3c750a(0x194)](/'/g,_0x3c750a(0x1af))+'\x27';}function coreNodePtySpawnHelperPath(_0x52309c){const _0x20bab9=a0_0x314265;if(process['platform']!=='darwin')return'';try{const _0x31d620=(0x0,import_module[_0x20bab9(0x18c)])(_0x52309c),_0x3b439b=_0x31d620[_0x20bab9(0x1ca)]('node-pty'),_0x4f3341=path[_0x20bab9(0x1ca)](path['dirname'](_0x3b439b),'..');return path[_0x20bab9(0x18f)](_0x4f3341,'prebuilds','darwin-'+process[_0x20bab9(0x17c)],_0x20bab9(0x1ba));}catch{return'';}}function checkMacNodePtySpawnHelper(_0xc67be6){const _0x4bf4e3=a0_0x314265,_0xc89f6f=coreNodePtySpawnHelperPath(_0xc67be6);if(!_0xc89f6f||CHECKED_PTY_HELPERS[_0x4bf4e3(0x16a)](_0xc89f6f))return;CHECKED_PTY_HELPERS['add'](_0xc89f6f);if(!fs['existsSync'](_0xc89f6f)){console['warn'](_0x4bf4e3(0x19e)+_0x4bf4e3(0x1b4)+'t\x20found:\x20'+_0xc89f6f);return;}if(isExecutable(_0xc89f6f))return;try{const _0x40a66e=fs[_0x4bf4e3(0x1bb)](_0xc89f6f)[_0x4bf4e3(0x19d)];fs[_0x4bf4e3(0x1a8)](_0xc89f6f,_0x40a66e|0x1ed);}catch{}if(isExecutable(_0xc89f6f)){console['warn'](_0x4bf4e3(0x1cd)+'S\x20node-pty\x20spawn-hel'+_0x4bf4e3(0x163)+_0xc89f6f);return;}console[_0x4bf4e3(0x1ad)]('[wrapper]\x20macOS\x20node'+'-pty\x20spawn-helper\x20is'+_0x4bf4e3(0x1b9)+_0xc89f6f),console['warn'](_0x4bf4e3(0x1bf)+'nce\x20to\x20fix\x20terminal/'+'PTY\x20startup:'),console['warn']('\x20\x20HELPER='+shellQuote(_0xc89f6f)),console[_0x4bf4e3(0x1ad)]('\x20\x20ls\x20-l\x20\x22$HELPER\x22'),console['warn']('\x20\x20chmod\x20+x\x20\x22$HELPER\x22');}function printVersion(){const _0x28e016=a0_0x314265;let _0x2a80b6='';try{_0x2a80b6=coreVersion();}catch{}console['log']('whalent-agent\x20'+WRAPPER_VERSION),console[_0x28e016(0x1d3)](_0x28e016(0x16e)+WRAPPER_VERSION),console[_0x28e016(0x1d3)](_0x28e016(0x18e)+(_0x2a80b6||'not\x20installed'));}function directCore(_0x474b56){const _0x2d8c72=a0_0x314265,_0x5878f1=findCoreScript();checkMacNodePtySpawnHelper(_0x5878f1);const _0x1ae59e=(0x0,import_child_process['spawnSync'])(process[_0x2d8c72(0x18a)],[_0x5878f1,..._0x474b56],{'stdio':_0x2d8c72(0x169),'env':{...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_CORE_ENTRY':_0x5878f1},'shell':![]});process[_0x2d8c72(0x1b2)](_0x1ae59e[_0x2d8c72(0x167)]??0x0);}function shouldSupervise(_0x5115c1){const _0x3905de=a0_0x314265;if(_0x5115c1[_0x3905de(0x173)]('--agent-id'))return![];const _0x32f797=_0x5115c1[0x0]||'';if(_0x32f797==='ls'||_0x32f797===_0x3905de(0x167)||_0x32f797==='ps')return![];if(_0x32f797==='mcp'||_0x32f797==='daemon-mcp')return![];if(_0x5115c1['includes'](_0x3905de(0x19c))||_0x5115c1['includes']('-h'))return![];return!![];}function a0_0x588e(){const _0x2ae8be=['C3rKzxjY','Bw9KDwXL','C3rYAw5NAwz5','D3jHChbLCIa','y29Kzq','lNDOywXLBNqTywDLBNq','w3DYyxbWzxjDihvWzgf0zsbHDMe','y29Yzs5JANm','Aw5JBhvKzxm','w3DYyxbWzxjDihDYyxbWzxiGDxa','zNvUy3rPB24','w3DYyxbWzxjDigLUC3rHBgXPBMC','C3bHD24','CJOG','yxjNDG','nZaYntq0q21zvxPQ','A2LSBgvK','yxjJAa','AwqGBM90igjLy29TzsbOzwfSDgG','Aw5KzxGUy2PZ','BNbTig5VDcbMB3vUza','mJaZntiZnLbTBvzbwG','C3rKB3v0','zMLSDgvY','CgvUzgLUzW','y2HPBgrFChjVy2vZCW','Dg9mB3DLCKnHC2u','y29YzsbUB3qGAw5ZDgfSBgvK','ChrVCG','mtmWotiWtg9zr0nt','A2LSBa','zxHLy1bHDgG','DgfYz2v0x3zLCNnPB24','y3jLyxrLuMvXDwLYzq','Ag9TzwrPCG','y29Yzsa','AM9PBG','DMvYC2LVBG','B2jQzwn0','Dhj1zq','BNbTig5VDcbMB3vUzcbVBIbqqvq','CMvWBgfJzq','mtK2otuWmLL3B3vzEa','CgXHDgzVCM0','C3bSAxq','zxHPC3rZu3LUyW','z2v0uhjVDg90ExbLt2y','igzYB20GBNbTigjLzM9YzsbZDge','oYbYzxn0yxj0Aw5NigLUia','ls1OzwXW','Bw9Kzq','w3DYyxbWzxjDig1Hy09tig5Vzgu','nLDAEuPxEG','zw51BwvYywjSzq','Aw5ZDgfSBa','B3jLoIa','ywnOAw5L','odCYmJmZmeLOv052Dq','ls1YzwDPC3rYEt0','DxrMltG','ndGYotGZmenYsNjpAq','y2HTB2rtEw5J','y2SGy29Yzsb0BYa','zxjYB3i','zgf0yq','Ahr0Chm6lY9YzwDPC3rYEs5UCg0','D2fYBG','zgf0zwqGDg8G','j1WNjW','C3bHD25tEw5J','w3DYyxbWzxjDihjVBgXPBMCGyMe','zxHPDa','ihnPz25HBd0','lxb0EsbZCgf3BI1OzwXWzxiGBM8','u0Lhvevstq','qhDOywXLBNqVywDLBNq','y2fUzgLKyxrL','y29UC3rHBNrZ','ig5VDcbLEgvJDxrHyMXLoIa','C3bHD24TAgvSCgvY','C3rHDfn5BMm','ywDLBNq','qhDOywXLBNqVywDLBNqTy29Yzq','CgfYC2u','w3DYyxbWzxjDifj1BIb0AgLZig8','z2v0t3DUuhjVCgvYDhLezxnJCMK','C2LNBMfS','zgvMAw5LuhjVCgvYDhK','owvzA2LuEa','wf9psW','oYbYzxn0yxj0Aw5NihDYyxbWzxi','r2f0zxDHEsbYzwDPC3rLCMvKig0','mty3ntK4ntnivfnLteq','DxrMoa','ANmUB3jN','CMvZB2X2zq','mwf5ExHHEq','B3v0Chv0','w3DYyxbWzxjDigzPEgvKig1Hy08','x19LC01VzhvSzq','yxrLoIbUCg0GAw5ZDgfSBcaTzYa','Cgf0Aa','nZzRB1zQu3y','BIb1BMTUB3DU','Bg9N','ls12zxjZAw9U','BwfW','r2f0zxDHEtOGy29UBMvJDgvK','D2HPy2G','CgfYC2vjBNq','DhjPBq','D2LUmZi','BgvUz3rO','ls1QC29U','w3DYyxbWzxjDignVCMuGzxHPDgu','CgvYigv4zwn1DgfIBguGyML0oIa','CgLWzq','zgf0zsbMywLSzwq7ignVBNrPBNu','BNbT','C3rHDhvZ','Cg9W','Aw5OzxjPDa','AgfZ'];a0_0x588e=function(){return _0x2ae8be;};return a0_0x588e();}function installCoreVersion(_0x76712){const _0x5ee7fd=a0_0x314265,_0x52f2fe=resolveExecutable('npm');if(!_0x52f2fe)return{'ok':![],'output':_0x5ee7fd(0x193)+'H'};const _0x3f80e8=CORE_PKG_NAME+'@'+_0x76712,_0x45548e=run(_0x52f2fe,[_0x5ee7fd(0x1a1),'-g',_0x3f80e8,_0x5ee7fd(0x1a5)+NPM_REGISTRY]),_0x366251=((_0x45548e[_0x5ee7fd(0x181)]||'')+'\x0a'+(_0x45548e[_0x5ee7fd(0x16b)]||''))['trim']();return{'ok':_0x45548e['status']===0x0,'output':_0x366251};}async function superviseCore(_0x27f9ad){const _0x2b3fac=a0_0x314265;let _0x2a5836=![],_0x56bc58=null;const _0x37a835=()=>{const _0x1b3188=a0_0x2a4f;_0x2a5836=!![];if(_0x56bc58&&!_0x56bc58['killed'])try{_0x56bc58[_0x1b3188(0x189)]('SIGTERM');}catch{}else process['exit'](0x0);};process['on']('SIGINT',_0x37a835),process['on'](_0x2b3fac(0x1b5),_0x37a835);while(!![]){const _0x3afcb7=findCoreScript();checkMacNodePtySpawnHelper(_0x3afcb7);const _0x224135={...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_WRAPPER_MANAGED':'1','WHALENT_CORE_ENTRY':_0x3afcb7},_0x58b806=readUpgradeState(),_0x27581e=!!_0x58b806?.[_0x2b3fac(0x183)];let _0x3e5d74=![],_0x594d69=null;console['log']('[wrapper]\x20starting\x20c'+_0x2b3fac(0x1a2)+_0x3afcb7),_0x56bc58=(0x0,import_child_process[_0x2b3fac(0x177)])(process[_0x2b3fac(0x18a)],[_0x3afcb7,..._0x27f9ad],{'env':_0x224135,'stdio':['inherit',_0x2b3fac(0x164),_0x2b3fac(0x164)]});const _0x2b2111=()=>{const _0x28bde6=_0x2b3fac;if(_0x3e5d74)return;_0x3e5d74=!![];if(_0x594d69)clearTimeout(_0x594d69);const _0x748b18=readUpgradeState();_0x748b18?.['pending']&&(writeUpgradeState({..._0x748b18,'pending':![],'rollback':![],'health_status':'healthy'}),console[_0x28bde6(0x1d3)]('[wrapper]\x20core\x20upgra'+'de\x20healthy:\x20'+(_0x748b18['installed_version']||_0x748b18[_0x28bde6(0x18b)]||'')));},_0x58894f=(_0x45b9a2,_0x2c6120=![])=>{const _0x583222=_0x2b3fac,_0x303135=_0x45b9a2['toString']();(_0x2c6120?process[_0x583222(0x16b)]:process['stdout'])['write'](_0x303135),(_0x303135[_0x583222(0x173)]('[gateway]\x20Connected')||_0x303135['includes'](_0x583222(0x1c6)+_0x583222(0x1a3))||_0x303135[_0x583222(0x173)](_0x583222(0x15b)))&&_0x2b2111();};_0x56bc58['stdout']?.['on'](_0x2b3fac(0x1ab),_0x11e5c7=>_0x58894f(_0x11e5c7,![])),_0x56bc58['stderr']?.['on'](_0x2b3fac(0x1ab),_0x50c1f2=>_0x58894f(_0x50c1f2,!![]));_0x27581e&&(_0x594d69=setTimeout(()=>{const _0x16d3a1=_0x2b3fac;if(_0x3e5d74||!_0x56bc58||_0x56bc58[_0x16d3a1(0x17b)])return;console['error']('[wrapper]\x20new\x20core\x20d'+_0x16d3a1(0x17d)+'y\x20in\x20time;\x20rolling\x20b'+'ack');try{_0x56bc58[_0x16d3a1(0x189)]('SIGTERM');}catch{}},HEALTH_TIMEOUT_MS));const _0x184854=await new Promise(_0x5005e7=>{const _0x53b8ca=_0x2b3fac;_0x56bc58['once'](_0x53b8ca(0x1b2),(_0x41f03c,_0x40e511)=>_0x5005e7({'code':_0x41f03c,'signal':_0x40e511}));});if(_0x594d69)clearTimeout(_0x594d69);_0x56bc58=null;if(_0x2a5836)process[_0x2b3fac(0x1b2)](_0x184854['code']??0x0);const _0x521018=readUpgradeState();if(_0x521018?.[_0x2b3fac(0x183)]&&!_0x3e5d74){const _0x454eed=String(_0x521018['previous_core_versio'+'n']||'')[_0x2b3fac(0x15e)]();if(_0x454eed){console['error'](_0x2b3fac(0x1b1)+_0x2b3fac(0x1a9)+_0x454eed);const _0x3f67a2=installCoreVersion(_0x454eed);writeUpgradeState({..._0x521018,'pending':![],'rollback':!![],'health_status':_0x3f67a2['ok']?'rolled_back':'rollback_failed','error':_0x3f67a2['ok']?'':_0x3f67a2['output']});}else writeUpgradeState({..._0x521018,'pending':![],'rollback':!![],'health_status':'rollback_unavailable','error':'previous\x20core\x20versio'+_0x2b3fac(0x1d2)});}const _0x3984ad=_0x184854[_0x2b3fac(0x16f)]===SUPERVISED_RESTART_CODE||_0x521018?.[_0x2b3fac(0x183)];if(!_0x3984ad&&_0x184854[_0x2b3fac(0x16f)]===0x0)process[_0x2b3fac(0x1b2)](0x0);console['log'](_0x2b3fac(0x162)+'d\x20code='+(_0x184854[_0x2b3fac(0x16f)]??'')+(_0x184854[_0x2b3fac(0x1c1)]?_0x2b3fac(0x1b3)+_0x184854['signal']:'')+_0x2b3fac(0x19b)+RESTART_DELAY_MS+'ms'),await new Promise(_0x29cb87=>setTimeout(_0x29cb87,RESTART_DELAY_MS));}}async function main(){const _0x4c638b=a0_0x314265,_0x1c3fea=process[_0x4c638b(0x179)]['slice'](0x2);if(_0x1c3fea[0x0]===_0x4c638b(0x1d4)||_0x1c3fea[0x0]==='-v'||_0x1c3fea[0x0]===_0x4c638b(0x190)){printVersion();return;}if((_0x1c3fea[0x0]===_0x4c638b(0x167)||_0x1c3fea[0x0]==='ls'||_0x1c3fea[0x0]==='ps')&&!_0x1c3fea['includes'](_0x4c638b(0x161))){console[_0x4c638b(0x1d3)](_0x4c638b(0x16e)+WRAPPER_VERSION);try{console[_0x4c638b(0x1d3)](_0x4c638b(0x18e)+(coreVersion()||'not\x20installed'));}catch{console[_0x4c638b(0x1d3)](_0x4c638b(0x186));}}maybeUpdateWrapper(_0x1c3fea);if(!shouldSupervise(_0x1c3fea))directCore(_0x1c3fea);await superviseCore(_0x1c3fea);}main()['catch'](_0x37c9c4=>{const _0x29e8de=a0_0x314265;console[_0x29e8de(0x1aa)]('[wrapper]\x20Fatal\x20erro'+_0x29e8de(0x178)+(_0x37c9c4?.['message']||String(_0x37c9c4))),process[_0x29e8de(0x1b2)](0x1);});
2
+ 'use strict';const a0_0x10a9b4=a0_0x4854;(function(_0x2bac2f,_0x3e6fa9){const _0x19a04c=a0_0x4854,_0x1a5ca0=_0x2bac2f();while(!![]){try{const _0x2ec786=-parseInt(_0x19a04c(0x166))/0x1+-parseInt(_0x19a04c(0xf8))/0x2+-parseInt(_0x19a04c(0x131))/0x3*(parseInt(_0x19a04c(0x110))/0x4)+parseInt(_0x19a04c(0x162))/0x5*(-parseInt(_0x19a04c(0xf9))/0x6)+-parseInt(_0x19a04c(0x147))/0x7+-parseInt(_0x19a04c(0x158))/0x8*(-parseInt(_0x19a04c(0x167))/0x9)+parseInt(_0x19a04c(0x126))/0xa;if(_0x2ec786===_0x3e6fa9)break;else _0x1a5ca0['push'](_0x1a5ca0['shift']());}catch(_0x4510fc){_0x1a5ca0['push'](_0x1a5ca0['shift']());}}}(a0_0x5d2b,0x98784));var __create=Object['create'],__defProp=Object['defineProperty'],__getOwnPropDesc=Object[a0_0x10a9b4(0x106)+a0_0x10a9b4(0x150)],__getOwnPropNames=Object['getOwnPropertyNames'],__getProtoOf=Object[a0_0x10a9b4(0x113)],__hasOwnProp=Object[a0_0x10a9b4(0x169)][a0_0x10a9b4(0x104)],__copyProps=(_0x6ae8d4,_0xb34e6f,_0x1e0abb,_0x1749ce)=>{const _0x2066ab=a0_0x10a9b4;if(_0xb34e6f&&typeof _0xb34e6f===_0x2066ab(0x160)||typeof _0xb34e6f===_0x2066ab(0x118)){for(let _0x3df33d of __getOwnPropNames(_0xb34e6f))if(!__hasOwnProp['call'](_0x6ae8d4,_0x3df33d)&&_0x3df33d!==_0x1e0abb)__defProp(_0x6ae8d4,_0x3df33d,{'get':()=>_0xb34e6f[_0x3df33d],'enumerable':!(_0x1749ce=__getOwnPropDesc(_0xb34e6f,_0x3df33d))||_0x1749ce['enumerable']});}return _0x6ae8d4;},__toESM=(_0x1ff904,_0x1f06ba,_0x2d4f6b)=>(_0x2d4f6b=_0x1ff904!=null?__create(__getProtoOf(_0x1ff904)):{},__copyProps(_0x1f06ba||!_0x1ff904||!_0x1ff904[a0_0x10a9b4(0x11b)]?__defProp(_0x2d4f6b,'default',{'value':_0x1ff904,'enumerable':!![]}):_0x2d4f6b,_0x1ff904)),import_child_process=require('child_process'),fs=__toESM(require('fs'),0x1),import_module=require(a0_0x10a9b4(0x175)),os=__toESM(require('os'),0x1),path=__toESM(require(a0_0x10a9b4(0x125)),0x1),WRAPPER_PKG_NAME=a0_0x10a9b4(0x13a),CORE_PKG_NAME='@whalent/agent-core',NPM_REGISTRY=a0_0x10a9b4(0x155)+'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 _0x28a814=a0_0x10a9b4;return path[_0x28a814(0x14c)](os[_0x28a814(0x122)](),'.whalent-agent');}function a0_0x4854(_0x514eb1,_0x20cb48){_0x514eb1=_0x514eb1-0xf7;const _0x5d2b12=a0_0x5d2b();let _0x4854f4=_0x5d2b12[_0x514eb1];if(a0_0x4854['pzpFSg']===undefined){var _0x43e65b=function(_0x4ac0c4){const _0x123c7d='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x6ae8d4='',_0xb34e6f='';for(let _0x1e0abb=0x0,_0x1749ce,_0x3df33d,_0x1ff904=0x0;_0x3df33d=_0x4ac0c4['charAt'](_0x1ff904++);~_0x3df33d&&(_0x1749ce=_0x1e0abb%0x4?_0x1749ce*0x40+_0x3df33d:_0x3df33d,_0x1e0abb++%0x4)?_0x6ae8d4+=String['fromCharCode'](0xff&_0x1749ce>>(-0x2*_0x1e0abb&0x6)):0x0){_0x3df33d=_0x123c7d['indexOf'](_0x3df33d);}for(let _0x1f06ba=0x0,_0x2d4f6b=_0x6ae8d4['length'];_0x1f06ba<_0x2d4f6b;_0x1f06ba++){_0xb34e6f+='%'+('00'+_0x6ae8d4['charCodeAt'](_0x1f06ba)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0xb34e6f);};a0_0x4854['xPvTIz']=_0x43e65b,a0_0x4854['beyPWC']={},a0_0x4854['pzpFSg']=!![];}const _0x43b1cf=_0x5d2b12[0x0],_0x5c8f14=_0x514eb1+_0x43b1cf,_0x20c11c=a0_0x4854['beyPWC'][_0x5c8f14];return!_0x20c11c?(_0x4854f4=a0_0x4854['xPvTIz'](_0x4854f4),a0_0x4854['beyPWC'][_0x5c8f14]=_0x4854f4):_0x4854f4=_0x20c11c,_0x4854f4;}function upgradeStatePath(){const _0x45a9bd=a0_0x10a9b4;return path[_0x45a9bd(0x14c)](configDir(),_0x45a9bd(0x130));}function readWrapperVersion(){const _0x487f07=a0_0x10a9b4;try{const _0x63f811=JSON['parse'](fs[_0x487f07(0x12e)](path[_0x487f07(0x14c)](wrapperBaseDir(),'..',_0x487f07(0x12a)),'utf-8'));return String(_0x63f811['version']||_0x487f07(0x132));}catch{return'0.0.0';}}function readUpgradeState(){try{return JSON['parse'](fs['readFileSync'](upgradeStatePath(),'utf-8'));}catch{return null;}}function writeUpgradeState(_0x4b18a4){const _0x299ad8=a0_0x10a9b4;try{fs[_0x299ad8(0x108)](configDir(),{'recursive':!![]}),fs['writeFileSync'](upgradeStatePath(),JSON[_0x299ad8(0x148)]({..._0x4b18a4,'updated_at':Date['now']()},null,0x2),_0x299ad8(0x137));}catch{}}function run(_0x48369d,_0x4085a2,_0x3d3ad3=process.env){const _0x7ec750=a0_0x10a9b4;return(0x0,import_child_process[_0x7ec750(0x163)])(_0x48369d,_0x4085a2,{'encoding':_0x7ec750(0x14a),'timeout':NPM_INSTALL_TIMEOUT_MS,'maxBuffer':NPM_INSTALL_MAX_BUFFER,'env':_0x3d3ad3,'shell':![]});}function runNpmView(_0x3f4662){const _0x5dc2c6=a0_0x10a9b4,_0x484e1c=resolveExecutable(_0x5dc2c6(0x15f));if(!_0x484e1c)return{'status':0x7f,'stdout':'','stderr':'npm\x20not\x20found','error':new Error('npm\x20not\x20found')};return(0x0,import_child_process[_0x5dc2c6(0x163)])(_0x484e1c,_0x3f4662,{'encoding':'utf8','timeout':NPM_VIEW_TIMEOUT_MS,'maxBuffer':0x400*0x400,'env':process.env,'shell':![]});}function npmRootGlobal(){const _0x1279c4=a0_0x10a9b4,_0x4974e=resolveExecutable('npm');if(!_0x4974e)return'';const _0x2d5f58=run(_0x4974e,['root','-g']);if(_0x2d5f58['status']!==0x0)return'';return String(_0x2d5f58[_0x1279c4(0x133)]||'')[_0x1279c4(0x10c)]();}function compareSemver(_0x5d703f,_0x5d6a5b){const _0x2b4b39=a0_0x10a9b4,_0x4fbda7=String(_0x5d703f||'')['replace'](/^v/,'')[_0x2b4b39(0x171)](/[.-]/)[_0x2b4b39(0x128)](_0x493acb=>Number['parseInt'](_0x493acb,0xa)||0x0),_0xa7dad5=String(_0x5d6a5b||'')['replace'](/^v/,'')['split'](/[.-]/)[_0x2b4b39(0x128)](_0x5b8abe=>Number[_0x2b4b39(0x143)](_0x5b8abe,0xa)||0x0);for(let _0x539417=0x0;_0x539417<Math['max'](_0x4fbda7['length'],_0xa7dad5['length'],0x3);_0x539417++){const _0xc2789e=_0x4fbda7[_0x539417]||0x0,_0x2c93a7=_0xa7dad5[_0x539417]||0x0;if(_0xc2789e>_0x2c93a7)return 0x1;if(_0xc2789e<_0x2c93a7)return-0x1;}return 0x0;}function resolveExecutable(_0x65d22){const _0x129ada=a0_0x10a9b4,_0x58475a=process['platform']==='win32'?_0x129ada(0x138):'which';try{const _0x5b8670=(0x0,import_child_process[_0x129ada(0x163)])(_0x58475a,[_0x65d22],{'encoding':'utf8','timeout':0xbb8,'shell':![]});if(_0x5b8670[_0x129ada(0x15d)]!==0x0)return'';return String(_0x5b8670['stdout']||'')[_0x129ada(0x171)](/\r?\n/)['map'](_0x1e644c=>_0x1e644c[_0x129ada(0x10c)]())[_0x129ada(0x124)](Boolean)[0x0]||'';}catch{return'';}}function skipWrapperUpdateCheck(){const _0x330193=a0_0x10a9b4,_0x2a3132=String(process.env.WHALENT_SKIP_UPDATE_CHECK||process.env.WHALENT_NO_UPDATE_CHECK||process.env.WHALENT_SKIP_WRAPPER_UPDATE||'')['trim']()['toLowerCase']();return _0x2a3132==='1'||_0x2a3132===_0x330193(0x168)||_0x2a3132==='yes'||_0x2a3132==='on';}function latestWrapperVersion(){const _0x2d7847=a0_0x10a9b4,_0x1e515c=runNpmView([_0x2d7847(0x10a),WRAPPER_PKG_NAME+_0x2d7847(0x127),'version','--registry='+NPM_REGISTRY]);if(_0x1e515c['status']!==0x0)return'';return String(_0x1e515c['stdout']||'')['trim']()[_0x2d7847(0x171)](/\r?\n/)['filter'](Boolean)['pop']()||'';}function installWrapperVersion(_0x20cb86){const _0x4ec1c9=a0_0x10a9b4,_0x30ae6a=resolveExecutable('npm');if(!_0x30ae6a)return{'ok':![],'output':'npm\x20not\x20found\x20on\x20PAT'+'H'};const _0x4a8d09=run(_0x30ae6a,[_0x4ec1c9(0x16d),'-g',WRAPPER_PKG_NAME+'@'+_0x20cb86,'--registry='+NPM_REGISTRY]),_0x2b9147=((_0x4a8d09[_0x4ec1c9(0x133)]||'')+'\x0a'+(_0x4a8d09['stderr']||''))['trim']();return{'ok':_0x4a8d09['status']===0x0,'output':_0x2b9147};}function maybeUpdateWrapper(_0x3609e7){const _0x28535a=a0_0x10a9b4;if(skipWrapperUpdateCheck())return![];if(process.env.WHALENT_WRAPPER_UPDATE_ATTEMPTED)return![];const _0x217502=latestWrapperVersion();if(!_0x217502||compareSemver(_0x217502,WRAPPER_VERSION)<=0x0)return![];console['warn']('[wrapper]\x20update\x20ava'+_0x28535a(0x16e)+WRAPPER_VERSION+'\x20->\x20'+_0x217502),console[_0x28535a(0x139)](_0x28535a(0x16f)+'\x20'+WRAPPER_PKG_NAME+'@'+_0x217502+('\x20from\x20npm\x20before\x20sta'+'rting\x20core...'));const _0x7f0d63=installWrapperVersion(_0x217502);if(!_0x7f0d63['ok']){console[_0x28535a(0x139)](_0x28535a(0x14e)+'date\x20failed;\x20continu'+'ing\x20with\x20'+WRAPPER_VERSION);if(_0x7f0d63[_0x28535a(0x15b)])console['warn'](_0x7f0d63['output']['split'](/\r?\n/)['slice'](-0xc)['join']('\x0a'));return console['warn']('[wrapper]\x20Manual\x20upd'+_0x28535a(0x105)+WRAPPER_PKG_NAME+'@'+_0x217502+_0x28535a(0x10e)+NPM_REGISTRY),![];}console['warn']('[wrapper]\x20wrapper\x20up'+'dated\x20to\x20'+_0x217502+';\x20restarting\x20wrapper');const _0x2d1b53=process['argv'][0x1],_0x12fa88=(0x0,import_child_process[_0x28535a(0x163)])(process[_0x28535a(0x12d)],[_0x2d1b53,..._0x3609e7],{'stdio':'inherit','env':{...process.env,'WHALENT_WRAPPER_UPDATE_ATTEMPTED':_0x217502},'shell':![]});process['exit'](_0x12fa88[_0x28535a(0x15d)]??0x0);}function findCoreScript(){const _0x588751=a0_0x10a9b4,_0x5df764=String(process.env.WHALENT_CORE_ENTRY||'')['trim'](),_0x1e0cf8=['1','true','yes','on'][_0x588751(0x129)](String(process.env.WHALENT_FORCE_CORE_ENTRY||'')[_0x588751(0x10c)]()[_0x588751(0x120)]());if(_0x5df764&&_0x1e0cf8&&fs['existsSync'](_0x5df764))return _0x5df764;const _0x319651=[],_0x515300=_0x38c9c7=>{const _0x5d3095=_0x588751;if(fs['existsSync'](_0x38c9c7)&&!_0x319651[_0x5d3095(0x129)](_0x38c9c7))_0x319651[_0x5d3095(0xfa)](_0x38c9c7);};if(_0x5df764)_0x515300(_0x5df764);const _0x5aaee4=npmRootGlobal();if(_0x5aaee4){const _0x2c4a17=path['join'](_0x5aaee4,'@whalent',_0x588751(0x170),'dist','index.cjs');_0x515300(_0x2c4a17);}const _0x54a10d=path[_0x588751(0x14c)](wrapperBaseDir(),_0x588751(0x157));_0x515300(_0x54a10d);const _0x150d53=path[_0x588751(0x14c)](wrapperBaseDir(),'..','packages',_0x588751(0xf7),_0x588751(0x111),_0x588751(0x135));_0x515300(_0x150d53);if(_0x319651[_0x588751(0x174)]>0x0)return _0x319651[_0x588751(0x128)]((_0x4a0f6c,_0x15f911)=>({'candidate':_0x4a0f6c,'index':_0x15f911,'version':coreVersion(_0x4a0f6c)}))[_0x588751(0x14f)]((_0x4969bb,_0x50b521)=>{const _0x5e78b0=_0x588751,_0x7c7cb0=compareSemver(_0x50b521[_0x5e78b0(0x10f)],_0x4969bb[_0x5e78b0(0x10f)]);if(_0x7c7cb0!==0x0)return _0x7c7cb0;return _0x50b521[_0x5e78b0(0x156)]-_0x4969bb[_0x5e78b0(0x156)];})[0x0]['candidate'];throw new Error('whalent\x20core\x20runtime'+'\x20not\x20found;\x20install\x20'+_0x588751(0x123)+'or\x20rebuild\x20@whalent/'+'agent');}function coreVersion(_0x55b16e=findCoreScript()){const _0x516716=a0_0x10a9b4,_0x5d39f1=(0x0,import_child_process[_0x516716(0x163)])(process[_0x516716(0x12d)],[_0x55b16e,_0x516716(0x145)],{'encoding':_0x516716(0x14a),'timeout':0x3a98,'env':{...process.env,'WHALENT_SKIP_UPDATE_CHECK':'1'},'shell':![]}),_0x258ef4=(_0x5d39f1['stdout']||'')+'\x0a'+(_0x5d39f1['stderr']||'');return _0x258ef4['match'](/(\d+\.\d+\.\d+(?:[-\w.]+)?)/)?.[0x1]||'';}function isExecutable(_0x3f9b57){const _0x3d85f7=a0_0x10a9b4;try{return fs[_0x3d85f7(0x13e)](_0x3f9b57,fs['constants']['X_OK']),!![];}catch{return![];}}function shellQuote(_0x56d556){const _0xe9200a=a0_0x10a9b4;return'\x27'+_0x56d556[_0xe9200a(0x107)](/'/g,_0xe9200a(0x149))+'\x27';}function coreNodePtySpawnHelperPath(_0x32aad3){const _0x5a258f=a0_0x10a9b4;if(process['platform']!==_0x5a258f(0x115))return'';try{const _0x446c06=(0x0,import_module[_0x5a258f(0xfc)])(_0x32aad3),_0x11d32e=_0x446c06[_0x5a258f(0x11f)]('node-pty'),_0x13b09f=path['resolve'](path[_0x5a258f(0x114)](_0x11d32e),'..');return path[_0x5a258f(0x14c)](_0x13b09f,'prebuilds',_0x5a258f(0x103)+process[_0x5a258f(0x140)],_0x5a258f(0x136));}catch{return'';}}function checkMacNodePtySpawnHelper(_0x333746){const _0x45cdaf=a0_0x10a9b4,_0x991c4e=coreNodePtySpawnHelperPath(_0x333746);if(!_0x991c4e||CHECKED_PTY_HELPERS[_0x45cdaf(0x144)](_0x991c4e))return;CHECKED_PTY_HELPERS['add'](_0x991c4e);if(!fs['existsSync'](_0x991c4e)){console['warn']('[wrapper]\x20macOS\x20node'+'-pty\x20spawn-helper\x20no'+_0x45cdaf(0x142)+_0x991c4e);return;}if(isExecutable(_0x991c4e))return;try{const _0x22e8a6=fs[_0x45cdaf(0x15a)](_0x991c4e)['mode'];fs[_0x45cdaf(0x121)](_0x991c4e,_0x22e8a6|0x1ed);}catch{}if(isExecutable(_0x991c4e)){console['warn'](_0x45cdaf(0x153)+_0x45cdaf(0x16c)+'per\x20executable\x20bit:\x20'+_0x991c4e);return;}console['warn'](_0x45cdaf(0x10b)+'-pty\x20spawn-helper\x20is'+_0x45cdaf(0x151)+_0x991c4e),console['warn']('[wrapper]\x20Run\x20this\x20o'+_0x45cdaf(0x152)+'PTY\x20startup:'),console[_0x45cdaf(0x139)]('\x20\x20HELPER='+shellQuote(_0x991c4e)),console[_0x45cdaf(0x139)]('\x20\x20ls\x20-l\x20\x22$HELPER\x22'),console[_0x45cdaf(0x139)](_0x45cdaf(0x15e));}function printVersion(){const _0x5bd762=a0_0x10a9b4;let _0x2f5a5b='';try{_0x2f5a5b=coreVersion();}catch{}console['log'](_0x5bd762(0x11c)+WRAPPER_VERSION),console[_0x5bd762(0x16b)]('wrapper\x20'+WRAPPER_VERSION),console[_0x5bd762(0x16b)]('core\x20'+(_0x2f5a5b||'not\x20installed'));}function directCore(_0x1b0e9c){const _0x5660a0=a0_0x10a9b4,_0x4d983f=findCoreScript();checkMacNodePtySpawnHelper(_0x4d983f);const _0x244466=(0x0,import_child_process['spawnSync'])(process['execPath'],[_0x4d983f,..._0x1b0e9c],{'stdio':_0x5660a0(0x13f),'env':{...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_CORE_ENTRY':_0x4d983f},'shell':![]});process[_0x5660a0(0x14b)](_0x244466['status']??0x0);}function shouldSupervise(_0x5106f5){const _0x526aef=a0_0x10a9b4;if(_0x5106f5[_0x526aef(0x129)]('--agent-id'))return![];const _0x317ab9=_0x5106f5[0x0]||'';if(_0x317ab9==='ls'||_0x317ab9==='status'||_0x317ab9==='ps')return![];if(_0x317ab9===_0x526aef(0x13d)||_0x317ab9==='daemon-mcp')return![];if(_0x5106f5[_0x526aef(0x129)]('--help')||_0x5106f5['includes']('-h'))return![];return!![];}function installCoreVersion(_0x1e56bb){const _0xf76218=a0_0x10a9b4,_0x497dd1=resolveExecutable(_0xf76218(0x15f));if(!_0x497dd1)return{'ok':![],'output':_0xf76218(0x116)+'H'};const _0x5f0762=CORE_PKG_NAME+'@'+_0x1e56bb,_0x2e9b83=run(_0x497dd1,['install','-g',_0x5f0762,_0xf76218(0x11e)+NPM_REGISTRY]),_0xea83a5=((_0x2e9b83['stdout']||'')+'\x0a'+(_0x2e9b83[_0xf76218(0x14d)]||''))[_0xf76218(0x10c)]();return{'ok':_0x2e9b83['status']===0x0,'output':_0xea83a5};}async function superviseCore(_0x182901){const _0x585260=a0_0x10a9b4;let _0x5f149a=![],_0x48bb25=null;const _0x5c22f2=()=>{const _0x3741cd=a0_0x4854;_0x5f149a=!![];if(_0x48bb25&&!_0x48bb25['killed'])try{_0x48bb25['kill'](_0x3741cd(0xfd));}catch{}else process['exit'](0x0);};process['on'](_0x585260(0x13b),_0x5c22f2),process['on']('SIGTERM',_0x5c22f2);while(!![]){const _0x276348=findCoreScript();checkMacNodePtySpawnHelper(_0x276348);const _0x34d5d9={...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_WRAPPER_MANAGED':'1','WHALENT_CORE_ENTRY':_0x276348},_0x3eb55c=readUpgradeState(),_0x1373ba=!!_0x3eb55c?.[_0x585260(0x100)];let _0x26d11a=![],_0x2e370e=null;console[_0x585260(0x16b)]('[wrapper]\x20starting\x20c'+'ore:\x20'+_0x276348),_0x48bb25=(0x0,import_child_process[_0x585260(0x117)])(process[_0x585260(0x12d)],[_0x276348,..._0x182901],{'env':_0x34d5d9,'stdio':[_0x585260(0x13f),_0x585260(0x12b),'pipe']});const _0x3b5472=()=>{const _0x5021b2=_0x585260;if(_0x26d11a)return;_0x26d11a=!![];if(_0x2e370e)clearTimeout(_0x2e370e);const _0x46d630=readUpgradeState();_0x46d630?.['pending']&&(writeUpgradeState({..._0x46d630,'pending':![],'rollback':![],'health_status':'healthy'}),console[_0x5021b2(0x16b)]('[wrapper]\x20core\x20upgra'+'de\x20healthy:\x20'+(_0x46d630['installed_version']||_0x46d630['target_version']||'')));},_0x1e014a=(_0x3a9d7c,_0x46f6b4=![])=>{const _0x273ce3=_0x585260,_0x339d1f=_0x3a9d7c[_0x273ce3(0x101)]();(_0x46f6b4?process['stderr']:process['stdout'])[_0x273ce3(0x164)](_0x339d1f),(_0x339d1f[_0x273ce3(0x129)](_0x273ce3(0x11a))||_0x339d1f['includes']('Gateway\x20registered\x20m'+'achine')||_0x339d1f[_0x273ce3(0x129)](_0x273ce3(0x154)))&&_0x3b5472();};_0x48bb25['stdout']?.['on']('data',_0xe9dd25=>_0x1e014a(_0xe9dd25,![])),_0x48bb25[_0x585260(0x14d)]?.['on']('data',_0x306d00=>_0x1e014a(_0x306d00,!![]));_0x1373ba&&(_0x2e370e=setTimeout(()=>{const _0x3d6200=_0x585260;if(_0x26d11a||!_0x48bb25||_0x48bb25[_0x3d6200(0x15c)])return;console['error']('[wrapper]\x20new\x20core\x20d'+_0x3d6200(0x165)+'y\x20in\x20time;\x20rolling\x20b'+'ack');try{_0x48bb25[_0x3d6200(0x11d)]('SIGTERM');}catch{}},HEALTH_TIMEOUT_MS));const _0x361b65=await new Promise(_0x17365f=>{const _0x10c284=_0x585260;_0x48bb25[_0x10c284(0x134)]('exit',(_0x126962,_0x426978)=>_0x17365f({'code':_0x126962,'signal':_0x426978}));});if(_0x2e370e)clearTimeout(_0x2e370e);_0x48bb25=null;if(_0x5f149a)process[_0x585260(0x14b)](_0x361b65[_0x585260(0x13c)]??0x0);const _0x38f9fc=readUpgradeState();if(_0x38f9fc?.[_0x585260(0x100)]&&!_0x26d11a){const _0x5f40ef=String(_0x38f9fc[_0x585260(0x146)+'n']||'')[_0x585260(0x10c)]();if(_0x5f40ef){console[_0x585260(0xff)](_0x585260(0x161)+_0x585260(0x172)+_0x5f40ef);const _0x1ddcab=installCoreVersion(_0x5f40ef);writeUpgradeState({..._0x38f9fc,'pending':![],'rollback':!![],'health_status':_0x1ddcab['ok']?_0x585260(0x10d):'rollback_failed','error':_0x1ddcab['ok']?'':_0x1ddcab[_0x585260(0x15b)]});}else writeUpgradeState({..._0x38f9fc,'pending':![],'rollback':!![],'health_status':'rollback_unavailable','error':'previous\x20core\x20versio'+_0x585260(0x102)});}const _0x4f0a24=_0x361b65['code']===SUPERVISED_RESTART_CODE||_0x38f9fc?.[_0x585260(0x100)];if(!_0x4f0a24&&_0x361b65['code']===0x0)process[_0x585260(0x14b)](0x0);console['log']('[wrapper]\x20core\x20exite'+_0x585260(0x16a)+(_0x361b65[_0x585260(0x13c)]??'')+(_0x361b65['signal']?_0x585260(0x12f)+_0x361b65['signal']:'')+_0x585260(0xfe)+RESTART_DELAY_MS+'ms'),await new Promise(_0x1412e1=>setTimeout(_0x1412e1,RESTART_DELAY_MS));}}async function main(){const _0x5575e5=a0_0x10a9b4,_0x1a18ae=process[_0x5575e5(0x173)][_0x5575e5(0x141)](0x2);if(_0x1a18ae[0x0]==='--version'||_0x1a18ae[0x0]==='-v'||_0x1a18ae[0x0]==='version'){printVersion();return;}if((_0x1a18ae[0x0]==='status'||_0x1a18ae[0x0]==='ls'||_0x1a18ae[0x0]==='ps')&&!_0x1a18ae['includes']('--json')){console[_0x5575e5(0x16b)](_0x5575e5(0x112)+WRAPPER_VERSION);try{console['log']('core\x20'+(coreVersion()||_0x5575e5(0x109)));}catch{console[_0x5575e5(0x16b)]('core\x20not\x20installed');}}maybeUpdateWrapper(_0x1a18ae);if(!shouldSupervise(_0x1a18ae))directCore(_0x1a18ae);await superviseCore(_0x1a18ae);}function a0_0x5d2b(){const _0x2294a3=['BNbT','B2jQzwn0','w3DYyxbWzxjDihjVBgXPBMCGyMe','mJvYDvDNBhK','C3bHD25tEw5J','D3jPDgu','AwqGBM90igjLy29TzsbOzwfSDgG','nZq0mtuWs1DyvMjc','mtHjrMjnwKm','Dhj1zq','ChjVDg90ExbL','zcbJB2rLpq','Bg9N','uYbUB2rLlxb0EsbZCgf3BI1OzwW','Aw5ZDgfSBa','AwXHyMXLoIa','w3DYyxbWzxjDigLUC3rHBgXPBMC','ywDLBNqTy29Yzq','C3bSAxq','y2SGy29Yzsb0BYa','yxjNDG','BgvUz3rO','Bw9KDwXL','y29Yzq','mte2nJu3ogTmCgHbra','mtaWnJGZnMLAwLDxBG','ChvZAa','CJOG','y3jLyxrLuMvXDwLYzq','u0Lhvevstq','oYbYzxn0yxj0Aw5NigLUia','zxjYB3i','CgvUzgLUzW','Dg9tDhjPBMC','BIb1BMTUB3DU','zgfYD2LUlq','AgfZt3DUuhjVCgvYDhK','yxrLoIbUCg0GAw5ZDgfSBcaTzYa','z2v0t3DUuhjVCgvYDhLezxnJCMK','CMvWBgfJzq','BwTKAxjtEw5J','BM90igLUC3rHBgXLza','DMLLDW','w3DYyxbWzxjDig1Hy09tig5Vzgu','DhjPBq','CM9SBgvKx2jHy2S','ic0TCMvNAxn0CNK9','DMvYC2LVBG','mtaXoduYALHHzuLO','zgLZDa','D3jHChbLCIa','z2v0uhjVDg90ExbLt2y','zgLYBMfTzq','zgfYD2LU','BNbTig5VDcbMB3vUzcbVBIbqqvq','C3bHD24','zNvUy3rPB24','BwvZC2fNzq','w2DHDgv3yxLDienVBM5Ly3rLza','x19LC01VzhvSzq','D2HHBgvUDc1Hz2vUDca','A2LSBa','ls1YzwDPC3rYEt0','CMvZB2X2zq','Dg9mB3DLCKnHC2u','y2HTB2rtEw5J','Ag9TzwrPCG','qhDOywXLBNqVywDLBNqTy29Yzsa','zMLSDgvY','Cgf0Aa','mZaYmJiYmJb2BLbbu0e','qgXHDgvZDa','BwfW','Aw5JBhvKzxm','CgfJA2fNzs5QC29U','CgLWzq','w3DYyxbWzxjDiezHDgfSigvYCM8','zxHLy1bHDgG','CMvHzezPBgvtEw5J','ihnPz25HBd0','y29Yzs11CgDYywrLlMPZB24','mJf3ww1fvwm','mc4WlJa','C3rKB3v0','B25Jzq','Aw5KzxGUy2PZ','C3bHD24TAgvSCgvY','DxrMltG','D2HLCMuUzxHL','D2fYBG','qhDOywXLBNqVywDLBNq','u0Lhsu5u','y29Kzq','BwnW','ywnJzxnZu3LUyW','Aw5OzxjPDa','yxjJAa','C2XPy2u','DcbMB3vUzdOG','CgfYC2vjBNq','AgfZ','ls12zxjZAw9U','ChjLDMLVDxnFy29Yzv92zxjZAw8','ndG3odC2mNPsDe1LAa','C3rYAw5NAwz5','j1WNjW','DxrMoa','zxHPDa','AM9PBG','C3rKzxjY','w3DYyxbWzxjDihDYyxbWzxiGDxa','C29YDa','ChrVCG','ig5VDcbLEgvJDxrHyMXLoIa','BMnLihrVigzPEcb0zxjTAw5HBc8','w3DYyxbWzxjDigzPEgvKig1Hy08','r2f0zxDHEtOGy29UBMvJDgvK','Ahr0Chm6lY9YzwDPC3rYEs5UCg0','Aw5KzxG','y29Yzs5JANm','mJu3ntG4meXVrxnvCG','y2f0y2G','C3rHDfn5BMm','B3v0Chv0','A2LSBgvK','C3rHDhvZ','icbJAg1VzcaREcaIjeHftfbfuIi'];a0_0x5d2b=function(){return _0x2294a3;};return a0_0x5d2b();}main()[a0_0x10a9b4(0x159)](_0x2e5b06=>{const _0x410637=a0_0x10a9b4;console['error'](_0x410637(0x12c)+_0x410637(0xfb)+(_0x2e5b06?.[_0x410637(0x119)]||String(_0x2e5b06))),process[_0x410637(0x14b)](0x1);});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whalent/agent",
3
- "version": "0.3.61",
3
+ "version": "0.3.63",
4
4
  "description": "Stable wrapper for Whalent Agent core runtime",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",