@sleep2agi/agent-network 2.3.0-preview.232 → 2.3.0-preview.234

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_0x7d5828=a0_0x338f;(function(_0xd6d64a,_0x11236c){const _0x924cf1=a0_0x338f,_0x14044d=_0xd6d64a();while(!![]){try{const _0x545633=parseInt(_0x924cf1(0x13d))/0x1*(parseInt(_0x924cf1(0x176))/0x2)+-parseInt(_0x924cf1(0x193))/0x3*(-parseInt(_0x924cf1(0x132))/0x4)+parseInt(_0x924cf1(0x196))/0x5*(-parseInt(_0x924cf1(0x17f))/0x6)+-parseInt(_0x924cf1(0x12e))/0x7+-parseInt(_0x924cf1(0x189))/0x8*(-parseInt(_0x924cf1(0x154))/0x9)+-parseInt(_0x924cf1(0x142))/0xa+-parseInt(_0x924cf1(0x147))/0xb*(-parseInt(_0x924cf1(0x14c))/0xc);if(_0x545633===_0x11236c)break;else _0x14044d['push'](_0x14044d['shift']());}catch(_0x594ccd){_0x14044d['push'](_0x14044d['shift']());}}}(a0_0x18c6,0x6c81c));import{EventEmitter as a0_0x2bef32}from'events';import{hostname as a0_0x531741}from'os';function a0_0x338f(_0x2ab3c2,_0x314016){_0x2ab3c2=_0x2ab3c2-0x118;const _0x18c632=a0_0x18c6();let _0x338f6a=_0x18c632[_0x2ab3c2];return _0x338f6a;}var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x45852e,_0x296694)=>(_0x45852e??_0x296694)[a0_0x7d5828(0x13e)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x474fd4){const _0x3894b2=a0_0x7d5828;return(_0x474fd4 instanceof Error?_0x474fd4[_0x3894b2(0x18c)]:String(_0x474fd4??'unknown\x20error'))['replace'](K,_0x3894b2(0x11c))[_0x3894b2(0x13e)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x3894b2(0x194)](0x0,0xf0);}function O(_0x8ceca6,_0x4964cf=process.env.ANET_TASK_TRACE_FORMAT===a0_0x7d5828(0x177)){const _0x1bb1f0=a0_0x7d5828;if(_0x4964cf)return JSON[_0x1bb1f0(0x15a)](_0x8ceca6);let _0x4193f8=L(_0x8ceca6[_0x1bb1f0(0x165)],_0x1bb1f0(0x14b)),_0x124acd=L(_0x8ceca6[_0x1bb1f0(0x145)],'<pending>'),_0xf3da98=_0x8ceca6['error_code']?_0x1bb1f0(0x164)+_0x8ceca6[_0x1bb1f0(0x14a)]+':'+(_0x8ceca6[_0x1bb1f0(0x174)]??''):'';return'[commhub:task]\x20'+_0x8ceca6[_0x1bb1f0(0x11e)]+'\x20from='+L(_0x8ceca6[_0x1bb1f0(0x129)],_0x1bb1f0(0x160))+'\x20to='+L(_0x8ceca6[_0x1bb1f0(0x11d)],_0x1bb1f0(0x160))+_0x1bb1f0(0x16f)+_0x124acd+_0x1bb1f0(0x12f)+_0x4193f8+_0x1bb1f0(0x18a)+L(_0x8ceca6['network_id'],_0x1bb1f0(0x160))+_0x1bb1f0(0x184)+_0x8ceca6[_0x1bb1f0(0x134)]+_0x1bb1f0(0x153)+_0x8ceca6[_0x1bb1f0(0x127)]+_0x1bb1f0(0x18e)+_0x8ceca6[_0x1bb1f0(0x159)]+_0xf3da98;}function U(_0x439548){const _0x13b04d=a0_0x7d5828;return{'event':{'sending':_0x13b04d(0x12b),'delivered':_0x13b04d(0x199),'failed':'task.send.failed','acked':_0x13b04d(0x144),'started':_0x13b04d(0x158),'replied':_0x13b04d(0x128),'expired':_0x13b04d(0x11a)}[_0x439548[_0x13b04d(0x11e)]],..._0x439548};}function a0_0x18c6(){const _0x114a0c=['parent_task_id','autoConnect','alias','connect','error','messages','url','toTimeString','sdk-','inbox\x20error:\x20','\x20task_id=','SSE\x20error:\x20',']\x20[commhub:','send_rejected','sleep','error_message','reconnectDelay','1765316ikTcrz','json','data:\x20','text','connected','cwd','fromAlias','application/json','ack_inbox','2724NRZtXA','server','get_inbox','sseAbort','agent','\x20transport=','heartbeatInterval','abort','Bearer\x20','broadcast','94448HaCJdH','\x20network_id=','CommHub\x20response\x20omitted\x20task_id','message','pop','\x20lifecycle=','idle','task','log','emit','9LkDxGa','slice','min','7435klZIMU','heartbeatTimer','now','task.send.delivered','connectSSE','parentTaskId','task.expired','POST','[REDACTED]','to_alias','status','send_failed','networkId','get_all_status','content','tools/call','resumeId','send','/events/','duration_ms','task.replied','from_alias','from_session','task.send.start','running','application/json,\x20text/event-stream','2481038JTdMAc','\x20parent_task_id=','toAlias','startsWith','1107112NrHRMY','disconnect','transport','lifecycleTracking','send_task','body','type','CommHub\x20rejected\x20task','missing_task_id','parse','signal','1eZUeix','replace','s...','send_message','failed','7518280OuLZgd','toString','task.ack','task_id','/mcp','83589tANogS','sending','processInbox','error_code','<missing>','120OFKqEk','SSE\x20reconnecting\x20in\x20','disconnected','normal','token','split','message_id','\x20duration_ms=','333IgPkXR','getReader','call','reply','task.started','lifecycle_tracking','stringify','Authorization','catch','2.0','name','heartbeat\x20failed:\x20','<unknown>','new_message','decode','new_task','\x20error='];a0_0x18c6=function(){return _0x114a0c;};return a0_0x18c6();}function j(_0x40e58c){const _0x355198=a0_0x7d5828;let _0x1552b6=_0x40e58c?.[_0x355198(0x145)]||_0x40e58c?.[_0x355198(0x152)]||_0x40e58c?.['id'];if(_0x1552b6)return String(_0x1552b6);let _0x1fc941=_0x40e58c?.[_0x355198(0x122)]?.[0x0]?.[_0x355198(0x179)];if(typeof _0x1fc941!=='string')return null;try{let _0x374365=JSON[_0x355198(0x13b)](_0x1fc941);return _0x374365?.[_0x355198(0x145)]||_0x374365?.[_0x355198(0x152)]||_0x374365?.['id']||null;}catch{return null;}}async function X(_0x25df39,_0x37271e){const _0x4113a6=a0_0x7d5828;let _0x34ddfb=_0x37271e[_0x4113a6(0x198)]??Date[_0x4113a6(0x198)],_0x4ace99=_0x34ddfb(),_0x48aa6a=(_0xdd8c6f,_0x82d8a3,_0x32024f,_0x284f24)=>{const _0x1999aa=_0x4113a6;_0x37271e[_0x1999aa(0x191)](O(U({'from_alias':_0x25df39[_0x1999aa(0x17c)],'to_alias':_0x25df39[_0x1999aa(0x130)],'task_id':_0x82d8a3,'parent_task_id':_0x25df39['parentTaskId'],'network_id':_0x25df39[_0x1999aa(0x120)],'transport':_0x25df39['transport'],'status':_0xdd8c6f,'duration_ms':_0x34ddfb()-_0x4ace99,'lifecycle_tracking':_0x25df39[_0x1999aa(0x135)],..._0x32024f!==void 0x0?{'error_code':_0x284f24||_0x1999aa(0x11f),'error_message':N(_0x32024f)}:{}})));};_0x48aa6a(_0x4113a6(0x148),null);try{let _0x5ef177=await _0x37271e[_0x4113a6(0x125)](),_0x2a33a3=j(_0x5ef177);if(_0x2a33a3)_0x48aa6a('delivered',_0x2a33a3);else{if(_0x5ef177?.['ok']===!0x1||_0x5ef177?.[_0x4113a6(0x169)])_0x48aa6a(_0x4113a6(0x141),_0x2a33a3,_0x5ef177?.[_0x4113a6(0x169)]||_0x4113a6(0x139),_0x4113a6(0x172));else _0x48aa6a('failed',null,_0x4113a6(0x18b),_0x4113a6(0x13a));}return _0x5ef177;}catch(_0x3b0700){throw _0x48aa6a(_0x4113a6(0x141),null,_0x3b0700,_0x4113a6(0x11f)),_0x3b0700;}}async function Y(_0x432d44,_0x3a1452){const _0x5c2c1f=a0_0x7d5828;return X({'fromAlias':_0x432d44['fromAlias'],'toAlias':_0x432d44['alias'],'parentTaskId':_0x432d44[_0x5c2c1f(0x119)]||null,'networkId':_0x432d44['networkId']||null,'transport':'mcp_http','lifecycleTracking':'not_tracked'},_0x3a1452);}class $ extends a0_0x2bef32{[a0_0x7d5828(0x16b)];[a0_0x7d5828(0x167)];[a0_0x7d5828(0x150)];[a0_0x7d5828(0x183)];[a0_0x7d5828(0x124)];[a0_0x7d5828(0x185)];[a0_0x7d5828(0x175)];[a0_0x7d5828(0x197)];[a0_0x7d5828(0x182)];['running']=!0x1;constructor(_0x263e44){const _0x42364e=a0_0x7d5828;super();if(this['url']=_0x263e44[_0x42364e(0x16b)]['replace'](/\/$/,''),this[_0x42364e(0x167)]=_0x263e44[_0x42364e(0x167)],this[_0x42364e(0x150)]=_0x263e44[_0x42364e(0x150)],this[_0x42364e(0x183)]=_0x263e44[_0x42364e(0x183)]||'sdk',this[_0x42364e(0x124)]=_0x42364e(0x16d)+_0x263e44['alias']+'-'+Date['now']()[_0x42364e(0x143)](0x24),this[_0x42364e(0x185)]=_0x263e44[_0x42364e(0x185)]??0x2bf20,this[_0x42364e(0x175)]=_0x263e44[_0x42364e(0x175)]??0xbb8,_0x263e44[_0x42364e(0x166)]!==!0x1)this[_0x42364e(0x168)]();}['log'](_0x2530bd){const _0xcfbe46=a0_0x7d5828;console[_0xcfbe46(0x191)]('['+new Date()[_0xcfbe46(0x16c)]()['slice'](0x0,0x8)+_0xcfbe46(0x171)+this[_0xcfbe46(0x167)]+']\x20'+_0x2530bd);}async[a0_0x7d5828(0x156)](_0x131989,_0x17ec47){const _0x25bc5f=a0_0x7d5828;let _0x4aff74={'Content-Type':_0x25bc5f(0x17d),'Accept':_0x25bc5f(0x12d)};if(this[_0x25bc5f(0x150)])_0x4aff74[_0x25bc5f(0x15b)]=_0x25bc5f(0x187)+this[_0x25bc5f(0x150)];let _0x28ebd7=await(await fetch(this[_0x25bc5f(0x16b)]+_0x25bc5f(0x146),{'method':_0x25bc5f(0x11b),'headers':_0x4aff74,'body':JSON[_0x25bc5f(0x15a)]({'jsonrpc':_0x25bc5f(0x15d),'id':Date['now'](),'method':_0x25bc5f(0x123),'params':{'name':_0x131989,'arguments':_0x17ec47}})}))[_0x25bc5f(0x179)](),_0xee974d=_0x28ebd7['match'](/data: (.+)/),_0x143b06=_0xee974d?JSON[_0x25bc5f(0x13b)](_0xee974d[0x1]):JSON[_0x25bc5f(0x13b)](_0x28ebd7),_0x537cfe=_0x143b06?.['result']?.['content']?.[0x0]?.[_0x25bc5f(0x179)];return _0x537cfe?JSON[_0x25bc5f(0x13b)](_0x537cfe):_0x143b06;}async['connect'](){const _0xfc781a=a0_0x7d5828;if(this[_0xfc781a(0x12c)])return;this['running']=!0x0,await this[_0xfc781a(0x11e)](_0xfc781a(0x18f)),this[_0xfc781a(0x191)]('registered'),this['heartbeatTimer']=setInterval(()=>{const _0x59063e=_0xfc781a;this[_0x59063e(0x11e)](_0x59063e(0x18f))[_0x59063e(0x15c)](_0x1bfcc1=>this[_0x59063e(0x191)](_0x59063e(0x15f)+_0x1bfcc1['message']));},this[_0xfc781a(0x185)]),this[_0xfc781a(0x118)]();}async[a0_0x7d5828(0x133)](){const _0x419771=a0_0x7d5828;if(this[_0x419771(0x12c)]=!0x1,this['sseAbort']?.[_0x419771(0x186)](),this[_0x419771(0x197)])clearInterval(this[_0x419771(0x197)]);await this[_0x419771(0x11e)]('offline')[_0x419771(0x15c)](()=>{}),this['log'](_0x419771(0x14e));}async['send'](_0x136da4,_0x5d7ede,_0x58a6bd=a0_0x7d5828(0x14f)){const _0x3cf86e=a0_0x7d5828;return Y({'alias':_0x136da4,'fromAlias':this[_0x3cf86e(0x167)]},{'log':_0x5667d4=>console[_0x3cf86e(0x191)](_0x5667d4),'send':()=>this[_0x3cf86e(0x156)](_0x3cf86e(0x136),{'alias':_0x136da4,'task':_0x5d7ede,'priority':_0x58a6bd,'from_session':this['alias']})});}async[a0_0x7d5828(0x18c)](_0x3877c3,_0x1cc0d6){const _0x1c1e80=a0_0x7d5828;return this[_0x1c1e80(0x156)](_0x1c1e80(0x140),{'alias':_0x3877c3,'message':_0x1cc0d6,'from_session':this['alias']});}async[a0_0x7d5828(0x157)](_0x1e0801,_0x2acc61,_0x2b88bb='completed'){const _0x20c563=a0_0x7d5828;return this[_0x20c563(0x156)]('send_reply',{'in_reply_to':_0x1e0801,'text':_0x2acc61,'status':_0x2b88bb});}async[a0_0x7d5828(0x11e)](_0x505fb1,_0x11287a){const _0x2b37ca=a0_0x7d5828;return this[_0x2b37ca(0x156)]('report_status',{'resume_id':this[_0x2b37ca(0x124)],'alias':this[_0x2b37ca(0x167)],'status':_0x505fb1,'server':a0_0x531741(),'hostname':a0_0x531741(),'agent':this[_0x2b37ca(0x183)],'project_dir':process[_0x2b37ca(0x17b)](),..._0x11287a});}async['getAllStatus'](){const _0xc4a23f=a0_0x7d5828;return this['call'](_0xc4a23f(0x121),{});}async[a0_0x7d5828(0x188)](_0x20c61,_0x8f9d70){const _0x271fd8=a0_0x7d5828;return this[_0x271fd8(0x156)]('broadcast',{'message':_0x20c61,'filter_server':_0x8f9d70?.[_0x271fd8(0x180)],'filter_status':_0x8f9d70?.[_0x271fd8(0x11e)]});}async[a0_0x7d5828(0x118)](){const _0x429c37=a0_0x7d5828;let _0x4a5651=encodeURIComponent(this[_0x429c37(0x167)]),_0x790f25=this[_0x429c37(0x16b)]+_0x429c37(0x126)+_0x4a5651,_0x5826d2=this[_0x429c37(0x175)];while(this[_0x429c37(0x12c)]){try{this[_0x429c37(0x182)]=new AbortController();let _0x41ac31={'Accept':'text/event-stream'};if(this[_0x429c37(0x150)])_0x41ac31[_0x429c37(0x15b)]='Bearer\x20'+this[_0x429c37(0x150)];let _0x33ab2f=await fetch(_0x790f25,{'headers':_0x41ac31,'signal':this['sseAbort'][_0x429c37(0x13c)]});if(!_0x33ab2f['ok']||!_0x33ab2f['body']){this[_0x429c37(0x191)]('SSE\x20failed:\x20'+_0x33ab2f['status']),await this[_0x429c37(0x173)](_0x5826d2),_0x5826d2=Math[_0x429c37(0x195)](_0x5826d2*1.5,0xea60);continue;}_0x5826d2=this[_0x429c37(0x175)];let _0x4cf04e=_0x33ab2f[_0x429c37(0x137)][_0x429c37(0x155)](),_0xd7d456=new TextDecoder(),_0x58ccc1='';while(this[_0x429c37(0x12c)]){let {done:_0x132801,value:_0x161ef3}=await _0x4cf04e['read']();if(_0x132801)break;_0x58ccc1+=_0xd7d456[_0x429c37(0x162)](_0x161ef3,{'stream':!0x0});let _0x4701a2=_0x58ccc1[_0x429c37(0x151)]('\x0a');_0x58ccc1=_0x4701a2[_0x429c37(0x18d)]()||'';for(let _0x243a27 of _0x4701a2){if(!_0x243a27[_0x429c37(0x131)](_0x429c37(0x178)))continue;try{let _0x2d79ae=JSON[_0x429c37(0x13b)](_0x243a27['slice'](0x6));if(_0x2d79ae[_0x429c37(0x138)]===_0x429c37(0x17a)){this[_0x429c37(0x191)]('SSE\x20connected'),this['emit'](_0x429c37(0x17a));continue;}if(_0x2d79ae[_0x429c37(0x138)]===_0x429c37(0x163)||_0x2d79ae['type']===_0x429c37(0x161)||_0x2d79ae[_0x429c37(0x138)]===_0x429c37(0x188))await this[_0x429c37(0x149)]();}catch{}}}}catch(_0x176517){if(_0x176517[_0x429c37(0x15e)]==='AbortError')break;this['emit'](_0x429c37(0x169),_0x176517),this[_0x429c37(0x191)](_0x429c37(0x170)+_0x176517[_0x429c37(0x18c)]);}if(this['running'])this[_0x429c37(0x192)](_0x429c37(0x14e)),this[_0x429c37(0x191)](_0x429c37(0x14d)+_0x5826d2/0x3e8+_0x429c37(0x13f)),await this['sleep'](_0x5826d2),_0x5826d2=Math[_0x429c37(0x195)](_0x5826d2*1.5,0xea60);}}async[a0_0x7d5828(0x149)](){const _0x5054d9=a0_0x7d5828;try{let _0x10295f=(await this['call'](_0x5054d9(0x181),{'alias':this[_0x5054d9(0x167)],'limit':0xa}))?.[_0x5054d9(0x16a)]||[];for(let _0x1d4a63 of _0x10295f)await this[_0x5054d9(0x156)](_0x5054d9(0x17e),{'alias':this[_0x5054d9(0x167)],'message_id':_0x1d4a63['id']}),this['log']('←\x20'+_0x1d4a63[_0x5054d9(0x12a)]+':\x20'+_0x1d4a63[_0x5054d9(0x122)][_0x5054d9(0x194)](0x0,0x3c)),this[_0x5054d9(0x192)](_0x5054d9(0x190),_0x1d4a63),this[_0x5054d9(0x192)]('message',_0x1d4a63);}catch(_0x37fa39){this[_0x5054d9(0x191)](_0x5054d9(0x16e)+_0x37fa39[_0x5054d9(0x18c)]);}}[a0_0x7d5828(0x173)](_0xec066f){return new Promise(_0x4ac486=>setTimeout(_0x4ac486,_0xec066f));}}var F=$;export{F as default,$ as CommHub};
1
+ const a0_0x589708=a0_0x26c6;function a0_0x26c6(_0xb527da,_0x110a68){_0xb527da=_0xb527da-0xc2;const _0x239709=a0_0x2397();let _0x26c63b=_0x239709[_0xb527da];return _0x26c63b;}(function(_0x2ec502,_0x2fb8dd){const _0x51e200=a0_0x26c6,_0x429e40=_0x2ec502();while(!![]){try{const _0x327bd0=parseInt(_0x51e200(0xcb))/0x1+-parseInt(_0x51e200(0x11f))/0x2*(-parseInt(_0x51e200(0xd9))/0x3)+parseInt(_0x51e200(0xd5))/0x4+parseInt(_0x51e200(0x12d))/0x5+parseInt(_0x51e200(0x114))/0x6*(-parseInt(_0x51e200(0x131))/0x7)+parseInt(_0x51e200(0xf2))/0x8+-parseInt(_0x51e200(0x119))/0x9;if(_0x327bd0===_0x2fb8dd)break;else _0x429e40['push'](_0x429e40['shift']());}catch(_0x190e0a){_0x429e40['push'](_0x429e40['shift']());}}}(a0_0x2397,0x8f538));import{EventEmitter as a0_0x35b66d}from'events';import{hostname as a0_0x4092be}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x14f1ce,_0x310c29)=>(_0x14f1ce??_0x310c29)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x2483c3){const _0x314ca6=a0_0x26c6;return(_0x2483c3 instanceof Error?_0x2483c3['message']:String(_0x2483c3??_0x314ca6(0xe1)))[_0x314ca6(0x127)](K,_0x314ca6(0x109))[_0x314ca6(0x127)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x314ca6(0x139)](0x0,0xf0);}function O(_0x597e2f,_0xf0002f=process.env.ANET_TASK_TRACE_FORMAT===a0_0x589708(0xfb)){const _0x4b8c8f=a0_0x589708;if(_0xf0002f)return JSON[_0x4b8c8f(0xc9)](_0x597e2f);let _0x5b493d=L(_0x597e2f[_0x4b8c8f(0xfa)],_0x4b8c8f(0xfd)),_0x501191=L(_0x597e2f[_0x4b8c8f(0x129)],_0x4b8c8f(0xc3)),_0x37f4cb=_0x597e2f[_0x4b8c8f(0xcc)]?'\x20error='+_0x597e2f['error_code']+':'+(_0x597e2f[_0x4b8c8f(0x12e)]??''):'';return _0x4b8c8f(0x136)+_0x597e2f[_0x4b8c8f(0xfc)]+_0x4b8c8f(0x13d)+L(_0x597e2f[_0x4b8c8f(0xc2)],_0x4b8c8f(0x103))+_0x4b8c8f(0x133)+L(_0x597e2f[_0x4b8c8f(0xe3)],_0x4b8c8f(0x103))+_0x4b8c8f(0x126)+_0x501191+'\x20parent_task_id='+_0x5b493d+_0x4b8c8f(0xd2)+L(_0x597e2f[_0x4b8c8f(0xf5)],_0x4b8c8f(0x103))+_0x4b8c8f(0xc7)+_0x597e2f[_0x4b8c8f(0x11e)]+_0x4b8c8f(0xd0)+_0x597e2f['duration_ms']+'\x20lifecycle='+_0x597e2f[_0x4b8c8f(0xe7)]+_0x37f4cb;}function U(_0x380ecf){const _0x152105=a0_0x589708;return{'event':{'sending':'task.send.start','delivered':_0x152105(0x105),'failed':'task.send.failed','acked':'task.ack','started':_0x152105(0x104),'replied':_0x152105(0xef),'expired':_0x152105(0xd4)}[_0x380ecf[_0x152105(0xfc)]],..._0x380ecf};}function j(_0x46d4c6){const _0x5e0fa3=a0_0x589708;let _0x1987b1=_0x46d4c6?.[_0x5e0fa3(0x129)]||_0x46d4c6?.['message_id']||_0x46d4c6?.['id'];if(_0x1987b1)return String(_0x1987b1);let _0x3286ea=_0x46d4c6?.[_0x5e0fa3(0x11a)]?.[0x0]?.['text'];if(typeof _0x3286ea!==_0x5e0fa3(0x12a))return null;try{let _0x1ff63f=JSON[_0x5e0fa3(0xd1)](_0x3286ea);return _0x1ff63f?.[_0x5e0fa3(0x129)]||_0x1ff63f?.[_0x5e0fa3(0x13f)]||_0x1ff63f?.['id']||null;}catch{return null;}}async function X(_0x308044,_0x1f3c75){const _0x2293ef=a0_0x589708;let _0x503423=_0x1f3c75[_0x2293ef(0xf0)]??Date['now'],_0x4f874a=_0x503423(),_0x209142=(_0x5e9319,_0x260d1f,_0x361841,_0x31be5d)=>{const _0x581665=_0x2293ef;_0x1f3c75['log'](O(U({'from_alias':_0x308044[_0x581665(0x11b)],'to_alias':_0x308044[_0x581665(0xdf)],'task_id':_0x260d1f,'parent_task_id':_0x308044[_0x581665(0x141)],'network_id':_0x308044['networkId'],'transport':_0x308044[_0x581665(0x11e)],'status':_0x5e9319,'duration_ms':_0x503423()-_0x4f874a,'lifecycle_tracking':_0x308044['lifecycleTracking'],..._0x361841!==void 0x0?{'error_code':_0x31be5d||_0x581665(0xe6),'error_message':N(_0x361841)}:{}})));};_0x209142(_0x2293ef(0x10b),null);try{let _0x109ba4=await _0x1f3c75[_0x2293ef(0x13b)](),_0x4f5d5f=j(_0x109ba4);if(_0x4f5d5f)_0x209142(_0x2293ef(0x10f),_0x4f5d5f);else{if(_0x109ba4?.['ok']===!0x1||_0x109ba4?.[_0x2293ef(0x132)])_0x209142(_0x2293ef(0x10c),_0x4f5d5f,_0x109ba4?.[_0x2293ef(0x132)]||_0x2293ef(0xea),_0x2293ef(0x110));else _0x209142(_0x2293ef(0x10c),null,_0x2293ef(0xc6),_0x2293ef(0xf9));}return _0x109ba4;}catch(_0x302839){throw _0x209142(_0x2293ef(0x10c),null,_0x302839,_0x2293ef(0xe6)),_0x302839;}}function a0_0x2397(){const _0x23aa6d=['send_rejected','running','get_inbox','match','216gmohxR','connected','url','2.0','log','15986997CTgNpz','content','fromAlias','disconnected','abort','transport','135484GmvDoI','ack_inbox','processInbox','connect','catch','mcp_http','split','\x20task_id=','replace','Bearer\x20','task_id','string','idle','sseAbort','2325180Esyqsa','error_message','message','sdk-','227514dGRpHW','error','\x20to=','not_tracked','/mcp','[commhub:task]\x20',']\x20[commhub:','inbox\x20error:\x20','slice','networkId','send','new_task','\x20from=','from_session','message_id','report_status','parentTaskId','from_alias','<pending>','emit','server','CommHub\x20response\x20omitted\x20task_id','\x20transport=','completed','stringify','send_reply','437250nxDVLc','error_code','heartbeatTimer','normal','decode','\x20duration_ms=','parse','\x20network_id=','toString','task.expired','1457640tZsZup','body','heartbeatInterval','toTimeString','51jTITcY','agent','tools/call','new_message','get_all_status','application/json,\x20text/event-stream','toAlias','text','unknown\x20error','resumeId','to_alias','heartbeat\x20failed:\x20','type','send_failed','lifecycle_tracking','send_task','reconnectDelay','CommHub\x20rejected\x20task','read','/events/','token','connectSSE','task.replied','now','text/event-stream','8921272DIdsBG','Authorization','SSE\x20error:\x20','network_id','autoConnect','startsWith','messages','missing_task_id','parent_task_id','json','status','<missing>','AbortError','disconnect','send_message','broadcast','call','<unknown>','task.started','task.send.delivered','SSE\x20connected','data:\x20','alias','[REDACTED]','offline','sending','failed','sleep','s...','delivered'];a0_0x2397=function(){return _0x23aa6d;};return a0_0x2397();}async function Y(_0x511e82,_0xd0eb47){const _0x123ab6=a0_0x589708;return X({'fromAlias':_0x511e82[_0x123ab6(0x11b)],'toAlias':_0x511e82[_0x123ab6(0x108)],'parentTaskId':_0x511e82['parentTaskId']||null,'networkId':_0x511e82[_0x123ab6(0x13a)]||null,'transport':_0x123ab6(0x124),'lifecycleTracking':_0x123ab6(0x134)},_0xd0eb47);}class $ extends a0_0x35b66d{[a0_0x589708(0x116)];[a0_0x589708(0x108)];[a0_0x589708(0xed)];['agent'];[a0_0x589708(0xe2)];['heartbeatInterval'];[a0_0x589708(0xe9)];[a0_0x589708(0xcd)];['sseAbort'];[a0_0x589708(0x111)]=!0x1;constructor(_0x273c4c){const _0x1332ff=a0_0x589708;super();if(this[_0x1332ff(0x116)]=_0x273c4c['url']['replace'](/\/$/,''),this['alias']=_0x273c4c[_0x1332ff(0x108)],this['token']=_0x273c4c[_0x1332ff(0xed)],this['agent']=_0x273c4c[_0x1332ff(0xda)]||'sdk',this[_0x1332ff(0xe2)]=_0x1332ff(0x130)+_0x273c4c[_0x1332ff(0x108)]+'-'+Date[_0x1332ff(0xf0)]()[_0x1332ff(0xd3)](0x24),this[_0x1332ff(0xd7)]=_0x273c4c[_0x1332ff(0xd7)]??0x2bf20,this[_0x1332ff(0xe9)]=_0x273c4c[_0x1332ff(0xe9)]??0xbb8,_0x273c4c[_0x1332ff(0xf6)]!==!0x1)this[_0x1332ff(0x122)]();}[a0_0x589708(0x118)](_0x1942ab){const _0x1aeb73=a0_0x589708;console[_0x1aeb73(0x118)]('['+new Date()[_0x1aeb73(0xd8)]()[_0x1aeb73(0x139)](0x0,0x8)+_0x1aeb73(0x137)+this[_0x1aeb73(0x108)]+']\x20'+_0x1942ab);}async[a0_0x589708(0x102)](_0x40c4f0,_0x46962a){const _0x4f9117=a0_0x589708;let _0x328d97={'Content-Type':'application/json','Accept':_0x4f9117(0xde)};if(this[_0x4f9117(0xed)])_0x328d97[_0x4f9117(0xf3)]=_0x4f9117(0x128)+this['token'];let _0x5c51e0=await(await fetch(this[_0x4f9117(0x116)]+_0x4f9117(0x135),{'method':'POST','headers':_0x328d97,'body':JSON[_0x4f9117(0xc9)]({'jsonrpc':_0x4f9117(0x117),'id':Date[_0x4f9117(0xf0)](),'method':_0x4f9117(0xdb),'params':{'name':_0x40c4f0,'arguments':_0x46962a}})}))[_0x4f9117(0xe0)](),_0x6381da=_0x5c51e0[_0x4f9117(0x113)](/data: (.+)/),_0x2c5bed=_0x6381da?JSON[_0x4f9117(0xd1)](_0x6381da[0x1]):JSON['parse'](_0x5c51e0),_0x5b7f3c=_0x2c5bed?.['result']?.[_0x4f9117(0x11a)]?.[0x0]?.[_0x4f9117(0xe0)];return _0x5b7f3c?JSON[_0x4f9117(0xd1)](_0x5b7f3c):_0x2c5bed;}async[a0_0x589708(0x122)](){const _0x53dedc=a0_0x589708;if(this['running'])return;this[_0x53dedc(0x111)]=!0x0,await this[_0x53dedc(0xfc)](_0x53dedc(0x12b)),this['log']('registered'),this[_0x53dedc(0xcd)]=setInterval(()=>{const _0x453310=_0x53dedc;this[_0x453310(0xfc)]('idle')[_0x453310(0x123)](_0x4f5596=>this[_0x453310(0x118)](_0x453310(0xe4)+_0x4f5596['message']));},this['heartbeatInterval']),this[_0x53dedc(0xee)]();}async[a0_0x589708(0xff)](){const _0xdb017e=a0_0x589708;if(this[_0xdb017e(0x111)]=!0x1,this[_0xdb017e(0x12c)]?.[_0xdb017e(0x11d)](),this[_0xdb017e(0xcd)])clearInterval(this[_0xdb017e(0xcd)]);await this[_0xdb017e(0xfc)](_0xdb017e(0x10a))[_0xdb017e(0x123)](()=>{}),this[_0xdb017e(0x118)](_0xdb017e(0x11c));}async[a0_0x589708(0x13b)](_0x2d3a8a,_0x8ebd7c,_0x56bf45=a0_0x589708(0xce)){const _0x3a9ae3=a0_0x589708;return Y({'alias':_0x2d3a8a,'fromAlias':this[_0x3a9ae3(0x108)]},{'log':_0x13dba0=>console[_0x3a9ae3(0x118)](_0x13dba0),'send':()=>this[_0x3a9ae3(0x102)](_0x3a9ae3(0xe8),{'alias':_0x2d3a8a,'task':_0x8ebd7c,'priority':_0x56bf45,'from_session':this['alias']})});}async[a0_0x589708(0x12f)](_0xfe6f84,_0x8b351){const _0x3c1059=a0_0x589708;return this[_0x3c1059(0x102)](_0x3c1059(0x100),{'alias':_0xfe6f84,'message':_0x8b351,'from_session':this[_0x3c1059(0x108)]});}async['reply'](_0x4c1723,_0x40ea0d,_0xed29c5=a0_0x589708(0xc8)){const _0x1671aa=a0_0x589708;return this[_0x1671aa(0x102)](_0x1671aa(0xca),{'in_reply_to':_0x4c1723,'text':_0x40ea0d,'status':_0xed29c5});}async[a0_0x589708(0xfc)](_0x5703c4,_0x19c94f){const _0x200529=a0_0x589708;return this[_0x200529(0x102)](_0x200529(0x140),{'resume_id':this[_0x200529(0xe2)],'alias':this['alias'],'status':_0x5703c4,'server':a0_0x4092be(),'hostname':a0_0x4092be(),'agent':this[_0x200529(0xda)],'project_dir':process['cwd'](),..._0x19c94f});}async['getAllStatus'](){const _0x4b48db=a0_0x589708;return this['call'](_0x4b48db(0xdd),{});}async[a0_0x589708(0x101)](_0x536e1b,_0x2642f1){const _0x303c53=a0_0x589708;return this[_0x303c53(0x102)]('broadcast',{'message':_0x536e1b,'filter_server':_0x2642f1?.[_0x303c53(0xc5)],'filter_status':_0x2642f1?.['status']});}async[a0_0x589708(0xee)](){const _0x1d23c1=a0_0x589708;let _0xbf160c=encodeURIComponent(this[_0x1d23c1(0x108)]),_0x32916b=this[_0x1d23c1(0x116)]+_0x1d23c1(0xec)+_0xbf160c,_0x324b50=this['reconnectDelay'];while(this[_0x1d23c1(0x111)]){try{this[_0x1d23c1(0x12c)]=new AbortController();let _0x50c163={'Accept':_0x1d23c1(0xf1)};if(this[_0x1d23c1(0xed)])_0x50c163[_0x1d23c1(0xf3)]=_0x1d23c1(0x128)+this[_0x1d23c1(0xed)];let _0x1ef180=await fetch(_0x32916b,{'headers':_0x50c163,'signal':this[_0x1d23c1(0x12c)]['signal']});if(!_0x1ef180['ok']||!_0x1ef180['body']){this['log']('SSE\x20failed:\x20'+_0x1ef180['status']),await this['sleep'](_0x324b50),_0x324b50=Math['min'](_0x324b50*1.5,0xea60);continue;}_0x324b50=this[_0x1d23c1(0xe9)];let _0x351110=_0x1ef180[_0x1d23c1(0xd6)]['getReader'](),_0x11713d=new TextDecoder(),_0x3b5a9f='';while(this[_0x1d23c1(0x111)]){let {done:_0x256ae4,value:_0x176399}=await _0x351110[_0x1d23c1(0xeb)]();if(_0x256ae4)break;_0x3b5a9f+=_0x11713d[_0x1d23c1(0xcf)](_0x176399,{'stream':!0x0});let _0x6ebc19=_0x3b5a9f[_0x1d23c1(0x125)]('\x0a');_0x3b5a9f=_0x6ebc19['pop']()||'';for(let _0x35b022 of _0x6ebc19){if(!_0x35b022[_0x1d23c1(0xf7)](_0x1d23c1(0x107)))continue;try{let _0x53e3e1=JSON[_0x1d23c1(0xd1)](_0x35b022['slice'](0x6));if(_0x53e3e1[_0x1d23c1(0xe5)]===_0x1d23c1(0x115)){this[_0x1d23c1(0x118)](_0x1d23c1(0x106)),this['emit'](_0x1d23c1(0x115));continue;}if(_0x53e3e1[_0x1d23c1(0xe5)]===_0x1d23c1(0x13c)||_0x53e3e1[_0x1d23c1(0xe5)]===_0x1d23c1(0xdc)||_0x53e3e1[_0x1d23c1(0xe5)]===_0x1d23c1(0x101))await this[_0x1d23c1(0x121)]();}catch{}}}}catch(_0x5462c7){if(_0x5462c7['name']===_0x1d23c1(0xfe))break;this[_0x1d23c1(0xc4)]('error',_0x5462c7),this[_0x1d23c1(0x118)](_0x1d23c1(0xf4)+_0x5462c7[_0x1d23c1(0x12f)]);}if(this[_0x1d23c1(0x111)])this[_0x1d23c1(0xc4)](_0x1d23c1(0x11c)),this['log']('SSE\x20reconnecting\x20in\x20'+_0x324b50/0x3e8+_0x1d23c1(0x10e)),await this[_0x1d23c1(0x10d)](_0x324b50),_0x324b50=Math['min'](_0x324b50*1.5,0xea60);}}async['processInbox'](){const _0x2c2608=a0_0x589708;try{let _0x42f725=(await this[_0x2c2608(0x102)](_0x2c2608(0x112),{'alias':this[_0x2c2608(0x108)],'limit':0xa}))?.[_0x2c2608(0xf8)]||[];for(let _0x3b0774 of _0x42f725)await this[_0x2c2608(0x102)](_0x2c2608(0x120),{'alias':this['alias'],'message_id':_0x3b0774['id']}),this[_0x2c2608(0x118)]('←\x20'+_0x3b0774[_0x2c2608(0x13e)]+':\x20'+_0x3b0774[_0x2c2608(0x11a)][_0x2c2608(0x139)](0x0,0x3c)),this['emit']('task',_0x3b0774),this[_0x2c2608(0xc4)](_0x2c2608(0x12f),_0x3b0774);}catch(_0x3082b7){this[_0x2c2608(0x118)](_0x2c2608(0x138)+_0x3082b7[_0x2c2608(0x12f)]);}}[a0_0x589708(0x10d)](_0x2dd25d){return new Promise(_0x2691de=>setTimeout(_0x2691de,_0x2dd25d));}}var F=$;export{F as default,$ as CommHub};