@sleep2agi/agent-network 2.3.0-preview.167 → 2.3.0-preview.168

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_0x5bf240=a0_0xe272;function a0_0x4afb(){const _0x44d283=['89288yXqeWk','failed','disconnected','\x20task_id=','\x20network_id=','content','connectSSE','sdk-','slice','stringify','now','get_all_status','sending','idle','<unknown>','4Ikxkje','3841797GnoJCy','json','SSE\x20reconnecting\x20in\x20','broadcast','ack_inbox','messages','url','parent_task_id','emit','task.send.failed','registered','processInbox','text','getReader','lifecycle_tracking','name','min','get_inbox','[commhub:task]\x20','type','Authorization','send_task','send_rejected','call','agent','to_alias','connect','delivered','CommHub\x20response\x20omitted\x20task_id','\x20error=','2.0','catch','autoConnect','replace','lifecycleTracking','new_message','task.replied','task_id','task.started','SSE\x20connected','7258730SdmOXF','alias','application/json,\x20text/event-stream','disconnect','\x20transport=','2787936HWocMo','fromAlias','pop','from_session','74047HqldRa','heartbeatInterval','task','\x20duration_ms=','/events/','error','running','parentTaskId','body','parse','log','send_message','<missing>','send_failed','POST','token','abort','/mcp','\x20lifecycle=','error_code','task.ack','\x20parent_task_id=','reply','task.expired','completed','unknown\x20error','reconnectDelay','status','signal','duration_ms','31831540EZyGeX','getAllStatus','Bearer\x20','network_id','<pending>','text/event-stream','heartbeatTimer','AbortError','toAlias','networkId','report_status','sleep','read','startsWith','CommHub\x20rejected\x20task','558CwnyRR','[REDACTED]','\x20from=','send','toTimeString','resumeId','s...','new_task','from_alias','message_id','normal','data:\x20','sseAbort','6826225QmTDda','12oxCbbx',']\x20[commhub:','tools/call','message','mcp_http','connected','match'];a0_0x4afb=function(){return _0x44d283;};return a0_0x4afb();}(function(_0x1f14d6,_0x397f1a){const _0xfe3dd2=a0_0xe272,_0x57460b=_0x1f14d6();while(!![]){try{const _0x5130d2=-parseInt(_0xfe3dd2(0x14e))/0x1*(parseInt(_0xfe3dd2(0x106))/0x2)+-parseInt(_0xfe3dd2(0x11d))/0x3*(parseInt(_0xfe3dd2(0x11c))/0x4)+parseInt(_0xfe3dd2(0x145))/0x5+-parseInt(_0xfe3dd2(0x14a))/0x6+-parseInt(_0xfe3dd2(0x105))/0x7+parseInt(_0xfe3dd2(0x10d))/0x8*(-parseInt(_0xfe3dd2(0xf8))/0x9)+parseInt(_0xfe3dd2(0x16c))/0xa;if(_0x5130d2===_0x397f1a)break;else _0x57460b['push'](_0x57460b['shift']());}catch(_0x25d146){_0x57460b['push'](_0x57460b['shift']());}}}(a0_0x4afb,0xbdfde));import{EventEmitter as a0_0x27b2f7}from'events';import{hostname as a0_0x386df4}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x11df3d,_0x56dac0)=>(_0x11df3d??_0x56dac0)[a0_0x5bf240(0x13e)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x5bf240(0x115)](0x0,0xf0);function N(_0x2b4557){const _0x4b2304=a0_0x5bf240;return(_0x2b4557 instanceof Error?_0x2b4557['message']:String(_0x2b4557??_0x4b2304(0x167)))['replace'](K,_0x4b2304(0xf9))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x4b2304(0x115)](0x0,0xf0);}function O(_0x393b53,_0x27bb21=process.env.ANET_TASK_TRACE_FORMAT===a0_0x5bf240(0x11e)){const _0x51b279=a0_0x5bf240;if(_0x27bb21)return JSON[_0x51b279(0x116)](_0x393b53);let _0x5e1a78=L(_0x393b53[_0x51b279(0x124)],_0x51b279(0x15a)),_0x463f27=L(_0x393b53[_0x51b279(0x142)],_0x51b279(0x170)),_0x4daddd=_0x393b53['error_code']?_0x51b279(0x13a)+_0x393b53[_0x51b279(0x161)]+':'+(_0x393b53['error_message']??''):'';return _0x51b279(0x12f)+_0x393b53[_0x51b279(0x169)]+_0x51b279(0xfa)+L(_0x393b53[_0x51b279(0x100)],_0x51b279(0x11b))+'\x20to='+L(_0x393b53[_0x51b279(0x136)],_0x51b279(0x11b))+_0x51b279(0x110)+_0x463f27+_0x51b279(0x163)+_0x5e1a78+_0x51b279(0x111)+L(_0x393b53[_0x51b279(0x16f)],_0x51b279(0x11b))+_0x51b279(0x149)+_0x393b53['transport']+_0x51b279(0x151)+_0x393b53[_0x51b279(0x16b)]+_0x51b279(0x160)+_0x393b53[_0x51b279(0x12b)]+_0x4daddd;}function a0_0xe272(_0x1b28d2,_0x5dfa3a){_0x1b28d2=_0x1b28d2-0xf3;const _0x4afbe1=a0_0x4afb();let _0xe272ff=_0x4afbe1[_0x1b28d2];return _0xe272ff;}function U(_0x5afb4d){const _0x5c1044=a0_0x5bf240;return{'event':{'sending':'task.send.start','delivered':'task.send.delivered','failed':_0x5c1044(0x126),'acked':_0x5c1044(0x162),'started':_0x5c1044(0x143),'replied':_0x5c1044(0x141),'expired':_0x5c1044(0x165)}[_0x5afb4d['status']],..._0x5afb4d};}function j(_0xf6f309){const _0x171882=a0_0x5bf240;let _0x1eb0cb=_0xf6f309?.[_0x171882(0x142)]||_0xf6f309?.[_0x171882(0x101)]||_0xf6f309?.['id'];if(_0x1eb0cb)return String(_0x1eb0cb);let _0x5855de=_0xf6f309?.[_0x171882(0x112)]?.[0x0]?.['text'];if(typeof _0x5855de!=='string')return null;try{let _0x2f8980=JSON[_0x171882(0x157)](_0x5855de);return _0x2f8980?.['task_id']||_0x2f8980?.[_0x171882(0x101)]||_0x2f8980?.['id']||null;}catch{return null;}}async function X(_0x590cca,_0x510f4a){const _0x1bf2e6=a0_0x5bf240;let _0x7a7940=_0x510f4a['now']??Date[_0x1bf2e6(0x117)],_0x139580=_0x7a7940(),_0x26615a=(_0x733abd,_0x12aada,_0x301440,_0xb82330)=>{const _0x41299b=_0x1bf2e6;_0x510f4a[_0x41299b(0x158)](O(U({'from_alias':_0x590cca[_0x41299b(0x14b)],'to_alias':_0x590cca[_0x41299b(0x174)],'task_id':_0x12aada,'parent_task_id':_0x590cca[_0x41299b(0x155)],'network_id':_0x590cca[_0x41299b(0x175)],'transport':_0x590cca['transport'],'status':_0x733abd,'duration_ms':_0x7a7940()-_0x139580,'lifecycle_tracking':_0x590cca[_0x41299b(0x13f)],..._0x301440!==void 0x0?{'error_code':_0xb82330||_0x41299b(0x15b),'error_message':N(_0x301440)}:{}})));};_0x26615a(_0x1bf2e6(0x119),null);try{let _0x48a846=await _0x510f4a[_0x1bf2e6(0xfb)](),_0x517a2f=j(_0x48a846);if(_0x517a2f)_0x26615a(_0x1bf2e6(0x138),_0x517a2f);else{if(_0x48a846?.['ok']===!0x1||_0x48a846?.[_0x1bf2e6(0x153)])_0x26615a(_0x1bf2e6(0x10e),_0x517a2f,_0x48a846?.[_0x1bf2e6(0x153)]||_0x1bf2e6(0xf7),_0x1bf2e6(0x133));else _0x26615a('failed',null,_0x1bf2e6(0x139),'missing_task_id');}return _0x48a846;}catch(_0x3bbaf5){throw _0x26615a(_0x1bf2e6(0x10e),null,_0x3bbaf5,'send_failed'),_0x3bbaf5;}}async function Y(_0x14d735,_0x784e13){const _0x352cc1=a0_0x5bf240;return X({'fromAlias':_0x14d735[_0x352cc1(0x14b)],'toAlias':_0x14d735['alias'],'parentTaskId':_0x14d735['parentTaskId']||null,'networkId':_0x14d735[_0x352cc1(0x175)]||null,'transport':_0x352cc1(0x10a),'lifecycleTracking':'not_tracked'},_0x784e13);}class $ extends a0_0x27b2f7{[a0_0x5bf240(0x123)];[a0_0x5bf240(0x146)];[a0_0x5bf240(0x15d)];[a0_0x5bf240(0x135)];['resumeId'];['heartbeatInterval'];[a0_0x5bf240(0x168)];[a0_0x5bf240(0x172)];[a0_0x5bf240(0x104)];['running']=!0x1;constructor(_0x181673){const _0x498efe=a0_0x5bf240;super();if(this[_0x498efe(0x123)]=_0x181673[_0x498efe(0x123)][_0x498efe(0x13e)](/\/$/,''),this[_0x498efe(0x146)]=_0x181673[_0x498efe(0x146)],this[_0x498efe(0x15d)]=_0x181673['token'],this[_0x498efe(0x135)]=_0x181673[_0x498efe(0x135)]||'sdk',this[_0x498efe(0xfd)]=_0x498efe(0x114)+_0x181673[_0x498efe(0x146)]+'-'+Date['now']()['toString'](0x24),this[_0x498efe(0x14f)]=_0x181673[_0x498efe(0x14f)]??0x2bf20,this[_0x498efe(0x168)]=_0x181673[_0x498efe(0x168)]??0xbb8,_0x181673[_0x498efe(0x13d)]!==!0x1)this[_0x498efe(0x137)]();}[a0_0x5bf240(0x158)](_0x158e65){const _0x46f393=a0_0x5bf240;console[_0x46f393(0x158)]('['+new Date()[_0x46f393(0xfc)]()['slice'](0x0,0x8)+_0x46f393(0x107)+this[_0x46f393(0x146)]+']\x20'+_0x158e65);}async['call'](_0x1fc303,_0x15e6c4){const _0x1ded1b=a0_0x5bf240;let _0x954f91={'Content-Type':'application/json','Accept':_0x1ded1b(0x147)};if(this[_0x1ded1b(0x15d)])_0x954f91['Authorization']=_0x1ded1b(0x16e)+this['token'];let _0x33d706=await(await fetch(this['url']+_0x1ded1b(0x15f),{'method':_0x1ded1b(0x15c),'headers':_0x954f91,'body':JSON['stringify']({'jsonrpc':_0x1ded1b(0x13b),'id':Date['now'](),'method':_0x1ded1b(0x108),'params':{'name':_0x1fc303,'arguments':_0x15e6c4}})}))[_0x1ded1b(0x129)](),_0x408c30=_0x33d706[_0x1ded1b(0x10c)](/data: (.+)/),_0x6e0d15=_0x408c30?JSON[_0x1ded1b(0x157)](_0x408c30[0x1]):JSON[_0x1ded1b(0x157)](_0x33d706),_0x5f097a=_0x6e0d15?.['result']?.['content']?.[0x0]?.[_0x1ded1b(0x129)];return _0x5f097a?JSON[_0x1ded1b(0x157)](_0x5f097a):_0x6e0d15;}async[a0_0x5bf240(0x137)](){const _0x1c516e=a0_0x5bf240;if(this['running'])return;this[_0x1c516e(0x154)]=!0x0,await this['status']('idle'),this[_0x1c516e(0x158)](_0x1c516e(0x127)),this['heartbeatTimer']=setInterval(()=>{const _0x3deaed=_0x1c516e;this[_0x3deaed(0x169)](_0x3deaed(0x11a))[_0x3deaed(0x13c)](_0x3a4008=>this[_0x3deaed(0x158)]('heartbeat\x20failed:\x20'+_0x3a4008[_0x3deaed(0x109)]));},this[_0x1c516e(0x14f)]),this['connectSSE']();}async[a0_0x5bf240(0x148)](){const _0xe247b2=a0_0x5bf240;if(this[_0xe247b2(0x154)]=!0x1,this[_0xe247b2(0x104)]?.[_0xe247b2(0x15e)](),this[_0xe247b2(0x172)])clearInterval(this[_0xe247b2(0x172)]);await this['status']('offline')[_0xe247b2(0x13c)](()=>{}),this[_0xe247b2(0x158)]('disconnected');}async[a0_0x5bf240(0xfb)](_0x207f4a,_0x579908,_0x280b5b=a0_0x5bf240(0x102)){const _0x11cbb7=a0_0x5bf240;return Y({'alias':_0x207f4a,'fromAlias':this['alias']},{'log':_0x20d01b=>console[_0x11cbb7(0x158)](_0x20d01b),'send':()=>this[_0x11cbb7(0x134)](_0x11cbb7(0x132),{'alias':_0x207f4a,'task':_0x579908,'priority':_0x280b5b,'from_session':this['alias']})});}async[a0_0x5bf240(0x109)](_0x2f02d0,_0x5e49d6){const _0x11e4f4=a0_0x5bf240;return this['call'](_0x11e4f4(0x159),{'alias':_0x2f02d0,'message':_0x5e49d6,'from_session':this[_0x11e4f4(0x146)]});}async[a0_0x5bf240(0x164)](_0x2b6b7a,_0x4297b5,_0x25336c=a0_0x5bf240(0x166)){const _0x2c2f32=a0_0x5bf240;return this[_0x2c2f32(0x134)]('send_reply',{'in_reply_to':_0x2b6b7a,'text':_0x4297b5,'status':_0x25336c});}async['status'](_0x3544b3,_0x593f7d){const _0x5858a1=a0_0x5bf240;return this[_0x5858a1(0x134)](_0x5858a1(0xf3),{'resume_id':this[_0x5858a1(0xfd)],'alias':this[_0x5858a1(0x146)],'status':_0x3544b3,'server':a0_0x386df4(),'hostname':a0_0x386df4(),'agent':this[_0x5858a1(0x135)],'project_dir':process['cwd'](),..._0x593f7d});}async[a0_0x5bf240(0x16d)](){const _0x4f958d=a0_0x5bf240;return this[_0x4f958d(0x134)](_0x4f958d(0x118),{});}async[a0_0x5bf240(0x120)](_0x25f107,_0x522cb6){const _0x3015c4=a0_0x5bf240;return this[_0x3015c4(0x134)](_0x3015c4(0x120),{'message':_0x25f107,'filter_server':_0x522cb6?.['server'],'filter_status':_0x522cb6?.[_0x3015c4(0x169)]});}async[a0_0x5bf240(0x113)](){const _0x255bb4=a0_0x5bf240;let _0x5331ac=encodeURIComponent(this[_0x255bb4(0x146)]),_0x1510de=this['url']+_0x255bb4(0x152)+_0x5331ac,_0x556d9a=this[_0x255bb4(0x168)];while(this[_0x255bb4(0x154)]){try{this[_0x255bb4(0x104)]=new AbortController();let _0x17f23d={'Accept':_0x255bb4(0x171)};if(this[_0x255bb4(0x15d)])_0x17f23d[_0x255bb4(0x131)]=_0x255bb4(0x16e)+this['token'];let _0xb3543b=await fetch(_0x1510de,{'headers':_0x17f23d,'signal':this['sseAbort'][_0x255bb4(0x16a)]});if(!_0xb3543b['ok']||!_0xb3543b[_0x255bb4(0x156)]){this[_0x255bb4(0x158)]('SSE\x20failed:\x20'+_0xb3543b[_0x255bb4(0x169)]),await this[_0x255bb4(0xf4)](_0x556d9a),_0x556d9a=Math[_0x255bb4(0x12d)](_0x556d9a*1.5,0xea60);continue;}_0x556d9a=this[_0x255bb4(0x168)];let _0xa288bf=_0xb3543b[_0x255bb4(0x156)][_0x255bb4(0x12a)](),_0x4f3784=new TextDecoder(),_0x1979d1='';while(this[_0x255bb4(0x154)]){let {done:_0x1c87c3,value:_0x301819}=await _0xa288bf[_0x255bb4(0xf5)]();if(_0x1c87c3)break;_0x1979d1+=_0x4f3784['decode'](_0x301819,{'stream':!0x0});let _0xaacc53=_0x1979d1['split']('\x0a');_0x1979d1=_0xaacc53[_0x255bb4(0x14c)]()||'';for(let _0x56b652 of _0xaacc53){if(!_0x56b652[_0x255bb4(0xf6)](_0x255bb4(0x103)))continue;try{let _0x22b530=JSON[_0x255bb4(0x157)](_0x56b652[_0x255bb4(0x115)](0x6));if(_0x22b530['type']===_0x255bb4(0x10b)){this['log'](_0x255bb4(0x144)),this[_0x255bb4(0x125)](_0x255bb4(0x10b));continue;}if(_0x22b530[_0x255bb4(0x130)]===_0x255bb4(0xff)||_0x22b530[_0x255bb4(0x130)]===_0x255bb4(0x140)||_0x22b530['type']==='broadcast')await this[_0x255bb4(0x128)]();}catch{}}}}catch(_0x436f79){if(_0x436f79[_0x255bb4(0x12c)]===_0x255bb4(0x173))break;this[_0x255bb4(0x125)](_0x255bb4(0x153),_0x436f79),this[_0x255bb4(0x158)]('SSE\x20error:\x20'+_0x436f79[_0x255bb4(0x109)]);}if(this[_0x255bb4(0x154)])this['emit'](_0x255bb4(0x10f)),this[_0x255bb4(0x158)](_0x255bb4(0x11f)+_0x556d9a/0x3e8+_0x255bb4(0xfe)),await this[_0x255bb4(0xf4)](_0x556d9a),_0x556d9a=Math[_0x255bb4(0x12d)](_0x556d9a*1.5,0xea60);}}async['processInbox'](){const _0x209845=a0_0x5bf240;try{let _0x36873a=(await this[_0x209845(0x134)](_0x209845(0x12e),{'alias':this['alias'],'limit':0xa}))?.[_0x209845(0x122)]||[];for(let _0x5f2d0e of _0x36873a)await this[_0x209845(0x134)](_0x209845(0x121),{'alias':this['alias'],'message_id':_0x5f2d0e['id']}),this['log']('←\x20'+_0x5f2d0e[_0x209845(0x14d)]+':\x20'+_0x5f2d0e['content'][_0x209845(0x115)](0x0,0x3c)),this[_0x209845(0x125)](_0x209845(0x150),_0x5f2d0e),this[_0x209845(0x125)]('message',_0x5f2d0e);}catch(_0x12db17){this[_0x209845(0x158)]('inbox\x20error:\x20'+_0x12db17[_0x209845(0x109)]);}}[a0_0x5bf240(0xf4)](_0x31694f){return new Promise(_0x29c293=>setTimeout(_0x29c293,_0x31694f));}}var F=$;export{F as default,$ as CommHub};
1
+ const a0_0x543c38=a0_0x24b6;(function(_0x330ca1,_0x378435){const _0x229b92=a0_0x24b6,_0x4653c7=_0x330ca1();while(!![]){try{const _0x39f05e=parseInt(_0x229b92(0xa9))/0x1+-parseInt(_0x229b92(0x88))/0x2*(-parseInt(_0x229b92(0x6d))/0x3)+parseInt(_0x229b92(0xb4))/0x4*(-parseInt(_0x229b92(0x7b))/0x5)+-parseInt(_0x229b92(0x8e))/0x6+parseInt(_0x229b92(0xc9))/0x7*(-parseInt(_0x229b92(0x91))/0x8)+parseInt(_0x229b92(0xe7))/0x9*(-parseInt(_0x229b92(0x94))/0xa)+parseInt(_0x229b92(0x80))/0xb;if(_0x39f05e===_0x378435)break;else _0x4653c7['push'](_0x4653c7['shift']());}catch(_0x46d8e2){_0x4653c7['push'](_0x4653c7['shift']());}}}(a0_0x20aa,0xf039e));import{EventEmitter as a0_0x2f0202}from'events';import{hostname as a0_0xecb4cd}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x2e01f4,_0x3a7ed0)=>(_0x2e01f4??_0x3a7ed0)[a0_0x543c38(0xcf)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x543c38(0xcd)](0x0,0xf0);function a0_0x24b6(_0x23c9f8,_0x2073a7){_0x23c9f8=_0x23c9f8-0x6d;const _0x20aa0e=a0_0x20aa();let _0x24b638=_0x20aa0e[_0x23c9f8];return _0x24b638;}function N(_0x305369){const _0x51271b=a0_0x543c38;return(_0x305369 instanceof Error?_0x305369[_0x51271b(0x8f)]:String(_0x305369??_0x51271b(0xaa)))[_0x51271b(0xcf)](K,_0x51271b(0xea))[_0x51271b(0xcf)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x51271b(0xcd)](0x0,0xf0);}function O(_0x28594d,_0x6c47a5=process.env.ANET_TASK_TRACE_FORMAT===a0_0x543c38(0xce)){const _0xd03e89=a0_0x543c38;if(_0x6c47a5)return JSON[_0xd03e89(0x72)](_0x28594d);let _0x5aae20=L(_0x28594d[_0xd03e89(0x81)],_0xd03e89(0xe4)),_0x56e54e=L(_0x28594d[_0xd03e89(0x89)],_0xd03e89(0xeb)),_0x481931=_0x28594d[_0xd03e89(0x9a)]?_0xd03e89(0xc8)+_0x28594d['error_code']+':'+(_0x28594d[_0xd03e89(0xb5)]??''):'';return'[commhub:task]\x20'+_0x28594d[_0xd03e89(0x9e)]+_0xd03e89(0x90)+L(_0x28594d[_0xd03e89(0xc2)],_0xd03e89(0x79))+_0xd03e89(0xc4)+L(_0x28594d['to_alias'],_0xd03e89(0x79))+'\x20task_id='+_0x56e54e+'\x20parent_task_id='+_0x5aae20+_0xd03e89(0x75)+L(_0x28594d[_0xd03e89(0x9b)],_0xd03e89(0x79))+_0xd03e89(0xda)+_0x28594d[_0xd03e89(0xec)]+_0xd03e89(0xd4)+_0x28594d[_0xd03e89(0x6e)]+_0xd03e89(0x84)+_0x28594d['lifecycle_tracking']+_0x481931;}function U(_0x3f0154){const _0x54c059=a0_0x543c38;return{'event':{'sending':_0x54c059(0xa4),'delivered':'task.send.delivered','failed':_0x54c059(0x78),'acked':'task.ack','started':'task.started','replied':'task.replied','expired':_0x54c059(0x8a)}[_0x3f0154[_0x54c059(0x9e)]],..._0x3f0154};}function j(_0x51b3b9){const _0x5828b0=a0_0x543c38;let _0x2502e1=_0x51b3b9?.[_0x5828b0(0x89)]||_0x51b3b9?.['message_id']||_0x51b3b9?.['id'];if(_0x2502e1)return String(_0x2502e1);let _0x36e1af=_0x51b3b9?.[_0x5828b0(0x97)]?.[0x0]?.[_0x5828b0(0xc7)];if(typeof _0x36e1af!==_0x5828b0(0x86))return null;try{let _0x2b0489=JSON[_0x5828b0(0x85)](_0x36e1af);return _0x2b0489?.[_0x5828b0(0x89)]||_0x2b0489?.[_0x5828b0(0xbd)]||_0x2b0489?.['id']||null;}catch{return null;}}async function X(_0x19259f,_0x33afb3){const _0x59def9=a0_0x543c38;let _0x3df50d=_0x33afb3[_0x59def9(0xd1)]??Date[_0x59def9(0xd1)],_0x4d5721=_0x3df50d(),_0x36a84e=(_0x21ed65,_0x43048f,_0x440165,_0x1d76e9)=>{const _0x319eb8=_0x59def9;_0x33afb3[_0x319eb8(0x71)](O(U({'from_alias':_0x19259f[_0x319eb8(0xc1)],'to_alias':_0x19259f['toAlias'],'task_id':_0x43048f,'parent_task_id':_0x19259f[_0x319eb8(0xad)],'network_id':_0x19259f[_0x319eb8(0x74)],'transport':_0x19259f[_0x319eb8(0xec)],'status':_0x21ed65,'duration_ms':_0x3df50d()-_0x4d5721,'lifecycle_tracking':_0x19259f[_0x319eb8(0x73)],..._0x440165!==void 0x0?{'error_code':_0x1d76e9||_0x319eb8(0xc5),'error_message':N(_0x440165)}:{}})));};_0x36a84e(_0x59def9(0xb6),null);try{let _0x4e6ce6=await _0x33afb3[_0x59def9(0xd6)](),_0x402987=j(_0x4e6ce6);if(_0x402987)_0x36a84e(_0x59def9(0xd3),_0x402987);else{if(_0x4e6ce6?.['ok']===!0x1||_0x4e6ce6?.[_0x59def9(0xbe)])_0x36a84e('failed',_0x402987,_0x4e6ce6?.['error']||_0x59def9(0x76),_0x59def9(0xe9));else _0x36a84e(_0x59def9(0xee),null,_0x59def9(0xa7),_0x59def9(0xb7));}return _0x4e6ce6;}catch(_0x3781e6){throw _0x36a84e(_0x59def9(0xee),null,_0x3781e6,'send_failed'),_0x3781e6;}}async function Y(_0x540c32,_0x40c09b){const _0x4a3809=a0_0x543c38;return X({'fromAlias':_0x540c32[_0x4a3809(0xc1)],'toAlias':_0x540c32[_0x4a3809(0xa3)],'parentTaskId':_0x540c32[_0x4a3809(0xad)]||null,'networkId':_0x540c32['networkId']||null,'transport':_0x4a3809(0x77),'lifecycleTracking':_0x4a3809(0xe5)},_0x40c09b);}class $ extends a0_0x2f0202{[a0_0x543c38(0xcc)];[a0_0x543c38(0xa3)];[a0_0x543c38(0x7c)];['agent'];['resumeId'];[a0_0x543c38(0xa6)];['reconnectDelay'];[a0_0x543c38(0xba)];['sseAbort'];[a0_0x543c38(0xe8)]=!0x1;constructor(_0x46ef48){const _0x2b98bf=a0_0x543c38;super();if(this['url']=_0x46ef48['url'][_0x2b98bf(0xcf)](/\/$/,''),this['alias']=_0x46ef48[_0x2b98bf(0xa3)],this[_0x2b98bf(0x7c)]=_0x46ef48[_0x2b98bf(0x7c)],this['agent']=_0x46ef48['agent']||_0x2b98bf(0x83),this['resumeId']=_0x2b98bf(0xa5)+_0x46ef48[_0x2b98bf(0xa3)]+'-'+Date[_0x2b98bf(0xd1)]()[_0x2b98bf(0xd8)](0x24),this[_0x2b98bf(0xa6)]=_0x46ef48[_0x2b98bf(0xa6)]??0x2bf20,this[_0x2b98bf(0xa0)]=_0x46ef48[_0x2b98bf(0xa0)]??0xbb8,_0x46ef48[_0x2b98bf(0x8d)]!==!0x1)this[_0x2b98bf(0x70)]();}[a0_0x543c38(0x71)](_0x586227){const _0x2d149a=a0_0x543c38;console['log']('['+new Date()[_0x2d149a(0xca)]()['slice'](0x0,0x8)+_0x2d149a(0xe0)+this[_0x2d149a(0xa3)]+']\x20'+_0x586227);}async[a0_0x543c38(0xab)](_0x561374,_0x146ccd){const _0x299f85=a0_0x543c38;let _0x43a565={'Content-Type':_0x299f85(0xe3),'Accept':_0x299f85(0xcb)};if(this['token'])_0x43a565[_0x299f85(0xbc)]='Bearer\x20'+this[_0x299f85(0x7c)];let _0xb71c8b=await(await fetch(this['url']+_0x299f85(0xdb),{'method':'POST','headers':_0x43a565,'body':JSON[_0x299f85(0x72)]({'jsonrpc':'2.0','id':Date[_0x299f85(0xd1)](),'method':_0x299f85(0xdc),'params':{'name':_0x561374,'arguments':_0x146ccd}})}))[_0x299f85(0xc7)](),_0x18ae3c=_0xb71c8b[_0x299f85(0x8c)](/data: (.+)/),_0x1a0399=_0x18ae3c?JSON['parse'](_0x18ae3c[0x1]):JSON['parse'](_0xb71c8b),_0x3fe64e=_0x1a0399?.[_0x299f85(0x99)]?.['content']?.[0x0]?.[_0x299f85(0xc7)];return _0x3fe64e?JSON[_0x299f85(0x85)](_0x3fe64e):_0x1a0399;}async[a0_0x543c38(0x70)](){const _0x277496=a0_0x543c38;if(this[_0x277496(0xe8)])return;this[_0x277496(0xe8)]=!0x0,await this[_0x277496(0x9e)](_0x277496(0xb9)),this[_0x277496(0x71)](_0x277496(0xe6)),this['heartbeatTimer']=setInterval(()=>{const _0x2d5fbc=_0x277496;this[_0x2d5fbc(0x9e)](_0x2d5fbc(0xb9))[_0x2d5fbc(0xd2)](_0x26e96e=>this['log'](_0x2d5fbc(0xbf)+_0x26e96e[_0x2d5fbc(0x8f)]));},this['heartbeatInterval']),this[_0x277496(0x9f)]();}async[a0_0x543c38(0x95)](){const _0x19b8db=a0_0x543c38;if(this['running']=!0x1,this['sseAbort']?.['abort'](),this[_0x19b8db(0xba)])clearInterval(this[_0x19b8db(0xba)]);await this[_0x19b8db(0x9e)](_0x19b8db(0xdf))[_0x19b8db(0xd2)](()=>{}),this[_0x19b8db(0x71)](_0x19b8db(0xa2));}async[a0_0x543c38(0xd6)](_0x68ad89,_0x5c06c9,_0x31f997=a0_0x543c38(0x9c)){const _0x5c8aca=a0_0x543c38;return Y({'alias':_0x68ad89,'fromAlias':this[_0x5c8aca(0xa3)]},{'log':_0x57c670=>console[_0x5c8aca(0x71)](_0x57c670),'send':()=>this['call'](_0x5c8aca(0x82),{'alias':_0x68ad89,'task':_0x5c06c9,'priority':_0x31f997,'from_session':this[_0x5c8aca(0xa3)]})});}async['message'](_0x35441a,_0x3ee095){const _0x36ee6f=a0_0x543c38;return this[_0x36ee6f(0xab)](_0x36ee6f(0x7a),{'alias':_0x35441a,'message':_0x3ee095,'from_session':this['alias']});}async[a0_0x543c38(0xc6)](_0x52e19a,_0x4326b8,_0x463363=a0_0x543c38(0xd0)){const _0x2741d6=a0_0x543c38;return this[_0x2741d6(0xab)](_0x2741d6(0x93),{'in_reply_to':_0x52e19a,'text':_0x4326b8,'status':_0x463363});}async['status'](_0x400527,_0x558764){const _0x3b107f=a0_0x543c38;return this[_0x3b107f(0xab)](_0x3b107f(0xd5),{'resume_id':this['resumeId'],'alias':this[_0x3b107f(0xa3)],'status':_0x400527,'server':a0_0xecb4cd(),'hostname':a0_0xecb4cd(),'agent':this[_0x3b107f(0xd9)],'project_dir':process[_0x3b107f(0xbb)](),..._0x558764});}async[a0_0x543c38(0xb2)](){const _0x4dda67=a0_0x543c38;return this[_0x4dda67(0xab)]('get_all_status',{});}async[a0_0x543c38(0xd7)](_0x1342ed,_0x43e63d){const _0x22a2a6=a0_0x543c38;return this[_0x22a2a6(0xab)](_0x22a2a6(0xd7),{'message':_0x1342ed,'filter_server':_0x43e63d?.['server'],'filter_status':_0x43e63d?.[_0x22a2a6(0x9e)]});}async[a0_0x543c38(0x9f)](){const _0x50e046=a0_0x543c38;let _0x444979=encodeURIComponent(this['alias']),_0x11783e=this[_0x50e046(0xcc)]+_0x50e046(0x92)+_0x444979,_0x52d6c0=this[_0x50e046(0xa0)];while(this[_0x50e046(0xe8)]){try{this['sseAbort']=new AbortController();let _0x1fb1b2={'Accept':'text/event-stream'};if(this[_0x50e046(0x7c)])_0x1fb1b2[_0x50e046(0xbc)]=_0x50e046(0xa8)+this['token'];let _0x26de69=await fetch(_0x11783e,{'headers':_0x1fb1b2,'signal':this[_0x50e046(0xc3)][_0x50e046(0xdd)]});if(!_0x26de69['ok']||!_0x26de69[_0x50e046(0xaf)]){this[_0x50e046(0x71)](_0x50e046(0xed)+_0x26de69['status']),await this['sleep'](_0x52d6c0),_0x52d6c0=Math['min'](_0x52d6c0*1.5,0xea60);continue;}_0x52d6c0=this[_0x50e046(0xa0)];let _0x3b9f74=_0x26de69['body'][_0x50e046(0x98)](),_0x28a611=new TextDecoder(),_0x1ec1e3='';while(this[_0x50e046(0xe8)]){let {done:_0x5442bc,value:_0x25e9cc}=await _0x3b9f74[_0x50e046(0xae)]();if(_0x5442bc)break;_0x1ec1e3+=_0x28a611[_0x50e046(0x7e)](_0x25e9cc,{'stream':!0x0});let _0x2100ae=_0x1ec1e3['split']('\x0a');_0x1ec1e3=_0x2100ae[_0x50e046(0xac)]()||'';for(let _0x3d9b45 of _0x2100ae){if(!_0x3d9b45[_0x50e046(0xe2)](_0x50e046(0x87)))continue;try{let _0x2a0f22=JSON[_0x50e046(0x85)](_0x3d9b45[_0x50e046(0xcd)](0x6));if(_0x2a0f22[_0x50e046(0x96)]==='connected'){this['log'](_0x50e046(0xa1)),this[_0x50e046(0x7d)](_0x50e046(0xb0));continue;}if(_0x2a0f22[_0x50e046(0x96)]==='new_task'||_0x2a0f22['type']===_0x50e046(0xb1)||_0x2a0f22[_0x50e046(0x96)]===_0x50e046(0xd7))await this[_0x50e046(0x6f)]();}catch{}}}}catch(_0x1653da){if(_0x1653da['name']==='AbortError')break;this[_0x50e046(0x7d)]('error',_0x1653da),this[_0x50e046(0x71)](_0x50e046(0xb3)+_0x1653da[_0x50e046(0x8f)]);}if(this[_0x50e046(0xe8)])this[_0x50e046(0x7d)]('disconnected'),this[_0x50e046(0x71)](_0x50e046(0xde)+_0x52d6c0/0x3e8+_0x50e046(0x8b)),await this[_0x50e046(0x7f)](_0x52d6c0),_0x52d6c0=Math[_0x50e046(0xc0)](_0x52d6c0*1.5,0xea60);}}async[a0_0x543c38(0x6f)](){const _0x22073d=a0_0x543c38;try{let _0x462c96=(await this[_0x22073d(0xab)]('get_inbox',{'alias':this['alias'],'limit':0xa}))?.[_0x22073d(0xb8)]||[];for(let _0x24df74 of _0x462c96)await this[_0x22073d(0xab)]('ack_inbox',{'alias':this[_0x22073d(0xa3)],'message_id':_0x24df74['id']}),this[_0x22073d(0x71)]('←\x20'+_0x24df74[_0x22073d(0x9d)]+':\x20'+_0x24df74[_0x22073d(0x97)][_0x22073d(0xcd)](0x0,0x3c)),this['emit'](_0x22073d(0xe1),_0x24df74),this[_0x22073d(0x7d)](_0x22073d(0x8f),_0x24df74);}catch(_0x39a0eb){this[_0x22073d(0x71)]('inbox\x20error:\x20'+_0x39a0eb[_0x22073d(0x8f)]);}}[a0_0x543c38(0x7f)](_0x4e318a){return new Promise(_0x5987ed=>setTimeout(_0x5987ed,_0x4e318a));}}var F=$;function a0_0x20aa(){const _0x20fa1f=['sdk','\x20lifecycle=','parse','string','data:\x20','1481606nFUBmQ','task_id','task.expired','s...','match','autoConnect','171234oCWWdz','message','\x20from=','1175896zSpnFM','/events/','send_reply','10ubNzkS','disconnect','type','content','getReader','result','error_code','network_id','normal','from_session','status','connectSSE','reconnectDelay','SSE\x20connected','disconnected','alias','task.send.start','sdk-','heartbeatInterval','CommHub\x20response\x20omitted\x20task_id','Bearer\x20','213975zYuNoK','unknown\x20error','call','pop','parentTaskId','read','body','connected','new_message','getAllStatus','SSE\x20error:\x20','283516zEnzUC','error_message','sending','missing_task_id','messages','idle','heartbeatTimer','cwd','Authorization','message_id','error','heartbeat\x20failed:\x20','min','fromAlias','from_alias','sseAbort','\x20to=','send_failed','reply','text','\x20error=','91KWjxVT','toTimeString','application/json,\x20text/event-stream','url','slice','json','replace','completed','now','catch','delivered','\x20duration_ms=','report_status','send','broadcast','toString','agent','\x20transport=','/mcp','tools/call','signal','SSE\x20reconnecting\x20in\x20','offline',']\x20[commhub:','task','startsWith','application/json','<missing>','not_tracked','registered','9417186hxAbVY','running','send_rejected','[REDACTED]','<pending>','transport','SSE\x20failed:\x20','failed','3CPxINe','duration_ms','processInbox','connect','log','stringify','lifecycleTracking','networkId','\x20network_id=','CommHub\x20rejected\x20task','mcp_http','task.send.failed','<unknown>','send_message','95DOUfhS','token','emit','decode','sleep','47977743wXsRmV','parent_task_id','send_task'];a0_0x20aa=function(){return _0x20fa1f;};return a0_0x20aa();}export{F as default,$ as CommHub};