@sleep2agi/agent-network 2.3.0-preview.190 → 2.3.0-preview.191

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_0x3415c1=a0_0xad81;(function(_0x28102c,_0xdff2ad){const _0x4533ce=a0_0xad81,_0x3c341=_0x28102c();while(!![]){try{const _0x3daa65=parseInt(_0x4533ce(0x12b))/0x1*(parseInt(_0x4533ce(0x13d))/0x2)+parseInt(_0x4533ce(0x14e))/0x3*(parseInt(_0x4533ce(0x124))/0x4)+-parseInt(_0x4533ce(0x125))/0x5*(parseInt(_0x4533ce(0x170))/0x6)+-parseInt(_0x4533ce(0x126))/0x7+parseInt(_0x4533ce(0x113))/0x8*(parseInt(_0x4533ce(0x16e))/0x9)+-parseInt(_0x4533ce(0x14a))/0xa+parseInt(_0x4533ce(0x128))/0xb;if(_0x3daa65===_0xdff2ad)break;else _0x3c341['push'](_0x3c341['shift']());}catch(_0x587937){_0x3c341['push'](_0x3c341['shift']());}}}(a0_0x1625,0xad788));import{EventEmitter as a0_0x15c96e}from'events';import{hostname as a0_0x596ed3}from'os';function a0_0xad81(_0x475488,_0x2cf2ae){_0x475488=_0x475488-0x106;const _0x162543=a0_0x1625();let _0xad818e=_0x162543[_0x475488];return _0xad818e;}var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x22bd9f,_0x58c185)=>(_0x22bd9f??_0x58c185)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x3415c1(0x16a)](0x0,0xf0);function a0_0x1625(){const _0x7f1db5=['normal','string','pop','toString','Bearer\x20','network_id','\x20transport=','idle','SSE\x20reconnecting\x20in\x20','parse','alias','<pending>','name','duration_ms','send','14YTWwEI','error','s...','heartbeat\x20failed:\x20','parent_task_id','call','url','sending','\x20parent_task_id=','offline','failed','<missing>','startsWith','12779160SIVrmi','new_message','POST','[REDACTED]','1869543OGOhTH','text/event-stream','Authorization','send_message','2.0','content','connected','send_task','SSE\x20error:\x20','body','message','<unknown>','\x20to=','text','[commhub:task]\x20','token','task.send.failed','sleep','abort','task.started','task.replied','result','lifecycleTracking','sseAbort','signal','transport','from_session','min','slice','sdk-','fromAlias','data:\x20','8073RXsDKm','/mcp','114XPlDyt','AbortError','disconnect','/events/','cwd','SSE\x20connected','json','reconnectDelay','error_code','get_all_status','type','get_inbox','stringify','send_rejected','\x20network_id=','missing_task_id','not_tracked','task','\x20task_id=','\x20duration_ms=','emit','broadcast','status','autoConnect','heartbeatTimer','reply','getReader','running','send_failed','CommHub\x20rejected\x20task','task.send.delivered','networkId','task_id','mcp_http','heartbeatInterval','4568qtNjAb','tools/call',']\x20[commhub:','log','replace','now','disconnected','SSE\x20failed:\x20','catch','agent','error_message','resumeId','send_reply','CommHub\x20response\x20omitted\x20task_id','completed','connect','new_task','8ORRAxY','50625hRoRpP','5733980BfCneb','connectSSE','6068557NmDxko','split','ack_inbox','98533xdGkCk','sdk','parentTaskId'];a0_0x1625=function(){return _0x7f1db5;};return a0_0x1625();}function N(_0x4ed6c4){const _0x314b8f=a0_0x3415c1;return(_0x4ed6c4 instanceof Error?_0x4ed6c4[_0x314b8f(0x158)]:String(_0x4ed6c4??'unknown\x20error'))[_0x314b8f(0x117)](K,_0x314b8f(0x14d))[_0x314b8f(0x117)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x314b8f(0x16a)](0x0,0xf0);}function O(_0x548816,_0x4b7dff=process.env.ANET_TASK_TRACE_FORMAT===a0_0x3415c1(0x176)){const _0x1f43d1=a0_0x3415c1;if(_0x4b7dff)return JSON[_0x1f43d1(0x17c)](_0x548816);let _0x2f0494=L(_0x548816[_0x1f43d1(0x141)],_0x1f43d1(0x148)),_0x595190=L(_0x548816[_0x1f43d1(0x110)],_0x1f43d1(0x139)),_0xbe17b2=_0x548816[_0x1f43d1(0x178)]?'\x20error='+_0x548816['error_code']+':'+(_0x548816[_0x1f43d1(0x11d)]??''):'';return _0x1f43d1(0x15c)+_0x548816['status']+'\x20from='+L(_0x548816['from_alias'],_0x1f43d1(0x159))+_0x1f43d1(0x15a)+L(_0x548816['to_alias'],_0x1f43d1(0x159))+_0x1f43d1(0x182)+_0x595190+_0x1f43d1(0x145)+_0x2f0494+_0x1f43d1(0x17e)+L(_0x548816[_0x1f43d1(0x133)],_0x1f43d1(0x159))+_0x1f43d1(0x134)+_0x548816['transport']+_0x1f43d1(0x183)+_0x548816[_0x1f43d1(0x13b)]+'\x20lifecycle='+_0x548816['lifecycle_tracking']+_0xbe17b2;}function U(_0x134b19){const _0x47ac21=a0_0x3415c1;return{'event':{'sending':'task.send.start','delivered':_0x47ac21(0x10e),'failed':_0x47ac21(0x15e),'acked':'task.ack','started':_0x47ac21(0x161),'replied':_0x47ac21(0x162),'expired':'task.expired'}[_0x134b19[_0x47ac21(0x106)]],..._0x134b19};}function j(_0x257de2){const _0x1549ee=a0_0x3415c1;let _0x588cc1=_0x257de2?.[_0x1549ee(0x110)]||_0x257de2?.['message_id']||_0x257de2?.['id'];if(_0x588cc1)return String(_0x588cc1);let _0x5080ec=_0x257de2?.[_0x1549ee(0x153)]?.[0x0]?.[_0x1549ee(0x15b)];if(typeof _0x5080ec!==_0x1549ee(0x12f))return null;try{let _0x3c389a=JSON['parse'](_0x5080ec);return _0x3c389a?.['task_id']||_0x3c389a?.['message_id']||_0x3c389a?.['id']||null;}catch{return null;}}async function X(_0x2b91c7,_0xac330a){const _0x41bb56=a0_0x3415c1;let _0x5bac87=_0xac330a[_0x41bb56(0x118)]??Date[_0x41bb56(0x118)],_0x2583ee=_0x5bac87(),_0xeb2e13=(_0x43675e,_0x5405df,_0xed17a7,_0x4b0dc1)=>{const _0x4138dc=_0x41bb56;_0xac330a['log'](O(U({'from_alias':_0x2b91c7[_0x4138dc(0x16c)],'to_alias':_0x2b91c7['toAlias'],'task_id':_0x5405df,'parent_task_id':_0x2b91c7[_0x4138dc(0x12d)],'network_id':_0x2b91c7[_0x4138dc(0x10f)],'transport':_0x2b91c7[_0x4138dc(0x167)],'status':_0x43675e,'duration_ms':_0x5bac87()-_0x2583ee,'lifecycle_tracking':_0x2b91c7[_0x4138dc(0x164)],..._0xed17a7!==void 0x0?{'error_code':_0x4b0dc1||_0x4138dc(0x10c),'error_message':N(_0xed17a7)}:{}})));};_0xeb2e13(_0x41bb56(0x144),null);try{let _0x279433=await _0xac330a['send'](),_0x10b4aa=j(_0x279433);if(_0x10b4aa)_0xeb2e13('delivered',_0x10b4aa);else{if(_0x279433?.['ok']===!0x1||_0x279433?.[_0x41bb56(0x13e)])_0xeb2e13(_0x41bb56(0x147),_0x10b4aa,_0x279433?.[_0x41bb56(0x13e)]||_0x41bb56(0x10d),_0x41bb56(0x17d));else _0xeb2e13(_0x41bb56(0x147),null,_0x41bb56(0x120),_0x41bb56(0x17f));}return _0x279433;}catch(_0x11f909){throw _0xeb2e13(_0x41bb56(0x147),null,_0x11f909,_0x41bb56(0x10c)),_0x11f909;}}async function Y(_0x592474,_0x2b1d34){const _0x5e7141=a0_0x3415c1;return X({'fromAlias':_0x592474[_0x5e7141(0x16c)],'toAlias':_0x592474[_0x5e7141(0x138)],'parentTaskId':_0x592474[_0x5e7141(0x12d)]||null,'networkId':_0x592474[_0x5e7141(0x10f)]||null,'transport':_0x5e7141(0x111),'lifecycleTracking':_0x5e7141(0x180)},_0x2b1d34);}class $ extends a0_0x15c96e{[a0_0x3415c1(0x143)];[a0_0x3415c1(0x138)];[a0_0x3415c1(0x15d)];[a0_0x3415c1(0x11c)];['resumeId'];[a0_0x3415c1(0x112)];[a0_0x3415c1(0x177)];[a0_0x3415c1(0x108)];[a0_0x3415c1(0x165)];[a0_0x3415c1(0x10b)]=!0x1;constructor(_0x2e32d){const _0x287463=a0_0x3415c1;super();if(this['url']=_0x2e32d[_0x287463(0x143)]['replace'](/\/$/,''),this[_0x287463(0x138)]=_0x2e32d[_0x287463(0x138)],this['token']=_0x2e32d[_0x287463(0x15d)],this['agent']=_0x2e32d[_0x287463(0x11c)]||_0x287463(0x12c),this[_0x287463(0x11e)]=_0x287463(0x16b)+_0x2e32d[_0x287463(0x138)]+'-'+Date[_0x287463(0x118)]()[_0x287463(0x131)](0x24),this[_0x287463(0x112)]=_0x2e32d['heartbeatInterval']??0x2bf20,this[_0x287463(0x177)]=_0x2e32d[_0x287463(0x177)]??0xbb8,_0x2e32d[_0x287463(0x107)]!==!0x1)this[_0x287463(0x122)]();}['log'](_0x4d1faf){const _0x40e791=a0_0x3415c1;console[_0x40e791(0x116)]('['+new Date()['toTimeString']()[_0x40e791(0x16a)](0x0,0x8)+_0x40e791(0x115)+this[_0x40e791(0x138)]+']\x20'+_0x4d1faf);}async[a0_0x3415c1(0x142)](_0x17d49e,_0x552ee4){const _0x4284b9=a0_0x3415c1;let _0x3e387f={'Content-Type':'application/json','Accept':'application/json,\x20text/event-stream'};if(this[_0x4284b9(0x15d)])_0x3e387f[_0x4284b9(0x150)]=_0x4284b9(0x132)+this[_0x4284b9(0x15d)];let _0x552d20=await(await fetch(this['url']+_0x4284b9(0x16f),{'method':_0x4284b9(0x14c),'headers':_0x3e387f,'body':JSON[_0x4284b9(0x17c)]({'jsonrpc':_0x4284b9(0x152),'id':Date[_0x4284b9(0x118)](),'method':_0x4284b9(0x114),'params':{'name':_0x17d49e,'arguments':_0x552ee4}})}))[_0x4284b9(0x15b)](),_0x4ee426=_0x552d20['match'](/data: (.+)/),_0x5303e9=_0x4ee426?JSON[_0x4284b9(0x137)](_0x4ee426[0x1]):JSON['parse'](_0x552d20),_0x32028c=_0x5303e9?.[_0x4284b9(0x163)]?.['content']?.[0x0]?.[_0x4284b9(0x15b)];return _0x32028c?JSON['parse'](_0x32028c):_0x5303e9;}async[a0_0x3415c1(0x122)](){const _0x2f7895=a0_0x3415c1;if(this[_0x2f7895(0x10b)])return;this[_0x2f7895(0x10b)]=!0x0,await this['status']('idle'),this[_0x2f7895(0x116)]('registered'),this[_0x2f7895(0x108)]=setInterval(()=>{const _0x982e1f=_0x2f7895;this[_0x982e1f(0x106)](_0x982e1f(0x135))[_0x982e1f(0x11b)](_0x355297=>this[_0x982e1f(0x116)](_0x982e1f(0x140)+_0x355297[_0x982e1f(0x158)]));},this[_0x2f7895(0x112)]),this[_0x2f7895(0x127)]();}async[a0_0x3415c1(0x172)](){const _0x365146=a0_0x3415c1;if(this[_0x365146(0x10b)]=!0x1,this[_0x365146(0x165)]?.[_0x365146(0x160)](),this[_0x365146(0x108)])clearInterval(this[_0x365146(0x108)]);await this[_0x365146(0x106)](_0x365146(0x146))[_0x365146(0x11b)](()=>{}),this[_0x365146(0x116)](_0x365146(0x119));}async[a0_0x3415c1(0x13c)](_0x4e6cc9,_0x18e675,_0x312b67=a0_0x3415c1(0x12e)){const _0x363385=a0_0x3415c1;return Y({'alias':_0x4e6cc9,'fromAlias':this[_0x363385(0x138)]},{'log':_0x27688d=>console[_0x363385(0x116)](_0x27688d),'send':()=>this[_0x363385(0x142)](_0x363385(0x155),{'alias':_0x4e6cc9,'task':_0x18e675,'priority':_0x312b67,'from_session':this[_0x363385(0x138)]})});}async[a0_0x3415c1(0x158)](_0x18472b,_0x152927){const _0x449931=a0_0x3415c1;return this[_0x449931(0x142)](_0x449931(0x151),{'alias':_0x18472b,'message':_0x152927,'from_session':this[_0x449931(0x138)]});}async[a0_0x3415c1(0x109)](_0x5edfb6,_0x3232bc,_0x126880=a0_0x3415c1(0x121)){const _0x5171ac=a0_0x3415c1;return this[_0x5171ac(0x142)](_0x5171ac(0x11f),{'in_reply_to':_0x5edfb6,'text':_0x3232bc,'status':_0x126880});}async['status'](_0x543443,_0x350243){const _0x5d3b2e=a0_0x3415c1;return this[_0x5d3b2e(0x142)]('report_status',{'resume_id':this[_0x5d3b2e(0x11e)],'alias':this[_0x5d3b2e(0x138)],'status':_0x543443,'server':a0_0x596ed3(),'hostname':a0_0x596ed3(),'agent':this[_0x5d3b2e(0x11c)],'project_dir':process[_0x5d3b2e(0x174)](),..._0x350243});}async['getAllStatus'](){const _0x2dce98=a0_0x3415c1;return this[_0x2dce98(0x142)](_0x2dce98(0x179),{});}async[a0_0x3415c1(0x185)](_0x5d2e25,_0x4c3d48){const _0x24e23d=a0_0x3415c1;return this['call']('broadcast',{'message':_0x5d2e25,'filter_server':_0x4c3d48?.['server'],'filter_status':_0x4c3d48?.[_0x24e23d(0x106)]});}async['connectSSE'](){const _0x231027=a0_0x3415c1;let _0x549ca1=encodeURIComponent(this[_0x231027(0x138)]),_0x3d9331=this[_0x231027(0x143)]+_0x231027(0x173)+_0x549ca1,_0x2ea151=this[_0x231027(0x177)];while(this['running']){try{this['sseAbort']=new AbortController();let _0xd5e2bb={'Accept':_0x231027(0x14f)};if(this[_0x231027(0x15d)])_0xd5e2bb[_0x231027(0x150)]='Bearer\x20'+this['token'];let _0x5431e2=await fetch(_0x3d9331,{'headers':_0xd5e2bb,'signal':this[_0x231027(0x165)][_0x231027(0x166)]});if(!_0x5431e2['ok']||!_0x5431e2['body']){this[_0x231027(0x116)](_0x231027(0x11a)+_0x5431e2['status']),await this[_0x231027(0x15f)](_0x2ea151),_0x2ea151=Math[_0x231027(0x169)](_0x2ea151*1.5,0xea60);continue;}_0x2ea151=this[_0x231027(0x177)];let _0x5d2bf4=_0x5431e2[_0x231027(0x157)][_0x231027(0x10a)](),_0x392cd2=new TextDecoder(),_0x2bc049='';while(this[_0x231027(0x10b)]){let {done:_0x590d34,value:_0x2bffd6}=await _0x5d2bf4['read']();if(_0x590d34)break;_0x2bc049+=_0x392cd2['decode'](_0x2bffd6,{'stream':!0x0});let _0x9b6e0a=_0x2bc049[_0x231027(0x129)]('\x0a');_0x2bc049=_0x9b6e0a[_0x231027(0x130)]()||'';for(let _0x300520 of _0x9b6e0a){if(!_0x300520[_0x231027(0x149)](_0x231027(0x16d)))continue;try{let _0x2c5a98=JSON['parse'](_0x300520[_0x231027(0x16a)](0x6));if(_0x2c5a98[_0x231027(0x17a)]===_0x231027(0x154)){this[_0x231027(0x116)](_0x231027(0x175)),this[_0x231027(0x184)](_0x231027(0x154));continue;}if(_0x2c5a98[_0x231027(0x17a)]===_0x231027(0x123)||_0x2c5a98[_0x231027(0x17a)]===_0x231027(0x14b)||_0x2c5a98[_0x231027(0x17a)]==='broadcast')await this['processInbox']();}catch{}}}}catch(_0x43dd0a){if(_0x43dd0a[_0x231027(0x13a)]===_0x231027(0x171))break;this['emit']('error',_0x43dd0a),this[_0x231027(0x116)](_0x231027(0x156)+_0x43dd0a[_0x231027(0x158)]);}if(this[_0x231027(0x10b)])this[_0x231027(0x184)]('disconnected'),this[_0x231027(0x116)](_0x231027(0x136)+_0x2ea151/0x3e8+_0x231027(0x13f)),await this[_0x231027(0x15f)](_0x2ea151),_0x2ea151=Math[_0x231027(0x169)](_0x2ea151*1.5,0xea60);}}async['processInbox'](){const _0x1fb5d6=a0_0x3415c1;try{let _0x5be081=(await this['call'](_0x1fb5d6(0x17b),{'alias':this[_0x1fb5d6(0x138)],'limit':0xa}))?.['messages']||[];for(let _0x13dcdf of _0x5be081)await this['call'](_0x1fb5d6(0x12a),{'alias':this[_0x1fb5d6(0x138)],'message_id':_0x13dcdf['id']}),this[_0x1fb5d6(0x116)]('←\x20'+_0x13dcdf[_0x1fb5d6(0x168)]+':\x20'+_0x13dcdf[_0x1fb5d6(0x153)]['slice'](0x0,0x3c)),this[_0x1fb5d6(0x184)](_0x1fb5d6(0x181),_0x13dcdf),this[_0x1fb5d6(0x184)]('message',_0x13dcdf);}catch(_0x5da321){this[_0x1fb5d6(0x116)]('inbox\x20error:\x20'+_0x5da321['message']);}}['sleep'](_0x374048){return new Promise(_0x260d7a=>setTimeout(_0x260d7a,_0x374048));}}var F=$;export{F as default,$ as CommHub};
1
+ const a0_0x57d90b=a0_0x1906;(function(_0x1d2e0f,_0x61bc2b){const _0x3b1534=a0_0x1906,_0x43682c=_0x1d2e0f();while(!![]){try{const _0x31f158=parseInt(_0x3b1534(0xf8))/0x1+parseInt(_0x3b1534(0xd5))/0x2+parseInt(_0x3b1534(0x13c))/0x3+parseInt(_0x3b1534(0xd7))/0x4+-parseInt(_0x3b1534(0x13f))/0x5*(-parseInt(_0x3b1534(0xf0))/0x6)+parseInt(_0x3b1534(0xfe))/0x7+-parseInt(_0x3b1534(0xde))/0x8*(parseInt(_0x3b1534(0x144))/0x9);if(_0x31f158===_0x61bc2b)break;else _0x43682c['push'](_0x43682c['shift']());}catch(_0xf0257f){_0x43682c['push'](_0x43682c['shift']());}}}(a0_0x341e,0x52104));import{EventEmitter as a0_0x40270f}from'events';import{hostname as a0_0x3dcf72}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x28b52b,_0x5ee8a5)=>(_0x28b52b??_0x5ee8a5)[a0_0x57d90b(0xeb)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x557c5b){const _0x5542e4=a0_0x57d90b;return(_0x557c5b instanceof Error?_0x557c5b[_0x5542e4(0xf6)]:String(_0x557c5b??'unknown\x20error'))[_0x5542e4(0xeb)](K,_0x5542e4(0x110))[_0x5542e4(0xeb)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x5542e4(0x106)](0x0,0xf0);}function O(_0x18fdde,_0x3958c0=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x11660a=a0_0x57d90b;if(_0x3958c0)return JSON[_0x11660a(0x108)](_0x18fdde);let _0x523822=L(_0x18fdde[_0x11660a(0xd6)],_0x11660a(0x10e)),_0x546ccc=L(_0x18fdde['task_id'],'<pending>'),_0x54f9b2=_0x18fdde['error_code']?'\x20error='+_0x18fdde[_0x11660a(0x116)]+':'+(_0x18fdde[_0x11660a(0x11a)]??''):'';return _0x11660a(0x13b)+_0x18fdde[_0x11660a(0x10d)]+_0x11660a(0x101)+L(_0x18fdde[_0x11660a(0x139)],_0x11660a(0x135))+'\x20to='+L(_0x18fdde[_0x11660a(0xf3)],_0x11660a(0x135))+_0x11660a(0xee)+_0x546ccc+_0x11660a(0x118)+_0x523822+_0x11660a(0x102)+L(_0x18fdde[_0x11660a(0x105)],_0x11660a(0x135))+_0x11660a(0xdf)+_0x18fdde[_0x11660a(0xcb)]+_0x11660a(0x103)+_0x18fdde[_0x11660a(0x122)]+_0x11660a(0xc4)+_0x18fdde[_0x11660a(0xd8)]+_0x54f9b2;}function a0_0x1906(_0x51f174,_0x581058){_0x51f174=_0x51f174-0xc4;const _0x341e8e=a0_0x341e();let _0x1906c3=_0x341e8e[_0x51f174];return _0x1906c3;}function U(_0x3f69e0){const _0x593268=a0_0x57d90b;return{'event':{'sending':_0x593268(0x131),'delivered':_0x593268(0x129),'failed':_0x593268(0x136),'acked':'task.ack','started':_0x593268(0xe7),'replied':_0x593268(0x126),'expired':'task.expired'}[_0x3f69e0[_0x593268(0x10d)]],..._0x3f69e0};}function j(_0x4f0c07){const _0x5be96c=a0_0x57d90b;let _0x431f20=_0x4f0c07?.[_0x5be96c(0xe5)]||_0x4f0c07?.['message_id']||_0x4f0c07?.['id'];if(_0x431f20)return String(_0x431f20);let _0x41ca9a=_0x4f0c07?.['content']?.[0x0]?.[_0x5be96c(0x12e)];if(typeof _0x41ca9a!=='string')return null;try{let _0x34eae5=JSON['parse'](_0x41ca9a);return _0x34eae5?.[_0x5be96c(0xe5)]||_0x34eae5?.[_0x5be96c(0xec)]||_0x34eae5?.['id']||null;}catch{return null;}}async function X(_0x2d1c17,_0x406a18){const _0x472274=a0_0x57d90b;let _0x902de9=_0x406a18['now']??Date['now'],_0x573052=_0x902de9(),_0x150d80=(_0x5aba2f,_0xb8b4fb,_0xa2e06b,_0x2988ed)=>{const _0x4c5378=a0_0x1906;_0x406a18[_0x4c5378(0xf9)](O(U({'from_alias':_0x2d1c17['fromAlias'],'to_alias':_0x2d1c17[_0x4c5378(0x12f)],'task_id':_0xb8b4fb,'parent_task_id':_0x2d1c17[_0x4c5378(0xe2)],'network_id':_0x2d1c17[_0x4c5378(0xc9)],'transport':_0x2d1c17[_0x4c5378(0xcb)],'status':_0x5aba2f,'duration_ms':_0x902de9()-_0x573052,'lifecycle_tracking':_0x2d1c17[_0x4c5378(0x11b)],..._0xa2e06b!==void 0x0?{'error_code':_0x2988ed||'send_failed','error_message':N(_0xa2e06b)}:{}})));};_0x150d80(_0x472274(0xd2),null);try{let _0x5035a6=await _0x406a18[_0x472274(0x137)](),_0x38b81c=j(_0x5035a6);if(_0x38b81c)_0x150d80(_0x472274(0xfb),_0x38b81c);else{if(_0x5035a6?.['ok']===!0x1||_0x5035a6?.[_0x472274(0x124)])_0x150d80(_0x472274(0xe8),_0x38b81c,_0x5035a6?.[_0x472274(0x124)]||_0x472274(0xff),'send_rejected');else _0x150d80('failed',null,'CommHub\x20response\x20omitted\x20task_id',_0x472274(0xef));}return _0x5035a6;}catch(_0x953564){throw _0x150d80(_0x472274(0xe8),null,_0x953564,_0x472274(0x13e)),_0x953564;}}function a0_0x341e(){const _0x3a689c=['missing_task_id','1078206zPlscf','min','toTimeString','to_alias','split','get_all_status','message','completed','316500JjhzMA','log','result','delivered','autoConnect','task','110915bpTNNG','CommHub\x20rejected\x20task','read','\x20from=','\x20network_id=','\x20duration_ms=','parse','network_id','slice','SSE\x20failed:\x20','stringify','now','abort','SSE\x20connected','catch','status','<missing>','decode','[REDACTED]','reconnectDelay','connectSSE','heartbeatTimer','normal','not_tracked','error_code','new_message','\x20parent_task_id=','content','error_message','lifecycleTracking','send_message','reply','ack_inbox','Bearer\x20','getAllStatus','startsWith','duration_ms','sleep','error','cwd','task.replied','report_status','emit','task.send.delivered','sseAbort','2.0','alias','fromAlias','text','toAlias','sdk-','task.send.start','running','tools/call','resumeId','<unknown>','task.send.failed','send','application/json','from_alias','AbortError','[commhub:task]\x20','622344CQRjDE','idle','send_failed','5eEcQLK','disconnect','processInbox','send_task','registered','45wJdQKb','\x20lifecycle=','POST','agent','/mcp','type','networkId','connected','transport','Authorization','disconnected','inbox\x20error:\x20','body','sdk','broadcast','sending','/events/','call','415170NErSGf','parent_task_id','1309232oMlMiA','lifecycle_tracking','getReader','heartbeatInterval','signal','url','send_reply','1469208KfogdS','\x20transport=','data:\x20','name','parentTaskId','token','toString','task_id','connect','task.started','failed','s...','match','replace','message_id','pop','\x20task_id='];a0_0x341e=function(){return _0x3a689c;};return a0_0x341e();}async function Y(_0x37dd27,_0x111124){const _0x2954d4=a0_0x57d90b;return X({'fromAlias':_0x37dd27[_0x2954d4(0x12d)],'toAlias':_0x37dd27[_0x2954d4(0x12c)],'parentTaskId':_0x37dd27[_0x2954d4(0xe2)]||null,'networkId':_0x37dd27[_0x2954d4(0xc9)]||null,'transport':'mcp_http','lifecycleTracking':_0x2954d4(0x115)},_0x111124);}class $ extends a0_0x40270f{['url'];[a0_0x57d90b(0x12c)];['token'];[a0_0x57d90b(0xc6)];[a0_0x57d90b(0x134)];[a0_0x57d90b(0xda)];[a0_0x57d90b(0x111)];[a0_0x57d90b(0x113)];[a0_0x57d90b(0x12a)];['running']=!0x1;constructor(_0x40ce3d){const _0x170778=a0_0x57d90b;super();if(this['url']=_0x40ce3d[_0x170778(0xdc)]['replace'](/\/$/,''),this[_0x170778(0x12c)]=_0x40ce3d['alias'],this['token']=_0x40ce3d[_0x170778(0xe3)],this[_0x170778(0xc6)]=_0x40ce3d['agent']||_0x170778(0xd0),this[_0x170778(0x134)]=_0x170778(0x130)+_0x40ce3d[_0x170778(0x12c)]+'-'+Date[_0x170778(0x109)]()[_0x170778(0xe4)](0x24),this['heartbeatInterval']=_0x40ce3d['heartbeatInterval']??0x2bf20,this['reconnectDelay']=_0x40ce3d[_0x170778(0x111)]??0xbb8,_0x40ce3d[_0x170778(0xfc)]!==!0x1)this[_0x170778(0xe6)]();}[a0_0x57d90b(0xf9)](_0x42d405){const _0x392dff=a0_0x57d90b;console[_0x392dff(0xf9)]('['+new Date()[_0x392dff(0xf2)]()['slice'](0x0,0x8)+']\x20[commhub:'+this[_0x392dff(0x12c)]+']\x20'+_0x42d405);}async[a0_0x57d90b(0xd4)](_0x78b95c,_0x46cbe9){const _0x502c7a=a0_0x57d90b;let _0x46e7c8={'Content-Type':_0x502c7a(0x138),'Accept':'application/json,\x20text/event-stream'};if(this[_0x502c7a(0xe3)])_0x46e7c8[_0x502c7a(0xcc)]='Bearer\x20'+this['token'];let _0x24c4bf=await(await fetch(this[_0x502c7a(0xdc)]+_0x502c7a(0xc7),{'method':_0x502c7a(0xc5),'headers':_0x46e7c8,'body':JSON['stringify']({'jsonrpc':_0x502c7a(0x12b),'id':Date[_0x502c7a(0x109)](),'method':_0x502c7a(0x133),'params':{'name':_0x78b95c,'arguments':_0x46cbe9}})}))[_0x502c7a(0x12e)](),_0x581cc9=_0x24c4bf[_0x502c7a(0xea)](/data: (.+)/),_0x27a743=_0x581cc9?JSON[_0x502c7a(0x104)](_0x581cc9[0x1]):JSON[_0x502c7a(0x104)](_0x24c4bf),_0x9d79e6=_0x27a743?.[_0x502c7a(0xfa)]?.[_0x502c7a(0x119)]?.[0x0]?.[_0x502c7a(0x12e)];return _0x9d79e6?JSON[_0x502c7a(0x104)](_0x9d79e6):_0x27a743;}async[a0_0x57d90b(0xe6)](){const _0x500174=a0_0x57d90b;if(this['running'])return;this[_0x500174(0x132)]=!0x0,await this['status'](_0x500174(0x13d)),this['log'](_0x500174(0x143)),this['heartbeatTimer']=setInterval(()=>{const _0x17afd1=_0x500174;this[_0x17afd1(0x10d)](_0x17afd1(0x13d))[_0x17afd1(0x10c)](_0xc79820=>this['log']('heartbeat\x20failed:\x20'+_0xc79820['message']));},this[_0x500174(0xda)]),this[_0x500174(0x112)]();}async[a0_0x57d90b(0x140)](){const _0x37c617=a0_0x57d90b;if(this[_0x37c617(0x132)]=!0x1,this[_0x37c617(0x12a)]?.[_0x37c617(0x10a)](),this[_0x37c617(0x113)])clearInterval(this[_0x37c617(0x113)]);await this[_0x37c617(0x10d)]('offline')[_0x37c617(0x10c)](()=>{}),this['log']('disconnected');}async[a0_0x57d90b(0x137)](_0x318ca5,_0x3c1e87,_0x40aac6=a0_0x57d90b(0x114)){const _0x3e23be=a0_0x57d90b;return Y({'alias':_0x318ca5,'fromAlias':this['alias']},{'log':_0x2bf66b=>console[_0x3e23be(0xf9)](_0x2bf66b),'send':()=>this[_0x3e23be(0xd4)](_0x3e23be(0x142),{'alias':_0x318ca5,'task':_0x3c1e87,'priority':_0x40aac6,'from_session':this[_0x3e23be(0x12c)]})});}async[a0_0x57d90b(0xf6)](_0xc7a29b,_0x1c00f5){const _0x49d036=a0_0x57d90b;return this[_0x49d036(0xd4)](_0x49d036(0x11c),{'alias':_0xc7a29b,'message':_0x1c00f5,'from_session':this[_0x49d036(0x12c)]});}async[a0_0x57d90b(0x11d)](_0x28ed3a,_0x229ab9,_0x9f998a=a0_0x57d90b(0xf7)){const _0x5e83ba=a0_0x57d90b;return this[_0x5e83ba(0xd4)](_0x5e83ba(0xdd),{'in_reply_to':_0x28ed3a,'text':_0x229ab9,'status':_0x9f998a});}async[a0_0x57d90b(0x10d)](_0x5e1373,_0x276e27){const _0x1f28a=a0_0x57d90b;return this[_0x1f28a(0xd4)](_0x1f28a(0x127),{'resume_id':this[_0x1f28a(0x134)],'alias':this[_0x1f28a(0x12c)],'status':_0x5e1373,'server':a0_0x3dcf72(),'hostname':a0_0x3dcf72(),'agent':this['agent'],'project_dir':process[_0x1f28a(0x125)](),..._0x276e27});}async[a0_0x57d90b(0x120)](){const _0x3ea84b=a0_0x57d90b;return this[_0x3ea84b(0xd4)](_0x3ea84b(0xf5),{});}async[a0_0x57d90b(0xd1)](_0xfcc8dd,_0x1104ae){const _0x1cd7ee=a0_0x57d90b;return this[_0x1cd7ee(0xd4)](_0x1cd7ee(0xd1),{'message':_0xfcc8dd,'filter_server':_0x1104ae?.['server'],'filter_status':_0x1104ae?.[_0x1cd7ee(0x10d)]});}async['connectSSE'](){const _0x1e75af=a0_0x57d90b;let _0x47b018=encodeURIComponent(this[_0x1e75af(0x12c)]),_0x5c4a4e=this[_0x1e75af(0xdc)]+_0x1e75af(0xd3)+_0x47b018,_0x34c118=this[_0x1e75af(0x111)];while(this[_0x1e75af(0x132)]){try{this[_0x1e75af(0x12a)]=new AbortController();let _0x12763e={'Accept':'text/event-stream'};if(this[_0x1e75af(0xe3)])_0x12763e[_0x1e75af(0xcc)]=_0x1e75af(0x11f)+this[_0x1e75af(0xe3)];let _0x3d7780=await fetch(_0x5c4a4e,{'headers':_0x12763e,'signal':this[_0x1e75af(0x12a)][_0x1e75af(0xdb)]});if(!_0x3d7780['ok']||!_0x3d7780[_0x1e75af(0xcf)]){this['log'](_0x1e75af(0x107)+_0x3d7780[_0x1e75af(0x10d)]),await this[_0x1e75af(0x123)](_0x34c118),_0x34c118=Math[_0x1e75af(0xf1)](_0x34c118*1.5,0xea60);continue;}_0x34c118=this[_0x1e75af(0x111)];let _0x2ae488=_0x3d7780['body'][_0x1e75af(0xd9)](),_0x489c4f=new TextDecoder(),_0x716a91='';while(this[_0x1e75af(0x132)]){let {done:_0x191b66,value:_0x1916bd}=await _0x2ae488[_0x1e75af(0x100)]();if(_0x191b66)break;_0x716a91+=_0x489c4f[_0x1e75af(0x10f)](_0x1916bd,{'stream':!0x0});let _0x27ab77=_0x716a91[_0x1e75af(0xf4)]('\x0a');_0x716a91=_0x27ab77[_0x1e75af(0xed)]()||'';for(let _0x4454b2 of _0x27ab77){if(!_0x4454b2[_0x1e75af(0x121)](_0x1e75af(0xe0)))continue;try{let _0x4a9772=JSON[_0x1e75af(0x104)](_0x4454b2[_0x1e75af(0x106)](0x6));if(_0x4a9772[_0x1e75af(0xc8)]===_0x1e75af(0xca)){this[_0x1e75af(0xf9)](_0x1e75af(0x10b)),this[_0x1e75af(0x128)](_0x1e75af(0xca));continue;}if(_0x4a9772[_0x1e75af(0xc8)]==='new_task'||_0x4a9772[_0x1e75af(0xc8)]===_0x1e75af(0x117)||_0x4a9772[_0x1e75af(0xc8)]===_0x1e75af(0xd1))await this[_0x1e75af(0x141)]();}catch{}}}}catch(_0x108e69){if(_0x108e69[_0x1e75af(0xe1)]===_0x1e75af(0x13a))break;this[_0x1e75af(0x128)](_0x1e75af(0x124),_0x108e69),this[_0x1e75af(0xf9)]('SSE\x20error:\x20'+_0x108e69[_0x1e75af(0xf6)]);}if(this['running'])this[_0x1e75af(0x128)](_0x1e75af(0xcd)),this['log']('SSE\x20reconnecting\x20in\x20'+_0x34c118/0x3e8+_0x1e75af(0xe9)),await this[_0x1e75af(0x123)](_0x34c118),_0x34c118=Math['min'](_0x34c118*1.5,0xea60);}}async[a0_0x57d90b(0x141)](){const _0xeff226=a0_0x57d90b;try{let _0x3937b6=(await this[_0xeff226(0xd4)]('get_inbox',{'alias':this['alias'],'limit':0xa}))?.['messages']||[];for(let _0x37b34d of _0x3937b6)await this[_0xeff226(0xd4)](_0xeff226(0x11e),{'alias':this[_0xeff226(0x12c)],'message_id':_0x37b34d['id']}),this[_0xeff226(0xf9)]('←\x20'+_0x37b34d['from_session']+':\x20'+_0x37b34d[_0xeff226(0x119)][_0xeff226(0x106)](0x0,0x3c)),this['emit'](_0xeff226(0xfd),_0x37b34d),this[_0xeff226(0x128)]('message',_0x37b34d);}catch(_0x58aefb){this[_0xeff226(0xf9)](_0xeff226(0xce)+_0x58aefb[_0xeff226(0xf6)]);}}[a0_0x57d90b(0x123)](_0x15c03c){return new Promise(_0xad132b=>setTimeout(_0xad132b,_0x15c03c));}}var F=$;export{F as default,$ as CommHub};