@sleep2agi/agent-network 2.3.0-preview.204 → 2.3.0-preview.206
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_0x5f3d88=a0_0x3353;(function(_0x2464c1,_0x59284a){const _0x5d274d=a0_0x3353,_0x51799b=_0x2464c1();while(!![]){try{const _0x573659=-parseInt(_0x5d274d(0x145))/0x1*(parseInt(_0x5d274d(0x13f))/0x2)+-parseInt(_0x5d274d(0x162))/0x3*(-parseInt(_0x5d274d(0x141))/0x4)+-parseInt(_0x5d274d(0x109))/0x5*(-parseInt(_0x5d274d(0x156))/0x6)+parseInt(_0x5d274d(0xfc))/0x7*(parseInt(_0x5d274d(0x14e))/0x8)+-parseInt(_0x5d274d(0x100))/0x9+parseInt(_0x5d274d(0x13d))/0xa+parseInt(_0x5d274d(0xfd))/0xb*(-parseInt(_0x5d274d(0x11a))/0xc);if(_0x573659===_0x59284a)break;else _0x51799b['push'](_0x51799b['shift']());}catch(_0x4e5f88){_0x51799b['push'](_0x51799b['shift']());}}}(a0_0x1b98,0x29477));import{EventEmitter as a0_0x592341}from'events';function a0_0x3353(_0x57f7d5,_0x5ea9ff){_0x57f7d5=_0x57f7d5-0xe2;const _0x1b98ad=a0_0x1b98();let _0x3353ea=_0x1b98ad[_0x57f7d5];return _0x3353ea;}import{hostname as a0_0x2e6272}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x4f7ee7,_0x19913c)=>(_0x4f7ee7??_0x19913c)[a0_0x5f3d88(0x154)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x5de5a1){const _0x52e08d=a0_0x5f3d88;return(_0x5de5a1 instanceof Error?_0x5de5a1[_0x52e08d(0x121)]:String(_0x5de5a1??_0x52e08d(0x11e)))[_0x52e08d(0x154)](K,'[REDACTED]')[_0x52e08d(0x154)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x52e08d(0x115)](0x0,0xf0);}function O(_0x59f58c,_0x2b8242=process.env.ANET_TASK_TRACE_FORMAT===a0_0x5f3d88(0x161)){const _0x40e048=a0_0x5f3d88;if(_0x2b8242)return JSON[_0x40e048(0x15d)](_0x59f58c);let _0x18dba5=L(_0x59f58c[_0x40e048(0x117)],_0x40e048(0x102)),_0x42813d=L(_0x59f58c['task_id'],'<pending>'),_0x31e702=_0x59f58c[_0x40e048(0xea)]?_0x40e048(0x14a)+_0x59f58c[_0x40e048(0xea)]+':'+(_0x59f58c[_0x40e048(0x113)]??''):'';return _0x40e048(0x118)+_0x59f58c[_0x40e048(0x15e)]+_0x40e048(0xe7)+L(_0x59f58c[_0x40e048(0xe9)],_0x40e048(0x14c))+_0x40e048(0x147)+L(_0x59f58c['to_alias'],'<unknown>')+_0x40e048(0x12c)+_0x42813d+_0x40e048(0xfa)+_0x18dba5+_0x40e048(0x163)+L(_0x59f58c[_0x40e048(0x134)],'<unknown>')+_0x40e048(0x128)+_0x59f58c['transport']+_0x40e048(0x120)+_0x59f58c['duration_ms']+'\x20lifecycle='+_0x59f58c['lifecycle_tracking']+_0x31e702;}function U(_0x5a6462){const _0x1d55bd=a0_0x5f3d88;return{'event':{'sending':_0x1d55bd(0x122),'delivered':_0x1d55bd(0xf9),'failed':_0x1d55bd(0x14b),'acked':_0x1d55bd(0x139),'started':'task.started','replied':_0x1d55bd(0x136),'expired':'task.expired'}[_0x5a6462['status']],..._0x5a6462};}function a0_0x1b98(){const _0x459959=['task.replied','disconnect','CommHub\x20rejected\x20task','task.ack','Bearer\x20','normal','sdk','2618570hRmhjT','report_status','7318foiRAX','pop','612828QhqVrY','agent','new_task','send_reply','27aptTmD','POST','\x20to=','disconnected','sseAbort','\x20error=','task.send.failed','<unknown>','get_all_status','1168sNHrBa','alias','connect','SSE\x20reconnecting\x20in\x20','getReader','reconnectDelay','replace','SSE\x20failed:\x20','24rkYZDB','call','running','text','match','type','parse','stringify','status','min','connectSSE','json','3KBcVsd','\x20network_id=','AbortError','error','token','missing_task_id','body','from_session','registered','completed','mcp_http','application/json,\x20text/event-stream','\x20from=','sending','from_alias','error_code','broadcast','parentTaskId','autoConnect','send_message','get_inbox','data:\x20','read','heartbeatInterval','messages','inbox\x20error:\x20','task_id','content','toString','not_tracked','task.send.delivered','\x20parent_task_id=','transport','7483XWcSZG','1624381LlOfUN','reply','connected','1797111UuWLMd','emit','<missing>','SSE\x20error:\x20','now','networkId','send_task','ack_inbox','message_id','55105dJXcqI','send','cwd','sleep','send_failed','delivered','log','resumeId','processInbox','result','error_message','getAllStatus','slice','toTimeString','parent_task_id','[commhub:task]\x20','fromAlias','12GjbfOp','catch','SSE\x20connected','CommHub\x20response\x20omitted\x20task_id','unknown\x20error','text/event-stream','\x20duration_ms=','message','task.send.start','heartbeatTimer','failed','toAlias','Authorization','lifecycleTracking','\x20transport=','url','/events/','heartbeat\x20failed:\x20','\x20task_id=','tools/call','abort','split','name','new_message','idle','signal','network_id','string'];a0_0x1b98=function(){return _0x459959;};return a0_0x1b98();}function j(_0xe529b7){const _0x7a9611=a0_0x5f3d88;let _0x5aca10=_0xe529b7?.[_0x7a9611(0xf5)]||_0xe529b7?.[_0x7a9611(0x108)]||_0xe529b7?.['id'];if(_0x5aca10)return String(_0x5aca10);let _0x1c6258=_0xe529b7?.[_0x7a9611(0xf6)]?.[0x0]?.[_0x7a9611(0x159)];if(typeof _0x1c6258!==_0x7a9611(0x135))return null;try{let _0x243337=JSON[_0x7a9611(0x15c)](_0x1c6258);return _0x243337?.['task_id']||_0x243337?.[_0x7a9611(0x108)]||_0x243337?.['id']||null;}catch{return null;}}async function X(_0x417aa8,_0x185c0a){const _0x22b96e=a0_0x5f3d88;let _0x3ee057=_0x185c0a[_0x22b96e(0x104)]??Date[_0x22b96e(0x104)],_0xe09c1e=_0x3ee057(),_0x1025a6=(_0x2dd2ca,_0x44727f,_0x3df653,_0xb13792)=>{const _0x15e438=_0x22b96e;_0x185c0a['log'](O(U({'from_alias':_0x417aa8['fromAlias'],'to_alias':_0x417aa8[_0x15e438(0x125)],'task_id':_0x44727f,'parent_task_id':_0x417aa8[_0x15e438(0xec)],'network_id':_0x417aa8['networkId'],'transport':_0x417aa8[_0x15e438(0xfb)],'status':_0x2dd2ca,'duration_ms':_0x3ee057()-_0xe09c1e,'lifecycle_tracking':_0x417aa8[_0x15e438(0x127)],..._0x3df653!==void 0x0?{'error_code':_0xb13792||_0x15e438(0x10d),'error_message':N(_0x3df653)}:{}})));};_0x1025a6(_0x22b96e(0xe8),null);try{let _0x5ea8ff=await _0x185c0a[_0x22b96e(0x10a)](),_0x1be2f5=j(_0x5ea8ff);if(_0x1be2f5)_0x1025a6(_0x22b96e(0x10e),_0x1be2f5);else{if(_0x5ea8ff?.['ok']===!0x1||_0x5ea8ff?.[_0x22b96e(0x165)])_0x1025a6('failed',_0x1be2f5,_0x5ea8ff?.[_0x22b96e(0x165)]||_0x22b96e(0x138),'send_rejected');else _0x1025a6(_0x22b96e(0x124),null,_0x22b96e(0x11d),_0x22b96e(0x167));}return _0x5ea8ff;}catch(_0x510b7b){throw _0x1025a6('failed',null,_0x510b7b,_0x22b96e(0x10d)),_0x510b7b;}}async function Y(_0x1b505a,_0x3c1dcb){const _0x294a30=a0_0x5f3d88;return X({'fromAlias':_0x1b505a[_0x294a30(0x119)],'toAlias':_0x1b505a[_0x294a30(0x14f)],'parentTaskId':_0x1b505a[_0x294a30(0xec)]||null,'networkId':_0x1b505a[_0x294a30(0x105)]||null,'transport':_0x294a30(0xe5),'lifecycleTracking':_0x294a30(0xf8)},_0x3c1dcb);}class $ extends a0_0x592341{[a0_0x5f3d88(0x129)];[a0_0x5f3d88(0x14f)];['token'];[a0_0x5f3d88(0x142)];[a0_0x5f3d88(0x110)];[a0_0x5f3d88(0xf2)];['reconnectDelay'];[a0_0x5f3d88(0x123)];[a0_0x5f3d88(0x149)];['running']=!0x1;constructor(_0xd79857){const _0x539994=a0_0x5f3d88;super();if(this[_0x539994(0x129)]=_0xd79857[_0x539994(0x129)][_0x539994(0x154)](/\/$/,''),this['alias']=_0xd79857[_0x539994(0x14f)],this[_0x539994(0x166)]=_0xd79857[_0x539994(0x166)],this[_0x539994(0x142)]=_0xd79857[_0x539994(0x142)]||_0x539994(0x13c),this[_0x539994(0x110)]='sdk-'+_0xd79857['alias']+'-'+Date[_0x539994(0x104)]()[_0x539994(0xf7)](0x24),this[_0x539994(0xf2)]=_0xd79857['heartbeatInterval']??0x2bf20,this[_0x539994(0x153)]=_0xd79857[_0x539994(0x153)]??0xbb8,_0xd79857[_0x539994(0xed)]!==!0x1)this['connect']();}[a0_0x5f3d88(0x10f)](_0x19760c){const _0x577cfe=a0_0x5f3d88;console[_0x577cfe(0x10f)]('['+new Date()[_0x577cfe(0x116)]()[_0x577cfe(0x115)](0x0,0x8)+']\x20[commhub:'+this[_0x577cfe(0x14f)]+']\x20'+_0x19760c);}async[a0_0x5f3d88(0x157)](_0x213755,_0x31501c){const _0x1d9c19=a0_0x5f3d88;let _0x4414c4={'Content-Type':'application/json','Accept':_0x1d9c19(0xe6)};if(this[_0x1d9c19(0x166)])_0x4414c4['Authorization']=_0x1d9c19(0x13a)+this[_0x1d9c19(0x166)];let _0x110e76=await(await fetch(this[_0x1d9c19(0x129)]+'/mcp',{'method':_0x1d9c19(0x146),'headers':_0x4414c4,'body':JSON['stringify']({'jsonrpc':'2.0','id':Date[_0x1d9c19(0x104)](),'method':_0x1d9c19(0x12d),'params':{'name':_0x213755,'arguments':_0x31501c}})}))[_0x1d9c19(0x159)](),_0x53f247=_0x110e76[_0x1d9c19(0x15a)](/data: (.+)/),_0x1f5a25=_0x53f247?JSON['parse'](_0x53f247[0x1]):JSON[_0x1d9c19(0x15c)](_0x110e76),_0x404f29=_0x1f5a25?.[_0x1d9c19(0x112)]?.[_0x1d9c19(0xf6)]?.[0x0]?.[_0x1d9c19(0x159)];return _0x404f29?JSON[_0x1d9c19(0x15c)](_0x404f29):_0x1f5a25;}async[a0_0x5f3d88(0x150)](){const _0x531463=a0_0x5f3d88;if(this[_0x531463(0x158)])return;this['running']=!0x0,await this[_0x531463(0x15e)](_0x531463(0x132)),this[_0x531463(0x10f)](_0x531463(0xe3)),this[_0x531463(0x123)]=setInterval(()=>{const _0x55457a=_0x531463;this[_0x55457a(0x15e)]('idle')['catch'](_0x1f0172=>this[_0x55457a(0x10f)](_0x55457a(0x12b)+_0x1f0172[_0x55457a(0x121)]));},this[_0x531463(0xf2)]),this[_0x531463(0x160)]();}async[a0_0x5f3d88(0x137)](){const _0x5c2e33=a0_0x5f3d88;if(this['running']=!0x1,this[_0x5c2e33(0x149)]?.[_0x5c2e33(0x12e)](),this['heartbeatTimer'])clearInterval(this['heartbeatTimer']);await this[_0x5c2e33(0x15e)]('offline')[_0x5c2e33(0x11b)](()=>{}),this[_0x5c2e33(0x10f)](_0x5c2e33(0x148));}async[a0_0x5f3d88(0x10a)](_0x25dafd,_0x2beabf,_0x1e9293=a0_0x5f3d88(0x13b)){const _0x35a737=a0_0x5f3d88;return Y({'alias':_0x25dafd,'fromAlias':this[_0x35a737(0x14f)]},{'log':_0x5b1672=>console[_0x35a737(0x10f)](_0x5b1672),'send':()=>this[_0x35a737(0x157)](_0x35a737(0x106),{'alias':_0x25dafd,'task':_0x2beabf,'priority':_0x1e9293,'from_session':this[_0x35a737(0x14f)]})});}async[a0_0x5f3d88(0x121)](_0x3fed29,_0x3b7746){const _0x4bbbca=a0_0x5f3d88;return this[_0x4bbbca(0x157)](_0x4bbbca(0xee),{'alias':_0x3fed29,'message':_0x3b7746,'from_session':this[_0x4bbbca(0x14f)]});}async[a0_0x5f3d88(0xfe)](_0x3fe9a3,_0x55b713,_0x48e718=a0_0x5f3d88(0xe4)){const _0x2ba835=a0_0x5f3d88;return this[_0x2ba835(0x157)](_0x2ba835(0x144),{'in_reply_to':_0x3fe9a3,'text':_0x55b713,'status':_0x48e718});}async[a0_0x5f3d88(0x15e)](_0x4e93a8,_0x1f62f6){const _0x5f08a9=a0_0x5f3d88;return this[_0x5f08a9(0x157)](_0x5f08a9(0x13e),{'resume_id':this[_0x5f08a9(0x110)],'alias':this[_0x5f08a9(0x14f)],'status':_0x4e93a8,'server':a0_0x2e6272(),'hostname':a0_0x2e6272(),'agent':this[_0x5f08a9(0x142)],'project_dir':process[_0x5f08a9(0x10b)](),..._0x1f62f6});}async[a0_0x5f3d88(0x114)](){const _0x26e53a=a0_0x5f3d88;return this[_0x26e53a(0x157)](_0x26e53a(0x14d),{});}async[a0_0x5f3d88(0xeb)](_0x39d57f,_0x456571){const _0x1be367=a0_0x5f3d88;return this[_0x1be367(0x157)](_0x1be367(0xeb),{'message':_0x39d57f,'filter_server':_0x456571?.['server'],'filter_status':_0x456571?.[_0x1be367(0x15e)]});}async[a0_0x5f3d88(0x160)](){const _0x2350e0=a0_0x5f3d88;let _0x50ff44=encodeURIComponent(this[_0x2350e0(0x14f)]),_0x455403=this[_0x2350e0(0x129)]+_0x2350e0(0x12a)+_0x50ff44,_0x376dd6=this['reconnectDelay'];while(this[_0x2350e0(0x158)]){try{this[_0x2350e0(0x149)]=new AbortController();let _0x59be7a={'Accept':_0x2350e0(0x11f)};if(this[_0x2350e0(0x166)])_0x59be7a[_0x2350e0(0x126)]=_0x2350e0(0x13a)+this[_0x2350e0(0x166)];let _0x16f9fd=await fetch(_0x455403,{'headers':_0x59be7a,'signal':this['sseAbort'][_0x2350e0(0x133)]});if(!_0x16f9fd['ok']||!_0x16f9fd[_0x2350e0(0x168)]){this[_0x2350e0(0x10f)](_0x2350e0(0x155)+_0x16f9fd[_0x2350e0(0x15e)]),await this[_0x2350e0(0x10c)](_0x376dd6),_0x376dd6=Math[_0x2350e0(0x15f)](_0x376dd6*1.5,0xea60);continue;}_0x376dd6=this[_0x2350e0(0x153)];let _0x19918e=_0x16f9fd[_0x2350e0(0x168)][_0x2350e0(0x152)](),_0xf67c34=new TextDecoder(),_0x220f8a='';while(this['running']){let {done:_0x2c76ff,value:_0x426481}=await _0x19918e[_0x2350e0(0xf1)]();if(_0x2c76ff)break;_0x220f8a+=_0xf67c34['decode'](_0x426481,{'stream':!0x0});let _0x13e528=_0x220f8a[_0x2350e0(0x12f)]('\x0a');_0x220f8a=_0x13e528[_0x2350e0(0x140)]()||'';for(let _0x5aea75 of _0x13e528){if(!_0x5aea75['startsWith'](_0x2350e0(0xf0)))continue;try{let _0xf7fd19=JSON[_0x2350e0(0x15c)](_0x5aea75[_0x2350e0(0x115)](0x6));if(_0xf7fd19[_0x2350e0(0x15b)]===_0x2350e0(0xff)){this[_0x2350e0(0x10f)](_0x2350e0(0x11c)),this['emit'](_0x2350e0(0xff));continue;}if(_0xf7fd19['type']===_0x2350e0(0x143)||_0xf7fd19['type']===_0x2350e0(0x131)||_0xf7fd19['type']==='broadcast')await this['processInbox']();}catch{}}}}catch(_0x3291cd){if(_0x3291cd[_0x2350e0(0x130)]===_0x2350e0(0x164))break;this[_0x2350e0(0x101)]('error',_0x3291cd),this[_0x2350e0(0x10f)](_0x2350e0(0x103)+_0x3291cd[_0x2350e0(0x121)]);}if(this[_0x2350e0(0x158)])this[_0x2350e0(0x101)]('disconnected'),this['log'](_0x2350e0(0x151)+_0x376dd6/0x3e8+'s...'),await this['sleep'](_0x376dd6),_0x376dd6=Math[_0x2350e0(0x15f)](_0x376dd6*1.5,0xea60);}}async[a0_0x5f3d88(0x111)](){const _0x13d02a=a0_0x5f3d88;try{let _0x1d3cd6=(await this[_0x13d02a(0x157)](_0x13d02a(0xef),{'alias':this[_0x13d02a(0x14f)],'limit':0xa}))?.[_0x13d02a(0xf3)]||[];for(let _0xfd89c7 of _0x1d3cd6)await this[_0x13d02a(0x157)](_0x13d02a(0x107),{'alias':this[_0x13d02a(0x14f)],'message_id':_0xfd89c7['id']}),this[_0x13d02a(0x10f)]('←\x20'+_0xfd89c7[_0x13d02a(0xe2)]+':\x20'+_0xfd89c7[_0x13d02a(0xf6)][_0x13d02a(0x115)](0x0,0x3c)),this[_0x13d02a(0x101)]('task',_0xfd89c7),this[_0x13d02a(0x101)]('message',_0xfd89c7);}catch(_0x22e031){this[_0x13d02a(0x10f)](_0x13d02a(0xf4)+_0x22e031[_0x13d02a(0x121)]);}}[a0_0x5f3d88(0x10c)](_0x1cf8e6){return new Promise(_0x220e8c=>setTimeout(_0x220e8c,_0x1cf8e6));}}var F=$;export{F as default,$ as CommHub};
|
|
1
|
+
const a0_0x4ab4f5=a0_0x4626;(function(_0x53633a,_0xa0cedc){const _0x6ccf95=a0_0x4626,_0x138f7d=_0x53633a();while(!![]){try{const _0x23ac7e=parseInt(_0x6ccf95(0x217))/0x1*(parseInt(_0x6ccf95(0x21d))/0x2)+-parseInt(_0x6ccf95(0x1c1))/0x3+parseInt(_0x6ccf95(0x1ff))/0x4+parseInt(_0x6ccf95(0x1ac))/0x5*(-parseInt(_0x6ccf95(0x1e5))/0x6)+parseInt(_0x6ccf95(0x202))/0x7+-parseInt(_0x6ccf95(0x212))/0x8+parseInt(_0x6ccf95(0x1fb))/0x9;if(_0x23ac7e===_0xa0cedc)break;else _0x138f7d['push'](_0x138f7d['shift']());}catch(_0x50b04a){_0x138f7d['push'](_0x138f7d['shift']());}}}(a0_0x5e33,0xc6917));function a0_0x4626(_0x5c648f,_0x183d8f){_0x5c648f=_0x5c648f-0x1a5;const _0x5e331e=a0_0x5e33();let _0x4626bd=_0x5e331e[_0x5c648f];return _0x4626bd;}import{EventEmitter as a0_0x1cc878}from'events';import{hostname as a0_0x8fbb80}from'os';function a0_0x5e33(){const _0x396160=['networkId','normal','url','get_all_status','cwd','slice','status','connect','idle','10580661hGQVUD','send_message','\x20task_id=','disconnected','314116ONObEV','result','task.send.start','9123695vwBGvG','failed','signal','token','from_alias','text','task','match','processInbox','toTimeString','\x20network_id=','lifecycle_tracking','Authorization','\x20error=','resumeId','min','10552584ymBgeV','s...','to_alias','message_id','reconnectDelay','3503CGqYKp','body','registered','/mcp','heartbeatInterval','task.send.delivered','888hzQrTv','heartbeat\x20failed:\x20','autoConnect','application/json,\x20text/event-stream','[REDACTED]','error_message','call','CommHub\x20response\x20omitted\x20task_id','\x20from=','[commhub:task]\x20','sleep','new_message','message','from_session','fromAlias','catch','type','5tXhazN','agent','transport','emit','get_inbox','running','SSE\x20error:\x20','parentTaskId','2.0','Bearer\x20','string','log','CommHub\x20rejected\x20task','now','read','offline','<pending>','abort','not_tracked','lifecycleTracking','task_id','4239432JHDFQr','completed','network_id','getAllStatus','sseAbort','pop','parent_task_id','send_reply','content','broadcast','missing_task_id','reply','send_failed','connectSSE','heartbeatTimer','POST','application/json','\x20parent_task_id=','task.replied','mcp_http','task.expired','send_task','delivered','error_code','<unknown>','data:\x20','alias',']\x20[commhub:','replace','task.started','<missing>','toAlias','SSE\x20connected','error','parse','/events/','3403938IOhnyv','\x20lifecycle=','getReader','toString','connected','stringify','decode','sending','\x20duration_ms=','name','inbox\x20error:\x20','startsWith','duration_ms'];a0_0x5e33=function(){return _0x396160;};return a0_0x5e33();}var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x374170,_0x5ee3a1)=>(_0x374170??_0x5ee3a1)[a0_0x4ab4f5(0x1dd)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x4ab4f5(0x1f7)](0x0,0xf0);function N(_0x11b4c1){const _0x29f5aa=a0_0x4ab4f5;return(_0x11b4c1 instanceof Error?_0x11b4c1[_0x29f5aa(0x1a7)]:String(_0x11b4c1??'unknown\x20error'))['replace'](K,_0x29f5aa(0x221))[_0x29f5aa(0x1dd)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x29116d,_0x324168=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x163d31=a0_0x4ab4f5;if(_0x324168)return JSON[_0x163d31(0x1ea)](_0x29116d);let _0x36f431=L(_0x29116d[_0x163d31(0x1c7)],_0x163d31(0x1df)),_0x26132c=L(_0x29116d[_0x163d31(0x1c0)],_0x163d31(0x1bc)),_0x2f5dd3=_0x29116d[_0x163d31(0x1d8)]?_0x163d31(0x20f)+_0x29116d['error_code']+':'+(_0x29116d[_0x163d31(0x222)]??''):'';return _0x163d31(0x226)+_0x29116d[_0x163d31(0x1f8)]+_0x163d31(0x225)+L(_0x29116d[_0x163d31(0x206)],_0x163d31(0x1d9))+'\x20to='+L(_0x29116d[_0x163d31(0x214)],_0x163d31(0x1d9))+_0x163d31(0x1fd)+_0x26132c+_0x163d31(0x1d2)+_0x36f431+_0x163d31(0x20c)+L(_0x29116d[_0x163d31(0x1c3)],_0x163d31(0x1d9))+'\x20transport='+_0x29116d[_0x163d31(0x1ae)]+_0x163d31(0x1ed)+_0x29116d[_0x163d31(0x1f1)]+_0x163d31(0x1e6)+_0x29116d[_0x163d31(0x20d)]+_0x2f5dd3;}function U(_0x2060b8){const _0x2477dc=a0_0x4ab4f5;return{'event':{'sending':_0x2477dc(0x201),'delivered':_0x2477dc(0x21c),'failed':'task.send.failed','acked':'task.ack','started':_0x2477dc(0x1de),'replied':_0x2477dc(0x1d3),'expired':_0x2477dc(0x1d5)}[_0x2060b8['status']],..._0x2060b8};}function j(_0x4a5c21){const _0x5d4078=a0_0x4ab4f5;let _0x2f6684=_0x4a5c21?.[_0x5d4078(0x1c0)]||_0x4a5c21?.['message_id']||_0x4a5c21?.['id'];if(_0x2f6684)return String(_0x2f6684);let _0x5aa685=_0x4a5c21?.[_0x5d4078(0x1c9)]?.[0x0]?.[_0x5d4078(0x207)];if(typeof _0x5aa685!==_0x5d4078(0x1b6))return null;try{let _0x47f4fc=JSON['parse'](_0x5aa685);return _0x47f4fc?.['task_id']||_0x47f4fc?.[_0x5d4078(0x215)]||_0x47f4fc?.['id']||null;}catch{return null;}}async function X(_0x37a13a,_0x51e85f){const _0x5d007f=a0_0x4ab4f5;let _0x25c6e1=_0x51e85f[_0x5d007f(0x1b9)]??Date['now'],_0xc112dd=_0x25c6e1(),_0x4bfd78=(_0x17c462,_0x3efd98,_0x44b54e,_0x486424)=>{const _0x5aa2b8=_0x5d007f;_0x51e85f[_0x5aa2b8(0x1b7)](O(U({'from_alias':_0x37a13a['fromAlias'],'to_alias':_0x37a13a[_0x5aa2b8(0x1e0)],'task_id':_0x3efd98,'parent_task_id':_0x37a13a[_0x5aa2b8(0x1b3)],'network_id':_0x37a13a['networkId'],'transport':_0x37a13a[_0x5aa2b8(0x1ae)],'status':_0x17c462,'duration_ms':_0x25c6e1()-_0xc112dd,'lifecycle_tracking':_0x37a13a[_0x5aa2b8(0x1bf)],..._0x44b54e!==void 0x0?{'error_code':_0x486424||_0x5aa2b8(0x1cd),'error_message':N(_0x44b54e)}:{}})));};_0x4bfd78(_0x5d007f(0x1ec),null);try{let _0x2adbc1=await _0x51e85f['send'](),_0x35ee5e=j(_0x2adbc1);if(_0x35ee5e)_0x4bfd78(_0x5d007f(0x1d7),_0x35ee5e);else{if(_0x2adbc1?.['ok']===!0x1||_0x2adbc1?.[_0x5d007f(0x1e2)])_0x4bfd78(_0x5d007f(0x203),_0x35ee5e,_0x2adbc1?.[_0x5d007f(0x1e2)]||_0x5d007f(0x1b8),'send_rejected');else _0x4bfd78(_0x5d007f(0x203),null,_0x5d007f(0x224),_0x5d007f(0x1cb));}return _0x2adbc1;}catch(_0x19ca9a){throw _0x4bfd78('failed',null,_0x19ca9a,_0x5d007f(0x1cd)),_0x19ca9a;}}async function Y(_0x265c6e,_0x14b6ad){const _0xcf2414=a0_0x4ab4f5;return X({'fromAlias':_0x265c6e[_0xcf2414(0x1a9)],'toAlias':_0x265c6e[_0xcf2414(0x1db)],'parentTaskId':_0x265c6e['parentTaskId']||null,'networkId':_0x265c6e[_0xcf2414(0x1f2)]||null,'transport':_0xcf2414(0x1d4),'lifecycleTracking':_0xcf2414(0x1be)},_0x14b6ad);}class $ extends a0_0x1cc878{[a0_0x4ab4f5(0x1f4)];[a0_0x4ab4f5(0x1db)];[a0_0x4ab4f5(0x205)];[a0_0x4ab4f5(0x1ad)];[a0_0x4ab4f5(0x210)];[a0_0x4ab4f5(0x21b)];[a0_0x4ab4f5(0x216)];[a0_0x4ab4f5(0x1cf)];[a0_0x4ab4f5(0x1c5)];['running']=!0x1;constructor(_0x532c49){const _0x106885=a0_0x4ab4f5;super();if(this[_0x106885(0x1f4)]=_0x532c49[_0x106885(0x1f4)][_0x106885(0x1dd)](/\/$/,''),this[_0x106885(0x1db)]=_0x532c49['alias'],this['token']=_0x532c49['token'],this[_0x106885(0x1ad)]=_0x532c49[_0x106885(0x1ad)]||'sdk',this[_0x106885(0x210)]='sdk-'+_0x532c49[_0x106885(0x1db)]+'-'+Date[_0x106885(0x1b9)]()[_0x106885(0x1e8)](0x24),this['heartbeatInterval']=_0x532c49[_0x106885(0x21b)]??0x2bf20,this['reconnectDelay']=_0x532c49[_0x106885(0x216)]??0xbb8,_0x532c49[_0x106885(0x21f)]!==!0x1)this[_0x106885(0x1f9)]();}['log'](_0x2a739a){const _0x5669cd=a0_0x4ab4f5;console[_0x5669cd(0x1b7)]('['+new Date()[_0x5669cd(0x20b)]()[_0x5669cd(0x1f7)](0x0,0x8)+_0x5669cd(0x1dc)+this['alias']+']\x20'+_0x2a739a);}async['call'](_0x35471f,_0x478d28){const _0x39bd4b=a0_0x4ab4f5;let _0x374076={'Content-Type':_0x39bd4b(0x1d1),'Accept':_0x39bd4b(0x220)};if(this[_0x39bd4b(0x205)])_0x374076[_0x39bd4b(0x20e)]=_0x39bd4b(0x1b5)+this[_0x39bd4b(0x205)];let _0x2ef452=await(await fetch(this[_0x39bd4b(0x1f4)]+_0x39bd4b(0x21a),{'method':_0x39bd4b(0x1d0),'headers':_0x374076,'body':JSON[_0x39bd4b(0x1ea)]({'jsonrpc':_0x39bd4b(0x1b4),'id':Date[_0x39bd4b(0x1b9)](),'method':'tools/call','params':{'name':_0x35471f,'arguments':_0x478d28}})}))[_0x39bd4b(0x207)](),_0x38f971=_0x2ef452[_0x39bd4b(0x209)](/data: (.+)/),_0x11d7c3=_0x38f971?JSON['parse'](_0x38f971[0x1]):JSON[_0x39bd4b(0x1e3)](_0x2ef452),_0x546135=_0x11d7c3?.[_0x39bd4b(0x200)]?.[_0x39bd4b(0x1c9)]?.[0x0]?.[_0x39bd4b(0x207)];return _0x546135?JSON[_0x39bd4b(0x1e3)](_0x546135):_0x11d7c3;}async['connect'](){const _0x12c7a0=a0_0x4ab4f5;if(this['running'])return;this[_0x12c7a0(0x1b1)]=!0x0,await this[_0x12c7a0(0x1f8)](_0x12c7a0(0x1fa)),this[_0x12c7a0(0x1b7)](_0x12c7a0(0x219)),this[_0x12c7a0(0x1cf)]=setInterval(()=>{const _0x56e55f=_0x12c7a0;this[_0x56e55f(0x1f8)](_0x56e55f(0x1fa))[_0x56e55f(0x1aa)](_0x51c931=>this[_0x56e55f(0x1b7)](_0x56e55f(0x21e)+_0x51c931['message']));},this[_0x12c7a0(0x21b)]),this[_0x12c7a0(0x1ce)]();}async['disconnect'](){const _0x35316d=a0_0x4ab4f5;if(this['running']=!0x1,this[_0x35316d(0x1c5)]?.[_0x35316d(0x1bd)](),this['heartbeatTimer'])clearInterval(this[_0x35316d(0x1cf)]);await this['status'](_0x35316d(0x1bb))['catch'](()=>{}),this[_0x35316d(0x1b7)](_0x35316d(0x1fe));}async['send'](_0x89ad08,_0x42db09,_0x3a3c83=a0_0x4ab4f5(0x1f3)){const _0x56c158=a0_0x4ab4f5;return Y({'alias':_0x89ad08,'fromAlias':this[_0x56c158(0x1db)]},{'log':_0x26983e=>console[_0x56c158(0x1b7)](_0x26983e),'send':()=>this['call'](_0x56c158(0x1d6),{'alias':_0x89ad08,'task':_0x42db09,'priority':_0x3a3c83,'from_session':this[_0x56c158(0x1db)]})});}async[a0_0x4ab4f5(0x1a7)](_0x504d11,_0x37c0f0){const _0x1416d4=a0_0x4ab4f5;return this[_0x1416d4(0x223)](_0x1416d4(0x1fc),{'alias':_0x504d11,'message':_0x37c0f0,'from_session':this[_0x1416d4(0x1db)]});}async[a0_0x4ab4f5(0x1cc)](_0xb65879,_0x1d506e,_0x3c8552=a0_0x4ab4f5(0x1c2)){const _0xf635cc=a0_0x4ab4f5;return this[_0xf635cc(0x223)](_0xf635cc(0x1c8),{'in_reply_to':_0xb65879,'text':_0x1d506e,'status':_0x3c8552});}async['status'](_0x53fc49,_0x56fd5c){const _0x2caae9=a0_0x4ab4f5;return this[_0x2caae9(0x223)]('report_status',{'resume_id':this['resumeId'],'alias':this[_0x2caae9(0x1db)],'status':_0x53fc49,'server':a0_0x8fbb80(),'hostname':a0_0x8fbb80(),'agent':this[_0x2caae9(0x1ad)],'project_dir':process[_0x2caae9(0x1f6)](),..._0x56fd5c});}async[a0_0x4ab4f5(0x1c4)](){const _0x3f8282=a0_0x4ab4f5;return this[_0x3f8282(0x223)](_0x3f8282(0x1f5),{});}async[a0_0x4ab4f5(0x1ca)](_0x3ccd1f,_0x4e2532){const _0x57090c=a0_0x4ab4f5;return this[_0x57090c(0x223)](_0x57090c(0x1ca),{'message':_0x3ccd1f,'filter_server':_0x4e2532?.['server'],'filter_status':_0x4e2532?.['status']});}async[a0_0x4ab4f5(0x1ce)](){const _0x4066a5=a0_0x4ab4f5;let _0x1011b7=encodeURIComponent(this['alias']),_0x485608=this['url']+_0x4066a5(0x1e4)+_0x1011b7,_0x4168dd=this[_0x4066a5(0x216)];while(this['running']){try{this['sseAbort']=new AbortController();let _0xe0255={'Accept':'text/event-stream'};if(this['token'])_0xe0255[_0x4066a5(0x20e)]='Bearer\x20'+this['token'];let _0xcf2722=await fetch(_0x485608,{'headers':_0xe0255,'signal':this[_0x4066a5(0x1c5)][_0x4066a5(0x204)]});if(!_0xcf2722['ok']||!_0xcf2722['body']){this[_0x4066a5(0x1b7)]('SSE\x20failed:\x20'+_0xcf2722[_0x4066a5(0x1f8)]),await this['sleep'](_0x4168dd),_0x4168dd=Math[_0x4066a5(0x211)](_0x4168dd*1.5,0xea60);continue;}_0x4168dd=this['reconnectDelay'];let _0x250656=_0xcf2722[_0x4066a5(0x218)][_0x4066a5(0x1e7)](),_0x526532=new TextDecoder(),_0x2e6843='';while(this[_0x4066a5(0x1b1)]){let {done:_0x3706a4,value:_0xae3beb}=await _0x250656[_0x4066a5(0x1ba)]();if(_0x3706a4)break;_0x2e6843+=_0x526532[_0x4066a5(0x1eb)](_0xae3beb,{'stream':!0x0});let _0x44139d=_0x2e6843['split']('\x0a');_0x2e6843=_0x44139d[_0x4066a5(0x1c6)]()||'';for(let _0x1b2bb8 of _0x44139d){if(!_0x1b2bb8[_0x4066a5(0x1f0)](_0x4066a5(0x1da)))continue;try{let _0x9e98c9=JSON[_0x4066a5(0x1e3)](_0x1b2bb8[_0x4066a5(0x1f7)](0x6));if(_0x9e98c9[_0x4066a5(0x1ab)]==='connected'){this[_0x4066a5(0x1b7)](_0x4066a5(0x1e1)),this[_0x4066a5(0x1af)](_0x4066a5(0x1e9));continue;}if(_0x9e98c9[_0x4066a5(0x1ab)]==='new_task'||_0x9e98c9[_0x4066a5(0x1ab)]===_0x4066a5(0x1a6)||_0x9e98c9[_0x4066a5(0x1ab)]===_0x4066a5(0x1ca))await this[_0x4066a5(0x20a)]();}catch{}}}}catch(_0x2feb34){if(_0x2feb34[_0x4066a5(0x1ee)]==='AbortError')break;this[_0x4066a5(0x1af)]('error',_0x2feb34),this[_0x4066a5(0x1b7)](_0x4066a5(0x1b2)+_0x2feb34[_0x4066a5(0x1a7)]);}if(this[_0x4066a5(0x1b1)])this[_0x4066a5(0x1af)]('disconnected'),this[_0x4066a5(0x1b7)]('SSE\x20reconnecting\x20in\x20'+_0x4168dd/0x3e8+_0x4066a5(0x213)),await this['sleep'](_0x4168dd),_0x4168dd=Math[_0x4066a5(0x211)](_0x4168dd*1.5,0xea60);}}async[a0_0x4ab4f5(0x20a)](){const _0x561a46=a0_0x4ab4f5;try{let _0x534aee=(await this[_0x561a46(0x223)](_0x561a46(0x1b0),{'alias':this['alias'],'limit':0xa}))?.['messages']||[];for(let _0x147bde of _0x534aee)await this[_0x561a46(0x223)]('ack_inbox',{'alias':this['alias'],'message_id':_0x147bde['id']}),this[_0x561a46(0x1b7)]('←\x20'+_0x147bde[_0x561a46(0x1a8)]+':\x20'+_0x147bde[_0x561a46(0x1c9)][_0x561a46(0x1f7)](0x0,0x3c)),this[_0x561a46(0x1af)](_0x561a46(0x208),_0x147bde),this[_0x561a46(0x1af)](_0x561a46(0x1a7),_0x147bde);}catch(_0x3ae733){this['log'](_0x561a46(0x1ef)+_0x3ae733['message']);}}[a0_0x4ab4f5(0x1a5)](_0x453a3a){return new Promise(_0x334e8d=>setTimeout(_0x334e8d,_0x453a3a));}}var F=$;export{F as default,$ as CommHub};
|