@sleep2agi/agent-network 2.3.0-preview.71 → 2.3.0-preview.72
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.
package/dist/src/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function a0_0x268b(_0xec6201,_0x177dbe){_0xec6201=_0xec6201-0x91;const _0xb46bcb=a0_0xb46b();let _0x268bda=_0xb46bcb[_0xec6201];return _0x268bda;}const a0_0x58c91a=a0_0x268b;(function(_0x5e40b7,_0x1d373b){const _0x2b2e28=a0_0x268b,_0x2a80f4=_0x5e40b7();while(!![]){try{const _0x538844=parseInt(_0x2b2e28(0xab))/0x1+parseInt(_0x2b2e28(0x9a))/0x2*(-parseInt(_0x2b2e28(0xb3))/0x3)+parseInt(_0x2b2e28(0xee))/0x4+parseInt(_0x2b2e28(0xb2))/0x5*(parseInt(_0x2b2e28(0xc6))/0x6)+parseInt(_0x2b2e28(0xe2))/0x7*(-parseInt(_0x2b2e28(0xfa))/0x8)+parseInt(_0x2b2e28(0xa3))/0x9+parseInt(_0x2b2e28(0x10a))/0xa;if(_0x538844===_0x1d373b)break;else _0x2a80f4['push'](_0x2a80f4['shift']());}catch(_0x6d7459){_0x2a80f4['push'](_0x2a80f4['shift']());}}}(a0_0xb46b,0x4d4a8));import{EventEmitter as a0_0x1042a4}from'events';function a0_0xb46b(){const _0x1adba3=['abort','task.send.failed','catch','<pending>','from_session','broadcast','offline','error','completed','504EqzLwF','\x20duration_ms=','error_code','autoConnect','send_task','connected','sending','message','Bearer\x20','mcp_http','cwd','lifecycleTracking','processInbox','getAllStatus','CommHub\x20response\x20omitted\x20task_id','split','4281450uuuMDk','failed','new_task','signal','sseAbort','application/json','\x20lifecycle=','heartbeatInterval','Authorization','not_tracked','stringify','task.send.start','connectSSE','ack_inbox','[REDACTED]','\x20from=','540HBWPsF','message_id','string','status','tools/call','<missing>','log','\x20network_id=','data:\x20','642420mUjYJL','sleep','inbox\x20error:\x20','send_reply','\x20to=','s...','toString','alias','464232rXCgOc','error_message','network_id','getReader','slice','min','name','55yyWhyq','4797ZWUTqY','missing_task_id','server','send','\x20task_id=','task.started','networkId','task_id','SSE\x20connected','task.expired','toAlias','heartbeat\x20failed:\x20','/events/','normal','now','type','POST','startsWith','json','44718ckxKbd','running','resumeId','url','[commhub:task]\x20','SSE\x20reconnecting\x20in\x20','idle','replace','connect','disconnect','AbortError','content','result','application/json,\x20text/event-stream','heartbeatTimer','task.replied','text/event-stream','reconnectDelay','parent_task_id','<unknown>','parse','messages','token','call','SSE\x20failed:\x20','send_failed','read','\x20parent_task_id=','55559MOXdih','task.ack','task','send_rejected','agent','to_alias','emit','registered','parentTaskId','disconnected','fromAlias','text','810420TsXMiD','CommHub\x20rejected\x20task','sdk-'];a0_0xb46b=function(){return _0x1adba3;};return a0_0xb46b();}import{hostname as a0_0x3df4f8}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x398863,_0x381fd7)=>(_0x398863??_0x381fd7)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x4052d2){const _0x53a357=a0_0x268b;return(_0x4052d2 instanceof Error?_0x4052d2[_0x53a357(0x101)]:String(_0x4052d2??'unknown\x20error'))[_0x53a357(0xcd)](K,_0x53a357(0x98))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x1496b5,_0x58ff4c=process.env.ANET_TASK_TRACE_FORMAT===a0_0x58c91a(0xc5)){const _0x2c1a9a=a0_0x58c91a;if(_0x58ff4c)return JSON[_0x2c1a9a(0x94)](_0x1496b5);let _0x2fadbc=L(_0x1496b5[_0x2c1a9a(0xd8)],_0x2c1a9a(0x9f)),_0x9d502f=L(_0x1496b5[_0x2c1a9a(0xba)],_0x2c1a9a(0xf4)),_0x1f872e=_0x1496b5[_0x2c1a9a(0xfc)]?'\x20error='+_0x1496b5[_0x2c1a9a(0xfc)]+':'+(_0x1496b5[_0x2c1a9a(0xac)]??''):'';return _0x2c1a9a(0xca)+_0x1496b5[_0x2c1a9a(0x9d)]+_0x2c1a9a(0x99)+L(_0x1496b5['from_alias'],_0x2c1a9a(0xd9))+_0x2c1a9a(0xa7)+L(_0x1496b5[_0x2c1a9a(0xe7)],_0x2c1a9a(0xd9))+_0x2c1a9a(0xb7)+_0x9d502f+_0x2c1a9a(0xe1)+_0x2fadbc+_0x2c1a9a(0xa1)+L(_0x1496b5[_0x2c1a9a(0xad)],'<unknown>')+'\x20transport='+_0x1496b5['transport']+_0x2c1a9a(0xfb)+_0x1496b5['duration_ms']+_0x2c1a9a(0x110)+_0x1496b5['lifecycle_tracking']+_0x1f872e;}function U(_0xae52a0){const _0x41801e=a0_0x58c91a;return{'event':{'sending':_0x41801e(0x95),'delivered':'task.send.delivered','failed':_0x41801e(0xf2),'acked':_0x41801e(0xe3),'started':_0x41801e(0xb8),'replied':_0x41801e(0xd5),'expired':_0x41801e(0xbc)}[_0xae52a0[_0x41801e(0x9d)]],..._0xae52a0};}function j(_0x20f2c9){const _0x3368d7=a0_0x58c91a;let _0x1beb0e=_0x20f2c9?.[_0x3368d7(0xba)]||_0x20f2c9?.[_0x3368d7(0x9b)]||_0x20f2c9?.['id'];if(_0x1beb0e)return String(_0x1beb0e);let _0x30004a=_0x20f2c9?.[_0x3368d7(0xd1)]?.[0x0]?.[_0x3368d7(0xed)];if(typeof _0x30004a!==_0x3368d7(0x9c))return null;try{let _0x398c30=JSON['parse'](_0x30004a);return _0x398c30?.[_0x3368d7(0xba)]||_0x398c30?.[_0x3368d7(0x9b)]||_0x398c30?.['id']||null;}catch{return null;}}async function X(_0x1283ac,_0x3ba307){const _0x559cc9=a0_0x58c91a;let _0x33a5e0=_0x3ba307[_0x559cc9(0xc1)]??Date[_0x559cc9(0xc1)],_0x328e49=_0x33a5e0(),_0x5dfbeb=(_0x17346e,_0x1bbdb9,_0x37993d,_0xa5e91b)=>{const _0x54bf78=_0x559cc9;_0x3ba307[_0x54bf78(0xa0)](O(U({'from_alias':_0x1283ac[_0x54bf78(0xec)],'to_alias':_0x1283ac[_0x54bf78(0xbd)],'task_id':_0x1bbdb9,'parent_task_id':_0x1283ac['parentTaskId'],'network_id':_0x1283ac[_0x54bf78(0xb9)],'transport':_0x1283ac['transport'],'status':_0x17346e,'duration_ms':_0x33a5e0()-_0x328e49,'lifecycle_tracking':_0x1283ac[_0x54bf78(0x105)],..._0x37993d!==void 0x0?{'error_code':_0xa5e91b||_0x54bf78(0xdf),'error_message':N(_0x37993d)}:{}})));};_0x5dfbeb(_0x559cc9(0x100),null);try{let _0x1eb2f6=await _0x3ba307[_0x559cc9(0xb6)](),_0xf62d25=j(_0x1eb2f6);if(_0xf62d25)_0x5dfbeb('delivered',_0xf62d25);else{if(_0x1eb2f6?.['ok']===!0x1||_0x1eb2f6?.[_0x559cc9(0xf8)])_0x5dfbeb(_0x559cc9(0x10b),_0xf62d25,_0x1eb2f6?.['error']||_0x559cc9(0xef),_0x559cc9(0xe5));else _0x5dfbeb(_0x559cc9(0x10b),null,_0x559cc9(0x108),_0x559cc9(0xb4));}return _0x1eb2f6;}catch(_0x3fef30){throw _0x5dfbeb(_0x559cc9(0x10b),null,_0x3fef30,'send_failed'),_0x3fef30;}}async function Y(_0x4ac945,_0xd3ae74){const _0x3bcf3e=a0_0x58c91a;return X({'fromAlias':_0x4ac945[_0x3bcf3e(0xec)],'toAlias':_0x4ac945[_0x3bcf3e(0xaa)],'parentTaskId':_0x4ac945[_0x3bcf3e(0xea)]||null,'networkId':_0x4ac945[_0x3bcf3e(0xb9)]||null,'transport':_0x3bcf3e(0x103),'lifecycleTracking':_0x3bcf3e(0x93)},_0xd3ae74);}class $ extends a0_0x1042a4{[a0_0x58c91a(0xc9)];['alias'];[a0_0x58c91a(0xdc)];[a0_0x58c91a(0xe6)];[a0_0x58c91a(0xc8)];[a0_0x58c91a(0x91)];[a0_0x58c91a(0xd7)];[a0_0x58c91a(0xd4)];[a0_0x58c91a(0x10e)];[a0_0x58c91a(0xc7)]=!0x1;constructor(_0x2fca58){const _0x522316=a0_0x58c91a;super();if(this['url']=_0x2fca58[_0x522316(0xc9)][_0x522316(0xcd)](/\/$/,''),this[_0x522316(0xaa)]=_0x2fca58[_0x522316(0xaa)],this[_0x522316(0xdc)]=_0x2fca58[_0x522316(0xdc)],this[_0x522316(0xe6)]=_0x2fca58[_0x522316(0xe6)]||'sdk',this['resumeId']=_0x522316(0xf0)+_0x2fca58[_0x522316(0xaa)]+'-'+Date['now']()[_0x522316(0xa9)](0x24),this[_0x522316(0x91)]=_0x2fca58[_0x522316(0x91)]??0x2bf20,this[_0x522316(0xd7)]=_0x2fca58['reconnectDelay']??0xbb8,_0x2fca58[_0x522316(0xfd)]!==!0x1)this[_0x522316(0xce)]();}[a0_0x58c91a(0xa0)](_0x13884d){const _0x2a82ad=a0_0x58c91a;console[_0x2a82ad(0xa0)]('['+new Date()['toTimeString']()[_0x2a82ad(0xaf)](0x0,0x8)+']\x20[commhub:'+this[_0x2a82ad(0xaa)]+']\x20'+_0x13884d);}async[a0_0x58c91a(0xdd)](_0x248434,_0x127150){const _0x2b5156=a0_0x58c91a;let _0x15caa8={'Content-Type':_0x2b5156(0x10f),'Accept':_0x2b5156(0xd3)};if(this['token'])_0x15caa8[_0x2b5156(0x92)]=_0x2b5156(0x102)+this[_0x2b5156(0xdc)];let _0x337506=await(await fetch(this[_0x2b5156(0xc9)]+'/mcp',{'method':_0x2b5156(0xc3),'headers':_0x15caa8,'body':JSON[_0x2b5156(0x94)]({'jsonrpc':'2.0','id':Date[_0x2b5156(0xc1)](),'method':_0x2b5156(0x9e),'params':{'name':_0x248434,'arguments':_0x127150}})}))[_0x2b5156(0xed)](),_0x3d5481=_0x337506['match'](/data: (.+)/),_0x168b05=_0x3d5481?JSON[_0x2b5156(0xda)](_0x3d5481[0x1]):JSON[_0x2b5156(0xda)](_0x337506),_0x2e50b6=_0x168b05?.[_0x2b5156(0xd2)]?.[_0x2b5156(0xd1)]?.[0x0]?.['text'];return _0x2e50b6?JSON[_0x2b5156(0xda)](_0x2e50b6):_0x168b05;}async['connect'](){const _0x19b19d=a0_0x58c91a;if(this[_0x19b19d(0xc7)])return;this[_0x19b19d(0xc7)]=!0x0,await this[_0x19b19d(0x9d)]('idle'),this['log'](_0x19b19d(0xe9)),this[_0x19b19d(0xd4)]=setInterval(()=>{const _0x36bf2f=_0x19b19d;this[_0x36bf2f(0x9d)](_0x36bf2f(0xcc))[_0x36bf2f(0xf3)](_0x435dd0=>this[_0x36bf2f(0xa0)](_0x36bf2f(0xbe)+_0x435dd0[_0x36bf2f(0x101)]));},this[_0x19b19d(0x91)]),this[_0x19b19d(0x96)]();}async[a0_0x58c91a(0xcf)](){const _0x2f09bc=a0_0x58c91a;if(this[_0x2f09bc(0xc7)]=!0x1,this[_0x2f09bc(0x10e)]?.[_0x2f09bc(0xf1)](),this[_0x2f09bc(0xd4)])clearInterval(this[_0x2f09bc(0xd4)]);await this[_0x2f09bc(0x9d)](_0x2f09bc(0xf7))[_0x2f09bc(0xf3)](()=>{}),this[_0x2f09bc(0xa0)](_0x2f09bc(0xeb));}async[a0_0x58c91a(0xb6)](_0x5dd3d5,_0x6b9585,_0x4f7a86=a0_0x58c91a(0xc0)){const _0x2e25f6=a0_0x58c91a;return Y({'alias':_0x5dd3d5,'fromAlias':this[_0x2e25f6(0xaa)]},{'log':_0x64c8bd=>console['log'](_0x64c8bd),'send':()=>this['call'](_0x2e25f6(0xfe),{'alias':_0x5dd3d5,'task':_0x6b9585,'priority':_0x4f7a86,'from_session':this[_0x2e25f6(0xaa)]})});}async['message'](_0x4c777a,_0x1b7b45){const _0x103dad=a0_0x58c91a;return this[_0x103dad(0xdd)]('send_message',{'alias':_0x4c777a,'message':_0x1b7b45,'from_session':this['alias']});}async['reply'](_0x3f9174,_0x4e4417,_0x3289b6=a0_0x58c91a(0xf9)){const _0x500862=a0_0x58c91a;return this[_0x500862(0xdd)](_0x500862(0xa6),{'in_reply_to':_0x3f9174,'text':_0x4e4417,'status':_0x3289b6});}async['status'](_0x39072b,_0x4323e7){const _0x191f21=a0_0x58c91a;return this[_0x191f21(0xdd)]('report_status',{'resume_id':this[_0x191f21(0xc8)],'alias':this[_0x191f21(0xaa)],'status':_0x39072b,'server':a0_0x3df4f8(),'hostname':a0_0x3df4f8(),'agent':this[_0x191f21(0xe6)],'project_dir':process[_0x191f21(0x104)](),..._0x4323e7});}async[a0_0x58c91a(0x107)](){return this['call']('get_all_status',{});}async[a0_0x58c91a(0xf6)](_0x38e2f2,_0x187d6b){const _0x1a3d53=a0_0x58c91a;return this['call'](_0x1a3d53(0xf6),{'message':_0x38e2f2,'filter_server':_0x187d6b?.[_0x1a3d53(0xb5)],'filter_status':_0x187d6b?.[_0x1a3d53(0x9d)]});}async[a0_0x58c91a(0x96)](){const _0x39cc8f=a0_0x58c91a;let _0x4a4632=encodeURIComponent(this[_0x39cc8f(0xaa)]),_0xb7f11b=this['url']+_0x39cc8f(0xbf)+_0x4a4632,_0x3e0628=this['reconnectDelay'];while(this[_0x39cc8f(0xc7)]){try{this['sseAbort']=new AbortController();let _0x4df032={'Accept':_0x39cc8f(0xd6)};if(this['token'])_0x4df032[_0x39cc8f(0x92)]=_0x39cc8f(0x102)+this[_0x39cc8f(0xdc)];let _0x13041c=await fetch(_0xb7f11b,{'headers':_0x4df032,'signal':this[_0x39cc8f(0x10e)][_0x39cc8f(0x10d)]});if(!_0x13041c['ok']||!_0x13041c['body']){this['log'](_0x39cc8f(0xde)+_0x13041c[_0x39cc8f(0x9d)]),await this[_0x39cc8f(0xa4)](_0x3e0628),_0x3e0628=Math[_0x39cc8f(0xb0)](_0x3e0628*1.5,0xea60);continue;}_0x3e0628=this[_0x39cc8f(0xd7)];let _0x39a612=_0x13041c['body'][_0x39cc8f(0xae)](),_0x4d5056=new TextDecoder(),_0x2bfd64='';while(this[_0x39cc8f(0xc7)]){let {done:_0x2de728,value:_0x23f69d}=await _0x39a612[_0x39cc8f(0xe0)]();if(_0x2de728)break;_0x2bfd64+=_0x4d5056['decode'](_0x23f69d,{'stream':!0x0});let _0x2c3f0e=_0x2bfd64[_0x39cc8f(0x109)]('\x0a');_0x2bfd64=_0x2c3f0e['pop']()||'';for(let _0xe05c69 of _0x2c3f0e){if(!_0xe05c69[_0x39cc8f(0xc4)](_0x39cc8f(0xa2)))continue;try{let _0x20e4fa=JSON[_0x39cc8f(0xda)](_0xe05c69[_0x39cc8f(0xaf)](0x6));if(_0x20e4fa[_0x39cc8f(0xc2)]===_0x39cc8f(0xff)){this[_0x39cc8f(0xa0)](_0x39cc8f(0xbb)),this[_0x39cc8f(0xe8)](_0x39cc8f(0xff));continue;}if(_0x20e4fa[_0x39cc8f(0xc2)]===_0x39cc8f(0x10c)||_0x20e4fa['type']==='new_message'||_0x20e4fa[_0x39cc8f(0xc2)]===_0x39cc8f(0xf6))await this[_0x39cc8f(0x106)]();}catch{}}}}catch(_0x3944b2){if(_0x3944b2[_0x39cc8f(0xb1)]===_0x39cc8f(0xd0))break;this[_0x39cc8f(0xe8)](_0x39cc8f(0xf8),_0x3944b2),this['log']('SSE\x20error:\x20'+_0x3944b2['message']);}if(this[_0x39cc8f(0xc7)])this['emit'](_0x39cc8f(0xeb)),this[_0x39cc8f(0xa0)](_0x39cc8f(0xcb)+_0x3e0628/0x3e8+_0x39cc8f(0xa8)),await this['sleep'](_0x3e0628),_0x3e0628=Math[_0x39cc8f(0xb0)](_0x3e0628*1.5,0xea60);}}async['processInbox'](){const _0x1dd30b=a0_0x58c91a;try{let _0x5e1011=(await this['call']('get_inbox',{'alias':this[_0x1dd30b(0xaa)],'limit':0xa}))?.[_0x1dd30b(0xdb)]||[];for(let _0x542867 of _0x5e1011)await this[_0x1dd30b(0xdd)](_0x1dd30b(0x97),{'alias':this[_0x1dd30b(0xaa)],'message_id':_0x542867['id']}),this[_0x1dd30b(0xa0)]('←\x20'+_0x542867[_0x1dd30b(0xf5)]+':\x20'+_0x542867[_0x1dd30b(0xd1)]['slice'](0x0,0x3c)),this[_0x1dd30b(0xe8)](_0x1dd30b(0xe4),_0x542867),this[_0x1dd30b(0xe8)](_0x1dd30b(0x101),_0x542867);}catch(_0x3fd90b){this[_0x1dd30b(0xa0)](_0x1dd30b(0xa5)+_0x3fd90b[_0x1dd30b(0x101)]);}}[a0_0x58c91a(0xa4)](_0x3e1615){return new Promise(_0x2d8b6f=>setTimeout(_0x2d8b6f,_0x3e1615));}}var F=$;export{F as default,$ as CommHub};
|
|
1
|
+
const a0_0x32c978=a0_0xf4d6;(function(_0x4b69d5,_0x4d3b29){const _0x4838bf=a0_0xf4d6,_0x19fef6=_0x4b69d5();while(!![]){try{const _0x10c0ed=parseInt(_0x4838bf(0x24e))/0x1+-parseInt(_0x4838bf(0x233))/0x2+-parseInt(_0x4838bf(0x206))/0x3*(parseInt(_0x4838bf(0x23e))/0x4)+-parseInt(_0x4838bf(0x215))/0x5*(-parseInt(_0x4838bf(0x207))/0x6)+parseInt(_0x4838bf(0x223))/0x7*(-parseInt(_0x4838bf(0x1ed))/0x8)+parseInt(_0x4838bf(0x23d))/0x9*(-parseInt(_0x4838bf(0x221))/0xa)+parseInt(_0x4838bf(0x246))/0xb*(parseInt(_0x4838bf(0x229))/0xc);if(_0x10c0ed===_0x4d3b29)break;else _0x19fef6['push'](_0x19fef6['shift']());}catch(_0x4a05a6){_0x19fef6['push'](_0x19fef6['shift']());}}}(a0_0x3b90,0x2080b));import{EventEmitter as a0_0x39481c}from'events';import{hostname as a0_0x415061}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x367d1c,_0x588c77)=>(_0x367d1c??_0x588c77)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x20abaf){const _0x45c6a4=a0_0xf4d6;return(_0x20abaf instanceof Error?_0x20abaf[_0x45c6a4(0x1eb)]:String(_0x20abaf??_0x45c6a4(0x25b)))[_0x45c6a4(0x25a)](K,_0x45c6a4(0x22d))[_0x45c6a4(0x25a)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x45c6a4(0x25f)](0x0,0xf0);}function O(_0x165478,_0x21b4b3=process.env.ANET_TASK_TRACE_FORMAT===a0_0x32c978(0x24b)){const _0x201bcf=a0_0x32c978;if(_0x21b4b3)return JSON['stringify'](_0x165478);let _0x4b18c=L(_0x165478[_0x201bcf(0x20d)],'<missing>'),_0x13748e=L(_0x165478['task_id'],_0x201bcf(0x1f1)),_0x5a3f6c=_0x165478[_0x201bcf(0x1f8)]?_0x201bcf(0x245)+_0x165478[_0x201bcf(0x1f8)]+':'+(_0x165478[_0x201bcf(0x1f6)]??''):'';return _0x201bcf(0x266)+_0x165478[_0x201bcf(0x230)]+_0x201bcf(0x20e)+L(_0x165478[_0x201bcf(0x244)],_0x201bcf(0x235))+_0x201bcf(0x1ee)+L(_0x165478[_0x201bcf(0x226)],_0x201bcf(0x235))+_0x201bcf(0x210)+_0x13748e+_0x201bcf(0x240)+_0x4b18c+_0x201bcf(0x212)+L(_0x165478[_0x201bcf(0x25d)],_0x201bcf(0x235))+_0x201bcf(0x202)+_0x165478[_0x201bcf(0x261)]+'\x20duration_ms='+_0x165478['duration_ms']+'\x20lifecycle='+_0x165478[_0x201bcf(0x269)]+_0x5a3f6c;}function U(_0x381318){const _0x6f0f32=a0_0x32c978;return{'event':{'sending':'task.send.start','delivered':_0x6f0f32(0x241),'failed':_0x6f0f32(0x23b),'acked':_0x6f0f32(0x26a),'started':_0x6f0f32(0x21e),'replied':_0x6f0f32(0x209),'expired':_0x6f0f32(0x213)}[_0x381318[_0x6f0f32(0x230)]],..._0x381318};}function j(_0x40e90d){const _0x275783=a0_0x32c978;let _0x4d6f1b=_0x40e90d?.['task_id']||_0x40e90d?.[_0x275783(0x216)]||_0x40e90d?.['id'];if(_0x4d6f1b)return String(_0x4d6f1b);let _0x52bef9=_0x40e90d?.['content']?.[0x0]?.[_0x275783(0x24d)];if(typeof _0x52bef9!==_0x275783(0x203))return null;try{let _0x10e99f=JSON[_0x275783(0x222)](_0x52bef9);return _0x10e99f?.['task_id']||_0x10e99f?.[_0x275783(0x216)]||_0x10e99f?.['id']||null;}catch{return null;}}function a0_0xf4d6(_0x885ab,_0xd4566b){_0x885ab=_0x885ab-0x1ea;const _0x3b90ff=a0_0x3b90();let _0xf4d630=_0x3b90ff[_0x885ab];return _0xf4d630;}async function X(_0x2f7227,_0x5691d6){const _0x17f61f=a0_0x32c978;let _0x348b91=_0x5691d6[_0x17f61f(0x21c)]??Date[_0x17f61f(0x21c)],_0x15c8e5=_0x348b91(),_0x3217d5=(_0x3fbfb9,_0x575924,_0x2dc1e2,_0x3ab6cb)=>{const _0xdc4af7=_0x17f61f;_0x5691d6[_0xdc4af7(0x219)](O(U({'from_alias':_0x2f7227[_0xdc4af7(0x234)],'to_alias':_0x2f7227[_0xdc4af7(0x267)],'task_id':_0x575924,'parent_task_id':_0x2f7227['parentTaskId'],'network_id':_0x2f7227[_0xdc4af7(0x214)],'transport':_0x2f7227[_0xdc4af7(0x261)],'status':_0x3fbfb9,'duration_ms':_0x348b91()-_0x15c8e5,'lifecycle_tracking':_0x2f7227[_0xdc4af7(0x1ec)],..._0x2dc1e2!==void 0x0?{'error_code':_0x3ab6cb||'send_failed','error_message':N(_0x2dc1e2)}:{}})));};_0x3217d5(_0x17f61f(0x20f),null);try{let _0x54a54a=await _0x5691d6[_0x17f61f(0x262)](),_0x5c0c29=j(_0x54a54a);if(_0x5c0c29)_0x3217d5('delivered',_0x5c0c29);else{if(_0x54a54a?.['ok']===!0x1||_0x54a54a?.[_0x17f61f(0x1f3)])_0x3217d5(_0x17f61f(0x249),_0x5c0c29,_0x54a54a?.[_0x17f61f(0x1f3)]||_0x17f61f(0x1fa),'send_rejected');else _0x3217d5(_0x17f61f(0x249),null,_0x17f61f(0x228),_0x17f61f(0x253));}return _0x54a54a;}catch(_0x2af17f){throw _0x3217d5(_0x17f61f(0x249),null,_0x2af17f,_0x17f61f(0x225)),_0x2af17f;}}async function Y(_0x5c364c,_0x1fb9fa){const _0x21a005=a0_0x32c978;return X({'fromAlias':_0x5c364c[_0x21a005(0x234)],'toAlias':_0x5c364c[_0x21a005(0x265)],'parentTaskId':_0x5c364c[_0x21a005(0x258)]||null,'networkId':_0x5c364c[_0x21a005(0x214)]||null,'transport':_0x21a005(0x1ff),'lifecycleTracking':_0x21a005(0x1f2)},_0x1fb9fa);}class $ extends a0_0x39481c{[a0_0x32c978(0x239)];[a0_0x32c978(0x265)];[a0_0x32c978(0x248)];[a0_0x32c978(0x237)];[a0_0x32c978(0x255)];[a0_0x32c978(0x251)];['reconnectDelay'];[a0_0x32c978(0x25e)];['sseAbort'];['running']=!0x1;constructor(_0x15d5ea){const _0x50b757=a0_0x32c978;super();if(this['url']=_0x15d5ea[_0x50b757(0x239)]['replace'](/\/$/,''),this['alias']=_0x15d5ea['alias'],this['token']=_0x15d5ea[_0x50b757(0x248)],this[_0x50b757(0x237)]=_0x15d5ea['agent']||_0x50b757(0x220),this[_0x50b757(0x255)]=_0x50b757(0x22a)+_0x15d5ea[_0x50b757(0x265)]+'-'+Date[_0x50b757(0x21c)]()[_0x50b757(0x208)](0x24),this['heartbeatInterval']=_0x15d5ea[_0x50b757(0x251)]??0x2bf20,this['reconnectDelay']=_0x15d5ea['reconnectDelay']??0xbb8,_0x15d5ea[_0x50b757(0x21a)]!==!0x1)this[_0x50b757(0x257)]();}[a0_0x32c978(0x219)](_0xa1014c){const _0x4fe321=a0_0x32c978;console[_0x4fe321(0x219)]('['+new Date()[_0x4fe321(0x1ea)]()[_0x4fe321(0x25f)](0x0,0x8)+_0x4fe321(0x247)+this[_0x4fe321(0x265)]+']\x20'+_0xa1014c);}async[a0_0x32c978(0x20a)](_0x32835c,_0x4e555c){const _0x4eb629=a0_0x32c978;let _0x691db2={'Content-Type':_0x4eb629(0x236),'Accept':'application/json,\x20text/event-stream'};if(this[_0x4eb629(0x248)])_0x691db2['Authorization']='Bearer\x20'+this['token'];let _0x41ebff=await(await fetch(this[_0x4eb629(0x239)]+_0x4eb629(0x1f7),{'method':_0x4eb629(0x21b),'headers':_0x691db2,'body':JSON['stringify']({'jsonrpc':_0x4eb629(0x227),'id':Date['now'](),'method':_0x4eb629(0x268),'params':{'name':_0x32835c,'arguments':_0x4e555c}})}))[_0x4eb629(0x24d)](),_0x14bfeb=_0x41ebff['match'](/data: (.+)/),_0x2469ec=_0x14bfeb?JSON[_0x4eb629(0x222)](_0x14bfeb[0x1]):JSON[_0x4eb629(0x222)](_0x41ebff),_0x5eba7b=_0x2469ec?.['result']?.[_0x4eb629(0x243)]?.[0x0]?.['text'];return _0x5eba7b?JSON[_0x4eb629(0x222)](_0x5eba7b):_0x2469ec;}async['connect'](){const _0x5045fa=a0_0x32c978;if(this['running'])return;this[_0x5045fa(0x232)]=!0x0,await this[_0x5045fa(0x230)](_0x5045fa(0x1f4)),this['log'](_0x5045fa(0x22b)),this[_0x5045fa(0x25e)]=setInterval(()=>{const _0x25bda5=_0x5045fa;this[_0x25bda5(0x230)]('idle')[_0x25bda5(0x218)](_0x2936d4=>this[_0x25bda5(0x219)]('heartbeat\x20failed:\x20'+_0x2936d4[_0x25bda5(0x1eb)]));},this[_0x5045fa(0x251)]),this['connectSSE']();}async[a0_0x32c978(0x242)](){const _0x51b5f1=a0_0x32c978;if(this[_0x51b5f1(0x232)]=!0x1,this[_0x51b5f1(0x23a)]?.[_0x51b5f1(0x23f)](),this['heartbeatTimer'])clearInterval(this[_0x51b5f1(0x25e)]);await this['status'](_0x51b5f1(0x21d))[_0x51b5f1(0x218)](()=>{}),this[_0x51b5f1(0x219)](_0x51b5f1(0x22c));}async[a0_0x32c978(0x262)](_0x3d020a,_0x33c0c5,_0xf5b1d9=a0_0x32c978(0x20c)){const _0xc6b81a=a0_0x32c978;return Y({'alias':_0x3d020a,'fromAlias':this['alias']},{'log':_0x39acbc=>console['log'](_0x39acbc),'send':()=>this[_0xc6b81a(0x20a)](_0xc6b81a(0x20b),{'alias':_0x3d020a,'task':_0x33c0c5,'priority':_0xf5b1d9,'from_session':this[_0xc6b81a(0x265)]})});}async[a0_0x32c978(0x1eb)](_0x37a333,_0x1a64ec){const _0xa60abd=a0_0x32c978;return this[_0xa60abd(0x20a)](_0xa60abd(0x23c),{'alias':_0x37a333,'message':_0x1a64ec,'from_session':this['alias']});}async[a0_0x32c978(0x205)](_0x357dcf,_0x46172d,_0x1f8858=a0_0x32c978(0x1fb)){const _0x23c4b6=a0_0x32c978;return this[_0x23c4b6(0x20a)](_0x23c4b6(0x24c),{'in_reply_to':_0x357dcf,'text':_0x46172d,'status':_0x1f8858});}async[a0_0x32c978(0x230)](_0x1a57c3,_0x117cb7){const _0x51298f=a0_0x32c978;return this['call']('report_status',{'resume_id':this[_0x51298f(0x255)],'alias':this[_0x51298f(0x265)],'status':_0x1a57c3,'server':a0_0x415061(),'hostname':a0_0x415061(),'agent':this[_0x51298f(0x237)],'project_dir':process['cwd'](),..._0x117cb7});}async[a0_0x32c978(0x259)](){const _0x5ae531=a0_0x32c978;return this[_0x5ae531(0x20a)]('get_all_status',{});}async[a0_0x32c978(0x24f)](_0x29a0ec,_0xd670dc){const _0x116d38=a0_0x32c978;return this[_0x116d38(0x20a)](_0x116d38(0x24f),{'message':_0x29a0ec,'filter_server':_0xd670dc?.['server'],'filter_status':_0xd670dc?.[_0x116d38(0x230)]});}async['connectSSE'](){const _0x290e9c=a0_0x32c978;let _0x3d339b=encodeURIComponent(this[_0x290e9c(0x265)]),_0x57828e=this['url']+_0x290e9c(0x211)+_0x3d339b,_0x26b4a7=this[_0x290e9c(0x25c)];while(this[_0x290e9c(0x232)]){try{this[_0x290e9c(0x23a)]=new AbortController();let _0x4ded89={'Accept':_0x290e9c(0x231)};if(this['token'])_0x4ded89[_0x290e9c(0x1fc)]=_0x290e9c(0x1f0)+this[_0x290e9c(0x248)];let _0x13aae7=await fetch(_0x57828e,{'headers':_0x4ded89,'signal':this['sseAbort'][_0x290e9c(0x1f9)]});if(!_0x13aae7['ok']||!_0x13aae7[_0x290e9c(0x200)]){this[_0x290e9c(0x219)]('SSE\x20failed:\x20'+_0x13aae7['status']),await this['sleep'](_0x26b4a7),_0x26b4a7=Math[_0x290e9c(0x1f5)](_0x26b4a7*1.5,0xea60);continue;}_0x26b4a7=this[_0x290e9c(0x25c)];let _0x19242c=_0x13aae7[_0x290e9c(0x200)][_0x290e9c(0x24a)](),_0x16c3ef=new TextDecoder(),_0x547310='';while(this['running']){let {done:_0x44f7c6,value:_0xce22f}=await _0x19242c[_0x290e9c(0x1ef)]();if(_0x44f7c6)break;_0x547310+=_0x16c3ef[_0x290e9c(0x224)](_0xce22f,{'stream':!0x0});let _0x32a374=_0x547310[_0x290e9c(0x22e)]('\x0a');_0x547310=_0x32a374[_0x290e9c(0x26b)]()||'';for(let _0x2b8482 of _0x32a374){if(!_0x2b8482[_0x290e9c(0x256)](_0x290e9c(0x217)))continue;try{let _0x43db63=JSON[_0x290e9c(0x222)](_0x2b8482[_0x290e9c(0x25f)](0x6));if(_0x43db63['type']===_0x290e9c(0x204)){this[_0x290e9c(0x219)](_0x290e9c(0x254)),this[_0x290e9c(0x22f)]('connected');continue;}if(_0x43db63[_0x290e9c(0x201)]===_0x290e9c(0x1fe)||_0x43db63[_0x290e9c(0x201)]==='new_message'||_0x43db63['type']==='broadcast')await this[_0x290e9c(0x250)]();}catch{}}}}catch(_0x4631ea){if(_0x4631ea['name']===_0x290e9c(0x238))break;this['emit']('error',_0x4631ea),this['log']('SSE\x20error:\x20'+_0x4631ea[_0x290e9c(0x1eb)]);}if(this['running'])this[_0x290e9c(0x22f)](_0x290e9c(0x22c)),this[_0x290e9c(0x219)](_0x290e9c(0x263)+_0x26b4a7/0x3e8+_0x290e9c(0x252)),await this[_0x290e9c(0x260)](_0x26b4a7),_0x26b4a7=Math[_0x290e9c(0x1f5)](_0x26b4a7*1.5,0xea60);}}async['processInbox'](){const _0x34a0e3=a0_0x32c978;try{let _0x2035d5=(await this[_0x34a0e3(0x20a)]('get_inbox',{'alias':this[_0x34a0e3(0x265)],'limit':0xa}))?.[_0x34a0e3(0x264)]||[];for(let _0x4fca49 of _0x2035d5)await this[_0x34a0e3(0x20a)](_0x34a0e3(0x21f),{'alias':this['alias'],'message_id':_0x4fca49['id']}),this[_0x34a0e3(0x219)]('←\x20'+_0x4fca49['from_session']+':\x20'+_0x4fca49[_0x34a0e3(0x243)][_0x34a0e3(0x25f)](0x0,0x3c)),this[_0x34a0e3(0x22f)](_0x34a0e3(0x1fd),_0x4fca49),this[_0x34a0e3(0x22f)](_0x34a0e3(0x1eb),_0x4fca49);}catch(_0x3a999b){this[_0x34a0e3(0x219)]('inbox\x20error:\x20'+_0x3a999b[_0x34a0e3(0x1eb)]);}}['sleep'](_0xf4718c){return new Promise(_0x125202=>setTimeout(_0x125202,_0xf4718c));}}var F=$;export{F as default,$ as CommHub};function a0_0x3b90(){const _0x3c02d2=['from_alias','\x20error=','3502873PzNHYu',']\x20[commhub:','token','failed','getReader','json','send_reply','text','215923RZXoAT','broadcast','processInbox','heartbeatInterval','s...','missing_task_id','SSE\x20connected','resumeId','startsWith','connect','parentTaskId','getAllStatus','replace','unknown\x20error','reconnectDelay','network_id','heartbeatTimer','slice','sleep','transport','send','SSE\x20reconnecting\x20in\x20','messages','alias','[commhub:task]\x20','toAlias','tools/call','lifecycle_tracking','task.ack','pop','toTimeString','message','lifecycleTracking','1455160dfbYhT','\x20to=','read','Bearer\x20','<pending>','not_tracked','error','idle','min','error_message','/mcp','error_code','signal','CommHub\x20rejected\x20task','completed','Authorization','task','new_task','mcp_http','body','type','\x20transport=','string','connected','reply','21fHdjFm','84852MQrsZY','toString','task.replied','call','send_task','normal','parent_task_id','\x20from=','sending','\x20task_id=','/events/','\x20network_id=','task.expired','networkId','40ZNmSRE','message_id','data:\x20','catch','log','autoConnect','POST','now','offline','task.started','ack_inbox','sdk','10fdkYWr','parse','7qjtzuh','decode','send_failed','to_alias','2.0','CommHub\x20response\x20omitted\x20task_id','24lWpKbz','sdk-','registered','disconnected','[REDACTED]','split','emit','status','text/event-stream','running','440418YAeRAY','fromAlias','<unknown>','application/json','agent','AbortError','url','sseAbort','task.send.failed','send_message','1973223lQbvzp','120836bLQsgT','abort','\x20parent_task_id=','task.send.delivered','disconnect','content'];a0_0x3b90=function(){return _0x3c02d2;};return a0_0x3b90();}
|