@sleep2agi/agent-network 2.3.0-preview.95 → 2.3.0-preview.97

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_0x4a7953=a0_0x2720;(function(_0x52f593,_0x2a9cb2){const _0x59dc64=a0_0x2720,_0xe0c498=_0x52f593();while(!![]){try{const _0xaf501e=parseInt(_0x59dc64(0xb7))/0x1+parseInt(_0x59dc64(0xbc))/0x2+-parseInt(_0x59dc64(0xfb))/0x3+-parseInt(_0x59dc64(0x114))/0x4+-parseInt(_0x59dc64(0xbf))/0x5*(parseInt(_0x59dc64(0xe1))/0x6)+-parseInt(_0x59dc64(0xa7))/0x7+parseInt(_0x59dc64(0x103))/0x8;if(_0xaf501e===_0x2a9cb2)break;else _0xe0c498['push'](_0xe0c498['shift']());}catch(_0x2bbdb7){_0xe0c498['push'](_0xe0c498['shift']());}}}(a0_0x2202,0x9a03e));import{EventEmitter as a0_0xfd59e1}from'events';import{hostname as a0_0x6c445c}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x50dec3,_0x5bbbb7)=>(_0x50dec3??_0x5bbbb7)[a0_0x4a7953(0x116)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x4a7953(0xab)](0x0,0xf0);function a0_0x2202(){const _0x2a5e20=['AbortError','unknown\x20error','catch','min','content','toString','parse','s...','error_message','error','pop','1195073oMaIkh','log','message_id','connect','task.send.start','985066JflaKk','\x20network_id=','report_status','1597635QPEgFw','send','networkId','\x20lifecycle=','alias','task.send.failed','application/json','Authorization','send_rejected','[commhub:task]\x20','duration_ms','toAlias','\x20task_id=','sdk-','task.ack','completed','agent',']\x20[commhub:','text','\x20error=','new_task','network_id','match','broadcast','/mcp','now','delivered','task_id','send_failed','application/json,\x20text/event-stream','running','SSE\x20failed:\x20','error_code','emit','18ISKtPY','result','offline','sseAbort','missing_task_id','failed','split','fromAlias','name','disconnect','2.0','processInbox','reconnectDelay','abort','heartbeatTimer','send_task','sending','sleep','\x20parent_task_id=','/events/','token','task.send.delivered','messages','not_tracked','lifecycleTracking','task','1684662zBWUZO','SSE\x20reconnecting\x20in\x20','stringify','text/event-stream','<unknown>','parentTaskId','idle','getAllStatus','13389536iIXiXh','<pending>','getReader','\x20to=','status','message','url','task.expired','\x20transport=','tools/call','send_message','SSE\x20connected','to_alias','CommHub\x20response\x20omitted\x20task_id','string','lifecycle_tracking','heartbeatInterval','1603212JFpMlX','SSE\x20error:\x20','replace','task.replied','ack_inbox','Bearer\x20','normal','new_message','from_session','json','CommHub\x20rejected\x20task','call','disconnected','toTimeString','type','decode','signal','resumeId','task.started','mcp_http','5666598JIErjB','connectSSE','\x20from=','sdk','slice'];a0_0x2202=function(){return _0x2a5e20;};return a0_0x2202();}function N(_0x5e5a08){const _0x5d9059=a0_0x4a7953;return(_0x5e5a08 instanceof Error?_0x5e5a08[_0x5d9059(0x108)]:String(_0x5e5a08??_0x5d9059(0xad)))['replace'](K,'[REDACTED]')[_0x5d9059(0x116)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x5d9059(0xab)](0x0,0xf0);}function a0_0x2720(_0x4eb483,_0x108ab2){_0x4eb483=_0x4eb483-0x96;const _0x220293=a0_0x2202();let _0x2720fe=_0x220293[_0x4eb483];return _0x2720fe;}function O(_0x4dd2d4,_0x416395=process.env.ANET_TASK_TRACE_FORMAT===a0_0x4a7953(0x9c)){const _0x53068f=a0_0x4a7953;if(_0x416395)return JSON[_0x53068f(0xfd)](_0x4dd2d4);let _0x5afae9=L(_0x4dd2d4['parent_task_id'],'<missing>'),_0x41b394=L(_0x4dd2d4[_0x53068f(0xda)],_0x53068f(0x104)),_0x57567c=_0x4dd2d4[_0x53068f(0xdf)]?_0x53068f(0xd2)+_0x4dd2d4[_0x53068f(0xdf)]+':'+(_0x4dd2d4[_0x53068f(0xb4)]??''):'';return _0x53068f(0xc8)+_0x4dd2d4['status']+_0x53068f(0xa9)+L(_0x4dd2d4['from_alias'],'<unknown>')+_0x53068f(0x106)+L(_0x4dd2d4[_0x53068f(0x10f)],'<unknown>')+_0x53068f(0xcb)+_0x41b394+_0x53068f(0xf3)+_0x5afae9+_0x53068f(0xbd)+L(_0x4dd2d4[_0x53068f(0xd4)],_0x53068f(0xff))+_0x53068f(0x10b)+_0x4dd2d4['transport']+'\x20duration_ms='+_0x4dd2d4[_0x53068f(0xc9)]+_0x53068f(0xc2)+_0x4dd2d4[_0x53068f(0x112)]+_0x57567c;}function U(_0x405f2b){const _0xf95c9c=a0_0x4a7953;return{'event':{'sending':_0xf95c9c(0xbb),'delivered':_0xf95c9c(0xf6),'failed':_0xf95c9c(0xc4),'acked':_0xf95c9c(0xcd),'started':_0xf95c9c(0xa5),'replied':_0xf95c9c(0x96),'expired':_0xf95c9c(0x10a)}[_0x405f2b[_0xf95c9c(0x107)]],..._0x405f2b};}function j(_0x13a4a3){const _0x811f4=a0_0x4a7953;let _0xc13d82=_0x13a4a3?.[_0x811f4(0xda)]||_0x13a4a3?.[_0x811f4(0xb9)]||_0x13a4a3?.['id'];if(_0xc13d82)return String(_0xc13d82);let _0x10f859=_0x13a4a3?.[_0x811f4(0xb0)]?.[0x0]?.[_0x811f4(0xd1)];if(typeof _0x10f859!==_0x811f4(0x111))return null;try{let _0x2464d7=JSON['parse'](_0x10f859);return _0x2464d7?.[_0x811f4(0xda)]||_0x2464d7?.['message_id']||_0x2464d7?.['id']||null;}catch{return null;}}async function X(_0x334274,_0x2c92f0){const _0x40c578=a0_0x4a7953;let _0x28c550=_0x2c92f0[_0x40c578(0xd8)]??Date[_0x40c578(0xd8)],_0x32db4b=_0x28c550(),_0x3057a8=(_0x260608,_0x71db2b,_0x5d36eb,_0x2c01b7)=>{const _0x24394a=_0x40c578;_0x2c92f0[_0x24394a(0xb8)](O(U({'from_alias':_0x334274[_0x24394a(0xe8)],'to_alias':_0x334274[_0x24394a(0xca)],'task_id':_0x71db2b,'parent_task_id':_0x334274[_0x24394a(0x100)],'network_id':_0x334274[_0x24394a(0xc1)],'transport':_0x334274['transport'],'status':_0x260608,'duration_ms':_0x28c550()-_0x32db4b,'lifecycle_tracking':_0x334274[_0x24394a(0xf9)],..._0x5d36eb!==void 0x0?{'error_code':_0x2c01b7||_0x24394a(0xdb),'error_message':N(_0x5d36eb)}:{}})));};_0x3057a8(_0x40c578(0xf1),null);try{let _0x293620=await _0x2c92f0[_0x40c578(0xc0)](),_0x1e8826=j(_0x293620);if(_0x1e8826)_0x3057a8(_0x40c578(0xd9),_0x1e8826);else{if(_0x293620?.['ok']===!0x1||_0x293620?.['error'])_0x3057a8(_0x40c578(0xe6),_0x1e8826,_0x293620?.['error']||_0x40c578(0x9d),_0x40c578(0xc7));else _0x3057a8('failed',null,_0x40c578(0x110),_0x40c578(0xe5));}return _0x293620;}catch(_0x2a0b1f){throw _0x3057a8(_0x40c578(0xe6),null,_0x2a0b1f,_0x40c578(0xdb)),_0x2a0b1f;}}async function Y(_0x3a49ac,_0x541a76){const _0x4083d8=a0_0x4a7953;return X({'fromAlias':_0x3a49ac['fromAlias'],'toAlias':_0x3a49ac['alias'],'parentTaskId':_0x3a49ac['parentTaskId']||null,'networkId':_0x3a49ac[_0x4083d8(0xc1)]||null,'transport':_0x4083d8(0xa6),'lifecycleTracking':_0x4083d8(0xf8)},_0x541a76);}class $ extends a0_0xfd59e1{[a0_0x4a7953(0x109)];[a0_0x4a7953(0xc3)];[a0_0x4a7953(0xf5)];[a0_0x4a7953(0xcf)];[a0_0x4a7953(0xa4)];[a0_0x4a7953(0x113)];[a0_0x4a7953(0xed)];[a0_0x4a7953(0xef)];['sseAbort'];['running']=!0x1;constructor(_0x248081){const _0x64cf23=a0_0x4a7953;super();if(this[_0x64cf23(0x109)]=_0x248081[_0x64cf23(0x109)][_0x64cf23(0x116)](/\/$/,''),this[_0x64cf23(0xc3)]=_0x248081[_0x64cf23(0xc3)],this[_0x64cf23(0xf5)]=_0x248081['token'],this[_0x64cf23(0xcf)]=_0x248081[_0x64cf23(0xcf)]||_0x64cf23(0xaa),this['resumeId']=_0x64cf23(0xcc)+_0x248081['alias']+'-'+Date[_0x64cf23(0xd8)]()[_0x64cf23(0xb1)](0x24),this[_0x64cf23(0x113)]=_0x248081[_0x64cf23(0x113)]??0x2bf20,this[_0x64cf23(0xed)]=_0x248081[_0x64cf23(0xed)]??0xbb8,_0x248081['autoConnect']!==!0x1)this[_0x64cf23(0xba)]();}[a0_0x4a7953(0xb8)](_0x45ebc2){const _0x530048=a0_0x4a7953;console[_0x530048(0xb8)]('['+new Date()[_0x530048(0xa0)]()[_0x530048(0xab)](0x0,0x8)+_0x530048(0xd0)+this[_0x530048(0xc3)]+']\x20'+_0x45ebc2);}async['call'](_0x3d3d01,_0x377d7c){const _0x164d05=a0_0x4a7953;let _0x9c1b6b={'Content-Type':_0x164d05(0xc5),'Accept':_0x164d05(0xdc)};if(this['token'])_0x9c1b6b[_0x164d05(0xc6)]=_0x164d05(0x98)+this[_0x164d05(0xf5)];let _0xce763f=await(await fetch(this[_0x164d05(0x109)]+_0x164d05(0xd7),{'method':'POST','headers':_0x9c1b6b,'body':JSON[_0x164d05(0xfd)]({'jsonrpc':_0x164d05(0xeb),'id':Date[_0x164d05(0xd8)](),'method':_0x164d05(0x10c),'params':{'name':_0x3d3d01,'arguments':_0x377d7c}})}))[_0x164d05(0xd1)](),_0x3bb7fb=_0xce763f[_0x164d05(0xd5)](/data: (.+)/),_0x28c73a=_0x3bb7fb?JSON[_0x164d05(0xb2)](_0x3bb7fb[0x1]):JSON[_0x164d05(0xb2)](_0xce763f),_0x137ae7=_0x28c73a?.[_0x164d05(0xe2)]?.['content']?.[0x0]?.[_0x164d05(0xd1)];return _0x137ae7?JSON[_0x164d05(0xb2)](_0x137ae7):_0x28c73a;}async['connect'](){const _0x3719d8=a0_0x4a7953;if(this[_0x3719d8(0xdd)])return;this[_0x3719d8(0xdd)]=!0x0,await this['status']('idle'),this[_0x3719d8(0xb8)]('registered'),this[_0x3719d8(0xef)]=setInterval(()=>{const _0x480ac4=_0x3719d8;this[_0x480ac4(0x107)](_0x480ac4(0x101))[_0x480ac4(0xae)](_0x116cf9=>this[_0x480ac4(0xb8)]('heartbeat\x20failed:\x20'+_0x116cf9['message']));},this[_0x3719d8(0x113)]),this[_0x3719d8(0xa8)]();}async[a0_0x4a7953(0xea)](){const _0x465ff6=a0_0x4a7953;if(this[_0x465ff6(0xdd)]=!0x1,this[_0x465ff6(0xe4)]?.[_0x465ff6(0xee)](),this['heartbeatTimer'])clearInterval(this['heartbeatTimer']);await this[_0x465ff6(0x107)](_0x465ff6(0xe3))[_0x465ff6(0xae)](()=>{}),this[_0x465ff6(0xb8)](_0x465ff6(0x9f));}async[a0_0x4a7953(0xc0)](_0x275fd2,_0x1772dc,_0x147108=a0_0x4a7953(0x99)){const _0x2b5c62=a0_0x4a7953;return Y({'alias':_0x275fd2,'fromAlias':this[_0x2b5c62(0xc3)]},{'log':_0x41e7e3=>console['log'](_0x41e7e3),'send':()=>this[_0x2b5c62(0x9e)](_0x2b5c62(0xf0),{'alias':_0x275fd2,'task':_0x1772dc,'priority':_0x147108,'from_session':this[_0x2b5c62(0xc3)]})});}async[a0_0x4a7953(0x108)](_0x54c12a,_0x267b52){const _0x246e08=a0_0x4a7953;return this[_0x246e08(0x9e)](_0x246e08(0x10d),{'alias':_0x54c12a,'message':_0x267b52,'from_session':this[_0x246e08(0xc3)]});}async['reply'](_0x4b1871,_0x439350,_0x11d19e=a0_0x4a7953(0xce)){const _0x1dfac9=a0_0x4a7953;return this[_0x1dfac9(0x9e)]('send_reply',{'in_reply_to':_0x4b1871,'text':_0x439350,'status':_0x11d19e});}async[a0_0x4a7953(0x107)](_0x42a46f,_0x1d029c){const _0x59b459=a0_0x4a7953;return this[_0x59b459(0x9e)](_0x59b459(0xbe),{'resume_id':this[_0x59b459(0xa4)],'alias':this[_0x59b459(0xc3)],'status':_0x42a46f,'server':a0_0x6c445c(),'hostname':a0_0x6c445c(),'agent':this[_0x59b459(0xcf)],'project_dir':process['cwd'](),..._0x1d029c});}async[a0_0x4a7953(0x102)](){const _0x3c4e4f=a0_0x4a7953;return this[_0x3c4e4f(0x9e)]('get_all_status',{});}async['broadcast'](_0x30250b,_0x12c271){const _0x287a0d=a0_0x4a7953;return this['call']('broadcast',{'message':_0x30250b,'filter_server':_0x12c271?.['server'],'filter_status':_0x12c271?.[_0x287a0d(0x107)]});}async['connectSSE'](){const _0x1ab699=a0_0x4a7953;let _0xd06b84=encodeURIComponent(this[_0x1ab699(0xc3)]),_0x4ec75f=this[_0x1ab699(0x109)]+_0x1ab699(0xf4)+_0xd06b84,_0x3c1a65=this[_0x1ab699(0xed)];while(this[_0x1ab699(0xdd)]){try{this['sseAbort']=new AbortController();let _0x138b70={'Accept':_0x1ab699(0xfe)};if(this[_0x1ab699(0xf5)])_0x138b70[_0x1ab699(0xc6)]='Bearer\x20'+this[_0x1ab699(0xf5)];let _0x108b19=await fetch(_0x4ec75f,{'headers':_0x138b70,'signal':this['sseAbort'][_0x1ab699(0xa3)]});if(!_0x108b19['ok']||!_0x108b19['body']){this[_0x1ab699(0xb8)](_0x1ab699(0xde)+_0x108b19[_0x1ab699(0x107)]),await this[_0x1ab699(0xf2)](_0x3c1a65),_0x3c1a65=Math[_0x1ab699(0xaf)](_0x3c1a65*1.5,0xea60);continue;}_0x3c1a65=this[_0x1ab699(0xed)];let _0x37497e=_0x108b19['body'][_0x1ab699(0x105)](),_0x2a6bb7=new TextDecoder(),_0x5205bd='';while(this['running']){let {done:_0x4dcfe3,value:_0x3b5063}=await _0x37497e['read']();if(_0x4dcfe3)break;_0x5205bd+=_0x2a6bb7[_0x1ab699(0xa2)](_0x3b5063,{'stream':!0x0});let _0x235706=_0x5205bd[_0x1ab699(0xe7)]('\x0a');_0x5205bd=_0x235706[_0x1ab699(0xb6)]()||'';for(let _0x5be6ed of _0x235706){if(!_0x5be6ed['startsWith']('data:\x20'))continue;try{let _0x370ea0=JSON['parse'](_0x5be6ed[_0x1ab699(0xab)](0x6));if(_0x370ea0['type']==='connected'){this[_0x1ab699(0xb8)](_0x1ab699(0x10e)),this[_0x1ab699(0xe0)]('connected');continue;}if(_0x370ea0[_0x1ab699(0xa1)]===_0x1ab699(0xd3)||_0x370ea0['type']===_0x1ab699(0x9a)||_0x370ea0[_0x1ab699(0xa1)]===_0x1ab699(0xd6))await this[_0x1ab699(0xec)]();}catch{}}}}catch(_0x4db3ea){if(_0x4db3ea[_0x1ab699(0xe9)]===_0x1ab699(0xac))break;this[_0x1ab699(0xe0)](_0x1ab699(0xb5),_0x4db3ea),this['log'](_0x1ab699(0x115)+_0x4db3ea[_0x1ab699(0x108)]);}if(this['running'])this[_0x1ab699(0xe0)]('disconnected'),this[_0x1ab699(0xb8)](_0x1ab699(0xfc)+_0x3c1a65/0x3e8+_0x1ab699(0xb3)),await this['sleep'](_0x3c1a65),_0x3c1a65=Math[_0x1ab699(0xaf)](_0x3c1a65*1.5,0xea60);}}async[a0_0x4a7953(0xec)](){const _0x2f0fd3=a0_0x4a7953;try{let _0x113c15=(await this[_0x2f0fd3(0x9e)]('get_inbox',{'alias':this['alias'],'limit':0xa}))?.[_0x2f0fd3(0xf7)]||[];for(let _0x11d72b of _0x113c15)await this[_0x2f0fd3(0x9e)](_0x2f0fd3(0x97),{'alias':this[_0x2f0fd3(0xc3)],'message_id':_0x11d72b['id']}),this[_0x2f0fd3(0xb8)]('←\x20'+_0x11d72b[_0x2f0fd3(0x9b)]+':\x20'+_0x11d72b['content']['slice'](0x0,0x3c)),this[_0x2f0fd3(0xe0)](_0x2f0fd3(0xfa),_0x11d72b),this[_0x2f0fd3(0xe0)]('message',_0x11d72b);}catch(_0x11dad2){this[_0x2f0fd3(0xb8)]('inbox\x20error:\x20'+_0x11dad2[_0x2f0fd3(0x108)]);}}['sleep'](_0x3f5400){return new Promise(_0x363f6a=>setTimeout(_0x363f6a,_0x3f5400));}}var F=$;export{F as default,$ as CommHub};
1
+ const a0_0x1d2064=a0_0x1266;(function(_0x180b91,_0x148ca8){const _0x150974=a0_0x1266,_0x233117=_0x180b91();while(!![]){try{const _0x1c70c2=-parseInt(_0x150974(0x183))/0x1*(parseInt(_0x150974(0x154))/0x2)+parseInt(_0x150974(0x10b))/0x3+-parseInt(_0x150974(0x177))/0x4*(-parseInt(_0x150974(0x173))/0x5)+-parseInt(_0x150974(0x180))/0x6+parseInt(_0x150974(0x12c))/0x7*(-parseInt(_0x150974(0x185))/0x8)+parseInt(_0x150974(0x132))/0x9*(parseInt(_0x150974(0x15a))/0xa)+-parseInt(_0x150974(0x144))/0xb;if(_0x1c70c2===_0x148ca8)break;else _0x233117['push'](_0x233117['shift']());}catch(_0x3c2564){_0x233117['push'](_0x233117['shift']());}}}(a0_0x646a,0x52e5a));import{EventEmitter as a0_0xba609b}from'events';import{hostname as a0_0x39f3af}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x176564,_0x230396)=>(_0x176564??_0x230396)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x1d2064(0x15e)](0x0,0xf0);function N(_0xdcc1a6){const _0x29906a=a0_0x1d2064;return(_0xdcc1a6 instanceof Error?_0xdcc1a6[_0x29906a(0x12f)]:String(_0xdcc1a6??_0x29906a(0x178)))[_0x29906a(0x169)](K,_0x29906a(0x112))[_0x29906a(0x169)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x29906a(0x15e)](0x0,0xf0);}function O(_0x2841e2,_0x19f5a7=process.env.ANET_TASK_TRACE_FORMAT===a0_0x1d2064(0x12e)){const _0x3c368c=a0_0x1d2064;if(_0x19f5a7)return JSON[_0x3c368c(0x12b)](_0x2841e2);let _0xef2512=L(_0x2841e2[_0x3c368c(0x17e)],_0x3c368c(0x12a)),_0x27927d=L(_0x2841e2[_0x3c368c(0x15b)],_0x3c368c(0x17f)),_0x391ba7=_0x2841e2[_0x3c368c(0x125)]?_0x3c368c(0x118)+_0x2841e2[_0x3c368c(0x125)]+':'+(_0x2841e2['error_message']??''):'';return _0x3c368c(0x124)+_0x2841e2['status']+_0x3c368c(0x158)+L(_0x2841e2[_0x3c368c(0x162)],_0x3c368c(0x152))+_0x3c368c(0x14a)+L(_0x2841e2[_0x3c368c(0x13b)],'<unknown>')+_0x3c368c(0x13f)+_0x27927d+_0x3c368c(0x114)+_0xef2512+_0x3c368c(0x145)+L(_0x2841e2[_0x3c368c(0x150)],'<unknown>')+_0x3c368c(0x142)+_0x2841e2[_0x3c368c(0x168)]+_0x3c368c(0x16b)+_0x2841e2[_0x3c368c(0x11a)]+_0x3c368c(0x138)+_0x2841e2[_0x3c368c(0x113)]+_0x391ba7;}function U(_0x43e9dc){const _0x466699=a0_0x1d2064;return{'event':{'sending':'task.send.start','delivered':'task.send.delivered','failed':'task.send.failed','acked':_0x466699(0x136),'started':_0x466699(0x115),'replied':_0x466699(0x13d),'expired':'task.expired'}[_0x43e9dc['status']],..._0x43e9dc};}function a0_0x646a(){const _0x2859e0=['emit','[REDACTED]','lifecycle_tracking','\x20parent_task_id=','task.started','offline','running','\x20error=','send_rejected','duration_ms','send_failed','SSE\x20error:\x20','new_task','tools/call','min','processInbox','application/json','data:\x20','string','[commhub:task]\x20','error_code','s...','url','connectSSE','heartbeatInterval','<missing>','stringify','21ryKVsT','toString','json','message','/mcp','/events/','45RklLOC','send_task','decode','send_reply','task.ack','disconnect','\x20lifecycle=','text/event-stream','missing_task_id','to_alias','call','task.replied','networkId','\x20task_id=','delivered','registered','\x20transport=','sleep','1535644WxYkdZ','\x20network_id=','body','reconnectDelay','get_all_status','not_tracked','\x20to=','cwd','token','error','broadcast','getReader','network_id','connect','<unknown>','sdk','14JEtBep','autoConnect','signal','CommHub\x20response\x20omitted\x20task_id','\x20from=','type','1151180gmTGNX','task_id','SSE\x20connected','agent','slice','split','resumeId','result','from_alias','get_inbox','log','sdk-','failed','now','transport','replace','heartbeatTimer','\x20duration_ms=','parentTaskId','send','new_message','fromAlias','sending','text','POST','557365PTwSXB','content','abort','SSE\x20reconnecting\x20in\x20','4Qpowix','unknown\x20error','report_status','Authorization','status','getAllStatus','application/json,\x20text/event-stream','parent_task_id','<pending>','2686524OyplFV','parse','2.0','2258fDxLGW','sseAbort','697832gYgJUm','ack_inbox','idle','lifecycleTracking','match','read','toAlias','Bearer\x20','messages','completed','1552002NIDIIr','connected','send_message','alias','task','disconnected'];a0_0x646a=function(){return _0x2859e0;};return a0_0x646a();}function j(_0x5c2381){const _0x1f6646=a0_0x1d2064;let _0x4e1dbe=_0x5c2381?.['task_id']||_0x5c2381?.['message_id']||_0x5c2381?.['id'];if(_0x4e1dbe)return String(_0x4e1dbe);let _0x1a6e88=_0x5c2381?.[_0x1f6646(0x174)]?.[0x0]?.['text'];if(typeof _0x1a6e88!==_0x1f6646(0x123))return null;try{let _0x282af6=JSON[_0x1f6646(0x181)](_0x1a6e88);return _0x282af6?.[_0x1f6646(0x15b)]||_0x282af6?.['message_id']||_0x282af6?.['id']||null;}catch{return null;}}function a0_0x1266(_0x39a0c9,_0x5949ba){_0x39a0c9=_0x39a0c9-0x103;const _0x646acf=a0_0x646a();let _0x1266e4=_0x646acf[_0x39a0c9];return _0x1266e4;}async function X(_0x4b2073,_0x436f21){const _0x1dd640=a0_0x1d2064;let _0x32b876=_0x436f21[_0x1dd640(0x167)]??Date[_0x1dd640(0x167)],_0x26d543=_0x32b876(),_0x88c677=(_0x4afcd9,_0x3d7cf7,_0x8f99ac,_0x163e39)=>{const _0xd19f4c=_0x1dd640;_0x436f21['log'](O(U({'from_alias':_0x4b2073[_0xd19f4c(0x16f)],'to_alias':_0x4b2073[_0xd19f4c(0x107)],'task_id':_0x3d7cf7,'parent_task_id':_0x4b2073[_0xd19f4c(0x16c)],'network_id':_0x4b2073['networkId'],'transport':_0x4b2073[_0xd19f4c(0x168)],'status':_0x4afcd9,'duration_ms':_0x32b876()-_0x26d543,'lifecycle_tracking':_0x4b2073[_0xd19f4c(0x104)],..._0x8f99ac!==void 0x0?{'error_code':_0x163e39||'send_failed','error_message':N(_0x8f99ac)}:{}})));};_0x88c677(_0x1dd640(0x170),null);try{let _0x40745f=await _0x436f21[_0x1dd640(0x16d)](),_0x43d890=j(_0x40745f);if(_0x43d890)_0x88c677(_0x1dd640(0x140),_0x43d890);else{if(_0x40745f?.['ok']===!0x1||_0x40745f?.[_0x1dd640(0x14d)])_0x88c677(_0x1dd640(0x166),_0x43d890,_0x40745f?.[_0x1dd640(0x14d)]||'CommHub\x20rejected\x20task',_0x1dd640(0x119));else _0x88c677('failed',null,_0x1dd640(0x157),_0x1dd640(0x13a));}return _0x40745f;}catch(_0x45245a){throw _0x88c677(_0x1dd640(0x166),null,_0x45245a,_0x1dd640(0x11b)),_0x45245a;}}async function Y(_0x87284f,_0x427af5){const _0x345106=a0_0x1d2064;return X({'fromAlias':_0x87284f['fromAlias'],'toAlias':_0x87284f[_0x345106(0x10e)],'parentTaskId':_0x87284f[_0x345106(0x16c)]||null,'networkId':_0x87284f[_0x345106(0x13e)]||null,'transport':'mcp_http','lifecycleTracking':_0x345106(0x149)},_0x427af5);}class $ extends a0_0xba609b{['url'];[a0_0x1d2064(0x10e)];['token'];['agent'];[a0_0x1d2064(0x160)];[a0_0x1d2064(0x129)];[a0_0x1d2064(0x147)];[a0_0x1d2064(0x16a)];[a0_0x1d2064(0x184)];[a0_0x1d2064(0x117)]=!0x1;constructor(_0x3cbf34){const _0x4f27ac=a0_0x1d2064;super();if(this[_0x4f27ac(0x127)]=_0x3cbf34[_0x4f27ac(0x127)][_0x4f27ac(0x169)](/\/$/,''),this[_0x4f27ac(0x10e)]=_0x3cbf34[_0x4f27ac(0x10e)],this[_0x4f27ac(0x14c)]=_0x3cbf34[_0x4f27ac(0x14c)],this[_0x4f27ac(0x15d)]=_0x3cbf34[_0x4f27ac(0x15d)]||_0x4f27ac(0x153),this[_0x4f27ac(0x160)]=_0x4f27ac(0x165)+_0x3cbf34[_0x4f27ac(0x10e)]+'-'+Date[_0x4f27ac(0x167)]()[_0x4f27ac(0x12d)](0x24),this[_0x4f27ac(0x129)]=_0x3cbf34[_0x4f27ac(0x129)]??0x2bf20,this[_0x4f27ac(0x147)]=_0x3cbf34[_0x4f27ac(0x147)]??0xbb8,_0x3cbf34[_0x4f27ac(0x155)]!==!0x1)this[_0x4f27ac(0x151)]();}['log'](_0x4fd95b){const _0x1ccd77=a0_0x1d2064;console['log']('['+new Date()['toTimeString']()[_0x1ccd77(0x15e)](0x0,0x8)+']\x20[commhub:'+this['alias']+']\x20'+_0x4fd95b);}async['call'](_0x31d49a,_0x52b12a){const _0x42945e=a0_0x1d2064;let _0x5af303={'Content-Type':_0x42945e(0x121),'Accept':_0x42945e(0x17d)};if(this[_0x42945e(0x14c)])_0x5af303[_0x42945e(0x17a)]=_0x42945e(0x108)+this[_0x42945e(0x14c)];let _0x4c8213=await(await fetch(this[_0x42945e(0x127)]+_0x42945e(0x130),{'method':_0x42945e(0x172),'headers':_0x5af303,'body':JSON[_0x42945e(0x12b)]({'jsonrpc':_0x42945e(0x182),'id':Date[_0x42945e(0x167)](),'method':_0x42945e(0x11e),'params':{'name':_0x31d49a,'arguments':_0x52b12a}})}))[_0x42945e(0x171)](),_0x4a552d=_0x4c8213[_0x42945e(0x105)](/data: (.+)/),_0x19a50b=_0x4a552d?JSON[_0x42945e(0x181)](_0x4a552d[0x1]):JSON[_0x42945e(0x181)](_0x4c8213),_0xc06a07=_0x19a50b?.[_0x42945e(0x161)]?.[_0x42945e(0x174)]?.[0x0]?.[_0x42945e(0x171)];return _0xc06a07?JSON['parse'](_0xc06a07):_0x19a50b;}async['connect'](){const _0x12c255=a0_0x1d2064;if(this[_0x12c255(0x117)])return;this[_0x12c255(0x117)]=!0x0,await this[_0x12c255(0x17b)]('idle'),this[_0x12c255(0x164)](_0x12c255(0x141)),this[_0x12c255(0x16a)]=setInterval(()=>{const _0xdcd6a0=_0x12c255;this[_0xdcd6a0(0x17b)](_0xdcd6a0(0x103))['catch'](_0x1d1eab=>this['log']('heartbeat\x20failed:\x20'+_0x1d1eab['message']));},this[_0x12c255(0x129)]),this[_0x12c255(0x128)]();}async[a0_0x1d2064(0x137)](){const _0x49efa6=a0_0x1d2064;if(this[_0x49efa6(0x117)]=!0x1,this['sseAbort']?.[_0x49efa6(0x175)](),this[_0x49efa6(0x16a)])clearInterval(this['heartbeatTimer']);await this['status'](_0x49efa6(0x116))['catch'](()=>{}),this[_0x49efa6(0x164)](_0x49efa6(0x110));}async[a0_0x1d2064(0x16d)](_0x1539ac,_0x3f8c99,_0x161c2f='normal'){const _0x29883a=a0_0x1d2064;return Y({'alias':_0x1539ac,'fromAlias':this[_0x29883a(0x10e)]},{'log':_0x21a8e3=>console[_0x29883a(0x164)](_0x21a8e3),'send':()=>this[_0x29883a(0x13c)](_0x29883a(0x133),{'alias':_0x1539ac,'task':_0x3f8c99,'priority':_0x161c2f,'from_session':this['alias']})});}async[a0_0x1d2064(0x12f)](_0x55cf87,_0x51e982){const _0x59f179=a0_0x1d2064;return this[_0x59f179(0x13c)](_0x59f179(0x10d),{'alias':_0x55cf87,'message':_0x51e982,'from_session':this[_0x59f179(0x10e)]});}async['reply'](_0x3ce911,_0x537bf5,_0x2e802f=a0_0x1d2064(0x10a)){const _0x534ab8=a0_0x1d2064;return this[_0x534ab8(0x13c)](_0x534ab8(0x135),{'in_reply_to':_0x3ce911,'text':_0x537bf5,'status':_0x2e802f});}async['status'](_0x1abab2,_0x2ffc54){const _0x46f760=a0_0x1d2064;return this['call'](_0x46f760(0x179),{'resume_id':this['resumeId'],'alias':this[_0x46f760(0x10e)],'status':_0x1abab2,'server':a0_0x39f3af(),'hostname':a0_0x39f3af(),'agent':this['agent'],'project_dir':process[_0x46f760(0x14b)](),..._0x2ffc54});}async[a0_0x1d2064(0x17c)](){const _0x29922f=a0_0x1d2064;return this[_0x29922f(0x13c)](_0x29922f(0x148),{});}async[a0_0x1d2064(0x14e)](_0x2b8f6f,_0x151049){const _0x47f4d0=a0_0x1d2064;return this[_0x47f4d0(0x13c)](_0x47f4d0(0x14e),{'message':_0x2b8f6f,'filter_server':_0x151049?.['server'],'filter_status':_0x151049?.['status']});}async[a0_0x1d2064(0x128)](){const _0x538b00=a0_0x1d2064;let _0x1c2e2e=encodeURIComponent(this['alias']),_0x11dc47=this[_0x538b00(0x127)]+_0x538b00(0x131)+_0x1c2e2e,_0x526054=this['reconnectDelay'];while(this[_0x538b00(0x117)]){try{this['sseAbort']=new AbortController();let _0x2af4d4={'Accept':_0x538b00(0x139)};if(this[_0x538b00(0x14c)])_0x2af4d4[_0x538b00(0x17a)]=_0x538b00(0x108)+this[_0x538b00(0x14c)];let _0x3f987a=await fetch(_0x11dc47,{'headers':_0x2af4d4,'signal':this[_0x538b00(0x184)][_0x538b00(0x156)]});if(!_0x3f987a['ok']||!_0x3f987a['body']){this[_0x538b00(0x164)]('SSE\x20failed:\x20'+_0x3f987a[_0x538b00(0x17b)]),await this[_0x538b00(0x143)](_0x526054),_0x526054=Math[_0x538b00(0x11f)](_0x526054*1.5,0xea60);continue;}_0x526054=this[_0x538b00(0x147)];let _0x241b24=_0x3f987a[_0x538b00(0x146)][_0x538b00(0x14f)](),_0x4f3eff=new TextDecoder(),_0x3cea8e='';while(this['running']){let {done:_0x34fb27,value:_0x7d2147}=await _0x241b24[_0x538b00(0x106)]();if(_0x34fb27)break;_0x3cea8e+=_0x4f3eff[_0x538b00(0x134)](_0x7d2147,{'stream':!0x0});let _0x16ab31=_0x3cea8e[_0x538b00(0x15f)]('\x0a');_0x3cea8e=_0x16ab31['pop']()||'';for(let _0x4d5a85 of _0x16ab31){if(!_0x4d5a85['startsWith'](_0x538b00(0x122)))continue;try{let _0x22cd71=JSON[_0x538b00(0x181)](_0x4d5a85[_0x538b00(0x15e)](0x6));if(_0x22cd71[_0x538b00(0x159)]===_0x538b00(0x10c)){this[_0x538b00(0x164)](_0x538b00(0x15c)),this[_0x538b00(0x111)](_0x538b00(0x10c));continue;}if(_0x22cd71[_0x538b00(0x159)]===_0x538b00(0x11d)||_0x22cd71[_0x538b00(0x159)]===_0x538b00(0x16e)||_0x22cd71[_0x538b00(0x159)]===_0x538b00(0x14e))await this[_0x538b00(0x120)]();}catch{}}}}catch(_0xaab24b){if(_0xaab24b['name']==='AbortError')break;this['emit']('error',_0xaab24b),this[_0x538b00(0x164)](_0x538b00(0x11c)+_0xaab24b['message']);}if(this[_0x538b00(0x117)])this[_0x538b00(0x111)](_0x538b00(0x110)),this[_0x538b00(0x164)](_0x538b00(0x176)+_0x526054/0x3e8+_0x538b00(0x126)),await this[_0x538b00(0x143)](_0x526054),_0x526054=Math[_0x538b00(0x11f)](_0x526054*1.5,0xea60);}}async[a0_0x1d2064(0x120)](){const _0x24b28e=a0_0x1d2064;try{let _0x493349=(await this[_0x24b28e(0x13c)](_0x24b28e(0x163),{'alias':this[_0x24b28e(0x10e)],'limit':0xa}))?.[_0x24b28e(0x109)]||[];for(let _0xce7b95 of _0x493349)await this[_0x24b28e(0x13c)](_0x24b28e(0x186),{'alias':this[_0x24b28e(0x10e)],'message_id':_0xce7b95['id']}),this[_0x24b28e(0x164)]('←\x20'+_0xce7b95['from_session']+':\x20'+_0xce7b95[_0x24b28e(0x174)][_0x24b28e(0x15e)](0x0,0x3c)),this[_0x24b28e(0x111)](_0x24b28e(0x10f),_0xce7b95),this[_0x24b28e(0x111)]('message',_0xce7b95);}catch(_0x57c5aa){this[_0x24b28e(0x164)]('inbox\x20error:\x20'+_0x57c5aa[_0x24b28e(0x12f)]);}}['sleep'](_0xf639b4){return new Promise(_0x2c98a7=>setTimeout(_0x2c98a7,_0xf639b4));}}var F=$;export{F as default,$ as CommHub};
@@ -0,0 +1,75 @@
1
+ /** Per-node record, written into the node dir next to the other state files. */
2
+ export declare const CODEX_AUTH_FINGERPRINT_FILE = ".codex-auth-fingerprint.json";
3
+ /** Length of the stored fingerprint. Collisions at 8 hex are ~1 in 4 billion;
4
+ * a false "these two share a login" warning costs a second look, while the
5
+ * value staying short keeps it obviously non-reversible in logs. */
6
+ export declare const FINGERPRINT_LENGTH = 8;
7
+ export interface CodexAuthFingerprintRecord {
8
+ readonly schema_version: 1;
9
+ readonly alias: string;
10
+ /** sha256(refresh_token) truncated — never the token. */
11
+ readonly fingerprint: string;
12
+ readonly written_at: string;
13
+ }
14
+ /**
15
+ * Hash the refresh token out of an auth.json body.
16
+ *
17
+ * Accepts both shapes seen in the wild: the current codex layout nests it
18
+ * under `tokens` (`{auth_mode, tokens:{id_token, access_token, refresh_token,
19
+ * account_id}, last_refresh}`), and older/plain bodies put `refresh_token` at
20
+ * the top level. Anything else — unparsable, absent, empty, non-string —
21
+ * returns null, because "we cannot tell" must not be reported as "no
22
+ * collision".
23
+ */
24
+ export declare function fingerprintRefreshToken(authJsonText: string): string | null;
25
+ export interface NodeFingerprint {
26
+ readonly alias: string;
27
+ /** null when the node has no auth.json, or one we could not read. */
28
+ readonly fingerprint: string | null;
29
+ /** When the record was written; used to say how stale a claim is. */
30
+ readonly writtenAt?: string | null;
31
+ }
32
+ /**
33
+ * Other nodes holding the same credential chain as `self`.
34
+ *
35
+ * Records with no fingerprint are skipped rather than grouped: "unknown" is
36
+ * not a match. Self is excluded by alias, so re-reading one's own record is
37
+ * harmless.
38
+ */
39
+ export declare function collidingNodes(records: readonly NodeFingerprint[], self: NodeFingerprint): NodeFingerprint[];
40
+ /**
41
+ * The warning an operator sees at start. Returns [] when nothing collides —
42
+ * callers print exactly what they get, so silence is representable and the
43
+ * "no collision" path cannot accidentally print a scary empty banner.
44
+ *
45
+ * Deliberately a warning and never a refusal: every node on a host shares one
46
+ * login today, so refusing to start would take the whole box down at once
47
+ * over a condition that is survivable until the next refresh.
48
+ */
49
+ export declare function sharedCredentialWarningLines(self: NodeFingerprint, colliding: readonly NodeFingerprint[]): string[];
50
+ /**
51
+ * Two different things both read as "codex cannot refresh", and they need
52
+ * opposite remedies. Telling them apart is the whole value of this mapping:
53
+ * treating a transport failure as a rotation conflict sends an operator to
54
+ * copy someone else's auth.json, which is precisely how a shared-credential
55
+ * chain gets created.
56
+ */
57
+ export type CodexRefreshFailureKind =
58
+ /** Someone else spent this refresh token first. */
59
+ "rotation-conflict"
60
+ /** The token endpoint is unreachable — nobody's token is rotating. */
61
+ | "token-endpoint-unreachable";
62
+ export interface CodexRefreshFailure {
63
+ readonly kind: CodexRefreshFailureKind;
64
+ readonly lines: string[];
65
+ }
66
+ /**
67
+ * Name what actually went wrong with a codex refresh, and say what to do.
68
+ *
69
+ * Returns null for anything else, so callers fall through to whatever they
70
+ * printed before — an unrelated error must pass through unchanged.
71
+ *
72
+ * Order matters: a reuse rejection is a server answer and is checked first; a
73
+ * transport failure means no answer arrived at all.
74
+ */
75
+ export declare function describeCodexRefreshFailure(text: string, colliding?: readonly NodeFingerprint[]): CodexRefreshFailure | null;