@sleep2agi/agent-network 2.3.0-preview.51 → 2.3.0-preview.52
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_0x1006a0=a0_0x85dc;(function(_0x208670,_0x5dca58){const _0x25dcf2=a0_0x85dc,_0x2c43d7=_0x208670();while(!![]){try{const _0x1089f5=parseInt(_0x25dcf2(0xff))/0x1*(parseInt(_0x25dcf2(0x11d))/0x2)+parseInt(_0x25dcf2(0xae))/0x3+-parseInt(_0x25dcf2(0xf0))/0x4*(-parseInt(_0x25dcf2(0x9f))/0x5)+parseInt(_0x25dcf2(0xe1))/0x6*(-parseInt(_0x25dcf2(0xc6))/0x7)+parseInt(_0x25dcf2(0x106))/0x8*(-parseInt(_0x25dcf2(0xab))/0x9)+-parseInt(_0x25dcf2(0xb3))/0xa+-parseInt(_0x25dcf2(0xf1))/0xb*(-parseInt(_0x25dcf2(0xa9))/0xc);if(_0x1089f5===_0x5dca58)break;else _0x2c43d7['push'](_0x2c43d7['shift']());}catch(_0x4a24ba){_0x2c43d7['push'](_0x2c43d7['shift']());}}}(a0_0x4288,0xb5193));import{EventEmitter as a0_0x32e1ff}from'events';import{hostname as a0_0x47dd29}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0xe9357d,_0x228e18)=>(_0xe9357d??_0x228e18)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x1006a0(0xc3)](0x0,0xf0);function a0_0x85dc(_0xe60acb,_0x21e998){_0xe60acb=_0xe60acb-0x9e;const _0x42880e=a0_0x4288();let _0x85dc20=_0x42880e[_0xe60acb];return _0x85dc20;}function N(_0x3ff431){const _0x40b239=a0_0x1006a0;return(_0x3ff431 instanceof Error?_0x3ff431[_0x40b239(0xf4)]:String(_0x3ff431??_0x40b239(0xa0)))[_0x40b239(0xc5)](K,_0x40b239(0x10f))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x37a72c,_0x574131=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0xfe5d8a=a0_0x1006a0;if(_0x574131)return JSON[_0xfe5d8a(0xa5)](_0x37a72c);let _0x77808f=L(_0x37a72c[_0xfe5d8a(0x9e)],_0xfe5d8a(0xfe)),_0x1466a6=L(_0x37a72c[_0xfe5d8a(0xfb)],_0xfe5d8a(0x117)),_0x343f62=_0x37a72c[_0xfe5d8a(0xd6)]?_0xfe5d8a(0xe0)+_0x37a72c[_0xfe5d8a(0xd6)]+':'+(_0x37a72c[_0xfe5d8a(0x118)]??''):'';return _0xfe5d8a(0xcd)+_0x37a72c[_0xfe5d8a(0xe9)]+'\x20from='+L(_0x37a72c[_0xfe5d8a(0x119)],_0xfe5d8a(0xf6))+_0xfe5d8a(0xda)+L(_0x37a72c['to_alias'],_0xfe5d8a(0xf6))+_0xfe5d8a(0x101)+_0x1466a6+'\x20parent_task_id='+_0x77808f+_0xfe5d8a(0xd2)+L(_0x37a72c[_0xfe5d8a(0xea)],_0xfe5d8a(0xf6))+_0xfe5d8a(0x102)+_0x37a72c[_0xfe5d8a(0xb7)]+_0xfe5d8a(0xaa)+_0x37a72c[_0xfe5d8a(0xb4)]+_0xfe5d8a(0xc1)+_0x37a72c['lifecycle_tracking']+_0x343f62;}function U(_0x11d352){const _0x21739a=a0_0x1006a0;return{'event':{'sending':_0x21739a(0xc0),'delivered':_0x21739a(0xdb),'failed':_0x21739a(0xa2),'acked':_0x21739a(0xcf),'started':'task.started','replied':_0x21739a(0x113),'expired':_0x21739a(0xba)}[_0x11d352[_0x21739a(0xe9)]],..._0x11d352};}function j(_0x4ca0fb){const _0x402c7d=a0_0x1006a0;let _0x143246=_0x4ca0fb?.[_0x402c7d(0xfb)]||_0x4ca0fb?.[_0x402c7d(0xe7)]||_0x4ca0fb?.['id'];if(_0x143246)return String(_0x143246);let _0x18df90=_0x4ca0fb?.[_0x402c7d(0xa3)]?.[0x0]?.[_0x402c7d(0x114)];if(typeof _0x18df90!==_0x402c7d(0x10a))return null;try{let _0x1e12c8=JSON[_0x402c7d(0xb8)](_0x18df90);return _0x1e12c8?.['task_id']||_0x1e12c8?.['message_id']||_0x1e12c8?.['id']||null;}catch{return null;}}function a0_0x4288(){const _0x477eb0=['url','send','\x20to=','task.send.delivered','token','decode','toAlias','not_tracked','\x20error=','8173500HqLLQC','type','connectSSE','broadcast','emit','/events/','message_id','send_rejected','status','network_id','agent','body','log','sleep','connected','4DDpqIf','11RzaueB','report_status','sending','message','signal','<unknown>','resumeId','Authorization','fromAlias','text/event-stream','task_id','task','get_all_status','<missing>','82UUJdoz','disconnected','\x20task_id=','\x20transport=','2.0','send_failed','sdk-','8rgCzZq','tools/call','SSE\x20error:\x20','normal','string','reconnectDelay','toTimeString','registered','connect','[REDACTED]','autoConnect','delivered','idle','task.replied','text','offline','min','<pending>','error_message','from_alias','AbortError','s...','getReader','30350CQEAHV','heartbeat\x20failed:\x20','CommHub\x20response\x20omitted\x20task_id','parent_task_id','5223995QBtlae','unknown\x20error','split','task.send.failed','content','abort','stringify','error','disconnect','alias','8005272BYfvKT','\x20duration_ms=','9840429utwAVF','sseAbort','send_message','3206211ImvCTo','SSE\x20reconnecting\x20in\x20','startsWith','reply','sdk','8275820FoMIzD','duration_ms','completed','send_task','transport','parse','catch','task.expired','missing_task_id','application/json','SSE\x20failed:\x20','parentTaskId','mcp_http','task.send.start','\x20lifecycle=','heartbeatInterval','slice','call','replace','7UqfuBk','Bearer\x20','failed','now','server','send_reply','SSE\x20connected','[commhub:task]\x20','processInbox','task.ack','networkId','lifecycleTracking','\x20network_id=','running','heartbeatTimer','messages','error_code','pop'];a0_0x4288=function(){return _0x477eb0;};return a0_0x4288();}async function X(_0x15ee16,_0x19cff7){const _0x353a44=a0_0x1006a0;let _0x1ccf94=_0x19cff7[_0x353a44(0xc9)]??Date[_0x353a44(0xc9)],_0x3334d9=_0x1ccf94(),_0x3648a0=(_0x2315d8,_0x4a8be2,_0xb9db98,_0x1537d0)=>{const _0x261302=_0x353a44;_0x19cff7['log'](O(U({'from_alias':_0x15ee16[_0x261302(0xf9)],'to_alias':_0x15ee16[_0x261302(0xde)],'task_id':_0x4a8be2,'parent_task_id':_0x15ee16['parentTaskId'],'network_id':_0x15ee16[_0x261302(0xd0)],'transport':_0x15ee16['transport'],'status':_0x2315d8,'duration_ms':_0x1ccf94()-_0x3334d9,'lifecycle_tracking':_0x15ee16[_0x261302(0xd1)],..._0xb9db98!==void 0x0?{'error_code':_0x1537d0||_0x261302(0x104),'error_message':N(_0xb9db98)}:{}})));};_0x3648a0(_0x353a44(0xf3),null);try{let _0x31d7b3=await _0x19cff7[_0x353a44(0xd9)](),_0x3b3d8f=j(_0x31d7b3);if(_0x3b3d8f)_0x3648a0(_0x353a44(0x111),_0x3b3d8f);else{if(_0x31d7b3?.['ok']===!0x1||_0x31d7b3?.[_0x353a44(0xa6)])_0x3648a0(_0x353a44(0xc8),_0x3b3d8f,_0x31d7b3?.[_0x353a44(0xa6)]||'CommHub\x20rejected\x20task',_0x353a44(0xe8));else _0x3648a0(_0x353a44(0xc8),null,_0x353a44(0x11f),_0x353a44(0xbb));}return _0x31d7b3;}catch(_0x51542c){throw _0x3648a0(_0x353a44(0xc8),null,_0x51542c,'send_failed'),_0x51542c;}}async function Y(_0x1ebf31,_0x33e7fb){const _0x591da7=a0_0x1006a0;return X({'fromAlias':_0x1ebf31['fromAlias'],'toAlias':_0x1ebf31[_0x591da7(0xa8)],'parentTaskId':_0x1ebf31[_0x591da7(0xbe)]||null,'networkId':_0x1ebf31[_0x591da7(0xd0)]||null,'transport':_0x591da7(0xbf),'lifecycleTracking':_0x591da7(0xdf)},_0x33e7fb);}class $ extends a0_0x32e1ff{[a0_0x1006a0(0xd8)];[a0_0x1006a0(0xa8)];['token'];['agent'];[a0_0x1006a0(0xf7)];[a0_0x1006a0(0xc2)];[a0_0x1006a0(0x10b)];[a0_0x1006a0(0xd4)];[a0_0x1006a0(0xac)];['running']=!0x1;constructor(_0x13e493){const _0x20a3de=a0_0x1006a0;super();if(this[_0x20a3de(0xd8)]=_0x13e493[_0x20a3de(0xd8)]['replace'](/\/$/,''),this[_0x20a3de(0xa8)]=_0x13e493[_0x20a3de(0xa8)],this['token']=_0x13e493[_0x20a3de(0xdc)],this[_0x20a3de(0xeb)]=_0x13e493[_0x20a3de(0xeb)]||_0x20a3de(0xb2),this['resumeId']=_0x20a3de(0x105)+_0x13e493[_0x20a3de(0xa8)]+'-'+Date[_0x20a3de(0xc9)]()['toString'](0x24),this[_0x20a3de(0xc2)]=_0x13e493[_0x20a3de(0xc2)]??0x2bf20,this[_0x20a3de(0x10b)]=_0x13e493[_0x20a3de(0x10b)]??0xbb8,_0x13e493[_0x20a3de(0x110)]!==!0x1)this['connect']();}[a0_0x1006a0(0xed)](_0x138aa1){const _0x17afee=a0_0x1006a0;console[_0x17afee(0xed)]('['+new Date()[_0x17afee(0x10c)]()[_0x17afee(0xc3)](0x0,0x8)+']\x20[commhub:'+this[_0x17afee(0xa8)]+']\x20'+_0x138aa1);}async['call'](_0x4b4725,_0xa6014f){const _0x132578=a0_0x1006a0;let _0x2616d4={'Content-Type':_0x132578(0xbc),'Accept':'application/json,\x20text/event-stream'};if(this['token'])_0x2616d4[_0x132578(0xf8)]=_0x132578(0xc7)+this['token'];let _0x40035e=await(await fetch(this['url']+'/mcp',{'method':'POST','headers':_0x2616d4,'body':JSON[_0x132578(0xa5)]({'jsonrpc':_0x132578(0x103),'id':Date['now'](),'method':_0x132578(0x107),'params':{'name':_0x4b4725,'arguments':_0xa6014f}})}))[_0x132578(0x114)](),_0x1519e0=_0x40035e['match'](/data: (.+)/),_0x303d1e=_0x1519e0?JSON[_0x132578(0xb8)](_0x1519e0[0x1]):JSON[_0x132578(0xb8)](_0x40035e),_0x9c78e9=_0x303d1e?.['result']?.[_0x132578(0xa3)]?.[0x0]?.['text'];return _0x9c78e9?JSON[_0x132578(0xb8)](_0x9c78e9):_0x303d1e;}async[a0_0x1006a0(0x10e)](){const _0x4bf6f5=a0_0x1006a0;if(this['running'])return;this[_0x4bf6f5(0xd3)]=!0x0,await this['status'](_0x4bf6f5(0x112)),this[_0x4bf6f5(0xed)](_0x4bf6f5(0x10d)),this[_0x4bf6f5(0xd4)]=setInterval(()=>{const _0x536c99=_0x4bf6f5;this[_0x536c99(0xe9)](_0x536c99(0x112))[_0x536c99(0xb9)](_0x58bf0f=>this[_0x536c99(0xed)](_0x536c99(0x11e)+_0x58bf0f[_0x536c99(0xf4)]));},this[_0x4bf6f5(0xc2)]),this[_0x4bf6f5(0xe3)]();}async[a0_0x1006a0(0xa7)](){const _0x51ffce=a0_0x1006a0;if(this[_0x51ffce(0xd3)]=!0x1,this['sseAbort']?.[_0x51ffce(0xa4)](),this[_0x51ffce(0xd4)])clearInterval(this[_0x51ffce(0xd4)]);await this['status'](_0x51ffce(0x115))[_0x51ffce(0xb9)](()=>{}),this[_0x51ffce(0xed)](_0x51ffce(0x100));}async[a0_0x1006a0(0xd9)](_0x491c27,_0x257739,_0x193cc9=a0_0x1006a0(0x109)){const _0x2581f7=a0_0x1006a0;return Y({'alias':_0x491c27,'fromAlias':this['alias']},{'log':_0x609c42=>console[_0x2581f7(0xed)](_0x609c42),'send':()=>this[_0x2581f7(0xc4)](_0x2581f7(0xb6),{'alias':_0x491c27,'task':_0x257739,'priority':_0x193cc9,'from_session':this[_0x2581f7(0xa8)]})});}async[a0_0x1006a0(0xf4)](_0x1b71e8,_0x3ffc4b){const _0x47c960=a0_0x1006a0;return this[_0x47c960(0xc4)](_0x47c960(0xad),{'alias':_0x1b71e8,'message':_0x3ffc4b,'from_session':this['alias']});}async[a0_0x1006a0(0xb1)](_0x5630c0,_0x30e6ff,_0x1d8051=a0_0x1006a0(0xb5)){const _0x32d5bd=a0_0x1006a0;return this[_0x32d5bd(0xc4)](_0x32d5bd(0xcb),{'in_reply_to':_0x5630c0,'text':_0x30e6ff,'status':_0x1d8051});}async[a0_0x1006a0(0xe9)](_0x5d3b91,_0x4b7a92){const _0x25f374=a0_0x1006a0;return this[_0x25f374(0xc4)](_0x25f374(0xf2),{'resume_id':this[_0x25f374(0xf7)],'alias':this[_0x25f374(0xa8)],'status':_0x5d3b91,'server':a0_0x47dd29(),'hostname':a0_0x47dd29(),'agent':this[_0x25f374(0xeb)],'project_dir':process['cwd'](),..._0x4b7a92});}async['getAllStatus'](){const _0x2bba5e=a0_0x1006a0;return this[_0x2bba5e(0xc4)](_0x2bba5e(0xfd),{});}async['broadcast'](_0x211678,_0x180416){const _0x15fa43=a0_0x1006a0;return this[_0x15fa43(0xc4)](_0x15fa43(0xe4),{'message':_0x211678,'filter_server':_0x180416?.[_0x15fa43(0xca)],'filter_status':_0x180416?.[_0x15fa43(0xe9)]});}async['connectSSE'](){const _0x22cdad=a0_0x1006a0;let _0x14cbb7=encodeURIComponent(this['alias']),_0x1ce789=this[_0x22cdad(0xd8)]+_0x22cdad(0xe6)+_0x14cbb7,_0x2a2ca4=this[_0x22cdad(0x10b)];while(this[_0x22cdad(0xd3)]){try{this['sseAbort']=new AbortController();let _0x2527b3={'Accept':_0x22cdad(0xfa)};if(this['token'])_0x2527b3[_0x22cdad(0xf8)]='Bearer\x20'+this[_0x22cdad(0xdc)];let _0x3ae4a1=await fetch(_0x1ce789,{'headers':_0x2527b3,'signal':this[_0x22cdad(0xac)][_0x22cdad(0xf5)]});if(!_0x3ae4a1['ok']||!_0x3ae4a1['body']){this[_0x22cdad(0xed)](_0x22cdad(0xbd)+_0x3ae4a1['status']),await this['sleep'](_0x2a2ca4),_0x2a2ca4=Math[_0x22cdad(0x116)](_0x2a2ca4*1.5,0xea60);continue;}_0x2a2ca4=this[_0x22cdad(0x10b)];let _0x5e1092=_0x3ae4a1[_0x22cdad(0xec)][_0x22cdad(0x11c)](),_0x480e4f=new TextDecoder(),_0x4ba6ad='';while(this[_0x22cdad(0xd3)]){let {done:_0x28d2ea,value:_0x5ba6fc}=await _0x5e1092['read']();if(_0x28d2ea)break;_0x4ba6ad+=_0x480e4f[_0x22cdad(0xdd)](_0x5ba6fc,{'stream':!0x0});let _0x477cc2=_0x4ba6ad[_0x22cdad(0xa1)]('\x0a');_0x4ba6ad=_0x477cc2[_0x22cdad(0xd7)]()||'';for(let _0x1cf87e of _0x477cc2){if(!_0x1cf87e[_0x22cdad(0xb0)]('data:\x20'))continue;try{let _0x23f6b1=JSON[_0x22cdad(0xb8)](_0x1cf87e[_0x22cdad(0xc3)](0x6));if(_0x23f6b1[_0x22cdad(0xe2)]===_0x22cdad(0xef)){this[_0x22cdad(0xed)](_0x22cdad(0xcc)),this[_0x22cdad(0xe5)](_0x22cdad(0xef));continue;}if(_0x23f6b1[_0x22cdad(0xe2)]==='new_task'||_0x23f6b1[_0x22cdad(0xe2)]==='new_message'||_0x23f6b1[_0x22cdad(0xe2)]===_0x22cdad(0xe4))await this[_0x22cdad(0xce)]();}catch{}}}}catch(_0x34a5e6){if(_0x34a5e6['name']===_0x22cdad(0x11a))break;this[_0x22cdad(0xe5)](_0x22cdad(0xa6),_0x34a5e6),this[_0x22cdad(0xed)](_0x22cdad(0x108)+_0x34a5e6[_0x22cdad(0xf4)]);}if(this[_0x22cdad(0xd3)])this[_0x22cdad(0xe5)](_0x22cdad(0x100)),this['log'](_0x22cdad(0xaf)+_0x2a2ca4/0x3e8+_0x22cdad(0x11b)),await this['sleep'](_0x2a2ca4),_0x2a2ca4=Math['min'](_0x2a2ca4*1.5,0xea60);}}async[a0_0x1006a0(0xce)](){const _0x1a24d5=a0_0x1006a0;try{let _0x153d4c=(await this[_0x1a24d5(0xc4)]('get_inbox',{'alias':this[_0x1a24d5(0xa8)],'limit':0xa}))?.[_0x1a24d5(0xd5)]||[];for(let _0x96e1a9 of _0x153d4c)await this[_0x1a24d5(0xc4)]('ack_inbox',{'alias':this['alias'],'message_id':_0x96e1a9['id']}),this[_0x1a24d5(0xed)]('←\x20'+_0x96e1a9['from_session']+':\x20'+_0x96e1a9[_0x1a24d5(0xa3)][_0x1a24d5(0xc3)](0x0,0x3c)),this[_0x1a24d5(0xe5)](_0x1a24d5(0xfc),_0x96e1a9),this[_0x1a24d5(0xe5)]('message',_0x96e1a9);}catch(_0x54bca5){this['log']('inbox\x20error:\x20'+_0x54bca5['message']);}}[a0_0x1006a0(0xee)](_0x86a539){return new Promise(_0x506156=>setTimeout(_0x506156,_0x86a539));}}var F=$;export{F as default,$ as CommHub};
|
|
1
|
+
function a0_0x372f(_0x11f988,_0x2bdd94){_0x11f988=_0x11f988-0x11e;const _0x13cb4a=a0_0x13cb();let _0x372fb7=_0x13cb4a[_0x11f988];return _0x372fb7;}const a0_0x252a16=a0_0x372f;(function(_0x581b96,_0x2e12b9){const _0x5e9784=a0_0x372f,_0x6a41a2=_0x581b96();while(!![]){try{const _0x37f858=parseInt(_0x5e9784(0x158))/0x1+-parseInt(_0x5e9784(0x19e))/0x2*(-parseInt(_0x5e9784(0x193))/0x3)+parseInt(_0x5e9784(0x14a))/0x4+parseInt(_0x5e9784(0x191))/0x5*(parseInt(_0x5e9784(0x180))/0x6)+-parseInt(_0x5e9784(0x186))/0x7+parseInt(_0x5e9784(0x152))/0x8*(parseInt(_0x5e9784(0x168))/0x9)+-parseInt(_0x5e9784(0x190))/0xa*(parseInt(_0x5e9784(0x13b))/0xb);if(_0x37f858===_0x2e12b9)break;else _0x6a41a2['push'](_0x6a41a2['shift']());}catch(_0x1cbea0){_0x6a41a2['push'](_0x6a41a2['shift']());}}}(a0_0x13cb,0xc69e3));import{EventEmitter as a0_0x45e0d2}from'events';import{hostname as a0_0xbee4e0}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0xdb9f1e,_0x284509)=>(_0xdb9f1e??_0x284509)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x252a16(0x148)](0x0,0xf0);function N(_0x4d3bba){const _0x996ee1=a0_0x252a16;return(_0x4d3bba instanceof Error?_0x4d3bba[_0x996ee1(0x155)]:String(_0x4d3bba??'unknown\x20error'))[_0x996ee1(0x154)](K,_0x996ee1(0x160))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x996ee1(0x148)](0x0,0xf0);}function O(_0xcda38b,_0x301420=process.env.ANET_TASK_TRACE_FORMAT===a0_0x252a16(0x147)){const _0x541087=a0_0x252a16;if(_0x301420)return JSON['stringify'](_0xcda38b);let _0x1a1ebc=L(_0xcda38b[_0x541087(0x16c)],_0x541087(0x17d)),_0x4f728b=L(_0xcda38b[_0x541087(0x139)],_0x541087(0x167)),_0x22e717=_0xcda38b[_0x541087(0x170)]?'\x20error='+_0xcda38b[_0x541087(0x170)]+':'+(_0xcda38b[_0x541087(0x12a)]??''):'';return'[commhub:task]\x20'+_0xcda38b[_0x541087(0x11f)]+_0x541087(0x16a)+L(_0xcda38b[_0x541087(0x175)],'<unknown>')+_0x541087(0x162)+L(_0xcda38b[_0x541087(0x12c)],_0x541087(0x181))+_0x541087(0x135)+_0x4f728b+_0x541087(0x149)+_0x1a1ebc+_0x541087(0x14c)+L(_0xcda38b[_0x541087(0x12f)],_0x541087(0x181))+'\x20transport='+_0xcda38b[_0x541087(0x163)]+_0x541087(0x174)+_0xcda38b[_0x541087(0x142)]+_0x541087(0x187)+_0xcda38b[_0x541087(0x196)]+_0x22e717;}function a0_0x13cb(){const _0x475210=['task.ack','lifecycle_tracking','from_session','inbox\x20error:\x20','fromAlias','POST','CommHub\x20response\x20omitted\x20task_id','completed','parse','1185214xrqEmo','CommHub\x20rejected\x20task','getAllStatus','status','resumeId','error','mcp_http','toString','sleep','normal','disconnected','running','url','missing_task_id','error_message','lifecycleTracking','to_alias','match','connect','network_id','SSE\x20failed:\x20','task.send.failed','application/json','not_tracked','networkId','\x20task_id=','text/event-stream','SSE\x20error:\x20','report_status','task_id','send','11KHflxA','messages','toAlias','application/json,\x20text/event-stream','SSE\x20reconnecting\x20in\x20','task.expired','task','duration_ms','sending','delivered','token','emit','json','slice','\x20parent_task_id=','1109632zBPHGz','reply','\x20network_id=','send_rejected','content','processInbox','/mcp','body','80720leneBb','reconnectDelay','replace','message','Authorization','min','706602FNavrL','pop','message_id','failed','send_message','signal','broadcast','text','[REDACTED]','heartbeatInterval','\x20to=','transport','type','stringify','connectSSE','<pending>','1170hyNiYs','server','\x20from=','now','parent_task_id','AbortError','heartbeatTimer','new_message','error_code','string','agent','toTimeString','\x20duration_ms=','from_alias','get_inbox','cwd','new_task','get_all_status','getReader','s...','sseAbort','<missing>','registered','parentTaskId','12vQbJWK','<unknown>','autoConnect','task.replied','ack_inbox','alias','7592305YHAxdl','\x20lifecycle=','log','data:\x20','connected','task.send.start','sdk','offline','call','decode','17148670ZsOhEf','1811760ffhZgO','Bearer\x20','3PQIlFn','idle'];a0_0x13cb=function(){return _0x475210;};return a0_0x13cb();}function U(_0x4de6e8){const _0x469adf=a0_0x252a16;return{'event':{'sending':_0x469adf(0x18b),'delivered':'task.send.delivered','failed':_0x469adf(0x131),'acked':_0x469adf(0x195),'started':'task.started','replied':_0x469adf(0x183),'expired':_0x469adf(0x140)}[_0x4de6e8[_0x469adf(0x11f)]],..._0x4de6e8};}function j(_0x920b40){const _0x3877a5=a0_0x252a16;let _0x51c9cf=_0x920b40?.[_0x3877a5(0x139)]||_0x920b40?.['message_id']||_0x920b40?.['id'];if(_0x51c9cf)return String(_0x51c9cf);let _0x1020be=_0x920b40?.[_0x3877a5(0x14e)]?.[0x0]?.[_0x3877a5(0x15f)];if(typeof _0x1020be!==_0x3877a5(0x171))return null;try{let _0x87eb6c=JSON['parse'](_0x1020be);return _0x87eb6c?.[_0x3877a5(0x139)]||_0x87eb6c?.[_0x3877a5(0x15a)]||_0x87eb6c?.['id']||null;}catch{return null;}}async function X(_0x3b625a,_0x276011){const _0x2877d2=a0_0x252a16;let _0x5c9b6b=_0x276011[_0x2877d2(0x16b)]??Date[_0x2877d2(0x16b)],_0x96931b=_0x5c9b6b(),_0x250038=(_0x1a6cc8,_0x38b24d,_0x52af77,_0x508709)=>{const _0x33331e=_0x2877d2;_0x276011[_0x33331e(0x188)](O(U({'from_alias':_0x3b625a[_0x33331e(0x199)],'to_alias':_0x3b625a[_0x33331e(0x13d)],'task_id':_0x38b24d,'parent_task_id':_0x3b625a[_0x33331e(0x17f)],'network_id':_0x3b625a['networkId'],'transport':_0x3b625a[_0x33331e(0x163)],'status':_0x1a6cc8,'duration_ms':_0x5c9b6b()-_0x96931b,'lifecycle_tracking':_0x3b625a[_0x33331e(0x12b)],..._0x52af77!==void 0x0?{'error_code':_0x508709||'send_failed','error_message':N(_0x52af77)}:{}})));};_0x250038(_0x2877d2(0x143),null);try{let _0x5f2639=await _0x276011[_0x2877d2(0x13a)](),_0x593971=j(_0x5f2639);if(_0x593971)_0x250038(_0x2877d2(0x144),_0x593971);else{if(_0x5f2639?.['ok']===!0x1||_0x5f2639?.['error'])_0x250038(_0x2877d2(0x15b),_0x593971,_0x5f2639?.[_0x2877d2(0x121)]||_0x2877d2(0x19f),_0x2877d2(0x14d));else _0x250038(_0x2877d2(0x15b),null,_0x2877d2(0x19b),_0x2877d2(0x129));}return _0x5f2639;}catch(_0x4fefbe){throw _0x250038('failed',null,_0x4fefbe,'send_failed'),_0x4fefbe;}}async function Y(_0x3a3d6,_0x79b51a){const _0x4a7beb=a0_0x252a16;return X({'fromAlias':_0x3a3d6[_0x4a7beb(0x199)],'toAlias':_0x3a3d6[_0x4a7beb(0x185)],'parentTaskId':_0x3a3d6[_0x4a7beb(0x17f)]||null,'networkId':_0x3a3d6[_0x4a7beb(0x134)]||null,'transport':_0x4a7beb(0x122),'lifecycleTracking':_0x4a7beb(0x133)},_0x79b51a);}class $ extends a0_0x45e0d2{['url'];[a0_0x252a16(0x185)];[a0_0x252a16(0x145)];[a0_0x252a16(0x172)];[a0_0x252a16(0x120)];[a0_0x252a16(0x161)];['reconnectDelay'];[a0_0x252a16(0x16e)];[a0_0x252a16(0x17c)];[a0_0x252a16(0x127)]=!0x1;constructor(_0x3be9bd){const _0x3ed9e6=a0_0x252a16;super();if(this['url']=_0x3be9bd[_0x3ed9e6(0x128)][_0x3ed9e6(0x154)](/\/$/,''),this[_0x3ed9e6(0x185)]=_0x3be9bd[_0x3ed9e6(0x185)],this[_0x3ed9e6(0x145)]=_0x3be9bd[_0x3ed9e6(0x145)],this[_0x3ed9e6(0x172)]=_0x3be9bd[_0x3ed9e6(0x172)]||_0x3ed9e6(0x18c),this[_0x3ed9e6(0x120)]='sdk-'+_0x3be9bd[_0x3ed9e6(0x185)]+'-'+Date['now']()[_0x3ed9e6(0x123)](0x24),this['heartbeatInterval']=_0x3be9bd[_0x3ed9e6(0x161)]??0x2bf20,this[_0x3ed9e6(0x153)]=_0x3be9bd[_0x3ed9e6(0x153)]??0xbb8,_0x3be9bd[_0x3ed9e6(0x182)]!==!0x1)this[_0x3ed9e6(0x12e)]();}[a0_0x252a16(0x188)](_0x154496){const _0x20e5da=a0_0x252a16;console[_0x20e5da(0x188)]('['+new Date()[_0x20e5da(0x173)]()[_0x20e5da(0x148)](0x0,0x8)+']\x20[commhub:'+this[_0x20e5da(0x185)]+']\x20'+_0x154496);}async[a0_0x252a16(0x18e)](_0x17f7cc,_0x59b6cb){const _0x3dbe53=a0_0x252a16;let _0x200478={'Content-Type':_0x3dbe53(0x132),'Accept':_0x3dbe53(0x13e)};if(this[_0x3dbe53(0x145)])_0x200478[_0x3dbe53(0x156)]=_0x3dbe53(0x192)+this[_0x3dbe53(0x145)];let _0x5233a4=await(await fetch(this[_0x3dbe53(0x128)]+_0x3dbe53(0x150),{'method':_0x3dbe53(0x19a),'headers':_0x200478,'body':JSON[_0x3dbe53(0x165)]({'jsonrpc':'2.0','id':Date[_0x3dbe53(0x16b)](),'method':'tools/call','params':{'name':_0x17f7cc,'arguments':_0x59b6cb}})}))[_0x3dbe53(0x15f)](),_0x1f5d47=_0x5233a4[_0x3dbe53(0x12d)](/data: (.+)/),_0x29e3a0=_0x1f5d47?JSON[_0x3dbe53(0x19d)](_0x1f5d47[0x1]):JSON[_0x3dbe53(0x19d)](_0x5233a4),_0x2d05e4=_0x29e3a0?.['result']?.[_0x3dbe53(0x14e)]?.[0x0]?.[_0x3dbe53(0x15f)];return _0x2d05e4?JSON[_0x3dbe53(0x19d)](_0x2d05e4):_0x29e3a0;}async[a0_0x252a16(0x12e)](){const _0x4edfed=a0_0x252a16;if(this[_0x4edfed(0x127)])return;this['running']=!0x0,await this[_0x4edfed(0x11f)](_0x4edfed(0x194)),this['log'](_0x4edfed(0x17e)),this[_0x4edfed(0x16e)]=setInterval(()=>{const _0x45266f=_0x4edfed;this[_0x45266f(0x11f)](_0x45266f(0x194))['catch'](_0x3b0a39=>this['log']('heartbeat\x20failed:\x20'+_0x3b0a39[_0x45266f(0x155)]));},this[_0x4edfed(0x161)]),this[_0x4edfed(0x166)]();}async['disconnect'](){const _0x312c28=a0_0x252a16;if(this['running']=!0x1,this[_0x312c28(0x17c)]?.['abort'](),this['heartbeatTimer'])clearInterval(this[_0x312c28(0x16e)]);await this['status'](_0x312c28(0x18d))['catch'](()=>{}),this[_0x312c28(0x188)](_0x312c28(0x126));}async[a0_0x252a16(0x13a)](_0x33bc24,_0x318c03,_0x4c6f4b=a0_0x252a16(0x125)){const _0x2fc65b=a0_0x252a16;return Y({'alias':_0x33bc24,'fromAlias':this[_0x2fc65b(0x185)]},{'log':_0x620281=>console[_0x2fc65b(0x188)](_0x620281),'send':()=>this[_0x2fc65b(0x18e)]('send_task',{'alias':_0x33bc24,'task':_0x318c03,'priority':_0x4c6f4b,'from_session':this[_0x2fc65b(0x185)]})});}async['message'](_0x45faed,_0x1adc3e){const _0x24c58f=a0_0x252a16;return this[_0x24c58f(0x18e)](_0x24c58f(0x15c),{'alias':_0x45faed,'message':_0x1adc3e,'from_session':this[_0x24c58f(0x185)]});}async[a0_0x252a16(0x14b)](_0x4b01d9,_0x19548d,_0x57f698=a0_0x252a16(0x19c)){const _0x4daeb1=a0_0x252a16;return this[_0x4daeb1(0x18e)]('send_reply',{'in_reply_to':_0x4b01d9,'text':_0x19548d,'status':_0x57f698});}async[a0_0x252a16(0x11f)](_0x432f2c,_0x5c9253){const _0x2d7e40=a0_0x252a16;return this['call'](_0x2d7e40(0x138),{'resume_id':this[_0x2d7e40(0x120)],'alias':this[_0x2d7e40(0x185)],'status':_0x432f2c,'server':a0_0xbee4e0(),'hostname':a0_0xbee4e0(),'agent':this[_0x2d7e40(0x172)],'project_dir':process[_0x2d7e40(0x177)](),..._0x5c9253});}async[a0_0x252a16(0x11e)](){const _0xf1714c=a0_0x252a16;return this[_0xf1714c(0x18e)](_0xf1714c(0x179),{});}async['broadcast'](_0x43fe53,_0x5aec82){const _0x3a1607=a0_0x252a16;return this[_0x3a1607(0x18e)](_0x3a1607(0x15e),{'message':_0x43fe53,'filter_server':_0x5aec82?.[_0x3a1607(0x169)],'filter_status':_0x5aec82?.['status']});}async[a0_0x252a16(0x166)](){const _0x5aedb1=a0_0x252a16;let _0x1a66eb=encodeURIComponent(this[_0x5aedb1(0x185)]),_0x3ea6eb=this[_0x5aedb1(0x128)]+'/events/'+_0x1a66eb,_0x312aa8=this[_0x5aedb1(0x153)];while(this[_0x5aedb1(0x127)]){try{this[_0x5aedb1(0x17c)]=new AbortController();let _0x346375={'Accept':_0x5aedb1(0x136)};if(this[_0x5aedb1(0x145)])_0x346375[_0x5aedb1(0x156)]=_0x5aedb1(0x192)+this['token'];let _0x447c6e=await fetch(_0x3ea6eb,{'headers':_0x346375,'signal':this[_0x5aedb1(0x17c)][_0x5aedb1(0x15d)]});if(!_0x447c6e['ok']||!_0x447c6e[_0x5aedb1(0x151)]){this['log'](_0x5aedb1(0x130)+_0x447c6e[_0x5aedb1(0x11f)]),await this[_0x5aedb1(0x124)](_0x312aa8),_0x312aa8=Math[_0x5aedb1(0x157)](_0x312aa8*1.5,0xea60);continue;}_0x312aa8=this[_0x5aedb1(0x153)];let _0x2dbeae=_0x447c6e[_0x5aedb1(0x151)][_0x5aedb1(0x17a)](),_0x1d93c5=new TextDecoder(),_0x5f331b='';while(this['running']){let {done:_0x4ea1e9,value:_0x53648e}=await _0x2dbeae['read']();if(_0x4ea1e9)break;_0x5f331b+=_0x1d93c5[_0x5aedb1(0x18f)](_0x53648e,{'stream':!0x0});let _0x5a31c1=_0x5f331b['split']('\x0a');_0x5f331b=_0x5a31c1[_0x5aedb1(0x159)]()||'';for(let _0x594085 of _0x5a31c1){if(!_0x594085['startsWith'](_0x5aedb1(0x189)))continue;try{let _0x1154a7=JSON[_0x5aedb1(0x19d)](_0x594085['slice'](0x6));if(_0x1154a7[_0x5aedb1(0x164)]===_0x5aedb1(0x18a)){this['log']('SSE\x20connected'),this[_0x5aedb1(0x146)](_0x5aedb1(0x18a));continue;}if(_0x1154a7[_0x5aedb1(0x164)]===_0x5aedb1(0x178)||_0x1154a7[_0x5aedb1(0x164)]===_0x5aedb1(0x16f)||_0x1154a7[_0x5aedb1(0x164)]===_0x5aedb1(0x15e))await this[_0x5aedb1(0x14f)]();}catch{}}}}catch(_0x148559){if(_0x148559['name']===_0x5aedb1(0x16d))break;this['emit'](_0x5aedb1(0x121),_0x148559),this[_0x5aedb1(0x188)](_0x5aedb1(0x137)+_0x148559[_0x5aedb1(0x155)]);}if(this[_0x5aedb1(0x127)])this['emit'](_0x5aedb1(0x126)),this[_0x5aedb1(0x188)](_0x5aedb1(0x13f)+_0x312aa8/0x3e8+_0x5aedb1(0x17b)),await this[_0x5aedb1(0x124)](_0x312aa8),_0x312aa8=Math['min'](_0x312aa8*1.5,0xea60);}}async['processInbox'](){const _0x52be44=a0_0x252a16;try{let _0x5970cf=(await this['call'](_0x52be44(0x176),{'alias':this[_0x52be44(0x185)],'limit':0xa}))?.[_0x52be44(0x13c)]||[];for(let _0xfd98f2 of _0x5970cf)await this[_0x52be44(0x18e)](_0x52be44(0x184),{'alias':this['alias'],'message_id':_0xfd98f2['id']}),this['log']('←\x20'+_0xfd98f2[_0x52be44(0x197)]+':\x20'+_0xfd98f2[_0x52be44(0x14e)][_0x52be44(0x148)](0x0,0x3c)),this[_0x52be44(0x146)](_0x52be44(0x141),_0xfd98f2),this[_0x52be44(0x146)](_0x52be44(0x155),_0xfd98f2);}catch(_0xe4676e){this[_0x52be44(0x188)](_0x52be44(0x198)+_0xe4676e['message']);}}[a0_0x252a16(0x124)](_0xef1a16){return new Promise(_0x32f332=>setTimeout(_0x32f332,_0xef1a16));}}var F=$;export{F as default,$ as CommHub};
|