@sleep2agi/agent-network 2.3.0-preview.195 → 2.3.0-preview.196

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_0xfef4bc=a0_0x5475;(function(_0x1a28b1,_0x3a6af2){const _0x2ec90b=a0_0x5475,_0x536a5e=_0x1a28b1();while(!![]){try{const _0x7e8920=parseInt(_0x2ec90b(0x23b))/0x1+parseInt(_0x2ec90b(0x21d))/0x2+parseInt(_0x2ec90b(0x1cc))/0x3+-parseInt(_0x2ec90b(0x1c7))/0x4*(parseInt(_0x2ec90b(0x204))/0x5)+parseInt(_0x2ec90b(0x23e))/0x6+-parseInt(_0x2ec90b(0x237))/0x7*(-parseInt(_0x2ec90b(0x1df))/0x8)+parseInt(_0x2ec90b(0x229))/0x9*(-parseInt(_0x2ec90b(0x1f3))/0xa);if(_0x7e8920===_0x3a6af2)break;else _0x536a5e['push'](_0x536a5e['shift']());}catch(_0xb4dd4c){_0x536a5e['push'](_0x536a5e['shift']());}}}(a0_0x1c3b,0x3f0e1));import{EventEmitter as a0_0xde8ec0}from'events';import{hostname as a0_0x42df73}from'os';function a0_0x5475(_0x1b4f75,_0x25df6c){_0x1b4f75=_0x1b4f75-0x1c4;const _0x1c3bf4=a0_0x1c3b();let _0x5475c5=_0x1c3bf4[_0x1b4f75];return _0x5475c5;}function a0_0x1c3b(){const _0x526ca9=['emit','task.send.delivered','task.ack','<pending>','CommHub\x20response\x20omitted\x20task_id','pop','inbox\x20error:\x20','match','send_failed','string','offline','CommHub\x20rejected\x20task','867192OmJjQJ','s...','idle','toString','sdk-','connectSSE','SSE\x20reconnecting\x20in\x20','toAlias',']\x20[commhub:','stringify','processInbox','send','1012302wbWzoI','\x20parent_task_id=','[commhub:task]\x20','send_reply','sseAbort','send_message','broadcast','connect','report_status','url','error_code','get_inbox','completed','agent','258293NitWhv','2.0','disconnected','unknown\x20error','332475wQxcHQ','get_all_status','new_message','2149638PZMcMx','parent_task_id','split','log','getReader','messages','from_session','disconnect','<unknown>','3100LGuPBD','text','server','sleep','sending','1176621awwWOv','/mcp','\x20to=','networkId','task.send.start','mcp_http','data:\x20','\x20lifecycle=','running','slice','task_id','tools/call','failed','heartbeatTimer','task.replied','heartbeatInterval','not_tracked','decode','\x20network_id=','8EtWnNK','<missing>','alias','to_alias','catch','call','type','task.expired','new_task','transport','\x20from=','Authorization','Bearer\x20','reply','missing_task_id','reconnectDelay','\x20error=','name','task','fromAlias','90LSzaSP','SSE\x20error:\x20','token','min','parentTaskId','from_alias','sdk','AbortError','\x20duration_ms=','read','now','application/json,\x20text/event-stream','send_task','network_id','/events/','message','resumeId','1825sfaBlC','getAllStatus','send_rejected','error','replace','content','startsWith','parse','lifecycleTracking','connected','task.send.failed','status','body'];a0_0x1c3b=function(){return _0x526ca9;};return a0_0x1c3b();}var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x18bfe9,_0x559dfa)=>(_0x18bfe9??_0x559dfa)[a0_0xfef4bc(0x208)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0xfef4bc(0x1d5)](0x0,0xf0);function N(_0x5937c6){const _0x5ef594=a0_0xfef4bc;return(_0x5937c6 instanceof Error?_0x5937c6['message']:String(_0x5937c6??_0x5ef594(0x23a)))['replace'](K,'[REDACTED]')[_0x5ef594(0x208)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x27487d,_0x375bae=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x5d6666=a0_0xfef4bc;if(_0x375bae)return JSON[_0x5d6666(0x226)](_0x27487d);let _0x351864=L(_0x27487d[_0x5d6666(0x23f)],_0x5d6666(0x1e0)),_0x20cb3e=L(_0x27487d['task_id'],_0x5d6666(0x214)),_0x4323e8=_0x27487d[_0x5d6666(0x233)]?_0x5d6666(0x1ef)+_0x27487d[_0x5d6666(0x233)]+':'+(_0x27487d['error_message']??''):'';return _0x5d6666(0x22b)+_0x27487d['status']+_0x5d6666(0x1e9)+L(_0x27487d[_0x5d6666(0x1f8)],_0x5d6666(0x1c6))+_0x5d6666(0x1ce)+L(_0x27487d[_0x5d6666(0x1e2)],_0x5d6666(0x1c6))+'\x20task_id='+_0x20cb3e+_0x5d6666(0x22a)+_0x351864+_0x5d6666(0x1de)+L(_0x27487d[_0x5d6666(0x200)],_0x5d6666(0x1c6))+'\x20transport='+_0x27487d[_0x5d6666(0x1e8)]+_0x5d6666(0x1fb)+_0x27487d['duration_ms']+_0x5d6666(0x1d3)+_0x27487d['lifecycle_tracking']+_0x4323e8;}function U(_0x2570f5){const _0x2eddf2=a0_0xfef4bc;return{'event':{'sending':_0x2eddf2(0x1d0),'delivered':_0x2eddf2(0x212),'failed':_0x2eddf2(0x20e),'acked':_0x2eddf2(0x213),'started':'task.started','replied':_0x2eddf2(0x1da),'expired':_0x2eddf2(0x1e6)}[_0x2570f5[_0x2eddf2(0x20f)]],..._0x2570f5};}function j(_0x1b965c){const _0x5122e5=a0_0xfef4bc;let _0x423f6f=_0x1b965c?.[_0x5122e5(0x1d6)]||_0x1b965c?.['message_id']||_0x1b965c?.['id'];if(_0x423f6f)return String(_0x423f6f);let _0x3ddfcb=_0x1b965c?.['content']?.[0x0]?.[_0x5122e5(0x1c8)];if(typeof _0x3ddfcb!==_0x5122e5(0x21a))return null;try{let _0x487417=JSON[_0x5122e5(0x20b)](_0x3ddfcb);return _0x487417?.['task_id']||_0x487417?.['message_id']||_0x487417?.['id']||null;}catch{return null;}}async function X(_0x58d8c8,_0xf81b11){const _0x43f3e0=a0_0xfef4bc;let _0x2be187=_0xf81b11['now']??Date['now'],_0x103485=_0x2be187(),_0x1866ff=(_0xc2036c,_0x56a6aa,_0x28d710,_0x51f71e)=>{const _0x29af13=a0_0x5475;_0xf81b11[_0x29af13(0x241)](O(U({'from_alias':_0x58d8c8[_0x29af13(0x1f2)],'to_alias':_0x58d8c8[_0x29af13(0x224)],'task_id':_0x56a6aa,'parent_task_id':_0x58d8c8[_0x29af13(0x1f7)],'network_id':_0x58d8c8['networkId'],'transport':_0x58d8c8['transport'],'status':_0xc2036c,'duration_ms':_0x2be187()-_0x103485,'lifecycle_tracking':_0x58d8c8[_0x29af13(0x20c)],..._0x28d710!==void 0x0?{'error_code':_0x51f71e||_0x29af13(0x219),'error_message':N(_0x28d710)}:{}})));};_0x1866ff(_0x43f3e0(0x1cb),null);try{let _0x4bc2ea=await _0xf81b11[_0x43f3e0(0x228)](),_0x4bf325=j(_0x4bc2ea);if(_0x4bf325)_0x1866ff('delivered',_0x4bf325);else{if(_0x4bc2ea?.['ok']===!0x1||_0x4bc2ea?.[_0x43f3e0(0x207)])_0x1866ff(_0x43f3e0(0x1d8),_0x4bf325,_0x4bc2ea?.[_0x43f3e0(0x207)]||_0x43f3e0(0x21c),_0x43f3e0(0x206));else _0x1866ff(_0x43f3e0(0x1d8),null,_0x43f3e0(0x215),_0x43f3e0(0x1ed));}return _0x4bc2ea;}catch(_0x2e67ed){throw _0x1866ff(_0x43f3e0(0x1d8),null,_0x2e67ed,'send_failed'),_0x2e67ed;}}async function Y(_0x2d0fc3,_0x50dda4){const _0x439e4c=a0_0xfef4bc;return X({'fromAlias':_0x2d0fc3[_0x439e4c(0x1f2)],'toAlias':_0x2d0fc3[_0x439e4c(0x1e1)],'parentTaskId':_0x2d0fc3[_0x439e4c(0x1f7)]||null,'networkId':_0x2d0fc3[_0x439e4c(0x1cf)]||null,'transport':_0x439e4c(0x1d1),'lifecycleTracking':_0x439e4c(0x1dc)},_0x50dda4);}class $ extends a0_0xde8ec0{[a0_0xfef4bc(0x232)];[a0_0xfef4bc(0x1e1)];[a0_0xfef4bc(0x1f5)];['agent'];[a0_0xfef4bc(0x203)];['heartbeatInterval'];['reconnectDelay'];[a0_0xfef4bc(0x1d9)];[a0_0xfef4bc(0x22d)];['running']=!0x1;constructor(_0x20c1ef){const _0x44fe25=a0_0xfef4bc;super();if(this[_0x44fe25(0x232)]=_0x20c1ef[_0x44fe25(0x232)][_0x44fe25(0x208)](/\/$/,''),this[_0x44fe25(0x1e1)]=_0x20c1ef[_0x44fe25(0x1e1)],this[_0x44fe25(0x1f5)]=_0x20c1ef[_0x44fe25(0x1f5)],this[_0x44fe25(0x236)]=_0x20c1ef[_0x44fe25(0x236)]||_0x44fe25(0x1f9),this[_0x44fe25(0x203)]=_0x44fe25(0x221)+_0x20c1ef[_0x44fe25(0x1e1)]+'-'+Date[_0x44fe25(0x1fd)]()[_0x44fe25(0x220)](0x24),this[_0x44fe25(0x1db)]=_0x20c1ef[_0x44fe25(0x1db)]??0x2bf20,this[_0x44fe25(0x1ee)]=_0x20c1ef[_0x44fe25(0x1ee)]??0xbb8,_0x20c1ef['autoConnect']!==!0x1)this[_0x44fe25(0x230)]();}[a0_0xfef4bc(0x241)](_0xaa5b68){const _0x4104dc=a0_0xfef4bc;console[_0x4104dc(0x241)]('['+new Date()['toTimeString']()[_0x4104dc(0x1d5)](0x0,0x8)+_0x4104dc(0x225)+this[_0x4104dc(0x1e1)]+']\x20'+_0xaa5b68);}async[a0_0xfef4bc(0x1e4)](_0x5d6d20,_0x4bd500){const _0x168a54=a0_0xfef4bc;let _0x1c7ca9={'Content-Type':'application/json','Accept':_0x168a54(0x1fe)};if(this['token'])_0x1c7ca9[_0x168a54(0x1ea)]='Bearer\x20'+this[_0x168a54(0x1f5)];let _0x2e25b3=await(await fetch(this[_0x168a54(0x232)]+_0x168a54(0x1cd),{'method':'POST','headers':_0x1c7ca9,'body':JSON[_0x168a54(0x226)]({'jsonrpc':_0x168a54(0x238),'id':Date[_0x168a54(0x1fd)](),'method':_0x168a54(0x1d7),'params':{'name':_0x5d6d20,'arguments':_0x4bd500}})}))[_0x168a54(0x1c8)](),_0x333443=_0x2e25b3[_0x168a54(0x218)](/data: (.+)/),_0x1bddba=_0x333443?JSON[_0x168a54(0x20b)](_0x333443[0x1]):JSON[_0x168a54(0x20b)](_0x2e25b3),_0x2deae6=_0x1bddba?.['result']?.['content']?.[0x0]?.[_0x168a54(0x1c8)];return _0x2deae6?JSON[_0x168a54(0x20b)](_0x2deae6):_0x1bddba;}async[a0_0xfef4bc(0x230)](){const _0x2eb155=a0_0xfef4bc;if(this[_0x2eb155(0x1d4)])return;this[_0x2eb155(0x1d4)]=!0x0,await this['status'](_0x2eb155(0x21f)),this['log']('registered'),this['heartbeatTimer']=setInterval(()=>{const _0x31f2b8=_0x2eb155;this['status'](_0x31f2b8(0x21f))[_0x31f2b8(0x1e3)](_0x11e4aa=>this[_0x31f2b8(0x241)]('heartbeat\x20failed:\x20'+_0x11e4aa[_0x31f2b8(0x202)]));},this[_0x2eb155(0x1db)]),this['connectSSE']();}async[a0_0xfef4bc(0x1c5)](){const _0x4c473a=a0_0xfef4bc;if(this[_0x4c473a(0x1d4)]=!0x1,this[_0x4c473a(0x22d)]?.['abort'](),this[_0x4c473a(0x1d9)])clearInterval(this[_0x4c473a(0x1d9)]);await this[_0x4c473a(0x20f)](_0x4c473a(0x21b))[_0x4c473a(0x1e3)](()=>{}),this[_0x4c473a(0x241)](_0x4c473a(0x239));}async[a0_0xfef4bc(0x228)](_0x405ce1,_0x39f4bf,_0x9c4ecd='normal'){const _0x3701f1=a0_0xfef4bc;return Y({'alias':_0x405ce1,'fromAlias':this[_0x3701f1(0x1e1)]},{'log':_0x55323c=>console[_0x3701f1(0x241)](_0x55323c),'send':()=>this[_0x3701f1(0x1e4)](_0x3701f1(0x1ff),{'alias':_0x405ce1,'task':_0x39f4bf,'priority':_0x9c4ecd,'from_session':this[_0x3701f1(0x1e1)]})});}async[a0_0xfef4bc(0x202)](_0x1c97e2,_0xd4a863){const _0xa9b3f6=a0_0xfef4bc;return this[_0xa9b3f6(0x1e4)](_0xa9b3f6(0x22e),{'alias':_0x1c97e2,'message':_0xd4a863,'from_session':this[_0xa9b3f6(0x1e1)]});}async[a0_0xfef4bc(0x1ec)](_0x1e3b27,_0x254526,_0x22b286=a0_0xfef4bc(0x235)){const _0x3bb55a=a0_0xfef4bc;return this['call'](_0x3bb55a(0x22c),{'in_reply_to':_0x1e3b27,'text':_0x254526,'status':_0x22b286});}async[a0_0xfef4bc(0x20f)](_0x5ef7ff,_0x4bbf98){const _0x4e2a82=a0_0xfef4bc;return this[_0x4e2a82(0x1e4)](_0x4e2a82(0x231),{'resume_id':this['resumeId'],'alias':this[_0x4e2a82(0x1e1)],'status':_0x5ef7ff,'server':a0_0x42df73(),'hostname':a0_0x42df73(),'agent':this['agent'],'project_dir':process['cwd'](),..._0x4bbf98});}async[a0_0xfef4bc(0x205)](){const _0xc91328=a0_0xfef4bc;return this[_0xc91328(0x1e4)](_0xc91328(0x23c),{});}async[a0_0xfef4bc(0x22f)](_0x5e485b,_0x2adaf4){const _0x12ef6b=a0_0xfef4bc;return this['call'](_0x12ef6b(0x22f),{'message':_0x5e485b,'filter_server':_0x2adaf4?.[_0x12ef6b(0x1c9)],'filter_status':_0x2adaf4?.[_0x12ef6b(0x20f)]});}async[a0_0xfef4bc(0x222)](){const _0x1f4c2f=a0_0xfef4bc;let _0x376a9c=encodeURIComponent(this[_0x1f4c2f(0x1e1)]),_0x586f4f=this[_0x1f4c2f(0x232)]+_0x1f4c2f(0x201)+_0x376a9c,_0x1dcb88=this[_0x1f4c2f(0x1ee)];while(this[_0x1f4c2f(0x1d4)]){try{this['sseAbort']=new AbortController();let _0x57c3b0={'Accept':'text/event-stream'};if(this[_0x1f4c2f(0x1f5)])_0x57c3b0['Authorization']=_0x1f4c2f(0x1eb)+this['token'];let _0x1f79fa=await fetch(_0x586f4f,{'headers':_0x57c3b0,'signal':this[_0x1f4c2f(0x22d)]['signal']});if(!_0x1f79fa['ok']||!_0x1f79fa[_0x1f4c2f(0x210)]){this[_0x1f4c2f(0x241)]('SSE\x20failed:\x20'+_0x1f79fa[_0x1f4c2f(0x20f)]),await this[_0x1f4c2f(0x1ca)](_0x1dcb88),_0x1dcb88=Math[_0x1f4c2f(0x1f6)](_0x1dcb88*1.5,0xea60);continue;}_0x1dcb88=this['reconnectDelay'];let _0xdf44ba=_0x1f79fa[_0x1f4c2f(0x210)][_0x1f4c2f(0x242)](),_0x262c9c=new TextDecoder(),_0x2ec388='';while(this['running']){let {done:_0x115797,value:_0x5848ed}=await _0xdf44ba[_0x1f4c2f(0x1fc)]();if(_0x115797)break;_0x2ec388+=_0x262c9c[_0x1f4c2f(0x1dd)](_0x5848ed,{'stream':!0x0});let _0x137d35=_0x2ec388[_0x1f4c2f(0x240)]('\x0a');_0x2ec388=_0x137d35[_0x1f4c2f(0x216)]()||'';for(let _0x37ff23 of _0x137d35){if(!_0x37ff23[_0x1f4c2f(0x20a)](_0x1f4c2f(0x1d2)))continue;try{let _0x2a17dd=JSON[_0x1f4c2f(0x20b)](_0x37ff23['slice'](0x6));if(_0x2a17dd[_0x1f4c2f(0x1e5)]==='connected'){this['log']('SSE\x20connected'),this[_0x1f4c2f(0x211)](_0x1f4c2f(0x20d));continue;}if(_0x2a17dd[_0x1f4c2f(0x1e5)]===_0x1f4c2f(0x1e7)||_0x2a17dd[_0x1f4c2f(0x1e5)]===_0x1f4c2f(0x23d)||_0x2a17dd[_0x1f4c2f(0x1e5)]===_0x1f4c2f(0x22f))await this[_0x1f4c2f(0x227)]();}catch{}}}}catch(_0x576c6c){if(_0x576c6c[_0x1f4c2f(0x1f0)]===_0x1f4c2f(0x1fa))break;this[_0x1f4c2f(0x211)](_0x1f4c2f(0x207),_0x576c6c),this[_0x1f4c2f(0x241)](_0x1f4c2f(0x1f4)+_0x576c6c[_0x1f4c2f(0x202)]);}if(this['running'])this[_0x1f4c2f(0x211)]('disconnected'),this['log'](_0x1f4c2f(0x223)+_0x1dcb88/0x3e8+_0x1f4c2f(0x21e)),await this[_0x1f4c2f(0x1ca)](_0x1dcb88),_0x1dcb88=Math['min'](_0x1dcb88*1.5,0xea60);}}async['processInbox'](){const _0x327ce0=a0_0xfef4bc;try{let _0x1c6206=(await this[_0x327ce0(0x1e4)](_0x327ce0(0x234),{'alias':this[_0x327ce0(0x1e1)],'limit':0xa}))?.[_0x327ce0(0x243)]||[];for(let _0x2450e3 of _0x1c6206)await this['call']('ack_inbox',{'alias':this['alias'],'message_id':_0x2450e3['id']}),this['log']('←\x20'+_0x2450e3[_0x327ce0(0x1c4)]+':\x20'+_0x2450e3[_0x327ce0(0x209)][_0x327ce0(0x1d5)](0x0,0x3c)),this[_0x327ce0(0x211)](_0x327ce0(0x1f1),_0x2450e3),this[_0x327ce0(0x211)]('message',_0x2450e3);}catch(_0x3f07ec){this[_0x327ce0(0x241)](_0x327ce0(0x217)+_0x3f07ec['message']);}}['sleep'](_0x1b9c27){return new Promise(_0x3d3566=>setTimeout(_0x3d3566,_0x1b9c27));}}var F=$;export{F as default,$ as CommHub};
1
+ const a0_0x131053=a0_0x1098;(function(_0x17dcea,_0xa95950){const _0x100bb0=a0_0x1098,_0x318faa=_0x17dcea();while(!![]){try{const _0x569b56=parseInt(_0x100bb0(0xc0))/0x1+-parseInt(_0x100bb0(0xdc))/0x2+parseInt(_0x100bb0(0x92))/0x3*(parseInt(_0x100bb0(0x87))/0x4)+-parseInt(_0x100bb0(0xa7))/0x5+-parseInt(_0x100bb0(0xce))/0x6*(-parseInt(_0x100bb0(0xdd))/0x7)+parseInt(_0x100bb0(0x79))/0x8*(parseInt(_0x100bb0(0xbe))/0x9)+-parseInt(_0x100bb0(0x6f))/0xa*(parseInt(_0x100bb0(0x90))/0xb);if(_0x569b56===_0xa95950)break;else _0x318faa['push'](_0x318faa['shift']());}catch(_0x1a5c67){_0x318faa['push'](_0x318faa['shift']());}}}(a0_0x5434,0x89947));import{EventEmitter as a0_0x126b01}from'events';import{hostname as a0_0x170346}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x43e548,_0x2f1dca)=>(_0x43e548??_0x2f1dca)[a0_0x131053(0xd5)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x131053(0xe1)](0x0,0xf0);function N(_0x122f00){const _0x1cc8c1=a0_0x131053;return(_0x122f00 instanceof Error?_0x122f00[_0x1cc8c1(0xa0)]:String(_0x122f00??'unknown\x20error'))[_0x1cc8c1(0xd5)](K,_0x1cc8c1(0x78))[_0x1cc8c1(0xd5)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x41e4e8,_0x5862f8=process.env.ANET_TASK_TRACE_FORMAT===a0_0x131053(0xca)){const _0x15e16f=a0_0x131053;if(_0x5862f8)return JSON[_0x15e16f(0x6b)](_0x41e4e8);let _0x1ed113=L(_0x41e4e8[_0x15e16f(0xa9)],'<missing>'),_0x4663d4=L(_0x41e4e8[_0x15e16f(0x9c)],'<pending>'),_0x1fc182=_0x41e4e8[_0x15e16f(0xe4)]?_0x15e16f(0xdf)+_0x41e4e8[_0x15e16f(0xe4)]+':'+(_0x41e4e8[_0x15e16f(0xb5)]??''):'';return _0x15e16f(0x67)+_0x41e4e8['status']+_0x15e16f(0x9f)+L(_0x41e4e8[_0x15e16f(0xd2)],'<unknown>')+'\x20to='+L(_0x41e4e8[_0x15e16f(0xa3)],_0x15e16f(0x98))+_0x15e16f(0xd4)+_0x4663d4+_0x15e16f(0x8e)+_0x1ed113+_0x15e16f(0xeb)+L(_0x41e4e8[_0x15e16f(0xc4)],_0x15e16f(0x98))+_0x15e16f(0x9a)+_0x41e4e8[_0x15e16f(0x77)]+'\x20duration_ms='+_0x41e4e8[_0x15e16f(0x91)]+_0x15e16f(0xda)+_0x41e4e8['lifecycle_tracking']+_0x1fc182;}function U(_0x14817a){const _0x273003=a0_0x131053;return{'event':{'sending':_0x273003(0xb9),'delivered':_0x273003(0xe9),'failed':_0x273003(0xc5),'acked':'task.ack','started':_0x273003(0x7f),'replied':_0x273003(0xa5),'expired':'task.expired'}[_0x14817a[_0x273003(0x93)]],..._0x14817a};}function a0_0x1098(_0x2c5948,_0x105b3e){_0x2c5948=_0x2c5948-0x66;const _0x543434=a0_0x5434();let _0x10988f=_0x543434[_0x2c5948];return _0x10988f;}function j(_0x549065){const _0x2427cf=a0_0x131053;let _0x557789=_0x549065?.[_0x2427cf(0x9c)]||_0x549065?.[_0x2427cf(0xbc)]||_0x549065?.['id'];if(_0x557789)return String(_0x557789);let _0x498e6b=_0x549065?.[_0x2427cf(0x74)]?.[0x0]?.['text'];if(typeof _0x498e6b!==_0x2427cf(0x76))return null;try{let _0x2ce0bb=JSON[_0x2427cf(0xdb)](_0x498e6b);return _0x2ce0bb?.['task_id']||_0x2ce0bb?.['message_id']||_0x2ce0bb?.['id']||null;}catch{return null;}}async function X(_0x25fb76,_0x2fd261){const _0x4dc00c=a0_0x131053;let _0x303bfb=_0x2fd261[_0x4dc00c(0xac)]??Date[_0x4dc00c(0xac)],_0x206b10=_0x303bfb(),_0x2b50eb=(_0x54d11f,_0x4effcc,_0x10d946,_0x4ea798)=>{const _0x40cb53=_0x4dc00c;_0x2fd261[_0x40cb53(0x83)](O(U({'from_alias':_0x25fb76[_0x40cb53(0xad)],'to_alias':_0x25fb76[_0x40cb53(0x7c)],'task_id':_0x4effcc,'parent_task_id':_0x25fb76[_0x40cb53(0xd0)],'network_id':_0x25fb76['networkId'],'transport':_0x25fb76[_0x40cb53(0x77)],'status':_0x54d11f,'duration_ms':_0x303bfb()-_0x206b10,'lifecycle_tracking':_0x25fb76[_0x40cb53(0x7e)],..._0x10d946!==void 0x0?{'error_code':_0x4ea798||_0x40cb53(0x81),'error_message':N(_0x10d946)}:{}})));};_0x2b50eb('sending',null);try{let _0x3dc61a=await _0x2fd261[_0x4dc00c(0xb8)](),_0x306b1e=j(_0x3dc61a);if(_0x306b1e)_0x2b50eb(_0x4dc00c(0xde),_0x306b1e);else{if(_0x3dc61a?.['ok']===!0x1||_0x3dc61a?.[_0x4dc00c(0xb2)])_0x2b50eb(_0x4dc00c(0xc9),_0x306b1e,_0x3dc61a?.[_0x4dc00c(0xb2)]||_0x4dc00c(0x68),'send_rejected');else _0x2b50eb(_0x4dc00c(0xc9),null,_0x4dc00c(0x7a),_0x4dc00c(0xe5));}return _0x3dc61a;}catch(_0x34a1bc){throw _0x2b50eb(_0x4dc00c(0xc9),null,_0x34a1bc,'send_failed'),_0x34a1bc;}}async function Y(_0x1c2798,_0x44c7e6){const _0x1cc55f=a0_0x131053;return X({'fromAlias':_0x1c2798['fromAlias'],'toAlias':_0x1c2798[_0x1cc55f(0xcf)],'parentTaskId':_0x1c2798[_0x1cc55f(0xd0)]||null,'networkId':_0x1c2798[_0x1cc55f(0xc7)]||null,'transport':_0x1cc55f(0xa1),'lifecycleTracking':'not_tracked'},_0x44c7e6);}class $ extends a0_0x126b01{[a0_0x131053(0x89)];[a0_0x131053(0xcf)];[a0_0x131053(0xc3)];[a0_0x131053(0xaa)];[a0_0x131053(0xe2)];['heartbeatInterval'];['reconnectDelay'];['heartbeatTimer'];[a0_0x131053(0xe7)];[a0_0x131053(0x8f)]=!0x1;constructor(_0x3ef5d4){const _0x479478=a0_0x131053;super();if(this[_0x479478(0x89)]=_0x3ef5d4[_0x479478(0x89)][_0x479478(0xd5)](/\/$/,''),this[_0x479478(0xcf)]=_0x3ef5d4[_0x479478(0xcf)],this[_0x479478(0xc3)]=_0x3ef5d4[_0x479478(0xc3)],this['agent']=_0x3ef5d4[_0x479478(0xaa)]||_0x479478(0xb0),this['resumeId']=_0x479478(0xb6)+_0x3ef5d4[_0x479478(0xcf)]+'-'+Date[_0x479478(0xac)]()['toString'](0x24),this[_0x479478(0x6a)]=_0x3ef5d4[_0x479478(0x6a)]??0x2bf20,this[_0x479478(0xe6)]=_0x3ef5d4['reconnectDelay']??0xbb8,_0x3ef5d4[_0x479478(0xd1)]!==!0x1)this[_0x479478(0x73)]();}[a0_0x131053(0x83)](_0x914e07){const _0x18d167=a0_0x131053;console['log']('['+new Date()[_0x18d167(0x75)]()['slice'](0x0,0x8)+_0x18d167(0xba)+this['alias']+']\x20'+_0x914e07);}async['call'](_0x60e110,_0x457987){const _0x5f10bb=a0_0x131053;let _0x558e44={'Content-Type':_0x5f10bb(0x69),'Accept':_0x5f10bb(0x80)};if(this[_0x5f10bb(0xc3)])_0x558e44[_0x5f10bb(0x8c)]=_0x5f10bb(0x71)+this[_0x5f10bb(0xc3)];let _0x5280f0=await(await fetch(this['url']+'/mcp',{'method':_0x5f10bb(0x9e),'headers':_0x558e44,'body':JSON[_0x5f10bb(0x6b)]({'jsonrpc':_0x5f10bb(0x82),'id':Date[_0x5f10bb(0xac)](),'method':_0x5f10bb(0xb1),'params':{'name':_0x60e110,'arguments':_0x457987}})}))[_0x5f10bb(0x96)](),_0x29ddb1=_0x5280f0['match'](/data: (.+)/),_0x2abf4d=_0x29ddb1?JSON[_0x5f10bb(0xdb)](_0x29ddb1[0x1]):JSON['parse'](_0x5280f0),_0x555656=_0x2abf4d?.[_0x5f10bb(0xa8)]?.[_0x5f10bb(0x74)]?.[0x0]?.['text'];return _0x555656?JSON[_0x5f10bb(0xdb)](_0x555656):_0x2abf4d;}async[a0_0x131053(0x73)](){const _0x326458=a0_0x131053;if(this[_0x326458(0x8f)])return;this[_0x326458(0x8f)]=!0x0,await this[_0x326458(0x93)](_0x326458(0xd8)),this['log'](_0x326458(0xbd)),this[_0x326458(0x99)]=setInterval(()=>{const _0x120058=_0x326458;this[_0x120058(0x93)](_0x120058(0xd8))[_0x120058(0x85)](_0x563fdb=>this[_0x120058(0x83)](_0x120058(0xb4)+_0x563fdb['message']));},this['heartbeatInterval']),this[_0x326458(0x94)]();}async['disconnect'](){const _0x569a1b=a0_0x131053;if(this['running']=!0x1,this[_0x569a1b(0xe7)]?.['abort'](),this[_0x569a1b(0x99)])clearInterval(this[_0x569a1b(0x99)]);await this[_0x569a1b(0x93)]('offline')[_0x569a1b(0x85)](()=>{}),this[_0x569a1b(0x83)]('disconnected');}async['send'](_0x1dcced,_0x314e3f,_0x28a308=a0_0x131053(0xb3)){const _0x446ac7=a0_0x131053;return Y({'alias':_0x1dcced,'fromAlias':this[_0x446ac7(0xcf)]},{'log':_0x4829f1=>console['log'](_0x4829f1),'send':()=>this[_0x446ac7(0xd7)](_0x446ac7(0xc2),{'alias':_0x1dcced,'task':_0x314e3f,'priority':_0x28a308,'from_session':this[_0x446ac7(0xcf)]})});}async[a0_0x131053(0xa0)](_0xe2721d,_0x32cd7a){const _0x533a55=a0_0x131053;return this[_0x533a55(0xd7)](_0x533a55(0xbf),{'alias':_0xe2721d,'message':_0x32cd7a,'from_session':this['alias']});}async[a0_0x131053(0xa6)](_0x1a5e3e,_0x1fc094,_0x5ba399=a0_0x131053(0x7d)){const _0x15d70e=a0_0x131053;return this[_0x15d70e(0xd7)](_0x15d70e(0xab),{'in_reply_to':_0x1a5e3e,'text':_0x1fc094,'status':_0x5ba399});}async[a0_0x131053(0x93)](_0x306b44,_0x3955c0){const _0x52d597=a0_0x131053;return this['call'](_0x52d597(0xaf),{'resume_id':this[_0x52d597(0xe2)],'alias':this[_0x52d597(0xcf)],'status':_0x306b44,'server':a0_0x170346(),'hostname':a0_0x170346(),'agent':this['agent'],'project_dir':process[_0x52d597(0x84)](),..._0x3955c0});}async[a0_0x131053(0xa4)](){const _0x14c276=a0_0x131053;return this[_0x14c276(0xd7)](_0x14c276(0xea),{});}async[a0_0x131053(0x8b)](_0x4c8ec2,_0x44fb4a){const _0x226111=a0_0x131053;return this[_0x226111(0xd7)](_0x226111(0x8b),{'message':_0x4c8ec2,'filter_server':_0x44fb4a?.[_0x226111(0xc8)],'filter_status':_0x44fb4a?.[_0x226111(0x93)]});}async[a0_0x131053(0x94)](){const _0x9a92a7=a0_0x131053;let _0x1f5cf2=encodeURIComponent(this[_0x9a92a7(0xcf)]),_0x3086b9=this[_0x9a92a7(0x89)]+'/events/'+_0x1f5cf2,_0x290acf=this[_0x9a92a7(0xe6)];while(this[_0x9a92a7(0x8f)]){try{this[_0x9a92a7(0xe7)]=new AbortController();let _0x595628={'Accept':_0x9a92a7(0x7b)};if(this['token'])_0x595628[_0x9a92a7(0x8c)]=_0x9a92a7(0x71)+this[_0x9a92a7(0xc3)];let _0x237c0d=await fetch(_0x3086b9,{'headers':_0x595628,'signal':this[_0x9a92a7(0xe7)][_0x9a92a7(0x95)]});if(!_0x237c0d['ok']||!_0x237c0d[_0x9a92a7(0x9b)]){this[_0x9a92a7(0x83)]('SSE\x20failed:\x20'+_0x237c0d[_0x9a92a7(0x93)]),await this['sleep'](_0x290acf),_0x290acf=Math['min'](_0x290acf*1.5,0xea60);continue;}_0x290acf=this[_0x9a92a7(0xe6)];let _0x39f983=_0x237c0d[_0x9a92a7(0x9b)][_0x9a92a7(0x97)](),_0x533ab7=new TextDecoder(),_0x3d9fb5='';while(this['running']){let {done:_0x304be0,value:_0x3bdb3f}=await _0x39f983[_0x9a92a7(0x6e)]();if(_0x304be0)break;_0x3d9fb5+=_0x533ab7[_0x9a92a7(0xd3)](_0x3bdb3f,{'stream':!0x0});let _0x3427f4=_0x3d9fb5[_0x9a92a7(0xcc)]('\x0a');_0x3d9fb5=_0x3427f4[_0x9a92a7(0xd9)]()||'';for(let _0x3051da of _0x3427f4){if(!_0x3051da[_0x9a92a7(0xb7)](_0x9a92a7(0x6d)))continue;try{let _0x1051c9=JSON[_0x9a92a7(0xdb)](_0x3051da[_0x9a92a7(0xe1)](0x6));if(_0x1051c9['type']===_0x9a92a7(0xe0)){this[_0x9a92a7(0x83)](_0x9a92a7(0xc6)),this[_0x9a92a7(0x66)](_0x9a92a7(0xe0));continue;}if(_0x1051c9[_0x9a92a7(0x72)]===_0x9a92a7(0x88)||_0x1051c9[_0x9a92a7(0x72)]===_0x9a92a7(0xe3)||_0x1051c9['type']==='broadcast')await this[_0x9a92a7(0x8a)]();}catch{}}}}catch(_0x577b5f){if(_0x577b5f[_0x9a92a7(0x86)]===_0x9a92a7(0xbb))break;this[_0x9a92a7(0x66)](_0x9a92a7(0xb2),_0x577b5f),this['log'](_0x9a92a7(0xcb)+_0x577b5f[_0x9a92a7(0xa0)]);}if(this[_0x9a92a7(0x8f)])this[_0x9a92a7(0x66)](_0x9a92a7(0x9d)),this[_0x9a92a7(0x83)](_0x9a92a7(0x8d)+_0x290acf/0x3e8+'s...'),await this['sleep'](_0x290acf),_0x290acf=Math[_0x9a92a7(0xe8)](_0x290acf*1.5,0xea60);}}async['processInbox'](){const _0x3da014=a0_0x131053;try{let _0x2786cf=(await this[_0x3da014(0xd7)](_0x3da014(0xd6),{'alias':this[_0x3da014(0xcf)],'limit':0xa}))?.[_0x3da014(0xa2)]||[];for(let _0x2b47c4 of _0x2786cf)await this['call'](_0x3da014(0xcd),{'alias':this['alias'],'message_id':_0x2b47c4['id']}),this[_0x3da014(0x83)]('←\x20'+_0x2b47c4[_0x3da014(0x70)]+':\x20'+_0x2b47c4[_0x3da014(0x74)]['slice'](0x0,0x3c)),this[_0x3da014(0x66)](_0x3da014(0xc1),_0x2b47c4),this['emit'](_0x3da014(0xa0),_0x2b47c4);}catch(_0x234d8a){this[_0x3da014(0x83)](_0x3da014(0xae)+_0x234d8a['message']);}}[a0_0x131053(0x6c)](_0xa6d516){return new Promise(_0x5a8fcc=>setTimeout(_0x5a8fcc,_0xa6d516));}}function a0_0x5434(){const _0x9a9c55=['now','fromAlias','inbox\x20error:\x20','report_status','sdk','tools/call','error','normal','heartbeat\x20failed:\x20','error_message','sdk-','startsWith','send','task.send.start',']\x20[commhub:','AbortError','message_id','registered','9eGQsdI','send_message','1088656qMOYhE','task','send_task','token','network_id','task.send.failed','SSE\x20connected','networkId','server','failed','json','SSE\x20error:\x20','split','ack_inbox','93234gGNgDP','alias','parentTaskId','autoConnect','from_alias','decode','\x20task_id=','replace','get_inbox','call','idle','pop','\x20lifecycle=','parse','698056tNikUg','14JiqflO','delivered','\x20error=','connected','slice','resumeId','new_message','error_code','missing_task_id','reconnectDelay','sseAbort','min','task.send.delivered','get_all_status','\x20network_id=','emit','[commhub:task]\x20','CommHub\x20rejected\x20task','application/json','heartbeatInterval','stringify','sleep','data:\x20','read','370490UyYIJV','from_session','Bearer\x20','type','connect','content','toTimeString','string','transport','[REDACTED]','1838552wmxBZD','CommHub\x20response\x20omitted\x20task_id','text/event-stream','toAlias','completed','lifecycleTracking','task.started','application/json,\x20text/event-stream','send_failed','2.0','log','cwd','catch','name','16ctHCQG','new_task','url','processInbox','broadcast','Authorization','SSE\x20reconnecting\x20in\x20','\x20parent_task_id=','running','341WdHYoO','duration_ms','791943iPkinl','status','connectSSE','signal','text','getReader','<unknown>','heartbeatTimer','\x20transport=','body','task_id','disconnected','POST','\x20from=','message','mcp_http','messages','to_alias','getAllStatus','task.replied','reply','1722015jflTGi','result','parent_task_id','agent','send_reply'];a0_0x5434=function(){return _0x9a9c55;};return a0_0x5434();}var F=$;export{F as default,$ as CommHub};