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

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_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};
1
+ const a0_0x5ce150=a0_0x4c89;(function(_0x21ab87,_0x3d289f){const _0x4cf448=a0_0x4c89,_0x40eb47=_0x21ab87();while(!![]){try{const _0x1a7e71=-parseInt(_0x4cf448(0x18e))/0x1+parseInt(_0x4cf448(0x1cd))/0x2+parseInt(_0x4cf448(0x19e))/0x3+-parseInt(_0x4cf448(0x198))/0x4*(-parseInt(_0x4cf448(0x1b8))/0x5)+-parseInt(_0x4cf448(0x1a7))/0x6+parseInt(_0x4cf448(0x1e9))/0x7+-parseInt(_0x4cf448(0x1a1))/0x8*(parseInt(_0x4cf448(0x1c5))/0x9);if(_0x1a7e71===_0x3d289f)break;else _0x40eb47['push'](_0x40eb47['shift']());}catch(_0x5f445b){_0x40eb47['push'](_0x40eb47['shift']());}}}(a0_0x5349,0xa0ae0));import{EventEmitter as a0_0x4b6e45}from'events';import{hostname as a0_0xabc1ad}from'os';function a0_0x4c89(_0x28d206,_0x2bbda6){_0x28d206=_0x28d206-0x182;const _0x534949=a0_0x5349();let _0x4c8921=_0x534949[_0x28d206];return _0x4c8921;}var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x489f7a,_0x5b86d7)=>(_0x489f7a??_0x5b86d7)[a0_0x5ce150(0x1a3)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x5ce150(0x1ac)](0x0,0xf0);function N(_0x1eef63){const _0x1f84b1=a0_0x5ce150;return(_0x1eef63 instanceof Error?_0x1eef63[_0x1f84b1(0x1d5)]:String(_0x1eef63??_0x1f84b1(0x188)))[_0x1f84b1(0x1a3)](K,_0x1f84b1(0x1ae))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x21881f,_0xe95d2d=process.env.ANET_TASK_TRACE_FORMAT===a0_0x5ce150(0x1b1)){const _0x52c4eb=a0_0x5ce150;if(_0xe95d2d)return JSON[_0x52c4eb(0x1ef)](_0x21881f);let _0x375e24=L(_0x21881f['parent_task_id'],_0x52c4eb(0x1d1)),_0x1a9463=L(_0x21881f['task_id'],_0x52c4eb(0x1fa)),_0x39ec6e=_0x21881f[_0x52c4eb(0x192)]?'\x20error='+_0x21881f[_0x52c4eb(0x192)]+':'+(_0x21881f['error_message']??''):'';return _0x52c4eb(0x1b6)+_0x21881f[_0x52c4eb(0x1bf)]+'\x20from='+L(_0x21881f[_0x52c4eb(0x18b)],_0x52c4eb(0x182))+_0x52c4eb(0x1c6)+L(_0x21881f[_0x52c4eb(0x193)],_0x52c4eb(0x182))+_0x52c4eb(0x1dc)+_0x1a9463+'\x20parent_task_id='+_0x375e24+_0x52c4eb(0x1d0)+L(_0x21881f[_0x52c4eb(0x1c4)],_0x52c4eb(0x182))+'\x20transport='+_0x21881f[_0x52c4eb(0x1e3)]+_0x52c4eb(0x1d7)+_0x21881f[_0x52c4eb(0x1cf)]+_0x52c4eb(0x1f0)+_0x21881f[_0x52c4eb(0x1f9)]+_0x39ec6e;}function U(_0x10b219){const _0xf000ac=a0_0x5ce150;return{'event':{'sending':_0xf000ac(0x1a5),'delivered':_0xf000ac(0x18a),'failed':_0xf000ac(0x1dd),'acked':'task.ack','started':_0xf000ac(0x1ed),'replied':_0xf000ac(0x1ec),'expired':'task.expired'}[_0x10b219['status']],..._0x10b219};}function j(_0x27faf0){const _0x447825=a0_0x5ce150;let _0x563c9a=_0x27faf0?.[_0x447825(0x1f5)]||_0x27faf0?.[_0x447825(0x1ab)]||_0x27faf0?.['id'];if(_0x563c9a)return String(_0x563c9a);let _0x51829e=_0x27faf0?.['content']?.[0x0]?.['text'];if(typeof _0x51829e!=='string')return null;try{let _0x49f72b=JSON[_0x447825(0x191)](_0x51829e);return _0x49f72b?.[_0x447825(0x1f5)]||_0x49f72b?.['message_id']||_0x49f72b?.['id']||null;}catch{return null;}}async function X(_0x20f4a4,_0x59f919){const _0x1dc49e=a0_0x5ce150;let _0x1f88c2=_0x59f919[_0x1dc49e(0x1b0)]??Date['now'],_0x22c188=_0x1f88c2(),_0x33cc92=(_0x294cc3,_0x3668c9,_0x38f778,_0x329b6d)=>{const _0x86ed17=_0x1dc49e;_0x59f919['log'](O(U({'from_alias':_0x20f4a4['fromAlias'],'to_alias':_0x20f4a4[_0x86ed17(0x1b7)],'task_id':_0x3668c9,'parent_task_id':_0x20f4a4[_0x86ed17(0x1e8)],'network_id':_0x20f4a4[_0x86ed17(0x190)],'transport':_0x20f4a4[_0x86ed17(0x1e3)],'status':_0x294cc3,'duration_ms':_0x1f88c2()-_0x22c188,'lifecycle_tracking':_0x20f4a4[_0x86ed17(0x1c2)],..._0x38f778!==void 0x0?{'error_code':_0x329b6d||_0x86ed17(0x186),'error_message':N(_0x38f778)}:{}})));};_0x33cc92(_0x1dc49e(0x1d3),null);try{let _0x2e85a9=await _0x59f919[_0x1dc49e(0x1a0)](),_0xda4e78=j(_0x2e85a9);if(_0xda4e78)_0x33cc92(_0x1dc49e(0x1e4),_0xda4e78);else{if(_0x2e85a9?.['ok']===!0x1||_0x2e85a9?.['error'])_0x33cc92(_0x1dc49e(0x1a2),_0xda4e78,_0x2e85a9?.[_0x1dc49e(0x19c)]||_0x1dc49e(0x1e1),_0x1dc49e(0x1d8));else _0x33cc92(_0x1dc49e(0x1a2),null,'CommHub\x20response\x20omitted\x20task_id',_0x1dc49e(0x19a));}return _0x2e85a9;}catch(_0x4fb411){throw _0x33cc92(_0x1dc49e(0x1a2),null,_0x4fb411,_0x1dc49e(0x186)),_0x4fb411;}}async function Y(_0x5e2608,_0x54c36c){const _0xd304bc=a0_0x5ce150;return X({'fromAlias':_0x5e2608['fromAlias'],'toAlias':_0x5e2608[_0xd304bc(0x19b)],'parentTaskId':_0x5e2608[_0xd304bc(0x1e8)]||null,'networkId':_0x5e2608['networkId']||null,'transport':_0xd304bc(0x1e7),'lifecycleTracking':'not_tracked'},_0x54c36c);}class $ extends a0_0x4b6e45{[a0_0x5ce150(0x1d6)];[a0_0x5ce150(0x19b)];['token'];[a0_0x5ce150(0x1bd)];[a0_0x5ce150(0x1ba)];[a0_0x5ce150(0x195)];[a0_0x5ce150(0x1a4)];[a0_0x5ce150(0x1b5)];[a0_0x5ce150(0x1df)];[a0_0x5ce150(0x1c7)]=!0x1;constructor(_0x98701d){const _0x4d60f8=a0_0x5ce150;super();if(this['url']=_0x98701d[_0x4d60f8(0x1d6)][_0x4d60f8(0x1a3)](/\/$/,''),this[_0x4d60f8(0x19b)]=_0x98701d['alias'],this[_0x4d60f8(0x1cb)]=_0x98701d[_0x4d60f8(0x1cb)],this[_0x4d60f8(0x1bd)]=_0x98701d[_0x4d60f8(0x1bd)]||_0x4d60f8(0x1ea),this[_0x4d60f8(0x1ba)]='sdk-'+_0x98701d['alias']+'-'+Date[_0x4d60f8(0x1b0)]()[_0x4d60f8(0x187)](0x24),this[_0x4d60f8(0x195)]=_0x98701d['heartbeatInterval']??0x2bf20,this[_0x4d60f8(0x1a4)]=_0x98701d[_0x4d60f8(0x1a4)]??0xbb8,_0x98701d['autoConnect']!==!0x1)this[_0x4d60f8(0x1b3)]();}[a0_0x5ce150(0x1e2)](_0x5ed5ae){const _0x16b128=a0_0x5ce150;console[_0x16b128(0x1e2)]('['+new Date()['toTimeString']()['slice'](0x0,0x8)+_0x16b128(0x1de)+this[_0x16b128(0x19b)]+']\x20'+_0x5ed5ae);}async[a0_0x5ce150(0x184)](_0x22dcc3,_0x3c754c){const _0x5b9b03=a0_0x5ce150;let _0x1c81a4={'Content-Type':'application/json','Accept':_0x5b9b03(0x1c8)};if(this[_0x5b9b03(0x1cb)])_0x1c81a4[_0x5b9b03(0x18f)]=_0x5b9b03(0x19f)+this[_0x5b9b03(0x1cb)];let _0x1cf32a=await(await fetch(this['url']+'/mcp',{'method':'POST','headers':_0x1c81a4,'body':JSON[_0x5b9b03(0x1ef)]({'jsonrpc':_0x5b9b03(0x1c3),'id':Date[_0x5b9b03(0x1b0)](),'method':'tools/call','params':{'name':_0x22dcc3,'arguments':_0x3c754c}})}))[_0x5b9b03(0x1be)](),_0x59f5f3=_0x1cf32a[_0x5b9b03(0x1bb)](/data: (.+)/),_0xe22b83=_0x59f5f3?JSON['parse'](_0x59f5f3[0x1]):JSON[_0x5b9b03(0x191)](_0x1cf32a),_0x2aea2f=_0xe22b83?.[_0x5b9b03(0x1eb)]?.[_0x5b9b03(0x1ce)]?.[0x0]?.[_0x5b9b03(0x1be)];return _0x2aea2f?JSON[_0x5b9b03(0x191)](_0x2aea2f):_0xe22b83;}async['connect'](){const _0x1ab9ea=a0_0x5ce150;if(this[_0x1ab9ea(0x1c7)])return;this[_0x1ab9ea(0x1c7)]=!0x0,await this['status'](_0x1ab9ea(0x1a9)),this[_0x1ab9ea(0x1e2)](_0x1ab9ea(0x1d2)),this[_0x1ab9ea(0x1b5)]=setInterval(()=>{const _0x591a77=_0x1ab9ea;this['status'](_0x591a77(0x1a9))[_0x591a77(0x1f3)](_0x4dc4c8=>this[_0x591a77(0x1e2)]('heartbeat\x20failed:\x20'+_0x4dc4c8['message']));},this[_0x1ab9ea(0x195)]),this[_0x1ab9ea(0x1c0)]();}async['disconnect'](){const _0x1098f7=a0_0x5ce150;if(this[_0x1098f7(0x1c7)]=!0x1,this['sseAbort']?.['abort'](),this['heartbeatTimer'])clearInterval(this[_0x1098f7(0x1b5)]);await this[_0x1098f7(0x1bf)](_0x1098f7(0x1f6))[_0x1098f7(0x1f3)](()=>{}),this['log']('disconnected');}async[a0_0x5ce150(0x1a0)](_0x208463,_0x1823dc,_0x5c7760=a0_0x5ce150(0x197)){const _0x16c310=a0_0x5ce150;return Y({'alias':_0x208463,'fromAlias':this[_0x16c310(0x19b)]},{'log':_0x57e8e1=>console[_0x16c310(0x1e2)](_0x57e8e1),'send':()=>this[_0x16c310(0x184)](_0x16c310(0x194),{'alias':_0x208463,'task':_0x1823dc,'priority':_0x5c7760,'from_session':this[_0x16c310(0x19b)]})});}async[a0_0x5ce150(0x1d5)](_0x2bbb65,_0x5ca9e6){const _0x323824=a0_0x5ce150;return this[_0x323824(0x184)](_0x323824(0x1ad),{'alias':_0x2bbb65,'message':_0x5ca9e6,'from_session':this[_0x323824(0x19b)]});}async[a0_0x5ce150(0x1db)](_0x44823c,_0x576077,_0x1f4ea9='completed'){const _0x5a5aaf=a0_0x5ce150;return this[_0x5a5aaf(0x184)](_0x5a5aaf(0x189),{'in_reply_to':_0x44823c,'text':_0x576077,'status':_0x1f4ea9});}async[a0_0x5ce150(0x1bf)](_0x2897a4,_0x8ce420){const _0xd78f81=a0_0x5ce150;return this['call'](_0xd78f81(0x1af),{'resume_id':this[_0xd78f81(0x1ba)],'alias':this[_0xd78f81(0x19b)],'status':_0x2897a4,'server':a0_0xabc1ad(),'hostname':a0_0xabc1ad(),'agent':this[_0xd78f81(0x1bd)],'project_dir':process['cwd'](),..._0x8ce420});}async[a0_0x5ce150(0x1b9)](){const _0x21a073=a0_0x5ce150;return this[_0x21a073(0x184)](_0x21a073(0x19d),{});}async[a0_0x5ce150(0x18c)](_0x5b2b3d,_0x5358bc){const _0x1aa2c9=a0_0x5ce150;return this[_0x1aa2c9(0x184)](_0x1aa2c9(0x18c),{'message':_0x5b2b3d,'filter_server':_0x5358bc?.[_0x1aa2c9(0x1bc)],'filter_status':_0x5358bc?.[_0x1aa2c9(0x1bf)]});}async[a0_0x5ce150(0x1c0)](){const _0x16ed68=a0_0x5ce150;let _0x47eaf6=encodeURIComponent(this[_0x16ed68(0x19b)]),_0x29b45b=this[_0x16ed68(0x1d6)]+_0x16ed68(0x1da)+_0x47eaf6,_0x343516=this[_0x16ed68(0x1a4)];while(this[_0x16ed68(0x1c7)]){try{this[_0x16ed68(0x1df)]=new AbortController();let _0x5c093f={'Accept':_0x16ed68(0x1ca)};if(this[_0x16ed68(0x1cb)])_0x5c093f[_0x16ed68(0x18f)]=_0x16ed68(0x19f)+this[_0x16ed68(0x1cb)];let _0x3a7b3e=await fetch(_0x29b45b,{'headers':_0x5c093f,'signal':this[_0x16ed68(0x1df)][_0x16ed68(0x185)]});if(!_0x3a7b3e['ok']||!_0x3a7b3e[_0x16ed68(0x1f8)]){this['log'](_0x16ed68(0x1d4)+_0x3a7b3e[_0x16ed68(0x1bf)]),await this['sleep'](_0x343516),_0x343516=Math['min'](_0x343516*1.5,0xea60);continue;}_0x343516=this[_0x16ed68(0x1a4)];let _0x27e596=_0x3a7b3e['body'][_0x16ed68(0x1d9)](),_0x2f35cf=new TextDecoder(),_0x28d283='';while(this[_0x16ed68(0x1c7)]){let {done:_0x42605b,value:_0x2b1afb}=await _0x27e596[_0x16ed68(0x1a6)]();if(_0x42605b)break;_0x28d283+=_0x2f35cf[_0x16ed68(0x1b4)](_0x2b1afb,{'stream':!0x0});let _0x39d8ac=_0x28d283[_0x16ed68(0x1f7)]('\x0a');_0x28d283=_0x39d8ac[_0x16ed68(0x1f2)]()||'';for(let _0xbf586 of _0x39d8ac){if(!_0xbf586[_0x16ed68(0x1e0)]('data:\x20'))continue;try{let _0x49ea99=JSON['parse'](_0xbf586[_0x16ed68(0x1ac)](0x6));if(_0x49ea99[_0x16ed68(0x1a8)]===_0x16ed68(0x183)){this[_0x16ed68(0x1e2)](_0x16ed68(0x1f4)),this[_0x16ed68(0x18d)](_0x16ed68(0x183));continue;}if(_0x49ea99['type']==='new_task'||_0x49ea99[_0x16ed68(0x1a8)]===_0x16ed68(0x196)||_0x49ea99[_0x16ed68(0x1a8)]===_0x16ed68(0x18c))await this[_0x16ed68(0x1e6)]();}catch{}}}}catch(_0x92c90c){if(_0x92c90c[_0x16ed68(0x1c1)]==='AbortError')break;this[_0x16ed68(0x18d)](_0x16ed68(0x19c),_0x92c90c),this[_0x16ed68(0x1e2)](_0x16ed68(0x1c9)+_0x92c90c[_0x16ed68(0x1d5)]);}if(this[_0x16ed68(0x1c7)])this[_0x16ed68(0x18d)](_0x16ed68(0x1b2)),this[_0x16ed68(0x1e2)]('SSE\x20reconnecting\x20in\x20'+_0x343516/0x3e8+_0x16ed68(0x1e5)),await this[_0x16ed68(0x1ee)](_0x343516),_0x343516=Math['min'](_0x343516*1.5,0xea60);}}async[a0_0x5ce150(0x1e6)](){const _0x30e77b=a0_0x5ce150;try{let _0x1331a5=(await this[_0x30e77b(0x184)](_0x30e77b(0x1aa),{'alias':this[_0x30e77b(0x19b)],'limit':0xa}))?.['messages']||[];for(let _0x305ef3 of _0x1331a5)await this['call'](_0x30e77b(0x199),{'alias':this[_0x30e77b(0x19b)],'message_id':_0x305ef3['id']}),this['log']('←\x20'+_0x305ef3['from_session']+':\x20'+_0x305ef3['content'][_0x30e77b(0x1ac)](0x0,0x3c)),this[_0x30e77b(0x18d)](_0x30e77b(0x1cc),_0x305ef3),this['emit'](_0x30e77b(0x1d5),_0x305ef3);}catch(_0x285fad){this[_0x30e77b(0x1e2)](_0x30e77b(0x1f1)+_0x285fad[_0x30e77b(0x1d5)]);}}[a0_0x5ce150(0x1ee)](_0x3e0384){return new Promise(_0x29db68=>setTimeout(_0x29db68,_0x3e0384));}}var F=$;function a0_0x5349(){const _0x4d5e64=['5359314fFYdtX','type','idle','get_inbox','message_id','slice','send_message','[REDACTED]','report_status','now','json','disconnected','connect','decode','heartbeatTimer','[commhub:task]\x20','toAlias','25LEzsGg','getAllStatus','resumeId','match','server','agent','text','status','connectSSE','name','lifecycleTracking','2.0','network_id','9NwxMPN','\x20to=','running','application/json,\x20text/event-stream','SSE\x20error:\x20','text/event-stream','token','task','1740606SfTJmU','content','duration_ms','\x20network_id=','<missing>','registered','sending','SSE\x20failed:\x20','message','url','\x20duration_ms=','send_rejected','getReader','/events/','reply','\x20task_id=','task.send.failed',']\x20[commhub:','sseAbort','startsWith','CommHub\x20rejected\x20task','log','transport','delivered','s...','processInbox','mcp_http','parentTaskId','6356805OiSPtK','sdk','result','task.replied','task.started','sleep','stringify','\x20lifecycle=','inbox\x20error:\x20','pop','catch','SSE\x20connected','task_id','offline','split','body','lifecycle_tracking','<pending>','<unknown>','connected','call','signal','send_failed','toString','unknown\x20error','send_reply','task.send.delivered','from_alias','broadcast','emit','205650YRNAwj','Authorization','networkId','parse','error_code','to_alias','send_task','heartbeatInterval','new_message','normal','120568pncWDT','ack_inbox','missing_task_id','alias','error','get_all_status','2406156xehTnD','Bearer\x20','send','7793336VsdzVq','failed','replace','reconnectDelay','task.send.start','read'];a0_0x5349=function(){return _0x4d5e64;};return a0_0x5349();}export{F as default,$ as CommHub};
@@ -4,12 +4,24 @@ export declare const CODEX_AUTH_FINGERPRINT_FILE = ".codex-auth-fingerprint.json
4
4
  * a false "these two share a login" warning costs a second look, while the
