@sleep2agi/agent-network 2.3.0-preview.188 → 2.3.0-preview.189
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_0x5b0223=a0_0x5cbe;(function(_0x299373,_0x522294){const _0x1ad23d=a0_0x5cbe,_0x5eada2=_0x299373();while(!![]){try{const _0x5870da=-parseInt(_0x1ad23d(0x20f))/0x1+parseInt(_0x1ad23d(0x233))/0x2*(parseInt(_0x1ad23d(0x23a))/0x3)+parseInt(_0x1ad23d(0x227))/0x4+parseInt(_0x1ad23d(0x210))/0x5*(parseInt(_0x1ad23d(0x228))/0x6)+-parseInt(_0x1ad23d(0x1f9))/0x7*(parseInt(_0x1ad23d(0x1ec))/0x8)+parseInt(_0x1ad23d(0x25d))/0x9+parseInt(_0x1ad23d(0x240))/0xa*(-parseInt(_0x1ad23d(0x235))/0xb);if(_0x5870da===_0x522294)break;else _0x5eada2['push'](_0x5eada2['shift']());}catch(_0x390355){_0x5eada2['push'](_0x5eada2['shift']());}}}(a0_0x1651,0x3e4b9));import{EventEmitter as a0_0x68384b}from'events';import{hostname as a0_0x1c71b5}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x3aac50,_0x43d25b)=>(_0x3aac50??_0x43d25b)[a0_0x5b0223(0x263)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x5b0223(0x250)](0x0,0xf0);function N(_0xa99024){const _0x5d1bab=a0_0x5b0223;return(_0xa99024 instanceof Error?_0xa99024[_0x5d1bab(0x20d)]:String(_0xa99024??_0x5d1bab(0x239)))[_0x5d1bab(0x263)](K,_0x5d1bab(0x1fa))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x5d1bab(0x250)](0x0,0xf0);}function a0_0x5cbe(_0x4e7701,_0x4d9946){_0x4e7701=_0x4e7701-0x1e7;const _0x165189=a0_0x1651();let _0x5cbe43=_0x165189[_0x4e7701];return _0x5cbe43;}function a0_0x1651(){const _0x2ff04b=['2086wtUNlT','[REDACTED]','new_task','task.ack','split','task.send.delivered','Authorization','error','task.expired','catch','pop','delivered','content','network_id','getReader','missing_task_id','\x20parent_task_id=','connected','token','task_id','message','broadcast','189908zDNgLn','901585zZNeVI','parent_task_id','alias','parse','message_id','server','send_failed','abort','running','2.0','stringify','from_session','min','ack_inbox','AbortError','toString','transport','heartbeatInterval','data:\x20','match','CommHub\x20response\x20omitted\x20task_id','fromAlias','application/json,\x20text/event-stream','782352SAJlvV','6Ppvdkl','resumeId','decode','<pending>','task.started','text','body','send_task','SSE\x20failed:\x20','task','sdk-','86oDkfoP','url','392095rrPmyu','/events/','disconnected','sleep','unknown\x20error','34014HiEvMa','Bearer\x20','networkId','emit','SSE\x20error:\x20','status','210jAkctz','duration_ms','toAlias','toTimeString','type','heartbeatTimer','lifecycleTracking','application/json','s...','not_tracked','/mcp','POST','agent','send_reply','mcp_http','new_message','slice','idle','to_alias','completed','<missing>','processInbox','startsWith','now','cwd','get_all_status','reconnectDelay','disconnect','task.send.start','4186521lsDFWq','<unknown>','error_code','connect','call','heartbeat\x20failed:\x20','replace','failed','sseAbort','parentTaskId','task.replied','error_message','CommHub\x20rejected\x20task','inbox\x20error:\x20','3624mGUlsi','get_inbox','\x20task_id=','log','connectSSE','result','sending',']\x20[commhub:','\x20transport=','read','\x20network_id=','json','send'];a0_0x1651=function(){return _0x2ff04b;};return a0_0x1651();}function O(_0x58c17e,_0x449aad=process.env.ANET_TASK_TRACE_FORMAT===a0_0x5b0223(0x1f7)){const _0x58de78=a0_0x5b0223;if(_0x449aad)return JSON[_0x58de78(0x21a)](_0x58c17e);let _0x70a47f=L(_0x58c17e[_0x58de78(0x211)],_0x58de78(0x254)),_0x1e0e16=L(_0x58c17e[_0x58de78(0x20c)],_0x58de78(0x22b)),_0x1b1d29=_0x58c17e['error_code']?'\x20error='+_0x58c17e[_0x58de78(0x25f)]+':'+(_0x58c17e[_0x58de78(0x1e9)]??''):'';return'[commhub:task]\x20'+_0x58c17e[_0x58de78(0x23f)]+'\x20from='+L(_0x58c17e['from_alias'],_0x58de78(0x25e))+'\x20to='+L(_0x58c17e[_0x58de78(0x252)],_0x58de78(0x25e))+_0x58de78(0x1ee)+_0x1e0e16+_0x58de78(0x209)+_0x70a47f+_0x58de78(0x1f6)+L(_0x58c17e[_0x58de78(0x206)],_0x58de78(0x25e))+_0x58de78(0x1f4)+_0x58c17e['transport']+'\x20duration_ms='+_0x58c17e[_0x58de78(0x241)]+'\x20lifecycle='+_0x58c17e['lifecycle_tracking']+_0x1b1d29;}function U(_0x36b686){const _0xfede73=a0_0x5b0223;return{'event':{'sending':_0xfede73(0x25c),'delivered':_0xfede73(0x1fe),'failed':'task.send.failed','acked':_0xfede73(0x1fc),'started':_0xfede73(0x22c),'replied':_0xfede73(0x1e8),'expired':_0xfede73(0x201)}[_0x36b686['status']],..._0x36b686};}function j(_0x2ba00f){const _0x2aadc1=a0_0x5b0223;let _0x5c285c=_0x2ba00f?.[_0x2aadc1(0x20c)]||_0x2ba00f?.[_0x2aadc1(0x214)]||_0x2ba00f?.['id'];if(_0x5c285c)return String(_0x5c285c);let _0x3f0242=_0x2ba00f?.[_0x2aadc1(0x205)]?.[0x0]?.['text'];if(typeof _0x3f0242!=='string')return null;try{let _0x4e1c3a=JSON[_0x2aadc1(0x213)](_0x3f0242);return _0x4e1c3a?.[_0x2aadc1(0x20c)]||_0x4e1c3a?.[_0x2aadc1(0x214)]||_0x4e1c3a?.['id']||null;}catch{return null;}}async function X(_0x102b3c,_0x654996){const _0x2ab2e9=a0_0x5b0223;let _0x123c07=_0x654996[_0x2ab2e9(0x257)]??Date[_0x2ab2e9(0x257)],_0x4c0c61=_0x123c07(),_0x46bfcc=(_0x3fd3ba,_0x168645,_0x4898e0,_0x93b37d)=>{const _0x3de3bb=_0x2ab2e9;_0x654996[_0x3de3bb(0x1ef)](O(U({'from_alias':_0x102b3c[_0x3de3bb(0x225)],'to_alias':_0x102b3c[_0x3de3bb(0x242)],'task_id':_0x168645,'parent_task_id':_0x102b3c[_0x3de3bb(0x1e7)],'network_id':_0x102b3c[_0x3de3bb(0x23c)],'transport':_0x102b3c[_0x3de3bb(0x220)],'status':_0x3fd3ba,'duration_ms':_0x123c07()-_0x4c0c61,'lifecycle_tracking':_0x102b3c[_0x3de3bb(0x246)],..._0x4898e0!==void 0x0?{'error_code':_0x93b37d||_0x3de3bb(0x216),'error_message':N(_0x4898e0)}:{}})));};_0x46bfcc(_0x2ab2e9(0x1f2),null);try{let _0x275806=await _0x654996[_0x2ab2e9(0x1f8)](),_0x58e925=j(_0x275806);if(_0x58e925)_0x46bfcc(_0x2ab2e9(0x204),_0x58e925);else{if(_0x275806?.['ok']===!0x1||_0x275806?.[_0x2ab2e9(0x200)])_0x46bfcc(_0x2ab2e9(0x264),_0x58e925,_0x275806?.[_0x2ab2e9(0x200)]||_0x2ab2e9(0x1ea),'send_rejected');else _0x46bfcc(_0x2ab2e9(0x264),null,_0x2ab2e9(0x224),_0x2ab2e9(0x208));}return _0x275806;}catch(_0x444ffe){throw _0x46bfcc(_0x2ab2e9(0x264),null,_0x444ffe,_0x2ab2e9(0x216)),_0x444ffe;}}async function Y(_0x48b3ed,_0x19821e){const _0x33590c=a0_0x5b0223;return X({'fromAlias':_0x48b3ed[_0x33590c(0x225)],'toAlias':_0x48b3ed[_0x33590c(0x212)],'parentTaskId':_0x48b3ed[_0x33590c(0x1e7)]||null,'networkId':_0x48b3ed[_0x33590c(0x23c)]||null,'transport':_0x33590c(0x24e),'lifecycleTracking':_0x33590c(0x249)},_0x19821e);}class $ extends a0_0x68384b{[a0_0x5b0223(0x234)];[a0_0x5b0223(0x212)];[a0_0x5b0223(0x20b)];['agent'];['resumeId'];[a0_0x5b0223(0x221)];[a0_0x5b0223(0x25a)];[a0_0x5b0223(0x245)];[a0_0x5b0223(0x265)];['running']=!0x1;constructor(_0x1f659a){const _0x2c7934=a0_0x5b0223;super();if(this[_0x2c7934(0x234)]=_0x1f659a[_0x2c7934(0x234)][_0x2c7934(0x263)](/\/$/,''),this['alias']=_0x1f659a[_0x2c7934(0x212)],this['token']=_0x1f659a['token'],this['agent']=_0x1f659a[_0x2c7934(0x24c)]||'sdk',this[_0x2c7934(0x229)]=_0x2c7934(0x232)+_0x1f659a[_0x2c7934(0x212)]+'-'+Date['now']()[_0x2c7934(0x21f)](0x24),this[_0x2c7934(0x221)]=_0x1f659a[_0x2c7934(0x221)]??0x2bf20,this['reconnectDelay']=_0x1f659a['reconnectDelay']??0xbb8,_0x1f659a['autoConnect']!==!0x1)this[_0x2c7934(0x260)]();}[a0_0x5b0223(0x1ef)](_0x304bff){const _0x1da6d0=a0_0x5b0223;console[_0x1da6d0(0x1ef)]('['+new Date()[_0x1da6d0(0x243)]()[_0x1da6d0(0x250)](0x0,0x8)+_0x1da6d0(0x1f3)+this[_0x1da6d0(0x212)]+']\x20'+_0x304bff);}async['call'](_0x1d3b9a,_0x3d1a15){const _0x453c00=a0_0x5b0223;let _0x2ca548={'Content-Type':_0x453c00(0x247),'Accept':_0x453c00(0x226)};if(this[_0x453c00(0x20b)])_0x2ca548[_0x453c00(0x1ff)]='Bearer\x20'+this[_0x453c00(0x20b)];let _0x2b7bdf=await(await fetch(this[_0x453c00(0x234)]+_0x453c00(0x24a),{'method':_0x453c00(0x24b),'headers':_0x2ca548,'body':JSON['stringify']({'jsonrpc':_0x453c00(0x219),'id':Date[_0x453c00(0x257)](),'method':'tools/call','params':{'name':_0x1d3b9a,'arguments':_0x3d1a15}})}))[_0x453c00(0x22d)](),_0xfc75c7=_0x2b7bdf[_0x453c00(0x223)](/data: (.+)/),_0x5c7a41=_0xfc75c7?JSON[_0x453c00(0x213)](_0xfc75c7[0x1]):JSON[_0x453c00(0x213)](_0x2b7bdf),_0x5e2012=_0x5c7a41?.[_0x453c00(0x1f1)]?.[_0x453c00(0x205)]?.[0x0]?.[_0x453c00(0x22d)];return _0x5e2012?JSON[_0x453c00(0x213)](_0x5e2012):_0x5c7a41;}async[a0_0x5b0223(0x260)](){const _0x9358b=a0_0x5b0223;if(this[_0x9358b(0x218)])return;this[_0x9358b(0x218)]=!0x0,await this['status'](_0x9358b(0x251)),this['log']('registered'),this[_0x9358b(0x245)]=setInterval(()=>{const _0x26b7d4=_0x9358b;this[_0x26b7d4(0x23f)](_0x26b7d4(0x251))[_0x26b7d4(0x202)](_0x206aa9=>this['log'](_0x26b7d4(0x262)+_0x206aa9[_0x26b7d4(0x20d)]));},this[_0x9358b(0x221)]),this[_0x9358b(0x1f0)]();}async[a0_0x5b0223(0x25b)](){const _0x3f3816=a0_0x5b0223;if(this[_0x3f3816(0x218)]=!0x1,this[_0x3f3816(0x265)]?.[_0x3f3816(0x217)](),this[_0x3f3816(0x245)])clearInterval(this[_0x3f3816(0x245)]);await this[_0x3f3816(0x23f)]('offline')[_0x3f3816(0x202)](()=>{}),this['log'](_0x3f3816(0x237));}async[a0_0x5b0223(0x1f8)](_0x199a2c,_0x5069b4,_0x218705='normal'){const _0x20a29d=a0_0x5b0223;return Y({'alias':_0x199a2c,'fromAlias':this[_0x20a29d(0x212)]},{'log':_0x1a3baa=>console[_0x20a29d(0x1ef)](_0x1a3baa),'send':()=>this['call'](_0x20a29d(0x22f),{'alias':_0x199a2c,'task':_0x5069b4,'priority':_0x218705,'from_session':this[_0x20a29d(0x212)]})});}async[a0_0x5b0223(0x20d)](_0x11ac9c,_0x1d5331){const _0x41472d=a0_0x5b0223;return this[_0x41472d(0x261)]('send_message',{'alias':_0x11ac9c,'message':_0x1d5331,'from_session':this[_0x41472d(0x212)]});}async['reply'](_0x23c323,_0x2ef235,_0x556eaa=a0_0x5b0223(0x253)){const _0x1ab8c3=a0_0x5b0223;return this['call'](_0x1ab8c3(0x24d),{'in_reply_to':_0x23c323,'text':_0x2ef235,'status':_0x556eaa});}async[a0_0x5b0223(0x23f)](_0x979b4b,_0x42c526){const _0x41874a=a0_0x5b0223;return this[_0x41874a(0x261)]('report_status',{'resume_id':this[_0x41874a(0x229)],'alias':this[_0x41874a(0x212)],'status':_0x979b4b,'server':a0_0x1c71b5(),'hostname':a0_0x1c71b5(),'agent':this['agent'],'project_dir':process[_0x41874a(0x258)](),..._0x42c526});}async['getAllStatus'](){const _0x24671f=a0_0x5b0223;return this[_0x24671f(0x261)](_0x24671f(0x259),{});}async[a0_0x5b0223(0x20e)](_0x460622,_0x3ca9ca){const _0x1405ce=a0_0x5b0223;return this[_0x1405ce(0x261)](_0x1405ce(0x20e),{'message':_0x460622,'filter_server':_0x3ca9ca?.[_0x1405ce(0x215)],'filter_status':_0x3ca9ca?.['status']});}async[a0_0x5b0223(0x1f0)](){const _0xe04972=a0_0x5b0223;let _0x211a21=encodeURIComponent(this[_0xe04972(0x212)]),_0x2965f5=this[_0xe04972(0x234)]+_0xe04972(0x236)+_0x211a21,_0x4eb636=this[_0xe04972(0x25a)];while(this[_0xe04972(0x218)]){try{this[_0xe04972(0x265)]=new AbortController();let _0x4a2523={'Accept':'text/event-stream'};if(this[_0xe04972(0x20b)])_0x4a2523[_0xe04972(0x1ff)]=_0xe04972(0x23b)+this[_0xe04972(0x20b)];let _0x5acd96=await fetch(_0x2965f5,{'headers':_0x4a2523,'signal':this[_0xe04972(0x265)]['signal']});if(!_0x5acd96['ok']||!_0x5acd96['body']){this[_0xe04972(0x1ef)](_0xe04972(0x230)+_0x5acd96['status']),await this['sleep'](_0x4eb636),_0x4eb636=Math['min'](_0x4eb636*1.5,0xea60);continue;}_0x4eb636=this[_0xe04972(0x25a)];let _0x38e20e=_0x5acd96[_0xe04972(0x22e)][_0xe04972(0x207)](),_0x541fb8=new TextDecoder(),_0x13966a='';while(this[_0xe04972(0x218)]){let {done:_0x1140ce,value:_0x33e38f}=await _0x38e20e[_0xe04972(0x1f5)]();if(_0x1140ce)break;_0x13966a+=_0x541fb8[_0xe04972(0x22a)](_0x33e38f,{'stream':!0x0});let _0x1295d3=_0x13966a[_0xe04972(0x1fd)]('\x0a');_0x13966a=_0x1295d3[_0xe04972(0x203)]()||'';for(let _0x4c1abe of _0x1295d3){if(!_0x4c1abe[_0xe04972(0x256)](_0xe04972(0x222)))continue;try{let _0x35a75b=JSON[_0xe04972(0x213)](_0x4c1abe[_0xe04972(0x250)](0x6));if(_0x35a75b['type']===_0xe04972(0x20a)){this[_0xe04972(0x1ef)]('SSE\x20connected'),this[_0xe04972(0x23d)]('connected');continue;}if(_0x35a75b[_0xe04972(0x244)]===_0xe04972(0x1fb)||_0x35a75b['type']===_0xe04972(0x24f)||_0x35a75b[_0xe04972(0x244)]===_0xe04972(0x20e))await this[_0xe04972(0x255)]();}catch{}}}}catch(_0x3e2928){if(_0x3e2928['name']===_0xe04972(0x21e))break;this[_0xe04972(0x23d)]('error',_0x3e2928),this[_0xe04972(0x1ef)](_0xe04972(0x23e)+_0x3e2928['message']);}if(this[_0xe04972(0x218)])this[_0xe04972(0x23d)](_0xe04972(0x237)),this['log']('SSE\x20reconnecting\x20in\x20'+_0x4eb636/0x3e8+_0xe04972(0x248)),await this[_0xe04972(0x238)](_0x4eb636),_0x4eb636=Math[_0xe04972(0x21c)](_0x4eb636*1.5,0xea60);}}async[a0_0x5b0223(0x255)](){const _0x5dc8e3=a0_0x5b0223;try{let _0x381877=(await this['call'](_0x5dc8e3(0x1ed),{'alias':this[_0x5dc8e3(0x212)],'limit':0xa}))?.['messages']||[];for(let _0x4a4f4f of _0x381877)await this[_0x5dc8e3(0x261)](_0x5dc8e3(0x21d),{'alias':this[_0x5dc8e3(0x212)],'message_id':_0x4a4f4f['id']}),this[_0x5dc8e3(0x1ef)]('←\x20'+_0x4a4f4f[_0x5dc8e3(0x21b)]+':\x20'+_0x4a4f4f[_0x5dc8e3(0x205)][_0x5dc8e3(0x250)](0x0,0x3c)),this[_0x5dc8e3(0x23d)](_0x5dc8e3(0x231),_0x4a4f4f),this[_0x5dc8e3(0x23d)](_0x5dc8e3(0x20d),_0x4a4f4f);}catch(_0xed67ae){this['log'](_0x5dc8e3(0x1eb)+_0xed67ae[_0x5dc8e3(0x20d)]);}}[a0_0x5b0223(0x238)](_0x11f76b){return new Promise(_0x152d94=>setTimeout(_0x152d94,_0x11f76b));}}var F=$;export{F as default,$ as CommHub};
|
|
1
|
+
const a0_0x24e2e5=a0_0x100e;(function(_0x201cd8,_0x4b4378){const _0x2f1ca3=a0_0x100e,_0x19720c=_0x201cd8();while(!![]){try{const _0x43ab20=parseInt(_0x2f1ca3(0x211))/0x1*(parseInt(_0x2f1ca3(0x1c0))/0x2)+parseInt(_0x2f1ca3(0x207))/0x3*(-parseInt(_0x2f1ca3(0x1d4))/0x4)+parseInt(_0x2f1ca3(0x1f0))/0x5+-parseInt(_0x2f1ca3(0x20f))/0x6+parseInt(_0x2f1ca3(0x22f))/0x7+-parseInt(_0x2f1ca3(0x1dd))/0x8*(-parseInt(_0x2f1ca3(0x203))/0x9)+parseInt(_0x2f1ca3(0x1d2))/0xa*(-parseInt(_0x2f1ca3(0x1b9))/0xb);if(_0x43ab20===_0x4b4378)break;else _0x19720c['push'](_0x19720c['shift']());}catch(_0x20d282){_0x19720c['push'](_0x19720c['shift']());}}}(a0_0x121a,0xba517));import{EventEmitter as a0_0x3983c5}from'events';import{hostname as a0_0x41b0af}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x30e552,_0xefd89a)=>(_0x30e552??_0xefd89a)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x7c08e6){const _0xe0add9=a0_0x100e;return(_0x7c08e6 instanceof Error?_0x7c08e6[_0xe0add9(0x233)]:String(_0x7c08e6??_0xe0add9(0x224)))['replace'](K,_0xe0add9(0x21f))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0xe0add9(0x22b)](0x0,0xf0);}function O(_0x3cb1d3,_0x5655ee=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x564169=a0_0x100e;if(_0x5655ee)return JSON[_0x564169(0x22c)](_0x3cb1d3);let _0x2b0344=L(_0x3cb1d3['parent_task_id'],_0x564169(0x1ea)),_0x30f017=L(_0x3cb1d3['task_id'],_0x564169(0x228)),_0x45d90a=_0x3cb1d3['error_code']?_0x564169(0x1df)+_0x3cb1d3[_0x564169(0x1d3)]+':'+(_0x3cb1d3[_0x564169(0x20d)]??''):'';return _0x564169(0x234)+_0x3cb1d3['status']+_0x564169(0x1b8)+L(_0x3cb1d3[_0x564169(0x1ce)],_0x564169(0x1f8))+'\x20to='+L(_0x3cb1d3[_0x564169(0x221)],_0x564169(0x1f8))+_0x564169(0x216)+_0x30f017+_0x564169(0x1f7)+_0x2b0344+'\x20network_id='+L(_0x3cb1d3['network_id'],'<unknown>')+_0x564169(0x22a)+_0x3cb1d3[_0x564169(0x20a)]+_0x564169(0x217)+_0x3cb1d3[_0x564169(0x1c6)]+'\x20lifecycle='+_0x3cb1d3['lifecycle_tracking']+_0x45d90a;}function U(_0x3c286a){const _0x5d9b5e=a0_0x100e;return{'event':{'sending':_0x5d9b5e(0x1d5),'delivered':_0x5d9b5e(0x20c),'failed':_0x5d9b5e(0x1fd),'acked':_0x5d9b5e(0x231),'started':_0x5d9b5e(0x1ca),'replied':'task.replied','expired':_0x5d9b5e(0x213)}[_0x3c286a['status']],..._0x3c286a};}function j(_0x170ba4){const _0x9d5c46=a0_0x100e;let _0x5b9794=_0x170ba4?.['task_id']||_0x170ba4?.[_0x9d5c46(0x1eb)]||_0x170ba4?.['id'];if(_0x5b9794)return String(_0x5b9794);let _0x4da443=_0x170ba4?.[_0x9d5c46(0x21e)]?.[0x0]?.[_0x9d5c46(0x210)];if(typeof _0x4da443!==_0x9d5c46(0x232))return null;try{let _0x12945a=JSON[_0x9d5c46(0x1ba)](_0x4da443);return _0x12945a?.['task_id']||_0x12945a?.[_0x9d5c46(0x1eb)]||_0x12945a?.['id']||null;}catch{return null;}}function a0_0x100e(_0x2cd871,_0x2b0ef9){_0x2cd871=_0x2cd871-0x1b8;const _0x121a1f=a0_0x121a();let _0x100ea5=_0x121a1f[_0x2cd871];return _0x100ea5;}async function X(_0x972516,_0x4d74b6){const _0x33c346=a0_0x100e;let _0xfa2e3e=_0x4d74b6['now']??Date[_0x33c346(0x21b)],_0x348c47=_0xfa2e3e(),_0x3ae325=(_0x36c206,_0x5dd481,_0x4b2a72,_0x6a68dc)=>{const _0x535dc2=_0x33c346;_0x4d74b6[_0x535dc2(0x1e3)](O(U({'from_alias':_0x972516[_0x535dc2(0x1ec)],'to_alias':_0x972516[_0x535dc2(0x1f3)],'task_id':_0x5dd481,'parent_task_id':_0x972516[_0x535dc2(0x237)],'network_id':_0x972516[_0x535dc2(0x1c8)],'transport':_0x972516['transport'],'status':_0x36c206,'duration_ms':_0xfa2e3e()-_0x348c47,'lifecycle_tracking':_0x972516[_0x535dc2(0x1fc)],..._0x4b2a72!==void 0x0?{'error_code':_0x6a68dc||_0x535dc2(0x223),'error_message':N(_0x4b2a72)}:{}})));};_0x3ae325('sending',null);try{let _0x210970=await _0x4d74b6[_0x33c346(0x21d)](),_0x4b3a0e=j(_0x210970);if(_0x4b3a0e)_0x3ae325(_0x33c346(0x1e5),_0x4b3a0e);else{if(_0x210970?.['ok']===!0x1||_0x210970?.[_0x33c346(0x1c7)])_0x3ae325(_0x33c346(0x1d1),_0x4b3a0e,_0x210970?.[_0x33c346(0x1c7)]||_0x33c346(0x1cf),'send_rejected');else _0x3ae325('failed',null,_0x33c346(0x1d8),_0x33c346(0x1e2));}return _0x210970;}catch(_0x417469){throw _0x3ae325(_0x33c346(0x1d1),null,_0x417469,_0x33c346(0x223)),_0x417469;}}async function Y(_0x5404e0,_0x3027a1){const _0x5696d3=a0_0x100e;return X({'fromAlias':_0x5404e0[_0x5696d3(0x1ec)],'toAlias':_0x5404e0['alias'],'parentTaskId':_0x5404e0[_0x5696d3(0x237)]||null,'networkId':_0x5404e0['networkId']||null,'transport':'mcp_http','lifecycleTracking':_0x5696d3(0x222)},_0x3027a1);}function a0_0x121a(){const _0x484ea5=['getReader','\x20parent_task_id=','<unknown>','type','pop','POST','lifecycleTracking','task.send.failed','name','catch','Authorization','toString','match','9wjxvjU','running','alias','connectSSE','9BDIoxy','tools/call','data:\x20','transport','disconnect','task.send.delivered','error_message','disconnected','6286758kkSrcc','text','28eSyrsW','application/json','task.expired','heartbeat\x20failed:\x20','sseAbort','\x20task_id=','\x20duration_ms=','SSE\x20reconnecting\x20in\x20','heartbeatTimer','Bearer\x20','now','send_reply','send','content','[REDACTED]','task','to_alias','not_tracked','send_failed','unknown\x20error','2.0','s...','server','<pending>','token','\x20transport=','slice','stringify','connected','SSE\x20connected','8988749OwecDJ','reconnectDelay','task.ack','string','message','[commhub:task]\x20','status','SSE\x20error:\x20','parentTaskId','get_inbox','ack_inbox','\x20from=','209uRMXhs','parse','heartbeatInterval','getAllStatus',']\x20[commhub:','broadcast','autoConnect','33330VRbHpU','toTimeString','call','read','reply','new_message','duration_ms','error','networkId','processInbox','task.started','signal','get_all_status','body','from_alias','CommHub\x20rejected\x20task','min','failed','535550ciyZCL','error_code','393916QwfGTK','task.send.start','new_task','send_task','CommHub\x20response\x20omitted\x20task_id','messages','url','resumeId','replace','10552928zligaJ','connect','\x20error=','/mcp','idle','missing_task_id','log','result','delivered','report_status','split','from_session','registered','<missing>','message_id','fromAlias','/events/','agent','completed','270455LZVeuY','emit','sleep','toAlias','sdk-','abort'];a0_0x121a=function(){return _0x484ea5;};return a0_0x121a();}class $ extends a0_0x3983c5{[a0_0x24e2e5(0x1da)];[a0_0x24e2e5(0x205)];['token'];[a0_0x24e2e5(0x1ee)];[a0_0x24e2e5(0x1db)];['heartbeatInterval'];[a0_0x24e2e5(0x230)];['heartbeatTimer'];[a0_0x24e2e5(0x215)];[a0_0x24e2e5(0x204)]=!0x1;constructor(_0x51a757){const _0x5639c9=a0_0x24e2e5;super();if(this[_0x5639c9(0x1da)]=_0x51a757[_0x5639c9(0x1da)][_0x5639c9(0x1dc)](/\/$/,''),this[_0x5639c9(0x205)]=_0x51a757[_0x5639c9(0x205)],this['token']=_0x51a757[_0x5639c9(0x229)],this[_0x5639c9(0x1ee)]=_0x51a757['agent']||'sdk',this[_0x5639c9(0x1db)]=_0x5639c9(0x1f4)+_0x51a757[_0x5639c9(0x205)]+'-'+Date[_0x5639c9(0x21b)]()[_0x5639c9(0x201)](0x24),this[_0x5639c9(0x1bb)]=_0x51a757[_0x5639c9(0x1bb)]??0x2bf20,this[_0x5639c9(0x230)]=_0x51a757[_0x5639c9(0x230)]??0xbb8,_0x51a757[_0x5639c9(0x1bf)]!==!0x1)this[_0x5639c9(0x1de)]();}[a0_0x24e2e5(0x1e3)](_0x2efae9){const _0xb80c1e=a0_0x24e2e5;console[_0xb80c1e(0x1e3)]('['+new Date()[_0xb80c1e(0x1c1)]()['slice'](0x0,0x8)+_0xb80c1e(0x1bd)+this[_0xb80c1e(0x205)]+']\x20'+_0x2efae9);}async[a0_0x24e2e5(0x1c2)](_0x2df5eb,_0x18044a){const _0x30eb4a=a0_0x24e2e5;let _0xc87fa9={'Content-Type':_0x30eb4a(0x212),'Accept':'application/json,\x20text/event-stream'};if(this[_0x30eb4a(0x229)])_0xc87fa9[_0x30eb4a(0x200)]=_0x30eb4a(0x21a)+this[_0x30eb4a(0x229)];let _0x193960=await(await fetch(this['url']+_0x30eb4a(0x1e0),{'method':_0x30eb4a(0x1fb),'headers':_0xc87fa9,'body':JSON[_0x30eb4a(0x22c)]({'jsonrpc':_0x30eb4a(0x225),'id':Date[_0x30eb4a(0x21b)](),'method':_0x30eb4a(0x208),'params':{'name':_0x2df5eb,'arguments':_0x18044a}})}))[_0x30eb4a(0x210)](),_0x58abe4=_0x193960[_0x30eb4a(0x202)](/data: (.+)/),_0x2ca8d6=_0x58abe4?JSON[_0x30eb4a(0x1ba)](_0x58abe4[0x1]):JSON[_0x30eb4a(0x1ba)](_0x193960),_0x467bb1=_0x2ca8d6?.[_0x30eb4a(0x1e4)]?.['content']?.[0x0]?.[_0x30eb4a(0x210)];return _0x467bb1?JSON[_0x30eb4a(0x1ba)](_0x467bb1):_0x2ca8d6;}async[a0_0x24e2e5(0x1de)](){const _0x46a69d=a0_0x24e2e5;if(this[_0x46a69d(0x204)])return;this[_0x46a69d(0x204)]=!0x0,await this['status']('idle'),this[_0x46a69d(0x1e3)](_0x46a69d(0x1e9)),this[_0x46a69d(0x219)]=setInterval(()=>{const _0x849f40=_0x46a69d;this['status'](_0x849f40(0x1e1))['catch'](_0x13c7eb=>this['log'](_0x849f40(0x214)+_0x13c7eb[_0x849f40(0x233)]));},this[_0x46a69d(0x1bb)]),this['connectSSE']();}async[a0_0x24e2e5(0x20b)](){const _0xc91a0f=a0_0x24e2e5;if(this[_0xc91a0f(0x204)]=!0x1,this[_0xc91a0f(0x215)]?.[_0xc91a0f(0x1f5)](),this['heartbeatTimer'])clearInterval(this[_0xc91a0f(0x219)]);await this[_0xc91a0f(0x235)]('offline')[_0xc91a0f(0x1ff)](()=>{}),this[_0xc91a0f(0x1e3)](_0xc91a0f(0x20e));}async[a0_0x24e2e5(0x21d)](_0x1eb683,_0x499d2c,_0x4ffb19='normal'){const _0x38016d=a0_0x24e2e5;return Y({'alias':_0x1eb683,'fromAlias':this[_0x38016d(0x205)]},{'log':_0x811e2c=>console[_0x38016d(0x1e3)](_0x811e2c),'send':()=>this[_0x38016d(0x1c2)](_0x38016d(0x1d7),{'alias':_0x1eb683,'task':_0x499d2c,'priority':_0x4ffb19,'from_session':this[_0x38016d(0x205)]})});}async[a0_0x24e2e5(0x233)](_0x44cb13,_0x2c4caf){const _0x243324=a0_0x24e2e5;return this[_0x243324(0x1c2)]('send_message',{'alias':_0x44cb13,'message':_0x2c4caf,'from_session':this[_0x243324(0x205)]});}async[a0_0x24e2e5(0x1c4)](_0x701e56,_0x2c3fd2,_0x519364=a0_0x24e2e5(0x1ef)){const _0x46149a=a0_0x24e2e5;return this[_0x46149a(0x1c2)](_0x46149a(0x21c),{'in_reply_to':_0x701e56,'text':_0x2c3fd2,'status':_0x519364});}async[a0_0x24e2e5(0x235)](_0x54f873,_0x3cc3aa){const _0x371a10=a0_0x24e2e5;return this[_0x371a10(0x1c2)](_0x371a10(0x1e6),{'resume_id':this[_0x371a10(0x1db)],'alias':this[_0x371a10(0x205)],'status':_0x54f873,'server':a0_0x41b0af(),'hostname':a0_0x41b0af(),'agent':this['agent'],'project_dir':process['cwd'](),..._0x3cc3aa});}async[a0_0x24e2e5(0x1bc)](){const _0x14f00d=a0_0x24e2e5;return this[_0x14f00d(0x1c2)](_0x14f00d(0x1cc),{});}async[a0_0x24e2e5(0x1be)](_0x37f210,_0x1b9eef){const _0x54d8bc=a0_0x24e2e5;return this[_0x54d8bc(0x1c2)](_0x54d8bc(0x1be),{'message':_0x37f210,'filter_server':_0x1b9eef?.[_0x54d8bc(0x227)],'filter_status':_0x1b9eef?.[_0x54d8bc(0x235)]});}async[a0_0x24e2e5(0x206)](){const _0x1e37a8=a0_0x24e2e5;let _0x433da6=encodeURIComponent(this[_0x1e37a8(0x205)]),_0x26563f=this['url']+_0x1e37a8(0x1ed)+_0x433da6,_0x415e69=this['reconnectDelay'];while(this[_0x1e37a8(0x204)]){try{this['sseAbort']=new AbortController();let _0x3d4a56={'Accept':'text/event-stream'};if(this[_0x1e37a8(0x229)])_0x3d4a56[_0x1e37a8(0x200)]=_0x1e37a8(0x21a)+this['token'];let _0x1c9741=await fetch(_0x26563f,{'headers':_0x3d4a56,'signal':this[_0x1e37a8(0x215)][_0x1e37a8(0x1cb)]});if(!_0x1c9741['ok']||!_0x1c9741[_0x1e37a8(0x1cd)]){this[_0x1e37a8(0x1e3)]('SSE\x20failed:\x20'+_0x1c9741[_0x1e37a8(0x235)]),await this[_0x1e37a8(0x1f2)](_0x415e69),_0x415e69=Math[_0x1e37a8(0x1d0)](_0x415e69*1.5,0xea60);continue;}_0x415e69=this[_0x1e37a8(0x230)];let _0x242422=_0x1c9741['body'][_0x1e37a8(0x1f6)](),_0x2887d4=new TextDecoder(),_0x298d4d='';while(this['running']){let {done:_0x3789cc,value:_0x5efa88}=await _0x242422[_0x1e37a8(0x1c3)]();if(_0x3789cc)break;_0x298d4d+=_0x2887d4['decode'](_0x5efa88,{'stream':!0x0});let _0x4561ad=_0x298d4d[_0x1e37a8(0x1e7)]('\x0a');_0x298d4d=_0x4561ad[_0x1e37a8(0x1fa)]()||'';for(let _0x2d83b2 of _0x4561ad){if(!_0x2d83b2['startsWith'](_0x1e37a8(0x209)))continue;try{let _0x573fd1=JSON[_0x1e37a8(0x1ba)](_0x2d83b2[_0x1e37a8(0x22b)](0x6));if(_0x573fd1[_0x1e37a8(0x1f9)]===_0x1e37a8(0x22d)){this[_0x1e37a8(0x1e3)](_0x1e37a8(0x22e)),this[_0x1e37a8(0x1f1)]('connected');continue;}if(_0x573fd1[_0x1e37a8(0x1f9)]===_0x1e37a8(0x1d6)||_0x573fd1[_0x1e37a8(0x1f9)]===_0x1e37a8(0x1c5)||_0x573fd1[_0x1e37a8(0x1f9)]==='broadcast')await this[_0x1e37a8(0x1c9)]();}catch{}}}}catch(_0x110511){if(_0x110511[_0x1e37a8(0x1fe)]==='AbortError')break;this['emit'](_0x1e37a8(0x1c7),_0x110511),this[_0x1e37a8(0x1e3)](_0x1e37a8(0x236)+_0x110511[_0x1e37a8(0x233)]);}if(this['running'])this['emit'](_0x1e37a8(0x20e)),this[_0x1e37a8(0x1e3)](_0x1e37a8(0x218)+_0x415e69/0x3e8+_0x1e37a8(0x226)),await this[_0x1e37a8(0x1f2)](_0x415e69),_0x415e69=Math[_0x1e37a8(0x1d0)](_0x415e69*1.5,0xea60);}}async[a0_0x24e2e5(0x1c9)](){const _0x4035af=a0_0x24e2e5;try{let _0x41aa18=(await this['call'](_0x4035af(0x238),{'alias':this[_0x4035af(0x205)],'limit':0xa}))?.[_0x4035af(0x1d9)]||[];for(let _0x21ffc5 of _0x41aa18)await this['call'](_0x4035af(0x239),{'alias':this[_0x4035af(0x205)],'message_id':_0x21ffc5['id']}),this[_0x4035af(0x1e3)]('←\x20'+_0x21ffc5[_0x4035af(0x1e8)]+':\x20'+_0x21ffc5['content'][_0x4035af(0x22b)](0x0,0x3c)),this['emit'](_0x4035af(0x220),_0x21ffc5),this[_0x4035af(0x1f1)](_0x4035af(0x233),_0x21ffc5);}catch(_0x33ecb2){this[_0x4035af(0x1e3)]('inbox\x20error:\x20'+_0x33ecb2['message']);}}[a0_0x24e2e5(0x1f2)](_0x254277){return new Promise(_0x5bcdf2=>setTimeout(_0x5bcdf2,_0x254277));}}var F=$;export{F as default,$ as CommHub};
|