@sleep2agi/agent-network 2.3.0-preview.156 → 2.3.0-preview.158
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-copresence-env.d.ts +5 -0
- package/dist/src/codex-copresence-recovery.d.ts +9 -0
- package/dist/src/codex-copresence-resume-timeout.d.ts +28 -0
- package/dist/src/codex-copresence-rollout-guard.d.ts +36 -0
- package/dist/src/codex-copresence-rpc.d.ts +15 -0
- package/dist/src/codex-external-appserver.d.ts +6 -0
- package/dist/src/codex-fork-recovery.d.ts +47 -0
- package/dist/src/codex-pending-thread-restart.d.ts +15 -1
- package/dist/src/codex-recovery-resource-gate.d.ts +15 -0
- package/dist/src/codex-rollout-history-guard.d.ts +84 -0
- package/dist/src/im/feishu/worker.js +1 -1
- package/dist/src/node-server.js +8 -8
- package/dist/src/opencode-agent-node-pair.d.ts +6 -6
- package/dist/src/posix-codex-copresence.d.ts +0 -2
- package/dist/src/shared/reserved-env.d.ts +3 -0
- package/dist/src/start-resource-gate.d.ts +146 -0
- package/package.json +4 -2
package/dist/src/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a0_0x42246c=a0_0x3ddc;(function(_0x4b3d82,_0x46aa53){const _0x5d4a50=a0_0x3ddc,_0x140c67=_0x4b3d82();while(!![]){try{const _0x41a55a=-parseInt(_0x5d4a50(0x124))/0x1*(parseInt(_0x5d4a50(0x118))/0x2)+-parseInt(_0x5d4a50(0x140))/0x3+-parseInt(_0x5d4a50(0x170))/0x4+parseInt(_0x5d4a50(0x171))/0x5*(-parseInt(_0x5d4a50(0x177))/0x6)+-parseInt(_0x5d4a50(0x117))/0x7*(-parseInt(_0x5d4a50(0x16e))/0x8)+parseInt(_0x5d4a50(0x12b))/0x9*(parseInt(_0x5d4a50(0x149))/0xa)+-parseInt(_0x5d4a50(0x108))/0xb*(-parseInt(_0x5d4a50(0x11f))/0xc);if(_0x41a55a===_0x46aa53)break;else _0x140c67['push'](_0x140c67['shift']());}catch(_0x90312e){_0x140c67['push'](_0x140c67['shift']());}}}(a0_0x3212,0x4a104));import{EventEmitter as a0_0x614c1b}from'events';import{hostname as a0_0x55d1c0}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x33a5a9,_0x335236)=>(_0x33a5a9??_0x335236)[a0_0x42246c(0x147)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x42246c(0x154)](0x0,0xf0);function a0_0x3212(){const _0x538509=['Authorization','2.0','task.expired','SSE\x20connected','12dBtfxv','min','missing_task_id','networkId','toTimeString','1gLvyIW','/mcp','data:\x20','not_tracked','heartbeat\x20failed:\x20','get_inbox','<pending>','63zaxxAO','task.ack','task.replied','send_failed','read','resumeId','connectSSE','\x20from=','status','broadcast','task.send.start','autoConnect','abort','sseAbort','running','offline','sdk-','now','error','duration_ms','messages','1749009wlJpjJ','text/event-stream','task.send.delivered','log','sdk','fromAlias','startsWith','replace','CommHub\x20response\x20omitted\x20task_id','553390nsUaTg','alias','signal','\x20network_id=','sending','\x20parent_task_id=','/events/','heartbeatInterval','send_task','cwd','toAlias','slice','task_id','\x20task_id=','connect','idle','POST','reply','send_message','type','unknown\x20error','send','getReader','reconnectDelay','mcp_http','parent_task_id','message','string','inbox\x20error:\x20','\x20to=','from_session','delivered','lifecycleTracking','disconnected','processInbox','<missing>','send_reply','7352DTVJpB','tools/call','833104GufFLv','47485WnuNfD','Bearer\x20','s...','content','body','match','6NWcIAV','sleep','name','disconnect','report_status','url','text','agent','emit','application/json,\x20text/event-stream','getAllStatus','registered','network_id','send_rejected','parentTaskId','token','parse','connected','6444317bpRwqz','decode','stringify','server','ack_inbox','call','transport','\x20error=','heartbeatTimer','error_code','catch','failed','<unknown>','AbortError','lifecycle_tracking','4501Oeurve','919994EOULeG','error_message','task.send.failed'];a0_0x3212=function(){return _0x538509;};return a0_0x3212();}function N(_0x45fd27){const _0x1c0cff=a0_0x42246c;return(_0x45fd27 instanceof Error?_0x45fd27[_0x1c0cff(0x163)]:String(_0x45fd27??_0x1c0cff(0x15d)))[_0x1c0cff(0x147)](K,'[REDACTED]')[_0x1c0cff(0x147)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x1c0cff(0x154)](0x0,0xf0);}function a0_0x3ddc(_0xa368f0,_0x26db90){_0xa368f0=_0xa368f0-0xff;const _0x3212ad=a0_0x3212();let _0x3ddc8f=_0x3212ad[_0xa368f0];return _0x3ddc8f;}function O(_0x17a6c4,_0x366d06=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x558257=a0_0x42246c;if(_0x366d06)return JSON[_0x558257(0x10a)](_0x17a6c4);let _0x4389b9=L(_0x17a6c4[_0x558257(0x162)],_0x558257(0x16c)),_0x142c25=L(_0x17a6c4[_0x558257(0x155)],_0x558257(0x12a)),_0x48ab33=_0x17a6c4['error_code']?_0x558257(0x10f)+_0x17a6c4[_0x558257(0x111)]+':'+(_0x17a6c4[_0x558257(0x119)]??''):'';return'[commhub:task]\x20'+_0x17a6c4['status']+_0x558257(0x132)+L(_0x17a6c4['from_alias'],_0x558257(0x114))+_0x558257(0x166)+L(_0x17a6c4['to_alias'],_0x558257(0x114))+_0x558257(0x156)+_0x142c25+_0x558257(0x14e)+_0x4389b9+_0x558257(0x14c)+L(_0x17a6c4[_0x558257(0x102)],_0x558257(0x114))+'\x20transport='+_0x17a6c4[_0x558257(0x10e)]+'\x20duration_ms='+_0x17a6c4[_0x558257(0x13e)]+'\x20lifecycle='+_0x17a6c4[_0x558257(0x116)]+_0x48ab33;}function U(_0x4425a7){const _0x151bae=a0_0x42246c;return{'event':{'sending':_0x151bae(0x135),'delivered':_0x151bae(0x142),'failed':_0x151bae(0x11a),'acked':_0x151bae(0x12c),'started':'task.started','replied':_0x151bae(0x12d),'expired':_0x151bae(0x11d)}[_0x4425a7['status']],..._0x4425a7};}function j(_0x334ac2){const _0xf36363=a0_0x42246c;let _0x2161a7=_0x334ac2?.[_0xf36363(0x155)]||_0x334ac2?.['message_id']||_0x334ac2?.['id'];if(_0x2161a7)return String(_0x2161a7);let _0x5523b9=_0x334ac2?.['content']?.[0x0]?.[_0xf36363(0x17d)];if(typeof _0x5523b9!==_0xf36363(0x164))return null;try{let _0x82ca17=JSON[_0xf36363(0x106)](_0x5523b9);return _0x82ca17?.[_0xf36363(0x155)]||_0x82ca17?.['message_id']||_0x82ca17?.['id']||null;}catch{return null;}}async function X(_0x55403d,_0x4d2fb9){const _0x95c17f=a0_0x42246c;let _0x3442ac=_0x4d2fb9[_0x95c17f(0x13c)]??Date[_0x95c17f(0x13c)],_0x5c9970=_0x3442ac(),_0x179d85=(_0xbdb02b,_0x429e94,_0x5979f2,_0x5b761a)=>{const _0x268b5b=_0x95c17f;_0x4d2fb9[_0x268b5b(0x143)](O(U({'from_alias':_0x55403d[_0x268b5b(0x145)],'to_alias':_0x55403d[_0x268b5b(0x153)],'task_id':_0x429e94,'parent_task_id':_0x55403d[_0x268b5b(0x104)],'network_id':_0x55403d[_0x268b5b(0x122)],'transport':_0x55403d['transport'],'status':_0xbdb02b,'duration_ms':_0x3442ac()-_0x5c9970,'lifecycle_tracking':_0x55403d[_0x268b5b(0x169)],..._0x5979f2!==void 0x0?{'error_code':_0x5b761a||_0x268b5b(0x12e),'error_message':N(_0x5979f2)}:{}})));};_0x179d85(_0x95c17f(0x14d),null);try{let _0x3bcb66=await _0x4d2fb9[_0x95c17f(0x15e)](),_0x5d2ae2=j(_0x3bcb66);if(_0x5d2ae2)_0x179d85(_0x95c17f(0x168),_0x5d2ae2);else{if(_0x3bcb66?.['ok']===!0x1||_0x3bcb66?.[_0x95c17f(0x13d)])_0x179d85(_0x95c17f(0x113),_0x5d2ae2,_0x3bcb66?.[_0x95c17f(0x13d)]||'CommHub\x20rejected\x20task',_0x95c17f(0x103));else _0x179d85('failed',null,_0x95c17f(0x148),_0x95c17f(0x121));}return _0x3bcb66;}catch(_0x271a59){throw _0x179d85(_0x95c17f(0x113),null,_0x271a59,_0x95c17f(0x12e)),_0x271a59;}}async function Y(_0x15df0e,_0x50eadd){const _0x2b2e62=a0_0x42246c;return X({'fromAlias':_0x15df0e['fromAlias'],'toAlias':_0x15df0e['alias'],'parentTaskId':_0x15df0e[_0x2b2e62(0x104)]||null,'networkId':_0x15df0e[_0x2b2e62(0x122)]||null,'transport':_0x2b2e62(0x161),'lifecycleTracking':_0x2b2e62(0x127)},_0x50eadd);}class $ extends a0_0x614c1b{[a0_0x42246c(0x17c)];['alias'];[a0_0x42246c(0x105)];[a0_0x42246c(0x17e)];[a0_0x42246c(0x130)];[a0_0x42246c(0x150)];[a0_0x42246c(0x160)];[a0_0x42246c(0x110)];[a0_0x42246c(0x138)];['running']=!0x1;constructor(_0x4bfd48){const _0x5e6c33=a0_0x42246c;super();if(this[_0x5e6c33(0x17c)]=_0x4bfd48[_0x5e6c33(0x17c)][_0x5e6c33(0x147)](/\/$/,''),this[_0x5e6c33(0x14a)]=_0x4bfd48['alias'],this[_0x5e6c33(0x105)]=_0x4bfd48[_0x5e6c33(0x105)],this[_0x5e6c33(0x17e)]=_0x4bfd48[_0x5e6c33(0x17e)]||_0x5e6c33(0x144),this[_0x5e6c33(0x130)]=_0x5e6c33(0x13b)+_0x4bfd48[_0x5e6c33(0x14a)]+'-'+Date['now']()['toString'](0x24),this[_0x5e6c33(0x150)]=_0x4bfd48[_0x5e6c33(0x150)]??0x2bf20,this[_0x5e6c33(0x160)]=_0x4bfd48[_0x5e6c33(0x160)]??0xbb8,_0x4bfd48[_0x5e6c33(0x136)]!==!0x1)this['connect']();}[a0_0x42246c(0x143)](_0x7cf40){const _0x3af873=a0_0x42246c;console[_0x3af873(0x143)]('['+new Date()[_0x3af873(0x123)]()[_0x3af873(0x154)](0x0,0x8)+']\x20[commhub:'+this[_0x3af873(0x14a)]+']\x20'+_0x7cf40);}async[a0_0x42246c(0x10d)](_0x19380d,_0x49b43d){const _0x5f0ec=a0_0x42246c;let _0x1e1c62={'Content-Type':'application/json','Accept':_0x5f0ec(0xff)};if(this['token'])_0x1e1c62[_0x5f0ec(0x11b)]=_0x5f0ec(0x172)+this['token'];let _0x37ff52=await(await fetch(this[_0x5f0ec(0x17c)]+_0x5f0ec(0x125),{'method':_0x5f0ec(0x159),'headers':_0x1e1c62,'body':JSON[_0x5f0ec(0x10a)]({'jsonrpc':_0x5f0ec(0x11c),'id':Date['now'](),'method':_0x5f0ec(0x16f),'params':{'name':_0x19380d,'arguments':_0x49b43d}})}))[_0x5f0ec(0x17d)](),_0x572528=_0x37ff52[_0x5f0ec(0x176)](/data: (.+)/),_0x4449dd=_0x572528?JSON[_0x5f0ec(0x106)](_0x572528[0x1]):JSON[_0x5f0ec(0x106)](_0x37ff52),_0x291d00=_0x4449dd?.['result']?.[_0x5f0ec(0x174)]?.[0x0]?.[_0x5f0ec(0x17d)];return _0x291d00?JSON[_0x5f0ec(0x106)](_0x291d00):_0x4449dd;}async[a0_0x42246c(0x157)](){const _0x4ec024=a0_0x42246c;if(this[_0x4ec024(0x139)])return;this[_0x4ec024(0x139)]=!0x0,await this[_0x4ec024(0x133)](_0x4ec024(0x158)),this[_0x4ec024(0x143)](_0x4ec024(0x101)),this[_0x4ec024(0x110)]=setInterval(()=>{const _0x50984d=_0x4ec024;this['status']('idle')[_0x50984d(0x112)](_0x27572d=>this['log'](_0x50984d(0x128)+_0x27572d[_0x50984d(0x163)]));},this['heartbeatInterval']),this[_0x4ec024(0x131)]();}async[a0_0x42246c(0x17a)](){const _0x114d10=a0_0x42246c;if(this[_0x114d10(0x139)]=!0x1,this[_0x114d10(0x138)]?.[_0x114d10(0x137)](),this[_0x114d10(0x110)])clearInterval(this[_0x114d10(0x110)]);await this[_0x114d10(0x133)](_0x114d10(0x13a))['catch'](()=>{}),this[_0x114d10(0x143)]('disconnected');}async[a0_0x42246c(0x15e)](_0x95eedb,_0x5ba4c5,_0x57d2d5='normal'){const _0x59b618=a0_0x42246c;return Y({'alias':_0x95eedb,'fromAlias':this['alias']},{'log':_0x22adc4=>console[_0x59b618(0x143)](_0x22adc4),'send':()=>this[_0x59b618(0x10d)](_0x59b618(0x151),{'alias':_0x95eedb,'task':_0x5ba4c5,'priority':_0x57d2d5,'from_session':this[_0x59b618(0x14a)]})});}async['message'](_0x2de512,_0x3112f5){const _0x5d1c77=a0_0x42246c;return this[_0x5d1c77(0x10d)](_0x5d1c77(0x15b),{'alias':_0x2de512,'message':_0x3112f5,'from_session':this[_0x5d1c77(0x14a)]});}async[a0_0x42246c(0x15a)](_0x47bba5,_0x392158,_0x2bc3e6='completed'){const _0x2997a3=a0_0x42246c;return this['call'](_0x2997a3(0x16d),{'in_reply_to':_0x47bba5,'text':_0x392158,'status':_0x2bc3e6});}async['status'](_0x4dfba2,_0x2d3dac){const _0x3abf1c=a0_0x42246c;return this[_0x3abf1c(0x10d)](_0x3abf1c(0x17b),{'resume_id':this[_0x3abf1c(0x130)],'alias':this[_0x3abf1c(0x14a)],'status':_0x4dfba2,'server':a0_0x55d1c0(),'hostname':a0_0x55d1c0(),'agent':this['agent'],'project_dir':process[_0x3abf1c(0x152)](),..._0x2d3dac});}async[a0_0x42246c(0x100)](){return this['call']('get_all_status',{});}async[a0_0x42246c(0x134)](_0x370fa1,_0x102bb6){const _0x4483df=a0_0x42246c;return this['call']('broadcast',{'message':_0x370fa1,'filter_server':_0x102bb6?.[_0x4483df(0x10b)],'filter_status':_0x102bb6?.[_0x4483df(0x133)]});}async[a0_0x42246c(0x131)](){const _0x25b910=a0_0x42246c;let _0x233d00=encodeURIComponent(this[_0x25b910(0x14a)]),_0x441a52=this[_0x25b910(0x17c)]+_0x25b910(0x14f)+_0x233d00,_0x2d3993=this[_0x25b910(0x160)];while(this[_0x25b910(0x139)]){try{this[_0x25b910(0x138)]=new AbortController();let _0x29af1e={'Accept':_0x25b910(0x141)};if(this[_0x25b910(0x105)])_0x29af1e['Authorization']=_0x25b910(0x172)+this[_0x25b910(0x105)];let _0x10ff8f=await fetch(_0x441a52,{'headers':_0x29af1e,'signal':this[_0x25b910(0x138)][_0x25b910(0x14b)]});if(!_0x10ff8f['ok']||!_0x10ff8f[_0x25b910(0x175)]){this[_0x25b910(0x143)]('SSE\x20failed:\x20'+_0x10ff8f[_0x25b910(0x133)]),await this[_0x25b910(0x178)](_0x2d3993),_0x2d3993=Math['min'](_0x2d3993*1.5,0xea60);continue;}_0x2d3993=this[_0x25b910(0x160)];let _0x23938c=_0x10ff8f[_0x25b910(0x175)][_0x25b910(0x15f)](),_0xe7021=new TextDecoder(),_0x2eaf14='';while(this[_0x25b910(0x139)]){let {done:_0x26a94c,value:_0x57d59f}=await _0x23938c[_0x25b910(0x12f)]();if(_0x26a94c)break;_0x2eaf14+=_0xe7021[_0x25b910(0x109)](_0x57d59f,{'stream':!0x0});let _0x385708=_0x2eaf14['split']('\x0a');_0x2eaf14=_0x385708['pop']()||'';for(let _0x480325 of _0x385708){if(!_0x480325[_0x25b910(0x146)](_0x25b910(0x126)))continue;try{let _0x320d0a=JSON[_0x25b910(0x106)](_0x480325[_0x25b910(0x154)](0x6));if(_0x320d0a[_0x25b910(0x15c)]===_0x25b910(0x107)){this[_0x25b910(0x143)](_0x25b910(0x11e)),this[_0x25b910(0x17f)]('connected');continue;}if(_0x320d0a['type']==='new_task'||_0x320d0a[_0x25b910(0x15c)]==='new_message'||_0x320d0a[_0x25b910(0x15c)]==='broadcast')await this[_0x25b910(0x16b)]();}catch{}}}}catch(_0x444ea7){if(_0x444ea7[_0x25b910(0x179)]===_0x25b910(0x115))break;this[_0x25b910(0x17f)]('error',_0x444ea7),this['log']('SSE\x20error:\x20'+_0x444ea7[_0x25b910(0x163)]);}if(this['running'])this[_0x25b910(0x17f)](_0x25b910(0x16a)),this[_0x25b910(0x143)]('SSE\x20reconnecting\x20in\x20'+_0x2d3993/0x3e8+_0x25b910(0x173)),await this['sleep'](_0x2d3993),_0x2d3993=Math[_0x25b910(0x120)](_0x2d3993*1.5,0xea60);}}async[a0_0x42246c(0x16b)](){const _0x4db0f8=a0_0x42246c;try{let _0x306b97=(await this[_0x4db0f8(0x10d)](_0x4db0f8(0x129),{'alias':this[_0x4db0f8(0x14a)],'limit':0xa}))?.[_0x4db0f8(0x13f)]||[];for(let _0x23716d of _0x306b97)await this[_0x4db0f8(0x10d)](_0x4db0f8(0x10c),{'alias':this[_0x4db0f8(0x14a)],'message_id':_0x23716d['id']}),this[_0x4db0f8(0x143)]('←\x20'+_0x23716d[_0x4db0f8(0x167)]+':\x20'+_0x23716d['content'][_0x4db0f8(0x154)](0x0,0x3c)),this[_0x4db0f8(0x17f)]('task',_0x23716d),this[_0x4db0f8(0x17f)](_0x4db0f8(0x163),_0x23716d);}catch(_0x4eac54){this[_0x4db0f8(0x143)](_0x4db0f8(0x165)+_0x4eac54[_0x4db0f8(0x163)]);}}[a0_0x42246c(0x178)](_0x3f7839){return new Promise(_0x171cd2=>setTimeout(_0x171cd2,_0x3f7839));}}var F=$;export{F as default,$ as CommHub};
|
|
1
|
+
const a0_0x29ff6e=a0_0xf0ac;(function(_0x5ec37e,_0x3bf339){const _0x16ff02=a0_0xf0ac,_0x471eaa=_0x5ec37e();while(!![]){try{const _0x129bbc=-parseInt(_0x16ff02(0x248))/0x1+-parseInt(_0x16ff02(0x236))/0x2*(parseInt(_0x16ff02(0x1e4))/0x3)+-parseInt(_0x16ff02(0x226))/0x4*(-parseInt(_0x16ff02(0x20e))/0x5)+parseInt(_0x16ff02(0x22d))/0x6+-parseInt(_0x16ff02(0x24e))/0x7*(parseInt(_0x16ff02(0x22c))/0x8)+parseInt(_0x16ff02(0x219))/0x9*(parseInt(_0x16ff02(0x24f))/0xa)+-parseInt(_0x16ff02(0x234))/0xb;if(_0x129bbc===_0x3bf339)break;else _0x471eaa['push'](_0x471eaa['shift']());}catch(_0x531469){_0x471eaa['push'](_0x471eaa['shift']());}}}(a0_0x1b64,0x86cbe));import{EventEmitter as a0_0x56ddee}from'events';import{hostname as a0_0x12ebf3}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x3d3a15,_0x4e6d55)=>(_0x3d3a15??_0x4e6d55)[a0_0x29ff6e(0x23a)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x29ff6e(0x249)](0x0,0xf0);function N(_0x2a1028){const _0x46a117=a0_0x29ff6e;return(_0x2a1028 instanceof Error?_0x2a1028[_0x46a117(0x213)]:String(_0x2a1028??_0x46a117(0x235)))['replace'](K,_0x46a117(0x1ea))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x46a117(0x249)](0x0,0xf0);}function O(_0x375ab9,_0xa14e67=process.env.ANET_TASK_TRACE_FORMAT===a0_0x29ff6e(0x216)){const _0x556f22=a0_0x29ff6e;if(_0xa14e67)return JSON['stringify'](_0x375ab9);let _0x260ad1=L(_0x375ab9[_0x556f22(0x203)],_0x556f22(0x227)),_0x3a8b85=L(_0x375ab9['task_id'],'<pending>'),_0x1771f0=_0x375ab9[_0x556f22(0x239)]?'\x20error='+_0x375ab9[_0x556f22(0x239)]+':'+(_0x375ab9['error_message']??''):'';return _0x556f22(0x241)+_0x375ab9[_0x556f22(0x258)]+_0x556f22(0x215)+L(_0x375ab9['from_alias'],'<unknown>')+'\x20to='+L(_0x375ab9['to_alias'],'<unknown>')+_0x556f22(0x24a)+_0x3a8b85+_0x556f22(0x255)+_0x260ad1+_0x556f22(0x243)+L(_0x375ab9[_0x556f22(0x20d)],_0x556f22(0x247))+'\x20transport='+_0x375ab9[_0x556f22(0x221)]+'\x20duration_ms='+_0x375ab9[_0x556f22(0x1f6)]+'\x20lifecycle='+_0x375ab9[_0x556f22(0x207)]+_0x1771f0;}function U(_0x382585){const _0x4d8f09=a0_0x29ff6e;return{'event':{'sending':_0x4d8f09(0x23c),'delivered':_0x4d8f09(0x246),'failed':_0x4d8f09(0x1f2),'acked':_0x4d8f09(0x230),'started':_0x4d8f09(0x1fc),'replied':_0x4d8f09(0x256),'expired':'task.expired'}[_0x382585[_0x4d8f09(0x258)]],..._0x382585};}function a0_0xf0ac(_0x313ce4,_0x329d07){_0x313ce4=_0x313ce4-0x1e2;const _0x1b6485=a0_0x1b64();let _0xf0acfc=_0x1b6485[_0x313ce4];return _0xf0acfc;}function j(_0x548429){const _0x597830=a0_0x29ff6e;let _0x1b1fc5=_0x548429?.[_0x597830(0x25a)]||_0x548429?.[_0x597830(0x251)]||_0x548429?.['id'];if(_0x1b1fc5)return String(_0x1b1fc5);let _0x4aabae=_0x548429?.[_0x597830(0x1f1)]?.[0x0]?.[_0x597830(0x1fe)];if(typeof _0x4aabae!=='string')return null;try{let _0x4bcc56=JSON[_0x597830(0x22b)](_0x4aabae);return _0x4bcc56?.[_0x597830(0x25a)]||_0x4bcc56?.['message_id']||_0x4bcc56?.['id']||null;}catch{return null;}}async function X(_0x1f3aef,_0x4c45ab){const _0x1ec834=a0_0x29ff6e;let _0x46a5dc=_0x4c45ab['now']??Date[_0x1ec834(0x24c)],_0x54f204=_0x46a5dc(),_0xc95b5e=(_0x24dcff,_0x2e3201,_0x12ad42,_0x28657a)=>{const _0x482902=_0x1ec834;_0x4c45ab[_0x482902(0x240)](O(U({'from_alias':_0x1f3aef['fromAlias'],'to_alias':_0x1f3aef[_0x482902(0x25b)],'task_id':_0x2e3201,'parent_task_id':_0x1f3aef['parentTaskId'],'network_id':_0x1f3aef[_0x482902(0x20c)],'transport':_0x1f3aef[_0x482902(0x221)],'status':_0x24dcff,'duration_ms':_0x46a5dc()-_0x54f204,'lifecycle_tracking':_0x1f3aef[_0x482902(0x225)],..._0x12ad42!==void 0x0?{'error_code':_0x28657a||_0x482902(0x200),'error_message':N(_0x12ad42)}:{}})));};_0xc95b5e(_0x1ec834(0x242),null);try{let _0x1f4ffc=await _0x4c45ab['send'](),_0x9063ff=j(_0x1f4ffc);if(_0x9063ff)_0xc95b5e(_0x1ec834(0x202),_0x9063ff);else{if(_0x1f4ffc?.['ok']===!0x1||_0x1f4ffc?.[_0x1ec834(0x229)])_0xc95b5e(_0x1ec834(0x224),_0x9063ff,_0x1f4ffc?.['error']||_0x1ec834(0x1ed),'send_rejected');else _0xc95b5e('failed',null,_0x1ec834(0x206),'missing_task_id');}return _0x1f4ffc;}catch(_0x8a6ded){throw _0xc95b5e('failed',null,_0x8a6ded,_0x1ec834(0x200)),_0x8a6ded;}}async function Y(_0x5144a3,_0x3616a2){const _0x653631=a0_0x29ff6e;return X({'fromAlias':_0x5144a3[_0x653631(0x1eb)],'toAlias':_0x5144a3[_0x653631(0x228)],'parentTaskId':_0x5144a3[_0x653631(0x1e9)]||null,'networkId':_0x5144a3[_0x653631(0x20c)]||null,'transport':'mcp_http','lifecycleTracking':_0x653631(0x1f7)},_0x3616a2);}class $ extends a0_0x56ddee{[a0_0x29ff6e(0x1f9)];[a0_0x29ff6e(0x228)];['token'];['agent'];['resumeId'];['heartbeatInterval'];[a0_0x29ff6e(0x23d)];[a0_0x29ff6e(0x20f)];[a0_0x29ff6e(0x252)];['running']=!0x1;constructor(_0x580e02){const _0x43c5dd=a0_0x29ff6e;super();if(this['url']=_0x580e02[_0x43c5dd(0x1f9)][_0x43c5dd(0x23a)](/\/$/,''),this[_0x43c5dd(0x228)]=_0x580e02[_0x43c5dd(0x228)],this['token']=_0x580e02[_0x43c5dd(0x1ef)],this[_0x43c5dd(0x22f)]=_0x580e02[_0x43c5dd(0x22f)]||'sdk',this[_0x43c5dd(0x1f4)]=_0x43c5dd(0x222)+_0x580e02[_0x43c5dd(0x228)]+'-'+Date[_0x43c5dd(0x24c)]()[_0x43c5dd(0x23f)](0x24),this[_0x43c5dd(0x1e8)]=_0x580e02[_0x43c5dd(0x1e8)]??0x2bf20,this[_0x43c5dd(0x23d)]=_0x580e02['reconnectDelay']??0xbb8,_0x580e02[_0x43c5dd(0x1e6)]!==!0x1)this['connect']();}[a0_0x29ff6e(0x240)](_0x556b59){const _0x341ffe=a0_0x29ff6e;console[_0x341ffe(0x240)]('['+new Date()[_0x341ffe(0x218)]()['slice'](0x0,0x8)+_0x341ffe(0x1fa)+this[_0x341ffe(0x228)]+']\x20'+_0x556b59);}async[a0_0x29ff6e(0x204)](_0x2a0139,_0x4ada90){const _0x3d8b66=a0_0x29ff6e;let _0x3ce317={'Content-Type':'application/json','Accept':_0x3d8b66(0x1f3)};if(this[_0x3d8b66(0x1ef)])_0x3ce317['Authorization']=_0x3d8b66(0x244)+this[_0x3d8b66(0x1ef)];let _0x3e8f17=await(await fetch(this[_0x3d8b66(0x1f9)]+'/mcp',{'method':'POST','headers':_0x3ce317,'body':JSON[_0x3d8b66(0x223)]({'jsonrpc':'2.0','id':Date[_0x3d8b66(0x24c)](),'method':_0x3d8b66(0x220),'params':{'name':_0x2a0139,'arguments':_0x4ada90}})}))[_0x3d8b66(0x1fe)](),_0x21bd24=_0x3e8f17[_0x3d8b66(0x1e3)](/data: (.+)/),_0x26a8d2=_0x21bd24?JSON[_0x3d8b66(0x22b)](_0x21bd24[0x1]):JSON[_0x3d8b66(0x22b)](_0x3e8f17),_0xcd63bd=_0x26a8d2?.[_0x3d8b66(0x205)]?.[_0x3d8b66(0x1f1)]?.[0x0]?.[_0x3d8b66(0x1fe)];return _0xcd63bd?JSON[_0x3d8b66(0x22b)](_0xcd63bd):_0x26a8d2;}async[a0_0x29ff6e(0x214)](){const _0x1b67e5=a0_0x29ff6e;if(this[_0x1b67e5(0x21e)])return;this['running']=!0x0,await this[_0x1b67e5(0x258)]('idle'),this[_0x1b67e5(0x240)]('registered'),this['heartbeatTimer']=setInterval(()=>{const _0x52c8b0=_0x1b67e5;this[_0x52c8b0(0x258)](_0x52c8b0(0x22e))[_0x52c8b0(0x22a)](_0x8adde9=>this['log'](_0x52c8b0(0x1fb)+_0x8adde9[_0x52c8b0(0x213)]));},this[_0x1b67e5(0x1e8)]),this[_0x1b67e5(0x23e)]();}async['disconnect'](){const _0x580ec8=a0_0x29ff6e;if(this['running']=!0x1,this[_0x580ec8(0x252)]?.[_0x580ec8(0x257)](),this[_0x580ec8(0x20f)])clearInterval(this[_0x580ec8(0x20f)]);await this[_0x580ec8(0x258)]('offline')[_0x580ec8(0x22a)](()=>{}),this[_0x580ec8(0x240)](_0x580ec8(0x1f8));}async[a0_0x29ff6e(0x253)](_0xd742b,_0x2d82ed,_0x238733=a0_0x29ff6e(0x1f0)){const _0x24a489=a0_0x29ff6e;return Y({'alias':_0xd742b,'fromAlias':this[_0x24a489(0x228)]},{'log':_0x18657c=>console[_0x24a489(0x240)](_0x18657c),'send':()=>this['call'](_0x24a489(0x245),{'alias':_0xd742b,'task':_0x2d82ed,'priority':_0x238733,'from_session':this[_0x24a489(0x228)]})});}async[a0_0x29ff6e(0x213)](_0x2ebf15,_0x173762){const _0x46ccc3=a0_0x29ff6e;return this[_0x46ccc3(0x204)]('send_message',{'alias':_0x2ebf15,'message':_0x173762,'from_session':this[_0x46ccc3(0x228)]});}async['reply'](_0x32810b,_0x1de703,_0x504d6b='completed'){const _0x44fc04=a0_0x29ff6e;return this[_0x44fc04(0x204)](_0x44fc04(0x254),{'in_reply_to':_0x32810b,'text':_0x1de703,'status':_0x504d6b});}async['status'](_0x139030,_0x5ed445){const _0x38d816=a0_0x29ff6e;return this[_0x38d816(0x204)]('report_status',{'resume_id':this[_0x38d816(0x1f4)],'alias':this[_0x38d816(0x228)],'status':_0x139030,'server':a0_0x12ebf3(),'hostname':a0_0x12ebf3(),'agent':this[_0x38d816(0x22f)],'project_dir':process[_0x38d816(0x20b)](),..._0x5ed445});}async[a0_0x29ff6e(0x238)](){const _0x5cad29=a0_0x29ff6e;return this[_0x5cad29(0x204)](_0x5cad29(0x21a),{});}async['broadcast'](_0x2c3e61,_0x3c2611){const _0x56b7d8=a0_0x29ff6e;return this['call'](_0x56b7d8(0x210),{'message':_0x2c3e61,'filter_server':_0x3c2611?.[_0x56b7d8(0x209)],'filter_status':_0x3c2611?.[_0x56b7d8(0x258)]});}async[a0_0x29ff6e(0x23e)](){const _0x2981ce=a0_0x29ff6e;let _0x53b0bd=encodeURIComponent(this[_0x2981ce(0x228)]),_0x4ae7fe=this[_0x2981ce(0x1f9)]+_0x2981ce(0x250)+_0x53b0bd,_0x2c8c00=this[_0x2981ce(0x23d)];while(this[_0x2981ce(0x21e)]){try{this['sseAbort']=new AbortController();let _0x5e2bc3={'Accept':'text/event-stream'};if(this[_0x2981ce(0x1ef)])_0x5e2bc3['Authorization']=_0x2981ce(0x244)+this[_0x2981ce(0x1ef)];let _0xd7f848=await fetch(_0x4ae7fe,{'headers':_0x5e2bc3,'signal':this[_0x2981ce(0x252)][_0x2981ce(0x259)]});if(!_0xd7f848['ok']||!_0xd7f848[_0x2981ce(0x201)]){this[_0x2981ce(0x240)](_0x2981ce(0x21c)+_0xd7f848[_0x2981ce(0x258)]),await this[_0x2981ce(0x21f)](_0x2c8c00),_0x2c8c00=Math[_0x2981ce(0x24d)](_0x2c8c00*1.5,0xea60);continue;}_0x2c8c00=this[_0x2981ce(0x23d)];let _0x2d3ebe=_0xd7f848[_0x2981ce(0x201)][_0x2981ce(0x1ec)](),_0x5ba44c=new TextDecoder(),_0x106900='';while(this[_0x2981ce(0x21e)]){let {done:_0x3043d5,value:_0x233193}=await _0x2d3ebe[_0x2981ce(0x232)]();if(_0x3043d5)break;_0x106900+=_0x5ba44c[_0x2981ce(0x208)](_0x233193,{'stream':!0x0});let _0x162ff5=_0x106900['split']('\x0a');_0x106900=_0x162ff5[_0x2981ce(0x1e7)]()||'';for(let _0x3e8c11 of _0x162ff5){if(!_0x3e8c11[_0x2981ce(0x217)](_0x2981ce(0x21d)))continue;try{let _0x48b776=JSON[_0x2981ce(0x22b)](_0x3e8c11[_0x2981ce(0x249)](0x6));if(_0x48b776['type']===_0x2981ce(0x1f5)){this[_0x2981ce(0x240)](_0x2981ce(0x1e2)),this[_0x2981ce(0x24b)](_0x2981ce(0x1f5));continue;}if(_0x48b776[_0x2981ce(0x20a)]===_0x2981ce(0x1fd)||_0x48b776[_0x2981ce(0x20a)]==='new_message'||_0x48b776[_0x2981ce(0x20a)]===_0x2981ce(0x210))await this[_0x2981ce(0x231)]();}catch{}}}}catch(_0x5b2b0e){if(_0x5b2b0e['name']===_0x2981ce(0x1ee))break;this['emit'](_0x2981ce(0x229),_0x5b2b0e),this[_0x2981ce(0x240)](_0x2981ce(0x1ff)+_0x5b2b0e[_0x2981ce(0x213)]);}if(this['running'])this['emit'](_0x2981ce(0x1f8)),this['log'](_0x2981ce(0x23b)+_0x2c8c00/0x3e8+_0x2981ce(0x211)),await this[_0x2981ce(0x21f)](_0x2c8c00),_0x2c8c00=Math['min'](_0x2c8c00*1.5,0xea60);}}async[a0_0x29ff6e(0x231)](){const _0x37acad=a0_0x29ff6e;try{let _0x343c65=(await this[_0x37acad(0x204)](_0x37acad(0x1e5),{'alias':this['alias'],'limit':0xa}))?.[_0x37acad(0x237)]||[];for(let _0x1997c2 of _0x343c65)await this[_0x37acad(0x204)](_0x37acad(0x212),{'alias':this[_0x37acad(0x228)],'message_id':_0x1997c2['id']}),this['log']('←\x20'+_0x1997c2[_0x37acad(0x21b)]+':\x20'+_0x1997c2[_0x37acad(0x1f1)][_0x37acad(0x249)](0x0,0x3c)),this[_0x37acad(0x24b)](_0x37acad(0x233),_0x1997c2),this[_0x37acad(0x24b)](_0x37acad(0x213),_0x1997c2);}catch(_0x2762fe){this[_0x37acad(0x240)]('inbox\x20error:\x20'+_0x2762fe[_0x37acad(0x213)]);}}['sleep'](_0x29cdbe){return new Promise(_0x5ebd59=>setTimeout(_0x5ebd59,_0x29cdbe));}}var F=$;export{F as default,$ as CommHub};function a0_0x1b64(){const _0xf03ce0=['3964020VfmYyo','idle','agent','task.ack','processInbox','read','task','3648304IZRBrd','unknown\x20error','149074iySyMg','messages','getAllStatus','error_code','replace','SSE\x20reconnecting\x20in\x20','task.send.start','reconnectDelay','connectSSE','toString','log','[commhub:task]\x20','sending','\x20network_id=','Bearer\x20','send_task','task.send.delivered','<unknown>','841906FjisOu','slice','\x20task_id=','emit','now','min','2681EpcIbV','100sZgCKd','/events/','message_id','sseAbort','send','send_reply','\x20parent_task_id=','task.replied','abort','status','signal','task_id','toAlias','SSE\x20connected','match','12JspBvY','get_inbox','autoConnect','pop','heartbeatInterval','parentTaskId','[REDACTED]','fromAlias','getReader','CommHub\x20rejected\x20task','AbortError','token','normal','content','task.send.failed','application/json,\x20text/event-stream','resumeId','connected','duration_ms','not_tracked','disconnected','url',']\x20[commhub:','heartbeat\x20failed:\x20','task.started','new_task','text','SSE\x20error:\x20','send_failed','body','delivered','parent_task_id','call','result','CommHub\x20response\x20omitted\x20task_id','lifecycle_tracking','decode','server','type','cwd','networkId','network_id','5mANVEH','heartbeatTimer','broadcast','s...','ack_inbox','message','connect','\x20from=','json','startsWith','toTimeString','525087BbfRQj','get_all_status','from_session','SSE\x20failed:\x20','data:\x20','running','sleep','tools/call','transport','sdk-','stringify','failed','lifecycleTracking','3200172tMiLTF','<missing>','alias','error','catch','parse','424hePDFL'];a0_0x1b64=function(){return _0xf03ce0;};return a0_0x1b64();}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Merge user config.env into one co-presence stage. Required launcher values
|
|
2
|
+
* always win. Invalid shell names/NULs fail closed before a tmux session starts. */
|
|
3
|
+
export declare function codexCopresenceStageEnv(configEnv: Readonly<Record<string, string>>, required: Readonly<Record<string, string>>): Record<string, string>;
|
|
4
|
+
/** Contents for a private source-then-delete file. Values never enter argv. */
|
|
5
|
+
export declare function codexCopresenceEnvFileText(env: Readonly<Record<string, string>>): string;
|
|
@@ -4,6 +4,8 @@ export interface CodexRecoveryVerification {
|
|
|
4
4
|
verifiedAt: string;
|
|
5
5
|
historyTurnCount: number;
|
|
6
6
|
historyFingerprint: string;
|
|
7
|
+
/** Metadata-only thread/read proof that Codex resolved this exact rollout. */
|
|
8
|
+
persistedPath?: string;
|
|
7
9
|
}
|
|
8
10
|
export interface CodexRecoveryBackup {
|
|
9
11
|
backupDir: string;
|
|
@@ -13,6 +15,13 @@ export interface CodexRecoveryBackup {
|
|
|
13
15
|
/** Transaction boundary shared by Windows and POSIX cutovers: the snapshot
|
|
14
16
|
* cannot begin until every authoritative state writer has quiesced. */
|
|
15
17
|
export declare function quiesceThenSnapshot<T>(quiesce: () => Promise<void>, snapshot: () => T): Promise<T>;
|
|
18
|
+
/** Copy and hash without ever materializing the whole file in a Buffer.
|
|
19
|
+
* Zero chunks are sought over and the final length is truncated explicitly,
|
|
20
|
+
* so a multi-GiB sparse rollout stays sparse in the private recovery point. */
|
|
21
|
+
export declare function copyAndHashRecoveryFile(source: string, target: string): {
|
|
22
|
+
size: number;
|
|
23
|
+
sha256: string;
|
|
24
|
+
};
|
|
16
25
|
/** A stored thread is never considered resumed until app-server reads the
|
|
17
26
|
* exact thread back with persisted history. This is deliberately stricter
|
|
18
27
|
* than accepting a successful thread/resume RPC response. */
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare const CODEX_RESUME_TIMEOUT_ENV = "ANET_CODEX_RESUME_TIMEOUT_MS";
|
|
2
|
+
export declare const CODEX_RESUME_BASE_TIMEOUT_MS = 300000;
|
|
3
|
+
export declare const CODEX_RESUME_PER_GIB_MS = 120000;
|
|
4
|
+
export declare const CODEX_RESUME_MAX_TIMEOUT_MS: number;
|
|
5
|
+
export declare const CODEX_RECOVERY_MIN_PAYLOAD_BYTES: number;
|
|
6
|
+
export declare const CODEX_RECOVERY_PAYLOAD_OVERHEAD_BYTES: number;
|
|
7
|
+
export declare const CODEX_RECOVERY_MAX_PAYLOAD_BYTES: number;
|
|
8
|
+
export interface CopresenceResumeBudget {
|
|
9
|
+
timeoutMs: number;
|
|
10
|
+
rolloutBytes: number | null;
|
|
11
|
+
}
|
|
12
|
+
/** `--new-session` is authoritative for co-presence too: never feed the
|
|
13
|
+
* recorded thread into thread/resume when the operator explicitly asked for
|
|
14
|
+
* a fresh conversation. */
|
|
15
|
+
export declare function codexThreadIdForStart(recordedThreadId: string | undefined, newSession: boolean): string | undefined;
|
|
16
|
+
/** Resolve the recovery deadline once, before opening the app-server socket.
|
|
17
|
+
* The automatic budget is 300 s plus 120 s for each started GiB of the exact
|
|
18
|
+
* recorded rollout, capped at 15 minutes. An explicit environment value wins. */
|
|
19
|
+
export declare function resolveCopresenceResumeBudget(codexHome: string, threadId: string | undefined, env?: NodeJS.ProcessEnv, warn?: (message: string) => void): CopresenceResumeBudget;
|
|
20
|
+
export declare function resolveCopresenceResumeTimeoutMs(codexHome: string, threadId: string | undefined, env?: NodeJS.ProcessEnv, warn?: (message: string) => void): number;
|
|
21
|
+
export declare function formatCopresenceRolloutSize(bytes: number | null): string;
|
|
22
|
+
/** A finite receive ceiling for the one large thread/resume frame emitted by
|
|
23
|
+
* older Codex app-servers. Twice the rollout plus protocol headroom covers the
|
|
24
|
+
* measured JSON expansion without giving the loopback peer an unlimited heap. */
|
|
25
|
+
export declare function resolveCopresenceMaxPayloadBytes(rolloutBytes: number | null): number;
|
|
26
|
+
/** The bridge can make one retry after a resume timeout, so launcher readiness
|
|
27
|
+
* covers both bounded attempts instead of killing it at the old fixed 25 s. */
|
|
28
|
+
export declare function resolveCopresenceBridgeAttachTimeoutMs(resumeTimeoutMs: number): number;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { spawnSync } from "child_process";
|
|
2
|
+
import { type FirstLineRead } from "./codex-rollout-history-guard";
|
|
3
|
+
export interface CopresenceRolloutGuardInput {
|
|
4
|
+
codexHome: string;
|
|
5
|
+
/** Threads this start may resume (recorded thread, pending candidate). Empty entries are skipped. */
|
|
6
|
+
threadIds: Array<string | undefined | null>;
|
|
7
|
+
/** The binary as the launch names it (probeVersion should run it the way the launch does). */
|
|
8
|
+
codexBin: string;
|
|
9
|
+
displayName: string;
|
|
10
|
+
probeVersion?: (bin: string) => string | null;
|
|
11
|
+
resolveRollout?: (codexHome: string, threadId: string) => string | null;
|
|
12
|
+
readFirstLine?: (path: string) => FirstLineRead;
|
|
13
|
+
}
|
|
14
|
+
export interface CopresenceRolloutGuardResult {
|
|
15
|
+
/** Non-null = refuse to start; print these lines. */
|
|
16
|
+
block: string[] | null;
|
|
17
|
+
/** Could-not-tell notes; print and continue. */
|
|
18
|
+
warnings: string[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* `codex --version` run through the SAME shell preamble the launch uses, so the
|
|
22
|
+
* probe sees the binary the launch will run: the launch command itself is never
|
|
23
|
+
* rewritten. The co-presence panes run `bash -lc "… exec <codexBin> app-server"`
|
|
24
|
+
* (login-shell PATH); external app-server panes run `bash -c "<source .env>; …;
|
|
25
|
+
* <codexBin> app-server"` (the workspace .env may set PATH). `script` must end in
|
|
26
|
+
* `exec <codexBin> --version`. Only a codex-identifying line counts; anything
|
|
27
|
+
* else (or any failure) is null = unknown, which never blocks.
|
|
28
|
+
*/
|
|
29
|
+
export declare function probeCodexVersionViaShell(script: string, opts: {
|
|
30
|
+
loginShell: boolean;
|
|
31
|
+
env?: NodeJS.ProcessEnv;
|
|
32
|
+
run?: typeof spawnSync;
|
|
33
|
+
}): string | null;
|
|
34
|
+
/** The co-presence app-server pane's preamble (CODEX_HOME, then exec the binary), ending in `--version`. */
|
|
35
|
+
export declare function copresenceVersionProbeScript(codexHome: string, codexBin: string): string;
|
|
36
|
+
export declare function copresenceRolloutGuard(input: CopresenceRolloutGuardInput): CopresenceRolloutGuardResult;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type CodexRecoveryVerification } from "./codex-copresence-recovery";
|
|
2
|
+
export declare const SAFE_CODEX_THREAD_ID: RegExp;
|
|
3
|
+
/** Minimal JSON-RPC client used only while bringing up a co-presence app-server. */
|
|
4
|
+
export declare function createCodexCopresenceThread(ws: string, timeoutMs: number, resumeThreadId?: string, model?: string,
|
|
5
|
+
/** forkFirst (board #738): `thread/fork` the recorded thread, then resume the NEW thread. */
|
|
6
|
+
options?: {
|
|
7
|
+
webSocketCtor?: any;
|
|
8
|
+
rolloutBytes?: number | null;
|
|
9
|
+
forkFirst?: boolean;
|
|
10
|
+
}): Promise<{
|
|
11
|
+
threadId: string;
|
|
12
|
+
verification?: CodexRecoveryVerification;
|
|
13
|
+
freshDeferred: boolean;
|
|
14
|
+
resumedModel?: string;
|
|
15
|
+
}>;
|
|
@@ -74,6 +74,12 @@ export declare function exactSessionRows(rows: readonly {
|
|
|
74
74
|
*/
|
|
75
75
|
export declare function tokenInSessionSnippet(configPath: string, jsRuntime: string): string;
|
|
76
76
|
export declare function appserverShellCommand(plan: ExternalAppserverPlan, jsRuntime: string): string;
|
|
77
|
+
/**
|
|
78
|
+
* Board #734 — `codex --version` with the app-server pane's exact preamble (workspace
|
|
79
|
+
* .env sourced the same way, same CODEX_HOME), run with `bash -c` like the pane, so the
|
|
80
|
+
* version probe sees the binary appserverShellCommand will run.
|
|
81
|
+
*/
|
|
82
|
+
export declare function versionProbeShellCommand(plan: ExternalAppserverPlan): string;
|
|
77
83
|
export declare function tuiShellCommand(plan: ExternalAppserverPlan): string;
|
|
78
84
|
export declare function bridgeShellCommand(plan: ExternalAppserverPlan, launch: {
|
|
79
85
|
command: string;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export declare const FORK_RECOVERY_STATE_FILE = "codex-fork-recovery.json";
|
|
2
|
+
export declare const FORK_RECOVERY_SNAPSHOT_DIR = "rollout-snapshots";
|
|
3
|
+
export interface ForkRecoveryOptions {
|
|
4
|
+
/** --fork-on-resume-failure was passed. */
|
|
5
|
+
enabled: boolean;
|
|
6
|
+
/** --yes was passed (required when there is no terminal to ask). */
|
|
7
|
+
yes: boolean;
|
|
8
|
+
/** A human can answer a prompt (stdin is a TTY). */
|
|
9
|
+
interactive: boolean;
|
|
10
|
+
/** The recorded thread this start tried to resume. */
|
|
11
|
+
threadId: string | undefined;
|
|
12
|
+
codexHome: string;
|
|
13
|
+
/** <nodes dir>/<node id> — config.json lives here. */
|
|
14
|
+
nodeDir: string;
|
|
15
|
+
/** Display name, for messages. */
|
|
16
|
+
node: string;
|
|
17
|
+
/** Ask a y/N question; resolves true only for an explicit yes. */
|
|
18
|
+
confirm: (prompt: string) => Promise<boolean>;
|
|
19
|
+
now?: () => Date;
|
|
20
|
+
log?: (line: string) => void;
|
|
21
|
+
}
|
|
22
|
+
export interface ForkMapping {
|
|
23
|
+
oldThreadId: string;
|
|
24
|
+
newThreadId: string;
|
|
25
|
+
originalRollout: string;
|
|
26
|
+
snapshot: string;
|
|
27
|
+
sha256: string;
|
|
28
|
+
at: string;
|
|
29
|
+
}
|
|
30
|
+
export declare function sha256OfFile(path: string): string;
|
|
31
|
+
/** The rollout codex named in the error (when it exists), else the shared resolver's pick. */
|
|
32
|
+
export declare function rolloutForMissingOrdinal(message: string, codexHome: string, threadId: string): string | null;
|
|
33
|
+
/** Copy (never move) the rollout into <nodeDir>/rollout-snapshots/ and drop every write bit. */
|
|
34
|
+
export declare function snapshotRollout(original: string, nodeDir: string, now: Date): {
|
|
35
|
+
path: string;
|
|
36
|
+
sha256: string;
|
|
37
|
+
};
|
|
38
|
+
export declare function recordForkMapping(nodeDir: string, entry: ForkMapping): string;
|
|
39
|
+
export declare function forkConfirmationText(node: string, threadId: string, original: string): string[];
|
|
40
|
+
/**
|
|
41
|
+
* Resume as before; on the "missing an ordinal" failure, and only with the flag and a
|
|
42
|
+
* human's yes, fork instead. `start(false)` resumes the recorded thread; `start(true)`
|
|
43
|
+
* forks it and resumes the fork. Every other outcome re-throws the original error.
|
|
44
|
+
*/
|
|
45
|
+
export declare function resumeOrForkOnMissingOrdinal<T extends {
|
|
46
|
+
threadId: string;
|
|
47
|
+
}>(start: (forkFirst: boolean) => Promise<T>, o: ForkRecoveryOptions): Promise<T>;
|
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
* not had a conversation yet (codex only writes a rollout on the first turn).
|
|
7
7
|
* It is bound to the identity marker of the generation that saw it, so a
|
|
8
8
|
* restart after a crash can carry it over to the next generation without
|
|
9
|
-
* guessing (`migrateCodexPendingThread`).
|
|
9
|
+
* guessing (`migrateCodexPendingThread`) once its exact rollout exists. A
|
|
10
|
+
* candidate acknowledged by RPC but never materialized remains pending and
|
|
11
|
+
* is dropped on the next start, even if the old marker file survived.
|
|
10
12
|
*
|
|
11
13
|
* A clean `anet node stop` reaps that generation and removes its marker, but
|
|
12
14
|
* the candidate stays in the config. Before #602 the next start then refused
|
|
@@ -47,6 +49,18 @@ export type PendingMarkerFact = {
|
|
|
47
49
|
/** Rollout files for exactly this thread id (suffix match, no prefix guessing), or `null` if the search itself failed. */
|
|
48
50
|
export type RolloutLookup = (threadId: string) => string[] | null;
|
|
49
51
|
export declare function decidePendingThreadAtStart(pending: unknown, marker: PendingMarkerFact, rollouts: RolloutLookup): PendingThreadAtStart;
|
|
52
|
+
/**
|
|
53
|
+
* Apply the decision to an in-memory node config without platform-specific
|
|
54
|
+
* shortcuts. Both launchers persist `config` before quiescing the old
|
|
55
|
+
* generation. Keeping the deletion here makes the Windows stop -> start
|
|
56
|
+
* behavior executable in the Linux Docker gate instead of relying only on a
|
|
57
|
+
* source-shape assertion (the native Windows smoke remains the end-to-end
|
|
58
|
+
* proof).
|
|
59
|
+
*/
|
|
60
|
+
export declare function reconcilePendingThreadAtStart<T extends Record<string, unknown>>(config: T, marker: PendingMarkerFact, rollouts: RolloutLookup): PendingThreadAtStart & {
|
|
61
|
+
config: T;
|
|
62
|
+
changed: boolean;
|
|
63
|
+
};
|
|
50
64
|
/**
|
|
51
65
|
* Every `*-<threadId>.jsonl` under `<codexHome>/sessions` and
|
|
52
66
|
* `<codexHome>/archived_sessions`. A missing directory is "no rollouts"; any
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { waitForStartResources, type StartGateDeps, type StartGateResult } from "./start-resource-gate";
|
|
2
|
+
/** A measured 500 MiB legacy recovery peaked at 8.4x its rollout size. Nine
|
|
3
|
+
* times the rollout leaves a small margin while remaining an explainable,
|
|
4
|
+
* testable admission estimate rather than pretending maxPayload bounds Codex. */
|
|
5
|
+
export declare const CODEX_RECOVERY_MEMORY_MULTIPLIER = 9;
|
|
6
|
+
export declare const CODEX_RECOVERY_MIN_MEMORY_MB = 4096;
|
|
7
|
+
export declare function estimatedCodexRecoveryMemoryMb(rolloutBytes: number | null): number;
|
|
8
|
+
export interface CodexRecoveryGateDeps extends StartGateDeps {
|
|
9
|
+
/** @internal seam: the shared start gate owns locking and stale-lease safety. */
|
|
10
|
+
gate?: typeof waitForStartResources;
|
|
11
|
+
}
|
|
12
|
+
/** Serialize the memory-heavy legacy resume phase and require enough effective
|
|
13
|
+
* MemAvailable for this rollout. The returned lease stays held through the
|
|
14
|
+
* launcher, bridge and TUI attachment and must then be released. */
|
|
15
|
+
export declare function waitForCodexRecoveryResources(nodeId: string, rolloutBytes: number | null, deps?: CodexRecoveryGateDeps): Promise<StartGateResult>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/** First codex release that writes paginated rollouts with per-line ordinals. */
|
|
2
|
+
export declare const PAGINATED_ROLLOUT_MIN_CODEX = "0.145.0";
|
|
3
|
+
/** Read the first line in chunks of this size … */
|
|
4
|
+
export declare const FIRST_LINE_CHUNK_BYTES: number;
|
|
5
|
+
/** … and give up (do not block) when no newline shows up within this many bytes. */
|
|
6
|
+
export declare const FIRST_LINE_MAX_BYTES: number;
|
|
7
|
+
export declare const BOARD_REF = "board #734";
|
|
8
|
+
export interface FirstLineRead {
|
|
9
|
+
/** The first line without its newline; null when it could not be read. */
|
|
10
|
+
line: string | null;
|
|
11
|
+
/** How many bytes were actually read from the file. */
|
|
12
|
+
bytesRead: number;
|
|
13
|
+
/** Why `line` is null. */
|
|
14
|
+
reason?: string;
|
|
15
|
+
}
|
|
16
|
+
/** Bounded read of the first line. Never reads past `maxBytes`. */
|
|
17
|
+
export declare function readRolloutFirstLine(path: string, maxBytes?: number, chunkBytes?: number): FirstLineRead;
|
|
18
|
+
export type HistoryModeParse = {
|
|
19
|
+
ok: true;
|
|
20
|
+
historyMode: string | null;
|
|
21
|
+
} | {
|
|
22
|
+
ok: false;
|
|
23
|
+
reason: string;
|
|
24
|
+
};
|
|
25
|
+
/** `payload.history_mode` of the session-meta line; null when the field is absent (legacy rollout). */
|
|
26
|
+
export declare function parseRolloutHistoryMode(line: string): HistoryModeParse;
|
|
27
|
+
/** <0, 0, >0 — numeric `x.y.z` compare; null when either side is not a version. */
|
|
28
|
+
export declare function compareVersions(a: string, b: string): number | null;
|
|
29
|
+
/**
|
|
30
|
+
* Version from `codex --version` output. Only a codex-identifying token counts
|
|
31
|
+
* (`codex-cli 0.159.2`, `codex 0.145.0`): a wrapper that prints its own version
|
|
32
|
+
* first (`nvm 0.39.7`) must not be read as the codex version. No match = unknown.
|
|
33
|
+
*/
|
|
34
|
+
export declare function parseCodexVersionOutput(text: string | undefined | null): string | null;
|
|
35
|
+
/** `<bin> --version` → `x.y.z`, cached per binary for the life of the process. */
|
|
36
|
+
export declare function probeCodexVersionCached(bin: string, timeoutMs?: number): string | null;
|
|
37
|
+
/**
|
|
38
|
+
* The rollout codex would resume for `threadId`, following codex's own filesystem
|
|
39
|
+
* order (codex-rs thread-store thread_rollout_resolver): `sessions/` first, newest
|
|
40
|
+
* matching file wins; `archived_sessions/` only when nothing is in `sessions/`.
|
|
41
|
+
* (codex consults its SQLite index before the filesystem; that index is not read here.)
|
|
42
|
+
* The ONE resolver every anet guard uses (co-presence launchers and agent-node).
|
|
43
|
+
*/
|
|
44
|
+
export declare function resolveCodexResumeRollout(codexHome: string, threadId: string): string | null;
|
|
45
|
+
export interface RolloutCompatInput {
|
|
46
|
+
threadId: string;
|
|
47
|
+
/** Exact rollout path, or null when the caller could not find one. */
|
|
48
|
+
rolloutPath: string | null;
|
|
49
|
+
/** How the operator would name the binary (path or command). */
|
|
50
|
+
codexBin: string;
|
|
51
|
+
/** Parsed version of `codexBin`; null/undefined = unknown. */
|
|
52
|
+
codexVersion: string | null | undefined;
|
|
53
|
+
/** How to point THIS node at another codex (one line per option). */
|
|
54
|
+
pointAtNewerCodex: string[];
|
|
55
|
+
/** Injected for tests; defaults to the bounded reader. */
|
|
56
|
+
readFirstLine?: (path: string) => FirstLineRead;
|
|
57
|
+
}
|
|
58
|
+
export type RolloutCompatVerdict = {
|
|
59
|
+
verdict: "block";
|
|
60
|
+
lines: string[];
|
|
61
|
+
historyMode: string;
|
|
62
|
+
codexVersion: string;
|
|
63
|
+
} | {
|
|
64
|
+
verdict: "allow";
|
|
65
|
+
historyMode: string | null;
|
|
66
|
+
codexVersion: string | null;
|
|
67
|
+
} | {
|
|
68
|
+
verdict: "unknown";
|
|
69
|
+
lines: string[];
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Decide whether starting `codexBin` on `threadId` is safe.
|
|
73
|
+
* block — paginated rollout + codex < 0.145: starting would make the thread unresumable.
|
|
74
|
+
* allow — legacy rollout, or codex new enough.
|
|
75
|
+
* unknown — could not tell; caller must NOT block (warn and continue as before).
|
|
76
|
+
*/
|
|
77
|
+
export declare function checkRolloutCodexCompat(input: RolloutCompatInput): RolloutCompatVerdict;
|
|
78
|
+
export declare const MISSING_ORDINAL_RE: RegExp;
|
|
79
|
+
export declare function isMissingOrdinalError(text: string): boolean;
|
|
80
|
+
/** Explanation for the upstream "missing an ordinal" resume failure; [] when `text` is something else. */
|
|
81
|
+
export declare function describeMissingOrdinalFailure(text: string, ctx?: {
|
|
82
|
+
threadId?: string;
|
|
83
|
+
rolloutPath?: string | null;
|
|
84
|
+
}): string[];
|