@sleep2agi/agent-network 2.3.0-preview.145 → 2.3.0-preview.147
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-home-enforce.d.ts +17 -0
- package/dist/src/codex-pending-thread-restart.d.ts +55 -0
- package/dist/src/copresence-identity.d.ts +10 -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_0x58cada=a0_0x5441;(function(_0x1621f7,_0x58a20b){const _0x5eca70=a0_0x5441,_0x8de785=_0x1621f7();while(!![]){try{const _0x56b16d=-parseInt(_0x5eca70(0x113))/0x1+parseInt(_0x5eca70(0xe8))/0x2*(-parseInt(_0x5eca70(0xc5))/0x3)+-parseInt(_0x5eca70(0xcc))/0x4*(-parseInt(_0x5eca70(0xea))/0x5)+parseInt(_0x5eca70(0xde))/0x6+parseInt(_0x5eca70(0xb3))/0x7+-parseInt(_0x5eca70(0x10b))/0x8*(-parseInt(_0x5eca70(0xe5))/0x9)+parseInt(_0x5eca70(0x107))/0xa*(parseInt(_0x5eca70(0xd9))/0xb);if(_0x56b16d===_0x58a20b)break;else _0x8de785['push'](_0x8de785['shift']());}catch(_0x37ad15){_0x8de785['push'](_0x8de785['shift']());}}}(a0_0x1a7e,0xd78fa));import{EventEmitter as a0_0x41d38a}from'events';import{hostname as a0_0x445e88}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x445d6b,_0x482ae0)=>(_0x445d6b??_0x482ae0)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x58cada(0xf2)](0x0,0xf0);function N(_0x59f14d){const _0x1c97a3=a0_0x58cada;return(_0x59f14d instanceof Error?_0x59f14d[_0x1c97a3(0xc7)]:String(_0x59f14d??_0x1c97a3(0x10f)))[_0x1c97a3(0x10e)](K,'[REDACTED]')[_0x1c97a3(0x10e)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x329be0,_0x1f22cb=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x4e69bb=a0_0x58cada;if(_0x1f22cb)return JSON[_0x4e69bb(0xb7)](_0x329be0);let _0x39eb39=L(_0x329be0['parent_task_id'],_0x4e69bb(0xe0)),_0xac0405=L(_0x329be0[_0x4e69bb(0xee)],'<pending>'),_0x597670=_0x329be0[_0x4e69bb(0xba)]?_0x4e69bb(0xc0)+_0x329be0[_0x4e69bb(0xba)]+':'+(_0x329be0[_0x4e69bb(0x10a)]??''):'';return _0x4e69bb(0xd3)+_0x329be0[_0x4e69bb(0xc8)]+_0x4e69bb(0xff)+L(_0x329be0[_0x4e69bb(0x105)],_0x4e69bb(0x109))+'\x20to='+L(_0x329be0[_0x4e69bb(0x121)],_0x4e69bb(0x109))+'\x20task_id='+_0xac0405+_0x4e69bb(0xda)+_0x39eb39+_0x4e69bb(0x119)+L(_0x329be0[_0x4e69bb(0xb2)],_0x4e69bb(0x109))+_0x4e69bb(0xd8)+_0x329be0[_0x4e69bb(0xaf)]+'\x20duration_ms='+_0x329be0['duration_ms']+_0x4e69bb(0xb8)+_0x329be0[_0x4e69bb(0xef)]+_0x597670;}function a0_0x5441(_0x6276cd,_0x29c6ce){_0x6276cd=_0x6276cd-0xaa;const _0x1a7efc=a0_0x1a7e();let _0x544106=_0x1a7efc[_0x6276cd];return _0x544106;}function U(_0x1baf21){const _0x23bb58=a0_0x58cada;return{'event':{'sending':_0x23bb58(0xfd),'delivered':_0x23bb58(0xcf),'failed':'task.send.failed','acked':_0x23bb58(0x110),'started':'task.started','replied':_0x23bb58(0x112),'expired':_0x23bb58(0xb4)}[_0x1baf21[_0x23bb58(0xc8)]],..._0x1baf21};}function j(_0x40b313){const _0x16f836=a0_0x58cada;let _0x3a0e81=_0x40b313?.[_0x16f836(0xee)]||_0x40b313?.[_0x16f836(0xaa)]||_0x40b313?.['id'];if(_0x3a0e81)return String(_0x3a0e81);let _0x3f08d1=_0x40b313?.['content']?.[0x0]?.['text'];if(typeof _0x3f08d1!==_0x16f836(0xb5))return null;try{let _0x51df9e=JSON[_0x16f836(0xdd)](_0x3f08d1);return _0x51df9e?.[_0x16f836(0xee)]||_0x51df9e?.[_0x16f836(0xaa)]||_0x51df9e?.['id']||null;}catch{return null;}}async function X(_0x20ca9d,_0x4fd9bf){const _0x130f2f=a0_0x58cada;let _0x13d60f=_0x4fd9bf[_0x130f2f(0xab)]??Date['now'],_0x43518c=_0x13d60f(),_0x5c234b=(_0x5a0131,_0x3fa617,_0x44f866,_0x3686f1)=>{const _0x5d855a=_0x130f2f;_0x4fd9bf[_0x5d855a(0xce)](O(U({'from_alias':_0x20ca9d[_0x5d855a(0xe4)],'to_alias':_0x20ca9d[_0x5d855a(0x11c)],'task_id':_0x3fa617,'parent_task_id':_0x20ca9d[_0x5d855a(0xf4)],'network_id':_0x20ca9d[_0x5d855a(0x10c)],'transport':_0x20ca9d[_0x5d855a(0xaf)],'status':_0x5a0131,'duration_ms':_0x13d60f()-_0x43518c,'lifecycle_tracking':_0x20ca9d['lifecycleTracking'],..._0x44f866!==void 0x0?{'error_code':_0x3686f1||_0x5d855a(0xe9),'error_message':N(_0x44f866)}:{}})));};_0x5c234b(_0x130f2f(0x108),null);try{let _0x4fe6b4=await _0x4fd9bf['send'](),_0x5bc512=j(_0x4fe6b4);if(_0x5bc512)_0x5c234b(_0x130f2f(0x100),_0x5bc512);else{if(_0x4fe6b4?.['ok']===!0x1||_0x4fe6b4?.['error'])_0x5c234b(_0x130f2f(0xe6),_0x5bc512,_0x4fe6b4?.[_0x130f2f(0x10d)]||'CommHub\x20rejected\x20task',_0x130f2f(0xed));else _0x5c234b(_0x130f2f(0xe6),null,'CommHub\x20response\x20omitted\x20task_id','missing_task_id');}return _0x4fe6b4;}catch(_0x466678){throw _0x5c234b(_0x130f2f(0xe6),null,_0x466678,_0x130f2f(0xe9)),_0x466678;}}function a0_0x1a7e(){const _0x7db67e=['sending','<unknown>','error_message','88qHcjhM','networkId','error','replace','unknown\x20error','task.ack','not_tracked','task.replied','275349sTVelv','/mcp','reconnectDelay','connect','SSE\x20failed:\x20','task','\x20network_id=','from_session','get_all_status','toAlias','running','tools/call','/events/','min','to_alias','agent','SSE\x20connected','sleep','processInbox','message_id','now','cwd','abort','broadcast','transport','toTimeString',']\x20[commhub:','network_id','6177500VwKHeL','task.expired','string','heartbeatTimer','stringify','\x20lifecycle=','token','error_code','sseAbort','AbortError','completed','mcp_http','new_task','\x20error=','url','offline','text','getAllStatus','6OtWIdv','get_inbox','message','status','pop','SSE\x20error:\x20','name','28rnKNRi','new_message','log','task.send.delivered','reply','signal','send','[commhub:task]\x20','application/json,\x20text/event-stream','toString','heartbeat\x20failed:\x20','send_reply','\x20transport=','197131ONcoZT','\x20parent_task_id=','startsWith','decode','parse','27342FnWNbB','catch','<missing>','Authorization','application/json','call','fromAlias','243162DAYGgD','failed','emit','847134oXhfWT','send_failed','548145CKLiKh','Bearer\x20','send_message','send_rejected','task_id','lifecycle_tracking','alias','content','slice','match','parentTaskId','resumeId','normal','inbox\x20error:\x20','s...','connectSSE','type','disconnected','text/event-stream','task.send.start','idle','\x20from=','delivered','read','POST','body','heartbeatInterval','from_alias','sdk-','30uhNRTI'];a0_0x1a7e=function(){return _0x7db67e;};return a0_0x1a7e();}async function Y(_0x40eac0,_0x5c5897){const _0x3cd2d8=a0_0x58cada;return X({'fromAlias':_0x40eac0[_0x3cd2d8(0xe4)],'toAlias':_0x40eac0[_0x3cd2d8(0xf0)],'parentTaskId':_0x40eac0[_0x3cd2d8(0xf4)]||null,'networkId':_0x40eac0['networkId']||null,'transport':_0x3cd2d8(0xbe),'lifecycleTracking':_0x3cd2d8(0x111)},_0x5c5897);}class $ extends a0_0x41d38a{['url'];['alias'];['token'];[a0_0x58cada(0x122)];['resumeId'];['heartbeatInterval'];[a0_0x58cada(0x115)];[a0_0x58cada(0xb6)];['sseAbort'];['running']=!0x1;constructor(_0x5d6564){const _0xb9c95f=a0_0x58cada;super();if(this[_0xb9c95f(0xc1)]=_0x5d6564[_0xb9c95f(0xc1)][_0xb9c95f(0x10e)](/\/$/,''),this[_0xb9c95f(0xf0)]=_0x5d6564[_0xb9c95f(0xf0)],this[_0xb9c95f(0xb9)]=_0x5d6564[_0xb9c95f(0xb9)],this[_0xb9c95f(0x122)]=_0x5d6564[_0xb9c95f(0x122)]||'sdk',this[_0xb9c95f(0xf5)]=_0xb9c95f(0x106)+_0x5d6564['alias']+'-'+Date['now']()[_0xb9c95f(0xd5)](0x24),this[_0xb9c95f(0x104)]=_0x5d6564['heartbeatInterval']??0x2bf20,this['reconnectDelay']=_0x5d6564[_0xb9c95f(0x115)]??0xbb8,_0x5d6564['autoConnect']!==!0x1)this[_0xb9c95f(0x116)]();}[a0_0x58cada(0xce)](_0x2716bb){const _0x29af49=a0_0x58cada;console[_0x29af49(0xce)]('['+new Date()[_0x29af49(0xb0)]()[_0x29af49(0xf2)](0x0,0x8)+_0x29af49(0xb1)+this[_0x29af49(0xf0)]+']\x20'+_0x2716bb);}async[a0_0x58cada(0xe3)](_0x519204,_0x3acee8){const _0x3d0207=a0_0x58cada;let _0x127361={'Content-Type':_0x3d0207(0xe2),'Accept':_0x3d0207(0xd4)};if(this[_0x3d0207(0xb9)])_0x127361['Authorization']=_0x3d0207(0xeb)+this[_0x3d0207(0xb9)];let _0x200a36=await(await fetch(this[_0x3d0207(0xc1)]+_0x3d0207(0x114),{'method':_0x3d0207(0x102),'headers':_0x127361,'body':JSON[_0x3d0207(0xb7)]({'jsonrpc':'2.0','id':Date[_0x3d0207(0xab)](),'method':_0x3d0207(0x11e),'params':{'name':_0x519204,'arguments':_0x3acee8}})}))[_0x3d0207(0xc3)](),_0x531884=_0x200a36[_0x3d0207(0xf3)](/data: (.+)/),_0x56e0bf=_0x531884?JSON[_0x3d0207(0xdd)](_0x531884[0x1]):JSON[_0x3d0207(0xdd)](_0x200a36),_0x2b09de=_0x56e0bf?.['result']?.[_0x3d0207(0xf1)]?.[0x0]?.['text'];return _0x2b09de?JSON[_0x3d0207(0xdd)](_0x2b09de):_0x56e0bf;}async[a0_0x58cada(0x116)](){const _0x351691=a0_0x58cada;if(this['running'])return;this[_0x351691(0x11d)]=!0x0,await this[_0x351691(0xc8)]('idle'),this[_0x351691(0xce)]('registered'),this[_0x351691(0xb6)]=setInterval(()=>{const _0x19e8ca=_0x351691;this[_0x19e8ca(0xc8)](_0x19e8ca(0xfe))[_0x19e8ca(0xdf)](_0x29bc09=>this['log'](_0x19e8ca(0xd6)+_0x29bc09[_0x19e8ca(0xc7)]));},this['heartbeatInterval']),this['connectSSE']();}async['disconnect'](){const _0x306ec7=a0_0x58cada;if(this[_0x306ec7(0x11d)]=!0x1,this[_0x306ec7(0xbb)]?.[_0x306ec7(0xad)](),this[_0x306ec7(0xb6)])clearInterval(this[_0x306ec7(0xb6)]);await this[_0x306ec7(0xc8)](_0x306ec7(0xc2))[_0x306ec7(0xdf)](()=>{}),this['log'](_0x306ec7(0xfb));}async[a0_0x58cada(0xd2)](_0x2cc332,_0x2ab31b,_0x44fd9d=a0_0x58cada(0xf6)){const _0x1b5c24=a0_0x58cada;return Y({'alias':_0x2cc332,'fromAlias':this[_0x1b5c24(0xf0)]},{'log':_0x346181=>console[_0x1b5c24(0xce)](_0x346181),'send':()=>this[_0x1b5c24(0xe3)]('send_task',{'alias':_0x2cc332,'task':_0x2ab31b,'priority':_0x44fd9d,'from_session':this['alias']})});}async[a0_0x58cada(0xc7)](_0x212e7b,_0x35ce52){const _0x87f5d8=a0_0x58cada;return this[_0x87f5d8(0xe3)](_0x87f5d8(0xec),{'alias':_0x212e7b,'message':_0x35ce52,'from_session':this[_0x87f5d8(0xf0)]});}async[a0_0x58cada(0xd0)](_0x34a35a,_0x286803,_0x29ed3f=a0_0x58cada(0xbd)){const _0x540d4e=a0_0x58cada;return this[_0x540d4e(0xe3)](_0x540d4e(0xd7),{'in_reply_to':_0x34a35a,'text':_0x286803,'status':_0x29ed3f});}async[a0_0x58cada(0xc8)](_0x1ded28,_0x33f4d7){const _0x90de94=a0_0x58cada;return this[_0x90de94(0xe3)]('report_status',{'resume_id':this[_0x90de94(0xf5)],'alias':this['alias'],'status':_0x1ded28,'server':a0_0x445e88(),'hostname':a0_0x445e88(),'agent':this[_0x90de94(0x122)],'project_dir':process[_0x90de94(0xac)](),..._0x33f4d7});}async[a0_0x58cada(0xc4)](){const _0x14e4b5=a0_0x58cada;return this[_0x14e4b5(0xe3)](_0x14e4b5(0x11b),{});}async[a0_0x58cada(0xae)](_0x53469c,_0x3b8ac4){const _0x25f02b=a0_0x58cada;return this[_0x25f02b(0xe3)](_0x25f02b(0xae),{'message':_0x53469c,'filter_server':_0x3b8ac4?.['server'],'filter_status':_0x3b8ac4?.[_0x25f02b(0xc8)]});}async[a0_0x58cada(0xf9)](){const _0x29d8da=a0_0x58cada;let _0x1597f9=encodeURIComponent(this[_0x29d8da(0xf0)]),_0x2c73d6=this[_0x29d8da(0xc1)]+_0x29d8da(0x11f)+_0x1597f9,_0x137ca3=this['reconnectDelay'];while(this[_0x29d8da(0x11d)]){try{this[_0x29d8da(0xbb)]=new AbortController();let _0x4daa38={'Accept':_0x29d8da(0xfc)};if(this[_0x29d8da(0xb9)])_0x4daa38[_0x29d8da(0xe1)]=_0x29d8da(0xeb)+this['token'];let _0x31e4c7=await fetch(_0x2c73d6,{'headers':_0x4daa38,'signal':this['sseAbort'][_0x29d8da(0xd1)]});if(!_0x31e4c7['ok']||!_0x31e4c7[_0x29d8da(0x103)]){this[_0x29d8da(0xce)](_0x29d8da(0x117)+_0x31e4c7['status']),await this[_0x29d8da(0x124)](_0x137ca3),_0x137ca3=Math['min'](_0x137ca3*1.5,0xea60);continue;}_0x137ca3=this[_0x29d8da(0x115)];let _0x2b66e1=_0x31e4c7[_0x29d8da(0x103)]['getReader'](),_0x42293d=new TextDecoder(),_0x45cc6f='';while(this[_0x29d8da(0x11d)]){let {done:_0x140de3,value:_0x5b147d}=await _0x2b66e1[_0x29d8da(0x101)]();if(_0x140de3)break;_0x45cc6f+=_0x42293d[_0x29d8da(0xdc)](_0x5b147d,{'stream':!0x0});let _0x174d6c=_0x45cc6f['split']('\x0a');_0x45cc6f=_0x174d6c[_0x29d8da(0xc9)]()||'';for(let _0x359513 of _0x174d6c){if(!_0x359513[_0x29d8da(0xdb)]('data:\x20'))continue;try{let _0x3b3abf=JSON[_0x29d8da(0xdd)](_0x359513[_0x29d8da(0xf2)](0x6));if(_0x3b3abf[_0x29d8da(0xfa)]==='connected'){this[_0x29d8da(0xce)](_0x29d8da(0x123)),this[_0x29d8da(0xe7)]('connected');continue;}if(_0x3b3abf[_0x29d8da(0xfa)]===_0x29d8da(0xbf)||_0x3b3abf[_0x29d8da(0xfa)]===_0x29d8da(0xcd)||_0x3b3abf[_0x29d8da(0xfa)]===_0x29d8da(0xae))await this[_0x29d8da(0x125)]();}catch{}}}}catch(_0x538694){if(_0x538694[_0x29d8da(0xcb)]===_0x29d8da(0xbc))break;this['emit'](_0x29d8da(0x10d),_0x538694),this[_0x29d8da(0xce)](_0x29d8da(0xca)+_0x538694[_0x29d8da(0xc7)]);}if(this[_0x29d8da(0x11d)])this[_0x29d8da(0xe7)]('disconnected'),this[_0x29d8da(0xce)]('SSE\x20reconnecting\x20in\x20'+_0x137ca3/0x3e8+_0x29d8da(0xf8)),await this[_0x29d8da(0x124)](_0x137ca3),_0x137ca3=Math[_0x29d8da(0x120)](_0x137ca3*1.5,0xea60);}}async[a0_0x58cada(0x125)](){const _0x1544e7=a0_0x58cada;try{let _0x55242b=(await this[_0x1544e7(0xe3)](_0x1544e7(0xc6),{'alias':this[_0x1544e7(0xf0)],'limit':0xa}))?.['messages']||[];for(let _0x318901 of _0x55242b)await this[_0x1544e7(0xe3)]('ack_inbox',{'alias':this[_0x1544e7(0xf0)],'message_id':_0x318901['id']}),this[_0x1544e7(0xce)]('←\x20'+_0x318901[_0x1544e7(0x11a)]+':\x20'+_0x318901[_0x1544e7(0xf1)][_0x1544e7(0xf2)](0x0,0x3c)),this[_0x1544e7(0xe7)](_0x1544e7(0x118),_0x318901),this['emit'](_0x1544e7(0xc7),_0x318901);}catch(_0x14fd7e){this[_0x1544e7(0xce)](_0x1544e7(0xf7)+_0x14fd7e[_0x1544e7(0xc7)]);}}['sleep'](_0x4f8ea6){return new Promise(_0x49516e=>setTimeout(_0x49516e,_0x4f8ea6));}}var F=$;export{F as default,$ as CommHub};
|
|
1
|
+
const a0_0x7b615a=a0_0x3f71;(function(_0x279cc0,_0x2943d8){const _0x1fe3cb=a0_0x3f71,_0x384e4f=_0x279cc0();while(!![]){try{const _0x3e227f=parseInt(_0x1fe3cb(0x180))/0x1+-parseInt(_0x1fe3cb(0x17e))/0x2+-parseInt(_0x1fe3cb(0x192))/0x3+-parseInt(_0x1fe3cb(0x166))/0x4*(parseInt(_0x1fe3cb(0x1b6))/0x5)+parseInt(_0x1fe3cb(0x1b3))/0x6*(parseInt(_0x1fe3cb(0x14c))/0x7)+parseInt(_0x1fe3cb(0x174))/0x8+parseInt(_0x1fe3cb(0x15e))/0x9;if(_0x3e227f===_0x2943d8)break;else _0x384e4f['push'](_0x384e4f['shift']());}catch(_0x532fa2){_0x384e4f['push'](_0x384e4f['shift']());}}}(a0_0x5e76,0xa03ac));import{EventEmitter as a0_0x34fd85}from'events';function a0_0x3f71(_0x425a81,_0x5a6370){_0x425a81=_0x425a81-0x13f;const _0x5e7646=a0_0x5e76();let _0x3f71af=_0x5e7646[_0x425a81];return _0x3f71af;}import{hostname as a0_0x3316f4}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x2dd3c0,_0x28771c)=>(_0x2dd3c0??_0x28771c)[a0_0x7b615a(0x189)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x7b615a(0x149)](0x0,0xf0);function N(_0x989486){const _0x22e230=a0_0x7b615a;return(_0x989486 instanceof Error?_0x989486['message']:String(_0x989486??_0x22e230(0x141)))[_0x22e230(0x189)](K,'[REDACTED]')['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x213627,_0x482cd0=process.env.ANET_TASK_TRACE_FORMAT===a0_0x7b615a(0x163)){const _0x6da51d=a0_0x7b615a;if(_0x482cd0)return JSON[_0x6da51d(0x151)](_0x213627);let _0x3cee82=L(_0x213627[_0x6da51d(0x1a9)],_0x6da51d(0x186)),_0x2c546f=L(_0x213627[_0x6da51d(0x1af)],_0x6da51d(0x17d)),_0x3bdb51=_0x213627[_0x6da51d(0x178)]?_0x6da51d(0x16e)+_0x213627[_0x6da51d(0x178)]+':'+(_0x213627['error_message']??''):'';return _0x6da51d(0x187)+_0x213627[_0x6da51d(0x168)]+'\x20from='+L(_0x213627[_0x6da51d(0x199)],_0x6da51d(0x1a5))+_0x6da51d(0x196)+L(_0x213627[_0x6da51d(0x182)],_0x6da51d(0x1a5))+_0x6da51d(0x148)+_0x2c546f+_0x6da51d(0x17f)+_0x3cee82+_0x6da51d(0x16d)+L(_0x213627['network_id'],_0x6da51d(0x1a5))+_0x6da51d(0x195)+_0x213627[_0x6da51d(0x1ab)]+_0x6da51d(0x15f)+_0x213627[_0x6da51d(0x164)]+'\x20lifecycle='+_0x213627['lifecycle_tracking']+_0x3bdb51;}function U(_0x1f10aa){const _0x55db07=a0_0x7b615a;return{'event':{'sending':'task.send.start','delivered':_0x55db07(0x1b4),'failed':'task.send.failed','acked':_0x55db07(0x15d),'started':'task.started','replied':_0x55db07(0x153),'expired':_0x55db07(0x183)}[_0x1f10aa[_0x55db07(0x168)]],..._0x1f10aa};}function j(_0x23203a){const _0x3967f6=a0_0x7b615a;let _0x3ac53b=_0x23203a?.[_0x3967f6(0x1af)]||_0x23203a?.[_0x3967f6(0x173)]||_0x23203a?.['id'];if(_0x3ac53b)return String(_0x3ac53b);let _0x18c495=_0x23203a?.[_0x3967f6(0x155)]?.[0x0]?.[_0x3967f6(0x18c)];if(typeof _0x18c495!==_0x3967f6(0x14f))return null;try{let _0xf7a058=JSON[_0x3967f6(0x142)](_0x18c495);return _0xf7a058?.[_0x3967f6(0x1af)]||_0xf7a058?.[_0x3967f6(0x173)]||_0xf7a058?.['id']||null;}catch{return null;}}async function X(_0xf65000,_0x3b420d){const _0x2c606f=a0_0x7b615a;let _0x6df729=_0x3b420d['now']??Date[_0x2c606f(0x185)],_0x5b83cd=_0x6df729(),_0x43bb45=(_0x9f72c7,_0x22c946,_0x2f2a89,_0x110017)=>{const _0x35cb4f=_0x2c606f;_0x3b420d[_0x35cb4f(0x16a)](O(U({'from_alias':_0xf65000[_0x35cb4f(0x14d)],'to_alias':_0xf65000['toAlias'],'task_id':_0x22c946,'parent_task_id':_0xf65000['parentTaskId'],'network_id':_0xf65000[_0x35cb4f(0x165)],'transport':_0xf65000[_0x35cb4f(0x1ab)],'status':_0x9f72c7,'duration_ms':_0x6df729()-_0x5b83cd,'lifecycle_tracking':_0xf65000[_0x35cb4f(0x17a)],..._0x2f2a89!==void 0x0?{'error_code':_0x110017||'send_failed','error_message':N(_0x2f2a89)}:{}})));};_0x43bb45(_0x2c606f(0x17c),null);try{let _0x1535df=await _0x3b420d[_0x2c606f(0x1b9)](),_0x22ae3b=j(_0x1535df);if(_0x22ae3b)_0x43bb45(_0x2c606f(0x14b),_0x22ae3b);else{if(_0x1535df?.['ok']===!0x1||_0x1535df?.[_0x2c606f(0x171)])_0x43bb45(_0x2c606f(0x193),_0x22ae3b,_0x1535df?.['error']||_0x2c606f(0x14e),'send_rejected');else _0x43bb45(_0x2c606f(0x193),null,_0x2c606f(0x160),_0x2c606f(0x191));}return _0x1535df;}catch(_0x4f8bc2){throw _0x43bb45('failed',null,_0x4f8bc2,_0x2c606f(0x18e)),_0x4f8bc2;}}async function Y(_0x4ee913,_0x3718f2){const _0x34d4d3=a0_0x7b615a;return X({'fromAlias':_0x4ee913[_0x34d4d3(0x14d)],'toAlias':_0x4ee913[_0x34d4d3(0x172)],'parentTaskId':_0x4ee913['parentTaskId']||null,'networkId':_0x4ee913[_0x34d4d3(0x165)]||null,'transport':'mcp_http','lifecycleTracking':_0x34d4d3(0x176)},_0x3718f2);}class $ extends a0_0x34fd85{[a0_0x7b615a(0x184)];[a0_0x7b615a(0x172)];[a0_0x7b615a(0x19b)];[a0_0x7b615a(0x1ae)];[a0_0x7b615a(0x1a1)];[a0_0x7b615a(0x1b1)];[a0_0x7b615a(0x13f)];[a0_0x7b615a(0x1a2)];['sseAbort'];[a0_0x7b615a(0x143)]=!0x1;constructor(_0x443a96){const _0x18b7a2=a0_0x7b615a;super();if(this[_0x18b7a2(0x184)]=_0x443a96[_0x18b7a2(0x184)][_0x18b7a2(0x189)](/\/$/,''),this[_0x18b7a2(0x172)]=_0x443a96[_0x18b7a2(0x172)],this['token']=_0x443a96[_0x18b7a2(0x19b)],this[_0x18b7a2(0x1ae)]=_0x443a96[_0x18b7a2(0x1ae)]||_0x18b7a2(0x1b0),this[_0x18b7a2(0x1a1)]=_0x18b7a2(0x18d)+_0x443a96[_0x18b7a2(0x172)]+'-'+Date[_0x18b7a2(0x185)]()['toString'](0x24),this[_0x18b7a2(0x1b1)]=_0x443a96[_0x18b7a2(0x1b1)]??0x2bf20,this[_0x18b7a2(0x13f)]=_0x443a96[_0x18b7a2(0x13f)]??0xbb8,_0x443a96[_0x18b7a2(0x15b)]!==!0x1)this['connect']();}[a0_0x7b615a(0x16a)](_0x37def9){const _0x150891=a0_0x7b615a;console[_0x150891(0x16a)]('['+new Date()[_0x150891(0x1a7)]()[_0x150891(0x149)](0x0,0x8)+_0x150891(0x177)+this[_0x150891(0x172)]+']\x20'+_0x37def9);}async[a0_0x7b615a(0x15a)](_0x456d8a,_0x17037c){const _0x41916e=a0_0x7b615a;let _0x1644d0={'Content-Type':_0x41916e(0x146),'Accept':_0x41916e(0x19e)};if(this[_0x41916e(0x19b)])_0x1644d0[_0x41916e(0x188)]=_0x41916e(0x152)+this[_0x41916e(0x19b)];let _0x1ba7a=await(await fetch(this[_0x41916e(0x184)]+_0x41916e(0x147),{'method':_0x41916e(0x16c),'headers':_0x1644d0,'body':JSON[_0x41916e(0x151)]({'jsonrpc':_0x41916e(0x18b),'id':Date[_0x41916e(0x185)](),'method':_0x41916e(0x150),'params':{'name':_0x456d8a,'arguments':_0x17037c}})}))[_0x41916e(0x18c)](),_0x28de83=_0x1ba7a['match'](/data: (.+)/),_0x9655aa=_0x28de83?JSON['parse'](_0x28de83[0x1]):JSON[_0x41916e(0x142)](_0x1ba7a),_0xa8ad6c=_0x9655aa?.[_0x41916e(0x1b2)]?.[_0x41916e(0x155)]?.[0x0]?.['text'];return _0xa8ad6c?JSON[_0x41916e(0x142)](_0xa8ad6c):_0x9655aa;}async[a0_0x7b615a(0x19c)](){const _0x593cbc=a0_0x7b615a;if(this[_0x593cbc(0x143)])return;this[_0x593cbc(0x143)]=!0x0,await this[_0x593cbc(0x168)]('idle'),this['log'](_0x593cbc(0x1a3)),this[_0x593cbc(0x1a2)]=setInterval(()=>{const _0x377545=_0x593cbc;this[_0x377545(0x168)](_0x377545(0x169))[_0x377545(0x190)](_0x18fd7a=>this[_0x377545(0x16a)](_0x377545(0x197)+_0x18fd7a[_0x377545(0x15c)]));},this['heartbeatInterval']),this[_0x593cbc(0x157)]();}async[a0_0x7b615a(0x19d)](){const _0x9fd0de=a0_0x7b615a;if(this[_0x9fd0de(0x143)]=!0x1,this[_0x9fd0de(0x194)]?.['abort'](),this[_0x9fd0de(0x1a2)])clearInterval(this[_0x9fd0de(0x1a2)]);await this[_0x9fd0de(0x168)](_0x9fd0de(0x1a0))[_0x9fd0de(0x190)](()=>{}),this[_0x9fd0de(0x16a)]('disconnected');}async['send'](_0x6f3813,_0x48e8ad,_0x8bb00f='normal'){const _0x124800=a0_0x7b615a;return Y({'alias':_0x6f3813,'fromAlias':this[_0x124800(0x172)]},{'log':_0x16490d=>console[_0x124800(0x16a)](_0x16490d),'send':()=>this[_0x124800(0x15a)](_0x124800(0x16b),{'alias':_0x6f3813,'task':_0x48e8ad,'priority':_0x8bb00f,'from_session':this[_0x124800(0x172)]})});}async[a0_0x7b615a(0x15c)](_0x3db8fa,_0x13b7c4){const _0x20c1d7=a0_0x7b615a;return this[_0x20c1d7(0x15a)]('send_message',{'alias':_0x3db8fa,'message':_0x13b7c4,'from_session':this[_0x20c1d7(0x172)]});}async[a0_0x7b615a(0x175)](_0x7e14a6,_0x15518a,_0x38f166=a0_0x7b615a(0x1ac)){const _0x5299b5=a0_0x7b615a;return this[_0x5299b5(0x15a)](_0x5299b5(0x1a6),{'in_reply_to':_0x7e14a6,'text':_0x15518a,'status':_0x38f166});}async[a0_0x7b615a(0x168)](_0x10abe7,_0x22dd72){const _0x4a61be=a0_0x7b615a;return this[_0x4a61be(0x15a)]('report_status',{'resume_id':this[_0x4a61be(0x1a1)],'alias':this[_0x4a61be(0x172)],'status':_0x10abe7,'server':a0_0x3316f4(),'hostname':a0_0x3316f4(),'agent':this[_0x4a61be(0x1ae)],'project_dir':process[_0x4a61be(0x179)](),..._0x22dd72});}async['getAllStatus'](){const _0x4374e0=a0_0x7b615a;return this[_0x4374e0(0x15a)](_0x4374e0(0x1a8),{});}async[a0_0x7b615a(0x1b8)](_0x427a8b,_0x1a6530){const _0x2c54e8=a0_0x7b615a;return this[_0x2c54e8(0x15a)]('broadcast',{'message':_0x427a8b,'filter_server':_0x1a6530?.[_0x2c54e8(0x140)],'filter_status':_0x1a6530?.[_0x2c54e8(0x168)]});}async['connectSSE'](){const _0x5ba107=a0_0x7b615a;let _0xfda958=encodeURIComponent(this[_0x5ba107(0x172)]),_0x16fd23=this[_0x5ba107(0x184)]+_0x5ba107(0x158)+_0xfda958,_0x198f8c=this[_0x5ba107(0x13f)];while(this[_0x5ba107(0x143)]){try{this[_0x5ba107(0x194)]=new AbortController();let _0x2e1d07={'Accept':'text/event-stream'};if(this[_0x5ba107(0x19b)])_0x2e1d07[_0x5ba107(0x188)]=_0x5ba107(0x152)+this[_0x5ba107(0x19b)];let _0x1a39b5=await fetch(_0x16fd23,{'headers':_0x2e1d07,'signal':this[_0x5ba107(0x194)][_0x5ba107(0x145)]});if(!_0x1a39b5['ok']||!_0x1a39b5[_0x5ba107(0x19a)]){this[_0x5ba107(0x16a)](_0x5ba107(0x17b)+_0x1a39b5[_0x5ba107(0x168)]),await this['sleep'](_0x198f8c),_0x198f8c=Math[_0x5ba107(0x161)](_0x198f8c*1.5,0xea60);continue;}_0x198f8c=this['reconnectDelay'];let _0x53f190=_0x1a39b5[_0x5ba107(0x19a)]['getReader'](),_0x4f7031=new TextDecoder(),_0x503b9d='';while(this[_0x5ba107(0x143)]){let {done:_0x8b062a,value:_0x513b5c}=await _0x53f190[_0x5ba107(0x154)]();if(_0x8b062a)break;_0x503b9d+=_0x4f7031[_0x5ba107(0x1a4)](_0x513b5c,{'stream':!0x0});let _0x389651=_0x503b9d[_0x5ba107(0x156)]('\x0a');_0x503b9d=_0x389651[_0x5ba107(0x14a)]()||'';for(let _0x250744 of _0x389651){if(!_0x250744[_0x5ba107(0x1b7)](_0x5ba107(0x1b5)))continue;try{let _0x3b0a6f=JSON[_0x5ba107(0x142)](_0x250744['slice'](0x6));if(_0x3b0a6f[_0x5ba107(0x144)]==='connected'){this['log'](_0x5ba107(0x16f)),this['emit']('connected');continue;}if(_0x3b0a6f[_0x5ba107(0x144)]===_0x5ba107(0x1ad)||_0x3b0a6f[_0x5ba107(0x144)]===_0x5ba107(0x18a)||_0x3b0a6f[_0x5ba107(0x144)]===_0x5ba107(0x1b8))await this[_0x5ba107(0x181)]();}catch{}}}}catch(_0x5de10a){if(_0x5de10a['name']===_0x5ba107(0x159))break;this[_0x5ba107(0x167)](_0x5ba107(0x171),_0x5de10a),this[_0x5ba107(0x16a)](_0x5ba107(0x162)+_0x5de10a[_0x5ba107(0x15c)]);}if(this[_0x5ba107(0x143)])this[_0x5ba107(0x167)]('disconnected'),this[_0x5ba107(0x16a)](_0x5ba107(0x1aa)+_0x198f8c/0x3e8+'s...'),await this['sleep'](_0x198f8c),_0x198f8c=Math['min'](_0x198f8c*1.5,0xea60);}}async[a0_0x7b615a(0x181)](){const _0xf022f6=a0_0x7b615a;try{let _0x2e8c34=(await this[_0xf022f6(0x15a)](_0xf022f6(0x18f),{'alias':this[_0xf022f6(0x172)],'limit':0xa}))?.[_0xf022f6(0x19f)]||[];for(let _0x11aa22 of _0x2e8c34)await this['call']('ack_inbox',{'alias':this[_0xf022f6(0x172)],'message_id':_0x11aa22['id']}),this['log']('←\x20'+_0x11aa22['from_session']+':\x20'+_0x11aa22['content'][_0xf022f6(0x149)](0x0,0x3c)),this['emit'](_0xf022f6(0x198),_0x11aa22),this[_0xf022f6(0x167)](_0xf022f6(0x15c),_0x11aa22);}catch(_0x38a37b){this['log'](_0xf022f6(0x170)+_0x38a37b[_0xf022f6(0x15c)]);}}['sleep'](_0x52b2c4){return new Promise(_0x1f6874=>setTimeout(_0x1f6874,_0x52b2c4));}}function a0_0x5e76(){const _0x3249a7=['pop','delivered','42PTtSZi','fromAlias','CommHub\x20rejected\x20task','string','tools/call','stringify','Bearer\x20','task.replied','read','content','split','connectSSE','/events/','AbortError','call','autoConnect','message','task.ack','16825527pENtBO','\x20duration_ms=','CommHub\x20response\x20omitted\x20task_id','min','SSE\x20error:\x20','json','duration_ms','networkId','196GiDgXQ','emit','status','idle','log','send_task','POST','\x20network_id=','\x20error=','SSE\x20connected','inbox\x20error:\x20','error','alias','message_id','526928zigswR','reply','not_tracked',']\x20[commhub:','error_code','cwd','lifecycleTracking','SSE\x20failed:\x20','sending','<pending>','742938knCBzh','\x20parent_task_id=','170761YeXxQN','processInbox','to_alias','task.expired','url','now','<missing>','[commhub:task]\x20','Authorization','replace','new_message','2.0','text','sdk-','send_failed','get_inbox','catch','missing_task_id','3430212CwdLtT','failed','sseAbort','\x20transport=','\x20to=','heartbeat\x20failed:\x20','task','from_alias','body','token','connect','disconnect','application/json,\x20text/event-stream','messages','offline','resumeId','heartbeatTimer','registered','decode','<unknown>','send_reply','toTimeString','get_all_status','parent_task_id','SSE\x20reconnecting\x20in\x20','transport','completed','new_task','agent','task_id','sdk','heartbeatInterval','result','295098roofIx','task.send.delivered','data:\x20','23475yMJFdq','startsWith','broadcast','send','reconnectDelay','server','unknown\x20error','parse','running','type','signal','application/json','/mcp','\x20task_id=','slice'];a0_0x5e76=function(){return _0x3249a7;};return a0_0x5e76();}var F=$;export{F as default,$ as CommHub};
|
|
@@ -40,6 +40,23 @@ export interface ProcReader {
|
|
|
40
40
|
/** 所有进程的 [pid, ppid];读不到返回 []。 */
|
|
41
41
|
parents(): Array<[number, number]>;
|
|
42
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* 一个 /proc 里的 NUL 分隔块(environ / cmdline)的**原始字节** → JS 字符串,逐条按 UTF-8 解码。
|
|
45
|
+
*
|
|
46
|
+
* 🔴 #448 回归:曾经是 `readFileSync(…, "latin1")`,每个字节变成一个 U+00xx。期望值是 JS 字符串
|
|
47
|
+
* (UTF-8 路径解码来的),于是**任何非 ASCII 路径**(如 `.anet/nodes/测试节点/codex-home`)
|
|
48
|
+
* 读出来都是 `æµè¯…` 这种乱码、永远不相等 → fail closed → 该节点每个任务都被拒。
|
|
49
|
+
*
|
|
50
|
+
* 某一条不是合法 UTF-8 时,不做有损替换(U+FFFD 可能碰巧和期望值里的 U+FFFD 相等):
|
|
51
|
+
* 把 `=` 之后的部分换成 INVALID_UTF8_MARK + 原字节的 latin1 —— 以一个孤立代理项开头,
|
|
52
|
+
* 而合法 UTF-8 解码出来的字符串绝不含孤立代理项,所以它**不可能**等于任何真实路径(fail closed)。
|
|
53
|
+
*/
|
|
54
|
+
export declare const INVALID_UTF8_MARK = "\uDFFF";
|
|
55
|
+
export declare function decodeProcNulBlock(bytes: Uint8Array): string;
|
|
56
|
+
/** 合法 UTF-8 解码不出孤立代理项;含孤立代理项的值(INVALID_UTF8_MARK)不能拿来和任何东西比相等。 */
|
|
57
|
+
export declare function hasLoneSurrogate(s: string): boolean;
|
|
58
|
+
/** 读 /proc/<pid>/<file>(environ / cmdline)并逐条按 UTF-8 解码;读不到返回 null。 */
|
|
59
|
+
export declare function readProcNulBlock(pid: number, file: "environ" | "cmdline"): string | null;
|
|
43
60
|
export declare const linuxProcReader: ProcReader;
|
|
44
61
|
/** 环境块里某个变量的值:undefined = 环境读不到;null = 读到了但没有这个变量。 */
|
|
45
62
|
export declare function envVarFromEnviron(environ: string | null, name: string): string | null | undefined;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #602 — what `anet node start` does with a `codexPendingThread` it finds in
|
|
3
|
+
* the node config before launching a new co-presence generation.
|
|
4
|
+
*
|
|
5
|
+
* The candidate is written by the bridge when the TUI opens a thread that has
|
|
6
|
+
* not had a conversation yet (codex only writes a rollout on the first turn).
|
|
7
|
+
* It is bound to the identity marker of the generation that saw it, so a
|
|
8
|
+
* restart after a crash can carry it over to the next generation without
|
|
9
|
+
* guessing (`migrateCodexPendingThread`).
|
|
10
|
+
*
|
|
11
|
+
* A clean `anet node stop` reaps that generation and removes its marker, but
|
|
12
|
+
* the candidate stays in the config. Before #602 the next start then refused
|
|
13
|
+
* for good: "pending Codex thread is not bound to the exact private
|
|
14
|
+
* previous-generation marker" — every node whose TUI was never used could be
|
|
15
|
+
* stopped once and never started again.
|
|
16
|
+
*
|
|
17
|
+
* A candidate whose marker file is gone AND whose thread has no rollout under
|
|
18
|
+
* this node's CODEX_HOME holds nothing: codex never persisted the thread, its
|
|
19
|
+
* app-server generation is gone, and no app-server can resume it. Dropping it
|
|
20
|
+
* adopts nothing and loses nothing; the new generation starts a fresh thread
|
|
21
|
+
* exactly like a first start. Everything else keeps the old fail-closed
|
|
22
|
+
* answer — in particular a candidate whose thread HAS a rollout while the
|
|
23
|
+
* marker that bound it is gone is never adopted, because nothing proves the
|
|
24
|
+
* binding was ours.
|
|
25
|
+
*/
|
|
26
|
+
export type PendingThreadAtStart = {
|
|
27
|
+
kind: "none";
|
|
28
|
+
} | {
|
|
29
|
+
kind: "migrate";
|
|
30
|
+
oldMarker: string;
|
|
31
|
+
} | {
|
|
32
|
+
kind: "drop-unmaterialized";
|
|
33
|
+
threadId: string;
|
|
34
|
+
} | {
|
|
35
|
+
kind: "refuse";
|
|
36
|
+
reason: string;
|
|
37
|
+
};
|
|
38
|
+
export type PendingMarkerFact = {
|
|
39
|
+
kind: "ok";
|
|
40
|
+
marker: string;
|
|
41
|
+
} | {
|
|
42
|
+
kind: "missing";
|
|
43
|
+
} | {
|
|
44
|
+
kind: "unreadable";
|
|
45
|
+
cause: string;
|
|
46
|
+
};
|
|
47
|
+
/** Rollout files for exactly this thread id (suffix match, no prefix guessing), or `null` if the search itself failed. */
|
|
48
|
+
export type RolloutLookup = (threadId: string) => string[] | null;
|
|
49
|
+
export declare function decidePendingThreadAtStart(pending: unknown, marker: PendingMarkerFact, rollouts: RolloutLookup): PendingThreadAtStart;
|
|
50
|
+
/**
|
|
51
|
+
* Every `*-<threadId>.jsonl` under `<codexHome>/sessions` and
|
|
52
|
+
* `<codexHome>/archived_sessions`. A missing directory is "no rollouts"; any
|
|
53
|
+
* other read error makes the whole lookup `null` (the caller then refuses).
|
|
54
|
+
*/
|
|
55
|
+
export declare function findThreadRollouts(codexHome: string, threadId: string): string[] | null;
|
|
@@ -281,6 +281,16 @@ export interface ReapOptions {
|
|
|
281
281
|
* widen scope, so a stale/recycled pid cannot.
|
|
282
282
|
*/
|
|
283
283
|
anchors?: ScanAnchors;
|
|
284
|
+
/**
|
|
285
|
+
* #602 — after a SIGKILL, how many 100 ms polls the post-KILL rescan may wait
|
|
286
|
+
* for the killed pids to actually leave /proc before calling them residual.
|
|
287
|
+
* SIGKILL is not synchronous: under CPU contention (CI runners, `--cpus 1`)
|
|
288
|
+
* the rescan used to run while the KILLed codex app-server wrapper was still
|
|
289
|
+
* exiting, and stop failed with "1 marker-carrying pid(s) still alive after
|
|
290
|
+
* grace+KILL" although the next stop found 0. Default 30 (= 3 s). Only waits
|
|
291
|
+
* when a SIGKILL was actually sent; it never signals anything new.
|
|
292
|
+
*/
|
|
293
|
+
postKillSettlePolls?: number;
|
|
284
294
|
}
|
|
285
295
|
/**
|
|
286
296
|
* Full reap flow with TOCTOU re-verification.
|