@sleep2agi/agent-network 2.3.0-preview.245 → 2.3.0-preview.246

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_0x55eb92=a0_0x45b6;(function(_0x267ebb,_0x136818){const _0x196a0e=a0_0x45b6,_0x5c8128=_0x267ebb();while(!![]){try{const _0x25b3df=parseInt(_0x196a0e(0x167))/0x1*(parseInt(_0x196a0e(0x1ad))/0x2)+parseInt(_0x196a0e(0x1cd))/0x3+-parseInt(_0x196a0e(0x1b1))/0x4+parseInt(_0x196a0e(0x18a))/0x5*(-parseInt(_0x196a0e(0x15f))/0x6)+parseInt(_0x196a0e(0x193))/0x7*(-parseInt(_0x196a0e(0x1a4))/0x8)+parseInt(_0x196a0e(0x163))/0x9*(parseInt(_0x196a0e(0x164))/0xa)+-parseInt(_0x196a0e(0x1a8))/0xb*(-parseInt(_0x196a0e(0x1ba))/0xc);if(_0x25b3df===_0x136818)break;else _0x5c8128['push'](_0x5c8128['shift']());}catch(_0x3d0a19){_0x5c8128['push'](_0x5c8128['shift']());}}}(a0_0x2905,0xec5b1));import{EventEmitter as a0_0x57742f}from'events';import{hostname as a0_0x463126}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x14e2ba,_0x12fcae)=>(_0x14e2ba??_0x12fcae)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x55eb92(0x18d)](0x0,0xf0);function N(_0xbaf20f){const _0x4b5985=a0_0x55eb92;return(_0xbaf20f instanceof Error?_0xbaf20f[_0x4b5985(0x1cc)]:String(_0xbaf20f??_0x4b5985(0x16f)))[_0x4b5985(0x1cb)](K,'[REDACTED]')['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function a0_0x2905(){const _0x50430c=['1026666VBRwMD','cwd','resumeId','status','idle','failed','AbortError','server','task.send.start','split','connect','broadcast','task.ack','2.0','missing_task_id','to_alias','[commhub:task]\x20','message_id','send','send_task','6Joalju','json','parse','task','51498oejjPp','2290lRYgip','task_id','normal','162362FLpfeP','from_alias','type','new_message',']\x20[commhub:','data:\x20','SSE\x20error:\x20','content','unknown\x20error','heartbeat\x20failed:\x20','sleep','lifecycleTracking','catch','now','lifecycle_tracking','log','heartbeatInterval','match','error_message','get_all_status','reply','task.send.delivered','disconnect','sending','sseAbort','decode','autoConnect','send_rejected','min','application/json','/mcp','SSE\x20connected','abort','send_reply','body','6171380ayljWV','parentTaskId','error_code','slice','call','running','s...','heartbeatTimer','Bearer\x20','9986221swKvaJ','emit','report_status','name','url','networkId','delivered','CommHub\x20response\x20omitted\x20task_id','agent','alias','connected','getReader','string','messages','completed','processInbox','reconnectDelay','8eaBNIJ','new_task','\x20parent_task_id=','get_inbox','2241492qFZspQ','duration_ms','task.send.failed','disconnected','from_session','6zFQldp','result','task.started','sdk-','3823672IpgKQg','network_id','connectSSE','SSE\x20reconnecting\x20in\x20','toString','registered','startsWith','signal','task.expired','144ZpONxQ','toAlias','\x20network_id=','\x20duration_ms=','Authorization','send_failed','toTimeString','error','<pending>','<unknown>','stringify','text','tools/call','transport','token','\x20to=','\x20from=','replace','message'];a0_0x2905=function(){return _0x50430c;};return a0_0x2905();}function O(_0x25fde0,_0x500a58=process.env.ANET_TASK_TRACE_FORMAT===a0_0x55eb92(0x160)){const _0x2122d2=a0_0x55eb92;if(_0x500a58)return JSON[_0x2122d2(0x1c4)](_0x25fde0);let _0x40649e=L(_0x25fde0['parent_task_id'],'<missing>'),_0x1ebef0=L(_0x25fde0['task_id'],_0x2122d2(0x1c2)),_0x55e29a=_0x25fde0[_0x2122d2(0x18c)]?'\x20error='+_0x25fde0['error_code']+':'+(_0x25fde0[_0x2122d2(0x179)]??''):'';return _0x2122d2(0x15b)+_0x25fde0['status']+_0x2122d2(0x1ca)+L(_0x25fde0[_0x2122d2(0x168)],_0x2122d2(0x1c3))+_0x2122d2(0x1c9)+L(_0x25fde0[_0x2122d2(0x15a)],_0x2122d2(0x1c3))+'\x20task_id='+_0x1ebef0+_0x2122d2(0x1a6)+_0x40649e+_0x2122d2(0x1bc)+L(_0x25fde0[_0x2122d2(0x1b2)],'<unknown>')+'\x20transport='+_0x25fde0[_0x2122d2(0x1c7)]+_0x2122d2(0x1bd)+_0x25fde0[_0x2122d2(0x1a9)]+'\x20lifecycle='+_0x25fde0[_0x2122d2(0x175)]+_0x55e29a;}function U(_0x558f3e){const _0x13b57e=a0_0x55eb92;return{'event':{'sending':_0x13b57e(0x153),'delivered':_0x13b57e(0x17c),'failed':_0x13b57e(0x1aa),'acked':_0x13b57e(0x157),'started':_0x13b57e(0x1af),'replied':'task.replied','expired':_0x13b57e(0x1b9)}[_0x558f3e[_0x13b57e(0x1d0)]],..._0x558f3e};}function j(_0x51cb5d){const _0x222202=a0_0x55eb92;let _0x18ee0e=_0x51cb5d?.[_0x222202(0x165)]||_0x51cb5d?.['message_id']||_0x51cb5d?.['id'];if(_0x18ee0e)return String(_0x18ee0e);let _0x4ec1dc=_0x51cb5d?.[_0x222202(0x16e)]?.[0x0]?.[_0x222202(0x1c5)];if(typeof _0x4ec1dc!==_0x222202(0x19f))return null;try{let _0x4e2660=JSON['parse'](_0x4ec1dc);return _0x4e2660?.['task_id']||_0x4e2660?.[_0x222202(0x15c)]||_0x4e2660?.['id']||null;}catch{return null;}}async function X(_0x489e9e,_0x8de6e4){const _0x672f8e=a0_0x55eb92;let _0x2cd8e4=_0x8de6e4[_0x672f8e(0x174)]??Date[_0x672f8e(0x174)],_0x261b26=_0x2cd8e4(),_0x41a278=(_0xab3b7e,_0x2de927,_0x1e6ee6,_0x256785)=>{const _0x5952b1=_0x672f8e;_0x8de6e4[_0x5952b1(0x176)](O(U({'from_alias':_0x489e9e['fromAlias'],'to_alias':_0x489e9e[_0x5952b1(0x1bb)],'task_id':_0x2de927,'parent_task_id':_0x489e9e[_0x5952b1(0x18b)],'network_id':_0x489e9e[_0x5952b1(0x198)],'transport':_0x489e9e['transport'],'status':_0xab3b7e,'duration_ms':_0x2cd8e4()-_0x261b26,'lifecycle_tracking':_0x489e9e[_0x5952b1(0x172)],..._0x1e6ee6!==void 0x0?{'error_code':_0x256785||_0x5952b1(0x1bf),'error_message':N(_0x1e6ee6)}:{}})));};_0x41a278(_0x672f8e(0x17e),null);try{let _0x217062=await _0x8de6e4[_0x672f8e(0x15d)](),_0x2b25b0=j(_0x217062);if(_0x2b25b0)_0x41a278(_0x672f8e(0x199),_0x2b25b0);else{if(_0x217062?.['ok']===!0x1||_0x217062?.['error'])_0x41a278('failed',_0x2b25b0,_0x217062?.[_0x672f8e(0x1c1)]||'CommHub\x20rejected\x20task',_0x672f8e(0x182));else _0x41a278(_0x672f8e(0x1d2),null,_0x672f8e(0x19a),_0x672f8e(0x159));}return _0x217062;}catch(_0x25d251){throw _0x41a278(_0x672f8e(0x1d2),null,_0x25d251,_0x672f8e(0x1bf)),_0x25d251;}}async function Y(_0xd40d1,_0xbf0e16){const _0x506cc1=a0_0x55eb92;return X({'fromAlias':_0xd40d1['fromAlias'],'toAlias':_0xd40d1[_0x506cc1(0x19c)],'parentTaskId':_0xd40d1[_0x506cc1(0x18b)]||null,'networkId':_0xd40d1[_0x506cc1(0x198)]||null,'transport':'mcp_http','lifecycleTracking':'not_tracked'},_0xbf0e16);}function a0_0x45b6(_0x5a4ec0,_0x79799c){_0x5a4ec0=_0x5a4ec0-0x152;const _0x29058b=a0_0x2905();let _0x45b694=_0x29058b[_0x5a4ec0];return _0x45b694;}class $ extends a0_0x57742f{['url'];[a0_0x55eb92(0x19c)];[a0_0x55eb92(0x1c8)];[a0_0x55eb92(0x19b)];['resumeId'];[a0_0x55eb92(0x177)];[a0_0x55eb92(0x1a3)];[a0_0x55eb92(0x191)];[a0_0x55eb92(0x17f)];[a0_0x55eb92(0x18f)]=!0x1;constructor(_0xe0c5ee){const _0x19bcd3=a0_0x55eb92;super();if(this['url']=_0xe0c5ee[_0x19bcd3(0x197)][_0x19bcd3(0x1cb)](/\/$/,''),this[_0x19bcd3(0x19c)]=_0xe0c5ee[_0x19bcd3(0x19c)],this[_0x19bcd3(0x1c8)]=_0xe0c5ee[_0x19bcd3(0x1c8)],this['agent']=_0xe0c5ee[_0x19bcd3(0x19b)]||'sdk',this['resumeId']=_0x19bcd3(0x1b0)+_0xe0c5ee[_0x19bcd3(0x19c)]+'-'+Date[_0x19bcd3(0x174)]()[_0x19bcd3(0x1b5)](0x24),this[_0x19bcd3(0x177)]=_0xe0c5ee[_0x19bcd3(0x177)]??0x2bf20,this[_0x19bcd3(0x1a3)]=_0xe0c5ee[_0x19bcd3(0x1a3)]??0xbb8,_0xe0c5ee[_0x19bcd3(0x181)]!==!0x1)this[_0x19bcd3(0x155)]();}['log'](_0x22504c){const _0x243d8f=a0_0x55eb92;console[_0x243d8f(0x176)]('['+new Date()[_0x243d8f(0x1c0)]()['slice'](0x0,0x8)+_0x243d8f(0x16b)+this[_0x243d8f(0x19c)]+']\x20'+_0x22504c);}async['call'](_0x92af95,_0x9d6317){const _0x48c31b=a0_0x55eb92;let _0x7c096e={'Content-Type':_0x48c31b(0x184),'Accept':'application/json,\x20text/event-stream'};if(this['token'])_0x7c096e[_0x48c31b(0x1be)]=_0x48c31b(0x192)+this['token'];let _0x205039=await(await fetch(this['url']+_0x48c31b(0x185),{'method':'POST','headers':_0x7c096e,'body':JSON['stringify']({'jsonrpc':_0x48c31b(0x158),'id':Date[_0x48c31b(0x174)](),'method':_0x48c31b(0x1c6),'params':{'name':_0x92af95,'arguments':_0x9d6317}})}))['text'](),_0x2233c7=_0x205039[_0x48c31b(0x178)](/data: (.+)/),_0x6962a9=_0x2233c7?JSON['parse'](_0x2233c7[0x1]):JSON[_0x48c31b(0x161)](_0x205039),_0x441df7=_0x6962a9?.[_0x48c31b(0x1ae)]?.[_0x48c31b(0x16e)]?.[0x0]?.[_0x48c31b(0x1c5)];return _0x441df7?JSON['parse'](_0x441df7):_0x6962a9;}async[a0_0x55eb92(0x155)](){const _0x355459=a0_0x55eb92;if(this[_0x355459(0x18f)])return;this[_0x355459(0x18f)]=!0x0,await this[_0x355459(0x1d0)](_0x355459(0x1d1)),this['log'](_0x355459(0x1b6)),this['heartbeatTimer']=setInterval(()=>{const _0x29e1b5=_0x355459;this[_0x29e1b5(0x1d0)](_0x29e1b5(0x1d1))[_0x29e1b5(0x173)](_0x4adb61=>this[_0x29e1b5(0x176)](_0x29e1b5(0x170)+_0x4adb61[_0x29e1b5(0x1cc)]));},this[_0x355459(0x177)]),this[_0x355459(0x1b3)]();}async[a0_0x55eb92(0x17d)](){const _0x1b616e=a0_0x55eb92;if(this[_0x1b616e(0x18f)]=!0x1,this[_0x1b616e(0x17f)]?.[_0x1b616e(0x187)](),this[_0x1b616e(0x191)])clearInterval(this[_0x1b616e(0x191)]);await this[_0x1b616e(0x1d0)]('offline')['catch'](()=>{}),this['log'](_0x1b616e(0x1ab));}async[a0_0x55eb92(0x15d)](_0x505c50,_0x4cb9e0,_0x617b81=a0_0x55eb92(0x166)){const _0x39d92e=a0_0x55eb92;return Y({'alias':_0x505c50,'fromAlias':this['alias']},{'log':_0x4985cd=>console[_0x39d92e(0x176)](_0x4985cd),'send':()=>this[_0x39d92e(0x18e)](_0x39d92e(0x15e),{'alias':_0x505c50,'task':_0x4cb9e0,'priority':_0x617b81,'from_session':this[_0x39d92e(0x19c)]})});}async[a0_0x55eb92(0x1cc)](_0x4e20cd,_0x9018bc){const _0x385a25=a0_0x55eb92;return this[_0x385a25(0x18e)]('send_message',{'alias':_0x4e20cd,'message':_0x9018bc,'from_session':this[_0x385a25(0x19c)]});}async[a0_0x55eb92(0x17b)](_0x4671c2,_0x5d8d72,_0x2beb9c=a0_0x55eb92(0x1a1)){const _0x486dc2=a0_0x55eb92;return this[_0x486dc2(0x18e)](_0x486dc2(0x188),{'in_reply_to':_0x4671c2,'text':_0x5d8d72,'status':_0x2beb9c});}async[a0_0x55eb92(0x1d0)](_0xb00ada,_0x856f13){const _0x30bbd9=a0_0x55eb92;return this['call'](_0x30bbd9(0x195),{'resume_id':this[_0x30bbd9(0x1cf)],'alias':this[_0x30bbd9(0x19c)],'status':_0xb00ada,'server':a0_0x463126(),'hostname':a0_0x463126(),'agent':this[_0x30bbd9(0x19b)],'project_dir':process[_0x30bbd9(0x1ce)](),..._0x856f13});}async['getAllStatus'](){const _0x2c618c=a0_0x55eb92;return this[_0x2c618c(0x18e)](_0x2c618c(0x17a),{});}async[a0_0x55eb92(0x156)](_0x2c3f8a,_0x1afc8c){const _0x3f9635=a0_0x55eb92;return this['call'](_0x3f9635(0x156),{'message':_0x2c3f8a,'filter_server':_0x1afc8c?.[_0x3f9635(0x152)],'filter_status':_0x1afc8c?.[_0x3f9635(0x1d0)]});}async['connectSSE'](){const _0x1d8871=a0_0x55eb92;let _0x50d784=encodeURIComponent(this[_0x1d8871(0x19c)]),_0x46e4d5=this[_0x1d8871(0x197)]+'/events/'+_0x50d784,_0x3779e2=this[_0x1d8871(0x1a3)];while(this['running']){try{this[_0x1d8871(0x17f)]=new AbortController();let _0x354e92={'Accept':'text/event-stream'};if(this[_0x1d8871(0x1c8)])_0x354e92[_0x1d8871(0x1be)]=_0x1d8871(0x192)+this['token'];let _0x4df6da=await fetch(_0x46e4d5,{'headers':_0x354e92,'signal':this['sseAbort'][_0x1d8871(0x1b8)]});if(!_0x4df6da['ok']||!_0x4df6da[_0x1d8871(0x189)]){this[_0x1d8871(0x176)]('SSE\x20failed:\x20'+_0x4df6da[_0x1d8871(0x1d0)]),await this[_0x1d8871(0x171)](_0x3779e2),_0x3779e2=Math[_0x1d8871(0x183)](_0x3779e2*1.5,0xea60);continue;}_0x3779e2=this[_0x1d8871(0x1a3)];let _0x20c7ae=_0x4df6da[_0x1d8871(0x189)][_0x1d8871(0x19e)](),_0x3537cc=new TextDecoder(),_0x4bb10a='';while(this[_0x1d8871(0x18f)]){let {done:_0x483262,value:_0x406d7a}=await _0x20c7ae['read']();if(_0x483262)break;_0x4bb10a+=_0x3537cc[_0x1d8871(0x180)](_0x406d7a,{'stream':!0x0});let _0x9c5c6b=_0x4bb10a[_0x1d8871(0x154)]('\x0a');_0x4bb10a=_0x9c5c6b['pop']()||'';for(let _0x1fc8f4 of _0x9c5c6b){if(!_0x1fc8f4[_0x1d8871(0x1b7)](_0x1d8871(0x16c)))continue;try{let _0x154b11=JSON[_0x1d8871(0x161)](_0x1fc8f4[_0x1d8871(0x18d)](0x6));if(_0x154b11[_0x1d8871(0x169)]==='connected'){this[_0x1d8871(0x176)](_0x1d8871(0x186)),this['emit'](_0x1d8871(0x19d));continue;}if(_0x154b11[_0x1d8871(0x169)]===_0x1d8871(0x1a5)||_0x154b11['type']===_0x1d8871(0x16a)||_0x154b11[_0x1d8871(0x169)]==='broadcast')await this['processInbox']();}catch{}}}}catch(_0x643ba7){if(_0x643ba7[_0x1d8871(0x196)]===_0x1d8871(0x1d3))break;this[_0x1d8871(0x194)]('error',_0x643ba7),this[_0x1d8871(0x176)](_0x1d8871(0x16d)+_0x643ba7[_0x1d8871(0x1cc)]);}if(this['running'])this[_0x1d8871(0x194)](_0x1d8871(0x1ab)),this[_0x1d8871(0x176)](_0x1d8871(0x1b4)+_0x3779e2/0x3e8+_0x1d8871(0x190)),await this[_0x1d8871(0x171)](_0x3779e2),_0x3779e2=Math[_0x1d8871(0x183)](_0x3779e2*1.5,0xea60);}}async[a0_0x55eb92(0x1a2)](){const _0x13244c=a0_0x55eb92;try{let _0x5696c1=(await this[_0x13244c(0x18e)](_0x13244c(0x1a7),{'alias':this['alias'],'limit':0xa}))?.[_0x13244c(0x1a0)]||[];for(let _0x517d1f of _0x5696c1)await this['call']('ack_inbox',{'alias':this[_0x13244c(0x19c)],'message_id':_0x517d1f['id']}),this[_0x13244c(0x176)]('←\x20'+_0x517d1f[_0x13244c(0x1ac)]+':\x20'+_0x517d1f['content'][_0x13244c(0x18d)](0x0,0x3c)),this[_0x13244c(0x194)](_0x13244c(0x162),_0x517d1f),this[_0x13244c(0x194)](_0x13244c(0x1cc),_0x517d1f);}catch(_0x3a6e93){this[_0x13244c(0x176)]('inbox\x20error:\x20'+_0x3a6e93[_0x13244c(0x1cc)]);}}[a0_0x55eb92(0x171)](_0x11bcc3){return new Promise(_0x27bea7=>setTimeout(_0x27bea7,_0x11bcc3));}}var F=$;export{F as default,$ as CommHub};
1
+ const a0_0x2e1d66=a0_0x53f5;(function(_0x300e8c,_0x584917){const _0x45369d=a0_0x53f5,_0xa54d=_0x300e8c();while(!![]){try{const _0xa1f7f6=parseInt(_0x45369d(0x22a))/0x1*(parseInt(_0x45369d(0x1cf))/0x2)+parseInt(_0x45369d(0x1d0))/0x3*(parseInt(_0x45369d(0x232))/0x4)+parseInt(_0x45369d(0x207))/0x5*(-parseInt(_0x45369d(0x228))/0x6)+-parseInt(_0x45369d(0x214))/0x7*(parseInt(_0x45369d(0x1ce))/0x8)+parseInt(_0x45369d(0x1d9))/0x9+-parseInt(_0x45369d(0x212))/0xa*(parseInt(_0x45369d(0x1e2))/0xb)+parseInt(_0x45369d(0x1f0))/0xc;if(_0xa1f7f6===_0x584917)break;else _0xa54d['push'](_0xa54d['shift']());}catch(_0x478c9b){_0xa54d['push'](_0xa54d['shift']());}}}(a0_0x3f0d,0x58177));import{EventEmitter as a0_0x561018}from'events';import{hostname as a0_0x5321be}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x2e7b70,_0x1c474e)=>(_0x2e7b70??_0x1c474e)[a0_0x2e1d66(0x23b)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function a0_0x53f5(_0x2165a2,_0x1849de){_0x2165a2=_0x2165a2-0x1b2;const _0x3f0db0=a0_0x3f0d();let _0x53f546=_0x3f0db0[_0x2165a2];return _0x53f546;}function N(_0x2b96f6){const _0x16eeba=a0_0x2e1d66;return(_0x2b96f6 instanceof Error?_0x2b96f6[_0x16eeba(0x1dc)]:String(_0x2b96f6??_0x16eeba(0x204)))[_0x16eeba(0x23b)](K,_0x16eeba(0x1f1))[_0x16eeba(0x23b)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x16eeba(0x20b)](0x0,0xf0);}function O(_0x2289f3,_0x4465fb=process.env.ANET_TASK_TRACE_FORMAT===a0_0x2e1d66(0x1fd)){const _0x508ac6=a0_0x2e1d66;if(_0x4465fb)return JSON[_0x508ac6(0x1c2)](_0x2289f3);let _0x33b7b0=L(_0x2289f3[_0x508ac6(0x1ed)],_0x508ac6(0x1b2)),_0xd61be=L(_0x2289f3[_0x508ac6(0x20d)],_0x508ac6(0x1d1)),_0x1a21b2=_0x2289f3['error_code']?_0x508ac6(0x1e5)+_0x2289f3[_0x508ac6(0x1d7)]+':'+(_0x2289f3[_0x508ac6(0x1c0)]??''):'';return _0x508ac6(0x1b9)+_0x2289f3[_0x508ac6(0x222)]+_0x508ac6(0x219)+L(_0x2289f3[_0x508ac6(0x1be)],_0x508ac6(0x201))+_0x508ac6(0x23a)+L(_0x2289f3[_0x508ac6(0x211)],_0x508ac6(0x201))+_0x508ac6(0x1fb)+_0xd61be+_0x508ac6(0x22c)+_0x33b7b0+_0x508ac6(0x1bc)+L(_0x2289f3[_0x508ac6(0x235)],_0x508ac6(0x201))+_0x508ac6(0x224)+_0x2289f3[_0x508ac6(0x1e3)]+_0x508ac6(0x1b5)+_0x2289f3['duration_ms']+_0x508ac6(0x1f7)+_0x2289f3[_0x508ac6(0x1d4)]+_0x1a21b2;}function U(_0x25ec87){const _0x5098ce=a0_0x2e1d66;return{'event':{'sending':_0x5098ce(0x1c4),'delivered':_0x5098ce(0x1c6),'failed':_0x5098ce(0x1fe),'acked':_0x5098ce(0x1c1),'started':_0x5098ce(0x216),'replied':'task.replied','expired':_0x5098ce(0x230)}[_0x25ec87[_0x5098ce(0x222)]],..._0x25ec87};}function j(_0x30a116){const _0xccbc17=a0_0x2e1d66;let _0x40884f=_0x30a116?.['task_id']||_0x30a116?.['message_id']||_0x30a116?.['id'];if(_0x40884f)return String(_0x40884f);let _0x385d2d=_0x30a116?.[_0xccbc17(0x21f)]?.[0x0]?.['text'];if(typeof _0x385d2d!==_0xccbc17(0x22d))return null;try{let _0xdc82e3=JSON[_0xccbc17(0x1e9)](_0x385d2d);return _0xdc82e3?.[_0xccbc17(0x20d)]||_0xdc82e3?.[_0xccbc17(0x1d5)]||_0xdc82e3?.['id']||null;}catch{return null;}}async function X(_0x5b2a67,_0x509dd6){const _0x2d5f57=a0_0x2e1d66;let _0xd2ca1a=_0x509dd6[_0x2d5f57(0x1f8)]??Date[_0x2d5f57(0x1f8)],_0x176844=_0xd2ca1a(),_0xf1593d=(_0x37f74d,_0x3563b5,_0x50a272,_0x24cae2)=>{const _0x3b43f0=_0x2d5f57;_0x509dd6[_0x3b43f0(0x1cd)](O(U({'from_alias':_0x5b2a67['fromAlias'],'to_alias':_0x5b2a67[_0x3b43f0(0x1e4)],'task_id':_0x3563b5,'parent_task_id':_0x5b2a67['parentTaskId'],'network_id':_0x5b2a67['networkId'],'transport':_0x5b2a67[_0x3b43f0(0x1e3)],'status':_0x37f74d,'duration_ms':_0xd2ca1a()-_0x176844,'lifecycle_tracking':_0x5b2a67[_0x3b43f0(0x1b8)],..._0x50a272!==void 0x0?{'error_code':_0x24cae2||_0x3b43f0(0x238),'error_message':N(_0x50a272)}:{}})));};_0xf1593d(_0x2d5f57(0x1c5),null);try{let _0x1e83c5=await _0x509dd6[_0x2d5f57(0x1dd)](),_0x11f5dc=j(_0x1e83c5);if(_0x11f5dc)_0xf1593d(_0x2d5f57(0x1eb),_0x11f5dc);else{if(_0x1e83c5?.['ok']===!0x1||_0x1e83c5?.['error'])_0xf1593d(_0x2d5f57(0x237),_0x11f5dc,_0x1e83c5?.[_0x2d5f57(0x1e7)]||_0x2d5f57(0x1f6),_0x2d5f57(0x1e1));else _0xf1593d('failed',null,'CommHub\x20response\x20omitted\x20task_id',_0x2d5f57(0x1ef));}return _0x1e83c5;}catch(_0x424852){throw _0xf1593d(_0x2d5f57(0x237),null,_0x424852,_0x2d5f57(0x238)),_0x424852;}}async function Y(_0x590e96,_0x5824b4){const _0x54cb68=a0_0x2e1d66;return X({'fromAlias':_0x590e96[_0x54cb68(0x1f4)],'toAlias':_0x590e96[_0x54cb68(0x1e8)],'parentTaskId':_0x590e96[_0x54cb68(0x1cc)]||null,'networkId':_0x590e96[_0x54cb68(0x210)]||null,'transport':_0x54cb68(0x1fc),'lifecycleTracking':'not_tracked'},_0x5824b4);}class $ extends a0_0x561018{[a0_0x2e1d66(0x1d3)];[a0_0x2e1d66(0x1e8)];['token'];['agent'];['resumeId'];['heartbeatInterval'];[a0_0x2e1d66(0x20a)];[a0_0x2e1d66(0x229)];[a0_0x2e1d66(0x1bb)];['running']=!0x1;constructor(_0x24b6a1){const _0x56c3e1=a0_0x2e1d66;super();if(this['url']=_0x24b6a1['url'][_0x56c3e1(0x23b)](/\/$/,''),this[_0x56c3e1(0x1e8)]=_0x24b6a1[_0x56c3e1(0x1e8)],this['token']=_0x24b6a1[_0x56c3e1(0x20c)],this[_0x56c3e1(0x218)]=_0x24b6a1[_0x56c3e1(0x218)]||_0x56c3e1(0x208),this[_0x56c3e1(0x1e6)]=_0x56c3e1(0x1da)+_0x24b6a1[_0x56c3e1(0x1e8)]+'-'+Date[_0x56c3e1(0x1f8)]()[_0x56c3e1(0x1b4)](0x24),this['heartbeatInterval']=_0x24b6a1[_0x56c3e1(0x21a)]??0x2bf20,this[_0x56c3e1(0x20a)]=_0x24b6a1['reconnectDelay']??0xbb8,_0x24b6a1['autoConnect']!==!0x1)this[_0x56c3e1(0x1c8)]();}[a0_0x2e1d66(0x1cd)](_0x650a70){const _0x222959=a0_0x2e1d66;console[_0x222959(0x1cd)]('['+new Date()['toTimeString']()['slice'](0x0,0x8)+_0x222959(0x22e)+this[_0x222959(0x1e8)]+']\x20'+_0x650a70);}async['call'](_0x51db64,_0x4dbbf6){const _0x1c0537=a0_0x2e1d66;let _0x5b1282={'Content-Type':_0x1c0537(0x200),'Accept':_0x1c0537(0x1bd)};if(this[_0x1c0537(0x20c)])_0x5b1282['Authorization']=_0x1c0537(0x20e)+this[_0x1c0537(0x20c)];let _0xd5cb4a=await(await fetch(this[_0x1c0537(0x1d3)]+_0x1c0537(0x1e0),{'method':_0x1c0537(0x226),'headers':_0x5b1282,'body':JSON['stringify']({'jsonrpc':_0x1c0537(0x213),'id':Date[_0x1c0537(0x1f8)](),'method':'tools/call','params':{'name':_0x51db64,'arguments':_0x4dbbf6}})}))[_0x1c0537(0x209)](),_0x2eebf=_0xd5cb4a[_0x1c0537(0x1d8)](/data: (.+)/),_0x5b025d=_0x2eebf?JSON['parse'](_0x2eebf[0x1]):JSON[_0x1c0537(0x1e9)](_0xd5cb4a),_0x15f0a0=_0x5b025d?.[_0x1c0537(0x236)]?.[_0x1c0537(0x21f)]?.[0x0]?.[_0x1c0537(0x209)];return _0x15f0a0?JSON[_0x1c0537(0x1e9)](_0x15f0a0):_0x5b025d;}async[a0_0x2e1d66(0x1c8)](){const _0x555d91=a0_0x2e1d66;if(this[_0x555d91(0x239)])return;this['running']=!0x0,await this[_0x555d91(0x222)](_0x555d91(0x1cb)),this['log'](_0x555d91(0x223)),this[_0x555d91(0x229)]=setInterval(()=>{const _0x486f98=_0x555d91;this['status'](_0x486f98(0x1cb))[_0x486f98(0x233)](_0x4252f8=>this[_0x486f98(0x1cd)](_0x486f98(0x1ba)+_0x4252f8[_0x486f98(0x1dc)]));},this[_0x555d91(0x21a)]),this[_0x555d91(0x1f9)]();}async[a0_0x2e1d66(0x1b3)](){const _0xf0db2c=a0_0x2e1d66;if(this[_0xf0db2c(0x239)]=!0x1,this[_0xf0db2c(0x1bb)]?.[_0xf0db2c(0x1de)](),this[_0xf0db2c(0x229)])clearInterval(this[_0xf0db2c(0x229)]);await this[_0xf0db2c(0x222)](_0xf0db2c(0x1b6))[_0xf0db2c(0x233)](()=>{}),this[_0xf0db2c(0x1cd)]('disconnected');}async[a0_0x2e1d66(0x1dd)](_0x2378b6,_0x540ac1,_0x8a4af2=a0_0x2e1d66(0x22b)){const _0x23d759=a0_0x2e1d66;return Y({'alias':_0x2378b6,'fromAlias':this[_0x23d759(0x1e8)]},{'log':_0x95362=>console['log'](_0x95362),'send':()=>this[_0x23d759(0x23c)](_0x23d759(0x234),{'alias':_0x2378b6,'task':_0x540ac1,'priority':_0x8a4af2,'from_session':this[_0x23d759(0x1e8)]})});}async[a0_0x2e1d66(0x1dc)](_0x5bae5e,_0x4839f8){const _0x400909=a0_0x2e1d66;return this[_0x400909(0x23c)](_0x400909(0x20f),{'alias':_0x5bae5e,'message':_0x4839f8,'from_session':this['alias']});}async['reply'](_0x197678,_0x1792a5,_0xc14eba=a0_0x2e1d66(0x1fa)){const _0x4dbec1=a0_0x2e1d66;return this['call'](_0x4dbec1(0x21d),{'in_reply_to':_0x197678,'text':_0x1792a5,'status':_0xc14eba});}async[a0_0x2e1d66(0x222)](_0x45bdb5,_0x183f8f){const _0x29a335=a0_0x2e1d66;return this[_0x29a335(0x23c)](_0x29a335(0x1ff),{'resume_id':this['resumeId'],'alias':this[_0x29a335(0x1e8)],'status':_0x45bdb5,'server':a0_0x5321be(),'hostname':a0_0x5321be(),'agent':this[_0x29a335(0x218)],'project_dir':process[_0x29a335(0x1b7)](),..._0x183f8f});}async[a0_0x2e1d66(0x22f)](){const _0x447cde=a0_0x2e1d66;return this[_0x447cde(0x23c)](_0x447cde(0x1ca),{});}async[a0_0x2e1d66(0x1ec)](_0x186230,_0xe99726){const _0x267746=a0_0x2e1d66;return this[_0x267746(0x23c)]('broadcast',{'message':_0x186230,'filter_server':_0xe99726?.[_0x267746(0x21b)],'filter_status':_0xe99726?.[_0x267746(0x222)]});}async[a0_0x2e1d66(0x1f9)](){const _0x3232ef=a0_0x2e1d66;let _0x2c9864=encodeURIComponent(this[_0x3232ef(0x1e8)]),_0x58eaba=this['url']+_0x3232ef(0x1bf)+_0x2c9864,_0x2f47cc=this['reconnectDelay'];while(this[_0x3232ef(0x239)]){try{this[_0x3232ef(0x1bb)]=new AbortController();let _0x153f3f={'Accept':_0x3232ef(0x220)};if(this['token'])_0x153f3f[_0x3232ef(0x1f3)]=_0x3232ef(0x20e)+this[_0x3232ef(0x20c)];let _0x1e45b7=await fetch(_0x58eaba,{'headers':_0x153f3f,'signal':this['sseAbort'][_0x3232ef(0x21e)]});if(!_0x1e45b7['ok']||!_0x1e45b7[_0x3232ef(0x1d2)]){this[_0x3232ef(0x1cd)](_0x3232ef(0x1d6)+_0x1e45b7[_0x3232ef(0x222)]),await this[_0x3232ef(0x1c9)](_0x2f47cc),_0x2f47cc=Math[_0x3232ef(0x1df)](_0x2f47cc*1.5,0xea60);continue;}_0x2f47cc=this['reconnectDelay'];let _0x3969aa=_0x1e45b7[_0x3232ef(0x1d2)][_0x3232ef(0x1c3)](),_0x35e2f9=new TextDecoder(),_0x47887d='';while(this['running']){let {done:_0x34785f,value:_0x560e24}=await _0x3969aa[_0x3232ef(0x217)]();if(_0x34785f)break;_0x47887d+=_0x35e2f9[_0x3232ef(0x225)](_0x560e24,{'stream':!0x0});let _0x4808be=_0x47887d[_0x3232ef(0x215)]('\x0a');_0x47887d=_0x4808be[_0x3232ef(0x205)]()||'';for(let _0x2a9b01 of _0x4808be){if(!_0x2a9b01[_0x3232ef(0x21c)]('data:\x20'))continue;try{let _0x2cc122=JSON[_0x3232ef(0x1e9)](_0x2a9b01[_0x3232ef(0x20b)](0x6));if(_0x2cc122[_0x3232ef(0x231)]==='connected'){this[_0x3232ef(0x1cd)]('SSE\x20connected'),this[_0x3232ef(0x1f2)](_0x3232ef(0x206));continue;}if(_0x2cc122[_0x3232ef(0x231)]===_0x3232ef(0x203)||_0x2cc122[_0x3232ef(0x231)]===_0x3232ef(0x1ea)||_0x2cc122['type']===_0x3232ef(0x1ec))await this[_0x3232ef(0x1f5)]();}catch{}}}}catch(_0x4cdbc8){if(_0x4cdbc8[_0x3232ef(0x1db)]==='AbortError')break;this['emit'](_0x3232ef(0x1e7),_0x4cdbc8),this['log']('SSE\x20error:\x20'+_0x4cdbc8[_0x3232ef(0x1dc)]);}if(this[_0x3232ef(0x239)])this[_0x3232ef(0x1f2)]('disconnected'),this[_0x3232ef(0x1cd)]('SSE\x20reconnecting\x20in\x20'+_0x2f47cc/0x3e8+_0x3232ef(0x1ee)),await this['sleep'](_0x2f47cc),_0x2f47cc=Math[_0x3232ef(0x1df)](_0x2f47cc*1.5,0xea60);}}async['processInbox'](){const _0x1a7d92=a0_0x2e1d66;try{let _0x156fbc=(await this[_0x1a7d92(0x23c)](_0x1a7d92(0x221),{'alias':this[_0x1a7d92(0x1e8)],'limit':0xa}))?.[_0x1a7d92(0x202)]||[];for(let _0x49626c of _0x156fbc)await this[_0x1a7d92(0x23c)]('ack_inbox',{'alias':this['alias'],'message_id':_0x49626c['id']}),this[_0x1a7d92(0x1cd)]('←\x20'+_0x49626c[_0x1a7d92(0x1c7)]+':\x20'+_0x49626c[_0x1a7d92(0x21f)][_0x1a7d92(0x20b)](0x0,0x3c)),this[_0x1a7d92(0x1f2)]('task',_0x49626c),this['emit'](_0x1a7d92(0x1dc),_0x49626c);}catch(_0x5bfd11){this[_0x1a7d92(0x1cd)](_0x1a7d92(0x227)+_0x5bfd11['message']);}}[a0_0x2e1d66(0x1c9)](_0x2969ff){return new Promise(_0x5820b4=>setTimeout(_0x5820b4,_0x2969ff));}}function a0_0x3f0d(){const _0x21f5fd=['new_message','delivered','broadcast','parent_task_id','s...','missing_task_id','8851956mfEbiw','[REDACTED]','emit','Authorization','fromAlias','processInbox','CommHub\x20rejected\x20task','\x20lifecycle=','now','connectSSE','completed','\x20task_id=','mcp_http','json','task.send.failed','report_status','application/json','<unknown>','messages','new_task','unknown\x20error','pop','connected','70895HLPsgP','sdk','text','reconnectDelay','slice','token','task_id','Bearer\x20','send_message','networkId','to_alias','10PHhOxh','2.0','1603QzuSoI','split','task.started','read','agent','\x20from=','heartbeatInterval','server','startsWith','send_reply','signal','content','text/event-stream','get_inbox','status','registered','\x20transport=','decode','POST','inbox\x20error:\x20','186SLxbrC','heartbeatTimer','616575WBNYzc','normal','\x20parent_task_id=','string',']\x20[commhub:','getAllStatus','task.expired','type','495124jyoSsi','catch','send_task','network_id','result','failed','send_failed','running','\x20to=','replace','call','<missing>','disconnect','toString','\x20duration_ms=','offline','cwd','lifecycleTracking','[commhub:task]\x20','heartbeat\x20failed:\x20','sseAbort','\x20network_id=','application/json,\x20text/event-stream','from_alias','/events/','error_message','task.ack','stringify','getReader','task.send.start','sending','task.send.delivered','from_session','connect','sleep','get_all_status','idle','parentTaskId','log','11560yVxcUR','2BdgPbx','3ylNufY','<pending>','body','url','lifecycle_tracking','message_id','SSE\x20failed:\x20','error_code','match','2242422znmdCi','sdk-','name','message','send','abort','min','/mcp','send_rejected','6554900SJRXcM','transport','toAlias','\x20error=','resumeId','error','alias','parse'];a0_0x3f0d=function(){return _0x21f5fd;};return a0_0x3f0d();}var F=$;export{F as default,$ as CommHub};