@sleep2agi/agent-network 2.3.0-preview.194 → 2.3.0-preview.195

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.
@@ -1 +1 @@
1
- const a0_0x2672d9=a0_0x80b9;(function(_0x43523d,_0x21f408){const _0x5a4322=a0_0x80b9,_0xd03e95=_0x43523d();while(!![]){try{const _0x3927b1=-parseInt(_0x5a4322(0x269))/0x1*(parseInt(_0x5a4322(0x1fc))/0x2)+-parseInt(_0x5a4322(0x259))/0x3*(-parseInt(_0x5a4322(0x23d))/0x4)+-parseInt(_0x5a4322(0x1f5))/0x5+-parseInt(_0x5a4322(0x205))/0x6+-parseInt(_0x5a4322(0x24a))/0x7+-parseInt(_0x5a4322(0x260))/0x8+parseInt(_0x5a4322(0x1fa))/0x9*(parseInt(_0x5a4322(0x1ff))/0xa);if(_0x3927b1===_0x21f408)break;else _0xd03e95['push'](_0xd03e95['shift']());}catch(_0x1cf0e9){_0xd03e95['push'](_0xd03e95['shift']());}}}(a0_0xcafd,0x3ba01));import{EventEmitter as a0_0x4c7d84}from'events';import{hostname as a0_0x11d06b}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x12ee79,_0x5bc061)=>(_0x12ee79??_0x5bc061)[a0_0x2672d9(0x230)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x2672d9(0x1f9)](0x0,0xf0);function N(_0x4023ba){const _0x276d15=a0_0x2672d9;return(_0x4023ba instanceof Error?_0x4023ba[_0x276d15(0x228)]:String(_0x4023ba??_0x276d15(0x264)))['replace'](K,_0x276d15(0x23f))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x276d15(0x1f9)](0x0,0xf0);}function a0_0x80b9(_0x1b888a,_0x3c5536){_0x1b888a=_0x1b888a-0x1ef;const _0xcafda0=a0_0xcafd();let _0x80b99f=_0xcafda0[_0x1b888a];return _0x80b99f;}function O(_0x527f8a,_0x40f579=process.env.ANET_TASK_TRACE_FORMAT===a0_0x2672d9(0x237)){const _0x5e2b02=a0_0x2672d9;if(_0x40f579)return JSON[_0x5e2b02(0x20e)](_0x527f8a);let _0x11c25f=L(_0x527f8a[_0x5e2b02(0x20c)],'<missing>'),_0x3560d4=L(_0x527f8a[_0x5e2b02(0x24c)],_0x5e2b02(0x24f)),_0x58a5db=_0x527f8a[_0x5e2b02(0x241)]?_0x5e2b02(0x22e)+_0x527f8a[_0x5e2b02(0x241)]+':'+(_0x527f8a[_0x5e2b02(0x252)]??''):'';return _0x5e2b02(0x263)+_0x527f8a['status']+_0x5e2b02(0x26a)+L(_0x527f8a[_0x5e2b02(0x245)],_0x5e2b02(0x239))+'\x20to='+L(_0x527f8a[_0x5e2b02(0x22c)],_0x5e2b02(0x239))+_0x5e2b02(0x202)+_0x3560d4+_0x5e2b02(0x20b)+_0x11c25f+'\x20network_id='+L(_0x527f8a['network_id'],_0x5e2b02(0x239))+_0x5e2b02(0x20a)+_0x527f8a['transport']+_0x5e2b02(0x201)+_0x527f8a[_0x5e2b02(0x254)]+_0x5e2b02(0x20d)+_0x527f8a['lifecycle_tracking']+_0x58a5db;}function U(_0x5755a0){const _0x319fce=a0_0x2672d9;return{'event':{'sending':_0x319fce(0x24e),'delivered':_0x319fce(0x225),'failed':_0x319fce(0x266),'acked':_0x319fce(0x25f),'started':_0x319fce(0x24b),'replied':_0x319fce(0x265),'expired':_0x319fce(0x23b)}[_0x5755a0[_0x319fce(0x1fb)]],..._0x5755a0};}function j(_0x27d539){const _0x39ccc3=a0_0x2672d9;let _0x404887=_0x27d539?.[_0x39ccc3(0x24c)]||_0x27d539?.[_0x39ccc3(0x250)]||_0x27d539?.['id'];if(_0x404887)return String(_0x404887);let _0x586282=_0x27d539?.[_0x39ccc3(0x219)]?.[0x0]?.['text'];if(typeof _0x586282!=='string')return null;try{let _0x23459a=JSON[_0x39ccc3(0x224)](_0x586282);return _0x23459a?.[_0x39ccc3(0x24c)]||_0x23459a?.['message_id']||_0x23459a?.['id']||null;}catch{return null;}}function a0_0xcafd(){const _0x53a80e=['244030LpvACl','heartbeatInterval','application/json,\x20text/event-stream','410cHYyKZ','running','\x20duration_ms=','\x20task_id=','SSE\x20error:\x20','failed','1640568zSrkOF','send_rejected','disconnected','missing_task_id','SSE\x20connected','\x20transport=','\x20parent_task_id=','parent_task_id','\x20lifecycle=','stringify','messages','heartbeat\x20failed:\x20','text','sending','server','normal','min','Bearer\x20','/mcp','read','content','sdk-','processInbox','match','reply','offline','toTimeString','registered','AbortError',']\x20[commhub:','url','parse','task.send.delivered','split','token','message','broadcast','text/event-stream','not_tracked','to_alias','startsWith','\x20error=','get_all_status','replace','s...','alias','2.0','parentTaskId','body','call','json','cwd','<unknown>','result','task.expired','autoConnect','430372HZeFSW','send_message','[REDACTED]','signal','error_code','lifecycleTracking','error','type','from_alias','agent','/events/','sleep','connected','2378999qIVDPs','task.started','task_id','send','task.send.start','<pending>','message_id','connectSSE','error_message','send_failed','duration_ms','now','emit','send_reply','sseAbort','3IYsCMU','idle','data:\x20','fromAlias','connect','application/json','task.ack','401856hPWsxE','get_inbox','POST','[commhub:task]\x20','unknown\x20error','task.replied','task.send.failed','heartbeatTimer','sdk','4hXlAhn','\x20from=','log','resumeId','networkId','Authorization','reconnectDelay','SSE\x20failed:\x20','700950ubyMWN','catch','CommHub\x20response\x20omitted\x20task_id','tools/call','slice','313551FPBLwP','status'];a0_0xcafd=function(){return _0x53a80e;};return a0_0xcafd();}async function X(_0x40daea,_0x3127f5){const _0x59148b=a0_0x2672d9;let _0x28ba39=_0x3127f5[_0x59148b(0x255)]??Date[_0x59148b(0x255)],_0x54d137=_0x28ba39(),_0x470d5c=(_0x9de847,_0x1ed101,_0xf3542b,_0x9a85b1)=>{const _0x30b4e8=_0x59148b;_0x3127f5[_0x30b4e8(0x1ef)](O(U({'from_alias':_0x40daea[_0x30b4e8(0x25c)],'to_alias':_0x40daea['toAlias'],'task_id':_0x1ed101,'parent_task_id':_0x40daea[_0x30b4e8(0x234)],'network_id':_0x40daea[_0x30b4e8(0x1f1)],'transport':_0x40daea['transport'],'status':_0x9de847,'duration_ms':_0x28ba39()-_0x54d137,'lifecycle_tracking':_0x40daea[_0x30b4e8(0x242)],..._0xf3542b!==void 0x0?{'error_code':_0x9a85b1||'send_failed','error_message':N(_0xf3542b)}:{}})));};_0x470d5c(_0x59148b(0x212),null);try{let _0x3beded=await _0x3127f5[_0x59148b(0x24d)](),_0x8a499f=j(_0x3beded);if(_0x8a499f)_0x470d5c('delivered',_0x8a499f);else{if(_0x3beded?.['ok']===!0x1||_0x3beded?.[_0x59148b(0x243)])_0x470d5c(_0x59148b(0x204),_0x8a499f,_0x3beded?.[_0x59148b(0x243)]||'CommHub\x20rejected\x20task',_0x59148b(0x206));else _0x470d5c(_0x59148b(0x204),null,_0x59148b(0x1f7),_0x59148b(0x208));}return _0x3beded;}catch(_0x292981){throw _0x470d5c(_0x59148b(0x204),null,_0x292981,_0x59148b(0x253)),_0x292981;}}async function Y(_0x4c1606,_0x3c51b1){const _0x449e1e=a0_0x2672d9;return X({'fromAlias':_0x4c1606[_0x449e1e(0x25c)],'toAlias':_0x4c1606[_0x449e1e(0x232)],'parentTaskId':_0x4c1606[_0x449e1e(0x234)]||null,'networkId':_0x4c1606['networkId']||null,'transport':'mcp_http','lifecycleTracking':_0x449e1e(0x22b)},_0x3c51b1);}class $ extends a0_0x4c7d84{[a0_0x2672d9(0x223)];[a0_0x2672d9(0x232)];['token'];[a0_0x2672d9(0x246)];[a0_0x2672d9(0x1f0)];[a0_0x2672d9(0x1fd)];[a0_0x2672d9(0x1f3)];[a0_0x2672d9(0x267)];[a0_0x2672d9(0x258)];[a0_0x2672d9(0x200)]=!0x1;constructor(_0x422d6b){const _0x1fd7a3=a0_0x2672d9;super();if(this[_0x1fd7a3(0x223)]=_0x422d6b[_0x1fd7a3(0x223)][_0x1fd7a3(0x230)](/\/$/,''),this['alias']=_0x422d6b[_0x1fd7a3(0x232)],this[_0x1fd7a3(0x227)]=_0x422d6b[_0x1fd7a3(0x227)],this[_0x1fd7a3(0x246)]=_0x422d6b[_0x1fd7a3(0x246)]||_0x1fd7a3(0x268),this[_0x1fd7a3(0x1f0)]=_0x1fd7a3(0x21a)+_0x422d6b['alias']+'-'+Date[_0x1fd7a3(0x255)]()['toString'](0x24),this[_0x1fd7a3(0x1fd)]=_0x422d6b[_0x1fd7a3(0x1fd)]??0x2bf20,this[_0x1fd7a3(0x1f3)]=_0x422d6b[_0x1fd7a3(0x1f3)]??0xbb8,_0x422d6b[_0x1fd7a3(0x23c)]!==!0x1)this[_0x1fd7a3(0x25d)]();}['log'](_0x2e5b85){const _0x50b34f=a0_0x2672d9;console[_0x50b34f(0x1ef)]('['+new Date()[_0x50b34f(0x21f)]()[_0x50b34f(0x1f9)](0x0,0x8)+_0x50b34f(0x222)+this[_0x50b34f(0x232)]+']\x20'+_0x2e5b85);}async[a0_0x2672d9(0x236)](_0x2465c6,_0x357ec3){const _0x2472f5=a0_0x2672d9;let _0x4c7a38={'Content-Type':_0x2472f5(0x25e),'Accept':_0x2472f5(0x1fe)};if(this[_0x2472f5(0x227)])_0x4c7a38[_0x2472f5(0x1f2)]='Bearer\x20'+this[_0x2472f5(0x227)];let _0xa5edb5=await(await fetch(this[_0x2472f5(0x223)]+_0x2472f5(0x217),{'method':_0x2472f5(0x262),'headers':_0x4c7a38,'body':JSON[_0x2472f5(0x20e)]({'jsonrpc':_0x2472f5(0x233),'id':Date[_0x2472f5(0x255)](),'method':_0x2472f5(0x1f8),'params':{'name':_0x2465c6,'arguments':_0x357ec3}})}))[_0x2472f5(0x211)](),_0x143532=_0xa5edb5[_0x2472f5(0x21c)](/data: (.+)/),_0x2b3553=_0x143532?JSON[_0x2472f5(0x224)](_0x143532[0x1]):JSON['parse'](_0xa5edb5),_0x4f3bbd=_0x2b3553?.[_0x2472f5(0x23a)]?.[_0x2472f5(0x219)]?.[0x0]?.['text'];return _0x4f3bbd?JSON[_0x2472f5(0x224)](_0x4f3bbd):_0x2b3553;}async[a0_0x2672d9(0x25d)](){const _0x1769fd=a0_0x2672d9;if(this[_0x1769fd(0x200)])return;this[_0x1769fd(0x200)]=!0x0,await this[_0x1769fd(0x1fb)](_0x1769fd(0x25a)),this[_0x1769fd(0x1ef)](_0x1769fd(0x220)),this[_0x1769fd(0x267)]=setInterval(()=>{const _0x50acf2=_0x1769fd;this[_0x50acf2(0x1fb)](_0x50acf2(0x25a))[_0x50acf2(0x1f6)](_0x32df28=>this[_0x50acf2(0x1ef)](_0x50acf2(0x210)+_0x32df28['message']));},this[_0x1769fd(0x1fd)]),this['connectSSE']();}async['disconnect'](){const _0x4aa201=a0_0x2672d9;if(this[_0x4aa201(0x200)]=!0x1,this['sseAbort']?.['abort'](),this[_0x4aa201(0x267)])clearInterval(this[_0x4aa201(0x267)]);await this[_0x4aa201(0x1fb)](_0x4aa201(0x21e))['catch'](()=>{}),this[_0x4aa201(0x1ef)](_0x4aa201(0x207));}async['send'](_0x13bf3e,_0x5ee5f3,_0xd0cb9e=a0_0x2672d9(0x214)){const _0x34f3ad=a0_0x2672d9;return Y({'alias':_0x13bf3e,'fromAlias':this[_0x34f3ad(0x232)]},{'log':_0x1d8aad=>console['log'](_0x1d8aad),'send':()=>this[_0x34f3ad(0x236)]('send_task',{'alias':_0x13bf3e,'task':_0x5ee5f3,'priority':_0xd0cb9e,'from_session':this[_0x34f3ad(0x232)]})});}async['message'](_0x5093f3,_0x443c9d){const _0xc2e440=a0_0x2672d9;return this['call'](_0xc2e440(0x23e),{'alias':_0x5093f3,'message':_0x443c9d,'from_session':this[_0xc2e440(0x232)]});}async[a0_0x2672d9(0x21d)](_0x427aa2,_0x49b46b,_0x53db40='completed'){const _0xba654b=a0_0x2672d9;return this[_0xba654b(0x236)](_0xba654b(0x257),{'in_reply_to':_0x427aa2,'text':_0x49b46b,'status':_0x53db40});}async[a0_0x2672d9(0x1fb)](_0x22c5cf,_0x2b19ff){const _0x56320d=a0_0x2672d9;return this[_0x56320d(0x236)]('report_status',{'resume_id':this[_0x56320d(0x1f0)],'alias':this[_0x56320d(0x232)],'status':_0x22c5cf,'server':a0_0x11d06b(),'hostname':a0_0x11d06b(),'agent':this[_0x56320d(0x246)],'project_dir':process[_0x56320d(0x238)](),..._0x2b19ff});}async['getAllStatus'](){const _0x436c8f=a0_0x2672d9;return this['call'](_0x436c8f(0x22f),{});}async[a0_0x2672d9(0x229)](_0x5f37a5,_0x25d8b3){const _0x51e0d1=a0_0x2672d9;return this[_0x51e0d1(0x236)](_0x51e0d1(0x229),{'message':_0x5f37a5,'filter_server':_0x25d8b3?.[_0x51e0d1(0x213)],'filter_status':_0x25d8b3?.[_0x51e0d1(0x1fb)]});}async[a0_0x2672d9(0x251)](){const _0x4e9dab=a0_0x2672d9;let _0x3ba555=encodeURIComponent(this[_0x4e9dab(0x232)]),_0x5afe6b=this[_0x4e9dab(0x223)]+_0x4e9dab(0x247)+_0x3ba555,_0x15c39b=this[_0x4e9dab(0x1f3)];while(this[_0x4e9dab(0x200)]){try{this[_0x4e9dab(0x258)]=new AbortController();let _0x241de3={'Accept':_0x4e9dab(0x22a)};if(this[_0x4e9dab(0x227)])_0x241de3[_0x4e9dab(0x1f2)]=_0x4e9dab(0x216)+this[_0x4e9dab(0x227)];let _0x305d08=await fetch(_0x5afe6b,{'headers':_0x241de3,'signal':this[_0x4e9dab(0x258)][_0x4e9dab(0x240)]});if(!_0x305d08['ok']||!_0x305d08[_0x4e9dab(0x235)]){this[_0x4e9dab(0x1ef)](_0x4e9dab(0x1f4)+_0x305d08['status']),await this[_0x4e9dab(0x248)](_0x15c39b),_0x15c39b=Math[_0x4e9dab(0x215)](_0x15c39b*1.5,0xea60);continue;}_0x15c39b=this[_0x4e9dab(0x1f3)];let _0x1d86b4=_0x305d08[_0x4e9dab(0x235)]['getReader'](),_0x3cf270=new TextDecoder(),_0x509ca5='';while(this[_0x4e9dab(0x200)]){let {done:_0x3699b6,value:_0x498516}=await _0x1d86b4[_0x4e9dab(0x218)]();if(_0x3699b6)break;_0x509ca5+=_0x3cf270['decode'](_0x498516,{'stream':!0x0});let _0x1304f3=_0x509ca5[_0x4e9dab(0x226)]('\x0a');_0x509ca5=_0x1304f3['pop']()||'';for(let _0x52f72b of _0x1304f3){if(!_0x52f72b[_0x4e9dab(0x22d)](_0x4e9dab(0x25b)))continue;try{let _0x4e039e=JSON[_0x4e9dab(0x224)](_0x52f72b[_0x4e9dab(0x1f9)](0x6));if(_0x4e039e['type']==='connected'){this['log'](_0x4e9dab(0x209)),this[_0x4e9dab(0x256)](_0x4e9dab(0x249));continue;}if(_0x4e039e[_0x4e9dab(0x244)]==='new_task'||_0x4e039e[_0x4e9dab(0x244)]==='new_message'||_0x4e039e['type']===_0x4e9dab(0x229))await this[_0x4e9dab(0x21b)]();}catch{}}}}catch(_0x265859){if(_0x265859['name']===_0x4e9dab(0x221))break;this[_0x4e9dab(0x256)](_0x4e9dab(0x243),_0x265859),this[_0x4e9dab(0x1ef)](_0x4e9dab(0x203)+_0x265859['message']);}if(this['running'])this[_0x4e9dab(0x256)](_0x4e9dab(0x207)),this[_0x4e9dab(0x1ef)]('SSE\x20reconnecting\x20in\x20'+_0x15c39b/0x3e8+_0x4e9dab(0x231)),await this[_0x4e9dab(0x248)](_0x15c39b),_0x15c39b=Math[_0x4e9dab(0x215)](_0x15c39b*1.5,0xea60);}}async[a0_0x2672d9(0x21b)](){const _0x1d6a2f=a0_0x2672d9;try{let _0x3f580c=(await this[_0x1d6a2f(0x236)](_0x1d6a2f(0x261),{'alias':this[_0x1d6a2f(0x232)],'limit':0xa}))?.[_0x1d6a2f(0x20f)]||[];for(let _0x4c8e99 of _0x3f580c)await this[_0x1d6a2f(0x236)]('ack_inbox',{'alias':this[_0x1d6a2f(0x232)],'message_id':_0x4c8e99['id']}),this['log']('←\x20'+_0x4c8e99['from_session']+':\x20'+_0x4c8e99[_0x1d6a2f(0x219)][_0x1d6a2f(0x1f9)](0x0,0x3c)),this[_0x1d6a2f(0x256)]('task',_0x4c8e99),this['emit']('message',_0x4c8e99);}catch(_0x29f621){this[_0x1d6a2f(0x1ef)]('inbox\x20error:\x20'+_0x29f621['message']);}}[a0_0x2672d9(0x248)](_0x1dacc1){return new Promise(_0x5cdad9=>setTimeout(_0x5cdad9,_0x1dacc1));}}var F=$;export{F as default,$ as CommHub};
1
+ const a0_0xfef4bc=a0_0x5475;(function(_0x1a28b1,_0x3a6af2){const _0x2ec90b=a0_0x5475,_0x536a5e=_0x1a28b1();while(!![]){try{const _0x7e8920=parseInt(_0x2ec90b(0x23b))/0x1+parseInt(_0x2ec90b(0x21d))/0x2+parseInt(_0x2ec90b(0x1cc))/0x3+-parseInt(_0x2ec90b(0x1c7))/0x4*(parseInt(_0x2ec90b(0x204))/0x5)+parseInt(_0x2ec90b(0x23e))/0x6+-parseInt(_0x2ec90b(0x237))/0x7*(-parseInt(_0x2ec90b(0x1df))/0x8)+parseInt(_0x2ec90b(0x229))/0x9*(-parseInt(_0x2ec90b(0x1f3))/0xa);if(_0x7e8920===_0x3a6af2)break;else _0x536a5e['push'](_0x536a5e['shift']());}catch(_0xb4dd4c){_0x536a5e['push'](_0x536a5e['shift']());}}}(a0_0x1c3b,0x3f0e1));import{EventEmitter as a0_0xde8ec0}from'events';import{hostname as a0_0x42df73}from'os';function a0_0x5475(_0x1b4f75,_0x25df6c){_0x1b4f75=_0x1b4f75-0x1c4;const _0x1c3bf4=a0_0x1c3b();let _0x5475c5=_0x1c3bf4[_0x1b4f75];return _0x5475c5;}function a0_0x1c3b(){const _0x526ca9=['emit','task.send.delivered','task.ack','<pending>','CommHub\x20response\x20omitted\x20task_id','pop','inbox\x20error:\x20','match','send_failed','string','offline','CommHub\x20rejected\x20task','867192OmJjQJ','s...','idle','toString','sdk-','connectSSE','SSE\x20reconnecting\x20in\x20','toAlias',']\x20[commhub:','stringify','processInbox','send','1012302wbWzoI','\x20parent_task_id=','[commhub:task]\x20','send_reply','sseAbort','send_message','broadcast','connect','report_status','url','error_code','get_inbox','completed','agent','258293NitWhv','2.0','disconnected','unknown\x20error','332475wQxcHQ','get_all_status','new_message','2149638PZMcMx','parent_task_id','split','log','getReader','messages','from_session','disconnect','<unknown>','3100LGuPBD','text','server','sleep','sending','1176621awwWOv','/mcp','\x20to=','networkId','task.send.start','mcp_http','data:\x20','\x20lifecycle=','running','slice','task_id','tools/call','failed','heartbeatTimer','task.replied','heartbeatInterval','not_tracked','decode','\x20network_id=','8EtWnNK','<missing>','alias','to_alias','catch','call','type','task.expired','new_task','transport','\x20from=','Authorization','Bearer\x20','reply','missing_task_id','reconnectDelay','\x20error=','name','task','fromAlias','90LSzaSP','SSE\x20error:\x20','token','min','parentTaskId','from_alias','sdk','AbortError','\x20duration_ms=','read','now','application/json,\x20text/event-stream','send_task','network_id','/events/','message','resumeId','1825sfaBlC','getAllStatus','send_rejected','error','replace','content','startsWith','parse','lifecycleTracking','connected','task.send.failed','status','body'];a0_0x1c3b=function(){return _0x526ca9;};return a0_0x1c3b();}var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x18bfe9,_0x559dfa)=>(_0x18bfe9??_0x559dfa)[a0_0xfef4bc(0x208)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0xfef4bc(0x1d5)](0x0,0xf0);function N(_0x5937c6){const _0x5ef594=a0_0xfef4bc;return(_0x5937c6 instanceof Error?_0x5937c6['message']:String(_0x5937c6??_0x5ef594(0x23a)))['replace'](K,'[REDACTED]')[_0x5ef594(0x208)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x27487d,_0x375bae=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x5d6666=a0_0xfef4bc;if(_0x375bae)return JSON[_0x5d6666(0x226)](_0x27487d);let _0x351864=L(_0x27487d[_0x5d6666(0x23f)],_0x5d6666(0x1e0)),_0x20cb3e=L(_0x27487d['task_id'],_0x5d6666(0x214)),_0x4323e8=_0x27487d[_0x5d6666(0x233)]?_0x5d6666(0x1ef)+_0x27487d[_0x5d6666(0x233)]+':'+(_0x27487d['error_message']??''):'';return _0x5d6666(0x22b)+_0x27487d['status']+_0x5d6666(0x1e9)+L(_0x27487d[_0x5d6666(0x1f8)],_0x5d6666(0x1c6))+_0x5d6666(0x1ce)+L(_0x27487d[_0x5d6666(0x1e2)],_0x5d6666(0x1c6))+'\x20task_id='+_0x20cb3e+_0x5d6666(0x22a)+_0x351864+_0x5d6666(0x1de)+L(_0x27487d[_0x5d6666(0x200)],_0x5d6666(0x1c6))+'\x20transport='+_0x27487d[_0x5d6666(0x1e8)]+_0x5d6666(0x1fb)+_0x27487d['duration_ms']+_0x5d6666(0x1d3)+_0x27487d['lifecycle_tracking']+_0x4323e8;}function U(_0x2570f5){const _0x2eddf2=a0_0xfef4bc;return{'event':{'sending':_0x2eddf2(0x1d0),'delivered':_0x2eddf2(0x212),'failed':_0x2eddf2(0x20e),'acked':_0x2eddf2(0x213),'started':'task.started','replied':_0x2eddf2(0x1da),'expired':_0x2eddf2(0x1e6)}[_0x2570f5[_0x2eddf2(0x20f)]],..._0x2570f5};}function j(_0x1b965c){const _0x5122e5=a0_0xfef4bc;let _0x423f6f=_0x1b965c?.[_0x5122e5(0x1d6)]||_0x1b965c?.['message_id']||_0x1b965c?.['id'];if(_0x423f6f)return String(_0x423f6f);let _0x3ddfcb=_0x1b965c?.['content']?.[0x0]?.[_0x5122e5(0x1c8)];if(typeof _0x3ddfcb!==_0x5122e5(0x21a))return null;try{let _0x487417=JSON[_0x5122e5(0x20b)](_0x3ddfcb);return _0x487417?.['task_id']||_0x487417?.['message_id']||_0x487417?.['id']||null;}catch{return null;}}async function X(_0x58d8c8,_0xf81b11){const _0x43f3e0=a0_0xfef4bc;let _0x2be187=_0xf81b11['now']??Date['now'],_0x103485=_0x2be187(),_0x1866ff=(_0xc2036c,_0x56a6aa,_0x28d710,_0x51f71e)=>{const _0x29af13=a0_0x5475;_0xf81b11[_0x29af13(0x241)](O(U({'from_alias':_0x58d8c8[_0x29af13(0x1f2)],'to_alias':_0x58d8c8[_0x29af13(0x224)],'task_id':_0x56a6aa,'parent_task_id':_0x58d8c8[_0x29af13(0x1f7)],'network_id':_0x58d8c8['networkId'],'transport':_0x58d8c8['transport'],'status':_0xc2036c,'duration_ms':_0x2be187()-_0x103485,'lifecycle_tracking':_0x58d8c8[_0x29af13(0x20c)],..._0x28d710!==void 0x0?{'error_code':_0x51f71e||_0x29af13(0x219),'error_message':N(_0x28d710)}:{}})));};_0x1866ff(_0x43f3e0(0x1cb),null);try{let _0x4bc2ea=await _0xf81b11[_0x43f3e0(0x228)](),_0x4bf325=j(_0x4bc2ea);if(_0x4bf325)_0x1866ff('delivered',_0x4bf325);else{if(_0x4bc2ea?.['ok']===!0x1||_0x4bc2ea?.[_0x43f3e0(0x207)])_0x1866ff(_0x43f3e0(0x1d8),_0x4bf325,_0x4bc2ea?.[_0x43f3e0(0x207)]||_0x43f3e0(0x21c),_0x43f3e0(0x206));else _0x1866ff(_0x43f3e0(0x1d8),null,_0x43f3e0(0x215),_0x43f3e0(0x1ed));}return _0x4bc2ea;}catch(_0x2e67ed){throw _0x1866ff(_0x43f3e0(0x1d8),null,_0x2e67ed,'send_failed'),_0x2e67ed;}}async function Y(_0x2d0fc3,_0x50dda4){const _0x439e4c=a0_0xfef4bc;return X({'fromAlias':_0x2d0fc3[_0x439e4c(0x1f2)],'toAlias':_0x2d0fc3[_0x439e4c(0x1e1)],'parentTaskId':_0x2d0fc3[_0x439e4c(0x1f7)]||null,'networkId':_0x2d0fc3[_0x439e4c(0x1cf)]||null,'transport':_0x439e4c(0x1d1),'lifecycleTracking':_0x439e4c(0x1dc)},_0x50dda4);}class $ extends a0_0xde8ec0{[a0_0xfef4bc(0x232)];[a0_0xfef4bc(0x1e1)];[a0_0xfef4bc(0x1f5)];['agent'];[a0_0xfef4bc(0x203)];['heartbeatInterval'];['reconnectDelay'];[a0_0xfef4bc(0x1d9)];[a0_0xfef4bc(0x22d)];['running']=!0x1;constructor(_0x20c1ef){const _0x44fe25=a0_0xfef4bc;super();if(this[_0x44fe25(0x232)]=_0x20c1ef[_0x44fe25(0x232)][_0x44fe25(0x208)](/\/$/,''),this[_0x44fe25(0x1e1)]=_0x20c1ef[_0x44fe25(0x1e1)],this[_0x44fe25(0x1f5)]=_0x20c1ef[_0x44fe25(0x1f5)],this[_0x44fe25(0x236)]=_0x20c1ef[_0x44fe25(0x236)]||_0x44fe25(0x1f9),this[_0x44fe25(0x203)]=_0x44fe25(0x221)+_0x20c1ef[_0x44fe25(0x1e1)]+'-'+Date[_0x44fe25(0x1fd)]()[_0x44fe25(0x220)](0x24),this[_0x44fe25(0x1db)]=_0x20c1ef[_0x44fe25(0x1db)]??0x2bf20,this[_0x44fe25(0x1ee)]=_0x20c1ef[_0x44fe25(0x1ee)]??0xbb8,_0x20c1ef['autoConnect']!==!0x1)this[_0x44fe25(0x230)]();}[a0_0xfef4bc(0x241)](_0xaa5b68){const _0x4104dc=a0_0xfef4bc;console[_0x4104dc(0x241)]('['+new Date()['toTimeString']()[_0x4104dc(0x1d5)](0x0,0x8)+_0x4104dc(0x225)+this[_0x4104dc(0x1e1)]+']\x20'+_0xaa5b68);}async[a0_0xfef4bc(0x1e4)](_0x5d6d20,_0x4bd500){const _0x168a54=a0_0xfef4bc;let _0x1c7ca9={'Content-Type':'application/json','Accept':_0x168a54(0x1fe)};if(this['token'])_0x1c7ca9[_0x168a54(0x1ea)]='Bearer\x20'+this[_0x168a54(0x1f5)];let _0x2e25b3=await(await fetch(this[_0x168a54(0x232)]+_0x168a54(0x1cd),{'method':'POST','headers':_0x1c7ca9,'body':JSON[_0x168a54(0x226)]({'jsonrpc':_0x168a54(0x238),'id':Date[_0x168a54(0x1fd)](),'method':_0x168a54(0x1d7),'params':{'name':_0x5d6d20,'arguments':_0x4bd500}})}))[_0x168a54(0x1c8)](),_0x333443=_0x2e25b3[_0x168a54(0x218)](/data: (.+)/),_0x1bddba=_0x333443?JSON[_0x168a54(0x20b)](_0x333443[0x1]):JSON[_0x168a54(0x20b)](_0x2e25b3),_0x2deae6=_0x1bddba?.['result']?.['content']?.[0x0]?.[_0x168a54(0x1c8)];return _0x2deae6?JSON[_0x168a54(0x20b)](_0x2deae6):_0x1bddba;}async[a0_0xfef4bc(0x230)](){const _0x2eb155=a0_0xfef4bc;if(this[_0x2eb155(0x1d4)])return;this[_0x2eb155(0x1d4)]=!0x0,await this['status'](_0x2eb155(0x21f)),this['log']('registered'),this['heartbeatTimer']=setInterval(()=>{const _0x31f2b8=_0x2eb155;this['status'](_0x31f2b8(0x21f))[_0x31f2b8(0x1e3)](_0x11e4aa=>this[_0x31f2b8(0x241)]('heartbeat\x20failed:\x20'+_0x11e4aa[_0x31f2b8(0x202)]));},this[_0x2eb155(0x1db)]),this['connectSSE']();}async[a0_0xfef4bc(0x1c5)](){const _0x4c473a=a0_0xfef4bc;if(this[_0x4c473a(0x1d4)]=!0x1,this[_0x4c473a(0x22d)]?.['abort'](),this[_0x4c473a(0x1d9)])clearInterval(this[_0x4c473a(0x1d9)]);await this[_0x4c473a(0x20f)](_0x4c473a(0x21b))[_0x4c473a(0x1e3)](()=>{}),this[_0x4c473a(0x241)](_0x4c473a(0x239));}async[a0_0xfef4bc(0x228)](_0x405ce1,_0x39f4bf,_0x9c4ecd='normal'){const _0x3701f1=a0_0xfef4bc;return Y({'alias':_0x405ce1,'fromAlias':this[_0x3701f1(0x1e1)]},{'log':_0x55323c=>console[_0x3701f1(0x241)](_0x55323c),'send':()=>this[_0x3701f1(0x1e4)](_0x3701f1(0x1ff),{'alias':_0x405ce1,'task':_0x39f4bf,'priority':_0x9c4ecd,'from_session':this[_0x3701f1(0x1e1)]})});}async[a0_0xfef4bc(0x202)](_0x1c97e2,_0xd4a863){const _0xa9b3f6=a0_0xfef4bc;return this[_0xa9b3f6(0x1e4)](_0xa9b3f6(0x22e),{'alias':_0x1c97e2,'message':_0xd4a863,'from_session':this[_0xa9b3f6(0x1e1)]});}async[a0_0xfef4bc(0x1ec)](_0x1e3b27,_0x254526,_0x22b286=a0_0xfef4bc(0x235)){const _0x3bb55a=a0_0xfef4bc;return this['call'](_0x3bb55a(0x22c),{'in_reply_to':_0x1e3b27,'text':_0x254526,'status':_0x22b286});}async[a0_0xfef4bc(0x20f)](_0x5ef7ff,_0x4bbf98){const _0x4e2a82=a0_0xfef4bc;return this[_0x4e2a82(0x1e4)](_0x4e2a82(0x231),{'resume_id':this['resumeId'],'alias':this[_0x4e2a82(0x1e1)],'status':_0x5ef7ff,'server':a0_0x42df73(),'hostname':a0_0x42df73(),'agent':this['agent'],'project_dir':process['cwd'](),..._0x4bbf98});}async[a0_0xfef4bc(0x205)](){const _0xc91328=a0_0xfef4bc;return this[_0xc91328(0x1e4)](_0xc91328(0x23c),{});}async[a0_0xfef4bc(0x22f)](_0x5e485b,_0x2adaf4){const _0x12ef6b=a0_0xfef4bc;return this['call'](_0x12ef6b(0x22f),{'message':_0x5e485b,'filter_server':_0x2adaf4?.[_0x12ef6b(0x1c9)],'filter_status':_0x2adaf4?.[_0x12ef6b(0x20f)]});}async[a0_0xfef4bc(0x222)](){const _0x1f4c2f=a0_0xfef4bc;let _0x376a9c=encodeURIComponent(this[_0x1f4c2f(0x1e1)]),_0x586f4f=this[_0x1f4c2f(0x232)]+_0x1f4c2f(0x201)+_0x376a9c,_0x1dcb88=this[_0x1f4c2f(0x1ee)];while(this[_0x1f4c2f(0x1d4)]){try{this['sseAbort']=new AbortController();let _0x57c3b0={'Accept':'text/event-stream'};if(this[_0x1f4c2f(0x1f5)])_0x57c3b0['Authorization']=_0x1f4c2f(0x1eb)+this['token'];let _0x1f79fa=await fetch(_0x586f4f,{'headers':_0x57c3b0,'signal':this[_0x1f4c2f(0x22d)]['signal']});if(!_0x1f79fa['ok']||!_0x1f79fa[_0x1f4c2f(0x210)]){this[_0x1f4c2f(0x241)]('SSE\x20failed:\x20'+_0x1f79fa[_0x1f4c2f(0x20f)]),await this[_0x1f4c2f(0x1ca)](_0x1dcb88),_0x1dcb88=Math[_0x1f4c2f(0x1f6)](_0x1dcb88*1.5,0xea60);continue;}_0x1dcb88=this['reconnectDelay'];let _0xdf44ba=_0x1f79fa[_0x1f4c2f(0x210)][_0x1f4c2f(0x242)](),_0x262c9c=new TextDecoder(),_0x2ec388='';while(this['running']){let {done:_0x115797,value:_0x5848ed}=await _0xdf44ba[_0x1f4c2f(0x1fc)]();if(_0x115797)break;_0x2ec388+=_0x262c9c[_0x1f4c2f(0x1dd)](_0x5848ed,{'stream':!0x0});let _0x137d35=_0x2ec388[_0x1f4c2f(0x240)]('\x0a');_0x2ec388=_0x137d35[_0x1f4c2f(0x216)]()||'';for(let _0x37ff23 of _0x137d35){if(!_0x37ff23[_0x1f4c2f(0x20a)](_0x1f4c2f(0x1d2)))continue;try{let _0x2a17dd=JSON[_0x1f4c2f(0x20b)](_0x37ff23['slice'](0x6));if(_0x2a17dd[_0x1f4c2f(0x1e5)]==='connected'){this['log']('SSE\x20connected'),this[_0x1f4c2f(0x211)](_0x1f4c2f(0x20d));continue;}if(_0x2a17dd[_0x1f4c2f(0x1e5)]===_0x1f4c2f(0x1e7)||_0x2a17dd[_0x1f4c2f(0x1e5)]===_0x1f4c2f(0x23d)||_0x2a17dd[_0x1f4c2f(0x1e5)]===_0x1f4c2f(0x22f))await this[_0x1f4c2f(0x227)]();}catch{}}}}catch(_0x576c6c){if(_0x576c6c[_0x1f4c2f(0x1f0)]===_0x1f4c2f(0x1fa))break;this[_0x1f4c2f(0x211)](_0x1f4c2f(0x207),_0x576c6c),this[_0x1f4c2f(0x241)](_0x1f4c2f(0x1f4)+_0x576c6c[_0x1f4c2f(0x202)]);}if(this['running'])this[_0x1f4c2f(0x211)]('disconnected'),this['log'](_0x1f4c2f(0x223)+_0x1dcb88/0x3e8+_0x1f4c2f(0x21e)),await this[_0x1f4c2f(0x1ca)](_0x1dcb88),_0x1dcb88=Math['min'](_0x1dcb88*1.5,0xea60);}}async['processInbox'](){const _0x327ce0=a0_0xfef4bc;try{let _0x1c6206=(await this[_0x327ce0(0x1e4)](_0x327ce0(0x234),{'alias':this[_0x327ce0(0x1e1)],'limit':0xa}))?.[_0x327ce0(0x243)]||[];for(let _0x2450e3 of _0x1c6206)await this['call']('ack_inbox',{'alias':this['alias'],'message_id':_0x2450e3['id']}),this['log']('←\x20'+_0x2450e3[_0x327ce0(0x1c4)]+':\x20'+_0x2450e3[_0x327ce0(0x209)][_0x327ce0(0x1d5)](0x0,0x3c)),this[_0x327ce0(0x211)](_0x327ce0(0x1f1),_0x2450e3),this[_0x327ce0(0x211)]('message',_0x2450e3);}catch(_0x3f07ec){this[_0x327ce0(0x241)](_0x327ce0(0x217)+_0x3f07ec['message']);}}['sleep'](_0x1b9c27){return new Promise(_0x3d3566=>setTimeout(_0x3d3566,_0x1b9c27));}}var F=$;export{F as default,$ as CommHub};