@sleep2agi/agent-network 2.3.0-preview.176 → 2.3.0-preview.177
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_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};
|
|
1
|
+
const a0_0x44e94b=a0_0x4a4a;(function(_0x701d4e,_0x2dee80){const _0x2c711c=a0_0x4a4a,_0x2e47e7=_0x701d4e();while(!![]){try{const _0x3578c5=parseInt(_0x2c711c(0x125))/0x1*(parseInt(_0x2c711c(0x155))/0x2)+parseInt(_0x2c711c(0x11e))/0x3*(-parseInt(_0x2c711c(0x180))/0x4)+-parseInt(_0x2c711c(0x117))/0x5+-parseInt(_0x2c711c(0x131))/0x6+-parseInt(_0x2c711c(0x162))/0x7*(parseInt(_0x2c711c(0x113))/0x8)+-parseInt(_0x2c711c(0x179))/0x9*(parseInt(_0x2c711c(0x173))/0xa)+-parseInt(_0x2c711c(0x107))/0xb*(-parseInt(_0x2c711c(0x112))/0xc);if(_0x3578c5===_0x2dee80)break;else _0x2e47e7['push'](_0x2e47e7['shift']());}catch(_0x232445){_0x2e47e7['push'](_0x2e47e7['shift']());}}}(a0_0x4cd0,0xbbc1c));function a0_0x4a4a(_0x253da5,_0x2dea79){_0x253da5=_0x253da5-0x100;const _0x4cd036=a0_0x4cd0();let _0x4a4a38=_0x4cd036[_0x253da5];return _0x4a4a38;}import{EventEmitter as a0_0x408525}from'events';import{hostname as a0_0x29ead4}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x1458c5,_0x14bf76)=>(_0x1458c5??_0x14bf76)[a0_0x44e94b(0x166)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x1f135){const _0x287361=a0_0x44e94b;return(_0x1f135 instanceof Error?_0x1f135['message']:String(_0x1f135??_0x287361(0x14c)))[_0x287361(0x166)](K,_0x287361(0x163))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x287361(0x14a)](0x0,0xf0);}function O(_0x534f49,_0xcee4c=process.env.ANET_TASK_TRACE_FORMAT===a0_0x44e94b(0x11b)){const _0x2bf5fe=a0_0x44e94b;if(_0xcee4c)return JSON[_0x2bf5fe(0x10c)](_0x534f49);let _0x445617=L(_0x534f49['parent_task_id'],_0x2bf5fe(0x11a)),_0x276150=L(_0x534f49['task_id'],'<pending>'),_0x21af82=_0x534f49['error_code']?_0x2bf5fe(0x16b)+_0x534f49[_0x2bf5fe(0x15a)]+':'+(_0x534f49[_0x2bf5fe(0x14f)]??''):'';return _0x2bf5fe(0x103)+_0x534f49['status']+_0x2bf5fe(0x138)+L(_0x534f49[_0x2bf5fe(0x143)],_0x2bf5fe(0x15e))+_0x2bf5fe(0x16e)+L(_0x534f49[_0x2bf5fe(0x11d)],'<unknown>')+_0x2bf5fe(0x128)+_0x276150+'\x20parent_task_id='+_0x445617+_0x2bf5fe(0x114)+L(_0x534f49[_0x2bf5fe(0x168)],_0x2bf5fe(0x15e))+_0x2bf5fe(0x104)+_0x534f49['transport']+'\x20duration_ms='+_0x534f49[_0x2bf5fe(0x16a)]+_0x2bf5fe(0x11f)+_0x534f49[_0x2bf5fe(0x176)]+_0x21af82;}function a0_0x4cd0(){const _0x24c87d=['Authorization','send','send_message','4311042fQQLpT','task_id','result','resumeId','CommHub\x20response\x20omitted\x20task_id','alias','s...','\x20from=','normal','task.started','error','parse','broadcast','task.send.start','/mcp','message_id','sdk-','tools/call','from_alias','get_inbox','delivered','abort','processInbox','application/json','toString','slice','now','unknown\x20error','connected','fromAlias','error_message','send_rejected','task','call','sleep','token','1113106RcySTl','heartbeatTimer','completed','catch','text','error_code','mcp_http','content','POST','<unknown>','SSE\x20error:\x20','url','application/json,\x20text/event-stream','10325KJlbCZ','[REDACTED]','getAllStatus','startsWith','replace','AbortError','network_id','2.0','duration_ms','\x20error=','running','body','\x20to=','not_tracked','log','ack_inbox','signal','10kUWsnz','agent','min','lifecycle_tracking','SSE\x20failed:\x20','SSE\x20connected','1996587cUkFuT','Bearer\x20','reconnectDelay','task.ack','failed','idle','toAlias','1415752cIkriJ','messages','data:\x20','emit','send_failed','[commhub:task]\x20','\x20transport=','inbox\x20error:\x20','type','19213337hleVdC','connectSSE','sending','disconnected','transport','stringify','send_task','heartbeatInterval','split','connect','status','12XYfTep','952YHTlXV','\x20network_id=','read','name','321775JzYZRW','task.send.delivered','pop','<missing>','json',']\x20[commhub:','to_alias','3fatXzE','\x20lifecycle=','/events/','new_task','CommHub\x20rejected\x20task','task.expired','message','1BytpEG','missing_task_id','heartbeat\x20failed:\x20','\x20task_id=','parentTaskId','string','task.replied','SSE\x20reconnecting\x20in\x20','sseAbort'];a0_0x4cd0=function(){return _0x24c87d;};return a0_0x4cd0();}function U(_0x59e58e){const _0x188bf0=a0_0x44e94b;return{'event':{'sending':_0x188bf0(0x13e),'delivered':_0x188bf0(0x118),'failed':'task.send.failed','acked':_0x188bf0(0x17c),'started':_0x188bf0(0x13a),'replied':_0x188bf0(0x12b),'expired':_0x188bf0(0x123)}[_0x59e58e[_0x188bf0(0x111)]],..._0x59e58e};}function j(_0x37567f){const _0x2d54ed=a0_0x44e94b;let _0x5f286c=_0x37567f?.[_0x2d54ed(0x132)]||_0x37567f?.[_0x2d54ed(0x140)]||_0x37567f?.['id'];if(_0x5f286c)return String(_0x5f286c);let _0x9d4a81=_0x37567f?.['content']?.[0x0]?.['text'];if(typeof _0x9d4a81!==_0x2d54ed(0x12a))return null;try{let _0x13d694=JSON[_0x2d54ed(0x13c)](_0x9d4a81);return _0x13d694?.[_0x2d54ed(0x132)]||_0x13d694?.[_0x2d54ed(0x140)]||_0x13d694?.['id']||null;}catch{return null;}}async function X(_0x13bcb4,_0x4ca609){const _0xa05b60=a0_0x44e94b;let _0x195904=_0x4ca609[_0xa05b60(0x14b)]??Date[_0xa05b60(0x14b)],_0x13f3e5=_0x195904(),_0x1b39fb=(_0x1f3c77,_0x53799c,_0x3c0c07,_0x1e1fee)=>{const _0x1248c6=_0xa05b60;_0x4ca609[_0x1248c6(0x170)](O(U({'from_alias':_0x13bcb4['fromAlias'],'to_alias':_0x13bcb4[_0x1248c6(0x17f)],'task_id':_0x53799c,'parent_task_id':_0x13bcb4['parentTaskId'],'network_id':_0x13bcb4['networkId'],'transport':_0x13bcb4[_0x1248c6(0x10b)],'status':_0x1f3c77,'duration_ms':_0x195904()-_0x13f3e5,'lifecycle_tracking':_0x13bcb4['lifecycleTracking'],..._0x3c0c07!==void 0x0?{'error_code':_0x1e1fee||_0x1248c6(0x102),'error_message':N(_0x3c0c07)}:{}})));};_0x1b39fb(_0xa05b60(0x109),null);try{let _0x5b377e=await _0x4ca609['send'](),_0x845db1=j(_0x5b377e);if(_0x845db1)_0x1b39fb(_0xa05b60(0x145),_0x845db1);else{if(_0x5b377e?.['ok']===!0x1||_0x5b377e?.[_0xa05b60(0x13b)])_0x1b39fb(_0xa05b60(0x17d),_0x845db1,_0x5b377e?.[_0xa05b60(0x13b)]||_0xa05b60(0x122),_0xa05b60(0x150));else _0x1b39fb(_0xa05b60(0x17d),null,_0xa05b60(0x135),_0xa05b60(0x126));}return _0x5b377e;}catch(_0xc79916){throw _0x1b39fb(_0xa05b60(0x17d),null,_0xc79916,_0xa05b60(0x102)),_0xc79916;}}async function Y(_0x2fe686,_0x2ad555){const _0xf1bf89=a0_0x44e94b;return X({'fromAlias':_0x2fe686[_0xf1bf89(0x14e)],'toAlias':_0x2fe686['alias'],'parentTaskId':_0x2fe686[_0xf1bf89(0x129)]||null,'networkId':_0x2fe686['networkId']||null,'transport':_0xf1bf89(0x15b),'lifecycleTracking':_0xf1bf89(0x16f)},_0x2ad555);}class $ extends a0_0x408525{['url'];[a0_0x44e94b(0x136)];[a0_0x44e94b(0x154)];[a0_0x44e94b(0x174)];[a0_0x44e94b(0x134)];[a0_0x44e94b(0x10e)];[a0_0x44e94b(0x17b)];[a0_0x44e94b(0x156)];[a0_0x44e94b(0x12d)];[a0_0x44e94b(0x16c)]=!0x1;constructor(_0x1fe568){const _0x1d08f5=a0_0x44e94b;super();if(this[_0x1d08f5(0x160)]=_0x1fe568[_0x1d08f5(0x160)][_0x1d08f5(0x166)](/\/$/,''),this[_0x1d08f5(0x136)]=_0x1fe568[_0x1d08f5(0x136)],this[_0x1d08f5(0x154)]=_0x1fe568[_0x1d08f5(0x154)],this[_0x1d08f5(0x174)]=_0x1fe568['agent']||'sdk',this['resumeId']=_0x1d08f5(0x141)+_0x1fe568[_0x1d08f5(0x136)]+'-'+Date[_0x1d08f5(0x14b)]()[_0x1d08f5(0x149)](0x24),this[_0x1d08f5(0x10e)]=_0x1fe568[_0x1d08f5(0x10e)]??0x2bf20,this[_0x1d08f5(0x17b)]=_0x1fe568['reconnectDelay']??0xbb8,_0x1fe568['autoConnect']!==!0x1)this['connect']();}[a0_0x44e94b(0x170)](_0xaf9588){const _0x182d09=a0_0x44e94b;console[_0x182d09(0x170)]('['+new Date()['toTimeString']()[_0x182d09(0x14a)](0x0,0x8)+_0x182d09(0x11c)+this['alias']+']\x20'+_0xaf9588);}async[a0_0x44e94b(0x152)](_0x350111,_0x467b35){const _0x36157b=a0_0x44e94b;let _0x351e70={'Content-Type':_0x36157b(0x148),'Accept':_0x36157b(0x161)};if(this[_0x36157b(0x154)])_0x351e70['Authorization']=_0x36157b(0x17a)+this[_0x36157b(0x154)];let _0x12d24e=await(await fetch(this[_0x36157b(0x160)]+_0x36157b(0x13f),{'method':_0x36157b(0x15d),'headers':_0x351e70,'body':JSON['stringify']({'jsonrpc':_0x36157b(0x169),'id':Date[_0x36157b(0x14b)](),'method':_0x36157b(0x142),'params':{'name':_0x350111,'arguments':_0x467b35}})}))[_0x36157b(0x159)](),_0x42ae0a=_0x12d24e['match'](/data: (.+)/),_0x76f3b6=_0x42ae0a?JSON[_0x36157b(0x13c)](_0x42ae0a[0x1]):JSON[_0x36157b(0x13c)](_0x12d24e),_0x237b22=_0x76f3b6?.[_0x36157b(0x133)]?.[_0x36157b(0x15c)]?.[0x0]?.[_0x36157b(0x159)];return _0x237b22?JSON[_0x36157b(0x13c)](_0x237b22):_0x76f3b6;}async[a0_0x44e94b(0x110)](){const _0x45e8f9=a0_0x44e94b;if(this[_0x45e8f9(0x16c)])return;this['running']=!0x0,await this[_0x45e8f9(0x111)](_0x45e8f9(0x17e)),this['log']('registered'),this[_0x45e8f9(0x156)]=setInterval(()=>{const _0x514594=_0x45e8f9;this[_0x514594(0x111)]('idle')[_0x514594(0x158)](_0x2f4df3=>this['log'](_0x514594(0x127)+_0x2f4df3[_0x514594(0x124)]));},this['heartbeatInterval']),this[_0x45e8f9(0x108)]();}async['disconnect'](){const _0x4fd0e5=a0_0x44e94b;if(this[_0x4fd0e5(0x16c)]=!0x1,this['sseAbort']?.[_0x4fd0e5(0x146)](),this['heartbeatTimer'])clearInterval(this[_0x4fd0e5(0x156)]);await this[_0x4fd0e5(0x111)]('offline')[_0x4fd0e5(0x158)](()=>{}),this['log'](_0x4fd0e5(0x10a));}async[a0_0x44e94b(0x12f)](_0x3132f1,_0x1de82b,_0xa89edf=a0_0x44e94b(0x139)){const _0x463baf=a0_0x44e94b;return Y({'alias':_0x3132f1,'fromAlias':this[_0x463baf(0x136)]},{'log':_0x446907=>console['log'](_0x446907),'send':()=>this[_0x463baf(0x152)](_0x463baf(0x10d),{'alias':_0x3132f1,'task':_0x1de82b,'priority':_0xa89edf,'from_session':this[_0x463baf(0x136)]})});}async[a0_0x44e94b(0x124)](_0x5bfa5b,_0x332f9c){const _0x236e0f=a0_0x44e94b;return this['call'](_0x236e0f(0x130),{'alias':_0x5bfa5b,'message':_0x332f9c,'from_session':this[_0x236e0f(0x136)]});}async['reply'](_0x3b85c2,_0x3b9fae,_0x15ef54=a0_0x44e94b(0x157)){return this['call']('send_reply',{'in_reply_to':_0x3b85c2,'text':_0x3b9fae,'status':_0x15ef54});}async['status'](_0x27317d,_0x5477dc){const _0x4be4c8=a0_0x44e94b;return this[_0x4be4c8(0x152)]('report_status',{'resume_id':this[_0x4be4c8(0x134)],'alias':this['alias'],'status':_0x27317d,'server':a0_0x29ead4(),'hostname':a0_0x29ead4(),'agent':this[_0x4be4c8(0x174)],'project_dir':process['cwd'](),..._0x5477dc});}async[a0_0x44e94b(0x164)](){const _0x515c82=a0_0x44e94b;return this[_0x515c82(0x152)]('get_all_status',{});}async['broadcast'](_0x8b37a2,_0x54fff7){const _0x17ce94=a0_0x44e94b;return this[_0x17ce94(0x152)](_0x17ce94(0x13d),{'message':_0x8b37a2,'filter_server':_0x54fff7?.['server'],'filter_status':_0x54fff7?.[_0x17ce94(0x111)]});}async[a0_0x44e94b(0x108)](){const _0x7440fc=a0_0x44e94b;let _0x53ae0b=encodeURIComponent(this[_0x7440fc(0x136)]),_0x149818=this[_0x7440fc(0x160)]+_0x7440fc(0x120)+_0x53ae0b,_0x2fd2b9=this['reconnectDelay'];while(this['running']){try{this[_0x7440fc(0x12d)]=new AbortController();let _0x9c7a0b={'Accept':'text/event-stream'};if(this[_0x7440fc(0x154)])_0x9c7a0b[_0x7440fc(0x12e)]='Bearer\x20'+this[_0x7440fc(0x154)];let _0x4c430d=await fetch(_0x149818,{'headers':_0x9c7a0b,'signal':this[_0x7440fc(0x12d)][_0x7440fc(0x172)]});if(!_0x4c430d['ok']||!_0x4c430d[_0x7440fc(0x16d)]){this['log'](_0x7440fc(0x177)+_0x4c430d[_0x7440fc(0x111)]),await this[_0x7440fc(0x153)](_0x2fd2b9),_0x2fd2b9=Math[_0x7440fc(0x175)](_0x2fd2b9*1.5,0xea60);continue;}_0x2fd2b9=this['reconnectDelay'];let _0x3bf094=_0x4c430d[_0x7440fc(0x16d)]['getReader'](),_0x52f083=new TextDecoder(),_0x1c2ec9='';while(this[_0x7440fc(0x16c)]){let {done:_0x34de0c,value:_0x10d2d5}=await _0x3bf094[_0x7440fc(0x115)]();if(_0x34de0c)break;_0x1c2ec9+=_0x52f083['decode'](_0x10d2d5,{'stream':!0x0});let _0x35a473=_0x1c2ec9[_0x7440fc(0x10f)]('\x0a');_0x1c2ec9=_0x35a473[_0x7440fc(0x119)]()||'';for(let _0x437803 of _0x35a473){if(!_0x437803[_0x7440fc(0x165)](_0x7440fc(0x100)))continue;try{let _0x4cd8e4=JSON['parse'](_0x437803[_0x7440fc(0x14a)](0x6));if(_0x4cd8e4['type']===_0x7440fc(0x14d)){this[_0x7440fc(0x170)](_0x7440fc(0x178)),this[_0x7440fc(0x101)](_0x7440fc(0x14d));continue;}if(_0x4cd8e4['type']===_0x7440fc(0x121)||_0x4cd8e4[_0x7440fc(0x106)]==='new_message'||_0x4cd8e4[_0x7440fc(0x106)]==='broadcast')await this[_0x7440fc(0x147)]();}catch{}}}}catch(_0x13ac33){if(_0x13ac33[_0x7440fc(0x116)]===_0x7440fc(0x167))break;this[_0x7440fc(0x101)](_0x7440fc(0x13b),_0x13ac33),this['log'](_0x7440fc(0x15f)+_0x13ac33['message']);}if(this['running'])this['emit'](_0x7440fc(0x10a)),this[_0x7440fc(0x170)](_0x7440fc(0x12c)+_0x2fd2b9/0x3e8+_0x7440fc(0x137)),await this[_0x7440fc(0x153)](_0x2fd2b9),_0x2fd2b9=Math[_0x7440fc(0x175)](_0x2fd2b9*1.5,0xea60);}}async[a0_0x44e94b(0x147)](){const _0x3d2822=a0_0x44e94b;try{let _0x1bc172=(await this[_0x3d2822(0x152)](_0x3d2822(0x144),{'alias':this[_0x3d2822(0x136)],'limit':0xa}))?.[_0x3d2822(0x181)]||[];for(let _0x29370d of _0x1bc172)await this[_0x3d2822(0x152)](_0x3d2822(0x171),{'alias':this[_0x3d2822(0x136)],'message_id':_0x29370d['id']}),this[_0x3d2822(0x170)]('←\x20'+_0x29370d['from_session']+':\x20'+_0x29370d[_0x3d2822(0x15c)]['slice'](0x0,0x3c)),this[_0x3d2822(0x101)](_0x3d2822(0x151),_0x29370d),this['emit'](_0x3d2822(0x124),_0x29370d);}catch(_0x36946a){this[_0x3d2822(0x170)](_0x3d2822(0x105)+_0x36946a[_0x3d2822(0x124)]);}}[a0_0x44e94b(0x153)](_0x1d8d26){return new Promise(_0x32d651=>setTimeout(_0x32d651,_0x1d8d26));}}var F=$;export{F as default,$ as CommHub};
|