5
5
  * value staying short keeps it obviously non-reversible in logs. */
6
6
  export declare const FINGERPRINT_LENGTH = 8;
7
+ /** Access tokens measured on the reference fleet: `exp - iat` was exactly this,
8
+ * on 29 of 29 samples, with no jitter. Used only to phrase "how long until the
9
+ * shared copy dies" when we have an `exp` but no `iat`. */
10
+ export declare const ACCESS_TOKEN_LIFETIME_SECONDS = 864000;
7
11
  export interface CodexAuthFingerprintRecord {
8
- readonly schema_version: 1;
12
+ readonly schema_version: 1 | 2;
9
13
  readonly alias: string;
10
14
  /** sha256(refresh_token) truncated — never the token. */
11
15
  readonly fingerprint: string;
12
16
  readonly written_at: string;
17
+ /** v2: when this copy's ACCESS token expires, ISO-8601, or null if unreadable.
18
+ * A timestamp, not a credential. Two nodes holding one copied file share this
19
+ * instant exactly — which is how "they stop together" becomes observable. */
20
+ readonly access_expires_at?: string | null;
21
+ /** v2: the CODEX_HOME this record was read from. Distinguishes "two copies of
22
+ * one credential" from "two nodes pointed at one directory", which need
23
+ * different fixes. */
24
+ readonly codex_home?: string | null;
13
25
  }
