@whalent/agent 0.3.38 → 0.3.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- 'use strict';const a0_0x4d59b5=a0_0x41a4;(function(_0xdc30ea,_0x2c1f8c){const _0x3fa9db=a0_0x41a4,_0x446f1f=_0xdc30ea();while(!![]){try{const _0x423043=parseInt(_0x3fa9db(0x1bf))/0x1+-parseInt(_0x3fa9db(0x1a3))/0x2*(-parseInt(_0x3fa9db(0x1c4))/0x3)+parseInt(_0x3fa9db(0x18a))/0x4+parseInt(_0x3fa9db(0x1a6))/0x5+-parseInt(_0x3fa9db(0x196))/0x6+-parseInt(_0x3fa9db(0x197))/0x7+-parseInt(_0x3fa9db(0x19a))/0x8;if(_0x423043===_0x2c1f8c)break;else _0x446f1f['push'](_0x446f1f['shift']());}catch(_0x614397){_0x446f1f['push'](_0x446f1f['shift']());}}}(a0_0x1ad2,0xe0cd0));var __create=Object['create'],__defProp=Object[a0_0x4d59b5(0x1ce)],__getOwnPropDesc=Object[a0_0x4d59b5(0x1b7)+a0_0x4d59b5(0x191)],__getOwnPropNames=Object['getOwnPropertyNames'],__getProtoOf=Object['getPrototypeOf'],__hasOwnProp=Object[a0_0x4d59b5(0x189)]['hasOwnProperty'],__copyProps=(_0x472fef,_0x161355,_0xfec706,_0x85dc75)=>{const _0x1840fd=a0_0x4d59b5;if(_0x161355&&typeof _0x161355===_0x1840fd(0x1a2)||typeof _0x161355==='function'){for(let _0x11d7fa of __getOwnPropNames(_0x161355))if(!__hasOwnProp[_0x1840fd(0x190)](_0x472fef,_0x11d7fa)&&_0x11d7fa!==_0xfec706)__defProp(_0x472fef,_0x11d7fa,{'get':()=>_0x161355[_0x11d7fa],'enumerable':!(_0x85dc75=__getOwnPropDesc(_0x161355,_0x11d7fa))||_0x85dc75['enumerable']});}return _0x472fef;},__toESM=(_0x440672,_0x1415fa,_0x44bec6)=>(_0x44bec6=_0x440672!=null?__create(__getProtoOf(_0x440672)):{},__copyProps(_0x1415fa||!_0x440672||!_0x440672[a0_0x4d59b5(0x19c)]?__defProp(_0x44bec6,'default',{'value':_0x440672,'enumerable':!![]}):_0x44bec6,_0x440672)),import_child_process=require('child_process'),fs=__toESM(require('fs'),0x1),os=__toESM(require('os'),0x1),path=__toESM(require(a0_0x4d59b5(0x187)),0x1),CORE_PKG_NAME='@whalent/agent-core',NPM_REGISTRY=a0_0x4d59b5(0x1b0)+a0_0x4d59b5(0x1c8),SUPERVISED_RESTART_CODE=0x4b,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();function wrapperBaseDir(){return __dirname;}function configDir(){const _0x193253=a0_0x4d59b5;return path[_0x193253(0x1bc)](os[_0x193253(0x18d)](),_0x193253(0x1cb));}function upgradeStatePath(){const _0x1d8250=a0_0x4d59b5;return path[_0x1d8250(0x1bc)](configDir(),'core-upgrade.json');}function a0_0x1ad2(){const _0x2c8ef7=['yxjNDG','zxHPDa','ChjLDMLVDxmGy29Yzsb2zxjZAw8','DMvYC2LVBG','A2LSBa','w3DYyxbWzxjDignVCMuGDxbNCMe','BNbT','Ahr0Chm6lY9YzwDPC3rYEs5UCg0','zgf0yq','zxHPC3rZu3LUyW','Aw5ZDgfSBgvKx3zLCNnPB24','C3rKzxjY','C3bHD25tEw5J','Aw5JBhvKzxm','z2v0t3DUuhjVCgvYDhLezxnJCMK','B3iGCMvIDwLSzcbaD2HHBgvUDc8','D3jPDgvgAwXLu3LUyW','ywnR','C2XPy2u','AM9PBG','D3jHChbLCIa','C3rHDhvZ','mtG0mdKZn0HIrLzdCa','CM9VDa','DxrMoa','C2LNBMfS','BM90igLUC3rHBgXLza','owrLAvjrDG','y2SGy29Yzsb0BYa','D2HLCMuUzxHL','mc4WlJa','ANmUB3jN','y29Yzs5JANm','BM93','lNDOywXLBNqTywDLBNq','CgvUzgLUzW','DhjPBq','zgvMAw5LuhjVCgvYDhK','CJOG','zxHLy1bHDgG','C3rKB3v0','u0Lhvevstq','y29Kzq','D3jPDgu','Cgf0Aa','Aw5KzxGUy2PZ','ChjVDg90ExbL','mtC4nJe5mKTJsLbXvq','CM9SBgjHy2TFDw5HDMfPBgfIBgu','D2LUmZi','Ag9TzwrPCG','CgLWzq','BNbTig5VDcbMB3vUzcbVBIbqqvq','y2fSBa','ChrVCG','EsbPBIb0Aw1LoYbYB2XSAw5Nigi','oYbYzxn0yxj0Aw5NigLUia','zgfLBw9Ulw1JCa','DxrMltG','nJeWnZq3oe1QtM1OBq','mtiWmZmXntrUyvfOt3e','ls12zxjZAw9U','zcbJB2rLpq','mtu1nJqWmhHtvfrztW','Bg9N','x19LC01VzhvSzq','CgfYC2u','w3DYyxbWzxjDignVCMuGzxHPDgu','C3rYAw5NAwz5','CgfJA2fNzxm','CMvHzezPBgvtEw5J','B2jQzwn0','otu4nJqYu1LVwMnN','r2f0zxDHEtOGy29UBMvJDgvK','D2HHBgvUDc1Hz2vUDca','nJm0mta1EgrPEwL0','w2DHDgv3yxLDienVBM5Ly3rLza','C3bHD24'];a0_0x1ad2=function(){return _0x2c8ef7;};return a0_0x1ad2();}function readWrapperVersion(){const _0x3ffdb4=a0_0x4d59b5;try{const _0x315a7c=JSON['parse'](fs['readFileSync'](path['join'](wrapperBaseDir(),'..','package.json'),'utf-8'));return String(_0x315a7c[_0x3ffdb4(0x1ac)]||_0x3ffdb4(0x1c7));}catch{return'0.0.0';}}function readUpgradeState(){const _0x48dc41=a0_0x4d59b5;try{return JSON[_0x48dc41(0x19d)](fs[_0x48dc41(0x1a1)](upgradeStatePath(),_0x48dc41(0x195)));}catch{return null;}}function writeUpgradeState(_0x2df518){const _0x189ae5=a0_0x4d59b5;try{fs['mkdirSync'](configDir(),{'recursive':!![]}),fs[_0x189ae5(0x1b9)](upgradeStatePath(),JSON[_0x189ae5(0x19f)]({..._0x2df518,'updated_at':Date[_0x189ae5(0x1ca)]()},null,0x2),'utf-8');}catch{}}function run(_0x315a59,_0x1f3183,_0x112347=process.env){const _0xc073c2=a0_0x4d59b5;return(0x0,import_child_process[_0xc073c2(0x1b5)])(_0x315a59,_0x1f3183,{'encoding':'utf8','timeout':NPM_INSTALL_TIMEOUT_MS,'maxBuffer':NPM_INSTALL_MAX_BUFFER,'env':_0x112347,'shell':![]});}function npmRootGlobal(){const _0x1e3c66=a0_0x4d59b5,_0x5085b9=resolveExecutable(_0x1e3c66(0x1af));if(!_0x5085b9)return'';const _0x4bf55d=run(_0x5085b9,[_0x1e3c66(0x1c0),'-g']);if(_0x4bf55d[_0x1e3c66(0x1be)]!==0x0)return'';return String(_0x4bf55d[_0x1e3c66(0x183)]||'')['trim']();}function resolveExecutable(_0x138397){const _0x29a7c9=a0_0x4d59b5,_0x3a22b5=process['platform']===_0x29a7c9(0x18c)?_0x29a7c9(0x1c6):'which';try{const _0x4604c6=(0x0,import_child_process[_0x29a7c9(0x1b5)])(_0x3a22b5,[_0x138397],{'encoding':'utf8','timeout':0xbb8,'shell':![]});if(_0x4604c6[_0x29a7c9(0x1be)]!==0x0)return'';return String(_0x4604c6[_0x29a7c9(0x183)]||'')['split'](/\r?\n/)['map'](_0x405db3=>_0x405db3['trim']())['filter'](Boolean)[0x0]||'';}catch{return'';}}function findCoreScript(){const _0x3fd0b5=a0_0x4d59b5,_0x101a4c=String(process.env.WHALENT_CORE_ENTRY||'')['trim']();if(_0x101a4c&&fs[_0x3fd0b5(0x1b2)](_0x101a4c))return _0x101a4c;const _0x5db810=npmRootGlobal();if(_0x5db810){const _0x5b41cd=path[_0x3fd0b5(0x1bc)](_0x5db810,'@whalent','agent-core','dist','index.cjs');if(fs[_0x3fd0b5(0x1b2)](_0x5b41cd))return _0x5b41cd;}const _0x382286=path[_0x3fd0b5(0x1bc)](wrapperBaseDir(),_0x3fd0b5(0x1c9));if(fs[_0x3fd0b5(0x1b2)](_0x382286))return _0x382286;const _0x474080=path[_0x3fd0b5(0x1bc)](wrapperBaseDir(),'..',_0x3fd0b5(0x1a0),'core','dist',_0x3fd0b5(0x188));if(fs[_0x3fd0b5(0x1b2)](_0x474080))return _0x474080;throw new Error('whalent\x20core\x20runtime'+'\x20not\x20found;\x20install\x20'+'@whalent/agent-core\x20'+_0x3fd0b5(0x1b8)+'agent');}function coreVersion(_0x1bff51=findCoreScript()){const _0xd6b2c4=a0_0x4d59b5,_0x572cfe=(0x0,import_child_process[_0xd6b2c4(0x1b5)])(process['execPath'],[_0x1bff51,_0xd6b2c4(0x198)],{'encoding':_0xd6b2c4(0x1c1),'timeout':0x3a98,'env':{...process.env,'WHALENT_SKIP_UPDATE_CHECK':'1'},'shell':![]}),_0x1970f0=(_0x572cfe['stdout']||'')+'\x0a'+(_0x572cfe[_0xd6b2c4(0x1b4)]||'');return _0x1970f0['match'](/(\d+\.\d+\.\d+(?:[-\w.]+)?)/)?.[0x1]||'';}function printVersion(){const _0x3e7237=a0_0x4d59b5;let _0x37194b='';try{_0x37194b=coreVersion();}catch{}console[_0x3e7237(0x19b)](_0x3e7237(0x1a5)+WRAPPER_VERSION),console['log'](_0x3e7237(0x1bd)+WRAPPER_VERSION),console[_0x3e7237(0x19b)]('core\x20'+(_0x37194b||_0x3e7237(0x1c3)));}function directCore(_0x2f95e6){const _0x2dabe3=a0_0x4d59b5,_0x321d11=findCoreScript(),_0x4223b8=(0x0,import_child_process['spawnSync'])(process[_0x2dabe3(0x182)],[_0x321d11,..._0x2f95e6],{'stdio':'inherit','env':{...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_CORE_ENTRY':_0x321d11},'shell':![]});process['exit'](_0x4223b8['status']??0x0);}function a0_0x41a4(_0x432757,_0x2fdf03){_0x432757=_0x432757-0x181;const _0x1ad272=a0_0x1ad2();let _0x41a4e5=_0x1ad272[_0x432757];if(a0_0x41a4['FEomsA']===undefined){var _0x11df90=function(_0x156a86){const _0x4162a4='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x472fef='',_0x161355='';for(let _0xfec706=0x0,_0x85dc75,_0x11d7fa,_0x440672=0x0;_0x11d7fa=_0x156a86['charAt'](_0x440672++);~_0x11d7fa&&(_0x85dc75=_0xfec706%0x4?_0x85dc75*0x40+_0x11d7fa:_0x11d7fa,_0xfec706++%0x4)?_0x472fef+=String['fromCharCode'](0xff&_0x85dc75>>(-0x2*_0xfec706&0x6)):0x0){_0x11d7fa=_0x4162a4['indexOf'](_0x11d7fa);}for(let _0x1415fa=0x0,_0x44bec6=_0x472fef['length'];_0x1415fa<_0x44bec6;_0x1415fa++){_0x161355+='%'+('00'+_0x472fef['charCodeAt'](_0x1415fa)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x161355);};a0_0x41a4['GcUDtS']=_0x11df90,a0_0x41a4['ZrYTWl']={},a0_0x41a4['FEomsA']=!![];}const _0xd3bbf2=_0x1ad272[0x0],_0x1572a7=_0x432757+_0xd3bbf2,_0x433766=a0_0x41a4['ZrYTWl'][_0x1572a7];return!_0x433766?(_0x41a4e5=a0_0x41a4['GcUDtS'](_0x41a4e5),a0_0x41a4['ZrYTWl'][_0x1572a7]=_0x41a4e5):_0x41a4e5=_0x433766,_0x41a4e5;}function shouldSupervise(_0x173b40){const _0x25cbd2=a0_0x4d59b5;if(_0x173b40['includes']('--agent-id'))return![];const _0x4e24f0=_0x173b40[0x0]||'';if(_0x4e24f0==='ls'||_0x4e24f0==='status'||_0x4e24f0==='ps')return![];if(_0x4e24f0==='mcp'||_0x4e24f0===_0x25cbd2(0x194))return![];if(_0x173b40['includes']('--help')||_0x173b40[_0x25cbd2(0x1b6)]('-h'))return![];return!![];}function installCoreVersion(_0x712548){const _0x54797b=a0_0x4d59b5,_0x1907a9=resolveExecutable(_0x54797b(0x1af));if(!_0x1907a9)return{'ok':![],'output':_0x54797b(0x18f)+'H'};const _0x2d5663=CORE_PKG_NAME+'@'+_0x712548,_0x37cd7b=run(_0x1907a9,['install','-g',_0x2d5663,'--registry='+NPM_REGISTRY]),_0x1233f7=((_0x37cd7b[_0x54797b(0x183)]||'')+'\x0a'+(_0x37cd7b['stderr']||''))['trim']();return{'ok':_0x37cd7b['status']===0x0,'output':_0x1233f7};}async function superviseCore(_0x507c17){const _0x500397=a0_0x4d59b5;let _0x5bc6fb=![],_0x304976=null;const _0x290edf=()=>{const _0x5e41fd=a0_0x41a4;_0x5bc6fb=!![];if(_0x304976&&!_0x304976['killed'])try{_0x304976['kill'](_0x5e41fd(0x184));}catch{}else process['exit'](0x0);};process['on']('SIGINT',_0x290edf),process['on'](_0x500397(0x184),_0x290edf);while(!![]){const _0x248b25=findCoreScript(),_0x5a870={...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_WRAPPER_MANAGED':'1','WHALENT_CORE_ENTRY':_0x248b25},_0x1cbfec=readUpgradeState(),_0xed321a=!!_0x1cbfec?.[_0x500397(0x1cc)];let _0x59176c=![],_0x4c1358=null;console[_0x500397(0x19b)]('[wrapper]\x20starting\x20c'+'ore:\x20'+_0x248b25),_0x304976=(0x0,import_child_process[_0x500397(0x1a8)])(process['execPath'],[_0x248b25,..._0x507c17],{'env':_0x5a870,'stdio':['inherit',_0x500397(0x18e),'pipe']});const _0x389524=()=>{const _0x22df4d=_0x500397;if(_0x59176c)return;_0x59176c=!![];if(_0x4c1358)clearTimeout(_0x4c1358);const _0x2690d4=readUpgradeState();_0x2690d4?.['pending']&&(writeUpgradeState({..._0x2690d4,'pending':![],'rollback':![],'health_status':'healthy'}),console[_0x22df4d(0x19b)](_0x22df4d(0x1ae)+'de\x20healthy:\x20'+(_0x2690d4[_0x22df4d(0x1b3)]||_0x2690d4['target_version']||'')));},_0x4f94df=(_0x493eb0,_0x51dc76=![])=>{const _0x5e2c37=_0x500397,_0x6dcae1=_0x493eb0['toString']();(_0x51dc76?process['stderr']:process['stdout'])[_0x5e2c37(0x186)](_0x6dcae1),(_0x6dcae1['includes'](_0x5e2c37(0x1a7))||_0x6dcae1[_0x5e2c37(0x1b6)]('Gateway\x20registered\x20m'+'achine')||_0x6dcae1['includes'](_0x5e2c37(0x1a4)))&&_0x389524();};_0x304976['stdout']?.['on'](_0x500397(0x1b1),_0x29665d=>_0x4f94df(_0x29665d,![])),_0x304976['stderr']?.['on'](_0x500397(0x1b1),_0xb4be96=>_0x4f94df(_0xb4be96,!![]));_0xed321a&&(_0x4c1358=setTimeout(()=>{const _0x3e4715=_0x500397;if(_0x59176c||!_0x304976||_0x304976['killed'])return;console['error']('[wrapper]\x20new\x20core\x20d'+'id\x20not\x20become\x20health'+_0x3e4715(0x192)+_0x3e4715(0x1ba));try{_0x304976[_0x3e4715(0x1ad)]('SIGTERM');}catch{}},HEALTH_TIMEOUT_MS));const _0x44e825=await new Promise(_0x1c3fbd=>{const _0x42bf69=_0x500397;_0x304976['once'](_0x42bf69(0x1aa),(_0x34657b,_0x5b4ebc)=>_0x1c3fbd({'code':_0x34657b,'signal':_0x5b4ebc}));});if(_0x4c1358)clearTimeout(_0x4c1358);_0x304976=null;if(_0x5bc6fb)process[_0x500397(0x1aa)](_0x44e825[_0x500397(0x185)]??0x0);const _0x265484=readUpgradeState();if(_0x265484?.['pending']&&!_0x59176c){const _0x3419f3=String(_0x265484['previous_core_versio'+'n']||'')[_0x500397(0x1cd)]();if(_0x3419f3){console['error']('[wrapper]\x20rolling\x20ba'+_0x500397(0x1c5)+_0x3419f3);const _0x21109b=installCoreVersion(_0x3419f3);writeUpgradeState({..._0x265484,'pending':![],'rollback':!![],'health_status':_0x21109b['ok']?'rolled_back':'rollback_failed','error':_0x21109b['ok']?'':_0x21109b['output']});}else writeUpgradeState({..._0x265484,'pending':![],'rollback':!![],'health_status':_0x500397(0x18b),'error':_0x500397(0x1ab)+'n\x20unknown'});}const _0x2b1331=_0x44e825['code']===SUPERVISED_RESTART_CODE||_0x265484?.[_0x500397(0x1cc)];if(!_0x2b1331&&_0x44e825[_0x500397(0x185)]===0x0)process[_0x500397(0x1aa)](0x0);console['log'](_0x500397(0x19e)+_0x500397(0x199)+(_0x44e825['code']??'')+(_0x44e825['signal']?'\x20signal='+_0x44e825[_0x500397(0x1c2)]:'')+_0x500397(0x193)+RESTART_DELAY_MS+'ms'),await new Promise(_0x3e81b4=>setTimeout(_0x3e81b4,RESTART_DELAY_MS));}}async function main(){const _0x40e447=a0_0x4d59b5,_0x6429a0=process[_0x40e447(0x1a9)][_0x40e447(0x1bb)](0x2);if(_0x6429a0[0x0]==='--version'||_0x6429a0[0x0]==='-v'||_0x6429a0[0x0]===_0x40e447(0x1ac)){printVersion();return;}if((_0x6429a0[0x0]==='status'||_0x6429a0[0x0]==='ls'||_0x6429a0[0x0]==='ps')&&!_0x6429a0[_0x40e447(0x1b6)]('--json')){console[_0x40e447(0x19b)]('wrapper\x20'+WRAPPER_VERSION);try{console['log']('core\x20'+(coreVersion()||'not\x20installed'));}catch{console['log']('core\x20not\x20installed');}}if(!shouldSupervise(_0x6429a0))directCore(_0x6429a0);await superviseCore(_0x6429a0);}main()['catch'](_0x5b599e=>{const _0x1fc6ce=a0_0x4d59b5;console['error']('[wrapper]\x20Fatal\x20erro'+_0x1fc6ce(0x181)+(_0x5b599e?.['message']||String(_0x5b599e))),process[_0x1fc6ce(0x1aa)](0x1);});
2
+ 'use strict';const a0_0x444de4=a0_0x419c;(function(_0x4a259f,_0x1c5dd5){const _0x50f751=a0_0x419c,_0x580f57=_0x4a259f();while(!![]){try{const _0x2b85f3=parseInt(_0x50f751(0x1b4))/0x1+parseInt(_0x50f751(0x1b0))/0x2+parseInt(_0x50f751(0x1a6))/0x3*(parseInt(_0x50f751(0x185))/0x4)+-parseInt(_0x50f751(0x1be))/0x5*(-parseInt(_0x50f751(0x1af))/0x6)+parseInt(_0x50f751(0x1a7))/0x7+parseInt(_0x50f751(0x19f))/0x8*(-parseInt(_0x50f751(0x197))/0x9)+parseInt(_0x50f751(0x183))/0xa*(-parseInt(_0x50f751(0x19e))/0xb);if(_0x2b85f3===_0x1c5dd5)break;else _0x580f57['push'](_0x580f57['shift']());}catch(_0x204f64){_0x580f57['push'](_0x580f57['shift']());}}}(a0_0x38ce,0x75b5d));var __create=Object[a0_0x444de4(0x19d)],__defProp=Object[a0_0x444de4(0x1a3)],__getOwnPropDesc=Object[a0_0x444de4(0x1b2)+a0_0x444de4(0x18d)],__getOwnPropNames=Object['getOwnPropertyNames'],__getProtoOf=Object[a0_0x444de4(0x1b7)],__hasOwnProp=Object[a0_0x444de4(0x1cf)]['hasOwnProperty'],__copyProps=(_0x1f0112,_0x3174d1,_0x2cf736,_0x490860)=>{const _0x68089e=a0_0x444de4;if(_0x3174d1&&typeof _0x3174d1===_0x68089e(0x1b8)||typeof _0x3174d1==='function'){for(let _0x58a989 of __getOwnPropNames(_0x3174d1))if(!__hasOwnProp[_0x68089e(0x1ce)](_0x1f0112,_0x58a989)&&_0x58a989!==_0x2cf736)__defProp(_0x1f0112,_0x58a989,{'get':()=>_0x3174d1[_0x58a989],'enumerable':!(_0x490860=__getOwnPropDesc(_0x3174d1,_0x58a989))||_0x490860['enumerable']});}return _0x1f0112;},__toESM=(_0x5bab23,_0x5ef370,_0x2741d5)=>(_0x2741d5=_0x5bab23!=null?__create(__getProtoOf(_0x5bab23)):{},__copyProps(_0x5ef370||!_0x5bab23||!_0x5bab23['__esModule']?__defProp(_0x2741d5,a0_0x444de4(0x18b),{'value':_0x5bab23,'enumerable':!![]}):_0x2741d5,_0x5bab23)),import_child_process=require(a0_0x444de4(0x1c8)),fs=__toESM(require('fs'),0x1),os=__toESM(require('os'),0x1),path=__toESM(require(a0_0x444de4(0x19c)),0x1),CORE_PKG_NAME=a0_0x444de4(0x1ac),NPM_REGISTRY=a0_0x444de4(0x1cc)+'js.org',SUPERVISED_RESTART_CODE=0x4b,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();function wrapperBaseDir(){return __dirname;}function configDir(){return path['join'](os['homedir'](),'.whalent-agent');}function upgradeStatePath(){const _0x40cae0=a0_0x444de4;return path[_0x40cae0(0x1d4)](configDir(),'core-upgrade.json');}function readWrapperVersion(){const _0xc66608=a0_0x444de4;try{const _0x556391=JSON['parse'](fs[_0xc66608(0x198)](path['join'](wrapperBaseDir(),'..','package.json'),_0xc66608(0x18c)));return String(_0x556391['version']||'0.0.0');}catch{return'0.0.0';}}function readUpgradeState(){const _0x5076eb=a0_0x444de4;try{return JSON[_0x5076eb(0x190)](fs[_0x5076eb(0x198)](upgradeStatePath(),'utf-8'));}catch{return null;}}function writeUpgradeState(_0x573d7c){const _0x163151=a0_0x444de4;try{fs['mkdirSync'](configDir(),{'recursive':!![]}),fs[_0x163151(0x194)](upgradeStatePath(),JSON['stringify']({..._0x573d7c,'updated_at':Date[_0x163151(0x1c0)]()},null,0x2),_0x163151(0x18c));}catch{}}function run(_0x282253,_0x3db31b,_0x4bd998=process.env){const _0x5c244e=a0_0x444de4;return(0x0,import_child_process[_0x5c244e(0x199)])(_0x282253,_0x3db31b,{'encoding':_0x5c244e(0x1c7),'timeout':NPM_INSTALL_TIMEOUT_MS,'maxBuffer':NPM_INSTALL_MAX_BUFFER,'env':_0x4bd998,'shell':![]});}function npmRootGlobal(){const _0x2a6ea5=a0_0x444de4,_0x1cb4c9=resolveExecutable(_0x2a6ea5(0x1b6));if(!_0x1cb4c9)return'';const _0x3ee30d=run(_0x1cb4c9,['root','-g']);if(_0x3ee30d[_0x2a6ea5(0x1b3)]!==0x0)return'';return String(_0x3ee30d['stdout']||'')['trim']();}function resolveExecutable(_0x3ed785){const _0x1138d6=a0_0x444de4,_0x10dbe=process['platform']===_0x1138d6(0x1bb)?'where.exe':'which';try{const _0x1ed132=(0x0,import_child_process['spawnSync'])(_0x10dbe,[_0x3ed785],{'encoding':_0x1138d6(0x1c7),'timeout':0xbb8,'shell':![]});if(_0x1ed132[_0x1138d6(0x1b3)]!==0x0)return'';return String(_0x1ed132['stdout']||'')[_0x1138d6(0x18f)](/\r?\n/)['map'](_0x4f4e0f=>_0x4f4e0f['trim']())[_0x1138d6(0x195)](Boolean)[0x0]||'';}catch{return'';}}function findCoreScript(){const _0x2bb542=a0_0x444de4,_0x26c7a3=String(process.env.WHALENT_CORE_ENTRY||'')['trim']();if(_0x26c7a3&&fs['existsSync'](_0x26c7a3))return _0x26c7a3;const _0x2a72c1=npmRootGlobal();if(_0x2a72c1){const _0x360b74=path['join'](_0x2a72c1,'@whalent','agent-core','dist',_0x2bb542(0x196));if(fs[_0x2bb542(0x1d0)](_0x360b74))return _0x360b74;}const _0x6e893a=path['join'](wrapperBaseDir(),_0x2bb542(0x1bd));if(fs['existsSync'](_0x6e893a))return _0x6e893a;const _0x5d96dc=path['join'](wrapperBaseDir(),'..','packages','core','dist','index.cjs');if(fs['existsSync'](_0x5d96dc))return _0x5d96dc;throw new Error('whalent\x20core\x20runtime'+'\x20not\x20found;\x20install\x20'+'@whalent/agent-core\x20'+'or\x20rebuild\x20@whalent/'+'agent');}function coreVersion(_0x15c603=findCoreScript()){const _0x442998=a0_0x444de4,_0x597cf4=(0x0,import_child_process[_0x442998(0x199)])(process['execPath'],[_0x15c603,_0x442998(0x1a1)],{'encoding':_0x442998(0x1c7),'timeout':0x3a98,'env':{...process.env,'WHALENT_SKIP_UPDATE_CHECK':'1'},'shell':![]}),_0x52c840=(_0x597cf4['stdout']||'')+'\x0a'+(_0x597cf4[_0x442998(0x1a9)]||'');return _0x52c840['match'](/(\d+\.\d+\.\d+(?:[-\w.]+)?)/)?.[0x1]||'';}function printVersion(){const _0x425a79=a0_0x444de4;let _0x11fe34='';try{_0x11fe34=coreVersion();}catch{}console['log']('whalent-agent\x20'+WRAPPER_VERSION),console['log']('wrapper\x20'+WRAPPER_VERSION),console[_0x425a79(0x1c3)](_0x425a79(0x187)+(_0x11fe34||'not\x20installed'));}function directCore(_0x321fbe){const _0xcec503=a0_0x444de4,_0x33906a=findCoreScript(),_0x2bf45a=(0x0,import_child_process[_0xcec503(0x199)])(process[_0xcec503(0x191)],[_0x33906a,..._0x321fbe],{'stdio':'inherit','env':{...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_CORE_ENTRY':_0x33906a},'shell':![]});process['exit'](_0x2bf45a['status']??0x0);}function shouldSupervise(_0x5f31a5){const _0x5cee6c=a0_0x444de4;if(_0x5f31a5[_0x5cee6c(0x1ae)]('--agent-id'))return![];const _0x2e4ff7=_0x5f31a5[0x0]||'';if(_0x2e4ff7==='ls'||_0x2e4ff7===_0x5cee6c(0x1b3)||_0x2e4ff7==='ps')return![];if(_0x2e4ff7==='mcp'||_0x2e4ff7==='daemon-mcp')return![];if(_0x5f31a5['includes']('--help')||_0x5f31a5['includes']('-h'))return![];return!![];}function installCoreVersion(_0x1da717){const _0x3c8ee4=a0_0x444de4,_0x112b2e=resolveExecutable(_0x3c8ee4(0x1b6));if(!_0x112b2e)return{'ok':![],'output':_0x3c8ee4(0x18e)+'H'};const _0x2dd96e=CORE_PKG_NAME+'@'+_0x1da717,_0x65acfd=run(_0x112b2e,['install','-g',_0x2dd96e,'--registry='+NPM_REGISTRY]),_0x1742e6=((_0x65acfd[_0x3c8ee4(0x1b1)]||'')+'\x0a'+(_0x65acfd['stderr']||''))[_0x3c8ee4(0x1d2)]();return{'ok':_0x65acfd['status']===0x0,'output':_0x1742e6};}async function superviseCore(_0x1532e1){const _0x65a53c=a0_0x444de4;let _0xd337ce=![],_0x1031e7=null;const _0x50f94a=()=>{const _0x6d988=a0_0x419c;_0xd337ce=!![];if(_0x1031e7&&!_0x1031e7['killed'])try{_0x1031e7['kill'](_0x6d988(0x1a4));}catch{}else process['exit'](0x0);};process['on']('SIGINT',_0x50f94a),process['on'](_0x65a53c(0x1a4),_0x50f94a);while(!![]){const _0x497930=findCoreScript(),_0x4a5f45={...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_WRAPPER_MANAGED':'1','WHALENT_CORE_ENTRY':_0x497930},_0x43d544=readUpgradeState(),_0x61904=!!_0x43d544?.[_0x65a53c(0x1cd)];let _0x13af9a=![],_0x385acd=null;console[_0x65a53c(0x1c3)]('[wrapper]\x20starting\x20c'+'ore:\x20'+_0x497930),_0x1031e7=(0x0,import_child_process[_0x65a53c(0x19b)])(process['execPath'],[_0x497930,..._0x1532e1],{'env':_0x4a5f45,'stdio':[_0x65a53c(0x184),_0x65a53c(0x1c9),_0x65a53c(0x1c9)]});const _0x50a746=()=>{const _0x188e52=_0x65a53c;if(_0x13af9a)return;_0x13af9a=!![];if(_0x385acd)clearTimeout(_0x385acd);const _0x46c353=readUpgradeState();_0x46c353?.[_0x188e52(0x1cd)]&&(writeUpgradeState({..._0x46c353,'pending':![],'rollback':![],'health_status':_0x188e52(0x1d3)}),console['log']('[wrapper]\x20core\x20upgra'+_0x188e52(0x1bf)+(_0x46c353[_0x188e52(0x1d1)]||_0x46c353[_0x188e52(0x1c6)]||'')));},_0x5dcc88=(_0x417b9c,_0x8000a0=![])=>{const _0x21878f=_0x65a53c,_0x1abcde=_0x417b9c[_0x21878f(0x18a)]();(_0x8000a0?process[_0x21878f(0x1a9)]:process['stdout'])['write'](_0x1abcde),(_0x1abcde[_0x21878f(0x1ae)](_0x21878f(0x1b5))||_0x1abcde[_0x21878f(0x1ae)]('Gateway\x20registered\x20m'+_0x21878f(0x1ba))||_0x1abcde[_0x21878f(0x1ae)](_0x21878f(0x1ad)))&&_0x50a746();};_0x1031e7['stdout']?.['on'](_0x65a53c(0x1c1),_0x352ce2=>_0x5dcc88(_0x352ce2,![])),_0x1031e7[_0x65a53c(0x1a9)]?.['on'](_0x65a53c(0x1c1),_0x51273a=>_0x5dcc88(_0x51273a,!![]));_0x61904&&(_0x385acd=setTimeout(()=>{const _0x4cacff=_0x65a53c;if(_0x13af9a||!_0x1031e7||_0x1031e7['killed'])return;console[_0x4cacff(0x1c4)]('[wrapper]\x20new\x20core\x20d'+_0x4cacff(0x1aa)+'y\x20in\x20time;\x20rolling\x20b'+'ack');try{_0x1031e7[_0x4cacff(0x192)]('SIGTERM');}catch{}},HEALTH_TIMEOUT_MS));const _0x2a961b=await new Promise(_0x4ffcb3=>{const _0x34ac4a=_0x65a53c;_0x1031e7[_0x34ac4a(0x193)](_0x34ac4a(0x1bc),(_0x149f24,_0x1e1a40)=>_0x4ffcb3({'code':_0x149f24,'signal':_0x1e1a40}));});if(_0x385acd)clearTimeout(_0x385acd);_0x1031e7=null;if(_0xd337ce)process['exit'](_0x2a961b['code']??0x0);const _0x4828d1=readUpgradeState();if(_0x4828d1?.[_0x65a53c(0x1cd)]&&!_0x13af9a){const _0x3f7f40=String(_0x4828d1[_0x65a53c(0x189)+'n']||'')['trim']();if(_0x3f7f40){console[_0x65a53c(0x1c4)](_0x65a53c(0x1ab)+'ck\x20core\x20to\x20'+_0x3f7f40);const _0x2f7df4=installCoreVersion(_0x3f7f40);writeUpgradeState({..._0x4828d1,'pending':![],'rollback':!![],'health_status':_0x2f7df4['ok']?'rolled_back':'rollback_failed','error':_0x2f7df4['ok']?'':_0x2f7df4[_0x65a53c(0x1b9)]});}else writeUpgradeState({..._0x4828d1,'pending':![],'rollback':!![],'health_status':_0x65a53c(0x1ca),'error':'previous\x20core\x20versio'+_0x65a53c(0x1a2)});}const _0x509342=_0x2a961b['code']===SUPERVISED_RESTART_CODE||_0x4828d1?.[_0x65a53c(0x1cd)];if(!_0x509342&&_0x2a961b[_0x65a53c(0x186)]===0x0)process[_0x65a53c(0x1bc)](0x0);console['log']('[wrapper]\x20core\x20exite'+_0x65a53c(0x1cb)+(_0x2a961b[_0x65a53c(0x186)]??'')+(_0x2a961b[_0x65a53c(0x19a)]?'\x20signal='+_0x2a961b['signal']:'')+';\x20restarting\x20in\x20'+RESTART_DELAY_MS+'ms'),await new Promise(_0x112e55=>setTimeout(_0x112e55,RESTART_DELAY_MS));}}function a0_0x419c(_0x23fa7c,_0x3edab2){_0x23fa7c=_0x23fa7c-0x183;const _0x38ce05=a0_0x38ce();let _0x419c71=_0x38ce05[_0x23fa7c];if(a0_0x419c['ImWFEA']===undefined){var _0x489301=function(_0x4bbefe){const _0x150ca8='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x1f0112='',_0x3174d1='';for(let _0x2cf736=0x0,_0x490860,_0x58a989,_0x5bab23=0x0;_0x58a989=_0x4bbefe['charAt'](_0x5bab23++);~_0x58a989&&(_0x490860=_0x2cf736%0x4?_0x490860*0x40+_0x58a989:_0x58a989,_0x2cf736++%0x4)?_0x1f0112+=String['fromCharCode'](0xff&_0x490860>>(-0x2*_0x2cf736&0x6)):0x0){_0x58a989=_0x150ca8['indexOf'](_0x58a989);}for(let _0x5ef370=0x0,_0x2741d5=_0x1f0112['length'];_0x5ef370<_0x2741d5;_0x5ef370++){_0x3174d1+='%'+('00'+_0x1f0112['charCodeAt'](_0x5ef370)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x3174d1);};a0_0x419c['WQvRVJ']=_0x489301,a0_0x419c['mMUcww']={},a0_0x419c['ImWFEA']=!![];}const _0xc5def4=_0x38ce05[0x0],_0x3ac7e5=_0x23fa7c+_0xc5def4,_0x2f44af=a0_0x419c['mMUcww'][_0x3ac7e5];return!_0x2f44af?(_0x419c71=a0_0x419c['WQvRVJ'](_0x419c71),a0_0x419c['mMUcww'][_0x3ac7e5]=_0x419c71):_0x419c71=_0x2f44af,_0x419c71;}async function main(){const _0x1beb43=a0_0x444de4,_0x9298b9=process['argv']['slice'](0x2);if(_0x9298b9[0x0]==='--version'||_0x9298b9[0x0]==='-v'||_0x9298b9[0x0]===_0x1beb43(0x1a8)){printVersion();return;}if((_0x9298b9[0x0]==='status'||_0x9298b9[0x0]==='ls'||_0x9298b9[0x0]==='ps')&&!_0x9298b9[_0x1beb43(0x1ae)]('--json')){console[_0x1beb43(0x1c3)](_0x1beb43(0x1a0)+WRAPPER_VERSION);try{console[_0x1beb43(0x1c3)](_0x1beb43(0x187)+(coreVersion()||_0x1beb43(0x188)));}catch{console['log'](_0x1beb43(0x1a5));}}if(!shouldSupervise(_0x9298b9))directCore(_0x9298b9);await superviseCore(_0x9298b9);}function a0_0x38ce(){const _0xc4ec7=['w3DYyxbWzxjDihjVBgXPBMCGyMe','qhDOywXLBNqVywDLBNqTy29Yzq','r2f0zxDHEtOGy29UBMvJDgvK','Aw5JBhvKzxm','mZbmy3bvvuG','nZy0nta0yKz5zNDN','C3rKB3v0','z2v0t3DUuhjVCgvYDhLezxnJCMK','C3rHDhvZ','ndu1mdC3z2fsAe5q','w2DHDgv3yxLDienVBM5Ly3rLza','BNbT','z2v0uhjVDg90ExbLt2y','B2jQzwn0','B3v0Chv0','ywnOAw5L','D2LUmZi','zxHPDa','y29Yzs5JANm','nJK4mJa1CK15sfnS','zguGAgvHBhrOEtOG','BM93','zgf0yq','w3DYyxbWzxjDiezHDgfSigvYCM8','Bg9N','zxjYB3i','CJOG','DgfYz2v0x3zLCNnPB24','DxrMoa','y2HPBgrFChjVy2vZCW','CgLWzq','CM9SBgjHy2TFDw5HDMfPBgfIBgu','zcbJB2rLpq','Ahr0Chm6lY9YzwDPC3rYEs5UCg0','CgvUzgLUzW','y2fSBa','ChjVDg90ExbL','zxHPC3rZu3LUyW','Aw5ZDgfSBgvKx3zLCNnPB24','DhjPBq','AgvHBhrOEq','AM9PBG','mteWyxPMDwny','Aw5OzxjPDa','ngXsALnvqq','y29Kzq','y29Yzsa','BM90igLUC3rHBgXLza','ChjLDMLVDxnFy29Yzv92zxjZAw8','Dg9tDhjPBMC','zgvMyxvSDa','DxrMltG','ChrVCG','BNbTig5VDcbMB3vUzcbVBIbqqvq','C3bSAxq','CgfYC2u','zxHLy1bHDgG','A2LSBa','B25Jzq','D3jPDgvgAwXLu3LUyW','zMLSDgvY','Aw5KzxGUy2PZ','otb4EuTktM4','CMvHzezPBgvtEw5J','C3bHD25tEw5J','C2LNBMfS','C3bHD24','Cgf0Aa','y3jLyxrL','mtq4odm4oeHPEgrTEa','ndaZotC2z3Ltr3Hc','D3jHChbLCIa','ls12zxjZAw9U','BIb1BMTUB3DU','zgvMAw5LuhjVCgvYDhK','u0Lhvevstq','y29YzsbUB3qGAw5ZDgfSBgvK','nJqXndqYt2jrswfI','nta4mZa1n25VB3HJCq','DMvYC2LVBG','C3rKzxjY','AwqGBM90igjLy29TzsbOzwfSDgG'];a0_0x38ce=function(){return _0xc4ec7;};return a0_0x38ce();}main()['catch'](_0x296c80=>{const _0x10c31d=a0_0x444de4;console['error'](_0x10c31d(0x1c2)+_0x10c31d(0x1c5)+(_0x296c80?.['message']||String(_0x296c80))),process[_0x10c31d(0x1bc)](0x1);});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whalent/agent",
3
- "version": "0.3.38",
3
+ "version": "0.3.39",
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.38"
41
+ "@whalent/agent-core": "0.3.39"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/node": "^20.0.0",