@sleep2agi/agent-network 2.3.0-preview.173 → 2.3.0-preview.174

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.
@@ -1 +1 @@
1
- const a0_0x52b310=a0_0x1dfc;(function(_0x2e43ef,_0xb210ec){const _0x620bf6=a0_0x1dfc,_0x563cb6=_0x2e43ef();while(!![]){try{const _0x2d2c9b=parseInt(_0x620bf6(0x225))/0x1*(parseInt(_0x620bf6(0x23c))/0x2)+-parseInt(_0x620bf6(0x255))/0x3+parseInt(_0x620bf6(0x239))/0x4+-parseInt(_0x620bf6(0x244))/0x5+parseInt(_0x620bf6(0x251))/0x6*(-parseInt(_0x620bf6(0x231))/0x7)+parseInt(_0x620bf6(0x204))/0x8+parseInt(_0x620bf6(0x223))/0x9*(parseInt(_0x620bf6(0x1ed))/0xa);if(_0x2d2c9b===_0xb210ec)break;else _0x563cb6['push'](_0x563cb6['shift']());}catch(_0x3fe8fe){_0x563cb6['push'](_0x563cb6['shift']());}}}(a0_0x4155,0x1f6bf));import{EventEmitter as a0_0x22e8a3}from'events';import{hostname as a0_0x3642fe}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x5d9ff9,_0x50ac8d)=>(_0x5d9ff9??_0x50ac8d)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x52b310(0x22b)](0x0,0xf0);function N(_0x83e906){const _0x596b63=a0_0x52b310;return(_0x83e906 instanceof Error?_0x83e906[_0x596b63(0x224)]:String(_0x83e906??_0x596b63(0x228)))[_0x596b63(0x230)](K,_0x596b63(0x215))[_0x596b63(0x230)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function a0_0x4155(){const _0x4b5449=['\x20parent_task_id=','Authorization','AbortError','duration_ms','emit','get_inbox','agent','send_reply','heartbeat\x20failed:\x20','application/json,\x20text/event-stream','transport','networkId','token','1307456rOmGvK','lifecycle_tracking','type','parse','min','from_alias','read','getAllStatus','mcp_http','error_message','[commhub:task]\x20',']\x20[commhub:','error','Bearer\x20','\x20transport=','send_message','CommHub\x20rejected\x20task','[REDACTED]','\x20task_id=','split','heartbeatTimer','send_rejected','task.send.failed','report_status','error_code','offline','inbox\x20error:\x20','result','sseAbort','fromAlias','network_id','2871rnqXdJ','message','803jvfvNR','sdk','/mcp','unknown\x20error','sdk-','toTimeString','slice','url','lifecycleTracking','now','failed','replace','1659196yRBvQx','registered','running','get_all_status','task.send.delivered','send','task.started','missing_task_id','677332NzfcBW','idle','CommHub\x20response\x20omitted\x20task_id','190WJPDNY','string','disconnect','connectSSE','alias','\x20from=','body','application/json','867005LNlOUv','match','task.expired','log','delivered','task_id','\x20lifecycle=','POST','sleep','processInbox','not_tracked','reconnectDelay','\x20network_id=','6jSNbby','abort','cwd','broadcast','95910edEMKM','to_alias','sending','\x20error=','resumeId','status','send_failed','\x20duration_ms=','startsWith','2.0','task.replied','connect','<missing>','SSE\x20error:\x20','data:\x20','SSE\x20reconnecting\x20in\x20','toString','getReader','stringify','disconnected','normal','SSE\x20failed:\x20','json','/events/','name','autoConnect','content','5080VNtSlF','heartbeatInterval','send_task','text','catch','reply','<pending>','message_id','completed','call'];a0_0x4155=function(){return _0x4b5449;};return a0_0x4155();}function O(_0x2526eb,_0x6ff059=process.env.ANET_TASK_TRACE_FORMAT===a0_0x52b310(0x1e8)){const _0x53c005=a0_0x52b310;if(_0x6ff059)return JSON[_0x53c005(0x1e4)](_0x2526eb);let _0xcf8d4b=L(_0x2526eb['parent_task_id'],_0x53c005(0x1de)),_0x2c601a=L(_0x2526eb[_0x53c005(0x249)],_0x53c005(0x1f3)),_0x18258e=_0x2526eb['error_code']?_0x53c005(0x1d5)+_0x2526eb[_0x53c005(0x21c)]+':'+(_0x2526eb[_0x53c005(0x20d)]??''):'';return _0x53c005(0x20e)+_0x2526eb[_0x53c005(0x1d7)]+_0x53c005(0x241)+L(_0x2526eb[_0x53c005(0x209)],'<unknown>')+'\x20to='+L(_0x2526eb[_0x53c005(0x256)],'<unknown>')+_0x53c005(0x216)+_0x2c601a+_0x53c005(0x1f7)+_0xcf8d4b+_0x53c005(0x250)+L(_0x2526eb[_0x53c005(0x222)],'<unknown>')+_0x53c005(0x212)+_0x2526eb[_0x53c005(0x201)]+_0x53c005(0x1d9)+_0x2526eb[_0x53c005(0x1fa)]+_0x53c005(0x24a)+_0x2526eb[_0x53c005(0x205)]+_0x18258e;}function U(_0x37c52b){const _0x16b158=a0_0x52b310;return{'event':{'sending':'task.send.start','delivered':_0x16b158(0x235),'failed':_0x16b158(0x21a),'acked':'task.ack','started':_0x16b158(0x237),'replied':_0x16b158(0x1dc),'expired':_0x16b158(0x246)}[_0x37c52b[_0x16b158(0x1d7)]],..._0x37c52b};}function j(_0x1d5140){const _0x1cf14b=a0_0x52b310;let _0x25b150=_0x1d5140?.[_0x1cf14b(0x249)]||_0x1d5140?.[_0x1cf14b(0x1f4)]||_0x1d5140?.['id'];if(_0x25b150)return String(_0x25b150);let _0x5b2a31=_0x1d5140?.[_0x1cf14b(0x1ec)]?.[0x0]?.[_0x1cf14b(0x1f0)];if(typeof _0x5b2a31!==_0x1cf14b(0x23d))return null;try{let _0xbe084b=JSON['parse'](_0x5b2a31);return _0xbe084b?.[_0x1cf14b(0x249)]||_0xbe084b?.[_0x1cf14b(0x1f4)]||_0xbe084b?.['id']||null;}catch{return null;}}async function X(_0x390f6c,_0x3f6dd9){const _0x473042=a0_0x52b310;let _0x8362fa=_0x3f6dd9[_0x473042(0x22e)]??Date[_0x473042(0x22e)],_0x5b5a89=_0x8362fa(),_0x3ac464=(_0x37075a,_0x10a501,_0x3cb586,_0x1f178c)=>{const _0x53e704=_0x473042;_0x3f6dd9[_0x53e704(0x247)](O(U({'from_alias':_0x390f6c[_0x53e704(0x221)],'to_alias':_0x390f6c['toAlias'],'task_id':_0x10a501,'parent_task_id':_0x390f6c['parentTaskId'],'network_id':_0x390f6c[_0x53e704(0x202)],'transport':_0x390f6c[_0x53e704(0x201)],'status':_0x37075a,'duration_ms':_0x8362fa()-_0x5b5a89,'lifecycle_tracking':_0x390f6c[_0x53e704(0x22d)],..._0x3cb586!==void 0x0?{'error_code':_0x1f178c||_0x53e704(0x1d8),'error_message':N(_0x3cb586)}:{}})));};_0x3ac464(_0x473042(0x257),null);try{let _0x4e8c65=await _0x3f6dd9[_0x473042(0x236)](),_0x360513=j(_0x4e8c65);if(_0x360513)_0x3ac464(_0x473042(0x248),_0x360513);else{if(_0x4e8c65?.['ok']===!0x1||_0x4e8c65?.['error'])_0x3ac464(_0x473042(0x22f),_0x360513,_0x4e8c65?.[_0x473042(0x210)]||_0x473042(0x214),_0x473042(0x219));else _0x3ac464(_0x473042(0x22f),null,_0x473042(0x23b),_0x473042(0x238));}return _0x4e8c65;}catch(_0xc5ef1c){throw _0x3ac464(_0x473042(0x22f),null,_0xc5ef1c,'send_failed'),_0xc5ef1c;}}async function Y(_0x5d1828,_0x5cacac){const _0x4b5d39=a0_0x52b310;return X({'fromAlias':_0x5d1828['fromAlias'],'toAlias':_0x5d1828[_0x4b5d39(0x240)],'parentTaskId':_0x5d1828['parentTaskId']||null,'networkId':_0x5d1828[_0x4b5d39(0x202)]||null,'transport':_0x4b5d39(0x20c),'lifecycleTracking':_0x4b5d39(0x24e)},_0x5cacac);}class $ extends a0_0x22e8a3{[a0_0x52b310(0x22c)];['alias'];[a0_0x52b310(0x203)];[a0_0x52b310(0x1fd)];[a0_0x52b310(0x1d6)];[a0_0x52b310(0x1ee)];[a0_0x52b310(0x24f)];[a0_0x52b310(0x218)];[a0_0x52b310(0x220)];[a0_0x52b310(0x233)]=!0x1;constructor(_0x18e763){const _0x162add=a0_0x52b310;super();if(this[_0x162add(0x22c)]=_0x18e763[_0x162add(0x22c)]['replace'](/\/$/,''),this[_0x162add(0x240)]=_0x18e763[_0x162add(0x240)],this[_0x162add(0x203)]=_0x18e763['token'],this[_0x162add(0x1fd)]=_0x18e763[_0x162add(0x1fd)]||_0x162add(0x226),this['resumeId']=_0x162add(0x229)+_0x18e763[_0x162add(0x240)]+'-'+Date['now']()[_0x162add(0x1e2)](0x24),this[_0x162add(0x1ee)]=_0x18e763['heartbeatInterval']??0x2bf20,this[_0x162add(0x24f)]=_0x18e763[_0x162add(0x24f)]??0xbb8,_0x18e763[_0x162add(0x1eb)]!==!0x1)this['connect']();}[a0_0x52b310(0x247)](_0x3e4144){const _0xcb57a0=a0_0x52b310;console[_0xcb57a0(0x247)]('['+new Date()[_0xcb57a0(0x22a)]()[_0xcb57a0(0x22b)](0x0,0x8)+_0xcb57a0(0x20f)+this[_0xcb57a0(0x240)]+']\x20'+_0x3e4144);}async[a0_0x52b310(0x1f6)](_0x2fbab9,_0x310f78){const _0x22111c=a0_0x52b310;let _0x63202c={'Content-Type':_0x22111c(0x243),'Accept':_0x22111c(0x200)};if(this[_0x22111c(0x203)])_0x63202c[_0x22111c(0x1f8)]=_0x22111c(0x211)+this[_0x22111c(0x203)];let _0xc16867=await(await fetch(this[_0x22111c(0x22c)]+_0x22111c(0x227),{'method':_0x22111c(0x24b),'headers':_0x63202c,'body':JSON[_0x22111c(0x1e4)]({'jsonrpc':_0x22111c(0x1db),'id':Date[_0x22111c(0x22e)](),'method':'tools/call','params':{'name':_0x2fbab9,'arguments':_0x310f78}})}))['text'](),_0xd05ac5=_0xc16867[_0x22111c(0x245)](/data: (.+)/),_0x1837dd=_0xd05ac5?JSON[_0x22111c(0x207)](_0xd05ac5[0x1]):JSON[_0x22111c(0x207)](_0xc16867),_0x36e342=_0x1837dd?.[_0x22111c(0x21f)]?.[_0x22111c(0x1ec)]?.[0x0]?.[_0x22111c(0x1f0)];return _0x36e342?JSON[_0x22111c(0x207)](_0x36e342):_0x1837dd;}async[a0_0x52b310(0x1dd)](){const _0x1f5f4b=a0_0x52b310;if(this[_0x1f5f4b(0x233)])return;this['running']=!0x0,await this[_0x1f5f4b(0x1d7)](_0x1f5f4b(0x23a)),this[_0x1f5f4b(0x247)](_0x1f5f4b(0x232)),this[_0x1f5f4b(0x218)]=setInterval(()=>{const _0x158e3c=_0x1f5f4b;this[_0x158e3c(0x1d7)](_0x158e3c(0x23a))[_0x158e3c(0x1f1)](_0x65c82d=>this[_0x158e3c(0x247)](_0x158e3c(0x1ff)+_0x65c82d[_0x158e3c(0x224)]));},this[_0x1f5f4b(0x1ee)]),this[_0x1f5f4b(0x23f)]();}async[a0_0x52b310(0x23e)](){const _0x185118=a0_0x52b310;if(this[_0x185118(0x233)]=!0x1,this[_0x185118(0x220)]?.[_0x185118(0x252)](),this[_0x185118(0x218)])clearInterval(this[_0x185118(0x218)]);await this[_0x185118(0x1d7)](_0x185118(0x21d))['catch'](()=>{}),this[_0x185118(0x247)](_0x185118(0x1e5));}async[a0_0x52b310(0x236)](_0xa4f42e,_0x45629b,_0x3cdf37=a0_0x52b310(0x1e6)){const _0x2d3a71=a0_0x52b310;return Y({'alias':_0xa4f42e,'fromAlias':this[_0x2d3a71(0x240)]},{'log':_0x4a4dc2=>console[_0x2d3a71(0x247)](_0x4a4dc2),'send':()=>this[_0x2d3a71(0x1f6)](_0x2d3a71(0x1ef),{'alias':_0xa4f42e,'task':_0x45629b,'priority':_0x3cdf37,'from_session':this[_0x2d3a71(0x240)]})});}async[a0_0x52b310(0x224)](_0x271e57,_0x200a3b){const _0x400055=a0_0x52b310;return this[_0x400055(0x1f6)](_0x400055(0x213),{'alias':_0x271e57,'message':_0x200a3b,'from_session':this['alias']});}async[a0_0x52b310(0x1f2)](_0x5d7952,_0xaf634e,_0x103346=a0_0x52b310(0x1f5)){const _0x501287=a0_0x52b310;return this[_0x501287(0x1f6)](_0x501287(0x1fe),{'in_reply_to':_0x5d7952,'text':_0xaf634e,'status':_0x103346});}async[a0_0x52b310(0x1d7)](_0x2a03a1,_0x24f94b){const _0x18a5d8=a0_0x52b310;return this[_0x18a5d8(0x1f6)](_0x18a5d8(0x21b),{'resume_id':this[_0x18a5d8(0x1d6)],'alias':this['alias'],'status':_0x2a03a1,'server':a0_0x3642fe(),'hostname':a0_0x3642fe(),'agent':this['agent'],'project_dir':process[_0x18a5d8(0x253)](),..._0x24f94b});}async[a0_0x52b310(0x20b)](){const _0x149719=a0_0x52b310;return this['call'](_0x149719(0x234),{});}async[a0_0x52b310(0x254)](_0x151dba,_0x52330a){const _0x1e47b0=a0_0x52b310;return this[_0x1e47b0(0x1f6)]('broadcast',{'message':_0x151dba,'filter_server':_0x52330a?.['server'],'filter_status':_0x52330a?.[_0x1e47b0(0x1d7)]});}async[a0_0x52b310(0x23f)](){const _0x5aaa6c=a0_0x52b310;let _0x475ea0=encodeURIComponent(this[_0x5aaa6c(0x240)]),_0x9db806=this[_0x5aaa6c(0x22c)]+_0x5aaa6c(0x1e9)+_0x475ea0,_0x4443da=this[_0x5aaa6c(0x24f)];while(this['running']){try{this['sseAbort']=new AbortController();let _0x525127={'Accept':'text/event-stream'};if(this['token'])_0x525127[_0x5aaa6c(0x1f8)]=_0x5aaa6c(0x211)+this['token'];let _0x4e6c9f=await fetch(_0x9db806,{'headers':_0x525127,'signal':this[_0x5aaa6c(0x220)]['signal']});if(!_0x4e6c9f['ok']||!_0x4e6c9f['body']){this[_0x5aaa6c(0x247)](_0x5aaa6c(0x1e7)+_0x4e6c9f[_0x5aaa6c(0x1d7)]),await this[_0x5aaa6c(0x24c)](_0x4443da),_0x4443da=Math[_0x5aaa6c(0x208)](_0x4443da*1.5,0xea60);continue;}_0x4443da=this[_0x5aaa6c(0x24f)];let _0x29c2ec=_0x4e6c9f[_0x5aaa6c(0x242)][_0x5aaa6c(0x1e3)](),_0x288390=new TextDecoder(),_0x7c38c='';while(this['running']){let {done:_0x4914cf,value:_0x3e96bc}=await _0x29c2ec[_0x5aaa6c(0x20a)]();if(_0x4914cf)break;_0x7c38c+=_0x288390['decode'](_0x3e96bc,{'stream':!0x0});let _0x324708=_0x7c38c[_0x5aaa6c(0x217)]('\x0a');_0x7c38c=_0x324708['pop']()||'';for(let _0x51efd3 of _0x324708){if(!_0x51efd3[_0x5aaa6c(0x1da)](_0x5aaa6c(0x1e0)))continue;try{let _0x259fc6=JSON[_0x5aaa6c(0x207)](_0x51efd3['slice'](0x6));if(_0x259fc6[_0x5aaa6c(0x206)]==='connected'){this['log']('SSE\x20connected'),this[_0x5aaa6c(0x1fb)]('connected');continue;}if(_0x259fc6['type']==='new_task'||_0x259fc6['type']==='new_message'||_0x259fc6['type']==='broadcast')await this['processInbox']();}catch{}}}}catch(_0xc5ff38){if(_0xc5ff38[_0x5aaa6c(0x1ea)]===_0x5aaa6c(0x1f9))break;this[_0x5aaa6c(0x1fb)]('error',_0xc5ff38),this['log'](_0x5aaa6c(0x1df)+_0xc5ff38[_0x5aaa6c(0x224)]);}if(this['running'])this[_0x5aaa6c(0x1fb)](_0x5aaa6c(0x1e5)),this['log'](_0x5aaa6c(0x1e1)+_0x4443da/0x3e8+'s...'),await this[_0x5aaa6c(0x24c)](_0x4443da),_0x4443da=Math[_0x5aaa6c(0x208)](_0x4443da*1.5,0xea60);}}async[a0_0x52b310(0x24d)](){const _0x44b10a=a0_0x52b310;try{let _0x5773dd=(await this['call'](_0x44b10a(0x1fc),{'alias':this[_0x44b10a(0x240)],'limit':0xa}))?.['messages']||[];for(let _0x3f5bf9 of _0x5773dd)await this[_0x44b10a(0x1f6)]('ack_inbox',{'alias':this[_0x44b10a(0x240)],'message_id':_0x3f5bf9['id']}),this[_0x44b10a(0x247)]('←\x20'+_0x3f5bf9['from_session']+':\x20'+_0x3f5bf9[_0x44b10a(0x1ec)][_0x44b10a(0x22b)](0x0,0x3c)),this['emit']('task',_0x3f5bf9),this['emit'](_0x44b10a(0x224),_0x3f5bf9);}catch(_0x533837){this['log'](_0x44b10a(0x21e)+_0x533837['message']);}}[a0_0x52b310(0x24c)](_0x164e8e){return new Promise(_0x296c02=>setTimeout(_0x296c02,_0x164e8e));}}var F=$;function a0_0x1dfc(_0x3ba0d5,_0x114305){_0x3ba0d5=_0x3ba0d5-0x1d5;const _0x415591=a0_0x4155();let _0x1dfc08=_0x415591[_0x3ba0d5];return _0x1dfc08;}export{F as default,$ as CommHub};
1
+ const a0_0x18b3e1=a0_0x97b3;(function(_0x3a61f4,_0x5af702){const _0x3d8dba=a0_0x97b3,_0x4e9a63=_0x3a61f4();while(!![]){try{const _0x78eb0e=parseInt(_0x3d8dba(0x17b))/0x1+-parseInt(_0x3d8dba(0x13e))/0x2+parseInt(_0x3d8dba(0x133))/0x3+parseInt(_0x3d8dba(0x132))/0x4*(-parseInt(_0x3d8dba(0x16b))/0x5)+parseInt(_0x3d8dba(0x171))/0x6+-parseInt(_0x3d8dba(0x142))/0x7+parseInt(_0x3d8dba(0x186))/0x8*(parseInt(_0x3d8dba(0x18f))/0x9);if(_0x78eb0e===_0x5af702)break;else _0x4e9a63['push'](_0x4e9a63['shift']());}catch(_0x211567){_0x4e9a63['push'](_0x4e9a63['shift']());}}}(a0_0x3754,0x832b6));import{EventEmitter as a0_0x43e123}from'events';import{hostname as a0_0x340f9e}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x5803a7,_0xc354cf)=>(_0x5803a7??_0xc354cf)[a0_0x18b3e1(0x159)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x18b3e1(0x14f)](0x0,0xf0);function N(_0x102e39){const _0x35e30d=a0_0x18b3e1;return(_0x102e39 instanceof Error?_0x102e39[_0x35e30d(0x119)]:String(_0x102e39??_0x35e30d(0x174)))[_0x35e30d(0x159)](K,_0x35e30d(0x156))[_0x35e30d(0x159)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x35e30d(0x14f)](0x0,0xf0);}function O(_0x5e7df9,_0x97ba5b=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x158304=a0_0x18b3e1;if(_0x97ba5b)return JSON[_0x158304(0x131)](_0x5e7df9);let _0x2a7c19=L(_0x5e7df9['parent_task_id'],_0x158304(0x128)),_0x5a0a09=L(_0x5e7df9[_0x158304(0x187)],_0x158304(0x12c)),_0x114abe=_0x5e7df9[_0x158304(0x13c)]?_0x158304(0x161)+_0x5e7df9[_0x158304(0x13c)]+':'+(_0x5e7df9['error_message']??''):'';return'[commhub:task]\x20'+_0x5e7df9[_0x158304(0x18a)]+_0x158304(0x11c)+L(_0x5e7df9[_0x158304(0x17f)],_0x158304(0x163))+'\x20to='+L(_0x5e7df9[_0x158304(0x122)],'<unknown>')+_0x158304(0x16a)+_0x5a0a09+'\x20parent_task_id='+_0x2a7c19+_0x158304(0x124)+L(_0x5e7df9[_0x158304(0x176)],_0x158304(0x163))+_0x158304(0x143)+_0x5e7df9['transport']+'\x20duration_ms='+_0x5e7df9[_0x158304(0x14e)]+'\x20lifecycle='+_0x5e7df9[_0x158304(0x153)]+_0x114abe;}function U(_0x4b15e7){const _0x33e6b9=a0_0x18b3e1;return{'event':{'sending':_0x33e6b9(0x130),'delivered':_0x33e6b9(0x125),'failed':_0x33e6b9(0x170),'acked':'task.ack','started':'task.started','replied':_0x33e6b9(0x151),'expired':'task.expired'}[_0x4b15e7[_0x33e6b9(0x18a)]],..._0x4b15e7};}function j(_0x5e61ff){const _0xe043d3=a0_0x18b3e1;let _0x267bbf=_0x5e61ff?.['task_id']||_0x5e61ff?.[_0xe043d3(0x189)]||_0x5e61ff?.['id'];if(_0x267bbf)return String(_0x267bbf);let _0x3347fb=_0x5e61ff?.[_0xe043d3(0x146)]?.[0x0]?.[_0xe043d3(0x18c)];if(typeof _0x3347fb!==_0xe043d3(0x144))return null;try{let _0x4d4a19=JSON[_0xe043d3(0x12b)](_0x3347fb);return _0x4d4a19?.[_0xe043d3(0x187)]||_0x4d4a19?.[_0xe043d3(0x189)]||_0x4d4a19?.['id']||null;}catch{return null;}}async function X(_0x5d9542,_0x4fcd8e){const _0x40dc84=a0_0x18b3e1;let _0x27049e=_0x4fcd8e[_0x40dc84(0x16c)]??Date['now'],_0x2621a9=_0x27049e(),_0x39f2d7=(_0x83f5f8,_0x42b7dd,_0x514b63,_0x359a72)=>{const _0x29dac1=_0x40dc84;_0x4fcd8e[_0x29dac1(0x121)](O(U({'from_alias':_0x5d9542[_0x29dac1(0x126)],'to_alias':_0x5d9542['toAlias'],'task_id':_0x42b7dd,'parent_task_id':_0x5d9542[_0x29dac1(0x150)],'network_id':_0x5d9542[_0x29dac1(0x165)],'transport':_0x5d9542[_0x29dac1(0x12f)],'status':_0x83f5f8,'duration_ms':_0x27049e()-_0x2621a9,'lifecycle_tracking':_0x5d9542[_0x29dac1(0x127)],..._0x514b63!==void 0x0?{'error_code':_0x359a72||_0x29dac1(0x14d),'error_message':N(_0x514b63)}:{}})));};_0x39f2d7(_0x40dc84(0x169),null);try{let _0x17a043=await _0x4fcd8e[_0x40dc84(0x16d)](),_0x3a36e5=j(_0x17a043);if(_0x3a36e5)_0x39f2d7(_0x40dc84(0x178),_0x3a36e5);else{if(_0x17a043?.['ok']===!0x1||_0x17a043?.[_0x40dc84(0x11e)])_0x39f2d7('failed',_0x3a36e5,_0x17a043?.[_0x40dc84(0x11e)]||_0x40dc84(0x13a),'send_rejected');else _0x39f2d7(_0x40dc84(0x17a),null,_0x40dc84(0x15a),_0x40dc84(0x191));}return _0x17a043;}catch(_0xb611c7){throw _0x39f2d7(_0x40dc84(0x17a),null,_0xb611c7,_0x40dc84(0x14d)),_0xb611c7;}}function a0_0x3754(){const _0x499dc0=['from_session','heartbeat\x20failed:\x20','\x20error=','application/json','<unknown>','broadcast','networkId','messages','heartbeatInterval','data:\x20','sending','\x20task_id=','6750dffRZq','now','send','Bearer\x20','inbox\x20error:\x20','task.send.failed','5491818swYJXU','toTimeString','type','unknown\x20error','reply','network_id','s...','delivered','disconnected','failed','308892CscMCU','send_reply','catch','get_inbox','from_alias','startsWith','split','SSE\x20connected','alias','text/event-stream','url','8NBviRF','task_id','sdk','message_id','status','connectSSE','text','idle','SSE\x20reconnecting\x20in\x20','6049737IQzTwT','match','missing_task_id','tools/call','message','heartbeatTimer','autoConnect','\x20from=','not_tracked','error','name','signal','log','to_alias','completed','\x20network_id=','task.send.delivered','fromAlias','lifecycleTracking','<missing>','running','call','parse','<pending>','connected','new_task','transport','task.send.start','stringify','1996lTrLpf','1562121velXnW','sdk-','2.0','AbortError','sseAbort','processInbox','token','CommHub\x20rejected\x20task','disconnect','error_code','normal','426842waMYmq','body','resumeId','min','6949278YbEMTx','\x20transport=','string','agent','content','Authorization','emit','/events/','get_all_status','SSE\x20error:\x20','server','send_failed','duration_ms','slice','parentTaskId','task.replied','/mcp','lifecycle_tracking','sleep','connect','[REDACTED]','reconnectDelay','SSE\x20failed:\x20','replace','CommHub\x20response\x20omitted\x20task_id','toString','ack_inbox','offline',']\x20[commhub:'];a0_0x3754=function(){return _0x499dc0;};return a0_0x3754();}function a0_0x97b3(_0xa9bc94,_0x458ed4){_0xa9bc94=_0xa9bc94-0x118;const _0x3754df=a0_0x3754();let _0x97b3ec=_0x3754df[_0xa9bc94];return _0x97b3ec;}async function Y(_0x2a8317,_0x3312f4){const _0x24afa9=a0_0x18b3e1;return X({'fromAlias':_0x2a8317['fromAlias'],'toAlias':_0x2a8317[_0x24afa9(0x183)],'parentTaskId':_0x2a8317[_0x24afa9(0x150)]||null,'networkId':_0x2a8317[_0x24afa9(0x165)]||null,'transport':'mcp_http','lifecycleTracking':_0x24afa9(0x11d)},_0x3312f4);}class $ extends a0_0x43e123{[a0_0x18b3e1(0x185)];['alias'];['token'];['agent'];[a0_0x18b3e1(0x140)];['heartbeatInterval'];[a0_0x18b3e1(0x157)];[a0_0x18b3e1(0x11a)];[a0_0x18b3e1(0x137)];[a0_0x18b3e1(0x129)]=!0x1;constructor(_0x5abc03){const _0x4bb21a=a0_0x18b3e1;super();if(this[_0x4bb21a(0x185)]=_0x5abc03[_0x4bb21a(0x185)][_0x4bb21a(0x159)](/\/$/,''),this[_0x4bb21a(0x183)]=_0x5abc03['alias'],this['token']=_0x5abc03[_0x4bb21a(0x139)],this[_0x4bb21a(0x145)]=_0x5abc03[_0x4bb21a(0x145)]||_0x4bb21a(0x188),this[_0x4bb21a(0x140)]=_0x4bb21a(0x134)+_0x5abc03[_0x4bb21a(0x183)]+'-'+Date[_0x4bb21a(0x16c)]()[_0x4bb21a(0x15b)](0x24),this[_0x4bb21a(0x167)]=_0x5abc03[_0x4bb21a(0x167)]??0x2bf20,this['reconnectDelay']=_0x5abc03[_0x4bb21a(0x157)]??0xbb8,_0x5abc03[_0x4bb21a(0x11b)]!==!0x1)this[_0x4bb21a(0x155)]();}[a0_0x18b3e1(0x121)](_0x31b65a){const _0x666038=a0_0x18b3e1;console[_0x666038(0x121)]('['+new Date()[_0x666038(0x172)]()['slice'](0x0,0x8)+_0x666038(0x15e)+this[_0x666038(0x183)]+']\x20'+_0x31b65a);}async[a0_0x18b3e1(0x12a)](_0x1dc431,_0x227a4d){const _0x541681=a0_0x18b3e1;let _0x59b9fb={'Content-Type':_0x541681(0x162),'Accept':'application/json,\x20text/event-stream'};if(this[_0x541681(0x139)])_0x59b9fb[_0x541681(0x147)]=_0x541681(0x16e)+this[_0x541681(0x139)];let _0x1a2fdd=await(await fetch(this[_0x541681(0x185)]+_0x541681(0x152),{'method':'POST','headers':_0x59b9fb,'body':JSON['stringify']({'jsonrpc':_0x541681(0x135),'id':Date[_0x541681(0x16c)](),'method':_0x541681(0x118),'params':{'name':_0x1dc431,'arguments':_0x227a4d}})}))[_0x541681(0x18c)](),_0x31bd42=_0x1a2fdd[_0x541681(0x190)](/data: (.+)/),_0x5689ed=_0x31bd42?JSON['parse'](_0x31bd42[0x1]):JSON[_0x541681(0x12b)](_0x1a2fdd),_0x54bc88=_0x5689ed?.['result']?.[_0x541681(0x146)]?.[0x0]?.[_0x541681(0x18c)];return _0x54bc88?JSON[_0x541681(0x12b)](_0x54bc88):_0x5689ed;}async[a0_0x18b3e1(0x155)](){const _0x4abd0c=a0_0x18b3e1;if(this[_0x4abd0c(0x129)])return;this[_0x4abd0c(0x129)]=!0x0,await this[_0x4abd0c(0x18a)](_0x4abd0c(0x18d)),this[_0x4abd0c(0x121)]('registered'),this['heartbeatTimer']=setInterval(()=>{const _0x358895=_0x4abd0c;this[_0x358895(0x18a)](_0x358895(0x18d))[_0x358895(0x17d)](_0x2b9785=>this['log'](_0x358895(0x160)+_0x2b9785[_0x358895(0x119)]));},this[_0x4abd0c(0x167)]),this[_0x4abd0c(0x18b)]();}async[a0_0x18b3e1(0x13b)](){const _0x3741c3=a0_0x18b3e1;if(this['running']=!0x1,this[_0x3741c3(0x137)]?.['abort'](),this[_0x3741c3(0x11a)])clearInterval(this[_0x3741c3(0x11a)]);await this[_0x3741c3(0x18a)](_0x3741c3(0x15d))[_0x3741c3(0x17d)](()=>{}),this['log'](_0x3741c3(0x179));}async[a0_0x18b3e1(0x16d)](_0x50762f,_0x1302ce,_0xeecfad=a0_0x18b3e1(0x13d)){const _0x4c2e63=a0_0x18b3e1;return Y({'alias':_0x50762f,'fromAlias':this[_0x4c2e63(0x183)]},{'log':_0x260698=>console[_0x4c2e63(0x121)](_0x260698),'send':()=>this[_0x4c2e63(0x12a)]('send_task',{'alias':_0x50762f,'task':_0x1302ce,'priority':_0xeecfad,'from_session':this[_0x4c2e63(0x183)]})});}async['message'](_0x26059c,_0x373c2e){const _0x2a7515=a0_0x18b3e1;return this[_0x2a7515(0x12a)]('send_message',{'alias':_0x26059c,'message':_0x373c2e,'from_session':this[_0x2a7515(0x183)]});}async[a0_0x18b3e1(0x175)](_0x1fb31e,_0x33f7d9,_0x29cd31=a0_0x18b3e1(0x123)){const _0x394ab9=a0_0x18b3e1;return this['call'](_0x394ab9(0x17c),{'in_reply_to':_0x1fb31e,'text':_0x33f7d9,'status':_0x29cd31});}async[a0_0x18b3e1(0x18a)](_0x4b934b,_0xb5e01a){const _0x31a6cf=a0_0x18b3e1;return this[_0x31a6cf(0x12a)]('report_status',{'resume_id':this['resumeId'],'alias':this[_0x31a6cf(0x183)],'status':_0x4b934b,'server':a0_0x340f9e(),'hostname':a0_0x340f9e(),'agent':this['agent'],'project_dir':process['cwd'](),..._0xb5e01a});}async['getAllStatus'](){const _0x24fe02=a0_0x18b3e1;return this[_0x24fe02(0x12a)](_0x24fe02(0x14a),{});}async['broadcast'](_0x44cb34,_0x52a9cd){const _0x14e550=a0_0x18b3e1;return this[_0x14e550(0x12a)]('broadcast',{'message':_0x44cb34,'filter_server':_0x52a9cd?.[_0x14e550(0x14c)],'filter_status':_0x52a9cd?.['status']});}async[a0_0x18b3e1(0x18b)](){const _0x26c09c=a0_0x18b3e1;let _0x54a456=encodeURIComponent(this[_0x26c09c(0x183)]),_0x5488e5=this['url']+_0x26c09c(0x149)+_0x54a456,_0x280f29=this[_0x26c09c(0x157)];while(this[_0x26c09c(0x129)]){try{this['sseAbort']=new AbortController();let _0x58b3a7={'Accept':_0x26c09c(0x184)};if(this[_0x26c09c(0x139)])_0x58b3a7['Authorization']=_0x26c09c(0x16e)+this['token'];let _0xaca17b=await fetch(_0x5488e5,{'headers':_0x58b3a7,'signal':this['sseAbort'][_0x26c09c(0x120)]});if(!_0xaca17b['ok']||!_0xaca17b[_0x26c09c(0x13f)]){this[_0x26c09c(0x121)](_0x26c09c(0x158)+_0xaca17b[_0x26c09c(0x18a)]),await this[_0x26c09c(0x154)](_0x280f29),_0x280f29=Math['min'](_0x280f29*1.5,0xea60);continue;}_0x280f29=this[_0x26c09c(0x157)];let _0x268fa2=_0xaca17b[_0x26c09c(0x13f)]['getReader'](),_0x3c58fd=new TextDecoder(),_0x415cfc='';while(this[_0x26c09c(0x129)]){let {done:_0x2f0037,value:_0x23f319}=await _0x268fa2['read']();if(_0x2f0037)break;_0x415cfc+=_0x3c58fd['decode'](_0x23f319,{'stream':!0x0});let _0x2d76f2=_0x415cfc[_0x26c09c(0x181)]('\x0a');_0x415cfc=_0x2d76f2['pop']()||'';for(let _0x187808 of _0x2d76f2){if(!_0x187808[_0x26c09c(0x180)](_0x26c09c(0x168)))continue;try{let _0x4796df=JSON[_0x26c09c(0x12b)](_0x187808[_0x26c09c(0x14f)](0x6));if(_0x4796df[_0x26c09c(0x173)]===_0x26c09c(0x12d)){this['log'](_0x26c09c(0x182)),this[_0x26c09c(0x148)]('connected');continue;}if(_0x4796df[_0x26c09c(0x173)]===_0x26c09c(0x12e)||_0x4796df[_0x26c09c(0x173)]==='new_message'||_0x4796df[_0x26c09c(0x173)]===_0x26c09c(0x164))await this[_0x26c09c(0x138)]();}catch{}}}}catch(_0x3645ef){if(_0x3645ef[_0x26c09c(0x11f)]===_0x26c09c(0x136))break;this[_0x26c09c(0x148)](_0x26c09c(0x11e),_0x3645ef),this['log'](_0x26c09c(0x14b)+_0x3645ef[_0x26c09c(0x119)]);}if(this['running'])this[_0x26c09c(0x148)](_0x26c09c(0x179)),this[_0x26c09c(0x121)](_0x26c09c(0x18e)+_0x280f29/0x3e8+_0x26c09c(0x177)),await this[_0x26c09c(0x154)](_0x280f29),_0x280f29=Math[_0x26c09c(0x141)](_0x280f29*1.5,0xea60);}}async[a0_0x18b3e1(0x138)](){const _0x4753c0=a0_0x18b3e1;try{let _0x352155=(await this[_0x4753c0(0x12a)](_0x4753c0(0x17e),{'alias':this[_0x4753c0(0x183)],'limit':0xa}))?.[_0x4753c0(0x166)]||[];for(let _0x13e01b of _0x352155)await this[_0x4753c0(0x12a)](_0x4753c0(0x15c),{'alias':this[_0x4753c0(0x183)],'message_id':_0x13e01b['id']}),this['log']('←\x20'+_0x13e01b[_0x4753c0(0x15f)]+':\x20'+_0x13e01b['content'][_0x4753c0(0x14f)](0x0,0x3c)),this['emit']('task',_0x13e01b),this[_0x4753c0(0x148)](_0x4753c0(0x119),_0x13e01b);}catch(_0x65be8d){this[_0x4753c0(0x121)](_0x4753c0(0x16f)+_0x65be8d[_0x4753c0(0x119)]);}}[a0_0x18b3e1(0x154)](_0x3950ff){return new Promise(_0x4f2d72=>setTimeout(_0x4f2d72,_0x3950ff));}}var F=$;export{F as default,$ as CommHub};