@sleep2agi/agent-network 2.3.0-preview.50 → 2.3.0-preview.52

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_0x2b779f=a0_0x4ece;(function(_0x33dff6,_0x800a3e){const _0x4cbabb=a0_0x4ece,_0x581bce=_0x33dff6();while(!![]){try{const _0x27f1ab=-parseInt(_0x4cbabb(0x21b))/0x1*(-parseInt(_0x4cbabb(0x254))/0x2)+parseInt(_0x4cbabb(0x1ff))/0x3*(parseInt(_0x4cbabb(0x1fc))/0x4)+parseInt(_0x4cbabb(0x242))/0x5*(parseInt(_0x4cbabb(0x1f4))/0x6)+parseInt(_0x4cbabb(0x25a))/0x7*(-parseInt(_0x4cbabb(0x1ea))/0x8)+parseInt(_0x4cbabb(0x20f))/0x9+-parseInt(_0x4cbabb(0x25c))/0xa*(parseInt(_0x4cbabb(0x24c))/0xb)+-parseInt(_0x4cbabb(0x23e))/0xc;if(_0x27f1ab===_0x800a3e)break;else _0x581bce['push'](_0x581bce['shift']());}catch(_0x525195){_0x581bce['push'](_0x581bce['shift']());}}}(a0_0x47b1,0xc4bf1));function a0_0x47b1(){const _0x5b081c=[']\x20[commhub:','signal','12459573wrQwkW','result','json','<missing>','string','message_id','fromAlias','failed','parse','agent','call','data:\x20','1zPjjgd','stringify','2.0','split','connectSSE','from_session','send_failed','broadcast','processInbox','\x20to=','error_code','heartbeatTimer','idle','get_all_status','task_id','toTimeString','resumeId','reply','emit','sdk','reconnectDelay','name','connected','completed','send','<unknown>','transport','url','body','heartbeatInterval','AbortError','content','message','SSE\x20reconnecting\x20in\x20','alias','30442920AsmCoO','application/json','sending','<pending>','851470dYXNFq','slice','sdk-','server','new_task','sseAbort','unknown\x20error','running','\x20from=','send_message','11bXZBjS','task','CommHub\x20response\x20omitted\x20task_id','normal','Bearer\x20','missing_task_id','task.send.start','\x20parent_task_id=','1455124AwkmyA','send_rejected','networkId','disconnected','Authorization','\x20transport=','2912pghnVo','sleep','664270TVAAWz','autoConnect','error_message','registered','task.send.failed','now','CommHub\x20rejected\x20task','status','\x20error=','not_tracked','tools/call','parent_task_id','startsWith','delivered','6776RelsAe','toAlias','duration_ms','read','\x20duration_ms=','cwd','min','\x20lifecycle=','disconnect','inbox\x20error:\x20','18YRCXLQ','getAllStatus','task.expired','application/json,\x20text/event-stream','connect','/mcp','error','text','628sCFUjC','task.started','SSE\x20failed:\x20','21759pofOfW','catch','to_alias','offline','task.replied','log','type','pop','s...','token','\x20task_id=','from_alias','parentTaskId','replace'];a0_0x47b1=function(){return _0x5b081c;};return a0_0x47b1();}import{EventEmitter as a0_0x181164}from'events';import{hostname as a0_0x2f50b2}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x57501c,_0xe54201)=>(_0x57501c??_0xe54201)[a0_0x2b779f(0x20c)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x490806){const _0xbf88f6=a0_0x2b779f;return(_0x490806 instanceof Error?_0x490806['message']:String(_0x490806??_0xbf88f6(0x248)))['replace'](K,'[REDACTED]')[_0xbf88f6(0x20c)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x2d2397,_0x3a60f7=process.env.ANET_TASK_TRACE_FORMAT===a0_0x2b779f(0x211)){const _0x49bb4a=a0_0x2b779f;if(_0x3a60f7)return JSON[_0x49bb4a(0x21c)](_0x2d2397);let _0x4d0ec9=L(_0x2d2397[_0x49bb4a(0x1e7)],_0x49bb4a(0x212)),_0x241605=L(_0x2d2397[_0x49bb4a(0x229)],_0x49bb4a(0x241)),_0x3d170e=_0x2d2397['error_code']?_0x49bb4a(0x1e4)+_0x2d2397[_0x49bb4a(0x225)]+':'+(_0x2d2397[_0x49bb4a(0x25e)]??''):'';return'[commhub:task]\x20'+_0x2d2397[_0x49bb4a(0x1e3)]+_0x49bb4a(0x24a)+L(_0x2d2397[_0x49bb4a(0x20a)],'<unknown>')+_0x49bb4a(0x224)+L(_0x2d2397[_0x49bb4a(0x201)],_0x49bb4a(0x234))+_0x49bb4a(0x209)+_0x241605+_0x49bb4a(0x253)+_0x4d0ec9+'\x20network_id='+L(_0x2d2397['network_id'],_0x49bb4a(0x234))+_0x49bb4a(0x259)+_0x2d2397['transport']+_0x49bb4a(0x1ee)+_0x2d2397[_0x49bb4a(0x1ec)]+_0x49bb4a(0x1f1)+_0x2d2397['lifecycle_tracking']+_0x3d170e;}function U(_0x3d3213){const _0x14a1d2=a0_0x2b779f;return{'event':{'sending':_0x14a1d2(0x252),'delivered':'task.send.delivered','failed':_0x14a1d2(0x260),'acked':'task.ack','started':_0x14a1d2(0x1fd),'replied':_0x14a1d2(0x203),'expired':_0x14a1d2(0x1f6)}[_0x3d3213['status']],..._0x3d3213};}function j(_0x18fe2c){const _0x1c050d=a0_0x2b779f;let _0xa7f551=_0x18fe2c?.[_0x1c050d(0x229)]||_0x18fe2c?.[_0x1c050d(0x214)]||_0x18fe2c?.['id'];if(_0xa7f551)return String(_0xa7f551);let _0x246e0a=_0x18fe2c?.[_0x1c050d(0x23a)]?.[0x0]?.['text'];if(typeof _0x246e0a!==_0x1c050d(0x213))return null;try{let _0x477b19=JSON['parse'](_0x246e0a);return _0x477b19?.[_0x1c050d(0x229)]||_0x477b19?.[_0x1c050d(0x214)]||_0x477b19?.['id']||null;}catch{return null;}}async function X(_0x4964e9,_0x4c9477){const _0x5e5941=a0_0x2b779f;let _0x484139=_0x4c9477[_0x5e5941(0x261)]??Date[_0x5e5941(0x261)],_0x3a1d92=_0x484139(),_0x1d7be1=(_0x1fc045,_0x533a3c,_0x5d57d4,_0x4eb632)=>{const _0x21a1b0=_0x5e5941;_0x4c9477[_0x21a1b0(0x204)](O(U({'from_alias':_0x4964e9['fromAlias'],'to_alias':_0x4964e9[_0x21a1b0(0x1eb)],'task_id':_0x533a3c,'parent_task_id':_0x4964e9[_0x21a1b0(0x20b)],'network_id':_0x4964e9[_0x21a1b0(0x256)],'transport':_0x4964e9[_0x21a1b0(0x235)],'status':_0x1fc045,'duration_ms':_0x484139()-_0x3a1d92,'lifecycle_tracking':_0x4964e9['lifecycleTracking'],..._0x5d57d4!==void 0x0?{'error_code':_0x4eb632||_0x21a1b0(0x221),'error_message':N(_0x5d57d4)}:{}})));};_0x1d7be1(_0x5e5941(0x240),null);try{let _0x3b332a=await _0x4c9477[_0x5e5941(0x233)](),_0x4241c5=j(_0x3b332a);if(_0x4241c5)_0x1d7be1(_0x5e5941(0x1e9),_0x4241c5);else{if(_0x3b332a?.['ok']===!0x1||_0x3b332a?.[_0x5e5941(0x1fa)])_0x1d7be1('failed',_0x4241c5,_0x3b332a?.[_0x5e5941(0x1fa)]||_0x5e5941(0x1e2),_0x5e5941(0x255));else _0x1d7be1(_0x5e5941(0x216),null,_0x5e5941(0x24e),_0x5e5941(0x251));}return _0x3b332a;}catch(_0x37fafe){throw _0x1d7be1(_0x5e5941(0x216),null,_0x37fafe,_0x5e5941(0x221)),_0x37fafe;}}async function Y(_0x402726,_0x5f418d){const _0x4e70a0=a0_0x2b779f;return X({'fromAlias':_0x402726[_0x4e70a0(0x215)],'toAlias':_0x402726['alias'],'parentTaskId':_0x402726['parentTaskId']||null,'networkId':_0x402726['networkId']||null,'transport':'mcp_http','lifecycleTracking':_0x4e70a0(0x1e5)},_0x5f418d);}class $ extends a0_0x181164{[a0_0x2b779f(0x236)];[a0_0x2b779f(0x23d)];[a0_0x2b779f(0x208)];[a0_0x2b779f(0x218)];[a0_0x2b779f(0x22b)];[a0_0x2b779f(0x238)];[a0_0x2b779f(0x22f)];[a0_0x2b779f(0x226)];['sseAbort'];[a0_0x2b779f(0x249)]=!0x1;constructor(_0x1c10e4){const _0x3c3c18=a0_0x2b779f;super();if(this['url']=_0x1c10e4[_0x3c3c18(0x236)]['replace'](/\/$/,''),this['alias']=_0x1c10e4[_0x3c3c18(0x23d)],this[_0x3c3c18(0x208)]=_0x1c10e4[_0x3c3c18(0x208)],this[_0x3c3c18(0x218)]=_0x1c10e4[_0x3c3c18(0x218)]||_0x3c3c18(0x22e),this[_0x3c3c18(0x22b)]=_0x3c3c18(0x244)+_0x1c10e4[_0x3c3c18(0x23d)]+'-'+Date[_0x3c3c18(0x261)]()['toString'](0x24),this[_0x3c3c18(0x238)]=_0x1c10e4[_0x3c3c18(0x238)]??0x2bf20,this[_0x3c3c18(0x22f)]=_0x1c10e4[_0x3c3c18(0x22f)]??0xbb8,_0x1c10e4[_0x3c3c18(0x25d)]!==!0x1)this[_0x3c3c18(0x1f8)]();}[a0_0x2b779f(0x204)](_0x26eeaa){const _0x416f61=a0_0x2b779f;console[_0x416f61(0x204)]('['+new Date()[_0x416f61(0x22a)]()[_0x416f61(0x243)](0x0,0x8)+_0x416f61(0x20d)+this['alias']+']\x20'+_0x26eeaa);}async[a0_0x2b779f(0x219)](_0x20c518,_0x55a6ea){const _0x23b090=a0_0x2b779f;let _0x103ab8={'Content-Type':_0x23b090(0x23f),'Accept':_0x23b090(0x1f7)};if(this[_0x23b090(0x208)])_0x103ab8[_0x23b090(0x258)]=_0x23b090(0x250)+this[_0x23b090(0x208)];let _0x301545=await(await fetch(this[_0x23b090(0x236)]+_0x23b090(0x1f9),{'method':'POST','headers':_0x103ab8,'body':JSON['stringify']({'jsonrpc':_0x23b090(0x21d),'id':Date[_0x23b090(0x261)](),'method':_0x23b090(0x1e6),'params':{'name':_0x20c518,'arguments':_0x55a6ea}})}))[_0x23b090(0x1fb)](),_0x544d3a=_0x301545['match'](/data: (.+)/),_0x3dd80f=_0x544d3a?JSON[_0x23b090(0x217)](_0x544d3a[0x1]):JSON[_0x23b090(0x217)](_0x301545),_0x59ea66=_0x3dd80f?.[_0x23b090(0x210)]?.[_0x23b090(0x23a)]?.[0x0]?.[_0x23b090(0x1fb)];return _0x59ea66?JSON[_0x23b090(0x217)](_0x59ea66):_0x3dd80f;}async['connect'](){const _0x5dd280=a0_0x2b779f;if(this[_0x5dd280(0x249)])return;this[_0x5dd280(0x249)]=!0x0,await this[_0x5dd280(0x1e3)]('idle'),this[_0x5dd280(0x204)](_0x5dd280(0x25f)),this[_0x5dd280(0x226)]=setInterval(()=>{const _0x3ec35a=_0x5dd280;this[_0x3ec35a(0x1e3)](_0x3ec35a(0x227))[_0x3ec35a(0x200)](_0x5d63f5=>this['log']('heartbeat\x20failed:\x20'+_0x5d63f5[_0x3ec35a(0x23b)]));},this[_0x5dd280(0x238)]),this[_0x5dd280(0x21f)]();}async[a0_0x2b779f(0x1f2)](){const _0x393368=a0_0x2b779f;if(this['running']=!0x1,this[_0x393368(0x247)]?.['abort'](),this[_0x393368(0x226)])clearInterval(this['heartbeatTimer']);await this[_0x393368(0x1e3)](_0x393368(0x202))[_0x393368(0x200)](()=>{}),this[_0x393368(0x204)]('disconnected');}async[a0_0x2b779f(0x233)](_0x3efe6d,_0x36f785,_0xa97aa8=a0_0x2b779f(0x24f)){const _0x372f1d=a0_0x2b779f;return Y({'alias':_0x3efe6d,'fromAlias':this[_0x372f1d(0x23d)]},{'log':_0x447162=>console[_0x372f1d(0x204)](_0x447162),'send':()=>this[_0x372f1d(0x219)]('send_task',{'alias':_0x3efe6d,'task':_0x36f785,'priority':_0xa97aa8,'from_session':this['alias']})});}async['message'](_0x4ccd32,_0x4aec71){const _0x4de587=a0_0x2b779f;return this['call'](_0x4de587(0x24b),{'alias':_0x4ccd32,'message':_0x4aec71,'from_session':this['alias']});}async[a0_0x2b779f(0x22c)](_0x21845b,_0xcfac8a,_0xdf6037=a0_0x2b779f(0x232)){return this['call']('send_reply',{'in_reply_to':_0x21845b,'text':_0xcfac8a,'status':_0xdf6037});}async[a0_0x2b779f(0x1e3)](_0x28c5b4,_0x23eb94){const _0x137cc0=a0_0x2b779f;return this['call']('report_status',{'resume_id':this[_0x137cc0(0x22b)],'alias':this['alias'],'status':_0x28c5b4,'server':a0_0x2f50b2(),'hostname':a0_0x2f50b2(),'agent':this[_0x137cc0(0x218)],'project_dir':process[_0x137cc0(0x1ef)](),..._0x23eb94});}async[a0_0x2b779f(0x1f5)](){const _0x329956=a0_0x2b779f;return this[_0x329956(0x219)](_0x329956(0x228),{});}async[a0_0x2b779f(0x222)](_0x5ac6f6,_0x45bb3b){const _0x1866a9=a0_0x2b779f;return this[_0x1866a9(0x219)](_0x1866a9(0x222),{'message':_0x5ac6f6,'filter_server':_0x45bb3b?.[_0x1866a9(0x245)],'filter_status':_0x45bb3b?.[_0x1866a9(0x1e3)]});}async['connectSSE'](){const _0x335cc6=a0_0x2b779f;let _0x5650bc=encodeURIComponent(this[_0x335cc6(0x23d)]),_0x5d7ea9=this[_0x335cc6(0x236)]+'/events/'+_0x5650bc,_0x487e7f=this[_0x335cc6(0x22f)];while(this[_0x335cc6(0x249)]){try{this[_0x335cc6(0x247)]=new AbortController();let _0x2dd40c={'Accept':'text/event-stream'};if(this[_0x335cc6(0x208)])_0x2dd40c[_0x335cc6(0x258)]=_0x335cc6(0x250)+this[_0x335cc6(0x208)];let _0x1734bb=await fetch(_0x5d7ea9,{'headers':_0x2dd40c,'signal':this[_0x335cc6(0x247)][_0x335cc6(0x20e)]});if(!_0x1734bb['ok']||!_0x1734bb[_0x335cc6(0x237)]){this[_0x335cc6(0x204)](_0x335cc6(0x1fe)+_0x1734bb[_0x335cc6(0x1e3)]),await this[_0x335cc6(0x25b)](_0x487e7f),_0x487e7f=Math[_0x335cc6(0x1f0)](_0x487e7f*1.5,0xea60);continue;}_0x487e7f=this[_0x335cc6(0x22f)];let _0x2e4811=_0x1734bb['body']['getReader'](),_0x21fbc2=new TextDecoder(),_0x5d3af1='';while(this[_0x335cc6(0x249)]){let {done:_0x57543c,value:_0x3d9a04}=await _0x2e4811[_0x335cc6(0x1ed)]();if(_0x57543c)break;_0x5d3af1+=_0x21fbc2['decode'](_0x3d9a04,{'stream':!0x0});let _0x3b2a13=_0x5d3af1[_0x335cc6(0x21e)]('\x0a');_0x5d3af1=_0x3b2a13[_0x335cc6(0x206)]()||'';for(let _0xcaf418 of _0x3b2a13){if(!_0xcaf418[_0x335cc6(0x1e8)](_0x335cc6(0x21a)))continue;try{let _0x2f6d13=JSON[_0x335cc6(0x217)](_0xcaf418[_0x335cc6(0x243)](0x6));if(_0x2f6d13[_0x335cc6(0x205)]===_0x335cc6(0x231)){this['log']('SSE\x20connected'),this[_0x335cc6(0x22d)](_0x335cc6(0x231));continue;}if(_0x2f6d13[_0x335cc6(0x205)]===_0x335cc6(0x246)||_0x2f6d13['type']==='new_message'||_0x2f6d13[_0x335cc6(0x205)]===_0x335cc6(0x222))await this['processInbox']();}catch{}}}}catch(_0x1472db){if(_0x1472db[_0x335cc6(0x230)]===_0x335cc6(0x239))break;this[_0x335cc6(0x22d)](_0x335cc6(0x1fa),_0x1472db),this[_0x335cc6(0x204)]('SSE\x20error:\x20'+_0x1472db['message']);}if(this[_0x335cc6(0x249)])this[_0x335cc6(0x22d)](_0x335cc6(0x257)),this[_0x335cc6(0x204)](_0x335cc6(0x23c)+_0x487e7f/0x3e8+_0x335cc6(0x207)),await this[_0x335cc6(0x25b)](_0x487e7f),_0x487e7f=Math[_0x335cc6(0x1f0)](_0x487e7f*1.5,0xea60);}}async[a0_0x2b779f(0x223)](){const _0x2fe3af=a0_0x2b779f;try{let _0x2c7599=(await this[_0x2fe3af(0x219)]('get_inbox',{'alias':this[_0x2fe3af(0x23d)],'limit':0xa}))?.['messages']||[];for(let _0xf5885c of _0x2c7599)await this[_0x2fe3af(0x219)]('ack_inbox',{'alias':this[_0x2fe3af(0x23d)],'message_id':_0xf5885c['id']}),this['log']('←\x20'+_0xf5885c[_0x2fe3af(0x220)]+':\x20'+_0xf5885c[_0x2fe3af(0x23a)]['slice'](0x0,0x3c)),this[_0x2fe3af(0x22d)](_0x2fe3af(0x24d),_0xf5885c),this['emit'](_0x2fe3af(0x23b),_0xf5885c);}catch(_0x4a0df7){this[_0x2fe3af(0x204)](_0x2fe3af(0x1f3)+_0x4a0df7['message']);}}[a0_0x2b779f(0x25b)](_0x1f7c9a){return new Promise(_0x1f3dff=>setTimeout(_0x1f3dff,_0x1f7c9a));}}function a0_0x4ece(_0x3c6a4a,_0x43f008){_0x3c6a4a=_0x3c6a4a-0x1e2;const _0x47b182=a0_0x47b1();let _0x4ece34=_0x47b182[_0x3c6a4a];return _0x4ece34;}var F=$;export{F as default,$ as CommHub};
1
+ function a0_0x372f(_0x11f988,_0x2bdd94){_0x11f988=_0x11f988-0x11e;const _0x13cb4a=a0_0x13cb();let _0x372fb7=_0x13cb4a[_0x11f988];return _0x372fb7;}const a0_0x252a16=a0_0x372f;(function(_0x581b96,_0x2e12b9){const _0x5e9784=a0_0x372f,_0x6a41a2=_0x581b96();while(!![]){try{const _0x37f858=parseInt(_0x5e9784(0x158))/0x1+-parseInt(_0x5e9784(0x19e))/0x2*(-parseInt(_0x5e9784(0x193))/0x3)+parseInt(_0x5e9784(0x14a))/0x4+parseInt(_0x5e9784(0x191))/0x5*(parseInt(_0x5e9784(0x180))/0x6)+-parseInt(_0x5e9784(0x186))/0x7+parseInt(_0x5e9784(0x152))/0x8*(parseInt(_0x5e9784(0x168))/0x9)+-parseInt(_0x5e9784(0x190))/0xa*(parseInt(_0x5e9784(0x13b))/0xb);if(_0x37f858===_0x2e12b9)break;else _0x6a41a2['push'](_0x6a41a2['shift']());}catch(_0x1cbea0){_0x6a41a2['push'](_0x6a41a2['shift']());}}}(a0_0x13cb,0xc69e3));import{EventEmitter as a0_0x45e0d2}from'events';import{hostname as a0_0xbee4e0}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0xdb9f1e,_0x284509)=>(_0xdb9f1e??_0x284509)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x252a16(0x148)](0x0,0xf0);function N(_0x4d3bba){const _0x996ee1=a0_0x252a16;return(_0x4d3bba instanceof Error?_0x4d3bba[_0x996ee1(0x155)]:String(_0x4d3bba??'unknown\x20error'))[_0x996ee1(0x154)](K,_0x996ee1(0x160))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x996ee1(0x148)](0x0,0xf0);}function O(_0xcda38b,_0x301420=process.env.ANET_TASK_TRACE_FORMAT===a0_0x252a16(0x147)){const _0x541087=a0_0x252a16;if(_0x301420)return JSON['stringify'](_0xcda38b);let _0x1a1ebc=L(_0xcda38b[_0x541087(0x16c)],_0x541087(0x17d)),_0x4f728b=L(_0xcda38b[_0x541087(0x139)],_0x541087(0x167)),_0x22e717=_0xcda38b[_0x541087(0x170)]?'\x20error='+_0xcda38b[_0x541087(0x170)]+':'+(_0xcda38b[_0x541087(0x12a)]??''):'';return'[commhub:task]\x20'+_0xcda38b[_0x541087(0x11f)]+_0x541087(0x16a)+L(_0xcda38b[_0x541087(0x175)],'<unknown>')+_0x541087(0x162)+L(_0xcda38b[_0x541087(0x12c)],_0x541087(0x181))+_0x541087(0x135)+_0x4f728b+_0x541087(0x149)+_0x1a1ebc+_0x541087(0x14c)+L(_0xcda38b[_0x541087(0x12f)],_0x541087(0x181))+'\x20transport='+_0xcda38b[_0x541087(0x163)]+_0x541087(0x174)+_0xcda38b[_0x541087(0x142)]+_0x541087(0x187)+_0xcda38b[_0x541087(0x196)]+_0x22e717;}function a0_0x13cb(){const _0x475210=['task.ack','lifecycle_tracking','from_session','inbox\x20error:\x20','fromAlias','POST','CommHub\x20response\x20omitted\x20task_id','completed','parse','1185214xrqEmo','CommHub\x20rejected\x20task','getAllStatus','status','resumeId','error','mcp_http','toString','sleep','normal','disconnected','running','url','missing_task_id','error_message','lifecycleTracking','to_alias','match','connect','network_id','SSE\x20failed:\x20','task.send.failed','application/json','not_tracked','networkId','\x20task_id=','text/event-stream','SSE\x20error:\x20','report_status','task_id','send','11KHflxA','messages','toAlias','application/json,\x20text/event-stream','SSE\x20reconnecting\x20in\x20','task.expired','task','duration_ms','sending','delivered','token','emit','json','slice','\x20parent_task_id=','1109632zBPHGz','reply','\x20network_id=','send_rejected','content','processInbox','/mcp','body','80720leneBb','reconnectDelay','replace','message','Authorization','min','706602FNavrL','pop','message_id','failed','send_message','signal','broadcast','text','[REDACTED]','heartbeatInterval','\x20to=','transport','type','stringify','connectSSE','<pending>','1170hyNiYs','server','\x20from=','now','parent_task_id','AbortError','heartbeatTimer','new_message','error_code','string','agent','toTimeString','\x20duration_ms=','from_alias','get_inbox','cwd','new_task','get_all_status','getReader','s...','sseAbort','<missing>','registered','parentTaskId','12vQbJWK','<unknown>','autoConnect','task.replied','ack_inbox','alias','7592305YHAxdl','\x20lifecycle=','log','data:\x20','connected','task.send.start','sdk','offline','call','decode','17148670ZsOhEf','1811760ffhZgO','Bearer\x20','3PQIlFn','idle'];a0_0x13cb=function(){return _0x475210;};return a0_0x13cb();}function U(_0x4de6e8){const _0x469adf=a0_0x252a16;return{'event':{'sending':_0x469adf(0x18b),'delivered':'task.send.delivered','failed':_0x469adf(0x131),'acked':_0x469adf(0x195),'started':'task.started','replied':_0x469adf(0x183),'expired':_0x469adf(0x140)}[_0x4de6e8[_0x469adf(0x11f)]],..._0x4de6e8};}function j(_0x920b40){const _0x3877a5=a0_0x252a16;let _0x51c9cf=_0x920b40?.[_0x3877a5(0x139)]||_0x920b40?.['message_id']||_0x920b40?.['id'];if(_0x51c9cf)return String(_0x51c9cf);let _0x1020be=_0x920b40?.[_0x3877a5(0x14e)]?.[0x0]?.[_0x3877a5(0x15f)];if(typeof _0x1020be!==_0x3877a5(0x171))return null;try{let _0x87eb6c=JSON['parse'](_0x1020be);return _0x87eb6c?.[_0x3877a5(0x139)]||_0x87eb6c?.[_0x3877a5(0x15a)]||_0x87eb6c?.['id']||null;}catch{return null;}}async function X(_0x3b625a,_0x276011){const _0x2877d2=a0_0x252a16;let _0x5c9b6b=_0x276011[_0x2877d2(0x16b)]??Date[_0x2877d2(0x16b)],_0x96931b=_0x5c9b6b(),_0x250038=(_0x1a6cc8,_0x38b24d,_0x52af77,_0x508709)=>{const _0x33331e=_0x2877d2;_0x276011[_0x33331e(0x188)](O(U({'from_alias':_0x3b625a[_0x33331e(0x199)],'to_alias':_0x3b625a[_0x33331e(0x13d)],'task_id':_0x38b24d,'parent_task_id':_0x3b625a[_0x33331e(0x17f)],'network_id':_0x3b625a['networkId'],'transport':_0x3b625a[_0x33331e(0x163)],'status':_0x1a6cc8,'duration_ms':_0x5c9b6b()-_0x96931b,'lifecycle_tracking':_0x3b625a[_0x33331e(0x12b)],..._0x52af77!==void 0x0?{'error_code':_0x508709||'send_failed','error_message':N(_0x52af77)}:{}})));};_0x250038(_0x2877d2(0x143),null);try{let _0x5f2639=await _0x276011[_0x2877d2(0x13a)](),_0x593971=j(_0x5f2639);if(_0x593971)_0x250038(_0x2877d2(0x144),_0x593971);else{if(_0x5f2639?.['ok']===!0x1||_0x5f2639?.['error'])_0x250038(_0x2877d2(0x15b),_0x593971,_0x5f2639?.[_0x2877d2(0x121)]||_0x2877d2(0x19f),_0x2877d2(0x14d));else _0x250038(_0x2877d2(0x15b),null,_0x2877d2(0x19b),_0x2877d2(0x129));}return _0x5f2639;}catch(_0x4fefbe){throw _0x250038('failed',null,_0x4fefbe,'send_failed'),_0x4fefbe;}}async function Y(_0x3a3d6,_0x79b51a){const _0x4a7beb=a0_0x252a16;return X({'fromAlias':_0x3a3d6[_0x4a7beb(0x199)],'toAlias':_0x3a3d6[_0x4a7beb(0x185)],'parentTaskId':_0x3a3d6[_0x4a7beb(0x17f)]||null,'networkId':_0x3a3d6[_0x4a7beb(0x134)]||null,'transport':_0x4a7beb(0x122),'lifecycleTracking':_0x4a7beb(0x133)},_0x79b51a);}class $ extends a0_0x45e0d2{['url'];[a0_0x252a16(0x185)];[a0_0x252a16(0x145)];[a0_0x252a16(0x172)];[a0_0x252a16(0x120)];[a0_0x252a16(0x161)];['reconnectDelay'];[a0_0x252a16(0x16e)];[a0_0x252a16(0x17c)];[a0_0x252a16(0x127)]=!0x1;constructor(_0x3be9bd){const _0x3ed9e6=a0_0x252a16;super();if(this['url']=_0x3be9bd[_0x3ed9e6(0x128)][_0x3ed9e6(0x154)](/\/$/,''),this[_0x3ed9e6(0x185)]=_0x3be9bd[_0x3ed9e6(0x185)],this[_0x3ed9e6(0x145)]=_0x3be9bd[_0x3ed9e6(0x145)],this[_0x3ed9e6(0x172)]=_0x3be9bd[_0x3ed9e6(0x172)]||_0x3ed9e6(0x18c),this[_0x3ed9e6(0x120)]='sdk-'+_0x3be9bd[_0x3ed9e6(0x185)]+'-'+Date['now']()[_0x3ed9e6(0x123)](0x24),this['heartbeatInterval']=_0x3be9bd[_0x3ed9e6(0x161)]??0x2bf20,this[_0x3ed9e6(0x153)]=_0x3be9bd[_0x3ed9e6(0x153)]??0xbb8,_0x3be9bd[_0x3ed9e6(0x182)]!==!0x1)this[_0x3ed9e6(0x12e)]();}[a0_0x252a16(0x188)](_0x154496){const _0x20e5da=a0_0x252a16;console[_0x20e5da(0x188)]('['+new Date()[_0x20e5da(0x173)]()[_0x20e5da(0x148)](0x0,0x8)+']\x20[commhub:'+this[_0x20e5da(0x185)]+']\x20'+_0x154496);}async[a0_0x252a16(0x18e)](_0x17f7cc,_0x59b6cb){const _0x3dbe53=a0_0x252a16;let _0x200478={'Content-Type':_0x3dbe53(0x132),'Accept':_0x3dbe53(0x13e)};if(this[_0x3dbe53(0x145)])_0x200478[_0x3dbe53(0x156)]=_0x3dbe53(0x192)+this[_0x3dbe53(0x145)];let _0x5233a4=await(await fetch(this[_0x3dbe53(0x128)]+_0x3dbe53(0x150),{'method':_0x3dbe53(0x19a),'headers':_0x200478,'body':JSON[_0x3dbe53(0x165)]({'jsonrpc':'2.0','id':Date[_0x3dbe53(0x16b)](),'method':'tools/call','params':{'name':_0x17f7cc,'arguments':_0x59b6cb}})}))[_0x3dbe53(0x15f)](),_0x1f5d47=_0x5233a4[_0x3dbe53(0x12d)](/data: (.+)/),_0x29e3a0=_0x1f5d47?JSON[_0x3dbe53(0x19d)](_0x1f5d47[0x1]):JSON[_0x3dbe53(0x19d)](_0x5233a4),_0x2d05e4=_0x29e3a0?.['result']?.[_0x3dbe53(0x14e)]?.[0x0]?.[_0x3dbe53(0x15f)];return _0x2d05e4?JSON[_0x3dbe53(0x19d)](_0x2d05e4):_0x29e3a0;}async[a0_0x252a16(0x12e)](){const _0x4edfed=a0_0x252a16;if(this[_0x4edfed(0x127)])return;this['running']=!0x0,await this[_0x4edfed(0x11f)](_0x4edfed(0x194)),this['log'](_0x4edfed(0x17e)),this[_0x4edfed(0x16e)]=setInterval(()=>{const _0x45266f=_0x4edfed;this[_0x45266f(0x11f)](_0x45266f(0x194))['catch'](_0x3b0a39=>this['log']('heartbeat\x20failed:\x20'+_0x3b0a39[_0x45266f(0x155)]));},this[_0x4edfed(0x161)]),this[_0x4edfed(0x166)]();}async['disconnect'](){const _0x312c28=a0_0x252a16;if(this['running']=!0x1,this[_0x312c28(0x17c)]?.['abort'](),this['heartbeatTimer'])clearInterval(this[_0x312c28(0x16e)]);await this['status'](_0x312c28(0x18d))['catch'](()=>{}),this[_0x312c28(0x188)](_0x312c28(0x126));}async[a0_0x252a16(0x13a)](_0x33bc24,_0x318c03,_0x4c6f4b=a0_0x252a16(0x125)){const _0x2fc65b=a0_0x252a16;return Y({'alias':_0x33bc24,'fromAlias':this[_0x2fc65b(0x185)]},{'log':_0x620281=>console[_0x2fc65b(0x188)](_0x620281),'send':()=>this[_0x2fc65b(0x18e)]('send_task',{'alias':_0x33bc24,'task':_0x318c03,'priority':_0x4c6f4b,'from_session':this[_0x2fc65b(0x185)]})});}async['message'](_0x45faed,_0x1adc3e){const _0x24c58f=a0_0x252a16;return this[_0x24c58f(0x18e)](_0x24c58f(0x15c),{'alias':_0x45faed,'message':_0x1adc3e,'from_session':this[_0x24c58f(0x185)]});}async[a0_0x252a16(0x14b)](_0x4b01d9,_0x19548d,_0x57f698=a0_0x252a16(0x19c)){const _0x4daeb1=a0_0x252a16;return this[_0x4daeb1(0x18e)]('send_reply',{'in_reply_to':_0x4b01d9,'text':_0x19548d,'status':_0x57f698});}async[a0_0x252a16(0x11f)](_0x432f2c,_0x5c9253){const _0x2d7e40=a0_0x252a16;return this['call'](_0x2d7e40(0x138),{'resume_id':this[_0x2d7e40(0x120)],'alias':this[_0x2d7e40(0x185)],'status':_0x432f2c,'server':a0_0xbee4e0(),'hostname':a0_0xbee4e0(),'agent':this[_0x2d7e40(0x172)],'project_dir':process[_0x2d7e40(0x177)](),..._0x5c9253});}async[a0_0x252a16(0x11e)](){const _0xf1714c=a0_0x252a16;return this[_0xf1714c(0x18e)](_0xf1714c(0x179),{});}async['broadcast'](_0x43fe53,_0x5aec82){const _0x3a1607=a0_0x252a16;return this[_0x3a1607(0x18e)](_0x3a1607(0x15e),{'message':_0x43fe53,'filter_server':_0x5aec82?.[_0x3a1607(0x169)],'filter_status':_0x5aec82?.['status']});}async[a0_0x252a16(0x166)](){const _0x5aedb1=a0_0x252a16;let _0x1a66eb=encodeURIComponent(this[_0x5aedb1(0x185)]),_0x3ea6eb=this[_0x5aedb1(0x128)]+'/events/'+_0x1a66eb,_0x312aa8=this[_0x5aedb1(0x153)];while(this[_0x5aedb1(0x127)]){try{this[_0x5aedb1(0x17c)]=new AbortController();let _0x346375={'Accept':_0x5aedb1(0x136)};if(this[_0x5aedb1(0x145)])_0x346375[_0x5aedb1(0x156)]=_0x5aedb1(0x192)+this['token'];let _0x447c6e=await fetch(_0x3ea6eb,{'headers':_0x346375,'signal':this[_0x5aedb1(0x17c)][_0x5aedb1(0x15d)]});if(!_0x447c6e['ok']||!_0x447c6e[_0x5aedb1(0x151)]){this['log'](_0x5aedb1(0x130)+_0x447c6e[_0x5aedb1(0x11f)]),await this[_0x5aedb1(0x124)](_0x312aa8),_0x312aa8=Math[_0x5aedb1(0x157)](_0x312aa8*1.5,0xea60);continue;}_0x312aa8=this[_0x5aedb1(0x153)];let _0x2dbeae=_0x447c6e[_0x5aedb1(0x151)][_0x5aedb1(0x17a)](),_0x1d93c5=new TextDecoder(),_0x5f331b='';while(this['running']){let {done:_0x4ea1e9,value:_0x53648e}=await _0x2dbeae['read']();if(_0x4ea1e9)break;_0x5f331b+=_0x1d93c5[_0x5aedb1(0x18f)](_0x53648e,{'stream':!0x0});let _0x5a31c1=_0x5f331b['split']('\x0a');_0x5f331b=_0x5a31c1[_0x5aedb1(0x159)]()||'';for(let _0x594085 of _0x5a31c1){if(!_0x594085['startsWith'](_0x5aedb1(0x189)))continue;try{let _0x1154a7=JSON[_0x5aedb1(0x19d)](_0x594085['slice'](0x6));if(_0x1154a7[_0x5aedb1(0x164)]===_0x5aedb1(0x18a)){this['log']('SSE\x20connected'),this[_0x5aedb1(0x146)](_0x5aedb1(0x18a));continue;}if(_0x1154a7[_0x5aedb1(0x164)]===_0x5aedb1(0x178)||_0x1154a7[_0x5aedb1(0x164)]===_0x5aedb1(0x16f)||_0x1154a7[_0x5aedb1(0x164)]===_0x5aedb1(0x15e))await this[_0x5aedb1(0x14f)]();}catch{}}}}catch(_0x148559){if(_0x148559['name']===_0x5aedb1(0x16d))break;this['emit'](_0x5aedb1(0x121),_0x148559),this[_0x5aedb1(0x188)](_0x5aedb1(0x137)+_0x148559[_0x5aedb1(0x155)]);}if(this[_0x5aedb1(0x127)])this['emit'](_0x5aedb1(0x126)),this[_0x5aedb1(0x188)](_0x5aedb1(0x13f)+_0x312aa8/0x3e8+_0x5aedb1(0x17b)),await this[_0x5aedb1(0x124)](_0x312aa8),_0x312aa8=Math['min'](_0x312aa8*1.5,0xea60);}}async['processInbox'](){const _0x52be44=a0_0x252a16;try{let _0x5970cf=(await this['call'](_0x52be44(0x176),{'alias':this[_0x52be44(0x185)],'limit':0xa}))?.[_0x52be44(0x13c)]||[];for(let _0xfd98f2 of _0x5970cf)await this[_0x52be44(0x18e)](_0x52be44(0x184),{'alias':this['alias'],'message_id':_0xfd98f2['id']}),this['log']('←\x20'+_0xfd98f2[_0x52be44(0x197)]+':\x20'+_0xfd98f2[_0x52be44(0x14e)][_0x52be44(0x148)](0x0,0x3c)),this[_0x52be44(0x146)](_0x52be44(0x141),_0xfd98f2),this[_0x52be44(0x146)](_0x52be44(0x155),_0xfd98f2);}catch(_0xe4676e){this[_0x52be44(0x188)](_0x52be44(0x198)+_0xe4676e['message']);}}[a0_0x252a16(0x124)](_0xef1a16){return new Promise(_0x32f332=>setTimeout(_0x32f332,_0xef1a16));}}var F=$;export{F as default,$ as CommHub};