@sleep2agi/agent-network 2.3.0-preview.124 → 2.3.0-preview.127
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/bin/cli.js +2 -2
- package/dist/src/client.js +1 -1
- package/dist/src/codex-tui-client-health.d.ts +13 -0
- package/dist/src/hub-server-version.d.ts +64 -0
- package/dist/src/node-clone.d.ts +134 -0
- package/dist/src/node-server-identity.d.ts +35 -0
- package/dist/src/node-server.js +7 -7
- package/dist/src/opencode-agent-node-pair.d.ts +6 -6
- package/dist/src/tmux.d.ts +44 -0
- package/dist/src/upgrade-channel.d.ts +31 -0
- package/package.json +2 -2
package/dist/src/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a0_0x29f6d2=a0_0x3ce0;(function(_0xa4c5e3,_0x1e018f){const _0x15a0cb=a0_0x3ce0,_0x155dd5=_0xa4c5e3();while(!![]){try{const _0x31c9c7=-parseInt(_0x15a0cb(0x134))/0x1+parseInt(_0x15a0cb(0x13a))/0x2+parseInt(_0x15a0cb(0xe0))/0x3*(parseInt(_0x15a0cb(0x105))/0x4)+-parseInt(_0x15a0cb(0x117))/0x5+parseInt(_0x15a0cb(0xdf))/0x6+-parseInt(_0x15a0cb(0x139))/0x7+-parseInt(_0x15a0cb(0xe6))/0x8*(-parseInt(_0x15a0cb(0x13c))/0x9);if(_0x31c9c7===_0x1e018f)break;else _0x155dd5['push'](_0x155dd5['shift']());}catch(_0x5f5b86){_0x155dd5['push'](_0x155dd5['shift']());}}}(a0_0x57ce,0xb186c));import{EventEmitter as a0_0x121833}from'events';import{hostname as a0_0x556524}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x17c407,_0x827e79)=>(_0x17c407??_0x827e79)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x29f6d2(0xf8)](0x0,0xf0);function N(_0x24f825){const _0x5eef13=a0_0x29f6d2;return(_0x24f825 instanceof Error?_0x24f825[_0x5eef13(0xf3)]:String(_0x24f825??_0x5eef13(0x12c)))[_0x5eef13(0xe8)](K,_0x5eef13(0x104))[_0x5eef13(0xe8)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x5eef13(0xf8)](0x0,0xf0);}function O(_0x3f7fe9,_0x555cd7=process.env.ANET_TASK_TRACE_FORMAT===a0_0x29f6d2(0x109)){const _0x2fecdd=a0_0x29f6d2;if(_0x555cd7)return JSON[_0x2fecdd(0x119)](_0x3f7fe9);let _0x4861d9=L(_0x3f7fe9[_0x2fecdd(0xf6)],_0x2fecdd(0x127)),_0x368e7c=L(_0x3f7fe9[_0x2fecdd(0xdd)],'<pending>'),_0x3f896e=_0x3f7fe9[_0x2fecdd(0x145)]?_0x2fecdd(0x108)+_0x3f7fe9[_0x2fecdd(0x145)]+':'+(_0x3f7fe9['error_message']??''):'';return _0x2fecdd(0x147)+_0x3f7fe9[_0x2fecdd(0xd2)]+_0x2fecdd(0x12e)+L(_0x3f7fe9[_0x2fecdd(0x11a)],'<unknown>')+_0x2fecdd(0x143)+L(_0x3f7fe9[_0x2fecdd(0x12b)],'<unknown>')+_0x2fecdd(0xfb)+_0x368e7c+_0x2fecdd(0xed)+_0x4861d9+_0x2fecdd(0x132)+L(_0x3f7fe9['network_id'],_0x2fecdd(0x135))+_0x2fecdd(0x110)+_0x3f7fe9[_0x2fecdd(0x126)]+_0x2fecdd(0xf0)+_0x3f7fe9[_0x2fecdd(0x156)]+_0x2fecdd(0x13b)+_0x3f7fe9[_0x2fecdd(0xe4)]+_0x3f896e;}function U(_0x3819a9){const _0x2e5f98=a0_0x29f6d2;return{'event':{'sending':_0x2e5f98(0x10f),'delivered':_0x2e5f98(0x14b),'failed':_0x2e5f98(0x11c),'acked':_0x2e5f98(0x14e),'started':_0x2e5f98(0x152),'replied':_0x2e5f98(0xda),'expired':'task.expired'}[_0x3819a9['status']],..._0x3819a9};}function j(_0x54a243){const _0x5261e7=a0_0x29f6d2;let _0xb06f0c=_0x54a243?.[_0x5261e7(0xdd)]||_0x54a243?.['message_id']||_0x54a243?.['id'];if(_0xb06f0c)return String(_0xb06f0c);let _0x21df70=_0x54a243?.['content']?.[0x0]?.['text'];if(typeof _0x21df70!=='string')return null;try{let _0x23f47f=JSON['parse'](_0x21df70);return _0x23f47f?.[_0x5261e7(0xdd)]||_0x23f47f?.[_0x5261e7(0x121)]||_0x23f47f?.['id']||null;}catch{return null;}}async function X(_0x4cb5a6,_0x3194f5){const _0x1c1820=a0_0x29f6d2;let _0x2f0453=_0x3194f5[_0x1c1820(0x13f)]??Date['now'],_0x5bb690=_0x2f0453(),_0x278825=(_0x29afc2,_0x2d667f,_0x15e69d,_0x286988)=>{const _0x3410e8=_0x1c1820;_0x3194f5['log'](O(U({'from_alias':_0x4cb5a6['fromAlias'],'to_alias':_0x4cb5a6[_0x3410e8(0xe3)],'task_id':_0x2d667f,'parent_task_id':_0x4cb5a6[_0x3410e8(0x155)],'network_id':_0x4cb5a6[_0x3410e8(0xf5)],'transport':_0x4cb5a6['transport'],'status':_0x29afc2,'duration_ms':_0x2f0453()-_0x5bb690,'lifecycle_tracking':_0x4cb5a6[_0x3410e8(0x154)],..._0x15e69d!==void 0x0?{'error_code':_0x286988||_0x3410e8(0x136),'error_message':N(_0x15e69d)}:{}})));};_0x278825('sending',null);try{let _0x11af84=await _0x3194f5[_0x1c1820(0x106)](),_0x294183=j(_0x11af84);if(_0x294183)_0x278825(_0x1c1820(0x103),_0x294183);else{if(_0x11af84?.['ok']===!0x1||_0x11af84?.[_0x1c1820(0xf9)])_0x278825(_0x1c1820(0xfd),_0x294183,_0x11af84?.[_0x1c1820(0xf9)]||_0x1c1820(0xf2),_0x1c1820(0xe1));else _0x278825(_0x1c1820(0xfd),null,_0x1c1820(0xf4),_0x1c1820(0xd5));}return _0x11af84;}catch(_0xbbdb71){throw _0x278825(_0x1c1820(0xfd),null,_0xbbdb71,_0x1c1820(0x136)),_0xbbdb71;}}function a0_0x57ce(){const _0xa90b3b=['lifecycle_tracking','get_all_status','8LNUEjo','sseAbort','replace','SSE\x20reconnecting\x20in\x20','connectSSE','toTimeString','token','\x20parent_task_id=','SSE\x20connected','new_message','\x20duration_ms=','offline','CommHub\x20rejected\x20task','message','CommHub\x20response\x20omitted\x20task_id','networkId','parent_task_id','resumeId','slice','error','disconnected','\x20task_id=','sdk-','failed','alias','Bearer\x20','get_inbox','text/event-stream','send_reply','delivered','[REDACTED]','1545496vbiahg','send','server','\x20error=','json','signal','heartbeatInterval','new_task','log','cwd','task.send.start','\x20transport=','sdk','data:\x20','task','match','/events/','send_message','3545655tIfxLT','name','stringify','from_alias','split','task.send.failed',']\x20[commhub:','sleep','connected','toString','message_id','parse','mcp_http','processInbox','body','transport','<missing>','call','idle','reconnectDelay','to_alias','unknown\x20error','connect','\x20from=','tools/call','decode','read','\x20network_id=','heartbeat\x20failed:\x20','613628OAVQNv','<unknown>','send_failed','report_status','text','8050525aXinea','189122jqzebN','\x20lifecycle=','16280721QUbgkq','running','2.0','now','emit','catch','disconnect','\x20to=','not_tracked','error_code','ack_inbox','[commhub:task]\x20','type','broadcast','registered','task.send.delivered','getAllStatus','result','task.ack','pop','heartbeatTimer','inbox\x20error:\x20','task.started','min','lifecycleTracking','parentTaskId','duration_ms','status','application/json,\x20text/event-stream','agent','missing_task_id','from_session','send_task','getReader','SSE\x20error:\x20','task.replied','Authorization','POST','task_id','url','823980gjgoTw','9JfRKVI','send_rejected','messages','toAlias'];a0_0x57ce=function(){return _0xa90b3b;};return a0_0x57ce();}async function Y(_0x5d65e7,_0x55fddd){const _0x5d8810=a0_0x29f6d2;return X({'fromAlias':_0x5d65e7['fromAlias'],'toAlias':_0x5d65e7[_0x5d8810(0xfe)],'parentTaskId':_0x5d65e7['parentTaskId']||null,'networkId':_0x5d65e7[_0x5d8810(0xf5)]||null,'transport':_0x5d8810(0x123),'lifecycleTracking':_0x5d8810(0x144)},_0x55fddd);}class $ extends a0_0x121833{[a0_0x29f6d2(0xde)];[a0_0x29f6d2(0xfe)];[a0_0x29f6d2(0xec)];[a0_0x29f6d2(0xd4)];[a0_0x29f6d2(0xf7)];['heartbeatInterval'];['reconnectDelay'];['heartbeatTimer'];[a0_0x29f6d2(0xe7)];['running']=!0x1;constructor(_0x482c2a){const _0x34c710=a0_0x29f6d2;super();if(this[_0x34c710(0xde)]=_0x482c2a[_0x34c710(0xde)][_0x34c710(0xe8)](/\/$/,''),this[_0x34c710(0xfe)]=_0x482c2a[_0x34c710(0xfe)],this['token']=_0x482c2a['token'],this[_0x34c710(0xd4)]=_0x482c2a[_0x34c710(0xd4)]||_0x34c710(0x111),this[_0x34c710(0xf7)]=_0x34c710(0xfc)+_0x482c2a[_0x34c710(0xfe)]+'-'+Date[_0x34c710(0x13f)]()[_0x34c710(0x120)](0x24),this[_0x34c710(0x10b)]=_0x482c2a[_0x34c710(0x10b)]??0x2bf20,this[_0x34c710(0x12a)]=_0x482c2a[_0x34c710(0x12a)]??0xbb8,_0x482c2a['autoConnect']!==!0x1)this['connect']();}[a0_0x29f6d2(0x10d)](_0x2e8c60){const _0x19b83f=a0_0x29f6d2;console[_0x19b83f(0x10d)]('['+new Date()[_0x19b83f(0xeb)]()[_0x19b83f(0xf8)](0x0,0x8)+_0x19b83f(0x11d)+this[_0x19b83f(0xfe)]+']\x20'+_0x2e8c60);}async[a0_0x29f6d2(0x128)](_0x42fff2,_0x2626a1){const _0x3226a9=a0_0x29f6d2;let _0x4239d4={'Content-Type':'application/json','Accept':_0x3226a9(0xd3)};if(this[_0x3226a9(0xec)])_0x4239d4[_0x3226a9(0xdb)]=_0x3226a9(0xff)+this[_0x3226a9(0xec)];let _0x3050b7=await(await fetch(this[_0x3226a9(0xde)]+'/mcp',{'method':_0x3226a9(0xdc),'headers':_0x4239d4,'body':JSON[_0x3226a9(0x119)]({'jsonrpc':_0x3226a9(0x13e),'id':Date['now'](),'method':_0x3226a9(0x12f),'params':{'name':_0x42fff2,'arguments':_0x2626a1}})}))[_0x3226a9(0x138)](),_0x3bd5c7=_0x3050b7[_0x3226a9(0x114)](/data: (.+)/),_0x3267f3=_0x3bd5c7?JSON[_0x3226a9(0x122)](_0x3bd5c7[0x1]):JSON['parse'](_0x3050b7),_0x39e73b=_0x3267f3?.[_0x3226a9(0x14d)]?.['content']?.[0x0]?.[_0x3226a9(0x138)];return _0x39e73b?JSON[_0x3226a9(0x122)](_0x39e73b):_0x3267f3;}async[a0_0x29f6d2(0x12d)](){const _0x19d61d=a0_0x29f6d2;if(this[_0x19d61d(0x13d)])return;this[_0x19d61d(0x13d)]=!0x0,await this[_0x19d61d(0xd2)](_0x19d61d(0x129)),this[_0x19d61d(0x10d)](_0x19d61d(0x14a)),this['heartbeatTimer']=setInterval(()=>{const _0x8ca95=_0x19d61d;this[_0x8ca95(0xd2)](_0x8ca95(0x129))[_0x8ca95(0x141)](_0xffb1a2=>this['log'](_0x8ca95(0x133)+_0xffb1a2[_0x8ca95(0xf3)]));},this[_0x19d61d(0x10b)]),this[_0x19d61d(0xea)]();}async[a0_0x29f6d2(0x142)](){const _0x3f2f03=a0_0x29f6d2;if(this[_0x3f2f03(0x13d)]=!0x1,this['sseAbort']?.['abort'](),this[_0x3f2f03(0x150)])clearInterval(this[_0x3f2f03(0x150)]);await this[_0x3f2f03(0xd2)](_0x3f2f03(0xf1))[_0x3f2f03(0x141)](()=>{}),this[_0x3f2f03(0x10d)](_0x3f2f03(0xfa));}async[a0_0x29f6d2(0x106)](_0x1daaf5,_0x3d2319,_0x114563='normal'){const _0x4e4aae=a0_0x29f6d2;return Y({'alias':_0x1daaf5,'fromAlias':this['alias']},{'log':_0x59c50b=>console[_0x4e4aae(0x10d)](_0x59c50b),'send':()=>this['call'](_0x4e4aae(0xd7),{'alias':_0x1daaf5,'task':_0x3d2319,'priority':_0x114563,'from_session':this[_0x4e4aae(0xfe)]})});}async[a0_0x29f6d2(0xf3)](_0x276f4b,_0x5d8223){const _0x597207=a0_0x29f6d2;return this[_0x597207(0x128)](_0x597207(0x116),{'alias':_0x276f4b,'message':_0x5d8223,'from_session':this[_0x597207(0xfe)]});}async['reply'](_0x5d5eeb,_0x421a0f,_0x5483b3='completed'){const _0x3cb3ce=a0_0x29f6d2;return this[_0x3cb3ce(0x128)](_0x3cb3ce(0x102),{'in_reply_to':_0x5d5eeb,'text':_0x421a0f,'status':_0x5483b3});}async[a0_0x29f6d2(0xd2)](_0x232854,_0x39568a){const _0x366dcb=a0_0x29f6d2;return this['call'](_0x366dcb(0x137),{'resume_id':this[_0x366dcb(0xf7)],'alias':this[_0x366dcb(0xfe)],'status':_0x232854,'server':a0_0x556524(),'hostname':a0_0x556524(),'agent':this[_0x366dcb(0xd4)],'project_dir':process[_0x366dcb(0x10e)](),..._0x39568a});}async[a0_0x29f6d2(0x14c)](){const _0x486d02=a0_0x29f6d2;return this[_0x486d02(0x128)](_0x486d02(0xe5),{});}async[a0_0x29f6d2(0x149)](_0x3edd45,_0x50f4ad){const _0x2ecec9=a0_0x29f6d2;return this[_0x2ecec9(0x128)]('broadcast',{'message':_0x3edd45,'filter_server':_0x50f4ad?.[_0x2ecec9(0x107)],'filter_status':_0x50f4ad?.[_0x2ecec9(0xd2)]});}async[a0_0x29f6d2(0xea)](){const _0x146165=a0_0x29f6d2;let _0x548ca4=encodeURIComponent(this[_0x146165(0xfe)]),_0x32aac0=this[_0x146165(0xde)]+_0x146165(0x115)+_0x548ca4,_0x265258=this[_0x146165(0x12a)];while(this[_0x146165(0x13d)]){try{this[_0x146165(0xe7)]=new AbortController();let _0x324a6a={'Accept':_0x146165(0x101)};if(this['token'])_0x324a6a[_0x146165(0xdb)]=_0x146165(0xff)+this['token'];let _0x5b2d05=await fetch(_0x32aac0,{'headers':_0x324a6a,'signal':this[_0x146165(0xe7)][_0x146165(0x10a)]});if(!_0x5b2d05['ok']||!_0x5b2d05[_0x146165(0x125)]){this[_0x146165(0x10d)]('SSE\x20failed:\x20'+_0x5b2d05[_0x146165(0xd2)]),await this[_0x146165(0x11e)](_0x265258),_0x265258=Math[_0x146165(0x153)](_0x265258*1.5,0xea60);continue;}_0x265258=this[_0x146165(0x12a)];let _0x29dd88=_0x5b2d05[_0x146165(0x125)][_0x146165(0xd8)](),_0x32503f=new TextDecoder(),_0x3c5491='';while(this['running']){let {done:_0x5b8dd7,value:_0x54f85c}=await _0x29dd88[_0x146165(0x131)]();if(_0x5b8dd7)break;_0x3c5491+=_0x32503f[_0x146165(0x130)](_0x54f85c,{'stream':!0x0});let _0x312c12=_0x3c5491[_0x146165(0x11b)]('\x0a');_0x3c5491=_0x312c12[_0x146165(0x14f)]()||'';for(let _0x632742 of _0x312c12){if(!_0x632742['startsWith'](_0x146165(0x112)))continue;try{let _0x1eb3cc=JSON['parse'](_0x632742['slice'](0x6));if(_0x1eb3cc[_0x146165(0x148)]==='connected'){this[_0x146165(0x10d)](_0x146165(0xee)),this[_0x146165(0x140)](_0x146165(0x11f));continue;}if(_0x1eb3cc['type']===_0x146165(0x10c)||_0x1eb3cc[_0x146165(0x148)]===_0x146165(0xef)||_0x1eb3cc[_0x146165(0x148)]===_0x146165(0x149))await this[_0x146165(0x124)]();}catch{}}}}catch(_0x3e3a0a){if(_0x3e3a0a[_0x146165(0x118)]==='AbortError')break;this['emit'](_0x146165(0xf9),_0x3e3a0a),this[_0x146165(0x10d)](_0x146165(0xd9)+_0x3e3a0a[_0x146165(0xf3)]);}if(this['running'])this[_0x146165(0x140)]('disconnected'),this[_0x146165(0x10d)](_0x146165(0xe9)+_0x265258/0x3e8+'s...'),await this['sleep'](_0x265258),_0x265258=Math[_0x146165(0x153)](_0x265258*1.5,0xea60);}}async[a0_0x29f6d2(0x124)](){const _0x17558b=a0_0x29f6d2;try{let _0x38a9c6=(await this[_0x17558b(0x128)](_0x17558b(0x100),{'alias':this['alias'],'limit':0xa}))?.[_0x17558b(0xe2)]||[];for(let _0x1dfddc of _0x38a9c6)await this[_0x17558b(0x128)](_0x17558b(0x146),{'alias':this['alias'],'message_id':_0x1dfddc['id']}),this[_0x17558b(0x10d)]('←\x20'+_0x1dfddc[_0x17558b(0xd6)]+':\x20'+_0x1dfddc['content'][_0x17558b(0xf8)](0x0,0x3c)),this['emit'](_0x17558b(0x113),_0x1dfddc),this[_0x17558b(0x140)](_0x17558b(0xf3),_0x1dfddc);}catch(_0x48e6b){this[_0x17558b(0x10d)](_0x17558b(0x151)+_0x48e6b['message']);}}[a0_0x29f6d2(0x11e)](_0xc24f30){return new Promise(_0x1789db=>setTimeout(_0x1789db,_0xc24f30));}}function a0_0x3ce0(_0x4af6fd,_0x13f14f){_0x4af6fd=_0x4af6fd-0xd2;const _0x57ce9a=a0_0x57ce();let _0x3ce01c=_0x57ce9a[_0x4af6fd];return _0x3ce01c;}var F=$;export{F as default,$ as CommHub};
|
|
1
|
+
const a0_0x418f2e=a0_0x4ae2;(function(_0x414e82,_0x3d2a95){const _0x1fe9b1=a0_0x4ae2,_0x2ef0e9=_0x414e82();while(!![]){try{const _0x2ca167=parseInt(_0x1fe9b1(0x1d4))/0x1*(parseInt(_0x1fe9b1(0x20d))/0x2)+-parseInt(_0x1fe9b1(0x1da))/0x3+-parseInt(_0x1fe9b1(0x20b))/0x4*(-parseInt(_0x1fe9b1(0x249))/0x5)+-parseInt(_0x1fe9b1(0x1d7))/0x6*(-parseInt(_0x1fe9b1(0x1de))/0x7)+parseInt(_0x1fe9b1(0x202))/0x8+-parseInt(_0x1fe9b1(0x21d))/0x9*(-parseInt(_0x1fe9b1(0x23e))/0xa)+-parseInt(_0x1fe9b1(0x1e0))/0xb;if(_0x2ca167===_0x3d2a95)break;else _0x2ef0e9['push'](_0x2ef0e9['shift']());}catch(_0x1461ff){_0x2ef0e9['push'](_0x2ef0e9['shift']());}}}(a0_0x2db5,0xaddbc));import{EventEmitter as a0_0x3c33ac}from'events';import{hostname as a0_0x40011f}from'os';function a0_0x4ae2(_0x3930bf,_0x142388){_0x3930bf=_0x3930bf-0x1c6;const _0x2db522=a0_0x2db5();let _0x4ae244=_0x2db522[_0x3930bf];return _0x4ae244;}var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x23311b,_0x20dbfb)=>(_0x23311b??_0x20dbfb)[a0_0x418f2e(0x228)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x418f2e(0x1df)](0x0,0xf0);function N(_0x2d4533){const _0x56d695=a0_0x418f2e;return(_0x2d4533 instanceof Error?_0x2d4533['message']:String(_0x2d4533??_0x56d695(0x1cf)))[_0x56d695(0x228)](K,_0x56d695(0x1f3))[_0x56d695(0x228)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x56d695(0x1df)](0x0,0xf0);}function O(_0x6c81c,_0x2d75d4=process.env.ANET_TASK_TRACE_FORMAT===a0_0x418f2e(0x234)){const _0x1021a1=a0_0x418f2e;if(_0x2d75d4)return JSON[_0x1021a1(0x224)](_0x6c81c);let _0x27bc4e=L(_0x6c81c[_0x1021a1(0x1f4)],_0x1021a1(0x244)),_0x3e07be=L(_0x6c81c['task_id'],_0x1021a1(0x226)),_0x58e920=_0x6c81c[_0x1021a1(0x1f9)]?_0x1021a1(0x203)+_0x6c81c[_0x1021a1(0x1f9)]+':'+(_0x6c81c['error_message']??''):'';return _0x1021a1(0x20f)+_0x6c81c[_0x1021a1(0x200)]+_0x1021a1(0x23d)+L(_0x6c81c[_0x1021a1(0x240)],'<unknown>')+_0x1021a1(0x1c6)+L(_0x6c81c[_0x1021a1(0x1d2)],_0x1021a1(0x23b))+'\x20task_id='+_0x3e07be+_0x1021a1(0x1e3)+_0x27bc4e+_0x1021a1(0x1f7)+L(_0x6c81c[_0x1021a1(0x227)],_0x1021a1(0x23b))+_0x1021a1(0x1d8)+_0x6c81c['transport']+_0x1021a1(0x1d3)+_0x6c81c[_0x1021a1(0x1cb)]+_0x1021a1(0x1fa)+_0x6c81c[_0x1021a1(0x212)]+_0x58e920;}function U(_0x5da40b){const _0xde4c72=a0_0x418f2e;return{'event':{'sending':_0xde4c72(0x1f5),'delivered':'task.send.delivered','failed':_0xde4c72(0x23f),'acked':_0xde4c72(0x1ea),'started':_0xde4c72(0x235),'replied':_0xde4c72(0x245),'expired':_0xde4c72(0x209)}[_0x5da40b[_0xde4c72(0x200)]],..._0x5da40b};}function j(_0x3382f6){const _0x4bb307=a0_0x418f2e;let _0xa879f7=_0x3382f6?.[_0x4bb307(0x1fc)]||_0x3382f6?.[_0x4bb307(0x206)]||_0x3382f6?.['id'];if(_0xa879f7)return String(_0xa879f7);let _0x526c45=_0x3382f6?.['content']?.[0x0]?.[_0x4bb307(0x243)];if(typeof _0x526c45!==_0x4bb307(0x1cd))return null;try{let _0x38e9e5=JSON[_0x4bb307(0x1e7)](_0x526c45);return _0x38e9e5?.[_0x4bb307(0x1fc)]||_0x38e9e5?.[_0x4bb307(0x206)]||_0x38e9e5?.['id']||null;}catch{return null;}}async function X(_0x386454,_0x10c3cc){const _0x139d5f=a0_0x418f2e;let _0x2ee677=_0x10c3cc[_0x139d5f(0x1d6)]??Date[_0x139d5f(0x1d6)],_0x19f050=_0x2ee677(),_0x444823=(_0x4f91f3,_0x42141b,_0x2f6f23,_0x5d2fa8)=>{const _0x4f467f=_0x139d5f;_0x10c3cc['log'](O(U({'from_alias':_0x386454[_0x4f467f(0x1d0)],'to_alias':_0x386454[_0x4f467f(0x207)],'task_id':_0x42141b,'parent_task_id':_0x386454[_0x4f467f(0x1ec)],'network_id':_0x386454[_0x4f467f(0x21f)],'transport':_0x386454['transport'],'status':_0x4f91f3,'duration_ms':_0x2ee677()-_0x19f050,'lifecycle_tracking':_0x386454[_0x4f467f(0x1e8)],..._0x2f6f23!==void 0x0?{'error_code':_0x5d2fa8||'send_failed','error_message':N(_0x2f6f23)}:{}})));};_0x444823(_0x139d5f(0x218),null);try{let _0x5815d1=await _0x10c3cc[_0x139d5f(0x20a)](),_0x459d3f=j(_0x5815d1);if(_0x459d3f)_0x444823(_0x139d5f(0x237),_0x459d3f);else{if(_0x5815d1?.['ok']===!0x1||_0x5815d1?.['error'])_0x444823(_0x139d5f(0x213),_0x459d3f,_0x5815d1?.[_0x139d5f(0x220)]||_0x139d5f(0x246),'send_rejected');else _0x444823(_0x139d5f(0x213),null,_0x139d5f(0x236),_0x139d5f(0x1e4));}return _0x5815d1;}catch(_0x20ded1){throw _0x444823('failed',null,_0x20ded1,_0x139d5f(0x22a)),_0x20ded1;}}async function Y(_0x5961f6,_0x88fc19){const _0x461eac=a0_0x418f2e;return X({'fromAlias':_0x5961f6[_0x461eac(0x1d0)],'toAlias':_0x5961f6[_0x461eac(0x21e)],'parentTaskId':_0x5961f6['parentTaskId']||null,'networkId':_0x5961f6['networkId']||null,'transport':_0x461eac(0x22b),'lifecycleTracking':_0x461eac(0x214)},_0x88fc19);}function a0_0x2db5(){const _0x3a0e0f=['messages','text/event-stream','Bearer\x20','<unknown>','task','\x20from=','10pnJlVW','task.send.failed','from_alias','completed','reconnectDelay','text','<missing>','task.replied','CommHub\x20rejected\x20task','offline','application/json,\x20text/event-stream','65uZhAJs','broadcast','/mcp','\x20to=','split','reply','application/json','tools/call','duration_ms','registered','string','2.0','unknown\x20error','fromAlias','result','to_alias','\x20duration_ms=','661LfXISq','connected','now','25320dRyDcN','\x20transport=','from_session','2154669prVdpi','SSE\x20reconnecting\x20in\x20','new_task','SSE\x20failed:\x20','679NlqOne','slice','25173676ewFqvC','inbox\x20error:\x20','connect','\x20parent_task_id=','missing_task_id','getReader','running','parse','lifecycleTracking','body','task.ack','token','parentTaskId','decode','report_status',']\x20[commhub:','idle','agent','/events/','[REDACTED]','parent_task_id','task.send.start','sleep','\x20network_id=','connectSSE','error_code','\x20lifecycle=','match','task_id','send_message','abort','sseAbort','status','log','4078728BXYJXT','\x20error=','call','cwd','message_id','toAlias','url','task.expired','send','413032guJolz','catch','2932Tunygv','message','[commhub:task]\x20','emit','type','lifecycle_tracking','failed','not_tracked','send_task','heartbeatTimer','data:\x20','sending','disconnected','heartbeatInterval','autoConnect','content','4394718tSvqSZ','alias','networkId','error','min','SSE\x20connected','Authorization','stringify','new_message','<pending>','network_id','replace','server','send_failed','mcp_http','resumeId','sdk-','sdk','normal','toString','pop','AbortError','processInbox','json','task.started','CommHub\x20response\x20omitted\x20task_id','delivered'];a0_0x2db5=function(){return _0x3a0e0f;};return a0_0x2db5();}class $ extends a0_0x3c33ac{[a0_0x418f2e(0x208)];['alias'];['token'];[a0_0x418f2e(0x1f1)];[a0_0x418f2e(0x22c)];[a0_0x418f2e(0x21a)];['reconnectDelay'];[a0_0x418f2e(0x216)];[a0_0x418f2e(0x1ff)];[a0_0x418f2e(0x1e6)]=!0x1;constructor(_0x29c6f7){const _0x477eab=a0_0x418f2e;super();if(this['url']=_0x29c6f7[_0x477eab(0x208)][_0x477eab(0x228)](/\/$/,''),this[_0x477eab(0x21e)]=_0x29c6f7['alias'],this['token']=_0x29c6f7[_0x477eab(0x1eb)],this[_0x477eab(0x1f1)]=_0x29c6f7[_0x477eab(0x1f1)]||_0x477eab(0x22e),this[_0x477eab(0x22c)]=_0x477eab(0x22d)+_0x29c6f7[_0x477eab(0x21e)]+'-'+Date[_0x477eab(0x1d6)]()[_0x477eab(0x230)](0x24),this['heartbeatInterval']=_0x29c6f7[_0x477eab(0x21a)]??0x2bf20,this[_0x477eab(0x242)]=_0x29c6f7[_0x477eab(0x242)]??0xbb8,_0x29c6f7[_0x477eab(0x21b)]!==!0x1)this[_0x477eab(0x1e2)]();}[a0_0x418f2e(0x201)](_0x35d769){const _0xe987d=a0_0x418f2e;console[_0xe987d(0x201)]('['+new Date()['toTimeString']()['slice'](0x0,0x8)+_0xe987d(0x1ef)+this['alias']+']\x20'+_0x35d769);}async[a0_0x418f2e(0x204)](_0x140740,_0x11398c){const _0x230cb2=a0_0x418f2e;let _0x198aff={'Content-Type':_0x230cb2(0x1c9),'Accept':_0x230cb2(0x248)};if(this[_0x230cb2(0x1eb)])_0x198aff[_0x230cb2(0x223)]='Bearer\x20'+this['token'];let _0x5b37eb=await(await fetch(this[_0x230cb2(0x208)]+_0x230cb2(0x24b),{'method':'POST','headers':_0x198aff,'body':JSON[_0x230cb2(0x224)]({'jsonrpc':_0x230cb2(0x1ce),'id':Date['now'](),'method':_0x230cb2(0x1ca),'params':{'name':_0x140740,'arguments':_0x11398c}})}))['text'](),_0x2f2793=_0x5b37eb[_0x230cb2(0x1fb)](/data: (.+)/),_0x3a401=_0x2f2793?JSON[_0x230cb2(0x1e7)](_0x2f2793[0x1]):JSON[_0x230cb2(0x1e7)](_0x5b37eb),_0x1ebb0a=_0x3a401?.[_0x230cb2(0x1d1)]?.[_0x230cb2(0x21c)]?.[0x0]?.[_0x230cb2(0x243)];return _0x1ebb0a?JSON[_0x230cb2(0x1e7)](_0x1ebb0a):_0x3a401;}async[a0_0x418f2e(0x1e2)](){const _0x3f30ec=a0_0x418f2e;if(this[_0x3f30ec(0x1e6)])return;this['running']=!0x0,await this['status'](_0x3f30ec(0x1f0)),this[_0x3f30ec(0x201)](_0x3f30ec(0x1cc)),this['heartbeatTimer']=setInterval(()=>{const _0x58c58c=_0x3f30ec;this[_0x58c58c(0x200)](_0x58c58c(0x1f0))[_0x58c58c(0x20c)](_0x13c4a7=>this[_0x58c58c(0x201)]('heartbeat\x20failed:\x20'+_0x13c4a7[_0x58c58c(0x20e)]));},this[_0x3f30ec(0x21a)]),this[_0x3f30ec(0x1f8)]();}async['disconnect'](){const _0x1cf5d2=a0_0x418f2e;if(this[_0x1cf5d2(0x1e6)]=!0x1,this[_0x1cf5d2(0x1ff)]?.[_0x1cf5d2(0x1fe)](),this['heartbeatTimer'])clearInterval(this['heartbeatTimer']);await this['status'](_0x1cf5d2(0x247))[_0x1cf5d2(0x20c)](()=>{}),this[_0x1cf5d2(0x201)]('disconnected');}async['send'](_0x25c32e,_0x21d1e5,_0x5a7e01=a0_0x418f2e(0x22f)){const _0x2da13b=a0_0x418f2e;return Y({'alias':_0x25c32e,'fromAlias':this[_0x2da13b(0x21e)]},{'log':_0x43f255=>console[_0x2da13b(0x201)](_0x43f255),'send':()=>this[_0x2da13b(0x204)](_0x2da13b(0x215),{'alias':_0x25c32e,'task':_0x21d1e5,'priority':_0x5a7e01,'from_session':this['alias']})});}async['message'](_0x2f067f,_0x4b4378){const _0x1b6958=a0_0x418f2e;return this[_0x1b6958(0x204)](_0x1b6958(0x1fd),{'alias':_0x2f067f,'message':_0x4b4378,'from_session':this[_0x1b6958(0x21e)]});}async[a0_0x418f2e(0x1c8)](_0x9cdd79,_0x4f727d,_0x2d6efc=a0_0x418f2e(0x241)){const _0x29e572=a0_0x418f2e;return this[_0x29e572(0x204)]('send_reply',{'in_reply_to':_0x9cdd79,'text':_0x4f727d,'status':_0x2d6efc});}async[a0_0x418f2e(0x200)](_0x146675,_0x236f0b){const _0x555737=a0_0x418f2e;return this['call'](_0x555737(0x1ee),{'resume_id':this[_0x555737(0x22c)],'alias':this['alias'],'status':_0x146675,'server':a0_0x40011f(),'hostname':a0_0x40011f(),'agent':this[_0x555737(0x1f1)],'project_dir':process[_0x555737(0x205)](),..._0x236f0b});}async['getAllStatus'](){const _0x32b6e7=a0_0x418f2e;return this[_0x32b6e7(0x204)]('get_all_status',{});}async[a0_0x418f2e(0x24a)](_0x1d2d68,_0x43f8fd){const _0x5174d8=a0_0x418f2e;return this[_0x5174d8(0x204)](_0x5174d8(0x24a),{'message':_0x1d2d68,'filter_server':_0x43f8fd?.[_0x5174d8(0x229)],'filter_status':_0x43f8fd?.[_0x5174d8(0x200)]});}async[a0_0x418f2e(0x1f8)](){const _0x57c991=a0_0x418f2e;let _0x25fb9e=encodeURIComponent(this['alias']),_0x38dc04=this[_0x57c991(0x208)]+_0x57c991(0x1f2)+_0x25fb9e,_0x451857=this[_0x57c991(0x242)];while(this[_0x57c991(0x1e6)]){try{this[_0x57c991(0x1ff)]=new AbortController();let _0x5cbed6={'Accept':_0x57c991(0x239)};if(this[_0x57c991(0x1eb)])_0x5cbed6['Authorization']=_0x57c991(0x23a)+this['token'];let _0x3101d8=await fetch(_0x38dc04,{'headers':_0x5cbed6,'signal':this[_0x57c991(0x1ff)]['signal']});if(!_0x3101d8['ok']||!_0x3101d8['body']){this['log'](_0x57c991(0x1dd)+_0x3101d8[_0x57c991(0x200)]),await this['sleep'](_0x451857),_0x451857=Math[_0x57c991(0x221)](_0x451857*1.5,0xea60);continue;}_0x451857=this['reconnectDelay'];let _0x1702c4=_0x3101d8[_0x57c991(0x1e9)][_0x57c991(0x1e5)](),_0x4e4ec8=new TextDecoder(),_0x24a903='';while(this[_0x57c991(0x1e6)]){let {done:_0x1838ba,value:_0x362820}=await _0x1702c4['read']();if(_0x1838ba)break;_0x24a903+=_0x4e4ec8[_0x57c991(0x1ed)](_0x362820,{'stream':!0x0});let _0x440a29=_0x24a903[_0x57c991(0x1c7)]('\x0a');_0x24a903=_0x440a29[_0x57c991(0x231)]()||'';for(let _0x2973ff of _0x440a29){if(!_0x2973ff['startsWith'](_0x57c991(0x217)))continue;try{let _0x236248=JSON[_0x57c991(0x1e7)](_0x2973ff['slice'](0x6));if(_0x236248[_0x57c991(0x211)]==='connected'){this['log'](_0x57c991(0x222)),this[_0x57c991(0x210)](_0x57c991(0x1d5));continue;}if(_0x236248[_0x57c991(0x211)]===_0x57c991(0x1dc)||_0x236248['type']===_0x57c991(0x225)||_0x236248[_0x57c991(0x211)]===_0x57c991(0x24a))await this[_0x57c991(0x233)]();}catch{}}}}catch(_0x4ee57e){if(_0x4ee57e['name']===_0x57c991(0x232))break;this[_0x57c991(0x210)](_0x57c991(0x220),_0x4ee57e),this[_0x57c991(0x201)]('SSE\x20error:\x20'+_0x4ee57e[_0x57c991(0x20e)]);}if(this['running'])this[_0x57c991(0x210)](_0x57c991(0x219)),this['log'](_0x57c991(0x1db)+_0x451857/0x3e8+'s...'),await this[_0x57c991(0x1f6)](_0x451857),_0x451857=Math['min'](_0x451857*1.5,0xea60);}}async[a0_0x418f2e(0x233)](){const _0x144cdb=a0_0x418f2e;try{let _0x12793b=(await this['call']('get_inbox',{'alias':this[_0x144cdb(0x21e)],'limit':0xa}))?.[_0x144cdb(0x238)]||[];for(let _0x486355 of _0x12793b)await this[_0x144cdb(0x204)]('ack_inbox',{'alias':this[_0x144cdb(0x21e)],'message_id':_0x486355['id']}),this[_0x144cdb(0x201)]('←\x20'+_0x486355[_0x144cdb(0x1d9)]+':\x20'+_0x486355[_0x144cdb(0x21c)][_0x144cdb(0x1df)](0x0,0x3c)),this['emit'](_0x144cdb(0x23c),_0x486355),this[_0x144cdb(0x210)](_0x144cdb(0x20e),_0x486355);}catch(_0x329f2e){this[_0x144cdb(0x201)](_0x144cdb(0x1e1)+_0x329f2e[_0x144cdb(0x20e)]);}}[a0_0x418f2e(0x1f6)](_0x47d15c){return new Promise(_0x3c0ed9=>setTimeout(_0x3c0ed9,_0x47d15c));}}var F=$;export{F as default,$ as CommHub};
|
|
@@ -13,5 +13,18 @@ export interface MigratedCodexPendingThread {
|
|
|
13
13
|
*/
|
|
14
14
|
export declare function migrateCodexPendingThread(value: unknown, oldServerUrl: unknown, expectedOldMarker: unknown, newServerUrl: string, newMarker: string): MigratedCodexPendingThread;
|
|
15
15
|
export declare function requirePromotedCodexPendingThread(value: unknown, pendingThreadId: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* argv for the human TUI attached to the co-presence app-server.
|
|
18
|
+
*
|
|
19
|
+
* #505 — the permission override is only passed on the FRESH path. On
|
|
20
|
+
* `resume --remote <ws> <thread>` codex 0.155.1 exits immediately with
|
|
21
|
+
* "Error: Permission overrides are not supported when resuming a remote task."
|
|
22
|
+
* (anet then reports "TUI tmux session exited during startup"). Measured in
|
|
23
|
+
* Docker against a real app-server + real thread: 0.155.1 rejects
|
|
24
|
+
* resume + --dangerously-bypass-approvals-and-sandbox and accepts it fresh
|
|
25
|
+
* (TUI up, "permissions: YOLO mode"); 0.133.0 (agent-node's pin) accepts both.
|
|
26
|
+
* Nothing is lost by dropping it on resume: the app-server itself is started
|
|
27
|
+
* with `-c approval_policy=… -c sandbox_mode=…` from the same posture.
|
|
28
|
+
*/
|
|
16
29
|
export declare function codexTuiLaunchArgs(remote: string, model: string, threadId?: string, dangerFullAccess?: boolean): string[];
|
|
17
30
|
export declare function assertPendingServerQuiesced(serverUrl: unknown, isListening: (port: number) => boolean | Promise<boolean>): Promise<void>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export declare const COMMHUB_SERVER_PKG = "@sleep2agi/commhub-server";
|
|
2
|
+
export declare const AGENT_NETWORK_PKG = "@sleep2agi/agent-network";
|
|
3
|
+
export type HubReleaseChannel = "latest" | "preview";
|
|
4
|
+
export type HubVersionSource = "explicit" | "registry" | "cache" | "pinned-floor";
|
|
5
|
+
export interface DistTags {
|
|
6
|
+
latest?: string | null;
|
|
7
|
+
preview?: string | null;
|
|
8
|
+
}
|
|
9
|
+
export declare function isExactSemver(v: string | null | undefined): boolean;
|
|
10
|
+
/** Semver precedence. Unparseable versions sort lowest. */
|
|
11
|
+
export declare function compareSemver(a: string, b: string): number;
|
|
12
|
+
export declare function resolveHubChannel(input: {
|
|
13
|
+
anetVersion: string;
|
|
14
|
+
flag?: string | null;
|
|
15
|
+
anetDistTags: DistTags | null;
|
|
16
|
+
}): {
|
|
17
|
+
channel: HubReleaseChannel;
|
|
18
|
+
reason: string;
|
|
19
|
+
};
|
|
20
|
+
export interface HubVersionDecision {
|
|
21
|
+
version: string;
|
|
22
|
+
source: HubVersionSource;
|
|
23
|
+
channel: HubReleaseChannel | null;
|
|
24
|
+
/** true when `version` is already present in the local bun install cache. */
|
|
25
|
+
cached: boolean;
|
|
26
|
+
/** One-line, human readable "where it came from". */
|
|
27
|
+
origin: string;
|
|
28
|
+
/** Must be printed prominently (stderr). */
|
|
29
|
+
warnings: string[];
|
|
30
|
+
}
|
|
31
|
+
export declare function decideHubServerVersion(input: {
|
|
32
|
+
explicit?: string | null;
|
|
33
|
+
channelFlag?: string | null;
|
|
34
|
+
anetVersion: string;
|
|
35
|
+
anetDistTags: DistTags | null;
|
|
36
|
+
serverDistTags: DistTags | null;
|
|
37
|
+
floor: string;
|
|
38
|
+
cachedVersions: string[];
|
|
39
|
+
}): HubVersionDecision;
|
|
40
|
+
export type ExecFn = (cmd: string, args: string[]) => string;
|
|
41
|
+
export declare function fetchDistTags(exec: ExecFn, pkg: string): DistTags | null;
|
|
42
|
+
export interface CacheFs {
|
|
43
|
+
existsSync(p: string): boolean;
|
|
44
|
+
readdirSync(p: string): string[];
|
|
45
|
+
readFileSync(p: string): string;
|
|
46
|
+
}
|
|
47
|
+
export declare function bunInstallCacheDir(env?: NodeJS.ProcessEnv, home?: string): string;
|
|
48
|
+
/**
|
|
49
|
+
* Versions of commhub-server present in bun's install cache. Bun uses two
|
|
50
|
+
* layouts (`@sleep2agi/commhub-server@<ver-or-hash>@@@1/` and
|
|
51
|
+
* `@sleep2agi/commhub-server/<ver-or-hash>@@@1/`); prerelease parts are
|
|
52
|
+
* hashed in the directory name, so the version is read from package.json.
|
|
53
|
+
*/
|
|
54
|
+
export declare function listCachedServerVersions(cacheDir: string, fs?: CacheFs): string[];
|
|
55
|
+
export declare function resolveHubServerVersion(input: {
|
|
56
|
+
explicit?: string | null;
|
|
57
|
+
channelFlag?: string | null;
|
|
58
|
+
anetVersion: string;
|
|
59
|
+
floor: string;
|
|
60
|
+
exec: ExecFn;
|
|
61
|
+
cacheDir: string;
|
|
62
|
+
fs?: CacheFs;
|
|
63
|
+
}): HubVersionDecision;
|
|
64
|
+
export declare function formatHubVersionBanner(d: HubVersionDecision): string;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
export interface CloneArgs {
|
|
2
|
+
source: string;
|
|
3
|
+
target: string;
|
|
4
|
+
/** Raw --workdir as typed (resolved later against cwd). */
|
|
5
|
+
workdir?: string;
|
|
6
|
+
model?: string;
|
|
7
|
+
start: boolean;
|
|
8
|
+
}
|
|
9
|
+
export type CloneArgsResult = {
|
|
10
|
+
ok: true;
|
|
11
|
+
args: CloneArgs;
|
|
12
|
+
} | {
|
|
13
|
+
ok: false;
|
|
14
|
+
error: string;
|
|
15
|
+
} | {
|
|
16
|
+
ok: false;
|
|
17
|
+
help: true;
|
|
18
|
+
};
|
|
19
|
+
export declare const NODE_CLONE_USAGE = "anet node clone <source> <new-name> [--workdir <dir>] [--model <id>] [--start]\nanet node create <new-name> --from <source> [--workdir <dir>] [--model <id>] [--start]\n\n Make a new node with the same settings as <source>, under a NEW identity.\n The clone is registered with the Hub as its own node (new node_id + token);\n it never shares the source's identity, session, login or logs.\n\n Copied: runtime, model, tools, permission flags, prompts, non-secret env,\n rules file / skills / .mcp.json (with --workdir)\n Regenerated: node_id, token, session id, co-presence sockets\n Not copied: token, sessions/threads, logs, inbox, channel bot credentials,\n codex auth.json, secret env values (key names are kept)\n\n --workdir <dir> Put the clone in another project directory (created if\n missing; path must be ASCII). Default: the source's project\n directory (the current one), sharing its rules file/skills.\n --model <id> Use a different model than the source.\n --start Start the clone right after creating it.\n\n Never copy a node directory with cp -r: the copy keeps the same node_id and\n token, so the Hub delivers every task to both processes and it runs twice.";
|
|
20
|
+
/**
|
|
21
|
+
* Parse the tokens after the verb.
|
|
22
|
+
* mode "clone": [<source>, <new>, ...flags]
|
|
23
|
+
* mode "create-from": [<new>, ...flags] with a required --from <source>
|
|
24
|
+
*/
|
|
25
|
+
export declare function parseCloneArgs(tokens: readonly string[], mode: "clone" | "create-from"): CloneArgsResult;
|
|
26
|
+
/** Project rule: node working directories are ASCII (aliases may be Chinese, directories not). */
|
|
27
|
+
export declare function isAsciiPath(p: string): boolean;
|
|
28
|
+
export interface RefusalInput {
|
|
29
|
+
sourceId: string;
|
|
30
|
+
sourceProfile: Record<string, any>;
|
|
31
|
+
target: string;
|
|
32
|
+
sourceNodeDir: string;
|
|
33
|
+
targetNodeDir: string;
|
|
34
|
+
/** Present only when --workdir was given; absolute. */
|
|
35
|
+
explicitWorkdir?: string;
|
|
36
|
+
}
|
|
37
|
+
/** Every reason to stop before touching the Hub or the disk. null = go. */
|
|
38
|
+
export declare function cloneRefusal(i: RefusalInput): string | null;
|
|
39
|
+
export interface LedgerItem {
|
|
40
|
+
item: string;
|
|
41
|
+
note?: string;
|
|
42
|
+
}
|
|
43
|
+
export interface CloneLedger {
|
|
44
|
+
copied: LedgerItem[];
|
|
45
|
+
regenerated: LedgerItem[];
|
|
46
|
+
skipped: LedgerItem[];
|
|
47
|
+
/** env keys whose value is a secret: the clone references `ref`, which the user must set. */
|
|
48
|
+
secrets: {
|
|
49
|
+
key: string;
|
|
50
|
+
ref: string;
|
|
51
|
+
}[];
|
|
52
|
+
}
|
|
53
|
+
export declare function emptyLedger(): CloneLedger;
|
|
54
|
+
export interface PlanInput {
|
|
55
|
+
sourceProfile: Record<string, any>;
|
|
56
|
+
target: string;
|
|
57
|
+
newNodeId: string;
|
|
58
|
+
/** Absolute project directory the clone will live in. */
|
|
59
|
+
targetWorkdir: string;
|
|
60
|
+
modelOverride?: string;
|
|
61
|
+
/** New claude-code-cli session id. */
|
|
62
|
+
newSession: () => string;
|
|
63
|
+
/** grok co-presence socket fields for the new node id (grokBuildCliCreationFields). */
|
|
64
|
+
grokFields?: (nodeId: string) => Record<string, unknown>;
|
|
65
|
+
}
|
|
66
|
+
/** Build the clone's profile (no token yet) and the ledger of what happened to each field. */
|
|
67
|
+
export declare function planCloneProfile(p: PlanInput, ledger?: CloneLedger): {
|
|
68
|
+
profile: Record<string, any>;
|
|
69
|
+
ledger: CloneLedger;
|
|
70
|
+
};
|
|
71
|
+
/** Files a codex-home may carry to the clone. Never auth.json, never .anet-copresence.env. */
|
|
72
|
+
export declare const CODEX_HOME_COPY: readonly ["config.toml", "AGENTS.md", "version.json"];
|
|
73
|
+
export declare const CODEX_HOME_COPY_DIRS: readonly ["skills"];
|
|
74
|
+
/** Workdir-level settings copied only when the clone gets its own --workdir. */
|
|
75
|
+
export declare const WORKDIR_COPY_FILES: readonly ["CLAUDE.md", "AGENTS.md"];
|
|
76
|
+
export declare const WORKDIR_COPY_DIRS: readonly [".claude/skills", ".agents/skills", ".grok/skills", ".opencode/skill", ".opencode/skills"];
|
|
77
|
+
/** Recursive copy that never follows symlinks and never copies credential-looking files. Returns files copied. */
|
|
78
|
+
export declare function copyTreeSafe(from: string, to: string, skipped: LedgerItem[], label: string): number;
|
|
79
|
+
/** Strip values from env/headers of every MCP server; drop the commhub entry (regenerated at start). */
|
|
80
|
+
export declare function sanitizeMcpJson(raw: string): {
|
|
81
|
+
text: string;
|
|
82
|
+
blanked: string[];
|
|
83
|
+
};
|
|
84
|
+
export interface CopyFilesInput {
|
|
85
|
+
sourceNodeDir: string;
|
|
86
|
+
targetNodeDir: string;
|
|
87
|
+
sourceWorkdir: string;
|
|
88
|
+
targetWorkdir: string;
|
|
89
|
+
}
|
|
90
|
+
/** Copy the whitelisted on-disk settings. The target node dir must already exist. */
|
|
91
|
+
export declare function copyCloneFiles(i: CopyFilesInput, ledger: CloneLedger): void;
|
|
92
|
+
export interface RunCloneInput {
|
|
93
|
+
sourceId: string;
|
|
94
|
+
/** Raw source config.json (as stored, before normalisation). */
|
|
95
|
+
sourceProfile: Record<string, any>;
|
|
96
|
+
target: string;
|
|
97
|
+
sourceNodeDir: string;
|
|
98
|
+
sourceWorkdir: string;
|
|
99
|
+
targetWorkdir: string;
|
|
100
|
+
/** True when the user passed --workdir. */
|
|
101
|
+
explicitWorkdir: boolean;
|
|
102
|
+
modelOverride?: string;
|
|
103
|
+
newNodeId: () => string;
|
|
104
|
+
newSession: () => string;
|
|
105
|
+
grokFields?: (nodeId: string) => Record<string, unknown>;
|
|
106
|
+
/** Hub registration — returns the new node's ntok_. Same endpoint `anet node create` uses. */
|
|
107
|
+
register: (profile: Record<string, any>) => Promise<string>;
|
|
108
|
+
/** Write config.json into targetNodeDir (the CLI passes its create writer). */
|
|
109
|
+
persist: (profile: Record<string, any>, targetNodeDir: string) => void;
|
|
110
|
+
}
|
|
111
|
+
export type RunCloneResult = {
|
|
112
|
+
ok: true;
|
|
113
|
+
profile: Record<string, any>;
|
|
114
|
+
ledger: CloneLedger;
|
|
115
|
+
targetNodeDir: string;
|
|
116
|
+
} | {
|
|
117
|
+
ok: false;
|
|
118
|
+
stage: "refused" | "register" | "write";
|
|
119
|
+
error: string;
|
|
120
|
+
};
|
|
121
|
+
export declare function runNodeClone(i: RunCloneInput): Promise<RunCloneResult>;
|
|
122
|
+
/** Test/default writer: the same config.json whitelist `anet node create` persists, mode 0600. */
|
|
123
|
+
export declare function defaultClonePersist(profile: Record<string, any>, targetNodeDir: string): void;
|
|
124
|
+
/** The summary table printed after a clone. Never prints a token or a secret value. */
|
|
125
|
+
export declare function formatCloneSummary(r: {
|
|
126
|
+
source: string;
|
|
127
|
+
target: string;
|
|
128
|
+
profile: Record<string, any>;
|
|
129
|
+
ledger: CloneLedger;
|
|
130
|
+
targetNodeDir: string;
|
|
131
|
+
sourceNodeId?: string;
|
|
132
|
+
}): string;
|
|
133
|
+
/** realpath that tolerates a missing path (resolves the nearest existing parent). */
|
|
134
|
+
export declare function realpathLoose(p: string): string;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export interface NodeIdentityFromConfig {
|
|
2
|
+
node_id?: string;
|
|
3
|
+
node_name?: string;
|
|
4
|
+
model?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function nodeIdentityFromConfig(path: string | undefined): NodeIdentityFromConfig;
|
|
7
|
+
export interface NodeRowLike {
|
|
8
|
+
node_id?: string | null;
|
|
9
|
+
alias?: string | null;
|
|
10
|
+
runtime?: string | null;
|
|
11
|
+
config_path?: string | null;
|
|
12
|
+
}
|
|
13
|
+
export type NodeIdClaimVerdict = {
|
|
14
|
+
claim: true;
|
|
15
|
+
} | {
|
|
16
|
+
claim: false;
|
|
17
|
+
owner: string;
|
|
18
|
+
runtime: string | null;
|
|
19
|
+
config_path: string | null;
|
|
20
|
+
};
|
|
21
|
+
export declare function nodeIdClaimVerdict(nodeId: string, rows: readonly NodeRowLike[], alias: string): NodeIdClaimVerdict;
|
|
22
|
+
export type NodeIdClaimState = "ok" | "conflict" | "unknown";
|
|
23
|
+
/** 取 hub 上这个 node_id 的行并下结论;任何失败都是 "unknown"(调用方这次不报 node_id)。 */
|
|
24
|
+
export declare function checkNodeIdClaim(opts: {
|
|
25
|
+
hubUrl: string;
|
|
26
|
+
token: string;
|
|
27
|
+
nodeId: string;
|
|
28
|
+
alias: string;
|
|
29
|
+
fetchImpl?: typeof fetch;
|
|
30
|
+
timeoutMs?: number;
|
|
31
|
+
}): Promise<{
|
|
32
|
+
state: NodeIdClaimState;
|
|
33
|
+
verdict?: NodeIdClaimVerdict;
|
|
34
|
+
error?: string;
|
|
35
|
+
}>;
|