@sleep2agi/agent-network 2.3.0-preview.140 → 2.3.0-preview.141

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_0x5e3fe2=a0_0x557c;(function(_0x51de4b,_0x46c859){const _0x390f58=a0_0x557c,_0x288a8e=_0x51de4b();while(!![]){try{const _0x268c63=parseInt(_0x390f58(0x237))/0x1*(parseInt(_0x390f58(0x228))/0x2)+parseInt(_0x390f58(0x20a))/0x3+-parseInt(_0x390f58(0x26d))/0x4+parseInt(_0x390f58(0x238))/0x5*(parseInt(_0x390f58(0x22c))/0x6)+-parseInt(_0x390f58(0x214))/0x7+-parseInt(_0x390f58(0x25c))/0x8+parseInt(_0x390f58(0x264))/0x9*(parseInt(_0x390f58(0x26c))/0xa);if(_0x268c63===_0x46c859)break;else _0x288a8e['push'](_0x288a8e['shift']());}catch(_0x2a28e7){_0x288a8e['push'](_0x288a8e['shift']());}}}(a0_0x5957,0x3f5d2));import{EventEmitter as a0_0x32c53b}from'events';import{hostname as a0_0x1952d2}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x360b43,_0x384296)=>(_0x360b43??_0x384296)[a0_0x5e3fe2(0x21c)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function a0_0x5957(){const _0x5ef710=['get_inbox','network_id','min','connect','agent','idle','stringify','broadcast','heartbeatInterval','getAllStatus','signal','call','transport','heartbeat\x20failed:\x20','send_failed','sseAbort','inbox\x20error:\x20','new_task','body','server','SSE\x20connected','AbortError','emit','3015096vzpDjF','to_alias','task.started','/events/','now','task.ack','unknown\x20error','\x20duration_ms=','108648XpxQMh','tools/call','heartbeatTimer','send_reply','parentTaskId','sleep','2.0','send_message','90JWHTJN','1999208GZTFIQ','\x20to=','Authorization','sdk-','[commhub:task]\x20','json','from_alias','\x20network_id=','\x20parent_task_id=','message','sdk','new_message','<unknown>','task_id','content','task','message_id','task.expired','connectSSE','completed','slice','fromAlias','send','toAlias','lifecycleTracking','SSE\x20failed:\x20','token','reply','<missing>','reconnectDelay','pop','1358013AZmJbU',']\x20[commhub:','delivered','text','SSE\x20error:\x20','autoConnect','string','toTimeString','catch','alias','1451912SNmoIJ','log','ack_inbox','cwd','offline','application/json,\x20text/event-stream','application/json','getReader','replace','task.send.delivered','parse','\x20task_id=','networkId','running','\x20from=','type','name','get_all_status','missing_task_id','startsWith','170noaENg','text/event-stream','processInbox','not_tracked','6GtkQhV','registered','url','result','disconnected','failed','Bearer\x20','task.send.failed','/mcp','CommHub\x20rejected\x20task','abort','4051vNxQtR','2189945FdafkV','error_code','task.send.start','decode','error','SSE\x20reconnecting\x20in\x20','lifecycle_tracking','send_rejected','error_message','data:\x20','status','duration_ms','resumeId'];a0_0x5957=function(){return _0x5ef710;};return a0_0x5957();}function a0_0x557c(_0x2178b4,_0x5610e5){_0x2178b4=_0x2178b4-0x1f2;const _0x595774=a0_0x5957();let _0x557c34=_0x595774[_0x2178b4];return _0x557c34;}function N(_0x23ff20){const _0x2214ca=a0_0x5e3fe2;return(_0x23ff20 instanceof Error?_0x23ff20['message']:String(_0x23ff20??_0x2214ca(0x262)))[_0x2214ca(0x21c)](K,'[REDACTED]')[_0x2214ca(0x21c)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x297436,_0x13339d=process.env.ANET_TASK_TRACE_FORMAT===a0_0x5e3fe2(0x272)){const _0x1a9c4c=a0_0x5e3fe2;if(_0x13339d)return JSON[_0x1a9c4c(0x24b)](_0x297436);let _0x28137b=L(_0x297436['parent_task_id'],_0x1a9c4c(0x207)),_0x4130d0=L(_0x297436['task_id'],'<pending>'),_0x5a3500=_0x297436[_0x1a9c4c(0x239)]?'\x20error='+_0x297436[_0x1a9c4c(0x239)]+':'+(_0x297436[_0x1a9c4c(0x240)]??''):'';return _0x1a9c4c(0x271)+_0x297436[_0x1a9c4c(0x242)]+_0x1a9c4c(0x222)+L(_0x297436[_0x1a9c4c(0x273)],_0x1a9c4c(0x1f7))+_0x1a9c4c(0x26e)+L(_0x297436[_0x1a9c4c(0x25d)],'<unknown>')+_0x1a9c4c(0x21f)+_0x4130d0+_0x1a9c4c(0x1f3)+_0x28137b+_0x1a9c4c(0x1f2)+L(_0x297436[_0x1a9c4c(0x246)],_0x1a9c4c(0x1f7))+'\x20transport='+_0x297436[_0x1a9c4c(0x251)]+_0x1a9c4c(0x263)+_0x297436[_0x1a9c4c(0x243)]+'\x20lifecycle='+_0x297436[_0x1a9c4c(0x23e)]+_0x5a3500;}function U(_0x292490){const _0x4d58bf=a0_0x5e3fe2;return{'event':{'sending':_0x4d58bf(0x23a),'delivered':_0x4d58bf(0x21d),'failed':_0x4d58bf(0x233),'acked':_0x4d58bf(0x261),'started':_0x4d58bf(0x25e),'replied':'task.replied','expired':_0x4d58bf(0x1fc)}[_0x292490[_0x4d58bf(0x242)]],..._0x292490};}function j(_0x18af7a){const _0x26d68c=a0_0x5e3fe2;let _0x1b4452=_0x18af7a?.[_0x26d68c(0x1f8)]||_0x18af7a?.[_0x26d68c(0x1fb)]||_0x18af7a?.['id'];if(_0x1b4452)return String(_0x1b4452);let _0x5232b3=_0x18af7a?.[_0x26d68c(0x1f9)]?.[0x0]?.[_0x26d68c(0x20d)];if(typeof _0x5232b3!==_0x26d68c(0x210))return null;try{let _0x394b2f=JSON[_0x26d68c(0x21e)](_0x5232b3);return _0x394b2f?.[_0x26d68c(0x1f8)]||_0x394b2f?.[_0x26d68c(0x1fb)]||_0x394b2f?.['id']||null;}catch{return null;}}async function X(_0x553836,_0x18bc98){const _0x29fc08=a0_0x5e3fe2;let _0x17a0c5=_0x18bc98[_0x29fc08(0x260)]??Date[_0x29fc08(0x260)],_0x301e1c=_0x17a0c5(),_0x3a8a49=(_0x36c617,_0x33e302,_0x5530a4,_0x456b6f)=>{const _0xefb9a2=_0x29fc08;_0x18bc98['log'](O(U({'from_alias':_0x553836[_0xefb9a2(0x200)],'to_alias':_0x553836[_0xefb9a2(0x202)],'task_id':_0x33e302,'parent_task_id':_0x553836[_0xefb9a2(0x268)],'network_id':_0x553836[_0xefb9a2(0x220)],'transport':_0x553836['transport'],'status':_0x36c617,'duration_ms':_0x17a0c5()-_0x301e1c,'lifecycle_tracking':_0x553836[_0xefb9a2(0x203)],..._0x5530a4!==void 0x0?{'error_code':_0x456b6f||'send_failed','error_message':N(_0x5530a4)}:{}})));};_0x3a8a49('sending',null);try{let _0x47ca79=await _0x18bc98['send'](),_0x1412e0=j(_0x47ca79);if(_0x1412e0)_0x3a8a49(_0x29fc08(0x20c),_0x1412e0);else{if(_0x47ca79?.['ok']===!0x1||_0x47ca79?.[_0x29fc08(0x23c)])_0x3a8a49(_0x29fc08(0x231),_0x1412e0,_0x47ca79?.[_0x29fc08(0x23c)]||_0x29fc08(0x235),_0x29fc08(0x23f));else _0x3a8a49(_0x29fc08(0x231),null,'CommHub\x20response\x20omitted\x20task_id',_0x29fc08(0x226));}return _0x47ca79;}catch(_0x592a5c){throw _0x3a8a49(_0x29fc08(0x231),null,_0x592a5c,_0x29fc08(0x253)),_0x592a5c;}}async function Y(_0x49c1e2,_0x339787){const _0x2ae12e=a0_0x5e3fe2;return X({'fromAlias':_0x49c1e2[_0x2ae12e(0x200)],'toAlias':_0x49c1e2[_0x2ae12e(0x213)],'parentTaskId':_0x49c1e2[_0x2ae12e(0x268)]||null,'networkId':_0x49c1e2['networkId']||null,'transport':'mcp_http','lifecycleTracking':_0x2ae12e(0x22b)},_0x339787);}class $ extends a0_0x32c53b{[a0_0x5e3fe2(0x22e)];[a0_0x5e3fe2(0x213)];[a0_0x5e3fe2(0x205)];['agent'];[a0_0x5e3fe2(0x244)];['heartbeatInterval'];[a0_0x5e3fe2(0x208)];[a0_0x5e3fe2(0x266)];[a0_0x5e3fe2(0x254)];['running']=!0x1;constructor(_0x547bfb){const _0x1f2d7c=a0_0x5e3fe2;super();if(this[_0x1f2d7c(0x22e)]=_0x547bfb[_0x1f2d7c(0x22e)][_0x1f2d7c(0x21c)](/\/$/,''),this['alias']=_0x547bfb[_0x1f2d7c(0x213)],this[_0x1f2d7c(0x205)]=_0x547bfb[_0x1f2d7c(0x205)],this[_0x1f2d7c(0x249)]=_0x547bfb[_0x1f2d7c(0x249)]||_0x1f2d7c(0x1f5),this['resumeId']=_0x1f2d7c(0x270)+_0x547bfb[_0x1f2d7c(0x213)]+'-'+Date[_0x1f2d7c(0x260)]()['toString'](0x24),this['heartbeatInterval']=_0x547bfb[_0x1f2d7c(0x24d)]??0x2bf20,this[_0x1f2d7c(0x208)]=_0x547bfb[_0x1f2d7c(0x208)]??0xbb8,_0x547bfb[_0x1f2d7c(0x20f)]!==!0x1)this['connect']();}[a0_0x5e3fe2(0x215)](_0x54002a){const _0x568f97=a0_0x5e3fe2;console[_0x568f97(0x215)]('['+new Date()[_0x568f97(0x211)]()[_0x568f97(0x1ff)](0x0,0x8)+_0x568f97(0x20b)+this[_0x568f97(0x213)]+']\x20'+_0x54002a);}async[a0_0x5e3fe2(0x250)](_0x40cc8b,_0x2a6546){const _0x39cfe6=a0_0x5e3fe2;let _0x5bc675={'Content-Type':_0x39cfe6(0x21a),'Accept':_0x39cfe6(0x219)};if(this[_0x39cfe6(0x205)])_0x5bc675['Authorization']=_0x39cfe6(0x232)+this[_0x39cfe6(0x205)];let _0x35b798=await(await fetch(this[_0x39cfe6(0x22e)]+_0x39cfe6(0x234),{'method':'POST','headers':_0x5bc675,'body':JSON[_0x39cfe6(0x24b)]({'jsonrpc':_0x39cfe6(0x26a),'id':Date[_0x39cfe6(0x260)](),'method':_0x39cfe6(0x265),'params':{'name':_0x40cc8b,'arguments':_0x2a6546}})}))[_0x39cfe6(0x20d)](),_0x4b3066=_0x35b798['match'](/data: (.+)/),_0x2d2ec5=_0x4b3066?JSON[_0x39cfe6(0x21e)](_0x4b3066[0x1]):JSON[_0x39cfe6(0x21e)](_0x35b798),_0x5c6582=_0x2d2ec5?.[_0x39cfe6(0x22f)]?.[_0x39cfe6(0x1f9)]?.[0x0]?.[_0x39cfe6(0x20d)];return _0x5c6582?JSON[_0x39cfe6(0x21e)](_0x5c6582):_0x2d2ec5;}async[a0_0x5e3fe2(0x248)](){const _0x58d3ec=a0_0x5e3fe2;if(this[_0x58d3ec(0x221)])return;this[_0x58d3ec(0x221)]=!0x0,await this[_0x58d3ec(0x242)](_0x58d3ec(0x24a)),this[_0x58d3ec(0x215)](_0x58d3ec(0x22d)),this[_0x58d3ec(0x266)]=setInterval(()=>{const _0xf6003e=_0x58d3ec;this[_0xf6003e(0x242)](_0xf6003e(0x24a))[_0xf6003e(0x212)](_0x1cc698=>this[_0xf6003e(0x215)](_0xf6003e(0x252)+_0x1cc698[_0xf6003e(0x1f4)]));},this['heartbeatInterval']),this[_0x58d3ec(0x1fd)]();}async['disconnect'](){const _0x5994b5=a0_0x5e3fe2;if(this[_0x5994b5(0x221)]=!0x1,this['sseAbort']?.[_0x5994b5(0x236)](),this[_0x5994b5(0x266)])clearInterval(this[_0x5994b5(0x266)]);await this[_0x5994b5(0x242)](_0x5994b5(0x218))[_0x5994b5(0x212)](()=>{}),this[_0x5994b5(0x215)](_0x5994b5(0x230));}async[a0_0x5e3fe2(0x201)](_0x420efe,_0x5cf5e5,_0x1b6fe6='normal'){const _0x1af921=a0_0x5e3fe2;return Y({'alias':_0x420efe,'fromAlias':this[_0x1af921(0x213)]},{'log':_0x252e40=>console['log'](_0x252e40),'send':()=>this['call']('send_task',{'alias':_0x420efe,'task':_0x5cf5e5,'priority':_0x1b6fe6,'from_session':this[_0x1af921(0x213)]})});}async['message'](_0x3aed4f,_0x1e4f3a){const _0x17b728=a0_0x5e3fe2;return this['call'](_0x17b728(0x26b),{'alias':_0x3aed4f,'message':_0x1e4f3a,'from_session':this['alias']});}async[a0_0x5e3fe2(0x206)](_0x22161d,_0x2e37da,_0x33240a=a0_0x5e3fe2(0x1fe)){const _0x4f1336=a0_0x5e3fe2;return this['call'](_0x4f1336(0x267),{'in_reply_to':_0x22161d,'text':_0x2e37da,'status':_0x33240a});}async[a0_0x5e3fe2(0x242)](_0xf97210,_0x5ccdfc){const _0x2fcf6f=a0_0x5e3fe2;return this[_0x2fcf6f(0x250)]('report_status',{'resume_id':this[_0x2fcf6f(0x244)],'alias':this[_0x2fcf6f(0x213)],'status':_0xf97210,'server':a0_0x1952d2(),'hostname':a0_0x1952d2(),'agent':this['agent'],'project_dir':process[_0x2fcf6f(0x217)](),..._0x5ccdfc});}async[a0_0x5e3fe2(0x24e)](){const _0x39c504=a0_0x5e3fe2;return this['call'](_0x39c504(0x225),{});}async['broadcast'](_0x4c0167,_0x289935){const _0x1e0946=a0_0x5e3fe2;return this[_0x1e0946(0x250)](_0x1e0946(0x24c),{'message':_0x4c0167,'filter_server':_0x289935?.[_0x1e0946(0x258)],'filter_status':_0x289935?.['status']});}async[a0_0x5e3fe2(0x1fd)](){const _0x432482=a0_0x5e3fe2;let _0x211aac=encodeURIComponent(this[_0x432482(0x213)]),_0x40ce49=this['url']+_0x432482(0x25f)+_0x211aac,_0x1557fa=this['reconnectDelay'];while(this[_0x432482(0x221)]){try{this[_0x432482(0x254)]=new AbortController();let _0x436a75={'Accept':_0x432482(0x229)};if(this[_0x432482(0x205)])_0x436a75[_0x432482(0x26f)]=_0x432482(0x232)+this[_0x432482(0x205)];let _0x3320bf=await fetch(_0x40ce49,{'headers':_0x436a75,'signal':this[_0x432482(0x254)][_0x432482(0x24f)]});if(!_0x3320bf['ok']||!_0x3320bf['body']){this[_0x432482(0x215)](_0x432482(0x204)+_0x3320bf['status']),await this[_0x432482(0x269)](_0x1557fa),_0x1557fa=Math['min'](_0x1557fa*1.5,0xea60);continue;}_0x1557fa=this['reconnectDelay'];let _0x474f39=_0x3320bf[_0x432482(0x257)][_0x432482(0x21b)](),_0x387e8b=new TextDecoder(),_0x485b6e='';while(this[_0x432482(0x221)]){let {done:_0x42953f,value:_0x519dda}=await _0x474f39['read']();if(_0x42953f)break;_0x485b6e+=_0x387e8b[_0x432482(0x23b)](_0x519dda,{'stream':!0x0});let _0x5af355=_0x485b6e['split']('\x0a');_0x485b6e=_0x5af355[_0x432482(0x209)]()||'';for(let _0x49b6d6 of _0x5af355){if(!_0x49b6d6[_0x432482(0x227)](_0x432482(0x241)))continue;try{let _0x55052b=JSON['parse'](_0x49b6d6[_0x432482(0x1ff)](0x6));if(_0x55052b['type']==='connected'){this['log'](_0x432482(0x259)),this[_0x432482(0x25b)]('connected');continue;}if(_0x55052b[_0x432482(0x223)]===_0x432482(0x256)||_0x55052b['type']===_0x432482(0x1f6)||_0x55052b['type']===_0x432482(0x24c))await this[_0x432482(0x22a)]();}catch{}}}}catch(_0x4e0004){if(_0x4e0004[_0x432482(0x224)]===_0x432482(0x25a))break;this['emit'](_0x432482(0x23c),_0x4e0004),this[_0x432482(0x215)](_0x432482(0x20e)+_0x4e0004[_0x432482(0x1f4)]);}if(this[_0x432482(0x221)])this[_0x432482(0x25b)](_0x432482(0x230)),this[_0x432482(0x215)](_0x432482(0x23d)+_0x1557fa/0x3e8+'s...'),await this[_0x432482(0x269)](_0x1557fa),_0x1557fa=Math[_0x432482(0x247)](_0x1557fa*1.5,0xea60);}}async[a0_0x5e3fe2(0x22a)](){const _0x49dd2d=a0_0x5e3fe2;try{let _0x56a99b=(await this[_0x49dd2d(0x250)](_0x49dd2d(0x245),{'alias':this['alias'],'limit':0xa}))?.['messages']||[];for(let _0x3b1b36 of _0x56a99b)await this[_0x49dd2d(0x250)](_0x49dd2d(0x216),{'alias':this['alias'],'message_id':_0x3b1b36['id']}),this[_0x49dd2d(0x215)]('←\x20'+_0x3b1b36['from_session']+':\x20'+_0x3b1b36[_0x49dd2d(0x1f9)][_0x49dd2d(0x1ff)](0x0,0x3c)),this[_0x49dd2d(0x25b)](_0x49dd2d(0x1fa),_0x3b1b36),this[_0x49dd2d(0x25b)](_0x49dd2d(0x1f4),_0x3b1b36);}catch(_0x1c4c94){this[_0x49dd2d(0x215)](_0x49dd2d(0x255)+_0x1c4c94['message']);}}['sleep'](_0x406e53){return new Promise(_0x4ab446=>setTimeout(_0x4ab446,_0x406e53));}}var F=$;export{F as default,$ as CommHub};
1
+ const a0_0x26dbc9=a0_0xe7e2;(function(_0x1ae6c2,_0x907afb){const _0x1a0ecd=a0_0xe7e2,_0x15ad19=_0x1ae6c2();while(!![]){try{const _0x10bb00=parseInt(_0x1a0ecd(0x1ad))/0x1+-parseInt(_0x1a0ecd(0x1b1))/0x2+parseInt(_0x1a0ecd(0x157))/0x3*(-parseInt(_0x1a0ecd(0x15d))/0x4)+-parseInt(_0x1a0ecd(0x162))/0x5*(-parseInt(_0x1a0ecd(0x1a7))/0x6)+-parseInt(_0x1a0ecd(0x183))/0x7+-parseInt(_0x1a0ecd(0x169))/0x8*(-parseInt(_0x1a0ecd(0x173))/0x9)+parseInt(_0x1a0ecd(0x1a2))/0xa;if(_0x10bb00===_0x907afb)break;else _0x15ad19['push'](_0x15ad19['shift']());}catch(_0xa8c021){_0x15ad19['push'](_0x15ad19['shift']());}}}(a0_0x22de,0x50c44));import{EventEmitter as a0_0x2109ca}from'events';import{hostname as a0_0x483dac}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x4376e3,_0x4a0b40)=>(_0x4376e3??_0x4a0b40)[a0_0x26dbc9(0x19a)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x26dbc9(0x179)](0x0,0xf0);function N(_0x1b3b19){const _0x591008=a0_0x26dbc9;return(_0x1b3b19 instanceof Error?_0x1b3b19[_0x591008(0x146)]:String(_0x1b3b19??_0x591008(0x18d)))[_0x591008(0x19a)](K,_0x591008(0x15b))[_0x591008(0x19a)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x591008(0x179)](0x0,0xf0);}function O(_0x7a2e00,_0x55300a=process.env.ANET_TASK_TRACE_FORMAT===a0_0x26dbc9(0x15e)){const _0x10a5e3=a0_0x26dbc9;if(_0x55300a)return JSON[_0x10a5e3(0x181)](_0x7a2e00);let _0x2ad68c=L(_0x7a2e00[_0x10a5e3(0x15f)],'<missing>'),_0x55f87b=L(_0x7a2e00['task_id'],_0x10a5e3(0x184)),_0x40a04f=_0x7a2e00[_0x10a5e3(0x1aa)]?_0x10a5e3(0x199)+_0x7a2e00[_0x10a5e3(0x1aa)]+':'+(_0x7a2e00[_0x10a5e3(0x1af)]??''):'';return'[commhub:task]\x20'+_0x7a2e00[_0x10a5e3(0x151)]+_0x10a5e3(0x175)+L(_0x7a2e00[_0x10a5e3(0x188)],_0x10a5e3(0x14c))+_0x10a5e3(0x143)+L(_0x7a2e00[_0x10a5e3(0x14e)],_0x10a5e3(0x14c))+_0x10a5e3(0x18a)+_0x55f87b+_0x10a5e3(0x168)+_0x2ad68c+'\x20network_id='+L(_0x7a2e00[_0x10a5e3(0x142)],_0x10a5e3(0x14c))+_0x10a5e3(0x17b)+_0x7a2e00['transport']+_0x10a5e3(0x148)+_0x7a2e00['duration_ms']+_0x10a5e3(0x177)+_0x7a2e00[_0x10a5e3(0x171)]+_0x40a04f;}function U(_0x56a9b1){const _0x205956=a0_0x26dbc9;return{'event':{'sending':'task.send.start','delivered':'task.send.delivered','failed':_0x205956(0x161),'acked':_0x205956(0x1a0),'started':_0x205956(0x16a),'replied':_0x205956(0x17d),'expired':'task.expired'}[_0x56a9b1[_0x205956(0x151)]],..._0x56a9b1};}function a0_0xe7e2(_0x321c85,_0xc02cc){_0x321c85=_0x321c85-0x13c;const _0x22debb=a0_0x22de();let _0xe7e268=_0x22debb[_0x321c85];return _0xe7e268;}function a0_0x22de(){const _0x9306b5=['report_status','messages','network_id','\x20to=','Bearer\x20','sleep','message','resumeId','\x20duration_ms=','transport','content','idle','<unknown>','POST','to_alias','delivered','match','status','send',']\x20[commhub:','application/json,\x20text/event-stream','from_session','send_reply','543kehgnL','send_message','url','getReader','[REDACTED]','read','11240doTLfl','json','parent_task_id','disconnect','task.send.failed','30zswahA','reconnectDelay','server','send_task','connectSSE','error','\x20parent_task_id=','5160VYJiwg','task.started','min','pop','getAllStatus','type','cwd','networkId','lifecycle_tracking','new_message','6705mpjeTf','SSE\x20failed:\x20','\x20from=','split','\x20lifecycle=','broadcast','slice','sending','\x20transport=','heartbeatInterval','task.replied','processInbox','sseAbort','now','stringify','catch','3280144UMlZoU','<pending>','heartbeatTimer','body','token','from_alias','log','\x20task_id=','autoConnect','failed','unknown\x20error','message_id','text/event-stream','agent','fromAlias','CommHub\x20rejected\x20task','task','registered','inbox\x20error:\x20','tools/call','CommHub\x20response\x20omitted\x20task_id','s...','\x20error=','replace','text','/mcp','parse','alias','running','task.ack','/events/','4527910ulBbfi','parentTaskId','heartbeat\x20failed:\x20','not_tracked','disconnected','120546jGSYWg','toTimeString','task_id','error_code','SSE\x20connected','completed','392365medzdL','name','error_message','SSE\x20reconnecting\x20in\x20','276410LAEabL','send_failed','emit','Authorization','AbortError','call','connect','SSE\x20error:\x20','toString'];a0_0x22de=function(){return _0x9306b5;};return a0_0x22de();}function j(_0x194d61){const _0x43c526=a0_0x26dbc9;let _0x5aec79=_0x194d61?.[_0x43c526(0x1a9)]||_0x194d61?.[_0x43c526(0x18e)]||_0x194d61?.['id'];if(_0x5aec79)return String(_0x5aec79);let _0x857678=_0x194d61?.[_0x43c526(0x14a)]?.[0x0]?.[_0x43c526(0x19b)];if(typeof _0x857678!=='string')return null;try{let _0x2ff496=JSON[_0x43c526(0x19d)](_0x857678);return _0x2ff496?.[_0x43c526(0x1a9)]||_0x2ff496?.[_0x43c526(0x18e)]||_0x2ff496?.['id']||null;}catch{return null;}}async function X(_0x13d82d,_0x19178a){const _0x336a76=a0_0x26dbc9;let _0x4841bd=_0x19178a[_0x336a76(0x180)]??Date['now'],_0x2b9e12=_0x4841bd(),_0x163d09=(_0x48017c,_0x5090e0,_0x4da7bf,_0x4924c4)=>{const _0x594685=_0x336a76;_0x19178a[_0x594685(0x189)](O(U({'from_alias':_0x13d82d[_0x594685(0x191)],'to_alias':_0x13d82d['toAlias'],'task_id':_0x5090e0,'parent_task_id':_0x13d82d[_0x594685(0x1a3)],'network_id':_0x13d82d[_0x594685(0x170)],'transport':_0x13d82d[_0x594685(0x149)],'status':_0x48017c,'duration_ms':_0x4841bd()-_0x2b9e12,'lifecycle_tracking':_0x13d82d['lifecycleTracking'],..._0x4da7bf!==void 0x0?{'error_code':_0x4924c4||'send_failed','error_message':N(_0x4da7bf)}:{}})));};_0x163d09(_0x336a76(0x17a),null);try{let _0x436ba6=await _0x19178a[_0x336a76(0x152)](),_0x287f4f=j(_0x436ba6);if(_0x287f4f)_0x163d09(_0x336a76(0x14f),_0x287f4f);else{if(_0x436ba6?.['ok']===!0x1||_0x436ba6?.[_0x336a76(0x167)])_0x163d09(_0x336a76(0x18c),_0x287f4f,_0x436ba6?.['error']||_0x336a76(0x192),'send_rejected');else _0x163d09(_0x336a76(0x18c),null,_0x336a76(0x197),'missing_task_id');}return _0x436ba6;}catch(_0x4f5fdc){throw _0x163d09('failed',null,_0x4f5fdc,_0x336a76(0x1b2)),_0x4f5fdc;}}async function Y(_0x3bef1d,_0x5e23d3){const _0x55c0ce=a0_0x26dbc9;return X({'fromAlias':_0x3bef1d[_0x55c0ce(0x191)],'toAlias':_0x3bef1d[_0x55c0ce(0x19e)],'parentTaskId':_0x3bef1d[_0x55c0ce(0x1a3)]||null,'networkId':_0x3bef1d[_0x55c0ce(0x170)]||null,'transport':'mcp_http','lifecycleTracking':_0x55c0ce(0x1a5)},_0x5e23d3);}class $ extends a0_0x2109ca{[a0_0x26dbc9(0x159)];[a0_0x26dbc9(0x19e)];[a0_0x26dbc9(0x187)];['agent'];[a0_0x26dbc9(0x147)];[a0_0x26dbc9(0x17c)];[a0_0x26dbc9(0x163)];[a0_0x26dbc9(0x185)];[a0_0x26dbc9(0x17f)];[a0_0x26dbc9(0x19f)]=!0x1;constructor(_0x18987f){const _0x4e7fbc=a0_0x26dbc9;super();if(this[_0x4e7fbc(0x159)]=_0x18987f[_0x4e7fbc(0x159)][_0x4e7fbc(0x19a)](/\/$/,''),this[_0x4e7fbc(0x19e)]=_0x18987f[_0x4e7fbc(0x19e)],this['token']=_0x18987f[_0x4e7fbc(0x187)],this[_0x4e7fbc(0x190)]=_0x18987f[_0x4e7fbc(0x190)]||'sdk',this[_0x4e7fbc(0x147)]='sdk-'+_0x18987f['alias']+'-'+Date[_0x4e7fbc(0x180)]()[_0x4e7fbc(0x13f)](0x24),this[_0x4e7fbc(0x17c)]=_0x18987f[_0x4e7fbc(0x17c)]??0x2bf20,this[_0x4e7fbc(0x163)]=_0x18987f[_0x4e7fbc(0x163)]??0xbb8,_0x18987f[_0x4e7fbc(0x18b)]!==!0x1)this[_0x4e7fbc(0x13d)]();}[a0_0x26dbc9(0x189)](_0x13f39f){const _0x3352e0=a0_0x26dbc9;console[_0x3352e0(0x189)]('['+new Date()[_0x3352e0(0x1a8)]()[_0x3352e0(0x179)](0x0,0x8)+_0x3352e0(0x153)+this[_0x3352e0(0x19e)]+']\x20'+_0x13f39f);}async['call'](_0xb5f92d,_0x549a28){const _0x191931=a0_0x26dbc9;let _0x3dae98={'Content-Type':'application/json','Accept':_0x191931(0x154)};if(this[_0x191931(0x187)])_0x3dae98[_0x191931(0x1b4)]=_0x191931(0x144)+this[_0x191931(0x187)];let _0x211c4b=await(await fetch(this[_0x191931(0x159)]+_0x191931(0x19c),{'method':_0x191931(0x14d),'headers':_0x3dae98,'body':JSON[_0x191931(0x181)]({'jsonrpc':'2.0','id':Date[_0x191931(0x180)](),'method':_0x191931(0x196),'params':{'name':_0xb5f92d,'arguments':_0x549a28}})}))[_0x191931(0x19b)](),_0x3352f8=_0x211c4b[_0x191931(0x150)](/data: (.+)/),_0x25a00d=_0x3352f8?JSON[_0x191931(0x19d)](_0x3352f8[0x1]):JSON[_0x191931(0x19d)](_0x211c4b),_0x4e2c81=_0x25a00d?.['result']?.[_0x191931(0x14a)]?.[0x0]?.[_0x191931(0x19b)];return _0x4e2c81?JSON[_0x191931(0x19d)](_0x4e2c81):_0x25a00d;}async[a0_0x26dbc9(0x13d)](){const _0x14773e=a0_0x26dbc9;if(this[_0x14773e(0x19f)])return;this[_0x14773e(0x19f)]=!0x0,await this[_0x14773e(0x151)](_0x14773e(0x14b)),this[_0x14773e(0x189)](_0x14773e(0x194)),this['heartbeatTimer']=setInterval(()=>{const _0x421c0c=_0x14773e;this[_0x421c0c(0x151)](_0x421c0c(0x14b))[_0x421c0c(0x182)](_0x239177=>this['log'](_0x421c0c(0x1a4)+_0x239177[_0x421c0c(0x146)]));},this['heartbeatInterval']),this[_0x14773e(0x166)]();}async[a0_0x26dbc9(0x160)](){const _0x53f16e=a0_0x26dbc9;if(this[_0x53f16e(0x19f)]=!0x1,this['sseAbort']?.['abort'](),this[_0x53f16e(0x185)])clearInterval(this[_0x53f16e(0x185)]);await this['status']('offline')['catch'](()=>{}),this[_0x53f16e(0x189)](_0x53f16e(0x1a6));}async[a0_0x26dbc9(0x152)](_0x4e6047,_0x418e1f,_0x39993b='normal'){const _0x35e1df=a0_0x26dbc9;return Y({'alias':_0x4e6047,'fromAlias':this[_0x35e1df(0x19e)]},{'log':_0x3227e4=>console[_0x35e1df(0x189)](_0x3227e4),'send':()=>this[_0x35e1df(0x13c)](_0x35e1df(0x165),{'alias':_0x4e6047,'task':_0x418e1f,'priority':_0x39993b,'from_session':this[_0x35e1df(0x19e)]})});}async[a0_0x26dbc9(0x146)](_0x1992ec,_0x30ad63){const _0x4e2bda=a0_0x26dbc9;return this['call'](_0x4e2bda(0x158),{'alias':_0x1992ec,'message':_0x30ad63,'from_session':this[_0x4e2bda(0x19e)]});}async['reply'](_0x2337dc,_0x4a0cae,_0x1832f7=a0_0x26dbc9(0x1ac)){const _0x204b67=a0_0x26dbc9;return this[_0x204b67(0x13c)](_0x204b67(0x156),{'in_reply_to':_0x2337dc,'text':_0x4a0cae,'status':_0x1832f7});}async[a0_0x26dbc9(0x151)](_0x12757f,_0x1047c6){const _0x13d2be=a0_0x26dbc9;return this[_0x13d2be(0x13c)](_0x13d2be(0x140),{'resume_id':this[_0x13d2be(0x147)],'alias':this['alias'],'status':_0x12757f,'server':a0_0x483dac(),'hostname':a0_0x483dac(),'agent':this[_0x13d2be(0x190)],'project_dir':process[_0x13d2be(0x16f)](),..._0x1047c6});}async[a0_0x26dbc9(0x16d)](){const _0x3ce723=a0_0x26dbc9;return this[_0x3ce723(0x13c)]('get_all_status',{});}async[a0_0x26dbc9(0x178)](_0x48db6d,_0x52d47e){const _0x36fc4f=a0_0x26dbc9;return this[_0x36fc4f(0x13c)](_0x36fc4f(0x178),{'message':_0x48db6d,'filter_server':_0x52d47e?.[_0x36fc4f(0x164)],'filter_status':_0x52d47e?.[_0x36fc4f(0x151)]});}async[a0_0x26dbc9(0x166)](){const _0x18bba9=a0_0x26dbc9;let _0x6f9759=encodeURIComponent(this[_0x18bba9(0x19e)]),_0x5988a2=this['url']+_0x18bba9(0x1a1)+_0x6f9759,_0x486212=this['reconnectDelay'];while(this['running']){try{this[_0x18bba9(0x17f)]=new AbortController();let _0x14df06={'Accept':_0x18bba9(0x18f)};if(this[_0x18bba9(0x187)])_0x14df06['Authorization']=_0x18bba9(0x144)+this[_0x18bba9(0x187)];let _0x41a1c5=await fetch(_0x5988a2,{'headers':_0x14df06,'signal':this[_0x18bba9(0x17f)]['signal']});if(!_0x41a1c5['ok']||!_0x41a1c5[_0x18bba9(0x186)]){this[_0x18bba9(0x189)](_0x18bba9(0x174)+_0x41a1c5[_0x18bba9(0x151)]),await this[_0x18bba9(0x145)](_0x486212),_0x486212=Math[_0x18bba9(0x16b)](_0x486212*1.5,0xea60);continue;}_0x486212=this[_0x18bba9(0x163)];let _0x19738e=_0x41a1c5[_0x18bba9(0x186)][_0x18bba9(0x15a)](),_0x34d658=new TextDecoder(),_0x5b3a14='';while(this[_0x18bba9(0x19f)]){let {done:_0x4f0596,value:_0x188126}=await _0x19738e[_0x18bba9(0x15c)]();if(_0x4f0596)break;_0x5b3a14+=_0x34d658['decode'](_0x188126,{'stream':!0x0});let _0x4d8da4=_0x5b3a14[_0x18bba9(0x176)]('\x0a');_0x5b3a14=_0x4d8da4[_0x18bba9(0x16c)]()||'';for(let _0x3f70f3 of _0x4d8da4){if(!_0x3f70f3['startsWith']('data:\x20'))continue;try{let _0x42c4c1=JSON['parse'](_0x3f70f3[_0x18bba9(0x179)](0x6));if(_0x42c4c1['type']==='connected'){this[_0x18bba9(0x189)](_0x18bba9(0x1ab)),this[_0x18bba9(0x1b3)]('connected');continue;}if(_0x42c4c1['type']==='new_task'||_0x42c4c1[_0x18bba9(0x16e)]===_0x18bba9(0x172)||_0x42c4c1[_0x18bba9(0x16e)]===_0x18bba9(0x178))await this[_0x18bba9(0x17e)]();}catch{}}}}catch(_0x468e5c){if(_0x468e5c[_0x18bba9(0x1ae)]===_0x18bba9(0x1b5))break;this[_0x18bba9(0x1b3)](_0x18bba9(0x167),_0x468e5c),this['log'](_0x18bba9(0x13e)+_0x468e5c[_0x18bba9(0x146)]);}if(this[_0x18bba9(0x19f)])this['emit'](_0x18bba9(0x1a6)),this[_0x18bba9(0x189)](_0x18bba9(0x1b0)+_0x486212/0x3e8+_0x18bba9(0x198)),await this[_0x18bba9(0x145)](_0x486212),_0x486212=Math[_0x18bba9(0x16b)](_0x486212*1.5,0xea60);}}async[a0_0x26dbc9(0x17e)](){const _0x4614d1=a0_0x26dbc9;try{let _0x4e903d=(await this['call']('get_inbox',{'alias':this[_0x4614d1(0x19e)],'limit':0xa}))?.[_0x4614d1(0x141)]||[];for(let _0x169d95 of _0x4e903d)await this['call']('ack_inbox',{'alias':this[_0x4614d1(0x19e)],'message_id':_0x169d95['id']}),this[_0x4614d1(0x189)]('←\x20'+_0x169d95[_0x4614d1(0x155)]+':\x20'+_0x169d95[_0x4614d1(0x14a)][_0x4614d1(0x179)](0x0,0x3c)),this[_0x4614d1(0x1b3)](_0x4614d1(0x193),_0x169d95),this[_0x4614d1(0x1b3)](_0x4614d1(0x146),_0x169d95);}catch(_0x3d7813){this['log'](_0x4614d1(0x195)+_0x3d7813[_0x4614d1(0x146)]);}}[a0_0x26dbc9(0x145)](_0x58099b){return new Promise(_0x2530bf=>setTimeout(_0x2530bf,_0x58099b));}}var F=$;export{F as default,$ as CommHub};