@sleep2agi/agent-network 2.3.0-preview.142 → 2.3.0-preview.144
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_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};
|
|
1
|
+
const a0_0xe80285=a0_0x3cad;(function(_0x24d1c3,_0x3a3b42){const _0x1bfd76=a0_0x3cad,_0x553e03=_0x24d1c3();while(!![]){try{const _0x397e69=-parseInt(_0x1bfd76(0x81))/0x1+parseInt(_0x1bfd76(0xd0))/0x2+-parseInt(_0x1bfd76(0xaf))/0x3*(-parseInt(_0x1bfd76(0x75))/0x4)+parseInt(_0x1bfd76(0xd4))/0x5*(parseInt(_0x1bfd76(0x93))/0x6)+-parseInt(_0x1bfd76(0x72))/0x7+-parseInt(_0x1bfd76(0x83))/0x8+-parseInt(_0x1bfd76(0xbd))/0x9;if(_0x397e69===_0x3a3b42)break;else _0x553e03['push'](_0x553e03['shift']());}catch(_0x399fcf){_0x553e03['push'](_0x553e03['shift']());}}}(a0_0x516a,0x82a58));import{EventEmitter as a0_0x27824a}from'events';import{hostname as a0_0x1a07fb}from'os';function a0_0x3cad(_0x1d7e21,_0xd09352){_0x1d7e21=_0x1d7e21-0x6b;const _0x516aed=a0_0x516a();let _0x3cad04=_0x516aed[_0x1d7e21];return _0x3cad04;}var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x52e8c9,_0x1bcc97)=>(_0x52e8c9??_0x1bcc97)[a0_0xe80285(0xd1)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x5fcf67){const _0x16ba2a=a0_0xe80285;return(_0x5fcf67 instanceof Error?_0x5fcf67['message']:String(_0x5fcf67??_0x16ba2a(0xec)))[_0x16ba2a(0xd1)](K,_0x16ba2a(0xa2))[_0x16ba2a(0xd1)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x16ba2a(0xaa)](0x0,0xf0);}function O(_0x3ad6be,_0x4c2c0a=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0xf5dd4c=a0_0xe80285;if(_0x4c2c0a)return JSON[_0xf5dd4c(0x70)](_0x3ad6be);let _0x50da43=L(_0x3ad6be['parent_task_id'],_0xf5dd4c(0xe4)),_0xe379c3=L(_0x3ad6be['task_id'],_0xf5dd4c(0xdf)),_0x325b04=_0x3ad6be[_0xf5dd4c(0xa4)]?'\x20error='+_0x3ad6be[_0xf5dd4c(0xa4)]+':'+(_0x3ad6be['error_message']??''):'';return _0xf5dd4c(0xc6)+_0x3ad6be['status']+'\x20from='+L(_0x3ad6be[_0xf5dd4c(0xb9)],_0xf5dd4c(0xd2))+_0xf5dd4c(0xc5)+L(_0x3ad6be[_0xf5dd4c(0xb8)],_0xf5dd4c(0xd2))+_0xf5dd4c(0xcc)+_0xe379c3+_0xf5dd4c(0xc7)+_0x50da43+'\x20network_id='+L(_0x3ad6be[_0xf5dd4c(0xe0)],_0xf5dd4c(0xd2))+'\x20transport='+_0x3ad6be[_0xf5dd4c(0xdc)]+_0xf5dd4c(0x6d)+_0x3ad6be['duration_ms']+'\x20lifecycle='+_0x3ad6be[_0xf5dd4c(0x94)]+_0x325b04;}function a0_0x516a(){const _0x40f4b8=['agent','<pending>','network_id','connected','type','parentTaskId','<missing>','server','task','decode','Bearer\x20','failed','name','task.expired','unknown\x20error','task.ack','processInbox','body','new_task','disconnect','data:\x20','\x20duration_ms=','Authorization','signal','stringify','from_session','1522514hRnYWe','log','ack_inbox','555532rFDUfH','completed','autoConnect','s...','SSE\x20error:\x20','sseAbort','heartbeatTimer','connectSSE','send_rejected','inbox\x20error:\x20','cwd','message_id','764922SOAAkF','connect','595584YyzQZj','pop','read','alias','application/json','text/event-stream','POST','toAlias','task.started','fromAlias','url','task_id','parse','send','send_reply','2.0','6PwodFm','lifecycle_tracking','AbortError','application/json,\x20text/event-stream','emit','offline','normal','sdk-','report_status','SSE\x20connected','resumeId','get_inbox','messages','message','abort','[REDACTED]','CommHub\x20rejected\x20task','error_code','registered','task.replied','sdk','getAllStatus','reconnectDelay','slice','call','token','lifecycleTracking','networkId','6zZTyQX','new_message','send_failed','not_tracked','heartbeatInterval','tools/call','disconnected','startsWith','send_message','to_alias','from_alias','content','/mcp','text','2925090cSxldD','broadcast','get_all_status','task.send.start','status','send_task','sending','missing_task_id','\x20to=','[commhub:task]\x20','\x20parent_task_id=','result','running','delivered','SSE\x20failed:\x20','\x20task_id=','sleep','idle','CommHub\x20response\x20omitted\x20task_id','1187738NEjGjB','replace','<unknown>','mcp_http','5226875uAtPwx',']\x20[commhub:','getReader','task.send.failed','heartbeat\x20failed:\x20','task.send.delivered','error','now','transport','toString'];a0_0x516a=function(){return _0x40f4b8;};return a0_0x516a();}function U(_0x40d7b2){const _0x32647c=a0_0xe80285;return{'event':{'sending':_0x32647c(0xc0),'delivered':_0x32647c(0xd9),'failed':_0x32647c(0xd7),'acked':_0x32647c(0xed),'started':_0x32647c(0x8b),'replied':_0x32647c(0xa6),'expired':_0x32647c(0xeb)}[_0x40d7b2['status']],..._0x40d7b2};}function j(_0x1cdaff){const _0x4b3a8f=a0_0xe80285;let _0x27e0c3=_0x1cdaff?.['task_id']||_0x1cdaff?.[_0x4b3a8f(0x80)]||_0x1cdaff?.['id'];if(_0x27e0c3)return String(_0x27e0c3);let _0x5d5313=_0x1cdaff?.['content']?.[0x0]?.['text'];if(typeof _0x5d5313!=='string')return null;try{let _0x3bc713=JSON[_0x4b3a8f(0x8f)](_0x5d5313);return _0x3bc713?.[_0x4b3a8f(0x8e)]||_0x3bc713?.[_0x4b3a8f(0x80)]||_0x3bc713?.['id']||null;}catch{return null;}}async function X(_0x1270d9,_0x6ae44d){const _0x40ffb3=a0_0xe80285;let _0x117de9=_0x6ae44d['now']??Date[_0x40ffb3(0xdb)],_0x5758a4=_0x117de9(),_0x102da7=(_0x275e07,_0x442ea6,_0x2141f3,_0xe9febd)=>{const _0x46a6a9=_0x40ffb3;_0x6ae44d[_0x46a6a9(0x73)](O(U({'from_alias':_0x1270d9['fromAlias'],'to_alias':_0x1270d9[_0x46a6a9(0x8a)],'task_id':_0x442ea6,'parent_task_id':_0x1270d9[_0x46a6a9(0xe3)],'network_id':_0x1270d9[_0x46a6a9(0xae)],'transport':_0x1270d9[_0x46a6a9(0xdc)],'status':_0x275e07,'duration_ms':_0x117de9()-_0x5758a4,'lifecycle_tracking':_0x1270d9[_0x46a6a9(0xad)],..._0x2141f3!==void 0x0?{'error_code':_0xe9febd||_0x46a6a9(0xb1),'error_message':N(_0x2141f3)}:{}})));};_0x102da7(_0x40ffb3(0xc3),null);try{let _0x593a7f=await _0x6ae44d[_0x40ffb3(0x90)](),_0x1f6c42=j(_0x593a7f);if(_0x1f6c42)_0x102da7(_0x40ffb3(0xca),_0x1f6c42);else{if(_0x593a7f?.['ok']===!0x1||_0x593a7f?.[_0x40ffb3(0xda)])_0x102da7(_0x40ffb3(0xe9),_0x1f6c42,_0x593a7f?.['error']||_0x40ffb3(0xa3),_0x40ffb3(0x7d));else _0x102da7(_0x40ffb3(0xe9),null,_0x40ffb3(0xcf),_0x40ffb3(0xc4));}return _0x593a7f;}catch(_0x34da4d){throw _0x102da7('failed',null,_0x34da4d,'send_failed'),_0x34da4d;}}async function Y(_0x178a68,_0x3fe262){const _0x4b9a43=a0_0xe80285;return X({'fromAlias':_0x178a68[_0x4b9a43(0x8c)],'toAlias':_0x178a68[_0x4b9a43(0x86)],'parentTaskId':_0x178a68[_0x4b9a43(0xe3)]||null,'networkId':_0x178a68['networkId']||null,'transport':_0x4b9a43(0xd3),'lifecycleTracking':_0x4b9a43(0xb2)},_0x3fe262);}class $ extends a0_0x27824a{[a0_0xe80285(0x8d)];['alias'];['token'];[a0_0xe80285(0xde)];[a0_0xe80285(0x9d)];[a0_0xe80285(0xb3)];[a0_0xe80285(0xa9)];[a0_0xe80285(0x7b)];[a0_0xe80285(0x7a)];[a0_0xe80285(0xc9)]=!0x1;constructor(_0x26a04b){const _0x9db33a=a0_0xe80285;super();if(this['url']=_0x26a04b[_0x9db33a(0x8d)][_0x9db33a(0xd1)](/\/$/,''),this[_0x9db33a(0x86)]=_0x26a04b[_0x9db33a(0x86)],this[_0x9db33a(0xac)]=_0x26a04b[_0x9db33a(0xac)],this['agent']=_0x26a04b[_0x9db33a(0xde)]||_0x9db33a(0xa7),this[_0x9db33a(0x9d)]=_0x9db33a(0x9a)+_0x26a04b[_0x9db33a(0x86)]+'-'+Date[_0x9db33a(0xdb)]()[_0x9db33a(0xdd)](0x24),this[_0x9db33a(0xb3)]=_0x26a04b[_0x9db33a(0xb3)]??0x2bf20,this['reconnectDelay']=_0x26a04b[_0x9db33a(0xa9)]??0xbb8,_0x26a04b[_0x9db33a(0x77)]!==!0x1)this[_0x9db33a(0x82)]();}[a0_0xe80285(0x73)](_0x5898c2){const _0x270472=a0_0xe80285;console['log']('['+new Date()['toTimeString']()['slice'](0x0,0x8)+_0x270472(0xd5)+this[_0x270472(0x86)]+']\x20'+_0x5898c2);}async[a0_0xe80285(0xab)](_0x46ce25,_0x61d3e7){const _0x13c687=a0_0xe80285;let _0x5bf0ea={'Content-Type':_0x13c687(0x87),'Accept':_0x13c687(0x96)};if(this[_0x13c687(0xac)])_0x5bf0ea[_0x13c687(0x6e)]='Bearer\x20'+this[_0x13c687(0xac)];let _0x3a5113=await(await fetch(this[_0x13c687(0x8d)]+_0x13c687(0xbb),{'method':_0x13c687(0x89),'headers':_0x5bf0ea,'body':JSON[_0x13c687(0x70)]({'jsonrpc':_0x13c687(0x92),'id':Date['now'](),'method':_0x13c687(0xb4),'params':{'name':_0x46ce25,'arguments':_0x61d3e7}})}))[_0x13c687(0xbc)](),_0x4e42b0=_0x3a5113['match'](/data: (.+)/),_0x3bb9fa=_0x4e42b0?JSON[_0x13c687(0x8f)](_0x4e42b0[0x1]):JSON[_0x13c687(0x8f)](_0x3a5113),_0xaa4985=_0x3bb9fa?.[_0x13c687(0xc8)]?.[_0x13c687(0xba)]?.[0x0]?.[_0x13c687(0xbc)];return _0xaa4985?JSON[_0x13c687(0x8f)](_0xaa4985):_0x3bb9fa;}async[a0_0xe80285(0x82)](){const _0x544370=a0_0xe80285;if(this['running'])return;this['running']=!0x0,await this['status'](_0x544370(0xce)),this['log'](_0x544370(0xa5)),this[_0x544370(0x7b)]=setInterval(()=>{const _0x237735=_0x544370;this[_0x237735(0xc1)](_0x237735(0xce))['catch'](_0x38be8a=>this[_0x237735(0x73)](_0x237735(0xd8)+_0x38be8a['message']));},this['heartbeatInterval']),this[_0x544370(0x7c)]();}async[a0_0xe80285(0x6b)](){const _0x1c971d=a0_0xe80285;if(this['running']=!0x1,this['sseAbort']?.[_0x1c971d(0xa1)](),this[_0x1c971d(0x7b)])clearInterval(this[_0x1c971d(0x7b)]);await this['status'](_0x1c971d(0x98))['catch'](()=>{}),this['log']('disconnected');}async[a0_0xe80285(0x90)](_0x37b967,_0x1dfe21,_0x344db9=a0_0xe80285(0x99)){const _0x35b40b=a0_0xe80285;return Y({'alias':_0x37b967,'fromAlias':this['alias']},{'log':_0x1f2917=>console[_0x35b40b(0x73)](_0x1f2917),'send':()=>this[_0x35b40b(0xab)](_0x35b40b(0xc2),{'alias':_0x37b967,'task':_0x1dfe21,'priority':_0x344db9,'from_session':this[_0x35b40b(0x86)]})});}async['message'](_0x39aaad,_0x21ad2c){const _0x16cd6d=a0_0xe80285;return this[_0x16cd6d(0xab)](_0x16cd6d(0xb7),{'alias':_0x39aaad,'message':_0x21ad2c,'from_session':this[_0x16cd6d(0x86)]});}async['reply'](_0x11a7fa,_0x3763e7,_0x4ecf90=a0_0xe80285(0x76)){const _0x46376a=a0_0xe80285;return this['call'](_0x46376a(0x91),{'in_reply_to':_0x11a7fa,'text':_0x3763e7,'status':_0x4ecf90});}async[a0_0xe80285(0xc1)](_0x4070fd,_0x21f209){const _0x296808=a0_0xe80285;return this[_0x296808(0xab)](_0x296808(0x9b),{'resume_id':this[_0x296808(0x9d)],'alias':this[_0x296808(0x86)],'status':_0x4070fd,'server':a0_0x1a07fb(),'hostname':a0_0x1a07fb(),'agent':this[_0x296808(0xde)],'project_dir':process[_0x296808(0x7f)](),..._0x21f209});}async[a0_0xe80285(0xa8)](){const _0x3adafd=a0_0xe80285;return this[_0x3adafd(0xab)](_0x3adafd(0xbf),{});}async[a0_0xe80285(0xbe)](_0x23deb5,_0x5a84d2){const _0x293ccb=a0_0xe80285;return this[_0x293ccb(0xab)](_0x293ccb(0xbe),{'message':_0x23deb5,'filter_server':_0x5a84d2?.[_0x293ccb(0xe5)],'filter_status':_0x5a84d2?.[_0x293ccb(0xc1)]});}async[a0_0xe80285(0x7c)](){const _0x3a93f2=a0_0xe80285;let _0x2517c9=encodeURIComponent(this[_0x3a93f2(0x86)]),_0x48d553=this['url']+'/events/'+_0x2517c9,_0x4ba80a=this[_0x3a93f2(0xa9)];while(this[_0x3a93f2(0xc9)]){try{this['sseAbort']=new AbortController();let _0x4e1d58={'Accept':_0x3a93f2(0x88)};if(this['token'])_0x4e1d58['Authorization']=_0x3a93f2(0xe8)+this[_0x3a93f2(0xac)];let _0x4e9631=await fetch(_0x48d553,{'headers':_0x4e1d58,'signal':this[_0x3a93f2(0x7a)][_0x3a93f2(0x6f)]});if(!_0x4e9631['ok']||!_0x4e9631[_0x3a93f2(0xef)]){this[_0x3a93f2(0x73)](_0x3a93f2(0xcb)+_0x4e9631['status']),await this[_0x3a93f2(0xcd)](_0x4ba80a),_0x4ba80a=Math['min'](_0x4ba80a*1.5,0xea60);continue;}_0x4ba80a=this['reconnectDelay'];let _0x5ccef7=_0x4e9631[_0x3a93f2(0xef)][_0x3a93f2(0xd6)](),_0x2fb1e8=new TextDecoder(),_0xfa900='';while(this['running']){let {done:_0xf3ad6f,value:_0x168870}=await _0x5ccef7[_0x3a93f2(0x85)]();if(_0xf3ad6f)break;_0xfa900+=_0x2fb1e8[_0x3a93f2(0xe7)](_0x168870,{'stream':!0x0});let _0xaeea5d=_0xfa900['split']('\x0a');_0xfa900=_0xaeea5d[_0x3a93f2(0x84)]()||'';for(let _0xdd2570 of _0xaeea5d){if(!_0xdd2570[_0x3a93f2(0xb6)](_0x3a93f2(0x6c)))continue;try{let _0x34920a=JSON[_0x3a93f2(0x8f)](_0xdd2570[_0x3a93f2(0xaa)](0x6));if(_0x34920a[_0x3a93f2(0xe2)]==='connected'){this[_0x3a93f2(0x73)](_0x3a93f2(0x9c)),this[_0x3a93f2(0x97)](_0x3a93f2(0xe1));continue;}if(_0x34920a['type']===_0x3a93f2(0xf0)||_0x34920a['type']===_0x3a93f2(0xb0)||_0x34920a[_0x3a93f2(0xe2)]==='broadcast')await this['processInbox']();}catch{}}}}catch(_0x396ce1){if(_0x396ce1[_0x3a93f2(0xea)]===_0x3a93f2(0x95))break;this[_0x3a93f2(0x97)](_0x3a93f2(0xda),_0x396ce1),this[_0x3a93f2(0x73)](_0x3a93f2(0x79)+_0x396ce1[_0x3a93f2(0xa0)]);}if(this['running'])this[_0x3a93f2(0x97)](_0x3a93f2(0xb5)),this[_0x3a93f2(0x73)]('SSE\x20reconnecting\x20in\x20'+_0x4ba80a/0x3e8+_0x3a93f2(0x78)),await this['sleep'](_0x4ba80a),_0x4ba80a=Math['min'](_0x4ba80a*1.5,0xea60);}}async[a0_0xe80285(0xee)](){const _0x4d8233=a0_0xe80285;try{let _0x9d7915=(await this['call'](_0x4d8233(0x9e),{'alias':this['alias'],'limit':0xa}))?.[_0x4d8233(0x9f)]||[];for(let _0x389691 of _0x9d7915)await this['call'](_0x4d8233(0x74),{'alias':this['alias'],'message_id':_0x389691['id']}),this['log']('←\x20'+_0x389691[_0x4d8233(0x71)]+':\x20'+_0x389691[_0x4d8233(0xba)][_0x4d8233(0xaa)](0x0,0x3c)),this[_0x4d8233(0x97)](_0x4d8233(0xe6),_0x389691),this['emit'](_0x4d8233(0xa0),_0x389691);}catch(_0x3d4ce2){this['log'](_0x4d8233(0x7e)+_0x3d4ce2['message']);}}[a0_0xe80285(0xcd)](_0x1011cb){return new Promise(_0x5c8ab9=>setTimeout(_0x5c8ab9,_0x1011cb));}}var F=$;export{F as default,$ as CommHub};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { type SessionClass } from "./session-status-class";
|
|
2
|
+
export declare const UNKNOWN_HOST = "(unknown host)";
|
|
3
|
+
export type NodeLsAllArgs = {
|
|
4
|
+
all: boolean;
|
|
5
|
+
json: boolean;
|
|
6
|
+
network: string | null;
|
|
7
|
+
error: string | null;
|
|
8
|
+
};
|
|
9
|
+
/** `--all`, `--json`, `--network <id|name>` (also `--network=<v>`). */
|
|
10
|
+
export declare function parseNodeLsAllArgs(argv: string[]): NodeLsAllArgs;
|
|
11
|
+
export type HubNetwork = {
|
|
12
|
+
network_id: string;
|
|
13
|
+
network_name?: string | null;
|
|
14
|
+
member_role?: string | null;
|
|
15
|
+
};
|
|
16
|
+
export type NetworkPick = {
|
|
17
|
+
ok: true;
|
|
18
|
+
network: HubNetwork;
|
|
19
|
+
} | {
|
|
20
|
+
ok: false;
|
|
21
|
+
error: string;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Same matching as `anet network use <name>` (exact id or exact name), plus a unique id prefix
|
|
25
|
+
* because `anet network ls` prints 12-character id prefixes. Ambiguity is refused, never guessed.
|
|
26
|
+
*/
|
|
27
|
+
export declare function pickNetwork(networks: HubNetwork[], ref: string | null, currentId: string | null | undefined): NetworkPick;
|
|
28
|
+
export type DaemonState = "online" | "offline" | "none-visible" | "unknown";
|
|
29
|
+
export type MachineNode = {
|
|
30
|
+
alias: string;
|
|
31
|
+
node_id: string | null;
|
|
32
|
+
runtime: string | null;
|
|
33
|
+
status: string | null;
|
|
34
|
+
status_class: SessionClass;
|
|
35
|
+
last_seen_at: string | null;
|
|
36
|
+
model: string | null;
|
|
37
|
+
};
|
|
38
|
+
export type MachineDaemon = {
|
|
39
|
+
alias: string;
|
|
40
|
+
online: boolean;
|
|
41
|
+
last_seen_at: string | null;
|
|
42
|
+
};
|
|
43
|
+
export type MachineGroup = {
|
|
44
|
+
hostname: string | null;
|
|
45
|
+
/** online = at least one daemon on this host is online (remote management possible). */
|
|
46
|
+
daemon: DaemonState;
|
|
47
|
+
daemons: MachineDaemon[];
|
|
48
|
+
nodes: MachineNode[];
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* @param daemons the Hub's daemon list, or null when it could not be read (state "unknown").
|
|
52
|
+
* An empty array means "the Hub showed you none" (state "none-visible").
|
|
53
|
+
*/
|
|
54
|
+
export declare function groupNodesByMachine(sessions: any[], daemons: any[] | null): MachineGroup[];
|
|
55
|
+
/** Compact English age for a table cell. Unparseable → "?", future → "in Ns (clock skew?)". */
|
|
56
|
+
export declare function shortAgo(raw: string | null, nowMs: number): string;
|
|
57
|
+
export type FormatOpts = {
|
|
58
|
+
network: HubNetwork;
|
|
59
|
+
nowMs: number;
|
|
60
|
+
/** why the daemon list could not be read (daemons === null) */
|
|
61
|
+
daemonsError?: string | null;
|
|
62
|
+
};
|
|
63
|
+
export declare function formatMachineGroups(groups: MachineGroup[], opts: FormatOpts): string[];
|
|
64
|
+
export declare function machineGroupsJson(groups: MachineGroup[], opts: {
|
|
65
|
+
network: HubNetwork;
|
|
66
|
+
daemonsError?: string | null;
|
|
67
|
+
}): {
|
|
68
|
+
machines: {
|
|
69
|
+
hostname: string | null;
|
|
70
|
+
daemon: DaemonState;
|
|
71
|
+
daemons: MachineDaemon[];
|
|
72
|
+
nodes: MachineNode[];
|
|
73
|
+
}[];
|
|
74
|
+
daemons_error?: string | undefined;
|
|
75
|
+
network: {
|
|
76
|
+
network_id: string;
|
|
77
|
+
network_name: string | null;
|
|
78
|
+
};
|
|
79
|
+
daemons_readable: boolean;
|
|
80
|
+
};
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #562 step 2 — remote lifecycle: act on a node that lives on ANOTHER machine.
|
|
3
|
+
*
|
|
4
|
+
* anet node start <alias> --remote [--network <id|name>] [--yes] [--wait <s>]
|
|
5
|
+
* anet node stop <alias> --remote [--network <id|name>] [--yes] [--wait <s>] [--force]
|
|
6
|
+
* anet node restart <alias> --remote [--network <id|name>] [--yes] [--wait <s>]
|
|
7
|
+
* anet node edit <alias> --model <id> --remote [--network <id|name>] [--yes] [--wait <s>]
|
|
8
|
+
*
|
|
9
|
+
* Nothing new on the Hub: these are the same MCP tools the app calls (POST /mcp tools/call):
|
|
10
|
+
* start → start_node Hub → that machine's daemon (host_supervisor) spawns the child
|
|
11
|
+
* stop → stop_node Hub → that machine's daemon stops the child
|
|
12
|
+
* restart → restart_node Hub → the node itself drains + exits 75; its `anet node start`
|
|
13
|
+
* wrapper respawns it (whoever ran that wrapper: a daemon or a person)
|
|
14
|
+
* edit → update_node_config same doorbell; a model change is restart-tier
|
|
15
|
+
* Permission checks are the Hub's (canWrite: member+, not viewer, not agent-restricted); this
|
|
16
|
+
* module never decides who may do what — it only refuses what cannot work, BEFORE dispatching:
|
|
17
|
+
* start/stop (need the machine's daemon):
|
|
18
|
+
* - no online daemon on the node's machine → "this machine can't be managed remotely"
|
|
19
|
+
* - the node was not created by a daemon → the Hub keeps no daemon for it
|
|
20
|
+
* - the daemon that created it is offline
|
|
21
|
+
* restart/edit (#570 — no daemon involved, the Hub pushes to the node itself):
|
|
22
|
+
* - the node is not running → nothing would receive the doorbell
|
|
23
|
+
* - it does not report config_update_capable → no exit-75 supervisor: it would just die
|
|
24
|
+
*
|
|
25
|
+
* Pure functions here; the HTTP calls live in bin/cli.ts (nodeRemoteCommand).
|
|
26
|
+
*/
|
|
27
|
+
import type { PlannedCommand } from "./codex-menu";
|
|
28
|
+
export type RemoteVerb = "start" | "stop" | "restart" | "edit";
|
|
29
|
+
export declare const REMOTE_VERBS: readonly RemoteVerb[];
|
|
30
|
+
export declare const DEFAULT_WAIT_SECONDS = 60;
|
|
31
|
+
export declare const MAX_WAIT_SECONDS = 600;
|
|
32
|
+
export type RemoteArgs = {
|
|
33
|
+
verb: RemoteVerb;
|
|
34
|
+
alias: string | null;
|
|
35
|
+
network: string | null;
|
|
36
|
+
model: string | null;
|
|
37
|
+
yes: boolean;
|
|
38
|
+
force: boolean;
|
|
39
|
+
waitSeconds: number;
|
|
40
|
+
error: string | null;
|
|
41
|
+
};
|
|
42
|
+
/** True when this `anet node <verb> …` invocation is the remote form. */
|
|
43
|
+
export declare function isRemoteInvocation(argv: string[]): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* @param argv everything after `anet node <verb>` (the verb itself excluded).
|
|
46
|
+
* Unknown flags are refused: a local-only flag (`--tmux`, `--copresence`, `--runtime` …) silently
|
|
47
|
+
* ignored on a remote node would be a lie about what was done.
|
|
48
|
+
*/
|
|
49
|
+
export declare function parseRemoteArgs(verb: RemoteVerb, argv: string[]): RemoteArgs;
|
|
50
|
+
export type HubNodeRow = {
|
|
51
|
+
node_id: string;
|
|
52
|
+
alias: string;
|
|
53
|
+
hostname?: string | null;
|
|
54
|
+
role?: string | null;
|
|
55
|
+
lifecycle_state?: string | null;
|
|
56
|
+
lifecycle_controllable?: boolean;
|
|
57
|
+
lifecycle_daemon_node_id?: string | null;
|
|
58
|
+
model?: string | null;
|
|
59
|
+
};
|
|
60
|
+
export type HubSession = {
|
|
61
|
+
alias?: string;
|
|
62
|
+
node_id?: string | null;
|
|
63
|
+
status?: string | null;
|
|
64
|
+
hostname?: string | null;
|
|
65
|
+
host?: {
|
|
66
|
+
hostname?: string | null;
|
|
67
|
+
} | null;
|
|
68
|
+
last_seen_at?: string | null;
|
|
69
|
+
updated_at?: string | null;
|
|
70
|
+
model?: string | null;
|
|
71
|
+
};
|
|
72
|
+
/** GET /api/host-supervisors row: the daemon's node id is `daemon_node_id` (not `node_id`). */
|
|
73
|
+
export type HubDaemon = {
|
|
74
|
+
daemon_node_id?: string;
|
|
75
|
+
alias?: string;
|
|
76
|
+
hostname?: string | null;
|
|
77
|
+
online?: boolean;
|
|
78
|
+
last_seen_at?: string | null;
|
|
79
|
+
};
|
|
80
|
+
export type RemoteTarget = {
|
|
81
|
+
node_id: string;
|
|
82
|
+
alias: string;
|
|
83
|
+
hostname: string | null;
|
|
84
|
+
lifecycle_state: string;
|
|
85
|
+
session_status: string | null;
|
|
86
|
+
session_seen: string | null;
|
|
87
|
+
model: string | null;
|
|
88
|
+
/** The daemon that created the node (start/stop go through it). null = not daemon-managed: only
|
|
89
|
+
* restart/edit resolve without one. `online` is false only for restart/edit (they don't need it). */
|
|
90
|
+
daemon: {
|
|
91
|
+
node_id: string;
|
|
92
|
+
alias: string;
|
|
93
|
+
online: boolean;
|
|
94
|
+
} | null;
|
|
95
|
+
};
|
|
96
|
+
export type ResolveResult = {
|
|
97
|
+
ok: true;
|
|
98
|
+
target: RemoteTarget;
|
|
99
|
+
} | {
|
|
100
|
+
ok: false;
|
|
101
|
+
code: "not_found" | "is_daemon" | "daemons_not_visible" | "no_daemon_on_host" | "not_daemon_managed" | "creator_daemon_offline";
|
|
102
|
+
message: string;
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* @param nodes GET /api/nodes?alias=<alias>&network_id=<net> (rows; newest first)
|
|
106
|
+
* @param sessions GET /api/status?network_id=<net> (sessions)
|
|
107
|
+
* @param daemons GET /api/host-supervisors?network_id=<net> (daemons; [] = none visible)
|
|
108
|
+
*/
|
|
109
|
+
export declare function resolveRemoteTarget(verb: RemoteVerb, alias: string, nodes: HubNodeRow[], sessions: HubSession[], daemons: HubDaemon[]): ResolveResult;
|
|
110
|
+
export type Precheck = {
|
|
111
|
+
kind: "go";
|
|
112
|
+
} | {
|
|
113
|
+
kind: "noop";
|
|
114
|
+
message: string;
|
|
115
|
+
} | {
|
|
116
|
+
kind: "refuse";
|
|
117
|
+
message: string;
|
|
118
|
+
};
|
|
119
|
+
export declare function isRunning(t: RemoteTarget): boolean;
|
|
120
|
+
export declare function precheck(verb: RemoteVerb, t: RemoteTarget, cfg?: {
|
|
121
|
+
config_update_capable?: boolean;
|
|
122
|
+
} | null): Precheck;
|
|
123
|
+
export declare function remoteCommandArgv(a: {
|
|
124
|
+
verb: RemoteVerb;
|
|
125
|
+
alias: string;
|
|
126
|
+
networkId: string;
|
|
127
|
+
model?: string | null;
|
|
128
|
+
force?: boolean;
|
|
129
|
+
}): string[];
|
|
130
|
+
export declare function describePlan(verb: RemoteVerb, t: RemoteTarget, model?: string | null): string;
|
|
131
|
+
/** The one-line "where/what" header printed before the plan. */
|
|
132
|
+
export declare function describeTarget(verb: RemoteVerb, t: RemoteTarget): string;
|
|
133
|
+
export declare function planRemote(a: {
|
|
134
|
+
verb: RemoteVerb;
|
|
135
|
+
target: RemoteTarget;
|
|
136
|
+
networkId: string;
|
|
137
|
+
model?: string | null;
|
|
138
|
+
force?: boolean;
|
|
139
|
+
}): PlannedCommand;
|
|
140
|
+
export declare function toolCall(verb: RemoteVerb, t: RemoteTarget, networkId: string, opts?: {
|
|
141
|
+
model?: string | null;
|
|
142
|
+
force?: boolean;
|
|
143
|
+
baseRevision?: number;
|
|
144
|
+
}): {
|
|
145
|
+
name: string;
|
|
146
|
+
arguments: Record<string, unknown>;
|
|
147
|
+
};
|
|
148
|
+
export declare function explainHubRefusal(verb: RemoteVerb, alias: string, r: any): string;
|
|
149
|
+
export type Observation = {
|
|
150
|
+
lifecycle_state: string | null;
|
|
151
|
+
session_status: string | null;
|
|
152
|
+
session_seen: string | null;
|
|
153
|
+
config_revision: number | null;
|
|
154
|
+
model: string | null;
|
|
155
|
+
};
|
|
156
|
+
export type Outcome = {
|
|
157
|
+
state: "pending";
|
|
158
|
+
} | {
|
|
159
|
+
state: "done";
|
|
160
|
+
message: string;
|
|
161
|
+
} | {
|
|
162
|
+
state: "failed";
|
|
163
|
+
message: string;
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* @param before what the hub showed right before dispatch
|
|
167
|
+
* @param now what it shows now
|
|
168
|
+
* Seen-times are compared as the hub's own strings (changed or not), never against this machine's
|
|
169
|
+
* clock: the node is on another machine and the hub on a third.
|
|
170
|
+
*/
|
|
171
|
+
export declare function evaluateOutcome(verb: RemoteVerb, t: RemoteTarget, before: Observation, now: Observation, want?: {
|
|
172
|
+
model?: string | null;
|
|
173
|
+
baseRevision?: number;
|
|
174
|
+
}): Outcome;
|
|
175
|
+
/**
|
|
176
|
+
* @param last the last observation before the deadline (null = none could be read). For restart/edit it
|
|
177
|
+
* tells "went down and never came back" (the supervisor did not respawn it — a real failure
|
|
178
|
+
* worth a different next step) apart from "still finishing its turn".
|
|
179
|
+
*/
|
|
180
|
+
export declare function timeoutMessage(verb: RemoteVerb, alias: string, seconds: number, last?: Observation | null, host?: string | null): string;
|