@sleep2agi/agent-network 2.3.0-preview.62 → 2.3.0-preview.64

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_0x5bb32a=a0_0x17d4;function a0_0x576f(){const _0x5254d5=['send_rejected','emit','reconnectDelay','1397998NbVLNq','offline','sdk','connectSSE','missing_task_id','network_id','idle','content','heartbeatTimer','unknown\x20error','[REDACTED]','string','task.expired','alias','[commhub:task]\x20','\x20error=','SSE\x20error:\x20','error','lifecycleTracking','connected','result','912762zkxnOZ','replace','sdk-','getAllStatus','registered','new_task','\x20parent_task_id=','1612384ibyRro','status','completed','fromAlias','running','not_tracked','now','60vhEOQn','type','sleep','Bearer\x20','json','task.ack','tools/call','task.started','token','task','name','reply','startsWith','resumeId','message_id','disconnected','\x20network_id=','toString','from_alias','get_all_status','text','log','<pending>','send_reply','slice','send_failed','\x20task_id=','abort','task.replied','connect','min','transport','server','3156213STOamD','pop','processInbox','\x20transport=','2.0','task.send.delivered','catch','text/event-stream','disconnect','failed','broadcast','decode','31841824URenuB','1116680JbcYgu','sseAbort','SSE\x20connected','to_alias','getReader','ack_inbox','<unknown>','toAlias','send','duration_ms','Authorization','networkId','sending','CommHub\x20rejected\x20task','AbortError','\x20to=','split','delivered','heartbeatInterval','normal','<missing>','body','message','report_status','parse','parent_task_id','stringify','send_message','get_inbox','url','task_id','task.send.start','\x20from=','654057mwzyMp','call','read','inbox\x20error:\x20','/events/','agent'];a0_0x576f=function(){return _0x5254d5;};return a0_0x576f();}(function(_0x4f5807,_0x21416a){const _0x6dacea=a0_0x17d4,_0x5aebd7=_0x4f5807();while(!![]){try{const _0x34e784=parseInt(_0x6dacea(0x173))/0x1+-parseInt(_0x6dacea(0x152))/0x2+-parseInt(_0x6dacea(0x145))/0x3+-parseInt(_0x6dacea(0x11d))/0x4+-parseInt(_0x6dacea(0x124))/0x5*(parseInt(_0x6dacea(0x116))/0x6)+parseInt(_0x6dacea(0x17c))/0x7+parseInt(_0x6dacea(0x151))/0x8;if(_0x34e784===_0x21416a)break;else _0x5aebd7['push'](_0x5aebd7['shift']());}catch(_0x4db1af){_0x5aebd7['push'](_0x5aebd7['shift']());}}}(a0_0x576f,0xf2e98));import{EventEmitter as a0_0x54f089}from'events';import{hostname as a0_0x26deb8}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x272b7f,_0x3fb318)=>(_0x272b7f??_0x3fb318)[a0_0x5bb32a(0x117)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x5bb32a(0x13c)](0x0,0xf0);function N(_0x1a8131){const _0x10cbd6=a0_0x5bb32a;return(_0x1a8131 instanceof Error?_0x1a8131['message']:String(_0x1a8131??_0x10cbd6(0x10a)))[_0x10cbd6(0x117)](K,_0x10cbd6(0x10b))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x10cbd6(0x13c)](0x0,0xf0);}function O(_0x7f0df8,_0x3b14e7=process.env.ANET_TASK_TRACE_FORMAT===a0_0x5bb32a(0x128)){const _0xb22a50=a0_0x5bb32a;if(_0x3b14e7)return JSON[_0xb22a50(0x16c)](_0x7f0df8);let _0x4ba0cc=L(_0x7f0df8[_0xb22a50(0x16b)],_0xb22a50(0x166)),_0x15bc99=L(_0x7f0df8[_0xb22a50(0x170)],_0xb22a50(0x13a)),_0x52e6b1=_0x7f0df8['error_code']?_0xb22a50(0x110)+_0x7f0df8['error_code']+':'+(_0x7f0df8['error_message']??''):'';return _0xb22a50(0x10f)+_0x7f0df8[_0xb22a50(0x11e)]+_0xb22a50(0x172)+L(_0x7f0df8[_0xb22a50(0x136)],'<unknown>')+_0xb22a50(0x161)+L(_0x7f0df8[_0xb22a50(0x155)],'<unknown>')+_0xb22a50(0x13e)+_0x15bc99+_0xb22a50(0x11c)+_0x4ba0cc+_0xb22a50(0x134)+L(_0x7f0df8[_0xb22a50(0x106)],_0xb22a50(0x158))+_0xb22a50(0x148)+_0x7f0df8[_0xb22a50(0x143)]+'\x20duration_ms='+_0x7f0df8[_0xb22a50(0x15b)]+'\x20lifecycle='+_0x7f0df8['lifecycle_tracking']+_0x52e6b1;}function U(_0x23d52c){const _0x1b89f2=a0_0x5bb32a;return{'event':{'sending':_0x1b89f2(0x171),'delivered':_0x1b89f2(0x14a),'failed':'task.send.failed','acked':_0x1b89f2(0x129),'started':_0x1b89f2(0x12b),'replied':_0x1b89f2(0x140),'expired':_0x1b89f2(0x10d)}[_0x23d52c['status']],..._0x23d52c};}function j(_0x12847c){const _0x5504c1=a0_0x5bb32a;let _0x170c53=_0x12847c?.['task_id']||_0x12847c?.[_0x5504c1(0x132)]||_0x12847c?.['id'];if(_0x170c53)return String(_0x170c53);let _0x506ec1=_0x12847c?.[_0x5504c1(0x108)]?.[0x0]?.[_0x5504c1(0x138)];if(typeof _0x506ec1!==_0x5504c1(0x10c))return null;try{let _0xe2bd8b=JSON['parse'](_0x506ec1);return _0xe2bd8b?.[_0x5504c1(0x170)]||_0xe2bd8b?.['message_id']||_0xe2bd8b?.['id']||null;}catch{return null;}}function a0_0x17d4(_0x16ef4b,_0x63810b){_0x16ef4b=_0x16ef4b-0x105;const _0x576fd5=a0_0x576f();let _0x17d462=_0x576fd5[_0x16ef4b];return _0x17d462;}async function X(_0x69c529,_0x567e74){const _0x20d575=a0_0x5bb32a;let _0x55942e=_0x567e74['now']??Date[_0x20d575(0x123)],_0x21dd2f=_0x55942e(),_0x2a328e=(_0x205712,_0x13857f,_0x32315d,_0x480595)=>{const _0x23d298=_0x20d575;_0x567e74['log'](O(U({'from_alias':_0x69c529[_0x23d298(0x120)],'to_alias':_0x69c529[_0x23d298(0x159)],'task_id':_0x13857f,'parent_task_id':_0x69c529['parentTaskId'],'network_id':_0x69c529[_0x23d298(0x15d)],'transport':_0x69c529['transport'],'status':_0x205712,'duration_ms':_0x55942e()-_0x21dd2f,'lifecycle_tracking':_0x69c529[_0x23d298(0x113)],..._0x32315d!==void 0x0?{'error_code':_0x480595||_0x23d298(0x13d),'error_message':N(_0x32315d)}:{}})));};_0x2a328e(_0x20d575(0x15e),null);try{let _0x14d5d7=await _0x567e74[_0x20d575(0x15a)](),_0x3a95ac=j(_0x14d5d7);if(_0x3a95ac)_0x2a328e(_0x20d575(0x163),_0x3a95ac);else{if(_0x14d5d7?.['ok']===!0x1||_0x14d5d7?.[_0x20d575(0x112)])_0x2a328e(_0x20d575(0x14e),_0x3a95ac,_0x14d5d7?.[_0x20d575(0x112)]||_0x20d575(0x15f),_0x20d575(0x179));else _0x2a328e(_0x20d575(0x14e),null,'CommHub\x20response\x20omitted\x20task_id',_0x20d575(0x105));}return _0x14d5d7;}catch(_0x3d86a4){throw _0x2a328e('failed',null,_0x3d86a4,_0x20d575(0x13d)),_0x3d86a4;}}async function Y(_0x216b74,_0x55ddc4){const _0x1653de=a0_0x5bb32a;return X({'fromAlias':_0x216b74[_0x1653de(0x120)],'toAlias':_0x216b74[_0x1653de(0x10e)],'parentTaskId':_0x216b74['parentTaskId']||null,'networkId':_0x216b74[_0x1653de(0x15d)]||null,'transport':'mcp_http','lifecycleTracking':_0x1653de(0x122)},_0x55ddc4);}class $ extends a0_0x54f089{[a0_0x5bb32a(0x16f)];[a0_0x5bb32a(0x10e)];[a0_0x5bb32a(0x12c)];[a0_0x5bb32a(0x178)];[a0_0x5bb32a(0x131)];[a0_0x5bb32a(0x164)];[a0_0x5bb32a(0x17b)];['heartbeatTimer'];[a0_0x5bb32a(0x153)];[a0_0x5bb32a(0x121)]=!0x1;constructor(_0x26bf74){const _0xee09d6=a0_0x5bb32a;super();if(this[_0xee09d6(0x16f)]=_0x26bf74[_0xee09d6(0x16f)][_0xee09d6(0x117)](/\/$/,''),this[_0xee09d6(0x10e)]=_0x26bf74[_0xee09d6(0x10e)],this['token']=_0x26bf74[_0xee09d6(0x12c)],this[_0xee09d6(0x178)]=_0x26bf74[_0xee09d6(0x178)]||_0xee09d6(0x17e),this[_0xee09d6(0x131)]=_0xee09d6(0x118)+_0x26bf74[_0xee09d6(0x10e)]+'-'+Date[_0xee09d6(0x123)]()[_0xee09d6(0x135)](0x24),this[_0xee09d6(0x164)]=_0x26bf74[_0xee09d6(0x164)]??0x2bf20,this[_0xee09d6(0x17b)]=_0x26bf74[_0xee09d6(0x17b)]??0xbb8,_0x26bf74['autoConnect']!==!0x1)this[_0xee09d6(0x141)]();}[a0_0x5bb32a(0x139)](_0x275f80){const _0x4ab468=a0_0x5bb32a;console[_0x4ab468(0x139)]('['+new Date()['toTimeString']()['slice'](0x0,0x8)+']\x20[commhub:'+this['alias']+']\x20'+_0x275f80);}async[a0_0x5bb32a(0x174)](_0x53c8c6,_0x5e5a73){const _0x3d30e6=a0_0x5bb32a;let _0x1f3570={'Content-Type':'application/json','Accept':'application/json,\x20text/event-stream'};if(this[_0x3d30e6(0x12c)])_0x1f3570[_0x3d30e6(0x15c)]=_0x3d30e6(0x127)+this['token'];let _0x38bb26=await(await fetch(this[_0x3d30e6(0x16f)]+'/mcp',{'method':'POST','headers':_0x1f3570,'body':JSON[_0x3d30e6(0x16c)]({'jsonrpc':_0x3d30e6(0x149),'id':Date[_0x3d30e6(0x123)](),'method':_0x3d30e6(0x12a),'params':{'name':_0x53c8c6,'arguments':_0x5e5a73}})}))[_0x3d30e6(0x138)](),_0x17744c=_0x38bb26['match'](/data: (.+)/),_0x5cb39f=_0x17744c?JSON[_0x3d30e6(0x16a)](_0x17744c[0x1]):JSON['parse'](_0x38bb26),_0x1cb2c3=_0x5cb39f?.[_0x3d30e6(0x115)]?.[_0x3d30e6(0x108)]?.[0x0]?.[_0x3d30e6(0x138)];return _0x1cb2c3?JSON[_0x3d30e6(0x16a)](_0x1cb2c3):_0x5cb39f;}async['connect'](){const _0x4488d6=a0_0x5bb32a;if(this[_0x4488d6(0x121)])return;this['running']=!0x0,await this[_0x4488d6(0x11e)](_0x4488d6(0x107)),this[_0x4488d6(0x139)](_0x4488d6(0x11a)),this[_0x4488d6(0x109)]=setInterval(()=>{const _0x2a9acc=_0x4488d6;this[_0x2a9acc(0x11e)](_0x2a9acc(0x107))[_0x2a9acc(0x14b)](_0x11a5a8=>this['log']('heartbeat\x20failed:\x20'+_0x11a5a8[_0x2a9acc(0x168)]));},this['heartbeatInterval']),this[_0x4488d6(0x17f)]();}async[a0_0x5bb32a(0x14d)](){const _0x488c11=a0_0x5bb32a;if(this[_0x488c11(0x121)]=!0x1,this['sseAbort']?.[_0x488c11(0x13f)](),this[_0x488c11(0x109)])clearInterval(this[_0x488c11(0x109)]);await this[_0x488c11(0x11e)](_0x488c11(0x17d))[_0x488c11(0x14b)](()=>{}),this[_0x488c11(0x139)](_0x488c11(0x133));}async[a0_0x5bb32a(0x15a)](_0x5c3688,_0xfa7926,_0x4e0e29=a0_0x5bb32a(0x165)){const _0x48a244=a0_0x5bb32a;return Y({'alias':_0x5c3688,'fromAlias':this[_0x48a244(0x10e)]},{'log':_0x1f9c2a=>console['log'](_0x1f9c2a),'send':()=>this[_0x48a244(0x174)]('send_task',{'alias':_0x5c3688,'task':_0xfa7926,'priority':_0x4e0e29,'from_session':this[_0x48a244(0x10e)]})});}async[a0_0x5bb32a(0x168)](_0x1145b7,_0x345324){const _0x4c1dd9=a0_0x5bb32a;return this[_0x4c1dd9(0x174)](_0x4c1dd9(0x16d),{'alias':_0x1145b7,'message':_0x345324,'from_session':this[_0x4c1dd9(0x10e)]});}async[a0_0x5bb32a(0x12f)](_0x5f2a0c,_0xa1ddc,_0x288c99=a0_0x5bb32a(0x11f)){const _0x14e868=a0_0x5bb32a;return this[_0x14e868(0x174)](_0x14e868(0x13b),{'in_reply_to':_0x5f2a0c,'text':_0xa1ddc,'status':_0x288c99});}async[a0_0x5bb32a(0x11e)](_0x4ce402,_0x602261){const _0x3614c5=a0_0x5bb32a;return this['call'](_0x3614c5(0x169),{'resume_id':this['resumeId'],'alias':this[_0x3614c5(0x10e)],'status':_0x4ce402,'server':a0_0x26deb8(),'hostname':a0_0x26deb8(),'agent':this['agent'],'project_dir':process['cwd'](),..._0x602261});}async[a0_0x5bb32a(0x119)](){const _0x374a78=a0_0x5bb32a;return this['call'](_0x374a78(0x137),{});}async[a0_0x5bb32a(0x14f)](_0x43f942,_0x195a47){const _0x3f86f5=a0_0x5bb32a;return this[_0x3f86f5(0x174)](_0x3f86f5(0x14f),{'message':_0x43f942,'filter_server':_0x195a47?.[_0x3f86f5(0x144)],'filter_status':_0x195a47?.['status']});}async[a0_0x5bb32a(0x17f)](){const _0x144d6f=a0_0x5bb32a;let _0x4f58f8=encodeURIComponent(this[_0x144d6f(0x10e)]),_0x5e7f60=this[_0x144d6f(0x16f)]+_0x144d6f(0x177)+_0x4f58f8,_0x5400af=this['reconnectDelay'];while(this[_0x144d6f(0x121)]){try{this[_0x144d6f(0x153)]=new AbortController();let _0x252802={'Accept':_0x144d6f(0x14c)};if(this['token'])_0x252802[_0x144d6f(0x15c)]=_0x144d6f(0x127)+this[_0x144d6f(0x12c)];let _0x4ec7d0=await fetch(_0x5e7f60,{'headers':_0x252802,'signal':this[_0x144d6f(0x153)]['signal']});if(!_0x4ec7d0['ok']||!_0x4ec7d0[_0x144d6f(0x167)]){this[_0x144d6f(0x139)]('SSE\x20failed:\x20'+_0x4ec7d0[_0x144d6f(0x11e)]),await this[_0x144d6f(0x126)](_0x5400af),_0x5400af=Math[_0x144d6f(0x142)](_0x5400af*1.5,0xea60);continue;}_0x5400af=this['reconnectDelay'];let _0x18d93e=_0x4ec7d0[_0x144d6f(0x167)][_0x144d6f(0x156)](),_0x2e16c7=new TextDecoder(),_0x3c41ef='';while(this['running']){let {done:_0x8ea213,value:_0x4d627b}=await _0x18d93e[_0x144d6f(0x175)]();if(_0x8ea213)break;_0x3c41ef+=_0x2e16c7[_0x144d6f(0x150)](_0x4d627b,{'stream':!0x0});let _0x5b198e=_0x3c41ef[_0x144d6f(0x162)]('\x0a');_0x3c41ef=_0x5b198e[_0x144d6f(0x146)]()||'';for(let _0xf1edd8 of _0x5b198e){if(!_0xf1edd8[_0x144d6f(0x130)]('data:\x20'))continue;try{let _0x5dd0be=JSON['parse'](_0xf1edd8[_0x144d6f(0x13c)](0x6));if(_0x5dd0be[_0x144d6f(0x125)]===_0x144d6f(0x114)){this[_0x144d6f(0x139)](_0x144d6f(0x154)),this[_0x144d6f(0x17a)](_0x144d6f(0x114));continue;}if(_0x5dd0be[_0x144d6f(0x125)]===_0x144d6f(0x11b)||_0x5dd0be['type']==='new_message'||_0x5dd0be[_0x144d6f(0x125)]==='broadcast')await this[_0x144d6f(0x147)]();}catch{}}}}catch(_0x196475){if(_0x196475[_0x144d6f(0x12e)]===_0x144d6f(0x160))break;this[_0x144d6f(0x17a)]('error',_0x196475),this['log'](_0x144d6f(0x111)+_0x196475[_0x144d6f(0x168)]);}if(this[_0x144d6f(0x121)])this[_0x144d6f(0x17a)](_0x144d6f(0x133)),this[_0x144d6f(0x139)]('SSE\x20reconnecting\x20in\x20'+_0x5400af/0x3e8+'s...'),await this[_0x144d6f(0x126)](_0x5400af),_0x5400af=Math['min'](_0x5400af*1.5,0xea60);}}async[a0_0x5bb32a(0x147)](){const _0x3608fe=a0_0x5bb32a;try{let _0x443b19=(await this[_0x3608fe(0x174)](_0x3608fe(0x16e),{'alias':this['alias'],'limit':0xa}))?.['messages']||[];for(let _0x3aab68 of _0x443b19)await this[_0x3608fe(0x174)](_0x3608fe(0x157),{'alias':this[_0x3608fe(0x10e)],'message_id':_0x3aab68['id']}),this[_0x3608fe(0x139)]('←\x20'+_0x3aab68['from_session']+':\x20'+_0x3aab68[_0x3608fe(0x108)][_0x3608fe(0x13c)](0x0,0x3c)),this[_0x3608fe(0x17a)](_0x3608fe(0x12d),_0x3aab68),this['emit'](_0x3608fe(0x168),_0x3aab68);}catch(_0x5dbaec){this[_0x3608fe(0x139)](_0x3608fe(0x176)+_0x5dbaec[_0x3608fe(0x168)]);}}[a0_0x5bb32a(0x126)](_0x494e83){return new Promise(_0x3c2cba=>setTimeout(_0x3c2cba,_0x494e83));}}var F=$;export{F as default,$ as CommHub};
1
+ function a0_0x3bfa(){const _0x3d7358=['task.ack','heartbeatInterval','fromAlias','running','toTimeString','\x20duration_ms=','idle','disconnected','send','266lCIFue','replace','emit','tools/call','not_tracked','name','5txyxqQ','task.send.failed','offline','\x20network_id=','[REDACTED]','reply','heartbeat\x20failed:\x20','json','send_message','\x20from=','task.expired','CommHub\x20response\x20omitted\x20task_id','2.0','send_reply','AbortError','557418hnXXiJ','1633373gYTycX','/mcp','now','parent_task_id','lifecycleTracking','parse','error','sending','cwd','catch','24524631EPzGiT','getAllStatus','agent','get_inbox','heartbeatTimer','sseAbort','slice','/events/','string','broadcast','new_message','url','status','failed','networkId','sdk-','to_alias','2633648kvHJHC','getReader','send_task',']\x20[commhub:','\x20task_id=','token','11789jAQGXC','message','alias','call','reconnectDelay','send_failed','type','\x20parent_task_id=','ack_inbox','task.replied','abort','resumeId','messages','new_task','141474MIogpN','from_alias','\x20lifecycle=','duration_ms','delivered','pop','Authorization','toString','SSE\x20error:\x20','server','body','Bearer\x20','SSE\x20connected','transport','from_session','autoConnect','error_code','get_all_status','text','content','614824FVaMxW','<unknown>','<pending>','message_id','log','connectSSE','completed','disconnect','task.send.start','task.started','task','[commhub:task]\x20','\x20error=','read','connected','<missing>','connect','sleep','stringify','SSE\x20failed:\x20','task_id','POST','normal','parentTaskId','processInbox','error_message','min','split'];a0_0x3bfa=function(){return _0x3d7358;};return a0_0x3bfa();}const a0_0x12a50f=a0_0x20c2;(function(_0x2c8deb,_0x9fa7d0){const _0x1406a7=a0_0x20c2,_0x3969a9=_0x2c8deb();while(!![]){try{const _0x1c1308=-parseInt(_0x1406a7(0x124))/0x1*(parseInt(_0x1406a7(0x16b))/0x2)+parseInt(_0x1406a7(0x132))/0x3+parseInt(_0x1406a7(0x146))/0x4+-parseInt(_0x1406a7(0x171))/0x5*(-parseInt(_0x1406a7(0x180))/0x6)+-parseInt(_0x1406a7(0x181))/0x7+-parseInt(_0x1406a7(0x19c))/0x8+parseInt(_0x1406a7(0x18b))/0x9;if(_0x1c1308===_0x9fa7d0)break;else _0x3969a9['push'](_0x3969a9['shift']());}catch(_0x1731a4){_0x3969a9['push'](_0x3969a9['shift']());}}}(a0_0x3bfa,0xd8db4));import{EventEmitter as a0_0x5cf0ad}from'events';import{hostname as a0_0x23411e}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0xa0cdfe,_0x5951bd)=>(_0xa0cdfe??_0x5951bd)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0xceab9){const _0x526f1d=a0_0x20c2;return(_0xceab9 instanceof Error?_0xceab9['message']:String(_0xceab9??'unknown\x20error'))['replace'](K,_0x526f1d(0x175))[_0x526f1d(0x16c)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x56f2d8,_0x84929a=process.env.ANET_TASK_TRACE_FORMAT===a0_0x12a50f(0x178)){const _0x377926=a0_0x12a50f;if(_0x84929a)return JSON[_0x377926(0x158)](_0x56f2d8);let _0x9879f0=L(_0x56f2d8[_0x377926(0x184)],_0x377926(0x155)),_0x46b888=L(_0x56f2d8[_0x377926(0x15a)],_0x377926(0x148)),_0x3816b7=_0x56f2d8[_0x377926(0x142)]?_0x377926(0x152)+_0x56f2d8['error_code']+':'+(_0x56f2d8[_0x377926(0x15f)]??''):'';return _0x377926(0x151)+_0x56f2d8[_0x377926(0x197)]+_0x377926(0x17a)+L(_0x56f2d8[_0x377926(0x133)],_0x377926(0x147))+'\x20to='+L(_0x56f2d8[_0x377926(0x19b)],'<unknown>')+_0x377926(0x122)+_0x46b888+_0x377926(0x12b)+_0x9879f0+_0x377926(0x174)+L(_0x56f2d8['network_id'],_0x377926(0x147))+'\x20transport='+_0x56f2d8[_0x377926(0x13f)]+_0x377926(0x167)+_0x56f2d8[_0x377926(0x135)]+_0x377926(0x134)+_0x56f2d8['lifecycle_tracking']+_0x3816b7;}function U(_0x40c184){const _0x1f46fc=a0_0x12a50f;return{'event':{'sending':_0x1f46fc(0x14e),'delivered':'task.send.delivered','failed':_0x1f46fc(0x172),'acked':_0x1f46fc(0x162),'started':_0x1f46fc(0x14f),'replied':_0x1f46fc(0x12d),'expired':_0x1f46fc(0x17b)}[_0x40c184[_0x1f46fc(0x197)]],..._0x40c184};}function a0_0x20c2(_0x3c7db9,_0x44cd34){_0x3c7db9=_0x3c7db9-0x121;const _0x3bfa2e=a0_0x3bfa();let _0x20c230=_0x3bfa2e[_0x3c7db9];return _0x20c230;}function j(_0x3a8eea){const _0x3627d8=a0_0x12a50f;let _0x49932f=_0x3a8eea?.[_0x3627d8(0x15a)]||_0x3a8eea?.['message_id']||_0x3a8eea?.['id'];if(_0x49932f)return String(_0x49932f);let _0x46fde2=_0x3a8eea?.[_0x3627d8(0x145)]?.[0x0]?.[_0x3627d8(0x144)];if(typeof _0x46fde2!==_0x3627d8(0x193))return null;try{let _0x5c7a94=JSON[_0x3627d8(0x186)](_0x46fde2);return _0x5c7a94?.[_0x3627d8(0x15a)]||_0x5c7a94?.[_0x3627d8(0x149)]||_0x5c7a94?.['id']||null;}catch{return null;}}async function X(_0x1bbeeb,_0x28010b){const _0x2b236c=a0_0x12a50f;let _0x564304=_0x28010b[_0x2b236c(0x183)]??Date['now'],_0x1c067d=_0x564304(),_0x23eca7=(_0x3e80b5,_0x1d4152,_0x4a152,_0x24db1d)=>{const _0x5bffc1=_0x2b236c;_0x28010b[_0x5bffc1(0x14a)](O(U({'from_alias':_0x1bbeeb[_0x5bffc1(0x164)],'to_alias':_0x1bbeeb['toAlias'],'task_id':_0x1d4152,'parent_task_id':_0x1bbeeb[_0x5bffc1(0x15d)],'network_id':_0x1bbeeb[_0x5bffc1(0x199)],'transport':_0x1bbeeb[_0x5bffc1(0x13f)],'status':_0x3e80b5,'duration_ms':_0x564304()-_0x1c067d,'lifecycle_tracking':_0x1bbeeb[_0x5bffc1(0x185)],..._0x4a152!==void 0x0?{'error_code':_0x24db1d||_0x5bffc1(0x129),'error_message':N(_0x4a152)}:{}})));};_0x23eca7(_0x2b236c(0x188),null);try{let _0x4b0b16=await _0x28010b[_0x2b236c(0x16a)](),_0x38485a=j(_0x4b0b16);if(_0x38485a)_0x23eca7(_0x2b236c(0x136),_0x38485a);else{if(_0x4b0b16?.['ok']===!0x1||_0x4b0b16?.[_0x2b236c(0x187)])_0x23eca7(_0x2b236c(0x198),_0x38485a,_0x4b0b16?.['error']||'CommHub\x20rejected\x20task','send_rejected');else _0x23eca7(_0x2b236c(0x198),null,_0x2b236c(0x17c),'missing_task_id');}return _0x4b0b16;}catch(_0x1ee81a){throw _0x23eca7(_0x2b236c(0x198),null,_0x1ee81a,_0x2b236c(0x129)),_0x1ee81a;}}async function Y(_0x5b5ca3,_0x5b15ed){const _0xfaf945=a0_0x12a50f;return X({'fromAlias':_0x5b5ca3[_0xfaf945(0x164)],'toAlias':_0x5b5ca3['alias'],'parentTaskId':_0x5b5ca3[_0xfaf945(0x15d)]||null,'networkId':_0x5b5ca3['networkId']||null,'transport':'mcp_http','lifecycleTracking':_0xfaf945(0x16f)},_0x5b15ed);}class $ extends a0_0x5cf0ad{[a0_0x12a50f(0x196)];[a0_0x12a50f(0x126)];[a0_0x12a50f(0x123)];[a0_0x12a50f(0x18d)];['resumeId'];[a0_0x12a50f(0x163)];[a0_0x12a50f(0x128)];['heartbeatTimer'];['sseAbort'];[a0_0x12a50f(0x165)]=!0x1;constructor(_0x121f76){const _0x587a18=a0_0x12a50f;super();if(this['url']=_0x121f76[_0x587a18(0x196)][_0x587a18(0x16c)](/\/$/,''),this[_0x587a18(0x126)]=_0x121f76[_0x587a18(0x126)],this[_0x587a18(0x123)]=_0x121f76[_0x587a18(0x123)],this['agent']=_0x121f76[_0x587a18(0x18d)]||'sdk',this['resumeId']=_0x587a18(0x19a)+_0x121f76[_0x587a18(0x126)]+'-'+Date[_0x587a18(0x183)]()[_0x587a18(0x139)](0x24),this[_0x587a18(0x163)]=_0x121f76[_0x587a18(0x163)]??0x2bf20,this[_0x587a18(0x128)]=_0x121f76[_0x587a18(0x128)]??0xbb8,_0x121f76[_0x587a18(0x141)]!==!0x1)this[_0x587a18(0x156)]();}[a0_0x12a50f(0x14a)](_0x11b031){const _0x339f1c=a0_0x12a50f;console['log']('['+new Date()[_0x339f1c(0x166)]()[_0x339f1c(0x191)](0x0,0x8)+_0x339f1c(0x121)+this[_0x339f1c(0x126)]+']\x20'+_0x11b031);}async[a0_0x12a50f(0x127)](_0x4da697,_0x1c8396){const _0x4e6ca1=a0_0x12a50f;let _0x2da970={'Content-Type':'application/json','Accept':'application/json,\x20text/event-stream'};if(this['token'])_0x2da970[_0x4e6ca1(0x138)]=_0x4e6ca1(0x13d)+this[_0x4e6ca1(0x123)];let _0x5dbff1=await(await fetch(this[_0x4e6ca1(0x196)]+_0x4e6ca1(0x182),{'method':_0x4e6ca1(0x15b),'headers':_0x2da970,'body':JSON[_0x4e6ca1(0x158)]({'jsonrpc':_0x4e6ca1(0x17d),'id':Date['now'](),'method':_0x4e6ca1(0x16e),'params':{'name':_0x4da697,'arguments':_0x1c8396}})}))[_0x4e6ca1(0x144)](),_0x110af6=_0x5dbff1['match'](/data: (.+)/),_0xf76ee8=_0x110af6?JSON['parse'](_0x110af6[0x1]):JSON[_0x4e6ca1(0x186)](_0x5dbff1),_0x33cde9=_0xf76ee8?.['result']?.[_0x4e6ca1(0x145)]?.[0x0]?.[_0x4e6ca1(0x144)];return _0x33cde9?JSON['parse'](_0x33cde9):_0xf76ee8;}async[a0_0x12a50f(0x156)](){const _0x26baea=a0_0x12a50f;if(this[_0x26baea(0x165)])return;this[_0x26baea(0x165)]=!0x0,await this[_0x26baea(0x197)](_0x26baea(0x168)),this[_0x26baea(0x14a)]('registered'),this[_0x26baea(0x18f)]=setInterval(()=>{const _0x273de0=_0x26baea;this[_0x273de0(0x197)](_0x273de0(0x168))[_0x273de0(0x18a)](_0x37fe76=>this[_0x273de0(0x14a)](_0x273de0(0x177)+_0x37fe76[_0x273de0(0x125)]));},this[_0x26baea(0x163)]),this[_0x26baea(0x14b)]();}async[a0_0x12a50f(0x14d)](){const _0x5153d4=a0_0x12a50f;if(this[_0x5153d4(0x165)]=!0x1,this[_0x5153d4(0x190)]?.[_0x5153d4(0x12e)](),this[_0x5153d4(0x18f)])clearInterval(this[_0x5153d4(0x18f)]);await this[_0x5153d4(0x197)](_0x5153d4(0x173))[_0x5153d4(0x18a)](()=>{}),this[_0x5153d4(0x14a)](_0x5153d4(0x169));}async['send'](_0x2b3003,_0x2dcf7b,_0xf9fe3b=a0_0x12a50f(0x15c)){const _0x3e4c59=a0_0x12a50f;return Y({'alias':_0x2b3003,'fromAlias':this[_0x3e4c59(0x126)]},{'log':_0xdd0cf6=>console[_0x3e4c59(0x14a)](_0xdd0cf6),'send':()=>this[_0x3e4c59(0x127)](_0x3e4c59(0x19e),{'alias':_0x2b3003,'task':_0x2dcf7b,'priority':_0xf9fe3b,'from_session':this[_0x3e4c59(0x126)]})});}async[a0_0x12a50f(0x125)](_0xbe2a00,_0x46cb1f){const _0x25c3af=a0_0x12a50f;return this[_0x25c3af(0x127)](_0x25c3af(0x179),{'alias':_0xbe2a00,'message':_0x46cb1f,'from_session':this[_0x25c3af(0x126)]});}async[a0_0x12a50f(0x176)](_0x149882,_0x46becb,_0x23ae9f=a0_0x12a50f(0x14c)){const _0x396aac=a0_0x12a50f;return this[_0x396aac(0x127)](_0x396aac(0x17e),{'in_reply_to':_0x149882,'text':_0x46becb,'status':_0x23ae9f});}async[a0_0x12a50f(0x197)](_0x3fcd77,_0x37be61){const _0x509cab=a0_0x12a50f;return this[_0x509cab(0x127)]('report_status',{'resume_id':this[_0x509cab(0x12f)],'alias':this[_0x509cab(0x126)],'status':_0x3fcd77,'server':a0_0x23411e(),'hostname':a0_0x23411e(),'agent':this[_0x509cab(0x18d)],'project_dir':process[_0x509cab(0x189)](),..._0x37be61});}async[a0_0x12a50f(0x18c)](){const _0x22d5c3=a0_0x12a50f;return this[_0x22d5c3(0x127)](_0x22d5c3(0x143),{});}async['broadcast'](_0x5338e6,_0x55e805){const _0x205993=a0_0x12a50f;return this[_0x205993(0x127)](_0x205993(0x194),{'message':_0x5338e6,'filter_server':_0x55e805?.[_0x205993(0x13b)],'filter_status':_0x55e805?.[_0x205993(0x197)]});}async[a0_0x12a50f(0x14b)](){const _0x5b5205=a0_0x12a50f;let _0x4ae594=encodeURIComponent(this[_0x5b5205(0x126)]),_0x49b19b=this[_0x5b5205(0x196)]+_0x5b5205(0x192)+_0x4ae594,_0x481067=this[_0x5b5205(0x128)];while(this[_0x5b5205(0x165)]){try{this['sseAbort']=new AbortController();let _0x444180={'Accept':'text/event-stream'};if(this[_0x5b5205(0x123)])_0x444180[_0x5b5205(0x138)]=_0x5b5205(0x13d)+this['token'];let _0x286e02=await fetch(_0x49b19b,{'headers':_0x444180,'signal':this['sseAbort']['signal']});if(!_0x286e02['ok']||!_0x286e02[_0x5b5205(0x13c)]){this[_0x5b5205(0x14a)](_0x5b5205(0x159)+_0x286e02[_0x5b5205(0x197)]),await this[_0x5b5205(0x157)](_0x481067),_0x481067=Math[_0x5b5205(0x160)](_0x481067*1.5,0xea60);continue;}_0x481067=this[_0x5b5205(0x128)];let _0x1939b4=_0x286e02[_0x5b5205(0x13c)][_0x5b5205(0x19d)](),_0x29fd8d=new TextDecoder(),_0x41755a='';while(this[_0x5b5205(0x165)]){let {done:_0x2102c4,value:_0x3dcc88}=await _0x1939b4[_0x5b5205(0x153)]();if(_0x2102c4)break;_0x41755a+=_0x29fd8d['decode'](_0x3dcc88,{'stream':!0x0});let _0x393363=_0x41755a[_0x5b5205(0x161)]('\x0a');_0x41755a=_0x393363[_0x5b5205(0x137)]()||'';for(let _0x1d8dad of _0x393363){if(!_0x1d8dad['startsWith']('data:\x20'))continue;try{let _0x4b262d=JSON[_0x5b5205(0x186)](_0x1d8dad[_0x5b5205(0x191)](0x6));if(_0x4b262d['type']===_0x5b5205(0x154)){this[_0x5b5205(0x14a)](_0x5b5205(0x13e)),this[_0x5b5205(0x16d)](_0x5b5205(0x154));continue;}if(_0x4b262d[_0x5b5205(0x12a)]===_0x5b5205(0x131)||_0x4b262d[_0x5b5205(0x12a)]===_0x5b5205(0x195)||_0x4b262d[_0x5b5205(0x12a)]===_0x5b5205(0x194))await this[_0x5b5205(0x15e)]();}catch{}}}}catch(_0x341ac7){if(_0x341ac7[_0x5b5205(0x170)]===_0x5b5205(0x17f))break;this[_0x5b5205(0x16d)](_0x5b5205(0x187),_0x341ac7),this[_0x5b5205(0x14a)](_0x5b5205(0x13a)+_0x341ac7[_0x5b5205(0x125)]);}if(this[_0x5b5205(0x165)])this['emit'](_0x5b5205(0x169)),this[_0x5b5205(0x14a)]('SSE\x20reconnecting\x20in\x20'+_0x481067/0x3e8+'s...'),await this[_0x5b5205(0x157)](_0x481067),_0x481067=Math[_0x5b5205(0x160)](_0x481067*1.5,0xea60);}}async[a0_0x12a50f(0x15e)](){const _0x22389e=a0_0x12a50f;try{let _0x4741ef=(await this[_0x22389e(0x127)](_0x22389e(0x18e),{'alias':this[_0x22389e(0x126)],'limit':0xa}))?.[_0x22389e(0x130)]||[];for(let _0x58e9db of _0x4741ef)await this[_0x22389e(0x127)](_0x22389e(0x12c),{'alias':this['alias'],'message_id':_0x58e9db['id']}),this[_0x22389e(0x14a)]('←\x20'+_0x58e9db[_0x22389e(0x140)]+':\x20'+_0x58e9db[_0x22389e(0x145)][_0x22389e(0x191)](0x0,0x3c)),this[_0x22389e(0x16d)](_0x22389e(0x150),_0x58e9db),this[_0x22389e(0x16d)](_0x22389e(0x125),_0x58e9db);}catch(_0x266791){this[_0x22389e(0x14a)]('inbox\x20error:\x20'+_0x266791[_0x22389e(0x125)]);}}[a0_0x12a50f(0x157)](_0x1e98b3){return new Promise(_0x4a2652=>setTimeout(_0x4a2652,_0x1e98b3));}}var F=$;export{F as default,$ as CommHub};