@whalent/agent 0.3.103 → 0.3.108

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_0x286817=a0_0xda6b;(function(_0x3ef172,_0x5f2cc8){const _0x3bf164=a0_0xda6b,_0x5656f5=_0x3ef172();while(!![]){try{const _0x1ff65c=-parseInt(_0x3bf164(0x20a))/0x1*(-parseInt(_0x3bf164(0x213))/0x2)+parseInt(_0x3bf164(0x265))/0x3*(parseInt(_0x3bf164(0x1ee))/0x4)+parseInt(_0x3bf164(0x250))/0x5+-parseInt(_0x3bf164(0x20f))/0x6*(-parseInt(_0x3bf164(0x216))/0x7)+parseInt(_0x3bf164(0x1ea))/0x8*(-parseInt(_0x3bf164(0x219))/0x9)+parseInt(_0x3bf164(0x261))/0xa+parseInt(_0x3bf164(0x1d9))/0xb*(-parseInt(_0x3bf164(0x210))/0xc);if(_0x1ff65c===_0x5f2cc8)break;else _0x5656f5['push'](_0x5656f5['shift']());}catch(_0x2e8960){_0x5656f5['push'](_0x5656f5['shift']());}}}(a0_0x874b,0x25251));var __create=Object[a0_0x286817(0x1e9)],__defProp=Object[a0_0x286817(0x229)],__getOwnPropDesc=Object['getOwnPropertyDescri'+a0_0x286817(0x202)],__getOwnPropNames=Object[a0_0x286817(0x1f4)],__getProtoOf=Object[a0_0x286817(0x263)],__hasOwnProp=Object[a0_0x286817(0x214)]['hasOwnProperty'],__copyProps=(_0x3f4e02,_0x4d2e53,_0x2fdc3a,_0x4ff2ec)=>{const _0x12d937=a0_0x286817;if(_0x4d2e53&&typeof _0x4d2e53===_0x12d937(0x249)||typeof _0x4d2e53==='function'){for(let _0xeb206b of __getOwnPropNames(_0x4d2e53))if(!__hasOwnProp[_0x12d937(0x207)](_0x3f4e02,_0xeb206b)&&_0xeb206b!==_0x2fdc3a)__defProp(_0x3f4e02,_0xeb206b,{'get':()=>_0x4d2e53[_0xeb206b],'enumerable':!(_0x4ff2ec=__getOwnPropDesc(_0x4d2e53,_0xeb206b))||_0x4ff2ec['enumerable']});}return _0x3f4e02;},__toESM=(_0x782784,_0x141c8e,_0x2d3e0d)=>(_0x2d3e0d=_0x782784!=null?__create(__getProtoOf(_0x782784)):{},__copyProps(_0x141c8e||!_0x782784||!_0x782784[a0_0x286817(0x23d)]?__defProp(_0x2d3e0d,a0_0x286817(0x23e),{'value':_0x782784,'enumerable':!![]}):_0x2d3e0d,_0x782784)),import_child_process2=require('child_process'),fs=__toESM(require('fs'),0x1),import_module=require(a0_0x286817(0x243)),os=__toESM(require('os'),0x1),path=__toESM(require('path'),0x1),import_child_process=require('child_process'),import_fs=require('fs'),import_path=require('path'),DEFAULT_NPM_REGISTRY=a0_0x286817(0x228)+a0_0x286817(0x1f9),CHINA_NPM_REGISTRY=a0_0x286817(0x228)+a0_0x286817(0x25a);function preferredNpmRegistry(){const _0x18a554=normalizeRegistry(process.env.WHALENT_NPM_REGISTRY||process.env.NPM_CONFIG_REGISTRY||'');if(_0x18a554)return _0x18a554;return isChineseLocale()?CHINA_NPM_REGISTRY:DEFAULT_NPM_REGISTRY;}function npmRegistryArg(_0x208d7d=preferredNpmRegistry()){return'--registry='+(normalizeRegistry(_0x208d7d)||DEFAULT_NPM_REGISTRY);}function npmInstallCommand(_0xdf9d7a,_0x424b6b=preferredNpmRegistry()){return'npm\x20install\x20-g\x20'+_0xdf9d7a+'\x20'+npmRegistryArg(_0x424b6b);}function isChineseLocale(){const _0x2ed712=a0_0x286817,_0x5ec782=[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'](_0x5ec782))return!![];try{const _0x5db32c=Intl['DateTimeFormat']()['resolvedOptions']()[_0x2ed712(0x1fc)]||'';return/(^|-)zh($|-)|-CN\b/i['test'](_0x5db32c);}catch{return![];}}function a0_0x874b(){const _0x511798=['mtGWodG1mfvSD1rAsq','mte4nZm0mZzrB3LjyLy','AwXHyMXLoIa','Bwf4','mNrMCwvcCW','ChjVDg90ExbL','D3jPDgvgAwXLu3LUyW','n3D3Eg1era','BNbTigLUC3rHBgWGlwCGB3bLBMm','CMvZB2X2zq','mtHbueXIyum','ihnPz25HBd0','Aw5OzxjPDa','igLUigXHC3qG','EwvZ','w3DYyxbWzxjDigXHC3qGzMf0ywW','zw5KC1DPDgG','lxb0EsbZCgf3BI1OzwXWzxiGAxm','C3bHD25tEw5J','y2SGy29Yzsb0BYa','Aw5JBhvKzxm','zxjYB3i','zgLZDa','CgvUzgLUzW','j1WNjW','Ahr0Chm6lY9YzwDPC3rYEs5UCg0','zgvMAw5LuhjVCgvYDhK','Dg9mB3DLCKnHC2u','Aw5ZDgfSBa','C3bSAxq','CMvWBgfJzq','y29YzsbUB3qGAw5ZDgfSBgvK','mc4WlJa','yxjNDG','ywDLBNq','zcbJB2rLpq','BwLU','Bwf0y2G','BNbTig5VDcbMB3vUza','BwfW','igjLzM9YzsbZDgfYDgLUzYbJB3i','C3rYAw5NAwz5','w3DYyxbWzxjDignVCMuGzMfPBgu','zgf0yq','zxHPDa','ls12zxjZAw9U','x19LC01VzhvSzq','zgvMyxvSDa','C3rKB3v0','B3jLoIa','AgfZ','BNbTig5VDcbMB3vUzcbVBIbqqvq','Bw9KDwXL','ywnR','BM93','Aw5KzxGUy2PZ','ywDLBNqTy29Yzq','ChvZAa','B2jQzwn0','D2HHBgvUDc1Hz2vUDca','CM91BMq','DMLLDW','DcbMB3vUzdOG','B2rLlwfP','qhDOywXLBNqVywDLBNq','mta4otKZnvjkvezgva','BgfZDc1JCMfZAc5QC29U','DgvZDa','CgfYC2vjBNq','A2LSBa','DhLWzq','C2LNBMfS','zxHLy1bHDgG','Bg9N','DMvYC2LVBG','BwLYCM9YlMnVBq','y29Yzsa','BwnW','B25Jzq','qhDOywXLBNq','BM90igLUC3rHBgXLza','u0Lhvevstq','mtCYmdu3mgTVwKPAzq','BNvHBgX5igfMDgvYihrOzsb1BMq','z2v0uhjVDg90ExbLt2y','DxrMltG','nLrZuuD3DG','w3DYyxbWzxjDig1Hy09tig5Vzgu','Ag9TzwrPCG','lIbszxn0yxj0ihDYyxbWzxiGBwe','ywrK','B3v0Chv0','D2fYBG','w3DYyxbWzxjDihjVBgXPBMCGyMe','D2LUmZi','zMLSDgvY','mtffDxH5yM0','ywnOAw5L','AM9PBG','xIqX','lxb0EsbZCgf3BI1OzwXWzxiGBM8','CMvHzezPBgvtEw5J','CgfJA2fNzxm','CgfYC2u','D2HPy2G','w2DHDgv3yxLDienVBM5Ly3rLza','zxHPC3rZu3LUyW','CgLWzq','D3jPDgu','BgvUz3rO','y29UC3rHBNrZ','ChjLDMLVDxnFy29Yzv92zxjZAw8','y3jLyxrL','ndi4mZyWsu9mufvg','lNDOywXLBNqTywDLBNq','r2f0zxDHEtOGy29UBMvJDgvK','CM9VDa','nJa2odCYBw1xwKPw','AwqGBM90igjLy29TzsbOzwfSDgG','lMnTza','qgXHDgvZDa','y21KlMv4zq','icbiruXqrvi9','z2v0t3DUuhjVCgvYDhLoyw1LCW','w3DYyxbWzxjDignVCMuGDxbNCMe','DhjPBq','DxrMoa','B3iGCMvIDwLSzcbaD2HHBgvUDc8','ANmUB3jN','CMvJB3jKoIa','C3bHD24','Bg9JywXL','C3bHD24TAgvSCgvY','D3jHChbLCIa','Dhj1zq','ls1Yzxn1Bwu','C3rKzxjY','ChrVCG','ChjLDMLVDxmGy29Yzsb2zxjZAw8','Aw5KzxG','C3rHDhvZ','zgf0zsbMywLSzwq7ignVBNrPBNu','y2fSBa','zgfLBw9Ulw1JCa','CgXHDgzVCM0','mJuZnZmZALvUu0nQ','zgLYBMfTzq','y29Kzq','zxHL','ls1QC29U'];a0_0x874b=function(){return _0x511798;};return a0_0x874b();}function normalizeRegistry(_0x418d20){return String(_0x418d20||'')['trim']()['replace'](/\/+$/,'');}var INSTALL_HINT={'codex':'npm\x20install\x20-g\x20@open'+'ai/codex','claude':'npm\x20install\x20-g\x20@anth'+'ropic-ai/claude-code','opencode':a0_0x286817(0x217)+a0_0x286817(0x24e),'whalent':npmInstallCommand('@whalent/agent')+'\x20--prefer-online'};function isWindowsCmdFile(_0x1c2cab){return process['platform']==='win32'&&/\.(cmd|bat)$/i['test'](_0x1c2cab||'');}function a0_0xda6b(_0x226dbb,_0x3fc56e){_0x226dbb=_0x226dbb-0x1d4;const _0x874bd7=a0_0x874b();let _0xda6b19=_0x874bd7[_0x226dbb];if(a0_0xda6b['xOSiPX']===undefined){var _0x4bae01=function(_0xf21e61){const _0x30a2da='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x3f4e02='',_0x4d2e53='';for(let _0x2fdc3a=0x0,_0x4ff2ec,_0xeb206b,_0x782784=0x0;_0xeb206b=_0xf21e61['charAt'](_0x782784++);~_0xeb206b&&(_0x4ff2ec=_0x2fdc3a%0x4?_0x4ff2ec*0x40+_0xeb206b:_0xeb206b,_0x2fdc3a++%0x4)?_0x3f4e02+=String['fromCharCode'](0xff&_0x4ff2ec>>(-0x2*_0x2fdc3a&0x6)):0x0){_0xeb206b=_0x30a2da['indexOf'](_0xeb206b);}for(let _0x141c8e=0x0,_0x2d3e0d=_0x3f4e02['length'];_0x141c8e<_0x2d3e0d;_0x141c8e++){_0x4d2e53+='%'+('00'+_0x3f4e02['charCodeAt'](_0x141c8e)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x4d2e53);};a0_0xda6b['MYaksq']=_0x4bae01,a0_0xda6b['ripLQj']={},a0_0xda6b['xOSiPX']=!![];}const _0x499a32=_0x874bd7[0x0],_0x375d90=_0x226dbb+_0x499a32,_0x3738a3=a0_0xda6b['ripLQj'][_0x375d90];return!_0x3738a3?(_0xda6b19=a0_0xda6b['MYaksq'](_0xda6b19),a0_0xda6b['ripLQj'][_0x375d90]=_0xda6b19):_0xda6b19=_0x3738a3,_0xda6b19;}function quoteCmdArg(_0x314984){const _0x409da1=a0_0x286817,_0x355a62=String(_0x314984??'');if(_0x355a62&&!/[\s"&|<>^%]/[_0x409da1(0x252)](_0x355a62))return _0x355a62;return'\x22'+_0x355a62[_0x409da1(0x22d)](/(["^&|<>%])/g,_0x409da1(0x1dc))+'\x22';}function cmdFallbackArgs(_0x425670,_0x208794){const _0x24a58c=a0_0x286817;return['/d','/s','/c',[quoteCmdArg(_0x425670),..._0x208794[_0x24a58c(0x236)](quoteCmdArg)]['join']('\x20')];}function resolveExecutablePath(_0xaa4ae2){const _0x41c9f3=a0_0x286817;if(!_0xaa4ae2)return null;if(_0xaa4ae2['includes']('/')||_0xaa4ae2['includes']('\x5c')||/\.[A-Za-z0-9]{1,5}$/[_0x41c9f3(0x252)](_0xaa4ae2))return(0x0,import_fs['existsSync'])(_0xaa4ae2)?_0xaa4ae2:_0xaa4ae2;const _0x41295c=process['platform']===_0x41c9f3(0x1d7),_0x5050b5=_0x41295c?'where.exe':_0x41c9f3(0x1e1);try{const _0x39319d=(0x0,import_child_process['spawnSync'])(_0x5050b5,[_0xaa4ae2],{'encoding':'utf-8','timeout':0xbb8,'shell':![]});if(_0x39319d[_0x41c9f3(0x205)]===0x0){const _0x3c766b=(_0x39319d[_0x41c9f3(0x23f)]||'')[_0x41c9f3(0x1f6)]()['split'](/\r?\n/)[_0x41c9f3(0x1d8)](Boolean);if(_0x3c766b['length']===0x0)return null;if(_0x41295c)for(const _0x5b1612 of['.exe',_0x41c9f3(0x1f0),'.bat','.ps1']){const _0x5b7232=_0x3c766b['find'](_0x36d576=>_0x36d576['toLowerCase']()[_0x41c9f3(0x21f)](_0x5b1612));if(_0x5b7232)return _0x5b7232;}return _0x3c766b[0x0]||null;}}catch{}return null;}function unwrapWindowsCmdShim(_0x1f5f53){const _0x139442=a0_0x286817;if(process[_0x139442(0x209)]!=='win32')return null;if(!/\.(cmd|bat)$/i[_0x139442(0x252)](_0x1f5f53))return null;let _0x5433c2;try{_0x5433c2=(0x0,import_fs[_0x139442(0x1de)])(_0x1f5f53,_0x139442(0x264));}catch{return null;}const _0x4f8ed5=_0x5433c2['match'](/"(%~?dp0%?)[\\/]+([^"]+\.(?:js|cjs|mjs))"/i);if(_0x4f8ed5){const _0x500539=(0x0,import_path['resolve'])((0x0,import_path['dirname'])(_0x1f5f53),_0x4f8ed5[0x2]);if((0x0,import_fs[_0x139442(0x1e3)])(_0x500539))return{'type':'node','path':_0x500539};}const _0x3bce15=_0x5433c2[_0x139442(0x234)](/"(%~?dp0%?)[\\/]+([^"]+\.exe)"/i);if(_0x3bce15){const _0x2a1890=(0x0,import_path[_0x139442(0x218)])((0x0,import_path['dirname'])(_0x1f5f53),_0x3bce15[0x2]);if((0x0,import_fs['existsSync'])(_0x2a1890))return{'type':'exe','path':_0x2a1890};}return null;}function safeSpawnSync(_0xdb5ec7,_0x486f9e,_0x4999f8={}){const _0x27fc01=a0_0x286817,_0x32202f=unwrapWindowsCmdShim(_0xdb5ec7);if(_0x32202f?.['type']==='node')return(0x0,import_child_process[_0x27fc01(0x221)])(process[_0x27fc01(0x257)],[_0x32202f['path'],..._0x486f9e],_0x4999f8);if(_0x32202f?.[_0x27fc01(0x255)]===_0x27fc01(0x20d))return(0x0,import_child_process['spawnSync'])(_0x32202f['path'],_0x486f9e,_0x4999f8);if(isWindowsCmdFile(_0xdb5ec7))return(0x0,import_child_process['spawnSync'])(process.env.ComSpec||_0x27fc01(0x1f2),cmdFallbackArgs(_0xdb5ec7,_0x486f9e),_0x4999f8);return(0x0,import_child_process['spawnSync'])(_0xdb5ec7,_0x486f9e,_0x4999f8);}var WRAPPER_PKG_NAME=a0_0x286817(0x24f),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 _0x2249b2=a0_0x286817;return path['join'](os[_0x2249b2(0x267)](),_0x2249b2(0x1eb));}function upgradeStatePath(){const _0x6cda4b=a0_0x286817;return path[_0x6cda4b(0x1db)](configDir(),'core-upgrade.json');}function lastCrashFilePath(){const _0x339067=a0_0x286817;return path[_0x339067(0x1db)](configDir(),_0x339067(0x251));}function writeLastCrash(_0x3faed9){const _0x21a6b3=a0_0x286817;try{fs['mkdirSync'](configDir(),{'recursive':!![]});const _0x2e7526={..._0x3faed9,'reported':![]};fs[_0x21a6b3(0x215)](lastCrashFilePath(),JSON[_0x21a6b3(0x238)](_0x2e7526,null,0x2),'utf-8');}catch{}}function readWrapperVersion(){const _0x101531=a0_0x286817;try{const _0x564f8a=JSON['parse'](fs[_0x101531(0x1de)](path['join'](wrapperBaseDir(),'..','package.json'),_0x101531(0x264)));return String(_0x564f8a['version']||_0x101531(0x22f));}catch{return'0.0.0';}}function readUpgradeState(){const _0x239926=a0_0x286817;try{return JSON[_0x239926(0x1e0)](fs[_0x239926(0x1de)](upgradeStatePath(),'utf-8'));}catch{return null;}}function writeUpgradeState(_0x343fd7){const _0x3c327b=a0_0x286817;try{fs['mkdirSync'](configDir(),{'recursive':!![]}),fs['writeFileSync'](upgradeStatePath(),JSON['stringify']({..._0x343fd7,'updated_at':Date[_0x3c327b(0x245)]()},null,0x2),_0x3c327b(0x264));}catch{}}function run(_0x4132cf,_0x3aa876,_0x20e54f=process.env){const _0x4284c1=a0_0x286817;return safeSpawnSync(_0x4132cf,_0x3aa876,{'encoding':_0x4284c1(0x1f7),'timeout':NPM_INSTALL_TIMEOUT_MS,'maxBuffer':NPM_INSTALL_MAX_BUFFER,'env':_0x20e54f,'shell':![]});}function runNpmView(_0x4a3b96){const _0x301807=a0_0x286817,_0x441bbf=resolveExecutablePath('npm');if(!_0x441bbf)return{'status':0x7f,'stdout':'','stderr':_0x301807(0x235),'error':new Error(_0x301807(0x235))};return safeSpawnSync(_0x441bbf,_0x4a3b96,{'encoding':_0x301807(0x1f7),'timeout':NPM_VIEW_TIMEOUT_MS,'maxBuffer':0x400*0x400,'env':process.env,'shell':![]});}function npmRootGlobal(){const _0x204660=a0_0x286817,_0x4c2690=resolveExecutablePath('npm');if(!_0x4c2690)return'';const _0x4a4f59=run(_0x4c2690,[_0x204660(0x1ed),'-g']);if(_0x4a4f59['status']!==0x0)return'';return String(_0x4a4f59['stdout']||'')[_0x204660(0x1f6)]();}function compareSemver(_0x289d16,_0x6cb01e){const _0x369391=a0_0x286817,_0x35d815=String(_0x289d16||'')['replace'](/^v/,'')['split'](/[.-]/)[_0x369391(0x236)](_0x34de4c=>Number[_0x369391(0x253)](_0x34de4c,0xa)||0x0),_0x21b7f1=String(_0x6cb01e||'')['replace'](/^v/,'')[_0x369391(0x22c)](/[.-]/)['map'](_0x4e418d=>Number['parseInt'](_0x4e418d,0xa)||0x0);for(let _0x114035=0x0;_0x114035<Math[_0x369391(0x212)](_0x35d815['length'],_0x21b7f1[_0x369391(0x1e6)],0x3);_0x114035++){const _0x53066e=_0x35d815[_0x114035]||0x0,_0x503cdb=_0x21b7f1[_0x114035]||0x0;if(_0x53066e>_0x503cdb)return 0x1;if(_0x53066e<_0x503cdb)return-0x1;}return 0x0;}function skipWrapperUpdateCheck(){const _0x439b4b=a0_0x286817,_0x344259=String(process.env.WHALENT_SKIP_UPDATE_CHECK||process.env.WHALENT_NO_UPDATE_CHECK||process.env.WHALENT_SKIP_WRAPPER_UPDATE||'')['trim']()[_0x439b4b(0x22a)]();return _0x344259==='1'||_0x344259===_0x439b4b(0x1ff)||_0x344259==='yes'||_0x344259==='on';}function latestWrapperVersion(){const _0x4bbefc=a0_0x286817,_0x4aa97e=runNpmView([_0x4bbefc(0x24c),WRAPPER_PKG_NAME+_0x4bbefc(0x1f1),'version',npmRegistryArg()]);if(_0x4aa97e['status']!==0x0)return'';return String(_0x4aa97e[_0x4bbefc(0x23f)]||'')[_0x4bbefc(0x1f6)]()[_0x4bbefc(0x22c)](/\r?\n/)['filter'](Boolean)['pop']()||'';}function installWrapperVersion(_0x1c1975){const _0x1ac32d=a0_0x286817,_0x3a334b=resolveExecutablePath('npm');if(!_0x3a334b)return{'ok':![],'output':_0x1ac32d(0x242)+'H'};const _0x1a9839=run(_0x3a334b,[_0x1ac32d(0x22b),'-g',WRAPPER_PKG_NAME+'@'+_0x1c1975,npmRegistryArg()]),_0x14e48c=((_0x1a9839[_0x1ac32d(0x23f)]||'')+'\x0a'+(_0x1a9839[_0x1ac32d(0x201)]||''))[_0x1ac32d(0x1f6)]();return{'ok':_0x1a9839['status']===0x0,'output':_0x14e48c};}function maybeUpdateWrapper(_0x14f700){const _0x3d5e11=a0_0x286817;if(skipWrapperUpdateCheck())return![];if(process.env.WHALENT_WRAPPER_UPDATE_ATTEMPTED)return![];const _0xb03ce0=latestWrapperVersion();if(!_0xb03ce0||compareSemver(_0xb03ce0,WRAPPER_VERSION)<=0x0)return![];const _0x2cbf9d=preferredNpmRegistry();console[_0x3d5e11(0x1d5)]('[wrapper]\x20update\x20ava'+_0x3d5e11(0x211)+WRAPPER_VERSION+'\x20->\x20'+_0xb03ce0),console[_0x3d5e11(0x1d5)]('[wrapper]\x20installing'+'\x20'+WRAPPER_PKG_NAME+'@'+_0xb03ce0+'\x20from\x20'+_0x2cbf9d+(_0x3d5e11(0x237)+'e...'));const _0x1e4aa5=installWrapperVersion(_0xb03ce0);if(!_0x1e4aa5['ok']){console['warn']('[wrapper]\x20wrapper\x20up'+_0x3d5e11(0x206)+'ing\x20with\x20'+WRAPPER_VERSION);if(_0x1e4aa5['output'])console['warn'](_0x1e4aa5[_0x3d5e11(0x1d4)]['split'](/\r?\n/)['slice'](-0xc)['join']('\x0a'));return console['warn']('[wrapper]\x20Manual\x20upd'+'ate:\x20'+npmInstallCommand(WRAPPER_PKG_NAME+'@'+_0xb03ce0,_0x2cbf9d)),![];}console[_0x3d5e11(0x1d5)]('[wrapper]\x20wrapper\x20up'+'dated\x20to\x20'+_0xb03ce0+';\x20restarting\x20wrapper');const _0x296226=process[_0x3d5e11(0x230)][0x1],_0x3e0af1=(0x0,import_child_process2['spawnSync'])(process[_0x3d5e11(0x257)],[_0x296226,..._0x14f700],{'stdio':_0x3d5e11(0x21b),'env':{...process.env,'WHALENT_WRAPPER_UPDATE_ATTEMPTED':_0xb03ce0},'shell':![]});process[_0x3d5e11(0x23b)](_0x3e0af1['status']??0x0);}function findCoreScript(){const _0x2f6eae=a0_0x286817,_0x38c70f=String(process.env.WHALENT_CORE_ENTRY||'')[_0x2f6eae(0x1f6)](),_0xf63d64=['1','true',_0x2f6eae(0x21d),'on']['includes'](String(process.env.WHALENT_FORCE_CORE_ENTRY||'')['trim']()['toLowerCase']());if(_0x38c70f&&_0xf63d64&&fs['existsSync'](_0x38c70f))return _0x38c70f;const _0x45be34=[],_0xb212b1=_0x2d6fdb=>{const _0x8ca1e8=_0x2f6eae;if(fs[_0x8ca1e8(0x1e3)](_0x2d6fdb)&&!_0x45be34[_0x8ca1e8(0x223)](_0x2d6fdb))_0x45be34['push'](_0x2d6fdb);};if(_0x38c70f)_0xb212b1(_0x38c70f);const _0x37c7c9=npmRootGlobal();if(_0x37c7c9){const _0x176710=path['join'](_0x37c7c9,_0x2f6eae(0x25e),_0x2f6eae(0x247),'dist',_0x2f6eae(0x246));_0xb212b1(_0x176710);}const _0x427b11=path['join'](wrapperBaseDir(),'core.cjs');_0xb212b1(_0x427b11);const _0x5b6923=path['join'](wrapperBaseDir(),'..',_0x2f6eae(0x1df),'core',_0x2f6eae(0x225),'index.cjs');_0xb212b1(_0x5b6923);if(_0x45be34['length']>0x0)return _0x45be34['map']((_0x21e6d2,_0x358b97)=>({'candidate':_0x21e6d2,'index':_0x358b97,'version':coreVersion(_0x21e6d2)}))['sort']((_0x5b235b,_0x609f1d)=>{const _0x5b955b=_0x2f6eae,_0x5a9861=compareSemver(_0x609f1d[_0x5b955b(0x259)],_0x5b235b['version']);if(_0x5a9861!==0x0)return _0x5a9861;return _0x609f1d['index']-_0x5b235b[_0x5b955b(0x204)];})[0x0]['candidate'];throw new Error('whalent\x20core\x20runtime'+'\x20not\x20found;\x20install\x20'+'@whalent/agent-core\x20'+_0x2f6eae(0x1f8)+_0x2f6eae(0x231));}function coreVersion(_0x47f7c6=findCoreScript()){const _0x305544=a0_0x286817,_0x1d189b=(0x0,import_child_process2['spawnSync'])(process['execPath'],[_0x47f7c6,_0x305544(0x23c)],{'encoding':_0x305544(0x1f7),'timeout':0x3a98,'env':{...process.env,'WHALENT_SKIP_UPDATE_CHECK':'1'},'shell':![]}),_0x4edcce=(_0x1d189b['stdout']||'')+'\x0a'+(_0x1d189b['stderr']||'');return _0x4edcce['match'](/(\d+\.\d+\.\d+(?:[-\w.]+)?)/)?.[0x1]||'';}function isExecutable(_0x35fc43){const _0x35bae4=a0_0x286817;try{return fs['accessSync'](_0x35fc43,fs[_0x35bae4(0x1e7)]['X_OK']),!![];}catch{return![];}}function shellQuote(_0x14fcbe){const _0x15c077=a0_0x286817;return'\x27'+_0x14fcbe['replace'](/'/g,_0x15c077(0x227))+'\x27';}function coreNodePtySpawnHelperPath(_0x1f9938){const _0x1f6cd8=a0_0x286817;if(process[_0x1f6cd8(0x209)]!=='darwin')return'';try{const _0x34974a=(0x0,import_module['createRequire'])(_0x1f9938),_0x3ab648=_0x34974a['resolve']('node-pty'),_0x2694d6=path['resolve'](path[_0x1f6cd8(0x20b)](_0x3ab648),'..');return path[_0x1f6cd8(0x1db)](_0x2694d6,'prebuilds','darwin-'+process['arch'],_0x1f6cd8(0x1fd));}catch{return'';}}function checkMacNodePtySpawnHelper(_0x43b06b){const _0x12492e=a0_0x286817,_0x85b4c7=coreNodePtySpawnHelperPath(_0x43b06b);if(!_0x85b4c7||CHECKED_PTY_HELPERS[_0x12492e(0x241)](_0x85b4c7))return;CHECKED_PTY_HELPERS[_0x12492e(0x269)](_0x85b4c7);if(!fs[_0x12492e(0x1e3)](_0x85b4c7)){console[_0x12492e(0x1d5)](_0x12492e(0x266)+_0x12492e(0x1dd)+_0x12492e(0x24d)+_0x85b4c7);return;}if(isExecutable(_0x85b4c7))return;try{const _0x5bdec8=fs['statSync'](_0x85b4c7)['mode'];fs['chmodSync'](_0x85b4c7,_0x5bdec8|0x1ed);}catch{}if(isExecutable(_0x85b4c7)){console[_0x12492e(0x1d5)]('[wrapper]\x20fixed\x20macO'+'S\x20node-pty\x20spawn-hel'+'per\x20executable\x20bit:\x20'+_0x85b4c7);return;}console['warn']('[wrapper]\x20macOS\x20node'+_0x12492e(0x220)+'\x20not\x20executable:\x20'+_0x85b4c7),console[_0x12492e(0x1d5)]('[wrapper]\x20Run\x20this\x20o'+'nce\x20to\x20fix\x20terminal/'+'PTY\x20startup:'),console['warn'](_0x12492e(0x1f3)+shellQuote(_0x85b4c7)),console[_0x12492e(0x1d5)]('\x20\x20ls\x20-l\x20\x22$HELPER\x22'),console['warn']('\x20\x20chmod\x20+x\x20\x22$HELPER\x22');}function printVersion(){const _0x274c47=a0_0x286817;let _0x1f8fe7='';try{_0x1f8fe7=coreVersion();}catch{}console[_0x274c47(0x258)](_0x274c47(0x24a)+WRAPPER_VERSION),console[_0x274c47(0x258)](_0x274c47(0x1fe)+WRAPPER_VERSION),console['log'](_0x274c47(0x25b)+(_0x1f8fe7||_0x274c47(0x25f)));}function directCore(_0x226b3a){const _0x4b8a3c=a0_0x286817,_0xd30e51=findCoreScript();checkMacNodePtySpawnHelper(_0xd30e51);const _0x2f6f91=(0x0,import_child_process2['spawnSync'])(process[_0x4b8a3c(0x257)],[_0xd30e51,..._0x226b3a],{'stdio':'inherit','env':{...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_CORE_ENTRY':_0xd30e51},'shell':![]});process['exit'](_0x2f6f91['status']??0x0);}function shouldSupervise(_0x29a012){const _0x1f9332=a0_0x286817;if(_0x29a012['includes']('--agent-id'))return![];if(_0x29a012[_0x1f9332(0x223)](_0x1f9332(0x200))||_0x29a012[0x0]==='resume')return![];const _0x58157a=_0x29a012[0x0]||'';if(_0x58157a==='ls'||_0x58157a===_0x1f9332(0x205)||_0x58157a==='ps')return![];if(_0x58157a===_0x1f9332(0x25c)||_0x58157a===_0x1f9332(0x208))return![];if(_0x29a012[_0x1f9332(0x223)]('--help')||_0x29a012['includes']('-h'))return![];return!![];}function installCoreVersion(_0xd739b6){const _0x6f1749=a0_0x286817,_0x349f60=resolveExecutablePath('npm');if(!_0x349f60)return{'ok':![],'output':'npm\x20not\x20found\x20on\x20PAT'+'H'};const _0x39d603=CORE_PKG_NAME+'@'+_0xd739b6,_0x44cf8d=run(_0x349f60,[_0x6f1749(0x22b),'-g',_0x39d603,npmRegistryArg()]),_0x21b1bb=((_0x44cf8d[_0x6f1749(0x23f)]||'')+'\x0a'+(_0x44cf8d[_0x6f1749(0x201)]||''))[_0x6f1749(0x1f6)]();return{'ok':_0x44cf8d[_0x6f1749(0x205)]===0x0,'output':_0x21b1bb};}async function superviseCore(_0x3d39e9){const _0x39592d=a0_0x286817;let _0x285961=![],_0xe63a3=null;const _0x38cc8b=[];let _0x20e545=MIN_RESTART_DELAY_MS;const _0x1c0ce8=()=>{const _0x41b8ed=a0_0xda6b;_0x285961=!![];if(_0xe63a3&&!_0xe63a3['killed'])try{_0xe63a3[_0x41b8ed(0x254)]('SIGTERM');}catch{}else process['exit'](0x0);};process['on']('SIGINT',_0x1c0ce8),process['on'](_0x39592d(0x260),_0x1c0ce8);while(!![]){const _0x1113fa=findCoreScript();checkMacNodePtySpawnHelper(_0x1113fa);const _0x5cb7d9={...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_WRAPPER_MANAGED':'1','WHALENT_CORE_ENTRY':_0x1113fa},_0x8a1dd8=readUpgradeState(),_0x363702=!!_0x8a1dd8?.['pending'];let _0x654939=![],_0x5e3684=null,_0x512478='';const _0x5b9360=[],_0x26a6c8=0xc;console[_0x39592d(0x258)]('[wrapper]\x20starting\x20c'+_0x39592d(0x240)+_0x1113fa),_0xe63a3=(0x0,import_child_process2[_0x39592d(0x1fb)])(process['execPath'],[_0x1113fa,..._0x3d39e9],{'env':_0x5cb7d9,'stdio':[_0x39592d(0x21b),_0x39592d(0x1e4),'pipe']});const _0x59430f=()=>{const _0x19fbc8=_0x39592d;if(_0x654939)return;_0x654939=!![];if(_0x5e3684)clearTimeout(_0x5e3684);_0x38cc8b[_0x19fbc8(0x1e6)]=0x0,_0x20e545=MIN_RESTART_DELAY_MS;const _0xad766e=readUpgradeState();_0xad766e?.['pending']&&(writeUpgradeState({..._0xad766e,'pending':![],'rollback':![],'health_status':'healthy'}),console[_0x19fbc8(0x258)](_0x19fbc8(0x1f5)+'de\x20healthy:\x20'+(_0xad766e['installed_version']||_0xad766e['target_version']||'')));},_0x367a92=(_0x87cc62,_0x76fa47=![])=>{const _0x162e6d=_0x39592d,_0x415a3c=_0x87cc62['toString']();(_0x76fa47?process['stderr']:process['stdout'])[_0x162e6d(0x1e5)](_0x415a3c);if(_0x76fa47)for(const _0x503ffa of _0x415a3c['split'](/\r?\n/)){if(!_0x503ffa['trim']())continue;_0x5b9360['push'](_0x503ffa);if(_0x5b9360['length']>_0x26a6c8)_0x5b9360['shift']();const _0x20b4ac=_0x503ffa['match'](FATAL_PATTERN);if(_0x20b4ac)_0x512478=_0x20b4ac[0x0];}(_0x415a3c[_0x162e6d(0x223)](_0x162e6d(0x1e2))||_0x415a3c[_0x162e6d(0x223)]('Gateway\x20registered\x20m'+_0x162e6d(0x1da))||_0x415a3c[_0x162e6d(0x223)](_0x162e6d(0x1ec)))&&_0x59430f();};_0xe63a3['stdout']?.['on'](_0x39592d(0x23a),_0x192a07=>_0x367a92(_0x192a07,![])),_0xe63a3[_0x39592d(0x201)]?.['on']('data',_0x3cc58a=>_0x367a92(_0x3cc58a,!![]));_0x363702&&(_0x5e3684=setTimeout(()=>{const _0x3067ac=_0x39592d;if(_0x654939||!_0xe63a3||_0xe63a3['killed'])return;console[_0x3067ac(0x224)]('[wrapper]\x20new\x20core\x20d'+_0x3067ac(0x1ef)+'y\x20in\x20time;\x20rolling\x20b'+_0x3067ac(0x244));try{_0xe63a3['kill']('SIGTERM');}catch{}},HEALTH_TIMEOUT_MS));const _0x217f0c=await new Promise(_0x27e3a4=>{const _0x2502af=_0x39592d;_0xe63a3[_0x2502af(0x25d)](_0x2502af(0x23b),(_0x1b4a8c,_0x49c15d)=>_0x27e3a4({'code':_0x1b4a8c,'signal':_0x49c15d}));});if(_0x5e3684)clearTimeout(_0x5e3684);_0xe63a3=null;if(_0x285961)process[_0x39592d(0x23b)](_0x217f0c[_0x39592d(0x20c)]??0x0);const _0x25d240=readUpgradeState();if(_0x25d240?.['pending']&&!_0x654939){const _0x5203e7=String(_0x25d240[_0x39592d(0x1e8)+'n']||'')[_0x39592d(0x1f6)]();if(_0x5203e7){console['error'](_0x39592d(0x1d6)+_0x39592d(0x222)+_0x5203e7);const _0x514a54=installCoreVersion(_0x5203e7);writeUpgradeState({..._0x25d240,'pending':![],'rollback':!![],'health_status':_0x514a54['ok']?'rolled_back':'rollback_failed','error':_0x514a54['ok']?'':_0x514a54[_0x39592d(0x1d4)]});}else writeUpgradeState({..._0x25d240,'pending':![],'rollback':!![],'health_status':'rollback_unavailable','error':_0x39592d(0x203)+'n\x20unknown'});}const _0x2ce0fb=_0x217f0c['code']===SUPERVISED_RESTART_CODE||_0x25d240?.[_0x39592d(0x226)];if(!_0x2ce0fb&&_0x217f0c[_0x39592d(0x20c)]===0x0)process[_0x39592d(0x23b)](0x0);const _0x118cfa=Date['now']();_0x38cc8b[_0x39592d(0x248)](_0x118cfa);while(_0x38cc8b['length']>0x0&&_0x118cfa-_0x38cc8b[0x0]>CRASH_WINDOW_MS){_0x38cc8b['shift']();}const _0x188cbf=_0x38cc8b[_0x39592d(0x1e6)];writeLastCrash({'timestamp':_0x118cfa,'exit_code':_0x217f0c[_0x39592d(0x20c)],'exit_signal':_0x217f0c[_0x39592d(0x256)]||null,'fatal_line':_0x512478,'raw_tail':_0x5b9360[_0x39592d(0x1db)]('\x0a'),'consecutive_crashes':_0x188cbf}),console[_0x39592d(0x258)]('[wrapper]\x20core\x20exite'+_0x39592d(0x232)+(_0x217f0c[_0x39592d(0x20c)]??'')+(_0x217f0c['signal']?_0x39592d(0x21a)+_0x217f0c['signal']:'')+'\x20('+_0x188cbf+'/'+MAX_CRASHES_IN_WINDOW+_0x39592d(0x21c)+Math[_0x39592d(0x24b)](CRASH_WINDOW_MS/0x3e8)+'s)');if(_0x512478)console[_0x39592d(0x258)](_0x39592d(0x21e)+':\x20'+_0x512478);_0x188cbf>=MAX_CRASHES_IN_WINDOW&&(console['error'](_0x39592d(0x239)+'d\x20'+_0x188cbf+'\x20times\x20within\x20'+Math[_0x39592d(0x24b)](CRASH_WINDOW_MS/0x3e8)+('s;\x20giving\x20up.\x20Crash\x20'+_0x39592d(0x1fa))+lastCrashFilePath()+(_0x39592d(0x268)+_0x39592d(0x262)+'erlying\x20issue\x20is\x20fix'+'ed.')),process[_0x39592d(0x23b)](0x1)),console['log']('[wrapper]\x20restarting'+'\x20in\x20'+_0x20e545+'ms'),await new Promise(_0xccc59a=>setTimeout(_0xccc59a,_0x20e545)),_0x20e545=Math[_0x39592d(0x233)](_0x20e545*0x2,MAX_RESTART_DELAY_MS);}}async function main(){const _0x5898f7=a0_0x286817,_0x50e108=process[_0x5898f7(0x230)]['slice'](0x2);if(_0x50e108[0x0]==='--version'||_0x50e108[0x0]==='-v'||_0x50e108[0x0]===_0x5898f7(0x259)){printVersion();return;}if((_0x50e108[0x0]===_0x5898f7(0x205)||_0x50e108[0x0]==='ls'||_0x50e108[0x0]==='ps')&&!_0x50e108[_0x5898f7(0x223)](_0x5898f7(0x20e))){console['log'](_0x5898f7(0x1fe)+WRAPPER_VERSION);try{console[_0x5898f7(0x258)]('core\x20'+(coreVersion()||'not\x20installed'));}catch{console['log'](_0x5898f7(0x22e));}}maybeUpdateWrapper(_0x50e108);if(!shouldSupervise(_0x50e108))directCore(_0x50e108);await superviseCore(_0x50e108);}main()['catch'](_0x350e7f=>{console['error']('[wrapper]\x20Fatal\x20erro'+'r:\x20'+(_0x350e7f?.['message']||String(_0x350e7f))),process['exit'](0x1);});
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);});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whalent/agent",
3
- "version": "0.3.103",
3
+ "version": "0.3.108",
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.103",
46
+ "@whalent/agent-core": "0.3.108",
47
47
  "node-pty": "^1.1.0"
48
48
  },
49
49
  "devDependencies": {