@sleep2agi/agent-network 2.3.0-preview.57 → 2.3.0-preview.59
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
|
-
const a0_0x2ae722=a0_0x2925;(function(_0x235250,_0x66340f){const _0x503e46=a0_0x2925,_0x52cf0a=_0x235250();while(!![]){try{const _0x47e17b=parseInt(_0x503e46(0x163))/0x1+-parseInt(_0x503e46(0x147))/0x2+parseInt(_0x503e46(0x19c))/0x3*(-parseInt(_0x503e46(0x17b))/0x4)+-parseInt(_0x503e46(0x14b))/0x5+parseInt(_0x503e46(0x17d))/0x6*(parseInt(_0x503e46(0x13e))/0x7)+-parseInt(_0x503e46(0x173))/0x8*(parseInt(_0x503e46(0x141))/0x9)+parseInt(_0x503e46(0x18d))/0xa;if(_0x47e17b===_0x66340f)break;else _0x52cf0a['push'](_0x52cf0a['shift']());}catch(_0x3e2e50){_0x52cf0a['push'](_0x52cf0a['shift']());}}}(a0_0x4856,0x5c92d));import{EventEmitter as a0_0x5b4647}from'events';import{hostname as a0_0x2bba5e}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x332912,_0x217727)=>(_0x332912??_0x217727)[a0_0x2ae722(0x175)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x3cf98b){const _0x396f66=a0_0x2ae722;return(_0x3cf98b instanceof Error?_0x3cf98b['message']:String(_0x3cf98b??_0x396f66(0x150)))[_0x396f66(0x175)](K,_0x396f66(0x19f))[_0x396f66(0x175)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x396f66(0x13d)](0x0,0xf0);}function a0_0x2925(_0x50f325,_0x26329f){_0x50f325=_0x50f325-0x126;const _0x485640=a0_0x4856();let _0x2925bb=_0x485640[_0x50f325];return _0x2925bb;}function a0_0x4856(){const _0x38242c=['sleep','Authorization','normal','560095JEcLIX','/events/','\x20duration_ms=','signal','\x20to=','CommHub\x20response\x20omitted\x20task_id','send_failed','/mcp','task.ack','heartbeat\x20failed:\x20','transport','task_id','sdk','reconnectDelay','url','stringify','160eDePhf','task.send.delivered','replace','POST','\x20lifecycle=','disconnect','heartbeatInterval','network_id','72328LUrTlT','2.0','6NbNKcI','parse','connect','connectSSE','text','match','decode','status','connected','<missing>','json','Bearer\x20','name','min','messages','error','4915810Iduewc','getReader','processInbox','idle','read','data:\x20','s...','duration_ms','string','now','task.expired','heartbeatTimer','task.send.failed','catch','send_task','6PjxEey','error_code','result','[REDACTED]','split','task','\x20transport=','registered','toAlias','completed','get_inbox','from_alias','resumeId','<unknown>','lifecycle_tracking','sseAbort','alias','abort','SSE\x20reconnecting\x20in\x20','sending','message','ack_inbox','\x20error=','sdk-','parentTaskId','from_session','\x20from=','call','new_message','running','startsWith','type',']\x20[commhub:','slice','2238362vzKXip','log','body','275895eXscin','new_task','reply','missing_task_id','\x20task_id=','get_all_status','100970nKcjZB','fromAlias','tools/call','task.replied','1462560MSGmbe','broadcast','task.send.start','send_reply','content','unknown\x20error','send','toString','agent','<pending>','not_tracked','token','disconnected','getAllStatus','failed','message_id','networkId','emit','report_status','error_message','\x20parent_task_id='];a0_0x4856=function(){return _0x38242c;};return a0_0x4856();}function O(_0x15d17f,_0x1d3bdb=process.env.ANET_TASK_TRACE_FORMAT===a0_0x2ae722(0x187)){const _0x4c62b7=a0_0x2ae722;if(_0x1d3bdb)return JSON[_0x4c62b7(0x172)](_0x15d17f);let _0x37123d=L(_0x15d17f['parent_task_id'],_0x4c62b7(0x186)),_0x3c055a=L(_0x15d17f['task_id'],_0x4c62b7(0x154)),_0x3c48a3=_0x15d17f[_0x4c62b7(0x19d)]?_0x4c62b7(0x132)+_0x15d17f[_0x4c62b7(0x19d)]+':'+(_0x15d17f[_0x4c62b7(0x15e)]??''):'';return'[commhub:task]\x20'+_0x15d17f[_0x4c62b7(0x184)]+_0x4c62b7(0x136)+L(_0x15d17f[_0x4c62b7(0x127)],_0x4c62b7(0x129))+_0x4c62b7(0x167)+L(_0x15d17f['to_alias'],_0x4c62b7(0x129))+_0x4c62b7(0x145)+_0x3c055a+_0x4c62b7(0x15f)+_0x37123d+'\x20network_id='+L(_0x15d17f[_0x4c62b7(0x17a)],_0x4c62b7(0x129))+_0x4c62b7(0x1a2)+_0x15d17f[_0x4c62b7(0x16d)]+_0x4c62b7(0x165)+_0x15d17f[_0x4c62b7(0x194)]+_0x4c62b7(0x177)+_0x15d17f[_0x4c62b7(0x12a)]+_0x3c48a3;}function U(_0x47b25f){const _0x124ffb=a0_0x2ae722;return{'event':{'sending':_0x124ffb(0x14d),'delivered':_0x124ffb(0x174),'failed':_0x124ffb(0x199),'acked':_0x124ffb(0x16b),'started':'task.started','replied':_0x124ffb(0x14a),'expired':_0x124ffb(0x197)}[_0x47b25f[_0x124ffb(0x184)]],..._0x47b25f};}function j(_0x46e59b){const _0x34575f=a0_0x2ae722;let _0x117985=_0x46e59b?.[_0x34575f(0x16e)]||_0x46e59b?.[_0x34575f(0x15a)]||_0x46e59b?.['id'];if(_0x117985)return String(_0x117985);let _0x48cc1e=_0x46e59b?.[_0x34575f(0x14f)]?.[0x0]?.[_0x34575f(0x181)];if(typeof _0x48cc1e!==_0x34575f(0x195))return null;try{let _0x46c190=JSON['parse'](_0x48cc1e);return _0x46c190?.[_0x34575f(0x16e)]||_0x46c190?.[_0x34575f(0x15a)]||_0x46c190?.['id']||null;}catch{return null;}}async function X(_0x42c791,_0x4e3a0c){const _0x33d2b0=a0_0x2ae722;let _0x2b06f3=_0x4e3a0c['now']??Date[_0x33d2b0(0x196)],_0x78dbf4=_0x2b06f3(),_0xbe356a=(_0x31080e,_0x319726,_0x42f9fc,_0x486cbf)=>{const _0x488e13=_0x33d2b0;_0x4e3a0c['log'](O(U({'from_alias':_0x42c791[_0x488e13(0x148)],'to_alias':_0x42c791[_0x488e13(0x1a4)],'task_id':_0x319726,'parent_task_id':_0x42c791[_0x488e13(0x134)],'network_id':_0x42c791[_0x488e13(0x15b)],'transport':_0x42c791['transport'],'status':_0x31080e,'duration_ms':_0x2b06f3()-_0x78dbf4,'lifecycle_tracking':_0x42c791['lifecycleTracking'],..._0x42f9fc!==void 0x0?{'error_code':_0x486cbf||_0x488e13(0x169),'error_message':N(_0x42f9fc)}:{}})));};_0xbe356a(_0x33d2b0(0x12f),null);try{let _0x3a26bd=await _0x4e3a0c[_0x33d2b0(0x151)](),_0x2f4e74=j(_0x3a26bd);if(_0x2f4e74)_0xbe356a('delivered',_0x2f4e74);else{if(_0x3a26bd?.['ok']===!0x1||_0x3a26bd?.[_0x33d2b0(0x18c)])_0xbe356a(_0x33d2b0(0x159),_0x2f4e74,_0x3a26bd?.[_0x33d2b0(0x18c)]||'CommHub\x20rejected\x20task','send_rejected');else _0xbe356a(_0x33d2b0(0x159),null,_0x33d2b0(0x168),_0x33d2b0(0x144));}return _0x3a26bd;}catch(_0x106895){throw _0xbe356a(_0x33d2b0(0x159),null,_0x106895,_0x33d2b0(0x169)),_0x106895;}}async function Y(_0x1db13d,_0xbe1276){const _0x8f63d0=a0_0x2ae722;return X({'fromAlias':_0x1db13d['fromAlias'],'toAlias':_0x1db13d[_0x8f63d0(0x12c)],'parentTaskId':_0x1db13d[_0x8f63d0(0x134)]||null,'networkId':_0x1db13d['networkId']||null,'transport':'mcp_http','lifecycleTracking':_0x8f63d0(0x155)},_0xbe1276);}class $ extends a0_0x5b4647{['url'];[a0_0x2ae722(0x12c)];[a0_0x2ae722(0x156)];['agent'];[a0_0x2ae722(0x128)];[a0_0x2ae722(0x179)];[a0_0x2ae722(0x170)];[a0_0x2ae722(0x198)];[a0_0x2ae722(0x12b)];['running']=!0x1;constructor(_0x382b75){const _0x4eb987=a0_0x2ae722;super();if(this[_0x4eb987(0x171)]=_0x382b75[_0x4eb987(0x171)]['replace'](/\/$/,''),this[_0x4eb987(0x12c)]=_0x382b75[_0x4eb987(0x12c)],this['token']=_0x382b75[_0x4eb987(0x156)],this[_0x4eb987(0x153)]=_0x382b75[_0x4eb987(0x153)]||_0x4eb987(0x16f),this['resumeId']=_0x4eb987(0x133)+_0x382b75[_0x4eb987(0x12c)]+'-'+Date[_0x4eb987(0x196)]()[_0x4eb987(0x152)](0x24),this[_0x4eb987(0x179)]=_0x382b75['heartbeatInterval']??0x2bf20,this[_0x4eb987(0x170)]=_0x382b75[_0x4eb987(0x170)]??0xbb8,_0x382b75['autoConnect']!==!0x1)this[_0x4eb987(0x17f)]();}['log'](_0x15ed98){const _0x23b6e3=a0_0x2ae722;console['log']('['+new Date()['toTimeString']()[_0x23b6e3(0x13d)](0x0,0x8)+_0x23b6e3(0x13c)+this[_0x23b6e3(0x12c)]+']\x20'+_0x15ed98);}async[a0_0x2ae722(0x137)](_0x4db90c,_0x119f10){const _0x2d4ae1=a0_0x2ae722;let _0x2ad79b={'Content-Type':'application/json','Accept':'application/json,\x20text/event-stream'};if(this['token'])_0x2ad79b[_0x2d4ae1(0x161)]=_0x2d4ae1(0x188)+this[_0x2d4ae1(0x156)];let _0x3d4373=await(await fetch(this['url']+_0x2d4ae1(0x16a),{'method':_0x2d4ae1(0x176),'headers':_0x2ad79b,'body':JSON['stringify']({'jsonrpc':_0x2d4ae1(0x17c),'id':Date['now'](),'method':_0x2d4ae1(0x149),'params':{'name':_0x4db90c,'arguments':_0x119f10}})}))[_0x2d4ae1(0x181)](),_0x5339f8=_0x3d4373[_0x2d4ae1(0x182)](/data: (.+)/),_0x3396fa=_0x5339f8?JSON[_0x2d4ae1(0x17e)](_0x5339f8[0x1]):JSON[_0x2d4ae1(0x17e)](_0x3d4373),_0x2fcdbd=_0x3396fa?.[_0x2d4ae1(0x19e)]?.['content']?.[0x0]?.[_0x2d4ae1(0x181)];return _0x2fcdbd?JSON[_0x2d4ae1(0x17e)](_0x2fcdbd):_0x3396fa;}async[a0_0x2ae722(0x17f)](){const _0x317362=a0_0x2ae722;if(this[_0x317362(0x139)])return;this[_0x317362(0x139)]=!0x0,await this['status'](_0x317362(0x190)),this[_0x317362(0x13f)](_0x317362(0x1a3)),this[_0x317362(0x198)]=setInterval(()=>{const _0x16c07d=_0x317362;this['status'](_0x16c07d(0x190))[_0x16c07d(0x19a)](_0x76bb1b=>this[_0x16c07d(0x13f)](_0x16c07d(0x16c)+_0x76bb1b['message']));},this[_0x317362(0x179)]),this['connectSSE']();}async[a0_0x2ae722(0x178)](){const _0x499078=a0_0x2ae722;if(this[_0x499078(0x139)]=!0x1,this[_0x499078(0x12b)]?.[_0x499078(0x12d)](),this[_0x499078(0x198)])clearInterval(this[_0x499078(0x198)]);await this[_0x499078(0x184)]('offline')['catch'](()=>{}),this[_0x499078(0x13f)]('disconnected');}async['send'](_0xcd9ed,_0x140e72,_0x3f1442=a0_0x2ae722(0x162)){const _0x3649c8=a0_0x2ae722;return Y({'alias':_0xcd9ed,'fromAlias':this[_0x3649c8(0x12c)]},{'log':_0x36c0e8=>console[_0x3649c8(0x13f)](_0x36c0e8),'send':()=>this[_0x3649c8(0x137)](_0x3649c8(0x19b),{'alias':_0xcd9ed,'task':_0x140e72,'priority':_0x3f1442,'from_session':this[_0x3649c8(0x12c)]})});}async[a0_0x2ae722(0x130)](_0x428b16,_0x5ba99d){const _0x58effd=a0_0x2ae722;return this[_0x58effd(0x137)]('send_message',{'alias':_0x428b16,'message':_0x5ba99d,'from_session':this[_0x58effd(0x12c)]});}async[a0_0x2ae722(0x143)](_0xae8b11,_0x47f426,_0x55234b=a0_0x2ae722(0x1a5)){const _0xa86521=a0_0x2ae722;return this['call'](_0xa86521(0x14e),{'in_reply_to':_0xae8b11,'text':_0x47f426,'status':_0x55234b});}async['status'](_0x171006,_0x393fee){const _0xd89338=a0_0x2ae722;return this['call'](_0xd89338(0x15d),{'resume_id':this[_0xd89338(0x128)],'alias':this[_0xd89338(0x12c)],'status':_0x171006,'server':a0_0x2bba5e(),'hostname':a0_0x2bba5e(),'agent':this['agent'],'project_dir':process['cwd'](),..._0x393fee});}async[a0_0x2ae722(0x158)](){const _0x5049ca=a0_0x2ae722;return this[_0x5049ca(0x137)](_0x5049ca(0x146),{});}async[a0_0x2ae722(0x14c)](_0x2e8253,_0xf28c57){const _0x261271=a0_0x2ae722;return this[_0x261271(0x137)](_0x261271(0x14c),{'message':_0x2e8253,'filter_server':_0xf28c57?.['server'],'filter_status':_0xf28c57?.['status']});}async[a0_0x2ae722(0x180)](){const _0x3fcb79=a0_0x2ae722;let _0x152822=encodeURIComponent(this[_0x3fcb79(0x12c)]),_0x388495=this['url']+_0x3fcb79(0x164)+_0x152822,_0x2419c2=this[_0x3fcb79(0x170)];while(this['running']){try{this[_0x3fcb79(0x12b)]=new AbortController();let _0x2ecfc2={'Accept':'text/event-stream'};if(this[_0x3fcb79(0x156)])_0x2ecfc2[_0x3fcb79(0x161)]='Bearer\x20'+this['token'];let _0x38ab48=await fetch(_0x388495,{'headers':_0x2ecfc2,'signal':this['sseAbort'][_0x3fcb79(0x166)]});if(!_0x38ab48['ok']||!_0x38ab48[_0x3fcb79(0x140)]){this[_0x3fcb79(0x13f)]('SSE\x20failed:\x20'+_0x38ab48['status']),await this[_0x3fcb79(0x160)](_0x2419c2),_0x2419c2=Math[_0x3fcb79(0x18a)](_0x2419c2*1.5,0xea60);continue;}_0x2419c2=this[_0x3fcb79(0x170)];let _0x3248a9=_0x38ab48['body'][_0x3fcb79(0x18e)](),_0x2dc81e=new TextDecoder(),_0x135d75='';while(this['running']){let {done:_0x18ce6f,value:_0x30721b}=await _0x3248a9[_0x3fcb79(0x191)]();if(_0x18ce6f)break;_0x135d75+=_0x2dc81e[_0x3fcb79(0x183)](_0x30721b,{'stream':!0x0});let _0x16db81=_0x135d75[_0x3fcb79(0x1a0)]('\x0a');_0x135d75=_0x16db81['pop']()||'';for(let _0x293db3 of _0x16db81){if(!_0x293db3[_0x3fcb79(0x13a)](_0x3fcb79(0x192)))continue;try{let _0x2e3964=JSON[_0x3fcb79(0x17e)](_0x293db3[_0x3fcb79(0x13d)](0x6));if(_0x2e3964[_0x3fcb79(0x13b)]===_0x3fcb79(0x185)){this[_0x3fcb79(0x13f)]('SSE\x20connected'),this['emit'](_0x3fcb79(0x185));continue;}if(_0x2e3964[_0x3fcb79(0x13b)]===_0x3fcb79(0x142)||_0x2e3964['type']===_0x3fcb79(0x138)||_0x2e3964['type']===_0x3fcb79(0x14c))await this[_0x3fcb79(0x18f)]();}catch{}}}}catch(_0x2f10d2){if(_0x2f10d2[_0x3fcb79(0x189)]==='AbortError')break;this['emit']('error',_0x2f10d2),this[_0x3fcb79(0x13f)]('SSE\x20error:\x20'+_0x2f10d2[_0x3fcb79(0x130)]);}if(this[_0x3fcb79(0x139)])this[_0x3fcb79(0x15c)](_0x3fcb79(0x157)),this[_0x3fcb79(0x13f)](_0x3fcb79(0x12e)+_0x2419c2/0x3e8+_0x3fcb79(0x193)),await this[_0x3fcb79(0x160)](_0x2419c2),_0x2419c2=Math[_0x3fcb79(0x18a)](_0x2419c2*1.5,0xea60);}}async[a0_0x2ae722(0x18f)](){const _0x18addf=a0_0x2ae722;try{let _0x12d988=(await this[_0x18addf(0x137)](_0x18addf(0x126),{'alias':this['alias'],'limit':0xa}))?.[_0x18addf(0x18b)]||[];for(let _0x306c6f of _0x12d988)await this['call'](_0x18addf(0x131),{'alias':this[_0x18addf(0x12c)],'message_id':_0x306c6f['id']}),this['log']('←\x20'+_0x306c6f[_0x18addf(0x135)]+':\x20'+_0x306c6f[_0x18addf(0x14f)][_0x18addf(0x13d)](0x0,0x3c)),this[_0x18addf(0x15c)](_0x18addf(0x1a1),_0x306c6f),this['emit'](_0x18addf(0x130),_0x306c6f);}catch(_0xd96aa2){this[_0x18addf(0x13f)]('inbox\x20error:\x20'+_0xd96aa2[_0x18addf(0x130)]);}}[a0_0x2ae722(0x160)](_0x5df466){return new Promise(_0x3e6d7c=>setTimeout(_0x3e6d7c,_0x5df466));}}var F=$;export{F as default,$ as CommHub};
|
|
1
|
+
function a0_0x23d2(){const _0x4e4822=['241971poecfx',']\x20[commhub:','message_id','name','task.ack','117GGJtQz','Authorization','connectSSE','AbortError','match','missing_task_id','task.send.failed','s...','split','parent_task_id','processInbox','not_tracked','task','replace','connect','\x20to=','toAlias','from_alias','duration_ms','get_all_status','\x20duration_ms=','\x20from=','489935wgIIrB','18yMlFHm','send_failed','sdk','task.send.delivered','parse','\x20error=','POST','142888hGavnP','result','cwd','Bearer\x20','<pending>','sseAbort','alias','url','task_id','heartbeat\x20failed:\x20','networkId','task.send.start','reply','303648yJuUob','ack_inbox','/mcp','heartbeatInterval','slice','emit','transport','toString','toTimeString','type','read','error','data:\x20','send_task','inbox\x20error:\x20','error_code','unknown\x20error','string','error_message','send','get_inbox','signal','now','text','CommHub\x20rejected\x20task','pop','812yFEKdg','log','failed','new_task','sdk-','application/json','stringify','connected','content','task.replied','tools/call','status','call','\x20network_id=','2.0','send_reply','running','messages','normal','send_rejected','from_session','agent','completed','catch','json','15816yQmtfg','abort','<unknown>','task.expired','1879048KNVpRy','idle','\x20parent_task_id=','message','[commhub:task]\x20','reconnectDelay','broadcast','SSE\x20failed:\x20','token','sleep','\x20task_id=','fromAlias','getReader','<missing>','\x20transport=','heartbeatTimer','send_message','disconnect','278990pdyjRX','resumeId','body','getAllStatus'];a0_0x23d2=function(){return _0x4e4822;};return a0_0x23d2();}const a0_0x3a1a12=a0_0x5835;(function(_0x1d3698,_0x4a55f1){const _0x2b08f0=a0_0x5835,_0x337343=_0x1d3698();while(!![]){try{const _0x623e60=-parseInt(_0x2b08f0(0x177))/0x1+-parseInt(_0x2b08f0(0x1a7))/0x2+-parseInt(_0x2b08f0(0x193))/0x3*(-parseInt(_0x2b08f0(0x19a))/0x4)+-parseInt(_0x2b08f0(0x192))/0x5+parseInt(_0x2b08f0(0x15d))/0x6*(parseInt(_0x2b08f0(0x1c1))/0x7)+-parseInt(_0x2b08f0(0x161))/0x8+parseInt(_0x2b08f0(0x17c))/0x9*(parseInt(_0x2b08f0(0x173))/0xa);if(_0x623e60===_0x4a55f1)break;else _0x337343['push'](_0x337343['shift']());}catch(_0x4461bc){_0x337343['push'](_0x337343['shift']());}}}(a0_0x23d2,0x261e4));import{EventEmitter as a0_0x5daa22}from'events';import{hostname as a0_0x464838}from'os';function a0_0x5835(_0x957e00,_0x566d9f){_0x957e00=_0x957e00-0x148;const _0x23d2d3=a0_0x23d2();let _0x583538=_0x23d2d3[_0x957e00];return _0x583538;}var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x4b51a8,_0x4d93bb)=>(_0x4b51a8??_0x4d93bb)[a0_0x3a1a12(0x189)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x3a1a12(0x1ab)](0x0,0xf0);function N(_0xdbc7f0){const _0x1d8edf=a0_0x3a1a12;return(_0xdbc7f0 instanceof Error?_0xdbc7f0[_0x1d8edf(0x164)]:String(_0xdbc7f0??_0x1d8edf(0x1b7)))[_0x1d8edf(0x189)](K,'[REDACTED]')[_0x1d8edf(0x189)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x1d8edf(0x1ab)](0x0,0xf0);}function O(_0xd67bf7,_0xadf39f=process.env.ANET_TASK_TRACE_FORMAT===a0_0x3a1a12(0x15c)){const _0x463e0a=a0_0x3a1a12;if(_0xadf39f)return JSON[_0x463e0a(0x14a)](_0xd67bf7);let _0x3bac33=L(_0xd67bf7[_0x463e0a(0x185)],_0x463e0a(0x16e)),_0x53ca24=L(_0xd67bf7[_0x463e0a(0x1a2)],_0x463e0a(0x19e)),_0x535b30=_0xd67bf7['error_code']?_0x463e0a(0x198)+_0xd67bf7[_0x463e0a(0x1b6)]+':'+(_0xd67bf7[_0x463e0a(0x1b9)]??''):'';return _0x463e0a(0x165)+_0xd67bf7[_0x463e0a(0x14f)]+_0x463e0a(0x191)+L(_0xd67bf7[_0x463e0a(0x18d)],_0x463e0a(0x15f))+_0x463e0a(0x18b)+L(_0xd67bf7['to_alias'],'<unknown>')+_0x463e0a(0x16b)+_0x53ca24+_0x463e0a(0x163)+_0x3bac33+_0x463e0a(0x151)+L(_0xd67bf7['network_id'],_0x463e0a(0x15f))+_0x463e0a(0x16f)+_0xd67bf7[_0x463e0a(0x1ad)]+_0x463e0a(0x190)+_0xd67bf7[_0x463e0a(0x18e)]+'\x20lifecycle='+_0xd67bf7['lifecycle_tracking']+_0x535b30;}function U(_0x3a0a81){const _0x417d9b=a0_0x3a1a12;return{'event':{'sending':_0x417d9b(0x1a5),'delivered':_0x417d9b(0x196),'failed':_0x417d9b(0x182),'acked':_0x417d9b(0x17b),'started':'task.started','replied':_0x417d9b(0x14d),'expired':_0x417d9b(0x160)}[_0x3a0a81[_0x417d9b(0x14f)]],..._0x3a0a81};}function j(_0x1b8d8d){const _0x32eac6=a0_0x3a1a12;let _0x433685=_0x1b8d8d?.[_0x32eac6(0x1a2)]||_0x1b8d8d?.[_0x32eac6(0x179)]||_0x1b8d8d?.['id'];if(_0x433685)return String(_0x433685);let _0x1232c4=_0x1b8d8d?.[_0x32eac6(0x14c)]?.[0x0]?.[_0x32eac6(0x1be)];if(typeof _0x1232c4!==_0x32eac6(0x1b8))return null;try{let _0x2a8f64=JSON[_0x32eac6(0x197)](_0x1232c4);return _0x2a8f64?.[_0x32eac6(0x1a2)]||_0x2a8f64?.[_0x32eac6(0x179)]||_0x2a8f64?.['id']||null;}catch{return null;}}async function X(_0x301e56,_0x30f01f){const _0x4eac14=a0_0x3a1a12;let _0x40f3a9=_0x30f01f['now']??Date[_0x4eac14(0x1bd)],_0x56f9c1=_0x40f3a9(),_0x4f7d48=(_0x1653e2,_0x320f0b,_0x52d10f,_0x3d33fa)=>{const _0x5dfc6c=_0x4eac14;_0x30f01f['log'](O(U({'from_alias':_0x301e56[_0x5dfc6c(0x16c)],'to_alias':_0x301e56[_0x5dfc6c(0x18c)],'task_id':_0x320f0b,'parent_task_id':_0x301e56['parentTaskId'],'network_id':_0x301e56[_0x5dfc6c(0x1a4)],'transport':_0x301e56[_0x5dfc6c(0x1ad)],'status':_0x1653e2,'duration_ms':_0x40f3a9()-_0x56f9c1,'lifecycle_tracking':_0x301e56['lifecycleTracking'],..._0x52d10f!==void 0x0?{'error_code':_0x3d33fa||_0x5dfc6c(0x194),'error_message':N(_0x52d10f)}:{}})));};_0x4f7d48('sending',null);try{let _0x296e25=await _0x30f01f[_0x4eac14(0x1ba)](),_0x3a84da=j(_0x296e25);if(_0x3a84da)_0x4f7d48('delivered',_0x3a84da);else{if(_0x296e25?.['ok']===!0x1||_0x296e25?.[_0x4eac14(0x1b2)])_0x4f7d48('failed',_0x3a84da,_0x296e25?.[_0x4eac14(0x1b2)]||_0x4eac14(0x1bf),_0x4eac14(0x157));else _0x4f7d48(_0x4eac14(0x1c3),null,'CommHub\x20response\x20omitted\x20task_id',_0x4eac14(0x181));}return _0x296e25;}catch(_0xef5415){throw _0x4f7d48(_0x4eac14(0x1c3),null,_0xef5415,'send_failed'),_0xef5415;}}async function Y(_0x5a0d20,_0x2ca76d){const _0x594551=a0_0x3a1a12;return X({'fromAlias':_0x5a0d20['fromAlias'],'toAlias':_0x5a0d20[_0x594551(0x1a0)],'parentTaskId':_0x5a0d20['parentTaskId']||null,'networkId':_0x5a0d20[_0x594551(0x1a4)]||null,'transport':'mcp_http','lifecycleTracking':_0x594551(0x187)},_0x2ca76d);}class $ extends a0_0x5daa22{[a0_0x3a1a12(0x1a1)];[a0_0x3a1a12(0x1a0)];['token'];['agent'];[a0_0x3a1a12(0x174)];['heartbeatInterval'];['reconnectDelay'];[a0_0x3a1a12(0x170)];[a0_0x3a1a12(0x19f)];[a0_0x3a1a12(0x154)]=!0x1;constructor(_0x2cd5ac){const _0x13af5c=a0_0x3a1a12;super();if(this[_0x13af5c(0x1a1)]=_0x2cd5ac[_0x13af5c(0x1a1)][_0x13af5c(0x189)](/\/$/,''),this[_0x13af5c(0x1a0)]=_0x2cd5ac[_0x13af5c(0x1a0)],this[_0x13af5c(0x169)]=_0x2cd5ac[_0x13af5c(0x169)],this['agent']=_0x2cd5ac[_0x13af5c(0x159)]||_0x13af5c(0x195),this[_0x13af5c(0x174)]=_0x13af5c(0x148)+_0x2cd5ac[_0x13af5c(0x1a0)]+'-'+Date[_0x13af5c(0x1bd)]()[_0x13af5c(0x1ae)](0x24),this['heartbeatInterval']=_0x2cd5ac[_0x13af5c(0x1aa)]??0x2bf20,this['reconnectDelay']=_0x2cd5ac[_0x13af5c(0x166)]??0xbb8,_0x2cd5ac['autoConnect']!==!0x1)this[_0x13af5c(0x18a)]();}[a0_0x3a1a12(0x1c2)](_0x234469){const _0x3d67a9=a0_0x3a1a12;console[_0x3d67a9(0x1c2)]('['+new Date()[_0x3d67a9(0x1af)]()[_0x3d67a9(0x1ab)](0x0,0x8)+_0x3d67a9(0x178)+this[_0x3d67a9(0x1a0)]+']\x20'+_0x234469);}async[a0_0x3a1a12(0x150)](_0x42d950,_0x2b811e){const _0x136537=a0_0x3a1a12;let _0x4d5081={'Content-Type':_0x136537(0x149),'Accept':'application/json,\x20text/event-stream'};if(this[_0x136537(0x169)])_0x4d5081[_0x136537(0x17d)]=_0x136537(0x19d)+this[_0x136537(0x169)];let _0x5e3d4a=await(await fetch(this[_0x136537(0x1a1)]+_0x136537(0x1a9),{'method':_0x136537(0x199),'headers':_0x4d5081,'body':JSON[_0x136537(0x14a)]({'jsonrpc':_0x136537(0x152),'id':Date[_0x136537(0x1bd)](),'method':_0x136537(0x14e),'params':{'name':_0x42d950,'arguments':_0x2b811e}})}))[_0x136537(0x1be)](),_0x3b43fc=_0x5e3d4a[_0x136537(0x180)](/data: (.+)/),_0x509fcc=_0x3b43fc?JSON[_0x136537(0x197)](_0x3b43fc[0x1]):JSON[_0x136537(0x197)](_0x5e3d4a),_0x390b97=_0x509fcc?.[_0x136537(0x19b)]?.[_0x136537(0x14c)]?.[0x0]?.[_0x136537(0x1be)];return _0x390b97?JSON[_0x136537(0x197)](_0x390b97):_0x509fcc;}async[a0_0x3a1a12(0x18a)](){const _0x145218=a0_0x3a1a12;if(this[_0x145218(0x154)])return;this[_0x145218(0x154)]=!0x0,await this['status'](_0x145218(0x162)),this[_0x145218(0x1c2)]('registered'),this['heartbeatTimer']=setInterval(()=>{const _0x5cd84c=_0x145218;this[_0x5cd84c(0x14f)](_0x5cd84c(0x162))[_0x5cd84c(0x15b)](_0x4b4778=>this[_0x5cd84c(0x1c2)](_0x5cd84c(0x1a3)+_0x4b4778[_0x5cd84c(0x164)]));},this['heartbeatInterval']),this[_0x145218(0x17e)]();}async[a0_0x3a1a12(0x172)](){const _0x3b45b7=a0_0x3a1a12;if(this[_0x3b45b7(0x154)]=!0x1,this[_0x3b45b7(0x19f)]?.[_0x3b45b7(0x15e)](),this['heartbeatTimer'])clearInterval(this[_0x3b45b7(0x170)]);await this['status']('offline')['catch'](()=>{}),this[_0x3b45b7(0x1c2)]('disconnected');}async[a0_0x3a1a12(0x1ba)](_0x291bb9,_0x47b85f,_0x504cd2=a0_0x3a1a12(0x156)){const _0x3f8ca4=a0_0x3a1a12;return Y({'alias':_0x291bb9,'fromAlias':this[_0x3f8ca4(0x1a0)]},{'log':_0xa65b0b=>console[_0x3f8ca4(0x1c2)](_0xa65b0b),'send':()=>this['call'](_0x3f8ca4(0x1b4),{'alias':_0x291bb9,'task':_0x47b85f,'priority':_0x504cd2,'from_session':this['alias']})});}async[a0_0x3a1a12(0x164)](_0x4cff8e,_0x26288e){const _0x546899=a0_0x3a1a12;return this['call'](_0x546899(0x171),{'alias':_0x4cff8e,'message':_0x26288e,'from_session':this[_0x546899(0x1a0)]});}async[a0_0x3a1a12(0x1a6)](_0x2545a8,_0x3b3ae4,_0x211b97=a0_0x3a1a12(0x15a)){const _0x1e02d4=a0_0x3a1a12;return this[_0x1e02d4(0x150)](_0x1e02d4(0x153),{'in_reply_to':_0x2545a8,'text':_0x3b3ae4,'status':_0x211b97});}async['status'](_0x2deebb,_0x55bd25){const _0x21f269=a0_0x3a1a12;return this[_0x21f269(0x150)]('report_status',{'resume_id':this[_0x21f269(0x174)],'alias':this[_0x21f269(0x1a0)],'status':_0x2deebb,'server':a0_0x464838(),'hostname':a0_0x464838(),'agent':this[_0x21f269(0x159)],'project_dir':process[_0x21f269(0x19c)](),..._0x55bd25});}async[a0_0x3a1a12(0x176)](){const _0x1522cd=a0_0x3a1a12;return this[_0x1522cd(0x150)](_0x1522cd(0x18f),{});}async[a0_0x3a1a12(0x167)](_0x4d93fc,_0x3931bb){const _0x3b1ce5=a0_0x3a1a12;return this[_0x3b1ce5(0x150)](_0x3b1ce5(0x167),{'message':_0x4d93fc,'filter_server':_0x3931bb?.['server'],'filter_status':_0x3931bb?.[_0x3b1ce5(0x14f)]});}async[a0_0x3a1a12(0x17e)](){const _0x9d9aa7=a0_0x3a1a12;let _0x52bbfb=encodeURIComponent(this['alias']),_0x1e2838=this['url']+'/events/'+_0x52bbfb,_0x5ba814=this[_0x9d9aa7(0x166)];while(this[_0x9d9aa7(0x154)]){try{this[_0x9d9aa7(0x19f)]=new AbortController();let _0x486b19={'Accept':'text/event-stream'};if(this['token'])_0x486b19[_0x9d9aa7(0x17d)]=_0x9d9aa7(0x19d)+this[_0x9d9aa7(0x169)];let _0x3cd090=await fetch(_0x1e2838,{'headers':_0x486b19,'signal':this[_0x9d9aa7(0x19f)][_0x9d9aa7(0x1bc)]});if(!_0x3cd090['ok']||!_0x3cd090['body']){this['log'](_0x9d9aa7(0x168)+_0x3cd090['status']),await this[_0x9d9aa7(0x16a)](_0x5ba814),_0x5ba814=Math['min'](_0x5ba814*1.5,0xea60);continue;}_0x5ba814=this[_0x9d9aa7(0x166)];let _0x5e0263=_0x3cd090[_0x9d9aa7(0x175)][_0x9d9aa7(0x16d)](),_0xeb3238=new TextDecoder(),_0x5e7e13='';while(this['running']){let {done:_0x42ecc4,value:_0x5524ec}=await _0x5e0263[_0x9d9aa7(0x1b1)]();if(_0x42ecc4)break;_0x5e7e13+=_0xeb3238['decode'](_0x5524ec,{'stream':!0x0});let _0x32283a=_0x5e7e13[_0x9d9aa7(0x184)]('\x0a');_0x5e7e13=_0x32283a[_0x9d9aa7(0x1c0)]()||'';for(let _0x25f5c1 of _0x32283a){if(!_0x25f5c1['startsWith'](_0x9d9aa7(0x1b3)))continue;try{let _0x4df8be=JSON[_0x9d9aa7(0x197)](_0x25f5c1['slice'](0x6));if(_0x4df8be[_0x9d9aa7(0x1b0)]===_0x9d9aa7(0x14b)){this['log']('SSE\x20connected'),this[_0x9d9aa7(0x1ac)]('connected');continue;}if(_0x4df8be[_0x9d9aa7(0x1b0)]===_0x9d9aa7(0x1c4)||_0x4df8be[_0x9d9aa7(0x1b0)]==='new_message'||_0x4df8be['type']===_0x9d9aa7(0x167))await this[_0x9d9aa7(0x186)]();}catch{}}}}catch(_0x214f77){if(_0x214f77[_0x9d9aa7(0x17a)]===_0x9d9aa7(0x17f))break;this[_0x9d9aa7(0x1ac)](_0x9d9aa7(0x1b2),_0x214f77),this[_0x9d9aa7(0x1c2)]('SSE\x20error:\x20'+_0x214f77[_0x9d9aa7(0x164)]);}if(this[_0x9d9aa7(0x154)])this[_0x9d9aa7(0x1ac)]('disconnected'),this[_0x9d9aa7(0x1c2)]('SSE\x20reconnecting\x20in\x20'+_0x5ba814/0x3e8+_0x9d9aa7(0x183)),await this[_0x9d9aa7(0x16a)](_0x5ba814),_0x5ba814=Math['min'](_0x5ba814*1.5,0xea60);}}async['processInbox'](){const _0x1776dc=a0_0x3a1a12;try{let _0x5d756f=(await this['call'](_0x1776dc(0x1bb),{'alias':this[_0x1776dc(0x1a0)],'limit':0xa}))?.[_0x1776dc(0x155)]||[];for(let _0x10bc65 of _0x5d756f)await this[_0x1776dc(0x150)](_0x1776dc(0x1a8),{'alias':this[_0x1776dc(0x1a0)],'message_id':_0x10bc65['id']}),this[_0x1776dc(0x1c2)]('←\x20'+_0x10bc65[_0x1776dc(0x158)]+':\x20'+_0x10bc65[_0x1776dc(0x14c)]['slice'](0x0,0x3c)),this[_0x1776dc(0x1ac)](_0x1776dc(0x188),_0x10bc65),this['emit'](_0x1776dc(0x164),_0x10bc65);}catch(_0x393fe7){this['log'](_0x1776dc(0x1b5)+_0x393fe7[_0x1776dc(0x164)]);}}[a0_0x3a1a12(0x16a)](_0x2b8e8c){return new Promise(_0x33e90b=>setTimeout(_0x33e90b,_0x2b8e8c));}}var F=$;export{F as default,$ as CommHub};
|