@sleep2agi/agent-network 2.3.0-preview.80 → 2.3.0-preview.81
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.
package/dist/src/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a0_0x162b24=a0_0x4374;(function(_0x332f59,_0x2e54f1){const _0x4e3089=a0_0x4374,_0x3937d0=_0x332f59();while(!![]){try{const _0x5272f8=parseInt(_0x4e3089(0x11f))/0x1*(-parseInt(_0x4e3089(0xc6))/0x2)+-parseInt(_0x4e3089(0xdd))/0x3+parseInt(_0x4e3089(0x121))/0x4*(-parseInt(_0x4e3089(0xd3))/0x5)+parseInt(_0x4e3089(0x125))/0x6+-parseInt(_0x4e3089(0x113))/0x7+parseInt(_0x4e3089(0xe0))/0x8*(parseInt(_0x4e3089(0x132))/0x9)+-parseInt(_0x4e3089(0x101))/0xa*(-parseInt(_0x4e3089(0xbe))/0xb);if(_0x5272f8===_0x2e54f1)break;else _0x3937d0['push'](_0x3937d0['shift']());}catch(_0x370ca0){_0x3937d0['push'](_0x3937d0['shift']());}}}(a0_0x3edb,0x88359));import{EventEmitter as a0_0x27807f}from'events';import{hostname as a0_0x520ff0}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x4be9be,_0x332394)=>(_0x4be9be??_0x332394)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x3d7f6f){const _0x47c7b3=a0_0x4374;return(_0x3d7f6f instanceof Error?_0x3d7f6f[_0x47c7b3(0xef)]:String(_0x3d7f6f??_0x47c7b3(0xf1)))[_0x47c7b3(0xda)](K,_0x47c7b3(0x102))[_0x47c7b3(0xda)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0xb11477,_0x38f5ab=process.env.ANET_TASK_TRACE_FORMAT===a0_0x162b24(0xf9)){const _0x58690b=a0_0x162b24;if(_0x38f5ab)return JSON['stringify'](_0xb11477);let _0x403737=L(_0xb11477['parent_task_id'],_0x58690b(0xc9)),_0x1c0ebd=L(_0xb11477[_0x58690b(0x119)],'<pending>'),_0x4f4cff=_0xb11477[_0x58690b(0xfd)]?_0x58690b(0xbb)+_0xb11477[_0x58690b(0xfd)]+':'+(_0xb11477['error_message']??''):'';return _0x58690b(0x115)+_0xb11477[_0x58690b(0x124)]+_0x58690b(0xca)+L(_0xb11477[_0x58690b(0xc8)],_0x58690b(0x129))+_0x58690b(0xd0)+L(_0xb11477[_0x58690b(0xd7)],'<unknown>')+_0x58690b(0x10d)+_0x1c0ebd+_0x58690b(0x10c)+_0x403737+_0x58690b(0x10f)+L(_0xb11477['network_id'],_0x58690b(0x129))+'\x20transport='+_0xb11477['transport']+_0x58690b(0xdb)+_0xb11477[_0x58690b(0xff)]+'\x20lifecycle='+_0xb11477[_0x58690b(0x130)]+_0x4f4cff;}function U(_0x1fe6a5){const _0xbce298=a0_0x162b24;return{'event':{'sending':_0xbce298(0xdc),'delivered':'task.send.delivered','failed':_0xbce298(0xe5),'acked':_0xbce298(0x114),'started':'task.started','replied':_0xbce298(0xb8),'expired':'task.expired'}[_0x1fe6a5[_0xbce298(0x124)]],..._0x1fe6a5};}function j(_0x57c89b){const _0x240cf0=a0_0x162b24;let _0x1fced9=_0x57c89b?.['task_id']||_0x57c89b?.[_0x240cf0(0x11d)]||_0x57c89b?.['id'];if(_0x1fced9)return String(_0x1fced9);let _0x28f9c8=_0x57c89b?.[_0x240cf0(0xd2)]?.[0x0]?.[_0x240cf0(0x134)];if(typeof _0x28f9c8!==_0x240cf0(0xf6))return null;try{let _0x247683=JSON['parse'](_0x28f9c8);return _0x247683?.['task_id']||_0x247683?.['message_id']||_0x247683?.['id']||null;}catch{return null;}}async function X(_0x2c76b4,_0x4d1210){const _0xdc8e1b=a0_0x162b24;let _0x38beb3=_0x4d1210['now']??Date[_0xdc8e1b(0xcc)],_0x4e608a=_0x38beb3(),_0x3e7eb1=(_0x5efa61,_0x32c170,_0x8cdb82,_0x5b019f)=>{const _0x3ae2fb=_0xdc8e1b;_0x4d1210['log'](O(U({'from_alias':_0x2c76b4['fromAlias'],'to_alias':_0x2c76b4[_0x3ae2fb(0x110)],'task_id':_0x32c170,'parent_task_id':_0x2c76b4['parentTaskId'],'network_id':_0x2c76b4[_0x3ae2fb(0xea)],'transport':_0x2c76b4[_0x3ae2fb(0xd1)],'status':_0x5efa61,'duration_ms':_0x38beb3()-_0x4e608a,'lifecycle_tracking':_0x2c76b4[_0x3ae2fb(0x11c)],..._0x8cdb82!==void 0x0?{'error_code':_0x5b019f||'send_failed','error_message':N(_0x8cdb82)}:{}})));};_0x3e7eb1('sending',null);try{let _0x54b8a6=await _0x4d1210[_0xdc8e1b(0xcd)](),_0x87c771=j(_0x54b8a6);if(_0x87c771)_0x3e7eb1(_0xdc8e1b(0x12a),_0x87c771);else{if(_0x54b8a6?.['ok']===!0x1||_0x54b8a6?.[_0xdc8e1b(0x127)])_0x3e7eb1(_0xdc8e1b(0x12f),_0x87c771,_0x54b8a6?.[_0xdc8e1b(0x127)]||_0xdc8e1b(0x100),_0xdc8e1b(0xfa));else _0x3e7eb1(_0xdc8e1b(0x12f),null,_0xdc8e1b(0xf7),_0xdc8e1b(0xfb));}return _0x54b8a6;}catch(_0x29a54b){throw _0x3e7eb1(_0xdc8e1b(0x12f),null,_0x29a54b,_0xdc8e1b(0xf4)),_0x29a54b;}}async function Y(_0xd80b11,_0x2809cd){const _0x3357fe=a0_0x162b24;return X({'fromAlias':_0xd80b11[_0x3357fe(0x133)],'toAlias':_0xd80b11['alias'],'parentTaskId':_0xd80b11[_0x3357fe(0x109)]||null,'networkId':_0xd80b11['networkId']||null,'transport':_0x3357fe(0x112),'lifecycleTracking':_0x3357fe(0x131)},_0x2809cd);}class $ extends a0_0x27807f{[a0_0x162b24(0xfc)];[a0_0x162b24(0xba)];[a0_0x162b24(0x122)];[a0_0x162b24(0x108)];[a0_0x162b24(0xc7)];['heartbeatInterval'];[a0_0x162b24(0x123)];['heartbeatTimer'];[a0_0x162b24(0xd5)];['running']=!0x1;constructor(_0x332e5c){const _0x4da888=a0_0x162b24;super();if(this[_0x4da888(0xfc)]=_0x332e5c[_0x4da888(0xfc)]['replace'](/\/$/,''),this[_0x4da888(0xba)]=_0x332e5c[_0x4da888(0xba)],this[_0x4da888(0x122)]=_0x332e5c[_0x4da888(0x122)],this[_0x4da888(0x108)]=_0x332e5c[_0x4da888(0x108)]||'sdk',this['resumeId']='sdk-'+_0x332e5c[_0x4da888(0xba)]+'-'+Date[_0x4da888(0xcc)]()['toString'](0x24),this[_0x4da888(0xc4)]=_0x332e5c[_0x4da888(0xc4)]??0x2bf20,this[_0x4da888(0x123)]=_0x332e5c[_0x4da888(0x123)]??0xbb8,_0x332e5c[_0x4da888(0xe8)]!==!0x1)this[_0x4da888(0xd4)]();}[a0_0x162b24(0xcf)](_0x12b61f){const _0x6c3629=a0_0x162b24;console[_0x6c3629(0xcf)]('['+new Date()[_0x6c3629(0xcb)]()[_0x6c3629(0xd6)](0x0,0x8)+_0x6c3629(0xe3)+this[_0x6c3629(0xba)]+']\x20'+_0x12b61f);}async[a0_0x162b24(0xf5)](_0x52d279,_0x40629d){const _0x3d2c6d=a0_0x162b24;let _0xbb1ec8={'Content-Type':_0x3d2c6d(0x10b),'Accept':'application/json,\x20text/event-stream'};if(this[_0x3d2c6d(0x122)])_0xbb1ec8['Authorization']=_0x3d2c6d(0xeb)+this['token'];let _0x519092=await(await fetch(this[_0x3d2c6d(0xfc)]+_0x3d2c6d(0x10a),{'method':_0x3d2c6d(0x11a),'headers':_0xbb1ec8,'body':JSON[_0x3d2c6d(0xc3)]({'jsonrpc':_0x3d2c6d(0xe6),'id':Date[_0x3d2c6d(0xcc)](),'method':_0x3d2c6d(0xbf),'params':{'name':_0x52d279,'arguments':_0x40629d}})}))[_0x3d2c6d(0x134)](),_0x1d67bf=_0x519092['match'](/data: (.+)/),_0x15909d=_0x1d67bf?JSON[_0x3d2c6d(0xec)](_0x1d67bf[0x1]):JSON[_0x3d2c6d(0xec)](_0x519092),_0x1ca3da=_0x15909d?.[_0x3d2c6d(0x107)]?.[_0x3d2c6d(0xd2)]?.[0x0]?.[_0x3d2c6d(0x134)];return _0x1ca3da?JSON[_0x3d2c6d(0xec)](_0x1ca3da):_0x15909d;}async[a0_0x162b24(0xd4)](){const _0x5a7323=a0_0x162b24;if(this[_0x5a7323(0x103)])return;this[_0x5a7323(0x103)]=!0x0,await this['status']('idle'),this[_0x5a7323(0xcf)](_0x5a7323(0xe1)),this['heartbeatTimer']=setInterval(()=>{const _0x26c2c3=_0x5a7323;this[_0x26c2c3(0x124)](_0x26c2c3(0x128))[_0x26c2c3(0x120)](_0x3f225e=>this[_0x26c2c3(0xcf)](_0x26c2c3(0xce)+_0x3f225e[_0x26c2c3(0xef)]));},this['heartbeatInterval']),this[_0x5a7323(0x106)]();}async[a0_0x162b24(0x118)](){const _0x1c4840=a0_0x162b24;if(this[_0x1c4840(0x103)]=!0x1,this['sseAbort']?.['abort'](),this['heartbeatTimer'])clearInterval(this[_0x1c4840(0x12d)]);await this['status'](_0x1c4840(0xc2))[_0x1c4840(0x120)](()=>{}),this[_0x1c4840(0xcf)]('disconnected');}async[a0_0x162b24(0xcd)](_0x39449a,_0x255fa7,_0x58ae8d=a0_0x162b24(0xde)){const _0x49e7fb=a0_0x162b24;return Y({'alias':_0x39449a,'fromAlias':this[_0x49e7fb(0xba)]},{'log':_0x3b8a1e=>console[_0x49e7fb(0xcf)](_0x3b8a1e),'send':()=>this[_0x49e7fb(0xf5)]('send_task',{'alias':_0x39449a,'task':_0x255fa7,'priority':_0x58ae8d,'from_session':this[_0x49e7fb(0xba)]})});}async['message'](_0x6bc9db,_0x9341c7){const _0x1cd904=a0_0x162b24;return this[_0x1cd904(0xf5)]('send_message',{'alias':_0x6bc9db,'message':_0x9341c7,'from_session':this['alias']});}async[a0_0x162b24(0xed)](_0x1effb7,_0x461000,_0x297735=a0_0x162b24(0xf0)){const _0x2e86df=a0_0x162b24;return this['call'](_0x2e86df(0x10e),{'in_reply_to':_0x1effb7,'text':_0x461000,'status':_0x297735});}async[a0_0x162b24(0x124)](_0x2ed2cb,_0x2082a1){const _0x5b9671=a0_0x162b24;return this['call']('report_status',{'resume_id':this[_0x5b9671(0xc7)],'alias':this['alias'],'status':_0x2ed2cb,'server':a0_0x520ff0(),'hostname':a0_0x520ff0(),'agent':this[_0x5b9671(0x108)],'project_dir':process[_0x5b9671(0xbd)](),..._0x2082a1});}async['getAllStatus'](){const _0xcd9bbe=a0_0x162b24;return this[_0xcd9bbe(0xf5)](_0xcd9bbe(0xe2),{});}async[a0_0x162b24(0xc0)](_0x536c3b,_0x16f1e9){const _0x1efcd9=a0_0x162b24;return this[_0x1efcd9(0xf5)]('broadcast',{'message':_0x536c3b,'filter_server':_0x16f1e9?.[_0x1efcd9(0xe4)],'filter_status':_0x16f1e9?.['status']});}async['connectSSE'](){const _0x59ce77=a0_0x162b24;let _0x3ba488=encodeURIComponent(this[_0x59ce77(0xba)]),_0x2b39ef=this['url']+_0x59ce77(0xf8)+_0x3ba488,_0xcca5d5=this['reconnectDelay'];while(this[_0x59ce77(0x103)]){try{this[_0x59ce77(0xd5)]=new AbortController();let _0x112931={'Accept':_0x59ce77(0x135)};if(this[_0x59ce77(0x122)])_0x112931[_0x59ce77(0xc1)]=_0x59ce77(0xeb)+this[_0x59ce77(0x122)];let _0x3f5fe8=await fetch(_0x2b39ef,{'headers':_0x112931,'signal':this[_0x59ce77(0xd5)]['signal']});if(!_0x3f5fe8['ok']||!_0x3f5fe8[_0x59ce77(0xbc)]){this[_0x59ce77(0xcf)](_0x59ce77(0x11e)+_0x3f5fe8[_0x59ce77(0x124)]),await this[_0x59ce77(0xc5)](_0xcca5d5),_0xcca5d5=Math[_0x59ce77(0x11b)](_0xcca5d5*1.5,0xea60);continue;}_0xcca5d5=this[_0x59ce77(0x123)];let _0x4d0441=_0x3f5fe8['body'][_0x59ce77(0x116)](),_0x5e1922=new TextDecoder(),_0x67b194='';while(this[_0x59ce77(0x103)]){let {done:_0x46529e,value:_0x5a02ff}=await _0x4d0441[_0x59ce77(0xee)]();if(_0x46529e)break;_0x67b194+=_0x5e1922['decode'](_0x5a02ff,{'stream':!0x0});let _0x35bd36=_0x67b194[_0x59ce77(0x12e)]('\x0a');_0x67b194=_0x35bd36['pop']()||'';for(let _0x55bba5 of _0x35bd36){if(!_0x55bba5[_0x59ce77(0xd8)](_0x59ce77(0x12b)))continue;try{let _0x544150=JSON['parse'](_0x55bba5[_0x59ce77(0xd6)](0x6));if(_0x544150[_0x59ce77(0x12c)]===_0x59ce77(0x126)){this[_0x59ce77(0xcf)]('SSE\x20connected'),this[_0x59ce77(0xe7)](_0x59ce77(0x126));continue;}if(_0x544150['type']==='new_task'||_0x544150[_0x59ce77(0x12c)]===_0x59ce77(0xfe)||_0x544150['type']===_0x59ce77(0xc0))await this[_0x59ce77(0x105)]();}catch{}}}}catch(_0x10831a){if(_0x10831a['name']===_0x59ce77(0xdf))break;this[_0x59ce77(0xe7)](_0x59ce77(0x127),_0x10831a),this[_0x59ce77(0xcf)](_0x59ce77(0x111)+_0x10831a[_0x59ce77(0xef)]);}if(this['running'])this[_0x59ce77(0xe7)](_0x59ce77(0xb9)),this[_0x59ce77(0xcf)](_0x59ce77(0x117)+_0xcca5d5/0x3e8+_0x59ce77(0xd9)),await this['sleep'](_0xcca5d5),_0xcca5d5=Math[_0x59ce77(0x11b)](_0xcca5d5*1.5,0xea60);}}async[a0_0x162b24(0x105)](){const _0x34b8c2=a0_0x162b24;try{let _0x1fd97a=(await this[_0x34b8c2(0xf5)](_0x34b8c2(0xf3),{'alias':this[_0x34b8c2(0xba)],'limit':0xa}))?.[_0x34b8c2(0xe9)]||[];for(let _0x258423 of _0x1fd97a)await this['call'](_0x34b8c2(0xf2),{'alias':this[_0x34b8c2(0xba)],'message_id':_0x258423['id']}),this['log']('←\x20'+_0x258423[_0x34b8c2(0x104)]+':\x20'+_0x258423[_0x34b8c2(0xd2)][_0x34b8c2(0xd6)](0x0,0x3c)),this['emit']('task',_0x258423),this['emit'](_0x34b8c2(0xef),_0x258423);}catch(_0x5570a0){this[_0x34b8c2(0xcf)]('inbox\x20error:\x20'+_0x5570a0[_0x34b8c2(0xef)]);}}['sleep'](_0x4c7a6f){return new Promise(_0xbecdc4=>setTimeout(_0xbecdc4,_0x4c7a6f));}}function a0_0x4374(_0x453330,_0xf89ad0){_0x453330=_0x453330-0xb8;const _0x3edb44=a0_0x3edb();let _0x43740c=_0x3edb44[_0x453330];return _0x43740c;}var F=$;function a0_0x3edb(){const _0xede001=['task.send.failed','2.0','emit','autoConnect','messages','networkId','Bearer\x20','parse','reply','read','message','completed','unknown\x20error','ack_inbox','get_inbox','send_failed','call','string','CommHub\x20response\x20omitted\x20task_id','/events/','json','send_rejected','missing_task_id','url','error_code','new_message','duration_ms','CommHub\x20rejected\x20task','5780FVZnEm','[REDACTED]','running','from_session','processInbox','connectSSE','result','agent','parentTaskId','/mcp','application/json','\x20parent_task_id=','\x20task_id=','send_reply','\x20network_id=','toAlias','SSE\x20error:\x20','mcp_http','4484382sTxLgC','task.ack','[commhub:task]\x20','getReader','SSE\x20reconnecting\x20in\x20','disconnect','task_id','POST','min','lifecycleTracking','message_id','SSE\x20failed:\x20','5088JdgEzi','catch','244tdSVeV','token','reconnectDelay','status','3660312SrPvJi','connected','error','idle','<unknown>','delivered','data:\x20','type','heartbeatTimer','split','failed','lifecycle_tracking','not_tracked','15813uIbKUD','fromAlias','text','text/event-stream','task.replied','disconnected','alias','\x20error=','body','cwd','45012DcooiM','tools/call','broadcast','Authorization','offline','stringify','heartbeatInterval','sleep','364RYchaV','resumeId','from_alias','<missing>','\x20from=','toTimeString','now','send','heartbeat\x20failed:\x20','log','\x20to=','transport','content','41415NSbqtj','connect','sseAbort','slice','to_alias','startsWith','s...','replace','\x20duration_ms=','task.send.start','3023397neqzQK','normal','AbortError','3016VUmapD','registered','get_all_status',']\x20[commhub:','server'];a0_0x3edb=function(){return _0xede001;};return a0_0x3edb();}export{F as default,$ as CommHub};
|
|
1
|
+
const a0_0x47df6d=a0_0x1c20;(function(_0x4cf617,_0x4a3b26){const _0x3cfabc=a0_0x1c20,_0x515fb2=_0x4cf617();while(!![]){try{const _0x33ca84=-parseInt(_0x3cfabc(0x13a))/0x1*(parseInt(_0x3cfabc(0x148))/0x2)+-parseInt(_0x3cfabc(0x132))/0x3*(-parseInt(_0x3cfabc(0xfc))/0x4)+parseInt(_0x3cfabc(0x13b))/0x5*(parseInt(_0x3cfabc(0x126))/0x6)+-parseInt(_0x3cfabc(0x12a))/0x7*(parseInt(_0x3cfabc(0x124))/0x8)+-parseInt(_0x3cfabc(0xfb))/0x9+-parseInt(_0x3cfabc(0x156))/0xa+parseInt(_0x3cfabc(0x122))/0xb;if(_0x33ca84===_0x4a3b26)break;else _0x515fb2['push'](_0x515fb2['shift']());}catch(_0x212f42){_0x515fb2['push'](_0x515fb2['shift']());}}}(a0_0x49a5,0x18b33));import{EventEmitter as a0_0x3dfc70}from'events';import{hostname as a0_0x55a7b2}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0xd897cd,_0x4d22f6)=>(_0xd897cd??_0x4d22f6)[a0_0x47df6d(0x136)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x47df6d(0x137)](0x0,0xf0);function N(_0x3af736){const _0x5b0c3d=a0_0x47df6d;return(_0x3af736 instanceof Error?_0x3af736[_0x5b0c3d(0x111)]:String(_0x3af736??_0x5b0c3d(0xef)))['replace'](K,'[REDACTED]')[_0x5b0c3d(0x136)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x5b0c3d(0x137)](0x0,0xf0);}function a0_0x49a5(){const _0x56bf80=['emit','task.ack','url','get_inbox','duration_ms','autoConnect','task_id','unknown\x20error','disconnected','body','send_task','completed','status','delivered','new_task','registered','catch','signal','sdk','1231047YplFhi','726676hXqbAP','agent','type','log','CommHub\x20rejected\x20task','lifecycle_tracking',']\x20[commhub:','connect','error_message','not_tracked','<pending>','send_message','error_code','Bearer\x20','sseAbort','Authorization','\x20parent_task_id=','match','2.0','connected','sleep','message','transport','decode','sdk-','POST','\x20task_id=','heartbeat\x20failed:\x20','reconnectDelay','AbortError','from_session','from_alias','/events/','SSE\x20reconnecting\x20in\x20','message_id','text','call','connectSSE','2021602vjKgvr','fromAlias','248168SEjRnV','\x20transport=','42scbHHK','send','stringify','[commhub:task]\x20','7VEDoPv','parentTaskId','now','s...','parent_task_id','messages','resumeId','task.send.delivered','3OYhZTp','broadcast','offline','send_rejected','replace','slice','SSE\x20connected','data:\x20','4xYJWcN','119800xKtHxA','result','heartbeatTimer','getReader','content','application/json','abort','running','<unknown>','read','application/json,\x20text/event-stream','inbox\x20error:\x20','\x20lifecycle=','64946pqmDSM','alias','task.replied','idle','error','heartbeatInterval','toString','text/event-stream','to_alias','send_failed','CommHub\x20response\x20omitted\x20task_id','normal','missing_task_id','networkId','1343040kjNNyw','json','failed','token','\x20to=','sending','parse','getAllStatus','\x20from=','processInbox','mcp_http','tools/call','report_status','\x20duration_ms=','\x20network_id=','SSE\x20error:\x20'];a0_0x49a5=function(){return _0x56bf80;};return a0_0x49a5();}function O(_0x3274cd,_0x9301d5=process.env.ANET_TASK_TRACE_FORMAT===a0_0x47df6d(0x157)){const _0xd91b69=a0_0x47df6d;if(_0x9301d5)return JSON['stringify'](_0x3274cd);let _0x3fbf1a=L(_0x3274cd[_0xd91b69(0x12e)],'<missing>'),_0x30ceb9=L(_0x3274cd[_0xd91b69(0xee)],_0xd91b69(0x106)),_0x38ec=_0x3274cd[_0xd91b69(0x108)]?'\x20error='+_0x3274cd[_0xd91b69(0x108)]+':'+(_0x3274cd[_0xd91b69(0x104)]??''):'';return _0xd91b69(0x129)+_0x3274cd[_0xd91b69(0xf4)]+_0xd91b69(0x15e)+L(_0x3274cd[_0xd91b69(0x11b)],_0xd91b69(0x143))+_0xd91b69(0x15a)+L(_0x3274cd[_0xd91b69(0x150)],_0xd91b69(0x143))+_0xd91b69(0x116)+_0x30ceb9+_0xd91b69(0x10c)+_0x3fbf1a+_0xd91b69(0x164)+L(_0x3274cd['network_id'],_0xd91b69(0x143))+_0xd91b69(0x125)+_0x3274cd[_0xd91b69(0x112)]+_0xd91b69(0x163)+_0x3274cd[_0xd91b69(0xec)]+_0xd91b69(0x147)+_0x3274cd[_0xd91b69(0x101)]+_0x38ec;}function U(_0x5d2df5){const _0x30a118=a0_0x47df6d;return{'event':{'sending':'task.send.start','delivered':_0x30a118(0x131),'failed':'task.send.failed','acked':_0x30a118(0x167),'started':'task.started','replied':_0x30a118(0x14a),'expired':'task.expired'}[_0x5d2df5['status']],..._0x5d2df5};}function j(_0x45c46e){const _0x2435b3=a0_0x47df6d;let _0x18cba3=_0x45c46e?.[_0x2435b3(0xee)]||_0x45c46e?.[_0x2435b3(0x11e)]||_0x45c46e?.['id'];if(_0x18cba3)return String(_0x18cba3);let _0x454b52=_0x45c46e?.['content']?.[0x0]?.[_0x2435b3(0x11f)];if(typeof _0x454b52!=='string')return null;try{let _0x3251e5=JSON[_0x2435b3(0x15c)](_0x454b52);return _0x3251e5?.[_0x2435b3(0xee)]||_0x3251e5?.[_0x2435b3(0x11e)]||_0x3251e5?.['id']||null;}catch{return null;}}async function X(_0x520955,_0x526595){const _0xf81a75=a0_0x47df6d;let _0x1541ba=_0x526595[_0xf81a75(0x12c)]??Date['now'],_0x19304b=_0x1541ba(),_0x1ad337=(_0x5e4088,_0x266ee5,_0x3b49fa,_0x155a7a)=>{const _0xe1d848=_0xf81a75;_0x526595['log'](O(U({'from_alias':_0x520955[_0xe1d848(0x123)],'to_alias':_0x520955['toAlias'],'task_id':_0x266ee5,'parent_task_id':_0x520955[_0xe1d848(0x12b)],'network_id':_0x520955[_0xe1d848(0x155)],'transport':_0x520955['transport'],'status':_0x5e4088,'duration_ms':_0x1541ba()-_0x19304b,'lifecycle_tracking':_0x520955['lifecycleTracking'],..._0x3b49fa!==void 0x0?{'error_code':_0x155a7a||_0xe1d848(0x151),'error_message':N(_0x3b49fa)}:{}})));};_0x1ad337(_0xf81a75(0x15b),null);try{let _0x514731=await _0x526595[_0xf81a75(0x127)](),_0x370209=j(_0x514731);if(_0x370209)_0x1ad337(_0xf81a75(0xf5),_0x370209);else{if(_0x514731?.['ok']===!0x1||_0x514731?.[_0xf81a75(0x14c)])_0x1ad337(_0xf81a75(0x158),_0x370209,_0x514731?.['error']||_0xf81a75(0x100),_0xf81a75(0x135));else _0x1ad337(_0xf81a75(0x158),null,_0xf81a75(0x152),_0xf81a75(0x154));}return _0x514731;}catch(_0x1d2cd6){throw _0x1ad337(_0xf81a75(0x158),null,_0x1d2cd6,'send_failed'),_0x1d2cd6;}}async function Y(_0x5209b2,_0x342982){const _0x3f6657=a0_0x47df6d;return X({'fromAlias':_0x5209b2[_0x3f6657(0x123)],'toAlias':_0x5209b2[_0x3f6657(0x149)],'parentTaskId':_0x5209b2[_0x3f6657(0x12b)]||null,'networkId':_0x5209b2[_0x3f6657(0x155)]||null,'transport':_0x3f6657(0x160),'lifecycleTracking':_0x3f6657(0x105)},_0x342982);}class $ extends a0_0x3dfc70{['url'];[a0_0x47df6d(0x149)];[a0_0x47df6d(0x159)];[a0_0x47df6d(0xfd)];[a0_0x47df6d(0x130)];['heartbeatInterval'];[a0_0x47df6d(0x118)];['heartbeatTimer'];[a0_0x47df6d(0x10a)];[a0_0x47df6d(0x142)]=!0x1;constructor(_0xbbdca9){const _0x2ec548=a0_0x47df6d;super();if(this['url']=_0xbbdca9[_0x2ec548(0x168)][_0x2ec548(0x136)](/\/$/,''),this['alias']=_0xbbdca9[_0x2ec548(0x149)],this[_0x2ec548(0x159)]=_0xbbdca9['token'],this['agent']=_0xbbdca9[_0x2ec548(0xfd)]||_0x2ec548(0xfa),this[_0x2ec548(0x130)]=_0x2ec548(0x114)+_0xbbdca9[_0x2ec548(0x149)]+'-'+Date[_0x2ec548(0x12c)]()[_0x2ec548(0x14e)](0x24),this[_0x2ec548(0x14d)]=_0xbbdca9['heartbeatInterval']??0x2bf20,this['reconnectDelay']=_0xbbdca9['reconnectDelay']??0xbb8,_0xbbdca9[_0x2ec548(0xed)]!==!0x1)this[_0x2ec548(0x103)]();}[a0_0x47df6d(0xff)](_0x187535){const _0x446b6d=a0_0x47df6d;console[_0x446b6d(0xff)]('['+new Date()['toTimeString']()['slice'](0x0,0x8)+_0x446b6d(0x102)+this['alias']+']\x20'+_0x187535);}async[a0_0x47df6d(0x120)](_0x42dafb,_0x40b9a4){const _0x259b65=a0_0x47df6d;let _0x56f2e0={'Content-Type':_0x259b65(0x140),'Accept':_0x259b65(0x145)};if(this[_0x259b65(0x159)])_0x56f2e0['Authorization']='Bearer\x20'+this[_0x259b65(0x159)];let _0x48927b=await(await fetch(this[_0x259b65(0x168)]+'/mcp',{'method':_0x259b65(0x115),'headers':_0x56f2e0,'body':JSON[_0x259b65(0x128)]({'jsonrpc':_0x259b65(0x10e),'id':Date[_0x259b65(0x12c)](),'method':_0x259b65(0x161),'params':{'name':_0x42dafb,'arguments':_0x40b9a4}})}))[_0x259b65(0x11f)](),_0x198c6a=_0x48927b[_0x259b65(0x10d)](/data: (.+)/),_0x327ab9=_0x198c6a?JSON['parse'](_0x198c6a[0x1]):JSON['parse'](_0x48927b),_0x58f15e=_0x327ab9?.[_0x259b65(0x13c)]?.[_0x259b65(0x13f)]?.[0x0]?.[_0x259b65(0x11f)];return _0x58f15e?JSON['parse'](_0x58f15e):_0x327ab9;}async[a0_0x47df6d(0x103)](){const _0x438296=a0_0x47df6d;if(this[_0x438296(0x142)])return;this[_0x438296(0x142)]=!0x0,await this[_0x438296(0xf4)](_0x438296(0x14b)),this['log'](_0x438296(0xf7)),this['heartbeatTimer']=setInterval(()=>{const _0x4e0a82=_0x438296;this['status'](_0x4e0a82(0x14b))[_0x4e0a82(0xf8)](_0xb37689=>this['log'](_0x4e0a82(0x117)+_0xb37689[_0x4e0a82(0x111)]));},this['heartbeatInterval']),this[_0x438296(0x121)]();}async['disconnect'](){const _0x124339=a0_0x47df6d;if(this['running']=!0x1,this[_0x124339(0x10a)]?.[_0x124339(0x141)](),this[_0x124339(0x13d)])clearInterval(this[_0x124339(0x13d)]);await this[_0x124339(0xf4)](_0x124339(0x134))['catch'](()=>{}),this[_0x124339(0xff)](_0x124339(0xf0));}async['send'](_0x3dcf1b,_0x557430,_0x3707a9=a0_0x47df6d(0x153)){const _0x3f9a20=a0_0x47df6d;return Y({'alias':_0x3dcf1b,'fromAlias':this['alias']},{'log':_0x5d9839=>console['log'](_0x5d9839),'send':()=>this[_0x3f9a20(0x120)](_0x3f9a20(0xf2),{'alias':_0x3dcf1b,'task':_0x557430,'priority':_0x3707a9,'from_session':this[_0x3f9a20(0x149)]})});}async['message'](_0x22f3a6,_0x3f73cf){const _0x53378e=a0_0x47df6d;return this[_0x53378e(0x120)](_0x53378e(0x107),{'alias':_0x22f3a6,'message':_0x3f73cf,'from_session':this[_0x53378e(0x149)]});}async['reply'](_0xb3427d,_0x5b7405,_0xef62d1=a0_0x47df6d(0xf3)){const _0x2da225=a0_0x47df6d;return this[_0x2da225(0x120)]('send_reply',{'in_reply_to':_0xb3427d,'text':_0x5b7405,'status':_0xef62d1});}async[a0_0x47df6d(0xf4)](_0x4a57c9,_0x21acb7){const _0x499b6b=a0_0x47df6d;return this[_0x499b6b(0x120)](_0x499b6b(0x162),{'resume_id':this[_0x499b6b(0x130)],'alias':this[_0x499b6b(0x149)],'status':_0x4a57c9,'server':a0_0x55a7b2(),'hostname':a0_0x55a7b2(),'agent':this['agent'],'project_dir':process['cwd'](),..._0x21acb7});}async[a0_0x47df6d(0x15d)](){return this['call']('get_all_status',{});}async[a0_0x47df6d(0x133)](_0x40ca3a,_0x39fa68){const _0x502df1=a0_0x47df6d;return this[_0x502df1(0x120)](_0x502df1(0x133),{'message':_0x40ca3a,'filter_server':_0x39fa68?.['server'],'filter_status':_0x39fa68?.['status']});}async[a0_0x47df6d(0x121)](){const _0x53f7f8=a0_0x47df6d;let _0x3ea421=encodeURIComponent(this[_0x53f7f8(0x149)]),_0x10c1f6=this['url']+_0x53f7f8(0x11c)+_0x3ea421,_0x437e8d=this[_0x53f7f8(0x118)];while(this[_0x53f7f8(0x142)]){try{this[_0x53f7f8(0x10a)]=new AbortController();let _0x47138b={'Accept':_0x53f7f8(0x14f)};if(this['token'])_0x47138b[_0x53f7f8(0x10b)]=_0x53f7f8(0x109)+this[_0x53f7f8(0x159)];let _0x424bd6=await fetch(_0x10c1f6,{'headers':_0x47138b,'signal':this[_0x53f7f8(0x10a)][_0x53f7f8(0xf9)]});if(!_0x424bd6['ok']||!_0x424bd6[_0x53f7f8(0xf1)]){this['log']('SSE\x20failed:\x20'+_0x424bd6[_0x53f7f8(0xf4)]),await this['sleep'](_0x437e8d),_0x437e8d=Math['min'](_0x437e8d*1.5,0xea60);continue;}_0x437e8d=this[_0x53f7f8(0x118)];let _0x2659c9=_0x424bd6[_0x53f7f8(0xf1)][_0x53f7f8(0x13e)](),_0x57f05b=new TextDecoder(),_0x39184d='';while(this['running']){let {done:_0x3ace8c,value:_0xc52fa1}=await _0x2659c9[_0x53f7f8(0x144)]();if(_0x3ace8c)break;_0x39184d+=_0x57f05b[_0x53f7f8(0x113)](_0xc52fa1,{'stream':!0x0});let _0x39a4fd=_0x39184d['split']('\x0a');_0x39184d=_0x39a4fd['pop']()||'';for(let _0x2b58ce of _0x39a4fd){if(!_0x2b58ce['startsWith'](_0x53f7f8(0x139)))continue;try{let _0xb98433=JSON[_0x53f7f8(0x15c)](_0x2b58ce[_0x53f7f8(0x137)](0x6));if(_0xb98433['type']===_0x53f7f8(0x10f)){this[_0x53f7f8(0xff)](_0x53f7f8(0x138)),this[_0x53f7f8(0x166)](_0x53f7f8(0x10f));continue;}if(_0xb98433[_0x53f7f8(0xfe)]===_0x53f7f8(0xf6)||_0xb98433['type']==='new_message'||_0xb98433[_0x53f7f8(0xfe)]===_0x53f7f8(0x133))await this[_0x53f7f8(0x15f)]();}catch{}}}}catch(_0x29b76b){if(_0x29b76b['name']===_0x53f7f8(0x119))break;this['emit'](_0x53f7f8(0x14c),_0x29b76b),this[_0x53f7f8(0xff)](_0x53f7f8(0x165)+_0x29b76b[_0x53f7f8(0x111)]);}if(this[_0x53f7f8(0x142)])this[_0x53f7f8(0x166)](_0x53f7f8(0xf0)),this['log'](_0x53f7f8(0x11d)+_0x437e8d/0x3e8+_0x53f7f8(0x12d)),await this['sleep'](_0x437e8d),_0x437e8d=Math['min'](_0x437e8d*1.5,0xea60);}}async['processInbox'](){const _0x1f2d0d=a0_0x47df6d;try{let _0xd6a027=(await this[_0x1f2d0d(0x120)](_0x1f2d0d(0xeb),{'alias':this[_0x1f2d0d(0x149)],'limit':0xa}))?.[_0x1f2d0d(0x12f)]||[];for(let _0x1eb078 of _0xd6a027)await this[_0x1f2d0d(0x120)]('ack_inbox',{'alias':this[_0x1f2d0d(0x149)],'message_id':_0x1eb078['id']}),this[_0x1f2d0d(0xff)]('←\x20'+_0x1eb078[_0x1f2d0d(0x11a)]+':\x20'+_0x1eb078[_0x1f2d0d(0x13f)][_0x1f2d0d(0x137)](0x0,0x3c)),this[_0x1f2d0d(0x166)]('task',_0x1eb078),this[_0x1f2d0d(0x166)](_0x1f2d0d(0x111),_0x1eb078);}catch(_0x4f9b3c){this[_0x1f2d0d(0xff)](_0x1f2d0d(0x146)+_0x4f9b3c[_0x1f2d0d(0x111)]);}}[a0_0x47df6d(0x110)](_0xc3e9e7){return new Promise(_0x4e9c16=>setTimeout(_0x4e9c16,_0xc3e9e7));}}var F=$;function a0_0x1c20(_0x2a794c,_0x1d483e){_0x2a794c=_0x2a794c-0xeb;const _0x49a5ce=a0_0x49a5();let _0x1c20eb=_0x49a5ce[_0x2a794c];return _0x1c20eb;}export{F as default,$ as CommHub};
|