@sleep2agi/agent-network 2.3.0-preview.61 → 2.3.0-preview.62

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_0x8fd1a4=a0_0x45e1;(function(_0x2f5736,_0xdccac7){const _0x2b656c=a0_0x45e1,_0x372ef1=_0x2f5736();while(!![]){try{const _0x4908ae=parseInt(_0x2b656c(0x110))/0x1+parseInt(_0x2b656c(0x140))/0x2+-parseInt(_0x2b656c(0x102))/0x3+-parseInt(_0x2b656c(0x111))/0x4*(-parseInt(_0x2b656c(0x152))/0x5)+parseInt(_0x2b656c(0x13a))/0x6*(-parseInt(_0x2b656c(0x161))/0x7)+parseInt(_0x2b656c(0x133))/0x8+parseInt(_0x2b656c(0x168))/0x9*(-parseInt(_0x2b656c(0x15f))/0xa);if(_0x4908ae===_0xdccac7)break;else _0x372ef1['push'](_0x372ef1['shift']());}catch(_0x35d864){_0x372ef1['push'](_0x372ef1['shift']());}}}(a0_0x1527,0x868e8));import{EventEmitter as a0_0x524018}from'events';import{hostname as a0_0x6a640d}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x350399,_0x39b4b0)=>(_0x350399??_0x39b4b0)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x8fd1a4(0x124)](0x0,0xf0);function N(_0x56d985){const _0x152dfa=a0_0x8fd1a4;return(_0x56d985 instanceof Error?_0x56d985['message']:String(_0x56d985??_0x152dfa(0x147)))['replace'](K,_0x152dfa(0x130))[_0x152dfa(0xf9)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function a0_0x45e1(_0x33692b,_0x1e6f62){_0x33692b=_0x33692b-0xf0;const _0x152716=a0_0x1527();let _0x45e1b1=_0x152716[_0x33692b];return _0x45e1b1;}function O(_0x55263c,_0x4f77f5=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x56fbbb=a0_0x8fd1a4;if(_0x4f77f5)return JSON[_0x56fbbb(0xf3)](_0x55263c);let _0x11632d=L(_0x55263c[_0x56fbbb(0x141)],_0x56fbbb(0x114)),_0x57ceea=L(_0x55263c[_0x56fbbb(0x158)],_0x56fbbb(0x16c)),_0x1d24d0=_0x55263c[_0x56fbbb(0x126)]?'\x20error='+_0x55263c['error_code']+':'+(_0x55263c['error_message']??''):'';return _0x56fbbb(0x148)+_0x55263c['status']+'\x20from='+L(_0x55263c[_0x56fbbb(0x139)],_0x56fbbb(0x132))+_0x56fbbb(0xf4)+L(_0x55263c[_0x56fbbb(0x101)],_0x56fbbb(0x132))+_0x56fbbb(0x149)+_0x57ceea+_0x56fbbb(0xf0)+_0x11632d+_0x56fbbb(0x125)+L(_0x55263c['network_id'],_0x56fbbb(0x132))+_0x56fbbb(0x105)+_0x55263c[_0x56fbbb(0x153)]+_0x56fbbb(0x142)+_0x55263c[_0x56fbbb(0xfc)]+_0x56fbbb(0x12b)+_0x55263c[_0x56fbbb(0x103)]+_0x1d24d0;}function U(_0x1a5911){const _0x218321=a0_0x8fd1a4;return{'event':{'sending':_0x218321(0x15d),'delivered':_0x218321(0xfa),'failed':_0x218321(0x163),'acked':_0x218321(0x104),'started':_0x218321(0x10f),'replied':_0x218321(0x121),'expired':_0x218321(0x11d)}[_0x1a5911[_0x218321(0x157)]],..._0x1a5911};}function j(_0x5b95ab){const _0x4d61e4=a0_0x8fd1a4;let _0x37d096=_0x5b95ab?.[_0x4d61e4(0x158)]||_0x5b95ab?.['message_id']||_0x5b95ab?.['id'];if(_0x37d096)return String(_0x37d096);let _0x3531e1=_0x5b95ab?.[_0x4d61e4(0x11a)]?.[0x0]?.[_0x4d61e4(0x144)];if(typeof _0x3531e1!==_0x4d61e4(0x11f))return null;try{let _0x7c5aab=JSON[_0x4d61e4(0x137)](_0x3531e1);return _0x7c5aab?.[_0x4d61e4(0x158)]||_0x7c5aab?.['message_id']||_0x7c5aab?.['id']||null;}catch{return null;}}async function X(_0x5f5422,_0x54a195){const _0x8fd422=a0_0x8fd1a4;let _0x32e191=_0x54a195[_0x8fd422(0x117)]??Date[_0x8fd422(0x117)],_0x563352=_0x32e191(),_0x3ff01f=(_0x15fc14,_0x1a2ac4,_0x44c42f,_0x18a7a9)=>{const _0x5ef59e=_0x8fd422;_0x54a195[_0x5ef59e(0x123)](O(U({'from_alias':_0x5f5422[_0x5ef59e(0x12f)],'to_alias':_0x5f5422[_0x5ef59e(0x15b)],'task_id':_0x1a2ac4,'parent_task_id':_0x5f5422[_0x5ef59e(0x13c)],'network_id':_0x5f5422[_0x5ef59e(0xfe)],'transport':_0x5f5422[_0x5ef59e(0x153)],'status':_0x15fc14,'duration_ms':_0x32e191()-_0x563352,'lifecycle_tracking':_0x5f5422['lifecycleTracking'],..._0x44c42f!==void 0x0?{'error_code':_0x18a7a9||_0x5ef59e(0x118),'error_message':N(_0x44c42f)}:{}})));};_0x3ff01f(_0x8fd422(0x112),null);try{let _0x60e230=await _0x54a195[_0x8fd422(0x14e)](),_0x136d88=j(_0x60e230);if(_0x136d88)_0x3ff01f('delivered',_0x136d88);else{if(_0x60e230?.['ok']===!0x1||_0x60e230?.[_0x8fd422(0x12c)])_0x3ff01f(_0x8fd422(0xf1),_0x136d88,_0x60e230?.['error']||_0x8fd422(0x134),_0x8fd422(0xf7));else _0x3ff01f(_0x8fd422(0xf1),null,'CommHub\x20response\x20omitted\x20task_id',_0x8fd422(0x169));}return _0x60e230;}catch(_0x178da9){throw _0x3ff01f(_0x8fd422(0xf1),null,_0x178da9,'send_failed'),_0x178da9;}}async function Y(_0x3514d7,_0x44cf02){const _0x32e7f8=a0_0x8fd1a4;return X({'fromAlias':_0x3514d7[_0x32e7f8(0x12f)],'toAlias':_0x3514d7[_0x32e7f8(0xff)],'parentTaskId':_0x3514d7[_0x32e7f8(0x13c)]||null,'networkId':_0x3514d7[_0x32e7f8(0xfe)]||null,'transport':_0x32e7f8(0x16d),'lifecycleTracking':'not_tracked'},_0x44cf02);}class $ extends a0_0x524018{[a0_0x8fd1a4(0x135)];['alias'];[a0_0x8fd1a4(0x167)];[a0_0x8fd1a4(0x10b)];['resumeId'];[a0_0x8fd1a4(0x11c)];['reconnectDelay'];[a0_0x8fd1a4(0xf8)];['sseAbort'];[a0_0x8fd1a4(0x164)]=!0x1;constructor(_0x3b6cbd){const _0x930e2d=a0_0x8fd1a4;super();if(this[_0x930e2d(0x135)]=_0x3b6cbd[_0x930e2d(0x135)][_0x930e2d(0xf9)](/\/$/,''),this['alias']=_0x3b6cbd[_0x930e2d(0xff)],this[_0x930e2d(0x167)]=_0x3b6cbd['token'],this[_0x930e2d(0x10b)]=_0x3b6cbd[_0x930e2d(0x10b)]||'sdk',this[_0x930e2d(0x129)]=_0x930e2d(0x131)+_0x3b6cbd[_0x930e2d(0xff)]+'-'+Date[_0x930e2d(0x117)]()[_0x930e2d(0x14a)](0x24),this[_0x930e2d(0x11c)]=_0x3b6cbd[_0x930e2d(0x11c)]??0x2bf20,this[_0x930e2d(0x165)]=_0x3b6cbd[_0x930e2d(0x165)]??0xbb8,_0x3b6cbd[_0x930e2d(0x162)]!==!0x1)this[_0x930e2d(0x10c)]();}['log'](_0x1c7064){const _0x5a99da=a0_0x8fd1a4;console[_0x5a99da(0x123)]('['+new Date()[_0x5a99da(0x13f)]()[_0x5a99da(0x124)](0x0,0x8)+_0x5a99da(0x109)+this[_0x5a99da(0xff)]+']\x20'+_0x1c7064);}async['call'](_0x522dc9,_0x1dedb2){const _0xd62c3c=a0_0x8fd1a4;let _0x39bb2a={'Content-Type':_0xd62c3c(0x10e),'Accept':'application/json,\x20text/event-stream'};if(this[_0xd62c3c(0x167)])_0x39bb2a[_0xd62c3c(0x11e)]=_0xd62c3c(0x14f)+this[_0xd62c3c(0x167)];let _0x1fe390=await(await fetch(this['url']+_0xd62c3c(0x108),{'method':_0xd62c3c(0xf5),'headers':_0x39bb2a,'body':JSON['stringify']({'jsonrpc':'2.0','id':Date[_0xd62c3c(0x117)](),'method':_0xd62c3c(0x11b),'params':{'name':_0x522dc9,'arguments':_0x1dedb2}})}))['text'](),_0x819515=_0x1fe390[_0xd62c3c(0x145)](/data: (.+)/),_0x4646fb=_0x819515?JSON[_0xd62c3c(0x137)](_0x819515[0x1]):JSON[_0xd62c3c(0x137)](_0x1fe390),_0x496ae5=_0x4646fb?.['result']?.[_0xd62c3c(0x11a)]?.[0x0]?.[_0xd62c3c(0x144)];return _0x496ae5?JSON[_0xd62c3c(0x137)](_0x496ae5):_0x4646fb;}async[a0_0x8fd1a4(0x10c)](){const _0x53a6b8=a0_0x8fd1a4;if(this['running'])return;this[_0x53a6b8(0x164)]=!0x0,await this[_0x53a6b8(0x157)](_0x53a6b8(0x150)),this['log'](_0x53a6b8(0x136)),this[_0x53a6b8(0xf8)]=setInterval(()=>{const _0x3eb51f=_0x53a6b8;this[_0x3eb51f(0x157)]('idle')[_0x3eb51f(0x146)](_0x53d5f8=>this[_0x3eb51f(0x123)]('heartbeat\x20failed:\x20'+_0x53d5f8[_0x3eb51f(0x16a)]));},this[_0x53a6b8(0x11c)]),this[_0x53a6b8(0x156)]();}async[a0_0x8fd1a4(0x115)](){const _0x4a3ec0=a0_0x8fd1a4;if(this[_0x4a3ec0(0x164)]=!0x1,this[_0x4a3ec0(0x15c)]?.[_0x4a3ec0(0xfd)](),this['heartbeatTimer'])clearInterval(this[_0x4a3ec0(0xf8)]);await this['status'](_0x4a3ec0(0x107))[_0x4a3ec0(0x146)](()=>{}),this[_0x4a3ec0(0x123)](_0x4a3ec0(0x120));}async[a0_0x8fd1a4(0x14e)](_0x2c7a5d,_0x2c9121,_0x254879=a0_0x8fd1a4(0x10d)){const _0x4633b3=a0_0x8fd1a4;return Y({'alias':_0x2c7a5d,'fromAlias':this[_0x4633b3(0xff)]},{'log':_0x338cd6=>console[_0x4633b3(0x123)](_0x338cd6),'send':()=>this[_0x4633b3(0x116)](_0x4633b3(0x16b),{'alias':_0x2c7a5d,'task':_0x2c9121,'priority':_0x254879,'from_session':this[_0x4633b3(0xff)]})});}async[a0_0x8fd1a4(0x16a)](_0x4b09a5,_0x931840){const _0x374718=a0_0x8fd1a4;return this[_0x374718(0x116)](_0x374718(0x13d),{'alias':_0x4b09a5,'message':_0x931840,'from_session':this['alias']});}async[a0_0x8fd1a4(0x10a)](_0x44cd9d,_0x32028b,_0x292f14='completed'){const _0xfffd16=a0_0x8fd1a4;return this[_0xfffd16(0x116)](_0xfffd16(0xf2),{'in_reply_to':_0x44cd9d,'text':_0x32028b,'status':_0x292f14});}async[a0_0x8fd1a4(0x157)](_0x208bd8,_0x5cc4e2){const _0x7f5f7=a0_0x8fd1a4;return this[_0x7f5f7(0x116)](_0x7f5f7(0x119),{'resume_id':this[_0x7f5f7(0x129)],'alias':this[_0x7f5f7(0xff)],'status':_0x208bd8,'server':a0_0x6a640d(),'hostname':a0_0x6a640d(),'agent':this[_0x7f5f7(0x10b)],'project_dir':process['cwd'](),..._0x5cc4e2});}async['getAllStatus'](){const _0x3473ff=a0_0x8fd1a4;return this[_0x3473ff(0x116)]('get_all_status',{});}async['broadcast'](_0x2472ee,_0x16900d){const _0x2f2cf=a0_0x8fd1a4;return this[_0x2f2cf(0x116)]('broadcast',{'message':_0x2472ee,'filter_server':_0x16900d?.['server'],'filter_status':_0x16900d?.[_0x2f2cf(0x157)]});}async['connectSSE'](){const _0x3e8d62=a0_0x8fd1a4;let _0x4ee461=encodeURIComponent(this[_0x3e8d62(0xff)]),_0x4903c0=this['url']+_0x3e8d62(0x138)+_0x4ee461,_0x10b2a5=this['reconnectDelay'];while(this['running']){try{this['sseAbort']=new AbortController();let _0x25ae34={'Accept':_0x3e8d62(0x13b)};if(this[_0x3e8d62(0x167)])_0x25ae34['Authorization']='Bearer\x20'+this[_0x3e8d62(0x167)];let _0x5538de=await fetch(_0x4903c0,{'headers':_0x25ae34,'signal':this[_0x3e8d62(0x15c)][_0x3e8d62(0x12d)]});if(!_0x5538de['ok']||!_0x5538de[_0x3e8d62(0x13e)]){this['log']('SSE\x20failed:\x20'+_0x5538de[_0x3e8d62(0x157)]),await this[_0x3e8d62(0x100)](_0x10b2a5),_0x10b2a5=Math[_0x3e8d62(0x166)](_0x10b2a5*1.5,0xea60);continue;}_0x10b2a5=this[_0x3e8d62(0x165)];let _0x4ea403=_0x5538de[_0x3e8d62(0x13e)][_0x3e8d62(0x160)](),_0x2491ab=new TextDecoder(),_0x16d5b0='';while(this['running']){let {done:_0x18052e,value:_0x535023}=await _0x4ea403[_0x3e8d62(0x14c)]();if(_0x18052e)break;_0x16d5b0+=_0x2491ab['decode'](_0x535023,{'stream':!0x0});let _0x2a14b6=_0x16d5b0[_0x3e8d62(0x15e)]('\x0a');_0x16d5b0=_0x2a14b6[_0x3e8d62(0x143)]()||'';for(let _0x5a23fb of _0x2a14b6){if(!_0x5a23fb[_0x3e8d62(0x14b)](_0x3e8d62(0x122)))continue;try{let _0x2a21dc=JSON['parse'](_0x5a23fb[_0x3e8d62(0x124)](0x6));if(_0x2a21dc['type']===_0x3e8d62(0x127)){this[_0x3e8d62(0x123)](_0x3e8d62(0x155)),this['emit'](_0x3e8d62(0x127));continue;}if(_0x2a21dc[_0x3e8d62(0x12e)]==='new_task'||_0x2a21dc[_0x3e8d62(0x12e)]===_0x3e8d62(0x128)||_0x2a21dc[_0x3e8d62(0x12e)]==='broadcast')await this[_0x3e8d62(0x12a)]();}catch{}}}}catch(_0x51c1f6){if(_0x51c1f6[_0x3e8d62(0x106)]==='AbortError')break;this[_0x3e8d62(0x151)](_0x3e8d62(0x12c),_0x51c1f6),this[_0x3e8d62(0x123)](_0x3e8d62(0x159)+_0x51c1f6[_0x3e8d62(0x16a)]);}if(this[_0x3e8d62(0x164)])this[_0x3e8d62(0x151)](_0x3e8d62(0x120)),this[_0x3e8d62(0x123)](_0x3e8d62(0x154)+_0x10b2a5/0x3e8+_0x3e8d62(0xf6)),await this[_0x3e8d62(0x100)](_0x10b2a5),_0x10b2a5=Math[_0x3e8d62(0x166)](_0x10b2a5*1.5,0xea60);}}async['processInbox'](){const _0x5be5e3=a0_0x8fd1a4;try{let _0x40a4a9=(await this[_0x5be5e3(0x116)](_0x5be5e3(0x113),{'alias':this[_0x5be5e3(0xff)],'limit':0xa}))?.[_0x5be5e3(0xfb)]||[];for(let _0x66e67c of _0x40a4a9)await this[_0x5be5e3(0x116)]('ack_inbox',{'alias':this[_0x5be5e3(0xff)],'message_id':_0x66e67c['id']}),this[_0x5be5e3(0x123)]('←\x20'+_0x66e67c[_0x5be5e3(0x14d)]+':\x20'+_0x66e67c[_0x5be5e3(0x11a)]['slice'](0x0,0x3c)),this[_0x5be5e3(0x151)](_0x5be5e3(0x15a),_0x66e67c),this[_0x5be5e3(0x151)]('message',_0x66e67c);}catch(_0x269bb7){this[_0x5be5e3(0x123)]('inbox\x20error:\x20'+_0x269bb7['message']);}}[a0_0x8fd1a4(0x100)](_0x1316e3){return new Promise(_0x553b84=>setTimeout(_0x553b84,_0x1316e3));}}var F=$;export{F as default,$ as CommHub};function a0_0x1527(){const _0x20185e=['task_id','SSE\x20error:\x20','task','toAlias','sseAbort','task.send.start','split','2870SKiNIi','getReader','3288229UZcICW','autoConnect','task.send.failed','running','reconnectDelay','min','token','19071KSSlTX','missing_task_id','message','send_task','<pending>','mcp_http','\x20parent_task_id=','failed','send_reply','stringify','\x20to=','POST','s...','send_rejected','heartbeatTimer','replace','task.send.delivered','messages','duration_ms','abort','networkId','alias','sleep','to_alias','27753yytbVt','lifecycle_tracking','task.ack','\x20transport=','name','offline','/mcp',']\x20[commhub:','reply','agent','connect','normal','application/json','task.started','1087433KktLNA','180gZyMyY','sending','get_inbox','<missing>','disconnect','call','now','send_failed','report_status','content','tools/call','heartbeatInterval','task.expired','Authorization','string','disconnected','task.replied','data:\x20','log','slice','\x20network_id=','error_code','connected','new_message','resumeId','processInbox','\x20lifecycle=','error','signal','type','fromAlias','[REDACTED]','sdk-','<unknown>','1038872dAKRGv','CommHub\x20rejected\x20task','url','registered','parse','/events/','from_alias','12MSnFsB','text/event-stream','parentTaskId','send_message','body','toTimeString','297670EbqfHe','parent_task_id','\x20duration_ms=','pop','text','match','catch','unknown\x20error','[commhub:task]\x20','\x20task_id=','toString','startsWith','read','from_session','send','Bearer\x20','idle','emit','82435hZUHbL','transport','SSE\x20reconnecting\x20in\x20','SSE\x20connected','connectSSE','status'];a0_0x1527=function(){return _0x20185e;};return a0_0x1527();}
1
+ const a0_0x5bb32a=a0_0x17d4;function a0_0x576f(){const _0x5254d5=['send_rejected','emit','reconnectDelay','1397998NbVLNq','offline','sdk','connectSSE','missing_task_id','network_id','idle','content','heartbeatTimer','unknown\x20error','[REDACTED]','string','task.expired','alias','[commhub:task]\x20','\x20error=','SSE\x20error:\x20','error','lifecycleTracking','connected','result','912762zkxnOZ','replace','sdk-','getAllStatus','registered','new_task','\x20parent_task_id=','1612384ibyRro','status','completed','fromAlias','running','not_tracked','now','60vhEOQn','type','sleep','Bearer\x20','json','task.ack','tools/call','task.started','token','task','name','reply','startsWith','resumeId','message_id','disconnected','\x20network_id=','toString','from_alias','get_all_status','text','log','<pending>','send_reply','slice','send_failed','\x20task_id=','abort','task.replied','connect','min','transport','server','3156213STOamD','pop','processInbox','\x20transport=','2.0','task.send.delivered','catch','text/event-stream','disconnect','failed','broadcast','decode','31841824URenuB','1116680JbcYgu','sseAbort','SSE\x20connected','to_alias','getReader','ack_inbox','<unknown>','toAlias','send','duration_ms','Authorization','networkId','sending','CommHub\x20rejected\x20task','AbortError','\x20to=','split','delivered','heartbeatInterval','normal','<missing>','body','message','report_status','parse','parent_task_id','stringify','send_message','get_inbox','url','task_id','task.send.start','\x20from=','654057mwzyMp','call','read','inbox\x20error:\x20','/events/','agent'];a0_0x576f=function(){return _0x5254d5;};return a0_0x576f();}(function(_0x4f5807,_0x21416a){const _0x6dacea=a0_0x17d4,_0x5aebd7=_0x4f5807();while(!![]){try{const _0x34e784=parseInt(_0x6dacea(0x173))/0x1+-parseInt(_0x6dacea(0x152))/0x2+-parseInt(_0x6dacea(0x145))/0x3+-parseInt(_0x6dacea(0x11d))/0x4+-parseInt(_0x6dacea(0x124))/0x5*(parseInt(_0x6dacea(0x116))/0x6)+parseInt(_0x6dacea(0x17c))/0x7+parseInt(_0x6dacea(0x151))/0x8;if(_0x34e784===_0x21416a)break;else _0x5aebd7['push'](_0x5aebd7['shift']());}catch(_0x4db1af){_0x5aebd7['push'](_0x5aebd7['shift']());}}}(a0_0x576f,0xf2e98));import{EventEmitter as a0_0x54f089}from'events';import{hostname as a0_0x26deb8}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x272b7f,_0x3fb318)=>(_0x272b7f??_0x3fb318)[a0_0x5bb32a(0x117)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x5bb32a(0x13c)](0x0,0xf0);function N(_0x1a8131){const _0x10cbd6=a0_0x5bb32a;return(_0x1a8131 instanceof Error?_0x1a8131['message']:String(_0x1a8131??_0x10cbd6(0x10a)))[_0x10cbd6(0x117)](K,_0x10cbd6(0x10b))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x10cbd6(0x13c)](0x0,0xf0);}function O(_0x7f0df8,_0x3b14e7=process.env.ANET_TASK_TRACE_FORMAT===a0_0x5bb32a(0x128)){const _0xb22a50=a0_0x5bb32a;if(_0x3b14e7)return JSON[_0xb22a50(0x16c)](_0x7f0df8);let _0x4ba0cc=L(_0x7f0df8[_0xb22a50(0x16b)],_0xb22a50(0x166)),_0x15bc99=L(_0x7f0df8[_0xb22a50(0x170)],_0xb22a50(0x13a)),_0x52e6b1=_0x7f0df8['error_code']?_0xb22a50(0x110)+_0x7f0df8['error_code']+':'+(_0x7f0df8['error_message']??''):'';return _0xb22a50(0x10f)+_0x7f0df8[_0xb22a50(0x11e)]+_0xb22a50(0x172)+L(_0x7f0df8[_0xb22a50(0x136)],'<unknown>')+_0xb22a50(0x161)+L(_0x7f0df8[_0xb22a50(0x155)],'<unknown>')+_0xb22a50(0x13e)+_0x15bc99+_0xb22a50(0x11c)+_0x4ba0cc+_0xb22a50(0x134)+L(_0x7f0df8[_0xb22a50(0x106)],_0xb22a50(0x158))+_0xb22a50(0x148)+_0x7f0df8[_0xb22a50(0x143)]+'\x20duration_ms='+_0x7f0df8[_0xb22a50(0x15b)]+'\x20lifecycle='+_0x7f0df8['lifecycle_tracking']+_0x52e6b1;}function U(_0x23d52c){const _0x1b89f2=a0_0x5bb32a;return{'event':{'sending':_0x1b89f2(0x171),'delivered':_0x1b89f2(0x14a),'failed':'task.send.failed','acked':_0x1b89f2(0x129),'started':_0x1b89f2(0x12b),'replied':_0x1b89f2(0x140),'expired':_0x1b89f2(0x10d)}[_0x23d52c['status']],..._0x23d52c};}function j(_0x12847c){const _0x5504c1=a0_0x5bb32a;let _0x170c53=_0x12847c?.['task_id']||_0x12847c?.[_0x5504c1(0x132)]||_0x12847c?.['id'];if(_0x170c53)return String(_0x170c53);let _0x506ec1=_0x12847c?.[_0x5504c1(0x108)]?.[0x0]?.[_0x5504c1(0x138)];if(typeof _0x506ec1!==_0x5504c1(0x10c))return null;try{let _0xe2bd8b=JSON['parse'](_0x506ec1);return _0xe2bd8b?.[_0x5504c1(0x170)]||_0xe2bd8b?.['message_id']||_0xe2bd8b?.['id']||null;}catch{return null;}}function a0_0x17d4(_0x16ef4b,_0x63810b){_0x16ef4b=_0x16ef4b-0x105;const _0x576fd5=a0_0x576f();let _0x17d462=_0x576fd5[_0x16ef4b];return _0x17d462;}async function X(_0x69c529,_0x567e74){const _0x20d575=a0_0x5bb32a;let _0x55942e=_0x567e74['now']??Date[_0x20d575(0x123)],_0x21dd2f=_0x55942e(),_0x2a328e=(_0x205712,_0x13857f,_0x32315d,_0x480595)=>{const _0x23d298=_0x20d575;_0x567e74['log'](O(U({'from_alias':_0x69c529[_0x23d298(0x120)],'to_alias':_0x69c529[_0x23d298(0x159)],'task_id':_0x13857f,'parent_task_id':_0x69c529['parentTaskId'],'network_id':_0x69c529[_0x23d298(0x15d)],'transport':_0x69c529['transport'],'status':_0x205712,'duration_ms':_0x55942e()-_0x21dd2f,'lifecycle_tracking':_0x69c529[_0x23d298(0x113)],..._0x32315d!==void 0x0?{'error_code':_0x480595||_0x23d298(0x13d),'error_message':N(_0x32315d)}:{}})));};_0x2a328e(_0x20d575(0x15e),null);try{let _0x14d5d7=await _0x567e74[_0x20d575(0x15a)](),_0x3a95ac=j(_0x14d5d7);if(_0x3a95ac)_0x2a328e(_0x20d575(0x163),_0x3a95ac);else{if(_0x14d5d7?.['ok']===!0x1||_0x14d5d7?.[_0x20d575(0x112)])_0x2a328e(_0x20d575(0x14e),_0x3a95ac,_0x14d5d7?.[_0x20d575(0x112)]||_0x20d575(0x15f),_0x20d575(0x179));else _0x2a328e(_0x20d575(0x14e),null,'CommHub\x20response\x20omitted\x20task_id',_0x20d575(0x105));}return _0x14d5d7;}catch(_0x3d86a4){throw _0x2a328e('failed',null,_0x3d86a4,_0x20d575(0x13d)),_0x3d86a4;}}async function Y(_0x216b74,_0x55ddc4){const _0x1653de=a0_0x5bb32a;return X({'fromAlias':_0x216b74[_0x1653de(0x120)],'toAlias':_0x216b74[_0x1653de(0x10e)],'parentTaskId':_0x216b74['parentTaskId']||null,'networkId':_0x216b74[_0x1653de(0x15d)]||null,'transport':'mcp_http','lifecycleTracking':_0x1653de(0x122)},_0x55ddc4);}class $ extends a0_0x54f089{[a0_0x5bb32a(0x16f)];[a0_0x5bb32a(0x10e)];[a0_0x5bb32a(0x12c)];[a0_0x5bb32a(0x178)];[a0_0x5bb32a(0x131)];[a0_0x5bb32a(0x164)];[a0_0x5bb32a(0x17b)];['heartbeatTimer'];[a0_0x5bb32a(0x153)];[a0_0x5bb32a(0x121)]=!0x1;constructor(_0x26bf74){const _0xee09d6=a0_0x5bb32a;super();if(this[_0xee09d6(0x16f)]=_0x26bf74[_0xee09d6(0x16f)][_0xee09d6(0x117)](/\/$/,''),this[_0xee09d6(0x10e)]=_0x26bf74[_0xee09d6(0x10e)],this['token']=_0x26bf74[_0xee09d6(0x12c)],this[_0xee09d6(0x178)]=_0x26bf74[_0xee09d6(0x178)]||_0xee09d6(0x17e),this[_0xee09d6(0x131)]=_0xee09d6(0x118)+_0x26bf74[_0xee09d6(0x10e)]+'-'+Date[_0xee09d6(0x123)]()[_0xee09d6(0x135)](0x24),this[_0xee09d6(0x164)]=_0x26bf74[_0xee09d6(0x164)]??0x2bf20,this[_0xee09d6(0x17b)]=_0x26bf74[_0xee09d6(0x17b)]??0xbb8,_0x26bf74['autoConnect']!==!0x1)this[_0xee09d6(0x141)]();}[a0_0x5bb32a(0x139)](_0x275f80){const _0x4ab468=a0_0x5bb32a;console[_0x4ab468(0x139)]('['+new Date()['toTimeString']()['slice'](0x0,0x8)+']\x20[commhub:'+this['alias']+']\x20'+_0x275f80);}async[a0_0x5bb32a(0x174)](_0x53c8c6,_0x5e5a73){const _0x3d30e6=a0_0x5bb32a;let _0x1f3570={'Content-Type':'application/json','Accept':'application/json,\x20text/event-stream'};if(this[_0x3d30e6(0x12c)])_0x1f3570[_0x3d30e6(0x15c)]=_0x3d30e6(0x127)+this['token'];let _0x38bb26=await(await fetch(this[_0x3d30e6(0x16f)]+'/mcp',{'method':'POST','headers':_0x1f3570,'body':JSON[_0x3d30e6(0x16c)]({'jsonrpc':_0x3d30e6(0x149),'id':Date[_0x3d30e6(0x123)](),'method':_0x3d30e6(0x12a),'params':{'name':_0x53c8c6,'arguments':_0x5e5a73}})}))[_0x3d30e6(0x138)](),_0x17744c=_0x38bb26['match'](/data: (.+)/),_0x5cb39f=_0x17744c?JSON[_0x3d30e6(0x16a)](_0x17744c[0x1]):JSON['parse'](_0x38bb26),_0x1cb2c3=_0x5cb39f?.[_0x3d30e6(0x115)]?.[_0x3d30e6(0x108)]?.[0x0]?.[_0x3d30e6(0x138)];return _0x1cb2c3?JSON[_0x3d30e6(0x16a)](_0x1cb2c3):_0x5cb39f;}async['connect'](){const _0x4488d6=a0_0x5bb32a;if(this[_0x4488d6(0x121)])return;this['running']=!0x0,await this[_0x4488d6(0x11e)](_0x4488d6(0x107)),this[_0x4488d6(0x139)](_0x4488d6(0x11a)),this[_0x4488d6(0x109)]=setInterval(()=>{const _0x2a9acc=_0x4488d6;this[_0x2a9acc(0x11e)](_0x2a9acc(0x107))[_0x2a9acc(0x14b)](_0x11a5a8=>this['log']('heartbeat\x20failed:\x20'+_0x11a5a8[_0x2a9acc(0x168)]));},this['heartbeatInterval']),this[_0x4488d6(0x17f)]();}async[a0_0x5bb32a(0x14d)](){const _0x488c11=a0_0x5bb32a;if(this[_0x488c11(0x121)]=!0x1,this['sseAbort']?.[_0x488c11(0x13f)](),this[_0x488c11(0x109)])clearInterval(this[_0x488c11(0x109)]);await this[_0x488c11(0x11e)](_0x488c11(0x17d))[_0x488c11(0x14b)](()=>{}),this[_0x488c11(0x139)](_0x488c11(0x133));}async[a0_0x5bb32a(0x15a)](_0x5c3688,_0xfa7926,_0x4e0e29=a0_0x5bb32a(0x165)){const _0x48a244=a0_0x5bb32a;return Y({'alias':_0x5c3688,'fromAlias':this[_0x48a244(0x10e)]},{'log':_0x1f9c2a=>console['log'](_0x1f9c2a),'send':()=>this[_0x48a244(0x174)]('send_task',{'alias':_0x5c3688,'task':_0xfa7926,'priority':_0x4e0e29,'from_session':this[_0x48a244(0x10e)]})});}async[a0_0x5bb32a(0x168)](_0x1145b7,_0x345324){const _0x4c1dd9=a0_0x5bb32a;return this[_0x4c1dd9(0x174)](_0x4c1dd9(0x16d),{'alias':_0x1145b7,'message':_0x345324,'from_session':this[_0x4c1dd9(0x10e)]});}async[a0_0x5bb32a(0x12f)](_0x5f2a0c,_0xa1ddc,_0x288c99=a0_0x5bb32a(0x11f)){const _0x14e868=a0_0x5bb32a;return this[_0x14e868(0x174)](_0x14e868(0x13b),{'in_reply_to':_0x5f2a0c,'text':_0xa1ddc,'status':_0x288c99});}async[a0_0x5bb32a(0x11e)](_0x4ce402,_0x602261){const _0x3614c5=a0_0x5bb32a;return this['call'](_0x3614c5(0x169),{'resume_id':this['resumeId'],'alias':this[_0x3614c5(0x10e)],'status':_0x4ce402,'server':a0_0x26deb8(),'hostname':a0_0x26deb8(),'agent':this['agent'],'project_dir':process['cwd'](),..._0x602261});}async[a0_0x5bb32a(0x119)](){const _0x374a78=a0_0x5bb32a;return this['call'](_0x374a78(0x137),{});}async[a0_0x5bb32a(0x14f)](_0x43f942,_0x195a47){const _0x3f86f5=a0_0x5bb32a;return this[_0x3f86f5(0x174)](_0x3f86f5(0x14f),{'message':_0x43f942,'filter_server':_0x195a47?.[_0x3f86f5(0x144)],'filter_status':_0x195a47?.['status']});}async[a0_0x5bb32a(0x17f)](){const _0x144d6f=a0_0x5bb32a;let _0x4f58f8=encodeURIComponent(this[_0x144d6f(0x10e)]),_0x5e7f60=this[_0x144d6f(0x16f)]+_0x144d6f(0x177)+_0x4f58f8,_0x5400af=this['reconnectDelay'];while(this[_0x144d6f(0x121)]){try{this[_0x144d6f(0x153)]=new AbortController();let _0x252802={'Accept':_0x144d6f(0x14c)};if(this['token'])_0x252802[_0x144d6f(0x15c)]=_0x144d6f(0x127)+this[_0x144d6f(0x12c)];let _0x4ec7d0=await fetch(_0x5e7f60,{'headers':_0x252802,'signal':this[_0x144d6f(0x153)]['signal']});if(!_0x4ec7d0['ok']||!_0x4ec7d0[_0x144d6f(0x167)]){this[_0x144d6f(0x139)]('SSE\x20failed:\x20'+_0x4ec7d0[_0x144d6f(0x11e)]),await this[_0x144d6f(0x126)](_0x5400af),_0x5400af=Math[_0x144d6f(0x142)](_0x5400af*1.5,0xea60);continue;}_0x5400af=this['reconnectDelay'];let _0x18d93e=_0x4ec7d0[_0x144d6f(0x167)][_0x144d6f(0x156)](),_0x2e16c7=new TextDecoder(),_0x3c41ef='';while(this['running']){let {done:_0x8ea213,value:_0x4d627b}=await _0x18d93e[_0x144d6f(0x175)]();if(_0x8ea213)break;_0x3c41ef+=_0x2e16c7[_0x144d6f(0x150)](_0x4d627b,{'stream':!0x0});let _0x5b198e=_0x3c41ef[_0x144d6f(0x162)]('\x0a');_0x3c41ef=_0x5b198e[_0x144d6f(0x146)]()||'';for(let _0xf1edd8 of _0x5b198e){if(!_0xf1edd8[_0x144d6f(0x130)]('data:\x20'))continue;try{let _0x5dd0be=JSON['parse'](_0xf1edd8[_0x144d6f(0x13c)](0x6));if(_0x5dd0be[_0x144d6f(0x125)]===_0x144d6f(0x114)){this[_0x144d6f(0x139)](_0x144d6f(0x154)),this[_0x144d6f(0x17a)](_0x144d6f(0x114));continue;}if(_0x5dd0be[_0x144d6f(0x125)]===_0x144d6f(0x11b)||_0x5dd0be['type']==='new_message'||_0x5dd0be[_0x144d6f(0x125)]==='broadcast')await this[_0x144d6f(0x147)]();}catch{}}}}catch(_0x196475){if(_0x196475[_0x144d6f(0x12e)]===_0x144d6f(0x160))break;this[_0x144d6f(0x17a)]('error',_0x196475),this['log'](_0x144d6f(0x111)+_0x196475[_0x144d6f(0x168)]);}if(this[_0x144d6f(0x121)])this[_0x144d6f(0x17a)](_0x144d6f(0x133)),this[_0x144d6f(0x139)]('SSE\x20reconnecting\x20in\x20'+_0x5400af/0x3e8+'s...'),await this[_0x144d6f(0x126)](_0x5400af),_0x5400af=Math['min'](_0x5400af*1.5,0xea60);}}async[a0_0x5bb32a(0x147)](){const _0x3608fe=a0_0x5bb32a;try{let _0x443b19=(await this[_0x3608fe(0x174)](_0x3608fe(0x16e),{'alias':this['alias'],'limit':0xa}))?.['messages']||[];for(let _0x3aab68 of _0x443b19)await this[_0x3608fe(0x174)](_0x3608fe(0x157),{'alias':this[_0x3608fe(0x10e)],'message_id':_0x3aab68['id']}),this[_0x3608fe(0x139)]('←\x20'+_0x3aab68['from_session']+':\x20'+_0x3aab68[_0x3608fe(0x108)][_0x3608fe(0x13c)](0x0,0x3c)),this[_0x3608fe(0x17a)](_0x3608fe(0x12d),_0x3aab68),this['emit'](_0x3608fe(0x168),_0x3aab68);}catch(_0x5dbaec){this[_0x3608fe(0x139)](_0x3608fe(0x176)+_0x5dbaec[_0x3608fe(0x168)]);}}[a0_0x5bb32a(0x126)](_0x494e83){return new Promise(_0x3c2cba=>setTimeout(_0x3c2cba,_0x494e83));}}var F=$;export{F as default,$ as CommHub};