@sleep2agi/agent-network 2.3.0-preview.241 → 2.3.0-preview.243

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_0x547f64=a0_0x491a;(function(_0x52639f,_0x37737c){const _0x2e0df2=a0_0x491a,_0x1c9a1d=_0x52639f();while(!![]){try{const _0x74ba7b=parseInt(_0x2e0df2(0xe9))/0x1*(-parseInt(_0x2e0df2(0xa3))/0x2)+-parseInt(_0x2e0df2(0x91))/0x3*(-parseInt(_0x2e0df2(0xfb))/0x4)+-parseInt(_0x2e0df2(0xac))/0x5*(-parseInt(_0x2e0df2(0xa8))/0x6)+parseInt(_0x2e0df2(0xe4))/0x7+-parseInt(_0x2e0df2(0xdc))/0x8*(-parseInt(_0x2e0df2(0xc0))/0x9)+parseInt(_0x2e0df2(0xd0))/0xa*(parseInt(_0x2e0df2(0xc5))/0xb)+-parseInt(_0x2e0df2(0xb6))/0xc*(parseInt(_0x2e0df2(0x9b))/0xd);if(_0x74ba7b===_0x37737c)break;else _0x1c9a1d['push'](_0x1c9a1d['shift']());}catch(_0x40e2c0){_0x1c9a1d['push'](_0x1c9a1d['shift']());}}}(a0_0x556a,0xe564f));function a0_0x491a(_0x5513f9,_0x678b3d){_0x5513f9=_0x5513f9-0x84;const _0x556a12=a0_0x556a();let _0x491aa7=_0x556a12[_0x5513f9];return _0x491aa7;}import{EventEmitter as a0_0x8f975a}from'events';import{hostname as a0_0x530b89}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x235e18,_0x1c9389)=>(_0x235e18??_0x1c9389)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x547f64(0xf8)](0x0,0xf0);function N(_0x2f1b91){const _0x3886da=a0_0x547f64;return(_0x2f1b91 instanceof Error?_0x2f1b91[_0x3886da(0xec)]:String(_0x2f1b91??_0x3886da(0xd5)))[_0x3886da(0xea)](K,'[REDACTED]')[_0x3886da(0xea)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x3886da(0xf8)](0x0,0xf0);}function O(_0x694d82,_0xf8c0ec=process.env.ANET_TASK_TRACE_FORMAT===a0_0x547f64(0xf0)){const _0x3791a3=a0_0x547f64;if(_0xf8c0ec)return JSON[_0x3791a3(0xe2)](_0x694d82);let _0x54b12d=L(_0x694d82['parent_task_id'],_0x3791a3(0xab)),_0x3925d6=L(_0x694d82[_0x3791a3(0xa0)],_0x3791a3(0xfe)),_0x289271=_0x694d82[_0x3791a3(0x9a)]?'\x20error='+_0x694d82[_0x3791a3(0x9a)]+':'+(_0x694d82[_0x3791a3(0x9e)]??''):'';return _0x3791a3(0xbc)+_0x694d82[_0x3791a3(0xbe)]+'\x20from='+L(_0x694d82[_0x3791a3(0xa6)],_0x3791a3(0x9f))+_0x3791a3(0xc1)+L(_0x694d82[_0x3791a3(0xfd)],_0x3791a3(0x9f))+_0x3791a3(0x8c)+_0x3925d6+_0x3791a3(0x96)+_0x54b12d+_0x3791a3(0xb7)+L(_0x694d82['network_id'],_0x3791a3(0x9f))+'\x20transport='+_0x694d82[_0x3791a3(0xa1)]+'\x20duration_ms='+_0x694d82['duration_ms']+_0x3791a3(0xad)+_0x694d82[_0x3791a3(0xf6)]+_0x289271;}function U(_0x4b6d71){const _0x41afc4=a0_0x547f64;return{'event':{'sending':'task.send.start','delivered':_0x41afc4(0xd2),'failed':'task.send.failed','acked':'task.ack','started':'task.started','replied':_0x41afc4(0xee),'expired':_0x41afc4(0xdb)}[_0x4b6d71[_0x41afc4(0xbe)]],..._0x4b6d71};}function j(_0x2af352){const _0x742f8=a0_0x547f64;let _0x206936=_0x2af352?.['task_id']||_0x2af352?.[_0x742f8(0xdf)]||_0x2af352?.['id'];if(_0x206936)return String(_0x206936);let _0x228357=_0x2af352?.[_0x742f8(0xb8)]?.[0x0]?.[_0x742f8(0xcf)];if(typeof _0x228357!==_0x742f8(0x95))return null;try{let _0x59bb21=JSON[_0x742f8(0xd7)](_0x228357);return _0x59bb21?.[_0x742f8(0xa0)]||_0x59bb21?.[_0x742f8(0xdf)]||_0x59bb21?.['id']||null;}catch{return null;}}async function X(_0x578e60,_0x80b4bb){const _0x5bd121=a0_0x547f64;let _0x5d5b4b=_0x80b4bb[_0x5bd121(0xe7)]??Date['now'],_0x5491bf=_0x5d5b4b(),_0xb9da75=(_0x47e1f2,_0x5f0201,_0x4f639f,_0x5ddbf9)=>{const _0xd2b474=_0x5bd121;_0x80b4bb[_0xd2b474(0xdd)](O(U({'from_alias':_0x578e60[_0xd2b474(0xf7)],'to_alias':_0x578e60['toAlias'],'task_id':_0x5f0201,'parent_task_id':_0x578e60[_0xd2b474(0xf3)],'network_id':_0x578e60['networkId'],'transport':_0x578e60[_0xd2b474(0xa1)],'status':_0x47e1f2,'duration_ms':_0x5d5b4b()-_0x5491bf,'lifecycle_tracking':_0x578e60[_0xd2b474(0xe6)],..._0x4f639f!==void 0x0?{'error_code':_0x5ddbf9||_0xd2b474(0xaf),'error_message':N(_0x4f639f)}:{}})));};_0xb9da75(_0x5bd121(0xcd),null);try{let _0x100573=await _0x80b4bb['send'](),_0x40e904=j(_0x100573);if(_0x40e904)_0xb9da75('delivered',_0x40e904);else{if(_0x100573?.['ok']===!0x1||_0x100573?.['error'])_0xb9da75(_0x5bd121(0x8d),_0x40e904,_0x100573?.['error']||_0x5bd121(0xe0),_0x5bd121(0xc4));else _0xb9da75(_0x5bd121(0x8d),null,'CommHub\x20response\x20omitted\x20task_id',_0x5bd121(0x89));}return _0x100573;}catch(_0x2faea0){throw _0xb9da75(_0x5bd121(0x8d),null,_0x2faea0,_0x5bd121(0xaf)),_0x2faea0;}}async function Y(_0x323592,_0x38de9d){const _0x3e760d=a0_0x547f64;return X({'fromAlias':_0x323592[_0x3e760d(0xf7)],'toAlias':_0x323592[_0x3e760d(0xd3)],'parentTaskId':_0x323592[_0x3e760d(0xf3)]||null,'networkId':_0x323592[_0x3e760d(0xb0)]||null,'transport':_0x3e760d(0xef),'lifecycleTracking':_0x3e760d(0xfa)},_0x38de9d);}function a0_0x556a(){const _0x3c998f=['136iWSCjq','POST','to_alias','<pending>','send_reply','/events/','name','abort','Bearer\x20','missing_task_id','body','getAllStatus','\x20task_id=','failed','task','result','heartbeatInterval','46407IegeGV','send_message','heartbeat\x20failed:\x20','broadcast','string','\x20parent_task_id=','get_inbox','getReader','connectSSE','error_code','1547YMiVhV','match','reply','error_message','<unknown>','task_id','transport','heartbeatTimer','2gETRnA','resumeId','disconnected','from_alias','new_message','6sDyOaP','catch','token','<missing>','9243820TEWAlF','\x20lifecycle=','call','send_failed','networkId','reconnectDelay','connected','read','report_status','AbortError','286428OAUcDL','\x20network_id=','content','completed','normal','min','[commhub:task]\x20','processInbox','status','text/event-stream','84618Dhgvkh','\x20to=','emit','Authorization','send_rejected','10705310WJWWkM','SSE\x20error:\x20',']\x20[commhub:','tools/call','toTimeString','agent','url','disconnect','sending','/mcp','text','10Hdlbsv','2.0','task.send.delivered','alias','ack_inbox','unknown\x20error','idle','parse','signal','application/json','type','task.expired','392qlTNcF','log','decode','message_id','CommHub\x20rejected\x20task','offline','stringify','split','11740631MvgUTq','error','lifecycleTracking','now','running','1705841WPBxNy','replace','server','message','data:\x20','task.replied','mcp_http','json','send','registered','parentTaskId','connect','SSE\x20reconnecting\x20in\x20','lifecycle_tracking','fromAlias','slice','sseAbort','not_tracked'];a0_0x556a=function(){return _0x3c998f;};return a0_0x556a();}class $ extends a0_0x8f975a{[a0_0x547f64(0xcb)];[a0_0x547f64(0xd3)];[a0_0x547f64(0xaa)];['agent'];[a0_0x547f64(0xa4)];[a0_0x547f64(0x90)];['reconnectDelay'];['heartbeatTimer'];['sseAbort'];[a0_0x547f64(0xe8)]=!0x1;constructor(_0xeb6b5e){const _0x31f68d=a0_0x547f64;super();if(this[_0x31f68d(0xcb)]=_0xeb6b5e[_0x31f68d(0xcb)][_0x31f68d(0xea)](/\/$/,''),this['alias']=_0xeb6b5e[_0x31f68d(0xd3)],this[_0x31f68d(0xaa)]=_0xeb6b5e['token'],this[_0x31f68d(0xca)]=_0xeb6b5e[_0x31f68d(0xca)]||'sdk',this[_0x31f68d(0xa4)]='sdk-'+_0xeb6b5e[_0x31f68d(0xd3)]+'-'+Date[_0x31f68d(0xe7)]()['toString'](0x24),this[_0x31f68d(0x90)]=_0xeb6b5e[_0x31f68d(0x90)]??0x2bf20,this['reconnectDelay']=_0xeb6b5e[_0x31f68d(0xb1)]??0xbb8,_0xeb6b5e['autoConnect']!==!0x1)this['connect']();}[a0_0x547f64(0xdd)](_0x2a972b){const _0x4374d2=a0_0x547f64;console[_0x4374d2(0xdd)]('['+new Date()[_0x4374d2(0xc9)]()[_0x4374d2(0xf8)](0x0,0x8)+_0x4374d2(0xc7)+this['alias']+']\x20'+_0x2a972b);}async[a0_0x547f64(0xae)](_0x4e93a2,_0x52f81b){const _0x1aaecc=a0_0x547f64;let _0x35c37f={'Content-Type':_0x1aaecc(0xd9),'Accept':'application/json,\x20text/event-stream'};if(this['token'])_0x35c37f[_0x1aaecc(0xc3)]=_0x1aaecc(0x88)+this['token'];let _0x3cccc0=await(await fetch(this[_0x1aaecc(0xcb)]+_0x1aaecc(0xce),{'method':_0x1aaecc(0xfc),'headers':_0x35c37f,'body':JSON[_0x1aaecc(0xe2)]({'jsonrpc':_0x1aaecc(0xd1),'id':Date[_0x1aaecc(0xe7)](),'method':_0x1aaecc(0xc8),'params':{'name':_0x4e93a2,'arguments':_0x52f81b}})}))[_0x1aaecc(0xcf)](),_0x291bc5=_0x3cccc0[_0x1aaecc(0x9c)](/data: (.+)/),_0x861c2e=_0x291bc5?JSON['parse'](_0x291bc5[0x1]):JSON[_0x1aaecc(0xd7)](_0x3cccc0),_0x243ff9=_0x861c2e?.[_0x1aaecc(0x8f)]?.[_0x1aaecc(0xb8)]?.[0x0]?.[_0x1aaecc(0xcf)];return _0x243ff9?JSON[_0x1aaecc(0xd7)](_0x243ff9):_0x861c2e;}async[a0_0x547f64(0xf4)](){const _0x5a4e3=a0_0x547f64;if(this[_0x5a4e3(0xe8)])return;this[_0x5a4e3(0xe8)]=!0x0,await this[_0x5a4e3(0xbe)](_0x5a4e3(0xd6)),this[_0x5a4e3(0xdd)](_0x5a4e3(0xf2)),this['heartbeatTimer']=setInterval(()=>{const _0x536b2b=_0x5a4e3;this[_0x536b2b(0xbe)](_0x536b2b(0xd6))[_0x536b2b(0xa9)](_0x2e8ea7=>this[_0x536b2b(0xdd)](_0x536b2b(0x93)+_0x2e8ea7[_0x536b2b(0xec)]));},this[_0x5a4e3(0x90)]),this[_0x5a4e3(0x99)]();}async[a0_0x547f64(0xcc)](){const _0x4c2ab1=a0_0x547f64;if(this[_0x4c2ab1(0xe8)]=!0x1,this['sseAbort']?.[_0x4c2ab1(0x87)](),this[_0x4c2ab1(0xa2)])clearInterval(this['heartbeatTimer']);await this['status'](_0x4c2ab1(0xe1))['catch'](()=>{}),this[_0x4c2ab1(0xdd)](_0x4c2ab1(0xa5));}async[a0_0x547f64(0xf1)](_0x1114d0,_0x91d19e,_0x3b1c4c=a0_0x547f64(0xba)){const _0x2f1ff5=a0_0x547f64;return Y({'alias':_0x1114d0,'fromAlias':this['alias']},{'log':_0x2be9b2=>console[_0x2f1ff5(0xdd)](_0x2be9b2),'send':()=>this[_0x2f1ff5(0xae)]('send_task',{'alias':_0x1114d0,'task':_0x91d19e,'priority':_0x3b1c4c,'from_session':this[_0x2f1ff5(0xd3)]})});}async[a0_0x547f64(0xec)](_0x22f7b3,_0x140444){const _0x3a03be=a0_0x547f64;return this['call'](_0x3a03be(0x92),{'alias':_0x22f7b3,'message':_0x140444,'from_session':this[_0x3a03be(0xd3)]});}async[a0_0x547f64(0x9d)](_0x5125bb,_0xc2bb80,_0x32af82=a0_0x547f64(0xb9)){const _0x18db5f=a0_0x547f64;return this[_0x18db5f(0xae)](_0x18db5f(0x84),{'in_reply_to':_0x5125bb,'text':_0xc2bb80,'status':_0x32af82});}async[a0_0x547f64(0xbe)](_0x3aa24,_0x4ba111){const _0xfaca7d=a0_0x547f64;return this[_0xfaca7d(0xae)](_0xfaca7d(0xb4),{'resume_id':this['resumeId'],'alias':this[_0xfaca7d(0xd3)],'status':_0x3aa24,'server':a0_0x530b89(),'hostname':a0_0x530b89(),'agent':this['agent'],'project_dir':process['cwd'](),..._0x4ba111});}async[a0_0x547f64(0x8b)](){const _0x12efde=a0_0x547f64;return this[_0x12efde(0xae)]('get_all_status',{});}async[a0_0x547f64(0x94)](_0x1d0be6,_0x2e09fb){const _0x5b7deb=a0_0x547f64;return this[_0x5b7deb(0xae)]('broadcast',{'message':_0x1d0be6,'filter_server':_0x2e09fb?.[_0x5b7deb(0xeb)],'filter_status':_0x2e09fb?.[_0x5b7deb(0xbe)]});}async[a0_0x547f64(0x99)](){const _0x1ba4ab=a0_0x547f64;let _0x2af99f=encodeURIComponent(this[_0x1ba4ab(0xd3)]),_0x3909e0=this['url']+_0x1ba4ab(0x85)+_0x2af99f,_0x4665f8=this['reconnectDelay'];while(this['running']){try{this[_0x1ba4ab(0xf9)]=new AbortController();let _0x198c3e={'Accept':_0x1ba4ab(0xbf)};if(this[_0x1ba4ab(0xaa)])_0x198c3e[_0x1ba4ab(0xc3)]=_0x1ba4ab(0x88)+this[_0x1ba4ab(0xaa)];let _0x58bb85=await fetch(_0x3909e0,{'headers':_0x198c3e,'signal':this[_0x1ba4ab(0xf9)][_0x1ba4ab(0xd8)]});if(!_0x58bb85['ok']||!_0x58bb85[_0x1ba4ab(0x8a)]){this[_0x1ba4ab(0xdd)]('SSE\x20failed:\x20'+_0x58bb85[_0x1ba4ab(0xbe)]),await this['sleep'](_0x4665f8),_0x4665f8=Math[_0x1ba4ab(0xbb)](_0x4665f8*1.5,0xea60);continue;}_0x4665f8=this[_0x1ba4ab(0xb1)];let _0x461f32=_0x58bb85['body'][_0x1ba4ab(0x98)](),_0x93663f=new TextDecoder(),_0x1c974d='';while(this[_0x1ba4ab(0xe8)]){let {done:_0x34d5b5,value:_0xb83faa}=await _0x461f32[_0x1ba4ab(0xb3)]();if(_0x34d5b5)break;_0x1c974d+=_0x93663f[_0x1ba4ab(0xde)](_0xb83faa,{'stream':!0x0});let _0x9939c=_0x1c974d[_0x1ba4ab(0xe3)]('\x0a');_0x1c974d=_0x9939c['pop']()||'';for(let _0x5ce91a of _0x9939c){if(!_0x5ce91a['startsWith'](_0x1ba4ab(0xed)))continue;try{let _0x46fac6=JSON['parse'](_0x5ce91a[_0x1ba4ab(0xf8)](0x6));if(_0x46fac6[_0x1ba4ab(0xda)]===_0x1ba4ab(0xb2)){this[_0x1ba4ab(0xdd)]('SSE\x20connected'),this[_0x1ba4ab(0xc2)](_0x1ba4ab(0xb2));continue;}if(_0x46fac6[_0x1ba4ab(0xda)]==='new_task'||_0x46fac6['type']===_0x1ba4ab(0xa7)||_0x46fac6['type']===_0x1ba4ab(0x94))await this[_0x1ba4ab(0xbd)]();}catch{}}}}catch(_0x4ca135){if(_0x4ca135[_0x1ba4ab(0x86)]===_0x1ba4ab(0xb5))break;this[_0x1ba4ab(0xc2)](_0x1ba4ab(0xe5),_0x4ca135),this[_0x1ba4ab(0xdd)](_0x1ba4ab(0xc6)+_0x4ca135[_0x1ba4ab(0xec)]);}if(this[_0x1ba4ab(0xe8)])this[_0x1ba4ab(0xc2)](_0x1ba4ab(0xa5)),this[_0x1ba4ab(0xdd)](_0x1ba4ab(0xf5)+_0x4665f8/0x3e8+'s...'),await this['sleep'](_0x4665f8),_0x4665f8=Math[_0x1ba4ab(0xbb)](_0x4665f8*1.5,0xea60);}}async[a0_0x547f64(0xbd)](){const _0x4f9d5e=a0_0x547f64;try{let _0x1801cc=(await this[_0x4f9d5e(0xae)](_0x4f9d5e(0x97),{'alias':this[_0x4f9d5e(0xd3)],'limit':0xa}))?.['messages']||[];for(let _0x46a119 of _0x1801cc)await this['call'](_0x4f9d5e(0xd4),{'alias':this[_0x4f9d5e(0xd3)],'message_id':_0x46a119['id']}),this[_0x4f9d5e(0xdd)]('←\x20'+_0x46a119['from_session']+':\x20'+_0x46a119[_0x4f9d5e(0xb8)]['slice'](0x0,0x3c)),this[_0x4f9d5e(0xc2)](_0x4f9d5e(0x8e),_0x46a119),this[_0x4f9d5e(0xc2)](_0x4f9d5e(0xec),_0x46a119);}catch(_0x52089e){this['log']('inbox\x20error:\x20'+_0x52089e['message']);}}['sleep'](_0x515749){return new Promise(_0x4eb177=>setTimeout(_0x4eb177,_0x515749));}}var F=$;export{F as default,$ as CommHub};
1
+ const a0_0x265bba=a0_0xd7c1;(function(_0x1c3abf,_0x251805){const _0x497da0=a0_0xd7c1,_0xf7b04e=_0x1c3abf();while(!![]){try{const _0x27bda5=-parseInt(_0x497da0(0x107))/0x1+parseInt(_0x497da0(0xf5))/0x2*(-parseInt(_0x497da0(0xcc))/0x3)+-parseInt(_0x497da0(0xe2))/0x4*(-parseInt(_0x497da0(0xd6))/0x5)+-parseInt(_0x497da0(0xc9))/0x6+-parseInt(_0x497da0(0xa3))/0x7*(-parseInt(_0x497da0(0xbb))/0x8)+parseInt(_0x497da0(0x112))/0x9*(parseInt(_0x497da0(0xf6))/0xa)+parseInt(_0x497da0(0xea))/0xb*(-parseInt(_0x497da0(0xc4))/0xc);if(_0x27bda5===_0x251805)break;else _0xf7b04e['push'](_0xf7b04e['shift']());}catch(_0x501413){_0xf7b04e['push'](_0xf7b04e['shift']());}}}(a0_0x12eb,0xbcffa));import{EventEmitter as a0_0xe1aceb}from'events';import{hostname as a0_0x1c5d6a}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x55e852,_0x3bac8f)=>(_0x55e852??_0x3bac8f)[a0_0x265bba(0xe3)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x265bba(0xda)](0x0,0xf0);function a0_0xd7c1(_0x156f6c,_0x2b8f94){_0x156f6c=_0x156f6c-0x98;const _0x12eb7f=a0_0x12eb();let _0xd7c12=_0x12eb7f[_0x156f6c];return _0xd7c12;}function a0_0x12eb(){const _0x27ede5=['task_id','parent_task_id','emit','toTimeString','send_rejected','SSE\x20error:\x20','8YWmBmN','message_id','from_alias','content','\x20duration_ms=','signal','<unknown>','toString','getAllStatus','24NgrrMk','send_failed','\x20task_id=','\x20from=','status','7265274pYPRcu','task.send.start','fromAlias','532383LAHVOv','2.0','error_message','[commhub:task]\x20','inbox\x20error:\x20','sdk','heartbeatTimer','\x20to=','<missing>','sleep','10NkgVuT','reconnectDelay','call','alias','slice','sseAbort','not_tracked','data:\x20','parentTaskId','report_status','\x20lifecycle=','tools/call','838828upaLRJ','replace','task.ack','connectSSE','resumeId','Authorization','server','connected','1285328VleFKA','message','\x20parent_task_id=',']\x20[commhub:','connect','token','normal','read','abort','SSE\x20reconnecting\x20in\x20','min','2RapSAC','10BggBCD','log','url','cwd','sdk-','new_message','/mcp','to_alias','now','SSE\x20failed:\x20','transport','task','<pending>','networkId','network_id','match','send_reply','57767AzuSNi','disconnect','SSE\x20connected','lifecycleTracking','Bearer\x20','sending','toAlias','result','parse','failed','s...','11225394sRJCmu','mcp_http','running','duration_ms','type','heartbeat\x20failed:\x20','lifecycle_tracking','catch','task.started','stringify','heartbeatInterval','\x20error=','new_task','broadcast','error','send_message','agent','text/event-stream','disconnected','5510827GpFyzu','startsWith','CommHub\x20response\x20omitted\x20task_id','\x20transport=','idle','body','error_code','missing_task_id','processInbox','decode','get_inbox','messages','application/json,\x20text/event-stream','POST','task.send.failed','/events/','\x20network_id=','CommHub\x20rejected\x20task'];a0_0x12eb=function(){return _0x27ede5;};return a0_0x12eb();}function N(_0x1606c0){const _0x152055=a0_0x265bba;return(_0x1606c0 instanceof Error?_0x1606c0[_0x152055(0xeb)]:String(_0x1606c0??'unknown\x20error'))[_0x152055(0xe3)](K,'[REDACTED]')[_0x152055(0xe3)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x152055(0xda)](0x0,0xf0);}function O(_0x1dbf0e,_0x2376b8=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x2c8231=a0_0x265bba;if(_0x2376b8)return JSON[_0x2c8231(0x99)](_0x1dbf0e);let _0x45c215=L(_0x1dbf0e[_0x2c8231(0xb6)],_0x2c8231(0xd4)),_0x10c577=L(_0x1dbf0e[_0x2c8231(0xb5)],_0x2c8231(0x102)),_0x3f2719=_0x1dbf0e['error_code']?_0x2c8231(0x9b)+_0x1dbf0e[_0x2c8231(0xa9)]+':'+(_0x1dbf0e[_0x2c8231(0xce)]??''):'';return _0x2c8231(0xcf)+_0x1dbf0e['status']+_0x2c8231(0xc7)+L(_0x1dbf0e[_0x2c8231(0xbd)],_0x2c8231(0xc1))+_0x2c8231(0xd3)+L(_0x1dbf0e[_0x2c8231(0xfd)],_0x2c8231(0xc1))+_0x2c8231(0xc6)+_0x10c577+_0x2c8231(0xec)+_0x45c215+_0x2c8231(0xb3)+L(_0x1dbf0e[_0x2c8231(0x104)],_0x2c8231(0xc1))+_0x2c8231(0xa6)+_0x1dbf0e['transport']+_0x2c8231(0xbf)+_0x1dbf0e[_0x2c8231(0x115)]+_0x2c8231(0xe0)+_0x1dbf0e[_0x2c8231(0x118)]+_0x3f2719;}function U(_0x38a00d){const _0x4ccb12=a0_0x265bba;return{'event':{'sending':_0x4ccb12(0xca),'delivered':'task.send.delivered','failed':_0x4ccb12(0xb1),'acked':_0x4ccb12(0xe4),'started':_0x4ccb12(0x98),'replied':'task.replied','expired':'task.expired'}[_0x38a00d[_0x4ccb12(0xc8)]],..._0x38a00d};}function j(_0x406ce0){const _0x52a470=a0_0x265bba;let _0x54c444=_0x406ce0?.['task_id']||_0x406ce0?.['message_id']||_0x406ce0?.['id'];if(_0x54c444)return String(_0x54c444);let _0x91c2af=_0x406ce0?.[_0x52a470(0xbe)]?.[0x0]?.['text'];if(typeof _0x91c2af!=='string')return null;try{let _0x1ac78e=JSON['parse'](_0x91c2af);return _0x1ac78e?.[_0x52a470(0xb5)]||_0x1ac78e?.[_0x52a470(0xbc)]||_0x1ac78e?.['id']||null;}catch{return null;}}async function X(_0x3ef694,_0x36a329){const _0x195157=a0_0x265bba;let _0x24e1ca=_0x36a329[_0x195157(0xfe)]??Date['now'],_0x3b75b4=_0x24e1ca(),_0x21596f=(_0x56629a,_0x5aef15,_0x2a1213,_0x5791c0)=>{const _0x5b90df=_0x195157;_0x36a329[_0x5b90df(0xf7)](O(U({'from_alias':_0x3ef694[_0x5b90df(0xcb)],'to_alias':_0x3ef694[_0x5b90df(0x10d)],'task_id':_0x5aef15,'parent_task_id':_0x3ef694[_0x5b90df(0xde)],'network_id':_0x3ef694[_0x5b90df(0x103)],'transport':_0x3ef694[_0x5b90df(0x100)],'status':_0x56629a,'duration_ms':_0x24e1ca()-_0x3b75b4,'lifecycle_tracking':_0x3ef694[_0x5b90df(0x10a)],..._0x2a1213!==void 0x0?{'error_code':_0x5791c0||_0x5b90df(0xc5),'error_message':N(_0x2a1213)}:{}})));};_0x21596f(_0x195157(0x10c),null);try{let _0x4beced=await _0x36a329['send'](),_0x590aee=j(_0x4beced);if(_0x590aee)_0x21596f('delivered',_0x590aee);else{if(_0x4beced?.['ok']===!0x1||_0x4beced?.[_0x195157(0x9e)])_0x21596f(_0x195157(0x110),_0x590aee,_0x4beced?.[_0x195157(0x9e)]||_0x195157(0xb4),_0x195157(0xb9));else _0x21596f(_0x195157(0x110),null,_0x195157(0xa5),_0x195157(0xaa));}return _0x4beced;}catch(_0x3f24bd){throw _0x21596f(_0x195157(0x110),null,_0x3f24bd,'send_failed'),_0x3f24bd;}}async function Y(_0x492a26,_0x3d5e85){const _0x2fb4f3=a0_0x265bba;return X({'fromAlias':_0x492a26[_0x2fb4f3(0xcb)],'toAlias':_0x492a26[_0x2fb4f3(0xd9)],'parentTaskId':_0x492a26[_0x2fb4f3(0xde)]||null,'networkId':_0x492a26[_0x2fb4f3(0x103)]||null,'transport':_0x2fb4f3(0x113),'lifecycleTracking':_0x2fb4f3(0xdc)},_0x3d5e85);}class $ extends a0_0xe1aceb{['url'];[a0_0x265bba(0xd9)];[a0_0x265bba(0xef)];[a0_0x265bba(0xa0)];['resumeId'];[a0_0x265bba(0x9a)];[a0_0x265bba(0xd7)];[a0_0x265bba(0xd2)];['sseAbort'];[a0_0x265bba(0x114)]=!0x1;constructor(_0x1757f2){const _0x464bcc=a0_0x265bba;super();if(this[_0x464bcc(0xf8)]=_0x1757f2[_0x464bcc(0xf8)][_0x464bcc(0xe3)](/\/$/,''),this[_0x464bcc(0xd9)]=_0x1757f2[_0x464bcc(0xd9)],this[_0x464bcc(0xef)]=_0x1757f2['token'],this[_0x464bcc(0xa0)]=_0x1757f2[_0x464bcc(0xa0)]||_0x464bcc(0xd1),this[_0x464bcc(0xe6)]=_0x464bcc(0xfa)+_0x1757f2['alias']+'-'+Date['now']()[_0x464bcc(0xc2)](0x24),this[_0x464bcc(0x9a)]=_0x1757f2[_0x464bcc(0x9a)]??0x2bf20,this[_0x464bcc(0xd7)]=_0x1757f2['reconnectDelay']??0xbb8,_0x1757f2['autoConnect']!==!0x1)this[_0x464bcc(0xee)]();}[a0_0x265bba(0xf7)](_0x5472a0){const _0x30236e=a0_0x265bba;console[_0x30236e(0xf7)]('['+new Date()[_0x30236e(0xb8)]()[_0x30236e(0xda)](0x0,0x8)+_0x30236e(0xed)+this[_0x30236e(0xd9)]+']\x20'+_0x5472a0);}async[a0_0x265bba(0xd8)](_0x205848,_0x5cc57){const _0x163c93=a0_0x265bba;let _0x368c19={'Content-Type':'application/json','Accept':_0x163c93(0xaf)};if(this['token'])_0x368c19[_0x163c93(0xe7)]=_0x163c93(0x10b)+this[_0x163c93(0xef)];let _0x418a1c=await(await fetch(this[_0x163c93(0xf8)]+_0x163c93(0xfc),{'method':_0x163c93(0xb0),'headers':_0x368c19,'body':JSON[_0x163c93(0x99)]({'jsonrpc':_0x163c93(0xcd),'id':Date['now'](),'method':_0x163c93(0xe1),'params':{'name':_0x205848,'arguments':_0x5cc57}})}))['text'](),_0xbfa588=_0x418a1c[_0x163c93(0x105)](/data: (.+)/),_0x464fb2=_0xbfa588?JSON[_0x163c93(0x10f)](_0xbfa588[0x1]):JSON['parse'](_0x418a1c),_0x124fa6=_0x464fb2?.[_0x163c93(0x10e)]?.[_0x163c93(0xbe)]?.[0x0]?.['text'];return _0x124fa6?JSON[_0x163c93(0x10f)](_0x124fa6):_0x464fb2;}async[a0_0x265bba(0xee)](){const _0x109bfd=a0_0x265bba;if(this[_0x109bfd(0x114)])return;this[_0x109bfd(0x114)]=!0x0,await this[_0x109bfd(0xc8)](_0x109bfd(0xa7)),this['log']('registered'),this['heartbeatTimer']=setInterval(()=>{const _0x3bdce4=_0x109bfd;this[_0x3bdce4(0xc8)](_0x3bdce4(0xa7))[_0x3bdce4(0x119)](_0x7b6242=>this[_0x3bdce4(0xf7)](_0x3bdce4(0x117)+_0x7b6242[_0x3bdce4(0xeb)]));},this[_0x109bfd(0x9a)]),this[_0x109bfd(0xe5)]();}async[a0_0x265bba(0x108)](){const _0x3d4310=a0_0x265bba;if(this['running']=!0x1,this[_0x3d4310(0xdb)]?.[_0x3d4310(0xf2)](),this[_0x3d4310(0xd2)])clearInterval(this[_0x3d4310(0xd2)]);await this[_0x3d4310(0xc8)]('offline')[_0x3d4310(0x119)](()=>{}),this[_0x3d4310(0xf7)](_0x3d4310(0xa2));}async['send'](_0x587943,_0x557b6e,_0x35610b=a0_0x265bba(0xf0)){const _0x5c7bb0=a0_0x265bba;return Y({'alias':_0x587943,'fromAlias':this[_0x5c7bb0(0xd9)]},{'log':_0x79d8fc=>console['log'](_0x79d8fc),'send':()=>this[_0x5c7bb0(0xd8)]('send_task',{'alias':_0x587943,'task':_0x557b6e,'priority':_0x35610b,'from_session':this[_0x5c7bb0(0xd9)]})});}async['message'](_0x2fb679,_0x23574d){const _0x5e9da9=a0_0x265bba;return this[_0x5e9da9(0xd8)](_0x5e9da9(0x9f),{'alias':_0x2fb679,'message':_0x23574d,'from_session':this[_0x5e9da9(0xd9)]});}async['reply'](_0x29713c,_0x26ba7d,_0x5cc780='completed'){const _0x3f1262=a0_0x265bba;return this[_0x3f1262(0xd8)](_0x3f1262(0x106),{'in_reply_to':_0x29713c,'text':_0x26ba7d,'status':_0x5cc780});}async['status'](_0x4435f1,_0x32c28a){const _0x2979c8=a0_0x265bba;return this[_0x2979c8(0xd8)](_0x2979c8(0xdf),{'resume_id':this[_0x2979c8(0xe6)],'alias':this[_0x2979c8(0xd9)],'status':_0x4435f1,'server':a0_0x1c5d6a(),'hostname':a0_0x1c5d6a(),'agent':this[_0x2979c8(0xa0)],'project_dir':process[_0x2979c8(0xf9)](),..._0x32c28a});}async[a0_0x265bba(0xc3)](){const _0x206933=a0_0x265bba;return this[_0x206933(0xd8)]('get_all_status',{});}async['broadcast'](_0x485d1f,_0x4be5ef){const _0x27afc5=a0_0x265bba;return this['call'](_0x27afc5(0x9d),{'message':_0x485d1f,'filter_server':_0x4be5ef?.[_0x27afc5(0xe8)],'filter_status':_0x4be5ef?.[_0x27afc5(0xc8)]});}async['connectSSE'](){const _0x6e220c=a0_0x265bba;let _0x2b96de=encodeURIComponent(this['alias']),_0x12b2b4=this[_0x6e220c(0xf8)]+_0x6e220c(0xb2)+_0x2b96de,_0x4cc12d=this[_0x6e220c(0xd7)];while(this['running']){try{this[_0x6e220c(0xdb)]=new AbortController();let _0x48c9bd={'Accept':_0x6e220c(0xa1)};if(this['token'])_0x48c9bd['Authorization']='Bearer\x20'+this[_0x6e220c(0xef)];let _0xd164ff=await fetch(_0x12b2b4,{'headers':_0x48c9bd,'signal':this[_0x6e220c(0xdb)][_0x6e220c(0xc0)]});if(!_0xd164ff['ok']||!_0xd164ff[_0x6e220c(0xa8)]){this[_0x6e220c(0xf7)](_0x6e220c(0xff)+_0xd164ff[_0x6e220c(0xc8)]),await this[_0x6e220c(0xd5)](_0x4cc12d),_0x4cc12d=Math[_0x6e220c(0xf4)](_0x4cc12d*1.5,0xea60);continue;}_0x4cc12d=this[_0x6e220c(0xd7)];let _0x19eee6=_0xd164ff['body']['getReader'](),_0x528357=new TextDecoder(),_0x405880='';while(this[_0x6e220c(0x114)]){let {done:_0x2c6dd8,value:_0x530930}=await _0x19eee6[_0x6e220c(0xf1)]();if(_0x2c6dd8)break;_0x405880+=_0x528357[_0x6e220c(0xac)](_0x530930,{'stream':!0x0});let _0x347635=_0x405880['split']('\x0a');_0x405880=_0x347635['pop']()||'';for(let _0x5bd6c6 of _0x347635){if(!_0x5bd6c6[_0x6e220c(0xa4)](_0x6e220c(0xdd)))continue;try{let _0x4bd726=JSON[_0x6e220c(0x10f)](_0x5bd6c6[_0x6e220c(0xda)](0x6));if(_0x4bd726[_0x6e220c(0x116)]==='connected'){this[_0x6e220c(0xf7)](_0x6e220c(0x109)),this[_0x6e220c(0xb7)](_0x6e220c(0xe9));continue;}if(_0x4bd726['type']===_0x6e220c(0x9c)||_0x4bd726[_0x6e220c(0x116)]===_0x6e220c(0xfb)||_0x4bd726[_0x6e220c(0x116)]===_0x6e220c(0x9d))await this[_0x6e220c(0xab)]();}catch{}}}}catch(_0x5da394){if(_0x5da394['name']==='AbortError')break;this['emit'](_0x6e220c(0x9e),_0x5da394),this['log'](_0x6e220c(0xba)+_0x5da394['message']);}if(this[_0x6e220c(0x114)])this[_0x6e220c(0xb7)](_0x6e220c(0xa2)),this[_0x6e220c(0xf7)](_0x6e220c(0xf3)+_0x4cc12d/0x3e8+_0x6e220c(0x111)),await this['sleep'](_0x4cc12d),_0x4cc12d=Math['min'](_0x4cc12d*1.5,0xea60);}}async[a0_0x265bba(0xab)](){const _0x43b619=a0_0x265bba;try{let _0x49de05=(await this[_0x43b619(0xd8)](_0x43b619(0xad),{'alias':this[_0x43b619(0xd9)],'limit':0xa}))?.[_0x43b619(0xae)]||[];for(let _0x3b6418 of _0x49de05)await this[_0x43b619(0xd8)]('ack_inbox',{'alias':this[_0x43b619(0xd9)],'message_id':_0x3b6418['id']}),this[_0x43b619(0xf7)]('←\x20'+_0x3b6418['from_session']+':\x20'+_0x3b6418['content'][_0x43b619(0xda)](0x0,0x3c)),this[_0x43b619(0xb7)](_0x43b619(0x101),_0x3b6418),this[_0x43b619(0xb7)]('message',_0x3b6418);}catch(_0x4a8c1d){this[_0x43b619(0xf7)](_0x43b619(0xd0)+_0x4a8c1d[_0x43b619(0xeb)]);}}[a0_0x265bba(0xd5)](_0x184a51){return new Promise(_0x15bce3=>setTimeout(_0x15bce3,_0x184a51));}}var F=$;export{F as default,$ as CommHub};