@sleep2agi/agent-network 2.3.0-preview.130 → 2.3.0-preview.131

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_0x54dcea=a0_0x3c4d;(function(_0x2dce84,_0x5d2160){const _0x3bad70=a0_0x3c4d,_0x4a79ce=_0x2dce84();while(!![]){try{const _0x1366c9=-parseInt(_0x3bad70(0x13c))/0x1+parseInt(_0x3bad70(0x182))/0x2*(-parseInt(_0x3bad70(0x174))/0x3)+parseInt(_0x3bad70(0x11b))/0x4*(parseInt(_0x3bad70(0x19d))/0x5)+parseInt(_0x3bad70(0x126))/0x6*(parseInt(_0x3bad70(0x141))/0x7)+-parseInt(_0x3bad70(0x18a))/0x8*(parseInt(_0x3bad70(0x140))/0x9)+parseInt(_0x3bad70(0x172))/0xa+-parseInt(_0x3bad70(0x13a))/0xb*(parseInt(_0x3bad70(0x185))/0xc);if(_0x1366c9===_0x5d2160)break;else _0x4a79ce['push'](_0x4a79ce['shift']());}catch(_0x3a6238){_0x4a79ce['push'](_0x4a79ce['shift']());}}}(a0_0x5a1a,0x4fbc3));import{EventEmitter as a0_0x236648}from'events';function a0_0x3c4d(_0x25d33f,_0x18f813){_0x25d33f=_0x25d33f-0x11b;const _0x5a1a5c=a0_0x5a1a();let _0x3c4d8b=_0x5a1a5c[_0x25d33f];return _0x3c4d8b;}import{hostname as a0_0x47ae1d}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x25b62d,_0x3f933b)=>(_0x25b62d??_0x3f933b)[a0_0x54dcea(0x19b)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x54dcea(0x193)](0x0,0xf0);function N(_0x4d7650){const _0x4335c4=a0_0x54dcea;return(_0x4d7650 instanceof Error?_0x4d7650[_0x4335c4(0x17e)]:String(_0x4d7650??'unknown\x20error'))[_0x4335c4(0x19b)](K,_0x4335c4(0x146))[_0x4335c4(0x19b)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x4335c4(0x193)](0x0,0xf0);}function O(_0x2d484f,_0x34db13=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x3e7023=a0_0x54dcea;if(_0x34db13)return JSON[_0x3e7023(0x189)](_0x2d484f);let _0x8aeff1=L(_0x2d484f[_0x3e7023(0x15d)],_0x3e7023(0x12f)),_0x4c1f50=L(_0x2d484f['task_id'],_0x3e7023(0x143)),_0x26cb6b=_0x2d484f['error_code']?_0x3e7023(0x181)+_0x2d484f[_0x3e7023(0x17c)]+':'+(_0x2d484f[_0x3e7023(0x11e)]??''):'';return _0x3e7023(0x12b)+_0x2d484f[_0x3e7023(0x16c)]+'\x20from='+L(_0x2d484f['from_alias'],_0x3e7023(0x132))+_0x3e7023(0x164)+L(_0x2d484f[_0x3e7023(0x170)],_0x3e7023(0x132))+'\x20task_id='+_0x4c1f50+_0x3e7023(0x154)+_0x8aeff1+_0x3e7023(0x15a)+L(_0x2d484f[_0x3e7023(0x16d)],'<unknown>')+_0x3e7023(0x124)+_0x2d484f[_0x3e7023(0x125)]+'\x20duration_ms='+_0x2d484f[_0x3e7023(0x178)]+_0x3e7023(0x12a)+_0x2d484f[_0x3e7023(0x186)]+_0x26cb6b;}function U(_0x379a26){const _0x2a0914=a0_0x54dcea;return{'event':{'sending':_0x2a0914(0x17f),'delivered':_0x2a0914(0x14b),'failed':_0x2a0914(0x177),'acked':_0x2a0914(0x175),'started':_0x2a0914(0x153),'replied':_0x2a0914(0x14e),'expired':'task.expired'}[_0x379a26[_0x2a0914(0x16c)]],..._0x379a26};}function j(_0x1a4622){const _0x411e00=a0_0x54dcea;let _0x506af2=_0x1a4622?.[_0x411e00(0x11c)]||_0x1a4622?.[_0x411e00(0x160)]||_0x1a4622?.['id'];if(_0x506af2)return String(_0x506af2);let _0x4bb7e1=_0x1a4622?.[_0x411e00(0x18f)]?.[0x0]?.[_0x411e00(0x16f)];if(typeof _0x4bb7e1!==_0x411e00(0x17d))return null;try{let _0x2fc3da=JSON['parse'](_0x4bb7e1);return _0x2fc3da?.[_0x411e00(0x11c)]||_0x2fc3da?.[_0x411e00(0x160)]||_0x2fc3da?.['id']||null;}catch{return null;}}async function X(_0x57c2d2,_0x1f2941){const _0x58a73c=a0_0x54dcea;let _0x5d8629=_0x1f2941['now']??Date[_0x58a73c(0x183)],_0x21fd68=_0x5d8629(),_0x4e84be=(_0x4ed604,_0x36bb57,_0x3e586f,_0x3f3f6b)=>{const _0x2ec303=_0x58a73c;_0x1f2941[_0x2ec303(0x158)](O(U({'from_alias':_0x57c2d2[_0x2ec303(0x168)],'to_alias':_0x57c2d2['toAlias'],'task_id':_0x36bb57,'parent_task_id':_0x57c2d2[_0x2ec303(0x142)],'network_id':_0x57c2d2['networkId'],'transport':_0x57c2d2[_0x2ec303(0x125)],'status':_0x4ed604,'duration_ms':_0x5d8629()-_0x21fd68,'lifecycle_tracking':_0x57c2d2[_0x2ec303(0x138)],..._0x3e586f!==void 0x0?{'error_code':_0x3f3f6b||_0x2ec303(0x15b),'error_message':N(_0x3e586f)}:{}})));};_0x4e84be(_0x58a73c(0x1a0),null);try{let _0x3b5ebe=await _0x1f2941[_0x58a73c(0x162)](),_0x9ff2c7=j(_0x3b5ebe);if(_0x9ff2c7)_0x4e84be(_0x58a73c(0x122),_0x9ff2c7);else{if(_0x3b5ebe?.['ok']===!0x1||_0x3b5ebe?.[_0x58a73c(0x144)])_0x4e84be(_0x58a73c(0x198),_0x9ff2c7,_0x3b5ebe?.['error']||'CommHub\x20rejected\x20task',_0x58a73c(0x199));else _0x4e84be(_0x58a73c(0x198),null,_0x58a73c(0x134),_0x58a73c(0x17b));}return _0x3b5ebe;}catch(_0x2d5ab5){throw _0x4e84be(_0x58a73c(0x198),null,_0x2d5ab5,_0x58a73c(0x15b)),_0x2d5ab5;}}function a0_0x5a1a(){const _0x56f4d4=['parse','task.replied','idle','connected','normal','sleep','task.started','\x20parent_task_id=','SSE\x20reconnecting\x20in\x20','POST','agent','log','catch','\x20network_id=','send_failed','SSE\x20connected','parent_task_id','abort','startsWith','message_id','task','send','match','\x20to=','s...','autoConnect','tools/call','fromAlias','/events/','2.0','connect','status','network_id','result','text','to_alias','signal','1305230RErtzb','offline','1667661lKYvZW','task.ack','not_tracked','task.send.failed','duration_ms','emit','body','missing_task_id','error_code','string','message','task.send.start','pop','\x20error=','2TlYDfV','now','new_message','796788LvoNeW','lifecycle_tracking','cwd','broadcast','stringify','8QdXrmK','SSE\x20error:\x20','min','ack_inbox','send_message','content','heartbeatTimer','heartbeatInterval','registered','slice','AbortError','disconnected','application/json','alias','failed','send_rejected','token','replace','new_task','10szIxyH','processInbox','split','sending','881404PDWoXD','task_id','text/event-stream','error_message','sseAbort','type','/mcp','delivered','inbox\x20error:\x20','\x20transport=','transport','1006554lhsSna','reconnectDelay','disconnect','send_reply','\x20lifecycle=','[commhub:task]\x20','Bearer\x20','networkId','name','<missing>','mcp_http','get_inbox','<unknown>','call','CommHub\x20response\x20omitted\x20task_id','completed','connectSSE','from_session','lifecycleTracking','getReader','22NEZJlr','Authorization','13173TkQpMY','report_status','sdk','resumeId','414441igXdDn','21hWSJAA','parentTaskId','<pending>','error','url','[REDACTED]','decode','data:\x20','heartbeat\x20failed:\x20','read','task.send.delivered','running'];a0_0x5a1a=function(){return _0x56f4d4;};return a0_0x5a1a();}async function Y(_0x1ff4e9,_0x1016cc){const _0x164cfa=a0_0x54dcea;return X({'fromAlias':_0x1ff4e9['fromAlias'],'toAlias':_0x1ff4e9['alias'],'parentTaskId':_0x1ff4e9[_0x164cfa(0x142)]||null,'networkId':_0x1ff4e9[_0x164cfa(0x12d)]||null,'transport':_0x164cfa(0x130),'lifecycleTracking':_0x164cfa(0x176)},_0x1016cc);}class $ extends a0_0x236648{[a0_0x54dcea(0x145)];[a0_0x54dcea(0x197)];[a0_0x54dcea(0x19a)];[a0_0x54dcea(0x157)];[a0_0x54dcea(0x13f)];['heartbeatInterval'];[a0_0x54dcea(0x127)];['heartbeatTimer'];[a0_0x54dcea(0x11f)];[a0_0x54dcea(0x14c)]=!0x1;constructor(_0x185603){const _0x384373=a0_0x54dcea;super();if(this['url']=_0x185603['url'][_0x384373(0x19b)](/\/$/,''),this[_0x384373(0x197)]=_0x185603[_0x384373(0x197)],this[_0x384373(0x19a)]=_0x185603[_0x384373(0x19a)],this[_0x384373(0x157)]=_0x185603[_0x384373(0x157)]||_0x384373(0x13e),this[_0x384373(0x13f)]='sdk-'+_0x185603['alias']+'-'+Date[_0x384373(0x183)]()['toString'](0x24),this[_0x384373(0x191)]=_0x185603[_0x384373(0x191)]??0x2bf20,this[_0x384373(0x127)]=_0x185603[_0x384373(0x127)]??0xbb8,_0x185603[_0x384373(0x166)]!==!0x1)this['connect']();}[a0_0x54dcea(0x158)](_0x40195a){const _0x3d6bdb=a0_0x54dcea;console[_0x3d6bdb(0x158)]('['+new Date()['toTimeString']()[_0x3d6bdb(0x193)](0x0,0x8)+']\x20[commhub:'+this[_0x3d6bdb(0x197)]+']\x20'+_0x40195a);}async[a0_0x54dcea(0x133)](_0x447676,_0x556eb2){const _0x5b4e3c=a0_0x54dcea;let _0xf0dcd7={'Content-Type':_0x5b4e3c(0x196),'Accept':'application/json,\x20text/event-stream'};if(this[_0x5b4e3c(0x19a)])_0xf0dcd7['Authorization']=_0x5b4e3c(0x12c)+this[_0x5b4e3c(0x19a)];let _0x1af82c=await(await fetch(this[_0x5b4e3c(0x145)]+_0x5b4e3c(0x121),{'method':_0x5b4e3c(0x156),'headers':_0xf0dcd7,'body':JSON['stringify']({'jsonrpc':_0x5b4e3c(0x16a),'id':Date[_0x5b4e3c(0x183)](),'method':_0x5b4e3c(0x167),'params':{'name':_0x447676,'arguments':_0x556eb2}})}))['text'](),_0x4f7ecf=_0x1af82c[_0x5b4e3c(0x163)](/data: (.+)/),_0x251b83=_0x4f7ecf?JSON[_0x5b4e3c(0x14d)](_0x4f7ecf[0x1]):JSON[_0x5b4e3c(0x14d)](_0x1af82c),_0x2466df=_0x251b83?.[_0x5b4e3c(0x16e)]?.['content']?.[0x0]?.[_0x5b4e3c(0x16f)];return _0x2466df?JSON[_0x5b4e3c(0x14d)](_0x2466df):_0x251b83;}async[a0_0x54dcea(0x16b)](){const _0x25c9c6=a0_0x54dcea;if(this[_0x25c9c6(0x14c)])return;this[_0x25c9c6(0x14c)]=!0x0,await this[_0x25c9c6(0x16c)](_0x25c9c6(0x14f)),this[_0x25c9c6(0x158)](_0x25c9c6(0x192)),this[_0x25c9c6(0x190)]=setInterval(()=>{const _0x24036c=_0x25c9c6;this[_0x24036c(0x16c)](_0x24036c(0x14f))[_0x24036c(0x159)](_0x16480e=>this[_0x24036c(0x158)](_0x24036c(0x149)+_0x16480e[_0x24036c(0x17e)]));},this[_0x25c9c6(0x191)]),this[_0x25c9c6(0x136)]();}async[a0_0x54dcea(0x128)](){const _0x25e17a=a0_0x54dcea;if(this[_0x25e17a(0x14c)]=!0x1,this[_0x25e17a(0x11f)]?.[_0x25e17a(0x15e)](),this[_0x25e17a(0x190)])clearInterval(this[_0x25e17a(0x190)]);await this[_0x25e17a(0x16c)](_0x25e17a(0x173))[_0x25e17a(0x159)](()=>{}),this['log']('disconnected');}async['send'](_0x30915a,_0x1981cb,_0x545311=a0_0x54dcea(0x151)){const _0x28739c=a0_0x54dcea;return Y({'alias':_0x30915a,'fromAlias':this[_0x28739c(0x197)]},{'log':_0x42ca47=>console[_0x28739c(0x158)](_0x42ca47),'send':()=>this[_0x28739c(0x133)]('send_task',{'alias':_0x30915a,'task':_0x1981cb,'priority':_0x545311,'from_session':this[_0x28739c(0x197)]})});}async[a0_0x54dcea(0x17e)](_0x400bcd,_0x332e31){const _0x33de38=a0_0x54dcea;return this[_0x33de38(0x133)](_0x33de38(0x18e),{'alias':_0x400bcd,'message':_0x332e31,'from_session':this[_0x33de38(0x197)]});}async['reply'](_0x3fd746,_0x3c998d,_0x31da76=a0_0x54dcea(0x135)){const _0x4fe890=a0_0x54dcea;return this[_0x4fe890(0x133)](_0x4fe890(0x129),{'in_reply_to':_0x3fd746,'text':_0x3c998d,'status':_0x31da76});}async[a0_0x54dcea(0x16c)](_0x3680e6,_0x1496c4){const _0x5797f2=a0_0x54dcea;return this['call'](_0x5797f2(0x13d),{'resume_id':this[_0x5797f2(0x13f)],'alias':this['alias'],'status':_0x3680e6,'server':a0_0x47ae1d(),'hostname':a0_0x47ae1d(),'agent':this[_0x5797f2(0x157)],'project_dir':process[_0x5797f2(0x187)](),..._0x1496c4});}async['getAllStatus'](){const _0x5c2dee=a0_0x54dcea;return this[_0x5c2dee(0x133)]('get_all_status',{});}async['broadcast'](_0x982f52,_0x4b84aa){const _0x42f36c=a0_0x54dcea;return this[_0x42f36c(0x133)](_0x42f36c(0x188),{'message':_0x982f52,'filter_server':_0x4b84aa?.['server'],'filter_status':_0x4b84aa?.[_0x42f36c(0x16c)]});}async[a0_0x54dcea(0x136)](){const _0x25899d=a0_0x54dcea;let _0x3b06f7=encodeURIComponent(this[_0x25899d(0x197)]),_0x51a0a0=this['url']+_0x25899d(0x169)+_0x3b06f7,_0x3a27e1=this['reconnectDelay'];while(this[_0x25899d(0x14c)]){try{this['sseAbort']=new AbortController();let _0x3c3991={'Accept':_0x25899d(0x11d)};if(this['token'])_0x3c3991[_0x25899d(0x13b)]=_0x25899d(0x12c)+this[_0x25899d(0x19a)];let _0x256473=await fetch(_0x51a0a0,{'headers':_0x3c3991,'signal':this[_0x25899d(0x11f)][_0x25899d(0x171)]});if(!_0x256473['ok']||!_0x256473[_0x25899d(0x17a)]){this['log']('SSE\x20failed:\x20'+_0x256473[_0x25899d(0x16c)]),await this[_0x25899d(0x152)](_0x3a27e1),_0x3a27e1=Math[_0x25899d(0x18c)](_0x3a27e1*1.5,0xea60);continue;}_0x3a27e1=this[_0x25899d(0x127)];let _0x480cf3=_0x256473[_0x25899d(0x17a)][_0x25899d(0x139)](),_0x2a5636=new TextDecoder(),_0x22599f='';while(this[_0x25899d(0x14c)]){let {done:_0x2e6050,value:_0x4d98c6}=await _0x480cf3[_0x25899d(0x14a)]();if(_0x2e6050)break;_0x22599f+=_0x2a5636[_0x25899d(0x147)](_0x4d98c6,{'stream':!0x0});let _0x6cd1c1=_0x22599f[_0x25899d(0x19f)]('\x0a');_0x22599f=_0x6cd1c1[_0x25899d(0x180)]()||'';for(let _0x3bd05b of _0x6cd1c1){if(!_0x3bd05b[_0x25899d(0x15f)](_0x25899d(0x148)))continue;try{let _0xe20962=JSON['parse'](_0x3bd05b[_0x25899d(0x193)](0x6));if(_0xe20962[_0x25899d(0x120)]===_0x25899d(0x150)){this[_0x25899d(0x158)](_0x25899d(0x15c)),this[_0x25899d(0x179)]('connected');continue;}if(_0xe20962[_0x25899d(0x120)]===_0x25899d(0x19c)||_0xe20962[_0x25899d(0x120)]===_0x25899d(0x184)||_0xe20962['type']===_0x25899d(0x188))await this[_0x25899d(0x19e)]();}catch{}}}}catch(_0xe19233){if(_0xe19233[_0x25899d(0x12e)]===_0x25899d(0x194))break;this[_0x25899d(0x179)]('error',_0xe19233),this[_0x25899d(0x158)](_0x25899d(0x18b)+_0xe19233[_0x25899d(0x17e)]);}if(this['running'])this[_0x25899d(0x179)](_0x25899d(0x195)),this['log'](_0x25899d(0x155)+_0x3a27e1/0x3e8+_0x25899d(0x165)),await this[_0x25899d(0x152)](_0x3a27e1),_0x3a27e1=Math['min'](_0x3a27e1*1.5,0xea60);}}async['processInbox'](){const _0x4c9e71=a0_0x54dcea;try{let _0x14b0ea=(await this[_0x4c9e71(0x133)](_0x4c9e71(0x131),{'alias':this['alias'],'limit':0xa}))?.['messages']||[];for(let _0x3856bb of _0x14b0ea)await this[_0x4c9e71(0x133)](_0x4c9e71(0x18d),{'alias':this[_0x4c9e71(0x197)],'message_id':_0x3856bb['id']}),this['log']('←\x20'+_0x3856bb[_0x4c9e71(0x137)]+':\x20'+_0x3856bb[_0x4c9e71(0x18f)][_0x4c9e71(0x193)](0x0,0x3c)),this['emit'](_0x4c9e71(0x161),_0x3856bb),this[_0x4c9e71(0x179)](_0x4c9e71(0x17e),_0x3856bb);}catch(_0xed40aa){this[_0x4c9e71(0x158)](_0x4c9e71(0x123)+_0xed40aa['message']);}}[a0_0x54dcea(0x152)](_0x5cd5c4){return new Promise(_0x495dd1=>setTimeout(_0x495dd1,_0x5cd5c4));}}var F=$;export{F as default,$ as CommHub};
1
+ const a0_0x15d04e=a0_0x2533;function a0_0x2533(_0x133ede,_0x3c028c){_0x133ede=_0x133ede-0x16d;const _0x12772d=a0_0x1277();let _0x253375=_0x12772d[_0x133ede];return _0x253375;}(function(_0x134b15,_0x48f95b){const _0x309395=a0_0x2533,_0x5dab1f=_0x134b15();while(!![]){try{const _0x56f200=parseInt(_0x309395(0x1b5))/0x1+parseInt(_0x309395(0x1b9))/0x2+parseInt(_0x309395(0x1d3))/0x3+-parseInt(_0x309395(0x1b3))/0x4*(parseInt(_0x309395(0x1a0))/0x5)+-parseInt(_0x309395(0x1ab))/0x6*(-parseInt(_0x309395(0x184))/0x7)+parseInt(_0x309395(0x17e))/0x8+-parseInt(_0x309395(0x1a4))/0x9;if(_0x56f200===_0x48f95b)break;else _0x5dab1f['push'](_0x5dab1f['shift']());}catch(_0x24ae49){_0x5dab1f['push'](_0x5dab1f['shift']());}}}(a0_0x1277,0x74efa));import{EventEmitter as a0_0x293d8c}from'events';import{hostname as a0_0x458de4}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x29b2f8,_0x569852)=>(_0x29b2f8??_0x569852)[a0_0x15d04e(0x1d9)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x15d04e(0x1ea)](0x0,0xf0);function N(_0x159db5){const _0x1e8d27=a0_0x15d04e;return(_0x159db5 instanceof Error?_0x159db5[_0x1e8d27(0x172)]:String(_0x159db5??'unknown\x20error'))['replace'](K,_0x1e8d27(0x16f))[_0x1e8d27(0x1d9)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x1e8d27(0x1ea)](0x0,0xf0);}function O(_0x13f4f2,_0x724dfe=process.env.ANET_TASK_TRACE_FORMAT===a0_0x15d04e(0x188)){const _0x195916=a0_0x15d04e;if(_0x724dfe)return JSON[_0x195916(0x195)](_0x13f4f2);let _0x5152ae=L(_0x13f4f2[_0x195916(0x1be)],'<missing>'),_0x5b12e9=L(_0x13f4f2[_0x195916(0x19a)],_0x195916(0x1a5)),_0x7e6f56=_0x13f4f2[_0x195916(0x1b7)]?'\x20error='+_0x13f4f2['error_code']+':'+(_0x13f4f2[_0x195916(0x197)]??''):'';return _0x195916(0x1bb)+_0x13f4f2[_0x195916(0x173)]+_0x195916(0x170)+L(_0x13f4f2[_0x195916(0x1d6)],'<unknown>')+_0x195916(0x189)+L(_0x13f4f2[_0x195916(0x1e5)],_0x195916(0x1c7))+_0x195916(0x191)+_0x5b12e9+_0x195916(0x1a2)+_0x5152ae+'\x20network_id='+L(_0x13f4f2[_0x195916(0x17b)],_0x195916(0x1c7))+'\x20transport='+_0x13f4f2[_0x195916(0x1e1)]+_0x195916(0x1c0)+_0x13f4f2['duration_ms']+_0x195916(0x1de)+_0x13f4f2[_0x195916(0x1ad)]+_0x7e6f56;}function U(_0x27eed8){const _0x5927ff=a0_0x15d04e;return{'event':{'sending':_0x5927ff(0x1b8),'delivered':_0x5927ff(0x1b0),'failed':_0x5927ff(0x175),'acked':_0x5927ff(0x1bf),'started':_0x5927ff(0x1d1),'replied':_0x5927ff(0x1c6),'expired':'task.expired'}[_0x27eed8['status']],..._0x27eed8};}function j(_0x5f596c){const _0x27841c=a0_0x15d04e;let _0x50400f=_0x5f596c?.[_0x27841c(0x19a)]||_0x5f596c?.[_0x27841c(0x171)]||_0x5f596c?.['id'];if(_0x50400f)return String(_0x50400f);let _0x50f8f0=_0x5f596c?.[_0x27841c(0x1c4)]?.[0x0]?.[_0x27841c(0x1c1)];if(typeof _0x50f8f0!=='string')return null;try{let _0x1a1c99=JSON[_0x27841c(0x1a3)](_0x50f8f0);return _0x1a1c99?.[_0x27841c(0x19a)]||_0x1a1c99?.[_0x27841c(0x171)]||_0x1a1c99?.['id']||null;}catch{return null;}}async function X(_0x300f0d,_0x2a95de){const _0x28df19=a0_0x15d04e;let _0x3b5a52=_0x2a95de[_0x28df19(0x1e4)]??Date[_0x28df19(0x1e4)],_0x39a220=_0x3b5a52(),_0x47161f=(_0x499364,_0x19bdb3,_0x19a080,_0x418b8d)=>{const _0x1010bc=_0x28df19;_0x2a95de[_0x1010bc(0x185)](O(U({'from_alias':_0x300f0d[_0x1010bc(0x1c2)],'to_alias':_0x300f0d[_0x1010bc(0x1ba)],'task_id':_0x19bdb3,'parent_task_id':_0x300f0d[_0x1010bc(0x1c5)],'network_id':_0x300f0d[_0x1010bc(0x1a1)],'transport':_0x300f0d[_0x1010bc(0x1e1)],'status':_0x499364,'duration_ms':_0x3b5a52()-_0x39a220,'lifecycle_tracking':_0x300f0d[_0x1010bc(0x198)],..._0x19a080!==void 0x0?{'error_code':_0x418b8d||'send_failed','error_message':N(_0x19a080)}:{}})));};_0x47161f(_0x28df19(0x1c9),null);try{let _0x46bf0f=await _0x2a95de['send'](),_0x4ee81d=j(_0x46bf0f);if(_0x4ee81d)_0x47161f('delivered',_0x4ee81d);else{if(_0x46bf0f?.['ok']===!0x1||_0x46bf0f?.[_0x28df19(0x1d0)])_0x47161f('failed',_0x4ee81d,_0x46bf0f?.['error']||'CommHub\x20rejected\x20task',_0x28df19(0x1c3));else _0x47161f(_0x28df19(0x192),null,'CommHub\x20response\x20omitted\x20task_id','missing_task_id');}return _0x46bf0f;}catch(_0x50ca8d){throw _0x47161f('failed',null,_0x50ca8d,_0x28df19(0x1e8)),_0x50ca8d;}}function a0_0x1277(){const _0x3ea333=['type','\x20task_id=','failed','resumeId','data:\x20','stringify','min','error_message','lifecycleTracking','broadcast','task_id','Bearer\x20','token','connect','read','name','452940rpTDOP','networkId','\x20parent_task_id=','parse','13660479BGmlFu','<pending>','from_session','emit','signal','call','disconnected','2470410ZkwYza','connectSSE','lifecycle_tracking','normal','heartbeatInterval','task.send.delivered','completed','startsWith','8eCjDQq','2.0','131705pcVLAW','sleep','error_code','task.send.start','1848378vyMvEU','toAlias','[commhub:task]\x20','POST','idle','parent_task_id','task.ack','\x20duration_ms=','text','fromAlias','send_rejected','content','parentTaskId','task.replied','<unknown>','abort','sending','new_message','mcp_http','sdk','SSE\x20reconnecting\x20in\x20','/events/','connected','error','task.started','send','1949091pnVAbm',']\x20[commhub:','getAllStatus','from_alias','match','toTimeString','replace','SSE\x20connected','heartbeat\x20failed:\x20','reconnectDelay','agent','\x20lifecycle=','not_tracked','url','transport','ack_inbox','getReader','now','to_alias','body','send_reply','send_failed','registered','slice','SSE\x20failed:\x20','catch','[REDACTED]','\x20from=','message_id','message','status','inbox\x20error:\x20','task.send.failed','result','task','s...','new_task','get_inbox','network_id','sseAbort','tools/call','485208UYCQJh','cwd','heartbeatTimer','running','Authorization','send_task','7IiVMNN','log','SSE\x20error:\x20','sdk-','json','\x20to=','messages','server','processInbox','alias','/mcp','reply'];a0_0x1277=function(){return _0x3ea333;};return a0_0x1277();}async function Y(_0x536b46,_0x14838b){const _0x152032=a0_0x15d04e;return X({'fromAlias':_0x536b46[_0x152032(0x1c2)],'toAlias':_0x536b46[_0x152032(0x18d)],'parentTaskId':_0x536b46['parentTaskId']||null,'networkId':_0x536b46[_0x152032(0x1a1)]||null,'transport':_0x152032(0x1cb),'lifecycleTracking':_0x152032(0x1df)},_0x14838b);}class $ extends a0_0x293d8c{['url'];['alias'];[a0_0x15d04e(0x19c)];[a0_0x15d04e(0x1dd)];[a0_0x15d04e(0x193)];['heartbeatInterval'];[a0_0x15d04e(0x1dc)];['heartbeatTimer'];[a0_0x15d04e(0x17c)];[a0_0x15d04e(0x181)]=!0x1;constructor(_0x2ceb4a){const _0x3b8f3e=a0_0x15d04e;super();if(this['url']=_0x2ceb4a[_0x3b8f3e(0x1e0)][_0x3b8f3e(0x1d9)](/\/$/,''),this['alias']=_0x2ceb4a[_0x3b8f3e(0x18d)],this[_0x3b8f3e(0x19c)]=_0x2ceb4a[_0x3b8f3e(0x19c)],this[_0x3b8f3e(0x1dd)]=_0x2ceb4a['agent']||_0x3b8f3e(0x1cc),this[_0x3b8f3e(0x193)]=_0x3b8f3e(0x187)+_0x2ceb4a[_0x3b8f3e(0x18d)]+'-'+Date['now']()['toString'](0x24),this[_0x3b8f3e(0x1af)]=_0x2ceb4a['heartbeatInterval']??0x2bf20,this[_0x3b8f3e(0x1dc)]=_0x2ceb4a[_0x3b8f3e(0x1dc)]??0xbb8,_0x2ceb4a['autoConnect']!==!0x1)this[_0x3b8f3e(0x19d)]();}[a0_0x15d04e(0x185)](_0x1d2477){const _0x4684ae=a0_0x15d04e;console[_0x4684ae(0x185)]('['+new Date()[_0x4684ae(0x1d8)]()[_0x4684ae(0x1ea)](0x0,0x8)+_0x4684ae(0x1d4)+this['alias']+']\x20'+_0x1d2477);}async[a0_0x15d04e(0x1a9)](_0x3a2b84,_0x1fd039){const _0x261624=a0_0x15d04e;let _0x13c12f={'Content-Type':'application/json','Accept':'application/json,\x20text/event-stream'};if(this[_0x261624(0x19c)])_0x13c12f[_0x261624(0x182)]='Bearer\x20'+this['token'];let _0x5cdd46=await(await fetch(this[_0x261624(0x1e0)]+_0x261624(0x18e),{'method':_0x261624(0x1bc),'headers':_0x13c12f,'body':JSON[_0x261624(0x195)]({'jsonrpc':_0x261624(0x1b4),'id':Date[_0x261624(0x1e4)](),'method':_0x261624(0x17d),'params':{'name':_0x3a2b84,'arguments':_0x1fd039}})}))[_0x261624(0x1c1)](),_0x3937bc=_0x5cdd46[_0x261624(0x1d7)](/data: (.+)/),_0x59dc7e=_0x3937bc?JSON['parse'](_0x3937bc[0x1]):JSON[_0x261624(0x1a3)](_0x5cdd46),_0x3b2b18=_0x59dc7e?.[_0x261624(0x176)]?.['content']?.[0x0]?.[_0x261624(0x1c1)];return _0x3b2b18?JSON[_0x261624(0x1a3)](_0x3b2b18):_0x59dc7e;}async[a0_0x15d04e(0x19d)](){const _0x1ec597=a0_0x15d04e;if(this['running'])return;this['running']=!0x0,await this[_0x1ec597(0x173)](_0x1ec597(0x1bd)),this['log'](_0x1ec597(0x1e9)),this[_0x1ec597(0x180)]=setInterval(()=>{const _0x4916a8=_0x1ec597;this[_0x4916a8(0x173)](_0x4916a8(0x1bd))['catch'](_0x41cb59=>this[_0x4916a8(0x185)](_0x4916a8(0x1db)+_0x41cb59[_0x4916a8(0x172)]));},this[_0x1ec597(0x1af)]),this[_0x1ec597(0x1ac)]();}async['disconnect'](){const _0x27cf01=a0_0x15d04e;if(this[_0x27cf01(0x181)]=!0x1,this[_0x27cf01(0x17c)]?.[_0x27cf01(0x1c8)](),this[_0x27cf01(0x180)])clearInterval(this[_0x27cf01(0x180)]);await this['status']('offline')[_0x27cf01(0x16e)](()=>{}),this[_0x27cf01(0x185)](_0x27cf01(0x1aa));}async[a0_0x15d04e(0x1d2)](_0x191137,_0x35c471,_0x28cd92=a0_0x15d04e(0x1ae)){const _0x1ea79a=a0_0x15d04e;return Y({'alias':_0x191137,'fromAlias':this[_0x1ea79a(0x18d)]},{'log':_0x33e3bc=>console[_0x1ea79a(0x185)](_0x33e3bc),'send':()=>this[_0x1ea79a(0x1a9)](_0x1ea79a(0x183),{'alias':_0x191137,'task':_0x35c471,'priority':_0x28cd92,'from_session':this['alias']})});}async[a0_0x15d04e(0x172)](_0x34b7ca,_0x39366c){const _0x997a9e=a0_0x15d04e;return this[_0x997a9e(0x1a9)]('send_message',{'alias':_0x34b7ca,'message':_0x39366c,'from_session':this[_0x997a9e(0x18d)]});}async[a0_0x15d04e(0x18f)](_0x587c2c,_0x50a3a6,_0xbef49c=a0_0x15d04e(0x1b1)){const _0x598b6e=a0_0x15d04e;return this[_0x598b6e(0x1a9)](_0x598b6e(0x1e7),{'in_reply_to':_0x587c2c,'text':_0x50a3a6,'status':_0xbef49c});}async[a0_0x15d04e(0x173)](_0x223ea8,_0x496e84){const _0x15a59e=a0_0x15d04e;return this[_0x15a59e(0x1a9)]('report_status',{'resume_id':this[_0x15a59e(0x193)],'alias':this[_0x15a59e(0x18d)],'status':_0x223ea8,'server':a0_0x458de4(),'hostname':a0_0x458de4(),'agent':this[_0x15a59e(0x1dd)],'project_dir':process[_0x15a59e(0x17f)](),..._0x496e84});}async[a0_0x15d04e(0x1d5)](){const _0xb43964=a0_0x15d04e;return this[_0xb43964(0x1a9)]('get_all_status',{});}async[a0_0x15d04e(0x199)](_0x28b497,_0x67fed6){const _0x311df3=a0_0x15d04e;return this[_0x311df3(0x1a9)](_0x311df3(0x199),{'message':_0x28b497,'filter_server':_0x67fed6?.[_0x311df3(0x18b)],'filter_status':_0x67fed6?.[_0x311df3(0x173)]});}async[a0_0x15d04e(0x1ac)](){const _0x56a87f=a0_0x15d04e;let _0x5c6eb0=encodeURIComponent(this[_0x56a87f(0x18d)]),_0x36273b=this[_0x56a87f(0x1e0)]+_0x56a87f(0x1ce)+_0x5c6eb0,_0x32b7b7=this[_0x56a87f(0x1dc)];while(this[_0x56a87f(0x181)]){try{this['sseAbort']=new AbortController();let _0x205207={'Accept':'text/event-stream'};if(this[_0x56a87f(0x19c)])_0x205207[_0x56a87f(0x182)]=_0x56a87f(0x19b)+this[_0x56a87f(0x19c)];let _0x469ba5=await fetch(_0x36273b,{'headers':_0x205207,'signal':this['sseAbort'][_0x56a87f(0x1a8)]});if(!_0x469ba5['ok']||!_0x469ba5['body']){this[_0x56a87f(0x185)](_0x56a87f(0x16d)+_0x469ba5[_0x56a87f(0x173)]),await this[_0x56a87f(0x1b6)](_0x32b7b7),_0x32b7b7=Math['min'](_0x32b7b7*1.5,0xea60);continue;}_0x32b7b7=this[_0x56a87f(0x1dc)];let _0x5cc4d9=_0x469ba5[_0x56a87f(0x1e6)][_0x56a87f(0x1e3)](),_0xcfe664=new TextDecoder(),_0xab3674='';while(this['running']){let {done:_0x46419e,value:_0x12544d}=await _0x5cc4d9[_0x56a87f(0x19e)]();if(_0x46419e)break;_0xab3674+=_0xcfe664['decode'](_0x12544d,{'stream':!0x0});let _0x31f78b=_0xab3674['split']('\x0a');_0xab3674=_0x31f78b['pop']()||'';for(let _0x5e0df1 of _0x31f78b){if(!_0x5e0df1[_0x56a87f(0x1b2)](_0x56a87f(0x194)))continue;try{let _0x4c32bc=JSON[_0x56a87f(0x1a3)](_0x5e0df1[_0x56a87f(0x1ea)](0x6));if(_0x4c32bc[_0x56a87f(0x190)]==='connected'){this['log'](_0x56a87f(0x1da)),this[_0x56a87f(0x1a7)](_0x56a87f(0x1cf));continue;}if(_0x4c32bc[_0x56a87f(0x190)]===_0x56a87f(0x179)||_0x4c32bc['type']===_0x56a87f(0x1ca)||_0x4c32bc['type']===_0x56a87f(0x199))await this[_0x56a87f(0x18c)]();}catch{}}}}catch(_0x4ce3a6){if(_0x4ce3a6[_0x56a87f(0x19f)]==='AbortError')break;this['emit'](_0x56a87f(0x1d0),_0x4ce3a6),this['log'](_0x56a87f(0x186)+_0x4ce3a6[_0x56a87f(0x172)]);}if(this[_0x56a87f(0x181)])this[_0x56a87f(0x1a7)]('disconnected'),this[_0x56a87f(0x185)](_0x56a87f(0x1cd)+_0x32b7b7/0x3e8+_0x56a87f(0x178)),await this[_0x56a87f(0x1b6)](_0x32b7b7),_0x32b7b7=Math[_0x56a87f(0x196)](_0x32b7b7*1.5,0xea60);}}async[a0_0x15d04e(0x18c)](){const _0x146592=a0_0x15d04e;try{let _0xe851f9=(await this[_0x146592(0x1a9)](_0x146592(0x17a),{'alias':this[_0x146592(0x18d)],'limit':0xa}))?.[_0x146592(0x18a)]||[];for(let _0x327636 of _0xe851f9)await this[_0x146592(0x1a9)](_0x146592(0x1e2),{'alias':this[_0x146592(0x18d)],'message_id':_0x327636['id']}),this[_0x146592(0x185)]('←\x20'+_0x327636[_0x146592(0x1a6)]+':\x20'+_0x327636['content'][_0x146592(0x1ea)](0x0,0x3c)),this[_0x146592(0x1a7)](_0x146592(0x177),_0x327636),this[_0x146592(0x1a7)](_0x146592(0x172),_0x327636);}catch(_0x5c35d5){this[_0x146592(0x185)](_0x146592(0x174)+_0x5c35d5[_0x146592(0x172)]);}}['sleep'](_0x55af54){return new Promise(_0x145925=>setTimeout(_0x145925,_0x55af54));}}var F=$;export{F as default,$ as CommHub};