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

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_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};
1
+ const a0_0x24ce0c=a0_0x2688;(function(_0x507b64,_0x1f01e0){const _0x5a12a3=a0_0x2688,_0x3b70bd=_0x507b64();while(!![]){try{const _0x3772a9=parseInt(_0x5a12a3(0xd2))/0x1*(-parseInt(_0x5a12a3(0xd9))/0x2)+-parseInt(_0x5a12a3(0x121))/0x3+parseInt(_0x5a12a3(0x112))/0x4+-parseInt(_0x5a12a3(0xb7))/0x5*(-parseInt(_0x5a12a3(0xdc))/0x6)+parseInt(_0x5a12a3(0xe7))/0x7*(-parseInt(_0x5a12a3(0xef))/0x8)+-parseInt(_0x5a12a3(0xe6))/0x9*(-parseInt(_0x5a12a3(0x100))/0xa)+parseInt(_0x5a12a3(0xf6))/0xb*(parseInt(_0x5a12a3(0x12a))/0xc);if(_0x3772a9===_0x1f01e0)break;else _0x3b70bd['push'](_0x3b70bd['shift']());}catch(_0x48ea61){_0x3b70bd['push'](_0x3b70bd['shift']());}}}(a0_0x3b1f,0x5b46f));import{EventEmitter as a0_0x53906d}from'events';import{hostname as a0_0x1b9033}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x998b08,_0x19d243)=>(_0x998b08??_0x19d243)[a0_0x24ce0c(0x11d)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x2596b0){const _0xe66408=a0_0x24ce0c;return(_0x2596b0 instanceof Error?_0x2596b0['message']:String(_0x2596b0??_0xe66408(0xf9)))['replace'](K,_0xe66408(0x108))[_0xe66408(0x11d)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0xe66408(0xd4)](0x0,0xf0);}function O(_0x1701f3,_0x1f5b11=process.env.ANET_TASK_TRACE_FORMAT===a0_0x24ce0c(0xe0)){const _0x57b4f0=a0_0x24ce0c;if(_0x1f5b11)return JSON[_0x57b4f0(0xcf)](_0x1701f3);let _0x17ff30=L(_0x1701f3['parent_task_id'],_0x57b4f0(0xf0)),_0x4f56e9=L(_0x1701f3['task_id'],'<pending>'),_0x5c57d7=_0x1701f3[_0x57b4f0(0xdb)]?_0x57b4f0(0xe2)+_0x1701f3[_0x57b4f0(0xdb)]+':'+(_0x1701f3[_0x57b4f0(0x111)]??''):'';return _0x57b4f0(0xeb)+_0x1701f3[_0x57b4f0(0x11f)]+'\x20from='+L(_0x1701f3['from_alias'],_0x57b4f0(0xce))+_0x57b4f0(0xde)+L(_0x1701f3['to_alias'],_0x57b4f0(0xce))+_0x57b4f0(0xec)+_0x4f56e9+_0x57b4f0(0xee)+_0x17ff30+'\x20network_id='+L(_0x1701f3['network_id'],'<unknown>')+_0x57b4f0(0x10d)+_0x1701f3['transport']+'\x20duration_ms='+_0x1701f3[_0x57b4f0(0xc8)]+_0x57b4f0(0x117)+_0x1701f3[_0x57b4f0(0x120)]+_0x5c57d7;}function U(_0x38ed57){const _0x1550d2=a0_0x24ce0c;return{'event':{'sending':_0x1550d2(0xc2),'delivered':_0x1550d2(0xc3),'failed':'task.send.failed','acked':_0x1550d2(0xd3),'started':_0x1550d2(0x107),'replied':_0x1550d2(0xf4),'expired':'task.expired'}[_0x38ed57[_0x1550d2(0x11f)]],..._0x38ed57};}function a0_0x3b1f(){const _0x4a2d14=['disconnect','duration_ms','send_failed','POST','heartbeatTimer','delivered','sdk-','<unknown>','stringify','sseAbort','failed','409WoqLkL','task.ack','slice','messages','sending','connect','connected','1154sBFuIY','min','error_code','1987812TiABus','text','\x20to=','agent','json','SSE\x20connected','\x20error=','SSE\x20failed:\x20','type','Authorization','161613CJynvP','210266mNpOci','data:\x20','s...','message','[commhub:task]\x20','\x20task_id=','from_session','\x20parent_task_id=','16MxypBa','<missing>','toTimeString','message_id','result','task.replied','now','5709ndbAYt','broadcast','parentTaskId','unknown\x20error','name','application/json,\x20text/event-stream','string','body','CommHub\x20rejected\x20task','application/json','190HfqgvW','parse','processInbox','catch','emit','error','sleep','task.started','[REDACTED]','SSE\x20reconnecting\x20in\x20','AbortError','missing_task_id','url','\x20transport=','idle','send_task','getAllStatus','error_message','1683172TmspYS','inbox\x20error:\x20','server','new_message','send_reply','\x20lifecycle=','task_id','token','decode','getReader','sdk','replace','ack_inbox','status','lifecycle_tracking','2025159ufpDzX','report_status','networkId','reconnectDelay','connectSSE','lifecycleTracking','fromAlias','Bearer\x20','CommHub\x20response\x20omitted\x20task_id','5820LZQoMY','offline','split','autoConnect','alias','pop','disconnected','send_rejected','/mcp','send','5QIbMbL','log','startsWith','read','normal','heartbeatInterval','running','reply','match','tools/call','not_tracked','task.send.start','task.send.delivered','content','resumeId','call'];a0_0x3b1f=function(){return _0x4a2d14;};return a0_0x3b1f();}function j(_0x109efb){const _0x453e5d=a0_0x24ce0c;let _0x1bb8a1=_0x109efb?.[_0x453e5d(0x118)]||_0x109efb?.[_0x453e5d(0xf2)]||_0x109efb?.['id'];if(_0x1bb8a1)return String(_0x1bb8a1);let _0x51825d=_0x109efb?.[_0x453e5d(0xc4)]?.[0x0]?.['text'];if(typeof _0x51825d!==_0x453e5d(0xfc))return null;try{let _0x41a48a=JSON[_0x453e5d(0x101)](_0x51825d);return _0x41a48a?.[_0x453e5d(0x118)]||_0x41a48a?.[_0x453e5d(0xf2)]||_0x41a48a?.['id']||null;}catch{return null;}}async function X(_0x6ad33a,_0x1184aa){const _0x29f13b=a0_0x24ce0c;let _0x10a24d=_0x1184aa[_0x29f13b(0xf5)]??Date[_0x29f13b(0xf5)],_0x1153fa=_0x10a24d(),_0x115425=(_0xeebe10,_0x87d9cc,_0x568519,_0xf72e34)=>{const _0x14328c=_0x29f13b;_0x1184aa[_0x14328c(0xb8)](O(U({'from_alias':_0x6ad33a[_0x14328c(0x127)],'to_alias':_0x6ad33a['toAlias'],'task_id':_0x87d9cc,'parent_task_id':_0x6ad33a[_0x14328c(0xf8)],'network_id':_0x6ad33a['networkId'],'transport':_0x6ad33a['transport'],'status':_0xeebe10,'duration_ms':_0x10a24d()-_0x1153fa,'lifecycle_tracking':_0x6ad33a[_0x14328c(0x126)],..._0x568519!==void 0x0?{'error_code':_0xf72e34||_0x14328c(0xc9),'error_message':N(_0x568519)}:{}})));};_0x115425(_0x29f13b(0xd6),null);try{let _0x73efc6=await _0x1184aa[_0x29f13b(0xb6)](),_0x333b04=j(_0x73efc6);if(_0x333b04)_0x115425(_0x29f13b(0xcc),_0x333b04);else{if(_0x73efc6?.['ok']===!0x1||_0x73efc6?.[_0x29f13b(0x105)])_0x115425('failed',_0x333b04,_0x73efc6?.[_0x29f13b(0x105)]||_0x29f13b(0xfe),_0x29f13b(0xb4));else _0x115425(_0x29f13b(0xd1),null,_0x29f13b(0x129),_0x29f13b(0x10b));}return _0x73efc6;}catch(_0x494259){throw _0x115425(_0x29f13b(0xd1),null,_0x494259,_0x29f13b(0xc9)),_0x494259;}}async function Y(_0x286109,_0x53005c){const _0x1c3cb0=a0_0x24ce0c;return X({'fromAlias':_0x286109[_0x1c3cb0(0x127)],'toAlias':_0x286109[_0x1c3cb0(0x12e)],'parentTaskId':_0x286109[_0x1c3cb0(0xf8)]||null,'networkId':_0x286109[_0x1c3cb0(0x123)]||null,'transport':'mcp_http','lifecycleTracking':_0x1c3cb0(0xc1)},_0x53005c);}class $ extends a0_0x53906d{[a0_0x24ce0c(0x10c)];['alias'];['token'];[a0_0x24ce0c(0xdf)];[a0_0x24ce0c(0xc5)];[a0_0x24ce0c(0xbc)];['reconnectDelay'];['heartbeatTimer'];[a0_0x24ce0c(0xd0)];['running']=!0x1;constructor(_0x281489){const _0x57d936=a0_0x24ce0c;super();if(this['url']=_0x281489[_0x57d936(0x10c)][_0x57d936(0x11d)](/\/$/,''),this[_0x57d936(0x12e)]=_0x281489[_0x57d936(0x12e)],this[_0x57d936(0x119)]=_0x281489['token'],this[_0x57d936(0xdf)]=_0x281489[_0x57d936(0xdf)]||_0x57d936(0x11c),this[_0x57d936(0xc5)]=_0x57d936(0xcd)+_0x281489['alias']+'-'+Date['now']()['toString'](0x24),this[_0x57d936(0xbc)]=_0x281489[_0x57d936(0xbc)]??0x2bf20,this[_0x57d936(0x124)]=_0x281489['reconnectDelay']??0xbb8,_0x281489[_0x57d936(0x12d)]!==!0x1)this['connect']();}[a0_0x24ce0c(0xb8)](_0xdc4580){const _0x33b971=a0_0x24ce0c;console[_0x33b971(0xb8)]('['+new Date()[_0x33b971(0xf1)]()[_0x33b971(0xd4)](0x0,0x8)+']\x20[commhub:'+this['alias']+']\x20'+_0xdc4580);}async[a0_0x24ce0c(0xc6)](_0x550f15,_0x1a8238){const _0xf66c21=a0_0x24ce0c;let _0x5b9c0d={'Content-Type':_0xf66c21(0xff),'Accept':_0xf66c21(0xfb)};if(this[_0xf66c21(0x119)])_0x5b9c0d[_0xf66c21(0xe5)]='Bearer\x20'+this[_0xf66c21(0x119)];let _0x145109=await(await fetch(this[_0xf66c21(0x10c)]+_0xf66c21(0xb5),{'method':_0xf66c21(0xca),'headers':_0x5b9c0d,'body':JSON['stringify']({'jsonrpc':'2.0','id':Date['now'](),'method':_0xf66c21(0xc0),'params':{'name':_0x550f15,'arguments':_0x1a8238}})}))[_0xf66c21(0xdd)](),_0x2b555d=_0x145109[_0xf66c21(0xbf)](/data: (.+)/),_0x213f8a=_0x2b555d?JSON['parse'](_0x2b555d[0x1]):JSON[_0xf66c21(0x101)](_0x145109),_0x2a3fe4=_0x213f8a?.[_0xf66c21(0xf3)]?.[_0xf66c21(0xc4)]?.[0x0]?.['text'];return _0x2a3fe4?JSON[_0xf66c21(0x101)](_0x2a3fe4):_0x213f8a;}async[a0_0x24ce0c(0xd7)](){const _0x3cedbb=a0_0x24ce0c;if(this['running'])return;this[_0x3cedbb(0xbd)]=!0x0,await this[_0x3cedbb(0x11f)](_0x3cedbb(0x10e)),this['log']('registered'),this['heartbeatTimer']=setInterval(()=>{const _0x5db44c=_0x3cedbb;this['status'](_0x5db44c(0x10e))[_0x5db44c(0x103)](_0x3c629a=>this['log']('heartbeat\x20failed:\x20'+_0x3c629a['message']));},this[_0x3cedbb(0xbc)]),this[_0x3cedbb(0x125)]();}async[a0_0x24ce0c(0xc7)](){const _0x2f4827=a0_0x24ce0c;if(this['running']=!0x1,this[_0x2f4827(0xd0)]?.['abort'](),this[_0x2f4827(0xcb)])clearInterval(this[_0x2f4827(0xcb)]);await this[_0x2f4827(0x11f)](_0x2f4827(0x12b))[_0x2f4827(0x103)](()=>{}),this[_0x2f4827(0xb8)](_0x2f4827(0xb3));}async['send'](_0x576b35,_0x3d3bbe,_0x19b667=a0_0x24ce0c(0xbb)){const _0x718fc5=a0_0x24ce0c;return Y({'alias':_0x576b35,'fromAlias':this[_0x718fc5(0x12e)]},{'log':_0x2ff1b2=>console[_0x718fc5(0xb8)](_0x2ff1b2),'send':()=>this[_0x718fc5(0xc6)](_0x718fc5(0x10f),{'alias':_0x576b35,'task':_0x3d3bbe,'priority':_0x19b667,'from_session':this['alias']})});}async['message'](_0x9bd713,_0x283ca1){const _0x3c10ca=a0_0x24ce0c;return this[_0x3c10ca(0xc6)]('send_message',{'alias':_0x9bd713,'message':_0x283ca1,'from_session':this['alias']});}async[a0_0x24ce0c(0xbe)](_0x5c3f87,_0x5960fc,_0xb25af5='completed'){const _0x108618=a0_0x24ce0c;return this['call'](_0x108618(0x116),{'in_reply_to':_0x5c3f87,'text':_0x5960fc,'status':_0xb25af5});}async[a0_0x24ce0c(0x11f)](_0x1fe71f,_0x321f5e){const _0xa79b47=a0_0x24ce0c;return this['call'](_0xa79b47(0x122),{'resume_id':this[_0xa79b47(0xc5)],'alias':this['alias'],'status':_0x1fe71f,'server':a0_0x1b9033(),'hostname':a0_0x1b9033(),'agent':this[_0xa79b47(0xdf)],'project_dir':process['cwd'](),..._0x321f5e});}async[a0_0x24ce0c(0x110)](){const _0x5e47b3=a0_0x24ce0c;return this[_0x5e47b3(0xc6)]('get_all_status',{});}async[a0_0x24ce0c(0xf7)](_0x19b00b,_0xc59fd9){const _0x99ee3b=a0_0x24ce0c;return this['call'](_0x99ee3b(0xf7),{'message':_0x19b00b,'filter_server':_0xc59fd9?.[_0x99ee3b(0x114)],'filter_status':_0xc59fd9?.[_0x99ee3b(0x11f)]});}async[a0_0x24ce0c(0x125)](){const _0x54811e=a0_0x24ce0c;let _0x49a6ed=encodeURIComponent(this['alias']),_0x1dfa4f=this[_0x54811e(0x10c)]+'/events/'+_0x49a6ed,_0x4b1406=this[_0x54811e(0x124)];while(this[_0x54811e(0xbd)]){try{this[_0x54811e(0xd0)]=new AbortController();let _0x22f972={'Accept':'text/event-stream'};if(this[_0x54811e(0x119)])_0x22f972[_0x54811e(0xe5)]=_0x54811e(0x128)+this[_0x54811e(0x119)];let _0x1449bc=await fetch(_0x1dfa4f,{'headers':_0x22f972,'signal':this[_0x54811e(0xd0)]['signal']});if(!_0x1449bc['ok']||!_0x1449bc[_0x54811e(0xfd)]){this[_0x54811e(0xb8)](_0x54811e(0xe3)+_0x1449bc[_0x54811e(0x11f)]),await this[_0x54811e(0x106)](_0x4b1406),_0x4b1406=Math['min'](_0x4b1406*1.5,0xea60);continue;}_0x4b1406=this['reconnectDelay'];let _0x5dfc88=_0x1449bc['body'][_0x54811e(0x11b)](),_0x21dd6d=new TextDecoder(),_0x23e658='';while(this[_0x54811e(0xbd)]){let {done:_0x2a5289,value:_0x1819f5}=await _0x5dfc88[_0x54811e(0xba)]();if(_0x2a5289)break;_0x23e658+=_0x21dd6d[_0x54811e(0x11a)](_0x1819f5,{'stream':!0x0});let _0x53deb2=_0x23e658[_0x54811e(0x12c)]('\x0a');_0x23e658=_0x53deb2[_0x54811e(0x12f)]()||'';for(let _0x1ad8e8 of _0x53deb2){if(!_0x1ad8e8[_0x54811e(0xb9)](_0x54811e(0xe8)))continue;try{let _0x5b8f58=JSON[_0x54811e(0x101)](_0x1ad8e8[_0x54811e(0xd4)](0x6));if(_0x5b8f58[_0x54811e(0xe4)]===_0x54811e(0xd8)){this[_0x54811e(0xb8)](_0x54811e(0xe1)),this[_0x54811e(0x104)](_0x54811e(0xd8));continue;}if(_0x5b8f58[_0x54811e(0xe4)]==='new_task'||_0x5b8f58[_0x54811e(0xe4)]===_0x54811e(0x115)||_0x5b8f58[_0x54811e(0xe4)]===_0x54811e(0xf7))await this[_0x54811e(0x102)]();}catch{}}}}catch(_0x40701f){if(_0x40701f[_0x54811e(0xfa)]===_0x54811e(0x10a))break;this[_0x54811e(0x104)]('error',_0x40701f),this[_0x54811e(0xb8)]('SSE\x20error:\x20'+_0x40701f['message']);}if(this[_0x54811e(0xbd)])this[_0x54811e(0x104)](_0x54811e(0xb3)),this['log'](_0x54811e(0x109)+_0x4b1406/0x3e8+_0x54811e(0xe9)),await this[_0x54811e(0x106)](_0x4b1406),_0x4b1406=Math[_0x54811e(0xda)](_0x4b1406*1.5,0xea60);}}async['processInbox'](){const _0x478efa=a0_0x24ce0c;try{let _0x2229c4=(await this['call']('get_inbox',{'alias':this['alias'],'limit':0xa}))?.[_0x478efa(0xd5)]||[];for(let _0x431175 of _0x2229c4)await this[_0x478efa(0xc6)](_0x478efa(0x11e),{'alias':this[_0x478efa(0x12e)],'message_id':_0x431175['id']}),this['log']('←\x20'+_0x431175[_0x478efa(0xed)]+':\x20'+_0x431175['content'][_0x478efa(0xd4)](0x0,0x3c)),this[_0x478efa(0x104)]('task',_0x431175),this[_0x478efa(0x104)]('message',_0x431175);}catch(_0x3c1186){this[_0x478efa(0xb8)](_0x478efa(0x113)+_0x3c1186[_0x478efa(0xea)]);}}[a0_0x24ce0c(0x106)](_0x5ae567){return new Promise(_0x520f4e=>setTimeout(_0x520f4e,_0x5ae567));}}var F=$;function a0_0x2688(_0x50cf8d,_0x54c882){_0x50cf8d=_0x50cf8d-0xb3;const _0x3b1f68=a0_0x3b1f();let _0x268842=_0x3b1f68[_0x50cf8d];return _0x268842;}export{F as default,$ as CommHub};