@sleep2agi/agent-network 2.3.0-preview.190 → 2.3.0-preview.192
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_0x3415c1=a0_0xad81;(function(_0x28102c,_0xdff2ad){const _0x4533ce=a0_0xad81,_0x3c341=_0x28102c();while(!![]){try{const _0x3daa65=parseInt(_0x4533ce(0x12b))/0x1*(parseInt(_0x4533ce(0x13d))/0x2)+parseInt(_0x4533ce(0x14e))/0x3*(parseInt(_0x4533ce(0x124))/0x4)+-parseInt(_0x4533ce(0x125))/0x5*(parseInt(_0x4533ce(0x170))/0x6)+-parseInt(_0x4533ce(0x126))/0x7+parseInt(_0x4533ce(0x113))/0x8*(parseInt(_0x4533ce(0x16e))/0x9)+-parseInt(_0x4533ce(0x14a))/0xa+parseInt(_0x4533ce(0x128))/0xb;if(_0x3daa65===_0xdff2ad)break;else _0x3c341['push'](_0x3c341['shift']());}catch(_0x587937){_0x3c341['push'](_0x3c341['shift']());}}}(a0_0x1625,0xad788));import{EventEmitter as a0_0x15c96e}from'events';import{hostname as a0_0x596ed3}from'os';function a0_0xad81(_0x475488,_0x2cf2ae){_0x475488=_0x475488-0x106;const _0x162543=a0_0x1625();let _0xad818e=_0x162543[_0x475488];return _0xad818e;}var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x22bd9f,_0x58c185)=>(_0x22bd9f??_0x58c185)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x3415c1(0x16a)](0x0,0xf0);function a0_0x1625(){const _0x7f1db5=['normal','string','pop','toString','Bearer\x20','network_id','\x20transport=','idle','SSE\x20reconnecting\x20in\x20','parse','alias','<pending>','name','duration_ms','send','14YTWwEI','error','s...','heartbeat\x20failed:\x20','parent_task_id','call','url','sending','\x20parent_task_id=','offline','failed','<missing>','startsWith','12779160SIVrmi','new_message','POST','[REDACTED]','1869543OGOhTH','text/event-stream','Authorization','send_message','2.0','content','connected','send_task','SSE\x20error:\x20','body','message','<unknown>','\x20to=','text','[commhub:task]\x20','token','task.send.failed','sleep','abort','task.started','task.replied','result','lifecycleTracking','sseAbort','signal','transport','from_session','min','slice','sdk-','fromAlias','data:\x20','8073RXsDKm','/mcp','114XPlDyt','AbortError','disconnect','/events/','cwd','SSE\x20connected','json','reconnectDelay','error_code','get_all_status','type','get_inbox','stringify','send_rejected','\x20network_id=','missing_task_id','not_tracked','task','\x20task_id=','\x20duration_ms=','emit','broadcast','status','autoConnect','heartbeatTimer','reply','getReader','running','send_failed','CommHub\x20rejected\x20task','task.send.delivered','networkId','task_id','mcp_http','heartbeatInterval','4568qtNjAb','tools/call',']\x20[commhub:','log','replace','now','disconnected','SSE\x20failed:\x20','catch','agent','error_message','resumeId','send_reply','CommHub\x20response\x20omitted\x20task_id','completed','connect','new_task','8ORRAxY','50625hRoRpP','5733980BfCneb','connectSSE','6068557NmDxko','split','ack_inbox','98533xdGkCk','sdk','parentTaskId'];a0_0x1625=function(){return _0x7f1db5;};return a0_0x1625();}function N(_0x4ed6c4){const _0x314b8f=a0_0x3415c1;return(_0x4ed6c4 instanceof Error?_0x4ed6c4[_0x314b8f(0x158)]:String(_0x4ed6c4??'unknown\x20error'))[_0x314b8f(0x117)](K,_0x314b8f(0x14d))[_0x314b8f(0x117)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x314b8f(0x16a)](0x0,0xf0);}function O(_0x548816,_0x4b7dff=process.env.ANET_TASK_TRACE_FORMAT===a0_0x3415c1(0x176)){const _0x1f43d1=a0_0x3415c1;if(_0x4b7dff)return JSON[_0x1f43d1(0x17c)](_0x548816);let _0x2f0494=L(_0x548816[_0x1f43d1(0x141)],_0x1f43d1(0x148)),_0x595190=L(_0x548816[_0x1f43d1(0x110)],_0x1f43d1(0x139)),_0xbe17b2=_0x548816[_0x1f43d1(0x178)]?'\x20error='+_0x548816['error_code']+':'+(_0x548816[_0x1f43d1(0x11d)]??''):'';return _0x1f43d1(0x15c)+_0x548816['status']+'\x20from='+L(_0x548816['from_alias'],_0x1f43d1(0x159))+_0x1f43d1(0x15a)+L(_0x548816['to_alias'],_0x1f43d1(0x159))+_0x1f43d1(0x182)+_0x595190+_0x1f43d1(0x145)+_0x2f0494+_0x1f43d1(0x17e)+L(_0x548816[_0x1f43d1(0x133)],_0x1f43d1(0x159))+_0x1f43d1(0x134)+_0x548816['transport']+_0x1f43d1(0x183)+_0x548816[_0x1f43d1(0x13b)]+'\x20lifecycle='+_0x548816['lifecycle_tracking']+_0xbe17b2;}function U(_0x134b19){const _0x47ac21=a0_0x3415c1;return{'event':{'sending':'task.send.start','delivered':_0x47ac21(0x10e),'failed':_0x47ac21(0x15e),'acked':'task.ack','started':_0x47ac21(0x161),'replied':_0x47ac21(0x162),'expired':'task.expired'}[_0x134b19[_0x47ac21(0x106)]],..._0x134b19};}function j(_0x257de2){const _0x1549ee=a0_0x3415c1;let _0x588cc1=_0x257de2?.[_0x1549ee(0x110)]||_0x257de2?.['message_id']||_0x257de2?.['id'];if(_0x588cc1)return String(_0x588cc1);let _0x5080ec=_0x257de2?.[_0x1549ee(0x153)]?.[0x0]?.[_0x1549ee(0x15b)];if(typeof _0x5080ec!==_0x1549ee(0x12f))return null;try{let _0x3c389a=JSON['parse'](_0x5080ec);return _0x3c389a?.['task_id']||_0x3c389a?.['message_id']||_0x3c389a?.['id']||null;}catch{return null;}}async function X(_0x2b91c7,_0xac330a){const _0x41bb56=a0_0x3415c1;let _0x5bac87=_0xac330a[_0x41bb56(0x118)]??Date[_0x41bb56(0x118)],_0x2583ee=_0x5bac87(),_0xeb2e13=(_0x43675e,_0x5405df,_0xed17a7,_0x4b0dc1)=>{const _0x4138dc=_0x41bb56;_0xac330a['log'](O(U({'from_alias':_0x2b91c7[_0x4138dc(0x16c)],'to_alias':_0x2b91c7['toAlias'],'task_id':_0x5405df,'parent_task_id':_0x2b91c7[_0x4138dc(0x12d)],'network_id':_0x2b91c7[_0x4138dc(0x10f)],'transport':_0x2b91c7[_0x4138dc(0x167)],'status':_0x43675e,'duration_ms':_0x5bac87()-_0x2583ee,'lifecycle_tracking':_0x2b91c7[_0x4138dc(0x164)],..._0xed17a7!==void 0x0?{'error_code':_0x4b0dc1||_0x4138dc(0x10c),'error_message':N(_0xed17a7)}:{}})));};_0xeb2e13(_0x41bb56(0x144),null);try{let _0x279433=await _0xac330a['send'](),_0x10b4aa=j(_0x279433);if(_0x10b4aa)_0xeb2e13('delivered',_0x10b4aa);else{if(_0x279433?.['ok']===!0x1||_0x279433?.[_0x41bb56(0x13e)])_0xeb2e13(_0x41bb56(0x147),_0x10b4aa,_0x279433?.[_0x41bb56(0x13e)]||_0x41bb56(0x10d),_0x41bb56(0x17d));else _0xeb2e13(_0x41bb56(0x147),null,_0x41bb56(0x120),_0x41bb56(0x17f));}return _0x279433;}catch(_0x11f909){throw _0xeb2e13(_0x41bb56(0x147),null,_0x11f909,_0x41bb56(0x10c)),_0x11f909;}}async function Y(_0x592474,_0x2b1d34){const _0x5e7141=a0_0x3415c1;return X({'fromAlias':_0x592474[_0x5e7141(0x16c)],'toAlias':_0x592474[_0x5e7141(0x138)],'parentTaskId':_0x592474[_0x5e7141(0x12d)]||null,'networkId':_0x592474[_0x5e7141(0x10f)]||null,'transport':_0x5e7141(0x111),'lifecycleTracking':_0x5e7141(0x180)},_0x2b1d34);}class $ extends a0_0x15c96e{[a0_0x3415c1(0x143)];[a0_0x3415c1(0x138)];[a0_0x3415c1(0x15d)];[a0_0x3415c1(0x11c)];['resumeId'];[a0_0x3415c1(0x112)];[a0_0x3415c1(0x177)];[a0_0x3415c1(0x108)];[a0_0x3415c1(0x165)];[a0_0x3415c1(0x10b)]=!0x1;constructor(_0x2e32d){const _0x287463=a0_0x3415c1;super();if(this['url']=_0x2e32d[_0x287463(0x143)]['replace'](/\/$/,''),this[_0x287463(0x138)]=_0x2e32d[_0x287463(0x138)],this['token']=_0x2e32d[_0x287463(0x15d)],this['agent']=_0x2e32d[_0x287463(0x11c)]||_0x287463(0x12c),this[_0x287463(0x11e)]=_0x287463(0x16b)+_0x2e32d[_0x287463(0x138)]+'-'+Date[_0x287463(0x118)]()[_0x287463(0x131)](0x24),this[_0x287463(0x112)]=_0x2e32d['heartbeatInterval']??0x2bf20,this[_0x287463(0x177)]=_0x2e32d[_0x287463(0x177)]??0xbb8,_0x2e32d[_0x287463(0x107)]!==!0x1)this[_0x287463(0x122)]();}['log'](_0x4d1faf){const _0x40e791=a0_0x3415c1;console[_0x40e791(0x116)]('['+new Date()['toTimeString']()[_0x40e791(0x16a)](0x0,0x8)+_0x40e791(0x115)+this[_0x40e791(0x138)]+']\x20'+_0x4d1faf);}async[a0_0x3415c1(0x142)](_0x17d49e,_0x552ee4){const _0x4284b9=a0_0x3415c1;let _0x3e387f={'Content-Type':'application/json','Accept':'application/json,\x20text/event-stream'};if(this[_0x4284b9(0x15d)])_0x3e387f[_0x4284b9(0x150)]=_0x4284b9(0x132)+this[_0x4284b9(0x15d)];let _0x552d20=await(await fetch(this['url']+_0x4284b9(0x16f),{'method':_0x4284b9(0x14c),'headers':_0x3e387f,'body':JSON[_0x4284b9(0x17c)]({'jsonrpc':_0x4284b9(0x152),'id':Date[_0x4284b9(0x118)](),'method':_0x4284b9(0x114),'params':{'name':_0x17d49e,'arguments':_0x552ee4}})}))[_0x4284b9(0x15b)](),_0x4ee426=_0x552d20['match'](/data: (.+)/),_0x5303e9=_0x4ee426?JSON[_0x4284b9(0x137)](_0x4ee426[0x1]):JSON['parse'](_0x552d20),_0x32028c=_0x5303e9?.[_0x4284b9(0x163)]?.['content']?.[0x0]?.[_0x4284b9(0x15b)];return _0x32028c?JSON['parse'](_0x32028c):_0x5303e9;}async[a0_0x3415c1(0x122)](){const _0x2f7895=a0_0x3415c1;if(this[_0x2f7895(0x10b)])return;this[_0x2f7895(0x10b)]=!0x0,await this['status']('idle'),this[_0x2f7895(0x116)]('registered'),this[_0x2f7895(0x108)]=setInterval(()=>{const _0x982e1f=_0x2f7895;this[_0x982e1f(0x106)](_0x982e1f(0x135))[_0x982e1f(0x11b)](_0x355297=>this[_0x982e1f(0x116)](_0x982e1f(0x140)+_0x355297[_0x982e1f(0x158)]));},this[_0x2f7895(0x112)]),this[_0x2f7895(0x127)]();}async[a0_0x3415c1(0x172)](){const _0x365146=a0_0x3415c1;if(this[_0x365146(0x10b)]=!0x1,this[_0x365146(0x165)]?.[_0x365146(0x160)](),this[_0x365146(0x108)])clearInterval(this[_0x365146(0x108)]);await this[_0x365146(0x106)](_0x365146(0x146))[_0x365146(0x11b)](()=>{}),this[_0x365146(0x116)](_0x365146(0x119));}async[a0_0x3415c1(0x13c)](_0x4e6cc9,_0x18e675,_0x312b67=a0_0x3415c1(0x12e)){const _0x363385=a0_0x3415c1;return Y({'alias':_0x4e6cc9,'fromAlias':this[_0x363385(0x138)]},{'log':_0x27688d=>console[_0x363385(0x116)](_0x27688d),'send':()=>this[_0x363385(0x142)](_0x363385(0x155),{'alias':_0x4e6cc9,'task':_0x18e675,'priority':_0x312b67,'from_session':this[_0x363385(0x138)]})});}async[a0_0x3415c1(0x158)](_0x18472b,_0x152927){const _0x449931=a0_0x3415c1;return this[_0x449931(0x142)](_0x449931(0x151),{'alias':_0x18472b,'message':_0x152927,'from_session':this[_0x449931(0x138)]});}async[a0_0x3415c1(0x109)](_0x5edfb6,_0x3232bc,_0x126880=a0_0x3415c1(0x121)){const _0x5171ac=a0_0x3415c1;return this[_0x5171ac(0x142)](_0x5171ac(0x11f),{'in_reply_to':_0x5edfb6,'text':_0x3232bc,'status':_0x126880});}async['status'](_0x543443,_0x350243){const _0x5d3b2e=a0_0x3415c1;return this[_0x5d3b2e(0x142)]('report_status',{'resume_id':this[_0x5d3b2e(0x11e)],'alias':this[_0x5d3b2e(0x138)],'status':_0x543443,'server':a0_0x596ed3(),'hostname':a0_0x596ed3(),'agent':this[_0x5d3b2e(0x11c)],'project_dir':process[_0x5d3b2e(0x174)](),..._0x350243});}async['getAllStatus'](){const _0x2dce98=a0_0x3415c1;return this[_0x2dce98(0x142)](_0x2dce98(0x179),{});}async[a0_0x3415c1(0x185)](_0x5d2e25,_0x4c3d48){const _0x24e23d=a0_0x3415c1;return this['call']('broadcast',{'message':_0x5d2e25,'filter_server':_0x4c3d48?.['server'],'filter_status':_0x4c3d48?.[_0x24e23d(0x106)]});}async['connectSSE'](){const _0x231027=a0_0x3415c1;let _0x549ca1=encodeURIComponent(this[_0x231027(0x138)]),_0x3d9331=this[_0x231027(0x143)]+_0x231027(0x173)+_0x549ca1,_0x2ea151=this[_0x231027(0x177)];while(this['running']){try{this['sseAbort']=new AbortController();let _0xd5e2bb={'Accept':_0x231027(0x14f)};if(this[_0x231027(0x15d)])_0xd5e2bb[_0x231027(0x150)]='Bearer\x20'+this['token'];let _0x5431e2=await fetch(_0x3d9331,{'headers':_0xd5e2bb,'signal':this[_0x231027(0x165)][_0x231027(0x166)]});if(!_0x5431e2['ok']||!_0x5431e2['body']){this[_0x231027(0x116)](_0x231027(0x11a)+_0x5431e2['status']),await this[_0x231027(0x15f)](_0x2ea151),_0x2ea151=Math[_0x231027(0x169)](_0x2ea151*1.5,0xea60);continue;}_0x2ea151=this[_0x231027(0x177)];let _0x5d2bf4=_0x5431e2[_0x231027(0x157)][_0x231027(0x10a)](),_0x392cd2=new TextDecoder(),_0x2bc049='';while(this[_0x231027(0x10b)]){let {done:_0x590d34,value:_0x2bffd6}=await _0x5d2bf4['read']();if(_0x590d34)break;_0x2bc049+=_0x392cd2['decode'](_0x2bffd6,{'stream':!0x0});let _0x9b6e0a=_0x2bc049[_0x231027(0x129)]('\x0a');_0x2bc049=_0x9b6e0a[_0x231027(0x130)]()||'';for(let _0x300520 of _0x9b6e0a){if(!_0x300520[_0x231027(0x149)](_0x231027(0x16d)))continue;try{let _0x2c5a98=JSON['parse'](_0x300520[_0x231027(0x16a)](0x6));if(_0x2c5a98[_0x231027(0x17a)]===_0x231027(0x154)){this[_0x231027(0x116)](_0x231027(0x175)),this[_0x231027(0x184)](_0x231027(0x154));continue;}if(_0x2c5a98[_0x231027(0x17a)]===_0x231027(0x123)||_0x2c5a98[_0x231027(0x17a)]===_0x231027(0x14b)||_0x2c5a98[_0x231027(0x17a)]==='broadcast')await this['processInbox']();}catch{}}}}catch(_0x43dd0a){if(_0x43dd0a[_0x231027(0x13a)]===_0x231027(0x171))break;this['emit']('error',_0x43dd0a),this[_0x231027(0x116)](_0x231027(0x156)+_0x43dd0a[_0x231027(0x158)]);}if(this[_0x231027(0x10b)])this[_0x231027(0x184)]('disconnected'),this[_0x231027(0x116)](_0x231027(0x136)+_0x2ea151/0x3e8+_0x231027(0x13f)),await this[_0x231027(0x15f)](_0x2ea151),_0x2ea151=Math[_0x231027(0x169)](_0x2ea151*1.5,0xea60);}}async['processInbox'](){const _0x1fb5d6=a0_0x3415c1;try{let _0x5be081=(await this['call'](_0x1fb5d6(0x17b),{'alias':this[_0x1fb5d6(0x138)],'limit':0xa}))?.['messages']||[];for(let _0x13dcdf of _0x5be081)await this['call'](_0x1fb5d6(0x12a),{'alias':this[_0x1fb5d6(0x138)],'message_id':_0x13dcdf['id']}),this[_0x1fb5d6(0x116)]('←\x20'+_0x13dcdf[_0x1fb5d6(0x168)]+':\x20'+_0x13dcdf[_0x1fb5d6(0x153)]['slice'](0x0,0x3c)),this[_0x1fb5d6(0x184)](_0x1fb5d6(0x181),_0x13dcdf),this[_0x1fb5d6(0x184)]('message',_0x13dcdf);}catch(_0x5da321){this[_0x1fb5d6(0x116)]('inbox\x20error:\x20'+_0x5da321['message']);}}['sleep'](_0x374048){return new Promise(_0x260d7a=>setTimeout(_0x260d7a,_0x374048));}}var F=$;export{F as default,$ as CommHub};
|
|
1
|
+
const a0_0x58d40f=a0_0x13e3;function a0_0x469b(){const _0x636664=['idle','message','send','emit','text','tools/call','network_id','token','210RSFYig','delivered','abort','url','disconnected','ack_inbox','networkId','task.send.start','resumeId','parentTaskId','completed','missing_task_id','\x20lifecycle=','send_reply','lifecycle_tracking','Bearer\x20','failed','inbox\x20error:\x20','sseAbort','cwd','task.replied','send_rejected','connect','startsWith','/events/','alias','running','error_message','1783784NNNWfi','send_task','send_failed','agent','now','normal','result','SSE\x20failed:\x20','error','getAllStatus','processInbox','task.expired','task_id','string','394974TFaqcR','application/json','get_inbox','slice','data:\x20','log','messages','connected','\x20transport=','replace','task','mcp_http','task.ack','sdk-','autoConnect','Authorization','decode',']\x20[commhub:','\x20parent_task_id=','type','unknown\x20error','\x20network_id=','match','SSE\x20connected','error_code','POST','<missing>','parent_task_id','duration_ms','sending','21uEvAZi','transport','\x20to=','pop','min','2cudiIf','connectSSE','not_tracked','from_session','task.started','\x20from=','187032MRtzoB','<unknown>','heartbeatInterval','fromAlias','heartbeatTimer','broadcast','to_alias','parse','\x20error=','new_message','lifecycleTracking','catch','1123936gooaDp','status','call','content','text/event-stream','<pending>','1901520zzkpsN','[commhub:task]\x20','offline','reconnectDelay','message_id','CommHub\x20rejected\x20task','registered','3159295vPMghA','\x20task_id=','416828cZpOgW','name','CommHub\x20response\x20omitted\x20task_id','getReader','report_status','split'];a0_0x469b=function(){return _0x636664;};return a0_0x469b();}(function(_0x37a6c3,_0x27e9df){const _0x1055c1=a0_0x13e3,_0x53cda5=_0x37a6c3();while(!![]){try{const _0x5dd0bf=-parseInt(_0x1055c1(0x203))/0x1*(-parseInt(_0x1055c1(0x1e2))/0x2)+parseInt(_0x1055c1(0x1fa))/0x3+-parseInt(_0x1055c1(0x1b1))/0x4+-parseInt(_0x1055c1(0x201))/0x5+parseInt(_0x1055c1(0x1e8))/0x6+parseInt(_0x1055c1(0x1dd))/0x7*(-parseInt(_0x1055c1(0x1f4))/0x8)+parseInt(_0x1055c1(0x1bf))/0x9*(parseInt(_0x1055c1(0x195))/0xa);if(_0x5dd0bf===_0x27e9df)break;else _0x53cda5['push'](_0x53cda5['shift']());}catch(_0x1dbe5a){_0x53cda5['push'](_0x53cda5['shift']());}}}(a0_0x469b,0x7b165));import{EventEmitter as a0_0x2bae8d}from'events';import{hostname as a0_0x25084e}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x33f97b,_0x2f32e0)=>(_0x33f97b??_0x2f32e0)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x1725fd){const _0x21a0bd=a0_0x13e3;return(_0x1725fd instanceof Error?_0x1725fd[_0x21a0bd(0x18e)]:String(_0x1725fd??_0x21a0bd(0x1d3)))[_0x21a0bd(0x1c8)](K,'[REDACTED]')[_0x21a0bd(0x1c8)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x379929,_0x697e0a=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0xb5a59e=a0_0x13e3;if(_0x697e0a)return JSON['stringify'](_0x379929);let _0x1ab59e=L(_0x379929[_0xb5a59e(0x1da)],_0xb5a59e(0x1d9)),_0x5d9e9e=L(_0x379929[_0xb5a59e(0x1bd)],_0xb5a59e(0x1f9)),_0x1af058=_0x379929[_0xb5a59e(0x1d7)]?_0xb5a59e(0x1f0)+_0x379929['error_code']+':'+(_0x379929[_0xb5a59e(0x1b0)]??''):'';return _0xb5a59e(0x1fb)+_0x379929[_0xb5a59e(0x1f5)]+_0xb5a59e(0x1e7)+L(_0x379929['from_alias'],_0xb5a59e(0x1e9))+_0xb5a59e(0x1df)+L(_0x379929[_0xb5a59e(0x1ee)],_0xb5a59e(0x1e9))+_0xb5a59e(0x202)+_0x5d9e9e+_0xb5a59e(0x1d1)+_0x1ab59e+_0xb5a59e(0x1d4)+L(_0x379929[_0xb5a59e(0x193)],_0xb5a59e(0x1e9))+_0xb5a59e(0x1c7)+_0x379929[_0xb5a59e(0x1de)]+'\x20duration_ms='+_0x379929[_0xb5a59e(0x1db)]+_0xb5a59e(0x1a1)+_0x379929[_0xb5a59e(0x1a3)]+_0x1af058;}function U(_0x4dd518){const _0x158244=a0_0x13e3;return{'event':{'sending':_0x158244(0x19c),'delivered':'task.send.delivered','failed':'task.send.failed','acked':_0x158244(0x1cb),'started':_0x158244(0x1e6),'replied':_0x158244(0x1a9),'expired':_0x158244(0x1bc)}[_0x4dd518[_0x158244(0x1f5)]],..._0x4dd518};}function j(_0x4f2217){const _0x5a04b9=a0_0x13e3;let _0x194e14=_0x4f2217?.['task_id']||_0x4f2217?.[_0x5a04b9(0x1fe)]||_0x4f2217?.['id'];if(_0x194e14)return String(_0x194e14);let _0x257e90=_0x4f2217?.['content']?.[0x0]?.[_0x5a04b9(0x191)];if(typeof _0x257e90!==_0x5a04b9(0x1be))return null;try{let _0x5e14d4=JSON['parse'](_0x257e90);return _0x5e14d4?.[_0x5a04b9(0x1bd)]||_0x5e14d4?.[_0x5a04b9(0x1fe)]||_0x5e14d4?.['id']||null;}catch{return null;}}async function X(_0x3bab27,_0x47cb84){const _0x20b2a1=a0_0x13e3;let _0x217e40=_0x47cb84[_0x20b2a1(0x1b5)]??Date[_0x20b2a1(0x1b5)],_0x5bfed2=_0x217e40(),_0x2c8099=(_0x2c2410,_0x45a8bf,_0x3f6a57,_0x257051)=>{const _0x2601dd=_0x20b2a1;_0x47cb84[_0x2601dd(0x1c4)](O(U({'from_alias':_0x3bab27[_0x2601dd(0x1eb)],'to_alias':_0x3bab27['toAlias'],'task_id':_0x45a8bf,'parent_task_id':_0x3bab27['parentTaskId'],'network_id':_0x3bab27['networkId'],'transport':_0x3bab27[_0x2601dd(0x1de)],'status':_0x2c2410,'duration_ms':_0x217e40()-_0x5bfed2,'lifecycle_tracking':_0x3bab27[_0x2601dd(0x1f2)],..._0x3f6a57!==void 0x0?{'error_code':_0x257051||_0x2601dd(0x1b3),'error_message':N(_0x3f6a57)}:{}})));};_0x2c8099(_0x20b2a1(0x1dc),null);try{let _0x340574=await _0x47cb84[_0x20b2a1(0x18f)](),_0x52079e=j(_0x340574);if(_0x52079e)_0x2c8099(_0x20b2a1(0x196),_0x52079e);else{if(_0x340574?.['ok']===!0x1||_0x340574?.[_0x20b2a1(0x1b9)])_0x2c8099(_0x20b2a1(0x1a5),_0x52079e,_0x340574?.['error']||_0x20b2a1(0x1ff),_0x20b2a1(0x1aa));else _0x2c8099(_0x20b2a1(0x1a5),null,_0x20b2a1(0x189),_0x20b2a1(0x1a0));}return _0x340574;}catch(_0x13490a){throw _0x2c8099(_0x20b2a1(0x1a5),null,_0x13490a,_0x20b2a1(0x1b3)),_0x13490a;}}async function Y(_0x2cf2d8,_0x6b941e){const _0x254719=a0_0x13e3;return X({'fromAlias':_0x2cf2d8[_0x254719(0x1eb)],'toAlias':_0x2cf2d8[_0x254719(0x1ae)],'parentTaskId':_0x2cf2d8[_0x254719(0x19e)]||null,'networkId':_0x2cf2d8[_0x254719(0x19b)]||null,'transport':_0x254719(0x1ca),'lifecycleTracking':_0x254719(0x1e4)},_0x6b941e);}class $ extends a0_0x2bae8d{[a0_0x58d40f(0x198)];[a0_0x58d40f(0x1ae)];[a0_0x58d40f(0x194)];[a0_0x58d40f(0x1b4)];['resumeId'];[a0_0x58d40f(0x1ea)];['reconnectDelay'];[a0_0x58d40f(0x1ec)];[a0_0x58d40f(0x1a7)];[a0_0x58d40f(0x1af)]=!0x1;constructor(_0x41fd26){const _0x53a6c1=a0_0x58d40f;super();if(this[_0x53a6c1(0x198)]=_0x41fd26['url'][_0x53a6c1(0x1c8)](/\/$/,''),this[_0x53a6c1(0x1ae)]=_0x41fd26[_0x53a6c1(0x1ae)],this[_0x53a6c1(0x194)]=_0x41fd26[_0x53a6c1(0x194)],this[_0x53a6c1(0x1b4)]=_0x41fd26[_0x53a6c1(0x1b4)]||'sdk',this[_0x53a6c1(0x19d)]=_0x53a6c1(0x1cc)+_0x41fd26[_0x53a6c1(0x1ae)]+'-'+Date[_0x53a6c1(0x1b5)]()['toString'](0x24),this[_0x53a6c1(0x1ea)]=_0x41fd26['heartbeatInterval']??0x2bf20,this[_0x53a6c1(0x1fd)]=_0x41fd26[_0x53a6c1(0x1fd)]??0xbb8,_0x41fd26[_0x53a6c1(0x1cd)]!==!0x1)this[_0x53a6c1(0x1ab)]();}[a0_0x58d40f(0x1c4)](_0x37455b){const _0x561c5f=a0_0x58d40f;console[_0x561c5f(0x1c4)]('['+new Date()['toTimeString']()[_0x561c5f(0x1c2)](0x0,0x8)+_0x561c5f(0x1d0)+this[_0x561c5f(0x1ae)]+']\x20'+_0x37455b);}async[a0_0x58d40f(0x1f6)](_0x22ae2a,_0x1ee200){const _0x353c3f=a0_0x58d40f;let _0x59b0fc={'Content-Type':_0x353c3f(0x1c0),'Accept':'application/json,\x20text/event-stream'};if(this[_0x353c3f(0x194)])_0x59b0fc[_0x353c3f(0x1ce)]='Bearer\x20'+this[_0x353c3f(0x194)];let _0x37adf5=await(await fetch(this[_0x353c3f(0x198)]+'/mcp',{'method':_0x353c3f(0x1d8),'headers':_0x59b0fc,'body':JSON['stringify']({'jsonrpc':'2.0','id':Date[_0x353c3f(0x1b5)](),'method':_0x353c3f(0x192),'params':{'name':_0x22ae2a,'arguments':_0x1ee200}})}))['text'](),_0x476b91=_0x37adf5[_0x353c3f(0x1d5)](/data: (.+)/),_0x33c69c=_0x476b91?JSON[_0x353c3f(0x1ef)](_0x476b91[0x1]):JSON[_0x353c3f(0x1ef)](_0x37adf5),_0x3180e9=_0x33c69c?.[_0x353c3f(0x1b7)]?.[_0x353c3f(0x1f7)]?.[0x0]?.[_0x353c3f(0x191)];return _0x3180e9?JSON[_0x353c3f(0x1ef)](_0x3180e9):_0x33c69c;}async['connect'](){const _0x529e64=a0_0x58d40f;if(this[_0x529e64(0x1af)])return;this[_0x529e64(0x1af)]=!0x0,await this[_0x529e64(0x1f5)](_0x529e64(0x18d)),this[_0x529e64(0x1c4)](_0x529e64(0x200)),this[_0x529e64(0x1ec)]=setInterval(()=>{const _0x22dbf5=_0x529e64;this[_0x22dbf5(0x1f5)](_0x22dbf5(0x18d))['catch'](_0x24ac65=>this['log']('heartbeat\x20failed:\x20'+_0x24ac65['message']));},this[_0x529e64(0x1ea)]),this[_0x529e64(0x1e3)]();}async['disconnect'](){const _0x45817a=a0_0x58d40f;if(this['running']=!0x1,this['sseAbort']?.[_0x45817a(0x197)](),this[_0x45817a(0x1ec)])clearInterval(this[_0x45817a(0x1ec)]);await this[_0x45817a(0x1f5)](_0x45817a(0x1fc))[_0x45817a(0x1f3)](()=>{}),this[_0x45817a(0x1c4)]('disconnected');}async[a0_0x58d40f(0x18f)](_0x4256cf,_0x5a2a49,_0x1062b5=a0_0x58d40f(0x1b6)){const _0xb046ce=a0_0x58d40f;return Y({'alias':_0x4256cf,'fromAlias':this[_0xb046ce(0x1ae)]},{'log':_0x2d284c=>console[_0xb046ce(0x1c4)](_0x2d284c),'send':()=>this['call'](_0xb046ce(0x1b2),{'alias':_0x4256cf,'task':_0x5a2a49,'priority':_0x1062b5,'from_session':this[_0xb046ce(0x1ae)]})});}async[a0_0x58d40f(0x18e)](_0x3914c9,_0x3d0284){const _0x36bae8=a0_0x58d40f;return this[_0x36bae8(0x1f6)]('send_message',{'alias':_0x3914c9,'message':_0x3d0284,'from_session':this[_0x36bae8(0x1ae)]});}async['reply'](_0x134b28,_0x472227,_0x2c044d=a0_0x58d40f(0x19f)){const _0x22a9e2=a0_0x58d40f;return this['call'](_0x22a9e2(0x1a2),{'in_reply_to':_0x134b28,'text':_0x472227,'status':_0x2c044d});}async[a0_0x58d40f(0x1f5)](_0x578949,_0x37679b){const _0x12b1b7=a0_0x58d40f;return this['call'](_0x12b1b7(0x18b),{'resume_id':this[_0x12b1b7(0x19d)],'alias':this['alias'],'status':_0x578949,'server':a0_0x25084e(),'hostname':a0_0x25084e(),'agent':this[_0x12b1b7(0x1b4)],'project_dir':process[_0x12b1b7(0x1a8)](),..._0x37679b});}async[a0_0x58d40f(0x1ba)](){return this['call']('get_all_status',{});}async[a0_0x58d40f(0x1ed)](_0x574ab5,_0x4ab8cc){const _0x19e089=a0_0x58d40f;return this['call'](_0x19e089(0x1ed),{'message':_0x574ab5,'filter_server':_0x4ab8cc?.['server'],'filter_status':_0x4ab8cc?.[_0x19e089(0x1f5)]});}async[a0_0x58d40f(0x1e3)](){const _0x23050e=a0_0x58d40f;let _0x2fd041=encodeURIComponent(this[_0x23050e(0x1ae)]),_0x5758a3=this[_0x23050e(0x198)]+_0x23050e(0x1ad)+_0x2fd041,_0x4067fb=this[_0x23050e(0x1fd)];while(this['running']){try{this['sseAbort']=new AbortController();let _0x3c56ac={'Accept':_0x23050e(0x1f8)};if(this[_0x23050e(0x194)])_0x3c56ac['Authorization']=_0x23050e(0x1a4)+this[_0x23050e(0x194)];let _0x2f27cb=await fetch(_0x5758a3,{'headers':_0x3c56ac,'signal':this[_0x23050e(0x1a7)]['signal']});if(!_0x2f27cb['ok']||!_0x2f27cb['body']){this[_0x23050e(0x1c4)](_0x23050e(0x1b8)+_0x2f27cb[_0x23050e(0x1f5)]),await this['sleep'](_0x4067fb),_0x4067fb=Math[_0x23050e(0x1e1)](_0x4067fb*1.5,0xea60);continue;}_0x4067fb=this[_0x23050e(0x1fd)];let _0x49e03e=_0x2f27cb['body'][_0x23050e(0x18a)](),_0x13201e=new TextDecoder(),_0x328f6e='';while(this[_0x23050e(0x1af)]){let {done:_0x2c28ab,value:_0x4d0c67}=await _0x49e03e['read']();if(_0x2c28ab)break;_0x328f6e+=_0x13201e[_0x23050e(0x1cf)](_0x4d0c67,{'stream':!0x0});let _0x52f9d1=_0x328f6e[_0x23050e(0x18c)]('\x0a');_0x328f6e=_0x52f9d1[_0x23050e(0x1e0)]()||'';for(let _0x570f87 of _0x52f9d1){if(!_0x570f87[_0x23050e(0x1ac)](_0x23050e(0x1c3)))continue;try{let _0x4a416a=JSON[_0x23050e(0x1ef)](_0x570f87[_0x23050e(0x1c2)](0x6));if(_0x4a416a[_0x23050e(0x1d2)]===_0x23050e(0x1c6)){this[_0x23050e(0x1c4)](_0x23050e(0x1d6)),this['emit']('connected');continue;}if(_0x4a416a[_0x23050e(0x1d2)]==='new_task'||_0x4a416a[_0x23050e(0x1d2)]===_0x23050e(0x1f1)||_0x4a416a['type']==='broadcast')await this[_0x23050e(0x1bb)]();}catch{}}}}catch(_0xfb9588){if(_0xfb9588[_0x23050e(0x204)]==='AbortError')break;this[_0x23050e(0x190)](_0x23050e(0x1b9),_0xfb9588),this[_0x23050e(0x1c4)]('SSE\x20error:\x20'+_0xfb9588[_0x23050e(0x18e)]);}if(this[_0x23050e(0x1af)])this[_0x23050e(0x190)](_0x23050e(0x199)),this[_0x23050e(0x1c4)]('SSE\x20reconnecting\x20in\x20'+_0x4067fb/0x3e8+'s...'),await this['sleep'](_0x4067fb),_0x4067fb=Math[_0x23050e(0x1e1)](_0x4067fb*1.5,0xea60);}}async[a0_0x58d40f(0x1bb)](){const _0x53b637=a0_0x58d40f;try{let _0x4dc42d=(await this[_0x53b637(0x1f6)](_0x53b637(0x1c1),{'alias':this[_0x53b637(0x1ae)],'limit':0xa}))?.[_0x53b637(0x1c5)]||[];for(let _0x357b0f of _0x4dc42d)await this[_0x53b637(0x1f6)](_0x53b637(0x19a),{'alias':this[_0x53b637(0x1ae)],'message_id':_0x357b0f['id']}),this[_0x53b637(0x1c4)]('←\x20'+_0x357b0f[_0x53b637(0x1e5)]+':\x20'+_0x357b0f[_0x53b637(0x1f7)]['slice'](0x0,0x3c)),this['emit'](_0x53b637(0x1c9),_0x357b0f),this['emit'](_0x53b637(0x18e),_0x357b0f);}catch(_0x21fd77){this['log'](_0x53b637(0x1a6)+_0x21fd77[_0x53b637(0x18e)]);}}['sleep'](_0x17c109){return new Promise(_0x4d7439=>setTimeout(_0x4d7439,_0x17c109));}}function a0_0x13e3(_0x26385e,_0x24962e){_0x26385e=_0x26385e-0x189;const _0x469b51=a0_0x469b();let _0x13e3f6=_0x469b51[_0x26385e];return _0x13e3f6;}var F=$;export{F as default,$ as CommHub};
|