@sleep2agi/agent-network 2.3.0-preview.74 → 2.3.0-preview.75
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_0x578d01=a0_0x2995;(function(_0x43414a,_0xb7c6b7){const _0x3eeb2d=a0_0x2995,_0x582d8f=_0x43414a();while(!![]){try{const _0xaa9d=parseInt(_0x3eeb2d(0x15d))/0x1*(-parseInt(_0x3eeb2d(0x195))/0x2)+-parseInt(_0x3eeb2d(0x165))/0x3+parseInt(_0x3eeb2d(0x15f))/0x4+parseInt(_0x3eeb2d(0x160))/0x5*(-parseInt(_0x3eeb2d(0x175))/0x6)+-parseInt(_0x3eeb2d(0x169))/0x7*(parseInt(_0x3eeb2d(0x159))/0x8)+-parseInt(_0x3eeb2d(0x1c6))/0x9+parseInt(_0x3eeb2d(0x1cc))/0xa;if(_0xaa9d===_0xb7c6b7)break;else _0x582d8f['push'](_0x582d8f['shift']());}catch(_0x270cc2){_0x582d8f['push'](_0x582d8f['shift']());}}}(a0_0x1291,0xa80ac));import{EventEmitter as a0_0x4ca04f}from'events';import{hostname as a0_0x77ace9}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x47722a,_0x4cf4f3)=>(_0x47722a??_0x4cf4f3)[a0_0x578d01(0x1cf)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function a0_0x1291(){const _0x6be679=['reply','/mcp','connectSSE','new_message','toString','type','send_message','idle','text/event-stream','\x20from=','7571709eUiRrg','connected','SSE\x20reconnecting\x20in\x20','split','task','reconnectDelay','39464240hOMhTM','read','s...','replace','data:\x20','from_session','min','application/json,\x20text/event-stream','SSE\x20failed:\x20','send_rejected','sdk','parentTaskId','status','message','decode','fromAlias','abort','emit','normal','networkId','\x20task_id=','8ZwcCNw','[commhub:task]\x20','application/json','autoConnect','1DcHHtj','alias','26828SkbzDV','3518115oDPPax','new_task','log','send_failed','task_id','2734686VgcfET','to_alias','\x20transport=','error_code','2908892UUwNqi','lifecycle_tracking','processInbox','send_task','sending','\x20duration_ms=','name','agent','task.started','slice','stringify','Authorization','6Gcynyp','delivered','task.replied','disconnect','catch','<pending>','url','now','task.expired','task.send.failed','[REDACTED]','\x20lifecycle=','server','content','CommHub\x20rejected\x20task','parent_task_id','send_reply','pop','message_id','missing_task_id','\x20parent_task_id=','network_id','call','/events/','<unknown>','<missing>','\x20network_id=','text','AbortError','task.send.start','token','completed','785578vBpncd','\x20to=','CommHub\x20response\x20omitted\x20task_id','task.send.delivered','error','ack_inbox','lifecycleTracking','unknown\x20error','task.ack','from_alias','sseAbort','registered','running',']\x20[commhub:','json','resumeId','sdk-','heartbeatTimer','string','connect','get_inbox','cwd','send','tools/call','heartbeatInterval','parse','2.0','Bearer\x20','broadcast','report_status','disconnected','startsWith','get_all_status','body','\x20error=','failed','heartbeat\x20failed:\x20','duration_ms','messages'];a0_0x1291=function(){return _0x6be679;};return a0_0x1291();}function N(_0x32f736){const _0x2df201=a0_0x578d01;return(_0x32f736 instanceof Error?_0x32f736[_0x2df201(0x1d9)]:String(_0x32f736??_0x2df201(0x19c)))[_0x2df201(0x1cf)](K,_0x2df201(0x17f))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x2df201(0x172)](0x0,0xf0);}function O(_0x2909a1,_0x35e9bd=process.env.ANET_TASK_TRACE_FORMAT===a0_0x578d01(0x1a3)){const _0x150f40=a0_0x578d01;if(_0x35e9bd)return JSON[_0x150f40(0x173)](_0x2909a1);let _0x113362=L(_0x2909a1[_0x150f40(0x184)],_0x150f40(0x18e)),_0x10c1c9=L(_0x2909a1[_0x150f40(0x164)],_0x150f40(0x17a)),_0x2481af=_0x2909a1[_0x150f40(0x168)]?_0x150f40(0x1b7)+_0x2909a1[_0x150f40(0x168)]+':'+(_0x2909a1['error_message']??''):'';return _0x150f40(0x15a)+_0x2909a1[_0x150f40(0x1d8)]+_0x150f40(0x1c5)+L(_0x2909a1[_0x150f40(0x19e)],_0x150f40(0x18d))+_0x150f40(0x196)+L(_0x2909a1[_0x150f40(0x166)],_0x150f40(0x18d))+_0x150f40(0x1e0)+_0x10c1c9+_0x150f40(0x189)+_0x113362+_0x150f40(0x18f)+L(_0x2909a1[_0x150f40(0x18a)],'<unknown>')+_0x150f40(0x167)+_0x2909a1['transport']+_0x150f40(0x16e)+_0x2909a1[_0x150f40(0x1ba)]+_0x150f40(0x180)+_0x2909a1[_0x150f40(0x16a)]+_0x2481af;}function U(_0x4be2a4){const _0x590685=a0_0x578d01;return{'event':{'sending':_0x590685(0x192),'delivered':_0x590685(0x198),'failed':_0x590685(0x17e),'acked':_0x590685(0x19d),'started':_0x590685(0x171),'replied':_0x590685(0x177),'expired':_0x590685(0x17d)}[_0x4be2a4[_0x590685(0x1d8)]],..._0x4be2a4};}function j(_0x4e5e8b){const _0x11f83c=a0_0x578d01;let _0x57538e=_0x4e5e8b?.['task_id']||_0x4e5e8b?.[_0x11f83c(0x187)]||_0x4e5e8b?.['id'];if(_0x57538e)return String(_0x57538e);let _0x5e135c=_0x4e5e8b?.[_0x11f83c(0x182)]?.[0x0]?.[_0x11f83c(0x190)];if(typeof _0x5e135c!==_0x11f83c(0x1a7))return null;try{let _0x10e102=JSON[_0x11f83c(0x1ae)](_0x5e135c);return _0x10e102?.['task_id']||_0x10e102?.[_0x11f83c(0x187)]||_0x10e102?.['id']||null;}catch{return null;}}async function X(_0x114989,_0x6b1ef6){const _0x34caac=a0_0x578d01;let _0x4b3f82=_0x6b1ef6['now']??Date[_0x34caac(0x17c)],_0x178b6=_0x4b3f82(),_0xcf4727=(_0xa14e56,_0x315579,_0x514f24,_0x1f4945)=>{const _0x5761f5=_0x34caac;_0x6b1ef6['log'](O(U({'from_alias':_0x114989[_0x5761f5(0x1db)],'to_alias':_0x114989['toAlias'],'task_id':_0x315579,'parent_task_id':_0x114989['parentTaskId'],'network_id':_0x114989[_0x5761f5(0x1df)],'transport':_0x114989['transport'],'status':_0xa14e56,'duration_ms':_0x4b3f82()-_0x178b6,'lifecycle_tracking':_0x114989[_0x5761f5(0x19b)],..._0x514f24!==void 0x0?{'error_code':_0x1f4945||_0x5761f5(0x163),'error_message':N(_0x514f24)}:{}})));};_0xcf4727(_0x34caac(0x16d),null);try{let _0x1a5671=await _0x6b1ef6[_0x34caac(0x1ab)](),_0xae4e5e=j(_0x1a5671);if(_0xae4e5e)_0xcf4727(_0x34caac(0x176),_0xae4e5e);else{if(_0x1a5671?.['ok']===!0x1||_0x1a5671?.[_0x34caac(0x199)])_0xcf4727(_0x34caac(0x1b8),_0xae4e5e,_0x1a5671?.['error']||_0x34caac(0x183),_0x34caac(0x1d5));else _0xcf4727(_0x34caac(0x1b8),null,_0x34caac(0x197),_0x34caac(0x188));}return _0x1a5671;}catch(_0x410f93){throw _0xcf4727(_0x34caac(0x1b8),null,_0x410f93,_0x34caac(0x163)),_0x410f93;}}async function Y(_0x2025f6,_0x42b8d4){const _0x505325=a0_0x578d01;return X({'fromAlias':_0x2025f6['fromAlias'],'toAlias':_0x2025f6[_0x505325(0x15e)],'parentTaskId':_0x2025f6[_0x505325(0x1d7)]||null,'networkId':_0x2025f6[_0x505325(0x1df)]||null,'transport':'mcp_http','lifecycleTracking':'not_tracked'},_0x42b8d4);}function a0_0x2995(_0xc70572,_0x50ad13){_0xc70572=_0xc70572-0x159;const _0x129162=a0_0x1291();let _0x2995a1=_0x129162[_0xc70572];return _0x2995a1;}class $ extends a0_0x4ca04f{[a0_0x578d01(0x17b)];[a0_0x578d01(0x15e)];[a0_0x578d01(0x193)];['agent'];[a0_0x578d01(0x1a4)];['heartbeatInterval'];[a0_0x578d01(0x1cb)];[a0_0x578d01(0x1a6)];[a0_0x578d01(0x19f)];[a0_0x578d01(0x1a1)]=!0x1;constructor(_0x188987){const _0x5a7379=a0_0x578d01;super();if(this[_0x5a7379(0x17b)]=_0x188987[_0x5a7379(0x17b)]['replace'](/\/$/,''),this['alias']=_0x188987[_0x5a7379(0x15e)],this[_0x5a7379(0x193)]=_0x188987['token'],this[_0x5a7379(0x170)]=_0x188987[_0x5a7379(0x170)]||_0x5a7379(0x1d6),this[_0x5a7379(0x1a4)]=_0x5a7379(0x1a5)+_0x188987[_0x5a7379(0x15e)]+'-'+Date[_0x5a7379(0x17c)]()[_0x5a7379(0x1c0)](0x24),this[_0x5a7379(0x1ad)]=_0x188987[_0x5a7379(0x1ad)]??0x2bf20,this[_0x5a7379(0x1cb)]=_0x188987[_0x5a7379(0x1cb)]??0xbb8,_0x188987[_0x5a7379(0x15c)]!==!0x1)this[_0x5a7379(0x1a8)]();}[a0_0x578d01(0x162)](_0x184908){const _0x38a9b2=a0_0x578d01;console['log']('['+new Date()['toTimeString']()[_0x38a9b2(0x172)](0x0,0x8)+_0x38a9b2(0x1a2)+this[_0x38a9b2(0x15e)]+']\x20'+_0x184908);}async['call'](_0x589222,_0x1ebaf2){const _0x2e94ae=a0_0x578d01;let _0x21eb65={'Content-Type':_0x2e94ae(0x15b),'Accept':_0x2e94ae(0x1d3)};if(this[_0x2e94ae(0x193)])_0x21eb65['Authorization']=_0x2e94ae(0x1b0)+this[_0x2e94ae(0x193)];let _0x3e9a37=await(await fetch(this['url']+_0x2e94ae(0x1bd),{'method':'POST','headers':_0x21eb65,'body':JSON[_0x2e94ae(0x173)]({'jsonrpc':_0x2e94ae(0x1af),'id':Date[_0x2e94ae(0x17c)](),'method':_0x2e94ae(0x1ac),'params':{'name':_0x589222,'arguments':_0x1ebaf2}})}))[_0x2e94ae(0x190)](),_0x1fadf1=_0x3e9a37['match'](/data: (.+)/),_0xd155b3=_0x1fadf1?JSON[_0x2e94ae(0x1ae)](_0x1fadf1[0x1]):JSON[_0x2e94ae(0x1ae)](_0x3e9a37),_0x4491f3=_0xd155b3?.['result']?.[_0x2e94ae(0x182)]?.[0x0]?.['text'];return _0x4491f3?JSON[_0x2e94ae(0x1ae)](_0x4491f3):_0xd155b3;}async[a0_0x578d01(0x1a8)](){const _0x158a6c=a0_0x578d01;if(this[_0x158a6c(0x1a1)])return;this['running']=!0x0,await this['status'](_0x158a6c(0x1c3)),this[_0x158a6c(0x162)](_0x158a6c(0x1a0)),this[_0x158a6c(0x1a6)]=setInterval(()=>{const _0x32bf66=_0x158a6c;this['status'](_0x32bf66(0x1c3))['catch'](_0x4633ad=>this[_0x32bf66(0x162)](_0x32bf66(0x1b9)+_0x4633ad['message']));},this[_0x158a6c(0x1ad)]),this[_0x158a6c(0x1be)]();}async[a0_0x578d01(0x178)](){const _0x21a1d6=a0_0x578d01;if(this[_0x21a1d6(0x1a1)]=!0x1,this[_0x21a1d6(0x19f)]?.[_0x21a1d6(0x1dc)](),this[_0x21a1d6(0x1a6)])clearInterval(this[_0x21a1d6(0x1a6)]);await this[_0x21a1d6(0x1d8)]('offline')[_0x21a1d6(0x179)](()=>{}),this[_0x21a1d6(0x162)]('disconnected');}async[a0_0x578d01(0x1ab)](_0x391fad,_0x56fb72,_0x1e7b0d=a0_0x578d01(0x1de)){const _0x5d2229=a0_0x578d01;return Y({'alias':_0x391fad,'fromAlias':this['alias']},{'log':_0x3123cf=>console[_0x5d2229(0x162)](_0x3123cf),'send':()=>this[_0x5d2229(0x18b)](_0x5d2229(0x16c),{'alias':_0x391fad,'task':_0x56fb72,'priority':_0x1e7b0d,'from_session':this[_0x5d2229(0x15e)]})});}async[a0_0x578d01(0x1d9)](_0x1f01b5,_0x15ef83){const _0xc2f2fb=a0_0x578d01;return this[_0xc2f2fb(0x18b)](_0xc2f2fb(0x1c2),{'alias':_0x1f01b5,'message':_0x15ef83,'from_session':this[_0xc2f2fb(0x15e)]});}async[a0_0x578d01(0x1bc)](_0x124622,_0x30f967,_0x1c91bb=a0_0x578d01(0x194)){const _0x233ee7=a0_0x578d01;return this[_0x233ee7(0x18b)](_0x233ee7(0x185),{'in_reply_to':_0x124622,'text':_0x30f967,'status':_0x1c91bb});}async[a0_0x578d01(0x1d8)](_0x442b00,_0x533d87){const _0x460b07=a0_0x578d01;return this[_0x460b07(0x18b)](_0x460b07(0x1b2),{'resume_id':this['resumeId'],'alias':this[_0x460b07(0x15e)],'status':_0x442b00,'server':a0_0x77ace9(),'hostname':a0_0x77ace9(),'agent':this[_0x460b07(0x170)],'project_dir':process[_0x460b07(0x1aa)](),..._0x533d87});}async['getAllStatus'](){const _0x4621b7=a0_0x578d01;return this[_0x4621b7(0x18b)](_0x4621b7(0x1b5),{});}async[a0_0x578d01(0x1b1)](_0x3bcbf0,_0xd235ce){const _0x5548f7=a0_0x578d01;return this[_0x5548f7(0x18b)]('broadcast',{'message':_0x3bcbf0,'filter_server':_0xd235ce?.[_0x5548f7(0x181)],'filter_status':_0xd235ce?.[_0x5548f7(0x1d8)]});}async[a0_0x578d01(0x1be)](){const _0x4408a5=a0_0x578d01;let _0x2eda02=encodeURIComponent(this['alias']),_0x579e19=this[_0x4408a5(0x17b)]+_0x4408a5(0x18c)+_0x2eda02,_0x15cf70=this[_0x4408a5(0x1cb)];while(this[_0x4408a5(0x1a1)]){try{this[_0x4408a5(0x19f)]=new AbortController();let _0x218599={'Accept':_0x4408a5(0x1c4)};if(this[_0x4408a5(0x193)])_0x218599[_0x4408a5(0x174)]=_0x4408a5(0x1b0)+this['token'];let _0x245cfe=await fetch(_0x579e19,{'headers':_0x218599,'signal':this[_0x4408a5(0x19f)]['signal']});if(!_0x245cfe['ok']||!_0x245cfe[_0x4408a5(0x1b6)]){this['log'](_0x4408a5(0x1d4)+_0x245cfe[_0x4408a5(0x1d8)]),await this['sleep'](_0x15cf70),_0x15cf70=Math[_0x4408a5(0x1d2)](_0x15cf70*1.5,0xea60);continue;}_0x15cf70=this['reconnectDelay'];let _0x45aa9f=_0x245cfe[_0x4408a5(0x1b6)]['getReader'](),_0x3c9276=new TextDecoder(),_0x4f393f='';while(this['running']){let {done:_0x264062,value:_0x21d2db}=await _0x45aa9f[_0x4408a5(0x1cd)]();if(_0x264062)break;_0x4f393f+=_0x3c9276[_0x4408a5(0x1da)](_0x21d2db,{'stream':!0x0});let _0x2c611a=_0x4f393f[_0x4408a5(0x1c9)]('\x0a');_0x4f393f=_0x2c611a[_0x4408a5(0x186)]()||'';for(let _0x22cd2d of _0x2c611a){if(!_0x22cd2d[_0x4408a5(0x1b4)](_0x4408a5(0x1d0)))continue;try{let _0x1e6b4a=JSON[_0x4408a5(0x1ae)](_0x22cd2d['slice'](0x6));if(_0x1e6b4a[_0x4408a5(0x1c1)]===_0x4408a5(0x1c7)){this[_0x4408a5(0x162)]('SSE\x20connected'),this[_0x4408a5(0x1dd)]('connected');continue;}if(_0x1e6b4a[_0x4408a5(0x1c1)]===_0x4408a5(0x161)||_0x1e6b4a['type']===_0x4408a5(0x1bf)||_0x1e6b4a[_0x4408a5(0x1c1)]===_0x4408a5(0x1b1))await this[_0x4408a5(0x16b)]();}catch{}}}}catch(_0x39c530){if(_0x39c530[_0x4408a5(0x16f)]===_0x4408a5(0x191))break;this['emit']('error',_0x39c530),this[_0x4408a5(0x162)]('SSE\x20error:\x20'+_0x39c530[_0x4408a5(0x1d9)]);}if(this[_0x4408a5(0x1a1)])this['emit'](_0x4408a5(0x1b3)),this[_0x4408a5(0x162)](_0x4408a5(0x1c8)+_0x15cf70/0x3e8+_0x4408a5(0x1ce)),await this['sleep'](_0x15cf70),_0x15cf70=Math[_0x4408a5(0x1d2)](_0x15cf70*1.5,0xea60);}}async['processInbox'](){const _0x14ece0=a0_0x578d01;try{let _0x36c255=(await this[_0x14ece0(0x18b)](_0x14ece0(0x1a9),{'alias':this[_0x14ece0(0x15e)],'limit':0xa}))?.[_0x14ece0(0x1bb)]||[];for(let _0x14fb1a of _0x36c255)await this[_0x14ece0(0x18b)](_0x14ece0(0x19a),{'alias':this['alias'],'message_id':_0x14fb1a['id']}),this['log']('←\x20'+_0x14fb1a[_0x14ece0(0x1d1)]+':\x20'+_0x14fb1a[_0x14ece0(0x182)]['slice'](0x0,0x3c)),this[_0x14ece0(0x1dd)](_0x14ece0(0x1ca),_0x14fb1a),this[_0x14ece0(0x1dd)](_0x14ece0(0x1d9),_0x14fb1a);}catch(_0x3fc259){this[_0x14ece0(0x162)]('inbox\x20error:\x20'+_0x3fc259[_0x14ece0(0x1d9)]);}}['sleep'](_0x251902){return new Promise(_0x5cd14d=>setTimeout(_0x5cd14d,_0x251902));}}var F=$;export{F as default,$ as CommHub};
|
|
1
|
+
const a0_0x12b9ba=a0_0x5346;(function(_0x2defa4,_0x471f48){const _0x682c1d=a0_0x5346,_0x797fa0=_0x2defa4();while(!![]){try{const _0x14734a=parseInt(_0x682c1d(0x115))/0x1*(-parseInt(_0x682c1d(0xcb))/0x2)+-parseInt(_0x682c1d(0x119))/0x3*(parseInt(_0x682c1d(0xc1))/0x4)+parseInt(_0x682c1d(0xbe))/0x5*(parseInt(_0x682c1d(0xc9))/0x6)+-parseInt(_0x682c1d(0xa4))/0x7+parseInt(_0x682c1d(0xc0))/0x8*(parseInt(_0x682c1d(0xd6))/0x9)+-parseInt(_0x682c1d(0xfd))/0xa*(-parseInt(_0x682c1d(0xf4))/0xb)+-parseInt(_0x682c1d(0x11e))/0xc*(-parseInt(_0x682c1d(0xf1))/0xd);if(_0x14734a===_0x471f48)break;else _0x797fa0['push'](_0x797fa0['shift']());}catch(_0x1fa61d){_0x797fa0['push'](_0x797fa0['shift']());}}}(a0_0x4802,0xb2042));import{EventEmitter as a0_0x2f78a4}from'events';import{hostname as a0_0x434e4e}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x16f11d,_0x494088)=>(_0x16f11d??_0x494088)[a0_0x12b9ba(0x116)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x12b9ba(0x109)](0x0,0xf0);function a0_0x5346(_0x5f2c77,_0xb38c9c){_0x5f2c77=_0x5f2c77-0xa3;const _0x48025e=a0_0x4802();let _0x53461c=_0x48025e[_0x5f2c77];return _0x53461c;}function N(_0x302df6){const _0x32b1b6=a0_0x12b9ba;return(_0x302df6 instanceof Error?_0x302df6[_0x32b1b6(0xea)]:String(_0x302df6??_0x32b1b6(0x10f)))[_0x32b1b6(0x116)](K,_0x32b1b6(0xe4))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x32b1b6(0x109)](0x0,0xf0);}function O(_0x5ce31b,_0x4b250e=process.env.ANET_TASK_TRACE_FORMAT===a0_0x12b9ba(0xce)){const _0x4802cf=a0_0x12b9ba;if(_0x4b250e)return JSON[_0x4802cf(0xa3)](_0x5ce31b);let _0x11f626=L(_0x5ce31b['parent_task_id'],'<missing>'),_0x5e4b23=L(_0x5ce31b['task_id'],_0x4802cf(0xa5)),_0x50c13a=_0x5ce31b['error_code']?_0x4802cf(0xb6)+_0x5ce31b[_0x4802cf(0x10d)]+':'+(_0x5ce31b[_0x4802cf(0xed)]??''):'';return'[commhub:task]\x20'+_0x5ce31b['status']+'\x20from='+L(_0x5ce31b[_0x4802cf(0x10b)],_0x4802cf(0x10c))+_0x4802cf(0x105)+L(_0x5ce31b[_0x4802cf(0xb8)],_0x4802cf(0x10c))+_0x4802cf(0x125)+_0x5e4b23+_0x4802cf(0xb4)+_0x11f626+_0x4802cf(0x11f)+L(_0x5ce31b[_0x4802cf(0xc5)],_0x4802cf(0x10c))+_0x4802cf(0xe0)+_0x5ce31b['transport']+_0x4802cf(0x123)+_0x5ce31b[_0x4802cf(0x112)]+_0x4802cf(0xe7)+_0x5ce31b[_0x4802cf(0xfe)]+_0x50c13a;}function U(_0x247692){const _0x397bb1=a0_0x12b9ba;return{'event':{'sending':_0x397bb1(0xe8),'delivered':_0x397bb1(0xfa),'failed':_0x397bb1(0xb1),'acked':_0x397bb1(0xe1),'started':_0x397bb1(0x12a),'replied':_0x397bb1(0x127),'expired':_0x397bb1(0xeb)}[_0x247692['status']],..._0x247692};}function j(_0x1901f7){const _0x2e638f=a0_0x12b9ba;let _0x3374d3=_0x1901f7?.[_0x2e638f(0xee)]||_0x1901f7?.[_0x2e638f(0x100)]||_0x1901f7?.['id'];if(_0x3374d3)return String(_0x3374d3);let _0x4e80e8=_0x1901f7?.[_0x2e638f(0xf7)]?.[0x0]?.[_0x2e638f(0x114)];if(typeof _0x4e80e8!==_0x2e638f(0x113))return null;try{let _0x1f4e33=JSON[_0x2e638f(0xc4)](_0x4e80e8);return _0x1f4e33?.[_0x2e638f(0xee)]||_0x1f4e33?.[_0x2e638f(0x100)]||_0x1f4e33?.['id']||null;}catch{return null;}}function a0_0x4802(){const _0x2262bc=['get_inbox','SSE\x20reconnecting\x20in\x20','token','resumeId','/mcp','sdk','tools/call','signal','server','task.send.failed','sseAbort','min','\x20parent_task_id=','text/event-stream','\x20error=','reconnectDelay','to_alias','broadcast','lifecycleTracking','normal','url','toString','5346475rrMrUM','autoConnect','1854768yfhgCm','52qoKWCe','CommHub\x20response\x20omitted\x20task_id','log','parse','network_id','getReader','report_status','sleep','6DejKRm','CommHub\x20rejected\x20task','700822qXFMCh','messages','status','json','catch','error','match','heartbeatInterval','body','startsWith','pop','36NkbWZs','new_task','2.0','heartbeat\x20failed:\x20','networkId','send_rejected','send','Authorization','failed','send_task','\x20transport=','task.ack',']\x20[commhub:','from_session','[REDACTED]','transport','disconnect','\x20lifecycle=','task.send.start','connectSSE','message','task.expired','s...','error_message','task_id','parentTaskId','result','91nIdPgs','send_failed','sdk-','827233dBECIL','task','send_message','content','registered','decode','task.send.delivered','fromAlias','application/json','130xwVPAs','lifecycle_tracking','cwd','message_id','connect','get_all_status','heartbeatTimer','emit','\x20to=','alias','sending','abort','slice','ack_inbox','from_alias','<unknown>','error_code','type','unknown\x20error','Bearer\x20','missing_task_id','duration_ms','string','text','4RSkNIa','replace','now','disconnected','77793ZAwjbt','mcp_http','not_tracked','send_reply','agent','674484zsezYs','\x20network_id=','completed','application/json,\x20text/event-stream','SSE\x20failed:\x20','\x20duration_ms=','running','\x20task_id=','split','task.replied','reply','processInbox','task.started','stringify','6299062XQmOmJ','<pending>','delivered','call'];a0_0x4802=function(){return _0x2262bc;};return a0_0x4802();}async function X(_0x1b75e0,_0x30c7df){const _0xe5af24=a0_0x12b9ba;let _0x54348d=_0x30c7df[_0xe5af24(0x117)]??Date['now'],_0x31bb3d=_0x54348d(),_0x21774b=(_0x88cddd,_0x114e9e,_0x417a4c,_0x4bfa68)=>{const _0x2d630a=_0xe5af24;_0x30c7df[_0x2d630a(0xc3)](O(U({'from_alias':_0x1b75e0[_0x2d630a(0xfb)],'to_alias':_0x1b75e0['toAlias'],'task_id':_0x114e9e,'parent_task_id':_0x1b75e0[_0x2d630a(0xef)],'network_id':_0x1b75e0['networkId'],'transport':_0x1b75e0[_0x2d630a(0xe5)],'status':_0x88cddd,'duration_ms':_0x54348d()-_0x31bb3d,'lifecycle_tracking':_0x1b75e0[_0x2d630a(0xba)],..._0x417a4c!==void 0x0?{'error_code':_0x4bfa68||'send_failed','error_message':N(_0x417a4c)}:{}})));};_0x21774b(_0xe5af24(0x107),null);try{let _0x59c065=await _0x30c7df[_0xe5af24(0xdc)](),_0x176d9c=j(_0x59c065);if(_0x176d9c)_0x21774b(_0xe5af24(0xa6),_0x176d9c);else{if(_0x59c065?.['ok']===!0x1||_0x59c065?.[_0xe5af24(0xd0)])_0x21774b(_0xe5af24(0xde),_0x176d9c,_0x59c065?.[_0xe5af24(0xd0)]||_0xe5af24(0xca),_0xe5af24(0xdb));else _0x21774b(_0xe5af24(0xde),null,_0xe5af24(0xc2),_0xe5af24(0x111));}return _0x59c065;}catch(_0x12a316){throw _0x21774b(_0xe5af24(0xde),null,_0x12a316,_0xe5af24(0xf2)),_0x12a316;}}async function Y(_0x5aef81,_0x1284d3){const _0x3535b8=a0_0x12b9ba;return X({'fromAlias':_0x5aef81[_0x3535b8(0xfb)],'toAlias':_0x5aef81['alias'],'parentTaskId':_0x5aef81[_0x3535b8(0xef)]||null,'networkId':_0x5aef81[_0x3535b8(0xda)]||null,'transport':_0x3535b8(0x11a),'lifecycleTracking':_0x3535b8(0x11b)},_0x1284d3);}class $ extends a0_0x2f78a4{[a0_0x12b9ba(0xbc)];['alias'];['token'];[a0_0x12b9ba(0x11d)];[a0_0x12b9ba(0xab)];[a0_0x12b9ba(0xd2)];[a0_0x12b9ba(0xb7)];[a0_0x12b9ba(0x103)];[a0_0x12b9ba(0xb2)];['running']=!0x1;constructor(_0x1c2ff0){const _0x4f8077=a0_0x12b9ba;super();if(this['url']=_0x1c2ff0['url']['replace'](/\/$/,''),this[_0x4f8077(0x106)]=_0x1c2ff0['alias'],this[_0x4f8077(0xaa)]=_0x1c2ff0[_0x4f8077(0xaa)],this[_0x4f8077(0x11d)]=_0x1c2ff0[_0x4f8077(0x11d)]||_0x4f8077(0xad),this[_0x4f8077(0xab)]=_0x4f8077(0xf3)+_0x1c2ff0[_0x4f8077(0x106)]+'-'+Date['now']()[_0x4f8077(0xbd)](0x24),this[_0x4f8077(0xd2)]=_0x1c2ff0[_0x4f8077(0xd2)]??0x2bf20,this[_0x4f8077(0xb7)]=_0x1c2ff0[_0x4f8077(0xb7)]??0xbb8,_0x1c2ff0[_0x4f8077(0xbf)]!==!0x1)this[_0x4f8077(0x101)]();}[a0_0x12b9ba(0xc3)](_0x5ef8c7){const _0x23ee5c=a0_0x12b9ba;console[_0x23ee5c(0xc3)]('['+new Date()['toTimeString']()['slice'](0x0,0x8)+_0x23ee5c(0xe2)+this[_0x23ee5c(0x106)]+']\x20'+_0x5ef8c7);}async[a0_0x12b9ba(0xa7)](_0x4ce778,_0x2fde74){const _0x186667=a0_0x12b9ba;let _0x49f5ca={'Content-Type':_0x186667(0xfc),'Accept':_0x186667(0x121)};if(this[_0x186667(0xaa)])_0x49f5ca[_0x186667(0xdd)]=_0x186667(0x110)+this[_0x186667(0xaa)];let _0x54d4c5=await(await fetch(this['url']+_0x186667(0xac),{'method':'POST','headers':_0x49f5ca,'body':JSON[_0x186667(0xa3)]({'jsonrpc':_0x186667(0xd8),'id':Date['now'](),'method':_0x186667(0xae),'params':{'name':_0x4ce778,'arguments':_0x2fde74}})}))[_0x186667(0x114)](),_0x280613=_0x54d4c5[_0x186667(0xd1)](/data: (.+)/),_0x3a5414=_0x280613?JSON['parse'](_0x280613[0x1]):JSON[_0x186667(0xc4)](_0x54d4c5),_0x24e917=_0x3a5414?.[_0x186667(0xf0)]?.['content']?.[0x0]?.[_0x186667(0x114)];return _0x24e917?JSON[_0x186667(0xc4)](_0x24e917):_0x3a5414;}async[a0_0x12b9ba(0x101)](){const _0x4ad070=a0_0x12b9ba;if(this['running'])return;this[_0x4ad070(0x124)]=!0x0,await this[_0x4ad070(0xcd)]('idle'),this[_0x4ad070(0xc3)](_0x4ad070(0xf8)),this[_0x4ad070(0x103)]=setInterval(()=>{const _0x5a9243=_0x4ad070;this[_0x5a9243(0xcd)]('idle')[_0x5a9243(0xcf)](_0x4b8a3c=>this[_0x5a9243(0xc3)](_0x5a9243(0xd9)+_0x4b8a3c['message']));},this[_0x4ad070(0xd2)]),this['connectSSE']();}async[a0_0x12b9ba(0xe6)](){const _0x299cfd=a0_0x12b9ba;if(this['running']=!0x1,this[_0x299cfd(0xb2)]?.[_0x299cfd(0x108)](),this[_0x299cfd(0x103)])clearInterval(this[_0x299cfd(0x103)]);await this[_0x299cfd(0xcd)]('offline')[_0x299cfd(0xcf)](()=>{}),this['log'](_0x299cfd(0x118));}async[a0_0x12b9ba(0xdc)](_0x166022,_0x250652,_0x3b991e=a0_0x12b9ba(0xbb)){const _0x5e4ff1=a0_0x12b9ba;return Y({'alias':_0x166022,'fromAlias':this[_0x5e4ff1(0x106)]},{'log':_0x235b7f=>console[_0x5e4ff1(0xc3)](_0x235b7f),'send':()=>this[_0x5e4ff1(0xa7)](_0x5e4ff1(0xdf),{'alias':_0x166022,'task':_0x250652,'priority':_0x3b991e,'from_session':this[_0x5e4ff1(0x106)]})});}async['message'](_0x5b84c9,_0xcc8f67){const _0x126a27=a0_0x12b9ba;return this[_0x126a27(0xa7)](_0x126a27(0xf6),{'alias':_0x5b84c9,'message':_0xcc8f67,'from_session':this[_0x126a27(0x106)]});}async[a0_0x12b9ba(0x128)](_0x4e6286,_0x1bec3a,_0x2951ac=a0_0x12b9ba(0x120)){const _0x23b8f5=a0_0x12b9ba;return this[_0x23b8f5(0xa7)](_0x23b8f5(0x11c),{'in_reply_to':_0x4e6286,'text':_0x1bec3a,'status':_0x2951ac});}async[a0_0x12b9ba(0xcd)](_0x523fdb,_0x16e303){const _0x1b0e3f=a0_0x12b9ba;return this[_0x1b0e3f(0xa7)](_0x1b0e3f(0xc7),{'resume_id':this[_0x1b0e3f(0xab)],'alias':this[_0x1b0e3f(0x106)],'status':_0x523fdb,'server':a0_0x434e4e(),'hostname':a0_0x434e4e(),'agent':this[_0x1b0e3f(0x11d)],'project_dir':process[_0x1b0e3f(0xff)](),..._0x16e303});}async['getAllStatus'](){const _0x8c3b91=a0_0x12b9ba;return this[_0x8c3b91(0xa7)](_0x8c3b91(0x102),{});}async[a0_0x12b9ba(0xb9)](_0x47106d,_0x1de764){const _0x255653=a0_0x12b9ba;return this[_0x255653(0xa7)](_0x255653(0xb9),{'message':_0x47106d,'filter_server':_0x1de764?.[_0x255653(0xb0)],'filter_status':_0x1de764?.[_0x255653(0xcd)]});}async[a0_0x12b9ba(0xe9)](){const _0x15a02f=a0_0x12b9ba;let _0x569b14=encodeURIComponent(this['alias']),_0x4cbedd=this['url']+'/events/'+_0x569b14,_0x516b34=this[_0x15a02f(0xb7)];while(this[_0x15a02f(0x124)]){try{this[_0x15a02f(0xb2)]=new AbortController();let _0x5cdab1={'Accept':_0x15a02f(0xb5)};if(this[_0x15a02f(0xaa)])_0x5cdab1[_0x15a02f(0xdd)]=_0x15a02f(0x110)+this[_0x15a02f(0xaa)];let _0x357397=await fetch(_0x4cbedd,{'headers':_0x5cdab1,'signal':this[_0x15a02f(0xb2)][_0x15a02f(0xaf)]});if(!_0x357397['ok']||!_0x357397[_0x15a02f(0xd3)]){this[_0x15a02f(0xc3)](_0x15a02f(0x122)+_0x357397['status']),await this[_0x15a02f(0xc8)](_0x516b34),_0x516b34=Math[_0x15a02f(0xb3)](_0x516b34*1.5,0xea60);continue;}_0x516b34=this[_0x15a02f(0xb7)];let _0x3fd4cd=_0x357397[_0x15a02f(0xd3)][_0x15a02f(0xc6)](),_0x563931=new TextDecoder(),_0x1b72b7='';while(this[_0x15a02f(0x124)]){let {done:_0x1ab70a,value:_0x439e7e}=await _0x3fd4cd['read']();if(_0x1ab70a)break;_0x1b72b7+=_0x563931[_0x15a02f(0xf9)](_0x439e7e,{'stream':!0x0});let _0x4cf973=_0x1b72b7[_0x15a02f(0x126)]('\x0a');_0x1b72b7=_0x4cf973[_0x15a02f(0xd5)]()||'';for(let _0x4af73c of _0x4cf973){if(!_0x4af73c[_0x15a02f(0xd4)]('data:\x20'))continue;try{let _0x1a1371=JSON[_0x15a02f(0xc4)](_0x4af73c[_0x15a02f(0x109)](0x6));if(_0x1a1371['type']==='connected'){this[_0x15a02f(0xc3)]('SSE\x20connected'),this[_0x15a02f(0x104)]('connected');continue;}if(_0x1a1371[_0x15a02f(0x10e)]===_0x15a02f(0xd7)||_0x1a1371[_0x15a02f(0x10e)]==='new_message'||_0x1a1371[_0x15a02f(0x10e)]==='broadcast')await this[_0x15a02f(0x129)]();}catch{}}}}catch(_0x354292){if(_0x354292['name']==='AbortError')break;this['emit'](_0x15a02f(0xd0),_0x354292),this[_0x15a02f(0xc3)]('SSE\x20error:\x20'+_0x354292[_0x15a02f(0xea)]);}if(this['running'])this['emit'](_0x15a02f(0x118)),this[_0x15a02f(0xc3)](_0x15a02f(0xa9)+_0x516b34/0x3e8+_0x15a02f(0xec)),await this['sleep'](_0x516b34),_0x516b34=Math['min'](_0x516b34*1.5,0xea60);}}async['processInbox'](){const _0x1801fd=a0_0x12b9ba;try{let _0x4d0fce=(await this[_0x1801fd(0xa7)](_0x1801fd(0xa8),{'alias':this[_0x1801fd(0x106)],'limit':0xa}))?.[_0x1801fd(0xcc)]||[];for(let _0x8cdb1e of _0x4d0fce)await this[_0x1801fd(0xa7)](_0x1801fd(0x10a),{'alias':this['alias'],'message_id':_0x8cdb1e['id']}),this[_0x1801fd(0xc3)]('←\x20'+_0x8cdb1e[_0x1801fd(0xe3)]+':\x20'+_0x8cdb1e[_0x1801fd(0xf7)][_0x1801fd(0x109)](0x0,0x3c)),this[_0x1801fd(0x104)](_0x1801fd(0xf5),_0x8cdb1e),this[_0x1801fd(0x104)](_0x1801fd(0xea),_0x8cdb1e);}catch(_0x3cde1c){this[_0x1801fd(0xc3)]('inbox\x20error:\x20'+_0x3cde1c[_0x1801fd(0xea)]);}}[a0_0x12b9ba(0xc8)](_0x3f3844){return new Promise(_0x4d3e86=>setTimeout(_0x4d3e86,_0x3f3844));}}var F=$;export{F as default,$ as CommHub};
|