@sleep2agi/agent-network 2.3.0-preview.40 → 2.3.0-preview.41

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_0x48272b=a0_0x4270;(function(_0x518421,_0x24257a){const _0x28eaa4=a0_0x4270,_0x3c9de8=_0x518421();while(!![]){try{const _0x586398=-parseInt(_0x28eaa4(0x242))/0x1+parseInt(_0x28eaa4(0x240))/0x2+parseInt(_0x28eaa4(0x229))/0x3*(parseInt(_0x28eaa4(0x24f))/0x4)+parseInt(_0x28eaa4(0x1ff))/0x5*(-parseInt(_0x28eaa4(0x263))/0x6)+parseInt(_0x28eaa4(0x22c))/0x7+parseInt(_0x28eaa4(0x214))/0x8*(parseInt(_0x28eaa4(0x262))/0x9)+-parseInt(_0x28eaa4(0x225))/0xa;if(_0x586398===_0x24257a)break;else _0x3c9de8['push'](_0x3c9de8['shift']());}catch(_0x51d780){_0x3c9de8['push'](_0x3c9de8['shift']());}}}(a0_0x4f75,0xd5184));import{EventEmitter as a0_0x5582f2}from'events';import{hostname as a0_0x56836f}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x552101,_0x16b042)=>(_0x552101??_0x16b042)[a0_0x48272b(0x230)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x53dcd9){const _0x2d194a=a0_0x48272b;return(_0x53dcd9 instanceof Error?_0x53dcd9['message']:String(_0x53dcd9??_0x2d194a(0x236)))[_0x2d194a(0x230)](K,_0x2d194a(0x258))[_0x2d194a(0x230)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x2d194a(0x260)](0x0,0xf0);}function O(_0x430111,_0x3b7071=process.env.ANET_TASK_TRACE_FORMAT===a0_0x48272b(0x23b)){const _0x37ee88=a0_0x48272b;if(_0x3b7071)return JSON[_0x37ee88(0x245)](_0x430111);let _0x4acdff=L(_0x430111['parent_task_id'],_0x37ee88(0x1ef)),_0x3add72=L(_0x430111[_0x37ee88(0x22e)],_0x37ee88(0x251)),_0x414faf=_0x430111['error_code']?_0x37ee88(0x219)+_0x430111['error_code']+':'+(_0x430111['error_message']??''):'';return _0x37ee88(0x228)+_0x430111[_0x37ee88(0x1fa)]+_0x37ee88(0x246)+L(_0x430111[_0x37ee88(0x22a)],_0x37ee88(0x244))+_0x37ee88(0x20b)+L(_0x430111[_0x37ee88(0x1f7)],_0x37ee88(0x244))+_0x37ee88(0x220)+_0x3add72+_0x37ee88(0x232)+_0x4acdff+_0x37ee88(0x1f5)+L(_0x430111['network_id'],_0x37ee88(0x244))+'\x20transport='+_0x430111[_0x37ee88(0x267)]+_0x37ee88(0x239)+_0x430111['duration_ms']+_0x37ee88(0x211)+_0x430111[_0x37ee88(0x204)]+_0x414faf;}function U(_0x1745a2){const _0x59ecd6=a0_0x48272b;return{'event':{'sending':_0x59ecd6(0x206),'delivered':_0x59ecd6(0x1f9),'failed':_0x59ecd6(0x1f2),'acked':_0x59ecd6(0x250),'started':_0x59ecd6(0x24e),'replied':'task.replied','expired':_0x59ecd6(0x1ee)}[_0x1745a2[_0x59ecd6(0x1fa)]],..._0x1745a2};}function a0_0x4f75(){const _0x3c7394=['name','heartbeatInterval','task.started','88qkXYlc','task.ack','<pending>','min','connectSSE','2.0','toString','getAllStatus','now','[REDACTED]','split','send_message','autoConnect','tools/call','catch','fromAlias','send','slice','application/json,\x20text/event-stream','27DpQXWL','541110YVYbgL','getReader','call','startsWith','transport','error','send_reply','result','task.expired','<missing>','idle','/mcp','task.send.failed','failed','completed','\x20network_id=','running','to_alias','log','task.send.delivered','status','type','resumeId','ack_inbox',']\x20[commhub:','80dPvtXV','task','sseAbort','read','lifecycleTracking','lifecycle_tracking','normal','task.send.start','alias','offline','message_id','report_status','\x20to=','send_rejected','CommHub\x20response\x20omitted\x20task_id','agent','broadcast','mcp_http','\x20lifecycle=','heartbeat\x20failed:\x20','Authorization','3354704AKYsOD','content','data:\x20','processInbox','toTimeString','\x20error=','send_task','new_message','connected','decode','SSE\x20failed:\x20','parentTaskId','\x20task_id=','disconnected','body','url','SSE\x20connected','1383540mYhJmK','connect','Bearer\x20','[commhub:task]\x20','41589tbyqgw','from_alias','token','5114235OYgWUU','signal','task_id','reconnectDelay','replace','get_inbox','\x20parent_task_id=','pop','heartbeatTimer','application/json','unknown\x20error','server','emit','\x20duration_ms=','delivered','json','networkId','sleep','inbox\x20error:\x20','get_all_status','518624iOrovF','text','98767TaVubW','/events/','<unknown>','stringify','\x20from=','parse','message','text/event-stream','sdk','toAlias'];a0_0x4f75=function(){return _0x3c7394;};return a0_0x4f75();}function j(_0xef2634){const _0xc62a7d=a0_0x48272b;let _0xcd4873=_0xef2634?.[_0xc62a7d(0x22e)]||_0xef2634?.[_0xc62a7d(0x209)]||_0xef2634?.['id'];if(_0xcd4873)return String(_0xcd4873);let _0x5cd0b5=_0xef2634?.[_0xc62a7d(0x215)]?.[0x0]?.['text'];if(typeof _0x5cd0b5!=='string')return null;try{let _0x36edf7=JSON['parse'](_0x5cd0b5);return _0x36edf7?.[_0xc62a7d(0x22e)]||_0x36edf7?.[_0xc62a7d(0x209)]||_0x36edf7?.['id']||null;}catch{return null;}}async function X(_0xfad233,_0x4feb00){const _0x4f15f1=a0_0x48272b;let _0x4f3335=_0x4feb00['now']??Date[_0x4f15f1(0x257)],_0x13b6c2=_0x4f3335(),_0x45e6fd=(_0xc4ef21,_0x5491ad,_0x9e9b6d,_0x10b7d8)=>{const _0x142824=_0x4f15f1;_0x4feb00[_0x142824(0x1f8)](O(U({'from_alias':_0xfad233[_0x142824(0x25e)],'to_alias':_0xfad233[_0x142824(0x24b)],'task_id':_0x5491ad,'parent_task_id':_0xfad233[_0x142824(0x21f)],'network_id':_0xfad233[_0x142824(0x23c)],'transport':_0xfad233[_0x142824(0x267)],'status':_0xc4ef21,'duration_ms':_0x4f3335()-_0x13b6c2,'lifecycle_tracking':_0xfad233[_0x142824(0x203)],..._0x9e9b6d!==void 0x0?{'error_code':_0x10b7d8||'send_failed','error_message':N(_0x9e9b6d)}:{}})));};_0x45e6fd('sending',null);try{let _0x26e393=await _0x4feb00[_0x4f15f1(0x25f)](),_0xc48db5=j(_0x26e393);if(_0xc48db5)_0x45e6fd(_0x4f15f1(0x23a),_0xc48db5);else{if(_0x26e393?.['ok']===!0x1||_0x26e393?.[_0x4f15f1(0x268)])_0x45e6fd(_0x4f15f1(0x1f3),_0xc48db5,_0x26e393?.[_0x4f15f1(0x268)]||'CommHub\x20rejected\x20task',_0x4f15f1(0x20c));else _0x45e6fd('failed',null,_0x4f15f1(0x20d),'missing_task_id');}return _0x26e393;}catch(_0x5e4fa3){throw _0x45e6fd(_0x4f15f1(0x1f3),null,_0x5e4fa3,'send_failed'),_0x5e4fa3;}}async function Y(_0x130bf6,_0x45cf15){const _0x8fe689=a0_0x48272b;return X({'fromAlias':_0x130bf6[_0x8fe689(0x25e)],'toAlias':_0x130bf6[_0x8fe689(0x207)],'parentTaskId':_0x130bf6[_0x8fe689(0x21f)]||null,'networkId':_0x130bf6[_0x8fe689(0x23c)]||null,'transport':_0x8fe689(0x210),'lifecycleTracking':'not_tracked'},_0x45cf15);}class $ extends a0_0x5582f2{['url'];[a0_0x48272b(0x207)];['token'];[a0_0x48272b(0x20e)];['resumeId'];[a0_0x48272b(0x24d)];[a0_0x48272b(0x22f)];[a0_0x48272b(0x234)];[a0_0x48272b(0x201)];[a0_0x48272b(0x1f6)]=!0x1;constructor(_0x9168e9){const _0x3cee55=a0_0x48272b;super();if(this['url']=_0x9168e9[_0x3cee55(0x223)][_0x3cee55(0x230)](/\/$/,''),this[_0x3cee55(0x207)]=_0x9168e9[_0x3cee55(0x207)],this[_0x3cee55(0x22b)]=_0x9168e9[_0x3cee55(0x22b)],this[_0x3cee55(0x20e)]=_0x9168e9[_0x3cee55(0x20e)]||_0x3cee55(0x24a),this[_0x3cee55(0x1fc)]='sdk-'+_0x9168e9[_0x3cee55(0x207)]+'-'+Date[_0x3cee55(0x257)]()[_0x3cee55(0x255)](0x24),this[_0x3cee55(0x24d)]=_0x9168e9[_0x3cee55(0x24d)]??0x2bf20,this[_0x3cee55(0x22f)]=_0x9168e9[_0x3cee55(0x22f)]??0xbb8,_0x9168e9[_0x3cee55(0x25b)]!==!0x1)this[_0x3cee55(0x226)]();}[a0_0x48272b(0x1f8)](_0x16c4a2){const _0x3f1fd5=a0_0x48272b;console[_0x3f1fd5(0x1f8)]('['+new Date()[_0x3f1fd5(0x218)]()['slice'](0x0,0x8)+_0x3f1fd5(0x1fe)+this['alias']+']\x20'+_0x16c4a2);}async[a0_0x48272b(0x265)](_0x3e61ec,_0x213d75){const _0x3a5cb0=a0_0x48272b;let _0x2fd48e={'Content-Type':_0x3a5cb0(0x235),'Accept':_0x3a5cb0(0x261)};if(this[_0x3a5cb0(0x22b)])_0x2fd48e['Authorization']=_0x3a5cb0(0x227)+this[_0x3a5cb0(0x22b)];let _0x103818=await(await fetch(this[_0x3a5cb0(0x223)]+_0x3a5cb0(0x1f1),{'method':'POST','headers':_0x2fd48e,'body':JSON[_0x3a5cb0(0x245)]({'jsonrpc':_0x3a5cb0(0x254),'id':Date[_0x3a5cb0(0x257)](),'method':_0x3a5cb0(0x25c),'params':{'name':_0x3e61ec,'arguments':_0x213d75}})}))[_0x3a5cb0(0x241)](),_0x5c0b84=_0x103818['match'](/data: (.+)/),_0x1831f2=_0x5c0b84?JSON[_0x3a5cb0(0x247)](_0x5c0b84[0x1]):JSON[_0x3a5cb0(0x247)](_0x103818),_0x2be163=_0x1831f2?.[_0x3a5cb0(0x1ed)]?.[_0x3a5cb0(0x215)]?.[0x0]?.[_0x3a5cb0(0x241)];return _0x2be163?JSON[_0x3a5cb0(0x247)](_0x2be163):_0x1831f2;}async[a0_0x48272b(0x226)](){const _0x4f17af=a0_0x48272b;if(this[_0x4f17af(0x1f6)])return;this[_0x4f17af(0x1f6)]=!0x0,await this[_0x4f17af(0x1fa)](_0x4f17af(0x1f0)),this['log']('registered'),this[_0x4f17af(0x234)]=setInterval(()=>{const _0x37bccc=_0x4f17af;this['status']('idle')['catch'](_0x52e170=>this[_0x37bccc(0x1f8)](_0x37bccc(0x212)+_0x52e170['message']));},this[_0x4f17af(0x24d)]),this[_0x4f17af(0x253)]();}async['disconnect'](){const _0x3164cc=a0_0x48272b;if(this[_0x3164cc(0x1f6)]=!0x1,this['sseAbort']?.['abort'](),this[_0x3164cc(0x234)])clearInterval(this['heartbeatTimer']);await this[_0x3164cc(0x1fa)](_0x3164cc(0x208))[_0x3164cc(0x25d)](()=>{}),this['log']('disconnected');}async[a0_0x48272b(0x25f)](_0x19d492,_0x51f329,_0x332591=a0_0x48272b(0x205)){const _0x6db59b=a0_0x48272b;return Y({'alias':_0x19d492,'fromAlias':this['alias']},{'log':_0x427ec5=>console[_0x6db59b(0x1f8)](_0x427ec5),'send':()=>this[_0x6db59b(0x265)](_0x6db59b(0x21a),{'alias':_0x19d492,'task':_0x51f329,'priority':_0x332591,'from_session':this[_0x6db59b(0x207)]})});}async['message'](_0x11f237,_0x527b95){const _0x4c312b=a0_0x48272b;return this['call'](_0x4c312b(0x25a),{'alias':_0x11f237,'message':_0x527b95,'from_session':this[_0x4c312b(0x207)]});}async['reply'](_0xb6822d,_0x4032f4,_0x55a2e0=a0_0x48272b(0x1f4)){const _0x20f505=a0_0x48272b;return this['call'](_0x20f505(0x269),{'in_reply_to':_0xb6822d,'text':_0x4032f4,'status':_0x55a2e0});}async[a0_0x48272b(0x1fa)](_0xdcd44d,_0xd200e7){const _0x16ca54=a0_0x48272b;return this[_0x16ca54(0x265)](_0x16ca54(0x20a),{'resume_id':this['resumeId'],'alias':this['alias'],'status':_0xdcd44d,'server':a0_0x56836f(),'hostname':a0_0x56836f(),'agent':this[_0x16ca54(0x20e)],'project_dir':process['cwd'](),..._0xd200e7});}async[a0_0x48272b(0x256)](){const _0x27abd0=a0_0x48272b;return this['call'](_0x27abd0(0x23f),{});}async[a0_0x48272b(0x20f)](_0x2f8faf,_0xd49d11){const _0x2136d8=a0_0x48272b;return this[_0x2136d8(0x265)]('broadcast',{'message':_0x2f8faf,'filter_server':_0xd49d11?.[_0x2136d8(0x237)],'filter_status':_0xd49d11?.[_0x2136d8(0x1fa)]});}async[a0_0x48272b(0x253)](){const _0x497fbb=a0_0x48272b;let _0x5f3279=encodeURIComponent(this[_0x497fbb(0x207)]),_0x19cb7d=this[_0x497fbb(0x223)]+_0x497fbb(0x243)+_0x5f3279,_0x3e2421=this[_0x497fbb(0x22f)];while(this[_0x497fbb(0x1f6)]){try{this[_0x497fbb(0x201)]=new AbortController();let _0x352782={'Accept':_0x497fbb(0x249)};if(this[_0x497fbb(0x22b)])_0x352782[_0x497fbb(0x213)]=_0x497fbb(0x227)+this['token'];let _0x30033=await fetch(_0x19cb7d,{'headers':_0x352782,'signal':this['sseAbort'][_0x497fbb(0x22d)]});if(!_0x30033['ok']||!_0x30033[_0x497fbb(0x222)]){this[_0x497fbb(0x1f8)](_0x497fbb(0x21e)+_0x30033['status']),await this[_0x497fbb(0x23d)](_0x3e2421),_0x3e2421=Math[_0x497fbb(0x252)](_0x3e2421*1.5,0xea60);continue;}_0x3e2421=this[_0x497fbb(0x22f)];let _0x2a0e20=_0x30033['body'][_0x497fbb(0x264)](),_0x189b3d=new TextDecoder(),_0x3f75e3='';while(this[_0x497fbb(0x1f6)]){let {done:_0x1a583b,value:_0x119e48}=await _0x2a0e20[_0x497fbb(0x202)]();if(_0x1a583b)break;_0x3f75e3+=_0x189b3d[_0x497fbb(0x21d)](_0x119e48,{'stream':!0x0});let _0x144efc=_0x3f75e3[_0x497fbb(0x259)]('\x0a');_0x3f75e3=_0x144efc[_0x497fbb(0x233)]()||'';for(let _0x5c2778 of _0x144efc){if(!_0x5c2778[_0x497fbb(0x266)](_0x497fbb(0x216)))continue;try{let _0x2d5dd3=JSON['parse'](_0x5c2778[_0x497fbb(0x260)](0x6));if(_0x2d5dd3['type']===_0x497fbb(0x21c)){this[_0x497fbb(0x1f8)](_0x497fbb(0x224)),this[_0x497fbb(0x238)](_0x497fbb(0x21c));continue;}if(_0x2d5dd3[_0x497fbb(0x1fb)]==='new_task'||_0x2d5dd3[_0x497fbb(0x1fb)]===_0x497fbb(0x21b)||_0x2d5dd3[_0x497fbb(0x1fb)]===_0x497fbb(0x20f))await this[_0x497fbb(0x217)]();}catch{}}}}catch(_0x234b32){if(_0x234b32[_0x497fbb(0x24c)]==='AbortError')break;this[_0x497fbb(0x238)](_0x497fbb(0x268),_0x234b32),this['log']('SSE\x20error:\x20'+_0x234b32[_0x497fbb(0x248)]);}if(this[_0x497fbb(0x1f6)])this[_0x497fbb(0x238)](_0x497fbb(0x221)),this[_0x497fbb(0x1f8)]('SSE\x20reconnecting\x20in\x20'+_0x3e2421/0x3e8+'s...'),await this[_0x497fbb(0x23d)](_0x3e2421),_0x3e2421=Math['min'](_0x3e2421*1.5,0xea60);}}async['processInbox'](){const _0x5473b0=a0_0x48272b;try{let _0x49d8ca=(await this[_0x5473b0(0x265)](_0x5473b0(0x231),{'alias':this[_0x5473b0(0x207)],'limit':0xa}))?.['messages']||[];for(let _0x5554a2 of _0x49d8ca)await this['call'](_0x5473b0(0x1fd),{'alias':this[_0x5473b0(0x207)],'message_id':_0x5554a2['id']}),this['log']('←\x20'+_0x5554a2['from_session']+':\x20'+_0x5554a2[_0x5473b0(0x215)][_0x5473b0(0x260)](0x0,0x3c)),this['emit'](_0x5473b0(0x200),_0x5554a2),this[_0x5473b0(0x238)](_0x5473b0(0x248),_0x5554a2);}catch(_0x2729c7){this['log'](_0x5473b0(0x23e)+_0x2729c7[_0x5473b0(0x248)]);}}['sleep'](_0x235230){return new Promise(_0x47d8e1=>setTimeout(_0x47d8e1,_0x235230));}}function a0_0x4270(_0x32b12a,_0x15415d){_0x32b12a=_0x32b12a-0x1ed;const _0x4f750b=a0_0x4f75();let _0x427085=_0x4f750b[_0x32b12a];return _0x427085;}var F=$;export{F as default,$ as CommHub};
1
+ const a0_0x201ef5=a0_0x4006;(function(_0x72921b,_0x413af7){const _0x175ee8=a0_0x4006,_0x42b67e=_0x72921b();while(!![]){try{const _0x2aa7c4=parseInt(_0x175ee8(0xe6))/0x1+-parseInt(_0x175ee8(0x7f))/0x2*(-parseInt(_0x175ee8(0xa6))/0x3)+-parseInt(_0x175ee8(0xeb))/0x4+parseInt(_0x175ee8(0xba))/0x5+parseInt(_0x175ee8(0x8d))/0x6+parseInt(_0x175ee8(0x90))/0x7*(-parseInt(_0x175ee8(0xca))/0x8)+-parseInt(_0x175ee8(0xa4))/0x9;if(_0x2aa7c4===_0x413af7)break;else _0x42b67e['push'](_0x42b67e['shift']());}catch(_0x365aef){_0x42b67e['push'](_0x42b67e['shift']());}}}(a0_0x75ed,0xdc2e0));import{EventEmitter as a0_0x519a93}from'events';import{hostname as a0_0xec13ab}from'os';function a0_0x4006(_0x2fb5fe,_0x2c624c){_0x2fb5fe=_0x2fb5fe-0x7f;const _0x75edec=a0_0x75ed();let _0x400615=_0x75edec[_0x2fb5fe];return _0x400615;}var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x59027c,_0x3198e5)=>(_0x59027c??_0x3198e5)[a0_0x201ef5(0x97)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x201ef5(0xb1)](0x0,0xf0);function N(_0x3aad14){const _0x2c4d61=a0_0x201ef5;return(_0x3aad14 instanceof Error?_0x3aad14[_0x2c4d61(0xd9)]:String(_0x3aad14??_0x2c4d61(0xdf)))[_0x2c4d61(0x97)](K,_0x2c4d61(0xee))[_0x2c4d61(0x97)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0xb17fa7,_0x8841d9=process.env.ANET_TASK_TRACE_FORMAT===a0_0x201ef5(0xbe)){const _0x489d1e=a0_0x201ef5;if(_0x8841d9)return JSON[_0x489d1e(0xd1)](_0xb17fa7);let _0x2c3336=L(_0xb17fa7[_0x489d1e(0x8f)],'<missing>'),_0x3c6f57=L(_0xb17fa7[_0x489d1e(0xd7)],_0x489d1e(0xd8)),_0x3cb598=_0xb17fa7[_0x489d1e(0x88)]?_0x489d1e(0xc0)+_0xb17fa7[_0x489d1e(0x88)]+':'+(_0xb17fa7['error_message']??''):'';return'[commhub:task]\x20'+_0xb17fa7['status']+_0x489d1e(0x9c)+L(_0xb17fa7['from_alias'],'<unknown>')+_0x489d1e(0x9b)+L(_0xb17fa7[_0x489d1e(0xc2)],'<unknown>')+'\x20task_id='+_0x3c6f57+_0x489d1e(0xc9)+_0x2c3336+_0x489d1e(0x9e)+L(_0xb17fa7[_0x489d1e(0x96)],_0x489d1e(0xb5))+_0x489d1e(0x9f)+_0xb17fa7[_0x489d1e(0xad)]+'\x20duration_ms='+_0xb17fa7[_0x489d1e(0xb0)]+'\x20lifecycle='+_0xb17fa7[_0x489d1e(0xcc)]+_0x3cb598;}function U(_0x4142ca){const _0xffbf38=a0_0x201ef5;return{'event':{'sending':_0xffbf38(0xb9),'delivered':_0xffbf38(0xdc),'failed':_0xffbf38(0xef),'acked':'task.ack','started':_0xffbf38(0xe1),'replied':_0xffbf38(0xb8),'expired':_0xffbf38(0xa1)}[_0x4142ca[_0xffbf38(0xe0)]],..._0x4142ca};}function j(_0x1d4bd3){const _0x5c3a31=a0_0x201ef5;let _0x64f346=_0x1d4bd3?.[_0x5c3a31(0xd7)]||_0x1d4bd3?.[_0x5c3a31(0xb3)]||_0x1d4bd3?.['id'];if(_0x64f346)return String(_0x64f346);let _0x27d308=_0x1d4bd3?.[_0x5c3a31(0xe9)]?.[0x0]?.['text'];if(typeof _0x27d308!==_0x5c3a31(0x8a))return null;try{let _0x143880=JSON['parse'](_0x27d308);return _0x143880?.[_0x5c3a31(0xd7)]||_0x143880?.[_0x5c3a31(0xb3)]||_0x143880?.['id']||null;}catch{return null;}}function a0_0x75ed(){const _0x4741b6=['CommHub\x20response\x20omitted\x20task_id','data:\x20','heartbeatInterval','alias','stringify','lifecycleTracking','emit','signal','token','running','task_id','<pending>','message','from_session','log','task.send.delivered','fromAlias','Authorization','unknown\x20error','status','task.started','CommHub\x20rejected\x20task','parse','error','POST','601813HYJjzX','registered','sseAbort','content','resumeId','5667628ezIEQD','2.0','failed','[REDACTED]','task.send.failed','networkId','394GlSesT','result','reply','task','s...','type','toTimeString','/mcp','send_failed','error_code','reconnectDelay','string','not_tracked','disconnect','9382710bGKQDp','pop','parent_task_id','3403806iGdtSt','send_reply','name','AbortError','new_task','send_task','network_id','replace','offline','call','Bearer\x20','\x20to=','\x20from=','completed','\x20network_id=','\x20transport=','parentTaskId','task.expired','heartbeatTimer','idle','19660770LtwaZb','sdk-','16449cTFlMU','/events/','toString','now','connect','split','agent','transport','abort','match','duration_ms','slice','sleep','message_id','application/json','<unknown>','SSE\x20error:\x20','server','task.replied','task.send.start','8719010OEkLHx','disconnected','connectSSE','min','json','send_message','\x20error=','normal','to_alias','text/event-stream','getAllStatus','send','processInbox','url','SSE\x20reconnecting\x20in\x20','\x20parent_task_id=','8pbvRWE','broadcast','lifecycle_tracking'];a0_0x75ed=function(){return _0x4741b6;};return a0_0x75ed();}async function X(_0xe254d7,_0x1f591f){const _0x41a39a=a0_0x201ef5;let _0x4094ca=_0x1f591f['now']??Date[_0x41a39a(0xa9)],_0x3992fc=_0x4094ca(),_0x2688f2=(_0x19a154,_0x4a7f77,_0xc44c7f,_0x12379a)=>{const _0x1f65bc=_0x41a39a;_0x1f591f['log'](O(U({'from_alias':_0xe254d7[_0x1f65bc(0xdd)],'to_alias':_0xe254d7['toAlias'],'task_id':_0x4a7f77,'parent_task_id':_0xe254d7[_0x1f65bc(0xa0)],'network_id':_0xe254d7[_0x1f65bc(0xf0)],'transport':_0xe254d7['transport'],'status':_0x19a154,'duration_ms':_0x4094ca()-_0x3992fc,'lifecycle_tracking':_0xe254d7[_0x1f65bc(0xd2)],..._0xc44c7f!==void 0x0?{'error_code':_0x12379a||_0x1f65bc(0x87),'error_message':N(_0xc44c7f)}:{}})));};_0x2688f2('sending',null);try{let _0x4b1610=await _0x1f591f[_0x41a39a(0xc5)](),_0x351c58=j(_0x4b1610);if(_0x351c58)_0x2688f2('delivered',_0x351c58);else{if(_0x4b1610?.['ok']===!0x1||_0x4b1610?.[_0x41a39a(0xe4)])_0x2688f2('failed',_0x351c58,_0x4b1610?.[_0x41a39a(0xe4)]||_0x41a39a(0xe2),'send_rejected');else _0x2688f2(_0x41a39a(0xed),null,_0x41a39a(0xcd),'missing_task_id');}return _0x4b1610;}catch(_0xef0fbf){throw _0x2688f2('failed',null,_0xef0fbf,'send_failed'),_0xef0fbf;}}async function Y(_0x5e7684,_0x2cd395){const _0x11f573=a0_0x201ef5;return X({'fromAlias':_0x5e7684[_0x11f573(0xdd)],'toAlias':_0x5e7684[_0x11f573(0xd0)],'parentTaskId':_0x5e7684[_0x11f573(0xa0)]||null,'networkId':_0x5e7684[_0x11f573(0xf0)]||null,'transport':'mcp_http','lifecycleTracking':_0x11f573(0x8b)},_0x2cd395);}class $ extends a0_0x519a93{[a0_0x201ef5(0xc7)];[a0_0x201ef5(0xd0)];[a0_0x201ef5(0xd5)];[a0_0x201ef5(0xac)];['resumeId'];[a0_0x201ef5(0xcf)];[a0_0x201ef5(0x89)];['heartbeatTimer'];['sseAbort'];[a0_0x201ef5(0xd6)]=!0x1;constructor(_0x5aaa80){const _0x437422=a0_0x201ef5;super();if(this['url']=_0x5aaa80['url']['replace'](/\/$/,''),this[_0x437422(0xd0)]=_0x5aaa80[_0x437422(0xd0)],this['token']=_0x5aaa80[_0x437422(0xd5)],this[_0x437422(0xac)]=_0x5aaa80[_0x437422(0xac)]||'sdk',this[_0x437422(0xea)]=_0x437422(0xa5)+_0x5aaa80[_0x437422(0xd0)]+'-'+Date[_0x437422(0xa9)]()[_0x437422(0xa8)](0x24),this['heartbeatInterval']=_0x5aaa80['heartbeatInterval']??0x2bf20,this[_0x437422(0x89)]=_0x5aaa80[_0x437422(0x89)]??0xbb8,_0x5aaa80['autoConnect']!==!0x1)this['connect']();}[a0_0x201ef5(0xdb)](_0x5acda0){const _0x494c8f=a0_0x201ef5;console[_0x494c8f(0xdb)]('['+new Date()[_0x494c8f(0x85)]()[_0x494c8f(0xb1)](0x0,0x8)+']\x20[commhub:'+this[_0x494c8f(0xd0)]+']\x20'+_0x5acda0);}async[a0_0x201ef5(0x99)](_0x5dcf2c,_0x290b41){const _0x5f5969=a0_0x201ef5;let _0x5cf61f={'Content-Type':_0x5f5969(0xb4),'Accept':'application/json,\x20text/event-stream'};if(this[_0x5f5969(0xd5)])_0x5cf61f[_0x5f5969(0xde)]=_0x5f5969(0x9a)+this[_0x5f5969(0xd5)];let _0x4cfde6=await(await fetch(this['url']+_0x5f5969(0x86),{'method':_0x5f5969(0xe5),'headers':_0x5cf61f,'body':JSON[_0x5f5969(0xd1)]({'jsonrpc':_0x5f5969(0xec),'id':Date[_0x5f5969(0xa9)](),'method':'tools/call','params':{'name':_0x5dcf2c,'arguments':_0x290b41}})}))['text'](),_0x584f66=_0x4cfde6[_0x5f5969(0xaf)](/data: (.+)/),_0x28cc34=_0x584f66?JSON[_0x5f5969(0xe3)](_0x584f66[0x1]):JSON['parse'](_0x4cfde6),_0x3834bd=_0x28cc34?.[_0x5f5969(0x80)]?.[_0x5f5969(0xe9)]?.[0x0]?.['text'];return _0x3834bd?JSON[_0x5f5969(0xe3)](_0x3834bd):_0x28cc34;}async[a0_0x201ef5(0xaa)](){const _0x2fc055=a0_0x201ef5;if(this[_0x2fc055(0xd6)])return;this['running']=!0x0,await this[_0x2fc055(0xe0)](_0x2fc055(0xa3)),this[_0x2fc055(0xdb)](_0x2fc055(0xe7)),this[_0x2fc055(0xa2)]=setInterval(()=>{const _0xe28570=_0x2fc055;this['status'](_0xe28570(0xa3))['catch'](_0x4a3b3e=>this['log']('heartbeat\x20failed:\x20'+_0x4a3b3e[_0xe28570(0xd9)]));},this['heartbeatInterval']),this[_0x2fc055(0xbc)]();}async[a0_0x201ef5(0x8c)](){const _0x189f20=a0_0x201ef5;if(this[_0x189f20(0xd6)]=!0x1,this[_0x189f20(0xe8)]?.[_0x189f20(0xae)](),this[_0x189f20(0xa2)])clearInterval(this[_0x189f20(0xa2)]);await this['status'](_0x189f20(0x98))['catch'](()=>{}),this[_0x189f20(0xdb)]('disconnected');}async['send'](_0x49a76a,_0x110232,_0x2de63d=a0_0x201ef5(0xc1)){const _0x42ab62=a0_0x201ef5;return Y({'alias':_0x49a76a,'fromAlias':this['alias']},{'log':_0x18aeaa=>console[_0x42ab62(0xdb)](_0x18aeaa),'send':()=>this['call'](_0x42ab62(0x95),{'alias':_0x49a76a,'task':_0x110232,'priority':_0x2de63d,'from_session':this[_0x42ab62(0xd0)]})});}async[a0_0x201ef5(0xd9)](_0x1a7e98,_0x4c9fed){const _0x3298ed=a0_0x201ef5;return this['call'](_0x3298ed(0xbf),{'alias':_0x1a7e98,'message':_0x4c9fed,'from_session':this[_0x3298ed(0xd0)]});}async[a0_0x201ef5(0x81)](_0x5dfeff,_0x54c264,_0x1ba680=a0_0x201ef5(0x9d)){const _0x379ad9=a0_0x201ef5;return this[_0x379ad9(0x99)](_0x379ad9(0x91),{'in_reply_to':_0x5dfeff,'text':_0x54c264,'status':_0x1ba680});}async[a0_0x201ef5(0xe0)](_0x2f96f3,_0x37110c){const _0x173ecb=a0_0x201ef5;return this[_0x173ecb(0x99)]('report_status',{'resume_id':this[_0x173ecb(0xea)],'alias':this[_0x173ecb(0xd0)],'status':_0x2f96f3,'server':a0_0xec13ab(),'hostname':a0_0xec13ab(),'agent':this['agent'],'project_dir':process['cwd'](),..._0x37110c});}async[a0_0x201ef5(0xc4)](){const _0x54a950=a0_0x201ef5;return this[_0x54a950(0x99)]('get_all_status',{});}async[a0_0x201ef5(0xcb)](_0x499070,_0x43f84d){const _0x3e8601=a0_0x201ef5;return this[_0x3e8601(0x99)](_0x3e8601(0xcb),{'message':_0x499070,'filter_server':_0x43f84d?.[_0x3e8601(0xb7)],'filter_status':_0x43f84d?.['status']});}async[a0_0x201ef5(0xbc)](){const _0x24a59a=a0_0x201ef5;let _0x41d80e=encodeURIComponent(this['alias']),_0x5a84bf=this[_0x24a59a(0xc7)]+_0x24a59a(0xa7)+_0x41d80e,_0x532f69=this['reconnectDelay'];while(this[_0x24a59a(0xd6)]){try{this['sseAbort']=new AbortController();let _0x61455a={'Accept':_0x24a59a(0xc3)};if(this[_0x24a59a(0xd5)])_0x61455a[_0x24a59a(0xde)]=_0x24a59a(0x9a)+this[_0x24a59a(0xd5)];let _0x32fb69=await fetch(_0x5a84bf,{'headers':_0x61455a,'signal':this['sseAbort'][_0x24a59a(0xd4)]});if(!_0x32fb69['ok']||!_0x32fb69['body']){this[_0x24a59a(0xdb)]('SSE\x20failed:\x20'+_0x32fb69['status']),await this['sleep'](_0x532f69),_0x532f69=Math[_0x24a59a(0xbd)](_0x532f69*1.5,0xea60);continue;}_0x532f69=this['reconnectDelay'];let _0x364de0=_0x32fb69['body']['getReader'](),_0x102c31=new TextDecoder(),_0x3b01e2='';while(this[_0x24a59a(0xd6)]){let {done:_0x37a74c,value:_0x47c135}=await _0x364de0['read']();if(_0x37a74c)break;_0x3b01e2+=_0x102c31['decode'](_0x47c135,{'stream':!0x0});let _0x29baa3=_0x3b01e2[_0x24a59a(0xab)]('\x0a');_0x3b01e2=_0x29baa3[_0x24a59a(0x8e)]()||'';for(let _0x2604b7 of _0x29baa3){if(!_0x2604b7['startsWith'](_0x24a59a(0xce)))continue;try{let _0x3baa81=JSON[_0x24a59a(0xe3)](_0x2604b7['slice'](0x6));if(_0x3baa81['type']==='connected'){this[_0x24a59a(0xdb)]('SSE\x20connected'),this[_0x24a59a(0xd3)]('connected');continue;}if(_0x3baa81['type']===_0x24a59a(0x94)||_0x3baa81['type']==='new_message'||_0x3baa81[_0x24a59a(0x84)]==='broadcast')await this[_0x24a59a(0xc6)]();}catch{}}}}catch(_0x50be44){if(_0x50be44[_0x24a59a(0x92)]===_0x24a59a(0x93))break;this[_0x24a59a(0xd3)](_0x24a59a(0xe4),_0x50be44),this[_0x24a59a(0xdb)](_0x24a59a(0xb6)+_0x50be44[_0x24a59a(0xd9)]);}if(this[_0x24a59a(0xd6)])this['emit'](_0x24a59a(0xbb)),this[_0x24a59a(0xdb)](_0x24a59a(0xc8)+_0x532f69/0x3e8+_0x24a59a(0x83)),await this['sleep'](_0x532f69),_0x532f69=Math[_0x24a59a(0xbd)](_0x532f69*1.5,0xea60);}}async['processInbox'](){const _0x45702f=a0_0x201ef5;try{let _0x2bf4f0=(await this['call']('get_inbox',{'alias':this[_0x45702f(0xd0)],'limit':0xa}))?.['messages']||[];for(let _0x37e832 of _0x2bf4f0)await this[_0x45702f(0x99)]('ack_inbox',{'alias':this['alias'],'message_id':_0x37e832['id']}),this[_0x45702f(0xdb)]('←\x20'+_0x37e832[_0x45702f(0xda)]+':\x20'+_0x37e832[_0x45702f(0xe9)][_0x45702f(0xb1)](0x0,0x3c)),this[_0x45702f(0xd3)](_0x45702f(0x82),_0x37e832),this[_0x45702f(0xd3)](_0x45702f(0xd9),_0x37e832);}catch(_0x152332){this[_0x45702f(0xdb)]('inbox\x20error:\x20'+_0x152332[_0x45702f(0xd9)]);}}[a0_0x201ef5(0xb2)](_0x342326){return new Promise(_0x1648d5=>setTimeout(_0x1648d5,_0x342326));}}var F=$;export{F as default,$ as CommHub};
@@ -0,0 +1,65 @@
1
+ export interface CodexHomeInheritedFile {
2
+ readonly name: string;
3
+ readonly mode: number;
4
+ /** Why a node needs it — printed when staged, so the action is legible. */
5
+ readonly because: string;
6
+ }
7
+ export declare const CODEX_HOME_INHERITED_FILES: readonly CodexHomeInheritedFile[];
8
+ export interface StatLike {
9
+ readonly mtimeMs: number;
10
+ }
11
+ export type StatFn = (path: string) => StatLike | null;
12
+ export interface CodexHomeStageStep {
13
+ readonly name: string;
14
+ readonly src: string;
15
+ readonly dst: string;
16
+ readonly mode: number;
17
+ readonly reason: "missing" | "host-newer";
18
+ readonly because: string;
19
+ }
20
+ /**
21
+ * What to copy from the host CODEX_HOME into the node's, right now.
22
+ *
23
+ * Pure: takes the stat function so the ordering rules are testable without a
24
+ * filesystem. A node file that is NEWER than the host's is left alone — codex
25
+ * refreshes its own copy in place, and clobbering it would throw away a fresher
26
+ * token than the one we hold.
27
+ */
28
+ export declare function codexHomeStagePlan(hostHome: string, nodeHome: string, stat: StatFn, join: (a: string, b: string) => string, files?: readonly CodexHomeInheritedFile[]): CodexHomeStageStep[];
29
+ export type CodexTuiBlocker = "sign-in" | "update-prompt" | "trust-prompt";
30
+ export type CodexTuiPaneState = CodexTuiBlocker | "not-painted" | "usable";
31
+ /**
32
+ * Classify the TUI, from two different reads of the same pane.
33
+ *
34
+ * They answer different questions and need different tmux flags — the same
35
+ * distinction `waitForTmuxPaneText` documents one screenful up:
36
+ *
37
+ * onScreen (capture-pane, no -S) → "is it sitting on a prompt right now"
38
+ * A prompt that was already answered stays in scrollback forever,
39
+ * so reading history here would report a fixed node as blocked.
40
+ *
41
+ * everSeen (capture-pane -S -N) → "did the TUI ever paint"
42
+ * The banner is printed once and scrolls away — an MCP error burst
43
+ * was enough to push it off screen in under a minute — so reading
44
+ * only the current screen here would report a working node as dead.
45
+ *
46
+ * 🔴 And "the pane has text" answers neither. An earlier version of this used
47
+ * "≥3 non-empty lines ⇒ ready" and passed a node parked on the sign-in page.
48
+ * Measured timeline for that start:
49
+ *
50
+ * t≈3s 22 non-empty lines ← launcher output, TUI not up yet
51
+ * t≈6s 0 non-empty lines ← codex clears the screen and takes over
52
+ * t≈9s 10 non-empty lines ← the sign-in page finally paints
53
+ *
54
+ * The rule fired at t≈3s, six seconds before the thing it was meant to catch
55
+ * existed.
56
+ */
57
+ export declare function codexTuiPaneState(onScreen: string, everSeen?: string): CodexTuiPaneState;
58
+ /**
59
+ * What the operator should read when a node came up but cannot work. Names the
60
+ * blocker AND where to look — a launcher that only says "not ready" sends
61
+ * someone hunting through three tmux sessions.
62
+ */
63
+ export declare function describeCodexTuiBlocker(blocker: CodexTuiBlocker, displayName: string, tuiSession: string): string;
64
+ /** The TUI never painted at all — a distinct failure from being blocked. */
65
+ export declare function describeCodexTuiNotPainted(displayName: string, tuiSession: string, waitedMs: number): string;
@@ -0,0 +1,68 @@
1
+ export interface CodexCopresenceProfileFields {
2
+ readonly runtime?: string;
3
+ readonly codexCopresence?: boolean;
4
+ readonly codexCopresenceFullAccess?: boolean;
5
+ readonly flags?: Record<string, unknown>;
6
+ }
7
+ export declare const CODEX_COPRESENCE_RUNTIME = "codex-app-server";
8
+ /**
9
+ * Should this `anet node start` bring up the co-presence stack?
10
+ *
11
+ * The flag still works for a one-off; the profile field is what makes the
12
+ * second start a single command.
13
+ */
14
+ export declare function codexCopresenceRequested(flagPassed: boolean, profile: CodexCopresenceProfileFields): boolean;
15
+ /**
16
+ * True when a plain `anet node start` just became enough for this node — i.e.
17
+ * the flag was passed and the profile had not recorded it yet. Callers persist
18
+ * `codexCopresence: true` and tell the user they can drop the flag.
19
+ */
20
+ export declare function shouldPersistCodexCopresence(flagPassed: boolean, profile: CodexCopresenceProfileFields): boolean;
21
+ export interface CodexCopresencePosture {
22
+ readonly sandboxMode: "danger-full-access" | "read-only";
23
+ readonly approvalPolicy: "never" | "on-request";
24
+ /** Set when the node asked for full access and is NOT getting it. */
25
+ readonly downgradeNotice?: string;
26
+ /** Set when a remembered grant (not this invocation's flag) opened it up. */
27
+ readonly grantedFromProfile: boolean;
28
+ }
29
+ /**
30
+ * Resolve the sandbox the co-presence app-server runs under.
31
+ *
32
+ * Precedence: this invocation's flag → a grant already recorded on the profile
33
+ * → read-only. `flags.sandboxMode` alone never opens the sandbox; it only
34
+ * decides whether staying closed is worth telling the user about.
35
+ */
36
+ export declare function codexCopresencePosture(dangerFlagPassed: boolean, profile: CodexCopresenceProfileFields, displayName?: string): CodexCopresencePosture;
37
+ /** True when an explicit grant should be written to the profile for next time. */
38
+ export declare function shouldPersistCodexFullAccess(dangerFlagPassed: boolean, profile: CodexCopresenceProfileFields): boolean;
39
+ /**
40
+ * What `anet node create --runtime codex-app-server` should record, so that a
41
+ * later `anet node start <name>` is a single command with no flag.
42
+ *
43
+ * Shape copied from opencode, which already does exactly this at create time:
44
+ *
45
+ * ...(runtime === "opencode-cli"
46
+ * ? { opencodeMode: opts.mode === "copresence" || opts.copresence === "true"
47
+ * ? "copresence" : "headless" }
48
+ * : {}),
49
+ *
50
+ * Deliberately NOT keyed on which alias the operator typed. `codex-tui`,
51
+ * `codex-appserver` and `codex-app-server` are documented as aliases of one
52
+ * runtime (agent-node/src/cli.ts); giving one of them a different default would
53
+ * quietly break that contract, and "I typed the short name" is not a reliable
54
+ * statement of intent. Opting in stays explicit, exactly as it is for opencode.
55
+ */
56
+ export declare function codexCopresenceCreateFields(normalizedRuntime: string | undefined, copresenceOpt: string | boolean | undefined): {
57
+ codexCopresence?: true;
58
+ };
59
+ /**
60
+ * One line at create time for a node that will start headless.
61
+ *
62
+ * NOT keyed on which alias the operator typed: by the time create builds the
63
+ * profile, `opts.runtime` has already been normalized to `codex-app-server`, so
64
+ * `codex-tui` is simply not recoverable here — a hint that tried to read it
65
+ * would never fire. (It didn't; that is how this was found.) Keying on the
66
+ * runtime instead also keeps the aliases true synonyms.
67
+ */
68
+ export declare function codexCopresenceCreateHint(normalizedRuntime: string | undefined, copresenceOpt: string | boolean | undefined, displayName: string): string | undefined;
@@ -0,0 +1,20 @@
1
+ export interface CopresenceDep {
2
+ readonly name: string;
3
+ readonly present: boolean;
4
+ /** Exact command for this platform, or null when we cannot name one. */
5
+ readonly install: string | null;
6
+ readonly why: string;
7
+ }
8
+ export type CommandProbe = (cmd: string) => boolean;
9
+ export declare function copresenceDeps(probe: CommandProbe, platform?: NodeJS.Platform): CopresenceDep[];
10
+ export declare function missingCopresenceDeps(probe: CommandProbe, platform?: NodeJS.Platform): CopresenceDep[];
11
+ /** One block naming every gap and how to close it — never one gap at a time. */
12
+ export declare function describeMissingDeps(missing: readonly CopresenceDep[], displayName: string): string;
13
+ /**
14
+ * May we start this hub ourselves?
15
+ *
16
+ * Only a loopback hub. A remote URL that refuses the connection is somebody
17
+ * else's service — spawning a local one would silently point the node at a
18
+ * DIFFERENT hub than its profile names, which is worse than failing.
19
+ */
20
+ export declare function isLoopbackHub(hubUrl: string): boolean;