@sleep2agi/agent-network 2.3.0-preview.58 → 2.3.0-preview.59
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_0x2e18f7=a0_0x1a85;(function(_0x4dd29e,_0x13d560){const _0x4867d1=a0_0x1a85,_0x1061fd=_0x4dd29e();while(!![]){try{const _0x469229=-parseInt(_0x4867d1(0x176))/0x1+-parseInt(_0x4867d1(0x16a))/0x2+-parseInt(_0x4867d1(0x1e2))/0x3*(-parseInt(_0x4867d1(0x1a9))/0x4)+parseInt(_0x4867d1(0x198))/0x5*(parseInt(_0x4867d1(0x1c4))/0x6)+-parseInt(_0x4867d1(0x1b8))/0x7*(parseInt(_0x4867d1(0x1d3))/0x8)+parseInt(_0x4867d1(0x175))/0x9+-parseInt(_0x4867d1(0x18c))/0xa*(-parseInt(_0x4867d1(0x196))/0xb);if(_0x469229===_0x13d560)break;else _0x1061fd['push'](_0x1061fd['shift']());}catch(_0x5ee623){_0x1061fd['push'](_0x1061fd['shift']());}}}(a0_0x5d43,0x74afe));import{EventEmitter as a0_0x483b08}from'events';import{hostname as a0_0x4e38be}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x10fde7,_0x33a013)=>(_0x10fde7??_0x33a013)[a0_0x2e18f7(0x19f)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x2e18f7(0x1ac)](0x0,0xf0);function N(_0x25ba4c){const _0x32491e=a0_0x2e18f7;return(_0x25ba4c instanceof Error?_0x25ba4c[_0x32491e(0x1a8)]:String(_0x25ba4c??_0x32491e(0x1d6)))[_0x32491e(0x19f)](K,_0x32491e(0x189))[_0x32491e(0x19f)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x32491e(0x1ac)](0x0,0xf0);}function O(_0x12b8cd,_0x2449b7=process.env.ANET_TASK_TRACE_FORMAT===a0_0x2e18f7(0x1dd)){const _0x217de1=a0_0x2e18f7;if(_0x2449b7)return JSON[_0x217de1(0x1b7)](_0x12b8cd);let _0x3d98c6=L(_0x12b8cd[_0x217de1(0x1e0)],_0x217de1(0x1de)),_0x2cb7bb=L(_0x12b8cd[_0x217de1(0x19b)],'<pending>'),_0x2a8b8d=_0x12b8cd[_0x217de1(0x18a)]?_0x217de1(0x1d7)+_0x12b8cd[_0x217de1(0x18a)]+':'+(_0x12b8cd[_0x217de1(0x1b6)]??''):'';return'[commhub:task]\x20'+_0x12b8cd['status']+_0x217de1(0x16c)+L(_0x12b8cd[_0x217de1(0x1b1)],_0x217de1(0x1c6))+_0x217de1(0x1bc)+L(_0x12b8cd[_0x217de1(0x180)],_0x217de1(0x1c6))+_0x217de1(0x1a3)+_0x2cb7bb+_0x217de1(0x1aa)+_0x3d98c6+_0x217de1(0x1ad)+L(_0x12b8cd['network_id'],_0x217de1(0x1c6))+_0x217de1(0x1ba)+_0x12b8cd['transport']+_0x217de1(0x1b2)+_0x12b8cd[_0x217de1(0x193)]+_0x217de1(0x19c)+_0x12b8cd[_0x217de1(0x17f)]+_0x2a8b8d;}function U(_0x1e8359){const _0x3dfb76=a0_0x2e18f7;return{'event':{'sending':_0x3dfb76(0x1ae),'delivered':_0x3dfb76(0x1d5),'failed':_0x3dfb76(0x199),'acked':'task.ack','started':_0x3dfb76(0x194),'replied':'task.replied','expired':_0x3dfb76(0x1e1)}[_0x1e8359[_0x3dfb76(0x192)]],..._0x1e8359};}function j(_0x46eba2){const _0x3ab234=a0_0x2e18f7;let _0x32fd05=_0x46eba2?.[_0x3ab234(0x19b)]||_0x46eba2?.[_0x3ab234(0x184)]||_0x46eba2?.['id'];if(_0x32fd05)return String(_0x32fd05);let _0x10f80e=_0x46eba2?.[_0x3ab234(0x191)]?.[0x0]?.[_0x3ab234(0x1ce)];if(typeof _0x10f80e!==_0x3ab234(0x1c8))return null;try{let _0x5f09ce=JSON['parse'](_0x10f80e);return _0x5f09ce?.[_0x3ab234(0x19b)]||_0x5f09ce?.[_0x3ab234(0x184)]||_0x5f09ce?.['id']||null;}catch{return null;}}async function X(_0x2109bc,_0x5a4203){const _0x335eef=a0_0x2e18f7;let _0x1fa334=_0x5a4203[_0x335eef(0x173)]??Date[_0x335eef(0x173)],_0x330755=_0x1fa334(),_0x54c1f6=(_0x54e162,_0x2212f2,_0x425062,_0x53b738)=>{const _0x7a1fb0=_0x335eef;_0x5a4203[_0x7a1fb0(0x163)](O(U({'from_alias':_0x2109bc['fromAlias'],'to_alias':_0x2109bc['toAlias'],'task_id':_0x2212f2,'parent_task_id':_0x2109bc[_0x7a1fb0(0x1cd)],'network_id':_0x2109bc['networkId'],'transport':_0x2109bc[_0x7a1fb0(0x169)],'status':_0x54e162,'duration_ms':_0x1fa334()-_0x330755,'lifecycle_tracking':_0x2109bc[_0x7a1fb0(0x1c3)],..._0x425062!==void 0x0?{'error_code':_0x53b738||_0x7a1fb0(0x164),'error_message':N(_0x425062)}:{}})));};_0x54c1f6(_0x335eef(0x179),null);try{let _0x5abddf=await _0x5a4203['send'](),_0x1b4170=j(_0x5abddf);if(_0x1b4170)_0x54c1f6(_0x335eef(0x1d4),_0x1b4170);else{if(_0x5abddf?.['ok']===!0x1||_0x5abddf?.[_0x335eef(0x19a)])_0x54c1f6('failed',_0x1b4170,_0x5abddf?.[_0x335eef(0x19a)]||_0x335eef(0x18e),'send_rejected');else _0x54c1f6(_0x335eef(0x177),null,'CommHub\x20response\x20omitted\x20task_id',_0x335eef(0x1a2));}return _0x5abddf;}catch(_0x2ae0e8){throw _0x54c1f6(_0x335eef(0x177),null,_0x2ae0e8,_0x335eef(0x164)),_0x2ae0e8;}}function a0_0x1a85(_0x3204d7,_0x3b6dc4){_0x3204d7=_0x3204d7-0x163;const _0x5d43f4=a0_0x5d43();let _0x1a8573=_0x5d43f4[_0x3204d7];return _0x1a8573;}async function Y(_0x49aa04,_0xbd4eb0){const _0x392948=a0_0x2e18f7;return X({'fromAlias':_0x49aa04[_0x392948(0x18d)],'toAlias':_0x49aa04[_0x392948(0x17e)],'parentTaskId':_0x49aa04[_0x392948(0x1cd)]||null,'networkId':_0x49aa04['networkId']||null,'transport':_0x392948(0x195),'lifecycleTracking':'not_tracked'},_0xbd4eb0);}class $ extends a0_0x483b08{[a0_0x2e18f7(0x187)];[a0_0x2e18f7(0x17e)];['token'];[a0_0x2e18f7(0x1d9)];['resumeId'];[a0_0x2e18f7(0x16e)];[a0_0x2e18f7(0x178)];[a0_0x2e18f7(0x1a1)];[a0_0x2e18f7(0x16f)];[a0_0x2e18f7(0x185)]=!0x1;constructor(_0xecbc65){const _0x3cedd0=a0_0x2e18f7;super();if(this['url']=_0xecbc65[_0x3cedd0(0x187)][_0x3cedd0(0x19f)](/\/$/,''),this[_0x3cedd0(0x17e)]=_0xecbc65[_0x3cedd0(0x17e)],this[_0x3cedd0(0x1a7)]=_0xecbc65[_0x3cedd0(0x1a7)],this[_0x3cedd0(0x1d9)]=_0xecbc65[_0x3cedd0(0x1d9)]||'sdk',this[_0x3cedd0(0x1bd)]=_0x3cedd0(0x168)+_0xecbc65[_0x3cedd0(0x17e)]+'-'+Date['now']()[_0x3cedd0(0x1b3)](0x24),this[_0x3cedd0(0x16e)]=_0xecbc65[_0x3cedd0(0x16e)]??0x2bf20,this['reconnectDelay']=_0xecbc65['reconnectDelay']??0xbb8,_0xecbc65[_0x3cedd0(0x1b9)]!==!0x1)this[_0x3cedd0(0x1db)]();}['log'](_0x4cec13){const _0x1ca208=a0_0x2e18f7;console[_0x1ca208(0x163)]('['+new Date()[_0x1ca208(0x1d8)]()[_0x1ca208(0x1ac)](0x0,0x8)+']\x20[commhub:'+this[_0x1ca208(0x17e)]+']\x20'+_0x4cec13);}async[a0_0x2e18f7(0x188)](_0x59f51d,_0x154d3e){const _0xc219c1=a0_0x2e18f7;let _0x336868={'Content-Type':_0xc219c1(0x1b4),'Accept':_0xc219c1(0x1c9)};if(this['token'])_0x336868[_0xc219c1(0x186)]=_0xc219c1(0x1be)+this[_0xc219c1(0x1a7)];let _0x657e64=await(await fetch(this[_0xc219c1(0x187)]+'/mcp',{'method':'POST','headers':_0x336868,'body':JSON[_0xc219c1(0x1b7)]({'jsonrpc':'2.0','id':Date[_0xc219c1(0x173)](),'method':'tools/call','params':{'name':_0x59f51d,'arguments':_0x154d3e}})}))[_0xc219c1(0x1ce)](),_0x342c64=_0x657e64[_0xc219c1(0x174)](/data: (.+)/),_0x535363=_0x342c64?JSON[_0xc219c1(0x17b)](_0x342c64[0x1]):JSON[_0xc219c1(0x17b)](_0x657e64),_0x110686=_0x535363?.['result']?.['content']?.[0x0]?.[_0xc219c1(0x1ce)];return _0x110686?JSON[_0xc219c1(0x17b)](_0x110686):_0x535363;}async[a0_0x2e18f7(0x1db)](){const _0x2afdfb=a0_0x2e18f7;if(this[_0x2afdfb(0x185)])return;this[_0x2afdfb(0x185)]=!0x0,await this['status'](_0x2afdfb(0x1cc)),this[_0x2afdfb(0x163)]('registered'),this['heartbeatTimer']=setInterval(()=>{const _0x4d0884=_0x2afdfb;this[_0x4d0884(0x192)](_0x4d0884(0x1cc))[_0x4d0884(0x165)](_0x27817c=>this[_0x4d0884(0x163)](_0x4d0884(0x1cb)+_0x27817c['message']));},this[_0x2afdfb(0x16e)]),this['connectSSE']();}async[a0_0x2e18f7(0x1c1)](){const _0x5d12e4=a0_0x2e18f7;if(this[_0x5d12e4(0x185)]=!0x1,this[_0x5d12e4(0x16f)]?.['abort'](),this[_0x5d12e4(0x1a1)])clearInterval(this[_0x5d12e4(0x1a1)]);await this[_0x5d12e4(0x192)](_0x5d12e4(0x1a0))[_0x5d12e4(0x165)](()=>{}),this[_0x5d12e4(0x163)](_0x5d12e4(0x181));}async[a0_0x2e18f7(0x1c7)](_0x474a0b,_0x1e8919,_0x527e3f=a0_0x2e18f7(0x1b5)){const _0x4960d8=a0_0x2e18f7;return Y({'alias':_0x474a0b,'fromAlias':this[_0x4960d8(0x17e)]},{'log':_0x118868=>console[_0x4960d8(0x163)](_0x118868),'send':()=>this['call'](_0x4960d8(0x190),{'alias':_0x474a0b,'task':_0x1e8919,'priority':_0x527e3f,'from_session':this['alias']})});}async[a0_0x2e18f7(0x1a8)](_0x10297b,_0x296399){const _0x29a5b4=a0_0x2e18f7;return this[_0x29a5b4(0x188)](_0x29a5b4(0x1d2),{'alias':_0x10297b,'message':_0x296399,'from_session':this[_0x29a5b4(0x17e)]});}async[a0_0x2e18f7(0x19d)](_0xdd5d13,_0x42646c,_0x1cb438=a0_0x2e18f7(0x1a5)){const _0x1b1e08=a0_0x2e18f7;return this[_0x1b1e08(0x188)](_0x1b1e08(0x183),{'in_reply_to':_0xdd5d13,'text':_0x42646c,'status':_0x1cb438});}async[a0_0x2e18f7(0x192)](_0x5988e0,_0x32ed10){const _0xdf9c9=a0_0x2e18f7;return this[_0xdf9c9(0x188)]('report_status',{'resume_id':this['resumeId'],'alias':this[_0xdf9c9(0x17e)],'status':_0x5988e0,'server':a0_0x4e38be(),'hostname':a0_0x4e38be(),'agent':this[_0xdf9c9(0x1d9)],'project_dir':process['cwd'](),..._0x32ed10});}async['getAllStatus'](){const _0x4aea0f=a0_0x2e18f7;return this[_0x4aea0f(0x188)](_0x4aea0f(0x1dc),{});}async[a0_0x2e18f7(0x1cf)](_0x5a3de5,_0x39ba9d){const _0x452849=a0_0x2e18f7;return this[_0x452849(0x188)]('broadcast',{'message':_0x5a3de5,'filter_server':_0x39ba9d?.[_0x452849(0x1ca)],'filter_status':_0x39ba9d?.[_0x452849(0x192)]});}async[a0_0x2e18f7(0x1d1)](){const _0x4d7fbd=a0_0x2e18f7;let _0x373a40=encodeURIComponent(this[_0x4d7fbd(0x17e)]),_0x59a223=this['url']+_0x4d7fbd(0x197)+_0x373a40,_0x3dc34a=this[_0x4d7fbd(0x178)];while(this[_0x4d7fbd(0x185)]){try{this[_0x4d7fbd(0x16f)]=new AbortController();let _0x3e7630={'Accept':_0x4d7fbd(0x18f)};if(this[_0x4d7fbd(0x1a7)])_0x3e7630[_0x4d7fbd(0x186)]='Bearer\x20'+this['token'];let _0x36fef7=await fetch(_0x59a223,{'headers':_0x3e7630,'signal':this['sseAbort'][_0x4d7fbd(0x1ab)]});if(!_0x36fef7['ok']||!_0x36fef7[_0x4d7fbd(0x1d0)]){this[_0x4d7fbd(0x163)](_0x4d7fbd(0x166)+_0x36fef7[_0x4d7fbd(0x192)]),await this[_0x4d7fbd(0x1af)](_0x3dc34a),_0x3dc34a=Math['min'](_0x3dc34a*1.5,0xea60);continue;}_0x3dc34a=this['reconnectDelay'];let _0x16efd9=_0x36fef7['body']['getReader'](),_0x4b3501=new TextDecoder(),_0x20eb9d='';while(this[_0x4d7fbd(0x185)]){let {done:_0x21d4bf,value:_0x183429}=await _0x16efd9[_0x4d7fbd(0x18b)]();if(_0x21d4bf)break;_0x20eb9d+=_0x4b3501[_0x4d7fbd(0x1c5)](_0x183429,{'stream':!0x0});let _0x7e020e=_0x20eb9d[_0x4d7fbd(0x1da)]('\x0a');_0x20eb9d=_0x7e020e[_0x4d7fbd(0x16b)]()||'';for(let _0x79e157 of _0x7e020e){if(!_0x79e157[_0x4d7fbd(0x19e)](_0x4d7fbd(0x167)))continue;try{let _0x37162f=JSON[_0x4d7fbd(0x17b)](_0x79e157[_0x4d7fbd(0x1ac)](0x6));if(_0x37162f[_0x4d7fbd(0x1bf)]===_0x4d7fbd(0x1c2)){this['log'](_0x4d7fbd(0x172)),this[_0x4d7fbd(0x182)](_0x4d7fbd(0x1c2));continue;}if(_0x37162f[_0x4d7fbd(0x1bf)]===_0x4d7fbd(0x1a4)||_0x37162f[_0x4d7fbd(0x1bf)]===_0x4d7fbd(0x17d)||_0x37162f[_0x4d7fbd(0x1bf)]===_0x4d7fbd(0x1cf))await this['processInbox']();}catch{}}}}catch(_0x1f689a){if(_0x1f689a[_0x4d7fbd(0x16d)]==='AbortError')break;this[_0x4d7fbd(0x182)]('error',_0x1f689a),this[_0x4d7fbd(0x163)](_0x4d7fbd(0x171)+_0x1f689a[_0x4d7fbd(0x1a8)]);}if(this['running'])this[_0x4d7fbd(0x182)]('disconnected'),this[_0x4d7fbd(0x163)](_0x4d7fbd(0x1df)+_0x3dc34a/0x3e8+_0x4d7fbd(0x1c0)),await this[_0x4d7fbd(0x1af)](_0x3dc34a),_0x3dc34a=Math[_0x4d7fbd(0x1bb)](_0x3dc34a*1.5,0xea60);}}async[a0_0x2e18f7(0x17c)](){const _0x4b12f3=a0_0x2e18f7;try{let _0x598b00=(await this[_0x4b12f3(0x188)](_0x4b12f3(0x1a6),{'alias':this[_0x4b12f3(0x17e)],'limit':0xa}))?.['messages']||[];for(let _0x2f98c1 of _0x598b00)await this[_0x4b12f3(0x188)](_0x4b12f3(0x1b0),{'alias':this['alias'],'message_id':_0x2f98c1['id']}),this[_0x4b12f3(0x163)]('←\x20'+_0x2f98c1[_0x4b12f3(0x170)]+':\x20'+_0x2f98c1[_0x4b12f3(0x191)][_0x4b12f3(0x1ac)](0x0,0x3c)),this[_0x4b12f3(0x182)]('task',_0x2f98c1),this[_0x4b12f3(0x182)](_0x4b12f3(0x1a8),_0x2f98c1);}catch(_0x2deb17){this[_0x4b12f3(0x163)](_0x4b12f3(0x17a)+_0x2deb17[_0x4b12f3(0x1a8)]);}}[a0_0x2e18f7(0x1af)](_0x7560cd){return new Promise(_0x1323f1=>setTimeout(_0x1323f1,_0x7560cd));}}function a0_0x5d43(){const _0x458a03=['log','send_failed','catch','SSE\x20failed:\x20','data:\x20','sdk-','transport','392100bsAFnL','pop','\x20from=','name','heartbeatInterval','sseAbort','from_session','SSE\x20error:\x20','SSE\x20connected','now','match','1949328WHfidA','221945pWVaDt','failed','reconnectDelay','sending','inbox\x20error:\x20','parse','processInbox','new_message','alias','lifecycle_tracking','to_alias','disconnected','emit','send_reply','message_id','running','Authorization','url','call','[REDACTED]','error_code','read','190ExYbDs','fromAlias','CommHub\x20rejected\x20task','text/event-stream','send_task','content','status','duration_ms','task.started','mcp_http','121352hTwMwY','/events/','464395BWHLdA','task.send.failed','error','task_id','\x20lifecycle=','reply','startsWith','replace','offline','heartbeatTimer','missing_task_id','\x20task_id=','new_task','completed','get_inbox','token','message','104hhRCXc','\x20parent_task_id=','signal','slice','\x20network_id=','task.send.start','sleep','ack_inbox','from_alias','\x20duration_ms=','toString','application/json','normal','error_message','stringify','56PlfzNq','autoConnect','\x20transport=','min','\x20to=','resumeId','Bearer\x20','type','s...','disconnect','connected','lifecycleTracking','18RjZMll','decode','<unknown>','send','string','application/json,\x20text/event-stream','server','heartbeat\x20failed:\x20','idle','parentTaskId','text','broadcast','body','connectSSE','send_message','204144uxQuvb','delivered','task.send.delivered','unknown\x20error','\x20error=','toTimeString','agent','split','connect','get_all_status','json','<missing>','SSE\x20reconnecting\x20in\x20','parent_task_id','task.expired','45606EzZJVG'];a0_0x5d43=function(){return _0x458a03;};return a0_0x5d43();}var F=$;export{F as default,$ as CommHub};
|
|
1
|
+
function a0_0x23d2(){const _0x4e4822=['241971poecfx',']\x20[commhub:','message_id','name','task.ack','117GGJtQz','Authorization','connectSSE','AbortError','match','missing_task_id','task.send.failed','s...','split','parent_task_id','processInbox','not_tracked','task','replace','connect','\x20to=','toAlias','from_alias','duration_ms','get_all_status','\x20duration_ms=','\x20from=','489935wgIIrB','18yMlFHm','send_failed','sdk','task.send.delivered','parse','\x20error=','POST','142888hGavnP','result','cwd','Bearer\x20','<pending>','sseAbort','alias','url','task_id','heartbeat\x20failed:\x20','networkId','task.send.start','reply','303648yJuUob','ack_inbox','/mcp','heartbeatInterval','slice','emit','transport','toString','toTimeString','type','read','error','data:\x20','send_task','inbox\x20error:\x20','error_code','unknown\x20error','string','error_message','send','get_inbox','signal','now','text','CommHub\x20rejected\x20task','pop','812yFEKdg','log','failed','new_task','sdk-','application/json','stringify','connected','content','task.replied','tools/call','status','call','\x20network_id=','2.0','send_reply','running','messages','normal','send_rejected','from_session','agent','completed','catch','json','15816yQmtfg','abort','<unknown>','task.expired','1879048KNVpRy','idle','\x20parent_task_id=','message','[commhub:task]\x20','reconnectDelay','broadcast','SSE\x20failed:\x20','token','sleep','\x20task_id=','fromAlias','getReader','<missing>','\x20transport=','heartbeatTimer','send_message','disconnect','278990pdyjRX','resumeId','body','getAllStatus'];a0_0x23d2=function(){return _0x4e4822;};return a0_0x23d2();}const a0_0x3a1a12=a0_0x5835;(function(_0x1d3698,_0x4a55f1){const _0x2b08f0=a0_0x5835,_0x337343=_0x1d3698();while(!![]){try{const _0x623e60=-parseInt(_0x2b08f0(0x177))/0x1+-parseInt(_0x2b08f0(0x1a7))/0x2+-parseInt(_0x2b08f0(0x193))/0x3*(-parseInt(_0x2b08f0(0x19a))/0x4)+-parseInt(_0x2b08f0(0x192))/0x5+parseInt(_0x2b08f0(0x15d))/0x6*(parseInt(_0x2b08f0(0x1c1))/0x7)+-parseInt(_0x2b08f0(0x161))/0x8+parseInt(_0x2b08f0(0x17c))/0x9*(parseInt(_0x2b08f0(0x173))/0xa);if(_0x623e60===_0x4a55f1)break;else _0x337343['push'](_0x337343['shift']());}catch(_0x4461bc){_0x337343['push'](_0x337343['shift']());}}}(a0_0x23d2,0x261e4));import{EventEmitter as a0_0x5daa22}from'events';import{hostname as a0_0x464838}from'os';function a0_0x5835(_0x957e00,_0x566d9f){_0x957e00=_0x957e00-0x148;const _0x23d2d3=a0_0x23d2();let _0x583538=_0x23d2d3[_0x957e00];return _0x583538;}var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x4b51a8,_0x4d93bb)=>(_0x4b51a8??_0x4d93bb)[a0_0x3a1a12(0x189)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x3a1a12(0x1ab)](0x0,0xf0);function N(_0xdbc7f0){const _0x1d8edf=a0_0x3a1a12;return(_0xdbc7f0 instanceof Error?_0xdbc7f0[_0x1d8edf(0x164)]:String(_0xdbc7f0??_0x1d8edf(0x1b7)))[_0x1d8edf(0x189)](K,'[REDACTED]')[_0x1d8edf(0x189)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x1d8edf(0x1ab)](0x0,0xf0);}function O(_0xd67bf7,_0xadf39f=process.env.ANET_TASK_TRACE_FORMAT===a0_0x3a1a12(0x15c)){const _0x463e0a=a0_0x3a1a12;if(_0xadf39f)return JSON[_0x463e0a(0x14a)](_0xd67bf7);let _0x3bac33=L(_0xd67bf7[_0x463e0a(0x185)],_0x463e0a(0x16e)),_0x53ca24=L(_0xd67bf7[_0x463e0a(0x1a2)],_0x463e0a(0x19e)),_0x535b30=_0xd67bf7['error_code']?_0x463e0a(0x198)+_0xd67bf7[_0x463e0a(0x1b6)]+':'+(_0xd67bf7[_0x463e0a(0x1b9)]??''):'';return _0x463e0a(0x165)+_0xd67bf7[_0x463e0a(0x14f)]+_0x463e0a(0x191)+L(_0xd67bf7[_0x463e0a(0x18d)],_0x463e0a(0x15f))+_0x463e0a(0x18b)+L(_0xd67bf7['to_alias'],'<unknown>')+_0x463e0a(0x16b)+_0x53ca24+_0x463e0a(0x163)+_0x3bac33+_0x463e0a(0x151)+L(_0xd67bf7['network_id'],_0x463e0a(0x15f))+_0x463e0a(0x16f)+_0xd67bf7[_0x463e0a(0x1ad)]+_0x463e0a(0x190)+_0xd67bf7[_0x463e0a(0x18e)]+'\x20lifecycle='+_0xd67bf7['lifecycle_tracking']+_0x535b30;}function U(_0x3a0a81){const _0x417d9b=a0_0x3a1a12;return{'event':{'sending':_0x417d9b(0x1a5),'delivered':_0x417d9b(0x196),'failed':_0x417d9b(0x182),'acked':_0x417d9b(0x17b),'started':'task.started','replied':_0x417d9b(0x14d),'expired':_0x417d9b(0x160)}[_0x3a0a81[_0x417d9b(0x14f)]],..._0x3a0a81};}function j(_0x1b8d8d){const _0x32eac6=a0_0x3a1a12;let _0x433685=_0x1b8d8d?.[_0x32eac6(0x1a2)]||_0x1b8d8d?.[_0x32eac6(0x179)]||_0x1b8d8d?.['id'];if(_0x433685)return String(_0x433685);let _0x1232c4=_0x1b8d8d?.[_0x32eac6(0x14c)]?.[0x0]?.[_0x32eac6(0x1be)];if(typeof _0x1232c4!==_0x32eac6(0x1b8))return null;try{let _0x2a8f64=JSON[_0x32eac6(0x197)](_0x1232c4);return _0x2a8f64?.[_0x32eac6(0x1a2)]||_0x2a8f64?.[_0x32eac6(0x179)]||_0x2a8f64?.['id']||null;}catch{return null;}}async function X(_0x301e56,_0x30f01f){const _0x4eac14=a0_0x3a1a12;let _0x40f3a9=_0x30f01f['now']??Date[_0x4eac14(0x1bd)],_0x56f9c1=_0x40f3a9(),_0x4f7d48=(_0x1653e2,_0x320f0b,_0x52d10f,_0x3d33fa)=>{const _0x5dfc6c=_0x4eac14;_0x30f01f['log'](O(U({'from_alias':_0x301e56[_0x5dfc6c(0x16c)],'to_alias':_0x301e56[_0x5dfc6c(0x18c)],'task_id':_0x320f0b,'parent_task_id':_0x301e56['parentTaskId'],'network_id':_0x301e56[_0x5dfc6c(0x1a4)],'transport':_0x301e56[_0x5dfc6c(0x1ad)],'status':_0x1653e2,'duration_ms':_0x40f3a9()-_0x56f9c1,'lifecycle_tracking':_0x301e56['lifecycleTracking'],..._0x52d10f!==void 0x0?{'error_code':_0x3d33fa||_0x5dfc6c(0x194),'error_message':N(_0x52d10f)}:{}})));};_0x4f7d48('sending',null);try{let _0x296e25=await _0x30f01f[_0x4eac14(0x1ba)](),_0x3a84da=j(_0x296e25);if(_0x3a84da)_0x4f7d48('delivered',_0x3a84da);else{if(_0x296e25?.['ok']===!0x1||_0x296e25?.[_0x4eac14(0x1b2)])_0x4f7d48('failed',_0x3a84da,_0x296e25?.[_0x4eac14(0x1b2)]||_0x4eac14(0x1bf),_0x4eac14(0x157));else _0x4f7d48(_0x4eac14(0x1c3),null,'CommHub\x20response\x20omitted\x20task_id',_0x4eac14(0x181));}return _0x296e25;}catch(_0xef5415){throw _0x4f7d48(_0x4eac14(0x1c3),null,_0xef5415,'send_failed'),_0xef5415;}}async function Y(_0x5a0d20,_0x2ca76d){const _0x594551=a0_0x3a1a12;return X({'fromAlias':_0x5a0d20['fromAlias'],'toAlias':_0x5a0d20[_0x594551(0x1a0)],'parentTaskId':_0x5a0d20['parentTaskId']||null,'networkId':_0x5a0d20[_0x594551(0x1a4)]||null,'transport':'mcp_http','lifecycleTracking':_0x594551(0x187)},_0x2ca76d);}class $ extends a0_0x5daa22{[a0_0x3a1a12(0x1a1)];[a0_0x3a1a12(0x1a0)];['token'];['agent'];[a0_0x3a1a12(0x174)];['heartbeatInterval'];['reconnectDelay'];[a0_0x3a1a12(0x170)];[a0_0x3a1a12(0x19f)];[a0_0x3a1a12(0x154)]=!0x1;constructor(_0x2cd5ac){const _0x13af5c=a0_0x3a1a12;super();if(this[_0x13af5c(0x1a1)]=_0x2cd5ac[_0x13af5c(0x1a1)][_0x13af5c(0x189)](/\/$/,''),this[_0x13af5c(0x1a0)]=_0x2cd5ac[_0x13af5c(0x1a0)],this[_0x13af5c(0x169)]=_0x2cd5ac[_0x13af5c(0x169)],this['agent']=_0x2cd5ac[_0x13af5c(0x159)]||_0x13af5c(0x195),this[_0x13af5c(0x174)]=_0x13af5c(0x148)+_0x2cd5ac[_0x13af5c(0x1a0)]+'-'+Date[_0x13af5c(0x1bd)]()[_0x13af5c(0x1ae)](0x24),this['heartbeatInterval']=_0x2cd5ac[_0x13af5c(0x1aa)]??0x2bf20,this['reconnectDelay']=_0x2cd5ac[_0x13af5c(0x166)]??0xbb8,_0x2cd5ac['autoConnect']!==!0x1)this[_0x13af5c(0x18a)]();}[a0_0x3a1a12(0x1c2)](_0x234469){const _0x3d67a9=a0_0x3a1a12;console[_0x3d67a9(0x1c2)]('['+new Date()[_0x3d67a9(0x1af)]()[_0x3d67a9(0x1ab)](0x0,0x8)+_0x3d67a9(0x178)+this[_0x3d67a9(0x1a0)]+']\x20'+_0x234469);}async[a0_0x3a1a12(0x150)](_0x42d950,_0x2b811e){const _0x136537=a0_0x3a1a12;let _0x4d5081={'Content-Type':_0x136537(0x149),'Accept':'application/json,\x20text/event-stream'};if(this[_0x136537(0x169)])_0x4d5081[_0x136537(0x17d)]=_0x136537(0x19d)+this[_0x136537(0x169)];let _0x5e3d4a=await(await fetch(this[_0x136537(0x1a1)]+_0x136537(0x1a9),{'method':_0x136537(0x199),'headers':_0x4d5081,'body':JSON[_0x136537(0x14a)]({'jsonrpc':_0x136537(0x152),'id':Date[_0x136537(0x1bd)](),'method':_0x136537(0x14e),'params':{'name':_0x42d950,'arguments':_0x2b811e}})}))[_0x136537(0x1be)](),_0x3b43fc=_0x5e3d4a[_0x136537(0x180)](/data: (.+)/),_0x509fcc=_0x3b43fc?JSON[_0x136537(0x197)](_0x3b43fc[0x1]):JSON[_0x136537(0x197)](_0x5e3d4a),_0x390b97=_0x509fcc?.[_0x136537(0x19b)]?.[_0x136537(0x14c)]?.[0x0]?.[_0x136537(0x1be)];return _0x390b97?JSON[_0x136537(0x197)](_0x390b97):_0x509fcc;}async[a0_0x3a1a12(0x18a)](){const _0x145218=a0_0x3a1a12;if(this[_0x145218(0x154)])return;this[_0x145218(0x154)]=!0x0,await this['status'](_0x145218(0x162)),this[_0x145218(0x1c2)]('registered'),this['heartbeatTimer']=setInterval(()=>{const _0x5cd84c=_0x145218;this[_0x5cd84c(0x14f)](_0x5cd84c(0x162))[_0x5cd84c(0x15b)](_0x4b4778=>this[_0x5cd84c(0x1c2)](_0x5cd84c(0x1a3)+_0x4b4778[_0x5cd84c(0x164)]));},this['heartbeatInterval']),this[_0x145218(0x17e)]();}async[a0_0x3a1a12(0x172)](){const _0x3b45b7=a0_0x3a1a12;if(this[_0x3b45b7(0x154)]=!0x1,this[_0x3b45b7(0x19f)]?.[_0x3b45b7(0x15e)](),this['heartbeatTimer'])clearInterval(this[_0x3b45b7(0x170)]);await this['status']('offline')['catch'](()=>{}),this[_0x3b45b7(0x1c2)]('disconnected');}async[a0_0x3a1a12(0x1ba)](_0x291bb9,_0x47b85f,_0x504cd2=a0_0x3a1a12(0x156)){const _0x3f8ca4=a0_0x3a1a12;return Y({'alias':_0x291bb9,'fromAlias':this[_0x3f8ca4(0x1a0)]},{'log':_0xa65b0b=>console[_0x3f8ca4(0x1c2)](_0xa65b0b),'send':()=>this['call'](_0x3f8ca4(0x1b4),{'alias':_0x291bb9,'task':_0x47b85f,'priority':_0x504cd2,'from_session':this['alias']})});}async[a0_0x3a1a12(0x164)](_0x4cff8e,_0x26288e){const _0x546899=a0_0x3a1a12;return this['call'](_0x546899(0x171),{'alias':_0x4cff8e,'message':_0x26288e,'from_session':this[_0x546899(0x1a0)]});}async[a0_0x3a1a12(0x1a6)](_0x2545a8,_0x3b3ae4,_0x211b97=a0_0x3a1a12(0x15a)){const _0x1e02d4=a0_0x3a1a12;return this[_0x1e02d4(0x150)](_0x1e02d4(0x153),{'in_reply_to':_0x2545a8,'text':_0x3b3ae4,'status':_0x211b97});}async['status'](_0x2deebb,_0x55bd25){const _0x21f269=a0_0x3a1a12;return this[_0x21f269(0x150)]('report_status',{'resume_id':this[_0x21f269(0x174)],'alias':this[_0x21f269(0x1a0)],'status':_0x2deebb,'server':a0_0x464838(),'hostname':a0_0x464838(),'agent':this[_0x21f269(0x159)],'project_dir':process[_0x21f269(0x19c)](),..._0x55bd25});}async[a0_0x3a1a12(0x176)](){const _0x1522cd=a0_0x3a1a12;return this[_0x1522cd(0x150)](_0x1522cd(0x18f),{});}async[a0_0x3a1a12(0x167)](_0x4d93fc,_0x3931bb){const _0x3b1ce5=a0_0x3a1a12;return this[_0x3b1ce5(0x150)](_0x3b1ce5(0x167),{'message':_0x4d93fc,'filter_server':_0x3931bb?.['server'],'filter_status':_0x3931bb?.[_0x3b1ce5(0x14f)]});}async[a0_0x3a1a12(0x17e)](){const _0x9d9aa7=a0_0x3a1a12;let _0x52bbfb=encodeURIComponent(this['alias']),_0x1e2838=this['url']+'/events/'+_0x52bbfb,_0x5ba814=this[_0x9d9aa7(0x166)];while(this[_0x9d9aa7(0x154)]){try{this[_0x9d9aa7(0x19f)]=new AbortController();let _0x486b19={'Accept':'text/event-stream'};if(this['token'])_0x486b19[_0x9d9aa7(0x17d)]=_0x9d9aa7(0x19d)+this[_0x9d9aa7(0x169)];let _0x3cd090=await fetch(_0x1e2838,{'headers':_0x486b19,'signal':this[_0x9d9aa7(0x19f)][_0x9d9aa7(0x1bc)]});if(!_0x3cd090['ok']||!_0x3cd090['body']){this['log'](_0x9d9aa7(0x168)+_0x3cd090['status']),await this[_0x9d9aa7(0x16a)](_0x5ba814),_0x5ba814=Math['min'](_0x5ba814*1.5,0xea60);continue;}_0x5ba814=this[_0x9d9aa7(0x166)];let _0x5e0263=_0x3cd090[_0x9d9aa7(0x175)][_0x9d9aa7(0x16d)](),_0xeb3238=new TextDecoder(),_0x5e7e13='';while(this['running']){let {done:_0x42ecc4,value:_0x5524ec}=await _0x5e0263[_0x9d9aa7(0x1b1)]();if(_0x42ecc4)break;_0x5e7e13+=_0xeb3238['decode'](_0x5524ec,{'stream':!0x0});let _0x32283a=_0x5e7e13[_0x9d9aa7(0x184)]('\x0a');_0x5e7e13=_0x32283a[_0x9d9aa7(0x1c0)]()||'';for(let _0x25f5c1 of _0x32283a){if(!_0x25f5c1['startsWith'](_0x9d9aa7(0x1b3)))continue;try{let _0x4df8be=JSON[_0x9d9aa7(0x197)](_0x25f5c1['slice'](0x6));if(_0x4df8be[_0x9d9aa7(0x1b0)]===_0x9d9aa7(0x14b)){this['log']('SSE\x20connected'),this[_0x9d9aa7(0x1ac)]('connected');continue;}if(_0x4df8be[_0x9d9aa7(0x1b0)]===_0x9d9aa7(0x1c4)||_0x4df8be[_0x9d9aa7(0x1b0)]==='new_message'||_0x4df8be['type']===_0x9d9aa7(0x167))await this[_0x9d9aa7(0x186)]();}catch{}}}}catch(_0x214f77){if(_0x214f77[_0x9d9aa7(0x17a)]===_0x9d9aa7(0x17f))break;this[_0x9d9aa7(0x1ac)](_0x9d9aa7(0x1b2),_0x214f77),this[_0x9d9aa7(0x1c2)]('SSE\x20error:\x20'+_0x214f77[_0x9d9aa7(0x164)]);}if(this[_0x9d9aa7(0x154)])this[_0x9d9aa7(0x1ac)]('disconnected'),this[_0x9d9aa7(0x1c2)]('SSE\x20reconnecting\x20in\x20'+_0x5ba814/0x3e8+_0x9d9aa7(0x183)),await this[_0x9d9aa7(0x16a)](_0x5ba814),_0x5ba814=Math['min'](_0x5ba814*1.5,0xea60);}}async['processInbox'](){const _0x1776dc=a0_0x3a1a12;try{let _0x5d756f=(await this['call'](_0x1776dc(0x1bb),{'alias':this[_0x1776dc(0x1a0)],'limit':0xa}))?.[_0x1776dc(0x155)]||[];for(let _0x10bc65 of _0x5d756f)await this[_0x1776dc(0x150)](_0x1776dc(0x1a8),{'alias':this[_0x1776dc(0x1a0)],'message_id':_0x10bc65['id']}),this[_0x1776dc(0x1c2)]('←\x20'+_0x10bc65[_0x1776dc(0x158)]+':\x20'+_0x10bc65[_0x1776dc(0x14c)]['slice'](0x0,0x3c)),this[_0x1776dc(0x1ac)](_0x1776dc(0x188),_0x10bc65),this['emit'](_0x1776dc(0x164),_0x10bc65);}catch(_0x393fe7){this['log'](_0x1776dc(0x1b5)+_0x393fe7[_0x1776dc(0x164)]);}}[a0_0x3a1a12(0x16a)](_0x2b8e8c){return new Promise(_0x33e90b=>setTimeout(_0x33e90b,_0x2b8e8c));}}var F=$;export{F as default,$ as CommHub};
|