@whalent/agent 0.3.66 → 0.3.67

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_0xeb103c=a0_0x2b2a;(function(_0xec8f14,_0x5f1557){const _0x2d2ecc=a0_0x2b2a,_0x33b90a=_0xec8f14();while(!![]){try{const _0x2ea136=-parseInt(_0x2d2ecc(0x1ba))/0x1*(parseInt(_0x2d2ecc(0x1e6))/0x2)+parseInt(_0x2d2ecc(0x1e4))/0x3+parseInt(_0x2d2ecc(0x1f0))/0x4+-parseInt(_0x2d2ecc(0x1c6))/0x5*(-parseInt(_0x2d2ecc(0x1ea))/0x6)+-parseInt(_0x2d2ecc(0x182))/0x7*(parseInt(_0x2d2ecc(0x197))/0x8)+parseInt(_0x2d2ecc(0x1e3))/0x9*(-parseInt(_0x2d2ecc(0x1c0))/0xa)+parseInt(_0x2d2ecc(0x196))/0xb;if(_0x2ea136===_0x5f1557)break;else _0x33b90a['push'](_0x33b90a['shift']());}catch(_0x520dea){_0x33b90a['push'](_0x33b90a['shift']());}}}(a0_0x2180,0x771e1));var __create=Object['create'],__defProp=Object[a0_0xeb103c(0x1a7)],__getOwnPropDesc=Object[a0_0xeb103c(0x1d2)+'ptor'],__getOwnPropNames=Object[a0_0xeb103c(0x17e)],__getProtoOf=Object[a0_0xeb103c(0x1a8)],__hasOwnProp=Object[a0_0xeb103c(0x19e)][a0_0xeb103c(0x1d5)],__copyProps=(_0x596e77,_0x1348b3,_0x4b7825,_0x230c4f)=>{if(_0x1348b3&&typeof _0x1348b3==='object'||typeof _0x1348b3==='function'){for(let _0x4db399 of __getOwnPropNames(_0x1348b3))if(!__hasOwnProp['call'](_0x596e77,_0x4db399)&&_0x4db399!==_0x4b7825)__defProp(_0x596e77,_0x4db399,{'get':()=>_0x1348b3[_0x4db399],'enumerable':!(_0x230c4f=__getOwnPropDesc(_0x1348b3,_0x4db399))||_0x230c4f['enumerable']});}return _0x596e77;},__toESM=(_0x3490d1,_0xc7fce8,_0x4a2927)=>(_0x4a2927=_0x3490d1!=null?__create(__getProtoOf(_0x3490d1)):{},__copyProps(_0xc7fce8||!_0x3490d1||!_0x3490d1[a0_0xeb103c(0x1c2)]?__defProp(_0x4a2927,'default',{'value':_0x3490d1,'enumerable':!![]}):_0x4a2927,_0x3490d1)),import_child_process=require(a0_0xeb103c(0x1b6)),fs=__toESM(require('fs'),0x1),import_module=require('module'),os=__toESM(require('os'),0x1),path=__toESM(require('path'),0x1),WRAPPER_PKG_NAME='@whalent/agent',CORE_PKG_NAME='@whalent/agent-core',NPM_REGISTRY=a0_0xeb103c(0x18d)+'js.org',SUPERVISED_RESTART_CODE=0x4b,NPM_VIEW_TIMEOUT_MS=0x3a98,HEALTH_TIMEOUT_MS=0xafc8,MIN_RESTART_DELAY_MS=0x3e8,MAX_RESTART_DELAY_MS=0xea60,NPM_INSTALL_TIMEOUT_MS=0xa*0x3c*0x3e8,NPM_INSTALL_MAX_BUFFER=0x20*0x400*0x400,FATAL_PATTERN=/\[(?:agent|daemon|wrapper)\][^\n]*\bFatal error:[^\n]+|\[daemon\] Failed to start:[^\n]+|ENOSPC:[^\n]+|EACCES:[^\n]+|EPERM:[^\n]+|EAGAIN:[^\n]+|EMFILE:[^\n]+/,WRAPPER_VERSION=readWrapperVersion(),CHECKED_PTY_HELPERS=new Set();function wrapperBaseDir(){return __dirname;}function configDir(){const _0x5902db=a0_0xeb103c;return path['join'](os['homedir'](),_0x5902db(0x1af));}function upgradeStatePath(){return path['join'](configDir(),'core-upgrade.json');}function lastCrashFilePath(){const _0x2a27f0=a0_0xeb103c;return path[_0x2a27f0(0x187)](configDir(),_0x2a27f0(0x1a4));}function writeLastCrash(_0x5bba7b){const _0x3f84fb=a0_0xeb103c;try{fs[_0x3f84fb(0x1ac)](configDir(),{'recursive':!![]});const _0x3fdbab={..._0x5bba7b,'reported':![]};fs[_0x3f84fb(0x18e)](lastCrashFilePath(),JSON['stringify'](_0x3fdbab,null,0x2),'utf-8');}catch{}}function readWrapperVersion(){const _0x8cacaf=a0_0xeb103c;try{const _0x6041b2=JSON['parse'](fs['readFileSync'](path[_0x8cacaf(0x187)](wrapperBaseDir(),'..','package.json'),_0x8cacaf(0x1ca)));return String(_0x6041b2['version']||'0.0.0');}catch{return _0x8cacaf(0x1e5);}}function readUpgradeState(){const _0x2470ad=a0_0xeb103c;try{return JSON[_0x2470ad(0x18c)](fs['readFileSync'](upgradeStatePath(),'utf-8'));}catch{return null;}}function writeUpgradeState(_0x11fdf1){const _0x5c71d3=a0_0xeb103c;try{fs[_0x5c71d3(0x1ac)](configDir(),{'recursive':!![]}),fs[_0x5c71d3(0x18e)](upgradeStatePath(),JSON['stringify']({..._0x11fdf1,'updated_at':Date['now']()},null,0x2),_0x5c71d3(0x1ca));}catch{}}function run(_0x2c0a6a,_0xfa365b,_0x9c1e90=process.env){const _0x1bea60=a0_0xeb103c;return(0x0,import_child_process[_0x1bea60(0x1d1)])(_0x2c0a6a,_0xfa365b,{'encoding':'utf8','timeout':NPM_INSTALL_TIMEOUT_MS,'maxBuffer':NPM_INSTALL_MAX_BUFFER,'env':_0x9c1e90,'shell':![]});}function runNpmView(_0x125d58){const _0x4f82e6=a0_0xeb103c,_0x51557f=resolveExecutable(_0x4f82e6(0x1c7));if(!_0x51557f)return{'status':0x7f,'stdout':'','stderr':'npm\x20not\x20found','error':new Error(_0x4f82e6(0x185))};return(0x0,import_child_process[_0x4f82e6(0x1d1)])(_0x51557f,_0x125d58,{'encoding':'utf8','timeout':NPM_VIEW_TIMEOUT_MS,'maxBuffer':0x400*0x400,'env':process.env,'shell':![]});}function npmRootGlobal(){const _0x7de7e4=a0_0xeb103c,_0x35ab67=resolveExecutable('npm');if(!_0x35ab67)return'';const _0x5e59a0=run(_0x35ab67,['root','-g']);if(_0x5e59a0[_0x7de7e4(0x1b9)]!==0x0)return'';return String(_0x5e59a0['stdout']||'')[_0x7de7e4(0x1b1)]();}function compareSemver(_0x5f0d96,_0x8b481e){const _0x2b3cc3=a0_0xeb103c,_0x258c8a=String(_0x5f0d96||'')[_0x2b3cc3(0x19f)](/^v/,'')['split'](/[.-]/)['map'](_0x35251a=>Number['parseInt'](_0x35251a,0xa)||0x0),_0x394d62=String(_0x8b481e||'')[_0x2b3cc3(0x19f)](/^v/,'')['split'](/[.-]/)['map'](_0x58834b=>Number[_0x2b3cc3(0x1e9)](_0x58834b,0xa)||0x0);for(let _0x3ab6a9=0x0;_0x3ab6a9<Math['max'](_0x258c8a['length'],_0x394d62[_0x2b3cc3(0x1dd)],0x3);_0x3ab6a9++){const _0x118ba6=_0x258c8a[_0x3ab6a9]||0x0,_0x44fc4f=_0x394d62[_0x3ab6a9]||0x0;if(_0x118ba6>_0x44fc4f)return 0x1;if(_0x118ba6<_0x44fc4f)return-0x1;}return 0x0;}function resolveExecutable(_0xb75313){const _0x2c704e=a0_0xeb103c,_0x54cf9d=process[_0x2c704e(0x1cc)]===_0x2c704e(0x199)?_0x2c704e(0x192):'which';try{const _0x4c3c3d=(0x0,import_child_process['spawnSync'])(_0x54cf9d,[_0xb75313],{'encoding':_0x2c704e(0x19d),'timeout':0xbb8,'shell':![]});if(_0x4c3c3d['status']!==0x0)return'';return String(_0x4c3c3d['stdout']||'')['split'](/\r?\n/)[_0x2c704e(0x1bc)](_0x428ef9=>_0x428ef9[_0x2c704e(0x1b1)]())[_0x2c704e(0x1da)](Boolean)[0x0]||'';}catch{return'';}}function skipWrapperUpdateCheck(){const _0x4108c4=a0_0xeb103c,_0x23ee08=String(process.env.WHALENT_SKIP_UPDATE_CHECK||process.env.WHALENT_NO_UPDATE_CHECK||process.env.WHALENT_SKIP_WRAPPER_UPDATE||'')['trim']()[_0x4108c4(0x1cb)]();return _0x23ee08==='1'||_0x23ee08===_0x4108c4(0x18b)||_0x23ee08==='yes'||_0x23ee08==='on';}function latestWrapperVersion(){const _0x132c1a=a0_0xeb103c,_0x518ada=runNpmView(['view',WRAPPER_PKG_NAME+'@latest','version',_0x132c1a(0x191)+NPM_REGISTRY]);if(_0x518ada['status']!==0x0)return'';return String(_0x518ada['stdout']||'')[_0x132c1a(0x1b1)]()['split'](/\r?\n/)[_0x132c1a(0x1da)](Boolean)['pop']()||'';}function installWrapperVersion(_0x27c63f){const _0x31d367=a0_0xeb103c,_0x3d5744=resolveExecutable('npm');if(!_0x3d5744)return{'ok':![],'output':'npm\x20not\x20found\x20on\x20PAT'+'H'};const _0x5d844e=run(_0x3d5744,[_0x31d367(0x184),'-g',WRAPPER_PKG_NAME+'@'+_0x27c63f,'--registry='+NPM_REGISTRY]),_0x3a1309=((_0x5d844e[_0x31d367(0x1e2)]||'')+'\x0a'+(_0x5d844e[_0x31d367(0x1eb)]||''))['trim']();return{'ok':_0x5d844e['status']===0x0,'output':_0x3a1309};}function maybeUpdateWrapper(_0x55a240){const _0x35a1e8=a0_0xeb103c;if(skipWrapperUpdateCheck())return![];if(process.env.WHALENT_WRAPPER_UPDATE_ATTEMPTED)return![];const _0x150129=latestWrapperVersion();if(!_0x150129||compareSemver(_0x150129,WRAPPER_VERSION)<=0x0)return![];console[_0x35a1e8(0x1c9)]('[wrapper]\x20update\x20ava'+_0x35a1e8(0x194)+WRAPPER_VERSION+'\x20->\x20'+_0x150129),console[_0x35a1e8(0x1c9)]('[wrapper]\x20installing'+'\x20'+WRAPPER_PKG_NAME+'@'+_0x150129+('\x20from\x20npm\x20before\x20sta'+_0x35a1e8(0x1d0)));const _0x181b22=installWrapperVersion(_0x150129);if(!_0x181b22['ok']){console[_0x35a1e8(0x1c9)]('[wrapper]\x20wrapper\x20up'+'date\x20failed;\x20continu'+_0x35a1e8(0x1ab)+WRAPPER_VERSION);if(_0x181b22['output'])console[_0x35a1e8(0x1c9)](_0x181b22[_0x35a1e8(0x1e0)]['split'](/\r?\n/)[_0x35a1e8(0x1b3)](-0xc)['join']('\x0a'));return console[_0x35a1e8(0x1c9)]('[wrapper]\x20Manual\x20upd'+'ate:\x20npm\x20install\x20-g\x20'+WRAPPER_PKG_NAME+'@'+_0x150129+'\x20--registry='+NPM_REGISTRY),![];}console[_0x35a1e8(0x1c9)]('[wrapper]\x20wrapper\x20up'+_0x35a1e8(0x1e8)+_0x150129+';\x20restarting\x20wrapper');const _0x38accb=process['argv'][0x1],_0x69f076=(0x0,import_child_process['spawnSync'])(process['execPath'],[_0x38accb,..._0x55a240],{'stdio':'inherit','env':{...process.env,'WHALENT_WRAPPER_UPDATE_ATTEMPTED':_0x150129},'shell':![]});process['exit'](_0x69f076['status']??0x0);}function findCoreScript(){const _0xd4f2ea=a0_0xeb103c,_0x26a7a5=String(process.env.WHALENT_CORE_ENTRY||'')['trim'](),_0x4510e3=['1',_0xd4f2ea(0x18b),'yes','on']['includes'](String(process.env.WHALENT_FORCE_CORE_ENTRY||'')[_0xd4f2ea(0x1b1)]()['toLowerCase']());if(_0x26a7a5&&_0x4510e3&&fs['existsSync'](_0x26a7a5))return _0x26a7a5;const _0x38585f=[],_0x1f88f2=_0xcaa214=>{const _0x5019f8=_0xd4f2ea;if(fs[_0x5019f8(0x181)](_0xcaa214)&&!_0x38585f[_0x5019f8(0x1c3)](_0xcaa214))_0x38585f[_0x5019f8(0x1ad)](_0xcaa214);};if(_0x26a7a5)_0x1f88f2(_0x26a7a5);const _0x1e1f53=npmRootGlobal();if(_0x1e1f53){const _0x52e18d=path['join'](_0x1e1f53,_0xd4f2ea(0x1a0),_0xd4f2ea(0x180),'dist',_0xd4f2ea(0x1b7));_0x1f88f2(_0x52e18d);}const _0x20f803=path[_0xd4f2ea(0x187)](wrapperBaseDir(),'core.cjs');_0x1f88f2(_0x20f803);const _0x4f529c=path[_0xd4f2ea(0x187)](wrapperBaseDir(),'..','packages','core',_0xd4f2ea(0x17d),_0xd4f2ea(0x1b7));_0x1f88f2(_0x4f529c);if(_0x38585f['length']>0x0)return _0x38585f[_0xd4f2ea(0x1bc)]((_0x116a2d,_0x1ba183)=>({'candidate':_0x116a2d,'index':_0x1ba183,'version':coreVersion(_0x116a2d)}))['sort']((_0x5bb20b,_0x1f763b)=>{const _0x1882d6=_0xd4f2ea,_0x56fabc=compareSemver(_0x1f763b[_0x1882d6(0x1d9)],_0x5bb20b['version']);if(_0x56fabc!==0x0)return _0x56fabc;return _0x1f763b[_0x1882d6(0x1ed)]-_0x5bb20b[_0x1882d6(0x1ed)];})[0x0][_0xd4f2ea(0x195)];throw new Error('whalent\x20core\x20runtime'+_0xd4f2ea(0x18f)+'@whalent/agent-core\x20'+'or\x20rebuild\x20@whalent/'+'agent');}function a0_0x2180(){const _0x38ea39=['ywrK','mtiZotG1meLtrejfsW','BwnW','x19LC01VzhvSzq','Aw5JBhvKzxm','BM90igLUC3rHBgXLza','w3DYyxbWzxjDifj1BIb0AgLZig8','nxPgB1j5Ea','BNbT','ChjLyNvPBgrZ','D2fYBG','DxrMltG','Dg9mB3DLCKnHC2u','CgXHDgzVCM0','w3DYyxbWzxjDig1Hy09tig5Vzgu','w3DYyxbWzxjDiezHDgfSigvYCM8','A2LSBa','CNrPBMCGy29Yzs4UlG','C3bHD25tEw5J','z2v0t3DUuhjVCgvYDhLezxnJCMK','l3bLCM1PC3nPB25ZigjLzM9Yzsa','w3DYyxbWzxjDignVCMuGDxbNCMe','AgfZt3DUuhjVCgvYDhK','zxHPDa','C2LNBMfS','ywnR','DMvYC2LVBG','zMLSDgvY','w3DYyxbWzxjDig5LDYbJB3jLigq','ls12zxjZAw9U','BgvUz3rO','CgvUzgLUzW','Bwf0y2G','B3v0Chv0','zgf0yq','C3rKB3v0','nJnhwxjXA0m','mZi3mtu5y2TVugfH','mc4WlJa','nNL3qwDREa','BMnLihrVigzPEcb0zxjTAw5HBc8','zgf0zwqGDg8G','CgfYC2vjBNq','mJe3nduYnMHotxfYvW','C3rKzxjY','CM9SBgvKx2jHy2S','Aw5KzxG','j1WNjW','ywnJzxnZu3LUyW','mtu1ndaYogzsy0rNCW','zxHLy1bHDgG','w3DYyxbWzxjDihn0yxj0Aw5Nigm','y2HTB2rtEw5J','zxjYB3i','u0Lhsu5u','BwvZC2fNzq','BIb1BMTUB3DU','C3bHD24','CgLWzq','y29Yzsa','lxb0EsbZCgf3BI1OzwXWzxiGBM8','zgLZDa','z2v0t3DUuhjVCgvYDhLoyw1LCW','yxjNDG','ywDLBNqTy29Yzq','zxHPC3rZu3LUyW','mtmWndq1CxrmBvzb','D3jPDgu','Aw5ZDgfSBa','BNbTig5VDcbMB3vUza','r2f0zxDHEsbYzwDPC3rLCMvKig0','AM9PBG','Aw5ZDgfSBgvKx3zLCNnPB24','ls1QC29U','CMv0CNLPBMC','Dhj1zq','CgfYC2u','Ahr0Chm6lY9YzwDPC3rYEs5UCg0','D3jPDgvgAwXLu3LUyW','ig5VDcbMB3vUzdSGAw5ZDgfSBca','y29Kzq','ls1YzwDPC3rYEt0','D2HLCMuUzxHL','zcbJB2rLpq','AwXHyMXLoIa','y2fUzgLKyxrL','mte5mtyWmdn2BMvuu04','mtiWDvjVzgjf','C2HPzNq','D2LUmZi','ihnPz25HBd0','zgfLBw9Ulw1JCa','ChjLDMLVDxmGy29Yzsb2zxjZAw8','DxrMoa','ChjVDg90ExbL','CMvWBgfJzq','qhDOywXLBNq','AgvHBhrOEq','CMvZB2X2zq','y2SGy29Yzsb0BYa','BgfZDc1JCMfZAc5QC29U','ChjLDMLVDxnFy29Yzv92zxjZAw8','zgfYD2LUlq','zgvMAw5LuhjVCgvYDhK','z2v0uhjVDg90ExbLt2y','Aw5OzxjPDa','icbSCYaTBcaIjeHftfbfuIi','Aw5NihDPDgGG','BwTKAxjtEw5J','ChvZAa','y3jLyxrLuMvXDwLYzq','lNDOywXLBNqTywDLBNq','BM9Kzs1WDhK','DhjPBq','ls1OzwXW','C2XPy2u','B25Jzq','EsbPBIb0Aw1LoYbYB2XSAw5Nigi','y2HPBgrFChjVy2vZCW','Aw5KzxGUy2PZ','Bg9N','C3rHDhvZ','mtaYnJqZENDKsuTm','ls1Hz2vUDc1Pza','BwfW','w3DYyxbWzxjDignVCMuGAgfZigm','lxb0EsbZCgf3BI1OzwXWzxiGAxm'];a0_0x2180=function(){return _0x38ea39;};return a0_0x2180();}function coreVersion(_0x113007=findCoreScript()){const _0x122de7=a0_0xeb103c,_0x2d46e8=(0x0,import_child_process[_0x122de7(0x1d1)])(process[_0x122de7(0x1f1)],[_0x113007,_0x122de7(0x1dc)],{'encoding':_0x122de7(0x19d),'timeout':0x3a98,'env':{...process.env,'WHALENT_SKIP_UPDATE_CHECK':'1'},'shell':![]}),_0x2b31d6=(_0x2d46e8['stdout']||'')+'\x0a'+(_0x2d46e8[_0x122de7(0x1eb)]||'');return _0x2b31d6[_0x122de7(0x1df)](/(\d+\.\d+\.\d+(?:[-\w.]+)?)/)?.[0x1]||'';}function isExecutable(_0x255c35){const _0x141567=a0_0xeb103c;try{return fs[_0x141567(0x1ef)](_0x255c35,fs['constants']['X_OK']),!![];}catch{return![];}}function shellQuote(_0x4f610c){const _0x50c040=a0_0xeb103c;return'\x27'+_0x4f610c['replace'](/'/g,_0x50c040(0x1ee))+'\x27';}function coreNodePtySpawnHelperPath(_0x24f40c){const _0x572772=a0_0xeb103c;if(process[_0x572772(0x1cc)]!=='darwin')return'';try{const _0x180e5d=(0x0,import_module[_0x572772(0x1ae)])(_0x24f40c),_0x2b3ae4=_0x180e5d[_0x572772(0x1a2)](_0x572772(0x1b0)),_0x176d2e=path[_0x572772(0x1a2)](path['dirname'](_0x2b3ae4),'..');return path[_0x572772(0x187)](_0x176d2e,_0x572772(0x1c8),_0x572772(0x1a6)+process['arch'],'spawn-helper');}catch{return'';}}function checkMacNodePtySpawnHelper(_0x55fc9b){const _0xbfd4e5=a0_0xeb103c,_0x2e976f=coreNodePtySpawnHelperPath(_0x55fc9b);if(!_0x2e976f||CHECKED_PTY_HELPERS['has'](_0x2e976f))return;CHECKED_PTY_HELPERS[_0xbfd4e5(0x1bf)](_0x2e976f);if(!fs[_0xbfd4e5(0x181)](_0x2e976f)){console[_0xbfd4e5(0x1c9)]('[wrapper]\x20macOS\x20node'+_0xbfd4e5(0x1fb)+'t\x20found:\x20'+_0x2e976f);return;}if(isExecutable(_0x2e976f))return;try{const _0x3b5e0c=fs['statSync'](_0x2e976f)['mode'];fs[_0xbfd4e5(0x1f3)](_0x2e976f,_0x3b5e0c|0x1ed);}catch{}if(isExecutable(_0x2e976f)){console[_0xbfd4e5(0x1c9)]('[wrapper]\x20fixed\x20macO'+'S\x20node-pty\x20spawn-hel'+'per\x20executable\x20bit:\x20'+_0x2e976f);return;}console['warn'](_0xbfd4e5(0x1cd)+_0xbfd4e5(0x1be)+'\x20not\x20executable:\x20'+_0x2e976f),console['warn'](_0xbfd4e5(0x1c5)+_0xbfd4e5(0x1e7)+'PTY\x20startup:'),console[_0xbfd4e5(0x1c9)]('\x20\x20HELPER='+shellQuote(_0x2e976f)),console[_0xbfd4e5(0x1c9)](_0xbfd4e5(0x1aa)),console['warn']('\x20\x20chmod\x20+x\x20\x22$HELPER\x22');}function printVersion(){const _0x4f539c=a0_0xeb103c;let _0x13dd3c='';try{_0x13dd3c=coreVersion();}catch{}console[_0x4f539c(0x1b8)]('whalent-agent\x20'+WRAPPER_VERSION),console['log']('wrapper\x20'+WRAPPER_VERSION),console[_0x4f539c(0x1b8)]('core\x20'+(_0x13dd3c||_0x4f539c(0x1c4)));}function directCore(_0x22b4c4){const _0x5e92c2=a0_0xeb103c,_0x45d7cb=findCoreScript();checkMacNodePtySpawnHelper(_0x45d7cb);const _0x2196e3=(0x0,import_child_process['spawnSync'])(process[_0x5e92c2(0x1f1)],[_0x45d7cb,..._0x22b4c4],{'stdio':'inherit','env':{...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_CORE_ENTRY':_0x45d7cb},'shell':![]});process['exit'](_0x2196e3['status']??0x0);}function shouldSupervise(_0x2d4186){const _0x232304=a0_0xeb103c;if(_0x2d4186['includes'](_0x232304(0x1bb)))return![];const _0x1d26a6=_0x2d4186[0x0]||'';if(_0x1d26a6==='ls'||_0x1d26a6==='status'||_0x1d26a6==='ps')return![];if(_0x1d26a6===_0x232304(0x1c1)||_0x1d26a6===_0x232304(0x19b))return![];if(_0x2d4186['includes'](_0x232304(0x1b2))||_0x2d4186[_0x232304(0x1c3)]('-h'))return![];return!![];}function installCoreVersion(_0x23e81f){const _0x1cdb18=a0_0xeb103c,_0x1f0010=resolveExecutable('npm');if(!_0x1f0010)return{'ok':![],'output':'npm\x20not\x20found\x20on\x20PAT'+'H'};const _0x42cca2=CORE_PKG_NAME+'@'+_0x23e81f,_0x1e41bf=run(_0x1f0010,['install','-g',_0x42cca2,'--registry='+NPM_REGISTRY]),_0xd54565=((_0x1e41bf[_0x1cdb18(0x1e2)]||'')+'\x0a'+(_0x1e41bf[_0x1cdb18(0x1eb)]||''))['trim']();return{'ok':_0x1e41bf['status']===0x0,'output':_0xd54565};}async function superviseCore(_0x1b648e){const _0x47f0fe=a0_0xeb103c;let _0x14b5d8=![],_0x23d9d3=null,_0x3d01bf=0x0,_0x59b90f=MIN_RESTART_DELAY_MS;const _0x4c7371=()=>{const _0x15a592=a0_0x2b2a;_0x14b5d8=!![];if(_0x23d9d3&&!_0x23d9d3['killed'])try{_0x23d9d3[_0x15a592(0x1cf)]('SIGTERM');}catch{}else process['exit'](0x0);};process['on'](_0x47f0fe(0x1f5),_0x4c7371),process['on']('SIGTERM',_0x4c7371);while(!![]){const _0x48fa26=findCoreScript();checkMacNodePtySpawnHelper(_0x48fa26);const _0x4c9a1d={...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_WRAPPER_MANAGED':'1','WHALENT_CORE_ENTRY':_0x48fa26},_0x4af62a=readUpgradeState(),_0x2f43d6=!!_0x4af62a?.[_0x47f0fe(0x1de)];let _0x4009bb=![],_0x13675a=null,_0x58b370='';const _0x2f208c=[],_0x397503=0xc;console[_0x47f0fe(0x1b8)](_0x47f0fe(0x1f2)+'ore:\x20'+_0x48fa26),_0x23d9d3=(0x0,import_child_process[_0x47f0fe(0x1f8)])(process['execPath'],[_0x48fa26,..._0x1b648e],{'env':_0x4c9a1d,'stdio':[_0x47f0fe(0x1a9),'pipe',_0x47f0fe(0x1f9)]});const _0x2d0fc2=()=>{const _0xa60f2d=_0x47f0fe;if(_0x4009bb)return;_0x4009bb=!![];if(_0x13675a)clearTimeout(_0x13675a);_0x3d01bf=0x0,_0x59b90f=MIN_RESTART_DELAY_MS;const _0x4f5ea8=readUpgradeState();_0x4f5ea8?.['pending']&&(writeUpgradeState({..._0x4f5ea8,'pending':![],'rollback':![],'health_status':_0xa60f2d(0x1a1)}),console['log'](_0xa60f2d(0x1d4)+'de\x20healthy:\x20'+(_0x4f5ea8[_0xa60f2d(0x188)]||_0x4f5ea8['target_version']||'')));},_0x4c0f80=(_0x4b1d12,_0x26b04d=![])=>{const _0xa7225=_0x47f0fe,_0x56234c=_0x4b1d12['toString']();(_0x26b04d?process[_0xa7225(0x1eb)]:process['stdout'])[_0xa7225(0x183)](_0x56234c);if(_0x26b04d)for(const _0x1f2940 of _0x56234c['split'](/\r?\n/)){if(!_0x1f2940[_0xa7225(0x1b1)]())continue;_0x2f208c[_0xa7225(0x1ad)](_0x1f2940);if(_0x2f208c['length']>_0x397503)_0x2f208c[_0xa7225(0x198)]();const _0x46d822=_0x1f2940['match'](FATAL_PATTERN);if(_0x46d822)_0x58b370=_0x46d822[0x0];}(_0x56234c[_0xa7225(0x1c3)]('[gateway]\x20Connected')||_0x56234c[_0xa7225(0x1c3)](_0xa7225(0x186)+'achine')||_0x56234c['includes']('Gateway:\x20connected'))&&_0x2d0fc2();};_0x23d9d3['stdout']?.['on']('data',_0x12e774=>_0x4c0f80(_0x12e774,![])),_0x23d9d3[_0x47f0fe(0x1eb)]?.['on'](_0x47f0fe(0x1e1),_0x3dd155=>_0x4c0f80(_0x3dd155,!![]));_0x2f43d6&&(_0x13675a=setTimeout(()=>{const _0x200df5=_0x47f0fe;if(_0x4009bb||!_0x23d9d3||_0x23d9d3['killed'])return;console[_0x200df5(0x1f4)](_0x200df5(0x1db)+'id\x20not\x20become\x20health'+_0x200df5(0x1b5)+_0x200df5(0x1d8));try{_0x23d9d3[_0x200df5(0x1cf)]('SIGTERM');}catch{}},HEALTH_TIMEOUT_MS));const _0x1b12ff=await new Promise(_0x44c51e=>{const _0xb30480=_0x47f0fe;_0x23d9d3[_0xb30480(0x1b4)]('exit',(_0x27635c,_0x55ee31)=>_0x44c51e({'code':_0x27635c,'signal':_0x55ee31}));});if(_0x13675a)clearTimeout(_0x13675a);_0x23d9d3=null;if(_0x14b5d8)process['exit'](_0x1b12ff[_0x47f0fe(0x190)]??0x0);const _0xe62c52=readUpgradeState();if(_0xe62c52?.[_0x47f0fe(0x1de)]&&!_0x4009bb){const _0xd36571=String(_0xe62c52[_0x47f0fe(0x1a5)+'n']||'')[_0x47f0fe(0x1b1)]();if(_0xd36571){console['error']('[wrapper]\x20rolling\x20ba'+_0x47f0fe(0x1a3)+_0xd36571);const _0x4d2394=installCoreVersion(_0xd36571);writeUpgradeState({..._0xe62c52,'pending':![],'rollback':!![],'health_status':_0x4d2394['ok']?_0x47f0fe(0x1ec):'rollback_failed','error':_0x4d2394['ok']?'':_0x4d2394[_0x47f0fe(0x1e0)]});}else writeUpgradeState({..._0xe62c52,'pending':![],'rollback':!![],'health_status':'rollback_unavailable','error':_0x47f0fe(0x19c)+_0x47f0fe(0x1f7)});}const _0x4549c4=_0x1b12ff[_0x47f0fe(0x190)]===SUPERVISED_RESTART_CODE||_0xe62c52?.['pending'];if(!_0x4549c4&&_0x1b12ff['code']===0x0)process[_0x47f0fe(0x1d6)](0x0);_0x3d01bf+=0x1,writeLastCrash({'timestamp':Date['now'](),'exit_code':_0x1b12ff[_0x47f0fe(0x190)],'exit_signal':_0x1b12ff[_0x47f0fe(0x1d7)]||null,'fatal_line':_0x58b370,'raw_tail':_0x2f208c[_0x47f0fe(0x187)]('\x0a'),'consecutive_crashes':_0x3d01bf}),console['log']('[wrapper]\x20core\x20exite'+_0x47f0fe(0x193)+(_0x1b12ff[_0x47f0fe(0x190)]??'')+(_0x1b12ff[_0x47f0fe(0x1d7)]?_0x47f0fe(0x19a)+_0x1b12ff[_0x47f0fe(0x1d7)]:'')+';\x20restarting\x20in\x20'+_0x59b90f+'ms\x20(attempt\x20'+_0x3d01bf+')');if(_0x58b370)console['log']('[wrapper]\x20last\x20fatal'+':\x20'+_0x58b370);_0x3d01bf>=0x5&&console[_0x47f0fe(0x1c9)](_0x47f0fe(0x1bd)+'rashed\x20'+_0x3d01bf+('\x20times\x20in\x20a\x20row\x20—\x20in'+'spect\x20')+lastCrashFilePath()+('\x20and\x20the\x20host\x27s\x20disk'+_0x47f0fe(0x1d3)+_0x47f0fe(0x18a))),await new Promise(_0x5e3ccf=>setTimeout(_0x5e3ccf,_0x59b90f)),_0x59b90f=Math['min'](_0x59b90f*0x2,MAX_RESTART_DELAY_MS);}}function a0_0x2b2a(_0x5956bc,_0xb9bb6f){_0x5956bc=_0x5956bc-0x17d;const _0x2180b7=a0_0x2180();let _0x2b2a6=_0x2180b7[_0x5956bc];if(a0_0x2b2a['FRQPtk']===undefined){var _0x35a561=function(_0x250d68){const _0x32a335='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x596e77='',_0x1348b3='';for(let _0x4b7825=0x0,_0x230c4f,_0x4db399,_0x3490d1=0x0;_0x4db399=_0x250d68['charAt'](_0x3490d1++);~_0x4db399&&(_0x230c4f=_0x4b7825%0x4?_0x230c4f*0x40+_0x4db399:_0x4db399,_0x4b7825++%0x4)?_0x596e77+=String['fromCharCode'](0xff&_0x230c4f>>(-0x2*_0x4b7825&0x6)):0x0){_0x4db399=_0x32a335['indexOf'](_0x4db399);}for(let _0xc7fce8=0x0,_0x4a2927=_0x596e77['length'];_0xc7fce8<_0x4a2927;_0xc7fce8++){_0x1348b3+='%'+('00'+_0x596e77['charCodeAt'](_0xc7fce8)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x1348b3);};a0_0x2b2a['ujUeWa']=_0x35a561,a0_0x2b2a['vdKlgr']={},a0_0x2b2a['FRQPtk']=!![];}const _0x21d9ce=_0x2180b7[0x0],_0xa93cd3=_0x5956bc+_0x21d9ce,_0x4535ba=a0_0x2b2a['vdKlgr'][_0xa93cd3];return!_0x4535ba?(_0x2b2a6=a0_0x2b2a['ujUeWa'](_0x2b2a6),a0_0x2b2a['vdKlgr'][_0xa93cd3]=_0x2b2a6):_0x2b2a6=_0x4535ba,_0x2b2a6;}async function main(){const _0x1c97a3=a0_0xeb103c,_0x605ba8=process[_0x1c97a3(0x17f)][_0x1c97a3(0x1b3)](0x2);if(_0x605ba8[0x0]==='--version'||_0x605ba8[0x0]==='-v'||_0x605ba8[0x0]===_0x1c97a3(0x1d9)){printVersion();return;}if((_0x605ba8[0x0]==='status'||_0x605ba8[0x0]==='ls'||_0x605ba8[0x0]==='ps')&&!_0x605ba8[_0x1c97a3(0x1c3)](_0x1c97a3(0x189))){console['log']('wrapper\x20'+WRAPPER_VERSION);try{console[_0x1c97a3(0x1b8)](_0x1c97a3(0x1fa)+(coreVersion()||_0x1c97a3(0x1c4)));}catch{console['log']('core\x20not\x20installed');}}maybeUpdateWrapper(_0x605ba8);if(!shouldSupervise(_0x605ba8))directCore(_0x605ba8);await superviseCore(_0x605ba8);}main()['catch'](_0x6048dc=>{const _0x5d0967=a0_0xeb103c;console['error'](_0x5d0967(0x1ce)+'r:\x20'+(_0x6048dc?.[_0x5d0967(0x1f6)]||String(_0x6048dc))),process['exit'](0x1);});
2
+ 'use strict';const a0_0x1ac476=a0_0x1ac7;(function(_0x13bbab,_0xd45cd6){const _0x414976=a0_0x1ac7,_0x2864e3=_0x13bbab();while(!![]){try{const _0x1888a5=-parseInt(_0x414976(0x140))/0x1*(-parseInt(_0x414976(0x13d))/0x2)+parseInt(_0x414976(0x141))/0x3*(parseInt(_0x414976(0x13e))/0x4)+-parseInt(_0x414976(0x139))/0x5*(parseInt(_0x414976(0xee))/0x6)+parseInt(_0x414976(0x11f))/0x7+-parseInt(_0x414976(0x10b))/0x8+parseInt(_0x414976(0x101))/0x9+-parseInt(_0x414976(0xea))/0xa;if(_0x1888a5===_0xd45cd6)break;else _0x2864e3['push'](_0x2864e3['shift']());}catch(_0x47ee57){_0x2864e3['push'](_0x2864e3['shift']());}}}(a0_0x121e,0xeb12f));function a0_0x1ac7(_0x34aa9b,_0x25cce8){_0x34aa9b=_0x34aa9b-0xbb;const _0x121eae=a0_0x121e();let _0x1ac75b=_0x121eae[_0x34aa9b];if(a0_0x1ac7['yeXhfO']===undefined){var _0x21d2ed=function(_0x5bff6e){const _0x5102fa='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x4b8eaa='',_0x109612='';for(let _0x2ee763=0x0,_0x1d5ed5,_0x5d912d,_0x1c55c5=0x0;_0x5d912d=_0x5bff6e['charAt'](_0x1c55c5++);~_0x5d912d&&(_0x1d5ed5=_0x2ee763%0x4?_0x1d5ed5*0x40+_0x5d912d:_0x5d912d,_0x2ee763++%0x4)?_0x4b8eaa+=String['fromCharCode'](0xff&_0x1d5ed5>>(-0x2*_0x2ee763&0x6)):0x0){_0x5d912d=_0x5102fa['indexOf'](_0x5d912d);}for(let _0x123067=0x0,_0x4b9ceb=_0x4b8eaa['length'];_0x123067<_0x4b9ceb;_0x123067++){_0x109612+='%'+('00'+_0x4b8eaa['charCodeAt'](_0x123067)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x109612);};a0_0x1ac7['wHJQMx']=_0x21d2ed,a0_0x1ac7['zteFWm']={},a0_0x1ac7['yeXhfO']=!![];}const _0x61488f=_0x121eae[0x0],_0x2e4ec2=_0x34aa9b+_0x61488f,_0xe4f35d=a0_0x1ac7['zteFWm'][_0x2e4ec2];return!_0xe4f35d?(_0x1ac75b=a0_0x1ac7['wHJQMx'](_0x1ac75b),a0_0x1ac7['zteFWm'][_0x2e4ec2]=_0x1ac75b):_0x1ac75b=_0xe4f35d,_0x1ac75b;}var __create=Object[a0_0x1ac476(0xd4)],__defProp=Object['defineProperty'],__getOwnPropDesc=Object[a0_0x1ac476(0x110)+'ptor'],__getOwnPropNames=Object['getOwnPropertyNames'],__getProtoOf=Object[a0_0x1ac476(0xfc)],__hasOwnProp=Object['prototype']['hasOwnProperty'],__copyProps=(_0x4b8eaa,_0x109612,_0x2ee763,_0x1d5ed5)=>{const _0x1578fd=a0_0x1ac476;if(_0x109612&&typeof _0x109612===_0x1578fd(0xe9)||typeof _0x109612==='function'){for(let _0x5d912d of __getOwnPropNames(_0x109612))if(!__hasOwnProp['call'](_0x4b8eaa,_0x5d912d)&&_0x5d912d!==_0x2ee763)__defProp(_0x4b8eaa,_0x5d912d,{'get':()=>_0x109612[_0x5d912d],'enumerable':!(_0x1d5ed5=__getOwnPropDesc(_0x109612,_0x5d912d))||_0x1d5ed5['enumerable']});}return _0x4b8eaa;},__toESM=(_0x1c55c5,_0x123067,_0x4b9ceb)=>(_0x4b9ceb=_0x1c55c5!=null?__create(__getProtoOf(_0x1c55c5)):{},__copyProps(_0x123067||!_0x1c55c5||!_0x1c55c5['__esModule']?__defProp(_0x4b9ceb,a0_0x1ac476(0xfd),{'value':_0x1c55c5,'enumerable':!![]}):_0x4b9ceb,_0x1c55c5)),import_child_process=require('child_process'),fs=__toESM(require('fs'),0x1),import_module=require(a0_0x1ac476(0xc7)),os=__toESM(require('os'),0x1),path=__toESM(require('path'),0x1),WRAPPER_PKG_NAME=a0_0x1ac476(0x13c),CORE_PKG_NAME='@whalent/agent-core',NPM_REGISTRY=a0_0x1ac476(0x12d)+a0_0x1ac476(0xe6),SUPERVISED_RESTART_CODE=0x4b,NPM_VIEW_TIMEOUT_MS=0x3a98,HEALTH_TIMEOUT_MS=0xafc8,MIN_RESTART_DELAY_MS=0x3e8,MAX_RESTART_DELAY_MS=0xea60,MAX_CONSECUTIVE_CRASHES=0x3,NPM_INSTALL_TIMEOUT_MS=0xa*0x3c*0x3e8,NPM_INSTALL_MAX_BUFFER=0x20*0x400*0x400,FATAL_PATTERN=/\[(?:agent|daemon|wrapper)\][^\n]*\bFatal error:[^\n]+|\[daemon\] Failed to start:[^\n]+|Error:[^\n]+/,WRAPPER_VERSION=readWrapperVersion(),CHECKED_PTY_HELPERS=new Set();function wrapperBaseDir(){return __dirname;}function configDir(){const _0x50a00e=a0_0x1ac476;return path['join'](os[_0x50a00e(0x103)](),_0x50a00e(0x143));}function upgradeStatePath(){const _0x147df5=a0_0x1ac476;return path['join'](configDir(),_0x147df5(0xcf));}function lastCrashFilePath(){const _0x456b1c=a0_0x1ac476;return path[_0x456b1c(0x118)](configDir(),_0x456b1c(0xbd));}function writeLastCrash(_0x4a09c9){const _0x19b534=a0_0x1ac476;try{fs['mkdirSync'](configDir(),{'recursive':!![]});const _0x17eb4f={..._0x4a09c9,'reported':![]};fs[_0x19b534(0x112)](lastCrashFilePath(),JSON[_0x19b534(0x115)](_0x17eb4f,null,0x2),_0x19b534(0xda));}catch{}}function readWrapperVersion(){const _0x5c3aaa=a0_0x1ac476;try{const _0x5eb585=JSON['parse'](fs['readFileSync'](path[_0x5c3aaa(0x118)](wrapperBaseDir(),'..',_0x5c3aaa(0x11a)),_0x5c3aaa(0xda)));return String(_0x5eb585['version']||'0.0.0');}catch{return _0x5c3aaa(0xd6);}}function readUpgradeState(){const _0x4de372=a0_0x1ac476;try{return JSON[_0x4de372(0xf4)](fs[_0x4de372(0xce)](upgradeStatePath(),_0x4de372(0xda)));}catch{return null;}}function writeUpgradeState(_0x6247a9){const _0xc641b8=a0_0x1ac476;try{fs[_0xc641b8(0x128)](configDir(),{'recursive':!![]}),fs['writeFileSync'](upgradeStatePath(),JSON['stringify']({..._0x6247a9,'updated_at':Date['now']()},null,0x2),_0xc641b8(0xda));}catch{}}function run(_0x3f4c68,_0x279a87,_0x5f3724=process.env){const _0x47a4c7=a0_0x1ac476;return(0x0,import_child_process[_0x47a4c7(0x130)])(_0x3f4c68,_0x279a87,{'encoding':'utf8','timeout':NPM_INSTALL_TIMEOUT_MS,'maxBuffer':NPM_INSTALL_MAX_BUFFER,'env':_0x5f3724,'shell':![]});}function runNpmView(_0x5e5f96){const _0x37033b=a0_0x1ac476,_0x3c3359=resolveExecutable('npm');if(!_0x3c3359)return{'status':0x7f,'stdout':'','stderr':_0x37033b(0x148),'error':new Error(_0x37033b(0x148))};return(0x0,import_child_process[_0x37033b(0x130)])(_0x3c3359,_0x5e5f96,{'encoding':'utf8','timeout':NPM_VIEW_TIMEOUT_MS,'maxBuffer':0x400*0x400,'env':process.env,'shell':![]});}function npmRootGlobal(){const _0xaee549=a0_0x1ac476,_0x479246=resolveExecutable(_0xaee549(0x116));if(!_0x479246)return'';const _0x420e6e=run(_0x479246,['root','-g']);if(_0x420e6e[_0xaee549(0x10f)]!==0x0)return'';return String(_0x420e6e[_0xaee549(0x12b)]||'')['trim']();}function compareSemver(_0x277047,_0x44494d){const _0x4a3f25=a0_0x1ac476,_0x3f3a47=String(_0x277047||'')[_0x4a3f25(0xf9)](/^v/,'')[_0x4a3f25(0xf5)](/[.-]/)[_0x4a3f25(0x138)](_0x4544d6=>Number['parseInt'](_0x4544d6,0xa)||0x0),_0x30695e=String(_0x44494d||'')['replace'](/^v/,'')['split'](/[.-]/)[_0x4a3f25(0x138)](_0x4ff3e8=>Number['parseInt'](_0x4ff3e8,0xa)||0x0);for(let _0xd67aa7=0x0;_0xd67aa7<Math[_0x4a3f25(0x109)](_0x3f3a47[_0x4a3f25(0xd9)],_0x30695e[_0x4a3f25(0xd9)],0x3);_0xd67aa7++){const _0x202fe7=_0x3f3a47[_0xd67aa7]||0x0,_0x472ce6=_0x30695e[_0xd67aa7]||0x0;if(_0x202fe7>_0x472ce6)return 0x1;if(_0x202fe7<_0x472ce6)return-0x1;}return 0x0;}function resolveExecutable(_0x13c300){const _0x231843=a0_0x1ac476,_0x131f3c=process[_0x231843(0xf7)]===_0x231843(0x121)?_0x231843(0xcd):_0x231843(0x106);try{const _0x4b943f=(0x0,import_child_process['spawnSync'])(_0x131f3c,[_0x13c300],{'encoding':_0x231843(0xff),'timeout':0xbb8,'shell':![]});if(_0x4b943f[_0x231843(0x10f)]!==0x0)return'';return String(_0x4b943f[_0x231843(0x12b)]||'')['split'](/\r?\n/)[_0x231843(0x138)](_0x4cb583=>_0x4cb583['trim']())[_0x231843(0xc5)](Boolean)[0x0]||'';}catch{return'';}}function skipWrapperUpdateCheck(){const _0x2faaec=a0_0x1ac476,_0x213654=String(process.env.WHALENT_SKIP_UPDATE_CHECK||process.env.WHALENT_NO_UPDATE_CHECK||process.env.WHALENT_SKIP_WRAPPER_UPDATE||'')[_0x2faaec(0xf0)]()['toLowerCase']();return _0x213654==='1'||_0x213654===_0x2faaec(0xfe)||_0x213654==='yes'||_0x213654==='on';}function latestWrapperVersion(){const _0x50f3dd=a0_0x1ac476,_0x1cbd80=runNpmView(['view',WRAPPER_PKG_NAME+_0x50f3dd(0x10e),_0x50f3dd(0x11e),'--registry='+NPM_REGISTRY]);if(_0x1cbd80['status']!==0x0)return'';return String(_0x1cbd80[_0x50f3dd(0x12b)]||'')['trim']()[_0x50f3dd(0xf5)](/\r?\n/)[_0x50f3dd(0xc5)](Boolean)['pop']()||'';}function installWrapperVersion(_0x4baa02){const _0x4c59c8=a0_0x1ac476,_0x57bbc8=resolveExecutable('npm');if(!_0x57bbc8)return{'ok':![],'output':_0x4c59c8(0xe0)+'H'};const _0x33ade7=run(_0x57bbc8,[_0x4c59c8(0x13a),'-g',WRAPPER_PKG_NAME+'@'+_0x4baa02,'--registry='+NPM_REGISTRY]),_0x573e3c=((_0x33ade7[_0x4c59c8(0x12b)]||'')+'\x0a'+(_0x33ade7[_0x4c59c8(0x102)]||''))['trim']();return{'ok':_0x33ade7['status']===0x0,'output':_0x573e3c};}function maybeUpdateWrapper(_0xeb94f3){const _0x47f109=a0_0x1ac476;if(skipWrapperUpdateCheck())return![];if(process.env.WHALENT_WRAPPER_UPDATE_ATTEMPTED)return![];const _0x11e706=latestWrapperVersion();if(!_0x11e706||compareSemver(_0x11e706,WRAPPER_VERSION)<=0x0)return![];console[_0x47f109(0xe7)]('[wrapper]\x20update\x20ava'+'ilable:\x20'+WRAPPER_VERSION+_0x47f109(0x119)+_0x11e706),console[_0x47f109(0xe7)](_0x47f109(0x117)+'\x20'+WRAPPER_PKG_NAME+'@'+_0x11e706+(_0x47f109(0x129)+'rting\x20core...'));const _0x4f6a50=installWrapperVersion(_0x11e706);if(!_0x4f6a50['ok']){console[_0x47f109(0xe7)](_0x47f109(0xc0)+_0x47f109(0xbc)+'ing\x20with\x20'+WRAPPER_VERSION);if(_0x4f6a50['output'])console[_0x47f109(0xe7)](_0x4f6a50[_0x47f109(0x126)]['split'](/\r?\n/)['slice'](-0xc)[_0x47f109(0x118)]('\x0a'));return console['warn']('[wrapper]\x20Manual\x20upd'+_0x47f109(0xfb)+WRAPPER_PKG_NAME+'@'+_0x11e706+_0x47f109(0x11d)+NPM_REGISTRY),![];}console['warn']('[wrapper]\x20wrapper\x20up'+_0x47f109(0x120)+_0x11e706+_0x47f109(0xca));const _0x43766d=process[_0x47f109(0xf3)][0x1],_0x5ccd9c=(0x0,import_child_process[_0x47f109(0x130)])(process[_0x47f109(0xec)],[_0x43766d,..._0xeb94f3],{'stdio':'inherit','env':{...process.env,'WHALENT_WRAPPER_UPDATE_ATTEMPTED':_0x11e706},'shell':![]});process['exit'](_0x5ccd9c[_0x47f109(0x10f)]??0x0);}function findCoreScript(){const _0x1acbcd=a0_0x1ac476,_0x2f52bf=String(process.env.WHALENT_CORE_ENTRY||'')['trim'](),_0x53fddf=['1','true',_0x1acbcd(0xc3),'on'][_0x1acbcd(0xbb)](String(process.env.WHALENT_FORCE_CORE_ENTRY||'')['trim']()['toLowerCase']());if(_0x2f52bf&&_0x53fddf&&fs[_0x1acbcd(0x13f)](_0x2f52bf))return _0x2f52bf;const _0x4a85ba=[],_0x5a242c=_0x285c9d=>{const _0x5ac432=_0x1acbcd;if(fs['existsSync'](_0x285c9d)&&!_0x4a85ba['includes'](_0x285c9d))_0x4a85ba[_0x5ac432(0x133)](_0x285c9d);};if(_0x2f52bf)_0x5a242c(_0x2f52bf);const _0x5dae88=npmRootGlobal();if(_0x5dae88){const _0x4581ca=path['join'](_0x5dae88,_0x1acbcd(0xfa),_0x1acbcd(0x107),_0x1acbcd(0xf1),_0x1acbcd(0xbf));_0x5a242c(_0x4581ca);}const _0xc3f9d8=path[_0x1acbcd(0x118)](wrapperBaseDir(),_0x1acbcd(0xeb));_0x5a242c(_0xc3f9d8);const _0x375b06=path['join'](wrapperBaseDir(),'..',_0x1acbcd(0xe5),_0x1acbcd(0x11b),_0x1acbcd(0xf1),_0x1acbcd(0xbf));_0x5a242c(_0x375b06);if(_0x4a85ba['length']>0x0)return _0x4a85ba[_0x1acbcd(0x138)]((_0x34f40f,_0x1500b5)=>({'candidate':_0x34f40f,'index':_0x1500b5,'version':coreVersion(_0x34f40f)}))[_0x1acbcd(0x12e)]((_0x36ccfe,_0x142ecc)=>{const _0x4cffde=_0x1acbcd,_0x2763d4=compareSemver(_0x142ecc[_0x4cffde(0x11e)],_0x36ccfe['version']);if(_0x2763d4!==0x0)return _0x2763d4;return _0x142ecc[_0x4cffde(0xf8)]-_0x36ccfe[_0x4cffde(0xf8)];})[0x0][_0x1acbcd(0x149)];throw new Error('whalent\x20core\x20runtime'+'\x20not\x20found;\x20install\x20'+'@whalent/agent-core\x20'+'or\x20rebuild\x20@whalent/'+'agent');}function coreVersion(_0x2735ee=findCoreScript()){const _0x24c9de=a0_0x1ac476,_0x37302c=(0x0,import_child_process[_0x24c9de(0x130)])(process['execPath'],[_0x2735ee,_0x24c9de(0xe8)],{'encoding':'utf8','timeout':0x3a98,'env':{...process.env,'WHALENT_SKIP_UPDATE_CHECK':'1'},'shell':![]}),_0x33f883=(_0x37302c['stdout']||'')+'\x0a'+(_0x37302c['stderr']||'');return _0x33f883['match'](/(\d+\.\d+\.\d+(?:[-\w.]+)?)/)?.[0x1]||'';}function isExecutable(_0x50aca6){const _0x383fe7=a0_0x1ac476;try{return fs['accessSync'](_0x50aca6,fs[_0x383fe7(0xd3)]['X_OK']),!![];}catch{return![];}}function shellQuote(_0x35da3e){const _0x21ee7e=a0_0x1ac476;return'\x27'+_0x35da3e[_0x21ee7e(0xf9)](/'/g,'\x27\x5c\x27\x27')+'\x27';}function coreNodePtySpawnHelperPath(_0x4abc0e){const _0xfb47c3=a0_0x1ac476;if(process['platform']!==_0xfb47c3(0xbe))return'';try{const _0x514804=(0x0,import_module[_0xfb47c3(0xdf)])(_0x4abc0e),_0x308b5e=_0x514804['resolve'](_0xfb47c3(0xf2)),_0x475ba5=path[_0xfb47c3(0x11c)](path[_0xfb47c3(0xc8)](_0x308b5e),'..');return path[_0xfb47c3(0x118)](_0x475ba5,'prebuilds','darwin-'+process[_0xfb47c3(0x124)],'spawn-helper');}catch{return'';}}function checkMacNodePtySpawnHelper(_0x104c81){const _0x4866a4=a0_0x1ac476,_0x55d504=coreNodePtySpawnHelperPath(_0x104c81);if(!_0x55d504||CHECKED_PTY_HELPERS['has'](_0x55d504))return;CHECKED_PTY_HELPERS['add'](_0x55d504);if(!fs[_0x4866a4(0x13f)](_0x55d504)){console[_0x4866a4(0xe7)](_0x4866a4(0xd2)+'-pty\x20spawn-helper\x20no'+_0x4866a4(0xd5)+_0x55d504);return;}if(isExecutable(_0x55d504))return;try{const _0x2617d9=fs[_0x4866a4(0x12f)](_0x55d504)['mode'];fs[_0x4866a4(0x111)](_0x55d504,_0x2617d9|0x1ed);}catch{}if(isExecutable(_0x55d504)){console['warn']('[wrapper]\x20fixed\x20macO'+'S\x20node-pty\x20spawn-hel'+_0x4866a4(0xd1)+_0x55d504);return;}console['warn']('[wrapper]\x20macOS\x20node'+_0x4866a4(0xd8)+'\x20not\x20executable:\x20'+_0x55d504),console['warn'](_0x4866a4(0xc4)+_0x4866a4(0x144)+_0x4866a4(0xdc)),console[_0x4866a4(0xe7)](_0x4866a4(0x12a)+shellQuote(_0x55d504)),console['warn'](_0x4866a4(0x135)),console[_0x4866a4(0xe7)](_0x4866a4(0x131));}function printVersion(){const _0x1f6ebf=a0_0x1ac476;let _0x1cacb4='';try{_0x1cacb4=coreVersion();}catch{}console['log'](_0x1f6ebf(0x137)+WRAPPER_VERSION),console['log']('wrapper\x20'+WRAPPER_VERSION),console['log']('core\x20'+(_0x1cacb4||'not\x20installed'));}function directCore(_0x3531b1){const _0x35b22a=a0_0x1ac476,_0x493b02=findCoreScript();checkMacNodePtySpawnHelper(_0x493b02);const _0x48254e=(0x0,import_child_process[_0x35b22a(0x130)])(process[_0x35b22a(0xec)],[_0x493b02,..._0x3531b1],{'stdio':_0x35b22a(0xef),'env':{...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_CORE_ENTRY':_0x493b02},'shell':![]});process['exit'](_0x48254e[_0x35b22a(0x10f)]??0x0);}function shouldSupervise(_0x335dc4){const _0x3923f7=a0_0x1ac476;if(_0x335dc4[_0x3923f7(0xbb)]('--agent-id'))return![];const _0x483d42=_0x335dc4[0x0]||'';if(_0x483d42==='ls'||_0x483d42===_0x3923f7(0x10f)||_0x483d42==='ps')return![];if(_0x483d42==='mcp'||_0x483d42==='daemon-mcp')return![];if(_0x335dc4['includes'](_0x3923f7(0x12c))||_0x335dc4['includes']('-h'))return![];return!![];}function installCoreVersion(_0x2644e0){const _0x36ddc6=a0_0x1ac476,_0x18e7f2=resolveExecutable(_0x36ddc6(0x116));if(!_0x18e7f2)return{'ok':![],'output':_0x36ddc6(0xe0)+'H'};const _0x427f5e=CORE_PKG_NAME+'@'+_0x2644e0,_0x5c2cfd=run(_0x18e7f2,[_0x36ddc6(0x13a),'-g',_0x427f5e,'--registry='+NPM_REGISTRY]),_0x368f9f=((_0x5c2cfd['stdout']||'')+'\x0a'+(_0x5c2cfd[_0x36ddc6(0x102)]||''))['trim']();return{'ok':_0x5c2cfd[_0x36ddc6(0x10f)]===0x0,'output':_0x368f9f};}async function superviseCore(_0x11df28){const _0x21e32a=a0_0x1ac476;let _0x2f3fb0=![],_0x203031=null,_0x30c73c=0x0,_0x22e6d9=MIN_RESTART_DELAY_MS;const _0x2c915f=()=>{const _0x396b90=a0_0x1ac7;_0x2f3fb0=!![];if(_0x203031&&!_0x203031[_0x396b90(0x134)])try{_0x203031[_0x396b90(0xe4)](_0x396b90(0xc9));}catch{}else process['exit'](0x0);};process['on']('SIGINT',_0x2c915f),process['on']('SIGTERM',_0x2c915f);while(!![]){const _0x1005e8=findCoreScript();checkMacNodePtySpawnHelper(_0x1005e8);const _0x4c7196={...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_WRAPPER_MANAGED':'1','WHALENT_CORE_ENTRY':_0x1005e8},_0x3ec955=readUpgradeState(),_0x319420=!!_0x3ec955?.['pending'];let _0x1f6327=![],_0x5fd24f=null,_0x5eca21='';const _0x1ccbee=[],_0x57ac60=0xc;console[_0x21e32a(0x13b)](_0x21e32a(0x142)+'ore:\x20'+_0x1005e8),_0x203031=(0x0,import_child_process['spawn'])(process[_0x21e32a(0xec)],[_0x1005e8,..._0x11df28],{'env':_0x4c7196,'stdio':['inherit','pipe','pipe']});const _0x1d844b=()=>{const _0x8a06ac=_0x21e32a;if(_0x1f6327)return;_0x1f6327=!![];if(_0x5fd24f)clearTimeout(_0x5fd24f);_0x30c73c=0x0,_0x22e6d9=MIN_RESTART_DELAY_MS;const _0x161d7c=readUpgradeState();_0x161d7c?.[_0x8a06ac(0x136)]&&(writeUpgradeState({..._0x161d7c,'pending':![],'rollback':![],'health_status':_0x8a06ac(0xc1)}),console['log'](_0x8a06ac(0x146)+_0x8a06ac(0xf6)+(_0x161d7c[_0x8a06ac(0xdb)]||_0x161d7c['target_version']||'')));},_0x17a63c=(_0x3d62fe,_0x3617c0=![])=>{const _0x38a325=_0x21e32a,_0x561ac1=_0x3d62fe['toString']();(_0x3617c0?process[_0x38a325(0x102)]:process[_0x38a325(0x12b)])[_0x38a325(0x10d)](_0x561ac1);if(_0x3617c0)for(const _0x2bf02d of _0x561ac1['split'](/\r?\n/)){if(!_0x2bf02d[_0x38a325(0xf0)]())continue;_0x1ccbee['push'](_0x2bf02d);if(_0x1ccbee[_0x38a325(0xd9)]>_0x57ac60)_0x1ccbee['shift']();const _0x1ea9fc=_0x2bf02d[_0x38a325(0xe3)](FATAL_PATTERN);if(_0x1ea9fc)_0x5eca21=_0x1ea9fc[0x0];}(_0x561ac1[_0x38a325(0xbb)]('[gateway]\x20Connected')||_0x561ac1['includes'](_0x38a325(0x105)+_0x38a325(0x145))||_0x561ac1[_0x38a325(0xbb)](_0x38a325(0xcb)))&&_0x1d844b();};_0x203031['stdout']?.['on'](_0x21e32a(0x127),_0x179c29=>_0x17a63c(_0x179c29,![])),_0x203031[_0x21e32a(0x102)]?.['on']('data',_0x2867ce=>_0x17a63c(_0x2867ce,!![]));_0x319420&&(_0x5fd24f=setTimeout(()=>{const _0x17be06=_0x21e32a;if(_0x1f6327||!_0x203031||_0x203031['killed'])return;console['error'](_0x17be06(0xc2)+'id\x20not\x20become\x20health'+'y\x20in\x20time;\x20rolling\x20b'+_0x17be06(0x125));try{_0x203031['kill']('SIGTERM');}catch{}},HEALTH_TIMEOUT_MS));const _0x1a8c38=await new Promise(_0x1271a2=>{const _0x40c5ee=_0x21e32a;_0x203031[_0x40c5ee(0x147)](_0x40c5ee(0xde),(_0x3829f4,_0x40a221)=>_0x1271a2({'code':_0x3829f4,'signal':_0x40a221}));});if(_0x5fd24f)clearTimeout(_0x5fd24f);_0x203031=null;if(_0x2f3fb0)process['exit'](_0x1a8c38['code']??0x0);const _0x5e0b5a=readUpgradeState();if(_0x5e0b5a?.['pending']&&!_0x1f6327){const _0xf8163e=String(_0x5e0b5a[_0x21e32a(0xcc)+'n']||'')['trim']();if(_0xf8163e){console['error'](_0x21e32a(0xd0)+'ck\x20core\x20to\x20'+_0xf8163e);const _0x40ddbb=installCoreVersion(_0xf8163e);writeUpgradeState({..._0x5e0b5a,'pending':![],'rollback':!![],'health_status':_0x40ddbb['ok']?'rolled_back':_0x21e32a(0x113),'error':_0x40ddbb['ok']?'':_0x40ddbb['output']});}else writeUpgradeState({..._0x5e0b5a,'pending':![],'rollback':!![],'health_status':'rollback_unavailable','error':_0x21e32a(0x104)+_0x21e32a(0x108)});}const _0x3b8db0=_0x1a8c38['code']===SUPERVISED_RESTART_CODE||_0x5e0b5a?.['pending'];if(!_0x3b8db0&&_0x1a8c38[_0x21e32a(0xc6)]===0x0)process['exit'](0x0);_0x30c73c+=0x1,writeLastCrash({'timestamp':Date[_0x21e32a(0x132)](),'exit_code':_0x1a8c38['code'],'exit_signal':_0x1a8c38['signal']||null,'fatal_line':_0x5eca21,'raw_tail':_0x1ccbee['join']('\x0a'),'consecutive_crashes':_0x30c73c}),console[_0x21e32a(0x13b)]('[wrapper]\x20core\x20exite'+'d\x20code='+(_0x1a8c38[_0x21e32a(0xc6)]??'')+(_0x1a8c38['signal']?'\x20signal='+_0x1a8c38[_0x21e32a(0x123)]:'')+'\x20(attempt\x20'+_0x30c73c+'/'+MAX_CONSECUTIVE_CRASHES+')');if(_0x5eca21)console['log'](_0x21e32a(0xed)+':\x20'+_0x5eca21);_0x30c73c>=MAX_CONSECUTIVE_CRASHES&&(console['error']('[wrapper]\x20core\x20faile'+'d\x20'+_0x30c73c+(_0x21e32a(0xd7)+'ing\x20up.\x20Crash\x20record'+':\x20')+lastCrashFilePath()+(_0x21e32a(0xe1)+'nually\x20after\x20the\x20und'+'erlying\x20issue\x20is\x20fix'+_0x21e32a(0x100))),process[_0x21e32a(0xde)](0x1)),console['log'](_0x21e32a(0x122)+_0x21e32a(0xdd)+_0x22e6d9+'ms'),await new Promise(_0x2c47ef=>setTimeout(_0x2c47ef,_0x22e6d9)),_0x22e6d9=Math['min'](_0x22e6d9*0x2,MAX_RESTART_DELAY_MS);}}async function main(){const _0x581d66=a0_0x1ac476,_0x10ab3e=process[_0x581d66(0xf3)]['slice'](0x2);if(_0x10ab3e[0x0]===_0x581d66(0xe8)||_0x10ab3e[0x0]==='-v'||_0x10ab3e[0x0]===_0x581d66(0x11e)){printVersion();return;}if((_0x10ab3e[0x0]===_0x581d66(0x10f)||_0x10ab3e[0x0]==='ls'||_0x10ab3e[0x0]==='ps')&&!_0x10ab3e['includes']('--json')){console['log']('wrapper\x20'+WRAPPER_VERSION);try{console['log'](_0x581d66(0x10a)+(coreVersion()||_0x581d66(0x10c)));}catch{console['log']('core\x20not\x20installed');}}maybeUpdateWrapper(_0x10ab3e);if(!shouldSupervise(_0x10ab3e))directCore(_0x10ab3e);await superviseCore(_0x10ab3e);}main()['catch'](_0x9e51f9=>{const _0x37a8a5=a0_0x1ac476;console[_0x37a8a5(0xe2)]('[wrapper]\x20Fatal\x20erro'+_0x37a8a5(0x114)+(_0x9e51f9?.['message']||String(_0x9e51f9))),process[_0x37a8a5(0xde)](0x1);});function a0_0x121e(){const _0x66c783=['w3DYyxbWzxjDig1Hy09tig5Vzgu','y29UC3rHBNrZ','y3jLyxrL','DcbMB3vUzdOG','mc4WlJa','ihrPBwvZigLUigeGCM93oYbNAxy','lxb0EsbZCgf3BI1OzwXWzxiGAxm','BgvUz3rO','DxrMltG','Aw5ZDgfSBgvKx3zLCNnPB24','ufrzihn0yxj0Dxa6','igLUia','zxHPDa','y3jLyxrLuMvXDwLYzq','BNbTig5VDcbMB3vUzcbVBIbqqvq','lIbszxn0yxj0ihDYyxbWzxiGBwe','zxjYB3i','Bwf0y2G','A2LSBa','CgfJA2fNzxm','ANmUB3jN','D2fYBG','ls12zxjZAw9U','B2jQzwn0','mJiXodK2odbAyvLpC20','y29Yzs5JANm','zxHLy1bHDgG','w3DYyxbWzxjDigXHC3qGzMf0ywW','nMDgvgfHvG','Aw5OzxjPDa','DhjPBq','zgLZDa','BM9Kzs1WDhK','yxjNDG','CgfYC2u','C3bSAxq','zguGAgvHBhrOEtOG','CgXHDgzVCM0','Aw5KzxG','CMvWBgfJzq','qhDOywXLBNq','yxrLoIbUCg0GAw5ZDgfSBcaTzYa','z2v0uhjVDg90ExbLt2y','zgvMyxvSDa','Dhj1zq','DxrMoa','zwqU','mtm2mtKWodHlDejuywi','C3rKzxjY','Ag9TzwrPCG','ChjLDMLVDxmGy29Yzsb2zxjZAw8','r2f0zxDHEsbYzwDPC3rLCMvKig0','D2HPy2G','ywDLBNqTy29Yzq','BIb1BMTUB3DU','Bwf4','y29Yzsa','nJG0nJu1mNb1DwDABq','BM90igLUC3rHBgXLza','D3jPDgu','qgXHDgvZDa','C3rHDhvZ','z2v0t3DUuhjVCgvYDhLezxnJCMK','y2HTB2rtEw5J','D3jPDgvgAwXLu3LUyW','CM9SBgjHy2TFzMfPBgvK','CJOG','C3rYAw5NAwz5','BNbT','w3DYyxbWzxjDigLUC3rHBgXPBMC','AM9PBG','ic0+ia','CgfJA2fNzs5QC29U','y29Yzq','CMvZB2X2zq','ic0TCMvNAxn0CNK9','DMvYC2LVBG','mtaWmti5nJHQv2rjCgi','zgf0zwqGDg8G','D2LUmZi','w3DYyxbWzxjDihjLC3rHCNrPBMC','C2LNBMfS','yxjJAa','ywnR','B3v0Chv0','zgf0yq','BwTKAxjtEw5J','igzYB20GBNbTigjLzM9YzsbZDge','icbiruXqrvi9','C3rKB3v0','ls1OzwXW','Ahr0Chm6lY9YzwDPC3rYEs5UCg0','C29YDa','C3rHDfn5BMm','C3bHD25tEw5J','icbJAg1VzcaREcaIjeHftfbfuIi','BM93','ChvZAa','A2LSBgvK','icbSCYaTBcaIjeHftfbfuIi','CgvUzgLUzW','D2HHBgvUDc1Hz2vUDca','BwfW','mZGYode2nufKzM5ktW','Aw5ZDgfSBa','Bg9N','qhDOywXLBNqVywDLBNq','mtHlqu5mrwC','mZaZmKjpDezuAa','zxHPC3rZu3LUyW','mtqYody5Cg9rChr1','mJi3mvvJuMDZsa','w3DYyxbWzxjDihn0yxj0Aw5Nigm','lNDOywXLBNqTywDLBNq','BMnLihrVigzPEcb0zxjTAw5HBc8','ywnOAw5L','w3DYyxbWzxjDignVCMuGDxbNCMe','B25Jzq','BNbTig5VDcbMB3vUza','y2fUzgLKyxrL','Aw5JBhvKzxm','zgf0zsbMywLSzwq7ignVBNrPBNu','BgfZDc1JCMfZAc5QC29U','zgfYD2LU','Aw5KzxGUy2PZ','w3DYyxbWzxjDihDYyxbWzxiGDxa','AgvHBhrOEq','w3DYyxbWzxjDig5LDYbJB3jLigq','EwvZ','w3DYyxbWzxjDifj1BIb0AgLZig8','zMLSDgvY','y29Kzq','Bw9KDwXL','zgLYBMfTzq','u0Lhvevstq','oYbYzxn0yxj0Aw5NihDYyxbWzxi','r2f0zxDHEtOGy29UBMvJDgvK','ChjLDMLVDxnFy29Yzv92zxjZAw8','D2HLCMuUzxHL','CMvHzezPBgvtEw5J','y29Yzs11CgDYywrLlMPZB24','w3DYyxbWzxjDihjVBgXPBMCGyMe','CgvYigv4zwn1DgfIBguGyML0oIa'];a0_0x121e=function(){return _0x66c783;};return a0_0x121e();}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whalent/agent",
3
- "version": "0.3.66",
3
+ "version": "0.3.67",
4
4
  "description": "Stable wrapper for Whalent Agent core runtime",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",