@sleep2agi/agent-network 2.3.0-preview.175 → 2.3.0-preview.176

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_0x176379=a0_0x5eec;(function(_0x52b657,_0x3ddf98){const _0x3a4038=a0_0x5eec,_0x282412=_0x52b657();while(!![]){try{const _0x585512=-parseInt(_0x3a4038(0x162))/0x1+parseInt(_0x3a4038(0x1db))/0x2*(parseInt(_0x3a4038(0x1d8))/0x3)+parseInt(_0x3a4038(0x169))/0x4*(parseInt(_0x3a4038(0x17e))/0x5)+-parseInt(_0x3a4038(0x188))/0x6+-parseInt(_0x3a4038(0x174))/0x7+-parseInt(_0x3a4038(0x177))/0x8*(-parseInt(_0x3a4038(0x1c7))/0x9)+parseInt(_0x3a4038(0x1a9))/0xa;if(_0x585512===_0x3ddf98)break;else _0x282412['push'](_0x282412['shift']());}catch(_0x5e7956){_0x282412['push'](_0x282412['shift']());}}}(a0_0x531e,0x18cc3));import{EventEmitter as a0_0x5ea44d}from'events';import{hostname as a0_0x35d872}from'os';function a0_0x5eec(_0x352a67,_0x57eeaf){_0x352a67=_0x352a67-0x15f;const _0x531e47=a0_0x531e();let _0x5eec4a=_0x531e47[_0x352a67];return _0x5eec4a;}var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x2d4fbd,_0x55376c)=>(_0x2d4fbd??_0x55376c)[a0_0x176379(0x198)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x176379(0x167)](0x0,0xf0);function N(_0x150cc7){const _0x464f42=a0_0x176379;return(_0x150cc7 instanceof Error?_0x150cc7[_0x464f42(0x1b1)]:String(_0x150cc7??_0x464f42(0x16d)))[_0x464f42(0x198)](K,_0x464f42(0x15f))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x47bb71,_0x33d187=process.env.ANET_TASK_TRACE_FORMAT===a0_0x176379(0x1d7)){const _0x4ade11=a0_0x176379;if(_0x33d187)return JSON['stringify'](_0x47bb71);let _0x6b2e13=L(_0x47bb71['parent_task_id'],_0x4ade11(0x19b)),_0x31316f=L(_0x47bb71['task_id'],_0x4ade11(0x16e)),_0x20ebef=_0x47bb71[_0x4ade11(0x18b)]?_0x4ade11(0x1a5)+_0x47bb71[_0x4ade11(0x18b)]+':'+(_0x47bb71['error_message']??''):'';return _0x4ade11(0x19f)+_0x47bb71[_0x4ade11(0x193)]+'\x20from='+L(_0x47bb71[_0x4ade11(0x182)],'<unknown>')+_0x4ade11(0x17b)+L(_0x47bb71[_0x4ade11(0x1be)],_0x4ade11(0x179))+_0x4ade11(0x1a0)+_0x31316f+_0x4ade11(0x1dc)+_0x6b2e13+_0x4ade11(0x163)+L(_0x47bb71[_0x4ade11(0x1d9)],'<unknown>')+_0x4ade11(0x1d2)+_0x47bb71[_0x4ade11(0x1c1)]+'\x20duration_ms='+_0x47bb71[_0x4ade11(0x164)]+'\x20lifecycle='+_0x47bb71[_0x4ade11(0x1b9)]+_0x20ebef;}function U(_0x504f43){const _0x3cc84a=a0_0x176379;return{'event':{'sending':'task.send.start','delivered':'task.send.delivered','failed':_0x3cc84a(0x17d),'acked':_0x3cc84a(0x1cd),'started':_0x3cc84a(0x1a8),'replied':'task.replied','expired':'task.expired'}[_0x504f43[_0x3cc84a(0x193)]],..._0x504f43};}function j(_0x50d309){const _0x278e35=a0_0x176379;let _0x26470f=_0x50d309?.['task_id']||_0x50d309?.[_0x278e35(0x195)]||_0x50d309?.['id'];if(_0x26470f)return String(_0x26470f);let _0x13d9e9=_0x50d309?.[_0x278e35(0x17f)]?.[0x0]?.[_0x278e35(0x18e)];if(typeof _0x13d9e9!==_0x278e35(0x180))return null;try{let _0x5b0eba=JSON[_0x278e35(0x1ad)](_0x13d9e9);return _0x5b0eba?.[_0x278e35(0x1aa)]||_0x5b0eba?.[_0x278e35(0x195)]||_0x5b0eba?.['id']||null;}catch{return null;}}function a0_0x531e(){const _0x327dda=['Authorization','reply','reconnectDelay','message','application/json,\x20text/event-stream','sleep','split',']\x20[commhub:','broadcast','processInbox','Bearer\x20','lifecycle_tracking','new_message','SSE\x20failed:\x20','result','send_reply','to_alias','send','min','transport','heartbeatTimer','abort','catch','report_status','decode','18hXrPKh','failed','AbortError','2.0','name','now','task.ack','read','parentTaskId','s...','emit','\x20transport=','autoConnect','connect','send_failed','heartbeatInterval','json','59019ldXhMg','network_id','SSE\x20connected','4mGXptN','\x20parent_task_id=','[REDACTED]','task','connected','125806yiwKhs','\x20network_id=','duration_ms','missing_task_id','connectSSE','slice','error','11616ZPvktE','mcp_http','disconnect','/events/','unknown\x20error','<pending>','agent','server','offline','toString','getAllStatus','268030sjdDnv','resumeId','cwd','41672JuJeZW','SSE\x20error:\x20','<unknown>','heartbeat\x20failed:\x20','\x20to=','token','task.send.failed','200jlSdle','content','string','application/json','from_alias','url','get_inbox','idle','sseAbort','body','982794FJrNnk','stringify','fromAlias','error_code','sending','send_message','text','from_session','data:\x20','sdk','completed','status','disconnected','message_id','signal','sdk-','replace','POST','lifecycleTracking','<missing>','log','pop','type','[commhub:task]\x20','\x20task_id=','running','networkId','call','send_task','\x20error=','tools/call','alias','task.started','2635420KUkDoo','task_id','text/event-stream','not_tracked','parse'];a0_0x531e=function(){return _0x327dda;};return a0_0x531e();}async function X(_0x5cd014,_0x12ca5a){const _0xe31b9a=a0_0x176379;let _0x21998c=_0x12ca5a[_0xe31b9a(0x1cc)]??Date[_0xe31b9a(0x1cc)],_0x1382a9=_0x21998c(),_0x522753=(_0x3df59e,_0x24bf76,_0x123fc8,_0x3dbd89)=>{const _0x1822fa=_0xe31b9a;_0x12ca5a[_0x1822fa(0x19c)](O(U({'from_alias':_0x5cd014['fromAlias'],'to_alias':_0x5cd014['toAlias'],'task_id':_0x24bf76,'parent_task_id':_0x5cd014[_0x1822fa(0x1cf)],'network_id':_0x5cd014[_0x1822fa(0x1a2)],'transport':_0x5cd014[_0x1822fa(0x1c1)],'status':_0x3df59e,'duration_ms':_0x21998c()-_0x1382a9,'lifecycle_tracking':_0x5cd014[_0x1822fa(0x19a)],..._0x123fc8!==void 0x0?{'error_code':_0x3dbd89||_0x1822fa(0x1d5),'error_message':N(_0x123fc8)}:{}})));};_0x522753(_0xe31b9a(0x18c),null);try{let _0x5707aa=await _0x12ca5a[_0xe31b9a(0x1bf)](),_0x53bc89=j(_0x5707aa);if(_0x53bc89)_0x522753('delivered',_0x53bc89);else{if(_0x5707aa?.['ok']===!0x1||_0x5707aa?.[_0xe31b9a(0x168)])_0x522753(_0xe31b9a(0x1c8),_0x53bc89,_0x5707aa?.[_0xe31b9a(0x168)]||'CommHub\x20rejected\x20task','send_rejected');else _0x522753(_0xe31b9a(0x1c8),null,'CommHub\x20response\x20omitted\x20task_id',_0xe31b9a(0x165));}return _0x5707aa;}catch(_0x44835d){throw _0x522753(_0xe31b9a(0x1c8),null,_0x44835d,_0xe31b9a(0x1d5)),_0x44835d;}}async function Y(_0x347c5a,_0x2c8aee){const _0x18a8fa=a0_0x176379;return X({'fromAlias':_0x347c5a[_0x18a8fa(0x18a)],'toAlias':_0x347c5a['alias'],'parentTaskId':_0x347c5a['parentTaskId']||null,'networkId':_0x347c5a[_0x18a8fa(0x1a2)]||null,'transport':_0x18a8fa(0x16a),'lifecycleTracking':_0x18a8fa(0x1ac)},_0x2c8aee);}class $ extends a0_0x5ea44d{['url'];['alias'];[a0_0x176379(0x17c)];[a0_0x176379(0x16f)];[a0_0x176379(0x175)];[a0_0x176379(0x1d6)];[a0_0x176379(0x1b0)];[a0_0x176379(0x1c2)];[a0_0x176379(0x186)];[a0_0x176379(0x1a1)]=!0x1;constructor(_0x46a86b){const _0x30bae3=a0_0x176379;super();if(this['url']=_0x46a86b[_0x30bae3(0x183)]['replace'](/\/$/,''),this['alias']=_0x46a86b[_0x30bae3(0x1a7)],this[_0x30bae3(0x17c)]=_0x46a86b['token'],this[_0x30bae3(0x16f)]=_0x46a86b[_0x30bae3(0x16f)]||_0x30bae3(0x191),this['resumeId']=_0x30bae3(0x197)+_0x46a86b[_0x30bae3(0x1a7)]+'-'+Date['now']()[_0x30bae3(0x172)](0x24),this[_0x30bae3(0x1d6)]=_0x46a86b['heartbeatInterval']??0x2bf20,this['reconnectDelay']=_0x46a86b[_0x30bae3(0x1b0)]??0xbb8,_0x46a86b[_0x30bae3(0x1d3)]!==!0x1)this[_0x30bae3(0x1d4)]();}[a0_0x176379(0x19c)](_0x1306d3){const _0xb27ee9=a0_0x176379;console[_0xb27ee9(0x19c)]('['+new Date()['toTimeString']()[_0xb27ee9(0x167)](0x0,0x8)+_0xb27ee9(0x1b5)+this[_0xb27ee9(0x1a7)]+']\x20'+_0x1306d3);}async[a0_0x176379(0x1a3)](_0x1ccfc5,_0x460daa){const _0x42be8b=a0_0x176379;let _0x18cf4d={'Content-Type':_0x42be8b(0x181),'Accept':_0x42be8b(0x1b2)};if(this[_0x42be8b(0x17c)])_0x18cf4d[_0x42be8b(0x1ae)]=_0x42be8b(0x1b8)+this[_0x42be8b(0x17c)];let _0x103b50=await(await fetch(this['url']+'/mcp',{'method':_0x42be8b(0x199),'headers':_0x18cf4d,'body':JSON[_0x42be8b(0x189)]({'jsonrpc':_0x42be8b(0x1ca),'id':Date[_0x42be8b(0x1cc)](),'method':_0x42be8b(0x1a6),'params':{'name':_0x1ccfc5,'arguments':_0x460daa}})}))[_0x42be8b(0x18e)](),_0x402e4b=_0x103b50['match'](/data: (.+)/),_0x5410e9=_0x402e4b?JSON[_0x42be8b(0x1ad)](_0x402e4b[0x1]):JSON[_0x42be8b(0x1ad)](_0x103b50),_0x1b8fbb=_0x5410e9?.[_0x42be8b(0x1bc)]?.[_0x42be8b(0x17f)]?.[0x0]?.[_0x42be8b(0x18e)];return _0x1b8fbb?JSON[_0x42be8b(0x1ad)](_0x1b8fbb):_0x5410e9;}async['connect'](){const _0x33e8f8=a0_0x176379;if(this[_0x33e8f8(0x1a1)])return;this[_0x33e8f8(0x1a1)]=!0x0,await this[_0x33e8f8(0x193)](_0x33e8f8(0x185)),this[_0x33e8f8(0x19c)]('registered'),this['heartbeatTimer']=setInterval(()=>{const _0x536ce2=_0x33e8f8;this[_0x536ce2(0x193)](_0x536ce2(0x185))[_0x536ce2(0x1c4)](_0x17c262=>this['log'](_0x536ce2(0x17a)+_0x17c262[_0x536ce2(0x1b1)]));},this['heartbeatInterval']),this[_0x33e8f8(0x166)]();}async[a0_0x176379(0x16b)](){const _0x213765=a0_0x176379;if(this[_0x213765(0x1a1)]=!0x1,this[_0x213765(0x186)]?.[_0x213765(0x1c3)](),this[_0x213765(0x1c2)])clearInterval(this[_0x213765(0x1c2)]);await this[_0x213765(0x193)](_0x213765(0x171))[_0x213765(0x1c4)](()=>{}),this[_0x213765(0x19c)](_0x213765(0x194));}async[a0_0x176379(0x1bf)](_0xf51eee,_0x1c8b1a,_0x1f8d08='normal'){const _0x23906d=a0_0x176379;return Y({'alias':_0xf51eee,'fromAlias':this[_0x23906d(0x1a7)]},{'log':_0xa9997b=>console[_0x23906d(0x19c)](_0xa9997b),'send':()=>this[_0x23906d(0x1a3)](_0x23906d(0x1a4),{'alias':_0xf51eee,'task':_0x1c8b1a,'priority':_0x1f8d08,'from_session':this[_0x23906d(0x1a7)]})});}async['message'](_0x92c508,_0x3a4ccb){const _0x18862e=a0_0x176379;return this['call'](_0x18862e(0x18d),{'alias':_0x92c508,'message':_0x3a4ccb,'from_session':this['alias']});}async[a0_0x176379(0x1af)](_0x572474,_0x45b0b9,_0x32c49f=a0_0x176379(0x192)){const _0x4d5b05=a0_0x176379;return this[_0x4d5b05(0x1a3)](_0x4d5b05(0x1bd),{'in_reply_to':_0x572474,'text':_0x45b0b9,'status':_0x32c49f});}async[a0_0x176379(0x193)](_0x10df6d,_0xe91a1){const _0xa08e11=a0_0x176379;return this[_0xa08e11(0x1a3)](_0xa08e11(0x1c5),{'resume_id':this['resumeId'],'alias':this[_0xa08e11(0x1a7)],'status':_0x10df6d,'server':a0_0x35d872(),'hostname':a0_0x35d872(),'agent':this['agent'],'project_dir':process[_0xa08e11(0x176)](),..._0xe91a1});}async[a0_0x176379(0x173)](){const _0x3d39fa=a0_0x176379;return this[_0x3d39fa(0x1a3)]('get_all_status',{});}async[a0_0x176379(0x1b6)](_0x4cd3ab,_0x21e7c1){const _0xee070=a0_0x176379;return this[_0xee070(0x1a3)](_0xee070(0x1b6),{'message':_0x4cd3ab,'filter_server':_0x21e7c1?.[_0xee070(0x170)],'filter_status':_0x21e7c1?.[_0xee070(0x193)]});}async[a0_0x176379(0x166)](){const _0x4ff962=a0_0x176379;let _0x1cad56=encodeURIComponent(this['alias']),_0x1919c9=this[_0x4ff962(0x183)]+_0x4ff962(0x16c)+_0x1cad56,_0x1cffa8=this[_0x4ff962(0x1b0)];while(this['running']){try{this[_0x4ff962(0x186)]=new AbortController();let _0x25ae54={'Accept':_0x4ff962(0x1ab)};if(this[_0x4ff962(0x17c)])_0x25ae54[_0x4ff962(0x1ae)]=_0x4ff962(0x1b8)+this['token'];let _0x45209e=await fetch(_0x1919c9,{'headers':_0x25ae54,'signal':this[_0x4ff962(0x186)][_0x4ff962(0x196)]});if(!_0x45209e['ok']||!_0x45209e[_0x4ff962(0x187)]){this[_0x4ff962(0x19c)](_0x4ff962(0x1bb)+_0x45209e[_0x4ff962(0x193)]),await this[_0x4ff962(0x1b3)](_0x1cffa8),_0x1cffa8=Math[_0x4ff962(0x1c0)](_0x1cffa8*1.5,0xea60);continue;}_0x1cffa8=this[_0x4ff962(0x1b0)];let _0x359c2a=_0x45209e[_0x4ff962(0x187)]['getReader'](),_0x4738f1=new TextDecoder(),_0x58e8f8='';while(this[_0x4ff962(0x1a1)]){let {done:_0x50f2f2,value:_0x474ed0}=await _0x359c2a[_0x4ff962(0x1ce)]();if(_0x50f2f2)break;_0x58e8f8+=_0x4738f1[_0x4ff962(0x1c6)](_0x474ed0,{'stream':!0x0});let _0x1d567e=_0x58e8f8[_0x4ff962(0x1b4)]('\x0a');_0x58e8f8=_0x1d567e[_0x4ff962(0x19d)]()||'';for(let _0x55d48a of _0x1d567e){if(!_0x55d48a['startsWith'](_0x4ff962(0x190)))continue;try{let _0x47e509=JSON[_0x4ff962(0x1ad)](_0x55d48a[_0x4ff962(0x167)](0x6));if(_0x47e509[_0x4ff962(0x19e)]==='connected'){this[_0x4ff962(0x19c)](_0x4ff962(0x1da)),this[_0x4ff962(0x1d1)](_0x4ff962(0x161));continue;}if(_0x47e509[_0x4ff962(0x19e)]==='new_task'||_0x47e509[_0x4ff962(0x19e)]===_0x4ff962(0x1ba)||_0x47e509[_0x4ff962(0x19e)]===_0x4ff962(0x1b6))await this[_0x4ff962(0x1b7)]();}catch{}}}}catch(_0x511ff0){if(_0x511ff0[_0x4ff962(0x1cb)]===_0x4ff962(0x1c9))break;this[_0x4ff962(0x1d1)](_0x4ff962(0x168),_0x511ff0),this[_0x4ff962(0x19c)](_0x4ff962(0x178)+_0x511ff0[_0x4ff962(0x1b1)]);}if(this[_0x4ff962(0x1a1)])this['emit'](_0x4ff962(0x194)),this[_0x4ff962(0x19c)]('SSE\x20reconnecting\x20in\x20'+_0x1cffa8/0x3e8+_0x4ff962(0x1d0)),await this[_0x4ff962(0x1b3)](_0x1cffa8),_0x1cffa8=Math[_0x4ff962(0x1c0)](_0x1cffa8*1.5,0xea60);}}async[a0_0x176379(0x1b7)](){const _0x132f95=a0_0x176379;try{let _0x2787d8=(await this[_0x132f95(0x1a3)](_0x132f95(0x184),{'alias':this[_0x132f95(0x1a7)],'limit':0xa}))?.['messages']||[];for(let _0x2205cb of _0x2787d8)await this[_0x132f95(0x1a3)]('ack_inbox',{'alias':this[_0x132f95(0x1a7)],'message_id':_0x2205cb['id']}),this['log']('←\x20'+_0x2205cb[_0x132f95(0x18f)]+':\x20'+_0x2205cb[_0x132f95(0x17f)][_0x132f95(0x167)](0x0,0x3c)),this[_0x132f95(0x1d1)](_0x132f95(0x160),_0x2205cb),this[_0x132f95(0x1d1)](_0x132f95(0x1b1),_0x2205cb);}catch(_0x5c7ecf){this[_0x132f95(0x19c)]('inbox\x20error:\x20'+_0x5c7ecf[_0x132f95(0x1b1)]);}}[a0_0x176379(0x1b3)](_0x408c5c){return new Promise(_0x1cd234=>setTimeout(_0x1cd234,_0x408c5c));}}var F=$;export{F as default,$ as CommHub};
1
+ const a0_0x1c3100=a0_0x1a14;function a0_0x1a14(_0x347c32,_0x409e79){_0x347c32=_0x347c32-0xc1;const _0x578955=a0_0x5789();let _0x1a1436=_0x578955[_0x347c32];return _0x1a1436;}(function(_0x4c8e03,_0x36e943){const _0x49f872=a0_0x1a14,_0x552763=_0x4c8e03();while(!![]){try{const _0x3a242c=parseInt(_0x49f872(0xf3))/0x1+-parseInt(_0x49f872(0xc3))/0x2+parseInt(_0x49f872(0xd0))/0x3+parseInt(_0x49f872(0x12d))/0x4*(parseInt(_0x49f872(0xd9))/0x5)+parseInt(_0x49f872(0x130))/0x6+parseInt(_0x49f872(0xe8))/0x7+-parseInt(_0x49f872(0xeb))/0x8;if(_0x3a242c===_0x36e943)break;else _0x552763['push'](_0x552763['shift']());}catch(_0x2a314c){_0x552763['push'](_0x552763['shift']());}}}(a0_0x5789,0x34d6e));import{EventEmitter as a0_0x331c85}from'events';import{hostname as a0_0x177dc3}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x141e25,_0x4a04a8)=>(_0x141e25??_0x4a04a8)[a0_0x1c3100(0xc9)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x1c3100(0x11f)](0x0,0xf0);function a0_0x5789(){const _0x4858d4=['/mcp','broadcast','<missing>','processInbox','Authorization','now','sleep','normal','completed','offline','task_id','heartbeatInterval','disconnect','catch','status','lifecycle_tracking','from_session','networkId','application/json','CommHub\x20rejected\x20task','slice','from_alias','fromAlias','failed','\x20from=','task.expired','pop','\x20network_id=','startsWith','to_alias','token','message','connectSSE','mcp_http','1468eKLHSW','send','inbox\x20error:\x20','2547768mnlpcM','send_task','task.send.failed','parent_task_id','connect','message_id','split','send_message','lifecycleTracking','match','AbortError','content','sending','2.0','text','error','\x20task_id=','sseAbort','task.send.start','Bearer\x20','<unknown>','\x20error=','delivered','body','576532qRRDyW','sdk','\x20transport=','duration_ms','tools/call','sdk-','replace','data:\x20','error_message','toAlias','network_id','heartbeatTimer','stringify','463947ZhJdeU','json','not_tracked','url','[REDACTED]','application/json,\x20text/event-stream','getReader','error_code','get_all_status','625gZiRNN','alias','read','parentTaskId','\x20to=','call','cwd','registered','task.send.delivered','parse','result',']\x20[commhub:','get_inbox','transport','SSE\x20failed:\x20','1843807cjsabx','POST','send_rejected','3475312hmBKvE','<pending>','report_status','connected','idle','disconnected','\x20parent_task_id=','name','50557VIRehd','s...','reconnectDelay','task','emit','messages','[commhub:task]\x20','signal','SSE\x20connected','resumeId','\x20duration_ms=','agent','reply','type','new_task','toString','log','server','send_reply','task.ack','running','decode','\x20lifecycle=','min'];a0_0x5789=function(){return _0x4858d4;};return a0_0x5789();}function N(_0x20e78f){const _0x4780a9=a0_0x1c3100;return(_0x20e78f instanceof Error?_0x20e78f[_0x4780a9(0x12a)]:String(_0x20e78f??'unknown\x20error'))[_0x4780a9(0xc9)](K,_0x4780a9(0xd4))[_0x4780a9(0xc9)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x4780a9(0x11f)](0x0,0xf0);}function O(_0x589f3a,_0x398f69=process.env.ANET_TASK_TRACE_FORMAT===a0_0x1c3100(0xd1)){const _0x3f8f88=a0_0x1c3100;if(_0x398f69)return JSON[_0x3f8f88(0xcf)](_0x589f3a);let _0xc975c0=L(_0x589f3a[_0x3f8f88(0x133)],_0x3f8f88(0x10d)),_0x4cbbbd=L(_0x589f3a[_0x3f8f88(0x115)],_0x3f8f88(0xec)),_0x322b5e=_0x589f3a[_0x3f8f88(0xd7)]?_0x3f8f88(0x145)+_0x589f3a['error_code']+':'+(_0x589f3a[_0x3f8f88(0xcb)]??''):'';return _0x3f8f88(0xf9)+_0x589f3a[_0x3f8f88(0x119)]+_0x3f8f88(0x123)+L(_0x589f3a[_0x3f8f88(0x120)],_0x3f8f88(0x144))+_0x3f8f88(0xdd)+L(_0x589f3a[_0x3f8f88(0x128)],_0x3f8f88(0x144))+_0x3f8f88(0x140)+_0x4cbbbd+_0x3f8f88(0xf1)+_0xc975c0+_0x3f8f88(0x126)+L(_0x589f3a[_0x3f8f88(0xcd)],_0x3f8f88(0x144))+_0x3f8f88(0xc5)+_0x589f3a[_0x3f8f88(0xe6)]+_0x3f8f88(0xfd)+_0x589f3a[_0x3f8f88(0xc6)]+_0x3f8f88(0x109)+_0x589f3a[_0x3f8f88(0x11a)]+_0x322b5e;}function U(_0x3677ed){const _0x5f4572=a0_0x1c3100;return{'event':{'sending':_0x5f4572(0x142),'delivered':_0x5f4572(0xe1),'failed':_0x5f4572(0x132),'acked':_0x5f4572(0x106),'started':'task.started','replied':'task.replied','expired':_0x5f4572(0x124)}[_0x3677ed['status']],..._0x3677ed};}function j(_0xfa14ec){const _0x83577d=a0_0x1c3100;let _0xf8ddf9=_0xfa14ec?.[_0x83577d(0x115)]||_0xfa14ec?.[_0x83577d(0x135)]||_0xfa14ec?.['id'];if(_0xf8ddf9)return String(_0xf8ddf9);let _0xaaec54=_0xfa14ec?.[_0x83577d(0x13b)]?.[0x0]?.[_0x83577d(0x13e)];if(typeof _0xaaec54!=='string')return null;try{let _0x117eb0=JSON['parse'](_0xaaec54);return _0x117eb0?.[_0x83577d(0x115)]||_0x117eb0?.[_0x83577d(0x135)]||_0x117eb0?.['id']||null;}catch{return null;}}async function X(_0x1e0063,_0x4691ed){const _0x2d9e86=a0_0x1c3100;let _0x504b50=_0x4691ed[_0x2d9e86(0x110)]??Date[_0x2d9e86(0x110)],_0x243495=_0x504b50(),_0xdf4216=(_0x34851c,_0x198ae1,_0x59a618,_0x73887d)=>{const _0x12a88d=_0x2d9e86;_0x4691ed['log'](O(U({'from_alias':_0x1e0063[_0x12a88d(0x121)],'to_alias':_0x1e0063[_0x12a88d(0xcc)],'task_id':_0x198ae1,'parent_task_id':_0x1e0063['parentTaskId'],'network_id':_0x1e0063['networkId'],'transport':_0x1e0063[_0x12a88d(0xe6)],'status':_0x34851c,'duration_ms':_0x504b50()-_0x243495,'lifecycle_tracking':_0x1e0063[_0x12a88d(0x138)],..._0x59a618!==void 0x0?{'error_code':_0x73887d||'send_failed','error_message':N(_0x59a618)}:{}})));};_0xdf4216(_0x2d9e86(0x13c),null);try{let _0x50f071=await _0x4691ed[_0x2d9e86(0x12e)](),_0x108eb4=j(_0x50f071);if(_0x108eb4)_0xdf4216(_0x2d9e86(0xc1),_0x108eb4);else{if(_0x50f071?.['ok']===!0x1||_0x50f071?.[_0x2d9e86(0x13f)])_0xdf4216(_0x2d9e86(0x122),_0x108eb4,_0x50f071?.[_0x2d9e86(0x13f)]||_0x2d9e86(0x11e),_0x2d9e86(0xea));else _0xdf4216('failed',null,'CommHub\x20response\x20omitted\x20task_id','missing_task_id');}return _0x50f071;}catch(_0x3a11d0){throw _0xdf4216(_0x2d9e86(0x122),null,_0x3a11d0,'send_failed'),_0x3a11d0;}}async function Y(_0x7b07b5,_0x21af6e){const _0x3ceadf=a0_0x1c3100;return X({'fromAlias':_0x7b07b5['fromAlias'],'toAlias':_0x7b07b5['alias'],'parentTaskId':_0x7b07b5[_0x3ceadf(0xdc)]||null,'networkId':_0x7b07b5[_0x3ceadf(0x11c)]||null,'transport':_0x3ceadf(0x12c),'lifecycleTracking':_0x3ceadf(0xd2)},_0x21af6e);}class $ extends a0_0x331c85{['url'];[a0_0x1c3100(0xda)];[a0_0x1c3100(0x129)];['agent'];[a0_0x1c3100(0xfc)];['heartbeatInterval'];['reconnectDelay'];[a0_0x1c3100(0xce)];[a0_0x1c3100(0x141)];[a0_0x1c3100(0x107)]=!0x1;constructor(_0x209b2f){const _0x14a580=a0_0x1c3100;super();if(this[_0x14a580(0xd3)]=_0x209b2f['url'][_0x14a580(0xc9)](/\/$/,''),this[_0x14a580(0xda)]=_0x209b2f[_0x14a580(0xda)],this[_0x14a580(0x129)]=_0x209b2f[_0x14a580(0x129)],this[_0x14a580(0xfe)]=_0x209b2f[_0x14a580(0xfe)]||_0x14a580(0xc4),this[_0x14a580(0xfc)]=_0x14a580(0xc8)+_0x209b2f[_0x14a580(0xda)]+'-'+Date[_0x14a580(0x110)]()[_0x14a580(0x102)](0x24),this['heartbeatInterval']=_0x209b2f[_0x14a580(0x116)]??0x2bf20,this['reconnectDelay']=_0x209b2f[_0x14a580(0xf5)]??0xbb8,_0x209b2f['autoConnect']!==!0x1)this[_0x14a580(0x134)]();}[a0_0x1c3100(0x103)](_0x52432a){const _0x223596=a0_0x1c3100;console[_0x223596(0x103)]('['+new Date()['toTimeString']()['slice'](0x0,0x8)+_0x223596(0xe4)+this[_0x223596(0xda)]+']\x20'+_0x52432a);}async['call'](_0xea36db,_0x409a65){const _0x2325a0=a0_0x1c3100;let _0x48060b={'Content-Type':_0x2325a0(0x11d),'Accept':_0x2325a0(0xd5)};if(this['token'])_0x48060b[_0x2325a0(0x10f)]=_0x2325a0(0x143)+this[_0x2325a0(0x129)];let _0x5ed30c=await(await fetch(this[_0x2325a0(0xd3)]+_0x2325a0(0x10b),{'method':_0x2325a0(0xe9),'headers':_0x48060b,'body':JSON[_0x2325a0(0xcf)]({'jsonrpc':_0x2325a0(0x13d),'id':Date[_0x2325a0(0x110)](),'method':_0x2325a0(0xc7),'params':{'name':_0xea36db,'arguments':_0x409a65}})}))[_0x2325a0(0x13e)](),_0x355ff6=_0x5ed30c[_0x2325a0(0x139)](/data: (.+)/),_0x231949=_0x355ff6?JSON['parse'](_0x355ff6[0x1]):JSON[_0x2325a0(0xe2)](_0x5ed30c),_0x1c42da=_0x231949?.[_0x2325a0(0xe3)]?.[_0x2325a0(0x13b)]?.[0x0]?.[_0x2325a0(0x13e)];return _0x1c42da?JSON[_0x2325a0(0xe2)](_0x1c42da):_0x231949;}async['connect'](){const _0x4c0f2b=a0_0x1c3100;if(this[_0x4c0f2b(0x107)])return;this[_0x4c0f2b(0x107)]=!0x0,await this[_0x4c0f2b(0x119)](_0x4c0f2b(0xef)),this[_0x4c0f2b(0x103)](_0x4c0f2b(0xe0)),this[_0x4c0f2b(0xce)]=setInterval(()=>{const _0x4489c2=_0x4c0f2b;this[_0x4489c2(0x119)](_0x4489c2(0xef))[_0x4489c2(0x118)](_0x54c48c=>this[_0x4489c2(0x103)]('heartbeat\x20failed:\x20'+_0x54c48c[_0x4489c2(0x12a)]));},this[_0x4c0f2b(0x116)]),this[_0x4c0f2b(0x12b)]();}async[a0_0x1c3100(0x117)](){const _0x301ffb=a0_0x1c3100;if(this['running']=!0x1,this[_0x301ffb(0x141)]?.['abort'](),this[_0x301ffb(0xce)])clearInterval(this[_0x301ffb(0xce)]);await this['status'](_0x301ffb(0x114))[_0x301ffb(0x118)](()=>{}),this['log']('disconnected');}async[a0_0x1c3100(0x12e)](_0x4539c3,_0xc64934,_0x1f4971=a0_0x1c3100(0x112)){const _0x3549f6=a0_0x1c3100;return Y({'alias':_0x4539c3,'fromAlias':this['alias']},{'log':_0x1615b2=>console[_0x3549f6(0x103)](_0x1615b2),'send':()=>this[_0x3549f6(0xde)](_0x3549f6(0x131),{'alias':_0x4539c3,'task':_0xc64934,'priority':_0x1f4971,'from_session':this['alias']})});}async[a0_0x1c3100(0x12a)](_0x411ea9,_0x2afdc8){const _0x1ebac3=a0_0x1c3100;return this[_0x1ebac3(0xde)](_0x1ebac3(0x137),{'alias':_0x411ea9,'message':_0x2afdc8,'from_session':this[_0x1ebac3(0xda)]});}async[a0_0x1c3100(0xff)](_0x119a94,_0x2d0d90,_0x221863=a0_0x1c3100(0x113)){const _0x13b8a9=a0_0x1c3100;return this['call'](_0x13b8a9(0x105),{'in_reply_to':_0x119a94,'text':_0x2d0d90,'status':_0x221863});}async[a0_0x1c3100(0x119)](_0x4c6cce,_0x1c0a29){const _0x29b8b7=a0_0x1c3100;return this[_0x29b8b7(0xde)](_0x29b8b7(0xed),{'resume_id':this[_0x29b8b7(0xfc)],'alias':this[_0x29b8b7(0xda)],'status':_0x4c6cce,'server':a0_0x177dc3(),'hostname':a0_0x177dc3(),'agent':this[_0x29b8b7(0xfe)],'project_dir':process[_0x29b8b7(0xdf)](),..._0x1c0a29});}async['getAllStatus'](){const _0x14553f=a0_0x1c3100;return this[_0x14553f(0xde)](_0x14553f(0xd8),{});}async[a0_0x1c3100(0x10c)](_0x265e96,_0x2f7fd2){const _0x8079b0=a0_0x1c3100;return this[_0x8079b0(0xde)]('broadcast',{'message':_0x265e96,'filter_server':_0x2f7fd2?.[_0x8079b0(0x104)],'filter_status':_0x2f7fd2?.[_0x8079b0(0x119)]});}async[a0_0x1c3100(0x12b)](){const _0x483b22=a0_0x1c3100;let _0x479980=encodeURIComponent(this[_0x483b22(0xda)]),_0x28f68e=this[_0x483b22(0xd3)]+'/events/'+_0x479980,_0x5c4d70=this['reconnectDelay'];while(this[_0x483b22(0x107)]){try{this[_0x483b22(0x141)]=new AbortController();let _0x3a1362={'Accept':'text/event-stream'};if(this[_0x483b22(0x129)])_0x3a1362[_0x483b22(0x10f)]=_0x483b22(0x143)+this[_0x483b22(0x129)];let _0x1f8809=await fetch(_0x28f68e,{'headers':_0x3a1362,'signal':this[_0x483b22(0x141)][_0x483b22(0xfa)]});if(!_0x1f8809['ok']||!_0x1f8809[_0x483b22(0xc2)]){this[_0x483b22(0x103)](_0x483b22(0xe7)+_0x1f8809[_0x483b22(0x119)]),await this[_0x483b22(0x111)](_0x5c4d70),_0x5c4d70=Math[_0x483b22(0x10a)](_0x5c4d70*1.5,0xea60);continue;}_0x5c4d70=this['reconnectDelay'];let _0xb333cf=_0x1f8809[_0x483b22(0xc2)][_0x483b22(0xd6)](),_0x28faba=new TextDecoder(),_0x32072b='';while(this[_0x483b22(0x107)]){let {done:_0x20141a,value:_0x26bd4f}=await _0xb333cf[_0x483b22(0xdb)]();if(_0x20141a)break;_0x32072b+=_0x28faba[_0x483b22(0x108)](_0x26bd4f,{'stream':!0x0});let _0x2b47c6=_0x32072b[_0x483b22(0x136)]('\x0a');_0x32072b=_0x2b47c6[_0x483b22(0x125)]()||'';for(let _0x202cb0 of _0x2b47c6){if(!_0x202cb0[_0x483b22(0x127)](_0x483b22(0xca)))continue;try{let _0x31ebb8=JSON[_0x483b22(0xe2)](_0x202cb0['slice'](0x6));if(_0x31ebb8[_0x483b22(0x100)]===_0x483b22(0xee)){this[_0x483b22(0x103)](_0x483b22(0xfb)),this[_0x483b22(0xf7)](_0x483b22(0xee));continue;}if(_0x31ebb8[_0x483b22(0x100)]===_0x483b22(0x101)||_0x31ebb8['type']==='new_message'||_0x31ebb8[_0x483b22(0x100)]==='broadcast')await this[_0x483b22(0x10e)]();}catch{}}}}catch(_0x42a17e){if(_0x42a17e[_0x483b22(0xf2)]===_0x483b22(0x13a))break;this[_0x483b22(0xf7)]('error',_0x42a17e),this[_0x483b22(0x103)]('SSE\x20error:\x20'+_0x42a17e[_0x483b22(0x12a)]);}if(this[_0x483b22(0x107)])this[_0x483b22(0xf7)](_0x483b22(0xf0)),this[_0x483b22(0x103)]('SSE\x20reconnecting\x20in\x20'+_0x5c4d70/0x3e8+_0x483b22(0xf4)),await this[_0x483b22(0x111)](_0x5c4d70),_0x5c4d70=Math['min'](_0x5c4d70*1.5,0xea60);}}async[a0_0x1c3100(0x10e)](){const _0x1b70e2=a0_0x1c3100;try{let _0x4725bf=(await this[_0x1b70e2(0xde)](_0x1b70e2(0xe5),{'alias':this[_0x1b70e2(0xda)],'limit':0xa}))?.[_0x1b70e2(0xf8)]||[];for(let _0x4e55bc of _0x4725bf)await this[_0x1b70e2(0xde)]('ack_inbox',{'alias':this['alias'],'message_id':_0x4e55bc['id']}),this[_0x1b70e2(0x103)]('←\x20'+_0x4e55bc[_0x1b70e2(0x11b)]+':\x20'+_0x4e55bc[_0x1b70e2(0x13b)][_0x1b70e2(0x11f)](0x0,0x3c)),this[_0x1b70e2(0xf7)](_0x1b70e2(0xf6),_0x4e55bc),this['emit'](_0x1b70e2(0x12a),_0x4e55bc);}catch(_0x290cfe){this[_0x1b70e2(0x103)](_0x1b70e2(0x12f)+_0x290cfe[_0x1b70e2(0x12a)]);}}[a0_0x1c3100(0x111)](_0x5056b6){return new Promise(_0x515b4a=>setTimeout(_0x515b4a,_0x5056b6));}}var F=$;export{F as default,$ as CommHub};