@sleep2agi/agent-network 2.3.0-preview.140 → 2.3.0-preview.142

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_0x5e3fe2=a0_0x557c;(function(_0x51de4b,_0x46c859){const _0x390f58=a0_0x557c,_0x288a8e=_0x51de4b();while(!![]){try{const _0x268c63=parseInt(_0x390f58(0x237))/0x1*(parseInt(_0x390f58(0x228))/0x2)+parseInt(_0x390f58(0x20a))/0x3+-parseInt(_0x390f58(0x26d))/0x4+parseInt(_0x390f58(0x238))/0x5*(parseInt(_0x390f58(0x22c))/0x6)+-parseInt(_0x390f58(0x214))/0x7+-parseInt(_0x390f58(0x25c))/0x8+parseInt(_0x390f58(0x264))/0x9*(parseInt(_0x390f58(0x26c))/0xa);if(_0x268c63===_0x46c859)break;else _0x288a8e['push'](_0x288a8e['shift']());}catch(_0x2a28e7){_0x288a8e['push'](_0x288a8e['shift']());}}}(a0_0x5957,0x3f5d2));import{EventEmitter as a0_0x32c53b}from'events';import{hostname as a0_0x1952d2}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x360b43,_0x384296)=>(_0x360b43??_0x384296)[a0_0x5e3fe2(0x21c)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function a0_0x5957(){const _0x5ef710=['get_inbox','network_id','min','connect','agent','idle','stringify','broadcast','heartbeatInterval','getAllStatus','signal','call','transport','heartbeat\x20failed:\x20','send_failed','sseAbort','inbox\x20error:\x20','new_task','body','server','SSE\x20connected','AbortError','emit','3015096vzpDjF','to_alias','task.started','/events/','now','task.ack','unknown\x20error','\x20duration_ms=','108648XpxQMh','tools/call','heartbeatTimer','send_reply','parentTaskId','sleep','2.0','send_message','90JWHTJN','1999208GZTFIQ','\x20to=','Authorization','sdk-','[commhub:task]\x20','json','from_alias','\x20network_id=','\x20parent_task_id=','message','sdk','new_message','<unknown>','task_id','content','task','message_id','task.expired','connectSSE','completed','slice','fromAlias','send','toAlias','lifecycleTracking','SSE\x20failed:\x20','token','reply','<missing>','reconnectDelay','pop','1358013AZmJbU',']\x20[commhub:','delivered','text','SSE\x20error:\x20','autoConnect','string','toTimeString','catch','alias','1451912SNmoIJ','log','ack_inbox','cwd','offline','application/json,\x20text/event-stream','application/json','getReader','replace','task.send.delivered','parse','\x20task_id=','networkId','running','\x20from=','type','name','get_all_status','missing_task_id','startsWith','170noaENg','text/event-stream','processInbox','not_tracked','6GtkQhV','registered','url','result','disconnected','failed','Bearer\x20','task.send.failed','/mcp','CommHub\x20rejected\x20task','abort','4051vNxQtR','2189945FdafkV','error_code','task.send.start','decode','error','SSE\x20reconnecting\x20in\x20','lifecycle_tracking','send_rejected','error_message','data:\x20','status','duration_ms','resumeId'];a0_0x5957=function(){return _0x5ef710;};return a0_0x5957();}function a0_0x557c(_0x2178b4,_0x5610e5){_0x2178b4=_0x2178b4-0x1f2;const _0x595774=a0_0x5957();let _0x557c34=_0x595774[_0x2178b4];return _0x557c34;}function N(_0x23ff20){const _0x2214ca=a0_0x5e3fe2;return(_0x23ff20 instanceof Error?_0x23ff20['message']:String(_0x23ff20??_0x2214ca(0x262)))[_0x2214ca(0x21c)](K,'[REDACTED]')[_0x2214ca(0x21c)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x297436,_0x13339d=process.env.ANET_TASK_TRACE_FORMAT===a0_0x5e3fe2(0x272)){const _0x1a9c4c=a0_0x5e3fe2;if(_0x13339d)return JSON[_0x1a9c4c(0x24b)](_0x297436);let _0x28137b=L(_0x297436['parent_task_id'],_0x1a9c4c(0x207)),_0x4130d0=L(_0x297436['task_id'],'<pending>'),_0x5a3500=_0x297436[_0x1a9c4c(0x239)]?'\x20error='+_0x297436[_0x1a9c4c(0x239)]+':'+(_0x297436[_0x1a9c4c(0x240)]??''):'';return _0x1a9c4c(0x271)+_0x297436[_0x1a9c4c(0x242)]+_0x1a9c4c(0x222)+L(_0x297436[_0x1a9c4c(0x273)],_0x1a9c4c(0x1f7))+_0x1a9c4c(0x26e)+L(_0x297436[_0x1a9c4c(0x25d)],'<unknown>')+_0x1a9c4c(0x21f)+_0x4130d0+_0x1a9c4c(0x1f3)+_0x28137b+_0x1a9c4c(0x1f2)+L(_0x297436[_0x1a9c4c(0x246)],_0x1a9c4c(0x1f7))+'\x20transport='+_0x297436[_0x1a9c4c(0x251)]+_0x1a9c4c(0x263)+_0x297436[_0x1a9c4c(0x243)]+'\x20lifecycle='+_0x297436[_0x1a9c4c(0x23e)]+_0x5a3500;}function U(_0x292490){const _0x4d58bf=a0_0x5e3fe2;return{'event':{'sending':_0x4d58bf(0x23a),'delivered':_0x4d58bf(0x21d),'failed':_0x4d58bf(0x233),'acked':_0x4d58bf(0x261),'started':_0x4d58bf(0x25e),'replied':'task.replied','expired':_0x4d58bf(0x1fc)}[_0x292490[_0x4d58bf(0x242)]],..._0x292490};}function j(_0x18af7a){const _0x26d68c=a0_0x5e3fe2;let _0x1b4452=_0x18af7a?.[_0x26d68c(0x1f8)]||_0x18af7a?.[_0x26d68c(0x1fb)]||_0x18af7a?.['id'];if(_0x1b4452)return String(_0x1b4452);let _0x5232b3=_0x18af7a?.[_0x26d68c(0x1f9)]?.[0x0]?.[_0x26d68c(0x20d)];if(typeof _0x5232b3!==_0x26d68c(0x210))return null;try{let _0x394b2f=JSON[_0x26d68c(0x21e)](_0x5232b3);return _0x394b2f?.[_0x26d68c(0x1f8)]||_0x394b2f?.[_0x26d68c(0x1fb)]||_0x394b2f?.['id']||null;}catch{return null;}}async function X(_0x553836,_0x18bc98){const _0x29fc08=a0_0x5e3fe2;let _0x17a0c5=_0x18bc98[_0x29fc08(0x260)]??Date[_0x29fc08(0x260)],_0x301e1c=_0x17a0c5(),_0x3a8a49=(_0x36c617,_0x33e302,_0x5530a4,_0x456b6f)=>{const _0xefb9a2=_0x29fc08;_0x18bc98['log'](O(U({'from_alias':_0x553836[_0xefb9a2(0x200)],'to_alias':_0x553836[_0xefb9a2(0x202)],'task_id':_0x33e302,'parent_task_id':_0x553836[_0xefb9a2(0x268)],'network_id':_0x553836[_0xefb9a2(0x220)],'transport':_0x553836['transport'],'status':_0x36c617,'duration_ms':_0x17a0c5()-_0x301e1c,'lifecycle_tracking':_0x553836[_0xefb9a2(0x203)],..._0x5530a4!==void 0x0?{'error_code':_0x456b6f||'send_failed','error_message':N(_0x5530a4)}:{}})));};_0x3a8a49('sending',null);try{let _0x47ca79=await _0x18bc98['send'](),_0x1412e0=j(_0x47ca79);if(_0x1412e0)_0x3a8a49(_0x29fc08(0x20c),_0x1412e0);else{if(_0x47ca79?.['ok']===!0x1||_0x47ca79?.[_0x29fc08(0x23c)])_0x3a8a49(_0x29fc08(0x231),_0x1412e0,_0x47ca79?.[_0x29fc08(0x23c)]||_0x29fc08(0x235),_0x29fc08(0x23f));else _0x3a8a49(_0x29fc08(0x231),null,'CommHub\x20response\x20omitted\x20task_id',_0x29fc08(0x226));}return _0x47ca79;}catch(_0x592a5c){throw _0x3a8a49(_0x29fc08(0x231),null,_0x592a5c,_0x29fc08(0x253)),_0x592a5c;}}async function Y(_0x49c1e2,_0x339787){const _0x2ae12e=a0_0x5e3fe2;return X({'fromAlias':_0x49c1e2[_0x2ae12e(0x200)],'toAlias':_0x49c1e2[_0x2ae12e(0x213)],'parentTaskId':_0x49c1e2[_0x2ae12e(0x268)]||null,'networkId':_0x49c1e2['networkId']||null,'transport':'mcp_http','lifecycleTracking':_0x2ae12e(0x22b)},_0x339787);}class $ extends a0_0x32c53b{[a0_0x5e3fe2(0x22e)];[a0_0x5e3fe2(0x213)];[a0_0x5e3fe2(0x205)];['agent'];[a0_0x5e3fe2(0x244)];['heartbeatInterval'];[a0_0x5e3fe2(0x208)];[a0_0x5e3fe2(0x266)];[a0_0x5e3fe2(0x254)];['running']=!0x1;constructor(_0x547bfb){const _0x1f2d7c=a0_0x5e3fe2;super();if(this[_0x1f2d7c(0x22e)]=_0x547bfb[_0x1f2d7c(0x22e)][_0x1f2d7c(0x21c)](/\/$/,''),this['alias']=_0x547bfb[_0x1f2d7c(0x213)],this[_0x1f2d7c(0x205)]=_0x547bfb[_0x1f2d7c(0x205)],this[_0x1f2d7c(0x249)]=_0x547bfb[_0x1f2d7c(0x249)]||_0x1f2d7c(0x1f5),this['resumeId']=_0x1f2d7c(0x270)+_0x547bfb[_0x1f2d7c(0x213)]+'-'+Date[_0x1f2d7c(0x260)]()['toString'](0x24),this['heartbeatInterval']=_0x547bfb[_0x1f2d7c(0x24d)]??0x2bf20,this[_0x1f2d7c(0x208)]=_0x547bfb[_0x1f2d7c(0x208)]??0xbb8,_0x547bfb[_0x1f2d7c(0x20f)]!==!0x1)this['connect']();}[a0_0x5e3fe2(0x215)](_0x54002a){const _0x568f97=a0_0x5e3fe2;console[_0x568f97(0x215)]('['+new Date()[_0x568f97(0x211)]()[_0x568f97(0x1ff)](0x0,0x8)+_0x568f97(0x20b)+this[_0x568f97(0x213)]+']\x20'+_0x54002a);}async[a0_0x5e3fe2(0x250)](_0x40cc8b,_0x2a6546){const _0x39cfe6=a0_0x5e3fe2;let _0x5bc675={'Content-Type':_0x39cfe6(0x21a),'Accept':_0x39cfe6(0x219)};if(this[_0x39cfe6(0x205)])_0x5bc675['Authorization']=_0x39cfe6(0x232)+this[_0x39cfe6(0x205)];let _0x35b798=await(await fetch(this[_0x39cfe6(0x22e)]+_0x39cfe6(0x234),{'method':'POST','headers':_0x5bc675,'body':JSON[_0x39cfe6(0x24b)]({'jsonrpc':_0x39cfe6(0x26a),'id':Date[_0x39cfe6(0x260)](),'method':_0x39cfe6(0x265),'params':{'name':_0x40cc8b,'arguments':_0x2a6546}})}))[_0x39cfe6(0x20d)](),_0x4b3066=_0x35b798['match'](/data: (.+)/),_0x2d2ec5=_0x4b3066?JSON[_0x39cfe6(0x21e)](_0x4b3066[0x1]):JSON[_0x39cfe6(0x21e)](_0x35b798),_0x5c6582=_0x2d2ec5?.[_0x39cfe6(0x22f)]?.[_0x39cfe6(0x1f9)]?.[0x0]?.[_0x39cfe6(0x20d)];return _0x5c6582?JSON[_0x39cfe6(0x21e)](_0x5c6582):_0x2d2ec5;}async[a0_0x5e3fe2(0x248)](){const _0x58d3ec=a0_0x5e3fe2;if(this[_0x58d3ec(0x221)])return;this[_0x58d3ec(0x221)]=!0x0,await this[_0x58d3ec(0x242)](_0x58d3ec(0x24a)),this[_0x58d3ec(0x215)](_0x58d3ec(0x22d)),this[_0x58d3ec(0x266)]=setInterval(()=>{const _0xf6003e=_0x58d3ec;this[_0xf6003e(0x242)](_0xf6003e(0x24a))[_0xf6003e(0x212)](_0x1cc698=>this[_0xf6003e(0x215)](_0xf6003e(0x252)+_0x1cc698[_0xf6003e(0x1f4)]));},this['heartbeatInterval']),this[_0x58d3ec(0x1fd)]();}async['disconnect'](){const _0x5994b5=a0_0x5e3fe2;if(this[_0x5994b5(0x221)]=!0x1,this['sseAbort']?.[_0x5994b5(0x236)](),this[_0x5994b5(0x266)])clearInterval(this[_0x5994b5(0x266)]);await this[_0x5994b5(0x242)](_0x5994b5(0x218))[_0x5994b5(0x212)](()=>{}),this[_0x5994b5(0x215)](_0x5994b5(0x230));}async[a0_0x5e3fe2(0x201)](_0x420efe,_0x5cf5e5,_0x1b6fe6='normal'){const _0x1af921=a0_0x5e3fe2;return Y({'alias':_0x420efe,'fromAlias':this[_0x1af921(0x213)]},{'log':_0x252e40=>console['log'](_0x252e40),'send':()=>this['call']('send_task',{'alias':_0x420efe,'task':_0x5cf5e5,'priority':_0x1b6fe6,'from_session':this[_0x1af921(0x213)]})});}async['message'](_0x3aed4f,_0x1e4f3a){const _0x17b728=a0_0x5e3fe2;return this['call'](_0x17b728(0x26b),{'alias':_0x3aed4f,'message':_0x1e4f3a,'from_session':this['alias']});}async[a0_0x5e3fe2(0x206)](_0x22161d,_0x2e37da,_0x33240a=a0_0x5e3fe2(0x1fe)){const _0x4f1336=a0_0x5e3fe2;return this['call'](_0x4f1336(0x267),{'in_reply_to':_0x22161d,'text':_0x2e37da,'status':_0x33240a});}async[a0_0x5e3fe2(0x242)](_0xf97210,_0x5ccdfc){const _0x2fcf6f=a0_0x5e3fe2;return this[_0x2fcf6f(0x250)]('report_status',{'resume_id':this[_0x2fcf6f(0x244)],'alias':this[_0x2fcf6f(0x213)],'status':_0xf97210,'server':a0_0x1952d2(),'hostname':a0_0x1952d2(),'agent':this['agent'],'project_dir':process[_0x2fcf6f(0x217)](),..._0x5ccdfc});}async[a0_0x5e3fe2(0x24e)](){const _0x39c504=a0_0x5e3fe2;return this['call'](_0x39c504(0x225),{});}async['broadcast'](_0x4c0167,_0x289935){const _0x1e0946=a0_0x5e3fe2;return this[_0x1e0946(0x250)](_0x1e0946(0x24c),{'message':_0x4c0167,'filter_server':_0x289935?.[_0x1e0946(0x258)],'filter_status':_0x289935?.['status']});}async[a0_0x5e3fe2(0x1fd)](){const _0x432482=a0_0x5e3fe2;let _0x211aac=encodeURIComponent(this[_0x432482(0x213)]),_0x40ce49=this['url']+_0x432482(0x25f)+_0x211aac,_0x1557fa=this['reconnectDelay'];while(this[_0x432482(0x221)]){try{this[_0x432482(0x254)]=new AbortController();let _0x436a75={'Accept':_0x432482(0x229)};if(this[_0x432482(0x205)])_0x436a75[_0x432482(0x26f)]=_0x432482(0x232)+this[_0x432482(0x205)];let _0x3320bf=await fetch(_0x40ce49,{'headers':_0x436a75,'signal':this[_0x432482(0x254)][_0x432482(0x24f)]});if(!_0x3320bf['ok']||!_0x3320bf['body']){this[_0x432482(0x215)](_0x432482(0x204)+_0x3320bf['status']),await this[_0x432482(0x269)](_0x1557fa),_0x1557fa=Math['min'](_0x1557fa*1.5,0xea60);continue;}_0x1557fa=this['reconnectDelay'];let _0x474f39=_0x3320bf[_0x432482(0x257)][_0x432482(0x21b)](),_0x387e8b=new TextDecoder(),_0x485b6e='';while(this[_0x432482(0x221)]){let {done:_0x42953f,value:_0x519dda}=await _0x474f39['read']();if(_0x42953f)break;_0x485b6e+=_0x387e8b[_0x432482(0x23b)](_0x519dda,{'stream':!0x0});let _0x5af355=_0x485b6e['split']('\x0a');_0x485b6e=_0x5af355[_0x432482(0x209)]()||'';for(let _0x49b6d6 of _0x5af355){if(!_0x49b6d6[_0x432482(0x227)](_0x432482(0x241)))continue;try{let _0x55052b=JSON['parse'](_0x49b6d6[_0x432482(0x1ff)](0x6));if(_0x55052b['type']==='connected'){this['log'](_0x432482(0x259)),this[_0x432482(0x25b)]('connected');continue;}if(_0x55052b[_0x432482(0x223)]===_0x432482(0x256)||_0x55052b['type']===_0x432482(0x1f6)||_0x55052b['type']===_0x432482(0x24c))await this[_0x432482(0x22a)]();}catch{}}}}catch(_0x4e0004){if(_0x4e0004[_0x432482(0x224)]===_0x432482(0x25a))break;this['emit'](_0x432482(0x23c),_0x4e0004),this[_0x432482(0x215)](_0x432482(0x20e)+_0x4e0004[_0x432482(0x1f4)]);}if(this[_0x432482(0x221)])this[_0x432482(0x25b)](_0x432482(0x230)),this[_0x432482(0x215)](_0x432482(0x23d)+_0x1557fa/0x3e8+'s...'),await this[_0x432482(0x269)](_0x1557fa),_0x1557fa=Math[_0x432482(0x247)](_0x1557fa*1.5,0xea60);}}async[a0_0x5e3fe2(0x22a)](){const _0x49dd2d=a0_0x5e3fe2;try{let _0x56a99b=(await this[_0x49dd2d(0x250)](_0x49dd2d(0x245),{'alias':this['alias'],'limit':0xa}))?.['messages']||[];for(let _0x3b1b36 of _0x56a99b)await this[_0x49dd2d(0x250)](_0x49dd2d(0x216),{'alias':this['alias'],'message_id':_0x3b1b36['id']}),this[_0x49dd2d(0x215)]('←\x20'+_0x3b1b36['from_session']+':\x20'+_0x3b1b36[_0x49dd2d(0x1f9)][_0x49dd2d(0x1ff)](0x0,0x3c)),this[_0x49dd2d(0x25b)](_0x49dd2d(0x1fa),_0x3b1b36),this[_0x49dd2d(0x25b)](_0x49dd2d(0x1f4),_0x3b1b36);}catch(_0x1c4c94){this[_0x49dd2d(0x215)](_0x49dd2d(0x255)+_0x1c4c94['message']);}}['sleep'](_0x406e53){return new Promise(_0x4ab446=>setTimeout(_0x4ab446,_0x406e53));}}var F=$;export{F as default,$ as CommHub};
1
+ const a0_0x1eeda4=a0_0x400d;(function(_0x3b890d,_0x401cb8){const _0x1d08c9=a0_0x400d,_0x395ce4=_0x3b890d();while(!![]){try{const _0x1aa0bc=parseInt(_0x1d08c9(0x10f))/0x1+-parseInt(_0x1d08c9(0x114))/0x2+-parseInt(_0x1d08c9(0x100))/0x3*(parseInt(_0x1d08c9(0x158))/0x4)+-parseInt(_0x1d08c9(0xf4))/0x5+parseInt(_0x1d08c9(0x147))/0x6*(parseInt(_0x1d08c9(0x15c))/0x7)+-parseInt(_0x1d08c9(0x10c))/0x8*(-parseInt(_0x1d08c9(0x10b))/0x9)+parseInt(_0x1d08c9(0x129))/0xa*(parseInt(_0x1d08c9(0xfe))/0xb);if(_0x1aa0bc===_0x401cb8)break;else _0x395ce4['push'](_0x395ce4['shift']());}catch(_0x35157c){_0x395ce4['push'](_0x395ce4['shift']());}}}(a0_0x6119,0xc2650));import{EventEmitter as a0_0x401955}from'events';import{hostname as a0_0x23d19d}from'os';function a0_0x6119(){const _0x3ed8e0=['[commhub:task]\x20','from_session','stringify','\x20lifecycle=','SSE\x20reconnecting\x20in\x20','sdk-','duration_ms','log','report_status','\x20duration_ms=','registered','text','data:\x20','completed','min','task.expired','json','content','7216495pxpQQT','<missing>','processInbox','emit','CommHub\x20rejected\x20task','match','replace','tools/call','\x20network_id=','messages','2112vjTkpJ','<pending>','636YATamQ','\x20parent_task_id=','error','type','SSE\x20error:\x20','now','status','resumeId','disconnect','not_tracked','normal','3357RhcmPQ','5576fvdroG','connected','reconnectDelay','705481Pluyzo','inbox\x20error:\x20','<unknown>','AbortError','Authorization','1006638VwNEbL','parse','to_alias','heartbeatTimer','result','split','\x20from=','task.started','message_id','application/json,\x20text/event-stream','failed','networkId','\x20error=','call','token','new_message','delivered','error_code','/events/','offline','\x20transport=','77990pZtwGl','task.send.delivered','message','name','get_inbox','network_id','heartbeatInterval','broadcast','idle','signal','connect','Bearer\x20','new_task','fromAlias','mcp_http','send_message','sseAbort','abort','SSE\x20connected','sending','[REDACTED]','parentTaskId','decode','missing_task_id','pop','catch','alias','send_failed','send_reply','send','1018680cDvbhP','task_id','2.0','toTimeString','agent','unknown\x20error','text/event-stream','lifecycleTracking','task.send.start','slice','running','task.replied','from_alias','body','server','lifecycle_tracking','task.ack','1124CnAwpq','\x20task_id=','disconnected','parent_task_id','14QWTziV','url','sleep','transport','/mcp','\x20to=','connectSSE'];a0_0x6119=function(){return _0x3ed8e0;};return a0_0x6119();}function a0_0x400d(_0x54dba8,_0x19165f){_0x54dba8=_0x54dba8-0xeb;const _0x61193a=a0_0x6119();let _0x400dd3=_0x61193a[_0x54dba8];return _0x400dd3;}var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x52567a,_0xfe2edb)=>(_0x52567a??_0xfe2edb)[a0_0x1eeda4(0xfa)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x3274e8){const _0x325138=a0_0x1eeda4;return(_0x3274e8 instanceof Error?_0x3274e8[_0x325138(0x12b)]:String(_0x3274e8??_0x325138(0x14c)))[_0x325138(0xfa)](K,_0x325138(0x13d))[_0x325138(0xfa)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x325138(0x150)](0x0,0xf0);}function O(_0x258e36,_0x42399f=process.env.ANET_TASK_TRACE_FORMAT===a0_0x1eeda4(0xf2)){const _0x158585=a0_0x1eeda4;if(_0x42399f)return JSON[_0x158585(0x165)](_0x258e36);let _0x55d706=L(_0x258e36[_0x158585(0x15b)],_0x158585(0xf5)),_0x59c675=L(_0x258e36[_0x158585(0x148)],_0x158585(0xff)),_0x49b2ea=_0x258e36[_0x158585(0x125)]?_0x158585(0x120)+_0x258e36[_0x158585(0x125)]+':'+(_0x258e36['error_message']??''):'';return _0x158585(0x163)+_0x258e36['status']+_0x158585(0x11a)+L(_0x258e36[_0x158585(0x153)],_0x158585(0x111))+_0x158585(0x161)+L(_0x258e36[_0x158585(0x116)],_0x158585(0x111))+_0x158585(0x159)+_0x59c675+_0x158585(0x101)+_0x55d706+_0x158585(0xfc)+L(_0x258e36[_0x158585(0x12e)],_0x158585(0x111))+_0x158585(0x128)+_0x258e36[_0x158585(0x15f)]+_0x158585(0xeb)+_0x258e36[_0x158585(0x169)]+_0x158585(0x166)+_0x258e36[_0x158585(0x156)]+_0x49b2ea;}function U(_0x5a74d5){const _0x27d8c7=a0_0x1eeda4;return{'event':{'sending':_0x27d8c7(0x14f),'delivered':_0x27d8c7(0x12a),'failed':'task.send.failed','acked':_0x27d8c7(0x157),'started':_0x27d8c7(0x11b),'replied':_0x27d8c7(0x152),'expired':_0x27d8c7(0xf1)}[_0x5a74d5['status']],..._0x5a74d5};}function j(_0xa0ed7d){const _0x16ce19=a0_0x1eeda4;let _0xea0a5d=_0xa0ed7d?.['task_id']||_0xa0ed7d?.[_0x16ce19(0x11c)]||_0xa0ed7d?.['id'];if(_0xea0a5d)return String(_0xea0a5d);let _0x468844=_0xa0ed7d?.['content']?.[0x0]?.[_0x16ce19(0xed)];if(typeof _0x468844!=='string')return null;try{let _0x50eb97=JSON[_0x16ce19(0x115)](_0x468844);return _0x50eb97?.[_0x16ce19(0x148)]||_0x50eb97?.['message_id']||_0x50eb97?.['id']||null;}catch{return null;}}async function X(_0x3578d8,_0x16a2e6){const _0x14da3b=a0_0x1eeda4;let _0x42a173=_0x16a2e6[_0x14da3b(0x105)]??Date[_0x14da3b(0x105)],_0x207357=_0x42a173(),_0x5ddbdc=(_0x3e83ff,_0x35ae80,_0x3310e6,_0x42b1d8)=>{const _0x576729=_0x14da3b;_0x16a2e6['log'](O(U({'from_alias':_0x3578d8[_0x576729(0x136)],'to_alias':_0x3578d8['toAlias'],'task_id':_0x35ae80,'parent_task_id':_0x3578d8[_0x576729(0x13e)],'network_id':_0x3578d8[_0x576729(0x11f)],'transport':_0x3578d8['transport'],'status':_0x3e83ff,'duration_ms':_0x42a173()-_0x207357,'lifecycle_tracking':_0x3578d8[_0x576729(0x14e)],..._0x3310e6!==void 0x0?{'error_code':_0x42b1d8||_0x576729(0x144),'error_message':N(_0x3310e6)}:{}})));};_0x5ddbdc(_0x14da3b(0x13c),null);try{let _0x4b7822=await _0x16a2e6[_0x14da3b(0x146)](),_0x204d9a=j(_0x4b7822);if(_0x204d9a)_0x5ddbdc(_0x14da3b(0x124),_0x204d9a);else{if(_0x4b7822?.['ok']===!0x1||_0x4b7822?.[_0x14da3b(0x102)])_0x5ddbdc(_0x14da3b(0x11e),_0x204d9a,_0x4b7822?.[_0x14da3b(0x102)]||_0x14da3b(0xf8),'send_rejected');else _0x5ddbdc(_0x14da3b(0x11e),null,'CommHub\x20response\x20omitted\x20task_id',_0x14da3b(0x140));}return _0x4b7822;}catch(_0x4ff6a3){throw _0x5ddbdc('failed',null,_0x4ff6a3,'send_failed'),_0x4ff6a3;}}async function Y(_0x28e206,_0x5688d3){const _0x387656=a0_0x1eeda4;return X({'fromAlias':_0x28e206[_0x387656(0x136)],'toAlias':_0x28e206[_0x387656(0x143)],'parentTaskId':_0x28e206[_0x387656(0x13e)]||null,'networkId':_0x28e206[_0x387656(0x11f)]||null,'transport':_0x387656(0x137),'lifecycleTracking':_0x387656(0x109)},_0x5688d3);}class $ extends a0_0x401955{[a0_0x1eeda4(0x15d)];[a0_0x1eeda4(0x143)];['token'];[a0_0x1eeda4(0x14b)];['resumeId'];[a0_0x1eeda4(0x12f)];[a0_0x1eeda4(0x10e)];['heartbeatTimer'];[a0_0x1eeda4(0x139)];['running']=!0x1;constructor(_0x18f960){const _0x30c0a0=a0_0x1eeda4;super();if(this[_0x30c0a0(0x15d)]=_0x18f960[_0x30c0a0(0x15d)][_0x30c0a0(0xfa)](/\/$/,''),this[_0x30c0a0(0x143)]=_0x18f960[_0x30c0a0(0x143)],this['token']=_0x18f960['token'],this[_0x30c0a0(0x14b)]=_0x18f960[_0x30c0a0(0x14b)]||'sdk',this['resumeId']=_0x30c0a0(0x168)+_0x18f960[_0x30c0a0(0x143)]+'-'+Date[_0x30c0a0(0x105)]()['toString'](0x24),this[_0x30c0a0(0x12f)]=_0x18f960[_0x30c0a0(0x12f)]??0x2bf20,this['reconnectDelay']=_0x18f960[_0x30c0a0(0x10e)]??0xbb8,_0x18f960['autoConnect']!==!0x1)this[_0x30c0a0(0x133)]();}[a0_0x1eeda4(0x16a)](_0x1c494a){const _0x550eba=a0_0x1eeda4;console[_0x550eba(0x16a)]('['+new Date()[_0x550eba(0x14a)]()[_0x550eba(0x150)](0x0,0x8)+']\x20[commhub:'+this[_0x550eba(0x143)]+']\x20'+_0x1c494a);}async[a0_0x1eeda4(0x121)](_0x45733d,_0x52d059){const _0x2ddea5=a0_0x1eeda4;let _0x3a00fe={'Content-Type':'application/json','Accept':_0x2ddea5(0x11d)};if(this[_0x2ddea5(0x122)])_0x3a00fe[_0x2ddea5(0x113)]=_0x2ddea5(0x134)+this[_0x2ddea5(0x122)];let _0x19f4f2=await(await fetch(this[_0x2ddea5(0x15d)]+_0x2ddea5(0x160),{'method':'POST','headers':_0x3a00fe,'body':JSON[_0x2ddea5(0x165)]({'jsonrpc':_0x2ddea5(0x149),'id':Date['now'](),'method':_0x2ddea5(0xfb),'params':{'name':_0x45733d,'arguments':_0x52d059}})}))[_0x2ddea5(0xed)](),_0x455d85=_0x19f4f2[_0x2ddea5(0xf9)](/data: (.+)/),_0x417801=_0x455d85?JSON[_0x2ddea5(0x115)](_0x455d85[0x1]):JSON[_0x2ddea5(0x115)](_0x19f4f2),_0x15c197=_0x417801?.[_0x2ddea5(0x118)]?.[_0x2ddea5(0xf3)]?.[0x0]?.[_0x2ddea5(0xed)];return _0x15c197?JSON[_0x2ddea5(0x115)](_0x15c197):_0x417801;}async[a0_0x1eeda4(0x133)](){const _0x40e558=a0_0x1eeda4;if(this[_0x40e558(0x151)])return;this[_0x40e558(0x151)]=!0x0,await this['status'](_0x40e558(0x131)),this['log'](_0x40e558(0xec)),this['heartbeatTimer']=setInterval(()=>{const _0x295a2f=_0x40e558;this[_0x295a2f(0x106)](_0x295a2f(0x131))[_0x295a2f(0x142)](_0x407caf=>this['log']('heartbeat\x20failed:\x20'+_0x407caf[_0x295a2f(0x12b)]));},this['heartbeatInterval']),this[_0x40e558(0x162)]();}async[a0_0x1eeda4(0x108)](){const _0x2b55c9=a0_0x1eeda4;if(this[_0x2b55c9(0x151)]=!0x1,this[_0x2b55c9(0x139)]?.[_0x2b55c9(0x13a)](),this[_0x2b55c9(0x117)])clearInterval(this[_0x2b55c9(0x117)]);await this['status'](_0x2b55c9(0x127))[_0x2b55c9(0x142)](()=>{}),this[_0x2b55c9(0x16a)]('disconnected');}async[a0_0x1eeda4(0x146)](_0x41f1d5,_0x17989c,_0x19948b=a0_0x1eeda4(0x10a)){const _0x29fef5=a0_0x1eeda4;return Y({'alias':_0x41f1d5,'fromAlias':this[_0x29fef5(0x143)]},{'log':_0x198e8e=>console['log'](_0x198e8e),'send':()=>this[_0x29fef5(0x121)]('send_task',{'alias':_0x41f1d5,'task':_0x17989c,'priority':_0x19948b,'from_session':this[_0x29fef5(0x143)]})});}async[a0_0x1eeda4(0x12b)](_0x1c5644,_0x4bf349){const _0x2a8745=a0_0x1eeda4;return this[_0x2a8745(0x121)](_0x2a8745(0x138),{'alias':_0x1c5644,'message':_0x4bf349,'from_session':this[_0x2a8745(0x143)]});}async['reply'](_0x41d576,_0x3fae69,_0x5b564a=a0_0x1eeda4(0xef)){const _0x19d9fa=a0_0x1eeda4;return this[_0x19d9fa(0x121)](_0x19d9fa(0x145),{'in_reply_to':_0x41d576,'text':_0x3fae69,'status':_0x5b564a});}async[a0_0x1eeda4(0x106)](_0x5f2240,_0x2749b2){const _0x381bbf=a0_0x1eeda4;return this[_0x381bbf(0x121)](_0x381bbf(0x16b),{'resume_id':this[_0x381bbf(0x107)],'alias':this[_0x381bbf(0x143)],'status':_0x5f2240,'server':a0_0x23d19d(),'hostname':a0_0x23d19d(),'agent':this[_0x381bbf(0x14b)],'project_dir':process['cwd'](),..._0x2749b2});}async['getAllStatus'](){const _0x2f9ef1=a0_0x1eeda4;return this[_0x2f9ef1(0x121)]('get_all_status',{});}async['broadcast'](_0x44dbe1,_0x1b86f7){const _0x182e80=a0_0x1eeda4;return this[_0x182e80(0x121)]('broadcast',{'message':_0x44dbe1,'filter_server':_0x1b86f7?.[_0x182e80(0x155)],'filter_status':_0x1b86f7?.[_0x182e80(0x106)]});}async['connectSSE'](){const _0x241097=a0_0x1eeda4;let _0x3e3621=encodeURIComponent(this[_0x241097(0x143)]),_0x3097ad=this[_0x241097(0x15d)]+_0x241097(0x126)+_0x3e3621,_0x387df5=this[_0x241097(0x10e)];while(this[_0x241097(0x151)]){try{this[_0x241097(0x139)]=new AbortController();let _0x25c3ba={'Accept':_0x241097(0x14d)};if(this[_0x241097(0x122)])_0x25c3ba['Authorization']=_0x241097(0x134)+this[_0x241097(0x122)];let _0x500b87=await fetch(_0x3097ad,{'headers':_0x25c3ba,'signal':this['sseAbort'][_0x241097(0x132)]});if(!_0x500b87['ok']||!_0x500b87[_0x241097(0x154)]){this['log']('SSE\x20failed:\x20'+_0x500b87[_0x241097(0x106)]),await this[_0x241097(0x15e)](_0x387df5),_0x387df5=Math[_0x241097(0xf0)](_0x387df5*1.5,0xea60);continue;}_0x387df5=this[_0x241097(0x10e)];let _0x5910e3=_0x500b87['body']['getReader'](),_0x2bfdaf=new TextDecoder(),_0x40fc14='';while(this[_0x241097(0x151)]){let {done:_0x32709e,value:_0x1419cd}=await _0x5910e3['read']();if(_0x32709e)break;_0x40fc14+=_0x2bfdaf[_0x241097(0x13f)](_0x1419cd,{'stream':!0x0});let _0x28cba5=_0x40fc14[_0x241097(0x119)]('\x0a');_0x40fc14=_0x28cba5[_0x241097(0x141)]()||'';for(let _0x53b75e of _0x28cba5){if(!_0x53b75e['startsWith'](_0x241097(0xee)))continue;try{let _0x23ecd3=JSON[_0x241097(0x115)](_0x53b75e[_0x241097(0x150)](0x6));if(_0x23ecd3[_0x241097(0x103)]==='connected'){this[_0x241097(0x16a)](_0x241097(0x13b)),this[_0x241097(0xf7)](_0x241097(0x10d));continue;}if(_0x23ecd3[_0x241097(0x103)]===_0x241097(0x135)||_0x23ecd3[_0x241097(0x103)]===_0x241097(0x123)||_0x23ecd3[_0x241097(0x103)]===_0x241097(0x130))await this['processInbox']();}catch{}}}}catch(_0x3e1f11){if(_0x3e1f11[_0x241097(0x12c)]===_0x241097(0x112))break;this[_0x241097(0xf7)](_0x241097(0x102),_0x3e1f11),this[_0x241097(0x16a)](_0x241097(0x104)+_0x3e1f11['message']);}if(this['running'])this[_0x241097(0xf7)](_0x241097(0x15a)),this[_0x241097(0x16a)](_0x241097(0x167)+_0x387df5/0x3e8+'s...'),await this[_0x241097(0x15e)](_0x387df5),_0x387df5=Math[_0x241097(0xf0)](_0x387df5*1.5,0xea60);}}async[a0_0x1eeda4(0xf6)](){const _0xb7a773=a0_0x1eeda4;try{let _0x1bba75=(await this[_0xb7a773(0x121)](_0xb7a773(0x12d),{'alias':this[_0xb7a773(0x143)],'limit':0xa}))?.[_0xb7a773(0xfd)]||[];for(let _0x298e91 of _0x1bba75)await this['call']('ack_inbox',{'alias':this[_0xb7a773(0x143)],'message_id':_0x298e91['id']}),this[_0xb7a773(0x16a)]('←\x20'+_0x298e91[_0xb7a773(0x164)]+':\x20'+_0x298e91[_0xb7a773(0xf3)][_0xb7a773(0x150)](0x0,0x3c)),this[_0xb7a773(0xf7)]('task',_0x298e91),this[_0xb7a773(0xf7)](_0xb7a773(0x12b),_0x298e91);}catch(_0x2cc0f8){this[_0xb7a773(0x16a)](_0xb7a773(0x110)+_0x2cc0f8[_0xb7a773(0x12b)]);}}['sleep'](_0x413823){return new Promise(_0x314fcb=>setTimeout(_0x314fcb,_0x413823));}}var F=$;export{F as default,$ as CommHub};
@@ -30,6 +30,8 @@ export interface CollectEnv {
30
30
  tmuxSessions?: () => Set<string>;
31
31
  pidAlive?: (pid: number) => boolean;
32
32
  }
33
+ export declare function realTmuxSessions(): Set<string>;
34
+ export declare function realPidAlive(pid: number): boolean;
33
35
  /** Only codex nodes: co-presence (codex-app-server) and codex-sdk. */
34
36
  export declare function collectCodexRows(nodes: CodexMenuNode[], env: CollectEnv): CodexNodeRow[];
35
37
  export declare function renderCodexTable(rows: CodexNodeRow[], cwd: string): string;
@@ -66,10 +68,29 @@ export interface MenuIO {
66
68
  readLine(prompt: string): Promise<string | null>;
67
69
  }
68
70
  export type Runner = (cmd: PlannedCommand) => Promise<number>;
71
+ export declare function pick(io: MenuIO, prompt: string, max: number, allowAdopt?: boolean): Promise<number | "adopt" | null>;
69
72
  /** Returns the process exit code. Runs at most one command. */
70
73
  export declare function codexMenu(rows: CodexNodeRow[], io: MenuIO, run: Runner, ctx: {
71
74
  cwd: string;
72
75
  }): Promise<number>;
76
+ /** The action step for one codex node. #561: `anet node` (all runtimes) hands codex nodes off to this. */
77
+ export declare function codexNodeActions(row: CodexNodeRow, io: MenuIO, run: Runner, ctx: {
78
+ cwd: string;
79
+ }): Promise<number>;
80
+ /** Ask for a model id; null (and a message) when none / not a plain id. Shared with node-menu.ts (#561). */
81
+ export declare function askModel(io: MenuIO, current: string): Promise<string | null>;
82
+ /**
83
+ * Print the exact command, then ask: y/N, or (typedName) the node's name. Run it only then.
84
+ * The one gate both menus go through (#532 codex, #561 every runtime).
85
+ */
86
+ export declare function confirmAndRun(io: MenuIO, run: Runner, cmd: PlannedCommand, row: {
87
+ alias: string;
88
+ }, typedName: boolean): Promise<number>;
89
+ /** A line queue over one readline: scripted input that arrives in one chunk is not lost between prompts. */
90
+ export declare function readlineIO(): MenuIO & {
91
+ close(): void;
92
+ };
93
+ export declare function realRunner(beforeRun: () => void): Runner;
73
94
  /** Entry from cli.ts (`anet node codex` with no arguments). Returns the exit code. */
74
95
  export declare function runCodexMenu(nodes: CodexMenuNode[], opts: {
75
96
  nodesDir: string;
@@ -0,0 +1,40 @@
1
+ import { type CodexMenuNode, type CodexNodeRow, type CollectEnv, type MenuIO, type PlannedCommand, type Runner } from "./codex-menu";
2
+ import { type RuntimeName } from "./normalize-runtime";
3
+ export interface NodeRow {
4
+ id: string;
5
+ alias: string;
6
+ runtime: RuntimeName;
7
+ /** "running" | "stopped" (codex co-presence may say "partial 1/3"). */
8
+ state: string;
9
+ running: boolean;
10
+ model: string;
11
+ modelIsDefault: boolean;
12
+ /** Shared human + agent TUI (grok-build-cli / opencode-cli co-presence, codex-app-server). */
13
+ copresence: boolean;
14
+ /** The runtime has a TUI to enter (claude-code-cli, or any co-presence node). */
15
+ hasTui: boolean;
16
+ /** Set for codex-sdk / codex-app-server: these go to the #532 codex actions. */
17
+ codex: CodexNodeRow | null;
18
+ }
19
+ export declare function collectNodeRows(nodes: CodexMenuNode[], env: CollectEnv): NodeRow[];
20
+ export declare function renderNodeTable(rows: NodeRow[], cwd: string): string;
21
+ export declare const NODE_CHEAT_SHEET: string;
22
+ export type NodeAction = "start" | "stop" | "restart" | "attach" | "log" | "model" | "delete";
23
+ export declare function nodeActions(row: NodeRow): {
24
+ key: NodeAction;
25
+ label: string;
26
+ }[];
27
+ export declare function planNodeAction(row: NodeRow, action: NodeAction, input?: {
28
+ model?: string;
29
+ }): PlannedCommand;
30
+ /** Returns the process exit code. Runs at most one command. */
31
+ export declare function nodeMenu(rows: NodeRow[], io: MenuIO, run: Runner, ctx: {
32
+ cwd: string;
33
+ }): Promise<number>;
34
+ /** Entry from cli.ts (bare `anet node`). Returns the exit code. */
35
+ export declare function runNodeMenu(nodes: CodexMenuNode[], opts: {
36
+ nodesDir: string;
37
+ home: string;
38
+ cwd?: string;
39
+ usageLine?: string;
40
+ }): Promise<number>;