@sleep2agi/agent-network 2.3.0-preview.80 → 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.
@@ -1 +1 @@
1
- const a0_0x162b24=a0_0x4374;(function(_0x332f59,_0x2e54f1){const _0x4e3089=a0_0x4374,_0x3937d0=_0x332f59();while(!![]){try{const _0x5272f8=parseInt(_0x4e3089(0x11f))/0x1*(-parseInt(_0x4e3089(0xc6))/0x2)+-parseInt(_0x4e3089(0xdd))/0x3+parseInt(_0x4e3089(0x121))/0x4*(-parseInt(_0x4e3089(0xd3))/0x5)+parseInt(_0x4e3089(0x125))/0x6+-parseInt(_0x4e3089(0x113))/0x7+parseInt(_0x4e3089(0xe0))/0x8*(parseInt(_0x4e3089(0x132))/0x9)+-parseInt(_0x4e3089(0x101))/0xa*(-parseInt(_0x4e3089(0xbe))/0xb);if(_0x5272f8===_0x2e54f1)break;else _0x3937d0['push'](_0x3937d0['shift']());}catch(_0x370ca0){_0x3937d0['push'](_0x3937d0['shift']());}}}(a0_0x3edb,0x88359));import{EventEmitter as a0_0x27807f}from'events';import{hostname as a0_0x520ff0}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x4be9be,_0x332394)=>(_0x4be9be??_0x332394)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x3d7f6f){const _0x47c7b3=a0_0x4374;return(_0x3d7f6f instanceof Error?_0x3d7f6f[_0x47c7b3(0xef)]:String(_0x3d7f6f??_0x47c7b3(0xf1)))[_0x47c7b3(0xda)](K,_0x47c7b3(0x102))[_0x47c7b3(0xda)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0xb11477,_0x38f5ab=process.env.ANET_TASK_TRACE_FORMAT===a0_0x162b24(0xf9)){const _0x58690b=a0_0x162b24;if(_0x38f5ab)return JSON['stringify'](_0xb11477);let _0x403737=L(_0xb11477['parent_task_id'],_0x58690b(0xc9)),_0x1c0ebd=L(_0xb11477[_0x58690b(0x119)],'<pending>'),_0x4f4cff=_0xb11477[_0x58690b(0xfd)]?_0x58690b(0xbb)+_0xb11477[_0x58690b(0xfd)]+':'+(_0xb11477['error_message']??''):'';return _0x58690b(0x115)+_0xb11477[_0x58690b(0x124)]+_0x58690b(0xca)+L(_0xb11477[_0x58690b(0xc8)],_0x58690b(0x129))+_0x58690b(0xd0)+L(_0xb11477[_0x58690b(0xd7)],'<unknown>')+_0x58690b(0x10d)+_0x1c0ebd+_0x58690b(0x10c)+_0x403737+_0x58690b(0x10f)+L(_0xb11477['network_id'],_0x58690b(0x129))+'\x20transport='+_0xb11477['transport']+_0x58690b(0xdb)+_0xb11477[_0x58690b(0xff)]+'\x20lifecycle='+_0xb11477[_0x58690b(0x130)]+_0x4f4cff;}function U(_0x1fe6a5){const _0xbce298=a0_0x162b24;return{'event':{'sending':_0xbce298(0xdc),'delivered':'task.send.delivered','failed':_0xbce298(0xe5),'acked':_0xbce298(0x114),'started':'task.started','replied':_0xbce298(0xb8),'expired':'task.expired'}[_0x1fe6a5[_0xbce298(0x124)]],..._0x1fe6a5};}function j(_0x57c89b){const _0x240cf0=a0_0x162b24;let _0x1fced9=_0x57c89b?.['task_id']||_0x57c89b?.[_0x240cf0(0x11d)]||_0x57c89b?.['id'];if(_0x1fced9)return String(_0x1fced9);let _0x28f9c8=_0x57c89b?.[_0x240cf0(0xd2)]?.[0x0]?.[_0x240cf0(0x134)];if(typeof _0x28f9c8!==_0x240cf0(0xf6))return null;try{let _0x247683=JSON['parse'](_0x28f9c8);return _0x247683?.['task_id']||_0x247683?.['message_id']||_0x247683?.['id']||null;}catch{return null;}}async function X(_0x2c76b4,_0x4d1210){const _0xdc8e1b=a0_0x162b24;let _0x38beb3=_0x4d1210['now']??Date[_0xdc8e1b(0xcc)],_0x4e608a=_0x38beb3(),_0x3e7eb1=(_0x5efa61,_0x32c170,_0x8cdb82,_0x5b019f)=>{const _0x3ae2fb=_0xdc8e1b;_0x4d1210['log'](O(U({'from_alias':_0x2c76b4['fromAlias'],'to_alias':_0x2c76b4[_0x3ae2fb(0x110)],'task_id':_0x32c170,'parent_task_id':_0x2c76b4['parentTaskId'],'network_id':_0x2c76b4[_0x3ae2fb(0xea)],'transport':_0x2c76b4[_0x3ae2fb(0xd1)],'status':_0x5efa61,'duration_ms':_0x38beb3()-_0x4e608a,'lifecycle_tracking':_0x2c76b4[_0x3ae2fb(0x11c)],..._0x8cdb82!==void 0x0?{'error_code':_0x5b019f||'send_failed','error_message':N(_0x8cdb82)}:{}})));};_0x3e7eb1('sending',null);try{let _0x54b8a6=await _0x4d1210[_0xdc8e1b(0xcd)](),_0x87c771=j(_0x54b8a6);if(_0x87c771)_0x3e7eb1(_0xdc8e1b(0x12a),_0x87c771);else{if(_0x54b8a6?.['ok']===!0x1||_0x54b8a6?.[_0xdc8e1b(0x127)])_0x3e7eb1(_0xdc8e1b(0x12f),_0x87c771,_0x54b8a6?.[_0xdc8e1b(0x127)]||_0xdc8e1b(0x100),_0xdc8e1b(0xfa));else _0x3e7eb1(_0xdc8e1b(0x12f),null,_0xdc8e1b(0xf7),_0xdc8e1b(0xfb));}return _0x54b8a6;}catch(_0x29a54b){throw _0x3e7eb1(_0xdc8e1b(0x12f),null,_0x29a54b,_0xdc8e1b(0xf4)),_0x29a54b;}}async function Y(_0xd80b11,_0x2809cd){const _0x3357fe=a0_0x162b24;return X({'fromAlias':_0xd80b11[_0x3357fe(0x133)],'toAlias':_0xd80b11['alias'],'parentTaskId':_0xd80b11[_0x3357fe(0x109)]||null,'networkId':_0xd80b11['networkId']||null,'transport':_0x3357fe(0x112),'lifecycleTracking':_0x3357fe(0x131)},_0x2809cd);}class $ extends a0_0x27807f{[a0_0x162b24(0xfc)];[a0_0x162b24(0xba)];[a0_0x162b24(0x122)];[a0_0x162b24(0x108)];[a0_0x162b24(0xc7)];['heartbeatInterval'];[a0_0x162b24(0x123)];['heartbeatTimer'];[a0_0x162b24(0xd5)];['running']=!0x1;constructor(_0x332e5c){const _0x4da888=a0_0x162b24;super();if(this[_0x4da888(0xfc)]=_0x332e5c[_0x4da888(0xfc)]['replace'](/\/$/,''),this[_0x4da888(0xba)]=_0x332e5c[_0x4da888(0xba)],this[_0x4da888(0x122)]=_0x332e5c[_0x4da888(0x122)],this[_0x4da888(0x108)]=_0x332e5c[_0x4da888(0x108)]||'sdk',this['resumeId']='sdk-'+_0x332e5c[_0x4da888(0xba)]+'-'+Date[_0x4da888(0xcc)]()['toString'](0x24),this[_0x4da888(0xc4)]=_0x332e5c[_0x4da888(0xc4)]??0x2bf20,this[_0x4da888(0x123)]=_0x332e5c[_0x4da888(0x123)]??0xbb8,_0x332e5c[_0x4da888(0xe8)]!==!0x1)this[_0x4da888(0xd4)]();}[a0_0x162b24(0xcf)](_0x12b61f){const _0x6c3629=a0_0x162b24;console[_0x6c3629(0xcf)]('['+new Date()[_0x6c3629(0xcb)]()[_0x6c3629(0xd6)](0x0,0x8)+_0x6c3629(0xe3)+this[_0x6c3629(0xba)]+']\x20'+_0x12b61f);}async[a0_0x162b24(0xf5)](_0x52d279,_0x40629d){const _0x3d2c6d=a0_0x162b24;let _0xbb1ec8={'Content-Type':_0x3d2c6d(0x10b),'Accept':'application/json,\x20text/event-stream'};if(this[_0x3d2c6d(0x122)])_0xbb1ec8['Authorization']=_0x3d2c6d(0xeb)+this['token'];let _0x519092=await(await fetch(this[_0x3d2c6d(0xfc)]+_0x3d2c6d(0x10a),{'method':_0x3d2c6d(0x11a),'headers':_0xbb1ec8,'body':JSON[_0x3d2c6d(0xc3)]({'jsonrpc':_0x3d2c6d(0xe6),'id':Date[_0x3d2c6d(0xcc)](),'method':_0x3d2c6d(0xbf),'params':{'name':_0x52d279,'arguments':_0x40629d}})}))[_0x3d2c6d(0x134)](),_0x1d67bf=_0x519092['match'](/data: (.+)/),_0x15909d=_0x1d67bf?JSON[_0x3d2c6d(0xec)](_0x1d67bf[0x1]):JSON[_0x3d2c6d(0xec)](_0x519092),_0x1ca3da=_0x15909d?.[_0x3d2c6d(0x107)]?.[_0x3d2c6d(0xd2)]?.[0x0]?.[_0x3d2c6d(0x134)];return _0x1ca3da?JSON[_0x3d2c6d(0xec)](_0x1ca3da):_0x15909d;}async[a0_0x162b24(0xd4)](){const _0x5a7323=a0_0x162b24;if(this[_0x5a7323(0x103)])return;this[_0x5a7323(0x103)]=!0x0,await this['status']('idle'),this[_0x5a7323(0xcf)](_0x5a7323(0xe1)),this['heartbeatTimer']=setInterval(()=>{const _0x26c2c3=_0x5a7323;this[_0x26c2c3(0x124)](_0x26c2c3(0x128))[_0x26c2c3(0x120)](_0x3f225e=>this[_0x26c2c3(0xcf)](_0x26c2c3(0xce)+_0x3f225e[_0x26c2c3(0xef)]));},this['heartbeatInterval']),this[_0x5a7323(0x106)]();}async[a0_0x162b24(0x118)](){const _0x1c4840=a0_0x162b24;if(this[_0x1c4840(0x103)]=!0x1,this['sseAbort']?.['abort'](),this['heartbeatTimer'])clearInterval(this[_0x1c4840(0x12d)]);await this['status'](_0x1c4840(0xc2))[_0x1c4840(0x120)](()=>{}),this[_0x1c4840(0xcf)]('disconnected');}async[a0_0x162b24(0xcd)](_0x39449a,_0x255fa7,_0x58ae8d=a0_0x162b24(0xde)){const _0x49e7fb=a0_0x162b24;return Y({'alias':_0x39449a,'fromAlias':this[_0x49e7fb(0xba)]},{'log':_0x3b8a1e=>console[_0x49e7fb(0xcf)](_0x3b8a1e),'send':()=>this[_0x49e7fb(0xf5)]('send_task',{'alias':_0x39449a,'task':_0x255fa7,'priority':_0x58ae8d,'from_session':this[_0x49e7fb(0xba)]})});}async['message'](_0x6bc9db,_0x9341c7){const _0x1cd904=a0_0x162b24;return this[_0x1cd904(0xf5)]('send_message',{'alias':_0x6bc9db,'message':_0x9341c7,'from_session':this['alias']});}async[a0_0x162b24(0xed)](_0x1effb7,_0x461000,_0x297735=a0_0x162b24(0xf0)){const _0x2e86df=a0_0x162b24;return this['call'](_0x2e86df(0x10e),{'in_reply_to':_0x1effb7,'text':_0x461000,'status':_0x297735});}async[a0_0x162b24(0x124)](_0x2ed2cb,_0x2082a1){const _0x5b9671=a0_0x162b24;return this['call']('report_status',{'resume_id':this[_0x5b9671(0xc7)],'alias':this['alias'],'status':_0x2ed2cb,'server':a0_0x520ff0(),'hostname':a0_0x520ff0(),'agent':this[_0x5b9671(0x108)],'project_dir':process[_0x5b9671(0xbd)](),..._0x2082a1});}async['getAllStatus'](){const _0xcd9bbe=a0_0x162b24;return this[_0xcd9bbe(0xf5)](_0xcd9bbe(0xe2),{});}async[a0_0x162b24(0xc0)](_0x536c3b,_0x16f1e9){const _0x1efcd9=a0_0x162b24;return this[_0x1efcd9(0xf5)]('broadcast',{'message':_0x536c3b,'filter_server':_0x16f1e9?.[_0x1efcd9(0xe4)],'filter_status':_0x16f1e9?.['status']});}async['connectSSE'](){const _0x59ce77=a0_0x162b24;let _0x3ba488=encodeURIComponent(this[_0x59ce77(0xba)]),_0x2b39ef=this['url']+_0x59ce77(0xf8)+_0x3ba488,_0xcca5d5=this['reconnectDelay'];while(this[_0x59ce77(0x103)]){try{this[_0x59ce77(0xd5)]=new AbortController();let _0x112931={'Accept':_0x59ce77(0x135)};if(this[_0x59ce77(0x122)])_0x112931[_0x59ce77(0xc1)]=_0x59ce77(0xeb)+this[_0x59ce77(0x122)];let _0x3f5fe8=await fetch(_0x2b39ef,{'headers':_0x112931,'signal':this[_0x59ce77(0xd5)]['signal']});if(!_0x3f5fe8['ok']||!_0x3f5fe8[_0x59ce77(0xbc)]){this[_0x59ce77(0xcf)](_0x59ce77(0x11e)+_0x3f5fe8[_0x59ce77(0x124)]),await this[_0x59ce77(0xc5)](_0xcca5d5),_0xcca5d5=Math[_0x59ce77(0x11b)](_0xcca5d5*1.5,0xea60);continue;}_0xcca5d5=this[_0x59ce77(0x123)];let _0x4d0441=_0x3f5fe8['body'][_0x59ce77(0x116)](),_0x5e1922=new TextDecoder(),_0x67b194='';while(this[_0x59ce77(0x103)]){let {done:_0x46529e,value:_0x5a02ff}=await _0x4d0441[_0x59ce77(0xee)]();if(_0x46529e)break;_0x67b194+=_0x5e1922['decode'](_0x5a02ff,{'stream':!0x0});let _0x35bd36=_0x67b194[_0x59ce77(0x12e)]('\x0a');_0x67b194=_0x35bd36['pop']()||'';for(let _0x55bba5 of _0x35bd36){if(!_0x55bba5[_0x59ce77(0xd8)](_0x59ce77(0x12b)))continue;try{let _0x544150=JSON['parse'](_0x55bba5[_0x59ce77(0xd6)](0x6));if(_0x544150[_0x59ce77(0x12c)]===_0x59ce77(0x126)){this[_0x59ce77(0xcf)]('SSE\x20connected'),this[_0x59ce77(0xe7)](_0x59ce77(0x126));continue;}if(_0x544150['type']==='new_task'||_0x544150[_0x59ce77(0x12c)]===_0x59ce77(0xfe)||_0x544150['type']===_0x59ce77(0xc0))await this[_0x59ce77(0x105)]();}catch{}}}}catch(_0x10831a){if(_0x10831a['name']===_0x59ce77(0xdf))break;this[_0x59ce77(0xe7)](_0x59ce77(0x127),_0x10831a),this[_0x59ce77(0xcf)](_0x59ce77(0x111)+_0x10831a[_0x59ce77(0xef)]);}if(this['running'])this[_0x59ce77(0xe7)](_0x59ce77(0xb9)),this[_0x59ce77(0xcf)](_0x59ce77(0x117)+_0xcca5d5/0x3e8+_0x59ce77(0xd9)),await this['sleep'](_0xcca5d5),_0xcca5d5=Math[_0x59ce77(0x11b)](_0xcca5d5*1.5,0xea60);}}async[a0_0x162b24(0x105)](){const _0x34b8c2=a0_0x162b24;try{let _0x1fd97a=(await this[_0x34b8c2(0xf5)](_0x34b8c2(0xf3),{'alias':this[_0x34b8c2(0xba)],'limit':0xa}))?.[_0x34b8c2(0xe9)]||[];for(let _0x258423 of _0x1fd97a)await this['call'](_0x34b8c2(0xf2),{'alias':this[_0x34b8c2(0xba)],'message_id':_0x258423['id']}),this['log']('←\x20'+_0x258423[_0x34b8c2(0x104)]+':\x20'+_0x258423[_0x34b8c2(0xd2)][_0x34b8c2(0xd6)](0x0,0x3c)),this['emit']('task',_0x258423),this['emit'](_0x34b8c2(0xef),_0x258423);}catch(_0x5570a0){this[_0x34b8c2(0xcf)]('inbox\x20error:\x20'+_0x5570a0[_0x34b8c2(0xef)]);}}['sleep'](_0x4c7a6f){return new Promise(_0xbecdc4=>setTimeout(_0xbecdc4,_0x4c7a6f));}}function a0_0x4374(_0x453330,_0xf89ad0){_0x453330=_0x453330-0xb8;const _0x3edb44=a0_0x3edb();let _0x43740c=_0x3edb44[_0x453330];return _0x43740c;}var F=$;function a0_0x3edb(){const _0xede001=['task.send.failed','2.0','emit','autoConnect','messages','networkId','Bearer\x20','parse','reply','read','message','completed','unknown\x20error','ack_inbox','get_inbox','send_failed','call','string','CommHub\x20response\x20omitted\x20task_id','/events/','json','send_rejected','missing_task_id','url','error_code','new_message','duration_ms','CommHub\x20rejected\x20task','5780FVZnEm','[REDACTED]','running','from_session','processInbox','connectSSE','result','agent','parentTaskId','/mcp','application/json','\x20parent_task_id=','\x20task_id=','send_reply','\x20network_id=','toAlias','SSE\x20error:\x20','mcp_http','4484382sTxLgC','task.ack','[commhub:task]\x20','getReader','SSE\x20reconnecting\x20in\x20','disconnect','task_id','POST','min','lifecycleTracking','message_id','SSE\x20failed:\x20','5088JdgEzi','catch','244tdSVeV','token','reconnectDelay','status','3660312SrPvJi','connected','error','idle','<unknown>','delivered','data:\x20','type','heartbeatTimer','split','failed','lifecycle_tracking','not_tracked','15813uIbKUD','fromAlias','text','text/event-stream','task.replied','disconnected','alias','\x20error=','body','cwd','45012DcooiM','tools/call','broadcast','Authorization','offline','stringify','heartbeatInterval','sleep','364RYchaV','resumeId','from_alias','<missing>','\x20from=','toTimeString','now','send','heartbeat\x20failed:\x20','log','\x20to=','transport','content','41415NSbqtj','connect','sseAbort','slice','to_alias','startsWith','s...','replace','\x20duration_ms=','task.send.start','3023397neqzQK','normal','AbortError','3016VUmapD','registered','get_all_status',']\x20[commhub:','server'];a0_0x3edb=function(){return _0xede001;};return a0_0x3edb();}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[];