@sleep2agi/agent-network 2.3.0-preview.123 → 2.3.0-preview.124

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_0x47b98e=a0_0x3421;(function(_0x2c41b7,_0x150036){const _0x1fad7d=a0_0x3421,_0x3f2fcc=_0x2c41b7();while(!![]){try{const _0x35aa90=-parseInt(_0x1fad7d(0x202))/0x1*(parseInt(_0x1fad7d(0x187))/0x2)+-parseInt(_0x1fad7d(0x1b2))/0x3+parseInt(_0x1fad7d(0x1b9))/0x4+parseInt(_0x1fad7d(0x1d7))/0x5*(-parseInt(_0x1fad7d(0x1dc))/0x6)+-parseInt(_0x1fad7d(0x1c6))/0x7*(-parseInt(_0x1fad7d(0x1a0))/0x8)+-parseInt(_0x1fad7d(0x193))/0x9*(parseInt(_0x1fad7d(0x1d4))/0xa)+parseInt(_0x1fad7d(0x203))/0xb;if(_0x35aa90===_0x150036)break;else _0x3f2fcc['push'](_0x3f2fcc['shift']());}catch(_0x53a201){_0x3f2fcc['push'](_0x3f2fcc['shift']());}}}(a0_0xbb26,0x5b0e8));import{EventEmitter as a0_0x1389fb}from'events';import{hostname as a0_0x15db84}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x4dee4b,_0x49cc06)=>(_0x4dee4b??_0x49cc06)[a0_0x47b98e(0x186)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x3516ab){const _0x31f282=a0_0x47b98e;return(_0x3516ab instanceof Error?_0x3516ab[_0x31f282(0x1fa)]:String(_0x3516ab??_0x31f282(0x19d)))['replace'](K,_0x31f282(0x1cc))[_0x31f282(0x186)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x31f282(0x1b7)](0x0,0xf0);}function O(_0x5a1591,_0x2f6cd6=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x3fcf4a=a0_0x47b98e;if(_0x2f6cd6)return JSON[_0x3fcf4a(0x1de)](_0x5a1591);let _0x429fc5=L(_0x5a1591[_0x3fcf4a(0x1e6)],_0x3fcf4a(0x1f6)),_0x28b2bd=L(_0x5a1591[_0x3fcf4a(0x1bc)],_0x3fcf4a(0x201)),_0x5a4b49=_0x5a1591[_0x3fcf4a(0x1ad)]?_0x3fcf4a(0x1c5)+_0x5a1591[_0x3fcf4a(0x1ad)]+':'+(_0x5a1591[_0x3fcf4a(0x18e)]??''):'';return _0x3fcf4a(0x1fd)+_0x5a1591['status']+_0x3fcf4a(0x1ab)+L(_0x5a1591[_0x3fcf4a(0x1c3)],'<unknown>')+_0x3fcf4a(0x1c2)+L(_0x5a1591[_0x3fcf4a(0x192)],_0x3fcf4a(0x1ec))+_0x3fcf4a(0x1ff)+_0x28b2bd+_0x3fcf4a(0x1d1)+_0x429fc5+_0x3fcf4a(0x1b3)+L(_0x5a1591[_0x3fcf4a(0x1b5)],_0x3fcf4a(0x1ec))+_0x3fcf4a(0x18b)+_0x5a1591[_0x3fcf4a(0x1f0)]+'\x20duration_ms='+_0x5a1591['duration_ms']+_0x3fcf4a(0x19c)+_0x5a1591[_0x3fcf4a(0x1fc)]+_0x5a4b49;}function a0_0xbb26(){const _0x1ea477=['407973AIkmqc','\x20network_id=','AbortError','network_id','ack_inbox','slice','read','2607096LXWUgP','connected','server','task_id','autoConnect','text/event-stream','token','emit','tools/call','\x20to=','from_alias','call','\x20error=','7poevpF','min','task.started','match','resumeId','s...','[REDACTED]','parse','heartbeatInterval','SSE\x20failed:\x20','delivered','\x20parent_task_id=','getReader','name','3026710kwmGwW','report_status','sdk-','5RbhOxr','sleep','inbox\x20error:\x20','send_task','sending','4264098NRTPtm','text','stringify','agent','not_tracked','now','type','error','parentTaskId','get_inbox','parent_task_id','toTimeString','sseAbort','split','send','new_task','<unknown>','connect','2.0','CommHub\x20rejected\x20task','transport','heartbeatTimer','idle','connectSSE','data:\x20','fromAlias','<missing>','signal','/events/','get_all_status','message','Authorization','lifecycle_tracking','[commhub:task]\x20','SSE\x20error:\x20','\x20task_id=','send_failed','<pending>','1qOrRjK','17481882mYYenJ','log','heartbeat\x20failed:\x20','replace','1485538zwTCEk','task.send.failed','missing_task_id','registered','\x20transport=','CommHub\x20response\x20omitted\x20task_id','reply','error_message','normal','disconnect','disconnected','to_alias','9jYnDjA','cwd','SSE\x20connected','running','POST','send_rejected','alias','networkId','url','\x20lifecycle=','unknown\x20error','catch','broadcast','192368CsAVnr','task.ack','application/json,\x20text/event-stream','task.send.delivered','from_session','Bearer\x20','status','lifecycleTracking','reconnectDelay','toAlias','body','\x20from=','abort','error_code','send_message','content','task.expired','pop'];a0_0xbb26=function(){return _0x1ea477;};return a0_0xbb26();}function U(_0xb48fd5){const _0x1e5217=a0_0x47b98e;return{'event':{'sending':'task.send.start','delivered':_0x1e5217(0x1a3),'failed':_0x1e5217(0x188),'acked':_0x1e5217(0x1a1),'started':_0x1e5217(0x1c8),'replied':'task.replied','expired':_0x1e5217(0x1b0)}[_0xb48fd5[_0x1e5217(0x1a6)]],..._0xb48fd5};}function j(_0x1d47c8){const _0x3cc32c=a0_0x47b98e;let _0x1e222d=_0x1d47c8?.[_0x3cc32c(0x1bc)]||_0x1d47c8?.['message_id']||_0x1d47c8?.['id'];if(_0x1e222d)return String(_0x1e222d);let _0x56ccec=_0x1d47c8?.[_0x3cc32c(0x1af)]?.[0x0]?.[_0x3cc32c(0x1dd)];if(typeof _0x56ccec!=='string')return null;try{let _0x3b1954=JSON[_0x3cc32c(0x1cd)](_0x56ccec);return _0x3b1954?.[_0x3cc32c(0x1bc)]||_0x3b1954?.['message_id']||_0x3b1954?.['id']||null;}catch{return null;}}async function X(_0x255c5c,_0x43c52a){const _0x7a9854=a0_0x47b98e;let _0x212472=_0x43c52a[_0x7a9854(0x1e1)]??Date[_0x7a9854(0x1e1)],_0x4c9925=_0x212472(),_0x1f2f47=(_0x535f72,_0x8d88f8,_0x4ae0cc,_0x214eee)=>{const _0x43e640=_0x7a9854;_0x43c52a['log'](O(U({'from_alias':_0x255c5c[_0x43e640(0x1f5)],'to_alias':_0x255c5c[_0x43e640(0x1a9)],'task_id':_0x8d88f8,'parent_task_id':_0x255c5c[_0x43e640(0x1e4)],'network_id':_0x255c5c[_0x43e640(0x19a)],'transport':_0x255c5c[_0x43e640(0x1f0)],'status':_0x535f72,'duration_ms':_0x212472()-_0x4c9925,'lifecycle_tracking':_0x255c5c[_0x43e640(0x1a7)],..._0x4ae0cc!==void 0x0?{'error_code':_0x214eee||'send_failed','error_message':N(_0x4ae0cc)}:{}})));};_0x1f2f47(_0x7a9854(0x1db),null);try{let _0x22fd77=await _0x43c52a[_0x7a9854(0x1ea)](),_0x3faaf6=j(_0x22fd77);if(_0x3faaf6)_0x1f2f47(_0x7a9854(0x1d0),_0x3faaf6);else{if(_0x22fd77?.['ok']===!0x1||_0x22fd77?.[_0x7a9854(0x1e3)])_0x1f2f47('failed',_0x3faaf6,_0x22fd77?.['error']||_0x7a9854(0x1ef),_0x7a9854(0x198));else _0x1f2f47('failed',null,_0x7a9854(0x18c),_0x7a9854(0x189));}return _0x22fd77;}catch(_0x5930bb){throw _0x1f2f47('failed',null,_0x5930bb,_0x7a9854(0x200)),_0x5930bb;}}async function Y(_0xa2021,_0x4efd20){const _0x449f8b=a0_0x47b98e;return X({'fromAlias':_0xa2021['fromAlias'],'toAlias':_0xa2021[_0x449f8b(0x199)],'parentTaskId':_0xa2021[_0x449f8b(0x1e4)]||null,'networkId':_0xa2021['networkId']||null,'transport':'mcp_http','lifecycleTracking':_0x449f8b(0x1e0)},_0x4efd20);}class $ extends a0_0x1389fb{[a0_0x47b98e(0x19b)];[a0_0x47b98e(0x199)];[a0_0x47b98e(0x1bf)];[a0_0x47b98e(0x1df)];['resumeId'];['heartbeatInterval'];[a0_0x47b98e(0x1a8)];[a0_0x47b98e(0x1f1)];[a0_0x47b98e(0x1e8)];['running']=!0x1;constructor(_0x5d63f7){const _0x2d2765=a0_0x47b98e;super();if(this[_0x2d2765(0x19b)]=_0x5d63f7[_0x2d2765(0x19b)][_0x2d2765(0x186)](/\/$/,''),this[_0x2d2765(0x199)]=_0x5d63f7[_0x2d2765(0x199)],this[_0x2d2765(0x1bf)]=_0x5d63f7[_0x2d2765(0x1bf)],this[_0x2d2765(0x1df)]=_0x5d63f7[_0x2d2765(0x1df)]||'sdk',this[_0x2d2765(0x1ca)]=_0x2d2765(0x1d6)+_0x5d63f7[_0x2d2765(0x199)]+'-'+Date[_0x2d2765(0x1e1)]()['toString'](0x24),this[_0x2d2765(0x1ce)]=_0x5d63f7[_0x2d2765(0x1ce)]??0x2bf20,this['reconnectDelay']=_0x5d63f7[_0x2d2765(0x1a8)]??0xbb8,_0x5d63f7[_0x2d2765(0x1bd)]!==!0x1)this[_0x2d2765(0x1ed)]();}[a0_0x47b98e(0x204)](_0x3e8d85){const _0x18627d=a0_0x47b98e;console[_0x18627d(0x204)]('['+new Date()[_0x18627d(0x1e7)]()[_0x18627d(0x1b7)](0x0,0x8)+']\x20[commhub:'+this[_0x18627d(0x199)]+']\x20'+_0x3e8d85);}async[a0_0x47b98e(0x1c4)](_0x3a8de4,_0x516ad1){const _0x5360ff=a0_0x47b98e;let _0x2b2309={'Content-Type':'application/json','Accept':_0x5360ff(0x1a2)};if(this[_0x5360ff(0x1bf)])_0x2b2309[_0x5360ff(0x1fb)]=_0x5360ff(0x1a5)+this[_0x5360ff(0x1bf)];let _0x4d6135=await(await fetch(this[_0x5360ff(0x19b)]+'/mcp',{'method':_0x5360ff(0x197),'headers':_0x2b2309,'body':JSON[_0x5360ff(0x1de)]({'jsonrpc':_0x5360ff(0x1ee),'id':Date[_0x5360ff(0x1e1)](),'method':_0x5360ff(0x1c1),'params':{'name':_0x3a8de4,'arguments':_0x516ad1}})}))[_0x5360ff(0x1dd)](),_0x1fdf1e=_0x4d6135[_0x5360ff(0x1c9)](/data: (.+)/),_0x58b208=_0x1fdf1e?JSON[_0x5360ff(0x1cd)](_0x1fdf1e[0x1]):JSON[_0x5360ff(0x1cd)](_0x4d6135),_0x4e1a00=_0x58b208?.['result']?.['content']?.[0x0]?.['text'];return _0x4e1a00?JSON[_0x5360ff(0x1cd)](_0x4e1a00):_0x58b208;}async[a0_0x47b98e(0x1ed)](){const _0x2e5480=a0_0x47b98e;if(this['running'])return;this[_0x2e5480(0x196)]=!0x0,await this[_0x2e5480(0x1a6)](_0x2e5480(0x1f2)),this[_0x2e5480(0x204)](_0x2e5480(0x18a)),this[_0x2e5480(0x1f1)]=setInterval(()=>{const _0x2b3255=_0x2e5480;this['status']('idle')[_0x2b3255(0x19e)](_0x22f50d=>this[_0x2b3255(0x204)](_0x2b3255(0x185)+_0x22f50d[_0x2b3255(0x1fa)]));},this['heartbeatInterval']),this[_0x2e5480(0x1f3)]();}async[a0_0x47b98e(0x190)](){const _0x6d41d4=a0_0x47b98e;if(this[_0x6d41d4(0x196)]=!0x1,this[_0x6d41d4(0x1e8)]?.[_0x6d41d4(0x1ac)](),this[_0x6d41d4(0x1f1)])clearInterval(this[_0x6d41d4(0x1f1)]);await this[_0x6d41d4(0x1a6)]('offline')[_0x6d41d4(0x19e)](()=>{}),this[_0x6d41d4(0x204)](_0x6d41d4(0x191));}async[a0_0x47b98e(0x1ea)](_0x3038ef,_0x37221e,_0xdf7541=a0_0x47b98e(0x18f)){const _0x4054d3=a0_0x47b98e;return Y({'alias':_0x3038ef,'fromAlias':this[_0x4054d3(0x199)]},{'log':_0x200355=>console['log'](_0x200355),'send':()=>this[_0x4054d3(0x1c4)](_0x4054d3(0x1da),{'alias':_0x3038ef,'task':_0x37221e,'priority':_0xdf7541,'from_session':this[_0x4054d3(0x199)]})});}async[a0_0x47b98e(0x1fa)](_0x3c4fea,_0x22d508){const _0x29d86b=a0_0x47b98e;return this[_0x29d86b(0x1c4)](_0x29d86b(0x1ae),{'alias':_0x3c4fea,'message':_0x22d508,'from_session':this[_0x29d86b(0x199)]});}async[a0_0x47b98e(0x18d)](_0x185662,_0x22b7c5,_0x3f0161='completed'){return this['call']('send_reply',{'in_reply_to':_0x185662,'text':_0x22b7c5,'status':_0x3f0161});}async[a0_0x47b98e(0x1a6)](_0x37bc6e,_0xff9159){const _0x1456c8=a0_0x47b98e;return this[_0x1456c8(0x1c4)](_0x1456c8(0x1d5),{'resume_id':this[_0x1456c8(0x1ca)],'alias':this[_0x1456c8(0x199)],'status':_0x37bc6e,'server':a0_0x15db84(),'hostname':a0_0x15db84(),'agent':this['agent'],'project_dir':process[_0x1456c8(0x194)](),..._0xff9159});}async['getAllStatus'](){const _0x4516de=a0_0x47b98e;return this['call'](_0x4516de(0x1f9),{});}async['broadcast'](_0x48655b,_0x44213e){const _0x238c5d=a0_0x47b98e;return this['call']('broadcast',{'message':_0x48655b,'filter_server':_0x44213e?.[_0x238c5d(0x1bb)],'filter_status':_0x44213e?.[_0x238c5d(0x1a6)]});}async[a0_0x47b98e(0x1f3)](){const _0x24dade=a0_0x47b98e;let _0x5263ce=encodeURIComponent(this['alias']),_0x497b72=this[_0x24dade(0x19b)]+_0x24dade(0x1f8)+_0x5263ce,_0x49ebb1=this[_0x24dade(0x1a8)];while(this['running']){try{this[_0x24dade(0x1e8)]=new AbortController();let _0x22ae62={'Accept':_0x24dade(0x1be)};if(this[_0x24dade(0x1bf)])_0x22ae62[_0x24dade(0x1fb)]='Bearer\x20'+this[_0x24dade(0x1bf)];let _0x5500e3=await fetch(_0x497b72,{'headers':_0x22ae62,'signal':this[_0x24dade(0x1e8)][_0x24dade(0x1f7)]});if(!_0x5500e3['ok']||!_0x5500e3[_0x24dade(0x1aa)]){this[_0x24dade(0x204)](_0x24dade(0x1cf)+_0x5500e3[_0x24dade(0x1a6)]),await this[_0x24dade(0x1d8)](_0x49ebb1),_0x49ebb1=Math[_0x24dade(0x1c7)](_0x49ebb1*1.5,0xea60);continue;}_0x49ebb1=this['reconnectDelay'];let _0x5976b7=_0x5500e3[_0x24dade(0x1aa)][_0x24dade(0x1d2)](),_0x344710=new TextDecoder(),_0x5c4a0f='';while(this[_0x24dade(0x196)]){let {done:_0x3d8b0c,value:_0x45b840}=await _0x5976b7[_0x24dade(0x1b8)]();if(_0x3d8b0c)break;_0x5c4a0f+=_0x344710['decode'](_0x45b840,{'stream':!0x0});let _0x4da248=_0x5c4a0f[_0x24dade(0x1e9)]('\x0a');_0x5c4a0f=_0x4da248[_0x24dade(0x1b1)]()||'';for(let _0x5a3fb7 of _0x4da248){if(!_0x5a3fb7['startsWith'](_0x24dade(0x1f4)))continue;try{let _0x38e673=JSON[_0x24dade(0x1cd)](_0x5a3fb7['slice'](0x6));if(_0x38e673[_0x24dade(0x1e2)]===_0x24dade(0x1ba)){this['log'](_0x24dade(0x195)),this[_0x24dade(0x1c0)](_0x24dade(0x1ba));continue;}if(_0x38e673[_0x24dade(0x1e2)]===_0x24dade(0x1eb)||_0x38e673['type']==='new_message'||_0x38e673[_0x24dade(0x1e2)]===_0x24dade(0x19f))await this['processInbox']();}catch{}}}}catch(_0x39f36e){if(_0x39f36e[_0x24dade(0x1d3)]===_0x24dade(0x1b4))break;this[_0x24dade(0x1c0)](_0x24dade(0x1e3),_0x39f36e),this[_0x24dade(0x204)](_0x24dade(0x1fe)+_0x39f36e[_0x24dade(0x1fa)]);}if(this[_0x24dade(0x196)])this[_0x24dade(0x1c0)]('disconnected'),this[_0x24dade(0x204)]('SSE\x20reconnecting\x20in\x20'+_0x49ebb1/0x3e8+_0x24dade(0x1cb)),await this[_0x24dade(0x1d8)](_0x49ebb1),_0x49ebb1=Math[_0x24dade(0x1c7)](_0x49ebb1*1.5,0xea60);}}async['processInbox'](){const _0x76bb32=a0_0x47b98e;try{let _0x5b7bc6=(await this[_0x76bb32(0x1c4)](_0x76bb32(0x1e5),{'alias':this[_0x76bb32(0x199)],'limit':0xa}))?.['messages']||[];for(let _0x43307c of _0x5b7bc6)await this['call'](_0x76bb32(0x1b6),{'alias':this[_0x76bb32(0x199)],'message_id':_0x43307c['id']}),this[_0x76bb32(0x204)]('←\x20'+_0x43307c[_0x76bb32(0x1a4)]+':\x20'+_0x43307c[_0x76bb32(0x1af)]['slice'](0x0,0x3c)),this[_0x76bb32(0x1c0)]('task',_0x43307c),this['emit'](_0x76bb32(0x1fa),_0x43307c);}catch(_0x31992f){this['log'](_0x76bb32(0x1d9)+_0x31992f[_0x76bb32(0x1fa)]);}}['sleep'](_0x568d71){return new Promise(_0x2efb8b=>setTimeout(_0x2efb8b,_0x568d71));}}var F=$;function a0_0x3421(_0x264e4f,_0x567026){_0x264e4f=_0x264e4f-0x185;const _0xbb260d=a0_0xbb26();let _0x3421c7=_0xbb260d[_0x264e4f];return _0x3421c7;}export{F as default,$ as CommHub};
1
+ const a0_0x29f6d2=a0_0x3ce0;(function(_0xa4c5e3,_0x1e018f){const _0x15a0cb=a0_0x3ce0,_0x155dd5=_0xa4c5e3();while(!![]){try{const _0x31c9c7=-parseInt(_0x15a0cb(0x134))/0x1+parseInt(_0x15a0cb(0x13a))/0x2+parseInt(_0x15a0cb(0xe0))/0x3*(parseInt(_0x15a0cb(0x105))/0x4)+-parseInt(_0x15a0cb(0x117))/0x5+parseInt(_0x15a0cb(0xdf))/0x6+-parseInt(_0x15a0cb(0x139))/0x7+-parseInt(_0x15a0cb(0xe6))/0x8*(-parseInt(_0x15a0cb(0x13c))/0x9);if(_0x31c9c7===_0x1e018f)break;else _0x155dd5['push'](_0x155dd5['shift']());}catch(_0x5f5b86){_0x155dd5['push'](_0x155dd5['shift']());}}}(a0_0x57ce,0xb186c));import{EventEmitter as a0_0x121833}from'events';import{hostname as a0_0x556524}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x17c407,_0x827e79)=>(_0x17c407??_0x827e79)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x29f6d2(0xf8)](0x0,0xf0);function N(_0x24f825){const _0x5eef13=a0_0x29f6d2;return(_0x24f825 instanceof Error?_0x24f825[_0x5eef13(0xf3)]:String(_0x24f825??_0x5eef13(0x12c)))[_0x5eef13(0xe8)](K,_0x5eef13(0x104))[_0x5eef13(0xe8)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x5eef13(0xf8)](0x0,0xf0);}function O(_0x3f7fe9,_0x555cd7=process.env.ANET_TASK_TRACE_FORMAT===a0_0x29f6d2(0x109)){const _0x2fecdd=a0_0x29f6d2;if(_0x555cd7)return JSON[_0x2fecdd(0x119)](_0x3f7fe9);let _0x4861d9=L(_0x3f7fe9[_0x2fecdd(0xf6)],_0x2fecdd(0x127)),_0x368e7c=L(_0x3f7fe9[_0x2fecdd(0xdd)],'<pending>'),_0x3f896e=_0x3f7fe9[_0x2fecdd(0x145)]?_0x2fecdd(0x108)+_0x3f7fe9[_0x2fecdd(0x145)]+':'+(_0x3f7fe9['error_message']??''):'';return _0x2fecdd(0x147)+_0x3f7fe9[_0x2fecdd(0xd2)]+_0x2fecdd(0x12e)+L(_0x3f7fe9[_0x2fecdd(0x11a)],'<unknown>')+_0x2fecdd(0x143)+L(_0x3f7fe9[_0x2fecdd(0x12b)],'<unknown>')+_0x2fecdd(0xfb)+_0x368e7c+_0x2fecdd(0xed)+_0x4861d9+_0x2fecdd(0x132)+L(_0x3f7fe9['network_id'],_0x2fecdd(0x135))+_0x2fecdd(0x110)+_0x3f7fe9[_0x2fecdd(0x126)]+_0x2fecdd(0xf0)+_0x3f7fe9[_0x2fecdd(0x156)]+_0x2fecdd(0x13b)+_0x3f7fe9[_0x2fecdd(0xe4)]+_0x3f896e;}function U(_0x3819a9){const _0x2e5f98=a0_0x29f6d2;return{'event':{'sending':_0x2e5f98(0x10f),'delivered':_0x2e5f98(0x14b),'failed':_0x2e5f98(0x11c),'acked':_0x2e5f98(0x14e),'started':_0x2e5f98(0x152),'replied':_0x2e5f98(0xda),'expired':'task.expired'}[_0x3819a9['status']],..._0x3819a9};}function j(_0x54a243){const _0x5261e7=a0_0x29f6d2;let _0xb06f0c=_0x54a243?.[_0x5261e7(0xdd)]||_0x54a243?.['message_id']||_0x54a243?.['id'];if(_0xb06f0c)return String(_0xb06f0c);let _0x21df70=_0x54a243?.['content']?.[0x0]?.['text'];if(typeof _0x21df70!=='string')return null;try{let _0x23f47f=JSON['parse'](_0x21df70);return _0x23f47f?.[_0x5261e7(0xdd)]||_0x23f47f?.[_0x5261e7(0x121)]||_0x23f47f?.['id']||null;}catch{return null;}}async function X(_0x4cb5a6,_0x3194f5){const _0x1c1820=a0_0x29f6d2;let _0x2f0453=_0x3194f5[_0x1c1820(0x13f)]??Date['now'],_0x5bb690=_0x2f0453(),_0x278825=(_0x29afc2,_0x2d667f,_0x15e69d,_0x286988)=>{const _0x3410e8=_0x1c1820;_0x3194f5['log'](O(U({'from_alias':_0x4cb5a6['fromAlias'],'to_alias':_0x4cb5a6[_0x3410e8(0xe3)],'task_id':_0x2d667f,'parent_task_id':_0x4cb5a6[_0x3410e8(0x155)],'network_id':_0x4cb5a6[_0x3410e8(0xf5)],'transport':_0x4cb5a6['transport'],'status':_0x29afc2,'duration_ms':_0x2f0453()-_0x5bb690,'lifecycle_tracking':_0x4cb5a6[_0x3410e8(0x154)],..._0x15e69d!==void 0x0?{'error_code':_0x286988||_0x3410e8(0x136),'error_message':N(_0x15e69d)}:{}})));};_0x278825('sending',null);try{let _0x11af84=await _0x3194f5[_0x1c1820(0x106)](),_0x294183=j(_0x11af84);if(_0x294183)_0x278825(_0x1c1820(0x103),_0x294183);else{if(_0x11af84?.['ok']===!0x1||_0x11af84?.[_0x1c1820(0xf9)])_0x278825(_0x1c1820(0xfd),_0x294183,_0x11af84?.[_0x1c1820(0xf9)]||_0x1c1820(0xf2),_0x1c1820(0xe1));else _0x278825(_0x1c1820(0xfd),null,_0x1c1820(0xf4),_0x1c1820(0xd5));}return _0x11af84;}catch(_0xbbdb71){throw _0x278825(_0x1c1820(0xfd),null,_0xbbdb71,_0x1c1820(0x136)),_0xbbdb71;}}function a0_0x57ce(){const _0xa90b3b=['lifecycle_tracking','get_all_status','8LNUEjo','sseAbort','replace','SSE\x20reconnecting\x20in\x20','connectSSE','toTimeString','token','\x20parent_task_id=','SSE\x20connected','new_message','\x20duration_ms=','offline','CommHub\x20rejected\x20task','message','CommHub\x20response\x20omitted\x20task_id','networkId','parent_task_id','resumeId','slice','error','disconnected','\x20task_id=','sdk-','failed','alias','Bearer\x20','get_inbox','text/event-stream','send_reply','delivered','[REDACTED]','1545496vbiahg','send','server','\x20error=','json','signal','heartbeatInterval','new_task','log','cwd','task.send.start','\x20transport=','sdk','data:\x20','task','match','/events/','send_message','3545655tIfxLT','name','stringify','from_alias','split','task.send.failed',']\x20[commhub:','sleep','connected','toString','message_id','parse','mcp_http','processInbox','body','transport','<missing>','call','idle','reconnectDelay','to_alias','unknown\x20error','connect','\x20from=','tools/call','decode','read','\x20network_id=','heartbeat\x20failed:\x20','613628OAVQNv','<unknown>','send_failed','report_status','text','8050525aXinea','189122jqzebN','\x20lifecycle=','16280721QUbgkq','running','2.0','now','emit','catch','disconnect','\x20to=','not_tracked','error_code','ack_inbox','[commhub:task]\x20','type','broadcast','registered','task.send.delivered','getAllStatus','result','task.ack','pop','heartbeatTimer','inbox\x20error:\x20','task.started','min','lifecycleTracking','parentTaskId','duration_ms','status','application/json,\x20text/event-stream','agent','missing_task_id','from_session','send_task','getReader','SSE\x20error:\x20','task.replied','Authorization','POST','task_id','url','823980gjgoTw','9JfRKVI','send_rejected','messages','toAlias'];a0_0x57ce=function(){return _0xa90b3b;};return a0_0x57ce();}async function Y(_0x5d65e7,_0x55fddd){const _0x5d8810=a0_0x29f6d2;return X({'fromAlias':_0x5d65e7['fromAlias'],'toAlias':_0x5d65e7[_0x5d8810(0xfe)],'parentTaskId':_0x5d65e7['parentTaskId']||null,'networkId':_0x5d65e7[_0x5d8810(0xf5)]||null,'transport':_0x5d8810(0x123),'lifecycleTracking':_0x5d8810(0x144)},_0x55fddd);}class $ extends a0_0x121833{[a0_0x29f6d2(0xde)];[a0_0x29f6d2(0xfe)];[a0_0x29f6d2(0xec)];[a0_0x29f6d2(0xd4)];[a0_0x29f6d2(0xf7)];['heartbeatInterval'];['reconnectDelay'];['heartbeatTimer'];[a0_0x29f6d2(0xe7)];['running']=!0x1;constructor(_0x482c2a){const _0x34c710=a0_0x29f6d2;super();if(this[_0x34c710(0xde)]=_0x482c2a[_0x34c710(0xde)][_0x34c710(0xe8)](/\/$/,''),this[_0x34c710(0xfe)]=_0x482c2a[_0x34c710(0xfe)],this['token']=_0x482c2a['token'],this[_0x34c710(0xd4)]=_0x482c2a[_0x34c710(0xd4)]||_0x34c710(0x111),this[_0x34c710(0xf7)]=_0x34c710(0xfc)+_0x482c2a[_0x34c710(0xfe)]+'-'+Date[_0x34c710(0x13f)]()[_0x34c710(0x120)](0x24),this[_0x34c710(0x10b)]=_0x482c2a[_0x34c710(0x10b)]??0x2bf20,this[_0x34c710(0x12a)]=_0x482c2a[_0x34c710(0x12a)]??0xbb8,_0x482c2a['autoConnect']!==!0x1)this['connect']();}[a0_0x29f6d2(0x10d)](_0x2e8c60){const _0x19b83f=a0_0x29f6d2;console[_0x19b83f(0x10d)]('['+new Date()[_0x19b83f(0xeb)]()[_0x19b83f(0xf8)](0x0,0x8)+_0x19b83f(0x11d)+this[_0x19b83f(0xfe)]+']\x20'+_0x2e8c60);}async[a0_0x29f6d2(0x128)](_0x42fff2,_0x2626a1){const _0x3226a9=a0_0x29f6d2;let _0x4239d4={'Content-Type':'application/json','Accept':_0x3226a9(0xd3)};if(this[_0x3226a9(0xec)])_0x4239d4[_0x3226a9(0xdb)]=_0x3226a9(0xff)+this[_0x3226a9(0xec)];let _0x3050b7=await(await fetch(this[_0x3226a9(0xde)]+'/mcp',{'method':_0x3226a9(0xdc),'headers':_0x4239d4,'body':JSON[_0x3226a9(0x119)]({'jsonrpc':_0x3226a9(0x13e),'id':Date['now'](),'method':_0x3226a9(0x12f),'params':{'name':_0x42fff2,'arguments':_0x2626a1}})}))[_0x3226a9(0x138)](),_0x3bd5c7=_0x3050b7[_0x3226a9(0x114)](/data: (.+)/),_0x3267f3=_0x3bd5c7?JSON[_0x3226a9(0x122)](_0x3bd5c7[0x1]):JSON['parse'](_0x3050b7),_0x39e73b=_0x3267f3?.[_0x3226a9(0x14d)]?.['content']?.[0x0]?.[_0x3226a9(0x138)];return _0x39e73b?JSON[_0x3226a9(0x122)](_0x39e73b):_0x3267f3;}async[a0_0x29f6d2(0x12d)](){const _0x19d61d=a0_0x29f6d2;if(this[_0x19d61d(0x13d)])return;this[_0x19d61d(0x13d)]=!0x0,await this[_0x19d61d(0xd2)](_0x19d61d(0x129)),this[_0x19d61d(0x10d)](_0x19d61d(0x14a)),this['heartbeatTimer']=setInterval(()=>{const _0x8ca95=_0x19d61d;this[_0x8ca95(0xd2)](_0x8ca95(0x129))[_0x8ca95(0x141)](_0xffb1a2=>this['log'](_0x8ca95(0x133)+_0xffb1a2[_0x8ca95(0xf3)]));},this[_0x19d61d(0x10b)]),this[_0x19d61d(0xea)]();}async[a0_0x29f6d2(0x142)](){const _0x3f2f03=a0_0x29f6d2;if(this[_0x3f2f03(0x13d)]=!0x1,this['sseAbort']?.['abort'](),this[_0x3f2f03(0x150)])clearInterval(this[_0x3f2f03(0x150)]);await this[_0x3f2f03(0xd2)](_0x3f2f03(0xf1))[_0x3f2f03(0x141)](()=>{}),this[_0x3f2f03(0x10d)](_0x3f2f03(0xfa));}async[a0_0x29f6d2(0x106)](_0x1daaf5,_0x3d2319,_0x114563='normal'){const _0x4e4aae=a0_0x29f6d2;return Y({'alias':_0x1daaf5,'fromAlias':this['alias']},{'log':_0x59c50b=>console[_0x4e4aae(0x10d)](_0x59c50b),'send':()=>this['call'](_0x4e4aae(0xd7),{'alias':_0x1daaf5,'task':_0x3d2319,'priority':_0x114563,'from_session':this[_0x4e4aae(0xfe)]})});}async[a0_0x29f6d2(0xf3)](_0x276f4b,_0x5d8223){const _0x597207=a0_0x29f6d2;return this[_0x597207(0x128)](_0x597207(0x116),{'alias':_0x276f4b,'message':_0x5d8223,'from_session':this[_0x597207(0xfe)]});}async['reply'](_0x5d5eeb,_0x421a0f,_0x5483b3='completed'){const _0x3cb3ce=a0_0x29f6d2;return this[_0x3cb3ce(0x128)](_0x3cb3ce(0x102),{'in_reply_to':_0x5d5eeb,'text':_0x421a0f,'status':_0x5483b3});}async[a0_0x29f6d2(0xd2)](_0x232854,_0x39568a){const _0x366dcb=a0_0x29f6d2;return this['call'](_0x366dcb(0x137),{'resume_id':this[_0x366dcb(0xf7)],'alias':this[_0x366dcb(0xfe)],'status':_0x232854,'server':a0_0x556524(),'hostname':a0_0x556524(),'agent':this[_0x366dcb(0xd4)],'project_dir':process[_0x366dcb(0x10e)](),..._0x39568a});}async[a0_0x29f6d2(0x14c)](){const _0x486d02=a0_0x29f6d2;return this[_0x486d02(0x128)](_0x486d02(0xe5),{});}async[a0_0x29f6d2(0x149)](_0x3edd45,_0x50f4ad){const _0x2ecec9=a0_0x29f6d2;return this[_0x2ecec9(0x128)]('broadcast',{'message':_0x3edd45,'filter_server':_0x50f4ad?.[_0x2ecec9(0x107)],'filter_status':_0x50f4ad?.[_0x2ecec9(0xd2)]});}async[a0_0x29f6d2(0xea)](){const _0x146165=a0_0x29f6d2;let _0x548ca4=encodeURIComponent(this[_0x146165(0xfe)]),_0x32aac0=this[_0x146165(0xde)]+_0x146165(0x115)+_0x548ca4,_0x265258=this[_0x146165(0x12a)];while(this[_0x146165(0x13d)]){try{this[_0x146165(0xe7)]=new AbortController();let _0x324a6a={'Accept':_0x146165(0x101)};if(this['token'])_0x324a6a[_0x146165(0xdb)]=_0x146165(0xff)+this['token'];let _0x5b2d05=await fetch(_0x32aac0,{'headers':_0x324a6a,'signal':this[_0x146165(0xe7)][_0x146165(0x10a)]});if(!_0x5b2d05['ok']||!_0x5b2d05[_0x146165(0x125)]){this[_0x146165(0x10d)]('SSE\x20failed:\x20'+_0x5b2d05[_0x146165(0xd2)]),await this[_0x146165(0x11e)](_0x265258),_0x265258=Math[_0x146165(0x153)](_0x265258*1.5,0xea60);continue;}_0x265258=this[_0x146165(0x12a)];let _0x29dd88=_0x5b2d05[_0x146165(0x125)][_0x146165(0xd8)](),_0x32503f=new TextDecoder(),_0x3c5491='';while(this['running']){let {done:_0x5b8dd7,value:_0x54f85c}=await _0x29dd88[_0x146165(0x131)]();if(_0x5b8dd7)break;_0x3c5491+=_0x32503f[_0x146165(0x130)](_0x54f85c,{'stream':!0x0});let _0x312c12=_0x3c5491[_0x146165(0x11b)]('\x0a');_0x3c5491=_0x312c12[_0x146165(0x14f)]()||'';for(let _0x632742 of _0x312c12){if(!_0x632742['startsWith'](_0x146165(0x112)))continue;try{let _0x1eb3cc=JSON['parse'](_0x632742['slice'](0x6));if(_0x1eb3cc[_0x146165(0x148)]==='connected'){this[_0x146165(0x10d)](_0x146165(0xee)),this[_0x146165(0x140)](_0x146165(0x11f));continue;}if(_0x1eb3cc['type']===_0x146165(0x10c)||_0x1eb3cc[_0x146165(0x148)]===_0x146165(0xef)||_0x1eb3cc[_0x146165(0x148)]===_0x146165(0x149))await this[_0x146165(0x124)]();}catch{}}}}catch(_0x3e3a0a){if(_0x3e3a0a[_0x146165(0x118)]==='AbortError')break;this['emit'](_0x146165(0xf9),_0x3e3a0a),this[_0x146165(0x10d)](_0x146165(0xd9)+_0x3e3a0a[_0x146165(0xf3)]);}if(this['running'])this[_0x146165(0x140)]('disconnected'),this[_0x146165(0x10d)](_0x146165(0xe9)+_0x265258/0x3e8+'s...'),await this['sleep'](_0x265258),_0x265258=Math[_0x146165(0x153)](_0x265258*1.5,0xea60);}}async[a0_0x29f6d2(0x124)](){const _0x17558b=a0_0x29f6d2;try{let _0x38a9c6=(await this[_0x17558b(0x128)](_0x17558b(0x100),{'alias':this['alias'],'limit':0xa}))?.[_0x17558b(0xe2)]||[];for(let _0x1dfddc of _0x38a9c6)await this[_0x17558b(0x128)](_0x17558b(0x146),{'alias':this['alias'],'message_id':_0x1dfddc['id']}),this[_0x17558b(0x10d)]('←\x20'+_0x1dfddc[_0x17558b(0xd6)]+':\x20'+_0x1dfddc['content'][_0x17558b(0xf8)](0x0,0x3c)),this['emit'](_0x17558b(0x113),_0x1dfddc),this[_0x17558b(0x140)](_0x17558b(0xf3),_0x1dfddc);}catch(_0x48e6b){this[_0x17558b(0x10d)](_0x17558b(0x151)+_0x48e6b['message']);}}[a0_0x29f6d2(0x11e)](_0xc24f30){return new Promise(_0x1789db=>setTimeout(_0x1789db,_0xc24f30));}}function a0_0x3ce0(_0x4af6fd,_0x13f14f){_0x4af6fd=_0x4af6fd-0xd2;const _0x57ce9a=a0_0x57ce();let _0x3ce01c=_0x57ce9a[_0x4af6fd];return _0x3ce01c;}var F=$;export{F as default,$ as CommHub};