@whalent/agent 0.3.108 → 0.3.109

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_0x537d0c=a0_0x2b30;(function(_0x2ba68e,_0x42a7c6){const _0x4d2fe5=a0_0x2b30,_0x1944c8=_0x2ba68e();while(!![]){try{const _0x583c47=parseInt(_0x4d2fe5(0xbd))/0x1+-parseInt(_0x4d2fe5(0xeb))/0x2+-parseInt(_0x4d2fe5(0xbc))/0x3*(-parseInt(_0x4d2fe5(0xee))/0x4)+-parseInt(_0x4d2fe5(0xb9))/0x5+parseInt(_0x4d2fe5(0x90))/0x6+parseInt(_0x4d2fe5(0xf1))/0x7*(parseInt(_0x4d2fe5(0xe7))/0x8)+-parseInt(_0x4d2fe5(0xa4))/0x9;if(_0x583c47===_0x42a7c6)break;else _0x1944c8['push'](_0x1944c8['shift']());}catch(_0xdf8b64){_0x1944c8['push'](_0x1944c8['shift']());}}}(a0_0x483c,0xe92e4));var __create=Object[a0_0x537d0c(0x6f)],__defProp=Object[a0_0x537d0c(0xc8)],__getOwnPropDesc=Object['getOwnPropertyDescri'+a0_0x537d0c(0xc0)],__getOwnPropNames=Object[a0_0x537d0c(0x9f)],__getProtoOf=Object['getPrototypeOf'],__hasOwnProp=Object['prototype'][a0_0x537d0c(0xc1)],__copyProps=(_0x2ca944,_0x4ca854,_0x1cf4bc,_0x1b63d3)=>{const _0x3d2115=a0_0x537d0c;if(_0x4ca854&&typeof _0x4ca854==='object'||typeof _0x4ca854===_0x3d2115(0xb6)){for(let _0x346899 of __getOwnPropNames(_0x4ca854))if(!__hasOwnProp['call'](_0x2ca944,_0x346899)&&_0x346899!==_0x1cf4bc)__defProp(_0x2ca944,_0x346899,{'get':()=>_0x4ca854[_0x346899],'enumerable':!(_0x1b63d3=__getOwnPropDesc(_0x4ca854,_0x346899))||_0x1b63d3['enumerable']});}return _0x2ca944;},__toESM=(_0x484ec7,_0x5bd9a4,_0x7bc2a9)=>(_0x7bc2a9=_0x484ec7!=null?__create(__getProtoOf(_0x484ec7)):{},__copyProps(_0x5bd9a4||!_0x484ec7||!_0x484ec7[a0_0x537d0c(0xb8)]?__defProp(_0x7bc2a9,'default',{'value':_0x484ec7,'enumerable':!![]}):_0x7bc2a9,_0x484ec7)),import_child_process2=require('child_process'),fs=__toESM(require('fs'),0x1),import_module=require(a0_0x537d0c(0x9b)),os=__toESM(require('os'),0x1),path=__toESM(require(a0_0x537d0c(0x86)),0x1),import_child_process=require('child_process'),import_fs=require('fs'),import_path=require('path'),DEFAULT_NPM_REGISTRY='https://registry.npm'+a0_0x537d0c(0xec),CHINA_NPM_REGISTRY='https://registry.npm'+'mirror.com';function preferredNpmRegistry(){const _0x450751=normalizeRegistry(process.env.WHALENT_NPM_REGISTRY||process.env.NPM_CONFIG_REGISTRY||'');if(_0x450751)return _0x450751;return isChineseLocale()?CHINA_NPM_REGISTRY:DEFAULT_NPM_REGISTRY;}function npmRegistryArg(_0x53c269=preferredNpmRegistry()){const _0x3e8d4d=a0_0x537d0c;return _0x3e8d4d(0x6c)+(normalizeRegistry(_0x53c269)||DEFAULT_NPM_REGISTRY);}function npmInstallCommand(_0x23b6b4,_0x49cb7a=preferredNpmRegistry()){return'npm\x20install\x20-g\x20'+_0x23b6b4+'\x20'+npmRegistryArg(_0x49cb7a);}function isChineseLocale(){const _0x461ea1=a0_0x537d0c,_0x61f05d=[process.env.LC_ALL,process.env.LC_MESSAGES,process.env.LANG,process.env.LANGUAGE]['filter'](Boolean)['join']('\x20');if(/(^|[_.-])zh([_.-]|$)|chinese|china|cn\b/i[_0x461ea1(0xa3)](_0x61f05d))return!![];try{const _0x1deb60=Intl['DateTimeFormat']()['resolvedOptions']()[_0x461ea1(0x8b)]||'';return/(^|-)zh($|-)|-CN\b/i[_0x461ea1(0xa3)](_0x1deb60);}catch{return![];}}function normalizeRegistry(_0x396cbc){const _0x39ebdc=a0_0x537d0c;return String(_0x396cbc||'')[_0x39ebdc(0x8d)]()[_0x39ebdc(0xd5)](/\/+$/,'');}var INSTALL_HINT={'codex':a0_0x537d0c(0x8f)+a0_0x537d0c(0xc2),'claude':a0_0x537d0c(0xf4)+'ropic-ai/claude-code','opencode':a0_0x537d0c(0xb2)+'ode-ai','whalent':npmInstallCommand(a0_0x537d0c(0xa9))+a0_0x537d0c(0x74)};function isWindowsCmdFile(_0x394251){const _0x5e6615=a0_0x537d0c;return process[_0x5e6615(0x6a)]==='win32'&&/\.(cmd|bat)$/i['test'](_0x394251||'');}function a0_0x2b30(_0x4e4bbe,_0x28eb10){_0x4e4bbe=_0x4e4bbe-0x66;const _0x483c2e=a0_0x483c();let _0x2b304d=_0x483c2e[_0x4e4bbe];if(a0_0x2b30['mtlGaN']===undefined){var _0x353717=function(_0x4725b2){const _0x2c4dbd='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x2ca944='',_0x4ca854='';for(let _0x1cf4bc=0x0,_0x1b63d3,_0x346899,_0x484ec7=0x0;_0x346899=_0x4725b2['charAt'](_0x484ec7++);~_0x346899&&(_0x1b63d3=_0x1cf4bc%0x4?_0x1b63d3*0x40+_0x346899:_0x346899,_0x1cf4bc++%0x4)?_0x2ca944+=String['fromCharCode'](0xff&_0x1b63d3>>(-0x2*_0x1cf4bc&0x6)):0x0){_0x346899=_0x2c4dbd['indexOf'](_0x346899);}for(let _0x5bd9a4=0x0,_0x7bc2a9=_0x2ca944['length'];_0x5bd9a4<_0x7bc2a9;_0x5bd9a4++){_0x4ca854+='%'+('00'+_0x2ca944['charCodeAt'](_0x5bd9a4)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x4ca854);};a0_0x2b30['iYJMIT']=_0x353717,a0_0x2b30['OfzSbY']={},a0_0x2b30['mtlGaN']=!![];}const _0x4cfad0=_0x483c2e[0x0],_0x53b328=_0x4e4bbe+_0x4cfad0,_0x33b55d=a0_0x2b30['OfzSbY'][_0x53b328];return!_0x33b55d?(_0x2b304d=a0_0x2b30['iYJMIT'](_0x2b304d),a0_0x2b30['OfzSbY'][_0x53b328]=_0x2b304d):_0x2b304d=_0x33b55d,_0x2b304d;}function quoteCmdArg(_0x183204){const _0x34d764=a0_0x537d0c,_0x5e525a=String(_0x183204??'');if(_0x5e525a&&!/[\s"&|<>^%]/['test'](_0x5e525a))return _0x5e525a;return'\x22'+_0x5e525a[_0x34d764(0xd5)](/(["^&|<>%])/g,'^$1')+'\x22';}function a0_0x483c(){const _0x2517a7=['zgfLBw9Ulw1JCa','y2fUzgLKyxrL','w3DYyxbWzxjDignVCMuGzMfPBgu','ywDLBNq','DcbMB3vUzdOG','y29Yzq','CMvZDw1L','oeXrr1vdDq','C2XPy2u','yxjNDG','Bwf0y2G','mtq4nJCWmNDotu56zW','ANmUB3jN','zguGAgvHBhrOEtOG','nffttfPJra','ChjLyNvPBgrZ','DxrMltG','mtmWnJeXodfbzNP2yLu','C3rHDhvZ','zxHLy1bHDgG','BNbTigLUC3rHBgWGlwCGqgfUDgG','y29Kzq','C2LNBMfS','Bwf4','j1WNjW','ls1Hz2vUDc1Pza','CgXHDgzVCM0','ls12zxjZAw9U','ls1YzwDPC3rYEt0','C3bSAxq','Dg9mB3DLCKnHC2u','y3jLyxrL','zgLZDa','ic0+ia','C3bHD25tEw5J','zxjYB3i','ic0TChjLzMvYlw9UBgLUzq','Aw5ZDgfSBa','w3DYyxbWzxjDihDYyxbWzxiGDxa','D3jPDgvgAwXLu3LUyW','y3jLyxrLuMvXDwLYzq','igjLzM9YzsbZDgfYDgLUzYbJB3i','AM9PBG','DxrMoa','EwvZ','y21KlMv4zq','Bg9N','Dg9tDhjPBMC','CM91BMq','ls1Yzxn1Bwu','zgLYBMfTzq','CMvZB2X2zq','Cg9W','BNbT','Cgf0Aa','BNvHBgX5igfMDgvYihrOzsb1BMq','oYbYzxn0yxj0Aw5NihDYyxbWzxi','Aw5KzxG','zgf0zwqGDg8G','Bg9JywXL','zw5KC1DPDgG','DhjPBq','zxjSEwLUzYbPC3n1zsbPCYbMAxG','BNbTigLUC3rHBgWGlwCGqg9Wzw4','mJK4nJKZoeL6y0rQsa','y29Yzsa','BM9Kzq','CgvYigv4zwn1DgfIBguGyML0oIa','Aw5KzxGUy2PZ','CM9SBgvKx2jHy2S','zMLSDgvY','ywnR','C3rKzxjY','CgfJA2fNzs5QC29U','D3jHChbLCIa','Bw9KDwXL','Ag9TzwrPCG','CM9SBgjHy2TFzMfPBgvK','u0Lhsu5u','z2v0t3DUuhjVCgvYDhLoyw1LCW','BwLU','BwTKAxjtEw5J','AgfZ','DgvZDa','mtiWntG2mZjeENngBhK','D2HPy2G','CgLWzq','w3DYyxbWzxjDihjVBgXPBMCGyMe','lMnTza','qhDOywXLBNqVywDLBNq','r2f0zxDHEtOGy29UBMvJDgvK','BwnW','zxHPDa','zxHPC3rZu3LUyW','CM9VDa','y2SGy29Yzsb0BYa','zgfYD2LUlq','B25Jzq','BNbTigLUC3rHBgWGlwCGB3bLBMm','CZSGz2L2Aw5NihvWlIbdCMfZAca','BM90igLUC3rHBgXLza','zxHL','zNvUy3rPB24','DMvYC2LVBG','x19LC01VzhvSzq','mJC3nJqWmfvdsu12rW','BNbTig5VDcbMB3vUzcbVBIbqqvq','BwfW','mZuWnZuZnhz3rLfkzq','nJa3mdnJBNHpvMW','Dhj1zq','BNbTig5VDcbMB3vUza','ChrVCG','AgfZt3DUuhjVCgvYDhK','ywKVy29KzxG','lNDOywXLBNqTywDLBNq','w3DYyxbWzxjDig1Hy09tig5Vzgu','Aw5OzxjPDa','Aw5JBhvKzxm','w3DYyxbWzxjDiezHDgfSigvYCM8','zgvMAw5LuhjVCgvYDhK','DhLWzq','CgvUzgLUzW','zgf0yq','BM93','y29YzsbUB3qGAw5ZDgfSBgvK','Aw5ZDgfSBgvKx3zLCNnPB24','wf9psW','w3DYyxbWzxjDihvWzgf0zsbHDMe','zgfYD2LU','w3DYyxbWzxjDignVCMuGDxbNCMe','D2fYBG','w3DYyxbWzxjDifj1BIb0AgLZig8','CMvWBgfJzq','C29YDa','CJOG','C3rKB3v0','ihrPBwvZihDPDgHPBIa','Bw9Kzq','ls1QC29U','mc4WlJa','y2f0y2G','BgvUz3rO','w3DYyxbWzxjDig5LDYbJB3jLigq'];a0_0x483c=function(){return _0x2517a7;};return a0_0x483c();}function cmdFallbackArgs(_0xd7f7af,_0x5a0565){return['/d','/s','/c',[quoteCmdArg(_0xd7f7af),..._0x5a0565['map'](quoteCmdArg)]['join']('\x20')];}function resolveExecutablePath(_0x284f37){const _0x55983b=a0_0x537d0c;if(!_0x284f37)return null;if(_0x284f37[_0x55983b(0xc6)]('/')||_0x284f37['includes']('\x5c')||/\.[A-Za-z0-9]{1,5}$/['test'](_0x284f37))return(0x0,import_fs['existsSync'])(_0x284f37)?_0x284f37:_0x284f37;const _0x1a0c90=process[_0x55983b(0x6a)]==='win32',_0x244526=_0x1a0c90?'where.exe':_0x55983b(0xa5);try{const _0x34b364=(0x0,import_child_process[_0x55983b(0x72)])(_0x244526,[_0x284f37],{'encoding':_0x55983b(0xf0),'timeout':0xbb8,'shell':![]});if(_0x34b364['status']===0x0){const _0x3ad043=(_0x34b364['stdout']||'')['trim']()[_0x55983b(0x6d)](/\r?\n/)[_0x55983b(0x96)](Boolean);if(_0x3ad043[_0x55983b(0xde)]===0x0)return null;if(_0x1a0c90)for(const _0x19fc2e of['.exe',_0x55983b(0xa8),'.bat','.ps1']){const _0x1bf397=_0x3ad043['find'](_0x2e027b=>_0x2e027b['toLowerCase']()[_0x55983b(0x8c)](_0x19fc2e));if(_0x1bf397)return _0x1bf397;}return _0x3ad043[0x0]||null;}}catch{}return null;}function unwrapWindowsCmdShim(_0x1cf2b3){const _0x32ec6c=a0_0x537d0c;if(process['platform']!=='win32')return null;if(!/\.(cmd|bat)$/i['test'](_0x1cf2b3))return null;let _0x34610c;try{_0x34610c=(0x0,import_fs['readFileSync'])(_0x1cf2b3,'utf-8');}catch{return null;}const _0xba903f=_0x34610c['match'](/"(%~?dp0%?)[\\/]+([^"]+\.(?:js|cjs|mjs))"/i);if(_0xba903f){const _0x5e8dc6=(0x0,import_path['resolve'])((0x0,import_path['dirname'])(_0x1cf2b3),_0xba903f[0x2]);if((0x0,import_fs[_0x32ec6c(0xad)])(_0x5e8dc6))return{'type':'node','path':_0x5e8dc6};}const _0x44c2aa=_0x34610c[_0x32ec6c(0xea)](/"(%~?dp0%?)[\\/]+([^"]+\.exe)"/i);if(_0x44c2aa){const _0x4e71ca=(0x0,import_path[_0x32ec6c(0x83)])((0x0,import_path[_0x32ec6c(0x82)])(_0x1cf2b3),_0x44c2aa[0x2]);if((0x0,import_fs[_0x32ec6c(0xad)])(_0x4e71ca))return{'type':'exe','path':_0x4e71ca};}return null;}function safeSpawnSync(_0x10ef62,_0x2959d8,_0x4a60d3={}){const _0x104ae5=a0_0x537d0c,_0xcb6048=unwrapWindowsCmdShim(_0x10ef62);if(_0xcb6048?.[_0x104ae5(0xc9)]===_0x104ae5(0x92))return(0x0,import_child_process[_0x104ae5(0x72)])(process[_0x104ae5(0xf3)],[_0xcb6048[_0x104ae5(0x86)],..._0x2959d8],_0x4a60d3);if(_0xcb6048?.[_0x104ae5(0xc9)]===_0x104ae5(0xb5))return(0x0,import_child_process[_0x104ae5(0x72)])(_0xcb6048[_0x104ae5(0x86)],_0x2959d8,_0x4a60d3);if(isWindowsCmdFile(_0x10ef62))return(0x0,import_child_process['spawnSync'])(process.env.ComSpec||_0x104ae5(0x7d),cmdFallbackArgs(_0x10ef62,_0x2959d8),_0x4a60d3);return(0x0,import_child_process['spawnSync'])(_0x10ef62,_0x2959d8,_0x4a60d3);}var WRAPPER_PKG_NAME=a0_0x537d0c(0xa9),CORE_PKG_NAME='@whalent/agent-core',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 _0x1b3dec=a0_0x537d0c;return path[_0x1b3dec(0x7a)](os[_0x1b3dec(0x9c)](),_0x1b3dec(0xc3));}function upgradeStatePath(){const _0x147ca1=a0_0x537d0c;return path[_0x147ca1(0x7a)](configDir(),'core-upgrade.json');}function lastCrashFilePath(){const _0x583c91=a0_0x537d0c;return path[_0x583c91(0x7a)](configDir(),'last-crash.json');}function writeLastCrash(_0x596deb){const _0x469ae9=a0_0x537d0c;try{fs[_0x469ae9(0xa1)](configDir(),{'recursive':!![]});const _0x2397da={..._0x596deb,'reported':![]};fs['writeFileSync'](lastCrashFilePath(),JSON['stringify'](_0x2397da,null,0x2),'utf-8');}catch{}}function readWrapperVersion(){const _0x1110ab=a0_0x537d0c;try{const _0x5d5701=JSON['parse'](fs['readFileSync'](path['join'](wrapperBaseDir(),'..',_0x1110ab(0x99)),'utf-8'));return String(_0x5d5701[_0x1110ab(0xb7)]||'0.0.0');}catch{return _0x1110ab(0xdc);}}function readUpgradeState(){const _0x2ca14e=a0_0x537d0c;try{return JSON['parse'](fs['readFileSync'](upgradeStatePath(),_0x2ca14e(0xf0)));}catch{return null;}}function writeUpgradeState(_0x5c8bcb){const _0x67444=a0_0x537d0c;try{fs[_0x67444(0xa1)](configDir(),{'recursive':!![]}),fs[_0x67444(0x77)](upgradeStatePath(),JSON['stringify']({..._0x5c8bcb,'updated_at':Date[_0x67444(0xcc)]()},null,0x2),'utf-8');}catch{}}function run(_0x56ccf0,_0x142902,_0x61b859=process.env){return safeSpawnSync(_0x56ccf0,_0x142902,{'encoding':'utf8','timeout':NPM_INSTALL_TIMEOUT_MS,'maxBuffer':NPM_INSTALL_MAX_BUFFER,'env':_0x61b859,'shell':![]});}function runNpmView(_0xbf0e53){const _0x5f24c8=a0_0x537d0c,_0x3b3a79=resolveExecutablePath(_0x5f24c8(0x85));if(!_0x3b3a79)return{'status':0x7f,'stdout':'','stderr':_0x5f24c8(0xbf),'error':new Error(_0x5f24c8(0xbf))};return safeSpawnSync(_0x3b3a79,_0xbf0e53,{'encoding':'utf8','timeout':NPM_VIEW_TIMEOUT_MS,'maxBuffer':0x400*0x400,'env':process.env,'shell':![]});}function npmRootGlobal(){const _0x4af95e=a0_0x537d0c,_0x444843=resolveExecutablePath(_0x4af95e(0x85));if(!_0x444843)return'';const _0x4273c9=run(_0x444843,[_0x4af95e(0xae),'-g']);if(_0x4273c9['status']!==0x0)return'';return String(_0x4273c9[_0x4af95e(0xd8)]||'')[_0x4af95e(0x8d)]();}function compareSemver(_0xc98c5e,_0x290bc7){const _0x330aa3=a0_0x537d0c,_0x3e5b91=String(_0xc98c5e||'')[_0x330aa3(0xd5)](/^v/,'')['split'](/[.-]/)[_0x330aa3(0xbb)](_0x3b92c2=>Number['parseInt'](_0x3b92c2,0xa)||0x0),_0x43cf55=String(_0x290bc7||'')[_0x330aa3(0xd5)](/^v/,'')['split'](/[.-]/)['map'](_0xbc796c=>Number['parseInt'](_0xbc796c,0xa)||0x0);for(let _0x3c2373=0x0;_0x3c2373<Math[_0x330aa3(0x67)](_0x3e5b91['length'],_0x43cf55['length'],0x3);_0x3c2373++){const _0x3a3a68=_0x3e5b91[_0x3c2373]||0x0,_0x2bb237=_0x43cf55[_0x3c2373]||0x0;if(_0x3a3a68>_0x2bb237)return 0x1;if(_0x3a3a68<_0x2bb237)return-0x1;}return 0x0;}function skipWrapperUpdateCheck(){const _0x5a9790=a0_0x537d0c,_0x561888=String(process.env.WHALENT_SKIP_UPDATE_CHECK||process.env.WHALENT_NO_UPDATE_CHECK||process.env.WHALENT_SKIP_WRAPPER_UPDATE||'')['trim']()[_0x5a9790(0x6e)]();return _0x561888==='1'||_0x561888===_0x5a9790(0xbe)||_0x561888===_0x5a9790(0x7c)||_0x561888==='on';}function latestWrapperVersion(){const _0x2f11b2=a0_0x537d0c,_0x14ca83=runNpmView(['view',WRAPPER_PKG_NAME+'@latest','version',npmRegistryArg()]);if(_0x14ca83['status']!==0x0)return'';return String(_0x14ca83[_0x2f11b2(0xd8)]||'')[_0x2f11b2(0x8d)]()[_0x2f11b2(0x6d)](/\r?\n/)['filter'](Boolean)[_0x2f11b2(0x84)]()||'';}function installWrapperVersion(_0xeb4942){const _0xd2239f=a0_0x537d0c,_0x1d2b94=resolveExecutablePath(_0xd2239f(0x85));if(!_0x1d2b94)return{'ok':![],'output':_0xd2239f(0xba)+'H'};const _0x2c47aa=run(_0x1d2b94,[_0xd2239f(0x75),'-g',WRAPPER_PKG_NAME+'@'+_0xeb4942,npmRegistryArg()]),_0x39ae9c=((_0x2c47aa[_0xd2239f(0xd8)]||'')+'\x0a'+(_0x2c47aa[_0xd2239f(0x98)]||''))[_0xd2239f(0x8d)]();return{'ok':_0x2c47aa['status']===0x0,'output':_0x39ae9c};}function maybeUpdateWrapper(_0x358297){const _0x53afe6=a0_0x537d0c;if(skipWrapperUpdateCheck())return![];if(process.env.WHALENT_WRAPPER_UPDATE_ATTEMPTED)return![];const _0xe8bb83=latestWrapperVersion();if(!_0xe8bb83||compareSemver(_0xe8bb83,WRAPPER_VERSION)<=0x0)return![];const _0x340953=preferredNpmRegistry();console['warn'](_0x53afe6(0xd0)+'ilable:\x20'+WRAPPER_VERSION+_0x53afe6(0x71)+_0xe8bb83),console[_0x53afe6(0xd3)]('[wrapper]\x20installing'+'\x20'+WRAPPER_PKG_NAME+'@'+_0xe8bb83+'\x20from\x20'+_0x340953+(_0x53afe6(0x79)+'e...'));const _0x560ea9=installWrapperVersion(_0xe8bb83);if(!_0x560ea9['ok']){console['warn'](_0x53afe6(0x76)+'date\x20failed;\x20continu'+'ing\x20with\x20'+WRAPPER_VERSION);if(_0x560ea9['output'])console['warn'](_0x560ea9['output']['split'](/\r?\n/)[_0x53afe6(0xe8)](-0xc)[_0x53afe6(0x7a)]('\x0a'));return console[_0x53afe6(0xd3)]('[wrapper]\x20Manual\x20upd'+'ate:\x20'+npmInstallCommand(WRAPPER_PKG_NAME+'@'+_0xe8bb83,_0x340953)),![];}console[_0x53afe6(0xd3)](_0x53afe6(0x76)+_0x53afe6(0x8a)+_0xe8bb83+_0x53afe6(0x88));const _0x52cdea=process[_0x53afe6(0xe9)][0x1],_0x303741=(0x0,import_child_process2['spawnSync'])(process[_0x53afe6(0xf3)],[_0x52cdea,..._0x358297],{'stdio':'inherit','env':{...process.env,'WHALENT_WRAPPER_UPDATE_ATTEMPTED':_0xe8bb83},'shell':![]});process[_0x53afe6(0xac)](_0x303741['status']??0x0);}function findCoreScript(){const _0x13d81b=a0_0x537d0c,_0x5969d8=String(process.env.WHALENT_CORE_ENTRY||'')['trim'](),_0x542b19=['1',_0x13d81b(0xbe),'yes','on']['includes'](String(process.env.WHALENT_FORCE_CORE_ENTRY||'')['trim']()['toLowerCase']());if(_0x5969d8&&_0x542b19&&fs[_0x13d81b(0xad)](_0x5969d8))return _0x5969d8;const _0xdda784=[],_0x4b0750=_0x6fe9b=>{const _0x42a687=_0x13d81b;if(fs['existsSync'](_0x6fe9b)&&!_0xdda784[_0x42a687(0xc6)](_0x6fe9b))_0xdda784['push'](_0x6fe9b);};if(_0x5969d8)_0x4b0750(_0x5969d8);const _0x41f78f=npmRootGlobal();if(_0x41f78f){const _0x40835f=path[_0x13d81b(0x7a)](_0x41f78f,'@whalent','agent-core',_0x13d81b(0x70),_0x13d81b(0x94));_0x4b0750(_0x40835f);}const _0x4f9107=path['join'](wrapperBaseDir(),'core.cjs');_0x4b0750(_0x4f9107);const _0x4259c1=path[_0x13d81b(0x7a)](wrapperBaseDir(),'..','packages',_0x13d81b(0xe5),_0x13d81b(0x70),'index.cjs');_0x4b0750(_0x4259c1);if(_0xdda784['length']>0x0)return _0xdda784['map']((_0xc7558b,_0x4cbf79)=>({'candidate':_0xc7558b,'index':_0x4cbf79,'version':coreVersion(_0xc7558b)}))[_0x13d81b(0xd6)]((_0x1c3a07,_0x1136d6)=>{const _0x4cbfed=_0x13d81b,_0x35435c=compareSemver(_0x1136d6['version'],_0x1c3a07[_0x4cbfed(0xb7)]);if(_0x35435c!==0x0)return _0x35435c;return _0x1136d6[_0x4cbfed(0x89)]-_0x1c3a07[_0x4cbfed(0x89)];})[0x0][_0x13d81b(0xe1)];throw new Error('whalent\x20core\x20runtime'+'\x20not\x20found;\x20install\x20'+'@whalent/agent-core\x20'+'or\x20rebuild\x20@whalent/'+_0x13d81b(0xe3));}function coreVersion(_0x119a69=findCoreScript()){const _0x5751fb=a0_0x537d0c,_0x433d6e=(0x0,import_child_process2[_0x5751fb(0x72)])(process['execPath'],[_0x119a69,'--version'],{'encoding':_0x5751fb(0x7b),'timeout':0x3a98,'env':{...process.env,'WHALENT_SKIP_UPDATE_CHECK':'1'},'shell':![]}),_0x3c3296=(_0x433d6e[_0x5751fb(0xd8)]||'')+'\x0a'+(_0x433d6e[_0x5751fb(0x98)]||'');return _0x3c3296[_0x5751fb(0xea)](/(\d+\.\d+\.\d+(?:[-\w.]+)?)/)?.[0x1]||'';}function isExecutable(_0x60fd62){const _0x23694c=a0_0x537d0c;try{return fs['accessSync'](_0x60fd62,fs['constants'][_0x23694c(0xcf)]),!![];}catch{return![];}}function shellQuote(_0x1030f8){const _0x6977f6=a0_0x537d0c;return'\x27'+_0x1030f8['replace'](/'/g,_0x6977f6(0x68))+'\x27';}function coreNodePtySpawnHelperPath(_0x40a822){const _0x5d4a8d=a0_0x537d0c;if(process['platform']!==_0x5d4a8d(0xd1))return'';try{const _0x22ed55=(0x0,import_module[_0x5d4a8d(0x78)])(_0x40a822),_0x369f8e=_0x22ed55['resolve']('node-pty'),_0x248e66=path['resolve'](path['dirname'](_0x369f8e),'..');return path[_0x5d4a8d(0x7a)](_0x248e66,_0x5d4a8d(0xef),_0x5d4a8d(0xb0)+process['arch'],'spawn-helper');}catch{return'';}}function checkMacNodePtySpawnHelper(_0x1b8348){const _0x50b48a=a0_0x537d0c,_0x486a38=coreNodePtySpawnHelperPath(_0x1b8348);if(!_0x486a38||CHECKED_PTY_HELPERS[_0x50b48a(0xa2)](_0x486a38))return;CHECKED_PTY_HELPERS['add'](_0x486a38);if(!fs[_0x50b48a(0xad)](_0x486a38)){console[_0x50b48a(0xd3)](_0x50b48a(0xc4)+'-pty\x20spawn-helper\x20no'+_0x50b48a(0xe4)+_0x486a38);return;}if(isExecutable(_0x486a38))return;try{const _0x3185a6=fs['statSync'](_0x486a38)[_0x50b48a(0xda)];fs['chmodSync'](_0x486a38,_0x3185a6|0x1ed);}catch{}if(isExecutable(_0x486a38)){console['warn']('[wrapper]\x20fixed\x20macO'+'S\x20node-pty\x20spawn-hel'+_0x50b48a(0x93)+_0x486a38);return;}console[_0x50b48a(0xd3)](_0x50b48a(0xc4)+'-pty\x20spawn-helper\x20is'+'\x20not\x20executable:\x20'+_0x486a38),console['warn'](_0x50b48a(0xd4)+'nce\x20to\x20fix\x20terminal/'+'PTY\x20startup:'),console['warn']('\x20\x20HELPER='+shellQuote(_0x486a38)),console[_0x50b48a(0xd3)]('\x20\x20ls\x20-l\x20\x22$HELPER\x22'),console[_0x50b48a(0xd3)]('\x20\x20chmod\x20+x\x20\x22$HELPER\x22');}function printVersion(){const _0xcfa58e=a0_0x537d0c;let _0x7de323='';try{_0x7de323=coreVersion();}catch{}console[_0xcfa58e(0x7e)]('whalent-agent\x20'+WRAPPER_VERSION),console['log'](_0xcfa58e(0x9a)+WRAPPER_VERSION),console[_0xcfa58e(0x7e)](_0xcfa58e(0x91)+(_0x7de323||_0xcfa58e(0xb4)));}function directCore(_0x22c08e){const _0x2591e7=a0_0x537d0c,_0x4d573f=findCoreScript();checkMacNodePtySpawnHelper(_0x4d573f);const _0x564cee=(0x0,import_child_process2[_0x2591e7(0x72)])(process[_0x2591e7(0xf3)],[_0x4d573f,..._0x22c08e],{'stdio':'inherit','env':{...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_CORE_ENTRY':_0x4d573f},'shell':![]});process['exit'](_0x564cee['status']??0x0);}function shouldSupervise(_0x3ec31f){const _0x2ad172=a0_0x537d0c;if(_0x3ec31f[_0x2ad172(0xc6)](_0x2ad172(0x69)))return![];if(_0x3ec31f['includes'](_0x2ad172(0x81))||_0x3ec31f[0x0]===_0x2ad172(0xe6))return![];const _0x37a09a=_0x3ec31f[0x0]||'';if(_0x37a09a==='ls'||_0x37a09a===_0x2ad172(0xf2)||_0x37a09a==='ps')return![];if(_0x37a09a===_0x2ad172(0xab)||_0x37a09a===_0x2ad172(0xe0))return![];if(_0x3ec31f[_0x2ad172(0xc6)]('--help')||_0x3ec31f[_0x2ad172(0xc6)]('-h'))return![];return!![];}function installCoreVersion(_0x1c7b74){const _0x411fa7=a0_0x537d0c,_0x425f40=resolveExecutablePath('npm');if(!_0x425f40)return{'ok':![],'output':_0x411fa7(0xba)+'H'};const _0x38074d=CORE_PKG_NAME+'@'+_0x1c7b74,_0x129c0e=run(_0x425f40,['install','-g',_0x38074d,npmRegistryArg()]),_0x1b946e=((_0x129c0e[_0x411fa7(0xd8)]||'')+'\x0a'+(_0x129c0e['stderr']||''))['trim']();return{'ok':_0x129c0e[_0x411fa7(0xf2)]===0x0,'output':_0x1b946e};}async function superviseCore(_0x5d811b){const _0x44a72a=a0_0x537d0c;let _0x266794=![],_0x109be5=null;const _0x2373dd=[];let _0x531193=MIN_RESTART_DELAY_MS;const _0x7d0a17=()=>{_0x266794=!![];if(_0x109be5&&!_0x109be5['killed'])try{_0x109be5['kill']('SIGTERM');}catch{}else process['exit'](0x0);};process['on'](_0x44a72a(0x9e),_0x7d0a17),process['on']('SIGTERM',_0x7d0a17);while(!![]){const _0x5f622e=findCoreScript();checkMacNodePtySpawnHelper(_0x5f622e);const _0x444b33={...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_WRAPPER_MANAGED':'1','WHALENT_CORE_ENTRY':_0x5f622e},_0x172e20=readUpgradeState(),_0x4453d4=!!_0x172e20?.[_0x44a72a(0xca)];let _0x233fe2=![],_0x1b0077=null,_0x5e4e85='';const _0x2ed2c3=[],_0x470bfe=0xc;console[_0x44a72a(0x7e)]('[wrapper]\x20starting\x20c'+'ore:\x20'+_0x5f622e),_0x109be5=(0x0,import_child_process2['spawn'])(process[_0x44a72a(0xf3)],[_0x5f622e,..._0x5d811b],{'env':_0x444b33,'stdio':[_0x44a72a(0xc5),_0x44a72a(0xa6),'pipe']});const _0x35ef21=()=>{const _0x3c72ed=_0x44a72a;if(_0x233fe2)return;_0x233fe2=!![];if(_0x1b0077)clearTimeout(_0x1b0077);_0x2373dd[_0x3c72ed(0xde)]=0x0,_0x531193=MIN_RESTART_DELAY_MS;const _0x1dc9e9=readUpgradeState();_0x1dc9e9?.['pending']&&(writeUpgradeState({..._0x1dc9e9,'pending':![],'rollback':![],'health_status':'healthy'}),console['log'](_0x3c72ed(0xd2)+_0x3c72ed(0xed)+(_0x1dc9e9[_0x3c72ed(0xce)]||_0x1dc9e9['target_version']||'')));},_0x210d26=(_0x461aeb,_0x41ea77=![])=>{const _0x35c81f=_0x44a72a,_0x1cb184=_0x461aeb[_0x35c81f(0x7f)]();(_0x41ea77?process['stderr']:process[_0x35c81f(0xd8)])['write'](_0x1cb184);if(_0x41ea77)for(const _0x5aeece of _0x1cb184['split'](/\r?\n/)){if(!_0x5aeece[_0x35c81f(0x8d)]())continue;_0x2ed2c3['push'](_0x5aeece);if(_0x2ed2c3[_0x35c81f(0xde)]>_0x470bfe)_0x2ed2c3['shift']();const _0x255e7b=_0x5aeece[_0x35c81f(0xea)](FATAL_PATTERN);if(_0x255e7b)_0x5e4e85=_0x255e7b[0x0];}(_0x1cb184[_0x35c81f(0xc6)]('[gateway]\x20Connected')||_0x1cb184['includes']('Gateway\x20registered\x20m'+'achine')||_0x1cb184[_0x35c81f(0xc6)](_0x35c81f(0xaa)))&&_0x35ef21();};_0x109be5['stdout']?.['on'](_0x44a72a(0xcb),_0x27b984=>_0x210d26(_0x27b984,![])),_0x109be5[_0x44a72a(0x98)]?.['on']('data',_0x515bb7=>_0x210d26(_0x515bb7,!![]));_0x4453d4&&(_0x1b0077=setTimeout(()=>{const _0x152b23=_0x44a72a;if(_0x233fe2||!_0x109be5||_0x109be5['killed'])return;console[_0x152b23(0x73)](_0x152b23(0xdf)+'id\x20not\x20become\x20health'+'y\x20in\x20time;\x20rolling\x20b'+_0x152b23(0x97));try{_0x109be5['kill']('SIGTERM');}catch{}},HEALTH_TIMEOUT_MS));const _0x2be80e=await new Promise(_0x3556b9=>{const _0x1fb737=_0x44a72a;_0x109be5[_0x1fb737(0xb1)](_0x1fb737(0xac),(_0x48e0c0,_0x4ceabe)=>_0x3556b9({'code':_0x48e0c0,'signal':_0x4ceabe}));});if(_0x1b0077)clearTimeout(_0x1b0077);_0x109be5=null;if(_0x266794)process[_0x44a72a(0xac)](_0x2be80e['code']??0x0);const _0x8efe23=readUpgradeState();if(_0x8efe23?.[_0x44a72a(0xca)]&&!_0x233fe2){const _0x4c537e=String(_0x8efe23['previous_core_versio'+'n']||'')['trim']();if(_0x4c537e){console['error'](_0x44a72a(0xa7)+_0x44a72a(0xaf)+_0x4c537e);const _0x425601=installCoreVersion(_0x4c537e);writeUpgradeState({..._0x8efe23,'pending':![],'rollback':!![],'health_status':_0x425601['ok']?_0x44a72a(0x95):_0x44a72a(0x9d),'error':_0x425601['ok']?'':_0x425601['output']});}else writeUpgradeState({..._0x8efe23,'pending':![],'rollback':!![],'health_status':'rollback_unavailable','error':'previous\x20core\x20versio'+'n\x20unknown'});}const _0x11ea6f=_0x2be80e[_0x44a72a(0xf5)]===SUPERVISED_RESTART_CODE||_0x8efe23?.[_0x44a72a(0xca)];if(!_0x11ea6f&&_0x2be80e[_0x44a72a(0xf5)]===0x0)process['exit'](0x0);const _0x72194c=Date[_0x44a72a(0xcc)]();_0x2373dd['push'](_0x72194c);while(_0x2373dd['length']>0x0&&_0x72194c-_0x2373dd[0x0]>CRASH_WINDOW_MS){_0x2373dd['shift']();}const _0x48ac0f=_0x2373dd[_0x44a72a(0xde)];writeLastCrash({'timestamp':_0x72194c,'exit_code':_0x2be80e['code'],'exit_signal':_0x2be80e[_0x44a72a(0x66)]||null,'fatal_line':_0x5e4e85,'raw_tail':_0x2ed2c3[_0x44a72a(0x7a)]('\x0a'),'consecutive_crashes':_0x48ac0f}),console['log']('[wrapper]\x20core\x20exite'+'d\x20code='+(_0x2be80e[_0x44a72a(0xf5)]??'')+(_0x2be80e[_0x44a72a(0x66)]?'\x20signal='+_0x2be80e[_0x44a72a(0x66)]:'')+'\x20('+_0x48ac0f+'/'+MAX_CRASHES_IN_WINDOW+'\x20in\x20last\x20'+Math['round'](CRASH_WINDOW_MS/0x3e8)+'s)');if(_0x5e4e85)console[_0x44a72a(0x7e)]('[wrapper]\x20last\x20fatal'+':\x20'+_0x5e4e85);_0x48ac0f>=MAX_CRASHES_IN_WINDOW&&(console['error'](_0x44a72a(0xe2)+'d\x20'+_0x48ac0f+_0x44a72a(0xd9)+Math[_0x44a72a(0x80)](CRASH_WINDOW_MS/0x3e8)+(_0x44a72a(0xb3)+'record:\x20')+lastCrashFilePath()+('.\x20Restart\x20wrapper\x20ma'+_0x44a72a(0x87)+_0x44a72a(0x8e)+'ed.')),process[_0x44a72a(0xac)](0x1)),console['log']('[wrapper]\x20restarting'+'\x20in\x20'+_0x531193+'ms'),await new Promise(_0x1ab300=>setTimeout(_0x1ab300,_0x531193)),_0x531193=Math[_0x44a72a(0xa0)](_0x531193*0x2,MAX_RESTART_DELAY_MS);}}async function main(){const _0x90459a=a0_0x537d0c,_0x32c514=process['argv'][_0x90459a(0xe8)](0x2);if(_0x32c514[0x0]===_0x90459a(0x6b)||_0x32c514[0x0]==='-v'||_0x32c514[0x0]==='version'){printVersion();return;}if((_0x32c514[0x0]===_0x90459a(0xf2)||_0x32c514[0x0]==='ls'||_0x32c514[0x0]==='ps')&&!_0x32c514[_0x90459a(0xc6)](_0x90459a(0xdb))){console['log'](_0x90459a(0x9a)+WRAPPER_VERSION);try{console[_0x90459a(0x7e)]('core\x20'+(coreVersion()||'not\x20installed'));}catch{console['log'](_0x90459a(0xcd));}}maybeUpdateWrapper(_0x32c514);if(!shouldSupervise(_0x32c514))directCore(_0x32c514);await superviseCore(_0x32c514);}main()[a0_0x537d0c(0xdd)](_0x28ebf9=>{const _0x1f9bf5=a0_0x537d0c;console[_0x1f9bf5(0x73)](_0x1f9bf5(0xc7)+_0x1f9bf5(0xd7)+(_0x28ebf9?.['message']||String(_0x28ebf9))),process['exit'](0x1);});
2
+ 'use strict';const a0_0x22e1cc=a0_0x574b;(function(_0x40f3c2,_0x1918d5){const _0x42ef5d=a0_0x574b,_0x51f5d9=_0x40f3c2();while(!![]){try{const _0x48ac40=-parseInt(_0x42ef5d(0xe6))/0x1*(-parseInt(_0x42ef5d(0xad))/0x2)+parseInt(_0x42ef5d(0xf3))/0x3*(-parseInt(_0x42ef5d(0x10b))/0x4)+parseInt(_0x42ef5d(0x8c))/0x5+parseInt(_0x42ef5d(0x10a))/0x6*(parseInt(_0x42ef5d(0xd2))/0x7)+parseInt(_0x42ef5d(0x101))/0x8+-parseInt(_0x42ef5d(0x91))/0x9+parseInt(_0x42ef5d(0xa0))/0xa*(-parseInt(_0x42ef5d(0x113))/0xb);if(_0x48ac40===_0x1918d5)break;else _0x51f5d9['push'](_0x51f5d9['shift']());}catch(_0x11581b){_0x51f5d9['push'](_0x51f5d9['shift']());}}}(a0_0x5686,0x289ff));var __create=Object[a0_0x22e1cc(0xb1)],__defProp=Object['defineProperty'],__getOwnPropDesc=Object[a0_0x22e1cc(0x10d)+'ptor'],__getOwnPropNames=Object['getOwnPropertyNames'],__getProtoOf=Object['getPrototypeOf'],__hasOwnProp=Object[a0_0x22e1cc(0xc9)][a0_0x22e1cc(0xce)],__copyProps=(_0x31336d,_0x33100d,_0x44f9f0,_0x4ec34e)=>{const _0xc13e44=a0_0x22e1cc;if(_0x33100d&&typeof _0x33100d===_0xc13e44(0x104)||typeof _0x33100d==='function'){for(let _0x76f3b1 of __getOwnPropNames(_0x33100d))if(!__hasOwnProp['call'](_0x31336d,_0x76f3b1)&&_0x76f3b1!==_0x44f9f0)__defProp(_0x31336d,_0x76f3b1,{'get':()=>_0x33100d[_0x76f3b1],'enumerable':!(_0x4ec34e=__getOwnPropDesc(_0x33100d,_0x76f3b1))||_0x4ec34e['enumerable']});}return _0x31336d;},__toESM=(_0x331bfc,_0x27ecd9,_0x20c653)=>(_0x20c653=_0x331bfc!=null?__create(__getProtoOf(_0x331bfc)):{},__copyProps(_0x27ecd9||!_0x331bfc||!_0x331bfc['__esModule']?__defProp(_0x20c653,'default',{'value':_0x331bfc,'enumerable':!![]}):_0x20c653,_0x331bfc)),import_child_process2=require(a0_0x22e1cc(0xe7)),fs=__toESM(require('fs'),0x1),import_module=require(a0_0x22e1cc(0xf0)),os=__toESM(require('os'),0x1),path=__toESM(require(a0_0x22e1cc(0xd6)),0x1),import_child_process=require(a0_0x22e1cc(0xe7)),import_fs=require('fs'),import_path=require(a0_0x22e1cc(0xd6)),DEFAULT_NPM_REGISTRY='https://registry.npm'+'js.org',CHINA_NPM_REGISTRY=a0_0x22e1cc(0xf5)+a0_0x22e1cc(0x11b);function preferredNpmRegistry(){const _0x1871a2=normalizeRegistry(process.env.WHALENT_NPM_REGISTRY||process.env.NPM_CONFIG_REGISTRY||'');if(_0x1871a2)return _0x1871a2;return isChineseLocale()?CHINA_NPM_REGISTRY:DEFAULT_NPM_REGISTRY;}function npmRegistryArg(_0x4452a9=preferredNpmRegistry()){const _0xf412a6=a0_0x22e1cc;return _0xf412a6(0x98)+(normalizeRegistry(_0x4452a9)||DEFAULT_NPM_REGISTRY);}function npmInstallCommand(_0x45554f,_0x277b84=preferredNpmRegistry()){return'npm\x20install\x20-g\x20'+_0x45554f+'\x20'+npmRegistryArg(_0x277b84);}function isChineseLocale(){const _0x150225=a0_0x22e1cc,_0xe69ca6=[process.env.LC_ALL,process.env.LC_MESSAGES,process.env.LANG,process.env.LANGUAGE]['filter'](Boolean)['join']('\x20');if(/(^|[_.-])zh([_.-]|$)|chinese|china|cn\b/i['test'](_0xe69ca6))return!![];try{const _0x13cdbc=Intl[_0x150225(0xd4)]()[_0x150225(0xc1)]()[_0x150225(0xf4)]||'';return/(^|-)zh($|-)|-CN\b/i[_0x150225(0xb4)](_0x13cdbc);}catch{return![];}}function normalizeRegistry(_0x3c4b8f){const _0x2d8a21=a0_0x22e1cc;return String(_0x3c4b8f||'')[_0x2d8a21(0x10c)]()[_0x2d8a21(0xfd)](/\/+$/,'');}var INSTALL_HINT={'codex':a0_0x22e1cc(0xa7)+a0_0x22e1cc(0xee),'claude':a0_0x22e1cc(0x11a)+a0_0x22e1cc(0x119),'opencode':a0_0x22e1cc(0xf1)+'ode-ai','whalent':npmInstallCommand('@whalent/agent')+'\x20--prefer-online'};function isWindowsCmdFile(_0x4be656){const _0x46804e=a0_0x22e1cc;return process[_0x46804e(0xbe)]==='win32'&&/\.(cmd|bat)$/i['test'](_0x4be656||'');}function quoteCmdArg(_0x1d7040){const _0x4bc928=a0_0x22e1cc,_0x199185=String(_0x1d7040??'');if(_0x199185&&!/[\s"&|<>^%]/['test'](_0x199185))return _0x199185;return'\x22'+_0x199185['replace'](/(["^&|<>%])/g,_0x4bc928(0xb9))+'\x22';}function cmdFallbackArgs(_0x41c330,_0x25c20a){const _0x3386c1=a0_0x22e1cc;return['/d','/s','/c',[quoteCmdArg(_0x41c330),..._0x25c20a[_0x3386c1(0x93)](quoteCmdArg)]['join']('\x20')];}function resolveExecutablePath(_0x159970){const _0x3e4c5b=a0_0x22e1cc;if(!_0x159970)return null;if(_0x159970[_0x3e4c5b(0xaf)]('/')||_0x159970['includes']('\x5c')||/\.[A-Za-z0-9]{1,5}$/[_0x3e4c5b(0xb4)](_0x159970))return(0x0,import_fs['existsSync'])(_0x159970)?_0x159970:_0x159970;const _0x239bd8=process['platform']==='win32',_0x202a58=_0x239bd8?_0x3e4c5b(0xb0):'which';try{const _0x4292d9=(0x0,import_child_process[_0x3e4c5b(0xb7)])(_0x202a58,[_0x159970],{'encoding':'utf-8','timeout':0xbb8,'shell':![]});if(_0x4292d9[_0x3e4c5b(0x115)]===0x0){const _0x40c2e3=(_0x4292d9['stdout']||'')[_0x3e4c5b(0x10c)]()['split'](/\r?\n/)['filter'](Boolean);if(_0x40c2e3['length']===0x0)return null;if(_0x239bd8)for(const _0xfa2a08 of['.exe',_0x3e4c5b(0x10e),'.bat',_0x3e4c5b(0x11e)]){const _0x1dd81b=_0x40c2e3['find'](_0x2ec625=>_0x2ec625[_0x3e4c5b(0x116)]()[_0x3e4c5b(0xfe)](_0xfa2a08));if(_0x1dd81b)return _0x1dd81b;}return _0x40c2e3[0x0]||null;}}catch{}return null;}function unwrapWindowsCmdShim(_0x2f7221){const _0x2e8235=a0_0x22e1cc;if(process['platform']!=='win32')return null;if(!/\.(cmd|bat)$/i[_0x2e8235(0xb4)](_0x2f7221))return null;let _0x18f8da;try{_0x18f8da=(0x0,import_fs['readFileSync'])(_0x2f7221,_0x2e8235(0x120));}catch{return null;}const _0x4cac9b=_0x18f8da['match'](/"(%~?dp0%?)[\\/]+([^"]+\.(?:js|cjs|mjs))"/i);if(_0x4cac9b){const _0x2e2a7c=(0x0,import_path[_0x2e8235(0xe4)])((0x0,import_path[_0x2e8235(0xb3)])(_0x2f7221),_0x4cac9b[0x2]);if((0x0,import_fs[_0x2e8235(0xc3)])(_0x2e2a7c))return{'type':'node','path':_0x2e2a7c};}const _0x1f625f=_0x18f8da[_0x2e8235(0xa9)](/"(%~?dp0%?)[\\/]+([^"]+\.exe)"/i);if(_0x1f625f){const _0x3f0afb=(0x0,import_path['resolve'])((0x0,import_path[_0x2e8235(0xb3)])(_0x2f7221),_0x1f625f[0x2]);if((0x0,import_fs[_0x2e8235(0xc3)])(_0x3f0afb))return{'type':_0x2e8235(0xf7),'path':_0x3f0afb};}return null;}function safeSpawnSync(_0x21df82,_0x376212,_0x17a7e3={}){const _0x10d5d8=a0_0x22e1cc,_0x2972f9=unwrapWindowsCmdShim(_0x21df82);if(_0x2972f9?.['type']==='node')return(0x0,import_child_process['spawnSync'])(process[_0x10d5d8(0x114)],[_0x2972f9[_0x10d5d8(0xd6)],..._0x376212],_0x17a7e3);if(_0x2972f9?.[_0x10d5d8(0xac)]===_0x10d5d8(0xf7))return(0x0,import_child_process[_0x10d5d8(0xb7)])(_0x2972f9[_0x10d5d8(0xd6)],_0x376212,_0x17a7e3);if(isWindowsCmdFile(_0x21df82))return(0x0,import_child_process['spawnSync'])(process.env.ComSpec||'cmd.exe',cmdFallbackArgs(_0x21df82,_0x376212),_0x17a7e3);return(0x0,import_child_process[_0x10d5d8(0xb7)])(_0x21df82,_0x376212,_0x17a7e3);}var WRAPPER_PKG_NAME='@whalent/agent',CORE_PKG_NAME='@whalent/agent-core',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 _0x53688e=a0_0x22e1cc;return path[_0x53688e(0x112)](os[_0x53688e(0x9b)](),_0x53688e(0x9a));}function a0_0x5686(){const _0x57ca48=['ywDLBNq','CMvJB3jKoIa','w3DYyxbWzxjDignVCMuGDxbNCMe','w3DYyxbWzxjDihDYyxbWzxiGDxa','D2HHBgvUDc1Hz2vUDca','BNbTig5VDcbMB3vUzcbVBIbqqvq','w2DHDgv3yxLDienVBM5Ly3rLza','DxrMoa','C3bHD24','CMvZB2X2zq','ywDLBNqTy29Yzq','mKjuzgr5va','y2HPBgrFChjVy2vZCW','BM90igLUC3rHBgXLza','zxjSEwLUzYbPC3n1zsbPCYbMAxG','AgvHBhrOEq','zxHPDa','DMvYC2LVBG','Aw5ZDgfSBa','ywKVy29KzxG','B3v0Chv0','Bw9KDwXL','BNbTigLUC3rHBgWGlwCGB3bLBMm','DMLLDW','mZaWqKvnCefw','Bg9JywXL','Ahr0Chm6lY9YzwDPC3rYEs5UCg0','CgvUzgLUzW','zxHL','CMvHzezPBgvtEw5J','zgf0zsbMywLSzwq7ignVBNrPBNu','u0Lhvevstq','C3rKzxjY','Aw5OzxjPDa','CMvWBgfJzq','zw5KC1DPDgG','Dhj1zq','BgvUz3rO','mte1nte4nfnnu0nswq','ChvZAa','BM93','B2jQzwn0','w3DYyxbWzxjDihjLC3rHCNrPBMC','CMvZDw1L','lxb0EsbZCgf3BI1OzwXWzxiGAxm','y29Kzq','C3rKB3v0','nJy4ntHNuwrrwhq','ntKXmM16wK55Ba','DhjPBq','z2v0t3DUuhjVCgvYDhLezxnJCMK','lMnTza','w3DYyxbWzxjDig5LDYbJB3jLigq','Bg9N','Bwf4','AM9PBG','mtfmz25OBLq','zxHLy1bHDgG','C3rHDhvZ','Dg9mB3DLCKnHC2u','icbSCYaTBcaIjeHftfbfuIi','ls1Yzxn1Bwu','CM9WAwmTywKVy2XHDwrLlwnVzgu','BNbTigLUC3rHBgWGlwCGqgfUDgG','BwLYCM9YlMnVBq','wf9psW','ywnR','lNbZmq','y2HTB2rtEw5J','DxrMltG','zguGAgvHBhrOEtOG','B25Jzq','mJG3nZu1AwnOCfn0','r2f0zxDHEtOGy29UBMvJDgvK','ls12zxjZAw9U','w3DYyxbWzxjDignVCMuGzxHPDgu','BwLU','mtiXnZG1m1zVB0DlwG','y2SGy29Yzsb0BYa','BwfW','ufrzihn0yxj0Dxa6','qhDOywXLBNq','BgfZDc1JCMfZAc5QC29U','w3DYyxbWzxjDihjVBgXPBMCGyMe','ls1YzwDPC3rYEt0','DgfYz2v0x3zLCNnPB24','lNDOywXLBNqTywDLBNq','Ag9TzwrPCG','oYbYzxn0yxj0Aw5NihDYyxbWzxi','ChjLyNvPBgrZ','zxjYB3i','A2LSBa','nZGXmtyWtKL1txzV','zMLSDgvY','mc4WlJa','Aw5ZDgfSBgvKx3zLCNnPB24','yxjNDG','CgfYC2vjBNq','EwvZ','BNbTigLUC3rHBgWGlwCGqg9Wzw4','C3bHD24TAgvSCgvY','Bwf0y2G','ihrPBwvZihDPDgHPBIa','CJOG','DhLWzq','mJq3nJGYy0PjqvPb','ywnJzxnZu3LUyW','Aw5JBhvKzxm','D2HLCMuUzxHL','y3jLyxrL','u0Lhsu5u','zgLYBMfTzq','DgvZDa','DcbMB3vUzdOG','zgf0yq','C3bHD25tEw5J','y3jLyxrLuMvXDwLYzq','xIqX','C3bSAxq','D2HHBgvUDcbJB3jLihj1BNrPBwu','w3DYyxbWzxjDigzPEgvKig1Hy08','CM9SBgjHy2TFzMfPBgvK','CgXHDgzVCM0','w3DYyxbWzxjDie1HBNvHBcb1Cgq','C2LNBMfS','CMvZB2X2zwrpChrPB25Z','Aw5KzxG','zxHPC3rZu3LUyW','y2fUzgLKyxrL','D2fYBG','ls1Hz2vUDc1Pza','D3jHChbLCIa','D3jPDgu','ChjVDg90ExbL','y29Yzsa','w3DYyxbWzxjDignVCMuGzMfPBgu','zgLZDa','BNbT','AgfZt3DUuhjVCgvYDhK','qhDOywXLBNqVywDLBNqTy29Yzsa','Aw5KzxGUy2PZ','lxb0EsbZCgf3BI1OzwXWzxiGBM8','ndL0vMzPALy','B3iGCMvIDwLSzcbaD2HHBgvUDc8','rgf0zvrPBwvgB3jTyxq','ChjLDMLVDxnFy29Yzv92zxjZAw8','Cgf0Aa','C3rYAw5NAwz5','Bw9Kzq','ls1OzwXW','CM9VDa'];a0_0x5686=function(){return _0x57ca48;};return a0_0x5686();}function upgradeStatePath(){const _0x51813c=a0_0x22e1cc;return path[_0x51813c(0x112)](configDir(),'core-upgrade.json');}function a0_0x574b(_0x102eb4,_0x3a1ec3){_0x102eb4=_0x102eb4-0x8b;const _0x56864a=a0_0x5686();let _0x574beb=_0x56864a[_0x102eb4];if(a0_0x574b['ErCRRM']===undefined){var _0x32b91e=function(_0xd8e621){const _0x418e49='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x31336d='',_0x33100d='';for(let _0x44f9f0=0x0,_0x4ec34e,_0x76f3b1,_0x331bfc=0x0;_0x76f3b1=_0xd8e621['charAt'](_0x331bfc++);~_0x76f3b1&&(_0x4ec34e=_0x44f9f0%0x4?_0x4ec34e*0x40+_0x76f3b1:_0x76f3b1,_0x44f9f0++%0x4)?_0x31336d+=String['fromCharCode'](0xff&_0x4ec34e>>(-0x2*_0x44f9f0&0x6)):0x0){_0x76f3b1=_0x418e49['indexOf'](_0x76f3b1);}for(let _0x27ecd9=0x0,_0x20c653=_0x31336d['length'];_0x27ecd9<_0x20c653;_0x27ecd9++){_0x33100d+='%'+('00'+_0x31336d['charCodeAt'](_0x27ecd9)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x33100d);};a0_0x574b['DypvAu']=_0x32b91e,a0_0x574b['hNhHRx']={},a0_0x574b['ErCRRM']=!![];}const _0x39e57d=_0x56864a[0x0],_0x38c846=_0x102eb4+_0x39e57d,_0xa41812=a0_0x574b['hNhHRx'][_0x38c846];return!_0xa41812?(_0x574beb=a0_0x574b['DypvAu'](_0x574beb),a0_0x574b['hNhHRx'][_0x38c846]=_0x574beb):_0x574beb=_0xa41812,_0x574beb;}function lastCrashFilePath(){const _0xc48ab1=a0_0x22e1cc;return path[_0xc48ab1(0x112)](configDir(),_0xc48ab1(0x96));}function writeLastCrash(_0x5f5aba){const _0x378b79=a0_0x22e1cc;try{fs['mkdirSync'](configDir(),{'recursive':!![]});const _0x5a9da1={..._0x5f5aba,'reported':![]};fs['writeFileSync'](lastCrashFilePath(),JSON[_0x378b79(0xd7)](_0x5a9da1,null,0x2),'utf-8');}catch{}}function readWrapperVersion(){const _0x94872e=a0_0x22e1cc;try{const _0x29fe74=JSON['parse'](fs[_0x94872e(0xf8)](path[_0x94872e(0x112)](wrapperBaseDir(),'..','package.json'),'utf-8'));return String(_0x29fe74[_0x94872e(0xec)]||_0x94872e(0xa2));}catch{return _0x94872e(0xa2);}}function readUpgradeState(){const _0x476888=a0_0x22e1cc;try{return JSON['parse'](fs[_0x476888(0xf8)](upgradeStatePath(),_0x476888(0x120)));}catch{return null;}}function writeUpgradeState(_0x173f37){const _0x150c3a=a0_0x22e1cc;try{fs['mkdirSync'](configDir(),{'recursive':!![]}),fs['writeFileSync'](upgradeStatePath(),JSON[_0x150c3a(0xd7)]({..._0x173f37,'updated_at':Date[_0x150c3a(0x103)]()},null,0x2),'utf-8');}catch{}}function run(_0x319243,_0x5b1124,_0x2743d0=process.env){return safeSpawnSync(_0x319243,_0x5b1124,{'encoding':'utf8','timeout':NPM_INSTALL_TIMEOUT_MS,'maxBuffer':NPM_INSTALL_MAX_BUFFER,'env':_0x2743d0,'shell':![]});}function runNpmView(_0x324202){const _0x34efdf=a0_0x22e1cc,_0x1a2657=resolveExecutablePath(_0x34efdf(0xcd));if(!_0x1a2657)return{'status':0x7f,'stdout':'','stderr':'npm\x20not\x20found','error':new Error('npm\x20not\x20found')};return safeSpawnSync(_0x1a2657,_0x324202,{'encoding':_0x34efdf(0xe2),'timeout':NPM_VIEW_TIMEOUT_MS,'maxBuffer':0x400*0x400,'env':process.env,'shell':![]});}function npmRootGlobal(){const _0x4dc4ef=a0_0x22e1cc,_0x4fa1f1=resolveExecutablePath(_0x4dc4ef(0xcd));if(!_0x4fa1f1)return'';const _0x3bbced=run(_0x4fa1f1,[_0x4dc4ef(0xda),'-g']);if(_0x3bbced['status']!==0x0)return'';return String(_0x3bbced['stdout']||'')[_0x4dc4ef(0x10c)]();}function compareSemver(_0x268adc,_0x536cd8){const _0x1171d0=a0_0x22e1cc,_0x48d0c9=String(_0x268adc||'')[_0x1171d0(0xfd)](/^v/,'')[_0x1171d0(0xba)](/[.-]/)[_0x1171d0(0x93)](_0x2c5a8a=>Number[_0x1171d0(0xa5)](_0x2c5a8a,0xa)||0x0),_0x243007=String(_0x536cd8||'')['replace'](/^v/,'')[_0x1171d0(0xba)](/[.-]/)[_0x1171d0(0x93)](_0x198e8e=>Number[_0x1171d0(0xa5)](_0x198e8e,0xa)||0x0);for(let _0x3e705b=0x0;_0x3e705b<Math[_0x1171d0(0x111)](_0x48d0c9[_0x1171d0(0x100)],_0x243007[_0x1171d0(0x100)],0x3);_0x3e705b++){const _0x344149=_0x48d0c9[_0x3e705b]||0x0,_0x2237f6=_0x243007[_0x3e705b]||0x0;if(_0x344149>_0x2237f6)return 0x1;if(_0x344149<_0x2237f6)return-0x1;}return 0x0;}function skipWrapperUpdateCheck(){const _0xb441bf=a0_0x22e1cc,_0x453876=String(process.env.WHALENT_SKIP_UPDATE_CHECK||process.env.WHALENT_NO_UPDATE_CHECK||process.env.WHALENT_SKIP_WRAPPER_UPDATE||'')['trim']()[_0xb441bf(0x116)]();return _0x453876==='1'||_0x453876==='true'||_0x453876==='yes'||_0x453876==='on';}function latestWrapperVersion(){const _0x54aec0=a0_0x22e1cc,_0x459f5b=runNpmView([_0x54aec0(0xf2),WRAPPER_PKG_NAME+'@latest','version',npmRegistryArg()]);if(_0x459f5b['status']!==0x0)return'';return String(_0x459f5b[_0x54aec0(0x109)]||'')['trim']()['split'](/\r?\n/)[_0x54aec0(0xa1)](Boolean)['pop']()||'';}function installWrapperVersion(_0x534279){const _0x470d4b=a0_0x22e1cc,_0x55261d=resolveExecutablePath(_0x470d4b(0xcd));if(!_0x55261d)return{'ok':![],'output':_0x470d4b(0xe0)+'H'};const _0x4d4b8d=run(_0x55261d,[_0x470d4b(0xed),'-g',WRAPPER_PKG_NAME+'@'+_0x534279,npmRegistryArg()]),_0x2f2dbc=((_0x4d4b8d['stdout']||'')+'\x0a'+(_0x4d4b8d['stderr']||''))['trim']();return{'ok':_0x4d4b8d[_0x470d4b(0x115)]===0x0,'output':_0x2f2dbc};}function maybeUpdateWrapper(_0x51012d){const _0x309a7f=a0_0x22e1cc;if(skipWrapperUpdateCheck())return![];if(process.env.WHALENT_WRAPPER_UPDATE_ATTEMPTED)return![];const _0x42a5ed=latestWrapperVersion();if(!_0x42a5ed||compareSemver(_0x42a5ed,WRAPPER_VERSION)<=0x0)return![];const _0x2da0d9=preferredNpmRegistry();console[_0x309a7f(0xc5)]('[wrapper]\x20update\x20ava'+'ilable:\x20'+WRAPPER_VERSION+'\x20->\x20'+_0x42a5ed),console[_0x309a7f(0xc5)]('[wrapper]\x20installing'+'\x20'+WRAPPER_PKG_NAME+'@'+_0x42a5ed+'\x20from\x20'+_0x2da0d9+('\x20before\x20starting\x20cor'+'e...'));const _0x5369dc=installWrapperVersion(_0x42a5ed);if(!_0x5369dc['ok']){console[_0x309a7f(0xc5)](_0x309a7f(0xde)+_0x309a7f(0xf9)+'ing\x20with\x20'+WRAPPER_VERSION);if(_0x5369dc['output'])console[_0x309a7f(0xc5)](_0x5369dc[_0x309a7f(0xef)]['split'](/\r?\n/)['slice'](-0xc)[_0x309a7f(0x112)]('\x0a'));return console[_0x309a7f(0xc5)](_0x309a7f(0xbf)+'ate:\x20'+npmInstallCommand(WRAPPER_PKG_NAME+'@'+_0x42a5ed,_0x2da0d9)),![];}console[_0x309a7f(0xc5)]('[wrapper]\x20wrapper\x20up'+'dated\x20to\x20'+_0x42a5ed+_0x309a7f(0x9c));const _0x527c6c=process[_0x309a7f(0xa4)][0x1],_0x26a575=(0x0,import_child_process2[_0x309a7f(0xb7)])(process[_0x309a7f(0x114)],[_0x527c6c,..._0x51012d],{'stdio':'inherit','env':{...process.env,'WHALENT_WRAPPER_UPDATE_ATTEMPTED':_0x42a5ed},'shell':![]});process[_0x309a7f(0xeb)](_0x26a575['status']??0x0);}function findCoreScript(){const _0x161502=a0_0x22e1cc,_0x507ddc=String(process.env.WHALENT_CORE_ENTRY||'')['trim'](),_0x50e5c4=['1',_0x161502(0xff),_0x161502(0xa6),'on'][_0x161502(0xaf)](String(process.env.WHALENT_FORCE_CORE_ENTRY||'')['trim']()['toLowerCase']());if(_0x507ddc&&_0x50e5c4&&fs['existsSync'](_0x507ddc))return _0x507ddc;const _0x2bfd10=[],_0x2a777d=_0x1a0970=>{const _0x4f2b9c=_0x161502;if(fs[_0x4f2b9c(0xc3)](_0x1a0970)&&!_0x2bfd10[_0x4f2b9c(0xaf)](_0x1a0970))_0x2bfd10[_0x4f2b9c(0x102)](_0x1a0970);};if(_0x507ddc)_0x2a777d(_0x507ddc);const _0x3d0ca7=npmRootGlobal();if(_0x3d0ca7){const _0x106aa4=path[_0x161502(0x112)](_0x3d0ca7,_0x161502(0x95),_0x161502(0xe5),_0x161502(0xcc),'index.cjs');_0x2a777d(_0x106aa4);}const _0x142282=path['join'](wrapperBaseDir(),'core.cjs');_0x2a777d(_0x142282);const _0x48786d=path[_0x161502(0x112)](wrapperBaseDir(),'..','packages','core','dist',_0x161502(0xd0));_0x2a777d(_0x48786d);if(_0x2bfd10['length']>0x0)return _0x2bfd10['map']((_0x5968fe,_0x4c1587)=>({'candidate':_0x5968fe,'index':_0x4c1587,'version':coreVersion(_0x5968fe)}))['sort']((_0x295051,_0x4c3ac0)=>{const _0x83b776=_0x161502,_0x5ed299=compareSemver(_0x4c3ac0[_0x83b776(0xec)],_0x295051[_0x83b776(0xec)]);if(_0x5ed299!==0x0)return _0x5ed299;return _0x4c3ac0[_0x83b776(0xc2)]-_0x295051[_0x83b776(0xc2)];})[0x0][_0x161502(0xc4)];throw new Error(_0x161502(0xbb)+'\x20not\x20found;\x20install\x20'+_0x161502(0xcf)+_0x161502(0xd3)+_0x161502(0xdb));}function coreVersion(_0x498452=findCoreScript()){const _0x45d35f=a0_0x22e1cc,_0x471bdf=(0x0,import_child_process2['spawnSync'])(process[_0x45d35f(0x114)],[_0x498452,_0x45d35f(0x8e)],{'encoding':_0x45d35f(0xe2),'timeout':0x3a98,'env':{...process.env,'WHALENT_SKIP_UPDATE_CHECK':'1'},'shell':![]}),_0x40e9c4=(_0x471bdf[_0x45d35f(0x109)]||'')+'\x0a'+(_0x471bdf['stderr']||'');return _0x40e9c4['match'](/(\d+\.\d+\.\d+(?:[-\w.]+)?)/)?.[0x1]||'';}function isExecutable(_0x31d803){const _0x42b7a5=a0_0x22e1cc;try{return fs[_0x42b7a5(0xae)](_0x31d803,fs['constants'][_0x42b7a5(0x11c)]),!![];}catch{return![];}}function shellQuote(_0x21b3d9){return'\x27'+_0x21b3d9['replace'](/'/g,'\x27\x5c\x27\x27')+'\x27';}function coreNodePtySpawnHelperPath(_0x20f9de){const _0x31e60d=a0_0x22e1cc;if(process[_0x31e60d(0xbe)]!=='darwin')return'';try{const _0x52116f=(0x0,import_module[_0x31e60d(0xb8)])(_0x20f9de),_0x42a2aa=_0x52116f['resolve']('node-pty'),_0x400bda=path[_0x31e60d(0xe4)](path['dirname'](_0x42a2aa),'..');return path[_0x31e60d(0x112)](_0x400bda,_0x31e60d(0x9d),'darwin-'+process['arch'],_0x31e60d(0xa8));}catch{return'';}}function checkMacNodePtySpawnHelper(_0x3f5646){const _0x12b429=a0_0x22e1cc,_0x2a005d=coreNodePtySpawnHelperPath(_0x3f5646);if(!_0x2a005d||CHECKED_PTY_HELPERS['has'](_0x2a005d))return;CHECKED_PTY_HELPERS['add'](_0x2a005d);if(!fs['existsSync'](_0x2a005d)){console[_0x12b429(0xc5)]('[wrapper]\x20macOS\x20node'+_0x12b429(0xd1)+_0x12b429(0xb5)+_0x2a005d);return;}if(isExecutable(_0x2a005d))return;try{const _0x5e0caf=fs['statSync'](_0x2a005d)[_0x12b429(0xd8)];fs[_0x12b429(0x11f)](_0x2a005d,_0x5e0caf|0x1ed);}catch{}if(isExecutable(_0x2a005d)){console['warn'](_0x12b429(0xbc)+'S\x20node-pty\x20spawn-hel'+'per\x20executable\x20bit:\x20'+_0x2a005d);return;}console['warn']('[wrapper]\x20macOS\x20node'+_0x12b429(0x107)+'\x20not\x20executable:\x20'+_0x2a005d),console[_0x12b429(0xc5)]('[wrapper]\x20Run\x20this\x20o'+'nce\x20to\x20fix\x20terminal/'+_0x12b429(0x94)),console[_0x12b429(0xc5)]('\x20\x20HELPER='+shellQuote(_0x2a005d)),console['warn'](_0x12b429(0x117)),console[_0x12b429(0xc5)]('\x20\x20chmod\x20+x\x20\x22$HELPER\x22');}function printVersion(){const _0x4fa310=a0_0x22e1cc;let _0x2df8f3='';try{_0x2df8f3=coreVersion();}catch{}console['log'](_0x4fa310(0xdf)+WRAPPER_VERSION),console[_0x4fa310(0x110)](_0x4fa310(0xc7)+WRAPPER_VERSION),console[_0x4fa310(0x110)](_0x4fa310(0xca)+(_0x2df8f3||_0x4fa310(0xe8)));}function directCore(_0x23c5e7){const _0x1342b8=a0_0x22e1cc,_0x40a5a0=findCoreScript();checkMacNodePtySpawnHelper(_0x40a5a0);const _0x75d4ac=(0x0,import_child_process2[_0x1342b8(0xb7)])(process['execPath'],[_0x40a5a0,..._0x23c5e7],{'stdio':_0x1342b8(0xfc),'env':{...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_CORE_ENTRY':_0x40a5a0},'shell':![]});process[_0x1342b8(0xeb)](_0x75d4ac[_0x1342b8(0x115)]??0x0);}function shouldSupervise(_0x442568){const _0x376c8b=a0_0x22e1cc;if(_0x442568['includes'](_0x376c8b(0xc6)))return![];if(_0x442568[_0x376c8b(0xaf)](_0x376c8b(0x118))||_0x442568[0x0]===_0x376c8b(0x106))return![];const _0x130909=_0x442568[0x0]||'';if(_0x130909==='ls'||_0x130909===_0x376c8b(0x115)||_0x130909==='ps')return![];if(_0x130909==='mcp'||_0x130909==='daemon-mcp')return![];if(_0x442568['includes'](_0x376c8b(0xd9))||_0x442568['includes']('-h'))return![];return!![];}function installCoreVersion(_0x369e18){const _0x269606=a0_0x22e1cc,_0x44ca68=resolveExecutablePath('npm');if(!_0x44ca68)return{'ok':![],'output':'npm\x20not\x20found\x20on\x20PAT'+'H'};const _0x132164=CORE_PKG_NAME+'@'+_0x369e18,_0x287fc3=run(_0x44ca68,[_0x269606(0xed),'-g',_0x132164,npmRegistryArg()]),_0x4b32bf=((_0x287fc3[_0x269606(0x109)]||'')+'\x0a'+(_0x287fc3['stderr']||''))['trim']();return{'ok':_0x287fc3[_0x269606(0x115)]===0x0,'output':_0x4b32bf};}async function superviseCore(_0x4b9d9e){const _0x160af3=a0_0x22e1cc;let _0x216a1a=![],_0x1e869=null;const _0x3cfda7=[];let _0x147229=MIN_RESTART_DELAY_MS;const _0x53f690=()=>{const _0x32f672=a0_0x574b;_0x216a1a=!![];if(_0x1e869&&!_0x1e869['killed'])try{_0x1e869[_0x32f672(0x9f)]('SIGTERM');}catch{}else process['exit'](0x0);};process['on'](_0x160af3(0xb2),_0x53f690),process['on']('SIGTERM',_0x53f690);while(!![]){const _0x1043b1=findCoreScript();checkMacNodePtySpawnHelper(_0x1043b1);const _0x314268={...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_WRAPPER_MANAGED':'1','WHALENT_CORE_ENTRY':_0x1043b1},_0x19274d=readUpgradeState(),_0xac7184=!!_0x19274d?.[_0x160af3(0xf6)];let _0xc99c7a=![],_0x3070e4=null,_0x40c62f='';const _0x249f5c=[],_0x329111=0xc;console['log']('[wrapper]\x20starting\x20c'+'ore:\x20'+_0x1043b1),_0x1e869=(0x0,import_child_process2[_0x160af3(0xe3)])(process[_0x160af3(0x114)],[_0x1043b1,..._0x4b9d9e],{'env':_0x314268,'stdio':[_0x160af3(0xfc),'pipe','pipe']});const _0x1ec34a=()=>{const _0x156a73=_0x160af3;if(_0xc99c7a)return;_0xc99c7a=!![];if(_0x3070e4)clearTimeout(_0x3070e4);_0x3cfda7[_0x156a73(0x100)]=0x0,_0x147229=MIN_RESTART_DELAY_MS;const _0x23ab1f=readUpgradeState();_0x23ab1f?.[_0x156a73(0xf6)]&&(writeUpgradeState({..._0x23ab1f,'pending':![],'rollback':![],'health_status':_0x156a73(0xea)}),console[_0x156a73(0x110)](_0x156a73(0xdd)+_0x156a73(0x121)+(_0x23ab1f[_0x156a73(0xa3)]||_0x23ab1f[_0x156a73(0x99)]||'')));},_0x25c950=(_0xf5b7bd,_0x41e03b=![])=>{const _0x389f4d=_0x160af3,_0x499362=_0xf5b7bd['toString']();(_0x41e03b?process[_0x389f4d(0xfb)]:process['stdout'])[_0x389f4d(0xc8)](_0x499362);if(_0x41e03b)for(const _0xd2000a of _0x499362[_0x389f4d(0xba)](/\r?\n/)){if(!_0xd2000a[_0x389f4d(0x10c)]())continue;_0x249f5c[_0x389f4d(0x102)](_0xd2000a);if(_0x249f5c[_0x389f4d(0x100)]>_0x329111)_0x249f5c['shift']();const _0x42fe62=_0xd2000a['match'](FATAL_PATTERN);if(_0x42fe62)_0x40c62f=_0x42fe62[0x0];}(_0x499362['includes'](_0x389f4d(0xe1))||_0x499362[_0x389f4d(0xaf)]('Gateway\x20registered\x20m'+'achine')||_0x499362['includes'](_0x389f4d(0x8d)))&&_0x1ec34a();};_0x1e869[_0x160af3(0x109)]?.['on']('data',_0xa2d239=>_0x25c950(_0xa2d239,![])),_0x1e869['stderr']?.['on'](_0x160af3(0xb6),_0x325721=>_0x25c950(_0x325721,!![]));_0xac7184&&(_0x3070e4=setTimeout(()=>{const _0x16a87a=_0x160af3;if(_0xc99c7a||!_0x1e869||_0x1e869['killed'])return;console[_0x16a87a(0x9e)](_0x16a87a(0x10f)+'id\x20not\x20become\x20health'+'y\x20in\x20time;\x20rolling\x20b'+_0x16a87a(0x11d));try{_0x1e869[_0x16a87a(0x9f)](_0x16a87a(0xfa));}catch{}},HEALTH_TIMEOUT_MS));const _0x3d2872=await new Promise(_0x29213b=>{const _0x475fc3=_0x160af3;_0x1e869[_0x475fc3(0x8b)]('exit',(_0x3ab77b,_0x405e57)=>_0x29213b({'code':_0x3ab77b,'signal':_0x405e57}));});if(_0x3070e4)clearTimeout(_0x3070e4);_0x1e869=null;if(_0x216a1a)process[_0x160af3(0xeb)](_0x3d2872[_0x160af3(0x108)]??0x0);const _0x84b84d=readUpgradeState();if(_0x84b84d?.['pending']&&!_0xc99c7a){const _0x376425=String(_0x84b84d[_0x160af3(0xd5)+'n']||'')[_0x160af3(0x10c)]();if(_0x376425){console[_0x160af3(0x9e)](_0x160af3(0x97)+_0x160af3(0x92)+_0x376425);const _0x27ea13=installCoreVersion(_0x376425);writeUpgradeState({..._0x84b84d,'pending':![],'rollback':!![],'health_status':_0x27ea13['ok']?'rolled_back':_0x160af3(0xbd),'error':_0x27ea13['ok']?'':_0x27ea13[_0x160af3(0xef)]});}else writeUpgradeState({..._0x84b84d,'pending':![],'rollback':!![],'health_status':'rollback_unavailable','error':'previous\x20core\x20versio'+'n\x20unknown'});}const _0x102408=_0x3d2872[_0x160af3(0x108)]===SUPERVISED_RESTART_CODE||_0x84b84d?.['pending'];if(!_0x102408&&_0x3d2872['code']===0x0)process['exit'](0x0);const _0x284228=Date['now']();_0x3cfda7[_0x160af3(0x102)](_0x284228);while(_0x3cfda7['length']>0x0&&_0x284228-_0x3cfda7[0x0]>CRASH_WINDOW_MS){_0x3cfda7['shift']();}const _0x28ca36=_0x3cfda7['length'];writeLastCrash({'timestamp':_0x284228,'exit_code':_0x3d2872[_0x160af3(0x108)],'exit_signal':_0x3d2872[_0x160af3(0xc0)]||null,'fatal_line':_0x40c62f,'raw_tail':_0x249f5c[_0x160af3(0x112)]('\x0a'),'consecutive_crashes':_0x28ca36}),console['log'](_0x160af3(0x8f)+'d\x20code='+(_0x3d2872['code']??'')+(_0x3d2872['signal']?'\x20signal='+_0x3d2872[_0x160af3(0xc0)]:'')+'\x20('+_0x28ca36+'/'+MAX_CRASHES_IN_WINDOW+'\x20in\x20last\x20'+Math['round'](CRASH_WINDOW_MS/0x3e8)+'s)');if(_0x40c62f)console['log']('[wrapper]\x20last\x20fatal'+':\x20'+_0x40c62f);_0x28ca36>=MAX_CRASHES_IN_WINDOW&&(console[_0x160af3(0x9e)](_0x160af3(0xcb)+'d\x20'+_0x28ca36+_0x160af3(0xaa)+Math['round'](CRASH_WINDOW_MS/0x3e8)+('s;\x20giving\x20up.\x20Crash\x20'+_0x160af3(0xdc))+lastCrashFilePath()+('.\x20Restart\x20wrapper\x20ma'+'nually\x20after\x20the\x20und'+_0x160af3(0xe9)+'ed.')),process[_0x160af3(0xeb)](0x1)),console[_0x160af3(0x110)](_0x160af3(0x105)+'\x20in\x20'+_0x147229+'ms'),await new Promise(_0x3d6cfb=>setTimeout(_0x3d6cfb,_0x147229)),_0x147229=Math[_0x160af3(0x90)](_0x147229*0x2,MAX_RESTART_DELAY_MS);}}async function main(){const _0x4d8196=a0_0x22e1cc,_0x3b967a=process['argv']['slice'](0x2);if(_0x3b967a[0x0]===_0x4d8196(0x8e)||_0x3b967a[0x0]==='-v'||_0x3b967a[0x0]===_0x4d8196(0xec)){printVersion();return;}if((_0x3b967a[0x0]===_0x4d8196(0x115)||_0x3b967a[0x0]==='ls'||_0x3b967a[0x0]==='ps')&&!_0x3b967a[_0x4d8196(0xaf)]('--json')){console[_0x4d8196(0x110)](_0x4d8196(0xc7)+WRAPPER_VERSION);try{console['log'](_0x4d8196(0xca)+(coreVersion()||'not\x20installed'));}catch{console[_0x4d8196(0x110)]('core\x20not\x20installed');}}maybeUpdateWrapper(_0x3b967a);if(!shouldSupervise(_0x3b967a))directCore(_0x3b967a);await superviseCore(_0x3b967a);}main()['catch'](_0x15f8ed=>{const _0x36b632=a0_0x22e1cc;console['error']('[wrapper]\x20Fatal\x20erro'+_0x36b632(0xab)+(_0x15f8ed?.['message']||String(_0x15f8ed))),process[_0x36b632(0xeb)](0x1);});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whalent/agent",
3
- "version": "0.3.108",
3
+ "version": "0.3.109",
4
4
  "description": "Stable wrapper for Whalent Agent core runtime",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -43,7 +43,7 @@
43
43
  "yaml": "^2.4.0"
44
44
  },
45
45
  "optionalDependencies": {
46
- "@whalent/agent-core": "0.3.108",
46
+ "@whalent/agent-core": "0.3.109",
47
47
  "node-pty": "^1.1.0"
48
48
  },
49
49
  "devDependencies": {