@sleep2agi/agent-network 2.3.0-preview.208 → 2.3.0-preview.209

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
- function a0_0x4ae5(_0x52b20f,_0x530752){_0x52b20f=_0x52b20f-0x1d0;const _0x596ab6=a0_0x596a();let _0x4ae560=_0x596ab6[_0x52b20f];return _0x4ae560;}const a0_0x96fcb5=a0_0x4ae5;(function(_0x2e6fbe,_0x15e532){const _0x54a8eb=a0_0x4ae5,_0x30edcb=_0x2e6fbe();while(!![]){try{const _0x9d0974=-parseInt(_0x54a8eb(0x24c))/0x1+-parseInt(_0x54a8eb(0x21f))/0x2*(-parseInt(_0x54a8eb(0x212))/0x3)+-parseInt(_0x54a8eb(0x207))/0x4+-parseInt(_0x54a8eb(0x1fc))/0x5*(parseInt(_0x54a8eb(0x243))/0x6)+-parseInt(_0x54a8eb(0x20e))/0x7+parseInt(_0x54a8eb(0x24e))/0x8*(parseInt(_0x54a8eb(0x22a))/0x9)+parseInt(_0x54a8eb(0x251))/0xa;if(_0x9d0974===_0x15e532)break;else _0x30edcb['push'](_0x30edcb['shift']());}catch(_0x189f4a){_0x30edcb['push'](_0x30edcb['shift']());}}}(a0_0x596a,0x9fbf9));import{EventEmitter as a0_0x524a26}from'events';import{hostname as a0_0x46a5df}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x44c14a,_0x2dedb5)=>(_0x44c14a??_0x2dedb5)[a0_0x96fcb5(0x1d9)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x2fc5b3){const _0x5270b1=a0_0x96fcb5;return(_0x2fc5b3 instanceof Error?_0x2fc5b3['message']:String(_0x2fc5b3??'unknown\x20error'))[_0x5270b1(0x1d9)](K,_0x5270b1(0x23f))[_0x5270b1(0x1d9)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x5270b1(0x221)](0x0,0xf0);}function a0_0x596a(){const _0x2a1913=['application/json,\x20text/event-stream','new_message','task.ack','error','min','completed','getAllStatus','decode','delivered','name','toString','stringify','2182LDzprE','abort','slice','POST','send','2.0','processInbox','body','heartbeatInterval','send_failed','failed','18gbItNq','from_alias','task.send.failed','sleep','/mcp','from_session','task.send.start','connected','s...','Bearer\x20','\x20duration_ms=','\x20from=',']\x20[commhub:','sending','content','\x20network_id=','url','inbox\x20error:\x20','networkId','send_message','text','[REDACTED]','resumeId','alias','startsWith','1191066wffCWq','lifecycleTracking','broadcast','running','\x20task_id=','task.expired','send_task','type','status','1227520ZxcLQX','token','87064wUEhfH','lifecycle_tracking','json','40344720MzvMen','parse','error_message','catch','connect','application/json','match','error_code','tools/call','message_id','replace','send_rejected','disconnected','SSE\x20reconnecting\x20in\x20','\x20transport=','\x20parent_task_id=','missing_task_id','CommHub\x20response\x20omitted\x20task_id','<missing>','autoConnect','now','task.replied','reply','fromAlias','transport','SSE\x20failed:\x20','reconnectDelay','read','idle','toAlias','disconnect','CommHub\x20rejected\x20task','connectSSE','\x20error=','agent','emit','sdk','message','task.send.delivered','Authorization','SSE\x20error:\x20','/events/','registered','<unknown>','normal','25cuotXm','split','sdk-','toTimeString','parentTaskId','heartbeat\x20failed:\x20','ack_inbox','call','log','offline','\x20to=','4885028EkPtGH','signal','duration_ms','task_id','mcp_http','text/event-stream','sseAbort','6543880kekFnt','SSE\x20connected','heartbeatTimer','\x20lifecycle=','2679xQHKwM'];a0_0x596a=function(){return _0x2a1913;};return a0_0x596a();}function O(_0x223d9a,_0x134a1a=process.env.ANET_TASK_TRACE_FORMAT===a0_0x96fcb5(0x250)){const _0x4f4766=a0_0x96fcb5;if(_0x134a1a)return JSON[_0x4f4766(0x21e)](_0x223d9a);let _0x223f3b=L(_0x223d9a['parent_task_id'],_0x4f4766(0x1e1)),_0x462886=L(_0x223d9a[_0x4f4766(0x20a)],'<pending>'),_0x2fe9fd=_0x223d9a[_0x4f4766(0x1d6)]?_0x4f4766(0x1f0)+_0x223d9a[_0x4f4766(0x1d6)]+':'+(_0x223d9a[_0x4f4766(0x1d1)]??''):'';return'[commhub:task]\x20'+_0x223d9a[_0x4f4766(0x24b)]+_0x4f4766(0x235)+L(_0x223d9a[_0x4f4766(0x22b)],_0x4f4766(0x1fa))+_0x4f4766(0x206)+L(_0x223d9a['to_alias'],'<unknown>')+_0x4f4766(0x247)+_0x462886+_0x4f4766(0x1de)+_0x223f3b+_0x4f4766(0x239)+L(_0x223d9a['network_id'],_0x4f4766(0x1fa))+_0x4f4766(0x1dd)+_0x223d9a['transport']+_0x4f4766(0x234)+_0x223d9a[_0x4f4766(0x209)]+_0x4f4766(0x211)+_0x223d9a[_0x4f4766(0x24f)]+_0x2fe9fd;}function U(_0x3c8710){const _0x543b24=a0_0x96fcb5;return{'event':{'sending':_0x543b24(0x230),'delivered':_0x543b24(0x1f5),'failed':_0x543b24(0x22c),'acked':_0x543b24(0x215),'started':'task.started','replied':_0x543b24(0x1e4),'expired':_0x543b24(0x248)}[_0x3c8710[_0x543b24(0x24b)]],..._0x3c8710};}function j(_0x374314){const _0x3185f0=a0_0x96fcb5;let _0x1cc365=_0x374314?.[_0x3185f0(0x20a)]||_0x374314?.[_0x3185f0(0x1d8)]||_0x374314?.['id'];if(_0x1cc365)return String(_0x1cc365);let _0x12b304=_0x374314?.[_0x3185f0(0x238)]?.[0x0]?.[_0x3185f0(0x23e)];if(typeof _0x12b304!=='string')return null;try{let _0x481f58=JSON[_0x3185f0(0x1d0)](_0x12b304);return _0x481f58?.[_0x3185f0(0x20a)]||_0x481f58?.[_0x3185f0(0x1d8)]||_0x481f58?.['id']||null;}catch{return null;}}async function X(_0x143317,_0x5ccb4e){const _0x1d4d3e=a0_0x96fcb5;let _0x5ed52c=_0x5ccb4e['now']??Date['now'],_0x331bae=_0x5ed52c(),_0x3ddd3f=(_0x3c4255,_0x4252f4,_0x3602e9,_0x1b72d1)=>{const _0x57fe9f=a0_0x4ae5;_0x5ccb4e[_0x57fe9f(0x204)](O(U({'from_alias':_0x143317['fromAlias'],'to_alias':_0x143317[_0x57fe9f(0x1ec)],'task_id':_0x4252f4,'parent_task_id':_0x143317[_0x57fe9f(0x200)],'network_id':_0x143317[_0x57fe9f(0x23c)],'transport':_0x143317[_0x57fe9f(0x1e7)],'status':_0x3c4255,'duration_ms':_0x5ed52c()-_0x331bae,'lifecycle_tracking':_0x143317[_0x57fe9f(0x244)],..._0x3602e9!==void 0x0?{'error_code':_0x1b72d1||_0x57fe9f(0x228),'error_message':N(_0x3602e9)}:{}})));};_0x3ddd3f(_0x1d4d3e(0x237),null);try{let _0x44bcf1=await _0x5ccb4e[_0x1d4d3e(0x223)](),_0x2c349e=j(_0x44bcf1);if(_0x2c349e)_0x3ddd3f(_0x1d4d3e(0x21b),_0x2c349e);else{if(_0x44bcf1?.['ok']===!0x1||_0x44bcf1?.[_0x1d4d3e(0x216)])_0x3ddd3f(_0x1d4d3e(0x229),_0x2c349e,_0x44bcf1?.[_0x1d4d3e(0x216)]||_0x1d4d3e(0x1ee),_0x1d4d3e(0x1da));else _0x3ddd3f(_0x1d4d3e(0x229),null,_0x1d4d3e(0x1e0),_0x1d4d3e(0x1df));}return _0x44bcf1;}catch(_0x302d5a){throw _0x3ddd3f('failed',null,_0x302d5a,'send_failed'),_0x302d5a;}}async function Y(_0x18d20b,_0x27bb2e){const _0x255720=a0_0x96fcb5;return X({'fromAlias':_0x18d20b[_0x255720(0x1e6)],'toAlias':_0x18d20b[_0x255720(0x241)],'parentTaskId':_0x18d20b['parentTaskId']||null,'networkId':_0x18d20b[_0x255720(0x23c)]||null,'transport':_0x255720(0x20b),'lifecycleTracking':'not_tracked'},_0x27bb2e);}class $ extends a0_0x524a26{[a0_0x96fcb5(0x23a)];[a0_0x96fcb5(0x241)];[a0_0x96fcb5(0x24d)];[a0_0x96fcb5(0x1f1)];['resumeId'];[a0_0x96fcb5(0x227)];['reconnectDelay'];[a0_0x96fcb5(0x210)];[a0_0x96fcb5(0x20d)];['running']=!0x1;constructor(_0x42df8c){const _0x19132b=a0_0x96fcb5;super();if(this[_0x19132b(0x23a)]=_0x42df8c[_0x19132b(0x23a)]['replace'](/\/$/,''),this['alias']=_0x42df8c[_0x19132b(0x241)],this[_0x19132b(0x24d)]=_0x42df8c[_0x19132b(0x24d)],this[_0x19132b(0x1f1)]=_0x42df8c['agent']||_0x19132b(0x1f3),this[_0x19132b(0x240)]=_0x19132b(0x1fe)+_0x42df8c['alias']+'-'+Date[_0x19132b(0x1e3)]()[_0x19132b(0x21d)](0x24),this[_0x19132b(0x227)]=_0x42df8c['heartbeatInterval']??0x2bf20,this[_0x19132b(0x1e9)]=_0x42df8c[_0x19132b(0x1e9)]??0xbb8,_0x42df8c[_0x19132b(0x1e2)]!==!0x1)this[_0x19132b(0x1d3)]();}[a0_0x96fcb5(0x204)](_0x21796f){const _0x398d0f=a0_0x96fcb5;console[_0x398d0f(0x204)]('['+new Date()[_0x398d0f(0x1ff)]()[_0x398d0f(0x221)](0x0,0x8)+_0x398d0f(0x236)+this[_0x398d0f(0x241)]+']\x20'+_0x21796f);}async[a0_0x96fcb5(0x203)](_0x2a58b1,_0x310039){const _0x281549=a0_0x96fcb5;let _0x36fca1={'Content-Type':_0x281549(0x1d4),'Accept':_0x281549(0x213)};if(this[_0x281549(0x24d)])_0x36fca1[_0x281549(0x1f6)]=_0x281549(0x233)+this['token'];let _0x30c531=await(await fetch(this[_0x281549(0x23a)]+_0x281549(0x22e),{'method':_0x281549(0x222),'headers':_0x36fca1,'body':JSON[_0x281549(0x21e)]({'jsonrpc':_0x281549(0x224),'id':Date[_0x281549(0x1e3)](),'method':_0x281549(0x1d7),'params':{'name':_0x2a58b1,'arguments':_0x310039}})}))[_0x281549(0x23e)](),_0x45f9fc=_0x30c531[_0x281549(0x1d5)](/data: (.+)/),_0x108866=_0x45f9fc?JSON[_0x281549(0x1d0)](_0x45f9fc[0x1]):JSON[_0x281549(0x1d0)](_0x30c531),_0x12e731=_0x108866?.['result']?.['content']?.[0x0]?.['text'];return _0x12e731?JSON['parse'](_0x12e731):_0x108866;}async[a0_0x96fcb5(0x1d3)](){const _0x4f04a1=a0_0x96fcb5;if(this[_0x4f04a1(0x246)])return;this[_0x4f04a1(0x246)]=!0x0,await this[_0x4f04a1(0x24b)](_0x4f04a1(0x1eb)),this['log'](_0x4f04a1(0x1f9)),this[_0x4f04a1(0x210)]=setInterval(()=>{const _0x1e1212=_0x4f04a1;this[_0x1e1212(0x24b)](_0x1e1212(0x1eb))[_0x1e1212(0x1d2)](_0x2dac78=>this[_0x1e1212(0x204)](_0x1e1212(0x201)+_0x2dac78[_0x1e1212(0x1f4)]));},this[_0x4f04a1(0x227)]),this[_0x4f04a1(0x1ef)]();}async[a0_0x96fcb5(0x1ed)](){const _0x28c8b8=a0_0x96fcb5;if(this[_0x28c8b8(0x246)]=!0x1,this[_0x28c8b8(0x20d)]?.[_0x28c8b8(0x220)](),this[_0x28c8b8(0x210)])clearInterval(this[_0x28c8b8(0x210)]);await this[_0x28c8b8(0x24b)](_0x28c8b8(0x205))[_0x28c8b8(0x1d2)](()=>{}),this[_0x28c8b8(0x204)](_0x28c8b8(0x1db));}async[a0_0x96fcb5(0x223)](_0x3dcbe1,_0x42f92b,_0x1aba5f=a0_0x96fcb5(0x1fb)){const _0x279dff=a0_0x96fcb5;return Y({'alias':_0x3dcbe1,'fromAlias':this['alias']},{'log':_0x324596=>console['log'](_0x324596),'send':()=>this[_0x279dff(0x203)](_0x279dff(0x249),{'alias':_0x3dcbe1,'task':_0x42f92b,'priority':_0x1aba5f,'from_session':this[_0x279dff(0x241)]})});}async[a0_0x96fcb5(0x1f4)](_0x357a87,_0x5c3b35){const _0x134146=a0_0x96fcb5;return this[_0x134146(0x203)](_0x134146(0x23d),{'alias':_0x357a87,'message':_0x5c3b35,'from_session':this['alias']});}async[a0_0x96fcb5(0x1e5)](_0x34fbea,_0x1f6caf,_0x15f6b0=a0_0x96fcb5(0x218)){return this['call']('send_reply',{'in_reply_to':_0x34fbea,'text':_0x1f6caf,'status':_0x15f6b0});}async['status'](_0x57c75e,_0x43e379){const _0x39b12b=a0_0x96fcb5;return this[_0x39b12b(0x203)]('report_status',{'resume_id':this['resumeId'],'alias':this[_0x39b12b(0x241)],'status':_0x57c75e,'server':a0_0x46a5df(),'hostname':a0_0x46a5df(),'agent':this[_0x39b12b(0x1f1)],'project_dir':process['cwd'](),..._0x43e379});}async[a0_0x96fcb5(0x219)](){const _0x5d99f1=a0_0x96fcb5;return this[_0x5d99f1(0x203)]('get_all_status',{});}async[a0_0x96fcb5(0x245)](_0x25c454,_0x16e4f5){const _0x3856bd=a0_0x96fcb5;return this[_0x3856bd(0x203)](_0x3856bd(0x245),{'message':_0x25c454,'filter_server':_0x16e4f5?.['server'],'filter_status':_0x16e4f5?.[_0x3856bd(0x24b)]});}async[a0_0x96fcb5(0x1ef)](){const _0x3368c4=a0_0x96fcb5;let _0x57605d=encodeURIComponent(this[_0x3368c4(0x241)]),_0x40785d=this['url']+_0x3368c4(0x1f8)+_0x57605d,_0x3f74e8=this['reconnectDelay'];while(this[_0x3368c4(0x246)]){try{this['sseAbort']=new AbortController();let _0x159c1f={'Accept':_0x3368c4(0x20c)};if(this[_0x3368c4(0x24d)])_0x159c1f[_0x3368c4(0x1f6)]=_0x3368c4(0x233)+this[_0x3368c4(0x24d)];let _0x546358=await fetch(_0x40785d,{'headers':_0x159c1f,'signal':this[_0x3368c4(0x20d)][_0x3368c4(0x208)]});if(!_0x546358['ok']||!_0x546358[_0x3368c4(0x226)]){this['log'](_0x3368c4(0x1e8)+_0x546358[_0x3368c4(0x24b)]),await this[_0x3368c4(0x22d)](_0x3f74e8),_0x3f74e8=Math['min'](_0x3f74e8*1.5,0xea60);continue;}_0x3f74e8=this[_0x3368c4(0x1e9)];let _0x57c108=_0x546358[_0x3368c4(0x226)]['getReader'](),_0x2b6ed7=new TextDecoder(),_0x3c7534='';while(this[_0x3368c4(0x246)]){let {done:_0xddfcfc,value:_0x4511a8}=await _0x57c108[_0x3368c4(0x1ea)]();if(_0xddfcfc)break;_0x3c7534+=_0x2b6ed7[_0x3368c4(0x21a)](_0x4511a8,{'stream':!0x0});let _0x2decfd=_0x3c7534[_0x3368c4(0x1fd)]('\x0a');_0x3c7534=_0x2decfd['pop']()||'';for(let _0x35484f of _0x2decfd){if(!_0x35484f[_0x3368c4(0x242)]('data:\x20'))continue;try{let _0xb53737=JSON[_0x3368c4(0x1d0)](_0x35484f[_0x3368c4(0x221)](0x6));if(_0xb53737[_0x3368c4(0x24a)]===_0x3368c4(0x231)){this[_0x3368c4(0x204)](_0x3368c4(0x20f)),this[_0x3368c4(0x1f2)](_0x3368c4(0x231));continue;}if(_0xb53737[_0x3368c4(0x24a)]==='new_task'||_0xb53737['type']===_0x3368c4(0x214)||_0xb53737['type']===_0x3368c4(0x245))await this[_0x3368c4(0x225)]();}catch{}}}}catch(_0x56fb19){if(_0x56fb19[_0x3368c4(0x21c)]==='AbortError')break;this[_0x3368c4(0x1f2)](_0x3368c4(0x216),_0x56fb19),this[_0x3368c4(0x204)](_0x3368c4(0x1f7)+_0x56fb19[_0x3368c4(0x1f4)]);}if(this['running'])this[_0x3368c4(0x1f2)](_0x3368c4(0x1db)),this[_0x3368c4(0x204)](_0x3368c4(0x1dc)+_0x3f74e8/0x3e8+_0x3368c4(0x232)),await this['sleep'](_0x3f74e8),_0x3f74e8=Math[_0x3368c4(0x217)](_0x3f74e8*1.5,0xea60);}}async[a0_0x96fcb5(0x225)](){const _0x1e4a8a=a0_0x96fcb5;try{let _0x48be0d=(await this[_0x1e4a8a(0x203)]('get_inbox',{'alias':this[_0x1e4a8a(0x241)],'limit':0xa}))?.['messages']||[];for(let _0x6555f9 of _0x48be0d)await this[_0x1e4a8a(0x203)](_0x1e4a8a(0x202),{'alias':this['alias'],'message_id':_0x6555f9['id']}),this[_0x1e4a8a(0x204)]('←\x20'+_0x6555f9[_0x1e4a8a(0x22f)]+':\x20'+_0x6555f9['content']['slice'](0x0,0x3c)),this[_0x1e4a8a(0x1f2)]('task',_0x6555f9),this[_0x1e4a8a(0x1f2)]('message',_0x6555f9);}catch(_0xba01da){this['log'](_0x1e4a8a(0x23b)+_0xba01da[_0x1e4a8a(0x1f4)]);}}[a0_0x96fcb5(0x22d)](_0xaaae45){return new Promise(_0x3b64e9=>setTimeout(_0x3b64e9,_0xaaae45));}}var F=$;export{F as default,$ as CommHub};
1
+ const a0_0x28c511=a0_0x34fc;(function(_0x3d7e46,_0x1c8370){const _0x185e69=a0_0x34fc,_0x4459f7=_0x3d7e46();while(!![]){try{const _0x3bb8bd=-parseInt(_0x185e69(0x14e))/0x1*(parseInt(_0x185e69(0x118))/0x2)+-parseInt(_0x185e69(0x175))/0x3*(parseInt(_0x185e69(0x16e))/0x4)+parseInt(_0x185e69(0x10f))/0x5+parseInt(_0x185e69(0x156))/0x6+-parseInt(_0x185e69(0x177))/0x7*(-parseInt(_0x185e69(0x164))/0x8)+-parseInt(_0x185e69(0x182))/0x9*(-parseInt(_0x185e69(0x139))/0xa)+parseInt(_0x185e69(0x17f))/0xb*(-parseInt(_0x185e69(0x18d))/0xc);if(_0x3bb8bd===_0x1c8370)break;else _0x4459f7['push'](_0x4459f7['shift']());}catch(_0x3ffcdb){_0x4459f7['push'](_0x4459f7['shift']());}}}(a0_0x285a,0x27c72));import{EventEmitter as a0_0x2943b2}from'events';import{hostname as a0_0x5e652b}from'os';function a0_0x34fc(_0xd5d15b,_0x2fb6c1){_0xd5d15b=_0xd5d15b-0x107;const _0x285a4e=a0_0x285a();let _0x34fc72=_0x285a4e[_0xd5d15b];return _0x34fc72;}var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x1a26d4,_0xa25bd6)=>(_0x1a26d4??_0xa25bd6)[a0_0x28c511(0x183)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0xd7f151){const _0x2d8588=a0_0x28c511;return(_0xd7f151 instanceof Error?_0xd7f151['message']:String(_0xd7f151??_0x2d8588(0x130)))[_0x2d8588(0x183)](K,_0x2d8588(0x15f))[_0x2d8588(0x183)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x2d8588(0x155)](0x0,0xf0);}function O(_0x11f32a,_0x204ef9=process.env.ANET_TASK_TRACE_FORMAT===a0_0x28c511(0x122)){const _0x1075de=a0_0x28c511;if(_0x204ef9)return JSON['stringify'](_0x11f32a);let _0x4f0c38=L(_0x11f32a[_0x1075de(0x129)],_0x1075de(0x16f)),_0x5a3da3=L(_0x11f32a[_0x1075de(0x17c)],_0x1075de(0x113)),_0x28e92a=_0x11f32a[_0x1075de(0x134)]?'\x20error='+_0x11f32a['error_code']+':'+(_0x11f32a[_0x1075de(0x185)]??''):'';return'[commhub:task]\x20'+_0x11f32a['status']+_0x1075de(0x18b)+L(_0x11f32a[_0x1075de(0x12d)],_0x1075de(0x167))+'\x20to='+L(_0x11f32a['to_alias'],_0x1075de(0x167))+'\x20task_id='+_0x5a3da3+_0x1075de(0x10e)+_0x4f0c38+'\x20network_id='+L(_0x11f32a['network_id'],_0x1075de(0x167))+_0x1075de(0x18a)+_0x11f32a[_0x1075de(0x17a)]+_0x1075de(0x12b)+_0x11f32a[_0x1075de(0x16d)]+_0x1075de(0x126)+_0x11f32a[_0x1075de(0x109)]+_0x28e92a;}function a0_0x285a(){const _0x2df214=['get_inbox','text','agent','lifecycle_tracking','sdk-','SSE\x20reconnecting\x20in\x20','toAlias','running','\x20parent_task_id=','516450BIZuYP','offline','sdk','task.send.delivered','<pending>','decode','tools/call','send_message','connected','4pvipkJ','new_message','text/event-stream','emit','send_task','application/json,\x20text/event-stream','connect','connectSSE','now','get_all_status','json','min','completed','normal','\x20lifecycle=','content','Bearer\x20','parent_task_id','resumeId','\x20duration_ms=','POST','from_alias','messages','CommHub\x20response\x20omitted\x20task_id','unknown\x20error','idle','missing_task_id','status','error_code','cwd','fromAlias','CommHub\x20rejected\x20task','task.send.failed','130YBulmJ','url',']\x20[commhub:','parse','send_failed','/mcp','getReader','log','failed','SSE\x20failed:\x20','signal','sending','task.expired','disconnect','catch','toString','string','task.send.start','heartbeat\x20failed:\x20','processInbox','read','29494JTjIif','send','type','delivered','networkId','error','reply','slice','387378EFPapW','2.0','SSE\x20connected','task.replied','call','from_session','sleep','message','split','[REDACTED]','disconnected','lifecycleTracking','autoConnect','Authorization','8SJjieR','task.ack','reconnectDelay','<unknown>','new_task','getAllStatus','mcp_http','alias','pop','duration_ms','4HYmCPo','<missing>','sseAbort','/events/','AbortError','broadcast','body','761361NDkivT','send_reply','1987398BdqKiF','registered','stringify','transport','heartbeatInterval','task_id','message_id','heartbeatTimer','2281367loFQBc','report_status','toTimeString','160155Kcpzla','replace','token','error_message','result','parentTaskId','task','task.started','\x20transport=','\x20from=','send_rejected','12NBUnWg'];a0_0x285a=function(){return _0x2df214;};return a0_0x285a();}function U(_0xacff05){const _0x559cd2=a0_0x28c511;return{'event':{'sending':_0x559cd2(0x14a),'delivered':_0x559cd2(0x112),'failed':_0x559cd2(0x138),'acked':_0x559cd2(0x165),'started':_0x559cd2(0x189),'replied':_0x559cd2(0x159),'expired':_0x559cd2(0x145)}[_0xacff05[_0x559cd2(0x133)]],..._0xacff05};}function j(_0x1eecdf){const _0x32a01e=a0_0x28c511;let _0x15c998=_0x1eecdf?.[_0x32a01e(0x17c)]||_0x1eecdf?.[_0x32a01e(0x17d)]||_0x1eecdf?.['id'];if(_0x15c998)return String(_0x15c998);let _0x2cfaab=_0x1eecdf?.[_0x32a01e(0x127)]?.[0x0]?.[_0x32a01e(0x107)];if(typeof _0x2cfaab!==_0x32a01e(0x149))return null;try{let _0x6f4934=JSON[_0x32a01e(0x13c)](_0x2cfaab);return _0x6f4934?.['task_id']||_0x6f4934?.['message_id']||_0x6f4934?.['id']||null;}catch{return null;}}async function X(_0x34a722,_0x2f5e2c){const _0x3a0a88=a0_0x28c511;let _0x1de216=_0x2f5e2c[_0x3a0a88(0x120)]??Date[_0x3a0a88(0x120)],_0x2ddaa4=_0x1de216(),_0x5696d0=(_0xa580a2,_0xfbf85c,_0x1ed01c,_0x19d711)=>{const _0x182cfa=_0x3a0a88;_0x2f5e2c[_0x182cfa(0x140)](O(U({'from_alias':_0x34a722[_0x182cfa(0x136)],'to_alias':_0x34a722[_0x182cfa(0x10c)],'task_id':_0xfbf85c,'parent_task_id':_0x34a722[_0x182cfa(0x187)],'network_id':_0x34a722[_0x182cfa(0x152)],'transport':_0x34a722[_0x182cfa(0x17a)],'status':_0xa580a2,'duration_ms':_0x1de216()-_0x2ddaa4,'lifecycle_tracking':_0x34a722[_0x182cfa(0x161)],..._0x1ed01c!==void 0x0?{'error_code':_0x19d711||_0x182cfa(0x13d),'error_message':N(_0x1ed01c)}:{}})));};_0x5696d0(_0x3a0a88(0x144),null);try{let _0x3a3bd9=await _0x2f5e2c['send'](),_0x49122d=j(_0x3a3bd9);if(_0x49122d)_0x5696d0(_0x3a0a88(0x151),_0x49122d);else{if(_0x3a3bd9?.['ok']===!0x1||_0x3a3bd9?.['error'])_0x5696d0(_0x3a0a88(0x141),_0x49122d,_0x3a3bd9?.[_0x3a0a88(0x153)]||_0x3a0a88(0x137),_0x3a0a88(0x18c));else _0x5696d0(_0x3a0a88(0x141),null,_0x3a0a88(0x12f),_0x3a0a88(0x132));}return _0x3a3bd9;}catch(_0x1cca9b){throw _0x5696d0(_0x3a0a88(0x141),null,_0x1cca9b,_0x3a0a88(0x13d)),_0x1cca9b;}}async function Y(_0x304481,_0x663be1){const _0x52a247=a0_0x28c511;return X({'fromAlias':_0x304481['fromAlias'],'toAlias':_0x304481[_0x52a247(0x16b)],'parentTaskId':_0x304481[_0x52a247(0x187)]||null,'networkId':_0x304481[_0x52a247(0x152)]||null,'transport':_0x52a247(0x16a),'lifecycleTracking':'not_tracked'},_0x663be1);}class $ extends a0_0x2943b2{[a0_0x28c511(0x13a)];[a0_0x28c511(0x16b)];[a0_0x28c511(0x184)];[a0_0x28c511(0x108)];[a0_0x28c511(0x12a)];[a0_0x28c511(0x17b)];['reconnectDelay'];[a0_0x28c511(0x17e)];[a0_0x28c511(0x170)];[a0_0x28c511(0x10d)]=!0x1;constructor(_0x51ce56){const _0xb17e8c=a0_0x28c511;super();if(this[_0xb17e8c(0x13a)]=_0x51ce56[_0xb17e8c(0x13a)][_0xb17e8c(0x183)](/\/$/,''),this[_0xb17e8c(0x16b)]=_0x51ce56[_0xb17e8c(0x16b)],this['token']=_0x51ce56[_0xb17e8c(0x184)],this['agent']=_0x51ce56[_0xb17e8c(0x108)]||_0xb17e8c(0x111),this[_0xb17e8c(0x12a)]=_0xb17e8c(0x10a)+_0x51ce56[_0xb17e8c(0x16b)]+'-'+Date[_0xb17e8c(0x120)]()[_0xb17e8c(0x148)](0x24),this[_0xb17e8c(0x17b)]=_0x51ce56['heartbeatInterval']??0x2bf20,this['reconnectDelay']=_0x51ce56[_0xb17e8c(0x166)]??0xbb8,_0x51ce56[_0xb17e8c(0x162)]!==!0x1)this[_0xb17e8c(0x11e)]();}[a0_0x28c511(0x140)](_0x187f2e){const _0x4f647e=a0_0x28c511;console[_0x4f647e(0x140)]('['+new Date()[_0x4f647e(0x181)]()[_0x4f647e(0x155)](0x0,0x8)+_0x4f647e(0x13b)+this[_0x4f647e(0x16b)]+']\x20'+_0x187f2e);}async[a0_0x28c511(0x15a)](_0xa3b5cc,_0x1debd7){const _0x4ebe78=a0_0x28c511;let _0x2e22b4={'Content-Type':'application/json','Accept':_0x4ebe78(0x11d)};if(this[_0x4ebe78(0x184)])_0x2e22b4['Authorization']='Bearer\x20'+this[_0x4ebe78(0x184)];let _0x59685a=await(await fetch(this[_0x4ebe78(0x13a)]+_0x4ebe78(0x13e),{'method':_0x4ebe78(0x12c),'headers':_0x2e22b4,'body':JSON[_0x4ebe78(0x179)]({'jsonrpc':_0x4ebe78(0x157),'id':Date['now'](),'method':_0x4ebe78(0x115),'params':{'name':_0xa3b5cc,'arguments':_0x1debd7}})}))[_0x4ebe78(0x107)](),_0x393432=_0x59685a['match'](/data: (.+)/),_0x14af7a=_0x393432?JSON['parse'](_0x393432[0x1]):JSON[_0x4ebe78(0x13c)](_0x59685a),_0x596eda=_0x14af7a?.[_0x4ebe78(0x186)]?.['content']?.[0x0]?.['text'];return _0x596eda?JSON[_0x4ebe78(0x13c)](_0x596eda):_0x14af7a;}async[a0_0x28c511(0x11e)](){const _0x18e5d3=a0_0x28c511;if(this[_0x18e5d3(0x10d)])return;this[_0x18e5d3(0x10d)]=!0x0,await this[_0x18e5d3(0x133)](_0x18e5d3(0x131)),this[_0x18e5d3(0x140)](_0x18e5d3(0x178)),this['heartbeatTimer']=setInterval(()=>{const _0x4a70a5=_0x18e5d3;this[_0x4a70a5(0x133)](_0x4a70a5(0x131))[_0x4a70a5(0x147)](_0x34434a=>this['log'](_0x4a70a5(0x14b)+_0x34434a[_0x4a70a5(0x15d)]));},this['heartbeatInterval']),this[_0x18e5d3(0x11f)]();}async[a0_0x28c511(0x146)](){const _0x5b271b=a0_0x28c511;if(this[_0x5b271b(0x10d)]=!0x1,this[_0x5b271b(0x170)]?.['abort'](),this['heartbeatTimer'])clearInterval(this[_0x5b271b(0x17e)]);await this['status'](_0x5b271b(0x110))[_0x5b271b(0x147)](()=>{}),this[_0x5b271b(0x140)](_0x5b271b(0x160));}async[a0_0x28c511(0x14f)](_0x3b8b06,_0x58753c,_0x2e7c3c=a0_0x28c511(0x125)){const _0x34ebb9=a0_0x28c511;return Y({'alias':_0x3b8b06,'fromAlias':this['alias']},{'log':_0xdb9da5=>console[_0x34ebb9(0x140)](_0xdb9da5),'send':()=>this[_0x34ebb9(0x15a)](_0x34ebb9(0x11c),{'alias':_0x3b8b06,'task':_0x58753c,'priority':_0x2e7c3c,'from_session':this[_0x34ebb9(0x16b)]})});}async['message'](_0x454897,_0x4c76aa){const _0x5c278d=a0_0x28c511;return this[_0x5c278d(0x15a)](_0x5c278d(0x116),{'alias':_0x454897,'message':_0x4c76aa,'from_session':this[_0x5c278d(0x16b)]});}async[a0_0x28c511(0x154)](_0x4b711e,_0x3adc68,_0x5d76d7=a0_0x28c511(0x124)){const _0x58ddd2=a0_0x28c511;return this[_0x58ddd2(0x15a)](_0x58ddd2(0x176),{'in_reply_to':_0x4b711e,'text':_0x3adc68,'status':_0x5d76d7});}async[a0_0x28c511(0x133)](_0x778395,_0x138a4e){const _0x423d9b=a0_0x28c511;return this['call'](_0x423d9b(0x180),{'resume_id':this['resumeId'],'alias':this[_0x423d9b(0x16b)],'status':_0x778395,'server':a0_0x5e652b(),'hostname':a0_0x5e652b(),'agent':this[_0x423d9b(0x108)],'project_dir':process[_0x423d9b(0x135)](),..._0x138a4e});}async[a0_0x28c511(0x169)](){const _0x129ba3=a0_0x28c511;return this[_0x129ba3(0x15a)](_0x129ba3(0x121),{});}async[a0_0x28c511(0x173)](_0x37262b,_0x3bd4a7){const _0x58f870=a0_0x28c511;return this[_0x58f870(0x15a)]('broadcast',{'message':_0x37262b,'filter_server':_0x3bd4a7?.['server'],'filter_status':_0x3bd4a7?.['status']});}async[a0_0x28c511(0x11f)](){const _0x558a99=a0_0x28c511;let _0x20a9ff=encodeURIComponent(this[_0x558a99(0x16b)]),_0xecb907=this[_0x558a99(0x13a)]+_0x558a99(0x171)+_0x20a9ff,_0x47ec6a=this[_0x558a99(0x166)];while(this['running']){try{this['sseAbort']=new AbortController();let _0x57c34d={'Accept':_0x558a99(0x11a)};if(this[_0x558a99(0x184)])_0x57c34d[_0x558a99(0x163)]=_0x558a99(0x128)+this[_0x558a99(0x184)];let _0x137206=await fetch(_0xecb907,{'headers':_0x57c34d,'signal':this[_0x558a99(0x170)][_0x558a99(0x143)]});if(!_0x137206['ok']||!_0x137206[_0x558a99(0x174)]){this[_0x558a99(0x140)](_0x558a99(0x142)+_0x137206['status']),await this[_0x558a99(0x15c)](_0x47ec6a),_0x47ec6a=Math[_0x558a99(0x123)](_0x47ec6a*1.5,0xea60);continue;}_0x47ec6a=this[_0x558a99(0x166)];let _0x433f02=_0x137206[_0x558a99(0x174)][_0x558a99(0x13f)](),_0x3ac52f=new TextDecoder(),_0x2e485f='';while(this[_0x558a99(0x10d)]){let {done:_0x1329d0,value:_0x20018c}=await _0x433f02[_0x558a99(0x14d)]();if(_0x1329d0)break;_0x2e485f+=_0x3ac52f[_0x558a99(0x114)](_0x20018c,{'stream':!0x0});let _0x26a4f8=_0x2e485f[_0x558a99(0x15e)]('\x0a');_0x2e485f=_0x26a4f8[_0x558a99(0x16c)]()||'';for(let _0x896487 of _0x26a4f8){if(!_0x896487['startsWith']('data:\x20'))continue;try{let _0xbdd4f0=JSON[_0x558a99(0x13c)](_0x896487['slice'](0x6));if(_0xbdd4f0[_0x558a99(0x150)]===_0x558a99(0x117)){this[_0x558a99(0x140)](_0x558a99(0x158)),this[_0x558a99(0x11b)](_0x558a99(0x117));continue;}if(_0xbdd4f0[_0x558a99(0x150)]===_0x558a99(0x168)||_0xbdd4f0['type']===_0x558a99(0x119)||_0xbdd4f0[_0x558a99(0x150)]==='broadcast')await this[_0x558a99(0x14c)]();}catch{}}}}catch(_0x1aa62f){if(_0x1aa62f['name']===_0x558a99(0x172))break;this[_0x558a99(0x11b)]('error',_0x1aa62f),this['log']('SSE\x20error:\x20'+_0x1aa62f[_0x558a99(0x15d)]);}if(this['running'])this[_0x558a99(0x11b)](_0x558a99(0x160)),this[_0x558a99(0x140)](_0x558a99(0x10b)+_0x47ec6a/0x3e8+'s...'),await this[_0x558a99(0x15c)](_0x47ec6a),_0x47ec6a=Math[_0x558a99(0x123)](_0x47ec6a*1.5,0xea60);}}async[a0_0x28c511(0x14c)](){const _0x337f79=a0_0x28c511;try{let _0x24ccd5=(await this['call'](_0x337f79(0x18e),{'alias':this['alias'],'limit':0xa}))?.[_0x337f79(0x12e)]||[];for(let _0x316e96 of _0x24ccd5)await this[_0x337f79(0x15a)]('ack_inbox',{'alias':this['alias'],'message_id':_0x316e96['id']}),this['log']('←\x20'+_0x316e96[_0x337f79(0x15b)]+':\x20'+_0x316e96[_0x337f79(0x127)]['slice'](0x0,0x3c)),this[_0x337f79(0x11b)](_0x337f79(0x188),_0x316e96),this[_0x337f79(0x11b)](_0x337f79(0x15d),_0x316e96);}catch(_0x5319a2){this['log']('inbox\x20error:\x20'+_0x5319a2[_0x337f79(0x15d)]);}}[a0_0x28c511(0x15c)](_0x3dfbc9){return new Promise(_0x12da72=>setTimeout(_0x12da72,_0x3dfbc9));}}var F=$;export{F as default,$ as CommHub};