@sleep2agi/agent-network 2.3.0-preview.226 → 2.3.0-preview.227

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_0x42c9ed=a0_0xe91c;(function(_0x3e8db0,_0x56955d){const _0x5e7061=a0_0xe91c,_0x2bf5ee=_0x3e8db0();while(!![]){try{const _0x74bc61=parseInt(_0x5e7061(0x130))/0x1*(parseInt(_0x5e7061(0x177))/0x2)+-parseInt(_0x5e7061(0x131))/0x3*(parseInt(_0x5e7061(0x179))/0x4)+-parseInt(_0x5e7061(0x191))/0x5+-parseInt(_0x5e7061(0x199))/0x6*(parseInt(_0x5e7061(0x138))/0x7)+parseInt(_0x5e7061(0x141))/0x8+parseInt(_0x5e7061(0x156))/0x9+parseInt(_0x5e7061(0x135))/0xa;if(_0x74bc61===_0x56955d)break;else _0x2bf5ee['push'](_0x2bf5ee['shift']());}catch(_0x40aa9f){_0x2bf5ee['push'](_0x2bf5ee['shift']());}}}(a0_0x4a54,0x9d9f0));import{EventEmitter as a0_0x6fe51b}from'events';import{hostname as a0_0xff0b17}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x253c98,_0x4e32d3)=>(_0x253c98??_0x4e32d3)[a0_0x42c9ed(0x160)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x42c9ed(0x193)](0x0,0xf0);function N(_0x9279ad){const _0x2685aa=a0_0x42c9ed;return(_0x9279ad instanceof Error?_0x9279ad[_0x2685aa(0x142)]:String(_0x9279ad??'unknown\x20error'))[_0x2685aa(0x160)](K,_0x2685aa(0x13f))[_0x2685aa(0x160)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x2685aa(0x193)](0x0,0xf0);}function a0_0xe91c(_0x311154,_0x37d48d){_0x311154=_0x311154-0x119;const _0x4a54f8=a0_0x4a54();let _0xe91c87=_0x4a54f8[_0x311154];return _0xe91c87;}function O(_0x342fea,_0xf33e07=process.env.ANET_TASK_TRACE_FORMAT===a0_0x42c9ed(0x121)){const _0x4518ff=a0_0x42c9ed;if(_0xf33e07)return JSON[_0x4518ff(0x126)](_0x342fea);let _0x226218=L(_0x342fea['parent_task_id'],'<missing>'),_0x1e625e=L(_0x342fea[_0x4518ff(0x13b)],_0x4518ff(0x16c)),_0x19f216=_0x342fea[_0x4518ff(0x188)]?_0x4518ff(0x18d)+_0x342fea[_0x4518ff(0x188)]+':'+(_0x342fea['error_message']??''):'';return _0x4518ff(0x154)+_0x342fea[_0x4518ff(0x189)]+_0x4518ff(0x11b)+L(_0x342fea[_0x4518ff(0x163)],_0x4518ff(0x17a))+_0x4518ff(0x147)+L(_0x342fea[_0x4518ff(0x151)],_0x4518ff(0x17a))+_0x4518ff(0x162)+_0x1e625e+_0x4518ff(0x16f)+_0x226218+_0x4518ff(0x15a)+L(_0x342fea[_0x4518ff(0x190)],'<unknown>')+_0x4518ff(0x153)+_0x342fea['transport']+_0x4518ff(0x18b)+_0x342fea[_0x4518ff(0x185)]+_0x4518ff(0x150)+_0x342fea['lifecycle_tracking']+_0x19f216;}function a0_0x4a54(){const _0x1b8425=['toTimeString','4454096kNhqmV','message',']\x20[commhub:','send_reply','sseAbort','string','\x20to=','content','sending','s...','normal','autoConnect','error','task.ack','parse','\x20lifecycle=','to_alias','SSE\x20reconnecting\x20in\x20','\x20transport=','[commhub:task]\x20','sdk-','10056915UGFQrl','CommHub\x20response\x20omitted\x20task_id','ack_inbox','now','\x20network_id=','server','send','reply','offline','mcp_http','replace','idle','\x20task_id=','from_alias','agent','heartbeatTimer','SSE\x20connected','/events/','parentTaskId','task.expired','read','failed','<pending>','SSE\x20error:\x20','connect','\x20parent_task_id=','data:\x20','message_id','send_rejected','sdk','CommHub\x20rejected\x20task','task.replied','get_all_status','2BqDinQ','toAlias','8KmLfgn','<unknown>','/mcp','processInbox','task.started','not_tracked','2.0','url','transport','task.send.delivered','missing_task_id','task','duration_ms','alias','toString','error_code','status','fromAlias','\x20duration_ms=','match','\x20error=','connected','type','network_id','5260545gDpTps','name','slice','min','abort','inbox\x20error:\x20','registered','emit','1364172mAwkDz','task.send.failed','connectSSE','messages','running','call','resumeId','POST','\x20from=','broadcast','reconnectDelay','Authorization','Bearer\x20','text/event-stream','json','log','new_message','application/json','getAllStatus','stringify','send_message','catch','split','delivered','heartbeat\x20failed:\x20','decode','token','text','sleep','322159IBqSur','979059FrSNUO','send_failed','disconnect','body','8087990dvjPpc','send_task','networkId','14yyivjS','report_status','from_session','task_id','tools/call','heartbeatInterval','disconnected','[REDACTED]'];a0_0x4a54=function(){return _0x1b8425;};return a0_0x4a54();}function U(_0x36c0b4){const _0x2de1c3=a0_0x42c9ed;return{'event':{'sending':'task.send.start','delivered':_0x2de1c3(0x182),'failed':_0x2de1c3(0x19a),'acked':_0x2de1c3(0x14e),'started':_0x2de1c3(0x17d),'replied':_0x2de1c3(0x175),'expired':_0x2de1c3(0x169)}[_0x36c0b4['status']],..._0x36c0b4};}function j(_0x11a990){const _0x4bb384=a0_0x42c9ed;let _0x5b59e9=_0x11a990?.[_0x4bb384(0x13b)]||_0x11a990?.[_0x4bb384(0x171)]||_0x11a990?.['id'];if(_0x5b59e9)return String(_0x5b59e9);let _0x5b7b6e=_0x11a990?.[_0x4bb384(0x148)]?.[0x0]?.[_0x4bb384(0x12e)];if(typeof _0x5b7b6e!==_0x4bb384(0x146))return null;try{let _0x3813f4=JSON[_0x4bb384(0x14f)](_0x5b7b6e);return _0x3813f4?.[_0x4bb384(0x13b)]||_0x3813f4?.['message_id']||_0x3813f4?.['id']||null;}catch{return null;}}async function X(_0x5a1800,_0x332e25){const _0x5b4fa4=a0_0x42c9ed;let _0x1d7003=_0x332e25[_0x5b4fa4(0x159)]??Date['now'],_0x3feffd=_0x1d7003(),_0x4de1a1=(_0x5c07f7,_0x1b0096,_0x4920c2,_0x220722)=>{const _0x34647c=_0x5b4fa4;_0x332e25[_0x34647c(0x122)](O(U({'from_alias':_0x5a1800[_0x34647c(0x18a)],'to_alias':_0x5a1800[_0x34647c(0x178)],'task_id':_0x1b0096,'parent_task_id':_0x5a1800[_0x34647c(0x168)],'network_id':_0x5a1800[_0x34647c(0x137)],'transport':_0x5a1800[_0x34647c(0x181)],'status':_0x5c07f7,'duration_ms':_0x1d7003()-_0x3feffd,'lifecycle_tracking':_0x5a1800['lifecycleTracking'],..._0x4920c2!==void 0x0?{'error_code':_0x220722||'send_failed','error_message':N(_0x4920c2)}:{}})));};_0x4de1a1(_0x5b4fa4(0x149),null);try{let _0x17ba46=await _0x332e25[_0x5b4fa4(0x15c)](),_0x3dad72=j(_0x17ba46);if(_0x3dad72)_0x4de1a1(_0x5b4fa4(0x12a),_0x3dad72);else{if(_0x17ba46?.['ok']===!0x1||_0x17ba46?.[_0x5b4fa4(0x14d)])_0x4de1a1('failed',_0x3dad72,_0x17ba46?.[_0x5b4fa4(0x14d)]||_0x5b4fa4(0x174),_0x5b4fa4(0x172));else _0x4de1a1(_0x5b4fa4(0x16b),null,_0x5b4fa4(0x157),_0x5b4fa4(0x183));}return _0x17ba46;}catch(_0x346787){throw _0x4de1a1(_0x5b4fa4(0x16b),null,_0x346787,_0x5b4fa4(0x132)),_0x346787;}}async function Y(_0x4c0539,_0x283a1a){const _0x2b5f1f=a0_0x42c9ed;return X({'fromAlias':_0x4c0539['fromAlias'],'toAlias':_0x4c0539['alias'],'parentTaskId':_0x4c0539['parentTaskId']||null,'networkId':_0x4c0539['networkId']||null,'transport':_0x2b5f1f(0x15f),'lifecycleTracking':_0x2b5f1f(0x17e)},_0x283a1a);}class $ extends a0_0x6fe51b{['url'];[a0_0x42c9ed(0x186)];[a0_0x42c9ed(0x12d)];['agent'];[a0_0x42c9ed(0x119)];['heartbeatInterval'];[a0_0x42c9ed(0x11d)];[a0_0x42c9ed(0x165)];['sseAbort'];[a0_0x42c9ed(0x19d)]=!0x1;constructor(_0x5486b7){const _0x17ef7d=a0_0x42c9ed;super();if(this[_0x17ef7d(0x180)]=_0x5486b7['url'][_0x17ef7d(0x160)](/\/$/,''),this['alias']=_0x5486b7[_0x17ef7d(0x186)],this[_0x17ef7d(0x12d)]=_0x5486b7['token'],this[_0x17ef7d(0x164)]=_0x5486b7[_0x17ef7d(0x164)]||_0x17ef7d(0x173),this[_0x17ef7d(0x119)]=_0x17ef7d(0x155)+_0x5486b7['alias']+'-'+Date[_0x17ef7d(0x159)]()[_0x17ef7d(0x187)](0x24),this['heartbeatInterval']=_0x5486b7['heartbeatInterval']??0x2bf20,this[_0x17ef7d(0x11d)]=_0x5486b7[_0x17ef7d(0x11d)]??0xbb8,_0x5486b7[_0x17ef7d(0x14c)]!==!0x1)this[_0x17ef7d(0x16e)]();}[a0_0x42c9ed(0x122)](_0x28ef3c){const _0x64636e=a0_0x42c9ed;console['log']('['+new Date()[_0x64636e(0x140)]()['slice'](0x0,0x8)+_0x64636e(0x143)+this[_0x64636e(0x186)]+']\x20'+_0x28ef3c);}async[a0_0x42c9ed(0x19e)](_0x1a67b6,_0x1c7d6b){const _0x9e7a0e=a0_0x42c9ed;let _0x456a3f={'Content-Type':_0x9e7a0e(0x124),'Accept':'application/json,\x20text/event-stream'};if(this[_0x9e7a0e(0x12d)])_0x456a3f[_0x9e7a0e(0x11e)]=_0x9e7a0e(0x11f)+this[_0x9e7a0e(0x12d)];let _0xe3e043=await(await fetch(this['url']+_0x9e7a0e(0x17b),{'method':_0x9e7a0e(0x11a),'headers':_0x456a3f,'body':JSON[_0x9e7a0e(0x126)]({'jsonrpc':_0x9e7a0e(0x17f),'id':Date['now'](),'method':_0x9e7a0e(0x13c),'params':{'name':_0x1a67b6,'arguments':_0x1c7d6b}})}))[_0x9e7a0e(0x12e)](),_0x2d3250=_0xe3e043[_0x9e7a0e(0x18c)](/data: (.+)/),_0x29e73d=_0x2d3250?JSON[_0x9e7a0e(0x14f)](_0x2d3250[0x1]):JSON[_0x9e7a0e(0x14f)](_0xe3e043),_0x1204a4=_0x29e73d?.['result']?.[_0x9e7a0e(0x148)]?.[0x0]?.['text'];return _0x1204a4?JSON['parse'](_0x1204a4):_0x29e73d;}async[a0_0x42c9ed(0x16e)](){const _0x18d1b4=a0_0x42c9ed;if(this[_0x18d1b4(0x19d)])return;this[_0x18d1b4(0x19d)]=!0x0,await this[_0x18d1b4(0x189)]('idle'),this[_0x18d1b4(0x122)](_0x18d1b4(0x197)),this[_0x18d1b4(0x165)]=setInterval(()=>{const _0x70ae0b=_0x18d1b4;this['status'](_0x70ae0b(0x161))[_0x70ae0b(0x128)](_0x33d37a=>this[_0x70ae0b(0x122)](_0x70ae0b(0x12b)+_0x33d37a[_0x70ae0b(0x142)]));},this[_0x18d1b4(0x13d)]),this['connectSSE']();}async[a0_0x42c9ed(0x133)](){const _0x887604=a0_0x42c9ed;if(this['running']=!0x1,this['sseAbort']?.[_0x887604(0x195)](),this[_0x887604(0x165)])clearInterval(this[_0x887604(0x165)]);await this[_0x887604(0x189)](_0x887604(0x15e))[_0x887604(0x128)](()=>{}),this[_0x887604(0x122)](_0x887604(0x13e));}async[a0_0x42c9ed(0x15c)](_0x4b2b84,_0x1b7aad,_0x3eff47=a0_0x42c9ed(0x14b)){const _0x164a9d=a0_0x42c9ed;return Y({'alias':_0x4b2b84,'fromAlias':this[_0x164a9d(0x186)]},{'log':_0xef5135=>console[_0x164a9d(0x122)](_0xef5135),'send':()=>this['call'](_0x164a9d(0x136),{'alias':_0x4b2b84,'task':_0x1b7aad,'priority':_0x3eff47,'from_session':this['alias']})});}async[a0_0x42c9ed(0x142)](_0xfaedd6,_0xeabdda){const _0x17165b=a0_0x42c9ed;return this[_0x17165b(0x19e)](_0x17165b(0x127),{'alias':_0xfaedd6,'message':_0xeabdda,'from_session':this[_0x17165b(0x186)]});}async[a0_0x42c9ed(0x15d)](_0x3fa6fe,_0x45500e,_0x544fb5='completed'){const _0x3a2c76=a0_0x42c9ed;return this[_0x3a2c76(0x19e)](_0x3a2c76(0x144),{'in_reply_to':_0x3fa6fe,'text':_0x45500e,'status':_0x544fb5});}async[a0_0x42c9ed(0x189)](_0xb9a159,_0x179aa3){const _0x296e55=a0_0x42c9ed;return this[_0x296e55(0x19e)](_0x296e55(0x139),{'resume_id':this[_0x296e55(0x119)],'alias':this[_0x296e55(0x186)],'status':_0xb9a159,'server':a0_0xff0b17(),'hostname':a0_0xff0b17(),'agent':this[_0x296e55(0x164)],'project_dir':process['cwd'](),..._0x179aa3});}async[a0_0x42c9ed(0x125)](){const _0x2f3a1e=a0_0x42c9ed;return this[_0x2f3a1e(0x19e)](_0x2f3a1e(0x176),{});}async[a0_0x42c9ed(0x11c)](_0x168350,_0x3142c6){const _0x27864c=a0_0x42c9ed;return this[_0x27864c(0x19e)](_0x27864c(0x11c),{'message':_0x168350,'filter_server':_0x3142c6?.[_0x27864c(0x15b)],'filter_status':_0x3142c6?.['status']});}async[a0_0x42c9ed(0x19b)](){const _0x570fc4=a0_0x42c9ed;let _0x8e86fb=encodeURIComponent(this[_0x570fc4(0x186)]),_0x13a2fc=this[_0x570fc4(0x180)]+_0x570fc4(0x167)+_0x8e86fb,_0x52d341=this[_0x570fc4(0x11d)];while(this[_0x570fc4(0x19d)]){try{this[_0x570fc4(0x145)]=new AbortController();let _0x5e4641={'Accept':_0x570fc4(0x120)};if(this[_0x570fc4(0x12d)])_0x5e4641[_0x570fc4(0x11e)]=_0x570fc4(0x11f)+this['token'];let _0x493d7f=await fetch(_0x13a2fc,{'headers':_0x5e4641,'signal':this[_0x570fc4(0x145)]['signal']});if(!_0x493d7f['ok']||!_0x493d7f['body']){this[_0x570fc4(0x122)]('SSE\x20failed:\x20'+_0x493d7f[_0x570fc4(0x189)]),await this[_0x570fc4(0x12f)](_0x52d341),_0x52d341=Math[_0x570fc4(0x194)](_0x52d341*1.5,0xea60);continue;}_0x52d341=this['reconnectDelay'];let _0x328f84=_0x493d7f[_0x570fc4(0x134)]['getReader'](),_0x4f5c17=new TextDecoder(),_0x47d535='';while(this[_0x570fc4(0x19d)]){let {done:_0x1fc969,value:_0x176da8}=await _0x328f84[_0x570fc4(0x16a)]();if(_0x1fc969)break;_0x47d535+=_0x4f5c17[_0x570fc4(0x12c)](_0x176da8,{'stream':!0x0});let _0xa780db=_0x47d535[_0x570fc4(0x129)]('\x0a');_0x47d535=_0xa780db['pop']()||'';for(let _0x4ea3ae of _0xa780db){if(!_0x4ea3ae['startsWith'](_0x570fc4(0x170)))continue;try{let _0x1b644d=JSON[_0x570fc4(0x14f)](_0x4ea3ae[_0x570fc4(0x193)](0x6));if(_0x1b644d[_0x570fc4(0x18f)]==='connected'){this['log'](_0x570fc4(0x166)),this[_0x570fc4(0x198)](_0x570fc4(0x18e));continue;}if(_0x1b644d[_0x570fc4(0x18f)]==='new_task'||_0x1b644d['type']===_0x570fc4(0x123)||_0x1b644d[_0x570fc4(0x18f)]===_0x570fc4(0x11c))await this[_0x570fc4(0x17c)]();}catch{}}}}catch(_0x546b46){if(_0x546b46[_0x570fc4(0x192)]==='AbortError')break;this['emit'](_0x570fc4(0x14d),_0x546b46),this[_0x570fc4(0x122)](_0x570fc4(0x16d)+_0x546b46[_0x570fc4(0x142)]);}if(this[_0x570fc4(0x19d)])this[_0x570fc4(0x198)](_0x570fc4(0x13e)),this[_0x570fc4(0x122)](_0x570fc4(0x152)+_0x52d341/0x3e8+_0x570fc4(0x14a)),await this[_0x570fc4(0x12f)](_0x52d341),_0x52d341=Math[_0x570fc4(0x194)](_0x52d341*1.5,0xea60);}}async[a0_0x42c9ed(0x17c)](){const _0xf37cc6=a0_0x42c9ed;try{let _0x402f5c=(await this[_0xf37cc6(0x19e)]('get_inbox',{'alias':this[_0xf37cc6(0x186)],'limit':0xa}))?.[_0xf37cc6(0x19c)]||[];for(let _0x1df0f3 of _0x402f5c)await this[_0xf37cc6(0x19e)](_0xf37cc6(0x158),{'alias':this[_0xf37cc6(0x186)],'message_id':_0x1df0f3['id']}),this[_0xf37cc6(0x122)]('←\x20'+_0x1df0f3[_0xf37cc6(0x13a)]+':\x20'+_0x1df0f3[_0xf37cc6(0x148)]['slice'](0x0,0x3c)),this[_0xf37cc6(0x198)](_0xf37cc6(0x184),_0x1df0f3),this[_0xf37cc6(0x198)](_0xf37cc6(0x142),_0x1df0f3);}catch(_0x218562){this[_0xf37cc6(0x122)](_0xf37cc6(0x196)+_0x218562[_0xf37cc6(0x142)]);}}[a0_0x42c9ed(0x12f)](_0x250072){return new Promise(_0x18be5b=>setTimeout(_0x18be5b,_0x250072));}}var F=$;export{F as default,$ as CommHub};
1
+ function a0_0xea17(){const _0x91977a=['connect','sseAbort','Bearer\x20','disconnected','cwd','completed','status','log','<unknown>','Authorization','duration_ms','error_code','match','send_failed','POST','2743016HOVrBu','report_status','from_alias','content','signal','replace','\x20to=','network_id','url','s...','startsWith','broadcast','heartbeatTimer','agent','CommHub\x20rejected\x20task','token','string','text','toAlias','task','task.send.start','SSE\x20error:\x20','to_alias','connected','/mcp','160zPjIVL','get_inbox','send','name','idle','message_id','task.ack','fromAlias','lifecycle_tracking','failed','catch','slice','transport','getReader','task.send.delivered','parse','result','9eeazls','read','10890495lflFlv','/events/','data:\x20','error','heartbeatInterval','body','lifecycleTracking','server','disconnect','parent_task_id','message','2232027mXLSyF','sdk-','processInbox','task.replied','\x20network_id=','min','SSE\x20reconnecting\x20in\x20','networkId','emit','task.started','running','\x20from=','type','send_reply','call','tools/call','sleep','unknown\x20error','offline','toString','registered','pop','send_rejected','delivered','not_tracked','parentTaskId','task.expired','abort','alias','decode','\x20transport=','\x20duration_ms=','inbox\x20error:\x20','resumeId','text/event-stream','<missing>','heartbeat\x20failed:\x20','\x20error=','5654256YEYPZI','SSE\x20failed:\x20','task_id','45481224RTeRzH','new_task','send_message','77472HvWYrL','autoConnect','json','now','\x20task_id=','735955irAHZT','missing_task_id','new_message','[commhub:task]\x20','send_task'];a0_0xea17=function(){return _0x91977a;};return a0_0xea17();}const a0_0x24b300=a0_0xb6ab;(function(_0x11a11a,_0x4c4014){const _0x2369de=a0_0xb6ab,_0x1d5cb1=_0x11a11a();while(!![]){try{const _0x134ae2=-parseInt(_0x2369de(0xf2))/0x1+-parseInt(_0x2369de(0x106))/0x2+parseInt(_0x2369de(0xc1))/0x3+-parseInt(_0x2369de(0xe7))/0x4+-parseInt(_0x2369de(0xa3))/0x5*(parseInt(_0x2369de(0xed))/0x6)+-parseInt(_0x2369de(0xb6))/0x7+parseInt(_0x2369de(0xea))/0x8*(parseInt(_0x2369de(0xb4))/0x9);if(_0x134ae2===_0x4c4014)break;else _0x1d5cb1['push'](_0x1d5cb1['shift']());}catch(_0x727bd2){_0x1d5cb1['push'](_0x1d5cb1['shift']());}}}(a0_0xea17,0xe549e));import{EventEmitter as a0_0x2ab3f9}from'events';import{hostname as a0_0x44f980}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0xf8afc4,_0x2d79e4)=>(_0xf8afc4??_0x2d79e4)[a0_0x24b300(0x10b)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x24b300(0xae)](0x0,0xf0);function N(_0xe5f749){const _0x1fe948=a0_0x24b300;return(_0xe5f749 instanceof Error?_0xe5f749['message']:String(_0xe5f749??_0x1fe948(0xd2)))[_0x1fe948(0x10b)](K,'[REDACTED]')[_0x1fe948(0x10b)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x1fe948(0xae)](0x0,0xf0);}function O(_0x53378f,_0x55a51f=process.env.ANET_TASK_TRACE_FORMAT===a0_0x24b300(0xef)){const _0x1ebb7c=a0_0x24b300;if(_0x55a51f)return JSON['stringify'](_0x53378f);let _0x2506b5=L(_0x53378f[_0x1ebb7c(0xbf)],_0x1ebb7c(0xe4)),_0x1e19cc=L(_0x53378f['task_id'],'<pending>'),_0x374992=_0x53378f['error_code']?_0x1ebb7c(0xe6)+_0x53378f[_0x1ebb7c(0x102)]+':'+(_0x53378f['error_message']??''):'';return _0x1ebb7c(0xf5)+_0x53378f[_0x1ebb7c(0xfd)]+_0x1ebb7c(0xcc)+L(_0x53378f[_0x1ebb7c(0x108)],_0x1ebb7c(0xff))+_0x1ebb7c(0x10c)+L(_0x53378f[_0x1ebb7c(0xa0)],_0x1ebb7c(0xff))+_0x1ebb7c(0xf1)+_0x1e19cc+'\x20parent_task_id='+_0x2506b5+_0x1ebb7c(0xc5)+L(_0x53378f[_0x1ebb7c(0x10d)],_0x1ebb7c(0xff))+_0x1ebb7c(0xdf)+_0x53378f[_0x1ebb7c(0xaf)]+_0x1ebb7c(0xe0)+_0x53378f[_0x1ebb7c(0x101)]+'\x20lifecycle='+_0x53378f[_0x1ebb7c(0xab)]+_0x374992;}function U(_0x3a6f42){const _0x560b00=a0_0x24b300;return{'event':{'sending':_0x560b00(0x9e),'delivered':_0x560b00(0xb1),'failed':'task.send.failed','acked':_0x560b00(0xa9),'started':_0x560b00(0xca),'replied':_0x560b00(0xc4),'expired':_0x560b00(0xdb)}[_0x3a6f42['status']],..._0x3a6f42};}function j(_0x179d10){const _0x1778b4=a0_0x24b300;let _0x22ab50=_0x179d10?.[_0x1778b4(0xe9)]||_0x179d10?.['message_id']||_0x179d10?.['id'];if(_0x22ab50)return String(_0x22ab50);let _0x298b12=_0x179d10?.[_0x1778b4(0x109)]?.[0x0]?.[_0x1778b4(0x117)];if(typeof _0x298b12!==_0x1778b4(0x116))return null;try{let _0x56e1f3=JSON['parse'](_0x298b12);return _0x56e1f3?.[_0x1778b4(0xe9)]||_0x56e1f3?.[_0x1778b4(0xa8)]||_0x56e1f3?.['id']||null;}catch{return null;}}async function X(_0x5aba4e,_0x2759a9){const _0x42a548=a0_0x24b300;let _0x25a3aa=_0x2759a9[_0x42a548(0xf0)]??Date['now'],_0x4c1b11=_0x25a3aa(),_0x205d7e=(_0x5c50a8,_0x45a80c,_0x188599,_0x19d1ab)=>{const _0x590f31=_0x42a548;_0x2759a9[_0x590f31(0xfe)](O(U({'from_alias':_0x5aba4e[_0x590f31(0xaa)],'to_alias':_0x5aba4e[_0x590f31(0x118)],'task_id':_0x45a80c,'parent_task_id':_0x5aba4e[_0x590f31(0xda)],'network_id':_0x5aba4e['networkId'],'transport':_0x5aba4e[_0x590f31(0xaf)],'status':_0x5c50a8,'duration_ms':_0x25a3aa()-_0x4c1b11,'lifecycle_tracking':_0x5aba4e[_0x590f31(0xbc)],..._0x188599!==void 0x0?{'error_code':_0x19d1ab||'send_failed','error_message':N(_0x188599)}:{}})));};_0x205d7e('sending',null);try{let _0x1c7b3b=await _0x2759a9[_0x42a548(0xa5)](),_0x5b7e0e=j(_0x1c7b3b);if(_0x5b7e0e)_0x205d7e(_0x42a548(0xd8),_0x5b7e0e);else{if(_0x1c7b3b?.['ok']===!0x1||_0x1c7b3b?.[_0x42a548(0xb9)])_0x205d7e(_0x42a548(0xac),_0x5b7e0e,_0x1c7b3b?.['error']||_0x42a548(0x114),_0x42a548(0xd7));else _0x205d7e(_0x42a548(0xac),null,'CommHub\x20response\x20omitted\x20task_id',_0x42a548(0xf3));}return _0x1c7b3b;}catch(_0x246b79){throw _0x205d7e(_0x42a548(0xac),null,_0x246b79,_0x42a548(0x104)),_0x246b79;}}function a0_0xb6ab(_0x4e5c09,_0x2b528b){_0x4e5c09=_0x4e5c09-0x9e;const _0xea17ab=a0_0xea17();let _0xb6ab27=_0xea17ab[_0x4e5c09];return _0xb6ab27;}async function Y(_0x121547,_0x1db3ea){const _0x40d1b4=a0_0x24b300;return X({'fromAlias':_0x121547['fromAlias'],'toAlias':_0x121547[_0x40d1b4(0xdd)],'parentTaskId':_0x121547[_0x40d1b4(0xda)]||null,'networkId':_0x121547[_0x40d1b4(0xc8)]||null,'transport':'mcp_http','lifecycleTracking':_0x40d1b4(0xd9)},_0x1db3ea);}class $ extends a0_0x2ab3f9{[a0_0x24b300(0x10e)];[a0_0x24b300(0xdd)];['token'];['agent'];[a0_0x24b300(0xe2)];[a0_0x24b300(0xba)];['reconnectDelay'];[a0_0x24b300(0x112)];[a0_0x24b300(0xf8)];[a0_0x24b300(0xcb)]=!0x1;constructor(_0x37aaa9){const _0x48ffcb=a0_0x24b300;super();if(this[_0x48ffcb(0x10e)]=_0x37aaa9[_0x48ffcb(0x10e)][_0x48ffcb(0x10b)](/\/$/,''),this[_0x48ffcb(0xdd)]=_0x37aaa9[_0x48ffcb(0xdd)],this[_0x48ffcb(0x115)]=_0x37aaa9[_0x48ffcb(0x115)],this['agent']=_0x37aaa9[_0x48ffcb(0x113)]||'sdk',this[_0x48ffcb(0xe2)]=_0x48ffcb(0xc2)+_0x37aaa9[_0x48ffcb(0xdd)]+'-'+Date['now']()[_0x48ffcb(0xd4)](0x24),this[_0x48ffcb(0xba)]=_0x37aaa9[_0x48ffcb(0xba)]??0x2bf20,this['reconnectDelay']=_0x37aaa9['reconnectDelay']??0xbb8,_0x37aaa9[_0x48ffcb(0xee)]!==!0x1)this[_0x48ffcb(0xf7)]();}[a0_0x24b300(0xfe)](_0x31f111){const _0x4ca841=a0_0x24b300;console[_0x4ca841(0xfe)]('['+new Date()['toTimeString']()[_0x4ca841(0xae)](0x0,0x8)+']\x20[commhub:'+this['alias']+']\x20'+_0x31f111);}async[a0_0x24b300(0xcf)](_0x455045,_0x161728){const _0x366aea=a0_0x24b300;let _0x2fb344={'Content-Type':'application/json','Accept':'application/json,\x20text/event-stream'};if(this[_0x366aea(0x115)])_0x2fb344[_0x366aea(0x100)]=_0x366aea(0xf9)+this[_0x366aea(0x115)];let _0x56b291=await(await fetch(this[_0x366aea(0x10e)]+_0x366aea(0xa2),{'method':_0x366aea(0x105),'headers':_0x2fb344,'body':JSON['stringify']({'jsonrpc':'2.0','id':Date['now'](),'method':_0x366aea(0xd0),'params':{'name':_0x455045,'arguments':_0x161728}})}))[_0x366aea(0x117)](),_0x34d742=_0x56b291[_0x366aea(0x103)](/data: (.+)/),_0x3f747c=_0x34d742?JSON['parse'](_0x34d742[0x1]):JSON[_0x366aea(0xb2)](_0x56b291),_0x4e3c4=_0x3f747c?.[_0x366aea(0xb3)]?.[_0x366aea(0x109)]?.[0x0]?.[_0x366aea(0x117)];return _0x4e3c4?JSON[_0x366aea(0xb2)](_0x4e3c4):_0x3f747c;}async[a0_0x24b300(0xf7)](){const _0x5530d2=a0_0x24b300;if(this['running'])return;this[_0x5530d2(0xcb)]=!0x0,await this[_0x5530d2(0xfd)](_0x5530d2(0xa7)),this['log'](_0x5530d2(0xd5)),this[_0x5530d2(0x112)]=setInterval(()=>{const _0x2552cb=_0x5530d2;this['status'](_0x2552cb(0xa7))[_0x2552cb(0xad)](_0x13e506=>this['log'](_0x2552cb(0xe5)+_0x13e506[_0x2552cb(0xc0)]));},this[_0x5530d2(0xba)]),this['connectSSE']();}async[a0_0x24b300(0xbe)](){const _0x5f11e5=a0_0x24b300;if(this[_0x5f11e5(0xcb)]=!0x1,this[_0x5f11e5(0xf8)]?.[_0x5f11e5(0xdc)](),this[_0x5f11e5(0x112)])clearInterval(this['heartbeatTimer']);await this[_0x5f11e5(0xfd)](_0x5f11e5(0xd3))['catch'](()=>{}),this[_0x5f11e5(0xfe)](_0x5f11e5(0xfa));}async[a0_0x24b300(0xa5)](_0x50d2b2,_0x5be310,_0x8cbc0f='normal'){const _0x25fbba=a0_0x24b300;return Y({'alias':_0x50d2b2,'fromAlias':this[_0x25fbba(0xdd)]},{'log':_0x52fb50=>console[_0x25fbba(0xfe)](_0x52fb50),'send':()=>this[_0x25fbba(0xcf)](_0x25fbba(0xf6),{'alias':_0x50d2b2,'task':_0x5be310,'priority':_0x8cbc0f,'from_session':this['alias']})});}async[a0_0x24b300(0xc0)](_0x211019,_0x18996f){const _0x28e1b3=a0_0x24b300;return this[_0x28e1b3(0xcf)](_0x28e1b3(0xec),{'alias':_0x211019,'message':_0x18996f,'from_session':this[_0x28e1b3(0xdd)]});}async['reply'](_0x1fbb7c,_0x213c90,_0x4026a5=a0_0x24b300(0xfc)){const _0xc734bc=a0_0x24b300;return this[_0xc734bc(0xcf)](_0xc734bc(0xce),{'in_reply_to':_0x1fbb7c,'text':_0x213c90,'status':_0x4026a5});}async[a0_0x24b300(0xfd)](_0x28a0c0,_0x337e55){const _0x1d1b13=a0_0x24b300;return this['call'](_0x1d1b13(0x107),{'resume_id':this[_0x1d1b13(0xe2)],'alias':this[_0x1d1b13(0xdd)],'status':_0x28a0c0,'server':a0_0x44f980(),'hostname':a0_0x44f980(),'agent':this[_0x1d1b13(0x113)],'project_dir':process[_0x1d1b13(0xfb)](),..._0x337e55});}async['getAllStatus'](){const _0x2b5c9e=a0_0x24b300;return this[_0x2b5c9e(0xcf)]('get_all_status',{});}async['broadcast'](_0xf25a30,_0x5baa88){const _0x4c701a=a0_0x24b300;return this[_0x4c701a(0xcf)](_0x4c701a(0x111),{'message':_0xf25a30,'filter_server':_0x5baa88?.[_0x4c701a(0xbd)],'filter_status':_0x5baa88?.[_0x4c701a(0xfd)]});}async['connectSSE'](){const _0x1404c1=a0_0x24b300;let _0x20aed7=encodeURIComponent(this[_0x1404c1(0xdd)]),_0x2994d2=this['url']+_0x1404c1(0xb7)+_0x20aed7,_0x4c12ac=this['reconnectDelay'];while(this['running']){try{this[_0x1404c1(0xf8)]=new AbortController();let _0x4aacb8={'Accept':_0x1404c1(0xe3)};if(this[_0x1404c1(0x115)])_0x4aacb8['Authorization']=_0x1404c1(0xf9)+this[_0x1404c1(0x115)];let _0x2baf88=await fetch(_0x2994d2,{'headers':_0x4aacb8,'signal':this[_0x1404c1(0xf8)][_0x1404c1(0x10a)]});if(!_0x2baf88['ok']||!_0x2baf88[_0x1404c1(0xbb)]){this[_0x1404c1(0xfe)](_0x1404c1(0xe8)+_0x2baf88[_0x1404c1(0xfd)]),await this[_0x1404c1(0xd1)](_0x4c12ac),_0x4c12ac=Math[_0x1404c1(0xc6)](_0x4c12ac*1.5,0xea60);continue;}_0x4c12ac=this['reconnectDelay'];let _0x4f00c4=_0x2baf88[_0x1404c1(0xbb)][_0x1404c1(0xb0)](),_0x10b856=new TextDecoder(),_0x31e645='';while(this[_0x1404c1(0xcb)]){let {done:_0x1243eb,value:_0xccee76}=await _0x4f00c4[_0x1404c1(0xb5)]();if(_0x1243eb)break;_0x31e645+=_0x10b856[_0x1404c1(0xde)](_0xccee76,{'stream':!0x0});let _0x389f59=_0x31e645['split']('\x0a');_0x31e645=_0x389f59[_0x1404c1(0xd6)]()||'';for(let _0x53b2a6 of _0x389f59){if(!_0x53b2a6[_0x1404c1(0x110)](_0x1404c1(0xb8)))continue;try{let _0x548ef5=JSON[_0x1404c1(0xb2)](_0x53b2a6[_0x1404c1(0xae)](0x6));if(_0x548ef5['type']===_0x1404c1(0xa1)){this['log']('SSE\x20connected'),this['emit'](_0x1404c1(0xa1));continue;}if(_0x548ef5[_0x1404c1(0xcd)]===_0x1404c1(0xeb)||_0x548ef5['type']===_0x1404c1(0xf4)||_0x548ef5[_0x1404c1(0xcd)]===_0x1404c1(0x111))await this['processInbox']();}catch{}}}}catch(_0x5b1c4f){if(_0x5b1c4f[_0x1404c1(0xa6)]==='AbortError')break;this[_0x1404c1(0xc9)](_0x1404c1(0xb9),_0x5b1c4f),this[_0x1404c1(0xfe)](_0x1404c1(0x9f)+_0x5b1c4f[_0x1404c1(0xc0)]);}if(this[_0x1404c1(0xcb)])this['emit'](_0x1404c1(0xfa)),this[_0x1404c1(0xfe)](_0x1404c1(0xc7)+_0x4c12ac/0x3e8+_0x1404c1(0x10f)),await this[_0x1404c1(0xd1)](_0x4c12ac),_0x4c12ac=Math[_0x1404c1(0xc6)](_0x4c12ac*1.5,0xea60);}}async[a0_0x24b300(0xc3)](){const _0x3342ae=a0_0x24b300;try{let _0x160966=(await this[_0x3342ae(0xcf)](_0x3342ae(0xa4),{'alias':this['alias'],'limit':0xa}))?.['messages']||[];for(let _0x480794 of _0x160966)await this[_0x3342ae(0xcf)]('ack_inbox',{'alias':this[_0x3342ae(0xdd)],'message_id':_0x480794['id']}),this[_0x3342ae(0xfe)]('←\x20'+_0x480794['from_session']+':\x20'+_0x480794[_0x3342ae(0x109)][_0x3342ae(0xae)](0x0,0x3c)),this[_0x3342ae(0xc9)](_0x3342ae(0x119),_0x480794),this[_0x3342ae(0xc9)](_0x3342ae(0xc0),_0x480794);}catch(_0x4a9c21){this[_0x3342ae(0xfe)](_0x3342ae(0xe1)+_0x4a9c21[_0x3342ae(0xc0)]);}}['sleep'](_0x4421c2){return new Promise(_0x494e97=>setTimeout(_0x494e97,_0x4421c2));}}var F=$;export{F as default,$ as CommHub};