@sleep2agi/agent-network 2.3.0-preview.225 → 2.3.0-preview.227

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_0x47e872=a0_0x26a4;(function(_0x2656cd,_0x1b295f){const _0x47df9d=a0_0x26a4,_0x123875=_0x2656cd();while(!![]){try{const _0x39a225=-parseInt(_0x47df9d(0xe1))/0x1+parseInt(_0x47df9d(0xdd))/0x2+-parseInt(_0x47df9d(0xda))/0x3*(-parseInt(_0x47df9d(0x116))/0x4)+parseInt(_0x47df9d(0x120))/0x5+parseInt(_0x47df9d(0xd8))/0x6*(-parseInt(_0x47df9d(0xd4))/0x7)+parseInt(_0x47df9d(0xf7))/0x8*(-parseInt(_0x47df9d(0x13a))/0x9)+parseInt(_0x47df9d(0xcc))/0xa*(parseInt(_0x47df9d(0x131))/0xb);if(_0x39a225===_0x1b295f)break;else _0x123875['push'](_0x123875['shift']());}catch(_0x19b5ac){_0x123875['push'](_0x123875['shift']());}}}(a0_0x3eb1,0xa0aa0));function a0_0x3eb1(){const _0x597b8b=['registered','resumeId','failed','disconnected','messages','heartbeatTimer','text','to_alias','get_all_status','new_message','read','1868wrkltV','stringify','<missing>','Authorization','body','connect','mcp_http','url','AbortError','\x20network_id=','1852355NYlyMQ','broadcast','heartbeatInterval','signal','Bearer\x20','send_rejected','slice','reconnectDelay','connectSSE','startsWith','message_id','inbox\x20error:\x20','sending','error','type','s...','task.expired','14145890sJXkDu','lifecycle_tracking','task','error_code','parse','server','tools/call','toAlias','autoConnect','3634893UmVSzZ','getAllStatus','offline','POST','token','agent','\x20error=','json','now','2.0','status','idle','\x20duration_ms=','catch','connected','getReader','heartbeat\x20failed:\x20','content','networkId','10YPlkEy','sseAbort','split','missing_task_id','/mcp','\x20transport=','sleep','reply','21XTxzpo','application/json,\x20text/event-stream','running','delivered','2077230FZHYmP','match','4053XChoNJ','get_inbox','application/json','765664izUUNF','task.send.start','log','lifecycleTracking','165761rwRgUe',']\x20[commhub:','transport','fromAlias','SSE\x20reconnecting\x20in\x20','CommHub\x20response\x20omitted\x20task_id','parentTaskId','toString','unknown\x20error','[commhub:task]\x20','\x20lifecycle=','task.send.failed','normal','emit','sdk-','data:\x20','message','abort','report_status','min','task_id','replace','16ipBgKx','[REDACTED]','processInbox','SSE\x20error:\x20','duration_ms','not_tracked','network_id','<unknown>','CommHub\x20rejected\x20task','toTimeString','alias','/events/','send_reply','send_task','task.started','ack_inbox','text/event-stream','send_failed','call','send_message'];a0_0x3eb1=function(){return _0x597b8b;};return a0_0x3eb1();}import{EventEmitter as a0_0x44a1e0}from'events';import{hostname as a0_0x22f2d5}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x382f22,_0x41828e)=>(_0x382f22??_0x41828e)[a0_0x47e872(0xf6)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x47e872(0x126)](0x0,0xf0);function N(_0x479100){const _0x529afd=a0_0x47e872;return(_0x479100 instanceof Error?_0x479100[_0x529afd(0xf1)]:String(_0x479100??_0x529afd(0xe9)))[_0x529afd(0xf6)](K,_0x529afd(0xf8))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x529afd(0x126)](0x0,0xf0);}function O(_0x5c5083,_0x37d4ed=process.env.ANET_TASK_TRACE_FORMAT===a0_0x47e872(0x141)){const _0x2509fd=a0_0x47e872;if(_0x37d4ed)return JSON[_0x2509fd(0x117)](_0x5c5083);let _0x32c44b=L(_0x5c5083['parent_task_id'],_0x2509fd(0x118)),_0x4cc942=L(_0x5c5083['task_id'],'<pending>'),_0x329055=_0x5c5083[_0x2509fd(0x134)]?_0x2509fd(0x140)+_0x5c5083[_0x2509fd(0x134)]+':'+(_0x5c5083['error_message']??''):'';return _0x2509fd(0xea)+_0x5c5083[_0x2509fd(0x144)]+'\x20from='+L(_0x5c5083['from_alias'],_0x2509fd(0xfe))+'\x20to='+L(_0x5c5083[_0x2509fd(0x112)],_0x2509fd(0xfe))+'\x20task_id='+_0x4cc942+'\x20parent_task_id='+_0x32c44b+_0x2509fd(0x11f)+L(_0x5c5083[_0x2509fd(0xfd)],_0x2509fd(0xfe))+_0x2509fd(0xd1)+_0x5c5083['transport']+_0x2509fd(0xc5)+_0x5c5083[_0x2509fd(0xfb)]+_0x2509fd(0xeb)+_0x5c5083[_0x2509fd(0x132)]+_0x329055;}function U(_0x5e30f2){const _0x53c675=a0_0x47e872;return{'event':{'sending':_0x53c675(0xde),'delivered':'task.send.delivered','failed':_0x53c675(0xec),'acked':'task.ack','started':_0x53c675(0x105),'replied':'task.replied','expired':_0x53c675(0x130)}[_0x5e30f2[_0x53c675(0x144)]],..._0x5e30f2};}function j(_0xa82904){const _0x27c681=a0_0x47e872;let _0x583193=_0xa82904?.[_0x27c681(0xf5)]||_0xa82904?.[_0x27c681(0x12a)]||_0xa82904?.['id'];if(_0x583193)return String(_0x583193);let _0x30bcb1=_0xa82904?.['content']?.[0x0]?.['text'];if(typeof _0x30bcb1!=='string')return null;try{let _0x2db569=JSON[_0x27c681(0x135)](_0x30bcb1);return _0x2db569?.[_0x27c681(0xf5)]||_0x2db569?.[_0x27c681(0x12a)]||_0x2db569?.['id']||null;}catch{return null;}}function a0_0x26a4(_0x5b5ca3,_0x334013){_0x5b5ca3=_0x5b5ca3-0xc5;const _0x3eb1b0=a0_0x3eb1();let _0x26a457=_0x3eb1b0[_0x5b5ca3];return _0x26a457;}async function X(_0x55a238,_0x186993){const _0x3aa222=a0_0x47e872;let _0x5647bf=_0x186993['now']??Date['now'],_0x5475d3=_0x5647bf(),_0x4fde76=(_0x8af672,_0x271731,_0x23dff0,_0x46c07a)=>{const _0x2cc58f=a0_0x26a4;_0x186993[_0x2cc58f(0xdf)](O(U({'from_alias':_0x55a238[_0x2cc58f(0xe4)],'to_alias':_0x55a238[_0x2cc58f(0x138)],'task_id':_0x271731,'parent_task_id':_0x55a238[_0x2cc58f(0xe7)],'network_id':_0x55a238[_0x2cc58f(0xcb)],'transport':_0x55a238[_0x2cc58f(0xe3)],'status':_0x8af672,'duration_ms':_0x5647bf()-_0x5475d3,'lifecycle_tracking':_0x55a238[_0x2cc58f(0xe0)],..._0x23dff0!==void 0x0?{'error_code':_0x46c07a||_0x2cc58f(0x108),'error_message':N(_0x23dff0)}:{}})));};_0x4fde76(_0x3aa222(0x12c),null);try{let _0x373390=await _0x186993['send'](),_0x662141=j(_0x373390);if(_0x662141)_0x4fde76(_0x3aa222(0xd7),_0x662141);else{if(_0x373390?.['ok']===!0x1||_0x373390?.['error'])_0x4fde76(_0x3aa222(0x10d),_0x662141,_0x373390?.[_0x3aa222(0x12d)]||_0x3aa222(0xff),_0x3aa222(0x125));else _0x4fde76(_0x3aa222(0x10d),null,_0x3aa222(0xe6),_0x3aa222(0xcf));}return _0x373390;}catch(_0x1437fd){throw _0x4fde76(_0x3aa222(0x10d),null,_0x1437fd,'send_failed'),_0x1437fd;}}async function Y(_0x4b38ac,_0x39d617){const _0x9ef6f9=a0_0x47e872;return X({'fromAlias':_0x4b38ac['fromAlias'],'toAlias':_0x4b38ac[_0x9ef6f9(0x101)],'parentTaskId':_0x4b38ac[_0x9ef6f9(0xe7)]||null,'networkId':_0x4b38ac[_0x9ef6f9(0xcb)]||null,'transport':_0x9ef6f9(0x11c),'lifecycleTracking':_0x9ef6f9(0xfc)},_0x39d617);}class $ extends a0_0x44a1e0{[a0_0x47e872(0x11d)];[a0_0x47e872(0x101)];[a0_0x47e872(0x13e)];[a0_0x47e872(0x13f)];[a0_0x47e872(0x10c)];['heartbeatInterval'];['reconnectDelay'];[a0_0x47e872(0x110)];['sseAbort'];[a0_0x47e872(0xd6)]=!0x1;constructor(_0x1ce927){const _0x4ec864=a0_0x47e872;super();if(this['url']=_0x1ce927[_0x4ec864(0x11d)][_0x4ec864(0xf6)](/\/$/,''),this[_0x4ec864(0x101)]=_0x1ce927['alias'],this[_0x4ec864(0x13e)]=_0x1ce927['token'],this[_0x4ec864(0x13f)]=_0x1ce927['agent']||'sdk',this[_0x4ec864(0x10c)]=_0x4ec864(0xef)+_0x1ce927[_0x4ec864(0x101)]+'-'+Date['now']()[_0x4ec864(0xe8)](0x24),this[_0x4ec864(0x122)]=_0x1ce927[_0x4ec864(0x122)]??0x2bf20,this['reconnectDelay']=_0x1ce927[_0x4ec864(0x127)]??0xbb8,_0x1ce927[_0x4ec864(0x139)]!==!0x1)this[_0x4ec864(0x11b)]();}[a0_0x47e872(0xdf)](_0x4eb69a){const _0x81889e=a0_0x47e872;console[_0x81889e(0xdf)]('['+new Date()[_0x81889e(0x100)]()[_0x81889e(0x126)](0x0,0x8)+_0x81889e(0xe2)+this[_0x81889e(0x101)]+']\x20'+_0x4eb69a);}async[a0_0x47e872(0x109)](_0x190af3,_0x1d3de5){const _0x2d2eb5=a0_0x47e872;let _0x15b805={'Content-Type':_0x2d2eb5(0xdc),'Accept':_0x2d2eb5(0xd5)};if(this[_0x2d2eb5(0x13e)])_0x15b805['Authorization']=_0x2d2eb5(0x124)+this[_0x2d2eb5(0x13e)];let _0x5c8aeb=await(await fetch(this['url']+_0x2d2eb5(0xd0),{'method':_0x2d2eb5(0x13d),'headers':_0x15b805,'body':JSON[_0x2d2eb5(0x117)]({'jsonrpc':_0x2d2eb5(0x143),'id':Date[_0x2d2eb5(0x142)](),'method':_0x2d2eb5(0x137),'params':{'name':_0x190af3,'arguments':_0x1d3de5}})}))[_0x2d2eb5(0x111)](),_0x4e130d=_0x5c8aeb[_0x2d2eb5(0xd9)](/data: (.+)/),_0x1e9933=_0x4e130d?JSON[_0x2d2eb5(0x135)](_0x4e130d[0x1]):JSON['parse'](_0x5c8aeb),_0x4f5e94=_0x1e9933?.['result']?.[_0x2d2eb5(0xca)]?.[0x0]?.['text'];return _0x4f5e94?JSON['parse'](_0x4f5e94):_0x1e9933;}async[a0_0x47e872(0x11b)](){const _0x1709fe=a0_0x47e872;if(this['running'])return;this['running']=!0x0,await this[_0x1709fe(0x144)](_0x1709fe(0x145)),this[_0x1709fe(0xdf)](_0x1709fe(0x10b)),this['heartbeatTimer']=setInterval(()=>{const _0x1f4c25=_0x1709fe;this[_0x1f4c25(0x144)](_0x1f4c25(0x145))[_0x1f4c25(0xc6)](_0x25a531=>this[_0x1f4c25(0xdf)](_0x1f4c25(0xc9)+_0x25a531[_0x1f4c25(0xf1)]));},this[_0x1709fe(0x122)]),this['connectSSE']();}async['disconnect'](){const _0x7213dc=a0_0x47e872;if(this[_0x7213dc(0xd6)]=!0x1,this[_0x7213dc(0xcd)]?.[_0x7213dc(0xf2)](),this[_0x7213dc(0x110)])clearInterval(this['heartbeatTimer']);await this[_0x7213dc(0x144)](_0x7213dc(0x13c))[_0x7213dc(0xc6)](()=>{}),this[_0x7213dc(0xdf)](_0x7213dc(0x10e));}async['send'](_0x20b32b,_0x531652,_0x51385c=a0_0x47e872(0xed)){const _0x594f8d=a0_0x47e872;return Y({'alias':_0x20b32b,'fromAlias':this[_0x594f8d(0x101)]},{'log':_0x37b5e3=>console['log'](_0x37b5e3),'send':()=>this[_0x594f8d(0x109)](_0x594f8d(0x104),{'alias':_0x20b32b,'task':_0x531652,'priority':_0x51385c,'from_session':this['alias']})});}async['message'](_0x1718f7,_0x23b7f7){const _0x5b21dc=a0_0x47e872;return this[_0x5b21dc(0x109)](_0x5b21dc(0x10a),{'alias':_0x1718f7,'message':_0x23b7f7,'from_session':this[_0x5b21dc(0x101)]});}async[a0_0x47e872(0xd3)](_0x5bf5bb,_0x50bb16,_0x21e975='completed'){const _0x2a97f3=a0_0x47e872;return this['call'](_0x2a97f3(0x103),{'in_reply_to':_0x5bf5bb,'text':_0x50bb16,'status':_0x21e975});}async[a0_0x47e872(0x144)](_0x3ac902,_0x4364dc){const _0x3e939a=a0_0x47e872;return this[_0x3e939a(0x109)](_0x3e939a(0xf3),{'resume_id':this[_0x3e939a(0x10c)],'alias':this[_0x3e939a(0x101)],'status':_0x3ac902,'server':a0_0x22f2d5(),'hostname':a0_0x22f2d5(),'agent':this[_0x3e939a(0x13f)],'project_dir':process['cwd'](),..._0x4364dc});}async[a0_0x47e872(0x13b)](){const _0x74b095=a0_0x47e872;return this[_0x74b095(0x109)](_0x74b095(0x113),{});}async['broadcast'](_0x3facc8,_0x406c5b){const _0x47c134=a0_0x47e872;return this[_0x47c134(0x109)]('broadcast',{'message':_0x3facc8,'filter_server':_0x406c5b?.[_0x47c134(0x136)],'filter_status':_0x406c5b?.[_0x47c134(0x144)]});}async[a0_0x47e872(0x128)](){const _0x30a140=a0_0x47e872;let _0x761e7=encodeURIComponent(this[_0x30a140(0x101)]),_0x232673=this[_0x30a140(0x11d)]+_0x30a140(0x102)+_0x761e7,_0x158b9a=this['reconnectDelay'];while(this[_0x30a140(0xd6)]){try{this[_0x30a140(0xcd)]=new AbortController();let _0x708c23={'Accept':_0x30a140(0x107)};if(this['token'])_0x708c23[_0x30a140(0x119)]='Bearer\x20'+this['token'];let _0xe03293=await fetch(_0x232673,{'headers':_0x708c23,'signal':this[_0x30a140(0xcd)][_0x30a140(0x123)]});if(!_0xe03293['ok']||!_0xe03293[_0x30a140(0x11a)]){this[_0x30a140(0xdf)]('SSE\x20failed:\x20'+_0xe03293[_0x30a140(0x144)]),await this['sleep'](_0x158b9a),_0x158b9a=Math[_0x30a140(0xf4)](_0x158b9a*1.5,0xea60);continue;}_0x158b9a=this[_0x30a140(0x127)];let _0x233ff6=_0xe03293[_0x30a140(0x11a)][_0x30a140(0xc8)](),_0x5f2165=new TextDecoder(),_0x59e478='';while(this[_0x30a140(0xd6)]){let {done:_0x403d4d,value:_0x251c8b}=await _0x233ff6[_0x30a140(0x115)]();if(_0x403d4d)break;_0x59e478+=_0x5f2165['decode'](_0x251c8b,{'stream':!0x0});let _0x206faa=_0x59e478[_0x30a140(0xce)]('\x0a');_0x59e478=_0x206faa['pop']()||'';for(let _0x52c5c6 of _0x206faa){if(!_0x52c5c6[_0x30a140(0x129)](_0x30a140(0xf0)))continue;try{let _0x573bf7=JSON[_0x30a140(0x135)](_0x52c5c6[_0x30a140(0x126)](0x6));if(_0x573bf7[_0x30a140(0x12e)]==='connected'){this[_0x30a140(0xdf)]('SSE\x20connected'),this[_0x30a140(0xee)](_0x30a140(0xc7));continue;}if(_0x573bf7['type']==='new_task'||_0x573bf7[_0x30a140(0x12e)]===_0x30a140(0x114)||_0x573bf7[_0x30a140(0x12e)]===_0x30a140(0x121))await this['processInbox']();}catch{}}}}catch(_0x2b0278){if(_0x2b0278['name']===_0x30a140(0x11e))break;this['emit'](_0x30a140(0x12d),_0x2b0278),this[_0x30a140(0xdf)](_0x30a140(0xfa)+_0x2b0278[_0x30a140(0xf1)]);}if(this[_0x30a140(0xd6)])this[_0x30a140(0xee)](_0x30a140(0x10e)),this[_0x30a140(0xdf)](_0x30a140(0xe5)+_0x158b9a/0x3e8+_0x30a140(0x12f)),await this[_0x30a140(0xd2)](_0x158b9a),_0x158b9a=Math[_0x30a140(0xf4)](_0x158b9a*1.5,0xea60);}}async[a0_0x47e872(0xf9)](){const _0x1dc709=a0_0x47e872;try{let _0x257580=(await this['call'](_0x1dc709(0xdb),{'alias':this['alias'],'limit':0xa}))?.[_0x1dc709(0x10f)]||[];for(let _0x1dbdf5 of _0x257580)await this[_0x1dc709(0x109)](_0x1dc709(0x106),{'alias':this[_0x1dc709(0x101)],'message_id':_0x1dbdf5['id']}),this[_0x1dc709(0xdf)]('←\x20'+_0x1dbdf5['from_session']+':\x20'+_0x1dbdf5[_0x1dc709(0xca)][_0x1dc709(0x126)](0x0,0x3c)),this[_0x1dc709(0xee)](_0x1dc709(0x133),_0x1dbdf5),this[_0x1dc709(0xee)](_0x1dc709(0xf1),_0x1dbdf5);}catch(_0x5b9cff){this[_0x1dc709(0xdf)](_0x1dc709(0x12b)+_0x5b9cff['message']);}}[a0_0x47e872(0xd2)](_0x4ad855){return new Promise(_0x121e87=>setTimeout(_0x121e87,_0x4ad855));}}var F=$;export{F as default,$ as CommHub};
1
+ function a0_0xea17(){const _0x91977a=['connect','sseAbort','Bearer\x20','disconnected','cwd','completed','status','log','<unknown>','Authorization','duration_ms','error_code','match','send_failed','POST','2743016HOVrBu','report_status','from_alias','content','signal','replace','\x20to=','network_id','url','s...','startsWith','broadcast','heartbeatTimer','agent','CommHub\x20rejected\x20task','token','string','text','toAlias','task','task.send.start','SSE\x20error:\x20','to_alias','connected','/mcp','160zPjIVL','get_inbox','send','name','idle','message_id','task.ack','fromAlias','lifecycle_tracking','failed','catch','slice','transport','getReader','task.send.delivered','parse','result','9eeazls','read','10890495lflFlv','/events/','data:\x20','error','heartbeatInterval','body','lifecycleTracking','server','disconnect','parent_task_id','message','2232027mXLSyF','sdk-','processInbox','task.replied','\x20network_id=','min','SSE\x20reconnecting\x20in\x20','networkId','emit','task.started','running','\x20from=','type','send_reply','call','tools/call','sleep','unknown\x20error','offline','toString','registered','pop','send_rejected','delivered','not_tracked','parentTaskId','task.expired','abort','alias','decode','\x20transport=','\x20duration_ms=','inbox\x20error:\x20','resumeId','text/event-stream','<missing>','heartbeat\x20failed:\x20','\x20error=','5654256YEYPZI','SSE\x20failed:\x20','task_id','45481224RTeRzH','new_task','send_message','77472HvWYrL','autoConnect','json','now','\x20task_id=','735955irAHZT','missing_task_id','new_message','[commhub:task]\x20','send_task'];a0_0xea17=function(){return _0x91977a;};return a0_0xea17();}const a0_0x24b300=a0_0xb6ab;(function(_0x11a11a,_0x4c4014){const _0x2369de=a0_0xb6ab,_0x1d5cb1=_0x11a11a();while(!![]){try{const _0x134ae2=-parseInt(_0x2369de(0xf2))/0x1+-parseInt(_0x2369de(0x106))/0x2+parseInt(_0x2369de(0xc1))/0x3+-parseInt(_0x2369de(0xe7))/0x4+-parseInt(_0x2369de(0xa3))/0x5*(parseInt(_0x2369de(0xed))/0x6)+-parseInt(_0x2369de(0xb6))/0x7+parseInt(_0x2369de(0xea))/0x8*(parseInt(_0x2369de(0xb4))/0x9);if(_0x134ae2===_0x4c4014)break;else _0x1d5cb1['push'](_0x1d5cb1['shift']());}catch(_0x727bd2){_0x1d5cb1['push'](_0x1d5cb1['shift']());}}}(a0_0xea17,0xe549e));import{EventEmitter as a0_0x2ab3f9}from'events';import{hostname as a0_0x44f980}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0xf8afc4,_0x2d79e4)=>(_0xf8afc4??_0x2d79e4)[a0_0x24b300(0x10b)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x24b300(0xae)](0x0,0xf0);function N(_0xe5f749){const _0x1fe948=a0_0x24b300;return(_0xe5f749 instanceof Error?_0xe5f749['message']:String(_0xe5f749??_0x1fe948(0xd2)))[_0x1fe948(0x10b)](K,'[REDACTED]')[_0x1fe948(0x10b)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x1fe948(0xae)](0x0,0xf0);}function O(_0x53378f,_0x55a51f=process.env.ANET_TASK_TRACE_FORMAT===a0_0x24b300(0xef)){const _0x1ebb7c=a0_0x24b300;if(_0x55a51f)return JSON['stringify'](_0x53378f);let _0x2506b5=L(_0x53378f[_0x1ebb7c(0xbf)],_0x1ebb7c(0xe4)),_0x1e19cc=L(_0x53378f['task_id'],'<pending>'),_0x374992=_0x53378f['error_code']?_0x1ebb7c(0xe6)+_0x53378f[_0x1ebb7c(0x102)]+':'+(_0x53378f['error_message']??''):'';return _0x1ebb7c(0xf5)+_0x53378f[_0x1ebb7c(0xfd)]+_0x1ebb7c(0xcc)+L(_0x53378f[_0x1ebb7c(0x108)],_0x1ebb7c(0xff))+_0x1ebb7c(0x10c)+L(_0x53378f[_0x1ebb7c(0xa0)],_0x1ebb7c(0xff))+_0x1ebb7c(0xf1)+_0x1e19cc+'\x20parent_task_id='+_0x2506b5+_0x1ebb7c(0xc5)+L(_0x53378f[_0x1ebb7c(0x10d)],_0x1ebb7c(0xff))+_0x1ebb7c(0xdf)+_0x53378f[_0x1ebb7c(0xaf)]+_0x1ebb7c(0xe0)+_0x53378f[_0x1ebb7c(0x101)]+'\x20lifecycle='+_0x53378f[_0x1ebb7c(0xab)]+_0x374992;}function U(_0x3a6f42){const _0x560b00=a0_0x24b300;return{'event':{'sending':_0x560b00(0x9e),'delivered':_0x560b00(0xb1),'failed':'task.send.failed','acked':_0x560b00(0xa9),'started':_0x560b00(0xca),'replied':_0x560b00(0xc4),'expired':_0x560b00(0xdb)}[_0x3a6f42['status']],..._0x3a6f42};}function j(_0x179d10){const _0x1778b4=a0_0x24b300;let _0x22ab50=_0x179d10?.[_0x1778b4(0xe9)]||_0x179d10?.['message_id']||_0x179d10?.['id'];if(_0x22ab50)return String(_0x22ab50);let _0x298b12=_0x179d10?.[_0x1778b4(0x109)]?.[0x0]?.[_0x1778b4(0x117)];if(typeof _0x298b12!==_0x1778b4(0x116))return null;try{let _0x56e1f3=JSON['parse'](_0x298b12);return _0x56e1f3?.[_0x1778b4(0xe9)]||_0x56e1f3?.[_0x1778b4(0xa8)]||_0x56e1f3?.['id']||null;}catch{return null;}}async function X(_0x5aba4e,_0x2759a9){const _0x42a548=a0_0x24b300;let _0x25a3aa=_0x2759a9[_0x42a548(0xf0)]??Date['now'],_0x4c1b11=_0x25a3aa(),_0x205d7e=(_0x5c50a8,_0x45a80c,_0x188599,_0x19d1ab)=>{const _0x590f31=_0x42a548;_0x2759a9[_0x590f31(0xfe)](O(U({'from_alias':_0x5aba4e[_0x590f31(0xaa)],'to_alias':_0x5aba4e[_0x590f31(0x118)],'task_id':_0x45a80c,'parent_task_id':_0x5aba4e[_0x590f31(0xda)],'network_id':_0x5aba4e['networkId'],'transport':_0x5aba4e[_0x590f31(0xaf)],'status':_0x5c50a8,'duration_ms':_0x25a3aa()-_0x4c1b11,'lifecycle_tracking':_0x5aba4e[_0x590f31(0xbc)],..._0x188599!==void 0x0?{'error_code':_0x19d1ab||'send_failed','error_message':N(_0x188599)}:{}})));};_0x205d7e('sending',null);try{let _0x1c7b3b=await _0x2759a9[_0x42a548(0xa5)](),_0x5b7e0e=j(_0x1c7b3b);if(_0x5b7e0e)_0x205d7e(_0x42a548(0xd8),_0x5b7e0e);else{if(_0x1c7b3b?.['ok']===!0x1||_0x1c7b3b?.[_0x42a548(0xb9)])_0x205d7e(_0x42a548(0xac),_0x5b7e0e,_0x1c7b3b?.['error']||_0x42a548(0x114),_0x42a548(0xd7));else _0x205d7e(_0x42a548(0xac),null,'CommHub\x20response\x20omitted\x20task_id',_0x42a548(0xf3));}return _0x1c7b3b;}catch(_0x246b79){throw _0x205d7e(_0x42a548(0xac),null,_0x246b79,_0x42a548(0x104)),_0x246b79;}}function a0_0xb6ab(_0x4e5c09,_0x2b528b){_0x4e5c09=_0x4e5c09-0x9e;const _0xea17ab=a0_0xea17();let _0xb6ab27=_0xea17ab[_0x4e5c09];return _0xb6ab27;}async function Y(_0x121547,_0x1db3ea){const _0x40d1b4=a0_0x24b300;return X({'fromAlias':_0x121547['fromAlias'],'toAlias':_0x121547[_0x40d1b4(0xdd)],'parentTaskId':_0x121547[_0x40d1b4(0xda)]||null,'networkId':_0x121547[_0x40d1b4(0xc8)]||null,'transport':'mcp_http','lifecycleTracking':_0x40d1b4(0xd9)},_0x1db3ea);}class $ extends a0_0x2ab3f9{[a0_0x24b300(0x10e)];[a0_0x24b300(0xdd)];['token'];['agent'];[a0_0x24b300(0xe2)];[a0_0x24b300(0xba)];['reconnectDelay'];[a0_0x24b300(0x112)];[a0_0x24b300(0xf8)];[a0_0x24b300(0xcb)]=!0x1;constructor(_0x37aaa9){const _0x48ffcb=a0_0x24b300;super();if(this[_0x48ffcb(0x10e)]=_0x37aaa9[_0x48ffcb(0x10e)][_0x48ffcb(0x10b)](/\/$/,''),this[_0x48ffcb(0xdd)]=_0x37aaa9[_0x48ffcb(0xdd)],this[_0x48ffcb(0x115)]=_0x37aaa9[_0x48ffcb(0x115)],this['agent']=_0x37aaa9[_0x48ffcb(0x113)]||'sdk',this[_0x48ffcb(0xe2)]=_0x48ffcb(0xc2)+_0x37aaa9[_0x48ffcb(0xdd)]+'-'+Date['now']()[_0x48ffcb(0xd4)](0x24),this[_0x48ffcb(0xba)]=_0x37aaa9[_0x48ffcb(0xba)]??0x2bf20,this['reconnectDelay']=_0x37aaa9['reconnectDelay']??0xbb8,_0x37aaa9[_0x48ffcb(0xee)]!==!0x1)this[_0x48ffcb(0xf7)]();}[a0_0x24b300(0xfe)](_0x31f111){const _0x4ca841=a0_0x24b300;console[_0x4ca841(0xfe)]('['+new Date()['toTimeString']()[_0x4ca841(0xae)](0x0,0x8)+']\x20[commhub:'+this['alias']+']\x20'+_0x31f111);}async[a0_0x24b300(0xcf)](_0x455045,_0x161728){const _0x366aea=a0_0x24b300;let _0x2fb344={'Content-Type':'application/json','Accept':'application/json,\x20text/event-stream'};if(this[_0x366aea(0x115)])_0x2fb344[_0x366aea(0x100)]=_0x366aea(0xf9)+this[_0x366aea(0x115)];let _0x56b291=await(await fetch(this[_0x366aea(0x10e)]+_0x366aea(0xa2),{'method':_0x366aea(0x105),'headers':_0x2fb344,'body':JSON['stringify']({'jsonrpc':'2.0','id':Date['now'](),'method':_0x366aea(0xd0),'params':{'name':_0x455045,'arguments':_0x161728}})}))[_0x366aea(0x117)](),_0x34d742=_0x56b291[_0x366aea(0x103)](/data: (.+)/),_0x3f747c=_0x34d742?JSON['parse'](_0x34d742[0x1]):JSON[_0x366aea(0xb2)](_0x56b291),_0x4e3c4=_0x3f747c?.[_0x366aea(0xb3)]?.[_0x366aea(0x109)]?.[0x0]?.[_0x366aea(0x117)];return _0x4e3c4?JSON[_0x366aea(0xb2)](_0x4e3c4):_0x3f747c;}async[a0_0x24b300(0xf7)](){const _0x5530d2=a0_0x24b300;if(this['running'])return;this[_0x5530d2(0xcb)]=!0x0,await this[_0x5530d2(0xfd)](_0x5530d2(0xa7)),this['log'](_0x5530d2(0xd5)),this[_0x5530d2(0x112)]=setInterval(()=>{const _0x2552cb=_0x5530d2;this['status'](_0x2552cb(0xa7))[_0x2552cb(0xad)](_0x13e506=>this['log'](_0x2552cb(0xe5)+_0x13e506[_0x2552cb(0xc0)]));},this[_0x5530d2(0xba)]),this['connectSSE']();}async[a0_0x24b300(0xbe)](){const _0x5f11e5=a0_0x24b300;if(this[_0x5f11e5(0xcb)]=!0x1,this[_0x5f11e5(0xf8)]?.[_0x5f11e5(0xdc)](),this[_0x5f11e5(0x112)])clearInterval(this['heartbeatTimer']);await this[_0x5f11e5(0xfd)](_0x5f11e5(0xd3))['catch'](()=>{}),this[_0x5f11e5(0xfe)](_0x5f11e5(0xfa));}async[a0_0x24b300(0xa5)](_0x50d2b2,_0x5be310,_0x8cbc0f='normal'){const _0x25fbba=a0_0x24b300;return Y({'alias':_0x50d2b2,'fromAlias':this[_0x25fbba(0xdd)]},{'log':_0x52fb50=>console[_0x25fbba(0xfe)](_0x52fb50),'send':()=>this[_0x25fbba(0xcf)](_0x25fbba(0xf6),{'alias':_0x50d2b2,'task':_0x5be310,'priority':_0x8cbc0f,'from_session':this['alias']})});}async[a0_0x24b300(0xc0)](_0x211019,_0x18996f){const _0x28e1b3=a0_0x24b300;return this[_0x28e1b3(0xcf)](_0x28e1b3(0xec),{'alias':_0x211019,'message':_0x18996f,'from_session':this[_0x28e1b3(0xdd)]});}async['reply'](_0x1fbb7c,_0x213c90,_0x4026a5=a0_0x24b300(0xfc)){const _0xc734bc=a0_0x24b300;return this[_0xc734bc(0xcf)](_0xc734bc(0xce),{'in_reply_to':_0x1fbb7c,'text':_0x213c90,'status':_0x4026a5});}async[a0_0x24b300(0xfd)](_0x28a0c0,_0x337e55){const _0x1d1b13=a0_0x24b300;return this['call'](_0x1d1b13(0x107),{'resume_id':this[_0x1d1b13(0xe2)],'alias':this[_0x1d1b13(0xdd)],'status':_0x28a0c0,'server':a0_0x44f980(),'hostname':a0_0x44f980(),'agent':this[_0x1d1b13(0x113)],'project_dir':process[_0x1d1b13(0xfb)](),..._0x337e55});}async['getAllStatus'](){const _0x2b5c9e=a0_0x24b300;return this[_0x2b5c9e(0xcf)]('get_all_status',{});}async['broadcast'](_0xf25a30,_0x5baa88){const _0x4c701a=a0_0x24b300;return this[_0x4c701a(0xcf)](_0x4c701a(0x111),{'message':_0xf25a30,'filter_server':_0x5baa88?.[_0x4c701a(0xbd)],'filter_status':_0x5baa88?.[_0x4c701a(0xfd)]});}async['connectSSE'](){const _0x1404c1=a0_0x24b300;let _0x20aed7=encodeURIComponent(this[_0x1404c1(0xdd)]),_0x2994d2=this['url']+_0x1404c1(0xb7)+_0x20aed7,_0x4c12ac=this['reconnectDelay'];while(this['running']){try{this[_0x1404c1(0xf8)]=new AbortController();let _0x4aacb8={'Accept':_0x1404c1(0xe3)};if(this[_0x1404c1(0x115)])_0x4aacb8['Authorization']=_0x1404c1(0xf9)+this[_0x1404c1(0x115)];let _0x2baf88=await fetch(_0x2994d2,{'headers':_0x4aacb8,'signal':this[_0x1404c1(0xf8)][_0x1404c1(0x10a)]});if(!_0x2baf88['ok']||!_0x2baf88[_0x1404c1(0xbb)]){this[_0x1404c1(0xfe)](_0x1404c1(0xe8)+_0x2baf88[_0x1404c1(0xfd)]),await this[_0x1404c1(0xd1)](_0x4c12ac),_0x4c12ac=Math[_0x1404c1(0xc6)](_0x4c12ac*1.5,0xea60);continue;}_0x4c12ac=this['reconnectDelay'];let _0x4f00c4=_0x2baf88[_0x1404c1(0xbb)][_0x1404c1(0xb0)](),_0x10b856=new TextDecoder(),_0x31e645='';while(this[_0x1404c1(0xcb)]){let {done:_0x1243eb,value:_0xccee76}=await _0x4f00c4[_0x1404c1(0xb5)]();if(_0x1243eb)break;_0x31e645+=_0x10b856[_0x1404c1(0xde)](_0xccee76,{'stream':!0x0});let _0x389f59=_0x31e645['split']('\x0a');_0x31e645=_0x389f59[_0x1404c1(0xd6)]()||'';for(let _0x53b2a6 of _0x389f59){if(!_0x53b2a6[_0x1404c1(0x110)](_0x1404c1(0xb8)))continue;try{let _0x548ef5=JSON[_0x1404c1(0xb2)](_0x53b2a6[_0x1404c1(0xae)](0x6));if(_0x548ef5['type']===_0x1404c1(0xa1)){this['log']('SSE\x20connected'),this['emit'](_0x1404c1(0xa1));continue;}if(_0x548ef5[_0x1404c1(0xcd)]===_0x1404c1(0xeb)||_0x548ef5['type']===_0x1404c1(0xf4)||_0x548ef5[_0x1404c1(0xcd)]===_0x1404c1(0x111))await this['processInbox']();}catch{}}}}catch(_0x5b1c4f){if(_0x5b1c4f[_0x1404c1(0xa6)]==='AbortError')break;this[_0x1404c1(0xc9)](_0x1404c1(0xb9),_0x5b1c4f),this[_0x1404c1(0xfe)](_0x1404c1(0x9f)+_0x5b1c4f[_0x1404c1(0xc0)]);}if(this[_0x1404c1(0xcb)])this['emit'](_0x1404c1(0xfa)),this[_0x1404c1(0xfe)](_0x1404c1(0xc7)+_0x4c12ac/0x3e8+_0x1404c1(0x10f)),await this[_0x1404c1(0xd1)](_0x4c12ac),_0x4c12ac=Math[_0x1404c1(0xc6)](_0x4c12ac*1.5,0xea60);}}async[a0_0x24b300(0xc3)](){const _0x3342ae=a0_0x24b300;try{let _0x160966=(await this[_0x3342ae(0xcf)](_0x3342ae(0xa4),{'alias':this['alias'],'limit':0xa}))?.['messages']||[];for(let _0x480794 of _0x160966)await this[_0x3342ae(0xcf)]('ack_inbox',{'alias':this[_0x3342ae(0xdd)],'message_id':_0x480794['id']}),this[_0x3342ae(0xfe)]('←\x20'+_0x480794['from_session']+':\x20'+_0x480794[_0x3342ae(0x109)][_0x3342ae(0xae)](0x0,0x3c)),this[_0x3342ae(0xc9)](_0x3342ae(0x119),_0x480794),this[_0x3342ae(0xc9)](_0x3342ae(0xc0),_0x480794);}catch(_0x4a9c21){this[_0x3342ae(0xfe)](_0x3342ae(0xe1)+_0x4a9c21[_0x3342ae(0xc0)]);}}['sleep'](_0x4421c2){return new Promise(_0x494e97=>setTimeout(_0x494e97,_0x4421c2));}}var F=$;export{F as default,$ as CommHub};