@sleep2agi/agent-network 2.3.0-preview.170 → 2.3.0-preview.172

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_0x190d23=a0_0x5089;(function(_0x5eb96b,_0x5b6f30){const _0x4a734d=a0_0x5089,_0x55aa4b=_0x5eb96b();while(!![]){try{const _0x41de9c=parseInt(_0x4a734d(0xc3))/0x1*(-parseInt(_0x4a734d(0xd7))/0x2)+parseInt(_0x4a734d(0x11b))/0x3+-parseInt(_0x4a734d(0xf9))/0x4*(-parseInt(_0x4a734d(0xa6))/0x5)+parseInt(_0x4a734d(0xd8))/0x6+-parseInt(_0x4a734d(0xe7))/0x7+-parseInt(_0x4a734d(0x100))/0x8*(-parseInt(_0x4a734d(0xae))/0x9)+-parseInt(_0x4a734d(0xa5))/0xa;if(_0x41de9c===_0x5b6f30)break;else _0x55aa4b['push'](_0x55aa4b['shift']());}catch(_0x1512e8){_0x55aa4b['push'](_0x55aa4b['shift']());}}}(a0_0x2ce7,0xbf3b5));import{EventEmitter as a0_0x22c93e}from'events';import{hostname as a0_0x2251a6}from'os';function a0_0x5089(_0x485b3c,_0x8d9619){_0x485b3c=_0x485b3c-0xa5;const _0x2ce7b4=a0_0x2ce7();let _0x508934=_0x2ce7b4[_0x485b3c];return _0x508934;}var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x1f2ce1,_0x12fd2f)=>(_0x1f2ce1??_0x12fd2f)[a0_0x190d23(0xff)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x5e2ca5){const _0x5eefd8=a0_0x190d23;return(_0x5e2ca5 instanceof Error?_0x5e2ca5[_0x5eefd8(0xd5)]:String(_0x5e2ca5??'unknown\x20error'))['replace'](K,'[REDACTED]')[_0x5eefd8(0xff)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x5eefd8(0x10b)](0x0,0xf0);}function O(_0x3c018a,_0x2b54d3=process.env.ANET_TASK_TRACE_FORMAT===a0_0x190d23(0xfc)){const _0x46414e=a0_0x190d23;if(_0x2b54d3)return JSON[_0x46414e(0xaa)](_0x3c018a);let _0x3a5d8f=L(_0x3c018a[_0x46414e(0xfe)],_0x46414e(0xbe)),_0x56e195=L(_0x3c018a[_0x46414e(0xc0)],'<pending>'),_0x26af21=_0x3c018a[_0x46414e(0xf4)]?_0x46414e(0x11c)+_0x3c018a[_0x46414e(0xf4)]+':'+(_0x3c018a['error_message']??''):'';return _0x46414e(0x112)+_0x3c018a[_0x46414e(0x103)]+'\x20from='+L(_0x3c018a[_0x46414e(0xc2)],_0x46414e(0x118))+_0x46414e(0x111)+L(_0x3c018a['to_alias'],_0x46414e(0x118))+_0x46414e(0xc8)+_0x56e195+_0x46414e(0xd9)+_0x3a5d8f+_0x46414e(0xd6)+L(_0x3c018a['network_id'],_0x46414e(0x118))+'\x20transport='+_0x3c018a['transport']+'\x20duration_ms='+_0x3c018a['duration_ms']+_0x46414e(0xab)+_0x3c018a['lifecycle_tracking']+_0x26af21;}function U(_0x1e1cc1){const _0x228a6e=a0_0x190d23;return{'event':{'sending':'task.send.start','delivered':_0x228a6e(0xcf),'failed':'task.send.failed','acked':_0x228a6e(0xf6),'started':_0x228a6e(0xe9),'replied':_0x228a6e(0xe2),'expired':'task.expired'}[_0x1e1cc1[_0x228a6e(0x103)]],..._0x1e1cc1};}function j(_0x1134be){const _0x183cf9=a0_0x190d23;let _0x337466=_0x1134be?.[_0x183cf9(0xc0)]||_0x1134be?.[_0x183cf9(0x101)]||_0x1134be?.['id'];if(_0x337466)return String(_0x337466);let _0x5b9703=_0x1134be?.[_0x183cf9(0xdc)]?.[0x0]?.[_0x183cf9(0xac)];if(typeof _0x5b9703!=='string')return null;try{let _0x534f89=JSON[_0x183cf9(0x117)](_0x5b9703);return _0x534f89?.['task_id']||_0x534f89?.['message_id']||_0x534f89?.['id']||null;}catch{return null;}}async function X(_0x3efc2b,_0xf5099d){const _0x1f3c8f=a0_0x190d23;let _0x41c745=_0xf5099d[_0x1f3c8f(0xf2)]??Date[_0x1f3c8f(0xf2)],_0x3f48f7=_0x41c745(),_0x207f0d=(_0x5ec358,_0x467caf,_0x1c41c7,_0xdaf70b)=>{const _0x11c1a5=_0x1f3c8f;_0xf5099d['log'](O(U({'from_alias':_0x3efc2b[_0x11c1a5(0x116)],'to_alias':_0x3efc2b['toAlias'],'task_id':_0x467caf,'parent_task_id':_0x3efc2b[_0x11c1a5(0x114)],'network_id':_0x3efc2b[_0x11c1a5(0xc4)],'transport':_0x3efc2b[_0x11c1a5(0xc6)],'status':_0x5ec358,'duration_ms':_0x41c745()-_0x3f48f7,'lifecycle_tracking':_0x3efc2b[_0x11c1a5(0xe1)],..._0x1c41c7!==void 0x0?{'error_code':_0xdaf70b||'send_failed','error_message':N(_0x1c41c7)}:{}})));};_0x207f0d(_0x1f3c8f(0xcd),null);try{let _0x2beba3=await _0xf5099d['send'](),_0x18f2fc=j(_0x2beba3);if(_0x18f2fc)_0x207f0d(_0x1f3c8f(0xd3),_0x18f2fc);else{if(_0x2beba3?.['ok']===!0x1||_0x2beba3?.[_0x1f3c8f(0xea)])_0x207f0d(_0x1f3c8f(0x102),_0x18f2fc,_0x2beba3?.['error']||_0x1f3c8f(0x10e),'send_rejected');else _0x207f0d(_0x1f3c8f(0x102),null,_0x1f3c8f(0xe0),_0x1f3c8f(0x106));}return _0x2beba3;}catch(_0x27831c){throw _0x207f0d(_0x1f3c8f(0x102),null,_0x27831c,'send_failed'),_0x27831c;}}async function Y(_0x232dd0,_0x2d1be5){const _0x4a3f5b=a0_0x190d23;return X({'fromAlias':_0x232dd0[_0x4a3f5b(0x116)],'toAlias':_0x232dd0[_0x4a3f5b(0x105)],'parentTaskId':_0x232dd0[_0x4a3f5b(0x114)]||null,'networkId':_0x232dd0[_0x4a3f5b(0xc4)]||null,'transport':_0x4a3f5b(0x10c),'lifecycleTracking':'not_tracked'},_0x2d1be5);}class $ extends a0_0x22c93e{[a0_0x190d23(0xd1)];[a0_0x190d23(0x105)];[a0_0x190d23(0xec)];[a0_0x190d23(0xb5)];[a0_0x190d23(0xf8)];[a0_0x190d23(0xed)];[a0_0x190d23(0xe5)];[a0_0x190d23(0x115)];[a0_0x190d23(0xfa)];[a0_0x190d23(0xfd)]=!0x1;constructor(_0x46f4f0){const _0x5cdd76=a0_0x190d23;super();if(this[_0x5cdd76(0xd1)]=_0x46f4f0[_0x5cdd76(0xd1)][_0x5cdd76(0xff)](/\/$/,''),this[_0x5cdd76(0x105)]=_0x46f4f0[_0x5cdd76(0x105)],this[_0x5cdd76(0xec)]=_0x46f4f0[_0x5cdd76(0xec)],this[_0x5cdd76(0xb5)]=_0x46f4f0[_0x5cdd76(0xb5)]||_0x5cdd76(0xca),this['resumeId']=_0x5cdd76(0xcc)+_0x46f4f0[_0x5cdd76(0x105)]+'-'+Date[_0x5cdd76(0xf2)]()[_0x5cdd76(0xb0)](0x24),this[_0x5cdd76(0xed)]=_0x46f4f0[_0x5cdd76(0xed)]??0x2bf20,this['reconnectDelay']=_0x46f4f0['reconnectDelay']??0xbb8,_0x46f4f0[_0x5cdd76(0xc9)]!==!0x1)this['connect']();}[a0_0x190d23(0x109)](_0x5575b1){const _0x136c14=a0_0x190d23;console['log']('['+new Date()[_0x136c14(0xda)]()[_0x136c14(0x10b)](0x0,0x8)+_0x136c14(0xb3)+this['alias']+']\x20'+_0x5575b1);}async[a0_0x190d23(0xe8)](_0x221b61,_0x504f30){const _0x38c63d=a0_0x190d23;let _0xabd4={'Content-Type':_0x38c63d(0xb4),'Accept':_0x38c63d(0xce)};if(this[_0x38c63d(0xec)])_0xabd4[_0x38c63d(0x11a)]=_0x38c63d(0xb1)+this['token'];let _0x360f90=await(await fetch(this['url']+'/mcp',{'method':_0x38c63d(0xdd),'headers':_0xabd4,'body':JSON[_0x38c63d(0xaa)]({'jsonrpc':_0x38c63d(0xc7),'id':Date[_0x38c63d(0xf2)](),'method':_0x38c63d(0x10f),'params':{'name':_0x221b61,'arguments':_0x504f30}})}))[_0x38c63d(0xac)](),_0x229e04=_0x360f90[_0x38c63d(0xbb)](/data: (.+)/),_0x17d94b=_0x229e04?JSON[_0x38c63d(0x117)](_0x229e04[0x1]):JSON[_0x38c63d(0x117)](_0x360f90),_0x5925ee=_0x17d94b?.[_0x38c63d(0xb6)]?.['content']?.[0x0]?.['text'];return _0x5925ee?JSON[_0x38c63d(0x117)](_0x5925ee):_0x17d94b;}async[a0_0x190d23(0x10a)](){const _0x4d4988=a0_0x190d23;if(this[_0x4d4988(0xfd)])return;this[_0x4d4988(0xfd)]=!0x0,await this[_0x4d4988(0x103)](_0x4d4988(0xee)),this[_0x4d4988(0x109)]('registered'),this['heartbeatTimer']=setInterval(()=>{const _0x6e812e=_0x4d4988;this['status']('idle')[_0x6e812e(0xdb)](_0x53bf86=>this[_0x6e812e(0x109)](_0x6e812e(0xd0)+_0x53bf86[_0x6e812e(0xd5)]));},this['heartbeatInterval']),this['connectSSE']();}async[a0_0x190d23(0x108)](){const _0x149c69=a0_0x190d23;if(this[_0x149c69(0xfd)]=!0x1,this[_0x149c69(0xfa)]?.['abort'](),this[_0x149c69(0x115)])clearInterval(this[_0x149c69(0x115)]);await this[_0x149c69(0x103)]('offline')[_0x149c69(0xdb)](()=>{}),this[_0x149c69(0x109)](_0x149c69(0xe6));}async[a0_0x190d23(0xbf)](_0x25e5b6,_0xe06523,_0x520f04=a0_0x190d23(0xbd)){const _0x466a55=a0_0x190d23;return Y({'alias':_0x25e5b6,'fromAlias':this[_0x466a55(0x105)]},{'log':_0x52d2ad=>console['log'](_0x52d2ad),'send':()=>this[_0x466a55(0xe8)](_0x466a55(0xf7),{'alias':_0x25e5b6,'task':_0xe06523,'priority':_0x520f04,'from_session':this[_0x466a55(0x105)]})});}async[a0_0x190d23(0xd5)](_0x3a13b6,_0x474e36){const _0x5529ab=a0_0x190d23;return this[_0x5529ab(0xe8)](_0x5529ab(0xa9),{'alias':_0x3a13b6,'message':_0x474e36,'from_session':this['alias']});}async[a0_0x190d23(0xd2)](_0x4a26ee,_0x338238,_0x3a7f87=a0_0x190d23(0xaf)){const _0x51a1fb=a0_0x190d23;return this['call'](_0x51a1fb(0x110),{'in_reply_to':_0x4a26ee,'text':_0x338238,'status':_0x3a7f87});}async['status'](_0x57c38f,_0x5cb7cb){const _0x23fb68=a0_0x190d23;return this[_0x23fb68(0xe8)](_0x23fb68(0xb8),{'resume_id':this[_0x23fb68(0xf8)],'alias':this[_0x23fb68(0x105)],'status':_0x57c38f,'server':a0_0x2251a6(),'hostname':a0_0x2251a6(),'agent':this[_0x23fb68(0xb5)],'project_dir':process[_0x23fb68(0xef)](),..._0x5cb7cb});}async['getAllStatus'](){const _0x14d3f3=a0_0x190d23;return this[_0x14d3f3(0xe8)](_0x14d3f3(0xde),{});}async[a0_0x190d23(0xa8)](_0xb407eb,_0x3c9f74){const _0x488ea0=a0_0x190d23;return this[_0x488ea0(0xe8)](_0x488ea0(0xa8),{'message':_0xb407eb,'filter_server':_0x3c9f74?.[_0x488ea0(0xcb)],'filter_status':_0x3c9f74?.[_0x488ea0(0x103)]});}async['connectSSE'](){const _0x4402a2=a0_0x190d23;let _0x358997=encodeURIComponent(this['alias']),_0xcb9536=this[_0x4402a2(0xd1)]+_0x4402a2(0xe3)+_0x358997,_0x1664f1=this[_0x4402a2(0xe5)];while(this[_0x4402a2(0xfd)]){try{this['sseAbort']=new AbortController();let _0x148ccf={'Accept':_0x4402a2(0x119)};if(this[_0x4402a2(0xec)])_0x148ccf['Authorization']=_0x4402a2(0xb1)+this[_0x4402a2(0xec)];let _0x574f03=await fetch(_0xcb9536,{'headers':_0x148ccf,'signal':this[_0x4402a2(0xfa)][_0x4402a2(0x113)]});if(!_0x574f03['ok']||!_0x574f03[_0x4402a2(0xba)]){this[_0x4402a2(0x109)](_0x4402a2(0xf5)+_0x574f03['status']),await this[_0x4402a2(0x104)](_0x1664f1),_0x1664f1=Math['min'](_0x1664f1*1.5,0xea60);continue;}_0x1664f1=this[_0x4402a2(0xe5)];let _0x578a5c=_0x574f03[_0x4402a2(0xba)][_0x4402a2(0xd4)](),_0x5cea38=new TextDecoder(),_0x178404='';while(this['running']){let {done:_0x4aa91d,value:_0x4e1c73}=await _0x578a5c[_0x4402a2(0xc5)]();if(_0x4aa91d)break;_0x178404+=_0x5cea38[_0x4402a2(0xf0)](_0x4e1c73,{'stream':!0x0});let _0x1c8f74=_0x178404['split']('\x0a');_0x178404=_0x1c8f74[_0x4402a2(0xb2)]()||'';for(let _0x5e1a7f of _0x1c8f74){if(!_0x5e1a7f['startsWith'](_0x4402a2(0xb7)))continue;try{let _0x1dbf32=JSON['parse'](_0x5e1a7f['slice'](0x6));if(_0x1dbf32[_0x4402a2(0xa7)]==='connected'){this[_0x4402a2(0x109)](_0x4402a2(0x10d)),this[_0x4402a2(0xc1)](_0x4402a2(0xf1));continue;}if(_0x1dbf32['type']==='new_task'||_0x1dbf32[_0x4402a2(0xa7)]==='new_message'||_0x1dbf32[_0x4402a2(0xa7)]===_0x4402a2(0xa8))await this[_0x4402a2(0xb9)]();}catch{}}}}catch(_0x31938e){if(_0x31938e[_0x4402a2(0x107)]===_0x4402a2(0xbc))break;this[_0x4402a2(0xc1)](_0x4402a2(0xea),_0x31938e),this[_0x4402a2(0x109)](_0x4402a2(0xf3)+_0x31938e[_0x4402a2(0xd5)]);}if(this[_0x4402a2(0xfd)])this[_0x4402a2(0xc1)](_0x4402a2(0xe6)),this[_0x4402a2(0x109)](_0x4402a2(0xeb)+_0x1664f1/0x3e8+'s...'),await this[_0x4402a2(0x104)](_0x1664f1),_0x1664f1=Math[_0x4402a2(0xfb)](_0x1664f1*1.5,0xea60);}}async['processInbox'](){const _0x5f1434=a0_0x190d23;try{let _0x15e6ae=(await this[_0x5f1434(0xe8)]('get_inbox',{'alias':this[_0x5f1434(0x105)],'limit':0xa}))?.[_0x5f1434(0xdf)]||[];for(let _0x35eb5b of _0x15e6ae)await this[_0x5f1434(0xe8)]('ack_inbox',{'alias':this[_0x5f1434(0x105)],'message_id':_0x35eb5b['id']}),this[_0x5f1434(0x109)]('←\x20'+_0x35eb5b[_0x5f1434(0xe4)]+':\x20'+_0x35eb5b[_0x5f1434(0xdc)]['slice'](0x0,0x3c)),this[_0x5f1434(0xc1)](_0x5f1434(0xad),_0x35eb5b),this[_0x5f1434(0xc1)](_0x5f1434(0xd5),_0x35eb5b);}catch(_0x42f754){this[_0x5f1434(0x109)]('inbox\x20error:\x20'+_0x42f754[_0x5f1434(0xd5)]);}}['sleep'](_0x1b4ed1){return new Promise(_0x3936e3=>setTimeout(_0x3936e3,_0x1b4ed1));}}var F=$;function a0_0x2ce7(){const _0x4a2cdf=['POST','get_all_status','messages','CommHub\x20response\x20omitted\x20task_id','lifecycleTracking','task.replied','/events/','from_session','reconnectDelay','disconnected','2461179PLLtbX','call','task.started','error','SSE\x20reconnecting\x20in\x20','token','heartbeatInterval','idle','cwd','decode','connected','now','SSE\x20error:\x20','error_code','SSE\x20failed:\x20','task.ack','send_task','resumeId','95136CtXLiR','sseAbort','min','json','running','parent_task_id','replace','1864376ZqrPyK','message_id','failed','status','sleep','alias','missing_task_id','name','disconnect','log','connect','slice','mcp_http','SSE\x20connected','CommHub\x20rejected\x20task','tools/call','send_reply','\x20to=','[commhub:task]\x20','signal','parentTaskId','heartbeatTimer','fromAlias','parse','<unknown>','text/event-stream','Authorization','3857247LGXMJs','\x20error=','24174810mxeBNq','280RRNAoi','type','broadcast','send_message','stringify','\x20lifecycle=','text','task','54RHyePS','completed','toString','Bearer\x20','pop',']\x20[commhub:','application/json','agent','result','data:\x20','report_status','processInbox','body','match','AbortError','normal','<missing>','send','task_id','emit','from_alias','5pAJvXm','networkId','read','transport','2.0','\x20task_id=','autoConnect','sdk','server','sdk-','sending','application/json,\x20text/event-stream','task.send.delivered','heartbeat\x20failed:\x20','url','reply','delivered','getReader','message','\x20network_id=','378022jyyYDq','2888898NerLiC','\x20parent_task_id=','toTimeString','catch','content'];a0_0x2ce7=function(){return _0x4a2cdf;};return a0_0x2ce7();}export{F as default,$ as CommHub};
1
+ const a0_0xb2e5e2=a0_0x4c7e;(function(_0x24612a,_0x3a48c4){const _0x5e5778=a0_0x4c7e,_0x3344f4=_0x24612a();while(!![]){try{const _0x29c6d2=parseInt(_0x5e5778(0xec))/0x1+parseInt(_0x5e5778(0xfc))/0x2+parseInt(_0x5e5778(0x101))/0x3*(-parseInt(_0x5e5778(0x139))/0x4)+parseInt(_0x5e5778(0xd1))/0x5*(parseInt(_0x5e5778(0x13c))/0x6)+parseInt(_0x5e5778(0x132))/0x7*(parseInt(_0x5e5778(0xca))/0x8)+-parseInt(_0x5e5778(0xfd))/0x9*(parseInt(_0x5e5778(0xcd))/0xa)+parseInt(_0x5e5778(0xd8))/0xb*(-parseInt(_0x5e5778(0x124))/0xc);if(_0x29c6d2===_0x3a48c4)break;else _0x3344f4['push'](_0x3344f4['shift']());}catch(_0x5e9be0){_0x3344f4['push'](_0x3344f4['shift']());}}}(a0_0x4dbd,0x6e4be));import{EventEmitter as a0_0xea6ae5}from'events';import{hostname as a0_0x50b6bb}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x136666,_0x4964b6)=>(_0x136666??_0x4964b6)[a0_0xb2e5e2(0x102)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0xb2e5e2(0xf7)](0x0,0xf0);function N(_0xda578c){const _0x50b7aa=a0_0xb2e5e2;return(_0xda578c instanceof Error?_0xda578c['message']:String(_0xda578c??'unknown\x20error'))['replace'](K,'[REDACTED]')['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x50b7aa(0xf7)](0x0,0xf0);}function O(_0x15c3ae,_0x19145a=process.env.ANET_TASK_TRACE_FORMAT===a0_0xb2e5e2(0x104)){const _0x590a5d=a0_0xb2e5e2;if(_0x19145a)return JSON['stringify'](_0x15c3ae);let _0x1b50ec=L(_0x15c3ae['parent_task_id'],_0x590a5d(0x135)),_0x41feb3=L(_0x15c3ae['task_id'],'<pending>'),_0x225019=_0x15c3ae[_0x590a5d(0xf1)]?_0x590a5d(0xc0)+_0x15c3ae[_0x590a5d(0xf1)]+':'+(_0x15c3ae['error_message']??''):'';return'[commhub:task]\x20'+_0x15c3ae['status']+_0x590a5d(0x116)+L(_0x15c3ae['from_alias'],_0x590a5d(0xf4))+'\x20to='+L(_0x15c3ae[_0x590a5d(0xea)],_0x590a5d(0xf4))+_0x590a5d(0xc5)+_0x41feb3+_0x590a5d(0x10e)+_0x1b50ec+_0x590a5d(0xc2)+L(_0x15c3ae[_0x590a5d(0x13b)],_0x590a5d(0xf4))+_0x590a5d(0xe1)+_0x15c3ae['transport']+_0x590a5d(0x12f)+_0x15c3ae['duration_ms']+_0x590a5d(0xcb)+_0x15c3ae[_0x590a5d(0x113)]+_0x225019;}function U(_0x81fcaf){const _0xa189d3=a0_0xb2e5e2;return{'event':{'sending':_0xa189d3(0x129),'delivered':_0xa189d3(0x13a),'failed':_0xa189d3(0x123),'acked':_0xa189d3(0xe2),'started':_0xa189d3(0x107),'replied':'task.replied','expired':_0xa189d3(0xe8)}[_0x81fcaf[_0xa189d3(0x11c)]],..._0x81fcaf};}function j(_0xd26365){const _0xeda50e=a0_0xb2e5e2;let _0x93c59b=_0xd26365?.[_0xeda50e(0x108)]||_0xd26365?.[_0xeda50e(0x100)]||_0xd26365?.['id'];if(_0x93c59b)return String(_0x93c59b);let _0x214307=_0xd26365?.[_0xeda50e(0x130)]?.[0x0]?.[_0xeda50e(0xd3)];if(typeof _0x214307!==_0xeda50e(0x125))return null;try{let _0x5a8510=JSON['parse'](_0x214307);return _0x5a8510?.[_0xeda50e(0x108)]||_0x5a8510?.[_0xeda50e(0x100)]||_0x5a8510?.['id']||null;}catch{return null;}}function a0_0x4c7e(_0x53d0a1,_0x1420b8){_0x53d0a1=_0x53d0a1-0xc0;const _0x4dbd4a=a0_0x4dbd();let _0x4c7e82=_0x4dbd4a[_0x53d0a1];return _0x4c7e82;}async function X(_0x530dba,_0x2d4139){const _0x8bcf9f=a0_0xb2e5e2;let _0x4fbb6d=_0x2d4139[_0x8bcf9f(0x11b)]??Date[_0x8bcf9f(0x11b)],_0x4a8d4a=_0x4fbb6d(),_0xff62aa=(_0x4bb76f,_0x1eb07e,_0x33248c,_0x1a0008)=>{const _0x18de50=_0x8bcf9f;_0x2d4139['log'](O(U({'from_alias':_0x530dba[_0x18de50(0x143)],'to_alias':_0x530dba[_0x18de50(0xe3)],'task_id':_0x1eb07e,'parent_task_id':_0x530dba[_0x18de50(0xf6)],'network_id':_0x530dba[_0x18de50(0xfa)],'transport':_0x530dba['transport'],'status':_0x4bb76f,'duration_ms':_0x4fbb6d()-_0x4a8d4a,'lifecycle_tracking':_0x530dba[_0x18de50(0x11e)],..._0x33248c!==void 0x0?{'error_code':_0x1a0008||_0x18de50(0x140),'error_message':N(_0x33248c)}:{}})));};_0xff62aa(_0x8bcf9f(0xd6),null);try{let _0x758eb8=await _0x2d4139['send'](),_0x591ffb=j(_0x758eb8);if(_0x591ffb)_0xff62aa(_0x8bcf9f(0x138),_0x591ffb);else{if(_0x758eb8?.['ok']===!0x1||_0x758eb8?.[_0x8bcf9f(0xdd)])_0xff62aa(_0x8bcf9f(0xde),_0x591ffb,_0x758eb8?.[_0x8bcf9f(0xdd)]||_0x8bcf9f(0x11d),'send_rejected');else _0xff62aa(_0x8bcf9f(0xde),null,_0x8bcf9f(0x136),'missing_task_id');}return _0x758eb8;}catch(_0x1e23c2){throw _0xff62aa(_0x8bcf9f(0xde),null,_0x1e23c2,_0x8bcf9f(0x140)),_0x1e23c2;}}async function Y(_0x18b306,_0x5a0c56){const _0x366486=a0_0xb2e5e2;return X({'fromAlias':_0x18b306['fromAlias'],'toAlias':_0x18b306[_0x366486(0xd7)],'parentTaskId':_0x18b306['parentTaskId']||null,'networkId':_0x18b306[_0x366486(0xfa)]||null,'transport':_0x366486(0x106),'lifecycleTracking':_0x366486(0xd4)},_0x5a0c56);}class $ extends a0_0xea6ae5{[a0_0xb2e5e2(0x12d)];[a0_0xb2e5e2(0xd7)];['token'];[a0_0xb2e5e2(0x118)];[a0_0xb2e5e2(0x12b)];[a0_0xb2e5e2(0x133)];[a0_0xb2e5e2(0x11a)];['heartbeatTimer'];['sseAbort'];[a0_0xb2e5e2(0xf3)]=!0x1;constructor(_0x5b6fb1){const _0x32d155=a0_0xb2e5e2;super();if(this[_0x32d155(0x12d)]=_0x5b6fb1[_0x32d155(0x12d)][_0x32d155(0x102)](/\/$/,''),this[_0x32d155(0xd7)]=_0x5b6fb1[_0x32d155(0xd7)],this[_0x32d155(0xcf)]=_0x5b6fb1['token'],this[_0x32d155(0x118)]=_0x5b6fb1['agent']||'sdk',this['resumeId']=_0x32d155(0xdb)+_0x5b6fb1[_0x32d155(0xd7)]+'-'+Date['now']()[_0x32d155(0x117)](0x24),this[_0x32d155(0x133)]=_0x5b6fb1[_0x32d155(0x133)]??0x2bf20,this[_0x32d155(0x11a)]=_0x5b6fb1['reconnectDelay']??0xbb8,_0x5b6fb1[_0x32d155(0x110)]!==!0x1)this[_0x32d155(0xe9)]();}[a0_0xb2e5e2(0xfb)](_0x2a96ff){const _0x565c54=a0_0xb2e5e2;console['log']('['+new Date()[_0x565c54(0xdc)]()['slice'](0x0,0x8)+_0x565c54(0x109)+this[_0x565c54(0xd7)]+']\x20'+_0x2a96ff);}async[a0_0xb2e5e2(0xc3)](_0x4748ef,_0x562ad5){const _0x5992b7=a0_0xb2e5e2;let _0x226994={'Content-Type':_0x5992b7(0x10f),'Accept':_0x5992b7(0xce)};if(this[_0x5992b7(0xcf)])_0x226994[_0x5992b7(0x121)]=_0x5992b7(0x103)+this[_0x5992b7(0xcf)];let _0xb4ed11=await(await fetch(this['url']+_0x5992b7(0x10b),{'method':_0x5992b7(0x131),'headers':_0x226994,'body':JSON[_0x5992b7(0x111)]({'jsonrpc':_0x5992b7(0x112),'id':Date[_0x5992b7(0x11b)](),'method':_0x5992b7(0xe6),'params':{'name':_0x4748ef,'arguments':_0x562ad5}})}))['text'](),_0x577e22=_0xb4ed11[_0x5992b7(0xe5)](/data: (.+)/),_0x566800=_0x577e22?JSON[_0x5992b7(0x115)](_0x577e22[0x1]):JSON['parse'](_0xb4ed11),_0x385d3a=_0x566800?.[_0x5992b7(0xc1)]?.[_0x5992b7(0x130)]?.[0x0]?.[_0x5992b7(0xd3)];return _0x385d3a?JSON['parse'](_0x385d3a):_0x566800;}async[a0_0xb2e5e2(0xe9)](){const _0x5c83fc=a0_0xb2e5e2;if(this[_0x5c83fc(0xf3)])return;this['running']=!0x0,await this[_0x5c83fc(0x11c)](_0x5c83fc(0x122)),this['log'](_0x5c83fc(0x120)),this['heartbeatTimer']=setInterval(()=>{const _0x3801c8=_0x5c83fc;this[_0x3801c8(0x11c)](_0x3801c8(0x122))[_0x3801c8(0x126)](_0xb2e31f=>this['log'](_0x3801c8(0xf5)+_0xb2e31f[_0x3801c8(0x10d)]));},this[_0x5c83fc(0x133)]),this[_0x5c83fc(0xeb)]();}async[a0_0xb2e5e2(0x105)](){const _0x2e7dd1=a0_0xb2e5e2;if(this[_0x2e7dd1(0xf3)]=!0x1,this[_0x2e7dd1(0xc4)]?.['abort'](),this[_0x2e7dd1(0x13d)])clearInterval(this[_0x2e7dd1(0x13d)]);await this['status'](_0x2e7dd1(0xd0))['catch'](()=>{}),this[_0x2e7dd1(0xfb)](_0x2e7dd1(0x13e));}async[a0_0xb2e5e2(0xe0)](_0x1c9f11,_0x146997,_0x2fcee2='normal'){const _0x4cd385=a0_0xb2e5e2;return Y({'alias':_0x1c9f11,'fromAlias':this[_0x4cd385(0xd7)]},{'log':_0x44c75d=>console[_0x4cd385(0xfb)](_0x44c75d),'send':()=>this[_0x4cd385(0xc3)](_0x4cd385(0x127),{'alias':_0x1c9f11,'task':_0x146997,'priority':_0x2fcee2,'from_session':this[_0x4cd385(0xd7)]})});}async['message'](_0x522629,_0x4bb983){const _0x515846=a0_0xb2e5e2;return this[_0x515846(0xc3)](_0x515846(0x142),{'alias':_0x522629,'message':_0x4bb983,'from_session':this[_0x515846(0xd7)]});}async[a0_0xb2e5e2(0xc7)](_0x39f663,_0xd6cc2c,_0x3bdd65=a0_0xb2e5e2(0xdf)){const _0x26218f=a0_0xb2e5e2;return this[_0x26218f(0xc3)](_0x26218f(0xe4),{'in_reply_to':_0x39f663,'text':_0xd6cc2c,'status':_0x3bdd65});}async['status'](_0x406fe2,_0x321cdb){const _0x323b47=a0_0xb2e5e2;return this[_0x323b47(0xc3)](_0x323b47(0xef),{'resume_id':this[_0x323b47(0x12b)],'alias':this[_0x323b47(0xd7)],'status':_0x406fe2,'server':a0_0x50b6bb(),'hostname':a0_0x50b6bb(),'agent':this[_0x323b47(0x118)],'project_dir':process[_0x323b47(0x134)](),..._0x321cdb});}async['getAllStatus'](){const _0x2e1c20=a0_0xb2e5e2;return this['call'](_0x2e1c20(0xda),{});}async['broadcast'](_0x414745,_0x16aebb){const _0x372139=a0_0xb2e5e2;return this[_0x372139(0xc3)](_0x372139(0x12c),{'message':_0x414745,'filter_server':_0x16aebb?.[_0x372139(0xc6)],'filter_status':_0x16aebb?.[_0x372139(0x11c)]});}async[a0_0xb2e5e2(0xeb)](){const _0x9c787e=a0_0xb2e5e2;let _0x30a6e9=encodeURIComponent(this[_0x9c787e(0xd7)]),_0x160668=this[_0x9c787e(0x12d)]+_0x9c787e(0x10c)+_0x30a6e9,_0x19f98a=this[_0x9c787e(0x11a)];while(this[_0x9c787e(0xf3)]){try{this[_0x9c787e(0xc4)]=new AbortController();let _0x267b7e={'Accept':_0x9c787e(0x10a)};if(this[_0x9c787e(0xcf)])_0x267b7e[_0x9c787e(0x121)]=_0x9c787e(0x103)+this[_0x9c787e(0xcf)];let _0x334ecb=await fetch(_0x160668,{'headers':_0x267b7e,'signal':this[_0x9c787e(0xc4)][_0x9c787e(0x137)]});if(!_0x334ecb['ok']||!_0x334ecb[_0x9c787e(0xf2)]){this[_0x9c787e(0xfb)](_0x9c787e(0xcc)+_0x334ecb[_0x9c787e(0x11c)]),await this[_0x9c787e(0x119)](_0x19f98a),_0x19f98a=Math['min'](_0x19f98a*1.5,0xea60);continue;}_0x19f98a=this['reconnectDelay'];let _0x482c1e=_0x334ecb[_0x9c787e(0xf2)]['getReader'](),_0x10e4ca=new TextDecoder(),_0x37434d='';while(this[_0x9c787e(0xf3)]){let {done:_0x333c15,value:_0x3adc76}=await _0x482c1e[_0x9c787e(0x141)]();if(_0x333c15)break;_0x37434d+=_0x10e4ca[_0x9c787e(0xc8)](_0x3adc76,{'stream':!0x0});let _0x351cdb=_0x37434d[_0x9c787e(0xd5)]('\x0a');_0x37434d=_0x351cdb[_0x9c787e(0xed)]()||'';for(let _0x1e82df of _0x351cdb){if(!_0x1e82df['startsWith'](_0x9c787e(0x128)))continue;try{let _0x3c5fef=JSON[_0x9c787e(0x115)](_0x1e82df['slice'](0x6));if(_0x3c5fef[_0x9c787e(0x13f)]===_0x9c787e(0xd2)){this[_0x9c787e(0xfb)](_0x9c787e(0xee)),this['emit'](_0x9c787e(0xd2));continue;}if(_0x3c5fef[_0x9c787e(0x13f)]===_0x9c787e(0x12a)||_0x3c5fef[_0x9c787e(0x13f)]===_0x9c787e(0xe7)||_0x3c5fef[_0x9c787e(0x13f)]===_0x9c787e(0x12c))await this[_0x9c787e(0xf9)]();}catch{}}}}catch(_0xd053a4){if(_0xd053a4[_0x9c787e(0xf8)]===_0x9c787e(0xc9))break;this['emit'](_0x9c787e(0xdd),_0xd053a4),this['log']('SSE\x20error:\x20'+_0xd053a4[_0x9c787e(0x10d)]);}if(this[_0x9c787e(0xf3)])this[_0x9c787e(0x12e)]('disconnected'),this['log'](_0x9c787e(0x144)+_0x19f98a/0x3e8+_0x9c787e(0xd9)),await this[_0x9c787e(0x119)](_0x19f98a),_0x19f98a=Math['min'](_0x19f98a*1.5,0xea60);}}async[a0_0xb2e5e2(0xf9)](){const _0x3afe75=a0_0xb2e5e2;try{let _0x39eddd=(await this[_0x3afe75(0xc3)]('get_inbox',{'alias':this[_0x3afe75(0xd7)],'limit':0xa}))?.[_0x3afe75(0xf0)]||[];for(let _0x2b9585 of _0x39eddd)await this[_0x3afe75(0xc3)](_0x3afe75(0xfe),{'alias':this[_0x3afe75(0xd7)],'message_id':_0x2b9585['id']}),this[_0x3afe75(0xfb)]('←\x20'+_0x2b9585[_0x3afe75(0x114)]+':\x20'+_0x2b9585[_0x3afe75(0x130)][_0x3afe75(0xf7)](0x0,0x3c)),this[_0x3afe75(0x12e)](_0x3afe75(0xff),_0x2b9585),this[_0x3afe75(0x12e)]('message',_0x2b9585);}catch(_0x4e602a){this[_0x3afe75(0xfb)](_0x3afe75(0x11f)+_0x4e602a[_0x3afe75(0x10d)]);}}[a0_0xb2e5e2(0x119)](_0x27cedf){return new Promise(_0x45ae85=>setTimeout(_0x45ae85,_0x27cedf));}}var F=$;export{F as default,$ as CommHub};function a0_0x4dbd(){const _0x58cb86=['text','not_tracked','split','sending','alias','96580hlsQNc','s...','get_all_status','sdk-','toTimeString','error','failed','completed','send','\x20transport=','task.ack','toAlias','send_reply','match','tools/call','new_message','task.expired','connect','to_alias','connectSSE','620506GeWzsa','pop','SSE\x20connected','report_status','messages','error_code','body','running','<unknown>','heartbeat\x20failed:\x20','parentTaskId','slice','name','processInbox','networkId','log','1569138fqZNem','208485GoXHFp','ack_inbox','task','message_id','237438DLLlhx','replace','Bearer\x20','json','disconnect','mcp_http','task.started','task_id',']\x20[commhub:','text/event-stream','/mcp','/events/','message','\x20parent_task_id=','application/json','autoConnect','stringify','2.0','lifecycle_tracking','from_session','parse','\x20from=','toString','agent','sleep','reconnectDelay','now','status','CommHub\x20rejected\x20task','lifecycleTracking','inbox\x20error:\x20','registered','Authorization','idle','task.send.failed','1932RfuNky','string','catch','send_task','data:\x20','task.send.start','new_task','resumeId','broadcast','url','emit','\x20duration_ms=','content','POST','72107KHCJTz','heartbeatInterval','cwd','<missing>','CommHub\x20response\x20omitted\x20task_id','signal','delivered','16tJpVbn','task.send.delivered','network_id','6GAYbgm','heartbeatTimer','disconnected','type','send_failed','read','send_message','fromAlias','SSE\x20reconnecting\x20in\x20','\x20error=','result','\x20network_id=','call','sseAbort','\x20task_id=','server','reply','decode','AbortError','152YGjpJU','\x20lifecycle=','SSE\x20failed:\x20','10kDIYgd','application/json,\x20text/event-stream','token','offline','3021545qSLiqU','connected'];a0_0x4dbd=function(){return _0x58cb86;};return a0_0x4dbd();}