14
26
  /**
15
27
  * Hash the refresh token out of an auth.json body.
@@ -22,12 +34,25 @@ export interface CodexAuthFingerprintRecord {
22
34
  * collision".
23
35
  */
24
36
  export declare function fingerprintRefreshToken(authJsonText: string): string | null;
37
+ /**
38
+ * When this copy's access token expires, read out of the JWT's own payload.
39
+ *
40
+ * The signature is NOT verified and nothing here authenticates: we are reading
41
+ * a timestamp the token states about itself, the same way `jwt.io` would. A
42
+ * token that is not a JWT, or carries no numeric `exp`, yields null — unknown
43
+ * stays unknown.
44
+ */
45
+ export declare function accessTokenExpiry(authJsonText: string): Date | null;
25
46
  export interface NodeFingerprint {
26
47
  readonly alias: string;
27
48
  /** null when the node has no auth.json, or one we could not read. */
28
49
  readonly fingerprint: string | null;
29
50
  /** When the record was written; used to say how stale a claim is. */
30
51
  readonly writtenAt?: string | null;
52
+ /** When this copy's access token expires, if we could read it. */
53
+ readonly accessExpiresAt?: Date | null;
54
+ /** The CODEX_HOME this fingerprint came from, if known. */
55
+ readonly codexHome?: string | null;
31
56
  }
