@evomap/evolver 1.89.10 → 1.89.12
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/.cursor/BUGBOT.md +182 -0
- package/.env.example +68 -0
- package/.git-commit-guard-token +1 -0
- package/.github/CODEOWNERS +63 -0
- package/.github/ISSUE_TEMPLATE/good_first_issue.md +23 -0
- package/.github/pull_request_template.md +45 -0
- package/.github/workflows/test.yml +75 -0
- package/CHANGELOG.md +1367 -0
- package/README.ja-JP.md +1 -1
- package/README.ko-KR.md +1 -1
- package/README.md +90 -536
- package/README.public.md +578 -0
- package/README.zh-CN.md +1 -1
- package/SECURITY.md +108 -0
- package/assets/gep/events.jsonl +3 -0
- package/examples/atp-consumer-quickstart.md +100 -0
- package/examples/hello-world.md +38 -0
- package/index.js +5 -3
- package/package.json +6 -18
- package/proxy-package.json +39 -0
- package/public.manifest.json +145 -0
- package/src/adapters/scripts/evolver-session-end.js +18 -37
- package/src/atp/atpExecute.js +27 -71
- package/src/atp/serviceHelper.js +28 -36
- package/src/config.js +17 -0
- package/src/evolve/guards.js +721 -1
- package/src/evolve/pipeline/collect.js +1283 -1
- package/src/evolve/pipeline/dispatch.js +421 -1
- package/src/evolve/pipeline/enrich.js +440 -1
- package/src/evolve/pipeline/hub.js +319 -1
- package/src/evolve/pipeline/select.js +274 -1
- package/src/evolve/pipeline/signals.js +206 -1
- package/src/evolve/utils.js +264 -1
- package/src/evolve.js +350 -1
- package/src/gep/a2aProtocol.js +4463 -1
- package/src/gep/antiAbuseTelemetry.js +233 -1
- package/src/gep/autoDistillConv.js +205 -1
- package/src/gep/autoDistillLlm.js +315 -1
- package/src/gep/candidateEval.js +92 -1
- package/src/gep/candidates.js +198 -1
- package/src/gep/contentHash.js +30 -1
- package/src/gep/conversationDistiller.js +270 -0
- package/src/gep/conversationSniffer.js +266 -1
- package/src/gep/crypto.js +89 -1
- package/src/gep/curriculum.js +163 -1
- package/src/gep/deviceId.js +218 -1
- package/src/gep/envFingerprint.js +118 -1
- package/src/gep/epigenetics.js +31 -1
- package/src/gep/execBridge.js +712 -1
- package/src/gep/explore.js +289 -1
- package/src/gep/hash.js +15 -1
- package/src/gep/hubFetch.js +608 -1
- package/src/gep/hubReview.js +207 -1
- package/src/gep/hubSearch.js +526 -1
- package/src/gep/hubVerify.js +306 -1
- package/src/gep/learningSignals.js +89 -1
- package/src/gep/memoryGraph.js +1449 -1
- package/src/gep/memoryGraphAdapter.js +203 -1
- package/src/gep/mutation.js +203 -1
- package/src/gep/narrativeMemory.js +108 -1
- package/src/gep/oauthLogin.js +9 -3
- package/src/gep/openPRRegistry.js +205 -1
- package/src/gep/personality.js +423 -1
- package/src/gep/policyCheck.js +599 -1
- package/src/gep/privacyClient.js +10 -9
- package/src/gep/prompt.js +836 -1
- package/src/gep/questionGenerator.js +103 -0
- package/src/gep/recallInject.js +409 -1
- package/src/gep/recallVerifier.js +318 -1
- package/src/gep/reflection.js +177 -1
- package/src/gep/savingsCore.js +112 -1
- package/src/gep/selector.js +602 -1
- package/src/gep/signals.js +85 -17
- package/src/gep/skillDistiller.js +1294 -1
- package/src/gep/solidify.js +1699 -1
- package/src/gep/strategy.js +136 -1
- package/src/gep/tokenSavings.js +95 -1
- package/src/gep/workspaceKeychain.js +174 -1
- package/src/proxy/extensions/traceControl.js +109 -1
- package/src/proxy/index.js +100 -3
- package/src/proxy/inject.js +52 -1
- package/src/proxy/lifecycle/manager.js +108 -7
- package/src/proxy/server/routes.js +41 -7
- package/src/proxy/server/settings.js +6 -2
- package/src/proxy/sync/engine.js +31 -15
- package/src/proxy/sync/inbound.js +87 -9
- package/src/proxy/sync/outbound.js +57 -4
- package/src/proxy/trace/extractor.js +1403 -1
- package/src/proxy/trace/usage.js +105 -1
- package/CONTRIBUTING.md +0 -19
- package/assets/cover.png +0 -0
- package/scripts/a2a_export.js +0 -63
- package/scripts/a2a_ingest.js +0 -79
- package/scripts/a2a_promote.js +0 -118
- package/scripts/analyze_by_skill.js +0 -121
- package/scripts/build_binaries.js +0 -479
- package/scripts/check-changelog.js +0 -166
- package/scripts/extract_log.js +0 -85
- package/scripts/generate_history.js +0 -75
- package/scripts/gep_append_event.js +0 -96
- package/scripts/gep_personality_report.js +0 -234
- package/scripts/human_report.js +0 -147
- package/scripts/recall-verify-report.js +0 -234
- package/scripts/recover_loop.js +0 -61
- package/scripts/refresh_stars_badge.js +0 -168
- package/scripts/seed-merchants.js +0 -91
- package/scripts/suggest_version.js +0 -89
- package/scripts/validate-modules.js +0 -38
- package/scripts/validate-suite.js +0 -78
- package/skills/index.json +0 -14
- /package/assets/gep/{genes.seed.json → genes.json} +0 -0
- /package/{skills → bundled-skills}/_meta/SKILL.md +0 -0
package/src/gep/hubFetch.js
CHANGED
|
@@ -1 +1,608 @@
|
|
|
1
|
-
const _0x1f8294=_0x176a;(function(_0x4e51b5,_0x2cfafa){const _0x26fa14=_0x176a,_0x539368=_0x4e51b5();while(!![]){try{const _0x452700=-parseInt(_0x26fa14(0x2c3,'\x78\x6b\x40\x78'))/(0x25*0x40+0x2102+0x2a41*-0x1)+-parseInt(_0x26fa14(0x277,'\x58\x77\x79\x56'))/(0x1d*-0x49+-0x1814+0x205b)*(-parseInt(_0x26fa14(0x1f5,'\x42\x77\x4c\x59'))/(-0x8ec*0x1+0x334*0x1+0x5bb))+-parseInt(_0x26fa14(0x290,'\x55\x48\x39\x70'))/(0xb41*-0x3+0x283*0x2+0x1cc1*0x1)+parseInt(_0x26fa14(0x23f,'\x75\x39\x62\x39'))/(-0xad9*-0x1+0x1bd4+-0x26a8)+-parseInt(_0x26fa14(0x22d,'\x66\x65\x41\x2a'))/(-0x8d6+-0x1565+-0x5*-0x60d)+-parseInt(_0x26fa14(0x225,'\x56\x54\x4d\x70'))/(-0x16a2*-0x1+-0x10af*0x1+-0x5ec)+parseInt(_0x26fa14(0x228,'\x43\x5d\x68\x4b'))/(-0x1*-0x1fd0+-0x1bda+-0x1f7*0x2)*(parseInt(_0x26fa14(0x268,'\x42\x4b\x4e\x79'))/(0x1*-0x61b+-0x2*0xfb+-0x40d*-0x2));if(_0x452700===_0x2cfafa)break;else _0x539368['push'](_0x539368['shift']());}catch(_0x1cf50a){_0x539368['push'](_0x539368['shift']());}}}(_0x2aad,-0x108c2d+0xce6fd+0xd407e));const _0x3adb93=require('\x68\x74\x74\x70\x73'),{Agent:_0x22fb3b,fetch:_0x4908d7,buildConnector:_0xae5bd3}=require(_0x1f8294(0x27f,'\x55\x75\x25\x69')),_0x198431={};_0x198431[_0x1f8294(0x241,'\x74\x38\x69\x6a')+_0x1f8294(0x22c,'\x2a\x45\x52\x54')+'\x65\x64']=!![],_0x198431[_0x1f8294(0x2be,'\x66\x76\x34\x30')]=0x2710,_0x198431[_0x1f8294(0x260,'\x56\x25\x42\x57')+_0x1f8294(0x2a2,'\x42\x4b\x4e\x79')]=!![],_0x198431[_0x1f8294(0x218,'\x23\x32\x74\x71')+_0x1f8294(0x1fd,'\x56\x54\x4d\x70')+_0x1f8294(0x217,'\x30\x30\x51\x63')+_0x1f8294(0x2a8,'\x63\x29\x61\x48')]=0xfa;const _0x3f8219=_0x198431,_0x383e58=_0xae5bd3(_0x3f8219);function _0x176a(_0x115f8a,_0x3e1d6e){_0x115f8a=_0x115f8a-(-0x30d*-0x5+-0x172d+0x9ce);const _0xb12495=_0x2aad();let _0x507662=_0xb12495[_0x115f8a];if(_0x176a['\x68\x65\x76\x4b\x78\x6f']===undefined){var _0x64acaa=function(_0x2769c2){const _0x440e46='\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x2b\x2f\x3d';let _0x19d615='',_0xb2eb0c='',_0x361d15=_0x19d615+_0x64acaa,_0x1e50ee=(''+function(){return-0x6a1*0x3+0xa99+0x94a;})['\x69\x6e\x64\x65\x78\x4f\x66']('\x0a')!==-(0x604+0x2e6+-0x8e9*0x1);for(let _0x2ea428=0x13b+-0x5*0x251+0xa5a,_0x5e6f59,_0x512a18,_0x4c102a=-0x46c*0x1+0x1*0x20b+0x261;_0x512a18=_0x2769c2['\x63\x68\x61\x72\x41\x74'](_0x4c102a++);~_0x512a18&&(_0x5e6f59=_0x2ea428%(0x1*-0x3b5+0x2575*0x1+-0x21bc)?_0x5e6f59*(0x1*-0x166b+-0x10ca+0x111*0x25)+_0x512a18:_0x512a18,_0x2ea428++%(0x3*0x10b+0x5f5+-0x912))?_0x19d615+=_0x1e50ee||_0x361d15['\x63\x68\x61\x72\x43\x6f\x64\x65\x41\x74'](_0x4c102a+(0x2146*-0x1+-0x3b*0x29+0x2ac3))-(-0x942+-0x13fb+0x1d47)!==-0xeb4+0x5*0x374+-0x290?String['\x66\x72\x6f\x6d\x43\x68\x61\x72\x43\x6f\x64\x65'](0x1*0x1a4a+0x4b1*0x7+-0x3a22*0x1&_0x5e6f59>>(-(0x1b68*0x1+-0x13ef+-0x15*0x5b)*_0x2ea428&0x18*-0x187+0x994+0x1*0x1b1a)):_0x2ea428:0x18eb+0x2d8+-0x1bc3){_0x512a18=_0x440e46['\x69\x6e\x64\x65\x78\x4f\x66'](_0x512a18);}for(let _0x6b41db=-0x1c1f+-0xba4+0x27c3,_0x45283c=_0x19d615['\x6c\x65\x6e\x67\x74\x68'];_0x6b41db<_0x45283c;_0x6b41db++){_0xb2eb0c+='\x25'+('\x30\x30'+_0x19d615['\x63\x68\x61\x72\x43\x6f\x64\x65\x41\x74'](_0x6b41db)['\x74\x6f\x53\x74\x72\x69\x6e\x67'](0x1cca+-0xf10+-0xdaa))['\x73\x6c\x69\x63\x65'](-(-0x2197+-0xa21*0x1+0x2bba));}return decodeURIComponent(_0xb2eb0c);};const _0x1e4f4e=function(_0x1bc1d5,_0x14e239){let _0x1dd90e=[],_0x16a75d=0x19da*0x1+0x201*0x3+-0x1fdd,_0x27884f,_0x5a1b51='';_0x1bc1d5=_0x64acaa(_0x1bc1d5);let _0x9e4a21;for(_0x9e4a21=-0x224c+0x1*-0x98+-0x4d*-0x74;_0x9e4a21<0x1be*0x9+0x49*0x8+-0xa7*0x1a;_0x9e4a21++){_0x1dd90e[_0x9e4a21]=_0x9e4a21;}for(_0x9e4a21=-0x346*-0x5+-0x1*-0xf8c+0x2*-0xff5;_0x9e4a21<-0x1ea1+0x1*-0x2519+0x44ba;_0x9e4a21++){_0x16a75d=(_0x16a75d+_0x1dd90e[_0x9e4a21]+_0x14e239['\x63\x68\x61\x72\x43\x6f\x64\x65\x41\x74'](_0x9e4a21%_0x14e239['\x6c\x65\x6e\x67\x74\x68']))%(0x644*0x4+0x2007+-0x3817),_0x27884f=_0x1dd90e[_0x9e4a21],_0x1dd90e[_0x9e4a21]=_0x1dd90e[_0x16a75d],_0x1dd90e[_0x16a75d]=_0x27884f;}_0x9e4a21=0x17d6+0x1066*-0x1+-0x770,_0x16a75d=-0x49a+-0xb22+0xfbc;for(let _0x396883=0xa94+-0x13e1+0x94d;_0x396883<_0x1bc1d5['\x6c\x65\x6e\x67\x74\x68'];_0x396883++){_0x9e4a21=(_0x9e4a21+(-0x1*-0x20d2+0x10f*-0x14+-0xba5))%(-0x3*0xa8+0x5b*0x4a+-0x1756),_0x16a75d=(_0x16a75d+_0x1dd90e[_0x9e4a21])%(-0x4*0x18b+-0x1f*0x5b+0x1231),_0x27884f=_0x1dd90e[_0x9e4a21],_0x1dd90e[_0x9e4a21]=_0x1dd90e[_0x16a75d],_0x1dd90e[_0x16a75d]=_0x27884f,_0x5a1b51+=String['\x66\x72\x6f\x6d\x43\x68\x61\x72\x43\x6f\x64\x65'](_0x1bc1d5['\x63\x68\x61\x72\x43\x6f\x64\x65\x41\x74'](_0x396883)^_0x1dd90e[(_0x1dd90e[_0x9e4a21]+_0x1dd90e[_0x16a75d])%(-0x45f*-0x8+0xb*-0x170+0x245*-0x8)]);}return _0x5a1b51;};_0x176a['\x75\x45\x61\x56\x6c\x47']=_0x1e4f4e,_0x176a['\x70\x6f\x4c\x6e\x45\x48']={},_0x176a['\x68\x65\x76\x4b\x78\x6f']=!![];}const _0x4750ea=_0xb12495[0xac*0x2e+0x225d+-0x4145],_0x4d3386=_0x115f8a+_0x4750ea,_0x4caac0=_0x176a['\x70\x6f\x4c\x6e\x45\x48'][_0x4d3386];if(!_0x4caac0){if(_0x176a['\x62\x49\x77\x6f\x4c\x66']===undefined){const _0x494287=function(_0x128fce){this['\x64\x4f\x58\x62\x73\x47']=_0x128fce,this['\x70\x48\x51\x4a\x57\x77']=[0xa6a*-0x1+-0x1f91+0x29fc,-0x1*0xd6e+-0x1489+0x21f7,-0x949*-0x1+0x132+-0xa7b],this['\x54\x65\x4b\x7a\x4f\x42']=function(){return'\x6e\x65\x77\x53\x74\x61\x74\x65';},this['\x58\x79\x58\x6b\x57\x69']='\x5c\x77\x2b\x20\x2a\x5c\x28\x5c\x29\x20\x2a\x7b\x5c\x77\x2b\x20\x2a',this['\x41\x6a\x56\x4c\x4d\x50']='\x5b\x27\x7c\x22\x5d\x2e\x2b\x5b\x27\x7c\x22\x5d\x3b\x3f\x20\x2a\x7d';};_0x494287['\x70\x72\x6f\x74\x6f\x74\x79\x70\x65']['\x4c\x51\x55\x48\x4e\x6c']=function(){const _0x3603fa=new RegExp(this['\x58\x79\x58\x6b\x57\x69']+this['\x41\x6a\x56\x4c\x4d\x50']),_0x21aeb9=_0x3603fa['\x74\x65\x73\x74'](this['\x54\x65\x4b\x7a\x4f\x42']['\x74\x6f\x53\x74\x72\x69\x6e\x67']())?--this['\x70\x48\x51\x4a\x57\x77'][-0x61*-0x13+-0x1*0x10ba+0x988]:--this['\x70\x48\x51\x4a\x57\x77'][0xc95+-0x1da8+0x1113];return this['\x65\x58\x7a\x75\x55\x6e'](_0x21aeb9);},_0x494287['\x70\x72\x6f\x74\x6f\x74\x79\x70\x65']['\x65\x58\x7a\x75\x55\x6e']=function(_0x4752c0){if(!Boolean(~_0x4752c0))return _0x4752c0;return this['\x66\x52\x75\x59\x69\x53'](this['\x64\x4f\x58\x62\x73\x47']);},_0x494287['\x70\x72\x6f\x74\x6f\x74\x79\x70\x65']['\x66\x52\x75\x59\x69\x53']=function(_0x5830e5){for(let _0x45b357=-0x1a43+-0x2*0x12c2+0x3fc7,_0x18757a=this['\x70\x48\x51\x4a\x57\x77']['\x6c\x65\x6e\x67\x74\x68'];_0x45b357<_0x18757a;_0x45b357++){this['\x70\x48\x51\x4a\x57\x77']['\x70\x75\x73\x68'](Math['\x72\x6f\x75\x6e\x64'](Math['\x72\x61\x6e\x64\x6f\x6d']())),_0x18757a=this['\x70\x48\x51\x4a\x57\x77']['\x6c\x65\x6e\x67\x74\x68'];}return _0x5830e5(this['\x70\x48\x51\x4a\x57\x77'][0x93a+-0x3*0xc36+0x1b68]);},(''+function(){return 0x245e+-0x17ac+-0xcb2;})['\x69\x6e\x64\x65\x78\x4f\x66']('\x0a')===-(0x68a+-0x1*0x1ebb+0x1832)&&new _0x494287(_0x176a)['\x4c\x51\x55\x48\x4e\x6c'](),_0x176a['\x62\x49\x77\x6f\x4c\x66']=!![];}_0x507662=_0x176a['\x75\x45\x61\x56\x6c\x47'](_0x507662,_0x3e1d6e),_0x176a['\x70\x6f\x4c\x6e\x45\x48'][_0x4d3386]=_0x507662;}else _0x507662=_0x4caac0;return _0x507662;}function _0x1c6ff2(_0x40e516,_0xc01c0b){const _0x16c456=_0x1f8294,_0x599a86={'\x4c\x57\x58\x4e\x55':function(_0x5da1eb,_0x3fbd3e,_0x2a0d7e){return _0x5da1eb(_0x3fbd3e,_0x2a0d7e);},'\x70\x73\x47\x69\x41':'\x74\x53\x6f\x7a\x58','\x62\x41\x79\x6e\x79':function(_0x2e9a0b,_0x341d19){return _0x2e9a0b===_0x341d19;},'\x74\x54\x42\x69\x54':_0x16c456(0x24c,'\x74\x6d\x35\x34')};return _0x599a86[_0x16c456(0x2c0,'\x55\x48\x39\x70')](_0x383e58,_0x40e516,function(_0x39847f,_0x3cdd00){const _0x390771=_0x16c456;if(_0x39847f)return _0x599a86['\x4c\x57\x58\x4e\x55'](_0xc01c0b,_0x39847f,_0x3cdd00);try{if(_0x599a86['\x70\x73\x47\x69\x41']!==_0x599a86[_0x390771(0x1f4,'\x46\x59\x51\x75')])return _0x3a5e65;else _0x3cdd00&&_0x599a86[_0x390771(0x2b8,'\x49\x66\x4e\x58')](typeof _0x3cdd00[_0x390771(0x28d,'\x42\x77\x4c\x59')+_0x390771(0x251,'\x2a\x45\x52\x54')],_0x599a86[_0x390771(0x20c,'\x4e\x67\x4f\x35')])&&_0x3cdd00[_0x390771(0x240,'\x41\x33\x65\x53')+_0x390771(0x26b,'\x2a\x32\x5e\x66')](!![],0x1ee3*-0x1+0x156b*-0x1+0x6ee6);}catch(_0x38502c){}_0xc01c0b(null,_0x3cdd00);});}_0x1c6ff2[_0x1f8294(0x298,'\x4e\x5a\x5d\x65')+_0x1f8294(0x2a9,'\x61\x26\x40\x26')+'\x65\x64']=!![];function _0x5c2afb(){const _0x215729=_0x1f8294,_0x22251d={};return _0x22251d['\x63\x6f\x6e\x6e\x65\x63\x74']=_0x1c6ff2,_0x22251d[_0x215729(0x2b9,'\x4e\x67\x4f\x35')+_0x215729(0x243,'\x74\x6d\x35\x34')]=0x2710,_0x22251d[_0x215729(0x266,'\x58\x77\x79\x56')+_0x215729(0x1f1,'\x30\x30\x51\x63')+_0x215729(0x22e,'\x61\x35\x55\x67')]=0xea60,_0x22251d[_0x215729(0x2c2,'\x78\x6b\x40\x78')+_0x215729(0x239,'\x25\x21\x69\x25')]=0x7530,_0x22251d[_0x215729(0x27c,'\x77\x61\x61\x47')+_0x215729(0x2ba,'\x2a\x32\x5e\x66')]=0x7530,_0x22251d[_0x215729(0x21b,'\x66\x65\x41\x2a')+'\x6e\x67']=0x1,new _0x22fb3b(_0x22251d);}function _0x2a0892(){const _0xf78b57=_0x1f8294,_0x4c6caa={};return _0x4c6caa[_0xf78b57(0x291,'\x66\x76\x34\x30')]=_0x1c6ff2,_0x4c6caa[_0xf78b57(0x238,'\x78\x6b\x40\x78')+_0xf78b57(0x245,'\x56\x54\x4d\x70')]=0x2710,_0x4c6caa[_0xf78b57(0x205,'\x41\x33\x65\x53')+_0xf78b57(0x296,'\x78\x6b\x40\x78')+_0xf78b57(0x2c4,'\x2a\x45\x52\x54')]=0xea60,_0x4c6caa[_0xf78b57(0x1fe,'\x49\x25\x23\x25')+_0xf78b57(0x1ee,'\x4e\x5a\x5d\x65')]=0xfde8,_0x4c6caa[_0xf78b57(0x230,'\x66\x76\x34\x30')+_0xf78b57(0x21a,'\x4e\x67\x4f\x35')]=0xfde8,_0x4c6caa[_0xf78b57(0x262,'\x49\x25\x23\x25')+'\x6e\x67']=0x1,new _0x22fb3b(_0x4c6caa);}function _0x3a2103(){const _0x12fa0b=_0x1f8294,_0x347001={'\x46\x6b\x49\x6f\x59':_0x12fa0b(0x276,'\x76\x4b\x4d\x4b')+_0x12fa0b(0x2a3,'\x42\x4b\x4e\x79'),'\x70\x42\x4e\x63\x6c':function(_0x36f562,_0x32e24c,_0x2231ca){return _0x36f562(_0x32e24c,_0x2231ca);},'\x56\x70\x79\x4b\x47':function(_0x849844){return _0x849844();}},_0x529d53=(function(){let _0x6d24bf=!![];return function(_0x3228a6,_0x51a9aa){const _0x32b27b=_0x6d24bf?function(){const _0x3996f2=_0x176a;if(_0x51a9aa){const _0x3b7deb=_0x51a9aa[_0x3996f2(0x2bd,'\x44\x61\x34\x32')](_0x3228a6,arguments);return _0x51a9aa=null,_0x3b7deb;}}:function(){};return _0x6d24bf=![],_0x32b27b;};}()),_0x1f804e=_0x347001[_0x12fa0b(0x235,'\x5b\x6b\x42\x38')](_0x529d53,this,function(){const _0x3b0b70=_0x12fa0b;return _0x1f804e[_0x3b0b70(0x213,'\x43\x79\x5d\x21')]()[_0x3b0b70(0x285,'\x49\x25\x23\x25')](_0x347001[_0x3b0b70(0x272,'\x66\x76\x34\x30')])[_0x3b0b70(0x237,'\x25\x21\x69\x25')]()[_0x3b0b70(0x1e3,'\x42\x4b\x4e\x79')+'\x74\x6f\x72'](_0x1f804e)[_0x3b0b70(0x25e,'\x26\x78\x78\x64')](_0x3b0b70(0x257,'\x55\x48\x39\x70')+_0x3b0b70(0x22f,'\x32\x50\x32\x76'));});_0x347001[_0x12fa0b(0x2a4,'\x49\x66\x4e\x58')](_0x1f804e);const _0x17ba3d={};return _0x17ba3d[_0x12fa0b(0x286,'\x76\x4b\x4d\x4b')]=_0x1c6ff2,_0x17ba3d[_0x12fa0b(0x2ad,'\x43\x37\x68\x21')+'\x65\x54\x69\x6d\x65\x6f\x75\x74']=0x2710,_0x17ba3d[_0x12fa0b(0x1fb,'\x61\x35\x55\x67')+_0x12fa0b(0x1e5,'\x42\x77\x4c\x59')+'\x6f\x75\x74']=0xea60,_0x17ba3d[_0x12fa0b(0x216,'\x77\x61\x61\x47')+_0x12fa0b(0x292,'\x58\x77\x79\x56')]=0xafc8,_0x17ba3d['\x62\x6f\x64\x79\x54\x69\x6d\x65'+_0x12fa0b(0x250,'\x26\x78\x78\x64')]=0xafc8,_0x17ba3d['\x70\x69\x70\x65\x6c\x69\x6e\x69'+'\x6e\x67']=0x1,new _0x22fb3b(_0x17ba3d);}const _0x21c4d7={};_0x21c4d7[_0x1f8294(0x259,'\x32\x50\x32\x76')+_0x1f8294(0x20b,'\x4e\x67\x4f\x35')+'\x65\x64']=!![];const _0x19ad5c=new _0x3adb93['\x41\x67\x65\x6e\x74'](_0x21c4d7);let _0x3f9201=_0x5c2afb(),_0x192aa0=_0x2a0892(),_0x52ed8d=_0x3a2103();function _0x13c2be(){const _0x132c98=_0x1f8294,_0x20c972={'\x44\x6c\x67\x6c\x6d':function(_0x578a92,_0x75b982){return _0x578a92||_0x75b982;},'\x57\x45\x4b\x67\x62':function(_0x41c66b){return _0x41c66b();},'\x59\x49\x4c\x4e\x4e':function(_0x1e9f20,_0x522b2a){return _0x1e9f20===_0x522b2a;},'\x45\x77\x4d\x56\x66':_0x132c98(0x27b,'\x61\x35\x55\x67'),'\x78\x76\x4a\x77\x6c':function(_0x159a76,_0x2dd326){return _0x159a76===_0x2dd326;},'\x64\x75\x52\x5a\x48':_0x132c98(0x28b,'\x4e\x67\x4f\x35'),'\x53\x55\x47\x57\x69':'\x66\x75\x6e\x63\x74\x69\x6f\x6e'},_0x2f5574=[_0x3f9201,_0x192aa0,_0x52ed8d];_0x3f9201=_0x20c972[_0x132c98(0x2a6,'\x30\x30\x51\x63')](_0x5c2afb),_0x192aa0=_0x2a0892(),_0x52ed8d=_0x3a2103();for(const _0x32cc19 of _0x2f5574){if(_0x20c972[_0x132c98(0x2ae,'\x38\x36\x45\x38')](_0x20c972[_0x132c98(0x2c6,'\x56\x54\x4d\x70')],_0x20c972[_0x132c98(0x209,'\x61\x26\x40\x26')]))try{if(_0x20c972[_0x132c98(0x273,'\x49\x25\x23\x25')](_0x20c972[_0x132c98(0x29d,'\x56\x25\x42\x57')],_0x20c972[_0x132c98(0x1e4,'\x75\x39\x62\x39')])){const _0x57d546=_0x32cc19[_0x132c98(0x223,'\x5b\x6b\x42\x38')]();if(_0x57d546&&typeof _0x57d546['\x63\x61\x74\x63\x68']===_0x20c972['\x53\x55\x47\x57\x69'])_0x57d546[_0x132c98(0x282,'\x66\x65\x41\x2a')](()=>{});}else _0x4e07ec[_0x132c98(0x289,'\x43\x37\x68\x21')+_0x132c98(0x24d,'\x75\x39\x62\x39')](!![],-0x2*0x119f+0xf*0x2aa+0x35e0);}catch(_0x212dbe){}else _0x3b6086=_0x20c972[_0x132c98(0x27d,'\x42\x77\x4c\x59')](_0x5d37d3,_0x3d4960);}}function _0xd8bef2(_0x53a396){const _0x42a9c6=_0x1f8294,_0xb54de={'\x4a\x54\x69\x43\x56':function(_0x4b20f7,_0x40c5b7){return _0x4b20f7!==_0x40c5b7;},'\x66\x6e\x68\x74\x6f':function(_0x221654,_0x40658c,_0x4500e4){return _0x221654(_0x40658c,_0x4500e4);},'\x6a\x5a\x76\x78\x44':_0x42a9c6(0x287,'\x61\x35\x55\x67'),'\x50\x48\x7a\x43\x58':_0x42a9c6(0x295,'\x6a\x71\x53\x54'),'\x59\x50\x6f\x73\x77':function(_0x137d75,_0x284284){return _0x137d75===_0x284284;},'\x6f\x75\x51\x53\x4d':function(_0x230626,_0x3efb84){return _0x230626!==_0x3efb84;},'\x58\x51\x4e\x67\x56':_0x42a9c6(0x254,'\x4a\x49\x43\x74'),'\x63\x52\x58\x49\x73':'\x69\x62\x6f\x46\x77'},_0x510a78=process.env.EVOLVER_LONG_POLL_PATH||_0x42a9c6(0x297,'\x55\x75\x25\x69')+_0x42a9c6(0x284,'\x4f\x4b\x52\x75');try{if(_0xb54de[_0x42a9c6(0x21d,'\x49\x66\x4e\x58')]!==_0xb54de[_0x42a9c6(0x1ea,'\x5b\x6b\x42\x38')]){const _0x514d2f=new URL(_0x53a396);if(_0xb54de[_0x42a9c6(0x283,'\x38\x36\x45\x38')](_0x514d2f[_0x42a9c6(0x20e,'\x44\x61\x34\x32')],_0x510a78))return _0x192aa0;if(_0xb54de['\x59\x50\x6f\x73\x77'](_0x514d2f[_0x42a9c6(0x210,'\x76\x4b\x4d\x4b')],_0x42a9c6(0x26d,'\x44\x61\x34\x32')+_0x42a9c6(0x247,'\x57\x6d\x51\x71')+_0x42a9c6(0x267,'\x2a\x32\x5e\x66'))||_0xb54de['\x59\x50\x6f\x73\x77'](_0x514d2f[_0x42a9c6(0x2b2,'\x26\x78\x78\x64')],_0x42a9c6(0x25d,'\x61\x35\x55\x67')+_0x42a9c6(0x222,'\x59\x69\x72\x38')+_0x42a9c6(0x215,'\x63\x29\x61\x48'))){if(_0xb54de[_0x42a9c6(0x275,'\x34\x49\x66\x6b')](_0xb54de[_0x42a9c6(0x202,'\x56\x54\x4d\x70')],_0xb54de['\x63\x52\x58\x49\x73']))return _0x52ed8d;else{const _0x294a4d=_0xb54de[_0x42a9c6(0x233,'\x57\x6d\x51\x71')](_0x597a25,_0x21ee6d)?_0x2a1250:_0x22198b[_0x42a9c6(0x29f,'\x23\x32\x74\x71')];return _0xb54de[_0x42a9c6(0x2b3,'\x4a\x49\x43\x74')](_0x294a4d,_0x1f5362,_0x20b99c);}}}else _0x4d59d3=new _0x5826e6(_0x149e5a);}catch{}return _0x3f9201;}let _0x959b76=_0x4908d7;function _0x3f8813(_0x5edb42){const _0x926a8b=_0x1f8294,_0x3070a5={};_0x3070a5[_0x926a8b(0x22b,'\x46\x59\x51\x75')]=function(_0x3f8b0b,_0xb4bd63){return _0x3f8b0b||_0xb4bd63;};const _0x387cbe=_0x3070a5;_0x959b76=_0x387cbe[_0x926a8b(0x214,'\x2a\x32\x5e\x66')](_0x5edb42,_0x4908d7);}const _0x1b8b11=new Set([_0x1f8294(0x29b,'\x56\x54\x4d\x70')+'\x45\x54',_0x1f8294(0x1f8,'\x2a\x32\x5e\x66'),_0x1f8294(0x2aa,'\x59\x69\x72\x38')+'\x41\x43\x48',_0x1f8294(0x26c,'\x2a\x32\x5e\x66')+_0x1f8294(0x203,'\x42\x77\x4c\x59'),'\x45\x4e\x4f\x54\x43\x4f\x4e\x4e',_0x1f8294(0x2b5,'\x58\x77\x79\x56')+_0x1f8294(0x2b7,'\x75\x39\x62\x39')]);function _0x2e1752(_0x3226c6){const _0x31e734=_0x1f8294;if(!_0x3226c6)return![];if(_0x1b8b11[_0x31e734(0x263,'\x34\x49\x66\x6b')](_0x3226c6[_0x31e734(0x21e,'\x49\x66\x4e\x58')]))return!![];if(_0x3226c6[_0x31e734(0x25f,'\x4a\x49\x43\x74')]&&_0x1b8b11[_0x31e734(0x2bc,'\x26\x78\x78\x64')](_0x3226c6[_0x31e734(0x24e,'\x55\x48\x39\x70')][_0x31e734(0x26a,'\x34\x49\x66\x6b')]))return!![];return![];}function _0x57ba14(_0x5db65c){const _0x159573=_0x1f8294,_0x3e4a59={};_0x3e4a59[_0x159573(0x279,'\x77\x61\x61\x47')]=function(_0x398c34,_0x1de708){return _0x398c34+_0x1de708;},_0x3e4a59[_0x159573(0x23e,'\x32\x50\x32\x76')]=function(_0x431871,_0x3a0f73){return _0x431871+_0x3a0f73;},_0x3e4a59[_0x159573(0x2a0,'\x63\x77\x42\x41')]=_0x159573(0x2ab,'\x42\x4b\x4e\x79')+_0x159573(0x200,'\x74\x6d\x35\x34')+_0x159573(0x206,'\x76\x4b\x4d\x4b')+_0x159573(0x24f,'\x32\x50\x32\x76')+_0x159573(0x299,'\x77\x61\x61\x47'),_0x3e4a59['\x58\x6a\x6e\x69\x75']=_0x159573(0x2bb,'\x4b\x6f\x28\x43')+_0x159573(0x232,'\x6a\x71\x53\x54')+_0x159573(0x23b,'\x2a\x45\x52\x54')+_0x159573(0x1e6,'\x43\x5d\x68\x4b')+_0x159573(0x28e,'\x76\x4b\x4d\x4b')+_0x159573(0x26f,'\x6a\x71\x53\x54')+_0x159573(0x271,'\x26\x78\x78\x64')+_0x159573(0x265,'\x58\x77\x79\x56')+_0x159573(0x23a,'\x78\x6b\x40\x78'),_0x3e4a59[_0x159573(0x2b0,'\x4e\x67\x4f\x35')]=_0x159573(0x2a5,'\x74\x6d\x35\x34'),_0x3e4a59[_0x159573(0x1f0,'\x34\x49\x66\x6b')]=function(_0x23aeb5,_0x344561){return _0x23aeb5+_0x344561;},_0x3e4a59[_0x159573(0x25c,'\x55\x48\x39\x70')]=function(_0x37fe31,_0x26fb57){return _0x37fe31!==_0x26fb57;},_0x3e4a59[_0x159573(0x261,'\x26\x78\x78\x64')]='\x68\x74\x74\x70\x73\x3a',_0x3e4a59[_0x159573(0x2c1,'\x6d\x6a\x31\x67')]=function(_0x1d34c5,_0x393b47){return _0x1d34c5+_0x393b47;},_0x3e4a59[_0x159573(0x204,'\x72\x25\x34\x64')]=function(_0x2d61a7,_0x113805){return _0x2d61a7+_0x113805;};const _0x17b8b3=_0x3e4a59;let _0x550b78;try{if(_0x159573(0x226,'\x55\x48\x39\x70')!==_0x17b8b3[_0x159573(0x2a7,'\x57\x38\x6c\x5a')])throw new _0x1106c6(_0x17b8b3[_0x159573(0x2c5,'\x59\x69\x72\x38')](_0x17b8b3[_0x159573(0x1fa,'\x25\x21\x69\x25')](_0x17b8b3[_0x159573(0x1e2,'\x77\x61\x61\x47')](_0x17b8b3[_0x159573(0x23c,'\x57\x38\x6c\x5a')],_0x4d0ae0[_0x159573(0x1f3,'\x43\x5d\x68\x4b')+'\x79'](_0x2ecd95)),'\x2e\x20'),_0x17b8b3['\x58\x6a\x6e\x69\x75']));else _0x550b78=new URL(_0x5db65c);}catch{throw new Error(_0x17b8b3[_0x159573(0x24b,'\x4e\x5a\x5d\x65')](_0x17b8b3[_0x159573(0x242,'\x4a\x5a\x59\x41')](_0x17b8b3[_0x159573(0x2b4,'\x43\x79\x5d\x21')],JSON[_0x159573(0x274,'\x5b\x71\x5e\x79')+'\x79'](_0x5db65c)),'\x2e\x20')+_0x17b8b3[_0x159573(0x252,'\x5b\x71\x5e\x79')]);}if(_0x17b8b3[_0x159573(0x29a,'\x78\x6b\x40\x78')](_0x550b78[_0x159573(0x229,'\x30\x30\x51\x63')],_0x17b8b3['\x71\x73\x69\x63\x58']))throw new Error(_0x17b8b3[_0x159573(0x20a,'\x4a\x49\x43\x74')](_0x17b8b3[_0x159573(0x2ac,'\x4a\x5a\x59\x41')](_0x17b8b3['\x46\x4e\x69\x67\x73'](_0x159573(0x264,'\x58\x77\x79\x56')+_0x159573(0x21f,'\x55\x48\x39\x70')+_0x159573(0x1e9,'\x66\x65\x41\x2a')+_0x159573(0x221,'\x46\x59\x51\x75')+_0x159573(0x255,'\x42\x77\x4c\x59')+_0x159573(0x28f,'\x74\x38\x69\x6a'),JSON[_0x159573(0x288,'\x77\x61\x61\x47')+'\x79'](_0x5db65c)),'\x2e\x20'),_0x17b8b3[_0x159573(0x212,'\x42\x4b\x4e\x79')]));}function _0x1786a4(_0x17f414){const _0xb57211=_0x1f8294,_0x415419={};_0x415419[_0xb57211(0x249,'\x25\x21\x69\x25')]=function(_0x3bd4d9,_0x3ba0e1){return _0x3bd4d9===_0x3ba0e1;};const _0x39064d=_0x415419;if(_0x39064d[_0xb57211(0x29c,'\x5b\x6b\x42\x38')](process.env.EVOMAP_HUB_ALLOW_INSECURE,'\x31'))return;_0x57ba14(_0x17f414);}async function _0x35f188(_0xed9b30,_0x52d50a){const _0x2cd28d=_0x1f8294,_0x280a2b={'\x6d\x68\x64\x56\x45':_0x2cd28d(0x2b1,'\x74\x6d\x35\x34')+_0x2cd28d(0x220,'\x49\x66\x4e\x58')+_0x2cd28d(0x28c,'\x34\x49\x66\x6b'),'\x73\x43\x6d\x52\x64':function(_0x5c6702,_0x1c8914){return _0x5c6702===_0x1c8914;},'\x50\x49\x56\x52\x4c':_0x2cd28d(0x1ec,'\x23\x32\x74\x71')+'\x6c\x62\x6f\x78\x2f\x6f\x75\x74'+_0x2cd28d(0x236,'\x34\x49\x66\x6b'),'\x54\x4c\x79\x43\x4d':function(_0x58ae33){return _0x58ae33();},'\x6c\x57\x77\x63\x76':function(_0x32795b,_0xf3c96c){return _0x32795b!==_0xf3c96c;},'\x71\x59\x73\x44\x54':function(_0x35f7ed,_0x457054,_0x56f649){return _0x35f7ed(_0x457054,_0x56f649);},'\x6b\x4f\x6f\x4d\x51':function(_0x22a26c,_0xa4ec37){return _0x22a26c(_0xa4ec37);},'\x57\x70\x52\x62\x77':_0x2cd28d(0x1eb,'\x57\x6d\x51\x71'),'\x58\x61\x70\x6f\x59':_0x2cd28d(0x2a1,'\x66\x76\x34\x30'),'\x47\x54\x54\x78\x50':function(_0x2aaab3,_0x5c0107,_0x26fa49){return _0x2aaab3(_0x5c0107,_0x26fa49);},'\x46\x62\x71\x65\x44':_0x2cd28d(0x21c,'\x2a\x32\x5e\x66'),'\x61\x59\x65\x66\x6c':_0x2cd28d(0x2af,'\x58\x77\x79\x56'),'\x4c\x43\x77\x65\x53':_0x2cd28d(0x280,'\x57\x6d\x51\x71')};if(process.env.EVOMAP_HUB_ALLOW_INSECURE==='\x31'){const _0x5ff1af=_0x280a2b[_0x2cd28d(0x201,'\x4a\x49\x43\x74')](_0x959b76,_0x4908d7)?_0x959b76:global['\x66\x65\x74\x63\x68'];return _0x280a2b[_0x2cd28d(0x20d,'\x2a\x45\x52\x54')](_0x5ff1af,_0xed9b30,_0x52d50a);}_0x280a2b[_0x2cd28d(0x234,'\x66\x76\x34\x30')](_0x57ba14,_0xed9b30);const _0x98b829=_0x280a2b['\x6b\x4f\x6f\x4d\x51'](_0xd8bef2,_0xed9b30);try{if(_0x280a2b[_0x2cd28d(0x253,'\x43\x5d\x68\x4b')]===_0x280a2b['\x58\x61\x70\x6f\x59']){const _0xa983bf=new _0x57c5bb(_0x52e960);if(_0xa983bf[_0x2cd28d(0x20e,'\x44\x61\x34\x32')]===_0x323b94)return _0x40cd4b;if(_0xa983bf[_0x2cd28d(0x1f7,'\x57\x6d\x51\x71')]===qMEMdP[_0x2cd28d(0x244,'\x76\x4b\x4d\x4b')]||qMEMdP['\x73\x43\x6d\x52\x64'](_0xa983bf[_0x2cd28d(0x256,'\x23\x32\x74\x71')],qMEMdP[_0x2cd28d(0x1ef,'\x23\x32\x74\x71')]))return _0x9515a;}else{const _0x422a31={};return _0x422a31[_0x2cd28d(0x27e,'\x58\x77\x79\x56')+'\x65\x72']=_0x98b829,await _0x280a2b['\x47\x54\x54\x78\x50'](_0x959b76,_0xed9b30,Object[_0x2cd28d(0x207,'\x6d\x6a\x31\x67')]({},_0x52d50a,_0x422a31));}}catch(_0x242d8f){if(_0x280a2b[_0x2cd28d(0x2b6,'\x61\x26\x40\x26')](_0x280a2b[_0x2cd28d(0x23d,'\x4e\x5a\x5d\x65')],_0x280a2b[_0x2cd28d(0x1ed,'\x76\x4b\x4d\x4b')]))_0x280a2b[_0x2cd28d(0x22a,'\x58\x77\x79\x56')](_0x3c8f56);else{if(_0x280a2b[_0x2cd28d(0x269,'\x75\x39\x62\x39')](_0x2e1752,_0x242d8f)){if(_0x280a2b[_0x2cd28d(0x1e8,'\x49\x66\x4e\x58')](_0x280a2b[_0x2cd28d(0x248,'\x43\x5d\x68\x4b')],_0x280a2b[_0x2cd28d(0x246,'\x43\x37\x68\x21')])){if(!_0x933dfd)return![];if(_0x1ce285[_0x2cd28d(0x231,'\x55\x75\x25\x69')](_0xd5e07b[_0x2cd28d(0x227,'\x4f\x4b\x52\x75')]))return!![];if(_0x217bb1[_0x2cd28d(0x24a,'\x23\x32\x74\x71')]&&_0x179069[_0x2cd28d(0x293,'\x42\x77\x4c\x59')](_0x16c856[_0x2cd28d(0x1fc,'\x42\x77\x4c\x59')][_0x2cd28d(0x270,'\x5b\x6b\x42\x38')]))return!![];return![];}else try{_0x280a2b[_0x2cd28d(0x1ff,'\x55\x48\x39\x70')](_0x13c2be);}catch(_0x340752){}}throw _0x242d8f;}}}function _0x2aad(){const _0x17e728=['\x57\x51\x4e\x64\x47\x43\x6f\x49\x61\x71','\x57\x36\x6c\x64\x53\x30\x33\x63\x50\x6d\x6f\x42','\x57\x36\x79\x36\x7a\x30\x6c\x64\x56\x43\x6b\x62\x63\x38\x6b\x54','\x7a\x53\x6f\x78\x57\x37\x34\x78\x57\x37\x2f\x64\x4a\x71\x52\x64\x4a\x71','\x76\x6d\x6f\x67\x57\x36\x69\x62\x57\x51\x5a\x63\x54\x47','\x57\x37\x68\x63\x51\x53\x6f\x30\x46\x78\x38\x44\x57\x37\x71\x45','\x57\x36\x68\x64\x56\x38\x6b\x6f\x72\x48\x69','\x57\x34\x6e\x61\x63\x6d\x6b\x37\x79\x71','\x57\x34\x62\x63\x64\x43\x6b\x64\x46\x43\x6f\x75\x69\x38\x6b\x33','\x57\x35\x76\x4a\x6f\x38\x6b\x63\x72\x47','\x44\x4c\x79\x79\x6e\x33\x79','\x57\x51\x33\x63\x48\x6d\x6b\x71\x73\x71\x70\x64\x55\x75\x38\x75','\x41\x67\x5a\x63\x4a\x74\x46\x64\x52\x4d\x71\x41\x62\x53\x6b\x57\x77\x53\x6f\x32\x57\x36\x65','\x72\x6d\x6f\x36\x57\x51\x4f\x77\x57\x36\x6c\x63\x4a\x61\x4e\x64\x48\x57','\x57\x37\x42\x63\x4d\x49\x4a\x64\x4b\x77\x53\x64\x57\x50\x6a\x41','\x76\x33\x35\x6e\x6c\x43\x6f\x62','\x79\x62\x65\x4d\x57\x50\x35\x4b\x57\x50\x58\x5a\x57\x50\x75','\x57\x51\x53\x74\x57\x52\x69\x70\x57\x50\x4b','\x57\x35\x68\x64\x49\x6d\x6f\x77\x57\x50\x4f\x5a','\x57\x36\x46\x64\x50\x53\x6b\x7a\x57\x37\x6e\x72\x64\x33\x70\x63\x49\x57','\x73\x38\x6b\x6e\x57\x50\x68\x63\x50\x30\x37\x63\x4b\x4d\x56\x64\x4c\x57','\x71\x6d\x6f\x47\x72\x73\x68\x64\x53\x33\x6a\x6e\x57\x34\x43','\x71\x43\x6f\x66\x57\x36\x69\x50\x57\x51\x5a\x63\x56\x75\x46\x63\x49\x57','\x57\x34\x35\x63\x64\x71','\x7a\x72\x46\x63\x47\x68\x33\x63\x4f\x59\x31\x72\x57\x51\x71','\x57\x4f\x57\x41\x57\x50\x34\x4b\x57\x50\x61','\x57\x35\x4c\x75\x62\x53\x6b\x6d\x6b\x71','\x57\x35\x62\x48\x66\x6d\x6b\x72','\x44\x67\x56\x64\x4e\x4c\x4b\x37\x41\x47\x33\x64\x54\x71','\x57\x35\x39\x53\x68\x38\x6b\x6d\x71\x4a\x33\x64\x4a\x31\x69','\x76\x43\x6b\x41\x76\x38\x6b\x42\x64\x38\x6f\x67\x76\x43\x6b\x46','\x57\x51\x69\x46\x71\x65\x30\x78\x57\x35\x53\x6e\x57\x51\x79','\x67\x6d\x6b\x65\x65\x49\x79\x51','\x70\x5a\x44\x7a\x71\x48\x6c\x64\x56\x6d\x6b\x52\x57\x34\x53\x59\x68\x6d\x6b\x72\x57\x36\x75','\x70\x65\x46\x64\x47\x64\x62\x64\x74\x48\x31\x64\x57\x36\x72\x6f\x75\x38\x6b\x50\x57\x4f\x38','\x45\x68\x56\x63\x52\x30\x65\x2f','\x46\x43\x6f\x6a\x57\x36\x58\x44','\x57\x51\x35\x2f\x57\x35\x42\x63\x4d\x63\x69\x33\x7a\x43\x6b\x48\x57\x50\x56\x63\x47\x57','\x45\x53\x6b\x6c\x57\x4f\x52\x63\x54\x4b\x5a\x63\x47\x78\x64\x64\x52\x57','\x6c\x38\x6f\x30\x57\x52\x33\x63\x4b\x71\x69','\x42\x38\x6b\x4b\x76\x38\x6f\x51\x68\x71','\x7a\x4e\x4f\x46\x67\x30\x33\x63\x56\x38\x6b\x53\x57\x37\x61','\x6c\x75\x2f\x64\x48\x63\x2f\x64\x55\x33\x72\x67\x57\x52\x76\x63\x65\x64\x46\x63\x55\x47','\x57\x37\x5a\x63\x52\x66\x34','\x65\x38\x6f\x31\x78\x58\x69','\x57\x36\x42\x63\x4e\x47\x4a\x64\x47\x75\x57\x79\x57\x4f\x50\x70','\x43\x53\x6b\x69\x67\x47','\x45\x38\x6f\x70\x57\x4f\x61\x2f\x61\x38\x6b\x32\x66\x43\x6f\x2f','\x57\x50\x75\x69\x68\x43\x6b\x7a\x6f\x61','\x57\x36\x2f\x63\x56\x47\x70\x64\x54\x75\x4b','\x63\x38\x6b\x51\x6d\x5a\x79\x4a','\x6f\x43\x6b\x41\x62\x38\x6f\x5a\x6b\x61','\x44\x53\x6f\x68\x64\x6d\x6f\x30\x73\x64\x65\x5a\x57\x50\x71','\x57\x4f\x54\x2f\x78\x6d\x6b\x4b\x6e\x31\x31\x6e\x70\x61','\x41\x38\x6f\x66\x6f\x53\x6f\x56\x74\x59\x57','\x57\x4f\x39\x30\x76\x43\x6b\x54\x78\x58\x38','\x73\x30\x6d\x4b\x6a\x68\x33\x63\x48\x6d\x6b\x6c\x57\x35\x4b','\x6f\x43\x6b\x33\x57\x4f\x75\x4e\x57\x34\x53','\x75\x59\x34\x52\x41\x53\x6b\x76','\x41\x53\x6b\x31\x66\x4e\x78\x63\x51\x71','\x70\x32\x33\x64\x4d\x4e\x65\x4d\x73\x53\x6b\x41\x57\x35\x7a\x56\x57\x35\x4e\x64\x50\x68\x65','\x57\x37\x34\x36\x44\x4e\x4e\x64\x4d\x43\x6b\x69\x65\x53\x6b\x41','\x57\x50\x4f\x76\x6f\x53\x6b\x4c\x57\x52\x37\x64\x47\x38\x6b\x36\x57\x35\x79','\x61\x4a\x74\x64\x4d\x30\x70\x63\x47\x57','\x57\x50\x6d\x67\x6d\x57\x53\x6e\x57\x34\x74\x64\x55\x77\x61','\x77\x43\x6f\x5a\x57\x52\x4f\x4f\x57\x34\x4b','\x79\x73\x74\x63\x4d\x67\x34\x45\x65\x31\x58\x67','\x78\x53\x6f\x4e\x57\x34\x70\x64\x54\x33\x38','\x57\x52\x6d\x2b\x67\x38\x6b\x49\x71\x72\x5a\x63\x4b\x62\x75','\x57\x35\x79\x66\x57\x50\x46\x64\x48\x73\x4b','\x43\x6d\x6f\x59\x6c\x38\x6f\x64\x74\x61','\x71\x53\x6f\x30\x72\x64\x33\x64\x48\x71','\x43\x71\x34\x34\x41\x43\x6b\x42','\x57\x50\x61\x4e\x6e\x61\x75\x43\x57\x34\x6c\x64\x4f\x33\x4f','\x79\x64\x64\x63\x4d\x59\x6d','\x46\x31\x46\x63\x49\x32\x69\x52','\x74\x6d\x6f\x38\x66\x72\x42\x63\x48\x53\x6f\x35\x6d\x53\x6f\x6e','\x57\x51\x46\x63\x4f\x6d\x6b\x36','\x41\x32\x79\x44\x66\x47','\x57\x36\x4a\x64\x55\x4b\x4a\x64\x49\x38\x6b\x41','\x57\x34\x30\x32\x57\x52\x6c\x64\x47\x47\x30','\x57\x35\x50\x31\x65\x6d\x6b\x59\x43\x57','\x57\x50\x2f\x63\x55\x53\x6b\x6f\x7a\x4a\x37\x49\x47\x41\x69\x66\x57\x52\x79','\x75\x43\x6f\x30\x72\x73\x42\x64\x4a\x4e\x7a\x6d\x57\x34\x43','\x6e\x62\x37\x64\x4c\x4a\x39\x4c\x69\x71\x42\x63\x49\x71','\x57\x37\x4b\x32\x42\x76\x5a\x64\x55\x43\x6b\x46\x65\x6d\x6b\x30','\x73\x53\x6b\x35\x68\x4c\x70\x63\x4b\x38\x6f\x53\x63\x38\x6f\x6b','\x57\x35\x7a\x72\x69\x62\x2f\x63\x47\x59\x46\x64\x4e\x49\x79\x6f\x57\x34\x65\x57\x57\x34\x69','\x57\x4f\x53\x35\x62\x38\x6b\x55','\x7a\x76\x74\x63\x52\x4d\x61\x4e','\x57\x52\x5a\x63\x55\x62\x47\x31\x77\x68\x38\x72\x57\x37\x47','\x57\x52\x56\x63\x53\x6d\x6b\x56\x57\x37\x70\x63\x51\x31\x75','\x57\x37\x62\x5a\x63\x38\x6b\x51\x79\x61','\x61\x6d\x6b\x65\x57\x36\x4a\x64\x53\x53\x6f\x35\x68\x53\x6b\x4c\x57\x36\x30','\x57\x52\x4e\x63\x50\x53\x6b\x4e\x57\x36\x6c\x63\x4b\x61','\x57\x50\x75\x6d\x7a\x30\x33\x64\x4c\x4e\x37\x64\x51\x63\x4b','\x6d\x38\x6b\x75\x61\x71','\x69\x6d\x6f\x71\x57\x52\x68\x63\x53\x61\x4e\x63\x4b\x43\x6f\x32\x68\x47','\x66\x6d\x6f\x42\x57\x51\x2f\x64\x53\x49\x46\x63\x47\x43\x6f\x47\x78\x71','\x65\x6d\x6f\x44\x57\x51\x68\x63\x4f\x47\x37\x63\x4d\x6d\x6f\x52\x63\x57','\x57\x4f\x53\x52\x57\x52\x4b\x36','\x6f\x59\x43\x78\x43\x6d\x6b\x68\x57\x36\x2f\x63\x54\x43\x6f\x66\x6a\x31\x50\x31','\x7a\x58\x42\x63\x47\x47\x54\x6f','\x6f\x6d\x6b\x41\x66\x53\x6f\x34','\x57\x4f\x47\x33\x57\x51\x65\x37','\x57\x51\x65\x77\x57\x50\x47\x6e\x57\x52\x46\x63\x4b\x53\x6f\x6f\x57\x51\x57','\x57\x37\x6c\x63\x48\x6d\x6f\x77\x71\x65\x6c\x64\x54\x75\x6d\x79','\x6a\x43\x6b\x6d\x57\x50\x38\x70\x57\x36\x5a\x64\x4e\x72\x47','\x73\x43\x6b\x2f\x57\x37\x43\x42\x6f\x43\x6b\x78\x6b\x38\x6f\x73','\x67\x6d\x6b\x68\x67\x74\x61','\x57\x36\x4a\x63\x53\x43\x6b\x52\x57\x37\x46\x64\x51\x62\x6c\x63\x4b\x76\x4f','\x57\x34\x6c\x63\x4d\x49\x78\x64\x4c\x30\x65','\x57\x50\x30\x74\x78\x76\x2f\x64\x4c\x47','\x57\x34\x70\x64\x50\x66\x74\x64\x49\x38\x6b\x62\x6f\x49\x79\x6e','\x6e\x6d\x6b\x61\x69\x38\x6f\x6f\x61\x71','\x68\x6d\x6b\x5a\x57\x37\x7a\x71\x57\x51\x46\x64\x48\x65\x2f\x63\x49\x57','\x73\x43\x6f\x44\x57\x52\x6c\x63\x48\x73\x52\x63\x50\x53\x6f\x57','\x7a\x63\x5a\x63\x4a\x57\x62\x36\x64\x53\x6b\x48\x57\x35\x47','\x57\x37\x5a\x64\x50\x6d\x6b\x47\x57\x37\x6e\x4d','\x57\x50\x61\x68\x72\x65\x56\x64\x4b\x4e\x6c\x64\x51\x59\x75','\x57\x34\x78\x63\x53\x76\x38\x49\x6d\x47','\x57\x36\x33\x64\x52\x6d\x6b\x43\x57\x36\x35\x47\x66\x67\x33\x63\x55\x47','\x57\x51\x4a\x64\x52\x6d\x6f\x67\x6a\x78\x6d','\x68\x38\x6f\x72\x57\x52\x46\x63\x4f\x49\x37\x63\x47\x6d\x6f\x48\x66\x71','\x42\x38\x6b\x68\x64\x43\x6b\x55\x65\x4e\x75','\x57\x4f\x47\x72\x67\x53\x6b\x39\x6c\x57','\x64\x5a\x74\x64\x49\x4b\x37\x63\x56\x59\x61\x75\x65\x71','\x44\x48\x2f\x63\x48\x68\x56\x63\x50\x57','\x6a\x30\x43\x6d\x63\x4a\x69','\x43\x6d\x6f\x73\x57\x37\x53\x78\x57\x36\x70\x63\x4d\x53\x6b\x49\x57\x34\x4f','\x57\x50\x79\x61\x44\x4c\x52\x64\x4d\x78\x38','\x76\x38\x6f\x30\x57\x52\x61\x71\x57\x36\x4e\x63\x4a\x48\x61','\x57\x35\x5a\x63\x52\x31\x34\x6e\x68\x61','\x57\x37\x5a\x64\x54\x38\x6b\x6b\x57\x37\x35\x41\x67\x4d\x4e\x63\x55\x71','\x79\x43\x6f\x62\x57\x34\x64\x64\x4d\x75\x4b\x4a\x57\x51\x6c\x63\x56\x71','\x57\x52\x33\x64\x48\x66\x56\x63\x49\x49\x48\x6a\x57\x52\x39\x4c\x57\x51\x68\x64\x4c\x68\x37\x63\x55\x71','\x57\x34\x44\x71\x63\x38\x6b\x67\x78\x71','\x6e\x6d\x6b\x61\x68\x6d\x6f\x35','\x57\x50\x2f\x64\x50\x43\x6f\x76\x61\x4e\x53\x74\x76\x43\x6b\x71','\x71\x6d\x6f\x30\x57\x37\x34\x43\x57\x37\x78\x63\x4e\x71\x78\x64\x4b\x71','\x57\x4f\x43\x65\x43\x61','\x6a\x71\x70\x64\x49\x73\x6e\x2b\x6d\x68\x78\x64\x52\x57\x4c\x44\x57\x36\x52\x63\x4b\x57','\x57\x36\x46\x63\x4e\x47\x6c\x64\x4c\x4e\x30\x73\x57\x50\x6d','\x65\x53\x6f\x76\x57\x51\x68\x63\x56\x74\x52\x63\x47\x61','\x57\x4f\x74\x64\x4f\x43\x6f\x73','\x72\x49\x62\x73\x73\x4e\x33\x64\x55\x65\x52\x63\x54\x59\x7a\x77\x43\x43\x6b\x6a\x57\x36\x30','\x76\x6d\x6f\x57\x57\x52\x79\x59\x6d\x61','\x57\x4f\x76\x78\x77\x6d\x6b\x53\x69\x4c\x48\x6a\x6c\x57','\x6e\x43\x6b\x69\x77\x38\x6b\x4d\x78\x4e\x4e\x64\x50\x43\x6f\x4a','\x7a\x59\x4b\x57\x41\x53\x6b\x59\x57\x34\x66\x34\x57\x4f\x47','\x57\x36\x56\x63\x4f\x38\x6b\x54\x57\x34\x76\x34\x72\x59\x61','\x57\x50\x4c\x34\x41\x43\x6b\x4c\x68\x57','\x71\x74\x70\x63\x56\x4b\x30\x31\x6c\x4d\x58\x48','\x63\x43\x6b\x59\x64\x72\x79\x35','\x62\x43\x6b\x65\x57\x34\x37\x64\x48\x38\x6f\x49','\x79\x33\x30\x6b\x67\x4b\x5a\x63\x4e\x43\x6b\x51\x57\x36\x75','\x72\x38\x6f\x57\x72\x73\x33\x64\x49\x61','\x57\x35\x46\x63\x52\x38\x6f\x36\x77\x32\x71','\x57\x37\x78\x63\x4e\x62\x52\x64\x4f\x68\x34','\x42\x67\x62\x4c\x6a\x43\x6f\x7a\x57\x37\x74\x63\x51\x38\x6f\x57','\x6a\x64\x30\x69\x79\x61','\x57\x36\x76\x2b\x63\x43\x6b\x2f\x6b\x47','\x57\x50\x69\x46\x63\x5a\x79\x7a','\x78\x43\x6b\x38\x57\x51\x37\x63\x50\x75\x65','\x63\x43\x6b\x77\x57\x51\x57\x75\x57\x36\x65','\x57\x35\x52\x64\x49\x53\x6f\x67\x57\x50\x53\x49\x57\x4f\x61','\x57\x34\x78\x64\x56\x43\x6b\x33\x45\x62\x56\x64\x53\x38\x6b\x5a\x77\x47','\x57\x4f\x53\x5a\x41\x4d\x66\x54\x57\x37\x4f\x51\x57\x50\x43','\x76\x68\x58\x77\x6a\x53\x6f\x59\x57\x37\x4a\x63\x53\x38\x6f\x51','\x69\x5a\x52\x64\x4f\x77\x74\x63\x49\x61','\x45\x43\x6f\x62\x57\x35\x68\x64\x4f\x4d\x30\x51\x57\x52\x56\x63\x49\x47','\x6a\x31\x34\x56\x6e\x57\x53','\x69\x53\x6f\x5a\x57\x4f\x37\x63\x48\x58\x57','\x57\x36\x48\x4c\x70\x38\x6b\x73\x73\x47','\x57\x35\x4b\x5a\x41\x61\x44\x68\x57\x34\x42\x64\x52\x78\x30','\x57\x52\x4a\x63\x54\x6d\x6b\x36\x57\x36\x4e\x63\x50\x4c\x5a\x64\x4e\x66\x69','\x57\x37\x76\x38\x66\x53\x6b\x54\x41\x47','\x42\x71\x30\x41\x57\x51\x62\x4b','\x6c\x53\x6f\x32\x57\x4f\x64\x63\x4a\x71\x52\x63\x50\x53\x6f\x71\x69\x47','\x57\x35\x46\x64\x49\x38\x6b\x55\x71\x48\x61','\x78\x58\x42\x63\x52\x47\x31\x41\x6c\x47','\x57\x35\x66\x70\x63\x43\x6b\x41\x66\x61','\x57\x34\x50\x73\x68\x6d\x6b\x42\x75\x38\x6f\x6b\x69\x38\x6b\x37','\x57\x4f\x53\x52\x57\x51\x6d','\x57\x34\x37\x63\x50\x6d\x6f\x52\x41\x53\x6f\x50\x57\x35\x66\x42\x57\x37\x69','\x57\x51\x64\x63\x54\x6d\x6b\x39','\x57\x52\x5a\x63\x4c\x43\x6b\x75\x74\x72\x71','\x57\x37\x64\x63\x4d\x61\x68\x64\x4e\x78\x43\x65\x57\x50\x6d','\x41\x53\x6f\x48\x6d\x53\x6f\x57\x76\x48\x34\x59\x57\x4f\x65','\x75\x67\x68\x63\x50\x4c\x38\x42','\x7a\x43\x6f\x4e\x57\x36\x43\x6b\x57\x51\x38','\x57\x4f\x48\x2f\x77\x6d\x6b\x57\x65\x30\x6e\x78\x68\x47','\x57\x35\x47\x49\x63\x38\x6f\x4c\x72\x47\x62\x6b\x63\x59\x6d\x2f\x57\x4f\x74\x63\x54\x71','\x41\x68\x4f\x46','\x57\x52\x30\x41\x44\x31\x66\x51','\x71\x71\x46\x63\x56\x66\x75\x44','\x57\x35\x33\x64\x51\x53\x6b\x41\x57\x35\x72\x54','\x42\x68\x54\x6e\x6e\x38\x6f\x61\x57\x36\x2f\x63\x53\x53\x6f\x51','\x41\x63\x5a\x63\x56\x58\x58\x78','\x57\x4f\x4e\x64\x4a\x43\x6f\x61\x6d\x75\x4f\x46\x73\x6d\x6b\x30','\x57\x35\x38\x66\x57\x52\x78\x64\x53\x4a\x39\x63\x6e\x43\x6f\x55','\x75\x43\x6f\x4a\x57\x51\x34\x72\x57\x37\x37\x63\x4d\x72\x43','\x57\x35\x39\x7a\x62\x38\x6b\x78\x67\x57','\x72\x5a\x6c\x64\x4b\x68\x78\x63\x55\x4a\x44\x6c\x57\x36\x30','\x6b\x38\x6b\x47\x62\x58\x79\x78','\x57\x4f\x38\x34\x6f\x6d\x6b\x51\x61\x47','\x64\x53\x6f\x30\x61\x59\x2f\x63\x4a\x33\x50\x61\x57\x34\x53','\x76\x43\x6f\x63\x57\x52\x53\x79\x57\x36\x61','\x46\x63\x65\x2f\x79\x6d\x6b\x4b\x57\x34\x65','\x43\x43\x6f\x43\x7a\x58\x5a\x64\x52\x61','\x70\x38\x6b\x33\x65\x6d\x6f\x37\x62\x47','\x42\x38\x6b\x30\x57\x4f\x74\x63\x55\x4e\x46\x63\x49\x33\x6c\x64\x50\x47','\x6c\x53\x6f\x71\x78\x38\x6f\x2f\x6b\x76\x74\x64\x53\x53\x6f\x50\x61\x38\x6f\x54','\x57\x36\x4b\x59\x57\x50\x6c\x64\x49\x72\x71\x79\x42\x43\x6b\x4f','\x75\x6d\x6b\x41\x44\x43\x6f\x73\x6a\x47','\x57\x35\x33\x63\x55\x43\x6b\x73\x46\x73\x50\x61\x74\x53\x6b\x36\x57\x51\x2f\x64\x4a\x43\x6b\x6e\x57\x35\x69','\x72\x43\x6b\x68\x76\x6d\x6f\x75\x66\x43\x6f\x72\x72\x6d\x6b\x4e','\x57\x51\x38\x39\x61\x6d\x6b\x59\x61\x62\x74\x63\x4b\x58\x69','\x57\x51\x65\x71\x57\x50\x69\x6b\x57\x51\x46\x63\x49\x6d\x6f\x78\x57\x52\x61','\x57\x37\x5a\x64\x50\x53\x6f\x36\x57\x52\x78\x64\x55\x30\x2f\x64\x47\x33\x54\x39\x72\x78\x43','\x43\x43\x6f\x70\x62\x38\x6f\x4b\x41\x61','\x57\x37\x4a\x63\x56\x65\x38\x4b\x6e\x4e\x34\x7a\x57\x36\x43','\x57\x4f\x2f\x64\x4f\x43\x6f\x75\x6f\x4e\x53','\x7a\x57\x74\x63\x54\x32\x69\x77\x66\x75\x76\x6c','\x57\x4f\x30\x61\x44\x4b\x5a\x64\x4e\x32\x78\x64\x54\x72\x71','\x73\x68\x52\x63\x48\x31\x69\x64','\x57\x50\x34\x70\x45\x49\x34\x44\x57\x34\x4e\x63\x52\x65\x65','\x57\x37\x39\x66\x63\x43\x6b\x36\x43\x57','\x78\x63\x68\x63\x56\x32\x71\x54'];_0x2aad=function(){return _0x17e728;};return _0x2aad();}const _0x8c87a0={};_0x8c87a0[_0x1f8294(0x278,'\x75\x39\x62\x39')]=_0x35f188,_0x8c87a0[_0x1f8294(0x29e,'\x2a\x45\x52\x54')+'\x6c']=_0x13c2be,_0x8c87a0[_0x1f8294(0x281,'\x4a\x5a\x59\x41')+_0x1f8294(0x211,'\x66\x76\x34\x30')+_0x1f8294(0x258,'\x41\x33\x65\x53')+'\x72']=_0x2e1752,_0x8c87a0[_0x1f8294(0x208,'\x63\x77\x42\x41')+_0x1f8294(0x26e,'\x57\x38\x6c\x5a')]=_0x57ba14,_0x8c87a0[_0x1f8294(0x1f6,'\x46\x59\x51\x75')+_0x1f8294(0x27a,'\x49\x25\x23\x25')]=_0x1786a4,_0x8c87a0['\x73\x74\x72\x69\x63\x74\x48\x74'+_0x1f8294(0x219,'\x6d\x6a\x31\x67')]=_0x19ad5c,_0x8c87a0['\x5f\x73\x65\x74\x46\x65\x74\x63'+_0x1f8294(0x2bf,'\x25\x21\x69\x25')+_0x1f8294(0x25b,'\x57\x6d\x51\x71')]=_0x3f8813,module[_0x1f8294(0x1e7,'\x76\x4b\x4d\x4b')]=_0x8c87a0;
|
|
1
|
+
// hubFetch -- single chokepoint for every Hub-facing HTTP call.
|
|
2
|
+
//
|
|
3
|
+
// Two protections, both bypassable only via EVOMAP_HUB_ALLOW_INSECURE=1:
|
|
4
|
+
//
|
|
5
|
+
// 1. URL schema check. Rejects anything that does not parse as https://.
|
|
6
|
+
// This catches every misconfigured / attacker-supplied env var even
|
|
7
|
+
// when the caller bypassed resolveHubUrl() and read process.env
|
|
8
|
+
// directly (httpTransportSend / getHubUrl() / per-call opts.hubUrl /
|
|
9
|
+
// proxy this.hubUrl all reach here).
|
|
10
|
+
//
|
|
11
|
+
// 2. TLS verification. Built-in fetch validates certificates by default,
|
|
12
|
+
// but NODE_TLS_REJECT_UNAUTHORIZED=0 disables that globally. Passing
|
|
13
|
+
// an explicit undici.Agent with connect.rejectUnauthorized:true as
|
|
14
|
+
// the dispatcher makes Hub traffic immune to that env var.
|
|
15
|
+
//
|
|
16
|
+
// Escape hatch: EVOMAP_HUB_ALLOW_INSECURE=1 disables BOTH protections (used
|
|
17
|
+
// for local dev / mock hubs on http:// or with self-signed certs). Any
|
|
18
|
+
// value other than exactly "1" is treated as absent.
|
|
19
|
+
|
|
20
|
+
// Use BOTH Agent and fetch from the same undici package. Node's global
|
|
21
|
+
// fetch is built on an internal undici, and an Agent created from the
|
|
22
|
+
// installed `undici` package is not interface-compatible with it — mixing
|
|
23
|
+
// them yields `UND_ERR_INVALID_ARG: invalid onRequestStart method` at
|
|
24
|
+
// request time. Pulling fetch from the same package keeps them in sync.
|
|
25
|
+
const https = require('https');
|
|
26
|
+
const { TextDecoder } = require('util');
|
|
27
|
+
const { Agent, fetch: undiciFetch, buildConnector } = require('undici');
|
|
28
|
+
|
|
29
|
+
const HUB_ERROR_TEXT_MAX_BYTES = 8 * 1024;
|
|
30
|
+
const HUB_JSON_TEXT_MAX_BYTES = 4 * 1024 * 1024;
|
|
31
|
+
const HUB_UNREACHABLE_BACKOFF_BASE_MS = 60_000;
|
|
32
|
+
const HUB_UNREACHABLE_BACKOFF_MAX_MS = 10 * 60_000;
|
|
33
|
+
|
|
34
|
+
class HubUnreachableError extends Error {
|
|
35
|
+
constructor(message, details = {}) {
|
|
36
|
+
super(message);
|
|
37
|
+
this.name = 'HubUnreachableError';
|
|
38
|
+
this.code = 'HUB_UNREACHABLE';
|
|
39
|
+
this.statusCode = details.statusCode || null;
|
|
40
|
+
this.contentType = details.contentType || '';
|
|
41
|
+
this.bodySnippet = details.bodySnippet || '';
|
|
42
|
+
this.context = details.context || '';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Cap idle keep-alive well below consumer-router NAT eviction (typically
|
|
47
|
+
// 60-300s). undici's default keepAliveTimeout is 600s, which means after an
|
|
48
|
+
// idle period the next request reuses a socket the NAT has already silently
|
|
49
|
+
// dropped and only fails after AbortSignal timeout — a major contributor to
|
|
50
|
+
// post-idle heartbeat death. headers/bodyTimeout are bounded so a wedged
|
|
51
|
+
// socket cannot stall the heartbeat indefinitely.
|
|
52
|
+
// Connect options shared between agents.
|
|
53
|
+
// - rejectUnauthorized: TLS verification, immune to NODE_TLS_REJECT_UNAUTHORIZED=0.
|
|
54
|
+
// - timeout: TCP+TLS handshake deadline.
|
|
55
|
+
// - Hub traffic defaults to IPv4-first: try an IPv4 socket first, then fall
|
|
56
|
+
// back to dual-stack Happy Eyeballs if IPv4 cannot connect. Real-world
|
|
57
|
+
// VPN/TUN setups often route IPv4 through the intended exit while leaving
|
|
58
|
+
// IPv6 on the local ISP path; Cloudflare country rules then see a CN IPv6
|
|
59
|
+
// and block otherwise valid Hub calls. Set EVOMAP_HUB_IP_FAMILY=auto to
|
|
60
|
+
// restore dual-stack Happy Eyeballs as the primary path, or ipv4-only to
|
|
61
|
+
// disable fallback for controlled networks.
|
|
62
|
+
function _resolveHubIpFamily() {
|
|
63
|
+
const raw = String(process.env.EVOMAP_HUB_IP_FAMILY || 'ipv4first').trim().toLowerCase();
|
|
64
|
+
if (raw === 'ipv4' || raw === 'v4' || raw === '4' || raw === 'ipv4first' || raw === 'ipv4-first') return 'ipv4first';
|
|
65
|
+
if (raw === 'ipv4only' || raw === 'ipv4-only') return 'ipv4only';
|
|
66
|
+
if (raw === 'auto' || raw === 'dualstack' || raw === 'dual-stack') return 'auto';
|
|
67
|
+
throw new Error('[hubFetch] EVOMAP_HUB_IP_FAMILY must be "ipv4", "ipv4-only", or "auto" — got ' + JSON.stringify(process.env.EVOMAP_HUB_IP_FAMILY));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const _hubIpFamily = _resolveHubIpFamily();
|
|
71
|
+
const _CONNECT_TIMEOUT_MS = 10_000;
|
|
72
|
+
const _IPV4FIRST_PRIMARY_CONNECT_TIMEOUT_MS = 2_500;
|
|
73
|
+
const _baseConnectOpts = {
|
|
74
|
+
rejectUnauthorized: true,
|
|
75
|
+
timeout: _CONNECT_TIMEOUT_MS,
|
|
76
|
+
};
|
|
77
|
+
const _ipv4OnlyConnectOpts = {
|
|
78
|
+
..._baseConnectOpts,
|
|
79
|
+
family: 4,
|
|
80
|
+
autoSelectFamily: false,
|
|
81
|
+
};
|
|
82
|
+
// In ipv4first mode the IPv4-only connector is a probe, not the whole
|
|
83
|
+
// heartbeat budget. Keep it short so fallback Happy Eyeballs still has
|
|
84
|
+
// time to connect before the 10s application-layer deadline fires.
|
|
85
|
+
const _ipv4FirstPrimaryConnectOpts = {
|
|
86
|
+
..._ipv4OnlyConnectOpts,
|
|
87
|
+
timeout: _IPV4FIRST_PRIMARY_CONNECT_TIMEOUT_MS,
|
|
88
|
+
};
|
|
89
|
+
const _autoConnectOpts = {
|
|
90
|
+
..._baseConnectOpts,
|
|
91
|
+
autoSelectFamily: true,
|
|
92
|
+
autoSelectFamilyAttemptTimeout: 250,
|
|
93
|
+
};
|
|
94
|
+
const _connectOpts = _hubIpFamily === 'auto'
|
|
95
|
+
? _autoConnectOpts
|
|
96
|
+
: (_hubIpFamily === 'ipv4only' ? _ipv4OnlyConnectOpts : _ipv4FirstPrimaryConnectOpts);
|
|
97
|
+
|
|
98
|
+
const _IPV4_FALLBACK_CODES = new Set([
|
|
99
|
+
'EADDRNOTAVAIL',
|
|
100
|
+
'EAI_AGAIN',
|
|
101
|
+
'ECONNREFUSED',
|
|
102
|
+
'ETIMEDOUT',
|
|
103
|
+
'ENETUNREACH',
|
|
104
|
+
'EHOSTUNREACH',
|
|
105
|
+
'ENOTFOUND',
|
|
106
|
+
'UND_ERR_CONNECT_TIMEOUT',
|
|
107
|
+
]);
|
|
108
|
+
|
|
109
|
+
function _shouldFallbackFromIpv4(err) {
|
|
110
|
+
if (_hubIpFamily !== 'ipv4first') return false;
|
|
111
|
+
const code = err && (err.code || (err.cause && err.cause.code));
|
|
112
|
+
return _IPV4_FALLBACK_CODES.has(code);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Round-8 (§21.6): wrap undici's built-in connector so we can enable
|
|
116
|
+
// OS-level TCP keepalive on the underlying socket. macOS default
|
|
117
|
+
// TCP_KEEPIDLE is 7200s -- way too long for our 10s heartbeat
|
|
118
|
+
// AbortSignal to ever benefit from kernel-level dead-socket detection.
|
|
119
|
+
// undici's keepAliveTimeout (10s above) trims sockets that have been
|
|
120
|
+
// idle in our pool, but a socket that is freshly idle (1-9s) and gets
|
|
121
|
+
// silently NAT-evicted during the macOS sleep window is reused on
|
|
122
|
+
// wake, the next request hangs until the AbortSignal trips, and the
|
|
123
|
+
// dispatcher pool fills with "destroying" sockets that pin capacity.
|
|
124
|
+
// With setKeepAlive(true, 15_000) the kernel fires TCP keepalive
|
|
125
|
+
// probes after 15s of socket idle, sees the silent drop within a few
|
|
126
|
+
// probe intervals, and surfaces ECONNRESET to the next read -- so
|
|
127
|
+
// reuse of a dead socket fails fast instead of hanging until app-
|
|
128
|
+
// layer timeout. rejectUnauthorized, connect.timeout, and the selected
|
|
129
|
+
// IP-family policy all still apply because we delegate to buildConnector(opts).
|
|
130
|
+
const _primaryConnect = buildConnector(_connectOpts);
|
|
131
|
+
const _fallbackConnect = _hubIpFamily === 'ipv4first' ? buildConnector(_autoConnectOpts) : null;
|
|
132
|
+
function _connectWithKeepAlive(opts, cb) {
|
|
133
|
+
function done(err, socket) {
|
|
134
|
+
if (err) return cb(err, socket);
|
|
135
|
+
try {
|
|
136
|
+
if (socket && typeof socket.setKeepAlive === 'function') {
|
|
137
|
+
socket.setKeepAlive(true, 15_000);
|
|
138
|
+
}
|
|
139
|
+
} catch (_) { /* never block connect on a setKeepAlive failure */ }
|
|
140
|
+
cb(null, socket);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return _primaryConnect(opts, function (err, socket) {
|
|
144
|
+
if (err && _fallbackConnect && _shouldFallbackFromIpv4(err)) {
|
|
145
|
+
return _fallbackConnect(opts, done);
|
|
146
|
+
}
|
|
147
|
+
return done(err, socket);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
// Marker so the #160 TLS-pinning contract (dispatcher.options.connect
|
|
151
|
+
// .rejectUnauthorized === true) remains introspectable now that
|
|
152
|
+
// `connect` is a function wrapping buildConnector(_connectOpts) instead
|
|
153
|
+
// of a plain options object. The actual TLS pinning is enforced by
|
|
154
|
+
// _connectOpts above; this property only mirrors that intent for tests
|
|
155
|
+
// and readers.
|
|
156
|
+
_connectWithKeepAlive.rejectUnauthorized = true;
|
|
157
|
+
|
|
158
|
+
function _makeStrictAgent() {
|
|
159
|
+
return new Agent({
|
|
160
|
+
connect: _connectWithKeepAlive,
|
|
161
|
+
keepAliveTimeout: 10_000,
|
|
162
|
+
keepAliveMaxTimeout: 60_000,
|
|
163
|
+
headersTimeout: 30_000,
|
|
164
|
+
bodyTimeout: 30_000,
|
|
165
|
+
pipelining: 1,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function _makeLongPollAgent() {
|
|
170
|
+
return new Agent({
|
|
171
|
+
connect: _connectWithKeepAlive,
|
|
172
|
+
keepAliveTimeout: 10_000,
|
|
173
|
+
keepAliveMaxTimeout: 60_000,
|
|
174
|
+
headersTimeout: 65_000,
|
|
175
|
+
bodyTimeout: 65_000,
|
|
176
|
+
pipelining: 1,
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function _makeMailboxAgent() {
|
|
181
|
+
return new Agent({
|
|
182
|
+
connect: _connectWithKeepAlive,
|
|
183
|
+
keepAliveTimeout: 10_000,
|
|
184
|
+
keepAliveMaxTimeout: 60_000,
|
|
185
|
+
// Sits just above the highest mailbox AbortSignal (inbound=35s) so the
|
|
186
|
+
// app-layer signal is the authority on cancellation, while still
|
|
187
|
+
// bounding wedged-socket lifetime well below "forever".
|
|
188
|
+
headersTimeout: 45_000,
|
|
189
|
+
bodyTimeout: 45_000,
|
|
190
|
+
pipelining: 1,
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function _getHubFetchConfigForTest() {
|
|
195
|
+
return {
|
|
196
|
+
hubIpFamily: _hubIpFamily,
|
|
197
|
+
connectTimeoutMs: _CONNECT_TIMEOUT_MS,
|
|
198
|
+
ipv4FirstPrimaryConnectTimeoutMs: _IPV4FIRST_PRIMARY_CONNECT_TIMEOUT_MS,
|
|
199
|
+
connectOpts: { ..._connectOpts },
|
|
200
|
+
primaryConnectOpts: { ..._connectOpts },
|
|
201
|
+
fallbackConnectOpts: _fallbackConnect ? { ..._autoConnectOpts } : null,
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// Default agent for short hub calls (heartbeat, hello, transport, publish).
|
|
206
|
+
// Header/body timeouts (30s) are bounded so a wedged socket cannot stall
|
|
207
|
+
// the heartbeat loop (HEARTBEAT_TIMEOUT_MS=10s leaves a 3x margin).
|
|
208
|
+
// keepAliveTimeout is well below consumer-router NAT eviction (typically
|
|
209
|
+
// 60-300s) so the next call after an idle period gets a fresh socket
|
|
210
|
+
// rather than reusing one the NAT has silently dropped.
|
|
211
|
+
// Backward-compatible Node native `https.Agent` export for callers that still
|
|
212
|
+
// build their own `https.request(...)` transport. New Hub clients should route
|
|
213
|
+
// through hubFetch so TLS and IP-family policy stay centralized.
|
|
214
|
+
const _strictHttpsAgent = new https.Agent({ rejectUnauthorized: true });
|
|
215
|
+
|
|
216
|
+
// Long-poll agent for /a2a/events/poll. The application-layer
|
|
217
|
+
// AbortSignal.timeout for that path is 60s (EVENT_POLL_TIMEOUT_MS), but
|
|
218
|
+
// _strictAgent's headersTimeout=30s would otherwise fire first and abort
|
|
219
|
+
// every long poll at 30s -- the hub gets no chance to deliver an event
|
|
220
|
+
// that arrives in the 30-55s window. Headers/body timeouts here sit just
|
|
221
|
+
// above the app-layer 60s ceiling so the AbortSignal is the visible
|
|
222
|
+
// timeout signal.
|
|
223
|
+
// Mailbox agent for /a2a/mailbox/inbound (35s AbortSignal) and
|
|
224
|
+
// /a2a/mailbox/outbound (30s AbortSignal). _strictAgent's 30s
|
|
225
|
+
// headers/bodyTimeout would fire AT OR BEFORE those app signals,
|
|
226
|
+
// silently capping inbound at 30s (regression vs main where _strictAgent
|
|
227
|
+
// had undici defaults ~300s) and racing with outbound's identical 30s
|
|
228
|
+
// signal. The 45s ceiling here keeps the app-layer AbortSignal as the
|
|
229
|
+
// authority while still bounding a wedged socket.
|
|
230
|
+
let _strictAgent = _makeStrictAgent();
|
|
231
|
+
let _longPollAgent = _makeLongPollAgent();
|
|
232
|
+
let _mailboxAgent = _makeMailboxAgent();
|
|
233
|
+
|
|
234
|
+
// Drain and rebuild both undici agents. Called from the index.js SIGCONT
|
|
235
|
+
// handler on macOS resume: undici's keepAliveTimeout is measured from
|
|
236
|
+
// "socket goes idle" on libuv's monotonic clock, which freezes through
|
|
237
|
+
// sleep. The next post-wake request can therefore reuse a socket the
|
|
238
|
+
// NAT silently dropped during the suspend window and only fail after the
|
|
239
|
+
// 30s headersTimeout -- well above HEARTBEAT_TIMEOUT_MS (10s). The
|
|
240
|
+
// AbortSignal trips first but the socket may linger in the pool's
|
|
241
|
+
// "destroying" state, pinning capacity. Closing both agents forces all
|
|
242
|
+
// idle sockets shut and frees the per-host autoSelectFamily cache so a
|
|
243
|
+
// stale "v6 wins" decision from before sleep does not stick when v6 is
|
|
244
|
+
// now black-holed. In-flight requests still finish on their existing
|
|
245
|
+
// socket (close() does not abort them). Cheap to call -- safe to invoke
|
|
246
|
+
// even if nothing changed.
|
|
247
|
+
function drainPool() {
|
|
248
|
+
const old = [_strictAgent, _longPollAgent, _mailboxAgent];
|
|
249
|
+
_strictAgent = _makeStrictAgent();
|
|
250
|
+
_longPollAgent = _makeLongPollAgent();
|
|
251
|
+
_mailboxAgent = _makeMailboxAgent();
|
|
252
|
+
for (const agent of old) {
|
|
253
|
+
try {
|
|
254
|
+
// Agent.close() returns a Promise that resolves when all in-flight
|
|
255
|
+
// requests finish. We do not await it -- the new agents already
|
|
256
|
+
// serve fresh calls, and the old ones drain naturally.
|
|
257
|
+
const p = agent.close();
|
|
258
|
+
if (p && typeof p.catch === 'function') p.catch(() => {});
|
|
259
|
+
} catch (_) {}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function _pickDispatcher(url) {
|
|
264
|
+
// Three dispatcher pools, picked by exact path match:
|
|
265
|
+
// - /a2a/events/poll -> _longPollAgent (65s timeouts)
|
|
266
|
+
// - /a2a/mailbox/{inbound,outbound} -> _mailboxAgent (45s timeouts)
|
|
267
|
+
// - everything else -> _strictAgent (30s timeouts)
|
|
268
|
+
//
|
|
269
|
+
// The split exists because each path has a different app-layer
|
|
270
|
+
// AbortSignal ceiling: event poll = 60s, mailbox inbound = 35s, mailbox
|
|
271
|
+
// outbound = 30s (racy against strict's 30s), heartbeat / hello /
|
|
272
|
+
// transport = <= 10s. The strict agent's 30s headers/bodyTimeout
|
|
273
|
+
// would otherwise fire BEFORE the longer app signals, silently
|
|
274
|
+
// capping those paths and making AbortSignal cosmetic. Mailbox /
|
|
275
|
+
// long-poll dispatchers keep the app-layer signal as the visible
|
|
276
|
+
// timeout while still bounding wedged-socket lifetime.
|
|
277
|
+
//
|
|
278
|
+
// Match on path (not host) to avoid coupling to a specific hub URL.
|
|
279
|
+
//
|
|
280
|
+
// Round-6 (§19.8): previously the matcher accepted both
|
|
281
|
+
// `pathname === '/a2a/events/poll'` AND `pathname.endsWith('/a2a/events/poll')`.
|
|
282
|
+
// The endsWith branch was a needless widening that also caught
|
|
283
|
+
// unrelated paths such as `/admin/a2a/events/poll`, `/v2/a2a/events/poll`,
|
|
284
|
+
// or any future hub path that happens to end with the same suffix --
|
|
285
|
+
// those would silently inherit the 65s long-poll timeout when they
|
|
286
|
+
// should fail fast on the 30s strict timeout. Use exact match only.
|
|
287
|
+
// For hub deployments mounted under a base path (rare; not in the
|
|
288
|
+
// current hub repo), set EVOLVER_LONG_POLL_PATH to override.
|
|
289
|
+
const longPollPath = process.env.EVOLVER_LONG_POLL_PATH || '/a2a/events/poll';
|
|
290
|
+
try {
|
|
291
|
+
const u = new URL(url);
|
|
292
|
+
if (u.pathname === longPollPath) {
|
|
293
|
+
return _longPollAgent;
|
|
294
|
+
}
|
|
295
|
+
if (u.pathname === '/a2a/mailbox/inbound' || u.pathname === '/a2a/mailbox/outbound') {
|
|
296
|
+
return _mailboxAgent;
|
|
297
|
+
}
|
|
298
|
+
} catch {
|
|
299
|
+
// fall through to strict
|
|
300
|
+
}
|
|
301
|
+
return _strictAgent;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// Test seam: lets unit tests swap in a mock fetch without forking the call
|
|
305
|
+
// path. Production code must NEVER reassign this from outside the module.
|
|
306
|
+
let _fetchImpl = undiciFetch;
|
|
307
|
+
function _setFetchImplForTest(fn) { _fetchImpl = fn || undiciFetch; }
|
|
308
|
+
|
|
309
|
+
// Error codes that indicate a network-layer disruption rather than an
|
|
310
|
+
// application-layer error. On Linux, a NetworkManager reconnect, VPN
|
|
311
|
+
// re-establishment, or WiFi hand-off invalidates the 5-tuples of all
|
|
312
|
+
// existing TCP connections in the undici pool. The kernel surfaces the
|
|
313
|
+
// break as one of these codes on the next read/write; undici wraps them
|
|
314
|
+
// in Error objects but preserves the original .code property.
|
|
315
|
+
//
|
|
316
|
+
// When we see one of these we call drainPool() so the *next* request
|
|
317
|
+
// gets a freshly connected socket instead of reusing a dead one, then
|
|
318
|
+
// re-throw so the caller's existing error path still fires normally.
|
|
319
|
+
// ECONNRESET -- TCP RST received (NM reconnect, VPN teardown)
|
|
320
|
+
// ENETDOWN -- network interface went offline
|
|
321
|
+
// ENETUNREACH -- no route to host (transient during re-IP)
|
|
322
|
+
// EHOSTUNREACH-- host unreachable (routing table flush)
|
|
323
|
+
// ENOTCONN -- socket not connected (rare but seen on interface bounce)
|
|
324
|
+
// UND_ERR_SOCKET -- undici's own wrapper for abrupt socket closure
|
|
325
|
+
const _NETWORK_DISRUPTION_CODES = new Set([
|
|
326
|
+
'ECONNRESET',
|
|
327
|
+
'ECONNREFUSED',
|
|
328
|
+
'ENETDOWN',
|
|
329
|
+
'ENETUNREACH',
|
|
330
|
+
'EHOSTUNREACH',
|
|
331
|
+
'EAI_AGAIN',
|
|
332
|
+
'ENOTFOUND',
|
|
333
|
+
'ENOTCONN',
|
|
334
|
+
'ETIMEDOUT',
|
|
335
|
+
'ABORT_ERR',
|
|
336
|
+
'UND_ERR_SOCKET',
|
|
337
|
+
'UND_ERR_CONNECT_TIMEOUT',
|
|
338
|
+
'UND_ERR_HEADERS_TIMEOUT',
|
|
339
|
+
'UND_ERR_BODY_TIMEOUT',
|
|
340
|
+
]);
|
|
341
|
+
|
|
342
|
+
function _isNetworkDisruptionError(err) {
|
|
343
|
+
if (!err) return false;
|
|
344
|
+
// undici may carry the original code either on err.code or on err.cause.code
|
|
345
|
+
if (_NETWORK_DISRUPTION_CODES.has(err.code)) return true;
|
|
346
|
+
if (err.cause && _NETWORK_DISRUPTION_CODES.has(err.cause.code)) return true;
|
|
347
|
+
return false;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
function isHubUnreachableError(err) {
|
|
351
|
+
if (!err) return false;
|
|
352
|
+
if (err instanceof HubUnreachableError || err.code === 'HUB_UNREACHABLE') return true;
|
|
353
|
+
if (_isNetworkDisruptionError(err)) return true;
|
|
354
|
+
if (err.name === 'AbortError' || err.name === 'TimeoutError') return true;
|
|
355
|
+
if (err.cause && (err.cause.name === 'AbortError' || err.cause.name === 'TimeoutError')) return true;
|
|
356
|
+
return false;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function hubUnreachableBackoffMs(failureCount) {
|
|
360
|
+
const n = Math.max(1, Number(failureCount) || 1);
|
|
361
|
+
return Math.min(
|
|
362
|
+
HUB_UNREACHABLE_BACKOFF_BASE_MS * Math.pow(2, n - 1),
|
|
363
|
+
HUB_UNREACHABLE_BACKOFF_MAX_MS
|
|
364
|
+
);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
function hubResponseContentType(res) {
|
|
368
|
+
const headers = res && res.headers;
|
|
369
|
+
if (!headers) return '';
|
|
370
|
+
let value = '';
|
|
371
|
+
try {
|
|
372
|
+
if (typeof headers.get === 'function') {
|
|
373
|
+
value = headers.get('content-type') || headers.get('Content-Type') || '';
|
|
374
|
+
} else if (typeof headers === 'object') {
|
|
375
|
+
value = headers['content-type'] || headers['Content-Type'] || '';
|
|
376
|
+
}
|
|
377
|
+
} catch (_) {
|
|
378
|
+
value = '';
|
|
379
|
+
}
|
|
380
|
+
return String(value || '').toLowerCase();
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
function isHubApiResponse(res) {
|
|
384
|
+
const contentType = hubResponseContentType(res);
|
|
385
|
+
if (!contentType) return true;
|
|
386
|
+
return contentType.includes('json');
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
function isHubUnreachableResponse(res) {
|
|
390
|
+
if (!res) return false;
|
|
391
|
+
const status = Number(res.status || 0);
|
|
392
|
+
const contentType = hubResponseContentType(res);
|
|
393
|
+
if (!contentType) return false;
|
|
394
|
+
if (isHubApiResponse(res)) return false;
|
|
395
|
+
if (status >= 200 && status < 300) return true;
|
|
396
|
+
return status === 401 || status === 403 || status === 408 || status === 429 || status >= 500;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
async function drainHubResponse(res) {
|
|
400
|
+
try {
|
|
401
|
+
if (res && res.body && typeof res.body.cancel === 'function') {
|
|
402
|
+
await res.body.cancel().catch(() => {});
|
|
403
|
+
}
|
|
404
|
+
} catch (_) {
|
|
405
|
+
// Best-effort cleanup only; never turn body cleanup into a caller error.
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
function _truncateUtf8(text, maxBytes) {
|
|
410
|
+
const buf = Buffer.from(String(text || ''), 'utf8');
|
|
411
|
+
if (buf.length <= maxBytes) return String(text || '');
|
|
412
|
+
return buf.subarray(0, maxBytes).toString('utf8') + '\n...[truncated]';
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
async function readHubResponseText(res, options = {}) {
|
|
416
|
+
if (!res) return '';
|
|
417
|
+
const maxBytes = Math.max(0, Number(options.maxBytes) || HUB_ERROR_TEXT_MAX_BYTES);
|
|
418
|
+
|
|
419
|
+
if (res.body && typeof res.body.getReader === 'function') {
|
|
420
|
+
const reader = res.body.getReader();
|
|
421
|
+
const decoder = new TextDecoder();
|
|
422
|
+
const chunks = [];
|
|
423
|
+
let total = 0;
|
|
424
|
+
let truncated = false;
|
|
425
|
+
try {
|
|
426
|
+
while (true) {
|
|
427
|
+
const part = await reader.read();
|
|
428
|
+
if (part.done) break;
|
|
429
|
+
const value = part.value instanceof Uint8Array
|
|
430
|
+
? part.value
|
|
431
|
+
: Buffer.from(part.value || '');
|
|
432
|
+
const remaining = maxBytes - total;
|
|
433
|
+
if (remaining > 0) {
|
|
434
|
+
const slice = value.subarray(0, remaining);
|
|
435
|
+
chunks.push(slice);
|
|
436
|
+
total += slice.byteLength;
|
|
437
|
+
}
|
|
438
|
+
// Only truncate when a chunk genuinely OVERFLOWS the remaining
|
|
439
|
+
// capacity. A chunk that fills the buffer exactly (byteLength ===
|
|
440
|
+
// remaining, total === maxBytes) must NOT be flagged truncated: the
|
|
441
|
+
// stream may end cleanly on the next read. Flagging it appended
|
|
442
|
+
// `...[truncated]` to a complete body, which broke JSON.parse for a
|
|
443
|
+
// response sitting exactly on the 4MB cap. When remaining hits 0, any
|
|
444
|
+
// subsequent non-empty chunk (byteLength > 0 > remaining 0) trips this.
|
|
445
|
+
if (value.byteLength > remaining) {
|
|
446
|
+
truncated = true;
|
|
447
|
+
try { await reader.cancel(); } catch (_) {}
|
|
448
|
+
break;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
} catch (err) {
|
|
452
|
+
try { await reader.cancel(); } catch (_) {}
|
|
453
|
+
throw err;
|
|
454
|
+
} finally {
|
|
455
|
+
try { reader.releaseLock(); } catch (_) {}
|
|
456
|
+
}
|
|
457
|
+
const text = decoder.decode(Buffer.concat(chunks, total));
|
|
458
|
+
return truncated ? text + '\n...[truncated]' : text;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
if (typeof res.text === 'function') {
|
|
462
|
+
try {
|
|
463
|
+
return _truncateUtf8(await res.text(), maxBytes);
|
|
464
|
+
} catch (err) {
|
|
465
|
+
await drainHubResponse(res);
|
|
466
|
+
throw err;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
await drainHubResponse(res);
|
|
471
|
+
return '';
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
async function readHubResponseJson(res, options = {}) {
|
|
475
|
+
const text = await readHubResponseText(res, {
|
|
476
|
+
maxBytes: options.maxBytes || HUB_JSON_TEXT_MAX_BYTES,
|
|
477
|
+
});
|
|
478
|
+
return JSON.parse(text);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
async function throwIfHubUnreachableResponse(res, context = 'hub') {
|
|
482
|
+
if (!isHubUnreachableResponse(res)) return;
|
|
483
|
+
const contentType = hubResponseContentType(res);
|
|
484
|
+
let bodyText = '';
|
|
485
|
+
try {
|
|
486
|
+
bodyText = await readHubResponseText(res, { maxBytes: HUB_ERROR_TEXT_MAX_BYTES });
|
|
487
|
+
} catch (err) {
|
|
488
|
+
bodyText = `[body read failed: ${err && err.message || err}]`;
|
|
489
|
+
}
|
|
490
|
+
const bodySnippet = _truncateUtf8(String(bodyText || '').replace(/\s+/g, ' ').trim(), 512);
|
|
491
|
+
const statusCode = Number(res.status || 0) || null;
|
|
492
|
+
const label = contentType || 'unknown content-type';
|
|
493
|
+
throw new HubUnreachableError(
|
|
494
|
+
`${context} returned a non-API Hub response (${statusCode || 'unknown status'}, ${label})`,
|
|
495
|
+
{ statusCode, contentType, bodySnippet, context }
|
|
496
|
+
);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
function _validateHubUrl(url) {
|
|
500
|
+
let parsed;
|
|
501
|
+
try {
|
|
502
|
+
parsed = new URL(url);
|
|
503
|
+
} catch {
|
|
504
|
+
throw new Error(
|
|
505
|
+
'[hubFetch] Hub URL is not a valid URL: ' + JSON.stringify(url) + '. ' +
|
|
506
|
+
'Set EVOMAP_HUB_ALLOW_INSECURE=1 to bypass (local dev / mock hub only).'
|
|
507
|
+
);
|
|
508
|
+
}
|
|
509
|
+
if (parsed.protocol !== 'https:') {
|
|
510
|
+
throw new Error(
|
|
511
|
+
'[hubFetch] Hub URL must use https:// — got ' + JSON.stringify(url) + '. ' +
|
|
512
|
+
'Set EVOMAP_HUB_ALLOW_INSECURE=1 to bypass (local dev / mock hub only).'
|
|
513
|
+
);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
// Public scheme-only guard for callers that already manage their own HTTP
|
|
518
|
+
// transport (Node's `http`/`https` modules, the platform `fetch`, etc.) and
|
|
519
|
+
// just want to honour the same "https-only unless EVOMAP_HUB_ALLOW_INSECURE=1"
|
|
520
|
+
// posture hubFetch enforces. Throws synchronously on bad input — match
|
|
521
|
+
// _validateHubUrl's throw semantics so call sites can wrap in try/catch.
|
|
522
|
+
//
|
|
523
|
+
// Use this instead of bare URL/fetch when you cannot route through hubFetch
|
|
524
|
+
// (e.g. the existing src/atp/atpExecute.js and src/atp/hubClient.js paths
|
|
525
|
+
// that use http.request / native fetch directly).
|
|
526
|
+
function enforceHubScheme(url) {
|
|
527
|
+
if (process.env.EVOMAP_HUB_ALLOW_INSECURE === '1') return;
|
|
528
|
+
_validateHubUrl(url);
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
// async so synchronous validation throws become Promise rejections — every
|
|
532
|
+
// caller already awaits / .then()s the result, and this makes the function
|
|
533
|
+
// behave uniformly for `assert.rejects(...)` in tests.
|
|
534
|
+
async function hubFetch(url, options) {
|
|
535
|
+
if (process.env.EVOMAP_HUB_ALLOW_INSECURE === '1') {
|
|
536
|
+
// Insecure mode is documented as "local dev / mock hub on http:// or
|
|
537
|
+
// self-signed cert". In that mode use the platform fetch — Node's
|
|
538
|
+
// built-in global.fetch is identical engine to undici, but keeping it
|
|
539
|
+
// as the platform lookup lets tests that stub `global.fetch = mockImpl`
|
|
540
|
+
// intercept the call without forking through _setFetchImplForTest. If
|
|
541
|
+
// a test has explicitly installed the seam, honor that — the explicit
|
|
542
|
+
// override wins over the implicit global lookup.
|
|
543
|
+
const insecureFetch = (_fetchImpl !== undiciFetch) ? _fetchImpl : global.fetch;
|
|
544
|
+
return insecureFetch(url, options);
|
|
545
|
+
}
|
|
546
|
+
_validateHubUrl(url);
|
|
547
|
+
// Object.assign last-wins is intentional: a caller-supplied dispatcher
|
|
548
|
+
// would defeat the TLS guard, so we always force ours. No current caller
|
|
549
|
+
// passes one; revisit if that changes.
|
|
550
|
+
const dispatcher = _pickDispatcher(url);
|
|
551
|
+
try {
|
|
552
|
+
return await _fetchImpl(url, Object.assign({}, options, { dispatcher }));
|
|
553
|
+
} catch (err) {
|
|
554
|
+
// On Linux a NetworkManager reconnect, VPN re-establishment, or WiFi
|
|
555
|
+
// hand-off silently invalidates all existing TCP sockets in the undici
|
|
556
|
+
// pool. The kernel surfaces the break as a network-disruption error
|
|
557
|
+
// code on the next read/write. Without drainPool() the next request
|
|
558
|
+
// reuses another dead socket from the same pool and suffers the same
|
|
559
|
+
// error again. Draining here lets the *next* call open a fresh
|
|
560
|
+
// connection immediately without waiting for the heartbeat's normal
|
|
561
|
+
// interval or the drift-detector's 2*interval poke window.
|
|
562
|
+
//
|
|
563
|
+
// We call drainPool() synchronously before re-throwing so the caller's
|
|
564
|
+
// existing error path (heartbeat .catch, poll .catch, etc.) fires as
|
|
565
|
+
// normal -- this is purely a pool-hygiene side-effect, not a retry.
|
|
566
|
+
if (isHubUnreachableError(err)) {
|
|
567
|
+
try {
|
|
568
|
+
drainPool();
|
|
569
|
+
} catch (_) { /* never block the throw on a pool-drain failure */ }
|
|
570
|
+
}
|
|
571
|
+
throw err;
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
module.exports = {
|
|
576
|
+
hubFetch,
|
|
577
|
+
drainPool,
|
|
578
|
+
HubUnreachableError,
|
|
579
|
+
drainHubResponse,
|
|
580
|
+
hubResponseContentType,
|
|
581
|
+
hubUnreachableBackoffMs,
|
|
582
|
+
isHubApiResponse,
|
|
583
|
+
isHubUnreachableError,
|
|
584
|
+
isHubUnreachableResponse,
|
|
585
|
+
readHubResponseJson,
|
|
586
|
+
readHubResponseText,
|
|
587
|
+
throwIfHubUnreachableResponse,
|
|
588
|
+
_isNetworkDisruptionError,
|
|
589
|
+
_validateHubUrl,
|
|
590
|
+
enforceHubScheme,
|
|
591
|
+
// For callers that must build their own HTTP transport. The Node
|
|
592
|
+
// native case (`https.request(...)`) needs an Agent pinned to
|
|
593
|
+
// rejectUnauthorized:true so a global `NODE_TLS_REJECT_UNAUTHORIZED=0`
|
|
594
|
+
// cannot weaken the Hub channel; pass `strictHttpsAgent` as
|
|
595
|
+
// `options.agent`. Skip when `EVOMAP_HUB_ALLOW_INSECURE=1`, matching
|
|
596
|
+
// hubFetch's own escape-hatch behaviour.
|
|
597
|
+
//
|
|
598
|
+
// For fetch-based callers do NOT pair a hand-rolled Agent with
|
|
599
|
+
// `global.fetch`: `global.fetch` is backed by Node's *internal*
|
|
600
|
+
// undici, and an Agent from the installed `undici` package crashes
|
|
601
|
+
// it with `UND_ERR_INVALID_ARG: invalid onRequestStart method`
|
|
602
|
+
// (see the warning at the top of this file). Route through
|
|
603
|
+
// `hubFetch()` itself instead — it already applies the dispatcher
|
|
604
|
+
// from the right undici copy.
|
|
605
|
+
strictHttpsAgent: _strictHttpsAgent,
|
|
606
|
+
_getHubFetchConfigForTest,
|
|
607
|
+
_setFetchImplForTest,
|
|
608
|
+
};
|