@sleep2agi/agent-network 2.3.0-preview.249 → 2.3.0-preview.250

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_0x2ec609=a0_0x3533;(function(_0x42990b,_0x4c1cac){const _0x474c04=a0_0x3533,_0x21ac8a=_0x42990b();while(!![]){try{const _0x36601a=parseInt(_0x474c04(0x171))/0x1*(-parseInt(_0x474c04(0x17b))/0x2)+-parseInt(_0x474c04(0x18f))/0x3+-parseInt(_0x474c04(0x1c4))/0x4*(parseInt(_0x474c04(0x16c))/0x5)+-parseInt(_0x474c04(0x16f))/0x6*(parseInt(_0x474c04(0x191))/0x7)+-parseInt(_0x474c04(0x19b))/0x8*(parseInt(_0x474c04(0x15d))/0x9)+-parseInt(_0x474c04(0x1c5))/0xa*(-parseInt(_0x474c04(0x15f))/0xb)+-parseInt(_0x474c04(0x193))/0xc*(-parseInt(_0x474c04(0x15e))/0xd);if(_0x36601a===_0x4c1cac)break;else _0x21ac8a['push'](_0x21ac8a['shift']());}catch(_0x4c4dbe){_0x21ac8a['push'](_0x21ac8a['shift']());}}}(a0_0x2846,0xb7327));import{EventEmitter as a0_0x7d32ca}from'events';import{hostname as a0_0x1457cd}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x58526d,_0x60561c)=>(_0x58526d??_0x60561c)[a0_0x2ec609(0x175)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x2ec609(0x194)](0x0,0xf0);function N(_0x6f7bce){const _0x135ece=a0_0x2ec609;return(_0x6f7bce instanceof Error?_0x6f7bce[_0x135ece(0x1b2)]:String(_0x6f7bce??_0x135ece(0x16a)))[_0x135ece(0x175)](K,_0x135ece(0x19d))[_0x135ece(0x175)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x135ece(0x194)](0x0,0xf0);}function O(_0x12bf1b,_0x46ba3d=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0xbd8f48=a0_0x2ec609;if(_0x46ba3d)return JSON[_0xbd8f48(0x1b1)](_0x12bf1b);let _0x460353=L(_0x12bf1b[_0xbd8f48(0x196)],_0xbd8f48(0x1a7)),_0x1e65a7=L(_0x12bf1b[_0xbd8f48(0x1bc)],_0xbd8f48(0x169)),_0x3a658b=_0x12bf1b['error_code']?_0xbd8f48(0x1b3)+_0x12bf1b[_0xbd8f48(0x1b4)]+':'+(_0x12bf1b['error_message']??''):'';return'[commhub:task]\x20'+_0x12bf1b[_0xbd8f48(0x165)]+_0xbd8f48(0x162)+L(_0x12bf1b[_0xbd8f48(0x1d1)],_0xbd8f48(0x17d))+'\x20to='+L(_0x12bf1b[_0xbd8f48(0x176)],_0xbd8f48(0x17d))+_0xbd8f48(0x164)+_0x1e65a7+_0xbd8f48(0x190)+_0x460353+'\x20network_id='+L(_0x12bf1b[_0xbd8f48(0x17a)],_0xbd8f48(0x17d))+_0xbd8f48(0x1d4)+_0x12bf1b[_0xbd8f48(0x1a6)]+'\x20duration_ms='+_0x12bf1b[_0xbd8f48(0x189)]+_0xbd8f48(0x188)+_0x12bf1b[_0xbd8f48(0x19a)]+_0x3a658b;}function a0_0x3533(_0x5e2849,_0x4509a1){_0x5e2849=_0x5e2849-0x15d;const _0x28462c=a0_0x2846();let _0x353377=_0x28462c[_0x5e2849];return _0x353377;}function a0_0x2846(){const _0x49485f=['report_status','body','\x20lifecycle=','duration_ms','AbortError','inbox\x20error:\x20','/events/','error','getReader','1867203CrvSnA','\x20parent_task_id=','14RoLFII','toString','17895972UprLkV','slice','running','parent_task_id','reconnectDelay','connect','getAllStatus','lifecycle_tracking','296uJdAti','text/event-stream','[REDACTED]','connectSSE','missing_task_id','normal','task.ack','fromAlias','failed','idle','sseAbort','transport','<missing>','resumeId','agent','decode','abort','message_id','task.send.start','alias','POST','parse','stringify','message','\x20error=','error_code','disconnect','token','broadcast','sending','application/json,\x20text/event-stream','SSE\x20connected','type','task_id','split','lifecycleTracking','heartbeatInterval','content','SSE\x20failed:\x20','task.expired','task.replied','56rLTMiq','36620AkTXCC','pop','from_session','heartbeatTimer','new_message','catch','connected','send','get_inbox','Authorization','result','call','from_alias','name','/mcp','\x20transport=',']\x20[commhub:','new_task','not_tracked','get_all_status','completed','parentTaskId','Bearer\x20','toTimeString','url','send_failed','networkId','toAlias','processInbox','99603mwbkNv','39QMWMsL','913hHDMvm','sdk-','startsWith','\x20from=','cwd','\x20task_id=','status','SSE\x20reconnecting\x20in\x20','send_rejected','server','<pending>','unknown\x20error','heartbeat\x20failed:\x20','358580xUEXAN','SSE\x20error:\x20','text','3165384ihKjZR','task.send.failed','936532lvHRya','sleep','sdk','match','replace','to_alias','CommHub\x20rejected\x20task','min','log','network_id','2IHqJys','send_message','<unknown>','s...','messages','emit','task.started','2.0','send_reply','string','now'];a0_0x2846=function(){return _0x49485f;};return a0_0x2846();}function U(_0x51661e){const _0x24755e=a0_0x2ec609;return{'event':{'sending':_0x24755e(0x1ad),'delivered':'task.send.delivered','failed':_0x24755e(0x170),'acked':_0x24755e(0x1a1),'started':_0x24755e(0x181),'replied':_0x24755e(0x1c3),'expired':_0x24755e(0x1c2)}[_0x51661e[_0x24755e(0x165)]],..._0x51661e};}function j(_0x1947e5){const _0x215c1b=a0_0x2ec609;let _0x5b85cc=_0x1947e5?.[_0x215c1b(0x1bc)]||_0x1947e5?.[_0x215c1b(0x1ac)]||_0x1947e5?.['id'];if(_0x5b85cc)return String(_0x5b85cc);let _0xa67317=_0x1947e5?.[_0x215c1b(0x1c0)]?.[0x0]?.[_0x215c1b(0x16e)];if(typeof _0xa67317!==_0x215c1b(0x184))return null;try{let _0x3ed6ba=JSON[_0x215c1b(0x1b0)](_0xa67317);return _0x3ed6ba?.[_0x215c1b(0x1bc)]||_0x3ed6ba?.[_0x215c1b(0x1ac)]||_0x3ed6ba?.['id']||null;}catch{return null;}}async function X(_0x21b83d,_0x28541f){const _0x3dc579=a0_0x2ec609;let _0x8e4b01=_0x28541f[_0x3dc579(0x185)]??Date[_0x3dc579(0x185)],_0x47299a=_0x8e4b01(),_0x3561e6=(_0x2a92b3,_0x16db81,_0x4dff25,_0x5508f8)=>{const _0x2a13da=_0x3dc579;_0x28541f[_0x2a13da(0x179)](O(U({'from_alias':_0x21b83d[_0x2a13da(0x1a2)],'to_alias':_0x21b83d[_0x2a13da(0x1e0)],'task_id':_0x16db81,'parent_task_id':_0x21b83d[_0x2a13da(0x1da)],'network_id':_0x21b83d[_0x2a13da(0x1df)],'transport':_0x21b83d['transport'],'status':_0x2a92b3,'duration_ms':_0x8e4b01()-_0x47299a,'lifecycle_tracking':_0x21b83d[_0x2a13da(0x1be)],..._0x4dff25!==void 0x0?{'error_code':_0x5508f8||_0x2a13da(0x1de),'error_message':N(_0x4dff25)}:{}})));};_0x3561e6(_0x3dc579(0x1b8),null);try{let _0xfb7663=await _0x28541f[_0x3dc579(0x1cc)](),_0x4d3cf3=j(_0xfb7663);if(_0x4d3cf3)_0x3561e6('delivered',_0x4d3cf3);else{if(_0xfb7663?.['ok']===!0x1||_0xfb7663?.[_0x3dc579(0x18d)])_0x3561e6('failed',_0x4d3cf3,_0xfb7663?.[_0x3dc579(0x18d)]||_0x3dc579(0x177),_0x3dc579(0x167));else _0x3561e6(_0x3dc579(0x1a3),null,'CommHub\x20response\x20omitted\x20task_id',_0x3dc579(0x19f));}return _0xfb7663;}catch(_0xb940a6){throw _0x3561e6(_0x3dc579(0x1a3),null,_0xb940a6,_0x3dc579(0x1de)),_0xb940a6;}}async function Y(_0x2326b2,_0x28b8a4){const _0x48251b=a0_0x2ec609;return X({'fromAlias':_0x2326b2[_0x48251b(0x1a2)],'toAlias':_0x2326b2[_0x48251b(0x1ae)],'parentTaskId':_0x2326b2[_0x48251b(0x1da)]||null,'networkId':_0x2326b2[_0x48251b(0x1df)]||null,'transport':'mcp_http','lifecycleTracking':_0x48251b(0x1d7)},_0x28b8a4);}class $ extends a0_0x7d32ca{['url'];['alias'];[a0_0x2ec609(0x1b6)];['agent'];['resumeId'];[a0_0x2ec609(0x1bf)];[a0_0x2ec609(0x197)];[a0_0x2ec609(0x1c8)];['sseAbort'];[a0_0x2ec609(0x195)]=!0x1;constructor(_0x1962cc){const _0x7574f6=a0_0x2ec609;super();if(this[_0x7574f6(0x1dd)]=_0x1962cc[_0x7574f6(0x1dd)]['replace'](/\/$/,''),this[_0x7574f6(0x1ae)]=_0x1962cc[_0x7574f6(0x1ae)],this[_0x7574f6(0x1b6)]=_0x1962cc[_0x7574f6(0x1b6)],this['agent']=_0x1962cc[_0x7574f6(0x1a9)]||_0x7574f6(0x173),this['resumeId']=_0x7574f6(0x160)+_0x1962cc['alias']+'-'+Date[_0x7574f6(0x185)]()[_0x7574f6(0x192)](0x24),this[_0x7574f6(0x1bf)]=_0x1962cc['heartbeatInterval']??0x2bf20,this[_0x7574f6(0x197)]=_0x1962cc[_0x7574f6(0x197)]??0xbb8,_0x1962cc['autoConnect']!==!0x1)this['connect']();}[a0_0x2ec609(0x179)](_0x1690c2){const _0x44071a=a0_0x2ec609;console['log']('['+new Date()[_0x44071a(0x1dc)]()['slice'](0x0,0x8)+_0x44071a(0x1d5)+this[_0x44071a(0x1ae)]+']\x20'+_0x1690c2);}async['call'](_0x29db23,_0x35ce29){const _0x2086e5=a0_0x2ec609;let _0x274931={'Content-Type':'application/json','Accept':_0x2086e5(0x1b9)};if(this['token'])_0x274931['Authorization']=_0x2086e5(0x1db)+this[_0x2086e5(0x1b6)];let _0x293fe6=await(await fetch(this[_0x2086e5(0x1dd)]+_0x2086e5(0x1d3),{'method':_0x2086e5(0x1af),'headers':_0x274931,'body':JSON['stringify']({'jsonrpc':_0x2086e5(0x182),'id':Date[_0x2086e5(0x185)](),'method':'tools/call','params':{'name':_0x29db23,'arguments':_0x35ce29}})}))[_0x2086e5(0x16e)](),_0x2b21d3=_0x293fe6[_0x2086e5(0x174)](/data: (.+)/),_0x516809=_0x2b21d3?JSON[_0x2086e5(0x1b0)](_0x2b21d3[0x1]):JSON[_0x2086e5(0x1b0)](_0x293fe6),_0x4a010d=_0x516809?.[_0x2086e5(0x1cf)]?.[_0x2086e5(0x1c0)]?.[0x0]?.[_0x2086e5(0x16e)];return _0x4a010d?JSON['parse'](_0x4a010d):_0x516809;}async[a0_0x2ec609(0x198)](){const _0x4782a3=a0_0x2ec609;if(this[_0x4782a3(0x195)])return;this[_0x4782a3(0x195)]=!0x0,await this[_0x4782a3(0x165)]('idle'),this['log']('registered'),this[_0x4782a3(0x1c8)]=setInterval(()=>{const _0x423ef6=_0x4782a3;this[_0x423ef6(0x165)](_0x423ef6(0x1a4))[_0x423ef6(0x1ca)](_0x3641d0=>this[_0x423ef6(0x179)](_0x423ef6(0x16b)+_0x3641d0[_0x423ef6(0x1b2)]));},this['heartbeatInterval']),this[_0x4782a3(0x19e)]();}async[a0_0x2ec609(0x1b5)](){const _0x1c09f0=a0_0x2ec609;if(this['running']=!0x1,this[_0x1c09f0(0x1a5)]?.[_0x1c09f0(0x1ab)](),this['heartbeatTimer'])clearInterval(this['heartbeatTimer']);await this[_0x1c09f0(0x165)]('offline')[_0x1c09f0(0x1ca)](()=>{}),this[_0x1c09f0(0x179)]('disconnected');}async[a0_0x2ec609(0x1cc)](_0x1a19fa,_0x75e7ad,_0x1021c2=a0_0x2ec609(0x1a0)){const _0x3d6ca6=a0_0x2ec609;return Y({'alias':_0x1a19fa,'fromAlias':this['alias']},{'log':_0x2687d4=>console['log'](_0x2687d4),'send':()=>this[_0x3d6ca6(0x1d0)]('send_task',{'alias':_0x1a19fa,'task':_0x75e7ad,'priority':_0x1021c2,'from_session':this[_0x3d6ca6(0x1ae)]})});}async[a0_0x2ec609(0x1b2)](_0x10e725,_0xcfb502){const _0x353810=a0_0x2ec609;return this[_0x353810(0x1d0)](_0x353810(0x17c),{'alias':_0x10e725,'message':_0xcfb502,'from_session':this[_0x353810(0x1ae)]});}async['reply'](_0x4d1e93,_0x2fc79c,_0x3d548e=a0_0x2ec609(0x1d9)){const _0x24e1d7=a0_0x2ec609;return this[_0x24e1d7(0x1d0)](_0x24e1d7(0x183),{'in_reply_to':_0x4d1e93,'text':_0x2fc79c,'status':_0x3d548e});}async[a0_0x2ec609(0x165)](_0x38faa8,_0x2b01f3){const _0x4ab9b4=a0_0x2ec609;return this[_0x4ab9b4(0x1d0)](_0x4ab9b4(0x186),{'resume_id':this[_0x4ab9b4(0x1a8)],'alias':this[_0x4ab9b4(0x1ae)],'status':_0x38faa8,'server':a0_0x1457cd(),'hostname':a0_0x1457cd(),'agent':this['agent'],'project_dir':process[_0x4ab9b4(0x163)](),..._0x2b01f3});}async[a0_0x2ec609(0x199)](){const _0x14fd40=a0_0x2ec609;return this[_0x14fd40(0x1d0)](_0x14fd40(0x1d8),{});}async[a0_0x2ec609(0x1b7)](_0x5a6b22,_0x1a8ba9){const _0x2356be=a0_0x2ec609;return this[_0x2356be(0x1d0)](_0x2356be(0x1b7),{'message':_0x5a6b22,'filter_server':_0x1a8ba9?.[_0x2356be(0x168)],'filter_status':_0x1a8ba9?.[_0x2356be(0x165)]});}async[a0_0x2ec609(0x19e)](){const _0x582433=a0_0x2ec609;let _0x494fc1=encodeURIComponent(this[_0x582433(0x1ae)]),_0x3b9d61=this[_0x582433(0x1dd)]+_0x582433(0x18c)+_0x494fc1,_0x175ba7=this[_0x582433(0x197)];while(this[_0x582433(0x195)]){try{this['sseAbort']=new AbortController();let _0x5b3c60={'Accept':_0x582433(0x19c)};if(this[_0x582433(0x1b6)])_0x5b3c60[_0x582433(0x1ce)]=_0x582433(0x1db)+this[_0x582433(0x1b6)];let _0xfad4a8=await fetch(_0x3b9d61,{'headers':_0x5b3c60,'signal':this[_0x582433(0x1a5)]['signal']});if(!_0xfad4a8['ok']||!_0xfad4a8[_0x582433(0x187)]){this[_0x582433(0x179)](_0x582433(0x1c1)+_0xfad4a8[_0x582433(0x165)]),await this[_0x582433(0x172)](_0x175ba7),_0x175ba7=Math[_0x582433(0x178)](_0x175ba7*1.5,0xea60);continue;}_0x175ba7=this[_0x582433(0x197)];let _0x57de8f=_0xfad4a8[_0x582433(0x187)][_0x582433(0x18e)](),_0x150436=new TextDecoder(),_0x381b1f='';while(this[_0x582433(0x195)]){let {done:_0x3643db,value:_0x1a9a98}=await _0x57de8f['read']();if(_0x3643db)break;_0x381b1f+=_0x150436[_0x582433(0x1aa)](_0x1a9a98,{'stream':!0x0});let _0x46ac26=_0x381b1f[_0x582433(0x1bd)]('\x0a');_0x381b1f=_0x46ac26[_0x582433(0x1c6)]()||'';for(let _0x45f28b of _0x46ac26){if(!_0x45f28b[_0x582433(0x161)]('data:\x20'))continue;try{let _0x2cdb80=JSON['parse'](_0x45f28b['slice'](0x6));if(_0x2cdb80[_0x582433(0x1bb)]===_0x582433(0x1cb)){this[_0x582433(0x179)](_0x582433(0x1ba)),this[_0x582433(0x180)](_0x582433(0x1cb));continue;}if(_0x2cdb80['type']===_0x582433(0x1d6)||_0x2cdb80[_0x582433(0x1bb)]===_0x582433(0x1c9)||_0x2cdb80[_0x582433(0x1bb)]===_0x582433(0x1b7))await this[_0x582433(0x1e1)]();}catch{}}}}catch(_0x65a4a9){if(_0x65a4a9[_0x582433(0x1d2)]===_0x582433(0x18a))break;this[_0x582433(0x180)](_0x582433(0x18d),_0x65a4a9),this[_0x582433(0x179)](_0x582433(0x16d)+_0x65a4a9[_0x582433(0x1b2)]);}if(this[_0x582433(0x195)])this[_0x582433(0x180)]('disconnected'),this[_0x582433(0x179)](_0x582433(0x166)+_0x175ba7/0x3e8+_0x582433(0x17e)),await this[_0x582433(0x172)](_0x175ba7),_0x175ba7=Math[_0x582433(0x178)](_0x175ba7*1.5,0xea60);}}async[a0_0x2ec609(0x1e1)](){const _0xb4938d=a0_0x2ec609;try{let _0x33f64f=(await this[_0xb4938d(0x1d0)](_0xb4938d(0x1cd),{'alias':this['alias'],'limit':0xa}))?.[_0xb4938d(0x17f)]||[];for(let _0x53e870 of _0x33f64f)await this['call']('ack_inbox',{'alias':this[_0xb4938d(0x1ae)],'message_id':_0x53e870['id']}),this[_0xb4938d(0x179)]('←\x20'+_0x53e870[_0xb4938d(0x1c7)]+':\x20'+_0x53e870[_0xb4938d(0x1c0)][_0xb4938d(0x194)](0x0,0x3c)),this['emit']('task',_0x53e870),this['emit'](_0xb4938d(0x1b2),_0x53e870);}catch(_0x36bb74){this[_0xb4938d(0x179)](_0xb4938d(0x18b)+_0x36bb74[_0xb4938d(0x1b2)]);}}[a0_0x2ec609(0x172)](_0x42f2f1){return new Promise(_0x501427=>setTimeout(_0x501427,_0x42f2f1));}}var F=$;export{F as default,$ as CommHub};
1
+ const a0_0x51fda6=a0_0x1dc2;(function(_0x2956bc,_0x2eead0){const _0x30cb86=a0_0x1dc2,_0x5718c8=_0x2956bc();while(!![]){try{const _0x15bd14=-parseInt(_0x30cb86(0x208))/0x1*(parseInt(_0x30cb86(0x20c))/0x2)+parseInt(_0x30cb86(0x206))/0x3+parseInt(_0x30cb86(0x200))/0x4+parseInt(_0x30cb86(0x21f))/0x5*(-parseInt(_0x30cb86(0x264))/0x6)+parseInt(_0x30cb86(0x25a))/0x7*(parseInt(_0x30cb86(0x25d))/0x8)+-parseInt(_0x30cb86(0x22d))/0x9*(-parseInt(_0x30cb86(0x1ec))/0xa)+parseInt(_0x30cb86(0x1f2))/0xb*(-parseInt(_0x30cb86(0x205))/0xc);if(_0x15bd14===_0x2eead0)break;else _0x5718c8['push'](_0x5718c8['shift']());}catch(_0x35a923){_0x5718c8['push'](_0x5718c8['shift']());}}}(a0_0x2872,0xbf476));function a0_0x1dc2(_0x2a03d3,_0x56aa28){_0x2a03d3=_0x2a03d3-0x1e2;const _0x2872c2=a0_0x2872();let _0x1dc2b9=_0x2872c2[_0x2a03d3];return _0x1dc2b9;}import{EventEmitter as a0_0x74de}from'events';import{hostname as a0_0x478508}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x3ff71b,_0x3215be)=>(_0x3ff71b??_0x3215be)[a0_0x51fda6(0x1e9)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x51fda6(0x262)](0x0,0xf0);function N(_0xc4a918){const _0x122d4b=a0_0x51fda6;return(_0xc4a918 instanceof Error?_0xc4a918[_0x122d4b(0x1e5)]:String(_0xc4a918??_0x122d4b(0x243)))[_0x122d4b(0x1e9)](K,_0x122d4b(0x219))[_0x122d4b(0x1e9)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x122d4b(0x262)](0x0,0xf0);}function O(_0x2cadc8,_0x102a42=process.env.ANET_TASK_TRACE_FORMAT===a0_0x51fda6(0x230)){const _0x31536b=a0_0x51fda6;if(_0x102a42)return JSON['stringify'](_0x2cadc8);let _0x3a880b=L(_0x2cadc8[_0x31536b(0x1fc)],'<missing>'),_0x24ee0b=L(_0x2cadc8[_0x31536b(0x228)],_0x31536b(0x21b)),_0x56f05c=_0x2cadc8['error_code']?_0x31536b(0x256)+_0x2cadc8[_0x31536b(0x21c)]+':'+(_0x2cadc8[_0x31536b(0x23f)]??''):'';return _0x31536b(0x250)+_0x2cadc8[_0x31536b(0x266)]+_0x31536b(0x239)+L(_0x2cadc8[_0x31536b(0x1f7)],_0x31536b(0x222))+_0x31536b(0x1e3)+L(_0x2cadc8[_0x31536b(0x209)],_0x31536b(0x222))+_0x31536b(0x259)+_0x24ee0b+_0x31536b(0x210)+_0x3a880b+'\x20network_id='+L(_0x2cadc8[_0x31536b(0x24d)],_0x31536b(0x222))+_0x31536b(0x1f8)+_0x2cadc8[_0x31536b(0x20f)]+'\x20duration_ms='+_0x2cadc8[_0x31536b(0x215)]+_0x31536b(0x1ee)+_0x2cadc8['lifecycle_tracking']+_0x56f05c;}function U(_0x4929b4){const _0xe030ae=a0_0x51fda6;return{'event':{'sending':_0xe030ae(0x253),'delivered':_0xe030ae(0x25b),'failed':'task.send.failed','acked':_0xe030ae(0x263),'started':_0xe030ae(0x254),'replied':_0xe030ae(0x211),'expired':_0xe030ae(0x20a)}[_0x4929b4[_0xe030ae(0x266)]],..._0x4929b4};}function j(_0x338e1f){const _0x2d0605=a0_0x51fda6;let _0xf1c6d8=_0x338e1f?.['task_id']||_0x338e1f?.[_0x2d0605(0x22b)]||_0x338e1f?.['id'];if(_0xf1c6d8)return String(_0xf1c6d8);let _0x911ccf=_0x338e1f?.[_0x2d0605(0x1f6)]?.[0x0]?.[_0x2d0605(0x1e7)];if(typeof _0x911ccf!==_0x2d0605(0x1fa))return null;try{let _0x38f278=JSON[_0x2d0605(0x237)](_0x911ccf);return _0x38f278?.[_0x2d0605(0x228)]||_0x38f278?.[_0x2d0605(0x22b)]||_0x38f278?.['id']||null;}catch{return null;}}async function X(_0x5e4c19,_0x41f924){const _0x1d8fb8=a0_0x51fda6;let _0x3a706=_0x41f924[_0x1d8fb8(0x1f0)]??Date[_0x1d8fb8(0x1f0)],_0x437ce0=_0x3a706(),_0x1818c6=(_0x35b92e,_0x4bec13,_0x35cf2c,_0x9bf34c)=>{const _0x3f17f7=_0x1d8fb8;_0x41f924[_0x3f17f7(0x1f1)](O(U({'from_alias':_0x5e4c19[_0x3f17f7(0x23b)],'to_alias':_0x5e4c19[_0x3f17f7(0x242)],'task_id':_0x4bec13,'parent_task_id':_0x5e4c19['parentTaskId'],'network_id':_0x5e4c19[_0x3f17f7(0x22a)],'transport':_0x5e4c19[_0x3f17f7(0x20f)],'status':_0x35b92e,'duration_ms':_0x3a706()-_0x437ce0,'lifecycle_tracking':_0x5e4c19[_0x3f17f7(0x1ea)],..._0x35cf2c!==void 0x0?{'error_code':_0x9bf34c||_0x3f17f7(0x241),'error_message':N(_0x35cf2c)}:{}})));};_0x1818c6('sending',null);try{let _0x2e49cd=await _0x41f924[_0x1d8fb8(0x25e)](),_0x2bd30f=j(_0x2e49cd);if(_0x2bd30f)_0x1818c6(_0x1d8fb8(0x23a),_0x2bd30f);else{if(_0x2e49cd?.['ok']===!0x1||_0x2e49cd?.[_0x1d8fb8(0x224)])_0x1818c6(_0x1d8fb8(0x217),_0x2bd30f,_0x2e49cd?.[_0x1d8fb8(0x224)]||'CommHub\x20rejected\x20task',_0x1d8fb8(0x258));else _0x1818c6(_0x1d8fb8(0x217),null,_0x1d8fb8(0x1fe),_0x1d8fb8(0x24a));}return _0x2e49cd;}catch(_0x3c5eab){throw _0x1818c6('failed',null,_0x3c5eab,_0x1d8fb8(0x241)),_0x3c5eab;}}function a0_0x2872(){const _0x21891a=['message_id','send_reply','4824396UYwGVb','Bearer\x20','pop','json','s...','reconnectDelay','Authorization','SSE\x20error:\x20','heartbeatTimer','inbox\x20error:\x20','parse','abort','\x20from=','delivered','fromAlias','body','not_tracked','cwd','error_message','/mcp','send_failed','toAlias','unknown\x20error','agent','new_task','tools/call','min','token','completed','missing_task_id','application/json,\x20text/event-stream','split','network_id','2.0','match','[commhub:task]\x20','read','idle','task.send.start','task.started','send_message','\x20error=','POST','send_rejected','\x20task_id=','7NdlEdR','task.send.delivered','heartbeatInterval','4241928aAsMJJ','send','running','name','/events/','slice','task.ack','84Menghg','registered','status','disconnected','\x20to=','data:\x20','message','autoConnect','text','parentTaskId','replace','lifecycleTracking','stringify','20ddjFzz','application/json','\x20lifecycle=','SSE\x20failed:\x20','now','log','1281324PpvpyX','call','get_inbox','connectSSE','content','from_alias','\x20transport=','text/event-stream','string','resumeId','parent_task_id','report_status','CommHub\x20response\x20omitted\x20task_id','processInbox','4301508NUists','broadcast','new_message','startsWith','ack_inbox','108AuZdZi','194736yLXIWN','toString','7cCLakA','to_alias','task.expired','type','23948WkPWqE','get_all_status','disconnect','transport','\x20parent_task_id=','task.replied','result','SSE\x20reconnecting\x20in\x20','catch','duration_ms','url','failed','send_task','[REDACTED]','sdk-','<pending>','error_code','alias','mcp_http','295345MrQXrO','AbortError','connect','<unknown>','sseAbort','error','messages','server','sleep','task_id','emit','networkId'];a0_0x2872=function(){return _0x21891a;};return a0_0x2872();}async function Y(_0x2b9a66,_0x2fd0c9){const _0x31cf13=a0_0x51fda6;return X({'fromAlias':_0x2b9a66['fromAlias'],'toAlias':_0x2b9a66[_0x31cf13(0x21d)],'parentTaskId':_0x2b9a66[_0x31cf13(0x1e8)]||null,'networkId':_0x2b9a66[_0x31cf13(0x22a)]||null,'transport':_0x31cf13(0x21e),'lifecycleTracking':_0x31cf13(0x23d)},_0x2fd0c9);}class $ extends a0_0x74de{[a0_0x51fda6(0x216)];[a0_0x51fda6(0x21d)];[a0_0x51fda6(0x248)];['agent'];[a0_0x51fda6(0x1fb)];[a0_0x51fda6(0x25c)];[a0_0x51fda6(0x232)];[a0_0x51fda6(0x235)];[a0_0x51fda6(0x223)];[a0_0x51fda6(0x25f)]=!0x1;constructor(_0x2abf01){const _0x1d4a92=a0_0x51fda6;super();if(this[_0x1d4a92(0x216)]=_0x2abf01[_0x1d4a92(0x216)]['replace'](/\/$/,''),this[_0x1d4a92(0x21d)]=_0x2abf01[_0x1d4a92(0x21d)],this[_0x1d4a92(0x248)]=_0x2abf01[_0x1d4a92(0x248)],this[_0x1d4a92(0x244)]=_0x2abf01[_0x1d4a92(0x244)]||'sdk',this[_0x1d4a92(0x1fb)]=_0x1d4a92(0x21a)+_0x2abf01[_0x1d4a92(0x21d)]+'-'+Date[_0x1d4a92(0x1f0)]()[_0x1d4a92(0x207)](0x24),this[_0x1d4a92(0x25c)]=_0x2abf01[_0x1d4a92(0x25c)]??0x2bf20,this[_0x1d4a92(0x232)]=_0x2abf01['reconnectDelay']??0xbb8,_0x2abf01[_0x1d4a92(0x1e6)]!==!0x1)this['connect']();}[a0_0x51fda6(0x1f1)](_0x3ef769){const _0x33a9a3=a0_0x51fda6;console[_0x33a9a3(0x1f1)]('['+new Date()['toTimeString']()['slice'](0x0,0x8)+']\x20[commhub:'+this[_0x33a9a3(0x21d)]+']\x20'+_0x3ef769);}async[a0_0x51fda6(0x1f3)](_0x181157,_0x268209){const _0x418851=a0_0x51fda6;let _0x25826b={'Content-Type':_0x418851(0x1ed),'Accept':_0x418851(0x24b)};if(this[_0x418851(0x248)])_0x25826b['Authorization']=_0x418851(0x22e)+this['token'];let _0x2c9e22=await(await fetch(this[_0x418851(0x216)]+_0x418851(0x240),{'method':_0x418851(0x257),'headers':_0x25826b,'body':JSON[_0x418851(0x1eb)]({'jsonrpc':_0x418851(0x24e),'id':Date[_0x418851(0x1f0)](),'method':_0x418851(0x246),'params':{'name':_0x181157,'arguments':_0x268209}})}))['text'](),_0x3d9fe4=_0x2c9e22[_0x418851(0x24f)](/data: (.+)/),_0x59d72a=_0x3d9fe4?JSON[_0x418851(0x237)](_0x3d9fe4[0x1]):JSON[_0x418851(0x237)](_0x2c9e22),_0x1eea93=_0x59d72a?.[_0x418851(0x212)]?.[_0x418851(0x1f6)]?.[0x0]?.[_0x418851(0x1e7)];return _0x1eea93?JSON[_0x418851(0x237)](_0x1eea93):_0x59d72a;}async[a0_0x51fda6(0x221)](){const _0x2ed8cb=a0_0x51fda6;if(this[_0x2ed8cb(0x25f)])return;this[_0x2ed8cb(0x25f)]=!0x0,await this[_0x2ed8cb(0x266)](_0x2ed8cb(0x252)),this[_0x2ed8cb(0x1f1)](_0x2ed8cb(0x265)),this[_0x2ed8cb(0x235)]=setInterval(()=>{const _0x3aac45=_0x2ed8cb;this[_0x3aac45(0x266)](_0x3aac45(0x252))[_0x3aac45(0x214)](_0xf7469a=>this[_0x3aac45(0x1f1)]('heartbeat\x20failed:\x20'+_0xf7469a[_0x3aac45(0x1e5)]));},this[_0x2ed8cb(0x25c)]),this[_0x2ed8cb(0x1f5)]();}async[a0_0x51fda6(0x20e)](){const _0x3b45e6=a0_0x51fda6;if(this[_0x3b45e6(0x25f)]=!0x1,this[_0x3b45e6(0x223)]?.[_0x3b45e6(0x238)](),this['heartbeatTimer'])clearInterval(this['heartbeatTimer']);await this[_0x3b45e6(0x266)]('offline')[_0x3b45e6(0x214)](()=>{}),this[_0x3b45e6(0x1f1)](_0x3b45e6(0x1e2));}async[a0_0x51fda6(0x25e)](_0x54c33d,_0x3125d9,_0x3597d2='normal'){const _0x2d3104=a0_0x51fda6;return Y({'alias':_0x54c33d,'fromAlias':this['alias']},{'log':_0x53216f=>console[_0x2d3104(0x1f1)](_0x53216f),'send':()=>this['call'](_0x2d3104(0x218),{'alias':_0x54c33d,'task':_0x3125d9,'priority':_0x3597d2,'from_session':this[_0x2d3104(0x21d)]})});}async[a0_0x51fda6(0x1e5)](_0x308969,_0x534750){const _0x78045a=a0_0x51fda6;return this[_0x78045a(0x1f3)](_0x78045a(0x255),{'alias':_0x308969,'message':_0x534750,'from_session':this['alias']});}async['reply'](_0x2d2fce,_0x55273b,_0x5ebe6a=a0_0x51fda6(0x249)){const _0x33879d=a0_0x51fda6;return this[_0x33879d(0x1f3)](_0x33879d(0x22c),{'in_reply_to':_0x2d2fce,'text':_0x55273b,'status':_0x5ebe6a});}async['status'](_0x54a4ba,_0x277861){const _0x4b5815=a0_0x51fda6;return this[_0x4b5815(0x1f3)](_0x4b5815(0x1fd),{'resume_id':this[_0x4b5815(0x1fb)],'alias':this['alias'],'status':_0x54a4ba,'server':a0_0x478508(),'hostname':a0_0x478508(),'agent':this[_0x4b5815(0x244)],'project_dir':process[_0x4b5815(0x23e)](),..._0x277861});}async['getAllStatus'](){const _0x21e8a4=a0_0x51fda6;return this[_0x21e8a4(0x1f3)](_0x21e8a4(0x20d),{});}async[a0_0x51fda6(0x201)](_0x1fbcd9,_0x3cda8a){const _0x104c57=a0_0x51fda6;return this[_0x104c57(0x1f3)]('broadcast',{'message':_0x1fbcd9,'filter_server':_0x3cda8a?.[_0x104c57(0x226)],'filter_status':_0x3cda8a?.[_0x104c57(0x266)]});}async[a0_0x51fda6(0x1f5)](){const _0x9075c9=a0_0x51fda6;let _0x3a5344=encodeURIComponent(this[_0x9075c9(0x21d)]),_0x5a993c=this['url']+_0x9075c9(0x261)+_0x3a5344,_0x16540e=this[_0x9075c9(0x232)];while(this[_0x9075c9(0x25f)]){try{this[_0x9075c9(0x223)]=new AbortController();let _0x480942={'Accept':_0x9075c9(0x1f9)};if(this[_0x9075c9(0x248)])_0x480942[_0x9075c9(0x233)]=_0x9075c9(0x22e)+this[_0x9075c9(0x248)];let _0x53eee0=await fetch(_0x5a993c,{'headers':_0x480942,'signal':this[_0x9075c9(0x223)]['signal']});if(!_0x53eee0['ok']||!_0x53eee0[_0x9075c9(0x23c)]){this[_0x9075c9(0x1f1)](_0x9075c9(0x1ef)+_0x53eee0[_0x9075c9(0x266)]),await this[_0x9075c9(0x227)](_0x16540e),_0x16540e=Math[_0x9075c9(0x247)](_0x16540e*1.5,0xea60);continue;}_0x16540e=this[_0x9075c9(0x232)];let _0x27bb91=_0x53eee0[_0x9075c9(0x23c)]['getReader'](),_0x55cd7c=new TextDecoder(),_0x4d1fb9='';while(this['running']){let {done:_0x82955b,value:_0x16081e}=await _0x27bb91[_0x9075c9(0x251)]();if(_0x82955b)break;_0x4d1fb9+=_0x55cd7c['decode'](_0x16081e,{'stream':!0x0});let _0x17b715=_0x4d1fb9[_0x9075c9(0x24c)]('\x0a');_0x4d1fb9=_0x17b715[_0x9075c9(0x22f)]()||'';for(let _0x1eb6b5 of _0x17b715){if(!_0x1eb6b5[_0x9075c9(0x203)](_0x9075c9(0x1e4)))continue;try{let _0x2f920f=JSON[_0x9075c9(0x237)](_0x1eb6b5[_0x9075c9(0x262)](0x6));if(_0x2f920f['type']==='connected'){this['log']('SSE\x20connected'),this[_0x9075c9(0x229)]('connected');continue;}if(_0x2f920f['type']===_0x9075c9(0x245)||_0x2f920f[_0x9075c9(0x20b)]===_0x9075c9(0x202)||_0x2f920f[_0x9075c9(0x20b)]===_0x9075c9(0x201))await this[_0x9075c9(0x1ff)]();}catch{}}}}catch(_0x520574){if(_0x520574[_0x9075c9(0x260)]===_0x9075c9(0x220))break;this[_0x9075c9(0x229)](_0x9075c9(0x224),_0x520574),this[_0x9075c9(0x1f1)](_0x9075c9(0x234)+_0x520574['message']);}if(this[_0x9075c9(0x25f)])this['emit'](_0x9075c9(0x1e2)),this['log'](_0x9075c9(0x213)+_0x16540e/0x3e8+_0x9075c9(0x231)),await this[_0x9075c9(0x227)](_0x16540e),_0x16540e=Math[_0x9075c9(0x247)](_0x16540e*1.5,0xea60);}}async[a0_0x51fda6(0x1ff)](){const _0x5c5fdd=a0_0x51fda6;try{let _0xabd9c6=(await this[_0x5c5fdd(0x1f3)](_0x5c5fdd(0x1f4),{'alias':this[_0x5c5fdd(0x21d)],'limit':0xa}))?.[_0x5c5fdd(0x225)]||[];for(let _0x1e6ffa of _0xabd9c6)await this[_0x5c5fdd(0x1f3)](_0x5c5fdd(0x204),{'alias':this['alias'],'message_id':_0x1e6ffa['id']}),this[_0x5c5fdd(0x1f1)]('←\x20'+_0x1e6ffa['from_session']+':\x20'+_0x1e6ffa[_0x5c5fdd(0x1f6)][_0x5c5fdd(0x262)](0x0,0x3c)),this['emit']('task',_0x1e6ffa),this[_0x5c5fdd(0x229)](_0x5c5fdd(0x1e5),_0x1e6ffa);}catch(_0x1dacc9){this[_0x5c5fdd(0x1f1)](_0x5c5fdd(0x236)+_0x1dacc9[_0x5c5fdd(0x1e5)]);}}[a0_0x51fda6(0x227)](_0x120ee5){return new Promise(_0x4ec91c=>setTimeout(_0x4ec91c,_0x120ee5));}}var F=$;export{F as default,$ as CommHub};