@sleep2agi/agent-network 2.3.0-preview.261 → 2.3.0-preview.263
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_0xf3c5e9=a0_0x2d5d;function a0_0x47d7(){const _0x697288=['task.ack','send_message','type','\x20error=','task.send.failed','\x20to=','body','AbortError','9448341nYALbi','idle','send_task','cwd','<unknown>','json','result','task.started','send_failed','lifecycleTracking','heartbeatInterval','stringify','connectSSE','alias','string','inbox\x20error:\x20','toTimeString','offline','heartbeatTimer','<pending>','task','url','report_status','reconnectDelay','614248rdtapu','application/json','task_id','catch','sdk-','connected','sseAbort','transport','unknown\x20error','failed',']\x20[commhub:','read','emit','processInbox','574FPMAMP','pop','error_code','message','match','get_all_status','SSE\x20connected','heartbeat\x20failed:\x20','getAllStatus','ack_inbox','[REDACTED]','\x20network_id=','status','startsWith','log','new_message','broadcast','SSE\x20error:\x20','parentTaskId','\x20task_id=','new_task','now','registered','SSE\x20failed:\x20','replace','autoConnect','name','fromAlias','/mcp','connect','agent','duration_ms','delivered','application/json,\x20text/event-stream','disconnect','get_inbox','sleep','mcp_http','networkId','text','send_reply','2459XSqmyn','toString','27139984GbvYuf','Bearer\x20','2.0','token','call','message_id','\x20lifecycle=','signal','getReader','completed','not_tracked','tools/call','Authorization','abort','send','text/event-stream','resumeId','parse','sdk','\x20parent_task_id=','disconnected','7641702zHEBZr','server','decode','reply','task.send.start','running','1596005xWMCYl','error_message','messages','split','4129902HvnzpC','slice','to_alias','error','SSE\x20reconnecting\x20in\x20','task.expired','parent_task_id','send_rejected','\x20transport='];a0_0x47d7=function(){return _0x697288;};return a0_0x47d7();}(function(_0x519baf,_0x19bc32){const _0x44da6c=a0_0x2d5d,_0x1c6c0d=_0x519baf();while(!![]){try{const _0x294412=parseInt(_0x44da6c(0x180))/0x1*(-parseInt(_0x44da6c(0x157))/0x2)+-parseInt(_0x44da6c(0x120))/0x3+-parseInt(_0x44da6c(0x149))/0x4+-parseInt(_0x44da6c(0x11c))/0x5+parseInt(_0x44da6c(0x116))/0x6+-parseInt(_0x44da6c(0x131))/0x7+parseInt(_0x44da6c(0x182))/0x8;if(_0x294412===_0x19bc32)break;else _0x1c6c0d['push'](_0x1c6c0d['shift']());}catch(_0x56aa82){_0x1c6c0d['push'](_0x1c6c0d['shift']());}}}(a0_0x47d7,0xb9d86));function a0_0x2d5d(_0x897c99,_0x2f95da){_0x897c99=_0x897c99-0x104;const _0x47d7fa=a0_0x47d7();let _0x2d5d46=_0x47d7fa[_0x897c99];return _0x2d5d46;}import{EventEmitter as a0_0x1b9ac9}from'events';import{hostname as a0_0x34540d}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0xdff4c,_0x5550c7)=>(_0xdff4c??_0x5550c7)[a0_0xf3c5e9(0x16f)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0xf3c5e9(0x121)](0x0,0xf0);function N(_0x166a59){const _0x3afda0=a0_0xf3c5e9;return(_0x166a59 instanceof Error?_0x166a59[_0x3afda0(0x15a)]:String(_0x166a59??_0x3afda0(0x151)))[_0x3afda0(0x16f)](K,_0x3afda0(0x161))[_0x3afda0(0x16f)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x3afda0(0x121)](0x0,0xf0);}function O(_0x18c641,_0x5b45bd=process.env.ANET_TASK_TRACE_FORMAT===a0_0xf3c5e9(0x136)){const _0x7a026e=a0_0xf3c5e9;if(_0x5b45bd)return JSON[_0x7a026e(0x13c)](_0x18c641);let _0x50e314=L(_0x18c641[_0x7a026e(0x126)],'<missing>'),_0x150f44=L(_0x18c641['task_id'],_0x7a026e(0x144)),_0x3efa61=_0x18c641[_0x7a026e(0x159)]?_0x7a026e(0x12c)+_0x18c641[_0x7a026e(0x159)]+':'+(_0x18c641[_0x7a026e(0x11d)]??''):'';return'[commhub:task]\x20'+_0x18c641[_0x7a026e(0x163)]+'\x20from='+L(_0x18c641['from_alias'],_0x7a026e(0x135))+_0x7a026e(0x12e)+L(_0x18c641[_0x7a026e(0x122)],_0x7a026e(0x135))+_0x7a026e(0x16a)+_0x150f44+_0x7a026e(0x114)+_0x50e314+_0x7a026e(0x162)+L(_0x18c641['network_id'],'<unknown>')+_0x7a026e(0x128)+_0x18c641[_0x7a026e(0x150)]+'\x20duration_ms='+_0x18c641[_0x7a026e(0x176)]+_0x7a026e(0x107)+_0x18c641['lifecycle_tracking']+_0x3efa61;}function U(_0x2e6619){const _0x4b5c6a=a0_0xf3c5e9;return{'event':{'sending':_0x4b5c6a(0x11a),'delivered':'task.send.delivered','failed':_0x4b5c6a(0x12d),'acked':_0x4b5c6a(0x129),'started':_0x4b5c6a(0x138),'replied':'task.replied','expired':_0x4b5c6a(0x125)}[_0x2e6619[_0x4b5c6a(0x163)]],..._0x2e6619};}function j(_0x2dcdf8){const _0x1560af=a0_0xf3c5e9;let _0x4a17c5=_0x2dcdf8?.[_0x1560af(0x14b)]||_0x2dcdf8?.[_0x1560af(0x106)]||_0x2dcdf8?.['id'];if(_0x4a17c5)return String(_0x4a17c5);let _0x1e47b4=_0x2dcdf8?.['content']?.[0x0]?.['text'];if(typeof _0x1e47b4!==_0x1560af(0x13f))return null;try{let _0x10f87e=JSON['parse'](_0x1e47b4);return _0x10f87e?.[_0x1560af(0x14b)]||_0x10f87e?.[_0x1560af(0x106)]||_0x10f87e?.['id']||null;}catch{return null;}}async function X(_0x98019b,_0x368bff){const _0x369a9a=a0_0xf3c5e9;let _0x229c26=_0x368bff[_0x369a9a(0x16c)]??Date[_0x369a9a(0x16c)],_0x2d4f77=_0x229c26(),_0x597bc7=(_0x51ba24,_0x79448b,_0x353439,_0x3a8062)=>{const _0x4fee3c=_0x369a9a;_0x368bff['log'](O(U({'from_alias':_0x98019b[_0x4fee3c(0x172)],'to_alias':_0x98019b['toAlias'],'task_id':_0x79448b,'parent_task_id':_0x98019b['parentTaskId'],'network_id':_0x98019b[_0x4fee3c(0x17d)],'transport':_0x98019b[_0x4fee3c(0x150)],'status':_0x51ba24,'duration_ms':_0x229c26()-_0x2d4f77,'lifecycle_tracking':_0x98019b[_0x4fee3c(0x13a)],..._0x353439!==void 0x0?{'error_code':_0x3a8062||_0x4fee3c(0x139),'error_message':N(_0x353439)}:{}})));};_0x597bc7('sending',null);try{let _0x41f60a=await _0x368bff[_0x369a9a(0x10f)](),_0x16590d=j(_0x41f60a);if(_0x16590d)_0x597bc7(_0x369a9a(0x177),_0x16590d);else{if(_0x41f60a?.['ok']===!0x1||_0x41f60a?.[_0x369a9a(0x123)])_0x597bc7(_0x369a9a(0x152),_0x16590d,_0x41f60a?.[_0x369a9a(0x123)]||'CommHub\x20rejected\x20task',_0x369a9a(0x127));else _0x597bc7(_0x369a9a(0x152),null,'CommHub\x20response\x20omitted\x20task_id','missing_task_id');}return _0x41f60a;}catch(_0x1ec0c9){throw _0x597bc7(_0x369a9a(0x152),null,_0x1ec0c9,'send_failed'),_0x1ec0c9;}}async function Y(_0x1ffab3,_0xaa9d9c){const _0x2500bd=a0_0xf3c5e9;return X({'fromAlias':_0x1ffab3[_0x2500bd(0x172)],'toAlias':_0x1ffab3[_0x2500bd(0x13e)],'parentTaskId':_0x1ffab3[_0x2500bd(0x169)]||null,'networkId':_0x1ffab3['networkId']||null,'transport':_0x2500bd(0x17c),'lifecycleTracking':_0x2500bd(0x10b)},_0xaa9d9c);}class $ extends a0_0x1b9ac9{[a0_0xf3c5e9(0x146)];['alias'];[a0_0xf3c5e9(0x104)];[a0_0xf3c5e9(0x175)];[a0_0xf3c5e9(0x111)];[a0_0xf3c5e9(0x13b)];[a0_0xf3c5e9(0x148)];[a0_0xf3c5e9(0x143)];['sseAbort'];[a0_0xf3c5e9(0x11b)]=!0x1;constructor(_0x252871){const _0x222e67=a0_0xf3c5e9;super();if(this['url']=_0x252871[_0x222e67(0x146)][_0x222e67(0x16f)](/\/$/,''),this[_0x222e67(0x13e)]=_0x252871[_0x222e67(0x13e)],this[_0x222e67(0x104)]=_0x252871[_0x222e67(0x104)],this[_0x222e67(0x175)]=_0x252871['agent']||_0x222e67(0x113),this['resumeId']=_0x222e67(0x14d)+_0x252871[_0x222e67(0x13e)]+'-'+Date[_0x222e67(0x16c)]()[_0x222e67(0x181)](0x24),this[_0x222e67(0x13b)]=_0x252871[_0x222e67(0x13b)]??0x2bf20,this[_0x222e67(0x148)]=_0x252871[_0x222e67(0x148)]??0xbb8,_0x252871[_0x222e67(0x170)]!==!0x1)this[_0x222e67(0x174)]();}[a0_0xf3c5e9(0x165)](_0x516e16){const _0x176a3f=a0_0xf3c5e9;console[_0x176a3f(0x165)]('['+new Date()[_0x176a3f(0x141)]()[_0x176a3f(0x121)](0x0,0x8)+_0x176a3f(0x153)+this['alias']+']\x20'+_0x516e16);}async[a0_0xf3c5e9(0x105)](_0x13f657,_0x5ec450){const _0x5d346a=a0_0xf3c5e9;let _0x54b3b1={'Content-Type':_0x5d346a(0x14a),'Accept':_0x5d346a(0x178)};if(this[_0x5d346a(0x104)])_0x54b3b1[_0x5d346a(0x10d)]=_0x5d346a(0x183)+this[_0x5d346a(0x104)];let _0x57b3bf=await(await fetch(this[_0x5d346a(0x146)]+_0x5d346a(0x173),{'method':'POST','headers':_0x54b3b1,'body':JSON[_0x5d346a(0x13c)]({'jsonrpc':_0x5d346a(0x184),'id':Date[_0x5d346a(0x16c)](),'method':_0x5d346a(0x10c),'params':{'name':_0x13f657,'arguments':_0x5ec450}})}))[_0x5d346a(0x17e)](),_0x4278f7=_0x57b3bf[_0x5d346a(0x15b)](/data: (.+)/),_0x50c98a=_0x4278f7?JSON[_0x5d346a(0x112)](_0x4278f7[0x1]):JSON['parse'](_0x57b3bf),_0x50569d=_0x50c98a?.[_0x5d346a(0x137)]?.['content']?.[0x0]?.[_0x5d346a(0x17e)];return _0x50569d?JSON[_0x5d346a(0x112)](_0x50569d):_0x50c98a;}async[a0_0xf3c5e9(0x174)](){const _0x4d0016=a0_0xf3c5e9;if(this[_0x4d0016(0x11b)])return;this[_0x4d0016(0x11b)]=!0x0,await this[_0x4d0016(0x163)]('idle'),this[_0x4d0016(0x165)](_0x4d0016(0x16d)),this[_0x4d0016(0x143)]=setInterval(()=>{const _0x295463=_0x4d0016;this['status'](_0x295463(0x132))[_0x295463(0x14c)](_0x50c25b=>this[_0x295463(0x165)](_0x295463(0x15e)+_0x50c25b['message']));},this['heartbeatInterval']),this[_0x4d0016(0x13d)]();}async[a0_0xf3c5e9(0x179)](){const _0x52628e=a0_0xf3c5e9;if(this[_0x52628e(0x11b)]=!0x1,this['sseAbort']?.[_0x52628e(0x10e)](),this['heartbeatTimer'])clearInterval(this[_0x52628e(0x143)]);await this['status'](_0x52628e(0x142))[_0x52628e(0x14c)](()=>{}),this[_0x52628e(0x165)](_0x52628e(0x115));}async[a0_0xf3c5e9(0x10f)](_0x35276f,_0x3dd7eb,_0x238bf1='normal'){const _0x268c79=a0_0xf3c5e9;return Y({'alias':_0x35276f,'fromAlias':this[_0x268c79(0x13e)]},{'log':_0x165f20=>console['log'](_0x165f20),'send':()=>this[_0x268c79(0x105)](_0x268c79(0x133),{'alias':_0x35276f,'task':_0x3dd7eb,'priority':_0x238bf1,'from_session':this[_0x268c79(0x13e)]})});}async[a0_0xf3c5e9(0x15a)](_0x14003c,_0x504b73){const _0x237dc3=a0_0xf3c5e9;return this[_0x237dc3(0x105)](_0x237dc3(0x12a),{'alias':_0x14003c,'message':_0x504b73,'from_session':this[_0x237dc3(0x13e)]});}async[a0_0xf3c5e9(0x119)](_0x79aa8c,_0x584b6f,_0x619fc6=a0_0xf3c5e9(0x10a)){const _0xc23dcf=a0_0xf3c5e9;return this[_0xc23dcf(0x105)](_0xc23dcf(0x17f),{'in_reply_to':_0x79aa8c,'text':_0x584b6f,'status':_0x619fc6});}async[a0_0xf3c5e9(0x163)](_0xea17a0,_0x50eaf4){const _0x3f4ec8=a0_0xf3c5e9;return this['call'](_0x3f4ec8(0x147),{'resume_id':this[_0x3f4ec8(0x111)],'alias':this[_0x3f4ec8(0x13e)],'status':_0xea17a0,'server':a0_0x34540d(),'hostname':a0_0x34540d(),'agent':this[_0x3f4ec8(0x175)],'project_dir':process[_0x3f4ec8(0x134)](),..._0x50eaf4});}async[a0_0xf3c5e9(0x15f)](){const _0x303f0f=a0_0xf3c5e9;return this[_0x303f0f(0x105)](_0x303f0f(0x15c),{});}async['broadcast'](_0x415428,_0x320542){const _0x31becd=a0_0xf3c5e9;return this[_0x31becd(0x105)]('broadcast',{'message':_0x415428,'filter_server':_0x320542?.[_0x31becd(0x117)],'filter_status':_0x320542?.['status']});}async[a0_0xf3c5e9(0x13d)](){const _0x54405c=a0_0xf3c5e9;let _0x1e8236=encodeURIComponent(this[_0x54405c(0x13e)]),_0x46ada4=this['url']+'/events/'+_0x1e8236,_0x55758a=this[_0x54405c(0x148)];while(this[_0x54405c(0x11b)]){try{this[_0x54405c(0x14f)]=new AbortController();let _0x230f6c={'Accept':_0x54405c(0x110)};if(this[_0x54405c(0x104)])_0x230f6c[_0x54405c(0x10d)]=_0x54405c(0x183)+this['token'];let _0x455c8a=await fetch(_0x46ada4,{'headers':_0x230f6c,'signal':this[_0x54405c(0x14f)][_0x54405c(0x108)]});if(!_0x455c8a['ok']||!_0x455c8a[_0x54405c(0x12f)]){this['log'](_0x54405c(0x16e)+_0x455c8a[_0x54405c(0x163)]),await this[_0x54405c(0x17b)](_0x55758a),_0x55758a=Math['min'](_0x55758a*1.5,0xea60);continue;}_0x55758a=this[_0x54405c(0x148)];let _0x34cb41=_0x455c8a[_0x54405c(0x12f)][_0x54405c(0x109)](),_0x4c3f47=new TextDecoder(),_0x198604='';while(this['running']){let {done:_0x387774,value:_0x3944a9}=await _0x34cb41[_0x54405c(0x154)]();if(_0x387774)break;_0x198604+=_0x4c3f47[_0x54405c(0x118)](_0x3944a9,{'stream':!0x0});let _0x334582=_0x198604[_0x54405c(0x11f)]('\x0a');_0x198604=_0x334582[_0x54405c(0x158)]()||'';for(let _0x5547b2 of _0x334582){if(!_0x5547b2[_0x54405c(0x164)]('data:\x20'))continue;try{let _0x46c508=JSON['parse'](_0x5547b2['slice'](0x6));if(_0x46c508[_0x54405c(0x12b)]===_0x54405c(0x14e)){this['log'](_0x54405c(0x15d)),this[_0x54405c(0x155)](_0x54405c(0x14e));continue;}if(_0x46c508['type']===_0x54405c(0x16b)||_0x46c508[_0x54405c(0x12b)]===_0x54405c(0x166)||_0x46c508[_0x54405c(0x12b)]===_0x54405c(0x167))await this[_0x54405c(0x156)]();}catch{}}}}catch(_0x37454f){if(_0x37454f[_0x54405c(0x171)]===_0x54405c(0x130))break;this['emit'](_0x54405c(0x123),_0x37454f),this['log'](_0x54405c(0x168)+_0x37454f[_0x54405c(0x15a)]);}if(this[_0x54405c(0x11b)])this[_0x54405c(0x155)](_0x54405c(0x115)),this[_0x54405c(0x165)](_0x54405c(0x124)+_0x55758a/0x3e8+'s...'),await this[_0x54405c(0x17b)](_0x55758a),_0x55758a=Math['min'](_0x55758a*1.5,0xea60);}}async[a0_0xf3c5e9(0x156)](){const _0x15013e=a0_0xf3c5e9;try{let _0x821095=(await this[_0x15013e(0x105)](_0x15013e(0x17a),{'alias':this[_0x15013e(0x13e)],'limit':0xa}))?.[_0x15013e(0x11e)]||[];for(let _0xc4983b of _0x821095)await this[_0x15013e(0x105)](_0x15013e(0x160),{'alias':this[_0x15013e(0x13e)],'message_id':_0xc4983b['id']}),this[_0x15013e(0x165)]('←\x20'+_0xc4983b['from_session']+':\x20'+_0xc4983b['content']['slice'](0x0,0x3c)),this[_0x15013e(0x155)](_0x15013e(0x145),_0xc4983b),this['emit'](_0x15013e(0x15a),_0xc4983b);}catch(_0x5d6d9d){this[_0x15013e(0x165)](_0x15013e(0x140)+_0x5d6d9d['message']);}}[a0_0xf3c5e9(0x17b)](_0x48c690){return new Promise(_0x20f938=>setTimeout(_0x20f938,_0x48c690));}}var F=$;export{F as default,$ as CommHub};
|
|
1
|
+
const a0_0x250709=a0_0x2e28;(function(_0x214ef6,_0x55066f){const _0x8d354a=a0_0x2e28,_0x5b9091=_0x214ef6();while(!![]){try{const _0x4a4d01=-parseInt(_0x8d354a(0xba))/0x1+-parseInt(_0x8d354a(0xa1))/0x2*(-parseInt(_0x8d354a(0xd2))/0x3)+-parseInt(_0x8d354a(0x8e))/0x4+parseInt(_0x8d354a(0xd9))/0x5+-parseInt(_0x8d354a(0xce))/0x6*(parseInt(_0x8d354a(0xe5))/0x7)+-parseInt(_0x8d354a(0xe1))/0x8*(parseInt(_0x8d354a(0x73))/0x9)+parseInt(_0x8d354a(0x9a))/0xa;if(_0x4a4d01===_0x55066f)break;else _0x5b9091['push'](_0x5b9091['shift']());}catch(_0xd9fe05){_0x5b9091['push'](_0x5b9091['shift']());}}}(a0_0x1b83,0x4c4a6));import{EventEmitter as a0_0x1d9de2}from'events';import{hostname as a0_0x25b044}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x1c19e1,_0x3daf75)=>(_0x1c19e1??_0x3daf75)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x250709(0x82)](0x0,0xf0);function N(_0x711857){const _0x988ab7=a0_0x250709;return(_0x711857 instanceof Error?_0x711857[_0x988ab7(0x6e)]:String(_0x711857??_0x988ab7(0x92)))[_0x988ab7(0xbf)](K,_0x988ab7(0xe8))[_0x988ab7(0xbf)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function a0_0x1b83(){const _0x30fd2d=['SSE\x20connected','name','reconnectDelay','token','SSE\x20reconnecting\x20in\x20','lifecycle_tracking','cwd','get_all_status','<missing>','tools/call','send_message','send_task','\x20parent_task_id=','51401TGbiBt','application/json','autoConnect','SSE\x20error:\x20','inbox\x20error:\x20','replace','processInbox','CommHub\x20rejected\x20task','type','new_message','error','Bearer\x20','networkId','connected','task','task.send.failed','/events/','SSE\x20failed:\x20','2.0','task_id','300SHaZCM','failed','task.started','emit','1354008iNkMPF','error_code','now','connect','log','idle','parse','2825535BclTgb','normal','application/json,\x20text/event-stream','task.replied','heartbeatInterval','AbortError','send_failed','\x20error=','1917560LtJLZc','text','delivered','toTimeString','371KwbhSy','Authorization','parent_task_id','[REDACTED]','message','\x20task_id=','CommHub\x20response\x20omitted\x20task_id','duration_ms','server','18VaFcGy','getAllStatus','task.send.delivered','\x20transport=','broadcast','read','<unknown>','result','fromAlias','call','task.send.start','\x20from=','sleep','mcp_http','report_status','slice','send_rejected','min','s...','not_tracked','match','send','sending','catch','body','url','resumeId','2430592ooYMCu',']\x20[commhub:','toString','running','unknown\x20error','get_inbox','sseAbort','status','task.expired','connectSSE','new_task','disconnect','4371320aFRIvt','to_alias','decode','/mcp','\x20lifecycle=','message_id','agent','2JlQyAZ','error_message','heartbeatTimer','transport','parentTaskId','network_id','content','offline','alias','getReader','disconnected','\x20duration_ms='];a0_0x1b83=function(){return _0x30fd2d;};return a0_0x1b83();}function O(_0x42ff55,_0x173015=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0xf85987=a0_0x250709;if(_0x173015)return JSON['stringify'](_0x42ff55);let _0x3de815=L(_0x42ff55[_0xf85987(0xe7)],_0xf85987(0xb5)),_0x599bb4=L(_0x42ff55[_0xf85987(0xcd)],'<pending>'),_0x273407=_0x42ff55[_0xf85987(0xd3)]?_0xf85987(0xe0)+_0x42ff55[_0xf85987(0xd3)]+':'+(_0x42ff55[_0xf85987(0xa2)]??''):'';return'[commhub:task]\x20'+_0x42ff55[_0xf85987(0x95)]+_0xf85987(0x7e)+L(_0x42ff55['from_alias'],_0xf85987(0x79))+'\x20to='+L(_0x42ff55[_0xf85987(0x9b)],_0xf85987(0x79))+_0xf85987(0x6f)+_0x599bb4+_0xf85987(0xb9)+_0x3de815+'\x20network_id='+L(_0x42ff55[_0xf85987(0xa6)],_0xf85987(0x79))+_0xf85987(0x76)+_0x42ff55['transport']+_0xf85987(0xac)+_0x42ff55[_0xf85987(0x71)]+_0xf85987(0x9e)+_0x42ff55[_0xf85987(0xb2)]+_0x273407;}function a0_0x2e28(_0x41d831,_0x43f250){_0x41d831=_0x41d831-0x6e;const _0x1b832d=a0_0x1b83();let _0x2e2837=_0x1b832d[_0x41d831];return _0x2e2837;}function U(_0x32ba6c){const _0x413c3a=a0_0x250709;return{'event':{'sending':_0x413c3a(0x7d),'delivered':_0x413c3a(0x75),'failed':_0x413c3a(0xc9),'acked':'task.ack','started':_0x413c3a(0xd0),'replied':_0x413c3a(0xdc),'expired':_0x413c3a(0x96)}[_0x32ba6c['status']],..._0x32ba6c};}function j(_0x49f308){const _0x2479e5=a0_0x250709;let _0x375f4f=_0x49f308?.[_0x2479e5(0xcd)]||_0x49f308?.[_0x2479e5(0x9f)]||_0x49f308?.['id'];if(_0x375f4f)return String(_0x375f4f);let _0x5ed2fd=_0x49f308?.[_0x2479e5(0xa7)]?.[0x0]?.[_0x2479e5(0xe2)];if(typeof _0x5ed2fd!=='string')return null;try{let _0x1445a3=JSON['parse'](_0x5ed2fd);return _0x1445a3?.[_0x2479e5(0xcd)]||_0x1445a3?.[_0x2479e5(0x9f)]||_0x1445a3?.['id']||null;}catch{return null;}}async function X(_0x4b58d1,_0x375ad9){const _0x785fed=a0_0x250709;let _0x53bdc0=_0x375ad9[_0x785fed(0xd4)]??Date[_0x785fed(0xd4)],_0x455be0=_0x53bdc0(),_0x5f5a47=(_0x4c0db1,_0x4b9daa,_0x2363a2,_0x1c2ca6)=>{const _0x480b35=_0x785fed;_0x375ad9[_0x480b35(0xd6)](O(U({'from_alias':_0x4b58d1[_0x480b35(0x7b)],'to_alias':_0x4b58d1['toAlias'],'task_id':_0x4b9daa,'parent_task_id':_0x4b58d1[_0x480b35(0xa5)],'network_id':_0x4b58d1[_0x480b35(0xc6)],'transport':_0x4b58d1[_0x480b35(0xa4)],'status':_0x4c0db1,'duration_ms':_0x53bdc0()-_0x455be0,'lifecycle_tracking':_0x4b58d1['lifecycleTracking'],..._0x2363a2!==void 0x0?{'error_code':_0x1c2ca6||_0x480b35(0xdf),'error_message':N(_0x2363a2)}:{}})));};_0x5f5a47(_0x785fed(0x89),null);try{let _0x31de65=await _0x375ad9[_0x785fed(0x88)](),_0x45365f=j(_0x31de65);if(_0x45365f)_0x5f5a47(_0x785fed(0xe3),_0x45365f);else{if(_0x31de65?.['ok']===!0x1||_0x31de65?.[_0x785fed(0xc4)])_0x5f5a47(_0x785fed(0xcf),_0x45365f,_0x31de65?.[_0x785fed(0xc4)]||_0x785fed(0xc1),_0x785fed(0x83));else _0x5f5a47(_0x785fed(0xcf),null,_0x785fed(0x70),'missing_task_id');}return _0x31de65;}catch(_0x572ffb){throw _0x5f5a47('failed',null,_0x572ffb,_0x785fed(0xdf)),_0x572ffb;}}async function Y(_0x454747,_0x2c22d6){const _0x3b5838=a0_0x250709;return X({'fromAlias':_0x454747[_0x3b5838(0x7b)],'toAlias':_0x454747[_0x3b5838(0xa9)],'parentTaskId':_0x454747[_0x3b5838(0xa5)]||null,'networkId':_0x454747[_0x3b5838(0xc6)]||null,'transport':_0x3b5838(0x80),'lifecycleTracking':_0x3b5838(0x86)},_0x2c22d6);}class $ extends a0_0x1d9de2{[a0_0x250709(0x8c)];[a0_0x250709(0xa9)];[a0_0x250709(0xb0)];[a0_0x250709(0xa0)];[a0_0x250709(0x8d)];[a0_0x250709(0xdd)];['reconnectDelay'];[a0_0x250709(0xa3)];[a0_0x250709(0x94)];[a0_0x250709(0x91)]=!0x1;constructor(_0x529b99){const _0x1fda21=a0_0x250709;super();if(this['url']=_0x529b99[_0x1fda21(0x8c)]['replace'](/\/$/,''),this['alias']=_0x529b99['alias'],this['token']=_0x529b99[_0x1fda21(0xb0)],this[_0x1fda21(0xa0)]=_0x529b99['agent']||'sdk',this[_0x1fda21(0x8d)]='sdk-'+_0x529b99[_0x1fda21(0xa9)]+'-'+Date[_0x1fda21(0xd4)]()[_0x1fda21(0x90)](0x24),this[_0x1fda21(0xdd)]=_0x529b99[_0x1fda21(0xdd)]??0x2bf20,this[_0x1fda21(0xaf)]=_0x529b99[_0x1fda21(0xaf)]??0xbb8,_0x529b99[_0x1fda21(0xbc)]!==!0x1)this[_0x1fda21(0xd5)]();}[a0_0x250709(0xd6)](_0x46807a){const _0x69dcaf=a0_0x250709;console[_0x69dcaf(0xd6)]('['+new Date()[_0x69dcaf(0xe4)]()[_0x69dcaf(0x82)](0x0,0x8)+_0x69dcaf(0x8f)+this[_0x69dcaf(0xa9)]+']\x20'+_0x46807a);}async['call'](_0x4c18ff,_0x5dd282){const _0x51d405=a0_0x250709;let _0x310452={'Content-Type':_0x51d405(0xbb),'Accept':_0x51d405(0xdb)};if(this[_0x51d405(0xb0)])_0x310452[_0x51d405(0xe6)]=_0x51d405(0xc5)+this[_0x51d405(0xb0)];let _0x5560b0=await(await fetch(this[_0x51d405(0x8c)]+_0x51d405(0x9d),{'method':'POST','headers':_0x310452,'body':JSON['stringify']({'jsonrpc':_0x51d405(0xcc),'id':Date[_0x51d405(0xd4)](),'method':_0x51d405(0xb6),'params':{'name':_0x4c18ff,'arguments':_0x5dd282}})}))[_0x51d405(0xe2)](),_0xc78e11=_0x5560b0[_0x51d405(0x87)](/data: (.+)/),_0x2fdfb1=_0xc78e11?JSON[_0x51d405(0xd8)](_0xc78e11[0x1]):JSON['parse'](_0x5560b0),_0x1fb409=_0x2fdfb1?.[_0x51d405(0x7a)]?.[_0x51d405(0xa7)]?.[0x0]?.[_0x51d405(0xe2)];return _0x1fb409?JSON[_0x51d405(0xd8)](_0x1fb409):_0x2fdfb1;}async[a0_0x250709(0xd5)](){const _0x136d86=a0_0x250709;if(this[_0x136d86(0x91)])return;this['running']=!0x0,await this[_0x136d86(0x95)](_0x136d86(0xd7)),this[_0x136d86(0xd6)]('registered'),this[_0x136d86(0xa3)]=setInterval(()=>{const _0xab4749=_0x136d86;this['status'](_0xab4749(0xd7))[_0xab4749(0x8a)](_0x108c0d=>this['log']('heartbeat\x20failed:\x20'+_0x108c0d[_0xab4749(0x6e)]));},this[_0x136d86(0xdd)]),this[_0x136d86(0x97)]();}async[a0_0x250709(0x99)](){const _0x13033e=a0_0x250709;if(this[_0x13033e(0x91)]=!0x1,this[_0x13033e(0x94)]?.['abort'](),this[_0x13033e(0xa3)])clearInterval(this[_0x13033e(0xa3)]);await this['status'](_0x13033e(0xa8))['catch'](()=>{}),this[_0x13033e(0xd6)](_0x13033e(0xab));}async['send'](_0x55c386,_0x491d31,_0x52e316=a0_0x250709(0xda)){const _0x12fd47=a0_0x250709;return Y({'alias':_0x55c386,'fromAlias':this[_0x12fd47(0xa9)]},{'log':_0x210c62=>console[_0x12fd47(0xd6)](_0x210c62),'send':()=>this['call'](_0x12fd47(0xb8),{'alias':_0x55c386,'task':_0x491d31,'priority':_0x52e316,'from_session':this[_0x12fd47(0xa9)]})});}async[a0_0x250709(0x6e)](_0x2a1536,_0x449280){const _0x5df2a4=a0_0x250709;return this[_0x5df2a4(0x7c)](_0x5df2a4(0xb7),{'alias':_0x2a1536,'message':_0x449280,'from_session':this[_0x5df2a4(0xa9)]});}async['reply'](_0x44b7ca,_0x4eccda,_0xc05fc5='completed'){const _0x52e49b=a0_0x250709;return this[_0x52e49b(0x7c)]('send_reply',{'in_reply_to':_0x44b7ca,'text':_0x4eccda,'status':_0xc05fc5});}async[a0_0x250709(0x95)](_0x4d81a9,_0x50b1d3){const _0x1c1db1=a0_0x250709;return this[_0x1c1db1(0x7c)](_0x1c1db1(0x81),{'resume_id':this[_0x1c1db1(0x8d)],'alias':this['alias'],'status':_0x4d81a9,'server':a0_0x25b044(),'hostname':a0_0x25b044(),'agent':this['agent'],'project_dir':process[_0x1c1db1(0xb3)](),..._0x50b1d3});}async[a0_0x250709(0x74)](){const _0x5aa99=a0_0x250709;return this[_0x5aa99(0x7c)](_0x5aa99(0xb4),{});}async[a0_0x250709(0x77)](_0x493e6e,_0x2819c2){const _0x5ba341=a0_0x250709;return this['call'](_0x5ba341(0x77),{'message':_0x493e6e,'filter_server':_0x2819c2?.[_0x5ba341(0x72)],'filter_status':_0x2819c2?.[_0x5ba341(0x95)]});}async[a0_0x250709(0x97)](){const _0x5f3625=a0_0x250709;let _0x433c0c=encodeURIComponent(this[_0x5f3625(0xa9)]),_0xe057a3=this[_0x5f3625(0x8c)]+_0x5f3625(0xca)+_0x433c0c,_0x39966e=this['reconnectDelay'];while(this[_0x5f3625(0x91)]){try{this[_0x5f3625(0x94)]=new AbortController();let _0x244c7d={'Accept':'text/event-stream'};if(this[_0x5f3625(0xb0)])_0x244c7d[_0x5f3625(0xe6)]=_0x5f3625(0xc5)+this['token'];let _0xaf42c0=await fetch(_0xe057a3,{'headers':_0x244c7d,'signal':this[_0x5f3625(0x94)]['signal']});if(!_0xaf42c0['ok']||!_0xaf42c0[_0x5f3625(0x8b)]){this[_0x5f3625(0xd6)](_0x5f3625(0xcb)+_0xaf42c0[_0x5f3625(0x95)]),await this[_0x5f3625(0x7f)](_0x39966e),_0x39966e=Math[_0x5f3625(0x84)](_0x39966e*1.5,0xea60);continue;}_0x39966e=this[_0x5f3625(0xaf)];let _0x2406f6=_0xaf42c0[_0x5f3625(0x8b)][_0x5f3625(0xaa)](),_0x3eaf95=new TextDecoder(),_0x582b08='';while(this['running']){let {done:_0x45b12f,value:_0x146b67}=await _0x2406f6[_0x5f3625(0x78)]();if(_0x45b12f)break;_0x582b08+=_0x3eaf95[_0x5f3625(0x9c)](_0x146b67,{'stream':!0x0});let _0x49541d=_0x582b08['split']('\x0a');_0x582b08=_0x49541d['pop']()||'';for(let _0x2283d2 of _0x49541d){if(!_0x2283d2['startsWith']('data:\x20'))continue;try{let _0x40802f=JSON['parse'](_0x2283d2['slice'](0x6));if(_0x40802f[_0x5f3625(0xc2)]===_0x5f3625(0xc7)){this['log'](_0x5f3625(0xad)),this[_0x5f3625(0xd1)](_0x5f3625(0xc7));continue;}if(_0x40802f[_0x5f3625(0xc2)]===_0x5f3625(0x98)||_0x40802f[_0x5f3625(0xc2)]===_0x5f3625(0xc3)||_0x40802f[_0x5f3625(0xc2)]===_0x5f3625(0x77))await this['processInbox']();}catch{}}}}catch(_0x5175e4){if(_0x5175e4[_0x5f3625(0xae)]===_0x5f3625(0xde))break;this[_0x5f3625(0xd1)](_0x5f3625(0xc4),_0x5175e4),this['log'](_0x5f3625(0xbd)+_0x5175e4[_0x5f3625(0x6e)]);}if(this[_0x5f3625(0x91)])this[_0x5f3625(0xd1)](_0x5f3625(0xab)),this[_0x5f3625(0xd6)](_0x5f3625(0xb1)+_0x39966e/0x3e8+_0x5f3625(0x85)),await this[_0x5f3625(0x7f)](_0x39966e),_0x39966e=Math[_0x5f3625(0x84)](_0x39966e*1.5,0xea60);}}async[a0_0x250709(0xc0)](){const _0x218a71=a0_0x250709;try{let _0x237664=(await this[_0x218a71(0x7c)](_0x218a71(0x93),{'alias':this[_0x218a71(0xa9)],'limit':0xa}))?.['messages']||[];for(let _0x4ff0f3 of _0x237664)await this[_0x218a71(0x7c)]('ack_inbox',{'alias':this['alias'],'message_id':_0x4ff0f3['id']}),this['log']('←\x20'+_0x4ff0f3['from_session']+':\x20'+_0x4ff0f3['content'][_0x218a71(0x82)](0x0,0x3c)),this[_0x218a71(0xd1)](_0x218a71(0xc8),_0x4ff0f3),this[_0x218a71(0xd1)]('message',_0x4ff0f3);}catch(_0x406e04){this[_0x218a71(0xd6)](_0x218a71(0xbe)+_0x406e04['message']);}}[a0_0x250709(0x7f)](_0x407f4b){return new Promise(_0x23add1=>setTimeout(_0x23add1,_0x407f4b));}}var F=$;export{F as default,$ as CommHub};
|