@sleep2agi/agent-network 2.3.0-preview.247 → 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_0x35e9df=a0_0x1020;(function(_0x50f92e,_0x200685){const _0x13ba64=a0_0x1020,_0x35bb77=_0x50f92e();while(!![]){try{const _0x4b1685=-parseInt(_0x13ba64(0x203))/0x1+-parseInt(_0x13ba64(0x216))/0x2+parseInt(_0x13ba64(0x1d9))/0x3+-parseInt(_0x13ba64(0x1da))/0x4+parseInt(_0x13ba64(0x240))/0x5+parseInt(_0x13ba64(0x228))/0x6*(-parseInt(_0x13ba64(0x20b))/0x7)+parseInt(_0x13ba64(0x21a))/0x8;if(_0x4b1685===_0x200685)break;else _0x35bb77['push'](_0x35bb77['shift']());}catch(_0x187d9f){_0x35bb77['push'](_0x35bb77['shift']());}}}(a0_0x52ef,0x830b2));import{EventEmitter as a0_0x2c774d}from'events';import{hostname as a0_0x1af5e5}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x4253aa,_0x2e36ab)=>(_0x4253aa??_0x2e36ab)[a0_0x35e9df(0x233)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x35e9df(0x223)](0x0,0xf0);function N(_0x53cacf){const _0x1badc5=a0_0x35e9df;return(_0x53cacf instanceof Error?_0x53cacf[_0x1badc5(0x21f)]:String(_0x53cacf??_0x1badc5(0x201)))['replace'](K,'[REDACTED]')[_0x1badc5(0x233)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x2997f3,_0x5c29cc=process.env.ANET_TASK_TRACE_FORMAT===a0_0x35e9df(0x22b)){const _0x663245=a0_0x35e9df;if(_0x5c29cc)return JSON['stringify'](_0x2997f3);let _0x2402e6=L(_0x2997f3[_0x663245(0x1f2)],'<missing>'),_0x21717e=L(_0x2997f3[_0x663245(0x1d3)],'<pending>'),_0x5d0892=_0x2997f3[_0x663245(0x1ee)]?_0x663245(0x1d8)+_0x2997f3['error_code']+':'+(_0x2997f3['error_message']??''):'';return _0x663245(0x1e6)+_0x2997f3[_0x663245(0x214)]+_0x663245(0x221)+L(_0x2997f3[_0x663245(0x1e9)],_0x663245(0x22e))+'\x20to='+L(_0x2997f3[_0x663245(0x1eb)],_0x663245(0x22e))+_0x663245(0x1dc)+_0x21717e+'\x20parent_task_id='+_0x2402e6+_0x663245(0x1f3)+L(_0x2997f3[_0x663245(0x24b)],_0x663245(0x22e))+_0x663245(0x209)+_0x2997f3[_0x663245(0x20c)]+_0x663245(0x23c)+_0x2997f3[_0x663245(0x243)]+_0x663245(0x222)+_0x2997f3['lifecycle_tracking']+_0x5d0892;}function U(_0x65a6cf){const _0x198120=a0_0x35e9df;return{'event':{'sending':_0x198120(0x1ea),'delivered':_0x198120(0x1fa),'failed':_0x198120(0x1de),'acked':_0x198120(0x1e8),'started':_0x198120(0x1e2),'replied':_0x198120(0x22d),'expired':_0x198120(0x1ed)}[_0x65a6cf[_0x198120(0x214)]],..._0x65a6cf};}function a0_0x1020(_0x5d53fd,_0x31541c){_0x5d53fd=_0x5d53fd-0x1d0;const _0x52ef16=a0_0x52ef();let _0x1020dc=_0x52ef16[_0x5d53fd];return _0x1020dc;}function j(_0x404283){const _0x488483=a0_0x35e9df;let _0x1306b6=_0x404283?.['task_id']||_0x404283?.[_0x488483(0x1e7)]||_0x404283?.['id'];if(_0x1306b6)return String(_0x1306b6);let _0x3a7e1b=_0x404283?.[_0x488483(0x204)]?.[0x0]?.['text'];if(typeof _0x3a7e1b!=='string')return null;try{let _0x2847db=JSON[_0x488483(0x1e3)](_0x3a7e1b);return _0x2847db?.[_0x488483(0x1d3)]||_0x2847db?.['message_id']||_0x2847db?.['id']||null;}catch{return null;}}async function X(_0x1e2361,_0x43a826){const _0x3fc7a0=a0_0x35e9df;let _0x5f297a=_0x43a826[_0x3fc7a0(0x217)]??Date[_0x3fc7a0(0x217)],_0x3a20a3=_0x5f297a(),_0x3106c6=(_0x2bc707,_0x263773,_0x1703cf,_0x5047e6)=>{const _0x5580dd=_0x3fc7a0;_0x43a826[_0x5580dd(0x237)](O(U({'from_alias':_0x1e2361[_0x5580dd(0x23b)],'to_alias':_0x1e2361[_0x5580dd(0x1d4)],'task_id':_0x263773,'parent_task_id':_0x1e2361['parentTaskId'],'network_id':_0x1e2361[_0x5580dd(0x232)],'transport':_0x1e2361[_0x5580dd(0x20c)],'status':_0x2bc707,'duration_ms':_0x5f297a()-_0x3a20a3,'lifecycle_tracking':_0x1e2361[_0x5580dd(0x1e4)],..._0x1703cf!==void 0x0?{'error_code':_0x5047e6||_0x5580dd(0x1df),'error_message':N(_0x1703cf)}:{}})));};_0x3106c6(_0x3fc7a0(0x20f),null);try{let _0x4a5ea9=await _0x43a826[_0x3fc7a0(0x211)](),_0xb523b5=j(_0x4a5ea9);if(_0xb523b5)_0x3106c6('delivered',_0xb523b5);else{if(_0x4a5ea9?.['ok']===!0x1||_0x4a5ea9?.[_0x3fc7a0(0x1d7)])_0x3106c6(_0x3fc7a0(0x247),_0xb523b5,_0x4a5ea9?.[_0x3fc7a0(0x1d7)]||_0x3fc7a0(0x1fc),_0x3fc7a0(0x242));else _0x3106c6(_0x3fc7a0(0x247),null,_0x3fc7a0(0x20d),_0x3fc7a0(0x1f1));}return _0x4a5ea9;}catch(_0x1854ca){throw _0x3106c6(_0x3fc7a0(0x247),null,_0x1854ca,_0x3fc7a0(0x1df)),_0x1854ca;}}async function Y(_0xa278ce,_0x467938){const _0x1a4bd1=a0_0x35e9df;return X({'fromAlias':_0xa278ce[_0x1a4bd1(0x23b)],'toAlias':_0xa278ce[_0x1a4bd1(0x238)],'parentTaskId':_0xa278ce[_0x1a4bd1(0x22a)]||null,'networkId':_0xa278ce[_0x1a4bd1(0x232)]||null,'transport':_0x1a4bd1(0x246),'lifecycleTracking':'not_tracked'},_0x467938);}class $ extends a0_0x2c774d{['url'];[a0_0x35e9df(0x238)];['token'];[a0_0x35e9df(0x23e)];['resumeId'];[a0_0x35e9df(0x244)];[a0_0x35e9df(0x220)];[a0_0x35e9df(0x227)];[a0_0x35e9df(0x219)];[a0_0x35e9df(0x1f7)]=!0x1;constructor(_0x5e02a7){const _0xd61ed=a0_0x35e9df;super();if(this['url']=_0x5e02a7[_0xd61ed(0x1e0)][_0xd61ed(0x233)](/\/$/,''),this[_0xd61ed(0x238)]=_0x5e02a7[_0xd61ed(0x238)],this[_0xd61ed(0x230)]=_0x5e02a7[_0xd61ed(0x230)],this[_0xd61ed(0x23e)]=_0x5e02a7[_0xd61ed(0x23e)]||'sdk',this['resumeId']='sdk-'+_0x5e02a7[_0xd61ed(0x238)]+'-'+Date[_0xd61ed(0x217)]()[_0xd61ed(0x1fd)](0x24),this['heartbeatInterval']=_0x5e02a7[_0xd61ed(0x244)]??0x2bf20,this['reconnectDelay']=_0x5e02a7['reconnectDelay']??0xbb8,_0x5e02a7[_0xd61ed(0x200)]!==!0x1)this['connect']();}[a0_0x35e9df(0x237)](_0x4754a0){const _0x5867dc=a0_0x35e9df;console['log']('['+new Date()['toTimeString']()['slice'](0x0,0x8)+']\x20[commhub:'+this[_0x5867dc(0x238)]+']\x20'+_0x4754a0);}async[a0_0x35e9df(0x23d)](_0x5929ee,_0x5d8efe){const _0x581089=a0_0x35e9df;let _0x1b15ef={'Content-Type':_0x581089(0x1f5),'Accept':'application/json,\x20text/event-stream'};if(this[_0x581089(0x230)])_0x1b15ef['Authorization']=_0x581089(0x21e)+this[_0x581089(0x230)];let _0x281ead=await(await fetch(this[_0x581089(0x1e0)]+_0x581089(0x1fb),{'method':_0x581089(0x224),'headers':_0x1b15ef,'body':JSON[_0x581089(0x23f)]({'jsonrpc':_0x581089(0x21c),'id':Date[_0x581089(0x217)](),'method':_0x581089(0x239),'params':{'name':_0x5929ee,'arguments':_0x5d8efe}})}))[_0x581089(0x1dd)](),_0x46d7a2=_0x281ead[_0x581089(0x248)](/data: (.+)/),_0x17f155=_0x46d7a2?JSON[_0x581089(0x1e3)](_0x46d7a2[0x1]):JSON['parse'](_0x281ead),_0x6e3976=_0x17f155?.[_0x581089(0x1f9)]?.[_0x581089(0x204)]?.[0x0]?.[_0x581089(0x1dd)];return _0x6e3976?JSON['parse'](_0x6e3976):_0x17f155;}async[a0_0x35e9df(0x22c)](){const _0x34efce=a0_0x35e9df;if(this['running'])return;this[_0x34efce(0x1f7)]=!0x0,await this[_0x34efce(0x214)](_0x34efce(0x210)),this['log']('registered'),this[_0x34efce(0x227)]=setInterval(()=>{const _0x41f8b1=_0x34efce;this[_0x41f8b1(0x214)]('idle')[_0x41f8b1(0x23a)](_0x2401c4=>this[_0x41f8b1(0x237)](_0x41f8b1(0x225)+_0x2401c4['message']));},this[_0x34efce(0x244)]),this[_0x34efce(0x234)]();}async[a0_0x35e9df(0x202)](){const _0x5c9732=a0_0x35e9df;if(this[_0x5c9732(0x1f7)]=!0x1,this[_0x5c9732(0x219)]?.[_0x5c9732(0x1e1)](),this[_0x5c9732(0x227)])clearInterval(this['heartbeatTimer']);await this['status']('offline')[_0x5c9732(0x23a)](()=>{}),this[_0x5c9732(0x237)](_0x5c9732(0x1e5));}async[a0_0x35e9df(0x211)](_0x3aa46f,_0x58a0a6,_0xb8b238='normal'){const _0x566caa=a0_0x35e9df;return Y({'alias':_0x3aa46f,'fromAlias':this[_0x566caa(0x238)]},{'log':_0x4e8042=>console['log'](_0x4e8042),'send':()=>this['call'](_0x566caa(0x1d5),{'alias':_0x3aa46f,'task':_0x58a0a6,'priority':_0xb8b238,'from_session':this[_0x566caa(0x238)]})});}async[a0_0x35e9df(0x21f)](_0x2eb8c5,_0x4f42fe){const _0x56a39b=a0_0x35e9df;return this['call'](_0x56a39b(0x21d),{'alias':_0x2eb8c5,'message':_0x4f42fe,'from_session':this[_0x56a39b(0x238)]});}async[a0_0x35e9df(0x208)](_0xdad55f,_0x4aeb61,_0x96b4ab=a0_0x35e9df(0x1d1)){const _0xdcec24=a0_0x35e9df;return this[_0xdcec24(0x23d)](_0xdcec24(0x22f),{'in_reply_to':_0xdad55f,'text':_0x4aeb61,'status':_0x96b4ab});}async[a0_0x35e9df(0x214)](_0x45c425,_0x69827c){const _0x446f7b=a0_0x35e9df;return this[_0x446f7b(0x23d)](_0x446f7b(0x1d6),{'resume_id':this[_0x446f7b(0x21b)],'alias':this[_0x446f7b(0x238)],'status':_0x45c425,'server':a0_0x1af5e5(),'hostname':a0_0x1af5e5(),'agent':this[_0x446f7b(0x23e)],'project_dir':process['cwd'](),..._0x69827c});}async[a0_0x35e9df(0x207)](){const _0x52ea8c=a0_0x35e9df;return this[_0x52ea8c(0x23d)](_0x52ea8c(0x1fe),{});}async['broadcast'](_0x57f630,_0x488cca){const _0x52c49b=a0_0x35e9df;return this[_0x52c49b(0x23d)](_0x52c49b(0x1ef),{'message':_0x57f630,'filter_server':_0x488cca?.['server'],'filter_status':_0x488cca?.['status']});}async['connectSSE'](){const _0x3549d6=a0_0x35e9df;let _0x357101=encodeURIComponent(this['alias']),_0x49e7f3=this['url']+_0x3549d6(0x212)+_0x357101,_0x3eed00=this[_0x3549d6(0x220)];while(this[_0x3549d6(0x1f7)]){try{this[_0x3549d6(0x219)]=new AbortController();let _0x204f18={'Accept':_0x3549d6(0x241)};if(this[_0x3549d6(0x230)])_0x204f18[_0x3549d6(0x226)]=_0x3549d6(0x21e)+this[_0x3549d6(0x230)];let _0x55ef7f=await fetch(_0x49e7f3,{'headers':_0x204f18,'signal':this[_0x3549d6(0x219)]['signal']});if(!_0x55ef7f['ok']||!_0x55ef7f[_0x3549d6(0x229)]){this[_0x3549d6(0x237)](_0x3549d6(0x206)+_0x55ef7f['status']),await this[_0x3549d6(0x20a)](_0x3eed00),_0x3eed00=Math[_0x3549d6(0x236)](_0x3eed00*1.5,0xea60);continue;}_0x3eed00=this['reconnectDelay'];let _0x32f4b3=_0x55ef7f['body'][_0x3549d6(0x1f4)](),_0x17e8b3=new TextDecoder(),_0x452b59='';while(this[_0x3549d6(0x1f7)]){let {done:_0x2232d9,value:_0x1c16ca}=await _0x32f4b3[_0x3549d6(0x205)]();if(_0x2232d9)break;_0x452b59+=_0x17e8b3[_0x3549d6(0x1f8)](_0x1c16ca,{'stream':!0x0});let _0x5cf7bb=_0x452b59[_0x3549d6(0x1db)]('\x0a');_0x452b59=_0x5cf7bb['pop']()||'';for(let _0xe3e4e4 of _0x5cf7bb){if(!_0xe3e4e4[_0x3549d6(0x249)]('data:\x20'))continue;try{let _0xc4a815=JSON[_0x3549d6(0x1e3)](_0xe3e4e4['slice'](0x6));if(_0xc4a815[_0x3549d6(0x1f6)]===_0x3549d6(0x213)){this[_0x3549d6(0x237)](_0x3549d6(0x1d0)),this['emit'](_0x3549d6(0x213));continue;}if(_0xc4a815[_0x3549d6(0x1f6)]===_0x3549d6(0x1ec)||_0xc4a815[_0x3549d6(0x1f6)]===_0x3549d6(0x20e)||_0xc4a815[_0x3549d6(0x1f6)]==='broadcast')await this[_0x3549d6(0x24a)]();}catch{}}}}catch(_0x11ae01){if(_0x11ae01[_0x3549d6(0x218)]==='AbortError')break;this[_0x3549d6(0x215)](_0x3549d6(0x1d7),_0x11ae01),this[_0x3549d6(0x237)](_0x3549d6(0x245)+_0x11ae01[_0x3549d6(0x21f)]);}if(this[_0x3549d6(0x1f7)])this[_0x3549d6(0x215)](_0x3549d6(0x1e5)),this[_0x3549d6(0x237)](_0x3549d6(0x231)+_0x3eed00/0x3e8+'s...'),await this[_0x3549d6(0x20a)](_0x3eed00),_0x3eed00=Math[_0x3549d6(0x236)](_0x3eed00*1.5,0xea60);}}async['processInbox'](){const _0x4c5332=a0_0x35e9df;try{let _0x2579db=(await this[_0x4c5332(0x23d)](_0x4c5332(0x235),{'alias':this[_0x4c5332(0x238)],'limit':0xa}))?.[_0x4c5332(0x1d2)]||[];for(let _0x52c81c of _0x2579db)await this[_0x4c5332(0x23d)](_0x4c5332(0x1ff),{'alias':this[_0x4c5332(0x238)],'message_id':_0x52c81c['id']}),this[_0x4c5332(0x237)]('←\x20'+_0x52c81c['from_session']+':\x20'+_0x52c81c[_0x4c5332(0x204)][_0x4c5332(0x223)](0x0,0x3c)),this[_0x4c5332(0x215)]('task',_0x52c81c),this[_0x4c5332(0x215)](_0x4c5332(0x21f),_0x52c81c);}catch(_0x4481fa){this[_0x4c5332(0x237)](_0x4c5332(0x1f0)+_0x4481fa[_0x4c5332(0x21f)]);}}[a0_0x35e9df(0x20a)](_0x33547f){return new Promise(_0x4d625c=>setTimeout(_0x4d625c,_0x33547f));}}var F=$;function a0_0x52ef(){const _0x227888=['from_alias','task.send.start','to_alias','new_task','task.expired','error_code','broadcast','inbox\x20error:\x20','missing_task_id','parent_task_id','\x20network_id=','getReader','application/json','type','running','decode','result','task.send.delivered','/mcp','CommHub\x20rejected\x20task','toString','get_all_status','ack_inbox','autoConnect','unknown\x20error','disconnect','315911eaGdBY','content','read','SSE\x20failed:\x20','getAllStatus','reply','\x20transport=','sleep','7DfnrFd','transport','CommHub\x20response\x20omitted\x20task_id','new_message','sending','idle','send','/events/','connected','status','emit','2119602hANkGE','now','name','sseAbort','10899592dMmgMk','resumeId','2.0','send_message','Bearer\x20','message','reconnectDelay','\x20from=','\x20lifecycle=','slice','POST','heartbeat\x20failed:\x20','Authorization','heartbeatTimer','1253586mYIRqq','body','parentTaskId','json','connect','task.replied','<unknown>','send_reply','token','SSE\x20reconnecting\x20in\x20','networkId','replace','connectSSE','get_inbox','min','log','alias','tools/call','catch','fromAlias','\x20duration_ms=','call','agent','stringify','1145370oqxfpf','text/event-stream','send_rejected','duration_ms','heartbeatInterval','SSE\x20error:\x20','mcp_http','failed','match','startsWith','processInbox','network_id','SSE\x20connected','completed','messages','task_id','toAlias','send_task','report_status','error','\x20error=','2640099vzyPZs','1400636nKPWKN','split','\x20task_id=','text','task.send.failed','send_failed','url','abort','task.started','parse','lifecycleTracking','disconnected','[commhub:task]\x20','message_id','task.ack'];a0_0x52ef=function(){return _0x227888;};return a0_0x52ef();}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};