@sleep2agi/agent-network 2.3.0-preview.231 → 2.3.0-preview.232
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_0x219124=a0_0x277f;(function(_0x59df65,_0x44ab53){const _0x404eef=a0_0x277f,_0x344d30=_0x59df65();while(!![]){try{const _0x122d1a=parseInt(_0x404eef(0x19e))/0x1*(-parseInt(_0x404eef(0x15b))/0x2)+-parseInt(_0x404eef(0x1c3))/0x3+parseInt(_0x404eef(0x1b0))/0x4*(parseInt(_0x404eef(0x1a1))/0x5)+-parseInt(_0x404eef(0x15c))/0x6*(-parseInt(_0x404eef(0x180))/0x7)+-parseInt(_0x404eef(0x160))/0x8+-parseInt(_0x404eef(0x18d))/0x9+parseInt(_0x404eef(0x190))/0xa;if(_0x122d1a===_0x44ab53)break;else _0x344d30['push'](_0x344d30['shift']());}catch(_0x502a42){_0x344d30['push'](_0x344d30['shift']());}}}(a0_0x5331,0x4bc72));import{EventEmitter as a0_0x206828}from'events';import{hostname as a0_0x344b1e}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x1d2dff,_0x3c340b)=>(_0x1d2dff??_0x3c340b)[a0_0x219124(0x1a0)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x34954b){const _0x42d238=a0_0x219124;return(_0x34954b instanceof Error?_0x34954b[_0x42d238(0x19f)]:String(_0x34954b??_0x42d238(0x1c9)))['replace'](K,_0x42d238(0x16b))[_0x42d238(0x1a0)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function a0_0x5331(){const _0x685b04=['task.replied','error','/mcp','decode','normal','s...','\x20network_id=','Bearer\x20','connect','abort','61972fdHcNC','23706hocVvx','string','catch','log','4044096WlIPNh','heartbeatInterval','[commhub:task]\x20','slice','offline','task','token','status','inbox\x20error:\x20','content','text','[REDACTED]','result','<missing>','Authorization','split','send_message','error_code','lifecycle_tracking','sleep','task_id','now','\x20parent_task_id=','transport','autoConnect','<unknown>','sending','registered','parse','SSE\x20failed:\x20','network_id','\x20task_id=','553kjHQvM','signal','toString','json','completed','alias','broadcast','sseAbort','data:\x20','message_id','send_failed','connectSSE','SSE\x20reconnecting\x20in\x20','3902751oHavad','parent_task_id','server','9565120NCsfqi','task.send.delivered','match','getAllStatus','getReader','delivered','text/event-stream','task.ack','\x20lifecycle=','report_status','send_reply','name','from_session','error_message','3NRnPan','message','replace','1605fsQMYv','running','toAlias','emit','failed','from_alias','agent','connected','parentTaskId','resumeId','reply','heartbeatTimer','sdk','url','get_inbox','7116iWUJkO','SSE\x20connected','send_task','tools/call','send','min','type','lifecycleTracking','\x20transport=','pop','read','/events/','to_alias','2.0','toTimeString','idle','ack_inbox','reconnectDelay','processInbox','1491615XHuRDH','networkId','<pending>','missing_task_id','new_message','sdk-','unknown\x20error','POST','call','stringify','\x20from=','fromAlias','SSE\x20error:\x20'];a0_0x5331=function(){return _0x685b04;};return a0_0x5331();}function a0_0x277f(_0x230960,_0x17245c){_0x230960=_0x230960-0x152;const _0x5331e7=a0_0x5331();let _0x277f49=_0x5331e7[_0x230960];return _0x277f49;}function O(_0x27641f,_0xa3584f=process.env.ANET_TASK_TRACE_FORMAT===a0_0x219124(0x183)){const _0x258b73=a0_0x219124;if(_0xa3584f)return JSON[_0x258b73(0x1cc)](_0x27641f);let _0x531d85=L(_0x27641f[_0x258b73(0x18e)],_0x258b73(0x16d)),_0x3be5fb=L(_0x27641f[_0x258b73(0x174)],_0x258b73(0x1c5)),_0x15af6f=_0x27641f[_0x258b73(0x171)]?'\x20error='+_0x27641f[_0x258b73(0x171)]+':'+(_0x27641f[_0x258b73(0x19d)]??''):'';return _0x258b73(0x162)+_0x27641f[_0x258b73(0x167)]+_0x258b73(0x1cd)+L(_0x27641f[_0x258b73(0x1a6)],_0x258b73(0x179))+'\x20to='+L(_0x27641f[_0x258b73(0x1bc)],'<unknown>')+_0x258b73(0x17f)+_0x3be5fb+_0x258b73(0x176)+_0x531d85+_0x258b73(0x157)+L(_0x27641f[_0x258b73(0x17e)],_0x258b73(0x179))+_0x258b73(0x1b8)+_0x27641f[_0x258b73(0x177)]+'\x20duration_ms='+_0x27641f['duration_ms']+_0x258b73(0x198)+_0x27641f[_0x258b73(0x172)]+_0x15af6f;}function U(_0x196381){const _0x3eeae8=a0_0x219124;return{'event':{'sending':'task.send.start','delivered':_0x3eeae8(0x191),'failed':'task.send.failed','acked':_0x3eeae8(0x197),'started':'task.started','replied':_0x3eeae8(0x1d0),'expired':'task.expired'}[_0x196381[_0x3eeae8(0x167)]],..._0x196381};}function j(_0x3dabbe){const _0x1770dc=a0_0x219124;let _0x36ebda=_0x3dabbe?.[_0x1770dc(0x174)]||_0x3dabbe?.['message_id']||_0x3dabbe?.['id'];if(_0x36ebda)return String(_0x36ebda);let _0x4678e9=_0x3dabbe?.[_0x1770dc(0x169)]?.[0x0]?.['text'];if(typeof _0x4678e9!==_0x1770dc(0x15d))return null;try{let _0x5dfb39=JSON['parse'](_0x4678e9);return _0x5dfb39?.[_0x1770dc(0x174)]||_0x5dfb39?.[_0x1770dc(0x189)]||_0x5dfb39?.['id']||null;}catch{return null;}}async function X(_0x5bf810,_0xf68e34){const _0x26d7e9=a0_0x219124;let _0x2c96d3=_0xf68e34[_0x26d7e9(0x175)]??Date[_0x26d7e9(0x175)],_0x2fcb0f=_0x2c96d3(),_0x3da7fa=(_0x42e963,_0x405f11,_0x15016d,_0x425520)=>{const _0x181c06=_0x26d7e9;_0xf68e34[_0x181c06(0x15f)](O(U({'from_alias':_0x5bf810[_0x181c06(0x1ce)],'to_alias':_0x5bf810[_0x181c06(0x1a3)],'task_id':_0x405f11,'parent_task_id':_0x5bf810[_0x181c06(0x1a9)],'network_id':_0x5bf810['networkId'],'transport':_0x5bf810[_0x181c06(0x177)],'status':_0x42e963,'duration_ms':_0x2c96d3()-_0x2fcb0f,'lifecycle_tracking':_0x5bf810[_0x181c06(0x1b7)],..._0x15016d!==void 0x0?{'error_code':_0x425520||_0x181c06(0x18a),'error_message':N(_0x15016d)}:{}})));};_0x3da7fa(_0x26d7e9(0x17a),null);try{let _0x40c788=await _0xf68e34[_0x26d7e9(0x1b4)](),_0x455900=j(_0x40c788);if(_0x455900)_0x3da7fa(_0x26d7e9(0x195),_0x455900);else{if(_0x40c788?.['ok']===!0x1||_0x40c788?.['error'])_0x3da7fa(_0x26d7e9(0x1a5),_0x455900,_0x40c788?.[_0x26d7e9(0x152)]||'CommHub\x20rejected\x20task','send_rejected');else _0x3da7fa(_0x26d7e9(0x1a5),null,'CommHub\x20response\x20omitted\x20task_id',_0x26d7e9(0x1c6));}return _0x40c788;}catch(_0x4404f4){throw _0x3da7fa(_0x26d7e9(0x1a5),null,_0x4404f4,_0x26d7e9(0x18a)),_0x4404f4;}}async function Y(_0x29793a,_0x3cf3b7){const _0x1d4514=a0_0x219124;return X({'fromAlias':_0x29793a[_0x1d4514(0x1ce)],'toAlias':_0x29793a[_0x1d4514(0x185)],'parentTaskId':_0x29793a[_0x1d4514(0x1a9)]||null,'networkId':_0x29793a[_0x1d4514(0x1c4)]||null,'transport':'mcp_http','lifecycleTracking':'not_tracked'},_0x3cf3b7);}class $ extends a0_0x206828{['url'];[a0_0x219124(0x185)];[a0_0x219124(0x166)];[a0_0x219124(0x1a7)];[a0_0x219124(0x1aa)];[a0_0x219124(0x161)];[a0_0x219124(0x1c1)];[a0_0x219124(0x1ac)];[a0_0x219124(0x187)];['running']=!0x1;constructor(_0x3108f0){const _0x56748d=a0_0x219124;super();if(this[_0x56748d(0x1ae)]=_0x3108f0['url'][_0x56748d(0x1a0)](/\/$/,''),this[_0x56748d(0x185)]=_0x3108f0['alias'],this['token']=_0x3108f0['token'],this[_0x56748d(0x1a7)]=_0x3108f0['agent']||_0x56748d(0x1ad),this[_0x56748d(0x1aa)]=_0x56748d(0x1c8)+_0x3108f0['alias']+'-'+Date[_0x56748d(0x175)]()[_0x56748d(0x182)](0x24),this[_0x56748d(0x161)]=_0x3108f0[_0x56748d(0x161)]??0x2bf20,this['reconnectDelay']=_0x3108f0['reconnectDelay']??0xbb8,_0x3108f0[_0x56748d(0x178)]!==!0x1)this[_0x56748d(0x159)]();}['log'](_0x81cd46){const _0x272dbb=a0_0x219124;console[_0x272dbb(0x15f)]('['+new Date()[_0x272dbb(0x1be)]()['slice'](0x0,0x8)+']\x20[commhub:'+this[_0x272dbb(0x185)]+']\x20'+_0x81cd46);}async[a0_0x219124(0x1cb)](_0x331b9b,_0x275b1d){const _0xac907b=a0_0x219124;let _0x4b6542={'Content-Type':'application/json','Accept':'application/json,\x20text/event-stream'};if(this[_0xac907b(0x166)])_0x4b6542[_0xac907b(0x16e)]='Bearer\x20'+this[_0xac907b(0x166)];let _0x421a08=await(await fetch(this['url']+_0xac907b(0x153),{'method':_0xac907b(0x1ca),'headers':_0x4b6542,'body':JSON[_0xac907b(0x1cc)]({'jsonrpc':_0xac907b(0x1bd),'id':Date[_0xac907b(0x175)](),'method':_0xac907b(0x1b3),'params':{'name':_0x331b9b,'arguments':_0x275b1d}})}))[_0xac907b(0x16a)](),_0x457ed4=_0x421a08[_0xac907b(0x192)](/data: (.+)/),_0x5d9024=_0x457ed4?JSON[_0xac907b(0x17c)](_0x457ed4[0x1]):JSON['parse'](_0x421a08),_0x35c497=_0x5d9024?.[_0xac907b(0x16c)]?.[_0xac907b(0x169)]?.[0x0]?.[_0xac907b(0x16a)];return _0x35c497?JSON[_0xac907b(0x17c)](_0x35c497):_0x5d9024;}async['connect'](){const _0x207146=a0_0x219124;if(this[_0x207146(0x1a2)])return;this['running']=!0x0,await this['status'](_0x207146(0x1bf)),this[_0x207146(0x15f)](_0x207146(0x17b)),this[_0x207146(0x1ac)]=setInterval(()=>{const _0x28bd01=_0x207146;this[_0x28bd01(0x167)](_0x28bd01(0x1bf))[_0x28bd01(0x15e)](_0x53fe13=>this[_0x28bd01(0x15f)]('heartbeat\x20failed:\x20'+_0x53fe13[_0x28bd01(0x19f)]));},this[_0x207146(0x161)]),this[_0x207146(0x18b)]();}async['disconnect'](){const _0x307b9b=a0_0x219124;if(this[_0x307b9b(0x1a2)]=!0x1,this[_0x307b9b(0x187)]?.[_0x307b9b(0x15a)](),this[_0x307b9b(0x1ac)])clearInterval(this[_0x307b9b(0x1ac)]);await this[_0x307b9b(0x167)](_0x307b9b(0x164))[_0x307b9b(0x15e)](()=>{}),this[_0x307b9b(0x15f)]('disconnected');}async[a0_0x219124(0x1b4)](_0x2f823b,_0x2cf4e1,_0x467673=a0_0x219124(0x155)){const _0xdd4da1=a0_0x219124;return Y({'alias':_0x2f823b,'fromAlias':this[_0xdd4da1(0x185)]},{'log':_0x3e010f=>console['log'](_0x3e010f),'send':()=>this[_0xdd4da1(0x1cb)](_0xdd4da1(0x1b2),{'alias':_0x2f823b,'task':_0x2cf4e1,'priority':_0x467673,'from_session':this['alias']})});}async[a0_0x219124(0x19f)](_0x4d2135,_0x24924a){const _0x164265=a0_0x219124;return this[_0x164265(0x1cb)](_0x164265(0x170),{'alias':_0x4d2135,'message':_0x24924a,'from_session':this['alias']});}async[a0_0x219124(0x1ab)](_0x23ada8,_0x2a6fd8,_0xdc630a=a0_0x219124(0x184)){const _0x529c7d=a0_0x219124;return this[_0x529c7d(0x1cb)](_0x529c7d(0x19a),{'in_reply_to':_0x23ada8,'text':_0x2a6fd8,'status':_0xdc630a});}async[a0_0x219124(0x167)](_0xda6be9,_0x59f446){const _0x5b226e=a0_0x219124;return this[_0x5b226e(0x1cb)](_0x5b226e(0x199),{'resume_id':this[_0x5b226e(0x1aa)],'alias':this[_0x5b226e(0x185)],'status':_0xda6be9,'server':a0_0x344b1e(),'hostname':a0_0x344b1e(),'agent':this['agent'],'project_dir':process['cwd'](),..._0x59f446});}async[a0_0x219124(0x193)](){const _0x8403ae=a0_0x219124;return this[_0x8403ae(0x1cb)]('get_all_status',{});}async[a0_0x219124(0x186)](_0xc8f13,_0x326ca9){const _0x127b50=a0_0x219124;return this[_0x127b50(0x1cb)](_0x127b50(0x186),{'message':_0xc8f13,'filter_server':_0x326ca9?.[_0x127b50(0x18f)],'filter_status':_0x326ca9?.[_0x127b50(0x167)]});}async['connectSSE'](){const _0x3f1b2f=a0_0x219124;let _0x18d932=encodeURIComponent(this[_0x3f1b2f(0x185)]),_0x3cca56=this[_0x3f1b2f(0x1ae)]+_0x3f1b2f(0x1bb)+_0x18d932,_0x47e734=this[_0x3f1b2f(0x1c1)];while(this['running']){try{this[_0x3f1b2f(0x187)]=new AbortController();let _0x386c2e={'Accept':_0x3f1b2f(0x196)};if(this[_0x3f1b2f(0x166)])_0x386c2e[_0x3f1b2f(0x16e)]=_0x3f1b2f(0x158)+this[_0x3f1b2f(0x166)];let _0x16ece8=await fetch(_0x3cca56,{'headers':_0x386c2e,'signal':this['sseAbort'][_0x3f1b2f(0x181)]});if(!_0x16ece8['ok']||!_0x16ece8['body']){this[_0x3f1b2f(0x15f)](_0x3f1b2f(0x17d)+_0x16ece8[_0x3f1b2f(0x167)]),await this[_0x3f1b2f(0x173)](_0x47e734),_0x47e734=Math[_0x3f1b2f(0x1b5)](_0x47e734*1.5,0xea60);continue;}_0x47e734=this[_0x3f1b2f(0x1c1)];let _0x1f37f=_0x16ece8['body'][_0x3f1b2f(0x194)](),_0x397f8e=new TextDecoder(),_0x147357='';while(this[_0x3f1b2f(0x1a2)]){let {done:_0x38ee61,value:_0x386044}=await _0x1f37f[_0x3f1b2f(0x1ba)]();if(_0x38ee61)break;_0x147357+=_0x397f8e[_0x3f1b2f(0x154)](_0x386044,{'stream':!0x0});let _0x576049=_0x147357[_0x3f1b2f(0x16f)]('\x0a');_0x147357=_0x576049[_0x3f1b2f(0x1b9)]()||'';for(let _0x8f4d46 of _0x576049){if(!_0x8f4d46['startsWith'](_0x3f1b2f(0x188)))continue;try{let _0x373c94=JSON[_0x3f1b2f(0x17c)](_0x8f4d46[_0x3f1b2f(0x163)](0x6));if(_0x373c94[_0x3f1b2f(0x1b6)]===_0x3f1b2f(0x1a8)){this[_0x3f1b2f(0x15f)](_0x3f1b2f(0x1b1)),this['emit']('connected');continue;}if(_0x373c94['type']==='new_task'||_0x373c94[_0x3f1b2f(0x1b6)]===_0x3f1b2f(0x1c7)||_0x373c94[_0x3f1b2f(0x1b6)]===_0x3f1b2f(0x186))await this[_0x3f1b2f(0x1c2)]();}catch{}}}}catch(_0x458d38){if(_0x458d38[_0x3f1b2f(0x19b)]==='AbortError')break;this[_0x3f1b2f(0x1a4)]('error',_0x458d38),this[_0x3f1b2f(0x15f)](_0x3f1b2f(0x1cf)+_0x458d38[_0x3f1b2f(0x19f)]);}if(this['running'])this[_0x3f1b2f(0x1a4)]('disconnected'),this['log'](_0x3f1b2f(0x18c)+_0x47e734/0x3e8+_0x3f1b2f(0x156)),await this[_0x3f1b2f(0x173)](_0x47e734),_0x47e734=Math[_0x3f1b2f(0x1b5)](_0x47e734*1.5,0xea60);}}async['processInbox'](){const _0x5990e7=a0_0x219124;try{let _0x415fba=(await this[_0x5990e7(0x1cb)](_0x5990e7(0x1af),{'alias':this[_0x5990e7(0x185)],'limit':0xa}))?.['messages']||[];for(let _0x3fc826 of _0x415fba)await this[_0x5990e7(0x1cb)](_0x5990e7(0x1c0),{'alias':this['alias'],'message_id':_0x3fc826['id']}),this['log']('←\x20'+_0x3fc826[_0x5990e7(0x19c)]+':\x20'+_0x3fc826[_0x5990e7(0x169)][_0x5990e7(0x163)](0x0,0x3c)),this[_0x5990e7(0x1a4)](_0x5990e7(0x165),_0x3fc826),this[_0x5990e7(0x1a4)](_0x5990e7(0x19f),_0x3fc826);}catch(_0x4406c3){this['log'](_0x5990e7(0x168)+_0x4406c3[_0x5990e7(0x19f)]);}}[a0_0x219124(0x173)](_0x1076bc){return new Promise(_0x51b7a5=>setTimeout(_0x51b7a5,_0x1076bc));}}var F=$;export{F as default,$ as CommHub};
|
|
1
|
+
const a0_0x7d5828=a0_0x338f;(function(_0xd6d64a,_0x11236c){const _0x924cf1=a0_0x338f,_0x14044d=_0xd6d64a();while(!![]){try{const _0x545633=parseInt(_0x924cf1(0x13d))/0x1*(parseInt(_0x924cf1(0x176))/0x2)+-parseInt(_0x924cf1(0x193))/0x3*(-parseInt(_0x924cf1(0x132))/0x4)+parseInt(_0x924cf1(0x196))/0x5*(-parseInt(_0x924cf1(0x17f))/0x6)+-parseInt(_0x924cf1(0x12e))/0x7+-parseInt(_0x924cf1(0x189))/0x8*(-parseInt(_0x924cf1(0x154))/0x9)+-parseInt(_0x924cf1(0x142))/0xa+-parseInt(_0x924cf1(0x147))/0xb*(-parseInt(_0x924cf1(0x14c))/0xc);if(_0x545633===_0x11236c)break;else _0x14044d['push'](_0x14044d['shift']());}catch(_0x594ccd){_0x14044d['push'](_0x14044d['shift']());}}}(a0_0x18c6,0x6c81c));import{EventEmitter as a0_0x2bef32}from'events';import{hostname as a0_0x531741}from'os';function a0_0x338f(_0x2ab3c2,_0x314016){_0x2ab3c2=_0x2ab3c2-0x118;const _0x18c632=a0_0x18c6();let _0x338f6a=_0x18c632[_0x2ab3c2];return _0x338f6a;}var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x45852e,_0x296694)=>(_0x45852e??_0x296694)[a0_0x7d5828(0x13e)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x474fd4){const _0x3894b2=a0_0x7d5828;return(_0x474fd4 instanceof Error?_0x474fd4[_0x3894b2(0x18c)]:String(_0x474fd4??'unknown\x20error'))['replace'](K,_0x3894b2(0x11c))[_0x3894b2(0x13e)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x3894b2(0x194)](0x0,0xf0);}function O(_0x8ceca6,_0x4964cf=process.env.ANET_TASK_TRACE_FORMAT===a0_0x7d5828(0x177)){const _0x1bb1f0=a0_0x7d5828;if(_0x4964cf)return JSON[_0x1bb1f0(0x15a)](_0x8ceca6);let _0x4193f8=L(_0x8ceca6[_0x1bb1f0(0x165)],_0x1bb1f0(0x14b)),_0x124acd=L(_0x8ceca6[_0x1bb1f0(0x145)],'<pending>'),_0xf3da98=_0x8ceca6['error_code']?_0x1bb1f0(0x164)+_0x8ceca6[_0x1bb1f0(0x14a)]+':'+(_0x8ceca6[_0x1bb1f0(0x174)]??''):'';return'[commhub:task]\x20'+_0x8ceca6[_0x1bb1f0(0x11e)]+'\x20from='+L(_0x8ceca6[_0x1bb1f0(0x129)],_0x1bb1f0(0x160))+'\x20to='+L(_0x8ceca6[_0x1bb1f0(0x11d)],_0x1bb1f0(0x160))+_0x1bb1f0(0x16f)+_0x124acd+_0x1bb1f0(0x12f)+_0x4193f8+_0x1bb1f0(0x18a)+L(_0x8ceca6['network_id'],_0x1bb1f0(0x160))+_0x1bb1f0(0x184)+_0x8ceca6[_0x1bb1f0(0x134)]+_0x1bb1f0(0x153)+_0x8ceca6[_0x1bb1f0(0x127)]+_0x1bb1f0(0x18e)+_0x8ceca6[_0x1bb1f0(0x159)]+_0xf3da98;}function U(_0x439548){const _0x13b04d=a0_0x7d5828;return{'event':{'sending':_0x13b04d(0x12b),'delivered':_0x13b04d(0x199),'failed':'task.send.failed','acked':_0x13b04d(0x144),'started':_0x13b04d(0x158),'replied':_0x13b04d(0x128),'expired':_0x13b04d(0x11a)}[_0x439548[_0x13b04d(0x11e)]],..._0x439548};}function a0_0x18c6(){const _0x114a0c=['parent_task_id','autoConnect','alias','connect','error','messages','url','toTimeString','sdk-','inbox\x20error:\x20','\x20task_id=','SSE\x20error:\x20',']\x20[commhub:','send_rejected','sleep','error_message','reconnectDelay','1765316ikTcrz','json','data:\x20','text','connected','cwd','fromAlias','application/json','ack_inbox','2724NRZtXA','server','get_inbox','sseAbort','agent','\x20transport=','heartbeatInterval','abort','Bearer\x20','broadcast','94448HaCJdH','\x20network_id=','CommHub\x20response\x20omitted\x20task_id','message','pop','\x20lifecycle=','idle','task','log','emit','9LkDxGa','slice','min','7435klZIMU','heartbeatTimer','now','task.send.delivered','connectSSE','parentTaskId','task.expired','POST','[REDACTED]','to_alias','status','send_failed','networkId','get_all_status','content','tools/call','resumeId','send','/events/','duration_ms','task.replied','from_alias','from_session','task.send.start','running','application/json,\x20text/event-stream','2481038JTdMAc','\x20parent_task_id=','toAlias','startsWith','1107112NrHRMY','disconnect','transport','lifecycleTracking','send_task','body','type','CommHub\x20rejected\x20task','missing_task_id','parse','signal','1eZUeix','replace','s...','send_message','failed','7518280OuLZgd','toString','task.ack','task_id','/mcp','83589tANogS','sending','processInbox','error_code','<missing>','120OFKqEk','SSE\x20reconnecting\x20in\x20','disconnected','normal','token','split','message_id','\x20duration_ms=','333IgPkXR','getReader','call','reply','task.started','lifecycle_tracking','stringify','Authorization','catch','2.0','name','heartbeat\x20failed:\x20','<unknown>','new_message','decode','new_task','\x20error='];a0_0x18c6=function(){return _0x114a0c;};return a0_0x18c6();}function j(_0x40e58c){const _0x355198=a0_0x7d5828;let _0x1552b6=_0x40e58c?.[_0x355198(0x145)]||_0x40e58c?.[_0x355198(0x152)]||_0x40e58c?.['id'];if(_0x1552b6)return String(_0x1552b6);let _0x1fc941=_0x40e58c?.[_0x355198(0x122)]?.[0x0]?.[_0x355198(0x179)];if(typeof _0x1fc941!=='string')return null;try{let _0x374365=JSON[_0x355198(0x13b)](_0x1fc941);return _0x374365?.[_0x355198(0x145)]||_0x374365?.[_0x355198(0x152)]||_0x374365?.['id']||null;}catch{return null;}}async function X(_0x25df39,_0x37271e){const _0x4113a6=a0_0x7d5828;let _0x34ddfb=_0x37271e[_0x4113a6(0x198)]??Date[_0x4113a6(0x198)],_0x4ace99=_0x34ddfb(),_0x48aa6a=(_0xdd8c6f,_0x82d8a3,_0x32024f,_0x284f24)=>{const _0x1999aa=_0x4113a6;_0x37271e[_0x1999aa(0x191)](O(U({'from_alias':_0x25df39[_0x1999aa(0x17c)],'to_alias':_0x25df39[_0x1999aa(0x130)],'task_id':_0x82d8a3,'parent_task_id':_0x25df39['parentTaskId'],'network_id':_0x25df39[_0x1999aa(0x120)],'transport':_0x25df39['transport'],'status':_0xdd8c6f,'duration_ms':_0x34ddfb()-_0x4ace99,'lifecycle_tracking':_0x25df39[_0x1999aa(0x135)],..._0x32024f!==void 0x0?{'error_code':_0x284f24||_0x1999aa(0x11f),'error_message':N(_0x32024f)}:{}})));};_0x48aa6a(_0x4113a6(0x148),null);try{let _0x5ef177=await _0x37271e[_0x4113a6(0x125)](),_0x2a33a3=j(_0x5ef177);if(_0x2a33a3)_0x48aa6a('delivered',_0x2a33a3);else{if(_0x5ef177?.['ok']===!0x1||_0x5ef177?.[_0x4113a6(0x169)])_0x48aa6a(_0x4113a6(0x141),_0x2a33a3,_0x5ef177?.[_0x4113a6(0x169)]||_0x4113a6(0x139),_0x4113a6(0x172));else _0x48aa6a('failed',null,_0x4113a6(0x18b),_0x4113a6(0x13a));}return _0x5ef177;}catch(_0x3b0700){throw _0x48aa6a(_0x4113a6(0x141),null,_0x3b0700,_0x4113a6(0x11f)),_0x3b0700;}}async function Y(_0x432d44,_0x3a1452){const _0x5c2c1f=a0_0x7d5828;return X({'fromAlias':_0x432d44['fromAlias'],'toAlias':_0x432d44['alias'],'parentTaskId':_0x432d44[_0x5c2c1f(0x119)]||null,'networkId':_0x432d44['networkId']||null,'transport':'mcp_http','lifecycleTracking':'not_tracked'},_0x3a1452);}class $ extends a0_0x2bef32{[a0_0x7d5828(0x16b)];[a0_0x7d5828(0x167)];[a0_0x7d5828(0x150)];[a0_0x7d5828(0x183)];[a0_0x7d5828(0x124)];[a0_0x7d5828(0x185)];[a0_0x7d5828(0x175)];[a0_0x7d5828(0x197)];[a0_0x7d5828(0x182)];['running']=!0x1;constructor(_0x263e44){const _0x42364e=a0_0x7d5828;super();if(this['url']=_0x263e44[_0x42364e(0x16b)]['replace'](/\/$/,''),this[_0x42364e(0x167)]=_0x263e44[_0x42364e(0x167)],this[_0x42364e(0x150)]=_0x263e44[_0x42364e(0x150)],this[_0x42364e(0x183)]=_0x263e44[_0x42364e(0x183)]||'sdk',this[_0x42364e(0x124)]=_0x42364e(0x16d)+_0x263e44['alias']+'-'+Date['now']()[_0x42364e(0x143)](0x24),this[_0x42364e(0x185)]=_0x263e44[_0x42364e(0x185)]??0x2bf20,this[_0x42364e(0x175)]=_0x263e44[_0x42364e(0x175)]??0xbb8,_0x263e44[_0x42364e(0x166)]!==!0x1)this[_0x42364e(0x168)]();}['log'](_0x2530bd){const _0xcfbe46=a0_0x7d5828;console[_0xcfbe46(0x191)]('['+new Date()[_0xcfbe46(0x16c)]()['slice'](0x0,0x8)+_0xcfbe46(0x171)+this[_0xcfbe46(0x167)]+']\x20'+_0x2530bd);}async[a0_0x7d5828(0x156)](_0x131989,_0x17ec47){const _0x25bc5f=a0_0x7d5828;let _0x4aff74={'Content-Type':_0x25bc5f(0x17d),'Accept':_0x25bc5f(0x12d)};if(this[_0x25bc5f(0x150)])_0x4aff74[_0x25bc5f(0x15b)]=_0x25bc5f(0x187)+this[_0x25bc5f(0x150)];let _0x28ebd7=await(await fetch(this[_0x25bc5f(0x16b)]+_0x25bc5f(0x146),{'method':_0x25bc5f(0x11b),'headers':_0x4aff74,'body':JSON[_0x25bc5f(0x15a)]({'jsonrpc':_0x25bc5f(0x15d),'id':Date['now'](),'method':_0x25bc5f(0x123),'params':{'name':_0x131989,'arguments':_0x17ec47}})}))[_0x25bc5f(0x179)](),_0xee974d=_0x28ebd7['match'](/data: (.+)/),_0x143b06=_0xee974d?JSON[_0x25bc5f(0x13b)](_0xee974d[0x1]):JSON[_0x25bc5f(0x13b)](_0x28ebd7),_0x537cfe=_0x143b06?.['result']?.['content']?.[0x0]?.[_0x25bc5f(0x179)];return _0x537cfe?JSON[_0x25bc5f(0x13b)](_0x537cfe):_0x143b06;}async['connect'](){const _0xfc781a=a0_0x7d5828;if(this[_0xfc781a(0x12c)])return;this['running']=!0x0,await this[_0xfc781a(0x11e)](_0xfc781a(0x18f)),this[_0xfc781a(0x191)]('registered'),this['heartbeatTimer']=setInterval(()=>{const _0x59063e=_0xfc781a;this[_0x59063e(0x11e)](_0x59063e(0x18f))[_0x59063e(0x15c)](_0x1bfcc1=>this[_0x59063e(0x191)](_0x59063e(0x15f)+_0x1bfcc1['message']));},this[_0xfc781a(0x185)]),this[_0xfc781a(0x118)]();}async[a0_0x7d5828(0x133)](){const _0x419771=a0_0x7d5828;if(this[_0x419771(0x12c)]=!0x1,this['sseAbort']?.[_0x419771(0x186)](),this[_0x419771(0x197)])clearInterval(this[_0x419771(0x197)]);await this[_0x419771(0x11e)]('offline')[_0x419771(0x15c)](()=>{}),this['log'](_0x419771(0x14e));}async['send'](_0x136da4,_0x5d7ede,_0x58a6bd=a0_0x7d5828(0x14f)){const _0x3cf86e=a0_0x7d5828;return Y({'alias':_0x136da4,'fromAlias':this[_0x3cf86e(0x167)]},{'log':_0x5667d4=>console[_0x3cf86e(0x191)](_0x5667d4),'send':()=>this[_0x3cf86e(0x156)](_0x3cf86e(0x136),{'alias':_0x136da4,'task':_0x5d7ede,'priority':_0x58a6bd,'from_session':this['alias']})});}async[a0_0x7d5828(0x18c)](_0x3877c3,_0x1cc0d6){const _0x1c1e80=a0_0x7d5828;return this[_0x1c1e80(0x156)](_0x1c1e80(0x140),{'alias':_0x3877c3,'message':_0x1cc0d6,'from_session':this['alias']});}async[a0_0x7d5828(0x157)](_0x1e0801,_0x2acc61,_0x2b88bb='completed'){const _0x20c563=a0_0x7d5828;return this[_0x20c563(0x156)]('send_reply',{'in_reply_to':_0x1e0801,'text':_0x2acc61,'status':_0x2b88bb});}async[a0_0x7d5828(0x11e)](_0x505fb1,_0x11287a){const _0x2b37ca=a0_0x7d5828;return this[_0x2b37ca(0x156)]('report_status',{'resume_id':this[_0x2b37ca(0x124)],'alias':this[_0x2b37ca(0x167)],'status':_0x505fb1,'server':a0_0x531741(),'hostname':a0_0x531741(),'agent':this[_0x2b37ca(0x183)],'project_dir':process[_0x2b37ca(0x17b)](),..._0x11287a});}async['getAllStatus'](){const _0xc4a23f=a0_0x7d5828;return this['call'](_0xc4a23f(0x121),{});}async[a0_0x7d5828(0x188)](_0x20c61,_0x8f9d70){const _0x271fd8=a0_0x7d5828;return this[_0x271fd8(0x156)]('broadcast',{'message':_0x20c61,'filter_server':_0x8f9d70?.[_0x271fd8(0x180)],'filter_status':_0x8f9d70?.[_0x271fd8(0x11e)]});}async[a0_0x7d5828(0x118)](){const _0x429c37=a0_0x7d5828;let _0x4a5651=encodeURIComponent(this[_0x429c37(0x167)]),_0x790f25=this[_0x429c37(0x16b)]+_0x429c37(0x126)+_0x4a5651,_0x5826d2=this[_0x429c37(0x175)];while(this[_0x429c37(0x12c)]){try{this[_0x429c37(0x182)]=new AbortController();let _0x41ac31={'Accept':'text/event-stream'};if(this[_0x429c37(0x150)])_0x41ac31[_0x429c37(0x15b)]='Bearer\x20'+this[_0x429c37(0x150)];let _0x33ab2f=await fetch(_0x790f25,{'headers':_0x41ac31,'signal':this['sseAbort'][_0x429c37(0x13c)]});if(!_0x33ab2f['ok']||!_0x33ab2f['body']){this[_0x429c37(0x191)]('SSE\x20failed:\x20'+_0x33ab2f['status']),await this[_0x429c37(0x173)](_0x5826d2),_0x5826d2=Math[_0x429c37(0x195)](_0x5826d2*1.5,0xea60);continue;}_0x5826d2=this[_0x429c37(0x175)];let _0x4cf04e=_0x33ab2f[_0x429c37(0x137)][_0x429c37(0x155)](),_0xd7d456=new TextDecoder(),_0x58ccc1='';while(this[_0x429c37(0x12c)]){let {done:_0x132801,value:_0x161ef3}=await _0x4cf04e['read']();if(_0x132801)break;_0x58ccc1+=_0xd7d456[_0x429c37(0x162)](_0x161ef3,{'stream':!0x0});let _0x4701a2=_0x58ccc1[_0x429c37(0x151)]('\x0a');_0x58ccc1=_0x4701a2[_0x429c37(0x18d)]()||'';for(let _0x243a27 of _0x4701a2){if(!_0x243a27[_0x429c37(0x131)](_0x429c37(0x178)))continue;try{let _0x2d79ae=JSON[_0x429c37(0x13b)](_0x243a27['slice'](0x6));if(_0x2d79ae[_0x429c37(0x138)]===_0x429c37(0x17a)){this[_0x429c37(0x191)]('SSE\x20connected'),this['emit'](_0x429c37(0x17a));continue;}if(_0x2d79ae[_0x429c37(0x138)]===_0x429c37(0x163)||_0x2d79ae['type']===_0x429c37(0x161)||_0x2d79ae[_0x429c37(0x138)]===_0x429c37(0x188))await this[_0x429c37(0x149)]();}catch{}}}}catch(_0x176517){if(_0x176517[_0x429c37(0x15e)]==='AbortError')break;this['emit'](_0x429c37(0x169),_0x176517),this[_0x429c37(0x191)](_0x429c37(0x170)+_0x176517[_0x429c37(0x18c)]);}if(this['running'])this[_0x429c37(0x192)](_0x429c37(0x14e)),this[_0x429c37(0x191)](_0x429c37(0x14d)+_0x5826d2/0x3e8+_0x429c37(0x13f)),await this['sleep'](_0x5826d2),_0x5826d2=Math[_0x429c37(0x195)](_0x5826d2*1.5,0xea60);}}async[a0_0x7d5828(0x149)](){const _0x5054d9=a0_0x7d5828;try{let _0x10295f=(await this['call'](_0x5054d9(0x181),{'alias':this[_0x5054d9(0x167)],'limit':0xa}))?.[_0x5054d9(0x16a)]||[];for(let _0x1d4a63 of _0x10295f)await this[_0x5054d9(0x156)](_0x5054d9(0x17e),{'alias':this[_0x5054d9(0x167)],'message_id':_0x1d4a63['id']}),this['log']('←\x20'+_0x1d4a63[_0x5054d9(0x12a)]+':\x20'+_0x1d4a63[_0x5054d9(0x122)][_0x5054d9(0x194)](0x0,0x3c)),this[_0x5054d9(0x192)](_0x5054d9(0x190),_0x1d4a63),this[_0x5054d9(0x192)]('message',_0x1d4a63);}catch(_0x37fa39){this[_0x5054d9(0x191)](_0x5054d9(0x16e)+_0x37fa39[_0x5054d9(0x18c)]);}}[a0_0x7d5828(0x173)](_0xec066f){return new Promise(_0x4ac486=>setTimeout(_0x4ac486,_0xec066f));}}var F=$;export{F as default,$ as CommHub};
|