@sleep2agi/agent-network 2.3.0-preview.67 → 2.3.0-preview.68
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_0x517d1f=a0_0x35cf;(function(_0x3a1ffa,_0x243bbe){const _0x3f1791=a0_0x35cf,_0xb95119=_0x3a1ffa();while(!![]){try{const _0x59c2d4=-parseInt(_0x3f1791(0x150))/0x1*(parseInt(_0x3f1791(0x161))/0x2)+-parseInt(_0x3f1791(0x12d))/0x3+-parseInt(_0x3f1791(0x160))/0x4*(parseInt(_0x3f1791(0x179))/0x5)+-parseInt(_0x3f1791(0x176))/0x6+parseInt(_0x3f1791(0x157))/0x7+-parseInt(_0x3f1791(0x17d))/0x8+parseInt(_0x3f1791(0x109))/0x9;if(_0x59c2d4===_0x243bbe)break;else _0xb95119['push'](_0xb95119['shift']());}catch(_0x18916b){_0xb95119['push'](_0xb95119['shift']());}}}(a0_0x42bb,0x9090a));import{EventEmitter as a0_0x1726db}from'events';import{hostname as a0_0x2b7564}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x4212b3,_0x117c43)=>(_0x4212b3??_0x117c43)[a0_0x517d1f(0x136)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x517d1f(0x126)](0x0,0xf0);function N(_0x338ee8){const _0x4567d5=a0_0x517d1f;return(_0x338ee8 instanceof Error?_0x338ee8[_0x4567d5(0x171)]:String(_0x338ee8??'unknown\x20error'))[_0x4567d5(0x136)](K,'[REDACTED]')['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x4567d5(0x126)](0x0,0xf0);}function O(_0x4e5718,_0x577c25=process.env.ANET_TASK_TRACE_FORMAT===a0_0x517d1f(0x17e)){const _0x685adc=a0_0x517d1f;if(_0x577c25)return JSON[_0x685adc(0x17a)](_0x4e5718);let _0x5a1be1=L(_0x4e5718[_0x685adc(0xfe)],_0x685adc(0x164)),_0x593441=L(_0x4e5718[_0x685adc(0x11a)],_0x685adc(0x105)),_0x5231ba=_0x4e5718[_0x685adc(0x119)]?'\x20error='+_0x4e5718[_0x685adc(0x119)]+':'+(_0x4e5718[_0x685adc(0x149)]??''):'';return'[commhub:task]\x20'+_0x4e5718[_0x685adc(0x10c)]+'\x20from='+L(_0x4e5718[_0x685adc(0x134)],_0x685adc(0x103))+_0x685adc(0x17b)+L(_0x4e5718[_0x685adc(0x153)],_0x685adc(0x103))+_0x685adc(0x147)+_0x593441+_0x685adc(0x11c)+_0x5a1be1+_0x685adc(0x12a)+L(_0x4e5718[_0x685adc(0x12e)],_0x685adc(0x103))+_0x685adc(0x140)+_0x4e5718[_0x685adc(0x172)]+'\x20duration_ms='+_0x4e5718[_0x685adc(0x14e)]+_0x685adc(0x117)+_0x4e5718[_0x685adc(0x15e)]+_0x5231ba;}function U(_0x40baca){const _0x5ebdc3=a0_0x517d1f;return{'event':{'sending':_0x5ebdc3(0x148),'delivered':_0x5ebdc3(0x10b),'failed':_0x5ebdc3(0x115),'acked':_0x5ebdc3(0x111),'started':_0x5ebdc3(0x108),'replied':_0x5ebdc3(0x168),'expired':_0x5ebdc3(0x129)}[_0x40baca[_0x5ebdc3(0x10c)]],..._0x40baca};}function j(_0x5edc64){const _0x1b2749=a0_0x517d1f;let _0x4947da=_0x5edc64?.[_0x1b2749(0x11a)]||_0x5edc64?.[_0x1b2749(0x14d)]||_0x5edc64?.['id'];if(_0x4947da)return String(_0x4947da);let _0x1196e3=_0x5edc64?.[_0x1b2749(0x15b)]?.[0x0]?.[_0x1b2749(0x15c)];if(typeof _0x1196e3!==_0x1b2749(0x11b))return null;try{let _0x15e866=JSON[_0x1b2749(0x13a)](_0x1196e3);return _0x15e866?.[_0x1b2749(0x11a)]||_0x15e866?.['message_id']||_0x15e866?.['id']||null;}catch{return null;}}async function X(_0x3436c1,_0x1cbc1e){const _0x37621e=a0_0x517d1f;let _0x35cb93=_0x1cbc1e['now']??Date['now'],_0x56f2b8=_0x35cb93(),_0x5285c7=(_0x17e458,_0x3bbaac,_0x55bfca,_0x4e49f5)=>{const _0x118583=a0_0x35cf;_0x1cbc1e['log'](O(U({'from_alias':_0x3436c1[_0x118583(0x16f)],'to_alias':_0x3436c1['toAlias'],'task_id':_0x3bbaac,'parent_task_id':_0x3436c1[_0x118583(0x13f)],'network_id':_0x3436c1[_0x118583(0x133)],'transport':_0x3436c1[_0x118583(0x172)],'status':_0x17e458,'duration_ms':_0x35cb93()-_0x56f2b8,'lifecycle_tracking':_0x3436c1[_0x118583(0x142)],..._0x55bfca!==void 0x0?{'error_code':_0x4e49f5||_0x118583(0x107),'error_message':N(_0x55bfca)}:{}})));};_0x5285c7(_0x37621e(0x163),null);try{let _0x19dfac=await _0x1cbc1e[_0x37621e(0x146)](),_0x569816=j(_0x19dfac);if(_0x569816)_0x5285c7(_0x37621e(0x152),_0x569816);else{if(_0x19dfac?.['ok']===!0x1||_0x19dfac?.[_0x37621e(0x12f)])_0x5285c7('failed',_0x569816,_0x19dfac?.['error']||_0x37621e(0x16b),_0x37621e(0x138));else _0x5285c7(_0x37621e(0x122),null,_0x37621e(0x10d),_0x37621e(0x16a));}return _0x19dfac;}catch(_0x4d0a25){throw _0x5285c7(_0x37621e(0x122),null,_0x4d0a25,'send_failed'),_0x4d0a25;}}async function Y(_0x410c09,_0x4b2793){const _0x3389d8=a0_0x517d1f;return X({'fromAlias':_0x410c09[_0x3389d8(0x16f)],'toAlias':_0x410c09[_0x3389d8(0x120)],'parentTaskId':_0x410c09[_0x3389d8(0x13f)]||null,'networkId':_0x410c09[_0x3389d8(0x133)]||null,'transport':'mcp_http','lifecycleTracking':_0x3389d8(0x177)},_0x4b2793);}function a0_0x42bb(){const _0x1cb441=['autoConnect','reply','task.send.failed','sdk','\x20lifecycle=','application/json','error_code','task_id','string','\x20parent_task_id=','broadcast','running','heartbeatTimer','alias','toString','failed','data:\x20','SSE\x20error:\x20','body','slice','send_reply','catch','task.expired','\x20network_id=','cwd','disconnect','2390448eAQtjT','network_id','error','normal','reconnectDelay','send_message','networkId','from_alias','task','replace','POST','send_rejected','heartbeat\x20failed:\x20','parse','text/event-stream','connected','log','server','parentTaskId','\x20transport=','processInbox','lifecycleTracking','disconnected','SSE\x20reconnecting\x20in\x20','SSE\x20failed:\x20','send','\x20task_id=','task.send.start','error_message','inbox\x20error:\x20','url','s...','message_id','duration_ms','sdk-','101197oJghsY','startsWith','delivered','to_alias','Authorization','offline','agent','7899164ifhwUo','read','name','ack_inbox','content','text','new_task','lifecycle_tracking','sleep','4nYQPYv','2mLxLVp','application/json,\x20text/event-stream','sending','<missing>','connectSSE','token','get_all_status','task.replied','match','missing_task_id','CommHub\x20rejected\x20task','2.0','type','now','fromAlias','get_inbox','message','transport','connect','Bearer\x20','resumeId','5880894yUXmsS','not_tracked','idle','4747115iMCoMb','stringify','\x20to=','pop','1110064iiTLvU','json','parent_task_id','heartbeatInterval','abort','/events/','signal','<unknown>','min','<pending>','completed','send_failed','task.started','21870261WPafHy','/mcp','task.send.delivered','status','CommHub\x20response\x20omitted\x20task_id','sseAbort','call','getReader','task.ack','emit'];a0_0x42bb=function(){return _0x1cb441;};return a0_0x42bb();}class $ extends a0_0x1726db{[a0_0x517d1f(0x14b)];[a0_0x517d1f(0x120)];[a0_0x517d1f(0x166)];[a0_0x517d1f(0x156)];[a0_0x517d1f(0x175)];['heartbeatInterval'];[a0_0x517d1f(0x131)];[a0_0x517d1f(0x11f)];['sseAbort'];[a0_0x517d1f(0x11e)]=!0x1;constructor(_0x3b8333){const _0x50b9fa=a0_0x517d1f;super();if(this[_0x50b9fa(0x14b)]=_0x3b8333[_0x50b9fa(0x14b)]['replace'](/\/$/,''),this['alias']=_0x3b8333['alias'],this['token']=_0x3b8333[_0x50b9fa(0x166)],this[_0x50b9fa(0x156)]=_0x3b8333[_0x50b9fa(0x156)]||_0x50b9fa(0x116),this[_0x50b9fa(0x175)]=_0x50b9fa(0x14f)+_0x3b8333[_0x50b9fa(0x120)]+'-'+Date[_0x50b9fa(0x16e)]()[_0x50b9fa(0x121)](0x24),this['heartbeatInterval']=_0x3b8333[_0x50b9fa(0xff)]??0x2bf20,this['reconnectDelay']=_0x3b8333[_0x50b9fa(0x131)]??0xbb8,_0x3b8333[_0x50b9fa(0x113)]!==!0x1)this[_0x50b9fa(0x173)]();}[a0_0x517d1f(0x13d)](_0x29c842){const _0x5b7ca1=a0_0x517d1f;console[_0x5b7ca1(0x13d)]('['+new Date()['toTimeString']()[_0x5b7ca1(0x126)](0x0,0x8)+']\x20[commhub:'+this[_0x5b7ca1(0x120)]+']\x20'+_0x29c842);}async['call'](_0x1ac54c,_0x13971c){const _0x2e9985=a0_0x517d1f;let _0x84c15d={'Content-Type':_0x2e9985(0x118),'Accept':_0x2e9985(0x162)};if(this[_0x2e9985(0x166)])_0x84c15d[_0x2e9985(0x154)]=_0x2e9985(0x174)+this[_0x2e9985(0x166)];let _0x3aa945=await(await fetch(this[_0x2e9985(0x14b)]+_0x2e9985(0x10a),{'method':_0x2e9985(0x137),'headers':_0x84c15d,'body':JSON[_0x2e9985(0x17a)]({'jsonrpc':_0x2e9985(0x16c),'id':Date['now'](),'method':'tools/call','params':{'name':_0x1ac54c,'arguments':_0x13971c}})}))[_0x2e9985(0x15c)](),_0x378c2e=_0x3aa945[_0x2e9985(0x169)](/data: (.+)/),_0x1b1da6=_0x378c2e?JSON[_0x2e9985(0x13a)](_0x378c2e[0x1]):JSON['parse'](_0x3aa945),_0x9d31ba=_0x1b1da6?.['result']?.[_0x2e9985(0x15b)]?.[0x0]?.[_0x2e9985(0x15c)];return _0x9d31ba?JSON[_0x2e9985(0x13a)](_0x9d31ba):_0x1b1da6;}async[a0_0x517d1f(0x173)](){const _0x114cf1=a0_0x517d1f;if(this['running'])return;this[_0x114cf1(0x11e)]=!0x0,await this[_0x114cf1(0x10c)](_0x114cf1(0x178)),this[_0x114cf1(0x13d)]('registered'),this[_0x114cf1(0x11f)]=setInterval(()=>{const _0x238fc1=_0x114cf1;this['status'](_0x238fc1(0x178))['catch'](_0x360aa0=>this[_0x238fc1(0x13d)](_0x238fc1(0x139)+_0x360aa0['message']));},this[_0x114cf1(0xff)]),this[_0x114cf1(0x165)]();}async[a0_0x517d1f(0x12c)](){const _0x1394f2=a0_0x517d1f;if(this[_0x1394f2(0x11e)]=!0x1,this['sseAbort']?.[_0x1394f2(0x100)](),this['heartbeatTimer'])clearInterval(this[_0x1394f2(0x11f)]);await this[_0x1394f2(0x10c)](_0x1394f2(0x155))[_0x1394f2(0x128)](()=>{}),this[_0x1394f2(0x13d)](_0x1394f2(0x143));}async['send'](_0x2d0a2f,_0xab1b7c,_0x49cdd5=a0_0x517d1f(0x130)){const _0x172c0f=a0_0x517d1f;return Y({'alias':_0x2d0a2f,'fromAlias':this[_0x172c0f(0x120)]},{'log':_0x1efd3d=>console['log'](_0x1efd3d),'send':()=>this['call']('send_task',{'alias':_0x2d0a2f,'task':_0xab1b7c,'priority':_0x49cdd5,'from_session':this[_0x172c0f(0x120)]})});}async['message'](_0xa67724,_0x4dd06d){const _0x5ebbd2=a0_0x517d1f;return this[_0x5ebbd2(0x10f)](_0x5ebbd2(0x132),{'alias':_0xa67724,'message':_0x4dd06d,'from_session':this['alias']});}async[a0_0x517d1f(0x114)](_0x3dd789,_0x234a18,_0x2fe917=a0_0x517d1f(0x106)){const _0x1c55db=a0_0x517d1f;return this[_0x1c55db(0x10f)](_0x1c55db(0x127),{'in_reply_to':_0x3dd789,'text':_0x234a18,'status':_0x2fe917});}async[a0_0x517d1f(0x10c)](_0x1f3dc7,_0x5de153){const _0x1a5e89=a0_0x517d1f;return this[_0x1a5e89(0x10f)]('report_status',{'resume_id':this['resumeId'],'alias':this['alias'],'status':_0x1f3dc7,'server':a0_0x2b7564(),'hostname':a0_0x2b7564(),'agent':this['agent'],'project_dir':process[_0x1a5e89(0x12b)](),..._0x5de153});}async['getAllStatus'](){const _0x3aefb0=a0_0x517d1f;return this[_0x3aefb0(0x10f)](_0x3aefb0(0x167),{});}async[a0_0x517d1f(0x11d)](_0x4ec4c6,_0x3388dc){const _0x53973b=a0_0x517d1f;return this['call'](_0x53973b(0x11d),{'message':_0x4ec4c6,'filter_server':_0x3388dc?.[_0x53973b(0x13e)],'filter_status':_0x3388dc?.[_0x53973b(0x10c)]});}async[a0_0x517d1f(0x165)](){const _0x369ede=a0_0x517d1f;let _0x2f7edd=encodeURIComponent(this['alias']),_0x131ba4=this[_0x369ede(0x14b)]+_0x369ede(0x101)+_0x2f7edd,_0x25dc02=this[_0x369ede(0x131)];while(this[_0x369ede(0x11e)]){try{this[_0x369ede(0x10e)]=new AbortController();let _0x24a0f1={'Accept':_0x369ede(0x13b)};if(this[_0x369ede(0x166)])_0x24a0f1[_0x369ede(0x154)]=_0x369ede(0x174)+this['token'];let _0x297ef3=await fetch(_0x131ba4,{'headers':_0x24a0f1,'signal':this['sseAbort'][_0x369ede(0x102)]});if(!_0x297ef3['ok']||!_0x297ef3[_0x369ede(0x125)]){this[_0x369ede(0x13d)](_0x369ede(0x145)+_0x297ef3['status']),await this[_0x369ede(0x15f)](_0x25dc02),_0x25dc02=Math[_0x369ede(0x104)](_0x25dc02*1.5,0xea60);continue;}_0x25dc02=this[_0x369ede(0x131)];let _0xb4fed6=_0x297ef3[_0x369ede(0x125)][_0x369ede(0x110)](),_0x292ca6=new TextDecoder(),_0x12c6f1='';while(this[_0x369ede(0x11e)]){let {done:_0x1af3dc,value:_0x3ebeb6}=await _0xb4fed6[_0x369ede(0x158)]();if(_0x1af3dc)break;_0x12c6f1+=_0x292ca6['decode'](_0x3ebeb6,{'stream':!0x0});let _0x44a389=_0x12c6f1['split']('\x0a');_0x12c6f1=_0x44a389[_0x369ede(0x17c)]()||'';for(let _0x1ac5b5 of _0x44a389){if(!_0x1ac5b5[_0x369ede(0x151)](_0x369ede(0x123)))continue;try{let _0x3973f2=JSON['parse'](_0x1ac5b5[_0x369ede(0x126)](0x6));if(_0x3973f2['type']===_0x369ede(0x13c)){this['log']('SSE\x20connected'),this[_0x369ede(0x112)](_0x369ede(0x13c));continue;}if(_0x3973f2[_0x369ede(0x16d)]===_0x369ede(0x15d)||_0x3973f2['type']==='new_message'||_0x3973f2[_0x369ede(0x16d)]===_0x369ede(0x11d))await this[_0x369ede(0x141)]();}catch{}}}}catch(_0x45a0df){if(_0x45a0df[_0x369ede(0x159)]==='AbortError')break;this['emit'](_0x369ede(0x12f),_0x45a0df),this['log'](_0x369ede(0x124)+_0x45a0df[_0x369ede(0x171)]);}if(this[_0x369ede(0x11e)])this[_0x369ede(0x112)]('disconnected'),this[_0x369ede(0x13d)](_0x369ede(0x144)+_0x25dc02/0x3e8+_0x369ede(0x14c)),await this[_0x369ede(0x15f)](_0x25dc02),_0x25dc02=Math[_0x369ede(0x104)](_0x25dc02*1.5,0xea60);}}async[a0_0x517d1f(0x141)](){const _0x37260=a0_0x517d1f;try{let _0x17ad16=(await this[_0x37260(0x10f)](_0x37260(0x170),{'alias':this[_0x37260(0x120)],'limit':0xa}))?.['messages']||[];for(let _0x41b47d of _0x17ad16)await this['call'](_0x37260(0x15a),{'alias':this[_0x37260(0x120)],'message_id':_0x41b47d['id']}),this['log']('←\x20'+_0x41b47d['from_session']+':\x20'+_0x41b47d[_0x37260(0x15b)]['slice'](0x0,0x3c)),this[_0x37260(0x112)](_0x37260(0x135),_0x41b47d),this['emit']('message',_0x41b47d);}catch(_0xca6970){this[_0x37260(0x13d)](_0x37260(0x14a)+_0xca6970[_0x37260(0x171)]);}}[a0_0x517d1f(0x15f)](_0x32b102){return new Promise(_0x4f7788=>setTimeout(_0x4f7788,_0x32b102));}}var F=$;function a0_0x35cf(_0x3c6411,_0x4a2004){_0x3c6411=_0x3c6411-0xfe;const _0x42bb64=a0_0x42bb();let _0x35cf0c=_0x42bb64[_0x3c6411];return _0x35cf0c;}export{F as default,$ as CommHub};
|
|
1
|
+
const a0_0x4e0926=a0_0x49bd;(function(_0x155588,_0x52e51d){const _0x3f67af=a0_0x49bd,_0x28b773=_0x155588();while(!![]){try{const _0xd4b1b9=parseInt(_0x3f67af(0x1d2))/0x1+parseInt(_0x3f67af(0x199))/0x2*(parseInt(_0x3f67af(0x1a1))/0x3)+parseInt(_0x3f67af(0x1eb))/0x4*(-parseInt(_0x3f67af(0x19a))/0x5)+-parseInt(_0x3f67af(0x1c5))/0x6*(parseInt(_0x3f67af(0x196))/0x7)+-parseInt(_0x3f67af(0x1c2))/0x8*(-parseInt(_0x3f67af(0x1b1))/0x9)+-parseInt(_0x3f67af(0x1e9))/0xa+parseInt(_0x3f67af(0x1fa))/0xb;if(_0xd4b1b9===_0x52e51d)break;else _0x28b773['push'](_0x28b773['shift']());}catch(_0x27ff1a){_0x28b773['push'](_0x28b773['shift']());}}}(a0_0x1da9,0x5595b));import{EventEmitter as a0_0x145a41}from'events';import{hostname as a0_0x362b80}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x1d30b1,_0x438601)=>(_0x1d30b1??_0x438601)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x4e0926(0x1d4)](0x0,0xf0);function a0_0x49bd(_0x25e8c1,_0x5ee524){_0x25e8c1=_0x25e8c1-0x193;const _0x1da90c=a0_0x1da9();let _0x49bd9f=_0x1da90c[_0x25e8c1];return _0x49bd9f;}function a0_0x1da9(){const _0x4e9a10=[']\x20[commhub:','report_status','heartbeatTimer','message_id','stringify','connected','lifecycleTracking','task.expired','<missing>','data:\x20','task','missing_task_id','catch','text/event-stream','failed','transport','task_id','[REDACTED]','message','parse','task.send.start','from_alias','sseAbort','Bearer\x20','26677tDzQXx','call','reconnectDelay','6hJvclL','5QskNTp','get_all_status','networkId','lifecycle_tracking','token','send_task','sleep','383769ZYDdQr','heartbeat\x20failed:\x20','emit','parentTaskId','/events/','status','url','agent','<unknown>','replace','now','autoConnect','reply','startsWith','send_rejected','to_alias','109971BSzzYs','toAlias','getReader','2.0','\x20lifecycle=','not_tracked','application/json','running','server','disconnect','string','task.send.failed','error_code','fromAlias','pop','/mcp','connectSSE','200GhkypL','send_failed','\x20from=','930WbQmPR','result','idle','getAllStatus','AbortError','duration_ms','processInbox','connect','send_message','disconnected','normal','\x20task_id=','match','66379ojXrvM','completed','slice','read','broadcast','SSE\x20error:\x20','text','inbox\x20error:\x20','heartbeatInterval','POST','SSE\x20reconnecting\x20in\x20','\x20error=','min','body','tools/call','type','signal','log','sending','name','alias','delivered','split','5418260ROQnJD','ack_inbox','1584820YfMXlG','task.send.delivered','send','CommHub\x20rejected\x20task','toString','SSE\x20connected','new_task','task.replied','Authorization','offline','CommHub\x20response\x20omitted\x20task_id','resumeId','error','\x20parent_task_id=','content','12360348XDaWDo'];a0_0x1da9=function(){return _0x4e9a10;};return a0_0x1da9();}function N(_0x2c061c){const _0x45e7ff=a0_0x4e0926;return(_0x2c061c instanceof Error?_0x2c061c[_0x45e7ff(0x20d)]:String(_0x2c061c??'unknown\x20error'))[_0x45e7ff(0x1aa)](K,_0x45e7ff(0x20c))[_0x45e7ff(0x1aa)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x45e7ff(0x1d4)](0x0,0xf0);}function O(_0x7349f4,_0x1e9541=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x86e788=a0_0x4e0926;if(_0x1e9541)return JSON[_0x86e788(0x1ff)](_0x7349f4);let _0x5ab9c7=L(_0x7349f4['parent_task_id'],_0x86e788(0x203)),_0x591a8d=L(_0x7349f4[_0x86e788(0x20b)],'<pending>'),_0x34838e=_0x7349f4['error_code']?_0x86e788(0x1dd)+_0x7349f4[_0x86e788(0x1bd)]+':'+(_0x7349f4['error_message']??''):'';return'[commhub:task]\x20'+_0x7349f4[_0x86e788(0x1a6)]+_0x86e788(0x1c4)+L(_0x7349f4[_0x86e788(0x193)],_0x86e788(0x1a9))+'\x20to='+L(_0x7349f4[_0x86e788(0x1b0)],_0x86e788(0x1a9))+_0x86e788(0x1d0)+_0x591a8d+_0x86e788(0x1f8)+_0x5ab9c7+'\x20network_id='+L(_0x7349f4['network_id'],'<unknown>')+'\x20transport='+_0x7349f4[_0x86e788(0x20a)]+'\x20duration_ms='+_0x7349f4[_0x86e788(0x1ca)]+_0x86e788(0x1b5)+_0x7349f4[_0x86e788(0x19d)]+_0x34838e;}function U(_0x1b6c4a){const _0x1b13cc=a0_0x4e0926;return{'event':{'sending':_0x1b13cc(0x20f),'delivered':_0x1b13cc(0x1ec),'failed':_0x1b13cc(0x1bc),'acked':'task.ack','started':'task.started','replied':_0x1b13cc(0x1f2),'expired':_0x1b13cc(0x202)}[_0x1b6c4a[_0x1b13cc(0x1a6)]],..._0x1b6c4a};}function j(_0x5b0fde){const _0x2fcb34=a0_0x4e0926;let _0x39e1f0=_0x5b0fde?.[_0x2fcb34(0x20b)]||_0x5b0fde?.['message_id']||_0x5b0fde?.['id'];if(_0x39e1f0)return String(_0x39e1f0);let _0x5cecaa=_0x5b0fde?.[_0x2fcb34(0x1f9)]?.[0x0]?.['text'];if(typeof _0x5cecaa!==_0x2fcb34(0x1bb))return null;try{let _0x29b828=JSON[_0x2fcb34(0x20e)](_0x5cecaa);return _0x29b828?.[_0x2fcb34(0x20b)]||_0x29b828?.[_0x2fcb34(0x1fe)]||_0x29b828?.['id']||null;}catch{return null;}}async function X(_0x3bf443,_0x5690f4){const _0x29ff8d=a0_0x4e0926;let _0x558ec0=_0x5690f4['now']??Date[_0x29ff8d(0x1ab)],_0x2d82e8=_0x558ec0(),_0x2b4385=(_0x2896f8,_0x5c2ccd,_0x401a5c,_0x338c81)=>{const _0x34f1e6=_0x29ff8d;_0x5690f4[_0x34f1e6(0x1e3)](O(U({'from_alias':_0x3bf443[_0x34f1e6(0x1be)],'to_alias':_0x3bf443[_0x34f1e6(0x1b2)],'task_id':_0x5c2ccd,'parent_task_id':_0x3bf443[_0x34f1e6(0x1a4)],'network_id':_0x3bf443[_0x34f1e6(0x19c)],'transport':_0x3bf443[_0x34f1e6(0x20a)],'status':_0x2896f8,'duration_ms':_0x558ec0()-_0x2d82e8,'lifecycle_tracking':_0x3bf443[_0x34f1e6(0x201)],..._0x401a5c!==void 0x0?{'error_code':_0x338c81||'send_failed','error_message':N(_0x401a5c)}:{}})));};_0x2b4385(_0x29ff8d(0x1e4),null);try{let _0x4bea9b=await _0x5690f4['send'](),_0x2968fe=j(_0x4bea9b);if(_0x2968fe)_0x2b4385(_0x29ff8d(0x1e7),_0x2968fe);else{if(_0x4bea9b?.['ok']===!0x1||_0x4bea9b?.[_0x29ff8d(0x1f7)])_0x2b4385(_0x29ff8d(0x209),_0x2968fe,_0x4bea9b?.[_0x29ff8d(0x1f7)]||_0x29ff8d(0x1ee),_0x29ff8d(0x1af));else _0x2b4385(_0x29ff8d(0x209),null,_0x29ff8d(0x1f5),_0x29ff8d(0x206));}return _0x4bea9b;}catch(_0x57a921){throw _0x2b4385(_0x29ff8d(0x209),null,_0x57a921,_0x29ff8d(0x1c3)),_0x57a921;}}async function Y(_0x34ed7b,_0x46419e){const _0x5ddd99=a0_0x4e0926;return X({'fromAlias':_0x34ed7b[_0x5ddd99(0x1be)],'toAlias':_0x34ed7b[_0x5ddd99(0x1e6)],'parentTaskId':_0x34ed7b['parentTaskId']||null,'networkId':_0x34ed7b[_0x5ddd99(0x19c)]||null,'transport':'mcp_http','lifecycleTracking':_0x5ddd99(0x1b6)},_0x46419e);}class $ extends a0_0x145a41{[a0_0x4e0926(0x1a7)];[a0_0x4e0926(0x1e6)];[a0_0x4e0926(0x19e)];['agent'];['resumeId'];[a0_0x4e0926(0x1da)];[a0_0x4e0926(0x198)];[a0_0x4e0926(0x1fd)];[a0_0x4e0926(0x194)];[a0_0x4e0926(0x1b8)]=!0x1;constructor(_0x59b3bc){const _0x3e5049=a0_0x4e0926;super();if(this['url']=_0x59b3bc[_0x3e5049(0x1a7)][_0x3e5049(0x1aa)](/\/$/,''),this['alias']=_0x59b3bc[_0x3e5049(0x1e6)],this['token']=_0x59b3bc[_0x3e5049(0x19e)],this[_0x3e5049(0x1a8)]=_0x59b3bc['agent']||'sdk',this[_0x3e5049(0x1f6)]='sdk-'+_0x59b3bc[_0x3e5049(0x1e6)]+'-'+Date[_0x3e5049(0x1ab)]()[_0x3e5049(0x1ef)](0x24),this[_0x3e5049(0x1da)]=_0x59b3bc[_0x3e5049(0x1da)]??0x2bf20,this['reconnectDelay']=_0x59b3bc['reconnectDelay']??0xbb8,_0x59b3bc[_0x3e5049(0x1ac)]!==!0x1)this[_0x3e5049(0x1cc)]();}[a0_0x4e0926(0x1e3)](_0x3c3fb2){const _0x7de5e2=a0_0x4e0926;console[_0x7de5e2(0x1e3)]('['+new Date()['toTimeString']()['slice'](0x0,0x8)+_0x7de5e2(0x1fb)+this['alias']+']\x20'+_0x3c3fb2);}async[a0_0x4e0926(0x197)](_0x563ab1,_0x358543){const _0x1fcae=a0_0x4e0926;let _0x3e000d={'Content-Type':_0x1fcae(0x1b7),'Accept':'application/json,\x20text/event-stream'};if(this[_0x1fcae(0x19e)])_0x3e000d[_0x1fcae(0x1f3)]=_0x1fcae(0x195)+this[_0x1fcae(0x19e)];let _0x1e710c=await(await fetch(this['url']+_0x1fcae(0x1c0),{'method':_0x1fcae(0x1db),'headers':_0x3e000d,'body':JSON[_0x1fcae(0x1ff)]({'jsonrpc':_0x1fcae(0x1b4),'id':Date[_0x1fcae(0x1ab)](),'method':_0x1fcae(0x1e0),'params':{'name':_0x563ab1,'arguments':_0x358543}})}))[_0x1fcae(0x1d8)](),_0x1dec70=_0x1e710c[_0x1fcae(0x1d1)](/data: (.+)/),_0x3ae201=_0x1dec70?JSON[_0x1fcae(0x20e)](_0x1dec70[0x1]):JSON[_0x1fcae(0x20e)](_0x1e710c),_0x23e5f9=_0x3ae201?.[_0x1fcae(0x1c6)]?.[_0x1fcae(0x1f9)]?.[0x0]?.['text'];return _0x23e5f9?JSON[_0x1fcae(0x20e)](_0x23e5f9):_0x3ae201;}async[a0_0x4e0926(0x1cc)](){const _0x555520=a0_0x4e0926;if(this[_0x555520(0x1b8)])return;this[_0x555520(0x1b8)]=!0x0,await this['status'](_0x555520(0x1c7)),this['log']('registered'),this[_0x555520(0x1fd)]=setInterval(()=>{const _0x21abb4=_0x555520;this[_0x21abb4(0x1a6)]('idle')[_0x21abb4(0x207)](_0x31c73d=>this['log'](_0x21abb4(0x1a2)+_0x31c73d['message']));},this['heartbeatInterval']),this[_0x555520(0x1c1)]();}async[a0_0x4e0926(0x1ba)](){const _0x3b6726=a0_0x4e0926;if(this[_0x3b6726(0x1b8)]=!0x1,this[_0x3b6726(0x194)]?.['abort'](),this[_0x3b6726(0x1fd)])clearInterval(this['heartbeatTimer']);await this[_0x3b6726(0x1a6)](_0x3b6726(0x1f4))[_0x3b6726(0x207)](()=>{}),this[_0x3b6726(0x1e3)]('disconnected');}async[a0_0x4e0926(0x1ed)](_0x475296,_0x540eff,_0x3cc8ce=a0_0x4e0926(0x1cf)){const _0x40b3bc=a0_0x4e0926;return Y({'alias':_0x475296,'fromAlias':this['alias']},{'log':_0xe66989=>console[_0x40b3bc(0x1e3)](_0xe66989),'send':()=>this[_0x40b3bc(0x197)](_0x40b3bc(0x19f),{'alias':_0x475296,'task':_0x540eff,'priority':_0x3cc8ce,'from_session':this[_0x40b3bc(0x1e6)]})});}async[a0_0x4e0926(0x20d)](_0x2af1f2,_0x3cbec2){const _0x2e4c7c=a0_0x4e0926;return this[_0x2e4c7c(0x197)](_0x2e4c7c(0x1cd),{'alias':_0x2af1f2,'message':_0x3cbec2,'from_session':this[_0x2e4c7c(0x1e6)]});}async[a0_0x4e0926(0x1ad)](_0x56ee44,_0x53f30a,_0x1377e6=a0_0x4e0926(0x1d3)){const _0x31df72=a0_0x4e0926;return this[_0x31df72(0x197)]('send_reply',{'in_reply_to':_0x56ee44,'text':_0x53f30a,'status':_0x1377e6});}async[a0_0x4e0926(0x1a6)](_0x1aa161,_0x5e826d){const _0x4863b5=a0_0x4e0926;return this[_0x4863b5(0x197)](_0x4863b5(0x1fc),{'resume_id':this[_0x4863b5(0x1f6)],'alias':this[_0x4863b5(0x1e6)],'status':_0x1aa161,'server':a0_0x362b80(),'hostname':a0_0x362b80(),'agent':this[_0x4863b5(0x1a8)],'project_dir':process['cwd'](),..._0x5e826d});}async[a0_0x4e0926(0x1c8)](){const _0xddee37=a0_0x4e0926;return this[_0xddee37(0x197)](_0xddee37(0x19b),{});}async[a0_0x4e0926(0x1d6)](_0x46d91a,_0x49fccf){const _0x20bd4a=a0_0x4e0926;return this['call'](_0x20bd4a(0x1d6),{'message':_0x46d91a,'filter_server':_0x49fccf?.[_0x20bd4a(0x1b9)],'filter_status':_0x49fccf?.[_0x20bd4a(0x1a6)]});}async[a0_0x4e0926(0x1c1)](){const _0x13c59d=a0_0x4e0926;let _0x4e5f4a=encodeURIComponent(this[_0x13c59d(0x1e6)]),_0x5d90b4=this[_0x13c59d(0x1a7)]+_0x13c59d(0x1a5)+_0x4e5f4a,_0x3dbb75=this[_0x13c59d(0x198)];while(this['running']){try{this[_0x13c59d(0x194)]=new AbortController();let _0x4e0bc3={'Accept':_0x13c59d(0x208)};if(this[_0x13c59d(0x19e)])_0x4e0bc3[_0x13c59d(0x1f3)]=_0x13c59d(0x195)+this['token'];let _0x3ab379=await fetch(_0x5d90b4,{'headers':_0x4e0bc3,'signal':this[_0x13c59d(0x194)][_0x13c59d(0x1e2)]});if(!_0x3ab379['ok']||!_0x3ab379[_0x13c59d(0x1df)]){this[_0x13c59d(0x1e3)]('SSE\x20failed:\x20'+_0x3ab379[_0x13c59d(0x1a6)]),await this[_0x13c59d(0x1a0)](_0x3dbb75),_0x3dbb75=Math[_0x13c59d(0x1de)](_0x3dbb75*1.5,0xea60);continue;}_0x3dbb75=this[_0x13c59d(0x198)];let _0x254a7e=_0x3ab379[_0x13c59d(0x1df)][_0x13c59d(0x1b3)](),_0xfb879=new TextDecoder(),_0x1156e1='';while(this[_0x13c59d(0x1b8)]){let {done:_0x215c34,value:_0x4e3a57}=await _0x254a7e[_0x13c59d(0x1d5)]();if(_0x215c34)break;_0x1156e1+=_0xfb879['decode'](_0x4e3a57,{'stream':!0x0});let _0xbb9381=_0x1156e1[_0x13c59d(0x1e8)]('\x0a');_0x1156e1=_0xbb9381[_0x13c59d(0x1bf)]()||'';for(let _0x3679f7 of _0xbb9381){if(!_0x3679f7[_0x13c59d(0x1ae)](_0x13c59d(0x204)))continue;try{let _0x546575=JSON['parse'](_0x3679f7[_0x13c59d(0x1d4)](0x6));if(_0x546575['type']===_0x13c59d(0x200)){this[_0x13c59d(0x1e3)](_0x13c59d(0x1f0)),this[_0x13c59d(0x1a3)](_0x13c59d(0x200));continue;}if(_0x546575['type']===_0x13c59d(0x1f1)||_0x546575[_0x13c59d(0x1e1)]==='new_message'||_0x546575['type']===_0x13c59d(0x1d6))await this[_0x13c59d(0x1cb)]();}catch{}}}}catch(_0x397ec7){if(_0x397ec7[_0x13c59d(0x1e5)]===_0x13c59d(0x1c9))break;this['emit']('error',_0x397ec7),this[_0x13c59d(0x1e3)](_0x13c59d(0x1d7)+_0x397ec7[_0x13c59d(0x20d)]);}if(this[_0x13c59d(0x1b8)])this[_0x13c59d(0x1a3)](_0x13c59d(0x1ce)),this[_0x13c59d(0x1e3)](_0x13c59d(0x1dc)+_0x3dbb75/0x3e8+'s...'),await this['sleep'](_0x3dbb75),_0x3dbb75=Math[_0x13c59d(0x1de)](_0x3dbb75*1.5,0xea60);}}async[a0_0x4e0926(0x1cb)](){const _0x1e0219=a0_0x4e0926;try{let _0x39d4d5=(await this[_0x1e0219(0x197)]('get_inbox',{'alias':this['alias'],'limit':0xa}))?.['messages']||[];for(let _0x3bb745 of _0x39d4d5)await this['call'](_0x1e0219(0x1ea),{'alias':this[_0x1e0219(0x1e6)],'message_id':_0x3bb745['id']}),this[_0x1e0219(0x1e3)]('←\x20'+_0x3bb745['from_session']+':\x20'+_0x3bb745[_0x1e0219(0x1f9)][_0x1e0219(0x1d4)](0x0,0x3c)),this[_0x1e0219(0x1a3)](_0x1e0219(0x205),_0x3bb745),this[_0x1e0219(0x1a3)](_0x1e0219(0x20d),_0x3bb745);}catch(_0x4dac96){this[_0x1e0219(0x1e3)](_0x1e0219(0x1d9)+_0x4dac96[_0x1e0219(0x20d)]);}}[a0_0x4e0926(0x1a0)](_0x49ccfc){return new Promise(_0x5a1106=>setTimeout(_0x5a1106,_0x49ccfc));}}var F=$;export{F as default,$ as CommHub};
|