@whalent/agent 0.3.110 → 0.3.112

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_0x5eca0a=a0_0xeebc;(function(_0x6f0095,_0x108139){const _0x48aae5=a0_0xeebc,_0x328226=_0x6f0095();while(!![]){try{const _0x38f351=-parseInt(_0x48aae5(0x1ee))/0x1*(parseInt(_0x48aae5(0x24b))/0x2)+-parseInt(_0x48aae5(0x1e0))/0x3+-parseInt(_0x48aae5(0x246))/0x4+parseInt(_0x48aae5(0x227))/0x5*(-parseInt(_0x48aae5(0x25d))/0x6)+parseInt(_0x48aae5(0x200))/0x7*(parseInt(_0x48aae5(0x25f))/0x8)+parseInt(_0x48aae5(0x20a))/0x9+parseInt(_0x48aae5(0x233))/0xa;if(_0x38f351===_0x108139)break;else _0x328226['push'](_0x328226['shift']());}catch(_0x98ffe1){_0x328226['push'](_0x328226['shift']());}}}(a0_0x568a,0x8f0a7));var __create=Object['create'],__defProp=Object['defineProperty'],__getOwnPropDesc=Object['getOwnPropertyDescri'+'ptor'],__getOwnPropNames=Object['getOwnPropertyNames'],__getProtoOf=Object['getPrototypeOf'],__hasOwnProp=Object['prototype'][a0_0x5eca0a(0x255)],__copyProps=(_0x31669e,_0x396836,_0x58e8bc,_0x114cab)=>{const _0x3c79e5=a0_0x5eca0a;if(_0x396836&&typeof _0x396836==='object'||typeof _0x396836===_0x3c79e5(0x1f8)){for(let _0x535ce2 of __getOwnPropNames(_0x396836))if(!__hasOwnProp['call'](_0x31669e,_0x535ce2)&&_0x535ce2!==_0x58e8bc)__defProp(_0x31669e,_0x535ce2,{'get':()=>_0x396836[_0x535ce2],'enumerable':!(_0x114cab=__getOwnPropDesc(_0x396836,_0x535ce2))||_0x114cab['enumerable']});}return _0x31669e;},__toESM=(_0x3b09d6,_0x1db8e1,_0x791f49)=>(_0x791f49=_0x3b09d6!=null?__create(__getProtoOf(_0x3b09d6)):{},__copyProps(_0x1db8e1||!_0x3b09d6||!_0x3b09d6['__esModule']?__defProp(_0x791f49,'default',{'value':_0x3b09d6,'enumerable':!![]}):_0x791f49,_0x3b09d6)),import_child_process2=require(a0_0x5eca0a(0x229)),fs=__toESM(require('fs'),0x1),import_module=require(a0_0x5eca0a(0x22d)),os=__toESM(require('os'),0x1),path=__toESM(require(a0_0x5eca0a(0x216)),0x1),import_child_process=require('child_process'),import_fs=require('fs'),import_path=require(a0_0x5eca0a(0x216)),DEFAULT_NPM_REGISTRY='https://registry.npm'+a0_0x5eca0a(0x1fa),CHINA_NPM_REGISTRY='https://registry.npm'+a0_0x5eca0a(0x231);function preferredNpmRegistry(){const _0x1a4f38=normalizeRegistry(process.env.WHALENT_NPM_REGISTRY||process.env.NPM_CONFIG_REGISTRY||'');if(_0x1a4f38)return _0x1a4f38;return isChineseLocale()?CHINA_NPM_REGISTRY:DEFAULT_NPM_REGISTRY;}function npmRegistryArg(_0x34b3fc=preferredNpmRegistry()){return'--registry='+(normalizeRegistry(_0x34b3fc)||DEFAULT_NPM_REGISTRY);}function npmInstallCommand(_0x3efe81,_0x462734=preferredNpmRegistry()){return'npm\x20install\x20-g\x20'+_0x3efe81+'\x20'+npmRegistryArg(_0x462734);}function isChineseLocale(){const _0xb1b800=a0_0x5eca0a,_0x322067=[process.env.LC_ALL,process.env.LC_MESSAGES,process.env.LANG,process.env.LANGUAGE]['filter'](Boolean)[_0xb1b800(0x1f0)]('\x20');if(/(^|[_.-])zh([_.-]|$)|chinese|china|cn\b/i[_0xb1b800(0x202)](_0x322067))return!![];try{const _0x29b278=Intl[_0xb1b800(0x1f4)]()[_0xb1b800(0x24c)]()['locale']||'';return/(^|-)zh($|-)|-CN\b/i['test'](_0x29b278);}catch{return![];}}function normalizeRegistry(_0x373c19){const _0x51d01d=a0_0x5eca0a;return String(_0x373c19||'')[_0x51d01d(0x1fc)]()['replace'](/\/+$/,'');}var INSTALL_HINT={'codex':a0_0x5eca0a(0x1ec)+'ai/codex','claude':'npm\x20install\x20-g\x20@anth'+'ropic-ai/claude-code','opencode':'npm\x20install\x20-g\x20openc'+'ode-ai','whalent':npmInstallCommand('@whalent/agent')+a0_0x5eca0a(0x238)};function isWindowsCmdFile(_0x3553fc){const _0x398010=a0_0x5eca0a;return process[_0x398010(0x245)]==='win32'&&/\.(cmd|bat)$/i[_0x398010(0x202)](_0x3553fc||'');}function quoteCmdArg(_0x95d5fc){const _0x58f390=String(_0x95d5fc??'');if(_0x58f390&&!/[\s"&|<>^%]/['test'](_0x58f390))return _0x58f390;return'\x22'+_0x58f390['replace'](/(["^&|<>%])/g,'^$1')+'\x22';}function a0_0x568a(){const _0x35f4f4=['CMvZB2X2zq','y2HPBgrFChjVy2vZCW','w3DYyxbWzxjDignVCMuGDxbNCMe','Cg9W','Bwf4','Bw9KDwXL','C3bHD25tEw5J','zxHPDa','lNDOywXLBNqTywDLBNq','BwLYCM9YlMnVBq','A2LSBa','mJC2ody2mdbwqxDUsxO','zxHLy1bHDgG','ihrPBwvZihDPDgHPBIa','w3DYyxbWzxjDigLUC3rHBgXPBMC','BNbTig5VDcbMB3vUzcbVBIbqqvq','ic0TChjLzMvYlw9UBgLUzq','zgf0zwqGDg8G','CM9VDa','igLUia','D2HPy2G','Dhj1zq','zxHPC3rZu3LUyW','ChjLDMLVDxmGy29Yzsb2zxjZAw8','y29Yzq','qhDOywXLBNqVywDLBNqTy29Yzsa','w3DYyxbWzxjDig1Hy09tig5Vzgu','w3DYyxbWzxjDignVCMuGzxHPDgu','zgLZDa','CgXHDgzVCM0','mZqZmJm4neTuEfHxDG','ywnOAw5L','DMvYC2LVBG','C3rKB3v0','CgvUzgLUzW','mtG4tezLsKDH','CMvZB2X2zwrpChrPB25Z','B3v0Chv0','D3jHChbLCIa','C3bHD24','DhLWzq','D2HLCMuUzxHL','w3DYyxbWzxjDiezHDgfSigvYCM8','C3bSAxq','ls12zxjZAw9U','AgfZt3DUuhjVCgvYDhK','CMvHzezPBgvtEw5J','zxjYB3i','uYbUB2rLlxb0EsbZCgf3BI1OzwW','CZSGz2L2Aw5NihvWlIbdCMfZAca','Aw5ZDgfSBgvKx3zLCNnPB24','BM90igLUC3rHBgXLza','BgvUz3rO','ntCWD0T0vKXe','D3jPDgu','mZj6qufIANu','C3rYAw5NAwz5','DxrMltG','u0Lhsu5u','y21KlMv4zq','Aw5KzxG','mJG2mJa3mNLfBuHsyG','ChvZAa','D3jPDgvgAwXLu3LUyW','BNbT','zxjSEwLUzYbPC3n1zsbPCYbMAxG','D2HHBgvUDc1Hz2vUDca','CgLWzq','w2DHDgv3yxLDienVBM5Ly3rLza','Aw5JBhvKzxm','C3rKzxjY','BwfW','y29Yzs11CgDYywrLlMPZB24','BNbTigLUC3rHBgWGlwCGqg9Wzw4','CgfYC2u','ntm1m2rPrfH2tq','zgfYD2LU','AM9PBG','lNbZmq','B3iGCMvIDwLSzcbaD2HHBgvUDc8','zgfLBw9Ulw1JCa','rgf0zvrPBwvgB3jTyxq','mc4WlJa','BwTKAxjtEw5J','igzYB20G','zNvUy3rPB24','Dg9mB3DLCKnHC2u','ANmUB3jN','w3DYyxbWzxjDihDYyxbWzxiGDxa','DhjPBq','y29YzsbUB3qGAw5ZDgfSBgvK','BM93','qhDOywXLBNq','nZCYmZaZBg9evxHO','w3DYyxbWzxjDihvWzgf0zsbHDMe','DgvZDa','EwvZ','AgvHBhrOEq','zguGAgvHBhrOEtOG','y2HTB2rtEw5J','Aw5KzxGUy2PZ','y29Kzq','CgfYC2vjBNq','ndG3nda5nhPrAg5gBW','EsbPBIb0Aw1LoYbYB2XSAw5Nigi','C3rHDhvZ','BgfZDc1JCMfZAc5QC29U','icbJAg1VzcaREcaIjeHftfbfuIi','y29Yzs5JANm','C3bHD24TAgvSCgvY','Ag9TzwrPCG','CM91BMq','Aw5ZDgfSBa','qhDOywXLBNqVywDLBNq','w3DYyxbWzxjDigXHC3qGzMf0ywW','Cgf0Aa','Bg9N','ywDLBNqTy29Yzq','zgf0yq','zMLSDgvY','DgfYz2v0x3zLCNnPB24','DxrMoa','icbSCYaTBcaIjeHftfbfuIi','igLUigXHC3qG','CMvZDw1L','u0Lhvevstq','BwLU','D2fYBG','C2HPzNq','qhDOywXLBNqVywDLBNqTy29Yzq','D2HHBgvUDcbJB3jLihj1BNrPBwu','icbiruXqrvi9','ndq3ntveCu9IBgm'];a0_0x568a=function(){return _0x35f4f4;};return a0_0x568a();}function cmdFallbackArgs(_0x25584f,_0x453179){const _0x2550b4=a0_0x5eca0a;return['/d','/s','/c',[quoteCmdArg(_0x25584f),..._0x453179[_0x2550b4(0x1ea)](quoteCmdArg)][_0x2550b4(0x1f0)]('\x20')];}function resolveExecutablePath(_0x4e6934){const _0x156a2d=a0_0x5eca0a;if(!_0x4e6934)return null;if(_0x4e6934['includes']('/')||_0x4e6934['includes']('\x5c')||/\.[A-Za-z0-9]{1,5}$/[_0x156a2d(0x202)](_0x4e6934))return(0x0,import_fs[_0x156a2d(0x23e)])(_0x4e6934)?_0x4e6934:_0x4e6934;const _0x26d944=process['platform']==='win32',_0x1d6282=_0x26d944?_0x156a2d(0x251):_0x156a2d(0x23c);try{const _0x5635c0=(0x0,import_child_process[_0x156a2d(0x22e)])(_0x1d6282,[_0x4e6934],{'encoding':_0x156a2d(0x1dc),'timeout':0xbb8,'shell':![]});if(_0x5635c0[_0x156a2d(0x20c)]===0x0){const _0x3827b7=(_0x5635c0['stdout']||'')[_0x156a2d(0x1fc)]()[_0x156a2d(0x253)](/\r?\n/)[_0x156a2d(0x21a)](Boolean);if(_0x3827b7['length']===0x0)return null;if(_0x26d944)for(const _0x46195b of['.exe','.cmd','.bat',_0x156a2d(0x1f1)]){const _0x1d0e64=_0x3827b7['find'](_0x457e78=>_0x457e78[_0x156a2d(0x1f9)]()['endsWith'](_0x46195b));if(_0x1d0e64)return _0x1d0e64;}return _0x3827b7[0x0]||null;}}catch{}return null;}function unwrapWindowsCmdShim(_0x3cb8e6){const _0x289ec1=a0_0x5eca0a;if(process['platform']!=='win32')return null;if(!/\.(cmd|bat)$/i['test'](_0x3cb8e6))return null;let _0x54ea47;try{_0x54ea47=(0x0,import_fs[_0x289ec1(0x256)])(_0x3cb8e6,'utf-8');}catch{return null;}const _0x348ea9=_0x54ea47['match'](/"(%~?dp0%?)[\\/]+([^"]+\.(?:js|cjs|mjs))"/i);if(_0x348ea9){const _0x4adbad=(0x0,import_path['resolve'])((0x0,import_path['dirname'])(_0x3cb8e6),_0x348ea9[0x2]);if((0x0,import_fs['existsSync'])(_0x4adbad))return{'type':'node','path':_0x4adbad};}const _0x21e12f=_0x54ea47['match'](/"(%~?dp0%?)[\\/]+([^"]+\.exe)"/i);if(_0x21e12f){const _0x33d2a0=(0x0,import_path['resolve'])((0x0,import_path['dirname'])(_0x3cb8e6),_0x21e12f[0x2]);if((0x0,import_fs['existsSync'])(_0x33d2a0))return{'type':'exe','path':_0x33d2a0};}return null;}function a0_0xeebc(_0x190bed,_0x2d9e1e){_0x190bed=_0x190bed-0x1db;const _0x568a9f=a0_0x568a();let _0xeebcc8=_0x568a9f[_0x190bed];if(a0_0xeebc['BEwDWg']===undefined){var _0x56724d=function(_0x6f0569){const _0x2209c5='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x31669e='',_0x396836='';for(let _0x58e8bc=0x0,_0x114cab,_0x535ce2,_0x3b09d6=0x0;_0x535ce2=_0x6f0569['charAt'](_0x3b09d6++);~_0x535ce2&&(_0x114cab=_0x58e8bc%0x4?_0x114cab*0x40+_0x535ce2:_0x535ce2,_0x58e8bc++%0x4)?_0x31669e+=String['fromCharCode'](0xff&_0x114cab>>(-0x2*_0x58e8bc&0x6)):0x0){_0x535ce2=_0x2209c5['indexOf'](_0x535ce2);}for(let _0x1db8e1=0x0,_0x791f49=_0x31669e['length'];_0x1db8e1<_0x791f49;_0x1db8e1++){_0x396836+='%'+('00'+_0x31669e['charCodeAt'](_0x1db8e1)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x396836);};a0_0xeebc['QFsPqr']=_0x56724d,a0_0xeebc['FHEFUN']={},a0_0xeebc['BEwDWg']=!![];}const _0x6b909a=_0x568a9f[0x0],_0x2af412=_0x190bed+_0x6b909a,_0x4970ca=a0_0xeebc['FHEFUN'][_0x2af412];return!_0x4970ca?(_0xeebcc8=a0_0xeebc['QFsPqr'](_0xeebcc8),a0_0xeebc['FHEFUN'][_0x2af412]=_0xeebcc8):_0xeebcc8=_0x4970ca,_0xeebcc8;}function safeSpawnSync(_0x80c4c1,_0x5aa8c9,_0x11f36f={}){const _0x46cd67=a0_0x5eca0a,_0x4073b7=unwrapWindowsCmdShim(_0x80c4c1);if(_0x4073b7?.['type']==='node')return(0x0,import_child_process['spawnSync'])(process['execPath'],[_0x4073b7[_0x46cd67(0x216)],..._0x5aa8c9],_0x11f36f);if(_0x4073b7?.[_0x46cd67(0x250)]==='exe')return(0x0,import_child_process[_0x46cd67(0x22e)])(_0x4073b7['path'],_0x5aa8c9,_0x11f36f);if(isWindowsCmdFile(_0x80c4c1))return(0x0,import_child_process['spawnSync'])(process.env.ComSpec||_0x46cd67(0x1de),cmdFallbackArgs(_0x80c4c1,_0x5aa8c9),_0x11f36f);return(0x0,import_child_process[_0x46cd67(0x22e)])(_0x80c4c1,_0x5aa8c9,_0x11f36f);}var WRAPPER_PKG_NAME=a0_0x5eca0a(0x214),CORE_PKG_NAME=a0_0x5eca0a(0x224),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 _0x576b95=a0_0x5eca0a;return path['join'](os[_0x576b95(0x211)](),_0x576b95(0x230));}function upgradeStatePath(){const _0x564e75=a0_0x5eca0a;return path['join'](configDir(),_0x564e75(0x1eb));}function lastCrashFilePath(){const _0x4e7747=a0_0x5eca0a;return path[_0x4e7747(0x1f0)](configDir(),_0x4e7747(0x20d));}function writeLastCrash(_0x3c8420){const _0x1add86=a0_0x5eca0a;try{fs['mkdirSync'](configDir(),{'recursive':!![]});const _0x206c81={..._0x3c8420,'reported':![]};fs[_0x1add86(0x1e2)](lastCrashFilePath(),JSON['stringify'](_0x206c81,null,0x2),_0x1add86(0x1dc));}catch{}}function readWrapperVersion(){const _0x58a3bd=a0_0x5eca0a;try{const _0x1713f1=JSON['parse'](fs['readFileSync'](path['join'](wrapperBaseDir(),'..','package.json'),_0x58a3bd(0x1dc)));return String(_0x1713f1[_0x58a3bd(0x248)]||_0x58a3bd(0x1f5));}catch{return _0x58a3bd(0x1f5);}}function readUpgradeState(){const _0x400047=a0_0x5eca0a;try{return JSON[_0x400047(0x1ed)](fs['readFileSync'](upgradeStatePath(),_0x400047(0x1dc)));}catch{return null;}}function writeUpgradeState(_0x12c2ea){const _0x177e5d=a0_0x5eca0a;try{fs[_0x177e5d(0x1f6)](configDir(),{'recursive':!![]}),fs['writeFileSync'](upgradeStatePath(),JSON[_0x177e5d(0x1db)]({..._0x12c2ea,'updated_at':Date['now']()},null,0x2),'utf-8');}catch{}}function run(_0x1299c6,_0x51571a,_0x308a8d=process.env){return safeSpawnSync(_0x1299c6,_0x51571a,{'encoding':'utf8','timeout':NPM_INSTALL_TIMEOUT_MS,'maxBuffer':NPM_INSTALL_MAX_BUFFER,'env':_0x308a8d,'shell':![]});}function runNpmView(_0x459bd6){const _0x5155ad=a0_0x5eca0a,_0x14f29c=resolveExecutablePath(_0x5155ad(0x1e3));if(!_0x14f29c)return{'status':0x7f,'stdout':'','stderr':'npm\x20not\x20found','error':new Error('npm\x20not\x20found')};return safeSpawnSync(_0x14f29c,_0x459bd6,{'encoding':_0x5155ad(0x21c),'timeout':NPM_VIEW_TIMEOUT_MS,'maxBuffer':0x400*0x400,'env':process.env,'shell':![]});}function npmRootGlobal(){const _0x23246e=a0_0x5eca0a,_0x258d6e=resolveExecutablePath('npm');if(!_0x258d6e)return'';const _0x30da22=run(_0x258d6e,[_0x23246e(0x23a),'-g']);if(_0x30da22['status']!==0x0)return'';return String(_0x30da22['stdout']||'')['trim']();}function compareSemver(_0x1d0880,_0x1aaa7f){const _0x54f5a9=a0_0x5eca0a,_0xa94c0b=String(_0x1d0880||'')['replace'](/^v/,'')['split'](/[.-]/)['map'](_0x7a3f05=>Number[_0x54f5a9(0x209)](_0x7a3f05,0xa)||0x0),_0x152abe=String(_0x1aaa7f||'')['replace'](/^v/,'')[_0x54f5a9(0x253)](/[.-]/)['map'](_0x5173a2=>Number[_0x54f5a9(0x209)](_0x5173a2,0xa)||0x0);for(let _0x5c4cd2=0x0;_0x5c4cd2<Math[_0x54f5a9(0x22c)](_0xa94c0b[_0x54f5a9(0x25c)],_0x152abe['length'],0x3);_0x5c4cd2++){const _0x36cc5e=_0xa94c0b[_0x5c4cd2]||0x0,_0x550a08=_0x152abe[_0x5c4cd2]||0x0;if(_0x36cc5e>_0x550a08)return 0x1;if(_0x36cc5e<_0x550a08)return-0x1;}return 0x0;}function skipWrapperUpdateCheck(){const _0x137c1b=a0_0x5eca0a,_0x4ce261=String(process.env.WHALENT_SKIP_UPDATE_CHECK||process.env.WHALENT_NO_UPDATE_CHECK||process.env.WHALENT_SKIP_WRAPPER_UPDATE||'')['trim']()[_0x137c1b(0x1f9)]();return _0x4ce261==='1'||_0x4ce261==='true'||_0x4ce261==='yes'||_0x4ce261==='on';}function latestWrapperVersion(){const _0x27f074=a0_0x5eca0a,_0x530e75=runNpmView(['view',WRAPPER_PKG_NAME+'@latest',_0x27f074(0x248),npmRegistryArg()]);if(_0x530e75[_0x27f074(0x20c)]!==0x0)return'';return String(_0x530e75['stdout']||'')[_0x27f074(0x1fc)]()['split'](/\r?\n/)['filter'](Boolean)[_0x27f074(0x22b)]()||'';}function installWrapperVersion(_0x3cb400){const _0x1650d5=a0_0x5eca0a,_0x4f370e=resolveExecutablePath('npm');if(!_0x4f370e)return{'ok':![],'output':_0x1650d5(0x237)+'H'};const _0x134275=run(_0x4f370e,['install','-g',WRAPPER_PKG_NAME+'@'+_0x3cb400,npmRegistryArg()]),_0x56f83d=((_0x134275[_0x1650d5(0x249)]||'')+'\x0a'+(_0x134275['stderr']||''))['trim']();return{'ok':_0x134275[_0x1650d5(0x20c)]===0x0,'output':_0x56f83d};}function maybeUpdateWrapper(_0x5ef6bf){const _0x4329f2=a0_0x5eca0a;if(skipWrapperUpdateCheck())return![];if(process.env.WHALENT_WRAPPER_UPDATE_ATTEMPTED)return![];const _0x4d5bf0=latestWrapperVersion();if(!_0x4d5bf0||compareSemver(_0x4d5bf0,WRAPPER_VERSION)<=0x0)return![];const _0x28f723=preferredNpmRegistry();console['warn'](_0x4329f2(0x201)+'ilable:\x20'+WRAPPER_VERSION+'\x20->\x20'+_0x4d5bf0),console[_0x4329f2(0x222)](_0x4329f2(0x236)+'\x20'+WRAPPER_PKG_NAME+'@'+_0x4d5bf0+_0x4329f2(0x1f7)+_0x28f723+('\x20before\x20starting\x20cor'+'e...'));const _0xb91ac6=installWrapperVersion(_0x4d5bf0);if(!_0xb91ac6['ok']){console['warn']('[wrapper]\x20wrapper\x20up'+'date\x20failed;\x20continu'+'ing\x20with\x20'+WRAPPER_VERSION);if(_0xb91ac6[_0x4329f2(0x24d)])console['warn'](_0xb91ac6[_0x4329f2(0x24d)][_0x4329f2(0x253)](/\r?\n/)['slice'](-0xc)['join']('\x0a'));return console[_0x4329f2(0x222)]('[wrapper]\x20Manual\x20upd'+'ate:\x20'+npmInstallCommand(WRAPPER_PKG_NAME+'@'+_0x4d5bf0,_0x28f723)),![];}console[_0x4329f2(0x222)](_0x4329f2(0x1fb)+_0x4329f2(0x239)+_0x4d5bf0+';\x20restarting\x20wrapper');const _0x19b07b=process['argv'][0x1],_0x2681a3=(0x0,import_child_process2[_0x4329f2(0x22e)])(process[_0x4329f2(0x234)],[_0x19b07b,..._0x5ef6bf],{'stdio':'inherit','env':{...process.env,'WHALENT_WRAPPER_UPDATE_ATTEMPTED':_0x4d5bf0},'shell':![]});process[_0x4329f2(0x22f)](_0x2681a3[_0x4329f2(0x20c)]??0x0);}function findCoreScript(){const _0x5e8998=a0_0x5eca0a,_0x369eb3=String(process.env.WHALENT_CORE_ENTRY||'')['trim'](),_0x1fe972=['1',_0x5e8998(0x23d),_0x5e8998(0x203),'on']['includes'](String(process.env.WHALENT_FORCE_CORE_ENTRY||'')['trim']()['toLowerCase']());if(_0x369eb3&&_0x1fe972&&fs[_0x5e8998(0x23e)](_0x369eb3))return _0x369eb3;const _0x7916a4=[],_0x2f4095=_0xd8f15f=>{const _0x1a2552=_0x5e8998;if(fs[_0x1a2552(0x23e)](_0xd8f15f)&&!_0x7916a4['includes'](_0xd8f15f))_0x7916a4['push'](_0xd8f15f);};if(_0x369eb3)_0x2f4095(_0x369eb3);const _0xf539bc=npmRootGlobal();if(_0xf539bc){const _0x4b177f=path['join'](_0xf539bc,_0x5e8998(0x1ff),_0x5e8998(0x218),_0x5e8998(0x244),_0x5e8998(0x207));_0x2f4095(_0x4b177f);}const _0x53dd3e=path['join'](wrapperBaseDir(),_0x5e8998(0x20f));_0x2f4095(_0x53dd3e);const _0x29f34d=path[_0x5e8998(0x1f0)](wrapperBaseDir(),'..','packages',_0x5e8998(0x240),_0x5e8998(0x244),'index.cjs');_0x2f4095(_0x29f34d);if(_0x7916a4[_0x5e8998(0x25c)]>0x0)return _0x7916a4[_0x5e8998(0x1ea)]((_0x18c9c4,_0x32f907)=>({'candidate':_0x18c9c4,'index':_0x32f907,'version':coreVersion(_0x18c9c4)}))['sort']((_0x5ebccc,_0x5112b9)=>{const _0x38caf3=_0x5e8998,_0x175e8d=compareSemver(_0x5112b9[_0x38caf3(0x248)],_0x5ebccc[_0x38caf3(0x248)]);if(_0x175e8d!==0x0)return _0x175e8d;return _0x5112b9[_0x38caf3(0x1df)]-_0x5ebccc['index'];})[0x0]['candidate'];throw new Error(_0x5e8998(0x225)+'\x20not\x20found;\x20install\x20'+_0x5e8998(0x241)+_0x5e8998(0x1f2)+'agent');}function coreVersion(_0x5d9e1e=findCoreScript()){const _0xd488ef=a0_0x5eca0a,_0x114189=(0x0,import_child_process2['spawnSync'])(process[_0xd488ef(0x234)],[_0x5d9e1e,_0xd488ef(0x254)],{'encoding':_0xd488ef(0x21c),'timeout':0x3a98,'env':{...process.env,'WHALENT_SKIP_UPDATE_CHECK':'1'},'shell':![]}),_0x2289c5=(_0x114189[_0xd488ef(0x249)]||'')+'\x0a'+(_0x114189['stderr']||'');return _0x2289c5['match'](/(\d+\.\d+\.\d+(?:[-\w.]+)?)/)?.[0x1]||'';}function isExecutable(_0x3c84d4){try{return fs['accessSync'](_0x3c84d4,fs['constants']['X_OK']),!![];}catch{return![];}}function shellQuote(_0x960c81){return'\x27'+_0x960c81['replace'](/'/g,'\x27\x5c\x27\x27')+'\x27';}function coreNodePtySpawnHelperPath(_0x24213f){const _0x1d31c8=a0_0x5eca0a;if(process[_0x1d31c8(0x245)]!==_0x1d31c8(0x1ef))return'';try{const _0xa2a29d=(0x0,import_module['createRequire'])(_0x24213f),_0x2d846b=_0xa2a29d['resolve']('node-pty'),_0x54972a=path[_0x1d31c8(0x228)](path['dirname'](_0x2d846b),'..');return path['join'](_0x54972a,'prebuilds','darwin-'+process['arch'],_0x1d31c8(0x210));}catch{return'';}}function checkMacNodePtySpawnHelper(_0x5754cc){const _0x498e38=a0_0x5eca0a,_0xe079ef=coreNodePtySpawnHelperPath(_0x5754cc);if(!_0xe079ef||CHECKED_PTY_HELPERS['has'](_0xe079ef))return;CHECKED_PTY_HELPERS['add'](_0xe079ef);if(!fs['existsSync'](_0xe079ef)){console['warn'](_0x498e38(0x242)+'-pty\x20spawn-helper\x20no'+'t\x20found:\x20'+_0xe079ef);return;}if(isExecutable(_0xe079ef))return;try{const _0x4bf345=fs['statSync'](_0xe079ef)['mode'];fs[_0x498e38(0x206)](_0xe079ef,_0x4bf345|0x1ed);}catch{}if(isExecutable(_0xe079ef)){console[_0x498e38(0x222)]('[wrapper]\x20fixed\x20macO'+_0x498e38(0x258)+'per\x20executable\x20bit:\x20'+_0xe079ef);return;}console[_0x498e38(0x222)]('[wrapper]\x20macOS\x20node'+'-pty\x20spawn-helper\x20is'+'\x20not\x20executable:\x20'+_0xe079ef),console['warn']('[wrapper]\x20Run\x20this\x20o'+'nce\x20to\x20fix\x20terminal/'+'PTY\x20startup:'),console['warn'](_0x498e38(0x226)+shellQuote(_0xe079ef)),console[_0x498e38(0x222)](_0x498e38(0x21d)),console['warn'](_0x498e38(0x20e));}function printVersion(){const _0x1a691a=a0_0x5eca0a;let _0x5b68ed='';try{_0x5b68ed=coreVersion();}catch{}console['log'](_0x1a691a(0x1e5)+WRAPPER_VERSION),console[_0x1a691a(0x217)]('wrapper\x20'+WRAPPER_VERSION),console['log']('core\x20'+(_0x5b68ed||_0x1a691a(0x25b)));}function directCore(_0x30ee7d){const _0x34a542=a0_0x5eca0a,_0x1a270c=findCoreScript();checkMacNodePtySpawnHelper(_0x1a270c);const _0x29ccba=(0x0,import_child_process2['spawnSync'])(process['execPath'],[_0x1a270c,..._0x30ee7d],{'stdio':'inherit','env':{...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_CORE_ENTRY':_0x1a270c},'shell':![]});process[_0x34a542(0x22f)](_0x29ccba['status']??0x0);}function shouldSupervise(_0x4e51dc){const _0x530fee=a0_0x5eca0a;if(_0x4e51dc[_0x530fee(0x1e8)]('--agent-id'))return![];if(_0x4e51dc[_0x530fee(0x1e8)]('--resume')||_0x4e51dc[0x0]===_0x530fee(0x21f))return![];const _0x17f679=_0x4e51dc[0x0]||'';if(_0x17f679==='ls'||_0x17f679===_0x530fee(0x20c)||_0x17f679==='ps')return![];if(_0x17f679==='mcp'||_0x17f679===_0x530fee(0x1f3))return![];if(_0x4e51dc['includes']('--help')||_0x4e51dc[_0x530fee(0x1e8)]('-h'))return![];return!![];}function installCoreVersion(_0x206ef7){const _0x406dee=a0_0x5eca0a,_0x3ff836=resolveExecutablePath(_0x406dee(0x1e3));if(!_0x3ff836)return{'ok':![],'output':'npm\x20not\x20found\x20on\x20PAT'+'H'};const _0x2026c2=CORE_PKG_NAME+'@'+_0x206ef7,_0x47bf59=run(_0x3ff836,[_0x406dee(0x213),'-g',_0x2026c2,npmRegistryArg()]),_0x5a9be1=((_0x47bf59[_0x406dee(0x249)]||'')+'\x0a'+(_0x47bf59['stderr']||''))[_0x406dee(0x1fc)]();return{'ok':_0x47bf59[_0x406dee(0x20c)]===0x0,'output':_0x5a9be1};}async function superviseCore(_0x225f47){const _0x3839c9=a0_0x5eca0a;let _0x40ee34=![],_0x3a138c=null;const _0x320e80=[];let _0x522a59=MIN_RESTART_DELAY_MS;const _0x45fa74=()=>{const _0x586159=a0_0xeebc;_0x40ee34=!![];if(_0x3a138c&&!_0x3a138c['killed'])try{_0x3a138c[_0x586159(0x232)](_0x586159(0x220));}catch{}else process['exit'](0x0);};process['on'](_0x3839c9(0x1dd),_0x45fa74),process['on']('SIGTERM',_0x45fa74);while(!![]){const _0x4ae769=findCoreScript();checkMacNodePtySpawnHelper(_0x4ae769);const _0xb8b1aa={...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_WRAPPER_MANAGED':'1','WHALENT_CORE_ENTRY':_0x4ae769},_0x1cd3d2=readUpgradeState(),_0x40114e=!!_0x1cd3d2?.[_0x3839c9(0x24a)];let _0x36080b=![],_0x48bbdb=null,_0x25b086='';const _0x41dbdf=[],_0x1dff52=0xc;console[_0x3839c9(0x217)]('[wrapper]\x20starting\x20c'+'ore:\x20'+_0x4ae769),_0x3a138c=(0x0,import_child_process2[_0x3839c9(0x24f)])(process['execPath'],[_0x4ae769,..._0x225f47],{'env':_0xb8b1aa,'stdio':['inherit',_0x3839c9(0x1e6),_0x3839c9(0x1e6)]});const _0x2b1b9f=()=>{const _0x2b7673=_0x3839c9;if(_0x36080b)return;_0x36080b=!![];if(_0x48bbdb)clearTimeout(_0x48bbdb);_0x320e80['length']=0x0,_0x522a59=MIN_RESTART_DELAY_MS;const _0x1fc07b=readUpgradeState();_0x1fc07b?.['pending']&&(writeUpgradeState({..._0x1fc07b,'pending':![],'rollback':![],'health_status':_0x2b7673(0x204)}),console[_0x2b7673(0x217)](_0x2b7673(0x22a)+_0x2b7673(0x205)+(_0x1fc07b[_0x2b7673(0x25a)]||_0x1fc07b[_0x2b7673(0x21b)]||'')));},_0xcebfe2=(_0x6a0861,_0x526d86=![])=>{const _0x22b412=_0x3839c9,_0x331607=_0x6a0861['toString']();(_0x526d86?process[_0x22b412(0x1e9)]:process['stdout'])[_0x22b412(0x25e)](_0x331607);if(_0x526d86)for(const _0x5898fc of _0x331607['split'](/\r?\n/)){if(!_0x5898fc[_0x22b412(0x1fc)]())continue;_0x41dbdf[_0x22b412(0x1e1)](_0x5898fc);if(_0x41dbdf[_0x22b412(0x25c)]>_0x1dff52)_0x41dbdf['shift']();const _0xba6d2=_0x5898fc['match'](FATAL_PATTERN);if(_0xba6d2)_0x25b086=_0xba6d2[0x0];}(_0x331607['includes'](_0x22b412(0x1e7))||_0x331607['includes']('Gateway\x20registered\x20m'+_0x22b412(0x247))||_0x331607[_0x22b412(0x1e8)]('Gateway:\x20connected'))&&_0x2b1b9f();};_0x3a138c[_0x3839c9(0x249)]?.['on']('data',_0x9cd694=>_0xcebfe2(_0x9cd694,![])),_0x3a138c['stderr']?.['on'](_0x3839c9(0x219),_0x1ca2ca=>_0xcebfe2(_0x1ca2ca,!![]));_0x40114e&&(_0x48bbdb=setTimeout(()=>{const _0x35d1af=_0x3839c9;if(_0x36080b||!_0x3a138c||_0x3a138c['killed'])return;console[_0x35d1af(0x257)]('[wrapper]\x20new\x20core\x20d'+'id\x20not\x20become\x20health'+_0x35d1af(0x20b)+'ack');try{_0x3a138c[_0x35d1af(0x232)]('SIGTERM');}catch{}},HEALTH_TIMEOUT_MS));const _0x1a9c54=await new Promise(_0x498ebe=>{_0x3a138c['once']('exit',(_0x1a890c,_0x11dc3c)=>_0x498ebe({'code':_0x1a890c,'signal':_0x11dc3c}));});if(_0x48bbdb)clearTimeout(_0x48bbdb);_0x3a138c=null;if(_0x40ee34)process['exit'](_0x1a9c54['code']??0x0);const _0x1c40fa=readUpgradeState();if(_0x1c40fa?.[_0x3839c9(0x24a)]&&!_0x36080b){const _0x330a49=String(_0x1c40fa['previous_core_versio'+'n']||'')['trim']();if(_0x330a49){console[_0x3839c9(0x257)]('[wrapper]\x20rolling\x20ba'+'ck\x20core\x20to\x20'+_0x330a49);const _0x38197f=installCoreVersion(_0x330a49);writeUpgradeState({..._0x1c40fa,'pending':![],'rollback':!![],'health_status':_0x38197f['ok']?'rolled_back':'rollback_failed','error':_0x38197f['ok']?'':_0x38197f['output']});}else writeUpgradeState({..._0x1c40fa,'pending':![],'rollback':!![],'health_status':'rollback_unavailable','error':_0x3839c9(0x23f)+'n\x20unknown'});}const _0x1ad580=_0x1a9c54['code']===SUPERVISED_RESTART_CODE||_0x1c40fa?.['pending'];if(!_0x1ad580&&_0x1a9c54['code']===0x0)process['exit'](0x0);const _0x4c4f9d=Date[_0x3839c9(0x1fe)]();_0x320e80['push'](_0x4c4f9d);while(_0x320e80[_0x3839c9(0x25c)]>0x0&&_0x4c4f9d-_0x320e80[0x0]>CRASH_WINDOW_MS){_0x320e80[_0x3839c9(0x223)]();}const _0x32d71b=_0x320e80['length'];writeLastCrash({'timestamp':_0x4c4f9d,'exit_code':_0x1a9c54['code'],'exit_signal':_0x1a9c54['signal']||null,'fatal_line':_0x25b086,'raw_tail':_0x41dbdf[_0x3839c9(0x1f0)]('\x0a'),'consecutive_crashes':_0x32d71b}),console[_0x3839c9(0x217)](_0x3839c9(0x243)+'d\x20code='+(_0x1a9c54[_0x3839c9(0x208)]??'')+(_0x1a9c54['signal']?'\x20signal='+_0x1a9c54['signal']:'')+'\x20('+_0x32d71b+'/'+MAX_CRASHES_IN_WINDOW+_0x3839c9(0x21e)+Math['round'](CRASH_WINDOW_MS/0x3e8)+'s)');if(_0x25b086)console['log'](_0x3839c9(0x215)+':\x20'+_0x25b086);_0x32d71b>=MAX_CRASHES_IN_WINDOW&&(console['error']('[wrapper]\x20core\x20faile'+'d\x20'+_0x32d71b+_0x3839c9(0x235)+Math[_0x3839c9(0x212)](CRASH_WINDOW_MS/0x3e8)+(_0x3839c9(0x259)+'record:\x20')+lastCrashFilePath()+('.\x20Restart\x20wrapper\x20ma'+'nually\x20after\x20the\x20und'+_0x3839c9(0x1e4)+'ed.')),process[_0x3839c9(0x22f)](0x1)),console[_0x3839c9(0x217)]('[wrapper]\x20restarting'+_0x3839c9(0x23b)+_0x522a59+'ms'),await new Promise(_0x59e47b=>setTimeout(_0x59e47b,_0x522a59)),_0x522a59=Math[_0x3839c9(0x221)](_0x522a59*0x2,MAX_RESTART_DELAY_MS);}}async function main(){const _0x5a599b=a0_0x5eca0a,_0x4aa316=process['argv']['slice'](0x2);if(_0x4aa316[0x0]===_0x5a599b(0x254)||_0x4aa316[0x0]==='-v'||_0x4aa316[0x0]===_0x5a599b(0x248)){printVersion();return;}if((_0x4aa316[0x0]===_0x5a599b(0x20c)||_0x4aa316[0x0]==='ls'||_0x4aa316[0x0]==='ps')&&!_0x4aa316['includes']('--json')){console['log'](_0x5a599b(0x24e)+WRAPPER_VERSION);try{console[_0x5a599b(0x217)]('core\x20'+(coreVersion()||'not\x20installed'));}catch{console['log'](_0x5a599b(0x1fd));}}maybeUpdateWrapper(_0x4aa316);if(!shouldSupervise(_0x4aa316))directCore(_0x4aa316);await superviseCore(_0x4aa316);}main()['catch'](_0x27e4e4=>{const _0x3b6543=a0_0x5eca0a;console[_0x3b6543(0x257)](_0x3b6543(0x252)+'r:\x20'+(_0x27e4e4?.['message']||String(_0x27e4e4))),process['exit'](0x1);});
2
+ 'use strict';const a0_0x5037bd=a0_0x12d6;(function(_0x23d946,_0x35cd17){const _0x592800=a0_0x12d6,_0x4f5b38=_0x23d946();while(!![]){try{const _0x37abde=-parseInt(_0x592800(0x18f))/0x1+parseInt(_0x592800(0x1e0))/0x2+-parseInt(_0x592800(0x15c))/0x3+parseInt(_0x592800(0x15f))/0x4*(-parseInt(_0x592800(0x171))/0x5)+-parseInt(_0x592800(0x175))/0x6*(-parseInt(_0x592800(0x1a4))/0x7)+-parseInt(_0x592800(0x195))/0x8*(parseInt(_0x592800(0x19d))/0x9)+parseInt(_0x592800(0x1d1))/0xa;if(_0x37abde===_0x35cd17)break;else _0x4f5b38['push'](_0x4f5b38['shift']());}catch(_0x2c0c04){_0x4f5b38['push'](_0x4f5b38['shift']());}}}(a0_0x32ae,0xa9162));var __create=Object['create'],__defProp=Object['defineProperty'],__getOwnPropDesc=Object['getOwnPropertyDescri'+a0_0x5037bd(0x1ac)],__getOwnPropNames=Object[a0_0x5037bd(0x16c)],__getProtoOf=Object['getPrototypeOf'],__hasOwnProp=Object['prototype'][a0_0x5037bd(0x1cd)],__copyProps=(_0x195f8a,_0x4100d2,_0x3e552c,_0x91d6c7)=>{const _0x3ace8b=a0_0x5037bd;if(_0x4100d2&&typeof _0x4100d2==='object'||typeof _0x4100d2==='function'){for(let _0x58c171 of __getOwnPropNames(_0x4100d2))if(!__hasOwnProp[_0x3ace8b(0x1d5)](_0x195f8a,_0x58c171)&&_0x58c171!==_0x3e552c)__defProp(_0x195f8a,_0x58c171,{'get':()=>_0x4100d2[_0x58c171],'enumerable':!(_0x91d6c7=__getOwnPropDesc(_0x4100d2,_0x58c171))||_0x91d6c7[_0x3ace8b(0x1c5)]});}return _0x195f8a;},__toESM=(_0x330a0f,_0x34767e,_0x407d0b)=>(_0x407d0b=_0x330a0f!=null?__create(__getProtoOf(_0x330a0f)):{},__copyProps(_0x34767e||!_0x330a0f||!_0x330a0f[a0_0x5037bd(0x182)]?__defProp(_0x407d0b,'default',{'value':_0x330a0f,'enumerable':!![]}):_0x407d0b,_0x330a0f)),import_child_process2=require(a0_0x5037bd(0x1d3)),fs=__toESM(require('fs'),0x1),import_module=require('module'),os=__toESM(require('os'),0x1),path=__toESM(require(a0_0x5037bd(0x1bf)),0x1),import_child_process=require(a0_0x5037bd(0x1d3)),import_fs=require('fs'),import_path=require('path'),DEFAULT_NPM_REGISTRY='https://registry.npm'+a0_0x5037bd(0x1af),CHINA_NPM_REGISTRY=a0_0x5037bd(0x178)+'mirror.com';function preferredNpmRegistry(){const _0x247dc8=normalizeRegistry(process.env.WHALENT_NPM_REGISTRY||process.env.NPM_CONFIG_REGISTRY||'');if(_0x247dc8)return _0x247dc8;return isChineseLocale()?CHINA_NPM_REGISTRY:DEFAULT_NPM_REGISTRY;}function npmRegistryArg(_0x291453=preferredNpmRegistry()){return'--registry='+(normalizeRegistry(_0x291453)||DEFAULT_NPM_REGISTRY);}function npmInstallCommand(_0x19535f,_0x40ca2d=preferredNpmRegistry()){const _0x3b82b1=a0_0x5037bd;return _0x3b82b1(0x1b6)+_0x19535f+'\x20'+npmRegistryArg(_0x40ca2d);}function isChineseLocale(){const _0x327e32=[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'](_0x327e32))return!![];try{const _0x3d8408=Intl['DateTimeFormat']()['resolvedOptions']()['locale']||'';return/(^|-)zh($|-)|-CN\b/i['test'](_0x3d8408);}catch{return![];}}function normalizeRegistry(_0x2e2a56){const _0x414926=a0_0x5037bd;return String(_0x2e2a56||'')[_0x414926(0x14d)]()['replace'](/\/+$/,'');}var INSTALL_HINT={'codex':'npm\x20install\x20-g\x20@open'+a0_0x5037bd(0x17a),'claude':'npm\x20install\x20-g\x20@anth'+'ropic-ai/claude-code','opencode':'npm\x20install\x20-g\x20openc'+'ode-ai','whalent':npmInstallCommand(a0_0x5037bd(0x18b))+a0_0x5037bd(0x14f)};function isWindowsCmdFile(_0x36895f){const _0x405402=a0_0x5037bd;return process['platform']==='win32'&&/\.(cmd|bat)$/i[_0x405402(0x191)](_0x36895f||'');}function quoteCmdArg(_0x4f6eee){const _0x1850ee=a0_0x5037bd,_0x740797=String(_0x4f6eee??'');if(_0x740797&&!/[\s"&|<>^%]/['test'](_0x740797))return _0x740797;return'\x22'+_0x740797[_0x1850ee(0x158)](/(["^&|<>%])/g,_0x1850ee(0x1c3))+'\x22';}function cmdFallbackArgs(_0x46226a,_0x19af2d){const _0x5e2e31=a0_0x5037bd;return['/d','/s','/c',[quoteCmdArg(_0x46226a),..._0x19af2d[_0x5e2e31(0x1da)](quoteCmdArg)]['join']('\x20')];}function resolveExecutablePath(_0x55fe12){const _0x1c95f5=a0_0x5037bd;if(!_0x55fe12)return null;if(_0x55fe12[_0x1c95f5(0x19e)]('/')||_0x55fe12['includes']('\x5c')||/\.[A-Za-z0-9]{1,5}$/[_0x1c95f5(0x191)](_0x55fe12))return(0x0,import_fs['existsSync'])(_0x55fe12)?_0x55fe12:_0x55fe12;const _0x32a319=process[_0x1c95f5(0x1d2)]==='win32',_0x29bbdd=_0x32a319?'where.exe':_0x1c95f5(0x181);try{const _0x2b50f3=(0x0,import_child_process[_0x1c95f5(0x19f)])(_0x29bbdd,[_0x55fe12],{'encoding':'utf-8','timeout':0xbb8,'shell':![]});if(_0x2b50f3[_0x1c95f5(0x167)]===0x0){const _0x842774=(_0x2b50f3[_0x1c95f5(0x1bd)]||'')[_0x1c95f5(0x14d)]()[_0x1c95f5(0x16e)](/\r?\n/)['filter'](Boolean);if(_0x842774['length']===0x0)return null;if(_0x32a319)for(const _0x543987 of['.exe',_0x1c95f5(0x1bc),'.bat',_0x1c95f5(0x187)]){const _0x3e9ac6=_0x842774[_0x1c95f5(0x147)](_0x53a02c=>_0x53a02c[_0x1c95f5(0x1a1)]()[_0x1c95f5(0x1b5)](_0x543987));if(_0x3e9ac6)return _0x3e9ac6;}return _0x842774[0x0]||null;}}catch{}return null;}function unwrapWindowsCmdShim(_0x4def3f){const _0x27e2af=a0_0x5037bd;if(process[_0x27e2af(0x1d2)]!=='win32')return null;if(!/\.(cmd|bat)$/i['test'](_0x4def3f))return null;let _0x85b9f1;try{_0x85b9f1=(0x0,import_fs['readFileSync'])(_0x4def3f,'utf-8');}catch{return null;}const _0x5a78c1=_0x85b9f1['match'](/"(%~?dp0%?)[\\/]+([^"]+\.(?:js|cjs|mjs))"/i);if(_0x5a78c1){const _0x3c74cf=(0x0,import_path['resolve'])((0x0,import_path['dirname'])(_0x4def3f),_0x5a78c1[0x2]);if((0x0,import_fs[_0x27e2af(0x17e)])(_0x3c74cf))return{'type':_0x27e2af(0x18c),'path':_0x3c74cf};}const _0x118ff2=_0x85b9f1['match'](/"(%~?dp0%?)[\\/]+([^"]+\.exe)"/i);if(_0x118ff2){const _0x3c2682=(0x0,import_path[_0x27e2af(0x1be)])((0x0,import_path[_0x27e2af(0x1b7)])(_0x4def3f),_0x118ff2[0x2]);if((0x0,import_fs['existsSync'])(_0x3c2682))return{'type':'exe','path':_0x3c2682};}return null;}function safeSpawnSync(_0xd19ddb,_0x2a8875,_0xdf7df8={}){const _0x3fad58=a0_0x5037bd,_0x4e31b4=unwrapWindowsCmdShim(_0xd19ddb);if(_0x4e31b4?.[_0x3fad58(0x1b1)]===_0x3fad58(0x18c))return(0x0,import_child_process[_0x3fad58(0x19f)])(process['execPath'],[_0x4e31b4['path'],..._0x2a8875],_0xdf7df8);if(_0x4e31b4?.['type']===_0x3fad58(0x185))return(0x0,import_child_process[_0x3fad58(0x19f)])(_0x4e31b4[_0x3fad58(0x1bf)],_0x2a8875,_0xdf7df8);if(isWindowsCmdFile(_0xd19ddb))return(0x0,import_child_process['spawnSync'])(process.env.ComSpec||_0x3fad58(0x198),cmdFallbackArgs(_0xd19ddb,_0x2a8875),_0xdf7df8);return(0x0,import_child_process['spawnSync'])(_0xd19ddb,_0x2a8875,_0xdf7df8);}var WRAPPER_PKG_NAME='@whalent/agent',CORE_PKG_NAME=a0_0x5037bd(0x177),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 _0x41df0b=a0_0x5037bd;return path['join'](os['homedir'](),_0x41df0b(0x160));}function upgradeStatePath(){const _0x285e8a=a0_0x5037bd;return path[_0x285e8a(0x168)](configDir(),_0x285e8a(0x174));}function lastCrashFilePath(){const _0x2aeeb6=a0_0x5037bd;return path[_0x2aeeb6(0x168)](configDir(),_0x2aeeb6(0x196));}function writeLastCrash(_0x12dc80){const _0x1402ec=a0_0x5037bd;try{fs[_0x1402ec(0x1c2)](configDir(),{'recursive':!![]});const _0x487250={..._0x12dc80,'reported':![]};fs[_0x1402ec(0x148)](lastCrashFilePath(),JSON[_0x1402ec(0x1a5)](_0x487250,null,0x2),_0x1402ec(0x1c6));}catch{}}function readWrapperVersion(){const _0x1b8617=a0_0x5037bd;try{const _0x26d83d=JSON[_0x1b8617(0x157)](fs['readFileSync'](path['join'](wrapperBaseDir(),'..',_0x1b8617(0x194)),_0x1b8617(0x1c6)));return String(_0x26d83d['version']||_0x1b8617(0x1ca));}catch{return'0.0.0';}}function a0_0x32ae(){const _0x562980=['BNbTig5VDcbMB3vUzcbVBIbqqvq','CgfJA2fNzs5QC29U','mJy0DgHtsM1J','BgfZDc1JCMfZAc5QC29U','C2LNBMfS','y21KlMv4zq','w3DYyxbWzxjDig1Hy09tig5Vzgu','ig5VDcbLEgvJDxrHyMXLoIa','CM9VDa','AwqGBM90igjLy29TzsbOzwfSDgG','mtuWntC5A292uwzU','Aw5JBhvKzxm','C3bHD25tEw5J','icbSCYaTBcaIjeHftfbfuIi','Dg9mB3DLCKnHC2u','Dg9tDhjPBMC','A2LSBgvK','mJuZndqYEg9TALnz','C3rYAw5NAwz5','ihnPz25HBd0','D3jPDgu','w3DYyxbWzxjDihvWzgf0zsbHDMe','wf9psW','DxrMoa','BwnW','ChrVCG','ls1Hz2vUDc1Pza','ChjLyNvPBgrZ','ANmUB3jN','CgfYC2vjBNq','DhLWzq','y29Yzsa','ls1OzwXW','Bwf0y2G','zw5KC1DPDgG','BNbTigLUC3rHBgWGlwCG','zgLYBMfTzq','y29YzsbUB3qGAw5ZDgfSBgvK','DMvYC2LVBG','CgvUzgLUzW','igLUia','lMnTza','C3rKB3v0','CMvZB2X2zq','Cgf0Aa','D2fYBG','C2XPy2u','BwTKAxjtEw5J','xIqX','CM9SBgjHy2TFzMfPBgvK','zw51BwvYywjSzq','DxrMltG','B3jLoIa','w3DYyxbWzxjDihjLC3rHCNrPBMC','BNbT','mc4WlJa','BgvUz3rO','CM9SBgjHy2TFDw5HDMfPBgfIBgu','AgfZt3DUuhjVCgvYDhK','CM9SBgvKx2jHy2S','w3DYyxbWzxjDihDYyxbWzxiGDxa','BNbTig5VDcbMB3vUza','mJq5mJy1mtbNzwjftLO','CgXHDgzVCM0','y2HPBgrFChjVy2vZCW','Bw9Kzq','y2fSBa','CgvYigv4zwn1DgfIBguGyML0oIa','Bg9N','y29UC3rHBNrZ','yxjNDG','BwfW','BNvHBgX5igfMDgvYihrOzsb1BMq','B3iGCMvIDwLSzcbaD2HHBgvUDc8','y29Kzq','y29Yzq','igjLzM9YzsbZDgfYDgLUzYbJB3i','mta3mZq1ofnmug1mzW','igzYB20G','zgfYD2LU','ChvZAa','u0Lhsu5u','zMLUza','D3jPDgvgAwXLu3LUyW','lxb0EsbZCgf3BI1OzwXWzxiGBM8','w3DYyxbWzxjDignVCMuGzMfPBgu','CgLWzq','zxjYB3i','DhjPBq','CMvHzezPBgvtEw5J','ic0TChjLzMvYlw9UBgLUzq','r2f0zxDHEsbYzwDPC3rLCMvKig0','EwvZ','CMvJB3jKoIa','icbJAg1VzcaREcaIjeHftfbfuIi','C2HPzNq','lxb0EsbZCgf3BI1OzwXWzxiGAxm','Aw5OzxjPDa','CgfYC2u','CMvWBgfJzq','BM9Kzs1WDhK','u0Lhvevstq','zxHPDa','mJGZnJG0mLz2z29VCq','Aw5KzxGUy2PZ','AgfZ','mtyWmtq4B2vzsKTn','lNDOywXLBNqTywDLBNq','zwqU','w3DYyxbWzxjDifj1BIb0AgLZig8','C3rKzxjY','Aw5KzxG','Dhj1zq','w3DYyxbWzxjDie1HBNvHBcb1Cgq','C3rHDhvZ','AM9PBG','zgf0zwqGDg8G','y29Yzs5JANm','ic0+ia','z2v0t3DUuhjVCgvYDhLoyw1LCW','AgvHBhrOEq','C3bSAxq','EsbPBIb0Aw1LoYbYB2XSAw5Nigi','zxHLy1bHDgG','mtmWrNrktLjw','BM93','CMvZDw1L','y29Yzs11CgDYywrLlMPZB24','nZHzsvjxwwC','A2LSBa','qhDOywXLBNqVywDLBNqTy29Yzq','Ahr0Chm6lY9YzwDPC3rYEs5UCg0','D3jHChbLCIa','ywKVy29KzxG','zgLZDa','zxjSEwLUzYbPC3n1zsbPCYbMAxG','w3DYyxbWzxjDihn0yxj0Aw5Nigm','zxHPC3rZu3LUyW','w3DYyxbWzxjDigLUC3rHBgXPBMC','DgfYz2v0x3zLCNnPB24','D2HPy2G','x19LC01VzhvSzq','ywnOAw5L','qhDOywXLBNqVywDLBNqTy29Yzsa','zxHL','ChjLDMLVDxnFy29Yzv92zxjZAw8','lNbZmq','oYbYzxn0yxj0Aw5NihDYyxbWzxi','C29YDa','y3jLyxrLuMvXDwLYzq','qhDOywXLBNqVywDLBNq','BM9Kzq','zMLSDgvY','BMnLihrVigzPEcb0zxjTAw5HBc8','mJy4nZGXvNfsBNPc','w3DYyxbWzxjDihjVBgXPBMCGyMe','DgvZDa','qhDOywXLBNq'];a0_0x32ae=function(){return _0x562980;};return a0_0x32ae();}function readUpgradeState(){const _0x2274c4=a0_0x5037bd;try{return JSON[_0x2274c4(0x157)](fs[_0x2274c4(0x14e)](upgradeStatePath(),_0x2274c4(0x1c6)));}catch{return null;}}function writeUpgradeState(_0x3706b5){const _0x4e7123=a0_0x5037bd;try{fs[_0x4e7123(0x1c2)](configDir(),{'recursive':!![]}),fs['writeFileSync'](upgradeStatePath(),JSON['stringify']({..._0x3706b5,'updated_at':Date[_0x4e7123(0x172)]()},null,0x2),'utf-8');}catch{}}function run(_0x242bb7,_0x577e11,_0xa21513=process.env){return safeSpawnSync(_0x242bb7,_0x577e11,{'encoding':'utf8','timeout':NPM_INSTALL_TIMEOUT_MS,'maxBuffer':NPM_INSTALL_MAX_BUFFER,'env':_0xa21513,'shell':![]});}function runNpmView(_0x314675){const _0x3b98ab=a0_0x5037bd,_0x1b641c=resolveExecutablePath('npm');if(!_0x1b641c)return{'status':0x7f,'stdout':'','stderr':_0x3b98ab(0x1d0),'error':new Error(_0x3b98ab(0x1d0))};return safeSpawnSync(_0x1b641c,_0x314675,{'encoding':'utf8','timeout':NPM_VIEW_TIMEOUT_MS,'maxBuffer':0x400*0x400,'env':process.env,'shell':![]});}function a0_0x12d6(_0x3ebaae,_0x88b318){_0x3ebaae=_0x3ebaae-0x144;const _0x32aef3=a0_0x32ae();let _0x12d656=_0x32aef3[_0x3ebaae];if(a0_0x12d6['OlLzRv']===undefined){var _0x27b11a=function(_0x4c2c72){const _0x455dce='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x195f8a='',_0x4100d2='';for(let _0x3e552c=0x0,_0x91d6c7,_0x58c171,_0x330a0f=0x0;_0x58c171=_0x4c2c72['charAt'](_0x330a0f++);~_0x58c171&&(_0x91d6c7=_0x3e552c%0x4?_0x91d6c7*0x40+_0x58c171:_0x58c171,_0x3e552c++%0x4)?_0x195f8a+=String['fromCharCode'](0xff&_0x91d6c7>>(-0x2*_0x3e552c&0x6)):0x0){_0x58c171=_0x455dce['indexOf'](_0x58c171);}for(let _0x34767e=0x0,_0x407d0b=_0x195f8a['length'];_0x34767e<_0x407d0b;_0x34767e++){_0x4100d2+='%'+('00'+_0x195f8a['charCodeAt'](_0x34767e)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x4100d2);};a0_0x12d6['BdgaaO']=_0x27b11a,a0_0x12d6['bulUsl']={},a0_0x12d6['OlLzRv']=!![];}const _0xb261e8=_0x32aef3[0x0],_0x4d5971=_0x3ebaae+_0xb261e8,_0x2911db=a0_0x12d6['bulUsl'][_0x4d5971];return!_0x2911db?(_0x12d656=a0_0x12d6['BdgaaO'](_0x12d656),a0_0x12d6['bulUsl'][_0x4d5971]=_0x12d656):_0x12d656=_0x2911db,_0x12d656;}function npmRootGlobal(){const _0x2531be=a0_0x5037bd,_0x39991b=resolveExecutablePath('npm');if(!_0x39991b)return'';const _0x3725d1=run(_0x39991b,[_0x2531be(0x19b),'-g']);if(_0x3725d1['status']!==0x0)return'';return String(_0x3725d1['stdout']||'')['trim']();}function compareSemver(_0x42b05d,_0xcc8b3d){const _0x26a31e=a0_0x5037bd,_0x30644b=String(_0x42b05d||'')['replace'](/^v/,'')[_0x26a31e(0x16e)](/[.-]/)[_0x26a31e(0x1da)](_0x1c5eae=>Number[_0x26a31e(0x1b0)](_0x1c5eae,0xa)||0x0),_0x2ffbcc=String(_0xcc8b3d||'')['replace'](/^v/,'')[_0x26a31e(0x16e)](/[.-]/)[_0x26a31e(0x1da)](_0x58d3c6=>Number[_0x26a31e(0x1b0)](_0x58d3c6,0xa)||0x0);for(let _0x3ce415=0x0;_0x3ce415<Math['max'](_0x30644b['length'],_0x2ffbcc['length'],0x3);_0x3ce415++){const _0x560567=_0x30644b[_0x3ce415]||0x0,_0x15dccd=_0x2ffbcc[_0x3ce415]||0x0;if(_0x560567>_0x15dccd)return 0x1;if(_0x560567<_0x15dccd)return-0x1;}return 0x0;}function skipWrapperUpdateCheck(){const _0x3a903d=a0_0x5037bd,_0x2675e7=String(process.env.WHALENT_SKIP_UPDATE_CHECK||process.env.WHALENT_NO_UPDATE_CHECK||process.env.WHALENT_SKIP_WRAPPER_UPDATE||'')[_0x3a903d(0x14d)]()[_0x3a903d(0x1a1)]();return _0x2675e7==='1'||_0x2675e7==='true'||_0x2675e7==='yes'||_0x2675e7==='on';}function latestWrapperVersion(){const _0x293b3e=a0_0x5037bd,_0x160b49=runNpmView(['view',WRAPPER_PKG_NAME+'@latest',_0x293b3e(0x1b9),npmRegistryArg()]);if(_0x160b49['status']!==0x0)return'';return String(_0x160b49[_0x293b3e(0x1bd)]||'')[_0x293b3e(0x14d)]()['split'](/\r?\n/)[_0x293b3e(0x18d)](Boolean)['pop']()||'';}function installWrapperVersion(_0x21b818){const _0x4afc71=a0_0x5037bd,_0x1245f7=resolveExecutablePath('npm');if(!_0x1245f7)return{'ok':![],'output':_0x4afc71(0x193)+'H'};const _0x3ff0b1=run(_0x1245f7,['install','-g',WRAPPER_PKG_NAME+'@'+_0x21b818,npmRegistryArg()]),_0x5f06e8=((_0x3ff0b1['stdout']||'')+'\x0a'+(_0x3ff0b1[_0x4afc71(0x163)]||''))['trim']();return{'ok':_0x3ff0b1[_0x4afc71(0x167)]===0x0,'output':_0x5f06e8};}function maybeUpdateWrapper(_0x211af1){const _0x244096=a0_0x5037bd;if(skipWrapperUpdateCheck())return![];if(process.env.WHALENT_WRAPPER_UPDATE_ATTEMPTED)return![];const _0x163325=latestWrapperVersion();if(!_0x163325||compareSemver(_0x163325,WRAPPER_VERSION)<=0x0)return![];const _0x2ea4ad=preferredNpmRegistry();console[_0x244096(0x1c0)](_0x244096(0x1a8)+'ilable:\x20'+WRAPPER_VERSION+_0x244096(0x16b)+_0x163325),console['warn'](_0x244096(0x17f)+'\x20'+WRAPPER_PKG_NAME+'@'+_0x163325+_0x244096(0x1e1)+_0x2ea4ad+(_0x244096(0x1df)+'e...'));const _0x5e73e6=installWrapperVersion(_0x163325);if(!_0x5e73e6['ok']){console['warn'](_0x244096(0x1cf)+'date\x20failed;\x20continu'+'ing\x20with\x20'+WRAPPER_VERSION);if(_0x5e73e6['output'])console['warn'](_0x5e73e6['output']['split'](/\r?\n/)['slice'](-0xc)[_0x244096(0x168)]('\x0a'));return console[_0x244096(0x1c0)](_0x244096(0x166)+'ate:\x20'+npmInstallCommand(WRAPPER_PKG_NAME+'@'+_0x163325,_0x2ea4ad)),![];}console[_0x244096(0x1c0)]('[wrapper]\x20wrapper\x20up'+_0x244096(0x169)+_0x163325+_0x244096(0x188));const _0x5e5310=process[_0x244096(0x1d9)][0x1],_0x3fa72e=(0x0,import_child_process2[_0x244096(0x19f)])(process['execPath'],[_0x5e5310,..._0x211af1],{'stdio':_0x244096(0x156),'env':{...process.env,'WHALENT_WRAPPER_UPDATE_ATTEMPTED':_0x163325},'shell':![]});process['exit'](_0x3fa72e[_0x244096(0x167)]??0x0);}function findCoreScript(){const _0x5c86e4=a0_0x5037bd,_0x20bdb7=String(process.env.WHALENT_CORE_ENTRY||'')[_0x5c86e4(0x14d)](),_0x57e43b=['1',_0x5c86e4(0x165),_0x5c86e4(0x151),'on'][_0x5c86e4(0x19e)](String(process.env.WHALENT_FORCE_CORE_ENTRY||'')['trim']()[_0x5c86e4(0x1a1)]());if(_0x20bdb7&&_0x57e43b&&fs[_0x5c86e4(0x17e)](_0x20bdb7))return _0x20bdb7;const _0x36aec7=[],_0x18b449=_0x5c02bc=>{const _0x2a85a8=_0x5c86e4;if(fs[_0x2a85a8(0x17e)](_0x5c02bc)&&!_0x36aec7[_0x2a85a8(0x19e)](_0x5c02bc))_0x36aec7[_0x2a85a8(0x145)](_0x5c02bc);};if(_0x20bdb7)_0x18b449(_0x20bdb7);const _0x56d52a=npmRootGlobal();if(_0x56d52a){const _0x1bd37f=path['join'](_0x56d52a,_0x5c86e4(0x192),'agent-core',_0x5c86e4(0x17b),_0x5c86e4(0x15d));_0x18b449(_0x1bd37f);}const _0x3509ce=path[_0x5c86e4(0x168)](wrapperBaseDir(),_0x5c86e4(0x16a));_0x18b449(_0x3509ce);const _0xae0f0b=path[_0x5c86e4(0x168)](wrapperBaseDir(),'..','packages',_0x5c86e4(0x1de),_0x5c86e4(0x17b),'index.cjs');_0x18b449(_0xae0f0b);if(_0x36aec7[_0x5c86e4(0x1cb)]>0x0)return _0x36aec7['map']((_0xfab49,_0x34cddd)=>({'candidate':_0xfab49,'index':_0x34cddd,'version':coreVersion(_0xfab49)}))[_0x5c86e4(0x189)]((_0x4615f3,_0x2831d9)=>{const _0x1881a4=_0x5c86e4,_0x10e794=compareSemver(_0x2831d9['version'],_0x4615f3['version']);if(_0x10e794!==0x0)return _0x10e794;return _0x2831d9[_0x1881a4(0x164)]-_0x4615f3[_0x1881a4(0x164)];})[0x0]['candidate'];throw new Error('whalent\x20core\x20runtime'+'\x20not\x20found;\x20install\x20'+_0x5c86e4(0x184)+_0x5c86e4(0x1dc)+'agent');}function coreVersion(_0xaa6ca1=findCoreScript()){const _0x4095df=a0_0x5037bd,_0x3ed9f4=(0x0,import_child_process2['spawnSync'])(process['execPath'],[_0xaa6ca1,'--version'],{'encoding':_0x4095df(0x1aa),'timeout':0x3a98,'env':{...process.env,'WHALENT_SKIP_UPDATE_CHECK':'1'},'shell':![]}),_0x433a4e=(_0x3ed9f4['stdout']||'')+'\x0a'+(_0x3ed9f4['stderr']||'');return _0x433a4e[_0x4095df(0x1b4)](/(\d+\.\d+\.\d+(?:[-\w.]+)?)/)?.[0x1]||'';}function isExecutable(_0xec73a0){const _0x4da705=a0_0x5037bd;try{return fs['accessSync'](_0xec73a0,fs[_0x4da705(0x1d8)][_0x4da705(0x1a9)]),!![];}catch{return![];}}function shellQuote(_0x350593){const _0x293c11=a0_0x5037bd;return'\x27'+_0x350593[_0x293c11(0x158)](/'/g,'\x27\x5c\x27\x27')+'\x27';}function coreNodePtySpawnHelperPath(_0x2087ad){const _0x37f200=a0_0x5037bd;if(process[_0x37f200(0x1d2)]!==_0x37f200(0x144))return'';try{const _0x300f3d=(0x0,import_module[_0x37f200(0x18a)])(_0x2087ad),_0xeae5f9=_0x300f3d['resolve'](_0x37f200(0x159)),_0x36800d=path['resolve'](path[_0x37f200(0x1b7)](_0xeae5f9),'..');return path['join'](_0x36800d,_0x37f200(0x1ae),'darwin-'+process['arch'],'spawn-helper');}catch{return'';}}function checkMacNodePtySpawnHelper(_0x51e5ba){const _0x405a56=a0_0x5037bd,_0xd2dcd9=coreNodePtySpawnHelperPath(_0x51e5ba);if(!_0xd2dcd9||CHECKED_PTY_HELPERS[_0x405a56(0x15e)](_0xd2dcd9))return;CHECKED_PTY_HELPERS['add'](_0xd2dcd9);if(!fs['existsSync'](_0xd2dcd9)){console['warn'](_0x405a56(0x199)+_0x405a56(0x149)+'t\x20found:\x20'+_0xd2dcd9);return;}if(isExecutable(_0xd2dcd9))return;try{const _0x2b0073=fs['statSync'](_0xd2dcd9)[_0x405a56(0x1d4)];fs['chmodSync'](_0xd2dcd9,_0x2b0073|0x1ed);}catch{}if(isExecutable(_0xd2dcd9)){console[_0x405a56(0x1c0)]('[wrapper]\x20fixed\x20macO'+'S\x20node-pty\x20spawn-hel'+_0x405a56(0x1d6)+_0xd2dcd9);return;}console[_0x405a56(0x1c0)]('[wrapper]\x20macOS\x20node'+_0x405a56(0x155)+_0x405a56(0x19a)+_0xd2dcd9),console[_0x405a56(0x1c0)](_0x405a56(0x162)+_0x405a56(0x18e)+'PTY\x20startup:'),console['warn']('\x20\x20HELPER='+shellQuote(_0xd2dcd9)),console[_0x405a56(0x1c0)](_0x405a56(0x1a0)),console[_0x405a56(0x1c0)](_0x405a56(0x153));}function printVersion(){const _0x47d9e4=a0_0x5037bd;let _0x209198='';try{_0x209198=coreVersion();}catch{}console[_0x47d9e4(0x1d7)]('whalent-agent\x20'+WRAPPER_VERSION),console['log'](_0x47d9e4(0x179)+WRAPPER_VERSION),console[_0x47d9e4(0x1d7)](_0x47d9e4(0x1b2)+(_0x209198||'not\x20installed'));}function directCore(_0x5792ac){const _0x498e68=a0_0x5037bd,_0x4e3da3=findCoreScript();checkMacNodePtySpawnHelper(_0x4e3da3);const _0x55398d=(0x0,import_child_process2['spawnSync'])(process[_0x498e68(0x170)],[_0x4e3da3,..._0x5792ac],{'stdio':'inherit','env':{...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_CORE_ENTRY':_0x4e3da3},'shell':![]});process['exit'](_0x55398d['status']??0x0);}function shouldSupervise(_0xbfb32e){const _0x176dca=a0_0x5037bd;if(_0xbfb32e['includes'](_0x176dca(0x1ad)))return![];if(_0xbfb32e[_0x176dca(0x19e)]('--resume')||_0xbfb32e[0x0]===_0x176dca(0x173))return![];const _0x4c4b33=_0xbfb32e[0x0]||'';if(_0x4c4b33==='ls'||_0x4c4b33===_0x176dca(0x167)||_0x4c4b33==='ps')return![];if(_0x4c4b33===_0x176dca(0x1ab)||_0x4c4b33==='daemon-mcp')return![];if(_0xbfb32e['includes'](_0x176dca(0x1b3))||_0xbfb32e[_0x176dca(0x19e)]('-h'))return![];return!![];}function installCoreVersion(_0x1c559b){const _0x303279=a0_0x5037bd,_0x583e52=resolveExecutablePath(_0x303279(0x1c9));if(!_0x583e52)return{'ok':![],'output':_0x303279(0x193)+'H'};const _0x24b4d3=CORE_PKG_NAME+'@'+_0x1c559b,_0x548b3c=run(_0x583e52,['install','-g',_0x24b4d3,npmRegistryArg()]),_0x1e2545=((_0x548b3c['stdout']||'')+'\x0a'+(_0x548b3c['stderr']||''))['trim']();return{'ok':_0x548b3c[_0x303279(0x167)]===0x0,'output':_0x1e2545};}async function superviseCore(_0x1c7690){const _0xf3d7c8=a0_0x5037bd;let _0x2aea46=![],_0x56466a=null;const _0x2bbf15=[];let _0x2cb04e=MIN_RESTART_DELAY_MS;const _0x14fb16=()=>{const _0x8da95a=a0_0x12d6;_0x2aea46=!![];if(_0x56466a&&!_0x56466a[_0x8da95a(0x1a3)])try{_0x56466a[_0x8da95a(0x176)]('SIGTERM');}catch{}else process['exit'](0x0);};process['on'](_0xf3d7c8(0x146),_0x14fb16),process['on'](_0xf3d7c8(0x15a),_0x14fb16);while(!![]){const _0x1bfeee=findCoreScript();checkMacNodePtySpawnHelper(_0x1bfeee);const _0x550fd5={...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_WRAPPER_MANAGED':'1','WHALENT_CORE_ENTRY':_0x1bfeee},_0x4bdfde=readUpgradeState(),_0x24428b=!!_0x4bdfde?.[_0xf3d7c8(0x1ba)];let _0x9b71c6=![],_0xd3acf0=null,_0xeffd8c='';const _0x3c7c14=[],_0x5f8cd1=0xc;console['log'](_0xf3d7c8(0x17d)+_0xf3d7c8(0x1c7)+_0x1bfeee),_0x56466a=(0x0,import_child_process2['spawn'])(process['execPath'],[_0x1bfeee,..._0x1c7690],{'env':_0x550fd5,'stdio':['inherit',_0xf3d7c8(0x14b),_0xf3d7c8(0x14b)]});const _0x2afd17=()=>{const _0x3ea990=_0xf3d7c8;if(_0x9b71c6)return;_0x9b71c6=!![];if(_0xd3acf0)clearTimeout(_0xd3acf0);_0x2bbf15['length']=0x0,_0x2cb04e=MIN_RESTART_DELAY_MS;const _0x5adfd6=readUpgradeState();_0x5adfd6?.['pending']&&(writeUpgradeState({..._0x5adfd6,'pending':![],'rollback':![],'health_status':_0x3ea990(0x16d)}),console['log']('[wrapper]\x20core\x20upgra'+'de\x20healthy:\x20'+(_0x5adfd6['installed_version']||_0x5adfd6[_0x3ea990(0x180)]||'')));},_0xae01f9=(_0x1df0f7,_0x5920ed=![])=>{const _0x3f7204=_0xf3d7c8,_0x1d200d=_0x1df0f7[_0x3f7204(0x1a2)]();(_0x5920ed?process[_0x3f7204(0x163)]:process[_0x3f7204(0x1bd)])[_0x3f7204(0x1a7)](_0x1d200d);if(_0x5920ed)for(const _0x29f7ea of _0x1d200d[_0x3f7204(0x16e)](/\r?\n/)){if(!_0x29f7ea[_0x3f7204(0x14d)]())continue;_0x3c7c14['push'](_0x29f7ea);if(_0x3c7c14['length']>_0x5f8cd1)_0x3c7c14[_0x3f7204(0x154)]();const _0x1b0acb=_0x29f7ea[_0x3f7204(0x1b4)](FATAL_PATTERN);if(_0x1b0acb)_0xeffd8c=_0x1b0acb[0x0];}(_0x1d200d[_0x3f7204(0x19e)]('[gateway]\x20Connected')||_0x1d200d[_0x3f7204(0x19e)](_0x3f7204(0x150)+_0x3f7204(0x183))||_0x1d200d[_0x3f7204(0x19e)]('Gateway:\x20connected'))&&_0x2afd17();};_0x56466a[_0xf3d7c8(0x1bd)]?.['on']('data',_0x211d95=>_0xae01f9(_0x211d95,![])),_0x56466a['stderr']?.['on']('data',_0x45bfa4=>_0xae01f9(_0x45bfa4,!![]));_0x24428b&&(_0xd3acf0=setTimeout(()=>{const _0x134204=_0xf3d7c8;if(_0x9b71c6||!_0x56466a||_0x56466a['killed'])return;console[_0x134204(0x14c)]('[wrapper]\x20new\x20core\x20d'+_0x134204(0x19c)+_0x134204(0x16f)+'ack');try{_0x56466a[_0x134204(0x176)]('SIGTERM');}catch{}},HEALTH_TIMEOUT_MS));const _0x581f19=await new Promise(_0x40247e=>{_0x56466a['once']('exit',(_0x321448,_0x24e1c3)=>_0x40247e({'code':_0x321448,'signal':_0x24e1c3}));});if(_0xd3acf0)clearTimeout(_0xd3acf0);_0x56466a=null;if(_0x2aea46)process[_0xf3d7c8(0x15b)](_0x581f19[_0xf3d7c8(0x1dd)]??0x0);const _0x55733c=readUpgradeState();if(_0x55733c?.[_0xf3d7c8(0x1ba)]&&!_0x9b71c6){const _0x57c106=String(_0x55733c[_0xf3d7c8(0x186)+'n']||'')['trim']();if(_0x57c106){console[_0xf3d7c8(0x14c)](_0xf3d7c8(0x190)+'ck\x20core\x20to\x20'+_0x57c106);const _0x4ecaa3=installCoreVersion(_0x57c106);writeUpgradeState({..._0x55733c,'pending':![],'rollback':!![],'health_status':_0x4ecaa3['ok']?_0xf3d7c8(0x1ce):_0xf3d7c8(0x1c4),'error':_0x4ecaa3['ok']?'':_0x4ecaa3['output']});}else writeUpgradeState({..._0x55733c,'pending':![],'rollback':!![],'health_status':_0xf3d7c8(0x1cc),'error':'previous\x20core\x20versio'+'n\x20unknown'});}const _0x44ca01=_0x581f19[_0xf3d7c8(0x1dd)]===SUPERVISED_RESTART_CODE||_0x55733c?.[_0xf3d7c8(0x1ba)];if(!_0x44ca01&&_0x581f19[_0xf3d7c8(0x1dd)]===0x0)process['exit'](0x0);const _0xc3e311=Date[_0xf3d7c8(0x172)]();_0x2bbf15['push'](_0xc3e311);while(_0x2bbf15['length']>0x0&&_0xc3e311-_0x2bbf15[0x0]>CRASH_WINDOW_MS){_0x2bbf15['shift']();}const _0x5b2e68=_0x2bbf15['length'];writeLastCrash({'timestamp':_0xc3e311,'exit_code':_0x581f19['code'],'exit_signal':_0x581f19[_0xf3d7c8(0x197)]||null,'fatal_line':_0xeffd8c,'raw_tail':_0x3c7c14[_0xf3d7c8(0x168)]('\x0a'),'consecutive_crashes':_0x5b2e68}),console[_0xf3d7c8(0x1d7)]('[wrapper]\x20core\x20exite'+'d\x20code='+(_0x581f19[_0xf3d7c8(0x1dd)]??'')+(_0x581f19[_0xf3d7c8(0x197)]?_0xf3d7c8(0x1a6)+_0x581f19[_0xf3d7c8(0x197)]:'')+'\x20('+_0x5b2e68+'/'+MAX_CRASHES_IN_WINDOW+'\x20in\x20last\x20'+Math['round'](CRASH_WINDOW_MS/0x3e8)+'s)');if(_0xeffd8c)console['log']('[wrapper]\x20last\x20fatal'+':\x20'+_0xeffd8c);_0x5b2e68>=MAX_CRASHES_IN_WINDOW&&(console['error'](_0xf3d7c8(0x14a)+'d\x20'+_0x5b2e68+'\x20times\x20within\x20'+Math['round'](CRASH_WINDOW_MS/0x3e8)+('s;\x20giving\x20up.\x20Crash\x20'+_0xf3d7c8(0x152))+lastCrashFilePath()+('.\x20Restart\x20wrapper\x20ma'+_0xf3d7c8(0x1db)+_0xf3d7c8(0x17c)+_0xf3d7c8(0x161))),process[_0xf3d7c8(0x15b)](0x1)),console['log'](_0xf3d7c8(0x1c8)+_0xf3d7c8(0x1bb)+_0x2cb04e+'ms'),await new Promise(_0x41110c=>setTimeout(_0x41110c,_0x2cb04e)),_0x2cb04e=Math['min'](_0x2cb04e*0x2,MAX_RESTART_DELAY_MS);}}async function main(){const _0xa6653b=a0_0x5037bd,_0x5be0b5=process['argv'][_0xa6653b(0x1c1)](0x2);if(_0x5be0b5[0x0]==='--version'||_0x5be0b5[0x0]==='-v'||_0x5be0b5[0x0]===_0xa6653b(0x1b9)){printVersion();return;}if((_0x5be0b5[0x0]===_0xa6653b(0x167)||_0x5be0b5[0x0]==='ls'||_0x5be0b5[0x0]==='ps')&&!_0x5be0b5['includes']('--json')){console['log'](_0xa6653b(0x179)+WRAPPER_VERSION);try{console['log']('core\x20'+(coreVersion()||'not\x20installed'));}catch{console['log'](_0xa6653b(0x1b8));}}maybeUpdateWrapper(_0x5be0b5);if(!shouldSupervise(_0x5be0b5))directCore(_0x5be0b5);await superviseCore(_0x5be0b5);}main()['catch'](_0x550cfc=>{const _0x5c8552=a0_0x5037bd;console['error']('[wrapper]\x20Fatal\x20erro'+'r:\x20'+(_0x550cfc?.['message']||String(_0x550cfc))),process[_0x5c8552(0x15b)](0x1);});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whalent/agent",
3
- "version": "0.3.110",
3
+ "version": "0.3.112",
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.110",
46
+ "@whalent/agent-core": "0.3.112",
47
47
  "node-pty": "^1.1.0"
48
48
  },
49
49
  "devDependencies": {