@sleep2agi/agent-network 2.3.0-preview.147 → 2.3.0-preview.149

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_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};
1
+ function a0_0x3675(){const _0x371deb=['message_id','split','\x20error=','get_inbox','reply','parentTaskId','\x20parent_task_id=','toTimeString','\x20from=','6337148fYQkjE','failed','task.send.delivered','reconnectDelay','heartbeatTimer','server','broadcast','networkId','text','body','34uoKUKI','min','message','task_id','12039752cPlxPj','send_reply','decode','unknown\x20error','CommHub\x20rejected\x20task','new_task','messages','11731368zeAsKv','/mcp','heartbeatInterval','3cbVPAU','match','send','/events/','connected','processInbox','from_session','toString','disconnect','connect','offline','POST','token','from_alias','<unknown>','send_failed','sdk-','running','url','content','\x20task_id=','application/json,\x20text/event-stream','lifecycle_tracking','Authorization','4370715vupuSl','signal','sending','11334idaelU','disconnected','\x20to=','to_alias','data:\x20','15415719akgszp','task.expired','text/event-stream','sleep','autoConnect','SSE\x20connected','registered','6jBwBYd','lifecycleTracking','status','delivered','ack_inbox','replace','task','task.send.failed','string','task.send.start','idle','report_status','sseAbort','\x20duration_ms=','[commhub:task]\x20','catch','\x20lifecycle=','not_tracked','alias','send_rejected','now','slice','AbortError','heartbeat\x20failed:\x20','error_code',']\x20[commhub:','log','task.replied','application/json','resumeId','sdk','connectSSE','12154390mbFamy','pop','inbox\x20error:\x20','stringify','task.ack','error','7XzNIKL','result','send_message','Bearer\x20','new_message','9DdTNZA','normal','completed','missing_task_id','name','parse','call','CommHub\x20response\x20omitted\x20task_id','s...','emit','fromAlias','agent','SSE\x20error:\x20','tools/call','getAllStatus','type'];a0_0x3675=function(){return _0x371deb;};return a0_0x3675();}const a0_0x51d83a=a0_0x588e;function a0_0x588e(_0x7eaa63,_0x1f9e80){_0x7eaa63=_0x7eaa63-0x1ba;const _0x3675fc=a0_0x3675();let _0x588e74=_0x3675fc[_0x7eaa63];return _0x588e74;}(function(_0x55c852,_0x3502ce){const _0x4d3965=a0_0x588e,_0x59ba58=_0x55c852();while(!![]){try{const _0xc58cce=-parseInt(_0x4d3965(0x1c8))/0x1*(-parseInt(_0x4d3965(0x1f1))/0x2)+parseInt(_0x4d3965(0x1d6))/0x3*(-parseInt(_0x4d3965(0x1be))/0x4)+-parseInt(_0x4d3965(0x1ee))/0x5*(parseInt(_0x4d3965(0x1fd))/0x6)+-parseInt(_0x4d3965(0x223))/0x7*(-parseInt(_0x4d3965(0x1cc))/0x8)+-parseInt(_0x4d3965(0x228))/0x9*(-parseInt(_0x4d3965(0x21d))/0xa)+parseInt(_0x4d3965(0x1f6))/0xb+-parseInt(_0x4d3965(0x1d3))/0xc;if(_0xc58cce===_0x3502ce)break;else _0x59ba58['push'](_0x59ba58['shift']());}catch(_0x576bf9){_0x59ba58['push'](_0x59ba58['shift']());}}}(a0_0x3675,0xd6787));import{EventEmitter as a0_0x529cfb}from'events';import{hostname as a0_0x4f2d5f}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x1fa3d5,_0x4b553f)=>(_0x1fa3d5??_0x4b553f)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x51d83a(0x212)](0x0,0xf0);function N(_0x66d9e0){const _0x22832f=a0_0x51d83a;return(_0x66d9e0 instanceof Error?_0x66d9e0[_0x22832f(0x1ca)]:String(_0x66d9e0??_0x22832f(0x1cf)))[_0x22832f(0x202)](K,'[REDACTED]')[_0x22832f(0x202)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x2f1d5a,_0x1f3eb5=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x470d3c=a0_0x51d83a;if(_0x1f3eb5)return JSON[_0x470d3c(0x220)](_0x2f1d5a);let _0xd09cad=L(_0x2f1d5a['parent_task_id'],'<missing>'),_0x447384=L(_0x2f1d5a[_0x470d3c(0x1cb)],'<pending>'),_0x3a1c96=_0x2f1d5a[_0x470d3c(0x215)]?_0x470d3c(0x23a)+_0x2f1d5a[_0x470d3c(0x215)]+':'+(_0x2f1d5a['error_message']??''):'';return _0x470d3c(0x20b)+_0x2f1d5a['status']+_0x470d3c(0x1bd)+L(_0x2f1d5a[_0x470d3c(0x1e3)],'<unknown>')+_0x470d3c(0x1f3)+L(_0x2f1d5a[_0x470d3c(0x1f4)],_0x470d3c(0x1e4))+_0x470d3c(0x1ea)+_0x447384+_0x470d3c(0x1bb)+_0xd09cad+'\x20network_id='+L(_0x2f1d5a['network_id'],_0x470d3c(0x1e4))+'\x20transport='+_0x2f1d5a['transport']+_0x470d3c(0x20a)+_0x2f1d5a['duration_ms']+_0x470d3c(0x20d)+_0x2f1d5a[_0x470d3c(0x1ec)]+_0x3a1c96;}function U(_0x4a5a83){const _0x42e61d=a0_0x51d83a;return{'event':{'sending':_0x42e61d(0x206),'delivered':_0x42e61d(0x1c0),'failed':_0x42e61d(0x204),'acked':_0x42e61d(0x221),'started':'task.started','replied':_0x42e61d(0x218),'expired':_0x42e61d(0x1f7)}[_0x4a5a83[_0x42e61d(0x1ff)]],..._0x4a5a83};}function j(_0x271d6f){const _0x215f7c=a0_0x51d83a;let _0x56c559=_0x271d6f?.['task_id']||_0x271d6f?.[_0x215f7c(0x238)]||_0x271d6f?.['id'];if(_0x56c559)return String(_0x56c559);let _0x11b435=_0x271d6f?.[_0x215f7c(0x1e9)]?.[0x0]?.[_0x215f7c(0x1c6)];if(typeof _0x11b435!==_0x215f7c(0x205))return null;try{let _0x237ea5=JSON[_0x215f7c(0x22d)](_0x11b435);return _0x237ea5?.[_0x215f7c(0x1cb)]||_0x237ea5?.['message_id']||_0x237ea5?.['id']||null;}catch{return null;}}async function X(_0x32193f,_0x5f4a93){const _0x341e4e=a0_0x51d83a;let _0x228343=_0x5f4a93[_0x341e4e(0x211)]??Date[_0x341e4e(0x211)],_0x4f41b7=_0x228343(),_0x1e9fe7=(_0x341709,_0x13bd07,_0x13746a,_0x4dfc7e)=>{const _0x4447e6=_0x341e4e;_0x5f4a93['log'](O(U({'from_alias':_0x32193f[_0x4447e6(0x232)],'to_alias':_0x32193f['toAlias'],'task_id':_0x13bd07,'parent_task_id':_0x32193f['parentTaskId'],'network_id':_0x32193f[_0x4447e6(0x1c5)],'transport':_0x32193f['transport'],'status':_0x341709,'duration_ms':_0x228343()-_0x4f41b7,'lifecycle_tracking':_0x32193f[_0x4447e6(0x1fe)],..._0x13746a!==void 0x0?{'error_code':_0x4dfc7e||_0x4447e6(0x1e5),'error_message':N(_0x13746a)}:{}})));};_0x1e9fe7(_0x341e4e(0x1f0),null);try{let _0x1b5400=await _0x5f4a93[_0x341e4e(0x1d8)](),_0x341a20=j(_0x1b5400);if(_0x341a20)_0x1e9fe7(_0x341e4e(0x200),_0x341a20);else{if(_0x1b5400?.['ok']===!0x1||_0x1b5400?.[_0x341e4e(0x222)])_0x1e9fe7(_0x341e4e(0x1bf),_0x341a20,_0x1b5400?.[_0x341e4e(0x222)]||_0x341e4e(0x1d0),_0x341e4e(0x210));else _0x1e9fe7(_0x341e4e(0x1bf),null,_0x341e4e(0x22f),_0x341e4e(0x22b));}return _0x1b5400;}catch(_0x5ac173){throw _0x1e9fe7(_0x341e4e(0x1bf),null,_0x5ac173,'send_failed'),_0x5ac173;}}async function Y(_0x4a1d5b,_0x1aeab6){const _0x4ed9dc=a0_0x51d83a;return X({'fromAlias':_0x4a1d5b[_0x4ed9dc(0x232)],'toAlias':_0x4a1d5b[_0x4ed9dc(0x20f)],'parentTaskId':_0x4a1d5b[_0x4ed9dc(0x1ba)]||null,'networkId':_0x4a1d5b[_0x4ed9dc(0x1c5)]||null,'transport':'mcp_http','lifecycleTracking':_0x4ed9dc(0x20e)},_0x1aeab6);}class $ extends a0_0x529cfb{[a0_0x51d83a(0x1e8)];[a0_0x51d83a(0x20f)];[a0_0x51d83a(0x1e2)];[a0_0x51d83a(0x233)];[a0_0x51d83a(0x21a)];[a0_0x51d83a(0x1d5)];['reconnectDelay'];['heartbeatTimer'];[a0_0x51d83a(0x209)];[a0_0x51d83a(0x1e7)]=!0x1;constructor(_0x52d2b0){const _0x1f9a71=a0_0x51d83a;super();if(this[_0x1f9a71(0x1e8)]=_0x52d2b0[_0x1f9a71(0x1e8)][_0x1f9a71(0x202)](/\/$/,''),this[_0x1f9a71(0x20f)]=_0x52d2b0[_0x1f9a71(0x20f)],this[_0x1f9a71(0x1e2)]=_0x52d2b0[_0x1f9a71(0x1e2)],this['agent']=_0x52d2b0[_0x1f9a71(0x233)]||_0x1f9a71(0x21b),this[_0x1f9a71(0x21a)]=_0x1f9a71(0x1e6)+_0x52d2b0[_0x1f9a71(0x20f)]+'-'+Date[_0x1f9a71(0x211)]()[_0x1f9a71(0x1dd)](0x24),this[_0x1f9a71(0x1d5)]=_0x52d2b0[_0x1f9a71(0x1d5)]??0x2bf20,this['reconnectDelay']=_0x52d2b0[_0x1f9a71(0x1c1)]??0xbb8,_0x52d2b0[_0x1f9a71(0x1fa)]!==!0x1)this[_0x1f9a71(0x1df)]();}['log'](_0x488ce3){const _0x501df2=a0_0x51d83a;console[_0x501df2(0x217)]('['+new Date()[_0x501df2(0x1bc)]()['slice'](0x0,0x8)+_0x501df2(0x216)+this[_0x501df2(0x20f)]+']\x20'+_0x488ce3);}async[a0_0x51d83a(0x22e)](_0x4ad6e0,_0x5ac58f){const _0xfc7ad9=a0_0x51d83a;let _0x8a441={'Content-Type':_0xfc7ad9(0x219),'Accept':_0xfc7ad9(0x1eb)};if(this['token'])_0x8a441[_0xfc7ad9(0x1ed)]=_0xfc7ad9(0x226)+this[_0xfc7ad9(0x1e2)];let _0x14b8e2=await(await fetch(this[_0xfc7ad9(0x1e8)]+_0xfc7ad9(0x1d4),{'method':_0xfc7ad9(0x1e1),'headers':_0x8a441,'body':JSON[_0xfc7ad9(0x220)]({'jsonrpc':'2.0','id':Date[_0xfc7ad9(0x211)](),'method':_0xfc7ad9(0x235),'params':{'name':_0x4ad6e0,'arguments':_0x5ac58f}})}))[_0xfc7ad9(0x1c6)](),_0x3f1eaf=_0x14b8e2[_0xfc7ad9(0x1d7)](/data: (.+)/),_0x3c3cc8=_0x3f1eaf?JSON[_0xfc7ad9(0x22d)](_0x3f1eaf[0x1]):JSON[_0xfc7ad9(0x22d)](_0x14b8e2),_0x30014b=_0x3c3cc8?.[_0xfc7ad9(0x224)]?.[_0xfc7ad9(0x1e9)]?.[0x0]?.[_0xfc7ad9(0x1c6)];return _0x30014b?JSON[_0xfc7ad9(0x22d)](_0x30014b):_0x3c3cc8;}async['connect'](){const _0x5a9383=a0_0x51d83a;if(this['running'])return;this['running']=!0x0,await this[_0x5a9383(0x1ff)](_0x5a9383(0x207)),this[_0x5a9383(0x217)](_0x5a9383(0x1fc)),this[_0x5a9383(0x1c2)]=setInterval(()=>{const _0x54296c=_0x5a9383;this[_0x54296c(0x1ff)]('idle')[_0x54296c(0x20c)](_0x3a6ee3=>this[_0x54296c(0x217)](_0x54296c(0x214)+_0x3a6ee3[_0x54296c(0x1ca)]));},this['heartbeatInterval']),this['connectSSE']();}async[a0_0x51d83a(0x1de)](){const _0x4232fb=a0_0x51d83a;if(this[_0x4232fb(0x1e7)]=!0x1,this[_0x4232fb(0x209)]?.['abort'](),this[_0x4232fb(0x1c2)])clearInterval(this['heartbeatTimer']);await this['status'](_0x4232fb(0x1e0))[_0x4232fb(0x20c)](()=>{}),this[_0x4232fb(0x217)](_0x4232fb(0x1f2));}async['send'](_0x1cacb0,_0x179665,_0x11ef36=a0_0x51d83a(0x229)){const _0x332bcd=a0_0x51d83a;return Y({'alias':_0x1cacb0,'fromAlias':this[_0x332bcd(0x20f)]},{'log':_0x473c63=>console[_0x332bcd(0x217)](_0x473c63),'send':()=>this[_0x332bcd(0x22e)]('send_task',{'alias':_0x1cacb0,'task':_0x179665,'priority':_0x11ef36,'from_session':this['alias']})});}async[a0_0x51d83a(0x1ca)](_0x4156af,_0x24468b){const _0x2a99af=a0_0x51d83a;return this[_0x2a99af(0x22e)](_0x2a99af(0x225),{'alias':_0x4156af,'message':_0x24468b,'from_session':this[_0x2a99af(0x20f)]});}async[a0_0x51d83a(0x23c)](_0xbcab94,_0x3c59bc,_0x1c8ae6=a0_0x51d83a(0x22a)){const _0x599da5=a0_0x51d83a;return this[_0x599da5(0x22e)](_0x599da5(0x1cd),{'in_reply_to':_0xbcab94,'text':_0x3c59bc,'status':_0x1c8ae6});}async['status'](_0x3c1177,_0x564423){const _0x2daf1c=a0_0x51d83a;return this[_0x2daf1c(0x22e)](_0x2daf1c(0x208),{'resume_id':this[_0x2daf1c(0x21a)],'alias':this[_0x2daf1c(0x20f)],'status':_0x3c1177,'server':a0_0x4f2d5f(),'hostname':a0_0x4f2d5f(),'agent':this['agent'],'project_dir':process['cwd'](),..._0x564423});}async[a0_0x51d83a(0x236)](){const _0x429b86=a0_0x51d83a;return this[_0x429b86(0x22e)]('get_all_status',{});}async[a0_0x51d83a(0x1c4)](_0x21c521,_0x401b14){const _0x43d12d=a0_0x51d83a;return this[_0x43d12d(0x22e)]('broadcast',{'message':_0x21c521,'filter_server':_0x401b14?.[_0x43d12d(0x1c3)],'filter_status':_0x401b14?.[_0x43d12d(0x1ff)]});}async[a0_0x51d83a(0x21c)](){const _0x5a7d77=a0_0x51d83a;let _0x1acd3a=encodeURIComponent(this[_0x5a7d77(0x20f)]),_0x18aca5=this[_0x5a7d77(0x1e8)]+_0x5a7d77(0x1d9)+_0x1acd3a,_0x5d2474=this[_0x5a7d77(0x1c1)];while(this['running']){try{this[_0x5a7d77(0x209)]=new AbortController();let _0x35373b={'Accept':_0x5a7d77(0x1f8)};if(this[_0x5a7d77(0x1e2)])_0x35373b[_0x5a7d77(0x1ed)]=_0x5a7d77(0x226)+this[_0x5a7d77(0x1e2)];let _0x5a804e=await fetch(_0x18aca5,{'headers':_0x35373b,'signal':this[_0x5a7d77(0x209)][_0x5a7d77(0x1ef)]});if(!_0x5a804e['ok']||!_0x5a804e['body']){this[_0x5a7d77(0x217)]('SSE\x20failed:\x20'+_0x5a804e['status']),await this[_0x5a7d77(0x1f9)](_0x5d2474),_0x5d2474=Math[_0x5a7d77(0x1c9)](_0x5d2474*1.5,0xea60);continue;}_0x5d2474=this['reconnectDelay'];let _0x469bc4=_0x5a804e[_0x5a7d77(0x1c7)]['getReader'](),_0x1d157c=new TextDecoder(),_0x57a5e5='';while(this[_0x5a7d77(0x1e7)]){let {done:_0xdce690,value:_0xafde70}=await _0x469bc4['read']();if(_0xdce690)break;_0x57a5e5+=_0x1d157c[_0x5a7d77(0x1ce)](_0xafde70,{'stream':!0x0});let _0x162783=_0x57a5e5[_0x5a7d77(0x239)]('\x0a');_0x57a5e5=_0x162783[_0x5a7d77(0x21e)]()||'';for(let _0x18a139 of _0x162783){if(!_0x18a139['startsWith'](_0x5a7d77(0x1f5)))continue;try{let _0x54e5e8=JSON[_0x5a7d77(0x22d)](_0x18a139[_0x5a7d77(0x212)](0x6));if(_0x54e5e8[_0x5a7d77(0x237)]===_0x5a7d77(0x1da)){this[_0x5a7d77(0x217)](_0x5a7d77(0x1fb)),this[_0x5a7d77(0x231)]('connected');continue;}if(_0x54e5e8[_0x5a7d77(0x237)]===_0x5a7d77(0x1d1)||_0x54e5e8[_0x5a7d77(0x237)]===_0x5a7d77(0x227)||_0x54e5e8['type']===_0x5a7d77(0x1c4))await this[_0x5a7d77(0x1db)]();}catch{}}}}catch(_0x596bba){if(_0x596bba[_0x5a7d77(0x22c)]===_0x5a7d77(0x213))break;this[_0x5a7d77(0x231)]('error',_0x596bba),this['log'](_0x5a7d77(0x234)+_0x596bba[_0x5a7d77(0x1ca)]);}if(this['running'])this[_0x5a7d77(0x231)]('disconnected'),this['log']('SSE\x20reconnecting\x20in\x20'+_0x5d2474/0x3e8+_0x5a7d77(0x230)),await this[_0x5a7d77(0x1f9)](_0x5d2474),_0x5d2474=Math[_0x5a7d77(0x1c9)](_0x5d2474*1.5,0xea60);}}async[a0_0x51d83a(0x1db)](){const _0x1d5f7c=a0_0x51d83a;try{let _0x2c73c1=(await this[_0x1d5f7c(0x22e)](_0x1d5f7c(0x23b),{'alias':this[_0x1d5f7c(0x20f)],'limit':0xa}))?.[_0x1d5f7c(0x1d2)]||[];for(let _0x1b136c of _0x2c73c1)await this[_0x1d5f7c(0x22e)](_0x1d5f7c(0x201),{'alias':this[_0x1d5f7c(0x20f)],'message_id':_0x1b136c['id']}),this[_0x1d5f7c(0x217)]('←\x20'+_0x1b136c[_0x1d5f7c(0x1dc)]+':\x20'+_0x1b136c[_0x1d5f7c(0x1e9)][_0x1d5f7c(0x212)](0x0,0x3c)),this[_0x1d5f7c(0x231)](_0x1d5f7c(0x203),_0x1b136c),this[_0x1d5f7c(0x231)]('message',_0x1b136c);}catch(_0x396f71){this['log'](_0x1d5f7c(0x21f)+_0x396f71[_0x1d5f7c(0x1ca)]);}}[a0_0x51d83a(0x1f9)](_0xf4a121){return new Promise(_0x2b68ef=>setTimeout(_0x2b68ef,_0xf4a121));}}var F=$;export{F as default,$ as CommHub};
@@ -0,0 +1,120 @@
1
+ export declare const EXTERNAL_APPSERVER_LAYOUT = "external-appserver";
2
+ /** Each node (app-server + TUI) measured at 1.5–2 GB; refuse below two nodes' worth. */
3
+ export declare const MIN_MEM_AVAILABLE_BYTES: number;
4
+ export declare const READYZ_TIMEOUT_MS = 30000;
5
+ export interface ExternalAppserverProfile {
6
+ runtime?: string;
7
+ codexAppServerUrl?: string;
8
+ codexThreadId?: string;
9
+ codexProjectDir?: string;
10
+ codexCopresence?: boolean;
11
+ codexLaunchLayout?: string;
12
+ codexBin?: string;
13
+ codexHome?: string;
14
+ model?: string;
15
+ env?: Record<string, unknown>;
16
+ }
17
+ export interface ExternalAppserverSessions {
18
+ appsrv: string;
19
+ tui: string;
20
+ bridge: string;
21
+ }
22
+ export declare function externalAppserverSessions(alias: string): ExternalAppserverSessions;
23
+ /** Bridge first, so nothing is left attached to a server that is going away. */
24
+ export declare function externalAppserverStopOrder(alias: string): string[];
25
+ /**
26
+ * Does this start/stop/restart take the external-app-server lane?
27
+ * `runtime` is the already-normalized runtime name.
28
+ */
29
+ export declare function externalAppserverRequested(flagPassed: boolean, profile: ExternalAppserverProfile, runtime: string): boolean;
30
+ export interface ExternalAppserverPlan {
31
+ alias: string;
32
+ nodeDir: string;
33
+ configPath: string;
34
+ workspaceDir: string;
35
+ url: string;
36
+ host: string;
37
+ port: number;
38
+ readyzUrl: string;
39
+ projectDir: string;
40
+ /** True when config.codexProjectDir was empty and the workspace was used instead. */
41
+ projectDirFromWorkspace: boolean;
42
+ threadId: string;
43
+ model: string;
44
+ codexHome: string;
45
+ codexBin: string;
46
+ /** Start the `<alias>-tui` session (codexCopresence && codexThreadId). */
47
+ tui: boolean;
48
+ sessions: ExternalAppserverSessions;
49
+ }
50
+ export declare function planExternalAppserverNode(input: {
51
+ alias: string;
52
+ nodeDir: string;
53
+ workspaceDir: string;
54
+ profile: ExternalAppserverProfile;
55
+ }): {
56
+ ok: true;
57
+ plan: ExternalAppserverPlan;
58
+ } | {
59
+ ok: false;
60
+ error: string;
61
+ };
62
+ /** Names from `wanted` that exist in `existing` — compared as whole strings, never by tmux target rules. */
63
+ export declare function sessionsAlreadyPresent(existing: readonly string[], wanted: readonly string[]): string[];
64
+ /** `{id, name}` rows whose name equals one of `names` exactly, in the order of `names`. */
65
+ export declare function exactSessionRows(rows: readonly {
66
+ id: string;
67
+ name: string;
68
+ }[], names: readonly string[]): {
69
+ id: string;
70
+ name: string;
71
+ }[];
72
+ export declare function parseMemAvailableBytes(meminfo: string): number | null;
73
+ export declare function memoryVerdict(availableBytes: number | null, force: boolean): {
74
+ ok: boolean;
75
+ message: string;
76
+ };
77
+ /**
78
+ * Read the node token from config.json INSIDE the session shell, into the env.
79
+ * The value never appears in tmux's argv, the pane's start command, or any
80
+ * process's /proc/<pid>/cmdline — only the config path does.
81
+ */
82
+ export declare function tokenInSessionSnippet(configPath: string, jsRuntime: string): string;
83
+ export declare function appserverShellCommand(plan: ExternalAppserverPlan, jsRuntime: string): string;
84
+ export declare function tuiShellCommand(plan: ExternalAppserverPlan): string;
85
+ export declare function bridgeShellCommand(plan: ExternalAppserverPlan, launch: {
86
+ command: string;
87
+ argsPrefix: readonly string[];
88
+ }): string;
89
+ export declare function bridgeLogPath(plan: {
90
+ nodeDir: string;
91
+ }): string;
92
+ export type ResumedVerdict = {
93
+ state: "match";
94
+ seen: string;
95
+ } | {
96
+ state: "mismatch";
97
+ seen: string;
98
+ } | {
99
+ state: "new-thread";
100
+ seen: string;
101
+ } | {
102
+ state: "not-seen";
103
+ } | {
104
+ state: "no-thread-configured";
105
+ };
106
+ /**
107
+ * Did the bridge resume the configured thread? Reads only the log text written
108
+ * since this start. agent-node prints `[codex-app-server] resumed thread <12 chars>…`
109
+ * or `created thread <12 chars>…` (a silent new session). Registration alone
110
+ * proves nothing about which thread the node is on.
111
+ */
112
+ export declare function resumedThreadVerdict(logText: string, threadId: string): ResumedVerdict;
113
+ /** True when something is already bound to host:port (a listen attempt fails). */
114
+ export declare function portBusy(host: string, port: number): Promise<boolean>;
115
+ /** Poll `/readyz` until it answers 200 or `timeoutMs` passes. */
116
+ export declare function waitForReadyz(url: string, timeoutMs?: number, intervalMs?: number): Promise<{
117
+ ok: boolean;
118
+ status: number;
119
+ waitedMs: number;
120
+ }>;
@@ -0,0 +1,9 @@
1
+ export declare function isInheritedSessionIdentityEnvName(name: string): boolean;
2
+ /** Return a copy of `env` without session-identity variables, plus the sorted
3
+ * list of names that were removed. Does not mutate `env`. */
4
+ export declare function scrubInheritedSessionIdentityEnv(env: NodeJS.ProcessEnv): {
5
+ env: NodeJS.ProcessEnv;
6
+ removed: string[];
7
+ };
8
+ /** One log line, names only. */
9
+ export declare function formatScrubbedEnvLine(removed: string[]): string;