@sleep2agi/agent-network 2.3.0-preview.81 → 2.3.0-preview.82
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_0x47df6d=a0_0x1c20;(function(_0x4cf617,_0x4a3b26){const _0x3cfabc=a0_0x1c20,_0x515fb2=_0x4cf617();while(!![]){try{const _0x33ca84=-parseInt(_0x3cfabc(0x13a))/0x1*(parseInt(_0x3cfabc(0x148))/0x2)+-parseInt(_0x3cfabc(0x132))/0x3*(-parseInt(_0x3cfabc(0xfc))/0x4)+parseInt(_0x3cfabc(0x13b))/0x5*(parseInt(_0x3cfabc(0x126))/0x6)+-parseInt(_0x3cfabc(0x12a))/0x7*(parseInt(_0x3cfabc(0x124))/0x8)+-parseInt(_0x3cfabc(0xfb))/0x9+-parseInt(_0x3cfabc(0x156))/0xa+parseInt(_0x3cfabc(0x122))/0xb;if(_0x33ca84===_0x4a3b26)break;else _0x515fb2['push'](_0x515fb2['shift']());}catch(_0x212f42){_0x515fb2['push'](_0x515fb2['shift']());}}}(a0_0x49a5,0x18b33));import{EventEmitter as a0_0x3dfc70}from'events';import{hostname as a0_0x55a7b2}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0xd897cd,_0x4d22f6)=>(_0xd897cd??_0x4d22f6)[a0_0x47df6d(0x136)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x47df6d(0x137)](0x0,0xf0);function N(_0x3af736){const _0x5b0c3d=a0_0x47df6d;return(_0x3af736 instanceof Error?_0x3af736[_0x5b0c3d(0x111)]:String(_0x3af736??_0x5b0c3d(0xef)))['replace'](K,'[REDACTED]')[_0x5b0c3d(0x136)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x5b0c3d(0x137)](0x0,0xf0);}function a0_0x49a5(){const _0x56bf80=['emit','task.ack','url','get_inbox','duration_ms','autoConnect','task_id','unknown\x20error','disconnected','body','send_task','completed','status','delivered','new_task','registered','catch','signal','sdk','1231047YplFhi','726676hXqbAP','agent','type','log','CommHub\x20rejected\x20task','lifecycle_tracking',']\x20[commhub:','connect','error_message','not_tracked','<pending>','send_message','error_code','Bearer\x20','sseAbort','Authorization','\x20parent_task_id=','match','2.0','connected','sleep','message','transport','decode','sdk-','POST','\x20task_id=','heartbeat\x20failed:\x20','reconnectDelay','AbortError','from_session','from_alias','/events/','SSE\x20reconnecting\x20in\x20','message_id','text','call','connectSSE','2021602vjKgvr','fromAlias','248168SEjRnV','\x20transport=','42scbHHK','send','stringify','[commhub:task]\x20','7VEDoPv','parentTaskId','now','s...','parent_task_id','messages','resumeId','task.send.delivered','3OYhZTp','broadcast','offline','send_rejected','replace','slice','SSE\x20connected','data:\x20','4xYJWcN','119800xKtHxA','result','heartbeatTimer','getReader','content','application/json','abort','running','<unknown>','read','application/json,\x20text/event-stream','inbox\x20error:\x20','\x20lifecycle=','64946pqmDSM','alias','task.replied','idle','error','heartbeatInterval','toString','text/event-stream','to_alias','send_failed','CommHub\x20response\x20omitted\x20task_id','normal','missing_task_id','networkId','1343040kjNNyw','json','failed','token','\x20to=','sending','parse','getAllStatus','\x20from=','processInbox','mcp_http','tools/call','report_status','\x20duration_ms=','\x20network_id=','SSE\x20error:\x20'];a0_0x49a5=function(){return _0x56bf80;};return a0_0x49a5();}function O(_0x3274cd,_0x9301d5=process.env.ANET_TASK_TRACE_FORMAT===a0_0x47df6d(0x157)){const _0xd91b69=a0_0x47df6d;if(_0x9301d5)return JSON['stringify'](_0x3274cd);let _0x3fbf1a=L(_0x3274cd[_0xd91b69(0x12e)],'<missing>'),_0x30ceb9=L(_0x3274cd[_0xd91b69(0xee)],_0xd91b69(0x106)),_0x38ec=_0x3274cd[_0xd91b69(0x108)]?'\x20error='+_0x3274cd[_0xd91b69(0x108)]+':'+(_0x3274cd[_0xd91b69(0x104)]??''):'';return _0xd91b69(0x129)+_0x3274cd[_0xd91b69(0xf4)]+_0xd91b69(0x15e)+L(_0x3274cd[_0xd91b69(0x11b)],_0xd91b69(0x143))+_0xd91b69(0x15a)+L(_0x3274cd[_0xd91b69(0x150)],_0xd91b69(0x143))+_0xd91b69(0x116)+_0x30ceb9+_0xd91b69(0x10c)+_0x3fbf1a+_0xd91b69(0x164)+L(_0x3274cd['network_id'],_0xd91b69(0x143))+_0xd91b69(0x125)+_0x3274cd[_0xd91b69(0x112)]+_0xd91b69(0x163)+_0x3274cd[_0xd91b69(0xec)]+_0xd91b69(0x147)+_0x3274cd[_0xd91b69(0x101)]+_0x38ec;}function U(_0x5d2df5){const _0x30a118=a0_0x47df6d;return{'event':{'sending':'task.send.start','delivered':_0x30a118(0x131),'failed':'task.send.failed','acked':_0x30a118(0x167),'started':'task.started','replied':_0x30a118(0x14a),'expired':'task.expired'}[_0x5d2df5['status']],..._0x5d2df5};}function j(_0x45c46e){const _0x2435b3=a0_0x47df6d;let _0x18cba3=_0x45c46e?.[_0x2435b3(0xee)]||_0x45c46e?.[_0x2435b3(0x11e)]||_0x45c46e?.['id'];if(_0x18cba3)return String(_0x18cba3);let _0x454b52=_0x45c46e?.['content']?.[0x0]?.[_0x2435b3(0x11f)];if(typeof _0x454b52!=='string')return null;try{let _0x3251e5=JSON[_0x2435b3(0x15c)](_0x454b52);return _0x3251e5?.[_0x2435b3(0xee)]||_0x3251e5?.[_0x2435b3(0x11e)]||_0x3251e5?.['id']||null;}catch{return null;}}async function X(_0x520955,_0x526595){const _0xf81a75=a0_0x47df6d;let _0x1541ba=_0x526595[_0xf81a75(0x12c)]??Date['now'],_0x19304b=_0x1541ba(),_0x1ad337=(_0x5e4088,_0x266ee5,_0x3b49fa,_0x155a7a)=>{const _0xe1d848=_0xf81a75;_0x526595['log'](O(U({'from_alias':_0x520955[_0xe1d848(0x123)],'to_alias':_0x520955['toAlias'],'task_id':_0x266ee5,'parent_task_id':_0x520955[_0xe1d848(0x12b)],'network_id':_0x520955[_0xe1d848(0x155)],'transport':_0x520955['transport'],'status':_0x5e4088,'duration_ms':_0x1541ba()-_0x19304b,'lifecycle_tracking':_0x520955['lifecycleTracking'],..._0x3b49fa!==void 0x0?{'error_code':_0x155a7a||_0xe1d848(0x151),'error_message':N(_0x3b49fa)}:{}})));};_0x1ad337(_0xf81a75(0x15b),null);try{let _0x514731=await _0x526595[_0xf81a75(0x127)](),_0x370209=j(_0x514731);if(_0x370209)_0x1ad337(_0xf81a75(0xf5),_0x370209);else{if(_0x514731?.['ok']===!0x1||_0x514731?.[_0xf81a75(0x14c)])_0x1ad337(_0xf81a75(0x158),_0x370209,_0x514731?.['error']||_0xf81a75(0x100),_0xf81a75(0x135));else _0x1ad337(_0xf81a75(0x158),null,_0xf81a75(0x152),_0xf81a75(0x154));}return _0x514731;}catch(_0x1d2cd6){throw _0x1ad337(_0xf81a75(0x158),null,_0x1d2cd6,'send_failed'),_0x1d2cd6;}}async function Y(_0x5209b2,_0x342982){const _0x3f6657=a0_0x47df6d;return X({'fromAlias':_0x5209b2[_0x3f6657(0x123)],'toAlias':_0x5209b2[_0x3f6657(0x149)],'parentTaskId':_0x5209b2[_0x3f6657(0x12b)]||null,'networkId':_0x5209b2[_0x3f6657(0x155)]||null,'transport':_0x3f6657(0x160),'lifecycleTracking':_0x3f6657(0x105)},_0x342982);}class $ extends a0_0x3dfc70{['url'];[a0_0x47df6d(0x149)];[a0_0x47df6d(0x159)];[a0_0x47df6d(0xfd)];[a0_0x47df6d(0x130)];['heartbeatInterval'];[a0_0x47df6d(0x118)];['heartbeatTimer'];[a0_0x47df6d(0x10a)];[a0_0x47df6d(0x142)]=!0x1;constructor(_0xbbdca9){const _0x2ec548=a0_0x47df6d;super();if(this['url']=_0xbbdca9[_0x2ec548(0x168)][_0x2ec548(0x136)](/\/$/,''),this['alias']=_0xbbdca9[_0x2ec548(0x149)],this[_0x2ec548(0x159)]=_0xbbdca9['token'],this['agent']=_0xbbdca9[_0x2ec548(0xfd)]||_0x2ec548(0xfa),this[_0x2ec548(0x130)]=_0x2ec548(0x114)+_0xbbdca9[_0x2ec548(0x149)]+'-'+Date[_0x2ec548(0x12c)]()[_0x2ec548(0x14e)](0x24),this[_0x2ec548(0x14d)]=_0xbbdca9['heartbeatInterval']??0x2bf20,this['reconnectDelay']=_0xbbdca9['reconnectDelay']??0xbb8,_0xbbdca9[_0x2ec548(0xed)]!==!0x1)this[_0x2ec548(0x103)]();}[a0_0x47df6d(0xff)](_0x187535){const _0x446b6d=a0_0x47df6d;console[_0x446b6d(0xff)]('['+new Date()['toTimeString']()['slice'](0x0,0x8)+_0x446b6d(0x102)+this['alias']+']\x20'+_0x187535);}async[a0_0x47df6d(0x120)](_0x42dafb,_0x40b9a4){const _0x259b65=a0_0x47df6d;let _0x56f2e0={'Content-Type':_0x259b65(0x140),'Accept':_0x259b65(0x145)};if(this[_0x259b65(0x159)])_0x56f2e0['Authorization']='Bearer\x20'+this[_0x259b65(0x159)];let _0x48927b=await(await fetch(this[_0x259b65(0x168)]+'/mcp',{'method':_0x259b65(0x115),'headers':_0x56f2e0,'body':JSON[_0x259b65(0x128)]({'jsonrpc':_0x259b65(0x10e),'id':Date[_0x259b65(0x12c)](),'method':_0x259b65(0x161),'params':{'name':_0x42dafb,'arguments':_0x40b9a4}})}))[_0x259b65(0x11f)](),_0x198c6a=_0x48927b[_0x259b65(0x10d)](/data: (.+)/),_0x327ab9=_0x198c6a?JSON['parse'](_0x198c6a[0x1]):JSON['parse'](_0x48927b),_0x58f15e=_0x327ab9?.[_0x259b65(0x13c)]?.[_0x259b65(0x13f)]?.[0x0]?.[_0x259b65(0x11f)];return _0x58f15e?JSON['parse'](_0x58f15e):_0x327ab9;}async[a0_0x47df6d(0x103)](){const _0x438296=a0_0x47df6d;if(this[_0x438296(0x142)])return;this[_0x438296(0x142)]=!0x0,await this[_0x438296(0xf4)](_0x438296(0x14b)),this['log'](_0x438296(0xf7)),this['heartbeatTimer']=setInterval(()=>{const _0x4e0a82=_0x438296;this['status'](_0x4e0a82(0x14b))[_0x4e0a82(0xf8)](_0xb37689=>this['log'](_0x4e0a82(0x117)+_0xb37689[_0x4e0a82(0x111)]));},this['heartbeatInterval']),this[_0x438296(0x121)]();}async['disconnect'](){const _0x124339=a0_0x47df6d;if(this['running']=!0x1,this[_0x124339(0x10a)]?.[_0x124339(0x141)](),this[_0x124339(0x13d)])clearInterval(this[_0x124339(0x13d)]);await this[_0x124339(0xf4)](_0x124339(0x134))['catch'](()=>{}),this[_0x124339(0xff)](_0x124339(0xf0));}async['send'](_0x3dcf1b,_0x557430,_0x3707a9=a0_0x47df6d(0x153)){const _0x3f9a20=a0_0x47df6d;return Y({'alias':_0x3dcf1b,'fromAlias':this['alias']},{'log':_0x5d9839=>console['log'](_0x5d9839),'send':()=>this[_0x3f9a20(0x120)](_0x3f9a20(0xf2),{'alias':_0x3dcf1b,'task':_0x557430,'priority':_0x3707a9,'from_session':this[_0x3f9a20(0x149)]})});}async['message'](_0x22f3a6,_0x3f73cf){const _0x53378e=a0_0x47df6d;return this[_0x53378e(0x120)](_0x53378e(0x107),{'alias':_0x22f3a6,'message':_0x3f73cf,'from_session':this[_0x53378e(0x149)]});}async['reply'](_0xb3427d,_0x5b7405,_0xef62d1=a0_0x47df6d(0xf3)){const _0x2da225=a0_0x47df6d;return this[_0x2da225(0x120)]('send_reply',{'in_reply_to':_0xb3427d,'text':_0x5b7405,'status':_0xef62d1});}async[a0_0x47df6d(0xf4)](_0x4a57c9,_0x21acb7){const _0x499b6b=a0_0x47df6d;return this[_0x499b6b(0x120)](_0x499b6b(0x162),{'resume_id':this[_0x499b6b(0x130)],'alias':this[_0x499b6b(0x149)],'status':_0x4a57c9,'server':a0_0x55a7b2(),'hostname':a0_0x55a7b2(),'agent':this['agent'],'project_dir':process['cwd'](),..._0x21acb7});}async[a0_0x47df6d(0x15d)](){return this['call']('get_all_status',{});}async[a0_0x47df6d(0x133)](_0x40ca3a,_0x39fa68){const _0x502df1=a0_0x47df6d;return this[_0x502df1(0x120)](_0x502df1(0x133),{'message':_0x40ca3a,'filter_server':_0x39fa68?.['server'],'filter_status':_0x39fa68?.['status']});}async[a0_0x47df6d(0x121)](){const _0x53f7f8=a0_0x47df6d;let _0x3ea421=encodeURIComponent(this[_0x53f7f8(0x149)]),_0x10c1f6=this['url']+_0x53f7f8(0x11c)+_0x3ea421,_0x437e8d=this[_0x53f7f8(0x118)];while(this[_0x53f7f8(0x142)]){try{this[_0x53f7f8(0x10a)]=new AbortController();let _0x47138b={'Accept':_0x53f7f8(0x14f)};if(this['token'])_0x47138b[_0x53f7f8(0x10b)]=_0x53f7f8(0x109)+this[_0x53f7f8(0x159)];let _0x424bd6=await fetch(_0x10c1f6,{'headers':_0x47138b,'signal':this[_0x53f7f8(0x10a)][_0x53f7f8(0xf9)]});if(!_0x424bd6['ok']||!_0x424bd6[_0x53f7f8(0xf1)]){this['log']('SSE\x20failed:\x20'+_0x424bd6[_0x53f7f8(0xf4)]),await this['sleep'](_0x437e8d),_0x437e8d=Math['min'](_0x437e8d*1.5,0xea60);continue;}_0x437e8d=this[_0x53f7f8(0x118)];let _0x2659c9=_0x424bd6[_0x53f7f8(0xf1)][_0x53f7f8(0x13e)](),_0x57f05b=new TextDecoder(),_0x39184d='';while(this['running']){let {done:_0x3ace8c,value:_0xc52fa1}=await _0x2659c9[_0x53f7f8(0x144)]();if(_0x3ace8c)break;_0x39184d+=_0x57f05b[_0x53f7f8(0x113)](_0xc52fa1,{'stream':!0x0});let _0x39a4fd=_0x39184d['split']('\x0a');_0x39184d=_0x39a4fd['pop']()||'';for(let _0x2b58ce of _0x39a4fd){if(!_0x2b58ce['startsWith'](_0x53f7f8(0x139)))continue;try{let _0xb98433=JSON[_0x53f7f8(0x15c)](_0x2b58ce[_0x53f7f8(0x137)](0x6));if(_0xb98433['type']===_0x53f7f8(0x10f)){this[_0x53f7f8(0xff)](_0x53f7f8(0x138)),this[_0x53f7f8(0x166)](_0x53f7f8(0x10f));continue;}if(_0xb98433[_0x53f7f8(0xfe)]===_0x53f7f8(0xf6)||_0xb98433['type']==='new_message'||_0xb98433[_0x53f7f8(0xfe)]===_0x53f7f8(0x133))await this[_0x53f7f8(0x15f)]();}catch{}}}}catch(_0x29b76b){if(_0x29b76b['name']===_0x53f7f8(0x119))break;this['emit'](_0x53f7f8(0x14c),_0x29b76b),this[_0x53f7f8(0xff)](_0x53f7f8(0x165)+_0x29b76b[_0x53f7f8(0x111)]);}if(this[_0x53f7f8(0x142)])this[_0x53f7f8(0x166)](_0x53f7f8(0xf0)),this['log'](_0x53f7f8(0x11d)+_0x437e8d/0x3e8+_0x53f7f8(0x12d)),await this['sleep'](_0x437e8d),_0x437e8d=Math['min'](_0x437e8d*1.5,0xea60);}}async['processInbox'](){const _0x1f2d0d=a0_0x47df6d;try{let _0xd6a027=(await this[_0x1f2d0d(0x120)](_0x1f2d0d(0xeb),{'alias':this[_0x1f2d0d(0x149)],'limit':0xa}))?.[_0x1f2d0d(0x12f)]||[];for(let _0x1eb078 of _0xd6a027)await this[_0x1f2d0d(0x120)]('ack_inbox',{'alias':this[_0x1f2d0d(0x149)],'message_id':_0x1eb078['id']}),this[_0x1f2d0d(0xff)]('←\x20'+_0x1eb078[_0x1f2d0d(0x11a)]+':\x20'+_0x1eb078[_0x1f2d0d(0x13f)][_0x1f2d0d(0x137)](0x0,0x3c)),this[_0x1f2d0d(0x166)]('task',_0x1eb078),this[_0x1f2d0d(0x166)](_0x1f2d0d(0x111),_0x1eb078);}catch(_0x4f9b3c){this[_0x1f2d0d(0xff)](_0x1f2d0d(0x146)+_0x4f9b3c[_0x1f2d0d(0x111)]);}}[a0_0x47df6d(0x110)](_0xc3e9e7){return new Promise(_0x4e9c16=>setTimeout(_0x4e9c16,_0xc3e9e7));}}var F=$;function a0_0x1c20(_0x2a794c,_0x1d483e){_0x2a794c=_0x2a794c-0xeb;const _0x49a5ce=a0_0x49a5();let _0x1c20eb=_0x49a5ce[_0x2a794c];return _0x1c20eb;}export{F as default,$ as CommHub};
|
|
1
|
+
const a0_0x29f126=a0_0x34e9;(function(_0x2edd31,_0x3edbad){const _0x530453=a0_0x34e9,_0x2238f9=_0x2edd31();while(!![]){try{const _0xd0670f=-parseInt(_0x530453(0x19e))/0x1+-parseInt(_0x530453(0x12a))/0x2+parseInt(_0x530453(0x164))/0x3*(parseInt(_0x530453(0x149))/0x4)+-parseInt(_0x530453(0x15f))/0x5+parseInt(_0x530453(0x186))/0x6+parseInt(_0x530453(0x166))/0x7+-parseInt(_0x530453(0x134))/0x8*(-parseInt(_0x530453(0x181))/0x9);if(_0xd0670f===_0x3edbad)break;else _0x2238f9['push'](_0x2238f9['shift']());}catch(_0x4019ce){_0x2238f9['push'](_0x2238f9['shift']());}}}(a0_0x4737,0x7fa2e));import{EventEmitter as a0_0x418b76}from'events';import{hostname as a0_0x15eb1f}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x2f1a52,_0x3add02)=>(_0x2f1a52??_0x3add02)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x29f126(0x150)](0x0,0xf0);function N(_0x408edb){const _0xddbf65=a0_0x29f126;return(_0x408edb instanceof Error?_0x408edb[_0xddbf65(0x12e)]:String(_0x408edb??_0xddbf65(0x12b)))[_0xddbf65(0x16b)](K,_0xddbf65(0x17d))[_0xddbf65(0x16b)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0xddbf65(0x150)](0x0,0xf0);}function O(_0x3649b5,_0x4e0b5e=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x52a383=a0_0x29f126;if(_0x4e0b5e)return JSON[_0x52a383(0x192)](_0x3649b5);let _0x1a91d5=L(_0x3649b5['parent_task_id'],_0x52a383(0x14d)),_0x1b4627=L(_0x3649b5['task_id'],'<pending>'),_0x503639=_0x3649b5[_0x52a383(0x18e)]?_0x52a383(0x142)+_0x3649b5[_0x52a383(0x18e)]+':'+(_0x3649b5['error_message']??''):'';return _0x52a383(0x167)+_0x3649b5[_0x52a383(0x138)]+_0x52a383(0x14f)+L(_0x3649b5[_0x52a383(0x13f)],_0x52a383(0x193))+'\x20to='+L(_0x3649b5[_0x52a383(0x136)],_0x52a383(0x193))+_0x52a383(0x169)+_0x1b4627+'\x20parent_task_id='+_0x1a91d5+_0x52a383(0x19f)+L(_0x3649b5[_0x52a383(0x12d)],_0x52a383(0x193))+_0x52a383(0x176)+_0x3649b5[_0x52a383(0x158)]+_0x52a383(0x12f)+_0x3649b5[_0x52a383(0x190)]+_0x52a383(0x129)+_0x3649b5[_0x52a383(0x148)]+_0x503639;}function a0_0x34e9(_0x18d25e,_0x372e60){_0x18d25e=_0x18d25e-0x127;const _0x4737d3=a0_0x4737();let _0x34e975=_0x4737d3[_0x18d25e];return _0x34e975;}function U(_0x2e0d18){const _0x122d7a=a0_0x29f126;return{'event':{'sending':'task.send.start','delivered':'task.send.delivered','failed':_0x122d7a(0x161),'acked':'task.ack','started':_0x122d7a(0x199),'replied':'task.replied','expired':_0x122d7a(0x19c)}[_0x2e0d18[_0x122d7a(0x138)]],..._0x2e0d18};}function j(_0x52013c){const _0xcf9d9d=a0_0x29f126;let _0x50aa21=_0x52013c?.[_0xcf9d9d(0x184)]||_0x52013c?.[_0xcf9d9d(0x139)]||_0x52013c?.['id'];if(_0x50aa21)return String(_0x50aa21);let _0x4457a5=_0x52013c?.['content']?.[0x0]?.['text'];if(typeof _0x4457a5!==_0xcf9d9d(0x18a))return null;try{let _0x52960a=JSON[_0xcf9d9d(0x151)](_0x4457a5);return _0x52960a?.[_0xcf9d9d(0x184)]||_0x52960a?.[_0xcf9d9d(0x139)]||_0x52960a?.['id']||null;}catch{return null;}}async function X(_0x321ecc,_0x3d85fd){const _0x86bfc7=a0_0x29f126;let _0x1a8723=_0x3d85fd[_0x86bfc7(0x175)]??Date[_0x86bfc7(0x175)],_0x1153cf=_0x1a8723(),_0x3381e1=(_0xc9488,_0x33fe97,_0x4d53eb,_0x2b5c4a)=>{const _0x1443a3=_0x86bfc7;_0x3d85fd[_0x1443a3(0x191)](O(U({'from_alias':_0x321ecc[_0x1443a3(0x141)],'to_alias':_0x321ecc[_0x1443a3(0x16f)],'task_id':_0x33fe97,'parent_task_id':_0x321ecc[_0x1443a3(0x17a)],'network_id':_0x321ecc[_0x1443a3(0x17c)],'transport':_0x321ecc[_0x1443a3(0x158)],'status':_0xc9488,'duration_ms':_0x1a8723()-_0x1153cf,'lifecycle_tracking':_0x321ecc[_0x1443a3(0x163)],..._0x4d53eb!==void 0x0?{'error_code':_0x2b5c4a||_0x1443a3(0x16e),'error_message':N(_0x4d53eb)}:{}})));};_0x3381e1(_0x86bfc7(0x1a2),null);try{let _0x18baa1=await _0x3d85fd[_0x86bfc7(0x18c)](),_0x572365=j(_0x18baa1);if(_0x572365)_0x3381e1('delivered',_0x572365);else{if(_0x18baa1?.['ok']===!0x1||_0x18baa1?.['error'])_0x3381e1(_0x86bfc7(0x1a4),_0x572365,_0x18baa1?.[_0x86bfc7(0x173)]||_0x86bfc7(0x180),_0x86bfc7(0x168));else _0x3381e1(_0x86bfc7(0x1a4),null,'CommHub\x20response\x20omitted\x20task_id',_0x86bfc7(0x17e));}return _0x18baa1;}catch(_0x3ddc59){throw _0x3381e1('failed',null,_0x3ddc59,'send_failed'),_0x3ddc59;}}async function Y(_0x4c43f6,_0x48148b){const _0x34e701=a0_0x29f126;return X({'fromAlias':_0x4c43f6['fromAlias'],'toAlias':_0x4c43f6[_0x34e701(0x140)],'parentTaskId':_0x4c43f6['parentTaskId']||null,'networkId':_0x4c43f6[_0x34e701(0x17c)]||null,'transport':_0x34e701(0x17b),'lifecycleTracking':_0x34e701(0x196)},_0x48148b);}class $ extends a0_0x418b76{[a0_0x29f126(0x188)];['alias'];[a0_0x29f126(0x147)];[a0_0x29f126(0x16c)];['resumeId'];[a0_0x29f126(0x177)];['reconnectDelay'];[a0_0x29f126(0x152)];[a0_0x29f126(0x146)];[a0_0x29f126(0x171)]=!0x1;constructor(_0x5b1c00){const _0x6031ef=a0_0x29f126;super();if(this[_0x6031ef(0x188)]=_0x5b1c00[_0x6031ef(0x188)][_0x6031ef(0x16b)](/\/$/,''),this[_0x6031ef(0x140)]=_0x5b1c00[_0x6031ef(0x140)],this[_0x6031ef(0x147)]=_0x5b1c00[_0x6031ef(0x147)],this[_0x6031ef(0x16c)]=_0x5b1c00[_0x6031ef(0x16c)]||'sdk',this[_0x6031ef(0x16d)]=_0x6031ef(0x162)+_0x5b1c00[_0x6031ef(0x140)]+'-'+Date[_0x6031ef(0x175)]()[_0x6031ef(0x165)](0x24),this[_0x6031ef(0x177)]=_0x5b1c00[_0x6031ef(0x177)]??0x2bf20,this[_0x6031ef(0x194)]=_0x5b1c00['reconnectDelay']??0xbb8,_0x5b1c00[_0x6031ef(0x137)]!==!0x1)this[_0x6031ef(0x18f)]();}[a0_0x29f126(0x191)](_0x27af90){const _0xa230ef=a0_0x29f126;console[_0xa230ef(0x191)]('['+new Date()[_0xa230ef(0x19b)]()[_0xa230ef(0x150)](0x0,0x8)+']\x20[commhub:'+this[_0xa230ef(0x140)]+']\x20'+_0x27af90);}async[a0_0x29f126(0x13d)](_0x35d0ba,_0x284248){const _0x339ecd=a0_0x29f126;let _0x4af711={'Content-Type':_0x339ecd(0x14e),'Accept':_0x339ecd(0x14b)};if(this[_0x339ecd(0x147)])_0x4af711[_0x339ecd(0x17f)]='Bearer\x20'+this['token'];let _0x2c473f=await(await fetch(this[_0x339ecd(0x188)]+'/mcp',{'method':_0x339ecd(0x1a3),'headers':_0x4af711,'body':JSON[_0x339ecd(0x192)]({'jsonrpc':'2.0','id':Date[_0x339ecd(0x175)](),'method':_0x339ecd(0x172),'params':{'name':_0x35d0ba,'arguments':_0x284248}})}))[_0x339ecd(0x144)](),_0x1ffc3f=_0x2c473f['match'](/data: (.+)/),_0x3c5931=_0x1ffc3f?JSON['parse'](_0x1ffc3f[0x1]):JSON['parse'](_0x2c473f),_0x46a3ef=_0x3c5931?.[_0x339ecd(0x178)]?.[_0x339ecd(0x1a0)]?.[0x0]?.['text'];return _0x46a3ef?JSON[_0x339ecd(0x151)](_0x46a3ef):_0x3c5931;}async[a0_0x29f126(0x18f)](){const _0x24cd69=a0_0x29f126;if(this[_0x24cd69(0x171)])return;this[_0x24cd69(0x171)]=!0x0,await this[_0x24cd69(0x138)]('idle'),this[_0x24cd69(0x191)](_0x24cd69(0x19d)),this['heartbeatTimer']=setInterval(()=>{const _0x31d166=_0x24cd69;this['status'](_0x31d166(0x18d))[_0x31d166(0x174)](_0x36f631=>this['log'](_0x31d166(0x130)+_0x36f631['message']));},this[_0x24cd69(0x177)]),this['connectSSE']();}async[a0_0x29f126(0x13c)](){const _0x483bfa=a0_0x29f126;if(this['running']=!0x1,this['sseAbort']?.[_0x483bfa(0x179)](),this[_0x483bfa(0x152)])clearInterval(this[_0x483bfa(0x152)]);await this['status'](_0x483bfa(0x156))[_0x483bfa(0x174)](()=>{}),this[_0x483bfa(0x191)](_0x483bfa(0x132));}async['send'](_0x127076,_0x3c1878,_0x10e09a=a0_0x29f126(0x15d)){const _0x118d39=a0_0x29f126;return Y({'alias':_0x127076,'fromAlias':this['alias']},{'log':_0x395d1d=>console[_0x118d39(0x191)](_0x395d1d),'send':()=>this[_0x118d39(0x13d)]('send_task',{'alias':_0x127076,'task':_0x3c1878,'priority':_0x10e09a,'from_session':this['alias']})});}async[a0_0x29f126(0x12e)](_0x3150fa,_0x611914){const _0x56c6dc=a0_0x29f126;return this['call'](_0x56c6dc(0x145),{'alias':_0x3150fa,'message':_0x611914,'from_session':this[_0x56c6dc(0x140)]});}async[a0_0x29f126(0x157)](_0x42e93a,_0x6e0706,_0x101522=a0_0x29f126(0x127)){const _0x11c19a=a0_0x29f126;return this[_0x11c19a(0x13d)](_0x11c19a(0x15c),{'in_reply_to':_0x42e93a,'text':_0x6e0706,'status':_0x101522});}async['status'](_0x4134e1,_0x51dd61){const _0x4767f3=a0_0x29f126;return this[_0x4767f3(0x13d)](_0x4767f3(0x189),{'resume_id':this[_0x4767f3(0x16d)],'alias':this['alias'],'status':_0x4134e1,'server':a0_0x15eb1f(),'hostname':a0_0x15eb1f(),'agent':this['agent'],'project_dir':process[_0x4767f3(0x15e)](),..._0x51dd61});}async[a0_0x29f126(0x135)](){const _0x4d0c52=a0_0x29f126;return this['call'](_0x4d0c52(0x198),{});}async[a0_0x29f126(0x195)](_0x5f5469,_0x140a67){const _0x4d0883=a0_0x29f126;return this[_0x4d0883(0x13d)]('broadcast',{'message':_0x5f5469,'filter_server':_0x140a67?.[_0x4d0883(0x155)],'filter_status':_0x140a67?.[_0x4d0883(0x138)]});}async[a0_0x29f126(0x13a)](){const _0x55403a=a0_0x29f126;let _0x29c701=encodeURIComponent(this[_0x55403a(0x140)]),_0x3db97c=this[_0x55403a(0x188)]+'/events/'+_0x29c701,_0x4192fc=this[_0x55403a(0x194)];while(this[_0x55403a(0x171)]){try{this[_0x55403a(0x146)]=new AbortController();let _0x4fe140={'Accept':_0x55403a(0x19a)};if(this['token'])_0x4fe140[_0x55403a(0x17f)]=_0x55403a(0x159)+this[_0x55403a(0x147)];let _0x476140=await fetch(_0x3db97c,{'headers':_0x4fe140,'signal':this[_0x55403a(0x146)]['signal']});if(!_0x476140['ok']||!_0x476140['body']){this[_0x55403a(0x191)](_0x55403a(0x160)+_0x476140[_0x55403a(0x138)]),await this['sleep'](_0x4192fc),_0x4192fc=Math[_0x55403a(0x18b)](_0x4192fc*1.5,0xea60);continue;}_0x4192fc=this['reconnectDelay'];let _0x4ca200=_0x476140[_0x55403a(0x14a)][_0x55403a(0x185)](),_0x17d07f=new TextDecoder(),_0x3533d4='';while(this[_0x55403a(0x171)]){let {done:_0x15388,value:_0x19c201}=await _0x4ca200[_0x55403a(0x183)]();if(_0x15388)break;_0x3533d4+=_0x17d07f[_0x55403a(0x15b)](_0x19c201,{'stream':!0x0});let _0x3045ed=_0x3533d4['split']('\x0a');_0x3533d4=_0x3045ed[_0x55403a(0x12c)]()||'';for(let _0x4a6ffc of _0x3045ed){if(!_0x4a6ffc[_0x55403a(0x153)](_0x55403a(0x133)))continue;try{let _0x1cb426=JSON[_0x55403a(0x151)](_0x4a6ffc[_0x55403a(0x150)](0x6));if(_0x1cb426[_0x55403a(0x15a)]===_0x55403a(0x128)){this[_0x55403a(0x191)](_0x55403a(0x187)),this['emit']('connected');continue;}if(_0x1cb426[_0x55403a(0x15a)]==='new_task'||_0x1cb426[_0x55403a(0x15a)]===_0x55403a(0x16a)||_0x1cb426['type']===_0x55403a(0x195))await this[_0x55403a(0x154)]();}catch{}}}}catch(_0xfbb8b8){if(_0xfbb8b8[_0x55403a(0x13e)]===_0x55403a(0x131))break;this[_0x55403a(0x14c)](_0x55403a(0x173),_0xfbb8b8),this['log']('SSE\x20error:\x20'+_0xfbb8b8['message']);}if(this[_0x55403a(0x171)])this[_0x55403a(0x14c)](_0x55403a(0x132)),this[_0x55403a(0x191)]('SSE\x20reconnecting\x20in\x20'+_0x4192fc/0x3e8+'s...'),await this['sleep'](_0x4192fc),_0x4192fc=Math['min'](_0x4192fc*1.5,0xea60);}}async[a0_0x29f126(0x154)](){const _0x566498=a0_0x29f126;try{let _0x3a8907=(await this[_0x566498(0x13d)]('get_inbox',{'alias':this[_0x566498(0x140)],'limit':0xa}))?.[_0x566498(0x143)]||[];for(let _0x4796ff of _0x3a8907)await this[_0x566498(0x13d)](_0x566498(0x197),{'alias':this[_0x566498(0x140)],'message_id':_0x4796ff['id']}),this[_0x566498(0x191)]('←\x20'+_0x4796ff[_0x566498(0x170)]+':\x20'+_0x4796ff['content'][_0x566498(0x150)](0x0,0x3c)),this[_0x566498(0x14c)](_0x566498(0x13b),_0x4796ff),this[_0x566498(0x14c)](_0x566498(0x12e),_0x4796ff);}catch(_0x56811a){this[_0x566498(0x191)](_0x566498(0x182)+_0x56811a[_0x566498(0x12e)]);}}[a0_0x29f126(0x1a1)](_0x40d6fe){return new Promise(_0x32f374=>setTimeout(_0x32f374,_0x40d6fe));}}var F=$;function a0_0x4737(){const _0x51afd6=['connect','duration_ms','log','stringify','<unknown>','reconnectDelay','broadcast','not_tracked','ack_inbox','get_all_status','task.started','text/event-stream','toTimeString','task.expired','registered','892867QZZlki','\x20network_id=','content','sleep','sending','POST','failed','completed','connected','\x20lifecycle=','1427852LSjUxl','unknown\x20error','pop','network_id','message','\x20duration_ms=','heartbeat\x20failed:\x20','AbortError','disconnected','data:\x20','704008JFPDkd','getAllStatus','to_alias','autoConnect','status','message_id','connectSSE','task','disconnect','call','name','from_alias','alias','fromAlias','\x20error=','messages','text','send_message','sseAbort','token','lifecycle_tracking','62488YvCjis','body','application/json,\x20text/event-stream','emit','<missing>','application/json','\x20from=','slice','parse','heartbeatTimer','startsWith','processInbox','server','offline','reply','transport','Bearer\x20','type','decode','send_reply','normal','cwd','1544935kXKaXI','SSE\x20failed:\x20','task.send.failed','sdk-','lifecycleTracking','105eHDECL','toString','6008737Bohunl','[commhub:task]\x20','send_rejected','\x20task_id=','new_message','replace','agent','resumeId','send_failed','toAlias','from_session','running','tools/call','error','catch','now','\x20transport=','heartbeatInterval','result','abort','parentTaskId','mcp_http','networkId','[REDACTED]','missing_task_id','Authorization','CommHub\x20rejected\x20task','72nnYkzL','inbox\x20error:\x20','read','task_id','getReader','1976454DfmNsl','SSE\x20connected','url','report_status','string','min','send','idle','error_code'];a0_0x4737=function(){return _0x51afd6;};return a0_0x4737();}export{F as default,$ as CommHub};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const isAgentNodeCommand: (cmdline: string) => boolean;
|
|
2
|
+
export interface RunningNodeProbe {
|
|
3
|
+
pidFileContent: string | null;
|
|
4
|
+
isAlive: (pid: number) => boolean;
|
|
5
|
+
commandOf: (pid: number) => string | null;
|
|
6
|
+
}
|
|
7
|
+
/** 返回还活着且确实是 agent-node 的 pid;否则 null(不存在 / 死了 / pid 被别的进程复用)。 */
|
|
8
|
+
export declare const runningNodePid: (probe: RunningNodeProbe) => number | null;
|
|
9
|
+
export declare const alreadyRunningMessage: (displayName: string, pid: number) => string[];
|