@whalent/agent 0.3.98 → 0.3.101
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 +5 -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_0x2efdfc=a0_0x4016;(function(_0x4cad6c,_0x4d7d7a){const _0xd5f7ef=a0_0x4016,_0x201e21=_0x4cad6c();while(!![]){try{const _0xf1888d=-parseInt(_0xd5f7ef(0x233))/0x1*(-parseInt(_0xd5f7ef(0x204))/0x2)+parseInt(_0xd5f7ef(0x247))/0x3*(parseInt(_0xd5f7ef(0x1ea))/0x4)+parseInt(_0xd5f7ef(0x24d))/0x5*(parseInt(_0xd5f7ef(0x223))/0x6)+parseInt(_0xd5f7ef(0x237))/0x7*(parseInt(_0xd5f7ef(0x26a))/0x8)+parseInt(_0xd5f7ef(0x249))/0x9*(-parseInt(_0xd5f7ef(0x23b))/0xa)+parseInt(_0xd5f7ef(0x25f))/0xb*(parseInt(_0xd5f7ef(0x241))/0xc)+-parseInt(_0xd5f7ef(0x269))/0xd*(parseInt(_0xd5f7ef(0x278))/0xe);if(_0xf1888d===_0x4d7d7a)break;else _0x201e21['push'](_0x201e21['shift']());}catch(_0x2262cf){_0x201e21['push'](_0x201e21['shift']());}}}(a0_0x5c58,0xe2445));var __create=Object['create'],__defProp=Object[a0_0x2efdfc(0x1f6)],__getOwnPropDesc=Object[a0_0x2efdfc(0x252)+a0_0x2efdfc(0x21b)],__getOwnPropNames=Object['getOwnPropertyNames'],__getProtoOf=Object['getPrototypeOf'],__hasOwnProp=Object['prototype']['hasOwnProperty'],__copyProps=(_0x358db2,_0x20161a,_0x1876d9,_0xb4a12f)=>{const _0x3080af=a0_0x2efdfc;if(_0x20161a&&typeof _0x20161a===_0x3080af(0x275)||typeof _0x20161a===_0x3080af(0x251)){for(let _0x5b9b3c of __getOwnPropNames(_0x20161a))if(!__hasOwnProp['call'](_0x358db2,_0x5b9b3c)&&_0x5b9b3c!==_0x1876d9)__defProp(_0x358db2,_0x5b9b3c,{'get':()=>_0x20161a[_0x5b9b3c],'enumerable':!(_0xb4a12f=__getOwnPropDesc(_0x20161a,_0x5b9b3c))||_0xb4a12f['enumerable']});}return _0x358db2;},__toESM=(_0x163b17,_0x2f7f19,_0x5598fa)=>(_0x5598fa=_0x163b17!=null?__create(__getProtoOf(_0x163b17)):{},__copyProps(_0x2f7f19||!_0x163b17||!_0x163b17[a0_0x2efdfc(0x282)]?__defProp(_0x5598fa,a0_0x2efdfc(0x22d),{'value':_0x163b17,'enumerable':!![]}):_0x5598fa,_0x163b17)),import_child_process2=require(a0_0x2efdfc(0x1eb)),fs=__toESM(require('fs'),0x1),import_module=require('module'),os=__toESM(require('os'),0x1),path=__toESM(require('path'),0x1),import_child_process=require('child_process'),import_fs=require('fs'),import_path=require('path');function a0_0x5c58(){const _0x3d5089=['zxHLy1bHDgG','w3DYyxbWzxjDihvWzgf0zsbHDMe','C3bHD24TAgvSCgvY','DhjPBq','ywnR','ChjLyNvPBgrZ','BwLU','CMvWBgfJzq','zw5KC1DPDgG','Aw5ZDgfSBa','mNr0z3DeEa','y29Kzq','B3iGCMvIDwLSzcbaD2HHBgvUDc8','igzYB20GBNbTigjLzM9YzsbZDge','DcbMB3vUzdOG','wf9psW','CgfYC2vjBNq','zxHPDa','AgvHBhrOEq','yxrLoIbUCg0GAw5ZDgfSBcaTzYa','C3rHDhvZ','CM9SBgjHy2TFDw5HDMfPBgfIBgu','qhDOywXLBNq','icbSCYaTBcaIjeHftfbfuIi','CgfYC2u','w3DYyxbWzxjDihjVBgXPBMCGyMe','CgvUzgLUzW','ufrzihn0yxj0Dxa6','C3bHD24','zgf0yq','EwvZ','zgfLBw9Ulw1JCa','AwqGBM90igjLy29TzsbOzwfSDgG','ChrVCG','ywDLBNq','y2SGy29Yzsb0BYa','ls1Yzxn1Bwu','w3DYyxbWzxjDignVCMuGzxHPDgu','BNbTig5VDcbMB3vUzcbVBIbqqvq','Dg9mB3DLCKnHC2u','qhDOywXLBNqVywDLBNqTy29Yzq','nKvUA25AvG','Aw5KzxG','u0Lhvevstq','D2LUmZi','y29Yzs5JANm','ls1QC29U','w3DYyxbWzxjDifj1BIb0AgLZig8','igLUia','zxjSEwLUzYbPC3n1zsbPCYbMAxG','CM9VDa','zgvMyxvSDa','A2LSBgvK','w3DYyxbWzxjDignVCMuGDxbNCMe','DxrMoa','lNDOywXLBNqTywDLBNq','lNbZmq','mta0mZyWmuDbD1Leva','ls1YzwDPC3rYEt0','icbiruXqrvi9','zgf0zsbMywLSzwq7ignVBNrPBNu','nJa3odu5C3n6Eefn','w3DYyxbWzxjDihjLC3rHCNrPBMC','zxjYB3i','EsbPBIb0Aw1LoYbYB2XSAw5Nigi','nZqZmhbiAwH6qW','y21KlMv4zq','lMnTza','y2fUzgLKyxrL','B3v0Chv0','ls1Hz2vUDc1Pza','mta4mJK2nerwtLLmBq','CgXHDgzVCM0','CgfJA2fNzs5QC29U','CMvZB2X2zq','icbJAg1VzcaREcaIjeHftfbfuIi','BwfW','m2XyveHxuq','C2LNBMfS','odKXovHRB3LMsa','BwTKAxjtEw5J','j1WNjW','DhLWzq','ndKYntmZnxf2svn3uW','BgvUz3rO','C3rKB3v0','C3bHD25tEw5J','zNvUy3rPB24','z2v0t3DUuhjVCgvYDhLezxnJCMK','BNbTig5VDcbMB3vUza','ic0+ia','zgfYD2LU','DxrMltG','DMvYC2LVBG','zwqU','C2XPy2u','BIb1BMTUB3DU','w3DYyxbWzxjDigzPEgvKig1Hy08','Aw5JBhvKzxm','ywnOAw5L','B25Jzq','mZnuC3zMqLO','C3rKzxjY','w3DYyxbWzxjDigXHC3qGzMf0ywW','DMLLDW','DgvZDa','D2HLCMuUzxHL','Dg9tDhjPBMC','Aw5OzxjPDa','CZSGz2L2Aw5NihvWlIbdCMfZAca','ig5VDcbMB3vUzdSGAw5ZDgfSBca','mtGYBfLRu0Lj','mtuYrvjAwK14','CM9SBgvKx2jHy2S','C3rYAw5NAwz5','Bwf0y2G','y29UC3rHBNrZ','Ahr0Chm6lY9YzwDPC3rYEs5UCg0','AM9PBG','yxjJAa','CMvHzezPBgvtEw5J','Aw5KzxGUy2PZ','BM9Kzq','B2jQzwn0','oYbYzxn0yxj0Aw5NihDYyxbWzxi','Bg9N','mJm4ody5neTIwgTkDG','ywnJzxnZu3LUyW','lMv4zq','ic0TCMvNAxn0CNK9','Cg9W','BM90igLUC3rHBgXLza','BwnW','ig5VDcbLEgvJDxrHyMXLoIa','zgLYBMfTzq','CM91BMq','x19LC01VzhvSzq','ChvZAa','w3DYyxbWzxjDig1Hy09tig5Vzgu','Bwf4','nda5otm2z3D1rhbm','y2HPBgrFChjVy2vZCW','zgfYD2LUlq','BM93','lMjHDa','AgfZ','D2HPy2G','zxHL','zxHPC3rZu3LUyW','D2fYBG','C2HPzNq','CMvJB3jKoIa','zgvMAw5LuhjVCgvYDhK','y3jLyxrLuMvXDwLYzq','CM9SBgjHy2TFzMfPBgvK','yxjNDG'];a0_0x5c58=function(){return _0x3d5089;};return a0_0x5c58();}function isWindowsCmdFile(_0x2da029){const _0xc980f2=a0_0x2efdfc;return process[_0xc980f2(0x242)]===_0xc980f2(0x226)&&/\.(cmd|bat)$/i[_0xc980f2(0x263)](_0x2da029||'');}function quoteCmdArg(_0x4d06b6){const _0x14af0a=a0_0x2efdfc,_0x1b722d=String(_0x4d06b6??'');if(_0x1b722d&&!/[\s"&|<>^%]/[_0x14af0a(0x263)](_0x1b722d))return _0x1b722d;return'\x22'+_0x1b722d[_0x14af0a(0x201)](/(["^&|<>%])/g,'^$1')+'\x22';}function cmdFallbackArgs(_0x12a2e0,_0x3903cb){return['/d','/s','/c',[quoteCmdArg(_0x12a2e0),..._0x3903cb['map'](quoteCmdArg)]['join']('\x20')];}function resolveExecutablePath(_0x260729){const _0x1ecf7f=a0_0x2efdfc;if(!_0x260729)return null;if(_0x260729['includes']('/')||_0x260729['includes']('\x5c')||/\.[A-Za-z0-9]{1,5}$/[_0x1ecf7f(0x263)](_0x260729))return(0x0,import_fs['existsSync'])(_0x260729)?_0x260729:_0x260729;const _0x5105ee=process['platform']==='win32',_0x4279d4=_0x5105ee?_0x1ecf7f(0x264):_0x1ecf7f(0x1f0);try{const _0x57ce71=(0x0,import_child_process['spawnSync'])(_0x4279d4,[_0x260729],{'encoding':'utf-8','timeout':0xbb8,'shell':![]});if(_0x57ce71[_0x1ecf7f(0x20e)]===0x0){const _0x347bbd=(_0x57ce71['stdout']||'')[_0x1ecf7f(0x1fd)]()['split'](/\r?\n/)['filter'](Boolean);if(_0x347bbd['length']===0x0)return null;if(_0x5105ee)for(const _0x1fd5fd of[_0x1ecf7f(0x27a),_0x1ecf7f(0x23d),_0x1ecf7f(0x1ee),_0x1ecf7f(0x232)]){const _0x3e9235=_0x347bbd['find'](_0x13639f=>_0x13639f['toLowerCase']()[_0x1ecf7f(0x202)](_0x1fd5fd));if(_0x3e9235)return _0x3e9235;}return _0x347bbd[0x0]||null;}}catch{}return null;}function unwrapWindowsCmdShim(_0xe76c85){const _0x53f3db=a0_0x2efdfc;if(process['platform']!==_0x53f3db(0x226))return null;if(!/\.(cmd|bat)$/i['test'](_0xe76c85))return null;let _0x4fdd07;try{_0x4fdd07=(0x0,import_fs['readFileSync'])(_0xe76c85,_0x53f3db(0x256));}catch{return null;}const _0x1ddf66=_0x4fdd07['match'](/"(%~?dp0%?)[\\/]+([^"]+\.(?:js|cjs|mjs))"/i);if(_0x1ddf66){const _0x635060=(0x0,import_path[_0x53f3db(0x244)])((0x0,import_path['dirname'])(_0xe76c85),_0x1ddf66[0x2]);if((0x0,import_fs['existsSync'])(_0x635060))return{'type':_0x53f3db(0x274),'path':_0x635060};}const _0x53319b=_0x4fdd07['match'](/"(%~?dp0%?)[\\/]+([^"]+\.exe)"/i);if(_0x53319b){const _0x4ca99c=(0x0,import_path['resolve'])((0x0,import_path[_0x53f3db(0x280)])(_0xe76c85),_0x53319b[0x2]);if((0x0,import_fs[_0x53f3db(0x1f2)])(_0x4ca99c))return{'type':_0x53f3db(0x1f1),'path':_0x4ca99c};}return null;}function safeSpawnSync(_0x43c516,_0x470307,_0x33947f={}){const _0x132a66=a0_0x2efdfc,_0x252528=unwrapWindowsCmdShim(_0x43c516);if(_0x252528?.[_0x132a66(0x24c)]==='node')return(0x0,import_child_process[_0x132a66(0x250)])(process[_0x132a66(0x1fa)],[_0x252528['path'],..._0x470307],_0x33947f);if(_0x252528?.['type']==='exe')return(0x0,import_child_process['spawnSync'])(_0x252528['path'],_0x470307,_0x33947f);if(isWindowsCmdFile(_0x43c516))return(0x0,import_child_process[_0x132a66(0x250)])(process.env.ComSpec||_0x132a66(0x23c),cmdFallbackArgs(_0x43c516,_0x470307),_0x33947f);return(0x0,import_child_process['spawnSync'])(_0x43c516,_0x470307,_0x33947f);}var WRAPPER_PKG_NAME='@whalent/agent',CORE_PKG_NAME=a0_0x2efdfc(0x222),NPM_REGISTRY=a0_0x2efdfc(0x26f)+'js.org',SUPERVISED_RESTART_CODE=0x4b,NPM_VIEW_TIMEOUT_MS=0x3a98,HEALTH_TIMEOUT_MS=0xafc8,MIN_RESTART_DELAY_MS=0x3e8,MAX_RESTART_DELAY_MS=0xea60,MAX_CRASHES_IN_WINDOW=0x3,CRASH_WINDOW_MS=0x3*0x3c*0x3e8,NPM_INSTALL_TIMEOUT_MS=0xa*0x3c*0x3e8,NPM_INSTALL_MAX_BUFFER=0x20*0x400*0x400,FATAL_PATTERN=/\[(?:agent|daemon|wrapper)\][^\n]*\bFatal error:[^\n]+|\[daemon\] Failed to start:[^\n]+|Error:[^\n]+/,WRAPPER_VERSION=readWrapperVersion(),CHECKED_PTY_HELPERS=new Set();function wrapperBaseDir(){return __dirname;}function configDir(){const _0x9c04d1=a0_0x2efdfc;return path[_0x9c04d1(0x270)](os['homedir'](),_0x9c04d1(0x231));}function upgradeStatePath(){return path['join'](configDir(),'core-upgrade.json');}function lastCrashFilePath(){return path['join'](configDir(),'last-crash.json');}function writeLastCrash(_0x2d3d02){const _0x53ff7b=a0_0x2efdfc;try{fs[_0x53ff7b(0x24a)](configDir(),{'recursive':!![]});const _0x31013c={..._0x2d3d02,'reported':![]};fs['writeFileSync'](lastCrashFilePath(),JSON[_0x53ff7b(0x26c)](_0x31013c,null,0x2),_0x53ff7b(0x256));}catch{}}function readWrapperVersion(){const _0x5d094e=a0_0x2efdfc;try{const _0xb7ed3e=JSON[_0x5d094e(0x212)](fs[_0x5d094e(0x272)](path[_0x5d094e(0x270)](wrapperBaseDir(),'..',_0x5d094e(0x243)),_0x5d094e(0x256)));return String(_0xb7ed3e['version']||'0.0.0');}catch{return'0.0.0';}}function readUpgradeState(){const _0x5dd3d2=a0_0x2efdfc;try{return JSON[_0x5dd3d2(0x212)](fs['readFileSync'](upgradeStatePath(),_0x5dd3d2(0x256)));}catch{return null;}}function writeUpgradeState(_0x5c8910){const _0x3cc647=a0_0x2efdfc;try{fs[_0x3cc647(0x24a)](configDir(),{'recursive':!![]}),fs['writeFileSync'](upgradeStatePath(),JSON['stringify']({..._0x5c8910,'updated_at':Date['now']()},null,0x2),_0x3cc647(0x256));}catch{}}function run(_0x380609,_0x59ea3c,_0x43ecfa=process.env){return safeSpawnSync(_0x380609,_0x59ea3c,{'encoding':'utf8','timeout':NPM_INSTALL_TIMEOUT_MS,'maxBuffer':NPM_INSTALL_MAX_BUFFER,'env':_0x43ecfa,'shell':![]});}function runNpmView(_0x1fde92){const _0xab63e3=a0_0x2efdfc,_0x2aa6a2=resolveExecutablePath('npm');if(!_0x2aa6a2)return{'status':0x7f,'stdout':'','stderr':_0xab63e3(0x253),'error':new Error(_0xab63e3(0x253))};return safeSpawnSync(_0x2aa6a2,_0x1fde92,{'encoding':_0xab63e3(0x230),'timeout':NPM_VIEW_TIMEOUT_MS,'maxBuffer':0x400*0x400,'env':process.env,'shell':![]});}function npmRootGlobal(){const _0x315aee=a0_0x2efdfc,_0x5ae2f6=resolveExecutablePath('npm');if(!_0x5ae2f6)return'';const _0x1dc8d0=run(_0x5ae2f6,[_0x315aee(0x22c),'-g']);if(_0x1dc8d0[_0x315aee(0x20e)]!==0x0)return'';return String(_0x1dc8d0[_0x315aee(0x24f)]||'')['trim']();}function compareSemver(_0xed17a7,_0x1edfca){const _0x37d075=a0_0x2efdfc,_0x13d05f=String(_0xed17a7||'')[_0x37d075(0x201)](/^v/,'')['split'](/[.-]/)[_0x37d075(0x246)](_0x1cdf53=>Number['parseInt'](_0x1cdf53,0xa)||0x0),_0x5357b5=String(_0x1edfca||'')['replace'](/^v/,'')['split'](/[.-]/)[_0x37d075(0x246)](_0x45c84d=>Number[_0x37d075(0x20a)](_0x45c84d,0xa)||0x0);for(let _0x4a9dda=0x0;_0x4a9dda<Math[_0x37d075(0x1e9)](_0x13d05f[_0x37d075(0x24e)],_0x5357b5['length'],0x3);_0x4a9dda++){const _0x5ad096=_0x13d05f[_0x4a9dda]||0x0,_0x39c31d=_0x5357b5[_0x4a9dda]||0x0;if(_0x5ad096>_0x39c31d)return 0x1;if(_0x5ad096<_0x39c31d)return-0x1;}return 0x0;}function skipWrapperUpdateCheck(){const _0x2a78a3=String(process.env.WHALENT_SKIP_UPDATE_CHECK||process.env.WHALENT_NO_UPDATE_CHECK||process.env.WHALENT_SKIP_WRAPPER_UPDATE||'')['trim']()['toLowerCase']();return _0x2a78a3==='1'||_0x2a78a3==='true'||_0x2a78a3==='yes'||_0x2a78a3==='on';}function latestWrapperVersion(){const _0x349afa=a0_0x2efdfc,_0x12fe2b=runNpmView([_0x349afa(0x262),WRAPPER_PKG_NAME+'@latest','version','--registry='+NPM_REGISTRY]);if(_0x12fe2b[_0x349afa(0x20e)]!==0x0)return'';return String(_0x12fe2b['stdout']||'')['trim']()['split'](/\r?\n/)['filter'](Boolean)[_0x349afa(0x27c)]()||'';}function installWrapperVersion(_0x29bc63){const _0x4616d9=a0_0x2efdfc,_0x4be0a5=resolveExecutablePath('npm');if(!_0x4be0a5)return{'ok':![],'output':_0x4616d9(0x220)+'H'};const _0x156e93=run(_0x4be0a5,[_0x4616d9(0x203),'-g',WRAPPER_PKG_NAME+'@'+_0x29bc63,'--registry='+NPM_REGISTRY]),_0x146374=((_0x156e93['stdout']||'')+'\x0a'+(_0x156e93['stderr']||''))['trim']();return{'ok':_0x156e93[_0x4616d9(0x20e)]===0x0,'output':_0x146374};}function maybeUpdateWrapper(_0x4e5c8e){const _0x4f7e6c=a0_0x2efdfc;if(skipWrapperUpdateCheck())return![];if(process.env.WHALENT_WRAPPER_UPDATE_ATTEMPTED)return![];const _0x1eeca4=latestWrapperVersion();if(!_0x1eeca4||compareSemver(_0x1eeca4,WRAPPER_VERSION)<=0x0)return![];console['warn'](_0x4f7e6c(0x1fb)+'ilable:\x20'+WRAPPER_VERSION+_0x4f7e6c(0x254)+_0x1eeca4),console['warn']('[wrapper]\x20installing'+'\x20'+WRAPPER_PKG_NAME+'@'+_0x1eeca4+(_0x4f7e6c(0x207)+'rting\x20core...'));const _0x1e0478=installWrapperVersion(_0x1eeca4);if(!_0x1e0478['ok']){console[_0x4f7e6c(0x1f3)]('[wrapper]\x20wrapper\x20up'+_0x4f7e6c(0x236)+'ing\x20with\x20'+WRAPPER_VERSION);if(_0x1e0478[_0x4f7e6c(0x23f)])console['warn'](_0x1e0478['output']['split'](/\r?\n/)[_0x4f7e6c(0x259)](-0xc)[_0x4f7e6c(0x270)]('\x0a'));return console[_0x4f7e6c(0x1f3)]('[wrapper]\x20Manual\x20upd'+_0x4f7e6c(0x20d)+WRAPPER_PKG_NAME+'@'+_0x1eeca4+_0x4f7e6c(0x27b)+NPM_REGISTRY),![];}console[_0x4f7e6c(0x1f3)]('[wrapper]\x20wrapper\x20up'+'dated\x20to\x20'+_0x1eeca4+_0x4f7e6c(0x276));const _0x6d7898=process['argv'][0x1],_0x49a80d=(0x0,import_child_process2[_0x4f7e6c(0x250)])(process['execPath'],[_0x6d7898,..._0x4e5c8e],{'stdio':'inherit','env':{...process.env,'WHALENT_WRAPPER_UPDATE_ATTEMPTED':_0x1eeca4},'shell':![]});process[_0x4f7e6c(0x20b)](_0x49a80d[_0x4f7e6c(0x20e)]??0x0);}function findCoreScript(){const _0x546b75=a0_0x2efdfc,_0xe114a1=String(process.env.WHALENT_CORE_ENTRY||'')['trim'](),_0x4e3d40=['1','true',_0x546b75(0x218),'on']['includes'](String(process.env.WHALENT_FORCE_CORE_ENTRY||'')[_0x546b75(0x1fd)]()[_0x546b75(0x221)]());if(_0xe114a1&&_0x4e3d40&&fs[_0x546b75(0x1f2)](_0xe114a1))return _0xe114a1;const _0x380c29=[],_0x348c65=_0x3ca7a0=>{const _0x3a04c7=_0x546b75;if(fs[_0x3a04c7(0x1f2)](_0x3ca7a0)&&!_0x380c29[_0x3a04c7(0x25c)](_0x3ca7a0))_0x380c29[_0x3a04c7(0x283)](_0x3ca7a0);};if(_0xe114a1)_0x348c65(_0xe114a1);const _0x275bc9=npmRootGlobal();if(_0x275bc9){const _0x56a8d4=path['join'](_0x275bc9,_0x546b75(0x210),'agent-core','dist',_0x546b75(0x273));_0x348c65(_0x56a8d4);}const _0x2b4193=path[_0x546b75(0x270)](wrapperBaseDir(),_0x546b75(0x227));_0x348c65(_0x2b4193);const _0x32bba5=path[_0x546b75(0x270)](wrapperBaseDir(),'..','packages','core','dist',_0x546b75(0x273));_0x348c65(_0x32bba5);if(_0x380c29[_0x546b75(0x24e)]>0x0)return _0x380c29[_0x546b75(0x246)]((_0x112748,_0x5ae453)=>({'candidate':_0x112748,'index':_0x5ae453,'version':coreVersion(_0x112748)}))['sort']((_0x536b50,_0x52ad43)=>{const _0x1070ff=_0x546b75,_0x3e5775=compareSemver(_0x52ad43[_0x1070ff(0x257)],_0x536b50['version']);if(_0x3e5775!==0x0)return _0x3e5775;return _0x52ad43[_0x1070ff(0x224)]-_0x536b50[_0x1070ff(0x224)];})[0x0][_0x546b75(0x23e)];throw new Error('whalent\x20core\x20runtime'+_0x546b75(0x268)+'@whalent/agent-core\x20'+_0x546b75(0x206)+_0x546b75(0x21c));}function coreVersion(_0x107d62=findCoreScript()){const _0x533449=a0_0x2efdfc,_0x2dff57=(0x0,import_child_process2[_0x533449(0x250)])(process[_0x533449(0x1fa)],[_0x107d62,'--version'],{'encoding':_0x533449(0x230),'timeout':0x3a98,'env':{...process.env,'WHALENT_SKIP_UPDATE_CHECK':'1'},'shell':![]}),_0x50fe4f=(_0x2dff57[_0x533449(0x24f)]||'')+'\x0a'+(_0x2dff57['stderr']||'');return _0x50fe4f[_0x533449(0x26d)](/(\d+\.\d+\.\d+(?:[-\w.]+)?)/)?.[0x1]||'';}function isExecutable(_0x3dced4){const _0x566ecf=a0_0x2efdfc;try{return fs[_0x566ecf(0x279)](_0x3dced4,fs[_0x566ecf(0x26e)][_0x566ecf(0x209)]),!![];}catch{return![];}}function a0_0x4016(_0x2b3c4a,_0x4fb76f){_0x2b3c4a=_0x2b3c4a-0x1e8;const _0x5c58a7=a0_0x5c58();let _0x401639=_0x5c58a7[_0x2b3c4a];if(a0_0x4016['JcCtXX']===undefined){var _0xd37ac5=function(_0x3ec10f){const _0x3397e6='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x358db2='',_0x20161a='';for(let _0x1876d9=0x0,_0xb4a12f,_0x5b9b3c,_0x163b17=0x0;_0x5b9b3c=_0x3ec10f['charAt'](_0x163b17++);~_0x5b9b3c&&(_0xb4a12f=_0x1876d9%0x4?_0xb4a12f*0x40+_0x5b9b3c:_0x5b9b3c,_0x1876d9++%0x4)?_0x358db2+=String['fromCharCode'](0xff&_0xb4a12f>>(-0x2*_0x1876d9&0x6)):0x0){_0x5b9b3c=_0x3397e6['indexOf'](_0x5b9b3c);}for(let _0x2f7f19=0x0,_0x5598fa=_0x358db2['length'];_0x2f7f19<_0x5598fa;_0x2f7f19++){_0x20161a+='%'+('00'+_0x358db2['charCodeAt'](_0x2f7f19)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x20161a);};a0_0x4016['vpLIXv']=_0xd37ac5,a0_0x4016['CvYUkI']={},a0_0x4016['JcCtXX']=!![];}const _0x3d1a99=_0x5c58a7[0x0],_0x3ec519=_0x2b3c4a+_0x3d1a99,_0x304307=a0_0x4016['CvYUkI'][_0x3ec519];return!_0x304307?(_0x401639=a0_0x4016['vpLIXv'](_0x401639),a0_0x4016['CvYUkI'][_0x3ec519]=_0x401639):_0x401639=_0x304307,_0x401639;}function shellQuote(_0x2009bc){const _0x293548=a0_0x2efdfc;return'\x27'+_0x2009bc['replace'](/'/g,_0x293548(0x24b))+'\x27';}function coreNodePtySpawnHelperPath(_0x40ef43){const _0xce99b2=a0_0x2efdfc;if(process['platform']!==_0xce99b2(0x255))return'';try{const _0x18f8fa=(0x0,import_module[_0xce99b2(0x1f7)])(_0x40ef43),_0x559cf8=_0x18f8fa['resolve']('node-pty'),_0x10d2d6=path['resolve'](path['dirname'](_0x559cf8),'..');return path['join'](_0x10d2d6,_0xce99b2(0x1ff),_0xce99b2(0x1ec)+process[_0xce99b2(0x271)],_0xce99b2(0x1fc));}catch{return'';}}function checkMacNodePtySpawnHelper(_0x314aca){const _0x15f01c=a0_0x2efdfc,_0x258a26=coreNodePtySpawnHelperPath(_0x314aca);if(!_0x258a26||CHECKED_PTY_HELPERS[_0x15f01c(0x1ef)](_0x258a26))return;CHECKED_PTY_HELPERS['add'](_0x258a26);if(!fs['existsSync'](_0x258a26)){console[_0x15f01c(0x1f3)]('[wrapper]\x20macOS\x20node'+'-pty\x20spawn-helper\x20no'+_0x15f01c(0x208)+_0x258a26);return;}if(isExecutable(_0x258a26))return;try{const _0x57b285=fs['statSync'](_0x258a26)['mode'];fs['chmodSync'](_0x258a26,_0x57b285|0x1ed);}catch{}if(isExecutable(_0x258a26)){console[_0x15f01c(0x1f3)](_0x15f01c(0x25b)+'S\x20node-pty\x20spawn-hel'+'per\x20executable\x20bit:\x20'+_0x258a26);return;}console['warn'](_0x15f01c(0x1e8)+'-pty\x20spawn-helper\x20is'+_0x15f01c(0x27f)+_0x258a26),console[_0x15f01c(0x1f3)](_0x15f01c(0x229)+'nce\x20to\x20fix\x20terminal/'+_0x15f01c(0x215)),console[_0x15f01c(0x1f3)](_0x15f01c(0x235)+shellQuote(_0x258a26)),console['warn'](_0x15f01c(0x211)),console['warn'](_0x15f01c(0x245));}function printVersion(){const _0x16bc47=a0_0x2efdfc;let _0x31f0e2='';try{_0x31f0e2=coreVersion();}catch{}console['log']('whalent-agent\x20'+WRAPPER_VERSION),console[_0x16bc47(0x277)]('wrapper\x20'+WRAPPER_VERSION),console['log']('core\x20'+(_0x31f0e2||_0x16bc47(0x27d)));}function directCore(_0xf7e643){const _0x26a3fd=a0_0x2efdfc,_0x2ef357=findCoreScript();checkMacNodePtySpawnHelper(_0x2ef357);const _0x115f56=(0x0,import_child_process2['spawnSync'])(process[_0x26a3fd(0x1fa)],[_0x2ef357,..._0xf7e643],{'stdio':'inherit','env':{...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_CORE_ENTRY':_0x2ef357},'shell':![]});process[_0x26a3fd(0x20b)](_0x115f56['status']??0x0);}function shouldSupervise(_0x1a92fb){const _0x1648e2=a0_0x2efdfc;if(_0x1a92fb[_0x1648e2(0x25c)](_0x1648e2(0x240)))return![];if(_0x1a92fb['includes'](_0x1648e2(0x21e))||_0x1a92fb[0x0]==='resume')return![];const _0x203af3=_0x1a92fb[0x0]||'';if(_0x203af3==='ls'||_0x203af3===_0x1648e2(0x20e)||_0x203af3==='ps')return![];if(_0x203af3===_0x1648e2(0x27e)||_0x203af3===_0x1648e2(0x219))return![];if(_0x1a92fb['includes']('--help')||_0x1a92fb['includes']('-h'))return![];return!![];}function installCoreVersion(_0x29de40){const _0x45223a=a0_0x2efdfc,_0x26e01c=resolveExecutablePath('npm');if(!_0x26e01c)return{'ok':![],'output':_0x45223a(0x220)+'H'};const _0x3b3954=CORE_PKG_NAME+'@'+_0x29de40,_0xf91576=run(_0x26e01c,['install','-g',_0x3b3954,_0x45223a(0x234)+NPM_REGISTRY]),_0x3e4362=((_0xf91576['stdout']||'')+'\x0a'+(_0xf91576[_0x45223a(0x260)]||''))['trim']();return{'ok':_0xf91576[_0x45223a(0x20e)]===0x0,'output':_0x3e4362};}async function superviseCore(_0x5be5d7){const _0x2b3071=a0_0x2efdfc;let _0x24b554=![],_0x55319b=null;const _0x39ac69=[];let _0x25588c=MIN_RESTART_DELAY_MS;const _0x32b531=()=>{const _0x597b0b=a0_0x4016;_0x24b554=!![];if(_0x55319b&&!_0x55319b[_0x597b0b(0x22e)])try{_0x55319b['kill'](_0x597b0b(0x225));}catch{}else process[_0x597b0b(0x20b)](0x0);};process['on']('SIGINT',_0x32b531),process['on']('SIGTERM',_0x32b531);while(!![]){const _0x2b3e99=findCoreScript();checkMacNodePtySpawnHelper(_0x2b3e99);const _0x272335={...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_WRAPPER_MANAGED':'1','WHALENT_CORE_ENTRY':_0x2b3e99},_0x5e291d=readUpgradeState(),_0x97775e=!!_0x5e291d?.['pending'];let _0x41f013=![],_0x34bd93=null,_0x3b91b4='';const _0x26f6ce=[],_0x1dcf0e=0xc;console['log']('[wrapper]\x20starting\x20c'+'ore:\x20'+_0x2b3e99),_0x55319b=(0x0,import_child_process2[_0x2b3071(0x216)])(process['execPath'],[_0x2b3e99,..._0x5be5d7],{'env':_0x272335,'stdio':[_0x2b3071(0x266),'pipe','pipe']});const _0x10f55f=()=>{const _0x59247c=_0x2b3071;if(_0x41f013)return;_0x41f013=!![];if(_0x34bd93)clearTimeout(_0x34bd93);_0x39ac69[_0x59247c(0x24e)]=0x0,_0x25588c=MIN_RESTART_DELAY_MS;const _0x278e53=readUpgradeState();_0x278e53?.['pending']&&(writeUpgradeState({..._0x278e53,'pending':![],'rollback':![],'health_status':_0x59247c(0x20c)}),console[_0x59247c(0x277)](_0x59247c(0x22f)+'de\x20healthy:\x20'+(_0x278e53['installed_version']||_0x278e53['target_version']||'')));},_0x31d184=(_0xba673,_0x203b92=![])=>{const _0x119c73=_0x2b3071,_0x212c6d=_0xba673[_0x119c73(0x265)]();(_0x203b92?process['stderr']:process[_0x119c73(0x24f)])['write'](_0x212c6d);if(_0x203b92)for(const _0x4fc79d of _0x212c6d['split'](/\r?\n/)){if(!_0x4fc79d['trim']())continue;_0x26f6ce[_0x119c73(0x283)](_0x4fc79d);if(_0x26f6ce[_0x119c73(0x24e)]>_0x1dcf0e)_0x26f6ce['shift']();const _0x23fc08=_0x4fc79d[_0x119c73(0x26d)](FATAL_PATTERN);if(_0x23fc08)_0x3b91b4=_0x23fc08[0x0];}(_0x212c6d[_0x119c73(0x25c)]('[gateway]\x20Connected')||_0x212c6d['includes']('Gateway\x20registered\x20m'+_0x119c73(0x25d))||_0x212c6d[_0x119c73(0x25c)]('Gateway:\x20connected'))&&_0x10f55f();};_0x55319b[_0x2b3071(0x24f)]?.['on'](_0x2b3071(0x217),_0x262fc7=>_0x31d184(_0x262fc7,![])),_0x55319b['stderr']?.['on'](_0x2b3071(0x217),_0x409361=>_0x31d184(_0x409361,!![]));_0x97775e&&(_0x34bd93=setTimeout(()=>{const _0x2e0eb2=_0x2b3071;if(_0x41f013||!_0x55319b||_0x55319b['killed'])return;console['error']('[wrapper]\x20new\x20core\x20d'+_0x2e0eb2(0x21a)+_0x2e0eb2(0x23a)+_0x2e0eb2(0x1fe));try{_0x55319b['kill']('SIGTERM');}catch{}},HEALTH_TIMEOUT_MS));const _0x27d150=await new Promise(_0x7fd770=>{const _0x42fff9=_0x2b3071;_0x55319b[_0x42fff9(0x25e)]('exit',(_0x586407,_0x1d98ce)=>_0x7fd770({'code':_0x586407,'signal':_0x1d98ce}));});if(_0x34bd93)clearTimeout(_0x34bd93);_0x55319b=null;if(_0x24b554)process[_0x2b3071(0x20b)](_0x27d150['code']??0x0);const _0x3726d9=readUpgradeState();if(_0x3726d9?.[_0x2b3071(0x214)]&&!_0x41f013){const _0x222547=String(_0x3726d9['previous_core_versio'+'n']||'')['trim']();if(_0x222547){console['error'](_0x2b3071(0x213)+_0x2b3071(0x21d)+_0x222547);const _0x2d0327=installCoreVersion(_0x222547);writeUpgradeState({..._0x3726d9,'pending':![],'rollback':!![],'health_status':_0x2d0327['ok']?_0x2b3071(0x26b):_0x2b3071(0x1f8),'error':_0x2d0327['ok']?'':_0x2d0327['output']});}else writeUpgradeState({..._0x3726d9,'pending':![],'rollback':!![],'health_status':_0x2b3071(0x20f),'error':'previous\x20core\x20versio'+_0x2b3071(0x25a)});}const _0x169218=_0x27d150['code']===SUPERVISED_RESTART_CODE||_0x3726d9?.['pending'];if(!_0x169218&&_0x27d150[_0x2b3071(0x205)]===0x0)process[_0x2b3071(0x20b)](0x0);const _0x58aa57=Date[_0x2b3071(0x1ed)]();_0x39ac69['push'](_0x58aa57);while(_0x39ac69[_0x2b3071(0x24e)]>0x0&&_0x58aa57-_0x39ac69[0x0]>CRASH_WINDOW_MS){_0x39ac69[_0x2b3071(0x1f4)]();}const _0x5dab17=_0x39ac69['length'];writeLastCrash({'timestamp':_0x58aa57,'exit_code':_0x27d150[_0x2b3071(0x205)],'exit_signal':_0x27d150[_0x2b3071(0x248)]||null,'fatal_line':_0x3b91b4,'raw_tail':_0x26f6ce[_0x2b3071(0x270)]('\x0a'),'consecutive_crashes':_0x5dab17}),console[_0x2b3071(0x277)](_0x2b3071(0x21f)+'d\x20code='+(_0x27d150[_0x2b3071(0x205)]??'')+(_0x27d150['signal']?'\x20signal='+_0x27d150[_0x2b3071(0x248)]:'')+'\x20('+_0x5dab17+'/'+MAX_CRASHES_IN_WINDOW+'\x20in\x20last\x20'+Math[_0x2b3071(0x281)](CRASH_WINDOW_MS/0x3e8)+'s)');if(_0x3b91b4)console['log'](_0x2b3071(0x261)+':\x20'+_0x3b91b4);_0x5dab17>=MAX_CRASHES_IN_WINDOW&&(console[_0x2b3071(0x239)]('[wrapper]\x20core\x20faile'+'d\x20'+_0x5dab17+'\x20times\x20within\x20'+Math[_0x2b3071(0x281)](CRASH_WINDOW_MS/0x3e8)+(_0x2b3071(0x267)+_0x2b3071(0x1f5))+lastCrashFilePath()+('.\x20Restart\x20wrapper\x20ma'+'nually\x20after\x20the\x20und'+_0x2b3071(0x22b)+_0x2b3071(0x258))),process[_0x2b3071(0x20b)](0x1)),console[_0x2b3071(0x277)](_0x2b3071(0x238)+_0x2b3071(0x22a)+_0x25588c+'ms'),await new Promise(_0x22a50b=>setTimeout(_0x22a50b,_0x25588c)),_0x25588c=Math[_0x2b3071(0x200)](_0x25588c*0x2,MAX_RESTART_DELAY_MS);}}async function main(){const _0x23ebcc=a0_0x2efdfc,_0x51dedd=process[_0x23ebcc(0x1f9)][_0x23ebcc(0x259)](0x2);if(_0x51dedd[0x0]==='--version'||_0x51dedd[0x0]==='-v'||_0x51dedd[0x0]===_0x23ebcc(0x257)){printVersion();return;}if((_0x51dedd[0x0]==='status'||_0x51dedd[0x0]==='ls'||_0x51dedd[0x0]==='ps')&&!_0x51dedd[_0x23ebcc(0x25c)](_0x23ebcc(0x228))){console[_0x23ebcc(0x277)]('wrapper\x20'+WRAPPER_VERSION);try{console['log']('core\x20'+(coreVersion()||'not\x20installed'));}catch{console[_0x23ebcc(0x277)]('core\x20not\x20installed');}}maybeUpdateWrapper(_0x51dedd);if(!shouldSupervise(_0x51dedd))directCore(_0x51dedd);await superviseCore(_0x51dedd);}main()['catch'](_0x5b0c0e=>{const _0xb05ec8=a0_0x2efdfc;console['error']('[wrapper]\x20Fatal\x20erro'+'r:\x20'+(_0x5b0c0e?.['message']||String(_0x5b0c0e))),process[_0xb05ec8(0x20b)](0x1);});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@whalent/agent",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.101",
|
|
4
4
|
"description": "Stable wrapper for Whalent Agent core runtime",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -19,6 +19,8 @@
|
|
|
19
19
|
"build:fast": "node build.mjs --no-obfuscate",
|
|
20
20
|
"build:sqlite-helper": "node scripts/build-sqlite-helper.mjs",
|
|
21
21
|
"build:sqlite-helper:all": "node scripts/build-sqlite-helper.mjs --all",
|
|
22
|
+
"build:terminal-helper": "node scripts/build-terminal-helper.mjs",
|
|
23
|
+
"build:terminal-helper:all": "node scripts/build-terminal-helper.mjs --all",
|
|
22
24
|
"preinstall": "node scripts/preinstall-check.cjs",
|
|
23
25
|
"prepublishOnly": "node build.mjs",
|
|
24
26
|
"start": "node dist/index.cjs"
|
|
@@ -35,14 +37,14 @@
|
|
|
35
37
|
"@anthropic-ai/claude-agent-sdk": "^0.2.138",
|
|
36
38
|
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
37
39
|
"@opencode-ai/sdk": "^1.14.28",
|
|
38
|
-
"node-pty": "^1.1.0",
|
|
39
40
|
"proxy-agent": "^7.0.0",
|
|
40
41
|
"undici": "^6.25.0",
|
|
41
42
|
"ws": "^8.16.0",
|
|
42
43
|
"yaml": "^2.4.0"
|
|
43
44
|
},
|
|
44
45
|
"optionalDependencies": {
|
|
45
|
-
"@whalent/agent-core": "0.3.
|
|
46
|
+
"@whalent/agent-core": "0.3.101",
|
|
47
|
+
"node-pty": "^1.1.0"
|
|
46
48
|
},
|
|
47
49
|
"devDependencies": {
|
|
48
50
|
"@types/node": "^20.0.0",
|