@sleep2agi/agent-network 2.3.0-preview.120 → 2.3.0-preview.122

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_0x5eb80c=a0_0x1a30;(function(_0x3902ed,_0x5503e5){const _0x198a6f=a0_0x1a30,_0x44968a=_0x3902ed();while(!![]){try{const _0x10a8ab=parseInt(_0x198a6f(0x230))/0x1+parseInt(_0x198a6f(0x249))/0x2+-parseInt(_0x198a6f(0x1f8))/0x3+-parseInt(_0x198a6f(0x23d))/0x4+-parseInt(_0x198a6f(0x1f5))/0x5*(-parseInt(_0x198a6f(0x262))/0x6)+-parseInt(_0x198a6f(0x21c))/0x7+parseInt(_0x198a6f(0x21b))/0x8;if(_0x10a8ab===_0x5503e5)break;else _0x44968a['push'](_0x44968a['shift']());}catch(_0x4c2a99){_0x44968a['push'](_0x44968a['shift']());}}}(a0_0x3797,0xc0ed5));import{EventEmitter as a0_0x250011}from'events';import{hostname as a0_0x5dc034}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x278e77,_0x4e136e)=>(_0x278e77??_0x4e136e)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x5eb80c(0x1f3)](0x0,0xf0);function a0_0x3797(){const _0x3f31fe=['message_id','180FrHAqU','sdk','abort','4328658AUdIiN','\x20from=','lifecycleTracking','\x20parent_task_id=','toTimeString','token','idle','registered','connected','parent_task_id','sseAbort','error_message','\x20network_id=','AbortError','heartbeatTimer','send_failed','application/json,\x20text/event-stream','message','\x20to=','CommHub\x20rejected\x20task','task.send.delivered','heartbeatInterval','call','not_tracked','resumeId','status','failed','task.ack','Authorization','connect','running','match','messages','now','[commhub:task]\x20','15641744WaWVYl','10562328qAFwVu','send_task','CommHub\x20response\x20omitted\x20task_id','parse','parentTaskId','mcp_http','normal','connectSSE','delivered','task.expired','toAlias','error','send_rejected','task.replied','send','type','task','autoConnect','name','agent','1470859htIwts','networkId','from_alias','signal','POST','s...','SSE\x20connected','alias','catch','task.send.failed','/mcp','url','missing_task_id','5107784lSnOrR','toString','send_message','json','server','<pending>','/events/','\x20lifecycle=','stringify','reply','replace','application/json','1745704snwdiZ','disconnected','getReader','network_id','string','getAllStatus','sdk-','split','<unknown>','completed','tools/call','lifecycle_tracking','send_reply','task.send.start','SSE\x20error:\x20','task_id','result','[REDACTED]','min','fromAlias','emit','SSE\x20reconnecting\x20in\x20',']\x20[commhub:','body','to_alias','120006oBOOUL','SSE\x20failed:\x20','2.0','startsWith','sleep','content','Bearer\x20','text','log','processInbox','reconnectDelay','broadcast','pop','slice'];a0_0x3797=function(){return _0x3f31fe;};return a0_0x3797();}function a0_0x1a30(_0xa2bc5e,_0x26f636){_0xa2bc5e=_0xa2bc5e-0x1ed;const _0x379728=a0_0x3797();let _0x1a3097=_0x379728[_0xa2bc5e];return _0x1a3097;}function N(_0x147209){const _0x152c56=a0_0x5eb80c;return(_0x147209 instanceof Error?_0x147209[_0x152c56(0x209)]:String(_0x147209??'unknown\x20error'))[_0x152c56(0x247)](K,_0x152c56(0x25a))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x5f332c,_0x5a5d6f=process.env.ANET_TASK_TRACE_FORMAT===a0_0x5eb80c(0x240)){const _0x5c46a6=a0_0x5eb80c;if(_0x5a5d6f)return JSON[_0x5c46a6(0x245)](_0x5f332c);let _0x3aa4bb=L(_0x5f332c[_0x5c46a6(0x201)],'<missing>'),_0x2b4b76=L(_0x5f332c[_0x5c46a6(0x258)],_0x5c46a6(0x242)),_0x48d7d1=_0x5f332c['error_code']?'\x20error='+_0x5f332c['error_code']+':'+(_0x5f332c[_0x5c46a6(0x203)]??''):'';return _0x5c46a6(0x21a)+_0x5f332c[_0x5c46a6(0x211)]+_0x5c46a6(0x1f9)+L(_0x5f332c[_0x5c46a6(0x232)],_0x5c46a6(0x251))+_0x5c46a6(0x20a)+L(_0x5f332c[_0x5c46a6(0x261)],_0x5c46a6(0x251))+'\x20task_id='+_0x2b4b76+_0x5c46a6(0x1fb)+_0x3aa4bb+_0x5c46a6(0x204)+L(_0x5f332c[_0x5c46a6(0x24c)],'<unknown>')+'\x20transport='+_0x5f332c['transport']+'\x20duration_ms='+_0x5f332c['duration_ms']+_0x5c46a6(0x244)+_0x5f332c[_0x5c46a6(0x254)]+_0x48d7d1;}function U(_0x211b3c){const _0x3d5d03=a0_0x5eb80c;return{'event':{'sending':_0x3d5d03(0x256),'delivered':_0x3d5d03(0x20c),'failed':_0x3d5d03(0x239),'acked':_0x3d5d03(0x213),'started':'task.started','replied':_0x3d5d03(0x229),'expired':_0x3d5d03(0x225)}[_0x211b3c['status']],..._0x211b3c};}function j(_0x3e160a){const _0x373b34=a0_0x5eb80c;let _0x5a8bd8=_0x3e160a?.[_0x373b34(0x258)]||_0x3e160a?.[_0x373b34(0x1f4)]||_0x3e160a?.['id'];if(_0x5a8bd8)return String(_0x5a8bd8);let _0x452c06=_0x3e160a?.[_0x373b34(0x267)]?.[0x0]?.[_0x373b34(0x1ed)];if(typeof _0x452c06!==_0x373b34(0x24d))return null;try{let _0x3387ef=JSON['parse'](_0x452c06);return _0x3387ef?.[_0x373b34(0x258)]||_0x3387ef?.[_0x373b34(0x1f4)]||_0x3387ef?.['id']||null;}catch{return null;}}async function X(_0x550df0,_0x2e51cc){const _0xb456ae=a0_0x5eb80c;let _0x14745a=_0x2e51cc['now']??Date['now'],_0x1e11f5=_0x14745a(),_0xc533b0=(_0x1dc8e3,_0x1ec3b5,_0x42d0bd,_0x144368)=>{const _0x524b2e=a0_0x1a30;_0x2e51cc['log'](O(U({'from_alias':_0x550df0[_0x524b2e(0x25c)],'to_alias':_0x550df0[_0x524b2e(0x226)],'task_id':_0x1ec3b5,'parent_task_id':_0x550df0[_0x524b2e(0x220)],'network_id':_0x550df0[_0x524b2e(0x231)],'transport':_0x550df0['transport'],'status':_0x1dc8e3,'duration_ms':_0x14745a()-_0x1e11f5,'lifecycle_tracking':_0x550df0[_0x524b2e(0x1fa)],..._0x42d0bd!==void 0x0?{'error_code':_0x144368||_0x524b2e(0x207),'error_message':N(_0x42d0bd)}:{}})));};_0xc533b0('sending',null);try{let _0x176ccb=await _0x2e51cc[_0xb456ae(0x22a)](),_0x428544=j(_0x176ccb);if(_0x428544)_0xc533b0(_0xb456ae(0x224),_0x428544);else{if(_0x176ccb?.['ok']===!0x1||_0x176ccb?.[_0xb456ae(0x227)])_0xc533b0('failed',_0x428544,_0x176ccb?.[_0xb456ae(0x227)]||_0xb456ae(0x20b),_0xb456ae(0x228));else _0xc533b0('failed',null,_0xb456ae(0x21e),_0xb456ae(0x23c));}return _0x176ccb;}catch(_0x486fd8){throw _0xc533b0(_0xb456ae(0x212),null,_0x486fd8,_0xb456ae(0x207)),_0x486fd8;}}async function Y(_0x315d20,_0x23b724){const _0x31f96d=a0_0x5eb80c;return X({'fromAlias':_0x315d20[_0x31f96d(0x25c)],'toAlias':_0x315d20[_0x31f96d(0x237)],'parentTaskId':_0x315d20[_0x31f96d(0x220)]||null,'networkId':_0x315d20[_0x31f96d(0x231)]||null,'transport':_0x31f96d(0x221),'lifecycleTracking':_0x31f96d(0x20f)},_0x23b724);}class $ extends a0_0x250011{[a0_0x5eb80c(0x23b)];[a0_0x5eb80c(0x237)];[a0_0x5eb80c(0x1fd)];[a0_0x5eb80c(0x22f)];[a0_0x5eb80c(0x210)];[a0_0x5eb80c(0x20d)];[a0_0x5eb80c(0x1f0)];[a0_0x5eb80c(0x206)];['sseAbort'];['running']=!0x1;constructor(_0x22e9ca){const _0x33d4b4=a0_0x5eb80c;super();if(this[_0x33d4b4(0x23b)]=_0x22e9ca[_0x33d4b4(0x23b)][_0x33d4b4(0x247)](/\/$/,''),this[_0x33d4b4(0x237)]=_0x22e9ca[_0x33d4b4(0x237)],this[_0x33d4b4(0x1fd)]=_0x22e9ca[_0x33d4b4(0x1fd)],this[_0x33d4b4(0x22f)]=_0x22e9ca['agent']||_0x33d4b4(0x1f6),this[_0x33d4b4(0x210)]=_0x33d4b4(0x24f)+_0x22e9ca[_0x33d4b4(0x237)]+'-'+Date[_0x33d4b4(0x219)]()[_0x33d4b4(0x23e)](0x24),this[_0x33d4b4(0x20d)]=_0x22e9ca[_0x33d4b4(0x20d)]??0x2bf20,this[_0x33d4b4(0x1f0)]=_0x22e9ca[_0x33d4b4(0x1f0)]??0xbb8,_0x22e9ca[_0x33d4b4(0x22d)]!==!0x1)this[_0x33d4b4(0x215)]();}[a0_0x5eb80c(0x1ee)](_0x17b3c1){const _0x2863fe=a0_0x5eb80c;console['log']('['+new Date()[_0x2863fe(0x1fc)]()['slice'](0x0,0x8)+_0x2863fe(0x25f)+this[_0x2863fe(0x237)]+']\x20'+_0x17b3c1);}async['call'](_0x1c2d60,_0x298923){const _0x28c641=a0_0x5eb80c;let _0x5387e4={'Content-Type':_0x28c641(0x248),'Accept':_0x28c641(0x208)};if(this[_0x28c641(0x1fd)])_0x5387e4[_0x28c641(0x214)]=_0x28c641(0x268)+this['token'];let _0xe61d2c=await(await fetch(this[_0x28c641(0x23b)]+_0x28c641(0x23a),{'method':_0x28c641(0x234),'headers':_0x5387e4,'body':JSON[_0x28c641(0x245)]({'jsonrpc':_0x28c641(0x264),'id':Date[_0x28c641(0x219)](),'method':_0x28c641(0x253),'params':{'name':_0x1c2d60,'arguments':_0x298923}})}))[_0x28c641(0x1ed)](),_0x2e94ee=_0xe61d2c[_0x28c641(0x217)](/data: (.+)/),_0x19a7e9=_0x2e94ee?JSON[_0x28c641(0x21f)](_0x2e94ee[0x1]):JSON[_0x28c641(0x21f)](_0xe61d2c),_0x26fccb=_0x19a7e9?.[_0x28c641(0x259)]?.[_0x28c641(0x267)]?.[0x0]?.['text'];return _0x26fccb?JSON['parse'](_0x26fccb):_0x19a7e9;}async[a0_0x5eb80c(0x215)](){const _0x2a944a=a0_0x5eb80c;if(this[_0x2a944a(0x216)])return;this[_0x2a944a(0x216)]=!0x0,await this[_0x2a944a(0x211)]('idle'),this[_0x2a944a(0x1ee)](_0x2a944a(0x1ff)),this[_0x2a944a(0x206)]=setInterval(()=>{const _0x49d862=_0x2a944a;this['status'](_0x49d862(0x1fe))[_0x49d862(0x238)](_0x135d03=>this['log']('heartbeat\x20failed:\x20'+_0x135d03[_0x49d862(0x209)]));},this[_0x2a944a(0x20d)]),this[_0x2a944a(0x223)]();}async['disconnect'](){const _0x1ade56=a0_0x5eb80c;if(this[_0x1ade56(0x216)]=!0x1,this[_0x1ade56(0x202)]?.[_0x1ade56(0x1f7)](),this[_0x1ade56(0x206)])clearInterval(this[_0x1ade56(0x206)]);await this[_0x1ade56(0x211)]('offline')[_0x1ade56(0x238)](()=>{}),this[_0x1ade56(0x1ee)]('disconnected');}async[a0_0x5eb80c(0x22a)](_0x4f5de2,_0x18bea0,_0x2e0365=a0_0x5eb80c(0x222)){const _0x5361c5=a0_0x5eb80c;return Y({'alias':_0x4f5de2,'fromAlias':this['alias']},{'log':_0xbaac93=>console[_0x5361c5(0x1ee)](_0xbaac93),'send':()=>this[_0x5361c5(0x20e)](_0x5361c5(0x21d),{'alias':_0x4f5de2,'task':_0x18bea0,'priority':_0x2e0365,'from_session':this['alias']})});}async[a0_0x5eb80c(0x209)](_0x49be41,_0x17d559){const _0x2bfd2f=a0_0x5eb80c;return this['call'](_0x2bfd2f(0x23f),{'alias':_0x49be41,'message':_0x17d559,'from_session':this[_0x2bfd2f(0x237)]});}async[a0_0x5eb80c(0x246)](_0x5d4298,_0x175c44,_0x228468=a0_0x5eb80c(0x252)){const _0x1ca748=a0_0x5eb80c;return this[_0x1ca748(0x20e)](_0x1ca748(0x255),{'in_reply_to':_0x5d4298,'text':_0x175c44,'status':_0x228468});}async[a0_0x5eb80c(0x211)](_0x1ead92,_0x574344){const _0x4e587a=a0_0x5eb80c;return this[_0x4e587a(0x20e)]('report_status',{'resume_id':this[_0x4e587a(0x210)],'alias':this[_0x4e587a(0x237)],'status':_0x1ead92,'server':a0_0x5dc034(),'hostname':a0_0x5dc034(),'agent':this[_0x4e587a(0x22f)],'project_dir':process['cwd'](),..._0x574344});}async[a0_0x5eb80c(0x24e)](){const _0x2492d4=a0_0x5eb80c;return this[_0x2492d4(0x20e)]('get_all_status',{});}async[a0_0x5eb80c(0x1f1)](_0x502c56,_0x1d3e08){const _0x857ef3=a0_0x5eb80c;return this[_0x857ef3(0x20e)](_0x857ef3(0x1f1),{'message':_0x502c56,'filter_server':_0x1d3e08?.[_0x857ef3(0x241)],'filter_status':_0x1d3e08?.['status']});}async[a0_0x5eb80c(0x223)](){const _0x31332e=a0_0x5eb80c;let _0x1d977d=encodeURIComponent(this[_0x31332e(0x237)]),_0x4b9acd=this[_0x31332e(0x23b)]+_0x31332e(0x243)+_0x1d977d,_0x555c0c=this[_0x31332e(0x1f0)];while(this[_0x31332e(0x216)]){try{this[_0x31332e(0x202)]=new AbortController();let _0x5d09e1={'Accept':'text/event-stream'};if(this[_0x31332e(0x1fd)])_0x5d09e1[_0x31332e(0x214)]=_0x31332e(0x268)+this[_0x31332e(0x1fd)];let _0x3fb4cf=await fetch(_0x4b9acd,{'headers':_0x5d09e1,'signal':this['sseAbort'][_0x31332e(0x233)]});if(!_0x3fb4cf['ok']||!_0x3fb4cf[_0x31332e(0x260)]){this[_0x31332e(0x1ee)](_0x31332e(0x263)+_0x3fb4cf[_0x31332e(0x211)]),await this[_0x31332e(0x266)](_0x555c0c),_0x555c0c=Math[_0x31332e(0x25b)](_0x555c0c*1.5,0xea60);continue;}_0x555c0c=this[_0x31332e(0x1f0)];let _0x32c9d0=_0x3fb4cf[_0x31332e(0x260)][_0x31332e(0x24b)](),_0x30bb75=new TextDecoder(),_0x12167c='';while(this[_0x31332e(0x216)]){let {done:_0x4a42e2,value:_0x850cb8}=await _0x32c9d0['read']();if(_0x4a42e2)break;_0x12167c+=_0x30bb75['decode'](_0x850cb8,{'stream':!0x0});let _0x34195b=_0x12167c[_0x31332e(0x250)]('\x0a');_0x12167c=_0x34195b[_0x31332e(0x1f2)]()||'';for(let _0x1c50d9 of _0x34195b){if(!_0x1c50d9[_0x31332e(0x265)]('data:\x20'))continue;try{let _0x36f451=JSON[_0x31332e(0x21f)](_0x1c50d9['slice'](0x6));if(_0x36f451[_0x31332e(0x22b)]==='connected'){this['log'](_0x31332e(0x236)),this['emit'](_0x31332e(0x200));continue;}if(_0x36f451[_0x31332e(0x22b)]==='new_task'||_0x36f451['type']==='new_message'||_0x36f451['type']==='broadcast')await this['processInbox']();}catch{}}}}catch(_0x1ed613){if(_0x1ed613[_0x31332e(0x22e)]===_0x31332e(0x205))break;this[_0x31332e(0x25d)](_0x31332e(0x227),_0x1ed613),this[_0x31332e(0x1ee)](_0x31332e(0x257)+_0x1ed613[_0x31332e(0x209)]);}if(this[_0x31332e(0x216)])this['emit'](_0x31332e(0x24a)),this[_0x31332e(0x1ee)](_0x31332e(0x25e)+_0x555c0c/0x3e8+_0x31332e(0x235)),await this[_0x31332e(0x266)](_0x555c0c),_0x555c0c=Math['min'](_0x555c0c*1.5,0xea60);}}async[a0_0x5eb80c(0x1ef)](){const _0xb3c55d=a0_0x5eb80c;try{let _0x3fadbc=(await this['call']('get_inbox',{'alias':this[_0xb3c55d(0x237)],'limit':0xa}))?.[_0xb3c55d(0x218)]||[];for(let _0x32905e of _0x3fadbc)await this['call']('ack_inbox',{'alias':this[_0xb3c55d(0x237)],'message_id':_0x32905e['id']}),this[_0xb3c55d(0x1ee)]('←\x20'+_0x32905e['from_session']+':\x20'+_0x32905e['content'][_0xb3c55d(0x1f3)](0x0,0x3c)),this[_0xb3c55d(0x25d)](_0xb3c55d(0x22c),_0x32905e),this[_0xb3c55d(0x25d)](_0xb3c55d(0x209),_0x32905e);}catch(_0x3f355){this[_0xb3c55d(0x1ee)]('inbox\x20error:\x20'+_0x3f355[_0xb3c55d(0x209)]);}}['sleep'](_0x2f81ac){return new Promise(_0xb9b2bd=>setTimeout(_0xb9b2bd,_0x2f81ac));}}var F=$;export{F as default,$ as CommHub};
1
+ function a0_0x5227(){const _0x310858=['SSE\x20error:\x20','emit','task.replied','<missing>','registered','\x20from=','read','tools/call','resumeId','status','message_id','data:\x20','1038880MLCytS','\x20error=','idle','text/event-stream','<pending>',']\x20[commhub:','getReader','3AUkyUc','<unknown>','\x20lifecycle=','running','replace','text','fromAlias','heartbeatInterval','614853vqqGVn','result','server','Authorization','now','stringify','getAllStatus','SSE\x20failed:\x20','6ZxYDGv','networkId','reply','missing_task_id','offline','processInbox','error','/mcp','body','from_alias','failed','disconnected','error_message','error_code','abort','application/json,\x20text/event-stream','Bearer\x20','get_all_status','signal','connectSSE','AbortError','match','string','disconnect','6403800WgUZFe','\x20transport=','sdk','mcp_http','SSE\x20connected','sending','2.0','sleep','to_alias','sdk-','task_id','completed','token','sseAbort','parent_task_id','task.send.start','decode','startsWith','task.send.failed','autoConnect','content','new_message','task.expired','name','\x20duration_ms=','48854MwtQrK','agent','parse','send_task','lifecycleTracking','network_id','min','normal','send_message','connected','send_failed','POST','inbox\x20error:\x20','messages','send','broadcast','catch','report_status','application/json','heartbeatTimer','\x20to=','task.ack','lifecycle_tracking','json','transport','task.started','message','CommHub\x20rejected\x20task','5JSvVjX','alias','new_task','s...','call','slice','type','847564nwFVwM','reconnectDelay','\x20task_id=','connect','log','224253MZERNw','send_reply','get_inbox','task','toTimeString','1848091DLjKjT','toString','CommHub\x20response\x20omitted\x20task_id','url','unknown\x20error'];a0_0x5227=function(){return _0x310858;};return a0_0x5227();}const a0_0x4804e2=a0_0x1ce7;(function(_0x6a0457,_0x595fff){const _0x49b3f6=a0_0x1ce7,_0x5d9575=_0x6a0457();while(!![]){try{const _0x32e053=parseInt(_0x49b3f6(0x244))/0x1*(parseInt(_0x49b3f6(0x1ff))/0x2)+-parseInt(_0x49b3f6(0x24c))/0x3+parseInt(_0x49b3f6(0x222))/0x4*(-parseInt(_0x49b3f6(0x21b))/0x5)+-parseInt(_0x49b3f6(0x1ce))/0x6*(parseInt(_0x49b3f6(0x22c))/0x7)+parseInt(_0x49b3f6(0x23d))/0x8+-parseInt(_0x49b3f6(0x227))/0x9+parseInt(_0x49b3f6(0x1e6))/0xa;if(_0x32e053===_0x595fff)break;else _0x5d9575['push'](_0x5d9575['shift']());}catch(_0xac4e86){_0x5d9575['push'](_0x5d9575['shift']());}}}(a0_0x5227,0x21a15));import{EventEmitter as a0_0x1acb55}from'events';import{hostname as a0_0x316264}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x4aecdb,_0x5112f5)=>(_0x4aecdb??_0x5112f5)[a0_0x4804e2(0x248)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x4804e2(0x220)](0x0,0xf0);function N(_0x4eebf5){const _0x39d0d7=a0_0x4804e2;return(_0x4eebf5 instanceof Error?_0x4eebf5[_0x39d0d7(0x219)]:String(_0x4eebf5??_0x39d0d7(0x230)))[_0x39d0d7(0x248)](K,'[REDACTED]')[_0x39d0d7(0x248)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x39d0d7(0x220)](0x0,0xf0);}function a0_0x1ce7(_0x342318,_0x5045a6){_0x342318=_0x342318-0x1cd;const _0x522715=a0_0x5227();let _0x1ce739=_0x522715[_0x342318];return _0x1ce739;}function O(_0x53d3aa,_0x13938e=process.env.ANET_TASK_TRACE_FORMAT===a0_0x4804e2(0x216)){const _0x462df5=a0_0x4804e2;if(_0x13938e)return JSON['stringify'](_0x53d3aa);let _0x113968=L(_0x53d3aa[_0x462df5(0x1f4)],_0x462df5(0x234)),_0x3c646d=L(_0x53d3aa[_0x462df5(0x1f0)],_0x462df5(0x241)),_0x49f4cc=_0x53d3aa[_0x462df5(0x1db)]?_0x462df5(0x23e)+_0x53d3aa[_0x462df5(0x1db)]+':'+(_0x53d3aa[_0x462df5(0x1da)]??''):'';return'[commhub:task]\x20'+_0x53d3aa[_0x462df5(0x23a)]+_0x462df5(0x236)+L(_0x53d3aa[_0x462df5(0x1d7)],_0x462df5(0x245))+_0x462df5(0x213)+L(_0x53d3aa[_0x462df5(0x1ee)],_0x462df5(0x245))+_0x462df5(0x224)+_0x3c646d+'\x20parent_task_id='+_0x113968+'\x20network_id='+L(_0x53d3aa[_0x462df5(0x204)],_0x462df5(0x245))+_0x462df5(0x1e7)+_0x53d3aa[_0x462df5(0x217)]+_0x462df5(0x1fe)+_0x53d3aa['duration_ms']+_0x462df5(0x246)+_0x53d3aa[_0x462df5(0x215)]+_0x49f4cc;}function U(_0x11b68c){const _0x4ae7e1=a0_0x4804e2;return{'event':{'sending':_0x4ae7e1(0x1f5),'delivered':'task.send.delivered','failed':_0x4ae7e1(0x1f8),'acked':_0x4ae7e1(0x214),'started':_0x4ae7e1(0x218),'replied':_0x4ae7e1(0x233),'expired':_0x4ae7e1(0x1fc)}[_0x11b68c[_0x4ae7e1(0x23a)]],..._0x11b68c};}function j(_0x46c743){const _0x1c6643=a0_0x4804e2;let _0x2ab9eb=_0x46c743?.[_0x1c6643(0x1f0)]||_0x46c743?.[_0x1c6643(0x23b)]||_0x46c743?.['id'];if(_0x2ab9eb)return String(_0x2ab9eb);let _0x3bd00c=_0x46c743?.[_0x1c6643(0x1fa)]?.[0x0]?.[_0x1c6643(0x249)];if(typeof _0x3bd00c!==_0x1c6643(0x1e4))return null;try{let _0x5267d4=JSON[_0x1c6643(0x201)](_0x3bd00c);return _0x5267d4?.[_0x1c6643(0x1f0)]||_0x5267d4?.[_0x1c6643(0x23b)]||_0x5267d4?.['id']||null;}catch{return null;}}async function X(_0x15fca8,_0x5c40d9){const _0x428433=a0_0x4804e2;let _0x95530d=_0x5c40d9[_0x428433(0x250)]??Date['now'],_0x1c39c2=_0x95530d(),_0x2e9fcb=(_0x577bc2,_0x832a8f,_0x415d26,_0xe174df)=>{const _0x34ccf2=_0x428433;_0x5c40d9[_0x34ccf2(0x226)](O(U({'from_alias':_0x15fca8['fromAlias'],'to_alias':_0x15fca8['toAlias'],'task_id':_0x832a8f,'parent_task_id':_0x15fca8['parentTaskId'],'network_id':_0x15fca8[_0x34ccf2(0x1cf)],'transport':_0x15fca8[_0x34ccf2(0x217)],'status':_0x577bc2,'duration_ms':_0x95530d()-_0x1c39c2,'lifecycle_tracking':_0x15fca8[_0x34ccf2(0x203)],..._0x415d26!==void 0x0?{'error_code':_0xe174df||_0x34ccf2(0x209),'error_message':N(_0x415d26)}:{}})));};_0x2e9fcb(_0x428433(0x1eb),null);try{let _0x2c8722=await _0x5c40d9[_0x428433(0x20d)](),_0x4858b0=j(_0x2c8722);if(_0x4858b0)_0x2e9fcb('delivered',_0x4858b0);else{if(_0x2c8722?.['ok']===!0x1||_0x2c8722?.['error'])_0x2e9fcb('failed',_0x4858b0,_0x2c8722?.[_0x428433(0x1d4)]||_0x428433(0x21a),'send_rejected');else _0x2e9fcb(_0x428433(0x1d8),null,_0x428433(0x22e),_0x428433(0x1d1));}return _0x2c8722;}catch(_0x4dd49a){throw _0x2e9fcb(_0x428433(0x1d8),null,_0x4dd49a,'send_failed'),_0x4dd49a;}}async function Y(_0x4d126a,_0x4034af){const _0x2f21a8=a0_0x4804e2;return X({'fromAlias':_0x4d126a[_0x2f21a8(0x24a)],'toAlias':_0x4d126a[_0x2f21a8(0x21c)],'parentTaskId':_0x4d126a['parentTaskId']||null,'networkId':_0x4d126a[_0x2f21a8(0x1cf)]||null,'transport':_0x2f21a8(0x1e9),'lifecycleTracking':'not_tracked'},_0x4034af);}class $ extends a0_0x1acb55{[a0_0x4804e2(0x22f)];['alias'];[a0_0x4804e2(0x1f2)];[a0_0x4804e2(0x200)];[a0_0x4804e2(0x239)];[a0_0x4804e2(0x24b)];[a0_0x4804e2(0x223)];['heartbeatTimer'];['sseAbort'];[a0_0x4804e2(0x247)]=!0x1;constructor(_0x51b296){const _0x1554f9=a0_0x4804e2;super();if(this[_0x1554f9(0x22f)]=_0x51b296[_0x1554f9(0x22f)][_0x1554f9(0x248)](/\/$/,''),this['alias']=_0x51b296[_0x1554f9(0x21c)],this[_0x1554f9(0x1f2)]=_0x51b296[_0x1554f9(0x1f2)],this[_0x1554f9(0x200)]=_0x51b296[_0x1554f9(0x200)]||_0x1554f9(0x1e8),this[_0x1554f9(0x239)]=_0x1554f9(0x1ef)+_0x51b296['alias']+'-'+Date[_0x1554f9(0x250)]()[_0x1554f9(0x22d)](0x24),this[_0x1554f9(0x24b)]=_0x51b296[_0x1554f9(0x24b)]??0x2bf20,this['reconnectDelay']=_0x51b296['reconnectDelay']??0xbb8,_0x51b296[_0x1554f9(0x1f9)]!==!0x1)this['connect']();}[a0_0x4804e2(0x226)](_0x1bcf99){const _0x1f6f32=a0_0x4804e2;console[_0x1f6f32(0x226)]('['+new Date()[_0x1f6f32(0x22b)]()[_0x1f6f32(0x220)](0x0,0x8)+_0x1f6f32(0x242)+this[_0x1f6f32(0x21c)]+']\x20'+_0x1bcf99);}async[a0_0x4804e2(0x21f)](_0x323d9f,_0x2a4bd6){const _0x509173=a0_0x4804e2;let _0xd6dfb={'Content-Type':_0x509173(0x211),'Accept':_0x509173(0x1dd)};if(this[_0x509173(0x1f2)])_0xd6dfb[_0x509173(0x24f)]='Bearer\x20'+this['token'];let _0x41b800=await(await fetch(this[_0x509173(0x22f)]+_0x509173(0x1d5),{'method':_0x509173(0x20a),'headers':_0xd6dfb,'body':JSON[_0x509173(0x251)]({'jsonrpc':_0x509173(0x1ec),'id':Date[_0x509173(0x250)](),'method':_0x509173(0x238),'params':{'name':_0x323d9f,'arguments':_0x2a4bd6}})}))[_0x509173(0x249)](),_0x146e22=_0x41b800[_0x509173(0x1e3)](/data: (.+)/),_0x3aac51=_0x146e22?JSON['parse'](_0x146e22[0x1]):JSON[_0x509173(0x201)](_0x41b800),_0x571303=_0x3aac51?.[_0x509173(0x24d)]?.[_0x509173(0x1fa)]?.[0x0]?.['text'];return _0x571303?JSON[_0x509173(0x201)](_0x571303):_0x3aac51;}async[a0_0x4804e2(0x225)](){const _0x48a510=a0_0x4804e2;if(this[_0x48a510(0x247)])return;this[_0x48a510(0x247)]=!0x0,await this[_0x48a510(0x23a)]('idle'),this[_0x48a510(0x226)](_0x48a510(0x235)),this[_0x48a510(0x212)]=setInterval(()=>{const _0x3c2620=_0x48a510;this[_0x3c2620(0x23a)](_0x3c2620(0x23f))[_0x3c2620(0x20f)](_0x47f14d=>this[_0x3c2620(0x226)]('heartbeat\x20failed:\x20'+_0x47f14d[_0x3c2620(0x219)]));},this[_0x48a510(0x24b)]),this[_0x48a510(0x1e1)]();}async[a0_0x4804e2(0x1e5)](){const _0x42d02b=a0_0x4804e2;if(this[_0x42d02b(0x247)]=!0x1,this['sseAbort']?.[_0x42d02b(0x1dc)](),this[_0x42d02b(0x212)])clearInterval(this[_0x42d02b(0x212)]);await this[_0x42d02b(0x23a)](_0x42d02b(0x1d2))[_0x42d02b(0x20f)](()=>{}),this[_0x42d02b(0x226)](_0x42d02b(0x1d9));}async[a0_0x4804e2(0x20d)](_0x3a6975,_0x2566ee,_0x3f9551=a0_0x4804e2(0x206)){const _0x3565a7=a0_0x4804e2;return Y({'alias':_0x3a6975,'fromAlias':this[_0x3565a7(0x21c)]},{'log':_0x14ff34=>console['log'](_0x14ff34),'send':()=>this['call'](_0x3565a7(0x202),{'alias':_0x3a6975,'task':_0x2566ee,'priority':_0x3f9551,'from_session':this['alias']})});}async[a0_0x4804e2(0x219)](_0x1fb621,_0x4829a6){const _0x3d20c2=a0_0x4804e2;return this[_0x3d20c2(0x21f)](_0x3d20c2(0x207),{'alias':_0x1fb621,'message':_0x4829a6,'from_session':this[_0x3d20c2(0x21c)]});}async[a0_0x4804e2(0x1d0)](_0x3c0a79,_0x1997e0,_0x331667=a0_0x4804e2(0x1f1)){const _0x9d0dd7=a0_0x4804e2;return this[_0x9d0dd7(0x21f)](_0x9d0dd7(0x228),{'in_reply_to':_0x3c0a79,'text':_0x1997e0,'status':_0x331667});}async[a0_0x4804e2(0x23a)](_0x35c140,_0xad561f){const _0x449789=a0_0x4804e2;return this[_0x449789(0x21f)](_0x449789(0x210),{'resume_id':this['resumeId'],'alias':this['alias'],'status':_0x35c140,'server':a0_0x316264(),'hostname':a0_0x316264(),'agent':this['agent'],'project_dir':process['cwd'](),..._0xad561f});}async[a0_0x4804e2(0x252)](){const _0x2d083f=a0_0x4804e2;return this[_0x2d083f(0x21f)](_0x2d083f(0x1df),{});}async['broadcast'](_0x33f243,_0x5d6247){const _0x4ebf1f=a0_0x4804e2;return this[_0x4ebf1f(0x21f)](_0x4ebf1f(0x20e),{'message':_0x33f243,'filter_server':_0x5d6247?.[_0x4ebf1f(0x24e)],'filter_status':_0x5d6247?.['status']});}async[a0_0x4804e2(0x1e1)](){const _0x5311ec=a0_0x4804e2;let _0x4a5dbc=encodeURIComponent(this['alias']),_0x36d6ff=this['url']+'/events/'+_0x4a5dbc,_0x52b5b7=this[_0x5311ec(0x223)];while(this[_0x5311ec(0x247)]){try{this[_0x5311ec(0x1f3)]=new AbortController();let _0x2c5a83={'Accept':_0x5311ec(0x240)};if(this[_0x5311ec(0x1f2)])_0x2c5a83[_0x5311ec(0x24f)]=_0x5311ec(0x1de)+this[_0x5311ec(0x1f2)];let _0x5a1b7b=await fetch(_0x36d6ff,{'headers':_0x2c5a83,'signal':this[_0x5311ec(0x1f3)][_0x5311ec(0x1e0)]});if(!_0x5a1b7b['ok']||!_0x5a1b7b[_0x5311ec(0x1d6)]){this[_0x5311ec(0x226)](_0x5311ec(0x1cd)+_0x5a1b7b['status']),await this[_0x5311ec(0x1ed)](_0x52b5b7),_0x52b5b7=Math[_0x5311ec(0x205)](_0x52b5b7*1.5,0xea60);continue;}_0x52b5b7=this['reconnectDelay'];let _0x277eef=_0x5a1b7b['body'][_0x5311ec(0x243)](),_0x4eff18=new TextDecoder(),_0x2a44af='';while(this['running']){let {done:_0x1953b0,value:_0x5d9d59}=await _0x277eef[_0x5311ec(0x237)]();if(_0x1953b0)break;_0x2a44af+=_0x4eff18[_0x5311ec(0x1f6)](_0x5d9d59,{'stream':!0x0});let _0x3276fd=_0x2a44af['split']('\x0a');_0x2a44af=_0x3276fd['pop']()||'';for(let _0x49df2e of _0x3276fd){if(!_0x49df2e[_0x5311ec(0x1f7)](_0x5311ec(0x23c)))continue;try{let _0x481259=JSON[_0x5311ec(0x201)](_0x49df2e[_0x5311ec(0x220)](0x6));if(_0x481259[_0x5311ec(0x221)]===_0x5311ec(0x208)){this['log'](_0x5311ec(0x1ea)),this[_0x5311ec(0x232)](_0x5311ec(0x208));continue;}if(_0x481259[_0x5311ec(0x221)]===_0x5311ec(0x21d)||_0x481259[_0x5311ec(0x221)]===_0x5311ec(0x1fb)||_0x481259[_0x5311ec(0x221)]===_0x5311ec(0x20e))await this[_0x5311ec(0x1d3)]();}catch{}}}}catch(_0x323f01){if(_0x323f01[_0x5311ec(0x1fd)]===_0x5311ec(0x1e2))break;this[_0x5311ec(0x232)](_0x5311ec(0x1d4),_0x323f01),this[_0x5311ec(0x226)](_0x5311ec(0x231)+_0x323f01[_0x5311ec(0x219)]);}if(this['running'])this[_0x5311ec(0x232)](_0x5311ec(0x1d9)),this['log']('SSE\x20reconnecting\x20in\x20'+_0x52b5b7/0x3e8+_0x5311ec(0x21e)),await this[_0x5311ec(0x1ed)](_0x52b5b7),_0x52b5b7=Math[_0x5311ec(0x205)](_0x52b5b7*1.5,0xea60);}}async[a0_0x4804e2(0x1d3)](){const _0x3ee230=a0_0x4804e2;try{let _0x5c3c77=(await this[_0x3ee230(0x21f)](_0x3ee230(0x229),{'alias':this[_0x3ee230(0x21c)],'limit':0xa}))?.[_0x3ee230(0x20c)]||[];for(let _0x35a13a of _0x5c3c77)await this[_0x3ee230(0x21f)]('ack_inbox',{'alias':this[_0x3ee230(0x21c)],'message_id':_0x35a13a['id']}),this[_0x3ee230(0x226)]('←\x20'+_0x35a13a['from_session']+':\x20'+_0x35a13a[_0x3ee230(0x1fa)][_0x3ee230(0x220)](0x0,0x3c)),this[_0x3ee230(0x232)](_0x3ee230(0x22a),_0x35a13a),this[_0x3ee230(0x232)](_0x3ee230(0x219),_0x35a13a);}catch(_0x36a7cf){this[_0x3ee230(0x226)](_0x3ee230(0x20b)+_0x36a7cf['message']);}}[a0_0x4804e2(0x1ed)](_0x4e4f97){return new Promise(_0x50c3df=>setTimeout(_0x50c3df,_0x4e4f97));}}var F=$;export{F as default,$ as CommHub};
@@ -0,0 +1,71 @@
1
+ export type CodexHomeSource = "config.codexHome" | "node-codex-home" | "config.env" | "none";
2
+ export interface CodexHomeResolution {
3
+ /** null = 这台节点没有专属 CODEX_HOME(普通 codex 节点用 codex 自己的默认 ~/.codex)。 */
4
+ codexHome: string | null;
5
+ source: CodexHomeSource;
6
+ }
7
+ export interface ResolveNodeCodexHomeInput {
8
+ nodeDir: string;
9
+ /** 节点 config.json 的内容(只读其中三格:codexHome / codexCopresence / env.CODEX_HOME)。 */
10
+ config: Record<string, unknown> | null | undefined;
11
+ exists?: (path: string) => boolean;
12
+ }
13
+ /**
14
+ * 本节点的 CODEX_HOME,只由节点自己的配置/目录决定。优先级:
15
+ * ① config.codexHome(`--codex-home` 显式指定后持久化的那一格)
16
+ * ② <nodeDir>/codex-home(共存节点,或目录已经存在)
17
+ * ③ config.env.CODEX_HOME(节点 profile 自己写的,字面字符串)
18
+ * ④ 没有 → null
19
+ * **进程环境从不参与**:那正是本模块要挡掉的来源。
20
+ */
21
+ export declare function resolveNodeCodexHome(input: ResolveNodeCodexHomeInput): CodexHomeResolution;
22
+ export declare function looksLikeAnetNodeCodexHome(path: string): boolean;
23
+ export interface ApplyCodexHomeResult {
24
+ /** 实际交给子进程的值(undefined = 不设,交给 codex 默认)。 */
25
+ codexHome: string | undefined;
26
+ /** 给人看的一行;没有需要说的时候为 null。 */
27
+ note: string | null;
28
+ }
29
+ /**
30
+ * 把解析结果写进一份**将要交给子进程**的 env(原地修改并返回结论)。
31
+ * - 有专属值 → 强制写入,覆盖任何继承来的值。
32
+ * - 没有专属值、而继承来的值是**别的 anet 节点**的 codex-home → 删掉(那绝不是本节点的)。
33
+ * - 没有专属值、继承来的是运维自己 export 的普通路径 → 保留(不改变普通 codex 节点的既有行为),
34
+ * 并说一句它来自环境。
35
+ */
36
+ export declare function applyNodeCodexHome(env: Record<string, string | undefined>, resolution: CodexHomeResolution): ApplyCodexHomeResult;
37
+ export interface ProcReader {
38
+ /** /proc/<pid>/environ 的原始内容;读不到返回 null。 */
39
+ environ(pid: number): string | null;
40
+ /** 所有进程的 [pid, ppid];读不到返回 []。 */
41
+ parents(): Array<[number, number]>;
42
+ }
43
+ export declare const linuxProcReader: ProcReader;
44
+ /** 环境块里某个变量的值:undefined = 环境读不到;null = 读到了但没有这个变量。 */
45
+ export declare function envVarFromEnviron(environ: string | null, name: string): string | null | undefined;
46
+ export declare function descendantPids(rootPid: number, parents: Array<[number, number]>): number[];
47
+ export type CodexHomeVerdict = {
48
+ ok: true;
49
+ checked: number[];
50
+ skipped?: string;
51
+ } | {
52
+ ok: false;
53
+ pid: number;
54
+ actual: string | null;
55
+ expected: string;
56
+ message: string;
57
+ };
58
+ /**
59
+ * 读 rootPid 及其全部后代的 /proc/<pid>/environ:
60
+ * - rootPid 自己的 CODEX_HOME 必须**正好等于** expected(缺失也算不符);
61
+ * - 后代里凡是带 CODEX_HOME 的,也必须等于 expected(某个后代自己 unset 掉不算错)。
62
+ * 不是 Linux、或 rootPid 的环境根本读不到(进程已退出/权限)→ ok:true + skipped,由调用方决定怎么说。
63
+ * 🔴 读不到 ≠ 核对通过:skipped 必须被调用方打印出来,不能当绿。
64
+ */
65
+ export declare function verifyProcessTreeCodexHome(opts: {
66
+ rootPid: number;
67
+ expected: string;
68
+ label: string;
69
+ platform?: string;
70
+ reader?: ProcReader;
71
+ }): CodexHomeVerdict;