@sleep2agi/agent-network 2.3.0-preview.52 → 2.3.0-preview.53
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
|
-
function a0_0x372f(_0x11f988,_0x2bdd94){_0x11f988=_0x11f988-0x11e;const _0x13cb4a=a0_0x13cb();let _0x372fb7=_0x13cb4a[_0x11f988];return _0x372fb7;}const a0_0x252a16=a0_0x372f;(function(_0x581b96,_0x2e12b9){const _0x5e9784=a0_0x372f,_0x6a41a2=_0x581b96();while(!![]){try{const _0x37f858=parseInt(_0x5e9784(0x158))/0x1+-parseInt(_0x5e9784(0x19e))/0x2*(-parseInt(_0x5e9784(0x193))/0x3)+parseInt(_0x5e9784(0x14a))/0x4+parseInt(_0x5e9784(0x191))/0x5*(parseInt(_0x5e9784(0x180))/0x6)+-parseInt(_0x5e9784(0x186))/0x7+parseInt(_0x5e9784(0x152))/0x8*(parseInt(_0x5e9784(0x168))/0x9)+-parseInt(_0x5e9784(0x190))/0xa*(parseInt(_0x5e9784(0x13b))/0xb);if(_0x37f858===_0x2e12b9)break;else _0x6a41a2['push'](_0x6a41a2['shift']());}catch(_0x1cbea0){_0x6a41a2['push'](_0x6a41a2['shift']());}}}(a0_0x13cb,0xc69e3));import{EventEmitter as a0_0x45e0d2}from'events';import{hostname as a0_0xbee4e0}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0xdb9f1e,_0x284509)=>(_0xdb9f1e??_0x284509)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x252a16(0x148)](0x0,0xf0);function N(_0x4d3bba){const _0x996ee1=a0_0x252a16;return(_0x4d3bba instanceof Error?_0x4d3bba[_0x996ee1(0x155)]:String(_0x4d3bba??'unknown\x20error'))[_0x996ee1(0x154)](K,_0x996ee1(0x160))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x996ee1(0x148)](0x0,0xf0);}function O(_0xcda38b,_0x301420=process.env.ANET_TASK_TRACE_FORMAT===a0_0x252a16(0x147)){const _0x541087=a0_0x252a16;if(_0x301420)return JSON['stringify'](_0xcda38b);let _0x1a1ebc=L(_0xcda38b[_0x541087(0x16c)],_0x541087(0x17d)),_0x4f728b=L(_0xcda38b[_0x541087(0x139)],_0x541087(0x167)),_0x22e717=_0xcda38b[_0x541087(0x170)]?'\x20error='+_0xcda38b[_0x541087(0x170)]+':'+(_0xcda38b[_0x541087(0x12a)]??''):'';return'[commhub:task]\x20'+_0xcda38b[_0x541087(0x11f)]+_0x541087(0x16a)+L(_0xcda38b[_0x541087(0x175)],'<unknown>')+_0x541087(0x162)+L(_0xcda38b[_0x541087(0x12c)],_0x541087(0x181))+_0x541087(0x135)+_0x4f728b+_0x541087(0x149)+_0x1a1ebc+_0x541087(0x14c)+L(_0xcda38b[_0x541087(0x12f)],_0x541087(0x181))+'\x20transport='+_0xcda38b[_0x541087(0x163)]+_0x541087(0x174)+_0xcda38b[_0x541087(0x142)]+_0x541087(0x187)+_0xcda38b[_0x541087(0x196)]+_0x22e717;}function a0_0x13cb(){const _0x475210=['task.ack','lifecycle_tracking','from_session','inbox\x20error:\x20','fromAlias','POST','CommHub\x20response\x20omitted\x20task_id','completed','parse','1185214xrqEmo','CommHub\x20rejected\x20task','getAllStatus','status','resumeId','error','mcp_http','toString','sleep','normal','disconnected','running','url','missing_task_id','error_message','lifecycleTracking','to_alias','match','connect','network_id','SSE\x20failed:\x20','task.send.failed','application/json','not_tracked','networkId','\x20task_id=','text/event-stream','SSE\x20error:\x20','report_status','task_id','send','11KHflxA','messages','toAlias','application/json,\x20text/event-stream','SSE\x20reconnecting\x20in\x20','task.expired','task','duration_ms','sending','delivered','token','emit','json','slice','\x20parent_task_id=','1109632zBPHGz','reply','\x20network_id=','send_rejected','content','processInbox','/mcp','body','80720leneBb','reconnectDelay','replace','message','Authorization','min','706602FNavrL','pop','message_id','failed','send_message','signal','broadcast','text','[REDACTED]','heartbeatInterval','\x20to=','transport','type','stringify','connectSSE','<pending>','1170hyNiYs','server','\x20from=','now','parent_task_id','AbortError','heartbeatTimer','new_message','error_code','string','agent','toTimeString','\x20duration_ms=','from_alias','get_inbox','cwd','new_task','get_all_status','getReader','s...','sseAbort','<missing>','registered','parentTaskId','12vQbJWK','<unknown>','autoConnect','task.replied','ack_inbox','alias','7592305YHAxdl','\x20lifecycle=','log','data:\x20','connected','task.send.start','sdk','offline','call','decode','17148670ZsOhEf','1811760ffhZgO','Bearer\x20','3PQIlFn','idle'];a0_0x13cb=function(){return _0x475210;};return a0_0x13cb();}function U(_0x4de6e8){const _0x469adf=a0_0x252a16;return{'event':{'sending':_0x469adf(0x18b),'delivered':'task.send.delivered','failed':_0x469adf(0x131),'acked':_0x469adf(0x195),'started':'task.started','replied':_0x469adf(0x183),'expired':_0x469adf(0x140)}[_0x4de6e8[_0x469adf(0x11f)]],..._0x4de6e8};}function j(_0x920b40){const _0x3877a5=a0_0x252a16;let _0x51c9cf=_0x920b40?.[_0x3877a5(0x139)]||_0x920b40?.['message_id']||_0x920b40?.['id'];if(_0x51c9cf)return String(_0x51c9cf);let _0x1020be=_0x920b40?.[_0x3877a5(0x14e)]?.[0x0]?.[_0x3877a5(0x15f)];if(typeof _0x1020be!==_0x3877a5(0x171))return null;try{let _0x87eb6c=JSON['parse'](_0x1020be);return _0x87eb6c?.[_0x3877a5(0x139)]||_0x87eb6c?.[_0x3877a5(0x15a)]||_0x87eb6c?.['id']||null;}catch{return null;}}async function X(_0x3b625a,_0x276011){const _0x2877d2=a0_0x252a16;let _0x5c9b6b=_0x276011[_0x2877d2(0x16b)]??Date[_0x2877d2(0x16b)],_0x96931b=_0x5c9b6b(),_0x250038=(_0x1a6cc8,_0x38b24d,_0x52af77,_0x508709)=>{const _0x33331e=_0x2877d2;_0x276011[_0x33331e(0x188)](O(U({'from_alias':_0x3b625a[_0x33331e(0x199)],'to_alias':_0x3b625a[_0x33331e(0x13d)],'task_id':_0x38b24d,'parent_task_id':_0x3b625a[_0x33331e(0x17f)],'network_id':_0x3b625a['networkId'],'transport':_0x3b625a[_0x33331e(0x163)],'status':_0x1a6cc8,'duration_ms':_0x5c9b6b()-_0x96931b,'lifecycle_tracking':_0x3b625a[_0x33331e(0x12b)],..._0x52af77!==void 0x0?{'error_code':_0x508709||'send_failed','error_message':N(_0x52af77)}:{}})));};_0x250038(_0x2877d2(0x143),null);try{let _0x5f2639=await _0x276011[_0x2877d2(0x13a)](),_0x593971=j(_0x5f2639);if(_0x593971)_0x250038(_0x2877d2(0x144),_0x593971);else{if(_0x5f2639?.['ok']===!0x1||_0x5f2639?.['error'])_0x250038(_0x2877d2(0x15b),_0x593971,_0x5f2639?.[_0x2877d2(0x121)]||_0x2877d2(0x19f),_0x2877d2(0x14d));else _0x250038(_0x2877d2(0x15b),null,_0x2877d2(0x19b),_0x2877d2(0x129));}return _0x5f2639;}catch(_0x4fefbe){throw _0x250038('failed',null,_0x4fefbe,'send_failed'),_0x4fefbe;}}async function Y(_0x3a3d6,_0x79b51a){const _0x4a7beb=a0_0x252a16;return X({'fromAlias':_0x3a3d6[_0x4a7beb(0x199)],'toAlias':_0x3a3d6[_0x4a7beb(0x185)],'parentTaskId':_0x3a3d6[_0x4a7beb(0x17f)]||null,'networkId':_0x3a3d6[_0x4a7beb(0x134)]||null,'transport':_0x4a7beb(0x122),'lifecycleTracking':_0x4a7beb(0x133)},_0x79b51a);}class $ extends a0_0x45e0d2{['url'];[a0_0x252a16(0x185)];[a0_0x252a16(0x145)];[a0_0x252a16(0x172)];[a0_0x252a16(0x120)];[a0_0x252a16(0x161)];['reconnectDelay'];[a0_0x252a16(0x16e)];[a0_0x252a16(0x17c)];[a0_0x252a16(0x127)]=!0x1;constructor(_0x3be9bd){const _0x3ed9e6=a0_0x252a16;super();if(this['url']=_0x3be9bd[_0x3ed9e6(0x128)][_0x3ed9e6(0x154)](/\/$/,''),this[_0x3ed9e6(0x185)]=_0x3be9bd[_0x3ed9e6(0x185)],this[_0x3ed9e6(0x145)]=_0x3be9bd[_0x3ed9e6(0x145)],this[_0x3ed9e6(0x172)]=_0x3be9bd[_0x3ed9e6(0x172)]||_0x3ed9e6(0x18c),this[_0x3ed9e6(0x120)]='sdk-'+_0x3be9bd[_0x3ed9e6(0x185)]+'-'+Date['now']()[_0x3ed9e6(0x123)](0x24),this['heartbeatInterval']=_0x3be9bd[_0x3ed9e6(0x161)]??0x2bf20,this[_0x3ed9e6(0x153)]=_0x3be9bd[_0x3ed9e6(0x153)]??0xbb8,_0x3be9bd[_0x3ed9e6(0x182)]!==!0x1)this[_0x3ed9e6(0x12e)]();}[a0_0x252a16(0x188)](_0x154496){const _0x20e5da=a0_0x252a16;console[_0x20e5da(0x188)]('['+new Date()[_0x20e5da(0x173)]()[_0x20e5da(0x148)](0x0,0x8)+']\x20[commhub:'+this[_0x20e5da(0x185)]+']\x20'+_0x154496);}async[a0_0x252a16(0x18e)](_0x17f7cc,_0x59b6cb){const _0x3dbe53=a0_0x252a16;let _0x200478={'Content-Type':_0x3dbe53(0x132),'Accept':_0x3dbe53(0x13e)};if(this[_0x3dbe53(0x145)])_0x200478[_0x3dbe53(0x156)]=_0x3dbe53(0x192)+this[_0x3dbe53(0x145)];let _0x5233a4=await(await fetch(this[_0x3dbe53(0x128)]+_0x3dbe53(0x150),{'method':_0x3dbe53(0x19a),'headers':_0x200478,'body':JSON[_0x3dbe53(0x165)]({'jsonrpc':'2.0','id':Date[_0x3dbe53(0x16b)](),'method':'tools/call','params':{'name':_0x17f7cc,'arguments':_0x59b6cb}})}))[_0x3dbe53(0x15f)](),_0x1f5d47=_0x5233a4[_0x3dbe53(0x12d)](/data: (.+)/),_0x29e3a0=_0x1f5d47?JSON[_0x3dbe53(0x19d)](_0x1f5d47[0x1]):JSON[_0x3dbe53(0x19d)](_0x5233a4),_0x2d05e4=_0x29e3a0?.['result']?.[_0x3dbe53(0x14e)]?.[0x0]?.[_0x3dbe53(0x15f)];return _0x2d05e4?JSON[_0x3dbe53(0x19d)](_0x2d05e4):_0x29e3a0;}async[a0_0x252a16(0x12e)](){const _0x4edfed=a0_0x252a16;if(this[_0x4edfed(0x127)])return;this['running']=!0x0,await this[_0x4edfed(0x11f)](_0x4edfed(0x194)),this['log'](_0x4edfed(0x17e)),this[_0x4edfed(0x16e)]=setInterval(()=>{const _0x45266f=_0x4edfed;this[_0x45266f(0x11f)](_0x45266f(0x194))['catch'](_0x3b0a39=>this['log']('heartbeat\x20failed:\x20'+_0x3b0a39[_0x45266f(0x155)]));},this[_0x4edfed(0x161)]),this[_0x4edfed(0x166)]();}async['disconnect'](){const _0x312c28=a0_0x252a16;if(this['running']=!0x1,this[_0x312c28(0x17c)]?.['abort'](),this['heartbeatTimer'])clearInterval(this[_0x312c28(0x16e)]);await this['status'](_0x312c28(0x18d))['catch'](()=>{}),this[_0x312c28(0x188)](_0x312c28(0x126));}async[a0_0x252a16(0x13a)](_0x33bc24,_0x318c03,_0x4c6f4b=a0_0x252a16(0x125)){const _0x2fc65b=a0_0x252a16;return Y({'alias':_0x33bc24,'fromAlias':this[_0x2fc65b(0x185)]},{'log':_0x620281=>console[_0x2fc65b(0x188)](_0x620281),'send':()=>this[_0x2fc65b(0x18e)]('send_task',{'alias':_0x33bc24,'task':_0x318c03,'priority':_0x4c6f4b,'from_session':this[_0x2fc65b(0x185)]})});}async['message'](_0x45faed,_0x1adc3e){const _0x24c58f=a0_0x252a16;return this[_0x24c58f(0x18e)](_0x24c58f(0x15c),{'alias':_0x45faed,'message':_0x1adc3e,'from_session':this[_0x24c58f(0x185)]});}async[a0_0x252a16(0x14b)](_0x4b01d9,_0x19548d,_0x57f698=a0_0x252a16(0x19c)){const _0x4daeb1=a0_0x252a16;return this[_0x4daeb1(0x18e)]('send_reply',{'in_reply_to':_0x4b01d9,'text':_0x19548d,'status':_0x57f698});}async[a0_0x252a16(0x11f)](_0x432f2c,_0x5c9253){const _0x2d7e40=a0_0x252a16;return this['call'](_0x2d7e40(0x138),{'resume_id':this[_0x2d7e40(0x120)],'alias':this[_0x2d7e40(0x185)],'status':_0x432f2c,'server':a0_0xbee4e0(),'hostname':a0_0xbee4e0(),'agent':this[_0x2d7e40(0x172)],'project_dir':process[_0x2d7e40(0x177)](),..._0x5c9253});}async[a0_0x252a16(0x11e)](){const _0xf1714c=a0_0x252a16;return this[_0xf1714c(0x18e)](_0xf1714c(0x179),{});}async['broadcast'](_0x43fe53,_0x5aec82){const _0x3a1607=a0_0x252a16;return this[_0x3a1607(0x18e)](_0x3a1607(0x15e),{'message':_0x43fe53,'filter_server':_0x5aec82?.[_0x3a1607(0x169)],'filter_status':_0x5aec82?.['status']});}async[a0_0x252a16(0x166)](){const _0x5aedb1=a0_0x252a16;let _0x1a66eb=encodeURIComponent(this[_0x5aedb1(0x185)]),_0x3ea6eb=this[_0x5aedb1(0x128)]+'/events/'+_0x1a66eb,_0x312aa8=this[_0x5aedb1(0x153)];while(this[_0x5aedb1(0x127)]){try{this[_0x5aedb1(0x17c)]=new AbortController();let _0x346375={'Accept':_0x5aedb1(0x136)};if(this[_0x5aedb1(0x145)])_0x346375[_0x5aedb1(0x156)]=_0x5aedb1(0x192)+this['token'];let _0x447c6e=await fetch(_0x3ea6eb,{'headers':_0x346375,'signal':this[_0x5aedb1(0x17c)][_0x5aedb1(0x15d)]});if(!_0x447c6e['ok']||!_0x447c6e[_0x5aedb1(0x151)]){this['log'](_0x5aedb1(0x130)+_0x447c6e[_0x5aedb1(0x11f)]),await this[_0x5aedb1(0x124)](_0x312aa8),_0x312aa8=Math[_0x5aedb1(0x157)](_0x312aa8*1.5,0xea60);continue;}_0x312aa8=this[_0x5aedb1(0x153)];let _0x2dbeae=_0x447c6e[_0x5aedb1(0x151)][_0x5aedb1(0x17a)](),_0x1d93c5=new TextDecoder(),_0x5f331b='';while(this['running']){let {done:_0x4ea1e9,value:_0x53648e}=await _0x2dbeae['read']();if(_0x4ea1e9)break;_0x5f331b+=_0x1d93c5[_0x5aedb1(0x18f)](_0x53648e,{'stream':!0x0});let _0x5a31c1=_0x5f331b['split']('\x0a');_0x5f331b=_0x5a31c1[_0x5aedb1(0x159)]()||'';for(let _0x594085 of _0x5a31c1){if(!_0x594085['startsWith'](_0x5aedb1(0x189)))continue;try{let _0x1154a7=JSON[_0x5aedb1(0x19d)](_0x594085['slice'](0x6));if(_0x1154a7[_0x5aedb1(0x164)]===_0x5aedb1(0x18a)){this['log']('SSE\x20connected'),this[_0x5aedb1(0x146)](_0x5aedb1(0x18a));continue;}if(_0x1154a7[_0x5aedb1(0x164)]===_0x5aedb1(0x178)||_0x1154a7[_0x5aedb1(0x164)]===_0x5aedb1(0x16f)||_0x1154a7[_0x5aedb1(0x164)]===_0x5aedb1(0x15e))await this[_0x5aedb1(0x14f)]();}catch{}}}}catch(_0x148559){if(_0x148559['name']===_0x5aedb1(0x16d))break;this['emit'](_0x5aedb1(0x121),_0x148559),this[_0x5aedb1(0x188)](_0x5aedb1(0x137)+_0x148559[_0x5aedb1(0x155)]);}if(this[_0x5aedb1(0x127)])this['emit'](_0x5aedb1(0x126)),this[_0x5aedb1(0x188)](_0x5aedb1(0x13f)+_0x312aa8/0x3e8+_0x5aedb1(0x17b)),await this[_0x5aedb1(0x124)](_0x312aa8),_0x312aa8=Math['min'](_0x312aa8*1.5,0xea60);}}async['processInbox'](){const _0x52be44=a0_0x252a16;try{let _0x5970cf=(await this['call'](_0x52be44(0x176),{'alias':this[_0x52be44(0x185)],'limit':0xa}))?.[_0x52be44(0x13c)]||[];for(let _0xfd98f2 of _0x5970cf)await this[_0x52be44(0x18e)](_0x52be44(0x184),{'alias':this['alias'],'message_id':_0xfd98f2['id']}),this['log']('←\x20'+_0xfd98f2[_0x52be44(0x197)]+':\x20'+_0xfd98f2[_0x52be44(0x14e)][_0x52be44(0x148)](0x0,0x3c)),this[_0x52be44(0x146)](_0x52be44(0x141),_0xfd98f2),this[_0x52be44(0x146)](_0x52be44(0x155),_0xfd98f2);}catch(_0xe4676e){this[_0x52be44(0x188)](_0x52be44(0x198)+_0xe4676e['message']);}}[a0_0x252a16(0x124)](_0xef1a16){return new Promise(_0x32f332=>setTimeout(_0x32f332,_0xef1a16));}}var F=$;export{F as default,$ as CommHub};
|
|
1
|
+
const a0_0x2a613d=a0_0x133d;(function(_0x21ee4a,_0x3ccdd9){const _0x46be73=a0_0x133d,_0x1e840c=_0x21ee4a();while(!![]){try{const _0x422612=-parseInt(_0x46be73(0x223))/0x1+-parseInt(_0x46be73(0x260))/0x2+parseInt(_0x46be73(0x23e))/0x3+-parseInt(_0x46be73(0x1f1))/0x4*(-parseInt(_0x46be73(0x256))/0x5)+parseInt(_0x46be73(0x1f4))/0x6+-parseInt(_0x46be73(0x23f))/0x7+parseInt(_0x46be73(0x216))/0x8*(parseInt(_0x46be73(0x211))/0x9);if(_0x422612===_0x3ccdd9)break;else _0x1e840c['push'](_0x1e840c['shift']());}catch(_0x36ea20){_0x1e840c['push'](_0x1e840c['shift']());}}}(a0_0x3a99,0x7e9cd));import{EventEmitter as a0_0x3b2def}from'events';import{hostname as a0_0x23e654}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x222d0a,_0x2f8cd2)=>(_0x222d0a??_0x2f8cd2)[a0_0x2a613d(0x247)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x2a613d(0x1e7)](0x0,0xf0);function N(_0x4919a0){const _0x41c93e=a0_0x2a613d;return(_0x4919a0 instanceof Error?_0x4919a0[_0x41c93e(0x249)]:String(_0x4919a0??_0x41c93e(0x214)))['replace'](K,_0x41c93e(0x242))[_0x41c93e(0x247)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x41c93e(0x1e7)](0x0,0xf0);}function a0_0x3a99(){const _0x267a7c=['disconnected','\x20to=','\x20network_id=','resumeId','[commhub:task]\x20','new_task','task.send.start','stringify','transport','connect','AbortError','lifecycle_tracking','networkId','network_id','url','autoConnect','reconnectDelay','match','send_reply','offline','pop','error_code','running','parent_task_id','data:\x20','9hCMRst','log','send_failed','unknown\x20error','ack_inbox','7001144IVrzkL',']\x20[commhub:','2.0','error_message','connectSSE','call','send_task','SSE\x20connected','SSE\x20reconnecting\x20in\x20','failed','sseAbort','SSE\x20error:\x20','send','935313rCwsZO','error','now','broadcast','json','content','\x20error=','sleep','application/json,\x20text/event-stream','sdk','startsWith','emit','text','registered','processInbox','Authorization','min','abort','\x20from=','token','from_alias','<unknown>','completed','get_inbox','parse','send_message','\x20transport=','1702575ZvBXMR','2665019HBrCHz','SSE\x20failed:\x20','to_alias','[REDACTED]','message_id','CommHub\x20response\x20omitted\x20task_id','toTimeString','connected','replace','<pending>','message','missing_task_id','read','heartbeatInterval','disconnect','alias','not_tracked','decode','name','\x20lifecycle=','get_all_status','string','cwd','665290xsiQId','heartbeat\x20failed:\x20','status','new_message','<missing>','task.started','messages','task.replied','result','heartbeatTimer','1583384xOTRJI','inbox\x20error:\x20','sdk-','task','/mcp','slice','POST','task_id','split','catch','task.send.failed','Bearer\x20','mcp_http','toString','duration_ms','28glJeOq','idle','s...','1513518iwyyip','parentTaskId','body','agent'];a0_0x3a99=function(){return _0x267a7c;};return a0_0x3a99();}function O(_0x3189d5,_0x11f8a4=process.env.ANET_TASK_TRACE_FORMAT===a0_0x2a613d(0x227)){const _0x288eb1=a0_0x2a613d;if(_0x11f8a4)return JSON[_0x288eb1(0x1ff)](_0x3189d5);let _0x49f72f=L(_0x3189d5[_0x288eb1(0x20f)],_0x288eb1(0x25a)),_0x45cc9=L(_0x3189d5[_0x288eb1(0x1e9)],_0x288eb1(0x248)),_0x4bc272=_0x3189d5[_0x288eb1(0x20d)]?_0x288eb1(0x229)+_0x3189d5[_0x288eb1(0x20d)]+':'+(_0x3189d5[_0x288eb1(0x219)]??''):'';return _0x288eb1(0x1fc)+_0x3189d5[_0x288eb1(0x258)]+_0x288eb1(0x235)+L(_0x3189d5[_0x288eb1(0x237)],_0x288eb1(0x238))+_0x288eb1(0x1f9)+L(_0x3189d5[_0x288eb1(0x241)],_0x288eb1(0x238))+'\x20task_id='+_0x45cc9+'\x20parent_task_id='+_0x49f72f+_0x288eb1(0x1fa)+L(_0x3189d5[_0x288eb1(0x205)],_0x288eb1(0x238))+_0x288eb1(0x23d)+_0x3189d5[_0x288eb1(0x200)]+'\x20duration_ms='+_0x3189d5[_0x288eb1(0x1f0)]+_0x288eb1(0x252)+_0x3189d5[_0x288eb1(0x203)]+_0x4bc272;}function U(_0x438ae6){const _0x3c274c=a0_0x2a613d;return{'event':{'sending':_0x3c274c(0x1fe),'delivered':'task.send.delivered','failed':_0x3c274c(0x1ec),'acked':'task.ack','started':_0x3c274c(0x25b),'replied':_0x3c274c(0x25d),'expired':'task.expired'}[_0x438ae6[_0x3c274c(0x258)]],..._0x438ae6};}function j(_0x35c883){const _0x50c488=a0_0x2a613d;let _0x374345=_0x35c883?.[_0x50c488(0x1e9)]||_0x35c883?.[_0x50c488(0x243)]||_0x35c883?.['id'];if(_0x374345)return String(_0x374345);let _0x28329e=_0x35c883?.[_0x50c488(0x228)]?.[0x0]?.[_0x50c488(0x22f)];if(typeof _0x28329e!==_0x50c488(0x254))return null;try{let _0x2aa83d=JSON[_0x50c488(0x23b)](_0x28329e);return _0x2aa83d?.['task_id']||_0x2aa83d?.[_0x50c488(0x243)]||_0x2aa83d?.['id']||null;}catch{return null;}}async function X(_0x3b4153,_0x1b303c){const _0x273e3b=a0_0x2a613d;let _0x3ee895=_0x1b303c['now']??Date[_0x273e3b(0x225)],_0x2f7c29=_0x3ee895(),_0x5183f1=(_0x3a5e2c,_0x3fecd7,_0x181117,_0x3a4385)=>{const _0x26cd14=_0x273e3b;_0x1b303c[_0x26cd14(0x212)](O(U({'from_alias':_0x3b4153['fromAlias'],'to_alias':_0x3b4153['toAlias'],'task_id':_0x3fecd7,'parent_task_id':_0x3b4153[_0x26cd14(0x1f5)],'network_id':_0x3b4153[_0x26cd14(0x204)],'transport':_0x3b4153['transport'],'status':_0x3a5e2c,'duration_ms':_0x3ee895()-_0x2f7c29,'lifecycle_tracking':_0x3b4153['lifecycleTracking'],..._0x181117!==void 0x0?{'error_code':_0x3a4385||'send_failed','error_message':N(_0x181117)}:{}})));};_0x5183f1('sending',null);try{let _0x34623d=await _0x1b303c[_0x273e3b(0x222)](),_0x360a12=j(_0x34623d);if(_0x360a12)_0x5183f1('delivered',_0x360a12);else{if(_0x34623d?.['ok']===!0x1||_0x34623d?.['error'])_0x5183f1('failed',_0x360a12,_0x34623d?.['error']||'CommHub\x20rejected\x20task','send_rejected');else _0x5183f1(_0x273e3b(0x21f),null,_0x273e3b(0x244),_0x273e3b(0x24a));}return _0x34623d;}catch(_0x4e3b61){throw _0x5183f1(_0x273e3b(0x21f),null,_0x4e3b61,_0x273e3b(0x213)),_0x4e3b61;}}async function Y(_0x8c6ff7,_0x5dd545){const _0x525d74=a0_0x2a613d;return X({'fromAlias':_0x8c6ff7['fromAlias'],'toAlias':_0x8c6ff7[_0x525d74(0x24e)],'parentTaskId':_0x8c6ff7[_0x525d74(0x1f5)]||null,'networkId':_0x8c6ff7[_0x525d74(0x204)]||null,'transport':_0x525d74(0x1ee),'lifecycleTracking':_0x525d74(0x24f)},_0x5dd545);}class $ extends a0_0x3b2def{[a0_0x2a613d(0x206)];['alias'];[a0_0x2a613d(0x236)];['agent'];[a0_0x2a613d(0x1fb)];[a0_0x2a613d(0x24c)];[a0_0x2a613d(0x208)];[a0_0x2a613d(0x25f)];[a0_0x2a613d(0x220)];['running']=!0x1;constructor(_0x583938){const _0x3693b0=a0_0x2a613d;super();if(this[_0x3693b0(0x206)]=_0x583938[_0x3693b0(0x206)]['replace'](/\/$/,''),this[_0x3693b0(0x24e)]=_0x583938[_0x3693b0(0x24e)],this[_0x3693b0(0x236)]=_0x583938[_0x3693b0(0x236)],this['agent']=_0x583938[_0x3693b0(0x1f7)]||_0x3693b0(0x22c),this[_0x3693b0(0x1fb)]=_0x3693b0(0x262)+_0x583938[_0x3693b0(0x24e)]+'-'+Date['now']()[_0x3693b0(0x1ef)](0x24),this[_0x3693b0(0x24c)]=_0x583938[_0x3693b0(0x24c)]??0x2bf20,this['reconnectDelay']=_0x583938['reconnectDelay']??0xbb8,_0x583938[_0x3693b0(0x207)]!==!0x1)this['connect']();}['log'](_0x1c297c){const _0xece31d=a0_0x2a613d;console[_0xece31d(0x212)]('['+new Date()[_0xece31d(0x245)]()[_0xece31d(0x1e7)](0x0,0x8)+_0xece31d(0x217)+this[_0xece31d(0x24e)]+']\x20'+_0x1c297c);}async['call'](_0x468444,_0x453ef1){const _0x46c5c0=a0_0x2a613d;let _0x5ccbcd={'Content-Type':'application/json','Accept':_0x46c5c0(0x22b)};if(this[_0x46c5c0(0x236)])_0x5ccbcd[_0x46c5c0(0x232)]=_0x46c5c0(0x1ed)+this[_0x46c5c0(0x236)];let _0x3eda58=await(await fetch(this[_0x46c5c0(0x206)]+_0x46c5c0(0x264),{'method':_0x46c5c0(0x1e8),'headers':_0x5ccbcd,'body':JSON[_0x46c5c0(0x1ff)]({'jsonrpc':_0x46c5c0(0x218),'id':Date[_0x46c5c0(0x225)](),'method':'tools/call','params':{'name':_0x468444,'arguments':_0x453ef1}})}))['text'](),_0x43cad8=_0x3eda58[_0x46c5c0(0x209)](/data: (.+)/),_0xf2ddc=_0x43cad8?JSON['parse'](_0x43cad8[0x1]):JSON['parse'](_0x3eda58),_0x522c76=_0xf2ddc?.[_0x46c5c0(0x25e)]?.[_0x46c5c0(0x228)]?.[0x0]?.[_0x46c5c0(0x22f)];return _0x522c76?JSON[_0x46c5c0(0x23b)](_0x522c76):_0xf2ddc;}async[a0_0x2a613d(0x201)](){const _0x3faaff=a0_0x2a613d;if(this[_0x3faaff(0x20e)])return;this[_0x3faaff(0x20e)]=!0x0,await this[_0x3faaff(0x258)](_0x3faaff(0x1f2)),this[_0x3faaff(0x212)](_0x3faaff(0x230)),this[_0x3faaff(0x25f)]=setInterval(()=>{const _0x29f5a8=_0x3faaff;this[_0x29f5a8(0x258)](_0x29f5a8(0x1f2))[_0x29f5a8(0x1eb)](_0x3ab0ed=>this['log'](_0x29f5a8(0x257)+_0x3ab0ed['message']));},this[_0x3faaff(0x24c)]),this[_0x3faaff(0x21a)]();}async[a0_0x2a613d(0x24d)](){const _0x7c2113=a0_0x2a613d;if(this[_0x7c2113(0x20e)]=!0x1,this[_0x7c2113(0x220)]?.[_0x7c2113(0x234)](),this['heartbeatTimer'])clearInterval(this[_0x7c2113(0x25f)]);await this['status'](_0x7c2113(0x20b))[_0x7c2113(0x1eb)](()=>{}),this[_0x7c2113(0x212)](_0x7c2113(0x1f8));}async[a0_0x2a613d(0x222)](_0x4670c4,_0x125850,_0x492961='normal'){const _0x547ce8=a0_0x2a613d;return Y({'alias':_0x4670c4,'fromAlias':this[_0x547ce8(0x24e)]},{'log':_0xf5013f=>console[_0x547ce8(0x212)](_0xf5013f),'send':()=>this[_0x547ce8(0x21b)](_0x547ce8(0x21c),{'alias':_0x4670c4,'task':_0x125850,'priority':_0x492961,'from_session':this[_0x547ce8(0x24e)]})});}async[a0_0x2a613d(0x249)](_0x76472d,_0x56f100){const _0x219c81=a0_0x2a613d;return this[_0x219c81(0x21b)](_0x219c81(0x23c),{'alias':_0x76472d,'message':_0x56f100,'from_session':this['alias']});}async['reply'](_0xaa92b2,_0x2627be,_0x82600e=a0_0x2a613d(0x239)){const _0x572c1e=a0_0x2a613d;return this[_0x572c1e(0x21b)](_0x572c1e(0x20a),{'in_reply_to':_0xaa92b2,'text':_0x2627be,'status':_0x82600e});}async[a0_0x2a613d(0x258)](_0x53b22c,_0x5efec6){const _0x320fe6=a0_0x2a613d;return this[_0x320fe6(0x21b)]('report_status',{'resume_id':this['resumeId'],'alias':this[_0x320fe6(0x24e)],'status':_0x53b22c,'server':a0_0x23e654(),'hostname':a0_0x23e654(),'agent':this['agent'],'project_dir':process[_0x320fe6(0x255)](),..._0x5efec6});}async['getAllStatus'](){const _0x29315a=a0_0x2a613d;return this[_0x29315a(0x21b)](_0x29315a(0x253),{});}async[a0_0x2a613d(0x226)](_0x2c417c,_0x2b2b07){const _0x18ecb5=a0_0x2a613d;return this[_0x18ecb5(0x21b)](_0x18ecb5(0x226),{'message':_0x2c417c,'filter_server':_0x2b2b07?.['server'],'filter_status':_0x2b2b07?.[_0x18ecb5(0x258)]});}async[a0_0x2a613d(0x21a)](){const _0xee2f40=a0_0x2a613d;let _0x221a99=encodeURIComponent(this[_0xee2f40(0x24e)]),_0x3d6c2c=this[_0xee2f40(0x206)]+'/events/'+_0x221a99,_0x2f337e=this[_0xee2f40(0x208)];while(this[_0xee2f40(0x20e)]){try{this[_0xee2f40(0x220)]=new AbortController();let _0x51463e={'Accept':'text/event-stream'};if(this[_0xee2f40(0x236)])_0x51463e[_0xee2f40(0x232)]=_0xee2f40(0x1ed)+this['token'];let _0x7a6d5d=await fetch(_0x3d6c2c,{'headers':_0x51463e,'signal':this[_0xee2f40(0x220)]['signal']});if(!_0x7a6d5d['ok']||!_0x7a6d5d[_0xee2f40(0x1f6)]){this[_0xee2f40(0x212)](_0xee2f40(0x240)+_0x7a6d5d[_0xee2f40(0x258)]),await this[_0xee2f40(0x22a)](_0x2f337e),_0x2f337e=Math['min'](_0x2f337e*1.5,0xea60);continue;}_0x2f337e=this[_0xee2f40(0x208)];let _0x1d6a01=_0x7a6d5d[_0xee2f40(0x1f6)]['getReader'](),_0x263710=new TextDecoder(),_0x32dda3='';while(this[_0xee2f40(0x20e)]){let {done:_0xe88a56,value:_0x1b6072}=await _0x1d6a01[_0xee2f40(0x24b)]();if(_0xe88a56)break;_0x32dda3+=_0x263710[_0xee2f40(0x250)](_0x1b6072,{'stream':!0x0});let _0x23544f=_0x32dda3[_0xee2f40(0x1ea)]('\x0a');_0x32dda3=_0x23544f[_0xee2f40(0x20c)]()||'';for(let _0x370a80 of _0x23544f){if(!_0x370a80[_0xee2f40(0x22d)](_0xee2f40(0x210)))continue;try{let _0x402b0f=JSON[_0xee2f40(0x23b)](_0x370a80['slice'](0x6));if(_0x402b0f['type']===_0xee2f40(0x246)){this[_0xee2f40(0x212)](_0xee2f40(0x21d)),this[_0xee2f40(0x22e)]('connected');continue;}if(_0x402b0f['type']===_0xee2f40(0x1fd)||_0x402b0f['type']===_0xee2f40(0x259)||_0x402b0f['type']===_0xee2f40(0x226))await this[_0xee2f40(0x231)]();}catch{}}}}catch(_0xb203e3){if(_0xb203e3[_0xee2f40(0x251)]===_0xee2f40(0x202))break;this[_0xee2f40(0x22e)](_0xee2f40(0x224),_0xb203e3),this[_0xee2f40(0x212)](_0xee2f40(0x221)+_0xb203e3[_0xee2f40(0x249)]);}if(this[_0xee2f40(0x20e)])this[_0xee2f40(0x22e)](_0xee2f40(0x1f8)),this[_0xee2f40(0x212)](_0xee2f40(0x21e)+_0x2f337e/0x3e8+_0xee2f40(0x1f3)),await this[_0xee2f40(0x22a)](_0x2f337e),_0x2f337e=Math[_0xee2f40(0x233)](_0x2f337e*1.5,0xea60);}}async[a0_0x2a613d(0x231)](){const _0x516f40=a0_0x2a613d;try{let _0x71c829=(await this[_0x516f40(0x21b)](_0x516f40(0x23a),{'alias':this[_0x516f40(0x24e)],'limit':0xa}))?.[_0x516f40(0x25c)]||[];for(let _0x4a8d6d of _0x71c829)await this['call'](_0x516f40(0x215),{'alias':this[_0x516f40(0x24e)],'message_id':_0x4a8d6d['id']}),this['log']('←\x20'+_0x4a8d6d['from_session']+':\x20'+_0x4a8d6d[_0x516f40(0x228)][_0x516f40(0x1e7)](0x0,0x3c)),this['emit'](_0x516f40(0x263),_0x4a8d6d),this['emit'](_0x516f40(0x249),_0x4a8d6d);}catch(_0xc3a0ff){this[_0x516f40(0x212)](_0x516f40(0x261)+_0xc3a0ff[_0x516f40(0x249)]);}}[a0_0x2a613d(0x22a)](_0x4c06c2){return new Promise(_0x5605e3=>setTimeout(_0x5605e3,_0x4c06c2));}}var F=$;function a0_0x133d(_0x461188,_0x53caa5){_0x461188=_0x461188-0x1e7;const _0x3a9958=a0_0x3a99();let _0x133dde=_0x3a9958[_0x461188];return _0x133dde;}export{F as default,$ as CommHub};
|