@sleep2agi/agent-network 2.3.0-preview.56 → 2.3.0-preview.57

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_0x3f65d7=a0_0x1cd6;(function(_0xe9cf55,_0x3a793d){const _0xc0a76d=a0_0x1cd6,_0xace6a8=_0xe9cf55();while(!![]){try{const _0x389d4a=parseInt(_0xc0a76d(0x1ce))/0x1*(-parseInt(_0xc0a76d(0x1cf))/0x2)+-parseInt(_0xc0a76d(0x1a8))/0x3+-parseInt(_0xc0a76d(0x19d))/0x4+-parseInt(_0xc0a76d(0x186))/0x5+parseInt(_0xc0a76d(0x1f9))/0x6*(-parseInt(_0xc0a76d(0x184))/0x7)+parseInt(_0xc0a76d(0x1cd))/0x8*(-parseInt(_0xc0a76d(0x1d8))/0x9)+parseInt(_0xc0a76d(0x19f))/0xa;if(_0x389d4a===_0x3a793d)break;else _0xace6a8['push'](_0xace6a8['shift']());}catch(_0x136866){_0xace6a8['push'](_0xace6a8['shift']());}}}(a0_0x4a19,0x7d246));import{EventEmitter as a0_0x230289}from'events';function a0_0x1cd6(_0x5a6bb8,_0x377bae){_0x5a6bb8=_0x5a6bb8-0x184;const _0x4a198b=a0_0x4a19();let _0x1cd653=_0x4a198b[_0x5a6bb8];return _0x1cd653;}import{hostname as a0_0x4e0bfc}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x730d07,_0x308f3e)=>(_0x730d07??_0x308f3e)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x3f65d7(0x1a1)](0x0,0xf0);function N(_0x3dd80b){const _0x5d0563=a0_0x3f65d7;return(_0x3dd80b instanceof Error?_0x3dd80b['message']:String(_0x3dd80b??'unknown\x20error'))[_0x5d0563(0x1f4)](K,_0x5d0563(0x1cc))[_0x5d0563(0x1f4)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x5d0563(0x1a1)](0x0,0xf0);}function O(_0x51121c,_0x4aace4=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x34f409=a0_0x3f65d7;if(_0x4aace4)return JSON['stringify'](_0x51121c);let _0x1a9f21=L(_0x51121c['parent_task_id'],_0x34f409(0x188)),_0x47f430=L(_0x51121c[_0x34f409(0x201)],_0x34f409(0x1a4)),_0x755976=_0x51121c['error_code']?_0x34f409(0x18b)+_0x51121c[_0x34f409(0x1c3)]+':'+(_0x51121c[_0x34f409(0x1bf)]??''):'';return'[commhub:task]\x20'+_0x51121c[_0x34f409(0x1da)]+_0x34f409(0x1ad)+L(_0x51121c[_0x34f409(0x1ff)],_0x34f409(0x19b))+_0x34f409(0x1e8)+L(_0x51121c[_0x34f409(0x1a0)],_0x34f409(0x19b))+_0x34f409(0x1e4)+_0x47f430+_0x34f409(0x1d4)+_0x1a9f21+_0x34f409(0x19a)+L(_0x51121c[_0x34f409(0x1d6)],_0x34f409(0x19b))+'\x20transport='+_0x51121c[_0x34f409(0x1ee)]+_0x34f409(0x1b5)+_0x51121c['duration_ms']+_0x34f409(0x1e7)+_0x51121c['lifecycle_tracking']+_0x755976;}function U(_0x317e1b){const _0x382614=a0_0x3f65d7;return{'event':{'sending':_0x382614(0x19e),'delivered':'task.send.delivered','failed':_0x382614(0x193),'acked':_0x382614(0x1b3),'started':'task.started','replied':'task.replied','expired':_0x382614(0x1ab)}[_0x317e1b[_0x382614(0x1da)]],..._0x317e1b};}function j(_0x3fc9a2){const _0x2580be=a0_0x3f65d7;let _0x2dccb2=_0x3fc9a2?.[_0x2580be(0x201)]||_0x3fc9a2?.[_0x2580be(0x1e5)]||_0x3fc9a2?.['id'];if(_0x2dccb2)return String(_0x2dccb2);let _0x21c2e8=_0x3fc9a2?.['content']?.[0x0]?.[_0x2580be(0x1ae)];if(typeof _0x21c2e8!==_0x2580be(0x1f8))return null;try{let _0x31307b=JSON['parse'](_0x21c2e8);return _0x31307b?.[_0x2580be(0x201)]||_0x31307b?.[_0x2580be(0x1e5)]||_0x31307b?.['id']||null;}catch{return null;}}async function X(_0x2c19bb,_0x38032c){const _0x326441=a0_0x3f65d7;let _0x25b47b=_0x38032c[_0x326441(0x1fa)]??Date['now'],_0x376741=_0x25b47b(),_0x441012=(_0x5851ec,_0x1d7b55,_0x2b3fa9,_0x380b82)=>{const _0x36baaf=_0x326441;_0x38032c[_0x36baaf(0x1df)](O(U({'from_alias':_0x2c19bb['fromAlias'],'to_alias':_0x2c19bb[_0x36baaf(0x1e2)],'task_id':_0x1d7b55,'parent_task_id':_0x2c19bb['parentTaskId'],'network_id':_0x2c19bb['networkId'],'transport':_0x2c19bb[_0x36baaf(0x1ee)],'status':_0x5851ec,'duration_ms':_0x25b47b()-_0x376741,'lifecycle_tracking':_0x2c19bb[_0x36baaf(0x1ba)],..._0x2b3fa9!==void 0x0?{'error_code':_0x380b82||'send_failed','error_message':N(_0x2b3fa9)}:{}})));};_0x441012(_0x326441(0x18f),null);try{let _0x54c3d6=await _0x38032c['send'](),_0x52d46a=j(_0x54c3d6);if(_0x52d46a)_0x441012('delivered',_0x52d46a);else{if(_0x54c3d6?.['ok']===!0x1||_0x54c3d6?.[_0x326441(0x196)])_0x441012(_0x326441(0x1bc),_0x52d46a,_0x54c3d6?.[_0x326441(0x196)]||_0x326441(0x1ca),'send_rejected');else _0x441012(_0x326441(0x1bc),null,_0x326441(0x1b7),_0x326441(0x1b0));}return _0x54c3d6;}catch(_0x3d6ffd){throw _0x441012(_0x326441(0x1bc),null,_0x3d6ffd,_0x326441(0x1c0)),_0x3d6ffd;}}async function Y(_0x1cf34c,_0x3b903d){const _0x527d39=a0_0x3f65d7;return X({'fromAlias':_0x1cf34c[_0x527d39(0x1db)],'toAlias':_0x1cf34c[_0x527d39(0x195)],'parentTaskId':_0x1cf34c[_0x527d39(0x1e9)]||null,'networkId':_0x1cf34c[_0x527d39(0x1f2)]||null,'transport':_0x527d39(0x1d2),'lifecycleTracking':_0x527d39(0x1d1)},_0x3b903d);}class $ extends a0_0x230289{[a0_0x3f65d7(0x1de)];[a0_0x3f65d7(0x195)];[a0_0x3f65d7(0x1f6)];[a0_0x3f65d7(0x1d7)];[a0_0x3f65d7(0x1ac)];[a0_0x3f65d7(0x190)];['reconnectDelay'];[a0_0x3f65d7(0x1b2)];['sseAbort'];['running']=!0x1;constructor(_0x55a2fe){const _0x43428f=a0_0x3f65d7;super();if(this[_0x43428f(0x1de)]=_0x55a2fe[_0x43428f(0x1de)][_0x43428f(0x1f4)](/\/$/,''),this[_0x43428f(0x195)]=_0x55a2fe[_0x43428f(0x195)],this['token']=_0x55a2fe[_0x43428f(0x1f6)],this[_0x43428f(0x1d7)]=_0x55a2fe[_0x43428f(0x1d7)]||'sdk',this['resumeId']=_0x43428f(0x1dd)+_0x55a2fe['alias']+'-'+Date[_0x43428f(0x1fa)]()[_0x43428f(0x1f7)](0x24),this['heartbeatInterval']=_0x55a2fe[_0x43428f(0x190)]??0x2bf20,this[_0x43428f(0x1fb)]=_0x55a2fe['reconnectDelay']??0xbb8,_0x55a2fe[_0x43428f(0x1ed)]!==!0x1)this[_0x43428f(0x187)]();}['log'](_0x133e8e){const _0x420a67=a0_0x3f65d7;console[_0x420a67(0x1df)]('['+new Date()['toTimeString']()['slice'](0x0,0x8)+']\x20[commhub:'+this[_0x420a67(0x195)]+']\x20'+_0x133e8e);}async['call'](_0x202a9e,_0x582b1c){const _0x4c22fb=a0_0x3f65d7;let _0x52bc12={'Content-Type':_0x4c22fb(0x1a6),'Accept':_0x4c22fb(0x1bd)};if(this[_0x4c22fb(0x1f6)])_0x52bc12['Authorization']='Bearer\x20'+this[_0x4c22fb(0x1f6)];let _0x13e77c=await(await fetch(this['url']+_0x4c22fb(0x200),{'method':_0x4c22fb(0x1c2),'headers':_0x52bc12,'body':JSON[_0x4c22fb(0x189)]({'jsonrpc':_0x4c22fb(0x1f3),'id':Date[_0x4c22fb(0x1fa)](),'method':_0x4c22fb(0x1f0),'params':{'name':_0x202a9e,'arguments':_0x582b1c}})}))[_0x4c22fb(0x1ae)](),_0x5a765c=_0x13e77c[_0x4c22fb(0x191)](/data: (.+)/),_0x5664e7=_0x5a765c?JSON[_0x4c22fb(0x1c6)](_0x5a765c[0x1]):JSON[_0x4c22fb(0x1c6)](_0x13e77c),_0x39a235=_0x5664e7?.[_0x4c22fb(0x1b8)]?.[_0x4c22fb(0x1aa)]?.[0x0]?.[_0x4c22fb(0x1ae)];return _0x39a235?JSON['parse'](_0x39a235):_0x5664e7;}async[a0_0x3f65d7(0x187)](){const _0x53ca67=a0_0x3f65d7;if(this[_0x53ca67(0x198)])return;this[_0x53ca67(0x198)]=!0x0,await this[_0x53ca67(0x1da)]('idle'),this[_0x53ca67(0x1df)](_0x53ca67(0x1c4)),this[_0x53ca67(0x1b2)]=setInterval(()=>{const _0xea42d1=_0x53ca67;this[_0xea42d1(0x1da)](_0xea42d1(0x1a7))['catch'](_0x392d2c=>this['log']('heartbeat\x20failed:\x20'+_0x392d2c[_0xea42d1(0x192)]));},this['heartbeatInterval']),this[_0x53ca67(0x1d9)]();}async[a0_0x3f65d7(0x18c)](){const _0x4fac11=a0_0x3f65d7;if(this[_0x4fac11(0x198)]=!0x1,this[_0x4fac11(0x1b1)]?.[_0x4fac11(0x1fe)](),this[_0x4fac11(0x1b2)])clearInterval(this[_0x4fac11(0x1b2)]);await this[_0x4fac11(0x1da)]('offline')[_0x4fac11(0x1f5)](()=>{}),this[_0x4fac11(0x1df)](_0x4fac11(0x1dc));}async[a0_0x3f65d7(0x1af)](_0x192a68,_0x138fd7,_0x148424=a0_0x3f65d7(0x1f1)){const _0x605a7=a0_0x3f65d7;return Y({'alias':_0x192a68,'fromAlias':this[_0x605a7(0x195)]},{'log':_0xb12c5=>console[_0x605a7(0x1df)](_0xb12c5),'send':()=>this[_0x605a7(0x18a)](_0x605a7(0x18d),{'alias':_0x192a68,'task':_0x138fd7,'priority':_0x148424,'from_session':this[_0x605a7(0x195)]})});}async[a0_0x3f65d7(0x192)](_0x4d067a,_0xd8a469){const _0x38485c=a0_0x3f65d7;return this['call'](_0x38485c(0x1fc),{'alias':_0x4d067a,'message':_0xd8a469,'from_session':this[_0x38485c(0x195)]});}async[a0_0x3f65d7(0x1a2)](_0x191ad8,_0x2847f6,_0x48f258=a0_0x3f65d7(0x1d0)){const _0x22751d=a0_0x3f65d7;return this[_0x22751d(0x18a)](_0x22751d(0x1e0),{'in_reply_to':_0x191ad8,'text':_0x2847f6,'status':_0x48f258});}async['status'](_0x3bd97b,_0x5e8d12){const _0x4d0de5=a0_0x3f65d7;return this[_0x4d0de5(0x18a)](_0x4d0de5(0x1bb),{'resume_id':this[_0x4d0de5(0x1ac)],'alias':this[_0x4d0de5(0x195)],'status':_0x3bd97b,'server':a0_0x4e0bfc(),'hostname':a0_0x4e0bfc(),'agent':this['agent'],'project_dir':process[_0x4d0de5(0x1be)](),..._0x5e8d12});}async[a0_0x3f65d7(0x1b6)](){const _0x55f3bf=a0_0x3f65d7;return this[_0x55f3bf(0x18a)](_0x55f3bf(0x1c9),{});}async[a0_0x3f65d7(0x194)](_0x1d52c3,_0x5b5eae){const _0x26ffa4=a0_0x3f65d7;return this['call'](_0x26ffa4(0x194),{'message':_0x1d52c3,'filter_server':_0x5b5eae?.[_0x26ffa4(0x199)],'filter_status':_0x5b5eae?.[_0x26ffa4(0x1da)]});}async['connectSSE'](){const _0x32966a=a0_0x3f65d7;let _0x13f82a=encodeURIComponent(this[_0x32966a(0x195)]),_0x1899a8=this[_0x32966a(0x1de)]+_0x32966a(0x1e3)+_0x13f82a,_0x20ae69=this[_0x32966a(0x1fb)];while(this[_0x32966a(0x198)]){try{this[_0x32966a(0x1b1)]=new AbortController();let _0x15a6c8={'Accept':_0x32966a(0x197)};if(this[_0x32966a(0x1f6)])_0x15a6c8['Authorization']=_0x32966a(0x1c7)+this[_0x32966a(0x1f6)];let _0x57e021=await fetch(_0x1899a8,{'headers':_0x15a6c8,'signal':this[_0x32966a(0x1b1)][_0x32966a(0x18e)]});if(!_0x57e021['ok']||!_0x57e021[_0x32966a(0x1a3)]){this[_0x32966a(0x1df)]('SSE\x20failed:\x20'+_0x57e021[_0x32966a(0x1da)]),await this['sleep'](_0x20ae69),_0x20ae69=Math[_0x32966a(0x1ec)](_0x20ae69*1.5,0xea60);continue;}_0x20ae69=this[_0x32966a(0x1fb)];let _0x11b34b=_0x57e021[_0x32966a(0x1a3)][_0x32966a(0x1a9)](),_0x5d706b=new TextDecoder(),_0x4d76de='';while(this[_0x32966a(0x198)]){let {done:_0x466c19,value:_0x48a84f}=await _0x11b34b['read']();if(_0x466c19)break;_0x4d76de+=_0x5d706b[_0x32966a(0x1a5)](_0x48a84f,{'stream':!0x0});let _0x5c802a=_0x4d76de[_0x32966a(0x1ef)]('\x0a');_0x4d76de=_0x5c802a[_0x32966a(0x1e6)]()||'';for(let _0x14403b of _0x5c802a){if(!_0x14403b[_0x32966a(0x1d3)](_0x32966a(0x19c)))continue;try{let _0x12008d=JSON[_0x32966a(0x1c6)](_0x14403b[_0x32966a(0x1a1)](0x6));if(_0x12008d[_0x32966a(0x1ea)]==='connected'){this[_0x32966a(0x1df)]('SSE\x20connected'),this['emit']('connected');continue;}if(_0x12008d[_0x32966a(0x1ea)]===_0x32966a(0x1c1)||_0x12008d['type']===_0x32966a(0x1fd)||_0x12008d[_0x32966a(0x1ea)]===_0x32966a(0x194))await this['processInbox']();}catch{}}}}catch(_0xe0b062){if(_0xe0b062[_0x32966a(0x1eb)]==='AbortError')break;this[_0x32966a(0x1c8)](_0x32966a(0x196),_0xe0b062),this[_0x32966a(0x1df)]('SSE\x20error:\x20'+_0xe0b062[_0x32966a(0x192)]);}if(this['running'])this[_0x32966a(0x1c8)](_0x32966a(0x1dc)),this['log'](_0x32966a(0x1b9)+_0x20ae69/0x3e8+_0x32966a(0x1b4)),await this[_0x32966a(0x185)](_0x20ae69),_0x20ae69=Math['min'](_0x20ae69*1.5,0xea60);}}async['processInbox'](){const _0x1efbb0=a0_0x3f65d7;try{let _0x553a87=(await this[_0x1efbb0(0x18a)](_0x1efbb0(0x1e1),{'alias':this['alias'],'limit':0xa}))?.[_0x1efbb0(0x202)]||[];for(let _0x214d38 of _0x553a87)await this[_0x1efbb0(0x18a)](_0x1efbb0(0x1c5),{'alias':this['alias'],'message_id':_0x214d38['id']}),this['log']('←\x20'+_0x214d38[_0x1efbb0(0x1d5)]+':\x20'+_0x214d38[_0x1efbb0(0x1aa)][_0x1efbb0(0x1a1)](0x0,0x3c)),this[_0x1efbb0(0x1c8)](_0x1efbb0(0x1cb),_0x214d38),this[_0x1efbb0(0x1c8)]('message',_0x214d38);}catch(_0x43b122){this[_0x1efbb0(0x1df)]('inbox\x20error:\x20'+_0x43b122['message']);}}[a0_0x3f65d7(0x185)](_0x4a3f3f){return new Promise(_0x2dc8d0=>setTimeout(_0x2dc8d0,_0x4a3f3f));}}function a0_0x4a19(){const _0x4f082f=['SSE\x20reconnecting\x20in\x20','lifecycleTracking','report_status','failed','application/json,\x20text/event-stream','cwd','error_message','send_failed','new_task','POST','error_code','registered','ack_inbox','parse','Bearer\x20','emit','get_all_status','CommHub\x20rejected\x20task','task','[REDACTED]','136cFeQOq','1btMHqW','1206410uTFgdg','completed','not_tracked','mcp_http','startsWith','\x20parent_task_id=','from_session','network_id','agent','44991jKEbpE','connectSSE','status','fromAlias','disconnected','sdk-','url','log','send_reply','get_inbox','toAlias','/events/','\x20task_id=','message_id','pop','\x20lifecycle=','\x20to=','parentTaskId','type','name','min','autoConnect','transport','split','tools/call','normal','networkId','2.0','replace','catch','token','toString','string','1998120yRupLC','now','reconnectDelay','send_message','new_message','abort','from_alias','/mcp','task_id','messages','7wluzuT','sleep','222465UYeufE','connect','<missing>','stringify','call','\x20error=','disconnect','send_task','signal','sending','heartbeatInterval','match','message','task.send.failed','broadcast','alias','error','text/event-stream','running','server','\x20network_id=','<unknown>','data:\x20','3808920QnqOpZ','task.send.start','32233120ZBxyIb','to_alias','slice','reply','body','<pending>','decode','application/json','idle','2078397gSCuTG','getReader','content','task.expired','resumeId','\x20from=','text','send','missing_task_id','sseAbort','heartbeatTimer','task.ack','s...','\x20duration_ms=','getAllStatus','CommHub\x20response\x20omitted\x20task_id','result'];a0_0x4a19=function(){return _0x4f082f;};return a0_0x4a19();}var F=$;export{F as default,$ as CommHub};
1
+ const a0_0x2ae722=a0_0x2925;(function(_0x235250,_0x66340f){const _0x503e46=a0_0x2925,_0x52cf0a=_0x235250();while(!![]){try{const _0x47e17b=parseInt(_0x503e46(0x163))/0x1+-parseInt(_0x503e46(0x147))/0x2+parseInt(_0x503e46(0x19c))/0x3*(-parseInt(_0x503e46(0x17b))/0x4)+-parseInt(_0x503e46(0x14b))/0x5+parseInt(_0x503e46(0x17d))/0x6*(parseInt(_0x503e46(0x13e))/0x7)+-parseInt(_0x503e46(0x173))/0x8*(parseInt(_0x503e46(0x141))/0x9)+parseInt(_0x503e46(0x18d))/0xa;if(_0x47e17b===_0x66340f)break;else _0x52cf0a['push'](_0x52cf0a['shift']());}catch(_0x3e2e50){_0x52cf0a['push'](_0x52cf0a['shift']());}}}(a0_0x4856,0x5c92d));import{EventEmitter as a0_0x5b4647}from'events';import{hostname as a0_0x2bba5e}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x332912,_0x217727)=>(_0x332912??_0x217727)[a0_0x2ae722(0x175)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x3cf98b){const _0x396f66=a0_0x2ae722;return(_0x3cf98b instanceof Error?_0x3cf98b['message']:String(_0x3cf98b??_0x396f66(0x150)))[_0x396f66(0x175)](K,_0x396f66(0x19f))[_0x396f66(0x175)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x396f66(0x13d)](0x0,0xf0);}function a0_0x2925(_0x50f325,_0x26329f){_0x50f325=_0x50f325-0x126;const _0x485640=a0_0x4856();let _0x2925bb=_0x485640[_0x50f325];return _0x2925bb;}function a0_0x4856(){const _0x38242c=['sleep','Authorization','normal','560095JEcLIX','/events/','\x20duration_ms=','signal','\x20to=','CommHub\x20response\x20omitted\x20task_id','send_failed','/mcp','task.ack','heartbeat\x20failed:\x20','transport','task_id','sdk','reconnectDelay','url','stringify','160eDePhf','task.send.delivered','replace','POST','\x20lifecycle=','disconnect','heartbeatInterval','network_id','72328LUrTlT','2.0','6NbNKcI','parse','connect','connectSSE','text','match','decode','status','connected','<missing>','json','Bearer\x20','name','min','messages','error','4915810Iduewc','getReader','processInbox','idle','read','data:\x20','s...','duration_ms','string','now','task.expired','heartbeatTimer','task.send.failed','catch','send_task','6PjxEey','error_code','result','[REDACTED]','split','task','\x20transport=','registered','toAlias','completed','get_inbox','from_alias','resumeId','<unknown>','lifecycle_tracking','sseAbort','alias','abort','SSE\x20reconnecting\x20in\x20','sending','message','ack_inbox','\x20error=','sdk-','parentTaskId','from_session','\x20from=','call','new_message','running','startsWith','type',']\x20[commhub:','slice','2238362vzKXip','log','body','275895eXscin','new_task','reply','missing_task_id','\x20task_id=','get_all_status','100970nKcjZB','fromAlias','tools/call','task.replied','1462560MSGmbe','broadcast','task.send.start','send_reply','content','unknown\x20error','send','toString','agent','<pending>','not_tracked','token','disconnected','getAllStatus','failed','message_id','networkId','emit','report_status','error_message','\x20parent_task_id='];a0_0x4856=function(){return _0x38242c;};return a0_0x4856();}function O(_0x15d17f,_0x1d3bdb=process.env.ANET_TASK_TRACE_FORMAT===a0_0x2ae722(0x187)){const _0x4c62b7=a0_0x2ae722;if(_0x1d3bdb)return JSON[_0x4c62b7(0x172)](_0x15d17f);let _0x37123d=L(_0x15d17f['parent_task_id'],_0x4c62b7(0x186)),_0x3c055a=L(_0x15d17f['task_id'],_0x4c62b7(0x154)),_0x3c48a3=_0x15d17f[_0x4c62b7(0x19d)]?_0x4c62b7(0x132)+_0x15d17f[_0x4c62b7(0x19d)]+':'+(_0x15d17f[_0x4c62b7(0x15e)]??''):'';return'[commhub:task]\x20'+_0x15d17f[_0x4c62b7(0x184)]+_0x4c62b7(0x136)+L(_0x15d17f[_0x4c62b7(0x127)],_0x4c62b7(0x129))+_0x4c62b7(0x167)+L(_0x15d17f['to_alias'],_0x4c62b7(0x129))+_0x4c62b7(0x145)+_0x3c055a+_0x4c62b7(0x15f)+_0x37123d+'\x20network_id='+L(_0x15d17f[_0x4c62b7(0x17a)],_0x4c62b7(0x129))+_0x4c62b7(0x1a2)+_0x15d17f[_0x4c62b7(0x16d)]+_0x4c62b7(0x165)+_0x15d17f[_0x4c62b7(0x194)]+_0x4c62b7(0x177)+_0x15d17f[_0x4c62b7(0x12a)]+_0x3c48a3;}function U(_0x47b25f){const _0x124ffb=a0_0x2ae722;return{'event':{'sending':_0x124ffb(0x14d),'delivered':_0x124ffb(0x174),'failed':_0x124ffb(0x199),'acked':_0x124ffb(0x16b),'started':'task.started','replied':_0x124ffb(0x14a),'expired':_0x124ffb(0x197)}[_0x47b25f[_0x124ffb(0x184)]],..._0x47b25f};}function j(_0x46e59b){const _0x34575f=a0_0x2ae722;let _0x117985=_0x46e59b?.[_0x34575f(0x16e)]||_0x46e59b?.[_0x34575f(0x15a)]||_0x46e59b?.['id'];if(_0x117985)return String(_0x117985);let _0x48cc1e=_0x46e59b?.[_0x34575f(0x14f)]?.[0x0]?.[_0x34575f(0x181)];if(typeof _0x48cc1e!==_0x34575f(0x195))return null;try{let _0x46c190=JSON['parse'](_0x48cc1e);return _0x46c190?.[_0x34575f(0x16e)]||_0x46c190?.[_0x34575f(0x15a)]||_0x46c190?.['id']||null;}catch{return null;}}async function X(_0x42c791,_0x4e3a0c){const _0x33d2b0=a0_0x2ae722;let _0x2b06f3=_0x4e3a0c['now']??Date[_0x33d2b0(0x196)],_0x78dbf4=_0x2b06f3(),_0xbe356a=(_0x31080e,_0x319726,_0x42f9fc,_0x486cbf)=>{const _0x488e13=_0x33d2b0;_0x4e3a0c['log'](O(U({'from_alias':_0x42c791[_0x488e13(0x148)],'to_alias':_0x42c791[_0x488e13(0x1a4)],'task_id':_0x319726,'parent_task_id':_0x42c791[_0x488e13(0x134)],'network_id':_0x42c791[_0x488e13(0x15b)],'transport':_0x42c791['transport'],'status':_0x31080e,'duration_ms':_0x2b06f3()-_0x78dbf4,'lifecycle_tracking':_0x42c791['lifecycleTracking'],..._0x42f9fc!==void 0x0?{'error_code':_0x486cbf||_0x488e13(0x169),'error_message':N(_0x42f9fc)}:{}})));};_0xbe356a(_0x33d2b0(0x12f),null);try{let _0x3a26bd=await _0x4e3a0c[_0x33d2b0(0x151)](),_0x2f4e74=j(_0x3a26bd);if(_0x2f4e74)_0xbe356a('delivered',_0x2f4e74);else{if(_0x3a26bd?.['ok']===!0x1||_0x3a26bd?.[_0x33d2b0(0x18c)])_0xbe356a(_0x33d2b0(0x159),_0x2f4e74,_0x3a26bd?.[_0x33d2b0(0x18c)]||'CommHub\x20rejected\x20task','send_rejected');else _0xbe356a(_0x33d2b0(0x159),null,_0x33d2b0(0x168),_0x33d2b0(0x144));}return _0x3a26bd;}catch(_0x106895){throw _0xbe356a(_0x33d2b0(0x159),null,_0x106895,_0x33d2b0(0x169)),_0x106895;}}async function Y(_0x1db13d,_0xbe1276){const _0x8f63d0=a0_0x2ae722;return X({'fromAlias':_0x1db13d['fromAlias'],'toAlias':_0x1db13d[_0x8f63d0(0x12c)],'parentTaskId':_0x1db13d[_0x8f63d0(0x134)]||null,'networkId':_0x1db13d['networkId']||null,'transport':'mcp_http','lifecycleTracking':_0x8f63d0(0x155)},_0xbe1276);}class $ extends a0_0x5b4647{['url'];[a0_0x2ae722(0x12c)];[a0_0x2ae722(0x156)];['agent'];[a0_0x2ae722(0x128)];[a0_0x2ae722(0x179)];[a0_0x2ae722(0x170)];[a0_0x2ae722(0x198)];[a0_0x2ae722(0x12b)];['running']=!0x1;constructor(_0x382b75){const _0x4eb987=a0_0x2ae722;super();if(this[_0x4eb987(0x171)]=_0x382b75[_0x4eb987(0x171)]['replace'](/\/$/,''),this[_0x4eb987(0x12c)]=_0x382b75[_0x4eb987(0x12c)],this['token']=_0x382b75[_0x4eb987(0x156)],this[_0x4eb987(0x153)]=_0x382b75[_0x4eb987(0x153)]||_0x4eb987(0x16f),this['resumeId']=_0x4eb987(0x133)+_0x382b75[_0x4eb987(0x12c)]+'-'+Date[_0x4eb987(0x196)]()[_0x4eb987(0x152)](0x24),this[_0x4eb987(0x179)]=_0x382b75['heartbeatInterval']??0x2bf20,this[_0x4eb987(0x170)]=_0x382b75[_0x4eb987(0x170)]??0xbb8,_0x382b75['autoConnect']!==!0x1)this[_0x4eb987(0x17f)]();}['log'](_0x15ed98){const _0x23b6e3=a0_0x2ae722;console['log']('['+new Date()['toTimeString']()[_0x23b6e3(0x13d)](0x0,0x8)+_0x23b6e3(0x13c)+this[_0x23b6e3(0x12c)]+']\x20'+_0x15ed98);}async[a0_0x2ae722(0x137)](_0x4db90c,_0x119f10){const _0x2d4ae1=a0_0x2ae722;let _0x2ad79b={'Content-Type':'application/json','Accept':'application/json,\x20text/event-stream'};if(this['token'])_0x2ad79b[_0x2d4ae1(0x161)]=_0x2d4ae1(0x188)+this[_0x2d4ae1(0x156)];let _0x3d4373=await(await fetch(this['url']+_0x2d4ae1(0x16a),{'method':_0x2d4ae1(0x176),'headers':_0x2ad79b,'body':JSON['stringify']({'jsonrpc':_0x2d4ae1(0x17c),'id':Date['now'](),'method':_0x2d4ae1(0x149),'params':{'name':_0x4db90c,'arguments':_0x119f10}})}))[_0x2d4ae1(0x181)](),_0x5339f8=_0x3d4373[_0x2d4ae1(0x182)](/data: (.+)/),_0x3396fa=_0x5339f8?JSON[_0x2d4ae1(0x17e)](_0x5339f8[0x1]):JSON[_0x2d4ae1(0x17e)](_0x3d4373),_0x2fcdbd=_0x3396fa?.[_0x2d4ae1(0x19e)]?.['content']?.[0x0]?.[_0x2d4ae1(0x181)];return _0x2fcdbd?JSON[_0x2d4ae1(0x17e)](_0x2fcdbd):_0x3396fa;}async[a0_0x2ae722(0x17f)](){const _0x317362=a0_0x2ae722;if(this[_0x317362(0x139)])return;this[_0x317362(0x139)]=!0x0,await this['status'](_0x317362(0x190)),this[_0x317362(0x13f)](_0x317362(0x1a3)),this[_0x317362(0x198)]=setInterval(()=>{const _0x16c07d=_0x317362;this['status'](_0x16c07d(0x190))[_0x16c07d(0x19a)](_0x76bb1b=>this[_0x16c07d(0x13f)](_0x16c07d(0x16c)+_0x76bb1b['message']));},this[_0x317362(0x179)]),this['connectSSE']();}async[a0_0x2ae722(0x178)](){const _0x499078=a0_0x2ae722;if(this[_0x499078(0x139)]=!0x1,this[_0x499078(0x12b)]?.[_0x499078(0x12d)](),this[_0x499078(0x198)])clearInterval(this[_0x499078(0x198)]);await this[_0x499078(0x184)]('offline')['catch'](()=>{}),this[_0x499078(0x13f)]('disconnected');}async['send'](_0xcd9ed,_0x140e72,_0x3f1442=a0_0x2ae722(0x162)){const _0x3649c8=a0_0x2ae722;return Y({'alias':_0xcd9ed,'fromAlias':this[_0x3649c8(0x12c)]},{'log':_0x36c0e8=>console[_0x3649c8(0x13f)](_0x36c0e8),'send':()=>this[_0x3649c8(0x137)](_0x3649c8(0x19b),{'alias':_0xcd9ed,'task':_0x140e72,'priority':_0x3f1442,'from_session':this[_0x3649c8(0x12c)]})});}async[a0_0x2ae722(0x130)](_0x428b16,_0x5ba99d){const _0x58effd=a0_0x2ae722;return this[_0x58effd(0x137)]('send_message',{'alias':_0x428b16,'message':_0x5ba99d,'from_session':this[_0x58effd(0x12c)]});}async[a0_0x2ae722(0x143)](_0xae8b11,_0x47f426,_0x55234b=a0_0x2ae722(0x1a5)){const _0xa86521=a0_0x2ae722;return this['call'](_0xa86521(0x14e),{'in_reply_to':_0xae8b11,'text':_0x47f426,'status':_0x55234b});}async['status'](_0x171006,_0x393fee){const _0xd89338=a0_0x2ae722;return this['call'](_0xd89338(0x15d),{'resume_id':this[_0xd89338(0x128)],'alias':this[_0xd89338(0x12c)],'status':_0x171006,'server':a0_0x2bba5e(),'hostname':a0_0x2bba5e(),'agent':this['agent'],'project_dir':process['cwd'](),..._0x393fee});}async[a0_0x2ae722(0x158)](){const _0x5049ca=a0_0x2ae722;return this[_0x5049ca(0x137)](_0x5049ca(0x146),{});}async[a0_0x2ae722(0x14c)](_0x2e8253,_0xf28c57){const _0x261271=a0_0x2ae722;return this[_0x261271(0x137)](_0x261271(0x14c),{'message':_0x2e8253,'filter_server':_0xf28c57?.['server'],'filter_status':_0xf28c57?.['status']});}async[a0_0x2ae722(0x180)](){const _0x3fcb79=a0_0x2ae722;let _0x152822=encodeURIComponent(this[_0x3fcb79(0x12c)]),_0x388495=this['url']+_0x3fcb79(0x164)+_0x152822,_0x2419c2=this[_0x3fcb79(0x170)];while(this['running']){try{this[_0x3fcb79(0x12b)]=new AbortController();let _0x2ecfc2={'Accept':'text/event-stream'};if(this[_0x3fcb79(0x156)])_0x2ecfc2[_0x3fcb79(0x161)]='Bearer\x20'+this['token'];let _0x38ab48=await fetch(_0x388495,{'headers':_0x2ecfc2,'signal':this['sseAbort'][_0x3fcb79(0x166)]});if(!_0x38ab48['ok']||!_0x38ab48[_0x3fcb79(0x140)]){this[_0x3fcb79(0x13f)]('SSE\x20failed:\x20'+_0x38ab48['status']),await this[_0x3fcb79(0x160)](_0x2419c2),_0x2419c2=Math[_0x3fcb79(0x18a)](_0x2419c2*1.5,0xea60);continue;}_0x2419c2=this[_0x3fcb79(0x170)];let _0x3248a9=_0x38ab48['body'][_0x3fcb79(0x18e)](),_0x2dc81e=new TextDecoder(),_0x135d75='';while(this['running']){let {done:_0x18ce6f,value:_0x30721b}=await _0x3248a9[_0x3fcb79(0x191)]();if(_0x18ce6f)break;_0x135d75+=_0x2dc81e[_0x3fcb79(0x183)](_0x30721b,{'stream':!0x0});let _0x16db81=_0x135d75[_0x3fcb79(0x1a0)]('\x0a');_0x135d75=_0x16db81['pop']()||'';for(let _0x293db3 of _0x16db81){if(!_0x293db3[_0x3fcb79(0x13a)](_0x3fcb79(0x192)))continue;try{let _0x2e3964=JSON[_0x3fcb79(0x17e)](_0x293db3[_0x3fcb79(0x13d)](0x6));if(_0x2e3964[_0x3fcb79(0x13b)]===_0x3fcb79(0x185)){this[_0x3fcb79(0x13f)]('SSE\x20connected'),this['emit'](_0x3fcb79(0x185));continue;}if(_0x2e3964[_0x3fcb79(0x13b)]===_0x3fcb79(0x142)||_0x2e3964['type']===_0x3fcb79(0x138)||_0x2e3964['type']===_0x3fcb79(0x14c))await this[_0x3fcb79(0x18f)]();}catch{}}}}catch(_0x2f10d2){if(_0x2f10d2[_0x3fcb79(0x189)]==='AbortError')break;this['emit']('error',_0x2f10d2),this[_0x3fcb79(0x13f)]('SSE\x20error:\x20'+_0x2f10d2[_0x3fcb79(0x130)]);}if(this[_0x3fcb79(0x139)])this[_0x3fcb79(0x15c)](_0x3fcb79(0x157)),this[_0x3fcb79(0x13f)](_0x3fcb79(0x12e)+_0x2419c2/0x3e8+_0x3fcb79(0x193)),await this[_0x3fcb79(0x160)](_0x2419c2),_0x2419c2=Math[_0x3fcb79(0x18a)](_0x2419c2*1.5,0xea60);}}async[a0_0x2ae722(0x18f)](){const _0x18addf=a0_0x2ae722;try{let _0x12d988=(await this[_0x18addf(0x137)](_0x18addf(0x126),{'alias':this['alias'],'limit':0xa}))?.[_0x18addf(0x18b)]||[];for(let _0x306c6f of _0x12d988)await this['call'](_0x18addf(0x131),{'alias':this[_0x18addf(0x12c)],'message_id':_0x306c6f['id']}),this['log']('←\x20'+_0x306c6f[_0x18addf(0x135)]+':\x20'+_0x306c6f[_0x18addf(0x14f)][_0x18addf(0x13d)](0x0,0x3c)),this[_0x18addf(0x15c)](_0x18addf(0x1a1),_0x306c6f),this['emit'](_0x18addf(0x130),_0x306c6f);}catch(_0xd96aa2){this[_0x18addf(0x13f)]('inbox\x20error:\x20'+_0xd96aa2[_0x18addf(0x130)]);}}[a0_0x2ae722(0x160)](_0x5df466){return new Promise(_0x3e6d7c=>setTimeout(_0x3e6d7c,_0x5df466));}}var F=$;export{F as default,$ as CommHub};