@whalent/agent 0.3.92 → 0.3.94

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_0x11309b=a0_0x1032;(function(_0x395b7c,_0x56d622){const _0x2cccd8=a0_0x1032,_0x3d8709=_0x395b7c();while(!![]){try{const _0x56456d=parseInt(_0x2cccd8(0x152))/0x1+-parseInt(_0x2cccd8(0xef))/0x2*(parseInt(_0x2cccd8(0x13b))/0x3)+parseInt(_0x2cccd8(0x166))/0x4+-parseInt(_0x2cccd8(0xfc))/0x5+-parseInt(_0x2cccd8(0x139))/0x6*(parseInt(_0x2cccd8(0x172))/0x7)+parseInt(_0x2cccd8(0x15c))/0x8+-parseInt(_0x2cccd8(0x102))/0x9*(parseInt(_0x2cccd8(0x136))/0xa);if(_0x56456d===_0x56d622)break;else _0x3d8709['push'](_0x3d8709['shift']());}catch(_0x254d8a){_0x3d8709['push'](_0x3d8709['shift']());}}}(a0_0x176f,0x2d9f6));var __create=Object['create'],__defProp=Object[a0_0x11309b(0x111)],__getOwnPropDesc=Object[a0_0x11309b(0xf5)+a0_0x11309b(0x168)],__getOwnPropNames=Object['getOwnPropertyNames'],__getProtoOf=Object['getPrototypeOf'],__hasOwnProp=Object[a0_0x11309b(0xf3)][a0_0x11309b(0x107)],__copyProps=(_0xfe6f55,_0x2d894e,_0xbacaca,_0x109513)=>{const _0x2a6e7c=a0_0x11309b;if(_0x2d894e&&typeof _0x2d894e==='object'||typeof _0x2d894e===_0x2a6e7c(0x14d)){for(let _0x505143 of __getOwnPropNames(_0x2d894e))if(!__hasOwnProp[_0x2a6e7c(0x100)](_0xfe6f55,_0x505143)&&_0x505143!==_0xbacaca)__defProp(_0xfe6f55,_0x505143,{'get':()=>_0x2d894e[_0x505143],'enumerable':!(_0x109513=__getOwnPropDesc(_0x2d894e,_0x505143))||_0x109513['enumerable']});}return _0xfe6f55;},__toESM=(_0x411cf0,_0x1202ed,_0x4d0ba5)=>(_0x4d0ba5=_0x411cf0!=null?__create(__getProtoOf(_0x411cf0)):{},__copyProps(_0x1202ed||!_0x411cf0||!_0x411cf0[a0_0x11309b(0x116)]?__defProp(_0x4d0ba5,a0_0x11309b(0x11a),{'value':_0x411cf0,'enumerable':!![]}):_0x4d0ba5,_0x411cf0)),import_child_process=require(a0_0x11309b(0x10a)),fs=__toESM(require('fs'),0x1),import_module=require(a0_0x11309b(0x14f)),os=__toESM(require('os'),0x1),path=__toESM(require('path'),0x1),WRAPPER_PKG_NAME=a0_0x11309b(0x11f),CORE_PKG_NAME='@whalent/agent-core',NPM_REGISTRY='https://registry.npm'+a0_0x11309b(0x147),SUPERVISED_RESTART_CODE=0x4b,NPM_VIEW_TIMEOUT_MS=0x3a98,HEALTH_TIMEOUT_MS=0xafc8,MIN_RESTART_DELAY_MS=0x3e8,MAX_RESTART_DELAY_MS=0xea60,MAX_CRASHES_IN_WINDOW=0x3,CRASH_WINDOW_MS=0x3*0x3c*0x3e8,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 _0x58632f=a0_0x11309b;return path[_0x58632f(0x171)](os['homedir'](),_0x58632f(0x14e));}function upgradeStatePath(){return path['join'](configDir(),'core-upgrade.json');}function lastCrashFilePath(){const _0x167a06=a0_0x11309b;return path[_0x167a06(0x171)](configDir(),'last-crash.json');}function writeLastCrash(_0x24eafb){const _0x36f5b3=a0_0x11309b;try{fs['mkdirSync'](configDir(),{'recursive':!![]});const _0x3e2d37={..._0x24eafb,'reported':![]};fs['writeFileSync'](lastCrashFilePath(),JSON[_0x36f5b3(0x135)](_0x3e2d37,null,0x2),_0x36f5b3(0x12f));}catch{}}function readWrapperVersion(){const _0x16b94d=a0_0x11309b;try{const _0x13e00a=JSON[_0x16b94d(0x105)](fs[_0x16b94d(0xea)](path['join'](wrapperBaseDir(),'..','package.json'),_0x16b94d(0x12f)));return String(_0x13e00a['version']||_0x16b94d(0x163));}catch{return _0x16b94d(0x163);}}function readUpgradeState(){const _0x1442a2=a0_0x11309b;try{return JSON[_0x1442a2(0x105)](fs[_0x1442a2(0xea)](upgradeStatePath(),'utf-8'));}catch{return null;}}function writeUpgradeState(_0x3f98cf){const _0x270903=a0_0x11309b;try{fs[_0x270903(0xf0)](configDir(),{'recursive':!![]}),fs['writeFileSync'](upgradeStatePath(),JSON['stringify']({..._0x3f98cf,'updated_at':Date['now']()},null,0x2),'utf-8');}catch{}}function run(_0x32bd00,_0x5443aa,_0x37e66e=process.env){const _0x1df485=a0_0x11309b;return(0x0,import_child_process[_0x1df485(0x155)])(_0x32bd00,_0x5443aa,{'encoding':_0x1df485(0x167),'timeout':NPM_INSTALL_TIMEOUT_MS,'maxBuffer':NPM_INSTALL_MAX_BUFFER,'env':_0x37e66e,'shell':![]});}function runNpmView(_0x3d03b6){const _0x2d1f42=a0_0x11309b,_0x1c939e=resolveExecutable(_0x2d1f42(0xfa));if(!_0x1c939e)return{'status':0x7f,'stdout':'','stderr':_0x2d1f42(0x144),'error':new Error('npm\x20not\x20found')};return(0x0,import_child_process[_0x2d1f42(0x155)])(_0x1c939e,_0x3d03b6,{'encoding':'utf8','timeout':NPM_VIEW_TIMEOUT_MS,'maxBuffer':0x400*0x400,'env':process.env,'shell':![]});}function npmRootGlobal(){const _0x1bd509=a0_0x11309b,_0x144181=resolveExecutable(_0x1bd509(0xfa));if(!_0x144181)return'';const _0x763782=run(_0x144181,[_0x1bd509(0x129),'-g']);if(_0x763782[_0x1bd509(0x16c)]!==0x0)return'';return String(_0x763782['stdout']||'')[_0x1bd509(0x137)]();}function compareSemver(_0x5d064f,_0x5d458c){const _0x4d3ca5=a0_0x11309b,_0x2f8547=String(_0x5d064f||'')['replace'](/^v/,'')['split'](/[.-]/)['map'](_0x1f822f=>Number[_0x4d3ca5(0x112)](_0x1f822f,0xa)||0x0),_0x3f1df2=String(_0x5d458c||'')[_0x4d3ca5(0x142)](/^v/,'')['split'](/[.-]/)['map'](_0x7f3046=>Number[_0x4d3ca5(0x112)](_0x7f3046,0xa)||0x0);for(let _0x2693d8=0x0;_0x2693d8<Math['max'](_0x2f8547[_0x4d3ca5(0x11c)],_0x3f1df2['length'],0x3);_0x2693d8++){const _0x22f678=_0x2f8547[_0x2693d8]||0x0,_0x249a5a=_0x3f1df2[_0x2693d8]||0x0;if(_0x22f678>_0x249a5a)return 0x1;if(_0x22f678<_0x249a5a)return-0x1;}return 0x0;}function resolveExecutable(_0x1c1c62){const _0xfe9a7c=a0_0x11309b,_0x5725b2=process[_0xfe9a7c(0x154)]===_0xfe9a7c(0xfb)?'where.exe':'which';try{const _0xee42d2=(0x0,import_child_process[_0xfe9a7c(0x155)])(_0x5725b2,[_0x1c1c62],{'encoding':_0xfe9a7c(0x167),'timeout':0xbb8,'shell':![]});if(_0xee42d2['status']!==0x0)return'';return String(_0xee42d2['stdout']||'')['split'](/\r?\n/)[_0xfe9a7c(0x106)](_0x291d38=>_0x291d38[_0xfe9a7c(0x137)]())['filter'](Boolean)[0x0]||'';}catch{return'';}}function skipWrapperUpdateCheck(){const _0x191d23=a0_0x11309b,_0x380525=String(process.env.WHALENT_SKIP_UPDATE_CHECK||process.env.WHALENT_NO_UPDATE_CHECK||process.env.WHALENT_SKIP_WRAPPER_UPDATE||'')[_0x191d23(0x137)]()['toLowerCase']();return _0x380525==='1'||_0x380525===_0x191d23(0x119)||_0x380525===_0x191d23(0x115)||_0x380525==='on';}function latestWrapperVersion(){const _0x5e1d99=a0_0x11309b,_0x16fce0=runNpmView([_0x5e1d99(0x114),WRAPPER_PKG_NAME+_0x5e1d99(0x124),'version',_0x5e1d99(0x13f)+NPM_REGISTRY]);if(_0x16fce0['status']!==0x0)return'';return String(_0x16fce0[_0x5e1d99(0x125)]||'')[_0x5e1d99(0x137)]()['split'](/\r?\n/)[_0x5e1d99(0x15d)](Boolean)['pop']()||'';}function installWrapperVersion(_0xc90f1a){const _0x4d8ba3=a0_0x11309b,_0x59eb95=resolveExecutable(_0x4d8ba3(0xfa));if(!_0x59eb95)return{'ok':![],'output':'npm\x20not\x20found\x20on\x20PAT'+'H'};const _0x2862dc=run(_0x59eb95,['install','-g',WRAPPER_PKG_NAME+'@'+_0xc90f1a,'--registry='+NPM_REGISTRY]),_0x1d6590=((_0x2862dc[_0x4d8ba3(0x125)]||'')+'\x0a'+(_0x2862dc[_0x4d8ba3(0xed)]||''))[_0x4d8ba3(0x137)]();return{'ok':_0x2862dc['status']===0x0,'output':_0x1d6590};}function maybeUpdateWrapper(_0x351e3c){const _0xb0dd09=a0_0x11309b;if(skipWrapperUpdateCheck())return![];if(process.env.WHALENT_WRAPPER_UPDATE_ATTEMPTED)return![];const _0x890611=latestWrapperVersion();if(!_0x890611||compareSemver(_0x890611,WRAPPER_VERSION)<=0x0)return![];console[_0xb0dd09(0x113)]('[wrapper]\x20update\x20ava'+'ilable:\x20'+WRAPPER_VERSION+_0xb0dd09(0x15f)+_0x890611),console['warn']('[wrapper]\x20installing'+'\x20'+WRAPPER_PKG_NAME+'@'+_0x890611+(_0xb0dd09(0x104)+_0xb0dd09(0x15e)));const _0x2786f8=installWrapperVersion(_0x890611);if(!_0x2786f8['ok']){console[_0xb0dd09(0x113)]('[wrapper]\x20wrapper\x20up'+_0xb0dd09(0x121)+_0xb0dd09(0x16d)+WRAPPER_VERSION);if(_0x2786f8['output'])console[_0xb0dd09(0x113)](_0x2786f8[_0xb0dd09(0x173)]['split'](/\r?\n/)['slice'](-0xc)[_0xb0dd09(0x171)]('\x0a'));return console['warn'](_0xb0dd09(0x169)+'ate:\x20npm\x20install\x20-g\x20'+WRAPPER_PKG_NAME+'@'+_0x890611+'\x20--registry='+NPM_REGISTRY),![];}console[_0xb0dd09(0x113)](_0xb0dd09(0x13a)+_0xb0dd09(0x164)+_0x890611+';\x20restarting\x20wrapper');const _0x492556=process[_0xb0dd09(0x110)][0x1],_0x377e5f=(0x0,import_child_process[_0xb0dd09(0x155)])(process['execPath'],[_0x492556,..._0x351e3c],{'stdio':_0xb0dd09(0x11b),'env':{...process.env,'WHALENT_WRAPPER_UPDATE_ATTEMPTED':_0x890611},'shell':![]});process['exit'](_0x377e5f['status']??0x0);}function findCoreScript(){const _0x3baa16=a0_0x11309b,_0x34a875=String(process.env.WHALENT_CORE_ENTRY||'')[_0x3baa16(0x137)](),_0x13fa5b=['1',_0x3baa16(0x119),_0x3baa16(0x115),'on'][_0x3baa16(0x158)](String(process.env.WHALENT_FORCE_CORE_ENTRY||'')['trim']()[_0x3baa16(0x10c)]());if(_0x34a875&&_0x13fa5b&&fs['existsSync'](_0x34a875))return _0x34a875;const _0x368370=[],_0x3fad0b=_0x5367df=>{const _0x82162a=_0x3baa16;if(fs[_0x82162a(0x109)](_0x5367df)&&!_0x368370['includes'](_0x5367df))_0x368370['push'](_0x5367df);};if(_0x34a875)_0x3fad0b(_0x34a875);const _0x5dbf8c=npmRootGlobal();if(_0x5dbf8c){const _0x102db8=path[_0x3baa16(0x171)](_0x5dbf8c,_0x3baa16(0x157),'agent-core',_0x3baa16(0x143),'index.cjs');_0x3fad0b(_0x102db8);}const _0x1a571a=path['join'](wrapperBaseDir(),_0x3baa16(0x132));_0x3fad0b(_0x1a571a);const _0x3d77dc=path['join'](wrapperBaseDir(),'..',_0x3baa16(0x13c),_0x3baa16(0x16b),_0x3baa16(0x143),_0x3baa16(0x12b));_0x3fad0b(_0x3d77dc);if(_0x368370[_0x3baa16(0x11c)]>0x0)return _0x368370['map']((_0x46ac81,_0x4fa7be)=>({'candidate':_0x46ac81,'index':_0x4fa7be,'version':coreVersion(_0x46ac81)}))['sort']((_0x137c16,_0x47c61c)=>{const _0x5ce2a5=_0x3baa16,_0x30dc51=compareSemver(_0x47c61c[_0x5ce2a5(0x127)],_0x137c16['version']);if(_0x30dc51!==0x0)return _0x30dc51;return _0x47c61c[_0x5ce2a5(0x10b)]-_0x137c16[_0x5ce2a5(0x10b)];})[0x0]['candidate'];throw new Error('whalent\x20core\x20runtime'+'\x20not\x20found;\x20install\x20'+'@whalent/agent-core\x20'+_0x3baa16(0x149)+_0x3baa16(0x117));}function a0_0x1032(_0x38cf5c,_0x68e73e){_0x38cf5c=_0x38cf5c-0xea;const _0x176f60=a0_0x176f();let _0x10322d=_0x176f60[_0x38cf5c];if(a0_0x1032['ldmcLF']===undefined){var _0x379035=function(_0x2cc480){const _0x4c17e7='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0xfe6f55='',_0x2d894e='';for(let _0xbacaca=0x0,_0x109513,_0x505143,_0x411cf0=0x0;_0x505143=_0x2cc480['charAt'](_0x411cf0++);~_0x505143&&(_0x109513=_0xbacaca%0x4?_0x109513*0x40+_0x505143:_0x505143,_0xbacaca++%0x4)?_0xfe6f55+=String['fromCharCode'](0xff&_0x109513>>(-0x2*_0xbacaca&0x6)):0x0){_0x505143=_0x4c17e7['indexOf'](_0x505143);}for(let _0x1202ed=0x0,_0x4d0ba5=_0xfe6f55['length'];_0x1202ed<_0x4d0ba5;_0x1202ed++){_0x2d894e+='%'+('00'+_0xfe6f55['charCodeAt'](_0x1202ed)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x2d894e);};a0_0x1032['ohlwgP']=_0x379035,a0_0x1032['qWIlwA']={},a0_0x1032['ldmcLF']=!![];}const _0x573158=_0x176f60[0x0],_0x3393c3=_0x38cf5c+_0x573158,_0x39952b=a0_0x1032['qWIlwA'][_0x3393c3];return!_0x39952b?(_0x10322d=a0_0x1032['ohlwgP'](_0x10322d),a0_0x1032['qWIlwA'][_0x3393c3]=_0x10322d):_0x10322d=_0x39952b,_0x10322d;}function coreVersion(_0x2f8f8b=findCoreScript()){const _0x2810cc=a0_0x11309b,_0x10a8b4=(0x0,import_child_process['spawnSync'])(process[_0x2810cc(0x138)],[_0x2f8f8b,'--version'],{'encoding':_0x2810cc(0x167),'timeout':0x3a98,'env':{...process.env,'WHALENT_SKIP_UPDATE_CHECK':'1'},'shell':![]}),_0x187fc9=(_0x10a8b4[_0x2810cc(0x125)]||'')+'\x0a'+(_0x10a8b4['stderr']||'');return _0x187fc9[_0x2810cc(0x130)](/(\d+\.\d+\.\d+(?:[-\w.]+)?)/)?.[0x1]||'';}function isExecutable(_0x274e41){const _0xb2f225=a0_0x11309b;try{return fs[_0xb2f225(0x165)](_0x274e41,fs['constants']['X_OK']),!![];}catch{return![];}}function shellQuote(_0xe2c594){const _0x217bb7=a0_0x11309b;return'\x27'+_0xe2c594['replace'](/'/g,_0x217bb7(0x13d))+'\x27';}function coreNodePtySpawnHelperPath(_0x1d13fa){const _0x470390=a0_0x11309b;if(process[_0x470390(0x154)]!==_0x470390(0xff))return'';try{const _0x4b53c5=(0x0,import_module[_0x470390(0x122)])(_0x1d13fa),_0x290c49=_0x4b53c5['resolve']('node-pty'),_0xcbffc9=path[_0x470390(0x10d)](path[_0x470390(0x108)](_0x290c49),'..');return path['join'](_0xcbffc9,_0x470390(0x14a),_0x470390(0xf8)+process[_0x470390(0x12e)],'spawn-helper');}catch{return'';}}function checkMacNodePtySpawnHelper(_0x2798f1){const _0x174352=a0_0x11309b,_0x2a6b13=coreNodePtySpawnHelperPath(_0x2798f1);if(!_0x2a6b13||CHECKED_PTY_HELPERS[_0x174352(0x15b)](_0x2a6b13))return;CHECKED_PTY_HELPERS['add'](_0x2a6b13);if(!fs[_0x174352(0x109)](_0x2a6b13)){console[_0x174352(0x113)](_0x174352(0xf4)+_0x174352(0x16e)+_0x174352(0x126)+_0x2a6b13);return;}if(isExecutable(_0x2a6b13))return;try{const _0x31d226=fs[_0x174352(0x170)](_0x2a6b13)[_0x174352(0xf2)];fs['chmodSync'](_0x2a6b13,_0x31d226|0x1ed);}catch{}if(isExecutable(_0x2a6b13)){console['warn']('[wrapper]\x20fixed\x20macO'+'S\x20node-pty\x20spawn-hel'+'per\x20executable\x20bit:\x20'+_0x2a6b13);return;}console[_0x174352(0x113)]('[wrapper]\x20macOS\x20node'+'-pty\x20spawn-helper\x20is'+'\x20not\x20executable:\x20'+_0x2a6b13),console[_0x174352(0x113)](_0x174352(0x103)+'nce\x20to\x20fix\x20terminal/'+_0x174352(0x14c)),console[_0x174352(0x113)](_0x174352(0xf9)+shellQuote(_0x2a6b13)),console[_0x174352(0x113)](_0x174352(0xf7)),console[_0x174352(0x113)]('\x20\x20chmod\x20+x\x20\x22$HELPER\x22');}function printVersion(){const _0x59a460=a0_0x11309b;let _0x10a283='';try{_0x10a283=coreVersion();}catch{}console['log']('whalent-agent\x20'+WRAPPER_VERSION),console[_0x59a460(0xfe)](_0x59a460(0xf1)+WRAPPER_VERSION),console[_0x59a460(0xfe)]('core\x20'+(_0x10a283||'not\x20installed'));}function directCore(_0x32f894){const _0x19a5fe=a0_0x11309b,_0xb321bd=findCoreScript();checkMacNodePtySpawnHelper(_0xb321bd);const _0x15b40f=(0x0,import_child_process[_0x19a5fe(0x155)])(process['execPath'],[_0xb321bd,..._0x32f894],{'stdio':'inherit','env':{...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_CORE_ENTRY':_0xb321bd},'shell':![]});process[_0x19a5fe(0xec)](_0x15b40f['status']??0x0);}function shouldSupervise(_0x491c7c){const _0xc143a=a0_0x11309b;if(_0x491c7c['includes']('--agent-id'))return![];if(_0x491c7c[_0xc143a(0x158)](_0xc143a(0x12d))||_0x491c7c[0x0]===_0xc143a(0x133))return![];const _0x21b660=_0x491c7c[0x0]||'';if(_0x21b660==='ls'||_0x21b660===_0xc143a(0x16c)||_0x21b660==='ps')return![];if(_0x21b660===_0xc143a(0x16f)||_0x21b660===_0xc143a(0x148))return![];if(_0x491c7c[_0xc143a(0x158)]('--help')||_0x491c7c['includes']('-h'))return![];return!![];}function installCoreVersion(_0x52e613){const _0x228b71=a0_0x11309b,_0x21b3f4=resolveExecutable(_0x228b71(0xfa));if(!_0x21b3f4)return{'ok':![],'output':_0x228b71(0x10f)+'H'};const _0x3ab1b9=CORE_PKG_NAME+'@'+_0x52e613,_0x58ffd7=run(_0x21b3f4,['install','-g',_0x3ab1b9,'--registry='+NPM_REGISTRY]),_0x126787=((_0x58ffd7[_0x228b71(0x125)]||'')+'\x0a'+(_0x58ffd7['stderr']||''))['trim']();return{'ok':_0x58ffd7['status']===0x0,'output':_0x126787};}async function superviseCore(_0xe7ba2e){const _0x338c2f=a0_0x11309b;let _0x83181a=![],_0x306804=null;const _0x3639f9=[];let _0x3fdd6b=MIN_RESTART_DELAY_MS;const _0x53d448=()=>{const _0x34c467=a0_0x1032;_0x83181a=!![];if(_0x306804&&!_0x306804[_0x34c467(0x14b)])try{_0x306804['kill'](_0x34c467(0x145));}catch{}else process[_0x34c467(0xec)](0x0);};process['on'](_0x338c2f(0x146),_0x53d448),process['on']('SIGTERM',_0x53d448);while(!![]){const _0x5b46e4=findCoreScript();checkMacNodePtySpawnHelper(_0x5b46e4);const _0x3cf01b={...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_WRAPPER_MANAGED':'1','WHALENT_CORE_ENTRY':_0x5b46e4},_0x463cbc=readUpgradeState(),_0xc0ede1=!!_0x463cbc?.['pending'];let _0x57fcee=![],_0x1a71b0=null,_0x5c444e='';const _0x49ba23=[],_0x4b110f=0xc;console[_0x338c2f(0xfe)](_0x338c2f(0xeb)+_0x338c2f(0x16a)+_0x5b46e4),_0x306804=(0x0,import_child_process[_0x338c2f(0x156)])(process[_0x338c2f(0x138)],[_0x5b46e4,..._0xe7ba2e],{'env':_0x3cf01b,'stdio':[_0x338c2f(0x11b),'pipe',_0x338c2f(0x12a)]});const _0xa34840=()=>{if(_0x57fcee)return;_0x57fcee=!![];if(_0x1a71b0)clearTimeout(_0x1a71b0);_0x3639f9['length']=0x0,_0x3fdd6b=MIN_RESTART_DELAY_MS;const _0x5c4627=readUpgradeState();_0x5c4627?.['pending']&&(writeUpgradeState({..._0x5c4627,'pending':![],'rollback':![],'health_status':'healthy'}),console['log']('[wrapper]\x20core\x20upgra'+'de\x20healthy:\x20'+(_0x5c4627['installed_version']||_0x5c4627['target_version']||'')));},_0xdf81a8=(_0x1f696f,_0x56f90=![])=>{const _0x579c2e=_0x338c2f,_0x4cd65d=_0x1f696f['toString']();(_0x56f90?process[_0x579c2e(0xed)]:process[_0x579c2e(0x125)])[_0x579c2e(0x120)](_0x4cd65d);if(_0x56f90)for(const _0x5a6472 of _0x4cd65d['split'](/\r?\n/)){if(!_0x5a6472['trim']())continue;_0x49ba23['push'](_0x5a6472);if(_0x49ba23['length']>_0x4b110f)_0x49ba23[_0x579c2e(0x10e)]();const _0x1c2f7a=_0x5a6472['match'](FATAL_PATTERN);if(_0x1c2f7a)_0x5c444e=_0x1c2f7a[0x0];}(_0x4cd65d['includes']('[gateway]\x20Connected')||_0x4cd65d[_0x579c2e(0x158)](_0x579c2e(0x162)+'achine')||_0x4cd65d['includes']('Gateway:\x20connected'))&&_0xa34840();};_0x306804['stdout']?.['on'](_0x338c2f(0x159),_0x133cf2=>_0xdf81a8(_0x133cf2,![])),_0x306804['stderr']?.['on'](_0x338c2f(0x159),_0x138892=>_0xdf81a8(_0x138892,!![]));_0xc0ede1&&(_0x1a71b0=setTimeout(()=>{const _0x636ba=_0x338c2f;if(_0x57fcee||!_0x306804||_0x306804[_0x636ba(0x14b)])return;console[_0x636ba(0xfd)](_0x636ba(0x123)+_0x636ba(0x15a)+'y\x20in\x20time;\x20rolling\x20b'+'ack');try{_0x306804[_0x636ba(0x131)]('SIGTERM');}catch{}},HEALTH_TIMEOUT_MS));const _0x913d21=await new Promise(_0x4de3d6=>{_0x306804['once']('exit',(_0x10e907,_0x23014c)=>_0x4de3d6({'code':_0x10e907,'signal':_0x23014c}));});if(_0x1a71b0)clearTimeout(_0x1a71b0);_0x306804=null;if(_0x83181a)process['exit'](_0x913d21['code']??0x0);const _0x45f9ee=readUpgradeState();if(_0x45f9ee?.[_0x338c2f(0x11e)]&&!_0x57fcee){const _0x39ce7c=String(_0x45f9ee['previous_core_versio'+'n']||'')['trim']();if(_0x39ce7c){console['error']('[wrapper]\x20rolling\x20ba'+_0x338c2f(0x101)+_0x39ce7c);const _0xe1b07d=installCoreVersion(_0x39ce7c);writeUpgradeState({..._0x45f9ee,'pending':![],'rollback':!![],'health_status':_0xe1b07d['ok']?'rolled_back':'rollback_failed','error':_0xe1b07d['ok']?'':_0xe1b07d[_0x338c2f(0x173)]});}else writeUpgradeState({..._0x45f9ee,'pending':![],'rollback':!![],'health_status':'rollback_unavailable','error':'previous\x20core\x20versio'+_0x338c2f(0x160)});}const _0x5c2d8e=_0x913d21[_0x338c2f(0x151)]===SUPERVISED_RESTART_CODE||_0x45f9ee?.['pending'];if(!_0x5c2d8e&&_0x913d21[_0x338c2f(0x151)]===0x0)process[_0x338c2f(0xec)](0x0);const _0x43c84e=Date['now']();_0x3639f9['push'](_0x43c84e);while(_0x3639f9['length']>0x0&&_0x43c84e-_0x3639f9[0x0]>CRASH_WINDOW_MS){_0x3639f9[_0x338c2f(0x10e)]();}const _0x1cfd22=_0x3639f9['length'];writeLastCrash({'timestamp':_0x43c84e,'exit_code':_0x913d21[_0x338c2f(0x151)],'exit_signal':_0x913d21['signal']||null,'fatal_line':_0x5c444e,'raw_tail':_0x49ba23['join']('\x0a'),'consecutive_crashes':_0x1cfd22}),console['log']('[wrapper]\x20core\x20exite'+_0x338c2f(0x150)+(_0x913d21[_0x338c2f(0x151)]??'')+(_0x913d21['signal']?_0x338c2f(0x11d)+_0x913d21['signal']:'')+'\x20('+_0x1cfd22+'/'+MAX_CRASHES_IN_WINDOW+'\x20in\x20last\x20'+Math['round'](CRASH_WINDOW_MS/0x3e8)+'s)');if(_0x5c444e)console[_0x338c2f(0xfe)]('[wrapper]\x20last\x20fatal'+':\x20'+_0x5c444e);_0x1cfd22>=MAX_CRASHES_IN_WINDOW&&(console[_0x338c2f(0xfd)](_0x338c2f(0x12c)+'d\x20'+_0x1cfd22+'\x20times\x20within\x20'+Math[_0x338c2f(0xee)](CRASH_WINDOW_MS/0x3e8)+('s;\x20giving\x20up.\x20Crash\x20'+_0x338c2f(0x140))+lastCrashFilePath()+('.\x20Restart\x20wrapper\x20ma'+_0x338c2f(0x128)+'erlying\x20issue\x20is\x20fix'+_0x338c2f(0x153))),process['exit'](0x1)),console['log'](_0x338c2f(0x161)+'\x20in\x20'+_0x3fdd6b+'ms'),await new Promise(_0x47bd55=>setTimeout(_0x47bd55,_0x3fdd6b)),_0x3fdd6b=Math['min'](_0x3fdd6b*0x2,MAX_RESTART_DELAY_MS);}}function a0_0x176f(){const _0x14b13b=['zMLSDgvY','CNrPBMCGy29Yzs4UlG','ic0+ia','BIb1BMTUB3DU','w3DYyxbWzxjDihjLC3rHCNrPBMC','r2f0zxDHEsbYzwDPC3rLCMvKig0','mc4WlJa','zgf0zwqGDg8G','ywnJzxnZu3LUyW','mtq4ndmWmeTtDuXlzW','DxrMoa','ChrVCG','w3DYyxbWzxjDie1HBNvHBcb1Cgq','B3jLoIa','y29Yzq','C3rHDhvZ','Aw5NihDPDgGG','lxb0EsbZCgf3BI1OzwXWzxiGBM8','BwnW','C3rHDfn5BMm','AM9PBG','mteYodKXmuD1zNb5BG','B3v0Chv0','CMvHzezPBgvtEw5J','w3DYyxbWzxjDihn0yxj0Aw5Nigm','zxHPDa','C3rKzxjY','CM91BMq','odGYntHeuMHgrMu','BwTKAxjtEw5J','D3jHChbLCIa','Bw9Kzq','ChjVDg90ExbL','w3DYyxbWzxjDig1Hy09tig5Vzgu','z2v0t3DUuhjVCgvYDhLezxnJCMK','CJOG','icbSCYaTBcaIjeHftfbfuIi','zgfYD2LUlq','icbiruXqrvi9','BNbT','D2LUmZi','mJqZmZmWrfv6zK5s','zxjYB3i','Bg9N','zgfYD2LU','y2fSBa','y2SGy29Yzsb0BYa','odKYnZfhB1DIq3C','w3DYyxbWzxjDifj1BIb0AgLZig8','igzYB20GBNbTigjLzM9YzsbZDge','CgfYC2u','BwfW','AgfZt3DUuhjVCgvYDhK','zgLYBMfTzq','zxHPC3rZu3LUyW','y2HPBgrFChjVy2vZCW','Aw5KzxG','Dg9mB3DLCKnHC2u','CMvZB2X2zq','C2HPzNq','BNbTig5VDcbMB3vUzcbVBIbqqvq','yxjNDG','zgvMAw5LuhjVCgvYDhK','CgfYC2vjBNq','D2fYBG','DMLLDW','EwvZ','x19LC01VzhvSzq','ywDLBNq','ls12zxjZAw9U','Dhj1zq','zgvMyxvSDa','Aw5OzxjPDa','BgvUz3rO','ihnPz25HBd0','CgvUzgLUzW','qhDOywXLBNqVywDLBNq','D3jPDgu','zgf0zsbMywLSzwq7ignVBNrPBNu','y3jLyxrLuMvXDwLYzq','w3DYyxbWzxjDig5LDYbJB3jLigq','qgXHDgvZDa','C3rKB3v0','DcbMB3vUzdOG','DMvYC2LVBG','BNvHBgX5igfMDgvYihrOzsb1BMq','CM9VDa','CgLWzq','Aw5KzxGUy2PZ','w3DYyxbWzxjDignVCMuGzMfPBgu','ls1Yzxn1Bwu','yxjJAa','DxrMltG','Bwf0y2G','A2LSBa','y29Yzs5JANm','CMvZDw1L','C2XPy2u','C3rYAw5NAwz5','mZyWv252zMHV','DhjPBq','zxHLy1bHDgG','nKfArfjMAW','w3DYyxbWzxjDihDYyxbWzxiGDxa','m1n2DLjtza','CgfJA2fNzxm','j1WNjW','y29Yzsa','ls1YzwDPC3rYEt0','CMvJB3jKoIa','BwvZC2fNzq','CMvWBgfJzq','zgLZDa','BNbTig5VDcbMB3vUza','u0Lhvevstq','u0Lhsu5u','ANmUB3jN','zgfLBw9Ulw1JCa','B3iGCMvIDwLSzcbaD2HHBgvUDc8','ChjLyNvPBgrZ','A2LSBgvK','ufrzihn0yxj0Dxa6','zNvUy3rPB24','lNDOywXLBNqTywDLBNq','Bw9KDwXL','zcbJB2rLpq','y29Kzq','mtm5ntiWt0z0qwXo','zwqU','CgXHDgzVCM0','C3bHD25tEw5J','C3bHD24','qhDOywXLBNq','Aw5JBhvKzxm','zgf0yq','AwqGBM90igjLy29TzsbOzwfSDgG','AgfZ','mJi5otqXnLnPzMHKtq'];a0_0x176f=function(){return _0x14b13b;};return a0_0x176f();}async function main(){const _0x24c3e8=a0_0x11309b,_0x3a9aef=process['argv'][_0x24c3e8(0x134)](0x2);if(_0x3a9aef[0x0]===_0x24c3e8(0x118)||_0x3a9aef[0x0]==='-v'||_0x3a9aef[0x0]==='version'){printVersion();return;}if((_0x3a9aef[0x0]===_0x24c3e8(0x16c)||_0x3a9aef[0x0]==='ls'||_0x3a9aef[0x0]==='ps')&&!_0x3a9aef[_0x24c3e8(0x158)]('--json')){console['log']('wrapper\x20'+WRAPPER_VERSION);try{console[_0x24c3e8(0xfe)](_0x24c3e8(0x13e)+(coreVersion()||'not\x20installed'));}catch{console[_0x24c3e8(0xfe)]('core\x20not\x20installed');}}maybeUpdateWrapper(_0x3a9aef);if(!shouldSupervise(_0x3a9aef))directCore(_0x3a9aef);await superviseCore(_0x3a9aef);}main()['catch'](_0x1a1213=>{const _0x4cb330=a0_0x11309b;console['error']('[wrapper]\x20Fatal\x20erro'+_0x4cb330(0xf6)+(_0x1a1213?.[_0x4cb330(0x141)]||String(_0x1a1213))),process[_0x4cb330(0xec)](0x1);});
2
+ 'use strict';const a0_0x5141f2=a0_0x41c2;(function(_0x29a8eb,_0x1ebfd1){const _0x1fee5b=a0_0x41c2,_0x466faf=_0x29a8eb();while(!![]){try{const _0x45bd7e=-parseInt(_0x1fee5b(0x253))/0x1+parseInt(_0x1fee5b(0x1ed))/0x2*(parseInt(_0x1fee5b(0x1fc))/0x3)+-parseInt(_0x1fee5b(0x244))/0x4+parseInt(_0x1fee5b(0x1d6))/0x5+parseInt(_0x1fee5b(0x21f))/0x6*(-parseInt(_0x1fee5b(0x202))/0x7)+parseInt(_0x1fee5b(0x232))/0x8*(parseInt(_0x1fee5b(0x1cb))/0x9)+-parseInt(_0x1fee5b(0x1ea))/0xa;if(_0x45bd7e===_0x1ebfd1)break;else _0x466faf['push'](_0x466faf['shift']());}catch(_0x156067){_0x466faf['push'](_0x466faf['shift']());}}}(a0_0x4480,0x5269e));var __create=Object[a0_0x5141f2(0x245)],__defProp=Object[a0_0x5141f2(0x20c)],__getOwnPropDesc=Object[a0_0x5141f2(0x20f)+a0_0x5141f2(0x1db)],__getOwnPropNames=Object[a0_0x5141f2(0x1dc)],__getProtoOf=Object[a0_0x5141f2(0x24c)],__hasOwnProp=Object['prototype']['hasOwnProperty'],__copyProps=(_0x7a2112,_0x1db379,_0x15df90,_0x2db4dc)=>{const _0x5c2fab=a0_0x5141f2;if(_0x1db379&&typeof _0x1db379===_0x5c2fab(0x1da)||typeof _0x1db379===_0x5c2fab(0x25b)){for(let _0x3ab7eb of __getOwnPropNames(_0x1db379))if(!__hasOwnProp['call'](_0x7a2112,_0x3ab7eb)&&_0x3ab7eb!==_0x15df90)__defProp(_0x7a2112,_0x3ab7eb,{'get':()=>_0x1db379[_0x3ab7eb],'enumerable':!(_0x2db4dc=__getOwnPropDesc(_0x1db379,_0x3ab7eb))||_0x2db4dc['enumerable']});}return _0x7a2112;},__toESM=(_0x55b0de,_0x158804,_0x2d1024)=>(_0x2d1024=_0x55b0de!=null?__create(__getProtoOf(_0x55b0de)):{},__copyProps(_0x158804||!_0x55b0de||!_0x55b0de[a0_0x5141f2(0x1df)]?__defProp(_0x2d1024,'default',{'value':_0x55b0de,'enumerable':!![]}):_0x2d1024,_0x55b0de)),import_child_process=require(a0_0x5141f2(0x1c8)),fs=__toESM(require('fs'),0x1),import_module=require('module'),os=__toESM(require('os'),0x1),path=__toESM(require(a0_0x5141f2(0x224)),0x1),WRAPPER_PKG_NAME='@whalent/agent',CORE_PKG_NAME='@whalent/agent-core',NPM_REGISTRY=a0_0x5141f2(0x1ec)+'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,MAX_CRASHES_IN_WINDOW=0x3,CRASH_WINDOW_MS=0x3*0x3c*0x3e8,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(),CHECKED_NODE_PTY_RUNTIMES=new Set();function wrapperBaseDir(){return __dirname;}function configDir(){const _0x1d13cb=a0_0x5141f2;return path['join'](os[_0x1d13cb(0x227)](),'.whalent-agent');}function upgradeStatePath(){return path['join'](configDir(),'core-upgrade.json');}function lastCrashFilePath(){const _0x18ec86=a0_0x5141f2;return path[_0x18ec86(0x1ff)](configDir(),'last-crash.json');}function writeLastCrash(_0x465ac7){const _0x1a1906=a0_0x5141f2;try{fs[_0x1a1906(0x230)](configDir(),{'recursive':!![]});const _0x435faa={..._0x465ac7,'reported':![]};fs['writeFileSync'](lastCrashFilePath(),JSON[_0x1a1906(0x217)](_0x435faa,null,0x2),_0x1a1906(0x24e));}catch{}}function readWrapperVersion(){const _0x33dbc5=a0_0x5141f2;try{const _0x2df68d=JSON['parse'](fs[_0x33dbc5(0x258)](path[_0x33dbc5(0x1ff)](wrapperBaseDir(),'..',_0x33dbc5(0x1c9)),'utf-8'));return String(_0x2df68d[_0x33dbc5(0x22e)]||_0x33dbc5(0x243));}catch{return'0.0.0';}}function readUpgradeState(){try{return JSON['parse'](fs['readFileSync'](upgradeStatePath(),'utf-8'));}catch{return null;}}function a0_0x4480(){const _0x21b56d=['nti4yw5HDujp','igLUia','zguGAgvHBhrOEtOG','CM9SBgjHy2TFDw5HDMfPBgfIBgu','BwLU','DgfYDa','ls1Hz2vUDc1Pza','AgvHBhrOEq','w3DYyxbWzxjDihjLC3rHCNrPBMC','CgLWzq','zxjSEwLUzYbPC3n1zsbPCYbMAxG','w3DYyxbWzxjDignVCMuGDxbNCMe','BM90igLUC3rHBgXLza','CgvYigv4zwn1DgfIBguGyML0oIa','w3DYyxbWzxjDihn0yxj0Aw5Nigm','CZSGz2L2Aw5NihvWlIbdCMfZAca','BNbT','mc4WlJa','ntqWntq4s1vfChj0','y3jLyxrL','Dw5KoYbJyw5UB3qGCMvIDwLSzca','u0Lhsu5u','r2f0zxDHEsbYzwDPC3rLCMvKig0','Bg9N','BMfTzq','ywDLBNq','z2v0uhjVDg90ExbLt2y','y3jLyxrLuMvXDwLYzq','DxrMltG','CM91BMq','w3DYyxbWzxjDigLUC3rHBgXPBMC','u0Lhvevstq','yNvPBgq','mJqYowvnwMjKyq','D2HLCMuUzxHL','ls1OzwXW','BgvUz3rO','C3rHDhvZ','CMvHzezPBgvtEw5J','A2LSBa','yxjJAa','zNvUy3rPB24','CMvWBgfJzq','yxjNDG','BMnLihrVigzPEcb0zxjTAw5HBc8','D3jPDgvgAwXLu3LUyW','D2HPy2G','EsbPBIb0Aw1LoYbYB2XSAw5Nigi','yxrPDMuGBw9KDwXLigLZig1PC3m','y2f0y2G','Chr5lM5Vzgu','y2HPBgrFChjVy2vZCW','CgfJA2fNzs5QC29U','Aw5KzxGUy2PZ','ndCWnJfAuKfJt1C','C3rKB3v0','zgf0yq','C2LNBMfS','CM9SBgvKx2jHy2S','zxjYB3i','y29Yzq','lIbszxn0yxj0ihDYyxbWzxiGBwe','w3DYyxbWzxjDig5WBsbUB3qGzM8','Bwf4','C2XPy2u','mtGZmZm3nxD5zvfItW','lxb0EsbZCgf3BI1OzwXWzxiGAxm','w3DYyxbWzxjDigzPEgvKig1Hy08','zxHPC3rZu3LUyW','B2jQzwn0','ChrVCG','z2v0t3DUuhjVCgvYDhLoyw1LCW','CgfJA2fNzxm','ig5VDcbMB3vUzdSGAw5ZDgfSBca','x19LC01VzhvSzq','DhjPBq','zxHPDa','C3bHD25tEw5J','AwXHyMXLoIa','zgfYD2LUlq','CM9SBgjHy2TFzMfPBgvK','y29Yzsa','Dg9mB3DLCKnHC2u','ChjLDMLVDxmGy29Yzsb2zxjZAw8','Aw5OzxjPDa','mJiXmtq0mgXKDwX1tW','A2LSBgvK','Ahr0Chm6lY9YzwDPC3rYEs5UCg0','mKzlqKvyEa','y29Yzs5JANm','w3DYyxbWzxjDigXHC3qGzMf0ywW','BM9Kzs1WDhK','zxbLBMrLBMn5ig5VDcbYzxnVBhy','D2LUmZi','zgLYBMfTzq','D2fYBG','B3v0Chv0','ic0+ia','CMvHBhbHDgHtEw5J','ls12zxjZAw9U','CNrPBMCGy29Yzs4UlG','C3rKzxjY','w3DYyxbWzxjDignVCMuGzxHPDgu','mtu4otGYmhbRDurksG','Dhj1zq','ig5VDcbLEgvJDxrHyMXLoIa','AM9PBG','BwfW','w3DYyxbWzxjDig1Hy09tig5Vzgu','mtyZmwnxqvDruW','icbJAg1VzcaREcaIjeHftfbfuIi','y2SGy29Yzsb0BYa','zgfLBw9Ulw1JCa','CgfYC2vjBNq','B3jLoIa','w3DYyxbWzxjDig5VzguTChr5igq','w3DYyxbWzxjDig5VzguTChr5ihi','ihrPBwvZihDPDgHPBIa','CgvUzgLUzW','zgvMAw5LuhjVCgvYDhK','ChjLDMLVDxnFy29Yzv92zxjZAw8','CMvZB2X2zq','z2v0t3DUuhjVCgvYDhLezxnJCMK','ywrK','D3jHChbLCIa','ihnPz25HBd0','CgXHDgzVCM0','Aw5JBhvKzxm','Cg9W','y29UC3rHBNrZ','C3rYAw5NAwz5','BwvZC2fNzq','r2f0zxDHEtOGy29UBMvJDgvK','ywnR','DxrMoa','AgfZ','lxb0EsbZCgf3BI1OzwXWzxiGBM8','w3DYyxbWzxjDihDYyxbWzxiGDxa','mtqWndz3zxD0z0i','w3DYyxbWzxjDignVCMuGzMfPBgu','ChvZAa','y29YzsbUB3qGAw5ZDgfSBgvK','oYbJB3jLig1HEsbMywLSihrVihm','Cgf0Aa','zgf0zwqGDg8G','w3DYyxbWzxjDifj1BIb0AgLZig8','Ag9TzwrPCG','Aw5NihvUzgvYia','y29Kzq','zMLSDgvY','C29Tzq','igLUigXHC3qG','C3bSAxq','DMvYC2LVBG','C2HPzNq','BwTKAxjtEw5J','zgLZDa'];a0_0x4480=function(){return _0x21b56d;};return a0_0x4480();}function writeUpgradeState(_0x162209){const _0x4e30e8=a0_0x5141f2;try{fs[_0x4e30e8(0x230)](configDir(),{'recursive':!![]}),fs[_0x4e30e8(0x1c2)](upgradeStatePath(),JSON['stringify']({..._0x162209,'updated_at':Date['now']()},null,0x2),_0x4e30e8(0x24e));}catch{}}function run(_0x5b7780,_0x39fa19,_0x3b0352=process.env){const _0xfda870=a0_0x5141f2;return(0x0,import_child_process[_0xfda870(0x1e2)])(_0x5b7780,_0x39fa19,{'encoding':'utf8','timeout':NPM_INSTALL_TIMEOUT_MS,'maxBuffer':NPM_INSTALL_MAX_BUFFER,'env':_0x3b0352,'shell':![]});}function runNpmView(_0x2a1520){const _0x237415=resolveExecutable('npm');if(!_0x237415)return{'status':0x7f,'stdout':'','stderr':'npm\x20not\x20found','error':new Error('npm\x20not\x20found')};return(0x0,import_child_process['spawnSync'])(_0x237415,_0x2a1520,{'encoding':'utf8','timeout':NPM_VIEW_TIMEOUT_MS,'maxBuffer':0x400*0x400,'env':process.env,'shell':![]});}function npmRootGlobal(){const _0x4adaac=a0_0x5141f2,_0x26c852=resolveExecutable(_0x4adaac(0x242));if(!_0x26c852)return'';const _0x185050=run(_0x26c852,['root','-g']);if(_0x185050['status']!==0x0)return'';return String(_0x185050[_0x4adaac(0x1cc)]||'')[_0x4adaac(0x1e0)]();}function compareSemver(_0x13d4bc,_0x207e48){const _0x458f51=a0_0x5141f2,_0x2b7859=String(_0x13d4bc||'')[_0x458f51(0x25c)](/^v/,'')['split'](/[.-]/)['map'](_0x4387dc=>Number['parseInt'](_0x4387dc,0xa)||0x0),_0x313eb7=String(_0x207e48||'')['replace'](/^v/,'')[_0x458f51(0x22d)](/[.-]/)['map'](_0x26891b=>Number[_0x458f51(0x206)](_0x26891b,0xa)||0x0);for(let _0x5ad5c6=0x0;_0x5ad5c6<Math[_0x458f51(0x1d4)](_0x2b7859[_0x458f51(0x256)],_0x313eb7['length'],0x3);_0x5ad5c6++){const _0x59ebd7=_0x2b7859[_0x5ad5c6]||0x0,_0x596774=_0x313eb7[_0x5ad5c6]||0x0;if(_0x59ebd7>_0x596774)return 0x1;if(_0x59ebd7<_0x596774)return-0x1;}return 0x0;}function resolveExecutable(_0x2c8799){const _0x21096e=a0_0x5141f2,_0x4649cb=process[_0x21096e(0x213)]==='win32'?_0x21096e(0x254):_0x21096e(0x1c3);try{const _0x3465db=(0x0,import_child_process['spawnSync'])(_0x4649cb,[_0x2c8799],{'encoding':'utf8','timeout':0xbb8,'shell':![]});if(_0x3465db['status']!==0x0)return'';return String(_0x3465db['stdout']||'')[_0x21096e(0x22d)](/\r?\n/)[_0x21096e(0x200)](_0x271c1d=>_0x271c1d[_0x21096e(0x1e0)]())[_0x21096e(0x22a)](Boolean)[0x0]||'';}catch{return'';}}function skipWrapperUpdateCheck(){const _0x54164c=a0_0x5141f2,_0x3d0a27=String(process.env.WHALENT_SKIP_UPDATE_CHECK||process.env.WHALENT_NO_UPDATE_CHECK||process.env.WHALENT_SKIP_WRAPPER_UPDATE||'')['trim']()[_0x54164c(0x1e7)]();return _0x3d0a27==='1'||_0x3d0a27===_0x54164c(0x1fd)||_0x3d0a27==='yes'||_0x3d0a27==='on';}function latestWrapperVersion(){const _0x3a2282=a0_0x5141f2,_0x3d0f20=runNpmView(['view',WRAPPER_PKG_NAME+'@latest',_0x3a2282(0x22e),'--registry='+NPM_REGISTRY]);if(_0x3d0f20[_0x3a2282(0x257)]!==0x0)return'';return String(_0x3d0f20['stdout']||'')['trim']()[_0x3a2282(0x22d)](/\r?\n/)['filter'](Boolean)[_0x3a2282(0x215)]()||'';}function installWrapperVersion(_0x57c2b6){const _0x804b2b=a0_0x5141f2,_0x18005e=resolveExecutable(_0x804b2b(0x242));if(!_0x18005e)return{'ok':![],'output':'npm\x20not\x20found\x20on\x20PAT'+'H'};const _0x1c1159=run(_0x18005e,['install','-g',WRAPPER_PKG_NAME+'@'+_0x57c2b6,'--registry='+NPM_REGISTRY]),_0x5ceb6d=((_0x1c1159['stdout']||'')+'\x0a'+(_0x1c1159[_0x804b2b(0x1fa)]||''))[_0x804b2b(0x1e0)]();return{'ok':_0x1c1159['status']===0x0,'output':_0x5ceb6d};}function maybeUpdateWrapper(_0x13e828){const _0x356380=a0_0x5141f2;if(skipWrapperUpdateCheck())return![];if(process.env.WHALENT_WRAPPER_UPDATE_ATTEMPTED)return![];const _0x119724=latestWrapperVersion();if(!_0x119724||compareSemver(_0x119724,WRAPPER_VERSION)<=0x0)return![];console[_0x356380(0x1f4)]('[wrapper]\x20update\x20ava'+_0x356380(0x1e3)+WRAPPER_VERSION+_0x356380(0x1f6)+_0x119724),console['warn'](_0x356380(0x250)+'\x20'+WRAPPER_PKG_NAME+'@'+_0x119724+('\x20from\x20npm\x20before\x20sta'+_0x356380(0x1f9)));const _0x5ab6b7=installWrapperVersion(_0x119724);if(!_0x5ab6b7['ok']){console['warn'](_0x356380(0x21e)+'date\x20failed;\x20continu'+'ing\x20with\x20'+WRAPPER_VERSION);if(_0x5ab6b7[_0x356380(0x1f5)])console['warn'](_0x5ab6b7[_0x356380(0x1f5)]['split'](/\r?\n/)[_0x356380(0x1d5)](-0xc)[_0x356380(0x1ff)]('\x0a'));return console['warn']('[wrapper]\x20Manual\x20upd'+'ate:\x20npm\x20install\x20-g\x20'+WRAPPER_PKG_NAME+'@'+_0x119724+'\x20--registry='+NPM_REGISTRY),![];}console[_0x356380(0x1f4)](_0x356380(0x21e)+_0x356380(0x225)+_0x119724+';\x20restarting\x20wrapper');const _0x36f1a9=process[_0x356380(0x25d)][0x1],_0x171520=(0x0,import_child_process['spawnSync'])(process['execPath'],[_0x36f1a9,..._0x13e828],{'stdio':'inherit','env':{...process.env,'WHALENT_WRAPPER_UPDATE_ATTEMPTED':_0x119724},'shell':![]});process['exit'](_0x171520[_0x356380(0x257)]??0x0);}function findCoreScript(){const _0x185352=a0_0x5141f2,_0x32956a=String(process.env.WHALENT_CORE_ENTRY||'')['trim'](),_0xeb549c=['1','true','yes','on']['includes'](String(process.env.WHALENT_FORCE_CORE_ENTRY||'')['trim']()[_0x185352(0x1e7)]());if(_0x32956a&&_0xeb549c&&fs[_0x185352(0x1d9)](_0x32956a))return _0x32956a;const _0x191776=[],_0x3bd165=_0x2736a8=>{if(fs['existsSync'](_0x2736a8)&&!_0x191776['includes'](_0x2736a8))_0x191776['push'](_0x2736a8);};if(_0x32956a)_0x3bd165(_0x32956a);const _0x593691=npmRootGlobal();if(_0x593691){const _0x4dd0ea=path[_0x185352(0x1ff)](_0x593691,'@whalent','agent-core','dist','index.cjs');_0x3bd165(_0x4dd0ea);}const _0x24ded1=path['join'](wrapperBaseDir(),_0x185352(0x1ee));_0x3bd165(_0x24ded1);const _0x2d9237=path['join'](wrapperBaseDir(),'..',_0x185352(0x1dd),_0x185352(0x1d1),_0x185352(0x231),_0x185352(0x1ca));_0x3bd165(_0x2d9237);if(_0x191776['length']>0x0)return _0x191776['map']((_0x1de545,_0x35b7ff)=>({'candidate':_0x1de545,'index':_0x35b7ff,'version':coreVersion(_0x1de545)}))['sort']((_0x11efe1,_0x5720d5)=>{const _0x4a6329=_0x185352,_0x168045=compareSemver(_0x5720d5[_0x4a6329(0x22e)],_0x11efe1[_0x4a6329(0x22e)]);if(_0x168045!==0x0)return _0x168045;return _0x5720d5['index']-_0x11efe1['index'];})[0x0]['candidate'];throw new Error('whalent\x20core\x20runtime'+_0x185352(0x1de)+'@whalent/agent-core\x20'+'or\x20rebuild\x20@whalent/'+_0x185352(0x24b));}function coreVersion(_0x5d1857=findCoreScript()){const _0x2c707c=a0_0x5141f2;ensureNodePtyNativeModule(_0x5d1857);const _0x52c9e9=(0x0,import_child_process['spawnSync'])(process['execPath'],[_0x5d1857,_0x2c707c(0x1f8)],{'encoding':_0x2c707c(0x21b),'timeout':0x3a98,'env':{...process.env,'WHALENT_SKIP_UPDATE_CHECK':'1'},'shell':![]}),_0x10c88d=(_0x52c9e9['stdout']||'')+'\x0a'+(_0x52c9e9[_0x2c707c(0x1fa)]||'');return _0x10c88d['match'](/(\d+\.\d+\.\d+(?:[-\w.]+)?)/)?.[0x1]||'';}function isExecutable(_0x12782e){const _0x16550c=a0_0x5141f2;try{return fs['accessSync'](_0x12782e,fs[_0x16550c(0x216)]['X_OK']),!![];}catch{return![];}}function shellQuote(_0x1a9697){return'\x27'+_0x1a9697['replace'](/'/g,'\x27\x5c\x27\x27')+'\x27';}function corePackageRoot(_0x1b6cfa){const _0x274153=a0_0x5141f2;return path[_0x274153(0x20e)](path['dirname'](_0x1b6cfa),'..');}function nodePtyPackageRoot(_0x4f853f){const _0x3ed9f1=a0_0x5141f2,_0x5d3902=(0x0,import_module[_0x3ed9f1(0x24d)])(_0x4f853f),_0x2fa6ad=_0x5d3902[_0x3ed9f1(0x20e)]('node-pty');let _0x551430=path['dirname'](_0x2fa6ad);for(let _0x2afee2=0x0;_0x2afee2<0x5;_0x2afee2++){const _0x571f48=path[_0x3ed9f1(0x1ff)](_0x551430,'package.json');try{const _0x2010f3=JSON['parse'](fs[_0x3ed9f1(0x258)](_0x571f48,'utf-8'));if(_0x2010f3[_0x3ed9f1(0x24a)]==='node-pty')return _0x551430;}catch{}const _0x486b4d=path[_0x3ed9f1(0x1f3)](_0x551430);if(_0x486b4d===_0x551430)break;_0x551430=_0x486b4d;}return path['resolve'](path[_0x3ed9f1(0x1f3)](_0x2fa6ad),'..');}function nodePtyNativeCandidates(_0x3c2822){const _0x14bca6=a0_0x5141f2;return[path['join'](_0x3c2822,_0x14bca6(0x252),'Release','pty.node'),path[_0x14bca6(0x1ff)](_0x3c2822,'prebuilds',process['platform']+'-'+process[_0x14bca6(0x25a)],_0x14bca6(0x1c7))];}function hasNodePtyNativeModule(_0x2d7069){const _0x2c0aff=a0_0x5141f2;return nodePtyNativeCandidates(_0x2d7069)[_0x2c0aff(0x22b)](_0x56be39=>fs['existsSync'](_0x56be39));}function printNodePtyRebuildHint(_0x2c1fbe){const _0x48d651=a0_0x5141f2,_0x3f6c35=corePackageRoot(_0x2c1fbe);console['warn']('[wrapper]\x20Manual\x20fix'+':'),console[_0x48d651(0x1f4)]('\x20\x20cd\x20'+shellQuote(_0x3f6c35)),console[_0x48d651(0x1f4)]('\x20\x20npm\x20rebuild\x20node-p'+'ty\x20--verbose');}function ensureNodePtyNativeModule(_0xf0827d){const _0x5e4a60=a0_0x5141f2;if(process[_0x5e4a60(0x213)]===_0x5e4a60(0x1f2))return;let _0x32429e='';try{_0x32429e=nodePtyPackageRoot(_0xf0827d);}catch(_0x581cd3){console[_0x5e4a60(0x1f4)](_0x5e4a60(0x208)+_0x5e4a60(0x1f1)+'able\x20for\x20core:\x20'+_0x581cd3[_0x5e4a60(0x218)]),printNodePtyRebuildHint(_0xf0827d);return;}const _0x6351ad=((()=>{const _0x66a8b2=_0x5e4a60;try{return fs[_0x66a8b2(0x1f7)](_0x32429e);}catch{return _0x32429e;}})());if(CHECKED_NODE_PTY_RUNTIMES['has'](_0x6351ad))return;CHECKED_NODE_PTY_RUNTIMES[_0x5e4a60(0x210)](_0x6351ad);if(hasNodePtyNativeModule(_0x32429e))return;const _0x39c0b6=resolveExecutable(_0x5e4a60(0x242));console['warn']('[wrapper]\x20node-pty\x20n'+_0x5e4a60(0x1c5)+_0x5e4a60(0x228)+_0x32429e),console['warn']('[wrapper]\x20rebuilding'+'\x20node-pty\x20before\x20sta'+'rting\x20core...');if(!_0x39c0b6){console['warn'](_0x5e4a60(0x1d3)+_0x5e4a60(0x246)+'node-pty\x20automatical'+'ly'),printNodePtyRebuildHint(_0xf0827d);return;}const _0x259a35=corePackageRoot(_0xf0827d),_0x379ccc=(0x0,import_child_process[_0x5e4a60(0x1e2)])(_0x39c0b6,['rebuild',_0x5e4a60(0x1f0),'--verbose'],{'cwd':_0x259a35,'stdio':'inherit','timeout':NPM_INSTALL_TIMEOUT_MS,'env':process.env,'shell':![]});if(_0x379ccc[_0x5e4a60(0x257)]===0x0&&hasNodePtyNativeModule(_0x32429e)){console[_0x5e4a60(0x1f4)](_0x5e4a60(0x209)+'ebuild\x20completed');return;}console['warn'](_0x5e4a60(0x209)+'ebuild\x20failed'+(_0x379ccc[_0x5e4a60(0x257)]!==null?'\x20(exit='+_0x379ccc['status']+')':'')+(_0x5e4a60(0x223)+_0x5e4a60(0x237))),printNodePtyRebuildHint(_0xf0827d);}function coreNodePtySpawnHelperPath(_0x59d2fb){const _0x27ae82=a0_0x5141f2;if(process[_0x27ae82(0x213)]!=='darwin')return'';try{const _0x3afbc3=(0x0,import_module[_0x27ae82(0x24d)])(_0x59d2fb),_0x3aaa1e=_0x3afbc3['resolve']('node-pty'),_0xceeafa=path[_0x27ae82(0x20e)](path['dirname'](_0x3aaa1e),'..');return path['join'](_0xceeafa,'prebuilds',_0x27ae82(0x1e4)+process[_0x27ae82(0x25a)],'spawn-helper');}catch{return'';}}function checkMacNodePtySpawnHelper(_0x7604){const _0x332611=a0_0x5141f2,_0x2acd60=coreNodePtySpawnHelperPath(_0x7604);if(!_0x2acd60||CHECKED_PTY_HELPERS[_0x332611(0x21c)](_0x2acd60))return;CHECKED_PTY_HELPERS['add'](_0x2acd60);if(!fs[_0x332611(0x1d9)](_0x2acd60)){console['warn'](_0x332611(0x201)+_0x332611(0x21d)+'t\x20found:\x20'+_0x2acd60);return;}if(isExecutable(_0x2acd60))return;try{const _0x2b91c2=fs['statSync'](_0x2acd60)['mode'];fs['chmodSync'](_0x2acd60,_0x2b91c2|0x1ed);}catch{}if(isExecutable(_0x2acd60)){console[_0x332611(0x1f4)](_0x332611(0x1d8)+'S\x20node-pty\x20spawn-hel'+_0x332611(0x23f)+_0x2acd60);return;}console[_0x332611(0x1f4)](_0x332611(0x201)+_0x332611(0x1d7)+_0x332611(0x1fe)+_0x2acd60),console[_0x332611(0x1f4)](_0x332611(0x226)+_0x332611(0x25e)+'PTY\x20startup:'),console[_0x332611(0x1f4)]('\x20\x20HELPER='+shellQuote(_0x2acd60)),console[_0x332611(0x1f4)]('\x20\x20ls\x20-l\x20\x22$HELPER\x22'),console['warn'](_0x332611(0x203));}function printVersion(){const _0x45c1f5=a0_0x5141f2;let _0x268a93='';try{_0x268a93=coreVersion();}catch{}console['log']('whalent-agent\x20'+WRAPPER_VERSION),console[_0x45c1f5(0x249)](_0x45c1f5(0x211)+WRAPPER_VERSION),console['log']('core\x20'+(_0x268a93||_0x45c1f5(0x23e)));}function directCore(_0x5d8981){const _0x43362a=a0_0x5141f2,_0x47d45d=findCoreScript();ensureNodePtyNativeModule(_0x47d45d),checkMacNodePtySpawnHelper(_0x47d45d);const _0x2f0ef7=(0x0,import_child_process[_0x43362a(0x1e2)])(process['execPath'],[_0x47d45d,..._0x5d8981],{'stdio':_0x43362a(0x1e9),'env':{...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_CORE_ENTRY':_0x47d45d},'shell':![]});process['exit'](_0x2f0ef7[_0x43362a(0x257)]??0x0);}function shouldSupervise(_0x2d4c66){const _0x46ebf8=a0_0x5141f2;if(_0x2d4c66['includes'](_0x46ebf8(0x238)))return![];if(_0x2d4c66['includes']('--resume')||_0x2d4c66[0x0]==='resume')return![];const _0x49f9c1=_0x2d4c66[0x0]||'';if(_0x49f9c1==='ls'||_0x49f9c1==='status'||_0x49f9c1==='ps')return![];if(_0x49f9c1==='mcp'||_0x49f9c1===_0x46ebf8(0x205))return![];if(_0x2d4c66['includes'](_0x46ebf8(0x255))||_0x2d4c66[_0x46ebf8(0x214)]('-h'))return![];return!![];}function installCoreVersion(_0x3b4f20){const _0x32e567=a0_0x5141f2,_0xb113c3=resolveExecutable('npm');if(!_0xb113c3)return{'ok':![],'output':'npm\x20not\x20found\x20on\x20PAT'+'H'};const _0x3e6a93=CORE_PKG_NAME+'@'+_0x3b4f20,_0x22d6ff=run(_0xb113c3,['install','-g',_0x3e6a93,'--registry='+NPM_REGISTRY]),_0xd86eef=((_0x22d6ff['stdout']||'')+'\x0a'+(_0x22d6ff[_0x32e567(0x1fa)]||''))['trim']();return{'ok':_0x22d6ff[_0x32e567(0x257)]===0x0,'output':_0xd86eef};}function a0_0x41c2(_0x449b6a,_0xe17be2){_0x449b6a=_0x449b6a-0x1c2;const _0x4480df=a0_0x4480();let _0x41c2d3=_0x4480df[_0x449b6a];if(a0_0x41c2['jgYKyU']===undefined){var _0x37d5b6=function(_0x58ec4e){const _0x1cde3b='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x7a2112='',_0x1db379='';for(let _0x15df90=0x0,_0x2db4dc,_0x3ab7eb,_0x55b0de=0x0;_0x3ab7eb=_0x58ec4e['charAt'](_0x55b0de++);~_0x3ab7eb&&(_0x2db4dc=_0x15df90%0x4?_0x2db4dc*0x40+_0x3ab7eb:_0x3ab7eb,_0x15df90++%0x4)?_0x7a2112+=String['fromCharCode'](0xff&_0x2db4dc>>(-0x2*_0x15df90&0x6)):0x0){_0x3ab7eb=_0x1cde3b['indexOf'](_0x3ab7eb);}for(let _0x158804=0x0,_0x2d1024=_0x7a2112['length'];_0x158804<_0x2d1024;_0x158804++){_0x1db379+='%'+('00'+_0x7a2112['charCodeAt'](_0x158804)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x1db379);};a0_0x41c2['mRUuBv']=_0x37d5b6,a0_0x41c2['cqCQiV']={},a0_0x41c2['jgYKyU']=!![];}const _0x55212e=_0x4480df[0x0],_0x4ee048=_0x449b6a+_0x55212e,_0x2b6e6e=a0_0x41c2['cqCQiV'][_0x4ee048];return!_0x2b6e6e?(_0x41c2d3=a0_0x41c2['mRUuBv'](_0x41c2d3),a0_0x41c2['cqCQiV'][_0x4ee048]=_0x41c2d3):_0x41c2d3=_0x2b6e6e,_0x41c2d3;}async function superviseCore(_0x53c6fa){const _0x268794=a0_0x5141f2;let _0x271aa6=![],_0x19134b=null;const _0x26e11b=[];let _0xdcc511=MIN_RESTART_DELAY_MS;const _0x15a15b=()=>{const _0xa05513=a0_0x41c2;_0x271aa6=!![];if(_0x19134b&&!_0x19134b['killed'])try{_0x19134b[_0xa05513(0x259)](_0xa05513(0x251));}catch{}else process[_0xa05513(0x1e1)](0x0);};process['on'](_0x268794(0x247),_0x15a15b),process['on']('SIGTERM',_0x15a15b);while(!![]){const _0xafe8d=findCoreScript();ensureNodePtyNativeModule(_0xafe8d),checkMacNodePtySpawnHelper(_0xafe8d);const _0x5d3d73={...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_WRAPPER_MANAGED':'1','WHALENT_CORE_ENTRY':_0xafe8d},_0x17a949=readUpgradeState(),_0x2d5c4f=!!_0x17a949?.[_0x268794(0x20b)];let _0x18ee92=![],_0x59e693=null,_0x5adf83='';const _0x33344f=[],_0x3745f9=0xc;console[_0x268794(0x249)](_0x268794(0x240)+_0x268794(0x207)+_0xafe8d),_0x19134b=(0x0,import_child_process['spawn'])(process['execPath'],[_0xafe8d,..._0x53c6fa],{'env':_0x5d3d73,'stdio':['inherit',_0x268794(0x23b),_0x268794(0x23b)]});const _0x1da1c2=()=>{const _0x4e1fe6=_0x268794;if(_0x18ee92)return;_0x18ee92=!![];if(_0x59e693)clearTimeout(_0x59e693);_0x26e11b['length']=0x0,_0xdcc511=MIN_RESTART_DELAY_MS;const _0x1554ea=readUpgradeState();_0x1554ea?.['pending']&&(writeUpgradeState({..._0x1554ea,'pending':![],'rollback':![],'health_status':_0x4e1fe6(0x239)}),console['log'](_0x4e1fe6(0x23d)+_0x4e1fe6(0x234)+(_0x1554ea['installed_version']||_0x1554ea['target_version']||'')));},_0x1b234e=(_0x588898,_0x1ff551=![])=>{const _0x138e24=_0x268794,_0x532b98=_0x588898['toString']();(_0x1ff551?process['stderr']:process[_0x138e24(0x1cc)])['write'](_0x532b98);if(_0x1ff551)for(const _0x10570d of _0x532b98[_0x138e24(0x22d)](/\r?\n/)){if(!_0x10570d['trim']())continue;_0x33344f['push'](_0x10570d);if(_0x33344f['length']>_0x3745f9)_0x33344f[_0x138e24(0x22f)]();const _0x496ffe=_0x10570d['match'](FATAL_PATTERN);if(_0x496ffe)_0x5adf83=_0x496ffe[0x0];}(_0x532b98[_0x138e24(0x214)]('[gateway]\x20Connected')||_0x532b98[_0x138e24(0x214)](_0x138e24(0x248)+'achine')||_0x532b98['includes'](_0x138e24(0x219)))&&_0x1da1c2();};_0x19134b[_0x268794(0x1cc)]?.['on']('data',_0x562b7f=>_0x1b234e(_0x562b7f,![])),_0x19134b[_0x268794(0x1fa)]?.['on'](_0x268794(0x1cd),_0xc3403f=>_0x1b234e(_0xc3403f,!![]));_0x2d5c4f&&(_0x59e693=setTimeout(()=>{const _0x1cdcc0=_0x268794;if(_0x18ee92||!_0x19134b||_0x19134b[_0x1cdcc0(0x1eb)])return;console['error']('[wrapper]\x20new\x20core\x20d'+'id\x20not\x20become\x20health'+_0x1cdcc0(0x1c4)+_0x1cdcc0(0x21a));try{_0x19134b[_0x1cdcc0(0x259)](_0x1cdcc0(0x251));}catch{}},HEALTH_TIMEOUT_MS));const _0x588314=await new Promise(_0x1cc324=>{const _0x415b11=_0x268794;_0x19134b['once'](_0x415b11(0x1e1),(_0x1db52a,_0x1c4e67)=>_0x1cc324({'code':_0x1db52a,'signal':_0x1c4e67}));});if(_0x59e693)clearTimeout(_0x59e693);_0x19134b=null;if(_0x271aa6)process['exit'](_0x588314[_0x268794(0x229)]??0x0);const _0x4c076b=readUpgradeState();if(_0x4c076b?.['pending']&&!_0x18ee92){const _0x4a3b80=String(_0x4c076b[_0x268794(0x20d)+'n']||'')[_0x268794(0x1e0)]();if(_0x4a3b80){console['error']('[wrapper]\x20rolling\x20ba'+_0x268794(0x204)+_0x4a3b80);const _0x129f4d=installCoreVersion(_0x4a3b80);writeUpgradeState({..._0x4c076b,'pending':![],'rollback':!![],'health_status':_0x129f4d['ok']?_0x268794(0x1cf):_0x268794(0x1e5),'error':_0x129f4d['ok']?'':_0x129f4d[_0x268794(0x1f5)]});}else writeUpgradeState({..._0x4c076b,'pending':![],'rollback':!![],'health_status':_0x268794(0x235),'error':_0x268794(0x1e8)+'n\x20unknown'});}const _0x392804=_0x588314['code']===SUPERVISED_RESTART_CODE||_0x4c076b?.['pending'];if(!_0x392804&&_0x588314[_0x268794(0x229)]===0x0)process['exit'](0x0);const _0x24dd9f=Date['now']();_0x26e11b[_0x268794(0x221)](_0x24dd9f);while(_0x26e11b['length']>0x0&&_0x24dd9f-_0x26e11b[0x0]>CRASH_WINDOW_MS){_0x26e11b[_0x268794(0x22f)]();}const _0x450dbd=_0x26e11b['length'];writeLastCrash({'timestamp':_0x24dd9f,'exit_code':_0x588314['code'],'exit_signal':_0x588314['signal']||null,'fatal_line':_0x5adf83,'raw_tail':_0x33344f[_0x268794(0x1ff)]('\x0a'),'consecutive_crashes':_0x450dbd}),console[_0x268794(0x249)](_0x268794(0x1fb)+'d\x20code='+(_0x588314[_0x268794(0x229)]??'')+(_0x588314[_0x268794(0x1ce)]?_0x268794(0x212)+_0x588314['signal']:'')+'\x20('+_0x450dbd+'/'+MAX_CRASHES_IN_WINDOW+_0x268794(0x22c)+Math['round'](CRASH_WINDOW_MS/0x3e8)+'s)');if(_0x5adf83)console[_0x268794(0x249)](_0x268794(0x1ef)+':\x20'+_0x5adf83);_0x450dbd>=MAX_CRASHES_IN_WINDOW&&(console[_0x268794(0x1d0)](_0x268794(0x220)+'d\x20'+_0x450dbd+_0x268794(0x20a)+Math[_0x268794(0x24f)](CRASH_WINDOW_MS/0x3e8)+(_0x268794(0x241)+'record:\x20')+lastCrashFilePath()+(_0x268794(0x1d2)+'nually\x20after\x20the\x20und'+_0x268794(0x23c)+'ed.')),process[_0x268794(0x1e1)](0x1)),console['log'](_0x268794(0x23a)+_0x268794(0x233)+_0xdcc511+'ms'),await new Promise(_0x8a91bf=>setTimeout(_0x8a91bf,_0xdcc511)),_0xdcc511=Math[_0x268794(0x236)](_0xdcc511*0x2,MAX_RESTART_DELAY_MS);}}async function main(){const _0x3c0b0c=a0_0x5141f2,_0x5bb2a8=process['argv'][_0x3c0b0c(0x1d5)](0x2);if(_0x5bb2a8[0x0]==='--version'||_0x5bb2a8[0x0]==='-v'||_0x5bb2a8[0x0]===_0x3c0b0c(0x22e)){printVersion();return;}if((_0x5bb2a8[0x0]==='status'||_0x5bb2a8[0x0]==='ls'||_0x5bb2a8[0x0]==='ps')&&!_0x5bb2a8['includes']('--json')){console['log'](_0x3c0b0c(0x211)+WRAPPER_VERSION);try{console[_0x3c0b0c(0x249)](_0x3c0b0c(0x1e6)+(coreVersion()||'not\x20installed'));}catch{console['log'](_0x3c0b0c(0x222));}}maybeUpdateWrapper(_0x5bb2a8);if(!shouldSupervise(_0x5bb2a8))directCore(_0x5bb2a8);await superviseCore(_0x5bb2a8);}main()[a0_0x5141f2(0x1c6)](_0x4fee31=>{const _0x1783dc=a0_0x5141f2;console['error']('[wrapper]\x20Fatal\x20erro'+'r:\x20'+(_0x4fee31?.[_0x1783dc(0x218)]||String(_0x4fee31))),process[_0x1783dc(0x1e1)](0x1);});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whalent/agent",
3
- "version": "0.3.92",
3
+ "version": "0.3.94",
4
4
  "description": "Stable wrapper for Whalent Agent core runtime",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -42,7 +42,7 @@
42
42
  "yaml": "^2.4.0"
43
43
  },
44
44
  "optionalDependencies": {
45
- "@whalent/agent-core": "0.3.92"
45
+ "@whalent/agent-core": "0.3.94"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/node": "^20.0.0",