@whalent/agent 0.3.95 → 0.3.97
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 +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
'use strict';const a0_0x6a9c70=a0_0x1f90;(function(_0x185401,_0x69af23){const _0x4257da=a0_0x1f90,_0xb3c77e=_0x185401();while(!![]){try{const _0x59f9b8=-parseInt(_0x4257da(0x1e3))/0x1+parseInt(_0x4257da(0x1a1))/0x2*(parseInt(_0x4257da(0x1d9))/0x3)+parseInt(_0x4257da(0x1a3))/0x4+-parseInt(_0x4257da(0x21c))/0x5*(-parseInt(_0x4257da(0x203))/0x6)+parseInt(_0x4257da(0x190))/0x7*(parseInt(_0x4257da(0x211))/0x8)+parseInt(_0x4257da(0x1ec))/0x9+-parseInt(_0x4257da(0x1bb))/0xa;if(_0x59f9b8===_0x69af23)break;else _0xb3c77e['push'](_0xb3c77e['shift']());}catch(_0x5c92b1){_0xb3c77e['push'](_0xb3c77e['shift']());}}}(a0_0x1bcd,0x1f3dd));var __create=Object[a0_0x6a9c70(0x222)],__defProp=Object[a0_0x6a9c70(0x1fd)],__getOwnPropDesc=Object['getOwnPropertyDescri'+'ptor'],__getOwnPropNames=Object['getOwnPropertyNames'],__getProtoOf=Object[a0_0x6a9c70(0x1e1)],__hasOwnProp=Object[a0_0x6a9c70(0x1ca)]['hasOwnProperty'],__copyProps=(_0x4b08f4,_0x3ce9c9,_0x5d5cef,_0x40a656)=>{if(_0x3ce9c9&&typeof _0x3ce9c9==='object'||typeof _0x3ce9c9==='function'){for(let _0x4e166c of __getOwnPropNames(_0x3ce9c9))if(!__hasOwnProp['call'](_0x4b08f4,_0x4e166c)&&_0x4e166c!==_0x5d5cef)__defProp(_0x4b08f4,_0x4e166c,{'get':()=>_0x3ce9c9[_0x4e166c],'enumerable':!(_0x40a656=__getOwnPropDesc(_0x3ce9c9,_0x4e166c))||_0x40a656['enumerable']});}return _0x4b08f4;},__toESM=(_0x540739,_0x157552,_0xba082b)=>(_0xba082b=_0x540739!=null?__create(__getProtoOf(_0x540739)):{},__copyProps(_0x157552||!_0x540739||!_0x540739['__esModule']?__defProp(_0xba082b,'default',{'value':_0x540739,'enumerable':!![]}):_0xba082b,_0x540739)),import_child_process=require('child_process'),fs=__toESM(require('fs'),0x1),import_module=require(a0_0x6a9c70(0x181)),os=__toESM(require('os'),0x1),path=__toESM(require(a0_0x6a9c70(0x180)),0x1),WRAPPER_PKG_NAME=a0_0x6a9c70(0x1d3),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(),CHECKED_NODE_PTY_RUNTIMES=new Set();function wrapperBaseDir(){return __dirname;}function configDir(){const _0x748abc=a0_0x6a9c70;return path[_0x748abc(0x1e2)](os[_0x748abc(0x202)](),_0x748abc(0x1f2));}function upgradeStatePath(){const _0x4e4abc=a0_0x6a9c70;return path[_0x4e4abc(0x1e2)](configDir(),_0x4e4abc(0x1b7));}function lastCrashFilePath(){const _0x177ac6=a0_0x6a9c70;return path['join'](configDir(),_0x177ac6(0x1fb));}function writeLastCrash(_0x178553){const _0x14d9af=a0_0x6a9c70;try{fs[_0x14d9af(0x221)](configDir(),{'recursive':!![]});const _0x2fdd77={..._0x178553,'reported':![]};fs[_0x14d9af(0x218)](lastCrashFilePath(),JSON[_0x14d9af(0x19b)](_0x2fdd77,null,0x2),_0x14d9af(0x1b2));}catch{}}function readWrapperVersion(){const _0xc0b5f5=a0_0x6a9c70;try{const _0x48be40=JSON[_0xc0b5f5(0x198)](fs[_0xc0b5f5(0x183)](path['join'](wrapperBaseDir(),'..','package.json'),'utf-8'));return String(_0x48be40[_0xc0b5f5(0x210)]||'0.0.0');}catch{return'0.0.0';}}function readUpgradeState(){try{return JSON['parse'](fs['readFileSync'](upgradeStatePath(),'utf-8'));}catch{return null;}}function writeUpgradeState(_0x4e2bc6){const _0x315c2b=a0_0x6a9c70;try{fs['mkdirSync'](configDir(),{'recursive':!![]}),fs[_0x315c2b(0x218)](upgradeStatePath(),JSON[_0x315c2b(0x19b)]({..._0x4e2bc6,'updated_at':Date[_0x315c2b(0x1b1)]()},null,0x2),'utf-8');}catch{}}function run(_0x418164,_0x109727,_0x379bad=process.env){const _0x58b038=a0_0x6a9c70;return(0x0,import_child_process[_0x58b038(0x199)])(_0x418164,_0x109727,{'encoding':'utf8','timeout':NPM_INSTALL_TIMEOUT_MS,'maxBuffer':NPM_INSTALL_MAX_BUFFER,'env':_0x379bad,'shell':![]});}function runNpmView(_0x4719f5){const _0x570aaa=a0_0x6a9c70,_0x4d2db2=resolveExecutable('npm');if(!_0x4d2db2)return{'status':0x7f,'stdout':'','stderr':'npm\x20not\x20found','error':new Error('npm\x20not\x20found')};return(0x0,import_child_process[_0x570aaa(0x199)])(_0x4d2db2,_0x4719f5,{'encoding':_0x570aaa(0x207),'timeout':NPM_VIEW_TIMEOUT_MS,'maxBuffer':0x400*0x400,'env':process.env,'shell':![]});}function npmRootGlobal(){const _0x4f7f5b=a0_0x6a9c70,_0x4e1c9a=resolveExecutable('npm');if(!_0x4e1c9a)return'';const _0xb9efcc=run(_0x4e1c9a,[_0x4f7f5b(0x1a0),'-g']);if(_0xb9efcc['status']!==0x0)return'';return String(_0xb9efcc['stdout']||'')[_0x4f7f5b(0x208)]();}function compareSemver(_0x429904,_0x21c55f){const _0x5c3d55=a0_0x6a9c70,_0x58f828=String(_0x429904||'')[_0x5c3d55(0x1f1)](/^v/,'')[_0x5c3d55(0x1b3)](/[.-]/)['map'](_0x5da452=>Number['parseInt'](_0x5da452,0xa)||0x0),_0x48e73d=String(_0x21c55f||'')['replace'](/^v/,'')[_0x5c3d55(0x1b3)](/[.-]/)['map'](_0x193a5b=>Number[_0x5c3d55(0x1f8)](_0x193a5b,0xa)||0x0);for(let _0x5cec42=0x0;_0x5cec42<Math[_0x5c3d55(0x17e)](_0x58f828['length'],_0x48e73d[_0x5c3d55(0x1bd)],0x3);_0x5cec42++){const _0x4cfe2e=_0x58f828[_0x5cec42]||0x0,_0x23a89c=_0x48e73d[_0x5cec42]||0x0;if(_0x4cfe2e>_0x23a89c)return 0x1;if(_0x4cfe2e<_0x23a89c)return-0x1;}return 0x0;}function resolveExecutable(_0x58cfc2){const _0x25eb8d=a0_0x6a9c70,_0x304919=process[_0x25eb8d(0x191)]===_0x25eb8d(0x21a)?_0x25eb8d(0x184):_0x25eb8d(0x1ff);try{const _0x53f676=(0x0,import_child_process['spawnSync'])(_0x304919,[_0x58cfc2],{'encoding':'utf8','timeout':0xbb8,'shell':![]});if(_0x53f676[_0x25eb8d(0x1db)]!==0x0)return'';return String(_0x53f676['stdout']||'')[_0x25eb8d(0x1b3)](/\r?\n/)[_0x25eb8d(0x1f3)](_0x5a3b3f=>_0x5a3b3f['trim']())['filter'](Boolean)[0x0]||'';}catch{return'';}}function skipWrapperUpdateCheck(){const _0x253c14=a0_0x6a9c70,_0x4b56bb=String(process.env.WHALENT_SKIP_UPDATE_CHECK||process.env.WHALENT_NO_UPDATE_CHECK||process.env.WHALENT_SKIP_WRAPPER_UPDATE||'')[_0x253c14(0x208)]()[_0x253c14(0x1f5)]();return _0x4b56bb==='1'||_0x4b56bb===_0x253c14(0x223)||_0x4b56bb==='yes'||_0x4b56bb==='on';}function latestWrapperVersion(){const _0x3f111b=a0_0x6a9c70,_0x24de46=runNpmView(['view',WRAPPER_PKG_NAME+'@latest','version','--registry='+NPM_REGISTRY]);if(_0x24de46['status']!==0x0)return'';return String(_0x24de46['stdout']||'')[_0x3f111b(0x208)]()[_0x3f111b(0x1b3)](/\r?\n/)['filter'](Boolean)['pop']()||'';}function installWrapperVersion(_0x711d40){const _0x1a825=a0_0x6a9c70,_0x3748ae=resolveExecutable('npm');if(!_0x3748ae)return{'ok':![],'output':_0x1a825(0x1ef)+'H'};const _0x2b8130=run(_0x3748ae,[_0x1a825(0x1d6),'-g',WRAPPER_PKG_NAME+'@'+_0x711d40,'--registry='+NPM_REGISTRY]),_0x5b0a62=((_0x2b8130['stdout']||'')+'\x0a'+(_0x2b8130[_0x1a825(0x20a)]||''))[_0x1a825(0x208)]();return{'ok':_0x2b8130[_0x1a825(0x1db)]===0x0,'output':_0x5b0a62};}function maybeUpdateWrapper(_0x339c8a){const _0x3535bc=a0_0x6a9c70;if(skipWrapperUpdateCheck())return![];if(process.env.WHALENT_WRAPPER_UPDATE_ATTEMPTED)return![];const _0xbc177a=latestWrapperVersion();if(!_0xbc177a||compareSemver(_0xbc177a,WRAPPER_VERSION)<=0x0)return![];console[_0x3535bc(0x1cd)](_0x3535bc(0x18d)+_0x3535bc(0x18b)+WRAPPER_VERSION+_0x3535bc(0x1fa)+_0xbc177a),console[_0x3535bc(0x1cd)](_0x3535bc(0x192)+'\x20'+WRAPPER_PKG_NAME+'@'+_0xbc177a+('\x20from\x20npm\x20before\x20sta'+'rting\x20core...'));const _0x229f59=installWrapperVersion(_0xbc177a);if(!_0x229f59['ok']){console[_0x3535bc(0x1cd)](_0x3535bc(0x1e0)+_0x3535bc(0x189)+'ing\x20with\x20'+WRAPPER_VERSION);if(_0x229f59[_0x3535bc(0x1d5)])console[_0x3535bc(0x1cd)](_0x229f59['output'][_0x3535bc(0x1b3)](/\r?\n/)[_0x3535bc(0x1ba)](-0xc)['join']('\x0a'));return console[_0x3535bc(0x1cd)]('[wrapper]\x20Manual\x20upd'+'ate:\x20npm\x20install\x20-g\x20'+WRAPPER_PKG_NAME+'@'+_0xbc177a+'\x20--registry='+NPM_REGISTRY),![];}console[_0x3535bc(0x1cd)](_0x3535bc(0x1e0)+_0x3535bc(0x1ea)+_0xbc177a+_0x3535bc(0x185));const _0x105335=process[_0x3535bc(0x1c5)][0x1],_0x1735f4=(0x0,import_child_process[_0x3535bc(0x199)])(process['execPath'],[_0x105335,..._0x339c8a],{'stdio':_0x3535bc(0x19d),'env':{...process.env,'WHALENT_WRAPPER_UPDATE_ATTEMPTED':_0xbc177a},'shell':![]});process['exit'](_0x1735f4[_0x3535bc(0x1db)]??0x0);}function findCoreScript(){const _0xc38188=a0_0x6a9c70,_0x2213b9=String(process.env.WHALENT_CORE_ENTRY||'')['trim'](),_0x17093e=['1',_0xc38188(0x223),_0xc38188(0x1ee),'on'][_0xc38188(0x1de)](String(process.env.WHALENT_FORCE_CORE_ENTRY||'')['trim']()[_0xc38188(0x1f5)]());if(_0x2213b9&&_0x17093e&&fs['existsSync'](_0x2213b9))return _0x2213b9;const _0x5963ee=[],_0x3df1fc=_0x115296=>{const _0x484d33=_0xc38188;if(fs[_0x484d33(0x1ce)](_0x115296)&&!_0x5963ee[_0x484d33(0x1de)](_0x115296))_0x5963ee[_0x484d33(0x187)](_0x115296);};if(_0x2213b9)_0x3df1fc(_0x2213b9);const _0x5a29e7=npmRootGlobal();if(_0x5a29e7){const _0xafce57=path[_0xc38188(0x1e2)](_0x5a29e7,'@whalent',_0xc38188(0x19e),_0xc38188(0x1e7),_0xc38188(0x1eb));_0x3df1fc(_0xafce57);}const _0x1c2818=path['join'](wrapperBaseDir(),_0xc38188(0x1c6));_0x3df1fc(_0x1c2818);const _0x5c37d9=path[_0xc38188(0x1e2)](wrapperBaseDir(),'..',_0xc38188(0x212),'core',_0xc38188(0x1e7),_0xc38188(0x1eb));_0x3df1fc(_0x5c37d9);if(_0x5963ee[_0xc38188(0x1bd)]>0x0)return _0x5963ee['map']((_0xa6829f,_0xf2a0a2)=>({'candidate':_0xa6829f,'index':_0xf2a0a2,'version':coreVersion(_0xa6829f)}))[_0xc38188(0x19f)]((_0x372271,_0xadaa6c)=>{const _0x14cba1=_0xc38188,_0x21b6d4=compareSemver(_0xadaa6c[_0x14cba1(0x210)],_0x372271[_0x14cba1(0x210)]);if(_0x21b6d4!==0x0)return _0x21b6d4;return _0xadaa6c['index']-_0x372271[_0x14cba1(0x1c3)];})[0x0][_0xc38188(0x1b8)];throw new Error(_0xc38188(0x1d0)+_0xc38188(0x1ae)+_0xc38188(0x1ac)+'or\x20rebuild\x20@whalent/'+_0xc38188(0x1b0));}function coreVersion(_0x1e3500=findCoreScript()){const _0xc1b5a5=a0_0x6a9c70;ensureNodePtyNativeModule(_0x1e3500);const _0x4b38b0=(0x0,import_child_process['spawnSync'])(process[_0xc1b5a5(0x1da)],[_0x1e3500,_0xc1b5a5(0x1e4)],{'encoding':_0xc1b5a5(0x207),'timeout':0x3a98,'env':{...process.env,'WHALENT_SKIP_UPDATE_CHECK':'1'},'shell':![]}),_0x24bc3f=(_0x4b38b0['stdout']||'')+'\x0a'+(_0x4b38b0['stderr']||'');return _0x24bc3f['match'](/(\d+\.\d+\.\d+(?:[-\w.]+)?)/)?.[0x1]||'';}function isExecutable(_0x47214b){const _0x29de87=a0_0x6a9c70;try{return fs['accessSync'](_0x47214b,fs[_0x29de87(0x1c9)]['X_OK']),!![];}catch{return![];}}function shellQuote(_0x10631b){const _0x3f181e=a0_0x6a9c70;return'\x27'+_0x10631b['replace'](/'/g,_0x3f181e(0x206))+'\x27';}function corePackageRoot(_0xe8820e){const _0xac33b8=a0_0x6a9c70;return path['resolve'](path[_0xac33b8(0x1b4)](_0xe8820e),'..');}function nodePtyPackageRoot(_0xdaa6fa){const _0x258137=a0_0x6a9c70,_0x4224d4=(0x0,import_module[_0x258137(0x1d1)])(_0xdaa6fa),_0x4ce1ed=_0x4224d4['resolve']('node-pty');let _0x59b152=path[_0x258137(0x1b4)](_0x4ce1ed);for(let _0x11783c=0x0;_0x11783c<0x5;_0x11783c++){const _0x429db1=path['join'](_0x59b152,_0x258137(0x224));try{const _0x3f4e20=JSON[_0x258137(0x198)](fs['readFileSync'](_0x429db1,_0x258137(0x1b2)));if(_0x3f4e20['name']===_0x258137(0x196))return _0x59b152;}catch{}const _0x2f2d1c=path[_0x258137(0x1b4)](_0x59b152);if(_0x2f2d1c===_0x59b152)break;_0x59b152=_0x2f2d1c;}return path['resolve'](path[_0x258137(0x1b4)](_0x4ce1ed),'..');}function nodePtyNativeCandidates(_0x5ec470){const _0x16204d=a0_0x6a9c70;return[path[_0x16204d(0x1e2)](_0x5ec470,_0x16204d(0x1f6),'Release','pty.node'),path[_0x16204d(0x1e2)](_0x5ec470,_0x16204d(0x215),process[_0x16204d(0x191)]+'-'+process[_0x16204d(0x200)],_0x16204d(0x1d4))];}function hasNodePtyNativeModule(_0x159279){const _0x2278ec=a0_0x6a9c70;return nodePtyNativeCandidates(_0x159279)['some'](_0x304a02=>fs[_0x2278ec(0x1ce)](_0x304a02));}function printNodePtyRebuildHint(_0x2c3bcc){const _0x7e8649=a0_0x6a9c70,_0x5f0758=corePackageRoot(_0x2c3bcc);console['warn'](_0x7e8649(0x20d)+':'),console['warn'](_0x7e8649(0x193)+shellQuote(_0x5f0758)),console[_0x7e8649(0x1cd)](_0x7e8649(0x216)+_0x7e8649(0x1fe));}function ensureNodePtyNativeModule(_0x152cbc){const _0x5040f1=a0_0x6a9c70;if(process['platform']==='win32')return;let _0x259bd9='';try{_0x259bd9=nodePtyPackageRoot(_0x152cbc);}catch(_0x27f09e){console[_0x5040f1(0x1cd)](_0x5040f1(0x21d)+_0x5040f1(0x1dc)+_0x5040f1(0x1c0)+_0x27f09e['message']),printNodePtyRebuildHint(_0x152cbc);return;}const _0x1498ab=((()=>{try{return fs['realpathSync'](_0x259bd9);}catch{return _0x259bd9;}})());if(CHECKED_NODE_PTY_RUNTIMES[_0x5040f1(0x19a)](_0x1498ab))return;CHECKED_NODE_PTY_RUNTIMES[_0x5040f1(0x217)](_0x1498ab);if(hasNodePtyNativeModule(_0x259bd9))return;const _0x4c8a90=resolveExecutable('npm');console['warn']('[wrapper]\x20node-pty\x20n'+_0x5040f1(0x1df)+_0x5040f1(0x1c7)+_0x259bd9),console['warn']('[wrapper]\x20rebuilding'+'\x20node-pty\x20before\x20sta'+'rting\x20core...');if(!_0x4c8a90){console[_0x5040f1(0x1cd)]('[wrapper]\x20npm\x20not\x20fo'+_0x5040f1(0x205)+'node-pty\x20automatical'+'ly'),printNodePtyRebuildHint(_0x152cbc);return;}const _0x455b52=corePackageRoot(_0x152cbc),_0x33b7d0=(0x0,import_child_process['spawnSync'])(_0x4c8a90,[_0x5040f1(0x1c4),'node-pty','--verbose'],{'cwd':_0x455b52,'stdio':'inherit','timeout':NPM_INSTALL_TIMEOUT_MS,'env':process.env,'shell':![]});if(_0x33b7d0['status']===0x0&&hasNodePtyNativeModule(_0x259bd9)){console['warn']('[wrapper]\x20node-pty\x20r'+'ebuild\x20completed');return;}console[_0x5040f1(0x1cd)]('[wrapper]\x20node-pty\x20r'+'ebuild\x20failed'+(_0x33b7d0[_0x5040f1(0x1db)]!==null?_0x5040f1(0x186)+_0x33b7d0['status']+')':'')+(';\x20core\x20may\x20fail\x20to\x20s'+'tart')),printNodePtyRebuildHint(_0x152cbc);}function coreNodePtySpawnHelperPath(_0x52a8e8){const _0x171d2c=a0_0x6a9c70;if(process['platform']!==_0x171d2c(0x1a2))return'';try{const _0x133560=(0x0,import_module[_0x171d2c(0x1d1)])(_0x52a8e8),_0x5067c6=_0x133560[_0x171d2c(0x188)]('node-pty'),_0x39f976=path[_0x171d2c(0x188)](path[_0x171d2c(0x1b4)](_0x5067c6),'..');return path[_0x171d2c(0x1e2)](_0x39f976,'prebuilds',_0x171d2c(0x214)+process['arch'],_0x171d2c(0x1e9));}catch{return'';}}function checkMacNodePtySpawnHelper(_0x26d2fd){const _0x55357b=a0_0x6a9c70,_0x348e58=coreNodePtySpawnHelperPath(_0x26d2fd);if(!_0x348e58||CHECKED_PTY_HELPERS['has'](_0x348e58))return;CHECKED_PTY_HELPERS['add'](_0x348e58);if(!fs[_0x55357b(0x1ce)](_0x348e58)){console['warn'](_0x55357b(0x1aa)+_0x55357b(0x18a)+'t\x20found:\x20'+_0x348e58);return;}if(isExecutable(_0x348e58))return;try{const _0xc82369=fs['statSync'](_0x348e58)['mode'];fs[_0x55357b(0x1d2)](_0x348e58,_0xc82369|0x1ed);}catch{}if(isExecutable(_0x348e58)){console[_0x55357b(0x1cd)]('[wrapper]\x20fixed\x20macO'+_0x55357b(0x1e6)+'per\x20executable\x20bit:\x20'+_0x348e58);return;}console['warn']('[wrapper]\x20macOS\x20node'+'-pty\x20spawn-helper\x20is'+_0x55357b(0x1ab)+_0x348e58),console[_0x55357b(0x1cd)](_0x55357b(0x213)+'nce\x20to\x20fix\x20terminal/'+'PTY\x20startup:'),console['warn']('\x20\x20HELPER='+shellQuote(_0x348e58)),console['warn']('\x20\x20ls\x20-l\x20\x22$HELPER\x22'),console[_0x55357b(0x1cd)]('\x20\x20chmod\x20+x\x20\x22$HELPER\x22');}function printVersion(){const _0x58cdff=a0_0x6a9c70;let _0x3f70d9='';try{_0x3f70d9=coreVersion();}catch{}console[_0x58cdff(0x1cb)]('whalent-agent\x20'+WRAPPER_VERSION),console[_0x58cdff(0x1cb)](_0x58cdff(0x1ad)+WRAPPER_VERSION),console[_0x58cdff(0x1cb)](_0x58cdff(0x1a6)+(_0x3f70d9||_0x58cdff(0x1af)));}function directCore(_0x405e5c){const _0x4778f8=a0_0x6a9c70,_0x53fd84=findCoreScript();ensureNodePtyNativeModule(_0x53fd84),checkMacNodePtySpawnHelper(_0x53fd84);const _0xf7aa46=(0x0,import_child_process['spawnSync'])(process['execPath'],[_0x53fd84,..._0x405e5c],{'stdio':_0x4778f8(0x19d),'env':{...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_CORE_ENTRY':_0x53fd84},'shell':![]});process[_0x4778f8(0x1b5)](_0xf7aa46[_0x4778f8(0x1db)]??0x0);}function shouldSupervise(_0x36087c){const _0x37fa2c=a0_0x6a9c70;if(_0x36087c['includes']('--agent-id'))return![];if(_0x36087c[_0x37fa2c(0x1de)]('--resume')||_0x36087c[0x0]===_0x37fa2c(0x18e))return![];const _0x5f12cd=_0x36087c[0x0]||'';if(_0x5f12cd==='ls'||_0x5f12cd===_0x37fa2c(0x1db)||_0x5f12cd==='ps')return![];if(_0x5f12cd===_0x37fa2c(0x1c2)||_0x5f12cd===_0x37fa2c(0x1cf))return![];if(_0x36087c[_0x37fa2c(0x1de)]('--help')||_0x36087c['includes']('-h'))return![];return!![];}function a0_0x1f90(_0x1cdee9,_0x4b99ba){_0x1cdee9=_0x1cdee9-0x17e;const _0x1bcdee=a0_0x1bcd();let _0x1f90df=_0x1bcdee[_0x1cdee9];if(a0_0x1f90['JvigOZ']===undefined){var _0x49fedb=function(_0x21f654){const _0x5cdb7a='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x4b08f4='',_0x3ce9c9='';for(let _0x5d5cef=0x0,_0x40a656,_0x4e166c,_0x540739=0x0;_0x4e166c=_0x21f654['charAt'](_0x540739++);~_0x4e166c&&(_0x40a656=_0x5d5cef%0x4?_0x40a656*0x40+_0x4e166c:_0x4e166c,_0x5d5cef++%0x4)?_0x4b08f4+=String['fromCharCode'](0xff&_0x40a656>>(-0x2*_0x5d5cef&0x6)):0x0){_0x4e166c=_0x5cdb7a['indexOf'](_0x4e166c);}for(let _0x157552=0x0,_0xba082b=_0x4b08f4['length'];_0x157552<_0xba082b;_0x157552++){_0x3ce9c9+='%'+('00'+_0x4b08f4['charCodeAt'](_0x157552)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x3ce9c9);};a0_0x1f90['OVUKBY']=_0x49fedb,a0_0x1f90['VwlQDY']={},a0_0x1f90['JvigOZ']=!![];}const _0x52b953=_0x1bcdee[0x0],_0x1a3555=_0x1cdee9+_0x52b953,_0xcd1e61=a0_0x1f90['VwlQDY'][_0x1a3555];return!_0xcd1e61?(_0x1f90df=a0_0x1f90['OVUKBY'](_0x1f90df),a0_0x1f90['VwlQDY'][_0x1a3555]=_0x1f90df):_0x1f90df=_0xcd1e61,_0x1f90df;}function installCoreVersion(_0x2687d7){const _0xbb2285=a0_0x6a9c70,_0x36fd6a=resolveExecutable('npm');if(!_0x36fd6a)return{'ok':![],'output':'npm\x20not\x20found\x20on\x20PAT'+'H'};const _0x196039=CORE_PKG_NAME+'@'+_0x2687d7,_0x31e65a=run(_0x36fd6a,['install','-g',_0x196039,_0xbb2285(0x1c8)+NPM_REGISTRY]),_0x254d95=((_0x31e65a['stdout']||'')+'\x0a'+(_0x31e65a['stderr']||''))[_0xbb2285(0x208)]();return{'ok':_0x31e65a['status']===0x0,'output':_0x254d95};}async function superviseCore(_0x4770f0){const _0x36dd63=a0_0x6a9c70;let _0x206bcb=![],_0x39049e=null;const _0x19f846=[];let _0x49e5fa=MIN_RESTART_DELAY_MS;const _0x5e045f=()=>{const _0x443114=a0_0x1f90;_0x206bcb=!![];if(_0x39049e&&!_0x39049e[_0x443114(0x21e)])try{_0x39049e[_0x443114(0x1e8)](_0x443114(0x1be));}catch{}else process[_0x443114(0x1b5)](0x0);};process['on'](_0x36dd63(0x1f9),_0x5e045f),process['on'](_0x36dd63(0x1be),_0x5e045f);while(!![]){const _0x245f94=findCoreScript();ensureNodePtyNativeModule(_0x245f94),checkMacNodePtySpawnHelper(_0x245f94);const _0x2ab3b1={...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_WRAPPER_MANAGED':'1','WHALENT_CORE_ENTRY':_0x245f94},_0x1d9f91=readUpgradeState(),_0x3a4f5c=!!_0x1d9f91?.['pending'];let _0x34b8ac=![],_0x5ab605=null,_0x4f535b='';const _0x2990d7=[],_0x4a2dd0=0xc;console[_0x36dd63(0x1cb)]('[wrapper]\x20starting\x20c'+'ore:\x20'+_0x245f94),_0x39049e=(0x0,import_child_process['spawn'])(process[_0x36dd63(0x1da)],[_0x245f94,..._0x4770f0],{'env':_0x2ab3b1,'stdio':[_0x36dd63(0x19d),_0x36dd63(0x1a7),'pipe']});const _0x248e11=()=>{const _0x13a3b9=_0x36dd63;if(_0x34b8ac)return;_0x34b8ac=!![];if(_0x5ab605)clearTimeout(_0x5ab605);_0x19f846['length']=0x0,_0x49e5fa=MIN_RESTART_DELAY_MS;const _0x418c27=readUpgradeState();_0x418c27?.[_0x13a3b9(0x194)]&&(writeUpgradeState({..._0x418c27,'pending':![],'rollback':![],'health_status':_0x13a3b9(0x1b6)}),console[_0x13a3b9(0x1cb)](_0x13a3b9(0x1a4)+_0x13a3b9(0x1bf)+(_0x418c27['installed_version']||_0x418c27[_0x13a3b9(0x1e5)]||'')));},_0xf6d322=(_0x88961f,_0x5b068b=![])=>{const _0x1708dd=_0x36dd63,_0x58c61f=_0x88961f['toString']();(_0x5b068b?process['stderr']:process[_0x1708dd(0x197)])['write'](_0x58c61f);if(_0x5b068b)for(const _0xad825 of _0x58c61f['split'](/\r?\n/)){if(!_0xad825['trim']())continue;_0x2990d7[_0x1708dd(0x187)](_0xad825);if(_0x2990d7[_0x1708dd(0x1bd)]>_0x4a2dd0)_0x2990d7[_0x1708dd(0x182)]();const _0x5c17b3=_0xad825['match'](FATAL_PATTERN);if(_0x5c17b3)_0x4f535b=_0x5c17b3[0x0];}(_0x58c61f[_0x1708dd(0x1de)]('[gateway]\x20Connected')||_0x58c61f['includes'](_0x1708dd(0x1fc)+_0x1708dd(0x18c))||_0x58c61f[_0x1708dd(0x1de)]('Gateway:\x20connected'))&&_0x248e11();};_0x39049e['stdout']?.['on'](_0x36dd63(0x195),_0x2f7af=>_0xf6d322(_0x2f7af,![])),_0x39049e['stderr']?.['on']('data',_0x494d93=>_0xf6d322(_0x494d93,!![]));_0x3a4f5c&&(_0x5ab605=setTimeout(()=>{const _0x4cee99=_0x36dd63;if(_0x34b8ac||!_0x39049e||_0x39049e[_0x4cee99(0x21e)])return;console['error'](_0x4cee99(0x219)+_0x4cee99(0x1c1)+_0x4cee99(0x1ed)+_0x4cee99(0x20b));try{_0x39049e['kill']('SIGTERM');}catch{}},HEALTH_TIMEOUT_MS));const _0x7206d0=await new Promise(_0xdbb4f4=>{const _0x4bd322=_0x36dd63;_0x39049e[_0x4bd322(0x1dd)]('exit',(_0x5668f0,_0x33b0b3)=>_0xdbb4f4({'code':_0x5668f0,'signal':_0x33b0b3}));});if(_0x5ab605)clearTimeout(_0x5ab605);_0x39049e=null;if(_0x206bcb)process[_0x36dd63(0x1b5)](_0x7206d0['code']??0x0);const _0x4b1fc3=readUpgradeState();if(_0x4b1fc3?.['pending']&&!_0x34b8ac){const _0xa9e002=String(_0x4b1fc3[_0x36dd63(0x21b)+'n']||'')['trim']();if(_0xa9e002){console['error'](_0x36dd63(0x209)+_0x36dd63(0x1d8)+_0xa9e002);const _0xbf7f47=installCoreVersion(_0xa9e002);writeUpgradeState({..._0x4b1fc3,'pending':![],'rollback':!![],'health_status':_0xbf7f47['ok']?_0x36dd63(0x1f0):_0x36dd63(0x18f),'error':_0xbf7f47['ok']?'':_0xbf7f47['output']});}else writeUpgradeState({..._0x4b1fc3,'pending':![],'rollback':!![],'health_status':'rollback_unavailable','error':'previous\x20core\x20versio'+_0x36dd63(0x20c)});}const _0x568e8f=_0x7206d0[_0x36dd63(0x1a5)]===SUPERVISED_RESTART_CODE||_0x4b1fc3?.['pending'];if(!_0x568e8f&&_0x7206d0[_0x36dd63(0x1a5)]===0x0)process[_0x36dd63(0x1b5)](0x0);const _0x2642c6=Date[_0x36dd63(0x1b1)]();_0x19f846['push'](_0x2642c6);while(_0x19f846['length']>0x0&&_0x2642c6-_0x19f846[0x0]>CRASH_WINDOW_MS){_0x19f846[_0x36dd63(0x182)]();}const _0x33124b=_0x19f846[_0x36dd63(0x1bd)];writeLastCrash({'timestamp':_0x2642c6,'exit_code':_0x7206d0['code'],'exit_signal':_0x7206d0['signal']||null,'fatal_line':_0x4f535b,'raw_tail':_0x2990d7['join']('\x0a'),'consecutive_crashes':_0x33124b}),console['log'](_0x36dd63(0x1a8)+_0x36dd63(0x1a9)+(_0x7206d0[_0x36dd63(0x1a5)]??'')+(_0x7206d0['signal']?'\x20signal='+_0x7206d0['signal']:'')+'\x20('+_0x33124b+'/'+MAX_CRASHES_IN_WINDOW+'\x20in\x20last\x20'+Math[_0x36dd63(0x1f7)](CRASH_WINDOW_MS/0x3e8)+'s)');if(_0x4f535b)console['log']('[wrapper]\x20last\x20fatal'+':\x20'+_0x4f535b);_0x33124b>=MAX_CRASHES_IN_WINDOW&&(console[_0x36dd63(0x201)](_0x36dd63(0x1d7)+'d\x20'+_0x33124b+_0x36dd63(0x21f)+Math['round'](CRASH_WINDOW_MS/0x3e8)+(_0x36dd63(0x1f4)+_0x36dd63(0x220))+lastCrashFilePath()+('.\x20Restart\x20wrapper\x20ma'+_0x36dd63(0x17f)+'erlying\x20issue\x20is\x20fix'+'ed.')),process['exit'](0x1)),console['log'](_0x36dd63(0x1cc)+_0x36dd63(0x20f)+_0x49e5fa+'ms'),await new Promise(_0x3b6af6=>setTimeout(_0x3b6af6,_0x49e5fa)),_0x49e5fa=Math[_0x36dd63(0x20e)](_0x49e5fa*0x2,MAX_RESTART_DELAY_MS);}}async function main(){const _0x235cba=a0_0x6a9c70,_0x26161a=process[_0x235cba(0x1c5)]['slice'](0x2);if(_0x26161a[0x0]===_0x235cba(0x1e4)||_0x26161a[0x0]==='-v'||_0x26161a[0x0]===_0x235cba(0x210)){printVersion();return;}if((_0x26161a[0x0]===_0x235cba(0x1db)||_0x26161a[0x0]==='ls'||_0x26161a[0x0]==='ps')&&!_0x26161a[_0x235cba(0x1de)]('--json')){console['log'](_0x235cba(0x1ad)+WRAPPER_VERSION);try{console[_0x235cba(0x1cb)]('core\x20'+(coreVersion()||_0x235cba(0x1af)));}catch{console[_0x235cba(0x1cb)](_0x235cba(0x19c));}}maybeUpdateWrapper(_0x26161a);if(!shouldSupervise(_0x26161a))directCore(_0x26161a);await superviseCore(_0x26161a);}main()[a0_0x6a9c70(0x204)](_0x39c2ff=>{const _0x2e2e1c=a0_0x6a9c70;console['error'](_0x2e2e1c(0x1b9)+'r:\x20'+(_0x39c2ff?.[_0x2e2e1c(0x1bc)]||String(_0x39c2ff))),process['exit'](0x1);});function a0_0x1bcd(){const _0x59d694=['BwvZC2fNzq','BgvUz3rO','u0Lhvevstq','zguGAgvHBhrOEtOG','ywjSzsbMB3iGy29YztOG','AwqGBM90igjLy29TzsbOzwfSDgG','BwnW','Aw5KzxG','CMvIDwLSza','yxjNDG','y29Yzs5JANm','Aw5NihvUzgvYia','ls1YzwDPC3rYEt0','y29UC3rHBNrZ','ChjVDg90ExbL','Bg9N','w3DYyxbWzxjDihjLC3rHCNrPBMC','D2fYBG','zxHPC3rZu3LUyW','zgfLBw9Ulw1JCa','D2HHBgvUDcbJB3jLihj1BNrPBwu','y3jLyxrLuMvXDwLYzq','y2HTB2rtEw5J','qhDOywXLBNqVywDLBNq','Chr5lM5Vzgu','B3v0Chv0','Aw5ZDgfSBa','w3DYyxbWzxjDignVCMuGzMfPBgu','y2SGy29Yzsb0BYa','mJeYnti5ChnfCeLN','zxHLy1bHDgG','C3rHDhvZ','zxbLBMrLBMn5ig5VDcbYzxnVBhy','B25Jzq','Aw5JBhvKzxm','yxrPDMuGBw9KDwXLigLZig1PC3m','w3DYyxbWzxjDihDYyxbWzxiGDxa','z2v0uhjVDg90ExbLt2y','AM9PBG','nZe0odnVvvz2qLq','ls12zxjZAw9U','DgfYz2v0x3zLCNnPB24','uYbUB2rLlxb0EsbZCgf3BI1OzwW','zgLZDa','A2LSBa','C3bHD24TAgvSCgvY','zgf0zwqGDg8G','Aw5KzxGUy2PZ','mtyYnda4nMHYAgjWrq','EsbPBIb0Aw1LoYbYB2XSAw5Nigi','EwvZ','BNbTig5VDcbMB3vUzcbVBIbqqvq','CM9SBgvKx2jHy2S','CMvWBgfJzq','lNDOywXLBNqTywDLBNq','BwfW','CZSGz2L2Aw5NihvWlIbdCMfZAca','Dg9mB3DLCKnHC2u','yNvPBgq','CM91BMq','CgfYC2vjBNq','u0Lhsu5u','ic0+ia','BgfZDc1JCMfZAc5QC29U','r2f0zxDHEsbYzwDPC3rLCMvKig0','zgvMAw5LuhjVCgvYDhK','DhKGls12zxjIB3nL','D2HPy2G','yxjJAa','zxjYB3i','Ag9TzwrPCG','mtiZmtyZoej3EhnpyG','y2f0y2G','Dw5KoYbJyw5UB3qGCMvIDwLSzca','j1WNjW','DxrMoa','DhjPBq','w3DYyxbWzxjDihjVBgXPBMCGyMe','C3rKzxjY','ywnR','BIb1BMTUB3DU','w3DYyxbWzxjDie1HBNvHBcbMAxG','BwLU','igLUia','DMvYC2LVBG','mtm2mdbJuhH2qu0','CgfJA2fNzxm','w3DYyxbWzxjDifj1BIb0AgLZig8','zgfYD2LUlq','ChjLyNvPBgrZ','icbUCg0GCMvIDwLSzcbUB2rLlxa','ywrK','D3jPDgvgAwXLu3LUyW','w3DYyxbWzxjDig5LDYbJB3jLigq','D2LUmZi','ChjLDMLVDxnFy29Yzv92zxjZAw8','nwjuENr6AW','w3DYyxbWzxjDig5VzguTChr5igq','A2LSBgvK','ihrPBwvZihDPDgHPBIa','CMvJB3jKoIa','BwTKAxjtEw5J','y3jLyxrL','Dhj1zq','CgfJA2fNzs5QC29U','Bwf4','BNvHBgX5igfMDgvYihrOzsb1BMq','Cgf0Aa','Bw9KDwXL','C2HPzNq','CMvHzezPBgvtEw5J','D2HLCMuUzxHL','oYbYzxn0yxj0Aw5NihDYyxbWzxi','icHLEgL0pq','ChvZAa','CMvZB2X2zq','zgf0zsbMywLSzwq7ignVBNrPBNu','lxb0EsbZCgf3BI1OzwXWzxiGBM8','AwXHyMXLoIa','ywnOAw5L','w3DYyxbWzxjDihvWzgf0zsbHDMe','CMvZDw1L','CM9SBgjHy2TFzMfPBgvK','mZu3wvvAvuPN','CgXHDgzVCM0','w3DYyxbWzxjDigLUC3rHBgXPBMC','icbJzca','CgvUzgLUzW','zgf0yq','BM9Kzs1WDhK','C3rKB3v0','CgfYC2u','C3bHD25tEw5J','AgfZ','C3rYAw5NAwz5','y29YzsbUB3qGAw5ZDgfSBgvK','Aw5OzxjPDa','ywDLBNqTy29Yzq','C29YDa','CM9VDa','mNDtvM5mrG','zgfYD2LU','nZa2ntKYCvLtt1Ps','w3DYyxbWzxjDignVCMuGDxbNCMe','y29Kzq','y29Yzsa','CgLWzq','w3DYyxbWzxjDignVCMuGzxHPDgu','zcbJB2rLpq','w3DYyxbWzxjDig1Hy09tig5Vzgu','ig5VDcbLEgvJDxrHyMXLoIa','qhDOywXLBNqVywDLBNqTy29Yzsa','D3jHChbLCIa','ig5VDcbMB3vUzdSGAw5ZDgfSBca','BM90igLUC3rHBgXLza','ywDLBNq','BM93','DxrMltG','C3bSAxq','zgLYBMfTzq','zxHPDa','AgvHBhrOEq','y29Yzs11CgDYywrLlMPZB24','y2fUzgLKyxrL','w3DYyxbWzxjDiezHDgfSigvYCM8','C2XPy2u','ntiWndCWmeLnv2rOyG'];a0_0x1bcd=function(){return _0x59d694;};return a0_0x1bcd();}
|
|
2
|
+
'use strict';const a0_0x5d1578=a0_0x445a;(function(_0x481c5a,_0x2d90aa){const _0x48284a=a0_0x445a,_0x57b5b1=_0x481c5a();while(!![]){try{const _0x4a9095=parseInt(_0x48284a(0x1cf))/0x1*(-parseInt(_0x48284a(0x164))/0x2)+parseInt(_0x48284a(0x16a))/0x3*(-parseInt(_0x48284a(0x1ac))/0x4)+-parseInt(_0x48284a(0x15c))/0x5+-parseInt(_0x48284a(0x1de))/0x6*(parseInt(_0x48284a(0x1a1))/0x7)+parseInt(_0x48284a(0x187))/0x8*(parseInt(_0x48284a(0x189))/0x9)+-parseInt(_0x48284a(0x16e))/0xa*(-parseInt(_0x48284a(0x170))/0xb)+-parseInt(_0x48284a(0x1e7))/0xc*(-parseInt(_0x48284a(0x1df))/0xd);if(_0x4a9095===_0x2d90aa)break;else _0x57b5b1['push'](_0x57b5b1['shift']());}catch(_0x247a89){_0x57b5b1['push'](_0x57b5b1['shift']());}}}(a0_0x23db,0xba0f9));function a0_0x445a(_0x4532c7,_0x288433){_0x4532c7=_0x4532c7-0x159;const _0x23db2b=a0_0x23db();let _0x445a62=_0x23db2b[_0x4532c7];if(a0_0x445a['MLtVbJ']===undefined){var _0x288a1f=function(_0x3abfb3){const _0x2ed162='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x425260='',_0x22e696='';for(let _0x307170=0x0,_0x249f3d,_0x5c16bb,_0x15daba=0x0;_0x5c16bb=_0x3abfb3['charAt'](_0x15daba++);~_0x5c16bb&&(_0x249f3d=_0x307170%0x4?_0x249f3d*0x40+_0x5c16bb:_0x5c16bb,_0x307170++%0x4)?_0x425260+=String['fromCharCode'](0xff&_0x249f3d>>(-0x2*_0x307170&0x6)):0x0){_0x5c16bb=_0x2ed162['indexOf'](_0x5c16bb);}for(let _0x4842b1=0x0,_0x1a94ba=_0x425260['length'];_0x4842b1<_0x1a94ba;_0x4842b1++){_0x22e696+='%'+('00'+_0x425260['charCodeAt'](_0x4842b1)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x22e696);};a0_0x445a['VhbhBu']=_0x288a1f,a0_0x445a['amFDNa']={},a0_0x445a['MLtVbJ']=!![];}const _0x5dc7de=_0x23db2b[0x0],_0x2498cb=_0x4532c7+_0x5dc7de,_0x3d12c7=a0_0x445a['amFDNa'][_0x2498cb];return!_0x3d12c7?(_0x445a62=a0_0x445a['VhbhBu'](_0x445a62),a0_0x445a['amFDNa'][_0x2498cb]=_0x445a62):_0x445a62=_0x3d12c7,_0x445a62;}var __create=Object[a0_0x5d1578(0x1d7)],__defProp=Object['defineProperty'],__getOwnPropDesc=Object[a0_0x5d1578(0x17c)+'ptor'],__getOwnPropNames=Object['getOwnPropertyNames'],__getProtoOf=Object['getPrototypeOf'],__hasOwnProp=Object[a0_0x5d1578(0x18e)]['hasOwnProperty'],__copyProps=(_0x425260,_0x22e696,_0x307170,_0x249f3d)=>{const _0x4e6b51=a0_0x5d1578;if(_0x22e696&&typeof _0x22e696==='object'||typeof _0x22e696===_0x4e6b51(0x19c)){for(let _0x5c16bb of __getOwnPropNames(_0x22e696))if(!__hasOwnProp[_0x4e6b51(0x1a6)](_0x425260,_0x5c16bb)&&_0x5c16bb!==_0x307170)__defProp(_0x425260,_0x5c16bb,{'get':()=>_0x22e696[_0x5c16bb],'enumerable':!(_0x249f3d=__getOwnPropDesc(_0x22e696,_0x5c16bb))||_0x249f3d[_0x4e6b51(0x1aa)]});}return _0x425260;},__toESM=(_0x15daba,_0x4842b1,_0x1a94ba)=>(_0x1a94ba=_0x15daba!=null?__create(__getProtoOf(_0x15daba)):{},__copyProps(_0x4842b1||!_0x15daba||!_0x15daba['__esModule']?__defProp(_0x1a94ba,a0_0x5d1578(0x19b),{'value':_0x15daba,'enumerable':!![]}):_0x1a94ba,_0x15daba)),import_child_process=require('child_process'),fs=__toESM(require('fs'),0x1),import_module=require('module'),os=__toESM(require('os'),0x1),path=__toESM(require('path'),0x1),WRAPPER_PKG_NAME=a0_0x5d1578(0x1c5),CORE_PKG_NAME=a0_0x5d1578(0x1b6),NPM_REGISTRY=a0_0x5d1578(0x159)+'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 _0x2605a4=a0_0x5d1578;return path['join'](os[_0x2605a4(0x18d)](),'.whalent-agent');}function upgradeStatePath(){const _0x37437d=a0_0x5d1578;return path[_0x37437d(0x180)](configDir(),_0x37437d(0x15f));}function lastCrashFilePath(){return path['join'](configDir(),'last-crash.json');}function writeLastCrash(_0x432536){try{fs['mkdirSync'](configDir(),{'recursive':!![]});const _0x2e0dbd={..._0x432536,'reported':![]};fs['writeFileSync'](lastCrashFilePath(),JSON['stringify'](_0x2e0dbd,null,0x2),'utf-8');}catch{}}function readWrapperVersion(){const _0x2f77ad=a0_0x5d1578;try{const _0x15d7e6=JSON['parse'](fs[_0x2f77ad(0x178)](path[_0x2f77ad(0x180)](wrapperBaseDir(),'..',_0x2f77ad(0x1e9)),_0x2f77ad(0x15e)));return String(_0x15d7e6['version']||'0.0.0');}catch{return _0x2f77ad(0x1be);}}function readUpgradeState(){const _0xb18553=a0_0x5d1578;try{return JSON[_0xb18553(0x1a8)](fs[_0xb18553(0x178)](upgradeStatePath(),'utf-8'));}catch{return null;}}function writeUpgradeState(_0x14a3bd){const _0x13c3a0=a0_0x5d1578;try{fs['mkdirSync'](configDir(),{'recursive':!![]}),fs['writeFileSync'](upgradeStatePath(),JSON[_0x13c3a0(0x1d6)]({..._0x14a3bd,'updated_at':Date['now']()},null,0x2),'utf-8');}catch{}}function run(_0x13d974,_0x4bb7b9,_0x53c18b=process.env){const _0x3b391b=a0_0x5d1578;return(0x0,import_child_process['spawnSync'])(_0x13d974,_0x4bb7b9,{'encoding':_0x3b391b(0x1d2),'timeout':NPM_INSTALL_TIMEOUT_MS,'maxBuffer':NPM_INSTALL_MAX_BUFFER,'env':_0x53c18b,'shell':![]});}function runNpmView(_0x1a83a9){const _0x165702=a0_0x5d1578,_0xf78fd4=resolveExecutable(_0x165702(0x194));if(!_0xf78fd4)return{'status':0x7f,'stdout':'','stderr':'npm\x20not\x20found','error':new Error(_0x165702(0x1ae))};return(0x0,import_child_process[_0x165702(0x190)])(_0xf78fd4,_0x1a83a9,{'encoding':'utf8','timeout':NPM_VIEW_TIMEOUT_MS,'maxBuffer':0x400*0x400,'env':process.env,'shell':![]});}function npmRootGlobal(){const _0xa88a65=a0_0x5d1578,_0x1c4b5e=resolveExecutable('npm');if(!_0x1c4b5e)return'';const _0x5cb9ca=run(_0x1c4b5e,['root','-g']);if(_0x5cb9ca['status']!==0x0)return'';return String(_0x5cb9ca[_0xa88a65(0x18f)]||'')[_0xa88a65(0x160)]();}function compareSemver(_0x20f41c,_0x55cfee){const _0x3752d7=a0_0x5d1578,_0x10d028=String(_0x20f41c||'')[_0x3752d7(0x1dc)](/^v/,'')['split'](/[.-]/)['map'](_0x4670fc=>Number[_0x3752d7(0x1ea)](_0x4670fc,0xa)||0x0),_0x268312=String(_0x55cfee||'')['replace'](/^v/,'')[_0x3752d7(0x18c)](/[.-]/)['map'](_0x3eac4e=>Number[_0x3752d7(0x1ea)](_0x3eac4e,0xa)||0x0);for(let _0x527760=0x0;_0x527760<Math[_0x3752d7(0x1b5)](_0x10d028[_0x3752d7(0x1e0)],_0x268312[_0x3752d7(0x1e0)],0x3);_0x527760++){const _0x441a3a=_0x10d028[_0x527760]||0x0,_0x1b92d8=_0x268312[_0x527760]||0x0;if(_0x441a3a>_0x1b92d8)return 0x1;if(_0x441a3a<_0x1b92d8)return-0x1;}return 0x0;}function resolveExecutable(_0x277f3d){const _0x28c36d=a0_0x5d1578,_0x48efbe=process[_0x28c36d(0x1c1)]===_0x28c36d(0x19a)?_0x28c36d(0x19d):_0x28c36d(0x1b4);try{const _0x52e25c=(0x0,import_child_process[_0x28c36d(0x190)])(_0x48efbe,[_0x277f3d],{'encoding':'utf8','timeout':0xbb8,'shell':![]});if(_0x52e25c[_0x28c36d(0x191)]!==0x0)return'';return String(_0x52e25c['stdout']||'')['split'](/\r?\n/)[_0x28c36d(0x1c4)](_0x232905=>_0x232905['trim']())[_0x28c36d(0x161)](Boolean)[0x0]||'';}catch{return'';}}function skipWrapperUpdateCheck(){const _0x5896e1=a0_0x5d1578,_0x9fff2a=String(process.env.WHALENT_SKIP_UPDATE_CHECK||process.env.WHALENT_NO_UPDATE_CHECK||process.env.WHALENT_SKIP_WRAPPER_UPDATE||'')[_0x5896e1(0x160)]()['toLowerCase']();return _0x9fff2a==='1'||_0x9fff2a==='true'||_0x9fff2a==='yes'||_0x9fff2a==='on';}function latestWrapperVersion(){const _0x22195e=a0_0x5d1578,_0x5a2b36=runNpmView(['view',WRAPPER_PKG_NAME+'@latest','version','--registry='+NPM_REGISTRY]);if(_0x5a2b36['status']!==0x0)return'';return String(_0x5a2b36[_0x22195e(0x18f)]||'')[_0x22195e(0x160)]()['split'](/\r?\n/)['filter'](Boolean)['pop']()||'';}function installWrapperVersion(_0x59e0a5){const _0x27a9fa=a0_0x5d1578,_0x170eb7=resolveExecutable(_0x27a9fa(0x194));if(!_0x170eb7)return{'ok':![],'output':'npm\x20not\x20found\x20on\x20PAT'+'H'};const _0x5b3c4e=run(_0x170eb7,['install','-g',WRAPPER_PKG_NAME+'@'+_0x59e0a5,'--registry='+NPM_REGISTRY]),_0x5352db=((_0x5b3c4e['stdout']||'')+'\x0a'+(_0x5b3c4e['stderr']||''))[_0x27a9fa(0x160)]();return{'ok':_0x5b3c4e['status']===0x0,'output':_0x5352db};}function maybeUpdateWrapper(_0xa96a15){const _0x26a32b=a0_0x5d1578;if(skipWrapperUpdateCheck())return![];if(process.env.WHALENT_WRAPPER_UPDATE_ATTEMPTED)return![];const _0x2f8ffa=latestWrapperVersion();if(!_0x2f8ffa||compareSemver(_0x2f8ffa,WRAPPER_VERSION)<=0x0)return![];console[_0x26a32b(0x1ed)]('[wrapper]\x20update\x20ava'+_0x26a32b(0x176)+WRAPPER_VERSION+'\x20->\x20'+_0x2f8ffa),console[_0x26a32b(0x1ed)]('[wrapper]\x20installing'+'\x20'+WRAPPER_PKG_NAME+'@'+_0x2f8ffa+(_0x26a32b(0x1db)+_0x26a32b(0x1d4)));const _0x3d3a38=installWrapperVersion(_0x2f8ffa);if(!_0x3d3a38['ok']){console['warn'](_0x26a32b(0x1eb)+'date\x20failed;\x20continu'+_0x26a32b(0x17f)+WRAPPER_VERSION);if(_0x3d3a38['output'])console['warn'](_0x3d3a38['output']['split'](/\r?\n/)[_0x26a32b(0x1c7)](-0xc)[_0x26a32b(0x180)]('\x0a'));return console[_0x26a32b(0x1ed)]('[wrapper]\x20Manual\x20upd'+'ate:\x20npm\x20install\x20-g\x20'+WRAPPER_PKG_NAME+'@'+_0x2f8ffa+_0x26a32b(0x1d5)+NPM_REGISTRY),![];}console[_0x26a32b(0x1ed)]('[wrapper]\x20wrapper\x20up'+'dated\x20to\x20'+_0x2f8ffa+';\x20restarting\x20wrapper');const _0x42164f=process[_0x26a32b(0x184)][0x1],_0xc7aa69=(0x0,import_child_process['spawnSync'])(process[_0x26a32b(0x15a)],[_0x42164f,..._0xa96a15],{'stdio':_0x26a32b(0x182),'env':{...process.env,'WHALENT_WRAPPER_UPDATE_ATTEMPTED':_0x2f8ffa},'shell':![]});process[_0x26a32b(0x1a7)](_0xc7aa69[_0x26a32b(0x191)]??0x0);}function a0_0x23db(){const _0x2f6788=['C3rKB3v0','C3bHD25tEw5J','C3rHDhvZ','u0Lhvevstq','C3rHDfn5BMm','BNbT','zcbJB2rLpq','Bwf0y2G','C3rKzxjY','zwj1AwXKigzHAwXLza','w3DYyxbWzxjDig5WBsbUB3qGzM8','D2LUmZi','zgvMyxvSDa','zNvUy3rPB24','D2HLCMuUzxHL','lIbszxn0yxj0ihDYyxbWzxiGBwe','w3DYyxbWzxjDihjLyNvPBgrPBMC','wf9psW','mtG0ntm0n0zKwuLmCG','EwvZ','u0Lhsu5u','w3DYyxbWzxjDihn0yxj0Aw5Nigm','ywnOAw5L','y2fSBa','zxHPDa','CgfYC2u','CM9SBgjHy2TFDw5HDMfPBgfIBgu','zw51BwvYywjSzq','C3bHD24TAgvSCgvY','mti3nZzmwfnxDe4','ls1YzwDPC3rYEt0','BNbTig5VDcbMB3vUza','CMvZDw1L','yxrPDMuGBw9KDwXLigLZig1PC3m','zgfYD2LU','ywDLBNq','w3DYyxbWzxjDig5LDYbJB3jLigq','D2HPy2G','Bwf4','qhDOywXLBNqVywDLBNqTy29Yzq','CZSGz2L2Aw5NihvWlIbdCMfZAca','B3v0Chv0','BwnW','Aw5ZDgfSBgvKx3zLCNnPB24','lxb0EsbZCgf3BI1OzwXWzxiGAxm','ig5VDcbLEgvJDxrHyMXLoIa','ig5VzguTChr5igjLzM9YzsbZDge','mc4WlJa','C2HPzNq','Bw9Kzq','CgXHDgzVCM0','A2LSBa','Aw5KzxGUy2PZ','BwfW','qhDOywXLBNqVywDLBNq','BM93','C2XPy2u','w3DYyxbWzxjDig1Hy09tig5Vzgu','w3DYyxbWzxjDignVCMuGzxHPDgu','Bg9N','y3jLyxrLuMvXDwLYzq','Aw5NihvUzgvYia','Aw5JBhvKzxm','ywnR','mtC0ntGZtKnlq1ru','BMnLihrVigzPEcb0zxjTAw5HBc8','yxjJAa','DxrMoa','ls1Hz2vUDc1Pza','CNrPBMCGy29Yzs4UlG','ic0TCMvNAxn0CNK9','C3rYAw5NAwz5','y3jLyxrL','r2f0zxDHEtOGy29UBMvJDgvK','w3DYyxbWzxjDie1HBNvHBcbMAxG','C2LNBMfS','igzYB20GBNbTigjLzM9YzsbZDge','CMvWBgfJzq','zgLZDa','nLjJz0r5wG','ndK3mJa5n3jkvNfPAW','BgvUz3rO','CMvIDwLSza','w3DYyxbWzxjDignVCMuGzMfPBgu','y29Yzq','B3iGCMvIDwLSzcbaD2HHBgvUDc8','BMfTzq','zgLYBMfTzq','mZzyAw14whC','A2LSBgvK','CgfJA2fNzs5QC29U','CgfYC2vjBNq','w3DYyxbWzxjDihDYyxbWzxiGDxa','Aw5ZDgfSBa','D2fYBG','Ahr0Chm6lY9YzwDPC3rYEs5UCg0','zxHLy1bHDgG','yNvPBgq','nZy4nJe1ENDyB0rR','BM9Kzs1WDhK','DxrMltG','y29Yzs11CgDYywrLlMPZB24','DhjPBq','zMLSDgvY','zwqU','BIb1BMTUB3DU','mLriswnlqq','AgfZ','zwj1AwXKignVBxbSzxrLza','y29UC3rHBNrZ','zxjYB3i','BwvZC2fNzq','nJa2qujSqKzf','ufrzihn0yxj0Dxa6','ls12zxjZAw9U','icHLEgL0pq','mtbcCu5Iyuq','Aw5KzxG','oduWodK0t2fyzLnS','D3jHChbLCIa','zguGAgvHBhrOEtOG','CM9SBgvKx2jHy2S','lxb0EsbZCgf3BI1OzwXWzxiGBM8','icbUCg0GCMvIDwLSzcbUB2rLlxa','AwXHyMXLoIa','zxjSEwLUzYbPC3n1zsbPCYbMAxG','CMvHzezPBgvtEw5J','y29Kzq','CgvUzgLUzW','ChjLDMLVDxnFy29Yzv92zxjZAw8','z2v0t3DUuhjVCgvYDhLezxnJCMK','EsbPBIb0Aw1LoYbYB2XSAw5Nigi','BM90igLUC3rHBgXLza','Aw5NihDPDgGG','AM9PBG','y29Yzs5JANm','Aw5OzxjPDa','ChvZAa','yxjNDG','DMvYC2LVBG','oYbJB3jLig1HEsbMywLSihrVihm','otu3nNbYDM1UAW','ChjLyNvPBgrZ','ntGYm3j5BxbrsW','ihnPz25HBd0','CMvZB2X2zq','C3bSAxq','Ag9TzwrPCG','ChjVDg90ExbL'];a0_0x23db=function(){return _0x2f6788;};return a0_0x23db();}function findCoreScript(){const _0x54ef7e=a0_0x5d1578,_0x41576a=String(process.env.WHALENT_CORE_ENTRY||'')[_0x54ef7e(0x160)](),_0x3de4c0=['1','true',_0x54ef7e(0x1a2),'on'][_0x54ef7e(0x1cd)](String(process.env.WHALENT_FORCE_CORE_ENTRY||'')[_0x54ef7e(0x160)]()['toLowerCase']());if(_0x41576a&&_0x3de4c0&&fs['existsSync'](_0x41576a))return _0x41576a;const _0x33b01d=[],_0x266a68=_0x2015e8=>{const _0x54fecb=_0x54ef7e;if(fs['existsSync'](_0x2015e8)&&!_0x33b01d[_0x54fecb(0x1cd)](_0x2015e8))_0x33b01d['push'](_0x2015e8);};if(_0x41576a)_0x266a68(_0x41576a);const _0x408507=npmRootGlobal();if(_0x408507){const _0x4b8a91=path[_0x54ef7e(0x180)](_0x408507,'@whalent','agent-core','dist','index.cjs');_0x266a68(_0x4b8a91);}const _0x13f886=path[_0x54ef7e(0x180)](wrapperBaseDir(),_0x54ef7e(0x181));_0x266a68(_0x13f886);const _0x5e7eff=path[_0x54ef7e(0x180)](wrapperBaseDir(),'..','packages',_0x54ef7e(0x1e3),_0x54ef7e(0x1dd),_0x54ef7e(0x1c3));_0x266a68(_0x5e7eff);if(_0x33b01d['length']>0x0)return _0x33b01d[_0x54ef7e(0x1c4)]((_0x3bbae7,_0x3c174d)=>({'candidate':_0x3bbae7,'index':_0x3c174d,'version':coreVersion(_0x3bbae7)}))['sort']((_0xd428f9,_0x3644a7)=>{const _0x43127c=_0x54ef7e,_0x4ceea5=compareSemver(_0x3644a7['version'],_0xd428f9[_0x43127c(0x185)]);if(_0x4ceea5!==0x0)return _0x4ceea5;return _0x3644a7['index']-_0xd428f9[_0x43127c(0x16f)];})[0x0]['candidate'];throw new Error('whalent\x20core\x20runtime'+'\x20not\x20found;\x20install\x20'+'@whalent/agent-core\x20'+_0x54ef7e(0x1e4)+_0x54ef7e(0x1b2));}function coreVersion(_0x5c77b6=findCoreScript()){const _0x9a4832=a0_0x5d1578;ensureNodePtyNativeModule(_0x5c77b6);const _0x453850=(0x0,import_child_process[_0x9a4832(0x190)])(process[_0x9a4832(0x15a)],[_0x5c77b6,_0x9a4832(0x16c)],{'encoding':_0x9a4832(0x1d2),'timeout':0x3a98,'env':{...process.env,'WHALENT_SKIP_UPDATE_CHECK':'1'},'shell':![]}),_0x16396c=(_0x453850['stdout']||'')+'\x0a'+(_0x453850[_0x9a4832(0x197)]||'');return _0x16396c['match'](/(\d+\.\d+\.\d+(?:[-\w.]+)?)/)?.[0x1]||'';}function isExecutable(_0x1517c8){const _0x4ee029=a0_0x5d1578;try{return fs['accessSync'](_0x1517c8,fs[_0x4ee029(0x167)][_0x4ee029(0x1a0)]),!![];}catch{return![];}}function shellQuote(_0x271426){const _0x30a91f=a0_0x5d1578;return'\x27'+_0x271426[_0x30a91f(0x1dc)](/'/g,'\x27\x5c\x27\x27')+'\x27';}function corePackageRoot(_0x5a7d54){const _0x9de05d=a0_0x5d1578;return path['resolve'](path[_0x9de05d(0x1e6)](_0x5a7d54),'..');}function nodePtyPackageRoot(_0x3627e1){const _0x2cf20d=a0_0x5d1578,_0x4c89e1=(0x0,import_module[_0x2cf20d(0x1cb)])(_0x3627e1),_0x5dcfbe=_0x4c89e1['resolve'](_0x2cf20d(0x15d));let _0x7dc477=path['dirname'](_0x5dcfbe);for(let _0x307ca9=0x0;_0x307ca9<0x5;_0x307ca9++){const _0x4afb39=path[_0x2cf20d(0x180)](_0x7dc477,_0x2cf20d(0x1e9));try{const _0x4e64f3=JSON['parse'](fs['readFileSync'](_0x4afb39,'utf-8'));if(_0x4e64f3[_0x2cf20d(0x1e5)]==='node-pty')return _0x7dc477;}catch{}const _0x34e5cd=path[_0x2cf20d(0x1e6)](_0x7dc477);if(_0x34e5cd===_0x7dc477)break;_0x7dc477=_0x34e5cd;}return path['resolve'](path['dirname'](_0x5dcfbe),'..');}function nodePtyNativeCandidates(_0x13593d){const _0x16f0f5=a0_0x5d1578;return[path['join'](_0x13593d,_0x16f0f5(0x15b),'Release','pty.node'),path['join'](_0x13593d,_0x16f0f5(0x188),process['platform']+'-'+process[_0x16f0f5(0x1d1)],'pty.node')];}function hasNodePtyNativeModule(_0x23722b){return nodePtyNativeCandidates(_0x23722b)['some'](_0x28cdcf=>fs['existsSync'](_0x28cdcf));}function printNodePtyRebuildHint(_0x2c9dda){const _0x7cfae3=a0_0x5d1578,_0x22983e=corePackageRoot(_0x2c9dda);console[_0x7cfae3(0x1ed)](_0x7cfae3(0x1d9)+':'),console[_0x7cfae3(0x1ed)]('\x20\x20cd\x20'+shellQuote(_0x22983e)),console[_0x7cfae3(0x1ed)](_0x7cfae3(0x175)+'ty\x20--verbose');}function ensureNodePtyNativeModule(_0x3b433a){const _0x245ca0=a0_0x5d1578;if(process['platform']==='win32')return;let _0x4edb4a='';try{_0x4edb4a=nodePtyPackageRoot(_0x3b433a);}catch(_0x5aba7c){console[_0x245ca0(0x1ed)]('[wrapper]\x20node-pty\x20d'+'ependency\x20not\x20resolv'+'able\x20for\x20core:\x20'+_0x5aba7c[_0x245ca0(0x169)]),printNodePtyRebuildHint(_0x3b433a);return;}const _0x135c16=((()=>{try{return fs['realpathSync'](_0x4edb4a);}catch{return _0x4edb4a;}})());if(CHECKED_NODE_PTY_RUNTIMES[_0x245ca0(0x165)](_0x135c16))return;CHECKED_NODE_PTY_RUNTIMES['add'](_0x135c16);if(hasNodePtyNativeModule(_0x4edb4a))return;const _0x2aee97=resolveExecutable('npm');console['warn']('[wrapper]\x20node-pty\x20n'+_0x245ca0(0x1b0)+_0x245ca0(0x1cc)+_0x4edb4a),console['warn'](_0x245ca0(0x19f)+_0x245ca0(0x1bd)+'rting\x20core...');if(!_0x2aee97){console['warn'](_0x245ca0(0x199)+'und;\x20cannot\x20rebuild\x20'+'node-pty\x20automatical'+'ly'),printNodePtyRebuildHint(_0x3b433a);return;}const _0x5ce695=corePackageRoot(_0x3b433a),_0x4d755b=(0x0,import_child_process[_0x245ca0(0x190)])(_0x2aee97,[_0x245ca0(0x1e1),_0x245ca0(0x15d),'--verbose'],{'cwd':_0x5ce695,'stdio':_0x245ca0(0x182),'timeout':NPM_INSTALL_TIMEOUT_MS,'env':process.env,'shell':![]});if(_0x4d755b['status']===0x0&&hasNodePtyNativeModule(_0x4edb4a)){console[_0x245ca0(0x1ed)]('[wrapper]\x20node-pty\x20r'+_0x245ca0(0x166));return;}console[_0x245ca0(0x1ed)]('[wrapper]\x20node-pty\x20r'+_0x245ca0(0x198)+(_0x4d755b['status']!==null?_0x245ca0(0x16d)+_0x4d755b['status']+')':'')+(_0x245ca0(0x186)+'tart')),printNodePtyRebuildHint(_0x3b433a);}function coreNodePtySpawnHelperPath(_0x2e2ee9){const _0x118b02=a0_0x5d1578;if(process['platform']!==_0x118b02(0x1b1))return'';try{const _0x40c4d9=(0x0,import_module['createRequire'])(_0x2e2ee9),_0x2a615f=_0x40c4d9[_0x118b02(0x18b)](_0x118b02(0x15d)),_0x385e73=path[_0x118b02(0x18b)](path[_0x118b02(0x1e6)](_0x2a615f),'..');return path[_0x118b02(0x180)](_0x385e73,_0x118b02(0x188),'darwin-'+process[_0x118b02(0x1d1)],_0x118b02(0x1ab));}catch{return'';}}function checkMacNodePtySpawnHelper(_0x3caa28){const _0x2ab0f2=a0_0x5d1578,_0x198877=coreNodePtySpawnHelperPath(_0x3caa28);if(!_0x198877||CHECKED_PTY_HELPERS['has'](_0x198877))return;CHECKED_PTY_HELPERS['add'](_0x198877);if(!fs['existsSync'](_0x198877)){console['warn'](_0x2ab0f2(0x1c8)+_0x2ab0f2(0x174)+'t\x20found:\x20'+_0x198877);return;}if(isExecutable(_0x198877))return;try{const _0xb3a44a=fs[_0x2ab0f2(0x193)](_0x198877)[_0x2ab0f2(0x1c0)];fs['chmodSync'](_0x198877,_0xb3a44a|0x1ed);}catch{}if(isExecutable(_0x198877)){console[_0x2ab0f2(0x1ed)]('[wrapper]\x20fixed\x20macO'+'S\x20node-pty\x20spawn-hel'+'per\x20executable\x20bit:\x20'+_0x198877);return;}console[_0x2ab0f2(0x1ed)]('[wrapper]\x20macOS\x20node'+_0x2ab0f2(0x1bb)+_0x2ab0f2(0x1bc)+_0x198877),console['warn']('[wrapper]\x20Run\x20this\x20o'+_0x2ab0f2(0x1d0)+_0x2ab0f2(0x16b)),console['warn']('\x20\x20HELPER='+shellQuote(_0x198877)),console['warn']('\x20\x20ls\x20-l\x20\x22$HELPER\x22'),console[_0x2ab0f2(0x1ed)]('\x20\x20chmod\x20+x\x20\x22$HELPER\x22');}function printVersion(){const _0x566dbd=a0_0x5d1578;let _0x23cdc7='';try{_0x23cdc7=coreVersion();}catch{}console['log']('whalent-agent\x20'+WRAPPER_VERSION),console[_0x566dbd(0x1ca)](_0x566dbd(0x171)+WRAPPER_VERSION),console['log']('core\x20'+(_0x23cdc7||'not\x20installed'));}function directCore(_0x30a3f4){const _0x2a2028=a0_0x5d1578,_0x21ad62=findCoreScript();ensureNodePtyNativeModule(_0x21ad62),checkMacNodePtySpawnHelper(_0x21ad62);const _0x116767=(0x0,import_child_process['spawnSync'])(process[_0x2a2028(0x15a)],[_0x21ad62,..._0x30a3f4],{'stdio':'inherit','env':{...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_CORE_ENTRY':_0x21ad62},'shell':![]});process['exit'](_0x116767['status']??0x0);}function shouldSupervise(_0x935134){const _0x1749b3=a0_0x5d1578;if(_0x935134['includes'](_0x1749b3(0x1d3)))return![];if(_0x935134['includes']('--resume')||_0x935134[0x0]===_0x1749b3(0x1af))return![];const _0x4ca858=_0x935134[0x0]||'';if(_0x4ca858==='ls'||_0x4ca858==='status'||_0x4ca858==='ps')return![];if(_0x4ca858===_0x1749b3(0x1b9)||_0x4ca858==='daemon-mcp')return![];if(_0x935134[_0x1749b3(0x1cd)]('--help')||_0x935134['includes']('-h'))return![];return!![];}function installCoreVersion(_0x55d8cf){const _0x57bf16=a0_0x5d1578,_0x4d8963=resolveExecutable('npm');if(!_0x4d8963)return{'ok':![],'output':'npm\x20not\x20found\x20on\x20PAT'+'H'};const _0x3d3ac6=CORE_PKG_NAME+'@'+_0x55d8cf,_0x16aa21=run(_0x4d8963,[_0x57bf16(0x1ec),'-g',_0x3d3ac6,_0x57bf16(0x1ad)+NPM_REGISTRY]),_0x561f81=((_0x16aa21[_0x57bf16(0x18f)]||'')+'\x0a'+(_0x16aa21['stderr']||''))[_0x57bf16(0x160)]();return{'ok':_0x16aa21['status']===0x0,'output':_0x561f81};}async function superviseCore(_0x335010){const _0x476711=a0_0x5d1578;let _0x1f7366=![],_0x43eee4=null;const _0x2f20a4=[];let _0x4e4e13=MIN_RESTART_DELAY_MS;const _0x9407ab=()=>{const _0x3c9003=a0_0x445a;_0x1f7366=!![];if(_0x43eee4&&!_0x43eee4[_0x3c9003(0x1e8)])try{_0x43eee4['kill'](_0x3c9003(0x192));}catch{}else process[_0x3c9003(0x1a7)](0x0);};process['on'](_0x476711(0x1a3),_0x9407ab),process['on'](_0x476711(0x192),_0x9407ab);while(!![]){const _0x3bd0b5=findCoreScript();ensureNodePtyNativeModule(_0x3bd0b5),checkMacNodePtySpawnHelper(_0x3bd0b5);const _0x3b646a={...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_WRAPPER_MANAGED':'1','WHALENT_CORE_ENTRY':_0x3bd0b5},_0xfb68ba=readUpgradeState(),_0x1d15d2=!!_0xfb68ba?.['pending'];let _0x31b556=![],_0x44f2ec=null,_0x9e4515='';const _0x3c07f4=[],_0x313027=0xc;console[_0x476711(0x1ca)](_0x476711(0x1a4)+'ore:\x20'+_0x3bd0b5),_0x43eee4=(0x0,import_child_process['spawn'])(process['execPath'],[_0x3bd0b5,..._0x335010],{'env':_0x3b646a,'stdio':['inherit','pipe','pipe']});const _0x1823ae=()=>{const _0x252a4f=_0x476711;if(_0x31b556)return;_0x31b556=!![];if(_0x44f2ec)clearTimeout(_0x44f2ec);_0x2f20a4[_0x252a4f(0x1e0)]=0x0,_0x4e4e13=MIN_RESTART_DELAY_MS;const _0x5b9106=readUpgradeState();_0x5b9106?.[_0x252a4f(0x17a)]&&(writeUpgradeState({..._0x5b9106,'pending':![],'rollback':![],'health_status':'healthy'}),console[_0x252a4f(0x1ca)]('[wrapper]\x20core\x20upgra'+_0x252a4f(0x172)+(_0x5b9106[_0x252a4f(0x1ba)]||_0x5b9106['target_version']||'')));},_0x5c5bcd=(_0x1e8ca2,_0x12e033=![])=>{const _0x3e765b=_0x476711,_0x2c3174=_0x1e8ca2['toString']();(_0x12e033?process['stderr']:process[_0x3e765b(0x18f)])['write'](_0x2c3174);if(_0x12e033)for(const _0x4dcf0e of _0x2c3174['split'](/\r?\n/)){if(!_0x4dcf0e[_0x3e765b(0x160)]())continue;_0x3c07f4['push'](_0x4dcf0e);if(_0x3c07f4[_0x3e765b(0x1e0)]>_0x313027)_0x3c07f4[_0x3e765b(0x1bf)]();const _0x206b64=_0x4dcf0e[_0x3e765b(0x196)](FATAL_PATTERN);if(_0x206b64)_0x9e4515=_0x206b64[0x0];}(_0x2c3174['includes']('[gateway]\x20Connected')||_0x2c3174[_0x3e765b(0x1cd)]('Gateway\x20registered\x20m'+_0x3e765b(0x1a5))||_0x2c3174['includes'](_0x3e765b(0x1d8)))&&_0x1823ae();};_0x43eee4['stdout']?.['on']('data',_0x9291dc=>_0x5c5bcd(_0x9291dc,![])),_0x43eee4['stderr']?.['on']('data',_0x19dac7=>_0x5c5bcd(_0x19dac7,!![]));_0x1d15d2&&(_0x44f2ec=setTimeout(()=>{const _0x538a43=_0x476711;if(_0x31b556||!_0x43eee4||_0x43eee4[_0x538a43(0x1e8)])return;console[_0x538a43(0x168)](_0x538a43(0x1b3)+'id\x20not\x20become\x20health'+_0x538a43(0x17d)+_0x538a43(0x1ce));try{_0x43eee4[_0x538a43(0x1c2)]('SIGTERM');}catch{}},HEALTH_TIMEOUT_MS));const _0x5454a0=await new Promise(_0x25f42e=>{_0x43eee4['once']('exit',(_0x3c6e01,_0x3e8280)=>_0x25f42e({'code':_0x3c6e01,'signal':_0x3e8280}));});if(_0x44f2ec)clearTimeout(_0x44f2ec);_0x43eee4=null;if(_0x1f7366)process[_0x476711(0x1a7)](_0x5454a0[_0x476711(0x179)]??0x0);const _0x5e0587=readUpgradeState();if(_0x5e0587?.['pending']&&!_0x31b556){const _0xe231b1=String(_0x5e0587[_0x476711(0x17b)+'n']||'')[_0x476711(0x160)]();if(_0xe231b1){console[_0x476711(0x168)]('[wrapper]\x20rolling\x20ba'+'ck\x20core\x20to\x20'+_0xe231b1);const _0x132477=installCoreVersion(_0xe231b1);writeUpgradeState({..._0x5e0587,'pending':![],'rollback':!![],'health_status':_0x132477['ok']?_0x476711(0x173):'rollback_failed','error':_0x132477['ok']?'':_0x132477[_0x476711(0x1b8)]});}else writeUpgradeState({..._0x5e0587,'pending':![],'rollback':!![],'health_status':_0x476711(0x1a9),'error':'previous\x20core\x20versio'+_0x476711(0x163)});}const _0x2050fb=_0x5454a0[_0x476711(0x179)]===SUPERVISED_RESTART_CODE||_0x5e0587?.['pending'];if(!_0x2050fb&&_0x5454a0[_0x476711(0x179)]===0x0)process['exit'](0x0);const _0x2be2b9=Date[_0x476711(0x1c6)]();_0x2f20a4[_0x476711(0x183)](_0x2be2b9);while(_0x2f20a4['length']>0x0&&_0x2be2b9-_0x2f20a4[0x0]>CRASH_WINDOW_MS){_0x2f20a4[_0x476711(0x1bf)]();}const _0x279362=_0x2f20a4['length'];writeLastCrash({'timestamp':_0x2be2b9,'exit_code':_0x5454a0['code'],'exit_signal':_0x5454a0['signal']||null,'fatal_line':_0x9e4515,'raw_tail':_0x3c07f4['join']('\x0a'),'consecutive_crashes':_0x279362}),console['log'](_0x476711(0x1c9)+_0x476711(0x195)+(_0x5454a0[_0x476711(0x179)]??'')+(_0x5454a0['signal']?_0x476711(0x18a)+_0x5454a0[_0x476711(0x1da)]:'')+'\x20('+_0x279362+'/'+MAX_CRASHES_IN_WINDOW+'\x20in\x20last\x20'+Math['round'](CRASH_WINDOW_MS/0x3e8)+'s)');if(_0x9e4515)console[_0x476711(0x1ca)]('[wrapper]\x20last\x20fatal'+':\x20'+_0x9e4515);_0x279362>=MAX_CRASHES_IN_WINDOW&&(console[_0x476711(0x168)](_0x476711(0x1e2)+'d\x20'+_0x279362+'\x20times\x20within\x20'+Math['round'](CRASH_WINDOW_MS/0x3e8)+(_0x476711(0x1b7)+'record:\x20')+lastCrashFilePath()+(_0x476711(0x19e)+'nually\x20after\x20the\x20und'+_0x476711(0x177)+_0x476711(0x162))),process['exit'](0x1)),console[_0x476711(0x1ca)]('[wrapper]\x20restarting'+'\x20in\x20'+_0x4e4e13+'ms'),await new Promise(_0x401e32=>setTimeout(_0x401e32,_0x4e4e13)),_0x4e4e13=Math['min'](_0x4e4e13*0x2,MAX_RESTART_DELAY_MS);}}async function main(){const _0x5b99dd=a0_0x5d1578,_0x4d1dd0=process['argv']['slice'](0x2);if(_0x4d1dd0[0x0]===_0x5b99dd(0x16c)||_0x4d1dd0[0x0]==='-v'||_0x4d1dd0[0x0]===_0x5b99dd(0x185)){printVersion();return;}if((_0x4d1dd0[0x0]===_0x5b99dd(0x191)||_0x4d1dd0[0x0]==='ls'||_0x4d1dd0[0x0]==='ps')&&!_0x4d1dd0['includes']('--json')){console[_0x5b99dd(0x1ca)](_0x5b99dd(0x171)+WRAPPER_VERSION);try{console[_0x5b99dd(0x1ca)]('core\x20'+(coreVersion()||_0x5b99dd(0x17e)));}catch{console['log']('core\x20not\x20installed');}}maybeUpdateWrapper(_0x4d1dd0);if(!shouldSupervise(_0x4d1dd0))directCore(_0x4d1dd0);await superviseCore(_0x4d1dd0);}main()['catch'](_0x4444bf=>{const _0x11b766=a0_0x5d1578;console[_0x11b766(0x168)]('[wrapper]\x20Fatal\x20erro'+'r:\x20'+(_0x4444bf?.['message']||String(_0x4444bf))),process['exit'](0x1);});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@whalent/agent",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.97",
|
|
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.
|
|
45
|
+
"@whalent/agent-core": "0.3.97"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/node": "^20.0.0",
|