@sleep2agi/agent-network 2.3.0-preview.141 → 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.
package/dist/src/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a0_0x26dbc9=a0_0xe7e2;(function(_0x1ae6c2,_0x907afb){const _0x1a0ecd=a0_0xe7e2,_0x15ad19=_0x1ae6c2();while(!![]){try{const _0x10bb00=parseInt(_0x1a0ecd(0x1ad))/0x1+-parseInt(_0x1a0ecd(0x1b1))/0x2+parseInt(_0x1a0ecd(0x157))/0x3*(-parseInt(_0x1a0ecd(0x15d))/0x4)+-parseInt(_0x1a0ecd(0x162))/0x5*(-parseInt(_0x1a0ecd(0x1a7))/0x6)+-parseInt(_0x1a0ecd(0x183))/0x7+-parseInt(_0x1a0ecd(0x169))/0x8*(-parseInt(_0x1a0ecd(0x173))/0x9)+parseInt(_0x1a0ecd(0x1a2))/0xa;if(_0x10bb00===_0x907afb)break;else _0x15ad19['push'](_0x15ad19['shift']());}catch(_0xa8c021){_0x15ad19['push'](_0x15ad19['shift']());}}}(a0_0x22de,0x50c44));import{EventEmitter as a0_0x2109ca}from'events';import{hostname as a0_0x483dac}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x4376e3,_0x4a0b40)=>(_0x4376e3??_0x4a0b40)[a0_0x26dbc9(0x19a)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x26dbc9(0x179)](0x0,0xf0);function N(_0x1b3b19){const _0x591008=a0_0x26dbc9;return(_0x1b3b19 instanceof Error?_0x1b3b19[_0x591008(0x146)]:String(_0x1b3b19??_0x591008(0x18d)))[_0x591008(0x19a)](K,_0x591008(0x15b))[_0x591008(0x19a)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x591008(0x179)](0x0,0xf0);}function O(_0x7a2e00,_0x55300a=process.env.ANET_TASK_TRACE_FORMAT===a0_0x26dbc9(0x15e)){const _0x10a5e3=a0_0x26dbc9;if(_0x55300a)return JSON[_0x10a5e3(0x181)](_0x7a2e00);let _0x2ad68c=L(_0x7a2e00[_0x10a5e3(0x15f)],'<missing>'),_0x55f87b=L(_0x7a2e00['task_id'],_0x10a5e3(0x184)),_0x40a04f=_0x7a2e00[_0x10a5e3(0x1aa)]?_0x10a5e3(0x199)+_0x7a2e00[_0x10a5e3(0x1aa)]+':'+(_0x7a2e00[_0x10a5e3(0x1af)]??''):'';return'[commhub:task]\x20'+_0x7a2e00[_0x10a5e3(0x151)]+_0x10a5e3(0x175)+L(_0x7a2e00[_0x10a5e3(0x188)],_0x10a5e3(0x14c))+_0x10a5e3(0x143)+L(_0x7a2e00[_0x10a5e3(0x14e)],_0x10a5e3(0x14c))+_0x10a5e3(0x18a)+_0x55f87b+_0x10a5e3(0x168)+_0x2ad68c+'\x20network_id='+L(_0x7a2e00[_0x10a5e3(0x142)],_0x10a5e3(0x14c))+_0x10a5e3(0x17b)+_0x7a2e00['transport']+_0x10a5e3(0x148)+_0x7a2e00['duration_ms']+_0x10a5e3(0x177)+_0x7a2e00[_0x10a5e3(0x171)]+_0x40a04f;}function U(_0x56a9b1){const _0x205956=a0_0x26dbc9;return{'event':{'sending':'task.send.start','delivered':'task.send.delivered','failed':_0x205956(0x161),'acked':_0x205956(0x1a0),'started':_0x205956(0x16a),'replied':_0x205956(0x17d),'expired':'task.expired'}[_0x56a9b1[_0x205956(0x151)]],..._0x56a9b1};}function a0_0xe7e2(_0x321c85,_0xc02cc){_0x321c85=_0x321c85-0x13c;const _0x22debb=a0_0x22de();let _0xe7e268=_0x22debb[_0x321c85];return _0xe7e268;}function a0_0x22de(){const _0x9306b5=['report_status','messages','network_id','\x20to=','Bearer\x20','sleep','message','resumeId','\x20duration_ms=','transport','content','idle','<unknown>','POST','to_alias','delivered','match','status','send',']\x20[commhub:','application/json,\x20text/event-stream','from_session','send_reply','543kehgnL','send_message','url','getReader','[REDACTED]','read','11240doTLfl','json','parent_task_id','disconnect','task.send.failed','30zswahA','reconnectDelay','server','send_task','connectSSE','error','\x20parent_task_id=','5160VYJiwg','task.started','min','pop','getAllStatus','type','cwd','networkId','lifecycle_tracking','new_message','6705mpjeTf','SSE\x20failed:\x20','\x20from=','split','\x20lifecycle=','broadcast','slice','sending','\x20transport=','heartbeatInterval','task.replied','processInbox','sseAbort','now','stringify','catch','3280144UMlZoU','<pending>','heartbeatTimer','body','token','from_alias','log','\x20task_id=','autoConnect','failed','unknown\x20error','message_id','text/event-stream','agent','fromAlias','CommHub\x20rejected\x20task','task','registered','inbox\x20error:\x20','tools/call','CommHub\x20response\x20omitted\x20task_id','s...','\x20error=','replace','text','/mcp','parse','alias','running','task.ack','/events/','4527910ulBbfi','parentTaskId','heartbeat\x20failed:\x20','not_tracked','disconnected','120546jGSYWg','toTimeString','task_id','error_code','SSE\x20connected','completed','392365medzdL','name','error_message','SSE\x20reconnecting\x20in\x20','276410LAEabL','send_failed','emit','Authorization','AbortError','call','connect','SSE\x20error:\x20','toString'];a0_0x22de=function(){return _0x9306b5;};return a0_0x22de();}function j(_0x194d61){const _0x43c526=a0_0x26dbc9;let _0x5aec79=_0x194d61?.[_0x43c526(0x1a9)]||_0x194d61?.[_0x43c526(0x18e)]||_0x194d61?.['id'];if(_0x5aec79)return String(_0x5aec79);let _0x857678=_0x194d61?.[_0x43c526(0x14a)]?.[0x0]?.[_0x43c526(0x19b)];if(typeof _0x857678!=='string')return null;try{let _0x2ff496=JSON[_0x43c526(0x19d)](_0x857678);return _0x2ff496?.[_0x43c526(0x1a9)]||_0x2ff496?.[_0x43c526(0x18e)]||_0x2ff496?.['id']||null;}catch{return null;}}async function X(_0x13d82d,_0x19178a){const _0x336a76=a0_0x26dbc9;let _0x4841bd=_0x19178a[_0x336a76(0x180)]??Date['now'],_0x2b9e12=_0x4841bd(),_0x163d09=(_0x48017c,_0x5090e0,_0x4da7bf,_0x4924c4)=>{const _0x594685=_0x336a76;_0x19178a[_0x594685(0x189)](O(U({'from_alias':_0x13d82d[_0x594685(0x191)],'to_alias':_0x13d82d['toAlias'],'task_id':_0x5090e0,'parent_task_id':_0x13d82d[_0x594685(0x1a3)],'network_id':_0x13d82d[_0x594685(0x170)],'transport':_0x13d82d[_0x594685(0x149)],'status':_0x48017c,'duration_ms':_0x4841bd()-_0x2b9e12,'lifecycle_tracking':_0x13d82d['lifecycleTracking'],..._0x4da7bf!==void 0x0?{'error_code':_0x4924c4||'send_failed','error_message':N(_0x4da7bf)}:{}})));};_0x163d09(_0x336a76(0x17a),null);try{let _0x436ba6=await _0x19178a[_0x336a76(0x152)](),_0x287f4f=j(_0x436ba6);if(_0x287f4f)_0x163d09(_0x336a76(0x14f),_0x287f4f);else{if(_0x436ba6?.['ok']===!0x1||_0x436ba6?.[_0x336a76(0x167)])_0x163d09(_0x336a76(0x18c),_0x287f4f,_0x436ba6?.['error']||_0x336a76(0x192),'send_rejected');else _0x163d09(_0x336a76(0x18c),null,_0x336a76(0x197),'missing_task_id');}return _0x436ba6;}catch(_0x4f5fdc){throw _0x163d09('failed',null,_0x4f5fdc,_0x336a76(0x1b2)),_0x4f5fdc;}}async function Y(_0x3bef1d,_0x5e23d3){const _0x55c0ce=a0_0x26dbc9;return X({'fromAlias':_0x3bef1d[_0x55c0ce(0x191)],'toAlias':_0x3bef1d[_0x55c0ce(0x19e)],'parentTaskId':_0x3bef1d[_0x55c0ce(0x1a3)]||null,'networkId':_0x3bef1d[_0x55c0ce(0x170)]||null,'transport':'mcp_http','lifecycleTracking':_0x55c0ce(0x1a5)},_0x5e23d3);}class $ extends a0_0x2109ca{[a0_0x26dbc9(0x159)];[a0_0x26dbc9(0x19e)];[a0_0x26dbc9(0x187)];['agent'];[a0_0x26dbc9(0x147)];[a0_0x26dbc9(0x17c)];[a0_0x26dbc9(0x163)];[a0_0x26dbc9(0x185)];[a0_0x26dbc9(0x17f)];[a0_0x26dbc9(0x19f)]=!0x1;constructor(_0x18987f){const _0x4e7fbc=a0_0x26dbc9;super();if(this[_0x4e7fbc(0x159)]=_0x18987f[_0x4e7fbc(0x159)][_0x4e7fbc(0x19a)](/\/$/,''),this[_0x4e7fbc(0x19e)]=_0x18987f[_0x4e7fbc(0x19e)],this['token']=_0x18987f[_0x4e7fbc(0x187)],this[_0x4e7fbc(0x190)]=_0x18987f[_0x4e7fbc(0x190)]||'sdk',this[_0x4e7fbc(0x147)]='sdk-'+_0x18987f['alias']+'-'+Date[_0x4e7fbc(0x180)]()[_0x4e7fbc(0x13f)](0x24),this[_0x4e7fbc(0x17c)]=_0x18987f[_0x4e7fbc(0x17c)]??0x2bf20,this[_0x4e7fbc(0x163)]=_0x18987f[_0x4e7fbc(0x163)]??0xbb8,_0x18987f[_0x4e7fbc(0x18b)]!==!0x1)this[_0x4e7fbc(0x13d)]();}[a0_0x26dbc9(0x189)](_0x13f39f){const _0x3352e0=a0_0x26dbc9;console[_0x3352e0(0x189)]('['+new Date()[_0x3352e0(0x1a8)]()[_0x3352e0(0x179)](0x0,0x8)+_0x3352e0(0x153)+this[_0x3352e0(0x19e)]+']\x20'+_0x13f39f);}async['call'](_0xb5f92d,_0x549a28){const _0x191931=a0_0x26dbc9;let _0x3dae98={'Content-Type':'application/json','Accept':_0x191931(0x154)};if(this[_0x191931(0x187)])_0x3dae98[_0x191931(0x1b4)]=_0x191931(0x144)+this[_0x191931(0x187)];let _0x211c4b=await(await fetch(this[_0x191931(0x159)]+_0x191931(0x19c),{'method':_0x191931(0x14d),'headers':_0x3dae98,'body':JSON[_0x191931(0x181)]({'jsonrpc':'2.0','id':Date[_0x191931(0x180)](),'method':_0x191931(0x196),'params':{'name':_0xb5f92d,'arguments':_0x549a28}})}))[_0x191931(0x19b)](),_0x3352f8=_0x211c4b[_0x191931(0x150)](/data: (.+)/),_0x25a00d=_0x3352f8?JSON[_0x191931(0x19d)](_0x3352f8[0x1]):JSON[_0x191931(0x19d)](_0x211c4b),_0x4e2c81=_0x25a00d?.['result']?.[_0x191931(0x14a)]?.[0x0]?.[_0x191931(0x19b)];return _0x4e2c81?JSON[_0x191931(0x19d)](_0x4e2c81):_0x25a00d;}async[a0_0x26dbc9(0x13d)](){const _0x14773e=a0_0x26dbc9;if(this[_0x14773e(0x19f)])return;this[_0x14773e(0x19f)]=!0x0,await this[_0x14773e(0x151)](_0x14773e(0x14b)),this[_0x14773e(0x189)](_0x14773e(0x194)),this['heartbeatTimer']=setInterval(()=>{const _0x421c0c=_0x14773e;this[_0x421c0c(0x151)](_0x421c0c(0x14b))[_0x421c0c(0x182)](_0x239177=>this['log'](_0x421c0c(0x1a4)+_0x239177[_0x421c0c(0x146)]));},this['heartbeatInterval']),this[_0x14773e(0x166)]();}async[a0_0x26dbc9(0x160)](){const _0x53f16e=a0_0x26dbc9;if(this[_0x53f16e(0x19f)]=!0x1,this['sseAbort']?.['abort'](),this[_0x53f16e(0x185)])clearInterval(this[_0x53f16e(0x185)]);await this['status']('offline')['catch'](()=>{}),this[_0x53f16e(0x189)](_0x53f16e(0x1a6));}async[a0_0x26dbc9(0x152)](_0x4e6047,_0x418e1f,_0x39993b='normal'){const _0x35e1df=a0_0x26dbc9;return Y({'alias':_0x4e6047,'fromAlias':this[_0x35e1df(0x19e)]},{'log':_0x3227e4=>console[_0x35e1df(0x189)](_0x3227e4),'send':()=>this[_0x35e1df(0x13c)](_0x35e1df(0x165),{'alias':_0x4e6047,'task':_0x418e1f,'priority':_0x39993b,'from_session':this[_0x35e1df(0x19e)]})});}async[a0_0x26dbc9(0x146)](_0x1992ec,_0x30ad63){const _0x4e2bda=a0_0x26dbc9;return this['call'](_0x4e2bda(0x158),{'alias':_0x1992ec,'message':_0x30ad63,'from_session':this[_0x4e2bda(0x19e)]});}async['reply'](_0x2337dc,_0x4a0cae,_0x1832f7=a0_0x26dbc9(0x1ac)){const _0x204b67=a0_0x26dbc9;return this[_0x204b67(0x13c)](_0x204b67(0x156),{'in_reply_to':_0x2337dc,'text':_0x4a0cae,'status':_0x1832f7});}async[a0_0x26dbc9(0x151)](_0x12757f,_0x1047c6){const _0x13d2be=a0_0x26dbc9;return this[_0x13d2be(0x13c)](_0x13d2be(0x140),{'resume_id':this[_0x13d2be(0x147)],'alias':this['alias'],'status':_0x12757f,'server':a0_0x483dac(),'hostname':a0_0x483dac(),'agent':this[_0x13d2be(0x190)],'project_dir':process[_0x13d2be(0x16f)](),..._0x1047c6});}async[a0_0x26dbc9(0x16d)](){const _0x3ce723=a0_0x26dbc9;return this[_0x3ce723(0x13c)]('get_all_status',{});}async[a0_0x26dbc9(0x178)](_0x48db6d,_0x52d47e){const _0x36fc4f=a0_0x26dbc9;return this[_0x36fc4f(0x13c)](_0x36fc4f(0x178),{'message':_0x48db6d,'filter_server':_0x52d47e?.[_0x36fc4f(0x164)],'filter_status':_0x52d47e?.[_0x36fc4f(0x151)]});}async[a0_0x26dbc9(0x166)](){const _0x18bba9=a0_0x26dbc9;let _0x6f9759=encodeURIComponent(this[_0x18bba9(0x19e)]),_0x5988a2=this['url']+_0x18bba9(0x1a1)+_0x6f9759,_0x486212=this['reconnectDelay'];while(this['running']){try{this[_0x18bba9(0x17f)]=new AbortController();let _0x14df06={'Accept':_0x18bba9(0x18f)};if(this[_0x18bba9(0x187)])_0x14df06['Authorization']=_0x18bba9(0x144)+this[_0x18bba9(0x187)];let _0x41a1c5=await fetch(_0x5988a2,{'headers':_0x14df06,'signal':this[_0x18bba9(0x17f)]['signal']});if(!_0x41a1c5['ok']||!_0x41a1c5[_0x18bba9(0x186)]){this[_0x18bba9(0x189)](_0x18bba9(0x174)+_0x41a1c5[_0x18bba9(0x151)]),await this[_0x18bba9(0x145)](_0x486212),_0x486212=Math[_0x18bba9(0x16b)](_0x486212*1.5,0xea60);continue;}_0x486212=this[_0x18bba9(0x163)];let _0x19738e=_0x41a1c5[_0x18bba9(0x186)][_0x18bba9(0x15a)](),_0x34d658=new TextDecoder(),_0x5b3a14='';while(this[_0x18bba9(0x19f)]){let {done:_0x4f0596,value:_0x188126}=await _0x19738e[_0x18bba9(0x15c)]();if(_0x4f0596)break;_0x5b3a14+=_0x34d658['decode'](_0x188126,{'stream':!0x0});let _0x4d8da4=_0x5b3a14[_0x18bba9(0x176)]('\x0a');_0x5b3a14=_0x4d8da4[_0x18bba9(0x16c)]()||'';for(let _0x3f70f3 of _0x4d8da4){if(!_0x3f70f3['startsWith']('data:\x20'))continue;try{let _0x42c4c1=JSON['parse'](_0x3f70f3[_0x18bba9(0x179)](0x6));if(_0x42c4c1['type']==='connected'){this[_0x18bba9(0x189)](_0x18bba9(0x1ab)),this[_0x18bba9(0x1b3)]('connected');continue;}if(_0x42c4c1['type']==='new_task'||_0x42c4c1[_0x18bba9(0x16e)]===_0x18bba9(0x172)||_0x42c4c1[_0x18bba9(0x16e)]===_0x18bba9(0x178))await this[_0x18bba9(0x17e)]();}catch{}}}}catch(_0x468e5c){if(_0x468e5c[_0x18bba9(0x1ae)]===_0x18bba9(0x1b5))break;this[_0x18bba9(0x1b3)](_0x18bba9(0x167),_0x468e5c),this['log'](_0x18bba9(0x13e)+_0x468e5c[_0x18bba9(0x146)]);}if(this[_0x18bba9(0x19f)])this['emit'](_0x18bba9(0x1a6)),this[_0x18bba9(0x189)](_0x18bba9(0x1b0)+_0x486212/0x3e8+_0x18bba9(0x198)),await this[_0x18bba9(0x145)](_0x486212),_0x486212=Math[_0x18bba9(0x16b)](_0x486212*1.5,0xea60);}}async[a0_0x26dbc9(0x17e)](){const _0x4614d1=a0_0x26dbc9;try{let _0x4e903d=(await this['call']('get_inbox',{'alias':this[_0x4614d1(0x19e)],'limit':0xa}))?.[_0x4614d1(0x141)]||[];for(let _0x169d95 of _0x4e903d)await this['call']('ack_inbox',{'alias':this[_0x4614d1(0x19e)],'message_id':_0x169d95['id']}),this[_0x4614d1(0x189)]('←\x20'+_0x169d95[_0x4614d1(0x155)]+':\x20'+_0x169d95[_0x4614d1(0x14a)][_0x4614d1(0x179)](0x0,0x3c)),this[_0x4614d1(0x1b3)](_0x4614d1(0x193),_0x169d95),this[_0x4614d1(0x1b3)](_0x4614d1(0x146),_0x169d95);}catch(_0x3d7813){this['log'](_0x4614d1(0x195)+_0x3d7813[_0x4614d1(0x146)]);}}[a0_0x26dbc9(0x145)](_0x58099b){return new Promise(_0x2530bf=>setTimeout(_0x2530bf,_0x58099b));}}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};
|
package/dist/src/codex-menu.d.ts
CHANGED
|
@@ -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>;
|