@whalent/agent 0.3.111 → 0.3.112
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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_0x3c3ed8=a0_0x5a40;(function(_0x34017e,_0x5a7e95){const _0xaefdef=a0_0x5a40,_0x364857=_0x34017e();while(!![]){try{const _0x151048=parseInt(_0xaefdef(0x95))/0x1+-parseInt(_0xaefdef(0x81))/0x2+parseInt(_0xaefdef(0x78))/0x3*(parseInt(_0xaefdef(0xa3))/0x4)+parseInt(_0xaefdef(0xf1))/0x5*(-parseInt(_0xaefdef(0xa7))/0x6)+-parseInt(_0xaefdef(0xa0))/0x7+-parseInt(_0xaefdef(0xbb))/0x8+parseInt(_0xaefdef(0x7d))/0x9;if(_0x151048===_0x5a7e95)break;else _0x364857['push'](_0x364857['shift']());}catch(_0x1100e7){_0x364857['push'](_0x364857['shift']());}}}(a0_0x1038,0x6d3c4));var __create=Object['create'],__defProp=Object[a0_0x3c3ed8(0xab)],__getOwnPropDesc=Object['getOwnPropertyDescri'+'ptor'],__getOwnPropNames=Object[a0_0x3c3ed8(0x6f)],__getProtoOf=Object['getPrototypeOf'],__hasOwnProp=Object['prototype'][a0_0x3c3ed8(0x7c)],__copyProps=(_0xd2dfc7,_0x58e1d0,_0xa49847,_0x1648b7)=>{const _0x23cba6=a0_0x3c3ed8;if(_0x58e1d0&&typeof _0x58e1d0===_0x23cba6(0xc8)||typeof _0x58e1d0===_0x23cba6(0xce)){for(let _0x248275 of __getOwnPropNames(_0x58e1d0))if(!__hasOwnProp[_0x23cba6(0xae)](_0xd2dfc7,_0x248275)&&_0x248275!==_0xa49847)__defProp(_0xd2dfc7,_0x248275,{'get':()=>_0x58e1d0[_0x248275],'enumerable':!(_0x1648b7=__getOwnPropDesc(_0x58e1d0,_0x248275))||_0x1648b7['enumerable']});}return _0xd2dfc7;},__toESM=(_0x253b72,_0x3024d7,_0x7c5521)=>(_0x7c5521=_0x253b72!=null?__create(__getProtoOf(_0x253b72)):{},__copyProps(_0x3024d7||!_0x253b72||!_0x253b72[a0_0x3c3ed8(0x74)]?__defProp(_0x7c5521,a0_0x3c3ed8(0xbe),{'value':_0x253b72,'enumerable':!![]}):_0x7c5521,_0x253b72)),import_child_process2=require(a0_0x3c3ed8(0x88)),fs=__toESM(require('fs'),0x1),import_module=require(a0_0x3c3ed8(0x84)),os=__toESM(require('os'),0x1),path=__toESM(require(a0_0x3c3ed8(0xa9)),0x1),import_child_process=require(a0_0x3c3ed8(0x88)),import_fs=require('fs'),import_path=require('path'),DEFAULT_NPM_REGISTRY='https://registry.npm'+a0_0x3c3ed8(0xea),CHINA_NPM_REGISTRY=a0_0x3c3ed8(0xc1)+'mirror.com';function preferredNpmRegistry(){const _0x2f00e5=normalizeRegistry(process.env.WHALENT_NPM_REGISTRY||process.env.NPM_CONFIG_REGISTRY||'');if(_0x2f00e5)return _0x2f00e5;return isChineseLocale()?CHINA_NPM_REGISTRY:DEFAULT_NPM_REGISTRY;}function npmRegistryArg(_0x64cb3b=preferredNpmRegistry()){return'--registry='+(normalizeRegistry(_0x64cb3b)||DEFAULT_NPM_REGISTRY);}function npmInstallCommand(_0x1a442e,_0x3a6845=preferredNpmRegistry()){const _0x131cf0=a0_0x3c3ed8;return _0x131cf0(0xd0)+_0x1a442e+'\x20'+npmRegistryArg(_0x3a6845);}function isChineseLocale(){const _0x581d37=a0_0x3c3ed8,_0x416716=[process.env.LC_ALL,process.env.LC_MESSAGES,process.env.LANG,process.env.LANGUAGE]['filter'](Boolean)[_0x581d37(0xe9)]('\x20');if(/(^|[_.-])zh([_.-]|$)|chinese|china|cn\b/i[_0x581d37(0xe6)](_0x416716))return!![];try{const _0xf7b605=Intl[_0x581d37(0xdf)]()[_0x581d37(0x89)]()['locale']||'';return/(^|-)zh($|-)|-CN\b/i[_0x581d37(0xe6)](_0xf7b605);}catch{return![];}}function normalizeRegistry(_0x4ca1a2){const _0x36a3e2=a0_0x3c3ed8;return String(_0x4ca1a2||'')[_0x36a3e2(0x80)]()['replace'](/\/+$/,'');}var INSTALL_HINT={'codex':'npm\x20install\x20-g\x20@open'+a0_0x3c3ed8(0x86),'claude':'npm\x20install\x20-g\x20@anth'+'ropic-ai/claude-code','opencode':a0_0x3c3ed8(0xe8)+a0_0x3c3ed8(0x75),'whalent':npmInstallCommand('@whalent/agent')+a0_0x3c3ed8(0x9b)};function isWindowsCmdFile(_0x2d4e1b){return process['platform']==='win32'&&/\.(cmd|bat)$/i['test'](_0x2d4e1b||'');}function quoteCmdArg(_0x1686bc){const _0x31755d=a0_0x3c3ed8,_0x4664ce=String(_0x1686bc??'');if(_0x4664ce&&!/[\s"&|<>^%]/['test'](_0x4664ce))return _0x4664ce;return'\x22'+_0x4664ce[_0x31755d(0x82)](/(["^&|<>%])/g,_0x31755d(0xf7))+'\x22';}function cmdFallbackArgs(_0x472721,_0xc05c75){const _0xaf6503=a0_0x3c3ed8;return['/d','/s','/c',[quoteCmdArg(_0x472721),..._0xc05c75[_0xaf6503(0x91)](quoteCmdArg)]['join']('\x20')];}function resolveExecutablePath(_0x496c7f){const _0x5afd9a=a0_0x3c3ed8;if(!_0x496c7f)return null;if(_0x496c7f['includes']('/')||_0x496c7f['includes']('\x5c')||/\.[A-Za-z0-9]{1,5}$/['test'](_0x496c7f))return(0x0,import_fs[_0x5afd9a(0xaf)])(_0x496c7f)?_0x496c7f:_0x496c7f;const _0x460bee=process['platform']===_0x5afd9a(0x7b),_0x2dfaec=_0x460bee?'where.exe':'which';try{const _0x4accac=(0x0,import_child_process['spawnSync'])(_0x2dfaec,[_0x496c7f],{'encoding':'utf-8','timeout':0xbb8,'shell':![]});if(_0x4accac['status']===0x0){const _0x22cae0=(_0x4accac[_0x5afd9a(0xf4)]||'')['trim']()['split'](/\r?\n/)[_0x5afd9a(0x71)](Boolean);if(_0x22cae0['length']===0x0)return null;if(_0x460bee)for(const _0x1a38d5 of['.exe','.cmd',_0x5afd9a(0xb5),'.ps1']){const _0x5c7807=_0x22cae0[_0x5afd9a(0xa6)](_0x13e30a=>_0x13e30a['toLowerCase']()['endsWith'](_0x1a38d5));if(_0x5c7807)return _0x5c7807;}return _0x22cae0[0x0]||null;}}catch{}return null;}function unwrapWindowsCmdShim(_0x3f8d29){const _0x497c4e=a0_0x3c3ed8;if(process[_0x497c4e(0xd3)]!==_0x497c4e(0x7b))return null;if(!/\.(cmd|bat)$/i['test'](_0x3f8d29))return null;let _0x453cb5;try{_0x453cb5=(0x0,import_fs[_0x497c4e(0xc3)])(_0x3f8d29,_0x497c4e(0xbc));}catch{return null;}const _0x13e062=_0x453cb5['match'](/"(%~?dp0%?)[\\/]+([^"]+\.(?:js|cjs|mjs))"/i);if(_0x13e062){const _0x4ec940=(0x0,import_path[_0x497c4e(0x9a)])((0x0,import_path[_0x497c4e(0xe5)])(_0x3f8d29),_0x13e062[0x2]);if((0x0,import_fs['existsSync'])(_0x4ec940))return{'type':_0x497c4e(0xbf),'path':_0x4ec940};}const _0x5945bb=_0x453cb5[_0x497c4e(0xb3)](/"(%~?dp0%?)[\\/]+([^"]+\.exe)"/i);if(_0x5945bb){const _0x400a65=(0x0,import_path[_0x497c4e(0x9a)])((0x0,import_path[_0x497c4e(0xe5)])(_0x3f8d29),_0x5945bb[0x2]);if((0x0,import_fs[_0x497c4e(0xaf)])(_0x400a65))return{'type':'exe','path':_0x400a65};}return null;}function safeSpawnSync(_0x5227c9,_0x54eb5c,_0x4c3423={}){const _0x5345e6=a0_0x3c3ed8,_0x8e0c3f=unwrapWindowsCmdShim(_0x5227c9);if(_0x8e0c3f?.[_0x5345e6(0xf0)]==='node')return(0x0,import_child_process['spawnSync'])(process[_0x5345e6(0x9f)],[_0x8e0c3f[_0x5345e6(0xa9)],..._0x54eb5c],_0x4c3423);if(_0x8e0c3f?.[_0x5345e6(0xf0)]==='exe')return(0x0,import_child_process['spawnSync'])(_0x8e0c3f['path'],_0x54eb5c,_0x4c3423);if(isWindowsCmdFile(_0x5227c9))return(0x0,import_child_process[_0x5345e6(0xc4)])(process.env.ComSpec||'cmd.exe',cmdFallbackArgs(_0x5227c9,_0x54eb5c),_0x4c3423);return(0x0,import_child_process['spawnSync'])(_0x5227c9,_0x54eb5c,_0x4c3423);}function a0_0x5a40(_0x3a8fae,_0xbeef4b){_0x3a8fae=_0x3a8fae-0x6f;const _0x103884=a0_0x1038();let _0x5a40c6=_0x103884[_0x3a8fae];if(a0_0x5a40['eHHTPw']===undefined){var _0x439734=function(_0x53c074){const _0x268b80='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0xd2dfc7='',_0x58e1d0='';for(let _0xa49847=0x0,_0x1648b7,_0x248275,_0x253b72=0x0;_0x248275=_0x53c074['charAt'](_0x253b72++);~_0x248275&&(_0x1648b7=_0xa49847%0x4?_0x1648b7*0x40+_0x248275:_0x248275,_0xa49847++%0x4)?_0xd2dfc7+=String['fromCharCode'](0xff&_0x1648b7>>(-0x2*_0xa49847&0x6)):0x0){_0x248275=_0x268b80['indexOf'](_0x248275);}for(let _0x3024d7=0x0,_0x7c5521=_0xd2dfc7['length'];_0x3024d7<_0x7c5521;_0x3024d7++){_0x58e1d0+='%'+('00'+_0xd2dfc7['charCodeAt'](_0x3024d7)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x58e1d0);};a0_0x5a40['pkrAsN']=_0x439734,a0_0x5a40['BWdmXP']={},a0_0x5a40['eHHTPw']=!![];}const _0x4bc1af=_0x103884[0x0],_0x56d4d6=_0x3a8fae+_0x4bc1af,_0x473a93=a0_0x5a40['BWdmXP'][_0x56d4d6];return!_0x473a93?(_0x5a40c6=a0_0x5a40['pkrAsN'](_0x5a40c6),a0_0x5a40['BWdmXP'][_0x56d4d6]=_0x5a40c6):_0x5a40c6=_0x473a93,_0x5a40c6;}var WRAPPER_PKG_NAME='@whalent/agent',CORE_PKG_NAME='@whalent/agent-core',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 _0x3661f7=a0_0x3c3ed8;return path['join'](os[_0x3661f7(0x8d)](),'.whalent-agent');}function upgradeStatePath(){const _0xd88707=a0_0x3c3ed8;return path[_0xd88707(0xe9)](configDir(),_0xd88707(0xb1));}function lastCrashFilePath(){return path['join'](configDir(),'last-crash.json');}function writeLastCrash(_0x531d74){const _0x18546e=a0_0x3c3ed8;try{fs[_0x18546e(0x8b)](configDir(),{'recursive':!![]});const _0xf1eb14={..._0x531d74,'reported':![]};fs[_0x18546e(0x8c)](lastCrashFilePath(),JSON['stringify'](_0xf1eb14,null,0x2),_0x18546e(0xbc));}catch{}}function readWrapperVersion(){const _0x3b0b05=a0_0x3c3ed8;try{const _0x9dc640=JSON[_0x3b0b05(0xd6)](fs['readFileSync'](path['join'](wrapperBaseDir(),'..','package.json'),'utf-8'));return String(_0x9dc640[_0x3b0b05(0xde)]||'0.0.0');}catch{return _0x3b0b05(0xaa);}}function readUpgradeState(){const _0x530c09=a0_0x3c3ed8;try{return JSON[_0x530c09(0xd6)](fs[_0x530c09(0xc3)](upgradeStatePath(),'utf-8'));}catch{return null;}}function writeUpgradeState(_0x55e679){try{fs['mkdirSync'](configDir(),{'recursive':!![]}),fs['writeFileSync'](upgradeStatePath(),JSON['stringify']({..._0x55e679,'updated_at':Date['now']()},null,0x2),'utf-8');}catch{}}function run(_0x477f47,_0x33c409,_0x44b1ef=process.env){return safeSpawnSync(_0x477f47,_0x33c409,{'encoding':'utf8','timeout':NPM_INSTALL_TIMEOUT_MS,'maxBuffer':NPM_INSTALL_MAX_BUFFER,'env':_0x44b1ef,'shell':![]});}function runNpmView(_0x33ed29){const _0x3cea13=a0_0x3c3ed8,_0x337d2b=resolveExecutablePath('npm');if(!_0x337d2b)return{'status':0x7f,'stdout':'','stderr':'npm\x20not\x20found','error':new Error(_0x3cea13(0x98))};return safeSpawnSync(_0x337d2b,_0x33ed29,{'encoding':_0x3cea13(0xeb),'timeout':NPM_VIEW_TIMEOUT_MS,'maxBuffer':0x400*0x400,'env':process.env,'shell':![]});}function npmRootGlobal(){const _0x13b946=a0_0x3c3ed8,_0x257f61=resolveExecutablePath(_0x13b946(0xb8));if(!_0x257f61)return'';const _0x1ff61d=run(_0x257f61,['root','-g']);if(_0x1ff61d['status']!==0x0)return'';return String(_0x1ff61d[_0x13b946(0xf4)]||'')[_0x13b946(0x80)]();}function compareSemver(_0x28674f,_0x19755c){const _0x391c37=a0_0x3c3ed8,_0x27314e=String(_0x28674f||'')[_0x391c37(0x82)](/^v/,'')[_0x391c37(0xbd)](/[.-]/)[_0x391c37(0x91)](_0x43e065=>Number[_0x391c37(0x85)](_0x43e065,0xa)||0x0),_0x5e3f4a=String(_0x19755c||'')['replace'](/^v/,'')[_0x391c37(0xbd)](/[.-]/)['map'](_0x1cf714=>Number['parseInt'](_0x1cf714,0xa)||0x0);for(let _0x15fe22=0x0;_0x15fe22<Math[_0x391c37(0xee)](_0x27314e[_0x391c37(0x70)],_0x5e3f4a[_0x391c37(0x70)],0x3);_0x15fe22++){const _0x3291f1=_0x27314e[_0x15fe22]||0x0,_0x24ba39=_0x5e3f4a[_0x15fe22]||0x0;if(_0x3291f1>_0x24ba39)return 0x1;if(_0x3291f1<_0x24ba39)return-0x1;}return 0x0;}function skipWrapperUpdateCheck(){const _0x429a02=String(process.env.WHALENT_SKIP_UPDATE_CHECK||process.env.WHALENT_NO_UPDATE_CHECK||process.env.WHALENT_SKIP_WRAPPER_UPDATE||'')['trim']()['toLowerCase']();return _0x429a02==='1'||_0x429a02==='true'||_0x429a02==='yes'||_0x429a02==='on';}function latestWrapperVersion(){const _0x1e0692=a0_0x3c3ed8,_0x537394=runNpmView(['view',WRAPPER_PKG_NAME+_0x1e0692(0xe4),'version',npmRegistryArg()]);if(_0x537394[_0x1e0692(0x83)]!==0x0)return'';return String(_0x537394[_0x1e0692(0xf4)]||'')['trim']()[_0x1e0692(0xbd)](/\r?\n/)[_0x1e0692(0x71)](Boolean)[_0x1e0692(0xb4)]()||'';}function installWrapperVersion(_0x591c83){const _0x4d86aa=a0_0x3c3ed8,_0x5aba23=resolveExecutablePath(_0x4d86aa(0xb8));if(!_0x5aba23)return{'ok':![],'output':'npm\x20not\x20found\x20on\x20PAT'+'H'};const _0x513584=run(_0x5aba23,['install','-g',WRAPPER_PKG_NAME+'@'+_0x591c83,npmRegistryArg()]),_0x355027=((_0x513584[_0x4d86aa(0xf4)]||'')+'\x0a'+(_0x513584[_0x4d86aa(0xdb)]||''))[_0x4d86aa(0x80)]();return{'ok':_0x513584['status']===0x0,'output':_0x355027};}function maybeUpdateWrapper(_0x5d8d90){const _0x3e01a6=a0_0x3c3ed8;if(skipWrapperUpdateCheck())return![];if(process.env.WHALENT_WRAPPER_UPDATE_ATTEMPTED)return![];const _0x7caf76=latestWrapperVersion();if(!_0x7caf76||compareSemver(_0x7caf76,WRAPPER_VERSION)<=0x0)return![];const _0x2fc052=preferredNpmRegistry();console[_0x3e01a6(0xd1)]('[wrapper]\x20update\x20ava'+_0x3e01a6(0xf8)+WRAPPER_VERSION+'\x20->\x20'+_0x7caf76),console[_0x3e01a6(0xd1)]('[wrapper]\x20installing'+'\x20'+WRAPPER_PKG_NAME+'@'+_0x7caf76+'\x20from\x20'+_0x2fc052+('\x20before\x20starting\x20cor'+'e...'));const _0x53bb7d=installWrapperVersion(_0x7caf76);if(!_0x53bb7d['ok']){console['warn']('[wrapper]\x20wrapper\x20up'+_0x3e01a6(0x92)+'ing\x20with\x20'+WRAPPER_VERSION);if(_0x53bb7d[_0x3e01a6(0x7e)])console['warn'](_0x53bb7d['output']['split'](/\r?\n/)[_0x3e01a6(0xca)](-0xc)[_0x3e01a6(0xe9)]('\x0a'));return console[_0x3e01a6(0xd1)]('[wrapper]\x20Manual\x20upd'+'ate:\x20'+npmInstallCommand(WRAPPER_PKG_NAME+'@'+_0x7caf76,_0x2fc052)),![];}console['warn']('[wrapper]\x20wrapper\x20up'+_0x3e01a6(0xac)+_0x7caf76+';\x20restarting\x20wrapper');const _0x4c44ed=process[_0x3e01a6(0x96)][0x1],_0xbbe918=(0x0,import_child_process2[_0x3e01a6(0xc4)])(process[_0x3e01a6(0x9f)],[_0x4c44ed,..._0x5d8d90],{'stdio':'inherit','env':{...process.env,'WHALENT_WRAPPER_UPDATE_ATTEMPTED':_0x7caf76},'shell':![]});process[_0x3e01a6(0xcb)](_0xbbe918[_0x3e01a6(0x83)]??0x0);}function findCoreScript(){const _0x30eae8=a0_0x3c3ed8,_0x43f9c8=String(process.env.WHALENT_CORE_ENTRY||'')[_0x30eae8(0x80)](),_0x59bd07=['1','true',_0x30eae8(0x9d),'on']['includes'](String(process.env.WHALENT_FORCE_CORE_ENTRY||'')[_0x30eae8(0x80)]()[_0x30eae8(0x94)]());if(_0x43f9c8&&_0x59bd07&&fs['existsSync'](_0x43f9c8))return _0x43f9c8;const _0x54fdcc=[],_0x67324a=_0x5d8392=>{const _0x29a53f=_0x30eae8;if(fs['existsSync'](_0x5d8392)&&!_0x54fdcc['includes'](_0x5d8392))_0x54fdcc[_0x29a53f(0xba)](_0x5d8392);};if(_0x43f9c8)_0x67324a(_0x43f9c8);const _0x3365f3=npmRootGlobal();if(_0x3365f3){const _0x19ed89=path['join'](_0x3365f3,'@whalent',_0x30eae8(0xc7),'dist',_0x30eae8(0xc5));_0x67324a(_0x19ed89);}const _0x545d3a=path[_0x30eae8(0xe9)](wrapperBaseDir(),_0x30eae8(0xcd));_0x67324a(_0x545d3a);const _0xcc0b66=path[_0x30eae8(0xe9)](wrapperBaseDir(),'..',_0x30eae8(0xe7),'core','dist',_0x30eae8(0xc5));_0x67324a(_0xcc0b66);if(_0x54fdcc[_0x30eae8(0x70)]>0x0)return _0x54fdcc['map']((_0x1dae45,_0x16b0a1)=>({'candidate':_0x1dae45,'index':_0x16b0a1,'version':coreVersion(_0x1dae45)}))['sort']((_0x3e6cb6,_0x31b015)=>{const _0x4f7111=_0x30eae8,_0x5f2cb1=compareSemver(_0x31b015['version'],_0x3e6cb6['version']);if(_0x5f2cb1!==0x0)return _0x5f2cb1;return _0x31b015['index']-_0x3e6cb6[_0x4f7111(0xd7)];})[0x0][_0x30eae8(0xcc)];throw new Error('whalent\x20core\x20runtime'+'\x20not\x20found;\x20install\x20'+'@whalent/agent-core\x20'+'or\x20rebuild\x20@whalent/'+_0x30eae8(0x79));}function coreVersion(_0x1c7e99=findCoreScript()){const _0xc3a143=a0_0x3c3ed8,_0x4dab00=(0x0,import_child_process2[_0xc3a143(0xc4)])(process['execPath'],[_0x1c7e99,'--version'],{'encoding':_0xc3a143(0xeb),'timeout':0x3a98,'env':{...process.env,'WHALENT_SKIP_UPDATE_CHECK':'1'},'shell':![]}),_0x1447d5=(_0x4dab00['stdout']||'')+'\x0a'+(_0x4dab00[_0xc3a143(0xdb)]||'');return _0x1447d5[_0xc3a143(0xb3)](/(\d+\.\d+\.\d+(?:[-\w.]+)?)/)?.[0x1]||'';}function isExecutable(_0x458d8f){const _0x198895=a0_0x3c3ed8;try{return fs[_0x198895(0x7a)](_0x458d8f,fs['constants']['X_OK']),!![];}catch{return![];}}function shellQuote(_0x2258d1){return'\x27'+_0x2258d1['replace'](/'/g,'\x27\x5c\x27\x27')+'\x27';}function coreNodePtySpawnHelperPath(_0x45696d){const _0x3f1cac=a0_0x3c3ed8;if(process['platform']!==_0x3f1cac(0xb0))return'';try{const _0x3fd339=(0x0,import_module[_0x3f1cac(0xcf)])(_0x45696d),_0x4cd55e=_0x3fd339[_0x3f1cac(0x9a)](_0x3f1cac(0x7f)),_0x3e14f8=path['resolve'](path[_0x3f1cac(0xe5)](_0x4cd55e),'..');return path['join'](_0x3e14f8,'prebuilds','darwin-'+process[_0x3f1cac(0xb2)],'spawn-helper');}catch{return'';}}function checkMacNodePtySpawnHelper(_0x14a77c){const _0x29d606=a0_0x3c3ed8,_0x37ee48=coreNodePtySpawnHelperPath(_0x14a77c);if(!_0x37ee48||CHECKED_PTY_HELPERS['has'](_0x37ee48))return;CHECKED_PTY_HELPERS[_0x29d606(0xd8)](_0x37ee48);if(!fs[_0x29d606(0xaf)](_0x37ee48)){console['warn']('[wrapper]\x20macOS\x20node'+'-pty\x20spawn-helper\x20no'+'t\x20found:\x20'+_0x37ee48);return;}if(isExecutable(_0x37ee48))return;try{const _0x28686c=fs['statSync'](_0x37ee48)[_0x29d606(0xa4)];fs[_0x29d606(0xa8)](_0x37ee48,_0x28686c|0x1ed);}catch{}if(isExecutable(_0x37ee48)){console['warn'](_0x29d606(0xad)+'S\x20node-pty\x20spawn-hel'+_0x29d606(0xe0)+_0x37ee48);return;}console['warn']('[wrapper]\x20macOS\x20node'+_0x29d606(0x97)+_0x29d606(0x8f)+_0x37ee48),console['warn']('[wrapper]\x20Run\x20this\x20o'+'nce\x20to\x20fix\x20terminal/'+_0x29d606(0xf3)),console['warn'](_0x29d606(0xed)+shellQuote(_0x37ee48)),console['warn']('\x20\x20ls\x20-l\x20\x22$HELPER\x22'),console['warn'](_0x29d606(0xa2));}function printVersion(){const _0x4783cd=a0_0x3c3ed8;let _0x10e4d8='';try{_0x10e4d8=coreVersion();}catch{}console['log'](_0x4783cd(0x77)+WRAPPER_VERSION),console[_0x4783cd(0xc6)](_0x4783cd(0x9e)+WRAPPER_VERSION),console['log']('core\x20'+(_0x10e4d8||'not\x20installed'));}function directCore(_0x56f127){const _0x38894f=a0_0x3c3ed8,_0x4fe0a0=findCoreScript();checkMacNodePtySpawnHelper(_0x4fe0a0);const _0x486465=(0x0,import_child_process2['spawnSync'])(process[_0x38894f(0x9f)],[_0x4fe0a0,..._0x56f127],{'stdio':'inherit','env':{...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_CORE_ENTRY':_0x4fe0a0},'shell':![]});process[_0x38894f(0xcb)](_0x486465['status']??0x0);}function shouldSupervise(_0x1f8a22){const _0x313057=a0_0x3c3ed8;if(_0x1f8a22[_0x313057(0x99)](_0x313057(0xda)))return![];if(_0x1f8a22['includes']('--resume')||_0x1f8a22[0x0]==='resume')return![];const _0x4431e4=_0x1f8a22[0x0]||'';if(_0x4431e4==='ls'||_0x4431e4===_0x313057(0x83)||_0x4431e4==='ps')return![];if(_0x4431e4===_0x313057(0x8e)||_0x4431e4===_0x313057(0xb7))return![];if(_0x1f8a22['includes'](_0x313057(0xfa))||_0x1f8a22['includes']('-h'))return![];return!![];}function installCoreVersion(_0x377860){const _0x164821=a0_0x3c3ed8,_0x43efd6=resolveExecutablePath('npm');if(!_0x43efd6)return{'ok':![],'output':_0x164821(0xd2)+'H'};const _0x4c13d3=CORE_PKG_NAME+'@'+_0x377860,_0x56f4e3=run(_0x43efd6,['install','-g',_0x4c13d3,npmRegistryArg()]),_0x259006=((_0x56f4e3['stdout']||'')+'\x0a'+(_0x56f4e3[_0x164821(0xdb)]||''))['trim']();return{'ok':_0x56f4e3[_0x164821(0x83)]===0x0,'output':_0x259006};}async function superviseCore(_0x57c266){const _0xd3705=a0_0x3c3ed8;let _0xc6c9c5=![],_0x32a204=null;const _0x2ced13=[];let _0x45678b=MIN_RESTART_DELAY_MS;const _0x1457c2=()=>{const _0x277c02=a0_0x5a40;_0xc6c9c5=!![];if(_0x32a204&&!_0x32a204['killed'])try{_0x32a204['kill'](_0x277c02(0xdc));}catch{}else process[_0x277c02(0xcb)](0x0);};process['on'](_0xd3705(0x72),_0x1457c2),process['on']('SIGTERM',_0x1457c2);while(!![]){const _0x4b6593=findCoreScript();checkMacNodePtySpawnHelper(_0x4b6593);const _0x1227e7={...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_WRAPPER_MANAGED':'1','WHALENT_CORE_ENTRY':_0x4b6593},_0x3afa7c=readUpgradeState(),_0x42a87d=!!_0x3afa7c?.['pending'];let _0xb9ded9=![],_0x4a006a=null,_0x50daa7='';const _0x506e0a=[],_0x12778b=0xc;console['log']('[wrapper]\x20starting\x20c'+_0xd3705(0xfb)+_0x4b6593),_0x32a204=(0x0,import_child_process2[_0xd3705(0xe2)])(process[_0xd3705(0x9f)],[_0x4b6593,..._0x57c266],{'env':_0x1227e7,'stdio':[_0xd3705(0xa5),'pipe','pipe']});const _0x354efb=()=>{const _0x33b8e4=_0xd3705;if(_0xb9ded9)return;_0xb9ded9=!![];if(_0x4a006a)clearTimeout(_0x4a006a);_0x2ced13[_0x33b8e4(0x70)]=0x0,_0x45678b=MIN_RESTART_DELAY_MS;const _0x4bfb99=readUpgradeState();_0x4bfb99?.[_0x33b8e4(0xef)]&&(writeUpgradeState({..._0x4bfb99,'pending':![],'rollback':![],'health_status':'healthy'}),console['log']('[wrapper]\x20core\x20upgra'+_0x33b8e4(0xc9)+(_0x4bfb99[_0x33b8e4(0xf9)]||_0x4bfb99['target_version']||'')));},_0x5bd13a=(_0x22514c,_0x3754f0=![])=>{const _0x2012fb=_0xd3705,_0x1ca4dd=_0x22514c[_0x2012fb(0xb9)]();(_0x3754f0?process['stderr']:process[_0x2012fb(0xf4)])[_0x2012fb(0xdd)](_0x1ca4dd);if(_0x3754f0)for(const _0x2c6cf6 of _0x1ca4dd['split'](/\r?\n/)){if(!_0x2c6cf6['trim']())continue;_0x506e0a[_0x2012fb(0xba)](_0x2c6cf6);if(_0x506e0a['length']>_0x12778b)_0x506e0a[_0x2012fb(0x73)]();const _0x436070=_0x2c6cf6['match'](FATAL_PATTERN);if(_0x436070)_0x50daa7=_0x436070[0x0];}(_0x1ca4dd['includes']('[gateway]\x20Connected')||_0x1ca4dd[_0x2012fb(0x99)]('Gateway\x20registered\x20m'+_0x2012fb(0xf6))||_0x1ca4dd['includes']('Gateway:\x20connected'))&&_0x354efb();};_0x32a204[_0xd3705(0xf4)]?.['on'](_0xd3705(0xd4),_0x5f3cb5=>_0x5bd13a(_0x5f3cb5,![])),_0x32a204[_0xd3705(0xdb)]?.['on'](_0xd3705(0xd4),_0x31e92b=>_0x5bd13a(_0x31e92b,!![]));_0x42a87d&&(_0x4a006a=setTimeout(()=>{const _0x5eb3f2=_0xd3705;if(_0xb9ded9||!_0x32a204||_0x32a204[_0x5eb3f2(0x76)])return;console['error']('[wrapper]\x20new\x20core\x20d'+'id\x20not\x20become\x20health'+_0x5eb3f2(0x8a)+_0x5eb3f2(0x90));try{_0x32a204['kill']('SIGTERM');}catch{}},HEALTH_TIMEOUT_MS));const _0x520120=await new Promise(_0x25ef8c=>{const _0x1e9a23=_0xd3705;_0x32a204[_0x1e9a23(0xd5)]('exit',(_0x2a5bb3,_0x47eeca)=>_0x25ef8c({'code':_0x2a5bb3,'signal':_0x47eeca}));});if(_0x4a006a)clearTimeout(_0x4a006a);_0x32a204=null;if(_0xc6c9c5)process['exit'](_0x520120[_0xd3705(0xe1)]??0x0);const _0x1fe299=readUpgradeState();if(_0x1fe299?.[_0xd3705(0xef)]&&!_0xb9ded9){const _0x2ee796=String(_0x1fe299['previous_core_versio'+'n']||'')[_0xd3705(0x80)]();if(_0x2ee796){console[_0xd3705(0xec)]('[wrapper]\x20rolling\x20ba'+_0xd3705(0xf2)+_0x2ee796);const _0x1d50a1=installCoreVersion(_0x2ee796);writeUpgradeState({..._0x1fe299,'pending':![],'rollback':!![],'health_status':_0x1d50a1['ok']?_0xd3705(0x93):_0xd3705(0xf5),'error':_0x1d50a1['ok']?'':_0x1d50a1['output']});}else writeUpgradeState({..._0x1fe299,'pending':![],'rollback':!![],'health_status':_0xd3705(0xb6),'error':'previous\x20core\x20versio'+'n\x20unknown'});}const _0x21534a=_0x520120['code']===SUPERVISED_RESTART_CODE||_0x1fe299?.[_0xd3705(0xef)];if(!_0x21534a&&_0x520120[_0xd3705(0xe1)]===0x0)process['exit'](0x0);const _0x1aa94c=Date['now']();_0x2ced13['push'](_0x1aa94c);while(_0x2ced13['length']>0x0&&_0x1aa94c-_0x2ced13[0x0]>CRASH_WINDOW_MS){_0x2ced13['shift']();}const _0xae5f37=_0x2ced13['length'];writeLastCrash({'timestamp':_0x1aa94c,'exit_code':_0x520120['code'],'exit_signal':_0x520120[_0xd3705(0x87)]||null,'fatal_line':_0x50daa7,'raw_tail':_0x506e0a[_0xd3705(0xe9)]('\x0a'),'consecutive_crashes':_0xae5f37}),console['log']('[wrapper]\x20core\x20exite'+'d\x20code='+(_0x520120[_0xd3705(0xe1)]??'')+(_0x520120['signal']?_0xd3705(0xe3)+_0x520120['signal']:'')+'\x20('+_0xae5f37+'/'+MAX_CRASHES_IN_WINDOW+'\x20in\x20last\x20'+Math['round'](CRASH_WINDOW_MS/0x3e8)+'s)');if(_0x50daa7)console['log']('[wrapper]\x20last\x20fatal'+':\x20'+_0x50daa7);_0xae5f37>=MAX_CRASHES_IN_WINDOW&&(console[_0xd3705(0xec)](_0xd3705(0xd9)+'d\x20'+_0xae5f37+'\x20times\x20within\x20'+Math['round'](CRASH_WINDOW_MS/0x3e8)+('s;\x20giving\x20up.\x20Crash\x20'+_0xd3705(0xc2))+lastCrashFilePath()+('.\x20Restart\x20wrapper\x20ma'+'nually\x20after\x20the\x20und'+'erlying\x20issue\x20is\x20fix'+_0xd3705(0xc0))),process[_0xd3705(0xcb)](0x1)),console['log']('[wrapper]\x20restarting'+'\x20in\x20'+_0x45678b+'ms'),await new Promise(_0x1f3f49=>setTimeout(_0x1f3f49,_0x45678b)),_0x45678b=Math['min'](_0x45678b*0x2,MAX_RESTART_DELAY_MS);}}async function main(){const _0x11bce1=a0_0x3c3ed8,_0x2b660d=process['argv']['slice'](0x2);if(_0x2b660d[0x0]==='--version'||_0x2b660d[0x0]==='-v'||_0x2b660d[0x0]===_0x11bce1(0xde)){printVersion();return;}if((_0x2b660d[0x0]===_0x11bce1(0x83)||_0x2b660d[0x0]==='ls'||_0x2b660d[0x0]==='ps')&&!_0x2b660d[_0x11bce1(0x99)]('--json')){console[_0x11bce1(0xc6)]('wrapper\x20'+WRAPPER_VERSION);try{console[_0x11bce1(0xc6)]('core\x20'+(coreVersion()||'not\x20installed'));}catch{console[_0x11bce1(0xc6)]('core\x20not\x20installed');}}maybeUpdateWrapper(_0x2b660d);if(!shouldSupervise(_0x2b660d))directCore(_0x2b660d);await superviseCore(_0x2b660d);}function a0_0x1038(){const _0x1a3f3e=['w3DYyxbWzxjDignVCMuGzMfPBgu','ls1Hz2vUDc1Pza','C3rKzxjY','u0Lhvevstq','D3jPDgu','DMvYC2LVBG','rgf0zvrPBwvgB3jTyxq','CgvYigv4zwn1DgfIBguGyML0oIa','y29Kzq','C3bHD24','ihnPz25HBd0','qgXHDgvZDa','zgLYBMfTzq','DgvZDa','CgfJA2fNzxm','BNbTigLUC3rHBgWGlwCGB3bLBMm','AM9PBG','ANmUB3jN','DxrMoa','zxjYB3i','icbiruXqrvi9','Bwf4','CgvUzgLUzW','DhLWzq','mtbTq2r2r0i','y2SGy29Yzsb0BYa','ufrzihn0yxj0Dxa6','C3rKB3v0','CM9SBgjHy2TFzMfPBgvK','ywnOAw5L','xIqX','AwXHyMXLoIa','Aw5ZDgfSBgvKx3zLCNnPB24','ls1OzwXW','B3jLoIa','z2v0t3DUuhjVCgvYDhLoyw1LCW','BgvUz3rO','zMLSDgvY','u0Lhsu5u','C2HPzNq','x19LC01VzhvSzq','B2rLlwfP','A2LSBgvK','D2HHBgvUDc1Hz2vUDca','mti3nJK4m1rAugDPBa','ywDLBNq','ywnJzxnZu3LUyW','D2LUmZi','AgfZt3DUuhjVCgvYDhK','ody4nZiYm1rHAxjpyq','B3v0Chv0','BM9Kzs1WDhK','DhjPBq','mtC0nJiXnLDHrK1oza','CMvWBgfJzq','C3rHDhvZ','Bw9KDwXL','CgfYC2vjBNq','ywKVy29KzxG','C2LNBMfS','y2HPBgrFChjVy2vZCW','CMvZB2X2zwrpChrPB25Z','EsbPBIb0Aw1LoYbYB2XSAw5Nigi','BwTKAxjtEw5J','D3jPDgvgAwXLu3LUyW','Ag9TzwrPCG','BwnW','ig5VDcbLEgvJDxrHyMXLoIa','ywnR','BwfW','zgf0zsbMywLSzwq7ignVBNrPBNu','CM9SBgvKx2jHy2S','Dg9mB3DLCKnHC2u','nZm5nJG3wM5bu1bs','yxjNDG','lxb0EsbZCgf3BI1OzwXWzxiGAxm','BNbTig5VDcbMB3vUza','Aw5JBhvKzxm','CMvZB2X2zq','ic0TChjLzMvYlw9UBgLUzq','w3DYyxbWzxjDiezHDgfSigvYCM8','EwvZ','D3jHChbLCIa','zxHLy1bHDgG','mti3mZyZnNzqzevVEa','CJOG','icbJAg1VzcaREcaIjeHftfbfuIi','oeXuv0XZuG','Bw9Kzq','Aw5OzxjPDa','zMLUza','mJa5ntGZnKLvAfDcwG','y2HTB2rtEw5J','Cgf0Aa','mc4WlJa','zgvMAw5LuhjVCgvYDhK','zgf0zwqGDg8G','w3DYyxbWzxjDigzPEgvKig1Hy08','y2fSBa','zxHPC3rZu3LUyW','zgfYD2LU','y29Yzs11CgDYywrLlMPZB24','yxjJAa','Bwf0y2G','Cg9W','lMjHDa','CM9SBgjHy2TFDw5HDMfPBgfIBgu','zgfLBw9Ulw1JCa','BNbT','Dg9tDhjPBMC','ChvZAa','mJG0mti4mhrcvvv3CW','DxrMltG','C3bSAxq','zgvMyxvSDa','BM9Kzq','zwqU','Ahr0Chm6lY9YzwDPC3rYEs5UCg0','CMvJB3jKoIa','CMvHzezPBgvtEw5J','C3bHD25tEw5J','Aw5KzxGUy2PZ','Bg9N','ywDLBNqTy29Yzq','B2jQzwn0','zguGAgvHBhrOEtOG','C2XPy2u','zxHPDa','y2fUzgLKyxrL','y29Yzs5JANm','zNvUy3rPB24','y3jLyxrLuMvXDwLYzq','BNbTigLUC3rHBgWGlwCG','D2fYBG','BNbTig5VDcbMB3vUzcbVBIbqqvq','CgXHDgzVCM0','zgf0yq','B25Jzq','CgfYC2u','Aw5KzxG','ywrK'];a0_0x1038=function(){return _0x1a3f3e;};return a0_0x1038();}main()['catch'](_0xc9a67e=>{const _0x2d7aef=a0_0x3c3ed8;console['error'](_0x2d7aef(0x9c)+_0x2d7aef(0xa1)+(_0xc9a67e?.['message']||String(_0xc9a67e))),process[_0x2d7aef(0xcb)](0x1);});
|
|
2
|
+
'use strict';const a0_0x5037bd=a0_0x12d6;(function(_0x23d946,_0x35cd17){const _0x592800=a0_0x12d6,_0x4f5b38=_0x23d946();while(!![]){try{const _0x37abde=-parseInt(_0x592800(0x18f))/0x1+parseInt(_0x592800(0x1e0))/0x2+-parseInt(_0x592800(0x15c))/0x3+parseInt(_0x592800(0x15f))/0x4*(-parseInt(_0x592800(0x171))/0x5)+-parseInt(_0x592800(0x175))/0x6*(-parseInt(_0x592800(0x1a4))/0x7)+-parseInt(_0x592800(0x195))/0x8*(parseInt(_0x592800(0x19d))/0x9)+parseInt(_0x592800(0x1d1))/0xa;if(_0x37abde===_0x35cd17)break;else _0x4f5b38['push'](_0x4f5b38['shift']());}catch(_0x2c0c04){_0x4f5b38['push'](_0x4f5b38['shift']());}}}(a0_0x32ae,0xa9162));var __create=Object['create'],__defProp=Object['defineProperty'],__getOwnPropDesc=Object['getOwnPropertyDescri'+a0_0x5037bd(0x1ac)],__getOwnPropNames=Object[a0_0x5037bd(0x16c)],__getProtoOf=Object['getPrototypeOf'],__hasOwnProp=Object['prototype'][a0_0x5037bd(0x1cd)],__copyProps=(_0x195f8a,_0x4100d2,_0x3e552c,_0x91d6c7)=>{const _0x3ace8b=a0_0x5037bd;if(_0x4100d2&&typeof _0x4100d2==='object'||typeof _0x4100d2==='function'){for(let _0x58c171 of __getOwnPropNames(_0x4100d2))if(!__hasOwnProp[_0x3ace8b(0x1d5)](_0x195f8a,_0x58c171)&&_0x58c171!==_0x3e552c)__defProp(_0x195f8a,_0x58c171,{'get':()=>_0x4100d2[_0x58c171],'enumerable':!(_0x91d6c7=__getOwnPropDesc(_0x4100d2,_0x58c171))||_0x91d6c7[_0x3ace8b(0x1c5)]});}return _0x195f8a;},__toESM=(_0x330a0f,_0x34767e,_0x407d0b)=>(_0x407d0b=_0x330a0f!=null?__create(__getProtoOf(_0x330a0f)):{},__copyProps(_0x34767e||!_0x330a0f||!_0x330a0f[a0_0x5037bd(0x182)]?__defProp(_0x407d0b,'default',{'value':_0x330a0f,'enumerable':!![]}):_0x407d0b,_0x330a0f)),import_child_process2=require(a0_0x5037bd(0x1d3)),fs=__toESM(require('fs'),0x1),import_module=require('module'),os=__toESM(require('os'),0x1),path=__toESM(require(a0_0x5037bd(0x1bf)),0x1),import_child_process=require(a0_0x5037bd(0x1d3)),import_fs=require('fs'),import_path=require('path'),DEFAULT_NPM_REGISTRY='https://registry.npm'+a0_0x5037bd(0x1af),CHINA_NPM_REGISTRY=a0_0x5037bd(0x178)+'mirror.com';function preferredNpmRegistry(){const _0x247dc8=normalizeRegistry(process.env.WHALENT_NPM_REGISTRY||process.env.NPM_CONFIG_REGISTRY||'');if(_0x247dc8)return _0x247dc8;return isChineseLocale()?CHINA_NPM_REGISTRY:DEFAULT_NPM_REGISTRY;}function npmRegistryArg(_0x291453=preferredNpmRegistry()){return'--registry='+(normalizeRegistry(_0x291453)||DEFAULT_NPM_REGISTRY);}function npmInstallCommand(_0x19535f,_0x40ca2d=preferredNpmRegistry()){const _0x3b82b1=a0_0x5037bd;return _0x3b82b1(0x1b6)+_0x19535f+'\x20'+npmRegistryArg(_0x40ca2d);}function isChineseLocale(){const _0x327e32=[process.env.LC_ALL,process.env.LC_MESSAGES,process.env.LANG,process.env.LANGUAGE]['filter'](Boolean)['join']('\x20');if(/(^|[_.-])zh([_.-]|$)|chinese|china|cn\b/i['test'](_0x327e32))return!![];try{const _0x3d8408=Intl['DateTimeFormat']()['resolvedOptions']()['locale']||'';return/(^|-)zh($|-)|-CN\b/i['test'](_0x3d8408);}catch{return![];}}function normalizeRegistry(_0x2e2a56){const _0x414926=a0_0x5037bd;return String(_0x2e2a56||'')[_0x414926(0x14d)]()['replace'](/\/+$/,'');}var INSTALL_HINT={'codex':'npm\x20install\x20-g\x20@open'+a0_0x5037bd(0x17a),'claude':'npm\x20install\x20-g\x20@anth'+'ropic-ai/claude-code','opencode':'npm\x20install\x20-g\x20openc'+'ode-ai','whalent':npmInstallCommand(a0_0x5037bd(0x18b))+a0_0x5037bd(0x14f)};function isWindowsCmdFile(_0x36895f){const _0x405402=a0_0x5037bd;return process['platform']==='win32'&&/\.(cmd|bat)$/i[_0x405402(0x191)](_0x36895f||'');}function quoteCmdArg(_0x4f6eee){const _0x1850ee=a0_0x5037bd,_0x740797=String(_0x4f6eee??'');if(_0x740797&&!/[\s"&|<>^%]/['test'](_0x740797))return _0x740797;return'\x22'+_0x740797[_0x1850ee(0x158)](/(["^&|<>%])/g,_0x1850ee(0x1c3))+'\x22';}function cmdFallbackArgs(_0x46226a,_0x19af2d){const _0x5e2e31=a0_0x5037bd;return['/d','/s','/c',[quoteCmdArg(_0x46226a),..._0x19af2d[_0x5e2e31(0x1da)](quoteCmdArg)]['join']('\x20')];}function resolveExecutablePath(_0x55fe12){const _0x1c95f5=a0_0x5037bd;if(!_0x55fe12)return null;if(_0x55fe12[_0x1c95f5(0x19e)]('/')||_0x55fe12['includes']('\x5c')||/\.[A-Za-z0-9]{1,5}$/[_0x1c95f5(0x191)](_0x55fe12))return(0x0,import_fs['existsSync'])(_0x55fe12)?_0x55fe12:_0x55fe12;const _0x32a319=process[_0x1c95f5(0x1d2)]==='win32',_0x29bbdd=_0x32a319?'where.exe':_0x1c95f5(0x181);try{const _0x2b50f3=(0x0,import_child_process[_0x1c95f5(0x19f)])(_0x29bbdd,[_0x55fe12],{'encoding':'utf-8','timeout':0xbb8,'shell':![]});if(_0x2b50f3[_0x1c95f5(0x167)]===0x0){const _0x842774=(_0x2b50f3[_0x1c95f5(0x1bd)]||'')[_0x1c95f5(0x14d)]()[_0x1c95f5(0x16e)](/\r?\n/)['filter'](Boolean);if(_0x842774['length']===0x0)return null;if(_0x32a319)for(const _0x543987 of['.exe',_0x1c95f5(0x1bc),'.bat',_0x1c95f5(0x187)]){const _0x3e9ac6=_0x842774[_0x1c95f5(0x147)](_0x53a02c=>_0x53a02c[_0x1c95f5(0x1a1)]()[_0x1c95f5(0x1b5)](_0x543987));if(_0x3e9ac6)return _0x3e9ac6;}return _0x842774[0x0]||null;}}catch{}return null;}function unwrapWindowsCmdShim(_0x4def3f){const _0x27e2af=a0_0x5037bd;if(process[_0x27e2af(0x1d2)]!=='win32')return null;if(!/\.(cmd|bat)$/i['test'](_0x4def3f))return null;let _0x85b9f1;try{_0x85b9f1=(0x0,import_fs['readFileSync'])(_0x4def3f,'utf-8');}catch{return null;}const _0x5a78c1=_0x85b9f1['match'](/"(%~?dp0%?)[\\/]+([^"]+\.(?:js|cjs|mjs))"/i);if(_0x5a78c1){const _0x3c74cf=(0x0,import_path['resolve'])((0x0,import_path['dirname'])(_0x4def3f),_0x5a78c1[0x2]);if((0x0,import_fs[_0x27e2af(0x17e)])(_0x3c74cf))return{'type':_0x27e2af(0x18c),'path':_0x3c74cf};}const _0x118ff2=_0x85b9f1['match'](/"(%~?dp0%?)[\\/]+([^"]+\.exe)"/i);if(_0x118ff2){const _0x3c2682=(0x0,import_path[_0x27e2af(0x1be)])((0x0,import_path[_0x27e2af(0x1b7)])(_0x4def3f),_0x118ff2[0x2]);if((0x0,import_fs['existsSync'])(_0x3c2682))return{'type':'exe','path':_0x3c2682};}return null;}function safeSpawnSync(_0xd19ddb,_0x2a8875,_0xdf7df8={}){const _0x3fad58=a0_0x5037bd,_0x4e31b4=unwrapWindowsCmdShim(_0xd19ddb);if(_0x4e31b4?.[_0x3fad58(0x1b1)]===_0x3fad58(0x18c))return(0x0,import_child_process[_0x3fad58(0x19f)])(process['execPath'],[_0x4e31b4['path'],..._0x2a8875],_0xdf7df8);if(_0x4e31b4?.['type']===_0x3fad58(0x185))return(0x0,import_child_process[_0x3fad58(0x19f)])(_0x4e31b4[_0x3fad58(0x1bf)],_0x2a8875,_0xdf7df8);if(isWindowsCmdFile(_0xd19ddb))return(0x0,import_child_process['spawnSync'])(process.env.ComSpec||_0x3fad58(0x198),cmdFallbackArgs(_0xd19ddb,_0x2a8875),_0xdf7df8);return(0x0,import_child_process['spawnSync'])(_0xd19ddb,_0x2a8875,_0xdf7df8);}var WRAPPER_PKG_NAME='@whalent/agent',CORE_PKG_NAME=a0_0x5037bd(0x177),SUPERVISED_RESTART_CODE=0x4b,NPM_VIEW_TIMEOUT_MS=0x3a98,HEALTH_TIMEOUT_MS=0xafc8,MIN_RESTART_DELAY_MS=0x3e8,MAX_RESTART_DELAY_MS=0xea60,MAX_CRASHES_IN_WINDOW=0x3,CRASH_WINDOW_MS=0x3*0x3c*0x3e8,NPM_INSTALL_TIMEOUT_MS=0xa*0x3c*0x3e8,NPM_INSTALL_MAX_BUFFER=0x20*0x400*0x400,FATAL_PATTERN=/\[(?:agent|daemon|wrapper)\][^\n]*\bFatal error:[^\n]+|\[daemon\] Failed to start:[^\n]+|Error:[^\n]+/,WRAPPER_VERSION=readWrapperVersion(),CHECKED_PTY_HELPERS=new Set();function wrapperBaseDir(){return __dirname;}function configDir(){const _0x41df0b=a0_0x5037bd;return path['join'](os['homedir'](),_0x41df0b(0x160));}function upgradeStatePath(){const _0x285e8a=a0_0x5037bd;return path[_0x285e8a(0x168)](configDir(),_0x285e8a(0x174));}function lastCrashFilePath(){const _0x2aeeb6=a0_0x5037bd;return path[_0x2aeeb6(0x168)](configDir(),_0x2aeeb6(0x196));}function writeLastCrash(_0x12dc80){const _0x1402ec=a0_0x5037bd;try{fs[_0x1402ec(0x1c2)](configDir(),{'recursive':!![]});const _0x487250={..._0x12dc80,'reported':![]};fs[_0x1402ec(0x148)](lastCrashFilePath(),JSON[_0x1402ec(0x1a5)](_0x487250,null,0x2),_0x1402ec(0x1c6));}catch{}}function readWrapperVersion(){const _0x1b8617=a0_0x5037bd;try{const _0x26d83d=JSON[_0x1b8617(0x157)](fs['readFileSync'](path['join'](wrapperBaseDir(),'..',_0x1b8617(0x194)),_0x1b8617(0x1c6)));return String(_0x26d83d['version']||_0x1b8617(0x1ca));}catch{return'0.0.0';}}function a0_0x32ae(){const _0x562980=['BNbTig5VDcbMB3vUzcbVBIbqqvq','CgfJA2fNzs5QC29U','mJy0DgHtsM1J','BgfZDc1JCMfZAc5QC29U','C2LNBMfS','y21KlMv4zq','w3DYyxbWzxjDig1Hy09tig5Vzgu','ig5VDcbLEgvJDxrHyMXLoIa','CM9VDa','AwqGBM90igjLy29TzsbOzwfSDgG','mtuWntC5A292uwzU','Aw5JBhvKzxm','C3bHD25tEw5J','icbSCYaTBcaIjeHftfbfuIi','Dg9mB3DLCKnHC2u','Dg9tDhjPBMC','A2LSBgvK','mJuZndqYEg9TALnz','C3rYAw5NAwz5','ihnPz25HBd0','D3jPDgu','w3DYyxbWzxjDihvWzgf0zsbHDMe','wf9psW','DxrMoa','BwnW','ChrVCG','ls1Hz2vUDc1Pza','ChjLyNvPBgrZ','ANmUB3jN','CgfYC2vjBNq','DhLWzq','y29Yzsa','ls1OzwXW','Bwf0y2G','zw5KC1DPDgG','BNbTigLUC3rHBgWGlwCG','zgLYBMfTzq','y29YzsbUB3qGAw5ZDgfSBgvK','DMvYC2LVBG','CgvUzgLUzW','igLUia','lMnTza','C3rKB3v0','CMvZB2X2zq','Cgf0Aa','D2fYBG','C2XPy2u','BwTKAxjtEw5J','xIqX','CM9SBgjHy2TFzMfPBgvK','zw51BwvYywjSzq','DxrMltG','B3jLoIa','w3DYyxbWzxjDihjLC3rHCNrPBMC','BNbT','mc4WlJa','BgvUz3rO','CM9SBgjHy2TFDw5HDMfPBgfIBgu','AgfZt3DUuhjVCgvYDhK','CM9SBgvKx2jHy2S','w3DYyxbWzxjDihDYyxbWzxiGDxa','BNbTig5VDcbMB3vUza','mJq5mJy1mtbNzwjftLO','CgXHDgzVCM0','y2HPBgrFChjVy2vZCW','Bw9Kzq','y2fSBa','CgvYigv4zwn1DgfIBguGyML0oIa','Bg9N','y29UC3rHBNrZ','yxjNDG','BwfW','BNvHBgX5igfMDgvYihrOzsb1BMq','B3iGCMvIDwLSzcbaD2HHBgvUDc8','y29Kzq','y29Yzq','igjLzM9YzsbZDgfYDgLUzYbJB3i','mta3mZq1ofnmug1mzW','igzYB20G','zgfYD2LU','ChvZAa','u0Lhsu5u','zMLUza','D3jPDgvgAwXLu3LUyW','lxb0EsbZCgf3BI1OzwXWzxiGBM8','w3DYyxbWzxjDignVCMuGzMfPBgu','CgLWzq','zxjYB3i','DhjPBq','CMvHzezPBgvtEw5J','ic0TChjLzMvYlw9UBgLUzq','r2f0zxDHEsbYzwDPC3rLCMvKig0','EwvZ','CMvJB3jKoIa','icbJAg1VzcaREcaIjeHftfbfuIi','C2HPzNq','lxb0EsbZCgf3BI1OzwXWzxiGAxm','Aw5OzxjPDa','CgfYC2u','CMvWBgfJzq','BM9Kzs1WDhK','u0Lhvevstq','zxHPDa','mJGZnJG0mLz2z29VCq','Aw5KzxGUy2PZ','AgfZ','mtyWmtq4B2vzsKTn','lNDOywXLBNqTywDLBNq','zwqU','w3DYyxbWzxjDifj1BIb0AgLZig8','C3rKzxjY','Aw5KzxG','Dhj1zq','w3DYyxbWzxjDie1HBNvHBcb1Cgq','C3rHDhvZ','AM9PBG','zgf0zwqGDg8G','y29Yzs5JANm','ic0+ia','z2v0t3DUuhjVCgvYDhLoyw1LCW','AgvHBhrOEq','C3bSAxq','EsbPBIb0Aw1LoYbYB2XSAw5Nigi','zxHLy1bHDgG','mtmWrNrktLjw','BM93','CMvZDw1L','y29Yzs11CgDYywrLlMPZB24','nZHzsvjxwwC','A2LSBa','qhDOywXLBNqVywDLBNqTy29Yzq','Ahr0Chm6lY9YzwDPC3rYEs5UCg0','D3jHChbLCIa','ywKVy29KzxG','zgLZDa','zxjSEwLUzYbPC3n1zsbPCYbMAxG','w3DYyxbWzxjDihn0yxj0Aw5Nigm','zxHPC3rZu3LUyW','w3DYyxbWzxjDigLUC3rHBgXPBMC','DgfYz2v0x3zLCNnPB24','D2HPy2G','x19LC01VzhvSzq','ywnOAw5L','qhDOywXLBNqVywDLBNqTy29Yzsa','zxHL','ChjLDMLVDxnFy29Yzv92zxjZAw8','lNbZmq','oYbYzxn0yxj0Aw5NihDYyxbWzxi','C29YDa','y3jLyxrLuMvXDwLYzq','qhDOywXLBNqVywDLBNq','BM9Kzq','zMLSDgvY','BMnLihrVigzPEcb0zxjTAw5HBc8','mJy4nZGXvNfsBNPc','w3DYyxbWzxjDihjVBgXPBMCGyMe','DgvZDa','qhDOywXLBNq'];a0_0x32ae=function(){return _0x562980;};return a0_0x32ae();}function readUpgradeState(){const _0x2274c4=a0_0x5037bd;try{return JSON[_0x2274c4(0x157)](fs[_0x2274c4(0x14e)](upgradeStatePath(),_0x2274c4(0x1c6)));}catch{return null;}}function writeUpgradeState(_0x3706b5){const _0x4e7123=a0_0x5037bd;try{fs[_0x4e7123(0x1c2)](configDir(),{'recursive':!![]}),fs['writeFileSync'](upgradeStatePath(),JSON['stringify']({..._0x3706b5,'updated_at':Date[_0x4e7123(0x172)]()},null,0x2),'utf-8');}catch{}}function run(_0x242bb7,_0x577e11,_0xa21513=process.env){return safeSpawnSync(_0x242bb7,_0x577e11,{'encoding':'utf8','timeout':NPM_INSTALL_TIMEOUT_MS,'maxBuffer':NPM_INSTALL_MAX_BUFFER,'env':_0xa21513,'shell':![]});}function runNpmView(_0x314675){const _0x3b98ab=a0_0x5037bd,_0x1b641c=resolveExecutablePath('npm');if(!_0x1b641c)return{'status':0x7f,'stdout':'','stderr':_0x3b98ab(0x1d0),'error':new Error(_0x3b98ab(0x1d0))};return safeSpawnSync(_0x1b641c,_0x314675,{'encoding':'utf8','timeout':NPM_VIEW_TIMEOUT_MS,'maxBuffer':0x400*0x400,'env':process.env,'shell':![]});}function a0_0x12d6(_0x3ebaae,_0x88b318){_0x3ebaae=_0x3ebaae-0x144;const _0x32aef3=a0_0x32ae();let _0x12d656=_0x32aef3[_0x3ebaae];if(a0_0x12d6['OlLzRv']===undefined){var _0x27b11a=function(_0x4c2c72){const _0x455dce='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x195f8a='',_0x4100d2='';for(let _0x3e552c=0x0,_0x91d6c7,_0x58c171,_0x330a0f=0x0;_0x58c171=_0x4c2c72['charAt'](_0x330a0f++);~_0x58c171&&(_0x91d6c7=_0x3e552c%0x4?_0x91d6c7*0x40+_0x58c171:_0x58c171,_0x3e552c++%0x4)?_0x195f8a+=String['fromCharCode'](0xff&_0x91d6c7>>(-0x2*_0x3e552c&0x6)):0x0){_0x58c171=_0x455dce['indexOf'](_0x58c171);}for(let _0x34767e=0x0,_0x407d0b=_0x195f8a['length'];_0x34767e<_0x407d0b;_0x34767e++){_0x4100d2+='%'+('00'+_0x195f8a['charCodeAt'](_0x34767e)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x4100d2);};a0_0x12d6['BdgaaO']=_0x27b11a,a0_0x12d6['bulUsl']={},a0_0x12d6['OlLzRv']=!![];}const _0xb261e8=_0x32aef3[0x0],_0x4d5971=_0x3ebaae+_0xb261e8,_0x2911db=a0_0x12d6['bulUsl'][_0x4d5971];return!_0x2911db?(_0x12d656=a0_0x12d6['BdgaaO'](_0x12d656),a0_0x12d6['bulUsl'][_0x4d5971]=_0x12d656):_0x12d656=_0x2911db,_0x12d656;}function npmRootGlobal(){const _0x2531be=a0_0x5037bd,_0x39991b=resolveExecutablePath('npm');if(!_0x39991b)return'';const _0x3725d1=run(_0x39991b,[_0x2531be(0x19b),'-g']);if(_0x3725d1['status']!==0x0)return'';return String(_0x3725d1['stdout']||'')['trim']();}function compareSemver(_0x42b05d,_0xcc8b3d){const _0x26a31e=a0_0x5037bd,_0x30644b=String(_0x42b05d||'')['replace'](/^v/,'')[_0x26a31e(0x16e)](/[.-]/)[_0x26a31e(0x1da)](_0x1c5eae=>Number[_0x26a31e(0x1b0)](_0x1c5eae,0xa)||0x0),_0x2ffbcc=String(_0xcc8b3d||'')['replace'](/^v/,'')[_0x26a31e(0x16e)](/[.-]/)[_0x26a31e(0x1da)](_0x58d3c6=>Number[_0x26a31e(0x1b0)](_0x58d3c6,0xa)||0x0);for(let _0x3ce415=0x0;_0x3ce415<Math['max'](_0x30644b['length'],_0x2ffbcc['length'],0x3);_0x3ce415++){const _0x560567=_0x30644b[_0x3ce415]||0x0,_0x15dccd=_0x2ffbcc[_0x3ce415]||0x0;if(_0x560567>_0x15dccd)return 0x1;if(_0x560567<_0x15dccd)return-0x1;}return 0x0;}function skipWrapperUpdateCheck(){const _0x3a903d=a0_0x5037bd,_0x2675e7=String(process.env.WHALENT_SKIP_UPDATE_CHECK||process.env.WHALENT_NO_UPDATE_CHECK||process.env.WHALENT_SKIP_WRAPPER_UPDATE||'')[_0x3a903d(0x14d)]()[_0x3a903d(0x1a1)]();return _0x2675e7==='1'||_0x2675e7==='true'||_0x2675e7==='yes'||_0x2675e7==='on';}function latestWrapperVersion(){const _0x293b3e=a0_0x5037bd,_0x160b49=runNpmView(['view',WRAPPER_PKG_NAME+'@latest',_0x293b3e(0x1b9),npmRegistryArg()]);if(_0x160b49['status']!==0x0)return'';return String(_0x160b49[_0x293b3e(0x1bd)]||'')[_0x293b3e(0x14d)]()['split'](/\r?\n/)[_0x293b3e(0x18d)](Boolean)['pop']()||'';}function installWrapperVersion(_0x21b818){const _0x4afc71=a0_0x5037bd,_0x1245f7=resolveExecutablePath('npm');if(!_0x1245f7)return{'ok':![],'output':_0x4afc71(0x193)+'H'};const _0x3ff0b1=run(_0x1245f7,['install','-g',WRAPPER_PKG_NAME+'@'+_0x21b818,npmRegistryArg()]),_0x5f06e8=((_0x3ff0b1['stdout']||'')+'\x0a'+(_0x3ff0b1[_0x4afc71(0x163)]||''))['trim']();return{'ok':_0x3ff0b1[_0x4afc71(0x167)]===0x0,'output':_0x5f06e8};}function maybeUpdateWrapper(_0x211af1){const _0x244096=a0_0x5037bd;if(skipWrapperUpdateCheck())return![];if(process.env.WHALENT_WRAPPER_UPDATE_ATTEMPTED)return![];const _0x163325=latestWrapperVersion();if(!_0x163325||compareSemver(_0x163325,WRAPPER_VERSION)<=0x0)return![];const _0x2ea4ad=preferredNpmRegistry();console[_0x244096(0x1c0)](_0x244096(0x1a8)+'ilable:\x20'+WRAPPER_VERSION+_0x244096(0x16b)+_0x163325),console['warn'](_0x244096(0x17f)+'\x20'+WRAPPER_PKG_NAME+'@'+_0x163325+_0x244096(0x1e1)+_0x2ea4ad+(_0x244096(0x1df)+'e...'));const _0x5e73e6=installWrapperVersion(_0x163325);if(!_0x5e73e6['ok']){console['warn'](_0x244096(0x1cf)+'date\x20failed;\x20continu'+'ing\x20with\x20'+WRAPPER_VERSION);if(_0x5e73e6['output'])console['warn'](_0x5e73e6['output']['split'](/\r?\n/)['slice'](-0xc)[_0x244096(0x168)]('\x0a'));return console[_0x244096(0x1c0)](_0x244096(0x166)+'ate:\x20'+npmInstallCommand(WRAPPER_PKG_NAME+'@'+_0x163325,_0x2ea4ad)),![];}console[_0x244096(0x1c0)]('[wrapper]\x20wrapper\x20up'+_0x244096(0x169)+_0x163325+_0x244096(0x188));const _0x5e5310=process[_0x244096(0x1d9)][0x1],_0x3fa72e=(0x0,import_child_process2[_0x244096(0x19f)])(process['execPath'],[_0x5e5310,..._0x211af1],{'stdio':_0x244096(0x156),'env':{...process.env,'WHALENT_WRAPPER_UPDATE_ATTEMPTED':_0x163325},'shell':![]});process['exit'](_0x3fa72e[_0x244096(0x167)]??0x0);}function findCoreScript(){const _0x5c86e4=a0_0x5037bd,_0x20bdb7=String(process.env.WHALENT_CORE_ENTRY||'')[_0x5c86e4(0x14d)](),_0x57e43b=['1',_0x5c86e4(0x165),_0x5c86e4(0x151),'on'][_0x5c86e4(0x19e)](String(process.env.WHALENT_FORCE_CORE_ENTRY||'')['trim']()[_0x5c86e4(0x1a1)]());if(_0x20bdb7&&_0x57e43b&&fs[_0x5c86e4(0x17e)](_0x20bdb7))return _0x20bdb7;const _0x36aec7=[],_0x18b449=_0x5c02bc=>{const _0x2a85a8=_0x5c86e4;if(fs[_0x2a85a8(0x17e)](_0x5c02bc)&&!_0x36aec7[_0x2a85a8(0x19e)](_0x5c02bc))_0x36aec7[_0x2a85a8(0x145)](_0x5c02bc);};if(_0x20bdb7)_0x18b449(_0x20bdb7);const _0x56d52a=npmRootGlobal();if(_0x56d52a){const _0x1bd37f=path['join'](_0x56d52a,_0x5c86e4(0x192),'agent-core',_0x5c86e4(0x17b),_0x5c86e4(0x15d));_0x18b449(_0x1bd37f);}const _0x3509ce=path[_0x5c86e4(0x168)](wrapperBaseDir(),_0x5c86e4(0x16a));_0x18b449(_0x3509ce);const _0xae0f0b=path[_0x5c86e4(0x168)](wrapperBaseDir(),'..','packages',_0x5c86e4(0x1de),_0x5c86e4(0x17b),'index.cjs');_0x18b449(_0xae0f0b);if(_0x36aec7[_0x5c86e4(0x1cb)]>0x0)return _0x36aec7['map']((_0xfab49,_0x34cddd)=>({'candidate':_0xfab49,'index':_0x34cddd,'version':coreVersion(_0xfab49)}))[_0x5c86e4(0x189)]((_0x4615f3,_0x2831d9)=>{const _0x1881a4=_0x5c86e4,_0x10e794=compareSemver(_0x2831d9['version'],_0x4615f3['version']);if(_0x10e794!==0x0)return _0x10e794;return _0x2831d9[_0x1881a4(0x164)]-_0x4615f3[_0x1881a4(0x164)];})[0x0]['candidate'];throw new Error('whalent\x20core\x20runtime'+'\x20not\x20found;\x20install\x20'+_0x5c86e4(0x184)+_0x5c86e4(0x1dc)+'agent');}function coreVersion(_0xaa6ca1=findCoreScript()){const _0x4095df=a0_0x5037bd,_0x3ed9f4=(0x0,import_child_process2['spawnSync'])(process['execPath'],[_0xaa6ca1,'--version'],{'encoding':_0x4095df(0x1aa),'timeout':0x3a98,'env':{...process.env,'WHALENT_SKIP_UPDATE_CHECK':'1'},'shell':![]}),_0x433a4e=(_0x3ed9f4['stdout']||'')+'\x0a'+(_0x3ed9f4['stderr']||'');return _0x433a4e[_0x4095df(0x1b4)](/(\d+\.\d+\.\d+(?:[-\w.]+)?)/)?.[0x1]||'';}function isExecutable(_0xec73a0){const _0x4da705=a0_0x5037bd;try{return fs['accessSync'](_0xec73a0,fs[_0x4da705(0x1d8)][_0x4da705(0x1a9)]),!![];}catch{return![];}}function shellQuote(_0x350593){const _0x293c11=a0_0x5037bd;return'\x27'+_0x350593[_0x293c11(0x158)](/'/g,'\x27\x5c\x27\x27')+'\x27';}function coreNodePtySpawnHelperPath(_0x2087ad){const _0x37f200=a0_0x5037bd;if(process[_0x37f200(0x1d2)]!==_0x37f200(0x144))return'';try{const _0x300f3d=(0x0,import_module[_0x37f200(0x18a)])(_0x2087ad),_0xeae5f9=_0x300f3d['resolve'](_0x37f200(0x159)),_0x36800d=path['resolve'](path[_0x37f200(0x1b7)](_0xeae5f9),'..');return path['join'](_0x36800d,_0x37f200(0x1ae),'darwin-'+process['arch'],'spawn-helper');}catch{return'';}}function checkMacNodePtySpawnHelper(_0x51e5ba){const _0x405a56=a0_0x5037bd,_0xd2dcd9=coreNodePtySpawnHelperPath(_0x51e5ba);if(!_0xd2dcd9||CHECKED_PTY_HELPERS[_0x405a56(0x15e)](_0xd2dcd9))return;CHECKED_PTY_HELPERS['add'](_0xd2dcd9);if(!fs['existsSync'](_0xd2dcd9)){console['warn'](_0x405a56(0x199)+_0x405a56(0x149)+'t\x20found:\x20'+_0xd2dcd9);return;}if(isExecutable(_0xd2dcd9))return;try{const _0x2b0073=fs['statSync'](_0xd2dcd9)[_0x405a56(0x1d4)];fs['chmodSync'](_0xd2dcd9,_0x2b0073|0x1ed);}catch{}if(isExecutable(_0xd2dcd9)){console[_0x405a56(0x1c0)]('[wrapper]\x20fixed\x20macO'+'S\x20node-pty\x20spawn-hel'+_0x405a56(0x1d6)+_0xd2dcd9);return;}console[_0x405a56(0x1c0)]('[wrapper]\x20macOS\x20node'+_0x405a56(0x155)+_0x405a56(0x19a)+_0xd2dcd9),console[_0x405a56(0x1c0)](_0x405a56(0x162)+_0x405a56(0x18e)+'PTY\x20startup:'),console['warn']('\x20\x20HELPER='+shellQuote(_0xd2dcd9)),console[_0x405a56(0x1c0)](_0x405a56(0x1a0)),console[_0x405a56(0x1c0)](_0x405a56(0x153));}function printVersion(){const _0x47d9e4=a0_0x5037bd;let _0x209198='';try{_0x209198=coreVersion();}catch{}console[_0x47d9e4(0x1d7)]('whalent-agent\x20'+WRAPPER_VERSION),console['log'](_0x47d9e4(0x179)+WRAPPER_VERSION),console[_0x47d9e4(0x1d7)](_0x47d9e4(0x1b2)+(_0x209198||'not\x20installed'));}function directCore(_0x5792ac){const _0x498e68=a0_0x5037bd,_0x4e3da3=findCoreScript();checkMacNodePtySpawnHelper(_0x4e3da3);const _0x55398d=(0x0,import_child_process2['spawnSync'])(process[_0x498e68(0x170)],[_0x4e3da3,..._0x5792ac],{'stdio':'inherit','env':{...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_CORE_ENTRY':_0x4e3da3},'shell':![]});process['exit'](_0x55398d['status']??0x0);}function shouldSupervise(_0xbfb32e){const _0x176dca=a0_0x5037bd;if(_0xbfb32e['includes'](_0x176dca(0x1ad)))return![];if(_0xbfb32e[_0x176dca(0x19e)]('--resume')||_0xbfb32e[0x0]===_0x176dca(0x173))return![];const _0x4c4b33=_0xbfb32e[0x0]||'';if(_0x4c4b33==='ls'||_0x4c4b33===_0x176dca(0x167)||_0x4c4b33==='ps')return![];if(_0x4c4b33===_0x176dca(0x1ab)||_0x4c4b33==='daemon-mcp')return![];if(_0xbfb32e['includes'](_0x176dca(0x1b3))||_0xbfb32e[_0x176dca(0x19e)]('-h'))return![];return!![];}function installCoreVersion(_0x1c559b){const _0x303279=a0_0x5037bd,_0x583e52=resolveExecutablePath(_0x303279(0x1c9));if(!_0x583e52)return{'ok':![],'output':_0x303279(0x193)+'H'};const _0x24b4d3=CORE_PKG_NAME+'@'+_0x1c559b,_0x548b3c=run(_0x583e52,['install','-g',_0x24b4d3,npmRegistryArg()]),_0x1e2545=((_0x548b3c['stdout']||'')+'\x0a'+(_0x548b3c['stderr']||''))['trim']();return{'ok':_0x548b3c[_0x303279(0x167)]===0x0,'output':_0x1e2545};}async function superviseCore(_0x1c7690){const _0xf3d7c8=a0_0x5037bd;let _0x2aea46=![],_0x56466a=null;const _0x2bbf15=[];let _0x2cb04e=MIN_RESTART_DELAY_MS;const _0x14fb16=()=>{const _0x8da95a=a0_0x12d6;_0x2aea46=!![];if(_0x56466a&&!_0x56466a[_0x8da95a(0x1a3)])try{_0x56466a[_0x8da95a(0x176)]('SIGTERM');}catch{}else process['exit'](0x0);};process['on'](_0xf3d7c8(0x146),_0x14fb16),process['on'](_0xf3d7c8(0x15a),_0x14fb16);while(!![]){const _0x1bfeee=findCoreScript();checkMacNodePtySpawnHelper(_0x1bfeee);const _0x550fd5={...process.env,'WHALENT_WRAPPER_VERSION':WRAPPER_VERSION,'WHALENT_WRAPPER_MANAGED':'1','WHALENT_CORE_ENTRY':_0x1bfeee},_0x4bdfde=readUpgradeState(),_0x24428b=!!_0x4bdfde?.[_0xf3d7c8(0x1ba)];let _0x9b71c6=![],_0xd3acf0=null,_0xeffd8c='';const _0x3c7c14=[],_0x5f8cd1=0xc;console['log'](_0xf3d7c8(0x17d)+_0xf3d7c8(0x1c7)+_0x1bfeee),_0x56466a=(0x0,import_child_process2['spawn'])(process['execPath'],[_0x1bfeee,..._0x1c7690],{'env':_0x550fd5,'stdio':['inherit',_0xf3d7c8(0x14b),_0xf3d7c8(0x14b)]});const _0x2afd17=()=>{const _0x3ea990=_0xf3d7c8;if(_0x9b71c6)return;_0x9b71c6=!![];if(_0xd3acf0)clearTimeout(_0xd3acf0);_0x2bbf15['length']=0x0,_0x2cb04e=MIN_RESTART_DELAY_MS;const _0x5adfd6=readUpgradeState();_0x5adfd6?.['pending']&&(writeUpgradeState({..._0x5adfd6,'pending':![],'rollback':![],'health_status':_0x3ea990(0x16d)}),console['log']('[wrapper]\x20core\x20upgra'+'de\x20healthy:\x20'+(_0x5adfd6['installed_version']||_0x5adfd6[_0x3ea990(0x180)]||'')));},_0xae01f9=(_0x1df0f7,_0x5920ed=![])=>{const _0x3f7204=_0xf3d7c8,_0x1d200d=_0x1df0f7[_0x3f7204(0x1a2)]();(_0x5920ed?process[_0x3f7204(0x163)]:process[_0x3f7204(0x1bd)])[_0x3f7204(0x1a7)](_0x1d200d);if(_0x5920ed)for(const _0x29f7ea of _0x1d200d[_0x3f7204(0x16e)](/\r?\n/)){if(!_0x29f7ea[_0x3f7204(0x14d)]())continue;_0x3c7c14['push'](_0x29f7ea);if(_0x3c7c14['length']>_0x5f8cd1)_0x3c7c14[_0x3f7204(0x154)]();const _0x1b0acb=_0x29f7ea[_0x3f7204(0x1b4)](FATAL_PATTERN);if(_0x1b0acb)_0xeffd8c=_0x1b0acb[0x0];}(_0x1d200d[_0x3f7204(0x19e)]('[gateway]\x20Connected')||_0x1d200d[_0x3f7204(0x19e)](_0x3f7204(0x150)+_0x3f7204(0x183))||_0x1d200d[_0x3f7204(0x19e)]('Gateway:\x20connected'))&&_0x2afd17();};_0x56466a[_0xf3d7c8(0x1bd)]?.['on']('data',_0x211d95=>_0xae01f9(_0x211d95,![])),_0x56466a['stderr']?.['on']('data',_0x45bfa4=>_0xae01f9(_0x45bfa4,!![]));_0x24428b&&(_0xd3acf0=setTimeout(()=>{const _0x134204=_0xf3d7c8;if(_0x9b71c6||!_0x56466a||_0x56466a['killed'])return;console[_0x134204(0x14c)]('[wrapper]\x20new\x20core\x20d'+_0x134204(0x19c)+_0x134204(0x16f)+'ack');try{_0x56466a[_0x134204(0x176)]('SIGTERM');}catch{}},HEALTH_TIMEOUT_MS));const _0x581f19=await new Promise(_0x40247e=>{_0x56466a['once']('exit',(_0x321448,_0x24e1c3)=>_0x40247e({'code':_0x321448,'signal':_0x24e1c3}));});if(_0xd3acf0)clearTimeout(_0xd3acf0);_0x56466a=null;if(_0x2aea46)process[_0xf3d7c8(0x15b)](_0x581f19[_0xf3d7c8(0x1dd)]??0x0);const _0x55733c=readUpgradeState();if(_0x55733c?.[_0xf3d7c8(0x1ba)]&&!_0x9b71c6){const _0x57c106=String(_0x55733c[_0xf3d7c8(0x186)+'n']||'')['trim']();if(_0x57c106){console[_0xf3d7c8(0x14c)](_0xf3d7c8(0x190)+'ck\x20core\x20to\x20'+_0x57c106);const _0x4ecaa3=installCoreVersion(_0x57c106);writeUpgradeState({..._0x55733c,'pending':![],'rollback':!![],'health_status':_0x4ecaa3['ok']?_0xf3d7c8(0x1ce):_0xf3d7c8(0x1c4),'error':_0x4ecaa3['ok']?'':_0x4ecaa3['output']});}else writeUpgradeState({..._0x55733c,'pending':![],'rollback':!![],'health_status':_0xf3d7c8(0x1cc),'error':'previous\x20core\x20versio'+'n\x20unknown'});}const _0x44ca01=_0x581f19[_0xf3d7c8(0x1dd)]===SUPERVISED_RESTART_CODE||_0x55733c?.[_0xf3d7c8(0x1ba)];if(!_0x44ca01&&_0x581f19[_0xf3d7c8(0x1dd)]===0x0)process['exit'](0x0);const _0xc3e311=Date[_0xf3d7c8(0x172)]();_0x2bbf15['push'](_0xc3e311);while(_0x2bbf15['length']>0x0&&_0xc3e311-_0x2bbf15[0x0]>CRASH_WINDOW_MS){_0x2bbf15['shift']();}const _0x5b2e68=_0x2bbf15['length'];writeLastCrash({'timestamp':_0xc3e311,'exit_code':_0x581f19['code'],'exit_signal':_0x581f19[_0xf3d7c8(0x197)]||null,'fatal_line':_0xeffd8c,'raw_tail':_0x3c7c14[_0xf3d7c8(0x168)]('\x0a'),'consecutive_crashes':_0x5b2e68}),console[_0xf3d7c8(0x1d7)]('[wrapper]\x20core\x20exite'+'d\x20code='+(_0x581f19[_0xf3d7c8(0x1dd)]??'')+(_0x581f19[_0xf3d7c8(0x197)]?_0xf3d7c8(0x1a6)+_0x581f19[_0xf3d7c8(0x197)]:'')+'\x20('+_0x5b2e68+'/'+MAX_CRASHES_IN_WINDOW+'\x20in\x20last\x20'+Math['round'](CRASH_WINDOW_MS/0x3e8)+'s)');if(_0xeffd8c)console['log']('[wrapper]\x20last\x20fatal'+':\x20'+_0xeffd8c);_0x5b2e68>=MAX_CRASHES_IN_WINDOW&&(console['error'](_0xf3d7c8(0x14a)+'d\x20'+_0x5b2e68+'\x20times\x20within\x20'+Math['round'](CRASH_WINDOW_MS/0x3e8)+('s;\x20giving\x20up.\x20Crash\x20'+_0xf3d7c8(0x152))+lastCrashFilePath()+('.\x20Restart\x20wrapper\x20ma'+_0xf3d7c8(0x1db)+_0xf3d7c8(0x17c)+_0xf3d7c8(0x161))),process[_0xf3d7c8(0x15b)](0x1)),console['log'](_0xf3d7c8(0x1c8)+_0xf3d7c8(0x1bb)+_0x2cb04e+'ms'),await new Promise(_0x41110c=>setTimeout(_0x41110c,_0x2cb04e)),_0x2cb04e=Math['min'](_0x2cb04e*0x2,MAX_RESTART_DELAY_MS);}}async function main(){const _0xa6653b=a0_0x5037bd,_0x5be0b5=process['argv'][_0xa6653b(0x1c1)](0x2);if(_0x5be0b5[0x0]==='--version'||_0x5be0b5[0x0]==='-v'||_0x5be0b5[0x0]===_0xa6653b(0x1b9)){printVersion();return;}if((_0x5be0b5[0x0]===_0xa6653b(0x167)||_0x5be0b5[0x0]==='ls'||_0x5be0b5[0x0]==='ps')&&!_0x5be0b5['includes']('--json')){console['log'](_0xa6653b(0x179)+WRAPPER_VERSION);try{console['log']('core\x20'+(coreVersion()||'not\x20installed'));}catch{console['log'](_0xa6653b(0x1b8));}}maybeUpdateWrapper(_0x5be0b5);if(!shouldSupervise(_0x5be0b5))directCore(_0x5be0b5);await superviseCore(_0x5be0b5);}main()['catch'](_0x550cfc=>{const _0x5c8552=a0_0x5037bd;console['error']('[wrapper]\x20Fatal\x20erro'+'r:\x20'+(_0x550cfc?.['message']||String(_0x550cfc))),process[_0x5c8552(0x15b)](0x1);});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@whalent/agent",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.112",
|
|
4
4
|
"description": "Stable wrapper for Whalent Agent core runtime",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"yaml": "^2.4.0"
|
|
44
44
|
},
|
|
45
45
|
"optionalDependencies": {
|
|
46
|
-
"@whalent/agent-core": "0.3.
|
|
46
|
+
"@whalent/agent-core": "0.3.112",
|
|
47
47
|
"node-pty": "^1.1.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|