@sleep2agi/agent-network 2.3.0-preview.119 → 2.3.0-preview.121
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_0x44d3c0=a0_0x9fb0;(function(_0xcf57d2,_0x277d03){const _0x13f471=a0_0x9fb0,_0x23abe9=_0xcf57d2();while(!![]){try{const _0x493b8f=parseInt(_0x13f471(0x1a2))/0x1+-parseInt(_0x13f471(0x1bf))/0x2*(-parseInt(_0x13f471(0x196))/0x3)+-parseInt(_0x13f471(0x1a1))/0x4+parseInt(_0x13f471(0x1f3))/0x5+parseInt(_0x13f471(0x1ef))/0x6+-parseInt(_0x13f471(0x1ff))/0x7*(-parseInt(_0x13f471(0x1b9))/0x8)+parseInt(_0x13f471(0x199))/0x9*(-parseInt(_0x13f471(0x1c0))/0xa);if(_0x493b8f===_0x277d03)break;else _0x23abe9['push'](_0x23abe9['shift']());}catch(_0x436a6d){_0x23abe9['push'](_0x23abe9['shift']());}}}(a0_0x2e69,0x7102a));function a0_0x9fb0(_0x140a00,_0x48433a){_0x140a00=_0x140a00-0x180;const _0x2e6917=a0_0x2e69();let _0x9fb03e=_0x2e6917[_0x140a00];return _0x9fb03e;}import{EventEmitter as a0_0x3f510e}from'events';import{hostname as a0_0x593437}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x52bcf3,_0x135a45)=>(_0x52bcf3??_0x135a45)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x44d3c0(0x1ae)](0x0,0xf0);function N(_0x4dee0f){const _0x45f874=a0_0x44d3c0;return(_0x4dee0f instanceof Error?_0x4dee0f[_0x45f874(0x1b5)]:String(_0x4dee0f??_0x45f874(0x1a7)))[_0x45f874(0x1da)](K,_0x45f874(0x194))[_0x45f874(0x1da)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x45f874(0x1ae)](0x0,0xf0);}function O(_0x54a03c,_0x838a8f=process.env.ANET_TASK_TRACE_FORMAT===a0_0x44d3c0(0x1e9)){const _0x61b3ee=a0_0x44d3c0;if(_0x838a8f)return JSON['stringify'](_0x54a03c);let _0x2a0b72=L(_0x54a03c[_0x61b3ee(0x1fc)],_0x61b3ee(0x1ba)),_0x3e7ef4=L(_0x54a03c[_0x61b3ee(0x1f1)],_0x61b3ee(0x1bd)),_0x2135f8=_0x54a03c['error_code']?'\x20error='+_0x54a03c[_0x61b3ee(0x1c5)]+':'+(_0x54a03c[_0x61b3ee(0x1dc)]??''):'';return'[commhub:task]\x20'+_0x54a03c['status']+'\x20from='+L(_0x54a03c[_0x61b3ee(0x19f)],_0x61b3ee(0x1de))+_0x61b3ee(0x1ca)+L(_0x54a03c[_0x61b3ee(0x1d3)],_0x61b3ee(0x1de))+'\x20task_id='+_0x3e7ef4+_0x61b3ee(0x1be)+_0x2a0b72+_0x61b3ee(0x1c6)+L(_0x54a03c['network_id'],_0x61b3ee(0x1de))+_0x61b3ee(0x1ee)+_0x54a03c[_0x61b3ee(0x19c)]+'\x20duration_ms='+_0x54a03c[_0x61b3ee(0x1af)]+_0x61b3ee(0x184)+_0x54a03c['lifecycle_tracking']+_0x2135f8;}function U(_0x2f3a4d){const _0x3b3f41=a0_0x44d3c0;return{'event':{'sending':_0x3b3f41(0x195),'delivered':_0x3b3f41(0x1b3),'failed':'task.send.failed','acked':_0x3b3f41(0x1f7),'started':_0x3b3f41(0x186),'replied':_0x3b3f41(0x18f),'expired':_0x3b3f41(0x1d7)}[_0x2f3a4d[_0x3b3f41(0x18e)]],..._0x2f3a4d};}function j(_0x302975){const _0x28e126=a0_0x44d3c0;let _0x5a39bc=_0x302975?.[_0x28e126(0x1f1)]||_0x302975?.['message_id']||_0x302975?.['id'];if(_0x5a39bc)return String(_0x5a39bc);let _0x248dd0=_0x302975?.[_0x28e126(0x1a4)]?.[0x0]?.['text'];if(typeof _0x248dd0!==_0x28e126(0x1d1))return null;try{let _0x505dfd=JSON[_0x28e126(0x197)](_0x248dd0);return _0x505dfd?.[_0x28e126(0x1f1)]||_0x505dfd?.[_0x28e126(0x198)]||_0x505dfd?.['id']||null;}catch{return null;}}async function X(_0x1951ba,_0x1032e8){const _0x53a1fa=a0_0x44d3c0;let _0x17c4ba=_0x1032e8['now']??Date[_0x53a1fa(0x1dd)],_0x11a02b=_0x17c4ba(),_0x1be674=(_0x2db59e,_0x1c03dd,_0x1797c0,_0x4678a6)=>{const _0x1fec13=_0x53a1fa;_0x1032e8[_0x1fec13(0x1cf)](O(U({'from_alias':_0x1951ba[_0x1fec13(0x19d)],'to_alias':_0x1951ba[_0x1fec13(0x1e5)],'task_id':_0x1c03dd,'parent_task_id':_0x1951ba[_0x1fec13(0x1b4)],'network_id':_0x1951ba['networkId'],'transport':_0x1951ba[_0x1fec13(0x19c)],'status':_0x2db59e,'duration_ms':_0x17c4ba()-_0x11a02b,'lifecycle_tracking':_0x1951ba[_0x1fec13(0x187)],..._0x1797c0!==void 0x0?{'error_code':_0x4678a6||_0x1fec13(0x1fd),'error_message':N(_0x1797c0)}:{}})));};_0x1be674(_0x53a1fa(0x18c),null);try{let _0x7bd43c=await _0x1032e8[_0x53a1fa(0x1f5)](),_0x4f94ee=j(_0x7bd43c);if(_0x4f94ee)_0x1be674(_0x53a1fa(0x18a),_0x4f94ee);else{if(_0x7bd43c?.['ok']===!0x1||_0x7bd43c?.[_0x53a1fa(0x1b6)])_0x1be674(_0x53a1fa(0x1b8),_0x4f94ee,_0x7bd43c?.[_0x53a1fa(0x1b6)]||_0x53a1fa(0x1d6),_0x53a1fa(0x1b2));else _0x1be674(_0x53a1fa(0x1b8),null,'CommHub\x20response\x20omitted\x20task_id',_0x53a1fa(0x1c2));}return _0x7bd43c;}catch(_0x29b343){throw _0x1be674(_0x53a1fa(0x1b8),null,_0x29b343,_0x53a1fa(0x1fd)),_0x29b343;}}async function Y(_0x4e71b1,_0x3f4cf5){const _0x338d33=a0_0x44d3c0;return X({'fromAlias':_0x4e71b1['fromAlias'],'toAlias':_0x4e71b1[_0x338d33(0x19e)],'parentTaskId':_0x4e71b1[_0x338d33(0x1b4)]||null,'networkId':_0x4e71b1[_0x338d33(0x1f4)]||null,'transport':'mcp_http','lifecycleTracking':_0x338d33(0x1fa)},_0x3f4cf5);}function a0_0x2e69(){const _0x1ef0d5=['connect','error_message','now','<unknown>','connectSSE','processInbox','from_session','SSE\x20failed:\x20','send_task','application/json,\x20text/event-stream','toAlias','text','autoConnect','ack_inbox','json','heartbeatTimer','broadcast','report_status','connected','\x20transport=','442728vpehxI','heartbeatInterval','task_id','2.0','4078790ikGein','networkId','send','signal','task.ack','sdk','/mcp','not_tracked','min','parent_task_id','send_failed','resumeId','3122861MxmouK','result','agent','url','sdk-','registered','\x20lifecycle=','POST','task.started','lifecycleTracking','send_message','server','delivered','toTimeString','sending','AbortError','status','task.replied','catch','sleep','idle','disconnected','[REDACTED]','task.send.start','912885gGsKZb','parse','message_id','3705804fvzjzX','sseAbort','toString','transport','fromAlias','alias','from_alias','read','520732rfRnWA','780688yuhMYm','heartbeat\x20failed:\x20','content','inbox\x20error:\x20','token','unknown\x20error','match','text/event-stream','running','reconnectDelay','type','Bearer\x20','slice','duration_ms','tools/call','cwd','send_rejected','task.send.delivered','parentTaskId','message','error','call','failed','16CZfydS','<missing>','Authorization','name','<pending>','\x20parent_task_id=','6VjeolS','70LwmSbQ','normal','missing_task_id','split','disconnect','error_code','\x20network_id=','new_message','send_reply','getReader','\x20to=','emit','startsWith','abort','application/json','log','SSE\x20connected','string','reply','to_alias','data:\x20','pop','CommHub\x20rejected\x20task','task.expired','stringify',']\x20[commhub:','replace'];a0_0x2e69=function(){return _0x1ef0d5;};return a0_0x2e69();}class $ extends a0_0x3f510e{[a0_0x44d3c0(0x181)];[a0_0x44d3c0(0x19e)];['token'];['agent'];[a0_0x44d3c0(0x1fe)];[a0_0x44d3c0(0x1f0)];[a0_0x44d3c0(0x1ab)];[a0_0x44d3c0(0x1ea)];[a0_0x44d3c0(0x19a)];[a0_0x44d3c0(0x1aa)]=!0x1;constructor(_0x36b404){const _0x35cf30=a0_0x44d3c0;super();if(this[_0x35cf30(0x181)]=_0x36b404[_0x35cf30(0x181)][_0x35cf30(0x1da)](/\/$/,''),this['alias']=_0x36b404[_0x35cf30(0x19e)],this[_0x35cf30(0x1a6)]=_0x36b404['token'],this[_0x35cf30(0x180)]=_0x36b404['agent']||_0x35cf30(0x1f8),this[_0x35cf30(0x1fe)]=_0x35cf30(0x182)+_0x36b404[_0x35cf30(0x19e)]+'-'+Date[_0x35cf30(0x1dd)]()[_0x35cf30(0x19b)](0x24),this[_0x35cf30(0x1f0)]=_0x36b404[_0x35cf30(0x1f0)]??0x2bf20,this[_0x35cf30(0x1ab)]=_0x36b404[_0x35cf30(0x1ab)]??0xbb8,_0x36b404[_0x35cf30(0x1e7)]!==!0x1)this[_0x35cf30(0x1db)]();}[a0_0x44d3c0(0x1cf)](_0x3ea427){const _0x3d5483=a0_0x44d3c0;console[_0x3d5483(0x1cf)]('['+new Date()[_0x3d5483(0x18b)]()[_0x3d5483(0x1ae)](0x0,0x8)+_0x3d5483(0x1d9)+this[_0x3d5483(0x19e)]+']\x20'+_0x3ea427);}async[a0_0x44d3c0(0x1b7)](_0x18f954,_0x16d7ae){const _0x5c7d8a=a0_0x44d3c0;let _0x53d9eb={'Content-Type':_0x5c7d8a(0x1ce),'Accept':_0x5c7d8a(0x1e4)};if(this[_0x5c7d8a(0x1a6)])_0x53d9eb['Authorization']='Bearer\x20'+this[_0x5c7d8a(0x1a6)];let _0x36f2d0=await(await fetch(this[_0x5c7d8a(0x181)]+_0x5c7d8a(0x1f9),{'method':_0x5c7d8a(0x185),'headers':_0x53d9eb,'body':JSON[_0x5c7d8a(0x1d8)]({'jsonrpc':_0x5c7d8a(0x1f2),'id':Date[_0x5c7d8a(0x1dd)](),'method':_0x5c7d8a(0x1b0),'params':{'name':_0x18f954,'arguments':_0x16d7ae}})}))[_0x5c7d8a(0x1e6)](),_0x5ec370=_0x36f2d0[_0x5c7d8a(0x1a8)](/data: (.+)/),_0x36ca9b=_0x5ec370?JSON[_0x5c7d8a(0x197)](_0x5ec370[0x1]):JSON[_0x5c7d8a(0x197)](_0x36f2d0),_0x5df45e=_0x36ca9b?.[_0x5c7d8a(0x200)]?.[_0x5c7d8a(0x1a4)]?.[0x0]?.[_0x5c7d8a(0x1e6)];return _0x5df45e?JSON['parse'](_0x5df45e):_0x36ca9b;}async['connect'](){const _0x28eeda=a0_0x44d3c0;if(this[_0x28eeda(0x1aa)])return;this[_0x28eeda(0x1aa)]=!0x0,await this['status'](_0x28eeda(0x192)),this[_0x28eeda(0x1cf)](_0x28eeda(0x183)),this['heartbeatTimer']=setInterval(()=>{const _0x3c579b=_0x28eeda;this['status'](_0x3c579b(0x192))[_0x3c579b(0x190)](_0x1a47f0=>this['log'](_0x3c579b(0x1a3)+_0x1a47f0[_0x3c579b(0x1b5)]));},this[_0x28eeda(0x1f0)]),this[_0x28eeda(0x1df)]();}async[a0_0x44d3c0(0x1c4)](){const _0x3479b7=a0_0x44d3c0;if(this[_0x3479b7(0x1aa)]=!0x1,this['sseAbort']?.[_0x3479b7(0x1cd)](),this[_0x3479b7(0x1ea)])clearInterval(this[_0x3479b7(0x1ea)]);await this[_0x3479b7(0x18e)]('offline')[_0x3479b7(0x190)](()=>{}),this['log'](_0x3479b7(0x193));}async['send'](_0x4fc32f,_0x1f360c,_0x20b766=a0_0x44d3c0(0x1c1)){const _0x37afd3=a0_0x44d3c0;return Y({'alias':_0x4fc32f,'fromAlias':this['alias']},{'log':_0x5192f0=>console['log'](_0x5192f0),'send':()=>this[_0x37afd3(0x1b7)](_0x37afd3(0x1e3),{'alias':_0x4fc32f,'task':_0x1f360c,'priority':_0x20b766,'from_session':this['alias']})});}async[a0_0x44d3c0(0x1b5)](_0x404832,_0x4cb98c){const _0x214641=a0_0x44d3c0;return this[_0x214641(0x1b7)](_0x214641(0x188),{'alias':_0x404832,'message':_0x4cb98c,'from_session':this[_0x214641(0x19e)]});}async[a0_0x44d3c0(0x1d2)](_0x274e43,_0x2bb064,_0x26fb75='completed'){const _0x8abaed=a0_0x44d3c0;return this[_0x8abaed(0x1b7)](_0x8abaed(0x1c8),{'in_reply_to':_0x274e43,'text':_0x2bb064,'status':_0x26fb75});}async[a0_0x44d3c0(0x18e)](_0x51497b,_0x2683b3){const _0x9649d=a0_0x44d3c0;return this[_0x9649d(0x1b7)](_0x9649d(0x1ec),{'resume_id':this[_0x9649d(0x1fe)],'alias':this[_0x9649d(0x19e)],'status':_0x51497b,'server':a0_0x593437(),'hostname':a0_0x593437(),'agent':this[_0x9649d(0x180)],'project_dir':process[_0x9649d(0x1b1)](),..._0x2683b3});}async['getAllStatus'](){const _0x2ecc15=a0_0x44d3c0;return this[_0x2ecc15(0x1b7)]('get_all_status',{});}async[a0_0x44d3c0(0x1eb)](_0x324533,_0x2d1f3e){const _0x1d8b80=a0_0x44d3c0;return this[_0x1d8b80(0x1b7)](_0x1d8b80(0x1eb),{'message':_0x324533,'filter_server':_0x2d1f3e?.[_0x1d8b80(0x189)],'filter_status':_0x2d1f3e?.[_0x1d8b80(0x18e)]});}async[a0_0x44d3c0(0x1df)](){const _0xe68942=a0_0x44d3c0;let _0x478e0e=encodeURIComponent(this['alias']),_0x3b12fe=this[_0xe68942(0x181)]+'/events/'+_0x478e0e,_0x53fb37=this[_0xe68942(0x1ab)];while(this[_0xe68942(0x1aa)]){try{this[_0xe68942(0x19a)]=new AbortController();let _0x3b5769={'Accept':_0xe68942(0x1a9)};if(this[_0xe68942(0x1a6)])_0x3b5769[_0xe68942(0x1bb)]=_0xe68942(0x1ad)+this[_0xe68942(0x1a6)];let _0x2a6e10=await fetch(_0x3b12fe,{'headers':_0x3b5769,'signal':this[_0xe68942(0x19a)][_0xe68942(0x1f6)]});if(!_0x2a6e10['ok']||!_0x2a6e10['body']){this[_0xe68942(0x1cf)](_0xe68942(0x1e2)+_0x2a6e10['status']),await this['sleep'](_0x53fb37),_0x53fb37=Math[_0xe68942(0x1fb)](_0x53fb37*1.5,0xea60);continue;}_0x53fb37=this[_0xe68942(0x1ab)];let _0x24f92a=_0x2a6e10['body'][_0xe68942(0x1c9)](),_0x4d2d97=new TextDecoder(),_0x758892='';while(this[_0xe68942(0x1aa)]){let {done:_0x1951c9,value:_0x426191}=await _0x24f92a[_0xe68942(0x1a0)]();if(_0x1951c9)break;_0x758892+=_0x4d2d97['decode'](_0x426191,{'stream':!0x0});let _0x64441f=_0x758892[_0xe68942(0x1c3)]('\x0a');_0x758892=_0x64441f[_0xe68942(0x1d5)]()||'';for(let _0x2237fb of _0x64441f){if(!_0x2237fb[_0xe68942(0x1cc)](_0xe68942(0x1d4)))continue;try{let _0x494be1=JSON[_0xe68942(0x197)](_0x2237fb[_0xe68942(0x1ae)](0x6));if(_0x494be1['type']===_0xe68942(0x1ed)){this[_0xe68942(0x1cf)](_0xe68942(0x1d0)),this[_0xe68942(0x1cb)](_0xe68942(0x1ed));continue;}if(_0x494be1[_0xe68942(0x1ac)]==='new_task'||_0x494be1[_0xe68942(0x1ac)]===_0xe68942(0x1c7)||_0x494be1[_0xe68942(0x1ac)]==='broadcast')await this[_0xe68942(0x1e0)]();}catch{}}}}catch(_0x10bd10){if(_0x10bd10[_0xe68942(0x1bc)]===_0xe68942(0x18d))break;this[_0xe68942(0x1cb)](_0xe68942(0x1b6),_0x10bd10),this['log']('SSE\x20error:\x20'+_0x10bd10['message']);}if(this[_0xe68942(0x1aa)])this[_0xe68942(0x1cb)](_0xe68942(0x193)),this[_0xe68942(0x1cf)]('SSE\x20reconnecting\x20in\x20'+_0x53fb37/0x3e8+'s...'),await this[_0xe68942(0x191)](_0x53fb37),_0x53fb37=Math[_0xe68942(0x1fb)](_0x53fb37*1.5,0xea60);}}async[a0_0x44d3c0(0x1e0)](){const _0x1826df=a0_0x44d3c0;try{let _0x556d92=(await this[_0x1826df(0x1b7)]('get_inbox',{'alias':this[_0x1826df(0x19e)],'limit':0xa}))?.['messages']||[];for(let _0x4d4f45 of _0x556d92)await this[_0x1826df(0x1b7)](_0x1826df(0x1e8),{'alias':this[_0x1826df(0x19e)],'message_id':_0x4d4f45['id']}),this['log']('←\x20'+_0x4d4f45[_0x1826df(0x1e1)]+':\x20'+_0x4d4f45['content']['slice'](0x0,0x3c)),this[_0x1826df(0x1cb)]('task',_0x4d4f45),this['emit']('message',_0x4d4f45);}catch(_0x29f54f){this['log'](_0x1826df(0x1a5)+_0x29f54f[_0x1826df(0x1b5)]);}}[a0_0x44d3c0(0x191)](_0x6e27d0){return new Promise(_0x54e9a4=>setTimeout(_0x54e9a4,_0x6e27d0));}}var F=$;export{F as default,$ as CommHub};
|
|
1
|
+
const a0_0x6d7de9=a0_0x35ed;(function(_0x210c30,_0x3dc5ff){const _0x9aec35=a0_0x35ed,_0x2d7763=_0x210c30();while(!![]){try{const _0xeba8e=-parseInt(_0x9aec35(0x12c))/0x1*(parseInt(_0x9aec35(0x16a))/0x2)+-parseInt(_0x9aec35(0x182))/0x3+-parseInt(_0x9aec35(0x168))/0x4*(parseInt(_0x9aec35(0x18f))/0x5)+parseInt(_0x9aec35(0x199))/0x6*(-parseInt(_0x9aec35(0x16d))/0x7)+-parseInt(_0x9aec35(0x153))/0x8*(-parseInt(_0x9aec35(0x176))/0x9)+parseInt(_0x9aec35(0x17c))/0xa+-parseInt(_0x9aec35(0x162))/0xb*(-parseInt(_0x9aec35(0x196))/0xc);if(_0xeba8e===_0x3dc5ff)break;else _0x2d7763['push'](_0x2d7763['shift']());}catch(_0x27af2e){_0x2d7763['push'](_0x2d7763['shift']());}}}(a0_0x2b16,0xd8de4));import{EventEmitter as a0_0x45a37d}from'events';import{hostname as a0_0xf2252e}from'os';function a0_0x2b16(){const _0x2caacb=['text/event-stream','report_status','sdk','getReader','message_id','disconnect','sleep','application/json,\x20text/event-stream','body','catch','json','heartbeat\x20failed:\x20','task.ack','match','task.expired','new_message','getAllStatus','get_all_status','disconnected','resumeId','lifecycleTracking','/events/','running','call','log','\x20duration_ms=','send_reply','<missing>','sseAbort','sdk-','4832IlnLSk','messages','Bearer\x20','alias','agent','pop','startsWith','completed','heartbeatInterval','<pending>','broadcast','reconnectDelay','type','inbox\x20error:\x20','task','11jaKLEi','/mcp',']\x20[commhub:','parse','s...','send_task','388116pJnOcJ','reply','3350dkyAbP','cwd','heartbeatTimer','2037CtcUBK','Authorization','fromAlias','unknown\x20error','networkId','url','SSE\x20failed:\x20','offline','status','3357nmHDtH','string','stringify','now','\x20parent_task_id=','not_tracked','16620640gPvErI','parent_task_id','text','connectSSE','replace','lifecycle_tracking','4168170aNCxxD','registered','tools/call','send_rejected','delivered','\x20network_id=','emit','\x20to=','split','task.send.delivered','SSE\x20reconnecting\x20in\x20','toString','connect','80DgqIOe','slice','token','message','CommHub\x20response\x20omitted\x20task_id','send_message','failed','50932716RBgvYk','from_alias','transport','25698rSsvip','connected','<unknown>','idle','sending','application/json','send_failed','CommHub\x20rejected\x20task','error','server','network_id','new_task','result','parentTaskId','content','processInbox','signal','task_id','630RwdveS','min','task.replied','task.started','\x20from=','[REDACTED]','[commhub:task]\x20','autoConnect','send'];a0_0x2b16=function(){return _0x2caacb;};return a0_0x2b16();}var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x30fe90,_0xd9bf6a)=>(_0x30fe90??_0xd9bf6a)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x6d7de9(0x190)](0x0,0xf0);function N(_0x17ede5){const _0x28107c=a0_0x6d7de9;return(_0x17ede5 instanceof Error?_0x17ede5[_0x28107c(0x192)]:String(_0x17ede5??_0x28107c(0x170)))[_0x28107c(0x180)](K,_0x28107c(0x131))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x28107c(0x190)](0x0,0xf0);}function O(_0x2af591,_0x2397df=process.env.ANET_TASK_TRACE_FORMAT===a0_0x6d7de9(0x13f)){const _0xbea2c1=a0_0x6d7de9;if(_0x2397df)return JSON[_0xbea2c1(0x178)](_0x2af591);let _0x39e992=L(_0x2af591[_0xbea2c1(0x17d)],_0xbea2c1(0x150)),_0x34f77e=L(_0x2af591[_0xbea2c1(0x12b)],_0xbea2c1(0x15c)),_0x231a85=_0x2af591['error_code']?'\x20error='+_0x2af591['error_code']+':'+(_0x2af591['error_message']??''):'';return _0xbea2c1(0x132)+_0x2af591['status']+_0xbea2c1(0x130)+L(_0x2af591[_0xbea2c1(0x197)],_0xbea2c1(0x19b))+_0xbea2c1(0x189)+L(_0x2af591['to_alias'],_0xbea2c1(0x19b))+'\x20task_id='+_0x34f77e+_0xbea2c1(0x17a)+_0x39e992+_0xbea2c1(0x187)+L(_0x2af591[_0xbea2c1(0x1a3)],_0xbea2c1(0x19b))+'\x20transport='+_0x2af591[_0xbea2c1(0x198)]+_0xbea2c1(0x14e)+_0x2af591['duration_ms']+'\x20lifecycle='+_0x2af591[_0xbea2c1(0x181)]+_0x231a85;}function U(_0x216e5e){const _0x3064f0=a0_0x6d7de9;return{'event':{'sending':'task.send.start','delivered':_0x3064f0(0x18b),'failed':'task.send.failed','acked':_0x3064f0(0x141),'started':_0x3064f0(0x12f),'replied':_0x3064f0(0x12e),'expired':_0x3064f0(0x143)}[_0x216e5e[_0x3064f0(0x175)]],..._0x216e5e};}function j(_0x2b4256){const _0x2e49af=a0_0x6d7de9;let _0x3af507=_0x2b4256?.['task_id']||_0x2b4256?.['message_id']||_0x2b4256?.['id'];if(_0x3af507)return String(_0x3af507);let _0xc86beb=_0x2b4256?.[_0x2e49af(0x128)]?.[0x0]?.[_0x2e49af(0x17e)];if(typeof _0xc86beb!==_0x2e49af(0x177))return null;try{let _0xf312c7=JSON['parse'](_0xc86beb);return _0xf312c7?.[_0x2e49af(0x12b)]||_0xf312c7?.[_0x2e49af(0x139)]||_0xf312c7?.['id']||null;}catch{return null;}}async function X(_0x2bb629,_0x50711f){const _0x5076da=a0_0x6d7de9;let _0x39ea02=_0x50711f[_0x5076da(0x179)]??Date[_0x5076da(0x179)],_0x8441af=_0x39ea02(),_0xd988a8=(_0x508a93,_0x142bef,_0x200232,_0x58ac13)=>{const _0x555037=_0x5076da;_0x50711f[_0x555037(0x14d)](O(U({'from_alias':_0x2bb629[_0x555037(0x16f)],'to_alias':_0x2bb629['toAlias'],'task_id':_0x142bef,'parent_task_id':_0x2bb629[_0x555037(0x127)],'network_id':_0x2bb629[_0x555037(0x171)],'transport':_0x2bb629[_0x555037(0x198)],'status':_0x508a93,'duration_ms':_0x39ea02()-_0x8441af,'lifecycle_tracking':_0x2bb629[_0x555037(0x149)],..._0x200232!==void 0x0?{'error_code':_0x58ac13||_0x555037(0x19f),'error_message':N(_0x200232)}:{}})));};_0xd988a8(_0x5076da(0x19d),null);try{let _0x3f01fe=await _0x50711f[_0x5076da(0x134)](),_0x55b04e=j(_0x3f01fe);if(_0x55b04e)_0xd988a8(_0x5076da(0x186),_0x55b04e);else{if(_0x3f01fe?.['ok']===!0x1||_0x3f01fe?.[_0x5076da(0x1a1)])_0xd988a8(_0x5076da(0x195),_0x55b04e,_0x3f01fe?.[_0x5076da(0x1a1)]||_0x5076da(0x1a0),_0x5076da(0x185));else _0xd988a8('failed',null,_0x5076da(0x193),'missing_task_id');}return _0x3f01fe;}catch(_0x5aa73f){throw _0xd988a8('failed',null,_0x5aa73f,_0x5076da(0x19f)),_0x5aa73f;}}function a0_0x35ed(_0x345dab,_0x4e096f){_0x345dab=_0x345dab-0x127;const _0x2b16a9=a0_0x2b16();let _0x35edd5=_0x2b16a9[_0x345dab];return _0x35edd5;}async function Y(_0x39ca49,_0x445ab6){const _0x449380=a0_0x6d7de9;return X({'fromAlias':_0x39ca49[_0x449380(0x16f)],'toAlias':_0x39ca49[_0x449380(0x156)],'parentTaskId':_0x39ca49[_0x449380(0x127)]||null,'networkId':_0x39ca49[_0x449380(0x171)]||null,'transport':'mcp_http','lifecycleTracking':_0x449380(0x17b)},_0x445ab6);}class $ extends a0_0x45a37d{[a0_0x6d7de9(0x172)];['alias'];['token'];[a0_0x6d7de9(0x157)];['resumeId'];['heartbeatInterval'];['reconnectDelay'];[a0_0x6d7de9(0x16c)];[a0_0x6d7de9(0x151)];[a0_0x6d7de9(0x14b)]=!0x1;constructor(_0x1d4ecd){const _0xb2ffd6=a0_0x6d7de9;super();if(this[_0xb2ffd6(0x172)]=_0x1d4ecd[_0xb2ffd6(0x172)][_0xb2ffd6(0x180)](/\/$/,''),this[_0xb2ffd6(0x156)]=_0x1d4ecd['alias'],this[_0xb2ffd6(0x191)]=_0x1d4ecd[_0xb2ffd6(0x191)],this[_0xb2ffd6(0x157)]=_0x1d4ecd[_0xb2ffd6(0x157)]||_0xb2ffd6(0x137),this[_0xb2ffd6(0x148)]=_0xb2ffd6(0x152)+_0x1d4ecd[_0xb2ffd6(0x156)]+'-'+Date['now']()[_0xb2ffd6(0x18d)](0x24),this[_0xb2ffd6(0x15b)]=_0x1d4ecd[_0xb2ffd6(0x15b)]??0x2bf20,this[_0xb2ffd6(0x15e)]=_0x1d4ecd[_0xb2ffd6(0x15e)]??0xbb8,_0x1d4ecd[_0xb2ffd6(0x133)]!==!0x1)this[_0xb2ffd6(0x18e)]();}[a0_0x6d7de9(0x14d)](_0x1f0915){const _0x5c4ad1=a0_0x6d7de9;console['log']('['+new Date()['toTimeString']()['slice'](0x0,0x8)+_0x5c4ad1(0x164)+this[_0x5c4ad1(0x156)]+']\x20'+_0x1f0915);}async[a0_0x6d7de9(0x14c)](_0x55dffa,_0x4cb0dd){const _0x144555=a0_0x6d7de9;let _0x5c36e0={'Content-Type':_0x144555(0x19e),'Accept':_0x144555(0x13c)};if(this[_0x144555(0x191)])_0x5c36e0[_0x144555(0x16e)]=_0x144555(0x155)+this[_0x144555(0x191)];let _0x2c9b94=await(await fetch(this['url']+_0x144555(0x163),{'method':'POST','headers':_0x5c36e0,'body':JSON[_0x144555(0x178)]({'jsonrpc':'2.0','id':Date[_0x144555(0x179)](),'method':_0x144555(0x184),'params':{'name':_0x55dffa,'arguments':_0x4cb0dd}})}))[_0x144555(0x17e)](),_0x1ab427=_0x2c9b94[_0x144555(0x142)](/data: (.+)/),_0x470b83=_0x1ab427?JSON[_0x144555(0x165)](_0x1ab427[0x1]):JSON[_0x144555(0x165)](_0x2c9b94),_0x4460be=_0x470b83?.[_0x144555(0x1a5)]?.[_0x144555(0x128)]?.[0x0]?.[_0x144555(0x17e)];return _0x4460be?JSON[_0x144555(0x165)](_0x4460be):_0x470b83;}async[a0_0x6d7de9(0x18e)](){const _0x52121f=a0_0x6d7de9;if(this[_0x52121f(0x14b)])return;this['running']=!0x0,await this[_0x52121f(0x175)]('idle'),this[_0x52121f(0x14d)](_0x52121f(0x183)),this[_0x52121f(0x16c)]=setInterval(()=>{const _0x28d96d=_0x52121f;this[_0x28d96d(0x175)](_0x28d96d(0x19c))[_0x28d96d(0x13e)](_0x1609dc=>this['log'](_0x28d96d(0x140)+_0x1609dc[_0x28d96d(0x192)]));},this[_0x52121f(0x15b)]),this[_0x52121f(0x17f)]();}async[a0_0x6d7de9(0x13a)](){const _0x366e9f=a0_0x6d7de9;if(this[_0x366e9f(0x14b)]=!0x1,this['sseAbort']?.['abort'](),this[_0x366e9f(0x16c)])clearInterval(this['heartbeatTimer']);await this[_0x366e9f(0x175)](_0x366e9f(0x174))[_0x366e9f(0x13e)](()=>{}),this[_0x366e9f(0x14d)]('disconnected');}async['send'](_0x1eaef3,_0x452e47,_0x59f67e='normal'){const _0x19d1f3=a0_0x6d7de9;return Y({'alias':_0x1eaef3,'fromAlias':this[_0x19d1f3(0x156)]},{'log':_0x550dfb=>console[_0x19d1f3(0x14d)](_0x550dfb),'send':()=>this[_0x19d1f3(0x14c)](_0x19d1f3(0x167),{'alias':_0x1eaef3,'task':_0x452e47,'priority':_0x59f67e,'from_session':this[_0x19d1f3(0x156)]})});}async[a0_0x6d7de9(0x192)](_0x94e2d9,_0x200010){const _0x4dba29=a0_0x6d7de9;return this[_0x4dba29(0x14c)](_0x4dba29(0x194),{'alias':_0x94e2d9,'message':_0x200010,'from_session':this[_0x4dba29(0x156)]});}async[a0_0x6d7de9(0x169)](_0x1ed7ea,_0x419dca,_0x4a6804=a0_0x6d7de9(0x15a)){const _0x5b66d1=a0_0x6d7de9;return this[_0x5b66d1(0x14c)](_0x5b66d1(0x14f),{'in_reply_to':_0x1ed7ea,'text':_0x419dca,'status':_0x4a6804});}async[a0_0x6d7de9(0x175)](_0x28d86,_0x599aca){const _0x10e445=a0_0x6d7de9;return this[_0x10e445(0x14c)](_0x10e445(0x136),{'resume_id':this['resumeId'],'alias':this[_0x10e445(0x156)],'status':_0x28d86,'server':a0_0xf2252e(),'hostname':a0_0xf2252e(),'agent':this[_0x10e445(0x157)],'project_dir':process[_0x10e445(0x16b)](),..._0x599aca});}async[a0_0x6d7de9(0x145)](){const _0xd71e59=a0_0x6d7de9;return this[_0xd71e59(0x14c)](_0xd71e59(0x146),{});}async[a0_0x6d7de9(0x15d)](_0x1bf837,_0x4d0232){const _0x5c45c9=a0_0x6d7de9;return this[_0x5c45c9(0x14c)](_0x5c45c9(0x15d),{'message':_0x1bf837,'filter_server':_0x4d0232?.[_0x5c45c9(0x1a2)],'filter_status':_0x4d0232?.[_0x5c45c9(0x175)]});}async[a0_0x6d7de9(0x17f)](){const _0x57d4f2=a0_0x6d7de9;let _0x2ff49c=encodeURIComponent(this[_0x57d4f2(0x156)]),_0x526510=this['url']+_0x57d4f2(0x14a)+_0x2ff49c,_0xf43851=this[_0x57d4f2(0x15e)];while(this[_0x57d4f2(0x14b)]){try{this['sseAbort']=new AbortController();let _0x52bfc0={'Accept':_0x57d4f2(0x135)};if(this[_0x57d4f2(0x191)])_0x52bfc0[_0x57d4f2(0x16e)]=_0x57d4f2(0x155)+this[_0x57d4f2(0x191)];let _0x2f8014=await fetch(_0x526510,{'headers':_0x52bfc0,'signal':this['sseAbort'][_0x57d4f2(0x12a)]});if(!_0x2f8014['ok']||!_0x2f8014[_0x57d4f2(0x13d)]){this[_0x57d4f2(0x14d)](_0x57d4f2(0x173)+_0x2f8014[_0x57d4f2(0x175)]),await this['sleep'](_0xf43851),_0xf43851=Math[_0x57d4f2(0x12d)](_0xf43851*1.5,0xea60);continue;}_0xf43851=this[_0x57d4f2(0x15e)];let _0x117ae4=_0x2f8014['body'][_0x57d4f2(0x138)](),_0x39c7f6=new TextDecoder(),_0x476b46='';while(this[_0x57d4f2(0x14b)]){let {done:_0x3c7dcf,value:_0x43b492}=await _0x117ae4['read']();if(_0x3c7dcf)break;_0x476b46+=_0x39c7f6['decode'](_0x43b492,{'stream':!0x0});let _0x121a56=_0x476b46[_0x57d4f2(0x18a)]('\x0a');_0x476b46=_0x121a56[_0x57d4f2(0x158)]()||'';for(let _0x15cef1 of _0x121a56){if(!_0x15cef1[_0x57d4f2(0x159)]('data:\x20'))continue;try{let _0x40d345=JSON[_0x57d4f2(0x165)](_0x15cef1[_0x57d4f2(0x190)](0x6));if(_0x40d345[_0x57d4f2(0x15f)]===_0x57d4f2(0x19a)){this[_0x57d4f2(0x14d)]('SSE\x20connected'),this[_0x57d4f2(0x188)]('connected');continue;}if(_0x40d345[_0x57d4f2(0x15f)]===_0x57d4f2(0x1a4)||_0x40d345[_0x57d4f2(0x15f)]===_0x57d4f2(0x144)||_0x40d345[_0x57d4f2(0x15f)]==='broadcast')await this[_0x57d4f2(0x129)]();}catch{}}}}catch(_0x362160){if(_0x362160['name']==='AbortError')break;this[_0x57d4f2(0x188)](_0x57d4f2(0x1a1),_0x362160),this[_0x57d4f2(0x14d)]('SSE\x20error:\x20'+_0x362160[_0x57d4f2(0x192)]);}if(this[_0x57d4f2(0x14b)])this[_0x57d4f2(0x188)](_0x57d4f2(0x147)),this[_0x57d4f2(0x14d)](_0x57d4f2(0x18c)+_0xf43851/0x3e8+_0x57d4f2(0x166)),await this['sleep'](_0xf43851),_0xf43851=Math[_0x57d4f2(0x12d)](_0xf43851*1.5,0xea60);}}async['processInbox'](){const _0x46d16f=a0_0x6d7de9;try{let _0x37df39=(await this[_0x46d16f(0x14c)]('get_inbox',{'alias':this[_0x46d16f(0x156)],'limit':0xa}))?.[_0x46d16f(0x154)]||[];for(let _0x2bc68e of _0x37df39)await this[_0x46d16f(0x14c)]('ack_inbox',{'alias':this[_0x46d16f(0x156)],'message_id':_0x2bc68e['id']}),this[_0x46d16f(0x14d)]('←\x20'+_0x2bc68e['from_session']+':\x20'+_0x2bc68e[_0x46d16f(0x128)]['slice'](0x0,0x3c)),this[_0x46d16f(0x188)](_0x46d16f(0x161),_0x2bc68e),this[_0x46d16f(0x188)](_0x46d16f(0x192),_0x2bc68e);}catch(_0x57c59a){this[_0x46d16f(0x14d)](_0x46d16f(0x160)+_0x57c59a[_0x46d16f(0x192)]);}}[a0_0x6d7de9(0x13b)](_0x272dd6){return new Promise(_0x5658ef=>setTimeout(_0x5658ef,_0x272dd6));}}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;
|