@sleep2agi/agent-network 2.3.0-preview.234 → 2.3.0-preview.236
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_0x589708=a0_0x26c6;function a0_0x26c6(_0xb527da,_0x110a68){_0xb527da=_0xb527da-0xc2;const _0x239709=a0_0x2397();let _0x26c63b=_0x239709[_0xb527da];return _0x26c63b;}(function(_0x2ec502,_0x2fb8dd){const _0x51e200=a0_0x26c6,_0x429e40=_0x2ec502();while(!![]){try{const _0x327bd0=parseInt(_0x51e200(0xcb))/0x1+-parseInt(_0x51e200(0x11f))/0x2*(-parseInt(_0x51e200(0xd9))/0x3)+parseInt(_0x51e200(0xd5))/0x4+parseInt(_0x51e200(0x12d))/0x5+parseInt(_0x51e200(0x114))/0x6*(-parseInt(_0x51e200(0x131))/0x7)+parseInt(_0x51e200(0xf2))/0x8+-parseInt(_0x51e200(0x119))/0x9;if(_0x327bd0===_0x2fb8dd)break;else _0x429e40['push'](_0x429e40['shift']());}catch(_0x190e0a){_0x429e40['push'](_0x429e40['shift']());}}}(a0_0x2397,0x8f538));import{EventEmitter as a0_0x35b66d}from'events';import{hostname as a0_0x4092be}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x14f1ce,_0x310c29)=>(_0x14f1ce??_0x310c29)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x2483c3){const _0x314ca6=a0_0x26c6;return(_0x2483c3 instanceof Error?_0x2483c3['message']:String(_0x2483c3??_0x314ca6(0xe1)))[_0x314ca6(0x127)](K,_0x314ca6(0x109))[_0x314ca6(0x127)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x314ca6(0x139)](0x0,0xf0);}function O(_0x597e2f,_0xf0002f=process.env.ANET_TASK_TRACE_FORMAT===a0_0x589708(0xfb)){const _0x4b8c8f=a0_0x589708;if(_0xf0002f)return JSON[_0x4b8c8f(0xc9)](_0x597e2f);let _0x5b493d=L(_0x597e2f[_0x4b8c8f(0xfa)],_0x4b8c8f(0xfd)),_0x501191=L(_0x597e2f[_0x4b8c8f(0x129)],_0x4b8c8f(0xc3)),_0x37f4cb=_0x597e2f[_0x4b8c8f(0xcc)]?'\x20error='+_0x597e2f['error_code']+':'+(_0x597e2f[_0x4b8c8f(0x12e)]??''):'';return _0x4b8c8f(0x136)+_0x597e2f[_0x4b8c8f(0xfc)]+_0x4b8c8f(0x13d)+L(_0x597e2f[_0x4b8c8f(0xc2)],_0x4b8c8f(0x103))+_0x4b8c8f(0x133)+L(_0x597e2f[_0x4b8c8f(0xe3)],_0x4b8c8f(0x103))+_0x4b8c8f(0x126)+_0x501191+'\x20parent_task_id='+_0x5b493d+_0x4b8c8f(0xd2)+L(_0x597e2f[_0x4b8c8f(0xf5)],_0x4b8c8f(0x103))+_0x4b8c8f(0xc7)+_0x597e2f[_0x4b8c8f(0x11e)]+_0x4b8c8f(0xd0)+_0x597e2f['duration_ms']+'\x20lifecycle='+_0x597e2f[_0x4b8c8f(0xe7)]+_0x37f4cb;}function U(_0x380ecf){const _0x152105=a0_0x589708;return{'event':{'sending':'task.send.start','delivered':_0x152105(0x105),'failed':'task.send.failed','acked':'task.ack','started':_0x152105(0x104),'replied':_0x152105(0xef),'expired':_0x152105(0xd4)}[_0x380ecf[_0x152105(0xfc)]],..._0x380ecf};}function j(_0x46d4c6){const _0x5e0fa3=a0_0x589708;let _0x1987b1=_0x46d4c6?.[_0x5e0fa3(0x129)]||_0x46d4c6?.['message_id']||_0x46d4c6?.['id'];if(_0x1987b1)return String(_0x1987b1);let _0x3286ea=_0x46d4c6?.[_0x5e0fa3(0x11a)]?.[0x0]?.['text'];if(typeof _0x3286ea!==_0x5e0fa3(0x12a))return null;try{let _0x1ff63f=JSON[_0x5e0fa3(0xd1)](_0x3286ea);return _0x1ff63f?.[_0x5e0fa3(0x129)]||_0x1ff63f?.[_0x5e0fa3(0x13f)]||_0x1ff63f?.['id']||null;}catch{return null;}}async function X(_0x308044,_0x1f3c75){const _0x2293ef=a0_0x589708;let _0x503423=_0x1f3c75[_0x2293ef(0xf0)]??Date['now'],_0x4f874a=_0x503423(),_0x209142=(_0x5e9319,_0x260d1f,_0x361841,_0x31be5d)=>{const _0x581665=_0x2293ef;_0x1f3c75['log'](O(U({'from_alias':_0x308044[_0x581665(0x11b)],'to_alias':_0x308044[_0x581665(0xdf)],'task_id':_0x260d1f,'parent_task_id':_0x308044[_0x581665(0x141)],'network_id':_0x308044['networkId'],'transport':_0x308044[_0x581665(0x11e)],'status':_0x5e9319,'duration_ms':_0x503423()-_0x4f874a,'lifecycle_tracking':_0x308044['lifecycleTracking'],..._0x361841!==void 0x0?{'error_code':_0x31be5d||_0x581665(0xe6),'error_message':N(_0x361841)}:{}})));};_0x209142(_0x2293ef(0x10b),null);try{let _0x109ba4=await _0x1f3c75[_0x2293ef(0x13b)](),_0x4f5d5f=j(_0x109ba4);if(_0x4f5d5f)_0x209142(_0x2293ef(0x10f),_0x4f5d5f);else{if(_0x109ba4?.['ok']===!0x1||_0x109ba4?.[_0x2293ef(0x132)])_0x209142(_0x2293ef(0x10c),_0x4f5d5f,_0x109ba4?.[_0x2293ef(0x132)]||_0x2293ef(0xea),_0x2293ef(0x110));else _0x209142(_0x2293ef(0x10c),null,_0x2293ef(0xc6),_0x2293ef(0xf9));}return _0x109ba4;}catch(_0x302839){throw _0x209142(_0x2293ef(0x10c),null,_0x302839,_0x2293ef(0xe6)),_0x302839;}}function a0_0x2397(){const _0x23aa6d=['send_rejected','running','get_inbox','match','216gmohxR','connected','url','2.0','log','15986997CTgNpz','content','fromAlias','disconnected','abort','transport','135484GmvDoI','ack_inbox','processInbox','connect','catch','mcp_http','split','\x20task_id=','replace','Bearer\x20','task_id','string','idle','sseAbort','2325180Esyqsa','error_message','message','sdk-','227514dGRpHW','error','\x20to=','not_tracked','/mcp','[commhub:task]\x20',']\x20[commhub:','inbox\x20error:\x20','slice','networkId','send','new_task','\x20from=','from_session','message_id','report_status','parentTaskId','from_alias','<pending>','emit','server','CommHub\x20response\x20omitted\x20task_id','\x20transport=','completed','stringify','send_reply','437250nxDVLc','error_code','heartbeatTimer','normal','decode','\x20duration_ms=','parse','\x20network_id=','toString','task.expired','1457640tZsZup','body','heartbeatInterval','toTimeString','51jTITcY','agent','tools/call','new_message','get_all_status','application/json,\x20text/event-stream','toAlias','text','unknown\x20error','resumeId','to_alias','heartbeat\x20failed:\x20','type','send_failed','lifecycle_tracking','send_task','reconnectDelay','CommHub\x20rejected\x20task','read','/events/','token','connectSSE','task.replied','now','text/event-stream','8921272DIdsBG','Authorization','SSE\x20error:\x20','network_id','autoConnect','startsWith','messages','missing_task_id','parent_task_id','json','status','<missing>','AbortError','disconnect','send_message','broadcast','call','<unknown>','task.started','task.send.delivered','SSE\x20connected','data:\x20','alias','[REDACTED]','offline','sending','failed','sleep','s...','delivered'];a0_0x2397=function(){return _0x23aa6d;};return a0_0x2397();}async function Y(_0x511e82,_0xd0eb47){const _0x123ab6=a0_0x589708;return X({'fromAlias':_0x511e82[_0x123ab6(0x11b)],'toAlias':_0x511e82[_0x123ab6(0x108)],'parentTaskId':_0x511e82['parentTaskId']||null,'networkId':_0x511e82[_0x123ab6(0x13a)]||null,'transport':_0x123ab6(0x124),'lifecycleTracking':_0x123ab6(0x134)},_0xd0eb47);}class $ extends a0_0x35b66d{[a0_0x589708(0x116)];[a0_0x589708(0x108)];[a0_0x589708(0xed)];['agent'];[a0_0x589708(0xe2)];['heartbeatInterval'];[a0_0x589708(0xe9)];[a0_0x589708(0xcd)];['sseAbort'];[a0_0x589708(0x111)]=!0x1;constructor(_0x273c4c){const _0x1332ff=a0_0x589708;super();if(this[_0x1332ff(0x116)]=_0x273c4c['url']['replace'](/\/$/,''),this['alias']=_0x273c4c[_0x1332ff(0x108)],this['token']=_0x273c4c[_0x1332ff(0xed)],this['agent']=_0x273c4c[_0x1332ff(0xda)]||'sdk',this[_0x1332ff(0xe2)]=_0x1332ff(0x130)+_0x273c4c[_0x1332ff(0x108)]+'-'+Date[_0x1332ff(0xf0)]()[_0x1332ff(0xd3)](0x24),this[_0x1332ff(0xd7)]=_0x273c4c[_0x1332ff(0xd7)]??0x2bf20,this[_0x1332ff(0xe9)]=_0x273c4c[_0x1332ff(0xe9)]??0xbb8,_0x273c4c[_0x1332ff(0xf6)]!==!0x1)this[_0x1332ff(0x122)]();}[a0_0x589708(0x118)](_0x1942ab){const _0x1aeb73=a0_0x589708;console[_0x1aeb73(0x118)]('['+new Date()[_0x1aeb73(0xd8)]()[_0x1aeb73(0x139)](0x0,0x8)+_0x1aeb73(0x137)+this[_0x1aeb73(0x108)]+']\x20'+_0x1942ab);}async[a0_0x589708(0x102)](_0x40c4f0,_0x46962a){const _0x4f9117=a0_0x589708;let _0x328d97={'Content-Type':'application/json','Accept':_0x4f9117(0xde)};if(this[_0x4f9117(0xed)])_0x328d97[_0x4f9117(0xf3)]=_0x4f9117(0x128)+this['token'];let _0x5c51e0=await(await fetch(this[_0x4f9117(0x116)]+_0x4f9117(0x135),{'method':'POST','headers':_0x328d97,'body':JSON[_0x4f9117(0xc9)]({'jsonrpc':_0x4f9117(0x117),'id':Date[_0x4f9117(0xf0)](),'method':_0x4f9117(0xdb),'params':{'name':_0x40c4f0,'arguments':_0x46962a}})}))[_0x4f9117(0xe0)](),_0x6381da=_0x5c51e0[_0x4f9117(0x113)](/data: (.+)/),_0x2c5bed=_0x6381da?JSON[_0x4f9117(0xd1)](_0x6381da[0x1]):JSON['parse'](_0x5c51e0),_0x5b7f3c=_0x2c5bed?.['result']?.[_0x4f9117(0x11a)]?.[0x0]?.[_0x4f9117(0xe0)];return _0x5b7f3c?JSON[_0x4f9117(0xd1)](_0x5b7f3c):_0x2c5bed;}async[a0_0x589708(0x122)](){const _0x53dedc=a0_0x589708;if(this['running'])return;this[_0x53dedc(0x111)]=!0x0,await this[_0x53dedc(0xfc)](_0x53dedc(0x12b)),this['log']('registered'),this[_0x53dedc(0xcd)]=setInterval(()=>{const _0x453310=_0x53dedc;this[_0x453310(0xfc)]('idle')[_0x453310(0x123)](_0x4f5596=>this[_0x453310(0x118)](_0x453310(0xe4)+_0x4f5596['message']));},this['heartbeatInterval']),this[_0x53dedc(0xee)]();}async[a0_0x589708(0xff)](){const _0xdb017e=a0_0x589708;if(this[_0xdb017e(0x111)]=!0x1,this[_0xdb017e(0x12c)]?.[_0xdb017e(0x11d)](),this[_0xdb017e(0xcd)])clearInterval(this[_0xdb017e(0xcd)]);await this[_0xdb017e(0xfc)](_0xdb017e(0x10a))[_0xdb017e(0x123)](()=>{}),this[_0xdb017e(0x118)](_0xdb017e(0x11c));}async[a0_0x589708(0x13b)](_0x2d3a8a,_0x8ebd7c,_0x56bf45=a0_0x589708(0xce)){const _0x3a9ae3=a0_0x589708;return Y({'alias':_0x2d3a8a,'fromAlias':this[_0x3a9ae3(0x108)]},{'log':_0x13dba0=>console[_0x3a9ae3(0x118)](_0x13dba0),'send':()=>this[_0x3a9ae3(0x102)](_0x3a9ae3(0xe8),{'alias':_0x2d3a8a,'task':_0x8ebd7c,'priority':_0x56bf45,'from_session':this['alias']})});}async[a0_0x589708(0x12f)](_0xfe6f84,_0x8b351){const _0x3c1059=a0_0x589708;return this[_0x3c1059(0x102)](_0x3c1059(0x100),{'alias':_0xfe6f84,'message':_0x8b351,'from_session':this[_0x3c1059(0x108)]});}async['reply'](_0x4c1723,_0x40ea0d,_0xed29c5=a0_0x589708(0xc8)){const _0x1671aa=a0_0x589708;return this[_0x1671aa(0x102)](_0x1671aa(0xca),{'in_reply_to':_0x4c1723,'text':_0x40ea0d,'status':_0xed29c5});}async[a0_0x589708(0xfc)](_0x5703c4,_0x19c94f){const _0x200529=a0_0x589708;return this[_0x200529(0x102)](_0x200529(0x140),{'resume_id':this[_0x200529(0xe2)],'alias':this['alias'],'status':_0x5703c4,'server':a0_0x4092be(),'hostname':a0_0x4092be(),'agent':this[_0x200529(0xda)],'project_dir':process['cwd'](),..._0x19c94f});}async['getAllStatus'](){const _0x4b48db=a0_0x589708;return this['call'](_0x4b48db(0xdd),{});}async[a0_0x589708(0x101)](_0x536e1b,_0x2642f1){const _0x303c53=a0_0x589708;return this[_0x303c53(0x102)]('broadcast',{'message':_0x536e1b,'filter_server':_0x2642f1?.[_0x303c53(0xc5)],'filter_status':_0x2642f1?.['status']});}async[a0_0x589708(0xee)](){const _0x1d23c1=a0_0x589708;let _0xbf160c=encodeURIComponent(this[_0x1d23c1(0x108)]),_0x32916b=this[_0x1d23c1(0x116)]+_0x1d23c1(0xec)+_0xbf160c,_0x324b50=this['reconnectDelay'];while(this[_0x1d23c1(0x111)]){try{this[_0x1d23c1(0x12c)]=new AbortController();let _0x50c163={'Accept':_0x1d23c1(0xf1)};if(this[_0x1d23c1(0xed)])_0x50c163[_0x1d23c1(0xf3)]=_0x1d23c1(0x128)+this[_0x1d23c1(0xed)];let _0x1ef180=await fetch(_0x32916b,{'headers':_0x50c163,'signal':this[_0x1d23c1(0x12c)]['signal']});if(!_0x1ef180['ok']||!_0x1ef180['body']){this['log']('SSE\x20failed:\x20'+_0x1ef180['status']),await this['sleep'](_0x324b50),_0x324b50=Math['min'](_0x324b50*1.5,0xea60);continue;}_0x324b50=this[_0x1d23c1(0xe9)];let _0x351110=_0x1ef180[_0x1d23c1(0xd6)]['getReader'](),_0x11713d=new TextDecoder(),_0x3b5a9f='';while(this[_0x1d23c1(0x111)]){let {done:_0x256ae4,value:_0x176399}=await _0x351110[_0x1d23c1(0xeb)]();if(_0x256ae4)break;_0x3b5a9f+=_0x11713d[_0x1d23c1(0xcf)](_0x176399,{'stream':!0x0});let _0x6ebc19=_0x3b5a9f[_0x1d23c1(0x125)]('\x0a');_0x3b5a9f=_0x6ebc19['pop']()||'';for(let _0x35b022 of _0x6ebc19){if(!_0x35b022[_0x1d23c1(0xf7)](_0x1d23c1(0x107)))continue;try{let _0x53e3e1=JSON[_0x1d23c1(0xd1)](_0x35b022['slice'](0x6));if(_0x53e3e1[_0x1d23c1(0xe5)]===_0x1d23c1(0x115)){this[_0x1d23c1(0x118)](_0x1d23c1(0x106)),this['emit'](_0x1d23c1(0x115));continue;}if(_0x53e3e1[_0x1d23c1(0xe5)]===_0x1d23c1(0x13c)||_0x53e3e1[_0x1d23c1(0xe5)]===_0x1d23c1(0xdc)||_0x53e3e1[_0x1d23c1(0xe5)]===_0x1d23c1(0x101))await this[_0x1d23c1(0x121)]();}catch{}}}}catch(_0x5462c7){if(_0x5462c7['name']===_0x1d23c1(0xfe))break;this[_0x1d23c1(0xc4)]('error',_0x5462c7),this[_0x1d23c1(0x118)](_0x1d23c1(0xf4)+_0x5462c7[_0x1d23c1(0x12f)]);}if(this[_0x1d23c1(0x111)])this[_0x1d23c1(0xc4)](_0x1d23c1(0x11c)),this['log']('SSE\x20reconnecting\x20in\x20'+_0x324b50/0x3e8+_0x1d23c1(0x10e)),await this[_0x1d23c1(0x10d)](_0x324b50),_0x324b50=Math['min'](_0x324b50*1.5,0xea60);}}async['processInbox'](){const _0x2c2608=a0_0x589708;try{let _0x42f725=(await this[_0x2c2608(0x102)](_0x2c2608(0x112),{'alias':this[_0x2c2608(0x108)],'limit':0xa}))?.[_0x2c2608(0xf8)]||[];for(let _0x3b0774 of _0x42f725)await this[_0x2c2608(0x102)](_0x2c2608(0x120),{'alias':this['alias'],'message_id':_0x3b0774['id']}),this[_0x2c2608(0x118)]('←\x20'+_0x3b0774[_0x2c2608(0x13e)]+':\x20'+_0x3b0774[_0x2c2608(0x11a)][_0x2c2608(0x139)](0x0,0x3c)),this['emit']('task',_0x3b0774),this[_0x2c2608(0xc4)](_0x2c2608(0x12f),_0x3b0774);}catch(_0x3082b7){this[_0x2c2608(0x118)](_0x2c2608(0x138)+_0x3082b7[_0x2c2608(0x12f)]);}}[a0_0x589708(0x10d)](_0x2dd25d){return new Promise(_0x2691de=>setTimeout(_0x2691de,_0x2dd25d));}}var F=$;export{F as default,$ as CommHub};
|
|
1
|
+
const a0_0x55112a=a0_0x1e5e;(function(_0x21ec24,_0x43024e){const _0x52c325=a0_0x1e5e,_0x41444b=_0x21ec24();while(!![]){try{const _0x2c0c4c=-parseInt(_0x52c325(0x1ac))/0x1+parseInt(_0x52c325(0x162))/0x2+-parseInt(_0x52c325(0x1d9))/0x3*(-parseInt(_0x52c325(0x19f))/0x4)+-parseInt(_0x52c325(0x1cb))/0x5*(-parseInt(_0x52c325(0x1bf))/0x6)+-parseInt(_0x52c325(0x183))/0x7*(-parseInt(_0x52c325(0x1b1))/0x8)+-parseInt(_0x52c325(0x1d8))/0x9*(-parseInt(_0x52c325(0x1d4))/0xa)+-parseInt(_0x52c325(0x1bc))/0xb;if(_0x2c0c4c===_0x43024e)break;else _0x41444b['push'](_0x41444b['shift']());}catch(_0x453960){_0x41444b['push'](_0x41444b['shift']());}}}(a0_0x3332,0x5b8ae));import{EventEmitter as a0_0x592971}from'events';import{hostname as a0_0x1f32c9}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x371e7a,_0x41b4b9)=>(_0x371e7a??_0x41b4b9)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x55112a(0x1b7)](0x0,0xf0);function N(_0x492072){const _0x376b68=a0_0x55112a;return(_0x492072 instanceof Error?_0x492072[_0x376b68(0x1cc)]:String(_0x492072??'unknown\x20error'))[_0x376b68(0x18b)](K,_0x376b68(0x182))[_0x376b68(0x18b)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x376b68(0x1b7)](0x0,0xf0);}function O(_0x17bed7,_0x2cd355=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x5dc974=a0_0x55112a;if(_0x2cd355)return JSON[_0x5dc974(0x199)](_0x17bed7);let _0x3a81ad=L(_0x17bed7[_0x5dc974(0x1b4)],_0x5dc974(0x165)),_0x4e1c87=L(_0x17bed7[_0x5dc974(0x192)],'<pending>'),_0x211cea=_0x17bed7[_0x5dc974(0x178)]?_0x5dc974(0x180)+_0x17bed7[_0x5dc974(0x178)]+':'+(_0x17bed7[_0x5dc974(0x1be)]??''):'';return'[commhub:task]\x20'+_0x17bed7[_0x5dc974(0x1b8)]+'\x20from='+L(_0x17bed7['from_alias'],_0x5dc974(0x177))+_0x5dc974(0x1a9)+L(_0x17bed7[_0x5dc974(0x1d5)],_0x5dc974(0x177))+_0x5dc974(0x191)+_0x4e1c87+'\x20parent_task_id='+_0x3a81ad+_0x5dc974(0x1b3)+L(_0x17bed7[_0x5dc974(0x16f)],_0x5dc974(0x177))+_0x5dc974(0x196)+_0x17bed7[_0x5dc974(0x160)]+_0x5dc974(0x186)+_0x17bed7['duration_ms']+'\x20lifecycle='+_0x17bed7['lifecycle_tracking']+_0x211cea;}function U(_0x2ba766){const _0x31a7f5=a0_0x55112a;return{'event':{'sending':_0x31a7f5(0x175),'delivered':_0x31a7f5(0x1c9),'failed':'task.send.failed','acked':_0x31a7f5(0x1ab),'started':'task.started','replied':_0x31a7f5(0x163),'expired':_0x31a7f5(0x19c)}[_0x2ba766[_0x31a7f5(0x1b8)]],..._0x2ba766};}function j(_0x565b41){const _0x453275=a0_0x55112a;let _0x280e30=_0x565b41?.[_0x453275(0x192)]||_0x565b41?.[_0x453275(0x1aa)]||_0x565b41?.['id'];if(_0x280e30)return String(_0x280e30);let _0x4adc9d=_0x565b41?.[_0x453275(0x1b2)]?.[0x0]?.['text'];if(typeof _0x4adc9d!==_0x453275(0x1a8))return null;try{let _0x47cf42=JSON[_0x453275(0x1a4)](_0x4adc9d);return _0x47cf42?.[_0x453275(0x192)]||_0x47cf42?.['message_id']||_0x47cf42?.['id']||null;}catch{return null;}}async function X(_0x1177ec,_0xe249c){const _0x2eefb7=a0_0x55112a;let _0x2ddb29=_0xe249c[_0x2eefb7(0x17a)]??Date[_0x2eefb7(0x17a)],_0x49108b=_0x2ddb29(),_0x13062e=(_0x410683,_0x5032a3,_0x256997,_0x549ef1)=>{const _0x184883=_0x2eefb7;_0xe249c[_0x184883(0x194)](O(U({'from_alias':_0x1177ec['fromAlias'],'to_alias':_0x1177ec[_0x184883(0x198)],'task_id':_0x5032a3,'parent_task_id':_0x1177ec[_0x184883(0x1c3)],'network_id':_0x1177ec[_0x184883(0x17d)],'transport':_0x1177ec[_0x184883(0x160)],'status':_0x410683,'duration_ms':_0x2ddb29()-_0x49108b,'lifecycle_tracking':_0x1177ec['lifecycleTracking'],..._0x256997!==void 0x0?{'error_code':_0x549ef1||_0x184883(0x1d3),'error_message':N(_0x256997)}:{}})));};_0x13062e('sending',null);try{let _0x45e491=await _0xe249c[_0x2eefb7(0x1a1)](),_0x4c833d=j(_0x45e491);if(_0x4c833d)_0x13062e(_0x2eefb7(0x17b),_0x4c833d);else{if(_0x45e491?.['ok']===!0x1||_0x45e491?.[_0x2eefb7(0x166)])_0x13062e('failed',_0x4c833d,_0x45e491?.[_0x2eefb7(0x166)]||'CommHub\x20rejected\x20task',_0x2eefb7(0x197));else _0x13062e('failed',null,_0x2eefb7(0x19b),_0x2eefb7(0x1a6));}return _0x45e491;}catch(_0x3bccce){throw _0x13062e(_0x2eefb7(0x1d1),null,_0x3bccce,'send_failed'),_0x3bccce;}}async function Y(_0x2668a0,_0x2608b1){const _0x216494=a0_0x55112a;return X({'fromAlias':_0x2668a0['fromAlias'],'toAlias':_0x2668a0[_0x216494(0x16b)],'parentTaskId':_0x2668a0['parentTaskId']||null,'networkId':_0x2668a0[_0x216494(0x17d)]||null,'transport':_0x216494(0x1bb),'lifecycleTracking':_0x216494(0x17c)},_0x2608b1);}class $ extends a0_0x592971{['url'];[a0_0x55112a(0x16b)];['token'];[a0_0x55112a(0x1d7)];[a0_0x55112a(0x167)];[a0_0x55112a(0x1af)];[a0_0x55112a(0x1a5)];['heartbeatTimer'];[a0_0x55112a(0x190)];[a0_0x55112a(0x171)]=!0x1;constructor(_0x3bee0f){const _0x49c92f=a0_0x55112a;super();if(this[_0x49c92f(0x1c8)]=_0x3bee0f[_0x49c92f(0x1c8)][_0x49c92f(0x18b)](/\/$/,''),this[_0x49c92f(0x16b)]=_0x3bee0f['alias'],this['token']=_0x3bee0f[_0x49c92f(0x164)],this[_0x49c92f(0x1d7)]=_0x3bee0f['agent']||_0x49c92f(0x1c2),this[_0x49c92f(0x167)]='sdk-'+_0x3bee0f[_0x49c92f(0x16b)]+'-'+Date[_0x49c92f(0x17a)]()[_0x49c92f(0x17f)](0x24),this[_0x49c92f(0x1af)]=_0x3bee0f['heartbeatInterval']??0x2bf20,this['reconnectDelay']=_0x3bee0f['reconnectDelay']??0xbb8,_0x3bee0f[_0x49c92f(0x1b9)]!==!0x1)this['connect']();}['log'](_0x474c9c){const _0xe0125a=a0_0x55112a;console[_0xe0125a(0x194)]('['+new Date()['toTimeString']()[_0xe0125a(0x1b7)](0x0,0x8)+']\x20[commhub:'+this[_0xe0125a(0x16b)]+']\x20'+_0x474c9c);}async[a0_0x55112a(0x19e)](_0x1ff4cc,_0x123924){const _0x3ccc7e=a0_0x55112a;let _0x25e6f3={'Content-Type':_0x3ccc7e(0x1c6),'Accept':_0x3ccc7e(0x1bd)};if(this[_0x3ccc7e(0x164)])_0x25e6f3[_0x3ccc7e(0x187)]='Bearer\x20'+this[_0x3ccc7e(0x164)];let _0x16ab76=await(await fetch(this[_0x3ccc7e(0x1c8)]+_0x3ccc7e(0x1b0),{'method':_0x3ccc7e(0x1c4),'headers':_0x25e6f3,'body':JSON[_0x3ccc7e(0x199)]({'jsonrpc':_0x3ccc7e(0x1ae),'id':Date[_0x3ccc7e(0x17a)](),'method':_0x3ccc7e(0x1cf),'params':{'name':_0x1ff4cc,'arguments':_0x123924}})}))[_0x3ccc7e(0x185)](),_0x44e903=_0x16ab76[_0x3ccc7e(0x189)](/data: (.+)/),_0x461918=_0x44e903?JSON[_0x3ccc7e(0x1a4)](_0x44e903[0x1]):JSON[_0x3ccc7e(0x1a4)](_0x16ab76),_0x582282=_0x461918?.['result']?.['content']?.[0x0]?.[_0x3ccc7e(0x185)];return _0x582282?JSON[_0x3ccc7e(0x1a4)](_0x582282):_0x461918;}async[a0_0x55112a(0x1d0)](){const _0x435da6=a0_0x55112a;if(this['running'])return;this[_0x435da6(0x171)]=!0x0,await this[_0x435da6(0x1b8)](_0x435da6(0x1cd)),this[_0x435da6(0x194)](_0x435da6(0x17e)),this[_0x435da6(0x179)]=setInterval(()=>{const _0xbb41b3=_0x435da6;this[_0xbb41b3(0x1b8)](_0xbb41b3(0x1cd))[_0xbb41b3(0x172)](_0x24ae67=>this[_0xbb41b3(0x194)]('heartbeat\x20failed:\x20'+_0x24ae67[_0xbb41b3(0x1cc)]));},this['heartbeatInterval']),this[_0x435da6(0x1a3)]();}async['disconnect'](){const _0x41d337=a0_0x55112a;if(this[_0x41d337(0x171)]=!0x1,this['sseAbort']?.[_0x41d337(0x18d)](),this['heartbeatTimer'])clearInterval(this[_0x41d337(0x179)]);await this['status'](_0x41d337(0x1ba))[_0x41d337(0x172)](()=>{}),this['log'](_0x41d337(0x169));}async[a0_0x55112a(0x1a1)](_0x10ee7e,_0x4ac089,_0x3d9363=a0_0x55112a(0x16a)){const _0x1da55e=a0_0x55112a;return Y({'alias':_0x10ee7e,'fromAlias':this['alias']},{'log':_0x34c09c=>console[_0x1da55e(0x194)](_0x34c09c),'send':()=>this['call']('send_task',{'alias':_0x10ee7e,'task':_0x4ac089,'priority':_0x3d9363,'from_session':this[_0x1da55e(0x16b)]})});}async[a0_0x55112a(0x1cc)](_0x4141af,_0x2c1100){const _0x556a08=a0_0x55112a;return this['call']('send_message',{'alias':_0x4141af,'message':_0x2c1100,'from_session':this[_0x556a08(0x16b)]});}async[a0_0x55112a(0x195)](_0x58520b,_0x46d7eb,_0x139e07=a0_0x55112a(0x1c5)){const _0x413bca=a0_0x55112a;return this['call'](_0x413bca(0x18f),{'in_reply_to':_0x58520b,'text':_0x46d7eb,'status':_0x139e07});}async[a0_0x55112a(0x1b8)](_0x3a68f0,_0x3be803){const _0x4d1d0c=a0_0x55112a;return this[_0x4d1d0c(0x19e)](_0x4d1d0c(0x173),{'resume_id':this[_0x4d1d0c(0x167)],'alias':this['alias'],'status':_0x3a68f0,'server':a0_0x1f32c9(),'hostname':a0_0x1f32c9(),'agent':this[_0x4d1d0c(0x1d7)],'project_dir':process[_0x4d1d0c(0x1c0)](),..._0x3be803});}async['getAllStatus'](){const _0x110616=a0_0x55112a;return this[_0x110616(0x19e)](_0x110616(0x19d),{});}async[a0_0x55112a(0x1c1)](_0x3ff4cc,_0x1d9668){const _0x43a6e5=a0_0x55112a;return this[_0x43a6e5(0x19e)](_0x43a6e5(0x1c1),{'message':_0x3ff4cc,'filter_server':_0x1d9668?.[_0x43a6e5(0x193)],'filter_status':_0x1d9668?.[_0x43a6e5(0x1b8)]});}async[a0_0x55112a(0x1a3)](){const _0x58bc91=a0_0x55112a;let _0x4661a=encodeURIComponent(this[_0x58bc91(0x16b)]),_0xb197d9=this[_0x58bc91(0x1c8)]+_0x58bc91(0x18c)+_0x4661a,_0x2474e7=this['reconnectDelay'];while(this['running']){try{this[_0x58bc91(0x190)]=new AbortController();let _0x371b60={'Accept':_0x58bc91(0x170)};if(this[_0x58bc91(0x164)])_0x371b60[_0x58bc91(0x187)]='Bearer\x20'+this[_0x58bc91(0x164)];let _0xcba981=await fetch(_0xb197d9,{'headers':_0x371b60,'signal':this['sseAbort']['signal']});if(!_0xcba981['ok']||!_0xcba981[_0x58bc91(0x188)]){this[_0x58bc91(0x194)](_0x58bc91(0x1a0)+_0xcba981[_0x58bc91(0x1b8)]),await this[_0x58bc91(0x184)](_0x2474e7),_0x2474e7=Math[_0x58bc91(0x16c)](_0x2474e7*1.5,0xea60);continue;}_0x2474e7=this[_0x58bc91(0x1a5)];let _0x2f2465=_0xcba981['body'][_0x58bc91(0x1b5)](),_0x5b2151=new TextDecoder(),_0x56c9a8='';while(this['running']){let {done:_0x467c35,value:_0x284a72}=await _0x2f2465[_0x58bc91(0x1a2)]();if(_0x467c35)break;_0x56c9a8+=_0x5b2151[_0x58bc91(0x18e)](_0x284a72,{'stream':!0x0});let _0x52f061=_0x56c9a8[_0x58bc91(0x19a)]('\x0a');_0x56c9a8=_0x52f061[_0x58bc91(0x176)]()||'';for(let _0x141cc7 of _0x52f061){if(!_0x141cc7['startsWith'](_0x58bc91(0x181)))continue;try{let _0x268a8e=JSON['parse'](_0x141cc7['slice'](0x6));if(_0x268a8e[_0x58bc91(0x174)]==='connected'){this[_0x58bc91(0x194)](_0x58bc91(0x1b6)),this['emit'](_0x58bc91(0x1c7));continue;}if(_0x268a8e['type']==='new_task'||_0x268a8e[_0x58bc91(0x174)]===_0x58bc91(0x161)||_0x268a8e[_0x58bc91(0x174)]===_0x58bc91(0x1c1))await this['processInbox']();}catch{}}}}catch(_0x4dc826){if(_0x4dc826[_0x58bc91(0x1ca)]===_0x58bc91(0x18a))break;this['emit'](_0x58bc91(0x166),_0x4dc826),this['log'](_0x58bc91(0x1ad)+_0x4dc826['message']);}if(this[_0x58bc91(0x171)])this[_0x58bc91(0x1d6)](_0x58bc91(0x169)),this[_0x58bc91(0x194)]('SSE\x20reconnecting\x20in\x20'+_0x2474e7/0x3e8+_0x58bc91(0x1d2)),await this[_0x58bc91(0x184)](_0x2474e7),_0x2474e7=Math[_0x58bc91(0x16c)](_0x2474e7*1.5,0xea60);}}async[a0_0x55112a(0x1a7)](){const _0x3c18ac=a0_0x55112a;try{let _0xec7efc=(await this['call'](_0x3c18ac(0x16d),{'alias':this[_0x3c18ac(0x16b)],'limit':0xa}))?.[_0x3c18ac(0x16e)]||[];for(let _0x255e66 of _0xec7efc)await this['call']('ack_inbox',{'alias':this[_0x3c18ac(0x16b)],'message_id':_0x255e66['id']}),this[_0x3c18ac(0x194)]('←\x20'+_0x255e66['from_session']+':\x20'+_0x255e66[_0x3c18ac(0x1b2)][_0x3c18ac(0x1b7)](0x0,0x3c)),this[_0x3c18ac(0x1d6)](_0x3c18ac(0x168),_0x255e66),this['emit'](_0x3c18ac(0x1cc),_0x255e66);}catch(_0x46fe58){this['log'](_0x3c18ac(0x1ce)+_0x46fe58[_0x3c18ac(0x1cc)]);}}[a0_0x55112a(0x184)](_0x534364){return new Promise(_0x282707=>setTimeout(_0x282707,_0x534364));}}function a0_0x3332(){const _0x2a7ef6=['task','disconnected','normal','alias','min','get_inbox','messages','network_id','text/event-stream','running','catch','report_status','type','task.send.start','pop','<unknown>','error_code','heartbeatTimer','now','delivered','not_tracked','networkId','registered','toString','\x20error=','data:\x20','[REDACTED]','3688902GXlNDA','sleep','text','\x20duration_ms=','Authorization','body','match','AbortError','replace','/events/','abort','decode','send_reply','sseAbort','\x20task_id=','task_id','server','log','reply','\x20transport=','send_rejected','toAlias','stringify','split','CommHub\x20response\x20omitted\x20task_id','task.expired','get_all_status','call','12toIFVv','SSE\x20failed:\x20','send','read','connectSSE','parse','reconnectDelay','missing_task_id','processInbox','string','\x20to=','message_id','task.ack','18610tfDrnT','SSE\x20error:\x20','2.0','heartbeatInterval','/mcp','8KbtkkO','content','\x20network_id=','parent_task_id','getReader','SSE\x20connected','slice','status','autoConnect','offline','mcp_http','22638022TPqhrC','application/json,\x20text/event-stream','error_message','4141398oACBwH','cwd','broadcast','sdk','parentTaskId','POST','completed','application/json','connected','url','task.send.delivered','name','5VAwxIt','message','idle','inbox\x20error:\x20','tools/call','connect','failed','s...','send_failed','530630oNspSe','to_alias','emit','agent','18jhSoOh','611859ICHFap','transport','new_message','1032732ZjJBJw','task.replied','token','<missing>','error','resumeId'];a0_0x3332=function(){return _0x2a7ef6;};return a0_0x3332();}function a0_0x1e5e(_0x42afb6,_0x1e5ad4){_0x42afb6=_0x42afb6-0x160;const _0x3332df=a0_0x3332();let _0x1e5eb3=_0x3332df[_0x42afb6];return _0x1e5eb3;}var F=$;export{F as default,$ as CommHub};
|