@sleep2agi/agent-network 2.3.0-preview.89 → 2.3.0-preview.90

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_0x127d7e=a0_0x57e4;function a0_0x4cbd(){const _0x55a735=['<pending>','broadcast','s...','lifecycle_tracking','send_task','network_id','idle','replace','transport','name','send_failed','read','task.replied','get_inbox','message','signal','url','1570oeupyv','to_alias','content','registered','heartbeat\x20failed:\x20','485iepTZt','lifecycleTracking','toString','get_all_status','networkId','task.send.failed','[commhub:task]\x20','Bearer\x20','startsWith','14ATfxTW','CommHub\x20response\x20omitted\x20task_id','tools/call',']\x20[commhub:','agent','toTimeString','task_id','connect','status','call','<unknown>','\x20error=','/events/','sending','4jOVkei','212jLSsUB','task.started','parent_task_id','\x20task_id=','ack_inbox','task.send.delivered','now','/mcp','result','toAlias','split','reply','<missing>','missing_task_id','min','parse','sdk','running','2.0','task','parentTaskId','SSE\x20error:\x20','32352wnEmuP','abort','from_alias','connectSSE','string','CommHub\x20rejected\x20task','heartbeatTimer','resumeId','text/event-stream','error_message','application/json,\x20text/event-stream','text','new_message','new_task','not_tracked','SSE\x20reconnecting\x20in\x20','\x20transport=','[REDACTED]','Authorization','\x20from=','completed','task.send.start','sdk-','catch','send','\x20lifecycle=','task.ack','error_code','8YEiUCk','2163528kHsqWq','POST','unknown\x20error','17919pjkXcc','autoConnect','slice','stringify','offline','cwd','\x20network_id=','\x20duration_ms=','fromAlias','type','\x20parent_task_id=','sseAbort','match','8376ZvhCOo','pop','duration_ms','824100rMsHQl','alias','processInbox','heartbeatInterval','error','send_message','body','getAllStatus','emit','reconnectDelay','connected','524454djkaua','send_rejected','send_reply','sleep','token','disconnected','from_session','application/json','task.expired','message_id','failed','normal','report_status','log'];a0_0x4cbd=function(){return _0x55a735;};return a0_0x4cbd();}(function(_0x15e9e2,_0x3175d2){const _0x5d664c=a0_0x57e4,_0x2ada4a=_0x15e9e2();while(!![]){try{const _0x3167e1=-parseInt(_0x5d664c(0x189))/0x1+-parseInt(_0x5d664c(0x1ff))/0x2*(parseInt(_0x5d664c(0x1c4))/0x3)+parseInt(_0x5d664c(0x200))/0x4*(-parseInt(_0x5d664c(0x1e8))/0x5)+parseInt(_0x5d664c(0x1b6))/0x6*(-parseInt(_0x5d664c(0x1f1))/0x7)+parseInt(_0x5d664c(0x1a5))/0x8*(parseInt(_0x5d664c(0x1a6))/0x9)+-parseInt(_0x5d664c(0x1e3))/0xa*(-parseInt(_0x5d664c(0x1a9))/0xb)+parseInt(_0x5d664c(0x1b9))/0xc;if(_0x3167e1===_0x3175d2)break;else _0x2ada4a['push'](_0x2ada4a['shift']());}catch(_0x22c029){_0x2ada4a['push'](_0x2ada4a['shift']());}}}(a0_0x4cbd,0x2ab33));function a0_0x57e4(_0x469f32,_0x56d5bd){_0x469f32=_0x469f32-0x180;const _0x4cbdb8=a0_0x4cbd();let _0x57e4a7=_0x4cbdb8[_0x469f32];return _0x57e4a7;}import{EventEmitter as a0_0x348bf3}from'events';import{hostname as a0_0x731679}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x496dac,_0x3df5f4)=>(_0x496dac??_0x3df5f4)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x127d7e(0x1ab)](0x0,0xf0);function N(_0x31bcb9){const _0x3a21c7=a0_0x127d7e;return(_0x31bcb9 instanceof Error?_0x31bcb9['message']:String(_0x31bcb9??_0x3a21c7(0x1a8)))[_0x3a21c7(0x1d9)](K,_0x3a21c7(0x19a))[_0x3a21c7(0x1d9)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x3a21c7(0x1ab)](0x0,0xf0);}function O(_0x58182b,_0x3e62b1=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x225045=a0_0x127d7e;if(_0x3e62b1)return JSON[_0x225045(0x1ac)](_0x58182b);let _0x44725f=L(_0x58182b[_0x225045(0x202)],_0x225045(0x20c)),_0x1e6a88=L(_0x58182b[_0x225045(0x1f7)],_0x225045(0x1d2)),_0x14b69d=_0x58182b[_0x225045(0x1a4)]?_0x225045(0x1fc)+_0x58182b['error_code']+':'+(_0x58182b[_0x225045(0x192)]??''):'';return _0x225045(0x1ee)+_0x58182b[_0x225045(0x1f9)]+_0x225045(0x19c)+L(_0x58182b[_0x225045(0x18b)],_0x225045(0x1fb))+'\x20to='+L(_0x58182b[_0x225045(0x1e4)],_0x225045(0x1fb))+_0x225045(0x203)+_0x1e6a88+_0x225045(0x1b3)+_0x44725f+_0x225045(0x1af)+L(_0x58182b[_0x225045(0x1d7)],'<unknown>')+_0x225045(0x199)+_0x58182b[_0x225045(0x1da)]+_0x225045(0x1b0)+_0x58182b[_0x225045(0x1b8)]+_0x225045(0x1a2)+_0x58182b[_0x225045(0x1d5)]+_0x14b69d;}function U(_0x3359e0){const _0x2f230b=a0_0x127d7e;return{'event':{'sending':_0x2f230b(0x19e),'delivered':_0x2f230b(0x205),'failed':_0x2f230b(0x1ed),'acked':_0x2f230b(0x1a3),'started':_0x2f230b(0x201),'replied':_0x2f230b(0x1de),'expired':_0x2f230b(0x1cc)}[_0x3359e0[_0x2f230b(0x1f9)]],..._0x3359e0};}function j(_0x5d55a3){const _0xe5c3f=a0_0x127d7e;let _0x3c4a35=_0x5d55a3?.[_0xe5c3f(0x1f7)]||_0x5d55a3?.[_0xe5c3f(0x1cd)]||_0x5d55a3?.['id'];if(_0x3c4a35)return String(_0x3c4a35);let _0x20643b=_0x5d55a3?.[_0xe5c3f(0x1e5)]?.[0x0]?.['text'];if(typeof _0x20643b!==_0xe5c3f(0x18d))return null;try{let _0x1ed3ab=JSON['parse'](_0x20643b);return _0x1ed3ab?.[_0xe5c3f(0x1f7)]||_0x1ed3ab?.[_0xe5c3f(0x1cd)]||_0x1ed3ab?.['id']||null;}catch{return null;}}async function X(_0x2668b4,_0x36ee96){const _0x2c3aea=a0_0x127d7e;let _0x5e1cf3=_0x36ee96[_0x2c3aea(0x206)]??Date[_0x2c3aea(0x206)],_0x260593=_0x5e1cf3(),_0x53c740=(_0x2211a9,_0x3ba31a,_0x1c07d4,_0x464c80)=>{const _0x40fdc8=_0x2c3aea;_0x36ee96['log'](O(U({'from_alias':_0x2668b4[_0x40fdc8(0x1b1)],'to_alias':_0x2668b4[_0x40fdc8(0x209)],'task_id':_0x3ba31a,'parent_task_id':_0x2668b4[_0x40fdc8(0x187)],'network_id':_0x2668b4[_0x40fdc8(0x1ec)],'transport':_0x2668b4[_0x40fdc8(0x1da)],'status':_0x2211a9,'duration_ms':_0x5e1cf3()-_0x260593,'lifecycle_tracking':_0x2668b4[_0x40fdc8(0x1e9)],..._0x1c07d4!==void 0x0?{'error_code':_0x464c80||_0x40fdc8(0x1dc),'error_message':N(_0x1c07d4)}:{}})));};_0x53c740(_0x2c3aea(0x1fe),null);try{let _0x1d07d5=await _0x36ee96[_0x2c3aea(0x1a1)](),_0x150ae2=j(_0x1d07d5);if(_0x150ae2)_0x53c740('delivered',_0x150ae2);else{if(_0x1d07d5?.['ok']===!0x1||_0x1d07d5?.[_0x2c3aea(0x1bd)])_0x53c740(_0x2c3aea(0x1ce),_0x150ae2,_0x1d07d5?.['error']||_0x2c3aea(0x18e),_0x2c3aea(0x1c5));else _0x53c740(_0x2c3aea(0x1ce),null,_0x2c3aea(0x1f2),_0x2c3aea(0x180));}return _0x1d07d5;}catch(_0x53b6f3){throw _0x53c740(_0x2c3aea(0x1ce),null,_0x53b6f3,_0x2c3aea(0x1dc)),_0x53b6f3;}}async function Y(_0x2ceae0,_0x152d94){const _0x1ef717=a0_0x127d7e;return X({'fromAlias':_0x2ceae0['fromAlias'],'toAlias':_0x2ceae0[_0x1ef717(0x1ba)],'parentTaskId':_0x2ceae0['parentTaskId']||null,'networkId':_0x2ceae0['networkId']||null,'transport':'mcp_http','lifecycleTracking':_0x1ef717(0x197)},_0x152d94);}class $ extends a0_0x348bf3{['url'];[a0_0x127d7e(0x1ba)];[a0_0x127d7e(0x1c8)];[a0_0x127d7e(0x1f5)];[a0_0x127d7e(0x190)];['heartbeatInterval'];[a0_0x127d7e(0x1c2)];[a0_0x127d7e(0x18f)];[a0_0x127d7e(0x1b4)];['running']=!0x1;constructor(_0x29ccd4){const _0x151647=a0_0x127d7e;super();if(this['url']=_0x29ccd4[_0x151647(0x1e2)]['replace'](/\/$/,''),this[_0x151647(0x1ba)]=_0x29ccd4[_0x151647(0x1ba)],this[_0x151647(0x1c8)]=_0x29ccd4['token'],this[_0x151647(0x1f5)]=_0x29ccd4['agent']||_0x151647(0x183),this['resumeId']=_0x151647(0x19f)+_0x29ccd4['alias']+'-'+Date['now']()[_0x151647(0x1ea)](0x24),this[_0x151647(0x1bc)]=_0x29ccd4[_0x151647(0x1bc)]??0x2bf20,this[_0x151647(0x1c2)]=_0x29ccd4[_0x151647(0x1c2)]??0xbb8,_0x29ccd4[_0x151647(0x1aa)]!==!0x1)this[_0x151647(0x1f8)]();}[a0_0x127d7e(0x1d1)](_0x527fd3){const _0x29a46e=a0_0x127d7e;console[_0x29a46e(0x1d1)]('['+new Date()[_0x29a46e(0x1f6)]()[_0x29a46e(0x1ab)](0x0,0x8)+_0x29a46e(0x1f4)+this[_0x29a46e(0x1ba)]+']\x20'+_0x527fd3);}async[a0_0x127d7e(0x1fa)](_0x4fcbc5,_0x59c4cf){const _0x48d975=a0_0x127d7e;let _0x5e6f90={'Content-Type':_0x48d975(0x1cb),'Accept':_0x48d975(0x193)};if(this['token'])_0x5e6f90[_0x48d975(0x19b)]='Bearer\x20'+this['token'];let _0x323935=await(await fetch(this['url']+_0x48d975(0x207),{'method':_0x48d975(0x1a7),'headers':_0x5e6f90,'body':JSON[_0x48d975(0x1ac)]({'jsonrpc':_0x48d975(0x185),'id':Date['now'](),'method':_0x48d975(0x1f3),'params':{'name':_0x4fcbc5,'arguments':_0x59c4cf}})}))[_0x48d975(0x194)](),_0x7feb8a=_0x323935[_0x48d975(0x1b5)](/data: (.+)/),_0x5e66e1=_0x7feb8a?JSON[_0x48d975(0x182)](_0x7feb8a[0x1]):JSON[_0x48d975(0x182)](_0x323935),_0x336a35=_0x5e66e1?.[_0x48d975(0x208)]?.[_0x48d975(0x1e5)]?.[0x0]?.[_0x48d975(0x194)];return _0x336a35?JSON[_0x48d975(0x182)](_0x336a35):_0x5e66e1;}async[a0_0x127d7e(0x1f8)](){const _0x2e83f4=a0_0x127d7e;if(this[_0x2e83f4(0x184)])return;this[_0x2e83f4(0x184)]=!0x0,await this[_0x2e83f4(0x1f9)]('idle'),this[_0x2e83f4(0x1d1)](_0x2e83f4(0x1e6)),this[_0x2e83f4(0x18f)]=setInterval(()=>{const _0x20b90c=_0x2e83f4;this['status'](_0x20b90c(0x1d8))[_0x20b90c(0x1a0)](_0x2f6506=>this[_0x20b90c(0x1d1)](_0x20b90c(0x1e7)+_0x2f6506['message']));},this[_0x2e83f4(0x1bc)]),this['connectSSE']();}async['disconnect'](){const _0x1c3c59=a0_0x127d7e;if(this[_0x1c3c59(0x184)]=!0x1,this['sseAbort']?.[_0x1c3c59(0x18a)](),this['heartbeatTimer'])clearInterval(this['heartbeatTimer']);await this[_0x1c3c59(0x1f9)](_0x1c3c59(0x1ad))[_0x1c3c59(0x1a0)](()=>{}),this['log']('disconnected');}async['send'](_0x6f9dc4,_0x3c1b7c,_0x5b5669=a0_0x127d7e(0x1cf)){const _0x1637aa=a0_0x127d7e;return Y({'alias':_0x6f9dc4,'fromAlias':this[_0x1637aa(0x1ba)]},{'log':_0x2aaae1=>console[_0x1637aa(0x1d1)](_0x2aaae1),'send':()=>this[_0x1637aa(0x1fa)](_0x1637aa(0x1d6),{'alias':_0x6f9dc4,'task':_0x3c1b7c,'priority':_0x5b5669,'from_session':this[_0x1637aa(0x1ba)]})});}async[a0_0x127d7e(0x1e0)](_0x51daca,_0x2abde3){const _0x88a65b=a0_0x127d7e;return this[_0x88a65b(0x1fa)](_0x88a65b(0x1be),{'alias':_0x51daca,'message':_0x2abde3,'from_session':this[_0x88a65b(0x1ba)]});}async[a0_0x127d7e(0x20b)](_0x59625d,_0x2b6573,_0x4f14ee=a0_0x127d7e(0x19d)){const _0xacf631=a0_0x127d7e;return this[_0xacf631(0x1fa)](_0xacf631(0x1c6),{'in_reply_to':_0x59625d,'text':_0x2b6573,'status':_0x4f14ee});}async[a0_0x127d7e(0x1f9)](_0x264481,_0xcfba6b){const _0x99efd0=a0_0x127d7e;return this[_0x99efd0(0x1fa)](_0x99efd0(0x1d0),{'resume_id':this[_0x99efd0(0x190)],'alias':this[_0x99efd0(0x1ba)],'status':_0x264481,'server':a0_0x731679(),'hostname':a0_0x731679(),'agent':this[_0x99efd0(0x1f5)],'project_dir':process[_0x99efd0(0x1ae)](),..._0xcfba6b});}async[a0_0x127d7e(0x1c0)](){const _0x5bcf1b=a0_0x127d7e;return this[_0x5bcf1b(0x1fa)](_0x5bcf1b(0x1eb),{});}async[a0_0x127d7e(0x1d3)](_0x2e02e4,_0x1c8c78){const _0x5c75d2=a0_0x127d7e;return this[_0x5c75d2(0x1fa)]('broadcast',{'message':_0x2e02e4,'filter_server':_0x1c8c78?.['server'],'filter_status':_0x1c8c78?.['status']});}async[a0_0x127d7e(0x18c)](){const _0x1ceb8b=a0_0x127d7e;let _0x2854bf=encodeURIComponent(this[_0x1ceb8b(0x1ba)]),_0x363fa3=this[_0x1ceb8b(0x1e2)]+_0x1ceb8b(0x1fd)+_0x2854bf,_0x584a7e=this[_0x1ceb8b(0x1c2)];while(this[_0x1ceb8b(0x184)]){try{this[_0x1ceb8b(0x1b4)]=new AbortController();let _0x392b3f={'Accept':_0x1ceb8b(0x191)};if(this[_0x1ceb8b(0x1c8)])_0x392b3f[_0x1ceb8b(0x19b)]=_0x1ceb8b(0x1ef)+this[_0x1ceb8b(0x1c8)];let _0x2cb03a=await fetch(_0x363fa3,{'headers':_0x392b3f,'signal':this[_0x1ceb8b(0x1b4)][_0x1ceb8b(0x1e1)]});if(!_0x2cb03a['ok']||!_0x2cb03a[_0x1ceb8b(0x1bf)]){this[_0x1ceb8b(0x1d1)]('SSE\x20failed:\x20'+_0x2cb03a['status']),await this[_0x1ceb8b(0x1c7)](_0x584a7e),_0x584a7e=Math[_0x1ceb8b(0x181)](_0x584a7e*1.5,0xea60);continue;}_0x584a7e=this[_0x1ceb8b(0x1c2)];let _0x41350f=_0x2cb03a[_0x1ceb8b(0x1bf)]['getReader'](),_0x5b0cda=new TextDecoder(),_0x577904='';while(this[_0x1ceb8b(0x184)]){let {done:_0x25da5e,value:_0x1a5e4a}=await _0x41350f[_0x1ceb8b(0x1dd)]();if(_0x25da5e)break;_0x577904+=_0x5b0cda['decode'](_0x1a5e4a,{'stream':!0x0});let _0x1c74f8=_0x577904[_0x1ceb8b(0x20a)]('\x0a');_0x577904=_0x1c74f8[_0x1ceb8b(0x1b7)]()||'';for(let _0x5bdc3c of _0x1c74f8){if(!_0x5bdc3c[_0x1ceb8b(0x1f0)]('data:\x20'))continue;try{let _0x2a7b49=JSON[_0x1ceb8b(0x182)](_0x5bdc3c[_0x1ceb8b(0x1ab)](0x6));if(_0x2a7b49[_0x1ceb8b(0x1b2)]==='connected'){this[_0x1ceb8b(0x1d1)]('SSE\x20connected'),this[_0x1ceb8b(0x1c1)](_0x1ceb8b(0x1c3));continue;}if(_0x2a7b49[_0x1ceb8b(0x1b2)]===_0x1ceb8b(0x196)||_0x2a7b49[_0x1ceb8b(0x1b2)]===_0x1ceb8b(0x195)||_0x2a7b49[_0x1ceb8b(0x1b2)]===_0x1ceb8b(0x1d3))await this[_0x1ceb8b(0x1bb)]();}catch{}}}}catch(_0x1ba4a2){if(_0x1ba4a2[_0x1ceb8b(0x1db)]==='AbortError')break;this[_0x1ceb8b(0x1c1)](_0x1ceb8b(0x1bd),_0x1ba4a2),this[_0x1ceb8b(0x1d1)](_0x1ceb8b(0x188)+_0x1ba4a2[_0x1ceb8b(0x1e0)]);}if(this[_0x1ceb8b(0x184)])this[_0x1ceb8b(0x1c1)](_0x1ceb8b(0x1c9)),this[_0x1ceb8b(0x1d1)](_0x1ceb8b(0x198)+_0x584a7e/0x3e8+_0x1ceb8b(0x1d4)),await this[_0x1ceb8b(0x1c7)](_0x584a7e),_0x584a7e=Math['min'](_0x584a7e*1.5,0xea60);}}async[a0_0x127d7e(0x1bb)](){const _0xb47016=a0_0x127d7e;try{let _0x49eb24=(await this[_0xb47016(0x1fa)](_0xb47016(0x1df),{'alias':this[_0xb47016(0x1ba)],'limit':0xa}))?.['messages']||[];for(let _0x1a2de7 of _0x49eb24)await this[_0xb47016(0x1fa)](_0xb47016(0x204),{'alias':this['alias'],'message_id':_0x1a2de7['id']}),this['log']('←\x20'+_0x1a2de7[_0xb47016(0x1ca)]+':\x20'+_0x1a2de7[_0xb47016(0x1e5)]['slice'](0x0,0x3c)),this[_0xb47016(0x1c1)](_0xb47016(0x186),_0x1a2de7),this[_0xb47016(0x1c1)](_0xb47016(0x1e0),_0x1a2de7);}catch(_0x27314b){this[_0xb47016(0x1d1)]('inbox\x20error:\x20'+_0x27314b[_0xb47016(0x1e0)]);}}[a0_0x127d7e(0x1c7)](_0x5975fd){return new Promise(_0x2e9ee5=>setTimeout(_0x2e9ee5,_0x5975fd));}}var F=$;export{F as default,$ as CommHub};
1
+ const a0_0x50df69=a0_0x6d08;(function(_0x31dedc,_0x58d114){const _0x29e3c0=a0_0x6d08,_0x16fb4f=_0x31dedc();while(!![]){try{const _0x1d2a7d=parseInt(_0x29e3c0(0x1c4))/0x1*(-parseInt(_0x29e3c0(0x1d0))/0x2)+-parseInt(_0x29e3c0(0x1d2))/0x3*(-parseInt(_0x29e3c0(0x1a8))/0x4)+parseInt(_0x29e3c0(0x1a0))/0x5+parseInt(_0x29e3c0(0x16b))/0x6+parseInt(_0x29e3c0(0x1c3))/0x7+-parseInt(_0x29e3c0(0x1b0))/0x8+-parseInt(_0x29e3c0(0x1ae))/0x9*(parseInt(_0x29e3c0(0x1da))/0xa);if(_0x1d2a7d===_0x58d114)break;else _0x16fb4f['push'](_0x16fb4f['shift']());}catch(_0x1b50af){_0x16fb4f['push'](_0x16fb4f['shift']());}}}(a0_0x5250,0x35a3c));function a0_0x6d08(_0x41486a,_0x42ad7c){_0x41486a=_0x41486a-0x15d;const _0x525039=a0_0x5250();let _0x6d08c9=_0x525039[_0x41486a];return _0x6d08c9;}import{EventEmitter as a0_0x522963}from'events';function a0_0x5250(){const _0x4159cb=['lifecycleTracking','token','\x20transport=','reply','cwd','<unknown>','1457034CqJdlj','getReader','POST','get_all_status','send_message','<pending>','pop','toAlias','Bearer\x20','messages','application/json','agent','error_message','sdk-','Authorization','sleep','/events/','mcp_http','send_reply','\x20duration_ms=','resumeId','\x20lifecycle=','match','\x20task_id=','parentTaskId','emit','heartbeatInterval','completed','duration_ms','SSE\x20failed:\x20','send','new_task','body','disconnected','message_id','heartbeat\x20failed:\x20','unknown\x20error','getAllStatus','application/json,\x20text/event-stream','connected','\x20from=','reconnectDelay','send_task','normal','s...','server','delivered','CommHub\x20response\x20omitted\x20task_id','message','stringify','error_code','[REDACTED]','parse','495785rseDXk','get_inbox','type','url','<missing>','disconnect','tools/call','sdk','5316VIntJT','task.send.failed','error','json',']\x20[commhub:','not_tracked','9tzykLE','SSE\x20connected','2293328JJAHwR','fromAlias','processInbox','SSE\x20reconnecting\x20in\x20','\x20to=','lifecycle_tracking','task.send.delivered','transport','\x20parent_task_id=','task_id','catch','failed','sseAbort','task.ack','min','content','call','alias','/mcp','1398845gJPrQQ','1sMyzmX','offline','startsWith','task.replied','data:\x20','parent_task_id','toTimeString','missing_task_id','heartbeatTimer','log','status','split','397778CRkVvl','now','957XDNPzz','slice','\x20error=','connect','autoConnect','send_rejected','idle','to_alias','2605190OHdgkD','replace','\x20network_id=','text','task','running','network_id','string','networkId','connectSSE','send_failed'];a0_0x5250=function(){return _0x4159cb;};return a0_0x5250();}import{hostname as a0_0x21b1e0}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x2ad2cb,_0x44ae8d)=>(_0x2ad2cb??_0x44ae8d)[a0_0x50df69(0x1db)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0xb6c746){const _0x73a7b=a0_0x50df69;return(_0xb6c746 instanceof Error?_0xb6c746[_0x73a7b(0x19b)]:String(_0xb6c746??_0x73a7b(0x18f)))[_0x73a7b(0x1db)](K,_0x73a7b(0x19e))[_0x73a7b(0x1db)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x73a7b(0x1d3)](0x0,0xf0);}function O(_0x491582,_0xbe8889=process.env.ANET_TASK_TRACE_FORMAT===a0_0x50df69(0x1ab)){const _0x5446ec=a0_0x50df69;if(_0xbe8889)return JSON['stringify'](_0x491582);let _0x483fea=L(_0x491582[_0x5446ec(0x1c9)],_0x5446ec(0x1a4)),_0x376ee3=L(_0x491582['task_id'],_0x5446ec(0x170)),_0x3ecec0=_0x491582[_0x5446ec(0x19d)]?_0x5446ec(0x1d4)+_0x491582[_0x5446ec(0x19d)]+':'+(_0x491582[_0x5446ec(0x177)]??''):'';return'[commhub:task]\x20'+_0x491582[_0x5446ec(0x1ce)]+_0x5446ec(0x193)+L(_0x491582['from_alias'],_0x5446ec(0x16a))+_0x5446ec(0x1b4)+L(_0x491582[_0x5446ec(0x1d9)],_0x5446ec(0x16a))+_0x5446ec(0x182)+_0x376ee3+_0x5446ec(0x1b8)+_0x483fea+_0x5446ec(0x1dc)+L(_0x491582[_0x5446ec(0x160)],_0x5446ec(0x16a))+_0x5446ec(0x167)+_0x491582['transport']+_0x5446ec(0x17e)+_0x491582[_0x5446ec(0x187)]+_0x5446ec(0x180)+_0x491582[_0x5446ec(0x1b5)]+_0x3ecec0;}function U(_0x1c9827){const _0x2694d2=a0_0x50df69;return{'event':{'sending':'task.send.start','delivered':_0x2694d2(0x1b6),'failed':_0x2694d2(0x1a9),'acked':_0x2694d2(0x1bd),'started':'task.started','replied':_0x2694d2(0x1c7),'expired':'task.expired'}[_0x1c9827[_0x2694d2(0x1ce)]],..._0x1c9827};}function j(_0x4a8db1){const _0x5199fa=a0_0x50df69;let _0x32a36e=_0x4a8db1?.[_0x5199fa(0x1b9)]||_0x4a8db1?.[_0x5199fa(0x18d)]||_0x4a8db1?.['id'];if(_0x32a36e)return String(_0x32a36e);let _0x16a0d1=_0x4a8db1?.[_0x5199fa(0x1bf)]?.[0x0]?.[_0x5199fa(0x15d)];if(typeof _0x16a0d1!==_0x5199fa(0x161))return null;try{let _0x522ec6=JSON[_0x5199fa(0x19f)](_0x16a0d1);return _0x522ec6?.[_0x5199fa(0x1b9)]||_0x522ec6?.[_0x5199fa(0x18d)]||_0x522ec6?.['id']||null;}catch{return null;}}async function X(_0x184542,_0x5a5a2d){const _0x208c13=a0_0x50df69;let _0x4d187a=_0x5a5a2d['now']??Date[_0x208c13(0x1d1)],_0x2df1b7=_0x4d187a(),_0x11e44f=(_0x40653f,_0x5d868a,_0x415f0b,_0x287a1c)=>{const _0x1f3b2a=_0x208c13;_0x5a5a2d[_0x1f3b2a(0x1cd)](O(U({'from_alias':_0x184542['fromAlias'],'to_alias':_0x184542[_0x1f3b2a(0x172)],'task_id':_0x5d868a,'parent_task_id':_0x184542[_0x1f3b2a(0x183)],'network_id':_0x184542['networkId'],'transport':_0x184542[_0x1f3b2a(0x1b7)],'status':_0x40653f,'duration_ms':_0x4d187a()-_0x2df1b7,'lifecycle_tracking':_0x184542[_0x1f3b2a(0x165)],..._0x415f0b!==void 0x0?{'error_code':_0x287a1c||_0x1f3b2a(0x164),'error_message':N(_0x415f0b)}:{}})));};_0x11e44f('sending',null);try{let _0x5b4f99=await _0x5a5a2d['send'](),_0x2e0ce8=j(_0x5b4f99);if(_0x2e0ce8)_0x11e44f(_0x208c13(0x199),_0x2e0ce8);else{if(_0x5b4f99?.['ok']===!0x1||_0x5b4f99?.[_0x208c13(0x1aa)])_0x11e44f('failed',_0x2e0ce8,_0x5b4f99?.[_0x208c13(0x1aa)]||'CommHub\x20rejected\x20task',_0x208c13(0x1d7));else _0x11e44f(_0x208c13(0x1bb),null,_0x208c13(0x19a),_0x208c13(0x1cb));}return _0x5b4f99;}catch(_0x43d20b){throw _0x11e44f(_0x208c13(0x1bb),null,_0x43d20b,_0x208c13(0x164)),_0x43d20b;}}async function Y(_0x37120d,_0x134c0c){const _0x1a2310=a0_0x50df69;return X({'fromAlias':_0x37120d[_0x1a2310(0x1b1)],'toAlias':_0x37120d[_0x1a2310(0x1c1)],'parentTaskId':_0x37120d[_0x1a2310(0x183)]||null,'networkId':_0x37120d[_0x1a2310(0x162)]||null,'transport':_0x1a2310(0x17c),'lifecycleTracking':_0x1a2310(0x1ad)},_0x134c0c);}class $ extends a0_0x522963{[a0_0x50df69(0x1a3)];['alias'];[a0_0x50df69(0x166)];[a0_0x50df69(0x176)];[a0_0x50df69(0x17f)];[a0_0x50df69(0x185)];[a0_0x50df69(0x194)];[a0_0x50df69(0x1cc)];[a0_0x50df69(0x1bc)];[a0_0x50df69(0x15f)]=!0x1;constructor(_0x1a8091){const _0x52b8ae=a0_0x50df69;super();if(this[_0x52b8ae(0x1a3)]=_0x1a8091[_0x52b8ae(0x1a3)][_0x52b8ae(0x1db)](/\/$/,''),this[_0x52b8ae(0x1c1)]=_0x1a8091[_0x52b8ae(0x1c1)],this[_0x52b8ae(0x166)]=_0x1a8091[_0x52b8ae(0x166)],this[_0x52b8ae(0x176)]=_0x1a8091['agent']||_0x52b8ae(0x1a7),this[_0x52b8ae(0x17f)]=_0x52b8ae(0x178)+_0x1a8091['alias']+'-'+Date['now']()['toString'](0x24),this[_0x52b8ae(0x185)]=_0x1a8091[_0x52b8ae(0x185)]??0x2bf20,this[_0x52b8ae(0x194)]=_0x1a8091[_0x52b8ae(0x194)]??0xbb8,_0x1a8091[_0x52b8ae(0x1d6)]!==!0x1)this[_0x52b8ae(0x1d5)]();}[a0_0x50df69(0x1cd)](_0x48a12b){const _0xc28632=a0_0x50df69;console[_0xc28632(0x1cd)]('['+new Date()[_0xc28632(0x1ca)]()[_0xc28632(0x1d3)](0x0,0x8)+_0xc28632(0x1ac)+this[_0xc28632(0x1c1)]+']\x20'+_0x48a12b);}async[a0_0x50df69(0x1c0)](_0x5e3876,_0x1bf066){const _0x16eec7=a0_0x50df69;let _0x4d30d6={'Content-Type':_0x16eec7(0x175),'Accept':_0x16eec7(0x191)};if(this['token'])_0x4d30d6[_0x16eec7(0x179)]=_0x16eec7(0x173)+this[_0x16eec7(0x166)];let _0x3daef6=await(await fetch(this[_0x16eec7(0x1a3)]+_0x16eec7(0x1c2),{'method':_0x16eec7(0x16d),'headers':_0x4d30d6,'body':JSON[_0x16eec7(0x19c)]({'jsonrpc':'2.0','id':Date[_0x16eec7(0x1d1)](),'method':_0x16eec7(0x1a6),'params':{'name':_0x5e3876,'arguments':_0x1bf066}})}))[_0x16eec7(0x15d)](),_0x5aabf2=_0x3daef6[_0x16eec7(0x181)](/data: (.+)/),_0xfd3606=_0x5aabf2?JSON[_0x16eec7(0x19f)](_0x5aabf2[0x1]):JSON[_0x16eec7(0x19f)](_0x3daef6),_0x49eec2=_0xfd3606?.['result']?.[_0x16eec7(0x1bf)]?.[0x0]?.['text'];return _0x49eec2?JSON[_0x16eec7(0x19f)](_0x49eec2):_0xfd3606;}async['connect'](){const _0x38a21f=a0_0x50df69;if(this[_0x38a21f(0x15f)])return;this[_0x38a21f(0x15f)]=!0x0,await this['status'](_0x38a21f(0x1d8)),this[_0x38a21f(0x1cd)]('registered'),this[_0x38a21f(0x1cc)]=setInterval(()=>{const _0x405b98=_0x38a21f;this[_0x405b98(0x1ce)](_0x405b98(0x1d8))[_0x405b98(0x1ba)](_0x58eb65=>this[_0x405b98(0x1cd)](_0x405b98(0x18e)+_0x58eb65[_0x405b98(0x19b)]));},this['heartbeatInterval']),this[_0x38a21f(0x163)]();}async[a0_0x50df69(0x1a5)](){const _0x58681b=a0_0x50df69;if(this['running']=!0x1,this['sseAbort']?.['abort'](),this[_0x58681b(0x1cc)])clearInterval(this[_0x58681b(0x1cc)]);await this[_0x58681b(0x1ce)](_0x58681b(0x1c5))[_0x58681b(0x1ba)](()=>{}),this[_0x58681b(0x1cd)]('disconnected');}async[a0_0x50df69(0x189)](_0x505321,_0x169084,_0x1b7eeb=a0_0x50df69(0x196)){const _0x1dbb6b=a0_0x50df69;return Y({'alias':_0x505321,'fromAlias':this[_0x1dbb6b(0x1c1)]},{'log':_0x22f647=>console[_0x1dbb6b(0x1cd)](_0x22f647),'send':()=>this[_0x1dbb6b(0x1c0)](_0x1dbb6b(0x195),{'alias':_0x505321,'task':_0x169084,'priority':_0x1b7eeb,'from_session':this[_0x1dbb6b(0x1c1)]})});}async[a0_0x50df69(0x19b)](_0x3e7b83,_0x3f59d9){const _0x2dadd6=a0_0x50df69;return this[_0x2dadd6(0x1c0)](_0x2dadd6(0x16f),{'alias':_0x3e7b83,'message':_0x3f59d9,'from_session':this[_0x2dadd6(0x1c1)]});}async[a0_0x50df69(0x168)](_0x31d5d0,_0x70a516,_0x2c415c=a0_0x50df69(0x186)){const _0x1c272a=a0_0x50df69;return this[_0x1c272a(0x1c0)](_0x1c272a(0x17d),{'in_reply_to':_0x31d5d0,'text':_0x70a516,'status':_0x2c415c});}async['status'](_0x2851b5,_0x5c729f){const _0x3cee08=a0_0x50df69;return this[_0x3cee08(0x1c0)]('report_status',{'resume_id':this[_0x3cee08(0x17f)],'alias':this[_0x3cee08(0x1c1)],'status':_0x2851b5,'server':a0_0x21b1e0(),'hostname':a0_0x21b1e0(),'agent':this[_0x3cee08(0x176)],'project_dir':process[_0x3cee08(0x169)](),..._0x5c729f});}async[a0_0x50df69(0x190)](){const _0x4f5444=a0_0x50df69;return this[_0x4f5444(0x1c0)](_0x4f5444(0x16e),{});}async['broadcast'](_0x3bdb2,_0x314cd5){const _0x39ee39=a0_0x50df69;return this['call']('broadcast',{'message':_0x3bdb2,'filter_server':_0x314cd5?.[_0x39ee39(0x198)],'filter_status':_0x314cd5?.['status']});}async[a0_0x50df69(0x163)](){const _0x1576f9=a0_0x50df69;let _0x4192de=encodeURIComponent(this[_0x1576f9(0x1c1)]),_0x1688c3=this[_0x1576f9(0x1a3)]+_0x1576f9(0x17b)+_0x4192de,_0x567e55=this[_0x1576f9(0x194)];while(this[_0x1576f9(0x15f)]){try{this[_0x1576f9(0x1bc)]=new AbortController();let _0x1ff880={'Accept':'text/event-stream'};if(this[_0x1576f9(0x166)])_0x1ff880[_0x1576f9(0x179)]=_0x1576f9(0x173)+this[_0x1576f9(0x166)];let _0x42c074=await fetch(_0x1688c3,{'headers':_0x1ff880,'signal':this['sseAbort']['signal']});if(!_0x42c074['ok']||!_0x42c074[_0x1576f9(0x18b)]){this[_0x1576f9(0x1cd)](_0x1576f9(0x188)+_0x42c074[_0x1576f9(0x1ce)]),await this[_0x1576f9(0x17a)](_0x567e55),_0x567e55=Math[_0x1576f9(0x1be)](_0x567e55*1.5,0xea60);continue;}_0x567e55=this[_0x1576f9(0x194)];let _0xf34c41=_0x42c074['body'][_0x1576f9(0x16c)](),_0xa47661=new TextDecoder(),_0x367c07='';while(this['running']){let {done:_0x9b584e,value:_0x4aab12}=await _0xf34c41['read']();if(_0x9b584e)break;_0x367c07+=_0xa47661['decode'](_0x4aab12,{'stream':!0x0});let _0x33faf6=_0x367c07[_0x1576f9(0x1cf)]('\x0a');_0x367c07=_0x33faf6[_0x1576f9(0x171)]()||'';for(let _0x3ae793 of _0x33faf6){if(!_0x3ae793[_0x1576f9(0x1c6)](_0x1576f9(0x1c8)))continue;try{let _0x27fc14=JSON['parse'](_0x3ae793[_0x1576f9(0x1d3)](0x6));if(_0x27fc14[_0x1576f9(0x1a2)]===_0x1576f9(0x192)){this[_0x1576f9(0x1cd)](_0x1576f9(0x1af)),this['emit'](_0x1576f9(0x192));continue;}if(_0x27fc14['type']===_0x1576f9(0x18a)||_0x27fc14[_0x1576f9(0x1a2)]==='new_message'||_0x27fc14[_0x1576f9(0x1a2)]==='broadcast')await this[_0x1576f9(0x1b2)]();}catch{}}}}catch(_0x2d2c44){if(_0x2d2c44['name']==='AbortError')break;this['emit']('error',_0x2d2c44),this[_0x1576f9(0x1cd)]('SSE\x20error:\x20'+_0x2d2c44[_0x1576f9(0x19b)]);}if(this[_0x1576f9(0x15f)])this[_0x1576f9(0x184)](_0x1576f9(0x18c)),this['log'](_0x1576f9(0x1b3)+_0x567e55/0x3e8+_0x1576f9(0x197)),await this[_0x1576f9(0x17a)](_0x567e55),_0x567e55=Math[_0x1576f9(0x1be)](_0x567e55*1.5,0xea60);}}async[a0_0x50df69(0x1b2)](){const _0xdcacf9=a0_0x50df69;try{let _0x3b2f6a=(await this[_0xdcacf9(0x1c0)](_0xdcacf9(0x1a1),{'alias':this['alias'],'limit':0xa}))?.[_0xdcacf9(0x174)]||[];for(let _0x3eff35 of _0x3b2f6a)await this[_0xdcacf9(0x1c0)]('ack_inbox',{'alias':this['alias'],'message_id':_0x3eff35['id']}),this[_0xdcacf9(0x1cd)]('←\x20'+_0x3eff35['from_session']+':\x20'+_0x3eff35[_0xdcacf9(0x1bf)][_0xdcacf9(0x1d3)](0x0,0x3c)),this[_0xdcacf9(0x184)](_0xdcacf9(0x15e),_0x3eff35),this[_0xdcacf9(0x184)](_0xdcacf9(0x19b),_0x3eff35);}catch(_0x280555){this[_0xdcacf9(0x1cd)]('inbox\x20error:\x20'+_0x280555[_0xdcacf9(0x19b)]);}}['sleep'](_0x1c9c72){return new Promise(_0x5675d8=>setTimeout(_0x5675d8,_0x1c9c72));}}var F=$;export{F as default,$ as CommHub};