@sleep2agi/agent-network 2.3.0-preview.82 → 2.3.0-preview.84
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_0x29f126=a0_0x34e9;(function(_0x2edd31,_0x3edbad){const _0x530453=a0_0x34e9,_0x2238f9=_0x2edd31();while(!![]){try{const _0xd0670f=-parseInt(_0x530453(0x19e))/0x1+-parseInt(_0x530453(0x12a))/0x2+parseInt(_0x530453(0x164))/0x3*(parseInt(_0x530453(0x149))/0x4)+-parseInt(_0x530453(0x15f))/0x5+parseInt(_0x530453(0x186))/0x6+parseInt(_0x530453(0x166))/0x7+-parseInt(_0x530453(0x134))/0x8*(-parseInt(_0x530453(0x181))/0x9);if(_0xd0670f===_0x3edbad)break;else _0x2238f9['push'](_0x2238f9['shift']());}catch(_0x4019ce){_0x2238f9['push'](_0x2238f9['shift']());}}}(a0_0x4737,0x7fa2e));import{EventEmitter as a0_0x418b76}from'events';import{hostname as a0_0x15eb1f}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x2f1a52,_0x3add02)=>(_0x2f1a52??_0x3add02)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x29f126(0x150)](0x0,0xf0);function N(_0x408edb){const _0xddbf65=a0_0x29f126;return(_0x408edb instanceof Error?_0x408edb[_0xddbf65(0x12e)]:String(_0x408edb??_0xddbf65(0x12b)))[_0xddbf65(0x16b)](K,_0xddbf65(0x17d))[_0xddbf65(0x16b)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0xddbf65(0x150)](0x0,0xf0);}function O(_0x3649b5,_0x4e0b5e=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x52a383=a0_0x29f126;if(_0x4e0b5e)return JSON[_0x52a383(0x192)](_0x3649b5);let _0x1a91d5=L(_0x3649b5['parent_task_id'],_0x52a383(0x14d)),_0x1b4627=L(_0x3649b5['task_id'],'<pending>'),_0x503639=_0x3649b5[_0x52a383(0x18e)]?_0x52a383(0x142)+_0x3649b5[_0x52a383(0x18e)]+':'+(_0x3649b5['error_message']??''):'';return _0x52a383(0x167)+_0x3649b5[_0x52a383(0x138)]+_0x52a383(0x14f)+L(_0x3649b5[_0x52a383(0x13f)],_0x52a383(0x193))+'\x20to='+L(_0x3649b5[_0x52a383(0x136)],_0x52a383(0x193))+_0x52a383(0x169)+_0x1b4627+'\x20parent_task_id='+_0x1a91d5+_0x52a383(0x19f)+L(_0x3649b5[_0x52a383(0x12d)],_0x52a383(0x193))+_0x52a383(0x176)+_0x3649b5[_0x52a383(0x158)]+_0x52a383(0x12f)+_0x3649b5[_0x52a383(0x190)]+_0x52a383(0x129)+_0x3649b5[_0x52a383(0x148)]+_0x503639;}function a0_0x34e9(_0x18d25e,_0x372e60){_0x18d25e=_0x18d25e-0x127;const _0x4737d3=a0_0x4737();let _0x34e975=_0x4737d3[_0x18d25e];return _0x34e975;}function U(_0x2e0d18){const _0x122d7a=a0_0x29f126;return{'event':{'sending':'task.send.start','delivered':'task.send.delivered','failed':_0x122d7a(0x161),'acked':'task.ack','started':_0x122d7a(0x199),'replied':'task.replied','expired':_0x122d7a(0x19c)}[_0x2e0d18[_0x122d7a(0x138)]],..._0x2e0d18};}function j(_0x52013c){const _0xcf9d9d=a0_0x29f126;let _0x50aa21=_0x52013c?.[_0xcf9d9d(0x184)]||_0x52013c?.[_0xcf9d9d(0x139)]||_0x52013c?.['id'];if(_0x50aa21)return String(_0x50aa21);let _0x4457a5=_0x52013c?.['content']?.[0x0]?.['text'];if(typeof _0x4457a5!==_0xcf9d9d(0x18a))return null;try{let _0x52960a=JSON[_0xcf9d9d(0x151)](_0x4457a5);return _0x52960a?.[_0xcf9d9d(0x184)]||_0x52960a?.[_0xcf9d9d(0x139)]||_0x52960a?.['id']||null;}catch{return null;}}async function X(_0x321ecc,_0x3d85fd){const _0x86bfc7=a0_0x29f126;let _0x1a8723=_0x3d85fd[_0x86bfc7(0x175)]??Date[_0x86bfc7(0x175)],_0x1153cf=_0x1a8723(),_0x3381e1=(_0xc9488,_0x33fe97,_0x4d53eb,_0x2b5c4a)=>{const _0x1443a3=_0x86bfc7;_0x3d85fd[_0x1443a3(0x191)](O(U({'from_alias':_0x321ecc[_0x1443a3(0x141)],'to_alias':_0x321ecc[_0x1443a3(0x16f)],'task_id':_0x33fe97,'parent_task_id':_0x321ecc[_0x1443a3(0x17a)],'network_id':_0x321ecc[_0x1443a3(0x17c)],'transport':_0x321ecc[_0x1443a3(0x158)],'status':_0xc9488,'duration_ms':_0x1a8723()-_0x1153cf,'lifecycle_tracking':_0x321ecc[_0x1443a3(0x163)],..._0x4d53eb!==void 0x0?{'error_code':_0x2b5c4a||_0x1443a3(0x16e),'error_message':N(_0x4d53eb)}:{}})));};_0x3381e1(_0x86bfc7(0x1a2),null);try{let _0x18baa1=await _0x3d85fd[_0x86bfc7(0x18c)](),_0x572365=j(_0x18baa1);if(_0x572365)_0x3381e1('delivered',_0x572365);else{if(_0x18baa1?.['ok']===!0x1||_0x18baa1?.['error'])_0x3381e1(_0x86bfc7(0x1a4),_0x572365,_0x18baa1?.[_0x86bfc7(0x173)]||_0x86bfc7(0x180),_0x86bfc7(0x168));else _0x3381e1(_0x86bfc7(0x1a4),null,'CommHub\x20response\x20omitted\x20task_id',_0x86bfc7(0x17e));}return _0x18baa1;}catch(_0x3ddc59){throw _0x3381e1('failed',null,_0x3ddc59,'send_failed'),_0x3ddc59;}}async function Y(_0x4c43f6,_0x48148b){const _0x34e701=a0_0x29f126;return X({'fromAlias':_0x4c43f6['fromAlias'],'toAlias':_0x4c43f6[_0x34e701(0x140)],'parentTaskId':_0x4c43f6['parentTaskId']||null,'networkId':_0x4c43f6[_0x34e701(0x17c)]||null,'transport':_0x34e701(0x17b),'lifecycleTracking':_0x34e701(0x196)},_0x48148b);}class $ extends a0_0x418b76{[a0_0x29f126(0x188)];['alias'];[a0_0x29f126(0x147)];[a0_0x29f126(0x16c)];['resumeId'];[a0_0x29f126(0x177)];['reconnectDelay'];[a0_0x29f126(0x152)];[a0_0x29f126(0x146)];[a0_0x29f126(0x171)]=!0x1;constructor(_0x5b1c00){const _0x6031ef=a0_0x29f126;super();if(this[_0x6031ef(0x188)]=_0x5b1c00[_0x6031ef(0x188)][_0x6031ef(0x16b)](/\/$/,''),this[_0x6031ef(0x140)]=_0x5b1c00[_0x6031ef(0x140)],this[_0x6031ef(0x147)]=_0x5b1c00[_0x6031ef(0x147)],this[_0x6031ef(0x16c)]=_0x5b1c00[_0x6031ef(0x16c)]||'sdk',this[_0x6031ef(0x16d)]=_0x6031ef(0x162)+_0x5b1c00[_0x6031ef(0x140)]+'-'+Date[_0x6031ef(0x175)]()[_0x6031ef(0x165)](0x24),this[_0x6031ef(0x177)]=_0x5b1c00[_0x6031ef(0x177)]??0x2bf20,this[_0x6031ef(0x194)]=_0x5b1c00['reconnectDelay']??0xbb8,_0x5b1c00[_0x6031ef(0x137)]!==!0x1)this[_0x6031ef(0x18f)]();}[a0_0x29f126(0x191)](_0x27af90){const _0xa230ef=a0_0x29f126;console[_0xa230ef(0x191)]('['+new Date()[_0xa230ef(0x19b)]()[_0xa230ef(0x150)](0x0,0x8)+']\x20[commhub:'+this[_0xa230ef(0x140)]+']\x20'+_0x27af90);}async[a0_0x29f126(0x13d)](_0x35d0ba,_0x284248){const _0x339ecd=a0_0x29f126;let _0x4af711={'Content-Type':_0x339ecd(0x14e),'Accept':_0x339ecd(0x14b)};if(this[_0x339ecd(0x147)])_0x4af711[_0x339ecd(0x17f)]='Bearer\x20'+this['token'];let _0x2c473f=await(await fetch(this[_0x339ecd(0x188)]+'/mcp',{'method':_0x339ecd(0x1a3),'headers':_0x4af711,'body':JSON[_0x339ecd(0x192)]({'jsonrpc':'2.0','id':Date[_0x339ecd(0x175)](),'method':_0x339ecd(0x172),'params':{'name':_0x35d0ba,'arguments':_0x284248}})}))[_0x339ecd(0x144)](),_0x1ffc3f=_0x2c473f['match'](/data: (.+)/),_0x3c5931=_0x1ffc3f?JSON['parse'](_0x1ffc3f[0x1]):JSON['parse'](_0x2c473f),_0x46a3ef=_0x3c5931?.[_0x339ecd(0x178)]?.[_0x339ecd(0x1a0)]?.[0x0]?.['text'];return _0x46a3ef?JSON[_0x339ecd(0x151)](_0x46a3ef):_0x3c5931;}async[a0_0x29f126(0x18f)](){const _0x24cd69=a0_0x29f126;if(this[_0x24cd69(0x171)])return;this[_0x24cd69(0x171)]=!0x0,await this[_0x24cd69(0x138)]('idle'),this[_0x24cd69(0x191)](_0x24cd69(0x19d)),this['heartbeatTimer']=setInterval(()=>{const _0x31d166=_0x24cd69;this['status'](_0x31d166(0x18d))[_0x31d166(0x174)](_0x36f631=>this['log'](_0x31d166(0x130)+_0x36f631['message']));},this[_0x24cd69(0x177)]),this['connectSSE']();}async[a0_0x29f126(0x13c)](){const _0x483bfa=a0_0x29f126;if(this['running']=!0x1,this['sseAbort']?.[_0x483bfa(0x179)](),this[_0x483bfa(0x152)])clearInterval(this[_0x483bfa(0x152)]);await this['status'](_0x483bfa(0x156))[_0x483bfa(0x174)](()=>{}),this[_0x483bfa(0x191)](_0x483bfa(0x132));}async['send'](_0x127076,_0x3c1878,_0x10e09a=a0_0x29f126(0x15d)){const _0x118d39=a0_0x29f126;return Y({'alias':_0x127076,'fromAlias':this['alias']},{'log':_0x395d1d=>console[_0x118d39(0x191)](_0x395d1d),'send':()=>this[_0x118d39(0x13d)]('send_task',{'alias':_0x127076,'task':_0x3c1878,'priority':_0x10e09a,'from_session':this['alias']})});}async[a0_0x29f126(0x12e)](_0x3150fa,_0x611914){const _0x56c6dc=a0_0x29f126;return this['call'](_0x56c6dc(0x145),{'alias':_0x3150fa,'message':_0x611914,'from_session':this[_0x56c6dc(0x140)]});}async[a0_0x29f126(0x157)](_0x42e93a,_0x6e0706,_0x101522=a0_0x29f126(0x127)){const _0x11c19a=a0_0x29f126;return this[_0x11c19a(0x13d)](_0x11c19a(0x15c),{'in_reply_to':_0x42e93a,'text':_0x6e0706,'status':_0x101522});}async['status'](_0x4134e1,_0x51dd61){const _0x4767f3=a0_0x29f126;return this[_0x4767f3(0x13d)](_0x4767f3(0x189),{'resume_id':this[_0x4767f3(0x16d)],'alias':this['alias'],'status':_0x4134e1,'server':a0_0x15eb1f(),'hostname':a0_0x15eb1f(),'agent':this['agent'],'project_dir':process[_0x4767f3(0x15e)](),..._0x51dd61});}async[a0_0x29f126(0x135)](){const _0x4d0c52=a0_0x29f126;return this['call'](_0x4d0c52(0x198),{});}async[a0_0x29f126(0x195)](_0x5f5469,_0x140a67){const _0x4d0883=a0_0x29f126;return this[_0x4d0883(0x13d)]('broadcast',{'message':_0x5f5469,'filter_server':_0x140a67?.[_0x4d0883(0x155)],'filter_status':_0x140a67?.[_0x4d0883(0x138)]});}async[a0_0x29f126(0x13a)](){const _0x55403a=a0_0x29f126;let _0x29c701=encodeURIComponent(this[_0x55403a(0x140)]),_0x3db97c=this[_0x55403a(0x188)]+'/events/'+_0x29c701,_0x4192fc=this[_0x55403a(0x194)];while(this[_0x55403a(0x171)]){try{this[_0x55403a(0x146)]=new AbortController();let _0x4fe140={'Accept':_0x55403a(0x19a)};if(this['token'])_0x4fe140[_0x55403a(0x17f)]=_0x55403a(0x159)+this[_0x55403a(0x147)];let _0x476140=await fetch(_0x3db97c,{'headers':_0x4fe140,'signal':this[_0x55403a(0x146)]['signal']});if(!_0x476140['ok']||!_0x476140['body']){this[_0x55403a(0x191)](_0x55403a(0x160)+_0x476140[_0x55403a(0x138)]),await this['sleep'](_0x4192fc),_0x4192fc=Math[_0x55403a(0x18b)](_0x4192fc*1.5,0xea60);continue;}_0x4192fc=this['reconnectDelay'];let _0x4ca200=_0x476140[_0x55403a(0x14a)][_0x55403a(0x185)](),_0x17d07f=new TextDecoder(),_0x3533d4='';while(this[_0x55403a(0x171)]){let {done:_0x15388,value:_0x19c201}=await _0x4ca200[_0x55403a(0x183)]();if(_0x15388)break;_0x3533d4+=_0x17d07f[_0x55403a(0x15b)](_0x19c201,{'stream':!0x0});let _0x3045ed=_0x3533d4['split']('\x0a');_0x3533d4=_0x3045ed[_0x55403a(0x12c)]()||'';for(let _0x4a6ffc of _0x3045ed){if(!_0x4a6ffc[_0x55403a(0x153)](_0x55403a(0x133)))continue;try{let _0x1cb426=JSON[_0x55403a(0x151)](_0x4a6ffc[_0x55403a(0x150)](0x6));if(_0x1cb426[_0x55403a(0x15a)]===_0x55403a(0x128)){this[_0x55403a(0x191)](_0x55403a(0x187)),this['emit']('connected');continue;}if(_0x1cb426[_0x55403a(0x15a)]==='new_task'||_0x1cb426[_0x55403a(0x15a)]===_0x55403a(0x16a)||_0x1cb426['type']===_0x55403a(0x195))await this[_0x55403a(0x154)]();}catch{}}}}catch(_0xfbb8b8){if(_0xfbb8b8[_0x55403a(0x13e)]===_0x55403a(0x131))break;this[_0x55403a(0x14c)](_0x55403a(0x173),_0xfbb8b8),this['log']('SSE\x20error:\x20'+_0xfbb8b8['message']);}if(this[_0x55403a(0x171)])this[_0x55403a(0x14c)](_0x55403a(0x132)),this[_0x55403a(0x191)]('SSE\x20reconnecting\x20in\x20'+_0x4192fc/0x3e8+'s...'),await this['sleep'](_0x4192fc),_0x4192fc=Math['min'](_0x4192fc*1.5,0xea60);}}async[a0_0x29f126(0x154)](){const _0x566498=a0_0x29f126;try{let _0x3a8907=(await this[_0x566498(0x13d)]('get_inbox',{'alias':this[_0x566498(0x140)],'limit':0xa}))?.[_0x566498(0x143)]||[];for(let _0x4796ff of _0x3a8907)await this[_0x566498(0x13d)](_0x566498(0x197),{'alias':this[_0x566498(0x140)],'message_id':_0x4796ff['id']}),this[_0x566498(0x191)]('←\x20'+_0x4796ff[_0x566498(0x170)]+':\x20'+_0x4796ff['content'][_0x566498(0x150)](0x0,0x3c)),this[_0x566498(0x14c)](_0x566498(0x13b),_0x4796ff),this[_0x566498(0x14c)](_0x566498(0x12e),_0x4796ff);}catch(_0x56811a){this[_0x566498(0x191)](_0x566498(0x182)+_0x56811a[_0x566498(0x12e)]);}}[a0_0x29f126(0x1a1)](_0x40d6fe){return new Promise(_0x32f374=>setTimeout(_0x32f374,_0x40d6fe));}}var F=$;function a0_0x4737(){const _0x51afd6=['connect','duration_ms','log','stringify','<unknown>','reconnectDelay','broadcast','not_tracked','ack_inbox','get_all_status','task.started','text/event-stream','toTimeString','task.expired','registered','892867QZZlki','\x20network_id=','content','sleep','sending','POST','failed','completed','connected','\x20lifecycle=','1427852LSjUxl','unknown\x20error','pop','network_id','message','\x20duration_ms=','heartbeat\x20failed:\x20','AbortError','disconnected','data:\x20','704008JFPDkd','getAllStatus','to_alias','autoConnect','status','message_id','connectSSE','task','disconnect','call','name','from_alias','alias','fromAlias','\x20error=','messages','text','send_message','sseAbort','token','lifecycle_tracking','62488YvCjis','body','application/json,\x20text/event-stream','emit','<missing>','application/json','\x20from=','slice','parse','heartbeatTimer','startsWith','processInbox','server','offline','reply','transport','Bearer\x20','type','decode','send_reply','normal','cwd','1544935kXKaXI','SSE\x20failed:\x20','task.send.failed','sdk-','lifecycleTracking','105eHDECL','toString','6008737Bohunl','[commhub:task]\x20','send_rejected','\x20task_id=','new_message','replace','agent','resumeId','send_failed','toAlias','from_session','running','tools/call','error','catch','now','\x20transport=','heartbeatInterval','result','abort','parentTaskId','mcp_http','networkId','[REDACTED]','missing_task_id','Authorization','CommHub\x20rejected\x20task','72nnYkzL','inbox\x20error:\x20','read','task_id','getReader','1976454DfmNsl','SSE\x20connected','url','report_status','string','min','send','idle','error_code'];a0_0x4737=function(){return _0x51afd6;};return a0_0x4737();}export{F as default,$ as CommHub};
|
|
1
|
+
const a0_0x15bd20=a0_0x3cb6;function a0_0x3ad2(){const _0x405a37=['sleep','catch','split','disconnected','ack_inbox','autoConnect','SSE\x20reconnecting\x20in\x20','application/json,\x20text/event-stream','getReader','6024mzffrY','sdk','replace','agent','2472480drvGfd','task.expired','completed','parse','read','error','data:\x20','connect','AbortError','json','call','body','signal','status','247453ozvjED','toTimeString','message','error_message','SSE\x20connected','[REDACTED]','parentTaskId','resumeId','connectSSE','result','[commhub:task]\x20','2021136kQjLZn','send_message','text','tools/call','pop','delivered','failed','processInbox','now','abort','70erYiwl','fromAlias','idle','sdk-','\x20parent_task_id=','send_reply','alias','2161215VQtsqc','url','lifecycle_tracking','report_status','get_inbox','Bearer\x20','task_id','server','connected','3558294TRpfUE','messages','token','duration_ms','match','s...','normal','task.replied','emit','<unknown>','SSE\x20failed:\x20','task.started','heartbeatTimer','heartbeatInterval','1400wGGYAA','CommHub\x20rejected\x20task','text/event-stream','\x20transport=','transport','broadcast','offline','content','new_message','/mcp','Authorization','getAllStatus','error_code','from_session','SSE\x20error:\x20','mcp_http','reply','send','task.ack','\x20error=','stringify','log','heartbeat\x20failed:\x20','network_id','type','reconnectDelay','string','\x20lifecycle=','task.send.failed','min','CommHub\x20response\x20omitted\x20task_id','missing_task_id','networkId','/events/','18949DVrCAi','task.send.start','568NTOxcY','sending','parent_task_id','sseAbort','from_alias','lifecycleTracking','slice','message_id','send_task','running','name'];a0_0x3ad2=function(){return _0x405a37;};return a0_0x3ad2();}(function(_0x50d42f,_0x5d178a){const _0x5955f6=a0_0x3cb6,_0x457a84=_0x50d42f();while(!![]){try{const _0x2f739e=parseInt(_0x5955f6(0x14e))/0x1+parseInt(_0x5955f6(0x128))/0x2*(-parseInt(_0x5955f6(0x13c))/0x3)+parseInt(_0x5955f6(0x159))/0x4+-parseInt(_0x5955f6(0x140))/0x5+-parseInt(_0x5955f6(0x173))/0x6+-parseInt(_0x5955f6(0x126))/0x7*(parseInt(_0x5955f6(0x104))/0x8)+-parseInt(_0x5955f6(0x16a))/0x9*(-parseInt(_0x5955f6(0x163))/0xa);if(_0x2f739e===_0x5d178a)break;else _0x457a84['push'](_0x457a84['shift']());}catch(_0x2f4e00){_0x457a84['push'](_0x457a84['shift']());}}}(a0_0x3ad2,0x49c3c));import{EventEmitter as a0_0x4f10b9}from'events';import{hostname as a0_0x80af53}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0xdd41c8,_0x2758d6)=>(_0xdd41c8??_0x2758d6)[a0_0x15bd20(0x13e)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x5ef197){const _0xec042d=a0_0x15bd20;return(_0x5ef197 instanceof Error?_0x5ef197[_0xec042d(0x150)]:String(_0x5ef197??'unknown\x20error'))[_0xec042d(0x13e)](K,_0xec042d(0x153))[_0xec042d(0x13e)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0xec042d(0x12e)](0x0,0xf0);}function O(_0x50a0ce,_0x39afa9=process.env.ANET_TASK_TRACE_FORMAT===a0_0x15bd20(0x149)){const _0x3b6b66=a0_0x15bd20;if(_0x39afa9)return JSON[_0x3b6b66(0x118)](_0x50a0ce);let _0x333eec=L(_0x50a0ce[_0x3b6b66(0x12a)],'<missing>'),_0x24a3f9=L(_0x50a0ce[_0x3b6b66(0x170)],'<pending>'),_0x39b78e=_0x50a0ce[_0x3b6b66(0x110)]?_0x3b6b66(0x117)+_0x50a0ce[_0x3b6b66(0x110)]+':'+(_0x50a0ce[_0x3b6b66(0x151)]??''):'';return _0x3b6b66(0x158)+_0x50a0ce[_0x3b6b66(0x14d)]+'\x20from='+L(_0x50a0ce[_0x3b6b66(0x12c)],_0x3b6b66(0x17c))+'\x20to='+L(_0x50a0ce['to_alias'],_0x3b6b66(0x17c))+'\x20task_id='+_0x24a3f9+_0x3b6b66(0x167)+_0x333eec+'\x20network_id='+L(_0x50a0ce[_0x3b6b66(0x11b)],'<unknown>')+_0x3b6b66(0x107)+_0x50a0ce[_0x3b6b66(0x108)]+'\x20duration_ms='+_0x50a0ce[_0x3b6b66(0x176)]+_0x3b6b66(0x11f)+_0x50a0ce[_0x3b6b66(0x16c)]+_0x39b78e;}function U(_0x3e98fb){const _0x5305c8=a0_0x15bd20;return{'event':{'sending':_0x5305c8(0x127),'delivered':'task.send.delivered','failed':_0x5305c8(0x120),'acked':_0x5305c8(0x116),'started':_0x5305c8(0x17e),'replied':_0x5305c8(0x17a),'expired':_0x5305c8(0x141)}[_0x3e98fb[_0x5305c8(0x14d)]],..._0x3e98fb};}function j(_0x17038f){const _0x471cb8=a0_0x15bd20;let _0x284c56=_0x17038f?.['task_id']||_0x17038f?.[_0x471cb8(0x12f)]||_0x17038f?.['id'];if(_0x284c56)return String(_0x284c56);let _0x10ae6e=_0x17038f?.[_0x471cb8(0x10b)]?.[0x0]?.[_0x471cb8(0x15b)];if(typeof _0x10ae6e!==_0x471cb8(0x11e))return null;try{let _0x646598=JSON[_0x471cb8(0x143)](_0x10ae6e);return _0x646598?.[_0x471cb8(0x170)]||_0x646598?.['message_id']||_0x646598?.['id']||null;}catch{return null;}}function a0_0x3cb6(_0x38c418,_0x1b1c2a){_0x38c418=_0x38c418-0x102;const _0x3ad273=a0_0x3ad2();let _0x3cb640=_0x3ad273[_0x38c418];return _0x3cb640;}async function X(_0x4a2c88,_0x32d6a3){const _0x326e6f=a0_0x15bd20;let _0x47ac18=_0x32d6a3[_0x326e6f(0x161)]??Date[_0x326e6f(0x161)],_0x28a878=_0x47ac18(),_0x246e1c=(_0x3a19a2,_0x317e71,_0x48e82c,_0x3992bc)=>{const _0x581ea3=_0x326e6f;_0x32d6a3[_0x581ea3(0x119)](O(U({'from_alias':_0x4a2c88[_0x581ea3(0x164)],'to_alias':_0x4a2c88['toAlias'],'task_id':_0x317e71,'parent_task_id':_0x4a2c88[_0x581ea3(0x154)],'network_id':_0x4a2c88[_0x581ea3(0x124)],'transport':_0x4a2c88[_0x581ea3(0x108)],'status':_0x3a19a2,'duration_ms':_0x47ac18()-_0x28a878,'lifecycle_tracking':_0x4a2c88[_0x581ea3(0x12d)],..._0x48e82c!==void 0x0?{'error_code':_0x3992bc||'send_failed','error_message':N(_0x48e82c)}:{}})));};_0x246e1c(_0x326e6f(0x129),null);try{let _0x24e866=await _0x32d6a3[_0x326e6f(0x115)](),_0x57de23=j(_0x24e866);if(_0x57de23)_0x246e1c(_0x326e6f(0x15e),_0x57de23);else{if(_0x24e866?.['ok']===!0x1||_0x24e866?.['error'])_0x246e1c(_0x326e6f(0x15f),_0x57de23,_0x24e866?.['error']||_0x326e6f(0x105),'send_rejected');else _0x246e1c(_0x326e6f(0x15f),null,_0x326e6f(0x122),_0x326e6f(0x123));}return _0x24e866;}catch(_0x43d4f9){throw _0x246e1c(_0x326e6f(0x15f),null,_0x43d4f9,'send_failed'),_0x43d4f9;}}async function Y(_0x3b406a,_0xed9581){const _0x1deec6=a0_0x15bd20;return X({'fromAlias':_0x3b406a['fromAlias'],'toAlias':_0x3b406a[_0x1deec6(0x169)],'parentTaskId':_0x3b406a[_0x1deec6(0x154)]||null,'networkId':_0x3b406a[_0x1deec6(0x124)]||null,'transport':_0x1deec6(0x113),'lifecycleTracking':'not_tracked'},_0xed9581);}class $ extends a0_0x4f10b9{[a0_0x15bd20(0x16b)];[a0_0x15bd20(0x169)];[a0_0x15bd20(0x175)];[a0_0x15bd20(0x13f)];['resumeId'];[a0_0x15bd20(0x103)];[a0_0x15bd20(0x11d)];[a0_0x15bd20(0x102)];[a0_0x15bd20(0x12b)];[a0_0x15bd20(0x131)]=!0x1;constructor(_0x3114d5){const _0x1117b5=a0_0x15bd20;super();if(this[_0x1117b5(0x16b)]=_0x3114d5[_0x1117b5(0x16b)]['replace'](/\/$/,''),this['alias']=_0x3114d5['alias'],this['token']=_0x3114d5['token'],this[_0x1117b5(0x13f)]=_0x3114d5['agent']||_0x1117b5(0x13d),this[_0x1117b5(0x155)]=_0x1117b5(0x166)+_0x3114d5[_0x1117b5(0x169)]+'-'+Date['now']()['toString'](0x24),this['heartbeatInterval']=_0x3114d5[_0x1117b5(0x103)]??0x2bf20,this[_0x1117b5(0x11d)]=_0x3114d5[_0x1117b5(0x11d)]??0xbb8,_0x3114d5[_0x1117b5(0x138)]!==!0x1)this[_0x1117b5(0x147)]();}[a0_0x15bd20(0x119)](_0x4952ba){const _0x1b5600=a0_0x15bd20;console[_0x1b5600(0x119)]('['+new Date()[_0x1b5600(0x14f)]()[_0x1b5600(0x12e)](0x0,0x8)+']\x20[commhub:'+this[_0x1b5600(0x169)]+']\x20'+_0x4952ba);}async[a0_0x15bd20(0x14a)](_0xddd2a6,_0x47279f){const _0x4987ea=a0_0x15bd20;let _0x4eefca={'Content-Type':'application/json','Accept':_0x4987ea(0x13a)};if(this[_0x4987ea(0x175)])_0x4eefca[_0x4987ea(0x10e)]=_0x4987ea(0x16f)+this[_0x4987ea(0x175)];let _0x290bc8=await(await fetch(this['url']+_0x4987ea(0x10d),{'method':'POST','headers':_0x4eefca,'body':JSON[_0x4987ea(0x118)]({'jsonrpc':'2.0','id':Date['now'](),'method':_0x4987ea(0x15c),'params':{'name':_0xddd2a6,'arguments':_0x47279f}})}))[_0x4987ea(0x15b)](),_0x49bbc1=_0x290bc8[_0x4987ea(0x177)](/data: (.+)/),_0x24c232=_0x49bbc1?JSON['parse'](_0x49bbc1[0x1]):JSON[_0x4987ea(0x143)](_0x290bc8),_0x3b971d=_0x24c232?.[_0x4987ea(0x157)]?.[_0x4987ea(0x10b)]?.[0x0]?.[_0x4987ea(0x15b)];return _0x3b971d?JSON['parse'](_0x3b971d):_0x24c232;}async[a0_0x15bd20(0x147)](){const _0x3745d8=a0_0x15bd20;if(this['running'])return;this[_0x3745d8(0x131)]=!0x0,await this[_0x3745d8(0x14d)]('idle'),this['log']('registered'),this['heartbeatTimer']=setInterval(()=>{const _0x444a9e=_0x3745d8;this['status'](_0x444a9e(0x165))[_0x444a9e(0x134)](_0x3eb8b3=>this[_0x444a9e(0x119)](_0x444a9e(0x11a)+_0x3eb8b3[_0x444a9e(0x150)]));},this[_0x3745d8(0x103)]),this['connectSSE']();}async['disconnect'](){const _0x251f41=a0_0x15bd20;if(this[_0x251f41(0x131)]=!0x1,this[_0x251f41(0x12b)]?.[_0x251f41(0x162)](),this[_0x251f41(0x102)])clearInterval(this[_0x251f41(0x102)]);await this['status'](_0x251f41(0x10a))[_0x251f41(0x134)](()=>{}),this[_0x251f41(0x119)](_0x251f41(0x136));}async[a0_0x15bd20(0x115)](_0x40bf11,_0x4de05f,_0x37a9ae=a0_0x15bd20(0x179)){const _0x2474b7=a0_0x15bd20;return Y({'alias':_0x40bf11,'fromAlias':this['alias']},{'log':_0x4a7f3a=>console[_0x2474b7(0x119)](_0x4a7f3a),'send':()=>this['call'](_0x2474b7(0x130),{'alias':_0x40bf11,'task':_0x4de05f,'priority':_0x37a9ae,'from_session':this['alias']})});}async['message'](_0x484074,_0x347b4c){const _0x2fd41e=a0_0x15bd20;return this[_0x2fd41e(0x14a)](_0x2fd41e(0x15a),{'alias':_0x484074,'message':_0x347b4c,'from_session':this[_0x2fd41e(0x169)]});}async[a0_0x15bd20(0x114)](_0x68cf12,_0x15cc73,_0x45dbef=a0_0x15bd20(0x142)){const _0x5b8819=a0_0x15bd20;return this[_0x5b8819(0x14a)](_0x5b8819(0x168),{'in_reply_to':_0x68cf12,'text':_0x15cc73,'status':_0x45dbef});}async[a0_0x15bd20(0x14d)](_0x27de75,_0x1c30ca){const _0x4ba2a6=a0_0x15bd20;return this[_0x4ba2a6(0x14a)](_0x4ba2a6(0x16d),{'resume_id':this[_0x4ba2a6(0x155)],'alias':this[_0x4ba2a6(0x169)],'status':_0x27de75,'server':a0_0x80af53(),'hostname':a0_0x80af53(),'agent':this[_0x4ba2a6(0x13f)],'project_dir':process['cwd'](),..._0x1c30ca});}async[a0_0x15bd20(0x10f)](){return this['call']('get_all_status',{});}async[a0_0x15bd20(0x109)](_0x82bbc3,_0x13f10f){const _0x15f3f5=a0_0x15bd20;return this['call'](_0x15f3f5(0x109),{'message':_0x82bbc3,'filter_server':_0x13f10f?.[_0x15f3f5(0x171)],'filter_status':_0x13f10f?.[_0x15f3f5(0x14d)]});}async[a0_0x15bd20(0x156)](){const _0x584c84=a0_0x15bd20;let _0x2efed4=encodeURIComponent(this[_0x584c84(0x169)]),_0x31c4b7=this[_0x584c84(0x16b)]+_0x584c84(0x125)+_0x2efed4,_0x12e1af=this[_0x584c84(0x11d)];while(this['running']){try{this[_0x584c84(0x12b)]=new AbortController();let _0x2ff8a8={'Accept':_0x584c84(0x106)};if(this['token'])_0x2ff8a8[_0x584c84(0x10e)]='Bearer\x20'+this[_0x584c84(0x175)];let _0x4ddcb4=await fetch(_0x31c4b7,{'headers':_0x2ff8a8,'signal':this[_0x584c84(0x12b)][_0x584c84(0x14c)]});if(!_0x4ddcb4['ok']||!_0x4ddcb4[_0x584c84(0x14b)]){this[_0x584c84(0x119)](_0x584c84(0x17d)+_0x4ddcb4[_0x584c84(0x14d)]),await this[_0x584c84(0x133)](_0x12e1af),_0x12e1af=Math[_0x584c84(0x121)](_0x12e1af*1.5,0xea60);continue;}_0x12e1af=this[_0x584c84(0x11d)];let _0x1fa1b2=_0x4ddcb4['body'][_0x584c84(0x13b)](),_0x928abf=new TextDecoder(),_0x51db6d='';while(this['running']){let {done:_0x25997f,value:_0x537aa7}=await _0x1fa1b2[_0x584c84(0x144)]();if(_0x25997f)break;_0x51db6d+=_0x928abf['decode'](_0x537aa7,{'stream':!0x0});let _0x12c507=_0x51db6d[_0x584c84(0x135)]('\x0a');_0x51db6d=_0x12c507[_0x584c84(0x15d)]()||'';for(let _0x2b981b of _0x12c507){if(!_0x2b981b['startsWith'](_0x584c84(0x146)))continue;try{let _0xace0a9=JSON[_0x584c84(0x143)](_0x2b981b['slice'](0x6));if(_0xace0a9[_0x584c84(0x11c)]===_0x584c84(0x172)){this[_0x584c84(0x119)](_0x584c84(0x152)),this[_0x584c84(0x17b)](_0x584c84(0x172));continue;}if(_0xace0a9['type']==='new_task'||_0xace0a9[_0x584c84(0x11c)]===_0x584c84(0x10c)||_0xace0a9[_0x584c84(0x11c)]===_0x584c84(0x109))await this[_0x584c84(0x160)]();}catch{}}}}catch(_0x10d739){if(_0x10d739[_0x584c84(0x132)]===_0x584c84(0x148))break;this['emit'](_0x584c84(0x145),_0x10d739),this[_0x584c84(0x119)](_0x584c84(0x112)+_0x10d739[_0x584c84(0x150)]);}if(this['running'])this[_0x584c84(0x17b)](_0x584c84(0x136)),this[_0x584c84(0x119)](_0x584c84(0x139)+_0x12e1af/0x3e8+_0x584c84(0x178)),await this[_0x584c84(0x133)](_0x12e1af),_0x12e1af=Math['min'](_0x12e1af*1.5,0xea60);}}async[a0_0x15bd20(0x160)](){const _0x1b293e=a0_0x15bd20;try{let _0x2bb7e=(await this[_0x1b293e(0x14a)](_0x1b293e(0x16e),{'alias':this['alias'],'limit':0xa}))?.[_0x1b293e(0x174)]||[];for(let _0xca6131 of _0x2bb7e)await this[_0x1b293e(0x14a)](_0x1b293e(0x137),{'alias':this[_0x1b293e(0x169)],'message_id':_0xca6131['id']}),this['log']('←\x20'+_0xca6131[_0x1b293e(0x111)]+':\x20'+_0xca6131[_0x1b293e(0x10b)][_0x1b293e(0x12e)](0x0,0x3c)),this[_0x1b293e(0x17b)]('task',_0xca6131),this[_0x1b293e(0x17b)]('message',_0xca6131);}catch(_0x550330){this[_0x1b293e(0x119)]('inbox\x20error:\x20'+_0x550330[_0x1b293e(0x150)]);}}['sleep'](_0x455b64){return new Promise(_0xe736c7=>setTimeout(_0xe736c7,_0x455b64));}}var F=$;export{F as default,$ as CommHub};
|