@sleep2agi/agent-network 2.3.0-preview.248 → 2.3.0-preview.249

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_0x24ce0c=a0_0x2688;(function(_0x507b64,_0x1f01e0){const _0x5a12a3=a0_0x2688,_0x3b70bd=_0x507b64();while(!![]){try{const _0x3772a9=parseInt(_0x5a12a3(0xd2))/0x1*(-parseInt(_0x5a12a3(0xd9))/0x2)+-parseInt(_0x5a12a3(0x121))/0x3+parseInt(_0x5a12a3(0x112))/0x4+-parseInt(_0x5a12a3(0xb7))/0x5*(-parseInt(_0x5a12a3(0xdc))/0x6)+parseInt(_0x5a12a3(0xe7))/0x7*(-parseInt(_0x5a12a3(0xef))/0x8)+-parseInt(_0x5a12a3(0xe6))/0x9*(-parseInt(_0x5a12a3(0x100))/0xa)+parseInt(_0x5a12a3(0xf6))/0xb*(parseInt(_0x5a12a3(0x12a))/0xc);if(_0x3772a9===_0x1f01e0)break;else _0x3b70bd['push'](_0x3b70bd['shift']());}catch(_0x48ea61){_0x3b70bd['push'](_0x3b70bd['shift']());}}}(a0_0x3b1f,0x5b46f));import{EventEmitter as a0_0x53906d}from'events';import{hostname as a0_0x1b9033}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x998b08,_0x19d243)=>(_0x998b08??_0x19d243)[a0_0x24ce0c(0x11d)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x2596b0){const _0xe66408=a0_0x24ce0c;return(_0x2596b0 instanceof Error?_0x2596b0['message']:String(_0x2596b0??_0xe66408(0xf9)))['replace'](K,_0xe66408(0x108))[_0xe66408(0x11d)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0xe66408(0xd4)](0x0,0xf0);}function O(_0x1701f3,_0x1f5b11=process.env.ANET_TASK_TRACE_FORMAT===a0_0x24ce0c(0xe0)){const _0x57b4f0=a0_0x24ce0c;if(_0x1f5b11)return JSON[_0x57b4f0(0xcf)](_0x1701f3);let _0x17ff30=L(_0x1701f3['parent_task_id'],_0x57b4f0(0xf0)),_0x4f56e9=L(_0x1701f3['task_id'],'<pending>'),_0x5c57d7=_0x1701f3[_0x57b4f0(0xdb)]?_0x57b4f0(0xe2)+_0x1701f3[_0x57b4f0(0xdb)]+':'+(_0x1701f3[_0x57b4f0(0x111)]??''):'';return _0x57b4f0(0xeb)+_0x1701f3[_0x57b4f0(0x11f)]+'\x20from='+L(_0x1701f3['from_alias'],_0x57b4f0(0xce))+_0x57b4f0(0xde)+L(_0x1701f3['to_alias'],_0x57b4f0(0xce))+_0x57b4f0(0xec)+_0x4f56e9+_0x57b4f0(0xee)+_0x17ff30+'\x20network_id='+L(_0x1701f3['network_id'],'<unknown>')+_0x57b4f0(0x10d)+_0x1701f3['transport']+'\x20duration_ms='+_0x1701f3[_0x57b4f0(0xc8)]+_0x57b4f0(0x117)+_0x1701f3[_0x57b4f0(0x120)]+_0x5c57d7;}function U(_0x38ed57){const _0x1550d2=a0_0x24ce0c;return{'event':{'sending':_0x1550d2(0xc2),'delivered':_0x1550d2(0xc3),'failed':'task.send.failed','acked':_0x1550d2(0xd3),'started':_0x1550d2(0x107),'replied':_0x1550d2(0xf4),'expired':'task.expired'}[_0x38ed57[_0x1550d2(0x11f)]],..._0x38ed57};}function a0_0x3b1f(){const _0x4a2d14=['disconnect','duration_ms','send_failed','POST','heartbeatTimer','delivered','sdk-','<unknown>','stringify','sseAbort','failed','409WoqLkL','task.ack','slice','messages','sending','connect','connected','1154sBFuIY','min','error_code','1987812TiABus','text','\x20to=','agent','json','SSE\x20connected','\x20error=','SSE\x20failed:\x20','type','Authorization','161613CJynvP','210266mNpOci','data:\x20','s...','message','[commhub:task]\x20','\x20task_id=','from_session','\x20parent_task_id=','16MxypBa','<missing>','toTimeString','message_id','result','task.replied','now','5709ndbAYt','broadcast','parentTaskId','unknown\x20error','name','application/json,\x20text/event-stream','string','body','CommHub\x20rejected\x20task','application/json','190HfqgvW','parse','processInbox','catch','emit','error','sleep','task.started','[REDACTED]','SSE\x20reconnecting\x20in\x20','AbortError','missing_task_id','url','\x20transport=','idle','send_task','getAllStatus','error_message','1683172TmspYS','inbox\x20error:\x20','server','new_message','send_reply','\x20lifecycle=','task_id','token','decode','getReader','sdk','replace','ack_inbox','status','lifecycle_tracking','2025159ufpDzX','report_status','networkId','reconnectDelay','connectSSE','lifecycleTracking','fromAlias','Bearer\x20','CommHub\x20response\x20omitted\x20task_id','5820LZQoMY','offline','split','autoConnect','alias','pop','disconnected','send_rejected','/mcp','send','5QIbMbL','log','startsWith','read','normal','heartbeatInterval','running','reply','match','tools/call','not_tracked','task.send.start','task.send.delivered','content','resumeId','call'];a0_0x3b1f=function(){return _0x4a2d14;};return a0_0x3b1f();}function j(_0x109efb){const _0x453e5d=a0_0x24ce0c;let _0x1bb8a1=_0x109efb?.[_0x453e5d(0x118)]||_0x109efb?.[_0x453e5d(0xf2)]||_0x109efb?.['id'];if(_0x1bb8a1)return String(_0x1bb8a1);let _0x51825d=_0x109efb?.[_0x453e5d(0xc4)]?.[0x0]?.['text'];if(typeof _0x51825d!==_0x453e5d(0xfc))return null;try{let _0x41a48a=JSON[_0x453e5d(0x101)](_0x51825d);return _0x41a48a?.[_0x453e5d(0x118)]||_0x41a48a?.[_0x453e5d(0xf2)]||_0x41a48a?.['id']||null;}catch{return null;}}async function X(_0x6ad33a,_0x1184aa){const _0x29f13b=a0_0x24ce0c;let _0x10a24d=_0x1184aa[_0x29f13b(0xf5)]??Date[_0x29f13b(0xf5)],_0x1153fa=_0x10a24d(),_0x115425=(_0xeebe10,_0x87d9cc,_0x568519,_0xf72e34)=>{const _0x14328c=_0x29f13b;_0x1184aa[_0x14328c(0xb8)](O(U({'from_alias':_0x6ad33a[_0x14328c(0x127)],'to_alias':_0x6ad33a['toAlias'],'task_id':_0x87d9cc,'parent_task_id':_0x6ad33a[_0x14328c(0xf8)],'network_id':_0x6ad33a['networkId'],'transport':_0x6ad33a['transport'],'status':_0xeebe10,'duration_ms':_0x10a24d()-_0x1153fa,'lifecycle_tracking':_0x6ad33a[_0x14328c(0x126)],..._0x568519!==void 0x0?{'error_code':_0xf72e34||_0x14328c(0xc9),'error_message':N(_0x568519)}:{}})));};_0x115425(_0x29f13b(0xd6),null);try{let _0x73efc6=await _0x1184aa[_0x29f13b(0xb6)](),_0x333b04=j(_0x73efc6);if(_0x333b04)_0x115425(_0x29f13b(0xcc),_0x333b04);else{if(_0x73efc6?.['ok']===!0x1||_0x73efc6?.[_0x29f13b(0x105)])_0x115425('failed',_0x333b04,_0x73efc6?.[_0x29f13b(0x105)]||_0x29f13b(0xfe),_0x29f13b(0xb4));else _0x115425(_0x29f13b(0xd1),null,_0x29f13b(0x129),_0x29f13b(0x10b));}return _0x73efc6;}catch(_0x494259){throw _0x115425(_0x29f13b(0xd1),null,_0x494259,_0x29f13b(0xc9)),_0x494259;}}async function Y(_0x286109,_0x53005c){const _0x1c3cb0=a0_0x24ce0c;return X({'fromAlias':_0x286109[_0x1c3cb0(0x127)],'toAlias':_0x286109[_0x1c3cb0(0x12e)],'parentTaskId':_0x286109[_0x1c3cb0(0xf8)]||null,'networkId':_0x286109[_0x1c3cb0(0x123)]||null,'transport':'mcp_http','lifecycleTracking':_0x1c3cb0(0xc1)},_0x53005c);}class $ extends a0_0x53906d{[a0_0x24ce0c(0x10c)];['alias'];['token'];[a0_0x24ce0c(0xdf)];[a0_0x24ce0c(0xc5)];[a0_0x24ce0c(0xbc)];['reconnectDelay'];['heartbeatTimer'];[a0_0x24ce0c(0xd0)];['running']=!0x1;constructor(_0x281489){const _0x57d936=a0_0x24ce0c;super();if(this['url']=_0x281489[_0x57d936(0x10c)][_0x57d936(0x11d)](/\/$/,''),this[_0x57d936(0x12e)]=_0x281489[_0x57d936(0x12e)],this[_0x57d936(0x119)]=_0x281489['token'],this[_0x57d936(0xdf)]=_0x281489[_0x57d936(0xdf)]||_0x57d936(0x11c),this[_0x57d936(0xc5)]=_0x57d936(0xcd)+_0x281489['alias']+'-'+Date['now']()['toString'](0x24),this[_0x57d936(0xbc)]=_0x281489[_0x57d936(0xbc)]??0x2bf20,this[_0x57d936(0x124)]=_0x281489['reconnectDelay']??0xbb8,_0x281489[_0x57d936(0x12d)]!==!0x1)this['connect']();}[a0_0x24ce0c(0xb8)](_0xdc4580){const _0x33b971=a0_0x24ce0c;console[_0x33b971(0xb8)]('['+new Date()[_0x33b971(0xf1)]()[_0x33b971(0xd4)](0x0,0x8)+']\x20[commhub:'+this['alias']+']\x20'+_0xdc4580);}async[a0_0x24ce0c(0xc6)](_0x550f15,_0x1a8238){const _0xf66c21=a0_0x24ce0c;let _0x5b9c0d={'Content-Type':_0xf66c21(0xff),'Accept':_0xf66c21(0xfb)};if(this[_0xf66c21(0x119)])_0x5b9c0d[_0xf66c21(0xe5)]='Bearer\x20'+this[_0xf66c21(0x119)];let _0x145109=await(await fetch(this[_0xf66c21(0x10c)]+_0xf66c21(0xb5),{'method':_0xf66c21(0xca),'headers':_0x5b9c0d,'body':JSON['stringify']({'jsonrpc':'2.0','id':Date['now'](),'method':_0xf66c21(0xc0),'params':{'name':_0x550f15,'arguments':_0x1a8238}})}))[_0xf66c21(0xdd)](),_0x2b555d=_0x145109[_0xf66c21(0xbf)](/data: (.+)/),_0x213f8a=_0x2b555d?JSON['parse'](_0x2b555d[0x1]):JSON[_0xf66c21(0x101)](_0x145109),_0x2a3fe4=_0x213f8a?.[_0xf66c21(0xf3)]?.[_0xf66c21(0xc4)]?.[0x0]?.['text'];return _0x2a3fe4?JSON[_0xf66c21(0x101)](_0x2a3fe4):_0x213f8a;}async[a0_0x24ce0c(0xd7)](){const _0x3cedbb=a0_0x24ce0c;if(this['running'])return;this[_0x3cedbb(0xbd)]=!0x0,await this[_0x3cedbb(0x11f)](_0x3cedbb(0x10e)),this['log']('registered'),this['heartbeatTimer']=setInterval(()=>{const _0x5db44c=_0x3cedbb;this['status'](_0x5db44c(0x10e))[_0x5db44c(0x103)](_0x3c629a=>this['log']('heartbeat\x20failed:\x20'+_0x3c629a['message']));},this[_0x3cedbb(0xbc)]),this[_0x3cedbb(0x125)]();}async[a0_0x24ce0c(0xc7)](){const _0x2f4827=a0_0x24ce0c;if(this['running']=!0x1,this[_0x2f4827(0xd0)]?.['abort'](),this[_0x2f4827(0xcb)])clearInterval(this[_0x2f4827(0xcb)]);await this[_0x2f4827(0x11f)](_0x2f4827(0x12b))[_0x2f4827(0x103)](()=>{}),this[_0x2f4827(0xb8)](_0x2f4827(0xb3));}async['send'](_0x576b35,_0x3d3bbe,_0x19b667=a0_0x24ce0c(0xbb)){const _0x718fc5=a0_0x24ce0c;return Y({'alias':_0x576b35,'fromAlias':this[_0x718fc5(0x12e)]},{'log':_0x2ff1b2=>console[_0x718fc5(0xb8)](_0x2ff1b2),'send':()=>this[_0x718fc5(0xc6)](_0x718fc5(0x10f),{'alias':_0x576b35,'task':_0x3d3bbe,'priority':_0x19b667,'from_session':this['alias']})});}async['message'](_0x9bd713,_0x283ca1){const _0x3c10ca=a0_0x24ce0c;return this[_0x3c10ca(0xc6)]('send_message',{'alias':_0x9bd713,'message':_0x283ca1,'from_session':this['alias']});}async[a0_0x24ce0c(0xbe)](_0x5c3f87,_0x5960fc,_0xb25af5='completed'){const _0x108618=a0_0x24ce0c;return this['call'](_0x108618(0x116),{'in_reply_to':_0x5c3f87,'text':_0x5960fc,'status':_0xb25af5});}async[a0_0x24ce0c(0x11f)](_0x1fe71f,_0x321f5e){const _0xa79b47=a0_0x24ce0c;return this['call'](_0xa79b47(0x122),{'resume_id':this[_0xa79b47(0xc5)],'alias':this['alias'],'status':_0x1fe71f,'server':a0_0x1b9033(),'hostname':a0_0x1b9033(),'agent':this[_0xa79b47(0xdf)],'project_dir':process['cwd'](),..._0x321f5e});}async[a0_0x24ce0c(0x110)](){const _0x5e47b3=a0_0x24ce0c;return this[_0x5e47b3(0xc6)]('get_all_status',{});}async[a0_0x24ce0c(0xf7)](_0x19b00b,_0xc59fd9){const _0x99ee3b=a0_0x24ce0c;return this['call'](_0x99ee3b(0xf7),{'message':_0x19b00b,'filter_server':_0xc59fd9?.[_0x99ee3b(0x114)],'filter_status':_0xc59fd9?.[_0x99ee3b(0x11f)]});}async[a0_0x24ce0c(0x125)](){const _0x54811e=a0_0x24ce0c;let _0x49a6ed=encodeURIComponent(this['alias']),_0x1dfa4f=this[_0x54811e(0x10c)]+'/events/'+_0x49a6ed,_0x4b1406=this[_0x54811e(0x124)];while(this[_0x54811e(0xbd)]){try{this[_0x54811e(0xd0)]=new AbortController();let _0x22f972={'Accept':'text/event-stream'};if(this[_0x54811e(0x119)])_0x22f972[_0x54811e(0xe5)]=_0x54811e(0x128)+this[_0x54811e(0x119)];let _0x1449bc=await fetch(_0x1dfa4f,{'headers':_0x22f972,'signal':this[_0x54811e(0xd0)]['signal']});if(!_0x1449bc['ok']||!_0x1449bc[_0x54811e(0xfd)]){this[_0x54811e(0xb8)](_0x54811e(0xe3)+_0x1449bc[_0x54811e(0x11f)]),await this[_0x54811e(0x106)](_0x4b1406),_0x4b1406=Math['min'](_0x4b1406*1.5,0xea60);continue;}_0x4b1406=this['reconnectDelay'];let _0x5dfc88=_0x1449bc['body'][_0x54811e(0x11b)](),_0x21dd6d=new TextDecoder(),_0x23e658='';while(this[_0x54811e(0xbd)]){let {done:_0x2a5289,value:_0x1819f5}=await _0x5dfc88[_0x54811e(0xba)]();if(_0x2a5289)break;_0x23e658+=_0x21dd6d[_0x54811e(0x11a)](_0x1819f5,{'stream':!0x0});let _0x53deb2=_0x23e658[_0x54811e(0x12c)]('\x0a');_0x23e658=_0x53deb2[_0x54811e(0x12f)]()||'';for(let _0x1ad8e8 of _0x53deb2){if(!_0x1ad8e8[_0x54811e(0xb9)](_0x54811e(0xe8)))continue;try{let _0x5b8f58=JSON[_0x54811e(0x101)](_0x1ad8e8[_0x54811e(0xd4)](0x6));if(_0x5b8f58[_0x54811e(0xe4)]===_0x54811e(0xd8)){this[_0x54811e(0xb8)](_0x54811e(0xe1)),this[_0x54811e(0x104)](_0x54811e(0xd8));continue;}if(_0x5b8f58[_0x54811e(0xe4)]==='new_task'||_0x5b8f58[_0x54811e(0xe4)]===_0x54811e(0x115)||_0x5b8f58[_0x54811e(0xe4)]===_0x54811e(0xf7))await this[_0x54811e(0x102)]();}catch{}}}}catch(_0x40701f){if(_0x40701f[_0x54811e(0xfa)]===_0x54811e(0x10a))break;this[_0x54811e(0x104)]('error',_0x40701f),this[_0x54811e(0xb8)]('SSE\x20error:\x20'+_0x40701f['message']);}if(this[_0x54811e(0xbd)])this[_0x54811e(0x104)](_0x54811e(0xb3)),this['log'](_0x54811e(0x109)+_0x4b1406/0x3e8+_0x54811e(0xe9)),await this[_0x54811e(0x106)](_0x4b1406),_0x4b1406=Math[_0x54811e(0xda)](_0x4b1406*1.5,0xea60);}}async['processInbox'](){const _0x478efa=a0_0x24ce0c;try{let _0x2229c4=(await this['call']('get_inbox',{'alias':this['alias'],'limit':0xa}))?.[_0x478efa(0xd5)]||[];for(let _0x431175 of _0x2229c4)await this[_0x478efa(0xc6)](_0x478efa(0x11e),{'alias':this[_0x478efa(0x12e)],'message_id':_0x431175['id']}),this['log']('←\x20'+_0x431175[_0x478efa(0xed)]+':\x20'+_0x431175['content'][_0x478efa(0xd4)](0x0,0x3c)),this[_0x478efa(0x104)]('task',_0x431175),this[_0x478efa(0x104)]('message',_0x431175);}catch(_0x3c1186){this[_0x478efa(0xb8)](_0x478efa(0x113)+_0x3c1186[_0x478efa(0xea)]);}}[a0_0x24ce0c(0x106)](_0x5ae567){return new Promise(_0x520f4e=>setTimeout(_0x520f4e,_0x5ae567));}}var F=$;function a0_0x2688(_0x50cf8d,_0x54c882){_0x50cf8d=_0x50cf8d-0xb3;const _0x3b1f68=a0_0x3b1f();let _0x268842=_0x3b1f68[_0x50cf8d];return _0x268842;}export{F as default,$ as CommHub};
1
+ const a0_0x2ec609=a0_0x3533;(function(_0x42990b,_0x4c1cac){const _0x474c04=a0_0x3533,_0x21ac8a=_0x42990b();while(!![]){try{const _0x36601a=parseInt(_0x474c04(0x171))/0x1*(-parseInt(_0x474c04(0x17b))/0x2)+-parseInt(_0x474c04(0x18f))/0x3+-parseInt(_0x474c04(0x1c4))/0x4*(parseInt(_0x474c04(0x16c))/0x5)+-parseInt(_0x474c04(0x16f))/0x6*(parseInt(_0x474c04(0x191))/0x7)+-parseInt(_0x474c04(0x19b))/0x8*(parseInt(_0x474c04(0x15d))/0x9)+-parseInt(_0x474c04(0x1c5))/0xa*(-parseInt(_0x474c04(0x15f))/0xb)+-parseInt(_0x474c04(0x193))/0xc*(-parseInt(_0x474c04(0x15e))/0xd);if(_0x36601a===_0x4c1cac)break;else _0x21ac8a['push'](_0x21ac8a['shift']());}catch(_0x4c4dbe){_0x21ac8a['push'](_0x21ac8a['shift']());}}}(a0_0x2846,0xb7327));import{EventEmitter as a0_0x7d32ca}from'events';import{hostname as a0_0x1457cd}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x58526d,_0x60561c)=>(_0x58526d??_0x60561c)[a0_0x2ec609(0x175)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x2ec609(0x194)](0x0,0xf0);function N(_0x6f7bce){const _0x135ece=a0_0x2ec609;return(_0x6f7bce instanceof Error?_0x6f7bce[_0x135ece(0x1b2)]:String(_0x6f7bce??_0x135ece(0x16a)))[_0x135ece(0x175)](K,_0x135ece(0x19d))[_0x135ece(0x175)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x135ece(0x194)](0x0,0xf0);}function O(_0x12bf1b,_0x46ba3d=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0xbd8f48=a0_0x2ec609;if(_0x46ba3d)return JSON[_0xbd8f48(0x1b1)](_0x12bf1b);let _0x460353=L(_0x12bf1b[_0xbd8f48(0x196)],_0xbd8f48(0x1a7)),_0x1e65a7=L(_0x12bf1b[_0xbd8f48(0x1bc)],_0xbd8f48(0x169)),_0x3a658b=_0x12bf1b['error_code']?_0xbd8f48(0x1b3)+_0x12bf1b[_0xbd8f48(0x1b4)]+':'+(_0x12bf1b['error_message']??''):'';return'[commhub:task]\x20'+_0x12bf1b[_0xbd8f48(0x165)]+_0xbd8f48(0x162)+L(_0x12bf1b[_0xbd8f48(0x1d1)],_0xbd8f48(0x17d))+'\x20to='+L(_0x12bf1b[_0xbd8f48(0x176)],_0xbd8f48(0x17d))+_0xbd8f48(0x164)+_0x1e65a7+_0xbd8f48(0x190)+_0x460353+'\x20network_id='+L(_0x12bf1b[_0xbd8f48(0x17a)],_0xbd8f48(0x17d))+_0xbd8f48(0x1d4)+_0x12bf1b[_0xbd8f48(0x1a6)]+'\x20duration_ms='+_0x12bf1b[_0xbd8f48(0x189)]+_0xbd8f48(0x188)+_0x12bf1b[_0xbd8f48(0x19a)]+_0x3a658b;}function a0_0x3533(_0x5e2849,_0x4509a1){_0x5e2849=_0x5e2849-0x15d;const _0x28462c=a0_0x2846();let _0x353377=_0x28462c[_0x5e2849];return _0x353377;}function a0_0x2846(){const _0x49485f=['report_status','body','\x20lifecycle=','duration_ms','AbortError','inbox\x20error:\x20','/events/','error','getReader','1867203CrvSnA','\x20parent_task_id=','14RoLFII','toString','17895972UprLkV','slice','running','parent_task_id','reconnectDelay','connect','getAllStatus','lifecycle_tracking','296uJdAti','text/event-stream','[REDACTED]','connectSSE','missing_task_id','normal','task.ack','fromAlias','failed','idle','sseAbort','transport','<missing>','resumeId','agent','decode','abort','message_id','task.send.start','alias','POST','parse','stringify','message','\x20error=','error_code','disconnect','token','broadcast','sending','application/json,\x20text/event-stream','SSE\x20connected','type','task_id','split','lifecycleTracking','heartbeatInterval','content','SSE\x20failed:\x20','task.expired','task.replied','56rLTMiq','36620AkTXCC','pop','from_session','heartbeatTimer','new_message','catch','connected','send','get_inbox','Authorization','result','call','from_alias','name','/mcp','\x20transport=',']\x20[commhub:','new_task','not_tracked','get_all_status','completed','parentTaskId','Bearer\x20','toTimeString','url','send_failed','networkId','toAlias','processInbox','99603mwbkNv','39QMWMsL','913hHDMvm','sdk-','startsWith','\x20from=','cwd','\x20task_id=','status','SSE\x20reconnecting\x20in\x20','send_rejected','server','<pending>','unknown\x20error','heartbeat\x20failed:\x20','358580xUEXAN','SSE\x20error:\x20','text','3165384ihKjZR','task.send.failed','936532lvHRya','sleep','sdk','match','replace','to_alias','CommHub\x20rejected\x20task','min','log','network_id','2IHqJys','send_message','<unknown>','s...','messages','emit','task.started','2.0','send_reply','string','now'];a0_0x2846=function(){return _0x49485f;};return a0_0x2846();}function U(_0x51661e){const _0x24755e=a0_0x2ec609;return{'event':{'sending':_0x24755e(0x1ad),'delivered':'task.send.delivered','failed':_0x24755e(0x170),'acked':_0x24755e(0x1a1),'started':_0x24755e(0x181),'replied':_0x24755e(0x1c3),'expired':_0x24755e(0x1c2)}[_0x51661e[_0x24755e(0x165)]],..._0x51661e};}function j(_0x1947e5){const _0x215c1b=a0_0x2ec609;let _0x5b85cc=_0x1947e5?.[_0x215c1b(0x1bc)]||_0x1947e5?.[_0x215c1b(0x1ac)]||_0x1947e5?.['id'];if(_0x5b85cc)return String(_0x5b85cc);let _0xa67317=_0x1947e5?.[_0x215c1b(0x1c0)]?.[0x0]?.[_0x215c1b(0x16e)];if(typeof _0xa67317!==_0x215c1b(0x184))return null;try{let _0x3ed6ba=JSON[_0x215c1b(0x1b0)](_0xa67317);return _0x3ed6ba?.[_0x215c1b(0x1bc)]||_0x3ed6ba?.[_0x215c1b(0x1ac)]||_0x3ed6ba?.['id']||null;}catch{return null;}}async function X(_0x21b83d,_0x28541f){const _0x3dc579=a0_0x2ec609;let _0x8e4b01=_0x28541f[_0x3dc579(0x185)]??Date[_0x3dc579(0x185)],_0x47299a=_0x8e4b01(),_0x3561e6=(_0x2a92b3,_0x16db81,_0x4dff25,_0x5508f8)=>{const _0x2a13da=_0x3dc579;_0x28541f[_0x2a13da(0x179)](O(U({'from_alias':_0x21b83d[_0x2a13da(0x1a2)],'to_alias':_0x21b83d[_0x2a13da(0x1e0)],'task_id':_0x16db81,'parent_task_id':_0x21b83d[_0x2a13da(0x1da)],'network_id':_0x21b83d[_0x2a13da(0x1df)],'transport':_0x21b83d['transport'],'status':_0x2a92b3,'duration_ms':_0x8e4b01()-_0x47299a,'lifecycle_tracking':_0x21b83d[_0x2a13da(0x1be)],..._0x4dff25!==void 0x0?{'error_code':_0x5508f8||_0x2a13da(0x1de),'error_message':N(_0x4dff25)}:{}})));};_0x3561e6(_0x3dc579(0x1b8),null);try{let _0xfb7663=await _0x28541f[_0x3dc579(0x1cc)](),_0x4d3cf3=j(_0xfb7663);if(_0x4d3cf3)_0x3561e6('delivered',_0x4d3cf3);else{if(_0xfb7663?.['ok']===!0x1||_0xfb7663?.[_0x3dc579(0x18d)])_0x3561e6('failed',_0x4d3cf3,_0xfb7663?.[_0x3dc579(0x18d)]||_0x3dc579(0x177),_0x3dc579(0x167));else _0x3561e6(_0x3dc579(0x1a3),null,'CommHub\x20response\x20omitted\x20task_id',_0x3dc579(0x19f));}return _0xfb7663;}catch(_0xb940a6){throw _0x3561e6(_0x3dc579(0x1a3),null,_0xb940a6,_0x3dc579(0x1de)),_0xb940a6;}}async function Y(_0x2326b2,_0x28b8a4){const _0x48251b=a0_0x2ec609;return X({'fromAlias':_0x2326b2[_0x48251b(0x1a2)],'toAlias':_0x2326b2[_0x48251b(0x1ae)],'parentTaskId':_0x2326b2[_0x48251b(0x1da)]||null,'networkId':_0x2326b2[_0x48251b(0x1df)]||null,'transport':'mcp_http','lifecycleTracking':_0x48251b(0x1d7)},_0x28b8a4);}class $ extends a0_0x7d32ca{['url'];['alias'];[a0_0x2ec609(0x1b6)];['agent'];['resumeId'];[a0_0x2ec609(0x1bf)];[a0_0x2ec609(0x197)];[a0_0x2ec609(0x1c8)];['sseAbort'];[a0_0x2ec609(0x195)]=!0x1;constructor(_0x1962cc){const _0x7574f6=a0_0x2ec609;super();if(this[_0x7574f6(0x1dd)]=_0x1962cc[_0x7574f6(0x1dd)]['replace'](/\/$/,''),this[_0x7574f6(0x1ae)]=_0x1962cc[_0x7574f6(0x1ae)],this[_0x7574f6(0x1b6)]=_0x1962cc[_0x7574f6(0x1b6)],this['agent']=_0x1962cc[_0x7574f6(0x1a9)]||_0x7574f6(0x173),this['resumeId']=_0x7574f6(0x160)+_0x1962cc['alias']+'-'+Date[_0x7574f6(0x185)]()[_0x7574f6(0x192)](0x24),this[_0x7574f6(0x1bf)]=_0x1962cc['heartbeatInterval']??0x2bf20,this[_0x7574f6(0x197)]=_0x1962cc[_0x7574f6(0x197)]??0xbb8,_0x1962cc['autoConnect']!==!0x1)this['connect']();}[a0_0x2ec609(0x179)](_0x1690c2){const _0x44071a=a0_0x2ec609;console['log']('['+new Date()[_0x44071a(0x1dc)]()['slice'](0x0,0x8)+_0x44071a(0x1d5)+this[_0x44071a(0x1ae)]+']\x20'+_0x1690c2);}async['call'](_0x29db23,_0x35ce29){const _0x2086e5=a0_0x2ec609;let _0x274931={'Content-Type':'application/json','Accept':_0x2086e5(0x1b9)};if(this['token'])_0x274931['Authorization']=_0x2086e5(0x1db)+this[_0x2086e5(0x1b6)];let _0x293fe6=await(await fetch(this[_0x2086e5(0x1dd)]+_0x2086e5(0x1d3),{'method':_0x2086e5(0x1af),'headers':_0x274931,'body':JSON['stringify']({'jsonrpc':_0x2086e5(0x182),'id':Date[_0x2086e5(0x185)](),'method':'tools/call','params':{'name':_0x29db23,'arguments':_0x35ce29}})}))[_0x2086e5(0x16e)](),_0x2b21d3=_0x293fe6[_0x2086e5(0x174)](/data: (.+)/),_0x516809=_0x2b21d3?JSON[_0x2086e5(0x1b0)](_0x2b21d3[0x1]):JSON[_0x2086e5(0x1b0)](_0x293fe6),_0x4a010d=_0x516809?.[_0x2086e5(0x1cf)]?.[_0x2086e5(0x1c0)]?.[0x0]?.[_0x2086e5(0x16e)];return _0x4a010d?JSON['parse'](_0x4a010d):_0x516809;}async[a0_0x2ec609(0x198)](){const _0x4782a3=a0_0x2ec609;if(this[_0x4782a3(0x195)])return;this[_0x4782a3(0x195)]=!0x0,await this[_0x4782a3(0x165)]('idle'),this['log']('registered'),this[_0x4782a3(0x1c8)]=setInterval(()=>{const _0x423ef6=_0x4782a3;this[_0x423ef6(0x165)](_0x423ef6(0x1a4))[_0x423ef6(0x1ca)](_0x3641d0=>this[_0x423ef6(0x179)](_0x423ef6(0x16b)+_0x3641d0[_0x423ef6(0x1b2)]));},this['heartbeatInterval']),this[_0x4782a3(0x19e)]();}async[a0_0x2ec609(0x1b5)](){const _0x1c09f0=a0_0x2ec609;if(this['running']=!0x1,this[_0x1c09f0(0x1a5)]?.[_0x1c09f0(0x1ab)](),this['heartbeatTimer'])clearInterval(this['heartbeatTimer']);await this[_0x1c09f0(0x165)]('offline')[_0x1c09f0(0x1ca)](()=>{}),this[_0x1c09f0(0x179)]('disconnected');}async[a0_0x2ec609(0x1cc)](_0x1a19fa,_0x75e7ad,_0x1021c2=a0_0x2ec609(0x1a0)){const _0x3d6ca6=a0_0x2ec609;return Y({'alias':_0x1a19fa,'fromAlias':this['alias']},{'log':_0x2687d4=>console['log'](_0x2687d4),'send':()=>this[_0x3d6ca6(0x1d0)]('send_task',{'alias':_0x1a19fa,'task':_0x75e7ad,'priority':_0x1021c2,'from_session':this[_0x3d6ca6(0x1ae)]})});}async[a0_0x2ec609(0x1b2)](_0x10e725,_0xcfb502){const _0x353810=a0_0x2ec609;return this[_0x353810(0x1d0)](_0x353810(0x17c),{'alias':_0x10e725,'message':_0xcfb502,'from_session':this[_0x353810(0x1ae)]});}async['reply'](_0x4d1e93,_0x2fc79c,_0x3d548e=a0_0x2ec609(0x1d9)){const _0x24e1d7=a0_0x2ec609;return this[_0x24e1d7(0x1d0)](_0x24e1d7(0x183),{'in_reply_to':_0x4d1e93,'text':_0x2fc79c,'status':_0x3d548e});}async[a0_0x2ec609(0x165)](_0x38faa8,_0x2b01f3){const _0x4ab9b4=a0_0x2ec609;return this[_0x4ab9b4(0x1d0)](_0x4ab9b4(0x186),{'resume_id':this[_0x4ab9b4(0x1a8)],'alias':this[_0x4ab9b4(0x1ae)],'status':_0x38faa8,'server':a0_0x1457cd(),'hostname':a0_0x1457cd(),'agent':this['agent'],'project_dir':process[_0x4ab9b4(0x163)](),..._0x2b01f3});}async[a0_0x2ec609(0x199)](){const _0x14fd40=a0_0x2ec609;return this[_0x14fd40(0x1d0)](_0x14fd40(0x1d8),{});}async[a0_0x2ec609(0x1b7)](_0x5a6b22,_0x1a8ba9){const _0x2356be=a0_0x2ec609;return this[_0x2356be(0x1d0)](_0x2356be(0x1b7),{'message':_0x5a6b22,'filter_server':_0x1a8ba9?.[_0x2356be(0x168)],'filter_status':_0x1a8ba9?.[_0x2356be(0x165)]});}async[a0_0x2ec609(0x19e)](){const _0x582433=a0_0x2ec609;let _0x494fc1=encodeURIComponent(this[_0x582433(0x1ae)]),_0x3b9d61=this[_0x582433(0x1dd)]+_0x582433(0x18c)+_0x494fc1,_0x175ba7=this[_0x582433(0x197)];while(this[_0x582433(0x195)]){try{this['sseAbort']=new AbortController();let _0x5b3c60={'Accept':_0x582433(0x19c)};if(this[_0x582433(0x1b6)])_0x5b3c60[_0x582433(0x1ce)]=_0x582433(0x1db)+this[_0x582433(0x1b6)];let _0xfad4a8=await fetch(_0x3b9d61,{'headers':_0x5b3c60,'signal':this[_0x582433(0x1a5)]['signal']});if(!_0xfad4a8['ok']||!_0xfad4a8[_0x582433(0x187)]){this[_0x582433(0x179)](_0x582433(0x1c1)+_0xfad4a8[_0x582433(0x165)]),await this[_0x582433(0x172)](_0x175ba7),_0x175ba7=Math[_0x582433(0x178)](_0x175ba7*1.5,0xea60);continue;}_0x175ba7=this[_0x582433(0x197)];let _0x57de8f=_0xfad4a8[_0x582433(0x187)][_0x582433(0x18e)](),_0x150436=new TextDecoder(),_0x381b1f='';while(this[_0x582433(0x195)]){let {done:_0x3643db,value:_0x1a9a98}=await _0x57de8f['read']();if(_0x3643db)break;_0x381b1f+=_0x150436[_0x582433(0x1aa)](_0x1a9a98,{'stream':!0x0});let _0x46ac26=_0x381b1f[_0x582433(0x1bd)]('\x0a');_0x381b1f=_0x46ac26[_0x582433(0x1c6)]()||'';for(let _0x45f28b of _0x46ac26){if(!_0x45f28b[_0x582433(0x161)]('data:\x20'))continue;try{let _0x2cdb80=JSON['parse'](_0x45f28b['slice'](0x6));if(_0x2cdb80[_0x582433(0x1bb)]===_0x582433(0x1cb)){this[_0x582433(0x179)](_0x582433(0x1ba)),this[_0x582433(0x180)](_0x582433(0x1cb));continue;}if(_0x2cdb80['type']===_0x582433(0x1d6)||_0x2cdb80[_0x582433(0x1bb)]===_0x582433(0x1c9)||_0x2cdb80[_0x582433(0x1bb)]===_0x582433(0x1b7))await this[_0x582433(0x1e1)]();}catch{}}}}catch(_0x65a4a9){if(_0x65a4a9[_0x582433(0x1d2)]===_0x582433(0x18a))break;this[_0x582433(0x180)](_0x582433(0x18d),_0x65a4a9),this[_0x582433(0x179)](_0x582433(0x16d)+_0x65a4a9[_0x582433(0x1b2)]);}if(this[_0x582433(0x195)])this[_0x582433(0x180)]('disconnected'),this[_0x582433(0x179)](_0x582433(0x166)+_0x175ba7/0x3e8+_0x582433(0x17e)),await this[_0x582433(0x172)](_0x175ba7),_0x175ba7=Math[_0x582433(0x178)](_0x175ba7*1.5,0xea60);}}async[a0_0x2ec609(0x1e1)](){const _0xb4938d=a0_0x2ec609;try{let _0x33f64f=(await this[_0xb4938d(0x1d0)](_0xb4938d(0x1cd),{'alias':this['alias'],'limit':0xa}))?.[_0xb4938d(0x17f)]||[];for(let _0x53e870 of _0x33f64f)await this['call']('ack_inbox',{'alias':this[_0xb4938d(0x1ae)],'message_id':_0x53e870['id']}),this[_0xb4938d(0x179)]('←\x20'+_0x53e870[_0xb4938d(0x1c7)]+':\x20'+_0x53e870[_0xb4938d(0x1c0)][_0xb4938d(0x194)](0x0,0x3c)),this['emit']('task',_0x53e870),this['emit'](_0xb4938d(0x1b2),_0x53e870);}catch(_0x36bb74){this[_0xb4938d(0x179)](_0xb4938d(0x18b)+_0x36bb74[_0xb4938d(0x1b2)]);}}[a0_0x2ec609(0x172)](_0x42f2f1){return new Promise(_0x501427=>setTimeout(_0x501427,_0x42f2f1));}}var F=$;export{F as default,$ as CommHub};