@sleep2agi/agent-network 2.3.0-preview.155 → 2.3.0-preview.157

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_0x5a0aec=a0_0x1710;(function(_0x437176,_0x151f95){const _0x57a228=a0_0x1710,_0x14b20d=_0x437176();while(!![]){try{const _0x30fb31=-parseInt(_0x57a228(0x16c))/0x1*(parseInt(_0x57a228(0x192))/0x2)+parseInt(_0x57a228(0x13b))/0x3*(-parseInt(_0x57a228(0x168))/0x4)+parseInt(_0x57a228(0x182))/0x5+-parseInt(_0x57a228(0x149))/0x6*(-parseInt(_0x57a228(0x18d))/0x7)+parseInt(_0x57a228(0x175))/0x8+parseInt(_0x57a228(0x133))/0x9+parseInt(_0x57a228(0x132))/0xa;if(_0x30fb31===_0x151f95)break;else _0x14b20d['push'](_0x14b20d['shift']());}catch(_0x4507f0){_0x14b20d['push'](_0x14b20d['shift']());}}}(a0_0x4f19,0x70765));import{EventEmitter as a0_0x130632}from'events';import{hostname as a0_0x5a1fb0}from'os';function a0_0x4f19(){const _0x5276be=['from_session','heartbeatInterval','mcp_http','missing_task_id','CommHub\x20response\x20omitted\x20task_id','7ZilYKw','processInbox','unknown\x20error','connected','toTimeString','7188qHBZoV','name','\x20transport=','task','broadcast','status','task.replied','connect','parse','report_status','\x20from=','delivered','string','task_id','read','resumeId','<unknown>','sseAbort','now','error','slice','Authorization','send_failed','not_tracked','sending','sdk-','fromAlias','token','getReader','failed','6422320xOyzcq','2537361JdiuVH','log','transport','reply','[commhub:task]\x20','toString','match','completed','3iYxpCQ','message','data:\x20','SSE\x20error:\x20','connectSSE','toAlias','body','task.send.start','inbox\x20error:\x20','offline','sdk','ack_inbox','sleep','network_id','3623388AmytLG','running','decode','task.expired','SSE\x20reconnecting\x20in\x20','networkId','call','get_inbox','stringify','task.started','send_message','send_task','startsWith','/events/','alias','replace','parent_task_id','\x20network_id=','send','min','pop','\x20lifecycle=','CommHub\x20rejected\x20task','2.0','parentTaskId','task.send.delivered','abort','[REDACTED]','content','catch','disconnect','3061804SdUrqt','duration_ms','\x20duration_ms=','<missing>','106zjHIlK','text','url','error_code','idle','new_message',']\x20[commhub:','send_reply','s...','563192JLZZiA','lifecycleTracking','message_id','application/json','emit','disconnected','heartbeatTimer','heartbeat\x20failed:\x20','new_task','SSE\x20failed:\x20','agent','from_alias','reconnectDelay','43010vvMHnX','send_rejected','split','registered','type','get_all_status'];a0_0x4f19=function(){return _0x5276be;};return a0_0x4f19();}var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x51fb23,_0x5b85aa)=>(_0x51fb23??_0x5b85aa)[a0_0x5a0aec(0x158)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x5a0aec(0x1a6)](0x0,0xf0);function N(_0x4621cf){const _0xa2ac69=a0_0x5a0aec;return(_0x4621cf instanceof Error?_0x4621cf[_0xa2ac69(0x13c)]:String(_0x4621cf??_0xa2ac69(0x18f)))[_0xa2ac69(0x158)](K,_0xa2ac69(0x164))[_0xa2ac69(0x158)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0xa2ac69(0x1a6)](0x0,0xf0);}function O(_0x59a469,_0x44d8dd=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x308e12=a0_0x5a0aec;if(_0x44d8dd)return JSON[_0x308e12(0x151)](_0x59a469);let _0x3fe170=L(_0x59a469[_0x308e12(0x159)],_0x308e12(0x16b)),_0x75f9b2=L(_0x59a469[_0x308e12(0x19f)],'<pending>'),_0x4694b4=_0x59a469[_0x308e12(0x16f)]?'\x20error='+_0x59a469[_0x308e12(0x16f)]+':'+(_0x59a469['error_message']??''):'';return _0x308e12(0x137)+_0x59a469[_0x308e12(0x197)]+_0x308e12(0x19c)+L(_0x59a469[_0x308e12(0x180)],'<unknown>')+'\x20to='+L(_0x59a469['to_alias'],'<unknown>')+'\x20task_id='+_0x75f9b2+'\x20parent_task_id='+_0x3fe170+_0x308e12(0x15a)+L(_0x59a469[_0x308e12(0x148)],_0x308e12(0x1a2))+_0x308e12(0x194)+_0x59a469[_0x308e12(0x135)]+_0x308e12(0x16a)+_0x59a469[_0x308e12(0x169)]+_0x308e12(0x15e)+_0x59a469['lifecycle_tracking']+_0x4694b4;}function U(_0x4e3ebc){const _0x2bb770=a0_0x5a0aec;return{'event':{'sending':_0x2bb770(0x142),'delivered':_0x2bb770(0x162),'failed':'task.send.failed','acked':'task.ack','started':_0x2bb770(0x152),'replied':_0x2bb770(0x198),'expired':_0x2bb770(0x14c)}[_0x4e3ebc[_0x2bb770(0x197)]],..._0x4e3ebc};}function j(_0x2a5900){const _0x2759d0=a0_0x5a0aec;let _0x10af5d=_0x2a5900?.[_0x2759d0(0x19f)]||_0x2a5900?.[_0x2759d0(0x177)]||_0x2a5900?.['id'];if(_0x10af5d)return String(_0x10af5d);let _0x287eb4=_0x2a5900?.[_0x2759d0(0x165)]?.[0x0]?.[_0x2759d0(0x16d)];if(typeof _0x287eb4!==_0x2759d0(0x19e))return null;try{let _0x43ddf4=JSON[_0x2759d0(0x19a)](_0x287eb4);return _0x43ddf4?.[_0x2759d0(0x19f)]||_0x43ddf4?.[_0x2759d0(0x177)]||_0x43ddf4?.['id']||null;}catch{return null;}}async function X(_0x5cd11b,_0x2ab1de){const _0x17c431=a0_0x5a0aec;let _0x8a4d0e=_0x2ab1de[_0x17c431(0x1a4)]??Date[_0x17c431(0x1a4)],_0x5030a9=_0x8a4d0e(),_0x46fcbc=(_0x3011b9,_0x324fe3,_0x36855c,_0x229375)=>{const _0x328d8d=_0x17c431;_0x2ab1de[_0x328d8d(0x134)](O(U({'from_alias':_0x5cd11b[_0x328d8d(0x12e)],'to_alias':_0x5cd11b[_0x328d8d(0x140)],'task_id':_0x324fe3,'parent_task_id':_0x5cd11b[_0x328d8d(0x161)],'network_id':_0x5cd11b['networkId'],'transport':_0x5cd11b[_0x328d8d(0x135)],'status':_0x3011b9,'duration_ms':_0x8a4d0e()-_0x5030a9,'lifecycle_tracking':_0x5cd11b[_0x328d8d(0x176)],..._0x36855c!==void 0x0?{'error_code':_0x229375||_0x328d8d(0x1a8),'error_message':N(_0x36855c)}:{}})));};_0x46fcbc(_0x17c431(0x1aa),null);try{let _0x2a8735=await _0x2ab1de[_0x17c431(0x15b)](),_0x17f152=j(_0x2a8735);if(_0x17f152)_0x46fcbc(_0x17c431(0x19d),_0x17f152);else{if(_0x2a8735?.['ok']===!0x1||_0x2a8735?.['error'])_0x46fcbc(_0x17c431(0x131),_0x17f152,_0x2a8735?.[_0x17c431(0x1a5)]||_0x17c431(0x15f),_0x17c431(0x183));else _0x46fcbc(_0x17c431(0x131),null,_0x17c431(0x18c),_0x17c431(0x18b));}return _0x2a8735;}catch(_0x299e09){throw _0x46fcbc('failed',null,_0x299e09,_0x17c431(0x1a8)),_0x299e09;}}async function Y(_0x32e631,_0x5876ad){const _0x53a68f=a0_0x5a0aec;return X({'fromAlias':_0x32e631[_0x53a68f(0x12e)],'toAlias':_0x32e631['alias'],'parentTaskId':_0x32e631['parentTaskId']||null,'networkId':_0x32e631[_0x53a68f(0x14e)]||null,'transport':_0x53a68f(0x18a),'lifecycleTracking':_0x53a68f(0x1a9)},_0x5876ad);}function a0_0x1710(_0x3bb73b,_0x36e97d){_0x3bb73b=_0x3bb73b-0x12e;const _0x4f19bf=a0_0x4f19();let _0x1710f4=_0x4f19bf[_0x3bb73b];return _0x1710f4;}class $ extends a0_0x130632{[a0_0x5a0aec(0x16e)];[a0_0x5a0aec(0x157)];['token'];[a0_0x5a0aec(0x17f)];[a0_0x5a0aec(0x1a1)];['heartbeatInterval'];[a0_0x5a0aec(0x181)];['heartbeatTimer'];[a0_0x5a0aec(0x1a3)];[a0_0x5a0aec(0x14a)]=!0x1;constructor(_0x257390){const _0x417fc5=a0_0x5a0aec;super();if(this[_0x417fc5(0x16e)]=_0x257390[_0x417fc5(0x16e)][_0x417fc5(0x158)](/\/$/,''),this[_0x417fc5(0x157)]=_0x257390[_0x417fc5(0x157)],this[_0x417fc5(0x12f)]=_0x257390[_0x417fc5(0x12f)],this['agent']=_0x257390[_0x417fc5(0x17f)]||_0x417fc5(0x145),this[_0x417fc5(0x1a1)]=_0x417fc5(0x1ab)+_0x257390[_0x417fc5(0x157)]+'-'+Date[_0x417fc5(0x1a4)]()[_0x417fc5(0x138)](0x24),this[_0x417fc5(0x189)]=_0x257390[_0x417fc5(0x189)]??0x2bf20,this['reconnectDelay']=_0x257390[_0x417fc5(0x181)]??0xbb8,_0x257390['autoConnect']!==!0x1)this[_0x417fc5(0x199)]();}['log'](_0x34419c){const _0xdebc83=a0_0x5a0aec;console[_0xdebc83(0x134)]('['+new Date()[_0xdebc83(0x191)]()['slice'](0x0,0x8)+_0xdebc83(0x172)+this[_0xdebc83(0x157)]+']\x20'+_0x34419c);}async[a0_0x5a0aec(0x14f)](_0x311397,_0x292f01){const _0x3cbb84=a0_0x5a0aec;let _0x223b95={'Content-Type':_0x3cbb84(0x178),'Accept':'application/json,\x20text/event-stream'};if(this[_0x3cbb84(0x12f)])_0x223b95[_0x3cbb84(0x1a7)]='Bearer\x20'+this['token'];let _0x3bf6b2=await(await fetch(this[_0x3cbb84(0x16e)]+'/mcp',{'method':'POST','headers':_0x223b95,'body':JSON['stringify']({'jsonrpc':_0x3cbb84(0x160),'id':Date[_0x3cbb84(0x1a4)](),'method':'tools/call','params':{'name':_0x311397,'arguments':_0x292f01}})}))[_0x3cbb84(0x16d)](),_0x51aefb=_0x3bf6b2[_0x3cbb84(0x139)](/data: (.+)/),_0x1fc3ed=_0x51aefb?JSON[_0x3cbb84(0x19a)](_0x51aefb[0x1]):JSON[_0x3cbb84(0x19a)](_0x3bf6b2),_0x5d0cd7=_0x1fc3ed?.['result']?.['content']?.[0x0]?.[_0x3cbb84(0x16d)];return _0x5d0cd7?JSON[_0x3cbb84(0x19a)](_0x5d0cd7):_0x1fc3ed;}async[a0_0x5a0aec(0x199)](){const _0x55e9af=a0_0x5a0aec;if(this['running'])return;this['running']=!0x0,await this[_0x55e9af(0x197)](_0x55e9af(0x170)),this[_0x55e9af(0x134)](_0x55e9af(0x185)),this[_0x55e9af(0x17b)]=setInterval(()=>{const _0x271414=_0x55e9af;this[_0x271414(0x197)](_0x271414(0x170))[_0x271414(0x166)](_0x4d6509=>this[_0x271414(0x134)](_0x271414(0x17c)+_0x4d6509['message']));},this[_0x55e9af(0x189)]),this[_0x55e9af(0x13f)]();}async[a0_0x5a0aec(0x167)](){const _0x3f3337=a0_0x5a0aec;if(this[_0x3f3337(0x14a)]=!0x1,this['sseAbort']?.[_0x3f3337(0x163)](),this[_0x3f3337(0x17b)])clearInterval(this[_0x3f3337(0x17b)]);await this['status'](_0x3f3337(0x144))[_0x3f3337(0x166)](()=>{}),this[_0x3f3337(0x134)](_0x3f3337(0x17a));}async['send'](_0x137d33,_0x207812,_0x464adf='normal'){const _0x994d76=a0_0x5a0aec;return Y({'alias':_0x137d33,'fromAlias':this['alias']},{'log':_0x27bcd4=>console[_0x994d76(0x134)](_0x27bcd4),'send':()=>this[_0x994d76(0x14f)](_0x994d76(0x154),{'alias':_0x137d33,'task':_0x207812,'priority':_0x464adf,'from_session':this[_0x994d76(0x157)]})});}async[a0_0x5a0aec(0x13c)](_0x5e0f1f,_0x278a3f){const _0x57fee1=a0_0x5a0aec;return this[_0x57fee1(0x14f)](_0x57fee1(0x153),{'alias':_0x5e0f1f,'message':_0x278a3f,'from_session':this[_0x57fee1(0x157)]});}async[a0_0x5a0aec(0x136)](_0x1b3648,_0x4bf500,_0x676ab1=a0_0x5a0aec(0x13a)){const _0x4c27e8=a0_0x5a0aec;return this['call'](_0x4c27e8(0x173),{'in_reply_to':_0x1b3648,'text':_0x4bf500,'status':_0x676ab1});}async[a0_0x5a0aec(0x197)](_0xac8ddd,_0x55155d){const _0x1929d4=a0_0x5a0aec;return this[_0x1929d4(0x14f)](_0x1929d4(0x19b),{'resume_id':this['resumeId'],'alias':this[_0x1929d4(0x157)],'status':_0xac8ddd,'server':a0_0x5a1fb0(),'hostname':a0_0x5a1fb0(),'agent':this[_0x1929d4(0x17f)],'project_dir':process['cwd'](),..._0x55155d});}async['getAllStatus'](){const _0x16e946=a0_0x5a0aec;return this[_0x16e946(0x14f)](_0x16e946(0x187),{});}async[a0_0x5a0aec(0x196)](_0x3fe73f,_0x54c834){const _0x4afc5c=a0_0x5a0aec;return this['call'](_0x4afc5c(0x196),{'message':_0x3fe73f,'filter_server':_0x54c834?.['server'],'filter_status':_0x54c834?.[_0x4afc5c(0x197)]});}async[a0_0x5a0aec(0x13f)](){const _0x215737=a0_0x5a0aec;let _0x3da347=encodeURIComponent(this[_0x215737(0x157)]),_0x405456=this[_0x215737(0x16e)]+_0x215737(0x156)+_0x3da347,_0x29b86b=this[_0x215737(0x181)];while(this[_0x215737(0x14a)]){try{this[_0x215737(0x1a3)]=new AbortController();let _0xb97671={'Accept':'text/event-stream'};if(this[_0x215737(0x12f)])_0xb97671[_0x215737(0x1a7)]='Bearer\x20'+this[_0x215737(0x12f)];let _0x5988a8=await fetch(_0x405456,{'headers':_0xb97671,'signal':this[_0x215737(0x1a3)]['signal']});if(!_0x5988a8['ok']||!_0x5988a8[_0x215737(0x141)]){this['log'](_0x215737(0x17e)+_0x5988a8[_0x215737(0x197)]),await this[_0x215737(0x147)](_0x29b86b),_0x29b86b=Math[_0x215737(0x15c)](_0x29b86b*1.5,0xea60);continue;}_0x29b86b=this[_0x215737(0x181)];let _0x545c8a=_0x5988a8['body'][_0x215737(0x130)](),_0x13bb8c=new TextDecoder(),_0x560e30='';while(this[_0x215737(0x14a)]){let {done:_0x546a7f,value:_0x20cbce}=await _0x545c8a[_0x215737(0x1a0)]();if(_0x546a7f)break;_0x560e30+=_0x13bb8c[_0x215737(0x14b)](_0x20cbce,{'stream':!0x0});let _0x3a956e=_0x560e30[_0x215737(0x184)]('\x0a');_0x560e30=_0x3a956e[_0x215737(0x15d)]()||'';for(let _0x370e8 of _0x3a956e){if(!_0x370e8[_0x215737(0x155)](_0x215737(0x13d)))continue;try{let _0x3cbadc=JSON[_0x215737(0x19a)](_0x370e8[_0x215737(0x1a6)](0x6));if(_0x3cbadc[_0x215737(0x186)]===_0x215737(0x190)){this[_0x215737(0x134)]('SSE\x20connected'),this[_0x215737(0x179)](_0x215737(0x190));continue;}if(_0x3cbadc[_0x215737(0x186)]===_0x215737(0x17d)||_0x3cbadc[_0x215737(0x186)]===_0x215737(0x171)||_0x3cbadc[_0x215737(0x186)]==='broadcast')await this['processInbox']();}catch{}}}}catch(_0x100cc5){if(_0x100cc5[_0x215737(0x193)]==='AbortError')break;this['emit'](_0x215737(0x1a5),_0x100cc5),this[_0x215737(0x134)](_0x215737(0x13e)+_0x100cc5[_0x215737(0x13c)]);}if(this[_0x215737(0x14a)])this[_0x215737(0x179)](_0x215737(0x17a)),this[_0x215737(0x134)](_0x215737(0x14d)+_0x29b86b/0x3e8+_0x215737(0x174)),await this[_0x215737(0x147)](_0x29b86b),_0x29b86b=Math[_0x215737(0x15c)](_0x29b86b*1.5,0xea60);}}async[a0_0x5a0aec(0x18e)](){const _0xe039fb=a0_0x5a0aec;try{let _0x2aa716=(await this[_0xe039fb(0x14f)](_0xe039fb(0x150),{'alias':this['alias'],'limit':0xa}))?.['messages']||[];for(let _0x263c14 of _0x2aa716)await this[_0xe039fb(0x14f)](_0xe039fb(0x146),{'alias':this[_0xe039fb(0x157)],'message_id':_0x263c14['id']}),this[_0xe039fb(0x134)]('←\x20'+_0x263c14[_0xe039fb(0x188)]+':\x20'+_0x263c14['content'][_0xe039fb(0x1a6)](0x0,0x3c)),this['emit'](_0xe039fb(0x195),_0x263c14),this[_0xe039fb(0x179)](_0xe039fb(0x13c),_0x263c14);}catch(_0xe4276e){this[_0xe039fb(0x134)](_0xe039fb(0x143)+_0xe4276e[_0xe039fb(0x13c)]);}}['sleep'](_0x4efc2d){return new Promise(_0x29fbbc=>setTimeout(_0x29fbbc,_0x4efc2d));}}var F=$;export{F as default,$ as CommHub};
1
+ const a0_0x5b169f=a0_0x18a4;(function(_0x38d5a0,_0x57e691){const _0x4c9090=a0_0x18a4,_0x39e1c0=_0x38d5a0();while(!![]){try{const _0xf84c56=parseInt(_0x4c9090(0xaa))/0x1+parseInt(_0x4c9090(0xba))/0x2*(-parseInt(_0x4c9090(0x105))/0x3)+parseInt(_0x4c9090(0x102))/0x4+-parseInt(_0x4c9090(0xe1))/0x5+parseInt(_0x4c9090(0x8e))/0x6*(parseInt(_0x4c9090(0xfb))/0x7)+parseInt(_0x4c9090(0xf6))/0x8*(-parseInt(_0x4c9090(0xc3))/0x9)+parseInt(_0x4c9090(0xda))/0xa;if(_0xf84c56===_0x57e691)break;else _0x39e1c0['push'](_0x39e1c0['shift']());}catch(_0x43c405){_0x39e1c0['push'](_0x39e1c0['shift']());}}}(a0_0x1a4b,0x6632c));import{EventEmitter as a0_0x29bb58}from'events';import{hostname as a0_0x10445d}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x37f079,_0x35b676)=>(_0x37f079??_0x35b676)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x5b169f(0x9b)](0x0,0xf0);function N(_0x3bc5dc){const _0xd5b3bd=a0_0x5b169f;return(_0x3bc5dc instanceof Error?_0x3bc5dc[_0xd5b3bd(0xfe)]:String(_0x3bc5dc??'unknown\x20error'))[_0xd5b3bd(0x96)](K,_0xd5b3bd(0xa4))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0xd5b3bd(0x9b)](0x0,0xf0);}function O(_0x4eb4bb,_0x1dafe2=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x2e660b=a0_0x5b169f;if(_0x1dafe2)return JSON[_0x2e660b(0x101)](_0x4eb4bb);let _0x57b269=L(_0x4eb4bb[_0x2e660b(0xcd)],_0x2e660b(0xbe)),_0x4974e1=L(_0x4eb4bb[_0x2e660b(0xb7)],_0x2e660b(0x8c)),_0x29d9fb=_0x4eb4bb[_0x2e660b(0xf5)]?'\x20error='+_0x4eb4bb[_0x2e660b(0xf5)]+':'+(_0x4eb4bb[_0x2e660b(0xd2)]??''):'';return _0x2e660b(0xb8)+_0x4eb4bb[_0x2e660b(0x8b)]+_0x2e660b(0xce)+L(_0x4eb4bb[_0x2e660b(0xa8)],_0x2e660b(0xdf))+_0x2e660b(0x91)+L(_0x4eb4bb[_0x2e660b(0xc6)],_0x2e660b(0xdf))+'\x20task_id='+_0x4974e1+_0x2e660b(0xa7)+_0x57b269+_0x2e660b(0xa1)+L(_0x4eb4bb[_0x2e660b(0x94)],_0x2e660b(0xdf))+_0x2e660b(0xb6)+_0x4eb4bb[_0x2e660b(0xa0)]+_0x2e660b(0xf3)+_0x4eb4bb[_0x2e660b(0xc1)]+_0x2e660b(0xe6)+_0x4eb4bb[_0x2e660b(0xe3)]+_0x29d9fb;}function U(_0x52e2b7){const _0x3caa05=a0_0x5b169f;return{'event':{'sending':_0x3caa05(0xaf),'delivered':_0x3caa05(0xb9),'failed':_0x3caa05(0xbc),'acked':_0x3caa05(0x92),'started':'task.started','replied':'task.replied','expired':'task.expired'}[_0x52e2b7['status']],..._0x52e2b7};}function j(_0x456c53){const _0x1f0b12=a0_0x5b169f;let _0x115613=_0x456c53?.[_0x1f0b12(0xb7)]||_0x456c53?.[_0x1f0b12(0xc4)]||_0x456c53?.['id'];if(_0x115613)return String(_0x115613);let _0x555882=_0x456c53?.[_0x1f0b12(0xef)]?.[0x0]?.[_0x1f0b12(0x89)];if(typeof _0x555882!==_0x1f0b12(0xdd))return null;try{let _0x473e56=JSON['parse'](_0x555882);return _0x473e56?.['task_id']||_0x473e56?.[_0x1f0b12(0xc4)]||_0x473e56?.['id']||null;}catch{return null;}}async function X(_0x2978fb,_0x50c3dc){const _0x56cdcb=a0_0x5b169f;let _0x208940=_0x50c3dc[_0x56cdcb(0xe8)]??Date[_0x56cdcb(0xe8)],_0x1c4939=_0x208940(),_0x46caed=(_0x4896a2,_0x45b11a,_0x4a7bc9,_0x39d9af)=>{const _0x452cc6=_0x56cdcb;_0x50c3dc['log'](O(U({'from_alias':_0x2978fb['fromAlias'],'to_alias':_0x2978fb[_0x452cc6(0xb2)],'task_id':_0x45b11a,'parent_task_id':_0x2978fb['parentTaskId'],'network_id':_0x2978fb[_0x452cc6(0xf1)],'transport':_0x2978fb[_0x452cc6(0xa0)],'status':_0x4896a2,'duration_ms':_0x208940()-_0x1c4939,'lifecycle_tracking':_0x2978fb['lifecycleTracking'],..._0x4a7bc9!==void 0x0?{'error_code':_0x39d9af||_0x452cc6(0xfc),'error_message':N(_0x4a7bc9)}:{}})));};_0x46caed(_0x56cdcb(0x88),null);try{let _0x2d88b3=await _0x50c3dc[_0x56cdcb(0x9c)](),_0x89fd21=j(_0x2d88b3);if(_0x89fd21)_0x46caed(_0x56cdcb(0xad),_0x89fd21);else{if(_0x2d88b3?.['ok']===!0x1||_0x2d88b3?.[_0x56cdcb(0xec)])_0x46caed(_0x56cdcb(0x100),_0x89fd21,_0x2d88b3?.[_0x56cdcb(0xec)]||'CommHub\x20rejected\x20task',_0x56cdcb(0x98));else _0x46caed('failed',null,_0x56cdcb(0xd4),'missing_task_id');}return _0x2d88b3;}catch(_0x2fc96f){throw _0x46caed(_0x56cdcb(0x100),null,_0x2fc96f,_0x56cdcb(0xfc)),_0x2fc96f;}}function a0_0x18a4(_0x438cde,_0x58f630){_0x438cde=_0x438cde-0x88;const _0x1a4be1=a0_0x1a4b();let _0x18a438=_0x1a4be1[_0x438cde];return _0x18a438;}async function Y(_0x28e4f5,_0x66412e){const _0x2d6832=a0_0x5b169f;return X({'fromAlias':_0x28e4f5[_0x2d6832(0xff)],'toAlias':_0x28e4f5['alias'],'parentTaskId':_0x28e4f5[_0x2d6832(0xd6)]||null,'networkId':_0x28e4f5[_0x2d6832(0xf1)]||null,'transport':'mcp_http','lifecycleTracking':_0x2d6832(0xd7)},_0x66412e);}class $ extends a0_0x29bb58{[a0_0x5b169f(0xee)];[a0_0x5b169f(0xd0)];[a0_0x5b169f(0xf4)];['agent'];[a0_0x5b169f(0xfd)];['heartbeatInterval'];[a0_0x5b169f(0xab)];[a0_0x5b169f(0xa9)];['sseAbort'];[a0_0x5b169f(0xc7)]=!0x1;constructor(_0x2054cb){const _0x2405c1=a0_0x5b169f;super();if(this[_0x2405c1(0xee)]=_0x2054cb[_0x2405c1(0xee)][_0x2405c1(0x96)](/\/$/,''),this[_0x2405c1(0xd0)]=_0x2054cb[_0x2405c1(0xd0)],this[_0x2405c1(0xf4)]=_0x2054cb[_0x2405c1(0xf4)],this[_0x2405c1(0xd5)]=_0x2054cb['agent']||_0x2405c1(0xd9),this['resumeId']=_0x2405c1(0xc2)+_0x2054cb[_0x2405c1(0xd0)]+'-'+Date[_0x2405c1(0xe8)]()[_0x2405c1(0xeb)](0x24),this[_0x2405c1(0xb0)]=_0x2054cb['heartbeatInterval']??0x2bf20,this[_0x2405c1(0xab)]=_0x2054cb[_0x2405c1(0xab)]??0xbb8,_0x2054cb[_0x2405c1(0xea)]!==!0x1)this[_0x2405c1(0x99)]();}[a0_0x5b169f(0xf8)](_0x510084){const _0x1be377=a0_0x5b169f;console[_0x1be377(0xf8)]('['+new Date()[_0x1be377(0xa2)]()['slice'](0x0,0x8)+_0x1be377(0xca)+this[_0x1be377(0xd0)]+']\x20'+_0x510084);}async[a0_0x5b169f(0x9e)](_0x340b68,_0x48b5af){const _0x4d1f4e=a0_0x5b169f;let _0x1c3e8a={'Content-Type':'application/json','Accept':_0x4d1f4e(0xb5)};if(this['token'])_0x1c3e8a[_0x4d1f4e(0xe2)]=_0x4d1f4e(0xe4)+this[_0x4d1f4e(0xf4)];let _0x22e5c0=await(await fetch(this[_0x4d1f4e(0xee)]+_0x4d1f4e(0x9a),{'method':_0x4d1f4e(0xb3),'headers':_0x1c3e8a,'body':JSON[_0x4d1f4e(0x101)]({'jsonrpc':_0x4d1f4e(0x104),'id':Date[_0x4d1f4e(0xe8)](),'method':_0x4d1f4e(0xe0),'params':{'name':_0x340b68,'arguments':_0x48b5af}})}))[_0x4d1f4e(0x89)](),_0x360a80=_0x22e5c0[_0x4d1f4e(0xdb)](/data: (.+)/),_0x550b8b=_0x360a80?JSON[_0x4d1f4e(0x90)](_0x360a80[0x1]):JSON[_0x4d1f4e(0x90)](_0x22e5c0),_0x21a369=_0x550b8b?.['result']?.[_0x4d1f4e(0xef)]?.[0x0]?.[_0x4d1f4e(0x89)];return _0x21a369?JSON[_0x4d1f4e(0x90)](_0x21a369):_0x550b8b;}async[a0_0x5b169f(0x99)](){const _0x5a4b3a=a0_0x5b169f;if(this['running'])return;this[_0x5a4b3a(0xc7)]=!0x0,await this[_0x5a4b3a(0x8b)](_0x5a4b3a(0xd3)),this['log']('registered'),this[_0x5a4b3a(0xa9)]=setInterval(()=>{const _0x29e9fc=_0x5a4b3a;this['status']('idle')[_0x29e9fc(0x97)](_0x11b33f=>this[_0x29e9fc(0xf8)](_0x29e9fc(0xa6)+_0x11b33f[_0x29e9fc(0xfe)]));},this[_0x5a4b3a(0xb0)]),this['connectSSE']();}async[a0_0x5b169f(0x9f)](){const _0x39a6b1=a0_0x5b169f;if(this['running']=!0x1,this[_0x39a6b1(0xe7)]?.['abort'](),this[_0x39a6b1(0xa9)])clearInterval(this['heartbeatTimer']);await this[_0x39a6b1(0x8b)]('offline')[_0x39a6b1(0x97)](()=>{}),this[_0x39a6b1(0xf8)](_0x39a6b1(0xf7));}async[a0_0x5b169f(0x9c)](_0xf6817b,_0x984769,_0x5e9c3c=a0_0x5b169f(0xe5)){const _0x3f94c9=a0_0x5b169f;return Y({'alias':_0xf6817b,'fromAlias':this[_0x3f94c9(0xd0)]},{'log':_0x55430e=>console['log'](_0x55430e),'send':()=>this[_0x3f94c9(0x9e)]('send_task',{'alias':_0xf6817b,'task':_0x984769,'priority':_0x5e9c3c,'from_session':this[_0x3f94c9(0xd0)]})});}async[a0_0x5b169f(0xfe)](_0x321224,_0x3a7894){const _0x11f19a=a0_0x5b169f;return this[_0x11f19a(0x9e)](_0x11f19a(0xf0),{'alias':_0x321224,'message':_0x3a7894,'from_session':this[_0x11f19a(0xd0)]});}async[a0_0x5b169f(0xbf)](_0xac5c70,_0x73a354,_0x276e11='completed'){const _0x159ffc=a0_0x5b169f;return this['call'](_0x159ffc(0xb1),{'in_reply_to':_0xac5c70,'text':_0x73a354,'status':_0x276e11});}async[a0_0x5b169f(0x8b)](_0x2769f8,_0x577516){const _0x23ef42=a0_0x5b169f;return this[_0x23ef42(0x9e)](_0x23ef42(0xd8),{'resume_id':this[_0x23ef42(0xfd)],'alias':this['alias'],'status':_0x2769f8,'server':a0_0x10445d(),'hostname':a0_0x10445d(),'agent':this['agent'],'project_dir':process[_0x23ef42(0xa3)](),..._0x577516});}async[a0_0x5b169f(0xc5)](){const _0x35acae=a0_0x5b169f;return this[_0x35acae(0x9e)](_0x35acae(0xc8),{});}async[a0_0x5b169f(0xae)](_0x5d884a,_0x43d988){const _0xe73fef=a0_0x5b169f;return this[_0xe73fef(0x9e)](_0xe73fef(0xae),{'message':_0x5d884a,'filter_server':_0x43d988?.['server'],'filter_status':_0x43d988?.[_0xe73fef(0x8b)]});}async['connectSSE'](){const _0x52cee3=a0_0x5b169f;let _0x3d1def=encodeURIComponent(this[_0x52cee3(0xd0)]),_0x122bdd=this[_0x52cee3(0xee)]+_0x52cee3(0xa5)+_0x3d1def,_0x45f912=this[_0x52cee3(0xab)];while(this[_0x52cee3(0xc7)]){try{this['sseAbort']=new AbortController();let _0xe040b3={'Accept':_0x52cee3(0xbd)};if(this[_0x52cee3(0xf4)])_0xe040b3[_0x52cee3(0xe2)]=_0x52cee3(0xe4)+this[_0x52cee3(0xf4)];let _0x3960af=await fetch(_0x122bdd,{'headers':_0xe040b3,'signal':this[_0x52cee3(0xe7)]['signal']});if(!_0x3960af['ok']||!_0x3960af['body']){this[_0x52cee3(0xf8)]('SSE\x20failed:\x20'+_0x3960af[_0x52cee3(0x8b)]),await this[_0x52cee3(0xed)](_0x45f912),_0x45f912=Math[_0x52cee3(0xc0)](_0x45f912*1.5,0xea60);continue;}_0x45f912=this['reconnectDelay'];let _0x16f19e=_0x3960af['body'][_0x52cee3(0xdc)](),_0x108973=new TextDecoder(),_0x3ba176='';while(this['running']){let {done:_0x20b93d,value:_0x2fd472}=await _0x16f19e['read']();if(_0x20b93d)break;_0x3ba176+=_0x108973[_0x52cee3(0x9d)](_0x2fd472,{'stream':!0x0});let _0x55843d=_0x3ba176[_0x52cee3(0x8a)]('\x0a');_0x3ba176=_0x55843d[_0x52cee3(0xbb)]()||'';for(let _0xbf582e of _0x55843d){if(!_0xbf582e[_0x52cee3(0x95)](_0x52cee3(0x8f)))continue;try{let _0x440d83=JSON[_0x52cee3(0x90)](_0xbf582e[_0x52cee3(0x9b)](0x6));if(_0x440d83[_0x52cee3(0xe9)]===_0x52cee3(0xb4)){this[_0x52cee3(0xf8)](_0x52cee3(0xcf)),this[_0x52cee3(0x8d)]('connected');continue;}if(_0x440d83[_0x52cee3(0xe9)]===_0x52cee3(0xcc)||_0x440d83[_0x52cee3(0xe9)]==='new_message'||_0x440d83['type']===_0x52cee3(0xae))await this[_0x52cee3(0xac)]();}catch{}}}}catch(_0x2b009d){if(_0x2b009d[_0x52cee3(0xc9)]===_0x52cee3(0x106))break;this[_0x52cee3(0x8d)]('error',_0x2b009d),this[_0x52cee3(0xf8)](_0x52cee3(0x93)+_0x2b009d[_0x52cee3(0xfe)]);}if(this[_0x52cee3(0xc7)])this['emit']('disconnected'),this['log']('SSE\x20reconnecting\x20in\x20'+_0x45f912/0x3e8+_0x52cee3(0xfa)),await this[_0x52cee3(0xed)](_0x45f912),_0x45f912=Math['min'](_0x45f912*1.5,0xea60);}}async[a0_0x5b169f(0xac)](){const _0x5660c7=a0_0x5b169f;try{let _0x2e33de=(await this[_0x5660c7(0x9e)](_0x5660c7(0xde),{'alias':this[_0x5660c7(0xd0)],'limit':0xa}))?.[_0x5660c7(0xd1)]||[];for(let _0x3326e1 of _0x2e33de)await this['call'](_0x5660c7(0xf9),{'alias':this[_0x5660c7(0xd0)],'message_id':_0x3326e1['id']}),this[_0x5660c7(0xf8)]('←\x20'+_0x3326e1[_0x5660c7(0xcb)]+':\x20'+_0x3326e1['content']['slice'](0x0,0x3c)),this[_0x5660c7(0x8d)](_0x5660c7(0xf2),_0x3326e1),this['emit'](_0x5660c7(0xfe),_0x3326e1);}catch(_0x10b265){this['log'](_0x5660c7(0x103)+_0x10b265['message']);}}[a0_0x5b169f(0xed)](_0x5b4e63){return new Promise(_0x38298d=>setTimeout(_0x38298d,_0x5b4e63));}}function a0_0x1a4b(){const _0x5e8659=['status','<pending>','emit','42wsbyLn','data:\x20','parse','\x20to=','task.ack','SSE\x20error:\x20','network_id','startsWith','replace','catch','send_rejected','connect','/mcp','slice','send','decode','call','disconnect','transport','\x20network_id=','toTimeString','cwd','[REDACTED]','/events/','heartbeat\x20failed:\x20','\x20parent_task_id=','from_alias','heartbeatTimer','587181SXCGFV','reconnectDelay','processInbox','delivered','broadcast','task.send.start','heartbeatInterval','send_reply','toAlias','POST','connected','application/json,\x20text/event-stream','\x20transport=','task_id','[commhub:task]\x20','task.send.delivered','2NfYefw','pop','task.send.failed','text/event-stream','<missing>','reply','min','duration_ms','sdk-','99666gBUGKy','message_id','getAllStatus','to_alias','running','get_all_status','name',']\x20[commhub:','from_session','new_task','parent_task_id','\x20from=','SSE\x20connected','alias','messages','error_message','idle','CommHub\x20response\x20omitted\x20task_id','agent','parentTaskId','not_tracked','report_status','sdk','4983760UfMQhd','match','getReader','string','get_inbox','<unknown>','tools/call','3158700vayWHn','Authorization','lifecycle_tracking','Bearer\x20','normal','\x20lifecycle=','sseAbort','now','type','autoConnect','toString','error','sleep','url','content','send_message','networkId','task','\x20duration_ms=','token','error_code','272dWXPfW','disconnected','log','ack_inbox','s...','35021rGOpnU','send_failed','resumeId','message','fromAlias','failed','stringify','1240900lGpFBI','inbox\x20error:\x20','2.0','11829hEwVco','AbortError','sending','text','split'];a0_0x1a4b=function(){return _0x5e8659;};return a0_0x1a4b();}var F=$;export{F as default,$ as CommHub};
@@ -0,0 +1,22 @@
1
+ export declare const COMMHUB_TOOLS_APPROVAL_KEY = "mcp_servers.commhub.default_tools_approval_mode";
2
+ export declare const COMMHUB_TOOLS_APPROVAL_VALUE = "approve";
3
+ export declare const COMMHUB_TOKEN_ENV = "ANET_CODEX_COMMHUB_TOKEN";
4
+ /**
5
+ * `-c` fragments (without the `-c` flags) for the commhub MCP server.
6
+ * - `quoted`: TOML string literals, for the POSIX launcher (each fragment is shellQuoted).
7
+ * - `bare`: unquoted values, for the Windows launcher (cmd.exe mangles `"`; codex parses a
8
+ * value that is not valid TOML as a plain string, so `x=approve` reads as "approve").
9
+ */
10
+ export declare function codexCommhubMcpOverrides(hubBaseUrl: string, style: "quoted" | "bare"): string[];
11
+ /**
12
+ * The complete argv of the Windows co-presence `codex app-server` (the launcher passes
13
+ * exactly this to windowsManagedProcess). Pure, so it is testable on Linux CI where the
14
+ * win32 launcher itself cannot run (#720 review: assert the launcher's real argv).
15
+ */
16
+ export declare function codexWindowsAppServerArgs(o: {
17
+ approvalPolicy: string;
18
+ sandboxMode: string;
19
+ model: string;
20
+ hub: string;
21
+ wsUrl: string;
22
+ }): string[];
@@ -0,0 +1,5 @@
1
+ /** Merge user config.env into one co-presence stage. Required launcher values
2
+ * always win. Invalid shell names/NULs fail closed before a tmux session starts. */
3
+ export declare function codexCopresenceStageEnv(configEnv: Readonly<Record<string, string>>, required: Readonly<Record<string, string>>): Record<string, string>;
4
+ /** Contents for a private source-then-delete file. Values never enter argv. */
5
+ export declare function codexCopresenceEnvFileText(env: Readonly<Record<string, string>>): string;
@@ -4,6 +4,8 @@ export interface CodexRecoveryVerification {
4
4
  verifiedAt: string;
5
5
  historyTurnCount: number;
6
6
  historyFingerprint: string;
7
+ /** Metadata-only thread/read proof that Codex resolved this exact rollout. */
8
+ persistedPath?: string;
7
9
  }
