@whalent/agent 0.3.67 → 0.3.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.cjs +7 -7
- package/dist/index.cjs +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
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();}
|
|
2
|
+
'use strict';const a0_0x46f352=a0_0x43ce;(function(_0x304449,_0xc718ca){const _0x121aff=a0_0x43ce,_0x4f7aec=_0x304449();while(!![]){try{const _0x337598=-parseInt(_0x121aff(0x14e))/0x1+parseInt(_0x121aff(0x14b))/0x2+parseInt(_0x121aff(0x1a7))/0x3*(parseInt(_0x121aff(0x132))/0x4)+-parseInt(_0x121aff(0x13d))/0x5+-parseInt(_0x121aff(0x184))/0x6*(-parseInt(_0x121aff(0x17f))/0x7)+parseInt(_0x121aff(0x197))/0x8+-parseInt(_0x121aff(0x13f))/0x9;if(_0x337598===_0xc718ca)break;else _0x4f7aec['push'](_0x4f7aec['shift']());}catch(_0x5dde6f){_0x4f7aec['push'](_0x4f7aec['shift']());}}}(a0_0x4a69,0x67a2e));var __create=Object[a0_0x46f352(0x194)],__defProp=Object[a0_0x46f352(0x14f)],__getOwnPropDesc=Object[a0_0x46f352(0x156)+a0_0x46f352(0x12e)],__getOwnPropNames=Object['getOwnPropertyNames'],__getProtoOf=Object['getPrototypeOf'],__hasOwnProp=Object['prototype'][a0_0x46f352(0x172)],__copyProps=(_0x31d460,_0x16f423,_0x505193,_0x1390fd)=>{const _0x5d32ab=a0_0x46f352;if(_0x16f423&&typeof _0x16f423==='object'||typeof _0x16f423===_0x5d32ab(0x18d)){for(let _0x39ef6a of __getOwnPropNames(_0x16f423))if(!__hasOwnProp[_0x5d32ab(0x159)](_0x31d460,_0x39ef6a)&&_0x39ef6a!==_0x505193)__defProp(_0x31d460,_0x39ef6a,{'get':()=>_0x16f423[_0x39ef6a],'enumerable':!(_0x1390fd=__getOwnPropDesc(_0x16f423,_0x39ef6a))||_0x1390fd['enumerable']});}return _0x31d460;},__toESM=(_0x56ca08,_0x303e67,_0x2bb48b)=>(_0x2bb48b=_0x56ca08!=null?__create(__getProtoOf(_0x56ca08)):{},__copyProps(_0x303e67||!_0x56ca08||!_0x56ca08['__esModule']?__defProp(_0x2bb48b,'default',{'value':_0x56ca08,'enumerable':!![]}):_0x2bb48b,_0x56ca08)),import_child_process=require(a0_0x46f352(0x142)),fs=__toESM(require('fs'),0x1),import_module=require(a0_0x46f352(0x195)),os=__toESM(require('os'),0x1),path=__toESM(require(a0_0x46f352(0x186)),0x1),WRAPPER_PKG_NAME=a0_0x46f352(0x176),CORE_PKG_NAME='@whalent/agent-core',NPM_REGISTRY='https://registry.npm'+'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();function wrapperBaseDir(){return __dirname;}function configDir(){return path['join'](os['homedir'](),'.whalent-agent');}function upgradeStatePath(){const _0x114aed=a0_0x46f352;return path[_0x114aed(0x18c)](configDir(),'core-upgrade.json');}function lastCrashFilePath(){return path['join'](configDir(),'last-crash.json');}function writeLastCrash(_0x329ae6){const _0x2f70d0=a0_0x46f352;try{fs[_0x2f70d0(0x1a4)](configDir(),{'recursive':!![]});const _0xd55cf4={..._0x329ae6,'reported':![]};fs['writeFileSync'](lastCrashFilePath(),JSON['stringify'](_0xd55cf4,null,0x2),_0x2f70d0(0x17c));}catch{}}function readWrapperVersion(){const _0x1e3e18=a0_0x46f352;try{const _0x4e8a75=JSON['parse'](fs['readFileSync'](path[_0x1e3e18(0x18c)](wrapperBaseDir(),'..',_0x1e3e18(0x1a6)),'utf-8'));return String(_0x4e8a75[_0x1e3e18(0x161)]||_0x1e3e18(0x169));}catch{return _0x1e3e18(0x169);}}function readUpgradeState(){const _0xead693=a0_0x46f352;try{return JSON['parse'](fs[_0xead693(0x167)](upgradeStatePath(),'utf-8'));}catch{return null;}}function writeUpgradeState(_0x26c164){const _0xd4dac9=a0_0x46f352;try{fs[_0xd4dac9(0x1a4)](configDir(),{'recursive':!![]}),fs[_0xd4dac9(0x14d)](upgradeStatePath(),JSON[_0xd4dac9(0x14a)]({..._0x26c164,'updated_at':Date['now']()},null,0x2),'utf-8');}catch{}}function run(_0x575804,_0x5b4da4,_0x43bbb6=process.env){const _0x575f43=a0_0x46f352;return(0x0,import_child_process['spawnSync'])(_0x575804,_0x5b4da4,{'encoding':_0x575f43(0x196),'timeout':NPM_INSTALL_TIMEOUT_MS,'maxBuffer':NPM_INSTALL_MAX_BUFFER,'env':_0x43bbb6,'shell':![]});}function runNpmView(_0x12b381){const _0x598618=a0_0x46f352,_0x2e3923=resolveExecutable(_0x598618(0x16f));if(!_0x2e3923)return{'status':0x7f,'stdout':'','stderr':'npm\x20not\x20found','error':new Error('npm\x20not\x20found')};return(0x0,import_child_process['spawnSync'])(_0x2e3923,_0x12b381,{'encoding':_0x598618(0x196),'timeout':NPM_VIEW_TIMEOUT_MS,'maxBuffer':0x400*0x400,'env':process.env,'shell':![]});}function npmRootGlobal(){const _0x3acdde=a0_0x46f352,_0x25d408=resolveExecutable('npm');if(!_0x25d408)return'';const _0x4c0008=run(_0x25d408,[_0x3acdde(0x18b),'-g']);if(_0x4c0008[_0x3acdde(0x177)]!==0x0)return'';return String(_0x4c0008['stdout']||'')[_0x3acdde(0x16c)]();}function compareSemver(_0x37254f,_0x27f89e){const _0x320b9c=a0_0x46f352,_0x4bfbb5=String(_0x37254f||'')[_0x320b9c(0x191)](/^v/,'')[_0x320b9c(0x16e)](/[.-]/)[_0x320b9c(0x131)](_0x28e8f9=>Number['parseInt'](_0x28e8f9,0xa)||0x0),_0x43a3cb=String(_0x27f89e||'')[_0x320b9c(0x191)](/^v/,'')[_0x320b9c(0x16e)](/[.-]/)[_0x320b9c(0x131)](_0x171a37=>Number[_0x320b9c(0x13a)](_0x171a37,0xa)||0x0);for(let _0x5edbac=0x0;_0x5edbac<Math[_0x320b9c(0x155)](_0x4bfbb5['length'],_0x43a3cb[_0x320b9c(0x179)],0x3);_0x5edbac++){const _0x1056bc=_0x4bfbb5[_0x5edbac]||0x0,_0x21b2ce=_0x43a3cb[_0x5edbac]||0x0;if(_0x1056bc>_0x21b2ce)return 0x1;if(_0x1056bc<_0x21b2ce)return-0x1;}return 0x0;}function resolveExecutable(_0x2be46d){const _0x1db4aa=a0_0x46f352,_0xf03229=process['platform']==='win32'?'where.exe':'which';try{const _0xbca502=(0x0,import_child_process[_0x1db4aa(0x150)])(_0xf03229,[_0x2be46d],{'encoding':'utf8','timeout':0xbb8,'shell':![]});if(_0xbca502[_0x1db4aa(0x177)]!==0x0)return'';return String(_0xbca502['stdout']||'')['split'](/\r?\n/)['map'](_0x1c832c=>_0x1c832c['trim']())[_0x1db4aa(0x154)](Boolean)[0x0]||'';}catch{return'';}}function skipWrapperUpdateCheck(){const _0x3957e7=a0_0x46f352,_0x58e05d=String(process.env.WHALENT_SKIP_UPDATE_CHECK||process.env.WHALENT_NO_UPDATE_CHECK||process.env.WHALENT_SKIP_WRAPPER_UPDATE||'')['trim']()[_0x3957e7(0x1ac)]();return _0x58e05d==='1'||_0x58e05d===_0x3957e7(0x158)||_0x58e05d==='yes'||_0x58e05d==='on';}function latestWrapperVersion(){const _0x1ab208=a0_0x46f352,_0x403280=runNpmView([_0x1ab208(0x145),WRAPPER_PKG_NAME+'@latest',_0x1ab208(0x161),'--registry='+NPM_REGISTRY]);if(_0x403280['status']!==0x0)return'';return String(_0x403280[_0x1ab208(0x173)]||'')['trim']()['split'](/\r?\n/)[_0x1ab208(0x154)](Boolean)[_0x1ab208(0x157)]()||'';}function installWrapperVersion(_0x1dfcff){const _0xf5c71f=a0_0x46f352,_0x3cb9ba=resolveExecutable(_0xf5c71f(0x16f));if(!_0x3cb9ba)return{'ok':![],'output':'npm\x20not\x20found\x20on\x20PAT'+'H'};const _0x35d301=run(_0x3cb9ba,['install','-g',WRAPPER_PKG_NAME+'@'+_0x1dfcff,_0xf5c71f(0x198)+NPM_REGISTRY]),_0x56fdf0=((_0x35d301[_0xf5c71f(0x173)]||'')+'\x0a'+(_0x35d301['stderr']||''))[_0xf5c71f(0x16c)]();return{'ok':_0x35d301[_0xf5c71f(0x177)]===0x0,'output':_0x56fdf0};}function maybeUpdateWrapper(_0x2fcfc6){const _0x162676=a0_0x46f352;if(skipWrapperUpdateCheck())return![];if(process.env.WHALENT_WRAPPER_UPDATE_ATTEMPTED)return![];const _0x4c9b1f=latestWrapperVersion();if(!_0x4c9b1f||compareSemver(_0x4c9b1f,WRAPPER_VERSION)<=0x0)return![];console[_0x162676(0x187)]('[wrapper]\x20update\x20ava'+_0x162676(0x1a2)+WRAPPER_VERSION+'\x20->\x20'+_0x4c9b1f),console['warn']('[wrapper]\x20installing'+'\x20'+WRAPPER_PKG_NAME+'@'+_0x4c9b1f+(_0x162676(0x130)+'rting\x20core...'));const _0x5083b6=installWrapperVersion(_0x4c9b1f);if(!_0x5083b6['ok']){console['warn'](_0x162676(0x199)+'date\x20failed;\x20continu'+'ing\x20with\x20'+WRAPPER_VERSION);if(_0x5083b6[_0x162676(0x13c)])console['warn'](_0x5083b6['output'][_0x162676(0x16e)](/\r?\n/)['slice'](-0xc)[_0x162676(0x18c)]('\x0a'));return console['warn']('[wrapper]\x20Manual\x20upd'+'ate:\x20npm\x20install\x20-g\x20'+WRAPPER_PKG_NAME+'@'+_0x4c9b1f+_0x162676(0x153)+NPM_REGISTRY),![];}console['warn'](_0x162676(0x199)+_0x162676(0x18f)+_0x4c9b1f+';\x20restarting\x20wrapper');const _0x416677=process['argv'][0x1],_0x4cb111=(0x0,import_child_process['spawnSync'])(process['execPath'],[_0x416677,..._0x2fcfc6],{'stdio':_0x162676(0x1ad),'env':{...process.env,'WHALENT_WRAPPER_UPDATE_ATTEMPTED':_0x4c9b1f},'shell':![]});process['exit'](_0x4cb111['status']??0x0);}function a0_0x43ce(_0x2ea3bc,_0x493fdd){_0x2ea3bc=_0x2ea3bc-0x12d;const _0x4a69e7=a0_0x4a69();let _0x43cecf=_0x4a69e7[_0x2ea3bc];if(a0_0x43ce['cVwNyL']===undefined){var _0x48b7be=function(_0x49cc9f){const _0x5a9eb6='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x31d460='',_0x16f423='';for(let _0x505193=0x0,_0x1390fd,_0x39ef6a,_0x56ca08=0x0;_0x39ef6a=_0x49cc9f['charAt'](_0x56ca08++);~_0x39ef6a&&(_0x1390fd=_0x505193%0x4?_0x1390fd*0x40+_0x39ef6a:_0x39ef6a,_0x505193++%0x4)?_0x31d460+=String['fromCharCode'](0xff&_0x1390fd>>(-0x2*_0x505193&0x6)):0x0){_0x39ef6a=_0x5a9eb6['indexOf'](_0x39ef6a);}for(let _0x303e67=0x0,_0x2bb48b=_0x31d460['length'];_0x303e67<_0x2bb48b;_0x303e67++){_0x16f423+='%'+('00'+_0x31d460['charCodeAt'](_0x303e67)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x16f423);};a0_0x43ce['DVgiJp']=_0x48b7be,a0_0x43ce['gOwWuT']={},a0_0x43ce['cVwNyL']=!![];}const _0x50769c=_0x4a69e7[0x0],_0x96ab76=_0x2ea3bc+_0x50769c,_0x5e3864=a0_0x43ce['gOwWuT'][_0x96ab76];return!_0x5e3864?(_0x43cecf=a0_0x43ce['DVgiJp'](_0x43cecf),a0_0x43ce['gOwWuT'][_0x96ab76]=_0x43cecf):_0x43cecf=_0x5e3864,_0x43cecf;}function findCoreScript(){const _0x4600e5=a0_0x46f352,_0x448d84=String(process.env.WHALENT_CORE_ENTRY||'')[_0x4600e5(0x16c)](),_0x5b58c0=['1','true',_0x4600e5(0x16d),'on']['includes'](String(process.env.WHALENT_FORCE_CORE_ENTRY||'')['trim']()['toLowerCase']());if(_0x448d84&&_0x5b58c0&&fs['existsSync'](_0x448d84))return _0x448d84;const _0x4a16e0=[],_0xfec28f=_0x31bc8e=>{const _0x35cd4a=_0x4600e5;if(fs[_0x35cd4a(0x182)](_0x31bc8e)&&!_0x4a16e0[_0x35cd4a(0x190)](_0x31bc8e))_0x4a16e0[_0x35cd4a(0x1a3)](_0x31bc8e);};if(_0x448d84)_0xfec28f(_0x448d84);const _0x170e68=npmRootGlobal();if(_0x170e68){const _0x4a410b=path[_0x4600e5(0x18c)](_0x170e68,_0x4600e5(0x17b),_0x4600e5(0x13e),_0x4600e5(0x152),_0x4600e5(0x178));_0xfec28f(_0x4a410b);}const _0x18847e=path['join'](wrapperBaseDir(),'core.cjs');_0xfec28f(_0x18847e);const _0x1c0fad=path['join'](wrapperBaseDir(),'..','packages','core',_0x4600e5(0x152),_0x4600e5(0x178));_0xfec28f(_0x1c0fad);if(_0x4a16e0['length']>0x0)return _0x4a16e0['map']((_0x252eac,_0x1790ab)=>({'candidate':_0x252eac,'index':_0x1790ab,'version':coreVersion(_0x252eac)}))[_0x4600e5(0x1aa)]((_0x2f5ac2,_0x3991e3)=>{const _0x3d5cfd=_0x4600e5,_0x52b0fc=compareSemver(_0x3991e3['version'],_0x2f5ac2[_0x3d5cfd(0x161)]);if(_0x52b0fc!==0x0)return _0x52b0fc;return _0x3991e3['index']-_0x2f5ac2[_0x3d5cfd(0x1a9)];})[0x0][_0x4600e5(0x19c)];throw new Error(_0x4600e5(0x136)+'\x20not\x20found;\x20install\x20'+_0x4600e5(0x140)+_0x4600e5(0x1a1)+'agent');}function coreVersion(_0x17df6c=findCoreScript()){const _0x2c26c0=a0_0x46f352,_0x41c0e0=(0x0,import_child_process['spawnSync'])(process[_0x2c26c0(0x1ae)],[_0x17df6c,_0x2c26c0(0x19f)],{'encoding':'utf8','timeout':0x3a98,'env':{...process.env,'WHALENT_SKIP_UPDATE_CHECK':'1'},'shell':![]}),_0x391ca0=(_0x41c0e0['stdout']||'')+'\x0a'+(_0x41c0e0[_0x2c26c0(0x1a0)]||'');return _0x391ca0[_0x2c26c0(0x16a)](/(\d+\.\d+\.\d+(?:[-\w.]+)?)/)?.[0x1]||'';}function isExecutable(_0x18c476){const _0x29eb3d=a0_0x46f352;try{return fs[_0x29eb3d(0x146)](_0x18c476,fs['constants']['X_OK']),!![];}catch{return![];}}function shellQuote(_0x52efbd){const _0x4d05df=a0_0x46f352;return'\x27'+_0x52efbd[_0x4d05df(0x191)](/'/g,'\x27\x5c\x27\x27')+'\x27';}function coreNodePtySpawnHelperPath(_0x2fb894){const _0x38bacb=a0_0x46f352;if(process[_0x38bacb(0x148)]!=='darwin')return'';try{const _0xa83f05=(0x0,import_module[_0x38bacb(0x19b)])(_0x2fb894),_0x30f850=_0xa83f05['resolve'](_0x38bacb(0x134)),_0x234fe9=path['resolve'](path[_0x38bacb(0x143)](_0x30f850),'..');return path[_0x38bacb(0x18c)](_0x234fe9,'prebuilds','darwin-'+process['arch'],'spawn-helper');}catch{return'';}}function checkMacNodePtySpawnHelper(_0x145deb){const _0x1d1fe7=a0_0x46f352,_0x5877e2=coreNodePtySpawnHelperPath(_0x145deb);if(!_0x5877e2||CHECKED_PTY_HELPERS['has'](_0x5877e2))return;CHECKED_PTY_HELPERS['add'](_0x5877e2);if(!fs['existsSync'](_0x5877e2)){console[_0x1d1fe7(0x187)](_0x1d1fe7(0x183)+'-pty\x20spawn-helper\x20no'+_0x1d1fe7(0x1a5)+_0x5877e2);return;}if(isExecutable(_0x5877e2))return;try{const _0x5a3494=fs['statSync'](_0x5877e2)['mode'];fs['chmodSync'](_0x5877e2,_0x5a3494|0x1ed);}catch{}if(isExecutable(_0x5877e2)){console['warn']('[wrapper]\x20fixed\x20macO'+'S\x20node-pty\x20spawn-hel'+'per\x20executable\x20bit:\x20'+_0x5877e2);return;}console[_0x1d1fe7(0x187)](_0x1d1fe7(0x183)+'-pty\x20spawn-helper\x20is'+'\x20not\x20executable:\x20'+_0x5877e2),console['warn'](_0x1d1fe7(0x193)+_0x1d1fe7(0x12d)+'PTY\x20startup:'),console[_0x1d1fe7(0x187)](_0x1d1fe7(0x189)+shellQuote(_0x5877e2)),console[_0x1d1fe7(0x187)]('\x20\x20ls\x20-l\x20\x22$HELPER\x22'),console['warn']('\x20\x20chmod\x20+x\x20\x22$HELPER\x22');}function printVersion(){const _0x12640f=a0_0x46f352;let _0x4b708f='';try{_0x4b708f=coreVersion();}catch{}console[_0x12640f(0x151)]('whalent-agent\x20'+WRAPPER_VERSION),console['log'](_0x12640f(0x18a)+WRAPPER_VERSION),console['log']('core\x20'+(_0x4b708f||_0x12640f(0x163)));}function directCore(_0x3c8b9c){const _0xe3b99e=a0_0x46f352,_0x392397=findCoreScript();checkMacNodePtySpawnHelper(_0x392397);const _0x52db25=(0x0,import_child_process['spawnSync'])(process['execPath'],[_0x392397,..._0x3c8b9c],{'stdio':_0xe3b99e(0x1ad),'env':{...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_CORE_ENTRY':_0x392397},'shell':![]});process['exit'](_0x52db25['status']??0x0);}function shouldSupervise(_0x21edd2){const _0x36fa93=a0_0x46f352;if(_0x21edd2[_0x36fa93(0x190)](_0x36fa93(0x17d)))return![];const _0x4d0bf8=_0x21edd2[0x0]||'';if(_0x4d0bf8==='ls'||_0x4d0bf8==='status'||_0x4d0bf8==='ps')return![];if(_0x4d0bf8===_0x36fa93(0x19a)||_0x4d0bf8==='daemon-mcp')return![];if(_0x21edd2[_0x36fa93(0x190)]('--help')||_0x21edd2['includes']('-h'))return![];return!![];}function installCoreVersion(_0x2f43b2){const _0x24f57a=a0_0x46f352,_0xedf670=resolveExecutable(_0x24f57a(0x16f));if(!_0xedf670)return{'ok':![],'output':'npm\x20not\x20found\x20on\x20PAT'+'H'};const _0x16fcd5=CORE_PKG_NAME+'@'+_0x2f43b2,_0x136879=run(_0xedf670,[_0x24f57a(0x166),'-g',_0x16fcd5,'--registry='+NPM_REGISTRY]),_0x115a00=((_0x136879[_0x24f57a(0x173)]||'')+'\x0a'+(_0x136879[_0x24f57a(0x1a0)]||''))[_0x24f57a(0x16c)]();return{'ok':_0x136879[_0x24f57a(0x177)]===0x0,'output':_0x115a00};}async function superviseCore(_0x41672b){const _0x3cc4e3=a0_0x46f352;let _0x2f4e54=![],_0x6f8ff=null;const _0x39fb36=[];let _0x2fffc4=MIN_RESTART_DELAY_MS;const _0x146db3=()=>{const _0x4ceefc=a0_0x43ce;_0x2f4e54=!![];if(_0x6f8ff&&!_0x6f8ff[_0x4ceefc(0x18e)])try{_0x6f8ff[_0x4ceefc(0x15e)](_0x4ceefc(0x17a));}catch{}else process[_0x4ceefc(0x13b)](0x0);};process['on'](_0x3cc4e3(0x139),_0x146db3),process['on'](_0x3cc4e3(0x17a),_0x146db3);while(!![]){const _0x2fef90=findCoreScript();checkMacNodePtySpawnHelper(_0x2fef90);const _0x175850={...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_WRAPPER_MANAGED':'1','WHALENT_CORE_ENTRY':_0x2fef90},_0x4cbe3b=readUpgradeState(),_0x121def=!!_0x4cbe3b?.['pending'];let _0x4b31a2=![],_0x531095=null,_0x4ee646='';const _0x1eb76a=[],_0x155198=0xc;console[_0x3cc4e3(0x151)](_0x3cc4e3(0x174)+_0x3cc4e3(0x19e)+_0x2fef90),_0x6f8ff=(0x0,import_child_process[_0x3cc4e3(0x15c)])(process['execPath'],[_0x2fef90,..._0x41672b],{'env':_0x175850,'stdio':['inherit',_0x3cc4e3(0x185),'pipe']});const _0x46f48d=()=>{const _0x539040=_0x3cc4e3;if(_0x4b31a2)return;_0x4b31a2=!![];if(_0x531095)clearTimeout(_0x531095);_0x39fb36['length']=0x0,_0x2fffc4=MIN_RESTART_DELAY_MS;const _0x4abc91=readUpgradeState();_0x4abc91?.[_0x539040(0x175)]&&(writeUpgradeState({..._0x4abc91,'pending':![],'rollback':![],'health_status':_0x539040(0x188)}),console['log'](_0x539040(0x135)+_0x539040(0x15a)+(_0x4abc91['installed_version']||_0x4abc91['target_version']||'')));},_0x1b8d0a=(_0x55fbc9,_0x56bed4=![])=>{const _0x204220=_0x3cc4e3,_0x162179=_0x55fbc9['toString']();(_0x56bed4?process['stderr']:process['stdout'])['write'](_0x162179);if(_0x56bed4)for(const _0x3a3ed7 of _0x162179['split'](/\r?\n/)){if(!_0x3a3ed7['trim']())continue;_0x1eb76a[_0x204220(0x1a3)](_0x3a3ed7);if(_0x1eb76a[_0x204220(0x179)]>_0x155198)_0x1eb76a['shift']();const _0x32b477=_0x3a3ed7['match'](FATAL_PATTERN);if(_0x32b477)_0x4ee646=_0x32b477[0x0];}(_0x162179['includes'](_0x204220(0x133))||_0x162179[_0x204220(0x190)](_0x204220(0x15f)+'achine')||_0x162179['includes'](_0x204220(0x15d)))&&_0x46f48d();};_0x6f8ff['stdout']?.['on'](_0x3cc4e3(0x164),_0x415bb6=>_0x1b8d0a(_0x415bb6,![])),_0x6f8ff[_0x3cc4e3(0x1a0)]?.['on'](_0x3cc4e3(0x164),_0x5d92c7=>_0x1b8d0a(_0x5d92c7,!![]));_0x121def&&(_0x531095=setTimeout(()=>{const _0x848696=_0x3cc4e3;if(_0x4b31a2||!_0x6f8ff||_0x6f8ff['killed'])return;console[_0x848696(0x19d)](_0x848696(0x15b)+_0x848696(0x1a8)+'y\x20in\x20time;\x20rolling\x20b'+'ack');try{_0x6f8ff['kill'](_0x848696(0x17a));}catch{}},HEALTH_TIMEOUT_MS));const _0x431a23=await new Promise(_0x1f8bdd=>{_0x6f8ff['once']('exit',(_0x5e3ca8,_0x38d129)=>_0x1f8bdd({'code':_0x5e3ca8,'signal':_0x38d129}));});if(_0x531095)clearTimeout(_0x531095);_0x6f8ff=null;if(_0x2f4e54)process['exit'](_0x431a23[_0x3cc4e3(0x170)]??0x0);const _0x2c4458=readUpgradeState();if(_0x2c4458?.['pending']&&!_0x4b31a2){const _0x1646de=String(_0x2c4458[_0x3cc4e3(0x137)+'n']||'')['trim']();if(_0x1646de){console[_0x3cc4e3(0x19d)]('[wrapper]\x20rolling\x20ba'+_0x3cc4e3(0x149)+_0x1646de);const _0x2c2072=installCoreVersion(_0x1646de);writeUpgradeState({..._0x2c4458,'pending':![],'rollback':!![],'health_status':_0x2c2072['ok']?'rolled_back':'rollback_failed','error':_0x2c2072['ok']?'':_0x2c2072[_0x3cc4e3(0x13c)]});}else writeUpgradeState({..._0x2c4458,'pending':![],'rollback':!![],'health_status':'rollback_unavailable','error':_0x3cc4e3(0x138)+_0x3cc4e3(0x17e)});}const _0x196af9=_0x431a23[_0x3cc4e3(0x170)]===SUPERVISED_RESTART_CODE||_0x2c4458?.[_0x3cc4e3(0x175)];if(!_0x196af9&&_0x431a23['code']===0x0)process['exit'](0x0);const _0x2395e6=Date[_0x3cc4e3(0x192)]();_0x39fb36['push'](_0x2395e6);while(_0x39fb36['length']>0x0&&_0x2395e6-_0x39fb36[0x0]>CRASH_WINDOW_MS){_0x39fb36[_0x3cc4e3(0x162)]();}const _0x98902=_0x39fb36[_0x3cc4e3(0x179)];writeLastCrash({'timestamp':_0x2395e6,'exit_code':_0x431a23[_0x3cc4e3(0x170)],'exit_signal':_0x431a23['signal']||null,'fatal_line':_0x4ee646,'raw_tail':_0x1eb76a['join']('\x0a'),'consecutive_crashes':_0x98902}),console['log']('[wrapper]\x20core\x20exite'+_0x3cc4e3(0x160)+(_0x431a23['code']??'')+(_0x431a23['signal']?'\x20signal='+_0x431a23['signal']:'')+'\x20('+_0x98902+'/'+MAX_CRASHES_IN_WINDOW+'\x20in\x20last\x20'+Math['round'](CRASH_WINDOW_MS/0x3e8)+'s)');if(_0x4ee646)console['log']('[wrapper]\x20last\x20fatal'+':\x20'+_0x4ee646);_0x98902>=MAX_CRASHES_IN_WINDOW&&(console[_0x3cc4e3(0x19d)](_0x3cc4e3(0x144)+'d\x20'+_0x98902+'\x20times\x20within\x20'+Math['round'](CRASH_WINDOW_MS/0x3e8)+(_0x3cc4e3(0x12f)+_0x3cc4e3(0x147))+lastCrashFilePath()+(_0x3cc4e3(0x16b)+_0x3cc4e3(0x171)+'erlying\x20issue\x20is\x20fix'+_0x3cc4e3(0x168))),process[_0x3cc4e3(0x13b)](0x1)),console['log']('[wrapper]\x20restarting'+'\x20in\x20'+_0x2fffc4+'ms'),await new Promise(_0x38d45d=>setTimeout(_0x38d45d,_0x2fffc4)),_0x2fffc4=Math[_0x3cc4e3(0x165)](_0x2fffc4*0x2,MAX_RESTART_DELAY_MS);}}async function main(){const _0x310fbc=a0_0x46f352,_0x4ff7e5=process['argv']['slice'](0x2);if(_0x4ff7e5[0x0]==='--version'||_0x4ff7e5[0x0]==='-v'||_0x4ff7e5[0x0]==='version'){printVersion();return;}if((_0x4ff7e5[0x0]==='status'||_0x4ff7e5[0x0]==='ls'||_0x4ff7e5[0x0]==='ps')&&!_0x4ff7e5['includes'](_0x310fbc(0x180))){console[_0x310fbc(0x151)](_0x310fbc(0x18a)+WRAPPER_VERSION);try{console[_0x310fbc(0x151)](_0x310fbc(0x1ab)+(coreVersion()||'not\x20installed'));}catch{console['log']('core\x20not\x20installed');}}maybeUpdateWrapper(_0x4ff7e5);if(!shouldSupervise(_0x4ff7e5))directCore(_0x4ff7e5);await superviseCore(_0x4ff7e5);}main()[a0_0x46f352(0x181)](_0x812355=>{const _0x3ef008=a0_0x46f352;console[_0x3ef008(0x19d)]('[wrapper]\x20Fatal\x20erro'+_0x3ef008(0x141)+(_0x812355?.[_0x3ef008(0x14c)]||String(_0x812355))),process['exit'](0x1);});function a0_0x4a69(){const _0x34b189=['mte5mtm3mK5vsKzsqW','BwvZC2fNzq','D3jPDgvgAwXLu3LUyW','nJe3mty5CeT0yLPp','zgvMAw5LuhjVCgvYDhK','C3bHD25tEw5J','Bg9N','zgLZDa','ic0TCMvNAxn0CNK9','zMLSDgvY','Bwf4','z2v0t3DUuhjVCgvYDhLezxnJCMK','Cg9W','Dhj1zq','y2fSBa','zguGAgvHBhrOEtOG','w3DYyxbWzxjDig5LDYbJB3jLigq','C3bHD24','r2f0zxDHEtOGy29UBMvJDgvK','A2LSBa','r2f0zxDHEsbYzwDPC3rLCMvKig0','zcbJB2rLpq','DMvYC2LVBG','C2HPzNq','BM90igLUC3rHBgXLza','zgf0yq','BwLU','Aw5ZDgfSBa','CMvHzezPBgvtEw5J','zwqU','mc4WlJa','Bwf0y2G','lIbszxn0yxj0ihDYyxbWzxiGBwe','DhjPBq','EwvZ','C3bSAxq','BNbT','y29Kzq','BNvHBgX5igfMDgvYihrOzsb1BMq','AgfZt3DUuhjVCgvYDhK','C3rKB3v0','w3DYyxbWzxjDihn0yxj0Aw5Nigm','CgvUzgLUzW','qhDOywXLBNqVywDLBNq','C3rHDhvZ','Aw5KzxGUy2PZ','BgvUz3rO','u0Lhvevstq','qhDOywXLBNq','DxrMltG','ls1Hz2vUDc1Pza','BIb1BMTUB3DU','n21owfnYtW','ls1QC29U','y2f0y2G','zxHPC3rZu3LUyW','w3DYyxbWzxjDig1Hy09tig5Vzgu','mtuWmtm4nKjYwg9RAq','CgLWzq','Cgf0Aa','D2fYBG','AgvHBhrOEq','icbiruXqrvi9','D3jHChbLCIa','CM9VDa','AM9PBG','zNvUy3rPB24','A2LSBgvK','zgf0zwqGDg8G','Aw5JBhvKzxm','CMvWBgfJzq','BM93','w3DYyxbWzxjDifj1BIb0AgLZig8','y3jLyxrL','Bw9KDwXL','DxrMoa','mZK3ndKYog1JzwrJyq','ls1YzwDPC3rYEt0','w3DYyxbWzxjDihDYyxbWzxiGDxa','BwnW','y3jLyxrLuMvXDwLYzq','y2fUzgLKyxrL','zxjYB3i','B3jLoIa','ls12zxjZAw9U','C3rKzxjY','B3iGCMvIDwLSzcbaD2HHBgvUDc8','AwXHyMXLoIa','ChvZAa','BwTKAxjtEw5J','DcbMB3vUzdOG','CgfJA2fNzs5QC29U','mJaZotG0n3DUze9XrW','AwqGBM90igjLy29TzsbOzwfSDgG','Aw5KzxG','C29YDa','y29Yzsa','Dg9mB3DLCKnHC2u','Aw5OzxjPDa','zxHLy1bHDgG','BMnLihrVigzPEcb0zxjTAw5HBc8','ChrVCG','CZSGz2L2Aw5NihvWlIbdCMfZAca','igzYB20GBNbTigjLzM9YzsbZDge','BwfW','neXUyxvfuq','w2DHDgv3yxLDienVBM5Ly3rLza','BM9Kzs1WDhK','w3DYyxbWzxjDignVCMuGDxbNCMe','D2HHBgvUDcbJB3jLihj1BNrPBwu','ChjLDMLVDxnFy29Yzv92zxjZAw8','ChjLDMLVDxmGy29Yzsb2zxjZAw8','u0Lhsu5u','CgfYC2vjBNq','zxHPDa','B3v0Chv0','nte0nZi1uMT6ru1V','ywDLBNqTy29Yzq','nZKWmZeXnNHNsfn1va','qhDOywXLBNqVywDLBNqTy29Yzsa','CJOG','y2HPBgrFChjVy2vZCW','zgLYBMfTzq','w3DYyxbWzxjDignVCMuGzMfPBgu','DMLLDW','ywnJzxnZu3LUyW','CMvJB3jKoIa','CgXHDgzVCM0','y2SGy29Yzsb0BYa','C3rYAw5NAwz5'];a0_0x4a69=function(){return _0x34b189;};return a0_0x4a69();}
|