@sleep2agi/agent-network 2.3.0-preview.136 → 2.3.0-preview.138

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_0x588652=a0_0x3893;(function(_0x335b9d,_0x3b459c){const _0x59bd2e=a0_0x3893,_0x1b6790=_0x335b9d();while(!![]){try{const _0x552dc0=-parseInt(_0x59bd2e(0x180))/0x1*(parseInt(_0x59bd2e(0x189))/0x2)+-parseInt(_0x59bd2e(0x130))/0x3*(parseInt(_0x59bd2e(0x183))/0x4)+parseInt(_0x59bd2e(0x13e))/0x5+-parseInt(_0x59bd2e(0x1a4))/0x6*(parseInt(_0x59bd2e(0x153))/0x7)+-parseInt(_0x59bd2e(0x167))/0x8+-parseInt(_0x59bd2e(0x18d))/0x9+parseInt(_0x59bd2e(0x158))/0xa*(parseInt(_0x59bd2e(0x19b))/0xb);if(_0x552dc0===_0x3b459c)break;else _0x1b6790['push'](_0x1b6790['shift']());}catch(_0xa70f7e){_0x1b6790['push'](_0x1b6790['shift']());}}}(a0_0x8bf1,0x1b07b));import{EventEmitter as a0_0xae20f9}from'events';import{hostname as a0_0x39491e}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x468da7,_0x390ec0)=>(_0x468da7??_0x390ec0)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x5c45af){const _0x5b37cb=a0_0x3893;return(_0x5c45af instanceof Error?_0x5c45af[_0x5b37cb(0x17b)]:String(_0x5c45af??'unknown\x20error'))[_0x5b37cb(0x13f)](K,_0x5b37cb(0x137))[_0x5b37cb(0x13f)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x5b37cb(0x19c)](0x0,0xf0);}function O(_0x4ae211,_0x4efe93=process.env.ANET_TASK_TRACE_FORMAT===a0_0x588652(0x160)){const _0x5a1a53=a0_0x588652;if(_0x4efe93)return JSON[_0x5a1a53(0x18b)](_0x4ae211);let _0x4c9a3c=L(_0x4ae211[_0x5a1a53(0x198)],'<missing>'),_0x4d15fe=L(_0x4ae211[_0x5a1a53(0x15a)],_0x5a1a53(0x187)),_0x11c9af=_0x4ae211[_0x5a1a53(0x18a)]?'\x20error='+_0x4ae211[_0x5a1a53(0x18a)]+':'+(_0x4ae211[_0x5a1a53(0x161)]??''):'';return'[commhub:task]\x20'+_0x4ae211['status']+_0x5a1a53(0x184)+L(_0x4ae211[_0x5a1a53(0x1a3)],_0x5a1a53(0x1a9))+_0x5a1a53(0x14c)+L(_0x4ae211['to_alias'],_0x5a1a53(0x1a9))+_0x5a1a53(0x182)+_0x4d15fe+_0x5a1a53(0x170)+_0x4c9a3c+_0x5a1a53(0x178)+L(_0x4ae211[_0x5a1a53(0x17e)],'<unknown>')+_0x5a1a53(0x1a2)+_0x4ae211[_0x5a1a53(0x193)]+_0x5a1a53(0x16e)+_0x4ae211[_0x5a1a53(0x140)]+_0x5a1a53(0x148)+_0x4ae211[_0x5a1a53(0x175)]+_0x11c9af;}function U(_0x2aba09){const _0x941881=a0_0x588652;return{'event':{'sending':_0x941881(0x176),'delivered':'task.send.delivered','failed':_0x941881(0x1ab),'acked':'task.ack','started':'task.started','replied':_0x941881(0x13c),'expired':'task.expired'}[_0x2aba09['status']],..._0x2aba09};}function j(_0x57bad7){const _0x33aa6c=a0_0x588652;let _0x1ddb50=_0x57bad7?.[_0x33aa6c(0x15a)]||_0x57bad7?.['message_id']||_0x57bad7?.['id'];if(_0x1ddb50)return String(_0x1ddb50);let _0x52094b=_0x57bad7?.['content']?.[0x0]?.['text'];if(typeof _0x52094b!=='string')return null;try{let _0x341b99=JSON['parse'](_0x52094b);return _0x341b99?.[_0x33aa6c(0x15a)]||_0x341b99?.[_0x33aa6c(0x19e)]||_0x341b99?.['id']||null;}catch{return null;}}async function X(_0x5d0651,_0x26e5ea){const _0x5c06c3=a0_0x588652;let _0x50bafe=_0x26e5ea['now']??Date[_0x5c06c3(0x136)],_0x1721dc=_0x50bafe(),_0x3e5f13=(_0x27e5c0,_0x2ab724,_0x43c501,_0xf7d515)=>{const _0x54f081=_0x5c06c3;_0x26e5ea[_0x54f081(0x151)](O(U({'from_alias':_0x5d0651[_0x54f081(0x1ac)],'to_alias':_0x5d0651[_0x54f081(0x1a8)],'task_id':_0x2ab724,'parent_task_id':_0x5d0651[_0x54f081(0x145)],'network_id':_0x5d0651[_0x54f081(0x13d)],'transport':_0x5d0651[_0x54f081(0x193)],'status':_0x27e5c0,'duration_ms':_0x50bafe()-_0x1721dc,'lifecycle_tracking':_0x5d0651[_0x54f081(0x177)],..._0x43c501!==void 0x0?{'error_code':_0xf7d515||_0x54f081(0x1a1),'error_message':N(_0x43c501)}:{}})));};_0x3e5f13(_0x5c06c3(0x16d),null);try{let _0x217033=await _0x26e5ea[_0x5c06c3(0x154)](),_0x830bf9=j(_0x217033);if(_0x830bf9)_0x3e5f13('delivered',_0x830bf9);else{if(_0x217033?.['ok']===!0x1||_0x217033?.[_0x5c06c3(0x16c)])_0x3e5f13(_0x5c06c3(0x14f),_0x830bf9,_0x217033?.[_0x5c06c3(0x16c)]||'CommHub\x20rejected\x20task',_0x5c06c3(0x199));else _0x3e5f13('failed',null,_0x5c06c3(0x173),_0x5c06c3(0x16b));}return _0x217033;}catch(_0x47ee20){throw _0x3e5f13('failed',null,_0x47ee20,_0x5c06c3(0x1a1)),_0x47ee20;}}function a0_0x8bf1(){const _0x439c2a=['heartbeatTimer','task_id','alias','new_message','url','completed','send_message','json','error_message','mcp_http','body','not_tracked','application/json,\x20text/event-stream','pop','559008KKxoEt','read','from_session','heartbeat\x20failed:\x20','missing_task_id','error','sending','\x20duration_ms=','ack_inbox','\x20parent_task_id=','application/json','catch','CommHub\x20response\x20omitted\x20task_id','token','lifecycle_tracking','task.send.start','lifecycleTracking','\x20network_id=','get_inbox','reconnectDelay','message','Authorization','s...','network_id','heartbeatInterval','16PMeSsC','/mcp','\x20task_id=','11672ADfbuO','\x20from=','abort','parse','<pending>','disconnected','21874QjJhTK','error_code','stringify','min','713367sFCHcT','get_all_status','inbox\x20error:\x20','broadcast','status','text','transport','emit',']\x20[commhub:','content','connectSSE','parent_task_id','send_rejected','processInbox','6995219EBmEXX','slice','signal','message_id','SSE\x20failed:\x20','send_reply','send_failed','\x20transport=','from_alias','1150698sbBltr','autoConnect','sseAbort','SSE\x20connected','toAlias','<unknown>','resumeId','task.send.failed','fromAlias','reply','159apDdKA','agent','connected','server','offline','sleep','now','[REDACTED]','report_status','getReader','new_task','AbortError','task.replied','networkId','726770qfHkwb','replace','duration_ms','registered','sdk','messages','idle','parentTaskId','connect','result','\x20lifecycle=','running','call','startsWith','\x20to=','text/event-stream','Bearer\x20','failed','cwd','log','toTimeString','7SKKDaI','send','type','tools/call','split','10cgIYkr'];a0_0x8bf1=function(){return _0x439c2a;};return a0_0x8bf1();}async function Y(_0x2a59c5,_0x1e2c72){const _0x1428d7=a0_0x588652;return X({'fromAlias':_0x2a59c5['fromAlias'],'toAlias':_0x2a59c5[_0x1428d7(0x15b)],'parentTaskId':_0x2a59c5['parentTaskId']||null,'networkId':_0x2a59c5[_0x1428d7(0x13d)]||null,'transport':_0x1428d7(0x162),'lifecycleTracking':_0x1428d7(0x164)},_0x1e2c72);}function a0_0x3893(_0x3589ba,_0x3d30ac){_0x3589ba=_0x3589ba-0x12f;const _0x8bf18d=a0_0x8bf1();let _0x389353=_0x8bf18d[_0x3589ba];return _0x389353;}class $ extends a0_0xae20f9{[a0_0x588652(0x15d)];[a0_0x588652(0x15b)];[a0_0x588652(0x174)];[a0_0x588652(0x131)];[a0_0x588652(0x1aa)];[a0_0x588652(0x17f)];[a0_0x588652(0x17a)];[a0_0x588652(0x159)];['sseAbort'];[a0_0x588652(0x149)]=!0x1;constructor(_0x4836dd){const _0x5c7e43=a0_0x588652;super();if(this[_0x5c7e43(0x15d)]=_0x4836dd[_0x5c7e43(0x15d)][_0x5c7e43(0x13f)](/\/$/,''),this['alias']=_0x4836dd[_0x5c7e43(0x15b)],this[_0x5c7e43(0x174)]=_0x4836dd['token'],this[_0x5c7e43(0x131)]=_0x4836dd[_0x5c7e43(0x131)]||_0x5c7e43(0x142),this[_0x5c7e43(0x1aa)]='sdk-'+_0x4836dd[_0x5c7e43(0x15b)]+'-'+Date[_0x5c7e43(0x136)]()['toString'](0x24),this['heartbeatInterval']=_0x4836dd[_0x5c7e43(0x17f)]??0x2bf20,this[_0x5c7e43(0x17a)]=_0x4836dd[_0x5c7e43(0x17a)]??0xbb8,_0x4836dd[_0x5c7e43(0x1a5)]!==!0x1)this[_0x5c7e43(0x146)]();}[a0_0x588652(0x151)](_0x2900d7){const _0x20a1f9=a0_0x588652;console[_0x20a1f9(0x151)]('['+new Date()[_0x20a1f9(0x152)]()[_0x20a1f9(0x19c)](0x0,0x8)+_0x20a1f9(0x195)+this[_0x20a1f9(0x15b)]+']\x20'+_0x2900d7);}async[a0_0x588652(0x14a)](_0x324148,_0x209b82){const _0x581937=a0_0x588652;let _0x9368e1={'Content-Type':_0x581937(0x171),'Accept':_0x581937(0x165)};if(this['token'])_0x9368e1['Authorization']=_0x581937(0x14e)+this[_0x581937(0x174)];let _0x3a8015=await(await fetch(this[_0x581937(0x15d)]+_0x581937(0x181),{'method':'POST','headers':_0x9368e1,'body':JSON[_0x581937(0x18b)]({'jsonrpc':'2.0','id':Date[_0x581937(0x136)](),'method':_0x581937(0x156),'params':{'name':_0x324148,'arguments':_0x209b82}})}))['text'](),_0x4a1ef6=_0x3a8015['match'](/data: (.+)/),_0x25939f=_0x4a1ef6?JSON[_0x581937(0x186)](_0x4a1ef6[0x1]):JSON[_0x581937(0x186)](_0x3a8015),_0x436a50=_0x25939f?.[_0x581937(0x147)]?.[_0x581937(0x196)]?.[0x0]?.[_0x581937(0x192)];return _0x436a50?JSON['parse'](_0x436a50):_0x25939f;}async[a0_0x588652(0x146)](){const _0x2d1c21=a0_0x588652;if(this[_0x2d1c21(0x149)])return;this['running']=!0x0,await this['status'](_0x2d1c21(0x144)),this[_0x2d1c21(0x151)](_0x2d1c21(0x141)),this[_0x2d1c21(0x159)]=setInterval(()=>{const _0x433050=_0x2d1c21;this[_0x433050(0x191)](_0x433050(0x144))[_0x433050(0x172)](_0x4cc63b=>this[_0x433050(0x151)](_0x433050(0x16a)+_0x4cc63b[_0x433050(0x17b)]));},this[_0x2d1c21(0x17f)]),this[_0x2d1c21(0x197)]();}async['disconnect'](){const _0xa94866=a0_0x588652;if(this[_0xa94866(0x149)]=!0x1,this[_0xa94866(0x1a6)]?.[_0xa94866(0x185)](),this['heartbeatTimer'])clearInterval(this['heartbeatTimer']);await this['status'](_0xa94866(0x134))[_0xa94866(0x172)](()=>{}),this[_0xa94866(0x151)](_0xa94866(0x188));}async[a0_0x588652(0x154)](_0x22e3ce,_0x2f5982,_0x8a8150='normal'){const _0x61ff2b=a0_0x588652;return Y({'alias':_0x22e3ce,'fromAlias':this['alias']},{'log':_0x141392=>console['log'](_0x141392),'send':()=>this[_0x61ff2b(0x14a)]('send_task',{'alias':_0x22e3ce,'task':_0x2f5982,'priority':_0x8a8150,'from_session':this[_0x61ff2b(0x15b)]})});}async[a0_0x588652(0x17b)](_0x5c0ec0,_0xb8e9e9){const _0x43c270=a0_0x588652;return this['call'](_0x43c270(0x15f),{'alias':_0x5c0ec0,'message':_0xb8e9e9,'from_session':this[_0x43c270(0x15b)]});}async[a0_0x588652(0x12f)](_0x54b49c,_0x366ac2,_0x5963bc=a0_0x588652(0x15e)){const _0x1bbb61=a0_0x588652;return this[_0x1bbb61(0x14a)](_0x1bbb61(0x1a0),{'in_reply_to':_0x54b49c,'text':_0x366ac2,'status':_0x5963bc});}async[a0_0x588652(0x191)](_0x2ee736,_0xa79b5c){const _0x3d1850=a0_0x588652;return this[_0x3d1850(0x14a)](_0x3d1850(0x138),{'resume_id':this[_0x3d1850(0x1aa)],'alias':this[_0x3d1850(0x15b)],'status':_0x2ee736,'server':a0_0x39491e(),'hostname':a0_0x39491e(),'agent':this['agent'],'project_dir':process[_0x3d1850(0x150)](),..._0xa79b5c});}async['getAllStatus'](){const _0x100df7=a0_0x588652;return this[_0x100df7(0x14a)](_0x100df7(0x18e),{});}async[a0_0x588652(0x190)](_0x822f53,_0x2f3c0a){const _0x5524af=a0_0x588652;return this[_0x5524af(0x14a)](_0x5524af(0x190),{'message':_0x822f53,'filter_server':_0x2f3c0a?.[_0x5524af(0x133)],'filter_status':_0x2f3c0a?.['status']});}async[a0_0x588652(0x197)](){const _0x39b147=a0_0x588652;let _0xae0b8=encodeURIComponent(this['alias']),_0x4d9c62=this['url']+'/events/'+_0xae0b8,_0x4eb369=this[_0x39b147(0x17a)];while(this[_0x39b147(0x149)]){try{this[_0x39b147(0x1a6)]=new AbortController();let _0x483a47={'Accept':_0x39b147(0x14d)};if(this[_0x39b147(0x174)])_0x483a47[_0x39b147(0x17c)]=_0x39b147(0x14e)+this[_0x39b147(0x174)];let _0x1e867d=await fetch(_0x4d9c62,{'headers':_0x483a47,'signal':this['sseAbort'][_0x39b147(0x19d)]});if(!_0x1e867d['ok']||!_0x1e867d[_0x39b147(0x163)]){this[_0x39b147(0x151)](_0x39b147(0x19f)+_0x1e867d[_0x39b147(0x191)]),await this[_0x39b147(0x135)](_0x4eb369),_0x4eb369=Math[_0x39b147(0x18c)](_0x4eb369*1.5,0xea60);continue;}_0x4eb369=this[_0x39b147(0x17a)];let _0x1f9a5a=_0x1e867d[_0x39b147(0x163)][_0x39b147(0x139)](),_0x29eb21=new TextDecoder(),_0x531b16='';while(this[_0x39b147(0x149)]){let {done:_0xb468ed,value:_0x429db1}=await _0x1f9a5a[_0x39b147(0x168)]();if(_0xb468ed)break;_0x531b16+=_0x29eb21['decode'](_0x429db1,{'stream':!0x0});let _0x207411=_0x531b16[_0x39b147(0x157)]('\x0a');_0x531b16=_0x207411[_0x39b147(0x166)]()||'';for(let _0x58a8fc of _0x207411){if(!_0x58a8fc[_0x39b147(0x14b)]('data:\x20'))continue;try{let _0x34522f=JSON[_0x39b147(0x186)](_0x58a8fc[_0x39b147(0x19c)](0x6));if(_0x34522f[_0x39b147(0x155)]===_0x39b147(0x132)){this[_0x39b147(0x151)](_0x39b147(0x1a7)),this[_0x39b147(0x194)](_0x39b147(0x132));continue;}if(_0x34522f[_0x39b147(0x155)]===_0x39b147(0x13a)||_0x34522f[_0x39b147(0x155)]===_0x39b147(0x15c)||_0x34522f['type']===_0x39b147(0x190))await this[_0x39b147(0x19a)]();}catch{}}}}catch(_0x89e2a5){if(_0x89e2a5['name']===_0x39b147(0x13b))break;this[_0x39b147(0x194)]('error',_0x89e2a5),this[_0x39b147(0x151)]('SSE\x20error:\x20'+_0x89e2a5[_0x39b147(0x17b)]);}if(this[_0x39b147(0x149)])this[_0x39b147(0x194)](_0x39b147(0x188)),this[_0x39b147(0x151)]('SSE\x20reconnecting\x20in\x20'+_0x4eb369/0x3e8+_0x39b147(0x17d)),await this[_0x39b147(0x135)](_0x4eb369),_0x4eb369=Math[_0x39b147(0x18c)](_0x4eb369*1.5,0xea60);}}async[a0_0x588652(0x19a)](){const _0x468fa7=a0_0x588652;try{let _0x517fea=(await this[_0x468fa7(0x14a)](_0x468fa7(0x179),{'alias':this['alias'],'limit':0xa}))?.[_0x468fa7(0x143)]||[];for(let _0x186e64 of _0x517fea)await this['call'](_0x468fa7(0x16f),{'alias':this[_0x468fa7(0x15b)],'message_id':_0x186e64['id']}),this[_0x468fa7(0x151)]('←\x20'+_0x186e64[_0x468fa7(0x169)]+':\x20'+_0x186e64[_0x468fa7(0x196)][_0x468fa7(0x19c)](0x0,0x3c)),this[_0x468fa7(0x194)]('task',_0x186e64),this[_0x468fa7(0x194)](_0x468fa7(0x17b),_0x186e64);}catch(_0x5535dc){this[_0x468fa7(0x151)](_0x468fa7(0x18f)+_0x5535dc[_0x468fa7(0x17b)]);}}['sleep'](_0x2c224f){return new Promise(_0x6628a3=>setTimeout(_0x6628a3,_0x2c224f));}}var F=$;export{F as default,$ as CommHub};
1
+ const a0_0x530533=a0_0x335c;(function(_0x1c5d52,_0x2f5955){const _0x4643e0=a0_0x335c,_0x3748d7=_0x1c5d52();while(!![]){try{const _0x344ba9=-parseInt(_0x4643e0(0xb3))/0x1*(parseInt(_0x4643e0(0x9c))/0x2)+-parseInt(_0x4643e0(0xf9))/0x3*(parseInt(_0x4643e0(0x95))/0x4)+-parseInt(_0x4643e0(0xde))/0x5*(parseInt(_0x4643e0(0xd9))/0x6)+parseInt(_0x4643e0(0xef))/0x7+-parseInt(_0x4643e0(0x97))/0x8+-parseInt(_0x4643e0(0x105))/0x9+parseInt(_0x4643e0(0x8f))/0xa;if(_0x344ba9===_0x2f5955)break;else _0x3748d7['push'](_0x3748d7['shift']());}catch(_0x5e7ba1){_0x3748d7['push'](_0x3748d7['shift']());}}}(a0_0x58c6,0xd0b4d));function a0_0x58c6(){const _0x3898ec=['CommHub\x20rejected\x20task','heartbeatInterval','task.replied','/events/','completed','/mcp','getReader','366TYBhOr','sleep','cwd','string','token','104285hgOoUN','disconnect','transport','decode','task.send.start','AbortError','broadcast','fromAlias','\x20network_id=','<unknown>','SSE\x20error:\x20','error','autoConnect','text/event-stream','lifecycle_tracking','task','<pending>','5638290YNpLBO','send_failed','emit',']\x20[commhub:','Bearer\x20','connected','sdk','error_code','send_reply','send_message','4413yjxVto','unknown\x20error','Authorization','[commhub:task]\x20','match','<missing>','not_tracked','tools/call','result','heartbeatTimer','sseAbort','min','1429065wXCHaw','read','inbox\x20error:\x20','alias','slice','disconnected','startsWith','server','message','sending','ack_inbox','agent','send','36177130PZgVEj','task.started','task.expired','reconnectDelay','\x20error=','delivered','4164NLvHsm','reply','3027344qQiQdV','toString','offline','data:\x20','content','2XvBYIT','running','get_all_status','task_id','task.send.delivered','\x20to=','sdk-','connectSSE','\x20from=','networkId','messages','signal','SSE\x20connected','\x20parent_task_id=','catch','heartbeat\x20failed:\x20','idle','now','normal','failed','[REDACTED]','parse','replace','227531FDncUE','call','error_message','split','processInbox','network_id','task.ack','new_task','duration_ms','resumeId','getAllStatus','pop','status','mcp_http','send_task','message_id','type','SSE\x20failed:\x20','CommHub\x20response\x20omitted\x20task_id','to_alias','text','url','log','toTimeString','name','task.send.failed','SSE\x20reconnecting\x20in\x20','application/json','connect','body','toAlias'];a0_0x58c6=function(){return _0x3898ec;};return a0_0x58c6();}import{EventEmitter as a0_0x4c34bc}from'events';import{hostname as a0_0x5ca233}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0xd0596c,_0x3911c9)=>(_0xd0596c??_0x3911c9)[a0_0x530533(0xb2)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x530533(0x109)](0x0,0xf0);function N(_0x3523ec){const _0x282bf2=a0_0x530533;return(_0x3523ec instanceof Error?_0x3523ec['message']:String(_0x3523ec??_0x282bf2(0xfa)))[_0x282bf2(0xb2)](K,_0x282bf2(0xb0))[_0x282bf2(0xb2)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x282bf2(0x109)](0x0,0xf0);}function O(_0x4c9296,_0x4bd93a=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x3d3da5=a0_0x530533;if(_0x4bd93a)return JSON['stringify'](_0x4c9296);let _0x1febae=L(_0x4c9296['parent_task_id'],_0x3d3da5(0xfe)),_0x5e3d40=L(_0x4c9296[_0x3d3da5(0x9f)],_0x3d3da5(0xee)),_0x1f04ca=_0x4c9296['error_code']?_0x3d3da5(0x93)+_0x4c9296[_0x3d3da5(0xf6)]+':'+(_0x4c9296[_0x3d3da5(0xb5)]??''):'';return _0x3d3da5(0xfc)+_0x4c9296['status']+_0x3d3da5(0xa4)+L(_0x4c9296['from_alias'],_0x3d3da5(0xe7))+_0x3d3da5(0xa1)+L(_0x4c9296[_0x3d3da5(0xc6)],_0x3d3da5(0xe7))+'\x20task_id='+_0x5e3d40+_0x3d3da5(0xa9)+_0x1febae+_0x3d3da5(0xe6)+L(_0x4c9296[_0x3d3da5(0xb8)],'<unknown>')+'\x20transport='+_0x4c9296[_0x3d3da5(0xe0)]+'\x20duration_ms='+_0x4c9296[_0x3d3da5(0xbb)]+'\x20lifecycle='+_0x4c9296[_0x3d3da5(0xec)]+_0x1f04ca;}function U(_0x4278ec){const _0x146b28=a0_0x530533;return{'event':{'sending':_0x146b28(0xe2),'delivered':_0x146b28(0xa0),'failed':_0x146b28(0xcc),'acked':_0x146b28(0xb9),'started':_0x146b28(0x90),'replied':_0x146b28(0xd4),'expired':_0x146b28(0x91)}[_0x4278ec[_0x146b28(0xbf)]],..._0x4278ec};}function j(_0x269f9e){const _0x11ed8a=a0_0x530533;let _0x3bc23b=_0x269f9e?.[_0x11ed8a(0x9f)]||_0x269f9e?.[_0x11ed8a(0xc2)]||_0x269f9e?.['id'];if(_0x3bc23b)return String(_0x3bc23b);let _0x52bb2e=_0x269f9e?.['content']?.[0x0]?.[_0x11ed8a(0xc7)];if(typeof _0x52bb2e!==_0x11ed8a(0xdc))return null;try{let _0x29339f=JSON['parse'](_0x52bb2e);return _0x29339f?.[_0x11ed8a(0x9f)]||_0x29339f?.[_0x11ed8a(0xc2)]||_0x29339f?.['id']||null;}catch{return null;}}async function X(_0x19d56c,_0x1fcd73){const _0x4f6763=a0_0x530533;let _0x15df67=_0x1fcd73[_0x4f6763(0xad)]??Date['now'],_0x440f73=_0x15df67(),_0x1aea46=(_0x12c9ed,_0xce711a,_0x594975,_0x21705a)=>{const _0x4af90d=_0x4f6763;_0x1fcd73[_0x4af90d(0xc9)](O(U({'from_alias':_0x19d56c[_0x4af90d(0xe5)],'to_alias':_0x19d56c[_0x4af90d(0xd1)],'task_id':_0xce711a,'parent_task_id':_0x19d56c['parentTaskId'],'network_id':_0x19d56c[_0x4af90d(0xa5)],'transport':_0x19d56c[_0x4af90d(0xe0)],'status':_0x12c9ed,'duration_ms':_0x15df67()-_0x440f73,'lifecycle_tracking':_0x19d56c['lifecycleTracking'],..._0x594975!==void 0x0?{'error_code':_0x21705a||_0x4af90d(0xf0),'error_message':N(_0x594975)}:{}})));};_0x1aea46(_0x4f6763(0x8b),null);try{let _0x26d889=await _0x1fcd73[_0x4f6763(0x8e)](),_0x1fb44a=j(_0x26d889);if(_0x1fb44a)_0x1aea46(_0x4f6763(0x94),_0x1fb44a);else{if(_0x26d889?.['ok']===!0x1||_0x26d889?.[_0x4f6763(0xe9)])_0x1aea46(_0x4f6763(0xaf),_0x1fb44a,_0x26d889?.[_0x4f6763(0xe9)]||_0x4f6763(0xd2),'send_rejected');else _0x1aea46(_0x4f6763(0xaf),null,_0x4f6763(0xc5),'missing_task_id');}return _0x26d889;}catch(_0xf40b50){throw _0x1aea46('failed',null,_0xf40b50,_0x4f6763(0xf0)),_0xf40b50;}}function a0_0x335c(_0x40db36,_0x51eb74){_0x40db36=_0x40db36-0x8b;const _0x58c6c5=a0_0x58c6();let _0x335c45=_0x58c6c5[_0x40db36];return _0x335c45;}async function Y(_0x164bb8,_0x165794){const _0x216571=a0_0x530533;return X({'fromAlias':_0x164bb8[_0x216571(0xe5)],'toAlias':_0x164bb8[_0x216571(0x108)],'parentTaskId':_0x164bb8['parentTaskId']||null,'networkId':_0x164bb8[_0x216571(0xa5)]||null,'transport':_0x216571(0xc0),'lifecycleTracking':_0x216571(0xff)},_0x165794);}class $ extends a0_0x4c34bc{['url'];[a0_0x530533(0x108)];[a0_0x530533(0xdd)];[a0_0x530533(0x8d)];['resumeId'];['heartbeatInterval'];[a0_0x530533(0x92)];['heartbeatTimer'];['sseAbort'];[a0_0x530533(0x9d)]=!0x1;constructor(_0x5adf60){const _0x35e1bc=a0_0x530533;super();if(this[_0x35e1bc(0xc8)]=_0x5adf60[_0x35e1bc(0xc8)][_0x35e1bc(0xb2)](/\/$/,''),this[_0x35e1bc(0x108)]=_0x5adf60['alias'],this[_0x35e1bc(0xdd)]=_0x5adf60[_0x35e1bc(0xdd)],this[_0x35e1bc(0x8d)]=_0x5adf60['agent']||_0x35e1bc(0xf5),this[_0x35e1bc(0xbc)]=_0x35e1bc(0xa2)+_0x5adf60[_0x35e1bc(0x108)]+'-'+Date[_0x35e1bc(0xad)]()[_0x35e1bc(0x98)](0x24),this[_0x35e1bc(0xd3)]=_0x5adf60[_0x35e1bc(0xd3)]??0x2bf20,this[_0x35e1bc(0x92)]=_0x5adf60[_0x35e1bc(0x92)]??0xbb8,_0x5adf60[_0x35e1bc(0xea)]!==!0x1)this[_0x35e1bc(0xcf)]();}[a0_0x530533(0xc9)](_0x49689e){const _0x4f7849=a0_0x530533;console[_0x4f7849(0xc9)]('['+new Date()[_0x4f7849(0xca)]()['slice'](0x0,0x8)+_0x4f7849(0xf2)+this['alias']+']\x20'+_0x49689e);}async[a0_0x530533(0xb4)](_0xb8d4c0,_0x33f690){const _0x1a3eeb=a0_0x530533;let _0x30927c={'Content-Type':_0x1a3eeb(0xce),'Accept':'application/json,\x20text/event-stream'};if(this[_0x1a3eeb(0xdd)])_0x30927c[_0x1a3eeb(0xfb)]='Bearer\x20'+this['token'];let _0x504036=await(await fetch(this['url']+_0x1a3eeb(0xd7),{'method':'POST','headers':_0x30927c,'body':JSON['stringify']({'jsonrpc':'2.0','id':Date['now'](),'method':_0x1a3eeb(0x100),'params':{'name':_0xb8d4c0,'arguments':_0x33f690}})}))[_0x1a3eeb(0xc7)](),_0x5f0c54=_0x504036[_0x1a3eeb(0xfd)](/data: (.+)/),_0x56d42b=_0x5f0c54?JSON['parse'](_0x5f0c54[0x1]):JSON['parse'](_0x504036),_0x5b2fd1=_0x56d42b?.[_0x1a3eeb(0x101)]?.[_0x1a3eeb(0x9b)]?.[0x0]?.['text'];return _0x5b2fd1?JSON[_0x1a3eeb(0xb1)](_0x5b2fd1):_0x56d42b;}async[a0_0x530533(0xcf)](){const _0x5265c6=a0_0x530533;if(this['running'])return;this[_0x5265c6(0x9d)]=!0x0,await this[_0x5265c6(0xbf)](_0x5265c6(0xac)),this[_0x5265c6(0xc9)]('registered'),this[_0x5265c6(0x102)]=setInterval(()=>{const _0x7debef=_0x5265c6;this[_0x7debef(0xbf)](_0x7debef(0xac))[_0x7debef(0xaa)](_0x4bb19e=>this[_0x7debef(0xc9)](_0x7debef(0xab)+_0x4bb19e[_0x7debef(0x10d)]));},this['heartbeatInterval']),this[_0x5265c6(0xa3)]();}async[a0_0x530533(0xdf)](){const _0x362336=a0_0x530533;if(this[_0x362336(0x9d)]=!0x1,this[_0x362336(0x103)]?.['abort'](),this[_0x362336(0x102)])clearInterval(this[_0x362336(0x102)]);await this[_0x362336(0xbf)](_0x362336(0x99))[_0x362336(0xaa)](()=>{}),this[_0x362336(0xc9)](_0x362336(0x10a));}async[a0_0x530533(0x8e)](_0x6171f7,_0x1ae860,_0x5a47a2=a0_0x530533(0xae)){const _0xf30c46=a0_0x530533;return Y({'alias':_0x6171f7,'fromAlias':this['alias']},{'log':_0x19db47=>console[_0xf30c46(0xc9)](_0x19db47),'send':()=>this[_0xf30c46(0xb4)](_0xf30c46(0xc1),{'alias':_0x6171f7,'task':_0x1ae860,'priority':_0x5a47a2,'from_session':this[_0xf30c46(0x108)]})});}async[a0_0x530533(0x10d)](_0x11d94d,_0x5e8f91){const _0x2d6423=a0_0x530533;return this[_0x2d6423(0xb4)](_0x2d6423(0xf8),{'alias':_0x11d94d,'message':_0x5e8f91,'from_session':this[_0x2d6423(0x108)]});}async[a0_0x530533(0x96)](_0x206ac4,_0x33fcdb,_0x3944f6=a0_0x530533(0xd6)){const _0x53713a=a0_0x530533;return this[_0x53713a(0xb4)](_0x53713a(0xf7),{'in_reply_to':_0x206ac4,'text':_0x33fcdb,'status':_0x3944f6});}async[a0_0x530533(0xbf)](_0x17ea0d,_0x58243b){const _0x393739=a0_0x530533;return this[_0x393739(0xb4)]('report_status',{'resume_id':this[_0x393739(0xbc)],'alias':this[_0x393739(0x108)],'status':_0x17ea0d,'server':a0_0x5ca233(),'hostname':a0_0x5ca233(),'agent':this[_0x393739(0x8d)],'project_dir':process[_0x393739(0xdb)](),..._0x58243b});}async[a0_0x530533(0xbd)](){const _0x208f37=a0_0x530533;return this['call'](_0x208f37(0x9e),{});}async['broadcast'](_0x111e5c,_0x40bade){const _0x3343eb=a0_0x530533;return this[_0x3343eb(0xb4)](_0x3343eb(0xe4),{'message':_0x111e5c,'filter_server':_0x40bade?.[_0x3343eb(0x10c)],'filter_status':_0x40bade?.[_0x3343eb(0xbf)]});}async[a0_0x530533(0xa3)](){const _0x404abe=a0_0x530533;let _0x32220c=encodeURIComponent(this[_0x404abe(0x108)]),_0x13c043=this[_0x404abe(0xc8)]+_0x404abe(0xd5)+_0x32220c,_0x5f4edc=this[_0x404abe(0x92)];while(this['running']){try{this[_0x404abe(0x103)]=new AbortController();let _0x22db17={'Accept':_0x404abe(0xeb)};if(this[_0x404abe(0xdd)])_0x22db17[_0x404abe(0xfb)]=_0x404abe(0xf3)+this[_0x404abe(0xdd)];let _0x8daa6e=await fetch(_0x13c043,{'headers':_0x22db17,'signal':this[_0x404abe(0x103)][_0x404abe(0xa7)]});if(!_0x8daa6e['ok']||!_0x8daa6e[_0x404abe(0xd0)]){this['log'](_0x404abe(0xc4)+_0x8daa6e[_0x404abe(0xbf)]),await this[_0x404abe(0xda)](_0x5f4edc),_0x5f4edc=Math[_0x404abe(0x104)](_0x5f4edc*1.5,0xea60);continue;}_0x5f4edc=this['reconnectDelay'];let _0x55b24f=_0x8daa6e[_0x404abe(0xd0)][_0x404abe(0xd8)](),_0x3c3aa0=new TextDecoder(),_0x1f1371='';while(this['running']){let {done:_0x148f41,value:_0x133039}=await _0x55b24f[_0x404abe(0x106)]();if(_0x148f41)break;_0x1f1371+=_0x3c3aa0[_0x404abe(0xe1)](_0x133039,{'stream':!0x0});let _0x1e39c1=_0x1f1371[_0x404abe(0xb6)]('\x0a');_0x1f1371=_0x1e39c1[_0x404abe(0xbe)]()||'';for(let _0x1e6f99 of _0x1e39c1){if(!_0x1e6f99[_0x404abe(0x10b)](_0x404abe(0x9a)))continue;try{let _0x5c1ba6=JSON[_0x404abe(0xb1)](_0x1e6f99[_0x404abe(0x109)](0x6));if(_0x5c1ba6['type']===_0x404abe(0xf4)){this['log'](_0x404abe(0xa8)),this[_0x404abe(0xf1)](_0x404abe(0xf4));continue;}if(_0x5c1ba6[_0x404abe(0xc3)]===_0x404abe(0xba)||_0x5c1ba6['type']==='new_message'||_0x5c1ba6[_0x404abe(0xc3)]==='broadcast')await this[_0x404abe(0xb7)]();}catch{}}}}catch(_0x136a28){if(_0x136a28[_0x404abe(0xcb)]===_0x404abe(0xe3))break;this[_0x404abe(0xf1)](_0x404abe(0xe9),_0x136a28),this[_0x404abe(0xc9)](_0x404abe(0xe8)+_0x136a28[_0x404abe(0x10d)]);}if(this[_0x404abe(0x9d)])this[_0x404abe(0xf1)](_0x404abe(0x10a)),this[_0x404abe(0xc9)](_0x404abe(0xcd)+_0x5f4edc/0x3e8+'s...'),await this[_0x404abe(0xda)](_0x5f4edc),_0x5f4edc=Math[_0x404abe(0x104)](_0x5f4edc*1.5,0xea60);}}async['processInbox'](){const _0x539255=a0_0x530533;try{let _0xf37878=(await this[_0x539255(0xb4)]('get_inbox',{'alias':this[_0x539255(0x108)],'limit':0xa}))?.[_0x539255(0xa6)]||[];for(let _0xcc9324 of _0xf37878)await this['call'](_0x539255(0x8c),{'alias':this[_0x539255(0x108)],'message_id':_0xcc9324['id']}),this[_0x539255(0xc9)]('←\x20'+_0xcc9324['from_session']+':\x20'+_0xcc9324[_0x539255(0x9b)][_0x539255(0x109)](0x0,0x3c)),this[_0x539255(0xf1)](_0x539255(0xed),_0xcc9324),this[_0x539255(0xf1)](_0x539255(0x10d),_0xcc9324);}catch(_0x4ba9a0){this[_0x539255(0xc9)](_0x539255(0x107)+_0x4ba9a0[_0x539255(0x10d)]);}}[a0_0x530533(0xda)](_0x2670cc){return new Promise(_0x2b8239=>setTimeout(_0x2b8239,_0x2670cc));}}var F=$;export{F as default,$ as CommHub};
@@ -34,7 +34,7 @@ export interface CollectEnv {
34
34
  export declare function collectCodexRows(nodes: CodexMenuNode[], env: CollectEnv): CodexNodeRow[];
35
35
  export declare function renderCodexTable(rows: CodexNodeRow[], cwd: string): string;
36
36
  export declare const CODEX_CHEAT_SHEET: string;
37
- export type MenuAction = "start" | "stop" | "restart" | "verify" | "login" | "continue" | "model" | "copy" | "delete";
37
+ export type MenuAction = "start" | "stop" | "restart" | "verify" | "login" | "continue" | "pick" | "model" | "copy" | "delete";
38
38
  export declare const MENU_ACTIONS: {
39
39
  key: MenuAction;
40
40
  label: string;
@@ -0,0 +1,89 @@
1
+ import { type ExternalThread } from "./codex-adopt";
2
+ import { type CollectEnv, type CodexMenuNode } from "./codex-menu";
3
+ export type CodexResumeKind = "co-presence" | "codex-sdk";
4
+ export interface CodexResumeFacts {
5
+ readonly alias: string;
6
+ readonly kind: CodexResumeKind;
7
+ /** "running" | "stopped" | "partial 1/3" (codex-menu's row.state). */
8
+ readonly state: string;
9
+ readonly running: boolean;
10
+ /** The CODEX_HOME the node's codex runs with (its own, or the host ~/.codex for a codex-sdk node). */
11
+ readonly codexHome: string;
12
+ readonly homeExists: boolean;
13
+ /** true = codex's default ~/.codex (no CODEX_HOME needed to log it in). */
14
+ readonly homeIsHost: boolean;
15
+ readonly loggedIn: boolean;
16
+ /** codexThreadId (co-presence) / session (codex-sdk) from the node config. */
17
+ readonly recordedThread: string | null;
18
+ /** Every rollout under `<codexHome>/sessions`, newest first. */
19
+ readonly threads: readonly ExternalThread[];
20
+ }
21
+ export interface CodexResumeRequest {
22
+ /** --thread <id|unique prefix> (also --session <id>, the old spelling). */
23
+ readonly thread?: string | null;
24
+ readonly pick?: boolean;
25
+ /** stdin and stdout are both a terminal. */
26
+ readonly tty: boolean;
27
+ }
28
+ export type CodexResumeDecision =
29
+ /** Nothing was done. `lines[0]` is the reason with the fix; exit with `code`. */
30
+ {
31
+ readonly kind: "refuse";
32
+ readonly code: number;
33
+ readonly lines: readonly string[];
34
+ }
35
+ /** --pick without a terminal: the list plus a copy-paste command. Nothing was done. */
36
+ | {
37
+ readonly kind: "list";
38
+ readonly code: number;
39
+ readonly lines: readonly string[];
40
+ }
41
+ /** --pick in a terminal: show `lines`, ask for a number in 1..`choices.length`. */
42
+ | {
43
+ readonly kind: "ask";
44
+ readonly lines: readonly string[];
45
+ readonly choices: readonly string[];
46
+ }
47
+ /** Already running on exactly that thread — attach instead (exit 0). */
48
+ | {
49
+ readonly kind: "already";
50
+ readonly lines: readonly string[];
51
+ }
52
+ /** Go: record `threadId` (when `changed`) and start the node. */
53
+ | {
54
+ readonly kind: "resume";
55
+ readonly threadId: string;
56
+ readonly changed: boolean;
57
+ readonly rolloutPath: string;
58
+ };
59
+ /** How many threads the picker numbers; older ones are reachable with --thread. */
60
+ export declare const PICK_LIMIT = 20;
61
+ export declare function freshStartCommand(f: Pick<CodexResumeFacts, "alias" | "kind">): string;
62
+ export declare function codexLoginCommand(f: Pick<CodexResumeFacts, "codexHome" | "homeIsHost">): string;
63
+ /** Numbered rows: time (UTC, as codex wrote it), short id, first user line. The recorded thread is marked. */
64
+ export declare function formatNodeThreadList(threads: readonly ExternalThread[], recorded: string | null, limit?: number): string[];
65
+ export declare function resumeCommandFor(alias: string, threadId: string): string;
66
+ /** The whole decision. Order: request shape → home → which thread → login → process state. */
67
+ export declare function decideCodexResume(f: CodexResumeFacts, req: CodexResumeRequest): CodexResumeDecision;
68
+ /** A typed answer to the picker: a number from the list; empty / q = cancel. */
69
+ export declare function parsePickAnswer(answer: string | null, choices: readonly string[]): {
70
+ kind: "ok";
71
+ threadId: string;
72
+ } | {
73
+ kind: "cancel";
74
+ } | {
75
+ kind: "bad";
76
+ message: string;
77
+ };
78
+ /**
79
+ * `anet node codex resume` records the thread in config before its state
80
+ * machine runs. If the run stops before anything was touched, the old value
81
+ * goes back — the config must not name a thread the node is not running (#531 §5).
82
+ */
83
+ export declare function resumeConfigShouldRollBack(stoppedAt: string): boolean;
84
+ /**
85
+ * The facts for one node, from the same helpers the codex menu uses
86
+ * (collectCodexRows: kind / state / login; effectiveCodexHome: which home).
87
+ * Read-only. null = not a codex node.
88
+ */
89
+ export declare function gatherCodexResumeFacts(node: CodexMenuNode, env: CollectEnv): CodexResumeFacts | null;