@sleep2agi/agent-network 2.3.0-preview.186 → 2.3.0-preview.188

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_0x286575=a0_0x125c;(function(_0x344a56,_0x33440f){const _0x26a995=a0_0x125c,_0x116159=_0x344a56();while(!![]){try{const _0x5769ab=-parseInt(_0x26a995(0x1bb))/0x1+-parseInt(_0x26a995(0x223))/0x2+-parseInt(_0x26a995(0x1ba))/0x3+-parseInt(_0x26a995(0x1b3))/0x4+-parseInt(_0x26a995(0x1de))/0x5+parseInt(_0x26a995(0x1d2))/0x6*(-parseInt(_0x26a995(0x207))/0x7)+parseInt(_0x26a995(0x1e3))/0x8;if(_0x5769ab===_0x33440f)break;else _0x116159['push'](_0x116159['shift']());}catch(_0x365cb1){_0x116159['push'](_0x116159['shift']());}}}(a0_0xaa38,0x6d54a));import{EventEmitter as a0_0x47e58b}from'events';import{hostname as a0_0x17f7e5}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x474909,_0x4bd98a)=>(_0x474909??_0x4bd98a)[a0_0x286575(0x1e4)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x286575(0x213)](0x0,0xf0);function N(_0x3e12df){const _0x259bc1=a0_0x286575;return(_0x3e12df instanceof Error?_0x3e12df[_0x259bc1(0x1d3)]:String(_0x3e12df??_0x259bc1(0x1c5)))[_0x259bc1(0x1e4)](K,_0x259bc1(0x1d5))[_0x259bc1(0x1e4)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x259bc1(0x213)](0x0,0xf0);}function O(_0x168293,_0x56f4f0=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x5dabe7=a0_0x286575;if(_0x56f4f0)return JSON['stringify'](_0x168293);let _0xf6398a=L(_0x168293['parent_task_id'],_0x5dabe7(0x20b)),_0x4bf4c8=L(_0x168293[_0x5dabe7(0x1ae)],'<pending>'),_0x4a6e55=_0x168293[_0x5dabe7(0x229)]?_0x5dabe7(0x1fb)+_0x168293[_0x5dabe7(0x229)]+':'+(_0x168293[_0x5dabe7(0x1e2)]??''):'';return _0x5dabe7(0x1bd)+_0x168293[_0x5dabe7(0x1e8)]+_0x5dabe7(0x1c1)+L(_0x168293[_0x5dabe7(0x1c7)],'<unknown>')+_0x5dabe7(0x1db)+L(_0x168293[_0x5dabe7(0x212)],_0x5dabe7(0x1f7))+_0x5dabe7(0x1eb)+_0x4bf4c8+_0x5dabe7(0x1b0)+_0xf6398a+'\x20network_id='+L(_0x168293[_0x5dabe7(0x1d6)],_0x5dabe7(0x1f7))+_0x5dabe7(0x1f2)+_0x168293[_0x5dabe7(0x221)]+_0x5dabe7(0x1cb)+_0x168293['duration_ms']+_0x5dabe7(0x1ee)+_0x168293[_0x5dabe7(0x1f6)]+_0x4a6e55;}function U(_0x2e7d02){const _0x51879a=a0_0x286575;return{'event':{'sending':_0x51879a(0x216),'delivered':_0x51879a(0x20f),'failed':_0x51879a(0x226),'acked':_0x51879a(0x1d4),'started':'task.started','replied':'task.replied','expired':'task.expired'}[_0x2e7d02['status']],..._0x2e7d02};}function j(_0x413279){const _0x16e916=a0_0x286575;let _0x281517=_0x413279?.['task_id']||_0x413279?.[_0x16e916(0x1ef)]||_0x413279?.['id'];if(_0x281517)return String(_0x281517);let _0x5c18d8=_0x413279?.[_0x16e916(0x1b2)]?.[0x0]?.[_0x16e916(0x201)];if(typeof _0x5c18d8!==_0x16e916(0x218))return null;try{let _0x5c5adf=JSON['parse'](_0x5c18d8);return _0x5c5adf?.[_0x16e916(0x1ae)]||_0x5c5adf?.[_0x16e916(0x1ef)]||_0x5c5adf?.['id']||null;}catch{return null;}}function a0_0x125c(_0x39ed80,_0x1fe737){_0x39ed80=_0x39ed80-0x1ad;const _0xaa381a=a0_0xaa38();let _0x125cef=_0xaa381a[_0x39ed80];return _0x125cef;}async function X(_0x198c36,_0x1fde8d){const _0x2a2ce2=a0_0x286575;let _0x245446=_0x1fde8d[_0x2a2ce2(0x1ea)]??Date['now'],_0x253705=_0x245446(),_0x57d53a=(_0x450465,_0x11fbe5,_0x1e4ab9,_0x292ae6)=>{const _0x4fd22b=_0x2a2ce2;_0x1fde8d[_0x4fd22b(0x1d1)](O(U({'from_alias':_0x198c36['fromAlias'],'to_alias':_0x198c36[_0x4fd22b(0x214)],'task_id':_0x11fbe5,'parent_task_id':_0x198c36[_0x4fd22b(0x204)],'network_id':_0x198c36[_0x4fd22b(0x1e7)],'transport':_0x198c36[_0x4fd22b(0x221)],'status':_0x450465,'duration_ms':_0x245446()-_0x253705,'lifecycle_tracking':_0x198c36[_0x4fd22b(0x1b9)],..._0x1e4ab9!==void 0x0?{'error_code':_0x292ae6||_0x4fd22b(0x203),'error_message':N(_0x1e4ab9)}:{}})));};_0x57d53a('sending',null);try{let _0x16c3bf=await _0x1fde8d[_0x2a2ce2(0x21d)](),_0x114134=j(_0x16c3bf);if(_0x114134)_0x57d53a(_0x2a2ce2(0x21a),_0x114134);else{if(_0x16c3bf?.['ok']===!0x1||_0x16c3bf?.[_0x2a2ce2(0x1ff)])_0x57d53a(_0x2a2ce2(0x1b4),_0x114134,_0x16c3bf?.[_0x2a2ce2(0x1ff)]||_0x2a2ce2(0x1b1),_0x2a2ce2(0x1c3));else _0x57d53a(_0x2a2ce2(0x1b4),null,_0x2a2ce2(0x1f3),_0x2a2ce2(0x1f8));}return _0x16c3bf;}catch(_0x235580){throw _0x57d53a(_0x2a2ce2(0x1b4),null,_0x235580,'send_failed'),_0x235580;}}async function Y(_0x3c97be,_0x506f27){const _0x57826a=a0_0x286575;return X({'fromAlias':_0x3c97be['fromAlias'],'toAlias':_0x3c97be['alias'],'parentTaskId':_0x3c97be['parentTaskId']||null,'networkId':_0x3c97be[_0x57826a(0x1e7)]||null,'transport':'mcp_http','lifecycleTracking':'not_tracked'},_0x506f27);}class $ extends a0_0x47e58b{[a0_0x286575(0x228)];[a0_0x286575(0x1b5)];['token'];[a0_0x286575(0x209)];[a0_0x286575(0x222)];['heartbeatInterval'];[a0_0x286575(0x1fe)];[a0_0x286575(0x1bf)];[a0_0x286575(0x1f9)];[a0_0x286575(0x1cd)]=!0x1;constructor(_0x50f025){const _0x28a81f=a0_0x286575;super();if(this['url']=_0x50f025[_0x28a81f(0x228)][_0x28a81f(0x1e4)](/\/$/,''),this[_0x28a81f(0x1b5)]=_0x50f025['alias'],this[_0x28a81f(0x1af)]=_0x50f025[_0x28a81f(0x1af)],this['agent']=_0x50f025[_0x28a81f(0x209)]||'sdk',this['resumeId']='sdk-'+_0x50f025[_0x28a81f(0x1b5)]+'-'+Date[_0x28a81f(0x1ea)]()[_0x28a81f(0x20e)](0x24),this[_0x28a81f(0x1fd)]=_0x50f025[_0x28a81f(0x1fd)]??0x2bf20,this[_0x28a81f(0x1fe)]=_0x50f025[_0x28a81f(0x1fe)]??0xbb8,_0x50f025['autoConnect']!==!0x1)this[_0x28a81f(0x1d8)]();}[a0_0x286575(0x1d1)](_0x535869){const _0x108ebd=a0_0x286575;console[_0x108ebd(0x1d1)]('['+new Date()[_0x108ebd(0x1d9)]()[_0x108ebd(0x213)](0x0,0x8)+_0x108ebd(0x217)+this['alias']+']\x20'+_0x535869);}async['call'](_0x4cdcb2,_0x33e4b5){const _0x592fb5=a0_0x286575;let _0x57dc2d={'Content-Type':_0x592fb5(0x200),'Accept':'application/json,\x20text/event-stream'};if(this[_0x592fb5(0x1af)])_0x57dc2d[_0x592fb5(0x1cc)]='Bearer\x20'+this[_0x592fb5(0x1af)];let _0x204fab=await(await fetch(this[_0x592fb5(0x228)]+_0x592fb5(0x1c8),{'method':_0x592fb5(0x1c9),'headers':_0x57dc2d,'body':JSON['stringify']({'jsonrpc':'2.0','id':Date[_0x592fb5(0x1ea)](),'method':_0x592fb5(0x1e0),'params':{'name':_0x4cdcb2,'arguments':_0x33e4b5}})}))[_0x592fb5(0x201)](),_0x524493=_0x204fab[_0x592fb5(0x219)](/data: (.+)/),_0xf37d90=_0x524493?JSON[_0x592fb5(0x1f4)](_0x524493[0x1]):JSON[_0x592fb5(0x1f4)](_0x204fab),_0x3bbea5=_0xf37d90?.[_0x592fb5(0x21e)]?.[_0x592fb5(0x1b2)]?.[0x0]?.[_0x592fb5(0x201)];return _0x3bbea5?JSON['parse'](_0x3bbea5):_0xf37d90;}async[a0_0x286575(0x1d8)](){const _0x357956=a0_0x286575;if(this[_0x357956(0x1cd)])return;this[_0x357956(0x1cd)]=!0x0,await this[_0x357956(0x1e8)](_0x357956(0x1da)),this[_0x357956(0x1d1)]('registered'),this[_0x357956(0x1bf)]=setInterval(()=>{const _0x178a38=_0x357956;this['status']('idle')['catch'](_0x39a56e=>this[_0x178a38(0x1d1)](_0x178a38(0x20d)+_0x39a56e[_0x178a38(0x1d3)]));},this[_0x357956(0x1fd)]),this[_0x357956(0x1d0)]();}async[a0_0x286575(0x210)](){const _0x498975=a0_0x286575;if(this[_0x498975(0x1cd)]=!0x1,this[_0x498975(0x1f9)]?.[_0x498975(0x1bc)](),this[_0x498975(0x1bf)])clearInterval(this['heartbeatTimer']);await this[_0x498975(0x1e8)](_0x498975(0x1d7))[_0x498975(0x224)](()=>{}),this[_0x498975(0x1d1)](_0x498975(0x1dc));}async['send'](_0x2ac676,_0x346d1c,_0x37b1d7=a0_0x286575(0x1fa)){const _0x3e7858=a0_0x286575;return Y({'alias':_0x2ac676,'fromAlias':this['alias']},{'log':_0x1eeb85=>console[_0x3e7858(0x1d1)](_0x1eeb85),'send':()=>this['call'](_0x3e7858(0x215),{'alias':_0x2ac676,'task':_0x346d1c,'priority':_0x37b1d7,'from_session':this[_0x3e7858(0x1b5)]})});}async[a0_0x286575(0x1d3)](_0x590829,_0x3d1732){const _0x3b957d=a0_0x286575;return this['call'](_0x3b957d(0x208),{'alias':_0x590829,'message':_0x3d1732,'from_session':this[_0x3b957d(0x1b5)]});}async['reply'](_0xd7e3a8,_0x354886,_0x21ecf4=a0_0x286575(0x1b7)){const _0x1d93a4=a0_0x286575;return this[_0x1d93a4(0x1dd)](_0x1d93a4(0x21c),{'in_reply_to':_0xd7e3a8,'text':_0x354886,'status':_0x21ecf4});}async[a0_0x286575(0x1e8)](_0x3e920c,_0x310e95){const _0x5a7c0d=a0_0x286575;return this[_0x5a7c0d(0x1dd)]('report_status',{'resume_id':this[_0x5a7c0d(0x222)],'alias':this[_0x5a7c0d(0x1b5)],'status':_0x3e920c,'server':a0_0x17f7e5(),'hostname':a0_0x17f7e5(),'agent':this[_0x5a7c0d(0x209)],'project_dir':process[_0x5a7c0d(0x1e6)](),..._0x310e95});}async['getAllStatus'](){const _0x36fe90=a0_0x286575;return this[_0x36fe90(0x1dd)](_0x36fe90(0x225),{});}async['broadcast'](_0x35a413,_0x5c191c){const _0x28aeae=a0_0x286575;return this[_0x28aeae(0x1dd)](_0x28aeae(0x1c0),{'message':_0x35a413,'filter_server':_0x5c191c?.[_0x28aeae(0x206)],'filter_status':_0x5c191c?.[_0x28aeae(0x1e8)]});}async[a0_0x286575(0x1d0)](){const _0x44ee1f=a0_0x286575;let _0x46828d=encodeURIComponent(this[_0x44ee1f(0x1b5)]),_0x4a513f=this['url']+_0x44ee1f(0x1e9)+_0x46828d,_0x5cedc0=this[_0x44ee1f(0x1fe)];while(this[_0x44ee1f(0x1cd)]){try{this[_0x44ee1f(0x1f9)]=new AbortController();let _0x1435cf={'Accept':_0x44ee1f(0x1c4)};if(this['token'])_0x1435cf[_0x44ee1f(0x1cc)]='Bearer\x20'+this[_0x44ee1f(0x1af)];let _0x3f7211=await fetch(_0x4a513f,{'headers':_0x1435cf,'signal':this[_0x44ee1f(0x1f9)][_0x44ee1f(0x1c6)]});if(!_0x3f7211['ok']||!_0x3f7211['body']){this[_0x44ee1f(0x1d1)](_0x44ee1f(0x211)+_0x3f7211['status']),await this[_0x44ee1f(0x1ec)](_0x5cedc0),_0x5cedc0=Math[_0x44ee1f(0x21b)](_0x5cedc0*1.5,0xea60);continue;}_0x5cedc0=this[_0x44ee1f(0x1fe)];let _0x57b67d=_0x3f7211['body'][_0x44ee1f(0x1ed)](),_0x1c9f37=new TextDecoder(),_0x48c499='';while(this['running']){let {done:_0x50d75c,value:_0x3f0d74}=await _0x57b67d[_0x44ee1f(0x1df)]();if(_0x50d75c)break;_0x48c499+=_0x1c9f37[_0x44ee1f(0x220)](_0x3f0d74,{'stream':!0x0});let _0x5ec5a7=_0x48c499[_0x44ee1f(0x227)]('\x0a');_0x48c499=_0x5ec5a7[_0x44ee1f(0x1fc)]()||'';for(let _0x196e96 of _0x5ec5a7){if(!_0x196e96['startsWith'](_0x44ee1f(0x1b6)))continue;try{let _0x593ac6=JSON[_0x44ee1f(0x1f4)](_0x196e96[_0x44ee1f(0x213)](0x6));if(_0x593ac6[_0x44ee1f(0x21f)]===_0x44ee1f(0x20c)){this[_0x44ee1f(0x1d1)](_0x44ee1f(0x1ce)),this['emit']('connected');continue;}if(_0x593ac6[_0x44ee1f(0x21f)]===_0x44ee1f(0x202)||_0x593ac6['type']===_0x44ee1f(0x1e1)||_0x593ac6[_0x44ee1f(0x21f)]===_0x44ee1f(0x1c0))await this[_0x44ee1f(0x1be)]();}catch{}}}}catch(_0x2abd91){if(_0x2abd91[_0x44ee1f(0x1f0)]===_0x44ee1f(0x1ad))break;this[_0x44ee1f(0x1f1)](_0x44ee1f(0x1ff),_0x2abd91),this[_0x44ee1f(0x1d1)](_0x44ee1f(0x1cf)+_0x2abd91[_0x44ee1f(0x1d3)]);}if(this['running'])this[_0x44ee1f(0x1f1)](_0x44ee1f(0x1dc)),this[_0x44ee1f(0x1d1)](_0x44ee1f(0x1ca)+_0x5cedc0/0x3e8+_0x44ee1f(0x1e5)),await this[_0x44ee1f(0x1ec)](_0x5cedc0),_0x5cedc0=Math[_0x44ee1f(0x21b)](_0x5cedc0*1.5,0xea60);}}async[a0_0x286575(0x1be)](){const _0x2acf72=a0_0x286575;try{let _0x4ed466=(await this[_0x2acf72(0x1dd)](_0x2acf72(0x1b8),{'alias':this['alias'],'limit':0xa}))?.['messages']||[];for(let _0x4d18e1 of _0x4ed466)await this[_0x2acf72(0x1dd)](_0x2acf72(0x205),{'alias':this[_0x2acf72(0x1b5)],'message_id':_0x4d18e1['id']}),this[_0x2acf72(0x1d1)]('←\x20'+_0x4d18e1[_0x2acf72(0x1c2)]+':\x20'+_0x4d18e1[_0x2acf72(0x1b2)][_0x2acf72(0x213)](0x0,0x3c)),this[_0x2acf72(0x1f1)](_0x2acf72(0x1f5),_0x4d18e1),this['emit']('message',_0x4d18e1);}catch(_0x4991a4){this['log'](_0x2acf72(0x20a)+_0x4991a4[_0x2acf72(0x1d3)]);}}[a0_0x286575(0x1ec)](_0x4534d6){return new Promise(_0x26a7d3=>setTimeout(_0x26a7d3,_0x4534d6));}}function a0_0xaa38(){const _0x2e465e=['19252072vEQALB','replace','s...','cwd','networkId','status','/events/','now','\x20task_id=','sleep','getReader','\x20lifecycle=','message_id','name','emit','\x20transport=','CommHub\x20response\x20omitted\x20task_id','parse','task','lifecycle_tracking','<unknown>','missing_task_id','sseAbort','normal','\x20error=','pop','heartbeatInterval','reconnectDelay','error','application/json','text','new_task','send_failed','parentTaskId','ack_inbox','server','28OELnTf','send_message','agent','inbox\x20error:\x20','<missing>','connected','heartbeat\x20failed:\x20','toString','task.send.delivered','disconnect','SSE\x20failed:\x20','to_alias','slice','toAlias','send_task','task.send.start',']\x20[commhub:','string','match','delivered','min','send_reply','send','result','type','decode','transport','resumeId','1381600ejqOvr','catch','get_all_status','task.send.failed','split','url','error_code','AbortError','task_id','token','\x20parent_task_id=','CommHub\x20rejected\x20task','content','90696wuWsOw','failed','alias','data:\x20','completed','get_inbox','lifecycleTracking','249117zVLyfs','876029EhGghK','abort','[commhub:task]\x20','processInbox','heartbeatTimer','broadcast','\x20from=','from_session','send_rejected','text/event-stream','unknown\x20error','signal','from_alias','/mcp','POST','SSE\x20reconnecting\x20in\x20','\x20duration_ms=','Authorization','running','SSE\x20connected','SSE\x20error:\x20','connectSSE','log','251646vAyHBs','message','task.ack','[REDACTED]','network_id','offline','connect','toTimeString','idle','\x20to=','disconnected','call','591925aaOHkk','read','tools/call','new_message','error_message'];a0_0xaa38=function(){return _0x2e465e;};return a0_0xaa38();}var F=$;export{F as default,$ as CommHub};
1
+ const a0_0x5b0223=a0_0x5cbe;(function(_0x299373,_0x522294){const _0x1ad23d=a0_0x5cbe,_0x5eada2=_0x299373();while(!![]){try{const _0x5870da=-parseInt(_0x1ad23d(0x20f))/0x1+parseInt(_0x1ad23d(0x233))/0x2*(parseInt(_0x1ad23d(0x23a))/0x3)+parseInt(_0x1ad23d(0x227))/0x4+parseInt(_0x1ad23d(0x210))/0x5*(parseInt(_0x1ad23d(0x228))/0x6)+-parseInt(_0x1ad23d(0x1f9))/0x7*(parseInt(_0x1ad23d(0x1ec))/0x8)+parseInt(_0x1ad23d(0x25d))/0x9+parseInt(_0x1ad23d(0x240))/0xa*(-parseInt(_0x1ad23d(0x235))/0xb);if(_0x5870da===_0x522294)break;else _0x5eada2['push'](_0x5eada2['shift']());}catch(_0x390355){_0x5eada2['push'](_0x5eada2['shift']());}}}(a0_0x1651,0x3e4b9));import{EventEmitter as a0_0x68384b}from'events';import{hostname as a0_0x1c71b5}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x3aac50,_0x43d25b)=>(_0x3aac50??_0x43d25b)[a0_0x5b0223(0x263)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x5b0223(0x250)](0x0,0xf0);function N(_0xa99024){const _0x5d1bab=a0_0x5b0223;return(_0xa99024 instanceof Error?_0xa99024[_0x5d1bab(0x20d)]:String(_0xa99024??_0x5d1bab(0x239)))[_0x5d1bab(0x263)](K,_0x5d1bab(0x1fa))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x5d1bab(0x250)](0x0,0xf0);}function a0_0x5cbe(_0x4e7701,_0x4d9946){_0x4e7701=_0x4e7701-0x1e7;const _0x165189=a0_0x1651();let _0x5cbe43=_0x165189[_0x4e7701];return _0x5cbe43;}function a0_0x1651(){const _0x2ff04b=['2086wtUNlT','[REDACTED]','new_task','task.ack','split','task.send.delivered','Authorization','error','task.expired','catch','pop','delivered','content','network_id','getReader','missing_task_id','\x20parent_task_id=','connected','token','task_id','message','broadcast','189908zDNgLn','901585zZNeVI','parent_task_id','alias','parse','message_id','server','send_failed','abort','running','2.0','stringify','from_session','min','ack_inbox','AbortError','toString','transport','heartbeatInterval','data:\x20','match','CommHub\x20response\x20omitted\x20task_id','fromAlias','application/json,\x20text/event-stream','782352SAJlvV','6Ppvdkl','resumeId','decode','<pending>','task.started','text','body','send_task','SSE\x20failed:\x20','task','sdk-','86oDkfoP','url','392095rrPmyu','/events/','disconnected','sleep','unknown\x20error','34014HiEvMa','Bearer\x20','networkId','emit','SSE\x20error:\x20','status','210jAkctz','duration_ms','toAlias','toTimeString','type','heartbeatTimer','lifecycleTracking','application/json','s...','not_tracked','/mcp','POST','agent','send_reply','mcp_http','new_message','slice','idle','to_alias','completed','<missing>','processInbox','startsWith','now','cwd','get_all_status','reconnectDelay','disconnect','task.send.start','4186521lsDFWq','<unknown>','error_code','connect','call','heartbeat\x20failed:\x20','replace','failed','sseAbort','parentTaskId','task.replied','error_message','CommHub\x20rejected\x20task','inbox\x20error:\x20','3624mGUlsi','get_inbox','\x20task_id=','log','connectSSE','result','sending',']\x20[commhub:','\x20transport=','read','\x20network_id=','json','send'];a0_0x1651=function(){return _0x2ff04b;};return a0_0x1651();}function O(_0x58c17e,_0x449aad=process.env.ANET_TASK_TRACE_FORMAT===a0_0x5b0223(0x1f7)){const _0x58de78=a0_0x5b0223;if(_0x449aad)return JSON[_0x58de78(0x21a)](_0x58c17e);let _0x70a47f=L(_0x58c17e[_0x58de78(0x211)],_0x58de78(0x254)),_0x1e0e16=L(_0x58c17e[_0x58de78(0x20c)],_0x58de78(0x22b)),_0x1b1d29=_0x58c17e['error_code']?'\x20error='+_0x58c17e[_0x58de78(0x25f)]+':'+(_0x58c17e[_0x58de78(0x1e9)]??''):'';return'[commhub:task]\x20'+_0x58c17e[_0x58de78(0x23f)]+'\x20from='+L(_0x58c17e['from_alias'],_0x58de78(0x25e))+'\x20to='+L(_0x58c17e[_0x58de78(0x252)],_0x58de78(0x25e))+_0x58de78(0x1ee)+_0x1e0e16+_0x58de78(0x209)+_0x70a47f+_0x58de78(0x1f6)+L(_0x58c17e[_0x58de78(0x206)],_0x58de78(0x25e))+_0x58de78(0x1f4)+_0x58c17e['transport']+'\x20duration_ms='+_0x58c17e[_0x58de78(0x241)]+'\x20lifecycle='+_0x58c17e['lifecycle_tracking']+_0x1b1d29;}function U(_0x36b686){const _0xfede73=a0_0x5b0223;return{'event':{'sending':_0xfede73(0x25c),'delivered':_0xfede73(0x1fe),'failed':'task.send.failed','acked':_0xfede73(0x1fc),'started':_0xfede73(0x22c),'replied':_0xfede73(0x1e8),'expired':_0xfede73(0x201)}[_0x36b686['status']],..._0x36b686};}function j(_0x2ba00f){const _0x2aadc1=a0_0x5b0223;let _0x5c285c=_0x2ba00f?.[_0x2aadc1(0x20c)]||_0x2ba00f?.[_0x2aadc1(0x214)]||_0x2ba00f?.['id'];if(_0x5c285c)return String(_0x5c285c);let _0x3f0242=_0x2ba00f?.[_0x2aadc1(0x205)]?.[0x0]?.['text'];if(typeof _0x3f0242!=='string')return null;try{let _0x4e1c3a=JSON[_0x2aadc1(0x213)](_0x3f0242);return _0x4e1c3a?.[_0x2aadc1(0x20c)]||_0x4e1c3a?.[_0x2aadc1(0x214)]||_0x4e1c3a?.['id']||null;}catch{return null;}}async function X(_0x102b3c,_0x654996){const _0x2ab2e9=a0_0x5b0223;let _0x123c07=_0x654996[_0x2ab2e9(0x257)]??Date[_0x2ab2e9(0x257)],_0x4c0c61=_0x123c07(),_0x46bfcc=(_0x3fd3ba,_0x168645,_0x4898e0,_0x93b37d)=>{const _0x3de3bb=_0x2ab2e9;_0x654996[_0x3de3bb(0x1ef)](O(U({'from_alias':_0x102b3c[_0x3de3bb(0x225)],'to_alias':_0x102b3c[_0x3de3bb(0x242)],'task_id':_0x168645,'parent_task_id':_0x102b3c[_0x3de3bb(0x1e7)],'network_id':_0x102b3c[_0x3de3bb(0x23c)],'transport':_0x102b3c[_0x3de3bb(0x220)],'status':_0x3fd3ba,'duration_ms':_0x123c07()-_0x4c0c61,'lifecycle_tracking':_0x102b3c[_0x3de3bb(0x246)],..._0x4898e0!==void 0x0?{'error_code':_0x93b37d||_0x3de3bb(0x216),'error_message':N(_0x4898e0)}:{}})));};_0x46bfcc(_0x2ab2e9(0x1f2),null);try{let _0x275806=await _0x654996[_0x2ab2e9(0x1f8)](),_0x58e925=j(_0x275806);if(_0x58e925)_0x46bfcc(_0x2ab2e9(0x204),_0x58e925);else{if(_0x275806?.['ok']===!0x1||_0x275806?.[_0x2ab2e9(0x200)])_0x46bfcc(_0x2ab2e9(0x264),_0x58e925,_0x275806?.[_0x2ab2e9(0x200)]||_0x2ab2e9(0x1ea),'send_rejected');else _0x46bfcc(_0x2ab2e9(0x264),null,_0x2ab2e9(0x224),_0x2ab2e9(0x208));}return _0x275806;}catch(_0x444ffe){throw _0x46bfcc(_0x2ab2e9(0x264),null,_0x444ffe,_0x2ab2e9(0x216)),_0x444ffe;}}async function Y(_0x48b3ed,_0x19821e){const _0x33590c=a0_0x5b0223;return X({'fromAlias':_0x48b3ed[_0x33590c(0x225)],'toAlias':_0x48b3ed[_0x33590c(0x212)],'parentTaskId':_0x48b3ed[_0x33590c(0x1e7)]||null,'networkId':_0x48b3ed[_0x33590c(0x23c)]||null,'transport':_0x33590c(0x24e),'lifecycleTracking':_0x33590c(0x249)},_0x19821e);}class $ extends a0_0x68384b{[a0_0x5b0223(0x234)];[a0_0x5b0223(0x212)];[a0_0x5b0223(0x20b)];['agent'];['resumeId'];[a0_0x5b0223(0x221)];[a0_0x5b0223(0x25a)];[a0_0x5b0223(0x245)];[a0_0x5b0223(0x265)];['running']=!0x1;constructor(_0x1f659a){const _0x2c7934=a0_0x5b0223;super();if(this[_0x2c7934(0x234)]=_0x1f659a[_0x2c7934(0x234)][_0x2c7934(0x263)](/\/$/,''),this['alias']=_0x1f659a[_0x2c7934(0x212)],this['token']=_0x1f659a['token'],this['agent']=_0x1f659a[_0x2c7934(0x24c)]||'sdk',this[_0x2c7934(0x229)]=_0x2c7934(0x232)+_0x1f659a[_0x2c7934(0x212)]+'-'+Date['now']()[_0x2c7934(0x21f)](0x24),this[_0x2c7934(0x221)]=_0x1f659a[_0x2c7934(0x221)]??0x2bf20,this['reconnectDelay']=_0x1f659a['reconnectDelay']??0xbb8,_0x1f659a['autoConnect']!==!0x1)this[_0x2c7934(0x260)]();}[a0_0x5b0223(0x1ef)](_0x304bff){const _0x1da6d0=a0_0x5b0223;console[_0x1da6d0(0x1ef)]('['+new Date()[_0x1da6d0(0x243)]()[_0x1da6d0(0x250)](0x0,0x8)+_0x1da6d0(0x1f3)+this[_0x1da6d0(0x212)]+']\x20'+_0x304bff);}async['call'](_0x1d3b9a,_0x3d1a15){const _0x453c00=a0_0x5b0223;let _0x2ca548={'Content-Type':_0x453c00(0x247),'Accept':_0x453c00(0x226)};if(this[_0x453c00(0x20b)])_0x2ca548[_0x453c00(0x1ff)]='Bearer\x20'+this[_0x453c00(0x20b)];let _0x2b7bdf=await(await fetch(this[_0x453c00(0x234)]+_0x453c00(0x24a),{'method':_0x453c00(0x24b),'headers':_0x2ca548,'body':JSON['stringify']({'jsonrpc':_0x453c00(0x219),'id':Date[_0x453c00(0x257)](),'method':'tools/call','params':{'name':_0x1d3b9a,'arguments':_0x3d1a15}})}))[_0x453c00(0x22d)](),_0xfc75c7=_0x2b7bdf[_0x453c00(0x223)](/data: (.+)/),_0x5c7a41=_0xfc75c7?JSON[_0x453c00(0x213)](_0xfc75c7[0x1]):JSON[_0x453c00(0x213)](_0x2b7bdf),_0x5e2012=_0x5c7a41?.[_0x453c00(0x1f1)]?.[_0x453c00(0x205)]?.[0x0]?.[_0x453c00(0x22d)];return _0x5e2012?JSON[_0x453c00(0x213)](_0x5e2012):_0x5c7a41;}async[a0_0x5b0223(0x260)](){const _0x9358b=a0_0x5b0223;if(this[_0x9358b(0x218)])return;this[_0x9358b(0x218)]=!0x0,await this['status'](_0x9358b(0x251)),this['log']('registered'),this[_0x9358b(0x245)]=setInterval(()=>{const _0x26b7d4=_0x9358b;this[_0x26b7d4(0x23f)](_0x26b7d4(0x251))[_0x26b7d4(0x202)](_0x206aa9=>this['log'](_0x26b7d4(0x262)+_0x206aa9[_0x26b7d4(0x20d)]));},this[_0x9358b(0x221)]),this[_0x9358b(0x1f0)]();}async[a0_0x5b0223(0x25b)](){const _0x3f3816=a0_0x5b0223;if(this[_0x3f3816(0x218)]=!0x1,this[_0x3f3816(0x265)]?.[_0x3f3816(0x217)](),this[_0x3f3816(0x245)])clearInterval(this[_0x3f3816(0x245)]);await this[_0x3f3816(0x23f)]('offline')[_0x3f3816(0x202)](()=>{}),this['log'](_0x3f3816(0x237));}async[a0_0x5b0223(0x1f8)](_0x199a2c,_0x5069b4,_0x218705='normal'){const _0x20a29d=a0_0x5b0223;return Y({'alias':_0x199a2c,'fromAlias':this[_0x20a29d(0x212)]},{'log':_0x1a3baa=>console[_0x20a29d(0x1ef)](_0x1a3baa),'send':()=>this['call'](_0x20a29d(0x22f),{'alias':_0x199a2c,'task':_0x5069b4,'priority':_0x218705,'from_session':this[_0x20a29d(0x212)]})});}async[a0_0x5b0223(0x20d)](_0x11ac9c,_0x1d5331){const _0x41472d=a0_0x5b0223;return this[_0x41472d(0x261)]('send_message',{'alias':_0x11ac9c,'message':_0x1d5331,'from_session':this[_0x41472d(0x212)]});}async['reply'](_0x23c323,_0x2ef235,_0x556eaa=a0_0x5b0223(0x253)){const _0x1ab8c3=a0_0x5b0223;return this['call'](_0x1ab8c3(0x24d),{'in_reply_to':_0x23c323,'text':_0x2ef235,'status':_0x556eaa});}async[a0_0x5b0223(0x23f)](_0x979b4b,_0x42c526){const _0x41874a=a0_0x5b0223;return this[_0x41874a(0x261)]('report_status',{'resume_id':this[_0x41874a(0x229)],'alias':this[_0x41874a(0x212)],'status':_0x979b4b,'server':a0_0x1c71b5(),'hostname':a0_0x1c71b5(),'agent':this['agent'],'project_dir':process[_0x41874a(0x258)](),..._0x42c526});}async['getAllStatus'](){const _0x24671f=a0_0x5b0223;return this[_0x24671f(0x261)](_0x24671f(0x259),{});}async[a0_0x5b0223(0x20e)](_0x460622,_0x3ca9ca){const _0x1405ce=a0_0x5b0223;return this[_0x1405ce(0x261)](_0x1405ce(0x20e),{'message':_0x460622,'filter_server':_0x3ca9ca?.[_0x1405ce(0x215)],'filter_status':_0x3ca9ca?.['status']});}async[a0_0x5b0223(0x1f0)](){const _0xe04972=a0_0x5b0223;let _0x211a21=encodeURIComponent(this[_0xe04972(0x212)]),_0x2965f5=this[_0xe04972(0x234)]+_0xe04972(0x236)+_0x211a21,_0x4eb636=this[_0xe04972(0x25a)];while(this[_0xe04972(0x218)]){try{this[_0xe04972(0x265)]=new AbortController();let _0x4a2523={'Accept':'text/event-stream'};if(this[_0xe04972(0x20b)])_0x4a2523[_0xe04972(0x1ff)]=_0xe04972(0x23b)+this[_0xe04972(0x20b)];let _0x5acd96=await fetch(_0x2965f5,{'headers':_0x4a2523,'signal':this[_0xe04972(0x265)]['signal']});if(!_0x5acd96['ok']||!_0x5acd96['body']){this[_0xe04972(0x1ef)](_0xe04972(0x230)+_0x5acd96['status']),await this['sleep'](_0x4eb636),_0x4eb636=Math['min'](_0x4eb636*1.5,0xea60);continue;}_0x4eb636=this[_0xe04972(0x25a)];let _0x38e20e=_0x5acd96[_0xe04972(0x22e)][_0xe04972(0x207)](),_0x541fb8=new TextDecoder(),_0x13966a='';while(this[_0xe04972(0x218)]){let {done:_0x1140ce,value:_0x33e38f}=await _0x38e20e[_0xe04972(0x1f5)]();if(_0x1140ce)break;_0x13966a+=_0x541fb8[_0xe04972(0x22a)](_0x33e38f,{'stream':!0x0});let _0x1295d3=_0x13966a[_0xe04972(0x1fd)]('\x0a');_0x13966a=_0x1295d3[_0xe04972(0x203)]()||'';for(let _0x4c1abe of _0x1295d3){if(!_0x4c1abe[_0xe04972(0x256)](_0xe04972(0x222)))continue;try{let _0x35a75b=JSON[_0xe04972(0x213)](_0x4c1abe[_0xe04972(0x250)](0x6));if(_0x35a75b['type']===_0xe04972(0x20a)){this[_0xe04972(0x1ef)]('SSE\x20connected'),this[_0xe04972(0x23d)]('connected');continue;}if(_0x35a75b[_0xe04972(0x244)]===_0xe04972(0x1fb)||_0x35a75b['type']===_0xe04972(0x24f)||_0x35a75b[_0xe04972(0x244)]===_0xe04972(0x20e))await this[_0xe04972(0x255)]();}catch{}}}}catch(_0x3e2928){if(_0x3e2928['name']===_0xe04972(0x21e))break;this[_0xe04972(0x23d)]('error',_0x3e2928),this[_0xe04972(0x1ef)](_0xe04972(0x23e)+_0x3e2928['message']);}if(this[_0xe04972(0x218)])this[_0xe04972(0x23d)](_0xe04972(0x237)),this['log']('SSE\x20reconnecting\x20in\x20'+_0x4eb636/0x3e8+_0xe04972(0x248)),await this[_0xe04972(0x238)](_0x4eb636),_0x4eb636=Math[_0xe04972(0x21c)](_0x4eb636*1.5,0xea60);}}async[a0_0x5b0223(0x255)](){const _0x5dc8e3=a0_0x5b0223;try{let _0x381877=(await this['call'](_0x5dc8e3(0x1ed),{'alias':this[_0x5dc8e3(0x212)],'limit':0xa}))?.['messages']||[];for(let _0x4a4f4f of _0x381877)await this[_0x5dc8e3(0x261)](_0x5dc8e3(0x21d),{'alias':this[_0x5dc8e3(0x212)],'message_id':_0x4a4f4f['id']}),this[_0x5dc8e3(0x1ef)]('←\x20'+_0x4a4f4f[_0x5dc8e3(0x21b)]+':\x20'+_0x4a4f4f[_0x5dc8e3(0x205)][_0x5dc8e3(0x250)](0x0,0x3c)),this[_0x5dc8e3(0x23d)](_0x5dc8e3(0x231),_0x4a4f4f),this[_0x5dc8e3(0x23d)](_0x5dc8e3(0x20d),_0x4a4f4f);}catch(_0xed67ae){this['log'](_0x5dc8e3(0x1eb)+_0xed67ae[_0x5dc8e3(0x20d)]);}}[a0_0x5b0223(0x238)](_0x11f76b){return new Promise(_0x152d94=>setTimeout(_0x152d94,_0x11f76b));}}var F=$;export{F as default,$ as CommHub};