@sleep2agi/agent-network 2.3.0-preview.201 → 2.3.0-preview.202

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_0x5ec272=a0_0x5870;(function(_0xfdbf93,_0xe25e3b){const _0x149a27=a0_0x5870,_0x1735d9=_0xfdbf93();while(!![]){try{const _0x31e076=-parseInt(_0x149a27(0xec))/0x1+-parseInt(_0x149a27(0x94))/0x2*(-parseInt(_0x149a27(0x100))/0x3)+-parseInt(_0x149a27(0x9f))/0x4*(parseInt(_0x149a27(0xa3))/0x5)+parseInt(_0x149a27(0xb2))/0x6*(-parseInt(_0x149a27(0x8c))/0x7)+-parseInt(_0x149a27(0xdb))/0x8*(-parseInt(_0x149a27(0xc2))/0x9)+parseInt(_0x149a27(0xad))/0xa+-parseInt(_0x149a27(0xfe))/0xb*(parseInt(_0x149a27(0xf4))/0xc);if(_0x31e076===_0xe25e3b)break;else _0x1735d9['push'](_0x1735d9['shift']());}catch(_0x2b5b39){_0x1735d9['push'](_0x1735d9['shift']());}}}(a0_0x554b,0x26127));import{EventEmitter as a0_0x5be294}from'events';import{hostname as a0_0x46b32d}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x2fc60a,_0x56a94b)=>(_0x2fc60a??_0x56a94b)[a0_0x5ec272(0xd6)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x5ec272(0xfc)](0x0,0xf0);function N(_0x36881d){const _0x31638b=a0_0x5ec272;return(_0x36881d instanceof Error?_0x36881d[_0x31638b(0xe2)]:String(_0x36881d??_0x31638b(0xe1)))[_0x31638b(0xd6)](K,_0x31638b(0xcd))[_0x31638b(0xd6)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x5d8a0b,_0x339b7c=process.env.ANET_TASK_TRACE_FORMAT===a0_0x5ec272(0xca)){const _0x539c72=a0_0x5ec272;if(_0x339b7c)return JSON[_0x539c72(0xd1)](_0x5d8a0b);let _0x4608ac=L(_0x5d8a0b[_0x539c72(0xb0)],_0x539c72(0xa7)),_0x328e94=L(_0x5d8a0b[_0x539c72(0xb9)],'<pending>'),_0x4c7cf3=_0x5d8a0b[_0x539c72(0xd9)]?_0x539c72(0xdf)+_0x5d8a0b['error_code']+':'+(_0x5d8a0b[_0x539c72(0x8b)]??''):'';return _0x539c72(0x9e)+_0x5d8a0b['status']+_0x539c72(0xa1)+L(_0x5d8a0b[_0x539c72(0xe0)],_0x539c72(0x103))+_0x539c72(0x9a)+L(_0x5d8a0b['to_alias'],'<unknown>')+_0x539c72(0x102)+_0x328e94+_0x539c72(0xab)+_0x4608ac+_0x539c72(0xd0)+L(_0x5d8a0b[_0x539c72(0xbf)],'<unknown>')+_0x539c72(0xd7)+_0x5d8a0b[_0x539c72(0xe8)]+'\x20duration_ms='+_0x5d8a0b['duration_ms']+'\x20lifecycle='+_0x5d8a0b['lifecycle_tracking']+_0x4c7cf3;}function U(_0x142a7d){const _0x4913bf=a0_0x5ec272;return{'event':{'sending':_0x4913bf(0xc7),'delivered':_0x4913bf(0xf3),'failed':'task.send.failed','acked':_0x4913bf(0x8d),'started':_0x4913bf(0x98),'replied':'task.replied','expired':'task.expired'}[_0x142a7d[_0x4913bf(0xa4)]],..._0x142a7d};}function j(_0x1c5541){const _0x108d1a=a0_0x5ec272;let _0x408326=_0x1c5541?.[_0x108d1a(0xb9)]||_0x1c5541?.[_0x108d1a(0xef)]||_0x1c5541?.['id'];if(_0x408326)return String(_0x408326);let _0x8fd15f=_0x1c5541?.[_0x108d1a(0xff)]?.[0x0]?.[_0x108d1a(0xc8)];if(typeof _0x8fd15f!==_0x108d1a(0xbb))return null;try{let _0x4e8abe=JSON[_0x108d1a(0xf8)](_0x8fd15f);return _0x4e8abe?.[_0x108d1a(0xb9)]||_0x4e8abe?.[_0x108d1a(0xef)]||_0x4e8abe?.['id']||null;}catch{return null;}}async function X(_0x18a707,_0x796787){const _0x378e45=a0_0x5ec272;let _0xc257a9=_0x796787[_0x378e45(0xa0)]??Date[_0x378e45(0xa0)],_0x8e1d97=_0xc257a9(),_0x591daa=(_0x235864,_0x1274cf,_0x1b3b91,_0x14b6aa)=>{const _0x7c3f7=_0x378e45;_0x796787[_0x7c3f7(0x95)](O(U({'from_alias':_0x18a707[_0x7c3f7(0xe9)],'to_alias':_0x18a707[_0x7c3f7(0xbc)],'task_id':_0x1274cf,'parent_task_id':_0x18a707[_0x7c3f7(0xac)],'network_id':_0x18a707[_0x7c3f7(0x88)],'transport':_0x18a707[_0x7c3f7(0xe8)],'status':_0x235864,'duration_ms':_0xc257a9()-_0x8e1d97,'lifecycle_tracking':_0x18a707[_0x7c3f7(0x86)],..._0x1b3b91!==void 0x0?{'error_code':_0x14b6aa||_0x7c3f7(0xc5),'error_message':N(_0x1b3b91)}:{}})));};_0x591daa(_0x378e45(0xa8),null);try{let _0x413eaf=await _0x796787['send'](),_0x19c974=j(_0x413eaf);if(_0x19c974)_0x591daa(_0x378e45(0x89),_0x19c974);else{if(_0x413eaf?.['ok']===!0x1||_0x413eaf?.[_0x378e45(0xd8)])_0x591daa(_0x378e45(0xcc),_0x19c974,_0x413eaf?.[_0x378e45(0xd8)]||_0x378e45(0xa5),_0x378e45(0xe6));else _0x591daa('failed',null,_0x378e45(0xb4),_0x378e45(0xf5));}return _0x413eaf;}catch(_0xe472ab){throw _0x591daa(_0x378e45(0xcc),null,_0xe472ab,_0x378e45(0xc5)),_0xe472ab;}}async function Y(_0x42a1f4,_0xb46013){const _0x4de3d0=a0_0x5ec272;return X({'fromAlias':_0x42a1f4[_0x4de3d0(0xe9)],'toAlias':_0x42a1f4[_0x4de3d0(0x93)],'parentTaskId':_0x42a1f4['parentTaskId']||null,'networkId':_0x42a1f4[_0x4de3d0(0x88)]||null,'transport':_0x4de3d0(0xeb),'lifecycleTracking':_0x4de3d0(0xb6)},_0xb46013);}class $ extends a0_0x5be294{['url'];[a0_0x5ec272(0x93)];['token'];[a0_0x5ec272(0xf2)];[a0_0x5ec272(0xf0)];['heartbeatInterval'];['reconnectDelay'];[a0_0x5ec272(0x104)];[a0_0x5ec272(0x8a)];[a0_0x5ec272(0xcf)]=!0x1;constructor(_0x2781b0){const _0x19ee23=a0_0x5ec272;super();if(this['url']=_0x2781b0[_0x19ee23(0xf7)][_0x19ee23(0xd6)](/\/$/,''),this[_0x19ee23(0x93)]=_0x2781b0['alias'],this[_0x19ee23(0xb8)]=_0x2781b0['token'],this[_0x19ee23(0xf2)]=_0x2781b0['agent']||_0x19ee23(0xb3),this[_0x19ee23(0xf0)]=_0x19ee23(0xda)+_0x2781b0[_0x19ee23(0x93)]+'-'+Date['now']()[_0x19ee23(0xaf)](0x24),this[_0x19ee23(0xd4)]=_0x2781b0[_0x19ee23(0xd4)]??0x2bf20,this[_0x19ee23(0xfd)]=_0x2781b0['reconnectDelay']??0xbb8,_0x2781b0[_0x19ee23(0xd5)]!==!0x1)this['connect']();}[a0_0x5ec272(0x95)](_0x56f6b9){const _0x30e268=a0_0x5ec272;console['log']('['+new Date()['toTimeString']()['slice'](0x0,0x8)+_0x30e268(0xc3)+this[_0x30e268(0x93)]+']\x20'+_0x56f6b9);}async[a0_0x5ec272(0xde)](_0x4396af,_0x500efc){const _0x29872f=a0_0x5ec272;let _0x3bcdfd={'Content-Type':'application/json','Accept':_0x29872f(0xe7)};if(this[_0x29872f(0xb8)])_0x3bcdfd[_0x29872f(0xcb)]=_0x29872f(0xfb)+this[_0x29872f(0xb8)];let _0x1a0a25=await(await fetch(this['url']+_0x29872f(0x106),{'method':_0x29872f(0xa9),'headers':_0x3bcdfd,'body':JSON[_0x29872f(0xd1)]({'jsonrpc':_0x29872f(0xe5),'id':Date[_0x29872f(0xa0)](),'method':'tools/call','params':{'name':_0x4396af,'arguments':_0x500efc}})}))['text'](),_0x228e59=_0x1a0a25['match'](/data: (.+)/),_0x41bdd2=_0x228e59?JSON[_0x29872f(0xf8)](_0x228e59[0x1]):JSON[_0x29872f(0xf8)](_0x1a0a25),_0x55dc38=_0x41bdd2?.['result']?.[_0x29872f(0xff)]?.[0x0]?.[_0x29872f(0xc8)];return _0x55dc38?JSON[_0x29872f(0xf8)](_0x55dc38):_0x41bdd2;}async[a0_0x5ec272(0xb5)](){const _0x5113a9=a0_0x5ec272;if(this[_0x5113a9(0xcf)])return;this[_0x5113a9(0xcf)]=!0x0,await this[_0x5113a9(0xa4)](_0x5113a9(0x9d)),this[_0x5113a9(0x95)](_0x5113a9(0xee)),this['heartbeatTimer']=setInterval(()=>{const _0x3bf35b=_0x5113a9;this[_0x3bf35b(0xa4)](_0x3bf35b(0x9d))['catch'](_0x26ef42=>this[_0x3bf35b(0x95)](_0x3bf35b(0xc4)+_0x26ef42[_0x3bf35b(0xe2)]));},this[_0x5113a9(0xd4)]),this[_0x5113a9(0xbd)]();}async[a0_0x5ec272(0xfa)](){const _0x11d220=a0_0x5ec272;if(this['running']=!0x1,this[_0x11d220(0x8a)]?.[_0x11d220(0x99)](),this[_0x11d220(0x104)])clearInterval(this[_0x11d220(0x104)]);await this[_0x11d220(0xa4)](_0x11d220(0xc0))['catch'](()=>{}),this['log']('disconnected');}async[a0_0x5ec272(0xae)](_0x1eebf5,_0xcd0787,_0x3e97f4=a0_0x5ec272(0x91)){const _0x45c51f=a0_0x5ec272;return Y({'alias':_0x1eebf5,'fromAlias':this[_0x45c51f(0x93)]},{'log':_0x40fb12=>console[_0x45c51f(0x95)](_0x40fb12),'send':()=>this[_0x45c51f(0xde)](_0x45c51f(0xb1),{'alias':_0x1eebf5,'task':_0xcd0787,'priority':_0x3e97f4,'from_session':this[_0x45c51f(0x93)]})});}async['message'](_0x8fcbaf,_0x159910){const _0x491270=a0_0x5ec272;return this[_0x491270(0xde)](_0x491270(0xa2),{'alias':_0x8fcbaf,'message':_0x159910,'from_session':this[_0x491270(0x93)]});}async[a0_0x5ec272(0xdc)](_0x2f4384,_0x2dbbaa,_0x46b5ca=a0_0x5ec272(0x101)){const _0x39ed41=a0_0x5ec272;return this[_0x39ed41(0xde)]('send_reply',{'in_reply_to':_0x2f4384,'text':_0x2dbbaa,'status':_0x46b5ca});}async[a0_0x5ec272(0xa4)](_0x3d4567,_0x5577b7){const _0x5d8173=a0_0x5ec272;return this[_0x5d8173(0xde)](_0x5d8173(0x92),{'resume_id':this[_0x5d8173(0xf0)],'alias':this[_0x5d8173(0x93)],'status':_0x3d4567,'server':a0_0x46b32d(),'hostname':a0_0x46b32d(),'agent':this[_0x5d8173(0xf2)],'project_dir':process['cwd'](),..._0x5577b7});}async[a0_0x5ec272(0xed)](){const _0x3fc00c=a0_0x5ec272;return this[_0x3fc00c(0xde)]('get_all_status',{});}async['broadcast'](_0x22c3e2,_0x294d83){const _0x241fd7=a0_0x5ec272;return this['call'](_0x241fd7(0x9b),{'message':_0x22c3e2,'filter_server':_0x294d83?.[_0x241fd7(0x87)],'filter_status':_0x294d83?.['status']});}async[a0_0x5ec272(0xbd)](){const _0x4065e6=a0_0x5ec272;let _0x4852ae=encodeURIComponent(this['alias']),_0x5e05cd=this[_0x4065e6(0xf7)]+'/events/'+_0x4852ae,_0x332108=this[_0x4065e6(0xfd)];while(this[_0x4065e6(0xcf)]){try{this[_0x4065e6(0x8a)]=new AbortController();let _0x152751={'Accept':_0x4065e6(0x105)};if(this[_0x4065e6(0xb8)])_0x152751[_0x4065e6(0xcb)]=_0x4065e6(0xfb)+this[_0x4065e6(0xb8)];let _0x332e97=await fetch(_0x5e05cd,{'headers':_0x152751,'signal':this[_0x4065e6(0x8a)][_0x4065e6(0xc6)]});if(!_0x332e97['ok']||!_0x332e97[_0x4065e6(0xc1)]){this[_0x4065e6(0x95)](_0x4065e6(0x96)+_0x332e97[_0x4065e6(0xa4)]),await this[_0x4065e6(0x97)](_0x332108),_0x332108=Math['min'](_0x332108*1.5,0xea60);continue;}_0x332108=this[_0x4065e6(0xfd)];let _0x3c429c=_0x332e97[_0x4065e6(0xc1)][_0x4065e6(0xa6)](),_0x3d84ac=new TextDecoder(),_0x525df9='';while(this[_0x4065e6(0xcf)]){let {done:_0x1e63bf,value:_0x2cac0f}=await _0x3c429c['read']();if(_0x1e63bf)break;_0x525df9+=_0x3d84ac[_0x4065e6(0x8e)](_0x2cac0f,{'stream':!0x0});let _0x153dea=_0x525df9[_0x4065e6(0xbe)]('\x0a');_0x525df9=_0x153dea['pop']()||'';for(let _0x2ed117 of _0x153dea){if(!_0x2ed117['startsWith']('data:\x20'))continue;try{let _0x3dd6fd=JSON[_0x4065e6(0xf8)](_0x2ed117[_0x4065e6(0xfc)](0x6));if(_0x3dd6fd[_0x4065e6(0xc9)]==='connected'){this[_0x4065e6(0x95)](_0x4065e6(0xce)),this[_0x4065e6(0x90)]('connected');continue;}if(_0x3dd6fd['type']==='new_task'||_0x3dd6fd['type']===_0x4065e6(0x8f)||_0x3dd6fd[_0x4065e6(0xc9)]==='broadcast')await this[_0x4065e6(0xd2)]();}catch{}}}}catch(_0x2faecf){if(_0x2faecf[_0x4065e6(0xf1)]==='AbortError')break;this[_0x4065e6(0x90)]('error',_0x2faecf),this[_0x4065e6(0x95)](_0x4065e6(0xdd)+_0x2faecf[_0x4065e6(0xe2)]);}if(this[_0x4065e6(0xcf)])this[_0x4065e6(0x90)](_0x4065e6(0x9c)),this[_0x4065e6(0x95)](_0x4065e6(0xd3)+_0x332108/0x3e8+_0x4065e6(0xf9)),await this[_0x4065e6(0x97)](_0x332108),_0x332108=Math[_0x4065e6(0xe4)](_0x332108*1.5,0xea60);}}async[a0_0x5ec272(0xd2)](){const _0x12024b=a0_0x5ec272;try{let _0x5f45dd=(await this[_0x12024b(0xde)](_0x12024b(0xf6),{'alias':this['alias'],'limit':0xa}))?.[_0x12024b(0xb7)]||[];for(let _0x42cf26 of _0x5f45dd)await this[_0x12024b(0xde)](_0x12024b(0xba),{'alias':this[_0x12024b(0x93)],'message_id':_0x42cf26['id']}),this[_0x12024b(0x95)]('←\x20'+_0x42cf26[_0x12024b(0xea)]+':\x20'+_0x42cf26[_0x12024b(0xff)]['slice'](0x0,0x3c)),this[_0x12024b(0x90)](_0x12024b(0xe3),_0x42cf26),this['emit'](_0x12024b(0xe2),_0x42cf26);}catch(_0x12a0f5){this['log'](_0x12024b(0xaa)+_0x12a0f5[_0x12024b(0xe2)]);}}[a0_0x5ec272(0x97)](_0x2966ce){return new Promise(_0x1ffb37=>setTimeout(_0x1ffb37,_0x2966ce));}}var F=$;export{F as default,$ as CommHub};function a0_0x5870(_0x4d8925,_0x1ab951){_0x4d8925=_0x4d8925-0x86;const _0x554bde=a0_0x554b();let _0x587029=_0x554bde[_0x4d8925];return _0x587029;}function a0_0x554b(){const _0x150e06=['\x20task_id=','<unknown>','heartbeatTimer','text/event-stream','/mcp','lifecycleTracking','server','networkId','delivered','sseAbort','error_message','22449QHvGeY','task.ack','decode','new_message','emit','normal','report_status','alias','4208zzbKwR','log','SSE\x20failed:\x20','sleep','task.started','abort','\x20to=','broadcast','disconnected','idle','[commhub:task]\x20','16gePiDu','now','\x20from=','send_message','28850VBgVld','status','CommHub\x20rejected\x20task','getReader','<missing>','sending','POST','inbox\x20error:\x20','\x20parent_task_id=','parentTaskId','1300210bwrKnh','send','toString','parent_task_id','send_task','174TkRmgN','sdk','CommHub\x20response\x20omitted\x20task_id','connect','not_tracked','messages','token','task_id','ack_inbox','string','toAlias','connectSSE','split','network_id','offline','body','342BXBnnc',']\x20[commhub:','heartbeat\x20failed:\x20','send_failed','signal','task.send.start','text','type','json','Authorization','failed','[REDACTED]','SSE\x20connected','running','\x20network_id=','stringify','processInbox','SSE\x20reconnecting\x20in\x20','heartbeatInterval','autoConnect','replace','\x20transport=','error','error_code','sdk-','62232UaJwAA','reply','SSE\x20error:\x20','call','\x20error=','from_alias','unknown\x20error','message','task','min','2.0','send_rejected','application/json,\x20text/event-stream','transport','fromAlias','from_session','mcp_http','70057tGoBYt','getAllStatus','registered','message_id','resumeId','name','agent','task.send.delivered','12iZSEVR','missing_task_id','get_inbox','url','parse','s...','disconnect','Bearer\x20','slice','reconnectDelay','3094476UrVbFl','content','282wPDNHw','completed'];a0_0x554b=function(){return _0x150e06;};return a0_0x554b();}
1
+ const a0_0x507b29=a0_0x2317;(function(_0x16ec98,_0x96c12){const _0x46117a=a0_0x2317,_0x3a9eb=_0x16ec98();while(!![]){try{const _0x1970a7=-parseInt(_0x46117a(0x147))/0x1*(-parseInt(_0x46117a(0x172))/0x2)+parseInt(_0x46117a(0x11d))/0x3+-parseInt(_0x46117a(0x123))/0x4+parseInt(_0x46117a(0xfc))/0x5+-parseInt(_0x46117a(0x149))/0x6+-parseInt(_0x46117a(0x13a))/0x7*(-parseInt(_0x46117a(0x13f))/0x8)+-parseInt(_0x46117a(0x14e))/0x9*(-parseInt(_0x46117a(0x108))/0xa);if(_0x1970a7===_0x96c12)break;else _0x3a9eb['push'](_0x3a9eb['shift']());}catch(_0x34eae5){_0x3a9eb['push'](_0x3a9eb['shift']());}}}(a0_0x4bcf,0x6c85c));import{EventEmitter as a0_0x57b34e}from'events';import{hostname as a0_0x42303b}from'os';function a0_0x4bcf(){const _0x23a9b0=['now','startsWith','replace','from_session','send_reply','task','\x20transport=','content','119217VlrOQB','s...','status','error','ack_inbox','read','3126872gFmefF','sdk-','toString','log','string','message_id','error_code','getAllStatus','min','new_message','<unknown>','get_inbox','match','CommHub\x20rejected\x20task','task_id','toTimeString','alias','\x20network_id=','mcp_http','\x20parent_task_id=','2.0','connected','body','7nOXsOR','split','server','slice','\x20to=','6034064QpRIpg',']\x20[commhub:','signal','task.send.delivered','toAlias','send_rejected','normal','not_tracked','11ooehlB','token','4466136fLsLQK','emit','getReader','report_status','Authorization','18MzOXFT','cwd','send','error_message','message','type','offline','result','send_message','parentTaskId','registered','transport','[REDACTED]','url','idle','running','\x20task_id=','Bearer\x20','task.expired','resumeId','SSE\x20failed:\x20','heartbeatTimer','sseAbort','completed','fromAlias','send_task','\x20error=','tools/call','task.replied','connectSSE','from_alias','\x20from=','parse','json','data:\x20','agent','41858NeuiuF','SSE\x20connected','new_task','disconnect','abort','decode','processInbox','text','network_id','POST','to_alias','task.send.failed','\x20lifecycle=','heartbeatInterval','3234550pBbyRI','AbortError','<pending>','lifecycle_tracking','inbox\x20error:\x20','messages','disconnected','sdk','failed','call','SSE\x20error:\x20','broadcast','1497280OAFmRN','application/json,\x20text/event-stream','lifecycleTracking','connect','send_failed','name','task.started','missing_task_id','sending','networkId','/mcp','reconnectDelay','sleep'];a0_0x4bcf=function(){return _0x23a9b0;};return a0_0x4bcf();}var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x46066e,_0x1838ff)=>(_0x46066e??_0x1838ff)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x501290){const _0x5a19c5=a0_0x2317;return(_0x501290 instanceof Error?_0x501290[_0x5a19c5(0x152)]:String(_0x501290??'unknown\x20error'))[_0x5a19c5(0x117)](K,_0x5a19c5(0x15a))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x5a19c5(0x13d)](0x0,0xf0);}function O(_0x19c5e7,_0x461ba4=process.env.ANET_TASK_TRACE_FORMAT===a0_0x507b29(0x16f)){const _0x4d2d6b=a0_0x507b29;if(_0x461ba4)return JSON['stringify'](_0x19c5e7);let _0xa5445f=L(_0x19c5e7['parent_task_id'],'<missing>'),_0x4d5ac4=L(_0x19c5e7[_0x4d2d6b(0x131)],_0x4d2d6b(0xfe)),_0x29a84d=_0x19c5e7['error_code']?_0x4d2d6b(0x168)+_0x19c5e7[_0x4d2d6b(0x129)]+':'+(_0x19c5e7[_0x4d2d6b(0x151)]??''):'';return'[commhub:task]\x20'+_0x19c5e7['status']+_0x4d2d6b(0x16d)+L(_0x19c5e7[_0x4d2d6b(0x16c)],_0x4d2d6b(0x12d))+_0x4d2d6b(0x13e)+L(_0x19c5e7[_0x4d2d6b(0xf8)],_0x4d2d6b(0x12d))+_0x4d2d6b(0x15e)+_0x4d5ac4+_0x4d2d6b(0x136)+_0xa5445f+_0x4d2d6b(0x134)+L(_0x19c5e7[_0x4d2d6b(0xf6)],_0x4d2d6b(0x12d))+_0x4d2d6b(0x11b)+_0x19c5e7[_0x4d2d6b(0x159)]+'\x20duration_ms='+_0x19c5e7['duration_ms']+_0x4d2d6b(0xfa)+_0x19c5e7[_0x4d2d6b(0xff)]+_0x29a84d;}function U(_0x520dcd){const _0x35f0fe=a0_0x507b29;return{'event':{'sending':'task.send.start','delivered':_0x35f0fe(0x142),'failed':_0x35f0fe(0xf9),'acked':'task.ack','started':_0x35f0fe(0x10e),'replied':_0x35f0fe(0x16a),'expired':_0x35f0fe(0x160)}[_0x520dcd[_0x35f0fe(0x11f)]],..._0x520dcd};}function j(_0x255f2c){const _0x24e0fb=a0_0x507b29;let _0x1b1ae1=_0x255f2c?.[_0x24e0fb(0x131)]||_0x255f2c?.['message_id']||_0x255f2c?.['id'];if(_0x1b1ae1)return String(_0x1b1ae1);let _0xcd83d6=_0x255f2c?.['content']?.[0x0]?.[_0x24e0fb(0xf5)];if(typeof _0xcd83d6!==_0x24e0fb(0x127))return null;try{let _0x5e8d38=JSON[_0x24e0fb(0x16e)](_0xcd83d6);return _0x5e8d38?.[_0x24e0fb(0x131)]||_0x5e8d38?.[_0x24e0fb(0x128)]||_0x5e8d38?.['id']||null;}catch{return null;}}function a0_0x2317(_0x18d3f0,_0x3317b5){_0x18d3f0=_0x18d3f0-0xf5;const _0x4bcfa1=a0_0x4bcf();let _0x2317ef=_0x4bcfa1[_0x18d3f0];return _0x2317ef;}async function X(_0x5919ea,_0x5032c7){const _0x57767f=a0_0x507b29;let _0x2a2351=_0x5032c7[_0x57767f(0x115)]??Date['now'],_0x185e3a=_0x2a2351(),_0xb1c420=(_0x523f26,_0x5d5333,_0xa19a70,_0x54a403)=>{const _0x3b07b6=_0x57767f;_0x5032c7[_0x3b07b6(0x126)](O(U({'from_alias':_0x5919ea[_0x3b07b6(0x166)],'to_alias':_0x5919ea[_0x3b07b6(0x143)],'task_id':_0x5d5333,'parent_task_id':_0x5919ea[_0x3b07b6(0x157)],'network_id':_0x5919ea[_0x3b07b6(0x111)],'transport':_0x5919ea['transport'],'status':_0x523f26,'duration_ms':_0x2a2351()-_0x185e3a,'lifecycle_tracking':_0x5919ea[_0x3b07b6(0x10a)],..._0xa19a70!==void 0x0?{'error_code':_0x54a403||_0x3b07b6(0x10c),'error_message':N(_0xa19a70)}:{}})));};_0xb1c420(_0x57767f(0x110),null);try{let _0x17074a=await _0x5032c7[_0x57767f(0x150)](),_0x5e6e62=j(_0x17074a);if(_0x5e6e62)_0xb1c420('delivered',_0x5e6e62);else{if(_0x17074a?.['ok']===!0x1||_0x17074a?.['error'])_0xb1c420(_0x57767f(0x104),_0x5e6e62,_0x17074a?.[_0x57767f(0x120)]||_0x57767f(0x130),_0x57767f(0x144));else _0xb1c420(_0x57767f(0x104),null,'CommHub\x20response\x20omitted\x20task_id',_0x57767f(0x10f));}return _0x17074a;}catch(_0x540b07){throw _0xb1c420('failed',null,_0x540b07,_0x57767f(0x10c)),_0x540b07;}}async function Y(_0x27590e,_0x135bf7){const _0x482b75=a0_0x507b29;return X({'fromAlias':_0x27590e[_0x482b75(0x166)],'toAlias':_0x27590e[_0x482b75(0x133)],'parentTaskId':_0x27590e[_0x482b75(0x157)]||null,'networkId':_0x27590e[_0x482b75(0x111)]||null,'transport':_0x482b75(0x135),'lifecycleTracking':_0x482b75(0x146)},_0x135bf7);}class $ extends a0_0x57b34e{[a0_0x507b29(0x15b)];['alias'];[a0_0x507b29(0x148)];[a0_0x507b29(0x171)];[a0_0x507b29(0x161)];['heartbeatInterval'];['reconnectDelay'];[a0_0x507b29(0x163)];[a0_0x507b29(0x164)];[a0_0x507b29(0x15d)]=!0x1;constructor(_0x183ce4){const _0x3abecf=a0_0x507b29;super();if(this[_0x3abecf(0x15b)]=_0x183ce4['url'][_0x3abecf(0x117)](/\/$/,''),this[_0x3abecf(0x133)]=_0x183ce4[_0x3abecf(0x133)],this['token']=_0x183ce4[_0x3abecf(0x148)],this[_0x3abecf(0x171)]=_0x183ce4[_0x3abecf(0x171)]||_0x3abecf(0x103),this[_0x3abecf(0x161)]=_0x3abecf(0x124)+_0x183ce4['alias']+'-'+Date['now']()[_0x3abecf(0x125)](0x24),this[_0x3abecf(0xfb)]=_0x183ce4[_0x3abecf(0xfb)]??0x2bf20,this[_0x3abecf(0x113)]=_0x183ce4[_0x3abecf(0x113)]??0xbb8,_0x183ce4['autoConnect']!==!0x1)this[_0x3abecf(0x10b)]();}['log'](_0x120f21){const _0x5c1516=a0_0x507b29;console['log']('['+new Date()[_0x5c1516(0x132)]()[_0x5c1516(0x13d)](0x0,0x8)+_0x5c1516(0x140)+this[_0x5c1516(0x133)]+']\x20'+_0x120f21);}async[a0_0x507b29(0x105)](_0x49c685,_0x2e71f1){const _0x481161=a0_0x507b29;let _0x141d0f={'Content-Type':'application/json','Accept':_0x481161(0x109)};if(this[_0x481161(0x148)])_0x141d0f[_0x481161(0x14d)]='Bearer\x20'+this[_0x481161(0x148)];let _0x4cd6f9=await(await fetch(this['url']+_0x481161(0x112),{'method':_0x481161(0xf7),'headers':_0x141d0f,'body':JSON['stringify']({'jsonrpc':_0x481161(0x137),'id':Date[_0x481161(0x115)](),'method':_0x481161(0x169),'params':{'name':_0x49c685,'arguments':_0x2e71f1}})}))['text'](),_0x38247e=_0x4cd6f9[_0x481161(0x12f)](/data: (.+)/),_0x1ccd44=_0x38247e?JSON[_0x481161(0x16e)](_0x38247e[0x1]):JSON[_0x481161(0x16e)](_0x4cd6f9),_0x3ed400=_0x1ccd44?.[_0x481161(0x155)]?.[_0x481161(0x11c)]?.[0x0]?.[_0x481161(0xf5)];return _0x3ed400?JSON[_0x481161(0x16e)](_0x3ed400):_0x1ccd44;}async['connect'](){const _0x55ce69=a0_0x507b29;if(this['running'])return;this['running']=!0x0,await this['status'](_0x55ce69(0x15c)),this['log'](_0x55ce69(0x158)),this[_0x55ce69(0x163)]=setInterval(()=>{const _0x68f51d=_0x55ce69;this[_0x68f51d(0x11f)](_0x68f51d(0x15c))['catch'](_0xd473c1=>this['log']('heartbeat\x20failed:\x20'+_0xd473c1[_0x68f51d(0x152)]));},this['heartbeatInterval']),this['connectSSE']();}async[a0_0x507b29(0x175)](){const _0x134691=a0_0x507b29;if(this[_0x134691(0x15d)]=!0x1,this[_0x134691(0x164)]?.[_0x134691(0x176)](),this[_0x134691(0x163)])clearInterval(this[_0x134691(0x163)]);await this['status'](_0x134691(0x154))['catch'](()=>{}),this[_0x134691(0x126)](_0x134691(0x102));}async['send'](_0x3a038f,_0x329c28,_0x20576e=a0_0x507b29(0x145)){const _0x3d216a=a0_0x507b29;return Y({'alias':_0x3a038f,'fromAlias':this['alias']},{'log':_0x3b5e3f=>console[_0x3d216a(0x126)](_0x3b5e3f),'send':()=>this['call'](_0x3d216a(0x167),{'alias':_0x3a038f,'task':_0x329c28,'priority':_0x20576e,'from_session':this[_0x3d216a(0x133)]})});}async['message'](_0x428e42,_0x1181bd){const _0x580b04=a0_0x507b29;return this['call'](_0x580b04(0x156),{'alias':_0x428e42,'message':_0x1181bd,'from_session':this[_0x580b04(0x133)]});}async['reply'](_0x5a8abe,_0xa1cd2e,_0x5e8064=a0_0x507b29(0x165)){const _0x100e2b=a0_0x507b29;return this['call'](_0x100e2b(0x119),{'in_reply_to':_0x5a8abe,'text':_0xa1cd2e,'status':_0x5e8064});}async[a0_0x507b29(0x11f)](_0x15aa81,_0x280c09){const _0x1752d7=a0_0x507b29;return this[_0x1752d7(0x105)](_0x1752d7(0x14c),{'resume_id':this['resumeId'],'alias':this[_0x1752d7(0x133)],'status':_0x15aa81,'server':a0_0x42303b(),'hostname':a0_0x42303b(),'agent':this[_0x1752d7(0x171)],'project_dir':process[_0x1752d7(0x14f)](),..._0x280c09});}async[a0_0x507b29(0x12a)](){return this['call']('get_all_status',{});}async['broadcast'](_0x5c612e,_0x444e8e){const _0xc1f412=a0_0x507b29;return this[_0xc1f412(0x105)](_0xc1f412(0x107),{'message':_0x5c612e,'filter_server':_0x444e8e?.[_0xc1f412(0x13c)],'filter_status':_0x444e8e?.[_0xc1f412(0x11f)]});}async[a0_0x507b29(0x16b)](){const _0x5a9fbc=a0_0x507b29;let _0x5addbf=encodeURIComponent(this['alias']),_0x18b892=this[_0x5a9fbc(0x15b)]+'/events/'+_0x5addbf,_0x2cf1ae=this['reconnectDelay'];while(this['running']){try{this[_0x5a9fbc(0x164)]=new AbortController();let _0x25bfb7={'Accept':'text/event-stream'};if(this[_0x5a9fbc(0x148)])_0x25bfb7[_0x5a9fbc(0x14d)]=_0x5a9fbc(0x15f)+this[_0x5a9fbc(0x148)];let _0x22ac6c=await fetch(_0x18b892,{'headers':_0x25bfb7,'signal':this[_0x5a9fbc(0x164)][_0x5a9fbc(0x141)]});if(!_0x22ac6c['ok']||!_0x22ac6c['body']){this[_0x5a9fbc(0x126)](_0x5a9fbc(0x162)+_0x22ac6c[_0x5a9fbc(0x11f)]),await this['sleep'](_0x2cf1ae),_0x2cf1ae=Math['min'](_0x2cf1ae*1.5,0xea60);continue;}_0x2cf1ae=this[_0x5a9fbc(0x113)];let _0x57bd6a=_0x22ac6c[_0x5a9fbc(0x139)][_0x5a9fbc(0x14b)](),_0x2db7a8=new TextDecoder(),_0x3ca753='';while(this[_0x5a9fbc(0x15d)]){let {done:_0x57571a,value:_0x19592e}=await _0x57bd6a[_0x5a9fbc(0x122)]();if(_0x57571a)break;_0x3ca753+=_0x2db7a8[_0x5a9fbc(0x177)](_0x19592e,{'stream':!0x0});let _0x1dbbe9=_0x3ca753[_0x5a9fbc(0x13b)]('\x0a');_0x3ca753=_0x1dbbe9['pop']()||'';for(let _0x4bba92 of _0x1dbbe9){if(!_0x4bba92[_0x5a9fbc(0x116)](_0x5a9fbc(0x170)))continue;try{let _0x438ad0=JSON[_0x5a9fbc(0x16e)](_0x4bba92[_0x5a9fbc(0x13d)](0x6));if(_0x438ad0['type']===_0x5a9fbc(0x138)){this['log'](_0x5a9fbc(0x173)),this['emit']('connected');continue;}if(_0x438ad0[_0x5a9fbc(0x153)]===_0x5a9fbc(0x174)||_0x438ad0[_0x5a9fbc(0x153)]===_0x5a9fbc(0x12c)||_0x438ad0[_0x5a9fbc(0x153)]===_0x5a9fbc(0x107))await this[_0x5a9fbc(0x178)]();}catch{}}}}catch(_0x42844f){if(_0x42844f[_0x5a9fbc(0x10d)]===_0x5a9fbc(0xfd))break;this['emit'](_0x5a9fbc(0x120),_0x42844f),this[_0x5a9fbc(0x126)](_0x5a9fbc(0x106)+_0x42844f[_0x5a9fbc(0x152)]);}if(this[_0x5a9fbc(0x15d)])this['emit']('disconnected'),this[_0x5a9fbc(0x126)]('SSE\x20reconnecting\x20in\x20'+_0x2cf1ae/0x3e8+_0x5a9fbc(0x11e)),await this[_0x5a9fbc(0x114)](_0x2cf1ae),_0x2cf1ae=Math[_0x5a9fbc(0x12b)](_0x2cf1ae*1.5,0xea60);}}async['processInbox'](){const _0x766d53=a0_0x507b29;try{let _0x128712=(await this['call'](_0x766d53(0x12e),{'alias':this['alias'],'limit':0xa}))?.[_0x766d53(0x101)]||[];for(let _0xf30d25 of _0x128712)await this[_0x766d53(0x105)](_0x766d53(0x121),{'alias':this[_0x766d53(0x133)],'message_id':_0xf30d25['id']}),this[_0x766d53(0x126)]('←\x20'+_0xf30d25[_0x766d53(0x118)]+':\x20'+_0xf30d25[_0x766d53(0x11c)][_0x766d53(0x13d)](0x0,0x3c)),this[_0x766d53(0x14a)](_0x766d53(0x11a),_0xf30d25),this['emit'](_0x766d53(0x152),_0xf30d25);}catch(_0x281ee7){this[_0x766d53(0x126)](_0x766d53(0x100)+_0x281ee7[_0x766d53(0x152)]);}}['sleep'](_0x18b940){return new Promise(_0x35d2fd=>setTimeout(_0x35d2fd,_0x18b940));}}var F=$;export{F as default,$ as CommHub};