@sleep2agi/agent-network 2.3.0-preview.158 → 2.3.0-preview.159

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_0x29ff6e=a0_0xf0ac;(function(_0x5ec37e,_0x3bf339){const _0x16ff02=a0_0xf0ac,_0x471eaa=_0x5ec37e();while(!![]){try{const _0x129bbc=-parseInt(_0x16ff02(0x248))/0x1+-parseInt(_0x16ff02(0x236))/0x2*(parseInt(_0x16ff02(0x1e4))/0x3)+-parseInt(_0x16ff02(0x226))/0x4*(-parseInt(_0x16ff02(0x20e))/0x5)+parseInt(_0x16ff02(0x22d))/0x6+-parseInt(_0x16ff02(0x24e))/0x7*(parseInt(_0x16ff02(0x22c))/0x8)+parseInt(_0x16ff02(0x219))/0x9*(parseInt(_0x16ff02(0x24f))/0xa)+-parseInt(_0x16ff02(0x234))/0xb;if(_0x129bbc===_0x3bf339)break;else _0x471eaa['push'](_0x471eaa['shift']());}catch(_0x531469){_0x471eaa['push'](_0x471eaa['shift']());}}}(a0_0x1b64,0x86cbe));import{EventEmitter as a0_0x56ddee}from'events';import{hostname as a0_0x12ebf3}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x3d3a15,_0x4e6d55)=>(_0x3d3a15??_0x4e6d55)[a0_0x29ff6e(0x23a)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x29ff6e(0x249)](0x0,0xf0);function N(_0x2a1028){const _0x46a117=a0_0x29ff6e;return(_0x2a1028 instanceof Error?_0x2a1028[_0x46a117(0x213)]:String(_0x2a1028??_0x46a117(0x235)))['replace'](K,_0x46a117(0x1ea))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x46a117(0x249)](0x0,0xf0);}function O(_0x375ab9,_0xa14e67=process.env.ANET_TASK_TRACE_FORMAT===a0_0x29ff6e(0x216)){const _0x556f22=a0_0x29ff6e;if(_0xa14e67)return JSON['stringify'](_0x375ab9);let _0x260ad1=L(_0x375ab9[_0x556f22(0x203)],_0x556f22(0x227)),_0x3a8b85=L(_0x375ab9['task_id'],'<pending>'),_0x1771f0=_0x375ab9[_0x556f22(0x239)]?'\x20error='+_0x375ab9[_0x556f22(0x239)]+':'+(_0x375ab9['error_message']??''):'';return _0x556f22(0x241)+_0x375ab9[_0x556f22(0x258)]+_0x556f22(0x215)+L(_0x375ab9['from_alias'],'<unknown>')+'\x20to='+L(_0x375ab9['to_alias'],'<unknown>')+_0x556f22(0x24a)+_0x3a8b85+_0x556f22(0x255)+_0x260ad1+_0x556f22(0x243)+L(_0x375ab9[_0x556f22(0x20d)],_0x556f22(0x247))+'\x20transport='+_0x375ab9[_0x556f22(0x221)]+'\x20duration_ms='+_0x375ab9[_0x556f22(0x1f6)]+'\x20lifecycle='+_0x375ab9[_0x556f22(0x207)]+_0x1771f0;}function U(_0x382585){const _0x4d8f09=a0_0x29ff6e;return{'event':{'sending':_0x4d8f09(0x23c),'delivered':_0x4d8f09(0x246),'failed':_0x4d8f09(0x1f2),'acked':_0x4d8f09(0x230),'started':_0x4d8f09(0x1fc),'replied':_0x4d8f09(0x256),'expired':'task.expired'}[_0x382585[_0x4d8f09(0x258)]],..._0x382585};}function a0_0xf0ac(_0x313ce4,_0x329d07){_0x313ce4=_0x313ce4-0x1e2;const _0x1b6485=a0_0x1b64();let _0xf0acfc=_0x1b6485[_0x313ce4];return _0xf0acfc;}function j(_0x548429){const _0x597830=a0_0x29ff6e;let _0x1b1fc5=_0x548429?.[_0x597830(0x25a)]||_0x548429?.[_0x597830(0x251)]||_0x548429?.['id'];if(_0x1b1fc5)return String(_0x1b1fc5);let _0x4aabae=_0x548429?.[_0x597830(0x1f1)]?.[0x0]?.[_0x597830(0x1fe)];if(typeof _0x4aabae!=='string')return null;try{let _0x4bcc56=JSON[_0x597830(0x22b)](_0x4aabae);return _0x4bcc56?.[_0x597830(0x25a)]||_0x4bcc56?.['message_id']||_0x4bcc56?.['id']||null;}catch{return null;}}async function X(_0x1f3aef,_0x4c45ab){const _0x1ec834=a0_0x29ff6e;let _0x46a5dc=_0x4c45ab['now']??Date[_0x1ec834(0x24c)],_0x54f204=_0x46a5dc(),_0xc95b5e=(_0x24dcff,_0x2e3201,_0x12ad42,_0x28657a)=>{const _0x482902=_0x1ec834;_0x4c45ab[_0x482902(0x240)](O(U({'from_alias':_0x1f3aef['fromAlias'],'to_alias':_0x1f3aef[_0x482902(0x25b)],'task_id':_0x2e3201,'parent_task_id':_0x1f3aef['parentTaskId'],'network_id':_0x1f3aef[_0x482902(0x20c)],'transport':_0x1f3aef[_0x482902(0x221)],'status':_0x24dcff,'duration_ms':_0x46a5dc()-_0x54f204,'lifecycle_tracking':_0x1f3aef[_0x482902(0x225)],..._0x12ad42!==void 0x0?{'error_code':_0x28657a||_0x482902(0x200),'error_message':N(_0x12ad42)}:{}})));};_0xc95b5e(_0x1ec834(0x242),null);try{let _0x1f4ffc=await _0x4c45ab['send'](),_0x9063ff=j(_0x1f4ffc);if(_0x9063ff)_0xc95b5e(_0x1ec834(0x202),_0x9063ff);else{if(_0x1f4ffc?.['ok']===!0x1||_0x1f4ffc?.[_0x1ec834(0x229)])_0xc95b5e(_0x1ec834(0x224),_0x9063ff,_0x1f4ffc?.['error']||_0x1ec834(0x1ed),'send_rejected');else _0xc95b5e('failed',null,_0x1ec834(0x206),'missing_task_id');}return _0x1f4ffc;}catch(_0x8a6ded){throw _0xc95b5e('failed',null,_0x8a6ded,_0x1ec834(0x200)),_0x8a6ded;}}async function Y(_0x5144a3,_0x3616a2){const _0x653631=a0_0x29ff6e;return X({'fromAlias':_0x5144a3[_0x653631(0x1eb)],'toAlias':_0x5144a3[_0x653631(0x228)],'parentTaskId':_0x5144a3[_0x653631(0x1e9)]||null,'networkId':_0x5144a3[_0x653631(0x20c)]||null,'transport':'mcp_http','lifecycleTracking':_0x653631(0x1f7)},_0x3616a2);}class $ extends a0_0x56ddee{[a0_0x29ff6e(0x1f9)];[a0_0x29ff6e(0x228)];['token'];['agent'];['resumeId'];['heartbeatInterval'];[a0_0x29ff6e(0x23d)];[a0_0x29ff6e(0x20f)];[a0_0x29ff6e(0x252)];['running']=!0x1;constructor(_0x580e02){const _0x43c5dd=a0_0x29ff6e;super();if(this['url']=_0x580e02[_0x43c5dd(0x1f9)][_0x43c5dd(0x23a)](/\/$/,''),this[_0x43c5dd(0x228)]=_0x580e02[_0x43c5dd(0x228)],this['token']=_0x580e02[_0x43c5dd(0x1ef)],this[_0x43c5dd(0x22f)]=_0x580e02[_0x43c5dd(0x22f)]||'sdk',this[_0x43c5dd(0x1f4)]=_0x43c5dd(0x222)+_0x580e02[_0x43c5dd(0x228)]+'-'+Date[_0x43c5dd(0x24c)]()[_0x43c5dd(0x23f)](0x24),this[_0x43c5dd(0x1e8)]=_0x580e02[_0x43c5dd(0x1e8)]??0x2bf20,this[_0x43c5dd(0x23d)]=_0x580e02['reconnectDelay']??0xbb8,_0x580e02[_0x43c5dd(0x1e6)]!==!0x1)this['connect']();}[a0_0x29ff6e(0x240)](_0x556b59){const _0x341ffe=a0_0x29ff6e;console[_0x341ffe(0x240)]('['+new Date()[_0x341ffe(0x218)]()['slice'](0x0,0x8)+_0x341ffe(0x1fa)+this[_0x341ffe(0x228)]+']\x20'+_0x556b59);}async[a0_0x29ff6e(0x204)](_0x2a0139,_0x4ada90){const _0x3d8b66=a0_0x29ff6e;let _0x3ce317={'Content-Type':'application/json','Accept':_0x3d8b66(0x1f3)};if(this[_0x3d8b66(0x1ef)])_0x3ce317['Authorization']=_0x3d8b66(0x244)+this[_0x3d8b66(0x1ef)];let _0x3e8f17=await(await fetch(this[_0x3d8b66(0x1f9)]+'/mcp',{'method':'POST','headers':_0x3ce317,'body':JSON[_0x3d8b66(0x223)]({'jsonrpc':'2.0','id':Date[_0x3d8b66(0x24c)](),'method':_0x3d8b66(0x220),'params':{'name':_0x2a0139,'arguments':_0x4ada90}})}))[_0x3d8b66(0x1fe)](),_0x21bd24=_0x3e8f17[_0x3d8b66(0x1e3)](/data: (.+)/),_0x26a8d2=_0x21bd24?JSON[_0x3d8b66(0x22b)](_0x21bd24[0x1]):JSON[_0x3d8b66(0x22b)](_0x3e8f17),_0xcd63bd=_0x26a8d2?.[_0x3d8b66(0x205)]?.[_0x3d8b66(0x1f1)]?.[0x0]?.[_0x3d8b66(0x1fe)];return _0xcd63bd?JSON[_0x3d8b66(0x22b)](_0xcd63bd):_0x26a8d2;}async[a0_0x29ff6e(0x214)](){const _0x1b67e5=a0_0x29ff6e;if(this[_0x1b67e5(0x21e)])return;this['running']=!0x0,await this[_0x1b67e5(0x258)]('idle'),this[_0x1b67e5(0x240)]('registered'),this['heartbeatTimer']=setInterval(()=>{const _0x52c8b0=_0x1b67e5;this[_0x52c8b0(0x258)](_0x52c8b0(0x22e))[_0x52c8b0(0x22a)](_0x8adde9=>this['log'](_0x52c8b0(0x1fb)+_0x8adde9[_0x52c8b0(0x213)]));},this[_0x1b67e5(0x1e8)]),this[_0x1b67e5(0x23e)]();}async['disconnect'](){const _0x580ec8=a0_0x29ff6e;if(this['running']=!0x1,this[_0x580ec8(0x252)]?.[_0x580ec8(0x257)](),this[_0x580ec8(0x20f)])clearInterval(this[_0x580ec8(0x20f)]);await this[_0x580ec8(0x258)]('offline')[_0x580ec8(0x22a)](()=>{}),this[_0x580ec8(0x240)](_0x580ec8(0x1f8));}async[a0_0x29ff6e(0x253)](_0xd742b,_0x2d82ed,_0x238733=a0_0x29ff6e(0x1f0)){const _0x24a489=a0_0x29ff6e;return Y({'alias':_0xd742b,'fromAlias':this[_0x24a489(0x228)]},{'log':_0x18657c=>console[_0x24a489(0x240)](_0x18657c),'send':()=>this['call'](_0x24a489(0x245),{'alias':_0xd742b,'task':_0x2d82ed,'priority':_0x238733,'from_session':this[_0x24a489(0x228)]})});}async[a0_0x29ff6e(0x213)](_0x2ebf15,_0x173762){const _0x46ccc3=a0_0x29ff6e;return this[_0x46ccc3(0x204)]('send_message',{'alias':_0x2ebf15,'message':_0x173762,'from_session':this[_0x46ccc3(0x228)]});}async['reply'](_0x32810b,_0x1de703,_0x504d6b='completed'){const _0x44fc04=a0_0x29ff6e;return this[_0x44fc04(0x204)](_0x44fc04(0x254),{'in_reply_to':_0x32810b,'text':_0x1de703,'status':_0x504d6b});}async['status'](_0x139030,_0x5ed445){const _0x38d816=a0_0x29ff6e;return this[_0x38d816(0x204)]('report_status',{'resume_id':this[_0x38d816(0x1f4)],'alias':this[_0x38d816(0x228)],'status':_0x139030,'server':a0_0x12ebf3(),'hostname':a0_0x12ebf3(),'agent':this[_0x38d816(0x22f)],'project_dir':process[_0x38d816(0x20b)](),..._0x5ed445});}async[a0_0x29ff6e(0x238)](){const _0x5cad29=a0_0x29ff6e;return this[_0x5cad29(0x204)](_0x5cad29(0x21a),{});}async['broadcast'](_0x2c3e61,_0x3c2611){const _0x56b7d8=a0_0x29ff6e;return this['call'](_0x56b7d8(0x210),{'message':_0x2c3e61,'filter_server':_0x3c2611?.[_0x56b7d8(0x209)],'filter_status':_0x3c2611?.[_0x56b7d8(0x258)]});}async[a0_0x29ff6e(0x23e)](){const _0x2981ce=a0_0x29ff6e;let _0x53b0bd=encodeURIComponent(this[_0x2981ce(0x228)]),_0x4ae7fe=this[_0x2981ce(0x1f9)]+_0x2981ce(0x250)+_0x53b0bd,_0x2c8c00=this[_0x2981ce(0x23d)];while(this[_0x2981ce(0x21e)]){try{this['sseAbort']=new AbortController();let _0x5e2bc3={'Accept':'text/event-stream'};if(this[_0x2981ce(0x1ef)])_0x5e2bc3['Authorization']=_0x2981ce(0x244)+this[_0x2981ce(0x1ef)];let _0xd7f848=await fetch(_0x4ae7fe,{'headers':_0x5e2bc3,'signal':this[_0x2981ce(0x252)][_0x2981ce(0x259)]});if(!_0xd7f848['ok']||!_0xd7f848[_0x2981ce(0x201)]){this[_0x2981ce(0x240)](_0x2981ce(0x21c)+_0xd7f848[_0x2981ce(0x258)]),await this[_0x2981ce(0x21f)](_0x2c8c00),_0x2c8c00=Math[_0x2981ce(0x24d)](_0x2c8c00*1.5,0xea60);continue;}_0x2c8c00=this[_0x2981ce(0x23d)];let _0x2d3ebe=_0xd7f848[_0x2981ce(0x201)][_0x2981ce(0x1ec)](),_0x5ba44c=new TextDecoder(),_0x106900='';while(this[_0x2981ce(0x21e)]){let {done:_0x3043d5,value:_0x233193}=await _0x2d3ebe[_0x2981ce(0x232)]();if(_0x3043d5)break;_0x106900+=_0x5ba44c[_0x2981ce(0x208)](_0x233193,{'stream':!0x0});let _0x162ff5=_0x106900['split']('\x0a');_0x106900=_0x162ff5[_0x2981ce(0x1e7)]()||'';for(let _0x3e8c11 of _0x162ff5){if(!_0x3e8c11[_0x2981ce(0x217)](_0x2981ce(0x21d)))continue;try{let _0x48b776=JSON[_0x2981ce(0x22b)](_0x3e8c11[_0x2981ce(0x249)](0x6));if(_0x48b776['type']===_0x2981ce(0x1f5)){this[_0x2981ce(0x240)](_0x2981ce(0x1e2)),this[_0x2981ce(0x24b)](_0x2981ce(0x1f5));continue;}if(_0x48b776[_0x2981ce(0x20a)]===_0x2981ce(0x1fd)||_0x48b776[_0x2981ce(0x20a)]==='new_message'||_0x48b776[_0x2981ce(0x20a)]===_0x2981ce(0x210))await this[_0x2981ce(0x231)]();}catch{}}}}catch(_0x5b2b0e){if(_0x5b2b0e['name']===_0x2981ce(0x1ee))break;this['emit'](_0x2981ce(0x229),_0x5b2b0e),this[_0x2981ce(0x240)](_0x2981ce(0x1ff)+_0x5b2b0e[_0x2981ce(0x213)]);}if(this['running'])this['emit'](_0x2981ce(0x1f8)),this['log'](_0x2981ce(0x23b)+_0x2c8c00/0x3e8+_0x2981ce(0x211)),await this[_0x2981ce(0x21f)](_0x2c8c00),_0x2c8c00=Math['min'](_0x2c8c00*1.5,0xea60);}}async[a0_0x29ff6e(0x231)](){const _0x37acad=a0_0x29ff6e;try{let _0x343c65=(await this[_0x37acad(0x204)](_0x37acad(0x1e5),{'alias':this['alias'],'limit':0xa}))?.[_0x37acad(0x237)]||[];for(let _0x1997c2 of _0x343c65)await this[_0x37acad(0x204)](_0x37acad(0x212),{'alias':this[_0x37acad(0x228)],'message_id':_0x1997c2['id']}),this['log']('←\x20'+_0x1997c2[_0x37acad(0x21b)]+':\x20'+_0x1997c2[_0x37acad(0x1f1)][_0x37acad(0x249)](0x0,0x3c)),this[_0x37acad(0x24b)](_0x37acad(0x233),_0x1997c2),this[_0x37acad(0x24b)](_0x37acad(0x213),_0x1997c2);}catch(_0x2762fe){this[_0x37acad(0x240)]('inbox\x20error:\x20'+_0x2762fe[_0x37acad(0x213)]);}}['sleep'](_0x29cdbe){return new Promise(_0x5ebd59=>setTimeout(_0x5ebd59,_0x29cdbe));}}var F=$;export{F as default,$ as CommHub};function a0_0x1b64(){const _0xf03ce0=['3964020VfmYyo','idle','agent','task.ack','processInbox','read','task','3648304IZRBrd','unknown\x20error','149074iySyMg','messages','getAllStatus','error_code','replace','SSE\x20reconnecting\x20in\x20','task.send.start','reconnectDelay','connectSSE','toString','log','[commhub:task]\x20','sending','\x20network_id=','Bearer\x20','send_task','task.send.delivered','<unknown>','841906FjisOu','slice','\x20task_id=','emit','now','min','2681EpcIbV','100sZgCKd','/events/','message_id','sseAbort','send','send_reply','\x20parent_task_id=','task.replied','abort','status','signal','task_id','toAlias','SSE\x20connected','match','12JspBvY','get_inbox','autoConnect','pop','heartbeatInterval','parentTaskId','[REDACTED]','fromAlias','getReader','CommHub\x20rejected\x20task','AbortError','token','normal','content','task.send.failed','application/json,\x20text/event-stream','resumeId','connected','duration_ms','not_tracked','disconnected','url',']\x20[commhub:','heartbeat\x20failed:\x20','task.started','new_task','text','SSE\x20error:\x20','send_failed','body','delivered','parent_task_id','call','result','CommHub\x20response\x20omitted\x20task_id','lifecycle_tracking','decode','server','type','cwd','networkId','network_id','5mANVEH','heartbeatTimer','broadcast','s...','ack_inbox','message','connect','\x20from=','json','startsWith','toTimeString','525087BbfRQj','get_all_status','from_session','SSE\x20failed:\x20','data:\x20','running','sleep','tools/call','transport','sdk-','stringify','failed','lifecycleTracking','3200172tMiLTF','<missing>','alias','error','catch','parse','424hePDFL'];a0_0x1b64=function(){return _0xf03ce0;};return a0_0x1b64();}
1
+ const a0_0x24d820=a0_0xde79;(function(_0x22d4ac,_0x19e108){const _0x2d49fd=a0_0xde79,_0x20f920=_0x22d4ac();while(!![]){try{const _0x2381f1=parseInt(_0x2d49fd(0xc3))/0x1+-parseInt(_0x2d49fd(0xf5))/0x2*(parseInt(_0x2d49fd(0xb3))/0x3)+parseInt(_0x2d49fd(0xf4))/0x4*(parseInt(_0x2d49fd(0xcb))/0x5)+parseInt(_0x2d49fd(0xd5))/0x6*(parseInt(_0x2d49fd(0xfe))/0x7)+parseInt(_0x2d49fd(0xc4))/0x8*(parseInt(_0x2d49fd(0xb5))/0x9)+-parseInt(_0x2d49fd(0xb1))/0xa*(parseInt(_0x2d49fd(0xbc))/0xb)+-parseInt(_0x2d49fd(0xc6))/0xc*(parseInt(_0x2d49fd(0x103))/0xd);if(_0x2381f1===_0x19e108)break;else _0x20f920['push'](_0x20f920['shift']());}catch(_0x1d8439){_0x20f920['push'](_0x20f920['shift']());}}}(a0_0x5d2a,0x1b861));import{EventEmitter as a0_0x4b1961}from'events';import{hostname as a0_0x13a89f}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x42af4a,_0xc90d72)=>(_0x42af4a??_0xc90d72)[a0_0x24d820(0xd0)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x24d820(0xe1)](0x0,0xf0);function N(_0x4dc31b){const _0x2a0c04=a0_0x24d820;return(_0x4dc31b instanceof Error?_0x4dc31b[_0x2a0c04(0x96)]:String(_0x4dc31b??_0x2a0c04(0x8d)))['replace'](K,_0x2a0c04(0xc9))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x2a0c04(0xe1)](0x0,0xf0);}function O(_0x1818cd,_0x546da6=process.env.ANET_TASK_TRACE_FORMAT===a0_0x24d820(0x91)){const _0x5107a9=a0_0x24d820;if(_0x546da6)return JSON[_0x5107a9(0xdb)](_0x1818cd);let _0xba9f6=L(_0x1818cd['parent_task_id'],_0x5107a9(0xc0)),_0x42cb48=L(_0x1818cd[_0x5107a9(0xc2)],_0x5107a9(0xac)),_0x2e88c0=_0x1818cd[_0x5107a9(0xee)]?_0x5107a9(0xfb)+_0x1818cd['error_code']+':'+(_0x1818cd[_0x5107a9(0xe5)]??''):'';return _0x5107a9(0xf2)+_0x1818cd[_0x5107a9(0xb7)]+_0x5107a9(0xb8)+L(_0x1818cd[_0x5107a9(0x105)],_0x5107a9(0xd1))+_0x5107a9(0xd6)+L(_0x1818cd[_0x5107a9(0xf7)],_0x5107a9(0xd1))+_0x5107a9(0x102)+_0x42cb48+_0x5107a9(0x106)+_0xba9f6+_0x5107a9(0xe6)+L(_0x1818cd['network_id'],_0x5107a9(0xd1))+'\x20transport='+_0x1818cd[_0x5107a9(0x9e)]+'\x20duration_ms='+_0x1818cd[_0x5107a9(0xca)]+_0x5107a9(0xc1)+_0x1818cd[_0x5107a9(0xba)]+_0x2e88c0;}function U(_0x44870c){const _0x38fe5a=a0_0x24d820;return{'event':{'sending':_0x38fe5a(0xae),'delivered':_0x38fe5a(0x8b),'failed':_0x38fe5a(0xa1),'acked':_0x38fe5a(0x97),'started':'task.started','replied':_0x38fe5a(0x86),'expired':_0x38fe5a(0xe9)}[_0x44870c[_0x38fe5a(0xb7)]],..._0x44870c};}function j(_0x145700){const _0x56bf6a=a0_0x24d820;let _0x33b937=_0x145700?.[_0x56bf6a(0xc2)]||_0x145700?.['message_id']||_0x145700?.['id'];if(_0x33b937)return String(_0x33b937);let _0x5bf5f9=_0x145700?.[_0x56bf6a(0xf9)]?.[0x0]?.['text'];if(typeof _0x5bf5f9!==_0x56bf6a(0xbd))return null;try{let _0x515a5e=JSON['parse'](_0x5bf5f9);return _0x515a5e?.['task_id']||_0x515a5e?.['message_id']||_0x515a5e?.['id']||null;}catch{return null;}}async function X(_0x2397c3,_0x1642bf){const _0x19231a=a0_0x24d820;let _0xb28d42=_0x1642bf[_0x19231a(0xbe)]??Date[_0x19231a(0xbe)],_0x34b3d9=_0xb28d42(),_0x57fb54=(_0x5cdacc,_0x7dfeec,_0x53bee0,_0x3d6138)=>{const _0x3ba921=_0x19231a;_0x1642bf[_0x3ba921(0xf6)](O(U({'from_alias':_0x2397c3['fromAlias'],'to_alias':_0x2397c3['toAlias'],'task_id':_0x7dfeec,'parent_task_id':_0x2397c3['parentTaskId'],'network_id':_0x2397c3[_0x3ba921(0x88)],'transport':_0x2397c3[_0x3ba921(0x9e)],'status':_0x5cdacc,'duration_ms':_0xb28d42()-_0x34b3d9,'lifecycle_tracking':_0x2397c3[_0x3ba921(0xda)],..._0x53bee0!==void 0x0?{'error_code':_0x3d6138||_0x3ba921(0xbb),'error_message':N(_0x53bee0)}:{}})));};_0x57fb54('sending',null);try{let _0x428271=await _0x1642bf[_0x19231a(0xa7)](),_0x442f93=j(_0x428271);if(_0x442f93)_0x57fb54(_0x19231a(0xd7),_0x442f93);else{if(_0x428271?.['ok']===!0x1||_0x428271?.['error'])_0x57fb54('failed',_0x442f93,_0x428271?.[_0x19231a(0x87)]||'CommHub\x20rejected\x20task',_0x19231a(0xd8));else _0x57fb54(_0x19231a(0xe3),null,_0x19231a(0xb9),_0x19231a(0xb6));}return _0x428271;}catch(_0x108dd4){throw _0x57fb54(_0x19231a(0xe3),null,_0x108dd4,_0x19231a(0xbb)),_0x108dd4;}}function a0_0x5d2a(){const _0x11c21e=['1039514pKwtiV','sdk-','send_reply','ack_inbox','\x20task_id=','99437DPHuDz','from_session','from_alias','\x20parent_task_id=','SSE\x20reconnecting\x20in\x20','mcp_http','agent','task','task.replied','error','networkId','new_task','min','task.send.delivered','type','unknown\x20error','inbox\x20error:\x20','heartbeatTimer','Bearer\x20','json','connected','offline','getAllStatus','s...','message','task.ack','catch','sseAbort','call','read','sdk','/events/','transport','cwd','new_message','task.send.failed','Authorization','connect','parse','text/event-stream','idle','send','report_status','split','token','POST','<pending>','data:\x20','task.send.start','reply','alias','10UNBcLu','parentTaskId','30039xfKJfv','get_inbox','18iKILsp','missing_task_id','status','\x20from=','CommHub\x20response\x20omitted\x20task_id','lifecycle_tracking','send_failed','1173865eihPKw','string','now','registered','<missing>','\x20lifecycle=','task_id','168318cxvJlX','242992QafOOT','getReader','516yQXsRy','disconnected','SSE\x20connected','[REDACTED]','duration_ms','29060UnFCuw','connectSSE','broadcast','autoConnect','url','replace','<unknown>','emit','resumeId','sleep','6KRsfTg','\x20to=','delivered','send_rejected','reconnectDelay','lifecycleTracking','stringify','processInbox','SSE\x20failed:\x20','running','result','send_task','slice','/mcp','failed','heartbeatInterval','error_message','\x20network_id=','pop','SSE\x20error:\x20','task.expired','server','toTimeString','application/json',']\x20[commhub:','error_code','name','application/json,\x20text/event-stream','tools/call','[commhub:task]\x20','fromAlias','152UXykAU','10IFvIek','log','to_alias','completed','content','heartbeat\x20failed:\x20','\x20error=','text','get_all_status'];a0_0x5d2a=function(){return _0x11c21e;};return a0_0x5d2a();}function a0_0xde79(_0x5c7a3d,_0x130670){_0x5c7a3d=_0x5c7a3d-0x83;const _0x5d2ad9=a0_0x5d2a();let _0xde797b=_0x5d2ad9[_0x5c7a3d];return _0xde797b;}async function Y(_0x4ea0ff,_0xd4a833){const _0x116bdb=a0_0x24d820;return X({'fromAlias':_0x4ea0ff[_0x116bdb(0xf3)],'toAlias':_0x4ea0ff[_0x116bdb(0xb0)],'parentTaskId':_0x4ea0ff[_0x116bdb(0xb2)]||null,'networkId':_0x4ea0ff['networkId']||null,'transport':_0x116bdb(0x83),'lifecycleTracking':'not_tracked'},_0xd4a833);}class $ extends a0_0x4b1961{[a0_0x24d820(0xcf)];[a0_0x24d820(0xb0)];[a0_0x24d820(0xaa)];[a0_0x24d820(0x84)];[a0_0x24d820(0xd3)];['heartbeatInterval'];['reconnectDelay'];['heartbeatTimer'];[a0_0x24d820(0x99)];[a0_0x24d820(0xde)]=!0x1;constructor(_0x3fa90f){const _0x2b16c5=a0_0x24d820;super();if(this[_0x2b16c5(0xcf)]=_0x3fa90f['url']['replace'](/\/$/,''),this['alias']=_0x3fa90f['alias'],this['token']=_0x3fa90f[_0x2b16c5(0xaa)],this[_0x2b16c5(0x84)]=_0x3fa90f[_0x2b16c5(0x84)]||_0x2b16c5(0x9c),this['resumeId']=_0x2b16c5(0xff)+_0x3fa90f[_0x2b16c5(0xb0)]+'-'+Date[_0x2b16c5(0xbe)]()['toString'](0x24),this[_0x2b16c5(0xe4)]=_0x3fa90f[_0x2b16c5(0xe4)]??0x2bf20,this[_0x2b16c5(0xd9)]=_0x3fa90f[_0x2b16c5(0xd9)]??0xbb8,_0x3fa90f[_0x2b16c5(0xce)]!==!0x1)this[_0x2b16c5(0xa3)]();}[a0_0x24d820(0xf6)](_0x4c0b9a){const _0x2c2fef=a0_0x24d820;console[_0x2c2fef(0xf6)]('['+new Date()[_0x2c2fef(0xeb)]()[_0x2c2fef(0xe1)](0x0,0x8)+_0x2c2fef(0xed)+this[_0x2c2fef(0xb0)]+']\x20'+_0x4c0b9a);}async[a0_0x24d820(0x9a)](_0x14ddb7,_0x1f7e13){const _0x106f8a=a0_0x24d820;let _0xf3e594={'Content-Type':_0x106f8a(0xec),'Accept':_0x106f8a(0xf0)};if(this[_0x106f8a(0xaa)])_0xf3e594[_0x106f8a(0xa2)]='Bearer\x20'+this[_0x106f8a(0xaa)];let _0x38478e=await(await fetch(this['url']+_0x106f8a(0xe2),{'method':_0x106f8a(0xab),'headers':_0xf3e594,'body':JSON[_0x106f8a(0xdb)]({'jsonrpc':'2.0','id':Date['now'](),'method':_0x106f8a(0xf1),'params':{'name':_0x14ddb7,'arguments':_0x1f7e13}})}))[_0x106f8a(0xfc)](),_0x4ebdf2=_0x38478e['match'](/data: (.+)/),_0x1ab523=_0x4ebdf2?JSON[_0x106f8a(0xa4)](_0x4ebdf2[0x1]):JSON[_0x106f8a(0xa4)](_0x38478e),_0x328657=_0x1ab523?.[_0x106f8a(0xdf)]?.[_0x106f8a(0xf9)]?.[0x0]?.['text'];return _0x328657?JSON[_0x106f8a(0xa4)](_0x328657):_0x1ab523;}async[a0_0x24d820(0xa3)](){const _0x1918dc=a0_0x24d820;if(this[_0x1918dc(0xde)])return;this[_0x1918dc(0xde)]=!0x0,await this[_0x1918dc(0xb7)](_0x1918dc(0xa6)),this[_0x1918dc(0xf6)](_0x1918dc(0xbf)),this[_0x1918dc(0x8f)]=setInterval(()=>{const _0x4c9292=_0x1918dc;this[_0x4c9292(0xb7)]('idle')[_0x4c9292(0x98)](_0x495a43=>this[_0x4c9292(0xf6)](_0x4c9292(0xfa)+_0x495a43[_0x4c9292(0x96)]));},this[_0x1918dc(0xe4)]),this[_0x1918dc(0xcc)]();}async['disconnect'](){const _0xe181b6=a0_0x24d820;if(this['running']=!0x1,this[_0xe181b6(0x99)]?.['abort'](),this['heartbeatTimer'])clearInterval(this['heartbeatTimer']);await this[_0xe181b6(0xb7)](_0xe181b6(0x93))[_0xe181b6(0x98)](()=>{}),this[_0xe181b6(0xf6)](_0xe181b6(0xc7));}async[a0_0x24d820(0xa7)](_0x1ba2e7,_0x1eafec,_0x4a0d81='normal'){const _0x46ee3f=a0_0x24d820;return Y({'alias':_0x1ba2e7,'fromAlias':this[_0x46ee3f(0xb0)]},{'log':_0x5b72bd=>console[_0x46ee3f(0xf6)](_0x5b72bd),'send':()=>this[_0x46ee3f(0x9a)](_0x46ee3f(0xe0),{'alias':_0x1ba2e7,'task':_0x1eafec,'priority':_0x4a0d81,'from_session':this[_0x46ee3f(0xb0)]})});}async[a0_0x24d820(0x96)](_0x3ec574,_0x249b6e){const _0x3a539c=a0_0x24d820;return this[_0x3a539c(0x9a)]('send_message',{'alias':_0x3ec574,'message':_0x249b6e,'from_session':this[_0x3a539c(0xb0)]});}async[a0_0x24d820(0xaf)](_0x50e661,_0x4e024d,_0x149834=a0_0x24d820(0xf8)){const _0x32ade5=a0_0x24d820;return this[_0x32ade5(0x9a)](_0x32ade5(0x100),{'in_reply_to':_0x50e661,'text':_0x4e024d,'status':_0x149834});}async[a0_0x24d820(0xb7)](_0x6f9dc7,_0x435a7d){const _0x2397d6=a0_0x24d820;return this[_0x2397d6(0x9a)](_0x2397d6(0xa8),{'resume_id':this[_0x2397d6(0xd3)],'alias':this[_0x2397d6(0xb0)],'status':_0x6f9dc7,'server':a0_0x13a89f(),'hostname':a0_0x13a89f(),'agent':this[_0x2397d6(0x84)],'project_dir':process[_0x2397d6(0x9f)](),..._0x435a7d});}async[a0_0x24d820(0x94)](){const _0x2f384c=a0_0x24d820;return this[_0x2f384c(0x9a)](_0x2f384c(0xfd),{});}async[a0_0x24d820(0xcd)](_0x1654d5,_0x306437){const _0x29bbd4=a0_0x24d820;return this['call'](_0x29bbd4(0xcd),{'message':_0x1654d5,'filter_server':_0x306437?.[_0x29bbd4(0xea)],'filter_status':_0x306437?.['status']});}async[a0_0x24d820(0xcc)](){const _0x4b3ea4=a0_0x24d820;let _0x3608d8=encodeURIComponent(this['alias']),_0x4ec39d=this[_0x4b3ea4(0xcf)]+_0x4b3ea4(0x9d)+_0x3608d8,_0x31baa6=this['reconnectDelay'];while(this[_0x4b3ea4(0xde)]){try{this[_0x4b3ea4(0x99)]=new AbortController();let _0x50e350={'Accept':_0x4b3ea4(0xa5)};if(this[_0x4b3ea4(0xaa)])_0x50e350[_0x4b3ea4(0xa2)]=_0x4b3ea4(0x90)+this['token'];let _0xe4950=await fetch(_0x4ec39d,{'headers':_0x50e350,'signal':this[_0x4b3ea4(0x99)]['signal']});if(!_0xe4950['ok']||!_0xe4950['body']){this['log'](_0x4b3ea4(0xdd)+_0xe4950[_0x4b3ea4(0xb7)]),await this[_0x4b3ea4(0xd4)](_0x31baa6),_0x31baa6=Math[_0x4b3ea4(0x8a)](_0x31baa6*1.5,0xea60);continue;}_0x31baa6=this['reconnectDelay'];let _0x153f88=_0xe4950['body'][_0x4b3ea4(0xc5)](),_0x177be6=new TextDecoder(),_0xa32c91='';while(this[_0x4b3ea4(0xde)]){let {done:_0x18cb2f,value:_0xa589c9}=await _0x153f88[_0x4b3ea4(0x9b)]();if(_0x18cb2f)break;_0xa32c91+=_0x177be6['decode'](_0xa589c9,{'stream':!0x0});let _0xf2992f=_0xa32c91[_0x4b3ea4(0xa9)]('\x0a');_0xa32c91=_0xf2992f[_0x4b3ea4(0xe7)]()||'';for(let _0x1637f8 of _0xf2992f){if(!_0x1637f8['startsWith'](_0x4b3ea4(0xad)))continue;try{let _0x40ff8d=JSON[_0x4b3ea4(0xa4)](_0x1637f8[_0x4b3ea4(0xe1)](0x6));if(_0x40ff8d['type']===_0x4b3ea4(0x92)){this[_0x4b3ea4(0xf6)](_0x4b3ea4(0xc8)),this[_0x4b3ea4(0xd2)](_0x4b3ea4(0x92));continue;}if(_0x40ff8d[_0x4b3ea4(0x8c)]===_0x4b3ea4(0x89)||_0x40ff8d[_0x4b3ea4(0x8c)]===_0x4b3ea4(0xa0)||_0x40ff8d[_0x4b3ea4(0x8c)]===_0x4b3ea4(0xcd))await this[_0x4b3ea4(0xdc)]();}catch{}}}}catch(_0x356054){if(_0x356054[_0x4b3ea4(0xef)]==='AbortError')break;this[_0x4b3ea4(0xd2)](_0x4b3ea4(0x87),_0x356054),this['log'](_0x4b3ea4(0xe8)+_0x356054[_0x4b3ea4(0x96)]);}if(this['running'])this[_0x4b3ea4(0xd2)](_0x4b3ea4(0xc7)),this['log'](_0x4b3ea4(0x107)+_0x31baa6/0x3e8+_0x4b3ea4(0x95)),await this[_0x4b3ea4(0xd4)](_0x31baa6),_0x31baa6=Math[_0x4b3ea4(0x8a)](_0x31baa6*1.5,0xea60);}}async[a0_0x24d820(0xdc)](){const _0x5f4a5e=a0_0x24d820;try{let _0x594e26=(await this['call'](_0x5f4a5e(0xb4),{'alias':this[_0x5f4a5e(0xb0)],'limit':0xa}))?.['messages']||[];for(let _0x5ec3fb of _0x594e26)await this[_0x5f4a5e(0x9a)](_0x5f4a5e(0x101),{'alias':this[_0x5f4a5e(0xb0)],'message_id':_0x5ec3fb['id']}),this['log']('←\x20'+_0x5ec3fb[_0x5f4a5e(0x104)]+':\x20'+_0x5ec3fb['content'][_0x5f4a5e(0xe1)](0x0,0x3c)),this['emit'](_0x5f4a5e(0x85),_0x5ec3fb),this[_0x5f4a5e(0xd2)](_0x5f4a5e(0x96),_0x5ec3fb);}catch(_0x523ef7){this['log'](_0x5f4a5e(0x8e)+_0x523ef7[_0x5f4a5e(0x96)]);}}['sleep'](_0x1e6006){return new Promise(_0x349a95=>setTimeout(_0x349a95,_0x1e6006));}}var F=$;export{F as default,$ as CommHub};
@@ -0,0 +1,23 @@
1
+ /** The node's pinned binary from config.json, or undefined when not set. */
2
+ export declare function configuredCodexBin(profile: {
3
+ codexBin?: unknown;
4
+ } | null | undefined): string | undefined;
5
+ /** The node's pinned version from config.json, or undefined when not set. */
6
+ export declare function configuredCodexVersion(profile: {
7
+ codexVersion?: unknown;
8
+ } | null | undefined): string | undefined;
9
+ /** Order: --codex-bin (one-off) > config.json codexBin > bare "codex" (main's default). */
10
+ export declare function resolveCopresenceCodexBin(flag: string | undefined, profile: {
11
+ codexBin?: unknown;
12
+ } | null | undefined): string;
13
+ /**
14
+ * Null = the binary reports the pinned version. Otherwise the lines to print before
15
+ * refusing to start. An unreadable version is a refusal too: a pin that cannot be
16
+ * checked is not honoured silently.
17
+ */
18
+ export declare function codexVersionPinMismatch(input: {
19
+ expected: string;
20
+ actual: string | null;
21
+ codexBin: string;
22
+ displayName: string;
23
+ }): string[] | null;
@@ -26,8 +26,21 @@ export interface CodexHomeStageStep {
26
26
  * token than the one we hold.
27
27
  */
28
28
  export declare function codexHomeStagePlan(hostHome: string, nodeHome: string, stat: StatFn, join: (a: string, b: string) => string, files?: readonly CodexHomeInheritedFile[]): CodexHomeStageStep[];
29
- export type CodexTuiBlocker = "sign-in" | "update-prompt" | "trust-prompt";
29
+ export type CodexTuiBlocker = "sign-in" | "update-prompt" | "trust-prompt" | "input-not-ready";
30
30
  export type CodexTuiPaneState = CodexTuiBlocker | "not-painted" | "usable";
31
+ export interface CodexKnownStartupPromptAction {
32
+ readonly kind: "keep-existing-model";
33
+ readonly key: "2";
34
+ }
35
+ /**
36
+ * Return the one startup action whose exact current-screen contract we know.
37
+ *
38
+ * Codex's model-migration picker defaults to "Try new model" and both Enter
39
+ * and Escape confirm that highlighted choice. Sending a generic confirmation
40
+ * would therefore silently change the node's configured model. The explicit
41
+ * `2` choice preserves the current model and acknowledges this exact notice.
42
+ */
43
+ export declare function codexKnownStartupPromptAction(onScreen: string): CodexKnownStartupPromptAction | null;
31
44
  /**
32
45
  * Classify the TUI, from two different reads of the same pane.
33
46
  *
@@ -0,0 +1,39 @@
1
+ export interface RecoveryLease {
2
+ release: () => void;
3
+ }
4
+ export interface RecoveryLeaseHolderDeps {
5
+ /** Register `fn` to run when the process exits; returns an unregister function.
6
+ * Defaults to process.on("exit"), which also covers `process.exit(1)` failure paths. */
7
+ onProcessExit?: (fn: () => void) => () => void;
8
+ log?: (message: string) => void;
9
+ }
10
+ export interface RecoveryLeaseHolder {
11
+ /** Take ownership of a lease returned by waitForCodexRecoveryResources. */
12
+ hold(lease: RecoveryLease): void;
13
+ /** Release the held lease (stops its heartbeat and drops the slot). Idempotent. */
14
+ release(reason?: string): void;
15
+ readonly held: boolean;
16
+ }
17
+ export declare function createRecoveryLeaseHolder(deps?: RecoveryLeaseHolderDeps): RecoveryLeaseHolder;
18
+ export interface CopresencePieces {
19
+ /** `--tui-first`: restore the exact-session TUI before the bridge attaches. */
20
+ tuiFirst: boolean;
21
+ /** Piece ②: starts the bridge and resolves once it reported READY. */
22
+ launchBridge: () => Promise<void>;
23
+ /** Piece ③: starts the TUI session ("③ TUI … ready to attach"). */
24
+ launchTui: () => void;
25
+ /** Resolves once the TUI has painted a usable screen. */
26
+ requireTuiPainted: () => Promise<void>;
27
+ /** The TUI's own process tree must connect to the exact app-server; paint alone
28
+ * can precede WebSocket hydration and does not release the recovery lane. */
29
+ requireTuiConnected: () => Promise<void>;
30
+ /** Runs once both sessions were launched (marker refresh, liveness check). */
31
+ afterLaunch?: () => void;
32
+ /** Printed between the TUI paint and the bridge attach on the --tui-first path. */
33
+ announceTuiFirst?: () => void;
34
+ lease: RecoveryLeaseHolder;
35
+ }
36
+ /** Bring up the bridge and the TUI in the configured order, then release the
37
+ * recovery lease: the legacy resume (bridge) and the TUI hydration are the
38
+ * memory-heavy part the lane protects. The lease is released on failure too. */
39
+ export declare function launchCopresencePiecesReleasingRecovery(p: CopresencePieces): Promise<void>;