@sleep2agi/agent-network 2.3.0-preview.157 → 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-rollout-guard.d.ts +36 -0
- package/dist/src/codex-copresence-rpc.d.ts +4 -1
- package/dist/src/codex-external-appserver.d.ts +6 -0
- package/dist/src/codex-fork-recovery.d.ts +47 -0
- package/dist/src/codex-rollout-history-guard.d.ts +84 -0
- package/dist/src/node-server.js +8 -8
- package/dist/src/opencode-agent-node-pair.d.ts +6 -6
- package/package.json +1 -1
package/dist/src/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a0_0x5b169f=a0_0x18a4;(function(_0x38d5a0,_0x57e691){const _0x4c9090=a0_0x18a4,_0x39e1c0=_0x38d5a0();while(!![]){try{const _0xf84c56=parseInt(_0x4c9090(0xaa))/0x1+parseInt(_0x4c9090(0xba))/0x2*(-parseInt(_0x4c9090(0x105))/0x3)+parseInt(_0x4c9090(0x102))/0x4+-parseInt(_0x4c9090(0xe1))/0x5+parseInt(_0x4c9090(0x8e))/0x6*(parseInt(_0x4c9090(0xfb))/0x7)+parseInt(_0x4c9090(0xf6))/0x8*(-parseInt(_0x4c9090(0xc3))/0x9)+parseInt(_0x4c9090(0xda))/0xa;if(_0xf84c56===_0x57e691)break;else _0x39e1c0['push'](_0x39e1c0['shift']());}catch(_0x43c405){_0x39e1c0['push'](_0x39e1c0['shift']());}}}(a0_0x1a4b,0x6632c));import{EventEmitter as a0_0x29bb58}from'events';import{hostname as a0_0x10445d}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x37f079,_0x35b676)=>(_0x37f079??_0x35b676)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x5b169f(0x9b)](0x0,0xf0);function N(_0x3bc5dc){const _0xd5b3bd=a0_0x5b169f;return(_0x3bc5dc instanceof Error?_0x3bc5dc[_0xd5b3bd(0xfe)]:String(_0x3bc5dc??'unknown\x20error'))[_0xd5b3bd(0x96)](K,_0xd5b3bd(0xa4))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0xd5b3bd(0x9b)](0x0,0xf0);}function O(_0x4eb4bb,_0x1dafe2=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x2e660b=a0_0x5b169f;if(_0x1dafe2)return JSON[_0x2e660b(0x101)](_0x4eb4bb);let _0x57b269=L(_0x4eb4bb[_0x2e660b(0xcd)],_0x2e660b(0xbe)),_0x4974e1=L(_0x4eb4bb[_0x2e660b(0xb7)],_0x2e660b(0x8c)),_0x29d9fb=_0x4eb4bb[_0x2e660b(0xf5)]?'\x20error='+_0x4eb4bb[_0x2e660b(0xf5)]+':'+(_0x4eb4bb[_0x2e660b(0xd2)]??''):'';return _0x2e660b(0xb8)+_0x4eb4bb[_0x2e660b(0x8b)]+_0x2e660b(0xce)+L(_0x4eb4bb[_0x2e660b(0xa8)],_0x2e660b(0xdf))+_0x2e660b(0x91)+L(_0x4eb4bb[_0x2e660b(0xc6)],_0x2e660b(0xdf))+'\x20task_id='+_0x4974e1+_0x2e660b(0xa7)+_0x57b269+_0x2e660b(0xa1)+L(_0x4eb4bb[_0x2e660b(0x94)],_0x2e660b(0xdf))+_0x2e660b(0xb6)+_0x4eb4bb[_0x2e660b(0xa0)]+_0x2e660b(0xf3)+_0x4eb4bb[_0x2e660b(0xc1)]+_0x2e660b(0xe6)+_0x4eb4bb[_0x2e660b(0xe3)]+_0x29d9fb;}function U(_0x52e2b7){const _0x3caa05=a0_0x5b169f;return{'event':{'sending':_0x3caa05(0xaf),'delivered':_0x3caa05(0xb9),'failed':_0x3caa05(0xbc),'acked':_0x3caa05(0x92),'started':'task.started','replied':'task.replied','expired':'task.expired'}[_0x52e2b7['status']],..._0x52e2b7};}function j(_0x456c53){const _0x1f0b12=a0_0x5b169f;let _0x115613=_0x456c53?.[_0x1f0b12(0xb7)]||_0x456c53?.[_0x1f0b12(0xc4)]||_0x456c53?.['id'];if(_0x115613)return String(_0x115613);let _0x555882=_0x456c53?.[_0x1f0b12(0xef)]?.[0x0]?.[_0x1f0b12(0x89)];if(typeof _0x555882!==_0x1f0b12(0xdd))return null;try{let _0x473e56=JSON['parse'](_0x555882);return _0x473e56?.['task_id']||_0x473e56?.[_0x1f0b12(0xc4)]||_0x473e56?.['id']||null;}catch{return null;}}async function X(_0x2978fb,_0x50c3dc){const _0x56cdcb=a0_0x5b169f;let _0x208940=_0x50c3dc[_0x56cdcb(0xe8)]??Date[_0x56cdcb(0xe8)],_0x1c4939=_0x208940(),_0x46caed=(_0x4896a2,_0x45b11a,_0x4a7bc9,_0x39d9af)=>{const _0x452cc6=_0x56cdcb;_0x50c3dc['log'](O(U({'from_alias':_0x2978fb['fromAlias'],'to_alias':_0x2978fb[_0x452cc6(0xb2)],'task_id':_0x45b11a,'parent_task_id':_0x2978fb['parentTaskId'],'network_id':_0x2978fb[_0x452cc6(0xf1)],'transport':_0x2978fb[_0x452cc6(0xa0)],'status':_0x4896a2,'duration_ms':_0x208940()-_0x1c4939,'lifecycle_tracking':_0x2978fb['lifecycleTracking'],..._0x4a7bc9!==void 0x0?{'error_code':_0x39d9af||_0x452cc6(0xfc),'error_message':N(_0x4a7bc9)}:{}})));};_0x46caed(_0x56cdcb(0x88),null);try{let _0x2d88b3=await _0x50c3dc[_0x56cdcb(0x9c)](),_0x89fd21=j(_0x2d88b3);if(_0x89fd21)_0x46caed(_0x56cdcb(0xad),_0x89fd21);else{if(_0x2d88b3?.['ok']===!0x1||_0x2d88b3?.[_0x56cdcb(0xec)])_0x46caed(_0x56cdcb(0x100),_0x89fd21,_0x2d88b3?.[_0x56cdcb(0xec)]||'CommHub\x20rejected\x20task',_0x56cdcb(0x98));else _0x46caed('failed',null,_0x56cdcb(0xd4),'missing_task_id');}return _0x2d88b3;}catch(_0x2fc96f){throw _0x46caed(_0x56cdcb(0x100),null,_0x2fc96f,_0x56cdcb(0xfc)),_0x2fc96f;}}function a0_0x18a4(_0x438cde,_0x58f630){_0x438cde=_0x438cde-0x88;const _0x1a4be1=a0_0x1a4b();let _0x18a438=_0x1a4be1[_0x438cde];return _0x18a438;}async function Y(_0x28e4f5,_0x66412e){const _0x2d6832=a0_0x5b169f;return X({'fromAlias':_0x28e4f5[_0x2d6832(0xff)],'toAlias':_0x28e4f5['alias'],'parentTaskId':_0x28e4f5[_0x2d6832(0xd6)]||null,'networkId':_0x28e4f5[_0x2d6832(0xf1)]||null,'transport':'mcp_http','lifecycleTracking':_0x2d6832(0xd7)},_0x66412e);}class $ extends a0_0x29bb58{[a0_0x5b169f(0xee)];[a0_0x5b169f(0xd0)];[a0_0x5b169f(0xf4)];['agent'];[a0_0x5b169f(0xfd)];['heartbeatInterval'];[a0_0x5b169f(0xab)];[a0_0x5b169f(0xa9)];['sseAbort'];[a0_0x5b169f(0xc7)]=!0x1;constructor(_0x2054cb){const _0x2405c1=a0_0x5b169f;super();if(this[_0x2405c1(0xee)]=_0x2054cb[_0x2405c1(0xee)][_0x2405c1(0x96)](/\/$/,''),this[_0x2405c1(0xd0)]=_0x2054cb[_0x2405c1(0xd0)],this[_0x2405c1(0xf4)]=_0x2054cb[_0x2405c1(0xf4)],this[_0x2405c1(0xd5)]=_0x2054cb['agent']||_0x2405c1(0xd9),this['resumeId']=_0x2405c1(0xc2)+_0x2054cb[_0x2405c1(0xd0)]+'-'+Date[_0x2405c1(0xe8)]()[_0x2405c1(0xeb)](0x24),this[_0x2405c1(0xb0)]=_0x2054cb['heartbeatInterval']??0x2bf20,this[_0x2405c1(0xab)]=_0x2054cb[_0x2405c1(0xab)]??0xbb8,_0x2054cb[_0x2405c1(0xea)]!==!0x1)this[_0x2405c1(0x99)]();}[a0_0x5b169f(0xf8)](_0x510084){const _0x1be377=a0_0x5b169f;console[_0x1be377(0xf8)]('['+new Date()[_0x1be377(0xa2)]()['slice'](0x0,0x8)+_0x1be377(0xca)+this[_0x1be377(0xd0)]+']\x20'+_0x510084);}async[a0_0x5b169f(0x9e)](_0x340b68,_0x48b5af){const _0x4d1f4e=a0_0x5b169f;let _0x1c3e8a={'Content-Type':'application/json','Accept':_0x4d1f4e(0xb5)};if(this['token'])_0x1c3e8a[_0x4d1f4e(0xe2)]=_0x4d1f4e(0xe4)+this[_0x4d1f4e(0xf4)];let _0x22e5c0=await(await fetch(this[_0x4d1f4e(0xee)]+_0x4d1f4e(0x9a),{'method':_0x4d1f4e(0xb3),'headers':_0x1c3e8a,'body':JSON[_0x4d1f4e(0x101)]({'jsonrpc':_0x4d1f4e(0x104),'id':Date[_0x4d1f4e(0xe8)](),'method':_0x4d1f4e(0xe0),'params':{'name':_0x340b68,'arguments':_0x48b5af}})}))[_0x4d1f4e(0x89)](),_0x360a80=_0x22e5c0[_0x4d1f4e(0xdb)](/data: (.+)/),_0x550b8b=_0x360a80?JSON[_0x4d1f4e(0x90)](_0x360a80[0x1]):JSON[_0x4d1f4e(0x90)](_0x22e5c0),_0x21a369=_0x550b8b?.['result']?.[_0x4d1f4e(0xef)]?.[0x0]?.[_0x4d1f4e(0x89)];return _0x21a369?JSON[_0x4d1f4e(0x90)](_0x21a369):_0x550b8b;}async[a0_0x5b169f(0x99)](){const _0x5a4b3a=a0_0x5b169f;if(this['running'])return;this[_0x5a4b3a(0xc7)]=!0x0,await this[_0x5a4b3a(0x8b)](_0x5a4b3a(0xd3)),this['log']('registered'),this[_0x5a4b3a(0xa9)]=setInterval(()=>{const _0x29e9fc=_0x5a4b3a;this['status']('idle')[_0x29e9fc(0x97)](_0x11b33f=>this[_0x29e9fc(0xf8)](_0x29e9fc(0xa6)+_0x11b33f[_0x29e9fc(0xfe)]));},this[_0x5a4b3a(0xb0)]),this['connectSSE']();}async[a0_0x5b169f(0x9f)](){const _0x39a6b1=a0_0x5b169f;if(this['running']=!0x1,this[_0x39a6b1(0xe7)]?.['abort'](),this[_0x39a6b1(0xa9)])clearInterval(this['heartbeatTimer']);await this[_0x39a6b1(0x8b)]('offline')[_0x39a6b1(0x97)](()=>{}),this[_0x39a6b1(0xf8)](_0x39a6b1(0xf7));}async[a0_0x5b169f(0x9c)](_0xf6817b,_0x984769,_0x5e9c3c=a0_0x5b169f(0xe5)){const _0x3f94c9=a0_0x5b169f;return Y({'alias':_0xf6817b,'fromAlias':this[_0x3f94c9(0xd0)]},{'log':_0x55430e=>console['log'](_0x55430e),'send':()=>this[_0x3f94c9(0x9e)]('send_task',{'alias':_0xf6817b,'task':_0x984769,'priority':_0x5e9c3c,'from_session':this[_0x3f94c9(0xd0)]})});}async[a0_0x5b169f(0xfe)](_0x321224,_0x3a7894){const _0x11f19a=a0_0x5b169f;return this[_0x11f19a(0x9e)](_0x11f19a(0xf0),{'alias':_0x321224,'message':_0x3a7894,'from_session':this[_0x11f19a(0xd0)]});}async[a0_0x5b169f(0xbf)](_0xac5c70,_0x73a354,_0x276e11='completed'){const _0x159ffc=a0_0x5b169f;return this['call'](_0x159ffc(0xb1),{'in_reply_to':_0xac5c70,'text':_0x73a354,'status':_0x276e11});}async[a0_0x5b169f(0x8b)](_0x2769f8,_0x577516){const _0x23ef42=a0_0x5b169f;return this[_0x23ef42(0x9e)](_0x23ef42(0xd8),{'resume_id':this[_0x23ef42(0xfd)],'alias':this['alias'],'status':_0x2769f8,'server':a0_0x10445d(),'hostname':a0_0x10445d(),'agent':this['agent'],'project_dir':process[_0x23ef42(0xa3)](),..._0x577516});}async[a0_0x5b169f(0xc5)](){const _0x35acae=a0_0x5b169f;return this[_0x35acae(0x9e)](_0x35acae(0xc8),{});}async[a0_0x5b169f(0xae)](_0x5d884a,_0x43d988){const _0xe73fef=a0_0x5b169f;return this[_0xe73fef(0x9e)](_0xe73fef(0xae),{'message':_0x5d884a,'filter_server':_0x43d988?.['server'],'filter_status':_0x43d988?.[_0xe73fef(0x8b)]});}async['connectSSE'](){const _0x52cee3=a0_0x5b169f;let _0x3d1def=encodeURIComponent(this[_0x52cee3(0xd0)]),_0x122bdd=this[_0x52cee3(0xee)]+_0x52cee3(0xa5)+_0x3d1def,_0x45f912=this[_0x52cee3(0xab)];while(this[_0x52cee3(0xc7)]){try{this['sseAbort']=new AbortController();let _0xe040b3={'Accept':_0x52cee3(0xbd)};if(this[_0x52cee3(0xf4)])_0xe040b3[_0x52cee3(0xe2)]=_0x52cee3(0xe4)+this[_0x52cee3(0xf4)];let _0x3960af=await fetch(_0x122bdd,{'headers':_0xe040b3,'signal':this[_0x52cee3(0xe7)]['signal']});if(!_0x3960af['ok']||!_0x3960af['body']){this[_0x52cee3(0xf8)]('SSE\x20failed:\x20'+_0x3960af[_0x52cee3(0x8b)]),await this[_0x52cee3(0xed)](_0x45f912),_0x45f912=Math[_0x52cee3(0xc0)](_0x45f912*1.5,0xea60);continue;}_0x45f912=this['reconnectDelay'];let _0x16f19e=_0x3960af['body'][_0x52cee3(0xdc)](),_0x108973=new TextDecoder(),_0x3ba176='';while(this['running']){let {done:_0x20b93d,value:_0x2fd472}=await _0x16f19e['read']();if(_0x20b93d)break;_0x3ba176+=_0x108973[_0x52cee3(0x9d)](_0x2fd472,{'stream':!0x0});let _0x55843d=_0x3ba176[_0x52cee3(0x8a)]('\x0a');_0x3ba176=_0x55843d[_0x52cee3(0xbb)]()||'';for(let _0xbf582e of _0x55843d){if(!_0xbf582e[_0x52cee3(0x95)](_0x52cee3(0x8f)))continue;try{let _0x440d83=JSON[_0x52cee3(0x90)](_0xbf582e[_0x52cee3(0x9b)](0x6));if(_0x440d83[_0x52cee3(0xe9)]===_0x52cee3(0xb4)){this[_0x52cee3(0xf8)](_0x52cee3(0xcf)),this[_0x52cee3(0x8d)]('connected');continue;}if(_0x440d83[_0x52cee3(0xe9)]===_0x52cee3(0xcc)||_0x440d83[_0x52cee3(0xe9)]==='new_message'||_0x440d83['type']===_0x52cee3(0xae))await this[_0x52cee3(0xac)]();}catch{}}}}catch(_0x2b009d){if(_0x2b009d[_0x52cee3(0xc9)]===_0x52cee3(0x106))break;this[_0x52cee3(0x8d)]('error',_0x2b009d),this[_0x52cee3(0xf8)](_0x52cee3(0x93)+_0x2b009d[_0x52cee3(0xfe)]);}if(this[_0x52cee3(0xc7)])this['emit']('disconnected'),this['log']('SSE\x20reconnecting\x20in\x20'+_0x45f912/0x3e8+_0x52cee3(0xfa)),await this[_0x52cee3(0xed)](_0x45f912),_0x45f912=Math['min'](_0x45f912*1.5,0xea60);}}async[a0_0x5b169f(0xac)](){const _0x5660c7=a0_0x5b169f;try{let _0x2e33de=(await this[_0x5660c7(0x9e)](_0x5660c7(0xde),{'alias':this[_0x5660c7(0xd0)],'limit':0xa}))?.[_0x5660c7(0xd1)]||[];for(let _0x3326e1 of _0x2e33de)await this['call'](_0x5660c7(0xf9),{'alias':this[_0x5660c7(0xd0)],'message_id':_0x3326e1['id']}),this[_0x5660c7(0xf8)]('←\x20'+_0x3326e1[_0x5660c7(0xcb)]+':\x20'+_0x3326e1['content']['slice'](0x0,0x3c)),this[_0x5660c7(0x8d)](_0x5660c7(0xf2),_0x3326e1),this['emit'](_0x5660c7(0xfe),_0x3326e1);}catch(_0x10b265){this['log'](_0x5660c7(0x103)+_0x10b265['message']);}}[a0_0x5b169f(0xed)](_0x5b4e63){return new Promise(_0x38298d=>setTimeout(_0x38298d,_0x5b4e63));}}function a0_0x1a4b(){const _0x5e8659=['status','<pending>','emit','42wsbyLn','data:\x20','parse','\x20to=','task.ack','SSE\x20error:\x20','network_id','startsWith','replace','catch','send_rejected','connect','/mcp','slice','send','decode','call','disconnect','transport','\x20network_id=','toTimeString','cwd','[REDACTED]','/events/','heartbeat\x20failed:\x20','\x20parent_task_id=','from_alias','heartbeatTimer','587181SXCGFV','reconnectDelay','processInbox','delivered','broadcast','task.send.start','heartbeatInterval','send_reply','toAlias','POST','connected','application/json,\x20text/event-stream','\x20transport=','task_id','[commhub:task]\x20','task.send.delivered','2NfYefw','pop','task.send.failed','text/event-stream','<missing>','reply','min','duration_ms','sdk-','99666gBUGKy','message_id','getAllStatus','to_alias','running','get_all_status','name',']\x20[commhub:','from_session','new_task','parent_task_id','\x20from=','SSE\x20connected','alias','messages','error_message','idle','CommHub\x20response\x20omitted\x20task_id','agent','parentTaskId','not_tracked','report_status','sdk','4983760UfMQhd','match','getReader','string','get_inbox','<unknown>','tools/call','3158700vayWHn','Authorization','lifecycle_tracking','Bearer\x20','normal','\x20lifecycle=','sseAbort','now','type','autoConnect','toString','error','sleep','url','content','send_message','networkId','task','\x20duration_ms=','token','error_code','272dWXPfW','disconnected','log','ack_inbox','s...','35021rGOpnU','send_failed','resumeId','message','fromAlias','failed','stringify','1240900lGpFBI','inbox\x20error:\x20','2.0','11829hEwVco','AbortError','sending','text','split'];a0_0x1a4b=function(){return _0x5e8659;};return a0_0x1a4b();}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,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;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { type CodexRecoveryVerification } from "./codex-copresence-recovery";
|
|
2
2
|
export declare const SAFE_CODEX_THREAD_ID: RegExp;
|
|
3
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,
|
|
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?: {
|
|
5
7
|
webSocketCtor?: any;
|
|
6
8
|
rolloutBytes?: number | null;
|
|
9
|
+
forkFirst?: boolean;
|
|
7
10
|
}): Promise<{
|
|
8
11
|
threadId: string;
|
|
9
12
|
verification?: CodexRecoveryVerification;
|
|
@@ -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>;
|
|
@@ -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[];
|