@sleep2agi/agent-network 2.1.8-preview.3 → 2.1.8-preview.5

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_0x3b6f26=a0_0x3a93;function a0_0x3a93(_0x2dcac7,_0x3fba99){_0x2dcac7=_0x2dcac7-0x1b5;const _0x30c0e9=a0_0x30c0();let _0x3a937f=_0x30c0e9[_0x2dcac7];return _0x3a937f;}(function(_0x517c94,_0x16397e){const _0x13da31=a0_0x3a93,_0x4cf4a4=_0x517c94();while(!![]){try{const _0x6699f5=parseInt(_0x13da31(0x1f5))/0x1+-parseInt(_0x13da31(0x1c3))/0x2*(-parseInt(_0x13da31(0x1d7))/0x3)+-parseInt(_0x13da31(0x1c9))/0x4+parseInt(_0x13da31(0x1c1))/0x5+-parseInt(_0x13da31(0x1b7))/0x6+parseInt(_0x13da31(0x1f6))/0x7*(-parseInt(_0x13da31(0x1db))/0x8)+-parseInt(_0x13da31(0x1cb))/0x9*(parseInt(_0x13da31(0x1ec))/0xa);if(_0x6699f5===_0x16397e)break;else _0x4cf4a4['push'](_0x4cf4a4['shift']());}catch(_0x4907b8){_0x4cf4a4['push'](_0x4cf4a4['shift']());}}}(a0_0x30c0,0xb2d13));import{EventEmitter as a0_0x1dcb96}from'events';import{hostname as a0_0x55e3fa}from'os';class T extends a0_0x1dcb96{[a0_0x3b6f26(0x1ea)];[a0_0x3b6f26(0x1fb)];[a0_0x3b6f26(0x1e4)];[a0_0x3b6f26(0x1d4)];[a0_0x3b6f26(0x1b8)];['heartbeatInterval'];[a0_0x3b6f26(0x1bd)];[a0_0x3b6f26(0x1ee)];[a0_0x3b6f26(0x1f1)];[a0_0x3b6f26(0x1f7)]=!0x1;constructor(_0x1441c){const _0x3bbeb4=a0_0x3b6f26;super();if(this[_0x3bbeb4(0x1ea)]=_0x1441c[_0x3bbeb4(0x1ea)][_0x3bbeb4(0x1f4)](/\/$/,''),this[_0x3bbeb4(0x1fb)]=_0x1441c[_0x3bbeb4(0x1fb)],this[_0x3bbeb4(0x1e4)]=_0x1441c['token'],this['agent']=_0x1441c[_0x3bbeb4(0x1d4)]||_0x3bbeb4(0x1b5),this[_0x3bbeb4(0x1b8)]=_0x3bbeb4(0x1f8)+_0x1441c['alias']+'-'+Date[_0x3bbeb4(0x1c2)]()['toString'](0x24),this[_0x3bbeb4(0x1d9)]=_0x1441c[_0x3bbeb4(0x1d9)]??0x2bf20,this[_0x3bbeb4(0x1bd)]=_0x1441c[_0x3bbeb4(0x1bd)]??0xbb8,_0x1441c[_0x3bbeb4(0x206)]!==!0x1)this['connect']();}[a0_0x3b6f26(0x1eb)](_0x508e6c){const _0x3d09c4=a0_0x3b6f26;console['log']('['+new Date()[_0x3d09c4(0x204)]()[_0x3d09c4(0x1bb)](0x0,0x8)+']\x20[commhub:'+this[_0x3d09c4(0x1fb)]+']\x20'+_0x508e6c);}async[a0_0x3b6f26(0x1d8)](_0x185223,_0x4e3c30){const _0x100e50=a0_0x3b6f26;let _0x27ece9={'Content-Type':_0x100e50(0x1bc),'Accept':'application/json,\x20text/event-stream'};if(this[_0x100e50(0x1e4)])_0x27ece9[_0x100e50(0x203)]='Bearer\x20'+this['token'];let _0x16ccfe=await(await fetch(this[_0x100e50(0x1ea)]+_0x100e50(0x1c4),{'method':'POST','headers':_0x27ece9,'body':JSON['stringify']({'jsonrpc':_0x100e50(0x1e1),'id':Date[_0x100e50(0x1c2)](),'method':_0x100e50(0x1e7),'params':{'name':_0x185223,'arguments':_0x4e3c30}})}))[_0x100e50(0x1c5)](),_0x3be3a6=_0x16ccfe['match'](/data: (.+)/),_0x3286fd=_0x3be3a6?JSON[_0x100e50(0x1fa)](_0x3be3a6[0x1]):JSON[_0x100e50(0x1fa)](_0x16ccfe),_0x576f5c=_0x3286fd?.['result']?.['content']?.[0x0]?.[_0x100e50(0x1c5)];return _0x576f5c?JSON[_0x100e50(0x1fa)](_0x576f5c):_0x3286fd;}async['connect'](){const _0x16fe72=a0_0x3b6f26;if(this['running'])return;this['running']=!0x0,await this['status'](_0x16fe72(0x1f2)),this[_0x16fe72(0x1eb)](_0x16fe72(0x1df)),this[_0x16fe72(0x1ee)]=setInterval(()=>{const _0x4dac19=_0x16fe72;this[_0x4dac19(0x1c0)](_0x4dac19(0x1f2))['catch'](_0x29ac8f=>this[_0x4dac19(0x1eb)]('heartbeat\x20failed:\x20'+_0x29ac8f[_0x4dac19(0x1cf)]));},this[_0x16fe72(0x1d9)]),this[_0x16fe72(0x1ef)]();}async[a0_0x3b6f26(0x1be)](){const _0x38863f=a0_0x3b6f26;if(this[_0x38863f(0x1f7)]=!0x1,this[_0x38863f(0x1f1)]?.['abort'](),this[_0x38863f(0x1ee)])clearInterval(this['heartbeatTimer']);await this[_0x38863f(0x1c0)]('offline')['catch'](()=>{}),this['log'](_0x38863f(0x1dc));}async[a0_0x3b6f26(0x1cd)](_0x5c6986,_0x5f51f3,_0x4e9498=a0_0x3b6f26(0x200)){const _0xc2a560=a0_0x3b6f26;return this['call'](_0xc2a560(0x1d1),{'alias':_0x5c6986,'task':_0x5f51f3,'priority':_0x4e9498,'from_session':this[_0xc2a560(0x1fb)]});}async['message'](_0x3a0afa,_0x2a9e8c){const _0x163586=a0_0x3b6f26;return this[_0x163586(0x1d8)](_0x163586(0x1b9),{'alias':_0x3a0afa,'message':_0x2a9e8c,'from_session':this[_0x163586(0x1fb)]});}async[a0_0x3b6f26(0x1f0)](_0x550374,_0x2c1871,_0x2bc7da=a0_0x3b6f26(0x1ce)){const _0x3a766a=a0_0x3b6f26;return this[_0x3a766a(0x1d8)](_0x3a766a(0x1fc),{'in_reply_to':_0x550374,'text':_0x2c1871,'status':_0x2bc7da});}async[a0_0x3b6f26(0x1c0)](_0x77f865,_0x49ce9e){const _0x512ef9=a0_0x3b6f26;return this[_0x512ef9(0x1d8)](_0x512ef9(0x1e0),{'resume_id':this[_0x512ef9(0x1b8)],'alias':this[_0x512ef9(0x1fb)],'status':_0x77f865,'server':a0_0x55e3fa(),'hostname':a0_0x55e3fa(),'agent':this[_0x512ef9(0x1d4)],'project_dir':process[_0x512ef9(0x205)](),..._0x49ce9e});}async['getAllStatus'](){const _0x3877d5=a0_0x3b6f26;return this[_0x3877d5(0x1d8)](_0x3877d5(0x202),{});}async[a0_0x3b6f26(0x207)](_0x3dc6ce,_0x23d12f){const _0x254001=a0_0x3b6f26;return this[_0x254001(0x1d8)](_0x254001(0x207),{'message':_0x3dc6ce,'filter_server':_0x23d12f?.[_0x254001(0x1ba)],'filter_status':_0x23d12f?.[_0x254001(0x1c0)]});}async['connectSSE'](){const _0x46a121=a0_0x3b6f26;let _0x2316b8=encodeURIComponent(this['alias']),_0x58c09a=this['url']+'/events/'+_0x2316b8,_0x37fbac=this[_0x46a121(0x1bd)];while(this[_0x46a121(0x1f7)]){try{this['sseAbort']=new AbortController();let _0x4717a2={'Accept':_0x46a121(0x1fe)};if(this[_0x46a121(0x1e4)])_0x4717a2['Authorization']=_0x46a121(0x1d0)+this['token'];let _0x4b6e60=await fetch(_0x58c09a,{'headers':_0x4717a2,'signal':this[_0x46a121(0x1f1)]['signal']});if(!_0x4b6e60['ok']||!_0x4b6e60[_0x46a121(0x1f3)]){this[_0x46a121(0x1eb)](_0x46a121(0x1e9)+_0x4b6e60[_0x46a121(0x1c0)]),await this[_0x46a121(0x1ff)](_0x37fbac),_0x37fbac=Math[_0x46a121(0x1d3)](_0x37fbac*1.5,0xea60);continue;}_0x37fbac=this[_0x46a121(0x1bd)];let _0x3226c2=_0x4b6e60['body'][_0x46a121(0x1cc)](),_0x2c95fa=new TextDecoder(),_0x356983='';while(this[_0x46a121(0x1f7)]){let {done:_0x243676,value:_0x26103a}=await _0x3226c2[_0x46a121(0x1d2)]();if(_0x243676)break;_0x356983+=_0x2c95fa['decode'](_0x26103a,{'stream':!0x0});let _0x23cb8c=_0x356983[_0x46a121(0x201)]('\x0a');_0x356983=_0x23cb8c[_0x46a121(0x1e5)]()||'';for(let _0x2ba848 of _0x23cb8c){if(!_0x2ba848[_0x46a121(0x1ca)]('data:\x20'))continue;try{let _0x3bdabe=JSON[_0x46a121(0x1fa)](_0x2ba848[_0x46a121(0x1bb)](0x6));if(_0x3bdabe[_0x46a121(0x1dd)]==='connected'){this['log'](_0x46a121(0x1d6)),this[_0x46a121(0x1c6)](_0x46a121(0x1ed));continue;}if(_0x3bdabe['type']===_0x46a121(0x1fd)||_0x3bdabe[_0x46a121(0x1dd)]===_0x46a121(0x1e2)||_0x3bdabe[_0x46a121(0x1dd)]===_0x46a121(0x207))await this[_0x46a121(0x1bf)]();}catch{}}}}catch(_0x5ea3a9){if(_0x5ea3a9[_0x46a121(0x1d5)]===_0x46a121(0x1f9))break;this[_0x46a121(0x1c6)](_0x46a121(0x208),_0x5ea3a9),this['log'](_0x46a121(0x1c7)+_0x5ea3a9['message']);}if(this[_0x46a121(0x1f7)])this['emit'](_0x46a121(0x1dc)),this[_0x46a121(0x1eb)](_0x46a121(0x1e6)+_0x37fbac/0x3e8+_0x46a121(0x1c8)),await this[_0x46a121(0x1ff)](_0x37fbac),_0x37fbac=Math[_0x46a121(0x1d3)](_0x37fbac*1.5,0xea60);}}async['processInbox'](){const _0x4cc0a7=a0_0x3b6f26;try{let _0x2d20de=(await this['call'](_0x4cc0a7(0x1e3),{'alias':this[_0x4cc0a7(0x1fb)],'limit':0xa}))?.[_0x4cc0a7(0x1da)]||[];for(let _0x5eb4b1 of _0x2d20de)await this[_0x4cc0a7(0x1d8)](_0x4cc0a7(0x1b6),{'alias':this['alias'],'message_id':_0x5eb4b1['id']}),this[_0x4cc0a7(0x1eb)]('←\x20'+_0x5eb4b1[_0x4cc0a7(0x1de)]+':\x20'+_0x5eb4b1[_0x4cc0a7(0x209)]['slice'](0x0,0x3c)),this[_0x4cc0a7(0x1c6)]('task',_0x5eb4b1),this[_0x4cc0a7(0x1c6)](_0x4cc0a7(0x1cf),_0x5eb4b1);}catch(_0x2473ed){this[_0x4cc0a7(0x1eb)](_0x4cc0a7(0x1e8)+_0x2473ed[_0x4cc0a7(0x1cf)]);}}[a0_0x3b6f26(0x1ff)](_0x258013){return new Promise(_0x55a1e6=>setTimeout(_0x55a1e6,_0x258013));}}function a0_0x30c0(){const _0xf05a93=['disconnect','processInbox','status','5960065TGiXtu','now','700106PTBWxE','/mcp','text','emit','SSE\x20error:\x20','s...','4132068mewtfb','startsWith','1998kpxdBv','getReader','send','completed','message','Bearer\x20','send_task','read','min','agent','name','SSE\x20connected','3GhWBTr','call','heartbeatInterval','messages','16728jWYGnm','disconnected','type','from_session','registered','report_status','2.0','new_message','get_inbox','token','pop','SSE\x20reconnecting\x20in\x20','tools/call','inbox\x20error:\x20','SSE\x20failed:\x20','url','log','13270XxUCPC','connected','heartbeatTimer','connectSSE','reply','sseAbort','idle','body','replace','774309AVaced','35mpvAVP','running','sdk-','AbortError','parse','alias','send_reply','new_task','text/event-stream','sleep','normal','split','get_all_status','Authorization','toTimeString','cwd','autoConnect','broadcast','error','content','sdk','ack_inbox','1475244iWmmJV','resumeId','send_message','server','slice','application/json','reconnectDelay'];a0_0x30c0=function(){return _0xf05a93;};return a0_0x30c0();}var $=T;export{$ as default,T as CommHub};
1
+ const a0_0x5dc79c=a0_0x4301;(function(_0x10c6fa,_0x59e1a6){const _0x1957e8=a0_0x4301,_0x4b76cf=_0x10c6fa();while(!![]){try{const _0x19d3c0=-parseInt(_0x1957e8(0x163))/0x1*(-parseInt(_0x1957e8(0x147))/0x2)+parseInt(_0x1957e8(0x155))/0x3+parseInt(_0x1957e8(0x165))/0x4*(parseInt(_0x1957e8(0x120))/0x5)+parseInt(_0x1957e8(0x159))/0x6*(parseInt(_0x1957e8(0x14f))/0x7)+-parseInt(_0x1957e8(0x142))/0x8+parseInt(_0x1957e8(0x162))/0x9+-parseInt(_0x1957e8(0x13b))/0xa;if(_0x19d3c0===_0x59e1a6)break;else _0x4b76cf['push'](_0x4b76cf['shift']());}catch(_0x12d939){_0x4b76cf['push'](_0x4b76cf['shift']());}}}(a0_0x5d22,0xebc8d));import{EventEmitter as a0_0x3e8536}from'events';function a0_0x5d22(){const _0x7039fc=['result','tools/call','body','status','min','5tMzjCJ','broadcast','inbox\x20error:\x20','slice','from_session','SSE\x20reconnecting\x20in\x20','match','get_all_status','heartbeatTimer','sdk-','Bearer\x20','now','replace','sseAbort','getReader','send_message','s...','data:\x20','report_status','reconnectDelay','token','resumeId','AbortError','toTimeString','alias','emit','processInbox','36685480ZVYlgD','messages','heartbeat\x20failed:\x20','toString','read','agent','type','4719464rizHUZ','message','autoConnect','sdk','2.0','296156qLjeZz','idle','split','log','startsWith','error','heartbeatInterval','application/json','182UjrURN','send','get_inbox','url','running','stringify','466365oVXIFS','send_reply','name','offline','378006kXRbrk','call','abort','connectSSE','ack_inbox','new_task','sleep','registered','text','16544943niKiOC','8dBeyjA','catch','1631288PoHUCJ','connect','normal','server','/events/','new_message','parse','completed','disconnect','content','reply','connected','disconnected'];a0_0x5d22=function(){return _0x7039fc;};return a0_0x5d22();}import{hostname as a0_0x140ec7}from'os';function a0_0x4301(_0x8bcef,_0x40f219){_0x8bcef=_0x8bcef-0x11d;const _0x5d223d=a0_0x5d22();let _0x4301a0=_0x5d223d[_0x8bcef];return _0x4301a0;}class T extends a0_0x3e8536{[a0_0x5dc79c(0x152)];[a0_0x5dc79c(0x138)];['token'];[a0_0x5dc79c(0x140)];[a0_0x5dc79c(0x135)];[a0_0x5dc79c(0x14d)];[a0_0x5dc79c(0x133)];[a0_0x5dc79c(0x128)];[a0_0x5dc79c(0x12d)];['running']=!0x1;constructor(_0x4f5066){const _0x248b26=a0_0x5dc79c;super();if(this[_0x248b26(0x152)]=_0x4f5066['url'][_0x248b26(0x12c)](/\/$/,''),this[_0x248b26(0x138)]=_0x4f5066[_0x248b26(0x138)],this['token']=_0x4f5066[_0x248b26(0x134)],this['agent']=_0x4f5066[_0x248b26(0x140)]||_0x248b26(0x145),this[_0x248b26(0x135)]=_0x248b26(0x129)+_0x4f5066[_0x248b26(0x138)]+'-'+Date[_0x248b26(0x12b)]()[_0x248b26(0x13e)](0x24),this[_0x248b26(0x14d)]=_0x4f5066[_0x248b26(0x14d)]??0x2bf20,this[_0x248b26(0x133)]=_0x4f5066[_0x248b26(0x133)]??0xbb8,_0x4f5066[_0x248b26(0x144)]!==!0x1)this[_0x248b26(0x166)]();}[a0_0x5dc79c(0x14a)](_0x31778a){const _0x5646dc=a0_0x5dc79c;console[_0x5646dc(0x14a)]('['+new Date()[_0x5646dc(0x137)]()[_0x5646dc(0x123)](0x0,0x8)+']\x20[commhub:'+this[_0x5646dc(0x138)]+']\x20'+_0x31778a);}async[a0_0x5dc79c(0x15a)](_0x1fd20f,_0x4a59d5){const _0x5a5ab4=a0_0x5dc79c;let _0x54abb8={'Content-Type':_0x5a5ab4(0x14e),'Accept':'application/json,\x20text/event-stream'};if(this[_0x5a5ab4(0x134)])_0x54abb8['Authorization']=_0x5a5ab4(0x12a)+this[_0x5a5ab4(0x134)];let _0x2c4ead=await(await fetch(this[_0x5a5ab4(0x152)]+'/mcp',{'method':'POST','headers':_0x54abb8,'body':JSON[_0x5a5ab4(0x154)]({'jsonrpc':_0x5a5ab4(0x146),'id':Date[_0x5a5ab4(0x12b)](),'method':_0x5a5ab4(0x173),'params':{'name':_0x1fd20f,'arguments':_0x4a59d5}})}))[_0x5a5ab4(0x161)](),_0x49b561=_0x2c4ead[_0x5a5ab4(0x126)](/data: (.+)/),_0x2f1d64=_0x49b561?JSON[_0x5a5ab4(0x16b)](_0x49b561[0x1]):JSON[_0x5a5ab4(0x16b)](_0x2c4ead),_0x5b465c=_0x2f1d64?.[_0x5a5ab4(0x172)]?.[_0x5a5ab4(0x16e)]?.[0x0]?.[_0x5a5ab4(0x161)];return _0x5b465c?JSON[_0x5a5ab4(0x16b)](_0x5b465c):_0x2f1d64;}async[a0_0x5dc79c(0x166)](){const _0x9efd87=a0_0x5dc79c;if(this[_0x9efd87(0x153)])return;this[_0x9efd87(0x153)]=!0x0,await this[_0x9efd87(0x11e)](_0x9efd87(0x148)),this['log'](_0x9efd87(0x160)),this[_0x9efd87(0x128)]=setInterval(()=>{const _0x55c887=_0x9efd87;this['status'](_0x55c887(0x148))[_0x55c887(0x164)](_0x3fbc5e=>this['log'](_0x55c887(0x13d)+_0x3fbc5e[_0x55c887(0x143)]));},this['heartbeatInterval']),this[_0x9efd87(0x15c)]();}async[a0_0x5dc79c(0x16d)](){const _0x2bc3fa=a0_0x5dc79c;if(this[_0x2bc3fa(0x153)]=!0x1,this[_0x2bc3fa(0x12d)]?.[_0x2bc3fa(0x15b)](),this[_0x2bc3fa(0x128)])clearInterval(this[_0x2bc3fa(0x128)]);await this[_0x2bc3fa(0x11e)](_0x2bc3fa(0x158))['catch'](()=>{}),this[_0x2bc3fa(0x14a)](_0x2bc3fa(0x171));}async[a0_0x5dc79c(0x150)](_0x4180ea,_0xc140e0,_0x5dcb5b=a0_0x5dc79c(0x167)){const _0x4bfeef=a0_0x5dc79c;return this[_0x4bfeef(0x15a)]('send_task',{'alias':_0x4180ea,'task':_0xc140e0,'priority':_0x5dcb5b,'from_session':this['alias']});}async[a0_0x5dc79c(0x143)](_0x1434e0,_0x3bee5f){const _0x20c1af=a0_0x5dc79c;return this[_0x20c1af(0x15a)](_0x20c1af(0x12f),{'alias':_0x1434e0,'message':_0x3bee5f,'from_session':this[_0x20c1af(0x138)]});}async[a0_0x5dc79c(0x16f)](_0x1d3c0a,_0x1ca814,_0x424199=a0_0x5dc79c(0x16c)){const _0x2771cb=a0_0x5dc79c;return this[_0x2771cb(0x15a)](_0x2771cb(0x156),{'in_reply_to':_0x1d3c0a,'text':_0x1ca814,'status':_0x424199});}async[a0_0x5dc79c(0x11e)](_0x170bc8,_0x43cfe0){const _0x599c4f=a0_0x5dc79c;return this[_0x599c4f(0x15a)](_0x599c4f(0x132),{'resume_id':this[_0x599c4f(0x135)],'alias':this['alias'],'status':_0x170bc8,'server':a0_0x140ec7(),'hostname':a0_0x140ec7(),'agent':this['agent'],'project_dir':process['cwd'](),..._0x43cfe0});}async['getAllStatus'](){const _0x5f30a9=a0_0x5dc79c;return this[_0x5f30a9(0x15a)](_0x5f30a9(0x127),{});}async[a0_0x5dc79c(0x121)](_0x394364,_0x28a1d3){const _0x201c3c=a0_0x5dc79c;return this['call'](_0x201c3c(0x121),{'message':_0x394364,'filter_server':_0x28a1d3?.[_0x201c3c(0x168)],'filter_status':_0x28a1d3?.[_0x201c3c(0x11e)]});}async[a0_0x5dc79c(0x15c)](){const _0x3f0954=a0_0x5dc79c;let _0x400fe9=encodeURIComponent(this[_0x3f0954(0x138)]),_0x5eb832=this[_0x3f0954(0x152)]+_0x3f0954(0x169)+_0x400fe9,_0x3135f1=this[_0x3f0954(0x133)];while(this[_0x3f0954(0x153)]){try{this['sseAbort']=new AbortController();let _0x5bdad2={'Accept':'text/event-stream'};if(this[_0x3f0954(0x134)])_0x5bdad2['Authorization']=_0x3f0954(0x12a)+this[_0x3f0954(0x134)];let _0x57d941=await fetch(_0x5eb832,{'headers':_0x5bdad2,'signal':this['sseAbort']['signal']});if(!_0x57d941['ok']||!_0x57d941[_0x3f0954(0x11d)]){this[_0x3f0954(0x14a)]('SSE\x20failed:\x20'+_0x57d941[_0x3f0954(0x11e)]),await this[_0x3f0954(0x15f)](_0x3135f1),_0x3135f1=Math[_0x3f0954(0x11f)](_0x3135f1*1.5,0xea60);continue;}_0x3135f1=this[_0x3f0954(0x133)];let _0x758e50=_0x57d941[_0x3f0954(0x11d)][_0x3f0954(0x12e)](),_0x452889=new TextDecoder(),_0x52b9ef='';while(this[_0x3f0954(0x153)]){let {done:_0x425792,value:_0x5aaf12}=await _0x758e50[_0x3f0954(0x13f)]();if(_0x425792)break;_0x52b9ef+=_0x452889['decode'](_0x5aaf12,{'stream':!0x0});let _0x54744a=_0x52b9ef[_0x3f0954(0x149)]('\x0a');_0x52b9ef=_0x54744a['pop']()||'';for(let _0x3f4b57 of _0x54744a){if(!_0x3f4b57[_0x3f0954(0x14b)](_0x3f0954(0x131)))continue;try{let _0x54bf9d=JSON[_0x3f0954(0x16b)](_0x3f4b57[_0x3f0954(0x123)](0x6));if(_0x54bf9d[_0x3f0954(0x141)]==='connected'){this[_0x3f0954(0x14a)]('SSE\x20connected'),this[_0x3f0954(0x139)](_0x3f0954(0x170));continue;}if(_0x54bf9d[_0x3f0954(0x141)]===_0x3f0954(0x15e)||_0x54bf9d[_0x3f0954(0x141)]===_0x3f0954(0x16a)||_0x54bf9d[_0x3f0954(0x141)]===_0x3f0954(0x121))await this['processInbox']();}catch{}}}}catch(_0x201d4c){if(_0x201d4c[_0x3f0954(0x157)]===_0x3f0954(0x136))break;this['emit'](_0x3f0954(0x14c),_0x201d4c),this['log']('SSE\x20error:\x20'+_0x201d4c[_0x3f0954(0x143)]);}if(this[_0x3f0954(0x153)])this[_0x3f0954(0x139)](_0x3f0954(0x171)),this['log'](_0x3f0954(0x125)+_0x3135f1/0x3e8+_0x3f0954(0x130)),await this['sleep'](_0x3135f1),_0x3135f1=Math[_0x3f0954(0x11f)](_0x3135f1*1.5,0xea60);}}async[a0_0x5dc79c(0x13a)](){const _0x5827ff=a0_0x5dc79c;try{let _0x5d9967=(await this[_0x5827ff(0x15a)](_0x5827ff(0x151),{'alias':this[_0x5827ff(0x138)],'limit':0xa}))?.[_0x5827ff(0x13c)]||[];for(let _0x4bbcc9 of _0x5d9967)await this[_0x5827ff(0x15a)](_0x5827ff(0x15d),{'alias':this[_0x5827ff(0x138)],'message_id':_0x4bbcc9['id']}),this[_0x5827ff(0x14a)]('←\x20'+_0x4bbcc9[_0x5827ff(0x124)]+':\x20'+_0x4bbcc9[_0x5827ff(0x16e)][_0x5827ff(0x123)](0x0,0x3c)),this[_0x5827ff(0x139)]('task',_0x4bbcc9),this[_0x5827ff(0x139)](_0x5827ff(0x143),_0x4bbcc9);}catch(_0x36a609){this[_0x5827ff(0x14a)](_0x5827ff(0x122)+_0x36a609['message']);}}[a0_0x5dc79c(0x15f)](_0x741319){return new Promise(_0x1968d5=>setTimeout(_0x1968d5,_0x741319));}}var $=T;export{$ as default,T as CommHub};
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env bun
2
- function a0_0x34ef(_0x4d63bb,_0x5bdf74){_0x4d63bb=_0x4d63bb-0x122;const _0x5a8786=a0_0x5a87();let _0x34ef91=_0x5a8786[_0x4d63bb];return _0x34ef91;}const a0_0x18095e=a0_0x34ef;(function(_0x39a16a,_0x33db7c){const _0x5c62b3=a0_0x34ef,_0x4f0e56=_0x39a16a();while(!![]){try{const _0x1ee7d6=parseInt(_0x5c62b3(0x190))/0x1*(-parseInt(_0x5c62b3(0x194))/0x2)+parseInt(_0x5c62b3(0x186))/0x3*(-parseInt(_0x5c62b3(0x170))/0x4)+-parseInt(_0x5c62b3(0x162))/0x5*(-parseInt(_0x5c62b3(0x149))/0x6)+parseInt(_0x5c62b3(0x156))/0x7*(-parseInt(_0x5c62b3(0x12f))/0x8)+parseInt(_0x5c62b3(0x167))/0x9*(-parseInt(_0x5c62b3(0x16c))/0xa)+-parseInt(_0x5c62b3(0x16f))/0xb*(parseInt(_0x5c62b3(0x15f))/0xc)+-parseInt(_0x5c62b3(0x14b))/0xd*(-parseInt(_0x5c62b3(0x1a3))/0xe);if(_0x1ee7d6===_0x33db7c)break;else _0x4f0e56['push'](_0x4f0e56['shift']());}catch(_0x526be3){_0x4f0e56['push'](_0x4f0e56['shift']());}}}(a0_0x5a87,0x8b47e));import{readFileSync as a0_0x30f904,existsSync as a0_0x425f88}from'fs';import{randomUUID as a0_0x1ae0c4}from'crypto';import{join as a0_0x45990c}from'path';import{hostname as a0_0x1988a7}from'os';import{execSync as a0_0xa9bbed}from'child_process';import{Server as a0_0x253bc5}from'@modelcontextprotocol/sdk/server/index.js';function a0_0x5a87(){const _0x1b00f6=['error','commhub_get_all_status','get_inbox','catch','POST','string','find','working','message_id','1nOyfBU','trim','params','body','700996hwsCbn','commhub-channel','ack_inbox','connect','registered\x20as\x20\x22','slice','utf-8','shutting\x20down,\x20reporting\x20offline...','replied','new_message','0.3.0','send_reply','failed','\x20RESUME_ID=','.env','107114iKlrNq','message','report_status','object','2.0','notifications/claude/channel','getReader','Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.','connected','stdin',']\x20[commhub]\x20','You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.','commhub','inbox_count','Bearer\x20','content','Message\x20content','config.json','get_all_status','stringify','high','2576gVEROD','send_message','decode','idle','→\x20injected\x20task\x20','The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)','cancelled','←\x20message\x20from\x20','.anet','session\x20disconnected','\x20PROJECT_ENV=','ENV:\x20URL=','fatal:\x20','SIGINT','text','application/json','\x20from\x20','Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.','pop','broadcast','completed','cwd','blocked','Task\x20outcome:\x20completed/failed/cancelled\x20for\x20final\x20results,\x20blocked/error/in_progress\x20for\x20status\x20updates','initialize','stderr','36RLgutm','normal','4537rtjicx','send_task','get','then','Target\x20session\x20alias','replace','delete','messages','low','priority','SSE\x20connected\x20as\x20\x22','5698EEBTvM','Task\x20content','commhub_send_task','starting\x20SSE\x20listener...','number','Update\x20this\x20session\x27s\x20status\x20in\x20CommHub\x20(working/idle/blocked/error).\x20Returns\x20inbox_count.','setRequestHandler','result','These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.','290172LqtJNa','hub','application/json,\x20text/event-stream','678985bgPEbF','write','\x20CWD=','SSE\x20fatal:\x20','Progress\x200-100','27shezOe','from_session','Authorization','status','notification','1486110YsBHwk','init\x20failed:\x20','startsWith','440nCnzBL','888808mZwGJT','claude-code','Reply\x20using\x20the\x20commhub_reply\x20tool\x20to\x20report\x20status\x20or\x20results\x20back.','data:\x20','CommHub\x20init\x20failed:\x20','from','commhub_report_status','parse\x20error:\x20','2025-03-26','MCP\x20stdio\x20connected','commhub_reply','split','SSE\x20stream\x20ended,\x20reconnecting...','statusText','/events/','commhub_send_message','tools/call','join','parse','alias','exit','type','12pcrjSs'];a0_0x5a87=function(){return _0x1b00f6;};return a0_0x5a87();}import{StdioServerTransport as a0_0x32bd07}from'@modelcontextprotocol/sdk/server/stdio.js';import{ListToolsRequestSchema as a0_0x15f85b,CallToolRequestSchema as a0_0x17aa76}from'@modelcontextprotocol/sdk/types.js';function p(_0x4e062d){const _0x2cb0cf=a0_0x34ef;if(!a0_0x425f88(_0x4e062d))return;for(let _0x45060c of a0_0x30f904(_0x4e062d,_0x2cb0cf(0x19a))[_0x2cb0cf(0x17b)]('\x0a')){let _0x29c587=_0x45060c[_0x2cb0cf(0x191)]();if(!_0x29c587||_0x29c587[_0x2cb0cf(0x16e)]('#'))continue;let _0x4d1a4e=_0x29c587['indexOf']('=');if(_0x4d1a4e<0x0)continue;let _0x28694b=_0x29c587[_0x2cb0cf(0x199)](0x0,_0x4d1a4e)[_0x2cb0cf(0x191)](),_0x59760c=_0x29c587['slice'](_0x4d1a4e+0x1)['trim']()[_0x2cb0cf(0x150)](/^["']|["']$/g,'');if(!process.env[_0x28694b])process.env[_0x28694b]=_0x59760c;}}var C=process.env.HOME||'~',T=a0_0x45990c(C,'.claude/channels/commhub');p(a0_0x45990c(T,a0_0x18095e(0x1a2)));var L=process[a0_0x18095e(0x144)]()['replace'](/\//g,'-');p(a0_0x45990c(T,L,a0_0x18095e(0x1a2)));function U(){const _0x55bf6a=a0_0x18095e;try{return a0_0xa9bbed('tmux\x20display-message\x20-p\x20\x27#S\x27',{'encoding':_0x55bf6a(0x19a),'timeout':0x7d0})[_0x55bf6a(0x191)]();}catch{return'';}}function v(){const _0x319d08=a0_0x18095e;try{let _0x47f73b=a0_0x45990c(C,_0x319d08(0x137),_0x319d08(0x12b));if(a0_0x425f88(_0x47f73b))return JSON[_0x319d08(0x182)](a0_0x30f904(_0x47f73b,_0x319d08(0x19a)));}catch{}return{};}var H=v(),f=process.env.COMMHUB_URL||H[a0_0x18095e(0x160)]||'http://127.0.0.1:9200',j=process.env.COMMHUB_TMUX||U(),Z=process.env.COMMHUB_ALIAS||j||a0_0x1988a7(),w=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||a0_0x1ae0c4(),X=process.env.COMMHUB_TOKEN||H['token']||'';function Y(_0x4e9aca){const _0x2120dd=a0_0x18095e;let _0x45919c=new Date()['toTimeString']()[_0x2120dd(0x199)](0x0,0x8);process[_0x2120dd(0x148)][_0x2120dd(0x163)]('['+_0x45919c+_0x2120dd(0x124)+_0x4e9aca+'\x0a');}function h(_0x15b7e7){return new Promise(_0x56679b=>setTimeout(_0x56679b,_0x15b7e7));}Y(a0_0x18095e(0x13a)+f+'\x20ALIAS='+Z+a0_0x18095e(0x1a1)+w[a0_0x18095e(0x199)](0x0,0x8)+'...\x20TMUX='+(j||'none')+a0_0x18095e(0x164)+process[a0_0x18095e(0x144)]()+a0_0x18095e(0x139)+L);var k=new Map(),K=new a0_0x253bc5({'name':'commhub-channel','version':a0_0x18095e(0x19e)},{'capabilities':{'experimental':{'claude/channel':{}},'tools':{}},'instructions':['Messages\x20from\x20CommHub\x20arrive\x20as\x20<channel\x20source=\x22commhub\x22\x20task_id=\x22...\x22\x20priority=\x22...\x22\x20from=\x22...\x22>',a0_0x18095e(0x15e),a0_0x18095e(0x172),a0_0x18095e(0x125),'Session\x20alias:\x20'+Z][a0_0x18095e(0x181)]('\x0a')});K['setRequestHandler'](a0_0x15f85b,async()=>({'tools':[{'name':a0_0x18095e(0x17a),'description':'Reply\x20to\x20a\x20CommHub\x20task\x20—\x20report\x20completion\x20or\x20send\x20a\x20message\x20back\x20to\x20the\x20hub.','inputSchema':{'type':a0_0x18095e(0x1a6),'properties':{'task_id':{'type':a0_0x18095e(0x18c),'description':a0_0x18095e(0x134)},'text':{'type':'string','description':'Reply\x20text\x20/\x20result\x20summary'},'status':{'type':'string','enum':[a0_0x18095e(0x143),a0_0x18095e(0x1a0),'cancelled','blocked',a0_0x18095e(0x187),'in_progress'],'description':a0_0x18095e(0x146)}},'required':[a0_0x18095e(0x13d)]}},{'name':a0_0x18095e(0x176),'description':a0_0x18095e(0x15b),'inputSchema':{'type':a0_0x18095e(0x1a6),'properties':{'status':{'type':a0_0x18095e(0x18c),'enum':[a0_0x18095e(0x18e),'idle',a0_0x18095e(0x145),'error']},'task':{'type':a0_0x18095e(0x18c),'description':'Current\x20task\x20description'},'progress':{'type':a0_0x18095e(0x15a),'description':a0_0x18095e(0x166)}},'required':[a0_0x18095e(0x16a)]}},{'name':a0_0x18095e(0x158),'description':a0_0x18095e(0x1aa),'inputSchema':{'type':a0_0x18095e(0x1a6),'properties':{'alias':{'type':'string','description':a0_0x18095e(0x14f)},'task':{'type':a0_0x18095e(0x18c),'description':a0_0x18095e(0x157)},'priority':{'type':'string','enum':[a0_0x18095e(0x12e),a0_0x18095e(0x14a),a0_0x18095e(0x153)],'description':'Priority\x20(default:\x20normal)'}},'required':[a0_0x18095e(0x183),'task']}},{'name':a0_0x18095e(0x17f),'description':a0_0x18095e(0x140),'inputSchema':{'type':a0_0x18095e(0x1a6),'properties':{'alias':{'type':'string','description':a0_0x18095e(0x14f)},'message':{'type':a0_0x18095e(0x18c),'description':a0_0x18095e(0x12a)}},'required':['alias',a0_0x18095e(0x1a4)]}},{'name':a0_0x18095e(0x188),'description':'Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','inputSchema':{'type':a0_0x18095e(0x1a6),'properties':{}}}]}));async function P(_0xc2d59e,_0x3c791c){const _0x1633cc=a0_0x18095e;let _0x3757c2=await fetch(f+'/mcp',{'method':_0x1633cc(0x18b),'headers':{'Content-Type':_0x1633cc(0x13e),'Accept':_0x1633cc(0x161),...X?{'Authorization':_0x1633cc(0x128)+X}:{}},'body':JSON['stringify']({'jsonrpc':_0x1633cc(0x1a7),'id':0x1,'method':_0x1633cc(0x147),'params':{'protocolVersion':_0x1633cc(0x178),'capabilities':{},'clientInfo':{'name':_0x1633cc(0x195),'version':_0x1633cc(0x19e)}}})});if(!_0x3757c2['ok']){let _0x445764=await _0x3757c2[_0x1633cc(0x13d)]();return Y(_0x1633cc(0x174)+_0x3757c2[_0x1633cc(0x16a)]+'\x20'+_0x445764['slice'](0x0,0x64)),{'ok':!0x1,'error':_0x1633cc(0x16d)+_0x3757c2[_0x1633cc(0x16a)]};}await _0x3757c2[_0x1633cc(0x13d)]();let _0x1d8c94=(await(await fetch(f+'/mcp',{'method':_0x1633cc(0x18b),'headers':{'Content-Type':_0x1633cc(0x13e),'Accept':_0x1633cc(0x161),...X?{'Authorization':_0x1633cc(0x128)+X}:{}},'body':JSON['stringify']({'jsonrpc':'2.0','id':0x2,'method':_0x1633cc(0x180),'params':{'name':_0xc2d59e,'arguments':_0x3c791c}})}))[_0x1633cc(0x13d)]())[_0x1633cc(0x17b)]('\x0a')['find'](_0x3d269f=>_0x3d269f['startsWith'](_0x1633cc(0x173)));if(_0x1d8c94){let _0x489667=JSON[_0x1633cc(0x182)](_0x1d8c94[_0x1633cc(0x199)](0x6));return _0x489667?.[_0x1633cc(0x15d)]?.[_0x1633cc(0x129)]?.[0x0]?.[_0x1633cc(0x13d)]?JSON['parse'](_0x489667[_0x1633cc(0x15d)][_0x1633cc(0x129)][0x0][_0x1633cc(0x13d)]):_0x489667;}return{'ok':!0x1,'error':'no\x20response'};}K[a0_0x18095e(0x15c)](a0_0x17aa76,async _0x54a7ac=>{const _0x2d918f=a0_0x18095e;let {name:_0x30e662,arguments:_0x574a0d}=_0x54a7ac[_0x2d918f(0x192)];if(_0x30e662===_0x2d918f(0x17a)){let {task_id:_0x398f5d,text:_0x221d7e,status:_0x3c5244}=_0x574a0d;if(_0x3c5244===_0x2d918f(0x143)||_0x3c5244===_0x2d918f(0x1a0)||_0x3c5244===_0x2d918f(0x135)){let _0x10baaf=_0x3c5244==='completed'?_0x2d918f(0x19c):_0x3c5244,_0x48e311=_0x398f5d?k[_0x2d918f(0x14d)](_0x398f5d)||_0x2d918f(0x160):_0x2d918f(0x160),_0x3a2eb2=await P(_0x2d918f(0x19f),{'alias':_0x48e311,'text':_0x221d7e,'in_reply_to':_0x398f5d||void 0x0,'status':_0x10baaf,'from_session':Z});if(_0x398f5d)k[_0x2d918f(0x151)](_0x398f5d);return{'content':[{'type':_0x2d918f(0x13d),'text':JSON[_0x2d918f(0x12d)](_0x3a2eb2)}]};}let _0x3a1cf1=await P(_0x2d918f(0x1a5),{'resume_id':w,'alias':Z,'status':_0x3c5244===_0x2d918f(0x145)?_0x2d918f(0x145):_0x3c5244==='error'?_0x2d918f(0x187):'working','task':_0x221d7e[_0x2d918f(0x199)](0x0,0xc8),'output':_0x221d7e});return{'content':[{'type':_0x2d918f(0x13d),'text':JSON[_0x2d918f(0x12d)](_0x3a1cf1)}]};}if(_0x30e662===_0x2d918f(0x176)){let {status:_0x1c0713,task:_0x3a601b,progress:_0x4711d7}=_0x574a0d,_0x2f2c25=await P(_0x2d918f(0x1a5),{'resume_id':w,'alias':Z,'status':_0x1c0713,'task':_0x3a601b,'progress':_0x4711d7});return{'content':[{'type':_0x2d918f(0x13d),'text':JSON[_0x2d918f(0x12d)](_0x2f2c25)}]};}if(_0x30e662===_0x2d918f(0x158)){let {alias:_0x35b926,task:_0x1ccd9f,priority:_0x3eaa13}=_0x574a0d,_0x142fd4=await P(_0x2d918f(0x14c),{'alias':_0x35b926,'task':_0x1ccd9f,'priority':_0x3eaa13||_0x2d918f(0x14a),'from_session':Z});return{'content':[{'type':_0x2d918f(0x13d),'text':JSON[_0x2d918f(0x12d)](_0x142fd4)}]};}if(_0x30e662===_0x2d918f(0x17f)){let {alias:_0x256f43,message:_0x128095}=_0x574a0d,_0x42b446=await P(_0x2d918f(0x130),{'alias':_0x256f43,'message':_0x128095,'from_session':Z});return{'content':[{'type':_0x2d918f(0x13d),'text':JSON[_0x2d918f(0x12d)](_0x42b446)}]};}if(_0x30e662===_0x2d918f(0x188)){let _0x97fc3c=await P(_0x2d918f(0x12c),{});return{'content':[{'type':'text','text':JSON['stringify'](_0x97fc3c)}]};}return{'content':[{'type':_0x2d918f(0x13d),'text':JSON[_0x2d918f(0x12d)]({'error':'unknown\x20tool'})}]};});async function u(){const _0x228003=a0_0x18095e;let _0x49509c=f+_0x228003(0x17e)+encodeURIComponent(Z),_0x5dbb85={};if(X)_0x5dbb85[_0x228003(0x169)]=_0x228003(0x128)+X;Y('connecting\x20to\x20'+_0x49509c);while(!0x0){try{let _0x54b590=await fetch(_0x49509c,{'headers':_0x5dbb85});if(!_0x54b590['ok']){Y('SSE\x20error:\x20'+_0x54b590[_0x228003(0x16a)]+'\x20'+_0x54b590[_0x228003(0x17d)]),await h(0x1388);continue;}let _0x103271=_0x54b590[_0x228003(0x193)][_0x228003(0x1a9)](),_0x568f61=new TextDecoder(),_0x5be2f4='';while(!0x0){let {done:_0x576cf5,value:_0x39a3bd}=await _0x103271['read']();if(_0x576cf5)break;_0x5be2f4+=_0x568f61[_0x228003(0x131)](_0x39a3bd,{'stream':!0x0});let _0x6408a3=_0x5be2f4[_0x228003(0x17b)]('\x0a\x0a');_0x5be2f4=_0x6408a3[_0x228003(0x141)]()||'';for(let _0x379fd of _0x6408a3){let _0x1a1d84=_0x379fd[_0x228003(0x17b)]('\x0a')[_0x228003(0x18d)](_0x9cf120=>_0x9cf120[_0x228003(0x16e)](_0x228003(0x173)));if(!_0x1a1d84)continue;try{let _0x340866=JSON['parse'](_0x1a1d84[_0x228003(0x199)](0x6));await S(_0x340866);}catch(_0x36283a){Y(_0x228003(0x177)+_0x36283a);}}}Y(_0x228003(0x17c));}catch(_0x359cce){Y('SSE\x20connection\x20error:\x20'+_0x359cce);}await h(0xbb8);}}async function S(_0x4d6dfb){const _0x520930=a0_0x18095e;if(_0x4d6dfb['type']===_0x520930(0x122)){Y(_0x520930(0x155)+Z+'\x22');return;}if(_0x4d6dfb[_0x520930(0x185)]===_0x520930(0x19d)){if(Y(_0x520930(0x136)+_0x4d6dfb['from']+':\x20'+_0x4d6dfb['message'][_0x520930(0x199)](0x0,0x3c)),await K[_0x520930(0x16b)]({'method':'notifications/claude/channel','params':{'content':_0x4d6dfb['message'],'meta':{'sender':_0x4d6dfb['from']||_0x520930(0x160),'sender_id':_0x520930(0x126),'user':_0x4d6dfb[_0x520930(0x175)]||'hub','priority':_0x520930(0x14a)}}}),_0x4d6dfb[_0x520930(0x18f)])await P(_0x520930(0x196),{'alias':Z,'message_id':_0x4d6dfb[_0x520930(0x18f)]});return;}if(_0x4d6dfb[_0x520930(0x185)]==='new_task'||_0x4d6dfb[_0x520930(0x185)]===_0x520930(0x142)){Y('←\x20'+_0x4d6dfb[_0x520930(0x185)]+':\x20inbox_count='+_0x4d6dfb[_0x520930(0x127)]+'\x20priority='+(_0x4d6dfb[_0x520930(0x154)]||_0x520930(0x14a)));let _0x2361d4=await P(_0x520930(0x189),{'alias':Z,'limit':0x5});if(_0x2361d4?.['ok']&&_0x2361d4[_0x520930(0x152)]?.['length']>0x0)for(let _0x200e46 of _0x2361d4[_0x520930(0x152)]){let _0x2eb30d={'sender':_0x200e46[_0x520930(0x168)]||'hub','sender_id':_0x520930(0x126),'user':_0x200e46[_0x520930(0x168)]||'hub','task_id':_0x200e46['id'],'priority':_0x200e46['priority']||_0x520930(0x14a)};k['set'](_0x200e46['id'],_0x200e46[_0x520930(0x168)]||_0x520930(0x160)),await K[_0x520930(0x16b)]({'method':_0x520930(0x1a8),'params':{'content':_0x200e46['content'],'meta':_0x2eb30d}}),Y(_0x520930(0x133)+_0x200e46['id'][_0x520930(0x199)](0x0,0x8)+_0x520930(0x13f)+_0x200e46['from_session']+':\x20'+_0x200e46['content']['slice'](0x0,0x3c)),await P(_0x520930(0x196),{'alias':Z,'message_id':_0x200e46['id']});}}}async function A(){const _0x1a700f=a0_0x18095e;let _0x1236ee=new a0_0x32bd07();await K[_0x1a700f(0x197)](_0x1236ee),Y(_0x1a700f(0x179)),Y(_0x1a700f(0x159)),u()[_0x1a700f(0x18a)](_0x1c65cc=>Y(_0x1a700f(0x165)+_0x1c65cc)),P('report_status',{'resume_id':w,'alias':Z,'status':'idle','server':a0_0x1988a7(),'hostname':a0_0x1988a7(),'agent':_0x1a700f(0x171),'project_dir':process[_0x1a700f(0x144)](),'tmux_name':j||void 0x0})[_0x1a700f(0x14e)](()=>Y(_0x1a700f(0x198)+Z+'\x22\x20('+w[_0x1a700f(0x199)](0x0,0x8)+')'))[_0x1a700f(0x18a)](_0x47d009=>Y('warning:\x20could\x20not\x20register:\x20'+_0x47d009)),setInterval(()=>{const _0x538e7c=_0x1a700f;P('report_status',{'resume_id':w,'alias':Z,'status':_0x538e7c(0x132),'server':a0_0x1988a7(),'hostname':a0_0x1988a7(),'agent':_0x538e7c(0x171),'project_dir':process[_0x538e7c(0x144)](),'tmux_name':j||void 0x0})[_0x538e7c(0x18a)](_0x3097ab=>Y('heartbeat\x20failed:\x20'+_0x3097ab));},0x2bf20),Y('ready\x20—\x20waiting\x20for\x20events');}A()[a0_0x18095e(0x18a)](_0xbbaff=>{const _0x1339dc=a0_0x18095e;Y(_0x1339dc(0x13b)+_0xbbaff),process[_0x1339dc(0x184)](0x1);});async function N(){const _0x3e1a79=a0_0x18095e;Y(_0x3e1a79(0x19b)),await P(_0x3e1a79(0x1a5),{'resume_id':w,'alias':Z,'status':_0x3e1a79(0x187),'task':_0x3e1a79(0x138)})[_0x3e1a79(0x18a)](()=>{}),process[_0x3e1a79(0x184)](0x0);}process[a0_0x18095e(0x123)]['on']('end',()=>N()),process['on']('SIGTERM',()=>N()),process['on'](a0_0x18095e(0x13c),()=>N());
2
+ const a0_0x5afc3c=a0_0x1644;(function(_0x44ff8f,_0x525b4d){const _0x31c6dd=a0_0x1644,_0x3b86ef=_0x44ff8f();while(!![]){try{const _0x314bcb=-parseInt(_0x31c6dd(0x152))/0x1*(parseInt(_0x31c6dd(0x10f))/0x2)+-parseInt(_0x31c6dd(0x158))/0x3*(-parseInt(_0x31c6dd(0x128))/0x4)+-parseInt(_0x31c6dd(0xd4))/0x5*(-parseInt(_0x31c6dd(0xfa))/0x6)+parseInt(_0x31c6dd(0x12c))/0x7*(parseInt(_0x31c6dd(0x110))/0x8)+parseInt(_0x31c6dd(0x144))/0x9+-parseInt(_0x31c6dd(0xeb))/0xa*(parseInt(_0x31c6dd(0x141))/0xb)+parseInt(_0x31c6dd(0x102))/0xc;if(_0x314bcb===_0x525b4d)break;else _0x3b86ef['push'](_0x3b86ef['shift']());}catch(_0x1d3ab){_0x3b86ef['push'](_0x3b86ef['shift']());}}}(a0_0x40eb,0xe3170));import{readFileSync as a0_0x3f9e5e,existsSync as a0_0x758f04}from'fs';import{randomUUID as a0_0x12e77c}from'crypto';import{join as a0_0x18d90a}from'path';import{hostname as a0_0x2a592f}from'os';import{execSync as a0_0x403dc6}from'child_process';import{Server as a0_0x1d6a70}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport as a0_0x58a500}from'@modelcontextprotocol/sdk/server/stdio.js';import{ListToolsRequestSchema as a0_0x43fcca,CallToolRequestSchema as a0_0xa99d8}from'@modelcontextprotocol/sdk/types.js';function p(_0x5a7c89){const _0x393a39=a0_0x1644;if(!a0_0x758f04(_0x5a7c89))return;for(let _0x2d6255 of a0_0x3f9e5e(_0x5a7c89,_0x393a39(0x10a))[_0x393a39(0xe1)]('\x0a')){let _0x503b7d=_0x2d6255[_0x393a39(0x10e)]();if(!_0x503b7d||_0x503b7d['startsWith']('#'))continue;let _0x5aab51=_0x503b7d[_0x393a39(0x11d)]('=');if(_0x5aab51<0x0)continue;let _0x1b38ec=_0x503b7d['slice'](0x0,_0x5aab51)[_0x393a39(0x10e)](),_0x59f78a=_0x503b7d[_0x393a39(0xd5)](_0x5aab51+0x1)['trim']()['replace'](/^["']|["']$/g,'');if(!process.env[_0x1b38ec])process.env[_0x1b38ec]=_0x59f78a;}}var C=process.env.HOME||'~',T=a0_0x18d90a(C,a0_0x5afc3c(0x129));p(a0_0x18d90a(T,a0_0x5afc3c(0xed)));var L=process[a0_0x5afc3c(0xd0)]()[a0_0x5afc3c(0x119)](/\//g,'-');p(a0_0x18d90a(T,L,a0_0x5afc3c(0xed)));function U(){const _0x84a464=a0_0x5afc3c;try{return a0_0x403dc6('tmux\x20display-message\x20-p\x20\x27#S\x27',{'encoding':_0x84a464(0x10a),'timeout':0x7d0})['trim']();}catch{return'';}}function v(){const _0x41f078=a0_0x5afc3c;try{let _0x1b79bc=a0_0x18d90a(C,_0x41f078(0x11f),_0x41f078(0xf5));if(a0_0x758f04(_0x1b79bc))return JSON[_0x41f078(0x143)](a0_0x3f9e5e(_0x1b79bc,_0x41f078(0x10a)));}catch{}return{};}var H=v(),f=process.env.COMMHUB_URL||H[a0_0x5afc3c(0xda)]||a0_0x5afc3c(0xd2),j=process.env.COMMHUB_TMUX||U(),Z=process.env.COMMHUB_ALIAS||j||a0_0x2a592f(),w=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||a0_0x12e77c(),X=process.env.COMMHUB_TOKEN||H[a0_0x5afc3c(0xff)]||'';function Y(_0x21ac04){const _0x3083c1=a0_0x5afc3c;let _0x2d1ed1=new Date()[_0x3083c1(0x104)]()[_0x3083c1(0xd5)](0x0,0x8);process['stderr'][_0x3083c1(0xfb)]('['+_0x2d1ed1+_0x3083c1(0xf2)+_0x21ac04+'\x0a');}function h(_0x269553){return new Promise(_0x675e1=>setTimeout(_0x675e1,_0x269553));}Y('ENV:\x20URL='+f+a0_0x5afc3c(0x109)+Z+a0_0x5afc3c(0x114)+w[a0_0x5afc3c(0xd5)](0x0,0x8)+a0_0x5afc3c(0xee)+(j||a0_0x5afc3c(0x15a))+a0_0x5afc3c(0x115)+process['cwd']()+'\x20PROJECT_ENV='+L);var k=new Map(),K=new a0_0x1d6a70({'name':a0_0x5afc3c(0xf6),'version':a0_0x5afc3c(0xe6)},{'capabilities':{'experimental':{'claude/channel':{}},'tools':{}},'instructions':[a0_0x5afc3c(0x130),a0_0x5afc3c(0x11a),a0_0x5afc3c(0x12b),'You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.','Session\x20alias:\x20'+Z][a0_0x5afc3c(0xe2)]('\x0a')});K[a0_0x5afc3c(0x132)](a0_0x43fcca,async()=>({'tools':[{'name':a0_0x5afc3c(0xf8),'description':a0_0x5afc3c(0x10c),'inputSchema':{'type':a0_0x5afc3c(0xf4),'properties':{'task_id':{'type':a0_0x5afc3c(0x145),'description':a0_0x5afc3c(0xe5)},'text':{'type':a0_0x5afc3c(0x145),'description':a0_0x5afc3c(0xfc)},'status':{'type':a0_0x5afc3c(0x145),'enum':['completed',a0_0x5afc3c(0x150),a0_0x5afc3c(0xcc),a0_0x5afc3c(0x121),a0_0x5afc3c(0x134),a0_0x5afc3c(0xe0)],'description':a0_0x5afc3c(0x12e)}},'required':[a0_0x5afc3c(0xea)]}},{'name':a0_0x5afc3c(0xca),'description':'Update\x20this\x20session\x27s\x20status\x20in\x20CommHub\x20(working/idle/blocked/error).\x20Returns\x20inbox_count.','inputSchema':{'type':a0_0x5afc3c(0xf4),'properties':{'status':{'type':a0_0x5afc3c(0x145),'enum':[a0_0x5afc3c(0x124),a0_0x5afc3c(0x118),a0_0x5afc3c(0x121),'error']},'task':{'type':a0_0x5afc3c(0x145),'description':a0_0x5afc3c(0x101)},'progress':{'type':a0_0x5afc3c(0x125),'description':a0_0x5afc3c(0x131)}},'required':[a0_0x5afc3c(0x137)]}},{'name':a0_0x5afc3c(0x153),'description':a0_0x5afc3c(0x103),'inputSchema':{'type':a0_0x5afc3c(0xf4),'properties':{'alias':{'type':a0_0x5afc3c(0x145),'description':a0_0x5afc3c(0xf3)},'task':{'type':a0_0x5afc3c(0x145),'description':'Task\x20content'},'priority':{'type':a0_0x5afc3c(0x145),'enum':[a0_0x5afc3c(0x12d),'normal',a0_0x5afc3c(0xd9)],'description':a0_0x5afc3c(0xce)}},'required':[a0_0x5afc3c(0x117),a0_0x5afc3c(0x108)]}},{'name':a0_0x5afc3c(0x14f),'description':a0_0x5afc3c(0x12a),'inputSchema':{'type':a0_0x5afc3c(0xf4),'properties':{'alias':{'type':'string','description':a0_0x5afc3c(0xf3)},'message':{'type':a0_0x5afc3c(0x145),'description':a0_0x5afc3c(0x155)}},'required':['alias',a0_0x5afc3c(0xe7)]}},{'name':a0_0x5afc3c(0x135),'description':'Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','inputSchema':{'type':a0_0x5afc3c(0xf4),'properties':{}}}]}));async function P(_0x37102f,_0x4edad5){const _0x6e9552=a0_0x5afc3c;let _0x1145b9=await fetch(f+_0x6e9552(0xdc),{'method':_0x6e9552(0x142),'headers':{'Content-Type':_0x6e9552(0x156),'Accept':_0x6e9552(0xec),...X?{'Authorization':_0x6e9552(0x111)+X}:{}},'body':JSON['stringify']({'jsonrpc':_0x6e9552(0xf0),'id':0x1,'method':_0x6e9552(0x122),'params':{'protocolVersion':_0x6e9552(0x105),'capabilities':{},'clientInfo':{'name':_0x6e9552(0xf6),'version':_0x6e9552(0xe6)}}})});if(!_0x1145b9['ok']){let _0x3a2dea=await _0x1145b9[_0x6e9552(0xea)]();return Y(_0x6e9552(0x13a)+_0x1145b9[_0x6e9552(0x137)]+'\x20'+_0x3a2dea[_0x6e9552(0xd5)](0x0,0x64)),{'ok':!0x1,'error':_0x6e9552(0x120)+_0x1145b9[_0x6e9552(0x137)]};}await _0x1145b9[_0x6e9552(0xea)]();let _0x16a824=(await(await fetch(f+_0x6e9552(0xdc),{'method':_0x6e9552(0x142),'headers':{'Content-Type':_0x6e9552(0x156),'Accept':_0x6e9552(0xec),...X?{'Authorization':'Bearer\x20'+X}:{}},'body':JSON[_0x6e9552(0x13e)]({'jsonrpc':_0x6e9552(0xf0),'id':0x2,'method':_0x6e9552(0x14a),'params':{'name':_0x37102f,'arguments':_0x4edad5}})}))[_0x6e9552(0xea)]())[_0x6e9552(0xe1)]('\x0a')[_0x6e9552(0x154)](_0x54e0b2=>_0x54e0b2['startsWith'](_0x6e9552(0x146)));if(_0x16a824){let _0x14ae60=JSON[_0x6e9552(0x143)](_0x16a824[_0x6e9552(0xd5)](0x6));return _0x14ae60?.[_0x6e9552(0xe8)]?.[_0x6e9552(0x136)]?.[0x0]?.[_0x6e9552(0xea)]?JSON[_0x6e9552(0x143)](_0x14ae60[_0x6e9552(0xe8)]['content'][0x0]['text']):_0x14ae60;}return{'ok':!0x1,'error':_0x6e9552(0x14e)};}function a0_0x1644(_0x28afcc,_0x5655e7){_0x28afcc=_0x28afcc-0xca;const _0x40eb85=a0_0x40eb();let _0x16443f=_0x40eb85[_0x28afcc];return _0x16443f;}K[a0_0x5afc3c(0x132)](a0_0xa99d8,async _0x13d9cc=>{const _0x130b5d=a0_0x5afc3c;let {name:_0x2d2bd,arguments:_0x17f670}=_0x13d9cc['params'];if(_0x2d2bd===_0x130b5d(0xf8)){let {task_id:_0x136cf7,text:_0x32f03d,status:_0x3c68c0}=_0x17f670;if(_0x3c68c0===_0x130b5d(0x13b)||_0x3c68c0==='failed'||_0x3c68c0===_0x130b5d(0xcc)){let _0x52e421=_0x3c68c0===_0x130b5d(0x13b)?'replied':_0x3c68c0,_0x54a186=_0x136cf7?k[_0x130b5d(0xe9)](_0x136cf7)||_0x130b5d(0xda):_0x130b5d(0xda),_0x521301=await P('send_reply',{'alias':_0x54a186,'text':_0x32f03d,'in_reply_to':_0x136cf7||void 0x0,'status':_0x52e421,'from_session':Z});if(_0x136cf7)k[_0x130b5d(0xf7)](_0x136cf7);return{'content':[{'type':_0x130b5d(0xea),'text':JSON[_0x130b5d(0x13e)](_0x521301)}]};}let _0x5cfa77=await P(_0x130b5d(0x113),{'resume_id':w,'alias':Z,'status':_0x3c68c0===_0x130b5d(0x121)?'blocked':_0x3c68c0==='error'?_0x130b5d(0x134):_0x130b5d(0x124),'task':_0x32f03d[_0x130b5d(0xd5)](0x0,0xc8),'output':_0x32f03d});return{'content':[{'type':'text','text':JSON[_0x130b5d(0x13e)](_0x5cfa77)}]};}if(_0x2d2bd===_0x130b5d(0xca)){let {status:_0x20963d,task:_0x28ce40,progress:_0x301bae}=_0x17f670,_0x358c59=await P('report_status',{'resume_id':w,'alias':Z,'status':_0x20963d,'task':_0x28ce40,'progress':_0x301bae});return{'content':[{'type':'text','text':JSON[_0x130b5d(0x13e)](_0x358c59)}]};}if(_0x2d2bd===_0x130b5d(0x153)){let {alias:_0x343202,task:_0x4abb2e,priority:_0x3fce70}=_0x17f670,_0x34a9d5=await P(_0x130b5d(0x157),{'alias':_0x343202,'task':_0x4abb2e,'priority':_0x3fce70||_0x130b5d(0x11b),'from_session':Z});return{'content':[{'type':_0x130b5d(0xea),'text':JSON['stringify'](_0x34a9d5)}]};}if(_0x2d2bd===_0x130b5d(0x14f)){let {alias:_0x283c3a,message:_0x1145db}=_0x17f670,_0xfdee1d=await P(_0x130b5d(0xcb),{'alias':_0x283c3a,'message':_0x1145db,'from_session':Z});return{'content':[{'type':_0x130b5d(0xea),'text':JSON['stringify'](_0xfdee1d)}]};}if(_0x2d2bd==='commhub_get_all_status'){let _0x27efc9=await P(_0x130b5d(0xf1),{});return{'content':[{'type':_0x130b5d(0xea),'text':JSON[_0x130b5d(0x13e)](_0x27efc9)}]};}return{'content':[{'type':_0x130b5d(0xea),'text':JSON[_0x130b5d(0x13e)]({'error':_0x130b5d(0x100)})}]};});async function u(){const _0x1cfa64=a0_0x5afc3c;let _0x246e03=f+_0x1cfa64(0xe3)+encodeURIComponent(Z),_0x573d20={};if(X)_0x573d20[_0x1cfa64(0xfd)]=_0x1cfa64(0x111)+X;Y(_0x1cfa64(0x139)+_0x246e03);while(!0x0){try{let _0x1aba62=await fetch(_0x246e03,{'headers':_0x573d20});if(!_0x1aba62['ok']){Y(_0x1cfa64(0x13c)+_0x1aba62[_0x1cfa64(0x137)]+'\x20'+_0x1aba62[_0x1cfa64(0x133)]),await h(0x1388);continue;}let _0x23b34b=_0x1aba62[_0x1cfa64(0x123)]['getReader'](),_0x5aa8a8=new TextDecoder(),_0x5f2062='';while(!0x0){let {done:_0x3e3d78,value:_0x31e2e6}=await _0x23b34b[_0x1cfa64(0xdb)]();if(_0x3e3d78)break;_0x5f2062+=_0x5aa8a8[_0x1cfa64(0xd8)](_0x31e2e6,{'stream':!0x0});let _0x92465c=_0x5f2062[_0x1cfa64(0xe1)]('\x0a\x0a');_0x5f2062=_0x92465c[_0x1cfa64(0x147)]()||'';for(let _0x40e655 of _0x92465c){let _0x1d9806=_0x40e655[_0x1cfa64(0xe1)]('\x0a')['find'](_0x3d7e78=>_0x3d7e78[_0x1cfa64(0xd7)](_0x1cfa64(0x146)));if(!_0x1d9806)continue;try{let _0x3c669d=JSON[_0x1cfa64(0x143)](_0x1d9806[_0x1cfa64(0xd5)](0x6));await S(_0x3c669d);}catch(_0x5b8761){Y(_0x1cfa64(0x11c)+_0x5b8761);}}}Y(_0x1cfa64(0x126));}catch(_0xd00cda){Y('SSE\x20connection\x20error:\x20'+_0xd00cda);}await h(0xbb8);}}async function S(_0x2803cf){const _0xed37f4=a0_0x5afc3c;if(_0x2803cf[_0xed37f4(0x12f)]===_0xed37f4(0xde)){Y('SSE\x20connected\x20as\x20\x22'+Z+'\x22');return;}if(_0x2803cf['type']==='new_message'){if(Y(_0xed37f4(0x106)+_0x2803cf[_0xed37f4(0xdf)]+':\x20'+_0x2803cf['message'][_0xed37f4(0xd5)](0x0,0x3c)),await K[_0xed37f4(0xef)]({'method':_0xed37f4(0xd6),'params':{'content':_0x2803cf[_0xed37f4(0xe7)],'meta':{'sender':_0x2803cf[_0xed37f4(0xdf)]||_0xed37f4(0xda),'sender_id':_0xed37f4(0x127),'user':_0x2803cf[_0xed37f4(0xdf)]||_0xed37f4(0xda),'priority':_0xed37f4(0x11b)}}}),_0x2803cf[_0xed37f4(0x151)])await P(_0xed37f4(0x159),{'alias':Z,'message_id':_0x2803cf['message_id']});return;}if(_0x2803cf['type']===_0xed37f4(0xdd)||_0x2803cf[_0xed37f4(0x12f)]===_0xed37f4(0x140)){Y('←\x20'+_0x2803cf[_0xed37f4(0x12f)]+_0xed37f4(0x15b)+_0x2803cf[_0xed37f4(0xd1)]+'\x20priority='+(_0x2803cf[_0xed37f4(0xe4)]||_0xed37f4(0x11b)));let _0x223d28=await P(_0xed37f4(0xf9),{'alias':Z,'limit':0x5});if(_0x223d28?.['ok']&&_0x223d28[_0xed37f4(0x14c)]?.[_0xed37f4(0x149)]>0x0)for(let _0x35f1ed of _0x223d28[_0xed37f4(0x14c)]){let _0x477b05={'sender':_0x35f1ed[_0xed37f4(0x14b)]||_0xed37f4(0xda),'sender_id':_0xed37f4(0x127),'user':_0x35f1ed[_0xed37f4(0x14b)]||_0xed37f4(0xda),'task_id':_0x35f1ed['id'],'priority':_0x35f1ed[_0xed37f4(0xe4)]||_0xed37f4(0x11b)};k[_0xed37f4(0xcd)](_0x35f1ed['id'],_0x35f1ed[_0xed37f4(0x14b)]||_0xed37f4(0xda)),await K[_0xed37f4(0xef)]({'method':_0xed37f4(0xd6),'params':{'content':_0x35f1ed['content'],'meta':_0x477b05}}),Y(_0xed37f4(0x138)+_0x35f1ed['id']['slice'](0x0,0x8)+_0xed37f4(0x112)+_0x35f1ed[_0xed37f4(0x14b)]+':\x20'+_0x35f1ed['content'][_0xed37f4(0xd5)](0x0,0x3c)),await P(_0xed37f4(0x159),{'alias':Z,'message_id':_0x35f1ed['id']});}}}function a0_0x40eb(){const _0x4cc1ff=['\x20ALIAS=','utf-8','catch','Reply\x20to\x20a\x20CommHub\x20task\x20—\x20report\x20completion\x20or\x20send\x20a\x20message\x20back\x20to\x20the\x20hub.','shutting\x20down,\x20reporting\x20offline...','trim','781918ZXJyGZ','450040eanlgX','Bearer\x20','\x20from\x20','report_status','\x20RESUME_ID=','\x20CWD=','exit','alias','idle','replace','These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.','normal','parse\x20error:\x20','indexOf','end','.anet','init\x20failed:\x20','blocked','initialize','body','working','number','SSE\x20stream\x20ended,\x20reconnecting...','commhub','4RcDZjk','.claude/channels/commhub','Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.','Reply\x20using\x20the\x20commhub_reply\x20tool\x20to\x20report\x20status\x20or\x20results\x20back.','49ZjoSza','high','Task\x20outcome:\x20completed/failed/cancelled\x20for\x20final\x20results,\x20blocked/error/in_progress\x20for\x20status\x20updates','type','Messages\x20from\x20CommHub\x20arrive\x20as\x20<channel\x20source=\x22commhub\x22\x20task_id=\x22...\x22\x20priority=\x22...\x22\x20from=\x22...\x22>','Progress\x200-100','setRequestHandler','statusText','error','commhub_get_all_status','content','status','→\x20injected\x20task\x20','connecting\x20to\x20','CommHub\x20init\x20failed:\x20','completed','SSE\x20error:\x20','claude-code','stringify','starting\x20SSE\x20listener...','broadcast','187KPvTlM','POST','parse','8332965wlMjSk','string','data:\x20','pop','SSE\x20fatal:\x20','length','tools/call','from_session','messages','MCP\x20stdio\x20connected','no\x20response','commhub_send_message','failed','message_id','1omOFTw','commhub_send_task','find','Message\x20content','application/json','send_task','1195521EeEYAH','ack_inbox','none',':\x20inbox_count=','commhub_report_status','send_message','cancelled','set','Priority\x20(default:\x20normal)','fatal:\x20','cwd','inbox_count','http://127.0.0.1:9200','SIGTERM','4485145RsEECL','slice','notifications/claude/channel','startsWith','decode','low','hub','read','/mcp','new_task','connected','from','in_progress','split','join','/events/','priority','The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)','0.3.0','message','result','get','text','983140PCpuSU','application/json,\x20text/event-stream','.env','...\x20TMUX=','notification','2.0','get_all_status',']\x20[commhub]\x20','Target\x20session\x20alias','object','config.json','commhub-channel','delete','commhub_reply','get_inbox','6VNqPAA','write','Reply\x20text\x20/\x20result\x20summary','Authorization','warning:\x20could\x20not\x20register:\x20','token','unknown\x20tool','Current\x20task\x20description','4527012mFCOZT','Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.','toTimeString','2025-03-26','←\x20message\x20from\x20','stdin','task'];a0_0x40eb=function(){return _0x4cc1ff;};return a0_0x40eb();}async function A(){const _0x4ce632=a0_0x5afc3c;let _0xfd61db=new a0_0x58a500();await K['connect'](_0xfd61db),Y(_0x4ce632(0x14d)),Y(_0x4ce632(0x13f)),u()[_0x4ce632(0x10b)](_0x3899fb=>Y(_0x4ce632(0x148)+_0x3899fb)),P(_0x4ce632(0x113),{'resume_id':w,'alias':Z,'status':_0x4ce632(0x118),'server':a0_0x2a592f(),'hostname':a0_0x2a592f(),'agent':'claude-code','project_dir':process[_0x4ce632(0xd0)](),'tmux_name':j||void 0x0})['then'](()=>Y('registered\x20as\x20\x22'+Z+'\x22\x20('+w[_0x4ce632(0xd5)](0x0,0x8)+')'))[_0x4ce632(0x10b)](_0x2bc13f=>Y(_0x4ce632(0xfe)+_0x2bc13f)),setInterval(()=>{const _0x7cd90c=_0x4ce632;P(_0x7cd90c(0x113),{'resume_id':w,'alias':Z,'status':_0x7cd90c(0x118),'server':a0_0x2a592f(),'hostname':a0_0x2a592f(),'agent':_0x7cd90c(0x13d),'project_dir':process['cwd'](),'tmux_name':j||void 0x0})[_0x7cd90c(0x10b)](_0x4d300c=>Y('heartbeat\x20failed:\x20'+_0x4d300c));},0x2bf20),Y('ready\x20—\x20waiting\x20for\x20events');}A()['catch'](_0x43f393=>{const _0x3eb012=a0_0x5afc3c;Y(_0x3eb012(0xcf)+_0x43f393),process[_0x3eb012(0x116)](0x1);});async function N(){const _0x311466=a0_0x5afc3c;Y(_0x311466(0x10d)),await P(_0x311466(0x113),{'resume_id':w,'alias':Z,'status':_0x311466(0x134),'task':'session\x20disconnected'})[_0x311466(0x10b)](()=>{}),process[_0x311466(0x116)](0x0);}process[a0_0x5afc3c(0x107)]['on'](a0_0x5afc3c(0x11e),()=>N()),process['on'](a0_0x5afc3c(0xd3),()=>N()),process['on']('SIGINT',()=>N());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sleep2agi/agent-network",
3
- "version": "2.1.8-preview.3",
3
+ "version": "2.1.8-preview.5",
4
4
  "description": "AI Agent Network CLI — Create multi-agent networks with user management, network isolation, and 3 AI runtimes (Claude/Codex/MiniMax). 39 commands.",
5
5
  "type": "module",
6
6
  "main": "dist/src/client.js",
package/dist/client.d.ts DELETED
@@ -1,78 +0,0 @@
1
- /**
2
- * @sleep2agi/commhub-sdk
3
- *
4
- * CommHub 通信 SDK — 一个文件,SSE 长连接 + 自动重连 + 心跳。
5
- * 支持 Node.js 18+ 和 Bun。
6
- */
7
- import { EventEmitter } from "events";
8
- export interface CommHubOptions {
9
- /** CommHub Server URL, e.g. "http://YOUR_COMMHUB_IP:9200" */
10
- url: string;
11
- /** Session alias, e.g. "SDK马" */
12
- alias: string;
13
- /** Auth token (optional) */
14
- token?: string;
15
- /** Agent type for registration (default: "sdk") */
16
- agent?: string;
17
- /** Heartbeat interval in ms (default: 180000 = 3 min) */
18
- heartbeatInterval?: number;
19
- /** SSE reconnect base delay in ms (default: 3000) */
20
- reconnectDelay?: number;
21
- /** Auto-connect on creation (default: true) */
22
- autoConnect?: boolean;
23
- }
24
- export interface InboxMessage {
25
- id: string;
26
- content: string;
27
- from_session: string;
28
- priority: string;
29
- created_at: string;
30
- }
31
- export interface CommHubEvents {
32
- task: (msg: InboxMessage) => void;
33
- message: (msg: InboxMessage) => void;
34
- connected: () => void;
35
- disconnected: () => void;
36
- error: (err: Error) => void;
37
- }
38
- export declare class CommHub extends EventEmitter {
39
- private url;
40
- private alias;
41
- private token?;
42
- private agent;
43
- private resumeId;
44
- private heartbeatInterval;
45
- private reconnectDelay;
46
- private heartbeatTimer?;
47
- private sseAbort?;
48
- private running;
49
- constructor(opts: CommHubOptions);
50
- private log;
51
- private call;
52
- /** Connect to CommHub: register + start SSE + heartbeat */
53
- connect(): Promise<void>;
54
- /** Disconnect: stop SSE + heartbeat, report offline */
55
- disconnect(): Promise<void>;
56
- /** Send a task to another session */
57
- send(targetAlias: string, content: string, priority?: "high" | "normal" | "low"): Promise<any>;
58
- /** Send a message (no task lifecycle) */
59
- message(targetAlias: string, content: string): Promise<any>;
60
- /** Reply to a task (update status) */
61
- reply(taskId: string, text: string, status?: "completed" | "blocked" | "error" | "in_progress"): Promise<any>;
62
- /** Update session status */
63
- status(state: string, extra?: {
64
- task?: string;
65
- progress?: number;
66
- }): Promise<any>;
67
- /** Get all session statuses */
68
- getAllStatus(): Promise<any>;
69
- /** Broadcast to all sessions */
70
- broadcast(content: string, filter?: {
71
- server?: string;
72
- status?: string;
73
- }): Promise<any>;
74
- private connectSSE;
75
- private processInbox;
76
- private sleep;
77
- }
78
- export default CommHub;