@sleep2agi/agent-network 2.3.0-preview.259 → 2.3.0-preview.260
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_0x3e5f43=a0_0x14ff;(function(_0x4d9432,_0x1c5295){const _0x11c428=a0_0x14ff,_0x3d0c09=_0x4d9432();while(!![]){try{const _0x143f32=parseInt(_0x11c428(0x13b))/0x1*(parseInt(_0x11c428(0x123))/0x2)+parseInt(_0x11c428(0xf4))/0x3*(-parseInt(_0x11c428(0xc7))/0x4)+-parseInt(_0x11c428(0xeb))/0x5+-parseInt(_0x11c428(0xfd))/0x6*(-parseInt(_0x11c428(0x135))/0x7)+-parseInt(_0x11c428(0x132))/0x8*(-parseInt(_0x11c428(0xcb))/0x9)+parseInt(_0x11c428(0xf0))/0xa*(parseInt(_0x11c428(0xc2))/0xb)+parseInt(_0x11c428(0x10a))/0xc*(parseInt(_0x11c428(0x102))/0xd);if(_0x143f32===_0x1c5295)break;else _0x3d0c09['push'](_0x3d0c09['shift']());}catch(_0x3806cc){_0x3d0c09['push'](_0x3d0c09['shift']());}}}(a0_0x5299,0xa9468));import{EventEmitter as a0_0x4f7293}from'events';import{hostname as a0_0x5f6fd4}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x896fe0,_0x1814ac)=>(_0x896fe0??_0x1814ac)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function a0_0x14ff(_0x376a7f,_0x389839){_0x376a7f=_0x376a7f-0xbc;const _0x529943=a0_0x5299();let _0x14ff2f=_0x529943[_0x376a7f];return _0x14ff2f;}function N(_0x390e19){const _0x8f092f=a0_0x14ff;return(_0x390e19 instanceof Error?_0x390e19['message']:String(_0x390e19??'unknown\x20error'))[_0x8f092f(0x137)](K,_0x8f092f(0x111))[_0x8f092f(0x137)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x8f092f(0x108)](0x0,0xf0);}function O(_0x4fca27,_0x5407bd=process.env.ANET_TASK_TRACE_FORMAT===a0_0x3e5f43(0x11c)){const _0x2658f9=a0_0x3e5f43;if(_0x5407bd)return JSON[_0x2658f9(0xfb)](_0x4fca27);let _0x4819a9=L(_0x4fca27[_0x2658f9(0x11d)],_0x2658f9(0xc4)),_0x1dad9a=L(_0x4fca27['task_id'],_0x2658f9(0x11e)),_0x35be97=_0x4fca27[_0x2658f9(0x122)]?_0x2658f9(0x13d)+_0x4fca27[_0x2658f9(0x122)]+':'+(_0x4fca27['error_message']??''):'';return'[commhub:task]\x20'+_0x4fca27[_0x2658f9(0x115)]+_0x2658f9(0x10f)+L(_0x4fca27[_0x2658f9(0xca)],_0x2658f9(0x13a))+_0x2658f9(0xee)+L(_0x4fca27['to_alias'],_0x2658f9(0x13a))+_0x2658f9(0xf2)+_0x1dad9a+_0x2658f9(0xd8)+_0x4819a9+_0x2658f9(0xd5)+L(_0x4fca27[_0x2658f9(0xfc)],'<unknown>')+_0x2658f9(0xf8)+_0x4fca27[_0x2658f9(0x117)]+'\x20duration_ms='+_0x4fca27[_0x2658f9(0x133)]+_0x2658f9(0x139)+_0x4fca27[_0x2658f9(0x118)]+_0x35be97;}function U(_0x247fb2){const _0x19405a=a0_0x3e5f43;return{'event':{'sending':'task.send.start','delivered':_0x19405a(0xea),'failed':_0x19405a(0x134),'acked':'task.ack','started':_0x19405a(0x106),'replied':'task.replied','expired':'task.expired'}[_0x247fb2['status']],..._0x247fb2};}function a0_0x5299(){const _0x4dae5e=['getReader','text/event-stream','SSE\x20reconnecting\x20in\x20','read','heartbeatInterval','/events/','application/json','1420914ZSOSeo','connectSSE','<missing>',']\x20[commhub:','sseAbort','1723276PAZNxS','cwd','sdk','from_alias','9cArfvd','Bearer\x20','text','agent','tools/call','report_status','get_inbox','running','min','POST','\x20network_id=','ack_inbox','alias','\x20parent_task_id=','catch','sleep','new_message','processInbox','content','/mcp','get_all_status','mcp_http','send_rejected','parentTaskId','SSE\x20error:\x20','Authorization','completed','result','reconnectDelay','heartbeatTimer','normal','task.send.delivered','6346030acdmRi','getAllStatus','delivered','\x20to=','inbox\x20error:\x20','40nVVHLp','send_task','\x20task_id=','message','3CovrBZ','application/json,\x20text/event-stream','toTimeString','message_id','\x20transport=','idle','toString','stringify','network_id','2544TjCGon','task_id','reply','error','networkId','7111bdTARB','offline','abort','failed','task.started','url','slice','now','12684DsWslL','SSE\x20failed:\x20','broadcast','CommHub\x20response\x20omitted\x20task_id','autoConnect','\x20from=','emit','[REDACTED]','data:\x20','disconnected','s...','status','heartbeat\x20failed:\x20','transport','lifecycle_tracking','token','send','CommHub\x20rejected\x20task','json','parent_task_id','<pending>','sending','call','task','error_code','1018084aDNkUW','send_failed','parse','connected','from_session','log','split','type','startsWith','name','server','connect','resumeId','SSE\x20connected','signal','1469968hoXCTS','duration_ms','task.send.failed','1596gOABkZ','disconnect','replace','body','\x20lifecycle=','<unknown>','2XoCkTU','AbortError','\x20error=','2.0','fromAlias'];a0_0x5299=function(){return _0x4dae5e;};return a0_0x5299();}function j(_0x1c7ea9){const _0x13d2f7=a0_0x3e5f43;let _0x21c2b7=_0x1c7ea9?.[_0x13d2f7(0xfe)]||_0x1c7ea9?.[_0x13d2f7(0xf7)]||_0x1c7ea9?.['id'];if(_0x21c2b7)return String(_0x21c2b7);let _0xa78f5d=_0x1c7ea9?.[_0x13d2f7(0xdd)]?.[0x0]?.['text'];if(typeof _0xa78f5d!=='string')return null;try{let _0x2358d4=JSON[_0x13d2f7(0x125)](_0xa78f5d);return _0x2358d4?.[_0x13d2f7(0xfe)]||_0x2358d4?.[_0x13d2f7(0xf7)]||_0x2358d4?.['id']||null;}catch{return null;}}async function X(_0x251b85,_0x45b665){const _0x5440a0=a0_0x3e5f43;let _0x231802=_0x45b665['now']??Date['now'],_0x46b525=_0x231802(),_0x4d818e=(_0x20a776,_0x198927,_0x254de2,_0x5fc457)=>{const _0x35ce5b=a0_0x14ff;_0x45b665['log'](O(U({'from_alias':_0x251b85[_0x35ce5b(0x13f)],'to_alias':_0x251b85['toAlias'],'task_id':_0x198927,'parent_task_id':_0x251b85[_0x35ce5b(0xe2)],'network_id':_0x251b85[_0x35ce5b(0x101)],'transport':_0x251b85['transport'],'status':_0x20a776,'duration_ms':_0x231802()-_0x46b525,'lifecycle_tracking':_0x251b85['lifecycleTracking'],..._0x254de2!==void 0x0?{'error_code':_0x5fc457||'send_failed','error_message':N(_0x254de2)}:{}})));};_0x4d818e(_0x5440a0(0x11f),null);try{let _0x32aaf5=await _0x45b665[_0x5440a0(0x11a)](),_0x5486e2=j(_0x32aaf5);if(_0x5486e2)_0x4d818e(_0x5440a0(0xed),_0x5486e2);else{if(_0x32aaf5?.['ok']===!0x1||_0x32aaf5?.[_0x5440a0(0x100)])_0x4d818e(_0x5440a0(0x105),_0x5486e2,_0x32aaf5?.[_0x5440a0(0x100)]||_0x5440a0(0x11b),_0x5440a0(0xe1));else _0x4d818e(_0x5440a0(0x105),null,_0x5440a0(0x10d),'missing_task_id');}return _0x32aaf5;}catch(_0x355026){throw _0x4d818e(_0x5440a0(0x105),null,_0x355026,_0x5440a0(0x124)),_0x355026;}}async function Y(_0x2be323,_0x2b5323){const _0x4deaa6=a0_0x3e5f43;return X({'fromAlias':_0x2be323[_0x4deaa6(0x13f)],'toAlias':_0x2be323[_0x4deaa6(0xd7)],'parentTaskId':_0x2be323['parentTaskId']||null,'networkId':_0x2be323['networkId']||null,'transport':_0x4deaa6(0xe0),'lifecycleTracking':'not_tracked'},_0x2b5323);}class $ extends a0_0x4f7293{[a0_0x3e5f43(0x107)];[a0_0x3e5f43(0xd7)];[a0_0x3e5f43(0x119)];['agent'];[a0_0x3e5f43(0x12f)];[a0_0x3e5f43(0xbf)];['reconnectDelay'];[a0_0x3e5f43(0xe8)];[a0_0x3e5f43(0xc6)];[a0_0x3e5f43(0xd2)]=!0x1;constructor(_0x2b641a){const _0x245cc1=a0_0x3e5f43;super();if(this[_0x245cc1(0x107)]=_0x2b641a[_0x245cc1(0x107)][_0x245cc1(0x137)](/\/$/,''),this[_0x245cc1(0xd7)]=_0x2b641a[_0x245cc1(0xd7)],this[_0x245cc1(0x119)]=_0x2b641a[_0x245cc1(0x119)],this[_0x245cc1(0xce)]=_0x2b641a[_0x245cc1(0xce)]||_0x245cc1(0xc9),this[_0x245cc1(0x12f)]='sdk-'+_0x2b641a[_0x245cc1(0xd7)]+'-'+Date[_0x245cc1(0x109)]()[_0x245cc1(0xfa)](0x24),this[_0x245cc1(0xbf)]=_0x2b641a[_0x245cc1(0xbf)]??0x2bf20,this['reconnectDelay']=_0x2b641a[_0x245cc1(0xe7)]??0xbb8,_0x2b641a[_0x245cc1(0x10e)]!==!0x1)this[_0x245cc1(0x12e)]();}[a0_0x3e5f43(0x128)](_0x4907ff){const _0x2e4086=a0_0x3e5f43;console[_0x2e4086(0x128)]('['+new Date()[_0x2e4086(0xf6)]()[_0x2e4086(0x108)](0x0,0x8)+_0x2e4086(0xc5)+this[_0x2e4086(0xd7)]+']\x20'+_0x4907ff);}async[a0_0x3e5f43(0x120)](_0xfc49fc,_0x18953f){const _0x47d0b1=a0_0x3e5f43;let _0x45c9dd={'Content-Type':_0x47d0b1(0xc1),'Accept':_0x47d0b1(0xf5)};if(this[_0x47d0b1(0x119)])_0x45c9dd[_0x47d0b1(0xe4)]=_0x47d0b1(0xcc)+this[_0x47d0b1(0x119)];let _0x3e6bdf=await(await fetch(this[_0x47d0b1(0x107)]+_0x47d0b1(0xde),{'method':_0x47d0b1(0xd4),'headers':_0x45c9dd,'body':JSON[_0x47d0b1(0xfb)]({'jsonrpc':_0x47d0b1(0x13e),'id':Date[_0x47d0b1(0x109)](),'method':_0x47d0b1(0xcf),'params':{'name':_0xfc49fc,'arguments':_0x18953f}})}))[_0x47d0b1(0xcd)](),_0x532011=_0x3e6bdf['match'](/data: (.+)/),_0x33bbb3=_0x532011?JSON[_0x47d0b1(0x125)](_0x532011[0x1]):JSON[_0x47d0b1(0x125)](_0x3e6bdf),_0xa8f90d=_0x33bbb3?.[_0x47d0b1(0xe6)]?.[_0x47d0b1(0xdd)]?.[0x0]?.[_0x47d0b1(0xcd)];return _0xa8f90d?JSON[_0x47d0b1(0x125)](_0xa8f90d):_0x33bbb3;}async['connect'](){const _0x333ff2=a0_0x3e5f43;if(this[_0x333ff2(0xd2)])return;this[_0x333ff2(0xd2)]=!0x0,await this[_0x333ff2(0x115)](_0x333ff2(0xf9)),this[_0x333ff2(0x128)]('registered'),this[_0x333ff2(0xe8)]=setInterval(()=>{const _0x12edbf=_0x333ff2;this['status']('idle')[_0x12edbf(0xd9)](_0x24625f=>this[_0x12edbf(0x128)](_0x12edbf(0x116)+_0x24625f[_0x12edbf(0xf3)]));},this[_0x333ff2(0xbf)]),this[_0x333ff2(0xc3)]();}async[a0_0x3e5f43(0x136)](){const _0x463b7d=a0_0x3e5f43;if(this[_0x463b7d(0xd2)]=!0x1,this['sseAbort']?.[_0x463b7d(0x104)](),this[_0x463b7d(0xe8)])clearInterval(this[_0x463b7d(0xe8)]);await this[_0x463b7d(0x115)](_0x463b7d(0x103))[_0x463b7d(0xd9)](()=>{}),this[_0x463b7d(0x128)](_0x463b7d(0x113));}async[a0_0x3e5f43(0x11a)](_0x3cedb2,_0x178bcf,_0xce2b8c=a0_0x3e5f43(0xe9)){const _0x31158a=a0_0x3e5f43;return Y({'alias':_0x3cedb2,'fromAlias':this[_0x31158a(0xd7)]},{'log':_0x5446d5=>console[_0x31158a(0x128)](_0x5446d5),'send':()=>this[_0x31158a(0x120)](_0x31158a(0xf1),{'alias':_0x3cedb2,'task':_0x178bcf,'priority':_0xce2b8c,'from_session':this[_0x31158a(0xd7)]})});}async['message'](_0x157294,_0x38c0d1){const _0x9348dd=a0_0x3e5f43;return this[_0x9348dd(0x120)]('send_message',{'alias':_0x157294,'message':_0x38c0d1,'from_session':this['alias']});}async[a0_0x3e5f43(0xff)](_0x2e721b,_0x16ace5,_0x9999f0=a0_0x3e5f43(0xe5)){return this['call']('send_reply',{'in_reply_to':_0x2e721b,'text':_0x16ace5,'status':_0x9999f0});}async[a0_0x3e5f43(0x115)](_0x240d3a,_0x582b80){const _0x34ec47=a0_0x3e5f43;return this[_0x34ec47(0x120)](_0x34ec47(0xd0),{'resume_id':this[_0x34ec47(0x12f)],'alias':this[_0x34ec47(0xd7)],'status':_0x240d3a,'server':a0_0x5f6fd4(),'hostname':a0_0x5f6fd4(),'agent':this[_0x34ec47(0xce)],'project_dir':process[_0x34ec47(0xc8)](),..._0x582b80});}async[a0_0x3e5f43(0xec)](){const _0x16c706=a0_0x3e5f43;return this['call'](_0x16c706(0xdf),{});}async[a0_0x3e5f43(0x10c)](_0x55acac,_0x2eb30a){const _0x3e3c23=a0_0x3e5f43;return this[_0x3e3c23(0x120)](_0x3e3c23(0x10c),{'message':_0x55acac,'filter_server':_0x2eb30a?.[_0x3e3c23(0x12d)],'filter_status':_0x2eb30a?.[_0x3e3c23(0x115)]});}async[a0_0x3e5f43(0xc3)](){const _0x32968e=a0_0x3e5f43;let _0x471fef=encodeURIComponent(this[_0x32968e(0xd7)]),_0x36a88d=this[_0x32968e(0x107)]+_0x32968e(0xc0)+_0x471fef,_0x54a9d7=this[_0x32968e(0xe7)];while(this[_0x32968e(0xd2)]){try{this[_0x32968e(0xc6)]=new AbortController();let _0x4797fb={'Accept':_0x32968e(0xbc)};if(this['token'])_0x4797fb[_0x32968e(0xe4)]=_0x32968e(0xcc)+this[_0x32968e(0x119)];let _0x43795a=await fetch(_0x36a88d,{'headers':_0x4797fb,'signal':this['sseAbort'][_0x32968e(0x131)]});if(!_0x43795a['ok']||!_0x43795a[_0x32968e(0x138)]){this['log'](_0x32968e(0x10b)+_0x43795a[_0x32968e(0x115)]),await this[_0x32968e(0xda)](_0x54a9d7),_0x54a9d7=Math[_0x32968e(0xd3)](_0x54a9d7*1.5,0xea60);continue;}_0x54a9d7=this[_0x32968e(0xe7)];let _0x3ca409=_0x43795a[_0x32968e(0x138)][_0x32968e(0x140)](),_0x375005=new TextDecoder(),_0x1f2a1c='';while(this['running']){let {done:_0xa0b0c3,value:_0x1a9c1a}=await _0x3ca409[_0x32968e(0xbe)]();if(_0xa0b0c3)break;_0x1f2a1c+=_0x375005['decode'](_0x1a9c1a,{'stream':!0x0});let _0x3927d8=_0x1f2a1c[_0x32968e(0x129)]('\x0a');_0x1f2a1c=_0x3927d8['pop']()||'';for(let _0x43c2d6 of _0x3927d8){if(!_0x43c2d6[_0x32968e(0x12b)](_0x32968e(0x112)))continue;try{let _0x296453=JSON[_0x32968e(0x125)](_0x43c2d6['slice'](0x6));if(_0x296453[_0x32968e(0x12a)]==='connected'){this[_0x32968e(0x128)](_0x32968e(0x130)),this[_0x32968e(0x110)](_0x32968e(0x126));continue;}if(_0x296453[_0x32968e(0x12a)]==='new_task'||_0x296453[_0x32968e(0x12a)]===_0x32968e(0xdb)||_0x296453['type']==='broadcast')await this[_0x32968e(0xdc)]();}catch{}}}}catch(_0x38e791){if(_0x38e791[_0x32968e(0x12c)]===_0x32968e(0x13c))break;this[_0x32968e(0x110)](_0x32968e(0x100),_0x38e791),this[_0x32968e(0x128)](_0x32968e(0xe3)+_0x38e791[_0x32968e(0xf3)]);}if(this[_0x32968e(0xd2)])this[_0x32968e(0x110)](_0x32968e(0x113)),this[_0x32968e(0x128)](_0x32968e(0xbd)+_0x54a9d7/0x3e8+_0x32968e(0x114)),await this[_0x32968e(0xda)](_0x54a9d7),_0x54a9d7=Math[_0x32968e(0xd3)](_0x54a9d7*1.5,0xea60);}}async[a0_0x3e5f43(0xdc)](){const _0x5cc14f=a0_0x3e5f43;try{let _0x5530be=(await this[_0x5cc14f(0x120)](_0x5cc14f(0xd1),{'alias':this[_0x5cc14f(0xd7)],'limit':0xa}))?.['messages']||[];for(let _0x4a2aaf of _0x5530be)await this[_0x5cc14f(0x120)](_0x5cc14f(0xd6),{'alias':this[_0x5cc14f(0xd7)],'message_id':_0x4a2aaf['id']}),this[_0x5cc14f(0x128)]('←\x20'+_0x4a2aaf[_0x5cc14f(0x127)]+':\x20'+_0x4a2aaf[_0x5cc14f(0xdd)][_0x5cc14f(0x108)](0x0,0x3c)),this[_0x5cc14f(0x110)](_0x5cc14f(0x121),_0x4a2aaf),this[_0x5cc14f(0x110)]('message',_0x4a2aaf);}catch(_0x2a6684){this['log'](_0x5cc14f(0xef)+_0x2a6684['message']);}}[a0_0x3e5f43(0xda)](_0x58740a){return new Promise(_0x260b99=>setTimeout(_0x260b99,_0x58740a));}}var F=$;export{F as default,$ as CommHub};
|
|
1
|
+
const a0_0xab4448=a0_0x1aed;(function(_0x43b5f1,_0x1af34a){const _0x4c591f=a0_0x1aed,_0x1b2827=_0x43b5f1();while(!![]){try{const _0x7e33f9=-parseInt(_0x4c591f(0x8d))/0x1*(parseInt(_0x4c591f(0x7a))/0x2)+parseInt(_0x4c591f(0xe7))/0x3*(-parseInt(_0x4c591f(0xb9))/0x4)+-parseInt(_0x4c591f(0xe6))/0x5*(-parseInt(_0x4c591f(0x7f))/0x6)+-parseInt(_0x4c591f(0xbf))/0x7+-parseInt(_0x4c591f(0xa8))/0x8+parseInt(_0x4c591f(0x89))/0x9+parseInt(_0x4c591f(0x83))/0xa;if(_0x7e33f9===_0x1af34a)break;else _0x1b2827['push'](_0x1b2827['shift']());}catch(_0x3415dd){_0x1b2827['push'](_0x1b2827['shift']());}}}(a0_0xa732,0x32364));import{EventEmitter as a0_0x3a62ab}from'events';function a0_0xa732(){const _0x460382=['string','status','completed','toString','duration_ms','parse','min','2.0','AbortError','\x20error=','sleep','error_message','\x20network_id=','toTimeString','SSE\x20error:\x20','disconnect','connectSSE','autoConnect','7538hNDDEm','abort','task.send.delivered','registered','\x20transport=','30WBSgMR','transport','token','idle','9865800EqstHD',']\x20[commhub:','<missing>','getReader','\x20task_id=','network_id','53199IKbgJv','emit','result','/events/','75BTXcSZ','alias','call','new_task','task.replied','read','connected','pop','error_code','reply','CommHub\x20rejected\x20task','task.send.failed','send','stringify','content','normal','task.expired','error','heartbeatInterval','now','fromAlias','decode','task_id','<unknown>','toAlias','catch','ack_inbox','2270760gTLSdz','send_failed','lifecycleTracking','failed','connect','to_alias','task.started','sdk-','application/json','heartbeat\x20failed:\x20','task','lifecycle_tracking','data:\x20','new_message','networkId','get_all_status','heartbeatTimer','1454028ttMhnp','name','url','send_message','parent_task_id','slice','1724212GgOhcg','Authorization','resumeId','server','SSE\x20connected','<pending>','getAllStatus','sseAbort','SSE\x20reconnecting\x20in\x20','disconnected','/mcp','agent','message','startsWith','task.ack','not_tracked','parentTaskId','s...','Bearer\x20','sending','log','application/json,\x20text/event-stream','text/event-stream','task.send.start','\x20to=','report_status','reconnectDelay','messages','text','CommHub\x20response\x20omitted\x20task_id','type','broadcast','mcp_http','json','POST','\x20parent_task_id=','cwd','match','signal','389520diSaPs','3FHIsET','processInbox','replace','body','running','message_id'];a0_0xa732=function(){return _0x460382;};return a0_0xa732();}import{hostname as a0_0x42060f}from'os';function a0_0x1aed(_0x45ab30,_0x849047){_0x45ab30=_0x45ab30-0x75;const _0xa7325=a0_0xa732();let _0x1aed96=_0xa7325[_0x45ab30];return _0x1aed96;}var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x52392b,_0x3de9b7)=>(_0x52392b??_0x3de9b7)[a0_0xab4448(0xe9)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0xab4448(0xbe)](0x0,0xf0);function N(_0x5a57e7){const _0x1cae56=a0_0xab4448;return(_0x5a57e7 instanceof Error?_0x5a57e7[_0x1cae56(0xcb)]:String(_0x5a57e7??'unknown\x20error'))['replace'](K,'[REDACTED]')[_0x1cae56(0xe9)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x471aee,_0x542af3=process.env.ANET_TASK_TRACE_FORMAT===a0_0xab4448(0xe0)){const _0x3662f8=a0_0xab4448;if(_0x542af3)return JSON[_0x3662f8(0x9a)](_0x471aee);let _0x422d17=L(_0x471aee[_0x3662f8(0xbd)],_0x3662f8(0x85)),_0x5340d2=L(_0x471aee[_0x3662f8(0xa3)],_0x3662f8(0xc4)),_0x804a8c=_0x471aee[_0x3662f8(0x95)]?_0x3662f8(0xf6)+_0x471aee[_0x3662f8(0x95)]+':'+(_0x471aee[_0x3662f8(0xf8)]??''):'';return'[commhub:task]\x20'+_0x471aee[_0x3662f8(0xee)]+'\x20from='+L(_0x471aee['from_alias'],'<unknown>')+_0x3662f8(0xd7)+L(_0x471aee[_0x3662f8(0xad)],_0x3662f8(0xa4))+_0x3662f8(0x87)+_0x5340d2+_0x3662f8(0xe2)+_0x422d17+_0x3662f8(0xf9)+L(_0x471aee[_0x3662f8(0x88)],_0x3662f8(0xa4))+_0x3662f8(0x7e)+_0x471aee[_0x3662f8(0x80)]+'\x20duration_ms='+_0x471aee[_0x3662f8(0xf1)]+'\x20lifecycle='+_0x471aee[_0x3662f8(0xb3)]+_0x804a8c;}function U(_0x4dbf40){const _0x2b9fbf=a0_0xab4448;return{'event':{'sending':_0x2b9fbf(0xd6),'delivered':_0x2b9fbf(0x7c),'failed':_0x2b9fbf(0x98),'acked':_0x2b9fbf(0xcd),'started':_0x2b9fbf(0xae),'replied':_0x2b9fbf(0x91),'expired':_0x2b9fbf(0x9d)}[_0x4dbf40['status']],..._0x4dbf40};}function j(_0x4dee29){const _0x420c02=a0_0xab4448;let _0x31f042=_0x4dee29?.['task_id']||_0x4dee29?.[_0x420c02(0xec)]||_0x4dee29?.['id'];if(_0x31f042)return String(_0x31f042);let _0x2ffd91=_0x4dee29?.[_0x420c02(0x9b)]?.[0x0]?.[_0x420c02(0xdb)];if(typeof _0x2ffd91!==_0x420c02(0xed))return null;try{let _0x2db2fc=JSON['parse'](_0x2ffd91);return _0x2db2fc?.[_0x420c02(0xa3)]||_0x2db2fc?.[_0x420c02(0xec)]||_0x2db2fc?.['id']||null;}catch{return null;}}async function X(_0x47e289,_0x2754a4){const _0x56397e=a0_0xab4448;let _0x359091=_0x2754a4[_0x56397e(0xa0)]??Date[_0x56397e(0xa0)],_0x161b1a=_0x359091(),_0x3a4fd0=(_0x4f9e69,_0x57da79,_0x1e1837,_0x56f20b)=>{const _0x57c581=_0x56397e;_0x2754a4[_0x57c581(0xd3)](O(U({'from_alias':_0x47e289['fromAlias'],'to_alias':_0x47e289[_0x57c581(0xa5)],'task_id':_0x57da79,'parent_task_id':_0x47e289[_0x57c581(0xcf)],'network_id':_0x47e289[_0x57c581(0xb6)],'transport':_0x47e289[_0x57c581(0x80)],'status':_0x4f9e69,'duration_ms':_0x359091()-_0x161b1a,'lifecycle_tracking':_0x47e289[_0x57c581(0xaa)],..._0x1e1837!==void 0x0?{'error_code':_0x56f20b||_0x57c581(0xa9),'error_message':N(_0x1e1837)}:{}})));};_0x3a4fd0(_0x56397e(0xd2),null);try{let _0x54fa53=await _0x2754a4[_0x56397e(0x99)](),_0x392583=j(_0x54fa53);if(_0x392583)_0x3a4fd0('delivered',_0x392583);else{if(_0x54fa53?.['ok']===!0x1||_0x54fa53?.[_0x56397e(0x9e)])_0x3a4fd0(_0x56397e(0xab),_0x392583,_0x54fa53?.[_0x56397e(0x9e)]||_0x56397e(0x97),'send_rejected');else _0x3a4fd0(_0x56397e(0xab),null,_0x56397e(0xdc),'missing_task_id');}return _0x54fa53;}catch(_0x18646b){throw _0x3a4fd0(_0x56397e(0xab),null,_0x18646b,_0x56397e(0xa9)),_0x18646b;}}async function Y(_0x3be266,_0x3ea00a){const _0x3bd008=a0_0xab4448;return X({'fromAlias':_0x3be266[_0x3bd008(0xa1)],'toAlias':_0x3be266[_0x3bd008(0x8e)],'parentTaskId':_0x3be266['parentTaskId']||null,'networkId':_0x3be266[_0x3bd008(0xb6)]||null,'transport':_0x3bd008(0xdf),'lifecycleTracking':_0x3bd008(0xce)},_0x3ea00a);}class $ extends a0_0x3a62ab{[a0_0xab4448(0xbb)];['alias'];[a0_0xab4448(0x81)];[a0_0xab4448(0xca)];[a0_0xab4448(0xc1)];[a0_0xab4448(0x9f)];[a0_0xab4448(0xd9)];[a0_0xab4448(0xb8)];['sseAbort'];[a0_0xab4448(0xeb)]=!0x1;constructor(_0x2d3006){const _0x21f145=a0_0xab4448;super();if(this[_0x21f145(0xbb)]=_0x2d3006[_0x21f145(0xbb)][_0x21f145(0xe9)](/\/$/,''),this[_0x21f145(0x8e)]=_0x2d3006[_0x21f145(0x8e)],this[_0x21f145(0x81)]=_0x2d3006[_0x21f145(0x81)],this['agent']=_0x2d3006[_0x21f145(0xca)]||'sdk',this[_0x21f145(0xc1)]=_0x21f145(0xaf)+_0x2d3006[_0x21f145(0x8e)]+'-'+Date[_0x21f145(0xa0)]()[_0x21f145(0xf0)](0x24),this['heartbeatInterval']=_0x2d3006[_0x21f145(0x9f)]??0x2bf20,this[_0x21f145(0xd9)]=_0x2d3006['reconnectDelay']??0xbb8,_0x2d3006[_0x21f145(0x79)]!==!0x1)this[_0x21f145(0xac)]();}[a0_0xab4448(0xd3)](_0x71f93d){const _0x21cb1e=a0_0xab4448;console['log']('['+new Date()[_0x21cb1e(0x75)]()[_0x21cb1e(0xbe)](0x0,0x8)+_0x21cb1e(0x84)+this['alias']+']\x20'+_0x71f93d);}async[a0_0xab4448(0x8f)](_0x4f3ecf,_0x534611){const _0x24ef47=a0_0xab4448;let _0x450538={'Content-Type':_0x24ef47(0xb0),'Accept':_0x24ef47(0xd4)};if(this[_0x24ef47(0x81)])_0x450538[_0x24ef47(0xc0)]=_0x24ef47(0xd1)+this[_0x24ef47(0x81)];let _0x541ef8=await(await fetch(this[_0x24ef47(0xbb)]+_0x24ef47(0xc9),{'method':_0x24ef47(0xe1),'headers':_0x450538,'body':JSON[_0x24ef47(0x9a)]({'jsonrpc':_0x24ef47(0xf4),'id':Date[_0x24ef47(0xa0)](),'method':'tools/call','params':{'name':_0x4f3ecf,'arguments':_0x534611}})}))[_0x24ef47(0xdb)](),_0x28c135=_0x541ef8[_0x24ef47(0xe4)](/data: (.+)/),_0x417a03=_0x28c135?JSON[_0x24ef47(0xf2)](_0x28c135[0x1]):JSON[_0x24ef47(0xf2)](_0x541ef8),_0x1ce4b6=_0x417a03?.[_0x24ef47(0x8b)]?.[_0x24ef47(0x9b)]?.[0x0]?.[_0x24ef47(0xdb)];return _0x1ce4b6?JSON['parse'](_0x1ce4b6):_0x417a03;}async[a0_0xab4448(0xac)](){const _0x3f97cc=a0_0xab4448;if(this[_0x3f97cc(0xeb)])return;this[_0x3f97cc(0xeb)]=!0x0,await this[_0x3f97cc(0xee)](_0x3f97cc(0x82)),this['log'](_0x3f97cc(0x7d)),this['heartbeatTimer']=setInterval(()=>{const _0x1168c4=_0x3f97cc;this['status'](_0x1168c4(0x82))[_0x1168c4(0xa6)](_0x7c6993=>this[_0x1168c4(0xd3)](_0x1168c4(0xb1)+_0x7c6993[_0x1168c4(0xcb)]));},this[_0x3f97cc(0x9f)]),this[_0x3f97cc(0x78)]();}async[a0_0xab4448(0x77)](){const _0x5cfd18=a0_0xab4448;if(this[_0x5cfd18(0xeb)]=!0x1,this[_0x5cfd18(0xc6)]?.[_0x5cfd18(0x7b)](),this[_0x5cfd18(0xb8)])clearInterval(this[_0x5cfd18(0xb8)]);await this[_0x5cfd18(0xee)]('offline')['catch'](()=>{}),this[_0x5cfd18(0xd3)](_0x5cfd18(0xc8));}async[a0_0xab4448(0x99)](_0x390a1d,_0x4d5ebb,_0x24d03f=a0_0xab4448(0x9c)){const _0x5e923b=a0_0xab4448;return Y({'alias':_0x390a1d,'fromAlias':this[_0x5e923b(0x8e)]},{'log':_0x32e077=>console['log'](_0x32e077),'send':()=>this[_0x5e923b(0x8f)]('send_task',{'alias':_0x390a1d,'task':_0x4d5ebb,'priority':_0x24d03f,'from_session':this['alias']})});}async['message'](_0x14e7eb,_0x4e4246){const _0x4608e4=a0_0xab4448;return this[_0x4608e4(0x8f)](_0x4608e4(0xbc),{'alias':_0x14e7eb,'message':_0x4e4246,'from_session':this[_0x4608e4(0x8e)]});}async[a0_0xab4448(0x96)](_0x2aadb0,_0x312d11,_0x470956=a0_0xab4448(0xef)){return this['call']('send_reply',{'in_reply_to':_0x2aadb0,'text':_0x312d11,'status':_0x470956});}async[a0_0xab4448(0xee)](_0x51818f,_0x150877){const _0x4d74c1=a0_0xab4448;return this[_0x4d74c1(0x8f)](_0x4d74c1(0xd8),{'resume_id':this['resumeId'],'alias':this['alias'],'status':_0x51818f,'server':a0_0x42060f(),'hostname':a0_0x42060f(),'agent':this['agent'],'project_dir':process[_0x4d74c1(0xe3)](),..._0x150877});}async[a0_0xab4448(0xc5)](){const _0x58581c=a0_0xab4448;return this[_0x58581c(0x8f)](_0x58581c(0xb7),{});}async[a0_0xab4448(0xde)](_0x3bcbbc,_0x4788fc){const _0x1dd3bc=a0_0xab4448;return this['call'](_0x1dd3bc(0xde),{'message':_0x3bcbbc,'filter_server':_0x4788fc?.[_0x1dd3bc(0xc2)],'filter_status':_0x4788fc?.[_0x1dd3bc(0xee)]});}async[a0_0xab4448(0x78)](){const _0x3f6be2=a0_0xab4448;let _0x23f995=encodeURIComponent(this[_0x3f6be2(0x8e)]),_0x530a4b=this[_0x3f6be2(0xbb)]+_0x3f6be2(0x8c)+_0x23f995,_0x201ca5=this[_0x3f6be2(0xd9)];while(this[_0x3f6be2(0xeb)]){try{this[_0x3f6be2(0xc6)]=new AbortController();let _0x2f0eb3={'Accept':_0x3f6be2(0xd5)};if(this[_0x3f6be2(0x81)])_0x2f0eb3[_0x3f6be2(0xc0)]=_0x3f6be2(0xd1)+this[_0x3f6be2(0x81)];let _0x2cd34b=await fetch(_0x530a4b,{'headers':_0x2f0eb3,'signal':this[_0x3f6be2(0xc6)][_0x3f6be2(0xe5)]});if(!_0x2cd34b['ok']||!_0x2cd34b['body']){this[_0x3f6be2(0xd3)]('SSE\x20failed:\x20'+_0x2cd34b[_0x3f6be2(0xee)]),await this['sleep'](_0x201ca5),_0x201ca5=Math[_0x3f6be2(0xf3)](_0x201ca5*1.5,0xea60);continue;}_0x201ca5=this['reconnectDelay'];let _0x2abdbe=_0x2cd34b[_0x3f6be2(0xea)][_0x3f6be2(0x86)](),_0x2187f9=new TextDecoder(),_0x5a139c='';while(this[_0x3f6be2(0xeb)]){let {done:_0xbf4702,value:_0xf58199}=await _0x2abdbe[_0x3f6be2(0x92)]();if(_0xbf4702)break;_0x5a139c+=_0x2187f9[_0x3f6be2(0xa2)](_0xf58199,{'stream':!0x0});let _0x510c00=_0x5a139c['split']('\x0a');_0x5a139c=_0x510c00[_0x3f6be2(0x94)]()||'';for(let _0x2ecf51 of _0x510c00){if(!_0x2ecf51[_0x3f6be2(0xcc)](_0x3f6be2(0xb4)))continue;try{let _0x19c890=JSON['parse'](_0x2ecf51[_0x3f6be2(0xbe)](0x6));if(_0x19c890['type']===_0x3f6be2(0x93)){this[_0x3f6be2(0xd3)](_0x3f6be2(0xc3)),this['emit'](_0x3f6be2(0x93));continue;}if(_0x19c890[_0x3f6be2(0xdd)]===_0x3f6be2(0x90)||_0x19c890[_0x3f6be2(0xdd)]===_0x3f6be2(0xb5)||_0x19c890[_0x3f6be2(0xdd)]===_0x3f6be2(0xde))await this[_0x3f6be2(0xe8)]();}catch{}}}}catch(_0x55a906){if(_0x55a906[_0x3f6be2(0xba)]===_0x3f6be2(0xf5))break;this[_0x3f6be2(0x8a)]('error',_0x55a906),this[_0x3f6be2(0xd3)](_0x3f6be2(0x76)+_0x55a906[_0x3f6be2(0xcb)]);}if(this[_0x3f6be2(0xeb)])this[_0x3f6be2(0x8a)](_0x3f6be2(0xc8)),this[_0x3f6be2(0xd3)](_0x3f6be2(0xc7)+_0x201ca5/0x3e8+_0x3f6be2(0xd0)),await this['sleep'](_0x201ca5),_0x201ca5=Math[_0x3f6be2(0xf3)](_0x201ca5*1.5,0xea60);}}async['processInbox'](){const _0x2a6358=a0_0xab4448;try{let _0x2c7363=(await this[_0x2a6358(0x8f)]('get_inbox',{'alias':this[_0x2a6358(0x8e)],'limit':0xa}))?.[_0x2a6358(0xda)]||[];for(let _0x5cfdd0 of _0x2c7363)await this[_0x2a6358(0x8f)](_0x2a6358(0xa7),{'alias':this[_0x2a6358(0x8e)],'message_id':_0x5cfdd0['id']}),this[_0x2a6358(0xd3)]('←\x20'+_0x5cfdd0['from_session']+':\x20'+_0x5cfdd0[_0x2a6358(0x9b)][_0x2a6358(0xbe)](0x0,0x3c)),this['emit'](_0x2a6358(0xb2),_0x5cfdd0),this[_0x2a6358(0x8a)]('message',_0x5cfdd0);}catch(_0x230c55){this['log']('inbox\x20error:\x20'+_0x230c55['message']);}}[a0_0xab4448(0xf7)](_0x419b8a){return new Promise(_0x142b42=>setTimeout(_0x142b42,_0x419b8a));}}var F=$;export{F as default,$ as CommHub};
|