@sleep2agi/agent-network 2.3.0-preview.22 → 2.3.0-preview.23

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_0x1ae8e8=a0_0x418b;function a0_0x418b(_0x316f8a,_0x2d32c8){_0x316f8a=_0x316f8a-0x1cf;const _0x2ce83d=a0_0x2ce8();let _0x418b64=_0x2ce83d[_0x316f8a];return _0x418b64;}(function(_0x15c4d1,_0x524cf8){const _0x11ce2e=a0_0x418b,_0x16c4e7=_0x15c4d1();while(!![]){try{const _0x4ffbd6=-parseInt(_0x11ce2e(0x215))/0x1+-parseInt(_0x11ce2e(0x214))/0x2+parseInt(_0x11ce2e(0x1e6))/0x3*(parseInt(_0x11ce2e(0x1e0))/0x4)+-parseInt(_0x11ce2e(0x1df))/0x5*(parseInt(_0x11ce2e(0x1e9))/0x6)+parseInt(_0x11ce2e(0x208))/0x7+parseInt(_0x11ce2e(0x1d1))/0x8*(parseInt(_0x11ce2e(0x1f5))/0x9)+parseInt(_0x11ce2e(0x1e3))/0xa;if(_0x4ffbd6===_0x524cf8)break;else _0x16c4e7['push'](_0x16c4e7['shift']());}catch(_0x55d483){_0x16c4e7['push'](_0x16c4e7['shift']());}}}(a0_0x2ce8,0x8351d));function a0_0x2ce8(){const _0x42e57b=['message','now','report_status','decode','emit','startsWith','match','autoConnect','offline','SSE\x20failed:\x20','57688VdwCev','get_inbox','running','heartbeat\x20failed:\x20','heartbeatTimer','signal','status','catch','AbortError','get_all_status','toString','body','content','min','313340fLFcup','2916DbREny','Bearer\x20','data:\x20','8226330bfZMPY','read','2.0','3309gpbQzr','sdk-','type','96GkJQMB','task','replace','new_message','tools/call','broadcast',']\x20[commhub:','application/json','connectSSE','text','reconnectDelay','call','1161pHfTqK','application/json,\x20text/event-stream','/events/','sleep','split','new_task','send','stringify','idle','registered','slice','log','disconnect','SSE\x20connected','completed','Authorization','ack_inbox','send_reply','cwd','3774344KQPWvk','error','SSE\x20error:\x20','alias','connect','processInbox','sseAbort','send_task','normal','inbox\x20error:\x20','disconnected','name','1422856jfTHPx','844130BbrutR','connected','parse','token','resumeId','/mcp','send_message','SSE\x20reconnecting\x20in\x20','agent','abort','url','heartbeatInterval','text/event-stream'];a0_0x2ce8=function(){return _0x42e57b;};return a0_0x2ce8();}import{EventEmitter as a0_0x4108bc}from'events';import{hostname as a0_0x16c13a}from'os';class T extends a0_0x4108bc{['url'];[a0_0x1ae8e8(0x20b)];['token'];['agent'];[a0_0x1ae8e8(0x219)];['heartbeatInterval'];[a0_0x1ae8e8(0x1f3)];[a0_0x1ae8e8(0x1d5)];[a0_0x1ae8e8(0x20e)];[a0_0x1ae8e8(0x1d3)]=!0x1;constructor(_0xef7e84){const _0x4d6805=a0_0x1ae8e8;super();if(this[_0x4d6805(0x21f)]=_0xef7e84[_0x4d6805(0x21f)][_0x4d6805(0x1eb)](/\/$/,''),this['alias']=_0xef7e84['alias'],this[_0x4d6805(0x218)]=_0xef7e84[_0x4d6805(0x218)],this[_0x4d6805(0x21d)]=_0xef7e84['agent']||'sdk',this[_0x4d6805(0x219)]=_0x4d6805(0x1e7)+_0xef7e84[_0x4d6805(0x20b)]+'-'+Date['now']()[_0x4d6805(0x1db)](0x24),this['heartbeatInterval']=_0xef7e84[_0x4d6805(0x220)]??0x2bf20,this[_0x4d6805(0x1f3)]=_0xef7e84[_0x4d6805(0x1f3)]??0xbb8,_0xef7e84[_0x4d6805(0x229)]!==!0x1)this[_0x4d6805(0x20c)]();}[a0_0x1ae8e8(0x200)](_0x398a26){const _0x571d92=a0_0x1ae8e8;console[_0x571d92(0x200)]('['+new Date()['toTimeString']()['slice'](0x0,0x8)+_0x571d92(0x1ef)+this['alias']+']\x20'+_0x398a26);}async[a0_0x1ae8e8(0x1f4)](_0x31f369,_0xdb810e){const _0x22eb2b=a0_0x1ae8e8;let _0x17a2da={'Content-Type':_0x22eb2b(0x1f0),'Accept':_0x22eb2b(0x1f6)};if(this[_0x22eb2b(0x218)])_0x17a2da[_0x22eb2b(0x204)]=_0x22eb2b(0x1e1)+this[_0x22eb2b(0x218)];let _0x242bd7=await(await fetch(this[_0x22eb2b(0x21f)]+_0x22eb2b(0x21a),{'method':'POST','headers':_0x17a2da,'body':JSON[_0x22eb2b(0x1fc)]({'jsonrpc':_0x22eb2b(0x1e5),'id':Date[_0x22eb2b(0x223)](),'method':_0x22eb2b(0x1ed),'params':{'name':_0x31f369,'arguments':_0xdb810e}})}))[_0x22eb2b(0x1f2)](),_0x2aaae1=_0x242bd7[_0x22eb2b(0x228)](/data: (.+)/),_0x567f97=_0x2aaae1?JSON[_0x22eb2b(0x217)](_0x2aaae1[0x1]):JSON[_0x22eb2b(0x217)](_0x242bd7),_0x46e392=_0x567f97?.['result']?.[_0x22eb2b(0x1dd)]?.[0x0]?.[_0x22eb2b(0x1f2)];return _0x46e392?JSON[_0x22eb2b(0x217)](_0x46e392):_0x567f97;}async['connect'](){const _0x405717=a0_0x1ae8e8;if(this['running'])return;this['running']=!0x0,await this['status'](_0x405717(0x1fd)),this[_0x405717(0x200)](_0x405717(0x1fe)),this[_0x405717(0x1d5)]=setInterval(()=>{const _0x467dac=_0x405717;this[_0x467dac(0x1d7)](_0x467dac(0x1fd))[_0x467dac(0x1d8)](_0x323da3=>this['log'](_0x467dac(0x1d4)+_0x323da3[_0x467dac(0x222)]));},this[_0x405717(0x220)]),this[_0x405717(0x1f1)]();}async[a0_0x1ae8e8(0x201)](){const _0x5a5158=a0_0x1ae8e8;if(this[_0x5a5158(0x1d3)]=!0x1,this[_0x5a5158(0x20e)]?.[_0x5a5158(0x21e)](),this[_0x5a5158(0x1d5)])clearInterval(this[_0x5a5158(0x1d5)]);await this[_0x5a5158(0x1d7)](_0x5a5158(0x1cf))[_0x5a5158(0x1d8)](()=>{}),this[_0x5a5158(0x200)](_0x5a5158(0x212));}async[a0_0x1ae8e8(0x1fb)](_0x4c2f37,_0xa81b2e,_0x366b8f=a0_0x1ae8e8(0x210)){const _0x1e01ea=a0_0x1ae8e8;return this['call'](_0x1e01ea(0x20f),{'alias':_0x4c2f37,'task':_0xa81b2e,'priority':_0x366b8f,'from_session':this['alias']});}async[a0_0x1ae8e8(0x222)](_0xc518a2,_0x544b7b){const _0xb5684d=a0_0x1ae8e8;return this[_0xb5684d(0x1f4)](_0xb5684d(0x21b),{'alias':_0xc518a2,'message':_0x544b7b,'from_session':this[_0xb5684d(0x20b)]});}async['reply'](_0x5d6a21,_0x387945,_0x67004=a0_0x1ae8e8(0x203)){const _0x92f117=a0_0x1ae8e8;return this[_0x92f117(0x1f4)](_0x92f117(0x206),{'in_reply_to':_0x5d6a21,'text':_0x387945,'status':_0x67004});}async['status'](_0x10820c,_0x251d24){const _0xe4e570=a0_0x1ae8e8;return this[_0xe4e570(0x1f4)](_0xe4e570(0x224),{'resume_id':this[_0xe4e570(0x219)],'alias':this[_0xe4e570(0x20b)],'status':_0x10820c,'server':a0_0x16c13a(),'hostname':a0_0x16c13a(),'agent':this['agent'],'project_dir':process[_0xe4e570(0x207)](),..._0x251d24});}async['getAllStatus'](){const _0x50c39d=a0_0x1ae8e8;return this[_0x50c39d(0x1f4)](_0x50c39d(0x1da),{});}async[a0_0x1ae8e8(0x1ee)](_0xadb8b0,_0x2b457d){const _0x368e6=a0_0x1ae8e8;return this[_0x368e6(0x1f4)](_0x368e6(0x1ee),{'message':_0xadb8b0,'filter_server':_0x2b457d?.['server'],'filter_status':_0x2b457d?.['status']});}async[a0_0x1ae8e8(0x1f1)](){const _0x5b339e=a0_0x1ae8e8;let _0x1d8c27=encodeURIComponent(this[_0x5b339e(0x20b)]),_0x364b23=this[_0x5b339e(0x21f)]+_0x5b339e(0x1f7)+_0x1d8c27,_0xa6c448=this[_0x5b339e(0x1f3)];while(this['running']){try{this[_0x5b339e(0x20e)]=new AbortController();let _0x19c779={'Accept':_0x5b339e(0x221)};if(this[_0x5b339e(0x218)])_0x19c779[_0x5b339e(0x204)]='Bearer\x20'+this[_0x5b339e(0x218)];let _0x47cfc0=await fetch(_0x364b23,{'headers':_0x19c779,'signal':this['sseAbort'][_0x5b339e(0x1d6)]});if(!_0x47cfc0['ok']||!_0x47cfc0['body']){this[_0x5b339e(0x200)](_0x5b339e(0x1d0)+_0x47cfc0[_0x5b339e(0x1d7)]),await this[_0x5b339e(0x1f8)](_0xa6c448),_0xa6c448=Math[_0x5b339e(0x1de)](_0xa6c448*1.5,0xea60);continue;}_0xa6c448=this[_0x5b339e(0x1f3)];let _0x10c073=_0x47cfc0[_0x5b339e(0x1dc)]['getReader'](),_0x365ac7=new TextDecoder(),_0x34bb50='';while(this['running']){let {done:_0xc07b5f,value:_0x18c9c2}=await _0x10c073[_0x5b339e(0x1e4)]();if(_0xc07b5f)break;_0x34bb50+=_0x365ac7[_0x5b339e(0x225)](_0x18c9c2,{'stream':!0x0});let _0x2c40ae=_0x34bb50[_0x5b339e(0x1f9)]('\x0a');_0x34bb50=_0x2c40ae['pop']()||'';for(let _0x381516 of _0x2c40ae){if(!_0x381516[_0x5b339e(0x227)](_0x5b339e(0x1e2)))continue;try{let _0x49957f=JSON['parse'](_0x381516[_0x5b339e(0x1ff)](0x6));if(_0x49957f[_0x5b339e(0x1e8)]==='connected'){this['log'](_0x5b339e(0x202)),this[_0x5b339e(0x226)](_0x5b339e(0x216));continue;}if(_0x49957f[_0x5b339e(0x1e8)]===_0x5b339e(0x1fa)||_0x49957f['type']===_0x5b339e(0x1ec)||_0x49957f[_0x5b339e(0x1e8)]===_0x5b339e(0x1ee))await this[_0x5b339e(0x20d)]();}catch{}}}}catch(_0x533554){if(_0x533554[_0x5b339e(0x213)]===_0x5b339e(0x1d9))break;this[_0x5b339e(0x226)](_0x5b339e(0x209),_0x533554),this[_0x5b339e(0x200)](_0x5b339e(0x20a)+_0x533554[_0x5b339e(0x222)]);}if(this[_0x5b339e(0x1d3)])this[_0x5b339e(0x226)](_0x5b339e(0x212)),this['log'](_0x5b339e(0x21c)+_0xa6c448/0x3e8+'s...'),await this[_0x5b339e(0x1f8)](_0xa6c448),_0xa6c448=Math[_0x5b339e(0x1de)](_0xa6c448*1.5,0xea60);}}async[a0_0x1ae8e8(0x20d)](){const _0x2dbe49=a0_0x1ae8e8;try{let _0x3d23a2=(await this[_0x2dbe49(0x1f4)](_0x2dbe49(0x1d2),{'alias':this[_0x2dbe49(0x20b)],'limit':0xa}))?.['messages']||[];for(let _0x19736a of _0x3d23a2)await this[_0x2dbe49(0x1f4)](_0x2dbe49(0x205),{'alias':this[_0x2dbe49(0x20b)],'message_id':_0x19736a['id']}),this[_0x2dbe49(0x200)]('←\x20'+_0x19736a['from_session']+':\x20'+_0x19736a[_0x2dbe49(0x1dd)][_0x2dbe49(0x1ff)](0x0,0x3c)),this[_0x2dbe49(0x226)](_0x2dbe49(0x1ea),_0x19736a),this[_0x2dbe49(0x226)](_0x2dbe49(0x222),_0x19736a);}catch(_0x293ecd){this[_0x2dbe49(0x200)](_0x2dbe49(0x211)+_0x293ecd['message']);}}[a0_0x1ae8e8(0x1f8)](_0x132b2d){return new Promise(_0xc24840=>setTimeout(_0xc24840,_0x132b2d));}}var $=T;export{$ as default,T as CommHub};
1
+ const a0_0x5e1a20=a0_0x191f;(function(_0x52f11e,_0xa4f06a){const _0x26418f=a0_0x191f,_0x40b362=_0x52f11e();while(!![]){try{const _0x2b1232=parseInt(_0x26418f(0x1ba))/0x1*(-parseInt(_0x26418f(0x1ca))/0x2)+parseInt(_0x26418f(0x1af))/0x3+parseInt(_0x26418f(0x1f2))/0x4+-parseInt(_0x26418f(0x1da))/0x5*(-parseInt(_0x26418f(0x1df))/0x6)+parseInt(_0x26418f(0x1c4))/0x7*(parseInt(_0x26418f(0x1e3))/0x8)+-parseInt(_0x26418f(0x1b4))/0x9*(-parseInt(_0x26418f(0x1b0))/0xa)+-parseInt(_0x26418f(0x1e2))/0xb;if(_0x2b1232===_0xa4f06a)break;else _0x40b362['push'](_0x40b362['shift']());}catch(_0x3472f9){_0x40b362['push'](_0x40b362['shift']());}}}(a0_0x94f9,0x971f7));function a0_0x191f(_0x33e9c5,_0x27116a){_0x33e9c5=_0x33e9c5-0x19e;const _0x94f914=a0_0x94f9();let _0x191f93=_0x94f914[_0x33e9c5];return _0x191f93;}import{EventEmitter as a0_0x57a66e}from'events';import{hostname as a0_0x65b978}from'os';class T extends a0_0x57a66e{['url'];[a0_0x5e1a20(0x1a8)];[a0_0x5e1a20(0x1a6)];[a0_0x5e1a20(0x1d2)];[a0_0x5e1a20(0x1b6)];[a0_0x5e1a20(0x1db)];[a0_0x5e1a20(0x1a2)];['heartbeatTimer'];[a0_0x5e1a20(0x1a4)];[a0_0x5e1a20(0x1bc)]=!0x1;constructor(_0x1172de){const _0x3ee4dd=a0_0x5e1a20;super();if(this[_0x3ee4dd(0x1a3)]=_0x1172de[_0x3ee4dd(0x1a3)][_0x3ee4dd(0x1cf)](/\/$/,''),this[_0x3ee4dd(0x1a8)]=_0x1172de['alias'],this[_0x3ee4dd(0x1a6)]=_0x1172de[_0x3ee4dd(0x1a6)],this[_0x3ee4dd(0x1d2)]=_0x1172de[_0x3ee4dd(0x1d2)]||'sdk',this[_0x3ee4dd(0x1b6)]=_0x3ee4dd(0x1a7)+_0x1172de['alias']+'-'+Date[_0x3ee4dd(0x1f3)]()[_0x3ee4dd(0x1b5)](0x24),this[_0x3ee4dd(0x1db)]=_0x1172de[_0x3ee4dd(0x1db)]??0x2bf20,this['reconnectDelay']=_0x1172de[_0x3ee4dd(0x1a2)]??0xbb8,_0x1172de[_0x3ee4dd(0x1c0)]!==!0x1)this[_0x3ee4dd(0x1f8)]();}[a0_0x5e1a20(0x1d6)](_0x504590){const _0x205f30=a0_0x5e1a20;console[_0x205f30(0x1d6)]('['+new Date()[_0x205f30(0x1c2)]()[_0x205f30(0x1e9)](0x0,0x8)+_0x205f30(0x1d4)+this['alias']+']\x20'+_0x504590);}async[a0_0x5e1a20(0x1f7)](_0x557bc1,_0x5fa88a){const _0x2d9e86=a0_0x5e1a20;let _0x3d5ebf={'Content-Type':_0x2d9e86(0x1d0),'Accept':_0x2d9e86(0x1dd)};if(this[_0x2d9e86(0x1a6)])_0x3d5ebf[_0x2d9e86(0x1d3)]='Bearer\x20'+this[_0x2d9e86(0x1a6)];let _0x400d6b=await(await fetch(this[_0x2d9e86(0x1a3)]+'/mcp',{'method':_0x2d9e86(0x1ee),'headers':_0x3d5ebf,'body':JSON[_0x2d9e86(0x1dc)]({'jsonrpc':_0x2d9e86(0x1ac),'id':Date[_0x2d9e86(0x1f3)](),'method':_0x2d9e86(0x1aa),'params':{'name':_0x557bc1,'arguments':_0x5fa88a}})}))[_0x2d9e86(0x1b2)](),_0x4a373e=_0x400d6b[_0x2d9e86(0x1f9)](/data: (.+)/),_0x1d4a05=_0x4a373e?JSON['parse'](_0x4a373e[0x1]):JSON[_0x2d9e86(0x1e8)](_0x400d6b),_0x284e65=_0x1d4a05?.[_0x2d9e86(0x1f4)]?.[_0x2d9e86(0x1f6)]?.[0x0]?.[_0x2d9e86(0x1b2)];return _0x284e65?JSON[_0x2d9e86(0x1e8)](_0x284e65):_0x1d4a05;}async[a0_0x5e1a20(0x1f8)](){const _0x2590ba=a0_0x5e1a20;if(this[_0x2590ba(0x1bc)])return;this[_0x2590ba(0x1bc)]=!0x0,await this['status'](_0x2590ba(0x1d9)),this[_0x2590ba(0x1d6)](_0x2590ba(0x1e7)),this[_0x2590ba(0x1a0)]=setInterval(()=>{const _0x1decd9=_0x2590ba;this[_0x1decd9(0x1e6)](_0x1decd9(0x1d9))[_0x1decd9(0x1c6)](_0x7108ae=>this[_0x1decd9(0x1d6)](_0x1decd9(0x1d1)+_0x7108ae[_0x1decd9(0x1f5)]));},this[_0x2590ba(0x1db)]),this[_0x2590ba(0x1e4)]();}async[a0_0x5e1a20(0x1e0)](){const _0x556f39=a0_0x5e1a20;if(this['running']=!0x1,this[_0x556f39(0x1a4)]?.[_0x556f39(0x1d8)](),this['heartbeatTimer'])clearInterval(this[_0x556f39(0x1a0)]);await this[_0x556f39(0x1e6)](_0x556f39(0x19f))[_0x556f39(0x1c6)](()=>{}),this['log'](_0x556f39(0x1ef));}async[a0_0x5e1a20(0x1ae)](_0x53c7b7,_0x369fdb,_0x22dc50=a0_0x5e1a20(0x1c3)){const _0x211baf=a0_0x5e1a20;return this[_0x211baf(0x1f7)](_0x211baf(0x1f0),{'alias':_0x53c7b7,'task':_0x369fdb,'priority':_0x22dc50,'from_session':this[_0x211baf(0x1a8)]});}async['message'](_0x5187c3,_0x359057){const _0x17955d=a0_0x5e1a20;return this[_0x17955d(0x1f7)](_0x17955d(0x1b9),{'alias':_0x5187c3,'message':_0x359057,'from_session':this[_0x17955d(0x1a8)]});}async[a0_0x5e1a20(0x1be)](_0x39acc8,_0x1e47b0,_0x260230='completed'){const _0x16d683=a0_0x5e1a20;return this[_0x16d683(0x1f7)]('send_reply',{'in_reply_to':_0x39acc8,'text':_0x1e47b0,'status':_0x260230});}async['status'](_0x55de05,_0x350fe1){const _0x8b8c4f=a0_0x5e1a20;return this[_0x8b8c4f(0x1f7)]('report_status',{'resume_id':this[_0x8b8c4f(0x1b6)],'alias':this[_0x8b8c4f(0x1a8)],'status':_0x55de05,'server':a0_0x65b978(),'hostname':a0_0x65b978(),'agent':this[_0x8b8c4f(0x1d2)],'project_dir':process[_0x8b8c4f(0x1de)](),..._0x350fe1});}async[a0_0x5e1a20(0x1d7)](){const _0x1cabd1=a0_0x5e1a20;return this[_0x1cabd1(0x1f7)](_0x1cabd1(0x1e1),{});}async[a0_0x5e1a20(0x1bf)](_0x530af3,_0x518e62){const _0x3edcd3=a0_0x5e1a20;return this[_0x3edcd3(0x1f7)](_0x3edcd3(0x1bf),{'message':_0x530af3,'filter_server':_0x518e62?.[_0x3edcd3(0x1ec)],'filter_status':_0x518e62?.[_0x3edcd3(0x1e6)]});}async[a0_0x5e1a20(0x1e4)](){const _0x5b31d6=a0_0x5e1a20;let _0x4bdc23=encodeURIComponent(this[_0x5b31d6(0x1a8)]),_0x5a2d0b=this['url']+_0x5b31d6(0x1fa)+_0x4bdc23,_0x1e17ac=this[_0x5b31d6(0x1a2)];while(this[_0x5b31d6(0x1bc)]){try{this['sseAbort']=new AbortController();let _0x5c102f={'Accept':'text/event-stream'};if(this['token'])_0x5c102f[_0x5b31d6(0x1d3)]=_0x5b31d6(0x1b8)+this[_0x5b31d6(0x1a6)];let _0x2e01b3=await fetch(_0x5a2d0b,{'headers':_0x5c102f,'signal':this['sseAbort'][_0x5b31d6(0x1eb)]});if(!_0x2e01b3['ok']||!_0x2e01b3[_0x5b31d6(0x1c8)]){this[_0x5b31d6(0x1d6)](_0x5b31d6(0x1ab)+_0x2e01b3[_0x5b31d6(0x1e6)]),await this[_0x5b31d6(0x1a1)](_0x1e17ac),_0x1e17ac=Math[_0x5b31d6(0x1c5)](_0x1e17ac*1.5,0xea60);continue;}_0x1e17ac=this[_0x5b31d6(0x1a2)];let _0x5739e4=_0x2e01b3[_0x5b31d6(0x1c8)][_0x5b31d6(0x1c9)](),_0x33870c=new TextDecoder(),_0x582383='';while(this[_0x5b31d6(0x1bc)]){let {done:_0x39f073,value:_0x1975b1}=await _0x5739e4['read']();if(_0x39f073)break;_0x582383+=_0x33870c[_0x5b31d6(0x1ce)](_0x1975b1,{'stream':!0x0});let _0x11a30d=_0x582383['split']('\x0a');_0x582383=_0x11a30d[_0x5b31d6(0x1b1)]()||'';for(let _0x930f23 of _0x11a30d){if(!_0x930f23[_0x5b31d6(0x1bb)](_0x5b31d6(0x1cb)))continue;try{let _0x3d1616=JSON[_0x5b31d6(0x1e8)](_0x930f23[_0x5b31d6(0x1e9)](0x6));if(_0x3d1616[_0x5b31d6(0x1e5)]===_0x5b31d6(0x1ad)){this[_0x5b31d6(0x1d6)](_0x5b31d6(0x1b7)),this['emit'](_0x5b31d6(0x1ad));continue;}if(_0x3d1616['type']==='new_task'||_0x3d1616['type']===_0x5b31d6(0x1f1)||_0x3d1616['type']===_0x5b31d6(0x1bf))await this['processInbox']();}catch{}}}}catch(_0x342e1d){if(_0x342e1d[_0x5b31d6(0x1c1)]===_0x5b31d6(0x1c7))break;this[_0x5b31d6(0x1bd)](_0x5b31d6(0x19e),_0x342e1d),this['log'](_0x5b31d6(0x1a9)+_0x342e1d[_0x5b31d6(0x1f5)]);}if(this[_0x5b31d6(0x1bc)])this['emit']('disconnected'),this[_0x5b31d6(0x1d6)](_0x5b31d6(0x1a5)+_0x1e17ac/0x3e8+_0x5b31d6(0x1cc)),await this[_0x5b31d6(0x1a1)](_0x1e17ac),_0x1e17ac=Math[_0x5b31d6(0x1c5)](_0x1e17ac*1.5,0xea60);}}async[a0_0x5e1a20(0x1d5)](){const _0x347857=a0_0x5e1a20;try{let _0x3bd574=(await this[_0x347857(0x1f7)]('get_inbox',{'alias':this['alias'],'limit':0xa}))?.[_0x347857(0x1cd)]||[];for(let _0x10b1ee of _0x3bd574)await this['call']('ack_inbox',{'alias':this[_0x347857(0x1a8)],'message_id':_0x10b1ee['id']}),this[_0x347857(0x1d6)]('←\x20'+_0x10b1ee[_0x347857(0x1b3)]+':\x20'+_0x10b1ee[_0x347857(0x1f6)][_0x347857(0x1e9)](0x0,0x3c)),this[_0x347857(0x1bd)](_0x347857(0x1ed),_0x10b1ee),this[_0x347857(0x1bd)](_0x347857(0x1f5),_0x10b1ee);}catch(_0x1bad29){this['log'](_0x347857(0x1ea)+_0x1bad29[_0x347857(0x1f5)]);}}[a0_0x5e1a20(0x1a1)](_0x3ab0d9){return new Promise(_0x5c4779=>setTimeout(_0x5c4779,_0x3ab0d9));}}function a0_0x94f9(){const _0x55088d=['startsWith','running','emit','reply','broadcast','autoConnect','name','toTimeString','normal','2240833NrQqTV','min','catch','AbortError','body','getReader','98038ZYmfsW','data:\x20','s...','messages','decode','replace','application/json','heartbeat\x20failed:\x20','agent','Authorization',']\x20[commhub:','processInbox','log','getAllStatus','abort','idle','1383835aGJPuK','heartbeatInterval','stringify','application/json,\x20text/event-stream','cwd','6PaaoRp','disconnect','get_all_status','17772073LUTmjC','8kDcHrG','connectSSE','type','status','registered','parse','slice','inbox\x20error:\x20','signal','server','task','POST','disconnected','send_task','new_message','2414344ZPZklY','now','result','message','content','call','connect','match','/events/','error','offline','heartbeatTimer','sleep','reconnectDelay','url','sseAbort','SSE\x20reconnecting\x20in\x20','token','sdk-','alias','SSE\x20error:\x20','tools/call','SSE\x20failed:\x20','2.0','connected','send','1996068snBpiY','520jPzGAa','pop','text','from_session','182610ezgDQp','toString','resumeId','SSE\x20connected','Bearer\x20','send_message','14EbAcRc'];a0_0x94f9=function(){return _0x55088d;};return a0_0x94f9();}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>;