32
57
  /**
33
58
  * Other nodes holding the same credential chain as `self`.
@@ -45,8 +70,25 @@ export declare function collidingNodes(records: readonly NodeFingerprint[], self
45
70
  * Deliberately a warning and never a refusal: every node on a host shares one
46
71
  * login today, so refusing to start would take the whole box down at once
47
72
  * over a condition that is survivable until the next refresh.
73
+ *
74
+ * 🔴 Two outcomes, and the wrong one is actively misleading. The default text
75
+ * ("whichever node refreshes first keeps working") assumes refresh WORKS.
76
+ * On a host that cannot reach the OAuth token endpoint — egress blocked, or
77
+ * a proxy that allowlists the model API and 403s everything else — nobody
78
+ * refreshes, and the nodes holding one copy do not degrade one at a time:
79
+ * they stop together the moment the shared access token expires. Field case:
80
+ * three nodes whose auth.json files were byte-identical, carrying one access
81
+ * token, all expired at the same instant.
82
+ *
83
+ * We do NOT probe the network to tell these apart — a start path is the wrong
84
+ * place to open a socket, and a probe would answer for this moment rather
85
+ * than for the window that matters. We branch on evidence already in the
86
+ * file: an access token whose `exp` has passed is a copy that demonstrably
87
+ * stopped being refreshed, which is the observable the field case exhibits.
88
+ * When `exp` is still in the future we cannot prove reachability either way,
89
+ * and the default wording is the right one to print.
48
90
  */
