@sleep2agi/agent-network 2.3.0-preview.55 → 2.3.0-preview.57

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_0x30a80e=a0_0x198e;(function(_0x51b88b,_0x35a639){const _0x229363=a0_0x198e,_0x21f58f=_0x51b88b();while(!![]){try{const _0x20d2b5=parseInt(_0x229363(0x14b))/0x1+-parseInt(_0x229363(0x11e))/0x2*(-parseInt(_0x229363(0x146))/0x3)+-parseInt(_0x229363(0x168))/0x4*(parseInt(_0x229363(0x14c))/0x5)+parseInt(_0x229363(0x186))/0x6*(-parseInt(_0x229363(0x151))/0x7)+-parseInt(_0x229363(0x118))/0x8+parseInt(_0x229363(0x169))/0x9*(-parseInt(_0x229363(0x161))/0xa)+parseInt(_0x229363(0x111))/0xb;if(_0x20d2b5===_0x35a639)break;else _0x21f58f['push'](_0x21f58f['shift']());}catch(_0x5221dc){_0x21f58f['push'](_0x21f58f['shift']());}}}(a0_0x1e59,0xbc8f6));import{EventEmitter as a0_0xaa6cc3}from'events';import{hostname as a0_0x4cef47}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x16d387,_0x3543ea)=>(_0x16d387??_0x3543ea)[a0_0x30a80e(0x109)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x5a9fed){const _0x16f0d2=a0_0x30a80e;return(_0x5a9fed instanceof Error?_0x5a9fed[_0x16f0d2(0x157)]:String(_0x5a9fed??_0x16f0d2(0x159)))['replace'](K,_0x16f0d2(0x162))[_0x16f0d2(0x109)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x16f0d2(0x172)](0x0,0xf0);}function O(_0x18a0fe,_0x38fb1c=process.env.ANET_TASK_TRACE_FORMAT===a0_0x30a80e(0x148)){const _0x719f15=a0_0x30a80e;if(_0x38fb1c)return JSON[_0x719f15(0x179)](_0x18a0fe);let _0x542739=L(_0x18a0fe[_0x719f15(0x12b)],_0x719f15(0x165)),_0x4b1f23=L(_0x18a0fe[_0x719f15(0x156)],'<pending>'),_0xc4e92b=_0x18a0fe[_0x719f15(0x117)]?_0x719f15(0x11a)+_0x18a0fe['error_code']+':'+(_0x18a0fe[_0x719f15(0x164)]??''):'';return _0x719f15(0x119)+_0x18a0fe[_0x719f15(0x182)]+_0x719f15(0x11b)+L(_0x18a0fe[_0x719f15(0x153)],_0x719f15(0x14a))+_0x719f15(0x15a)+L(_0x18a0fe[_0x719f15(0x14e)],_0x719f15(0x14a))+_0x719f15(0x16f)+_0x4b1f23+'\x20parent_task_id='+_0x542739+_0x719f15(0x176)+L(_0x18a0fe['network_id'],_0x719f15(0x14a))+_0x719f15(0x131)+_0x18a0fe['transport']+_0x719f15(0x180)+_0x18a0fe[_0x719f15(0x107)]+_0x719f15(0x17b)+_0x18a0fe[_0x719f15(0x12e)]+_0xc4e92b;}function U(_0x329328){const _0x3f8c72=a0_0x30a80e;return{'event':{'sending':'task.send.start','delivered':_0x3f8c72(0x155),'failed':_0x3f8c72(0x145),'acked':_0x3f8c72(0x16a),'started':_0x3f8c72(0x14f),'replied':_0x3f8c72(0x134),'expired':'task.expired'}[_0x329328[_0x3f8c72(0x182)]],..._0x329328};}function a0_0x1e59(){const _0x450bd2=['new_message','decode','match','Authorization','\x20duration_ms=','alias','status','messages','agent',']\x20[commhub:','12ZjCYbe','signal','split','duration_ms','registered','replace','url','report_status','sseAbort','transport','normal','text','s...','25661196nUiXIH','SSE\x20reconnecting\x20in\x20','SSE\x20failed:\x20','send_reply','ack_inbox','call','error_code','11567608WjghbQ','[commhub:task]\x20','\x20error=','\x20from=','min','read','2pPddba','toAlias','send','reply','SSE\x20error:\x20','sleep','missing_task_id','content','not_tracked','parentTaskId','from_session','application/json','disconnected','parent_task_id','connect','CommHub\x20rejected\x20task','lifecycle_tracking','reconnectDelay','heartbeatTimer','\x20transport=','delivered','now','task.replied','task','CommHub\x20response\x20omitted\x20task_id','broadcast','processInbox','resumeId','networkId','catch','autoConnect','string','inbox\x20error:\x20','completed','mcp_http','body','parse','cwd','offline','task.send.failed','3433215zrMTWA','lifecycleTracking','json','text/event-stream','<unknown>','1323425DAodZK','2015BsKaRK','type','to_alias','task.started','POST','2503921YePYts','send_rejected','from_alias','send_message','task.send.delivered','task_id','message','emit','unknown\x20error','\x20to=','running','disconnect','toTimeString','log','Bearer\x20','connectSSE','20PiBhva','[REDACTED]','data:\x20','error_message','<missing>','get_inbox','error','6108IRVZOu','5632137fZpPZH','task.ack','new_task','heartbeatInterval','sending','message_id','\x20task_id=','startsWith','idle','slice','failed','connected','getAllStatus','\x20network_id=','sdk-','token','stringify','SSE\x20connected','\x20lifecycle='];a0_0x1e59=function(){return _0x450bd2;};return a0_0x1e59();}function j(_0x58100f){const _0x2c9288=a0_0x30a80e;let _0x5a53d8=_0x58100f?.['task_id']||_0x58100f?.[_0x2c9288(0x16e)]||_0x58100f?.['id'];if(_0x5a53d8)return String(_0x5a53d8);let _0x44858b=_0x58100f?.[_0x2c9288(0x125)]?.[0x0]?.['text'];if(typeof _0x44858b!==_0x2c9288(0x13d))return null;try{let _0x29aab2=JSON[_0x2c9288(0x142)](_0x44858b);return _0x29aab2?.[_0x2c9288(0x156)]||_0x29aab2?.[_0x2c9288(0x16e)]||_0x29aab2?.['id']||null;}catch{return null;}}async function X(_0x343eee,_0x64bb6f){const _0x549b4e=a0_0x30a80e;let _0x255b64=_0x64bb6f[_0x549b4e(0x133)]??Date['now'],_0x48c745=_0x255b64(),_0x18da47=(_0x5b8120,_0xa1346,_0x4ff74a,_0x345005)=>{const _0x336f56=_0x549b4e;_0x64bb6f['log'](O(U({'from_alias':_0x343eee['fromAlias'],'to_alias':_0x343eee[_0x336f56(0x11f)],'task_id':_0xa1346,'parent_task_id':_0x343eee[_0x336f56(0x127)],'network_id':_0x343eee[_0x336f56(0x13a)],'transport':_0x343eee[_0x336f56(0x10d)],'status':_0x5b8120,'duration_ms':_0x255b64()-_0x48c745,'lifecycle_tracking':_0x343eee[_0x336f56(0x147)],..._0x4ff74a!==void 0x0?{'error_code':_0x345005||'send_failed','error_message':N(_0x4ff74a)}:{}})));};_0x18da47(_0x549b4e(0x16d),null);try{let _0x5f179c=await _0x64bb6f['send'](),_0xc72e40=j(_0x5f179c);if(_0xc72e40)_0x18da47(_0x549b4e(0x132),_0xc72e40);else{if(_0x5f179c?.['ok']===!0x1||_0x5f179c?.[_0x549b4e(0x167)])_0x18da47(_0x549b4e(0x173),_0xc72e40,_0x5f179c?.['error']||_0x549b4e(0x12d),_0x549b4e(0x152));else _0x18da47(_0x549b4e(0x173),null,_0x549b4e(0x136),_0x549b4e(0x124));}return _0x5f179c;}catch(_0x19a863){throw _0x18da47(_0x549b4e(0x173),null,_0x19a863,'send_failed'),_0x19a863;}}function a0_0x198e(_0x35e674,_0xbd5336){_0x35e674=_0x35e674-0x106;const _0x1e59de=a0_0x1e59();let _0x198ecd=_0x1e59de[_0x35e674];return _0x198ecd;}async function Y(_0x1c5871,_0x439ee2){const _0x2af831=a0_0x30a80e;return X({'fromAlias':_0x1c5871['fromAlias'],'toAlias':_0x1c5871[_0x2af831(0x181)],'parentTaskId':_0x1c5871['parentTaskId']||null,'networkId':_0x1c5871['networkId']||null,'transport':_0x2af831(0x140),'lifecycleTracking':_0x2af831(0x126)},_0x439ee2);}class $ extends a0_0xaa6cc3{[a0_0x30a80e(0x10a)];['alias'];['token'];['agent'];[a0_0x30a80e(0x139)];[a0_0x30a80e(0x16c)];['reconnectDelay'];['heartbeatTimer'];['sseAbort'];['running']=!0x1;constructor(_0x22fd2d){const _0x2b4008=a0_0x30a80e;super();if(this[_0x2b4008(0x10a)]=_0x22fd2d[_0x2b4008(0x10a)][_0x2b4008(0x109)](/\/$/,''),this['alias']=_0x22fd2d[_0x2b4008(0x181)],this['token']=_0x22fd2d[_0x2b4008(0x178)],this[_0x2b4008(0x184)]=_0x22fd2d[_0x2b4008(0x184)]||'sdk',this[_0x2b4008(0x139)]=_0x2b4008(0x177)+_0x22fd2d[_0x2b4008(0x181)]+'-'+Date['now']()['toString'](0x24),this[_0x2b4008(0x16c)]=_0x22fd2d[_0x2b4008(0x16c)]??0x2bf20,this[_0x2b4008(0x12f)]=_0x22fd2d[_0x2b4008(0x12f)]??0xbb8,_0x22fd2d[_0x2b4008(0x13c)]!==!0x1)this['connect']();}[a0_0x30a80e(0x15e)](_0x21d716){const _0x2217f6=a0_0x30a80e;console[_0x2217f6(0x15e)]('['+new Date()[_0x2217f6(0x15d)]()[_0x2217f6(0x172)](0x0,0x8)+_0x2217f6(0x185)+this[_0x2217f6(0x181)]+']\x20'+_0x21d716);}async['call'](_0x2be764,_0x4ca2e6){const _0x14f78d=a0_0x30a80e;let _0x4de51a={'Content-Type':_0x14f78d(0x129),'Accept':'application/json,\x20text/event-stream'};if(this[_0x14f78d(0x178)])_0x4de51a[_0x14f78d(0x17f)]=_0x14f78d(0x15f)+this['token'];let _0x1b8938=await(await fetch(this[_0x14f78d(0x10a)]+'/mcp',{'method':_0x14f78d(0x150),'headers':_0x4de51a,'body':JSON['stringify']({'jsonrpc':'2.0','id':Date[_0x14f78d(0x133)](),'method':'tools/call','params':{'name':_0x2be764,'arguments':_0x4ca2e6}})}))[_0x14f78d(0x10f)](),_0x81445d=_0x1b8938[_0x14f78d(0x17e)](/data: (.+)/),_0x3905d7=_0x81445d?JSON['parse'](_0x81445d[0x1]):JSON[_0x14f78d(0x142)](_0x1b8938),_0x358dc4=_0x3905d7?.['result']?.[_0x14f78d(0x125)]?.[0x0]?.['text'];return _0x358dc4?JSON[_0x14f78d(0x142)](_0x358dc4):_0x3905d7;}async[a0_0x30a80e(0x12c)](){const _0x5031ed=a0_0x30a80e;if(this['running'])return;this[_0x5031ed(0x15b)]=!0x0,await this['status'](_0x5031ed(0x171)),this[_0x5031ed(0x15e)](_0x5031ed(0x108)),this[_0x5031ed(0x130)]=setInterval(()=>{const _0x2f6600=_0x5031ed;this['status'](_0x2f6600(0x171))[_0x2f6600(0x13b)](_0x367cb0=>this['log']('heartbeat\x20failed:\x20'+_0x367cb0['message']));},this['heartbeatInterval']),this['connectSSE']();}async[a0_0x30a80e(0x15c)](){const _0x57d80a=a0_0x30a80e;if(this['running']=!0x1,this[_0x57d80a(0x10c)]?.['abort'](),this[_0x57d80a(0x130)])clearInterval(this[_0x57d80a(0x130)]);await this[_0x57d80a(0x182)](_0x57d80a(0x144))[_0x57d80a(0x13b)](()=>{}),this[_0x57d80a(0x15e)](_0x57d80a(0x12a));}async[a0_0x30a80e(0x120)](_0x49e43c,_0x1adc80,_0x5bd5ef=a0_0x30a80e(0x10e)){const _0x18eab3=a0_0x30a80e;return Y({'alias':_0x49e43c,'fromAlias':this[_0x18eab3(0x181)]},{'log':_0x2681ea=>console[_0x18eab3(0x15e)](_0x2681ea),'send':()=>this[_0x18eab3(0x116)]('send_task',{'alias':_0x49e43c,'task':_0x1adc80,'priority':_0x5bd5ef,'from_session':this[_0x18eab3(0x181)]})});}async[a0_0x30a80e(0x157)](_0x165e47,_0x274f3b){const _0x3410c4=a0_0x30a80e;return this[_0x3410c4(0x116)](_0x3410c4(0x154),{'alias':_0x165e47,'message':_0x274f3b,'from_session':this[_0x3410c4(0x181)]});}async[a0_0x30a80e(0x121)](_0x37c415,_0x4993a6,_0x3e5efc=a0_0x30a80e(0x13f)){const _0x4b2545=a0_0x30a80e;return this[_0x4b2545(0x116)](_0x4b2545(0x114),{'in_reply_to':_0x37c415,'text':_0x4993a6,'status':_0x3e5efc});}async[a0_0x30a80e(0x182)](_0x476d34,_0x4cefff){const _0x413d25=a0_0x30a80e;return this[_0x413d25(0x116)](_0x413d25(0x10b),{'resume_id':this['resumeId'],'alias':this[_0x413d25(0x181)],'status':_0x476d34,'server':a0_0x4cef47(),'hostname':a0_0x4cef47(),'agent':this[_0x413d25(0x184)],'project_dir':process[_0x413d25(0x143)](),..._0x4cefff});}async[a0_0x30a80e(0x175)](){const _0x4e6adf=a0_0x30a80e;return this[_0x4e6adf(0x116)]('get_all_status',{});}async[a0_0x30a80e(0x137)](_0x126226,_0x9c08e1){const _0x3689c9=a0_0x30a80e;return this[_0x3689c9(0x116)](_0x3689c9(0x137),{'message':_0x126226,'filter_server':_0x9c08e1?.['server'],'filter_status':_0x9c08e1?.[_0x3689c9(0x182)]});}async[a0_0x30a80e(0x160)](){const _0x2e0300=a0_0x30a80e;let _0x4b55a3=encodeURIComponent(this['alias']),_0x5c0c63=this['url']+'/events/'+_0x4b55a3,_0x597f37=this[_0x2e0300(0x12f)];while(this[_0x2e0300(0x15b)]){try{this['sseAbort']=new AbortController();let _0x40af3f={'Accept':_0x2e0300(0x149)};if(this['token'])_0x40af3f['Authorization']='Bearer\x20'+this['token'];let _0x47ab65=await fetch(_0x5c0c63,{'headers':_0x40af3f,'signal':this[_0x2e0300(0x10c)][_0x2e0300(0x187)]});if(!_0x47ab65['ok']||!_0x47ab65[_0x2e0300(0x141)]){this['log'](_0x2e0300(0x113)+_0x47ab65[_0x2e0300(0x182)]),await this[_0x2e0300(0x123)](_0x597f37),_0x597f37=Math[_0x2e0300(0x11c)](_0x597f37*1.5,0xea60);continue;}_0x597f37=this[_0x2e0300(0x12f)];let _0x325065=_0x47ab65['body']['getReader'](),_0x274a66=new TextDecoder(),_0x3e67af='';while(this[_0x2e0300(0x15b)]){let {done:_0x9f14cf,value:_0xde2648}=await _0x325065[_0x2e0300(0x11d)]();if(_0x9f14cf)break;_0x3e67af+=_0x274a66[_0x2e0300(0x17d)](_0xde2648,{'stream':!0x0});let _0x148f1f=_0x3e67af[_0x2e0300(0x106)]('\x0a');_0x3e67af=_0x148f1f['pop']()||'';for(let _0xa1b22f of _0x148f1f){if(!_0xa1b22f[_0x2e0300(0x170)](_0x2e0300(0x163)))continue;try{let _0x3b3d41=JSON['parse'](_0xa1b22f[_0x2e0300(0x172)](0x6));if(_0x3b3d41[_0x2e0300(0x14d)]===_0x2e0300(0x174)){this[_0x2e0300(0x15e)](_0x2e0300(0x17a)),this['emit'](_0x2e0300(0x174));continue;}if(_0x3b3d41[_0x2e0300(0x14d)]===_0x2e0300(0x16b)||_0x3b3d41[_0x2e0300(0x14d)]===_0x2e0300(0x17c)||_0x3b3d41[_0x2e0300(0x14d)]==='broadcast')await this['processInbox']();}catch{}}}}catch(_0x5761e3){if(_0x5761e3['name']==='AbortError')break;this[_0x2e0300(0x158)](_0x2e0300(0x167),_0x5761e3),this['log'](_0x2e0300(0x122)+_0x5761e3[_0x2e0300(0x157)]);}if(this[_0x2e0300(0x15b)])this[_0x2e0300(0x158)](_0x2e0300(0x12a)),this[_0x2e0300(0x15e)](_0x2e0300(0x112)+_0x597f37/0x3e8+_0x2e0300(0x110)),await this[_0x2e0300(0x123)](_0x597f37),_0x597f37=Math[_0x2e0300(0x11c)](_0x597f37*1.5,0xea60);}}async[a0_0x30a80e(0x138)](){const _0xc424f9=a0_0x30a80e;try{let _0x1bd2d5=(await this[_0xc424f9(0x116)](_0xc424f9(0x166),{'alias':this[_0xc424f9(0x181)],'limit':0xa}))?.[_0xc424f9(0x183)]||[];for(let _0x565402 of _0x1bd2d5)await this[_0xc424f9(0x116)](_0xc424f9(0x115),{'alias':this[_0xc424f9(0x181)],'message_id':_0x565402['id']}),this[_0xc424f9(0x15e)]('←\x20'+_0x565402[_0xc424f9(0x128)]+':\x20'+_0x565402[_0xc424f9(0x125)]['slice'](0x0,0x3c)),this[_0xc424f9(0x158)](_0xc424f9(0x135),_0x565402),this[_0xc424f9(0x158)]('message',_0x565402);}catch(_0x268ddc){this[_0xc424f9(0x15e)](_0xc424f9(0x13e)+_0x268ddc['message']);}}['sleep'](_0x3e1973){return new Promise(_0x5d8496=>setTimeout(_0x5d8496,_0x3e1973));}}var F=$;export{F as default,$ as CommHub};
1
+ const a0_0x2ae722=a0_0x2925;(function(_0x235250,_0x66340f){const _0x503e46=a0_0x2925,_0x52cf0a=_0x235250();while(!![]){try{const _0x47e17b=parseInt(_0x503e46(0x163))/0x1+-parseInt(_0x503e46(0x147))/0x2+parseInt(_0x503e46(0x19c))/0x3*(-parseInt(_0x503e46(0x17b))/0x4)+-parseInt(_0x503e46(0x14b))/0x5+parseInt(_0x503e46(0x17d))/0x6*(parseInt(_0x503e46(0x13e))/0x7)+-parseInt(_0x503e46(0x173))/0x8*(parseInt(_0x503e46(0x141))/0x9)+parseInt(_0x503e46(0x18d))/0xa;if(_0x47e17b===_0x66340f)break;else _0x52cf0a['push'](_0x52cf0a['shift']());}catch(_0x3e2e50){_0x52cf0a['push'](_0x52cf0a['shift']());}}}(a0_0x4856,0x5c92d));import{EventEmitter as a0_0x5b4647}from'events';import{hostname as a0_0x2bba5e}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x332912,_0x217727)=>(_0x332912??_0x217727)[a0_0x2ae722(0x175)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x3cf98b){const _0x396f66=a0_0x2ae722;return(_0x3cf98b instanceof Error?_0x3cf98b['message']:String(_0x3cf98b??_0x396f66(0x150)))[_0x396f66(0x175)](K,_0x396f66(0x19f))[_0x396f66(0x175)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x396f66(0x13d)](0x0,0xf0);}function a0_0x2925(_0x50f325,_0x26329f){_0x50f325=_0x50f325-0x126;const _0x485640=a0_0x4856();let _0x2925bb=_0x485640[_0x50f325];return _0x2925bb;}function a0_0x4856(){const _0x38242c=['sleep','Authorization','normal','560095JEcLIX','/events/','\x20duration_ms=','signal','\x20to=','CommHub\x20response\x20omitted\x20task_id','send_failed','/mcp','task.ack','heartbeat\x20failed:\x20','transport','task_id','sdk','reconnectDelay','url','stringify','160eDePhf','task.send.delivered','replace','POST','\x20lifecycle=','disconnect','heartbeatInterval','network_id','72328LUrTlT','2.0','6NbNKcI','parse','connect','connectSSE','text','match','decode','status','connected','<missing>','json','Bearer\x20','name','min','messages','error','4915810Iduewc','getReader','processInbox','idle','read','data:\x20','s...','duration_ms','string','now','task.expired','heartbeatTimer','task.send.failed','catch','send_task','6PjxEey','error_code','result','[REDACTED]','split','task','\x20transport=','registered','toAlias','completed','get_inbox','from_alias','resumeId','<unknown>','lifecycle_tracking','sseAbort','alias','abort','SSE\x20reconnecting\x20in\x20','sending','message','ack_inbox','\x20error=','sdk-','parentTaskId','from_session','\x20from=','call','new_message','running','startsWith','type',']\x20[commhub:','slice','2238362vzKXip','log','body','275895eXscin','new_task','reply','missing_task_id','\x20task_id=','get_all_status','100970nKcjZB','fromAlias','tools/call','task.replied','1462560MSGmbe','broadcast','task.send.start','send_reply','content','unknown\x20error','send','toString','agent','<pending>','not_tracked','token','disconnected','getAllStatus','failed','message_id','networkId','emit','report_status','error_message','\x20parent_task_id='];a0_0x4856=function(){return _0x38242c;};return a0_0x4856();}function O(_0x15d17f,_0x1d3bdb=process.env.ANET_TASK_TRACE_FORMAT===a0_0x2ae722(0x187)){const _0x4c62b7=a0_0x2ae722;if(_0x1d3bdb)return JSON[_0x4c62b7(0x172)](_0x15d17f);let _0x37123d=L(_0x15d17f['parent_task_id'],_0x4c62b7(0x186)),_0x3c055a=L(_0x15d17f['task_id'],_0x4c62b7(0x154)),_0x3c48a3=_0x15d17f[_0x4c62b7(0x19d)]?_0x4c62b7(0x132)+_0x15d17f[_0x4c62b7(0x19d)]+':'+(_0x15d17f[_0x4c62b7(0x15e)]??''):'';return'[commhub:task]\x20'+_0x15d17f[_0x4c62b7(0x184)]+_0x4c62b7(0x136)+L(_0x15d17f[_0x4c62b7(0x127)],_0x4c62b7(0x129))+_0x4c62b7(0x167)+L(_0x15d17f['to_alias'],_0x4c62b7(0x129))+_0x4c62b7(0x145)+_0x3c055a+_0x4c62b7(0x15f)+_0x37123d+'\x20network_id='+L(_0x15d17f[_0x4c62b7(0x17a)],_0x4c62b7(0x129))+_0x4c62b7(0x1a2)+_0x15d17f[_0x4c62b7(0x16d)]+_0x4c62b7(0x165)+_0x15d17f[_0x4c62b7(0x194)]+_0x4c62b7(0x177)+_0x15d17f[_0x4c62b7(0x12a)]+_0x3c48a3;}function U(_0x47b25f){const _0x124ffb=a0_0x2ae722;return{'event':{'sending':_0x124ffb(0x14d),'delivered':_0x124ffb(0x174),'failed':_0x124ffb(0x199),'acked':_0x124ffb(0x16b),'started':'task.started','replied':_0x124ffb(0x14a),'expired':_0x124ffb(0x197)}[_0x47b25f[_0x124ffb(0x184)]],..._0x47b25f};}function j(_0x46e59b){const _0x34575f=a0_0x2ae722;let _0x117985=_0x46e59b?.[_0x34575f(0x16e)]||_0x46e59b?.[_0x34575f(0x15a)]||_0x46e59b?.['id'];if(_0x117985)return String(_0x117985);let _0x48cc1e=_0x46e59b?.[_0x34575f(0x14f)]?.[0x0]?.[_0x34575f(0x181)];if(typeof _0x48cc1e!==_0x34575f(0x195))return null;try{let _0x46c190=JSON['parse'](_0x48cc1e);return _0x46c190?.[_0x34575f(0x16e)]||_0x46c190?.[_0x34575f(0x15a)]||_0x46c190?.['id']||null;}catch{return null;}}async function X(_0x42c791,_0x4e3a0c){const _0x33d2b0=a0_0x2ae722;let _0x2b06f3=_0x4e3a0c['now']??Date[_0x33d2b0(0x196)],_0x78dbf4=_0x2b06f3(),_0xbe356a=(_0x31080e,_0x319726,_0x42f9fc,_0x486cbf)=>{const _0x488e13=_0x33d2b0;_0x4e3a0c['log'](O(U({'from_alias':_0x42c791[_0x488e13(0x148)],'to_alias':_0x42c791[_0x488e13(0x1a4)],'task_id':_0x319726,'parent_task_id':_0x42c791[_0x488e13(0x134)],'network_id':_0x42c791[_0x488e13(0x15b)],'transport':_0x42c791['transport'],'status':_0x31080e,'duration_ms':_0x2b06f3()-_0x78dbf4,'lifecycle_tracking':_0x42c791['lifecycleTracking'],..._0x42f9fc!==void 0x0?{'error_code':_0x486cbf||_0x488e13(0x169),'error_message':N(_0x42f9fc)}:{}})));};_0xbe356a(_0x33d2b0(0x12f),null);try{let _0x3a26bd=await _0x4e3a0c[_0x33d2b0(0x151)](),_0x2f4e74=j(_0x3a26bd);if(_0x2f4e74)_0xbe356a('delivered',_0x2f4e74);else{if(_0x3a26bd?.['ok']===!0x1||_0x3a26bd?.[_0x33d2b0(0x18c)])_0xbe356a(_0x33d2b0(0x159),_0x2f4e74,_0x3a26bd?.[_0x33d2b0(0x18c)]||'CommHub\x20rejected\x20task','send_rejected');else _0xbe356a(_0x33d2b0(0x159),null,_0x33d2b0(0x168),_0x33d2b0(0x144));}return _0x3a26bd;}catch(_0x106895){throw _0xbe356a(_0x33d2b0(0x159),null,_0x106895,_0x33d2b0(0x169)),_0x106895;}}async function Y(_0x1db13d,_0xbe1276){const _0x8f63d0=a0_0x2ae722;return X({'fromAlias':_0x1db13d['fromAlias'],'toAlias':_0x1db13d[_0x8f63d0(0x12c)],'parentTaskId':_0x1db13d[_0x8f63d0(0x134)]||null,'networkId':_0x1db13d['networkId']||null,'transport':'mcp_http','lifecycleTracking':_0x8f63d0(0x155)},_0xbe1276);}class $ extends a0_0x5b4647{['url'];[a0_0x2ae722(0x12c)];[a0_0x2ae722(0x156)];['agent'];[a0_0x2ae722(0x128)];[a0_0x2ae722(0x179)];[a0_0x2ae722(0x170)];[a0_0x2ae722(0x198)];[a0_0x2ae722(0x12b)];['running']=!0x1;constructor(_0x382b75){const _0x4eb987=a0_0x2ae722;super();if(this[_0x4eb987(0x171)]=_0x382b75[_0x4eb987(0x171)]['replace'](/\/$/,''),this[_0x4eb987(0x12c)]=_0x382b75[_0x4eb987(0x12c)],this['token']=_0x382b75[_0x4eb987(0x156)],this[_0x4eb987(0x153)]=_0x382b75[_0x4eb987(0x153)]||_0x4eb987(0x16f),this['resumeId']=_0x4eb987(0x133)+_0x382b75[_0x4eb987(0x12c)]+'-'+Date[_0x4eb987(0x196)]()[_0x4eb987(0x152)](0x24),this[_0x4eb987(0x179)]=_0x382b75['heartbeatInterval']??0x2bf20,this[_0x4eb987(0x170)]=_0x382b75[_0x4eb987(0x170)]??0xbb8,_0x382b75['autoConnect']!==!0x1)this[_0x4eb987(0x17f)]();}['log'](_0x15ed98){const _0x23b6e3=a0_0x2ae722;console['log']('['+new Date()['toTimeString']()[_0x23b6e3(0x13d)](0x0,0x8)+_0x23b6e3(0x13c)+this[_0x23b6e3(0x12c)]+']\x20'+_0x15ed98);}async[a0_0x2ae722(0x137)](_0x4db90c,_0x119f10){const _0x2d4ae1=a0_0x2ae722;let _0x2ad79b={'Content-Type':'application/json','Accept':'application/json,\x20text/event-stream'};if(this['token'])_0x2ad79b[_0x2d4ae1(0x161)]=_0x2d4ae1(0x188)+this[_0x2d4ae1(0x156)];let _0x3d4373=await(await fetch(this['url']+_0x2d4ae1(0x16a),{'method':_0x2d4ae1(0x176),'headers':_0x2ad79b,'body':JSON['stringify']({'jsonrpc':_0x2d4ae1(0x17c),'id':Date['now'](),'method':_0x2d4ae1(0x149),'params':{'name':_0x4db90c,'arguments':_0x119f10}})}))[_0x2d4ae1(0x181)](),_0x5339f8=_0x3d4373[_0x2d4ae1(0x182)](/data: (.+)/),_0x3396fa=_0x5339f8?JSON[_0x2d4ae1(0x17e)](_0x5339f8[0x1]):JSON[_0x2d4ae1(0x17e)](_0x3d4373),_0x2fcdbd=_0x3396fa?.[_0x2d4ae1(0x19e)]?.['content']?.[0x0]?.[_0x2d4ae1(0x181)];return _0x2fcdbd?JSON[_0x2d4ae1(0x17e)](_0x2fcdbd):_0x3396fa;}async[a0_0x2ae722(0x17f)](){const _0x317362=a0_0x2ae722;if(this[_0x317362(0x139)])return;this[_0x317362(0x139)]=!0x0,await this['status'](_0x317362(0x190)),this[_0x317362(0x13f)](_0x317362(0x1a3)),this[_0x317362(0x198)]=setInterval(()=>{const _0x16c07d=_0x317362;this['status'](_0x16c07d(0x190))[_0x16c07d(0x19a)](_0x76bb1b=>this[_0x16c07d(0x13f)](_0x16c07d(0x16c)+_0x76bb1b['message']));},this[_0x317362(0x179)]),this['connectSSE']();}async[a0_0x2ae722(0x178)](){const _0x499078=a0_0x2ae722;if(this[_0x499078(0x139)]=!0x1,this[_0x499078(0x12b)]?.[_0x499078(0x12d)](),this[_0x499078(0x198)])clearInterval(this[_0x499078(0x198)]);await this[_0x499078(0x184)]('offline')['catch'](()=>{}),this[_0x499078(0x13f)]('disconnected');}async['send'](_0xcd9ed,_0x140e72,_0x3f1442=a0_0x2ae722(0x162)){const _0x3649c8=a0_0x2ae722;return Y({'alias':_0xcd9ed,'fromAlias':this[_0x3649c8(0x12c)]},{'log':_0x36c0e8=>console[_0x3649c8(0x13f)](_0x36c0e8),'send':()=>this[_0x3649c8(0x137)](_0x3649c8(0x19b),{'alias':_0xcd9ed,'task':_0x140e72,'priority':_0x3f1442,'from_session':this[_0x3649c8(0x12c)]})});}async[a0_0x2ae722(0x130)](_0x428b16,_0x5ba99d){const _0x58effd=a0_0x2ae722;return this[_0x58effd(0x137)]('send_message',{'alias':_0x428b16,'message':_0x5ba99d,'from_session':this[_0x58effd(0x12c)]});}async[a0_0x2ae722(0x143)](_0xae8b11,_0x47f426,_0x55234b=a0_0x2ae722(0x1a5)){const _0xa86521=a0_0x2ae722;return this['call'](_0xa86521(0x14e),{'in_reply_to':_0xae8b11,'text':_0x47f426,'status':_0x55234b});}async['status'](_0x171006,_0x393fee){const _0xd89338=a0_0x2ae722;return this['call'](_0xd89338(0x15d),{'resume_id':this[_0xd89338(0x128)],'alias':this[_0xd89338(0x12c)],'status':_0x171006,'server':a0_0x2bba5e(),'hostname':a0_0x2bba5e(),'agent':this['agent'],'project_dir':process['cwd'](),..._0x393fee});}async[a0_0x2ae722(0x158)](){const _0x5049ca=a0_0x2ae722;return this[_0x5049ca(0x137)](_0x5049ca(0x146),{});}async[a0_0x2ae722(0x14c)](_0x2e8253,_0xf28c57){const _0x261271=a0_0x2ae722;return this[_0x261271(0x137)](_0x261271(0x14c),{'message':_0x2e8253,'filter_server':_0xf28c57?.['server'],'filter_status':_0xf28c57?.['status']});}async[a0_0x2ae722(0x180)](){const _0x3fcb79=a0_0x2ae722;let _0x152822=encodeURIComponent(this[_0x3fcb79(0x12c)]),_0x388495=this['url']+_0x3fcb79(0x164)+_0x152822,_0x2419c2=this[_0x3fcb79(0x170)];while(this['running']){try{this[_0x3fcb79(0x12b)]=new AbortController();let _0x2ecfc2={'Accept':'text/event-stream'};if(this[_0x3fcb79(0x156)])_0x2ecfc2[_0x3fcb79(0x161)]='Bearer\x20'+this['token'];let _0x38ab48=await fetch(_0x388495,{'headers':_0x2ecfc2,'signal':this['sseAbort'][_0x3fcb79(0x166)]});if(!_0x38ab48['ok']||!_0x38ab48[_0x3fcb79(0x140)]){this[_0x3fcb79(0x13f)]('SSE\x20failed:\x20'+_0x38ab48['status']),await this[_0x3fcb79(0x160)](_0x2419c2),_0x2419c2=Math[_0x3fcb79(0x18a)](_0x2419c2*1.5,0xea60);continue;}_0x2419c2=this[_0x3fcb79(0x170)];let _0x3248a9=_0x38ab48['body'][_0x3fcb79(0x18e)](),_0x2dc81e=new TextDecoder(),_0x135d75='';while(this['running']){let {done:_0x18ce6f,value:_0x30721b}=await _0x3248a9[_0x3fcb79(0x191)]();if(_0x18ce6f)break;_0x135d75+=_0x2dc81e[_0x3fcb79(0x183)](_0x30721b,{'stream':!0x0});let _0x16db81=_0x135d75[_0x3fcb79(0x1a0)]('\x0a');_0x135d75=_0x16db81['pop']()||'';for(let _0x293db3 of _0x16db81){if(!_0x293db3[_0x3fcb79(0x13a)](_0x3fcb79(0x192)))continue;try{let _0x2e3964=JSON[_0x3fcb79(0x17e)](_0x293db3[_0x3fcb79(0x13d)](0x6));if(_0x2e3964[_0x3fcb79(0x13b)]===_0x3fcb79(0x185)){this[_0x3fcb79(0x13f)]('SSE\x20connected'),this['emit'](_0x3fcb79(0x185));continue;}if(_0x2e3964[_0x3fcb79(0x13b)]===_0x3fcb79(0x142)||_0x2e3964['type']===_0x3fcb79(0x138)||_0x2e3964['type']===_0x3fcb79(0x14c))await this[_0x3fcb79(0x18f)]();}catch{}}}}catch(_0x2f10d2){if(_0x2f10d2[_0x3fcb79(0x189)]==='AbortError')break;this['emit']('error',_0x2f10d2),this[_0x3fcb79(0x13f)]('SSE\x20error:\x20'+_0x2f10d2[_0x3fcb79(0x130)]);}if(this[_0x3fcb79(0x139)])this[_0x3fcb79(0x15c)](_0x3fcb79(0x157)),this[_0x3fcb79(0x13f)](_0x3fcb79(0x12e)+_0x2419c2/0x3e8+_0x3fcb79(0x193)),await this[_0x3fcb79(0x160)](_0x2419c2),_0x2419c2=Math[_0x3fcb79(0x18a)](_0x2419c2*1.5,0xea60);}}async[a0_0x2ae722(0x18f)](){const _0x18addf=a0_0x2ae722;try{let _0x12d988=(await this[_0x18addf(0x137)](_0x18addf(0x126),{'alias':this['alias'],'limit':0xa}))?.[_0x18addf(0x18b)]||[];for(let _0x306c6f of _0x12d988)await this['call'](_0x18addf(0x131),{'alias':this[_0x18addf(0x12c)],'message_id':_0x306c6f['id']}),this['log']('←\x20'+_0x306c6f[_0x18addf(0x135)]+':\x20'+_0x306c6f[_0x18addf(0x14f)][_0x18addf(0x13d)](0x0,0x3c)),this[_0x18addf(0x15c)](_0x18addf(0x1a1),_0x306c6f),this['emit'](_0x18addf(0x130),_0x306c6f);}catch(_0xd96aa2){this[_0x18addf(0x13f)]('inbox\x20error:\x20'+_0xd96aa2[_0x18addf(0x130)]);}}[a0_0x2ae722(0x160)](_0x5df466){return new Promise(_0x3e6d7c=>setTimeout(_0x3e6d7c,_0x5df466));}}var F=$;export{F as default,$ as CommHub};