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

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_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};
1
+ const a0_0x3202f1=a0_0x1ba1;(function(_0xae77d3,_0x41acd6){const _0x49d876=a0_0x1ba1,_0x747006=_0xae77d3();while(!![]){try{const _0x25261b=-parseInt(_0x49d876(0x108))/0x1+parseInt(_0x49d876(0xf1))/0x2+parseInt(_0x49d876(0x149))/0x3*(-parseInt(_0x49d876(0xd7))/0x4)+-parseInt(_0x49d876(0x10d))/0x5*(parseInt(_0x49d876(0x114))/0x6)+parseInt(_0x49d876(0x122))/0x7+parseInt(_0x49d876(0x11f))/0x8+-parseInt(_0x49d876(0x121))/0x9*(-parseInt(_0x49d876(0x101))/0xa);if(_0x25261b===_0x41acd6)break;else _0x747006['push'](_0x747006['shift']());}catch(_0x47c0fd){_0x747006['push'](_0x747006['shift']());}}}(a0_0x188e,0xa58d7));import{EventEmitter as a0_0x1408d2}from'events';import{hostname as a0_0x5e1407}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x2b6b91,_0x52bd46)=>(_0x2b6b91??_0x52bd46)[a0_0x3202f1(0x11a)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x3202f1(0xd2)](0x0,0xf0);function N(_0x20bb47){const _0x4d08ee=a0_0x3202f1;return(_0x20bb47 instanceof Error?_0x20bb47[_0x4d08ee(0x13e)]:String(_0x20bb47??_0x4d08ee(0xe9)))[_0x4d08ee(0x11a)](K,_0x4d08ee(0x13a))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x4d08ee(0xd2)](0x0,0xf0);}function O(_0x31bc23,_0x1da239=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x1f11cb=a0_0x3202f1;if(_0x1da239)return JSON[_0x1f11cb(0x137)](_0x31bc23);let _0x8a08cc=L(_0x31bc23[_0x1f11cb(0xfb)],_0x1f11cb(0xdf)),_0x58446d=L(_0x31bc23[_0x1f11cb(0xf3)],_0x1f11cb(0x119)),_0xc0d95c=_0x31bc23[_0x1f11cb(0x12d)]?'\x20error='+_0x31bc23[_0x1f11cb(0x12d)]+':'+(_0x31bc23['error_message']??''):'';return'[commhub:task]\x20'+_0x31bc23[_0x1f11cb(0x105)]+_0x1f11cb(0xdc)+L(_0x31bc23['from_alias'],_0x1f11cb(0x11c))+_0x1f11cb(0xe3)+L(_0x31bc23[_0x1f11cb(0x12f)],_0x1f11cb(0x11c))+'\x20task_id='+_0x58446d+_0x1f11cb(0xfe)+_0x8a08cc+_0x1f11cb(0xd8)+L(_0x31bc23['network_id'],_0x1f11cb(0x11c))+_0x1f11cb(0x131)+_0x31bc23[_0x1f11cb(0x100)]+_0x1f11cb(0xfa)+_0x31bc23[_0x1f11cb(0xe5)]+_0x1f11cb(0x117)+_0x31bc23['lifecycle_tracking']+_0xc0d95c;}function U(_0x2da560){const _0x54a55b=a0_0x3202f1;return{'event':{'sending':_0x54a55b(0x10e),'delivered':'task.send.delivered','failed':_0x54a55b(0xee),'acked':_0x54a55b(0xe4),'started':_0x54a55b(0xf6),'replied':_0x54a55b(0xd6),'expired':_0x54a55b(0x148)}[_0x2da560[_0x54a55b(0x105)]],..._0x2da560};}function j(_0x8ae5ac){const _0x548fbe=a0_0x3202f1;let _0x17e93b=_0x8ae5ac?.[_0x548fbe(0xf3)]||_0x8ae5ac?.[_0x548fbe(0x125)]||_0x8ae5ac?.['id'];if(_0x17e93b)return String(_0x17e93b);let _0x5e9e9b=_0x8ae5ac?.['content']?.[0x0]?.[_0x548fbe(0xfc)];if(typeof _0x5e9e9b!==_0x548fbe(0x110))return null;try{let _0x2d56a1=JSON[_0x548fbe(0xf0)](_0x5e9e9b);return _0x2d56a1?.[_0x548fbe(0xf3)]||_0x2d56a1?.[_0x548fbe(0x125)]||_0x2d56a1?.['id']||null;}catch{return null;}}function a0_0x1ba1(_0x801137,_0x7187fd){_0x801137=_0x801137-0xd2;const _0x188ef6=a0_0x188e();let _0x1ba167=_0x188ef6[_0x801137];return _0x1ba167;}function a0_0x188e(){const _0x843026=['\x20to=','task.ack','duration_ms','pop','heartbeatTimer','failed','unknown\x20error','toAlias','completed','reconnectDelay','delivered','task.send.failed','body','parse','1144224cqQBtk',']\x20[commhub:','task_id','new_task','mcp_http','task.started','disconnect','send_message','get_all_status','\x20duration_ms=','parent_task_id','text','broadcast','\x20parent_task_id=','networkId','transport','10AkZdfY','tools/call','error','server','status','result','reply','1255308mfxUzd','data:\x20','SSE\x20reconnecting\x20in\x20','inbox\x20error:\x20','new_message','127440DtaMdE','task.send.start','text/event-stream','string','min','connectSSE','emit','234uOgFUw','registered','agent','\x20lifecycle=','/events/','<pending>','replace','token','<unknown>','abort','application/json','8948872vKfZRz','report_status','9728973CNmBmM','4183291MytEUA','split','url','message_id','application/json,\x20text/event-stream','send_rejected','send_failed','parentTaskId','running','CommHub\x20rejected\x20task','connect','error_code','processInbox','to_alias','autoConnect','\x20transport=','ack_inbox','Bearer\x20','lifecycleTracking','toString','call','stringify','sending','send_task','[REDACTED]','messages','connected','type','message','send_reply','alias','cwd','signal','SSE\x20failed:\x20','disconnected','startsWith','fromAlias','sseAbort','task.expired','3PHteDx','decode','not_tracked','now','SSE\x20error:\x20','toTimeString','missing_task_id','name','CommHub\x20response\x20omitted\x20task_id','slice','idle','offline','content','task.replied','1767552cyDndf','\x20network_id=','send','from_session','2.0','\x20from=','log','heartbeatInterval','<missing>','task','resumeId','catch'];a0_0x188e=function(){return _0x843026;};return a0_0x188e();}async function X(_0x5b0fec,_0x2bbbc5){const _0x457a8f=a0_0x3202f1;let _0x2a852a=_0x2bbbc5[_0x457a8f(0x14c)]??Date['now'],_0x3e4035=_0x2a852a(),_0x2fa989=(_0x233cc6,_0x1d0a3b,_0x3607d7,_0x295198)=>{const _0x3bada=_0x457a8f;_0x2bbbc5[_0x3bada(0xdd)](O(U({'from_alias':_0x5b0fec[_0x3bada(0x146)],'to_alias':_0x5b0fec[_0x3bada(0xea)],'task_id':_0x1d0a3b,'parent_task_id':_0x5b0fec[_0x3bada(0x129)],'network_id':_0x5b0fec[_0x3bada(0xff)],'transport':_0x5b0fec[_0x3bada(0x100)],'status':_0x233cc6,'duration_ms':_0x2a852a()-_0x3e4035,'lifecycle_tracking':_0x5b0fec[_0x3bada(0x134)],..._0x3607d7!==void 0x0?{'error_code':_0x295198||'send_failed','error_message':N(_0x3607d7)}:{}})));};_0x2fa989(_0x457a8f(0x138),null);try{let _0x31786f=await _0x2bbbc5[_0x457a8f(0xd9)](),_0x1f97de=j(_0x31786f);if(_0x1f97de)_0x2fa989(_0x457a8f(0xed),_0x1f97de);else{if(_0x31786f?.['ok']===!0x1||_0x31786f?.[_0x457a8f(0x103)])_0x2fa989(_0x457a8f(0xe8),_0x1f97de,_0x31786f?.[_0x457a8f(0x103)]||_0x457a8f(0x12b),_0x457a8f(0x127));else _0x2fa989(_0x457a8f(0xe8),null,_0x457a8f(0x151),_0x457a8f(0x14f));}return _0x31786f;}catch(_0x58d5eb){throw _0x2fa989(_0x457a8f(0xe8),null,_0x58d5eb,_0x457a8f(0x128)),_0x58d5eb;}}async function Y(_0x4084db,_0x51ce19){const _0x53b4e6=a0_0x3202f1;return X({'fromAlias':_0x4084db[_0x53b4e6(0x146)],'toAlias':_0x4084db[_0x53b4e6(0x140)],'parentTaskId':_0x4084db[_0x53b4e6(0x129)]||null,'networkId':_0x4084db[_0x53b4e6(0xff)]||null,'transport':_0x53b4e6(0xf5),'lifecycleTracking':_0x53b4e6(0x14b)},_0x51ce19);}class $ extends a0_0x1408d2{[a0_0x3202f1(0x124)];[a0_0x3202f1(0x140)];['token'];[a0_0x3202f1(0x116)];[a0_0x3202f1(0xe1)];['heartbeatInterval'];[a0_0x3202f1(0xec)];['heartbeatTimer'];['sseAbort'];[a0_0x3202f1(0x12a)]=!0x1;constructor(_0x370c0c){const _0x3491cd=a0_0x3202f1;super();if(this[_0x3491cd(0x124)]=_0x370c0c[_0x3491cd(0x124)][_0x3491cd(0x11a)](/\/$/,''),this[_0x3491cd(0x140)]=_0x370c0c['alias'],this[_0x3491cd(0x11b)]=_0x370c0c[_0x3491cd(0x11b)],this[_0x3491cd(0x116)]=_0x370c0c[_0x3491cd(0x116)]||'sdk',this[_0x3491cd(0xe1)]='sdk-'+_0x370c0c[_0x3491cd(0x140)]+'-'+Date['now']()[_0x3491cd(0x135)](0x24),this[_0x3491cd(0xde)]=_0x370c0c[_0x3491cd(0xde)]??0x2bf20,this[_0x3491cd(0xec)]=_0x370c0c['reconnectDelay']??0xbb8,_0x370c0c[_0x3491cd(0x130)]!==!0x1)this['connect']();}[a0_0x3202f1(0xdd)](_0x5905ae){const _0x5fe975=a0_0x3202f1;console['log']('['+new Date()[_0x5fe975(0x14e)]()[_0x5fe975(0xd2)](0x0,0x8)+_0x5fe975(0xf2)+this[_0x5fe975(0x140)]+']\x20'+_0x5905ae);}async['call'](_0x3dfa10,_0x3778d3){const _0x35ec58=a0_0x3202f1;let _0x855b97={'Content-Type':_0x35ec58(0x11e),'Accept':_0x35ec58(0x126)};if(this[_0x35ec58(0x11b)])_0x855b97['Authorization']=_0x35ec58(0x133)+this[_0x35ec58(0x11b)];let _0x1594da=await(await fetch(this['url']+'/mcp',{'method':'POST','headers':_0x855b97,'body':JSON[_0x35ec58(0x137)]({'jsonrpc':_0x35ec58(0xdb),'id':Date[_0x35ec58(0x14c)](),'method':_0x35ec58(0x102),'params':{'name':_0x3dfa10,'arguments':_0x3778d3}})}))['text'](),_0x56d749=_0x1594da['match'](/data: (.+)/),_0x36e6e5=_0x56d749?JSON['parse'](_0x56d749[0x1]):JSON[_0x35ec58(0xf0)](_0x1594da),_0xa6f538=_0x36e6e5?.[_0x35ec58(0x106)]?.[_0x35ec58(0xd5)]?.[0x0]?.[_0x35ec58(0xfc)];return _0xa6f538?JSON['parse'](_0xa6f538):_0x36e6e5;}async[a0_0x3202f1(0x12c)](){const _0x83430d=a0_0x3202f1;if(this[_0x83430d(0x12a)])return;this[_0x83430d(0x12a)]=!0x0,await this[_0x83430d(0x105)]('idle'),this[_0x83430d(0xdd)](_0x83430d(0x115)),this[_0x83430d(0xe7)]=setInterval(()=>{const _0x1c285f=_0x83430d;this[_0x1c285f(0x105)](_0x1c285f(0xd3))[_0x1c285f(0xe2)](_0x36f5b1=>this[_0x1c285f(0xdd)]('heartbeat\x20failed:\x20'+_0x36f5b1[_0x1c285f(0x13e)]));},this['heartbeatInterval']),this['connectSSE']();}async[a0_0x3202f1(0xf7)](){const _0x5fecbb=a0_0x3202f1;if(this[_0x5fecbb(0x12a)]=!0x1,this['sseAbort']?.[_0x5fecbb(0x11d)](),this['heartbeatTimer'])clearInterval(this['heartbeatTimer']);await this[_0x5fecbb(0x105)](_0x5fecbb(0xd4))['catch'](()=>{}),this[_0x5fecbb(0xdd)](_0x5fecbb(0x144));}async[a0_0x3202f1(0xd9)](_0x465c47,_0x34eb43,_0x11d26d='normal'){const _0xf029c0=a0_0x3202f1;return Y({'alias':_0x465c47,'fromAlias':this['alias']},{'log':_0x4bcaf6=>console['log'](_0x4bcaf6),'send':()=>this[_0xf029c0(0x136)](_0xf029c0(0x139),{'alias':_0x465c47,'task':_0x34eb43,'priority':_0x11d26d,'from_session':this['alias']})});}async['message'](_0xd45c25,_0x226bda){const _0x55973f=a0_0x3202f1;return this[_0x55973f(0x136)](_0x55973f(0xf8),{'alias':_0xd45c25,'message':_0x226bda,'from_session':this[_0x55973f(0x140)]});}async[a0_0x3202f1(0x107)](_0x18f9ad,_0x32460c,_0x1e256c=a0_0x3202f1(0xeb)){const _0x320570=a0_0x3202f1;return this['call'](_0x320570(0x13f),{'in_reply_to':_0x18f9ad,'text':_0x32460c,'status':_0x1e256c});}async[a0_0x3202f1(0x105)](_0x5eb4ff,_0x214cdd){const _0x13a588=a0_0x3202f1;return this[_0x13a588(0x136)](_0x13a588(0x120),{'resume_id':this[_0x13a588(0xe1)],'alias':this[_0x13a588(0x140)],'status':_0x5eb4ff,'server':a0_0x5e1407(),'hostname':a0_0x5e1407(),'agent':this['agent'],'project_dir':process[_0x13a588(0x141)](),..._0x214cdd});}async['getAllStatus'](){const _0x3a3b59=a0_0x3202f1;return this['call'](_0x3a3b59(0xf9),{});}async[a0_0x3202f1(0xfd)](_0x303db7,_0x3c151f){const _0x3ccc8d=a0_0x3202f1;return this[_0x3ccc8d(0x136)](_0x3ccc8d(0xfd),{'message':_0x303db7,'filter_server':_0x3c151f?.[_0x3ccc8d(0x104)],'filter_status':_0x3c151f?.[_0x3ccc8d(0x105)]});}async[a0_0x3202f1(0x112)](){const _0x4e2f29=a0_0x3202f1;let _0x421715=encodeURIComponent(this[_0x4e2f29(0x140)]),_0xe65260=this['url']+_0x4e2f29(0x118)+_0x421715,_0x5ec7ba=this[_0x4e2f29(0xec)];while(this['running']){try{this[_0x4e2f29(0x147)]=new AbortController();let _0x112588={'Accept':_0x4e2f29(0x10f)};if(this[_0x4e2f29(0x11b)])_0x112588['Authorization']='Bearer\x20'+this[_0x4e2f29(0x11b)];let _0x56de16=await fetch(_0xe65260,{'headers':_0x112588,'signal':this[_0x4e2f29(0x147)][_0x4e2f29(0x142)]});if(!_0x56de16['ok']||!_0x56de16['body']){this['log'](_0x4e2f29(0x143)+_0x56de16[_0x4e2f29(0x105)]),await this['sleep'](_0x5ec7ba),_0x5ec7ba=Math[_0x4e2f29(0x111)](_0x5ec7ba*1.5,0xea60);continue;}_0x5ec7ba=this[_0x4e2f29(0xec)];let _0x147311=_0x56de16[_0x4e2f29(0xef)]['getReader'](),_0x1073aa=new TextDecoder(),_0x5ca052='';while(this[_0x4e2f29(0x12a)]){let {done:_0x1079e4,value:_0x1474e9}=await _0x147311['read']();if(_0x1079e4)break;_0x5ca052+=_0x1073aa[_0x4e2f29(0x14a)](_0x1474e9,{'stream':!0x0});let _0x333886=_0x5ca052[_0x4e2f29(0x123)]('\x0a');_0x5ca052=_0x333886[_0x4e2f29(0xe6)]()||'';for(let _0x2eded1 of _0x333886){if(!_0x2eded1[_0x4e2f29(0x145)](_0x4e2f29(0x109)))continue;try{let _0x407b67=JSON[_0x4e2f29(0xf0)](_0x2eded1[_0x4e2f29(0xd2)](0x6));if(_0x407b67[_0x4e2f29(0x13d)]==='connected'){this['log']('SSE\x20connected'),this[_0x4e2f29(0x113)](_0x4e2f29(0x13c));continue;}if(_0x407b67[_0x4e2f29(0x13d)]===_0x4e2f29(0xf4)||_0x407b67[_0x4e2f29(0x13d)]===_0x4e2f29(0x10c)||_0x407b67[_0x4e2f29(0x13d)]===_0x4e2f29(0xfd))await this[_0x4e2f29(0x12e)]();}catch{}}}}catch(_0x274ad0){if(_0x274ad0[_0x4e2f29(0x150)]==='AbortError')break;this[_0x4e2f29(0x113)](_0x4e2f29(0x103),_0x274ad0),this[_0x4e2f29(0xdd)](_0x4e2f29(0x14d)+_0x274ad0[_0x4e2f29(0x13e)]);}if(this[_0x4e2f29(0x12a)])this[_0x4e2f29(0x113)](_0x4e2f29(0x144)),this[_0x4e2f29(0xdd)](_0x4e2f29(0x10a)+_0x5ec7ba/0x3e8+'s...'),await this['sleep'](_0x5ec7ba),_0x5ec7ba=Math[_0x4e2f29(0x111)](_0x5ec7ba*1.5,0xea60);}}async[a0_0x3202f1(0x12e)](){const _0x493a77=a0_0x3202f1;try{let _0xe6fcfd=(await this['call']('get_inbox',{'alias':this['alias'],'limit':0xa}))?.[_0x493a77(0x13b)]||[];for(let _0x3a1850 of _0xe6fcfd)await this[_0x493a77(0x136)](_0x493a77(0x132),{'alias':this[_0x493a77(0x140)],'message_id':_0x3a1850['id']}),this[_0x493a77(0xdd)]('←\x20'+_0x3a1850[_0x493a77(0xda)]+':\x20'+_0x3a1850['content'][_0x493a77(0xd2)](0x0,0x3c)),this[_0x493a77(0x113)](_0x493a77(0xe0),_0x3a1850),this[_0x493a77(0x113)](_0x493a77(0x13e),_0x3a1850);}catch(_0x196d3d){this[_0x493a77(0xdd)](_0x493a77(0x10b)+_0x196d3d[_0x493a77(0x13e)]);}}['sleep'](_0xd7c6ad){return new Promise(_0x123e39=>setTimeout(_0x123e39,_0xd7c6ad));}}var F=$;export{F as default,$ as CommHub};