49
- export declare function sharedCredentialWarningLines(self: NodeFingerprint, colliding: readonly NodeFingerprint[]): string[];
91
+ export declare function sharedCredentialWarningLines(self: NodeFingerprint, colliding: readonly NodeFingerprint[], now?: Date): string[];
50
92
  /**
51
93
  * Two different things both read as "codex cannot refresh", and they need
52
94
  * opposite remedies. Telling them apart is the whole value of this mapping:
@@ -73,3 +115,34 @@ export interface CodexRefreshFailure {
73
115
  * transport failure means no answer arrived at all.
74
116
  */
75
117
  export declare function describeCodexRefreshFailure(text: string, colliding?: readonly NodeFingerprint[]): CodexRefreshFailure | null;
118
+ export interface CodexCredentialSharingCheck {
119
+ /** This node's own directory — where its record is written. */
120
+ readonly nodeDir: string;
121
+ /** Shown to the operator; also how a node recognises its own record. */
122
+ readonly alias: string;
123
+ /** The CODEX_HOME whose auth.json this node will actually use. */
124
+ readonly codexHome: string;
125
+ /** Where the warning goes. Defaults to stderr. */
126
+ readonly say?: (message: string) => void;
127
+ /** Injected for tests; production passes nothing. */
128
+ readonly now?: Date;
129
+ }
130
+ /**
131
+ * The whole operation: read this node's credential, publish an 8-hex record,
132
+ * read what the *other* nodes published, and warn if any of them is on the
133
+ * same chain. Returns the colliding nodes so a caller can name them again if
134
+ * codex later fails to refresh.
135
+ *
136
+ * 🔴 Reads the neighbours' published fingerprint files, never their
137
+ * credentials. A guard against credential sharing must not itself become a
138
+ * reason to open every node's auth.json.
139
+ *
140
+ * 🔴 Always recomputes. The fingerprint changes every time codex refreshes in
141
+ * place, so a stale record is a wrong answer; both call paths may run for
142
+ * one node in sequence, and whichever runs last must leave the current
143
+ * value, never an older one.
144
+ *
145
+ * Never throws and never refuses: observability must not be the reason a node
146
+ * will not start.
147
+ */
148
+ export declare function checkCodexCredentialSharing(opts: CodexCredentialSharingCheck): NodeFingerprint[];