@sleep2agi/agent-network 2.3.0-preview.146 → 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.
@@ -1 +1 @@
1
- const a0_0x2ae587=a0_0x4d95;(function(_0x5e4298,_0x546411){const _0x16643b=a0_0x4d95,_0x3f36b4=_0x5e4298();while(!![]){try{const _0x5ce7dc=parseInt(_0x16643b(0xa0))/0x1+-parseInt(_0x16643b(0xbe))/0x2+-parseInt(_0x16643b(0xb9))/0x3+-parseInt(_0x16643b(0xac))/0x4*(-parseInt(_0x16643b(0xc9))/0x5)+parseInt(_0x16643b(0xdd))/0x6*(-parseInt(_0x16643b(0xa8))/0x7)+parseInt(_0x16643b(0xfd))/0x8*(parseInt(_0x16643b(0xb5))/0x9)+-parseInt(_0x16643b(0x109))/0xa;if(_0x5ce7dc===_0x546411)break;else _0x3f36b4['push'](_0x3f36b4['shift']());}catch(_0xc8af0e){_0x3f36b4['push'](_0x3f36b4['shift']());}}}(a0_0x3896,0x3af46));import{EventEmitter as a0_0x1e2067}from'events';function a0_0x4d95(_0x3bcd21,_0x4abb0a){_0x3bcd21=_0x3bcd21-0xa0;const _0x38964a=a0_0x3896();let _0x4d952d=_0x38964a[_0x3bcd21];return _0x4d952d;}import{hostname as a0_0x46bd4d}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x55e795,_0x5551f8)=>(_0x55e795??_0x5551f8)[a0_0x2ae587(0xdb)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x2ae587(0xca)](0x0,0xf0);function N(_0x20ce50){const _0x40d0e6=a0_0x2ae587;return(_0x20ce50 instanceof Error?_0x20ce50[_0x40d0e6(0xda)]:String(_0x20ce50??_0x40d0e6(0xd7)))[_0x40d0e6(0xdb)](K,_0x40d0e6(0xab))[_0x40d0e6(0xdb)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x40d0e6(0xca)](0x0,0xf0);}function O(_0x3decb2,_0x191faa=process.env.ANET_TASK_TRACE_FORMAT===a0_0x2ae587(0xe1)){const _0x149b29=a0_0x2ae587;if(_0x191faa)return JSON[_0x149b29(0xb3)](_0x3decb2);let _0x177c82=L(_0x3decb2[_0x149b29(0xb4)],_0x149b29(0xd1)),_0x469c73=L(_0x3decb2[_0x149b29(0xb7)],_0x149b29(0xc5)),_0x4be0b6=_0x3decb2[_0x149b29(0x11e)]?_0x149b29(0x119)+_0x3decb2['error_code']+':'+(_0x3decb2['error_message']??''):'';return _0x149b29(0x114)+_0x3decb2[_0x149b29(0x10c)]+'\x20from='+L(_0x3decb2[_0x149b29(0xc3)],'<unknown>')+_0x149b29(0xa4)+L(_0x3decb2[_0x149b29(0x104)],'<unknown>')+_0x149b29(0xd0)+_0x469c73+'\x20parent_task_id='+_0x177c82+_0x149b29(0xd8)+L(_0x3decb2[_0x149b29(0xec)],_0x149b29(0xe2))+'\x20transport='+_0x3decb2[_0x149b29(0xe4)]+'\x20duration_ms='+_0x3decb2['duration_ms']+_0x149b29(0xa5)+_0x3decb2[_0x149b29(0xa2)]+_0x4be0b6;}function U(_0x3ba8a5){const _0x86ea34=a0_0x2ae587;return{'event':{'sending':_0x86ea34(0x103),'delivered':_0x86ea34(0xcc),'failed':_0x86ea34(0xf0),'acked':_0x86ea34(0xad),'started':_0x86ea34(0x112),'replied':_0x86ea34(0xbc),'expired':_0x86ea34(0xc7)}[_0x3ba8a5[_0x86ea34(0x10c)]],..._0x3ba8a5};}function j(_0x118b48){const _0x111661=a0_0x2ae587;let _0x51701e=_0x118b48?.[_0x111661(0xb7)]||_0x118b48?.['message_id']||_0x118b48?.['id'];if(_0x51701e)return String(_0x51701e);let _0x422218=_0x118b48?.['content']?.[0x0]?.[_0x111661(0x10a)];if(typeof _0x422218!==_0x111661(0xe9))return null;try{let _0x2bac93=JSON[_0x111661(0xb2)](_0x422218);return _0x2bac93?.['task_id']||_0x2bac93?.['message_id']||_0x2bac93?.['id']||null;}catch{return null;}}async function X(_0xe0115d,_0x4b5cd4){const _0x2a5a9f=a0_0x2ae587;let _0x3e9171=_0x4b5cd4[_0x2a5a9f(0xa6)]??Date[_0x2a5a9f(0xa6)],_0x14fc7b=_0x3e9171(),_0xcee632=(_0x2c1b28,_0x59d5db,_0x3e8394,_0x28bfe2)=>{const _0x1f06bc=_0x2a5a9f;_0x4b5cd4[_0x1f06bc(0xdc)](O(U({'from_alias':_0xe0115d[_0x1f06bc(0x113)],'to_alias':_0xe0115d[_0x1f06bc(0xfa)],'task_id':_0x59d5db,'parent_task_id':_0xe0115d[_0x1f06bc(0xe0)],'network_id':_0xe0115d[_0x1f06bc(0x110)],'transport':_0xe0115d['transport'],'status':_0x2c1b28,'duration_ms':_0x3e9171()-_0x14fc7b,'lifecycle_tracking':_0xe0115d[_0x1f06bc(0xde)],..._0x3e8394!==void 0x0?{'error_code':_0x28bfe2||_0x1f06bc(0xdf),'error_message':N(_0x3e8394)}:{}})));};_0xcee632(_0x2a5a9f(0xee),null);try{let _0x10824c=await _0x4b5cd4[_0x2a5a9f(0xe5)](),_0x49b322=j(_0x10824c);if(_0x49b322)_0xcee632(_0x2a5a9f(0xa1),_0x49b322);else{if(_0x10824c?.['ok']===!0x1||_0x10824c?.[_0x2a5a9f(0xfb)])_0xcee632('failed',_0x49b322,_0x10824c?.[_0x2a5a9f(0xfb)]||_0x2a5a9f(0xd6),_0x2a5a9f(0x11d));else _0xcee632(_0x2a5a9f(0xf9),null,'CommHub\x20response\x20omitted\x20task_id',_0x2a5a9f(0x10e));}return _0x10824c;}catch(_0x275bf7){throw _0xcee632(_0x2a5a9f(0xf9),null,_0x275bf7,'send_failed'),_0x275bf7;}}async function Y(_0x1cc40d,_0x48f971){const _0x3e13bd=a0_0x2ae587;return X({'fromAlias':_0x1cc40d[_0x3e13bd(0x113)],'toAlias':_0x1cc40d['alias'],'parentTaskId':_0x1cc40d[_0x3e13bd(0xe0)]||null,'networkId':_0x1cc40d[_0x3e13bd(0x110)]||null,'transport':_0x3e13bd(0xbb),'lifecycleTracking':'not_tracked'},_0x48f971);}class $ extends a0_0x1e2067{[a0_0x2ae587(0xbd)];[a0_0x2ae587(0x11a)];[a0_0x2ae587(0xc6)];[a0_0x2ae587(0x11b)];['resumeId'];[a0_0x2ae587(0x106)];[a0_0x2ae587(0xa9)];['heartbeatTimer'];[a0_0x2ae587(0xc4)];['running']=!0x1;constructor(_0x49787b){const _0x429db9=a0_0x2ae587;super();if(this[_0x429db9(0xbd)]=_0x49787b[_0x429db9(0xbd)][_0x429db9(0xdb)](/\/$/,''),this[_0x429db9(0x11a)]=_0x49787b['alias'],this[_0x429db9(0xc6)]=_0x49787b[_0x429db9(0xc6)],this['agent']=_0x49787b[_0x429db9(0x11b)]||_0x429db9(0xb0),this[_0x429db9(0x107)]=_0x429db9(0x118)+_0x49787b[_0x429db9(0x11a)]+'-'+Date[_0x429db9(0xa6)]()[_0x429db9(0xb6)](0x24),this['heartbeatInterval']=_0x49787b[_0x429db9(0x106)]??0x2bf20,this['reconnectDelay']=_0x49787b[_0x429db9(0xa9)]??0xbb8,_0x49787b[_0x429db9(0xd5)]!==!0x1)this[_0x429db9(0xd3)]();}['log'](_0x29caf3){const _0xedafac=a0_0x2ae587;console['log']('['+new Date()['toTimeString']()[_0xedafac(0xca)](0x0,0x8)+_0xedafac(0xef)+this[_0xedafac(0x11a)]+']\x20'+_0x29caf3);}async[a0_0x2ae587(0x108)](_0x231648,_0x425956){const _0x341635=a0_0x2ae587;let _0x5be2bc={'Content-Type':'application/json','Accept':_0x341635(0xc1)};if(this[_0x341635(0xc6)])_0x5be2bc['Authorization']='Bearer\x20'+this['token'];let _0x4b8b8c=await(await fetch(this[_0x341635(0xbd)]+_0x341635(0xed),{'method':_0x341635(0xd9),'headers':_0x5be2bc,'body':JSON[_0x341635(0xb3)]({'jsonrpc':'2.0','id':Date['now'](),'method':_0x341635(0xc0),'params':{'name':_0x231648,'arguments':_0x425956}})}))[_0x341635(0x10a)](),_0x504a30=_0x4b8b8c['match'](/data: (.+)/),_0x1665f9=_0x504a30?JSON[_0x341635(0xb2)](_0x504a30[0x1]):JSON[_0x341635(0xb2)](_0x4b8b8c),_0x19654e=_0x1665f9?.[_0x341635(0xaa)]?.['content']?.[0x0]?.[_0x341635(0x10a)];return _0x19654e?JSON['parse'](_0x19654e):_0x1665f9;}async[a0_0x2ae587(0xd3)](){const _0x1c6f26=a0_0x2ae587;if(this[_0x1c6f26(0x117)])return;this[_0x1c6f26(0x117)]=!0x0,await this[_0x1c6f26(0x10c)]('idle'),this[_0x1c6f26(0xdc)](_0x1c6f26(0x101)),this['heartbeatTimer']=setInterval(()=>{const _0x54a21e=_0x1c6f26;this[_0x54a21e(0x10c)]('idle')[_0x54a21e(0xf1)](_0x4c46a6=>this[_0x54a21e(0xdc)](_0x54a21e(0xe6)+_0x4c46a6[_0x54a21e(0xda)]));},this['heartbeatInterval']),this['connectSSE']();}async[a0_0x2ae587(0xbf)](){const _0x14f87a=a0_0x2ae587;if(this['running']=!0x1,this[_0x14f87a(0xc4)]?.['abort'](),this['heartbeatTimer'])clearInterval(this['heartbeatTimer']);await this[_0x14f87a(0x10c)](_0x14f87a(0x10d))[_0x14f87a(0xf1)](()=>{}),this['log'](_0x14f87a(0xa3));}async[a0_0x2ae587(0xe5)](_0x30f685,_0x46b3cb,_0x4af951=a0_0x2ae587(0x102)){const _0x1df847=a0_0x2ae587;return Y({'alias':_0x30f685,'fromAlias':this['alias']},{'log':_0x2f4d54=>console[_0x1df847(0xdc)](_0x2f4d54),'send':()=>this[_0x1df847(0x108)](_0x1df847(0xff),{'alias':_0x30f685,'task':_0x46b3cb,'priority':_0x4af951,'from_session':this[_0x1df847(0x11a)]})});}async[a0_0x2ae587(0xda)](_0x18371c,_0x1e8352){const _0x67d37f=a0_0x2ae587;return this['call'](_0x67d37f(0xfc),{'alias':_0x18371c,'message':_0x1e8352,'from_session':this[_0x67d37f(0x11a)]});}async[a0_0x2ae587(0x105)](_0x46bbe2,_0x12ee12,_0xab4fe=a0_0x2ae587(0xf5)){const _0x360f6a=a0_0x2ae587;return this[_0x360f6a(0x108)](_0x360f6a(0x100),{'in_reply_to':_0x46bbe2,'text':_0x12ee12,'status':_0xab4fe});}async[a0_0x2ae587(0x10c)](_0x414efe,_0x22072f){const _0x549a4b=a0_0x2ae587;return this[_0x549a4b(0x108)](_0x549a4b(0xc8),{'resume_id':this['resumeId'],'alias':this[_0x549a4b(0x11a)],'status':_0x414efe,'server':a0_0x46bd4d(),'hostname':a0_0x46bd4d(),'agent':this['agent'],'project_dir':process[_0x549a4b(0xba)](),..._0x22072f});}async[a0_0x2ae587(0xf3)](){const _0x335805=a0_0x2ae587;return this[_0x335805(0x108)](_0x335805(0xf4),{});}async[a0_0x2ae587(0xeb)](_0xbf19bb,_0x4114ee){const _0x54df06=a0_0x2ae587;return this[_0x54df06(0x108)](_0x54df06(0xeb),{'message':_0xbf19bb,'filter_server':_0x4114ee?.['server'],'filter_status':_0x4114ee?.[_0x54df06(0x10c)]});}async[a0_0x2ae587(0x10b)](){const _0x396371=a0_0x2ae587;let _0x10dc0d=encodeURIComponent(this[_0x396371(0x11a)]),_0x5448a8=this['url']+_0x396371(0xf8)+_0x10dc0d,_0x544fb8=this[_0x396371(0xa9)];while(this[_0x396371(0x117)]){try{this[_0x396371(0xc4)]=new AbortController();let _0x4172bb={'Accept':_0x396371(0x111)};if(this['token'])_0x4172bb[_0x396371(0xcf)]='Bearer\x20'+this['token'];let _0x236740=await fetch(_0x5448a8,{'headers':_0x4172bb,'signal':this[_0x396371(0xc4)][_0x396371(0x11c)]});if(!_0x236740['ok']||!_0x236740[_0x396371(0xd4)]){this[_0x396371(0xdc)]('SSE\x20failed:\x20'+_0x236740[_0x396371(0x10c)]),await this[_0x396371(0xb8)](_0x544fb8),_0x544fb8=Math[_0x396371(0xd2)](_0x544fb8*1.5,0xea60);continue;}_0x544fb8=this['reconnectDelay'];let _0x3ea763=_0x236740[_0x396371(0xd4)][_0x396371(0xcd)](),_0x4d6a4b=new TextDecoder(),_0xe07af9='';while(this[_0x396371(0x117)]){let {done:_0x5daa2f,value:_0x5c5e33}=await _0x3ea763[_0x396371(0xae)]();if(_0x5daa2f)break;_0xe07af9+=_0x4d6a4b[_0x396371(0x115)](_0x5c5e33,{'stream':!0x0});let _0x3c7858=_0xe07af9['split']('\x0a');_0xe07af9=_0x3c7858['pop']()||'';for(let _0x5500ee of _0x3c7858){if(!_0x5500ee[_0x396371(0xf2)]('data:\x20'))continue;try{let _0x5dd252=JSON['parse'](_0x5500ee['slice'](0x6));if(_0x5dd252[_0x396371(0x116)]===_0x396371(0xfe)){this[_0x396371(0xdc)](_0x396371(0xe8)),this['emit'](_0x396371(0xfe));continue;}if(_0x5dd252[_0x396371(0x116)]===_0x396371(0xea)||_0x5dd252['type']===_0x396371(0xc2)||_0x5dd252['type']===_0x396371(0xeb))await this['processInbox']();}catch{}}}}catch(_0x209f43){if(_0x209f43[_0x396371(0xe3)]===_0x396371(0x10f))break;this[_0x396371(0xaf)]('error',_0x209f43),this['log'](_0x396371(0xce)+_0x209f43['message']);}if(this[_0x396371(0x117)])this['emit']('disconnected'),this['log'](_0x396371(0xcb)+_0x544fb8/0x3e8+_0x396371(0xf7)),await this[_0x396371(0xb8)](_0x544fb8),_0x544fb8=Math[_0x396371(0xd2)](_0x544fb8*1.5,0xea60);}}async[a0_0x2ae587(0xf6)](){const _0x559d8f=a0_0x2ae587;try{let _0xac9002=(await this[_0x559d8f(0x108)](_0x559d8f(0xa7),{'alias':this[_0x559d8f(0x11a)],'limit':0xa}))?.['messages']||[];for(let _0xa252d9 of _0xac9002)await this[_0x559d8f(0x108)]('ack_inbox',{'alias':this['alias'],'message_id':_0xa252d9['id']}),this[_0x559d8f(0xdc)]('←\x20'+_0xa252d9[_0x559d8f(0xe7)]+':\x20'+_0xa252d9['content'][_0x559d8f(0xca)](0x0,0x3c)),this['emit'](_0x559d8f(0xb1),_0xa252d9),this['emit']('message',_0xa252d9);}catch(_0x1852e4){this['log']('inbox\x20error:\x20'+_0x1852e4['message']);}}[a0_0x2ae587(0xb8)](_0xca1ad7){return new Promise(_0x2c791b=>setTimeout(_0x2c791b,_0xca1ad7));}}var F=$;export{F as default,$ as CommHub};function a0_0x3896(){const _0x37913e=['SSE\x20error:\x20','Authorization','\x20task_id=','<missing>','min','connect','body','autoConnect','CommHub\x20rejected\x20task','unknown\x20error','\x20network_id=','POST','message','replace','log','36GKSRXJ','lifecycleTracking','send_failed','parentTaskId','json','<unknown>','name','transport','send','heartbeat\x20failed:\x20','from_session','SSE\x20connected','string','new_task','broadcast','network_id','/mcp','sending',']\x20[commhub:','task.send.failed','catch','startsWith','getAllStatus','get_all_status','completed','processInbox','s...','/events/','failed','toAlias','error','send_message','32944vJfeGK','connected','send_task','send_reply','registered','normal','task.send.start','to_alias','reply','heartbeatInterval','resumeId','call','7056950GnXvev','text','connectSSE','status','offline','missing_task_id','AbortError','networkId','text/event-stream','task.started','fromAlias','[commhub:task]\x20','decode','type','running','sdk-','\x20error=','alias','agent','signal','send_rejected','error_code','477298ddJeya','delivered','lifecycle_tracking','disconnected','\x20to=','\x20lifecycle=','now','get_inbox','280847LmGqGe','reconnectDelay','result','[REDACTED]','913916AnhqNe','task.ack','read','emit','sdk','task','parse','stringify','parent_task_id','981hpYuvG','toString','task_id','sleep','259920SVjrcm','cwd','mcp_http','task.replied','url','217158wUZOtM','disconnect','tools/call','application/json,\x20text/event-stream','new_message','from_alias','sseAbort','<pending>','token','task.expired','report_status','10ZFcQVG','slice','SSE\x20reconnecting\x20in\x20','task.send.delivered','getReader'];a0_0x3896=function(){return _0x37913e;};return a0_0x3896();}
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.