@sleep2agi/agent-network 2.3.0-preview.137 → 2.3.0-preview.138

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_0x26d955=a0_0xd089;(function(_0x3ce976,_0x161c71){const _0xfb0cf5=a0_0xd089,_0x18329f=_0x3ce976();while(!![]){try{const _0x339cb0=parseInt(_0xfb0cf5(0x209))/0x1+parseInt(_0xfb0cf5(0x1c8))/0x2+-parseInt(_0xfb0cf5(0x1cf))/0x3*(-parseInt(_0xfb0cf5(0x1ef))/0x4)+parseInt(_0xfb0cf5(0x21f))/0x5+parseInt(_0xfb0cf5(0x1c9))/0x6+-parseInt(_0xfb0cf5(0x1d5))/0x7*(-parseInt(_0xfb0cf5(0x212))/0x8)+-parseInt(_0xfb0cf5(0x1dd))/0x9;if(_0x339cb0===_0x161c71)break;else _0x18329f['push'](_0x18329f['shift']());}catch(_0x481e4e){_0x18329f['push'](_0x18329f['shift']());}}}(a0_0x1da7,0xe2e46));import{EventEmitter as a0_0xaf28a1}from'events';import{hostname as a0_0x5b2d48}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x5abe5f,_0x32f50d)=>(_0x5abe5f??_0x32f50d)[a0_0x26d955(0x206)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x1b734d){const _0x5d5374=a0_0x26d955;return(_0x1b734d instanceof Error?_0x1b734d[_0x5d5374(0x1dc)]:String(_0x1b734d??_0x5d5374(0x232)))['replace'](K,_0x5d5374(0x1e0))[_0x5d5374(0x206)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x5d5374(0x231)](0x0,0xf0);}function O(_0x4ffa3a,_0x1d0ab3=process.env.ANET_TASK_TRACE_FORMAT===a0_0x26d955(0x1bb)){const _0x2228c8=a0_0x26d955;if(_0x1d0ab3)return JSON[_0x2228c8(0x1d9)](_0x4ffa3a);let _0x7f94c4=L(_0x4ffa3a['parent_task_id'],_0x2228c8(0x1ec)),_0x56ff40=L(_0x4ffa3a['task_id'],_0x2228c8(0x1f9)),_0x31c003=_0x4ffa3a['error_code']?_0x2228c8(0x207)+_0x4ffa3a[_0x2228c8(0x227)]+':'+(_0x4ffa3a[_0x2228c8(0x217)]??''):'';return'[commhub:task]\x20'+_0x4ffa3a[_0x2228c8(0x20d)]+_0x2228c8(0x1d4)+L(_0x4ffa3a[_0x2228c8(0x1d8)],_0x2228c8(0x1f0))+_0x2228c8(0x205)+L(_0x4ffa3a['to_alias'],'<unknown>')+'\x20task_id='+_0x56ff40+_0x2228c8(0x1fe)+_0x7f94c4+_0x2228c8(0x20b)+L(_0x4ffa3a[_0x2228c8(0x1f2)],_0x2228c8(0x1f0))+_0x2228c8(0x225)+_0x4ffa3a[_0x2228c8(0x229)]+_0x2228c8(0x1be)+_0x4ffa3a[_0x2228c8(0x1ba)]+_0x2228c8(0x1f7)+_0x4ffa3a['lifecycle_tracking']+_0x31c003;}function U(_0x4ff830){const _0x478569=a0_0x26d955;return{'event':{'sending':'task.send.start','delivered':'task.send.delivered','failed':_0x478569(0x1c3),'acked':_0x478569(0x1f6),'started':_0x478569(0x203),'replied':_0x478569(0x22f),'expired':'task.expired'}[_0x4ff830[_0x478569(0x20d)]],..._0x4ff830};}function a0_0x1da7(){const _0x144574=['reply','not_tracked','/mcp','send_reply','send_message','resumeId','cwd','1901970reZEii','missing_task_id','parse','heartbeat\x20failed:\x20','application/json','now','\x20transport=','Authorization','error_code','completed','transport','data:\x20','server','getAllStatus','body','inbox\x20error:\x20','task.replied','lifecycleTracking','slice','unknown\x20error','heartbeatTimer','toAlias','connectSSE','sleep','duration_ms','json','mcp_http','task','\x20duration_ms=','CommHub\x20response\x20omitted\x20task_id','CommHub\x20rejected\x20task','running','emit','task.send.failed','SSE\x20reconnecting\x20in\x20','log','read','2.0','1972614wijUJD','2124552bRChhd','text/event-stream','text','split','sseAbort','networkId','15IcTSeX','ack_inbox','send','sdk','SSE\x20connected','\x20from=','7Qcpchv','type','catch','from_alias','stringify','send_rejected','call','message','17866188BXNJWA','connect','url','[REDACTED]','startsWith','task_id','SSE\x20error:\x20','sdk-','name','broadcast','/events/','abort','delivered','failed','idle','<missing>','heartbeatInterval','registered','649828XEEgNp','<unknown>','fromAlias','network_id','disconnect','token','message_id','task.ack','\x20lifecycle=','application/json,\x20text/event-stream','<pending>','send_failed','report_status','reconnectDelay','POST','\x20parent_task_id=','offline','agent','s...','disconnected','task.started','SSE\x20failed:\x20','\x20to=','replace','\x20error=','error','306607oRZdiS','connected','\x20network_id=','processInbox','status','Bearer\x20','getReader','autoConnect','toString','598376WMgTab','match','content','parentTaskId','alias','error_message'];a0_0x1da7=function(){return _0x144574;};return a0_0x1da7();}function j(_0x14ab5e){const _0x275fbc=a0_0x26d955;let _0x87a6a6=_0x14ab5e?.[_0x275fbc(0x1e2)]||_0x14ab5e?.[_0x275fbc(0x1f5)]||_0x14ab5e?.['id'];if(_0x87a6a6)return String(_0x87a6a6);let _0x3e02af=_0x14ab5e?.[_0x275fbc(0x214)]?.[0x0]?.[_0x275fbc(0x1cb)];if(typeof _0x3e02af!=='string')return null;try{let _0x40a530=JSON[_0x275fbc(0x221)](_0x3e02af);return _0x40a530?.[_0x275fbc(0x1e2)]||_0x40a530?.[_0x275fbc(0x1f5)]||_0x40a530?.['id']||null;}catch{return null;}}async function X(_0x46f386,_0x5a374d){const _0x3f6028=a0_0x26d955;let _0x41f99f=_0x5a374d[_0x3f6028(0x224)]??Date[_0x3f6028(0x224)],_0x4871df=_0x41f99f(),_0x34493f=(_0x4bd80e,_0x108e12,_0x1d5f2c,_0x5965e6)=>{const _0xa6aadf=_0x3f6028;_0x5a374d[_0xa6aadf(0x1c5)](O(U({'from_alias':_0x46f386[_0xa6aadf(0x1f1)],'to_alias':_0x46f386[_0xa6aadf(0x234)],'task_id':_0x108e12,'parent_task_id':_0x46f386[_0xa6aadf(0x215)],'network_id':_0x46f386[_0xa6aadf(0x1ce)],'transport':_0x46f386['transport'],'status':_0x4bd80e,'duration_ms':_0x41f99f()-_0x4871df,'lifecycle_tracking':_0x46f386[_0xa6aadf(0x230)],..._0x1d5f2c!==void 0x0?{'error_code':_0x5965e6||'send_failed','error_message':N(_0x1d5f2c)}:{}})));};_0x34493f('sending',null);try{let _0x38db74=await _0x5a374d[_0x3f6028(0x1d1)](),_0x2393c8=j(_0x38db74);if(_0x2393c8)_0x34493f(_0x3f6028(0x1e9),_0x2393c8);else{if(_0x38db74?.['ok']===!0x1||_0x38db74?.['error'])_0x34493f('failed',_0x2393c8,_0x38db74?.[_0x3f6028(0x208)]||_0x3f6028(0x1c0),_0x3f6028(0x1da));else _0x34493f(_0x3f6028(0x1ea),null,_0x3f6028(0x1bf),_0x3f6028(0x220));}return _0x38db74;}catch(_0x2b7be4){throw _0x34493f('failed',null,_0x2b7be4,_0x3f6028(0x1fa)),_0x2b7be4;}}async function Y(_0x420af0,_0x2a8cb9){const _0x1e73ff=a0_0x26d955;return X({'fromAlias':_0x420af0[_0x1e73ff(0x1f1)],'toAlias':_0x420af0['alias'],'parentTaskId':_0x420af0[_0x1e73ff(0x215)]||null,'networkId':_0x420af0['networkId']||null,'transport':_0x1e73ff(0x1bc),'lifecycleTracking':_0x1e73ff(0x219)},_0x2a8cb9);}function a0_0xd089(_0x55d868,_0x5959d3){_0x55d868=_0x55d868-0x1b8;const _0x1da7e8=a0_0x1da7();let _0xd0893a=_0x1da7e8[_0x55d868];return _0xd0893a;}class $ extends a0_0xaf28a1{['url'];['alias'];[a0_0x26d955(0x1f4)];['agent'];[a0_0x26d955(0x21d)];['heartbeatInterval'];[a0_0x26d955(0x1fc)];[a0_0x26d955(0x233)];['sseAbort'];[a0_0x26d955(0x1c1)]=!0x1;constructor(_0x5b05c8){const _0x3dae9c=a0_0x26d955;super();if(this[_0x3dae9c(0x1df)]=_0x5b05c8[_0x3dae9c(0x1df)]['replace'](/\/$/,''),this[_0x3dae9c(0x216)]=_0x5b05c8[_0x3dae9c(0x216)],this[_0x3dae9c(0x1f4)]=_0x5b05c8[_0x3dae9c(0x1f4)],this['agent']=_0x5b05c8[_0x3dae9c(0x200)]||_0x3dae9c(0x1d2),this[_0x3dae9c(0x21d)]=_0x3dae9c(0x1e4)+_0x5b05c8[_0x3dae9c(0x216)]+'-'+Date[_0x3dae9c(0x224)]()[_0x3dae9c(0x211)](0x24),this[_0x3dae9c(0x1ed)]=_0x5b05c8[_0x3dae9c(0x1ed)]??0x2bf20,this['reconnectDelay']=_0x5b05c8[_0x3dae9c(0x1fc)]??0xbb8,_0x5b05c8[_0x3dae9c(0x210)]!==!0x1)this[_0x3dae9c(0x1de)]();}[a0_0x26d955(0x1c5)](_0x3e7a5d){const _0x49c65a=a0_0x26d955;console['log']('['+new Date()['toTimeString']()['slice'](0x0,0x8)+']\x20[commhub:'+this[_0x49c65a(0x216)]+']\x20'+_0x3e7a5d);}async[a0_0x26d955(0x1db)](_0x59e31c,_0x312f00){const _0x4367d0=a0_0x26d955;let _0x4552d3={'Content-Type':_0x4367d0(0x223),'Accept':_0x4367d0(0x1f8)};if(this[_0x4367d0(0x1f4)])_0x4552d3[_0x4367d0(0x226)]=_0x4367d0(0x20e)+this[_0x4367d0(0x1f4)];let _0x3b0ee7=await(await fetch(this[_0x4367d0(0x1df)]+_0x4367d0(0x21a),{'method':_0x4367d0(0x1fd),'headers':_0x4552d3,'body':JSON[_0x4367d0(0x1d9)]({'jsonrpc':_0x4367d0(0x1c7),'id':Date['now'](),'method':'tools/call','params':{'name':_0x59e31c,'arguments':_0x312f00}})}))[_0x4367d0(0x1cb)](),_0x255efd=_0x3b0ee7[_0x4367d0(0x213)](/data: (.+)/),_0xa268cd=_0x255efd?JSON[_0x4367d0(0x221)](_0x255efd[0x1]):JSON[_0x4367d0(0x221)](_0x3b0ee7),_0x2cbf01=_0xa268cd?.['result']?.[_0x4367d0(0x214)]?.[0x0]?.[_0x4367d0(0x1cb)];return _0x2cbf01?JSON[_0x4367d0(0x221)](_0x2cbf01):_0xa268cd;}async[a0_0x26d955(0x1de)](){const _0x805b65=a0_0x26d955;if(this[_0x805b65(0x1c1)])return;this[_0x805b65(0x1c1)]=!0x0,await this[_0x805b65(0x20d)](_0x805b65(0x1eb)),this[_0x805b65(0x1c5)](_0x805b65(0x1ee)),this[_0x805b65(0x233)]=setInterval(()=>{const _0x5a01ef=_0x805b65;this[_0x5a01ef(0x20d)](_0x5a01ef(0x1eb))[_0x5a01ef(0x1d7)](_0x35927b=>this[_0x5a01ef(0x1c5)](_0x5a01ef(0x222)+_0x35927b[_0x5a01ef(0x1dc)]));},this[_0x805b65(0x1ed)]),this['connectSSE']();}async[a0_0x26d955(0x1f3)](){const _0x3e28be=a0_0x26d955;if(this['running']=!0x1,this[_0x3e28be(0x1cd)]?.[_0x3e28be(0x1e8)](),this[_0x3e28be(0x233)])clearInterval(this[_0x3e28be(0x233)]);await this[_0x3e28be(0x20d)](_0x3e28be(0x1ff))[_0x3e28be(0x1d7)](()=>{}),this[_0x3e28be(0x1c5)](_0x3e28be(0x202));}async[a0_0x26d955(0x1d1)](_0x5a1bfc,_0x14ca77,_0x48436d='normal'){const _0x23ebf5=a0_0x26d955;return Y({'alias':_0x5a1bfc,'fromAlias':this['alias']},{'log':_0x5c1bab=>console[_0x23ebf5(0x1c5)](_0x5c1bab),'send':()=>this['call']('send_task',{'alias':_0x5a1bfc,'task':_0x14ca77,'priority':_0x48436d,'from_session':this[_0x23ebf5(0x216)]})});}async[a0_0x26d955(0x1dc)](_0x354cb9,_0xd251d6){const _0x16fd44=a0_0x26d955;return this[_0x16fd44(0x1db)](_0x16fd44(0x21c),{'alias':_0x354cb9,'message':_0xd251d6,'from_session':this[_0x16fd44(0x216)]});}async[a0_0x26d955(0x218)](_0x1b7d29,_0x1d6c1c,_0x3c32da=a0_0x26d955(0x228)){const _0x530413=a0_0x26d955;return this[_0x530413(0x1db)](_0x530413(0x21b),{'in_reply_to':_0x1b7d29,'text':_0x1d6c1c,'status':_0x3c32da});}async[a0_0x26d955(0x20d)](_0x349a21,_0x213ebf){const _0x4bbf23=a0_0x26d955;return this[_0x4bbf23(0x1db)](_0x4bbf23(0x1fb),{'resume_id':this[_0x4bbf23(0x21d)],'alias':this[_0x4bbf23(0x216)],'status':_0x349a21,'server':a0_0x5b2d48(),'hostname':a0_0x5b2d48(),'agent':this[_0x4bbf23(0x200)],'project_dir':process[_0x4bbf23(0x21e)](),..._0x213ebf});}async[a0_0x26d955(0x22c)](){const _0x4c0e88=a0_0x26d955;return this[_0x4c0e88(0x1db)]('get_all_status',{});}async[a0_0x26d955(0x1e6)](_0x24547d,_0x283b82){const _0x22e3ce=a0_0x26d955;return this[_0x22e3ce(0x1db)](_0x22e3ce(0x1e6),{'message':_0x24547d,'filter_server':_0x283b82?.[_0x22e3ce(0x22b)],'filter_status':_0x283b82?.[_0x22e3ce(0x20d)]});}async[a0_0x26d955(0x1b8)](){const _0x5eab37=a0_0x26d955;let _0xf4fdb7=encodeURIComponent(this[_0x5eab37(0x216)]),_0x110956=this[_0x5eab37(0x1df)]+_0x5eab37(0x1e7)+_0xf4fdb7,_0x10849e=this[_0x5eab37(0x1fc)];while(this['running']){try{this[_0x5eab37(0x1cd)]=new AbortController();let _0x255520={'Accept':_0x5eab37(0x1ca)};if(this[_0x5eab37(0x1f4)])_0x255520[_0x5eab37(0x226)]=_0x5eab37(0x20e)+this[_0x5eab37(0x1f4)];let _0x7bcac5=await fetch(_0x110956,{'headers':_0x255520,'signal':this[_0x5eab37(0x1cd)]['signal']});if(!_0x7bcac5['ok']||!_0x7bcac5[_0x5eab37(0x22d)]){this[_0x5eab37(0x1c5)](_0x5eab37(0x204)+_0x7bcac5['status']),await this[_0x5eab37(0x1b9)](_0x10849e),_0x10849e=Math['min'](_0x10849e*1.5,0xea60);continue;}_0x10849e=this[_0x5eab37(0x1fc)];let _0x5d386c=_0x7bcac5[_0x5eab37(0x22d)][_0x5eab37(0x20f)](),_0x574b69=new TextDecoder(),_0x480831='';while(this[_0x5eab37(0x1c1)]){let {done:_0x38013d,value:_0x341fb2}=await _0x5d386c[_0x5eab37(0x1c6)]();if(_0x38013d)break;_0x480831+=_0x574b69['decode'](_0x341fb2,{'stream':!0x0});let _0x48e113=_0x480831[_0x5eab37(0x1cc)]('\x0a');_0x480831=_0x48e113['pop']()||'';for(let _0x4c5d2e of _0x48e113){if(!_0x4c5d2e[_0x5eab37(0x1e1)](_0x5eab37(0x22a)))continue;try{let _0x374bb1=JSON[_0x5eab37(0x221)](_0x4c5d2e[_0x5eab37(0x231)](0x6));if(_0x374bb1['type']==='connected'){this[_0x5eab37(0x1c5)](_0x5eab37(0x1d3)),this[_0x5eab37(0x1c2)](_0x5eab37(0x20a));continue;}if(_0x374bb1[_0x5eab37(0x1d6)]==='new_task'||_0x374bb1[_0x5eab37(0x1d6)]==='new_message'||_0x374bb1['type']==='broadcast')await this[_0x5eab37(0x20c)]();}catch{}}}}catch(_0x5e1666){if(_0x5e1666[_0x5eab37(0x1e5)]==='AbortError')break;this[_0x5eab37(0x1c2)](_0x5eab37(0x208),_0x5e1666),this[_0x5eab37(0x1c5)](_0x5eab37(0x1e3)+_0x5e1666[_0x5eab37(0x1dc)]);}if(this[_0x5eab37(0x1c1)])this[_0x5eab37(0x1c2)](_0x5eab37(0x202)),this[_0x5eab37(0x1c5)](_0x5eab37(0x1c4)+_0x10849e/0x3e8+_0x5eab37(0x201)),await this[_0x5eab37(0x1b9)](_0x10849e),_0x10849e=Math['min'](_0x10849e*1.5,0xea60);}}async[a0_0x26d955(0x20c)](){const _0x256de6=a0_0x26d955;try{let _0x39eb3b=(await this[_0x256de6(0x1db)]('get_inbox',{'alias':this['alias'],'limit':0xa}))?.['messages']||[];for(let _0x5f2ecd of _0x39eb3b)await this[_0x256de6(0x1db)](_0x256de6(0x1d0),{'alias':this[_0x256de6(0x216)],'message_id':_0x5f2ecd['id']}),this[_0x256de6(0x1c5)]('←\x20'+_0x5f2ecd['from_session']+':\x20'+_0x5f2ecd[_0x256de6(0x214)][_0x256de6(0x231)](0x0,0x3c)),this[_0x256de6(0x1c2)](_0x256de6(0x1bd),_0x5f2ecd),this[_0x256de6(0x1c2)](_0x256de6(0x1dc),_0x5f2ecd);}catch(_0x5884bd){this[_0x256de6(0x1c5)](_0x256de6(0x22e)+_0x5884bd[_0x256de6(0x1dc)]);}}[a0_0x26d955(0x1b9)](_0x3a46dd){return new Promise(_0x4aa742=>setTimeout(_0x4aa742,_0x3a46dd));}}var F=$;export{F as default,$ as CommHub};
1
+ const a0_0x530533=a0_0x335c;(function(_0x1c5d52,_0x2f5955){const _0x4643e0=a0_0x335c,_0x3748d7=_0x1c5d52();while(!![]){try{const _0x344ba9=-parseInt(_0x4643e0(0xb3))/0x1*(parseInt(_0x4643e0(0x9c))/0x2)+-parseInt(_0x4643e0(0xf9))/0x3*(parseInt(_0x4643e0(0x95))/0x4)+-parseInt(_0x4643e0(0xde))/0x5*(parseInt(_0x4643e0(0xd9))/0x6)+parseInt(_0x4643e0(0xef))/0x7+-parseInt(_0x4643e0(0x97))/0x8+-parseInt(_0x4643e0(0x105))/0x9+parseInt(_0x4643e0(0x8f))/0xa;if(_0x344ba9===_0x2f5955)break;else _0x3748d7['push'](_0x3748d7['shift']());}catch(_0x5e7ba1){_0x3748d7['push'](_0x3748d7['shift']());}}}(a0_0x58c6,0xd0b4d));function a0_0x58c6(){const _0x3898ec=['CommHub\x20rejected\x20task','heartbeatInterval','task.replied','/events/','completed','/mcp','getReader','366TYBhOr','sleep','cwd','string','token','104285hgOoUN','disconnect','transport','decode','task.send.start','AbortError','broadcast','fromAlias','\x20network_id=','<unknown>','SSE\x20error:\x20','error','autoConnect','text/event-stream','lifecycle_tracking','task','<pending>','5638290YNpLBO','send_failed','emit',']\x20[commhub:','Bearer\x20','connected','sdk','error_code','send_reply','send_message','4413yjxVto','unknown\x20error','Authorization','[commhub:task]\x20','match','<missing>','not_tracked','tools/call','result','heartbeatTimer','sseAbort','min','1429065wXCHaw','read','inbox\x20error:\x20','alias','slice','disconnected','startsWith','server','message','sending','ack_inbox','agent','send','36177130PZgVEj','task.started','task.expired','reconnectDelay','\x20error=','delivered','4164NLvHsm','reply','3027344qQiQdV','toString','offline','data:\x20','content','2XvBYIT','running','get_all_status','task_id','task.send.delivered','\x20to=','sdk-','connectSSE','\x20from=','networkId','messages','signal','SSE\x20connected','\x20parent_task_id=','catch','heartbeat\x20failed:\x20','idle','now','normal','failed','[REDACTED]','parse','replace','227531FDncUE','call','error_message','split','processInbox','network_id','task.ack','new_task','duration_ms','resumeId','getAllStatus','pop','status','mcp_http','send_task','message_id','type','SSE\x20failed:\x20','CommHub\x20response\x20omitted\x20task_id','to_alias','text','url','log','toTimeString','name','task.send.failed','SSE\x20reconnecting\x20in\x20','application/json','connect','body','toAlias'];a0_0x58c6=function(){return _0x3898ec;};return a0_0x58c6();}import{EventEmitter as a0_0x4c34bc}from'events';import{hostname as a0_0x5ca233}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0xd0596c,_0x3911c9)=>(_0xd0596c??_0x3911c9)[a0_0x530533(0xb2)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x530533(0x109)](0x0,0xf0);function N(_0x3523ec){const _0x282bf2=a0_0x530533;return(_0x3523ec instanceof Error?_0x3523ec['message']:String(_0x3523ec??_0x282bf2(0xfa)))[_0x282bf2(0xb2)](K,_0x282bf2(0xb0))[_0x282bf2(0xb2)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x282bf2(0x109)](0x0,0xf0);}function O(_0x4c9296,_0x4bd93a=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x3d3da5=a0_0x530533;if(_0x4bd93a)return JSON['stringify'](_0x4c9296);let _0x1febae=L(_0x4c9296['parent_task_id'],_0x3d3da5(0xfe)),_0x5e3d40=L(_0x4c9296[_0x3d3da5(0x9f)],_0x3d3da5(0xee)),_0x1f04ca=_0x4c9296['error_code']?_0x3d3da5(0x93)+_0x4c9296[_0x3d3da5(0xf6)]+':'+(_0x4c9296[_0x3d3da5(0xb5)]??''):'';return _0x3d3da5(0xfc)+_0x4c9296['status']+_0x3d3da5(0xa4)+L(_0x4c9296['from_alias'],_0x3d3da5(0xe7))+_0x3d3da5(0xa1)+L(_0x4c9296[_0x3d3da5(0xc6)],_0x3d3da5(0xe7))+'\x20task_id='+_0x5e3d40+_0x3d3da5(0xa9)+_0x1febae+_0x3d3da5(0xe6)+L(_0x4c9296[_0x3d3da5(0xb8)],'<unknown>')+'\x20transport='+_0x4c9296[_0x3d3da5(0xe0)]+'\x20duration_ms='+_0x4c9296[_0x3d3da5(0xbb)]+'\x20lifecycle='+_0x4c9296[_0x3d3da5(0xec)]+_0x1f04ca;}function U(_0x4278ec){const _0x146b28=a0_0x530533;return{'event':{'sending':_0x146b28(0xe2),'delivered':_0x146b28(0xa0),'failed':_0x146b28(0xcc),'acked':_0x146b28(0xb9),'started':_0x146b28(0x90),'replied':_0x146b28(0xd4),'expired':_0x146b28(0x91)}[_0x4278ec[_0x146b28(0xbf)]],..._0x4278ec};}function j(_0x269f9e){const _0x11ed8a=a0_0x530533;let _0x3bc23b=_0x269f9e?.[_0x11ed8a(0x9f)]||_0x269f9e?.[_0x11ed8a(0xc2)]||_0x269f9e?.['id'];if(_0x3bc23b)return String(_0x3bc23b);let _0x52bb2e=_0x269f9e?.['content']?.[0x0]?.[_0x11ed8a(0xc7)];if(typeof _0x52bb2e!==_0x11ed8a(0xdc))return null;try{let _0x29339f=JSON['parse'](_0x52bb2e);return _0x29339f?.[_0x11ed8a(0x9f)]||_0x29339f?.[_0x11ed8a(0xc2)]||_0x29339f?.['id']||null;}catch{return null;}}async function X(_0x19d56c,_0x1fcd73){const _0x4f6763=a0_0x530533;let _0x15df67=_0x1fcd73[_0x4f6763(0xad)]??Date['now'],_0x440f73=_0x15df67(),_0x1aea46=(_0x12c9ed,_0xce711a,_0x594975,_0x21705a)=>{const _0x4af90d=_0x4f6763;_0x1fcd73[_0x4af90d(0xc9)](O(U({'from_alias':_0x19d56c[_0x4af90d(0xe5)],'to_alias':_0x19d56c[_0x4af90d(0xd1)],'task_id':_0xce711a,'parent_task_id':_0x19d56c['parentTaskId'],'network_id':_0x19d56c[_0x4af90d(0xa5)],'transport':_0x19d56c[_0x4af90d(0xe0)],'status':_0x12c9ed,'duration_ms':_0x15df67()-_0x440f73,'lifecycle_tracking':_0x19d56c['lifecycleTracking'],..._0x594975!==void 0x0?{'error_code':_0x21705a||_0x4af90d(0xf0),'error_message':N(_0x594975)}:{}})));};_0x1aea46(_0x4f6763(0x8b),null);try{let _0x26d889=await _0x1fcd73[_0x4f6763(0x8e)](),_0x1fb44a=j(_0x26d889);if(_0x1fb44a)_0x1aea46(_0x4f6763(0x94),_0x1fb44a);else{if(_0x26d889?.['ok']===!0x1||_0x26d889?.[_0x4f6763(0xe9)])_0x1aea46(_0x4f6763(0xaf),_0x1fb44a,_0x26d889?.[_0x4f6763(0xe9)]||_0x4f6763(0xd2),'send_rejected');else _0x1aea46(_0x4f6763(0xaf),null,_0x4f6763(0xc5),'missing_task_id');}return _0x26d889;}catch(_0xf40b50){throw _0x1aea46('failed',null,_0xf40b50,_0x4f6763(0xf0)),_0xf40b50;}}function a0_0x335c(_0x40db36,_0x51eb74){_0x40db36=_0x40db36-0x8b;const _0x58c6c5=a0_0x58c6();let _0x335c45=_0x58c6c5[_0x40db36];return _0x335c45;}async function Y(_0x164bb8,_0x165794){const _0x216571=a0_0x530533;return X({'fromAlias':_0x164bb8[_0x216571(0xe5)],'toAlias':_0x164bb8[_0x216571(0x108)],'parentTaskId':_0x164bb8['parentTaskId']||null,'networkId':_0x164bb8[_0x216571(0xa5)]||null,'transport':_0x216571(0xc0),'lifecycleTracking':_0x216571(0xff)},_0x165794);}class $ extends a0_0x4c34bc{['url'];[a0_0x530533(0x108)];[a0_0x530533(0xdd)];[a0_0x530533(0x8d)];['resumeId'];['heartbeatInterval'];[a0_0x530533(0x92)];['heartbeatTimer'];['sseAbort'];[a0_0x530533(0x9d)]=!0x1;constructor(_0x5adf60){const _0x35e1bc=a0_0x530533;super();if(this[_0x35e1bc(0xc8)]=_0x5adf60[_0x35e1bc(0xc8)][_0x35e1bc(0xb2)](/\/$/,''),this[_0x35e1bc(0x108)]=_0x5adf60['alias'],this[_0x35e1bc(0xdd)]=_0x5adf60[_0x35e1bc(0xdd)],this[_0x35e1bc(0x8d)]=_0x5adf60['agent']||_0x35e1bc(0xf5),this[_0x35e1bc(0xbc)]=_0x35e1bc(0xa2)+_0x5adf60[_0x35e1bc(0x108)]+'-'+Date[_0x35e1bc(0xad)]()[_0x35e1bc(0x98)](0x24),this[_0x35e1bc(0xd3)]=_0x5adf60[_0x35e1bc(0xd3)]??0x2bf20,this[_0x35e1bc(0x92)]=_0x5adf60[_0x35e1bc(0x92)]??0xbb8,_0x5adf60[_0x35e1bc(0xea)]!==!0x1)this[_0x35e1bc(0xcf)]();}[a0_0x530533(0xc9)](_0x49689e){const _0x4f7849=a0_0x530533;console[_0x4f7849(0xc9)]('['+new Date()[_0x4f7849(0xca)]()['slice'](0x0,0x8)+_0x4f7849(0xf2)+this['alias']+']\x20'+_0x49689e);}async[a0_0x530533(0xb4)](_0xb8d4c0,_0x33f690){const _0x1a3eeb=a0_0x530533;let _0x30927c={'Content-Type':_0x1a3eeb(0xce),'Accept':'application/json,\x20text/event-stream'};if(this[_0x1a3eeb(0xdd)])_0x30927c[_0x1a3eeb(0xfb)]='Bearer\x20'+this['token'];let _0x504036=await(await fetch(this['url']+_0x1a3eeb(0xd7),{'method':'POST','headers':_0x30927c,'body':JSON['stringify']({'jsonrpc':'2.0','id':Date['now'](),'method':_0x1a3eeb(0x100),'params':{'name':_0xb8d4c0,'arguments':_0x33f690}})}))[_0x1a3eeb(0xc7)](),_0x5f0c54=_0x504036[_0x1a3eeb(0xfd)](/data: (.+)/),_0x56d42b=_0x5f0c54?JSON['parse'](_0x5f0c54[0x1]):JSON['parse'](_0x504036),_0x5b2fd1=_0x56d42b?.[_0x1a3eeb(0x101)]?.[_0x1a3eeb(0x9b)]?.[0x0]?.['text'];return _0x5b2fd1?JSON[_0x1a3eeb(0xb1)](_0x5b2fd1):_0x56d42b;}async[a0_0x530533(0xcf)](){const _0x5265c6=a0_0x530533;if(this['running'])return;this[_0x5265c6(0x9d)]=!0x0,await this[_0x5265c6(0xbf)](_0x5265c6(0xac)),this[_0x5265c6(0xc9)]('registered'),this[_0x5265c6(0x102)]=setInterval(()=>{const _0x7debef=_0x5265c6;this[_0x7debef(0xbf)](_0x7debef(0xac))[_0x7debef(0xaa)](_0x4bb19e=>this[_0x7debef(0xc9)](_0x7debef(0xab)+_0x4bb19e[_0x7debef(0x10d)]));},this['heartbeatInterval']),this[_0x5265c6(0xa3)]();}async[a0_0x530533(0xdf)](){const _0x362336=a0_0x530533;if(this[_0x362336(0x9d)]=!0x1,this[_0x362336(0x103)]?.['abort'](),this[_0x362336(0x102)])clearInterval(this[_0x362336(0x102)]);await this[_0x362336(0xbf)](_0x362336(0x99))[_0x362336(0xaa)](()=>{}),this[_0x362336(0xc9)](_0x362336(0x10a));}async[a0_0x530533(0x8e)](_0x6171f7,_0x1ae860,_0x5a47a2=a0_0x530533(0xae)){const _0xf30c46=a0_0x530533;return Y({'alias':_0x6171f7,'fromAlias':this['alias']},{'log':_0x19db47=>console[_0xf30c46(0xc9)](_0x19db47),'send':()=>this[_0xf30c46(0xb4)](_0xf30c46(0xc1),{'alias':_0x6171f7,'task':_0x1ae860,'priority':_0x5a47a2,'from_session':this[_0xf30c46(0x108)]})});}async[a0_0x530533(0x10d)](_0x11d94d,_0x5e8f91){const _0x2d6423=a0_0x530533;return this[_0x2d6423(0xb4)](_0x2d6423(0xf8),{'alias':_0x11d94d,'message':_0x5e8f91,'from_session':this[_0x2d6423(0x108)]});}async[a0_0x530533(0x96)](_0x206ac4,_0x33fcdb,_0x3944f6=a0_0x530533(0xd6)){const _0x53713a=a0_0x530533;return this[_0x53713a(0xb4)](_0x53713a(0xf7),{'in_reply_to':_0x206ac4,'text':_0x33fcdb,'status':_0x3944f6});}async[a0_0x530533(0xbf)](_0x17ea0d,_0x58243b){const _0x393739=a0_0x530533;return this[_0x393739(0xb4)]('report_status',{'resume_id':this[_0x393739(0xbc)],'alias':this[_0x393739(0x108)],'status':_0x17ea0d,'server':a0_0x5ca233(),'hostname':a0_0x5ca233(),'agent':this[_0x393739(0x8d)],'project_dir':process[_0x393739(0xdb)](),..._0x58243b});}async[a0_0x530533(0xbd)](){const _0x208f37=a0_0x530533;return this['call'](_0x208f37(0x9e),{});}async['broadcast'](_0x111e5c,_0x40bade){const _0x3343eb=a0_0x530533;return this[_0x3343eb(0xb4)](_0x3343eb(0xe4),{'message':_0x111e5c,'filter_server':_0x40bade?.[_0x3343eb(0x10c)],'filter_status':_0x40bade?.[_0x3343eb(0xbf)]});}async[a0_0x530533(0xa3)](){const _0x404abe=a0_0x530533;let _0x32220c=encodeURIComponent(this[_0x404abe(0x108)]),_0x13c043=this[_0x404abe(0xc8)]+_0x404abe(0xd5)+_0x32220c,_0x5f4edc=this[_0x404abe(0x92)];while(this['running']){try{this[_0x404abe(0x103)]=new AbortController();let _0x22db17={'Accept':_0x404abe(0xeb)};if(this[_0x404abe(0xdd)])_0x22db17[_0x404abe(0xfb)]=_0x404abe(0xf3)+this[_0x404abe(0xdd)];let _0x8daa6e=await fetch(_0x13c043,{'headers':_0x22db17,'signal':this[_0x404abe(0x103)][_0x404abe(0xa7)]});if(!_0x8daa6e['ok']||!_0x8daa6e[_0x404abe(0xd0)]){this['log'](_0x404abe(0xc4)+_0x8daa6e[_0x404abe(0xbf)]),await this[_0x404abe(0xda)](_0x5f4edc),_0x5f4edc=Math[_0x404abe(0x104)](_0x5f4edc*1.5,0xea60);continue;}_0x5f4edc=this['reconnectDelay'];let _0x55b24f=_0x8daa6e[_0x404abe(0xd0)][_0x404abe(0xd8)](),_0x3c3aa0=new TextDecoder(),_0x1f1371='';while(this['running']){let {done:_0x148f41,value:_0x133039}=await _0x55b24f[_0x404abe(0x106)]();if(_0x148f41)break;_0x1f1371+=_0x3c3aa0[_0x404abe(0xe1)](_0x133039,{'stream':!0x0});let _0x1e39c1=_0x1f1371[_0x404abe(0xb6)]('\x0a');_0x1f1371=_0x1e39c1[_0x404abe(0xbe)]()||'';for(let _0x1e6f99 of _0x1e39c1){if(!_0x1e6f99[_0x404abe(0x10b)](_0x404abe(0x9a)))continue;try{let _0x5c1ba6=JSON[_0x404abe(0xb1)](_0x1e6f99[_0x404abe(0x109)](0x6));if(_0x5c1ba6['type']===_0x404abe(0xf4)){this['log'](_0x404abe(0xa8)),this[_0x404abe(0xf1)](_0x404abe(0xf4));continue;}if(_0x5c1ba6[_0x404abe(0xc3)]===_0x404abe(0xba)||_0x5c1ba6['type']==='new_message'||_0x5c1ba6[_0x404abe(0xc3)]==='broadcast')await this[_0x404abe(0xb7)]();}catch{}}}}catch(_0x136a28){if(_0x136a28[_0x404abe(0xcb)]===_0x404abe(0xe3))break;this[_0x404abe(0xf1)](_0x404abe(0xe9),_0x136a28),this[_0x404abe(0xc9)](_0x404abe(0xe8)+_0x136a28[_0x404abe(0x10d)]);}if(this[_0x404abe(0x9d)])this[_0x404abe(0xf1)](_0x404abe(0x10a)),this[_0x404abe(0xc9)](_0x404abe(0xcd)+_0x5f4edc/0x3e8+'s...'),await this[_0x404abe(0xda)](_0x5f4edc),_0x5f4edc=Math[_0x404abe(0x104)](_0x5f4edc*1.5,0xea60);}}async['processInbox'](){const _0x539255=a0_0x530533;try{let _0xf37878=(await this[_0x539255(0xb4)]('get_inbox',{'alias':this[_0x539255(0x108)],'limit':0xa}))?.[_0x539255(0xa6)]||[];for(let _0xcc9324 of _0xf37878)await this['call'](_0x539255(0x8c),{'alias':this[_0x539255(0x108)],'message_id':_0xcc9324['id']}),this[_0x539255(0xc9)]('←\x20'+_0xcc9324['from_session']+':\x20'+_0xcc9324[_0x539255(0x9b)][_0x539255(0x109)](0x0,0x3c)),this[_0x539255(0xf1)](_0x539255(0xed),_0xcc9324),this[_0x539255(0xf1)](_0x539255(0x10d),_0xcc9324);}catch(_0x4ba9a0){this[_0x539255(0xc9)](_0x539255(0x107)+_0x4ba9a0[_0x539255(0x10d)]);}}[a0_0x530533(0xda)](_0x2670cc){return new Promise(_0x2b8239=>setTimeout(_0x2b8239,_0x2670cc));}}var F=$;export{F as default,$ as CommHub};