@sleep2agi/agent-network 2.3.0-preview.171 → 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.
package/dist/src/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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();}
|
|
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();}
|