@sleep2agi/agent-network 2.3.0-preview.236 → 2.3.0-preview.238

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_0x55112a=a0_0x1e5e;(function(_0x21ec24,_0x43024e){const _0x52c325=a0_0x1e5e,_0x41444b=_0x21ec24();while(!![]){try{const _0x2c0c4c=-parseInt(_0x52c325(0x1ac))/0x1+parseInt(_0x52c325(0x162))/0x2+-parseInt(_0x52c325(0x1d9))/0x3*(-parseInt(_0x52c325(0x19f))/0x4)+-parseInt(_0x52c325(0x1cb))/0x5*(-parseInt(_0x52c325(0x1bf))/0x6)+-parseInt(_0x52c325(0x183))/0x7*(-parseInt(_0x52c325(0x1b1))/0x8)+-parseInt(_0x52c325(0x1d8))/0x9*(-parseInt(_0x52c325(0x1d4))/0xa)+-parseInt(_0x52c325(0x1bc))/0xb;if(_0x2c0c4c===_0x43024e)break;else _0x41444b['push'](_0x41444b['shift']());}catch(_0x453960){_0x41444b['push'](_0x41444b['shift']());}}}(a0_0x3332,0x5b8ae));import{EventEmitter as a0_0x592971}from'events';import{hostname as a0_0x1f32c9}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x371e7a,_0x41b4b9)=>(_0x371e7a??_0x41b4b9)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x55112a(0x1b7)](0x0,0xf0);function N(_0x492072){const _0x376b68=a0_0x55112a;return(_0x492072 instanceof Error?_0x492072[_0x376b68(0x1cc)]:String(_0x492072??'unknown\x20error'))[_0x376b68(0x18b)](K,_0x376b68(0x182))[_0x376b68(0x18b)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x376b68(0x1b7)](0x0,0xf0);}function O(_0x17bed7,_0x2cd355=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x5dc974=a0_0x55112a;if(_0x2cd355)return JSON[_0x5dc974(0x199)](_0x17bed7);let _0x3a81ad=L(_0x17bed7[_0x5dc974(0x1b4)],_0x5dc974(0x165)),_0x4e1c87=L(_0x17bed7[_0x5dc974(0x192)],'<pending>'),_0x211cea=_0x17bed7[_0x5dc974(0x178)]?_0x5dc974(0x180)+_0x17bed7[_0x5dc974(0x178)]+':'+(_0x17bed7[_0x5dc974(0x1be)]??''):'';return'[commhub:task]\x20'+_0x17bed7[_0x5dc974(0x1b8)]+'\x20from='+L(_0x17bed7['from_alias'],_0x5dc974(0x177))+_0x5dc974(0x1a9)+L(_0x17bed7[_0x5dc974(0x1d5)],_0x5dc974(0x177))+_0x5dc974(0x191)+_0x4e1c87+'\x20parent_task_id='+_0x3a81ad+_0x5dc974(0x1b3)+L(_0x17bed7[_0x5dc974(0x16f)],_0x5dc974(0x177))+_0x5dc974(0x196)+_0x17bed7[_0x5dc974(0x160)]+_0x5dc974(0x186)+_0x17bed7['duration_ms']+'\x20lifecycle='+_0x17bed7['lifecycle_tracking']+_0x211cea;}function U(_0x2ba766){const _0x31a7f5=a0_0x55112a;return{'event':{'sending':_0x31a7f5(0x175),'delivered':_0x31a7f5(0x1c9),'failed':'task.send.failed','acked':_0x31a7f5(0x1ab),'started':'task.started','replied':_0x31a7f5(0x163),'expired':_0x31a7f5(0x19c)}[_0x2ba766[_0x31a7f5(0x1b8)]],..._0x2ba766};}function j(_0x565b41){const _0x453275=a0_0x55112a;let _0x280e30=_0x565b41?.[_0x453275(0x192)]||_0x565b41?.[_0x453275(0x1aa)]||_0x565b41?.['id'];if(_0x280e30)return String(_0x280e30);let _0x4adc9d=_0x565b41?.[_0x453275(0x1b2)]?.[0x0]?.['text'];if(typeof _0x4adc9d!==_0x453275(0x1a8))return null;try{let _0x47cf42=JSON[_0x453275(0x1a4)](_0x4adc9d);return _0x47cf42?.[_0x453275(0x192)]||_0x47cf42?.['message_id']||_0x47cf42?.['id']||null;}catch{return null;}}async function X(_0x1177ec,_0xe249c){const _0x2eefb7=a0_0x55112a;let _0x2ddb29=_0xe249c[_0x2eefb7(0x17a)]??Date[_0x2eefb7(0x17a)],_0x49108b=_0x2ddb29(),_0x13062e=(_0x410683,_0x5032a3,_0x256997,_0x549ef1)=>{const _0x184883=_0x2eefb7;_0xe249c[_0x184883(0x194)](O(U({'from_alias':_0x1177ec['fromAlias'],'to_alias':_0x1177ec[_0x184883(0x198)],'task_id':_0x5032a3,'parent_task_id':_0x1177ec[_0x184883(0x1c3)],'network_id':_0x1177ec[_0x184883(0x17d)],'transport':_0x1177ec[_0x184883(0x160)],'status':_0x410683,'duration_ms':_0x2ddb29()-_0x49108b,'lifecycle_tracking':_0x1177ec['lifecycleTracking'],..._0x256997!==void 0x0?{'error_code':_0x549ef1||_0x184883(0x1d3),'error_message':N(_0x256997)}:{}})));};_0x13062e('sending',null);try{let _0x45e491=await _0xe249c[_0x2eefb7(0x1a1)](),_0x4c833d=j(_0x45e491);if(_0x4c833d)_0x13062e(_0x2eefb7(0x17b),_0x4c833d);else{if(_0x45e491?.['ok']===!0x1||_0x45e491?.[_0x2eefb7(0x166)])_0x13062e('failed',_0x4c833d,_0x45e491?.[_0x2eefb7(0x166)]||'CommHub\x20rejected\x20task',_0x2eefb7(0x197));else _0x13062e('failed',null,_0x2eefb7(0x19b),_0x2eefb7(0x1a6));}return _0x45e491;}catch(_0x3bccce){throw _0x13062e(_0x2eefb7(0x1d1),null,_0x3bccce,'send_failed'),_0x3bccce;}}async function Y(_0x2668a0,_0x2608b1){const _0x216494=a0_0x55112a;return X({'fromAlias':_0x2668a0['fromAlias'],'toAlias':_0x2668a0[_0x216494(0x16b)],'parentTaskId':_0x2668a0['parentTaskId']||null,'networkId':_0x2668a0[_0x216494(0x17d)]||null,'transport':_0x216494(0x1bb),'lifecycleTracking':_0x216494(0x17c)},_0x2608b1);}class $ extends a0_0x592971{['url'];[a0_0x55112a(0x16b)];['token'];[a0_0x55112a(0x1d7)];[a0_0x55112a(0x167)];[a0_0x55112a(0x1af)];[a0_0x55112a(0x1a5)];['heartbeatTimer'];[a0_0x55112a(0x190)];[a0_0x55112a(0x171)]=!0x1;constructor(_0x3bee0f){const _0x49c92f=a0_0x55112a;super();if(this[_0x49c92f(0x1c8)]=_0x3bee0f[_0x49c92f(0x1c8)][_0x49c92f(0x18b)](/\/$/,''),this[_0x49c92f(0x16b)]=_0x3bee0f['alias'],this['token']=_0x3bee0f[_0x49c92f(0x164)],this[_0x49c92f(0x1d7)]=_0x3bee0f['agent']||_0x49c92f(0x1c2),this[_0x49c92f(0x167)]='sdk-'+_0x3bee0f[_0x49c92f(0x16b)]+'-'+Date[_0x49c92f(0x17a)]()[_0x49c92f(0x17f)](0x24),this[_0x49c92f(0x1af)]=_0x3bee0f['heartbeatInterval']??0x2bf20,this['reconnectDelay']=_0x3bee0f['reconnectDelay']??0xbb8,_0x3bee0f[_0x49c92f(0x1b9)]!==!0x1)this['connect']();}['log'](_0x474c9c){const _0xe0125a=a0_0x55112a;console[_0xe0125a(0x194)]('['+new Date()['toTimeString']()[_0xe0125a(0x1b7)](0x0,0x8)+']\x20[commhub:'+this[_0xe0125a(0x16b)]+']\x20'+_0x474c9c);}async[a0_0x55112a(0x19e)](_0x1ff4cc,_0x123924){const _0x3ccc7e=a0_0x55112a;let _0x25e6f3={'Content-Type':_0x3ccc7e(0x1c6),'Accept':_0x3ccc7e(0x1bd)};if(this[_0x3ccc7e(0x164)])_0x25e6f3[_0x3ccc7e(0x187)]='Bearer\x20'+this[_0x3ccc7e(0x164)];let _0x16ab76=await(await fetch(this[_0x3ccc7e(0x1c8)]+_0x3ccc7e(0x1b0),{'method':_0x3ccc7e(0x1c4),'headers':_0x25e6f3,'body':JSON[_0x3ccc7e(0x199)]({'jsonrpc':_0x3ccc7e(0x1ae),'id':Date[_0x3ccc7e(0x17a)](),'method':_0x3ccc7e(0x1cf),'params':{'name':_0x1ff4cc,'arguments':_0x123924}})}))[_0x3ccc7e(0x185)](),_0x44e903=_0x16ab76[_0x3ccc7e(0x189)](/data: (.+)/),_0x461918=_0x44e903?JSON[_0x3ccc7e(0x1a4)](_0x44e903[0x1]):JSON[_0x3ccc7e(0x1a4)](_0x16ab76),_0x582282=_0x461918?.['result']?.['content']?.[0x0]?.[_0x3ccc7e(0x185)];return _0x582282?JSON[_0x3ccc7e(0x1a4)](_0x582282):_0x461918;}async[a0_0x55112a(0x1d0)](){const _0x435da6=a0_0x55112a;if(this['running'])return;this[_0x435da6(0x171)]=!0x0,await this[_0x435da6(0x1b8)](_0x435da6(0x1cd)),this[_0x435da6(0x194)](_0x435da6(0x17e)),this[_0x435da6(0x179)]=setInterval(()=>{const _0xbb41b3=_0x435da6;this[_0xbb41b3(0x1b8)](_0xbb41b3(0x1cd))[_0xbb41b3(0x172)](_0x24ae67=>this[_0xbb41b3(0x194)]('heartbeat\x20failed:\x20'+_0x24ae67[_0xbb41b3(0x1cc)]));},this['heartbeatInterval']),this[_0x435da6(0x1a3)]();}async['disconnect'](){const _0x41d337=a0_0x55112a;if(this[_0x41d337(0x171)]=!0x1,this['sseAbort']?.[_0x41d337(0x18d)](),this['heartbeatTimer'])clearInterval(this[_0x41d337(0x179)]);await this['status'](_0x41d337(0x1ba))[_0x41d337(0x172)](()=>{}),this['log'](_0x41d337(0x169));}async[a0_0x55112a(0x1a1)](_0x10ee7e,_0x4ac089,_0x3d9363=a0_0x55112a(0x16a)){const _0x1da55e=a0_0x55112a;return Y({'alias':_0x10ee7e,'fromAlias':this['alias']},{'log':_0x34c09c=>console[_0x1da55e(0x194)](_0x34c09c),'send':()=>this['call']('send_task',{'alias':_0x10ee7e,'task':_0x4ac089,'priority':_0x3d9363,'from_session':this[_0x1da55e(0x16b)]})});}async[a0_0x55112a(0x1cc)](_0x4141af,_0x2c1100){const _0x556a08=a0_0x55112a;return this['call']('send_message',{'alias':_0x4141af,'message':_0x2c1100,'from_session':this[_0x556a08(0x16b)]});}async[a0_0x55112a(0x195)](_0x58520b,_0x46d7eb,_0x139e07=a0_0x55112a(0x1c5)){const _0x413bca=a0_0x55112a;return this['call'](_0x413bca(0x18f),{'in_reply_to':_0x58520b,'text':_0x46d7eb,'status':_0x139e07});}async[a0_0x55112a(0x1b8)](_0x3a68f0,_0x3be803){const _0x4d1d0c=a0_0x55112a;return this[_0x4d1d0c(0x19e)](_0x4d1d0c(0x173),{'resume_id':this[_0x4d1d0c(0x167)],'alias':this['alias'],'status':_0x3a68f0,'server':a0_0x1f32c9(),'hostname':a0_0x1f32c9(),'agent':this[_0x4d1d0c(0x1d7)],'project_dir':process[_0x4d1d0c(0x1c0)](),..._0x3be803});}async['getAllStatus'](){const _0x110616=a0_0x55112a;return this[_0x110616(0x19e)](_0x110616(0x19d),{});}async[a0_0x55112a(0x1c1)](_0x3ff4cc,_0x1d9668){const _0x43a6e5=a0_0x55112a;return this[_0x43a6e5(0x19e)](_0x43a6e5(0x1c1),{'message':_0x3ff4cc,'filter_server':_0x1d9668?.[_0x43a6e5(0x193)],'filter_status':_0x1d9668?.[_0x43a6e5(0x1b8)]});}async[a0_0x55112a(0x1a3)](){const _0x58bc91=a0_0x55112a;let _0x4661a=encodeURIComponent(this[_0x58bc91(0x16b)]),_0xb197d9=this[_0x58bc91(0x1c8)]+_0x58bc91(0x18c)+_0x4661a,_0x2474e7=this['reconnectDelay'];while(this['running']){try{this[_0x58bc91(0x190)]=new AbortController();let _0x371b60={'Accept':_0x58bc91(0x170)};if(this[_0x58bc91(0x164)])_0x371b60[_0x58bc91(0x187)]='Bearer\x20'+this[_0x58bc91(0x164)];let _0xcba981=await fetch(_0xb197d9,{'headers':_0x371b60,'signal':this['sseAbort']['signal']});if(!_0xcba981['ok']||!_0xcba981[_0x58bc91(0x188)]){this[_0x58bc91(0x194)](_0x58bc91(0x1a0)+_0xcba981[_0x58bc91(0x1b8)]),await this[_0x58bc91(0x184)](_0x2474e7),_0x2474e7=Math[_0x58bc91(0x16c)](_0x2474e7*1.5,0xea60);continue;}_0x2474e7=this[_0x58bc91(0x1a5)];let _0x2f2465=_0xcba981['body'][_0x58bc91(0x1b5)](),_0x5b2151=new TextDecoder(),_0x56c9a8='';while(this['running']){let {done:_0x467c35,value:_0x284a72}=await _0x2f2465[_0x58bc91(0x1a2)]();if(_0x467c35)break;_0x56c9a8+=_0x5b2151[_0x58bc91(0x18e)](_0x284a72,{'stream':!0x0});let _0x52f061=_0x56c9a8[_0x58bc91(0x19a)]('\x0a');_0x56c9a8=_0x52f061[_0x58bc91(0x176)]()||'';for(let _0x141cc7 of _0x52f061){if(!_0x141cc7['startsWith'](_0x58bc91(0x181)))continue;try{let _0x268a8e=JSON['parse'](_0x141cc7['slice'](0x6));if(_0x268a8e[_0x58bc91(0x174)]==='connected'){this[_0x58bc91(0x194)](_0x58bc91(0x1b6)),this['emit'](_0x58bc91(0x1c7));continue;}if(_0x268a8e['type']==='new_task'||_0x268a8e[_0x58bc91(0x174)]===_0x58bc91(0x161)||_0x268a8e[_0x58bc91(0x174)]===_0x58bc91(0x1c1))await this['processInbox']();}catch{}}}}catch(_0x4dc826){if(_0x4dc826[_0x58bc91(0x1ca)]===_0x58bc91(0x18a))break;this['emit'](_0x58bc91(0x166),_0x4dc826),this['log'](_0x58bc91(0x1ad)+_0x4dc826['message']);}if(this[_0x58bc91(0x171)])this[_0x58bc91(0x1d6)](_0x58bc91(0x169)),this[_0x58bc91(0x194)]('SSE\x20reconnecting\x20in\x20'+_0x2474e7/0x3e8+_0x58bc91(0x1d2)),await this[_0x58bc91(0x184)](_0x2474e7),_0x2474e7=Math[_0x58bc91(0x16c)](_0x2474e7*1.5,0xea60);}}async[a0_0x55112a(0x1a7)](){const _0x3c18ac=a0_0x55112a;try{let _0xec7efc=(await this['call'](_0x3c18ac(0x16d),{'alias':this[_0x3c18ac(0x16b)],'limit':0xa}))?.[_0x3c18ac(0x16e)]||[];for(let _0x255e66 of _0xec7efc)await this['call']('ack_inbox',{'alias':this[_0x3c18ac(0x16b)],'message_id':_0x255e66['id']}),this[_0x3c18ac(0x194)]('←\x20'+_0x255e66['from_session']+':\x20'+_0x255e66[_0x3c18ac(0x1b2)][_0x3c18ac(0x1b7)](0x0,0x3c)),this[_0x3c18ac(0x1d6)](_0x3c18ac(0x168),_0x255e66),this['emit'](_0x3c18ac(0x1cc),_0x255e66);}catch(_0x46fe58){this['log'](_0x3c18ac(0x1ce)+_0x46fe58[_0x3c18ac(0x1cc)]);}}[a0_0x55112a(0x184)](_0x534364){return new Promise(_0x282707=>setTimeout(_0x282707,_0x534364));}}function a0_0x3332(){const _0x2a7ef6=['task','disconnected','normal','alias','min','get_inbox','messages','network_id','text/event-stream','running','catch','report_status','type','task.send.start','pop','<unknown>','error_code','heartbeatTimer','now','delivered','not_tracked','networkId','registered','toString','\x20error=','data:\x20','[REDACTED]','3688902GXlNDA','sleep','text','\x20duration_ms=','Authorization','body','match','AbortError','replace','/events/','abort','decode','send_reply','sseAbort','\x20task_id=','task_id','server','log','reply','\x20transport=','send_rejected','toAlias','stringify','split','CommHub\x20response\x20omitted\x20task_id','task.expired','get_all_status','call','12toIFVv','SSE\x20failed:\x20','send','read','connectSSE','parse','reconnectDelay','missing_task_id','processInbox','string','\x20to=','message_id','task.ack','18610tfDrnT','SSE\x20error:\x20','2.0','heartbeatInterval','/mcp','8KbtkkO','content','\x20network_id=','parent_task_id','getReader','SSE\x20connected','slice','status','autoConnect','offline','mcp_http','22638022TPqhrC','application/json,\x20text/event-stream','error_message','4141398oACBwH','cwd','broadcast','sdk','parentTaskId','POST','completed','application/json','connected','url','task.send.delivered','name','5VAwxIt','message','idle','inbox\x20error:\x20','tools/call','connect','failed','s...','send_failed','530630oNspSe','to_alias','emit','agent','18jhSoOh','611859ICHFap','transport','new_message','1032732ZjJBJw','task.replied','token','<missing>','error','resumeId'];a0_0x3332=function(){return _0x2a7ef6;};return a0_0x3332();}function a0_0x1e5e(_0x42afb6,_0x1e5ad4){_0x42afb6=_0x42afb6-0x160;const _0x3332df=a0_0x3332();let _0x1e5eb3=_0x3332df[_0x42afb6];return _0x1e5eb3;}var F=$;export{F as default,$ as CommHub};
1
+ const a0_0xbf8af8=a0_0x44ea;(function(_0xd303d4,_0x54557f){const _0x28e742=a0_0x44ea,_0x430777=_0xd303d4();while(!![]){try{const _0x1fb6ab=-parseInt(_0x28e742(0x1b6))/0x1+-parseInt(_0x28e742(0x188))/0x2+-parseInt(_0x28e742(0x184))/0x3*(parseInt(_0x28e742(0x151))/0x4)+parseInt(_0x28e742(0x15d))/0x5+parseInt(_0x28e742(0x155))/0x6*(-parseInt(_0x28e742(0x152))/0x7)+-parseInt(_0x28e742(0x183))/0x8*(parseInt(_0x28e742(0x160))/0x9)+parseInt(_0x28e742(0x1bc))/0xa;if(_0x1fb6ab===_0x54557f)break;else _0x430777['push'](_0x430777['shift']());}catch(_0x4e7177){_0x430777['push'](_0x430777['shift']());}}}(a0_0xb6fe,0xac0f1));import{EventEmitter as a0_0x32d76b}from'events';import{hostname as a0_0x17546c}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x4a87dc,_0x3a626b)=>(_0x4a87dc??_0x3a626b)[a0_0xbf8af8(0x1a0)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0xbf8af8(0x16a)](0x0,0xf0);function a0_0xb6fe(){const _0x14b3eb=['error_code','cwd','send_rejected','abort','broadcast','content','<missing>','from_session','task.started','call','\x20error=','send','task_id','autoConnect','alias','resumeId','network_id','processInbox','log','send_reply','name','replace','get_all_status','reply','mcp_http','idle','decode','json','heartbeatTimer','[REDACTED]','\x20duration_ms=','toString','tools/call','sending','Authorization','\x20to=','disconnected','connected','sdk-','url','now','error','2.0','1080313MfrcEb','task.replied','agent','error_message','sleep','CommHub\x20rejected\x20task','54861550yHWPPn','catch','parse','get_inbox','send_task','running','\x20task_id=','connectSSE','new_task','report_status','from_alias','failed','application/json','message','emit','task.expired','heartbeat\x20failed:\x20','duration_ms','\x20parent_task_id=','networkId','token','parentTaskId','188tSFQHE','14nYydgI','task.send.failed','status','2906934DMkWdQ','SSE\x20reconnecting\x20in\x20','text','reconnectDelay','ack_inbox','[commhub:task]\x20','Bearer\x20','disconnect','341100dqxyls','getAllStatus','task','36PbkTpH','missing_task_id','send_failed','\x20lifecycle=','CommHub\x20response\x20omitted\x20task_id','startsWith','string','stringify','message_id','offline','slice','fromAlias',']\x20[commhub:','send_message','read','task.ack','application/json,\x20text/event-stream','result','to_alias','toAlias','body','completed','data:\x20','server','\x20from=','sseAbort','POST','connect','pop','SSE\x20failed:\x20','heartbeatInterval','type','s...','lifecycleTracking','task.send.delivered','2563384eeAgaV','28554nfwUpF','parent_task_id','task.send.start','delivered','2142586ybKxtj','signal','<unknown>'];a0_0xb6fe=function(){return _0x14b3eb;};return a0_0xb6fe();}function N(_0x72243b){const _0xe03dec=a0_0xbf8af8;return(_0x72243b instanceof Error?_0x72243b[_0xe03dec(0x148)]:String(_0x72243b??'unknown\x20error'))[_0xe03dec(0x1a0)](K,_0xe03dec(0x1a8))[_0xe03dec(0x1a0)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0xe03dec(0x16a)](0x0,0xf0);}function O(_0xf985de,_0x404395=process.env.ANET_TASK_TRACE_FORMAT===a0_0xbf8af8(0x1a6)){const _0x367bc3=a0_0xbf8af8;if(_0x404395)return JSON[_0x367bc3(0x167)](_0xf985de);let _0x5084e8=L(_0xf985de[_0x367bc3(0x185)],_0x367bc3(0x191)),_0x1898e8=L(_0xf985de[_0x367bc3(0x197)],'<pending>'),_0x9c9878=_0xf985de['error_code']?_0x367bc3(0x195)+_0xf985de[_0x367bc3(0x18b)]+':'+(_0xf985de[_0x367bc3(0x1b9)]??''):'';return _0x367bc3(0x15a)+_0xf985de[_0x367bc3(0x154)]+_0x367bc3(0x178)+L(_0xf985de[_0x367bc3(0x145)],_0x367bc3(0x18a))+_0x367bc3(0x1ae)+L(_0xf985de[_0x367bc3(0x172)],_0x367bc3(0x18a))+_0x367bc3(0x141)+_0x1898e8+_0x367bc3(0x14d)+_0x5084e8+'\x20network_id='+L(_0xf985de[_0x367bc3(0x19b)],_0x367bc3(0x18a))+'\x20transport='+_0xf985de['transport']+_0x367bc3(0x1a9)+_0xf985de[_0x367bc3(0x14c)]+_0x367bc3(0x163)+_0xf985de['lifecycle_tracking']+_0x9c9878;}function U(_0x53d9f0){const _0x363ab0=a0_0xbf8af8;return{'event':{'sending':_0x363ab0(0x186),'delivered':_0x363ab0(0x182),'failed':_0x363ab0(0x153),'acked':_0x363ab0(0x16f),'started':_0x363ab0(0x193),'replied':_0x363ab0(0x1b7),'expired':_0x363ab0(0x14a)}[_0x53d9f0['status']],..._0x53d9f0};}function a0_0x44ea(_0x3074f1,_0x27bd6b){_0x3074f1=_0x3074f1-0x141;const _0xb6fea4=a0_0xb6fe();let _0x44ea41=_0xb6fea4[_0x3074f1];return _0x44ea41;}function j(_0x55ed86){const _0x3eb3eb=a0_0xbf8af8;let _0x1a2e01=_0x55ed86?.[_0x3eb3eb(0x197)]||_0x55ed86?.[_0x3eb3eb(0x168)]||_0x55ed86?.['id'];if(_0x1a2e01)return String(_0x1a2e01);let _0x58c35f=_0x55ed86?.[_0x3eb3eb(0x190)]?.[0x0]?.[_0x3eb3eb(0x157)];if(typeof _0x58c35f!==_0x3eb3eb(0x166))return null;try{let _0x479670=JSON[_0x3eb3eb(0x1be)](_0x58c35f);return _0x479670?.['task_id']||_0x479670?.[_0x3eb3eb(0x168)]||_0x479670?.['id']||null;}catch{return null;}}async function X(_0x506730,_0x526b18){const _0x1b709e=a0_0xbf8af8;let _0x3a636e=_0x526b18[_0x1b709e(0x1b3)]??Date['now'],_0x19f994=_0x3a636e(),_0x336f83=(_0x5ec5db,_0x3410d,_0x38542,_0x584673)=>{const _0x53a5dd=_0x1b709e;_0x526b18[_0x53a5dd(0x19d)](O(U({'from_alias':_0x506730[_0x53a5dd(0x16b)],'to_alias':_0x506730[_0x53a5dd(0x173)],'task_id':_0x3410d,'parent_task_id':_0x506730['parentTaskId'],'network_id':_0x506730[_0x53a5dd(0x14e)],'transport':_0x506730['transport'],'status':_0x5ec5db,'duration_ms':_0x3a636e()-_0x19f994,'lifecycle_tracking':_0x506730[_0x53a5dd(0x181)],..._0x38542!==void 0x0?{'error_code':_0x584673||'send_failed','error_message':N(_0x38542)}:{}})));};_0x336f83(_0x1b709e(0x1ac),null);try{let _0x31329b=await _0x526b18['send'](),_0x4d3390=j(_0x31329b);if(_0x4d3390)_0x336f83(_0x1b709e(0x187),_0x4d3390);else{if(_0x31329b?.['ok']===!0x1||_0x31329b?.[_0x1b709e(0x1b4)])_0x336f83(_0x1b709e(0x146),_0x4d3390,_0x31329b?.[_0x1b709e(0x1b4)]||_0x1b709e(0x1bb),_0x1b709e(0x18d));else _0x336f83(_0x1b709e(0x146),null,_0x1b709e(0x164),_0x1b709e(0x161));}return _0x31329b;}catch(_0xd8fe1b){throw _0x336f83('failed',null,_0xd8fe1b,_0x1b709e(0x162)),_0xd8fe1b;}}async function Y(_0x2425fa,_0x54b5aa){const _0x572b48=a0_0xbf8af8;return X({'fromAlias':_0x2425fa['fromAlias'],'toAlias':_0x2425fa[_0x572b48(0x199)],'parentTaskId':_0x2425fa[_0x572b48(0x150)]||null,'networkId':_0x2425fa[_0x572b48(0x14e)]||null,'transport':_0x572b48(0x1a3),'lifecycleTracking':'not_tracked'},_0x54b5aa);}class $ extends a0_0x32d76b{[a0_0xbf8af8(0x1b2)];[a0_0xbf8af8(0x199)];[a0_0xbf8af8(0x14f)];[a0_0xbf8af8(0x1b8)];[a0_0xbf8af8(0x19a)];[a0_0xbf8af8(0x17e)];['reconnectDelay'];[a0_0xbf8af8(0x1a7)];['sseAbort'];['running']=!0x1;constructor(_0x27d75b){const _0x1f6ab6=a0_0xbf8af8;super();if(this[_0x1f6ab6(0x1b2)]=_0x27d75b[_0x1f6ab6(0x1b2)][_0x1f6ab6(0x1a0)](/\/$/,''),this[_0x1f6ab6(0x199)]=_0x27d75b[_0x1f6ab6(0x199)],this[_0x1f6ab6(0x14f)]=_0x27d75b[_0x1f6ab6(0x14f)],this[_0x1f6ab6(0x1b8)]=_0x27d75b['agent']||'sdk',this['resumeId']=_0x1f6ab6(0x1b1)+_0x27d75b[_0x1f6ab6(0x199)]+'-'+Date[_0x1f6ab6(0x1b3)]()[_0x1f6ab6(0x1aa)](0x24),this['heartbeatInterval']=_0x27d75b[_0x1f6ab6(0x17e)]??0x2bf20,this['reconnectDelay']=_0x27d75b[_0x1f6ab6(0x158)]??0xbb8,_0x27d75b[_0x1f6ab6(0x198)]!==!0x1)this[_0x1f6ab6(0x17b)]();}[a0_0xbf8af8(0x19d)](_0x12b8dd){const _0x2b9b8f=a0_0xbf8af8;console[_0x2b9b8f(0x19d)]('['+new Date()['toTimeString']()['slice'](0x0,0x8)+_0x2b9b8f(0x16c)+this['alias']+']\x20'+_0x12b8dd);}async['call'](_0x5e6d98,_0x3daaf1){const _0x52e363=a0_0xbf8af8;let _0x1aec48={'Content-Type':_0x52e363(0x147),'Accept':_0x52e363(0x170)};if(this[_0x52e363(0x14f)])_0x1aec48[_0x52e363(0x1ad)]=_0x52e363(0x15b)+this['token'];let _0x2c3fd0=await(await fetch(this[_0x52e363(0x1b2)]+'/mcp',{'method':_0x52e363(0x17a),'headers':_0x1aec48,'body':JSON[_0x52e363(0x167)]({'jsonrpc':_0x52e363(0x1b5),'id':Date[_0x52e363(0x1b3)](),'method':_0x52e363(0x1ab),'params':{'name':_0x5e6d98,'arguments':_0x3daaf1}})}))[_0x52e363(0x157)](),_0x405206=_0x2c3fd0['match'](/data: (.+)/),_0x482173=_0x405206?JSON['parse'](_0x405206[0x1]):JSON['parse'](_0x2c3fd0),_0x1cb263=_0x482173?.[_0x52e363(0x171)]?.[_0x52e363(0x190)]?.[0x0]?.[_0x52e363(0x157)];return _0x1cb263?JSON['parse'](_0x1cb263):_0x482173;}async[a0_0xbf8af8(0x17b)](){const _0x2360a3=a0_0xbf8af8;if(this[_0x2360a3(0x1c1)])return;this[_0x2360a3(0x1c1)]=!0x0,await this[_0x2360a3(0x154)](_0x2360a3(0x1a4)),this[_0x2360a3(0x19d)]('registered'),this[_0x2360a3(0x1a7)]=setInterval(()=>{const _0x14575a=_0x2360a3;this[_0x14575a(0x154)](_0x14575a(0x1a4))[_0x14575a(0x1bd)](_0x4ea632=>this['log'](_0x14575a(0x14b)+_0x4ea632[_0x14575a(0x148)]));},this[_0x2360a3(0x17e)]),this[_0x2360a3(0x142)]();}async[a0_0xbf8af8(0x15c)](){const _0x1ced4b=a0_0xbf8af8;if(this[_0x1ced4b(0x1c1)]=!0x1,this[_0x1ced4b(0x179)]?.[_0x1ced4b(0x18e)](),this['heartbeatTimer'])clearInterval(this[_0x1ced4b(0x1a7)]);await this[_0x1ced4b(0x154)](_0x1ced4b(0x169))[_0x1ced4b(0x1bd)](()=>{}),this[_0x1ced4b(0x19d)](_0x1ced4b(0x1af));}async[a0_0xbf8af8(0x196)](_0x49211f,_0x34a628,_0x4305ca='normal'){const _0xa90daa=a0_0xbf8af8;return Y({'alias':_0x49211f,'fromAlias':this[_0xa90daa(0x199)]},{'log':_0x287302=>console[_0xa90daa(0x19d)](_0x287302),'send':()=>this[_0xa90daa(0x194)](_0xa90daa(0x1c0),{'alias':_0x49211f,'task':_0x34a628,'priority':_0x4305ca,'from_session':this[_0xa90daa(0x199)]})});}async[a0_0xbf8af8(0x148)](_0x425aa7,_0x34fdef){const _0x152d31=a0_0xbf8af8;return this[_0x152d31(0x194)](_0x152d31(0x16d),{'alias':_0x425aa7,'message':_0x34fdef,'from_session':this[_0x152d31(0x199)]});}async[a0_0xbf8af8(0x1a2)](_0x20f8ef,_0x4a6771,_0x58041e=a0_0xbf8af8(0x175)){const _0x1493b0=a0_0xbf8af8;return this[_0x1493b0(0x194)](_0x1493b0(0x19e),{'in_reply_to':_0x20f8ef,'text':_0x4a6771,'status':_0x58041e});}async['status'](_0x50e04f,_0x373581){const _0x484c36=a0_0xbf8af8;return this[_0x484c36(0x194)](_0x484c36(0x144),{'resume_id':this[_0x484c36(0x19a)],'alias':this[_0x484c36(0x199)],'status':_0x50e04f,'server':a0_0x17546c(),'hostname':a0_0x17546c(),'agent':this[_0x484c36(0x1b8)],'project_dir':process[_0x484c36(0x18c)](),..._0x373581});}async[a0_0xbf8af8(0x15e)](){const _0x85ff88=a0_0xbf8af8;return this[_0x85ff88(0x194)](_0x85ff88(0x1a1),{});}async[a0_0xbf8af8(0x18f)](_0xff0211,_0x5b6bf8){const _0x355330=a0_0xbf8af8;return this[_0x355330(0x194)]('broadcast',{'message':_0xff0211,'filter_server':_0x5b6bf8?.[_0x355330(0x177)],'filter_status':_0x5b6bf8?.['status']});}async['connectSSE'](){const _0x3db073=a0_0xbf8af8;let _0x5b24aa=encodeURIComponent(this['alias']),_0x3ce000=this[_0x3db073(0x1b2)]+'/events/'+_0x5b24aa,_0x2bfc90=this['reconnectDelay'];while(this[_0x3db073(0x1c1)]){try{this[_0x3db073(0x179)]=new AbortController();let _0x502cc8={'Accept':'text/event-stream'};if(this['token'])_0x502cc8['Authorization']='Bearer\x20'+this['token'];let _0x2191b4=await fetch(_0x3ce000,{'headers':_0x502cc8,'signal':this[_0x3db073(0x179)][_0x3db073(0x189)]});if(!_0x2191b4['ok']||!_0x2191b4[_0x3db073(0x174)]){this[_0x3db073(0x19d)](_0x3db073(0x17d)+_0x2191b4['status']),await this['sleep'](_0x2bfc90),_0x2bfc90=Math['min'](_0x2bfc90*1.5,0xea60);continue;}_0x2bfc90=this[_0x3db073(0x158)];let _0xfdf2d=_0x2191b4[_0x3db073(0x174)]['getReader'](),_0x2513c5=new TextDecoder(),_0x374fec='';while(this[_0x3db073(0x1c1)]){let {done:_0x138b0e,value:_0x713258}=await _0xfdf2d[_0x3db073(0x16e)]();if(_0x138b0e)break;_0x374fec+=_0x2513c5[_0x3db073(0x1a5)](_0x713258,{'stream':!0x0});let _0x4e3606=_0x374fec['split']('\x0a');_0x374fec=_0x4e3606[_0x3db073(0x17c)]()||'';for(let _0x1bb7aa of _0x4e3606){if(!_0x1bb7aa[_0x3db073(0x165)](_0x3db073(0x176)))continue;try{let _0x2016fd=JSON[_0x3db073(0x1be)](_0x1bb7aa['slice'](0x6));if(_0x2016fd['type']===_0x3db073(0x1b0)){this['log']('SSE\x20connected'),this['emit'](_0x3db073(0x1b0));continue;}if(_0x2016fd['type']===_0x3db073(0x143)||_0x2016fd[_0x3db073(0x17f)]==='new_message'||_0x2016fd[_0x3db073(0x17f)]==='broadcast')await this[_0x3db073(0x19c)]();}catch{}}}}catch(_0x2d61a4){if(_0x2d61a4[_0x3db073(0x19f)]==='AbortError')break;this['emit'](_0x3db073(0x1b4),_0x2d61a4),this['log']('SSE\x20error:\x20'+_0x2d61a4[_0x3db073(0x148)]);}if(this['running'])this['emit']('disconnected'),this[_0x3db073(0x19d)](_0x3db073(0x156)+_0x2bfc90/0x3e8+_0x3db073(0x180)),await this['sleep'](_0x2bfc90),_0x2bfc90=Math['min'](_0x2bfc90*1.5,0xea60);}}async[a0_0xbf8af8(0x19c)](){const _0x394aaf=a0_0xbf8af8;try{let _0x5b5229=(await this['call'](_0x394aaf(0x1bf),{'alias':this['alias'],'limit':0xa}))?.['messages']||[];for(let _0x225fb9 of _0x5b5229)await this[_0x394aaf(0x194)](_0x394aaf(0x159),{'alias':this[_0x394aaf(0x199)],'message_id':_0x225fb9['id']}),this[_0x394aaf(0x19d)]('←\x20'+_0x225fb9[_0x394aaf(0x192)]+':\x20'+_0x225fb9[_0x394aaf(0x190)]['slice'](0x0,0x3c)),this[_0x394aaf(0x149)](_0x394aaf(0x15f),_0x225fb9),this['emit'](_0x394aaf(0x148),_0x225fb9);}catch(_0x5e2618){this[_0x394aaf(0x19d)]('inbox\x20error:\x20'+_0x5e2618[_0x394aaf(0x148)]);}}[a0_0xbf8af8(0x1ba)](_0x82a46e){return new Promise(_0xf4f21e=>setTimeout(_0xf4f21e,_0x82a46e));}}var F=$;export{F as default,$ as CommHub};