@sleep2agi/agent-network 2.3.0-preview.244 → 2.3.0-preview.246

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_0x3202f1=a0_0x1ba1;(function(_0xae77d3,_0x41acd6){const _0x49d876=a0_0x1ba1,_0x747006=_0xae77d3();while(!![]){try{const _0x25261b=-parseInt(_0x49d876(0x108))/0x1+parseInt(_0x49d876(0xf1))/0x2+parseInt(_0x49d876(0x149))/0x3*(-parseInt(_0x49d876(0xd7))/0x4)+-parseInt(_0x49d876(0x10d))/0x5*(parseInt(_0x49d876(0x114))/0x6)+parseInt(_0x49d876(0x122))/0x7+parseInt(_0x49d876(0x11f))/0x8+-parseInt(_0x49d876(0x121))/0x9*(-parseInt(_0x49d876(0x101))/0xa);if(_0x25261b===_0x41acd6)break;else _0x747006['push'](_0x747006['shift']());}catch(_0x47c0fd){_0x747006['push'](_0x747006['shift']());}}}(a0_0x188e,0xa58d7));import{EventEmitter as a0_0x1408d2}from'events';import{hostname as a0_0x5e1407}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x2b6b91,_0x52bd46)=>(_0x2b6b91??_0x52bd46)[a0_0x3202f1(0x11a)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x3202f1(0xd2)](0x0,0xf0);function N(_0x20bb47){const _0x4d08ee=a0_0x3202f1;return(_0x20bb47 instanceof Error?_0x20bb47[_0x4d08ee(0x13e)]:String(_0x20bb47??_0x4d08ee(0xe9)))[_0x4d08ee(0x11a)](K,_0x4d08ee(0x13a))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x4d08ee(0xd2)](0x0,0xf0);}function O(_0x31bc23,_0x1da239=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x1f11cb=a0_0x3202f1;if(_0x1da239)return JSON[_0x1f11cb(0x137)](_0x31bc23);let _0x8a08cc=L(_0x31bc23[_0x1f11cb(0xfb)],_0x1f11cb(0xdf)),_0x58446d=L(_0x31bc23[_0x1f11cb(0xf3)],_0x1f11cb(0x119)),_0xc0d95c=_0x31bc23[_0x1f11cb(0x12d)]?'\x20error='+_0x31bc23[_0x1f11cb(0x12d)]+':'+(_0x31bc23['error_message']??''):'';return'[commhub:task]\x20'+_0x31bc23[_0x1f11cb(0x105)]+_0x1f11cb(0xdc)+L(_0x31bc23['from_alias'],_0x1f11cb(0x11c))+_0x1f11cb(0xe3)+L(_0x31bc23[_0x1f11cb(0x12f)],_0x1f11cb(0x11c))+'\x20task_id='+_0x58446d+_0x1f11cb(0xfe)+_0x8a08cc+_0x1f11cb(0xd8)+L(_0x31bc23['network_id'],_0x1f11cb(0x11c))+_0x1f11cb(0x131)+_0x31bc23[_0x1f11cb(0x100)]+_0x1f11cb(0xfa)+_0x31bc23[_0x1f11cb(0xe5)]+_0x1f11cb(0x117)+_0x31bc23['lifecycle_tracking']+_0xc0d95c;}function U(_0x2da560){const _0x54a55b=a0_0x3202f1;return{'event':{'sending':_0x54a55b(0x10e),'delivered':'task.send.delivered','failed':_0x54a55b(0xee),'acked':_0x54a55b(0xe4),'started':_0x54a55b(0xf6),'replied':_0x54a55b(0xd6),'expired':_0x54a55b(0x148)}[_0x2da560[_0x54a55b(0x105)]],..._0x2da560};}function j(_0x8ae5ac){const _0x548fbe=a0_0x3202f1;let _0x17e93b=_0x8ae5ac?.[_0x548fbe(0xf3)]||_0x8ae5ac?.[_0x548fbe(0x125)]||_0x8ae5ac?.['id'];if(_0x17e93b)return String(_0x17e93b);let _0x5e9e9b=_0x8ae5ac?.['content']?.[0x0]?.[_0x548fbe(0xfc)];if(typeof _0x5e9e9b!==_0x548fbe(0x110))return null;try{let _0x2d56a1=JSON[_0x548fbe(0xf0)](_0x5e9e9b);return _0x2d56a1?.[_0x548fbe(0xf3)]||_0x2d56a1?.[_0x548fbe(0x125)]||_0x2d56a1?.['id']||null;}catch{return null;}}function a0_0x1ba1(_0x801137,_0x7187fd){_0x801137=_0x801137-0xd2;const _0x188ef6=a0_0x188e();let _0x1ba167=_0x188ef6[_0x801137];return _0x1ba167;}function a0_0x188e(){const _0x843026=['\x20to=','task.ack','duration_ms','pop','heartbeatTimer','failed','unknown\x20error','toAlias','completed','reconnectDelay','delivered','task.send.failed','body','parse','1144224cqQBtk',']\x20[commhub:','task_id','new_task','mcp_http','task.started','disconnect','send_message','get_all_status','\x20duration_ms=','parent_task_id','text','broadcast','\x20parent_task_id=','networkId','transport','10AkZdfY','tools/call','error','server','status','result','reply','1255308mfxUzd','data:\x20','SSE\x20reconnecting\x20in\x20','inbox\x20error:\x20','new_message','127440DtaMdE','task.send.start','text/event-stream','string','min','connectSSE','emit','234uOgFUw','registered','agent','\x20lifecycle=','/events/','<pending>','replace','token','<unknown>','abort','application/json','8948872vKfZRz','report_status','9728973CNmBmM','4183291MytEUA','split','url','message_id','application/json,\x20text/event-stream','send_rejected','send_failed','parentTaskId','running','CommHub\x20rejected\x20task','connect','error_code','processInbox','to_alias','autoConnect','\x20transport=','ack_inbox','Bearer\x20','lifecycleTracking','toString','call','stringify','sending','send_task','[REDACTED]','messages','connected','type','message','send_reply','alias','cwd','signal','SSE\x20failed:\x20','disconnected','startsWith','fromAlias','sseAbort','task.expired','3PHteDx','decode','not_tracked','now','SSE\x20error:\x20','toTimeString','missing_task_id','name','CommHub\x20response\x20omitted\x20task_id','slice','idle','offline','content','task.replied','1767552cyDndf','\x20network_id=','send','from_session','2.0','\x20from=','log','heartbeatInterval','<missing>','task','resumeId','catch'];a0_0x188e=function(){return _0x843026;};return a0_0x188e();}async function X(_0x5b0fec,_0x2bbbc5){const _0x457a8f=a0_0x3202f1;let _0x2a852a=_0x2bbbc5[_0x457a8f(0x14c)]??Date['now'],_0x3e4035=_0x2a852a(),_0x2fa989=(_0x233cc6,_0x1d0a3b,_0x3607d7,_0x295198)=>{const _0x3bada=_0x457a8f;_0x2bbbc5[_0x3bada(0xdd)](O(U({'from_alias':_0x5b0fec[_0x3bada(0x146)],'to_alias':_0x5b0fec[_0x3bada(0xea)],'task_id':_0x1d0a3b,'parent_task_id':_0x5b0fec[_0x3bada(0x129)],'network_id':_0x5b0fec[_0x3bada(0xff)],'transport':_0x5b0fec[_0x3bada(0x100)],'status':_0x233cc6,'duration_ms':_0x2a852a()-_0x3e4035,'lifecycle_tracking':_0x5b0fec[_0x3bada(0x134)],..._0x3607d7!==void 0x0?{'error_code':_0x295198||'send_failed','error_message':N(_0x3607d7)}:{}})));};_0x2fa989(_0x457a8f(0x138),null);try{let _0x31786f=await _0x2bbbc5[_0x457a8f(0xd9)](),_0x1f97de=j(_0x31786f);if(_0x1f97de)_0x2fa989(_0x457a8f(0xed),_0x1f97de);else{if(_0x31786f?.['ok']===!0x1||_0x31786f?.[_0x457a8f(0x103)])_0x2fa989(_0x457a8f(0xe8),_0x1f97de,_0x31786f?.[_0x457a8f(0x103)]||_0x457a8f(0x12b),_0x457a8f(0x127));else _0x2fa989(_0x457a8f(0xe8),null,_0x457a8f(0x151),_0x457a8f(0x14f));}return _0x31786f;}catch(_0x58d5eb){throw _0x2fa989(_0x457a8f(0xe8),null,_0x58d5eb,_0x457a8f(0x128)),_0x58d5eb;}}async function Y(_0x4084db,_0x51ce19){const _0x53b4e6=a0_0x3202f1;return X({'fromAlias':_0x4084db[_0x53b4e6(0x146)],'toAlias':_0x4084db[_0x53b4e6(0x140)],'parentTaskId':_0x4084db[_0x53b4e6(0x129)]||null,'networkId':_0x4084db[_0x53b4e6(0xff)]||null,'transport':_0x53b4e6(0xf5),'lifecycleTracking':_0x53b4e6(0x14b)},_0x51ce19);}class $ extends a0_0x1408d2{[a0_0x3202f1(0x124)];[a0_0x3202f1(0x140)];['token'];[a0_0x3202f1(0x116)];[a0_0x3202f1(0xe1)];['heartbeatInterval'];[a0_0x3202f1(0xec)];['heartbeatTimer'];['sseAbort'];[a0_0x3202f1(0x12a)]=!0x1;constructor(_0x370c0c){const _0x3491cd=a0_0x3202f1;super();if(this[_0x3491cd(0x124)]=_0x370c0c[_0x3491cd(0x124)][_0x3491cd(0x11a)](/\/$/,''),this[_0x3491cd(0x140)]=_0x370c0c['alias'],this[_0x3491cd(0x11b)]=_0x370c0c[_0x3491cd(0x11b)],this[_0x3491cd(0x116)]=_0x370c0c[_0x3491cd(0x116)]||'sdk',this[_0x3491cd(0xe1)]='sdk-'+_0x370c0c[_0x3491cd(0x140)]+'-'+Date['now']()[_0x3491cd(0x135)](0x24),this[_0x3491cd(0xde)]=_0x370c0c[_0x3491cd(0xde)]??0x2bf20,this[_0x3491cd(0xec)]=_0x370c0c['reconnectDelay']??0xbb8,_0x370c0c[_0x3491cd(0x130)]!==!0x1)this['connect']();}[a0_0x3202f1(0xdd)](_0x5905ae){const _0x5fe975=a0_0x3202f1;console['log']('['+new Date()[_0x5fe975(0x14e)]()[_0x5fe975(0xd2)](0x0,0x8)+_0x5fe975(0xf2)+this[_0x5fe975(0x140)]+']\x20'+_0x5905ae);}async['call'](_0x3dfa10,_0x3778d3){const _0x35ec58=a0_0x3202f1;let _0x855b97={'Content-Type':_0x35ec58(0x11e),'Accept':_0x35ec58(0x126)};if(this[_0x35ec58(0x11b)])_0x855b97['Authorization']=_0x35ec58(0x133)+this[_0x35ec58(0x11b)];let _0x1594da=await(await fetch(this['url']+'/mcp',{'method':'POST','headers':_0x855b97,'body':JSON[_0x35ec58(0x137)]({'jsonrpc':_0x35ec58(0xdb),'id':Date[_0x35ec58(0x14c)](),'method':_0x35ec58(0x102),'params':{'name':_0x3dfa10,'arguments':_0x3778d3}})}))['text'](),_0x56d749=_0x1594da['match'](/data: (.+)/),_0x36e6e5=_0x56d749?JSON['parse'](_0x56d749[0x1]):JSON[_0x35ec58(0xf0)](_0x1594da),_0xa6f538=_0x36e6e5?.[_0x35ec58(0x106)]?.[_0x35ec58(0xd5)]?.[0x0]?.[_0x35ec58(0xfc)];return _0xa6f538?JSON['parse'](_0xa6f538):_0x36e6e5;}async[a0_0x3202f1(0x12c)](){const _0x83430d=a0_0x3202f1;if(this[_0x83430d(0x12a)])return;this[_0x83430d(0x12a)]=!0x0,await this[_0x83430d(0x105)]('idle'),this[_0x83430d(0xdd)](_0x83430d(0x115)),this[_0x83430d(0xe7)]=setInterval(()=>{const _0x1c285f=_0x83430d;this[_0x1c285f(0x105)](_0x1c285f(0xd3))[_0x1c285f(0xe2)](_0x36f5b1=>this[_0x1c285f(0xdd)]('heartbeat\x20failed:\x20'+_0x36f5b1[_0x1c285f(0x13e)]));},this['heartbeatInterval']),this['connectSSE']();}async[a0_0x3202f1(0xf7)](){const _0x5fecbb=a0_0x3202f1;if(this[_0x5fecbb(0x12a)]=!0x1,this['sseAbort']?.[_0x5fecbb(0x11d)](),this['heartbeatTimer'])clearInterval(this['heartbeatTimer']);await this[_0x5fecbb(0x105)](_0x5fecbb(0xd4))['catch'](()=>{}),this[_0x5fecbb(0xdd)](_0x5fecbb(0x144));}async[a0_0x3202f1(0xd9)](_0x465c47,_0x34eb43,_0x11d26d='normal'){const _0xf029c0=a0_0x3202f1;return Y({'alias':_0x465c47,'fromAlias':this['alias']},{'log':_0x4bcaf6=>console['log'](_0x4bcaf6),'send':()=>this[_0xf029c0(0x136)](_0xf029c0(0x139),{'alias':_0x465c47,'task':_0x34eb43,'priority':_0x11d26d,'from_session':this['alias']})});}async['message'](_0xd45c25,_0x226bda){const _0x55973f=a0_0x3202f1;return this[_0x55973f(0x136)](_0x55973f(0xf8),{'alias':_0xd45c25,'message':_0x226bda,'from_session':this[_0x55973f(0x140)]});}async[a0_0x3202f1(0x107)](_0x18f9ad,_0x32460c,_0x1e256c=a0_0x3202f1(0xeb)){const _0x320570=a0_0x3202f1;return this['call'](_0x320570(0x13f),{'in_reply_to':_0x18f9ad,'text':_0x32460c,'status':_0x1e256c});}async[a0_0x3202f1(0x105)](_0x5eb4ff,_0x214cdd){const _0x13a588=a0_0x3202f1;return this[_0x13a588(0x136)](_0x13a588(0x120),{'resume_id':this[_0x13a588(0xe1)],'alias':this[_0x13a588(0x140)],'status':_0x5eb4ff,'server':a0_0x5e1407(),'hostname':a0_0x5e1407(),'agent':this['agent'],'project_dir':process[_0x13a588(0x141)](),..._0x214cdd});}async['getAllStatus'](){const _0x3a3b59=a0_0x3202f1;return this['call'](_0x3a3b59(0xf9),{});}async[a0_0x3202f1(0xfd)](_0x303db7,_0x3c151f){const _0x3ccc8d=a0_0x3202f1;return this[_0x3ccc8d(0x136)](_0x3ccc8d(0xfd),{'message':_0x303db7,'filter_server':_0x3c151f?.[_0x3ccc8d(0x104)],'filter_status':_0x3c151f?.[_0x3ccc8d(0x105)]});}async[a0_0x3202f1(0x112)](){const _0x4e2f29=a0_0x3202f1;let _0x421715=encodeURIComponent(this[_0x4e2f29(0x140)]),_0xe65260=this['url']+_0x4e2f29(0x118)+_0x421715,_0x5ec7ba=this[_0x4e2f29(0xec)];while(this['running']){try{this[_0x4e2f29(0x147)]=new AbortController();let _0x112588={'Accept':_0x4e2f29(0x10f)};if(this[_0x4e2f29(0x11b)])_0x112588['Authorization']='Bearer\x20'+this[_0x4e2f29(0x11b)];let _0x56de16=await fetch(_0xe65260,{'headers':_0x112588,'signal':this[_0x4e2f29(0x147)][_0x4e2f29(0x142)]});if(!_0x56de16['ok']||!_0x56de16['body']){this['log'](_0x4e2f29(0x143)+_0x56de16[_0x4e2f29(0x105)]),await this['sleep'](_0x5ec7ba),_0x5ec7ba=Math[_0x4e2f29(0x111)](_0x5ec7ba*1.5,0xea60);continue;}_0x5ec7ba=this[_0x4e2f29(0xec)];let _0x147311=_0x56de16[_0x4e2f29(0xef)]['getReader'](),_0x1073aa=new TextDecoder(),_0x5ca052='';while(this[_0x4e2f29(0x12a)]){let {done:_0x1079e4,value:_0x1474e9}=await _0x147311['read']();if(_0x1079e4)break;_0x5ca052+=_0x1073aa[_0x4e2f29(0x14a)](_0x1474e9,{'stream':!0x0});let _0x333886=_0x5ca052[_0x4e2f29(0x123)]('\x0a');_0x5ca052=_0x333886[_0x4e2f29(0xe6)]()||'';for(let _0x2eded1 of _0x333886){if(!_0x2eded1[_0x4e2f29(0x145)](_0x4e2f29(0x109)))continue;try{let _0x407b67=JSON[_0x4e2f29(0xf0)](_0x2eded1[_0x4e2f29(0xd2)](0x6));if(_0x407b67[_0x4e2f29(0x13d)]==='connected'){this['log']('SSE\x20connected'),this[_0x4e2f29(0x113)](_0x4e2f29(0x13c));continue;}if(_0x407b67[_0x4e2f29(0x13d)]===_0x4e2f29(0xf4)||_0x407b67[_0x4e2f29(0x13d)]===_0x4e2f29(0x10c)||_0x407b67[_0x4e2f29(0x13d)]===_0x4e2f29(0xfd))await this[_0x4e2f29(0x12e)]();}catch{}}}}catch(_0x274ad0){if(_0x274ad0[_0x4e2f29(0x150)]==='AbortError')break;this[_0x4e2f29(0x113)](_0x4e2f29(0x103),_0x274ad0),this[_0x4e2f29(0xdd)](_0x4e2f29(0x14d)+_0x274ad0[_0x4e2f29(0x13e)]);}if(this[_0x4e2f29(0x12a)])this[_0x4e2f29(0x113)](_0x4e2f29(0x144)),this[_0x4e2f29(0xdd)](_0x4e2f29(0x10a)+_0x5ec7ba/0x3e8+'s...'),await this['sleep'](_0x5ec7ba),_0x5ec7ba=Math[_0x4e2f29(0x111)](_0x5ec7ba*1.5,0xea60);}}async[a0_0x3202f1(0x12e)](){const _0x493a77=a0_0x3202f1;try{let _0xe6fcfd=(await this['call']('get_inbox',{'alias':this['alias'],'limit':0xa}))?.[_0x493a77(0x13b)]||[];for(let _0x3a1850 of _0xe6fcfd)await this[_0x493a77(0x136)](_0x493a77(0x132),{'alias':this[_0x493a77(0x140)],'message_id':_0x3a1850['id']}),this[_0x493a77(0xdd)]('←\x20'+_0x3a1850[_0x493a77(0xda)]+':\x20'+_0x3a1850['content'][_0x493a77(0xd2)](0x0,0x3c)),this[_0x493a77(0x113)](_0x493a77(0xe0),_0x3a1850),this[_0x493a77(0x113)](_0x493a77(0x13e),_0x3a1850);}catch(_0x196d3d){this[_0x493a77(0xdd)](_0x493a77(0x10b)+_0x196d3d[_0x493a77(0x13e)]);}}['sleep'](_0xd7c6ad){return new Promise(_0x123e39=>setTimeout(_0x123e39,_0xd7c6ad));}}var F=$;export{F as default,$ as CommHub};
1
+ const a0_0x2e1d66=a0_0x53f5;(function(_0x300e8c,_0x584917){const _0x45369d=a0_0x53f5,_0xa54d=_0x300e8c();while(!![]){try{const _0xa1f7f6=parseInt(_0x45369d(0x22a))/0x1*(parseInt(_0x45369d(0x1cf))/0x2)+parseInt(_0x45369d(0x1d0))/0x3*(parseInt(_0x45369d(0x232))/0x4)+parseInt(_0x45369d(0x207))/0x5*(-parseInt(_0x45369d(0x228))/0x6)+-parseInt(_0x45369d(0x214))/0x7*(parseInt(_0x45369d(0x1ce))/0x8)+parseInt(_0x45369d(0x1d9))/0x9+-parseInt(_0x45369d(0x212))/0xa*(parseInt(_0x45369d(0x1e2))/0xb)+parseInt(_0x45369d(0x1f0))/0xc;if(_0xa1f7f6===_0x584917)break;else _0xa54d['push'](_0xa54d['shift']());}catch(_0x478c9b){_0xa54d['push'](_0xa54d['shift']());}}}(a0_0x3f0d,0x58177));import{EventEmitter as a0_0x561018}from'events';import{hostname as a0_0x5321be}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x2e7b70,_0x1c474e)=>(_0x2e7b70??_0x1c474e)[a0_0x2e1d66(0x23b)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function a0_0x53f5(_0x2165a2,_0x1849de){_0x2165a2=_0x2165a2-0x1b2;const _0x3f0db0=a0_0x3f0d();let _0x53f546=_0x3f0db0[_0x2165a2];return _0x53f546;}function N(_0x2b96f6){const _0x16eeba=a0_0x2e1d66;return(_0x2b96f6 instanceof Error?_0x2b96f6[_0x16eeba(0x1dc)]:String(_0x2b96f6??_0x16eeba(0x204)))[_0x16eeba(0x23b)](K,_0x16eeba(0x1f1))[_0x16eeba(0x23b)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x16eeba(0x20b)](0x0,0xf0);}function O(_0x2289f3,_0x4465fb=process.env.ANET_TASK_TRACE_FORMAT===a0_0x2e1d66(0x1fd)){const _0x508ac6=a0_0x2e1d66;if(_0x4465fb)return JSON[_0x508ac6(0x1c2)](_0x2289f3);let _0x33b7b0=L(_0x2289f3[_0x508ac6(0x1ed)],_0x508ac6(0x1b2)),_0xd61be=L(_0x2289f3[_0x508ac6(0x20d)],_0x508ac6(0x1d1)),_0x1a21b2=_0x2289f3['error_code']?_0x508ac6(0x1e5)+_0x2289f3[_0x508ac6(0x1d7)]+':'+(_0x2289f3[_0x508ac6(0x1c0)]??''):'';return _0x508ac6(0x1b9)+_0x2289f3[_0x508ac6(0x222)]+_0x508ac6(0x219)+L(_0x2289f3[_0x508ac6(0x1be)],_0x508ac6(0x201))+_0x508ac6(0x23a)+L(_0x2289f3[_0x508ac6(0x211)],_0x508ac6(0x201))+_0x508ac6(0x1fb)+_0xd61be+_0x508ac6(0x22c)+_0x33b7b0+_0x508ac6(0x1bc)+L(_0x2289f3[_0x508ac6(0x235)],_0x508ac6(0x201))+_0x508ac6(0x224)+_0x2289f3[_0x508ac6(0x1e3)]+_0x508ac6(0x1b5)+_0x2289f3['duration_ms']+_0x508ac6(0x1f7)+_0x2289f3[_0x508ac6(0x1d4)]+_0x1a21b2;}function U(_0x25ec87){const _0x5098ce=a0_0x2e1d66;return{'event':{'sending':_0x5098ce(0x1c4),'delivered':_0x5098ce(0x1c6),'failed':_0x5098ce(0x1fe),'acked':_0x5098ce(0x1c1),'started':_0x5098ce(0x216),'replied':'task.replied','expired':_0x5098ce(0x230)}[_0x25ec87[_0x5098ce(0x222)]],..._0x25ec87};}function j(_0x30a116){const _0xccbc17=a0_0x2e1d66;let _0x40884f=_0x30a116?.['task_id']||_0x30a116?.['message_id']||_0x30a116?.['id'];if(_0x40884f)return String(_0x40884f);let _0x385d2d=_0x30a116?.[_0xccbc17(0x21f)]?.[0x0]?.['text'];if(typeof _0x385d2d!==_0xccbc17(0x22d))return null;try{let _0xdc82e3=JSON[_0xccbc17(0x1e9)](_0x385d2d);return _0xdc82e3?.[_0xccbc17(0x20d)]||_0xdc82e3?.[_0xccbc17(0x1d5)]||_0xdc82e3?.['id']||null;}catch{return null;}}async function X(_0x5b2a67,_0x509dd6){const _0x2d5f57=a0_0x2e1d66;let _0xd2ca1a=_0x509dd6[_0x2d5f57(0x1f8)]??Date[_0x2d5f57(0x1f8)],_0x176844=_0xd2ca1a(),_0xf1593d=(_0x37f74d,_0x3563b5,_0x50a272,_0x24cae2)=>{const _0x3b43f0=_0x2d5f57;_0x509dd6[_0x3b43f0(0x1cd)](O(U({'from_alias':_0x5b2a67['fromAlias'],'to_alias':_0x5b2a67[_0x3b43f0(0x1e4)],'task_id':_0x3563b5,'parent_task_id':_0x5b2a67['parentTaskId'],'network_id':_0x5b2a67['networkId'],'transport':_0x5b2a67[_0x3b43f0(0x1e3)],'status':_0x37f74d,'duration_ms':_0xd2ca1a()-_0x176844,'lifecycle_tracking':_0x5b2a67[_0x3b43f0(0x1b8)],..._0x50a272!==void 0x0?{'error_code':_0x24cae2||_0x3b43f0(0x238),'error_message':N(_0x50a272)}:{}})));};_0xf1593d(_0x2d5f57(0x1c5),null);try{let _0x1e83c5=await _0x509dd6[_0x2d5f57(0x1dd)](),_0x11f5dc=j(_0x1e83c5);if(_0x11f5dc)_0xf1593d(_0x2d5f57(0x1eb),_0x11f5dc);else{if(_0x1e83c5?.['ok']===!0x1||_0x1e83c5?.['error'])_0xf1593d(_0x2d5f57(0x237),_0x11f5dc,_0x1e83c5?.[_0x2d5f57(0x1e7)]||_0x2d5f57(0x1f6),_0x2d5f57(0x1e1));else _0xf1593d('failed',null,'CommHub\x20response\x20omitted\x20task_id',_0x2d5f57(0x1ef));}return _0x1e83c5;}catch(_0x424852){throw _0xf1593d(_0x2d5f57(0x237),null,_0x424852,_0x2d5f57(0x238)),_0x424852;}}async function Y(_0x590e96,_0x5824b4){const _0x54cb68=a0_0x2e1d66;return X({'fromAlias':_0x590e96[_0x54cb68(0x1f4)],'toAlias':_0x590e96[_0x54cb68(0x1e8)],'parentTaskId':_0x590e96[_0x54cb68(0x1cc)]||null,'networkId':_0x590e96[_0x54cb68(0x210)]||null,'transport':_0x54cb68(0x1fc),'lifecycleTracking':'not_tracked'},_0x5824b4);}class $ extends a0_0x561018{[a0_0x2e1d66(0x1d3)];[a0_0x2e1d66(0x1e8)];['token'];['agent'];['resumeId'];['heartbeatInterval'];[a0_0x2e1d66(0x20a)];[a0_0x2e1d66(0x229)];[a0_0x2e1d66(0x1bb)];['running']=!0x1;constructor(_0x24b6a1){const _0x56c3e1=a0_0x2e1d66;super();if(this['url']=_0x24b6a1['url'][_0x56c3e1(0x23b)](/\/$/,''),this[_0x56c3e1(0x1e8)]=_0x24b6a1[_0x56c3e1(0x1e8)],this['token']=_0x24b6a1[_0x56c3e1(0x20c)],this[_0x56c3e1(0x218)]=_0x24b6a1[_0x56c3e1(0x218)]||_0x56c3e1(0x208),this[_0x56c3e1(0x1e6)]=_0x56c3e1(0x1da)+_0x24b6a1[_0x56c3e1(0x1e8)]+'-'+Date[_0x56c3e1(0x1f8)]()[_0x56c3e1(0x1b4)](0x24),this['heartbeatInterval']=_0x24b6a1[_0x56c3e1(0x21a)]??0x2bf20,this[_0x56c3e1(0x20a)]=_0x24b6a1['reconnectDelay']??0xbb8,_0x24b6a1['autoConnect']!==!0x1)this[_0x56c3e1(0x1c8)]();}[a0_0x2e1d66(0x1cd)](_0x650a70){const _0x222959=a0_0x2e1d66;console[_0x222959(0x1cd)]('['+new Date()['toTimeString']()['slice'](0x0,0x8)+_0x222959(0x22e)+this[_0x222959(0x1e8)]+']\x20'+_0x650a70);}async['call'](_0x51db64,_0x4dbbf6){const _0x1c0537=a0_0x2e1d66;let _0x5b1282={'Content-Type':_0x1c0537(0x200),'Accept':_0x1c0537(0x1bd)};if(this[_0x1c0537(0x20c)])_0x5b1282['Authorization']=_0x1c0537(0x20e)+this[_0x1c0537(0x20c)];let _0xd5cb4a=await(await fetch(this[_0x1c0537(0x1d3)]+_0x1c0537(0x1e0),{'method':_0x1c0537(0x226),'headers':_0x5b1282,'body':JSON['stringify']({'jsonrpc':_0x1c0537(0x213),'id':Date[_0x1c0537(0x1f8)](),'method':'tools/call','params':{'name':_0x51db64,'arguments':_0x4dbbf6}})}))[_0x1c0537(0x209)](),_0x2eebf=_0xd5cb4a[_0x1c0537(0x1d8)](/data: (.+)/),_0x5b025d=_0x2eebf?JSON['parse'](_0x2eebf[0x1]):JSON[_0x1c0537(0x1e9)](_0xd5cb4a),_0x15f0a0=_0x5b025d?.[_0x1c0537(0x236)]?.[_0x1c0537(0x21f)]?.[0x0]?.[_0x1c0537(0x209)];return _0x15f0a0?JSON[_0x1c0537(0x1e9)](_0x15f0a0):_0x5b025d;}async[a0_0x2e1d66(0x1c8)](){const _0x555d91=a0_0x2e1d66;if(this[_0x555d91(0x239)])return;this['running']=!0x0,await this[_0x555d91(0x222)](_0x555d91(0x1cb)),this['log'](_0x555d91(0x223)),this[_0x555d91(0x229)]=setInterval(()=>{const _0x486f98=_0x555d91;this['status'](_0x486f98(0x1cb))[_0x486f98(0x233)](_0x4252f8=>this[_0x486f98(0x1cd)](_0x486f98(0x1ba)+_0x4252f8[_0x486f98(0x1dc)]));},this[_0x555d91(0x21a)]),this[_0x555d91(0x1f9)]();}async[a0_0x2e1d66(0x1b3)](){const _0xf0db2c=a0_0x2e1d66;if(this[_0xf0db2c(0x239)]=!0x1,this[_0xf0db2c(0x1bb)]?.[_0xf0db2c(0x1de)](),this[_0xf0db2c(0x229)])clearInterval(this[_0xf0db2c(0x229)]);await this[_0xf0db2c(0x222)](_0xf0db2c(0x1b6))[_0xf0db2c(0x233)](()=>{}),this[_0xf0db2c(0x1cd)]('disconnected');}async[a0_0x2e1d66(0x1dd)](_0x2378b6,_0x540ac1,_0x8a4af2=a0_0x2e1d66(0x22b)){const _0x23d759=a0_0x2e1d66;return Y({'alias':_0x2378b6,'fromAlias':this[_0x23d759(0x1e8)]},{'log':_0x95362=>console['log'](_0x95362),'send':()=>this[_0x23d759(0x23c)](_0x23d759(0x234),{'alias':_0x2378b6,'task':_0x540ac1,'priority':_0x8a4af2,'from_session':this[_0x23d759(0x1e8)]})});}async[a0_0x2e1d66(0x1dc)](_0x5bae5e,_0x4839f8){const _0x400909=a0_0x2e1d66;return this[_0x400909(0x23c)](_0x400909(0x20f),{'alias':_0x5bae5e,'message':_0x4839f8,'from_session':this['alias']});}async['reply'](_0x197678,_0x1792a5,_0xc14eba=a0_0x2e1d66(0x1fa)){const _0x4dbec1=a0_0x2e1d66;return this['call'](_0x4dbec1(0x21d),{'in_reply_to':_0x197678,'text':_0x1792a5,'status':_0xc14eba});}async[a0_0x2e1d66(0x222)](_0x45bdb5,_0x183f8f){const _0x29a335=a0_0x2e1d66;return this[_0x29a335(0x23c)](_0x29a335(0x1ff),{'resume_id':this['resumeId'],'alias':this[_0x29a335(0x1e8)],'status':_0x45bdb5,'server':a0_0x5321be(),'hostname':a0_0x5321be(),'agent':this[_0x29a335(0x218)],'project_dir':process[_0x29a335(0x1b7)](),..._0x183f8f});}async[a0_0x2e1d66(0x22f)](){const _0x447cde=a0_0x2e1d66;return this[_0x447cde(0x23c)](_0x447cde(0x1ca),{});}async[a0_0x2e1d66(0x1ec)](_0x186230,_0xe99726){const _0x267746=a0_0x2e1d66;return this[_0x267746(0x23c)]('broadcast',{'message':_0x186230,'filter_server':_0xe99726?.[_0x267746(0x21b)],'filter_status':_0xe99726?.[_0x267746(0x222)]});}async[a0_0x2e1d66(0x1f9)](){const _0x3232ef=a0_0x2e1d66;let _0x2c9864=encodeURIComponent(this[_0x3232ef(0x1e8)]),_0x58eaba=this['url']+_0x3232ef(0x1bf)+_0x2c9864,_0x2f47cc=this['reconnectDelay'];while(this[_0x3232ef(0x239)]){try{this[_0x3232ef(0x1bb)]=new AbortController();let _0x153f3f={'Accept':_0x3232ef(0x220)};if(this['token'])_0x153f3f[_0x3232ef(0x1f3)]=_0x3232ef(0x20e)+this[_0x3232ef(0x20c)];let _0x1e45b7=await fetch(_0x58eaba,{'headers':_0x153f3f,'signal':this['sseAbort'][_0x3232ef(0x21e)]});if(!_0x1e45b7['ok']||!_0x1e45b7[_0x3232ef(0x1d2)]){this[_0x3232ef(0x1cd)](_0x3232ef(0x1d6)+_0x1e45b7[_0x3232ef(0x222)]),await this[_0x3232ef(0x1c9)](_0x2f47cc),_0x2f47cc=Math[_0x3232ef(0x1df)](_0x2f47cc*1.5,0xea60);continue;}_0x2f47cc=this['reconnectDelay'];let _0x3969aa=_0x1e45b7[_0x3232ef(0x1d2)][_0x3232ef(0x1c3)](),_0x35e2f9=new TextDecoder(),_0x47887d='';while(this['running']){let {done:_0x34785f,value:_0x560e24}=await _0x3969aa[_0x3232ef(0x217)]();if(_0x34785f)break;_0x47887d+=_0x35e2f9[_0x3232ef(0x225)](_0x560e24,{'stream':!0x0});let _0x4808be=_0x47887d[_0x3232ef(0x215)]('\x0a');_0x47887d=_0x4808be[_0x3232ef(0x205)]()||'';for(let _0x2a9b01 of _0x4808be){if(!_0x2a9b01[_0x3232ef(0x21c)]('data:\x20'))continue;try{let _0x2cc122=JSON[_0x3232ef(0x1e9)](_0x2a9b01[_0x3232ef(0x20b)](0x6));if(_0x2cc122[_0x3232ef(0x231)]==='connected'){this[_0x3232ef(0x1cd)]('SSE\x20connected'),this[_0x3232ef(0x1f2)](_0x3232ef(0x206));continue;}if(_0x2cc122[_0x3232ef(0x231)]===_0x3232ef(0x203)||_0x2cc122[_0x3232ef(0x231)]===_0x3232ef(0x1ea)||_0x2cc122['type']===_0x3232ef(0x1ec))await this[_0x3232ef(0x1f5)]();}catch{}}}}catch(_0x4cdbc8){if(_0x4cdbc8[_0x3232ef(0x1db)]==='AbortError')break;this['emit'](_0x3232ef(0x1e7),_0x4cdbc8),this['log']('SSE\x20error:\x20'+_0x4cdbc8[_0x3232ef(0x1dc)]);}if(this[_0x3232ef(0x239)])this[_0x3232ef(0x1f2)]('disconnected'),this[_0x3232ef(0x1cd)]('SSE\x20reconnecting\x20in\x20'+_0x2f47cc/0x3e8+_0x3232ef(0x1ee)),await this['sleep'](_0x2f47cc),_0x2f47cc=Math[_0x3232ef(0x1df)](_0x2f47cc*1.5,0xea60);}}async['processInbox'](){const _0x1a7d92=a0_0x2e1d66;try{let _0x156fbc=(await this[_0x1a7d92(0x23c)](_0x1a7d92(0x221),{'alias':this[_0x1a7d92(0x1e8)],'limit':0xa}))?.[_0x1a7d92(0x202)]||[];for(let _0x49626c of _0x156fbc)await this[_0x1a7d92(0x23c)]('ack_inbox',{'alias':this['alias'],'message_id':_0x49626c['id']}),this[_0x1a7d92(0x1cd)]('←\x20'+_0x49626c[_0x1a7d92(0x1c7)]+':\x20'+_0x49626c[_0x1a7d92(0x21f)][_0x1a7d92(0x20b)](0x0,0x3c)),this[_0x1a7d92(0x1f2)]('task',_0x49626c),this['emit'](_0x1a7d92(0x1dc),_0x49626c);}catch(_0x5bfd11){this[_0x1a7d92(0x1cd)](_0x1a7d92(0x227)+_0x5bfd11['message']);}}[a0_0x2e1d66(0x1c9)](_0x2969ff){return new Promise(_0x5820b4=>setTimeout(_0x5820b4,_0x2969ff));}}function a0_0x3f0d(){const _0x21f5fd=['new_message','delivered','broadcast','parent_task_id','s...','missing_task_id','8851956mfEbiw','[REDACTED]','emit','Authorization','fromAlias','processInbox','CommHub\x20rejected\x20task','\x20lifecycle=','now','connectSSE','completed','\x20task_id=','mcp_http','json','task.send.failed','report_status','application/json','<unknown>','messages','new_task','unknown\x20error','pop','connected','70895HLPsgP','sdk','text','reconnectDelay','slice','token','task_id','Bearer\x20','send_message','networkId','to_alias','10PHhOxh','2.0','1603QzuSoI','split','task.started','read','agent','\x20from=','heartbeatInterval','server','startsWith','send_reply','signal','content','text/event-stream','get_inbox','status','registered','\x20transport=','decode','POST','inbox\x20error:\x20','186SLxbrC','heartbeatTimer','616575WBNYzc','normal','\x20parent_task_id=','string',']\x20[commhub:','getAllStatus','task.expired','type','495124jyoSsi','catch','send_task','network_id','result','failed','send_failed','running','\x20to=','replace','call','<missing>','disconnect','toString','\x20duration_ms=','offline','cwd','lifecycleTracking','[commhub:task]\x20','heartbeat\x20failed:\x20','sseAbort','\x20network_id=','application/json,\x20text/event-stream','from_alias','/events/','error_message','task.ack','stringify','getReader','task.send.start','sending','task.send.delivered','from_session','connect','sleep','get_all_status','idle','parentTaskId','log','11560yVxcUR','2BdgPbx','3ylNufY','<pending>','body','url','lifecycle_tracking','message_id','SSE\x20failed:\x20','error_code','match','2242422znmdCi','sdk-','name','message','send','abort','min','/mcp','send_rejected','6554900SJRXcM','transport','toAlias','\x20error=','resumeId','error','alias','parse'];a0_0x3f0d=function(){return _0x21f5fd;};return a0_0x3f0d();}var F=$;export{F as default,$ as CommHub};