@whalent/agent 0.3.46 → 0.3.48
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 +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
'use strict';const a0_0x454959=a0_0x4500;(function(_0x2816f1,_0x23176d){const _0x21d996=a0_0x4500,_0x4b9aef=_0x2816f1();while(!![]){try{const _0x2d6a9e=parseInt(_0x21d996(0x23a))/0x1*(parseInt(_0x21d996(0x22b))/0x2)+-parseInt(_0x21d996(0x217))/0x3+-parseInt(_0x21d996(0x1c1))/0x4*(-parseInt(_0x21d996(0x1f3))/0x5)+-parseInt(_0x21d996(0x1ea))/0x6+parseInt(_0x21d996(0x22d))/0x7+-parseInt(_0x21d996(0x204))/0x8+-parseInt(_0x21d996(0x1dc))/0x9*(-parseInt(_0x21d996(0x1da))/0xa);if(_0x2d6a9e===_0x23176d)break;else _0x4b9aef['push'](_0x4b9aef['shift']());}catch(_0x5c0178){_0x4b9aef['push'](_0x4b9aef['shift']());}}}(a0_0x1950,0x5a426));var __create=Object['create'],__defProp=Object['defineProperty'],__getOwnPropDesc=Object['getOwnPropertyDescri'+a0_0x454959(0x21c)],__getOwnPropNames=Object[a0_0x454959(0x1d2)],__getProtoOf=Object[a0_0x454959(0x231)],__hasOwnProp=Object['prototype'][a0_0x454959(0x1d3)],__copyProps=(_0x3df28c,_0x357a64,_0x27ce09,_0x56fcf2)=>{const _0x458af2=a0_0x454959;if(_0x357a64&&typeof _0x357a64==='object'||typeof _0x357a64===_0x458af2(0x201)){for(let _0x22df06 of __getOwnPropNames(_0x357a64))if(!__hasOwnProp['call'](_0x3df28c,_0x22df06)&&_0x22df06!==_0x27ce09)__defProp(_0x3df28c,_0x22df06,{'get':()=>_0x357a64[_0x22df06],'enumerable':!(_0x56fcf2=__getOwnPropDesc(_0x357a64,_0x22df06))||_0x56fcf2['enumerable']});}return _0x3df28c;},__toESM=(_0x4a0f88,_0x3dbc42,_0x19c068)=>(_0x19c068=_0x4a0f88!=null?__create(__getProtoOf(_0x4a0f88)):{},__copyProps(_0x3dbc42||!_0x4a0f88||!_0x4a0f88[a0_0x454959(0x238)]?__defProp(_0x19c068,'default',{'value':_0x4a0f88,'enumerable':!![]}):_0x19c068,_0x4a0f88)),import_child_process=require('child_process'),fs=__toESM(require('fs'),0x1),import_module=require('module'),os=__toESM(require('os'),0x1),path=__toESM(require(a0_0x454959(0x1e6)),0x1),WRAPPER_PKG_NAME='@whalent/agent',CORE_PKG_NAME='@whalent/agent-core',NPM_REGISTRY=a0_0x454959(0x218)+'js.org',SUPERVISED_RESTART_CODE=0x4b,NPM_VIEW_TIMEOUT_MS=0x3a98,HEALTH_TIMEOUT_MS=0xafc8,RESTART_DELAY_MS=0x3e8,NPM_INSTALL_TIMEOUT_MS=0xa*0x3c*0x3e8,NPM_INSTALL_MAX_BUFFER=0x20*0x400*0x400,WRAPPER_VERSION=readWrapperVersion(),CHECKED_PTY_HELPERS=new Set();function wrapperBaseDir(){return __dirname;}function configDir(){const _0x3d09c4=a0_0x454959;return path['join'](os[_0x3d09c4(0x226)](),'.whalent-agent');}function upgradeStatePath(){const _0x5a67f9=a0_0x454959;return path[_0x5a67f9(0x213)](configDir(),'core-upgrade.json');}function readWrapperVersion(){const _0x1fd583=a0_0x454959;try{const _0x5e3797=JSON[_0x1fd583(0x200)](fs['readFileSync'](path['join'](wrapperBaseDir(),'..',_0x1fd583(0x216)),'utf-8'));return String(_0x5e3797[_0x1fd583(0x1f9)]||'0.0.0');}catch{return _0x1fd583(0x1e2);}}function readUpgradeState(){const _0x5338c5=a0_0x454959;try{return JSON[_0x5338c5(0x200)](fs[_0x5338c5(0x210)](upgradeStatePath(),'utf-8'));}catch{return null;}}function writeUpgradeState(_0x293c9a){const _0xa651d8=a0_0x454959;try{fs[_0xa651d8(0x21b)](configDir(),{'recursive':!![]}),fs['writeFileSync'](upgradeStatePath(),JSON['stringify']({..._0x293c9a,'updated_at':Date['now']()},null,0x2),_0xa651d8(0x1c6));}catch{}}function run(_0x582114,_0x17e4ae,_0x33a354=process.env){const _0x2e0634=a0_0x454959;return(0x0,import_child_process['spawnSync'])(_0x582114,_0x17e4ae,{'encoding':_0x2e0634(0x205),'timeout':NPM_INSTALL_TIMEOUT_MS,'maxBuffer':NPM_INSTALL_MAX_BUFFER,'env':_0x33a354,'shell':![]});}function runNpmView(_0x1f191c){const _0xf3a7f6=a0_0x454959,_0x174a5d=resolveExecutable(_0xf3a7f6(0x1ed));if(!_0x174a5d)return{'status':0x7f,'stdout':'','stderr':'npm\x20not\x20found','error':new Error(_0xf3a7f6(0x1fe))};return(0x0,import_child_process[_0xf3a7f6(0x23b)])(_0x174a5d,_0x1f191c,{'encoding':'utf8','timeout':NPM_VIEW_TIMEOUT_MS,'maxBuffer':0x400*0x400,'env':process.env,'shell':![]});}function npmRootGlobal(){const _0x5d9a8d=a0_0x454959,_0x5b0a13=resolveExecutable('npm');if(!_0x5b0a13)return'';const _0x3aa430=run(_0x5b0a13,['root','-g']);if(_0x3aa430['status']!==0x0)return'';return String(_0x3aa430[_0x5d9a8d(0x203)]||'')['trim']();}function compareSemver(_0x3cf3ab,_0x1e0c08){const _0x5d1683=a0_0x454959,_0x74391f=String(_0x3cf3ab||'')['replace'](/^v/,'')['split'](/[.-]/)['map'](_0x236136=>Number['parseInt'](_0x236136,0xa)||0x0),_0x57ca30=String(_0x1e0c08||'')[_0x5d1683(0x1c2)](/^v/,'')['split'](/[.-]/)['map'](_0x87aea0=>Number['parseInt'](_0x87aea0,0xa)||0x0);for(let _0x41595a=0x0;_0x41595a<Math[_0x5d1683(0x1d4)](_0x74391f[_0x5d1683(0x1c5)],_0x57ca30['length'],0x3);_0x41595a++){const _0x4b349a=_0x74391f[_0x41595a]||0x0,_0x55f89e=_0x57ca30[_0x41595a]||0x0;if(_0x4b349a>_0x55f89e)return 0x1;if(_0x4b349a<_0x55f89e)return-0x1;}return 0x0;}function resolveExecutable(_0x7fa1bc){const _0x60f166=a0_0x454959,_0x21bd70=process[_0x60f166(0x1d1)]==='win32'?'where.exe':_0x60f166(0x215);try{const _0x5bc85a=(0x0,import_child_process[_0x60f166(0x23b)])(_0x21bd70,[_0x7fa1bc],{'encoding':_0x60f166(0x205),'timeout':0xbb8,'shell':![]});if(_0x5bc85a[_0x60f166(0x236)]!==0x0)return'';return String(_0x5bc85a[_0x60f166(0x203)]||'')['split'](/\r?\n/)['map'](_0x4b0ab0=>_0x4b0ab0[_0x60f166(0x212)]())['filter'](Boolean)[0x0]||'';}catch{return'';}}function skipWrapperUpdateCheck(){const _0x444648=a0_0x454959,_0x8f5676=String(process.env.WHALENT_SKIP_UPDATE_CHECK||process.env.WHALENT_NO_UPDATE_CHECK||process.env.WHALENT_SKIP_WRAPPER_UPDATE||'')['trim']()[_0x444648(0x1db)]();return _0x8f5676==='1'||_0x8f5676==='true'||_0x8f5676===_0x444648(0x21d)||_0x8f5676==='on';}function latestWrapperVersion(){const _0x409510=a0_0x454959,_0xf7c70a=runNpmView(['view',WRAPPER_PKG_NAME+_0x409510(0x22f),'version','--registry='+NPM_REGISTRY]);if(_0xf7c70a['status']!==0x0)return'';return String(_0xf7c70a['stdout']||'')[_0x409510(0x212)]()[_0x409510(0x224)](/\r?\n/)[_0x409510(0x1ec)](Boolean)['pop']()||'';}function installWrapperVersion(_0x56e864){const _0x546cb2=a0_0x454959,_0x130189=resolveExecutable('npm');if(!_0x130189)return{'ok':![],'output':'npm\x20not\x20found\x20on\x20PAT'+'H'};const _0x3e2725=run(_0x130189,[_0x546cb2(0x1d0),'-g',WRAPPER_PKG_NAME+'@'+_0x56e864,'--registry='+NPM_REGISTRY]),_0x4ea3bb=((_0x3e2725['stdout']||'')+'\x0a'+(_0x3e2725['stderr']||''))[_0x546cb2(0x212)]();return{'ok':_0x3e2725['status']===0x0,'output':_0x4ea3bb};}function maybeUpdateWrapper(_0x296611){const _0x545817=a0_0x454959;if(skipWrapperUpdateCheck())return![];if(process.env.WHALENT_WRAPPER_UPDATE_ATTEMPTED)return![];const _0x52c003=latestWrapperVersion();if(!_0x52c003||compareSemver(_0x52c003,WRAPPER_VERSION)<=0x0)return![];console['warn'](_0x545817(0x1eb)+'ilable:\x20'+WRAPPER_VERSION+_0x545817(0x1f0)+_0x52c003),console[_0x545817(0x1c4)](_0x545817(0x1f4)+'\x20'+WRAPPER_PKG_NAME+'@'+_0x52c003+('\x20from\x20npm\x20before\x20sta'+_0x545817(0x1e8)));const _0x586840=installWrapperVersion(_0x52c003);if(!_0x586840['ok']){console['warn']('[wrapper]\x20wrapper\x20up'+_0x545817(0x1e3)+'ing\x20with\x20'+WRAPPER_VERSION);if(_0x586840['output'])console[_0x545817(0x1c4)](_0x586840[_0x545817(0x1d8)]['split'](/\r?\n/)[_0x545817(0x1ca)](-0xc)[_0x545817(0x213)]('\x0a'));return console[_0x545817(0x1c4)]('[wrapper]\x20Manual\x20upd'+'ate:\x20npm\x20install\x20-g\x20'+WRAPPER_PKG_NAME+'@'+_0x52c003+_0x545817(0x1e5)+NPM_REGISTRY),![];}console[_0x545817(0x1c4)]('[wrapper]\x20wrapper\x20up'+'dated\x20to\x20'+_0x52c003+_0x545817(0x1c3));const _0x434ba4=process[_0x545817(0x1cc)][0x1],_0xc48678=(0x0,import_child_process['spawnSync'])(process['execPath'],[_0x434ba4,..._0x296611],{'stdio':_0x545817(0x1e7),'env':{...process.env,'WHALENT_WRAPPER_UPDATE_ATTEMPTED':_0x52c003},'shell':![]});process['exit'](_0xc48678['status']??0x0);}function findCoreScript(){const _0x4c40a1=a0_0x454959,_0x530c99=String(process.env.WHALENT_CORE_ENTRY||'')['trim']();if(_0x530c99&&fs[_0x4c40a1(0x1d9)](_0x530c99))return _0x530c99;const _0x4447f1=npmRootGlobal();if(_0x4447f1){const _0x3d2d0b=path[_0x4c40a1(0x213)](_0x4447f1,_0x4c40a1(0x1ee),_0x4c40a1(0x202),'dist','index.cjs');if(fs[_0x4c40a1(0x1d9)](_0x3d2d0b))return _0x3d2d0b;}const _0x583add=path['join'](wrapperBaseDir(),_0x4c40a1(0x208));if(fs[_0x4c40a1(0x1d9)](_0x583add))return _0x583add;const _0x23f9aa=path['join'](wrapperBaseDir(),'..','packages','core','dist','index.cjs');if(fs['existsSync'](_0x23f9aa))return _0x23f9aa;throw new Error('whalent\x20core\x20runtime'+'\x20not\x20found;\x20install\x20'+'@whalent/agent-core\x20'+'or\x20rebuild\x20@whalent/'+'agent');}function coreVersion(_0x4c5622=findCoreScript()){const _0x4bc721=a0_0x454959,_0x5993cf=(0x0,import_child_process[_0x4bc721(0x23b)])(process[_0x4bc721(0x22a)],[_0x4c5622,_0x4bc721(0x237)],{'encoding':'utf8','timeout':0x3a98,'env':{...process.env,'WHALENT_SKIP_UPDATE_CHECK':'1'},'shell':![]}),_0x10e212=(_0x5993cf['stdout']||'')+'\x0a'+(_0x5993cf['stderr']||'');return _0x10e212[_0x4bc721(0x222)](/(\d+\.\d+\.\d+(?:[-\w.]+)?)/)?.[0x1]||'';}function isExecutable(_0x63d8ea){const _0x4105e2=a0_0x454959;try{return fs[_0x4105e2(0x20c)](_0x63d8ea,fs['constants']['X_OK']),!![];}catch{return![];}}function shellQuote(_0x331954){const _0x2a1379=a0_0x454959;return'\x27'+_0x331954[_0x2a1379(0x1c2)](/'/g,'\x27\x5c\x27\x27')+'\x27';}function coreNodePtySpawnHelperPath(_0x4abc4f){const _0x5cf982=a0_0x454959;if(process['platform']!==_0x5cf982(0x1ce))return'';try{const _0x17ec0c=(0x0,import_module['createRequire'])(_0x4abc4f),_0x15a563=_0x17ec0c['resolve']('node-pty'),_0x384ba7=path[_0x5cf982(0x229)](path[_0x5cf982(0x1fa)](_0x15a563),'..');return path[_0x5cf982(0x213)](_0x384ba7,_0x5cf982(0x219),'darwin-'+process[_0x5cf982(0x1f5)],'spawn-helper');}catch{return'';}}function checkMacNodePtySpawnHelper(_0xa9bb82){const _0xd03c7a=a0_0x454959,_0x5514c2=coreNodePtySpawnHelperPath(_0xa9bb82);if(!_0x5514c2||CHECKED_PTY_HELPERS[_0xd03c7a(0x225)](_0x5514c2))return;CHECKED_PTY_HELPERS[_0xd03c7a(0x221)](_0x5514c2);if(!fs['existsSync'](_0x5514c2)){console['warn'](_0xd03c7a(0x234)+'-pty\x20spawn-helper\x20no'+'t\x20found:\x20'+_0x5514c2);return;}if(isExecutable(_0x5514c2))return;try{const _0x436cfd=fs[_0xd03c7a(0x209)](_0x5514c2)['mode'];fs['chmodSync'](_0x5514c2,_0x436cfd|0x1ed);}catch{}if(isExecutable(_0x5514c2)){console['warn'](_0xd03c7a(0x22c)+_0xd03c7a(0x207)+_0xd03c7a(0x214)+_0x5514c2);return;}console['warn']('[wrapper]\x20macOS\x20node'+_0xd03c7a(0x1e1)+_0xd03c7a(0x1d6)+_0x5514c2),console['warn'](_0xd03c7a(0x211)+'nce\x20to\x20fix\x20terminal/'+_0xd03c7a(0x22e)),console[_0xd03c7a(0x1c4)]('\x20\x20HELPER='+shellQuote(_0x5514c2)),console['warn']('\x20\x20ls\x20-l\x20\x22$HELPER\x22'),console[_0xd03c7a(0x1c4)](_0xd03c7a(0x1cb));}function printVersion(){const _0x2af000=a0_0x454959;let _0x2694ae='';try{_0x2694ae=coreVersion();}catch{}console[_0x2af000(0x20a)](_0x2af000(0x1d7)+WRAPPER_VERSION),console[_0x2af000(0x20a)](_0x2af000(0x1fd)+WRAPPER_VERSION),console[_0x2af000(0x20a)](_0x2af000(0x21a)+(_0x2694ae||_0x2af000(0x1c7)));}function a0_0x4500(_0x536442,_0x559c6b){_0x536442=_0x536442-0x1c1;const _0x1950eb=a0_0x1950();let _0x45003e=_0x1950eb[_0x536442];if(a0_0x4500['juVbmP']===undefined){var _0x5730c1=function(_0x41c3e9){const _0x17cf6d='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x3df28c='',_0x357a64='';for(let _0x27ce09=0x0,_0x56fcf2,_0x22df06,_0x4a0f88=0x0;_0x22df06=_0x41c3e9['charAt'](_0x4a0f88++);~_0x22df06&&(_0x56fcf2=_0x27ce09%0x4?_0x56fcf2*0x40+_0x22df06:_0x22df06,_0x27ce09++%0x4)?_0x3df28c+=String['fromCharCode'](0xff&_0x56fcf2>>(-0x2*_0x27ce09&0x6)):0x0){_0x22df06=_0x17cf6d['indexOf'](_0x22df06);}for(let _0x3dbc42=0x0,_0x19c068=_0x3df28c['length'];_0x3dbc42<_0x19c068;_0x3dbc42++){_0x357a64+='%'+('00'+_0x3df28c['charCodeAt'](_0x3dbc42)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x357a64);};a0_0x4500['OkeSeS']=_0x5730c1,a0_0x4500['zPTDUy']={},a0_0x4500['juVbmP']=!![];}const _0x582d60=_0x1950eb[0x0],_0x3fe6f6=_0x536442+_0x582d60,_0x5f348b=a0_0x4500['zPTDUy'][_0x3fe6f6];return!_0x5f348b?(_0x45003e=a0_0x4500['OkeSeS'](_0x45003e),a0_0x4500['zPTDUy'][_0x3fe6f6]=_0x45003e):_0x45003e=_0x5f348b,_0x45003e;}function directCore(_0x5e4dd8){const _0x4e0e89=a0_0x454959,_0x27d002=findCoreScript();checkMacNodePtySpawnHelper(_0x27d002);const _0x1dff3f=(0x0,import_child_process[_0x4e0e89(0x23b)])(process['execPath'],[_0x27d002,..._0x5e4dd8],{'stdio':_0x4e0e89(0x1e7),'env':{...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_CORE_ENTRY':_0x27d002},'shell':![]});process[_0x4e0e89(0x223)](_0x1dff3f[_0x4e0e89(0x236)]??0x0);}function shouldSupervise(_0x1ab8d5){const _0x24f00c=a0_0x454959;if(_0x1ab8d5['includes'](_0x24f00c(0x1f1)))return![];const _0x166413=_0x1ab8d5[0x0]||'';if(_0x166413==='ls'||_0x166413===_0x24f00c(0x236)||_0x166413==='ps')return![];if(_0x166413===_0x24f00c(0x20e)||_0x166413==='daemon-mcp')return![];if(_0x1ab8d5['includes'](_0x24f00c(0x1f2))||_0x1ab8d5['includes']('-h'))return![];return!![];}function installCoreVersion(_0x1043ba){const _0x3b37f6=a0_0x454959,_0x5cdbf5=resolveExecutable('npm');if(!_0x5cdbf5)return{'ok':![],'output':'npm\x20not\x20found\x20on\x20PAT'+'H'};const _0xd11008=CORE_PKG_NAME+'@'+_0x1043ba,_0x8b8267=run(_0x5cdbf5,['install','-g',_0xd11008,'--registry='+NPM_REGISTRY]),_0x455d94=((_0x8b8267[_0x3b37f6(0x203)]||'')+'\x0a'+(_0x8b8267[_0x3b37f6(0x20d)]||''))['trim']();return{'ok':_0x8b8267[_0x3b37f6(0x236)]===0x0,'output':_0x455d94};}async function superviseCore(_0x159896){const _0x41b40f=a0_0x454959;let _0x191587=![],_0xfbf973=null;const _0x32991f=()=>{const _0x4c2f35=a0_0x4500;_0x191587=!![];if(_0xfbf973&&!_0xfbf973[_0x4c2f35(0x1de)])try{_0xfbf973['kill']('SIGTERM');}catch{}else process['exit'](0x0);};process['on'](_0x41b40f(0x220),_0x32991f),process['on']('SIGTERM',_0x32991f);while(!![]){const _0x10bed7=findCoreScript();checkMacNodePtySpawnHelper(_0x10bed7);const _0x2d0693={...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_WRAPPER_MANAGED':'1','WHALENT_CORE_ENTRY':_0x10bed7},_0x283b5d=readUpgradeState(),_0x18e059=!!_0x283b5d?.['pending'];let _0x2800d0=![],_0x35cc44=null;console[_0x41b40f(0x20a)](_0x41b40f(0x1f7)+'ore:\x20'+_0x10bed7),_0xfbf973=(0x0,import_child_process[_0x41b40f(0x1c9)])(process[_0x41b40f(0x22a)],[_0x10bed7,..._0x159896],{'env':_0x2d0693,'stdio':['inherit','pipe',_0x41b40f(0x21f)]});const _0x3ae79e=()=>{const _0x33ee8f=_0x41b40f;if(_0x2800d0)return;_0x2800d0=!![];if(_0x35cc44)clearTimeout(_0x35cc44);const _0x20f0b5=readUpgradeState();_0x20f0b5?.['pending']&&(writeUpgradeState({..._0x20f0b5,'pending':![],'rollback':![],'health_status':'healthy'}),console[_0x33ee8f(0x20a)](_0x33ee8f(0x227)+_0x33ee8f(0x235)+(_0x20f0b5[_0x33ee8f(0x239)]||_0x20f0b5[_0x33ee8f(0x232)]||'')));},_0x31b1c1=(_0x19527e,_0x275599=![])=>{const _0x3c0f54=_0x41b40f,_0x5f5ddc=_0x19527e['toString']();(_0x275599?process['stderr']:process['stdout'])[_0x3c0f54(0x1fc)](_0x5f5ddc),(_0x5f5ddc[_0x3c0f54(0x20f)](_0x3c0f54(0x1dd))||_0x5f5ddc['includes']('Gateway\x20registered\x20m'+_0x3c0f54(0x21e))||_0x5f5ddc['includes'](_0x3c0f54(0x1cf)))&&_0x3ae79e();};_0xfbf973['stdout']?.['on']('data',_0x17b0c4=>_0x31b1c1(_0x17b0c4,![])),_0xfbf973['stderr']?.['on']('data',_0x4f7fdb=>_0x31b1c1(_0x4f7fdb,!![]));_0x18e059&&(_0x35cc44=setTimeout(()=>{const _0x4eb113=_0x41b40f;if(_0x2800d0||!_0xfbf973||_0xfbf973[_0x4eb113(0x1de)])return;console['error']('[wrapper]\x20new\x20core\x20d'+_0x4eb113(0x23c)+_0x4eb113(0x1fb)+_0x4eb113(0x1c8));try{_0xfbf973['kill'](_0x4eb113(0x1e9));}catch{}},HEALTH_TIMEOUT_MS));const _0x28a163=await new Promise(_0x2fd061=>{const _0x47745a=_0x41b40f;_0xfbf973[_0x47745a(0x1e4)]('exit',(_0x34bdeb,_0x4ae996)=>_0x2fd061({'code':_0x34bdeb,'signal':_0x4ae996}));});if(_0x35cc44)clearTimeout(_0x35cc44);_0xfbf973=null;if(_0x191587)process['exit'](_0x28a163[_0x41b40f(0x1cd)]??0x0);const _0x1773b2=readUpgradeState();if(_0x1773b2?.[_0x41b40f(0x233)]&&!_0x2800d0){const _0x2c3c2e=String(_0x1773b2['previous_core_versio'+'n']||'')['trim']();if(_0x2c3c2e){console['error']('[wrapper]\x20rolling\x20ba'+'ck\x20core\x20to\x20'+_0x2c3c2e);const _0x36fa7d=installCoreVersion(_0x2c3c2e);writeUpgradeState({..._0x1773b2,'pending':![],'rollback':!![],'health_status':_0x36fa7d['ok']?_0x41b40f(0x206):_0x41b40f(0x1f8),'error':_0x36fa7d['ok']?'':_0x36fa7d[_0x41b40f(0x1d8)]});}else writeUpgradeState({..._0x1773b2,'pending':![],'rollback':!![],'health_status':_0x41b40f(0x1d5),'error':_0x41b40f(0x1e0)+'n\x20unknown'});}const _0xc3fcfc=_0x28a163['code']===SUPERVISED_RESTART_CODE||_0x1773b2?.[_0x41b40f(0x233)];if(!_0xc3fcfc&&_0x28a163['code']===0x0)process[_0x41b40f(0x223)](0x0);console['log']('[wrapper]\x20core\x20exite'+'d\x20code='+(_0x28a163['code']??'')+(_0x28a163[_0x41b40f(0x1df)]?'\x20signal='+_0x28a163[_0x41b40f(0x1df)]:'')+';\x20restarting\x20in\x20'+RESTART_DELAY_MS+'ms'),await new Promise(_0x8f4ec0=>setTimeout(_0x8f4ec0,RESTART_DELAY_MS));}}async function main(){const _0x2baccd=a0_0x454959,_0x4e7922=process['argv'][_0x2baccd(0x1ca)](0x2);if(_0x4e7922[0x0]==='--version'||_0x4e7922[0x0]==='-v'||_0x4e7922[0x0]===_0x2baccd(0x1f9)){printVersion();return;}if((_0x4e7922[0x0]===_0x2baccd(0x236)||_0x4e7922[0x0]==='ls'||_0x4e7922[0x0]==='ps')&&!_0x4e7922[_0x2baccd(0x20f)](_0x2baccd(0x1ef))){console[_0x2baccd(0x20a)](_0x2baccd(0x1fd)+WRAPPER_VERSION);try{console[_0x2baccd(0x20a)](_0x2baccd(0x21a)+(coreVersion()||'not\x20installed'));}catch{console['log'](_0x2baccd(0x1ff));}}maybeUpdateWrapper(_0x4e7922);if(!shouldSupervise(_0x4e7922))directCore(_0x4e7922);await superviseCore(_0x4e7922);}main()[a0_0x454959(0x20b)](_0x140174=>{const _0x9d7374=a0_0x454959;console[_0x9d7374(0x230)](_0x9d7374(0x228)+_0x9d7374(0x1f6)+(_0x140174?.['message']||String(_0x140174))),process['exit'](0x1);});function a0_0x1950(){const _0x59b873=['ig5VDcbLEgvJDxrHyMXLoIa','D2HHBgvUDc1Hz2vUDca','B3v0Chv0','zxHPC3rZu3LUyW','mZa3nZKWt3H2CKXI','Dg9mB3DLCKnHC2u','mte3t2rltM9L','w2DHDgv3yxLDienVBM5Ly3rLza','A2LSBgvK','C2LNBMfS','ChjLDMLVDxmGy29Yzsb2zxjZAw8','lxb0EsbZCgf3BI1OzwXWzxiGAxm','mc4WlJa','zgf0zsbMywLSzwq7ignVBNrPBNu','B25Jzq','ic0TCMvNAxn0CNK9','Cgf0Aa','Aw5OzxjPDa','CNrPBMCGy29Yzs4UlG','u0Lhvevstq','mZC3mJy5mNHfBvHxza','w3DYyxbWzxjDihvWzgf0zsbHDMe','zMLSDgvY','BNbT','qhDOywXLBNq','ls1QC29U','ic0+ia','ls1Hz2vUDc1Pza','ls1OzwXW','mtK4nJuXnuDzq2rTyG','w3DYyxbWzxjDigLUC3rHBgXPBMC','yxjJAa','CJOG','w3DYyxbWzxjDihn0yxj0Aw5Nigm','CM9SBgjHy2TFzMfPBgvK','DMvYC2LVBG','zgLYBMfTzq','EsbPBIb0Aw1LoYbYB2XSAw5Nigi','D3jPDgu','D3jHChbLCIa','BNbTig5VDcbMB3vUza','y29YzsbUB3qGAw5ZDgfSBgvK','CgfYC2u','zNvUy3rPB24','ywDLBNqTy29Yzq','C3rKB3v0','mZK3mZa4mhPfA0TSqG','DxrMoa','CM9SBgvKx2jHy2S','uYbUB2rLlxb0EsbZCgf3BI1OzwW','y29Yzs5JANm','C3rHDfn5BMm','Bg9N','y2f0y2G','ywnJzxnZu3LUyW','C3rKzxjY','BwnW','Aw5JBhvKzxm','CMvHzezPBgvtEw5J','w3DYyxbWzxjDifj1BIb0AgLZig8','DhjPBq','AM9PBG','CgvYigv4zwn1DgfIBguGyML0oIa','D2HPy2G','CgfJA2fNzs5QC29U','nZy3mZi4uNrjCffX','Ahr0Chm6lY9YzwDPC3rYEs5UCg0','ChjLyNvPBgrZ','y29Yzsa','BwTKAxjtEw5J','ChrVCG','EwvZ','ywnOAw5L','CgLWzq','u0Lhsu5u','ywrK','Bwf0y2G','zxHPDa','C3bSAxq','AgfZ','Ag9TzwrPCG','w3DYyxbWzxjDignVCMuGDxbNCMe','w3DYyxbWzxjDiezHDgfSigvYCM8','CMvZB2X2zq','zxHLy1bHDgG','ndC4nZa0CLLOzuL4','w3DYyxbWzxjDigzPEgvKig1Hy08','ndK5odC5mw5Wq2rerG','ufrzihn0yxj0Dxa6','qgXHDgvZDa','zxjYB3i','z2v0uhjVDg90ExbLt2y','DgfYz2v0x3zLCNnPB24','CgvUzgLUzW','w3DYyxbWzxjDig1Hy09tig5Vzgu','zguGAgvHBhrOEtOG','C3rHDhvZ','ls12zxjZAw9U','x19LC01VzhvSzq','Aw5ZDgfSBgvKx3zLCNnPB24','mvzQDgDgva','C3bHD25tEw5J','AwqGBM90igjLy29TzsbOzwfSDgG','nhntAgjgsW','CMvWBgfJzq','oYbYzxn0yxj0Aw5NihDYyxbWzxi','D2fYBG','BgvUz3rO','DxrMltG','BM90igLUC3rHBgXLza','ywnR','C3bHD24','C2XPy2u','icbJAg1VzcaREcaIjeHftfbfuIi','yxjNDG','y29Kzq','zgfYD2LU','r2f0zxDHEtOGy29UBMvJDgvK','Aw5ZDgfSBa','CgXHDgzVCM0','z2v0t3DUuhjVCgvYDhLoyw1LCW','AgfZt3DUuhjVCgvYDhK','Bwf4','CM9SBgjHy2TFDw5HDMfPBgfIBgu'];a0_0x1950=function(){return _0x59b873;};return a0_0x1950();}
|
|
2
|
+
'use strict';const a0_0x4aed35=a0_0x26cb;(function(_0x452a8b,_0x1688d0){const _0x5387a1=a0_0x26cb,_0x1f37f8=_0x452a8b();while(!![]){try{const _0x37f924=-parseInt(_0x5387a1(0x107))/0x1*(parseInt(_0x5387a1(0x11f))/0x2)+-parseInt(_0x5387a1(0x170))/0x3+-parseInt(_0x5387a1(0x138))/0x4+-parseInt(_0x5387a1(0x125))/0x5+-parseInt(_0x5387a1(0x151))/0x6+-parseInt(_0x5387a1(0x144))/0x7+parseInt(_0x5387a1(0x12e))/0x8*(parseInt(_0x5387a1(0x15a))/0x9);if(_0x37f924===_0x1688d0)break;else _0x1f37f8['push'](_0x1f37f8['shift']());}catch(_0x2239e6){_0x1f37f8['push'](_0x1f37f8['shift']());}}}(a0_0x192c,0x65a0c));var __create=Object['create'],__defProp=Object['defineProperty'],__getOwnPropDesc=Object['getOwnPropertyDescri'+'ptor'],__getOwnPropNames=Object[a0_0x4aed35(0x11a)],__getProtoOf=Object['getPrototypeOf'],__hasOwnProp=Object[a0_0x4aed35(0x163)]['hasOwnProperty'],__copyProps=(_0x3165e9,_0x5e28dd,_0xb74237,_0x373b1a)=>{const _0x48a048=a0_0x4aed35;if(_0x5e28dd&&typeof _0x5e28dd==='object'||typeof _0x5e28dd==='function'){for(let _0x4b62c3 of __getOwnPropNames(_0x5e28dd))if(!__hasOwnProp['call'](_0x3165e9,_0x4b62c3)&&_0x4b62c3!==_0xb74237)__defProp(_0x3165e9,_0x4b62c3,{'get':()=>_0x5e28dd[_0x4b62c3],'enumerable':!(_0x373b1a=__getOwnPropDesc(_0x5e28dd,_0x4b62c3))||_0x373b1a[_0x48a048(0x153)]});}return _0x3165e9;},__toESM=(_0x5c3648,_0x52ec82,_0x270012)=>(_0x270012=_0x5c3648!=null?__create(__getProtoOf(_0x5c3648)):{},__copyProps(_0x52ec82||!_0x5c3648||!_0x5c3648[a0_0x4aed35(0x159)]?__defProp(_0x270012,'default',{'value':_0x5c3648,'enumerable':!![]}):_0x270012,_0x5c3648)),import_child_process=require('child_process'),fs=__toESM(require('fs'),0x1),import_module=require(a0_0x4aed35(0x10a)),os=__toESM(require('os'),0x1),path=__toESM(require('path'),0x1),WRAPPER_PKG_NAME='@whalent/agent',CORE_PKG_NAME='@whalent/agent-core',NPM_REGISTRY='https://registry.npm'+'js.org',SUPERVISED_RESTART_CODE=0x4b,NPM_VIEW_TIMEOUT_MS=0x3a98,HEALTH_TIMEOUT_MS=0xafc8,RESTART_DELAY_MS=0x3e8,NPM_INSTALL_TIMEOUT_MS=0xa*0x3c*0x3e8,NPM_INSTALL_MAX_BUFFER=0x20*0x400*0x400,WRAPPER_VERSION=readWrapperVersion(),CHECKED_PTY_HELPERS=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 readWrapperVersion(){const _0xe80f8f=a0_0x4aed35;try{const _0x28b321=JSON['parse'](fs[_0xe80f8f(0x134)](path['join'](wrapperBaseDir(),'..',_0xe80f8f(0x111)),_0xe80f8f(0x16a)));return String(_0x28b321[_0xe80f8f(0x10d)]||'0.0.0');}catch{return _0xe80f8f(0x147);}}function readUpgradeState(){const _0x1ab12f=a0_0x4aed35;try{return JSON[_0x1ab12f(0x12c)](fs['readFileSync'](upgradeStatePath(),'utf-8'));}catch{return null;}}function writeUpgradeState(_0x545731){const _0x1d878f=a0_0x4aed35;try{fs[_0x1d878f(0x10f)](configDir(),{'recursive':!![]}),fs[_0x1d878f(0x15e)](upgradeStatePath(),JSON[_0x1d878f(0x16c)]({..._0x545731,'updated_at':Date[_0x1d878f(0x10c)]()},null,0x2),_0x1d878f(0x16a));}catch{}}function run(_0x204d65,_0x13980e,_0x85ab32=process.env){const _0x359b26=a0_0x4aed35;return(0x0,import_child_process[_0x359b26(0x15d)])(_0x204d65,_0x13980e,{'encoding':'utf8','timeout':NPM_INSTALL_TIMEOUT_MS,'maxBuffer':NPM_INSTALL_MAX_BUFFER,'env':_0x85ab32,'shell':![]});}function runNpmView(_0x12b5dc){const _0x2a7c36=a0_0x4aed35,_0x233ed9=resolveExecutable('npm');if(!_0x233ed9)return{'status':0x7f,'stdout':'','stderr':'npm\x20not\x20found','error':new Error(_0x2a7c36(0x109))};return(0x0,import_child_process[_0x2a7c36(0x15d)])(_0x233ed9,_0x12b5dc,{'encoding':'utf8','timeout':NPM_VIEW_TIMEOUT_MS,'maxBuffer':0x400*0x400,'env':process.env,'shell':![]});}function npmRootGlobal(){const _0x455120=a0_0x4aed35,_0x4b1a12=resolveExecutable('npm');if(!_0x4b1a12)return'';const _0x4ec951=run(_0x4b1a12,[_0x455120(0xfc),'-g']);if(_0x4ec951[_0x455120(0x161)]!==0x0)return'';return String(_0x4ec951[_0x455120(0xfd)]||'')['trim']();}function compareSemver(_0x56e177,_0x47332e){const _0x3d2e20=a0_0x4aed35,_0x549365=String(_0x56e177||'')['replace'](/^v/,'')['split'](/[.-]/)['map'](_0x52182c=>Number['parseInt'](_0x52182c,0xa)||0x0),_0xd765e2=String(_0x47332e||'')[_0x3d2e20(0x16f)](/^v/,'')[_0x3d2e20(0x113)](/[.-]/)[_0x3d2e20(0x149)](_0x534feb=>Number['parseInt'](_0x534feb,0xa)||0x0);for(let _0x36fbde=0x0;_0x36fbde<Math[_0x3d2e20(0x128)](_0x549365[_0x3d2e20(0x106)],_0xd765e2['length'],0x3);_0x36fbde++){const _0x217bbd=_0x549365[_0x36fbde]||0x0,_0x572ad5=_0xd765e2[_0x36fbde]||0x0;if(_0x217bbd>_0x572ad5)return 0x1;if(_0x217bbd<_0x572ad5)return-0x1;}return 0x0;}function resolveExecutable(_0x3bbdef){const _0x3846b2=a0_0x4aed35,_0x3fbe68=process['platform']==='win32'?'where.exe':_0x3846b2(0xff);try{const _0x5b606a=(0x0,import_child_process['spawnSync'])(_0x3fbe68,[_0x3bbdef],{'encoding':'utf8','timeout':0xbb8,'shell':![]});if(_0x5b606a['status']!==0x0)return'';return String(_0x5b606a[_0x3846b2(0xfd)]||'')['split'](/\r?\n/)['map'](_0x2a81e1=>_0x2a81e1[_0x3846b2(0x14e)]())[_0x3846b2(0x154)](Boolean)[0x0]||'';}catch{return'';}}function skipWrapperUpdateCheck(){const _0x50a165=a0_0x4aed35,_0x40dc14=String(process.env.WHALENT_SKIP_UPDATE_CHECK||process.env.WHALENT_NO_UPDATE_CHECK||process.env.WHALENT_SKIP_WRAPPER_UPDATE||'')[_0x50a165(0x14e)]()['toLowerCase']();return _0x40dc14==='1'||_0x40dc14===_0x50a165(0x10e)||_0x40dc14==='yes'||_0x40dc14==='on';}function latestWrapperVersion(){const _0x20b0a4=a0_0x4aed35,_0x48ba21=runNpmView([_0x20b0a4(0x150),WRAPPER_PKG_NAME+'@latest',_0x20b0a4(0x10d),'--registry='+NPM_REGISTRY]);if(_0x48ba21[_0x20b0a4(0x161)]!==0x0)return'';return String(_0x48ba21['stdout']||'')[_0x20b0a4(0x14e)]()['split'](/\r?\n/)[_0x20b0a4(0x154)](Boolean)['pop']()||'';}function installWrapperVersion(_0x4e6fe2){const _0x1f90f1=a0_0x4aed35,_0x4d3d3f=resolveExecutable('npm');if(!_0x4d3d3f)return{'ok':![],'output':'npm\x20not\x20found\x20on\x20PAT'+'H'};const _0x2d72f8=run(_0x4d3d3f,[_0x1f90f1(0x155),'-g',WRAPPER_PKG_NAME+'@'+_0x4e6fe2,_0x1f90f1(0x12a)+NPM_REGISTRY]),_0x2f0a00=((_0x2d72f8[_0x1f90f1(0xfd)]||'')+'\x0a'+(_0x2d72f8[_0x1f90f1(0x14c)]||''))['trim']();return{'ok':_0x2d72f8['status']===0x0,'output':_0x2f0a00};}function maybeUpdateWrapper(_0x18d6f0){const _0x338697=a0_0x4aed35;if(skipWrapperUpdateCheck())return![];if(process.env.WHALENT_WRAPPER_UPDATE_ATTEMPTED)return![];const _0xc78c9e=latestWrapperVersion();if(!_0xc78c9e||compareSemver(_0xc78c9e,WRAPPER_VERSION)<=0x0)return![];console[_0x338697(0x10b)]('[wrapper]\x20update\x20ava'+_0x338697(0x139)+WRAPPER_VERSION+'\x20->\x20'+_0xc78c9e),console[_0x338697(0x10b)]('[wrapper]\x20installing'+'\x20'+WRAPPER_PKG_NAME+'@'+_0xc78c9e+(_0x338697(0x14a)+_0x338697(0x102)));const _0x50242d=installWrapperVersion(_0xc78c9e);if(!_0x50242d['ok']){console['warn']('[wrapper]\x20wrapper\x20up'+'date\x20failed;\x20continu'+_0x338697(0x160)+WRAPPER_VERSION);if(_0x50242d[_0x338697(0x13c)])console[_0x338697(0x10b)](_0x50242d['output'][_0x338697(0x113)](/\r?\n/)['slice'](-0xc)[_0x338697(0x122)]('\x0a'));return console['warn'](_0x338697(0x115)+_0x338697(0x101)+WRAPPER_PKG_NAME+'@'+_0xc78c9e+'\x20--registry='+NPM_REGISTRY),![];}console[_0x338697(0x10b)](_0x338697(0x13d)+_0x338697(0x16d)+_0xc78c9e+';\x20restarting\x20wrapper');const _0x1c1725=process[_0x338697(0x131)][0x1],_0xbfa1e9=(0x0,import_child_process['spawnSync'])(process['execPath'],[_0x1c1725,..._0x18d6f0],{'stdio':'inherit','env':{...process.env,'WHALENT_WRAPPER_UPDATE_ATTEMPTED':_0xc78c9e},'shell':![]});process['exit'](_0xbfa1e9[_0x338697(0x161)]??0x0);}function findCoreScript(){const _0x4563fc=a0_0x4aed35,_0x505179=String(process.env.WHALENT_CORE_ENTRY||'')[_0x4563fc(0x14e)](),_0x56900c=['1','true',_0x4563fc(0x175),'on']['includes'](String(process.env.WHALENT_FORCE_CORE_ENTRY||'')[_0x4563fc(0x14e)]()['toLowerCase']());if(_0x505179&&_0x56900c&&fs['existsSync'](_0x505179))return _0x505179;const _0x39be01=[],_0x1429e2=_0x370841=>{const _0x2ae134=_0x4563fc;if(fs[_0x2ae134(0x148)](_0x370841)&&!_0x39be01['includes'](_0x370841))_0x39be01['push'](_0x370841);};if(_0x505179)_0x1429e2(_0x505179);const _0x12bdab=npmRootGlobal();if(_0x12bdab){const _0x2b16c8=path['join'](_0x12bdab,'@whalent',_0x4563fc(0x105),'dist','index.cjs');_0x1429e2(_0x2b16c8);}const _0x9cf616=path[_0x4563fc(0x122)](wrapperBaseDir(),_0x4563fc(0x145));_0x1429e2(_0x9cf616);const _0x2cadf7=path[_0x4563fc(0x122)](wrapperBaseDir(),'..','packages','core',_0x4563fc(0x135),_0x4563fc(0x100));_0x1429e2(_0x2cadf7);if(_0x39be01[_0x4563fc(0x106)]>0x0)return _0x39be01['map']((_0x5c8894,_0x2fd10d)=>({'candidate':_0x5c8894,'index':_0x2fd10d,'version':coreVersion(_0x5c8894)}))[_0x4563fc(0x13f)]((_0x464080,_0x35b9b9)=>{const _0x2ab0ce=_0x4563fc,_0x566b62=compareSemver(_0x35b9b9['version'],_0x464080['version']);if(_0x566b62!==0x0)return _0x566b62;return _0x35b9b9['index']-_0x464080[_0x2ab0ce(0x16b)];})[0x0][_0x4563fc(0x15f)];throw new Error(_0x4563fc(0x11b)+_0x4563fc(0x108)+'@whalent/agent-core\x20'+_0x4563fc(0x116)+_0x4563fc(0x152));}function coreVersion(_0x236907=findCoreScript()){const _0x355035=a0_0x4aed35,_0x2d3c83=(0x0,import_child_process['spawnSync'])(process['execPath'],[_0x236907,_0x355035(0x114)],{'encoding':_0x355035(0x176),'timeout':0x3a98,'env':{...process.env,'WHALENT_SKIP_UPDATE_CHECK':'1'},'shell':![]}),_0x26474d=(_0x2d3c83[_0x355035(0xfd)]||'')+'\x0a'+(_0x2d3c83[_0x355035(0x14c)]||'');return _0x26474d[_0x355035(0xfe)](/(\d+\.\d+\.\d+(?:[-\w.]+)?)/)?.[0x1]||'';}function isExecutable(_0x40c249){const _0x46fc0d=a0_0x4aed35;try{return fs[_0x46fc0d(0x121)](_0x40c249,fs['constants'][_0x46fc0d(0x16e)]),!![];}catch{return![];}}function shellQuote(_0x12583f){return'\x27'+_0x12583f['replace'](/'/g,'\x27\x5c\x27\x27')+'\x27';}function a0_0x192c(){const _0xe5690b=['nZy1vKvOsM1L','r2f0zxDHEtOGy29UBMvJDgvK','w3DYyxbWzxjDignVCMuGDxbNCMe','C3bHD25tEw5J','D3jPDgvgAwXLu3LUyW','y2fUzgLKyxrL','Aw5NihDPDgGG','C3rHDhvZ','C3rHDfn5BMm','ChjVDg90ExbL','r2f0zxDHEsbYzwDPC3rLCMvKig0','zxjYB3i','w3DYyxbWzxjDigzPEgvKig1Hy08','zxHLy1bHDgG','AgvHBhrOEq','C3bHD24TAgvSCgvY','DxrMltG','Aw5KzxG','C3rYAw5NAwz5','zgf0zwqGDg8G','wf9psW','CMvWBgfJzq','mJm3ntC1mwnqzhzPsW','ywnOAw5L','B25Jzq','A2LSBa','zgfYD2LU','EwvZ','DxrMoa','Aw5OzxjPDa','BIb1BMTUB3DU','CM9VDa','C3rKB3v0','Bwf0y2G','D2HPy2G','Aw5KzxGUy2PZ','yxrLoIbUCg0GAw5ZDgfSBcaTzYa','CNrPBMCGy29Yzs4UlG','DcbMB3vUzdOG','yxjJAa','ywDLBNqTy29Yzq','BgvUz3rO','mwDAsKPcsa','ig5VDcbMB3vUzdSGAw5ZDgfSBca','BNbTig5VDcbMB3vUza','Bw9KDwXL','D2fYBG','BM93','DMvYC2LVBG','Dhj1zq','BwTKAxjtEw5J','zcbJB2rLpq','CgfJA2fNzs5QC29U','w3DYyxbWzxjDig5LDYbJB3jLigq','C3bSAxq','ls12zxjZAw9U','w3DYyxbWzxjDie1HBNvHBcb1Cgq','B3iGCMvIDwLSzcbaD2HHBgvUDc8','D3jPDgu','CMvZB2X2zq','lxb0EsbZCgf3BI1OzwXWzxiGBM8','z2v0t3DUuhjVCgvYDhLoyw1LCW','D2HHBgvUDcbJB3jLihj1BNrPBwu','EsbPBIb0Aw1LoYbYB2XSAw5Nigi','BNbT','ig5VDcbLEgvJDxrHyMXLoIa','mta2nJqWohDbqvPHCq','y29Kzq','ywnJzxnZu3LUyW','AM9PBG','D2HHBgvUDc1Hz2vUDca','Bg9N','mJqXotmZmeHPA0XVtq','CM9SBgjHy2TFDw5HDMfPBgfIBgu','BM9Kzs1WDhK','Bwf4','u0Lhsu5u','ls1YzwDPC3rYEt0','zgfYD2LUlq','CgfYC2u','CM9SBgjHy2TFzMfPBgvK','mZm3mde2v05Jqufq','Aw5ZDgfSBgvKx3zLCNnPB24','CgvYigv4zwn1DgfIBguGyML0oIa','yxjNDG','w3DYyxbWzxjDignVCMuGzxHPDgu','BM90igLUC3rHBgXLza','CMvHzezPBgvtEw5J','zgLZDa','CgvUzgLUzW','icbSCYaTBcaIjeHftfbfuIi','mtG5otK3mKXdCNbYzq','AwXHyMXLoIa','Aw5JBhvKzxm','zgfLBw9Ulw1JCa','B3v0Chv0','w3DYyxbWzxjDihDYyxbWzxiGDxa','icbiruXqrvi9','C29YDa','C3bHD24','A2LSBgvK','zgLYBMfTzq','ls1OzwXW','mJK4mty4nvvnsvPcqW','y29Yzs5JANm','y2HTB2rtEw5J','mc4WlJa','zxHPC3rZu3LUyW','BwfW','igzYB20GBNbTigjLzM9YzsbZDge','oYbYzxn0yxj0Aw5NigLUia','C3rKzxjY','w3DYyxbWzxjDifj1BIb0AgLZig8','DhjPBq','ChjLDMLVDxmGy29Yzsb2zxjZAw8','DMLLDW','mJCYnZu1mKnwEfDNzW','ywDLBNq','zw51BwvYywjSzq','zMLSDgvY','Aw5ZDgfSBa','u0Lhvevstq','zxHPDa','zgf0yq','x19LC01VzhvSzq'];a0_0x192c=function(){return _0xe5690b;};return a0_0x192c();}function coreNodePtySpawnHelperPath(_0x22e7a4){const _0x43e6df=a0_0x4aed35;if(process['platform']!==_0x43e6df(0x174))return'';try{const _0x52c107=(0x0,import_module['createRequire'])(_0x22e7a4),_0x2d4198=_0x52c107[_0x43e6df(0x118)](_0x43e6df(0x127)),_0x5f4b80=path['resolve'](path[_0x43e6df(0x142)](_0x2d4198),'..');return path[_0x43e6df(0x122)](_0x5f4b80,'prebuilds',_0x43e6df(0x12b)+process[_0x43e6df(0x104)],_0x43e6df(0x169));}catch{return'';}}function checkMacNodePtySpawnHelper(_0xdddb8b){const _0x1f99ee=a0_0x4aed35,_0x1b54bc=coreNodePtySpawnHelperPath(_0xdddb8b);if(!_0x1b54bc||CHECKED_PTY_HELPERS['has'](_0x1b54bc))return;CHECKED_PTY_HELPERS['add'](_0x1b54bc);if(!fs['existsSync'](_0x1b54bc)){console['warn']('[wrapper]\x20macOS\x20node'+_0x1f99ee(0x119)+_0x1f99ee(0x103)+_0x1b54bc);return;}if(isExecutable(_0x1b54bc))return;try{const _0x2659f9=fs[_0x1f99ee(0x162)](_0x1b54bc)['mode'];fs[_0x1f99ee(0x146)](_0x1b54bc,_0x2659f9|0x1ed);}catch{}if(isExecutable(_0x1b54bc)){console['warn'](_0x1f99ee(0x166)+'S\x20node-pty\x20spawn-hel'+_0x1f99ee(0x130)+_0x1b54bc);return;}console[_0x1f99ee(0x10b)]('[wrapper]\x20macOS\x20node'+'-pty\x20spawn-helper\x20is'+_0x1f99ee(0x11e)+_0x1b54bc),console[_0x1f99ee(0x10b)](_0x1f99ee(0x14d)+'nce\x20to\x20fix\x20terminal/'+'PTY\x20startup:'),console['warn'](_0x1f99ee(0x13e)+shellQuote(_0x1b54bc)),console['warn'](_0x1f99ee(0x137)),console[_0x1f99ee(0x10b)]('\x20\x20chmod\x20+x\x20\x22$HELPER\x22');}function printVersion(){const _0x1b9298=a0_0x4aed35;let _0x455660='';try{_0x455660=coreVersion();}catch{}console['log'](_0x1b9298(0x123)+WRAPPER_VERSION),console[_0x1b9298(0x124)]('wrapper\x20'+WRAPPER_VERSION),console[_0x1b9298(0x124)]('core\x20'+(_0x455660||'not\x20installed'));}function directCore(_0x2faf29){const _0x470f22=a0_0x4aed35,_0x455f20=findCoreScript();checkMacNodePtySpawnHelper(_0x455f20);const _0x3e04cb=(0x0,import_child_process[_0x470f22(0x15d)])(process[_0x470f22(0x167)],[_0x455f20,..._0x2faf29],{'stdio':_0x470f22(0x177),'env':{...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_CORE_ENTRY':_0x455f20},'shell':![]});process['exit'](_0x3e04cb['status']??0x0);}function a0_0x26cb(_0x4434dc,_0x4280ea){_0x4434dc=_0x4434dc-0xfb;const _0x192c66=a0_0x192c();let _0x26cba7=_0x192c66[_0x4434dc];if(a0_0x26cb['STRrhV']===undefined){var _0x4ce2f5=function(_0xb8c84e){const _0xbc7d47='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x3165e9='',_0x5e28dd='';for(let _0xb74237=0x0,_0x373b1a,_0x4b62c3,_0x5c3648=0x0;_0x4b62c3=_0xb8c84e['charAt'](_0x5c3648++);~_0x4b62c3&&(_0x373b1a=_0xb74237%0x4?_0x373b1a*0x40+_0x4b62c3:_0x4b62c3,_0xb74237++%0x4)?_0x3165e9+=String['fromCharCode'](0xff&_0x373b1a>>(-0x2*_0xb74237&0x6)):0x0){_0x4b62c3=_0xbc7d47['indexOf'](_0x4b62c3);}for(let _0x52ec82=0x0,_0x270012=_0x3165e9['length'];_0x52ec82<_0x270012;_0x52ec82++){_0x5e28dd+='%'+('00'+_0x3165e9['charCodeAt'](_0x52ec82)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x5e28dd);};a0_0x26cb['RBJCaL']=_0x4ce2f5,a0_0x26cb['PkwVcz']={},a0_0x26cb['STRrhV']=!![];}const _0x497876=_0x192c66[0x0],_0x39e003=_0x4434dc+_0x497876,_0x1f3683=a0_0x26cb['PkwVcz'][_0x39e003];return!_0x1f3683?(_0x26cba7=a0_0x26cb['RBJCaL'](_0x26cba7),a0_0x26cb['PkwVcz'][_0x39e003]=_0x26cba7):_0x26cba7=_0x1f3683,_0x26cba7;}function shouldSupervise(_0x3612f6){const _0x346f8a=a0_0x4aed35;if(_0x3612f6[_0x346f8a(0x13a)]('--agent-id'))return![];const _0xb9d04f=_0x3612f6[0x0]||'';if(_0xb9d04f==='ls'||_0xb9d04f===_0x346f8a(0x161)||_0xb9d04f==='ps')return![];if(_0xb9d04f==='mcp'||_0xb9d04f===_0x346f8a(0x13b))return![];if(_0x3612f6['includes'](_0x346f8a(0x143))||_0x3612f6[_0x346f8a(0x13a)]('-h'))return![];return!![];}function installCoreVersion(_0xdcac84){const _0x275574=a0_0x4aed35,_0x23d333=resolveExecutable(_0x275574(0x11d));if(!_0x23d333)return{'ok':![],'output':'npm\x20not\x20found\x20on\x20PAT'+'H'};const _0x48958e=CORE_PKG_NAME+'@'+_0xdcac84,_0x43f674=run(_0x23d333,[_0x275574(0x155),'-g',_0x48958e,'--registry='+NPM_REGISTRY]),_0x409f09=((_0x43f674['stdout']||'')+'\x0a'+(_0x43f674[_0x275574(0x14c)]||''))['trim']();return{'ok':_0x43f674['status']===0x0,'output':_0x409f09};}async function superviseCore(_0x4b751e){const _0x45ca54=a0_0x4aed35;let _0xa772f5=![],_0xf8be3=null;const _0x566618=()=>{_0xa772f5=!![];if(_0xf8be3&&!_0xf8be3['killed'])try{_0xf8be3['kill']('SIGTERM');}catch{}else process['exit'](0x0);};process['on'](_0x45ca54(0x129),_0x566618),process['on']('SIGTERM',_0x566618);while(!![]){const _0x347d59=findCoreScript();checkMacNodePtySpawnHelper(_0x347d59);const _0x2a93cc={...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_WRAPPER_MANAGED':'1','WHALENT_CORE_ENTRY':_0x347d59},_0x598889=readUpgradeState(),_0x15e69b=!!_0x598889?.[_0x45ca54(0x136)];let _0x5aa308=![],_0xcf8ae5=null;console[_0x45ca54(0x124)]('[wrapper]\x20starting\x20c'+'ore:\x20'+_0x347d59),_0xf8be3=(0x0,import_child_process[_0x45ca54(0x140)])(process['execPath'],[_0x347d59,..._0x4b751e],{'env':_0x2a93cc,'stdio':['inherit','pipe','pipe']});const _0x13e719=()=>{const _0x1f3160=_0x45ca54;if(_0x5aa308)return;_0x5aa308=!![];if(_0xcf8ae5)clearTimeout(_0xcf8ae5);const _0x4c5616=readUpgradeState();_0x4c5616?.['pending']&&(writeUpgradeState({..._0x4c5616,'pending':![],'rollback':![],'health_status':_0x1f3160(0x168)}),console[_0x1f3160(0x124)](_0x1f3160(0x15c)+'de\x20healthy:\x20'+(_0x4c5616[_0x1f3160(0x12f)]||_0x4c5616['target_version']||'')));},_0x490137=(_0x10b75c,_0x4cf052=![])=>{const _0x9a5654=_0x45ca54,_0x2617b3=_0x10b75c['toString']();(_0x4cf052?process[_0x9a5654(0x14c)]:process[_0x9a5654(0xfd)])[_0x9a5654(0x117)](_0x2617b3),(_0x2617b3[_0x9a5654(0x13a)]('[gateway]\x20Connected')||_0x2617b3['includes'](_0x9a5654(0x164)+_0x9a5654(0x171))||_0x2617b3['includes'](_0x9a5654(0x15b)))&&_0x13e719();};_0xf8be3['stdout']?.['on'](_0x45ca54(0x158),_0x518acd=>_0x490137(_0x518acd,![])),_0xf8be3[_0x45ca54(0x14c)]?.['on'](_0x45ca54(0x158),_0x5b838b=>_0x490137(_0x5b838b,!![]));_0x15e69b&&(_0xcf8ae5=setTimeout(()=>{const _0x45e922=_0x45ca54;if(_0x5aa308||!_0xf8be3||_0xf8be3[_0x45e922(0x141)])return;console['error'](_0x45e922(0x112)+'id\x20not\x20become\x20health'+_0x45e922(0x11c)+'ack');try{_0xf8be3[_0x45e922(0x173)](_0x45e922(0x156));}catch{}},HEALTH_TIMEOUT_MS));const _0x1f0d51=await new Promise(_0x2c069a=>{const _0xc9acf5=_0x45ca54;_0xf8be3[_0xc9acf5(0x172)](_0xc9acf5(0x157),(_0x582e40,_0x514dc6)=>_0x2c069a({'code':_0x582e40,'signal':_0x514dc6}));});if(_0xcf8ae5)clearTimeout(_0xcf8ae5);_0xf8be3=null;if(_0xa772f5)process['exit'](_0x1f0d51['code']??0x0);const _0x4c9860=readUpgradeState();if(_0x4c9860?.['pending']&&!_0x5aa308){const _0x2b42cb=String(_0x4c9860['previous_core_versio'+'n']||'')['trim']();if(_0x2b42cb){console[_0x45ca54(0x165)]('[wrapper]\x20rolling\x20ba'+'ck\x20core\x20to\x20'+_0x2b42cb);const _0x370027=installCoreVersion(_0x2b42cb);writeUpgradeState({..._0x4c9860,'pending':![],'rollback':!![],'health_status':_0x370027['ok']?'rolled_back':_0x45ca54(0x12d),'error':_0x370027['ok']?'':_0x370027['output']});}else writeUpgradeState({..._0x4c9860,'pending':![],'rollback':!![],'health_status':_0x45ca54(0x126),'error':_0x45ca54(0x14f)+_0x45ca54(0xfb)});}const _0x299376=_0x1f0d51[_0x45ca54(0x120)]===SUPERVISED_RESTART_CODE||_0x4c9860?.['pending'];if(!_0x299376&&_0x1f0d51[_0x45ca54(0x120)]===0x0)process[_0x45ca54(0x157)](0x0);console['log'](_0x45ca54(0x132)+_0x45ca54(0x110)+(_0x1f0d51[_0x45ca54(0x120)]??'')+(_0x1f0d51['signal']?'\x20signal='+_0x1f0d51['signal']:'')+_0x45ca54(0x14b)+RESTART_DELAY_MS+'ms'),await new Promise(_0x2fff5e=>setTimeout(_0x2fff5e,RESTART_DELAY_MS));}}async function main(){const _0x1793a5=a0_0x4aed35,_0x15025f=process[_0x1793a5(0x131)]['slice'](0x2);if(_0x15025f[0x0]==='--version'||_0x15025f[0x0]==='-v'||_0x15025f[0x0]==='version'){printVersion();return;}if((_0x15025f[0x0]===_0x1793a5(0x161)||_0x15025f[0x0]==='ls'||_0x15025f[0x0]==='ps')&&!_0x15025f[_0x1793a5(0x13a)]('--json')){console[_0x1793a5(0x124)]('wrapper\x20'+WRAPPER_VERSION);try{console[_0x1793a5(0x124)]('core\x20'+(coreVersion()||_0x1793a5(0x133)));}catch{console[_0x1793a5(0x124)]('core\x20not\x20installed');}}maybeUpdateWrapper(_0x15025f);if(!shouldSupervise(_0x15025f))directCore(_0x15025f);await superviseCore(_0x15025f);}main()['catch'](_0x1d4a52=>{const _0x39ddc3=a0_0x4aed35;console[_0x39ddc3(0x165)]('[wrapper]\x20Fatal\x20erro'+'r:\x20'+(_0x1d4a52?.['message']||String(_0x1d4a52))),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.48",
|
|
4
4
|
"description": "Stable wrapper for Whalent Agent core runtime",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"yaml": "^2.4.0"
|
|
39
39
|
},
|
|
40
40
|
"optionalDependencies": {
|
|
41
|
-
"@whalent/agent-core": "0.3.
|
|
41
|
+
"@whalent/agent-core": "0.3.48"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/node": "^20.0.0",
|