@sleep2agi/agent-network 2.3.0-preview.135 → 2.3.0-preview.137

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- function a0_0x32d5(_0x202cc2,_0x317bda){_0x202cc2=_0x202cc2-0x1c7;const _0x3abf7b=a0_0x3abf();let _0x32d5d8=_0x3abf7b[_0x202cc2];return _0x32d5d8;}const a0_0x27dbbc=a0_0x32d5;(function(_0x160a70,_0x1f819e){const _0x5c7329=a0_0x32d5,_0x18c32c=_0x160a70();while(!![]){try{const _0x43d550=parseInt(_0x5c7329(0x212))/0x1*(parseInt(_0x5c7329(0x228))/0x2)+parseInt(_0x5c7329(0x243))/0x3+-parseInt(_0x5c7329(0x1c7))/0x4+-parseInt(_0x5c7329(0x1d0))/0x5+parseInt(_0x5c7329(0x1ec))/0x6+parseInt(_0x5c7329(0x1f9))/0x7+parseInt(_0x5c7329(0x1e4))/0x8;if(_0x43d550===_0x1f819e)break;else _0x18c32c['push'](_0x18c32c['shift']());}catch(_0x362491){_0x18c32c['push'](_0x18c32c['shift']());}}}(a0_0x3abf,0x6ccde));function a0_0x3abf(){const _0x38599e=['\x20to=','parse','send_rejected','[commhub:task]\x20','url','messages','52374SUtOTe','3068344NWlipA','log','connectSSE','processInbox','cwd','message','toString','\x20error=','[REDACTED]','2568310wxeUsr','POST','status','inbox\x20error:\x20','new_message','send_failed','data:\x20','call','\x20lifecycle=','Authorization','parentTaskId','heartbeatTimer','resumeId','send_reply','task.send.failed','startsWith','connect','sleep','\x20transport=','network_id','2134352HHdAMA','now','message_id','SSE\x20reconnecting\x20in\x20','CommHub\x20response\x20omitted\x20task_id','agent','server','task_id','2648466AFYMuz','mcp_http','SSE\x20error:\x20','content','reconnectDelay','catch','fromAlias','slice',']\x20[commhub:','send_message','body','string','/mcp','1684921esegER','CommHub\x20rejected\x20task','get_all_status','alias','\x20parent_task_id=','heartbeat\x20failed:\x20','AbortError','normal','sdk','failed','connected','broadcast','task.started','getReader','lifecycle_tracking','networkId','json','token','send','SSE\x20connected','toTimeString','name','send_task','error','reply','126674DdYNIh','task.send.start','result','parent_task_id','signal','replace','report_status','completed','stringify','abort','decode','error_code','type','disconnected','from_session','task.replied','pop','Bearer\x20','task.send.delivered','heartbeatInterval','s...','application/json,\x20text/event-stream','12mguenX','transport','text','\x20network_id=','running','sseAbort','application/json','idle','/events/','task.ack','tools/call','\x20duration_ms=','emit','registered','to_alias','<missing>','not_tracked','\x20task_id=','disconnect','min','lifecycleTracking'];a0_0x3abf=function(){return _0x38599e;};return a0_0x3abf();}import{EventEmitter as a0_0x5a18ff}from'events';import{hostname as a0_0x20ee56}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x2c52d0,_0x3f3961)=>(_0x2c52d0??_0x3f3961)[a0_0x27dbbc(0x217)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x27dbbc(0x1f3)](0x0,0xf0);function N(_0x327994){const _0x1e006d=a0_0x27dbbc;return(_0x327994 instanceof Error?_0x327994[_0x1e006d(0x1cc)]:String(_0x327994??'unknown\x20error'))[_0x1e006d(0x217)](K,_0x1e006d(0x1cf))[_0x1e006d(0x217)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x33c811,_0x121400=process.env.ANET_TASK_TRACE_FORMAT===a0_0x27dbbc(0x209)){const _0x443560=a0_0x27dbbc;if(_0x121400)return JSON[_0x443560(0x21a)](_0x33c811);let _0x7cb051=L(_0x33c811[_0x443560(0x215)],_0x443560(0x237)),_0x3412d8=L(_0x33c811[_0x443560(0x1eb)],'<pending>'),_0x3cc118=_0x33c811[_0x443560(0x21d)]?_0x443560(0x1ce)+_0x33c811[_0x443560(0x21d)]+':'+(_0x33c811['error_message']??''):'';return _0x443560(0x240)+_0x33c811[_0x443560(0x1d2)]+'\x20from='+L(_0x33c811['from_alias'],'<unknown>')+_0x443560(0x23d)+L(_0x33c811[_0x443560(0x236)],'<unknown>')+_0x443560(0x239)+_0x3412d8+_0x443560(0x1fd)+_0x7cb051+_0x443560(0x22b)+L(_0x33c811[_0x443560(0x1e3)],'<unknown>')+_0x443560(0x1e2)+_0x33c811[_0x443560(0x229)]+_0x443560(0x233)+_0x33c811['duration_ms']+_0x443560(0x1d8)+_0x33c811[_0x443560(0x207)]+_0x3cc118;}function U(_0x110ee1){const _0x573645=a0_0x27dbbc;return{'event':{'sending':_0x573645(0x213),'delivered':_0x573645(0x224),'failed':_0x573645(0x1de),'acked':_0x573645(0x231),'started':_0x573645(0x205),'replied':_0x573645(0x221),'expired':'task.expired'}[_0x110ee1[_0x573645(0x1d2)]],..._0x110ee1};}function j(_0x15d3d9){const _0xd26619=a0_0x27dbbc;let _0x124d6f=_0x15d3d9?.[_0xd26619(0x1eb)]||_0x15d3d9?.['message_id']||_0x15d3d9?.['id'];if(_0x124d6f)return String(_0x124d6f);let _0x4d76fb=_0x15d3d9?.[_0xd26619(0x1ef)]?.[0x0]?.[_0xd26619(0x22a)];if(typeof _0x4d76fb!==_0xd26619(0x1f7))return null;try{let _0x50aeb7=JSON[_0xd26619(0x23e)](_0x4d76fb);return _0x50aeb7?.[_0xd26619(0x1eb)]||_0x50aeb7?.[_0xd26619(0x1e6)]||_0x50aeb7?.['id']||null;}catch{return null;}}async function X(_0x443aea,_0x2440c9){const _0x50f10e=a0_0x27dbbc;let _0x2d045c=_0x2440c9[_0x50f10e(0x1e5)]??Date[_0x50f10e(0x1e5)],_0x3e55ea=_0x2d045c(),_0x4dc72d=(_0x3a2719,_0x4e9a60,_0x12b9e9,_0x579651)=>{const _0x3850ce=_0x50f10e;_0x2440c9[_0x3850ce(0x1c8)](O(U({'from_alias':_0x443aea['fromAlias'],'to_alias':_0x443aea['toAlias'],'task_id':_0x4e9a60,'parent_task_id':_0x443aea[_0x3850ce(0x1da)],'network_id':_0x443aea['networkId'],'transport':_0x443aea[_0x3850ce(0x229)],'status':_0x3a2719,'duration_ms':_0x2d045c()-_0x3e55ea,'lifecycle_tracking':_0x443aea[_0x3850ce(0x23c)],..._0x12b9e9!==void 0x0?{'error_code':_0x579651||_0x3850ce(0x1d5),'error_message':N(_0x12b9e9)}:{}})));};_0x4dc72d('sending',null);try{let _0x64c120=await _0x2440c9[_0x50f10e(0x20b)](),_0x42fb68=j(_0x64c120);if(_0x42fb68)_0x4dc72d('delivered',_0x42fb68);else{if(_0x64c120?.['ok']===!0x1||_0x64c120?.[_0x50f10e(0x210)])_0x4dc72d('failed',_0x42fb68,_0x64c120?.[_0x50f10e(0x210)]||_0x50f10e(0x1fa),_0x50f10e(0x23f));else _0x4dc72d(_0x50f10e(0x202),null,_0x50f10e(0x1e8),'missing_task_id');}return _0x64c120;}catch(_0x469b93){throw _0x4dc72d(_0x50f10e(0x202),null,_0x469b93,_0x50f10e(0x1d5)),_0x469b93;}}async function Y(_0x13196c,_0x9fdaeb){const _0x3555d7=a0_0x27dbbc;return X({'fromAlias':_0x13196c[_0x3555d7(0x1f2)],'toAlias':_0x13196c[_0x3555d7(0x1fc)],'parentTaskId':_0x13196c[_0x3555d7(0x1da)]||null,'networkId':_0x13196c[_0x3555d7(0x208)]||null,'transport':_0x3555d7(0x1ed),'lifecycleTracking':_0x3555d7(0x238)},_0x9fdaeb);}class $ extends a0_0x5a18ff{[a0_0x27dbbc(0x241)];[a0_0x27dbbc(0x1fc)];[a0_0x27dbbc(0x20a)];[a0_0x27dbbc(0x1e9)];['resumeId'];[a0_0x27dbbc(0x225)];[a0_0x27dbbc(0x1f0)];['heartbeatTimer'];[a0_0x27dbbc(0x22d)];[a0_0x27dbbc(0x22c)]=!0x1;constructor(_0xdf3fea){const _0x258b12=a0_0x27dbbc;super();if(this['url']=_0xdf3fea[_0x258b12(0x241)]['replace'](/\/$/,''),this[_0x258b12(0x1fc)]=_0xdf3fea['alias'],this[_0x258b12(0x20a)]=_0xdf3fea[_0x258b12(0x20a)],this[_0x258b12(0x1e9)]=_0xdf3fea[_0x258b12(0x1e9)]||_0x258b12(0x201),this[_0x258b12(0x1dc)]='sdk-'+_0xdf3fea[_0x258b12(0x1fc)]+'-'+Date[_0x258b12(0x1e5)]()[_0x258b12(0x1cd)](0x24),this[_0x258b12(0x225)]=_0xdf3fea[_0x258b12(0x225)]??0x2bf20,this[_0x258b12(0x1f0)]=_0xdf3fea[_0x258b12(0x1f0)]??0xbb8,_0xdf3fea['autoConnect']!==!0x1)this['connect']();}[a0_0x27dbbc(0x1c8)](_0x3aad28){const _0xbece3e=a0_0x27dbbc;console[_0xbece3e(0x1c8)]('['+new Date()[_0xbece3e(0x20d)]()[_0xbece3e(0x1f3)](0x0,0x8)+_0xbece3e(0x1f4)+this[_0xbece3e(0x1fc)]+']\x20'+_0x3aad28);}async[a0_0x27dbbc(0x1d7)](_0x3d41ae,_0x3873c9){const _0x51a7ec=a0_0x27dbbc;let _0x4b20d4={'Content-Type':_0x51a7ec(0x22e),'Accept':_0x51a7ec(0x227)};if(this[_0x51a7ec(0x20a)])_0x4b20d4[_0x51a7ec(0x1d9)]=_0x51a7ec(0x223)+this[_0x51a7ec(0x20a)];let _0x2dc14a=await(await fetch(this[_0x51a7ec(0x241)]+_0x51a7ec(0x1f8),{'method':_0x51a7ec(0x1d1),'headers':_0x4b20d4,'body':JSON[_0x51a7ec(0x21a)]({'jsonrpc':'2.0','id':Date['now'](),'method':_0x51a7ec(0x232),'params':{'name':_0x3d41ae,'arguments':_0x3873c9}})}))[_0x51a7ec(0x22a)](),_0x1b6169=_0x2dc14a['match'](/data: (.+)/),_0x4e89d6=_0x1b6169?JSON['parse'](_0x1b6169[0x1]):JSON[_0x51a7ec(0x23e)](_0x2dc14a),_0x120ae1=_0x4e89d6?.[_0x51a7ec(0x214)]?.[_0x51a7ec(0x1ef)]?.[0x0]?.['text'];return _0x120ae1?JSON['parse'](_0x120ae1):_0x4e89d6;}async[a0_0x27dbbc(0x1e0)](){const _0x475953=a0_0x27dbbc;if(this['running'])return;this[_0x475953(0x22c)]=!0x0,await this[_0x475953(0x1d2)](_0x475953(0x22f)),this[_0x475953(0x1c8)](_0x475953(0x235)),this['heartbeatTimer']=setInterval(()=>{const _0x5060a2=_0x475953;this['status'](_0x5060a2(0x22f))['catch'](_0x5bb3d1=>this[_0x5060a2(0x1c8)](_0x5060a2(0x1fe)+_0x5bb3d1[_0x5060a2(0x1cc)]));},this[_0x475953(0x225)]),this[_0x475953(0x1c9)]();}async[a0_0x27dbbc(0x23a)](){const _0x4df891=a0_0x27dbbc;if(this['running']=!0x1,this[_0x4df891(0x22d)]?.[_0x4df891(0x21b)](),this[_0x4df891(0x1db)])clearInterval(this[_0x4df891(0x1db)]);await this[_0x4df891(0x1d2)]('offline')[_0x4df891(0x1f1)](()=>{}),this[_0x4df891(0x1c8)](_0x4df891(0x21f));}async['send'](_0x326b31,_0x5d7bc1,_0x80e3c9=a0_0x27dbbc(0x200)){const _0x3d392b=a0_0x27dbbc;return Y({'alias':_0x326b31,'fromAlias':this[_0x3d392b(0x1fc)]},{'log':_0x2a9f87=>console['log'](_0x2a9f87),'send':()=>this['call'](_0x3d392b(0x20f),{'alias':_0x326b31,'task':_0x5d7bc1,'priority':_0x80e3c9,'from_session':this[_0x3d392b(0x1fc)]})});}async[a0_0x27dbbc(0x1cc)](_0x35ced8,_0x4eda40){const _0x963e31=a0_0x27dbbc;return this[_0x963e31(0x1d7)](_0x963e31(0x1f5),{'alias':_0x35ced8,'message':_0x4eda40,'from_session':this[_0x963e31(0x1fc)]});}async[a0_0x27dbbc(0x211)](_0x5697b4,_0x110d78,_0x553054=a0_0x27dbbc(0x219)){const _0x1f9d86=a0_0x27dbbc;return this['call'](_0x1f9d86(0x1dd),{'in_reply_to':_0x5697b4,'text':_0x110d78,'status':_0x553054});}async['status'](_0x219b71,_0x54134e){const _0xd2080b=a0_0x27dbbc;return this['call'](_0xd2080b(0x218),{'resume_id':this[_0xd2080b(0x1dc)],'alias':this['alias'],'status':_0x219b71,'server':a0_0x20ee56(),'hostname':a0_0x20ee56(),'agent':this[_0xd2080b(0x1e9)],'project_dir':process[_0xd2080b(0x1cb)](),..._0x54134e});}async['getAllStatus'](){const _0x2502a2=a0_0x27dbbc;return this[_0x2502a2(0x1d7)](_0x2502a2(0x1fb),{});}async[a0_0x27dbbc(0x204)](_0xeb3a8c,_0x5198da){const _0x2a067d=a0_0x27dbbc;return this['call'](_0x2a067d(0x204),{'message':_0xeb3a8c,'filter_server':_0x5198da?.[_0x2a067d(0x1ea)],'filter_status':_0x5198da?.['status']});}async[a0_0x27dbbc(0x1c9)](){const _0x1e9e44=a0_0x27dbbc;let _0x3fc613=encodeURIComponent(this[_0x1e9e44(0x1fc)]),_0x25caa2=this[_0x1e9e44(0x241)]+_0x1e9e44(0x230)+_0x3fc613,_0x292c93=this['reconnectDelay'];while(this['running']){try{this[_0x1e9e44(0x22d)]=new AbortController();let _0x4558c0={'Accept':'text/event-stream'};if(this['token'])_0x4558c0[_0x1e9e44(0x1d9)]=_0x1e9e44(0x223)+this['token'];let _0x5db9bc=await fetch(_0x25caa2,{'headers':_0x4558c0,'signal':this['sseAbort'][_0x1e9e44(0x216)]});if(!_0x5db9bc['ok']||!_0x5db9bc[_0x1e9e44(0x1f6)]){this[_0x1e9e44(0x1c8)]('SSE\x20failed:\x20'+_0x5db9bc[_0x1e9e44(0x1d2)]),await this[_0x1e9e44(0x1e1)](_0x292c93),_0x292c93=Math[_0x1e9e44(0x23b)](_0x292c93*1.5,0xea60);continue;}_0x292c93=this[_0x1e9e44(0x1f0)];let _0x476e6d=_0x5db9bc['body'][_0x1e9e44(0x206)](),_0x103412=new TextDecoder(),_0x439e1b='';while(this[_0x1e9e44(0x22c)]){let {done:_0x1177a0,value:_0x5177d6}=await _0x476e6d['read']();if(_0x1177a0)break;_0x439e1b+=_0x103412[_0x1e9e44(0x21c)](_0x5177d6,{'stream':!0x0});let _0x37536c=_0x439e1b['split']('\x0a');_0x439e1b=_0x37536c[_0x1e9e44(0x222)]()||'';for(let _0x30e6e2 of _0x37536c){if(!_0x30e6e2[_0x1e9e44(0x1df)](_0x1e9e44(0x1d6)))continue;try{let _0x3f42ba=JSON[_0x1e9e44(0x23e)](_0x30e6e2[_0x1e9e44(0x1f3)](0x6));if(_0x3f42ba[_0x1e9e44(0x21e)]===_0x1e9e44(0x203)){this[_0x1e9e44(0x1c8)](_0x1e9e44(0x20c)),this[_0x1e9e44(0x234)]('connected');continue;}if(_0x3f42ba['type']==='new_task'||_0x3f42ba[_0x1e9e44(0x21e)]===_0x1e9e44(0x1d4)||_0x3f42ba['type']===_0x1e9e44(0x204))await this[_0x1e9e44(0x1ca)]();}catch{}}}}catch(_0x148d32){if(_0x148d32[_0x1e9e44(0x20e)]===_0x1e9e44(0x1ff))break;this[_0x1e9e44(0x234)](_0x1e9e44(0x210),_0x148d32),this[_0x1e9e44(0x1c8)](_0x1e9e44(0x1ee)+_0x148d32['message']);}if(this[_0x1e9e44(0x22c)])this[_0x1e9e44(0x234)]('disconnected'),this['log'](_0x1e9e44(0x1e7)+_0x292c93/0x3e8+_0x1e9e44(0x226)),await this['sleep'](_0x292c93),_0x292c93=Math[_0x1e9e44(0x23b)](_0x292c93*1.5,0xea60);}}async[a0_0x27dbbc(0x1ca)](){const _0x44eb2a=a0_0x27dbbc;try{let _0x26b0d9=(await this[_0x44eb2a(0x1d7)]('get_inbox',{'alias':this[_0x44eb2a(0x1fc)],'limit':0xa}))?.[_0x44eb2a(0x242)]||[];for(let _0x57e93a of _0x26b0d9)await this[_0x44eb2a(0x1d7)]('ack_inbox',{'alias':this[_0x44eb2a(0x1fc)],'message_id':_0x57e93a['id']}),this[_0x44eb2a(0x1c8)]('←\x20'+_0x57e93a[_0x44eb2a(0x220)]+':\x20'+_0x57e93a['content'][_0x44eb2a(0x1f3)](0x0,0x3c)),this['emit']('task',_0x57e93a),this[_0x44eb2a(0x234)]('message',_0x57e93a);}catch(_0x2fc368){this[_0x44eb2a(0x1c8)](_0x44eb2a(0x1d3)+_0x2fc368[_0x44eb2a(0x1cc)]);}}[a0_0x27dbbc(0x1e1)](_0x13e96e){return new Promise(_0x55e8cf=>setTimeout(_0x55e8cf,_0x13e96e));}}var F=$;export{F as default,$ as CommHub};
1
+ const a0_0x26d955=a0_0xd089;(function(_0x3ce976,_0x161c71){const _0xfb0cf5=a0_0xd089,_0x18329f=_0x3ce976();while(!![]){try{const _0x339cb0=parseInt(_0xfb0cf5(0x209))/0x1+parseInt(_0xfb0cf5(0x1c8))/0x2+-parseInt(_0xfb0cf5(0x1cf))/0x3*(-parseInt(_0xfb0cf5(0x1ef))/0x4)+parseInt(_0xfb0cf5(0x21f))/0x5+parseInt(_0xfb0cf5(0x1c9))/0x6+-parseInt(_0xfb0cf5(0x1d5))/0x7*(-parseInt(_0xfb0cf5(0x212))/0x8)+-parseInt(_0xfb0cf5(0x1dd))/0x9;if(_0x339cb0===_0x161c71)break;else _0x18329f['push'](_0x18329f['shift']());}catch(_0x481e4e){_0x18329f['push'](_0x18329f['shift']());}}}(a0_0x1da7,0xe2e46));import{EventEmitter as a0_0xaf28a1}from'events';import{hostname as a0_0x5b2d48}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x5abe5f,_0x32f50d)=>(_0x5abe5f??_0x32f50d)[a0_0x26d955(0x206)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x1b734d){const _0x5d5374=a0_0x26d955;return(_0x1b734d instanceof Error?_0x1b734d[_0x5d5374(0x1dc)]:String(_0x1b734d??_0x5d5374(0x232)))['replace'](K,_0x5d5374(0x1e0))[_0x5d5374(0x206)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x5d5374(0x231)](0x0,0xf0);}function O(_0x4ffa3a,_0x1d0ab3=process.env.ANET_TASK_TRACE_FORMAT===a0_0x26d955(0x1bb)){const _0x2228c8=a0_0x26d955;if(_0x1d0ab3)return JSON[_0x2228c8(0x1d9)](_0x4ffa3a);let _0x7f94c4=L(_0x4ffa3a['parent_task_id'],_0x2228c8(0x1ec)),_0x56ff40=L(_0x4ffa3a['task_id'],_0x2228c8(0x1f9)),_0x31c003=_0x4ffa3a['error_code']?_0x2228c8(0x207)+_0x4ffa3a[_0x2228c8(0x227)]+':'+(_0x4ffa3a[_0x2228c8(0x217)]??''):'';return'[commhub:task]\x20'+_0x4ffa3a[_0x2228c8(0x20d)]+_0x2228c8(0x1d4)+L(_0x4ffa3a[_0x2228c8(0x1d8)],_0x2228c8(0x1f0))+_0x2228c8(0x205)+L(_0x4ffa3a['to_alias'],'<unknown>')+'\x20task_id='+_0x56ff40+_0x2228c8(0x1fe)+_0x7f94c4+_0x2228c8(0x20b)+L(_0x4ffa3a[_0x2228c8(0x1f2)],_0x2228c8(0x1f0))+_0x2228c8(0x225)+_0x4ffa3a[_0x2228c8(0x229)]+_0x2228c8(0x1be)+_0x4ffa3a[_0x2228c8(0x1ba)]+_0x2228c8(0x1f7)+_0x4ffa3a['lifecycle_tracking']+_0x31c003;}function U(_0x4ff830){const _0x478569=a0_0x26d955;return{'event':{'sending':'task.send.start','delivered':'task.send.delivered','failed':_0x478569(0x1c3),'acked':_0x478569(0x1f6),'started':_0x478569(0x203),'replied':_0x478569(0x22f),'expired':'task.expired'}[_0x4ff830[_0x478569(0x20d)]],..._0x4ff830};}function a0_0x1da7(){const _0x144574=['reply','not_tracked','/mcp','send_reply','send_message','resumeId','cwd','1901970reZEii','missing_task_id','parse','heartbeat\x20failed:\x20','application/json','now','\x20transport=','Authorization','error_code','completed','transport','data:\x20','server','getAllStatus','body','inbox\x20error:\x20','task.replied','lifecycleTracking','slice','unknown\x20error','heartbeatTimer','toAlias','connectSSE','sleep','duration_ms','json','mcp_http','task','\x20duration_ms=','CommHub\x20response\x20omitted\x20task_id','CommHub\x20rejected\x20task','running','emit','task.send.failed','SSE\x20reconnecting\x20in\x20','log','read','2.0','1972614wijUJD','2124552bRChhd','text/event-stream','text','split','sseAbort','networkId','15IcTSeX','ack_inbox','send','sdk','SSE\x20connected','\x20from=','7Qcpchv','type','catch','from_alias','stringify','send_rejected','call','message','17866188BXNJWA','connect','url','[REDACTED]','startsWith','task_id','SSE\x20error:\x20','sdk-','name','broadcast','/events/','abort','delivered','failed','idle','<missing>','heartbeatInterval','registered','649828XEEgNp','<unknown>','fromAlias','network_id','disconnect','token','message_id','task.ack','\x20lifecycle=','application/json,\x20text/event-stream','<pending>','send_failed','report_status','reconnectDelay','POST','\x20parent_task_id=','offline','agent','s...','disconnected','task.started','SSE\x20failed:\x20','\x20to=','replace','\x20error=','error','306607oRZdiS','connected','\x20network_id=','processInbox','status','Bearer\x20','getReader','autoConnect','toString','598376WMgTab','match','content','parentTaskId','alias','error_message'];a0_0x1da7=function(){return _0x144574;};return a0_0x1da7();}function j(_0x14ab5e){const _0x275fbc=a0_0x26d955;let _0x87a6a6=_0x14ab5e?.[_0x275fbc(0x1e2)]||_0x14ab5e?.[_0x275fbc(0x1f5)]||_0x14ab5e?.['id'];if(_0x87a6a6)return String(_0x87a6a6);let _0x3e02af=_0x14ab5e?.[_0x275fbc(0x214)]?.[0x0]?.[_0x275fbc(0x1cb)];if(typeof _0x3e02af!=='string')return null;try{let _0x40a530=JSON[_0x275fbc(0x221)](_0x3e02af);return _0x40a530?.[_0x275fbc(0x1e2)]||_0x40a530?.[_0x275fbc(0x1f5)]||_0x40a530?.['id']||null;}catch{return null;}}async function X(_0x46f386,_0x5a374d){const _0x3f6028=a0_0x26d955;let _0x41f99f=_0x5a374d[_0x3f6028(0x224)]??Date[_0x3f6028(0x224)],_0x4871df=_0x41f99f(),_0x34493f=(_0x4bd80e,_0x108e12,_0x1d5f2c,_0x5965e6)=>{const _0xa6aadf=_0x3f6028;_0x5a374d[_0xa6aadf(0x1c5)](O(U({'from_alias':_0x46f386[_0xa6aadf(0x1f1)],'to_alias':_0x46f386[_0xa6aadf(0x234)],'task_id':_0x108e12,'parent_task_id':_0x46f386[_0xa6aadf(0x215)],'network_id':_0x46f386[_0xa6aadf(0x1ce)],'transport':_0x46f386['transport'],'status':_0x4bd80e,'duration_ms':_0x41f99f()-_0x4871df,'lifecycle_tracking':_0x46f386[_0xa6aadf(0x230)],..._0x1d5f2c!==void 0x0?{'error_code':_0x5965e6||'send_failed','error_message':N(_0x1d5f2c)}:{}})));};_0x34493f('sending',null);try{let _0x38db74=await _0x5a374d[_0x3f6028(0x1d1)](),_0x2393c8=j(_0x38db74);if(_0x2393c8)_0x34493f(_0x3f6028(0x1e9),_0x2393c8);else{if(_0x38db74?.['ok']===!0x1||_0x38db74?.['error'])_0x34493f('failed',_0x2393c8,_0x38db74?.[_0x3f6028(0x208)]||_0x3f6028(0x1c0),_0x3f6028(0x1da));else _0x34493f(_0x3f6028(0x1ea),null,_0x3f6028(0x1bf),_0x3f6028(0x220));}return _0x38db74;}catch(_0x2b7be4){throw _0x34493f('failed',null,_0x2b7be4,_0x3f6028(0x1fa)),_0x2b7be4;}}async function Y(_0x420af0,_0x2a8cb9){const _0x1e73ff=a0_0x26d955;return X({'fromAlias':_0x420af0[_0x1e73ff(0x1f1)],'toAlias':_0x420af0['alias'],'parentTaskId':_0x420af0[_0x1e73ff(0x215)]||null,'networkId':_0x420af0['networkId']||null,'transport':_0x1e73ff(0x1bc),'lifecycleTracking':_0x1e73ff(0x219)},_0x2a8cb9);}function a0_0xd089(_0x55d868,_0x5959d3){_0x55d868=_0x55d868-0x1b8;const _0x1da7e8=a0_0x1da7();let _0xd0893a=_0x1da7e8[_0x55d868];return _0xd0893a;}class $ extends a0_0xaf28a1{['url'];['alias'];[a0_0x26d955(0x1f4)];['agent'];[a0_0x26d955(0x21d)];['heartbeatInterval'];[a0_0x26d955(0x1fc)];[a0_0x26d955(0x233)];['sseAbort'];[a0_0x26d955(0x1c1)]=!0x1;constructor(_0x5b05c8){const _0x3dae9c=a0_0x26d955;super();if(this[_0x3dae9c(0x1df)]=_0x5b05c8[_0x3dae9c(0x1df)]['replace'](/\/$/,''),this[_0x3dae9c(0x216)]=_0x5b05c8[_0x3dae9c(0x216)],this[_0x3dae9c(0x1f4)]=_0x5b05c8[_0x3dae9c(0x1f4)],this['agent']=_0x5b05c8[_0x3dae9c(0x200)]||_0x3dae9c(0x1d2),this[_0x3dae9c(0x21d)]=_0x3dae9c(0x1e4)+_0x5b05c8[_0x3dae9c(0x216)]+'-'+Date[_0x3dae9c(0x224)]()[_0x3dae9c(0x211)](0x24),this[_0x3dae9c(0x1ed)]=_0x5b05c8[_0x3dae9c(0x1ed)]??0x2bf20,this['reconnectDelay']=_0x5b05c8[_0x3dae9c(0x1fc)]??0xbb8,_0x5b05c8[_0x3dae9c(0x210)]!==!0x1)this[_0x3dae9c(0x1de)]();}[a0_0x26d955(0x1c5)](_0x3e7a5d){const _0x49c65a=a0_0x26d955;console['log']('['+new Date()['toTimeString']()['slice'](0x0,0x8)+']\x20[commhub:'+this[_0x49c65a(0x216)]+']\x20'+_0x3e7a5d);}async[a0_0x26d955(0x1db)](_0x59e31c,_0x312f00){const _0x4367d0=a0_0x26d955;let _0x4552d3={'Content-Type':_0x4367d0(0x223),'Accept':_0x4367d0(0x1f8)};if(this[_0x4367d0(0x1f4)])_0x4552d3[_0x4367d0(0x226)]=_0x4367d0(0x20e)+this[_0x4367d0(0x1f4)];let _0x3b0ee7=await(await fetch(this[_0x4367d0(0x1df)]+_0x4367d0(0x21a),{'method':_0x4367d0(0x1fd),'headers':_0x4552d3,'body':JSON[_0x4367d0(0x1d9)]({'jsonrpc':_0x4367d0(0x1c7),'id':Date['now'](),'method':'tools/call','params':{'name':_0x59e31c,'arguments':_0x312f00}})}))[_0x4367d0(0x1cb)](),_0x255efd=_0x3b0ee7[_0x4367d0(0x213)](/data: (.+)/),_0xa268cd=_0x255efd?JSON[_0x4367d0(0x221)](_0x255efd[0x1]):JSON[_0x4367d0(0x221)](_0x3b0ee7),_0x2cbf01=_0xa268cd?.['result']?.[_0x4367d0(0x214)]?.[0x0]?.[_0x4367d0(0x1cb)];return _0x2cbf01?JSON[_0x4367d0(0x221)](_0x2cbf01):_0xa268cd;}async[a0_0x26d955(0x1de)](){const _0x805b65=a0_0x26d955;if(this[_0x805b65(0x1c1)])return;this[_0x805b65(0x1c1)]=!0x0,await this[_0x805b65(0x20d)](_0x805b65(0x1eb)),this[_0x805b65(0x1c5)](_0x805b65(0x1ee)),this[_0x805b65(0x233)]=setInterval(()=>{const _0x5a01ef=_0x805b65;this[_0x5a01ef(0x20d)](_0x5a01ef(0x1eb))[_0x5a01ef(0x1d7)](_0x35927b=>this[_0x5a01ef(0x1c5)](_0x5a01ef(0x222)+_0x35927b[_0x5a01ef(0x1dc)]));},this[_0x805b65(0x1ed)]),this['connectSSE']();}async[a0_0x26d955(0x1f3)](){const _0x3e28be=a0_0x26d955;if(this['running']=!0x1,this[_0x3e28be(0x1cd)]?.[_0x3e28be(0x1e8)](),this[_0x3e28be(0x233)])clearInterval(this[_0x3e28be(0x233)]);await this[_0x3e28be(0x20d)](_0x3e28be(0x1ff))[_0x3e28be(0x1d7)](()=>{}),this[_0x3e28be(0x1c5)](_0x3e28be(0x202));}async[a0_0x26d955(0x1d1)](_0x5a1bfc,_0x14ca77,_0x48436d='normal'){const _0x23ebf5=a0_0x26d955;return Y({'alias':_0x5a1bfc,'fromAlias':this['alias']},{'log':_0x5c1bab=>console[_0x23ebf5(0x1c5)](_0x5c1bab),'send':()=>this['call']('send_task',{'alias':_0x5a1bfc,'task':_0x14ca77,'priority':_0x48436d,'from_session':this[_0x23ebf5(0x216)]})});}async[a0_0x26d955(0x1dc)](_0x354cb9,_0xd251d6){const _0x16fd44=a0_0x26d955;return this[_0x16fd44(0x1db)](_0x16fd44(0x21c),{'alias':_0x354cb9,'message':_0xd251d6,'from_session':this[_0x16fd44(0x216)]});}async[a0_0x26d955(0x218)](_0x1b7d29,_0x1d6c1c,_0x3c32da=a0_0x26d955(0x228)){const _0x530413=a0_0x26d955;return this[_0x530413(0x1db)](_0x530413(0x21b),{'in_reply_to':_0x1b7d29,'text':_0x1d6c1c,'status':_0x3c32da});}async[a0_0x26d955(0x20d)](_0x349a21,_0x213ebf){const _0x4bbf23=a0_0x26d955;return this[_0x4bbf23(0x1db)](_0x4bbf23(0x1fb),{'resume_id':this[_0x4bbf23(0x21d)],'alias':this[_0x4bbf23(0x216)],'status':_0x349a21,'server':a0_0x5b2d48(),'hostname':a0_0x5b2d48(),'agent':this[_0x4bbf23(0x200)],'project_dir':process[_0x4bbf23(0x21e)](),..._0x213ebf});}async[a0_0x26d955(0x22c)](){const _0x4c0e88=a0_0x26d955;return this[_0x4c0e88(0x1db)]('get_all_status',{});}async[a0_0x26d955(0x1e6)](_0x24547d,_0x283b82){const _0x22e3ce=a0_0x26d955;return this[_0x22e3ce(0x1db)](_0x22e3ce(0x1e6),{'message':_0x24547d,'filter_server':_0x283b82?.[_0x22e3ce(0x22b)],'filter_status':_0x283b82?.[_0x22e3ce(0x20d)]});}async[a0_0x26d955(0x1b8)](){const _0x5eab37=a0_0x26d955;let _0xf4fdb7=encodeURIComponent(this[_0x5eab37(0x216)]),_0x110956=this[_0x5eab37(0x1df)]+_0x5eab37(0x1e7)+_0xf4fdb7,_0x10849e=this[_0x5eab37(0x1fc)];while(this['running']){try{this[_0x5eab37(0x1cd)]=new AbortController();let _0x255520={'Accept':_0x5eab37(0x1ca)};if(this[_0x5eab37(0x1f4)])_0x255520[_0x5eab37(0x226)]=_0x5eab37(0x20e)+this[_0x5eab37(0x1f4)];let _0x7bcac5=await fetch(_0x110956,{'headers':_0x255520,'signal':this[_0x5eab37(0x1cd)]['signal']});if(!_0x7bcac5['ok']||!_0x7bcac5[_0x5eab37(0x22d)]){this[_0x5eab37(0x1c5)](_0x5eab37(0x204)+_0x7bcac5['status']),await this[_0x5eab37(0x1b9)](_0x10849e),_0x10849e=Math['min'](_0x10849e*1.5,0xea60);continue;}_0x10849e=this[_0x5eab37(0x1fc)];let _0x5d386c=_0x7bcac5[_0x5eab37(0x22d)][_0x5eab37(0x20f)](),_0x574b69=new TextDecoder(),_0x480831='';while(this[_0x5eab37(0x1c1)]){let {done:_0x38013d,value:_0x341fb2}=await _0x5d386c[_0x5eab37(0x1c6)]();if(_0x38013d)break;_0x480831+=_0x574b69['decode'](_0x341fb2,{'stream':!0x0});let _0x48e113=_0x480831[_0x5eab37(0x1cc)]('\x0a');_0x480831=_0x48e113['pop']()||'';for(let _0x4c5d2e of _0x48e113){if(!_0x4c5d2e[_0x5eab37(0x1e1)](_0x5eab37(0x22a)))continue;try{let _0x374bb1=JSON[_0x5eab37(0x221)](_0x4c5d2e[_0x5eab37(0x231)](0x6));if(_0x374bb1['type']==='connected'){this[_0x5eab37(0x1c5)](_0x5eab37(0x1d3)),this[_0x5eab37(0x1c2)](_0x5eab37(0x20a));continue;}if(_0x374bb1[_0x5eab37(0x1d6)]==='new_task'||_0x374bb1[_0x5eab37(0x1d6)]==='new_message'||_0x374bb1['type']==='broadcast')await this[_0x5eab37(0x20c)]();}catch{}}}}catch(_0x5e1666){if(_0x5e1666[_0x5eab37(0x1e5)]==='AbortError')break;this[_0x5eab37(0x1c2)](_0x5eab37(0x208),_0x5e1666),this[_0x5eab37(0x1c5)](_0x5eab37(0x1e3)+_0x5e1666[_0x5eab37(0x1dc)]);}if(this[_0x5eab37(0x1c1)])this[_0x5eab37(0x1c2)](_0x5eab37(0x202)),this[_0x5eab37(0x1c5)](_0x5eab37(0x1c4)+_0x10849e/0x3e8+_0x5eab37(0x201)),await this[_0x5eab37(0x1b9)](_0x10849e),_0x10849e=Math['min'](_0x10849e*1.5,0xea60);}}async[a0_0x26d955(0x20c)](){const _0x256de6=a0_0x26d955;try{let _0x39eb3b=(await this[_0x256de6(0x1db)]('get_inbox',{'alias':this['alias'],'limit':0xa}))?.['messages']||[];for(let _0x5f2ecd of _0x39eb3b)await this[_0x256de6(0x1db)](_0x256de6(0x1d0),{'alias':this[_0x256de6(0x216)],'message_id':_0x5f2ecd['id']}),this[_0x256de6(0x1c5)]('←\x20'+_0x5f2ecd['from_session']+':\x20'+_0x5f2ecd[_0x256de6(0x214)][_0x256de6(0x231)](0x0,0x3c)),this[_0x256de6(0x1c2)](_0x256de6(0x1bd),_0x5f2ecd),this[_0x256de6(0x1c2)](_0x256de6(0x1dc),_0x5f2ecd);}catch(_0x5884bd){this[_0x256de6(0x1c5)](_0x256de6(0x22e)+_0x5884bd[_0x256de6(0x1dc)]);}}[a0_0x26d955(0x1b9)](_0x3a46dd){return new Promise(_0x4aa742=>setTimeout(_0x4aa742,_0x3a46dd));}}var F=$;export{F as default,$ as CommHub};
@@ -0,0 +1,46 @@
1
+ /** A prefix is hex digits and dashes. Shorter than this matches too much to be a deliberate choice. */
2
+ export declare const MIN_THREAD_PREFIX = 4;
3
+ export interface ExternalThread {
4
+ readonly threadId: string;
5
+ readonly path: string;
6
+ readonly bytes: number;
7
+ readonly inode: number | bigint;
8
+ readonly mtimeMs: number;
9
+ /** session_meta timestamp (falls back to the file's mtime when missing). */
10
+ readonly startedAt: string;
11
+ readonly cwd: string | null;
12
+ readonly firstPrompt: string | null;
13
+ }
14
+ /** The first thing the human typed: event_msg user_message, else a user message item that is not injected context. */
15
+ export declare function firstPromptOf(lines: readonly string[]): string | null;
16
+ export declare function threadFactsOf(path: string, threadId: string, mtimeMs: number, headBytes?: number): {
17
+ startedAt: string;
18
+ cwd: string | null;
19
+ firstPrompt: string | null;
20
+ };
21
+ /** Every rollout under `<codexHome>/sessions` (read-only), newest first. */
22
+ export declare function listExternalThreads(codexHome: string): ExternalThread[];
23
+ export type ThreadResolution = {
24
+ kind: "ok";
25
+ thread: ExternalThread;
26
+ } | {
27
+ kind: "invalid";
28
+ reason: string;
29
+ } | {
30
+ kind: "none";
31
+ }
32
+ /** The prefix names more than one thread. */
33
+ | {
34
+ kind: "ambiguous";
35
+ matches: readonly ExternalThread[];
36
+ }
37
+ /** One thread id, but more than one rollout file carries it — which one is the conversation is a guess. */
38
+ | {
39
+ kind: "duplicate";
40
+ matches: readonly ExternalThread[];
41
+ };
42
+ export declare function resolveExternalThread(threads: readonly ExternalThread[], query: string): ThreadResolution;
43
+ /** Shortest prefix (≥ minLen) of each id that no other id in the list shares. */
44
+ export declare function shortIds(ids: readonly string[], minLen?: number): Map<string, string>;
45
+ /** Numbered table for the picker / the non-TTY listing. Local time is not used: the stamp is the UTC one codex wrote. */
46
+ export declare function formatThreadList(threads: readonly ExternalThread[], limit?: number): string[];
@@ -0,0 +1,44 @@
1
+ /**
2
+ * #535 (audit P1-2) — keep the codex co-presence bridge's last words.
3
+ *
4
+ * The bridge (piece ②) runs in its own tmux session. When it failed, that
5
+ * session exited, and the launcher still printed
6
+ * Debug: tmux attach -t '=<alias>-桥'
7
+ * which pointed at nothing. The audit only found the real cause
8
+ * (`exact paired package identity validation failed: … unsafe ownership or
9
+ * mode`) by re-running the bridge command by hand.
10
+ *
11
+ * Its stdout/stderr now also go to `<node dir>/codex-bridge.log`, and a failed
12
+ * start prints the tail of that file plus the path. Same idea as the OpenCode
13
+ * twin (copresence-bridge.log), with two differences:
14
+ * - the file is NOT under logs/: `anet logs` shows the reverse-sorted first
15
+ * `*.log` there, and a name like this sorts above agent-node's dated logs,
16
+ * so it would hide them;
17
+ * - the copy is capped (the bridge runs for days and agent-node already
18
+ * writes its own dated log). Past the cap the remainder is drained, never
19
+ * refused: a reader that stopped reading would SIGPIPE `tee` and with it
20
+ * the bridge's stdout.
21
+ */
22
+ export declare const CODEX_BRIDGE_LOG_NAME = "codex-bridge.log";
23
+ export declare const CODEX_BRIDGE_LOG_CAP_BYTES: number;
24
+ export declare const CODEX_BRIDGE_TAIL_LINES = 20;
25
+ /**
26
+ * A bash statement that sends the rest of the script's stdout+stderr to the
27
+ * pane AND to the log (whole lines, up to about CAP bytes, flushed line by line). `quotedLogPath` must already be
28
+ * shell-quoted. The parent `exec`s anet next, so anet's pid is still the pane's
29
+ * process; `tee`/`awk` inherit the session's ANET_NODE_MARKER and are
30
+ * reaped with it on stop.
31
+ */
32
+ export declare function codexBridgeTeeCommand(quotedLogPath: string, capBytes?: number): string;
33
+ /** Last `n` non-empty lines, with trailing whitespace trimmed. */
34
+ export declare function tailLines(text: string, n?: number): string[];
35
+ export interface BridgeFailureInput {
36
+ readonly bridgeAlive: boolean;
37
+ readonly attachCommand: string;
38
+ readonly logPath: string;
39
+ readonly logText: string;
40
+ readonly waitedSeconds: number;
41
+ readonly cleanupCommand: string;
42
+ }
43
+ /** What the launcher prints when the bridge did not report ready. */
44
+ export declare function bridgeLaunchFailureLines(i: BridgeFailureInput): string[];
@@ -0,0 +1,16 @@
1
+ export type CodexHomeLoginState = "logged-in" | "needs-login" | "unknown";
2
+ export interface CodexHomeLoginVerdict {
3
+ readonly state: CodexHomeLoginState;
4
+ /** One phrase for the operator: why this state. No secrets. */
5
+ readonly reason: string;
6
+ }
7
+ /** The node's verdict. auth.json is judged by the #529 helper; see the header for the two fail-open cases. */
8
+ export declare function codexHomeLoginState(codexHome: string, env?: Record<string, string | undefined>): CodexHomeLoginVerdict;
9
+ /** Exit code for `needs-login`: distinct from 1 (failed) so scripts can tell "do something" from "broken". */
10
+ export declare const NEEDS_LOGIN_EXIT_CODE = 3;
11
+ /** What the launcher prints instead of "✅ 就绪": a state line, then the #529 next step. Nothing executed. */
12
+ export declare function describeCodexNeedsLogin(i: {
13
+ alias: string;
14
+ codexHome: string;
15
+ reason: string;
16
+ }): string[];
@@ -1,4 +1,4 @@
1
- export type CheckStatus = "pass" | "fail" | "unknown";
1
+ export type CheckStatus = "pass" | "fail" | "unknown" | "n/a";
2
2
  export interface ReceiptCheck {
3
3
  readonly key: string;
4
4
  readonly status: CheckStatus;
@@ -7,7 +7,7 @@ export interface ReceiptCheck {
7
7
  /** 可复核的证据(路径、inode、字节数、短指纹……);不得含凭据。 */
8
8
  readonly evidence?: Readonly<Record<string, unknown>>;
9
9
  }
10
- export type LifecycleVerb = "preflight" | "verify" | "start" | "restart" | "resume" | "fork" | "account-install" | "rollback";
10
+ export type LifecycleVerb = "preflight" | "verify" | "start" | "restart" | "resume" | "fork" | "adopt" | "account-install" | "rollback";
11
11
  export interface LifecycleReceipt {
12
12
  readonly format: "anet-codex-lifecycle-receipt/1";
13
13
  readonly id: string;
@@ -25,7 +25,16 @@ export interface LifecycleReceipt {
25
25
  export declare const REQUIRED_CHECKS: Readonly<Record<LifecycleVerb, readonly string[]>>;
26
26
  export declare function shortFingerprint(value: string | undefined | null, length?: number): string | null;
27
27
  export declare function redactReceipt<T>(value: T, key?: string): T;
28
+ /**
29
+ * #535 — required checks that may be "n/a" instead of "pass". identity_attested needs a second
30
+ * local node to send the nonce; a user with one node has no peer, and a verdict that can never be
31
+ * PASS for them is a verdict nobody can act on (audit: verify/canary/restart rc=2 on a healthy node).
32
+ * "n/a" stays visible in the receipt and in the summary line; it never turns into "pass".
33
+ */
34
+ export declare const NOT_APPLICABLE_OK: ReadonlySet<string>;
28
35
  export declare const INFORMATIONAL_PREFIXES: readonly string[];
36
+ /** before:home_isolated → home_isolated; rollout_before (restart's renamed snapshot) → rollout_intact. */
37
+ export declare function unprefixedCheckKey(key: string): string;
29
38
  export declare function receiptVerdict(verb: LifecycleVerb, checks: readonly ReceiptCheck[]): {
30
39
  verdict: "PASS" | "FAIL";
31
40
  blocking: string[];
@@ -65,7 +65,7 @@ export interface RestartActions {
65
65
  ok: boolean;
66
66
  detail: string;
67
67
  }>;
68
- /** 跨节点 nonce 探针;未配置时返回 undefined(check 记 unknown)。 */
68
+ /** 跨节点 nonce 探针;未配置时为 undefined(check 记 n/a,#535:单节点不阻塞)。 */
69
69
  nonceProbe?: () => Promise<{
70
70
  ok: boolean;
71
71
  detail: string;
@@ -79,6 +79,8 @@ export interface RestartOutcome {
79
79
  readonly stoppedAt: string;
80
80
  readonly rolledBack: boolean;
81
81
  }
82
+ /** #535 — shared with the CLI's verify/canary so every verb says the same thing. */
83
+ export declare const SINGLE_NODE_UNATTESTED_DETAIL = "not applicable: no --probe-from <peer> given (single node) \u2014 cross-node nonce attestation skipped; pass --probe-from <alias> to attest";
82
84
  /** before 阶段的门:required 里不许有 fail;unknown 允许(要重启的节点常常就是缺了一截进程)。 */
83
85
  export declare function beforeGateBlocks(checks: readonly ReceiptCheck[]): string[];
84
86
  /** 三个角色按依赖反向停;返回 stop_order check(顺序本身就是证据)。 */
@@ -34,7 +34,7 @@ export interface CollectEnv {
34
34
  export declare function collectCodexRows(nodes: CodexMenuNode[], env: CollectEnv): CodexNodeRow[];
35
35
  export declare function renderCodexTable(rows: CodexNodeRow[], cwd: string): string;
36
36
  export declare const CODEX_CHEAT_SHEET: string;
37
- export type MenuAction = "start" | "stop" | "restart" | "verify" | "login" | "continue" | "model" | "copy" | "delete";
37
+ export type MenuAction = "start" | "stop" | "restart" | "verify" | "login" | "continue" | "pick" | "model" | "copy" | "delete";
38
38
  export declare const MENU_ACTIONS: {
39
39
  key: MenuAction;
40
40
  label: string;
@@ -56,6 +56,9 @@ export interface ActionInput {
56
56
  newName?: string;
57
57
  workdir?: string;
58
58
  }
59
+ /** #528 — not about an existing node: turn a codex conversation started outside anet into a new one. */
60
+ export declare const ADOPT_KEY = "a";
61
+ export declare function planAdopt(newName: string): PlannedCommand;
59
62
  export declare function planAction(row: CodexNodeRow, action: MenuAction, input?: ActionInput): PlannedCommand;
60
63
  export interface MenuIO {
61
64
  write(s: string): void;
@@ -0,0 +1,89 @@
1
+ import { type ExternalThread } from "./codex-adopt";
2
+ import { type CollectEnv, type CodexMenuNode } from "./codex-menu";
3
+ export type CodexResumeKind = "co-presence" | "codex-sdk";
4
+ export interface CodexResumeFacts {
5
+ readonly alias: string;
6
+ readonly kind: CodexResumeKind;
7
+ /** "running" | "stopped" | "partial 1/3" (codex-menu's row.state). */
8
+ readonly state: string;
9
+ readonly running: boolean;
10
+ /** The CODEX_HOME the node's codex runs with (its own, or the host ~/.codex for a codex-sdk node). */
11
+ readonly codexHome: string;
12
+ readonly homeExists: boolean;
13
+ /** true = codex's default ~/.codex (no CODEX_HOME needed to log it in). */
14
+ readonly homeIsHost: boolean;
15
+ readonly loggedIn: boolean;
16
+ /** codexThreadId (co-presence) / session (codex-sdk) from the node config. */
17
+ readonly recordedThread: string | null;
18
+ /** Every rollout under `<codexHome>/sessions`, newest first. */
19
+ readonly threads: readonly ExternalThread[];
20
+ }
21
+ export interface CodexResumeRequest {
22
+ /** --thread <id|unique prefix> (also --session <id>, the old spelling). */
23
+ readonly thread?: string | null;
24
+ readonly pick?: boolean;
25
+ /** stdin and stdout are both a terminal. */
26
+ readonly tty: boolean;
27
+ }
28
+ export type CodexResumeDecision =
29
+ /** Nothing was done. `lines[0]` is the reason with the fix; exit with `code`. */
30
+ {
31
+ readonly kind: "refuse";
32
+ readonly code: number;
33
+ readonly lines: readonly string[];
34
+ }
35
+ /** --pick without a terminal: the list plus a copy-paste command. Nothing was done. */
36
+ | {
37
+ readonly kind: "list";
38
+ readonly code: number;
39
+ readonly lines: readonly string[];
40
+ }
41
+ /** --pick in a terminal: show `lines`, ask for a number in 1..`choices.length`. */
42
+ | {
43
+ readonly kind: "ask";
44
+ readonly lines: readonly string[];
45
+ readonly choices: readonly string[];
46
+ }
47
+ /** Already running on exactly that thread — attach instead (exit 0). */
48
+ | {
49
+ readonly kind: "already";
50
+ readonly lines: readonly string[];
51
+ }
52
+ /** Go: record `threadId` (when `changed`) and start the node. */
53
+ | {
54
+ readonly kind: "resume";
55
+ readonly threadId: string;
56
+ readonly changed: boolean;
57
+ readonly rolloutPath: string;
58
+ };
59
+ /** How many threads the picker numbers; older ones are reachable with --thread. */
60
+ export declare const PICK_LIMIT = 20;
61
+ export declare function freshStartCommand(f: Pick<CodexResumeFacts, "alias" | "kind">): string;
62
+ export declare function codexLoginCommand(f: Pick<CodexResumeFacts, "codexHome" | "homeIsHost">): string;
63
+ /** Numbered rows: time (UTC, as codex wrote it), short id, first user line. The recorded thread is marked. */
64
+ export declare function formatNodeThreadList(threads: readonly ExternalThread[], recorded: string | null, limit?: number): string[];
65
+ export declare function resumeCommandFor(alias: string, threadId: string): string;
66
+ /** The whole decision. Order: request shape → home → which thread → login → process state. */
67
+ export declare function decideCodexResume(f: CodexResumeFacts, req: CodexResumeRequest): CodexResumeDecision;
68
+ /** A typed answer to the picker: a number from the list; empty / q = cancel. */
69
+ export declare function parsePickAnswer(answer: string | null, choices: readonly string[]): {
70
+ kind: "ok";
71
+ threadId: string;
72
+ } | {
73
+ kind: "cancel";
74
+ } | {
75
+ kind: "bad";
76
+ message: string;
77
+ };
78
+ /**
79
+ * `anet node codex resume` records the thread in config before its state
80
+ * machine runs. If the run stops before anything was touched, the old value
81
+ * goes back — the config must not name a thread the node is not running (#531 §5).
82
+ */
83
+ export declare function resumeConfigShouldRollBack(stoppedAt: string): boolean;
84
+ /**
85
+ * The facts for one node, from the same helpers the codex menu uses
86
+ * (collectCodexRows: kind / state / login; effectiveCodexHome: which home).
87
+ * Read-only. null = not a codex node.
88
+ */
89
+ export declare function gatherCodexResumeFacts(node: CodexMenuNode, env: CollectEnv): CodexResumeFacts | null;
@@ -0,0 +1,39 @@
1
+ export declare const NODE_SERVER_VERSION_MARKER_PREFIX = "// anet-node-server-version: ";
2
+ /** The version carried by a node-server payload, or null if it has no valid marker. */
3
+ export declare function readNodeServerVersion(text: string | null | undefined): string | null;
4
+ /**
5
+ * Add the marker if the payload has none. A leading `#!` line stays first so
6
+ * the file is still directly executable.
7
+ */
8
+ export declare function stampNodeServerVersion(payload: string, version: string): string;
9
+ /**
10
+ * Version of the agent-network package that owns `sourcePath`, found by walking
11
+ * up (dist/src/node-server.js → package root is two levels up; src/node-server.ts
12
+ * one level). Null when no agent-network package.json is found.
13
+ */
14
+ export declare function owningAgentNetworkVersion(sourcePath: string): string | null;
15
+ /** Ensure the payload carries a marker, deriving the version from its source package when needed. */
16
+ export declare function ensureNodeServerVersionMarker(payload: string, sourcePath: string): string;
17
+ export type NodeServerWriteDecision = {
18
+ action: "write";
19
+ existingVersion: string | null;
20
+ incomingVersion: string | null;
21
+ } | {
22
+ action: "keep-newer";
23
+ existingVersion: string;
24
+ incomingVersion: string;
25
+ };
26
+ /**
27
+ * Keep the existing file only when BOTH sides carry a valid marker and the
28
+ * existing one is strictly newer. Everything else behaves as before (#549).
29
+ */
30
+ export declare function decideNodeServerWrite(existing: string | null, incoming: string): NodeServerWriteDecision;
31
+ /** The one-line warning printed when a newer file is kept. */
32
+ export declare function nodeServerKeptNewerWarning(existingVersion: string, incomingVersion: string): string;
33
+ export type NodeServerApplyResult = "wrote" | "unchanged" | "kept-newer";
34
+ /**
35
+ * The single write path both cli.ts writers use: stamp the payload, refuse to
36
+ * downgrade a newer existing file (warning once via `warn`), otherwise write
37
+ * when the bytes differ.
38
+ */
39
+ export declare function applyNodeServerPayload(targetPath: string, payload: string, sourcePath: string, warn?: (line: string) => void): NodeServerApplyResult;