@whalent/agent 0.3.68 → 0.3.70

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- 'use strict';const a0_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();}
2
+ 'use strict';const a0_0x1906bb=a0_0x843a;(function(_0x13e196,_0xeed023){const _0xce9557=a0_0x843a,_0x5c4501=_0x13e196();while(!![]){try{const _0x590426=-parseInt(_0xce9557(0x121))/0x1+parseInt(_0xce9557(0x176))/0x2+parseInt(_0xce9557(0x137))/0x3+-parseInt(_0xce9557(0x183))/0x4+-parseInt(_0xce9557(0x151))/0x5*(-parseInt(_0xce9557(0x1a6))/0x6)+-parseInt(_0xce9557(0x189))/0x7+-parseInt(_0xce9557(0x179))/0x8*(-parseInt(_0xce9557(0x18d))/0x9);if(_0x590426===_0xeed023)break;else _0x5c4501['push'](_0x5c4501['shift']());}catch(_0x3fba7e){_0x5c4501['push'](_0x5c4501['shift']());}}}(a0_0xafaa,0x6c86a));var __create=Object['create'],__defProp=Object[a0_0x1906bb(0x199)],__getOwnPropDesc=Object[a0_0x1906bb(0x134)+a0_0x1906bb(0x1a5)],__getOwnPropNames=Object['getOwnPropertyNames'],__getProtoOf=Object[a0_0x1906bb(0x1ac)],__hasOwnProp=Object['prototype'][a0_0x1906bb(0x17d)],__copyProps=(_0x7c0d0d,_0x162a50,_0x3f3563,_0x655097)=>{const _0x268ae3=a0_0x1906bb;if(_0x162a50&&typeof _0x162a50===_0x268ae3(0x16c)||typeof _0x162a50==='function'){for(let _0x45e5d9 of __getOwnPropNames(_0x162a50))if(!__hasOwnProp['call'](_0x7c0d0d,_0x45e5d9)&&_0x45e5d9!==_0x3f3563)__defProp(_0x7c0d0d,_0x45e5d9,{'get':()=>_0x162a50[_0x45e5d9],'enumerable':!(_0x655097=__getOwnPropDesc(_0x162a50,_0x45e5d9))||_0x655097['enumerable']});}return _0x7c0d0d;},__toESM=(_0x744e54,_0x4e0ddf,_0x62ce19)=>(_0x62ce19=_0x744e54!=null?__create(__getProtoOf(_0x744e54)):{},__copyProps(_0x4e0ddf||!_0x744e54||!_0x744e54[a0_0x1906bb(0x152)]?__defProp(_0x62ce19,'default',{'value':_0x744e54,'enumerable':!![]}):_0x62ce19,_0x744e54)),import_child_process=require(a0_0x1906bb(0x19d)),fs=__toESM(require('fs'),0x1),import_module=require(a0_0x1906bb(0x164)),os=__toESM(require('os'),0x1),path=__toESM(require(a0_0x1906bb(0x178)),0x1),WRAPPER_PKG_NAME=a0_0x1906bb(0x166),CORE_PKG_NAME='@whalent/agent-core',NPM_REGISTRY=a0_0x1906bb(0x1a7)+'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(){const _0x339581=a0_0x1906bb;return path['join'](os['homedir'](),_0x339581(0x160));}function upgradeStatePath(){const _0x3b5ab3=a0_0x1906bb;return path[_0x3b5ab3(0x1a3)](configDir(),'core-upgrade.json');}function lastCrashFilePath(){const _0x5e1a74=a0_0x1906bb;return path[_0x5e1a74(0x1a3)](configDir(),_0x5e1a74(0x135));}function writeLastCrash(_0x567caa){const _0x136593=a0_0x1906bb;try{fs[_0x136593(0x184)](configDir(),{'recursive':!![]});const _0x507e57={..._0x567caa,'reported':![]};fs[_0x136593(0x19a)](lastCrashFilePath(),JSON['stringify'](_0x507e57,null,0x2),'utf-8');}catch{}}function readWrapperVersion(){const _0x525f50=a0_0x1906bb;try{const _0x49f158=JSON[_0x525f50(0x18c)](fs[_0x525f50(0x161)](path[_0x525f50(0x1a3)](wrapperBaseDir(),'..',_0x525f50(0x181)),_0x525f50(0x129)));return String(_0x49f158[_0x525f50(0x182)]||'0.0.0');}catch{return'0.0.0';}}function readUpgradeState(){const _0x2306d3=a0_0x1906bb;try{return JSON[_0x2306d3(0x18c)](fs[_0x2306d3(0x161)](upgradeStatePath(),_0x2306d3(0x129)));}catch{return null;}}function writeUpgradeState(_0x40e7a7){const _0x2974bb=a0_0x1906bb;try{fs[_0x2974bb(0x184)](configDir(),{'recursive':!![]}),fs[_0x2974bb(0x19a)](upgradeStatePath(),JSON[_0x2974bb(0x14b)]({..._0x40e7a7,'updated_at':Date[_0x2974bb(0x156)]()},null,0x2),'utf-8');}catch{}}function run(_0x287c8a,_0x20673b,_0x51d4fe=process.env){const _0x18aab4=a0_0x1906bb;return(0x0,import_child_process[_0x18aab4(0x169)])(_0x287c8a,_0x20673b,{'encoding':'utf8','timeout':NPM_INSTALL_TIMEOUT_MS,'maxBuffer':NPM_INSTALL_MAX_BUFFER,'env':_0x51d4fe,'shell':![]});}function runNpmView(_0x793a26){const _0x49453b=a0_0x1906bb,_0x4aeceb=resolveExecutable('npm');if(!_0x4aeceb)return{'status':0x7f,'stdout':'','stderr':'npm\x20not\x20found','error':new Error(_0x49453b(0x16d))};return(0x0,import_child_process[_0x49453b(0x169)])(_0x4aeceb,_0x793a26,{'encoding':'utf8','timeout':NPM_VIEW_TIMEOUT_MS,'maxBuffer':0x400*0x400,'env':process.env,'shell':![]});}function npmRootGlobal(){const _0x40216e=a0_0x1906bb,_0x376120=resolveExecutable('npm');if(!_0x376120)return'';const _0x1af8cb=run(_0x376120,['root','-g']);if(_0x1af8cb['status']!==0x0)return'';return String(_0x1af8cb['stdout']||'')[_0x40216e(0x173)]();}function compareSemver(_0xae948d,_0x660e89){const _0x39fec9=a0_0x1906bb,_0x781c9b=String(_0xae948d||'')['replace'](/^v/,'')[_0x39fec9(0x1aa)](/[.-]/)['map'](_0x4e71fb=>Number['parseInt'](_0x4e71fb,0xa)||0x0),_0x496395=String(_0x660e89||'')['replace'](/^v/,'')['split'](/[.-]/)['map'](_0x4fc671=>Number[_0x39fec9(0x162)](_0x4fc671,0xa)||0x0);for(let _0x286af1=0x0;_0x286af1<Math[_0x39fec9(0x123)](_0x781c9b[_0x39fec9(0x128)],_0x496395[_0x39fec9(0x128)],0x3);_0x286af1++){const _0x18ed4c=_0x781c9b[_0x286af1]||0x0,_0x4978d0=_0x496395[_0x286af1]||0x0;if(_0x18ed4c>_0x4978d0)return 0x1;if(_0x18ed4c<_0x4978d0)return-0x1;}return 0x0;}function resolveExecutable(_0x5d44b7){const _0x3531e5=a0_0x1906bb,_0x435ec1=process['platform']===_0x3531e5(0x142)?'where.exe':'which';try{const _0x25902c=(0x0,import_child_process['spawnSync'])(_0x435ec1,[_0x5d44b7],{'encoding':'utf8','timeout':0xbb8,'shell':![]});if(_0x25902c[_0x3531e5(0x188)]!==0x0)return'';return String(_0x25902c['stdout']||'')['split'](/\r?\n/)[_0x3531e5(0x195)](_0x22e324=>_0x22e324['trim']())[_0x3531e5(0x1a8)](Boolean)[0x0]||'';}catch{return'';}}function skipWrapperUpdateCheck(){const _0x3db588=a0_0x1906bb,_0x3b0402=String(process.env.WHALENT_SKIP_UPDATE_CHECK||process.env.WHALENT_NO_UPDATE_CHECK||process.env.WHALENT_SKIP_WRAPPER_UPDATE||'')[_0x3db588(0x173)]()['toLowerCase']();return _0x3b0402==='1'||_0x3b0402==='true'||_0x3b0402==='yes'||_0x3b0402==='on';}function latestWrapperVersion(){const _0x4ff5ab=a0_0x1906bb,_0x326b1d=runNpmView([_0x4ff5ab(0x12f),WRAPPER_PKG_NAME+_0x4ff5ab(0x12e),_0x4ff5ab(0x182),_0x4ff5ab(0x194)+NPM_REGISTRY]);if(_0x326b1d[_0x4ff5ab(0x188)]!==0x0)return'';return String(_0x326b1d[_0x4ff5ab(0x13c)]||'')[_0x4ff5ab(0x173)]()['split'](/\r?\n/)[_0x4ff5ab(0x1a8)](Boolean)['pop']()||'';}function installWrapperVersion(_0x30ade7){const _0xc5ae56=a0_0x1906bb,_0x41664c=resolveExecutable(_0xc5ae56(0x157));if(!_0x41664c)return{'ok':![],'output':_0xc5ae56(0x167)+'H'};const _0x5d4bf3=run(_0x41664c,['install','-g',WRAPPER_PKG_NAME+'@'+_0x30ade7,'--registry='+NPM_REGISTRY]),_0x586ed4=((_0x5d4bf3[_0xc5ae56(0x13c)]||'')+'\x0a'+(_0x5d4bf3['stderr']||''))[_0xc5ae56(0x173)]();return{'ok':_0x5d4bf3['status']===0x0,'output':_0x586ed4};}function maybeUpdateWrapper(_0x3e2926){const _0x459d5d=a0_0x1906bb;if(skipWrapperUpdateCheck())return![];if(process.env.WHALENT_WRAPPER_UPDATE_ATTEMPTED)return![];const _0x3f3fe5=latestWrapperVersion();if(!_0x3f3fe5||compareSemver(_0x3f3fe5,WRAPPER_VERSION)<=0x0)return![];console[_0x459d5d(0x133)](_0x459d5d(0x138)+_0x459d5d(0x158)+WRAPPER_VERSION+_0x459d5d(0x185)+_0x3f3fe5),console['warn']('[wrapper]\x20installing'+'\x20'+WRAPPER_PKG_NAME+'@'+_0x3f3fe5+('\x20from\x20npm\x20before\x20sta'+'rting\x20core...'));const _0x19fbf6=installWrapperVersion(_0x3f3fe5);if(!_0x19fbf6['ok']){console['warn'](_0x459d5d(0x132)+_0x459d5d(0x17c)+'ing\x20with\x20'+WRAPPER_VERSION);if(_0x19fbf6[_0x459d5d(0x16e)])console[_0x459d5d(0x133)](_0x19fbf6['output'][_0x459d5d(0x1aa)](/\r?\n/)['slice'](-0xc)['join']('\x0a'));return console[_0x459d5d(0x133)]('[wrapper]\x20Manual\x20upd'+_0x459d5d(0x12b)+WRAPPER_PKG_NAME+'@'+_0x3f3fe5+_0x459d5d(0x1a2)+NPM_REGISTRY),![];}console['warn']('[wrapper]\x20wrapper\x20up'+'dated\x20to\x20'+_0x3f3fe5+_0x459d5d(0x122));const _0x19bf45=process[_0x459d5d(0x190)][0x1],_0x5bc3cb=(0x0,import_child_process['spawnSync'])(process['execPath'],[_0x19bf45,..._0x3e2926],{'stdio':'inherit','env':{...process.env,'WHALENT_WRAPPER_UPDATE_ATTEMPTED':_0x3f3fe5},'shell':![]});process['exit'](_0x5bc3cb[_0x459d5d(0x188)]??0x0);}function findCoreScript(){const _0x491263=a0_0x1906bb,_0x56ae83=String(process.env.WHALENT_CORE_ENTRY||'')['trim'](),_0x3d9710=['1',_0x491263(0x143),_0x491263(0x141),'on']['includes'](String(process.env.WHALENT_FORCE_CORE_ENTRY||'')[_0x491263(0x173)]()[_0x491263(0x154)]());if(_0x56ae83&&_0x3d9710&&fs['existsSync'](_0x56ae83))return _0x56ae83;const _0x189835=[],_0x1ae78a=_0x355c14=>{const _0x49cf60=_0x491263;if(fs[_0x49cf60(0x177)](_0x355c14)&&!_0x189835['includes'](_0x355c14))_0x189835[_0x49cf60(0x131)](_0x355c14);};if(_0x56ae83)_0x1ae78a(_0x56ae83);const _0x36104a=npmRootGlobal();if(_0x36104a){const _0x5252d7=path['join'](_0x36104a,_0x491263(0x19f),'agent-core',_0x491263(0x13f),'index.cjs');_0x1ae78a(_0x5252d7);}const _0x21f6ab=path['join'](wrapperBaseDir(),_0x491263(0x14e));_0x1ae78a(_0x21f6ab);const _0x264749=path['join'](wrapperBaseDir(),'..','packages',_0x491263(0x18e),_0x491263(0x13f),_0x491263(0x14d));_0x1ae78a(_0x264749);if(_0x189835['length']>0x0)return _0x189835['map']((_0x52e84a,_0xc450b)=>({'candidate':_0x52e84a,'index':_0xc450b,'version':coreVersion(_0x52e84a)}))[_0x491263(0x171)]((_0xbf7944,_0x2fddce)=>{const _0x1001db=_0x491263,_0x3c52fd=compareSemver(_0x2fddce['version'],_0xbf7944['version']);if(_0x3c52fd!==0x0)return _0x3c52fd;return _0x2fddce['index']-_0xbf7944[_0x1001db(0x146)];})[0x0]['candidate'];throw new Error('whalent\x20core\x20runtime'+_0x491263(0x130)+'@whalent/agent-core\x20'+_0x491263(0x193)+'agent');}function coreVersion(_0x33583d=findCoreScript()){const _0xc46f86=a0_0x1906bb,_0x3c0269=(0x0,import_child_process['spawnSync'])(process[_0xc46f86(0x13b)],[_0x33583d,_0xc46f86(0x12d)],{'encoding':_0xc46f86(0x16b),'timeout':0x3a98,'env':{...process.env,'WHALENT_SKIP_UPDATE_CHECK':'1'},'shell':![]}),_0x27b91c=(_0x3c0269['stdout']||'')+'\x0a'+(_0x3c0269[_0xc46f86(0x140)]||'');return _0x27b91c['match'](/(\d+\.\d+\.\d+(?:[-\w.]+)?)/)?.[0x1]||'';}function isExecutable(_0x20d45e){const _0x3463b5=a0_0x1906bb;try{return fs[_0x3463b5(0x19e)](_0x20d45e,fs['constants']['X_OK']),!![];}catch{return![];}}function shellQuote(_0x51e98c){const _0x2954ff=a0_0x1906bb;return'\x27'+_0x51e98c['replace'](/'/g,_0x2954ff(0x14c))+'\x27';}function coreNodePtySpawnHelperPath(_0x28d545){const _0x2d68b0=a0_0x1906bb;if(process[_0x2d68b0(0x186)]!==_0x2d68b0(0x125))return'';try{const _0xb05b21=(0x0,import_module['createRequire'])(_0x28d545),_0x35bd2e=_0xb05b21[_0x2d68b0(0x168)]('node-pty'),_0x4447b6=path['resolve'](path[_0x2d68b0(0x19b)](_0x35bd2e),'..');return path['join'](_0x4447b6,_0x2d68b0(0x196),'darwin-'+process['arch'],_0x2d68b0(0x192));}catch{return'';}}function checkMacNodePtySpawnHelper(_0x2a3515){const _0x42bdaf=a0_0x1906bb,_0xb710d0=coreNodePtySpawnHelperPath(_0x2a3515);if(!_0xb710d0||CHECKED_PTY_HELPERS[_0x42bdaf(0x127)](_0xb710d0))return;CHECKED_PTY_HELPERS['add'](_0xb710d0);if(!fs[_0x42bdaf(0x177)](_0xb710d0)){console[_0x42bdaf(0x133)](_0x42bdaf(0x15b)+_0x42bdaf(0x163)+_0x42bdaf(0x124)+_0xb710d0);return;}if(isExecutable(_0xb710d0))return;try{const _0x212f58=fs[_0x42bdaf(0x15e)](_0xb710d0)['mode'];fs[_0x42bdaf(0x12c)](_0xb710d0,_0x212f58|0x1ed);}catch{}if(isExecutable(_0xb710d0)){console['warn']('[wrapper]\x20fixed\x20macO'+'S\x20node-pty\x20spawn-hel'+'per\x20executable\x20bit:\x20'+_0xb710d0);return;}console['warn']('[wrapper]\x20macOS\x20node'+'-pty\x20spawn-helper\x20is'+_0x42bdaf(0x136)+_0xb710d0),console['warn'](_0x42bdaf(0x19c)+'nce\x20to\x20fix\x20terminal/'+'PTY\x20startup:'),console[_0x42bdaf(0x133)](_0x42bdaf(0x174)+shellQuote(_0xb710d0)),console['warn'](_0x42bdaf(0x15c)),console['warn'](_0x42bdaf(0x17e));}function printVersion(){const _0x1094bc=a0_0x1906bb;let _0x29c7e3='';try{_0x29c7e3=coreVersion();}catch{}console['log'](_0x1094bc(0x15a)+WRAPPER_VERSION),console['log']('wrapper\x20'+WRAPPER_VERSION),console[_0x1094bc(0x148)]('core\x20'+(_0x29c7e3||'not\x20installed'));}function directCore(_0x4d93f2){const _0x349ae9=a0_0x1906bb,_0x59f1c7=findCoreScript();checkMacNodePtySpawnHelper(_0x59f1c7);const _0x21e40c=(0x0,import_child_process[_0x349ae9(0x169)])(process[_0x349ae9(0x13b)],[_0x59f1c7,..._0x4d93f2],{'stdio':_0x349ae9(0x1ae),'env':{...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_CORE_ENTRY':_0x59f1c7},'shell':![]});process['exit'](_0x21e40c['status']??0x0);}function shouldSupervise(_0x4056a9){const _0x2eb0be=a0_0x1906bb;if(_0x4056a9['includes'](_0x2eb0be(0x126)))return![];const _0x569f88=_0x4056a9[0x0]||'';if(_0x569f88==='ls'||_0x569f88===_0x2eb0be(0x188)||_0x569f88==='ps')return![];if(_0x569f88==='mcp'||_0x569f88==='daemon-mcp')return![];if(_0x4056a9[_0x2eb0be(0x1ab)](_0x2eb0be(0x13d))||_0x4056a9['includes']('-h'))return![];return!![];}function installCoreVersion(_0x1ae068){const _0xaa50c5=a0_0x1906bb,_0x3b1520=resolveExecutable(_0xaa50c5(0x157));if(!_0x3b1520)return{'ok':![],'output':'npm\x20not\x20found\x20on\x20PAT'+'H'};const _0x3d2cba=CORE_PKG_NAME+'@'+_0x1ae068,_0x3ea386=run(_0x3b1520,['install','-g',_0x3d2cba,_0xaa50c5(0x194)+NPM_REGISTRY]),_0x3b0339=((_0x3ea386[_0xaa50c5(0x13c)]||'')+'\x0a'+(_0x3ea386[_0xaa50c5(0x140)]||''))['trim']();return{'ok':_0x3ea386[_0xaa50c5(0x188)]===0x0,'output':_0x3b0339};}async function superviseCore(_0x498f70){const _0x36b672=a0_0x1906bb;let _0x3ba9eb=![],_0x426777=null;const _0xd5ceb1=[];let _0x257e39=MIN_RESTART_DELAY_MS;const _0x1bd293=()=>{_0x3ba9eb=!![];if(_0x426777&&!_0x426777['killed'])try{_0x426777['kill']('SIGTERM');}catch{}else process['exit'](0x0);};process['on'](_0x36b672(0x15f),_0x1bd293),process['on'](_0x36b672(0x18f),_0x1bd293);while(!![]){const _0x5b6639=findCoreScript();checkMacNodePtySpawnHelper(_0x5b6639);const _0x271d93={...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_WRAPPER_MANAGED':'1','WHALENT_CORE_ENTRY':_0x5b6639},_0x28c8d4=readUpgradeState(),_0x35b557=!!_0x28c8d4?.['pending'];let _0x107a47=![],_0x34aa8a=null,_0x35349d='';const _0x278f9d=[],_0x1c092b=0xc;console['log']('[wrapper]\x20starting\x20c'+_0x36b672(0x144)+_0x5b6639),_0x426777=(0x0,import_child_process[_0x36b672(0x1a4)])(process['execPath'],[_0x5b6639,..._0x498f70],{'env':_0x271d93,'stdio':[_0x36b672(0x1ae),_0x36b672(0x15d),_0x36b672(0x15d)]});const _0x56dc76=()=>{const _0x48dc07=_0x36b672;if(_0x107a47)return;_0x107a47=!![];if(_0x34aa8a)clearTimeout(_0x34aa8a);_0xd5ceb1['length']=0x0,_0x257e39=MIN_RESTART_DELAY_MS;const _0x271b3d=readUpgradeState();_0x271b3d?.['pending']&&(writeUpgradeState({..._0x271b3d,'pending':![],'rollback':![],'health_status':_0x48dc07(0x17a)}),console['log']('[wrapper]\x20core\x20upgra'+'de\x20healthy:\x20'+(_0x271b3d['installed_version']||_0x271b3d[_0x48dc07(0x155)]||'')));},_0x40810b=(_0x29a8de,_0x3a7165=![])=>{const _0x461bd1=_0x36b672,_0x3fad5d=_0x29a8de[_0x461bd1(0x18b)]();(_0x3a7165?process[_0x461bd1(0x140)]:process['stdout'])[_0x461bd1(0x147)](_0x3fad5d);if(_0x3a7165)for(const _0x2f1943 of _0x3fad5d['split'](/\r?\n/)){if(!_0x2f1943[_0x461bd1(0x173)]())continue;_0x278f9d[_0x461bd1(0x131)](_0x2f1943);if(_0x278f9d['length']>_0x1c092b)_0x278f9d['shift']();const _0x175df1=_0x2f1943['match'](FATAL_PATTERN);if(_0x175df1)_0x35349d=_0x175df1[0x0];}(_0x3fad5d['includes']('[gateway]\x20Connected')||_0x3fad5d['includes']('Gateway\x20registered\x20m'+'achine')||_0x3fad5d['includes']('Gateway:\x20connected'))&&_0x56dc76();};_0x426777['stdout']?.['on'](_0x36b672(0x180),_0xaa10c3=>_0x40810b(_0xaa10c3,![])),_0x426777['stderr']?.['on']('data',_0x1d1c5d=>_0x40810b(_0x1d1c5d,!![]));_0x35b557&&(_0x34aa8a=setTimeout(()=>{const _0xdf2182=_0x36b672;if(_0x107a47||!_0x426777||_0x426777['killed'])return;console[_0xdf2182(0x165)]('[wrapper]\x20new\x20core\x20d'+_0xdf2182(0x13a)+_0xdf2182(0x17f)+_0xdf2182(0x14a));try{_0x426777[_0xdf2182(0x159)](_0xdf2182(0x18f));}catch{}},HEALTH_TIMEOUT_MS));const _0x40ddec=await new Promise(_0x5829a4=>{const _0x37bf74=_0x36b672;_0x426777[_0x37bf74(0x1a9)]('exit',(_0x210dea,_0x56f567)=>_0x5829a4({'code':_0x210dea,'signal':_0x56f567}));});if(_0x34aa8a)clearTimeout(_0x34aa8a);_0x426777=null;if(_0x3ba9eb)process[_0x36b672(0x16a)](_0x40ddec[_0x36b672(0x13e)]??0x0);const _0x4b3af5=readUpgradeState();if(_0x4b3af5?.[_0x36b672(0x175)]&&!_0x107a47){const _0x5a9b22=String(_0x4b3af5['previous_core_versio'+'n']||'')['trim']();if(_0x5a9b22){console[_0x36b672(0x165)](_0x36b672(0x17b)+_0x36b672(0x197)+_0x5a9b22);const _0x3072d=installCoreVersion(_0x5a9b22);writeUpgradeState({..._0x4b3af5,'pending':![],'rollback':!![],'health_status':_0x3072d['ok']?_0x36b672(0x1ad):_0x36b672(0x16f),'error':_0x3072d['ok']?'':_0x3072d[_0x36b672(0x16e)]});}else writeUpgradeState({..._0x4b3af5,'pending':![],'rollback':!![],'health_status':'rollback_unavailable','error':_0x36b672(0x198)+_0x36b672(0x187)});}const _0x51c96f=_0x40ddec[_0x36b672(0x13e)]===SUPERVISED_RESTART_CODE||_0x4b3af5?.[_0x36b672(0x175)];if(!_0x51c96f&&_0x40ddec[_0x36b672(0x13e)]===0x0)process[_0x36b672(0x16a)](0x0);const _0x52ac8b=Date['now']();_0xd5ceb1[_0x36b672(0x131)](_0x52ac8b);while(_0xd5ceb1[_0x36b672(0x128)]>0x0&&_0x52ac8b-_0xd5ceb1[0x0]>CRASH_WINDOW_MS){_0xd5ceb1['shift']();}const _0x14fd86=_0xd5ceb1[_0x36b672(0x128)];writeLastCrash({'timestamp':_0x52ac8b,'exit_code':_0x40ddec[_0x36b672(0x13e)],'exit_signal':_0x40ddec[_0x36b672(0x18a)]||null,'fatal_line':_0x35349d,'raw_tail':_0x278f9d[_0x36b672(0x1a3)]('\x0a'),'consecutive_crashes':_0x14fd86}),console[_0x36b672(0x148)](_0x36b672(0x1a1)+_0x36b672(0x172)+(_0x40ddec['code']??'')+(_0x40ddec['signal']?'\x20signal='+_0x40ddec[_0x36b672(0x18a)]:'')+'\x20('+_0x14fd86+'/'+MAX_CRASHES_IN_WINDOW+_0x36b672(0x14f)+Math[_0x36b672(0x153)](CRASH_WINDOW_MS/0x3e8)+'s)');if(_0x35349d)console['log'](_0x36b672(0x149)+':\x20'+_0x35349d);_0x14fd86>=MAX_CRASHES_IN_WINDOW&&(console['error']('[wrapper]\x20core\x20faile'+'d\x20'+_0x14fd86+_0x36b672(0x150)+Math[_0x36b672(0x153)](CRASH_WINDOW_MS/0x3e8)+('s;\x20giving\x20up.\x20Crash\x20'+'record:\x20')+lastCrashFilePath()+(_0x36b672(0x139)+_0x36b672(0x191)+_0x36b672(0x1a0)+_0x36b672(0x170))),process['exit'](0x1)),console[_0x36b672(0x148)]('[wrapper]\x20restarting'+_0x36b672(0x145)+_0x257e39+'ms'),await new Promise(_0x43014e=>setTimeout(_0x43014e,_0x257e39)),_0x257e39=Math['min'](_0x257e39*0x2,MAX_RESTART_DELAY_MS);}}async function main(){const _0x3afddc=a0_0x1906bb,_0x4af6b2=process[_0x3afddc(0x190)]['slice'](0x2);if(_0x4af6b2[0x0]==='--version'||_0x4af6b2[0x0]==='-v'||_0x4af6b2[0x0]==='version'){printVersion();return;}if((_0x4af6b2[0x0]==='status'||_0x4af6b2[0x0]==='ls'||_0x4af6b2[0x0]==='ps')&&!_0x4af6b2[_0x3afddc(0x1ab)]('--json')){console[_0x3afddc(0x148)]('wrapper\x20'+WRAPPER_VERSION);try{console['log']('core\x20'+(coreVersion()||'not\x20installed'));}catch{console['log']('core\x20not\x20installed');}}maybeUpdateWrapper(_0x4af6b2);if(!shouldSupervise(_0x4af6b2))directCore(_0x4af6b2);await superviseCore(_0x4af6b2);}function a0_0x843a(_0x21f879,_0x3080ce){_0x21f879=_0x21f879-0x121;const _0xafaaee=a0_0xafaa();let _0x843a7=_0xafaaee[_0x21f879];if(a0_0x843a['lOUgRL']===undefined){var _0x49e311=function(_0x41e195){const _0x459059='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x7c0d0d='',_0x162a50='';for(let _0x3f3563=0x0,_0x655097,_0x45e5d9,_0x744e54=0x0;_0x45e5d9=_0x41e195['charAt'](_0x744e54++);~_0x45e5d9&&(_0x655097=_0x3f3563%0x4?_0x655097*0x40+_0x45e5d9:_0x45e5d9,_0x3f3563++%0x4)?_0x7c0d0d+=String['fromCharCode'](0xff&_0x655097>>(-0x2*_0x3f3563&0x6)):0x0){_0x45e5d9=_0x459059['indexOf'](_0x45e5d9);}for(let _0x4e0ddf=0x0,_0x62ce19=_0x7c0d0d['length'];_0x4e0ddf<_0x62ce19;_0x4e0ddf++){_0x162a50+='%'+('00'+_0x7c0d0d['charCodeAt'](_0x4e0ddf)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x162a50);};a0_0x843a['dgApKJ']=_0x49e311,a0_0x843a['gSwQFu']={},a0_0x843a['lOUgRL']=!![];}const _0x595cbc=_0xafaaee[0x0],_0x1c3dd5=_0x21f879+_0x595cbc,_0x2b57c7=a0_0x843a['gSwQFu'][_0x1c3dd5];return!_0x2b57c7?(_0x843a7=a0_0x843a['dgApKJ'](_0x843a7),a0_0x843a['gSwQFu'][_0x1c3dd5]=_0x843a7):_0x843a7=_0x2b57c7,_0x843a7;}main()[a0_0x1906bb(0x12a)](_0xf1ba3e=>{const _0x15bdae=a0_0x1906bb;console[_0x15bdae(0x165)]('[wrapper]\x20Fatal\x20erro'+'r:\x20'+(_0xf1ba3e?.['message']||String(_0xf1ba3e))),process[_0x15bdae(0x16a)](0x1);});function a0_0xafaa(){const _0x1f595f=['zxHPC3rZu3LUyW','Cgf0Aa','ndm3nJHIshLIveO','AgvHBhrOEq','w3DYyxbWzxjDihjVBgXPBMCGyMe','zgf0zsbMywLSzwq7ignVBNrPBNu','AgfZt3DUuhjVCgvYDhK','icbJAg1VzcaREcaIjeHftfbfuIi','EsbPBIb0Aw1LoYbYB2XSAw5Nigi','zgf0yq','CgfJA2fNzs5QC29U','DMvYC2LVBG','mZuZmJi5nKHbuuT1Da','BwTKAxjtEw5J','ic0+ia','CgXHDgzVCM0','BIb1BMTUB3DU','C3rHDhvZ','ndGXnZaZnNLPsK52qq','C2LNBMfS','Dg9tDhjPBMC','CgfYC2u','mtKXn0LIAK1esW','y29Yzq','u0Lhvevstq','yxjNDG','BNvHBgX5igfMDgvYihrOzsb1BMq','C3bHD24TAgvSCgvY','B3iGCMvIDwLSzcbaD2HHBgvUDc8','ls1YzwDPC3rYEt0','BwfW','ChjLyNvPBgrZ','y2SGy29Yzsb0BYa','ChjLDMLVDxmGy29Yzsb2zxjZAw8','zgvMAw5LuhjVCgvYDhK','D3jPDgvgAwXLu3LUyW','zgLYBMfTzq','w3DYyxbWzxjDifj1BIb0AgLZig8','y2HPBgrFChjVy2vZCW','ywnJzxnZu3LUyW','qhDOywXLBNq','zxjSEwLUzYbPC3n1zsbPCYbMAxG','w3DYyxbWzxjDignVCMuGzxHPDgu','ic0TCMvNAxn0CNK9','AM9PBG','C3bHD24','ChrVCG','mtHMy1jXAuK','Ahr0Chm6lY9YzwDPC3rYEs5UCg0','zMLSDgvY','B25Jzq','C3bSAxq','Aw5JBhvKzxm','z2v0uhjVDg90ExbLt2y','CM9SBgvKx2jHy2S','Aw5OzxjPDa','ntmWotKXC3jRD0HZ','oYbYzxn0yxj0Aw5NihDYyxbWzxi','Bwf4','DcbMB3vUzdOG','zgfYD2LU','ls1Hz2vUDc1Pza','AgfZ','BgvUz3rO','DxrMltG','y2f0y2G','yxrLoIbUCg0GAw5ZDgfSBcaTzYa','y2HTB2rtEw5J','ls12zxjZAw9U','qgXHDgvZDa','DMLLDW','ig5VDcbMB3vUzdSGAw5ZDgfSBca','ChvZAa','w3DYyxbWzxjDihDYyxbWzxiGDxa','D2fYBG','z2v0t3DUuhjVCgvYDhLezxnJCMK','BgfZDc1JCMfZAc5QC29U','ig5VDcbLEgvJDxrHyMXLoIa','mti3ntC0n0feBu55rG','w3DYyxbWzxjDihvWzgf0zsbHDMe','lIbszxn0yxj0ihDYyxbWzxiGBwe','AwqGBM90igjLy29TzsbOzwfSDgG','zxHLy1bHDgG','C3rKB3v0','ls1OzwXW','y29Kzq','zgLZDa','C3rKzxjY','EwvZ','D2LUmZi','Dhj1zq','B3jLoIa','igLUia','Aw5KzxG','D3jPDgu','Bg9N','w3DYyxbWzxjDigXHC3qGzMf0ywW','ywnR','C3rYAw5NAwz5','j1WNjW','Aw5KzxGUy2PZ','y29Yzs5JANm','igLUigXHC3qG','ihrPBwvZihDPDgHPBIa','otyZmJy1Bgf5ueLp','x19LC01VzhvSzq','CM91BMq','Dg9mB3DLCKnHC2u','DgfYz2v0x3zLCNnPB24','BM93','BNbT','AwXHyMXLoIa','A2LSBa','D2HHBgvUDc1Hz2vUDca','w3DYyxbWzxjDig1Hy09tig5Vzgu','icbSCYaTBcaIjeHftfbfuIi','CgLWzq','C3rHDfn5BMm','u0Lhsu5u','lNDOywXLBNqTywDLBNq','CMvHzezPBgvtEw5J','CgfYC2vjBNq','lxb0EsbZCgf3BI1OzwXWzxiGBM8','Bw9KDwXL','zxjYB3i','qhDOywXLBNqVywDLBNq','BNbTig5VDcbMB3vUzcbVBIbqqvq','CMvZB2X2zq','C3bHD25tEw5J','zxHPDa','DxrMoa','B2jQzwn0','BNbTig5VDcbMB3vUza','B3v0Chv0','CM9SBgjHy2TFzMfPBgvK','zwqU','C29YDa','zcbJB2rLpq','DhjPBq','icbiruXqrvi9','CgvUzgLUzW','nZu2nda4BgzUvLby'];a0_0xafaa=function(){return _0x1f595f;};return a0_0xafaa();}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whalent/agent",
3
- "version": "0.3.68",
3
+ "version": "0.3.70",
4
4
  "description": "Stable wrapper for Whalent Agent core runtime",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",