@sleep2agi/agent-network 2.3.0-preview.170 → 2.3.0-preview.171
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.
package/dist/src/client.js
CHANGED
|
@@ -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_0x52d491=a0_0x2cf6;(function(_0x3284a3,_0x53ef11){const _0x4454e5=a0_0x2cf6,_0x14518c=_0x3284a3();while(!![]){try{const _0x4d4ac9=-parseInt(_0x4454e5(0x127))/0x1*(-parseInt(_0x4454e5(0x112))/0x2)+parseInt(_0x4454e5(0x10f))/0x3+parseInt(_0x4454e5(0xf7))/0x4*(parseInt(_0x4454e5(0x162))/0x5)+-parseInt(_0x4454e5(0x168))/0x6+-parseInt(_0x4454e5(0x10b))/0x7*(parseInt(_0x4454e5(0xee))/0x8)+parseInt(_0x4454e5(0x142))/0x9*(parseInt(_0x4454e5(0x151))/0xa)+-parseInt(_0x4454e5(0x10c))/0xb*(parseInt(_0x4454e5(0x133))/0xc);if(_0x4d4ac9===_0x53ef11)break;else _0x14518c['push'](_0x14518c['shift']());}catch(_0x28236c){_0x14518c['push'](_0x14518c['shift']());}}}(a0_0x558c,0xb4d79));import{EventEmitter as a0_0x18db8f}from'events';import{hostname as a0_0x3e54e0}from'os';function a0_0x2cf6(_0x564b64,_0x5ab298){_0x564b64=_0x564b64-0xeb;const _0x558c14=a0_0x558c();let _0x2cf6de=_0x558c14[_0x564b64];return _0x2cf6de;}var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x11ee03,_0xea5819)=>(_0x11ee03??_0xea5819)[a0_0x52d491(0x13c)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x52d491(0xfc)](0x0,0xf0);function N(_0x5aa8ed){const _0x58392e=a0_0x52d491;return(_0x5aa8ed instanceof Error?_0x5aa8ed['message']:String(_0x5aa8ed??'unknown\x20error'))[_0x58392e(0x13c)](K,'[REDACTED]')[_0x58392e(0x13c)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x58392e(0xfc)](0x0,0xf0);}function O(_0x3692bc,_0x2a42b9=process.env.ANET_TASK_TRACE_FORMAT===a0_0x52d491(0x101)){const _0x22764e=a0_0x52d491;if(_0x2a42b9)return JSON[_0x22764e(0x153)](_0x3692bc);let _0x1f21f4=L(_0x3692bc[_0x22764e(0x139)],_0x22764e(0x102)),_0x5218c4=L(_0x3692bc['task_id'],_0x22764e(0x154)),_0x3e27a2=_0x3692bc['error_code']?_0x22764e(0x161)+_0x3692bc[_0x22764e(0xf5)]+':'+(_0x3692bc['error_message']??''):'';return _0x22764e(0x159)+_0x3692bc[_0x22764e(0x167)]+_0x22764e(0x11a)+L(_0x3692bc[_0x22764e(0x12f)],_0x22764e(0x122))+'\x20to='+L(_0x3692bc[_0x22764e(0x111)],_0x22764e(0x122))+'\x20task_id='+_0x5218c4+_0x22764e(0x13a)+_0x1f21f4+_0x22764e(0x109)+L(_0x3692bc[_0x22764e(0x15a)],_0x22764e(0x122))+'\x20transport='+_0x3692bc[_0x22764e(0x118)]+_0x22764e(0x143)+_0x3692bc['duration_ms']+_0x22764e(0x126)+_0x3692bc[_0x22764e(0x128)]+_0x3e27a2;}function U(_0x314c9e){const _0xe89760=a0_0x52d491;return{'event':{'sending':_0xe89760(0x15f),'delivered':_0xe89760(0xf3),'failed':_0xe89760(0x10e),'acked':'task.ack','started':_0xe89760(0x136),'replied':_0xe89760(0x131),'expired':_0xe89760(0x157)}[_0x314c9e['status']],..._0x314c9e};}function j(_0x3190a3){const _0x2a5b6b=a0_0x52d491;let _0x196d9b=_0x3190a3?.[_0x2a5b6b(0x125)]||_0x3190a3?.[_0x2a5b6b(0x14d)]||_0x3190a3?.['id'];if(_0x196d9b)return String(_0x196d9b);let _0x4ed064=_0x3190a3?.[_0x2a5b6b(0x147)]?.[0x0]?.['text'];if(typeof _0x4ed064!==_0x2a5b6b(0x107))return null;try{let _0x34e566=JSON[_0x2a5b6b(0x152)](_0x4ed064);return _0x34e566?.[_0x2a5b6b(0x125)]||_0x34e566?.['message_id']||_0x34e566?.['id']||null;}catch{return null;}}async function X(_0x6f5617,_0x507e61){const _0x1d6798=a0_0x52d491;let _0x317e8f=_0x507e61[_0x1d6798(0x129)]??Date[_0x1d6798(0x129)],_0x5f0194=_0x317e8f(),_0xf1c6b8=(_0x5f55e5,_0x485ec9,_0x347354,_0x3e31f9)=>{const _0x5e8dc4=_0x1d6798;_0x507e61[_0x5e8dc4(0x140)](O(U({'from_alias':_0x6f5617['fromAlias'],'to_alias':_0x6f5617[_0x5e8dc4(0xff)],'task_id':_0x485ec9,'parent_task_id':_0x6f5617[_0x5e8dc4(0x11c)],'network_id':_0x6f5617[_0x5e8dc4(0x146)],'transport':_0x6f5617['transport'],'status':_0x5f55e5,'duration_ms':_0x317e8f()-_0x5f0194,'lifecycle_tracking':_0x6f5617[_0x5e8dc4(0x13b)],..._0x347354!==void 0x0?{'error_code':_0x3e31f9||_0x5e8dc4(0xf1),'error_message':N(_0x347354)}:{}})));};_0xf1c6b8(_0x1d6798(0x15d),null);try{let _0x24617f=await _0x507e61[_0x1d6798(0xfb)](),_0x577914=j(_0x24617f);if(_0x577914)_0xf1c6b8(_0x1d6798(0x166),_0x577914);else{if(_0x24617f?.['ok']===!0x1||_0x24617f?.[_0x1d6798(0xf2)])_0xf1c6b8('failed',_0x577914,_0x24617f?.[_0x1d6798(0xf2)]||_0x1d6798(0x135),'send_rejected');else _0xf1c6b8('failed',null,_0x1d6798(0xf8),_0x1d6798(0x123));}return _0x24617f;}catch(_0x46bdfc){throw _0xf1c6b8(_0x1d6798(0x114),null,_0x46bdfc,_0x1d6798(0xf1)),_0x46bdfc;}}async function Y(_0x388e25,_0x3b63b6){const _0x27c0ab=a0_0x52d491;return X({'fromAlias':_0x388e25[_0x27c0ab(0x145)],'toAlias':_0x388e25[_0x27c0ab(0x10a)],'parentTaskId':_0x388e25['parentTaskId']||null,'networkId':_0x388e25[_0x27c0ab(0x146)]||null,'transport':_0x27c0ab(0x105),'lifecycleTracking':'not_tracked'},_0x3b63b6);}class $ extends a0_0x18db8f{[a0_0x52d491(0x117)];[a0_0x52d491(0x10a)];[a0_0x52d491(0x104)];[a0_0x52d491(0x15b)];['resumeId'];['heartbeatInterval'];[a0_0x52d491(0x12e)];[a0_0x52d491(0x15c)];[a0_0x52d491(0x16c)];['running']=!0x1;constructor(_0xfe4e8b){const _0x352e26=a0_0x52d491;super();if(this[_0x352e26(0x117)]=_0xfe4e8b['url']['replace'](/\/$/,''),this['alias']=_0xfe4e8b['alias'],this[_0x352e26(0x104)]=_0xfe4e8b[_0x352e26(0x104)],this[_0x352e26(0x15b)]=_0xfe4e8b[_0x352e26(0x15b)]||_0x352e26(0x13d),this[_0x352e26(0x121)]=_0x352e26(0x110)+_0xfe4e8b['alias']+'-'+Date['now']()[_0x352e26(0x11f)](0x24),this[_0x352e26(0x11b)]=_0xfe4e8b[_0x352e26(0x11b)]??0x2bf20,this[_0x352e26(0x12e)]=_0xfe4e8b[_0x352e26(0x12e)]??0xbb8,_0xfe4e8b[_0x352e26(0xeb)]!==!0x1)this[_0x352e26(0x169)]();}[a0_0x52d491(0x140)](_0x48c0e1){const _0x2e14b8=a0_0x52d491;console[_0x2e14b8(0x140)]('['+new Date()['toTimeString']()[_0x2e14b8(0xfc)](0x0,0x8)+']\x20[commhub:'+this[_0x2e14b8(0x10a)]+']\x20'+_0x48c0e1);}async['call'](_0x47b172,_0x5d39ed){const _0x2373bb=a0_0x52d491;let _0xf3894c={'Content-Type':_0x2373bb(0x137),'Accept':_0x2373bb(0x134)};if(this[_0x2373bb(0x104)])_0xf3894c[_0x2373bb(0x163)]=_0x2373bb(0xef)+this[_0x2373bb(0x104)];let _0x2f7e2=await(await fetch(this['url']+_0x2373bb(0x156),{'method':'POST','headers':_0xf3894c,'body':JSON[_0x2373bb(0x153)]({'jsonrpc':_0x2373bb(0x165),'id':Date[_0x2373bb(0x129)](),'method':_0x2373bb(0x130),'params':{'name':_0x47b172,'arguments':_0x5d39ed}})}))['text'](),_0x11408d=_0x2f7e2['match'](/data: (.+)/),_0x365733=_0x11408d?JSON[_0x2373bb(0x152)](_0x11408d[0x1]):JSON[_0x2373bb(0x152)](_0x2f7e2),_0x4a6ee0=_0x365733?.[_0x2373bb(0x13e)]?.[_0x2373bb(0x147)]?.[0x0]?.[_0x2373bb(0x14b)];return _0x4a6ee0?JSON[_0x2373bb(0x152)](_0x4a6ee0):_0x365733;}async[a0_0x52d491(0x169)](){const _0x43e199=a0_0x52d491;if(this[_0x43e199(0x160)])return;this[_0x43e199(0x160)]=!0x0,await this[_0x43e199(0x167)]('idle'),this[_0x43e199(0x140)](_0x43e199(0xed)),this[_0x43e199(0x15c)]=setInterval(()=>{const _0x1b0db2=_0x43e199;this[_0x1b0db2(0x167)](_0x1b0db2(0x11d))[_0x1b0db2(0xfa)](_0x26e8c3=>this[_0x1b0db2(0x140)]('heartbeat\x20failed:\x20'+_0x26e8c3[_0x1b0db2(0x155)]));},this['heartbeatInterval']),this[_0x43e199(0xf6)]();}async[a0_0x52d491(0x113)](){const _0x9b4e3=a0_0x52d491;if(this['running']=!0x1,this[_0x9b4e3(0x16c)]?.[_0x9b4e3(0x144)](),this[_0x9b4e3(0x15c)])clearInterval(this['heartbeatTimer']);await this['status'](_0x9b4e3(0xf4))[_0x9b4e3(0xfa)](()=>{}),this[_0x9b4e3(0x140)](_0x9b4e3(0x164));}async[a0_0x52d491(0xfb)](_0x98f26f,_0x3eaf6c,_0x3d212b=a0_0x52d491(0x120)){const _0x289842=a0_0x52d491;return Y({'alias':_0x98f26f,'fromAlias':this[_0x289842(0x10a)]},{'log':_0x1475de=>console[_0x289842(0x140)](_0x1475de),'send':()=>this[_0x289842(0x14c)](_0x289842(0x12d),{'alias':_0x98f26f,'task':_0x3eaf6c,'priority':_0x3d212b,'from_session':this['alias']})});}async[a0_0x52d491(0x155)](_0x15bf55,_0x4d75ff){const _0x20eab4=a0_0x52d491;return this[_0x20eab4(0x14c)](_0x20eab4(0x150),{'alias':_0x15bf55,'message':_0x4d75ff,'from_session':this[_0x20eab4(0x10a)]});}async[a0_0x52d491(0xec)](_0x316bc3,_0x3a4fed,_0x2b67cc='completed'){const _0x5275f9=a0_0x52d491;return this[_0x5275f9(0x14c)](_0x5275f9(0x141),{'in_reply_to':_0x316bc3,'text':_0x3a4fed,'status':_0x2b67cc});}async['status'](_0x39903d,_0x1550b3){const _0x45e731=a0_0x52d491;return this[_0x45e731(0x14c)](_0x45e731(0x108),{'resume_id':this[_0x45e731(0x121)],'alias':this['alias'],'status':_0x39903d,'server':a0_0x3e54e0(),'hostname':a0_0x3e54e0(),'agent':this['agent'],'project_dir':process[_0x45e731(0x16a)](),..._0x1550b3});}async[a0_0x52d491(0x132)](){const _0x139872=a0_0x52d491;return this[_0x139872(0x14c)](_0x139872(0x106),{});}async[a0_0x52d491(0x12c)](_0x20f607,_0x23fff9){const _0xdf66b9=a0_0x52d491;return this[_0xdf66b9(0x14c)]('broadcast',{'message':_0x20f607,'filter_server':_0x23fff9?.['server'],'filter_status':_0x23fff9?.['status']});}async[a0_0x52d491(0xf6)](){const _0x2a0e21=a0_0x52d491;let _0x1ad12d=encodeURIComponent(this[_0x2a0e21(0x10a)]),_0x5d3d83=this[_0x2a0e21(0x117)]+'/events/'+_0x1ad12d,_0x46cfe5=this[_0x2a0e21(0x12e)];while(this[_0x2a0e21(0x160)]){try{this[_0x2a0e21(0x16c)]=new AbortController();let _0x52f479={'Accept':_0x2a0e21(0x12b)};if(this['token'])_0x52f479[_0x2a0e21(0x163)]='Bearer\x20'+this[_0x2a0e21(0x104)];let _0x5a92fb=await fetch(_0x5d3d83,{'headers':_0x52f479,'signal':this[_0x2a0e21(0x16c)][_0x2a0e21(0x149)]});if(!_0x5a92fb['ok']||!_0x5a92fb['body']){this['log'](_0x2a0e21(0x138)+_0x5a92fb['status']),await this[_0x2a0e21(0x14e)](_0x46cfe5),_0x46cfe5=Math[_0x2a0e21(0x14f)](_0x46cfe5*1.5,0xea60);continue;}_0x46cfe5=this['reconnectDelay'];let _0x47850e=_0x5a92fb[_0x2a0e21(0x115)]['getReader'](),_0x4830e7=new TextDecoder(),_0x588074='';while(this[_0x2a0e21(0x160)]){let {done:_0x24ac1d,value:_0xc24414}=await _0x47850e[_0x2a0e21(0x124)]();if(_0x24ac1d)break;_0x588074+=_0x4830e7[_0x2a0e21(0x158)](_0xc24414,{'stream':!0x0});let _0x38ea7e=_0x588074[_0x2a0e21(0x119)]('\x0a');_0x588074=_0x38ea7e['pop']()||'';for(let _0x46ddb8 of _0x38ea7e){if(!_0x46ddb8[_0x2a0e21(0x103)](_0x2a0e21(0x16d)))continue;try{let _0x217d32=JSON[_0x2a0e21(0x152)](_0x46ddb8[_0x2a0e21(0xfc)](0x6));if(_0x217d32[_0x2a0e21(0xf0)]===_0x2a0e21(0x11e)){this[_0x2a0e21(0x140)](_0x2a0e21(0x116)),this['emit'](_0x2a0e21(0x11e));continue;}if(_0x217d32[_0x2a0e21(0xf0)]===_0x2a0e21(0x12a)||_0x217d32['type']===_0x2a0e21(0x16e)||_0x217d32['type']===_0x2a0e21(0x12c))await this[_0x2a0e21(0x10d)]();}catch{}}}}catch(_0x57877f){if(_0x57877f['name']===_0x2a0e21(0x148))break;this['emit'](_0x2a0e21(0xf2),_0x57877f),this[_0x2a0e21(0x140)](_0x2a0e21(0xfd)+_0x57877f[_0x2a0e21(0x155)]);}if(this[_0x2a0e21(0x160)])this[_0x2a0e21(0xfe)]('disconnected'),this[_0x2a0e21(0x140)](_0x2a0e21(0x100)+_0x46cfe5/0x3e8+_0x2a0e21(0x15e)),await this[_0x2a0e21(0x14e)](_0x46cfe5),_0x46cfe5=Math[_0x2a0e21(0x14f)](_0x46cfe5*1.5,0xea60);}}async[a0_0x52d491(0x10d)](){const _0x59bc73=a0_0x52d491;try{let _0x353848=(await this[_0x59bc73(0x14c)](_0x59bc73(0x16b),{'alias':this[_0x59bc73(0x10a)],'limit':0xa}))?.[_0x59bc73(0x14a)]||[];for(let _0x5eccff of _0x353848)await this[_0x59bc73(0x14c)](_0x59bc73(0x13f),{'alias':this[_0x59bc73(0x10a)],'message_id':_0x5eccff['id']}),this['log']('←\x20'+_0x5eccff['from_session']+':\x20'+_0x5eccff[_0x59bc73(0x147)][_0x59bc73(0xfc)](0x0,0x3c)),this[_0x59bc73(0xfe)]('task',_0x5eccff),this[_0x59bc73(0xfe)](_0x59bc73(0x155),_0x5eccff);}catch(_0x54cecf){this[_0x59bc73(0x140)](_0x59bc73(0xf9)+_0x54cecf[_0x59bc73(0x155)]);}}[a0_0x52d491(0x14e)](_0x28804d){return new Promise(_0x48c1d6=>setTimeout(_0x48c1d6,_0x28804d));}}var F=$;export{F as default,$ as CommHub};function a0_0x558c(){const _0x1f9729=['task.replied','getAllStatus','67800zAjrVB','application/json,\x20text/event-stream','CommHub\x20rejected\x20task','task.started','application/json','SSE\x20failed:\x20','parent_task_id','\x20parent_task_id=','lifecycleTracking','replace','sdk','result','ack_inbox','log','send_reply','1047294RuYMzq','\x20duration_ms=','abort','fromAlias','networkId','content','AbortError','signal','messages','text','call','message_id','sleep','min','send_message','80ZSowZj','parse','stringify','<pending>','message','/mcp','task.expired','decode','[commhub:task]\x20','network_id','agent','heartbeatTimer','sending','s...','task.send.start','running','\x20error=','2253800lRdeFc','Authorization','disconnected','2.0','delivered','status','2623746iCBnpe','connect','cwd','get_inbox','sseAbort','data:\x20','new_message','autoConnect','reply','registered','408jwXwAz','Bearer\x20','type','send_failed','error','task.send.delivered','offline','error_code','connectSSE','8hsxIqD','CommHub\x20response\x20omitted\x20task_id','inbox\x20error:\x20','catch','send','slice','SSE\x20error:\x20','emit','toAlias','SSE\x20reconnecting\x20in\x20','json','<missing>','startsWith','token','mcp_http','get_all_status','string','report_status','\x20network_id=','alias','72107sZeNBJ','3883DaitZH','processInbox','task.send.failed','2191476YWcUPA','sdk-','to_alias','2ZUpgop','disconnect','failed','body','SSE\x20connected','url','transport','split','\x20from=','heartbeatInterval','parentTaskId','idle','connected','toString','normal','resumeId','<unknown>','missing_task_id','read','task_id','\x20lifecycle=','1134881ZiDkbn','lifecycle_tracking','now','new_task','text/event-stream','broadcast','send_task','reconnectDelay','from_alias','tools/call'];a0_0x558c=function(){return _0x1f9729;};return a0_0x558c();}
|