@sleep2agi/agent-network 2.3.0-preview.214 → 2.3.0-preview.215

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_0x66592b=a0_0x4ae1;(function(_0x2954a9,_0x3b1474){const _0x5e2929=a0_0x4ae1,_0x1d3d66=_0x2954a9();while(!![]){try{const _0x16e706=-parseInt(_0x5e2929(0x82))/0x1+parseInt(_0x5e2929(0x85))/0x2*(parseInt(_0x5e2929(0xb5))/0x3)+-parseInt(_0x5e2929(0xe9))/0x4+parseInt(_0x5e2929(0x9e))/0x5*(-parseInt(_0x5e2929(0xd6))/0x6)+-parseInt(_0x5e2929(0xf8))/0x7*(-parseInt(_0x5e2929(0xf9))/0x8)+parseInt(_0x5e2929(0x9a))/0x9+parseInt(_0x5e2929(0x91))/0xa;if(_0x16e706===_0x3b1474)break;else _0x1d3d66['push'](_0x1d3d66['shift']());}catch(_0x4a76a1){_0x1d3d66['push'](_0x1d3d66['shift']());}}}(a0_0x339a,0x705a5));import{EventEmitter as a0_0xd2e692}from'events';import{hostname as a0_0xab7f48}from'os';function a0_0x339a(){const _0x255f67=['7DidduT','311312UTSwVF','SSE\x20connected','report_status','application/json,\x20text/event-stream','content','heartbeat\x20failed:\x20','<missing>','text','disconnect','<pending>','167738lLgAXp','duration_ms','server','4wkHBFW','unknown\x20error','\x20network_id=','disconnected','mcp_http','task','parent_task_id','get_all_status','connectSSE','reply','decode','send','2434390ksxCpx','not_tracked','sdk-','cwd','json','toAlias','data:\x20','string','inbox\x20error:\x20','7564806wFtGBc','sending','failed','sdk','3123635btUUIr','status','task.started','task.send.start','slice','broadcast','send_reply','type','error','task.ack','SSE\x20error:\x20','CommHub\x20rejected\x20task','POST','send_failed','catch','abort','Bearer\x20',']\x20[commhub:','from_session','sseAbort','resumeId','now','connected','1179147xSPXkI','sleep','agent','delivered','fromAlias','completed','match','error_message','\x20to=','lifecycleTracking','replace','url','task_id','missing_task_id','parse','emit','running','parentTaskId','tools/call','networkId','startsWith','registered','normal','name','processInbox','alias','idle','getAllStatus','reconnectDelay','signal','offline','\x20parent_task_id=','/mcp','6bRSZWj','token','\x20from=','log','application/json','stringify','toString','message','body','call','connect','2.0','send_rejected','task.expired','message_id','send_task','error_code','to_alias','heartbeatInterval','2625292Omjnav','network_id','autoConnect','pop','task.send.failed','heartbeatTimer','new_message','transport','Authorization','/events/','toTimeString','<unknown>','min','task.send.delivered','\x20lifecycle='];a0_0x339a=function(){return _0x255f67;};return a0_0x339a();}var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x48b8e8,_0x56f38e)=>(_0x48b8e8??_0x56f38e)[a0_0x66592b(0xbf)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x66592b(0xa2)](0x0,0xf0);function N(_0x168ebe){const _0x394966=a0_0x66592b;return(_0x168ebe instanceof Error?_0x168ebe['message']:String(_0x168ebe??_0x394966(0x86)))[_0x394966(0xbf)](K,'[REDACTED]')['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x394966(0xa2)](0x0,0xf0);}function O(_0x1e2bb4,_0x43ebb4=process.env.ANET_TASK_TRACE_FORMAT===a0_0x66592b(0x95)){const _0x21eb98=a0_0x66592b;if(_0x43ebb4)return JSON['stringify'](_0x1e2bb4);let _0x2c1a9e=L(_0x1e2bb4[_0x21eb98(0x8b)],_0x21eb98(0xff)),_0x45ddf2=L(_0x1e2bb4[_0x21eb98(0xc1)],_0x21eb98(0x102)),_0x290ed5=_0x1e2bb4[_0x21eb98(0xe6)]?'\x20error='+_0x1e2bb4['error_code']+':'+(_0x1e2bb4[_0x21eb98(0xbc)]??''):'';return'[commhub:task]\x20'+_0x1e2bb4[_0x21eb98(0x9f)]+_0x21eb98(0xd8)+L(_0x1e2bb4['from_alias'],_0x21eb98(0xf4))+_0x21eb98(0xbd)+L(_0x1e2bb4[_0x21eb98(0xe7)],_0x21eb98(0xf4))+'\x20task_id='+_0x45ddf2+_0x21eb98(0xd4)+_0x2c1a9e+_0x21eb98(0x87)+L(_0x1e2bb4[_0x21eb98(0xea)],_0x21eb98(0xf4))+'\x20transport='+_0x1e2bb4[_0x21eb98(0xf0)]+'\x20duration_ms='+_0x1e2bb4[_0x21eb98(0x83)]+_0x21eb98(0xf7)+_0x1e2bb4['lifecycle_tracking']+_0x290ed5;}function U(_0x5ff901){const _0x738317=a0_0x66592b;return{'event':{'sending':_0x738317(0xa1),'delivered':_0x738317(0xf6),'failed':_0x738317(0xed),'acked':_0x738317(0xa7),'started':_0x738317(0xa0),'replied':'task.replied','expired':_0x738317(0xe3)}[_0x5ff901['status']],..._0x5ff901};}function j(_0x517fe1){const _0x3a199c=a0_0x66592b;let _0x305039=_0x517fe1?.[_0x3a199c(0xc1)]||_0x517fe1?.[_0x3a199c(0xe4)]||_0x517fe1?.['id'];if(_0x305039)return String(_0x305039);let _0x370ce8=_0x517fe1?.[_0x3a199c(0xfd)]?.[0x0]?.[_0x3a199c(0x100)];if(typeof _0x370ce8!==_0x3a199c(0x98))return null;try{let _0x225fd2=JSON[_0x3a199c(0xc3)](_0x370ce8);return _0x225fd2?.[_0x3a199c(0xc1)]||_0x225fd2?.[_0x3a199c(0xe4)]||_0x225fd2?.['id']||null;}catch{return null;}}function a0_0x4ae1(_0x3a73ea,_0xf3fadd){_0x3a73ea=_0x3a73ea-0x82;const _0x339ac1=a0_0x339a();let _0x4ae186=_0x339ac1[_0x3a73ea];return _0x4ae186;}async function X(_0x46e509,_0x1f05ac){const _0x48d34e=a0_0x66592b;let _0x5e29be=_0x1f05ac[_0x48d34e(0xb3)]??Date[_0x48d34e(0xb3)],_0x45380a=_0x5e29be(),_0x3c2bd1=(_0x4fb0d4,_0x1cb447,_0x33edb0,_0x393fc0)=>{const _0x292907=_0x48d34e;_0x1f05ac['log'](O(U({'from_alias':_0x46e509[_0x292907(0xb9)],'to_alias':_0x46e509[_0x292907(0x96)],'task_id':_0x1cb447,'parent_task_id':_0x46e509[_0x292907(0xc6)],'network_id':_0x46e509[_0x292907(0xc8)],'transport':_0x46e509[_0x292907(0xf0)],'status':_0x4fb0d4,'duration_ms':_0x5e29be()-_0x45380a,'lifecycle_tracking':_0x46e509[_0x292907(0xbe)],..._0x33edb0!==void 0x0?{'error_code':_0x393fc0||_0x292907(0xab),'error_message':N(_0x33edb0)}:{}})));};_0x3c2bd1(_0x48d34e(0x9b),null);try{let _0x29beb9=await _0x1f05ac['send'](),_0x242f78=j(_0x29beb9);if(_0x242f78)_0x3c2bd1(_0x48d34e(0xb8),_0x242f78);else{if(_0x29beb9?.['ok']===!0x1||_0x29beb9?.['error'])_0x3c2bd1(_0x48d34e(0x9c),_0x242f78,_0x29beb9?.['error']||_0x48d34e(0xa9),_0x48d34e(0xe2));else _0x3c2bd1('failed',null,'CommHub\x20response\x20omitted\x20task_id',_0x48d34e(0xc2));}return _0x29beb9;}catch(_0x18cac7){throw _0x3c2bd1('failed',null,_0x18cac7,_0x48d34e(0xab)),_0x18cac7;}}async function Y(_0x2d5502,_0x5505a5){const _0x224ea2=a0_0x66592b;return X({'fromAlias':_0x2d5502[_0x224ea2(0xb9)],'toAlias':_0x2d5502[_0x224ea2(0xce)],'parentTaskId':_0x2d5502[_0x224ea2(0xc6)]||null,'networkId':_0x2d5502[_0x224ea2(0xc8)]||null,'transport':_0x224ea2(0x89),'lifecycleTracking':_0x224ea2(0x92)},_0x5505a5);}class $ extends a0_0xd2e692{[a0_0x66592b(0xc0)];[a0_0x66592b(0xce)];['token'];[a0_0x66592b(0xb7)];[a0_0x66592b(0xb2)];[a0_0x66592b(0xe8)];[a0_0x66592b(0xd1)];['heartbeatTimer'];[a0_0x66592b(0xb1)];[a0_0x66592b(0xc5)]=!0x1;constructor(_0x500cc2){const _0x5dde56=a0_0x66592b;super();if(this[_0x5dde56(0xc0)]=_0x500cc2[_0x5dde56(0xc0)][_0x5dde56(0xbf)](/\/$/,''),this[_0x5dde56(0xce)]=_0x500cc2[_0x5dde56(0xce)],this[_0x5dde56(0xd7)]=_0x500cc2[_0x5dde56(0xd7)],this[_0x5dde56(0xb7)]=_0x500cc2['agent']||_0x5dde56(0x9d),this['resumeId']=_0x5dde56(0x93)+_0x500cc2[_0x5dde56(0xce)]+'-'+Date[_0x5dde56(0xb3)]()[_0x5dde56(0xdc)](0x24),this[_0x5dde56(0xe8)]=_0x500cc2['heartbeatInterval']??0x2bf20,this[_0x5dde56(0xd1)]=_0x500cc2['reconnectDelay']??0xbb8,_0x500cc2[_0x5dde56(0xeb)]!==!0x1)this[_0x5dde56(0xe0)]();}[a0_0x66592b(0xd9)](_0x1df07c){const _0x3e9373=a0_0x66592b;console[_0x3e9373(0xd9)]('['+new Date()[_0x3e9373(0xf3)]()[_0x3e9373(0xa2)](0x0,0x8)+_0x3e9373(0xaf)+this[_0x3e9373(0xce)]+']\x20'+_0x1df07c);}async[a0_0x66592b(0xdf)](_0x37f5a3,_0xbe23c5){const _0xb622dd=a0_0x66592b;let _0x3965b2={'Content-Type':_0xb622dd(0xda),'Accept':_0xb622dd(0xfc)};if(this['token'])_0x3965b2[_0xb622dd(0xf1)]=_0xb622dd(0xae)+this[_0xb622dd(0xd7)];let _0x328ce7=await(await fetch(this[_0xb622dd(0xc0)]+_0xb622dd(0xd5),{'method':_0xb622dd(0xaa),'headers':_0x3965b2,'body':JSON[_0xb622dd(0xdb)]({'jsonrpc':_0xb622dd(0xe1),'id':Date[_0xb622dd(0xb3)](),'method':_0xb622dd(0xc7),'params':{'name':_0x37f5a3,'arguments':_0xbe23c5}})}))[_0xb622dd(0x100)](),_0x3f64cc=_0x328ce7[_0xb622dd(0xbb)](/data: (.+)/),_0x4cbda2=_0x3f64cc?JSON[_0xb622dd(0xc3)](_0x3f64cc[0x1]):JSON['parse'](_0x328ce7),_0x4a0952=_0x4cbda2?.['result']?.[_0xb622dd(0xfd)]?.[0x0]?.[_0xb622dd(0x100)];return _0x4a0952?JSON[_0xb622dd(0xc3)](_0x4a0952):_0x4cbda2;}async['connect'](){const _0x2c76b6=a0_0x66592b;if(this[_0x2c76b6(0xc5)])return;this[_0x2c76b6(0xc5)]=!0x0,await this[_0x2c76b6(0x9f)](_0x2c76b6(0xcf)),this[_0x2c76b6(0xd9)](_0x2c76b6(0xca)),this[_0x2c76b6(0xee)]=setInterval(()=>{const _0x2d9052=_0x2c76b6;this['status'](_0x2d9052(0xcf))['catch'](_0x53ea4c=>this[_0x2d9052(0xd9)](_0x2d9052(0xfe)+_0x53ea4c['message']));},this[_0x2c76b6(0xe8)]),this[_0x2c76b6(0x8d)]();}async[a0_0x66592b(0x101)](){const _0x1e749e=a0_0x66592b;if(this[_0x1e749e(0xc5)]=!0x1,this[_0x1e749e(0xb1)]?.[_0x1e749e(0xad)](),this[_0x1e749e(0xee)])clearInterval(this[_0x1e749e(0xee)]);await this[_0x1e749e(0x9f)](_0x1e749e(0xd3))[_0x1e749e(0xac)](()=>{}),this[_0x1e749e(0xd9)](_0x1e749e(0x88));}async[a0_0x66592b(0x90)](_0x9c22fe,_0x2f2322,_0x249561=a0_0x66592b(0xcb)){const _0xe376be=a0_0x66592b;return Y({'alias':_0x9c22fe,'fromAlias':this[_0xe376be(0xce)]},{'log':_0x44e458=>console[_0xe376be(0xd9)](_0x44e458),'send':()=>this[_0xe376be(0xdf)](_0xe376be(0xe5),{'alias':_0x9c22fe,'task':_0x2f2322,'priority':_0x249561,'from_session':this[_0xe376be(0xce)]})});}async[a0_0x66592b(0xdd)](_0x1921d1,_0x1a9d0a){return this['call']('send_message',{'alias':_0x1921d1,'message':_0x1a9d0a,'from_session':this['alias']});}async[a0_0x66592b(0x8e)](_0x4d43bf,_0x1c7c08,_0x2e6de2=a0_0x66592b(0xba)){const _0x202f39=a0_0x66592b;return this[_0x202f39(0xdf)](_0x202f39(0xa4),{'in_reply_to':_0x4d43bf,'text':_0x1c7c08,'status':_0x2e6de2});}async[a0_0x66592b(0x9f)](_0x76dc6a,_0x623b3f){const _0x1518ca=a0_0x66592b;return this['call'](_0x1518ca(0xfb),{'resume_id':this['resumeId'],'alias':this[_0x1518ca(0xce)],'status':_0x76dc6a,'server':a0_0xab7f48(),'hostname':a0_0xab7f48(),'agent':this[_0x1518ca(0xb7)],'project_dir':process[_0x1518ca(0x94)](),..._0x623b3f});}async[a0_0x66592b(0xd0)](){const _0x51b83e=a0_0x66592b;return this['call'](_0x51b83e(0x8c),{});}async[a0_0x66592b(0xa3)](_0xf46807,_0x58ee4d){const _0x15644c=a0_0x66592b;return this[_0x15644c(0xdf)]('broadcast',{'message':_0xf46807,'filter_server':_0x58ee4d?.[_0x15644c(0x84)],'filter_status':_0x58ee4d?.[_0x15644c(0x9f)]});}async[a0_0x66592b(0x8d)](){const _0x27bf0f=a0_0x66592b;let _0x171673=encodeURIComponent(this['alias']),_0x2e9165=this[_0x27bf0f(0xc0)]+_0x27bf0f(0xf2)+_0x171673,_0x2d009b=this[_0x27bf0f(0xd1)];while(this['running']){try{this[_0x27bf0f(0xb1)]=new AbortController();let _0x5cbe4d={'Accept':'text/event-stream'};if(this[_0x27bf0f(0xd7)])_0x5cbe4d[_0x27bf0f(0xf1)]=_0x27bf0f(0xae)+this[_0x27bf0f(0xd7)];let _0x68a595=await fetch(_0x2e9165,{'headers':_0x5cbe4d,'signal':this[_0x27bf0f(0xb1)][_0x27bf0f(0xd2)]});if(!_0x68a595['ok']||!_0x68a595['body']){this[_0x27bf0f(0xd9)]('SSE\x20failed:\x20'+_0x68a595[_0x27bf0f(0x9f)]),await this['sleep'](_0x2d009b),_0x2d009b=Math['min'](_0x2d009b*1.5,0xea60);continue;}_0x2d009b=this[_0x27bf0f(0xd1)];let _0x1e2165=_0x68a595[_0x27bf0f(0xde)]['getReader'](),_0xc60486=new TextDecoder(),_0x386bd2='';while(this['running']){let {done:_0x5e863c,value:_0x365e39}=await _0x1e2165['read']();if(_0x5e863c)break;_0x386bd2+=_0xc60486[_0x27bf0f(0x8f)](_0x365e39,{'stream':!0x0});let _0x21c6a6=_0x386bd2['split']('\x0a');_0x386bd2=_0x21c6a6[_0x27bf0f(0xec)]()||'';for(let _0x16b781 of _0x21c6a6){if(!_0x16b781[_0x27bf0f(0xc9)](_0x27bf0f(0x97)))continue;try{let _0x405375=JSON[_0x27bf0f(0xc3)](_0x16b781['slice'](0x6));if(_0x405375['type']===_0x27bf0f(0xb4)){this['log'](_0x27bf0f(0xfa)),this[_0x27bf0f(0xc4)](_0x27bf0f(0xb4));continue;}if(_0x405375[_0x27bf0f(0xa5)]==='new_task'||_0x405375[_0x27bf0f(0xa5)]===_0x27bf0f(0xef)||_0x405375['type']===_0x27bf0f(0xa3))await this[_0x27bf0f(0xcd)]();}catch{}}}}catch(_0xc0db76){if(_0xc0db76[_0x27bf0f(0xcc)]==='AbortError')break;this[_0x27bf0f(0xc4)](_0x27bf0f(0xa6),_0xc0db76),this[_0x27bf0f(0xd9)](_0x27bf0f(0xa8)+_0xc0db76[_0x27bf0f(0xdd)]);}if(this[_0x27bf0f(0xc5)])this[_0x27bf0f(0xc4)](_0x27bf0f(0x88)),this['log']('SSE\x20reconnecting\x20in\x20'+_0x2d009b/0x3e8+'s...'),await this['sleep'](_0x2d009b),_0x2d009b=Math[_0x27bf0f(0xf5)](_0x2d009b*1.5,0xea60);}}async['processInbox'](){const _0x2bbd32=a0_0x66592b;try{let _0xd2f1e1=(await this[_0x2bbd32(0xdf)]('get_inbox',{'alias':this['alias'],'limit':0xa}))?.['messages']||[];for(let _0x55c924 of _0xd2f1e1)await this[_0x2bbd32(0xdf)]('ack_inbox',{'alias':this[_0x2bbd32(0xce)],'message_id':_0x55c924['id']}),this[_0x2bbd32(0xd9)]('←\x20'+_0x55c924[_0x2bbd32(0xb0)]+':\x20'+_0x55c924['content']['slice'](0x0,0x3c)),this[_0x2bbd32(0xc4)](_0x2bbd32(0x8a),_0x55c924),this[_0x2bbd32(0xc4)](_0x2bbd32(0xdd),_0x55c924);}catch(_0x1a339c){this[_0x2bbd32(0xd9)](_0x2bbd32(0x99)+_0x1a339c[_0x2bbd32(0xdd)]);}}[a0_0x66592b(0xb6)](_0x487c25){return new Promise(_0x487ec8=>setTimeout(_0x487ec8,_0x487c25));}}var F=$;export{F as default,$ as CommHub};
1
+ const a0_0x4f40f9=a0_0xe5d0;function a0_0x50c6(){const _0x29b7a1=['2.0','task_id','application/json,\x20text/event-stream','signal','connected','log','176IoPmnL','resumeId','POST','stringify','normal','toString','sleep','connect',']\x20[commhub:','startsWith','/mcp','status','sending','task.send.failed','not_tracked','error_code','\x20transport=','\x20duration_ms=','Authorization','decode','fromAlias','Bearer\x20','\x20error=','server','send_reply','text','running','mcp_http','from_session','CommHub\x20rejected\x20task','data:\x20','duration_ms','string','\x20parent_task_id=','connectSSE','task.started','16407jmZkOR','ack_inbox','url','22210dUNOas','329691aTYPRL','message_id','offline','missing_task_id','<pending>','idle','registered','cwd','task.send.delivered','error','10TIYKxS','task.ack','reconnectDelay','get_all_status','send_rejected','broadcast','content','completed','agent','new_message','error_message','sdk','\x20to=','pop','now','replace','CommHub\x20response\x20omitted\x20task_id','messages','token','send_message','match','tools/call','reply','[REDACTED]','disconnected','toAlias','processInbox','type','task','alias','1657362ykksPE','heartbeatTimer','call','parentTaskId','send','text/event-stream','611262MYPHST','task.send.start','application/json','\x20from=','body','5071mvqcjF','slice','message','get_inbox','send_task','SSE\x20error:\x20','sseAbort','toTimeString','autoConnect','result','s...','<unknown>','32RPenCV','emit','read','sdk-','send_failed','SSE\x20connected','1436449itDYcI','failed','transport','2095140NqYxja','networkId','SSE\x20reconnecting\x20in\x20','heartbeatInterval','parse','lifecycleTracking'];a0_0x50c6=function(){return _0x29b7a1;};return a0_0x50c6();}(function(_0x1871b7,_0x36f494){const _0x53a508=a0_0xe5d0,_0x39aedf=_0x1871b7();while(!![]){try{const _0x4833c1=parseInt(_0x53a508(0x23b))/0x1+parseInt(_0x53a508(0x213))/0x2*(parseInt(_0x53a508(0x237))/0x3)+-parseInt(_0x53a508(0x207))/0x4+-parseInt(_0x53a508(0x245))/0x5*(parseInt(_0x53a508(0x1e7))/0x6)+-parseInt(_0x53a508(0x204))/0x7+parseInt(_0x53a508(0x1fe))/0x8*(-parseInt(_0x53a508(0x1ed))/0x9)+-parseInt(_0x53a508(0x23a))/0xa*(-parseInt(_0x53a508(0x1f2))/0xb);if(_0x4833c1===_0x36f494)break;else _0x39aedf['push'](_0x39aedf['shift']());}catch(_0x318a71){_0x39aedf['push'](_0x39aedf['shift']());}}}(a0_0x50c6,0x44c7e));import{EventEmitter as a0_0x1bc1fd}from'events';import{hostname as a0_0x5bd3d5}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x34344d,_0x48d7cc)=>(_0x34344d??_0x48d7cc)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x4f40f9(0x1f3)](0x0,0xf0);function N(_0xbe812f){const _0x1fb400=a0_0x4f40f9;return(_0xbe812f instanceof Error?_0xbe812f[_0x1fb400(0x1f4)]:String(_0xbe812f??'unknown\x20error'))['replace'](K,_0x1fb400(0x25c))[_0x1fb400(0x254)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x1fb400(0x1f3)](0x0,0xf0);}function O(_0x7b703c,_0x2ff1e4=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0xa8be13=a0_0x4f40f9;if(_0x2ff1e4)return JSON[_0xa8be13(0x216)](_0x7b703c);let _0x5d531e=L(_0x7b703c['parent_task_id'],'<missing>'),_0x4711fd=L(_0x7b703c[_0xa8be13(0x20e)],_0xa8be13(0x23f)),_0x45710e=_0x7b703c['error_code']?_0xa8be13(0x229)+_0x7b703c[_0xa8be13(0x222)]+':'+(_0x7b703c[_0xa8be13(0x24f)]??''):'';return'[commhub:task]\x20'+_0x7b703c[_0xa8be13(0x21e)]+_0xa8be13(0x1f0)+L(_0x7b703c['from_alias'],_0xa8be13(0x1fd))+_0xa8be13(0x251)+L(_0x7b703c['to_alias'],_0xa8be13(0x1fd))+'\x20task_id='+_0x4711fd+_0xa8be13(0x234)+_0x5d531e+'\x20network_id='+L(_0x7b703c['network_id'],_0xa8be13(0x1fd))+_0xa8be13(0x223)+_0x7b703c['transport']+_0xa8be13(0x224)+_0x7b703c[_0xa8be13(0x232)]+'\x20lifecycle='+_0x7b703c['lifecycle_tracking']+_0x45710e;}function a0_0xe5d0(_0x1cc331,_0x85fa99){_0x1cc331=_0x1cc331-0x1e4;const _0x50c66b=a0_0x50c6();let _0xe5d01b=_0x50c66b[_0x1cc331];return _0xe5d01b;}function U(_0x4f4776){const _0x16c585=a0_0x4f40f9;return{'event':{'sending':_0x16c585(0x1ee),'delivered':_0x16c585(0x243),'failed':_0x16c585(0x220),'acked':_0x16c585(0x246),'started':_0x16c585(0x236),'replied':'task.replied','expired':'task.expired'}[_0x4f4776[_0x16c585(0x21e)]],..._0x4f4776};}function j(_0x505198){const _0x4413d9=a0_0x4f40f9;let _0xae909b=_0x505198?.[_0x4413d9(0x20e)]||_0x505198?.[_0x4413d9(0x23c)]||_0x505198?.['id'];if(_0xae909b)return String(_0xae909b);let _0x128b56=_0x505198?.[_0x4413d9(0x24b)]?.[0x0]?.['text'];if(typeof _0x128b56!==_0x4413d9(0x233))return null;try{let _0x4a575c=JSON['parse'](_0x128b56);return _0x4a575c?.['task_id']||_0x4a575c?.[_0x4413d9(0x23c)]||_0x4a575c?.['id']||null;}catch{return null;}}async function X(_0x5b0230,_0x421a2b){const _0x378ea4=a0_0x4f40f9;let _0x1367ff=_0x421a2b['now']??Date[_0x378ea4(0x253)],_0xb96858=_0x1367ff(),_0x3f57ed=(_0x51c56b,_0x460ed1,_0xcdab3d,_0xb25893)=>{const _0x1e6841=_0x378ea4;_0x421a2b[_0x1e6841(0x212)](O(U({'from_alias':_0x5b0230['fromAlias'],'to_alias':_0x5b0230[_0x1e6841(0x25e)],'task_id':_0x460ed1,'parent_task_id':_0x5b0230[_0x1e6841(0x1ea)],'network_id':_0x5b0230[_0x1e6841(0x208)],'transport':_0x5b0230[_0x1e6841(0x206)],'status':_0x51c56b,'duration_ms':_0x1367ff()-_0xb96858,'lifecycle_tracking':_0x5b0230[_0x1e6841(0x20c)],..._0xcdab3d!==void 0x0?{'error_code':_0xb25893||_0x1e6841(0x202),'error_message':N(_0xcdab3d)}:{}})));};_0x3f57ed(_0x378ea4(0x21f),null);try{let _0x162bc9=await _0x421a2b['send'](),_0x590639=j(_0x162bc9);if(_0x590639)_0x3f57ed('delivered',_0x590639);else{if(_0x162bc9?.['ok']===!0x1||_0x162bc9?.[_0x378ea4(0x244)])_0x3f57ed(_0x378ea4(0x205),_0x590639,_0x162bc9?.[_0x378ea4(0x244)]||_0x378ea4(0x230),_0x378ea4(0x249));else _0x3f57ed('failed',null,_0x378ea4(0x255),_0x378ea4(0x23e));}return _0x162bc9;}catch(_0x5c2019){throw _0x3f57ed(_0x378ea4(0x205),null,_0x5c2019,_0x378ea4(0x202)),_0x5c2019;}}async function Y(_0xe9f2d7,_0x58f71e){const _0x5ab250=a0_0x4f40f9;return X({'fromAlias':_0xe9f2d7[_0x5ab250(0x227)],'toAlias':_0xe9f2d7[_0x5ab250(0x1e6)],'parentTaskId':_0xe9f2d7['parentTaskId']||null,'networkId':_0xe9f2d7[_0x5ab250(0x208)]||null,'transport':_0x5ab250(0x22e),'lifecycleTracking':_0x5ab250(0x221)},_0x58f71e);}class $ extends a0_0x1bc1fd{[a0_0x4f40f9(0x239)];[a0_0x4f40f9(0x1e6)];[a0_0x4f40f9(0x257)];[a0_0x4f40f9(0x24d)];[a0_0x4f40f9(0x214)];[a0_0x4f40f9(0x20a)];['reconnectDelay'];[a0_0x4f40f9(0x1e8)];[a0_0x4f40f9(0x1f8)];[a0_0x4f40f9(0x22d)]=!0x1;constructor(_0x533f20){const _0x8382c7=a0_0x4f40f9;super();if(this[_0x8382c7(0x239)]=_0x533f20[_0x8382c7(0x239)]['replace'](/\/$/,''),this[_0x8382c7(0x1e6)]=_0x533f20[_0x8382c7(0x1e6)],this[_0x8382c7(0x257)]=_0x533f20['token'],this[_0x8382c7(0x24d)]=_0x533f20['agent']||_0x8382c7(0x250),this[_0x8382c7(0x214)]=_0x8382c7(0x201)+_0x533f20[_0x8382c7(0x1e6)]+'-'+Date[_0x8382c7(0x253)]()[_0x8382c7(0x218)](0x24),this['heartbeatInterval']=_0x533f20[_0x8382c7(0x20a)]??0x2bf20,this[_0x8382c7(0x247)]=_0x533f20[_0x8382c7(0x247)]??0xbb8,_0x533f20[_0x8382c7(0x1fa)]!==!0x1)this['connect']();}['log'](_0x2c6295){const _0x4c70e0=a0_0x4f40f9;console[_0x4c70e0(0x212)]('['+new Date()[_0x4c70e0(0x1f9)]()['slice'](0x0,0x8)+_0x4c70e0(0x21b)+this[_0x4c70e0(0x1e6)]+']\x20'+_0x2c6295);}async['call'](_0x2a9bff,_0x3ee19e){const _0x59da48=a0_0x4f40f9;let _0xa48b88={'Content-Type':_0x59da48(0x1ef),'Accept':_0x59da48(0x20f)};if(this[_0x59da48(0x257)])_0xa48b88[_0x59da48(0x225)]=_0x59da48(0x228)+this[_0x59da48(0x257)];let _0x5a4a64=await(await fetch(this[_0x59da48(0x239)]+_0x59da48(0x21d),{'method':_0x59da48(0x215),'headers':_0xa48b88,'body':JSON[_0x59da48(0x216)]({'jsonrpc':_0x59da48(0x20d),'id':Date[_0x59da48(0x253)](),'method':_0x59da48(0x25a),'params':{'name':_0x2a9bff,'arguments':_0x3ee19e}})}))[_0x59da48(0x22c)](),_0x3cd375=_0x5a4a64[_0x59da48(0x259)](/data: (.+)/),_0xf56a8c=_0x3cd375?JSON[_0x59da48(0x20b)](_0x3cd375[0x1]):JSON[_0x59da48(0x20b)](_0x5a4a64),_0x4ba504=_0xf56a8c?.[_0x59da48(0x1fb)]?.[_0x59da48(0x24b)]?.[0x0]?.['text'];return _0x4ba504?JSON['parse'](_0x4ba504):_0xf56a8c;}async[a0_0x4f40f9(0x21a)](){const _0x26086=a0_0x4f40f9;if(this['running'])return;this[_0x26086(0x22d)]=!0x0,await this[_0x26086(0x21e)](_0x26086(0x240)),this['log'](_0x26086(0x241)),this[_0x26086(0x1e8)]=setInterval(()=>{const _0x4c4107=_0x26086;this[_0x4c4107(0x21e)](_0x4c4107(0x240))['catch'](_0x4bec2b=>this['log']('heartbeat\x20failed:\x20'+_0x4bec2b['message']));},this[_0x26086(0x20a)]),this[_0x26086(0x235)]();}async['disconnect'](){const _0x3fade0=a0_0x4f40f9;if(this[_0x3fade0(0x22d)]=!0x1,this[_0x3fade0(0x1f8)]?.['abort'](),this['heartbeatTimer'])clearInterval(this[_0x3fade0(0x1e8)]);await this['status'](_0x3fade0(0x23d))['catch'](()=>{}),this[_0x3fade0(0x212)](_0x3fade0(0x25d));}async[a0_0x4f40f9(0x1eb)](_0x449307,_0x5e0f34,_0x2e4f26=a0_0x4f40f9(0x217)){const _0xb7e47a=a0_0x4f40f9;return Y({'alias':_0x449307,'fromAlias':this['alias']},{'log':_0x28b396=>console['log'](_0x28b396),'send':()=>this['call'](_0xb7e47a(0x1f6),{'alias':_0x449307,'task':_0x5e0f34,'priority':_0x2e4f26,'from_session':this[_0xb7e47a(0x1e6)]})});}async['message'](_0x494dbc,_0x368f3b){const _0xe429dd=a0_0x4f40f9;return this['call'](_0xe429dd(0x258),{'alias':_0x494dbc,'message':_0x368f3b,'from_session':this[_0xe429dd(0x1e6)]});}async[a0_0x4f40f9(0x25b)](_0x46dc12,_0x35d74a,_0xda5129=a0_0x4f40f9(0x24c)){const _0xd8efb1=a0_0x4f40f9;return this[_0xd8efb1(0x1e9)](_0xd8efb1(0x22b),{'in_reply_to':_0x46dc12,'text':_0x35d74a,'status':_0xda5129});}async[a0_0x4f40f9(0x21e)](_0x214542,_0x44eecb){const _0x1d0523=a0_0x4f40f9;return this[_0x1d0523(0x1e9)]('report_status',{'resume_id':this[_0x1d0523(0x214)],'alias':this[_0x1d0523(0x1e6)],'status':_0x214542,'server':a0_0x5bd3d5(),'hostname':a0_0x5bd3d5(),'agent':this[_0x1d0523(0x24d)],'project_dir':process[_0x1d0523(0x242)](),..._0x44eecb});}async['getAllStatus'](){const _0x1e5a27=a0_0x4f40f9;return this[_0x1e5a27(0x1e9)](_0x1e5a27(0x248),{});}async[a0_0x4f40f9(0x24a)](_0x5d0f14,_0x5912c6){const _0xe9a0c1=a0_0x4f40f9;return this['call'](_0xe9a0c1(0x24a),{'message':_0x5d0f14,'filter_server':_0x5912c6?.[_0xe9a0c1(0x22a)],'filter_status':_0x5912c6?.[_0xe9a0c1(0x21e)]});}async[a0_0x4f40f9(0x235)](){const _0x53edaf=a0_0x4f40f9;let _0x51252b=encodeURIComponent(this[_0x53edaf(0x1e6)]),_0x34459c=this[_0x53edaf(0x239)]+'/events/'+_0x51252b,_0x2e5d14=this[_0x53edaf(0x247)];while(this['running']){try{this[_0x53edaf(0x1f8)]=new AbortController();let _0x26909c={'Accept':_0x53edaf(0x1ec)};if(this[_0x53edaf(0x257)])_0x26909c[_0x53edaf(0x225)]=_0x53edaf(0x228)+this[_0x53edaf(0x257)];let _0x4b186d=await fetch(_0x34459c,{'headers':_0x26909c,'signal':this['sseAbort'][_0x53edaf(0x210)]});if(!_0x4b186d['ok']||!_0x4b186d[_0x53edaf(0x1f1)]){this['log']('SSE\x20failed:\x20'+_0x4b186d[_0x53edaf(0x21e)]),await this['sleep'](_0x2e5d14),_0x2e5d14=Math['min'](_0x2e5d14*1.5,0xea60);continue;}_0x2e5d14=this[_0x53edaf(0x247)];let _0x48692d=_0x4b186d['body']['getReader'](),_0x1c30c8=new TextDecoder(),_0x2373da='';while(this[_0x53edaf(0x22d)]){let {done:_0x1a5c29,value:_0x4600fd}=await _0x48692d[_0x53edaf(0x200)]();if(_0x1a5c29)break;_0x2373da+=_0x1c30c8[_0x53edaf(0x226)](_0x4600fd,{'stream':!0x0});let _0x35abf9=_0x2373da['split']('\x0a');_0x2373da=_0x35abf9[_0x53edaf(0x252)]()||'';for(let _0x45a87b of _0x35abf9){if(!_0x45a87b[_0x53edaf(0x21c)](_0x53edaf(0x231)))continue;try{let _0x1dad48=JSON['parse'](_0x45a87b[_0x53edaf(0x1f3)](0x6));if(_0x1dad48[_0x53edaf(0x1e4)]===_0x53edaf(0x211)){this[_0x53edaf(0x212)](_0x53edaf(0x203)),this[_0x53edaf(0x1ff)](_0x53edaf(0x211));continue;}if(_0x1dad48[_0x53edaf(0x1e4)]==='new_task'||_0x1dad48[_0x53edaf(0x1e4)]===_0x53edaf(0x24e)||_0x1dad48[_0x53edaf(0x1e4)]==='broadcast')await this[_0x53edaf(0x25f)]();}catch{}}}}catch(_0x378e07){if(_0x378e07['name']==='AbortError')break;this[_0x53edaf(0x1ff)](_0x53edaf(0x244),_0x378e07),this[_0x53edaf(0x212)](_0x53edaf(0x1f7)+_0x378e07['message']);}if(this[_0x53edaf(0x22d)])this['emit'](_0x53edaf(0x25d)),this[_0x53edaf(0x212)](_0x53edaf(0x209)+_0x2e5d14/0x3e8+_0x53edaf(0x1fc)),await this[_0x53edaf(0x219)](_0x2e5d14),_0x2e5d14=Math['min'](_0x2e5d14*1.5,0xea60);}}async[a0_0x4f40f9(0x25f)](){const _0x3c0a00=a0_0x4f40f9;try{let _0x3643cd=(await this[_0x3c0a00(0x1e9)](_0x3c0a00(0x1f5),{'alias':this[_0x3c0a00(0x1e6)],'limit':0xa}))?.[_0x3c0a00(0x256)]||[];for(let _0x37a1c0 of _0x3643cd)await this['call'](_0x3c0a00(0x238),{'alias':this[_0x3c0a00(0x1e6)],'message_id':_0x37a1c0['id']}),this[_0x3c0a00(0x212)]('←\x20'+_0x37a1c0[_0x3c0a00(0x22f)]+':\x20'+_0x37a1c0[_0x3c0a00(0x24b)][_0x3c0a00(0x1f3)](0x0,0x3c)),this[_0x3c0a00(0x1ff)](_0x3c0a00(0x1e5),_0x37a1c0),this['emit']('message',_0x37a1c0);}catch(_0x1b2585){this[_0x3c0a00(0x212)]('inbox\x20error:\x20'+_0x1b2585['message']);}}[a0_0x4f40f9(0x219)](_0x55a7ab){return new Promise(_0x1d6bcb=>setTimeout(_0x1d6bcb,_0x55a7ab));}}var F=$;export{F as default,$ as CommHub};