@sleep2agi/agent-network 2.3.0-preview.265 → 2.3.0-preview.267

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_0x2788ae=a0_0x1127;(function(_0x3e1f65,_0x5137d1){const _0x20846b=a0_0x1127,_0x1ec76a=_0x3e1f65();while(!![]){try{const _0x16182e=parseInt(_0x20846b(0x1c6))/0x1*(parseInt(_0x20846b(0x1ff))/0x2)+-parseInt(_0x20846b(0x1e6))/0x3*(-parseInt(_0x20846b(0x1d2))/0x4)+-parseInt(_0x20846b(0x1f1))/0x5+parseInt(_0x20846b(0x214))/0x6*(parseInt(_0x20846b(0x1de))/0x7)+parseInt(_0x20846b(0x226))/0x8+parseInt(_0x20846b(0x222))/0x9+-parseInt(_0x20846b(0x1e4))/0xa;if(_0x16182e===_0x5137d1)break;else _0x1ec76a['push'](_0x1ec76a['shift']());}catch(_0x3b237e){_0x1ec76a['push'](_0x1ec76a['shift']());}}}(a0_0x3164,0xa3798));import{EventEmitter as a0_0x128c83}from'events';import{hostname as a0_0x521838}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x5d91fa,_0xde6489)=>(_0x5d91fa??_0xde6489)[a0_0x2788ae(0x1ec)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x2788ae(0x202)](0x0,0xf0);function N(_0xb11b93){const _0x199481=a0_0x2788ae;return(_0xb11b93 instanceof Error?_0xb11b93[_0x199481(0x220)]:String(_0xb11b93??_0x199481(0x1e9)))[_0x199481(0x1ec)](K,_0x199481(0x235))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x199481(0x202)](0x0,0xf0);}function O(_0x2b24e5,_0x10f149=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0xbb625e=a0_0x2788ae;if(_0x10f149)return JSON[_0xbb625e(0x238)](_0x2b24e5);let _0x2b99a9=L(_0x2b24e5[_0xbb625e(0x237)],_0xbb625e(0x1d5)),_0x48558a=L(_0x2b24e5['task_id'],'<pending>'),_0x492f0c=_0x2b24e5['error_code']?_0xbb625e(0x22d)+_0x2b24e5['error_code']+':'+(_0x2b24e5[_0xbb625e(0x234)]??''):'';return'[commhub:task]\x20'+_0x2b24e5['status']+'\x20from='+L(_0x2b24e5[_0xbb625e(0x1fa)],_0xbb625e(0x22a))+_0xbb625e(0x1c3)+L(_0x2b24e5[_0xbb625e(0x23d)],'<unknown>')+_0xbb625e(0x205)+_0x48558a+_0xbb625e(0x219)+_0x2b99a9+_0xbb625e(0x1e0)+L(_0x2b24e5[_0xbb625e(0x231)],_0xbb625e(0x22a))+_0xbb625e(0x20a)+_0x2b24e5[_0xbb625e(0x22c)]+'\x20duration_ms='+_0x2b24e5[_0xbb625e(0x1c5)]+_0xbb625e(0x1e7)+_0x2b24e5['lifecycle_tracking']+_0x492f0c;}function a0_0x1127(_0x4067eb,_0x43e514){_0x4067eb=_0x4067eb-0x1c1;const _0x316496=a0_0x3164();let _0x1127db=_0x316496[_0x4067eb];return _0x1127db;}function U(_0xeba0e4){const _0x542bb6=a0_0x2788ae;return{'event':{'sending':_0x542bb6(0x203),'delivered':'task.send.delivered','failed':_0x542bb6(0x233),'acked':_0x542bb6(0x229),'started':_0x542bb6(0x212),'replied':_0x542bb6(0x215),'expired':_0x542bb6(0x1f0)}[_0xeba0e4[_0x542bb6(0x217)]],..._0xeba0e4};}function j(_0x126311){const _0x403cc5=a0_0x2788ae;let _0x17ff82=_0x126311?.['task_id']||_0x126311?.[_0x403cc5(0x210)]||_0x126311?.['id'];if(_0x17ff82)return String(_0x17ff82);let _0xbcec94=_0x126311?.[_0x403cc5(0x23f)]?.[0x0]?.[_0x403cc5(0x1e1)];if(typeof _0xbcec94!==_0x403cc5(0x1cc))return null;try{let _0x4f79f4=JSON[_0x403cc5(0x1df)](_0xbcec94);return _0x4f79f4?.[_0x403cc5(0x1ed)]||_0x4f79f4?.[_0x403cc5(0x210)]||_0x4f79f4?.['id']||null;}catch{return null;}}async function X(_0x263660,_0x1eda36){const _0x561f45=a0_0x2788ae;let _0x5cf7ce=_0x1eda36[_0x561f45(0x1dc)]??Date['now'],_0x21886f=_0x5cf7ce(),_0x3e192a=(_0xdc3a19,_0x44a7b2,_0x5863ac,_0x4741ed)=>{const _0x158020=_0x561f45;_0x1eda36['log'](O(U({'from_alias':_0x263660[_0x158020(0x1cd)],'to_alias':_0x263660[_0x158020(0x1c7)],'task_id':_0x44a7b2,'parent_task_id':_0x263660['parentTaskId'],'network_id':_0x263660[_0x158020(0x1ee)],'transport':_0x263660[_0x158020(0x22c)],'status':_0xdc3a19,'duration_ms':_0x5cf7ce()-_0x21886f,'lifecycle_tracking':_0x263660[_0x158020(0x230)],..._0x5863ac!==void 0x0?{'error_code':_0x4741ed||_0x158020(0x21a),'error_message':N(_0x5863ac)}:{}})));};_0x3e192a(_0x561f45(0x20f),null);try{let _0x22394f=await _0x1eda36['send'](),_0x2a9809=j(_0x22394f);if(_0x2a9809)_0x3e192a('delivered',_0x2a9809);else{if(_0x22394f?.['ok']===!0x1||_0x22394f?.[_0x561f45(0x1dd)])_0x3e192a(_0x561f45(0x240),_0x2a9809,_0x22394f?.[_0x561f45(0x1dd)]||_0x561f45(0x218),_0x561f45(0x1d4));else _0x3e192a('failed',null,_0x561f45(0x23a),_0x561f45(0x1ea));}return _0x22394f;}catch(_0x13d14f){throw _0x3e192a(_0x561f45(0x240),null,_0x13d14f,'send_failed'),_0x13d14f;}}async function Y(_0x22ea2d,_0x2f88de){const _0x2f11c2=a0_0x2788ae;return X({'fromAlias':_0x22ea2d['fromAlias'],'toAlias':_0x22ea2d['alias'],'parentTaskId':_0x22ea2d[_0x2f11c2(0x20e)]||null,'networkId':_0x22ea2d[_0x2f11c2(0x1ee)]||null,'transport':_0x2f11c2(0x1f4),'lifecycleTracking':_0x2f11c2(0x20b)},_0x2f88de);}class $ extends a0_0x128c83{[a0_0x2788ae(0x1ef)];['alias'];[a0_0x2788ae(0x21f)];[a0_0x2788ae(0x20c)];[a0_0x2788ae(0x1f5)];[a0_0x2788ae(0x216)];[a0_0x2788ae(0x22e)];['heartbeatTimer'];[a0_0x2788ae(0x1f7)];[a0_0x2788ae(0x1d6)]=!0x1;constructor(_0x4ef2b7){const _0x37c722=a0_0x2788ae;super();if(this['url']=_0x4ef2b7['url'][_0x37c722(0x1ec)](/\/$/,''),this['alias']=_0x4ef2b7['alias'],this[_0x37c722(0x21f)]=_0x4ef2b7[_0x37c722(0x21f)],this[_0x37c722(0x20c)]=_0x4ef2b7[_0x37c722(0x20c)]||'sdk',this[_0x37c722(0x1f5)]='sdk-'+_0x4ef2b7[_0x37c722(0x211)]+'-'+Date[_0x37c722(0x1dc)]()[_0x37c722(0x1eb)](0x24),this[_0x37c722(0x216)]=_0x4ef2b7[_0x37c722(0x216)]??0x2bf20,this[_0x37c722(0x22e)]=_0x4ef2b7[_0x37c722(0x22e)]??0xbb8,_0x4ef2b7[_0x37c722(0x208)]!==!0x1)this[_0x37c722(0x1c9)]();}[a0_0x2788ae(0x1fc)](_0xc2ffc5){const _0x54dcfd=a0_0x2788ae;console['log']('['+new Date()['toTimeString']()['slice'](0x0,0x8)+_0x54dcfd(0x21e)+this[_0x54dcfd(0x211)]+']\x20'+_0xc2ffc5);}async[a0_0x2788ae(0x1f6)](_0x10b77a,_0x85186e){const _0x139943=a0_0x2788ae;let _0x534d11={'Content-Type':_0x139943(0x1fb),'Accept':_0x139943(0x1c8)};if(this[_0x139943(0x21f)])_0x534d11[_0x139943(0x23c)]=_0x139943(0x223)+this[_0x139943(0x21f)];let _0xdabf5a=await(await fetch(this[_0x139943(0x1ef)]+_0x139943(0x236),{'method':_0x139943(0x206),'headers':_0x534d11,'body':JSON['stringify']({'jsonrpc':'2.0','id':Date[_0x139943(0x1dc)](),'method':'tools/call','params':{'name':_0x10b77a,'arguments':_0x85186e}})}))[_0x139943(0x1e1)](),_0x4cd71a=_0xdabf5a[_0x139943(0x1c1)](/data: (.+)/),_0x373799=_0x4cd71a?JSON[_0x139943(0x1df)](_0x4cd71a[0x1]):JSON[_0x139943(0x1df)](_0xdabf5a),_0x2ff6d0=_0x373799?.[_0x139943(0x1cb)]?.[_0x139943(0x23f)]?.[0x0]?.['text'];return _0x2ff6d0?JSON[_0x139943(0x1df)](_0x2ff6d0):_0x373799;}async[a0_0x2788ae(0x1c9)](){const _0x36e2f2=a0_0x2788ae;if(this[_0x36e2f2(0x1d6)])return;this[_0x36e2f2(0x1d6)]=!0x0,await this[_0x36e2f2(0x217)](_0x36e2f2(0x22f)),this[_0x36e2f2(0x1fc)]('registered'),this['heartbeatTimer']=setInterval(()=>{const _0x1b499e=_0x36e2f2;this[_0x1b499e(0x217)](_0x1b499e(0x22f))[_0x1b499e(0x21d)](_0x32cccf=>this[_0x1b499e(0x1fc)](_0x1b499e(0x1d7)+_0x32cccf[_0x1b499e(0x220)]));},this[_0x36e2f2(0x216)]),this[_0x36e2f2(0x224)]();}async[a0_0x2788ae(0x1d1)](){const _0x4fb8ce=a0_0x2788ae;if(this[_0x4fb8ce(0x1d6)]=!0x1,this['sseAbort']?.['abort'](),this[_0x4fb8ce(0x200)])clearInterval(this['heartbeatTimer']);await this[_0x4fb8ce(0x217)](_0x4fb8ce(0x1fd))[_0x4fb8ce(0x21d)](()=>{}),this[_0x4fb8ce(0x1fc)](_0x4fb8ce(0x209));}async[a0_0x2788ae(0x1d0)](_0x2bee36,_0x470a5c,_0x55fe1f=a0_0x2788ae(0x1fe)){const _0x1e08bf=a0_0x2788ae;return Y({'alias':_0x2bee36,'fromAlias':this['alias']},{'log':_0x28108f=>console[_0x1e08bf(0x1fc)](_0x28108f),'send':()=>this[_0x1e08bf(0x1f6)](_0x1e08bf(0x239),{'alias':_0x2bee36,'task':_0x470a5c,'priority':_0x55fe1f,'from_session':this[_0x1e08bf(0x211)]})});}async[a0_0x2788ae(0x220)](_0x543b90,_0x3fb63a){const _0x4c326d=a0_0x2788ae;return this[_0x4c326d(0x1f6)](_0x4c326d(0x1f3),{'alias':_0x543b90,'message':_0x3fb63a,'from_session':this['alias']});}async[a0_0x2788ae(0x213)](_0x2da846,_0x5f130f,_0x33cac7=a0_0x2788ae(0x21c)){const _0x556af2=a0_0x2788ae;return this[_0x556af2(0x1f6)](_0x556af2(0x1cf),{'in_reply_to':_0x2da846,'text':_0x5f130f,'status':_0x33cac7});}async[a0_0x2788ae(0x217)](_0x2f7277,_0x1c9a14){const _0x5275bd=a0_0x2788ae;return this['call'](_0x5275bd(0x23b),{'resume_id':this[_0x5275bd(0x1f5)],'alias':this[_0x5275bd(0x211)],'status':_0x2f7277,'server':a0_0x521838(),'hostname':a0_0x521838(),'agent':this['agent'],'project_dir':process['cwd'](),..._0x1c9a14});}async[a0_0x2788ae(0x1e2)](){const _0x54ab57=a0_0x2788ae;return this[_0x54ab57(0x1f6)](_0x54ab57(0x1e8),{});}async[a0_0x2788ae(0x1ce)](_0x4bd048,_0x43060d){const _0x1c0bc6=a0_0x2788ae;return this[_0x1c0bc6(0x1f6)](_0x1c0bc6(0x1ce),{'message':_0x4bd048,'filter_server':_0x43060d?.['server'],'filter_status':_0x43060d?.['status']});}async[a0_0x2788ae(0x224)](){const _0x3e5de4=a0_0x2788ae;let _0x21cc29=encodeURIComponent(this['alias']),_0x13cb91=this[_0x3e5de4(0x1ef)]+_0x3e5de4(0x221)+_0x21cc29,_0x13b96a=this[_0x3e5de4(0x22e)];while(this[_0x3e5de4(0x1d6)]){try{this['sseAbort']=new AbortController();let _0x2d57df={'Accept':_0x3e5de4(0x207)};if(this[_0x3e5de4(0x21f)])_0x2d57df[_0x3e5de4(0x23c)]=_0x3e5de4(0x223)+this['token'];let _0x4a35bf=await fetch(_0x13cb91,{'headers':_0x2d57df,'signal':this[_0x3e5de4(0x1f7)][_0x3e5de4(0x1e3)]});if(!_0x4a35bf['ok']||!_0x4a35bf[_0x3e5de4(0x242)]){this[_0x3e5de4(0x1fc)](_0x3e5de4(0x1f2)+_0x4a35bf[_0x3e5de4(0x217)]),await this[_0x3e5de4(0x243)](_0x13b96a),_0x13b96a=Math[_0x3e5de4(0x1d9)](_0x13b96a*1.5,0xea60);continue;}_0x13b96a=this['reconnectDelay'];let _0x46d92a=_0x4a35bf['body'][_0x3e5de4(0x1e5)](),_0x3cecf0=new TextDecoder(),_0x1ed38a='';while(this[_0x3e5de4(0x1d6)]){let {done:_0x183582,value:_0xcb0011}=await _0x46d92a[_0x3e5de4(0x1d3)]();if(_0x183582)break;_0x1ed38a+=_0x3cecf0['decode'](_0xcb0011,{'stream':!0x0});let _0x944dcf=_0x1ed38a[_0x3e5de4(0x1db)]('\x0a');_0x1ed38a=_0x944dcf[_0x3e5de4(0x232)]()||'';for(let _0x1ddbf1 of _0x944dcf){if(!_0x1ddbf1[_0x3e5de4(0x1ca)](_0x3e5de4(0x227)))continue;try{let _0xaf7b2f=JSON[_0x3e5de4(0x1df)](_0x1ddbf1[_0x3e5de4(0x202)](0x6));if(_0xaf7b2f[_0x3e5de4(0x23e)]==='connected'){this['log'](_0x3e5de4(0x228)),this[_0x3e5de4(0x1f9)]('connected');continue;}if(_0xaf7b2f[_0x3e5de4(0x23e)]==='new_task'||_0xaf7b2f[_0x3e5de4(0x23e)]==='new_message'||_0xaf7b2f[_0x3e5de4(0x23e)]===_0x3e5de4(0x1ce))await this[_0x3e5de4(0x22b)]();}catch{}}}}catch(_0x3df3a4){if(_0x3df3a4[_0x3e5de4(0x201)]===_0x3e5de4(0x20d))break;this[_0x3e5de4(0x1f9)]('error',_0x3df3a4),this[_0x3e5de4(0x1fc)](_0x3e5de4(0x1c4)+_0x3df3a4[_0x3e5de4(0x220)]);}if(this[_0x3e5de4(0x1d6)])this[_0x3e5de4(0x1f9)](_0x3e5de4(0x209)),this[_0x3e5de4(0x1fc)](_0x3e5de4(0x204)+_0x13b96a/0x3e8+_0x3e5de4(0x1da)),await this[_0x3e5de4(0x243)](_0x13b96a),_0x13b96a=Math[_0x3e5de4(0x1d9)](_0x13b96a*1.5,0xea60);}}async['processInbox'](){const _0x4c3c5e=a0_0x2788ae;try{let _0x2a15aa=(await this[_0x4c3c5e(0x1f6)](_0x4c3c5e(0x1d8),{'alias':this[_0x4c3c5e(0x211)],'limit':0xa}))?.[_0x4c3c5e(0x21b)]||[];for(let _0x434266 of _0x2a15aa)await this['call'](_0x4c3c5e(0x241),{'alias':this['alias'],'message_id':_0x434266['id']}),this[_0x4c3c5e(0x1fc)]('←\x20'+_0x434266[_0x4c3c5e(0x225)]+':\x20'+_0x434266[_0x4c3c5e(0x23f)][_0x4c3c5e(0x202)](0x0,0x3c)),this[_0x4c3c5e(0x1f9)](_0x4c3c5e(0x1c2),_0x434266),this[_0x4c3c5e(0x1f9)](_0x4c3c5e(0x220),_0x434266);}catch(_0x1d986e){this[_0x4c3c5e(0x1fc)](_0x4c3c5e(0x1f8)+_0x1d986e[_0x4c3c5e(0x220)]);}}[a0_0x2788ae(0x243)](_0x380ea0){return new Promise(_0x5ae906=>setTimeout(_0x5ae906,_0x380ea0));}}function a0_0x3164(){const _0x307d82=['CommHub\x20response\x20omitted\x20task_id','report_status','Authorization','to_alias','type','content','failed','ack_inbox','body','sleep','match','task','\x20to=','SSE\x20error:\x20','duration_ms','11683IrUoVR','toAlias','application/json,\x20text/event-stream','connect','startsWith','result','string','fromAlias','broadcast','send_reply','send','disconnect','3576292ksKFIC','read','send_rejected','<missing>','running','heartbeat\x20failed:\x20','get_inbox','min','s...','split','now','error','4637143iwayUG','parse','\x20network_id=','text','getAllStatus','signal','21028050vAMiNt','getReader','3dwyomF','\x20lifecycle=','get_all_status','unknown\x20error','missing_task_id','toString','replace','task_id','networkId','url','task.expired','5988725EvRQMx','SSE\x20failed:\x20','send_message','mcp_http','resumeId','call','sseAbort','inbox\x20error:\x20','emit','from_alias','application/json','log','offline','normal','166CcvTey','heartbeatTimer','name','slice','task.send.start','SSE\x20reconnecting\x20in\x20','\x20task_id=','POST','text/event-stream','autoConnect','disconnected','\x20transport=','not_tracked','agent','AbortError','parentTaskId','sending','message_id','alias','task.started','reply','12KaEooZ','task.replied','heartbeatInterval','status','CommHub\x20rejected\x20task','\x20parent_task_id=','send_failed','messages','completed','catch',']\x20[commhub:','token','message','/events/','779292lupqeD','Bearer\x20','connectSSE','from_session','5559152qFqipT','data:\x20','SSE\x20connected','task.ack','<unknown>','processInbox','transport','\x20error=','reconnectDelay','idle','lifecycleTracking','network_id','pop','task.send.failed','error_message','[REDACTED]','/mcp','parent_task_id','stringify','send_task'];a0_0x3164=function(){return _0x307d82;};return a0_0x3164();}var F=$;export{F as default,$ as CommHub};
1
+ const a0_0x3628a8=a0_0x6382;(function(_0x294cf5,_0x1341c3){const _0x226192=a0_0x6382,_0x5d4c26=_0x294cf5();while(!![]){try{const _0x56f497=-parseInt(_0x226192(0x127))/0x1+-parseInt(_0x226192(0x12d))/0x2*(parseInt(_0x226192(0x139))/0x3)+parseInt(_0x226192(0x164))/0x4+-parseInt(_0x226192(0x173))/0x5*(-parseInt(_0x226192(0x158))/0x6)+parseInt(_0x226192(0x141))/0x7+-parseInt(_0x226192(0x12b))/0x8*(-parseInt(_0x226192(0x19d))/0x9)+parseInt(_0x226192(0x17f))/0xa*(-parseInt(_0x226192(0x13d))/0xb);if(_0x56f497===_0x1341c3)break;else _0x5d4c26['push'](_0x5d4c26['shift']());}catch(_0x2a5558){_0x5d4c26['push'](_0x5d4c26['shift']());}}}(a0_0xc728,0x1c141));import{EventEmitter as a0_0x150ff0}from'events';import{hostname as a0_0x4846f8}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x5a740d,_0x96f21c)=>(_0x5a740d??_0x96f21c)[a0_0x3628a8(0x167)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x481f9e){const _0x1725a3=a0_0x3628a8;return(_0x481f9e instanceof Error?_0x481f9e[_0x1725a3(0x142)]:String(_0x481f9e??_0x1725a3(0x19e)))[_0x1725a3(0x167)](K,'[REDACTED]')[_0x1725a3(0x167)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x1725a3(0x134)](0x0,0xf0);}function O(_0x130c16,_0xf6b5a1=process.env.ANET_TASK_TRACE_FORMAT===a0_0x3628a8(0x151)){const _0x1e77f7=a0_0x3628a8;if(_0xf6b5a1)return JSON[_0x1e77f7(0x181)](_0x130c16);let _0x50bfa6=L(_0x130c16['parent_task_id'],_0x1e77f7(0x1a0)),_0xadb608=L(_0x130c16['task_id'],_0x1e77f7(0x1a3)),_0xd66fad=_0x130c16['error_code']?_0x1e77f7(0x17d)+_0x130c16[_0x1e77f7(0x171)]+':'+(_0x130c16[_0x1e77f7(0x16f)]??''):'';return'[commhub:task]\x20'+_0x130c16[_0x1e77f7(0x18c)]+'\x20from='+L(_0x130c16['from_alias'],_0x1e77f7(0x16d))+_0x1e77f7(0x194)+L(_0x130c16[_0x1e77f7(0x13e)],'<unknown>')+_0x1e77f7(0x13a)+_0xadb608+_0x1e77f7(0x180)+_0x50bfa6+'\x20network_id='+L(_0x130c16[_0x1e77f7(0x196)],_0x1e77f7(0x16d))+_0x1e77f7(0x16a)+_0x130c16[_0x1e77f7(0x136)]+'\x20duration_ms='+_0x130c16[_0x1e77f7(0x138)]+_0x1e77f7(0x1a8)+_0x130c16[_0x1e77f7(0x13c)]+_0xd66fad;}function a0_0x6382(_0x3a4062,_0x413b17){_0x3a4062=_0x3a4062-0x127;const _0xc7285=a0_0xc728();let _0x63826=_0xc7285[_0x3a4062];return _0x63826;}function U(_0x39bafa){const _0x7552af=a0_0x3628a8;return{'event':{'sending':_0x7552af(0x14f),'delivered':'task.send.delivered','failed':_0x7552af(0x198),'acked':_0x7552af(0x168),'started':_0x7552af(0x163),'replied':_0x7552af(0x157),'expired':_0x7552af(0x177)}[_0x39bafa['status']],..._0x39bafa};}function j(_0x4caa10){const _0xf9df9f=a0_0x3628a8;let _0x280a50=_0x4caa10?.[_0xf9df9f(0x145)]||_0x4caa10?.[_0xf9df9f(0x129)]||_0x4caa10?.['id'];if(_0x280a50)return String(_0x280a50);let _0x414844=_0x4caa10?.['content']?.[0x0]?.['text'];if(typeof _0x414844!=='string')return null;try{let _0x1aa276=JSON[_0xf9df9f(0x147)](_0x414844);return _0x1aa276?.[_0xf9df9f(0x145)]||_0x1aa276?.['message_id']||_0x1aa276?.['id']||null;}catch{return null;}}async function X(_0x3ffd8a,_0x343894){const _0x2e6703=a0_0x3628a8;let _0x458927=_0x343894['now']??Date['now'],_0x3eea43=_0x458927(),_0x1c59a4=(_0x4b4fb6,_0x410c5a,_0x1b5f5e,_0xd6a61c)=>{const _0x2efff2=a0_0x6382;_0x343894[_0x2efff2(0x199)](O(U({'from_alias':_0x3ffd8a[_0x2efff2(0x1a1)],'to_alias':_0x3ffd8a[_0x2efff2(0x148)],'task_id':_0x410c5a,'parent_task_id':_0x3ffd8a['parentTaskId'],'network_id':_0x3ffd8a[_0x2efff2(0x15d)],'transport':_0x3ffd8a[_0x2efff2(0x136)],'status':_0x4b4fb6,'duration_ms':_0x458927()-_0x3eea43,'lifecycle_tracking':_0x3ffd8a[_0x2efff2(0x195)],..._0x1b5f5e!==void 0x0?{'error_code':_0xd6a61c||'send_failed','error_message':N(_0x1b5f5e)}:{}})));};_0x1c59a4(_0x2e6703(0x185),null);try{let _0x21de47=await _0x343894[_0x2e6703(0x130)](),_0x150f17=j(_0x21de47);if(_0x150f17)_0x1c59a4('delivered',_0x150f17);else{if(_0x21de47?.['ok']===!0x1||_0x21de47?.[_0x2e6703(0x152)])_0x1c59a4(_0x2e6703(0x166),_0x150f17,_0x21de47?.['error']||_0x2e6703(0x19c),_0x2e6703(0x187));else _0x1c59a4(_0x2e6703(0x166),null,_0x2e6703(0x16c),'missing_task_id');}return _0x21de47;}catch(_0x40936f){throw _0x1c59a4(_0x2e6703(0x166),null,_0x40936f,'send_failed'),_0x40936f;}}function a0_0xc728(){const _0x1fde7f=['transport','application/json','duration_ms','93ixhzLr','\x20task_id=','read','lifecycle_tracking','297mnBJBJ','to_alias','text','not_tracked','565082kumgiw','message','text/event-stream','startsWith','task_id','alias','parse','toAlias','s...','sdk-','abort','SSE\x20reconnecting\x20in\x20','broadcast','toTimeString','task.send.start','token','json','error','connect','signal','call','get_inbox','task.replied','1307658wQPtde','inbox\x20error:\x20','sleep','now','sseAbort','networkId','split','result','normal','POST','processInbox','task.started','102740TddmCd','tools/call','failed','replace','task.ack','heartbeat\x20failed:\x20','\x20transport=','sdk','CommHub\x20response\x20omitted\x20task_id','<unknown>','get_all_status','error_message','server','error_code','Authorization','5yAULPJ','resumeId','connectSSE','pop','task.expired','disconnect','min','Bearer\x20','match','report_status','\x20error=','from_session','103570fIHYKN','\x20parent_task_id=','stringify','body','new_task','connected','sending','send_message','send_rejected','heartbeatTimer','application/json,\x20text/event-stream','parentTaskId','data:\x20','status','heartbeatInterval','task','ack_inbox','name','type','registered','/events/','\x20to=','lifecycleTracking','network_id','completed','task.send.failed','log','content','emit','CommHub\x20rejected\x20task','18XJPBYp','unknown\x20error','reconnectDelay','<missing>','fromAlias','url','<pending>','reply','send_task','agent','autoConnect','\x20lifecycle=','116163PljwSL','SSE\x20connected','message_id','/mcp','796544eAKWEm','idle','818iCzNYz','cwd','getReader','send','disconnected','new_message','catch','slice','running'];a0_0xc728=function(){return _0x1fde7f;};return a0_0xc728();}async function Y(_0x5823f7,_0x100e37){const _0x1bb699=a0_0x3628a8;return X({'fromAlias':_0x5823f7[_0x1bb699(0x1a1)],'toAlias':_0x5823f7[_0x1bb699(0x146)],'parentTaskId':_0x5823f7[_0x1bb699(0x18a)]||null,'networkId':_0x5823f7[_0x1bb699(0x15d)]||null,'transport':'mcp_http','lifecycleTracking':_0x1bb699(0x140)},_0x100e37);}class $ extends a0_0x150ff0{[a0_0x3628a8(0x1a2)];[a0_0x3628a8(0x146)];[a0_0x3628a8(0x150)];[a0_0x3628a8(0x1a6)];[a0_0x3628a8(0x174)];[a0_0x3628a8(0x18d)];[a0_0x3628a8(0x19f)];['heartbeatTimer'];[a0_0x3628a8(0x15c)];[a0_0x3628a8(0x135)]=!0x1;constructor(_0x2f1714){const _0x242ed2=a0_0x3628a8;super();if(this[_0x242ed2(0x1a2)]=_0x2f1714[_0x242ed2(0x1a2)][_0x242ed2(0x167)](/\/$/,''),this['alias']=_0x2f1714['alias'],this[_0x242ed2(0x150)]=_0x2f1714[_0x242ed2(0x150)],this[_0x242ed2(0x1a6)]=_0x2f1714['agent']||_0x242ed2(0x16b),this['resumeId']=_0x242ed2(0x14a)+_0x2f1714['alias']+'-'+Date[_0x242ed2(0x15b)]()['toString'](0x24),this['heartbeatInterval']=_0x2f1714['heartbeatInterval']??0x2bf20,this[_0x242ed2(0x19f)]=_0x2f1714[_0x242ed2(0x19f)]??0xbb8,_0x2f1714[_0x242ed2(0x1a7)]!==!0x1)this[_0x242ed2(0x153)]();}[a0_0x3628a8(0x199)](_0x5ccbf1){const _0x2450e6=a0_0x3628a8;console[_0x2450e6(0x199)]('['+new Date()[_0x2450e6(0x14e)]()['slice'](0x0,0x8)+']\x20[commhub:'+this[_0x2450e6(0x146)]+']\x20'+_0x5ccbf1);}async[a0_0x3628a8(0x155)](_0x55e918,_0xfedba2){const _0x30fd76=a0_0x3628a8;let _0x478e7b={'Content-Type':_0x30fd76(0x137),'Accept':_0x30fd76(0x189)};if(this[_0x30fd76(0x150)])_0x478e7b[_0x30fd76(0x172)]='Bearer\x20'+this[_0x30fd76(0x150)];let _0x29ca03=await(await fetch(this[_0x30fd76(0x1a2)]+_0x30fd76(0x12a),{'method':_0x30fd76(0x161),'headers':_0x478e7b,'body':JSON['stringify']({'jsonrpc':'2.0','id':Date[_0x30fd76(0x15b)](),'method':_0x30fd76(0x165),'params':{'name':_0x55e918,'arguments':_0xfedba2}})}))[_0x30fd76(0x13f)](),_0x15033b=_0x29ca03[_0x30fd76(0x17b)](/data: (.+)/),_0x564cba=_0x15033b?JSON[_0x30fd76(0x147)](_0x15033b[0x1]):JSON['parse'](_0x29ca03),_0x32fd60=_0x564cba?.[_0x30fd76(0x15f)]?.[_0x30fd76(0x19a)]?.[0x0]?.[_0x30fd76(0x13f)];return _0x32fd60?JSON['parse'](_0x32fd60):_0x564cba;}async[a0_0x3628a8(0x153)](){const _0x1c22bf=a0_0x3628a8;if(this[_0x1c22bf(0x135)])return;this['running']=!0x0,await this['status'](_0x1c22bf(0x12c)),this['log'](_0x1c22bf(0x192)),this[_0x1c22bf(0x188)]=setInterval(()=>{const _0x433ac0=_0x1c22bf;this[_0x433ac0(0x18c)](_0x433ac0(0x12c))[_0x433ac0(0x133)](_0x26bbe3=>this[_0x433ac0(0x199)](_0x433ac0(0x169)+_0x26bbe3[_0x433ac0(0x142)]));},this[_0x1c22bf(0x18d)]),this[_0x1c22bf(0x175)]();}async[a0_0x3628a8(0x178)](){const _0x4059ab=a0_0x3628a8;if(this[_0x4059ab(0x135)]=!0x1,this[_0x4059ab(0x15c)]?.[_0x4059ab(0x14b)](),this[_0x4059ab(0x188)])clearInterval(this[_0x4059ab(0x188)]);await this[_0x4059ab(0x18c)]('offline')[_0x4059ab(0x133)](()=>{}),this[_0x4059ab(0x199)]('disconnected');}async[a0_0x3628a8(0x130)](_0x270c37,_0x3fd25d,_0x2eb98e=a0_0x3628a8(0x160)){const _0x54c92f=a0_0x3628a8;return Y({'alias':_0x270c37,'fromAlias':this[_0x54c92f(0x146)]},{'log':_0x41a0c2=>console['log'](_0x41a0c2),'send':()=>this[_0x54c92f(0x155)](_0x54c92f(0x1a5),{'alias':_0x270c37,'task':_0x3fd25d,'priority':_0x2eb98e,'from_session':this['alias']})});}async[a0_0x3628a8(0x142)](_0xaf02ec,_0x53bb50){const _0x5de84b=a0_0x3628a8;return this[_0x5de84b(0x155)](_0x5de84b(0x186),{'alias':_0xaf02ec,'message':_0x53bb50,'from_session':this[_0x5de84b(0x146)]});}async[a0_0x3628a8(0x1a4)](_0x208860,_0x25e517,_0x445f75=a0_0x3628a8(0x197)){const _0x1279c9=a0_0x3628a8;return this[_0x1279c9(0x155)]('send_reply',{'in_reply_to':_0x208860,'text':_0x25e517,'status':_0x445f75});}async['status'](_0x37e6e5,_0x337ad4){const _0x1569e0=a0_0x3628a8;return this[_0x1569e0(0x155)](_0x1569e0(0x17c),{'resume_id':this['resumeId'],'alias':this[_0x1569e0(0x146)],'status':_0x37e6e5,'server':a0_0x4846f8(),'hostname':a0_0x4846f8(),'agent':this[_0x1569e0(0x1a6)],'project_dir':process[_0x1569e0(0x12e)](),..._0x337ad4});}async['getAllStatus'](){const _0x323f3c=a0_0x3628a8;return this[_0x323f3c(0x155)](_0x323f3c(0x16e),{});}async[a0_0x3628a8(0x14d)](_0x54796f,_0x19d543){const _0x470134=a0_0x3628a8;return this[_0x470134(0x155)]('broadcast',{'message':_0x54796f,'filter_server':_0x19d543?.[_0x470134(0x170)],'filter_status':_0x19d543?.[_0x470134(0x18c)]});}async[a0_0x3628a8(0x175)](){const _0xdf9357=a0_0x3628a8;let _0x1da926=encodeURIComponent(this[_0xdf9357(0x146)]),_0x51570d=this[_0xdf9357(0x1a2)]+_0xdf9357(0x193)+_0x1da926,_0x18e7fc=this[_0xdf9357(0x19f)];while(this[_0xdf9357(0x135)]){try{this['sseAbort']=new AbortController();let _0x352002={'Accept':_0xdf9357(0x143)};if(this[_0xdf9357(0x150)])_0x352002['Authorization']=_0xdf9357(0x17a)+this[_0xdf9357(0x150)];let _0xa91b49=await fetch(_0x51570d,{'headers':_0x352002,'signal':this[_0xdf9357(0x15c)][_0xdf9357(0x154)]});if(!_0xa91b49['ok']||!_0xa91b49[_0xdf9357(0x182)]){this[_0xdf9357(0x199)]('SSE\x20failed:\x20'+_0xa91b49[_0xdf9357(0x18c)]),await this[_0xdf9357(0x15a)](_0x18e7fc),_0x18e7fc=Math[_0xdf9357(0x179)](_0x18e7fc*1.5,0xea60);continue;}_0x18e7fc=this[_0xdf9357(0x19f)];let _0x5501bd=_0xa91b49['body'][_0xdf9357(0x12f)](),_0xcbdb56=new TextDecoder(),_0x2f9882='';while(this[_0xdf9357(0x135)]){let {done:_0x22f34a,value:_0x307b31}=await _0x5501bd[_0xdf9357(0x13b)]();if(_0x22f34a)break;_0x2f9882+=_0xcbdb56['decode'](_0x307b31,{'stream':!0x0});let _0x57628c=_0x2f9882[_0xdf9357(0x15e)]('\x0a');_0x2f9882=_0x57628c[_0xdf9357(0x176)]()||'';for(let _0x27d0d6 of _0x57628c){if(!_0x27d0d6[_0xdf9357(0x144)](_0xdf9357(0x18b)))continue;try{let _0x1572df=JSON['parse'](_0x27d0d6[_0xdf9357(0x134)](0x6));if(_0x1572df['type']===_0xdf9357(0x184)){this[_0xdf9357(0x199)](_0xdf9357(0x128)),this[_0xdf9357(0x19b)](_0xdf9357(0x184));continue;}if(_0x1572df[_0xdf9357(0x191)]===_0xdf9357(0x183)||_0x1572df['type']===_0xdf9357(0x132)||_0x1572df[_0xdf9357(0x191)]===_0xdf9357(0x14d))await this['processInbox']();}catch{}}}}catch(_0x1c09ff){if(_0x1c09ff[_0xdf9357(0x190)]==='AbortError')break;this[_0xdf9357(0x19b)](_0xdf9357(0x152),_0x1c09ff),this[_0xdf9357(0x199)]('SSE\x20error:\x20'+_0x1c09ff[_0xdf9357(0x142)]);}if(this['running'])this[_0xdf9357(0x19b)](_0xdf9357(0x131)),this[_0xdf9357(0x199)](_0xdf9357(0x14c)+_0x18e7fc/0x3e8+_0xdf9357(0x149)),await this['sleep'](_0x18e7fc),_0x18e7fc=Math[_0xdf9357(0x179)](_0x18e7fc*1.5,0xea60);}}async[a0_0x3628a8(0x162)](){const _0x3d7691=a0_0x3628a8;try{let _0x323eed=(await this['call'](_0x3d7691(0x156),{'alias':this[_0x3d7691(0x146)],'limit':0xa}))?.['messages']||[];for(let _0x4f66f9 of _0x323eed)await this[_0x3d7691(0x155)](_0x3d7691(0x18f),{'alias':this['alias'],'message_id':_0x4f66f9['id']}),this['log']('←\x20'+_0x4f66f9[_0x3d7691(0x17e)]+':\x20'+_0x4f66f9[_0x3d7691(0x19a)][_0x3d7691(0x134)](0x0,0x3c)),this[_0x3d7691(0x19b)](_0x3d7691(0x18e),_0x4f66f9),this[_0x3d7691(0x19b)](_0x3d7691(0x142),_0x4f66f9);}catch(_0xbc58fe){this[_0x3d7691(0x199)](_0x3d7691(0x159)+_0xbc58fe[_0x3d7691(0x142)]);}}[a0_0x3628a8(0x15a)](_0x152e0c){return new Promise(_0x103ae6=>setTimeout(_0x103ae6,_0x152e0c));}}var F=$;export{F as default,$ as CommHub};