@sleep2agi/agent-network 2.3.0-preview.200 → 2.3.0-preview.201
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_0x577b69=a0_0x1864;(function(_0x1112a5,_0x2f1825){const _0x38d4e8=a0_0x1864,_0x4b54f2=_0x1112a5();while(!![]){try{const _0x4b7509=parseInt(_0x38d4e8(0x203))/0x1+-parseInt(_0x38d4e8(0x1fa))/0x2+parseInt(_0x38d4e8(0x20b))/0x3*(parseInt(_0x38d4e8(0x1c1))/0x4)+parseInt(_0x38d4e8(0x1dd))/0x5*(parseInt(_0x38d4e8(0x1a1))/0x6)+-parseInt(_0x38d4e8(0x1c4))/0x7*(-parseInt(_0x38d4e8(0x206))/0x8)+parseInt(_0x38d4e8(0x1d1))/0x9+parseInt(_0x38d4e8(0x204))/0xa*(-parseInt(_0x38d4e8(0x205))/0xb);if(_0x4b7509===_0x2f1825)break;else _0x4b54f2['push'](_0x4b54f2['shift']());}catch(_0x105fc8){_0x4b54f2['push'](_0x4b54f2['shift']());}}}(a0_0x3cb1,0xc500d));import{EventEmitter as a0_0x584e76}from'events';function a0_0x1864(_0x140cc7,_0x3de6dc){_0x140cc7=_0x140cc7-0x19d;const _0x3cb19d=a0_0x3cb1();let _0x1864e1=_0x3cb19d[_0x140cc7];return _0x1864e1;}import{hostname as a0_0x149386}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x2aa9a6,_0x144a2a)=>(_0x2aa9a6??_0x144a2a)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x577b69(0x1d8)](0x0,0xf0);function a0_0x3cb1(){const _0x21abd1=['error','heartbeatInterval','emit','idle','send_message','294082OAwjVp','Authorization','reconnectDelay','call','sleep','networkId','abort','task_id','failed','518032gprYEI','5620210WBdBqP','55zeTsPB','5409392AlSIsm','log','2.0','s...','unknown\x20error','35094XOOHXb','url','new_message','from_session','heartbeatTimer','cwd','stringify','network_id','task.started','now','catch','name','parentTaskId','toAlias','SSE\x20connected','message','getReader','error_code','toString','token','decode','\x20lifecycle=','6IaZlvL','sseAbort','error_message','data:\x20','completed','SSE\x20reconnecting\x20in\x20','content','connected','/events/','status','disconnected','task','\x20error=','json','match','to_alias','get_inbox','reply','body','agent','\x20network_id=','send_reply','parse','parent_task_id','getAllStatus','duration_ms','lifecycle_tracking','task.expired','sending','task.ack','CommHub\x20response\x20omitted\x20task_id','resumeId','64GrkgDx','string','CommHub\x20rejected\x20task','7ubrrjM','SSE\x20failed:\x20','split','send','result','<unknown>','alias','processInbox','messages','signal','text/event-stream','offline','get_all_status','8773317vuadHo','normal','transport','sdk','task.send.failed','[commhub:task]\x20','not_tracked','slice','broadcast','text','sdk-','\x20task_id=','7039420yKSZEa','type','message_id','task.replied','send_rejected','AbortError','autoConnect','heartbeat\x20failed:\x20','server','POST','running','mcp_http','\x20transport=','Bearer\x20','send_failed','/mcp','inbox\x20error:\x20','replace','registered','\x20to=','disconnect','toTimeString','report_status','\x20duration_ms='];a0_0x3cb1=function(){return _0x21abd1;};return a0_0x3cb1();}function N(_0x4ee4b3){const _0x18989e=a0_0x577b69;return(_0x4ee4b3 instanceof Error?_0x4ee4b3[_0x18989e(0x21a)]:String(_0x4ee4b3??_0x18989e(0x20a)))[_0x18989e(0x1ee)](K,'[REDACTED]')['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x18989e(0x1d8)](0x0,0xf0);}function O(_0x9c8751,_0x40902e=process.env.ANET_TASK_TRACE_FORMAT===a0_0x577b69(0x1ae)){const _0x148b7b=a0_0x577b69;if(_0x40902e)return JSON[_0x148b7b(0x211)](_0x9c8751);let _0x42c610=L(_0x9c8751[_0x148b7b(0x1b8)],'<missing>'),_0x358abf=L(_0x9c8751[_0x148b7b(0x201)],'<pending>'),_0x3be181=_0x9c8751[_0x148b7b(0x21c)]?_0x148b7b(0x1ad)+_0x9c8751[_0x148b7b(0x21c)]+':'+(_0x9c8751[_0x148b7b(0x1a3)]??''):'';return _0x148b7b(0x1d6)+_0x9c8751[_0x148b7b(0x1aa)]+'\x20from='+L(_0x9c8751['from_alias'],_0x148b7b(0x1c9))+_0x148b7b(0x1f0)+L(_0x9c8751[_0x148b7b(0x1b0)],_0x148b7b(0x1c9))+_0x148b7b(0x1dc)+_0x358abf+'\x20parent_task_id='+_0x42c610+_0x148b7b(0x1b5)+L(_0x9c8751[_0x148b7b(0x212)],_0x148b7b(0x1c9))+_0x148b7b(0x1e9)+_0x9c8751[_0x148b7b(0x1d3)]+_0x148b7b(0x1f4)+_0x9c8751[_0x148b7b(0x1ba)]+_0x148b7b(0x1a0)+_0x9c8751[_0x148b7b(0x1bb)]+_0x3be181;}function U(_0x4eba8e){const _0x17b9ca=a0_0x577b69;return{'event':{'sending':'task.send.start','delivered':'task.send.delivered','failed':_0x17b9ca(0x1d5),'acked':_0x17b9ca(0x1be),'started':_0x17b9ca(0x213),'replied':_0x17b9ca(0x1e0),'expired':_0x17b9ca(0x1bc)}[_0x4eba8e[_0x17b9ca(0x1aa)]],..._0x4eba8e};}function j(_0x490dec){const _0x617563=a0_0x577b69;let _0x93905f=_0x490dec?.[_0x617563(0x201)]||_0x490dec?.[_0x617563(0x1df)]||_0x490dec?.['id'];if(_0x93905f)return String(_0x93905f);let _0x2dea9a=_0x490dec?.[_0x617563(0x1a7)]?.[0x0]?.[_0x617563(0x1da)];if(typeof _0x2dea9a!==_0x617563(0x1c2))return null;try{let _0x3fca06=JSON['parse'](_0x2dea9a);return _0x3fca06?.[_0x617563(0x201)]||_0x3fca06?.['message_id']||_0x3fca06?.['id']||null;}catch{return null;}}async function X(_0x1a92ee,_0x4737ae){const _0x20c12d=a0_0x577b69;let _0x25ec30=_0x4737ae[_0x20c12d(0x214)]??Date[_0x20c12d(0x214)],_0x2035c0=_0x25ec30(),_0x37a68a=(_0x237c55,_0x232690,_0x33c5f2,_0x359542)=>{const _0x13a1aa=_0x20c12d;_0x4737ae['log'](O(U({'from_alias':_0x1a92ee['fromAlias'],'to_alias':_0x1a92ee[_0x13a1aa(0x218)],'task_id':_0x232690,'parent_task_id':_0x1a92ee[_0x13a1aa(0x217)],'network_id':_0x1a92ee[_0x13a1aa(0x1ff)],'transport':_0x1a92ee['transport'],'status':_0x237c55,'duration_ms':_0x25ec30()-_0x2035c0,'lifecycle_tracking':_0x1a92ee['lifecycleTracking'],..._0x33c5f2!==void 0x0?{'error_code':_0x359542||_0x13a1aa(0x1eb),'error_message':N(_0x33c5f2)}:{}})));};_0x37a68a(_0x20c12d(0x1bd),null);try{let _0x46feab=await _0x4737ae[_0x20c12d(0x1c7)](),_0x17c482=j(_0x46feab);if(_0x17c482)_0x37a68a('delivered',_0x17c482);else{if(_0x46feab?.['ok']===!0x1||_0x46feab?.[_0x20c12d(0x1f5)])_0x37a68a(_0x20c12d(0x202),_0x17c482,_0x46feab?.[_0x20c12d(0x1f5)]||_0x20c12d(0x1c3),_0x20c12d(0x1e1));else _0x37a68a(_0x20c12d(0x202),null,_0x20c12d(0x1bf),'missing_task_id');}return _0x46feab;}catch(_0x2bae6d){throw _0x37a68a(_0x20c12d(0x202),null,_0x2bae6d,'send_failed'),_0x2bae6d;}}async function Y(_0x24e6c2,_0x47188e){const _0x25ec22=a0_0x577b69;return X({'fromAlias':_0x24e6c2['fromAlias'],'toAlias':_0x24e6c2[_0x25ec22(0x1ca)],'parentTaskId':_0x24e6c2[_0x25ec22(0x217)]||null,'networkId':_0x24e6c2[_0x25ec22(0x1ff)]||null,'transport':_0x25ec22(0x1e8),'lifecycleTracking':_0x25ec22(0x1d7)},_0x47188e);}class $ extends a0_0x584e76{[a0_0x577b69(0x20c)];[a0_0x577b69(0x1ca)];[a0_0x577b69(0x19e)];['agent'];[a0_0x577b69(0x1c0)];[a0_0x577b69(0x1f6)];[a0_0x577b69(0x1fc)];[a0_0x577b69(0x20f)];[a0_0x577b69(0x1a2)];['running']=!0x1;constructor(_0x1ddd2e){const _0x10d6e6=a0_0x577b69;super();if(this[_0x10d6e6(0x20c)]=_0x1ddd2e[_0x10d6e6(0x20c)][_0x10d6e6(0x1ee)](/\/$/,''),this[_0x10d6e6(0x1ca)]=_0x1ddd2e[_0x10d6e6(0x1ca)],this[_0x10d6e6(0x19e)]=_0x1ddd2e[_0x10d6e6(0x19e)],this[_0x10d6e6(0x1b4)]=_0x1ddd2e[_0x10d6e6(0x1b4)]||_0x10d6e6(0x1d4),this[_0x10d6e6(0x1c0)]=_0x10d6e6(0x1db)+_0x1ddd2e[_0x10d6e6(0x1ca)]+'-'+Date[_0x10d6e6(0x214)]()[_0x10d6e6(0x19d)](0x24),this[_0x10d6e6(0x1f6)]=_0x1ddd2e['heartbeatInterval']??0x2bf20,this[_0x10d6e6(0x1fc)]=_0x1ddd2e[_0x10d6e6(0x1fc)]??0xbb8,_0x1ddd2e[_0x10d6e6(0x1e3)]!==!0x1)this['connect']();}[a0_0x577b69(0x207)](_0x233716){const _0x55f45c=a0_0x577b69;console[_0x55f45c(0x207)]('['+new Date()[_0x55f45c(0x1f2)]()[_0x55f45c(0x1d8)](0x0,0x8)+']\x20[commhub:'+this[_0x55f45c(0x1ca)]+']\x20'+_0x233716);}async[a0_0x577b69(0x1fd)](_0x39d366,_0x2c9ec8){const _0x2af9b3=a0_0x577b69;let _0x479873={'Content-Type':'application/json','Accept':'application/json,\x20text/event-stream'};if(this['token'])_0x479873[_0x2af9b3(0x1fb)]='Bearer\x20'+this[_0x2af9b3(0x19e)];let _0x3ee8d7=await(await fetch(this[_0x2af9b3(0x20c)]+_0x2af9b3(0x1ec),{'method':_0x2af9b3(0x1e6),'headers':_0x479873,'body':JSON['stringify']({'jsonrpc':_0x2af9b3(0x208),'id':Date['now'](),'method':'tools/call','params':{'name':_0x39d366,'arguments':_0x2c9ec8}})}))[_0x2af9b3(0x1da)](),_0x310d55=_0x3ee8d7[_0x2af9b3(0x1af)](/data: (.+)/),_0x364759=_0x310d55?JSON['parse'](_0x310d55[0x1]):JSON[_0x2af9b3(0x1b7)](_0x3ee8d7),_0xd3e005=_0x364759?.[_0x2af9b3(0x1c8)]?.[_0x2af9b3(0x1a7)]?.[0x0]?.['text'];return _0xd3e005?JSON['parse'](_0xd3e005):_0x364759;}async['connect'](){const _0x2f3304=a0_0x577b69;if(this[_0x2f3304(0x1e7)])return;this[_0x2f3304(0x1e7)]=!0x0,await this[_0x2f3304(0x1aa)](_0x2f3304(0x1f8)),this[_0x2f3304(0x207)](_0x2f3304(0x1ef)),this[_0x2f3304(0x20f)]=setInterval(()=>{const _0x1f04d4=_0x2f3304;this[_0x1f04d4(0x1aa)]('idle')[_0x1f04d4(0x215)](_0x561df1=>this['log'](_0x1f04d4(0x1e4)+_0x561df1['message']));},this[_0x2f3304(0x1f6)]),this['connectSSE']();}async[a0_0x577b69(0x1f1)](){const _0x3b4407=a0_0x577b69;if(this['running']=!0x1,this[_0x3b4407(0x1a2)]?.[_0x3b4407(0x200)](),this['heartbeatTimer'])clearInterval(this['heartbeatTimer']);await this[_0x3b4407(0x1aa)](_0x3b4407(0x1cf))[_0x3b4407(0x215)](()=>{}),this['log'](_0x3b4407(0x1ab));}async['send'](_0x11389e,_0x1c8bee,_0x26a91c=a0_0x577b69(0x1d2)){const _0x4eec0a=a0_0x577b69;return Y({'alias':_0x11389e,'fromAlias':this[_0x4eec0a(0x1ca)]},{'log':_0x1d5c27=>console['log'](_0x1d5c27),'send':()=>this['call']('send_task',{'alias':_0x11389e,'task':_0x1c8bee,'priority':_0x26a91c,'from_session':this[_0x4eec0a(0x1ca)]})});}async[a0_0x577b69(0x21a)](_0x5c20c3,_0x426b16){const _0x155e40=a0_0x577b69;return this[_0x155e40(0x1fd)](_0x155e40(0x1f9),{'alias':_0x5c20c3,'message':_0x426b16,'from_session':this['alias']});}async[a0_0x577b69(0x1b2)](_0x49cd76,_0x118194,_0x5c08e2=a0_0x577b69(0x1a5)){const _0x2344b1=a0_0x577b69;return this['call'](_0x2344b1(0x1b6),{'in_reply_to':_0x49cd76,'text':_0x118194,'status':_0x5c08e2});}async[a0_0x577b69(0x1aa)](_0x3d4165,_0x440a3d){const _0x4e911e=a0_0x577b69;return this[_0x4e911e(0x1fd)](_0x4e911e(0x1f3),{'resume_id':this[_0x4e911e(0x1c0)],'alias':this['alias'],'status':_0x3d4165,'server':a0_0x149386(),'hostname':a0_0x149386(),'agent':this['agent'],'project_dir':process[_0x4e911e(0x210)](),..._0x440a3d});}async[a0_0x577b69(0x1b9)](){const _0x320b6b=a0_0x577b69;return this['call'](_0x320b6b(0x1d0),{});}async[a0_0x577b69(0x1d9)](_0x150291,_0x3c5711){const _0x51d55f=a0_0x577b69;return this[_0x51d55f(0x1fd)](_0x51d55f(0x1d9),{'message':_0x150291,'filter_server':_0x3c5711?.[_0x51d55f(0x1e5)],'filter_status':_0x3c5711?.['status']});}async['connectSSE'](){const _0x305a0e=a0_0x577b69;let _0x33cd9d=encodeURIComponent(this[_0x305a0e(0x1ca)]),_0x23be1f=this[_0x305a0e(0x20c)]+_0x305a0e(0x1a9)+_0x33cd9d,_0x3ffa8d=this['reconnectDelay'];while(this['running']){try{this['sseAbort']=new AbortController();let _0x27303e={'Accept':_0x305a0e(0x1ce)};if(this[_0x305a0e(0x19e)])_0x27303e['Authorization']=_0x305a0e(0x1ea)+this[_0x305a0e(0x19e)];let _0x23fb7f=await fetch(_0x23be1f,{'headers':_0x27303e,'signal':this[_0x305a0e(0x1a2)][_0x305a0e(0x1cd)]});if(!_0x23fb7f['ok']||!_0x23fb7f[_0x305a0e(0x1b3)]){this[_0x305a0e(0x207)](_0x305a0e(0x1c5)+_0x23fb7f[_0x305a0e(0x1aa)]),await this[_0x305a0e(0x1fe)](_0x3ffa8d),_0x3ffa8d=Math['min'](_0x3ffa8d*1.5,0xea60);continue;}_0x3ffa8d=this[_0x305a0e(0x1fc)];let _0x232539=_0x23fb7f[_0x305a0e(0x1b3)][_0x305a0e(0x21b)](),_0xc9fa69=new TextDecoder(),_0x3338fb='';while(this['running']){let {done:_0x125a20,value:_0x171d2b}=await _0x232539['read']();if(_0x125a20)break;_0x3338fb+=_0xc9fa69[_0x305a0e(0x19f)](_0x171d2b,{'stream':!0x0});let _0x497714=_0x3338fb[_0x305a0e(0x1c6)]('\x0a');_0x3338fb=_0x497714['pop']()||'';for(let _0x3c85dc of _0x497714){if(!_0x3c85dc['startsWith'](_0x305a0e(0x1a4)))continue;try{let _0x38e7f1=JSON[_0x305a0e(0x1b7)](_0x3c85dc[_0x305a0e(0x1d8)](0x6));if(_0x38e7f1[_0x305a0e(0x1de)]===_0x305a0e(0x1a8)){this[_0x305a0e(0x207)](_0x305a0e(0x219)),this['emit']('connected');continue;}if(_0x38e7f1[_0x305a0e(0x1de)]==='new_task'||_0x38e7f1[_0x305a0e(0x1de)]===_0x305a0e(0x20d)||_0x38e7f1[_0x305a0e(0x1de)]===_0x305a0e(0x1d9))await this[_0x305a0e(0x1cb)]();}catch{}}}}catch(_0x23efec){if(_0x23efec[_0x305a0e(0x216)]===_0x305a0e(0x1e2))break;this[_0x305a0e(0x1f7)](_0x305a0e(0x1f5),_0x23efec),this['log']('SSE\x20error:\x20'+_0x23efec['message']);}if(this['running'])this[_0x305a0e(0x1f7)](_0x305a0e(0x1ab)),this['log'](_0x305a0e(0x1a6)+_0x3ffa8d/0x3e8+_0x305a0e(0x209)),await this['sleep'](_0x3ffa8d),_0x3ffa8d=Math['min'](_0x3ffa8d*1.5,0xea60);}}async[a0_0x577b69(0x1cb)](){const _0x1444cd=a0_0x577b69;try{let _0x3830ff=(await this['call'](_0x1444cd(0x1b1),{'alias':this['alias'],'limit':0xa}))?.[_0x1444cd(0x1cc)]||[];for(let _0x58b765 of _0x3830ff)await this[_0x1444cd(0x1fd)]('ack_inbox',{'alias':this['alias'],'message_id':_0x58b765['id']}),this['log']('←\x20'+_0x58b765[_0x1444cd(0x20e)]+':\x20'+_0x58b765[_0x1444cd(0x1a7)]['slice'](0x0,0x3c)),this[_0x1444cd(0x1f7)](_0x1444cd(0x1ac),_0x58b765),this['emit'](_0x1444cd(0x21a),_0x58b765);}catch(_0x3d00d8){this[_0x1444cd(0x207)](_0x1444cd(0x1ed)+_0x3d00d8[_0x1444cd(0x21a)]);}}['sleep'](_0x5cb3d2){return new Promise(_0x1be77b=>setTimeout(_0x1be77b,_0x5cb3d2));}}var F=$;export{F as default,$ as CommHub};
|
|
1
|
+
const a0_0x5ec272=a0_0x5870;(function(_0xfdbf93,_0xe25e3b){const _0x149a27=a0_0x5870,_0x1735d9=_0xfdbf93();while(!![]){try{const _0x31e076=-parseInt(_0x149a27(0xec))/0x1+-parseInt(_0x149a27(0x94))/0x2*(-parseInt(_0x149a27(0x100))/0x3)+-parseInt(_0x149a27(0x9f))/0x4*(parseInt(_0x149a27(0xa3))/0x5)+parseInt(_0x149a27(0xb2))/0x6*(-parseInt(_0x149a27(0x8c))/0x7)+-parseInt(_0x149a27(0xdb))/0x8*(-parseInt(_0x149a27(0xc2))/0x9)+parseInt(_0x149a27(0xad))/0xa+-parseInt(_0x149a27(0xfe))/0xb*(parseInt(_0x149a27(0xf4))/0xc);if(_0x31e076===_0xe25e3b)break;else _0x1735d9['push'](_0x1735d9['shift']());}catch(_0x2b5b39){_0x1735d9['push'](_0x1735d9['shift']());}}}(a0_0x554b,0x26127));import{EventEmitter as a0_0x5be294}from'events';import{hostname as a0_0x46b32d}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x2fc60a,_0x56a94b)=>(_0x2fc60a??_0x56a94b)[a0_0x5ec272(0xd6)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x5ec272(0xfc)](0x0,0xf0);function N(_0x36881d){const _0x31638b=a0_0x5ec272;return(_0x36881d instanceof Error?_0x36881d[_0x31638b(0xe2)]:String(_0x36881d??_0x31638b(0xe1)))[_0x31638b(0xd6)](K,_0x31638b(0xcd))[_0x31638b(0xd6)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x5d8a0b,_0x339b7c=process.env.ANET_TASK_TRACE_FORMAT===a0_0x5ec272(0xca)){const _0x539c72=a0_0x5ec272;if(_0x339b7c)return JSON[_0x539c72(0xd1)](_0x5d8a0b);let _0x4608ac=L(_0x5d8a0b[_0x539c72(0xb0)],_0x539c72(0xa7)),_0x328e94=L(_0x5d8a0b[_0x539c72(0xb9)],'<pending>'),_0x4c7cf3=_0x5d8a0b[_0x539c72(0xd9)]?_0x539c72(0xdf)+_0x5d8a0b['error_code']+':'+(_0x5d8a0b[_0x539c72(0x8b)]??''):'';return _0x539c72(0x9e)+_0x5d8a0b['status']+_0x539c72(0xa1)+L(_0x5d8a0b[_0x539c72(0xe0)],_0x539c72(0x103))+_0x539c72(0x9a)+L(_0x5d8a0b['to_alias'],'<unknown>')+_0x539c72(0x102)+_0x328e94+_0x539c72(0xab)+_0x4608ac+_0x539c72(0xd0)+L(_0x5d8a0b[_0x539c72(0xbf)],'<unknown>')+_0x539c72(0xd7)+_0x5d8a0b[_0x539c72(0xe8)]+'\x20duration_ms='+_0x5d8a0b['duration_ms']+'\x20lifecycle='+_0x5d8a0b['lifecycle_tracking']+_0x4c7cf3;}function U(_0x142a7d){const _0x4913bf=a0_0x5ec272;return{'event':{'sending':_0x4913bf(0xc7),'delivered':_0x4913bf(0xf3),'failed':'task.send.failed','acked':_0x4913bf(0x8d),'started':_0x4913bf(0x98),'replied':'task.replied','expired':'task.expired'}[_0x142a7d[_0x4913bf(0xa4)]],..._0x142a7d};}function j(_0x1c5541){const _0x108d1a=a0_0x5ec272;let _0x408326=_0x1c5541?.[_0x108d1a(0xb9)]||_0x1c5541?.[_0x108d1a(0xef)]||_0x1c5541?.['id'];if(_0x408326)return String(_0x408326);let _0x8fd15f=_0x1c5541?.[_0x108d1a(0xff)]?.[0x0]?.[_0x108d1a(0xc8)];if(typeof _0x8fd15f!==_0x108d1a(0xbb))return null;try{let _0x4e8abe=JSON[_0x108d1a(0xf8)](_0x8fd15f);return _0x4e8abe?.[_0x108d1a(0xb9)]||_0x4e8abe?.[_0x108d1a(0xef)]||_0x4e8abe?.['id']||null;}catch{return null;}}async function X(_0x18a707,_0x796787){const _0x378e45=a0_0x5ec272;let _0xc257a9=_0x796787[_0x378e45(0xa0)]??Date[_0x378e45(0xa0)],_0x8e1d97=_0xc257a9(),_0x591daa=(_0x235864,_0x1274cf,_0x1b3b91,_0x14b6aa)=>{const _0x7c3f7=_0x378e45;_0x796787[_0x7c3f7(0x95)](O(U({'from_alias':_0x18a707[_0x7c3f7(0xe9)],'to_alias':_0x18a707[_0x7c3f7(0xbc)],'task_id':_0x1274cf,'parent_task_id':_0x18a707[_0x7c3f7(0xac)],'network_id':_0x18a707[_0x7c3f7(0x88)],'transport':_0x18a707[_0x7c3f7(0xe8)],'status':_0x235864,'duration_ms':_0xc257a9()-_0x8e1d97,'lifecycle_tracking':_0x18a707[_0x7c3f7(0x86)],..._0x1b3b91!==void 0x0?{'error_code':_0x14b6aa||_0x7c3f7(0xc5),'error_message':N(_0x1b3b91)}:{}})));};_0x591daa(_0x378e45(0xa8),null);try{let _0x413eaf=await _0x796787['send'](),_0x19c974=j(_0x413eaf);if(_0x19c974)_0x591daa(_0x378e45(0x89),_0x19c974);else{if(_0x413eaf?.['ok']===!0x1||_0x413eaf?.[_0x378e45(0xd8)])_0x591daa(_0x378e45(0xcc),_0x19c974,_0x413eaf?.[_0x378e45(0xd8)]||_0x378e45(0xa5),_0x378e45(0xe6));else _0x591daa('failed',null,_0x378e45(0xb4),_0x378e45(0xf5));}return _0x413eaf;}catch(_0xe472ab){throw _0x591daa(_0x378e45(0xcc),null,_0xe472ab,_0x378e45(0xc5)),_0xe472ab;}}async function Y(_0x42a1f4,_0xb46013){const _0x4de3d0=a0_0x5ec272;return X({'fromAlias':_0x42a1f4[_0x4de3d0(0xe9)],'toAlias':_0x42a1f4[_0x4de3d0(0x93)],'parentTaskId':_0x42a1f4['parentTaskId']||null,'networkId':_0x42a1f4[_0x4de3d0(0x88)]||null,'transport':_0x4de3d0(0xeb),'lifecycleTracking':_0x4de3d0(0xb6)},_0xb46013);}class $ extends a0_0x5be294{['url'];[a0_0x5ec272(0x93)];['token'];[a0_0x5ec272(0xf2)];[a0_0x5ec272(0xf0)];['heartbeatInterval'];['reconnectDelay'];[a0_0x5ec272(0x104)];[a0_0x5ec272(0x8a)];[a0_0x5ec272(0xcf)]=!0x1;constructor(_0x2781b0){const _0x19ee23=a0_0x5ec272;super();if(this['url']=_0x2781b0[_0x19ee23(0xf7)][_0x19ee23(0xd6)](/\/$/,''),this[_0x19ee23(0x93)]=_0x2781b0['alias'],this[_0x19ee23(0xb8)]=_0x2781b0['token'],this[_0x19ee23(0xf2)]=_0x2781b0['agent']||_0x19ee23(0xb3),this[_0x19ee23(0xf0)]=_0x19ee23(0xda)+_0x2781b0[_0x19ee23(0x93)]+'-'+Date['now']()[_0x19ee23(0xaf)](0x24),this[_0x19ee23(0xd4)]=_0x2781b0[_0x19ee23(0xd4)]??0x2bf20,this[_0x19ee23(0xfd)]=_0x2781b0['reconnectDelay']??0xbb8,_0x2781b0[_0x19ee23(0xd5)]!==!0x1)this['connect']();}[a0_0x5ec272(0x95)](_0x56f6b9){const _0x30e268=a0_0x5ec272;console['log']('['+new Date()['toTimeString']()['slice'](0x0,0x8)+_0x30e268(0xc3)+this[_0x30e268(0x93)]+']\x20'+_0x56f6b9);}async[a0_0x5ec272(0xde)](_0x4396af,_0x500efc){const _0x29872f=a0_0x5ec272;let _0x3bcdfd={'Content-Type':'application/json','Accept':_0x29872f(0xe7)};if(this[_0x29872f(0xb8)])_0x3bcdfd[_0x29872f(0xcb)]=_0x29872f(0xfb)+this[_0x29872f(0xb8)];let _0x1a0a25=await(await fetch(this['url']+_0x29872f(0x106),{'method':_0x29872f(0xa9),'headers':_0x3bcdfd,'body':JSON[_0x29872f(0xd1)]({'jsonrpc':_0x29872f(0xe5),'id':Date[_0x29872f(0xa0)](),'method':'tools/call','params':{'name':_0x4396af,'arguments':_0x500efc}})}))['text'](),_0x228e59=_0x1a0a25['match'](/data: (.+)/),_0x41bdd2=_0x228e59?JSON[_0x29872f(0xf8)](_0x228e59[0x1]):JSON[_0x29872f(0xf8)](_0x1a0a25),_0x55dc38=_0x41bdd2?.['result']?.[_0x29872f(0xff)]?.[0x0]?.[_0x29872f(0xc8)];return _0x55dc38?JSON[_0x29872f(0xf8)](_0x55dc38):_0x41bdd2;}async[a0_0x5ec272(0xb5)](){const _0x5113a9=a0_0x5ec272;if(this[_0x5113a9(0xcf)])return;this[_0x5113a9(0xcf)]=!0x0,await this[_0x5113a9(0xa4)](_0x5113a9(0x9d)),this[_0x5113a9(0x95)](_0x5113a9(0xee)),this['heartbeatTimer']=setInterval(()=>{const _0x3bf35b=_0x5113a9;this[_0x3bf35b(0xa4)](_0x3bf35b(0x9d))['catch'](_0x26ef42=>this[_0x3bf35b(0x95)](_0x3bf35b(0xc4)+_0x26ef42[_0x3bf35b(0xe2)]));},this[_0x5113a9(0xd4)]),this[_0x5113a9(0xbd)]();}async[a0_0x5ec272(0xfa)](){const _0x11d220=a0_0x5ec272;if(this['running']=!0x1,this[_0x11d220(0x8a)]?.[_0x11d220(0x99)](),this[_0x11d220(0x104)])clearInterval(this[_0x11d220(0x104)]);await this[_0x11d220(0xa4)](_0x11d220(0xc0))['catch'](()=>{}),this['log']('disconnected');}async[a0_0x5ec272(0xae)](_0x1eebf5,_0xcd0787,_0x3e97f4=a0_0x5ec272(0x91)){const _0x45c51f=a0_0x5ec272;return Y({'alias':_0x1eebf5,'fromAlias':this[_0x45c51f(0x93)]},{'log':_0x40fb12=>console[_0x45c51f(0x95)](_0x40fb12),'send':()=>this[_0x45c51f(0xde)](_0x45c51f(0xb1),{'alias':_0x1eebf5,'task':_0xcd0787,'priority':_0x3e97f4,'from_session':this[_0x45c51f(0x93)]})});}async['message'](_0x8fcbaf,_0x159910){const _0x491270=a0_0x5ec272;return this[_0x491270(0xde)](_0x491270(0xa2),{'alias':_0x8fcbaf,'message':_0x159910,'from_session':this[_0x491270(0x93)]});}async[a0_0x5ec272(0xdc)](_0x2f4384,_0x2dbbaa,_0x46b5ca=a0_0x5ec272(0x101)){const _0x39ed41=a0_0x5ec272;return this[_0x39ed41(0xde)]('send_reply',{'in_reply_to':_0x2f4384,'text':_0x2dbbaa,'status':_0x46b5ca});}async[a0_0x5ec272(0xa4)](_0x3d4567,_0x5577b7){const _0x5d8173=a0_0x5ec272;return this[_0x5d8173(0xde)](_0x5d8173(0x92),{'resume_id':this[_0x5d8173(0xf0)],'alias':this[_0x5d8173(0x93)],'status':_0x3d4567,'server':a0_0x46b32d(),'hostname':a0_0x46b32d(),'agent':this[_0x5d8173(0xf2)],'project_dir':process['cwd'](),..._0x5577b7});}async[a0_0x5ec272(0xed)](){const _0x3fc00c=a0_0x5ec272;return this[_0x3fc00c(0xde)]('get_all_status',{});}async['broadcast'](_0x22c3e2,_0x294d83){const _0x241fd7=a0_0x5ec272;return this['call'](_0x241fd7(0x9b),{'message':_0x22c3e2,'filter_server':_0x294d83?.[_0x241fd7(0x87)],'filter_status':_0x294d83?.['status']});}async[a0_0x5ec272(0xbd)](){const _0x4065e6=a0_0x5ec272;let _0x4852ae=encodeURIComponent(this['alias']),_0x5e05cd=this[_0x4065e6(0xf7)]+'/events/'+_0x4852ae,_0x332108=this[_0x4065e6(0xfd)];while(this[_0x4065e6(0xcf)]){try{this[_0x4065e6(0x8a)]=new AbortController();let _0x152751={'Accept':_0x4065e6(0x105)};if(this[_0x4065e6(0xb8)])_0x152751[_0x4065e6(0xcb)]=_0x4065e6(0xfb)+this[_0x4065e6(0xb8)];let _0x332e97=await fetch(_0x5e05cd,{'headers':_0x152751,'signal':this[_0x4065e6(0x8a)][_0x4065e6(0xc6)]});if(!_0x332e97['ok']||!_0x332e97[_0x4065e6(0xc1)]){this[_0x4065e6(0x95)](_0x4065e6(0x96)+_0x332e97[_0x4065e6(0xa4)]),await this[_0x4065e6(0x97)](_0x332108),_0x332108=Math['min'](_0x332108*1.5,0xea60);continue;}_0x332108=this[_0x4065e6(0xfd)];let _0x3c429c=_0x332e97[_0x4065e6(0xc1)][_0x4065e6(0xa6)](),_0x3d84ac=new TextDecoder(),_0x525df9='';while(this[_0x4065e6(0xcf)]){let {done:_0x1e63bf,value:_0x2cac0f}=await _0x3c429c['read']();if(_0x1e63bf)break;_0x525df9+=_0x3d84ac[_0x4065e6(0x8e)](_0x2cac0f,{'stream':!0x0});let _0x153dea=_0x525df9[_0x4065e6(0xbe)]('\x0a');_0x525df9=_0x153dea['pop']()||'';for(let _0x2ed117 of _0x153dea){if(!_0x2ed117['startsWith']('data:\x20'))continue;try{let _0x3dd6fd=JSON[_0x4065e6(0xf8)](_0x2ed117[_0x4065e6(0xfc)](0x6));if(_0x3dd6fd[_0x4065e6(0xc9)]==='connected'){this[_0x4065e6(0x95)](_0x4065e6(0xce)),this[_0x4065e6(0x90)]('connected');continue;}if(_0x3dd6fd['type']==='new_task'||_0x3dd6fd['type']===_0x4065e6(0x8f)||_0x3dd6fd[_0x4065e6(0xc9)]==='broadcast')await this[_0x4065e6(0xd2)]();}catch{}}}}catch(_0x2faecf){if(_0x2faecf[_0x4065e6(0xf1)]==='AbortError')break;this[_0x4065e6(0x90)]('error',_0x2faecf),this[_0x4065e6(0x95)](_0x4065e6(0xdd)+_0x2faecf[_0x4065e6(0xe2)]);}if(this[_0x4065e6(0xcf)])this[_0x4065e6(0x90)](_0x4065e6(0x9c)),this[_0x4065e6(0x95)](_0x4065e6(0xd3)+_0x332108/0x3e8+_0x4065e6(0xf9)),await this[_0x4065e6(0x97)](_0x332108),_0x332108=Math[_0x4065e6(0xe4)](_0x332108*1.5,0xea60);}}async[a0_0x5ec272(0xd2)](){const _0x12024b=a0_0x5ec272;try{let _0x5f45dd=(await this[_0x12024b(0xde)](_0x12024b(0xf6),{'alias':this['alias'],'limit':0xa}))?.[_0x12024b(0xb7)]||[];for(let _0x42cf26 of _0x5f45dd)await this[_0x12024b(0xde)](_0x12024b(0xba),{'alias':this[_0x12024b(0x93)],'message_id':_0x42cf26['id']}),this[_0x12024b(0x95)]('←\x20'+_0x42cf26[_0x12024b(0xea)]+':\x20'+_0x42cf26[_0x12024b(0xff)]['slice'](0x0,0x3c)),this[_0x12024b(0x90)](_0x12024b(0xe3),_0x42cf26),this['emit'](_0x12024b(0xe2),_0x42cf26);}catch(_0x12a0f5){this['log'](_0x12024b(0xaa)+_0x12a0f5[_0x12024b(0xe2)]);}}[a0_0x5ec272(0x97)](_0x2966ce){return new Promise(_0x1ffb37=>setTimeout(_0x1ffb37,_0x2966ce));}}var F=$;export{F as default,$ as CommHub};function a0_0x5870(_0x4d8925,_0x1ab951){_0x4d8925=_0x4d8925-0x86;const _0x554bde=a0_0x554b();let _0x587029=_0x554bde[_0x4d8925];return _0x587029;}function a0_0x554b(){const _0x150e06=['\x20task_id=','<unknown>','heartbeatTimer','text/event-stream','/mcp','lifecycleTracking','server','networkId','delivered','sseAbort','error_message','22449QHvGeY','task.ack','decode','new_message','emit','normal','report_status','alias','4208zzbKwR','log','SSE\x20failed:\x20','sleep','task.started','abort','\x20to=','broadcast','disconnected','idle','[commhub:task]\x20','16gePiDu','now','\x20from=','send_message','28850VBgVld','status','CommHub\x20rejected\x20task','getReader','<missing>','sending','POST','inbox\x20error:\x20','\x20parent_task_id=','parentTaskId','1300210bwrKnh','send','toString','parent_task_id','send_task','174TkRmgN','sdk','CommHub\x20response\x20omitted\x20task_id','connect','not_tracked','messages','token','task_id','ack_inbox','string','toAlias','connectSSE','split','network_id','offline','body','342BXBnnc',']\x20[commhub:','heartbeat\x20failed:\x20','send_failed','signal','task.send.start','text','type','json','Authorization','failed','[REDACTED]','SSE\x20connected','running','\x20network_id=','stringify','processInbox','SSE\x20reconnecting\x20in\x20','heartbeatInterval','autoConnect','replace','\x20transport=','error','error_code','sdk-','62232UaJwAA','reply','SSE\x20error:\x20','call','\x20error=','from_alias','unknown\x20error','message','task','min','2.0','send_rejected','application/json,\x20text/event-stream','transport','fromAlias','from_session','mcp_http','70057tGoBYt','getAllStatus','registered','message_id','resumeId','name','agent','task.send.delivered','12iZSEVR','missing_task_id','get_inbox','url','parse','s...','disconnect','Bearer\x20','slice','reconnectDelay','3094476UrVbFl','content','282wPDNHw','completed'];a0_0x554b=function(){return _0x150e06;};return a0_0x554b();}
|