@sleep2agi/agent-network 2.3.0-preview.60 → 2.3.0-preview.62
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_0x57a208=a0_0x46d5;(function(_0xb3918a,_0x30aecf){const _0xf24638=a0_0x46d5,_0xdf5b4b=_0xb3918a();while(!![]){try{const _0x3dca79=-parseInt(_0xf24638(0x1f7))/0x1+parseInt(_0xf24638(0x1ae))/0x2+parseInt(_0xf24638(0x1ff))/0x3*(parseInt(_0xf24638(0x1d8))/0x4)+parseInt(_0xf24638(0x1d7))/0x5*(-parseInt(_0xf24638(0x218))/0x6)+-parseInt(_0xf24638(0x1ed))/0x7*(-parseInt(_0xf24638(0x1bd))/0x8)+-parseInt(_0xf24638(0x202))/0x9*(parseInt(_0xf24638(0x200))/0xa)+parseInt(_0xf24638(0x212))/0xb*(parseInt(_0xf24638(0x1f1))/0xc);if(_0x3dca79===_0x30aecf)break;else _0xdf5b4b['push'](_0xdf5b4b['shift']());}catch(_0x1e4193){_0xdf5b4b['push'](_0xdf5b4b['shift']());}}}(a0_0x3771,0x35105));import{EventEmitter as a0_0x5c77a8}from'events';import{hostname as a0_0x1ceb32}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x4cef1b,_0x2bc4ce)=>(_0x4cef1b??_0x2bc4ce)[a0_0x57a208(0x1b7)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x57a208(0x1de)](0x0,0xf0);function a0_0x46d5(_0x4f96db,_0x10c642){_0x4f96db=_0x4f96db-0x1a4;const _0x3771fa=a0_0x3771();let _0x46d564=_0x3771fa[_0x4f96db];return _0x46d564;}function N(_0x461911){const _0x58affd=a0_0x57a208;return(_0x461911 instanceof Error?_0x461911['message']:String(_0x461911??_0x58affd(0x1fe)))[_0x58affd(0x1b7)](K,'[REDACTED]')['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x58affd(0x1de)](0x0,0xf0);}function O(_0x1bf689,_0x4ea9d1=process.env.ANET_TASK_TRACE_FORMAT===a0_0x57a208(0x219)){const _0x84ce2e=a0_0x57a208;if(_0x4ea9d1)return JSON[_0x84ce2e(0x1fa)](_0x1bf689);let _0x28f967=L(_0x1bf689['parent_task_id'],_0x84ce2e(0x20c)),_0x2279f2=L(_0x1bf689[_0x84ce2e(0x1d0)],_0x84ce2e(0x1d1)),_0x38899a=_0x1bf689['error_code']?_0x84ce2e(0x1f8)+_0x1bf689['error_code']+':'+(_0x1bf689['error_message']??''):'';return _0x84ce2e(0x210)+_0x1bf689[_0x84ce2e(0x1dc)]+_0x84ce2e(0x226)+L(_0x1bf689[_0x84ce2e(0x1d2)],_0x84ce2e(0x1d5))+'\x20to='+L(_0x1bf689[_0x84ce2e(0x1e1)],_0x84ce2e(0x1d5))+_0x84ce2e(0x1f0)+_0x2279f2+_0x84ce2e(0x1ef)+_0x28f967+_0x84ce2e(0x205)+L(_0x1bf689['network_id'],_0x84ce2e(0x1d5))+_0x84ce2e(0x1a4)+_0x1bf689['transport']+'\x20duration_ms='+_0x1bf689[_0x84ce2e(0x224)]+_0x84ce2e(0x21d)+_0x1bf689['lifecycle_tracking']+_0x38899a;}function U(_0x4d45d4){const _0x2aaaee=a0_0x57a208;return{'event':{'sending':_0x2aaaee(0x1c7),'delivered':_0x2aaaee(0x1bb),'failed':_0x2aaaee(0x1e3),'acked':_0x2aaaee(0x1b8),'started':'task.started','replied':_0x2aaaee(0x1ec),'expired':_0x2aaaee(0x207)}[_0x4d45d4[_0x2aaaee(0x1dc)]],..._0x4d45d4};}function j(_0x5c5744){const _0xe2095b=a0_0x57a208;let _0x46544c=_0x5c5744?.[_0xe2095b(0x1d0)]||_0x5c5744?.[_0xe2095b(0x208)]||_0x5c5744?.['id'];if(_0x46544c)return String(_0x46544c);let _0x46b3ed=_0x5c5744?.['content']?.[0x0]?.['text'];if(typeof _0x46b3ed!==_0xe2095b(0x20a))return null;try{let _0x471819=JSON[_0xe2095b(0x1bc)](_0x46b3ed);return _0x471819?.['task_id']||_0x471819?.[_0xe2095b(0x208)]||_0x471819?.['id']||null;}catch{return null;}}async function X(_0x19852a,_0x5d78d8){const _0x3c89f2=a0_0x57a208;let _0xe05db7=_0x5d78d8[_0x3c89f2(0x1b0)]??Date[_0x3c89f2(0x1b0)],_0x515be6=_0xe05db7(),_0x34b5a7=(_0x5441ed,_0x52b1f0,_0x549a2e,_0xf33261)=>{const _0x3949c8=_0x3c89f2;_0x5d78d8[_0x3949c8(0x1b6)](O(U({'from_alias':_0x19852a['fromAlias'],'to_alias':_0x19852a['toAlias'],'task_id':_0x52b1f0,'parent_task_id':_0x19852a[_0x3949c8(0x1f5)],'network_id':_0x19852a[_0x3949c8(0x217)],'transport':_0x19852a[_0x3949c8(0x1e8)],'status':_0x5441ed,'duration_ms':_0xe05db7()-_0x515be6,'lifecycle_tracking':_0x19852a['lifecycleTracking'],..._0x549a2e!==void 0x0?{'error_code':_0xf33261||_0x3949c8(0x1b3),'error_message':N(_0x549a2e)}:{}})));};_0x34b5a7('sending',null);try{let _0x5f0e6e=await _0x5d78d8[_0x3c89f2(0x1b2)](),_0x192aa1=j(_0x5f0e6e);if(_0x192aa1)_0x34b5a7('delivered',_0x192aa1);else{if(_0x5f0e6e?.['ok']===!0x1||_0x5f0e6e?.['error'])_0x34b5a7(_0x3c89f2(0x214),_0x192aa1,_0x5f0e6e?.['error']||_0x3c89f2(0x21e),_0x3c89f2(0x203));else _0x34b5a7('failed',null,_0x3c89f2(0x20b),_0x3c89f2(0x1ab));}return _0x5f0e6e;}catch(_0x206aea){throw _0x34b5a7(_0x3c89f2(0x214),null,_0x206aea,_0x3c89f2(0x1b3)),_0x206aea;}}function a0_0x3771(){const _0x16b077=['[commhub:task]\x20','mcp_http','44GtRdav','/events/','failed','Bearer\x20','completed','networkId','6mCGCBj','json','body','connect','sleep','\x20lifecycle=','CommHub\x20rejected\x20task','url','reconnectDelay','agent','get_all_status','new_task','duration_ms','heartbeatTimer','\x20from=','\x20transport=','messages','min','get_inbox','autoConnect','call','alias','missing_task_id','application/json,\x20text/event-stream','new_message','282520sTnvxF','sdk','now','pop','send','send_failed','heartbeatInterval','offline','log','replace','task.ack','read','SSE\x20error:\x20','task.send.delivered','parse','21712sVXcmY','running','POST','type','message','send_task','sseAbort','s...','broadcast','registered','task.send.start','SSE\x20reconnecting\x20in\x20','catch','signal','send_message','token','getReader','text','emit','task_id','<pending>','from_alias','disconnected','Authorization','<unknown>','task','1011055NEaiim','8tTcSNu','abort','data:\x20','ack_inbox','status','server','slice','tools/call','send_reply','to_alias','reply','task.send.failed','result','normal','not_tracked','application/json','transport','AbortError','disconnect','split','task.replied','973xvSkwX','from_session','\x20parent_task_id=','\x20task_id=','83292TUuFTR','/mcp','connectSSE','decode','parentTaskId','toTimeString','134813cSUUdy','\x20error=','toString','stringify','content',']\x20[commhub:','processInbox','unknown\x20error','261912ViwWaS','333010hatgwo','text/event-stream','45ICTOLQ','send_rejected','idle','\x20network_id=','match','task.expired','message_id','resumeId','string','CommHub\x20response\x20omitted\x20task_id','<missing>','sdk-','SSE\x20failed:\x20','SSE\x20connected'];a0_0x3771=function(){return _0x16b077;};return a0_0x3771();}async function Y(_0x56ce0a,_0x216ba9){const _0x595220=a0_0x57a208;return X({'fromAlias':_0x56ce0a['fromAlias'],'toAlias':_0x56ce0a[_0x595220(0x1aa)],'parentTaskId':_0x56ce0a['parentTaskId']||null,'networkId':_0x56ce0a[_0x595220(0x217)]||null,'transport':_0x595220(0x211),'lifecycleTracking':_0x595220(0x1e6)},_0x216ba9);}class $ extends a0_0x5c77a8{[a0_0x57a208(0x21f)];[a0_0x57a208(0x1aa)];[a0_0x57a208(0x1cc)];[a0_0x57a208(0x221)];[a0_0x57a208(0x209)];['heartbeatInterval'];[a0_0x57a208(0x220)];[a0_0x57a208(0x225)];[a0_0x57a208(0x1c3)];['running']=!0x1;constructor(_0x2c5214){const _0x6c3a7c=a0_0x57a208;super();if(this['url']=_0x2c5214['url'][_0x6c3a7c(0x1b7)](/\/$/,''),this[_0x6c3a7c(0x1aa)]=_0x2c5214['alias'],this['token']=_0x2c5214[_0x6c3a7c(0x1cc)],this[_0x6c3a7c(0x221)]=_0x2c5214[_0x6c3a7c(0x221)]||_0x6c3a7c(0x1af),this['resumeId']=_0x6c3a7c(0x20d)+_0x2c5214[_0x6c3a7c(0x1aa)]+'-'+Date[_0x6c3a7c(0x1b0)]()[_0x6c3a7c(0x1f9)](0x24),this[_0x6c3a7c(0x1b4)]=_0x2c5214[_0x6c3a7c(0x1b4)]??0x2bf20,this['reconnectDelay']=_0x2c5214[_0x6c3a7c(0x220)]??0xbb8,_0x2c5214[_0x6c3a7c(0x1a8)]!==!0x1)this[_0x6c3a7c(0x21b)]();}[a0_0x57a208(0x1b6)](_0x492b27){const _0x120be8=a0_0x57a208;console[_0x120be8(0x1b6)]('['+new Date()[_0x120be8(0x1f6)]()[_0x120be8(0x1de)](0x0,0x8)+_0x120be8(0x1fc)+this[_0x120be8(0x1aa)]+']\x20'+_0x492b27);}async[a0_0x57a208(0x1a9)](_0x5b92b5,_0x4dcb20){const _0x27146f=a0_0x57a208;let _0x3a1029={'Content-Type':_0x27146f(0x1e7),'Accept':_0x27146f(0x1ac)};if(this[_0x27146f(0x1cc)])_0x3a1029[_0x27146f(0x1d4)]=_0x27146f(0x215)+this[_0x27146f(0x1cc)];let _0x4add50=await(await fetch(this[_0x27146f(0x21f)]+_0x27146f(0x1f2),{'method':_0x27146f(0x1bf),'headers':_0x3a1029,'body':JSON[_0x27146f(0x1fa)]({'jsonrpc':'2.0','id':Date['now'](),'method':_0x27146f(0x1df),'params':{'name':_0x5b92b5,'arguments':_0x4dcb20}})}))['text'](),_0x321ff0=_0x4add50[_0x27146f(0x206)](/data: (.+)/),_0x5d5ce6=_0x321ff0?JSON['parse'](_0x321ff0[0x1]):JSON[_0x27146f(0x1bc)](_0x4add50),_0xb0e0f5=_0x5d5ce6?.[_0x27146f(0x1e4)]?.[_0x27146f(0x1fb)]?.[0x0]?.[_0x27146f(0x1ce)];return _0xb0e0f5?JSON[_0x27146f(0x1bc)](_0xb0e0f5):_0x5d5ce6;}async[a0_0x57a208(0x21b)](){const _0x2c0e59=a0_0x57a208;if(this['running'])return;this['running']=!0x0,await this[_0x2c0e59(0x1dc)](_0x2c0e59(0x204)),this[_0x2c0e59(0x1b6)](_0x2c0e59(0x1c6)),this[_0x2c0e59(0x225)]=setInterval(()=>{const _0x1dc7c4=_0x2c0e59;this[_0x1dc7c4(0x1dc)](_0x1dc7c4(0x204))[_0x1dc7c4(0x1c9)](_0x4eb0e0=>this[_0x1dc7c4(0x1b6)]('heartbeat\x20failed:\x20'+_0x4eb0e0[_0x1dc7c4(0x1c1)]));},this[_0x2c0e59(0x1b4)]),this['connectSSE']();}async[a0_0x57a208(0x1ea)](){const _0x306068=a0_0x57a208;if(this['running']=!0x1,this[_0x306068(0x1c3)]?.[_0x306068(0x1d9)](),this[_0x306068(0x225)])clearInterval(this['heartbeatTimer']);await this[_0x306068(0x1dc)](_0x306068(0x1b5))[_0x306068(0x1c9)](()=>{}),this['log'](_0x306068(0x1d3));}async[a0_0x57a208(0x1b2)](_0x2144d3,_0x489223,_0x23e5ca=a0_0x57a208(0x1e5)){const _0xfb9ae2=a0_0x57a208;return Y({'alias':_0x2144d3,'fromAlias':this[_0xfb9ae2(0x1aa)]},{'log':_0x26b7d9=>console[_0xfb9ae2(0x1b6)](_0x26b7d9),'send':()=>this[_0xfb9ae2(0x1a9)](_0xfb9ae2(0x1c2),{'alias':_0x2144d3,'task':_0x489223,'priority':_0x23e5ca,'from_session':this[_0xfb9ae2(0x1aa)]})});}async[a0_0x57a208(0x1c1)](_0x54540c,_0x596baf){const _0x2a144c=a0_0x57a208;return this[_0x2a144c(0x1a9)](_0x2a144c(0x1cb),{'alias':_0x54540c,'message':_0x596baf,'from_session':this['alias']});}async[a0_0x57a208(0x1e2)](_0x1314c4,_0x49ef04,_0x3dc263=a0_0x57a208(0x216)){const _0x3b8dd3=a0_0x57a208;return this[_0x3b8dd3(0x1a9)](_0x3b8dd3(0x1e0),{'in_reply_to':_0x1314c4,'text':_0x49ef04,'status':_0x3dc263});}async['status'](_0x2116dc,_0x1cccd8){const _0x588e8a=a0_0x57a208;return this[_0x588e8a(0x1a9)]('report_status',{'resume_id':this[_0x588e8a(0x209)],'alias':this[_0x588e8a(0x1aa)],'status':_0x2116dc,'server':a0_0x1ceb32(),'hostname':a0_0x1ceb32(),'agent':this[_0x588e8a(0x221)],'project_dir':process['cwd'](),..._0x1cccd8});}async['getAllStatus'](){const _0x5efaaf=a0_0x57a208;return this[_0x5efaaf(0x1a9)](_0x5efaaf(0x222),{});}async['broadcast'](_0x1abd5e,_0x2384b7){const _0x36f641=a0_0x57a208;return this[_0x36f641(0x1a9)]('broadcast',{'message':_0x1abd5e,'filter_server':_0x2384b7?.[_0x36f641(0x1dd)],'filter_status':_0x2384b7?.[_0x36f641(0x1dc)]});}async[a0_0x57a208(0x1f3)](){const _0x3ff777=a0_0x57a208;let _0x232560=encodeURIComponent(this[_0x3ff777(0x1aa)]),_0x32db68=this[_0x3ff777(0x21f)]+_0x3ff777(0x213)+_0x232560,_0x3b9f1d=this['reconnectDelay'];while(this[_0x3ff777(0x1be)]){try{this['sseAbort']=new AbortController();let _0x3303ff={'Accept':_0x3ff777(0x201)};if(this[_0x3ff777(0x1cc)])_0x3303ff[_0x3ff777(0x1d4)]='Bearer\x20'+this[_0x3ff777(0x1cc)];let _0x4aef9d=await fetch(_0x32db68,{'headers':_0x3303ff,'signal':this['sseAbort'][_0x3ff777(0x1ca)]});if(!_0x4aef9d['ok']||!_0x4aef9d[_0x3ff777(0x21a)]){this[_0x3ff777(0x1b6)](_0x3ff777(0x20e)+_0x4aef9d['status']),await this['sleep'](_0x3b9f1d),_0x3b9f1d=Math[_0x3ff777(0x1a6)](_0x3b9f1d*1.5,0xea60);continue;}_0x3b9f1d=this[_0x3ff777(0x220)];let _0x5026ec=_0x4aef9d[_0x3ff777(0x21a)][_0x3ff777(0x1cd)](),_0x1c75df=new TextDecoder(),_0x239897='';while(this[_0x3ff777(0x1be)]){let {done:_0xe5d364,value:_0x37411b}=await _0x5026ec[_0x3ff777(0x1b9)]();if(_0xe5d364)break;_0x239897+=_0x1c75df[_0x3ff777(0x1f4)](_0x37411b,{'stream':!0x0});let _0x532204=_0x239897[_0x3ff777(0x1eb)]('\x0a');_0x239897=_0x532204[_0x3ff777(0x1b1)]()||'';for(let _0x1724a0 of _0x532204){if(!_0x1724a0['startsWith'](_0x3ff777(0x1da)))continue;try{let _0x72b7c=JSON[_0x3ff777(0x1bc)](_0x1724a0[_0x3ff777(0x1de)](0x6));if(_0x72b7c[_0x3ff777(0x1c0)]==='connected'){this[_0x3ff777(0x1b6)](_0x3ff777(0x20f)),this[_0x3ff777(0x1cf)]('connected');continue;}if(_0x72b7c[_0x3ff777(0x1c0)]===_0x3ff777(0x223)||_0x72b7c[_0x3ff777(0x1c0)]===_0x3ff777(0x1ad)||_0x72b7c[_0x3ff777(0x1c0)]===_0x3ff777(0x1c5))await this[_0x3ff777(0x1fd)]();}catch{}}}}catch(_0x229a06){if(_0x229a06['name']===_0x3ff777(0x1e9))break;this[_0x3ff777(0x1cf)]('error',_0x229a06),this[_0x3ff777(0x1b6)](_0x3ff777(0x1ba)+_0x229a06[_0x3ff777(0x1c1)]);}if(this['running'])this['emit'](_0x3ff777(0x1d3)),this[_0x3ff777(0x1b6)](_0x3ff777(0x1c8)+_0x3b9f1d/0x3e8+_0x3ff777(0x1c4)),await this[_0x3ff777(0x21c)](_0x3b9f1d),_0x3b9f1d=Math['min'](_0x3b9f1d*1.5,0xea60);}}async[a0_0x57a208(0x1fd)](){const _0x2195ae=a0_0x57a208;try{let _0x4807d8=(await this[_0x2195ae(0x1a9)](_0x2195ae(0x1a7),{'alias':this[_0x2195ae(0x1aa)],'limit':0xa}))?.[_0x2195ae(0x1a5)]||[];for(let _0x30faf1 of _0x4807d8)await this[_0x2195ae(0x1a9)](_0x2195ae(0x1db),{'alias':this['alias'],'message_id':_0x30faf1['id']}),this[_0x2195ae(0x1b6)]('←\x20'+_0x30faf1[_0x2195ae(0x1ee)]+':\x20'+_0x30faf1[_0x2195ae(0x1fb)][_0x2195ae(0x1de)](0x0,0x3c)),this[_0x2195ae(0x1cf)](_0x2195ae(0x1d6),_0x30faf1),this[_0x2195ae(0x1cf)]('message',_0x30faf1);}catch(_0x426079){this['log']('inbox\x20error:\x20'+_0x426079[_0x2195ae(0x1c1)]);}}[a0_0x57a208(0x21c)](_0x5a3952){return new Promise(_0x5a1435=>setTimeout(_0x5a1435,_0x5a3952));}}var F=$;export{F as default,$ as CommHub};
|
|
1
|
+
const a0_0x5bb32a=a0_0x17d4;function a0_0x576f(){const _0x5254d5=['send_rejected','emit','reconnectDelay','1397998NbVLNq','offline','sdk','connectSSE','missing_task_id','network_id','idle','content','heartbeatTimer','unknown\x20error','[REDACTED]','string','task.expired','alias','[commhub:task]\x20','\x20error=','SSE\x20error:\x20','error','lifecycleTracking','connected','result','912762zkxnOZ','replace','sdk-','getAllStatus','registered','new_task','\x20parent_task_id=','1612384ibyRro','status','completed','fromAlias','running','not_tracked','now','60vhEOQn','type','sleep','Bearer\x20','json','task.ack','tools/call','task.started','token','task','name','reply','startsWith','resumeId','message_id','disconnected','\x20network_id=','toString','from_alias','get_all_status','text','log','<pending>','send_reply','slice','send_failed','\x20task_id=','abort','task.replied','connect','min','transport','server','3156213STOamD','pop','processInbox','\x20transport=','2.0','task.send.delivered','catch','text/event-stream','disconnect','failed','broadcast','decode','31841824URenuB','1116680JbcYgu','sseAbort','SSE\x20connected','to_alias','getReader','ack_inbox','<unknown>','toAlias','send','duration_ms','Authorization','networkId','sending','CommHub\x20rejected\x20task','AbortError','\x20to=','split','delivered','heartbeatInterval','normal','<missing>','body','message','report_status','parse','parent_task_id','stringify','send_message','get_inbox','url','task_id','task.send.start','\x20from=','654057mwzyMp','call','read','inbox\x20error:\x20','/events/','agent'];a0_0x576f=function(){return _0x5254d5;};return a0_0x576f();}(function(_0x4f5807,_0x21416a){const _0x6dacea=a0_0x17d4,_0x5aebd7=_0x4f5807();while(!![]){try{const _0x34e784=parseInt(_0x6dacea(0x173))/0x1+-parseInt(_0x6dacea(0x152))/0x2+-parseInt(_0x6dacea(0x145))/0x3+-parseInt(_0x6dacea(0x11d))/0x4+-parseInt(_0x6dacea(0x124))/0x5*(parseInt(_0x6dacea(0x116))/0x6)+parseInt(_0x6dacea(0x17c))/0x7+parseInt(_0x6dacea(0x151))/0x8;if(_0x34e784===_0x21416a)break;else _0x5aebd7['push'](_0x5aebd7['shift']());}catch(_0x4db1af){_0x5aebd7['push'](_0x5aebd7['shift']());}}}(a0_0x576f,0xf2e98));import{EventEmitter as a0_0x54f089}from'events';import{hostname as a0_0x26deb8}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x272b7f,_0x3fb318)=>(_0x272b7f??_0x3fb318)[a0_0x5bb32a(0x117)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x5bb32a(0x13c)](0x0,0xf0);function N(_0x1a8131){const _0x10cbd6=a0_0x5bb32a;return(_0x1a8131 instanceof Error?_0x1a8131['message']:String(_0x1a8131??_0x10cbd6(0x10a)))[_0x10cbd6(0x117)](K,_0x10cbd6(0x10b))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x10cbd6(0x13c)](0x0,0xf0);}function O(_0x7f0df8,_0x3b14e7=process.env.ANET_TASK_TRACE_FORMAT===a0_0x5bb32a(0x128)){const _0xb22a50=a0_0x5bb32a;if(_0x3b14e7)return JSON[_0xb22a50(0x16c)](_0x7f0df8);let _0x4ba0cc=L(_0x7f0df8[_0xb22a50(0x16b)],_0xb22a50(0x166)),_0x15bc99=L(_0x7f0df8[_0xb22a50(0x170)],_0xb22a50(0x13a)),_0x52e6b1=_0x7f0df8['error_code']?_0xb22a50(0x110)+_0x7f0df8['error_code']+':'+(_0x7f0df8['error_message']??''):'';return _0xb22a50(0x10f)+_0x7f0df8[_0xb22a50(0x11e)]+_0xb22a50(0x172)+L(_0x7f0df8[_0xb22a50(0x136)],'<unknown>')+_0xb22a50(0x161)+L(_0x7f0df8[_0xb22a50(0x155)],'<unknown>')+_0xb22a50(0x13e)+_0x15bc99+_0xb22a50(0x11c)+_0x4ba0cc+_0xb22a50(0x134)+L(_0x7f0df8[_0xb22a50(0x106)],_0xb22a50(0x158))+_0xb22a50(0x148)+_0x7f0df8[_0xb22a50(0x143)]+'\x20duration_ms='+_0x7f0df8[_0xb22a50(0x15b)]+'\x20lifecycle='+_0x7f0df8['lifecycle_tracking']+_0x52e6b1;}function U(_0x23d52c){const _0x1b89f2=a0_0x5bb32a;return{'event':{'sending':_0x1b89f2(0x171),'delivered':_0x1b89f2(0x14a),'failed':'task.send.failed','acked':_0x1b89f2(0x129),'started':_0x1b89f2(0x12b),'replied':_0x1b89f2(0x140),'expired':_0x1b89f2(0x10d)}[_0x23d52c['status']],..._0x23d52c};}function j(_0x12847c){const _0x5504c1=a0_0x5bb32a;let _0x170c53=_0x12847c?.['task_id']||_0x12847c?.[_0x5504c1(0x132)]||_0x12847c?.['id'];if(_0x170c53)return String(_0x170c53);let _0x506ec1=_0x12847c?.[_0x5504c1(0x108)]?.[0x0]?.[_0x5504c1(0x138)];if(typeof _0x506ec1!==_0x5504c1(0x10c))return null;try{let _0xe2bd8b=JSON['parse'](_0x506ec1);return _0xe2bd8b?.[_0x5504c1(0x170)]||_0xe2bd8b?.['message_id']||_0xe2bd8b?.['id']||null;}catch{return null;}}function a0_0x17d4(_0x16ef4b,_0x63810b){_0x16ef4b=_0x16ef4b-0x105;const _0x576fd5=a0_0x576f();let _0x17d462=_0x576fd5[_0x16ef4b];return _0x17d462;}async function X(_0x69c529,_0x567e74){const _0x20d575=a0_0x5bb32a;let _0x55942e=_0x567e74['now']??Date[_0x20d575(0x123)],_0x21dd2f=_0x55942e(),_0x2a328e=(_0x205712,_0x13857f,_0x32315d,_0x480595)=>{const _0x23d298=_0x20d575;_0x567e74['log'](O(U({'from_alias':_0x69c529[_0x23d298(0x120)],'to_alias':_0x69c529[_0x23d298(0x159)],'task_id':_0x13857f,'parent_task_id':_0x69c529['parentTaskId'],'network_id':_0x69c529[_0x23d298(0x15d)],'transport':_0x69c529['transport'],'status':_0x205712,'duration_ms':_0x55942e()-_0x21dd2f,'lifecycle_tracking':_0x69c529[_0x23d298(0x113)],..._0x32315d!==void 0x0?{'error_code':_0x480595||_0x23d298(0x13d),'error_message':N(_0x32315d)}:{}})));};_0x2a328e(_0x20d575(0x15e),null);try{let _0x14d5d7=await _0x567e74[_0x20d575(0x15a)](),_0x3a95ac=j(_0x14d5d7);if(_0x3a95ac)_0x2a328e(_0x20d575(0x163),_0x3a95ac);else{if(_0x14d5d7?.['ok']===!0x1||_0x14d5d7?.[_0x20d575(0x112)])_0x2a328e(_0x20d575(0x14e),_0x3a95ac,_0x14d5d7?.[_0x20d575(0x112)]||_0x20d575(0x15f),_0x20d575(0x179));else _0x2a328e(_0x20d575(0x14e),null,'CommHub\x20response\x20omitted\x20task_id',_0x20d575(0x105));}return _0x14d5d7;}catch(_0x3d86a4){throw _0x2a328e('failed',null,_0x3d86a4,_0x20d575(0x13d)),_0x3d86a4;}}async function Y(_0x216b74,_0x55ddc4){const _0x1653de=a0_0x5bb32a;return X({'fromAlias':_0x216b74[_0x1653de(0x120)],'toAlias':_0x216b74[_0x1653de(0x10e)],'parentTaskId':_0x216b74['parentTaskId']||null,'networkId':_0x216b74[_0x1653de(0x15d)]||null,'transport':'mcp_http','lifecycleTracking':_0x1653de(0x122)},_0x55ddc4);}class $ extends a0_0x54f089{[a0_0x5bb32a(0x16f)];[a0_0x5bb32a(0x10e)];[a0_0x5bb32a(0x12c)];[a0_0x5bb32a(0x178)];[a0_0x5bb32a(0x131)];[a0_0x5bb32a(0x164)];[a0_0x5bb32a(0x17b)];['heartbeatTimer'];[a0_0x5bb32a(0x153)];[a0_0x5bb32a(0x121)]=!0x1;constructor(_0x26bf74){const _0xee09d6=a0_0x5bb32a;super();if(this[_0xee09d6(0x16f)]=_0x26bf74[_0xee09d6(0x16f)][_0xee09d6(0x117)](/\/$/,''),this[_0xee09d6(0x10e)]=_0x26bf74[_0xee09d6(0x10e)],this['token']=_0x26bf74[_0xee09d6(0x12c)],this[_0xee09d6(0x178)]=_0x26bf74[_0xee09d6(0x178)]||_0xee09d6(0x17e),this[_0xee09d6(0x131)]=_0xee09d6(0x118)+_0x26bf74[_0xee09d6(0x10e)]+'-'+Date[_0xee09d6(0x123)]()[_0xee09d6(0x135)](0x24),this[_0xee09d6(0x164)]=_0x26bf74[_0xee09d6(0x164)]??0x2bf20,this[_0xee09d6(0x17b)]=_0x26bf74[_0xee09d6(0x17b)]??0xbb8,_0x26bf74['autoConnect']!==!0x1)this[_0xee09d6(0x141)]();}[a0_0x5bb32a(0x139)](_0x275f80){const _0x4ab468=a0_0x5bb32a;console[_0x4ab468(0x139)]('['+new Date()['toTimeString']()['slice'](0x0,0x8)+']\x20[commhub:'+this['alias']+']\x20'+_0x275f80);}async[a0_0x5bb32a(0x174)](_0x53c8c6,_0x5e5a73){const _0x3d30e6=a0_0x5bb32a;let _0x1f3570={'Content-Type':'application/json','Accept':'application/json,\x20text/event-stream'};if(this[_0x3d30e6(0x12c)])_0x1f3570[_0x3d30e6(0x15c)]=_0x3d30e6(0x127)+this['token'];let _0x38bb26=await(await fetch(this[_0x3d30e6(0x16f)]+'/mcp',{'method':'POST','headers':_0x1f3570,'body':JSON[_0x3d30e6(0x16c)]({'jsonrpc':_0x3d30e6(0x149),'id':Date[_0x3d30e6(0x123)](),'method':_0x3d30e6(0x12a),'params':{'name':_0x53c8c6,'arguments':_0x5e5a73}})}))[_0x3d30e6(0x138)](),_0x17744c=_0x38bb26['match'](/data: (.+)/),_0x5cb39f=_0x17744c?JSON[_0x3d30e6(0x16a)](_0x17744c[0x1]):JSON['parse'](_0x38bb26),_0x1cb2c3=_0x5cb39f?.[_0x3d30e6(0x115)]?.[_0x3d30e6(0x108)]?.[0x0]?.[_0x3d30e6(0x138)];return _0x1cb2c3?JSON[_0x3d30e6(0x16a)](_0x1cb2c3):_0x5cb39f;}async['connect'](){const _0x4488d6=a0_0x5bb32a;if(this[_0x4488d6(0x121)])return;this['running']=!0x0,await this[_0x4488d6(0x11e)](_0x4488d6(0x107)),this[_0x4488d6(0x139)](_0x4488d6(0x11a)),this[_0x4488d6(0x109)]=setInterval(()=>{const _0x2a9acc=_0x4488d6;this[_0x2a9acc(0x11e)](_0x2a9acc(0x107))[_0x2a9acc(0x14b)](_0x11a5a8=>this['log']('heartbeat\x20failed:\x20'+_0x11a5a8[_0x2a9acc(0x168)]));},this['heartbeatInterval']),this[_0x4488d6(0x17f)]();}async[a0_0x5bb32a(0x14d)](){const _0x488c11=a0_0x5bb32a;if(this[_0x488c11(0x121)]=!0x1,this['sseAbort']?.[_0x488c11(0x13f)](),this[_0x488c11(0x109)])clearInterval(this[_0x488c11(0x109)]);await this[_0x488c11(0x11e)](_0x488c11(0x17d))[_0x488c11(0x14b)](()=>{}),this[_0x488c11(0x139)](_0x488c11(0x133));}async[a0_0x5bb32a(0x15a)](_0x5c3688,_0xfa7926,_0x4e0e29=a0_0x5bb32a(0x165)){const _0x48a244=a0_0x5bb32a;return Y({'alias':_0x5c3688,'fromAlias':this[_0x48a244(0x10e)]},{'log':_0x1f9c2a=>console['log'](_0x1f9c2a),'send':()=>this[_0x48a244(0x174)]('send_task',{'alias':_0x5c3688,'task':_0xfa7926,'priority':_0x4e0e29,'from_session':this[_0x48a244(0x10e)]})});}async[a0_0x5bb32a(0x168)](_0x1145b7,_0x345324){const _0x4c1dd9=a0_0x5bb32a;return this[_0x4c1dd9(0x174)](_0x4c1dd9(0x16d),{'alias':_0x1145b7,'message':_0x345324,'from_session':this[_0x4c1dd9(0x10e)]});}async[a0_0x5bb32a(0x12f)](_0x5f2a0c,_0xa1ddc,_0x288c99=a0_0x5bb32a(0x11f)){const _0x14e868=a0_0x5bb32a;return this[_0x14e868(0x174)](_0x14e868(0x13b),{'in_reply_to':_0x5f2a0c,'text':_0xa1ddc,'status':_0x288c99});}async[a0_0x5bb32a(0x11e)](_0x4ce402,_0x602261){const _0x3614c5=a0_0x5bb32a;return this['call'](_0x3614c5(0x169),{'resume_id':this['resumeId'],'alias':this[_0x3614c5(0x10e)],'status':_0x4ce402,'server':a0_0x26deb8(),'hostname':a0_0x26deb8(),'agent':this['agent'],'project_dir':process['cwd'](),..._0x602261});}async[a0_0x5bb32a(0x119)](){const _0x374a78=a0_0x5bb32a;return this['call'](_0x374a78(0x137),{});}async[a0_0x5bb32a(0x14f)](_0x43f942,_0x195a47){const _0x3f86f5=a0_0x5bb32a;return this[_0x3f86f5(0x174)](_0x3f86f5(0x14f),{'message':_0x43f942,'filter_server':_0x195a47?.[_0x3f86f5(0x144)],'filter_status':_0x195a47?.['status']});}async[a0_0x5bb32a(0x17f)](){const _0x144d6f=a0_0x5bb32a;let _0x4f58f8=encodeURIComponent(this[_0x144d6f(0x10e)]),_0x5e7f60=this[_0x144d6f(0x16f)]+_0x144d6f(0x177)+_0x4f58f8,_0x5400af=this['reconnectDelay'];while(this[_0x144d6f(0x121)]){try{this[_0x144d6f(0x153)]=new AbortController();let _0x252802={'Accept':_0x144d6f(0x14c)};if(this['token'])_0x252802[_0x144d6f(0x15c)]=_0x144d6f(0x127)+this[_0x144d6f(0x12c)];let _0x4ec7d0=await fetch(_0x5e7f60,{'headers':_0x252802,'signal':this[_0x144d6f(0x153)]['signal']});if(!_0x4ec7d0['ok']||!_0x4ec7d0[_0x144d6f(0x167)]){this[_0x144d6f(0x139)]('SSE\x20failed:\x20'+_0x4ec7d0[_0x144d6f(0x11e)]),await this[_0x144d6f(0x126)](_0x5400af),_0x5400af=Math[_0x144d6f(0x142)](_0x5400af*1.5,0xea60);continue;}_0x5400af=this['reconnectDelay'];let _0x18d93e=_0x4ec7d0[_0x144d6f(0x167)][_0x144d6f(0x156)](),_0x2e16c7=new TextDecoder(),_0x3c41ef='';while(this['running']){let {done:_0x8ea213,value:_0x4d627b}=await _0x18d93e[_0x144d6f(0x175)]();if(_0x8ea213)break;_0x3c41ef+=_0x2e16c7[_0x144d6f(0x150)](_0x4d627b,{'stream':!0x0});let _0x5b198e=_0x3c41ef[_0x144d6f(0x162)]('\x0a');_0x3c41ef=_0x5b198e[_0x144d6f(0x146)]()||'';for(let _0xf1edd8 of _0x5b198e){if(!_0xf1edd8[_0x144d6f(0x130)]('data:\x20'))continue;try{let _0x5dd0be=JSON['parse'](_0xf1edd8[_0x144d6f(0x13c)](0x6));if(_0x5dd0be[_0x144d6f(0x125)]===_0x144d6f(0x114)){this[_0x144d6f(0x139)](_0x144d6f(0x154)),this[_0x144d6f(0x17a)](_0x144d6f(0x114));continue;}if(_0x5dd0be[_0x144d6f(0x125)]===_0x144d6f(0x11b)||_0x5dd0be['type']==='new_message'||_0x5dd0be[_0x144d6f(0x125)]==='broadcast')await this[_0x144d6f(0x147)]();}catch{}}}}catch(_0x196475){if(_0x196475[_0x144d6f(0x12e)]===_0x144d6f(0x160))break;this[_0x144d6f(0x17a)]('error',_0x196475),this['log'](_0x144d6f(0x111)+_0x196475[_0x144d6f(0x168)]);}if(this[_0x144d6f(0x121)])this[_0x144d6f(0x17a)](_0x144d6f(0x133)),this[_0x144d6f(0x139)]('SSE\x20reconnecting\x20in\x20'+_0x5400af/0x3e8+'s...'),await this[_0x144d6f(0x126)](_0x5400af),_0x5400af=Math['min'](_0x5400af*1.5,0xea60);}}async[a0_0x5bb32a(0x147)](){const _0x3608fe=a0_0x5bb32a;try{let _0x443b19=(await this[_0x3608fe(0x174)](_0x3608fe(0x16e),{'alias':this['alias'],'limit':0xa}))?.['messages']||[];for(let _0x3aab68 of _0x443b19)await this[_0x3608fe(0x174)](_0x3608fe(0x157),{'alias':this[_0x3608fe(0x10e)],'message_id':_0x3aab68['id']}),this[_0x3608fe(0x139)]('←\x20'+_0x3aab68['from_session']+':\x20'+_0x3aab68[_0x3608fe(0x108)][_0x3608fe(0x13c)](0x0,0x3c)),this[_0x3608fe(0x17a)](_0x3608fe(0x12d),_0x3aab68),this['emit'](_0x3608fe(0x168),_0x3aab68);}catch(_0x5dbaec){this[_0x3608fe(0x139)](_0x3608fe(0x176)+_0x5dbaec[_0x3608fe(0x168)]);}}[a0_0x5bb32a(0x126)](_0x494e83){return new Promise(_0x3c2cba=>setTimeout(_0x3c2cba,_0x494e83));}}var F=$;export{F as default,$ as CommHub};
|