8
10
  export interface CodexRecoveryBackup {
9
11
  backupDir: string;
@@ -13,6 +15,13 @@ export interface CodexRecoveryBackup {
13
15
  /** Transaction boundary shared by Windows and POSIX cutovers: the snapshot
14
16
  * cannot begin until every authoritative state writer has quiesced. */
15
17
  export declare function quiesceThenSnapshot<T>(quiesce: () => Promise<void>, snapshot: () => T): Promise<T>;
18
+ /** Copy and hash without ever materializing the whole file in a Buffer.
19
+ * Zero chunks are sought over and the final length is truncated explicitly,
20
+ * so a multi-GiB sparse rollout stays sparse in the private recovery point. */
21
+ export declare function copyAndHashRecoveryFile(source: string, target: string): {
22
+ size: number;
23
+ sha256: string;
24
+ };
16
25
  /** A stored thread is never considered resumed until app-server reads the
17
26
  * exact thread back with persisted history. This is deliberately stricter
18
27
  * than accepting a successful thread/resume RPC response. */
@@ -0,0 +1,28 @@
1
+ export declare const CODEX_RESUME_TIMEOUT_ENV = "ANET_CODEX_RESUME_TIMEOUT_MS";
2
+ export declare const CODEX_RESUME_BASE_TIMEOUT_MS = 300000;
3
+ export declare const CODEX_RESUME_PER_GIB_MS = 120000;
4
+ export declare const CODEX_RESUME_MAX_TIMEOUT_MS: number;
5
+ export declare const CODEX_RECOVERY_MIN_PAYLOAD_BYTES: number;
6
+ export declare const CODEX_RECOVERY_PAYLOAD_OVERHEAD_BYTES: number;
7
+ export declare const CODEX_RECOVERY_MAX_PAYLOAD_BYTES: number;
8
+ export interface CopresenceResumeBudget {
9
+ timeoutMs: number;
10
+ rolloutBytes: number | null;
11
+ }
12
+ /** `--new-session` is authoritative for co-presence too: never feed the
13
+ * recorded thread into thread/resume when the operator explicitly asked for
14
+ * a fresh conversation. */
15
+ export declare function codexThreadIdForStart(recordedThreadId: string | undefined, newSession: boolean): string | undefined;
16
+ /** Resolve the recovery deadline once, before opening the app-server socket.
17
+ * The automatic budget is 300 s plus 120 s for each started GiB of the exact
18
+ * recorded rollout, capped at 15 minutes. An explicit environment value wins. */
19
+ export declare function resolveCopresenceResumeBudget(codexHome: string, threadId: string | undefined, env?: NodeJS.ProcessEnv, warn?: (message: string) => void): CopresenceResumeBudget;
20
+ export declare function resolveCopresenceResumeTimeoutMs(codexHome: string, threadId: string | undefined, env?: NodeJS.ProcessEnv, warn?: (message: string) => void): number;
21
+ export declare function formatCopresenceRolloutSize(bytes: number | null): string;
22
+ /** A finite receive ceiling for the one large thread/resume frame emitted by
23
+ * older Codex app-servers. Twice the rollout plus protocol headroom covers the
24
+ * measured JSON expansion without giving the loopback peer an unlimited heap. */
25
+ export declare function resolveCopresenceMaxPayloadBytes(rolloutBytes: number | null): number;
26
+ /** The bridge can make one retry after a resume timeout, so launcher readiness
27
+ * covers both bounded attempts instead of killing it at the old fixed 25 s. */
28
+ export declare function resolveCopresenceBridgeAttachTimeoutMs(resumeTimeoutMs: number): number;
@@ -0,0 +1,12 @@
1
+ import { type CodexRecoveryVerification } from "./codex-copresence-recovery";
2
+ export declare const SAFE_CODEX_THREAD_ID: RegExp;
3
+ /** Minimal JSON-RPC client used only while bringing up a co-presence app-server. */
4
+ export declare function createCodexCopresenceThread(ws: string, timeoutMs: number, resumeThreadId?: string, model?: string, options?: {
5
+ webSocketCtor?: any;
6
+ rolloutBytes?: number | null;
7
+ }): Promise<{
8
+ threadId: string;
9
+ verification?: CodexRecoveryVerification;
10
+ freshDeferred: boolean;
11
+ resumedModel?: string;
12
+ }>;
@@ -6,7 +6,9 @@
6
6
  * not had a conversation yet (codex only writes a rollout on the first turn).
7
7
  * It is bound to the identity marker of the generation that saw it, so a
8
8
  * restart after a crash can carry it over to the next generation without
9
- * guessing (`migrateCodexPendingThread`).
9
+ * guessing (`migrateCodexPendingThread`) once its exact rollout exists. A
10
+ * candidate acknowledged by RPC but never materialized remains pending and
11
+ * is dropped on the next start, even if the old marker file survived.
10
12
  *
11
13
  * A clean `anet node stop` reaps that generation and removes its marker, but
12
14
  * the candidate stays in the config. Before #602 the next start then refused
@@ -47,6 +49,18 @@ export type PendingMarkerFact = {
47
49
  /** Rollout files for exactly this thread id (suffix match, no prefix guessing), or `null` if the search itself failed. */
48
50
  export type RolloutLookup = (threadId: string) => string[] | null;
49
51
  export declare function decidePendingThreadAtStart(pending: unknown, marker: PendingMarkerFact, rollouts: RolloutLookup): PendingThreadAtStart;
52
+ /**
53
+ * Apply the decision to an in-memory node config without platform-specific
54
+ * shortcuts. Both launchers persist `config` before quiescing the old
55
+ * generation. Keeping the deletion here makes the Windows stop -> start
56
+ * behavior executable in the Linux Docker gate instead of relying only on a
57
+ * source-shape assertion (the native Windows smoke remains the end-to-end
58
+ * proof).
59
+ */
60
+ export declare function reconcilePendingThreadAtStart<T extends Record<string, unknown>>(config: T, marker: PendingMarkerFact, rollouts: RolloutLookup): PendingThreadAtStart & {
61
+ config: T;
62
+ changed: boolean;
63
+ };
50
64
  /**
51
65
  * Every `*-<threadId>.jsonl` under `<codexHome>/sessions` and
52
66
  * `<codexHome>/archived_sessions`. A missing directory is "no rollouts"; any
@@ -0,0 +1,15 @@
1
+ import { waitForStartResources, type StartGateDeps, type StartGateResult } from "./start-resource-gate";
2
+ /** A measured 500 MiB legacy recovery peaked at 8.4x its rollout size. Nine
3
+ * times the rollout leaves a small margin while remaining an explainable,
4
+ * testable admission estimate rather than pretending maxPayload bounds Codex. */
5
+ export declare const CODEX_RECOVERY_MEMORY_MULTIPLIER = 9;
6
+ export declare const CODEX_RECOVERY_MIN_MEMORY_MB = 4096;
7
+ export declare function estimatedCodexRecoveryMemoryMb(rolloutBytes: number | null): number;
8
+ export interface CodexRecoveryGateDeps extends StartGateDeps {
9
+ /** @internal seam: the shared start gate owns locking and stale-lease safety. */
10
+ gate?: typeof waitForStartResources;
11
+ }
12
+ /** Serialize the memory-heavy legacy resume phase and require enough effective
13
+ * MemAvailable for this rollout. The returned lease stays held through the
14
+ * launcher, bridge and TUI attachment and must then be released. */
15
+ export declare function waitForCodexRecoveryResources(nodeId: string, rolloutBytes: number | null, deps?: CodexRecoveryGateDeps): Promise<StartGateResult>;