@sleep2agi/agent-network 2.3.0-preview.246 → 2.3.0-preview.247
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_0x2e1d66=a0_0x53f5;(function(_0x300e8c,_0x584917){const _0x45369d=a0_0x53f5,_0xa54d=_0x300e8c();while(!![]){try{const _0xa1f7f6=parseInt(_0x45369d(0x22a))/0x1*(parseInt(_0x45369d(0x1cf))/0x2)+parseInt(_0x45369d(0x1d0))/0x3*(parseInt(_0x45369d(0x232))/0x4)+parseInt(_0x45369d(0x207))/0x5*(-parseInt(_0x45369d(0x228))/0x6)+-parseInt(_0x45369d(0x214))/0x7*(parseInt(_0x45369d(0x1ce))/0x8)+parseInt(_0x45369d(0x1d9))/0x9+-parseInt(_0x45369d(0x212))/0xa*(parseInt(_0x45369d(0x1e2))/0xb)+parseInt(_0x45369d(0x1f0))/0xc;if(_0xa1f7f6===_0x584917)break;else _0xa54d['push'](_0xa54d['shift']());}catch(_0x478c9b){_0xa54d['push'](_0xa54d['shift']());}}}(a0_0x3f0d,0x58177));import{EventEmitter as a0_0x561018}from'events';import{hostname as a0_0x5321be}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x2e7b70,_0x1c474e)=>(_0x2e7b70??_0x1c474e)[a0_0x2e1d66(0x23b)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function a0_0x53f5(_0x2165a2,_0x1849de){_0x2165a2=_0x2165a2-0x1b2;const _0x3f0db0=a0_0x3f0d();let _0x53f546=_0x3f0db0[_0x2165a2];return _0x53f546;}function N(_0x2b96f6){const _0x16eeba=a0_0x2e1d66;return(_0x2b96f6 instanceof Error?_0x2b96f6[_0x16eeba(0x1dc)]:String(_0x2b96f6??_0x16eeba(0x204)))[_0x16eeba(0x23b)](K,_0x16eeba(0x1f1))[_0x16eeba(0x23b)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x16eeba(0x20b)](0x0,0xf0);}function O(_0x2289f3,_0x4465fb=process.env.ANET_TASK_TRACE_FORMAT===a0_0x2e1d66(0x1fd)){const _0x508ac6=a0_0x2e1d66;if(_0x4465fb)return JSON[_0x508ac6(0x1c2)](_0x2289f3);let _0x33b7b0=L(_0x2289f3[_0x508ac6(0x1ed)],_0x508ac6(0x1b2)),_0xd61be=L(_0x2289f3[_0x508ac6(0x20d)],_0x508ac6(0x1d1)),_0x1a21b2=_0x2289f3['error_code']?_0x508ac6(0x1e5)+_0x2289f3[_0x508ac6(0x1d7)]+':'+(_0x2289f3[_0x508ac6(0x1c0)]??''):'';return _0x508ac6(0x1b9)+_0x2289f3[_0x508ac6(0x222)]+_0x508ac6(0x219)+L(_0x2289f3[_0x508ac6(0x1be)],_0x508ac6(0x201))+_0x508ac6(0x23a)+L(_0x2289f3[_0x508ac6(0x211)],_0x508ac6(0x201))+_0x508ac6(0x1fb)+_0xd61be+_0x508ac6(0x22c)+_0x33b7b0+_0x508ac6(0x1bc)+L(_0x2289f3[_0x508ac6(0x235)],_0x508ac6(0x201))+_0x508ac6(0x224)+_0x2289f3[_0x508ac6(0x1e3)]+_0x508ac6(0x1b5)+_0x2289f3['duration_ms']+_0x508ac6(0x1f7)+_0x2289f3[_0x508ac6(0x1d4)]+_0x1a21b2;}function U(_0x25ec87){const _0x5098ce=a0_0x2e1d66;return{'event':{'sending':_0x5098ce(0x1c4),'delivered':_0x5098ce(0x1c6),'failed':_0x5098ce(0x1fe),'acked':_0x5098ce(0x1c1),'started':_0x5098ce(0x216),'replied':'task.replied','expired':_0x5098ce(0x230)}[_0x25ec87[_0x5098ce(0x222)]],..._0x25ec87};}function j(_0x30a116){const _0xccbc17=a0_0x2e1d66;let _0x40884f=_0x30a116?.['task_id']||_0x30a116?.['message_id']||_0x30a116?.['id'];if(_0x40884f)return String(_0x40884f);let _0x385d2d=_0x30a116?.[_0xccbc17(0x21f)]?.[0x0]?.['text'];if(typeof _0x385d2d!==_0xccbc17(0x22d))return null;try{let _0xdc82e3=JSON[_0xccbc17(0x1e9)](_0x385d2d);return _0xdc82e3?.[_0xccbc17(0x20d)]||_0xdc82e3?.[_0xccbc17(0x1d5)]||_0xdc82e3?.['id']||null;}catch{return null;}}async function X(_0x5b2a67,_0x509dd6){const _0x2d5f57=a0_0x2e1d66;let _0xd2ca1a=_0x509dd6[_0x2d5f57(0x1f8)]??Date[_0x2d5f57(0x1f8)],_0x176844=_0xd2ca1a(),_0xf1593d=(_0x37f74d,_0x3563b5,_0x50a272,_0x24cae2)=>{const _0x3b43f0=_0x2d5f57;_0x509dd6[_0x3b43f0(0x1cd)](O(U({'from_alias':_0x5b2a67['fromAlias'],'to_alias':_0x5b2a67[_0x3b43f0(0x1e4)],'task_id':_0x3563b5,'parent_task_id':_0x5b2a67['parentTaskId'],'network_id':_0x5b2a67['networkId'],'transport':_0x5b2a67[_0x3b43f0(0x1e3)],'status':_0x37f74d,'duration_ms':_0xd2ca1a()-_0x176844,'lifecycle_tracking':_0x5b2a67[_0x3b43f0(0x1b8)],..._0x50a272!==void 0x0?{'error_code':_0x24cae2||_0x3b43f0(0x238),'error_message':N(_0x50a272)}:{}})));};_0xf1593d(_0x2d5f57(0x1c5),null);try{let _0x1e83c5=await _0x509dd6[_0x2d5f57(0x1dd)](),_0x11f5dc=j(_0x1e83c5);if(_0x11f5dc)_0xf1593d(_0x2d5f57(0x1eb),_0x11f5dc);else{if(_0x1e83c5?.['ok']===!0x1||_0x1e83c5?.['error'])_0xf1593d(_0x2d5f57(0x237),_0x11f5dc,_0x1e83c5?.[_0x2d5f57(0x1e7)]||_0x2d5f57(0x1f6),_0x2d5f57(0x1e1));else _0xf1593d('failed',null,'CommHub\x20response\x20omitted\x20task_id',_0x2d5f57(0x1ef));}return _0x1e83c5;}catch(_0x424852){throw _0xf1593d(_0x2d5f57(0x237),null,_0x424852,_0x2d5f57(0x238)),_0x424852;}}async function Y(_0x590e96,_0x5824b4){const _0x54cb68=a0_0x2e1d66;return X({'fromAlias':_0x590e96[_0x54cb68(0x1f4)],'toAlias':_0x590e96[_0x54cb68(0x1e8)],'parentTaskId':_0x590e96[_0x54cb68(0x1cc)]||null,'networkId':_0x590e96[_0x54cb68(0x210)]||null,'transport':_0x54cb68(0x1fc),'lifecycleTracking':'not_tracked'},_0x5824b4);}class $ extends a0_0x561018{[a0_0x2e1d66(0x1d3)];[a0_0x2e1d66(0x1e8)];['token'];['agent'];['resumeId'];['heartbeatInterval'];[a0_0x2e1d66(0x20a)];[a0_0x2e1d66(0x229)];[a0_0x2e1d66(0x1bb)];['running']=!0x1;constructor(_0x24b6a1){const _0x56c3e1=a0_0x2e1d66;super();if(this['url']=_0x24b6a1['url'][_0x56c3e1(0x23b)](/\/$/,''),this[_0x56c3e1(0x1e8)]=_0x24b6a1[_0x56c3e1(0x1e8)],this['token']=_0x24b6a1[_0x56c3e1(0x20c)],this[_0x56c3e1(0x218)]=_0x24b6a1[_0x56c3e1(0x218)]||_0x56c3e1(0x208),this[_0x56c3e1(0x1e6)]=_0x56c3e1(0x1da)+_0x24b6a1[_0x56c3e1(0x1e8)]+'-'+Date[_0x56c3e1(0x1f8)]()[_0x56c3e1(0x1b4)](0x24),this['heartbeatInterval']=_0x24b6a1[_0x56c3e1(0x21a)]??0x2bf20,this[_0x56c3e1(0x20a)]=_0x24b6a1['reconnectDelay']??0xbb8,_0x24b6a1['autoConnect']!==!0x1)this[_0x56c3e1(0x1c8)]();}[a0_0x2e1d66(0x1cd)](_0x650a70){const _0x222959=a0_0x2e1d66;console[_0x222959(0x1cd)]('['+new Date()['toTimeString']()['slice'](0x0,0x8)+_0x222959(0x22e)+this[_0x222959(0x1e8)]+']\x20'+_0x650a70);}async['call'](_0x51db64,_0x4dbbf6){const _0x1c0537=a0_0x2e1d66;let _0x5b1282={'Content-Type':_0x1c0537(0x200),'Accept':_0x1c0537(0x1bd)};if(this[_0x1c0537(0x20c)])_0x5b1282['Authorization']=_0x1c0537(0x20e)+this[_0x1c0537(0x20c)];let _0xd5cb4a=await(await fetch(this[_0x1c0537(0x1d3)]+_0x1c0537(0x1e0),{'method':_0x1c0537(0x226),'headers':_0x5b1282,'body':JSON['stringify']({'jsonrpc':_0x1c0537(0x213),'id':Date[_0x1c0537(0x1f8)](),'method':'tools/call','params':{'name':_0x51db64,'arguments':_0x4dbbf6}})}))[_0x1c0537(0x209)](),_0x2eebf=_0xd5cb4a[_0x1c0537(0x1d8)](/data: (.+)/),_0x5b025d=_0x2eebf?JSON['parse'](_0x2eebf[0x1]):JSON[_0x1c0537(0x1e9)](_0xd5cb4a),_0x15f0a0=_0x5b025d?.[_0x1c0537(0x236)]?.[_0x1c0537(0x21f)]?.[0x0]?.[_0x1c0537(0x209)];return _0x15f0a0?JSON[_0x1c0537(0x1e9)](_0x15f0a0):_0x5b025d;}async[a0_0x2e1d66(0x1c8)](){const _0x555d91=a0_0x2e1d66;if(this[_0x555d91(0x239)])return;this['running']=!0x0,await this[_0x555d91(0x222)](_0x555d91(0x1cb)),this['log'](_0x555d91(0x223)),this[_0x555d91(0x229)]=setInterval(()=>{const _0x486f98=_0x555d91;this['status'](_0x486f98(0x1cb))[_0x486f98(0x233)](_0x4252f8=>this[_0x486f98(0x1cd)](_0x486f98(0x1ba)+_0x4252f8[_0x486f98(0x1dc)]));},this[_0x555d91(0x21a)]),this[_0x555d91(0x1f9)]();}async[a0_0x2e1d66(0x1b3)](){const _0xf0db2c=a0_0x2e1d66;if(this[_0xf0db2c(0x239)]=!0x1,this[_0xf0db2c(0x1bb)]?.[_0xf0db2c(0x1de)](),this[_0xf0db2c(0x229)])clearInterval(this[_0xf0db2c(0x229)]);await this[_0xf0db2c(0x222)](_0xf0db2c(0x1b6))[_0xf0db2c(0x233)](()=>{}),this[_0xf0db2c(0x1cd)]('disconnected');}async[a0_0x2e1d66(0x1dd)](_0x2378b6,_0x540ac1,_0x8a4af2=a0_0x2e1d66(0x22b)){const _0x23d759=a0_0x2e1d66;return Y({'alias':_0x2378b6,'fromAlias':this[_0x23d759(0x1e8)]},{'log':_0x95362=>console['log'](_0x95362),'send':()=>this[_0x23d759(0x23c)](_0x23d759(0x234),{'alias':_0x2378b6,'task':_0x540ac1,'priority':_0x8a4af2,'from_session':this[_0x23d759(0x1e8)]})});}async[a0_0x2e1d66(0x1dc)](_0x5bae5e,_0x4839f8){const _0x400909=a0_0x2e1d66;return this[_0x400909(0x23c)](_0x400909(0x20f),{'alias':_0x5bae5e,'message':_0x4839f8,'from_session':this['alias']});}async['reply'](_0x197678,_0x1792a5,_0xc14eba=a0_0x2e1d66(0x1fa)){const _0x4dbec1=a0_0x2e1d66;return this['call'](_0x4dbec1(0x21d),{'in_reply_to':_0x197678,'text':_0x1792a5,'status':_0xc14eba});}async[a0_0x2e1d66(0x222)](_0x45bdb5,_0x183f8f){const _0x29a335=a0_0x2e1d66;return this[_0x29a335(0x23c)](_0x29a335(0x1ff),{'resume_id':this['resumeId'],'alias':this[_0x29a335(0x1e8)],'status':_0x45bdb5,'server':a0_0x5321be(),'hostname':a0_0x5321be(),'agent':this[_0x29a335(0x218)],'project_dir':process[_0x29a335(0x1b7)](),..._0x183f8f});}async[a0_0x2e1d66(0x22f)](){const _0x447cde=a0_0x2e1d66;return this[_0x447cde(0x23c)](_0x447cde(0x1ca),{});}async[a0_0x2e1d66(0x1ec)](_0x186230,_0xe99726){const _0x267746=a0_0x2e1d66;return this[_0x267746(0x23c)]('broadcast',{'message':_0x186230,'filter_server':_0xe99726?.[_0x267746(0x21b)],'filter_status':_0xe99726?.[_0x267746(0x222)]});}async[a0_0x2e1d66(0x1f9)](){const _0x3232ef=a0_0x2e1d66;let _0x2c9864=encodeURIComponent(this[_0x3232ef(0x1e8)]),_0x58eaba=this['url']+_0x3232ef(0x1bf)+_0x2c9864,_0x2f47cc=this['reconnectDelay'];while(this[_0x3232ef(0x239)]){try{this[_0x3232ef(0x1bb)]=new AbortController();let _0x153f3f={'Accept':_0x3232ef(0x220)};if(this['token'])_0x153f3f[_0x3232ef(0x1f3)]=_0x3232ef(0x20e)+this[_0x3232ef(0x20c)];let _0x1e45b7=await fetch(_0x58eaba,{'headers':_0x153f3f,'signal':this['sseAbort'][_0x3232ef(0x21e)]});if(!_0x1e45b7['ok']||!_0x1e45b7[_0x3232ef(0x1d2)]){this[_0x3232ef(0x1cd)](_0x3232ef(0x1d6)+_0x1e45b7[_0x3232ef(0x222)]),await this[_0x3232ef(0x1c9)](_0x2f47cc),_0x2f47cc=Math[_0x3232ef(0x1df)](_0x2f47cc*1.5,0xea60);continue;}_0x2f47cc=this['reconnectDelay'];let _0x3969aa=_0x1e45b7[_0x3232ef(0x1d2)][_0x3232ef(0x1c3)](),_0x35e2f9=new TextDecoder(),_0x47887d='';while(this['running']){let {done:_0x34785f,value:_0x560e24}=await _0x3969aa[_0x3232ef(0x217)]();if(_0x34785f)break;_0x47887d+=_0x35e2f9[_0x3232ef(0x225)](_0x560e24,{'stream':!0x0});let _0x4808be=_0x47887d[_0x3232ef(0x215)]('\x0a');_0x47887d=_0x4808be[_0x3232ef(0x205)]()||'';for(let _0x2a9b01 of _0x4808be){if(!_0x2a9b01[_0x3232ef(0x21c)]('data:\x20'))continue;try{let _0x2cc122=JSON[_0x3232ef(0x1e9)](_0x2a9b01[_0x3232ef(0x20b)](0x6));if(_0x2cc122[_0x3232ef(0x231)]==='connected'){this[_0x3232ef(0x1cd)]('SSE\x20connected'),this[_0x3232ef(0x1f2)](_0x3232ef(0x206));continue;}if(_0x2cc122[_0x3232ef(0x231)]===_0x3232ef(0x203)||_0x2cc122[_0x3232ef(0x231)]===_0x3232ef(0x1ea)||_0x2cc122['type']===_0x3232ef(0x1ec))await this[_0x3232ef(0x1f5)]();}catch{}}}}catch(_0x4cdbc8){if(_0x4cdbc8[_0x3232ef(0x1db)]==='AbortError')break;this['emit'](_0x3232ef(0x1e7),_0x4cdbc8),this['log']('SSE\x20error:\x20'+_0x4cdbc8[_0x3232ef(0x1dc)]);}if(this[_0x3232ef(0x239)])this[_0x3232ef(0x1f2)]('disconnected'),this[_0x3232ef(0x1cd)]('SSE\x20reconnecting\x20in\x20'+_0x2f47cc/0x3e8+_0x3232ef(0x1ee)),await this['sleep'](_0x2f47cc),_0x2f47cc=Math[_0x3232ef(0x1df)](_0x2f47cc*1.5,0xea60);}}async['processInbox'](){const _0x1a7d92=a0_0x2e1d66;try{let _0x156fbc=(await this[_0x1a7d92(0x23c)](_0x1a7d92(0x221),{'alias':this[_0x1a7d92(0x1e8)],'limit':0xa}))?.[_0x1a7d92(0x202)]||[];for(let _0x49626c of _0x156fbc)await this[_0x1a7d92(0x23c)]('ack_inbox',{'alias':this['alias'],'message_id':_0x49626c['id']}),this[_0x1a7d92(0x1cd)]('←\x20'+_0x49626c[_0x1a7d92(0x1c7)]+':\x20'+_0x49626c[_0x1a7d92(0x21f)][_0x1a7d92(0x20b)](0x0,0x3c)),this[_0x1a7d92(0x1f2)]('task',_0x49626c),this['emit'](_0x1a7d92(0x1dc),_0x49626c);}catch(_0x5bfd11){this[_0x1a7d92(0x1cd)](_0x1a7d92(0x227)+_0x5bfd11['message']);}}[a0_0x2e1d66(0x1c9)](_0x2969ff){return new Promise(_0x5820b4=>setTimeout(_0x5820b4,_0x2969ff));}}function a0_0x3f0d(){const _0x21f5fd=['new_message','delivered','broadcast','parent_task_id','s...','missing_task_id','8851956mfEbiw','[REDACTED]','emit','Authorization','fromAlias','processInbox','CommHub\x20rejected\x20task','\x20lifecycle=','now','connectSSE','completed','\x20task_id=','mcp_http','json','task.send.failed','report_status','application/json','<unknown>','messages','new_task','unknown\x20error','pop','connected','70895HLPsgP','sdk','text','reconnectDelay','slice','token','task_id','Bearer\x20','send_message','networkId','to_alias','10PHhOxh','2.0','1603QzuSoI','split','task.started','read','agent','\x20from=','heartbeatInterval','server','startsWith','send_reply','signal','content','text/event-stream','get_inbox','status','registered','\x20transport=','decode','POST','inbox\x20error:\x20','186SLxbrC','heartbeatTimer','616575WBNYzc','normal','\x20parent_task_id=','string',']\x20[commhub:','getAllStatus','task.expired','type','495124jyoSsi','catch','send_task','network_id','result','failed','send_failed','running','\x20to=','replace','call','<missing>','disconnect','toString','\x20duration_ms=','offline','cwd','lifecycleTracking','[commhub:task]\x20','heartbeat\x20failed:\x20','sseAbort','\x20network_id=','application/json,\x20text/event-stream','from_alias','/events/','error_message','task.ack','stringify','getReader','task.send.start','sending','task.send.delivered','from_session','connect','sleep','get_all_status','idle','parentTaskId','log','11560yVxcUR','2BdgPbx','3ylNufY','<pending>','body','url','lifecycle_tracking','message_id','SSE\x20failed:\x20','error_code','match','2242422znmdCi','sdk-','name','message','send','abort','min','/mcp','send_rejected','6554900SJRXcM','transport','toAlias','\x20error=','resumeId','error','alias','parse'];a0_0x3f0d=function(){return _0x21f5fd;};return a0_0x3f0d();}var F=$;export{F as default,$ as CommHub};
|
|
1
|
+
const a0_0x35e9df=a0_0x1020;(function(_0x50f92e,_0x200685){const _0x13ba64=a0_0x1020,_0x35bb77=_0x50f92e();while(!![]){try{const _0x4b1685=-parseInt(_0x13ba64(0x203))/0x1+-parseInt(_0x13ba64(0x216))/0x2+parseInt(_0x13ba64(0x1d9))/0x3+-parseInt(_0x13ba64(0x1da))/0x4+parseInt(_0x13ba64(0x240))/0x5+parseInt(_0x13ba64(0x228))/0x6*(-parseInt(_0x13ba64(0x20b))/0x7)+parseInt(_0x13ba64(0x21a))/0x8;if(_0x4b1685===_0x200685)break;else _0x35bb77['push'](_0x35bb77['shift']());}catch(_0x187d9f){_0x35bb77['push'](_0x35bb77['shift']());}}}(a0_0x52ef,0x830b2));import{EventEmitter as a0_0x2c774d}from'events';import{hostname as a0_0x1af5e5}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x4253aa,_0x2e36ab)=>(_0x4253aa??_0x2e36ab)[a0_0x35e9df(0x233)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x35e9df(0x223)](0x0,0xf0);function N(_0x53cacf){const _0x1badc5=a0_0x35e9df;return(_0x53cacf instanceof Error?_0x53cacf[_0x1badc5(0x21f)]:String(_0x53cacf??_0x1badc5(0x201)))['replace'](K,'[REDACTED]')[_0x1badc5(0x233)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x2997f3,_0x5c29cc=process.env.ANET_TASK_TRACE_FORMAT===a0_0x35e9df(0x22b)){const _0x663245=a0_0x35e9df;if(_0x5c29cc)return JSON['stringify'](_0x2997f3);let _0x2402e6=L(_0x2997f3[_0x663245(0x1f2)],'<missing>'),_0x21717e=L(_0x2997f3[_0x663245(0x1d3)],'<pending>'),_0x5d0892=_0x2997f3[_0x663245(0x1ee)]?_0x663245(0x1d8)+_0x2997f3['error_code']+':'+(_0x2997f3['error_message']??''):'';return _0x663245(0x1e6)+_0x2997f3[_0x663245(0x214)]+_0x663245(0x221)+L(_0x2997f3[_0x663245(0x1e9)],_0x663245(0x22e))+'\x20to='+L(_0x2997f3[_0x663245(0x1eb)],_0x663245(0x22e))+_0x663245(0x1dc)+_0x21717e+'\x20parent_task_id='+_0x2402e6+_0x663245(0x1f3)+L(_0x2997f3[_0x663245(0x24b)],_0x663245(0x22e))+_0x663245(0x209)+_0x2997f3[_0x663245(0x20c)]+_0x663245(0x23c)+_0x2997f3[_0x663245(0x243)]+_0x663245(0x222)+_0x2997f3['lifecycle_tracking']+_0x5d0892;}function U(_0x65a6cf){const _0x198120=a0_0x35e9df;return{'event':{'sending':_0x198120(0x1ea),'delivered':_0x198120(0x1fa),'failed':_0x198120(0x1de),'acked':_0x198120(0x1e8),'started':_0x198120(0x1e2),'replied':_0x198120(0x22d),'expired':_0x198120(0x1ed)}[_0x65a6cf[_0x198120(0x214)]],..._0x65a6cf};}function a0_0x1020(_0x5d53fd,_0x31541c){_0x5d53fd=_0x5d53fd-0x1d0;const _0x52ef16=a0_0x52ef();let _0x1020dc=_0x52ef16[_0x5d53fd];return _0x1020dc;}function j(_0x404283){const _0x488483=a0_0x35e9df;let _0x1306b6=_0x404283?.['task_id']||_0x404283?.[_0x488483(0x1e7)]||_0x404283?.['id'];if(_0x1306b6)return String(_0x1306b6);let _0x3a7e1b=_0x404283?.[_0x488483(0x204)]?.[0x0]?.['text'];if(typeof _0x3a7e1b!=='string')return null;try{let _0x2847db=JSON[_0x488483(0x1e3)](_0x3a7e1b);return _0x2847db?.[_0x488483(0x1d3)]||_0x2847db?.['message_id']||_0x2847db?.['id']||null;}catch{return null;}}async function X(_0x1e2361,_0x43a826){const _0x3fc7a0=a0_0x35e9df;let _0x5f297a=_0x43a826[_0x3fc7a0(0x217)]??Date[_0x3fc7a0(0x217)],_0x3a20a3=_0x5f297a(),_0x3106c6=(_0x2bc707,_0x263773,_0x1703cf,_0x5047e6)=>{const _0x5580dd=_0x3fc7a0;_0x43a826[_0x5580dd(0x237)](O(U({'from_alias':_0x1e2361[_0x5580dd(0x23b)],'to_alias':_0x1e2361[_0x5580dd(0x1d4)],'task_id':_0x263773,'parent_task_id':_0x1e2361['parentTaskId'],'network_id':_0x1e2361[_0x5580dd(0x232)],'transport':_0x1e2361[_0x5580dd(0x20c)],'status':_0x2bc707,'duration_ms':_0x5f297a()-_0x3a20a3,'lifecycle_tracking':_0x1e2361[_0x5580dd(0x1e4)],..._0x1703cf!==void 0x0?{'error_code':_0x5047e6||_0x5580dd(0x1df),'error_message':N(_0x1703cf)}:{}})));};_0x3106c6(_0x3fc7a0(0x20f),null);try{let _0x4a5ea9=await _0x43a826[_0x3fc7a0(0x211)](),_0xb523b5=j(_0x4a5ea9);if(_0xb523b5)_0x3106c6('delivered',_0xb523b5);else{if(_0x4a5ea9?.['ok']===!0x1||_0x4a5ea9?.[_0x3fc7a0(0x1d7)])_0x3106c6(_0x3fc7a0(0x247),_0xb523b5,_0x4a5ea9?.[_0x3fc7a0(0x1d7)]||_0x3fc7a0(0x1fc),_0x3fc7a0(0x242));else _0x3106c6(_0x3fc7a0(0x247),null,_0x3fc7a0(0x20d),_0x3fc7a0(0x1f1));}return _0x4a5ea9;}catch(_0x1854ca){throw _0x3106c6(_0x3fc7a0(0x247),null,_0x1854ca,_0x3fc7a0(0x1df)),_0x1854ca;}}async function Y(_0xa278ce,_0x467938){const _0x1a4bd1=a0_0x35e9df;return X({'fromAlias':_0xa278ce[_0x1a4bd1(0x23b)],'toAlias':_0xa278ce[_0x1a4bd1(0x238)],'parentTaskId':_0xa278ce[_0x1a4bd1(0x22a)]||null,'networkId':_0xa278ce[_0x1a4bd1(0x232)]||null,'transport':_0x1a4bd1(0x246),'lifecycleTracking':'not_tracked'},_0x467938);}class $ extends a0_0x2c774d{['url'];[a0_0x35e9df(0x238)];['token'];[a0_0x35e9df(0x23e)];['resumeId'];[a0_0x35e9df(0x244)];[a0_0x35e9df(0x220)];[a0_0x35e9df(0x227)];[a0_0x35e9df(0x219)];[a0_0x35e9df(0x1f7)]=!0x1;constructor(_0x5e02a7){const _0xd61ed=a0_0x35e9df;super();if(this['url']=_0x5e02a7[_0xd61ed(0x1e0)][_0xd61ed(0x233)](/\/$/,''),this[_0xd61ed(0x238)]=_0x5e02a7[_0xd61ed(0x238)],this[_0xd61ed(0x230)]=_0x5e02a7[_0xd61ed(0x230)],this[_0xd61ed(0x23e)]=_0x5e02a7[_0xd61ed(0x23e)]||'sdk',this['resumeId']='sdk-'+_0x5e02a7[_0xd61ed(0x238)]+'-'+Date[_0xd61ed(0x217)]()[_0xd61ed(0x1fd)](0x24),this['heartbeatInterval']=_0x5e02a7[_0xd61ed(0x244)]??0x2bf20,this['reconnectDelay']=_0x5e02a7['reconnectDelay']??0xbb8,_0x5e02a7[_0xd61ed(0x200)]!==!0x1)this['connect']();}[a0_0x35e9df(0x237)](_0x4754a0){const _0x5867dc=a0_0x35e9df;console['log']('['+new Date()['toTimeString']()['slice'](0x0,0x8)+']\x20[commhub:'+this[_0x5867dc(0x238)]+']\x20'+_0x4754a0);}async[a0_0x35e9df(0x23d)](_0x5929ee,_0x5d8efe){const _0x581089=a0_0x35e9df;let _0x1b15ef={'Content-Type':_0x581089(0x1f5),'Accept':'application/json,\x20text/event-stream'};if(this[_0x581089(0x230)])_0x1b15ef['Authorization']=_0x581089(0x21e)+this[_0x581089(0x230)];let _0x281ead=await(await fetch(this[_0x581089(0x1e0)]+_0x581089(0x1fb),{'method':_0x581089(0x224),'headers':_0x1b15ef,'body':JSON[_0x581089(0x23f)]({'jsonrpc':_0x581089(0x21c),'id':Date[_0x581089(0x217)](),'method':_0x581089(0x239),'params':{'name':_0x5929ee,'arguments':_0x5d8efe}})}))[_0x581089(0x1dd)](),_0x46d7a2=_0x281ead[_0x581089(0x248)](/data: (.+)/),_0x17f155=_0x46d7a2?JSON[_0x581089(0x1e3)](_0x46d7a2[0x1]):JSON['parse'](_0x281ead),_0x6e3976=_0x17f155?.[_0x581089(0x1f9)]?.[_0x581089(0x204)]?.[0x0]?.[_0x581089(0x1dd)];return _0x6e3976?JSON['parse'](_0x6e3976):_0x17f155;}async[a0_0x35e9df(0x22c)](){const _0x34efce=a0_0x35e9df;if(this['running'])return;this[_0x34efce(0x1f7)]=!0x0,await this[_0x34efce(0x214)](_0x34efce(0x210)),this['log']('registered'),this[_0x34efce(0x227)]=setInterval(()=>{const _0x41f8b1=_0x34efce;this[_0x41f8b1(0x214)]('idle')[_0x41f8b1(0x23a)](_0x2401c4=>this[_0x41f8b1(0x237)](_0x41f8b1(0x225)+_0x2401c4['message']));},this[_0x34efce(0x244)]),this[_0x34efce(0x234)]();}async[a0_0x35e9df(0x202)](){const _0x5c9732=a0_0x35e9df;if(this[_0x5c9732(0x1f7)]=!0x1,this[_0x5c9732(0x219)]?.[_0x5c9732(0x1e1)](),this[_0x5c9732(0x227)])clearInterval(this['heartbeatTimer']);await this['status']('offline')[_0x5c9732(0x23a)](()=>{}),this[_0x5c9732(0x237)](_0x5c9732(0x1e5));}async[a0_0x35e9df(0x211)](_0x3aa46f,_0x58a0a6,_0xb8b238='normal'){const _0x566caa=a0_0x35e9df;return Y({'alias':_0x3aa46f,'fromAlias':this[_0x566caa(0x238)]},{'log':_0x4e8042=>console['log'](_0x4e8042),'send':()=>this['call'](_0x566caa(0x1d5),{'alias':_0x3aa46f,'task':_0x58a0a6,'priority':_0xb8b238,'from_session':this[_0x566caa(0x238)]})});}async[a0_0x35e9df(0x21f)](_0x2eb8c5,_0x4f42fe){const _0x56a39b=a0_0x35e9df;return this['call'](_0x56a39b(0x21d),{'alias':_0x2eb8c5,'message':_0x4f42fe,'from_session':this[_0x56a39b(0x238)]});}async[a0_0x35e9df(0x208)](_0xdad55f,_0x4aeb61,_0x96b4ab=a0_0x35e9df(0x1d1)){const _0xdcec24=a0_0x35e9df;return this[_0xdcec24(0x23d)](_0xdcec24(0x22f),{'in_reply_to':_0xdad55f,'text':_0x4aeb61,'status':_0x96b4ab});}async[a0_0x35e9df(0x214)](_0x45c425,_0x69827c){const _0x446f7b=a0_0x35e9df;return this[_0x446f7b(0x23d)](_0x446f7b(0x1d6),{'resume_id':this[_0x446f7b(0x21b)],'alias':this[_0x446f7b(0x238)],'status':_0x45c425,'server':a0_0x1af5e5(),'hostname':a0_0x1af5e5(),'agent':this[_0x446f7b(0x23e)],'project_dir':process['cwd'](),..._0x69827c});}async[a0_0x35e9df(0x207)](){const _0x52ea8c=a0_0x35e9df;return this[_0x52ea8c(0x23d)](_0x52ea8c(0x1fe),{});}async['broadcast'](_0x57f630,_0x488cca){const _0x52c49b=a0_0x35e9df;return this[_0x52c49b(0x23d)](_0x52c49b(0x1ef),{'message':_0x57f630,'filter_server':_0x488cca?.['server'],'filter_status':_0x488cca?.['status']});}async['connectSSE'](){const _0x3549d6=a0_0x35e9df;let _0x357101=encodeURIComponent(this['alias']),_0x49e7f3=this['url']+_0x3549d6(0x212)+_0x357101,_0x3eed00=this[_0x3549d6(0x220)];while(this[_0x3549d6(0x1f7)]){try{this[_0x3549d6(0x219)]=new AbortController();let _0x204f18={'Accept':_0x3549d6(0x241)};if(this[_0x3549d6(0x230)])_0x204f18[_0x3549d6(0x226)]=_0x3549d6(0x21e)+this[_0x3549d6(0x230)];let _0x55ef7f=await fetch(_0x49e7f3,{'headers':_0x204f18,'signal':this[_0x3549d6(0x219)]['signal']});if(!_0x55ef7f['ok']||!_0x55ef7f[_0x3549d6(0x229)]){this[_0x3549d6(0x237)](_0x3549d6(0x206)+_0x55ef7f['status']),await this[_0x3549d6(0x20a)](_0x3eed00),_0x3eed00=Math[_0x3549d6(0x236)](_0x3eed00*1.5,0xea60);continue;}_0x3eed00=this['reconnectDelay'];let _0x32f4b3=_0x55ef7f['body'][_0x3549d6(0x1f4)](),_0x17e8b3=new TextDecoder(),_0x452b59='';while(this[_0x3549d6(0x1f7)]){let {done:_0x2232d9,value:_0x1c16ca}=await _0x32f4b3[_0x3549d6(0x205)]();if(_0x2232d9)break;_0x452b59+=_0x17e8b3[_0x3549d6(0x1f8)](_0x1c16ca,{'stream':!0x0});let _0x5cf7bb=_0x452b59[_0x3549d6(0x1db)]('\x0a');_0x452b59=_0x5cf7bb['pop']()||'';for(let _0xe3e4e4 of _0x5cf7bb){if(!_0xe3e4e4[_0x3549d6(0x249)]('data:\x20'))continue;try{let _0xc4a815=JSON[_0x3549d6(0x1e3)](_0xe3e4e4['slice'](0x6));if(_0xc4a815[_0x3549d6(0x1f6)]===_0x3549d6(0x213)){this[_0x3549d6(0x237)](_0x3549d6(0x1d0)),this['emit'](_0x3549d6(0x213));continue;}if(_0xc4a815[_0x3549d6(0x1f6)]===_0x3549d6(0x1ec)||_0xc4a815[_0x3549d6(0x1f6)]===_0x3549d6(0x20e)||_0xc4a815[_0x3549d6(0x1f6)]==='broadcast')await this[_0x3549d6(0x24a)]();}catch{}}}}catch(_0x11ae01){if(_0x11ae01[_0x3549d6(0x218)]==='AbortError')break;this[_0x3549d6(0x215)](_0x3549d6(0x1d7),_0x11ae01),this[_0x3549d6(0x237)](_0x3549d6(0x245)+_0x11ae01[_0x3549d6(0x21f)]);}if(this[_0x3549d6(0x1f7)])this[_0x3549d6(0x215)](_0x3549d6(0x1e5)),this[_0x3549d6(0x237)](_0x3549d6(0x231)+_0x3eed00/0x3e8+'s...'),await this[_0x3549d6(0x20a)](_0x3eed00),_0x3eed00=Math[_0x3549d6(0x236)](_0x3eed00*1.5,0xea60);}}async['processInbox'](){const _0x4c5332=a0_0x35e9df;try{let _0x2579db=(await this[_0x4c5332(0x23d)](_0x4c5332(0x235),{'alias':this[_0x4c5332(0x238)],'limit':0xa}))?.[_0x4c5332(0x1d2)]||[];for(let _0x52c81c of _0x2579db)await this[_0x4c5332(0x23d)](_0x4c5332(0x1ff),{'alias':this[_0x4c5332(0x238)],'message_id':_0x52c81c['id']}),this[_0x4c5332(0x237)]('←\x20'+_0x52c81c['from_session']+':\x20'+_0x52c81c[_0x4c5332(0x204)][_0x4c5332(0x223)](0x0,0x3c)),this[_0x4c5332(0x215)]('task',_0x52c81c),this[_0x4c5332(0x215)](_0x4c5332(0x21f),_0x52c81c);}catch(_0x4481fa){this[_0x4c5332(0x237)](_0x4c5332(0x1f0)+_0x4481fa[_0x4c5332(0x21f)]);}}[a0_0x35e9df(0x20a)](_0x33547f){return new Promise(_0x4d625c=>setTimeout(_0x4d625c,_0x33547f));}}var F=$;function a0_0x52ef(){const _0x227888=['from_alias','task.send.start','to_alias','new_task','task.expired','error_code','broadcast','inbox\x20error:\x20','missing_task_id','parent_task_id','\x20network_id=','getReader','application/json','type','running','decode','result','task.send.delivered','/mcp','CommHub\x20rejected\x20task','toString','get_all_status','ack_inbox','autoConnect','unknown\x20error','disconnect','315911eaGdBY','content','read','SSE\x20failed:\x20','getAllStatus','reply','\x20transport=','sleep','7DfnrFd','transport','CommHub\x20response\x20omitted\x20task_id','new_message','sending','idle','send','/events/','connected','status','emit','2119602hANkGE','now','name','sseAbort','10899592dMmgMk','resumeId','2.0','send_message','Bearer\x20','message','reconnectDelay','\x20from=','\x20lifecycle=','slice','POST','heartbeat\x20failed:\x20','Authorization','heartbeatTimer','1253586mYIRqq','body','parentTaskId','json','connect','task.replied','<unknown>','send_reply','token','SSE\x20reconnecting\x20in\x20','networkId','replace','connectSSE','get_inbox','min','log','alias','tools/call','catch','fromAlias','\x20duration_ms=','call','agent','stringify','1145370oqxfpf','text/event-stream','send_rejected','duration_ms','heartbeatInterval','SSE\x20error:\x20','mcp_http','failed','match','startsWith','processInbox','network_id','SSE\x20connected','completed','messages','task_id','toAlias','send_task','report_status','error','\x20error=','2640099vzyPZs','1400636nKPWKN','split','\x20task_id=','text','task.send.failed','send_failed','url','abort','task.started','parse','lifecycleTracking','disconnected','[commhub:task]\x20','message_id','task.ack'];a0_0x52ef=function(){return _0x227888;};return a0_0x52ef();}export{F as default,$ as CommHub};
|