@sleep2agi/agent-network 2.3.0-preview.45 → 2.3.0-preview.47

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_0x457c52=a0_0x538a;function a0_0x538a(_0xc62142,_0x22af78){_0xc62142=_0xc62142-0x184;const _0x1b2050=a0_0x1b20();let _0x538a85=_0x1b2050[_0xc62142];return _0x538a85;}(function(_0x1b4f79,_0x4952c0){const _0x2bcf26=a0_0x538a,_0x463903=_0x1b4f79();while(!![]){try{const _0x49bdb5=parseInt(_0x2bcf26(0x1af))/0x1+-parseInt(_0x2bcf26(0x19a))/0x2+-parseInt(_0x2bcf26(0x1ad))/0x3+parseInt(_0x2bcf26(0x19d))/0x4+-parseInt(_0x2bcf26(0x1da))/0x5+parseInt(_0x2bcf26(0x18f))/0x6*(-parseInt(_0x2bcf26(0x1ec))/0x7)+parseInt(_0x2bcf26(0x1ea))/0x8;if(_0x49bdb5===_0x4952c0)break;else _0x463903['push'](_0x463903['shift']());}catch(_0xe7a56a){_0x463903['push'](_0x463903['shift']());}}}(a0_0x1b20,0xdad3e));import{EventEmitter as a0_0x1d8d91}from'events';import{hostname as a0_0x4fc7ca}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x3ae98f,_0x47ba03)=>(_0x3ae98f??_0x47ba03)[a0_0x457c52(0x1c4)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x243450){const _0x16ec74=a0_0x457c52;return(_0x243450 instanceof Error?_0x243450[_0x16ec74(0x1a2)]:String(_0x243450??_0x16ec74(0x1c8)))[_0x16ec74(0x1c4)](K,'[REDACTED]')[_0x16ec74(0x1c4)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x37a47a,_0x16afdf=process.env.ANET_TASK_TRACE_FORMAT===a0_0x457c52(0x1eb)){const _0x2be35b=a0_0x457c52;if(_0x16afdf)return JSON[_0x2be35b(0x197)](_0x37a47a);let _0x6d764a=L(_0x37a47a[_0x2be35b(0x1d6)],_0x2be35b(0x205)),_0x401e97=L(_0x37a47a[_0x2be35b(0x1d8)],_0x2be35b(0x18c)),_0x35606b=_0x37a47a[_0x2be35b(0x1cb)]?_0x2be35b(0x1d9)+_0x37a47a[_0x2be35b(0x1cb)]+':'+(_0x37a47a[_0x2be35b(0x1ff)]??''):'';return _0x2be35b(0x1ca)+_0x37a47a[_0x2be35b(0x1dc)]+'\x20from='+L(_0x37a47a[_0x2be35b(0x1fe)],'<unknown>')+_0x2be35b(0x193)+L(_0x37a47a[_0x2be35b(0x196)],_0x2be35b(0x19b))+_0x2be35b(0x203)+_0x401e97+_0x2be35b(0x1fc)+_0x6d764a+_0x2be35b(0x1cf)+L(_0x37a47a[_0x2be35b(0x201)],_0x2be35b(0x19b))+_0x2be35b(0x1f8)+_0x37a47a['transport']+'\x20duration_ms='+_0x37a47a['duration_ms']+_0x2be35b(0x1ee)+_0x37a47a[_0x2be35b(0x1fa)]+_0x35606b;}function U(_0x3d580f){const _0x22b5ef=a0_0x457c52;return{'event':{'sending':_0x22b5ef(0x1f0),'delivered':_0x22b5ef(0x1cc),'failed':_0x22b5ef(0x1e9),'acked':_0x22b5ef(0x1de),'started':_0x22b5ef(0x1e3),'replied':_0x22b5ef(0x1a0),'expired':'task.expired'}[_0x3d580f['status']],..._0x3d580f};}function j(_0x393337){const _0x2af100=a0_0x457c52;let _0x1d0144=_0x393337?.['task_id']||_0x393337?.[_0x2af100(0x1c9)]||_0x393337?.['id'];if(_0x1d0144)return String(_0x1d0144);let _0x1df658=_0x393337?.['content']?.[0x0]?.[_0x2af100(0x1db)];if(typeof _0x1df658!=='string')return null;try{let _0x3001e2=JSON[_0x2af100(0x1f3)](_0x1df658);return _0x3001e2?.['task_id']||_0x3001e2?.[_0x2af100(0x1c9)]||_0x3001e2?.['id']||null;}catch{return null;}}async function X(_0x39113d,_0x410e7d){const _0x11d72a=a0_0x457c52;let _0x2973df=_0x410e7d['now']??Date[_0x11d72a(0x1e2)],_0x36fc11=_0x2973df(),_0x3cd884=(_0x122701,_0xf6c767,_0x4352c2,_0x3b2c4b)=>{const _0x466039=_0x11d72a;_0x410e7d['log'](O(U({'from_alias':_0x39113d['fromAlias'],'to_alias':_0x39113d[_0x466039(0x1f2)],'task_id':_0xf6c767,'parent_task_id':_0x39113d[_0x466039(0x1c3)],'network_id':_0x39113d[_0x466039(0x1e0)],'transport':_0x39113d[_0x466039(0x1f9)],'status':_0x122701,'duration_ms':_0x2973df()-_0x36fc11,'lifecycle_tracking':_0x39113d[_0x466039(0x1c1)],..._0x4352c2!==void 0x0?{'error_code':_0x3b2c4b||'send_failed','error_message':N(_0x4352c2)}:{}})));};_0x3cd884(_0x11d72a(0x188),null);try{let _0x2cc26f=await _0x410e7d[_0x11d72a(0x1c6)](),_0x19fb63=j(_0x2cc26f);if(_0x19fb63)_0x3cd884(_0x11d72a(0x1bc),_0x19fb63);else{if(_0x2cc26f?.['ok']===!0x1||_0x2cc26f?.['error'])_0x3cd884(_0x11d72a(0x1f7),_0x19fb63,_0x2cc26f?.[_0x11d72a(0x1e8)]||_0x11d72a(0x199),_0x11d72a(0x1bd));else _0x3cd884(_0x11d72a(0x1f7),null,'CommHub\x20response\x20omitted\x20task_id',_0x11d72a(0x1ce));}return _0x2cc26f;}catch(_0x290c21){throw _0x3cd884(_0x11d72a(0x1f7),null,_0x290c21,_0x11d72a(0x1bb)),_0x290c21;}}function a0_0x1b20(){const _0x56440b=['sdk','toAlias','parse','new_task','min','emit','failed','\x20transport=','transport','lifecycle_tracking','SSE\x20reconnecting\x20in\x20','\x20parent_task_id=','reply','from_alias','error_message','disconnect','network_id','slice','\x20task_id=','body','<missing>','running','get_inbox','name','send_task','content','cwd','registered','sleep','tools/call','alias','split','sending','log','read','task','<pending>','from_session','get_all_status','6aMuBmr','messages','pop','call','\x20to=','s...','/mcp','to_alias','stringify','mcp_http','CommHub\x20rejected\x20task','860580EPbFAm','<unknown>','agent','2638640NwIqsl','application/json','text/event-stream','task.replied','getReader','message','result','inbox\x20error:\x20','Bearer\x20','new_message','idle','heartbeatInterval','connect','POST','fromAlias','sdk-','3326874UleHBZ','heartbeatTimer','1390390QJNwgY','connected','processInbox','normal','2.0','signal','toString','connectSSE','sseAbort','ack_inbox','application/json,\x20text/event-stream','AbortError','send_failed','delivered','send_rejected','report_status','/events/','send_message','lifecycleTracking','abort','parentTaskId','replace','url','send','reconnectDelay','unknown\x20error','message_id','[commhub:task]\x20','error_code','task.send.delivered','heartbeat\x20failed:\x20','missing_task_id','\x20network_id=','offline','send_reply','autoConnect','decode','data:\x20','SSE\x20error:\x20','parent_task_id','token','task_id','\x20error=','6521610Dmqvzi','text','status','not_tracked','task.ack','startsWith','networkId','getAllStatus','now','task.started','disconnected','broadcast','catch','resumeId','error','task.send.failed','15628912YxtPWE','json','1846432uVqaiU','type','\x20lifecycle=','toTimeString','task.send.start'];a0_0x1b20=function(){return _0x56440b;};return a0_0x1b20();}async function Y(_0x3b3a0c,_0x462a60){const _0x3a518b=a0_0x457c52;return X({'fromAlias':_0x3b3a0c[_0x3a518b(0x1ab)],'toAlias':_0x3b3a0c['alias'],'parentTaskId':_0x3b3a0c[_0x3a518b(0x1c3)]||null,'networkId':_0x3b3a0c['networkId']||null,'transport':_0x3a518b(0x198),'lifecycleTracking':_0x3a518b(0x1dd)},_0x462a60);}class $ extends a0_0x1d8d91{[a0_0x457c52(0x1c5)];[a0_0x457c52(0x186)];[a0_0x457c52(0x1d7)];[a0_0x457c52(0x19c)];[a0_0x457c52(0x1e7)];[a0_0x457c52(0x1a8)];[a0_0x457c52(0x1c7)];[a0_0x457c52(0x1ae)];[a0_0x457c52(0x1b7)];[a0_0x457c52(0x206)]=!0x1;constructor(_0x42893a){const _0x3edb1b=a0_0x457c52;super();if(this['url']=_0x42893a[_0x3edb1b(0x1c5)][_0x3edb1b(0x1c4)](/\/$/,''),this['alias']=_0x42893a['alias'],this['token']=_0x42893a[_0x3edb1b(0x1d7)],this[_0x3edb1b(0x19c)]=_0x42893a[_0x3edb1b(0x19c)]||_0x3edb1b(0x1f1),this[_0x3edb1b(0x1e7)]=_0x3edb1b(0x1ac)+_0x42893a['alias']+'-'+Date[_0x3edb1b(0x1e2)]()[_0x3edb1b(0x1b5)](0x24),this[_0x3edb1b(0x1a8)]=_0x42893a[_0x3edb1b(0x1a8)]??0x2bf20,this[_0x3edb1b(0x1c7)]=_0x42893a[_0x3edb1b(0x1c7)]??0xbb8,_0x42893a[_0x3edb1b(0x1d2)]!==!0x1)this[_0x3edb1b(0x1a9)]();}[a0_0x457c52(0x189)](_0x563faa){const _0xf6369f=a0_0x457c52;console[_0xf6369f(0x189)]('['+new Date()[_0xf6369f(0x1ef)]()[_0xf6369f(0x202)](0x0,0x8)+']\x20[commhub:'+this[_0xf6369f(0x186)]+']\x20'+_0x563faa);}async[a0_0x457c52(0x192)](_0x22b29c,_0x47aaf0){const _0x1f252b=a0_0x457c52;let _0x442df3={'Content-Type':_0x1f252b(0x19e),'Accept':_0x1f252b(0x1b9)};if(this[_0x1f252b(0x1d7)])_0x442df3['Authorization']=_0x1f252b(0x1a5)+this[_0x1f252b(0x1d7)];let _0x5951b8=await(await fetch(this[_0x1f252b(0x1c5)]+_0x1f252b(0x195),{'method':_0x1f252b(0x1aa),'headers':_0x442df3,'body':JSON[_0x1f252b(0x197)]({'jsonrpc':_0x1f252b(0x1b3),'id':Date['now'](),'method':_0x1f252b(0x185),'params':{'name':_0x22b29c,'arguments':_0x47aaf0}})}))['text'](),_0x1e093e=_0x5951b8['match'](/data: (.+)/),_0x5383b6=_0x1e093e?JSON[_0x1f252b(0x1f3)](_0x1e093e[0x1]):JSON[_0x1f252b(0x1f3)](_0x5951b8),_0x252d8b=_0x5383b6?.[_0x1f252b(0x1a3)]?.[_0x1f252b(0x20a)]?.[0x0]?.['text'];return _0x252d8b?JSON[_0x1f252b(0x1f3)](_0x252d8b):_0x5383b6;}async[a0_0x457c52(0x1a9)](){const _0x101020=a0_0x457c52;if(this[_0x101020(0x206)])return;this['running']=!0x0,await this[_0x101020(0x1dc)](_0x101020(0x1a7)),this['log'](_0x101020(0x20c)),this[_0x101020(0x1ae)]=setInterval(()=>{const _0x7ce214=_0x101020;this[_0x7ce214(0x1dc)](_0x7ce214(0x1a7))[_0x7ce214(0x1e6)](_0x4038a5=>this['log'](_0x7ce214(0x1cd)+_0x4038a5[_0x7ce214(0x1a2)]));},this['heartbeatInterval']),this[_0x101020(0x1b6)]();}async[a0_0x457c52(0x200)](){const _0x3f15e4=a0_0x457c52;if(this['running']=!0x1,this[_0x3f15e4(0x1b7)]?.[_0x3f15e4(0x1c2)](),this[_0x3f15e4(0x1ae)])clearInterval(this[_0x3f15e4(0x1ae)]);await this[_0x3f15e4(0x1dc)](_0x3f15e4(0x1d0))[_0x3f15e4(0x1e6)](()=>{}),this[_0x3f15e4(0x189)](_0x3f15e4(0x1e4));}async[a0_0x457c52(0x1c6)](_0x4b4b37,_0x20c265,_0x22720a=a0_0x457c52(0x1b2)){const _0x2568ee=a0_0x457c52;return Y({'alias':_0x4b4b37,'fromAlias':this[_0x2568ee(0x186)]},{'log':_0x65ca50=>console[_0x2568ee(0x189)](_0x65ca50),'send':()=>this['call'](_0x2568ee(0x209),{'alias':_0x4b4b37,'task':_0x20c265,'priority':_0x22720a,'from_session':this[_0x2568ee(0x186)]})});}async[a0_0x457c52(0x1a2)](_0xd04ec4,_0x38ca2d){const _0x58e75e=a0_0x457c52;return this[_0x58e75e(0x192)](_0x58e75e(0x1c0),{'alias':_0xd04ec4,'message':_0x38ca2d,'from_session':this['alias']});}async[a0_0x457c52(0x1fd)](_0x250b0a,_0x3f93d8,_0x2009a1='completed'){const _0x19db09=a0_0x457c52;return this[_0x19db09(0x192)](_0x19db09(0x1d1),{'in_reply_to':_0x250b0a,'text':_0x3f93d8,'status':_0x2009a1});}async[a0_0x457c52(0x1dc)](_0x5ae54d,_0x59b4d4){const _0xa3a624=a0_0x457c52;return this[_0xa3a624(0x192)](_0xa3a624(0x1be),{'resume_id':this['resumeId'],'alias':this[_0xa3a624(0x186)],'status':_0x5ae54d,'server':a0_0x4fc7ca(),'hostname':a0_0x4fc7ca(),'agent':this['agent'],'project_dir':process[_0xa3a624(0x20b)](),..._0x59b4d4});}async[a0_0x457c52(0x1e1)](){const _0x4d3768=a0_0x457c52;return this[_0x4d3768(0x192)](_0x4d3768(0x18e),{});}async[a0_0x457c52(0x1e5)](_0xde63af,_0x5da94b){const _0x5efd02=a0_0x457c52;return this['call'](_0x5efd02(0x1e5),{'message':_0xde63af,'filter_server':_0x5da94b?.['server'],'filter_status':_0x5da94b?.['status']});}async[a0_0x457c52(0x1b6)](){const _0x5482fa=a0_0x457c52;let _0x5205e7=encodeURIComponent(this[_0x5482fa(0x186)]),_0xf999f1=this[_0x5482fa(0x1c5)]+_0x5482fa(0x1bf)+_0x5205e7,_0x944d32=this['reconnectDelay'];while(this[_0x5482fa(0x206)]){try{this[_0x5482fa(0x1b7)]=new AbortController();let _0x436e88={'Accept':_0x5482fa(0x19f)};if(this[_0x5482fa(0x1d7)])_0x436e88['Authorization']=_0x5482fa(0x1a5)+this[_0x5482fa(0x1d7)];let _0x381db2=await fetch(_0xf999f1,{'headers':_0x436e88,'signal':this[_0x5482fa(0x1b7)][_0x5482fa(0x1b4)]});if(!_0x381db2['ok']||!_0x381db2[_0x5482fa(0x204)]){this[_0x5482fa(0x189)]('SSE\x20failed:\x20'+_0x381db2[_0x5482fa(0x1dc)]),await this['sleep'](_0x944d32),_0x944d32=Math['min'](_0x944d32*1.5,0xea60);continue;}_0x944d32=this[_0x5482fa(0x1c7)];let _0x1d6331=_0x381db2['body'][_0x5482fa(0x1a1)](),_0x464c42=new TextDecoder(),_0x36590c='';while(this[_0x5482fa(0x206)]){let {done:_0x52e501,value:_0x5319b2}=await _0x1d6331[_0x5482fa(0x18a)]();if(_0x52e501)break;_0x36590c+=_0x464c42[_0x5482fa(0x1d3)](_0x5319b2,{'stream':!0x0});let _0x113b18=_0x36590c[_0x5482fa(0x187)]('\x0a');_0x36590c=_0x113b18[_0x5482fa(0x191)]()||'';for(let _0x4649f5 of _0x113b18){if(!_0x4649f5[_0x5482fa(0x1df)](_0x5482fa(0x1d4)))continue;try{let _0x419f9d=JSON[_0x5482fa(0x1f3)](_0x4649f5[_0x5482fa(0x202)](0x6));if(_0x419f9d[_0x5482fa(0x1ed)]===_0x5482fa(0x1b0)){this[_0x5482fa(0x189)]('SSE\x20connected'),this['emit'](_0x5482fa(0x1b0));continue;}if(_0x419f9d[_0x5482fa(0x1ed)]===_0x5482fa(0x1f4)||_0x419f9d[_0x5482fa(0x1ed)]===_0x5482fa(0x1a6)||_0x419f9d['type']==='broadcast')await this[_0x5482fa(0x1b1)]();}catch{}}}}catch(_0x182b04){if(_0x182b04[_0x5482fa(0x208)]===_0x5482fa(0x1ba))break;this[_0x5482fa(0x1f6)](_0x5482fa(0x1e8),_0x182b04),this[_0x5482fa(0x189)](_0x5482fa(0x1d5)+_0x182b04[_0x5482fa(0x1a2)]);}if(this[_0x5482fa(0x206)])this[_0x5482fa(0x1f6)](_0x5482fa(0x1e4)),this[_0x5482fa(0x189)](_0x5482fa(0x1fb)+_0x944d32/0x3e8+_0x5482fa(0x194)),await this['sleep'](_0x944d32),_0x944d32=Math[_0x5482fa(0x1f5)](_0x944d32*1.5,0xea60);}}async['processInbox'](){const _0xac3a73=a0_0x457c52;try{let _0x140a7e=(await this['call'](_0xac3a73(0x207),{'alias':this[_0xac3a73(0x186)],'limit':0xa}))?.[_0xac3a73(0x190)]||[];for(let _0x1379a3 of _0x140a7e)await this[_0xac3a73(0x192)](_0xac3a73(0x1b8),{'alias':this[_0xac3a73(0x186)],'message_id':_0x1379a3['id']}),this[_0xac3a73(0x189)]('←\x20'+_0x1379a3[_0xac3a73(0x18d)]+':\x20'+_0x1379a3['content'][_0xac3a73(0x202)](0x0,0x3c)),this[_0xac3a73(0x1f6)](_0xac3a73(0x18b),_0x1379a3),this[_0xac3a73(0x1f6)]('message',_0x1379a3);}catch(_0x1e8469){this[_0xac3a73(0x189)](_0xac3a73(0x1a4)+_0x1e8469['message']);}}[a0_0x457c52(0x184)](_0x5caa2a){return new Promise(_0x1213fd=>setTimeout(_0x1213fd,_0x5caa2a));}}var F=$;export{F as default,$ as CommHub};
1
+ const a0_0x240860=a0_0xfa02;(function(_0x1d8ce7,_0x619d2b){const _0x491374=a0_0xfa02,_0x2d1699=_0x1d8ce7();while(!![]){try{const _0x259bd5=parseInt(_0x491374(0x10b))/0x1+-parseInt(_0x491374(0x155))/0x2*(-parseInt(_0x491374(0x103))/0x3)+parseInt(_0x491374(0xee))/0x4+-parseInt(_0x491374(0x156))/0x5*(-parseInt(_0x491374(0x14b))/0x6)+parseInt(_0x491374(0xfb))/0x7+parseInt(_0x491374(0xef))/0x8*(-parseInt(_0x491374(0xfa))/0x9)+-parseInt(_0x491374(0x141))/0xa;if(_0x259bd5===_0x619d2b)break;else _0x2d1699['push'](_0x2d1699['shift']());}catch(_0x496f67){_0x2d1699['push'](_0x2d1699['shift']());}}}(a0_0x3927,0xd672b));import{EventEmitter as a0_0x59ad8d}from'events';import{hostname as a0_0x11444b}from'os';var _=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,c=(_0x461794,_0x2c070c)=>(_0x461794??_0x2c070c)[a0_0x240860(0x11a)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x240860(0xeb)](0x0,0xf0);function T(_0x110129){const _0x45541f=a0_0x240860;return(_0x110129 instanceof Error?_0x110129['message']:String(_0x110129??_0x45541f(0x153)))[_0x45541f(0x11a)](_,'[REDACTED]')[_0x45541f(0x11a)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function a0_0x3927(){const _0x50f72f=['fromAlias','delivered','network_id','<missing>','stringify','type','body','decode','CommHub\x20rejected\x20task','min','s...','name','application/json,\x20text/event-stream','parentTaskId','Authorization','getAllStatus','/events/','task.send.start','AbortError','send_rejected','task.ack','sdk-','status','task.replied','send_reply','sseAbort','SSE\x20connected','data:\x20','agent','url','\x20duration_ms=','mcp_http','53074740PLeqkJ','send','error','emit','running','connect','text/event-stream','<pending>','\x20lifecycle=','error_code','10462998TnCzyK','connectSSE','\x20from=','task_id','2.0','string','cwd','disconnected','unknown\x20error','from_alias','2780714bjthvK','5GkBhPn','broadcast','SSE\x20failed:\x20','failed','\x20to=','text','task.send.delivered','toAlias','abort','pop','send_message','split','task.send.failed','heartbeatInterval','SSE\x20reconnecting\x20in\x20','message','content','slice','new_message','transport','6488752vsdIXR','12248LvlAOU','signal','match','disconnect','completed',']\x20[commhub:','token','\x20task_id=','task.expired','sleep','alias','5562JvyHjd','9424828JFssXf','now','parse','getReader','messages','networkId','lifecycle_tracking','sdk','3izNcEU','duration_ms','send_failed','CommHub\x20response\x20omitted\x20task_id','missing_task_id','get_inbox','lifecycleTracking','[commhub:task]\x20','1029229CfQMas','to_alias','message_id','get_all_status','heartbeat\x20failed:\x20','call','inbox\x20error:\x20','<unknown>','log','Bearer\x20','heartbeatTimer','read','\x20network_id=','toTimeString','reconnectDelay','replace','SSE\x20error:\x20','task','new_task','resumeId','registered','sending'];a0_0x3927=function(){return _0x50f72f;};return a0_0x3927();}function y(_0x50dd5b,_0x26c289=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x46a26e=a0_0x240860;if(_0x26c289)return JSON[_0x46a26e(0x125)](_0x50dd5b);let _0x156ad9=c(_0x50dd5b['parent_task_id'],_0x46a26e(0x124)),_0x136b5b=c(_0x50dd5b['task_id'],_0x46a26e(0x148)),_0x5bf3ba=_0x50dd5b[_0x46a26e(0x14a)]?'\x20error='+_0x50dd5b[_0x46a26e(0x14a)]+':'+(_0x50dd5b['error_message']??''):'';return _0x46a26e(0x10a)+_0x50dd5b['status']+_0x46a26e(0x14d)+c(_0x50dd5b[_0x46a26e(0x154)],_0x46a26e(0x112))+_0x46a26e(0x15a)+c(_0x50dd5b[_0x46a26e(0x10c)],'<unknown>')+_0x46a26e(0xf6)+_0x136b5b+'\x20parent_task_id='+_0x156ad9+_0x46a26e(0x117)+c(_0x50dd5b[_0x46a26e(0x123)],_0x46a26e(0x112))+'\x20transport='+_0x50dd5b[_0x46a26e(0xed)]+_0x46a26e(0x13f)+_0x50dd5b[_0x46a26e(0x104)]+_0x46a26e(0x149)+_0x50dd5b[_0x46a26e(0x101)]+_0x5bf3ba;}function b(_0x309e22){const _0x3e8a2e=a0_0x240860;return{'event':{'sending':_0x3e8a2e(0x132),'delivered':_0x3e8a2e(0x15c),'failed':_0x3e8a2e(0x162),'acked':_0x3e8a2e(0x135),'started':'task.started','replied':_0x3e8a2e(0x138),'expired':_0x3e8a2e(0xf7)}[_0x309e22[_0x3e8a2e(0x137)]],..._0x309e22};}function w(_0x485425){const _0x24dc5a=a0_0x240860;let _0x55ef2b=_0x485425?.[_0x24dc5a(0x14e)]||_0x485425?.['message_id']||_0x485425?.['id'];if(_0x55ef2b)return String(_0x55ef2b);let _0x30b2b4=_0x485425?.[_0x24dc5a(0xea)]?.[0x0]?.['text'];if(typeof _0x30b2b4!==_0x24dc5a(0x150))return null;try{let _0x1798c=JSON[_0x24dc5a(0xfd)](_0x30b2b4);return _0x1798c?.[_0x24dc5a(0x14e)]||_0x1798c?.[_0x24dc5a(0x10d)]||_0x1798c?.['id']||null;}catch{return null;}}async function h(_0x45f05f,_0x524841){const _0x5ae68a=a0_0x240860;let _0x5ea059=_0x524841[_0x5ae68a(0xfc)]??Date[_0x5ae68a(0xfc)],_0x133027=_0x5ea059(),_0x4936d7=(_0x33de68,_0x5a571c,_0x41691c,_0xf327e9)=>{const _0x291d1f=_0x5ae68a;_0x524841['log'](y(b({'from_alias':_0x45f05f[_0x291d1f(0x121)],'to_alias':_0x45f05f[_0x291d1f(0x15d)],'task_id':_0x5a571c,'parent_task_id':_0x45f05f[_0x291d1f(0x12e)],'network_id':_0x45f05f[_0x291d1f(0x100)],'transport':_0x45f05f['transport'],'status':_0x33de68,'duration_ms':_0x5ea059()-_0x133027,'lifecycle_tracking':_0x45f05f[_0x291d1f(0x109)],..._0x41691c!==void 0x0?{'error_code':_0xf327e9||_0x291d1f(0x105),'error_message':T(_0x41691c)}:{}})));};_0x4936d7(_0x5ae68a(0x120),null);try{let _0x532c49=await _0x524841['send'](),_0x271066=w(_0x532c49);if(_0x271066)_0x4936d7(_0x5ae68a(0x122),_0x271066);else{if(_0x532c49?.['ok']===!0x1||_0x532c49?.[_0x5ae68a(0x143)])_0x4936d7('failed',_0x271066,_0x532c49?.[_0x5ae68a(0x143)]||_0x5ae68a(0x129),_0x5ae68a(0x134));else _0x4936d7(_0x5ae68a(0x159),null,_0x5ae68a(0x106),_0x5ae68a(0x107));}return _0x532c49;}catch(_0x54d25c){throw _0x4936d7(_0x5ae68a(0x159),null,_0x54d25c,_0x5ae68a(0x105)),_0x54d25c;}}function a0_0xfa02(_0x5ea432,_0x4d7ff6){_0x5ea432=_0x5ea432-0xe8;const _0x392711=a0_0x3927();let _0xfa0231=_0x392711[_0x5ea432];return _0xfa0231;}async function u(_0x58ded2,_0x4e8d76){const _0x46835b=a0_0x240860;return h({'fromAlias':_0x58ded2[_0x46835b(0x121)],'toAlias':_0x58ded2[_0x46835b(0xf9)],'parentTaskId':_0x58ded2[_0x46835b(0x12e)]||null,'networkId':_0x58ded2['networkId']||null,'transport':_0x46835b(0x140),'lifecycleTracking':'not_tracked'},_0x4e8d76);}class k extends a0_0x59ad8d{['url'];[a0_0x240860(0xf9)];[a0_0x240860(0xf5)];[a0_0x240860(0x13d)];['resumeId'];[a0_0x240860(0x163)];[a0_0x240860(0x119)];[a0_0x240860(0x115)];['sseAbort'];[a0_0x240860(0x145)]=!0x1;constructor(_0x550012){const _0x565047=a0_0x240860;super();if(this[_0x565047(0x13e)]=_0x550012[_0x565047(0x13e)][_0x565047(0x11a)](/\/$/,''),this['alias']=_0x550012['alias'],this[_0x565047(0xf5)]=_0x550012['token'],this[_0x565047(0x13d)]=_0x550012[_0x565047(0x13d)]||_0x565047(0x102),this[_0x565047(0x11e)]=_0x565047(0x136)+_0x550012['alias']+'-'+Date[_0x565047(0xfc)]()['toString'](0x24),this[_0x565047(0x163)]=_0x550012['heartbeatInterval']??0x2bf20,this[_0x565047(0x119)]=_0x550012[_0x565047(0x119)]??0xbb8,_0x550012['autoConnect']!==!0x1)this['connect']();}[a0_0x240860(0x113)](_0x4b788e){const _0x5428ea=a0_0x240860;console[_0x5428ea(0x113)]('['+new Date()[_0x5428ea(0x118)]()['slice'](0x0,0x8)+_0x5428ea(0xf4)+this[_0x5428ea(0xf9)]+']\x20'+_0x4b788e);}async[a0_0x240860(0x110)](_0x1e3ef4,_0x5d3248){const _0xe8bd55=a0_0x240860;let _0x5154b4={'Content-Type':'application/json','Accept':_0xe8bd55(0x12d)};if(this[_0xe8bd55(0xf5)])_0x5154b4[_0xe8bd55(0x12f)]=_0xe8bd55(0x114)+this[_0xe8bd55(0xf5)];let _0x5e1651=await(await fetch(this[_0xe8bd55(0x13e)]+'/mcp',{'method':'POST','headers':_0x5154b4,'body':JSON['stringify']({'jsonrpc':_0xe8bd55(0x14f),'id':Date[_0xe8bd55(0xfc)](),'method':'tools/call','params':{'name':_0x1e3ef4,'arguments':_0x5d3248}})}))[_0xe8bd55(0x15b)](),_0x2a9e3e=_0x5e1651[_0xe8bd55(0xf1)](/data: (.+)/),_0x2a46f7=_0x2a9e3e?JSON[_0xe8bd55(0xfd)](_0x2a9e3e[0x1]):JSON[_0xe8bd55(0xfd)](_0x5e1651),_0x1b5d6e=_0x2a46f7?.['result']?.[_0xe8bd55(0xea)]?.[0x0]?.['text'];return _0x1b5d6e?JSON[_0xe8bd55(0xfd)](_0x1b5d6e):_0x2a46f7;}async[a0_0x240860(0x146)](){const _0x53d85d=a0_0x240860;if(this[_0x53d85d(0x145)])return;this[_0x53d85d(0x145)]=!0x0,await this[_0x53d85d(0x137)]('idle'),this['log'](_0x53d85d(0x11f)),this[_0x53d85d(0x115)]=setInterval(()=>{const _0x18ced7=_0x53d85d;this['status']('idle')['catch'](_0x5a727d=>this[_0x18ced7(0x113)](_0x18ced7(0x10f)+_0x5a727d[_0x18ced7(0xe9)]));},this[_0x53d85d(0x163)]),this[_0x53d85d(0x14c)]();}async[a0_0x240860(0xf2)](){const _0xa20671=a0_0x240860;if(this[_0xa20671(0x145)]=!0x1,this['sseAbort']?.[_0xa20671(0x15e)](),this['heartbeatTimer'])clearInterval(this[_0xa20671(0x115)]);await this[_0xa20671(0x137)]('offline')['catch'](()=>{}),this['log'](_0xa20671(0x152));}async[a0_0x240860(0x142)](_0x1df799,_0x2f4ba3,_0x35e566='normal'){const _0x583976=a0_0x240860;return u({'alias':_0x1df799,'fromAlias':this[_0x583976(0xf9)]},{'log':_0x4be846=>console[_0x583976(0x113)](_0x4be846),'send':()=>this[_0x583976(0x110)]('send_task',{'alias':_0x1df799,'task':_0x2f4ba3,'priority':_0x35e566,'from_session':this[_0x583976(0xf9)]})});}async[a0_0x240860(0xe9)](_0x47dfc0,_0x974a6c){const _0x34ed86=a0_0x240860;return this[_0x34ed86(0x110)](_0x34ed86(0x160),{'alias':_0x47dfc0,'message':_0x974a6c,'from_session':this[_0x34ed86(0xf9)]});}async['reply'](_0x153e61,_0x4ca25c,_0x3d1304=a0_0x240860(0xf3)){const _0x44489e=a0_0x240860;return this[_0x44489e(0x110)](_0x44489e(0x139),{'in_reply_to':_0x153e61,'text':_0x4ca25c,'status':_0x3d1304});}async[a0_0x240860(0x137)](_0x5e13a5,_0x5ebc83){const _0xf8a758=a0_0x240860;return this['call']('report_status',{'resume_id':this[_0xf8a758(0x11e)],'alias':this[_0xf8a758(0xf9)],'status':_0x5e13a5,'server':a0_0x11444b(),'hostname':a0_0x11444b(),'agent':this[_0xf8a758(0x13d)],'project_dir':process[_0xf8a758(0x151)](),..._0x5ebc83});}async[a0_0x240860(0x130)](){const _0x14c30d=a0_0x240860;return this[_0x14c30d(0x110)](_0x14c30d(0x10e),{});}async[a0_0x240860(0x157)](_0x36d094,_0x2e3e57){const _0x149bb8=a0_0x240860;return this[_0x149bb8(0x110)](_0x149bb8(0x157),{'message':_0x36d094,'filter_server':_0x2e3e57?.['server'],'filter_status':_0x2e3e57?.[_0x149bb8(0x137)]});}async['connectSSE'](){const _0x26ff5c=a0_0x240860;let _0x15c140=encodeURIComponent(this[_0x26ff5c(0xf9)]),_0x58c2b5=this['url']+_0x26ff5c(0x131)+_0x15c140,_0x30a412=this[_0x26ff5c(0x119)];while(this[_0x26ff5c(0x145)]){try{this[_0x26ff5c(0x13a)]=new AbortController();let _0x4e5ea9={'Accept':_0x26ff5c(0x147)};if(this[_0x26ff5c(0xf5)])_0x4e5ea9[_0x26ff5c(0x12f)]=_0x26ff5c(0x114)+this[_0x26ff5c(0xf5)];let _0x511bf7=await fetch(_0x58c2b5,{'headers':_0x4e5ea9,'signal':this[_0x26ff5c(0x13a)][_0x26ff5c(0xf0)]});if(!_0x511bf7['ok']||!_0x511bf7[_0x26ff5c(0x127)]){this[_0x26ff5c(0x113)](_0x26ff5c(0x158)+_0x511bf7[_0x26ff5c(0x137)]),await this['sleep'](_0x30a412),_0x30a412=Math[_0x26ff5c(0x12a)](_0x30a412*1.5,0xea60);continue;}_0x30a412=this['reconnectDelay'];let _0x38fecf=_0x511bf7[_0x26ff5c(0x127)][_0x26ff5c(0xfe)](),_0x2f9bfb=new TextDecoder(),_0x24607d='';while(this[_0x26ff5c(0x145)]){let {done:_0x1d6c6c,value:_0x26bf96}=await _0x38fecf[_0x26ff5c(0x116)]();if(_0x1d6c6c)break;_0x24607d+=_0x2f9bfb[_0x26ff5c(0x128)](_0x26bf96,{'stream':!0x0});let _0x37a360=_0x24607d[_0x26ff5c(0x161)]('\x0a');_0x24607d=_0x37a360[_0x26ff5c(0x15f)]()||'';for(let _0x48fdad of _0x37a360){if(!_0x48fdad['startsWith'](_0x26ff5c(0x13c)))continue;try{let _0x3cd990=JSON[_0x26ff5c(0xfd)](_0x48fdad[_0x26ff5c(0xeb)](0x6));if(_0x3cd990[_0x26ff5c(0x126)]==='connected'){this['log'](_0x26ff5c(0x13b)),this[_0x26ff5c(0x144)]('connected');continue;}if(_0x3cd990[_0x26ff5c(0x126)]===_0x26ff5c(0x11d)||_0x3cd990[_0x26ff5c(0x126)]===_0x26ff5c(0xec)||_0x3cd990[_0x26ff5c(0x126)]===_0x26ff5c(0x157))await this['processInbox']();}catch{}}}}catch(_0x4b0e70){if(_0x4b0e70[_0x26ff5c(0x12c)]===_0x26ff5c(0x133))break;this[_0x26ff5c(0x144)](_0x26ff5c(0x143),_0x4b0e70),this[_0x26ff5c(0x113)](_0x26ff5c(0x11b)+_0x4b0e70['message']);}if(this[_0x26ff5c(0x145)])this['emit'](_0x26ff5c(0x152)),this[_0x26ff5c(0x113)](_0x26ff5c(0xe8)+_0x30a412/0x3e8+_0x26ff5c(0x12b)),await this[_0x26ff5c(0xf8)](_0x30a412),_0x30a412=Math[_0x26ff5c(0x12a)](_0x30a412*1.5,0xea60);}}async['processInbox'](){const _0xae381d=a0_0x240860;try{let _0x12eb26=(await this['call'](_0xae381d(0x108),{'alias':this[_0xae381d(0xf9)],'limit':0xa}))?.[_0xae381d(0xff)]||[];for(let _0x12e458 of _0x12eb26)await this[_0xae381d(0x110)]('ack_inbox',{'alias':this[_0xae381d(0xf9)],'message_id':_0x12e458['id']}),this['log']('←\x20'+_0x12e458['from_session']+':\x20'+_0x12e458['content'][_0xae381d(0xeb)](0x0,0x3c)),this[_0xae381d(0x144)](_0xae381d(0x11c),_0x12e458),this[_0xae381d(0x144)]('message',_0x12e458);}catch(_0x4ab21f){this[_0xae381d(0x113)](_0xae381d(0x111)+_0x4ab21f[_0xae381d(0xe9)]);}}[a0_0x240860(0xf8)](_0x3f5ab1){return new Promise(_0x4560de=>setTimeout(_0x4560de,_0x3f5ab1));}}var O=k;export{k as CommHub,O as default};
@@ -6,8 +6,10 @@ export interface CopresenceDep {
6
6
  readonly why: string;
7
7
  }
8
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[];
9
+ /** Which agent binary this co-presence lane is built on. */
10
+ export type CopresenceAgent = "codex" | "grok";
11
+ export declare function copresenceDeps(probe: CommandProbe, platform?: NodeJS.Platform, agent?: CopresenceAgent): CopresenceDep[];
12
+ export declare function missingCopresenceDeps(probe: CommandProbe, platform?: NodeJS.Platform, agent?: CopresenceAgent): CopresenceDep[];
11
13
  /** One block naming every gap and how to close it — never one gap at a time. */
12
14
  export declare function describeMissingDeps(missing: readonly CopresenceDep[], displayName: string): string;
13
15
  /**
@@ -45,7 +45,12 @@ export interface GrokAttachResizeFrame {
45
45
  cols: number;
46
46
  rows: number;
47
47
  }
48
- export type GrokAttachClientFrame = GrokAttachInputFrame | GrokAttachResizeFrame | GrokAttachDetachFrame;
48
+ /** Asks the node to switch models (issue #879); allowed on control connections. */
49
+ export interface GrokAttachSetModelFrame {
50
+ type: "set-model";
51
+ model: string;
52
+ }
53
+ export type GrokAttachClientFrame = GrokAttachInputFrame | GrokAttachResizeFrame | GrokAttachSetModelFrame | GrokAttachDetachFrame;
49
54
  export interface GrokAttachInputSource {
50
55
  on(event: "data", listener: (chunk: unknown) => void): unknown;
51
56
  on(event: "end", listener: () => void): unknown;
@@ -105,6 +110,15 @@ export interface GrokAttachSession {
105
110
  readonly closed: Promise<GrokAttachCloseInfo>;
106
111
  detach(): void;
107
112
  resize(cols?: number, rows?: number): void;
113
+ /**
114
+ * Ask the node to switch models (issue #879).
115
+ *
116
+ * The outcome does not come back from this call — it arrives as a `status`
117
+ * frame carrying `modelSwitch`, because the node may accept, refuse
118
+ * (busy / unchanged / invalid), or fail while re-spawning. Callers read it
119
+ * through `onStatus`.
120
+ */
121
+ setModel(model: string): void;
108
122
  }
109
123
  export declare class GrokAttachRemoteError extends Error {
110
124
  readonly code: string;
@@ -0,0 +1,70 @@
1
+ /** tmux session names. The attachable TUI owns the bare alias so that
2
+ * `tmux attach -t '=<alias>'` lands a human on the TUI, matching the codex
3
+ * lane exactly — an operator should not have to remember which runtime a node
4
+ * uses in order to know where to attach. */
5
+ export declare function grokCopresenceSessions(displayName: string): {
6
+ node: string;
7
+ tui: string;
8
+ };
9
+ export type GrokAttachSocketState = "missing" | "not_a_socket" | "ready";
10
+ /** Readiness is "the attach socket exists AND is a socket", never "the child
11
+ * process started". A grok leader that dies during startup leaves either no
12
+ * socket at all or a stale regular file from an aborted run; both used to read
13
+ * as ready because nothing looked. */
14
+ export declare function grokAttachSocketState(entry: {
15
+ isSocket(): boolean;
16
+ } | null | undefined): GrokAttachSocketState;
17
+ /** Set on the node child so that `anet node start` inside the tmux session does
18
+ * not re-enter this orchestration and fork bomb. The codex lane guards on the
19
+ * same variable (cli.ts: `process.env.ANET_COPRESENCE_BRIDGE !== "1"`); using a
20
+ * second name would leave two guards that must be kept in sync by hand. */
21
+ export declare const GROK_COPRESENCE_CHILD_ENV = "ANET_COPRESENCE_BRIDGE";
22
+ export interface GrokCopresenceDiagnosis {
23
+ readonly ok: boolean;
24
+ readonly lines: readonly string[];
25
+ }
26
+ /** One block naming every reason this node cannot run the shared TUI, not one
27
+ * exit per reason. A node that is both the wrong runtime AND missing its
28
+ * attach socket should learn both in one run. */
29
+ /** Platforms whose PTY / IPC / isolation primitives the grok co-presence lane
30
+ * has actually been validated on. agent-node refuses anywhere else, and it does
31
+ * so only after the node has been created and started once:
32
+ *
33
+ * [agent-node] grok-build-cli co-presence 无法在 darwin 上运行,缺少:
34
+ * 平台 darwin 尚未验证过共存所需的 PTY / IPC / 隔离原语
35
+ *
36
+ * Learned the expensive way on a Mac mini: install anet, install agent-node,
37
+ * create the node, start it — and only then find out the platform is refused.
38
+ * A one-command launcher that lets someone get that far has not saved them
39
+ * anything, so say it in the same breath as every other gap. */
40
+ export declare const GROK_COPRESENCE_PLATFORMS: readonly NodeJS.Platform[];
41
+ export declare function diagnoseGrokCopresence(input: {
42
+ runtime: string;
43
+ displayName: string;
44
+ grokCopresence?: boolean;
45
+ grokAttachSocket?: string;
46
+ platform?: NodeJS.Platform;
47
+ }): GrokCopresenceDiagnosis;
48
+ /** True when a plain `anet node start <name>` (no flag) should bring the shared
49
+ * TUI up by itself.
50
+ *
51
+ * 🔴 Deliberately NOT keyed on `grokCopresence`. That field is set to true at
52
+ * CREATE time for every grok-build-cli node, so reading it here would silently
53
+ * change what `anet node start` does for every grok node that already exists —
54
+ * they would stop running in the foreground and fork into tmux, unasked. Caught
55
+ * exactly that way: a start without the flag entered the orchestration.
56
+ *
57
+ * The codex lane looks the same but is not: `codexCopresence` is written only
58
+ * when the operator passes the flag. So grok needs its own record of the
59
+ * operator's choice, and `grokCopresenceAuto` is it. */
60
+ export declare function grokCopresenceRequested(flagPassed: boolean, profile: {
61
+ runtime?: unknown;
62
+ grokCopresence?: unknown;
63
+ grokCopresenceAuto?: unknown;
64
+ }): boolean;
65
+ /** Record the operator's opt-in so the NEXT start needs no flag — and only then.
66
+ * Never infer it from `grokCopresence`, which create sets by default. */
67
+ export declare function shouldPersistGrokCopresence(flagPassed: boolean, profile: {
68
+ runtime?: unknown;
69
+ grokCopresenceAuto?: unknown;
70
+ }): boolean;
@@ -0,0 +1,34 @@
1
+ import type { IMCorrelationStore, IMTaskCorrelation } from "./types";
2
+ export interface JsonIMCorrelationStoreOptions {
3
+ now?: () => number;
4
+ /** How long idempotency keys remain valid. Defaults to 24h. */
5
+ seenTtlMs?: number;
6
+ /** How long terminal correlations remain queryable. Defaults to 24h. */
7
+ terminalTtlMs?: number;
8
+ }
9
+ /**
10
+ * Small durable store for RFC-020 §2.9④ / §4.4 correlation state.
11
+ *
12
+ * The first gateway PR needs this as a standalone data structure before the
13
+ * bridge is rewired: idempotency keys survive process restart, and task replies
14
+ * can be routed back to their originating IM conversation.
15
+ */
16
+ export declare class JsonIMCorrelationStore implements IMCorrelationStore {
17
+ private readonly path;
18
+ private readonly now;
19
+ private readonly seenTtlMs;
20
+ private readonly terminalTtlMs;
21
+ constructor(path: string, options?: JsonIMCorrelationStoreOptions);
22
+ hasSeen(idempotencyKey: string): Promise<string | null>;
23
+ recordSeen(idempotencyKey: string, taskId: string): Promise<void>;
24
+ getCorrelation(taskId: string): Promise<IMTaskCorrelation | null>;
25
+ putCorrelation(taskId: string, correlation: IMTaskCorrelation): Promise<void>;
26
+ updateStatus(taskId: string, status: IMTaskCorrelation["status"]): Promise<void>;
27
+ gc(now: number): Promise<{
28
+ removed: number;
29
+ }>;
30
+ private isExpired;
31
+ private load;
32
+ private save;
33
+ }
34
+ export declare function createJsonIMCorrelationStore(path: string, options?: JsonIMCorrelationStoreOptions): IMCorrelationStore;