@sleep2agi/agent-network 2.3.0-preview.215 → 2.3.0-preview.216

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_0x4f40f9=a0_0xe5d0;function a0_0x50c6(){const _0x29b7a1=['2.0','task_id','application/json,\x20text/event-stream','signal','connected','log','176IoPmnL','resumeId','POST','stringify','normal','toString','sleep','connect',']\x20[commhub:','startsWith','/mcp','status','sending','task.send.failed','not_tracked','error_code','\x20transport=','\x20duration_ms=','Authorization','decode','fromAlias','Bearer\x20','\x20error=','server','send_reply','text','running','mcp_http','from_session','CommHub\x20rejected\x20task','data:\x20','duration_ms','string','\x20parent_task_id=','connectSSE','task.started','16407jmZkOR','ack_inbox','url','22210dUNOas','329691aTYPRL','message_id','offline','missing_task_id','<pending>','idle','registered','cwd','task.send.delivered','error','10TIYKxS','task.ack','reconnectDelay','get_all_status','send_rejected','broadcast','content','completed','agent','new_message','error_message','sdk','\x20to=','pop','now','replace','CommHub\x20response\x20omitted\x20task_id','messages','token','send_message','match','tools/call','reply','[REDACTED]','disconnected','toAlias','processInbox','type','task','alias','1657362ykksPE','heartbeatTimer','call','parentTaskId','send','text/event-stream','611262MYPHST','task.send.start','application/json','\x20from=','body','5071mvqcjF','slice','message','get_inbox','send_task','SSE\x20error:\x20','sseAbort','toTimeString','autoConnect','result','s...','<unknown>','32RPenCV','emit','read','sdk-','send_failed','SSE\x20connected','1436449itDYcI','failed','transport','2095140NqYxja','networkId','SSE\x20reconnecting\x20in\x20','heartbeatInterval','parse','lifecycleTracking'];a0_0x50c6=function(){return _0x29b7a1;};return a0_0x50c6();}(function(_0x1871b7,_0x36f494){const _0x53a508=a0_0xe5d0,_0x39aedf=_0x1871b7();while(!![]){try{const _0x4833c1=parseInt(_0x53a508(0x23b))/0x1+parseInt(_0x53a508(0x213))/0x2*(parseInt(_0x53a508(0x237))/0x3)+-parseInt(_0x53a508(0x207))/0x4+-parseInt(_0x53a508(0x245))/0x5*(parseInt(_0x53a508(0x1e7))/0x6)+-parseInt(_0x53a508(0x204))/0x7+parseInt(_0x53a508(0x1fe))/0x8*(-parseInt(_0x53a508(0x1ed))/0x9)+-parseInt(_0x53a508(0x23a))/0xa*(-parseInt(_0x53a508(0x1f2))/0xb);if(_0x4833c1===_0x36f494)break;else _0x39aedf['push'](_0x39aedf['shift']());}catch(_0x318a71){_0x39aedf['push'](_0x39aedf['shift']());}}}(a0_0x50c6,0x44c7e));import{EventEmitter as a0_0x1bc1fd}from'events';import{hostname as a0_0x5bd3d5}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x34344d,_0x48d7cc)=>(_0x34344d??_0x48d7cc)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x4f40f9(0x1f3)](0x0,0xf0);function N(_0xbe812f){const _0x1fb400=a0_0x4f40f9;return(_0xbe812f instanceof Error?_0xbe812f[_0x1fb400(0x1f4)]:String(_0xbe812f??'unknown\x20error'))['replace'](K,_0x1fb400(0x25c))[_0x1fb400(0x254)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x1fb400(0x1f3)](0x0,0xf0);}function O(_0x7b703c,_0x2ff1e4=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0xa8be13=a0_0x4f40f9;if(_0x2ff1e4)return JSON[_0xa8be13(0x216)](_0x7b703c);let _0x5d531e=L(_0x7b703c['parent_task_id'],'<missing>'),_0x4711fd=L(_0x7b703c[_0xa8be13(0x20e)],_0xa8be13(0x23f)),_0x45710e=_0x7b703c['error_code']?_0xa8be13(0x229)+_0x7b703c[_0xa8be13(0x222)]+':'+(_0x7b703c[_0xa8be13(0x24f)]??''):'';return'[commhub:task]\x20'+_0x7b703c[_0xa8be13(0x21e)]+_0xa8be13(0x1f0)+L(_0x7b703c['from_alias'],_0xa8be13(0x1fd))+_0xa8be13(0x251)+L(_0x7b703c['to_alias'],_0xa8be13(0x1fd))+'\x20task_id='+_0x4711fd+_0xa8be13(0x234)+_0x5d531e+'\x20network_id='+L(_0x7b703c['network_id'],_0xa8be13(0x1fd))+_0xa8be13(0x223)+_0x7b703c['transport']+_0xa8be13(0x224)+_0x7b703c[_0xa8be13(0x232)]+'\x20lifecycle='+_0x7b703c['lifecycle_tracking']+_0x45710e;}function a0_0xe5d0(_0x1cc331,_0x85fa99){_0x1cc331=_0x1cc331-0x1e4;const _0x50c66b=a0_0x50c6();let _0xe5d01b=_0x50c66b[_0x1cc331];return _0xe5d01b;}function U(_0x4f4776){const _0x16c585=a0_0x4f40f9;return{'event':{'sending':_0x16c585(0x1ee),'delivered':_0x16c585(0x243),'failed':_0x16c585(0x220),'acked':_0x16c585(0x246),'started':_0x16c585(0x236),'replied':'task.replied','expired':'task.expired'}[_0x4f4776[_0x16c585(0x21e)]],..._0x4f4776};}function j(_0x505198){const _0x4413d9=a0_0x4f40f9;let _0xae909b=_0x505198?.[_0x4413d9(0x20e)]||_0x505198?.[_0x4413d9(0x23c)]||_0x505198?.['id'];if(_0xae909b)return String(_0xae909b);let _0x128b56=_0x505198?.[_0x4413d9(0x24b)]?.[0x0]?.['text'];if(typeof _0x128b56!==_0x4413d9(0x233))return null;try{let _0x4a575c=JSON['parse'](_0x128b56);return _0x4a575c?.['task_id']||_0x4a575c?.[_0x4413d9(0x23c)]||_0x4a575c?.['id']||null;}catch{return null;}}async function X(_0x5b0230,_0x421a2b){const _0x378ea4=a0_0x4f40f9;let _0x1367ff=_0x421a2b['now']??Date[_0x378ea4(0x253)],_0xb96858=_0x1367ff(),_0x3f57ed=(_0x51c56b,_0x460ed1,_0xcdab3d,_0xb25893)=>{const _0x1e6841=_0x378ea4;_0x421a2b[_0x1e6841(0x212)](O(U({'from_alias':_0x5b0230['fromAlias'],'to_alias':_0x5b0230[_0x1e6841(0x25e)],'task_id':_0x460ed1,'parent_task_id':_0x5b0230[_0x1e6841(0x1ea)],'network_id':_0x5b0230[_0x1e6841(0x208)],'transport':_0x5b0230[_0x1e6841(0x206)],'status':_0x51c56b,'duration_ms':_0x1367ff()-_0xb96858,'lifecycle_tracking':_0x5b0230[_0x1e6841(0x20c)],..._0xcdab3d!==void 0x0?{'error_code':_0xb25893||_0x1e6841(0x202),'error_message':N(_0xcdab3d)}:{}})));};_0x3f57ed(_0x378ea4(0x21f),null);try{let _0x162bc9=await _0x421a2b['send'](),_0x590639=j(_0x162bc9);if(_0x590639)_0x3f57ed('delivered',_0x590639);else{if(_0x162bc9?.['ok']===!0x1||_0x162bc9?.[_0x378ea4(0x244)])_0x3f57ed(_0x378ea4(0x205),_0x590639,_0x162bc9?.[_0x378ea4(0x244)]||_0x378ea4(0x230),_0x378ea4(0x249));else _0x3f57ed('failed',null,_0x378ea4(0x255),_0x378ea4(0x23e));}return _0x162bc9;}catch(_0x5c2019){throw _0x3f57ed(_0x378ea4(0x205),null,_0x5c2019,_0x378ea4(0x202)),_0x5c2019;}}async function Y(_0xe9f2d7,_0x58f71e){const _0x5ab250=a0_0x4f40f9;return X({'fromAlias':_0xe9f2d7[_0x5ab250(0x227)],'toAlias':_0xe9f2d7[_0x5ab250(0x1e6)],'parentTaskId':_0xe9f2d7['parentTaskId']||null,'networkId':_0xe9f2d7[_0x5ab250(0x208)]||null,'transport':_0x5ab250(0x22e),'lifecycleTracking':_0x5ab250(0x221)},_0x58f71e);}class $ extends a0_0x1bc1fd{[a0_0x4f40f9(0x239)];[a0_0x4f40f9(0x1e6)];[a0_0x4f40f9(0x257)];[a0_0x4f40f9(0x24d)];[a0_0x4f40f9(0x214)];[a0_0x4f40f9(0x20a)];['reconnectDelay'];[a0_0x4f40f9(0x1e8)];[a0_0x4f40f9(0x1f8)];[a0_0x4f40f9(0x22d)]=!0x1;constructor(_0x533f20){const _0x8382c7=a0_0x4f40f9;super();if(this[_0x8382c7(0x239)]=_0x533f20[_0x8382c7(0x239)]['replace'](/\/$/,''),this[_0x8382c7(0x1e6)]=_0x533f20[_0x8382c7(0x1e6)],this[_0x8382c7(0x257)]=_0x533f20['token'],this[_0x8382c7(0x24d)]=_0x533f20['agent']||_0x8382c7(0x250),this[_0x8382c7(0x214)]=_0x8382c7(0x201)+_0x533f20[_0x8382c7(0x1e6)]+'-'+Date[_0x8382c7(0x253)]()[_0x8382c7(0x218)](0x24),this['heartbeatInterval']=_0x533f20[_0x8382c7(0x20a)]??0x2bf20,this[_0x8382c7(0x247)]=_0x533f20[_0x8382c7(0x247)]??0xbb8,_0x533f20[_0x8382c7(0x1fa)]!==!0x1)this['connect']();}['log'](_0x2c6295){const _0x4c70e0=a0_0x4f40f9;console[_0x4c70e0(0x212)]('['+new Date()[_0x4c70e0(0x1f9)]()['slice'](0x0,0x8)+_0x4c70e0(0x21b)+this[_0x4c70e0(0x1e6)]+']\x20'+_0x2c6295);}async['call'](_0x2a9bff,_0x3ee19e){const _0x59da48=a0_0x4f40f9;let _0xa48b88={'Content-Type':_0x59da48(0x1ef),'Accept':_0x59da48(0x20f)};if(this[_0x59da48(0x257)])_0xa48b88[_0x59da48(0x225)]=_0x59da48(0x228)+this[_0x59da48(0x257)];let _0x5a4a64=await(await fetch(this[_0x59da48(0x239)]+_0x59da48(0x21d),{'method':_0x59da48(0x215),'headers':_0xa48b88,'body':JSON[_0x59da48(0x216)]({'jsonrpc':_0x59da48(0x20d),'id':Date[_0x59da48(0x253)](),'method':_0x59da48(0x25a),'params':{'name':_0x2a9bff,'arguments':_0x3ee19e}})}))[_0x59da48(0x22c)](),_0x3cd375=_0x5a4a64[_0x59da48(0x259)](/data: (.+)/),_0xf56a8c=_0x3cd375?JSON[_0x59da48(0x20b)](_0x3cd375[0x1]):JSON[_0x59da48(0x20b)](_0x5a4a64),_0x4ba504=_0xf56a8c?.[_0x59da48(0x1fb)]?.[_0x59da48(0x24b)]?.[0x0]?.['text'];return _0x4ba504?JSON['parse'](_0x4ba504):_0xf56a8c;}async[a0_0x4f40f9(0x21a)](){const _0x26086=a0_0x4f40f9;if(this['running'])return;this[_0x26086(0x22d)]=!0x0,await this[_0x26086(0x21e)](_0x26086(0x240)),this['log'](_0x26086(0x241)),this[_0x26086(0x1e8)]=setInterval(()=>{const _0x4c4107=_0x26086;this[_0x4c4107(0x21e)](_0x4c4107(0x240))['catch'](_0x4bec2b=>this['log']('heartbeat\x20failed:\x20'+_0x4bec2b['message']));},this[_0x26086(0x20a)]),this[_0x26086(0x235)]();}async['disconnect'](){const _0x3fade0=a0_0x4f40f9;if(this[_0x3fade0(0x22d)]=!0x1,this[_0x3fade0(0x1f8)]?.['abort'](),this['heartbeatTimer'])clearInterval(this[_0x3fade0(0x1e8)]);await this['status'](_0x3fade0(0x23d))['catch'](()=>{}),this[_0x3fade0(0x212)](_0x3fade0(0x25d));}async[a0_0x4f40f9(0x1eb)](_0x449307,_0x5e0f34,_0x2e4f26=a0_0x4f40f9(0x217)){const _0xb7e47a=a0_0x4f40f9;return Y({'alias':_0x449307,'fromAlias':this['alias']},{'log':_0x28b396=>console['log'](_0x28b396),'send':()=>this['call'](_0xb7e47a(0x1f6),{'alias':_0x449307,'task':_0x5e0f34,'priority':_0x2e4f26,'from_session':this[_0xb7e47a(0x1e6)]})});}async['message'](_0x494dbc,_0x368f3b){const _0xe429dd=a0_0x4f40f9;return this['call'](_0xe429dd(0x258),{'alias':_0x494dbc,'message':_0x368f3b,'from_session':this[_0xe429dd(0x1e6)]});}async[a0_0x4f40f9(0x25b)](_0x46dc12,_0x35d74a,_0xda5129=a0_0x4f40f9(0x24c)){const _0xd8efb1=a0_0x4f40f9;return this[_0xd8efb1(0x1e9)](_0xd8efb1(0x22b),{'in_reply_to':_0x46dc12,'text':_0x35d74a,'status':_0xda5129});}async[a0_0x4f40f9(0x21e)](_0x214542,_0x44eecb){const _0x1d0523=a0_0x4f40f9;return this[_0x1d0523(0x1e9)]('report_status',{'resume_id':this[_0x1d0523(0x214)],'alias':this[_0x1d0523(0x1e6)],'status':_0x214542,'server':a0_0x5bd3d5(),'hostname':a0_0x5bd3d5(),'agent':this[_0x1d0523(0x24d)],'project_dir':process[_0x1d0523(0x242)](),..._0x44eecb});}async['getAllStatus'](){const _0x1e5a27=a0_0x4f40f9;return this[_0x1e5a27(0x1e9)](_0x1e5a27(0x248),{});}async[a0_0x4f40f9(0x24a)](_0x5d0f14,_0x5912c6){const _0xe9a0c1=a0_0x4f40f9;return this['call'](_0xe9a0c1(0x24a),{'message':_0x5d0f14,'filter_server':_0x5912c6?.[_0xe9a0c1(0x22a)],'filter_status':_0x5912c6?.[_0xe9a0c1(0x21e)]});}async[a0_0x4f40f9(0x235)](){const _0x53edaf=a0_0x4f40f9;let _0x51252b=encodeURIComponent(this[_0x53edaf(0x1e6)]),_0x34459c=this[_0x53edaf(0x239)]+'/events/'+_0x51252b,_0x2e5d14=this[_0x53edaf(0x247)];while(this['running']){try{this[_0x53edaf(0x1f8)]=new AbortController();let _0x26909c={'Accept':_0x53edaf(0x1ec)};if(this[_0x53edaf(0x257)])_0x26909c[_0x53edaf(0x225)]=_0x53edaf(0x228)+this[_0x53edaf(0x257)];let _0x4b186d=await fetch(_0x34459c,{'headers':_0x26909c,'signal':this['sseAbort'][_0x53edaf(0x210)]});if(!_0x4b186d['ok']||!_0x4b186d[_0x53edaf(0x1f1)]){this['log']('SSE\x20failed:\x20'+_0x4b186d[_0x53edaf(0x21e)]),await this['sleep'](_0x2e5d14),_0x2e5d14=Math['min'](_0x2e5d14*1.5,0xea60);continue;}_0x2e5d14=this[_0x53edaf(0x247)];let _0x48692d=_0x4b186d['body']['getReader'](),_0x1c30c8=new TextDecoder(),_0x2373da='';while(this[_0x53edaf(0x22d)]){let {done:_0x1a5c29,value:_0x4600fd}=await _0x48692d[_0x53edaf(0x200)]();if(_0x1a5c29)break;_0x2373da+=_0x1c30c8[_0x53edaf(0x226)](_0x4600fd,{'stream':!0x0});let _0x35abf9=_0x2373da['split']('\x0a');_0x2373da=_0x35abf9[_0x53edaf(0x252)]()||'';for(let _0x45a87b of _0x35abf9){if(!_0x45a87b[_0x53edaf(0x21c)](_0x53edaf(0x231)))continue;try{let _0x1dad48=JSON['parse'](_0x45a87b[_0x53edaf(0x1f3)](0x6));if(_0x1dad48[_0x53edaf(0x1e4)]===_0x53edaf(0x211)){this[_0x53edaf(0x212)](_0x53edaf(0x203)),this[_0x53edaf(0x1ff)](_0x53edaf(0x211));continue;}if(_0x1dad48[_0x53edaf(0x1e4)]==='new_task'||_0x1dad48[_0x53edaf(0x1e4)]===_0x53edaf(0x24e)||_0x1dad48[_0x53edaf(0x1e4)]==='broadcast')await this[_0x53edaf(0x25f)]();}catch{}}}}catch(_0x378e07){if(_0x378e07['name']==='AbortError')break;this[_0x53edaf(0x1ff)](_0x53edaf(0x244),_0x378e07),this[_0x53edaf(0x212)](_0x53edaf(0x1f7)+_0x378e07['message']);}if(this[_0x53edaf(0x22d)])this['emit'](_0x53edaf(0x25d)),this[_0x53edaf(0x212)](_0x53edaf(0x209)+_0x2e5d14/0x3e8+_0x53edaf(0x1fc)),await this[_0x53edaf(0x219)](_0x2e5d14),_0x2e5d14=Math['min'](_0x2e5d14*1.5,0xea60);}}async[a0_0x4f40f9(0x25f)](){const _0x3c0a00=a0_0x4f40f9;try{let _0x3643cd=(await this[_0x3c0a00(0x1e9)](_0x3c0a00(0x1f5),{'alias':this[_0x3c0a00(0x1e6)],'limit':0xa}))?.[_0x3c0a00(0x256)]||[];for(let _0x37a1c0 of _0x3643cd)await this['call'](_0x3c0a00(0x238),{'alias':this[_0x3c0a00(0x1e6)],'message_id':_0x37a1c0['id']}),this[_0x3c0a00(0x212)]('←\x20'+_0x37a1c0[_0x3c0a00(0x22f)]+':\x20'+_0x37a1c0[_0x3c0a00(0x24b)][_0x3c0a00(0x1f3)](0x0,0x3c)),this[_0x3c0a00(0x1ff)](_0x3c0a00(0x1e5),_0x37a1c0),this['emit']('message',_0x37a1c0);}catch(_0x1b2585){this[_0x3c0a00(0x212)]('inbox\x20error:\x20'+_0x1b2585['message']);}}[a0_0x4f40f9(0x219)](_0x55a7ab){return new Promise(_0x1d6bcb=>setTimeout(_0x1d6bcb,_0x55a7ab));}}var F=$;export{F as default,$ as CommHub};
1
+ const a0_0x1e76f0=a0_0x4b14;(function(_0x4309df,_0x494005){const _0x428fed=a0_0x4b14,_0x3a97e6=_0x4309df();while(!![]){try{const _0x377aa2=-parseInt(_0x428fed(0xd0))/0x1+parseInt(_0x428fed(0x116))/0x2*(parseInt(_0x428fed(0xf0))/0x3)+parseInt(_0x428fed(0x10a))/0x4+parseInt(_0x428fed(0xe2))/0x5+parseInt(_0x428fed(0xd8))/0x6+-parseInt(_0x428fed(0xc8))/0x7*(parseInt(_0x428fed(0xdc))/0x8)+-parseInt(_0x428fed(0xa0))/0x9;if(_0x377aa2===_0x494005)break;else _0x3a97e6['push'](_0x3a97e6['shift']());}catch(_0x933340){_0x3a97e6['push'](_0x3a97e6['shift']());}}}(a0_0x4e8b,0x82205));import{EventEmitter as a0_0x373a4c}from'events';import{hostname as a0_0x492e26}from'os';function a0_0x4e8b(){const _0x3a750e=['type','5177565xQiRyh','SSE\x20connected','AbortError','send_message','error_code','lifecycleTracking','<unknown>','connectSSE','get_inbox','\x20duration_ms=','disconnect','new_task','running','read','parse','application/json','task_id','text','sdk-','Bearer\x20','result','idle','from_alias','to_alias','\x20lifecycle=','connect','network_id','\x20transport=','ack_inbox','completed','lifecycle_tracking','offline','message','error_message','getReader','server','stringify','emit','resumeId','match','336kIMiiw','agent','body','data:\x20','sending','toTimeString','signal','toString','554244helYEW','2.0','delivered','heartbeatTimer','name','SSE\x20reconnecting\x20in\x20','/events/','send_task','2699154cAzTcX','catch','sleep','pop','135360fXvcJW','broadcast','token','disconnected','sseAbort','slice','3477925eoUNTW','string','fromAlias','split','content','report_status','getAllStatus','failed','messages','networkId','task','SSE\x20error:\x20','json','mcp_http','1311rpJwiI','new_message','missing_task_id','get_all_status','log','transport','decode','replace','alias','heartbeatInterval','cwd','url','parentTaskId','[REDACTED]','Authorization','heartbeat\x20failed:\x20','reply','now','\x20error=','task.expired','status','call','task.send.delivered','duration_ms','error','send','3138960HDJruc','startsWith','reconnectDelay','connected','processInbox','send_failed','application/json,\x20text/event-stream','from_session','task.ack','registered','toAlias','task.send.failed','2492sqpYQG','min','<missing>','CommHub\x20rejected\x20task','message_id'];a0_0x4e8b=function(){return _0x3a750e;};return a0_0x4e8b();}function a0_0x4b14(_0x221983,_0x2f57e8){_0x221983=_0x221983-0x9c;const _0x4e8b03=a0_0x4e8b();let _0x4b14bd=_0x4e8b03[_0x221983];return _0x4b14bd;}var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x7180ce,_0xaa2a53)=>(_0x7180ce??_0xaa2a53)[a0_0x1e76f0(0xf7)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x1e76f0(0xe1)](0x0,0xf0);function N(_0x559b9e){const _0x459802=a0_0x1e76f0;return(_0x559b9e instanceof Error?_0x559b9e[_0x459802(0xc0)]:String(_0x559b9e??'unknown\x20error'))['replace'](K,_0x459802(0xfd))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x4d0588,_0x4b1cbd=process.env.ANET_TASK_TRACE_FORMAT===a0_0x1e76f0(0xee)){const _0x2527b3=a0_0x1e76f0;if(_0x4b1cbd)return JSON[_0x2527b3(0xc4)](_0x4d0588);let _0x21fb11=L(_0x4d0588['parent_task_id'],_0x2527b3(0x9c)),_0xd9f519=L(_0x4d0588[_0x2527b3(0xb0)],'<pending>'),_0x11ea0f=_0x4d0588[_0x2527b3(0xa4)]?_0x2527b3(0x102)+_0x4d0588[_0x2527b3(0xa4)]+':'+(_0x4d0588[_0x2527b3(0xc1)]??''):'';return'[commhub:task]\x20'+_0x4d0588[_0x2527b3(0x104)]+'\x20from='+L(_0x4d0588[_0x2527b3(0xb6)],_0x2527b3(0xa6))+'\x20to='+L(_0x4d0588[_0x2527b3(0xb7)],_0x2527b3(0xa6))+'\x20task_id='+_0xd9f519+'\x20parent_task_id='+_0x21fb11+'\x20network_id='+L(_0x4d0588[_0x2527b3(0xba)],_0x2527b3(0xa6))+_0x2527b3(0xbb)+_0x4d0588['transport']+_0x2527b3(0xa9)+_0x4d0588[_0x2527b3(0x107)]+_0x2527b3(0xb8)+_0x4d0588[_0x2527b3(0xbe)]+_0x11ea0f;}function U(_0x56e59f){const _0x396c52=a0_0x1e76f0;return{'event':{'sending':'task.send.start','delivered':_0x396c52(0x106),'failed':_0x396c52(0x115),'acked':_0x396c52(0x112),'started':'task.started','replied':'task.replied','expired':_0x396c52(0x103)}[_0x56e59f[_0x396c52(0x104)]],..._0x56e59f};}function j(_0x1cf393){const _0x4e0ae0=a0_0x1e76f0;let _0x4797c2=_0x1cf393?.['task_id']||_0x1cf393?.['message_id']||_0x1cf393?.['id'];if(_0x4797c2)return String(_0x4797c2);let _0x313408=_0x1cf393?.[_0x4e0ae0(0xe6)]?.[0x0]?.[_0x4e0ae0(0xb1)];if(typeof _0x313408!==_0x4e0ae0(0xe3))return null;try{let _0x58e2d2=JSON[_0x4e0ae0(0xae)](_0x313408);return _0x58e2d2?.[_0x4e0ae0(0xb0)]||_0x58e2d2?.[_0x4e0ae0(0x9e)]||_0x58e2d2?.['id']||null;}catch{return null;}}async function X(_0x233945,_0x552ce5){const _0x5de635=a0_0x1e76f0;let _0x52dbc7=_0x552ce5['now']??Date[_0x5de635(0x101)],_0x5dc235=_0x52dbc7(),_0x54f119=(_0x5830fa,_0x4dc165,_0x10e73e,_0x38e2c7)=>{const _0x28ae80=_0x5de635;_0x552ce5[_0x28ae80(0xf4)](O(U({'from_alias':_0x233945[_0x28ae80(0xe4)],'to_alias':_0x233945[_0x28ae80(0x114)],'task_id':_0x4dc165,'parent_task_id':_0x233945[_0x28ae80(0xfc)],'network_id':_0x233945[_0x28ae80(0xeb)],'transport':_0x233945[_0x28ae80(0xf5)],'status':_0x5830fa,'duration_ms':_0x52dbc7()-_0x5dc235,'lifecycle_tracking':_0x233945[_0x28ae80(0xa5)],..._0x10e73e!==void 0x0?{'error_code':_0x38e2c7||_0x28ae80(0x10f),'error_message':N(_0x10e73e)}:{}})));};_0x54f119(_0x5de635(0xcc),null);try{let _0x17f8c7=await _0x552ce5[_0x5de635(0x109)](),_0x2f360c=j(_0x17f8c7);if(_0x2f360c)_0x54f119(_0x5de635(0xd2),_0x2f360c);else{if(_0x17f8c7?.['ok']===!0x1||_0x17f8c7?.['error'])_0x54f119(_0x5de635(0xe9),_0x2f360c,_0x17f8c7?.[_0x5de635(0x108)]||_0x5de635(0x9d),'send_rejected');else _0x54f119(_0x5de635(0xe9),null,'CommHub\x20response\x20omitted\x20task_id',_0x5de635(0xf2));}return _0x17f8c7;}catch(_0x3fb1da){throw _0x54f119(_0x5de635(0xe9),null,_0x3fb1da,_0x5de635(0x10f)),_0x3fb1da;}}async function Y(_0x57049c,_0x39fea0){const _0x41a3ce=a0_0x1e76f0;return X({'fromAlias':_0x57049c['fromAlias'],'toAlias':_0x57049c[_0x41a3ce(0xf8)],'parentTaskId':_0x57049c[_0x41a3ce(0xfc)]||null,'networkId':_0x57049c[_0x41a3ce(0xeb)]||null,'transport':_0x41a3ce(0xef),'lifecycleTracking':'not_tracked'},_0x39fea0);}class $ extends a0_0x373a4c{['url'];[a0_0x1e76f0(0xf8)];['token'];[a0_0x1e76f0(0xc9)];['resumeId'];[a0_0x1e76f0(0xf9)];[a0_0x1e76f0(0x10c)];[a0_0x1e76f0(0xd3)];[a0_0x1e76f0(0xe0)];[a0_0x1e76f0(0xac)]=!0x1;constructor(_0x173238){const _0x24eb9c=a0_0x1e76f0;super();if(this[_0x24eb9c(0xfb)]=_0x173238[_0x24eb9c(0xfb)][_0x24eb9c(0xf7)](/\/$/,''),this['alias']=_0x173238[_0x24eb9c(0xf8)],this['token']=_0x173238[_0x24eb9c(0xde)],this[_0x24eb9c(0xc9)]=_0x173238[_0x24eb9c(0xc9)]||'sdk',this[_0x24eb9c(0xc6)]=_0x24eb9c(0xb2)+_0x173238[_0x24eb9c(0xf8)]+'-'+Date[_0x24eb9c(0x101)]()[_0x24eb9c(0xcf)](0x24),this[_0x24eb9c(0xf9)]=_0x173238['heartbeatInterval']??0x2bf20,this[_0x24eb9c(0x10c)]=_0x173238[_0x24eb9c(0x10c)]??0xbb8,_0x173238['autoConnect']!==!0x1)this[_0x24eb9c(0xb9)]();}[a0_0x1e76f0(0xf4)](_0x20a987){const _0x3f2fab=a0_0x1e76f0;console[_0x3f2fab(0xf4)]('['+new Date()[_0x3f2fab(0xcd)]()['slice'](0x0,0x8)+']\x20[commhub:'+this['alias']+']\x20'+_0x20a987);}async[a0_0x1e76f0(0x105)](_0x37341a,_0x10d6b8){const _0x179adb=a0_0x1e76f0;let _0x2a4e14={'Content-Type':_0x179adb(0xaf),'Accept':_0x179adb(0x110)};if(this[_0x179adb(0xde)])_0x2a4e14['Authorization']=_0x179adb(0xb3)+this[_0x179adb(0xde)];let _0x5828a3=await(await fetch(this[_0x179adb(0xfb)]+'/mcp',{'method':'POST','headers':_0x2a4e14,'body':JSON['stringify']({'jsonrpc':_0x179adb(0xd1),'id':Date[_0x179adb(0x101)](),'method':'tools/call','params':{'name':_0x37341a,'arguments':_0x10d6b8}})}))[_0x179adb(0xb1)](),_0x1763a7=_0x5828a3[_0x179adb(0xc7)](/data: (.+)/),_0xf8d684=_0x1763a7?JSON[_0x179adb(0xae)](_0x1763a7[0x1]):JSON[_0x179adb(0xae)](_0x5828a3),_0x5c9b81=_0xf8d684?.[_0x179adb(0xb4)]?.['content']?.[0x0]?.['text'];return _0x5c9b81?JSON[_0x179adb(0xae)](_0x5c9b81):_0xf8d684;}async[a0_0x1e76f0(0xb9)](){const _0x54314b=a0_0x1e76f0;if(this[_0x54314b(0xac)])return;this[_0x54314b(0xac)]=!0x0,await this[_0x54314b(0x104)](_0x54314b(0xb5)),this[_0x54314b(0xf4)](_0x54314b(0x113)),this[_0x54314b(0xd3)]=setInterval(()=>{const _0xbeeb47=_0x54314b;this[_0xbeeb47(0x104)](_0xbeeb47(0xb5))[_0xbeeb47(0xd9)](_0x222819=>this[_0xbeeb47(0xf4)](_0xbeeb47(0xff)+_0x222819['message']));},this[_0x54314b(0xf9)]),this[_0x54314b(0xa7)]();}async[a0_0x1e76f0(0xaa)](){const _0x4ea780=a0_0x1e76f0;if(this[_0x4ea780(0xac)]=!0x1,this[_0x4ea780(0xe0)]?.['abort'](),this[_0x4ea780(0xd3)])clearInterval(this['heartbeatTimer']);await this[_0x4ea780(0x104)](_0x4ea780(0xbf))[_0x4ea780(0xd9)](()=>{}),this['log']('disconnected');}async[a0_0x1e76f0(0x109)](_0x30ec6e,_0x4bf35a,_0x1b6382='normal'){const _0x16966a=a0_0x1e76f0;return Y({'alias':_0x30ec6e,'fromAlias':this[_0x16966a(0xf8)]},{'log':_0x9935be=>console[_0x16966a(0xf4)](_0x9935be),'send':()=>this['call'](_0x16966a(0xd7),{'alias':_0x30ec6e,'task':_0x4bf35a,'priority':_0x1b6382,'from_session':this[_0x16966a(0xf8)]})});}async[a0_0x1e76f0(0xc0)](_0x59d9b5,_0x287db1){const _0x3ff1f8=a0_0x1e76f0;return this[_0x3ff1f8(0x105)](_0x3ff1f8(0xa3),{'alias':_0x59d9b5,'message':_0x287db1,'from_session':this[_0x3ff1f8(0xf8)]});}async[a0_0x1e76f0(0x100)](_0x4dea48,_0x1bd70d,_0x120c51=a0_0x1e76f0(0xbd)){const _0x260bdc=a0_0x1e76f0;return this[_0x260bdc(0x105)]('send_reply',{'in_reply_to':_0x4dea48,'text':_0x1bd70d,'status':_0x120c51});}async[a0_0x1e76f0(0x104)](_0x1420b1,_0x40c0a5){const _0x339080=a0_0x1e76f0;return this[_0x339080(0x105)](_0x339080(0xe7),{'resume_id':this[_0x339080(0xc6)],'alias':this[_0x339080(0xf8)],'status':_0x1420b1,'server':a0_0x492e26(),'hostname':a0_0x492e26(),'agent':this[_0x339080(0xc9)],'project_dir':process[_0x339080(0xfa)](),..._0x40c0a5});}async[a0_0x1e76f0(0xe8)](){const _0x529cd1=a0_0x1e76f0;return this['call'](_0x529cd1(0xf3),{});}async[a0_0x1e76f0(0xdd)](_0x4e5fbe,_0x13e59a){const _0xf322db=a0_0x1e76f0;return this[_0xf322db(0x105)](_0xf322db(0xdd),{'message':_0x4e5fbe,'filter_server':_0x13e59a?.[_0xf322db(0xc3)],'filter_status':_0x13e59a?.[_0xf322db(0x104)]});}async[a0_0x1e76f0(0xa7)](){const _0x42619e=a0_0x1e76f0;let _0x2bdc92=encodeURIComponent(this['alias']),_0x421a16=this[_0x42619e(0xfb)]+_0x42619e(0xd6)+_0x2bdc92,_0x1160ac=this[_0x42619e(0x10c)];while(this[_0x42619e(0xac)]){try{this[_0x42619e(0xe0)]=new AbortController();let _0x5db312={'Accept':'text/event-stream'};if(this['token'])_0x5db312[_0x42619e(0xfe)]=_0x42619e(0xb3)+this[_0x42619e(0xde)];let _0x7aa7e=await fetch(_0x421a16,{'headers':_0x5db312,'signal':this[_0x42619e(0xe0)][_0x42619e(0xce)]});if(!_0x7aa7e['ok']||!_0x7aa7e[_0x42619e(0xca)]){this[_0x42619e(0xf4)]('SSE\x20failed:\x20'+_0x7aa7e[_0x42619e(0x104)]),await this[_0x42619e(0xda)](_0x1160ac),_0x1160ac=Math[_0x42619e(0x117)](_0x1160ac*1.5,0xea60);continue;}_0x1160ac=this[_0x42619e(0x10c)];let _0x4a9b34=_0x7aa7e[_0x42619e(0xca)][_0x42619e(0xc2)](),_0x5364b8=new TextDecoder(),_0x45d85b='';while(this['running']){let {done:_0x37b83c,value:_0xe271dc}=await _0x4a9b34[_0x42619e(0xad)]();if(_0x37b83c)break;_0x45d85b+=_0x5364b8[_0x42619e(0xf6)](_0xe271dc,{'stream':!0x0});let _0xa0ec03=_0x45d85b[_0x42619e(0xe5)]('\x0a');_0x45d85b=_0xa0ec03[_0x42619e(0xdb)]()||'';for(let _0x27ef28 of _0xa0ec03){if(!_0x27ef28[_0x42619e(0x10b)](_0x42619e(0xcb)))continue;try{let _0x5b6ce2=JSON[_0x42619e(0xae)](_0x27ef28['slice'](0x6));if(_0x5b6ce2[_0x42619e(0x9f)]===_0x42619e(0x10d)){this[_0x42619e(0xf4)](_0x42619e(0xa1)),this['emit'](_0x42619e(0x10d));continue;}if(_0x5b6ce2['type']===_0x42619e(0xab)||_0x5b6ce2[_0x42619e(0x9f)]===_0x42619e(0xf1)||_0x5b6ce2['type']==='broadcast')await this[_0x42619e(0x10e)]();}catch{}}}}catch(_0x542532){if(_0x542532[_0x42619e(0xd4)]===_0x42619e(0xa2))break;this[_0x42619e(0xc5)](_0x42619e(0x108),_0x542532),this[_0x42619e(0xf4)](_0x42619e(0xed)+_0x542532[_0x42619e(0xc0)]);}if(this[_0x42619e(0xac)])this[_0x42619e(0xc5)](_0x42619e(0xdf)),this[_0x42619e(0xf4)](_0x42619e(0xd5)+_0x1160ac/0x3e8+'s...'),await this['sleep'](_0x1160ac),_0x1160ac=Math[_0x42619e(0x117)](_0x1160ac*1.5,0xea60);}}async[a0_0x1e76f0(0x10e)](){const _0x9bcee7=a0_0x1e76f0;try{let _0x566c75=(await this['call'](_0x9bcee7(0xa8),{'alias':this[_0x9bcee7(0xf8)],'limit':0xa}))?.[_0x9bcee7(0xea)]||[];for(let _0x530a78 of _0x566c75)await this[_0x9bcee7(0x105)](_0x9bcee7(0xbc),{'alias':this['alias'],'message_id':_0x530a78['id']}),this[_0x9bcee7(0xf4)]('←\x20'+_0x530a78[_0x9bcee7(0x111)]+':\x20'+_0x530a78[_0x9bcee7(0xe6)][_0x9bcee7(0xe1)](0x0,0x3c)),this[_0x9bcee7(0xc5)](_0x9bcee7(0xec),_0x530a78),this[_0x9bcee7(0xc5)](_0x9bcee7(0xc0),_0x530a78);}catch(_0xfd2267){this[_0x9bcee7(0xf4)]('inbox\x20error:\x20'+_0xfd2267[_0x9bcee7(0xc0)]);}}['sleep'](_0x3e38fe){return new Promise(_0x56fe9a=>setTimeout(_0x56fe9a,_0x3e38fe));}}var F=$;export{F as default,$ as CommHub};