@whalent/agent 0.3.98 → 0.3.100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.cjs +7 -7
- package/dist/index.cjs +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
'use strict';const a0_0x41e4c3=a0_0x3c08;(function(_0x450bd5,_0x2abb69){const _0x4543bf=a0_0x3c08,_0x1f0b04=_0x450bd5();while(!![]){try{const _0x47f6f3=-parseInt(_0x4543bf(0x18c))/0x1*(parseInt(_0x4543bf(0x155))/0x2)+parseInt(_0x4543bf(0x166))/0x3+-parseInt(_0x4543bf(0x128))/0x4+parseInt(_0x4543bf(0x15f))/0x5*(-parseInt(_0x4543bf(0x147))/0x6)+-parseInt(_0x4543bf(0x127))/0x7+parseInt(_0x4543bf(0x125))/0x8+parseInt(_0x4543bf(0x138))/0x9*(parseInt(_0x4543bf(0x12a))/0xa);if(_0x47f6f3===_0x2abb69)break;else _0x1f0b04['push'](_0x1f0b04['shift']());}catch(_0x58cb26){_0x1f0b04['push'](_0x1f0b04['shift']());}}}(a0_0x7c88,0x5f042));var __create=Object[a0_0x41e4c3(0x175)],__defProp=Object['defineProperty'],__getOwnPropDesc=Object[a0_0x41e4c3(0x178)+'ptor'],__getOwnPropNames=Object['getOwnPropertyNames'],__getProtoOf=Object[a0_0x41e4c3(0x10e)],__hasOwnProp=Object[a0_0x41e4c3(0x154)][a0_0x41e4c3(0x143)],__copyProps=(_0x142f9d,_0x5b7886,_0x2264e5,_0x3f75e9)=>{const _0x110014=a0_0x41e4c3;if(_0x5b7886&&typeof _0x5b7886==='object'||typeof _0x5b7886===_0x110014(0x183)){for(let _0x2170bf of __getOwnPropNames(_0x5b7886))if(!__hasOwnProp[_0x110014(0x134)](_0x142f9d,_0x2170bf)&&_0x2170bf!==_0x2264e5)__defProp(_0x142f9d,_0x2170bf,{'get':()=>_0x5b7886[_0x2170bf],'enumerable':!(_0x3f75e9=__getOwnPropDesc(_0x5b7886,_0x2170bf))||_0x3f75e9['enumerable']});}return _0x142f9d;},__toESM=(_0x1aa222,_0x256e52,_0x3d7461)=>(_0x3d7461=_0x1aa222!=null?__create(__getProtoOf(_0x1aa222)):{},__copyProps(_0x256e52||!_0x1aa222||!_0x1aa222['__esModule']?__defProp(_0x3d7461,a0_0x41e4c3(0x131),{'value':_0x1aa222,'enumerable':!![]}):_0x3d7461,_0x1aa222)),import_child_process2=require(a0_0x41e4c3(0x122)),fs=__toESM(require('fs'),0x1),import_module=require(a0_0x41e4c3(0x176)),os=__toESM(require('os'),0x1),path=__toESM(require(a0_0x41e4c3(0x161)),0x1),import_child_process=require('child_process'),import_fs=require('fs'),import_path=require(a0_0x41e4c3(0x161));function isWindowsCmdFile(_0x12da4d){const _0x595277=a0_0x41e4c3;return process[_0x595277(0x14b)]===_0x595277(0x157)&&/\.(cmd|bat)$/i['test'](_0x12da4d||'');}function quoteCmdArg(_0x508c1b){const _0x47c260=a0_0x41e4c3,_0x2af12c=String(_0x508c1b??'');if(_0x2af12c&&!/[\s"&|<>^%]/['test'](_0x2af12c))return _0x2af12c;return'\x22'+_0x2af12c['replace'](/(["^&|<>%])/g,_0x47c260(0x156))+'\x22';}function cmdFallbackArgs(_0x3830d1,_0x2197b0){const _0x2934e1=a0_0x41e4c3;return['/d','/s','/c',[quoteCmdArg(_0x3830d1),..._0x2197b0[_0x2934e1(0x121)](quoteCmdArg)][_0x2934e1(0x177)]('\x20')];}function resolveExecutablePath(_0x14a210){const _0x2a49a6=a0_0x41e4c3;if(!_0x14a210)return null;if(_0x14a210[_0x2a49a6(0xf5)]('/')||_0x14a210[_0x2a49a6(0xf5)]('\x5c')||/\.[A-Za-z0-9]{1,5}$/['test'](_0x14a210))return(0x0,import_fs['existsSync'])(_0x14a210)?_0x14a210:_0x14a210;const _0x3f8d81=process[_0x2a49a6(0x14b)]==='win32',_0x55e56f=_0x3f8d81?'where.exe':'which';try{const _0x3f3c8b=(0x0,import_child_process[_0x2a49a6(0x185)])(_0x55e56f,[_0x14a210],{'encoding':_0x2a49a6(0xfd),'timeout':0xbb8,'shell':![]});if(_0x3f3c8b['status']===0x0){const _0x435751=(_0x3f3c8b['stdout']||'')[_0x2a49a6(0x15d)]()['split'](/\r?\n/)[_0x2a49a6(0x189)](Boolean);if(_0x435751['length']===0x0)return null;if(_0x3f8d81)for(const _0x215a90 of['.exe',_0x2a49a6(0xfa),_0x2a49a6(0x129),'.ps1']){const _0x209e12=_0x435751[_0x2a49a6(0x14e)](_0x134324=>_0x134324['toLowerCase']()[_0x2a49a6(0x14a)](_0x215a90));if(_0x209e12)return _0x209e12;}return _0x435751[0x0]||null;}}catch{}return null;}function unwrapWindowsCmdShim(_0x21be31){const _0x520ae7=a0_0x41e4c3;if(process['platform']!==_0x520ae7(0x157))return null;if(!/\.(cmd|bat)$/i['test'](_0x21be31))return null;let _0x1aa830;try{_0x1aa830=(0x0,import_fs['readFileSync'])(_0x21be31,'utf-8');}catch{return null;}const _0x396cc8=_0x1aa830['match'](/"(%~?dp0%?)[\\/]+([^"]+\.(?:js|cjs|mjs))"/i);if(_0x396cc8){const _0x80df00=(0x0,import_path[_0x520ae7(0x174)])((0x0,import_path[_0x520ae7(0x15a)])(_0x21be31),_0x396cc8[0x2]);if((0x0,import_fs[_0x520ae7(0x15c)])(_0x80df00))return{'type':'node','path':_0x80df00};}const _0x27aefd=_0x1aa830[_0x520ae7(0x16e)](/"(%~?dp0%?)[\\/]+([^"]+\.exe)"/i);if(_0x27aefd){const _0x46c748=(0x0,import_path['resolve'])((0x0,import_path['dirname'])(_0x21be31),_0x27aefd[0x2]);if((0x0,import_fs['existsSync'])(_0x46c748))return{'type':'exe','path':_0x46c748};}return null;}function safeSpawnSync(_0xc93243,_0x5c754f,_0x33cc19={}){const _0x214d93=a0_0x41e4c3,_0x22f054=unwrapWindowsCmdShim(_0xc93243);if(_0x22f054?.[_0x214d93(0x17e)]==='node')return(0x0,import_child_process['spawnSync'])(process[_0x214d93(0x136)],[_0x22f054[_0x214d93(0x161)],..._0x5c754f],_0x33cc19);if(_0x22f054?.[_0x214d93(0x17e)]==='exe')return(0x0,import_child_process[_0x214d93(0x185)])(_0x22f054[_0x214d93(0x161)],_0x5c754f,_0x33cc19);if(isWindowsCmdFile(_0xc93243))return(0x0,import_child_process[_0x214d93(0x185)])(process.env.ComSpec||_0x214d93(0x171),cmdFallbackArgs(_0xc93243,_0x5c754f),_0x33cc19);return(0x0,import_child_process['spawnSync'])(_0xc93243,_0x5c754f,_0x33cc19);}function a0_0x7c88(){const _0x4be7d8=['B3v0Chv0','Bwf4','y21KlMv4zq','ANmUB3jN','ChvZAa','CMvZB2X2zq','y3jLyxrL','Bw9KDwXL','AM9PBG','z2v0t3DUuhjVCgvYDhLezxnJCMK','u0Lhvevstq','C29YDa','AgvHBhrOEq','zgfYD2LUlq','ic0+ia','DhLWzq','zgf0yq','Bw9Kzq','igzYB20GBNbTigjLzM9YzsbZDge','ig5VzguTChr5igjLzM9YzsbZDge','zNvUy3rPB24','j1WNjW','C3bHD25tEw5J','CNrPBMCGy29Yzs4UlG','y3jLyxrLuMvXDwLYzq','qgXHDgvZDa','zMLSDgvY','w3DYyxbWzxjDig5VzguTChr5igq','yxrPDMuGBw9KDwXLigLZig1PC3m','nZi3Exvhwvrl','Aw5OzxjPDa','w3DYyxbWzxjDigzPEgvKig1Hy08','BNbTig5VDcbMB3vUzcbVBIbqqvq','Aw5JBhvKzxm','lxb0EsbZCgf3BI1OzwXWzxiGBM8','CMvWBgfJzq','qhDOywXLBNq','BM90igLUC3rHBgXLza','lMnTza','y2HTB2rtEw5J','Aw5KzxG','DxrMltG','A2LSBa','igLUia','CgfJA2fNzs5QC29U','oYbJB3jLig1HEsbMywLSihrVihm','w3DYyxbWzxjDihjLC3rHCNrPBMC','zgfYD2LU','ls1QC29U','r2f0zxDHEsbYzwDPC3rLCMvKig0','CgvUzgLUzW','y2SGy29Yzsb0BYa','C3rKB3v0','icbJzca','CgLWzq','Dg9mB3DLCKnHC2u','Aw5KzxGUy2PZ','w3DYyxbWzxjDig5VzguTChr5ihi','z2v0uhjVDg90ExbLt2y','ls12zxjZAw9U','EsbPBIb0Aw1LoYbYB2XSAw5Nigi','ChjLDMLVDxmGy29Yzsb2zxjZAw8','AgfZ','qhDOywXLBNqVywDLBNq','w3DYyxbWzxjDihvWzgf0zsbHDMe','D2HHBgvUDc1Hz2vUDca','y29Yzq','icbiruXqrvi9','ls1YzwDPC3rYEt0','EwvZ','y29Kzq','BM93','w3DYyxbWzxjDig5LDYbJB3jLigq','BNbT','CgfYC2vjBNq','ig5VDcbMB3vUzdSGAw5ZDgfSBca','zgLZDa','BwfW','y2HPBgrFChjVy2vZCW','CJOG','ywrK','mtqYnJm2mgHuyxn0zW','icHLEgL0pq','mJmXmtKXogvVCMnTBq','mtq0nZqZmKDVzxriyW','lMjHDa','mJy0mZqZmgvOD2DptW','BwvZC2fNzq','B3iGCMvIDwLSzcbaD2HHBgvUDc8','ywDLBNqTy29Yzq','C2LNBMfS','C3rHDhvZ','zgfLBw9Ulw1JCa','zgvMyxvSDa','A2LSBgvK','D3jPDgvgAwXLu3LUyW','y2fSBa','C3bSAxq','zxHLy1bHDgG','Bg9N','mJD2thDRz0W','C3bHD24','D3jPDgu','BwTKAxjtEw5J','DMvYC2LVBG','C3rYAw5NAwz5','ChjLDMLVDxnFy29Yzv92zxjZAw8','D2fYBG','C3rKzxjY','C3rHDfn5BMm','zxHPDa','AgfZt3DUuhjVCgvYDhK','DxrMoa','Ahr0Chm6lY9YzwDPC3rYEs5UCg0','Aw5NihvUzgvYia','odm0nZi2Auncv09h','ls1Yzxn1Bwu','w3DYyxbWzxjDihjVBgXPBMCGyMe','zw5KC1DPDgG','CgXHDgzVCM0','BM9Kzs1WDhK','zguGAgvHBhrOEtOG','zMLUza','y29YzsbUB3qGAw5ZDgfSBgvK','CM9SBgjHy2TFDw5HDMfPBgfIBgu','Cg9W','BgvUz3rO','AwqGBM90igjLy29TzsbOzwfSDgG','ChjVDg90ExbL','ntG4vevsrKvU','xIqX','D2LUmZi','yxjNDG','BNbTig5VDcbMB3vUza','zgLYBMfTzq','CMvHzezPBgvtEw5J','zxHPC3rZu3LUyW','DhjPBq','Aw5ZDgfSBa','nwz6s0rrwG','BIb1BMTUB3DU','Cgf0Aa','BNvHBgX5igfMDgvYihrOzsb1BMq','Dg9tDhjPBMC','zwqU','Dw5KoYbJyw5UB3qGCMvIDwLSzca','mtm4odu1oxHOyMXdAa','zxbLBMrLBMn5ig5VDcbYzxnVBhy','BMnLihrVigzPEcb0zxjTAw5HBc8','yNvPBgq','w2DHDgv3yxLDienVBM5Ly3rLza','CM9VDa','mc4WlJa','w3DYyxbWzxjDignVCMuGzxHPDgu','Bwf0y2G'];a0_0x7c88=function(){return _0x4be7d8;};return a0_0x7c88();}var WRAPPER_PKG_NAME=a0_0x41e4c3(0x113),CORE_PKG_NAME='@whalent/agent-core',NPM_REGISTRY=a0_0x41e4c3(0x145)+a0_0x41e4c3(0x172),SUPERVISED_RESTART_CODE=0x4b,NPM_VIEW_TIMEOUT_MS=0x3a98,HEALTH_TIMEOUT_MS=0xafc8,MIN_RESTART_DELAY_MS=0x3e8,MAX_RESTART_DELAY_MS=0xea60,MAX_CRASHES_IN_WINDOW=0x3,CRASH_WINDOW_MS=0x3*0x3c*0x3e8,NPM_INSTALL_TIMEOUT_MS=0xa*0x3c*0x3e8,NPM_INSTALL_MAX_BUFFER=0x20*0x400*0x400,FATAL_PATTERN=/\[(?:agent|daemon|wrapper)\][^\n]*\bFatal error:[^\n]+|\[daemon\] Failed to start:[^\n]+|Error:[^\n]+/,WRAPPER_VERSION=readWrapperVersion(),CHECKED_PTY_HELPERS=new Set(),CHECKED_NODE_PTY_RUNTIMES=new Set();function wrapperBaseDir(){return __dirname;}function configDir(){return path['join'](os['homedir'](),'.whalent-agent');}function upgradeStatePath(){return path['join'](configDir(),'core-upgrade.json');}function lastCrashFilePath(){return path['join'](configDir(),'last-crash.json');}function writeLastCrash(_0x3fb218){const _0x5de597=a0_0x41e4c3;try{fs['mkdirSync'](configDir(),{'recursive':!![]});const _0x139c2d={..._0x3fb218,'reported':![]};fs[_0x5de597(0x133)](lastCrashFilePath(),JSON[_0x5de597(0x13d)](_0x139c2d,null,0x2),'utf-8');}catch{}}function readWrapperVersion(){const _0x538486=a0_0x41e4c3;try{const _0x4fc9d4=JSON['parse'](fs[_0x538486(0x15b)](path[_0x538486(0x177)](wrapperBaseDir(),'..','package.json'),_0x538486(0xfd)));return String(_0x4fc9d4['version']||_0x538486(0x16c));}catch{return _0x538486(0x16c);}}function readUpgradeState(){try{return JSON['parse'](fs['readFileSync'](upgradeStatePath(),'utf-8'));}catch{return null;}}function writeUpgradeState(_0x22bd89){const _0x665cca=a0_0x41e4c3;try{fs[_0x665cca(0x13b)](configDir(),{'recursive':!![]}),fs['writeFileSync'](upgradeStatePath(),JSON['stringify']({..._0x22bd89,'updated_at':Date[_0x665cca(0x11b)]()},null,0x2),'utf-8');}catch{}}function run(_0x15c644,_0x3fb192,_0x314eac=process.env){return safeSpawnSync(_0x15c644,_0x3fb192,{'encoding':'utf8','timeout':NPM_INSTALL_TIMEOUT_MS,'maxBuffer':NPM_INSTALL_MAX_BUFFER,'env':_0x314eac,'shell':![]});}function runNpmView(_0x428899){const _0x461af7=a0_0x41e4c3,_0x1de8aa=resolveExecutablePath(_0x461af7(0x11d));if(!_0x1de8aa)return{'status':0x7f,'stdout':'','stderr':_0x461af7(0x159),'error':new Error(_0x461af7(0x159))};return safeSpawnSync(_0x1de8aa,_0x428899,{'encoding':_0x461af7(0x144),'timeout':NPM_VIEW_TIMEOUT_MS,'maxBuffer':0x400*0x400,'env':process.env,'shell':![]});}function npmRootGlobal(){const _0x41445b=a0_0x41e4c3,_0x2de44b=resolveExecutablePath(_0x41445b(0x11d));if(!_0x2de44b)return'';const _0x4eca25=run(_0x2de44b,[_0x41445b(0x16b),'-g']);if(_0x4eca25['status']!==0x0)return'';return String(_0x4eca25['stdout']||'')[_0x41445b(0x15d)]();}function compareSemver(_0x6154d,_0x38cef5){const _0x585d4b=a0_0x41e4c3,_0x1c5a15=String(_0x6154d||'')[_0x585d4b(0xf7)](/^v/,'')[_0x585d4b(0x135)](/[.-]/)['map'](_0x558489=>Number[_0x585d4b(0x11e)](_0x558489,0xa)||0x0),_0x2bc69d=String(_0x38cef5||'')['replace'](/^v/,'')[_0x585d4b(0x135)](/[.-]/)[_0x585d4b(0x121)](_0x34f76b=>Number[_0x585d4b(0x11e)](_0x34f76b,0xa)||0x0);for(let _0x50528b=0x0;_0x50528b<Math[_0x585d4b(0x170)](_0x1c5a15[_0x585d4b(0x152)],_0x2bc69d['length'],0x3);_0x50528b++){const _0x24ccfe=_0x1c5a15[_0x50528b]||0x0,_0x3c3863=_0x2bc69d[_0x50528b]||0x0;if(_0x24ccfe>_0x3c3863)return 0x1;if(_0x24ccfe<_0x3c3863)return-0x1;}return 0x0;}function skipWrapperUpdateCheck(){const _0x5adcf2=a0_0x41e4c3,_0x165afe=String(process.env.WHALENT_SKIP_UPDATE_CHECK||process.env.WHALENT_NO_UPDATE_CHECK||process.env.WHALENT_SKIP_WRAPPER_UPDATE||'')['trim']()[_0x5adcf2(0x10b)]();return _0x165afe==='1'||_0x165afe==='true'||_0x165afe===_0x5adcf2(0x119)||_0x165afe==='on';}function latestWrapperVersion(){const _0x30ec54=a0_0x41e4c3,_0x655dec=runNpmView(['view',WRAPPER_PKG_NAME+_0x30ec54(0x188),'version',_0x30ec54(0x118)+NPM_REGISTRY]);if(_0x655dec['status']!==0x0)return'';return String(_0x655dec['stdout']||'')[_0x30ec54(0x15d)]()[_0x30ec54(0x135)](/\r?\n/)[_0x30ec54(0x189)](Boolean)[_0x30ec54(0x151)]()||'';}function installWrapperVersion(_0xba6a83){const _0x541ae0=a0_0x41e4c3,_0x2a9706=resolveExecutablePath('npm');if(!_0x2a9706)return{'ok':![],'output':'npm\x20not\x20found\x20on\x20PAT'+'H'};const _0x84650=run(_0x2a9706,['install','-g',WRAPPER_PKG_NAME+'@'+_0xba6a83,'--registry='+NPM_REGISTRY]),_0x475e0f=((_0x84650[_0x541ae0(0x108)]||'')+'\x0a'+(_0x84650['stderr']||''))['trim']();return{'ok':_0x84650['status']===0x0,'output':_0x475e0f};}function maybeUpdateWrapper(_0x3140cd){const _0x53af9a=a0_0x41e4c3;if(skipWrapperUpdateCheck())return![];if(process.env.WHALENT_WRAPPER_UPDATE_ATTEMPTED)return![];const _0x25e24a=latestWrapperVersion();if(!_0x25e24a||compareSemver(_0x25e24a,WRAPPER_VERSION)<=0x0)return![];console['warn'](_0x53af9a(0x114)+'ilable:\x20'+WRAPPER_VERSION+_0x53af9a(0x17d)+_0x25e24a),console[_0x53af9a(0x13f)]('[wrapper]\x20installing'+'\x20'+WRAPPER_PKG_NAME+'@'+_0x25e24a+(_0x53af9a(0x181)+_0x53af9a(0x186)));const _0x3ca1d2=installWrapperVersion(_0x25e24a);if(!_0x3ca1d2['ok']){console['warn']('[wrapper]\x20wrapper\x20up'+'date\x20failed;\x20continu'+'ing\x20with\x20'+WRAPPER_VERSION);if(_0x3ca1d2['output'])console['warn'](_0x3ca1d2[_0x53af9a(0x16f)][_0x53af9a(0x135)](/\r?\n/)['slice'](-0xc)[_0x53af9a(0x177)]('\x0a'));return console[_0x53af9a(0x13f)]('[wrapper]\x20Manual\x20upd'+'ate:\x20npm\x20install\x20-g\x20'+WRAPPER_PKG_NAME+'@'+_0x25e24a+'\x20--registry='+NPM_REGISTRY),![];}console[_0x53af9a(0x13f)]('[wrapper]\x20wrapper\x20up'+'dated\x20to\x20'+_0x25e24a+';\x20restarting\x20wrapper');const _0x421bbe=process[_0x53af9a(0x158)][0x1],_0xae333f=(0x0,import_child_process2[_0x53af9a(0x185)])(process['execPath'],[_0x421bbe,..._0x3140cd],{'stdio':_0x53af9a(0x18d),'env':{...process.env,'WHALENT_WRAPPER_UPDATE_ATTEMPTED':_0x25e24a},'shell':![]});process[_0x53af9a(0x142)](_0xae333f[_0x53af9a(0x12f)]??0x0);}function findCoreScript(){const _0x4d161b=a0_0x41e4c3,_0x3893d7=String(process.env.WHALENT_CORE_ENTRY||'')['trim'](),_0x14c721=['1','true',_0x4d161b(0x119),'on']['includes'](String(process.env.WHALENT_FORCE_CORE_ENTRY||'')[_0x4d161b(0x15d)]()['toLowerCase']());if(_0x3893d7&&_0x14c721&&fs['existsSync'](_0x3893d7))return _0x3893d7;const _0x3f71ec=[],_0x41aecf=_0x24782c=>{const _0xbb3405=_0x4d161b;if(fs['existsSync'](_0x24782c)&&!_0x3f71ec['includes'](_0x24782c))_0x3f71ec[_0xbb3405(0x173)](_0x24782c);};if(_0x3893d7)_0x41aecf(_0x3893d7);const _0x4b5ab9=npmRootGlobal();if(_0x4b5ab9){const _0x1fa1d1=path['join'](_0x4b5ab9,_0x4d161b(0xf8),_0x4d161b(0x12d),_0x4d161b(0x120),_0x4d161b(0x10c));_0x41aecf(_0x1fa1d1);}const _0x3b3f59=path['join'](wrapperBaseDir(),'core.cjs');_0x41aecf(_0x3b3f59);const _0x248736=path['join'](wrapperBaseDir(),'..','packages',_0x4d161b(0x116),'dist','index.cjs');_0x41aecf(_0x248736);if(_0x3f71ec['length']>0x0)return _0x3f71ec['map']((_0x40a6d9,_0x4a89c5)=>({'candidate':_0x40a6d9,'index':_0x4a89c5,'version':coreVersion(_0x40a6d9)}))[_0x4d161b(0x17a)]((_0x387940,_0x40e526)=>{const _0x4a9aef=_0x4d161b,_0x21f1bc=compareSemver(_0x40e526['version'],_0x387940[_0x4a9aef(0x13c)]);if(_0x21f1bc!==0x0)return _0x21f1bc;return _0x40e526[_0x4a9aef(0xfc)]-_0x387940['index'];})[0x0]['candidate'];throw new Error('whalent\x20core\x20runtime'+_0x4d161b(0x11f)+'@whalent/agent-core\x20'+_0x4d161b(0x12c)+'agent');}function coreVersion(_0x4c3dcf=findCoreScript()){const _0x12405f=a0_0x41e4c3;ensureNodePtyNativeModule(_0x4c3dcf);const _0x113975=(0x0,import_child_process2['spawnSync'])(process['execPath'],[_0x4c3dcf,'--version'],{'encoding':'utf8','timeout':0x3a98,'env':{...process.env,'WHALENT_SKIP_UPDATE_CHECK':'1'},'shell':![]}),_0x2ed4a7=(_0x113975[_0x12405f(0x108)]||'')+'\x0a'+(_0x113975[_0x12405f(0x140)]||'');return _0x2ed4a7['match'](/(\d+\.\d+\.\d+(?:[-\w.]+)?)/)?.[0x1]||'';}function isExecutable(_0x49037c){try{return fs['accessSync'](_0x49037c,fs['constants']['X_OK']),!![];}catch{return![];}}function shellQuote(_0x1c7de5){const _0x2aa831=a0_0x41e4c3;return'\x27'+_0x1c7de5['replace'](/'/g,_0x2aa831(0x184))+'\x27';}function corePackageRoot(_0x4011a5){const _0x574e3c=a0_0x41e4c3;return path['resolve'](path[_0x574e3c(0x15a)](_0x4011a5),'..');}function nodePtyPackageRoot(_0x5a7102){const _0x167245=a0_0x41e4c3,_0x19f233=(0x0,import_module['createRequire'])(_0x5a7102),_0x17690a=_0x19f233[_0x167245(0x174)](_0x167245(0x14c));let _0x400a67=path[_0x167245(0x15a)](_0x17690a);for(let _0x620510=0x0;_0x620510<0x5;_0x620510++){const _0x191f3b=path[_0x167245(0x177)](_0x400a67,_0x167245(0x100));try{const _0x4ff5c5=JSON['parse'](fs['readFileSync'](_0x191f3b,'utf-8'));if(_0x4ff5c5['name']===_0x167245(0x14c))return _0x400a67;}catch{}const _0x3f9e00=path['dirname'](_0x400a67);if(_0x3f9e00===_0x400a67)break;_0x400a67=_0x3f9e00;}return path[_0x167245(0x174)](path[_0x167245(0x15a)](_0x17690a),'..');}function nodePtyNativeCandidates(_0x3ec6b5){const _0x11a933=a0_0x41e4c3;return[path[_0x11a933(0x177)](_0x3ec6b5,_0x11a933(0x169),'Release','pty.node'),path['join'](_0x3ec6b5,'prebuilds',process[_0x11a933(0x14b)]+'-'+process['arch'],'pty.node')];}function hasNodePtyNativeModule(_0x3c4bb2){return nodePtyNativeCandidates(_0x3c4bb2)['some'](_0x3ba2fa=>fs['existsSync'](_0x3ba2fa));}function printNodePtyRebuildHint(_0x509a2d){const _0x52c2a4=a0_0x41e4c3,_0x3b14e0=corePackageRoot(_0x509a2d);console['warn']('[wrapper]\x20Manual\x20fix'+':'),console[_0x52c2a4(0x13f)](_0x52c2a4(0x109)+shellQuote(_0x3b14e0)),console[_0x52c2a4(0x13f)]('\x20\x20npm\x20rebuild\x20node-p'+'ty\x20--verbose');}function ensureNodePtyNativeModule(_0x4e9ff1){const _0x469499=a0_0x41e4c3;if(process['platform']===_0x469499(0x157))return;let _0x18b7e7='';try{_0x18b7e7=nodePtyPackageRoot(_0x4e9ff1);}catch(_0x4d8c3a){console['warn'](_0x469499(0x18a)+_0x469499(0x167)+'able\x20for\x20core:\x20'+_0x4d8c3a[_0x469499(0x12b)]),printNodePtyRebuildHint(_0x4e9ff1);return;}const _0x3a1628=((()=>{try{return fs['realpathSync'](_0x18b7e7);}catch{return _0x18b7e7;}})());if(CHECKED_NODE_PTY_RUNTIMES[_0x469499(0x112)](_0x3a1628))return;CHECKED_NODE_PTY_RUNTIMES[_0x469499(0x124)](_0x3a1628);if(hasNodePtyNativeModule(_0x18b7e7))return;const _0x1cc115=resolveExecutablePath('npm');console['warn']('[wrapper]\x20node-pty\x20n'+_0x469499(0x18b)+_0x469499(0x146)+_0x18b7e7),console['warn']('[wrapper]\x20rebuilding'+_0x469499(0x182)+_0x469499(0x186));if(!_0x1cc115){console[_0x469499(0x13f)]('[wrapper]\x20npm\x20not\x20fo'+_0x469499(0x165)+'node-pty\x20automatical'+'ly'),printNodePtyRebuildHint(_0x4e9ff1);return;}const _0xf8f595=corePackageRoot(_0x4e9ff1),_0x599243=safeSpawnSync(_0x1cc115,['rebuild','node-pty','--verbose'],{'cwd':_0xf8f595,'stdio':_0x469499(0x18d),'timeout':NPM_INSTALL_TIMEOUT_MS,'env':process.env,'shell':![]});if(_0x599243[_0x469499(0x12f)]===0x0&&hasNodePtyNativeModule(_0x18b7e7)){console['warn'](_0x469499(0x10d)+'ebuild\x20completed');return;}console[_0x469499(0x13f)](_0x469499(0x10d)+'ebuild\x20failed'+(_0x599243['status']!==null?_0x469499(0x126)+_0x599243['status']+')':'')+(_0x469499(0x101)+'tart')),printNodePtyRebuildHint(_0x4e9ff1);}function coreNodePtySpawnHelperPath(_0x3ede55){const _0x59fa21=a0_0x41e4c3;if(process['platform']!==_0x59fa21(0x103))return'';try{const _0x59c43e=(0x0,import_module[_0x59fa21(0x187)])(_0x3ede55),_0x3cde6f=_0x59c43e[_0x59fa21(0x174)](_0x59fa21(0x14c)),_0x56bfc4=path['resolve'](path[_0x59fa21(0x15a)](_0x3cde6f),'..');return path['join'](_0x56bfc4,'prebuilds',_0x59fa21(0x17c)+process['arch'],'spawn-helper');}catch{return'';}}function a0_0x3c08(_0x121d65,_0x230323){_0x121d65=_0x121d65-0xf4;const _0x7c88a0=a0_0x7c88();let _0x3c0862=_0x7c88a0[_0x121d65];if(a0_0x3c08['gTWYgG']===undefined){var _0x42732a=function(_0x135749){const _0x2c4982='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x142f9d='',_0x5b7886='';for(let _0x2264e5=0x0,_0x3f75e9,_0x2170bf,_0x1aa222=0x0;_0x2170bf=_0x135749['charAt'](_0x1aa222++);~_0x2170bf&&(_0x3f75e9=_0x2264e5%0x4?_0x3f75e9*0x40+_0x2170bf:_0x2170bf,_0x2264e5++%0x4)?_0x142f9d+=String['fromCharCode'](0xff&_0x3f75e9>>(-0x2*_0x2264e5&0x6)):0x0){_0x2170bf=_0x2c4982['indexOf'](_0x2170bf);}for(let _0x256e52=0x0,_0x3d7461=_0x142f9d['length'];_0x256e52<_0x3d7461;_0x256e52++){_0x5b7886+='%'+('00'+_0x142f9d['charCodeAt'](_0x256e52)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x5b7886);};a0_0x3c08['viuQho']=_0x42732a,a0_0x3c08['sYQhgA']={},a0_0x3c08['gTWYgG']=!![];}const _0x2162bd=_0x7c88a0[0x0],_0x3a0fa6=_0x121d65+_0x2162bd,_0x314b6f=a0_0x3c08['sYQhgA'][_0x3a0fa6];return!_0x314b6f?(_0x3c0862=a0_0x3c08['viuQho'](_0x3c0862),a0_0x3c08['sYQhgA'][_0x3a0fa6]=_0x3c0862):_0x3c0862=_0x314b6f,_0x3c0862;}function checkMacNodePtySpawnHelper(_0xfd898a){const _0x49382b=a0_0x41e4c3,_0x4b33b5=coreNodePtySpawnHelperPath(_0xfd898a);if(!_0x4b33b5||CHECKED_PTY_HELPERS[_0x49382b(0x112)](_0x4b33b5))return;CHECKED_PTY_HELPERS['add'](_0x4b33b5);if(!fs[_0x49382b(0x15c)](_0x4b33b5)){console[_0x49382b(0x13f)]('[wrapper]\x20macOS\x20node'+_0x49382b(0xf6)+'t\x20found:\x20'+_0x4b33b5);return;}if(isExecutable(_0x4b33b5))return;try{const _0x3df388=fs[_0x49382b(0x141)](_0x4b33b5)[_0x49382b(0x180)];fs[_0x49382b(0xfb)](_0x4b33b5,_0x3df388|0x1ed);}catch{}if(isExecutable(_0x4b33b5)){console[_0x49382b(0x13f)](_0x49382b(0x18e)+'S\x20node-pty\x20spawn-hel'+'per\x20executable\x20bit:\x20'+_0x4b33b5);return;}console[_0x49382b(0x13f)]('[wrapper]\x20macOS\x20node'+'-pty\x20spawn-helper\x20is'+'\x20not\x20executable:\x20'+_0x4b33b5),console[_0x49382b(0x13f)]('[wrapper]\x20Run\x20this\x20o'+_0x49382b(0x168)+'PTY\x20startup:'),console['warn'](_0x49382b(0x117)+shellQuote(_0x4b33b5)),console['warn']('\x20\x20ls\x20-l\x20\x22$HELPER\x22'),console[_0x49382b(0x13f)]('\x20\x20chmod\x20+x\x20\x22$HELPER\x22');}function printVersion(){const _0x447cdb=a0_0x41e4c3;let _0x4640b0='';try{_0x4640b0=coreVersion();}catch{}console[_0x447cdb(0x137)](_0x447cdb(0x115)+WRAPPER_VERSION),console['log']('wrapper\x20'+WRAPPER_VERSION),console['log']('core\x20'+(_0x4640b0||'not\x20installed'));}function directCore(_0x274abe){const _0x288c8a=a0_0x41e4c3,_0x193d09=findCoreScript();ensureNodePtyNativeModule(_0x193d09),checkMacNodePtySpawnHelper(_0x193d09);const _0x37520d=(0x0,import_child_process2['spawnSync'])(process['execPath'],[_0x193d09,..._0x274abe],{'stdio':'inherit','env':{...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_CORE_ENTRY':_0x193d09},'shell':![]});process[_0x288c8a(0x142)](_0x37520d[_0x288c8a(0x12f)]??0x0);}function shouldSupervise(_0x134445){const _0x1ad86c=a0_0x41e4c3;if(_0x134445['includes']('--agent-id'))return![];if(_0x134445['includes'](_0x1ad86c(0x148))||_0x134445[0x0]==='resume')return![];const _0x188f63=_0x134445[0x0]||'';if(_0x188f63==='ls'||_0x188f63==='status'||_0x188f63==='ps')return![];if(_0x188f63==='mcp'||_0x188f63===_0x1ad86c(0x130))return![];if(_0x134445[_0x1ad86c(0xf5)]('--help')||_0x134445['includes']('-h'))return![];return!![];}function installCoreVersion(_0x219f32){const _0x3e3f70=a0_0x41e4c3,_0x554db7=resolveExecutablePath(_0x3e3f70(0x11d));if(!_0x554db7)return{'ok':![],'output':_0x3e3f70(0xf4)+'H'};const _0x5ed464=CORE_PKG_NAME+'@'+_0x219f32,_0x574c24=run(_0x554db7,[_0x3e3f70(0x15e),'-g',_0x5ed464,_0x3e3f70(0x118)+NPM_REGISTRY]),_0x363430=((_0x574c24[_0x3e3f70(0x108)]||'')+'\x0a'+(_0x574c24[_0x3e3f70(0x140)]||''))['trim']();return{'ok':_0x574c24[_0x3e3f70(0x12f)]===0x0,'output':_0x363430};}async function superviseCore(_0x51b657){const _0x26e38e=a0_0x41e4c3;let _0x395564=![],_0x44ff60=null;const _0x47e455=[];let _0x62c7ef=MIN_RESTART_DELAY_MS;const _0x5f2757=()=>{const _0x142912=a0_0x3c08;_0x395564=!![];if(_0x44ff60&&!_0x44ff60['killed'])try{_0x44ff60['kill'](_0x142912(0x179));}catch{}else process[_0x142912(0x142)](0x0);};process['on']('SIGINT',_0x5f2757),process['on']('SIGTERM',_0x5f2757);while(!![]){const _0x26e57a=findCoreScript();ensureNodePtyNativeModule(_0x26e57a),checkMacNodePtySpawnHelper(_0x26e57a);const _0x13dfaa={...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_WRAPPER_MANAGED':'1','WHALENT_CORE_ENTRY':_0x26e57a},_0x5ca1b2=readUpgradeState(),_0x4290d9=!!_0x5ca1b2?.['pending'];let _0xc8fbbf=![],_0x3bd9e8=null,_0x10cdeb='';const _0x108eaf=[],_0x1d05b2=0xc;console['log']('[wrapper]\x20starting\x20c'+'ore:\x20'+_0x26e57a),_0x44ff60=(0x0,import_child_process2[_0x26e38e(0x139)])(process[_0x26e38e(0x136)],[_0x26e57a,..._0x51b657],{'env':_0x13dfaa,'stdio':['inherit','pipe',_0x26e38e(0x10a)]});const _0x179e1d=()=>{const _0xb0f22b=_0x26e38e;if(_0xc8fbbf)return;_0xc8fbbf=!![];if(_0x3bd9e8)clearTimeout(_0x3bd9e8);_0x47e455[_0xb0f22b(0x152)]=0x0,_0x62c7ef=MIN_RESTART_DELAY_MS;const _0x1e87ff=readUpgradeState();_0x1e87ff?.['pending']&&(writeUpgradeState({..._0x1e87ff,'pending':![],'rollback':![],'health_status':_0xb0f22b(0x17b)}),console['log']('[wrapper]\x20core\x20upgra'+_0xb0f22b(0x14d)+(_0x1e87ff['installed_version']||_0x1e87ff['target_version']||'')));},_0x377746=(_0xbb9821,_0x335905=![])=>{const _0x10709e=_0x26e38e,_0x484e3f=_0xbb9821[_0x10709e(0x163)]();(_0x335905?process['stderr']:process[_0x10709e(0x108)])[_0x10709e(0x13a)](_0x484e3f);if(_0x335905)for(const _0x101be1 of _0x484e3f[_0x10709e(0x135)](/\r?\n/)){if(!_0x101be1[_0x10709e(0x15d)]())continue;_0x108eaf[_0x10709e(0x173)](_0x101be1);if(_0x108eaf[_0x10709e(0x152)]>_0x1d05b2)_0x108eaf['shift']();const _0x3dc700=_0x101be1['match'](FATAL_PATTERN);if(_0x3dc700)_0x10cdeb=_0x3dc700[0x0];}(_0x484e3f['includes'](_0x10709e(0x16a))||_0x484e3f['includes'](_0x10709e(0x105)+'achine')||_0x484e3f[_0x10709e(0xf5)]('Gateway:\x20connected'))&&_0x179e1d();};_0x44ff60[_0x26e38e(0x108)]?.['on'](_0x26e38e(0x17f),_0x2efc9c=>_0x377746(_0x2efc9c,![])),_0x44ff60['stderr']?.['on']('data',_0x5048f6=>_0x377746(_0x5048f6,!![]));_0x4290d9&&(_0x3bd9e8=setTimeout(()=>{const _0x4fd52a=_0x26e38e;if(_0xc8fbbf||!_0x44ff60||_0x44ff60[_0x4fd52a(0x132)])return;console['error'](_0x4fd52a(0x11c)+_0x4fd52a(0x153)+_0x4fd52a(0x110)+'ack');try{_0x44ff60[_0x4fd52a(0xfe)]('SIGTERM');}catch{}},HEALTH_TIMEOUT_MS));const _0x4dfe30=await new Promise(_0x4bc2de=>{_0x44ff60['once']('exit',(_0x2a82b1,_0x22d4d4)=>_0x4bc2de({'code':_0x2a82b1,'signal':_0x22d4d4}));});if(_0x3bd9e8)clearTimeout(_0x3bd9e8);_0x44ff60=null;if(_0x395564)process[_0x26e38e(0x142)](_0x4dfe30[_0x26e38e(0x11a)]??0x0);const _0x37b82=readUpgradeState();if(_0x37b82?.[_0x26e38e(0x106)]&&!_0xc8fbbf){const _0x4f9445=String(_0x37b82[_0x26e38e(0x13e)+'n']||'')[_0x26e38e(0x15d)]();if(_0x4f9445){console['error'](_0x26e38e(0x149)+_0x26e38e(0x107)+_0x4f9445);const _0x50ad3f=installCoreVersion(_0x4f9445);writeUpgradeState({..._0x37b82,'pending':![],'rollback':!![],'health_status':_0x50ad3f['ok']?'rolled_back':'rollback_failed','error':_0x50ad3f['ok']?'':_0x50ad3f['output']});}else writeUpgradeState({..._0x37b82,'pending':![],'rollback':!![],'health_status':_0x26e38e(0x150),'error':_0x26e38e(0x111)+_0x26e38e(0x160)});}const _0x1ffeef=_0x4dfe30[_0x26e38e(0x11a)]===SUPERVISED_RESTART_CODE||_0x37b82?.['pending'];if(!_0x1ffeef&&_0x4dfe30['code']===0x0)process['exit'](0x0);const _0x40f10d=Date[_0x26e38e(0x11b)]();_0x47e455['push'](_0x40f10d);while(_0x47e455[_0x26e38e(0x152)]>0x0&&_0x40f10d-_0x47e455[0x0]>CRASH_WINDOW_MS){_0x47e455['shift']();}const _0x445a76=_0x47e455['length'];writeLastCrash({'timestamp':_0x40f10d,'exit_code':_0x4dfe30[_0x26e38e(0x11a)],'exit_signal':_0x4dfe30['signal']||null,'fatal_line':_0x10cdeb,'raw_tail':_0x108eaf['join']('\x0a'),'consecutive_crashes':_0x445a76}),console[_0x26e38e(0x137)](_0x26e38e(0x16d)+'d\x20code='+(_0x4dfe30[_0x26e38e(0x11a)]??'')+(_0x4dfe30['signal']?'\x20signal='+_0x4dfe30[_0x26e38e(0x12e)]:'')+'\x20('+_0x445a76+'/'+MAX_CRASHES_IN_WINDOW+'\x20in\x20last\x20'+Math['round'](CRASH_WINDOW_MS/0x3e8)+'s)');if(_0x10cdeb)console['log']('[wrapper]\x20last\x20fatal'+':\x20'+_0x10cdeb);_0x445a76>=MAX_CRASHES_IN_WINDOW&&(console['error']('[wrapper]\x20core\x20faile'+'d\x20'+_0x445a76+'\x20times\x20within\x20'+Math['round'](CRASH_WINDOW_MS/0x3e8)+('s;\x20giving\x20up.\x20Crash\x20'+'record:\x20')+lastCrashFilePath()+('.\x20Restart\x20wrapper\x20ma'+_0x26e38e(0x162)+'erlying\x20issue\x20is\x20fix'+_0x26e38e(0x164))),process[_0x26e38e(0x142)](0x1)),console[_0x26e38e(0x137)](_0x26e38e(0x102)+_0x26e38e(0xff)+_0x62c7ef+'ms'),await new Promise(_0x22a412=>setTimeout(_0x22a412,_0x62c7ef)),_0x62c7ef=Math['min'](_0x62c7ef*0x2,MAX_RESTART_DELAY_MS);}}async function main(){const _0xbcf815=a0_0x41e4c3,_0x2374be=process['argv']['slice'](0x2);if(_0x2374be[0x0]===_0xbcf815(0x10f)||_0x2374be[0x0]==='-v'||_0x2374be[0x0]==='version'){printVersion();return;}if((_0x2374be[0x0]==='status'||_0x2374be[0x0]==='ls'||_0x2374be[0x0]==='ps')&&!_0x2374be[_0xbcf815(0xf5)](_0xbcf815(0x104))){console[_0xbcf815(0x137)]('wrapper\x20'+WRAPPER_VERSION);try{console[_0xbcf815(0x137)]('core\x20'+(coreVersion()||_0xbcf815(0xf9)));}catch{console[_0xbcf815(0x137)](_0xbcf815(0x14f));}}maybeUpdateWrapper(_0x2374be);if(!shouldSupervise(_0x2374be))directCore(_0x2374be);await superviseCore(_0x2374be);}main()['catch'](_0x3e7f00=>{const _0x18ee6a=a0_0x41e4c3;console['error']('[wrapper]\x20Fatal\x20erro'+_0x18ee6a(0x123)+(_0x3e7f00?.[_0x18ee6a(0x12b)]||String(_0x3e7f00))),process[_0x18ee6a(0x142)](0x1);});
|
|
2
|
+
'use strict';const a0_0x4376c1=a0_0x3884;(function(_0x241b09,_0x4532da){const _0x4b6fc1=a0_0x3884,_0x32f02a=_0x241b09();while(!![]){try{const _0x19912b=-parseInt(_0x4b6fc1(0x177))/0x1+parseInt(_0x4b6fc1(0xdf))/0x2*(-parseInt(_0x4b6fc1(0x170))/0x3)+-parseInt(_0x4b6fc1(0x104))/0x4+-parseInt(_0x4b6fc1(0xdb))/0x5*(-parseInt(_0x4b6fc1(0x103))/0x6)+-parseInt(_0x4b6fc1(0x10b))/0x7*(parseInt(_0x4b6fc1(0xe3))/0x8)+-parseInt(_0x4b6fc1(0x11b))/0x9+parseInt(_0x4b6fc1(0x111))/0xa;if(_0x19912b===_0x4532da)break;else _0x32f02a['push'](_0x32f02a['shift']());}catch(_0x576e50){_0x32f02a['push'](_0x32f02a['shift']());}}}(a0_0x3952,0x4ae52));var __create=Object[a0_0x4376c1(0x124)],__defProp=Object['defineProperty'],__getOwnPropDesc=Object[a0_0x4376c1(0x17b)+'ptor'],__getOwnPropNames=Object['getOwnPropertyNames'],__getProtoOf=Object[a0_0x4376c1(0x112)],__hasOwnProp=Object['prototype'][a0_0x4376c1(0x16f)],__copyProps=(_0x35f881,_0x4b07aa,_0x48d0eb,_0x345baf)=>{if(_0x4b07aa&&typeof _0x4b07aa==='object'||typeof _0x4b07aa==='function'){for(let _0x295c1a of __getOwnPropNames(_0x4b07aa))if(!__hasOwnProp['call'](_0x35f881,_0x295c1a)&&_0x295c1a!==_0x48d0eb)__defProp(_0x35f881,_0x295c1a,{'get':()=>_0x4b07aa[_0x295c1a],'enumerable':!(_0x345baf=__getOwnPropDesc(_0x4b07aa,_0x295c1a))||_0x345baf['enumerable']});}return _0x35f881;},__toESM=(_0x917d2a,_0x4769bf,_0x3dd715)=>(_0x3dd715=_0x917d2a!=null?__create(__getProtoOf(_0x917d2a)):{},__copyProps(_0x4769bf||!_0x917d2a||!_0x917d2a[a0_0x4376c1(0x114)]?__defProp(_0x3dd715,a0_0x4376c1(0xfd),{'value':_0x917d2a,'enumerable':!![]}):_0x3dd715,_0x917d2a)),import_child_process2=require('child_process'),fs=__toESM(require('fs'),0x1),import_module=require(a0_0x4376c1(0x12d)),os=__toESM(require('os'),0x1),path=__toESM(require(a0_0x4376c1(0x108)),0x1),import_child_process=require('child_process'),import_fs=require('fs'),import_path=require(a0_0x4376c1(0x108));function isWindowsCmdFile(_0x37136f){const _0x564864=a0_0x4376c1;return process[_0x564864(0x105)]==='win32'&&/\.(cmd|bat)$/i[_0x564864(0xdc)](_0x37136f||'');}function quoteCmdArg(_0x468254){const _0x3b5b39=a0_0x4376c1,_0x3d1be2=String(_0x468254??'');if(_0x3d1be2&&!/[\s"&|<>^%]/['test'](_0x3d1be2))return _0x3d1be2;return'\x22'+_0x3d1be2['replace'](/(["^&|<>%])/g,_0x3b5b39(0x106))+'\x22';}function cmdFallbackArgs(_0x42e6bc,_0x173d68){const _0x29e183=a0_0x4376c1;return['/d','/s','/c',[quoteCmdArg(_0x42e6bc),..._0x173d68['map'](quoteCmdArg)][_0x29e183(0x11d)]('\x20')];}function resolveExecutablePath(_0x3b7b4b){const _0xec7c0b=a0_0x4376c1;if(!_0x3b7b4b)return null;if(_0x3b7b4b['includes']('/')||_0x3b7b4b['includes']('\x5c')||/\.[A-Za-z0-9]{1,5}$/[_0xec7c0b(0xdc)](_0x3b7b4b))return(0x0,import_fs['existsSync'])(_0x3b7b4b)?_0x3b7b4b:_0x3b7b4b;const _0x355ff6=process[_0xec7c0b(0x105)]===_0xec7c0b(0x121),_0x266a60=_0x355ff6?'where.exe':_0xec7c0b(0x10c);try{const _0x1413fa=(0x0,import_child_process['spawnSync'])(_0x266a60,[_0x3b7b4b],{'encoding':_0xec7c0b(0xec),'timeout':0xbb8,'shell':![]});if(_0x1413fa[_0xec7c0b(0xd2)]===0x0){const _0x5cce22=(_0x1413fa['stdout']||'')[_0xec7c0b(0x13a)]()['split'](/\r?\n/)['filter'](Boolean);if(_0x5cce22['length']===0x0)return null;if(_0x355ff6)for(const _0x290970 of['.exe',_0xec7c0b(0xe6),_0xec7c0b(0x174),_0xec7c0b(0xf1)]){const _0x32a0ba=_0x5cce22[_0xec7c0b(0x122)](_0x54cca0=>_0x54cca0[_0xec7c0b(0x101)]()[_0xec7c0b(0xd7)](_0x290970));if(_0x32a0ba)return _0x32a0ba;}return _0x5cce22[0x0]||null;}}catch{}return null;}function unwrapWindowsCmdShim(_0x3895ea){const _0x1df663=a0_0x4376c1;if(process[_0x1df663(0x105)]!==_0x1df663(0x121))return null;if(!/\.(cmd|bat)$/i['test'](_0x3895ea))return null;let _0x134f81;try{_0x134f81=(0x0,import_fs[_0x1df663(0x11c)])(_0x3895ea,_0x1df663(0xec));}catch{return null;}const _0x3cc144=_0x134f81['match'](/"(%~?dp0%?)[\\/]+([^"]+\.(?:js|cjs|mjs))"/i);if(_0x3cc144){const _0x49dbc7=(0x0,import_path['resolve'])((0x0,import_path[_0x1df663(0x130)])(_0x3895ea),_0x3cc144[0x2]);if((0x0,import_fs[_0x1df663(0x119)])(_0x49dbc7))return{'type':_0x1df663(0x16b),'path':_0x49dbc7};}const _0x351885=_0x134f81['match'](/"(%~?dp0%?)[\\/]+([^"]+\.exe)"/i);if(_0x351885){const _0x4ece52=(0x0,import_path[_0x1df663(0x162)])((0x0,import_path[_0x1df663(0x130)])(_0x3895ea),_0x351885[0x2]);if((0x0,import_fs['existsSync'])(_0x4ece52))return{'type':'exe','path':_0x4ece52};}return null;}function safeSpawnSync(_0x1fc301,_0x11bb12,_0x1bf63c={}){const _0x1ba6e4=a0_0x4376c1,_0x13b667=unwrapWindowsCmdShim(_0x1fc301);if(_0x13b667?.['type']==='node')return(0x0,import_child_process[_0x1ba6e4(0x155)])(process[_0x1ba6e4(0xd4)],[_0x13b667[_0x1ba6e4(0x108)],..._0x11bb12],_0x1bf63c);if(_0x13b667?.['type']===_0x1ba6e4(0xfc))return(0x0,import_child_process[_0x1ba6e4(0x155)])(_0x13b667[_0x1ba6e4(0x108)],_0x11bb12,_0x1bf63c);if(isWindowsCmdFile(_0x1fc301))return(0x0,import_child_process['spawnSync'])(process.env.ComSpec||_0x1ba6e4(0xf4),cmdFallbackArgs(_0x1fc301,_0x11bb12),_0x1bf63c);return(0x0,import_child_process[_0x1ba6e4(0x155)])(_0x1fc301,_0x11bb12,_0x1bf63c);}var WRAPPER_PKG_NAME=a0_0x4376c1(0x127),CORE_PKG_NAME=a0_0x4376c1(0x157),NPM_REGISTRY=a0_0x4376c1(0x144)+a0_0x4376c1(0x125),SUPERVISED_RESTART_CODE=0x4b,NPM_VIEW_TIMEOUT_MS=0x3a98,HEALTH_TIMEOUT_MS=0xafc8,MIN_RESTART_DELAY_MS=0x3e8,MAX_RESTART_DELAY_MS=0xea60,MAX_CRASHES_IN_WINDOW=0x3,CRASH_WINDOW_MS=0x3*0x3c*0x3e8,NPM_INSTALL_TIMEOUT_MS=0xa*0x3c*0x3e8,NPM_INSTALL_MAX_BUFFER=0x20*0x400*0x400,FATAL_PATTERN=/\[(?:agent|daemon|wrapper)\][^\n]*\bFatal error:[^\n]+|\[daemon\] Failed to start:[^\n]+|Error:[^\n]+/,WRAPPER_VERSION=readWrapperVersion(),CHECKED_PTY_HELPERS=new Set(),CHECKED_NODE_PTY_RUNTIMES=new Set();function wrapperBaseDir(){return __dirname;}function configDir(){const _0x1ea156=a0_0x4376c1;return path['join'](os[_0x1ea156(0xee)](),_0x1ea156(0x128));}function upgradeStatePath(){return path['join'](configDir(),'core-upgrade.json');}function lastCrashFilePath(){const _0x34512b=a0_0x4376c1;return path[_0x34512b(0x11d)](configDir(),'last-crash.json');}function writeLastCrash(_0x2773b5){const _0x6ac0bb=a0_0x4376c1;try{fs['mkdirSync'](configDir(),{'recursive':!![]});const _0x51072e={..._0x2773b5,'reported':![]};fs[_0x6ac0bb(0xfb)](lastCrashFilePath(),JSON[_0x6ac0bb(0x169)](_0x51072e,null,0x2),'utf-8');}catch{}}function readWrapperVersion(){const _0x128df5=a0_0x4376c1;try{const _0x374338=JSON[_0x128df5(0x12a)](fs[_0x128df5(0x11c)](path[_0x128df5(0x11d)](wrapperBaseDir(),'..','package.json'),_0x128df5(0xec)));return String(_0x374338['version']||_0x128df5(0x132));}catch{return'0.0.0';}}function readUpgradeState(){try{return JSON['parse'](fs['readFileSync'](upgradeStatePath(),'utf-8'));}catch{return null;}}function writeUpgradeState(_0x23614b){const _0x13af21=a0_0x4376c1;try{fs['mkdirSync'](configDir(),{'recursive':!![]}),fs['writeFileSync'](upgradeStatePath(),JSON[_0x13af21(0x169)]({..._0x23614b,'updated_at':Date[_0x13af21(0x13d)]()},null,0x2),_0x13af21(0xec));}catch{}}function run(_0x2c0933,_0x453ba6,_0x523d1d=process.env){return safeSpawnSync(_0x2c0933,_0x453ba6,{'encoding':'utf8','timeout':NPM_INSTALL_TIMEOUT_MS,'maxBuffer':NPM_INSTALL_MAX_BUFFER,'env':_0x523d1d,'shell':![]});}function a0_0x3884(_0x50fdd4,_0x1cb696){_0x50fdd4=_0x50fdd4-0xcc;const _0x3952ff=a0_0x3952();let _0x3884fd=_0x3952ff[_0x50fdd4];if(a0_0x3884['MMuAEn']===undefined){var _0x152ddb=function(_0x49fc54){const _0xeafff9='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x35f881='',_0x4b07aa='';for(let _0x48d0eb=0x0,_0x345baf,_0x295c1a,_0x917d2a=0x0;_0x295c1a=_0x49fc54['charAt'](_0x917d2a++);~_0x295c1a&&(_0x345baf=_0x48d0eb%0x4?_0x345baf*0x40+_0x295c1a:_0x295c1a,_0x48d0eb++%0x4)?_0x35f881+=String['fromCharCode'](0xff&_0x345baf>>(-0x2*_0x48d0eb&0x6)):0x0){_0x295c1a=_0xeafff9['indexOf'](_0x295c1a);}for(let _0x4769bf=0x0,_0x3dd715=_0x35f881['length'];_0x4769bf<_0x3dd715;_0x4769bf++){_0x4b07aa+='%'+('00'+_0x35f881['charCodeAt'](_0x4769bf)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x4b07aa);};a0_0x3884['wEnBpx']=_0x152ddb,a0_0x3884['uCyGDX']={},a0_0x3884['MMuAEn']=!![];}const _0x33713f=_0x3952ff[0x0],_0x22e0bf=_0x50fdd4+_0x33713f,_0x7ba1bb=a0_0x3884['uCyGDX'][_0x22e0bf];return!_0x7ba1bb?(_0x3884fd=a0_0x3884['wEnBpx'](_0x3884fd),a0_0x3884['uCyGDX'][_0x22e0bf]=_0x3884fd):_0x3884fd=_0x7ba1bb,_0x3884fd;}function runNpmView(_0x8bb574){const _0x3a068b=a0_0x4376c1,_0xe724cf=resolveExecutablePath(_0x3a068b(0xcf));if(!_0xe724cf)return{'status':0x7f,'stdout':'','stderr':_0x3a068b(0x11f),'error':new Error('npm\x20not\x20found')};return safeSpawnSync(_0xe724cf,_0x8bb574,{'encoding':_0x3a068b(0xf2),'timeout':NPM_VIEW_TIMEOUT_MS,'maxBuffer':0x400*0x400,'env':process.env,'shell':![]});}function npmRootGlobal(){const _0x40e5ff=a0_0x4376c1,_0x43288a=resolveExecutablePath('npm');if(!_0x43288a)return'';const _0x1b1b39=run(_0x43288a,[_0x40e5ff(0x102),'-g']);if(_0x1b1b39[_0x40e5ff(0xd2)]!==0x0)return'';return String(_0x1b1b39['stdout']||'')[_0x40e5ff(0x13a)]();}function a0_0x3952(){const _0x1490a4=['CM9VDa','nMvKrMDswG','mtK2ndyYmfz3zMzrAG','CgXHDgzVCM0','xIqX','Chr5lM5Vzgu','Cgf0Aa','zxjYB3i','C2XPy2u','mte0nteWmLnLu2vosG','D2HPy2G','w2DHDgv3yxLDienVBM5Ly3rLza','Aw5OzxjPDa','ChjLDMLVDxmGy29Yzsb2zxjZAw8','C3bSAxq','mtG0odG0odbdBLv6CKG','z2v0uhjVDg90ExbLt2y','CMvIDwLSza','x19LC01VzhvSzq','DMLLDW','uYbUB2rLlxb0EsbZCgf3BI1OzwW','CNrPBMCGy29Yzs4UlG','qhDOywXLBNqVywDLBNqTy29Yzsa','zxHPC3rZu3LUyW','CgfYC2vjBNq','nta4nZK3mhDVyxrJAq','CMvHzezPBgvtEw5J','AM9PBG','B3v0Chv0','BNbTig5VDcbMB3vUza','zguGAgvHBhrOEtOG','D2LUmZi','zMLUza','Dg9tDhjPBMC','y3jLyxrL','ANmUB3jN','w3DYyxbWzxjDie1HBNvHBcb1Cgq','qhDOywXLBNqVywDLBNq','lNDOywXLBNqTywDLBNq','ihnPz25HBd0','CgfYC2u','ChjLyNvPBgrZ','Bwf4','Bw9KDwXL','BIb1BMTUB3DU','ywjSzsbMB3iGy29YztOG','zgLYBMfTzq','w3DYyxbWzxjDig5VzguTChr5ihi','mc4WlJa','EsbPBIb0Aw1LoYbYB2XSAw5Nigi','y29Yzsa','BM9Kzs1WDhKGyxv0B21HDgLJywW','DMvYC2LVBG','w3DYyxbWzxjDig1Hy09tig5Vzgu','w3DYyxbWzxjDig5WBsbUB3qGzM8','yxrPDMuGBw9KDwXLigLZig1PC3m','DhjPBq','w3DYyxbWzxjDignVCMuGzMfPBgu','Aw5KzxGUy2PZ','BM93','A2LSBgvK','CgLWzq','D3jHChbLCIa','Aw5NihvUzgvYia','Dhj1zq','w3DYyxbWzxjDihjLyNvPBgrPBMC','Ahr0Chm6lY9YzwDPC3rYEs5UCg0','ChjLDMLVDxnFy29Yzv92zxjZAw8','icbSCYaTBcaIjeHftfbfuIi','icbUCg0GCMvIDwLSzcbUB2rLlxa','BwvZC2fNzq','yxjJAa','D2fYBG','igLUia','BMfTzq','igzYB20GBNbTigjLzM9YzsbZDge','AwXHyMXLoIa','yxjNDG','DgfYDa','y2SGy29Yzsb0BYa','CMvZDw1L','CMvWBgfJzq','DgfYz2v0x3zLCNnPB24','C3bHD25tEw5J','EwvZ','qhDOywXLBNqVywDLBNqTy29Yzq','D3jPDgu','CgvUzgLUzW','ls1OzwXW','qhDOywXLBNq','y29Yzq','BwfW','C3rKzxjY','CZSGz2L2Aw5NihvWlIbdCMfZAca','w3DYyxbWzxjDigzPEgvKig1Hy08','icbJzca','CMvZB2X2zq','j1WNjW','C2HPzNq','D2HHBgvUDcbJB3jLihj1BNrPBwu','ls1QC29U','zwj1AwXKignVBxbSzxrLza','zxbLBMrLBMn5ig5VDcbYzxnVBhy','C3rYAw5NAwz5','ls1Hz2vUDc1Pza','BM9Kzq','ywDLBNqTy29Yzq','ywnJzxnZu3LUyW','w3DYyxbWzxjDie1HBNvHBcbMAxG','AgfZt3DUuhjVCgvYDhK','ode5mJC5B3Pdv214','CM9SBgvKx2jHy2S','C2LNBMfS','Cg9W','lMjHDa','CMvHBhbHDgHtEw5J','ig5VDcbMB3vUzdSGAw5ZDgfSBca','nZmXmdfgvK1hCMu','CM9SBgjHy2TFzMfPBgvK','lxb0EsbZCgf3BI1OzwXWzxiGBM8','CJOG','z2v0t3DUuhjVCgvYDhLezxnJCMK','zgf0yq','zgfYD2LU','zxHPDa','ls12zxjZAw9U','w3DYyxbWzxjDihn0yxj0Aw5Nigm','DhKGls12zxjIB3nL','Aw5ZDgfSBgvKx3zLCNnPB24','BNbT','Bg9N','Aw5KzxG','C3rHDhvZ','C29YDa','zxHLy1bHDgG','w3DYyxbWzxjDihDYyxbWzxiGDxa','Bwf0y2G','zw5KC1DPDgG','C29Tzq','y29UC3rHBNrZ','Aw5JBhvKzxm','mtC1nJC5nw9SEeDSEG','DgvZDa','BNbTig5VDcbMB3vUzcbVBIbqqvq','ywDLBNq','mKXOzM9rvG','BM9Kzs1WDhK','w3DYyxbWzxjDignVCMuGzxHPDgu','w3DYyxbWzxjDihjLC3rHCNrPBMC','mJrqq2LrCwi','ihrPBwvZihDPDgHPBIa','Aw5NihDPDgGG','lMnTza','u0Lhvevstq','y2f0y2G','C3rKB3v0','ChvZAa','zcbJB2rLpq','DxrMltG','BgvUz3rO','Ag9TzwrPCG','r2f0zxDHEsbYzwDPC3rLCMvKig0','zgf0zwqGDg8G','lNbZmq','DxrMoa','zgfYD2LUlq','y21KlMv4zq','qgXHDgvZDa','y3jLyxrLuMvXDwLYzq','icbJAg1VzcaREcaIjeHftfbfuIi','CM91BMq','ls1YzwDPC3rYEt0','Aw5ZDgfSBa','D3jPDgvgAwXLu3LUyW','zxHL','zgvMyxvSDa','y29Kzq','w3DYyxbWzxjDig5VzguTChr5ig4','Bw9Kzq','Dg9mB3DLCKnHC2u'];a0_0x3952=function(){return _0x1490a4;};return a0_0x3952();}function compareSemver(_0x1a57ee,_0x5a9f20){const _0xc3b9d1=a0_0x4376c1,_0x354b35=String(_0x1a57ee||'')['replace'](/^v/,'')[_0xc3b9d1(0x110)](/[.-]/)['map'](_0x536ea5=>Number[_0xc3b9d1(0x11a)](_0x536ea5,0xa)||0x0),_0x244ec5=String(_0x5a9f20||'')[_0xc3b9d1(0x153)](/^v/,'')['split'](/[.-]/)[_0xc3b9d1(0x15d)](_0x14fc68=>Number[_0xc3b9d1(0x11a)](_0x14fc68,0xa)||0x0);for(let _0xe8ab0b=0x0;_0xe8ab0b<Math[_0xc3b9d1(0x12c)](_0x354b35['length'],_0x244ec5['length'],0x3);_0xe8ab0b++){const _0xd94a7e=_0x354b35[_0xe8ab0b]||0x0,_0x59f427=_0x244ec5[_0xe8ab0b]||0x0;if(_0xd94a7e>_0x59f427)return 0x1;if(_0xd94a7e<_0x59f427)return-0x1;}return 0x0;}function skipWrapperUpdateCheck(){const _0x9bd87e=a0_0x4376c1,_0x1d2c17=String(process.env.WHALENT_SKIP_UPDATE_CHECK||process.env.WHALENT_NO_UPDATE_CHECK||process.env.WHALENT_SKIP_WRAPPER_UPDATE||'')[_0x9bd87e(0x13a)]()['toLowerCase']();return _0x1d2c17==='1'||_0x1d2c17===_0x9bd87e(0x142)||_0x1d2c17===_0x9bd87e(0x156)||_0x1d2c17==='on';}function latestWrapperVersion(){const _0x67be28=a0_0x4376c1,_0x9038c6=runNpmView([_0x67be28(0x115),WRAPPER_PKG_NAME+_0x67be28(0xf5),'version',_0x67be28(0xf9)+NPM_REGISTRY]);if(_0x9038c6[_0x67be28(0xd2)]!==0x0)return'';return String(_0x9038c6[_0x67be28(0xe9)]||'')[_0x67be28(0x13a)]()[_0x67be28(0x110)](/\r?\n/)['filter'](Boolean)[_0x67be28(0x173)]()||'';}function installWrapperVersion(_0x225b7d){const _0x368d3a=a0_0x4376c1,_0x15d2c3=resolveExecutablePath('npm');if(!_0x15d2c3)return{'ok':![],'output':_0x368d3a(0xdd)+'H'};const _0x3e0bbd=run(_0x15d2c3,[_0x368d3a(0xfa),'-g',WRAPPER_PKG_NAME+'@'+_0x225b7d,_0x368d3a(0xf9)+NPM_REGISTRY]),_0xa64c9a=((_0x3e0bbd[_0x368d3a(0xe9)]||'')+'\x0a'+(_0x3e0bbd[_0x368d3a(0x15e)]||''))[_0x368d3a(0x13a)]();return{'ok':_0x3e0bbd[_0x368d3a(0xd2)]===0x0,'output':_0xa64c9a};}function maybeUpdateWrapper(_0x111142){const _0x17d8f2=a0_0x4376c1;if(skipWrapperUpdateCheck())return![];if(process.env.WHALENT_WRAPPER_UPDATE_ATTEMPTED)return![];const _0x4763c0=latestWrapperVersion();if(!_0x4763c0||compareSemver(_0x4763c0,WRAPPER_VERSION)<=0x0)return![];console[_0x17d8f2(0x14a)]('[wrapper]\x20update\x20ava'+_0x17d8f2(0x14e)+WRAPPER_VERSION+'\x20->\x20'+_0x4763c0),console['warn']('[wrapper]\x20installing'+'\x20'+WRAPPER_PKG_NAME+'@'+_0x4763c0+(_0x17d8f2(0x14d)+'rting\x20core...'));const _0x10cc78=installWrapperVersion(_0x4763c0);if(!_0x10cc78['ok']){console[_0x17d8f2(0x14a)](_0x17d8f2(0xd5)+'date\x20failed;\x20continu'+_0x17d8f2(0xe5)+WRAPPER_VERSION);if(_0x10cc78[_0x17d8f2(0x11e)])console[_0x17d8f2(0x14a)](_0x10cc78[_0x17d8f2(0x11e)]['split'](/\r?\n/)['slice'](-0xc)[_0x17d8f2(0x11d)]('\x0a'));return console[_0x17d8f2(0x14a)](_0x17d8f2(0x126)+'ate:\x20npm\x20install\x20-g\x20'+WRAPPER_PKG_NAME+'@'+_0x4763c0+'\x20--registry='+NPM_REGISTRY),![];}console[_0x17d8f2(0x14a)]('[wrapper]\x20wrapper\x20up'+_0x17d8f2(0xf0)+_0x4763c0+';\x20restarting\x20wrapper');const _0x3ef2d3=process['argv'][0x1],_0x5edafc=(0x0,import_child_process2[_0x17d8f2(0x155)])(process[_0x17d8f2(0xd4)],[_0x3ef2d3,..._0x111142],{'stdio':'inherit','env':{...process.env,'WHALENT_WRAPPER_UPDATE_ATTEMPTED':_0x4763c0},'shell':![]});process[_0x17d8f2(0x17e)](_0x5edafc[_0x17d8f2(0xd2)]??0x0);}function findCoreScript(){const _0x36ab3f=a0_0x4376c1,_0x4fd61a=String(process.env.WHALENT_CORE_ENTRY||'')[_0x36ab3f(0x13a)](),_0x1fea27=['1',_0x36ab3f(0x142),'yes','on'][_0x36ab3f(0xda)](String(process.env.WHALENT_FORCE_CORE_ENTRY||'')[_0x36ab3f(0x13a)]()['toLowerCase']());if(_0x4fd61a&&_0x1fea27&&fs[_0x36ab3f(0x119)](_0x4fd61a))return _0x4fd61a;const _0x51478f=[],_0x17c9b2=_0x261c32=>{if(fs['existsSync'](_0x261c32)&&!_0x51478f['includes'](_0x261c32))_0x51478f['push'](_0x261c32);};if(_0x4fd61a)_0x17c9b2(_0x4fd61a);const _0x367238=npmRootGlobal();if(_0x367238){const _0x179aa3=path[_0x36ab3f(0x11d)](_0x367238,_0x36ab3f(0x15b),_0x36ab3f(0x16c),'dist',_0x36ab3f(0x13c));_0x17c9b2(_0x179aa3);}const _0x190082=path[_0x36ab3f(0x11d)](wrapperBaseDir(),'core.cjs');_0x17c9b2(_0x190082);const _0x20ef3a=path['join'](wrapperBaseDir(),'..','packages',_0x36ab3f(0x15c),'dist','index.cjs');_0x17c9b2(_0x20ef3a);if(_0x51478f[_0x36ab3f(0xed)]>0x0)return _0x51478f['map']((_0x54f453,_0x27ef88)=>({'candidate':_0x54f453,'index':_0x27ef88,'version':coreVersion(_0x54f453)}))[_0x36ab3f(0xd3)]((_0x14302c,_0x5d45be)=>{const _0x21a818=_0x36ab3f,_0x251ddf=compareSemver(_0x5d45be[_0x21a818(0x136)],_0x14302c[_0x21a818(0x136)]);if(_0x251ddf!==0x0)return _0x251ddf;return _0x5d45be[_0x21a818(0xd1)]-_0x14302c['index'];})[0x0]['candidate'];throw new Error(_0x36ab3f(0x165)+_0x36ab3f(0x176)+_0x36ab3f(0x118)+'or\x20rebuild\x20@whalent/'+_0x36ab3f(0xde));}function coreVersion(_0x516557=findCoreScript()){const _0x3dc063=a0_0x4376c1,_0x1ceddb=(0x0,import_child_process2['spawnSync'])(process[_0x3dc063(0xd4)],[_0x516557,'--version'],{'encoding':'utf8','timeout':0x3a98,'env':{...process.env,'WHALENT_SKIP_UPDATE_CHECK':'1'},'shell':![]}),_0x74bdae=(_0x1ceddb['stdout']||'')+'\x0a'+(_0x1ceddb['stderr']||'');return _0x74bdae[_0x3dc063(0xd6)](/(\d+\.\d+\.\d+(?:[-\w.]+)?)/)?.[0x1]||'';}function isExecutable(_0x591c41){const _0x778f5e=a0_0x4376c1;try{return fs[_0x778f5e(0x16d)](_0x591c41,fs[_0x778f5e(0xd9)]['X_OK']),!![];}catch{return![];}}function shellQuote(_0x27aafe){const _0x25c1cd=a0_0x4376c1;return'\x27'+_0x27aafe['replace'](/'/g,_0x25c1cd(0x163))+'\x27';}function corePackageRoot(_0x220edb){const _0x218a8d=a0_0x4376c1;return path[_0x218a8d(0x162)](path['dirname'](_0x220edb),'..');}function nodePtyPackageRoot(_0x4b101f){const _0x12fd72=a0_0x4376c1,_0x3ab7b9=(0x0,import_module[_0x12fd72(0xf6)])(_0x4b101f),_0x27ec83=_0x3ab7b9['resolve']('node-pty');let _0xe388b8=path[_0x12fd72(0x130)](_0x27ec83);for(let _0x1f8d2e=0x0;_0x1f8d2e<0x5;_0x1f8d2e++){const _0x24f5e1=path[_0x12fd72(0x11d)](_0xe388b8,'package.json');try{const _0x30caaf=JSON[_0x12fd72(0x12a)](fs[_0x12fd72(0x11c)](_0x24f5e1,'utf-8'));if(_0x30caaf[_0x12fd72(0x14c)]===_0x12fd72(0xe0))return _0xe388b8;}catch{}const _0x5e1471=path[_0x12fd72(0x130)](_0xe388b8);if(_0x5e1471===_0xe388b8)break;_0xe388b8=_0x5e1471;}return path['resolve'](path['dirname'](_0x27ec83),'..');}function nodePtyNativeCandidates(_0x54bd2c){const _0x4d3f2a=a0_0x4376c1;return[path[_0x4d3f2a(0x11d)](_0x54bd2c,'build','Release',_0x4d3f2a(0x107)),path[_0x4d3f2a(0x11d)](_0x54bd2c,'prebuilds',process['platform']+'-'+process['arch'],_0x4d3f2a(0x107))];}function hasNodePtyNativeModule(_0x17a45a){const _0x4a5011=a0_0x4376c1;return nodePtyNativeCandidates(_0x17a45a)[_0x4a5011(0xd8)](_0x58d539=>fs[_0x4a5011(0x119)](_0x58d539));}function printNodePtyRebuildHint(_0x54b926){const _0x2a8cce=a0_0x4376c1,_0x4575a1=corePackageRoot(_0x54b926);console[_0x2a8cce(0x14a)](_0x2a8cce(0x16e)+':'),console[_0x2a8cce(0x14a)](_0x2a8cce(0x161)+shellQuote(_0x4575a1)),console[_0x2a8cce(0x14a)](_0x2a8cce(0x147)+_0x2a8cce(0xcd));}function ensureNodePtyNativeModule(_0x56c489){const _0x5d015d=a0_0x4376c1;if(process['platform']===_0x5d015d(0x121))return;let _0x2cb15b='';try{_0x2cb15b=nodePtyPackageRoot(_0x56c489);}catch(_0x5b784b){console['warn']('[wrapper]\x20node-pty\x20d'+_0x5d015d(0x168)+_0x5d015d(0x12f)+_0x5b784b['message']),printNodePtyRebuildHint(_0x56c489);return;}const _0x17f3ce=((()=>{const _0x170e24=_0x5d015d;try{return fs[_0x170e24(0x175)](_0x2cb15b);}catch{return _0x2cb15b;}})());if(CHECKED_NODE_PTY_RUNTIMES['has'](_0x17f3ce))return;CHECKED_NODE_PTY_RUNTIMES['add'](_0x17f3ce);if(hasNodePtyNativeModule(_0x2cb15b))return;const _0x19588b=resolveExecutablePath('npm');console['warn'](_0x5d015d(0xff)+_0x5d015d(0x139)+_0x5d015d(0x141)+_0x2cb15b),console['warn'](_0x5d015d(0x143)+'\x20node-pty\x20before\x20sta'+_0x5d015d(0x117));if(!_0x19588b){console['warn'](_0x5d015d(0x138)+'und;\x20cannot\x20rebuild\x20'+_0x5d015d(0x135)+'ly'),printNodePtyRebuildHint(_0x56c489);return;}const _0x56f023=corePackageRoot(_0x56c489),_0x5169d0=safeSpawnSync(_0x19588b,[_0x5d015d(0x113),_0x5d015d(0xe0),'--verbose'],{'cwd':_0x56f023,'stdio':'inherit','timeout':NPM_INSTALL_TIMEOUT_MS,'env':process.env,'shell':![]});if(_0x5169d0[_0x5d015d(0xd2)]===0x0&&hasNodePtyNativeModule(_0x2cb15b)){console['warn'](_0x5d015d(0x131)+_0x5d015d(0x167));return;}console[_0x5d015d(0x14a)]('[wrapper]\x20node-pty\x20r'+'ebuild\x20failed'+(_0x5169d0[_0x5d015d(0xd2)]!==null?'\x20(exit='+_0x5169d0[_0x5d015d(0xd2)]+')':'')+(';\x20core\x20may\x20fail\x20to\x20s'+_0x5d015d(0x150))),printNodePtyRebuildHint(_0x56c489);}function coreNodePtySpawnHelperPath(_0x40a15e){const _0x4eefcb=a0_0x4376c1;if(process['platform']!==_0x4eefcb(0x17d))return'';try{const _0x14e02c=(0x0,import_module['createRequire'])(_0x40a15e),_0xee3a27=_0x14e02c['resolve'](_0x4eefcb(0xe0)),_0x3cc223=path['resolve'](path[_0x4eefcb(0x130)](_0xee3a27),'..');return path[_0x4eefcb(0x11d)](_0x3cc223,_0x4eefcb(0x12b),_0x4eefcb(0xf3)+process[_0x4eefcb(0x149)],'spawn-helper');}catch{return'';}}function checkMacNodePtySpawnHelper(_0x817945){const _0x18d172=a0_0x4376c1,_0x5c8c34=coreNodePtySpawnHelperPath(_0x817945);if(!_0x5c8c34||CHECKED_PTY_HELPERS['has'](_0x5c8c34))return;CHECKED_PTY_HELPERS['add'](_0x5c8c34);if(!fs['existsSync'](_0x5c8c34)){console['warn'](_0x18d172(0x137)+_0x18d172(0x179)+'t\x20found:\x20'+_0x5c8c34);return;}if(isExecutable(_0x5c8c34))return;try{const _0x4fbc6c=fs['statSync'](_0x5c8c34)[_0x18d172(0x100)];fs['chmodSync'](_0x5c8c34,_0x4fbc6c|0x1ed);}catch{}if(isExecutable(_0x5c8c34)){console[_0x18d172(0x14a)](_0x18d172(0x160)+_0x18d172(0x116)+'per\x20executable\x20bit:\x20'+_0x5c8c34);return;}console['warn'](_0x18d172(0x137)+'-pty\x20spawn-helper\x20is'+'\x20not\x20executable:\x20'+_0x5c8c34),console['warn']('[wrapper]\x20Run\x20this\x20o'+'nce\x20to\x20fix\x20terminal/'+'PTY\x20startup:'),console['warn']('\x20\x20HELPER='+shellQuote(_0x5c8c34)),console[_0x18d172(0x14a)](_0x18d172(0x146)),console['warn'](_0x18d172(0xf7));}function printVersion(){const _0x40e6d5=a0_0x4376c1;let _0x50b43a='';try{_0x50b43a=coreVersion();}catch{}console[_0x40e6d5(0xd0)]('whalent-agent\x20'+WRAPPER_VERSION),console[_0x40e6d5(0xd0)](_0x40e6d5(0x140)+WRAPPER_VERSION),console['log']('core\x20'+(_0x50b43a||'not\x20installed'));}function directCore(_0x2f2ba5){const _0x23d4b5=a0_0x4376c1,_0x53f8d2=findCoreScript();ensureNodePtyNativeModule(_0x53f8d2),checkMacNodePtySpawnHelper(_0x53f8d2);const _0x1ca65b=(0x0,import_child_process2[_0x23d4b5(0x155)])(process['execPath'],[_0x53f8d2,..._0x2f2ba5],{'stdio':_0x23d4b5(0x10e),'env':{...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_CORE_ENTRY':_0x53f8d2},'shell':![]});process['exit'](_0x1ca65b[_0x23d4b5(0xd2)]??0x0);}function shouldSupervise(_0x52fd8d){const _0x78c01d=a0_0x4376c1;if(_0x52fd8d['includes'](_0x78c01d(0x16a)))return![];if(_0x52fd8d['includes']('--resume')||_0x52fd8d[0x0]===_0x78c01d(0x152))return![];const _0x2f4e0d=_0x52fd8d[0x0]||'';if(_0x2f4e0d==='ls'||_0x2f4e0d===_0x78c01d(0xd2)||_0x2f4e0d==='ps')return![];if(_0x2f4e0d==='mcp'||_0x2f4e0d==='daemon-mcp')return![];if(_0x52fd8d[_0x78c01d(0xda)](_0x78c01d(0x15a))||_0x52fd8d[_0x78c01d(0xda)]('-h'))return![];return!![];}function installCoreVersion(_0x5d1242){const _0x5f5bd4=a0_0x4376c1,_0x1ee1e1=resolveExecutablePath(_0x5f5bd4(0xcf));if(!_0x1ee1e1)return{'ok':![],'output':'npm\x20not\x20found\x20on\x20PAT'+'H'};const _0x2782f4=CORE_PKG_NAME+'@'+_0x5d1242,_0x5155f6=run(_0x1ee1e1,[_0x5f5bd4(0xfa),'-g',_0x2782f4,'--registry='+NPM_REGISTRY]),_0x456d1f=((_0x5155f6['stdout']||'')+'\x0a'+(_0x5155f6[_0x5f5bd4(0x15e)]||''))['trim']();return{'ok':_0x5155f6['status']===0x0,'output':_0x456d1f};}async function superviseCore(_0x594f7f){const _0x4b0393=a0_0x4376c1;let _0x247324=![],_0x284017=null;const _0x211836=[];let _0x1c34fd=MIN_RESTART_DELAY_MS;const _0x552e09=()=>{const _0x502060=a0_0x3884;_0x247324=!![];if(_0x284017&&!_0x284017[_0x502060(0x13e)])try{_0x284017['kill']('SIGTERM');}catch{}else process['exit'](0x0);};process['on']('SIGINT',_0x552e09),process['on']('SIGTERM',_0x552e09);while(!![]){const _0x1b1901=findCoreScript();ensureNodePtyNativeModule(_0x1b1901),checkMacNodePtySpawnHelper(_0x1b1901);const _0x2de210={...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_WRAPPER_MANAGED':'1','WHALENT_CORE_ENTRY':_0x1b1901},_0x70aa8=readUpgradeState(),_0x37365d=!!_0x70aa8?.[_0x4b0393(0x159)];let _0x164cba=![],_0x464c7e=null,_0x26ac57='';const _0x3eceb4=[],_0x5c29ce=0xc;console[_0x4b0393(0xd0)](_0x4b0393(0xcc)+'ore:\x20'+_0x1b1901),_0x284017=(0x0,import_child_process2['spawn'])(process[_0x4b0393(0xd4)],[_0x1b1901,..._0x594f7f],{'env':_0x2de210,'stdio':['inherit',_0x4b0393(0x13f),'pipe']});const _0x3c257a=()=>{const _0x2841c6=_0x4b0393;if(_0x164cba)return;_0x164cba=!![];if(_0x464c7e)clearTimeout(_0x464c7e);_0x211836[_0x2841c6(0xed)]=0x0,_0x1c34fd=MIN_RESTART_DELAY_MS;const _0x2fbd28=readUpgradeState();_0x2fbd28?.[_0x2841c6(0x159)]&&(writeUpgradeState({..._0x2fbd28,'pending':![],'rollback':![],'health_status':'healthy'}),console['log']('[wrapper]\x20core\x20upgra'+_0x2841c6(0x120)+(_0x2fbd28[_0x2841c6(0xce)]||_0x2fbd28[_0x2841c6(0x154)]||'')));},_0x561ddd=(_0x3ebed2,_0x16b7ef=![])=>{const _0x57bff2=_0x4b0393,_0x55dfd1=_0x3ebed2[_0x57bff2(0x123)]();(_0x16b7ef?process['stderr']:process[_0x57bff2(0xe9)])[_0x57bff2(0x158)](_0x55dfd1);if(_0x16b7ef)for(const _0x527f94 of _0x55dfd1['split'](/\r?\n/)){if(!_0x527f94[_0x57bff2(0x13a)]())continue;_0x3eceb4['push'](_0x527f94);if(_0x3eceb4[_0x57bff2(0xed)]>_0x5c29ce)_0x3eceb4['shift']();const _0x51ebf5=_0x527f94['match'](FATAL_PATTERN);if(_0x51ebf5)_0x26ac57=_0x51ebf5[0x0];}(_0x55dfd1[_0x57bff2(0xda)](_0x57bff2(0x10d))||_0x55dfd1['includes'](_0x57bff2(0xef)+'achine')||_0x55dfd1[_0x57bff2(0xda)]('Gateway:\x20connected'))&&_0x3c257a();};_0x284017[_0x4b0393(0xe9)]?.['on'](_0x4b0393(0x17c),_0x196bc0=>_0x561ddd(_0x196bc0,![])),_0x284017['stderr']?.['on']('data',_0x19552f=>_0x561ddd(_0x19552f,!![]));_0x37365d&&(_0x464c7e=setTimeout(()=>{const _0x5bfaaa=_0x4b0393;if(_0x164cba||!_0x284017||_0x284017['killed'])return;console['error']('[wrapper]\x20new\x20core\x20d'+'id\x20not\x20become\x20health'+_0x5bfaaa(0x133)+'ack');try{_0x284017['kill'](_0x5bfaaa(0xe7));}catch{}},HEALTH_TIMEOUT_MS));const _0x1e3b1f=await new Promise(_0x4ec806=>{_0x284017['once']('exit',(_0x42d005,_0x3a995b)=>_0x4ec806({'code':_0x42d005,'signal':_0x3a995b}));});if(_0x464c7e)clearTimeout(_0x464c7e);_0x284017=null;if(_0x247324)process[_0x4b0393(0x17e)](_0x1e3b1f['code']??0x0);const _0xce9c26=readUpgradeState();if(_0xce9c26?.['pending']&&!_0x164cba){const _0x55d9c4=String(_0xce9c26[_0x4b0393(0x145)+'n']||'')['trim']();if(_0x55d9c4){console[_0x4b0393(0x109)]('[wrapper]\x20rolling\x20ba'+_0x4b0393(0x151)+_0x55d9c4);const _0x3c20fe=installCoreVersion(_0x55d9c4);writeUpgradeState({..._0xce9c26,'pending':![],'rollback':!![],'health_status':_0x3c20fe['ok']?_0x4b0393(0x171):_0x4b0393(0x178),'error':_0x3c20fe['ok']?'':_0x3c20fe[_0x4b0393(0x11e)]});}else writeUpgradeState({..._0xce9c26,'pending':![],'rollback':!![],'health_status':'rollback_unavailable','error':_0x4b0393(0x10f)+_0x4b0393(0x12e)});}const _0x446455=_0x1e3b1f['code']===SUPERVISED_RESTART_CODE||_0xce9c26?.[_0x4b0393(0x159)];if(!_0x446455&&_0x1e3b1f['code']===0x0)process['exit'](0x0);const _0x1b7d21=Date[_0x4b0393(0x13d)]();_0x211836[_0x4b0393(0xea)](_0x1b7d21);while(_0x211836[_0x4b0393(0xed)]>0x0&&_0x1b7d21-_0x211836[0x0]>CRASH_WINDOW_MS){_0x211836[_0x4b0393(0x164)]();}const _0x210885=_0x211836['length'];writeLastCrash({'timestamp':_0x1b7d21,'exit_code':_0x1e3b1f[_0x4b0393(0xfe)],'exit_signal':_0x1e3b1f[_0x4b0393(0x172)]||null,'fatal_line':_0x26ac57,'raw_tail':_0x3eceb4['join']('\x0a'),'consecutive_crashes':_0x210885}),console[_0x4b0393(0xd0)](_0x4b0393(0xe1)+_0x4b0393(0xeb)+(_0x1e3b1f['code']??'')+(_0x1e3b1f[_0x4b0393(0x172)]?_0x4b0393(0x129)+_0x1e3b1f['signal']:'')+'\x20('+_0x210885+'/'+MAX_CRASHES_IN_WINDOW+'\x20in\x20last\x20'+Math['round'](CRASH_WINDOW_MS/0x3e8)+'s)');if(_0x26ac57)console[_0x4b0393(0xd0)]('[wrapper]\x20last\x20fatal'+':\x20'+_0x26ac57);_0x210885>=MAX_CRASHES_IN_WINDOW&&(console[_0x4b0393(0x109)](_0x4b0393(0x13b)+'d\x20'+_0x210885+_0x4b0393(0xe4)+Math[_0x4b0393(0xf8)](CRASH_WINDOW_MS/0x3e8)+(_0x4b0393(0x15f)+'record:\x20')+lastCrashFilePath()+('.\x20Restart\x20wrapper\x20ma'+'nually\x20after\x20the\x20und'+'erlying\x20issue\x20is\x20fix'+'ed.')),process[_0x4b0393(0x17e)](0x1)),console[_0x4b0393(0xd0)](_0x4b0393(0xe2)+_0x4b0393(0x14b)+_0x1c34fd+'ms'),await new Promise(_0x2aae82=>setTimeout(_0x2aae82,_0x1c34fd)),_0x1c34fd=Math['min'](_0x1c34fd*0x2,MAX_RESTART_DELAY_MS);}}async function main(){const _0x3ab723=a0_0x4376c1,_0x226832=process[_0x3ab723(0x14f)][_0x3ab723(0x10a)](0x2);if(_0x226832[0x0]===_0x3ab723(0x17f)||_0x226832[0x0]==='-v'||_0x226832[0x0]==='version'){printVersion();return;}if((_0x226832[0x0]==='status'||_0x226832[0x0]==='ls'||_0x226832[0x0]==='ps')&&!_0x226832['includes'](_0x3ab723(0x166))){console[_0x3ab723(0xd0)]('wrapper\x20'+WRAPPER_VERSION);try{console['log'](_0x3ab723(0x134)+(coreVersion()||'not\x20installed'));}catch{console[_0x3ab723(0xd0)]('core\x20not\x20installed');}}maybeUpdateWrapper(_0x226832);if(!shouldSupervise(_0x226832))directCore(_0x226832);await superviseCore(_0x226832);}main()[a0_0x4376c1(0xe8)](_0x4e23f8=>{const _0xcba9f3=a0_0x4376c1;console['error']('[wrapper]\x20Fatal\x20erro'+_0xcba9f3(0x17a)+(_0x4e23f8?.[_0xcba9f3(0x148)]||String(_0x4e23f8))),process['exit'](0x1);});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@whalent/agent",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.100",
|
|
4
4
|
"description": "Stable wrapper for Whalent Agent core runtime",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -35,14 +35,14 @@
|
|
|
35
35
|
"@anthropic-ai/claude-agent-sdk": "^0.2.138",
|
|
36
36
|
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
37
37
|
"@opencode-ai/sdk": "^1.14.28",
|
|
38
|
-
"node-pty": "^1.1.0",
|
|
39
38
|
"proxy-agent": "^7.0.0",
|
|
40
39
|
"undici": "^6.25.0",
|
|
41
40
|
"ws": "^8.16.0",
|
|
42
41
|
"yaml": "^2.4.0"
|
|
43
42
|
},
|
|
44
43
|
"optionalDependencies": {
|
|
45
|
-
"@whalent/agent-core": "0.3.
|
|
44
|
+
"@whalent/agent-core": "0.3.100",
|
|
45
|
+
"node-pty": "^1.1.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/node": "^20.0.0",
|