@sleep2agi/agent-network 2.3.0-preview.174 → 2.3.0-preview.176
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_0x18b3e1=a0_0x97b3;(function(_0x3a61f4,_0x5af702){const _0x3d8dba=a0_0x97b3,_0x4e9a63=_0x3a61f4();while(!![]){try{const _0x78eb0e=parseInt(_0x3d8dba(0x17b))/0x1+-parseInt(_0x3d8dba(0x13e))/0x2+parseInt(_0x3d8dba(0x133))/0x3+parseInt(_0x3d8dba(0x132))/0x4*(-parseInt(_0x3d8dba(0x16b))/0x5)+parseInt(_0x3d8dba(0x171))/0x6+-parseInt(_0x3d8dba(0x142))/0x7+parseInt(_0x3d8dba(0x186))/0x8*(parseInt(_0x3d8dba(0x18f))/0x9);if(_0x78eb0e===_0x5af702)break;else _0x4e9a63['push'](_0x4e9a63['shift']());}catch(_0x211567){_0x4e9a63['push'](_0x4e9a63['shift']());}}}(a0_0x3754,0x832b6));import{EventEmitter as a0_0x43e123}from'events';import{hostname as a0_0x340f9e}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x5803a7,_0xc354cf)=>(_0x5803a7??_0xc354cf)[a0_0x18b3e1(0x159)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x18b3e1(0x14f)](0x0,0xf0);function N(_0x102e39){const _0x35e30d=a0_0x18b3e1;return(_0x102e39 instanceof Error?_0x102e39[_0x35e30d(0x119)]:String(_0x102e39??_0x35e30d(0x174)))[_0x35e30d(0x159)](K,_0x35e30d(0x156))[_0x35e30d(0x159)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x35e30d(0x14f)](0x0,0xf0);}function O(_0x5e7df9,_0x97ba5b=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x158304=a0_0x18b3e1;if(_0x97ba5b)return JSON[_0x158304(0x131)](_0x5e7df9);let _0x2a7c19=L(_0x5e7df9['parent_task_id'],_0x158304(0x128)),_0x5a0a09=L(_0x5e7df9[_0x158304(0x187)],_0x158304(0x12c)),_0x114abe=_0x5e7df9[_0x158304(0x13c)]?_0x158304(0x161)+_0x5e7df9[_0x158304(0x13c)]+':'+(_0x5e7df9['error_message']??''):'';return'[commhub:task]\x20'+_0x5e7df9[_0x158304(0x18a)]+_0x158304(0x11c)+L(_0x5e7df9[_0x158304(0x17f)],_0x158304(0x163))+'\x20to='+L(_0x5e7df9[_0x158304(0x122)],'<unknown>')+_0x158304(0x16a)+_0x5a0a09+'\x20parent_task_id='+_0x2a7c19+_0x158304(0x124)+L(_0x5e7df9[_0x158304(0x176)],_0x158304(0x163))+_0x158304(0x143)+_0x5e7df9['transport']+'\x20duration_ms='+_0x5e7df9[_0x158304(0x14e)]+'\x20lifecycle='+_0x5e7df9[_0x158304(0x153)]+_0x114abe;}function U(_0x4b15e7){const _0x33e6b9=a0_0x18b3e1;return{'event':{'sending':_0x33e6b9(0x130),'delivered':_0x33e6b9(0x125),'failed':_0x33e6b9(0x170),'acked':'task.ack','started':'task.started','replied':_0x33e6b9(0x151),'expired':'task.expired'}[_0x4b15e7[_0x33e6b9(0x18a)]],..._0x4b15e7};}function j(_0x5e61ff){const _0xe043d3=a0_0x18b3e1;let _0x267bbf=_0x5e61ff?.['task_id']||_0x5e61ff?.[_0xe043d3(0x189)]||_0x5e61ff?.['id'];if(_0x267bbf)return String(_0x267bbf);let _0x3347fb=_0x5e61ff?.[_0xe043d3(0x146)]?.[0x0]?.[_0xe043d3(0x18c)];if(typeof _0x3347fb!==_0xe043d3(0x144))return null;try{let _0x4d4a19=JSON[_0xe043d3(0x12b)](_0x3347fb);return _0x4d4a19?.[_0xe043d3(0x187)]||_0x4d4a19?.[_0xe043d3(0x189)]||_0x4d4a19?.['id']||null;}catch{return null;}}async function X(_0x5d9542,_0x4fcd8e){const _0x40dc84=a0_0x18b3e1;let _0x27049e=_0x4fcd8e[_0x40dc84(0x16c)]??Date['now'],_0x2621a9=_0x27049e(),_0x39f2d7=(_0x83f5f8,_0x42b7dd,_0x514b63,_0x359a72)=>{const _0x29dac1=_0x40dc84;_0x4fcd8e[_0x29dac1(0x121)](O(U({'from_alias':_0x5d9542[_0x29dac1(0x126)],'to_alias':_0x5d9542['toAlias'],'task_id':_0x42b7dd,'parent_task_id':_0x5d9542[_0x29dac1(0x150)],'network_id':_0x5d9542[_0x29dac1(0x165)],'transport':_0x5d9542[_0x29dac1(0x12f)],'status':_0x83f5f8,'duration_ms':_0x27049e()-_0x2621a9,'lifecycle_tracking':_0x5d9542[_0x29dac1(0x127)],..._0x514b63!==void 0x0?{'error_code':_0x359a72||_0x29dac1(0x14d),'error_message':N(_0x514b63)}:{}})));};_0x39f2d7(_0x40dc84(0x169),null);try{let _0x17a043=await _0x4fcd8e[_0x40dc84(0x16d)](),_0x3a36e5=j(_0x17a043);if(_0x3a36e5)_0x39f2d7(_0x40dc84(0x178),_0x3a36e5);else{if(_0x17a043?.['ok']===!0x1||_0x17a043?.[_0x40dc84(0x11e)])_0x39f2d7('failed',_0x3a36e5,_0x17a043?.[_0x40dc84(0x11e)]||_0x40dc84(0x13a),'send_rejected');else _0x39f2d7(_0x40dc84(0x17a),null,_0x40dc84(0x15a),_0x40dc84(0x191));}return _0x17a043;}catch(_0xb611c7){throw _0x39f2d7(_0x40dc84(0x17a),null,_0xb611c7,_0x40dc84(0x14d)),_0xb611c7;}}function a0_0x3754(){const _0x499dc0=['from_session','heartbeat\x20failed:\x20','\x20error=','application/json','<unknown>','broadcast','networkId','messages','heartbeatInterval','data:\x20','sending','\x20task_id=','6750dffRZq','now','send','Bearer\x20','inbox\x20error:\x20','task.send.failed','5491818swYJXU','toTimeString','type','unknown\x20error','reply','network_id','s...','delivered','disconnected','failed','308892CscMCU','send_reply','catch','get_inbox','from_alias','startsWith','split','SSE\x20connected','alias','text/event-stream','url','8NBviRF','task_id','sdk','message_id','status','connectSSE','text','idle','SSE\x20reconnecting\x20in\x20','6049737IQzTwT','match','missing_task_id','tools/call','message','heartbeatTimer','autoConnect','\x20from=','not_tracked','error','name','signal','log','to_alias','completed','\x20network_id=','task.send.delivered','fromAlias','lifecycleTracking','<missing>','running','call','parse','<pending>','connected','new_task','transport','task.send.start','stringify','1996lTrLpf','1562121velXnW','sdk-','2.0','AbortError','sseAbort','processInbox','token','CommHub\x20rejected\x20task','disconnect','error_code','normal','426842waMYmq','body','resumeId','min','6949278YbEMTx','\x20transport=','string','agent','content','Authorization','emit','/events/','get_all_status','SSE\x20error:\x20','server','send_failed','duration_ms','slice','parentTaskId','task.replied','/mcp','lifecycle_tracking','sleep','connect','[REDACTED]','reconnectDelay','SSE\x20failed:\x20','replace','CommHub\x20response\x20omitted\x20task_id','toString','ack_inbox','offline',']\x20[commhub:'];a0_0x3754=function(){return _0x499dc0;};return a0_0x3754();}function a0_0x97b3(_0xa9bc94,_0x458ed4){_0xa9bc94=_0xa9bc94-0x118;const _0x3754df=a0_0x3754();let _0x97b3ec=_0x3754df[_0xa9bc94];return _0x97b3ec;}async function Y(_0x2a8317,_0x3312f4){const _0x24afa9=a0_0x18b3e1;return X({'fromAlias':_0x2a8317['fromAlias'],'toAlias':_0x2a8317[_0x24afa9(0x183)],'parentTaskId':_0x2a8317[_0x24afa9(0x150)]||null,'networkId':_0x2a8317[_0x24afa9(0x165)]||null,'transport':'mcp_http','lifecycleTracking':_0x24afa9(0x11d)},_0x3312f4);}class $ extends a0_0x43e123{[a0_0x18b3e1(0x185)];['alias'];['token'];['agent'];[a0_0x18b3e1(0x140)];['heartbeatInterval'];[a0_0x18b3e1(0x157)];[a0_0x18b3e1(0x11a)];[a0_0x18b3e1(0x137)];[a0_0x18b3e1(0x129)]=!0x1;constructor(_0x5abc03){const _0x4bb21a=a0_0x18b3e1;super();if(this[_0x4bb21a(0x185)]=_0x5abc03[_0x4bb21a(0x185)][_0x4bb21a(0x159)](/\/$/,''),this[_0x4bb21a(0x183)]=_0x5abc03['alias'],this['token']=_0x5abc03[_0x4bb21a(0x139)],this[_0x4bb21a(0x145)]=_0x5abc03[_0x4bb21a(0x145)]||_0x4bb21a(0x188),this[_0x4bb21a(0x140)]=_0x4bb21a(0x134)+_0x5abc03[_0x4bb21a(0x183)]+'-'+Date[_0x4bb21a(0x16c)]()[_0x4bb21a(0x15b)](0x24),this[_0x4bb21a(0x167)]=_0x5abc03[_0x4bb21a(0x167)]??0x2bf20,this['reconnectDelay']=_0x5abc03[_0x4bb21a(0x157)]??0xbb8,_0x5abc03[_0x4bb21a(0x11b)]!==!0x1)this[_0x4bb21a(0x155)]();}[a0_0x18b3e1(0x121)](_0x31b65a){const _0x666038=a0_0x18b3e1;console[_0x666038(0x121)]('['+new Date()[_0x666038(0x172)]()['slice'](0x0,0x8)+_0x666038(0x15e)+this[_0x666038(0x183)]+']\x20'+_0x31b65a);}async[a0_0x18b3e1(0x12a)](_0x1dc431,_0x227a4d){const _0x541681=a0_0x18b3e1;let _0x59b9fb={'Content-Type':_0x541681(0x162),'Accept':'application/json,\x20text/event-stream'};if(this[_0x541681(0x139)])_0x59b9fb[_0x541681(0x147)]=_0x541681(0x16e)+this[_0x541681(0x139)];let _0x1a2fdd=await(await fetch(this[_0x541681(0x185)]+_0x541681(0x152),{'method':'POST','headers':_0x59b9fb,'body':JSON['stringify']({'jsonrpc':_0x541681(0x135),'id':Date[_0x541681(0x16c)](),'method':_0x541681(0x118),'params':{'name':_0x1dc431,'arguments':_0x227a4d}})}))[_0x541681(0x18c)](),_0x31bd42=_0x1a2fdd[_0x541681(0x190)](/data: (.+)/),_0x5689ed=_0x31bd42?JSON['parse'](_0x31bd42[0x1]):JSON[_0x541681(0x12b)](_0x1a2fdd),_0x54bc88=_0x5689ed?.['result']?.[_0x541681(0x146)]?.[0x0]?.[_0x541681(0x18c)];return _0x54bc88?JSON[_0x541681(0x12b)](_0x54bc88):_0x5689ed;}async[a0_0x18b3e1(0x155)](){const _0x4abd0c=a0_0x18b3e1;if(this[_0x4abd0c(0x129)])return;this[_0x4abd0c(0x129)]=!0x0,await this[_0x4abd0c(0x18a)](_0x4abd0c(0x18d)),this[_0x4abd0c(0x121)]('registered'),this['heartbeatTimer']=setInterval(()=>{const _0x358895=_0x4abd0c;this[_0x358895(0x18a)](_0x358895(0x18d))[_0x358895(0x17d)](_0x2b9785=>this['log'](_0x358895(0x160)+_0x2b9785[_0x358895(0x119)]));},this[_0x4abd0c(0x167)]),this[_0x4abd0c(0x18b)]();}async[a0_0x18b3e1(0x13b)](){const _0x3741c3=a0_0x18b3e1;if(this['running']=!0x1,this[_0x3741c3(0x137)]?.['abort'](),this[_0x3741c3(0x11a)])clearInterval(this[_0x3741c3(0x11a)]);await this[_0x3741c3(0x18a)](_0x3741c3(0x15d))[_0x3741c3(0x17d)](()=>{}),this['log'](_0x3741c3(0x179));}async[a0_0x18b3e1(0x16d)](_0x50762f,_0x1302ce,_0xeecfad=a0_0x18b3e1(0x13d)){const _0x4c2e63=a0_0x18b3e1;return Y({'alias':_0x50762f,'fromAlias':this[_0x4c2e63(0x183)]},{'log':_0x260698=>console[_0x4c2e63(0x121)](_0x260698),'send':()=>this[_0x4c2e63(0x12a)]('send_task',{'alias':_0x50762f,'task':_0x1302ce,'priority':_0xeecfad,'from_session':this[_0x4c2e63(0x183)]})});}async['message'](_0x26059c,_0x373c2e){const _0x2a7515=a0_0x18b3e1;return this[_0x2a7515(0x12a)]('send_message',{'alias':_0x26059c,'message':_0x373c2e,'from_session':this[_0x2a7515(0x183)]});}async[a0_0x18b3e1(0x175)](_0x1fb31e,_0x33f7d9,_0x29cd31=a0_0x18b3e1(0x123)){const _0x394ab9=a0_0x18b3e1;return this['call'](_0x394ab9(0x17c),{'in_reply_to':_0x1fb31e,'text':_0x33f7d9,'status':_0x29cd31});}async[a0_0x18b3e1(0x18a)](_0x4b934b,_0xb5e01a){const _0x31a6cf=a0_0x18b3e1;return this[_0x31a6cf(0x12a)]('report_status',{'resume_id':this['resumeId'],'alias':this[_0x31a6cf(0x183)],'status':_0x4b934b,'server':a0_0x340f9e(),'hostname':a0_0x340f9e(),'agent':this['agent'],'project_dir':process['cwd'](),..._0xb5e01a});}async['getAllStatus'](){const _0x24fe02=a0_0x18b3e1;return this[_0x24fe02(0x12a)](_0x24fe02(0x14a),{});}async['broadcast'](_0x44cb34,_0x52a9cd){const _0x14e550=a0_0x18b3e1;return this[_0x14e550(0x12a)]('broadcast',{'message':_0x44cb34,'filter_server':_0x52a9cd?.[_0x14e550(0x14c)],'filter_status':_0x52a9cd?.['status']});}async[a0_0x18b3e1(0x18b)](){const _0x26c09c=a0_0x18b3e1;let _0x54a456=encodeURIComponent(this[_0x26c09c(0x183)]),_0x5488e5=this['url']+_0x26c09c(0x149)+_0x54a456,_0x280f29=this[_0x26c09c(0x157)];while(this[_0x26c09c(0x129)]){try{this['sseAbort']=new AbortController();let _0x58b3a7={'Accept':_0x26c09c(0x184)};if(this[_0x26c09c(0x139)])_0x58b3a7['Authorization']=_0x26c09c(0x16e)+this['token'];let _0xaca17b=await fetch(_0x5488e5,{'headers':_0x58b3a7,'signal':this['sseAbort'][_0x26c09c(0x120)]});if(!_0xaca17b['ok']||!_0xaca17b[_0x26c09c(0x13f)]){this[_0x26c09c(0x121)](_0x26c09c(0x158)+_0xaca17b[_0x26c09c(0x18a)]),await this[_0x26c09c(0x154)](_0x280f29),_0x280f29=Math['min'](_0x280f29*1.5,0xea60);continue;}_0x280f29=this[_0x26c09c(0x157)];let _0x268fa2=_0xaca17b[_0x26c09c(0x13f)]['getReader'](),_0x3c58fd=new TextDecoder(),_0x415cfc='';while(this[_0x26c09c(0x129)]){let {done:_0x2f0037,value:_0x23f319}=await _0x268fa2['read']();if(_0x2f0037)break;_0x415cfc+=_0x3c58fd['decode'](_0x23f319,{'stream':!0x0});let _0x2d76f2=_0x415cfc[_0x26c09c(0x181)]('\x0a');_0x415cfc=_0x2d76f2['pop']()||'';for(let _0x187808 of _0x2d76f2){if(!_0x187808[_0x26c09c(0x180)](_0x26c09c(0x168)))continue;try{let _0x4796df=JSON[_0x26c09c(0x12b)](_0x187808[_0x26c09c(0x14f)](0x6));if(_0x4796df[_0x26c09c(0x173)]===_0x26c09c(0x12d)){this['log'](_0x26c09c(0x182)),this[_0x26c09c(0x148)]('connected');continue;}if(_0x4796df[_0x26c09c(0x173)]===_0x26c09c(0x12e)||_0x4796df[_0x26c09c(0x173)]==='new_message'||_0x4796df[_0x26c09c(0x173)]===_0x26c09c(0x164))await this[_0x26c09c(0x138)]();}catch{}}}}catch(_0x3645ef){if(_0x3645ef[_0x26c09c(0x11f)]===_0x26c09c(0x136))break;this[_0x26c09c(0x148)](_0x26c09c(0x11e),_0x3645ef),this['log'](_0x26c09c(0x14b)+_0x3645ef[_0x26c09c(0x119)]);}if(this['running'])this[_0x26c09c(0x148)](_0x26c09c(0x179)),this[_0x26c09c(0x121)](_0x26c09c(0x18e)+_0x280f29/0x3e8+_0x26c09c(0x177)),await this[_0x26c09c(0x154)](_0x280f29),_0x280f29=Math[_0x26c09c(0x141)](_0x280f29*1.5,0xea60);}}async[a0_0x18b3e1(0x138)](){const _0x4753c0=a0_0x18b3e1;try{let _0x352155=(await this[_0x4753c0(0x12a)](_0x4753c0(0x17e),{'alias':this[_0x4753c0(0x183)],'limit':0xa}))?.[_0x4753c0(0x166)]||[];for(let _0x13e01b of _0x352155)await this[_0x4753c0(0x12a)](_0x4753c0(0x15c),{'alias':this[_0x4753c0(0x183)],'message_id':_0x13e01b['id']}),this['log']('←\x20'+_0x13e01b[_0x4753c0(0x15f)]+':\x20'+_0x13e01b['content'][_0x4753c0(0x14f)](0x0,0x3c)),this['emit']('task',_0x13e01b),this[_0x4753c0(0x148)](_0x4753c0(0x119),_0x13e01b);}catch(_0x65be8d){this[_0x4753c0(0x121)](_0x4753c0(0x16f)+_0x65be8d[_0x4753c0(0x119)]);}}[a0_0x18b3e1(0x154)](_0x3950ff){return new Promise(_0x4f2d72=>setTimeout(_0x4f2d72,_0x3950ff));}}var F=$;export{F as default,$ as CommHub};
|
|
1
|
+
const a0_0x1c3100=a0_0x1a14;function a0_0x1a14(_0x347c32,_0x409e79){_0x347c32=_0x347c32-0xc1;const _0x578955=a0_0x5789();let _0x1a1436=_0x578955[_0x347c32];return _0x1a1436;}(function(_0x4c8e03,_0x36e943){const _0x49f872=a0_0x1a14,_0x552763=_0x4c8e03();while(!![]){try{const _0x3a242c=parseInt(_0x49f872(0xf3))/0x1+-parseInt(_0x49f872(0xc3))/0x2+parseInt(_0x49f872(0xd0))/0x3+parseInt(_0x49f872(0x12d))/0x4*(parseInt(_0x49f872(0xd9))/0x5)+parseInt(_0x49f872(0x130))/0x6+parseInt(_0x49f872(0xe8))/0x7+-parseInt(_0x49f872(0xeb))/0x8;if(_0x3a242c===_0x36e943)break;else _0x552763['push'](_0x552763['shift']());}catch(_0x2a314c){_0x552763['push'](_0x552763['shift']());}}}(a0_0x5789,0x34d6e));import{EventEmitter as a0_0x331c85}from'events';import{hostname as a0_0x177dc3}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x141e25,_0x4a04a8)=>(_0x141e25??_0x4a04a8)[a0_0x1c3100(0xc9)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x1c3100(0x11f)](0x0,0xf0);function a0_0x5789(){const _0x4858d4=['/mcp','broadcast','<missing>','processInbox','Authorization','now','sleep','normal','completed','offline','task_id','heartbeatInterval','disconnect','catch','status','lifecycle_tracking','from_session','networkId','application/json','CommHub\x20rejected\x20task','slice','from_alias','fromAlias','failed','\x20from=','task.expired','pop','\x20network_id=','startsWith','to_alias','token','message','connectSSE','mcp_http','1468eKLHSW','send','inbox\x20error:\x20','2547768mnlpcM','send_task','task.send.failed','parent_task_id','connect','message_id','split','send_message','lifecycleTracking','match','AbortError','content','sending','2.0','text','error','\x20task_id=','sseAbort','task.send.start','Bearer\x20','<unknown>','\x20error=','delivered','body','576532qRRDyW','sdk','\x20transport=','duration_ms','tools/call','sdk-','replace','data:\x20','error_message','toAlias','network_id','heartbeatTimer','stringify','463947ZhJdeU','json','not_tracked','url','[REDACTED]','application/json,\x20text/event-stream','getReader','error_code','get_all_status','625gZiRNN','alias','read','parentTaskId','\x20to=','call','cwd','registered','task.send.delivered','parse','result',']\x20[commhub:','get_inbox','transport','SSE\x20failed:\x20','1843807cjsabx','POST','send_rejected','3475312hmBKvE','<pending>','report_status','connected','idle','disconnected','\x20parent_task_id=','name','50557VIRehd','s...','reconnectDelay','task','emit','messages','[commhub:task]\x20','signal','SSE\x20connected','resumeId','\x20duration_ms=','agent','reply','type','new_task','toString','log','server','send_reply','task.ack','running','decode','\x20lifecycle=','min'];a0_0x5789=function(){return _0x4858d4;};return a0_0x5789();}function N(_0x20e78f){const _0x4780a9=a0_0x1c3100;return(_0x20e78f instanceof Error?_0x20e78f[_0x4780a9(0x12a)]:String(_0x20e78f??'unknown\x20error'))[_0x4780a9(0xc9)](K,_0x4780a9(0xd4))[_0x4780a9(0xc9)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x4780a9(0x11f)](0x0,0xf0);}function O(_0x589f3a,_0x398f69=process.env.ANET_TASK_TRACE_FORMAT===a0_0x1c3100(0xd1)){const _0x3f8f88=a0_0x1c3100;if(_0x398f69)return JSON[_0x3f8f88(0xcf)](_0x589f3a);let _0xc975c0=L(_0x589f3a[_0x3f8f88(0x133)],_0x3f8f88(0x10d)),_0x4cbbbd=L(_0x589f3a[_0x3f8f88(0x115)],_0x3f8f88(0xec)),_0x322b5e=_0x589f3a[_0x3f8f88(0xd7)]?_0x3f8f88(0x145)+_0x589f3a['error_code']+':'+(_0x589f3a[_0x3f8f88(0xcb)]??''):'';return _0x3f8f88(0xf9)+_0x589f3a[_0x3f8f88(0x119)]+_0x3f8f88(0x123)+L(_0x589f3a[_0x3f8f88(0x120)],_0x3f8f88(0x144))+_0x3f8f88(0xdd)+L(_0x589f3a[_0x3f8f88(0x128)],_0x3f8f88(0x144))+_0x3f8f88(0x140)+_0x4cbbbd+_0x3f8f88(0xf1)+_0xc975c0+_0x3f8f88(0x126)+L(_0x589f3a[_0x3f8f88(0xcd)],_0x3f8f88(0x144))+_0x3f8f88(0xc5)+_0x589f3a[_0x3f8f88(0xe6)]+_0x3f8f88(0xfd)+_0x589f3a[_0x3f8f88(0xc6)]+_0x3f8f88(0x109)+_0x589f3a[_0x3f8f88(0x11a)]+_0x322b5e;}function U(_0x3677ed){const _0x5f4572=a0_0x1c3100;return{'event':{'sending':_0x5f4572(0x142),'delivered':_0x5f4572(0xe1),'failed':_0x5f4572(0x132),'acked':_0x5f4572(0x106),'started':'task.started','replied':'task.replied','expired':_0x5f4572(0x124)}[_0x3677ed['status']],..._0x3677ed};}function j(_0xfa14ec){const _0x83577d=a0_0x1c3100;let _0xf8ddf9=_0xfa14ec?.[_0x83577d(0x115)]||_0xfa14ec?.[_0x83577d(0x135)]||_0xfa14ec?.['id'];if(_0xf8ddf9)return String(_0xf8ddf9);let _0xaaec54=_0xfa14ec?.[_0x83577d(0x13b)]?.[0x0]?.[_0x83577d(0x13e)];if(typeof _0xaaec54!=='string')return null;try{let _0x117eb0=JSON['parse'](_0xaaec54);return _0x117eb0?.[_0x83577d(0x115)]||_0x117eb0?.[_0x83577d(0x135)]||_0x117eb0?.['id']||null;}catch{return null;}}async function X(_0x1e0063,_0x4691ed){const _0x2d9e86=a0_0x1c3100;let _0x504b50=_0x4691ed[_0x2d9e86(0x110)]??Date[_0x2d9e86(0x110)],_0x243495=_0x504b50(),_0xdf4216=(_0x34851c,_0x198ae1,_0x59a618,_0x73887d)=>{const _0x12a88d=_0x2d9e86;_0x4691ed['log'](O(U({'from_alias':_0x1e0063[_0x12a88d(0x121)],'to_alias':_0x1e0063[_0x12a88d(0xcc)],'task_id':_0x198ae1,'parent_task_id':_0x1e0063['parentTaskId'],'network_id':_0x1e0063['networkId'],'transport':_0x1e0063[_0x12a88d(0xe6)],'status':_0x34851c,'duration_ms':_0x504b50()-_0x243495,'lifecycle_tracking':_0x1e0063[_0x12a88d(0x138)],..._0x59a618!==void 0x0?{'error_code':_0x73887d||'send_failed','error_message':N(_0x59a618)}:{}})));};_0xdf4216(_0x2d9e86(0x13c),null);try{let _0x50f071=await _0x4691ed[_0x2d9e86(0x12e)](),_0x108eb4=j(_0x50f071);if(_0x108eb4)_0xdf4216(_0x2d9e86(0xc1),_0x108eb4);else{if(_0x50f071?.['ok']===!0x1||_0x50f071?.[_0x2d9e86(0x13f)])_0xdf4216(_0x2d9e86(0x122),_0x108eb4,_0x50f071?.[_0x2d9e86(0x13f)]||_0x2d9e86(0x11e),_0x2d9e86(0xea));else _0xdf4216('failed',null,'CommHub\x20response\x20omitted\x20task_id','missing_task_id');}return _0x50f071;}catch(_0x3a11d0){throw _0xdf4216(_0x2d9e86(0x122),null,_0x3a11d0,'send_failed'),_0x3a11d0;}}async function Y(_0x7b07b5,_0x21af6e){const _0x3ceadf=a0_0x1c3100;return X({'fromAlias':_0x7b07b5['fromAlias'],'toAlias':_0x7b07b5['alias'],'parentTaskId':_0x7b07b5[_0x3ceadf(0xdc)]||null,'networkId':_0x7b07b5[_0x3ceadf(0x11c)]||null,'transport':_0x3ceadf(0x12c),'lifecycleTracking':_0x3ceadf(0xd2)},_0x21af6e);}class $ extends a0_0x331c85{['url'];[a0_0x1c3100(0xda)];[a0_0x1c3100(0x129)];['agent'];[a0_0x1c3100(0xfc)];['heartbeatInterval'];['reconnectDelay'];[a0_0x1c3100(0xce)];[a0_0x1c3100(0x141)];[a0_0x1c3100(0x107)]=!0x1;constructor(_0x209b2f){const _0x14a580=a0_0x1c3100;super();if(this[_0x14a580(0xd3)]=_0x209b2f['url'][_0x14a580(0xc9)](/\/$/,''),this[_0x14a580(0xda)]=_0x209b2f[_0x14a580(0xda)],this[_0x14a580(0x129)]=_0x209b2f[_0x14a580(0x129)],this[_0x14a580(0xfe)]=_0x209b2f[_0x14a580(0xfe)]||_0x14a580(0xc4),this[_0x14a580(0xfc)]=_0x14a580(0xc8)+_0x209b2f[_0x14a580(0xda)]+'-'+Date[_0x14a580(0x110)]()[_0x14a580(0x102)](0x24),this['heartbeatInterval']=_0x209b2f[_0x14a580(0x116)]??0x2bf20,this['reconnectDelay']=_0x209b2f[_0x14a580(0xf5)]??0xbb8,_0x209b2f['autoConnect']!==!0x1)this[_0x14a580(0x134)]();}[a0_0x1c3100(0x103)](_0x52432a){const _0x223596=a0_0x1c3100;console[_0x223596(0x103)]('['+new Date()['toTimeString']()['slice'](0x0,0x8)+_0x223596(0xe4)+this[_0x223596(0xda)]+']\x20'+_0x52432a);}async['call'](_0xea36db,_0x409a65){const _0x2325a0=a0_0x1c3100;let _0x48060b={'Content-Type':_0x2325a0(0x11d),'Accept':_0x2325a0(0xd5)};if(this['token'])_0x48060b[_0x2325a0(0x10f)]=_0x2325a0(0x143)+this[_0x2325a0(0x129)];let _0x5ed30c=await(await fetch(this[_0x2325a0(0xd3)]+_0x2325a0(0x10b),{'method':_0x2325a0(0xe9),'headers':_0x48060b,'body':JSON[_0x2325a0(0xcf)]({'jsonrpc':_0x2325a0(0x13d),'id':Date[_0x2325a0(0x110)](),'method':_0x2325a0(0xc7),'params':{'name':_0xea36db,'arguments':_0x409a65}})}))[_0x2325a0(0x13e)](),_0x355ff6=_0x5ed30c[_0x2325a0(0x139)](/data: (.+)/),_0x231949=_0x355ff6?JSON['parse'](_0x355ff6[0x1]):JSON[_0x2325a0(0xe2)](_0x5ed30c),_0x1c42da=_0x231949?.[_0x2325a0(0xe3)]?.[_0x2325a0(0x13b)]?.[0x0]?.[_0x2325a0(0x13e)];return _0x1c42da?JSON[_0x2325a0(0xe2)](_0x1c42da):_0x231949;}async['connect'](){const _0x4c0f2b=a0_0x1c3100;if(this[_0x4c0f2b(0x107)])return;this[_0x4c0f2b(0x107)]=!0x0,await this[_0x4c0f2b(0x119)](_0x4c0f2b(0xef)),this[_0x4c0f2b(0x103)](_0x4c0f2b(0xe0)),this[_0x4c0f2b(0xce)]=setInterval(()=>{const _0x4489c2=_0x4c0f2b;this[_0x4489c2(0x119)](_0x4489c2(0xef))[_0x4489c2(0x118)](_0x54c48c=>this[_0x4489c2(0x103)]('heartbeat\x20failed:\x20'+_0x54c48c[_0x4489c2(0x12a)]));},this[_0x4c0f2b(0x116)]),this[_0x4c0f2b(0x12b)]();}async[a0_0x1c3100(0x117)](){const _0x301ffb=a0_0x1c3100;if(this['running']=!0x1,this[_0x301ffb(0x141)]?.['abort'](),this[_0x301ffb(0xce)])clearInterval(this[_0x301ffb(0xce)]);await this['status'](_0x301ffb(0x114))[_0x301ffb(0x118)](()=>{}),this['log']('disconnected');}async[a0_0x1c3100(0x12e)](_0x4539c3,_0xc64934,_0x1f4971=a0_0x1c3100(0x112)){const _0x3549f6=a0_0x1c3100;return Y({'alias':_0x4539c3,'fromAlias':this['alias']},{'log':_0x1615b2=>console[_0x3549f6(0x103)](_0x1615b2),'send':()=>this[_0x3549f6(0xde)](_0x3549f6(0x131),{'alias':_0x4539c3,'task':_0xc64934,'priority':_0x1f4971,'from_session':this['alias']})});}async[a0_0x1c3100(0x12a)](_0x411ea9,_0x2afdc8){const _0x1ebac3=a0_0x1c3100;return this[_0x1ebac3(0xde)](_0x1ebac3(0x137),{'alias':_0x411ea9,'message':_0x2afdc8,'from_session':this[_0x1ebac3(0xda)]});}async[a0_0x1c3100(0xff)](_0x119a94,_0x2d0d90,_0x221863=a0_0x1c3100(0x113)){const _0x13b8a9=a0_0x1c3100;return this['call'](_0x13b8a9(0x105),{'in_reply_to':_0x119a94,'text':_0x2d0d90,'status':_0x221863});}async[a0_0x1c3100(0x119)](_0x4c6cce,_0x1c0a29){const _0x29b8b7=a0_0x1c3100;return this[_0x29b8b7(0xde)](_0x29b8b7(0xed),{'resume_id':this[_0x29b8b7(0xfc)],'alias':this[_0x29b8b7(0xda)],'status':_0x4c6cce,'server':a0_0x177dc3(),'hostname':a0_0x177dc3(),'agent':this[_0x29b8b7(0xfe)],'project_dir':process[_0x29b8b7(0xdf)](),..._0x1c0a29});}async['getAllStatus'](){const _0x14553f=a0_0x1c3100;return this[_0x14553f(0xde)](_0x14553f(0xd8),{});}async[a0_0x1c3100(0x10c)](_0x265e96,_0x2f7fd2){const _0x8079b0=a0_0x1c3100;return this[_0x8079b0(0xde)]('broadcast',{'message':_0x265e96,'filter_server':_0x2f7fd2?.[_0x8079b0(0x104)],'filter_status':_0x2f7fd2?.[_0x8079b0(0x119)]});}async[a0_0x1c3100(0x12b)](){const _0x483b22=a0_0x1c3100;let _0x479980=encodeURIComponent(this[_0x483b22(0xda)]),_0x28f68e=this[_0x483b22(0xd3)]+'/events/'+_0x479980,_0x5c4d70=this['reconnectDelay'];while(this[_0x483b22(0x107)]){try{this[_0x483b22(0x141)]=new AbortController();let _0x3a1362={'Accept':'text/event-stream'};if(this[_0x483b22(0x129)])_0x3a1362[_0x483b22(0x10f)]=_0x483b22(0x143)+this[_0x483b22(0x129)];let _0x1f8809=await fetch(_0x28f68e,{'headers':_0x3a1362,'signal':this[_0x483b22(0x141)][_0x483b22(0xfa)]});if(!_0x1f8809['ok']||!_0x1f8809[_0x483b22(0xc2)]){this[_0x483b22(0x103)](_0x483b22(0xe7)+_0x1f8809[_0x483b22(0x119)]),await this[_0x483b22(0x111)](_0x5c4d70),_0x5c4d70=Math[_0x483b22(0x10a)](_0x5c4d70*1.5,0xea60);continue;}_0x5c4d70=this['reconnectDelay'];let _0xb333cf=_0x1f8809[_0x483b22(0xc2)][_0x483b22(0xd6)](),_0x28faba=new TextDecoder(),_0x32072b='';while(this[_0x483b22(0x107)]){let {done:_0x20141a,value:_0x26bd4f}=await _0xb333cf[_0x483b22(0xdb)]();if(_0x20141a)break;_0x32072b+=_0x28faba[_0x483b22(0x108)](_0x26bd4f,{'stream':!0x0});let _0x2b47c6=_0x32072b[_0x483b22(0x136)]('\x0a');_0x32072b=_0x2b47c6[_0x483b22(0x125)]()||'';for(let _0x202cb0 of _0x2b47c6){if(!_0x202cb0[_0x483b22(0x127)](_0x483b22(0xca)))continue;try{let _0x31ebb8=JSON[_0x483b22(0xe2)](_0x202cb0['slice'](0x6));if(_0x31ebb8[_0x483b22(0x100)]===_0x483b22(0xee)){this[_0x483b22(0x103)](_0x483b22(0xfb)),this[_0x483b22(0xf7)](_0x483b22(0xee));continue;}if(_0x31ebb8[_0x483b22(0x100)]===_0x483b22(0x101)||_0x31ebb8['type']==='new_message'||_0x31ebb8[_0x483b22(0x100)]==='broadcast')await this[_0x483b22(0x10e)]();}catch{}}}}catch(_0x42a17e){if(_0x42a17e[_0x483b22(0xf2)]===_0x483b22(0x13a))break;this[_0x483b22(0xf7)]('error',_0x42a17e),this[_0x483b22(0x103)]('SSE\x20error:\x20'+_0x42a17e[_0x483b22(0x12a)]);}if(this[_0x483b22(0x107)])this[_0x483b22(0xf7)](_0x483b22(0xf0)),this[_0x483b22(0x103)]('SSE\x20reconnecting\x20in\x20'+_0x5c4d70/0x3e8+_0x483b22(0xf4)),await this[_0x483b22(0x111)](_0x5c4d70),_0x5c4d70=Math['min'](_0x5c4d70*1.5,0xea60);}}async[a0_0x1c3100(0x10e)](){const _0x1b70e2=a0_0x1c3100;try{let _0x4725bf=(await this[_0x1b70e2(0xde)](_0x1b70e2(0xe5),{'alias':this[_0x1b70e2(0xda)],'limit':0xa}))?.[_0x1b70e2(0xf8)]||[];for(let _0x4e55bc of _0x4725bf)await this[_0x1b70e2(0xde)]('ack_inbox',{'alias':this['alias'],'message_id':_0x4e55bc['id']}),this[_0x1b70e2(0x103)]('←\x20'+_0x4e55bc[_0x1b70e2(0x11b)]+':\x20'+_0x4e55bc[_0x1b70e2(0x13b)][_0x1b70e2(0x11f)](0x0,0x3c)),this[_0x1b70e2(0xf7)](_0x1b70e2(0xf6),_0x4e55bc),this['emit'](_0x1b70e2(0x12a),_0x4e55bc);}catch(_0x290cfe){this[_0x1b70e2(0x103)](_0x1b70e2(0x12f)+_0x290cfe[_0x1b70e2(0x12a)]);}}[a0_0x1c3100(0x111)](_0x5056b6){return new Promise(_0x515b4a=>setTimeout(_0x515b4a,_0x5056b6));}}var F=$;export{F as default,$ as CommHub};
|