@sleep2agi/agent-network 2.3.0-preview.25 → 2.3.0-preview.27

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_0x448275=a0_0x55d4;(function(_0x568484,_0x43ea72){const _0x4141a5=a0_0x55d4,_0xffcb0=_0x568484();while(!![]){try{const _0x83cb50=parseInt(_0x4141a5(0x188))/0x1+parseInt(_0x4141a5(0x1a4))/0x2+parseInt(_0x4141a5(0x17a))/0x3*(parseInt(_0x4141a5(0x1af))/0x4)+-parseInt(_0x4141a5(0x182))/0x5+-parseInt(_0x4141a5(0x193))/0x6*(parseInt(_0x4141a5(0x184))/0x7)+parseInt(_0x4141a5(0x179))/0x8*(parseInt(_0x4141a5(0x19a))/0x9)+-parseInt(_0x4141a5(0x16b))/0xa;if(_0x83cb50===_0x43ea72)break;else _0xffcb0['push'](_0xffcb0['shift']());}catch(_0x56bd9e){_0xffcb0['push'](_0xffcb0['shift']());}}}(a0_0x5bc7,0xc1738));import{EventEmitter as a0_0x28a8ce}from'events';import{hostname as a0_0x4a32bd}from'os';class T extends a0_0x28a8ce{['url'];[a0_0x448275(0x195)];['token'];['agent'];['resumeId'];[a0_0x448275(0x1c0)];[a0_0x448275(0x191)];[a0_0x448275(0x17b)];['sseAbort'];[a0_0x448275(0x198)]=!0x1;constructor(_0xed11ae){const _0x586990=a0_0x448275;super();if(this[_0x586990(0x1a0)]=_0xed11ae[_0x586990(0x1a0)][_0x586990(0x171)](/\/$/,''),this[_0x586990(0x195)]=_0xed11ae[_0x586990(0x195)],this[_0x586990(0x19f)]=_0xed11ae[_0x586990(0x19f)],this['agent']=_0xed11ae[_0x586990(0x1b1)]||'sdk',this[_0x586990(0x169)]='sdk-'+_0xed11ae[_0x586990(0x195)]+'-'+Date[_0x586990(0x1bc)]()[_0x586990(0x1b0)](0x24),this[_0x586990(0x1c0)]=_0xed11ae[_0x586990(0x1c0)]??0x2bf20,this['reconnectDelay']=_0xed11ae[_0x586990(0x191)]??0xbb8,_0xed11ae[_0x586990(0x17e)]!==!0x1)this[_0x586990(0x190)]();}[a0_0x448275(0x197)](_0x1e965c){const _0x67a96c=a0_0x448275;console[_0x67a96c(0x197)]('['+new Date()[_0x67a96c(0x16e)]()['slice'](0x0,0x8)+_0x67a96c(0x1ae)+this['alias']+']\x20'+_0x1e965c);}async['call'](_0x4b0b28,_0x30c3e6){const _0x95d4b5=a0_0x448275;let _0x2daf92={'Content-Type':_0x95d4b5(0x177),'Accept':_0x95d4b5(0x170)};if(this[_0x95d4b5(0x19f)])_0x2daf92[_0x95d4b5(0x18c)]=_0x95d4b5(0x194)+this['token'];let _0x26503e=await(await fetch(this[_0x95d4b5(0x1a0)]+_0x95d4b5(0x176),{'method':_0x95d4b5(0x1a1),'headers':_0x2daf92,'body':JSON[_0x95d4b5(0x1a5)]({'jsonrpc':'2.0','id':Date['now'](),'method':_0x95d4b5(0x175),'params':{'name':_0x4b0b28,'arguments':_0x30c3e6}})}))['text'](),_0x500caa=_0x26503e[_0x95d4b5(0x16a)](/data: (.+)/),_0x5acce2=_0x500caa?JSON['parse'](_0x500caa[0x1]):JSON['parse'](_0x26503e),_0x8108ce=_0x5acce2?.['result']?.[_0x95d4b5(0x1be)]?.[0x0]?.[_0x95d4b5(0x1bd)];return _0x8108ce?JSON['parse'](_0x8108ce):_0x5acce2;}async[a0_0x448275(0x190)](){const _0x1ed315=a0_0x448275;if(this[_0x1ed315(0x198)])return;this[_0x1ed315(0x198)]=!0x0,await this[_0x1ed315(0x1b2)](_0x1ed315(0x1b6)),this[_0x1ed315(0x197)](_0x1ed315(0x18b)),this[_0x1ed315(0x17b)]=setInterval(()=>{const _0x7a7612=_0x1ed315;this[_0x7a7612(0x1b2)]('idle')[_0x7a7612(0x18d)](_0x5cf99c=>this[_0x7a7612(0x197)](_0x7a7612(0x1b9)+_0x5cf99c[_0x7a7612(0x1a2)]));},this[_0x1ed315(0x1c0)]),this[_0x1ed315(0x1b7)]();}async[a0_0x448275(0x19c)](){const _0x3de916=a0_0x448275;if(this[_0x3de916(0x198)]=!0x1,this[_0x3de916(0x1a3)]?.[_0x3de916(0x18f)](),this[_0x3de916(0x17b)])clearInterval(this[_0x3de916(0x17b)]);await this[_0x3de916(0x1b2)](_0x3de916(0x1bf))[_0x3de916(0x18d)](()=>{}),this['log'](_0x3de916(0x1ab));}async['send'](_0x167a8a,_0x44a494,_0x4cc7b6=a0_0x448275(0x1aa)){const _0x5b5499=a0_0x448275;return this['call'](_0x5b5499(0x18a),{'alias':_0x167a8a,'task':_0x44a494,'priority':_0x4cc7b6,'from_session':this[_0x5b5499(0x195)]});}async[a0_0x448275(0x1a2)](_0x378dde,_0x1b9b99){const _0x3ebd8e=a0_0x448275;return this[_0x3ebd8e(0x187)]('send_message',{'alias':_0x378dde,'message':_0x1b9b99,'from_session':this[_0x3ebd8e(0x195)]});}async['reply'](_0x4e3abe,_0x45f7da,_0x36f7ec=a0_0x448275(0x1a7)){const _0x413e91=a0_0x448275;return this[_0x413e91(0x187)](_0x413e91(0x173),{'in_reply_to':_0x4e3abe,'text':_0x45f7da,'status':_0x36f7ec});}async[a0_0x448275(0x1b2)](_0x5d1e8b,_0x3719a8){const _0x52fea4=a0_0x448275;return this['call'](_0x52fea4(0x16d),{'resume_id':this[_0x52fea4(0x169)],'alias':this[_0x52fea4(0x195)],'status':_0x5d1e8b,'server':a0_0x4a32bd(),'hostname':a0_0x4a32bd(),'agent':this[_0x52fea4(0x1b1)],'project_dir':process['cwd'](),..._0x3719a8});}async[a0_0x448275(0x16f)](){const _0x43ba07=a0_0x448275;return this[_0x43ba07(0x187)](_0x43ba07(0x19b),{});}async['broadcast'](_0x50b52c,_0x91cc46){const _0x4f1674=a0_0x448275;return this[_0x4f1674(0x187)](_0x4f1674(0x17c),{'message':_0x50b52c,'filter_server':_0x91cc46?.[_0x4f1674(0x183)],'filter_status':_0x91cc46?.[_0x4f1674(0x1b2)]});}async[a0_0x448275(0x1b7)](){const _0x549abc=a0_0x448275;let _0x4738ae=encodeURIComponent(this[_0x549abc(0x195)]),_0x484faa=this[_0x549abc(0x1a0)]+_0x549abc(0x186)+_0x4738ae,_0x4e0430=this[_0x549abc(0x191)];while(this[_0x549abc(0x198)]){try{this[_0x549abc(0x1a3)]=new AbortController();let _0x1b7926={'Accept':_0x549abc(0x174)};if(this['token'])_0x1b7926[_0x549abc(0x18c)]=_0x549abc(0x194)+this[_0x549abc(0x19f)];let _0x48e1e0=await fetch(_0x484faa,{'headers':_0x1b7926,'signal':this[_0x549abc(0x1a3)][_0x549abc(0x185)]});if(!_0x48e1e0['ok']||!_0x48e1e0[_0x549abc(0x17d)]){this[_0x549abc(0x197)]('SSE\x20failed:\x20'+_0x48e1e0[_0x549abc(0x1b2)]),await this[_0x549abc(0x1b3)](_0x4e0430),_0x4e0430=Math['min'](_0x4e0430*1.5,0xea60);continue;}_0x4e0430=this['reconnectDelay'];let _0x165213=_0x48e1e0[_0x549abc(0x17d)]['getReader'](),_0x3bafc2=new TextDecoder(),_0x149af0='';while(this[_0x549abc(0x198)]){let {done:_0x930db,value:_0x43e7c1}=await _0x165213[_0x549abc(0x19e)]();if(_0x930db)break;_0x149af0+=_0x3bafc2['decode'](_0x43e7c1,{'stream':!0x0});let _0x24d42e=_0x149af0[_0x549abc(0x1b4)]('\x0a');_0x149af0=_0x24d42e[_0x549abc(0x19d)]()||'';for(let _0x8cb294 of _0x24d42e){if(!_0x8cb294[_0x549abc(0x178)](_0x549abc(0x1ba)))continue;try{let _0x1ee75d=JSON[_0x549abc(0x181)](_0x8cb294[_0x549abc(0x1a8)](0x6));if(_0x1ee75d[_0x549abc(0x180)]===_0x549abc(0x17f)){this[_0x549abc(0x197)](_0x549abc(0x18e)),this['emit']('connected');continue;}if(_0x1ee75d[_0x549abc(0x180)]===_0x549abc(0x1a6)||_0x1ee75d[_0x549abc(0x180)]===_0x549abc(0x1a9)||_0x1ee75d[_0x549abc(0x180)]==='broadcast')await this[_0x549abc(0x1b8)]();}catch{}}}}catch(_0x1f1e9f){if(_0x1f1e9f[_0x549abc(0x172)]==='AbortError')break;this['emit'](_0x549abc(0x1ad),_0x1f1e9f),this[_0x549abc(0x197)]('SSE\x20error:\x20'+_0x1f1e9f[_0x549abc(0x1a2)]);}if(this[_0x549abc(0x198)])this[_0x549abc(0x192)](_0x549abc(0x1ab)),this[_0x549abc(0x197)](_0x549abc(0x16c)+_0x4e0430/0x3e8+_0x549abc(0x1ac)),await this['sleep'](_0x4e0430),_0x4e0430=Math[_0x549abc(0x1b5)](_0x4e0430*1.5,0xea60);}}async[a0_0x448275(0x1b8)](){const _0x23c363=a0_0x448275;try{let _0x224649=(await this[_0x23c363(0x187)](_0x23c363(0x1bb),{'alias':this[_0x23c363(0x195)],'limit':0xa}))?.[_0x23c363(0x196)]||[];for(let _0x997825 of _0x224649)await this['call'](_0x23c363(0x189),{'alias':this['alias'],'message_id':_0x997825['id']}),this['log']('←\x20'+_0x997825['from_session']+':\x20'+_0x997825[_0x23c363(0x1be)]['slice'](0x0,0x3c)),this[_0x23c363(0x192)]('task',_0x997825),this[_0x23c363(0x192)](_0x23c363(0x1a2),_0x997825);}catch(_0x1cbd6d){this[_0x23c363(0x197)](_0x23c363(0x199)+_0x1cbd6d[_0x23c363(0x1a2)]);}}['sleep'](_0x1b6330){return new Promise(_0x3eb371=>setTimeout(_0x3eb371,_0x1b6330));}}function a0_0x55d4(_0x3939f2,_0x26920a){_0x3939f2=_0x3939f2-0x169;const _0x5bc74f=a0_0x5bc7();let _0x55d487=_0x5bc74f[_0x3939f2];return _0x55d487;}function a0_0x5bc7(){const _0x4539b1=['server','45157KdpdLR','signal','/events/','call','1046243jaJcOj','ack_inbox','send_task','registered','Authorization','catch','SSE\x20connected','abort','connect','reconnectDelay','emit','492IjaEMq','Bearer\x20','alias','messages','log','running','inbox\x20error:\x20','48492RvmoZK','get_all_status','disconnect','pop','read','token','url','POST','message','sseAbort','1352176QJLEaj','stringify','new_task','completed','slice','new_message','normal','disconnected','s...','error',']\x20[commhub:','8iVTFdQ','toString','agent','status','sleep','split','min','idle','connectSSE','processInbox','heartbeat\x20failed:\x20','data:\x20','get_inbox','now','text','content','offline','heartbeatInterval','resumeId','match','7560860tMgUAS','SSE\x20reconnecting\x20in\x20','report_status','toTimeString','getAllStatus','application/json,\x20text/event-stream','replace','name','send_reply','text/event-stream','tools/call','/mcp','application/json','startsWith','1384lbkaSA','797763UZvWIk','heartbeatTimer','broadcast','body','autoConnect','connected','type','parse','5544265rxaDWY'];a0_0x5bc7=function(){return _0x4539b1;};return a0_0x5bc7();}var $=T;export{$ as default,T as CommHub};
1
+ const a0_0x39040b=a0_0x83b7;(function(_0x3d9895,_0x1da5f7){const _0x56236a=a0_0x83b7,_0x47d527=_0x3d9895();while(!![]){try{const _0x439c11=-parseInt(_0x56236a(0xcb))/0x1+-parseInt(_0x56236a(0xcd))/0x2*(-parseInt(_0x56236a(0x107))/0x3)+-parseInt(_0x56236a(0x108))/0x4+parseInt(_0x56236a(0xeb))/0x5+parseInt(_0x56236a(0xfa))/0x6+parseInt(_0x56236a(0xed))/0x7*(-parseInt(_0x56236a(0xe5))/0x8)+parseInt(_0x56236a(0xe7))/0x9*(-parseInt(_0x56236a(0xf8))/0xa);if(_0x439c11===_0x1da5f7)break;else _0x47d527['push'](_0x47d527['shift']());}catch(_0x5a9b37){_0x47d527['push'](_0x47d527['shift']());}}}(a0_0x6800,0xb7804));import{EventEmitter as a0_0x72c79f}from'events';import{hostname as a0_0x128a22}from'os';function a0_0x83b7(_0x4099dd,_0x63a88c){_0x4099dd=_0x4099dd-0xb3;const _0x68007=a0_0x6800();let _0x83b7b5=_0x68007[_0x4099dd];return _0x83b7b5;}class T extends a0_0x72c79f{[a0_0x39040b(0xfc)];[a0_0x39040b(0xf4)];['token'];[a0_0x39040b(0xe8)];[a0_0x39040b(0xf6)];[a0_0x39040b(0xc8)];['reconnectDelay'];['heartbeatTimer'];[a0_0x39040b(0xdd)];['running']=!0x1;constructor(_0x28d2a3){const _0x23e39f=a0_0x39040b;super();if(this[_0x23e39f(0xfc)]=_0x28d2a3['url'][_0x23e39f(0xe2)](/\/$/,''),this[_0x23e39f(0xf4)]=_0x28d2a3[_0x23e39f(0xf4)],this[_0x23e39f(0xf9)]=_0x28d2a3[_0x23e39f(0xf9)],this[_0x23e39f(0xe8)]=_0x28d2a3['agent']||_0x23e39f(0xb8),this[_0x23e39f(0xf6)]=_0x23e39f(0xb4)+_0x28d2a3['alias']+'-'+Date[_0x23e39f(0xfd)]()[_0x23e39f(0xc5)](0x24),this[_0x23e39f(0xc8)]=_0x28d2a3[_0x23e39f(0xc8)]??0x2bf20,this[_0x23e39f(0xf5)]=_0x28d2a3[_0x23e39f(0xf5)]??0xbb8,_0x28d2a3[_0x23e39f(0xe6)]!==!0x1)this[_0x23e39f(0xc0)]();}[a0_0x39040b(0xf3)](_0x38416c){const _0x1529e6=a0_0x39040b;console[_0x1529e6(0xf3)]('['+new Date()[_0x1529e6(0xfb)]()[_0x1529e6(0x105)](0x0,0x8)+_0x1529e6(0xc3)+this[_0x1529e6(0xf4)]+']\x20'+_0x38416c);}async[a0_0x39040b(0x109)](_0x503ff9,_0x278668){const _0x482186=a0_0x39040b;let _0x4fe4dd={'Content-Type':_0x482186(0x104),'Accept':'application/json,\x20text/event-stream'};if(this[_0x482186(0xf9)])_0x4fe4dd[_0x482186(0xfe)]=_0x482186(0xe1)+this[_0x482186(0xf9)];let _0x2ad69b=await(await fetch(this[_0x482186(0xfc)]+_0x482186(0xba),{'method':_0x482186(0x106),'headers':_0x4fe4dd,'body':JSON['stringify']({'jsonrpc':_0x482186(0xd3),'id':Date[_0x482186(0xfd)](),'method':_0x482186(0xdf),'params':{'name':_0x503ff9,'arguments':_0x278668}})}))[_0x482186(0xda)](),_0x4c6347=_0x2ad69b['match'](/data: (.+)/),_0x1f3bf9=_0x4c6347?JSON[_0x482186(0xdc)](_0x4c6347[0x1]):JSON[_0x482186(0xdc)](_0x2ad69b),_0x108842=_0x1f3bf9?.[_0x482186(0xff)]?.[_0x482186(0xc4)]?.[0x0]?.[_0x482186(0xda)];return _0x108842?JSON[_0x482186(0xdc)](_0x108842):_0x1f3bf9;}async['connect'](){const _0x507dec=a0_0x39040b;if(this[_0x507dec(0x102)])return;this[_0x507dec(0x102)]=!0x0,await this[_0x507dec(0xd1)](_0x507dec(0xc7)),this['log']('registered'),this[_0x507dec(0xd0)]=setInterval(()=>{const _0x5749fe=_0x507dec;this[_0x5749fe(0xd1)](_0x5749fe(0xc7))['catch'](_0x54f549=>this[_0x5749fe(0xf3)](_0x5749fe(0xd2)+_0x54f549[_0x5749fe(0xb7)]));},this[_0x507dec(0xc8)]),this['connectSSE']();}async['disconnect'](){const _0x2b6c17=a0_0x39040b;if(this[_0x2b6c17(0x102)]=!0x1,this['sseAbort']?.[_0x2b6c17(0xd8)](),this[_0x2b6c17(0xd0)])clearInterval(this[_0x2b6c17(0xd0)]);await this[_0x2b6c17(0xd1)](_0x2b6c17(0xe4))[_0x2b6c17(0xf1)](()=>{}),this[_0x2b6c17(0xf3)]('disconnected');}async['send'](_0x24aed3,_0x192b0f,_0x306d83=a0_0x39040b(0xd4)){const _0x3a92af=a0_0x39040b;return this[_0x3a92af(0x109)](_0x3a92af(0xc2),{'alias':_0x24aed3,'task':_0x192b0f,'priority':_0x306d83,'from_session':this['alias']});}async['message'](_0x2f029e,_0x5dacc3){const _0x3a7b44=a0_0x39040b;return this[_0x3a7b44(0x109)](_0x3a7b44(0xf7),{'alias':_0x2f029e,'message':_0x5dacc3,'from_session':this[_0x3a7b44(0xf4)]});}async[a0_0x39040b(0xc6)](_0x592113,_0x5742a2,_0x2c3bbf=a0_0x39040b(0xea)){const _0x16eccb=a0_0x39040b;return this['call'](_0x16eccb(0xd9),{'in_reply_to':_0x592113,'text':_0x5742a2,'status':_0x2c3bbf});}async['status'](_0x143e91,_0x17b06e){const _0x121db4=a0_0x39040b;return this[_0x121db4(0x109)](_0x121db4(0x101),{'resume_id':this[_0x121db4(0xf6)],'alias':this[_0x121db4(0xf4)],'status':_0x143e91,'server':a0_0x128a22(),'hostname':a0_0x128a22(),'agent':this[_0x121db4(0xe8)],'project_dir':process[_0x121db4(0xcf)](),..._0x17b06e});}async[a0_0x39040b(0xe0)](){const _0x40ba54=a0_0x39040b;return this[_0x40ba54(0x109)]('get_all_status',{});}async[a0_0x39040b(0xc1)](_0x330e12,_0x19fbbf){const _0xd4ee60=a0_0x39040b;return this[_0xd4ee60(0x109)](_0xd4ee60(0xc1),{'message':_0x330e12,'filter_server':_0x19fbbf?.[_0xd4ee60(0xb5)],'filter_status':_0x19fbbf?.[_0xd4ee60(0xd1)]});}async[a0_0x39040b(0xb3)](){const _0x168cba=a0_0x39040b;let _0x2b2e0e=encodeURIComponent(this[_0x168cba(0xf4)]),_0x3e799d=this[_0x168cba(0xfc)]+'/events/'+_0x2b2e0e,_0x38efbc=this[_0x168cba(0xf5)];while(this[_0x168cba(0x102)]){try{this[_0x168cba(0xdd)]=new AbortController();let _0x1003f6={'Accept':_0x168cba(0xf2)};if(this[_0x168cba(0xf9)])_0x1003f6[_0x168cba(0xfe)]=_0x168cba(0xe1)+this[_0x168cba(0xf9)];let _0x451ca2=await fetch(_0x3e799d,{'headers':_0x1003f6,'signal':this[_0x168cba(0xdd)][_0x168cba(0xe9)]});if(!_0x451ca2['ok']||!_0x451ca2[_0x168cba(0xc9)]){this[_0x168cba(0xf3)](_0x168cba(0xee)+_0x451ca2[_0x168cba(0xd1)]),await this['sleep'](_0x38efbc),_0x38efbc=Math['min'](_0x38efbc*1.5,0xea60);continue;}_0x38efbc=this[_0x168cba(0xf5)];let _0x467679=_0x451ca2[_0x168cba(0xc9)]['getReader'](),_0x1fe17d=new TextDecoder(),_0x19ee25='';while(this[_0x168cba(0x102)]){let {done:_0xdc7ac5,value:_0xd8036}=await _0x467679[_0x168cba(0xb6)]();if(_0xdc7ac5)break;_0x19ee25+=_0x1fe17d[_0x168cba(0xef)](_0xd8036,{'stream':!0x0});let _0x4134c1=_0x19ee25[_0x168cba(0xec)]('\x0a');_0x19ee25=_0x4134c1[_0x168cba(0xbe)]()||'';for(let _0x547216 of _0x4134c1){if(!_0x547216[_0x168cba(0xbb)](_0x168cba(0xbd)))continue;try{let _0xd8573d=JSON[_0x168cba(0xdc)](_0x547216[_0x168cba(0x105)](0x6));if(_0xd8573d[_0x168cba(0xb9)]==='connected'){this[_0x168cba(0xf3)]('SSE\x20connected'),this[_0x168cba(0xf0)]('connected');continue;}if(_0xd8573d['type']===_0x168cba(0xd5)||_0xd8573d['type']===_0x168cba(0xbf)||_0xd8573d['type']===_0x168cba(0xc1))await this[_0x168cba(0xd6)]();}catch{}}}}catch(_0x76544a){if(_0x76544a[_0x168cba(0xdb)]===_0x168cba(0xbc))break;this[_0x168cba(0xf0)]('error',_0x76544a),this[_0x168cba(0xf3)](_0x168cba(0xe3)+_0x76544a[_0x168cba(0xb7)]);}if(this[_0x168cba(0x102)])this[_0x168cba(0xf0)](_0x168cba(0xca)),this[_0x168cba(0xf3)]('SSE\x20reconnecting\x20in\x20'+_0x38efbc/0x3e8+'s...'),await this['sleep'](_0x38efbc),_0x38efbc=Math[_0x168cba(0xde)](_0x38efbc*1.5,0xea60);}}async[a0_0x39040b(0xd6)](){const _0x1d0c4c=a0_0x39040b;try{let _0x516bb7=(await this[_0x1d0c4c(0x109)](_0x1d0c4c(0x100),{'alias':this[_0x1d0c4c(0xf4)],'limit':0xa}))?.[_0x1d0c4c(0xd7)]||[];for(let _0x2d7ff2 of _0x516bb7)await this[_0x1d0c4c(0x109)](_0x1d0c4c(0x103),{'alias':this[_0x1d0c4c(0xf4)],'message_id':_0x2d7ff2['id']}),this[_0x1d0c4c(0xf3)]('←\x20'+_0x2d7ff2[_0x1d0c4c(0xcc)]+':\x20'+_0x2d7ff2[_0x1d0c4c(0xc4)][_0x1d0c4c(0x105)](0x0,0x3c)),this[_0x1d0c4c(0xf0)]('task',_0x2d7ff2),this['emit'](_0x1d0c4c(0xb7),_0x2d7ff2);}catch(_0x49cb9c){this[_0x1d0c4c(0xf3)](_0x1d0c4c(0xce)+_0x49cb9c[_0x1d0c4c(0xb7)]);}}['sleep'](_0x32e54e){return new Promise(_0x493b64=>setTimeout(_0x493b64,_0x32e54e));}}function a0_0x6800(){const _0x5745bb=['signal','completed','423660GDjeqU','split','171332ZuXwpb','SSE\x20failed:\x20','decode','emit','catch','text/event-stream','log','alias','reconnectDelay','resumeId','send_message','60pnXDEj','token','5749638dLjXbO','toTimeString','url','now','Authorization','result','get_inbox','report_status','running','ack_inbox','application/json','slice','POST','93723yHyEix','164760amRLki','call','connectSSE','sdk-','server','read','message','sdk','type','/mcp','startsWith','AbortError','data:\x20','pop','new_message','connect','broadcast','send_task',']\x20[commhub:','content','toString','reply','idle','heartbeatInterval','body','disconnected','327932mZSOHZ','from_session','94gvhBQl','inbox\x20error:\x20','cwd','heartbeatTimer','status','heartbeat\x20failed:\x20','2.0','normal','new_task','processInbox','messages','abort','send_reply','text','name','parse','sseAbort','min','tools/call','getAllStatus','Bearer\x20','replace','SSE\x20error:\x20','offline','24LrbntV','autoConnect','1975743NlnNmf','agent'];a0_0x6800=function(){return _0x5745bb;};return a0_0x6800();}var $=T;export{$ as default,T as CommHub};
@@ -0,0 +1,115 @@
1
+ import type { Duplex } from "node:stream";
2
+ export declare const GROK_ATTACH_PROTOCOL = "anet-grok-copresence-attach";
3
+ export declare const GROK_ATTACH_PROTOCOL_VERSION = 1;
4
+ export declare const GROK_ATTACH_DEFAULT_MAX_FRAME_BYTES: number;
5
+ export declare const GROK_ATTACH_DEFAULT_MAX_BUFFER_BYTES: number;
6
+ export declare const GROK_ATTACH_DEFAULT_HANDSHAKE_TIMEOUT_MS = 5000;
7
+ export declare const GROK_ATTACH_DEFAULT_CLOSE_TIMEOUT_MS = 1000;
8
+ export type GrokAttachJsonValue = null | boolean | number | string | GrokAttachJsonValue[] | {
9
+ [key: string]: GrokAttachJsonValue;
10
+ };
11
+ export interface GrokAttachHelloFrame {
12
+ type: "hello";
13
+ protocol: typeof GROK_ATTACH_PROTOCOL;
14
+ version: typeof GROK_ATTACH_PROTOCOL_VERSION;
15
+ alias: string;
16
+ sessionId: string;
17
+ [key: string]: unknown;
18
+ }
19
+ export interface GrokAttachOutputFrame {
20
+ type: "output";
21
+ data: string;
22
+ encoding: "base64";
23
+ }
24
+ export interface GrokAttachStatusFrame {
25
+ type: "status";
26
+ status: GrokAttachJsonValue;
27
+ }
28
+ export interface GrokAttachErrorFrame {
29
+ type: "error";
30
+ code: string;
31
+ message: string;
32
+ fatal: boolean;
33
+ }
34
+ export interface GrokAttachDetachFrame {
35
+ type: "detach";
36
+ }
37
+ export type GrokAttachServerFrame = GrokAttachHelloFrame | GrokAttachOutputFrame | GrokAttachStatusFrame | GrokAttachErrorFrame | GrokAttachDetachFrame;
38
+ export interface GrokAttachInputFrame {
39
+ type: "input";
40
+ data: string;
41
+ encoding: "base64";
42
+ }
43
+ export interface GrokAttachResizeFrame {
44
+ type: "resize";
45
+ cols: number;
46
+ rows: number;
47
+ }
48
+ export type GrokAttachClientFrame = GrokAttachInputFrame | GrokAttachResizeFrame | GrokAttachDetachFrame;
49
+ export interface GrokAttachInputSource {
50
+ on(event: "data", listener: (chunk: unknown) => void): unknown;
51
+ on(event: "end", listener: () => void): unknown;
52
+ off?(event: "data" | "end", listener: (...args: any[]) => void): unknown;
53
+ removeListener?(event: "data" | "end", listener: (...args: any[]) => void): unknown;
54
+ pause?(): unknown;
55
+ resume?(): unknown;
56
+ }
57
+ export interface GrokAttachOutputSink {
58
+ write(chunk: Uint8Array): boolean | void;
59
+ columns?: number;
60
+ rows?: number;
61
+ once?(event: "drain", listener: () => void): unknown;
62
+ }
63
+ export interface GrokAttachSignalSource {
64
+ on(event: "SIGWINCH", listener: () => void): unknown;
65
+ off?(event: "SIGWINCH", listener: () => void): unknown;
66
+ removeListener?(event: "SIGWINCH", listener: () => void): unknown;
67
+ }
68
+ export interface GrokAttachSocketStat {
69
+ uid: number;
70
+ isSocket(): boolean;
71
+ isSymbolicLink(): boolean;
72
+ }
73
+ export interface GrokAttachDependencies {
74
+ lstat?: (socketPath: string) => Promise<GrokAttachSocketStat>;
75
+ getuid?: () => number | undefined;
76
+ connect?: (socketPath: string) => Duplex;
77
+ }
78
+ export interface GrokAttachClientOptions {
79
+ socketPath: string;
80
+ input: GrokAttachInputSource;
81
+ output: GrokAttachOutputSink;
82
+ signalSource?: GrokAttachSignalSource;
83
+ terminalSize?: () => {
84
+ cols: number | undefined;
85
+ rows: number | undefined;
86
+ };
87
+ maxFrameBytes?: number;
88
+ maxBufferBytes?: number;
89
+ handshakeTimeoutMs?: number;
90
+ closeTimeoutMs?: number;
91
+ detachOnInputEnd?: boolean;
92
+ onHello?: (frame: GrokAttachHelloFrame) => void;
93
+ onStatus?: (frame: GrokAttachStatusFrame) => void;
94
+ onError?: (error: Error, frame?: GrokAttachErrorFrame) => void;
95
+ onDetach?: (frame: GrokAttachDetachFrame) => void;
96
+ dependencies?: GrokAttachDependencies;
97
+ }
98
+ export type GrokAttachCloseReason = "local-detach" | "input-end" | "remote-detach" | "socket-close" | "socket-error" | "protocol-error";
99
+ export interface GrokAttachCloseInfo {
100
+ reason: GrokAttachCloseReason;
101
+ error?: Error;
102
+ }
103
+ export interface GrokAttachSession {
104
+ readonly socketPath: string;
105
+ readonly closed: Promise<GrokAttachCloseInfo>;
106
+ detach(): void;
107
+ resize(cols?: number, rows?: number): void;
108
+ }
109
+ export declare class GrokAttachRemoteError extends Error {
110
+ readonly code: string;
111
+ readonly fatal: boolean;
112
+ constructor(frame: GrokAttachErrorFrame);
113
+ }
114
+ export declare function validateGrokAttachSocket(socketPath: string, dependencies?: GrokAttachDependencies): Promise<void>;
115
+ export declare function connectGrokAttach(options: GrokAttachClientOptions): Promise<GrokAttachSession>;
@@ -0,0 +1,44 @@
1
+ export declare const GROK_UNIX_SOCKET_PATH_MAX_BYTES = 100;
2
+ export declare const GROK_COPRESENCE_CAPABILITY_MARKER = "ANET_CAPABILITY_GROK_COPRESENCE_V2";
3
+ export declare const GROK_PREVIEW_RESOLVER_INHERITED_ENV_KEYS: readonly ["PATH", "TMPDIR", "TMP", "TEMP", "LANG", "LC_ALL", "LC_CTYPE", "TZ"];
4
+ export declare const GROK_AGENT_NODE_INHERITED_ENV_KEYS: readonly ["PATH", "HOME", "TMPDIR", "TMP", "TEMP", "LANG", "LC_ALL", "LC_CTYPE", "TZ", "SHELL", "USER", "LOGNAME", "TERM", "COLORTERM", "NO_COLOR"];
5
+ export declare const GROK_AGENT_NODE_OPTIONAL_ENV_KEYS: readonly ["GROK_BINARY", "GROK_HOME", "FLOCK_BINARY", "SETPRIV_BINARY", "UNSHARE_BINARY", "GROK_CLI_TIMEOUT_MS", "GROK_HANDSHAKE_TIMEOUT_MS", "LOG_LEVEL", "ANET_GOAL_TICK_MS", "COMMHUB_MAX_GOALS_PER_NODE"];
6
+ /** Exact environment for the long-lived agent-node parent of the Grok TUI. */
7
+ export declare function buildGrokAgentNodeEnv(parentEnv: NodeJS.ProcessEnv): Record<string, string>;
8
+ export declare function grokPreviewResolverConfigPaths(home: string): {
9
+ directory: string;
10
+ userConfig: string;
11
+ globalConfig: string;
12
+ };
13
+ /**
14
+ * npm rejects loading the same file as both user and global config. Prepare
15
+ * two distinct, empty, owner-only files without following a final symlink so
16
+ * the resolver cannot inherit a user's ordinary npmrc credentials.
17
+ */
18
+ export declare function prepareGrokPreviewResolverConfigs(home: string): void;
19
+ /** Exact environment for the short-lived npm resolver and capability probe. */
20
+ export declare function buildGrokPreviewResolverEnv(parentEnv: NodeJS.ProcessEnv, home: string): Record<string, string>;
21
+ /** Old headless-only agent-node builds already advertised grok-build-cli. */
22
+ export declare function agentNodeHelpSupportsGrokCopresence(help: string): boolean;
23
+ export interface GrokCopresenceProfileFields {
24
+ grokCopresence: boolean;
25
+ grokLeaderSocket?: string;
26
+ grokAttachSocket?: string;
27
+ }
28
+ export interface GrokSocketPathOptions {
29
+ cwd?: string;
30
+ home?: string;
31
+ xdgRuntimeDir?: string;
32
+ uid?: number;
33
+ platform?: NodeJS.Platform;
34
+ }
35
+ /**
36
+ * Allocate deterministic, short Unix socket paths without creating anything.
37
+ * The runtime owns directory creation and permissions; `anet node create`
38
+ * only persists the identity of the two sockets.
39
+ */
40
+ export declare function grokCopresenceSocketPaths(nodeId: string, options?: GrokSocketPathOptions): {
41
+ leaderSocket: string;
42
+ attachSocket: string;
43
+ };
44
+ export declare function grokBuildCliCreationFields(runtime: string, nodeId: string, headless?: boolean, options?: GrokSocketPathOptions): GrokCopresenceProfileFields | Record<string, never>;