@sleep2agi/agent-network 2.2.18-preview.0 → 2.2.19-preview.0

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_0x584588=a0_0x1c20;(function(_0x4034f7,_0x1ddc2c){const _0x3a5c44=a0_0x1c20,_0x1cf8d7=_0x4034f7();while(!![]){try{const _0x169192=-parseInt(_0x3a5c44(0x1c8))/0x1+-parseInt(_0x3a5c44(0x1ca))/0x2+parseInt(_0x3a5c44(0x18f))/0x3*(parseInt(_0x3a5c44(0x1e0))/0x4)+parseInt(_0x3a5c44(0x1db))/0x5*(parseInt(_0x3a5c44(0x1a3))/0x6)+-parseInt(_0x3a5c44(0x1a7))/0x7*(-parseInt(_0x3a5c44(0x1ab))/0x8)+-parseInt(_0x3a5c44(0x19d))/0x9*(parseInt(_0x3a5c44(0x196))/0xa)+parseInt(_0x3a5c44(0x1d9))/0xb;if(_0x169192===_0x1ddc2c)break;else _0x1cf8d7['push'](_0x1cf8d7['shift']());}catch(_0x47fc2a){_0x1cf8d7['push'](_0x1cf8d7['shift']());}}}(a0_0x5f00,0x9165f));function a0_0x1c20(_0x18afbe,_0x262736){_0x18afbe=_0x18afbe-0x18a;const _0x5f0051=a0_0x5f00();let _0x1c2082=_0x5f0051[_0x18afbe];return _0x1c2082;}function a0_0x5f00(){const _0x350088=['content','error','disconnected','heartbeat\x20failed:\x20','text','/mcp','connect','19966133LWniLp','abort','3844040LmpoGD','2.0','getReader','from_session','SSE\x20error:\x20','525752qJqvGl','cwd','body','POST','split','emit','3YcCFfK','application/json','status','running','registered','AbortError','connected','4010FaSaYs','sseAbort','name','token','get_inbox','Authorization','report_status','22455yhxTHi','sdk','heartbeatInterval','log','SSE\x20failed:\x20','heartbeatTimer','6yZOouL','slice','send_message','task','3361183hytxKF','s...','signal',']\x20[commhub:','8ZTfdUj','Bearer\x20','parse','now','processInbox','agent','connectSSE','reply','catch','reconnectDelay','send_task','pop','get_all_status','idle','normal','result','type','url','alias','getAllStatus','read','resumeId','min','disconnect','call','replace','autoConnect','SSE\x20connected','completed','1047359bacXwy','message','1104226JCiQBH','new_task','tools/call','sdk-','broadcast','messages','sleep','startsWith'];a0_0x5f00=function(){return _0x350088;};return a0_0x5f00();}import{EventEmitter as a0_0x3ef94b}from'events';import{hostname as a0_0x12b62a}from'os';class T extends a0_0x3ef94b{[a0_0x584588(0x1bc)];[a0_0x584588(0x1bd)];[a0_0x584588(0x199)];[a0_0x584588(0x1b0)];['resumeId'];[a0_0x584588(0x19f)];['reconnectDelay'];[a0_0x584588(0x1a2)];[a0_0x584588(0x197)];[a0_0x584588(0x192)]=!0x1;constructor(_0x16f66a){const _0x45f1d8=a0_0x584588;super();if(this['url']=_0x16f66a[_0x45f1d8(0x1bc)][_0x45f1d8(0x1c4)](/\/$/,''),this[_0x45f1d8(0x1bd)]=_0x16f66a['alias'],this[_0x45f1d8(0x199)]=_0x16f66a[_0x45f1d8(0x199)],this[_0x45f1d8(0x1b0)]=_0x16f66a[_0x45f1d8(0x1b0)]||_0x45f1d8(0x19e),this['resumeId']=_0x45f1d8(0x1cd)+_0x16f66a[_0x45f1d8(0x1bd)]+'-'+Date['now']()['toString'](0x24),this[_0x45f1d8(0x19f)]=_0x16f66a[_0x45f1d8(0x19f)]??0x2bf20,this[_0x45f1d8(0x1b4)]=_0x16f66a[_0x45f1d8(0x1b4)]??0xbb8,_0x16f66a[_0x45f1d8(0x1c5)]!==!0x1)this[_0x45f1d8(0x1d8)]();}[a0_0x584588(0x1a0)](_0x521db2){const _0x177728=a0_0x584588;console['log']('['+new Date()['toTimeString']()[_0x177728(0x1a4)](0x0,0x8)+_0x177728(0x1aa)+this['alias']+']\x20'+_0x521db2);}async[a0_0x584588(0x1c3)](_0x3c04c3,_0x40f06b){const _0x32d3c0=a0_0x584588;let _0x4be1a7={'Content-Type':_0x32d3c0(0x190),'Accept':'application/json,\x20text/event-stream'};if(this[_0x32d3c0(0x199)])_0x4be1a7[_0x32d3c0(0x19b)]=_0x32d3c0(0x1ac)+this[_0x32d3c0(0x199)];let _0x478647=await(await fetch(this[_0x32d3c0(0x1bc)]+_0x32d3c0(0x1d7),{'method':_0x32d3c0(0x18c),'headers':_0x4be1a7,'body':JSON['stringify']({'jsonrpc':_0x32d3c0(0x1dc),'id':Date[_0x32d3c0(0x1ae)](),'method':_0x32d3c0(0x1cc),'params':{'name':_0x3c04c3,'arguments':_0x40f06b}})}))[_0x32d3c0(0x1d6)](),_0x1b7142=_0x478647['match'](/data: (.+)/),_0x18dfaa=_0x1b7142?JSON[_0x32d3c0(0x1ad)](_0x1b7142[0x1]):JSON[_0x32d3c0(0x1ad)](_0x478647),_0x2de2b8=_0x18dfaa?.[_0x32d3c0(0x1ba)]?.[_0x32d3c0(0x1d2)]?.[0x0]?.[_0x32d3c0(0x1d6)];return _0x2de2b8?JSON[_0x32d3c0(0x1ad)](_0x2de2b8):_0x18dfaa;}async['connect'](){const _0x979ef8=a0_0x584588;if(this[_0x979ef8(0x192)])return;this['running']=!0x0,await this[_0x979ef8(0x191)](_0x979ef8(0x1b8)),this[_0x979ef8(0x1a0)](_0x979ef8(0x193)),this[_0x979ef8(0x1a2)]=setInterval(()=>{const _0x26968e=_0x979ef8;this[_0x26968e(0x191)](_0x26968e(0x1b8))[_0x26968e(0x1b3)](_0x22c0ed=>this[_0x26968e(0x1a0)](_0x26968e(0x1d5)+_0x22c0ed['message']));},this[_0x979ef8(0x19f)]),this[_0x979ef8(0x1b1)]();}async[a0_0x584588(0x1c2)](){const _0x518b21=a0_0x584588;if(this[_0x518b21(0x192)]=!0x1,this[_0x518b21(0x197)]?.[_0x518b21(0x1da)](),this['heartbeatTimer'])clearInterval(this[_0x518b21(0x1a2)]);await this[_0x518b21(0x191)]('offline')[_0x518b21(0x1b3)](()=>{}),this[_0x518b21(0x1a0)](_0x518b21(0x1d4));}async['send'](_0x5db2d9,_0x20c551,_0xae8e5a=a0_0x584588(0x1b9)){const _0x13fdc9=a0_0x584588;return this[_0x13fdc9(0x1c3)](_0x13fdc9(0x1b5),{'alias':_0x5db2d9,'task':_0x20c551,'priority':_0xae8e5a,'from_session':this[_0x13fdc9(0x1bd)]});}async[a0_0x584588(0x1c9)](_0x603c9e,_0x2e3b3b){const _0x52ba03=a0_0x584588;return this[_0x52ba03(0x1c3)](_0x52ba03(0x1a5),{'alias':_0x603c9e,'message':_0x2e3b3b,'from_session':this[_0x52ba03(0x1bd)]});}async[a0_0x584588(0x1b2)](_0x256e01,_0x61bdf0,_0x51925d=a0_0x584588(0x1c7)){const _0x120c93=a0_0x584588;return this[_0x120c93(0x1c3)]('send_reply',{'in_reply_to':_0x256e01,'text':_0x61bdf0,'status':_0x51925d});}async[a0_0x584588(0x191)](_0x110dd0,_0x545447){const _0x41acfc=a0_0x584588;return this['call'](_0x41acfc(0x19c),{'resume_id':this[_0x41acfc(0x1c0)],'alias':this['alias'],'status':_0x110dd0,'server':a0_0x12b62a(),'hostname':a0_0x12b62a(),'agent':this['agent'],'project_dir':process[_0x41acfc(0x18a)](),..._0x545447});}async[a0_0x584588(0x1be)](){const _0xe3d9a3=a0_0x584588;return this[_0xe3d9a3(0x1c3)](_0xe3d9a3(0x1b7),{});}async[a0_0x584588(0x1ce)](_0x247e4a,_0x6f6744){const _0x119147=a0_0x584588;return this[_0x119147(0x1c3)](_0x119147(0x1ce),{'message':_0x247e4a,'filter_server':_0x6f6744?.['server'],'filter_status':_0x6f6744?.[_0x119147(0x191)]});}async['connectSSE'](){const _0x5d2f31=a0_0x584588;let _0x1924f7=encodeURIComponent(this['alias']),_0x345c6a=this[_0x5d2f31(0x1bc)]+'/events/'+_0x1924f7,_0x48f699=this['reconnectDelay'];while(this[_0x5d2f31(0x192)]){try{this[_0x5d2f31(0x197)]=new AbortController();let _0x500685={'Accept':'text/event-stream'};if(this[_0x5d2f31(0x199)])_0x500685[_0x5d2f31(0x19b)]=_0x5d2f31(0x1ac)+this[_0x5d2f31(0x199)];let _0x382888=await fetch(_0x345c6a,{'headers':_0x500685,'signal':this[_0x5d2f31(0x197)][_0x5d2f31(0x1a9)]});if(!_0x382888['ok']||!_0x382888[_0x5d2f31(0x18b)]){this['log'](_0x5d2f31(0x1a1)+_0x382888['status']),await this[_0x5d2f31(0x1d0)](_0x48f699),_0x48f699=Math[_0x5d2f31(0x1c1)](_0x48f699*1.5,0xea60);continue;}_0x48f699=this[_0x5d2f31(0x1b4)];let _0x634af9=_0x382888[_0x5d2f31(0x18b)][_0x5d2f31(0x1dd)](),_0x130a28=new TextDecoder(),_0x258f37='';while(this[_0x5d2f31(0x192)]){let {done:_0x5adda0,value:_0x4e2eaa}=await _0x634af9[_0x5d2f31(0x1bf)]();if(_0x5adda0)break;_0x258f37+=_0x130a28['decode'](_0x4e2eaa,{'stream':!0x0});let _0x432cfc=_0x258f37[_0x5d2f31(0x18d)]('\x0a');_0x258f37=_0x432cfc[_0x5d2f31(0x1b6)]()||'';for(let _0x3357a7 of _0x432cfc){if(!_0x3357a7[_0x5d2f31(0x1d1)]('data:\x20'))continue;try{let _0x38769f=JSON[_0x5d2f31(0x1ad)](_0x3357a7['slice'](0x6));if(_0x38769f[_0x5d2f31(0x1bb)]===_0x5d2f31(0x195)){this[_0x5d2f31(0x1a0)](_0x5d2f31(0x1c6)),this[_0x5d2f31(0x18e)](_0x5d2f31(0x195));continue;}if(_0x38769f[_0x5d2f31(0x1bb)]===_0x5d2f31(0x1cb)||_0x38769f[_0x5d2f31(0x1bb)]==='new_message'||_0x38769f['type']===_0x5d2f31(0x1ce))await this[_0x5d2f31(0x1af)]();}catch{}}}}catch(_0x35802b){if(_0x35802b[_0x5d2f31(0x198)]===_0x5d2f31(0x194))break;this[_0x5d2f31(0x18e)](_0x5d2f31(0x1d3),_0x35802b),this[_0x5d2f31(0x1a0)](_0x5d2f31(0x1df)+_0x35802b[_0x5d2f31(0x1c9)]);}if(this[_0x5d2f31(0x192)])this[_0x5d2f31(0x18e)](_0x5d2f31(0x1d4)),this['log']('SSE\x20reconnecting\x20in\x20'+_0x48f699/0x3e8+_0x5d2f31(0x1a8)),await this[_0x5d2f31(0x1d0)](_0x48f699),_0x48f699=Math[_0x5d2f31(0x1c1)](_0x48f699*1.5,0xea60);}}async[a0_0x584588(0x1af)](){const _0x326db9=a0_0x584588;try{let _0x414e84=(await this[_0x326db9(0x1c3)](_0x326db9(0x19a),{'alias':this[_0x326db9(0x1bd)],'limit':0xa}))?.[_0x326db9(0x1cf)]||[];for(let _0x724e89 of _0x414e84)await this[_0x326db9(0x1c3)]('ack_inbox',{'alias':this[_0x326db9(0x1bd)],'message_id':_0x724e89['id']}),this[_0x326db9(0x1a0)]('←\x20'+_0x724e89[_0x326db9(0x1de)]+':\x20'+_0x724e89['content'][_0x326db9(0x1a4)](0x0,0x3c)),this[_0x326db9(0x18e)](_0x326db9(0x1a6),_0x724e89),this[_0x326db9(0x18e)]('message',_0x724e89);}catch(_0x1b2c99){this['log']('inbox\x20error:\x20'+_0x1b2c99[_0x326db9(0x1c9)]);}}[a0_0x584588(0x1d0)](_0x408406){return new Promise(_0x4a6959=>setTimeout(_0x4a6959,_0x408406));}}var $=T;export{$ as default,T as CommHub};
1
+ function a0_0x4f19(){const _0x5a6dcb=['application/json','connectSSE','decode','read','log','/events/','body','reconnectDelay','262140CBQLUM','Bearer\x20','disconnect','sseAbort','send','cwd','catch','12uxnSYV','processInbox','alias','AbortError','SSE\x20connected','completed','replace','sdk','resumeId','sleep','403501GfacLk','normal','Authorization','offline','broadcast','text','inbox\x20error:\x20','10orNsrj','stringify','getAllStatus','get_all_status','now','heartbeat\x20failed:\x20','sdk-','24FFcltX','new_message','parse','status','64YtuUez','send_message','518526MHNjPf','new_task','message','content','abort','s...','SSE\x20error:\x20','emit','registered','connect','call','min','running','3865301GoHtDO','720665nUClcS','538082BmFQUG','match','startsWith','agent','heartbeatTimer','url','get_inbox','/mcp','signal','disconnected','1eEFAaA','server','heartbeatInterval',']\x20[commhub:','178281dUENib','pop','from_session','type','idle','token','send_reply'];a0_0x4f19=function(){return _0x5a6dcb;};return a0_0x4f19();}const a0_0xa31648=a0_0x2e57;function a0_0x2e57(_0x2c4bee,_0x5b6e6d){_0x2c4bee=_0x2c4bee-0x1ae;const _0x4f19e2=a0_0x4f19();let _0x2e576f=_0x4f19e2[_0x2c4bee];return _0x2e576f;}(function(_0x20cc7e,_0xe856f3){const _0xba5a32=a0_0x2e57,_0x1b1886=_0x20cc7e();while(!![]){try{const _0x48ea6f=parseInt(_0xba5a32(0x1b8))/0x1*(-parseInt(_0xba5a32(0x1ae))/0x2)+parseInt(_0xba5a32(0x1bc))/0x3+parseInt(_0xba5a32(0x1cb))/0x4+-parseInt(_0xba5a32(0x1fe))/0x5*(-parseInt(_0xba5a32(0x1ea))/0x6)+-parseInt(_0xba5a32(0x1dc))/0x7*(-parseInt(_0xba5a32(0x1ee))/0x8)+parseInt(_0xba5a32(0x1f0))/0x9*(-parseInt(_0xba5a32(0x1e3))/0xa)+-parseInt(_0xba5a32(0x1fd))/0xb*(parseInt(_0xba5a32(0x1d2))/0xc);if(_0x48ea6f===_0xe856f3)break;else _0x1b1886['push'](_0x1b1886['shift']());}catch(_0x7c699c){_0x1b1886['push'](_0x1b1886['shift']());}}}(a0_0x4f19,0x764f0));import{EventEmitter as a0_0x2263f9}from'events';import{hostname as a0_0x4bf9e4}from'os';class T extends a0_0x2263f9{[a0_0xa31648(0x1b3)];['alias'];[a0_0xa31648(0x1c1)];[a0_0xa31648(0x1b1)];[a0_0xa31648(0x1da)];[a0_0xa31648(0x1ba)];[a0_0xa31648(0x1ca)];[a0_0xa31648(0x1b2)];[a0_0xa31648(0x1ce)];[a0_0xa31648(0x1fc)]=!0x1;constructor(_0x2a1d7e){const _0x247c71=a0_0xa31648;super();if(this[_0x247c71(0x1b3)]=_0x2a1d7e[_0x247c71(0x1b3)][_0x247c71(0x1d8)](/\/$/,''),this['alias']=_0x2a1d7e[_0x247c71(0x1d4)],this['token']=_0x2a1d7e[_0x247c71(0x1c1)],this['agent']=_0x2a1d7e[_0x247c71(0x1b1)]||_0x247c71(0x1d9),this[_0x247c71(0x1da)]=_0x247c71(0x1e9)+_0x2a1d7e['alias']+'-'+Date[_0x247c71(0x1e7)]()['toString'](0x24),this[_0x247c71(0x1ba)]=_0x2a1d7e[_0x247c71(0x1ba)]??0x2bf20,this[_0x247c71(0x1ca)]=_0x2a1d7e[_0x247c71(0x1ca)]??0xbb8,_0x2a1d7e['autoConnect']!==!0x1)this['connect']();}[a0_0xa31648(0x1c7)](_0x73709f){const _0x2a5064=a0_0xa31648;console[_0x2a5064(0x1c7)]('['+new Date()['toTimeString']()['slice'](0x0,0x8)+_0x2a5064(0x1bb)+this[_0x2a5064(0x1d4)]+']\x20'+_0x73709f);}async[a0_0xa31648(0x1fa)](_0x20f7af,_0xc0c097){const _0x437b33=a0_0xa31648;let _0x8994a1={'Content-Type':_0x437b33(0x1c3),'Accept':'application/json,\x20text/event-stream'};if(this['token'])_0x8994a1[_0x437b33(0x1de)]=_0x437b33(0x1cc)+this[_0x437b33(0x1c1)];let _0x2683ea=await(await fetch(this[_0x437b33(0x1b3)]+_0x437b33(0x1b5),{'method':'POST','headers':_0x8994a1,'body':JSON[_0x437b33(0x1e4)]({'jsonrpc':'2.0','id':Date['now'](),'method':'tools/call','params':{'name':_0x20f7af,'arguments':_0xc0c097}})}))[_0x437b33(0x1e1)](),_0x327231=_0x2683ea[_0x437b33(0x1af)](/data: (.+)/),_0x2a2aab=_0x327231?JSON[_0x437b33(0x1ec)](_0x327231[0x1]):JSON[_0x437b33(0x1ec)](_0x2683ea),_0x34602b=_0x2a2aab?.['result']?.[_0x437b33(0x1f3)]?.[0x0]?.[_0x437b33(0x1e1)];return _0x34602b?JSON['parse'](_0x34602b):_0x2a2aab;}async[a0_0xa31648(0x1f9)](){const _0xf84058=a0_0xa31648;if(this[_0xf84058(0x1fc)])return;this['running']=!0x0,await this[_0xf84058(0x1ed)](_0xf84058(0x1c0)),this[_0xf84058(0x1c7)](_0xf84058(0x1f8)),this[_0xf84058(0x1b2)]=setInterval(()=>{const _0x26622f=_0xf84058;this[_0x26622f(0x1ed)](_0x26622f(0x1c0))[_0x26622f(0x1d1)](_0x12cec9=>this['log'](_0x26622f(0x1e8)+_0x12cec9[_0x26622f(0x1f2)]));},this[_0xf84058(0x1ba)]),this[_0xf84058(0x1c4)]();}async[a0_0xa31648(0x1cd)](){const _0x6209a=a0_0xa31648;if(this[_0x6209a(0x1fc)]=!0x1,this[_0x6209a(0x1ce)]?.[_0x6209a(0x1f4)](),this['heartbeatTimer'])clearInterval(this['heartbeatTimer']);await this[_0x6209a(0x1ed)](_0x6209a(0x1df))['catch'](()=>{}),this[_0x6209a(0x1c7)]('disconnected');}async[a0_0xa31648(0x1cf)](_0x3d4331,_0x3d2f20,_0x5128bd=a0_0xa31648(0x1dd)){const _0x48f790=a0_0xa31648;return this[_0x48f790(0x1fa)]('send_task',{'alias':_0x3d4331,'task':_0x3d2f20,'priority':_0x5128bd,'from_session':this[_0x48f790(0x1d4)]});}async[a0_0xa31648(0x1f2)](_0x5f49d2,_0x119145){const _0x429da4=a0_0xa31648;return this[_0x429da4(0x1fa)](_0x429da4(0x1ef),{'alias':_0x5f49d2,'message':_0x119145,'from_session':this[_0x429da4(0x1d4)]});}async['reply'](_0x5a6ca9,_0x52d1f5,_0x134d6a=a0_0xa31648(0x1d7)){const _0x3307e5=a0_0xa31648;return this[_0x3307e5(0x1fa)](_0x3307e5(0x1c2),{'in_reply_to':_0x5a6ca9,'text':_0x52d1f5,'status':_0x134d6a});}async[a0_0xa31648(0x1ed)](_0x4168dd,_0x559bfd){const _0x3df185=a0_0xa31648;return this[_0x3df185(0x1fa)]('report_status',{'resume_id':this[_0x3df185(0x1da)],'alias':this[_0x3df185(0x1d4)],'status':_0x4168dd,'server':a0_0x4bf9e4(),'hostname':a0_0x4bf9e4(),'agent':this[_0x3df185(0x1b1)],'project_dir':process[_0x3df185(0x1d0)](),..._0x559bfd});}async[a0_0xa31648(0x1e5)](){const _0x4910a7=a0_0xa31648;return this[_0x4910a7(0x1fa)](_0x4910a7(0x1e6),{});}async[a0_0xa31648(0x1e0)](_0x37afe9,_0x494be3){const _0x108a75=a0_0xa31648;return this[_0x108a75(0x1fa)](_0x108a75(0x1e0),{'message':_0x37afe9,'filter_server':_0x494be3?.[_0x108a75(0x1b9)],'filter_status':_0x494be3?.['status']});}async[a0_0xa31648(0x1c4)](){const _0x32ac7b=a0_0xa31648;let _0x21eb98=encodeURIComponent(this['alias']),_0x116f63=this[_0x32ac7b(0x1b3)]+_0x32ac7b(0x1c8)+_0x21eb98,_0x2a045e=this['reconnectDelay'];while(this['running']){try{this[_0x32ac7b(0x1ce)]=new AbortController();let _0xae401b={'Accept':'text/event-stream'};if(this[_0x32ac7b(0x1c1)])_0xae401b[_0x32ac7b(0x1de)]=_0x32ac7b(0x1cc)+this['token'];let _0x451744=await fetch(_0x116f63,{'headers':_0xae401b,'signal':this[_0x32ac7b(0x1ce)][_0x32ac7b(0x1b6)]});if(!_0x451744['ok']||!_0x451744[_0x32ac7b(0x1c9)]){this[_0x32ac7b(0x1c7)]('SSE\x20failed:\x20'+_0x451744['status']),await this[_0x32ac7b(0x1db)](_0x2a045e),_0x2a045e=Math['min'](_0x2a045e*1.5,0xea60);continue;}_0x2a045e=this[_0x32ac7b(0x1ca)];let _0x22d517=_0x451744[_0x32ac7b(0x1c9)]['getReader'](),_0x2db235=new TextDecoder(),_0xc8ff84='';while(this['running']){let {done:_0x4a1de3,value:_0x171f64}=await _0x22d517[_0x32ac7b(0x1c6)]();if(_0x4a1de3)break;_0xc8ff84+=_0x2db235[_0x32ac7b(0x1c5)](_0x171f64,{'stream':!0x0});let _0x4b73a1=_0xc8ff84['split']('\x0a');_0xc8ff84=_0x4b73a1[_0x32ac7b(0x1bd)]()||'';for(let _0x57862d of _0x4b73a1){if(!_0x57862d[_0x32ac7b(0x1b0)]('data:\x20'))continue;try{let _0x4a4c99=JSON[_0x32ac7b(0x1ec)](_0x57862d['slice'](0x6));if(_0x4a4c99[_0x32ac7b(0x1bf)]==='connected'){this[_0x32ac7b(0x1c7)](_0x32ac7b(0x1d6)),this[_0x32ac7b(0x1f7)]('connected');continue;}if(_0x4a4c99[_0x32ac7b(0x1bf)]===_0x32ac7b(0x1f1)||_0x4a4c99[_0x32ac7b(0x1bf)]===_0x32ac7b(0x1eb)||_0x4a4c99[_0x32ac7b(0x1bf)]===_0x32ac7b(0x1e0))await this[_0x32ac7b(0x1d3)]();}catch{}}}}catch(_0x2c412a){if(_0x2c412a['name']===_0x32ac7b(0x1d5))break;this[_0x32ac7b(0x1f7)]('error',_0x2c412a),this[_0x32ac7b(0x1c7)](_0x32ac7b(0x1f6)+_0x2c412a['message']);}if(this[_0x32ac7b(0x1fc)])this[_0x32ac7b(0x1f7)](_0x32ac7b(0x1b7)),this[_0x32ac7b(0x1c7)]('SSE\x20reconnecting\x20in\x20'+_0x2a045e/0x3e8+_0x32ac7b(0x1f5)),await this[_0x32ac7b(0x1db)](_0x2a045e),_0x2a045e=Math[_0x32ac7b(0x1fb)](_0x2a045e*1.5,0xea60);}}async[a0_0xa31648(0x1d3)](){const _0x178b41=a0_0xa31648;try{let _0x54dab3=(await this[_0x178b41(0x1fa)](_0x178b41(0x1b4),{'alias':this[_0x178b41(0x1d4)],'limit':0xa}))?.['messages']||[];for(let _0x363391 of _0x54dab3)await this[_0x178b41(0x1fa)]('ack_inbox',{'alias':this[_0x178b41(0x1d4)],'message_id':_0x363391['id']}),this[_0x178b41(0x1c7)]('←\x20'+_0x363391[_0x178b41(0x1be)]+':\x20'+_0x363391[_0x178b41(0x1f3)]['slice'](0x0,0x3c)),this[_0x178b41(0x1f7)]('task',_0x363391),this[_0x178b41(0x1f7)]('message',_0x363391);}catch(_0x49181c){this[_0x178b41(0x1c7)](_0x178b41(0x1e2)+_0x49181c[_0x178b41(0x1f2)]);}}[a0_0xa31648(0x1db)](_0x51fd6f){return new Promise(_0x4fa607=>setTimeout(_0x4fa607,_0x51fd6f));}}var $=T;export{$ as default,T as CommHub};
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env bun
2
- const a0_0x19b54f=a0_0x83a7;(function(_0x8b9378,_0x46ce2d){const _0x479a20=a0_0x83a7,_0x19ac74=_0x8b9378();while(!![]){try{const _0x1fa3f0=parseInt(_0x479a20(0x1b5))/0x1+-parseInt(_0x479a20(0x1d9))/0x2*(-parseInt(_0x479a20(0x205))/0x3)+parseInt(_0x479a20(0x226))/0x4*(parseInt(_0x479a20(0x1fe))/0x5)+-parseInt(_0x479a20(0x218))/0x6*(parseInt(_0x479a20(0x1af))/0x7)+parseInt(_0x479a20(0x1e4))/0x8+-parseInt(_0x479a20(0x1cf))/0x9+-parseInt(_0x479a20(0x1ca))/0xa*(-parseInt(_0x479a20(0x1f5))/0xb);if(_0x1fa3f0===_0x46ce2d)break;else _0x19ac74['push'](_0x19ac74['shift']());}catch(_0x12be8a){_0x19ac74['push'](_0x19ac74['shift']());}}}(a0_0x53d4,0xa0417));import{readFileSync as a0_0x3c6e43,existsSync as a0_0x29d297}from'fs';import{randomUUID as a0_0x29680f}from'crypto';import{join as a0_0x22cf0c}from'path';import{hostname as a0_0x1025a0}from'os';import{execSync as a0_0x50203b}from'child_process';import{Server as a0_0x43a465}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport as a0_0x32fca4}from'@modelcontextprotocol/sdk/server/stdio.js';import{ListToolsRequestSchema as a0_0xcdfeef,CallToolRequestSchema as a0_0x3e6b8a}from'@modelcontextprotocol/sdk/types.js';function I(_0x23aabb){const _0x5b89bd=a0_0x83a7;if(!a0_0x29d297(_0x23aabb))return;for(let _0x552a6d of a0_0x3c6e43(_0x23aabb,_0x5b89bd(0x19c))[_0x5b89bd(0x1a5)]('\x0a')){let _0x4bbb95=_0x552a6d[_0x5b89bd(0x211)]();if(!_0x4bbb95||_0x4bbb95[_0x5b89bd(0x1f1)]('#'))continue;let _0x43791c=_0x4bbb95[_0x5b89bd(0x1be)]('=');if(_0x43791c<0x0)continue;let _0x291c5b=_0x4bbb95[_0x5b89bd(0x200)](0x0,_0x43791c)[_0x5b89bd(0x211)](),_0xca4710=_0x4bbb95[_0x5b89bd(0x200)](_0x43791c+0x1)[_0x5b89bd(0x211)]()['replace'](/^["']|["']$/g,'');if(!process.env[_0x291c5b])process.env[_0x291c5b]=_0xca4710;}}var L=process.env.HOME||'~',U=a0_0x22cf0c(L,'.claude/channels/commhub');I(a0_0x22cf0c(U,a0_0x19b54f(0x1dd)));function a0_0x53d4(){const _0x5d9286=['7680996HNThck','stdin','.\x20Restart\x20node\x20via\x20`anet\x20node\x20start\x20<alias>`\x20so\x20the\x20env\x20is\x20set\x20explicitly\x20(#203).\x0a','Current\x20task\x20description','Priority\x20(default:\x20normal)','new_task','error','0.3.0','commhub','replied','4qbRRER','pop','blocked','\x20/\x20hostname=','.env','alias','ENV:\x20URL=','2.0','Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.','heartbeat\x20failed:\x20','/mcp','6610376JiYppH','These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.','initialize','unknown\x20tool','idle','end','catch','inbox_count','type','SIGTERM','\x22\x20after\x20SSE\x20reconnect','\x20from\x20',')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。','startsWith','application/json,\x20text/event-stream','now','length','11iahRwD','messages','Messages\x20from\x20CommHub\x20arrive\x20as\x20<channel\x20source=\x22commhub\x22\x20task_id=\x22...\x22\x20priority=\x22...\x22\x20from=\x22...\x22>','Message\x20content','Task\x20content','ack_inbox','POST','high','cancelled','1880PikKdQ','Reply\x20to\x20a\x20CommHub\x20task\x20—\x20report\x20completion\x20or\x20send\x20a\x20message\x20back\x20to\x20the\x20hub.','slice','in_progress','report_status','http://127.0.0.1:9200','token','159207JgsnFc','claude-code','The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)','parse','read','\x20RESUME_ID=','get_all_status','starting\x20SSE\x20listener...','cwd','result','notifications/claude/channel','send_reply','trim','would\x20mis-attribute.\x20Refusing\x20to\x20guess\x20from\x20TMUX_NAME=','\x22\x20(','data:\x20','commhub_report_status','application/json','object','35118EMhKVE','Reply\x20using\x20the\x20commhub_reply\x20tool\x20to\x20report\x20status\x20or\x20results\x20back.','\x20CWD=','stringify',']\x20[commhub]\x20','Progress\x200-100','SSE\x20连续\x20>1h\x20连不上\x20hub\x20(','params','exit','Update\x20this\x20session\x27s\x20status\x20in\x20CommHub\x20(working/idle/blocked/error).\x20Returns\x20inbox_count.','statusText','setRequestHandler','task','completed','9796GZDmFw','from_session','warning:\x20could\x20not\x20register:\x20','SSE\x20stream\x20ended,\x20reconnecting...','notification','getReader','session\x20disconnected','message_id','normal','toTimeString','offline','Authorization','→\x20injected\x20task\x20','commhub-channel','send_message','Reply\x20text\x20/\x20result\x20summary','write','utf-8','←\x20message\x20from\x20','Target\x20session\x20alias','delete','broadcast','commhub_send_message','string','find','hub','split','stderr','status','connected','new_message','...\x20TMUX=','tools/call','get','init\x20failed:\x20','text','1309BenFSz','config.json','commhub_send_task','re-register\x20failed:\x20','SIGINT','parse\x20error:\x20','580914DoFwnd','content','/events/','commhub_get_all_status','pid','SSE\x20fatal:\x20',':\x20inbox_count=','message','SSE\x20connected\x20as\x20\x22','indexOf','set','commhub_reply','[commhub]\x20WARN:\x20COMMHUB_ALIAS\x20env\x20var\x20is\x20unset\x20—\x20outbound\x20from_session\x20','body','MCP\x20stdio\x20connected','re-registered\x20as\x20\x22','priority','replace','working','send_task','failed','1701890Sjgwcc','min','none','Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','ready\x20—\x20waiting\x20for\x20events'];a0_0x53d4=function(){return _0x5d9286;};return a0_0x53d4();}var v=process[a0_0x19b54f(0x20d)]()[a0_0x19b54f(0x1c6)](/\//g,'-');I(a0_0x22cf0c(U,v,'.env'));function d(){const _0x5adaa7=a0_0x19b54f;try{return a0_0x50203b('tmux\x20display-message\x20-p\x20\x27#S\x27',{'encoding':_0x5adaa7(0x19c),'timeout':0x7d0})[_0x5adaa7(0x211)]();}catch{return'';}}function m(){const _0x3f6c47=a0_0x19b54f;try{let _0x216a5d=a0_0x22cf0c(L,'.anet',_0x3f6c47(0x1b0));if(a0_0x29d297(_0x216a5d))return JSON[_0x3f6c47(0x208)](a0_0x3c6e43(_0x216a5d,_0x3f6c47(0x19c)));}catch{}return{};}var u=m(),j=process.env.COMMHUB_URL||u[a0_0x19b54f(0x1a4)]||a0_0x19b54f(0x203),f=process.env.COMMHUB_TMUX||d();function r(){const _0x5c2e74=a0_0x19b54f;if(process.env.COMMHUB_ALIAS&&process.env.COMMHUB_ALIAS[_0x5c2e74(0x211)]())return process.env.COMMHUB_ALIAS[_0x5c2e74(0x211)]();return process[_0x5c2e74(0x1a6)]['write'](_0x5c2e74(0x1c1)+(_0x5c2e74(0x212)+(f||'(none)')+_0x5c2e74(0x1dc)+a0_0x1025a0()+_0x5c2e74(0x1d1))),'unattributed-'+process[_0x5c2e74(0x1b9)];}var G=r(),K=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||a0_0x29680f(),F=process.env.COMMHUB_TOKEN||u[a0_0x19b54f(0x204)]||'';function W(_0x37cc67){const _0x8c0324=a0_0x19b54f;let _0x421f4e=new Date()[_0x8c0324(0x22f)]()[_0x8c0324(0x200)](0x0,0x8);process[_0x8c0324(0x1a6)][_0x8c0324(0x19b)]('['+_0x421f4e+_0x8c0324(0x21c)+_0x37cc67+'\x0a');}function N(_0x3ed8ce){return new Promise(_0xb1afa4=>setTimeout(_0xb1afa4,_0x3ed8ce));}W(a0_0x19b54f(0x1df)+j+'\x20ALIAS='+G+a0_0x19b54f(0x20a)+K[a0_0x19b54f(0x200)](0x0,0x8)+a0_0x19b54f(0x1aa)+(f||a0_0x19b54f(0x1cc))+a0_0x19b54f(0x21a)+process[a0_0x19b54f(0x20d)]()+'\x20PROJECT_ENV='+v);var D=new Map(),x=new a0_0x43a465({'name':a0_0x19b54f(0x198),'version':a0_0x19b54f(0x1d6)},{'capabilities':{'experimental':{'claude/channel':{}},'tools':{}},'instructions':[a0_0x19b54f(0x1f7),a0_0x19b54f(0x1e5),a0_0x19b54f(0x219),'You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.','Session\x20alias:\x20'+G]['join']('\x0a')});function a0_0x83a7(_0x19fbbf,_0x563c80){_0x19fbbf=_0x19fbbf-0x197;const _0x53d4fb=a0_0x53d4();let _0x83a7e9=_0x53d4fb[_0x19fbbf];return _0x83a7e9;}x[a0_0x19b54f(0x223)](a0_0xcdfeef,async()=>({'tools':[{'name':a0_0x19b54f(0x1c0),'description':a0_0x19b54f(0x1ff),'inputSchema':{'type':'object','properties':{'task_id':{'type':a0_0x19b54f(0x1a2),'description':a0_0x19b54f(0x207)},'text':{'type':'string','description':a0_0x19b54f(0x19a)},'status':{'type':'string','enum':[a0_0x19b54f(0x225),a0_0x19b54f(0x1c9),a0_0x19b54f(0x1fd),a0_0x19b54f(0x1db),'error',a0_0x19b54f(0x201)],'description':'Task\x20outcome:\x20completed/failed/cancelled\x20for\x20final\x20results,\x20blocked/error/in_progress\x20for\x20status\x20updates'}},'required':[a0_0x19b54f(0x1ae)]}},{'name':a0_0x19b54f(0x215),'description':a0_0x19b54f(0x221),'inputSchema':{'type':a0_0x19b54f(0x217),'properties':{'status':{'type':a0_0x19b54f(0x1a2),'enum':[a0_0x19b54f(0x1c7),a0_0x19b54f(0x1e8),a0_0x19b54f(0x1db),a0_0x19b54f(0x1d5)]},'task':{'type':a0_0x19b54f(0x1a2),'description':a0_0x19b54f(0x1d2)},'progress':{'type':'number','description':a0_0x19b54f(0x21d)}},'required':[a0_0x19b54f(0x1a7)]}},{'name':'commhub_send_task','description':'Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.','inputSchema':{'type':a0_0x19b54f(0x217),'properties':{'alias':{'type':'string','description':a0_0x19b54f(0x19e)},'task':{'type':a0_0x19b54f(0x1a2),'description':a0_0x19b54f(0x1f9)},'priority':{'type':a0_0x19b54f(0x1a2),'enum':[a0_0x19b54f(0x1fc),a0_0x19b54f(0x22e),'low'],'description':a0_0x19b54f(0x1d3)}},'required':[a0_0x19b54f(0x1de),a0_0x19b54f(0x224)]}},{'name':a0_0x19b54f(0x1a1),'description':a0_0x19b54f(0x1e1),'inputSchema':{'type':a0_0x19b54f(0x217),'properties':{'alias':{'type':a0_0x19b54f(0x1a2),'description':a0_0x19b54f(0x19e)},'message':{'type':a0_0x19b54f(0x1a2),'description':a0_0x19b54f(0x1f8)}},'required':['alias',a0_0x19b54f(0x1bc)]}},{'name':a0_0x19b54f(0x1b8),'description':a0_0x19b54f(0x1cd),'inputSchema':{'type':'object','properties':{}}}]}));async function Y(_0x53ba17,_0x5cffd2){const _0x1ee7b2=a0_0x19b54f;let _0x4fae4a=await fetch(j+_0x1ee7b2(0x1e3),{'method':'POST','headers':{'Content-Type':'application/json','Accept':_0x1ee7b2(0x1f2),...F?{'Authorization':'Bearer\x20'+F}:{}},'body':JSON['stringify']({'jsonrpc':_0x1ee7b2(0x1e0),'id':0x1,'method':_0x1ee7b2(0x1e6),'params':{'protocolVersion':'2025-03-26','capabilities':{},'clientInfo':{'name':_0x1ee7b2(0x198),'version':'0.3.0'}}})});if(!_0x4fae4a['ok']){let _0x435bd4=await _0x4fae4a[_0x1ee7b2(0x1ae)]();return W('CommHub\x20init\x20failed:\x20'+_0x4fae4a[_0x1ee7b2(0x1a7)]+'\x20'+_0x435bd4['slice'](0x0,0x64)),{'ok':!0x1,'error':_0x1ee7b2(0x1ad)+_0x4fae4a[_0x1ee7b2(0x1a7)]};}await _0x4fae4a[_0x1ee7b2(0x1ae)]();let _0xc6044e=(await(await fetch(j+_0x1ee7b2(0x1e3),{'method':_0x1ee7b2(0x1fb),'headers':{'Content-Type':_0x1ee7b2(0x216),'Accept':_0x1ee7b2(0x1f2),...F?{'Authorization':'Bearer\x20'+F}:{}},'body':JSON[_0x1ee7b2(0x21b)]({'jsonrpc':_0x1ee7b2(0x1e0),'id':0x2,'method':_0x1ee7b2(0x1ab),'params':{'name':_0x53ba17,'arguments':_0x5cffd2}})}))[_0x1ee7b2(0x1ae)]())[_0x1ee7b2(0x1a5)]('\x0a')[_0x1ee7b2(0x1a3)](_0xd633f8=>_0xd633f8[_0x1ee7b2(0x1f1)](_0x1ee7b2(0x214)));if(_0xc6044e){let _0x2faf4f=JSON['parse'](_0xc6044e[_0x1ee7b2(0x200)](0x6));return _0x2faf4f?.[_0x1ee7b2(0x20e)]?.[_0x1ee7b2(0x1b6)]?.[0x0]?.['text']?JSON['parse'](_0x2faf4f['result'][_0x1ee7b2(0x1b6)][0x0][_0x1ee7b2(0x1ae)]):_0x2faf4f;}return{'ok':!0x1,'error':'no\x20response'};}x[a0_0x19b54f(0x223)](a0_0x3e6b8a,async _0x59d741=>{const _0x284708=a0_0x19b54f;let {name:_0x14134d,arguments:_0x25d865}=_0x59d741[_0x284708(0x21f)];if(_0x14134d===_0x284708(0x1c0)){let {task_id:_0x2d40e9,text:_0x4c9a2c,status:_0x10b435}=_0x25d865;if(_0x10b435==='completed'||_0x10b435===_0x284708(0x1c9)||_0x10b435===_0x284708(0x1fd)){let _0x10840c=_0x10b435===_0x284708(0x225)?_0x284708(0x1d8):_0x10b435,_0x20da8c=_0x2d40e9?D[_0x284708(0x1ac)](_0x2d40e9)||_0x284708(0x1a4):_0x284708(0x1a4),_0x1f23eb=await Y(_0x284708(0x210),{'alias':_0x20da8c,'text':_0x4c9a2c,'in_reply_to':_0x2d40e9||void 0x0,'status':_0x10840c,'from_session':G});if(_0x2d40e9)D[_0x284708(0x19f)](_0x2d40e9);return{'content':[{'type':_0x284708(0x1ae),'text':JSON[_0x284708(0x21b)](_0x1f23eb)}]};}let _0x3df172=await Y(_0x284708(0x202),{'resume_id':K,'alias':G,'status':_0x10b435===_0x284708(0x1db)?'blocked':_0x10b435===_0x284708(0x1d5)?'error':_0x284708(0x1c7),'task':_0x4c9a2c[_0x284708(0x200)](0x0,0xc8),'output':_0x4c9a2c});return{'content':[{'type':_0x284708(0x1ae),'text':JSON[_0x284708(0x21b)](_0x3df172)}]};}if(_0x14134d===_0x284708(0x215)){let {status:_0x330773,task:_0x3b84b3,progress:_0x36686b}=_0x25d865,_0x2efd8e=await Y(_0x284708(0x202),{'resume_id':K,'alias':G,'status':_0x330773,'task':_0x3b84b3,'progress':_0x36686b});return{'content':[{'type':_0x284708(0x1ae),'text':JSON[_0x284708(0x21b)](_0x2efd8e)}]};}if(_0x14134d===_0x284708(0x1b1)){let {alias:_0x47cc7a,task:_0xf23985,priority:_0x227138}=_0x25d865,_0x1338bb=await Y(_0x284708(0x1c8),{'alias':_0x47cc7a,'task':_0xf23985,'priority':_0x227138||'normal','from_session':G});return{'content':[{'type':_0x284708(0x1ae),'text':JSON[_0x284708(0x21b)](_0x1338bb)}]};}if(_0x14134d===_0x284708(0x1a1)){let {alias:_0x13cba5,message:_0x5b07b0}=_0x25d865,_0x5c12cf=await Y(_0x284708(0x199),{'alias':_0x13cba5,'message':_0x5b07b0,'from_session':G});return{'content':[{'type':_0x284708(0x1ae),'text':JSON[_0x284708(0x21b)](_0x5c12cf)}]};}if(_0x14134d===_0x284708(0x1b8)){let _0x237746=await Y(_0x284708(0x20b),{});return{'content':[{'type':_0x284708(0x1ae),'text':JSON[_0x284708(0x21b)](_0x237746)}]};}return{'content':[{'type':_0x284708(0x1ae),'text':JSON[_0x284708(0x21b)]({'error':_0x284708(0x1e7)})}]};});var O=0x3e8,R=0x7530,T=0x36ee80;async function l(){const _0x35bd31=a0_0x19b54f;try{await Y('report_status',{'resume_id':K,'alias':G,'status':_0x35bd31(0x1e8),'server':a0_0x1025a0(),'hostname':a0_0x1025a0(),'agent':_0x35bd31(0x206),'project_dir':process[_0x35bd31(0x20d)](),'tmux_name':f||void 0x0}),W(_0x35bd31(0x1c4)+G+_0x35bd31(0x1ee));}catch(_0x23fd28){W(_0x35bd31(0x1b2)+_0x23fd28);}}async function o(){const _0x527db5=a0_0x19b54f;let _0x1f5750=j+_0x527db5(0x1b7)+encodeURIComponent(G),_0x35a62d={};if(F)_0x35a62d[_0x527db5(0x231)]='Bearer\x20'+F;W('connecting\x20to\x20'+_0x1f5750);let _0x3b0876=O,_0x5f519a=!0x0,_0x4ff48e=null;while(!0x0){try{let _0x2bf192=await fetch(_0x1f5750,{'headers':_0x35a62d});if(!_0x2bf192['ok']){if(W('SSE\x20error:\x20'+_0x2bf192[_0x527db5(0x1a7)]+'\x20'+_0x2bf192[_0x527db5(0x222)]),_0x4ff48e=_0x4ff48e??Date[_0x527db5(0x1f3)](),Date[_0x527db5(0x1f3)]()-_0x4ff48e>T){W(_0x527db5(0x21e)+j+_0x527db5(0x1f0));return;}await N(_0x3b0876),_0x3b0876=Math[_0x527db5(0x1cb)](_0x3b0876*0x2,R);continue;}let _0x2ea475=_0x2bf192[_0x527db5(0x1c2)][_0x527db5(0x22b)](),_0x5bcf54=new TextDecoder(),_0xb310b8='';_0x3b0876=O;while(!0x0){let {done:_0x67c80a,value:_0xcbbdc9}=await _0x2ea475[_0x527db5(0x209)]();if(_0x67c80a)break;_0xb310b8+=_0x5bcf54['decode'](_0xcbbdc9,{'stream':!0x0});let _0x20b36c=_0xb310b8[_0x527db5(0x1a5)]('\x0a\x0a');_0xb310b8=_0x20b36c[_0x527db5(0x1da)]()||'';for(let _0x289dd7 of _0x20b36c){let _0x4a7cc9=_0x289dd7[_0x527db5(0x1a5)]('\x0a')[_0x527db5(0x1a3)](_0xaf13bd=>_0xaf13bd[_0x527db5(0x1f1)]('data:\x20'));if(!_0x4a7cc9)continue;try{let _0x287750=JSON['parse'](_0x4a7cc9[_0x527db5(0x200)](0x6));if(await a(_0x287750),_0x287750[_0x527db5(0x1ec)]===_0x527db5(0x1a8)){if(_0x4ff48e=null,!_0x5f519a)await l();_0x5f519a=!0x1;}}catch(_0x1d4f31){W(_0x527db5(0x1b4)+_0x1d4f31);}}}W(_0x527db5(0x229));}catch(_0xc6e948){W('SSE\x20connection\x20error:\x20'+_0xc6e948);}if(_0x4ff48e=_0x4ff48e??Date[_0x527db5(0x1f3)](),Date['now']()-_0x4ff48e>T){W('SSE\x20连续\x20>1h\x20连不上\x20hub\x20('+j+_0x527db5(0x1f0));return;}await N(_0x3b0876),_0x3b0876=Math[_0x527db5(0x1cb)](_0x3b0876*0x2,R);}}async function a(_0x343720){const _0x3737c0=a0_0x19b54f;if(_0x343720[_0x3737c0(0x1ec)]==='connected'){W(_0x3737c0(0x1bd)+G+'\x22');return;}if(_0x343720[_0x3737c0(0x1ec)]===_0x3737c0(0x1a9)){if(W(_0x3737c0(0x19d)+_0x343720['from']+':\x20'+_0x343720[_0x3737c0(0x1bc)][_0x3737c0(0x200)](0x0,0x3c)),await x['notification']({'method':_0x3737c0(0x20f),'params':{'content':_0x343720[_0x3737c0(0x1bc)],'meta':{'sender':_0x343720['from']||_0x3737c0(0x1a4),'sender_id':_0x3737c0(0x1d7),'user':_0x343720['from']||_0x3737c0(0x1a4),'priority':_0x3737c0(0x22e)}}}),_0x343720[_0x3737c0(0x22d)])await Y(_0x3737c0(0x1fa),{'alias':G,'message_id':_0x343720[_0x3737c0(0x22d)]});return;}if(_0x343720[_0x3737c0(0x1ec)]===_0x3737c0(0x1d4)||_0x343720['type']===_0x3737c0(0x1a0)){W('←\x20'+_0x343720[_0x3737c0(0x1ec)]+_0x3737c0(0x1bb)+_0x343720[_0x3737c0(0x1eb)]+'\x20priority='+(_0x343720[_0x3737c0(0x1c5)]||'normal'));let _0xb876fe=await Y('get_inbox',{'alias':G,'limit':0x5});if(_0xb876fe?.['ok']&&_0xb876fe[_0x3737c0(0x1f6)]?.[_0x3737c0(0x1f4)]>0x0)for(let _0x35399b of _0xb876fe[_0x3737c0(0x1f6)]){let _0x4af4ba={'sender':_0x35399b[_0x3737c0(0x227)]||_0x3737c0(0x1a4),'sender_id':'commhub','user':_0x35399b[_0x3737c0(0x227)]||_0x3737c0(0x1a4),'task_id':_0x35399b['id'],'priority':_0x35399b['priority']||'normal'};D[_0x3737c0(0x1bf)](_0x35399b['id'],_0x35399b[_0x3737c0(0x227)]||_0x3737c0(0x1a4)),await x[_0x3737c0(0x22a)]({'method':'notifications/claude/channel','params':{'content':_0x35399b['content'],'meta':_0x4af4ba}}),W(_0x3737c0(0x197)+_0x35399b['id'][_0x3737c0(0x200)](0x0,0x8)+_0x3737c0(0x1ef)+_0x35399b[_0x3737c0(0x227)]+':\x20'+_0x35399b['content'][_0x3737c0(0x200)](0x0,0x3c)),await Y(_0x3737c0(0x1fa),{'alias':G,'message_id':_0x35399b['id']});}}}async function n(){const _0x3c798b=a0_0x19b54f;let _0x89b357=new a0_0x32fca4();await x['connect'](_0x89b357),W(_0x3c798b(0x1c3)),W(_0x3c798b(0x20c)),o()['catch'](_0x6babae=>W(_0x3c798b(0x1ba)+_0x6babae)),Y(_0x3c798b(0x202),{'resume_id':K,'alias':G,'status':_0x3c798b(0x1e8),'server':a0_0x1025a0(),'hostname':a0_0x1025a0(),'agent':'claude-code','project_dir':process[_0x3c798b(0x20d)](),'tmux_name':f||void 0x0})['then'](()=>W('registered\x20as\x20\x22'+G+_0x3c798b(0x213)+K[_0x3c798b(0x200)](0x0,0x8)+')'))[_0x3c798b(0x1ea)](_0x3e39d6=>W(_0x3c798b(0x228)+_0x3e39d6)),setInterval(()=>{const _0x51e2ce=_0x3c798b;Y('report_status',{'resume_id':K,'alias':G,'status':'idle','server':a0_0x1025a0(),'hostname':a0_0x1025a0(),'agent':'claude-code','project_dir':process['cwd'](),'tmux_name':f||void 0x0})['catch'](_0x95444b=>W(_0x51e2ce(0x1e2)+_0x95444b));},0x2bf20),W(_0x3c798b(0x1ce));}n()[a0_0x19b54f(0x1ea)](_0x3a1cf2=>{const _0x24c1ee=a0_0x19b54f;W('fatal:\x20'+_0x3a1cf2),process[_0x24c1ee(0x220)](0x1);});async function b(){const _0x42ea72=a0_0x19b54f;W('shutting\x20down,\x20reporting\x20offline...'),await Y(_0x42ea72(0x202),{'resume_id':K,'alias':G,'status':_0x42ea72(0x230),'task':_0x42ea72(0x22c)})[_0x42ea72(0x1ea)](()=>{}),process['exit'](0x0);}process[a0_0x19b54f(0x1d0)]['on'](a0_0x19b54f(0x1e9),()=>b()),process['on'](a0_0x19b54f(0x1ed),()=>b()),process['on'](a0_0x19b54f(0x1b3),()=>b());
2
+ const a0_0x2822e1=a0_0x3240;function a0_0x3240(_0x3627f1,_0x328f42){_0x3627f1=_0x3627f1-0x1cf;const _0x2e4003=a0_0x2e40();let _0x324049=_0x2e4003[_0x3627f1];return _0x324049;}(function(_0x6a23df,_0x189e50){const _0x31a703=a0_0x3240,_0x1d1d66=_0x6a23df();while(!![]){try{const _0x2e7871=parseInt(_0x31a703(0x203))/0x1+-parseInt(_0x31a703(0x22b))/0x2+parseInt(_0x31a703(0x22e))/0x3+-parseInt(_0x31a703(0x20a))/0x4*(-parseInt(_0x31a703(0x264))/0x5)+-parseInt(_0x31a703(0x200))/0x6*(parseInt(_0x31a703(0x23e))/0x7)+parseInt(_0x31a703(0x23b))/0x8*(parseInt(_0x31a703(0x20d))/0x9)+parseInt(_0x31a703(0x24f))/0xa*(-parseInt(_0x31a703(0x1ec))/0xb);if(_0x2e7871===_0x189e50)break;else _0x1d1d66['push'](_0x1d1d66['shift']());}catch(_0x4edea1){_0x1d1d66['push'](_0x1d1d66['shift']());}}}(a0_0x2e40,0x8be59));import{readFileSync as a0_0x369a00,existsSync as a0_0x407856}from'fs';import{randomUUID as a0_0x2e478d}from'crypto';import{join as a0_0x50c156}from'path';import{hostname as a0_0x4227fe}from'os';import{execSync as a0_0x4949a2}from'child_process';import{Server as a0_0x40500b}from'@modelcontextprotocol/sdk/server/index.js';function a0_0x2e40(){const _0x29fcbb=['end','Progress\x200-100','stdin','find','unknown\x20tool','join','messages','parse','Task\x20outcome:\x20completed/failed/cancelled\x20for\x20final\x20results,\x20blocked/error/in_progress\x20for\x20status\x20updates','working','low','none','Bearer\x20','\x22\x20after\x20SSE\x20reconnect','tmux\x20display-message\x20-p\x20\x27#S\x27','cancelled','split','commhub_report_status','new_task','You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.','startsWith','cwd','SSE\x20connection\x20error:\x20','broadcast','init\x20failed:\x20','report_status',']\x20[commhub]\x20','warning:\x20could\x20not\x20register:\x20','unattributed-','from','indexOf','idle','http://127.0.0.1:9200','Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.','from_session','21109BFCMUx','min','\x20from\x20','2025-03-26',')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。','\x22\x20(','SIGINT','ack_inbox','commhub_reply','hub','\x20priority=','Current\x20task\x20description','write','slice','Target\x20session\x20alias','pop',':\x20inbox_count=','\x20/\x20hostname=','heartbeat\x20failed:\x20','Reply\x20using\x20the\x20commhub_reply\x20tool\x20to\x20report\x20status\x20or\x20results\x20back.','30ylSSLq','SSE\x20连续\x20>1h\x20连不上\x20hub\x20(','SSE\x20error:\x20','217769wzHAKT','token','text','utf-8','Priority\x20(default:\x20normal)','object','message','36fijTzc','commhub_send_task','0.3.0','1251BXSYAE','completed','.anet','config.json','data:\x20','type','.\x20Restart\x20node\x20via\x20`anet\x20node\x20start\x20<alias>`\x20so\x20the\x20env\x20is\x20set\x20explicitly\x20(#203).\x0a','normal','.env','[commhub]\x20WARN:\x20COMMHUB_ALIAS\x20env\x20var\x20is\x20unset\x20—\x20outbound\x20from_session\x20','trim','content','fatal:\x20','Authorization','SSE\x20connected\x20as\x20\x22','The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)','offline','SSE\x20fatal:\x20','failed','commhub','result','SSE\x20stream\x20ended,\x20reconnecting...','application/json,\x20text/event-stream','number','These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.','params','\x20RESUME_ID=','send_task','commhub_get_all_status','ready\x20—\x20waiting\x20for\x20events','718172cimTHv','delete','ENV:\x20URL=','2873382FRBJgv','Message\x20content','setRequestHandler','POST','notifications/claude/channel','task','Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.','connected','stringify','body','→\x20injected\x20task\x20','2.0','string','20680TtNFYF','commhub-channel','application/json','950201TdeIld','now','status','pid','length','exit','Session\x20alias:\x20','re-registered\x20as\x20\x22','catch','re-register\x20failed:\x20','send_reply','starting\x20SSE\x20listener...','claude-code','toTimeString','priority','no\x20response','commhub_send_message','1630VoSLuH','parse\x20error:\x20','\x20ALIAS=','CommHub\x20init\x20failed:\x20','read','message_id','alias','stderr','send_message','initialize','\x20PROJECT_ENV=','Reply\x20text\x20/\x20result\x20summary','registered\x20as\x20\x22','getReader','replace','/mcp','blocked','.claude/channels/commhub','error','Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','/events/','215965cmjTzS'];a0_0x2e40=function(){return _0x29fcbb;};return a0_0x2e40();}import{StdioServerTransport as a0_0x27092c}from'@modelcontextprotocol/sdk/server/stdio.js';import{ListToolsRequestSchema as a0_0x3a8f12,CallToolRequestSchema as a0_0x55ef04}from'@modelcontextprotocol/sdk/types.js';function I(_0x5f0505){const _0x3ce49a=a0_0x3240;if(!a0_0x407856(_0x5f0505))return;for(let _0xe2bdb5 of a0_0x369a00(_0x5f0505,_0x3ce49a(0x206))[_0x3ce49a(0x1d9)]('\x0a')){let _0x494002=_0xe2bdb5[_0x3ce49a(0x217)]();if(!_0x494002||_0x494002[_0x3ce49a(0x1dd)]('#'))continue;let _0x35989a=_0x494002[_0x3ce49a(0x1e7)]('=');if(_0x35989a<0x0)continue;let _0x2a3d8f=_0x494002['slice'](0x0,_0x35989a)[_0x3ce49a(0x217)](),_0x5415f5=_0x494002[_0x3ce49a(0x1f9)](_0x35989a+0x1)[_0x3ce49a(0x217)]()[_0x3ce49a(0x25d)](/^["']|["']$/g,'');if(!process.env[_0x2a3d8f])process.env[_0x2a3d8f]=_0x5415f5;}}var L=process.env.HOME||'~',U=a0_0x50c156(L,a0_0x2822e1(0x260));I(a0_0x50c156(U,a0_0x2822e1(0x215)));var v=process['cwd']()[a0_0x2822e1(0x25d)](/\//g,'-');I(a0_0x50c156(U,v,a0_0x2822e1(0x215)));function d(){const _0x31a4e3=a0_0x2822e1;try{return a0_0x4949a2(_0x31a4e3(0x1d7),{'encoding':_0x31a4e3(0x206),'timeout':0x7d0})['trim']();}catch{return'';}}function m(){const _0x2bfd7a=a0_0x2822e1;try{let _0x35f0f2=a0_0x50c156(L,_0x2bfd7a(0x20f),_0x2bfd7a(0x210));if(a0_0x407856(_0x35f0f2))return JSON[_0x2bfd7a(0x1d0)](a0_0x369a00(_0x35f0f2,'utf-8'));}catch{}return{};}var u=m(),j=process.env.COMMHUB_URL||u[a0_0x2822e1(0x1f5)]||a0_0x2822e1(0x1e9),f=process.env.COMMHUB_TMUX||d();function r(){const _0x14b251=a0_0x2822e1;if(process.env.COMMHUB_ALIAS&&process.env.COMMHUB_ALIAS[_0x14b251(0x217)]())return process.env.COMMHUB_ALIAS[_0x14b251(0x217)]();return process['stderr']['write'](_0x14b251(0x216)+('would\x20mis-attribute.\x20Refusing\x20to\x20guess\x20from\x20TMUX_NAME='+(f||'(none)')+_0x14b251(0x1fd)+a0_0x4227fe()+_0x14b251(0x213))),_0x14b251(0x1e5)+process[_0x14b251(0x241)];}var G=r(),K=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||a0_0x2e478d(),F=process.env.COMMHUB_TOKEN||u[a0_0x2822e1(0x204)]||'';function W(_0x45a9f8){const _0x4a19fd=a0_0x2822e1;let _0x364397=new Date()[_0x4a19fd(0x24b)]()[_0x4a19fd(0x1f9)](0x0,0x8);process[_0x4a19fd(0x256)][_0x4a19fd(0x1f8)]('['+_0x364397+_0x4a19fd(0x1e3)+_0x45a9f8+'\x0a');}function N(_0x12ec2d){return new Promise(_0x5ae353=>setTimeout(_0x5ae353,_0x12ec2d));}W(a0_0x2822e1(0x22d)+j+a0_0x2822e1(0x251)+G+a0_0x2822e1(0x227)+K[a0_0x2822e1(0x1f9)](0x0,0x8)+'...\x20TMUX='+(f||a0_0x2822e1(0x1d4))+'\x20CWD='+process[a0_0x2822e1(0x1de)]()+a0_0x2822e1(0x259)+v);var D=new Map(),x=new a0_0x40500b({'name':a0_0x2822e1(0x23c),'version':a0_0x2822e1(0x20c)},{'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_0x2822e1(0x225),a0_0x2822e1(0x1ff),a0_0x2822e1(0x1dc),a0_0x2822e1(0x244)+G][a0_0x2822e1(0x26a)]('\x0a')});x[a0_0x2822e1(0x230)](a0_0x3a8f12,async()=>({'tools':[{'name':a0_0x2822e1(0x1f4),'description':'Reply\x20to\x20a\x20CommHub\x20task\x20—\x20report\x20completion\x20or\x20send\x20a\x20message\x20back\x20to\x20the\x20hub.','inputSchema':{'type':'object','properties':{'task_id':{'type':a0_0x2822e1(0x23a),'description':a0_0x2822e1(0x21c)},'text':{'type':'string','description':a0_0x2822e1(0x25a)},'status':{'type':a0_0x2822e1(0x23a),'enum':[a0_0x2822e1(0x20e),a0_0x2822e1(0x21f),a0_0x2822e1(0x1d8),a0_0x2822e1(0x25f),a0_0x2822e1(0x261),'in_progress'],'description':a0_0x2822e1(0x1d1)}},'required':[a0_0x2822e1(0x205)]}},{'name':a0_0x2822e1(0x1da),'description':'Update\x20this\x20session\x27s\x20status\x20in\x20CommHub\x20(working/idle/blocked/error).\x20Returns\x20inbox_count.','inputSchema':{'type':'object','properties':{'status':{'type':a0_0x2822e1(0x23a),'enum':[a0_0x2822e1(0x1d2),a0_0x2822e1(0x1e8),a0_0x2822e1(0x25f),'error']},'task':{'type':a0_0x2822e1(0x23a),'description':a0_0x2822e1(0x1f7)},'progress':{'type':a0_0x2822e1(0x224),'description':a0_0x2822e1(0x266)}},'required':[a0_0x2822e1(0x240)]}},{'name':a0_0x2822e1(0x20b),'description':a0_0x2822e1(0x1ea),'inputSchema':{'type':a0_0x2822e1(0x208),'properties':{'alias':{'type':'string','description':a0_0x2822e1(0x1fa)},'task':{'type':a0_0x2822e1(0x23a),'description':'Task\x20content'},'priority':{'type':a0_0x2822e1(0x23a),'enum':['high',a0_0x2822e1(0x214),a0_0x2822e1(0x1d3)],'description':a0_0x2822e1(0x207)}},'required':[a0_0x2822e1(0x255),a0_0x2822e1(0x233)]}},{'name':'commhub_send_message','description':a0_0x2822e1(0x234),'inputSchema':{'type':a0_0x2822e1(0x208),'properties':{'alias':{'type':a0_0x2822e1(0x23a),'description':a0_0x2822e1(0x1fa)},'message':{'type':a0_0x2822e1(0x23a),'description':a0_0x2822e1(0x22f)}},'required':[a0_0x2822e1(0x255),a0_0x2822e1(0x209)]}},{'name':a0_0x2822e1(0x229),'description':a0_0x2822e1(0x262),'inputSchema':{'type':a0_0x2822e1(0x208),'properties':{}}}]}));async function Y(_0xf516ca,_0x472292){const _0x19c8ac=a0_0x2822e1;let _0xb4e4d8=await fetch(j+_0x19c8ac(0x25e),{'method':_0x19c8ac(0x231),'headers':{'Content-Type':_0x19c8ac(0x23d),'Accept':_0x19c8ac(0x223),...F?{'Authorization':_0x19c8ac(0x1d5)+F}:{}},'body':JSON[_0x19c8ac(0x236)]({'jsonrpc':_0x19c8ac(0x239),'id':0x1,'method':_0x19c8ac(0x258),'params':{'protocolVersion':_0x19c8ac(0x1ef),'capabilities':{},'clientInfo':{'name':'commhub-channel','version':'0.3.0'}}})});if(!_0xb4e4d8['ok']){let _0x521a1a=await _0xb4e4d8[_0x19c8ac(0x205)]();return W(_0x19c8ac(0x252)+_0xb4e4d8['status']+'\x20'+_0x521a1a['slice'](0x0,0x64)),{'ok':!0x1,'error':_0x19c8ac(0x1e1)+_0xb4e4d8['status']};}await _0xb4e4d8['text']();let _0x3c468f=(await(await fetch(j+_0x19c8ac(0x25e),{'method':'POST','headers':{'Content-Type':_0x19c8ac(0x23d),'Accept':'application/json,\x20text/event-stream',...F?{'Authorization':_0x19c8ac(0x1d5)+F}:{}},'body':JSON[_0x19c8ac(0x236)]({'jsonrpc':_0x19c8ac(0x239),'id':0x2,'method':'tools/call','params':{'name':_0xf516ca,'arguments':_0x472292}})}))['text']())['split']('\x0a')[_0x19c8ac(0x268)](_0x1f1b70=>_0x1f1b70[_0x19c8ac(0x1dd)](_0x19c8ac(0x211)));if(_0x3c468f){let _0x210440=JSON[_0x19c8ac(0x1d0)](_0x3c468f[_0x19c8ac(0x1f9)](0x6));return _0x210440?.[_0x19c8ac(0x221)]?.[_0x19c8ac(0x218)]?.[0x0]?.[_0x19c8ac(0x205)]?JSON[_0x19c8ac(0x1d0)](_0x210440[_0x19c8ac(0x221)][_0x19c8ac(0x218)][0x0][_0x19c8ac(0x205)]):_0x210440;}return{'ok':!0x1,'error':_0x19c8ac(0x24d)};}x[a0_0x2822e1(0x230)](a0_0x55ef04,async _0x2d2eee=>{const _0x2aca64=a0_0x2822e1;let {name:_0x293379,arguments:_0x1aca22}=_0x2d2eee[_0x2aca64(0x226)];if(_0x293379==='commhub_reply'){let {task_id:_0x32b2e6,text:_0x162154,status:_0x630e00}=_0x1aca22;if(_0x630e00===_0x2aca64(0x20e)||_0x630e00===_0x2aca64(0x21f)||_0x630e00==='cancelled'){let _0xcf5feb=_0x630e00==='completed'?'replied':_0x630e00,_0x53c352=_0x32b2e6?D['get'](_0x32b2e6)||_0x2aca64(0x1f5):_0x2aca64(0x1f5),_0xb0e9a9=await Y(_0x2aca64(0x248),{'alias':_0x53c352,'text':_0x162154,'in_reply_to':_0x32b2e6||void 0x0,'status':_0xcf5feb,'from_session':G});if(_0x32b2e6)D[_0x2aca64(0x22c)](_0x32b2e6);return{'content':[{'type':'text','text':JSON[_0x2aca64(0x236)](_0xb0e9a9)}]};}let _0x897351=await Y(_0x2aca64(0x1e2),{'resume_id':K,'alias':G,'status':_0x630e00===_0x2aca64(0x25f)?_0x2aca64(0x25f):_0x630e00===_0x2aca64(0x261)?_0x2aca64(0x261):_0x2aca64(0x1d2),'task':_0x162154['slice'](0x0,0xc8),'output':_0x162154});return{'content':[{'type':_0x2aca64(0x205),'text':JSON[_0x2aca64(0x236)](_0x897351)}]};}if(_0x293379===_0x2aca64(0x1da)){let {status:_0x10caf2,task:_0x3681fc,progress:_0x34787b}=_0x1aca22,_0x52701f=await Y(_0x2aca64(0x1e2),{'resume_id':K,'alias':G,'status':_0x10caf2,'task':_0x3681fc,'progress':_0x34787b});return{'content':[{'type':_0x2aca64(0x205),'text':JSON[_0x2aca64(0x236)](_0x52701f)}]};}if(_0x293379===_0x2aca64(0x20b)){let {alias:_0x9b9e53,task:_0x175162,priority:_0x185da2}=_0x1aca22,_0x20728=await Y(_0x2aca64(0x228),{'alias':_0x9b9e53,'task':_0x175162,'priority':_0x185da2||_0x2aca64(0x214),'from_session':G});return{'content':[{'type':_0x2aca64(0x205),'text':JSON[_0x2aca64(0x236)](_0x20728)}]};}if(_0x293379===_0x2aca64(0x24e)){let {alias:_0x8b6e9d,message:_0x231501}=_0x1aca22,_0x1e6ea4=await Y(_0x2aca64(0x257),{'alias':_0x8b6e9d,'message':_0x231501,'from_session':G});return{'content':[{'type':_0x2aca64(0x205),'text':JSON[_0x2aca64(0x236)](_0x1e6ea4)}]};}if(_0x293379==='commhub_get_all_status'){let _0xc44229=await Y('get_all_status',{});return{'content':[{'type':_0x2aca64(0x205),'text':JSON['stringify'](_0xc44229)}]};}return{'content':[{'type':'text','text':JSON[_0x2aca64(0x236)]({'error':_0x2aca64(0x269)})}]};});var O=0x3e8,R=0x7530,T=0x36ee80;async function l(){const _0x46b974=a0_0x2822e1;try{await Y('report_status',{'resume_id':K,'alias':G,'status':_0x46b974(0x1e8),'server':a0_0x4227fe(),'hostname':a0_0x4227fe(),'agent':'claude-code','project_dir':process[_0x46b974(0x1de)](),'tmux_name':f||void 0x0}),W(_0x46b974(0x245)+G+_0x46b974(0x1d6));}catch(_0x1f1567){W(_0x46b974(0x247)+_0x1f1567);}}async function o(){const _0x168327=a0_0x2822e1;let _0x12811b=j+_0x168327(0x263)+encodeURIComponent(G),_0x231cf6={};if(F)_0x231cf6[_0x168327(0x21a)]=_0x168327(0x1d5)+F;W('connecting\x20to\x20'+_0x12811b);let _0x4e703c=O,_0x1a948f=!0x0,_0x186e3d=null;while(!0x0){try{let _0x1a89b7=await fetch(_0x12811b,{'headers':_0x231cf6});if(!_0x1a89b7['ok']){if(W(_0x168327(0x202)+_0x1a89b7['status']+'\x20'+_0x1a89b7['statusText']),_0x186e3d=_0x186e3d??Date['now'](),Date['now']()-_0x186e3d>T){W(_0x168327(0x201)+j+')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。');return;}await N(_0x4e703c),_0x4e703c=Math[_0x168327(0x1ed)](_0x4e703c*0x2,R);continue;}let _0x475a17=_0x1a89b7[_0x168327(0x237)][_0x168327(0x25c)](),_0x704e57=new TextDecoder(),_0x50da4e='';_0x4e703c=O;while(!0x0){let {done:_0x5a4fc1,value:_0x1bebad}=await _0x475a17[_0x168327(0x253)]();if(_0x5a4fc1)break;_0x50da4e+=_0x704e57['decode'](_0x1bebad,{'stream':!0x0});let _0x4b9de=_0x50da4e['split']('\x0a\x0a');_0x50da4e=_0x4b9de[_0x168327(0x1fb)]()||'';for(let _0x13b456 of _0x4b9de){let _0x5dec07=_0x13b456[_0x168327(0x1d9)]('\x0a')[_0x168327(0x268)](_0x2344c1=>_0x2344c1[_0x168327(0x1dd)](_0x168327(0x211)));if(!_0x5dec07)continue;try{let _0x358f34=JSON[_0x168327(0x1d0)](_0x5dec07[_0x168327(0x1f9)](0x6));if(await a(_0x358f34),_0x358f34[_0x168327(0x212)]===_0x168327(0x235)){if(_0x186e3d=null,!_0x1a948f)await l();_0x1a948f=!0x1;}}catch(_0x179ba6){W(_0x168327(0x250)+_0x179ba6);}}}W(_0x168327(0x222));}catch(_0x2d9d26){W(_0x168327(0x1df)+_0x2d9d26);}if(_0x186e3d=_0x186e3d??Date[_0x168327(0x23f)](),Date['now']()-_0x186e3d>T){W(_0x168327(0x201)+j+_0x168327(0x1f0));return;}await N(_0x4e703c),_0x4e703c=Math[_0x168327(0x1ed)](_0x4e703c*0x2,R);}}async function a(_0x533adf){const _0x27c1bc=a0_0x2822e1;if(_0x533adf[_0x27c1bc(0x212)]===_0x27c1bc(0x235)){W(_0x27c1bc(0x21b)+G+'\x22');return;}if(_0x533adf['type']==='new_message'){if(W('←\x20message\x20from\x20'+_0x533adf[_0x27c1bc(0x1e6)]+':\x20'+_0x533adf[_0x27c1bc(0x209)][_0x27c1bc(0x1f9)](0x0,0x3c)),await x['notification']({'method':_0x27c1bc(0x232),'params':{'content':_0x533adf['message'],'meta':{'sender':_0x533adf[_0x27c1bc(0x1e6)]||'hub','sender_id':_0x27c1bc(0x220),'user':_0x533adf[_0x27c1bc(0x1e6)]||_0x27c1bc(0x1f5),'priority':_0x27c1bc(0x214)}}}),_0x533adf[_0x27c1bc(0x254)])await Y(_0x27c1bc(0x1f3),{'alias':G,'message_id':_0x533adf[_0x27c1bc(0x254)]});return;}if(_0x533adf['type']===_0x27c1bc(0x1db)||_0x533adf[_0x27c1bc(0x212)]===_0x27c1bc(0x1e0)){W('←\x20'+_0x533adf[_0x27c1bc(0x212)]+_0x27c1bc(0x1fc)+_0x533adf['inbox_count']+_0x27c1bc(0x1f6)+(_0x533adf[_0x27c1bc(0x24c)]||'normal'));let _0x4e54ca=await Y('get_inbox',{'alias':G,'limit':0x5});if(_0x4e54ca?.['ok']&&_0x4e54ca['messages']?.[_0x27c1bc(0x242)]>0x0)for(let _0x11f272 of _0x4e54ca[_0x27c1bc(0x1cf)]){let _0x11a96f={'sender':_0x11f272[_0x27c1bc(0x1eb)]||_0x27c1bc(0x1f5),'sender_id':_0x27c1bc(0x220),'user':_0x11f272[_0x27c1bc(0x1eb)]||_0x27c1bc(0x1f5),'task_id':_0x11f272['id'],'priority':_0x11f272[_0x27c1bc(0x24c)]||'normal'};D['set'](_0x11f272['id'],_0x11f272[_0x27c1bc(0x1eb)]||_0x27c1bc(0x1f5)),await x['notification']({'method':'notifications/claude/channel','params':{'content':_0x11f272['content'],'meta':_0x11a96f}}),W(_0x27c1bc(0x238)+_0x11f272['id']['slice'](0x0,0x8)+_0x27c1bc(0x1ee)+_0x11f272[_0x27c1bc(0x1eb)]+':\x20'+_0x11f272['content'][_0x27c1bc(0x1f9)](0x0,0x3c)),await Y(_0x27c1bc(0x1f3),{'alias':G,'message_id':_0x11f272['id']});}}}async function n(){const _0x3aca88=a0_0x2822e1;let _0xcb3477=new a0_0x27092c();await x['connect'](_0xcb3477),W('MCP\x20stdio\x20connected'),W(_0x3aca88(0x249)),o()[_0x3aca88(0x246)](_0x3b6a46=>W(_0x3aca88(0x21e)+_0x3b6a46)),Y(_0x3aca88(0x1e2),{'resume_id':K,'alias':G,'status':_0x3aca88(0x1e8),'server':a0_0x4227fe(),'hostname':a0_0x4227fe(),'agent':_0x3aca88(0x24a),'project_dir':process['cwd'](),'tmux_name':f||void 0x0})['then'](()=>W(_0x3aca88(0x25b)+G+_0x3aca88(0x1f1)+K[_0x3aca88(0x1f9)](0x0,0x8)+')'))[_0x3aca88(0x246)](_0x8b9ab3=>W(_0x3aca88(0x1e4)+_0x8b9ab3)),setInterval(()=>{const _0x521abe=_0x3aca88;Y(_0x521abe(0x1e2),{'resume_id':K,'alias':G,'status':_0x521abe(0x1e8),'server':a0_0x4227fe(),'hostname':a0_0x4227fe(),'agent':_0x521abe(0x24a),'project_dir':process['cwd'](),'tmux_name':f||void 0x0})[_0x521abe(0x246)](_0x4359aa=>W(_0x521abe(0x1fe)+_0x4359aa));},0x2bf20),W(_0x3aca88(0x22a));}n()[a0_0x2822e1(0x246)](_0x50b512=>{const _0x4b91db=a0_0x2822e1;W(_0x4b91db(0x219)+_0x50b512),process[_0x4b91db(0x243)](0x1);});async function b(){const _0x425be3=a0_0x2822e1;W('shutting\x20down,\x20reporting\x20offline...'),await Y(_0x425be3(0x1e2),{'resume_id':K,'alias':G,'status':_0x425be3(0x21d),'task':'session\x20disconnected'})['catch'](()=>{}),process[_0x425be3(0x243)](0x0);}process[a0_0x2822e1(0x267)]['on'](a0_0x2822e1(0x265),()=>b()),process['on']('SIGTERM',()=>b()),process['on'](a0_0x2822e1(0x1f2),()=>b());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sleep2agi/agent-network",
3
- "version": "2.2.18-preview.0",
3
+ "version": "2.2.19-preview.0",
4
4
  "description": "AI Agent Network CLI — Local-first multi-agent orchestration across 4 runtimes (Claude Code CLI / Claude Agent SDK / Codex SDK / Grok Build ACP) and 8+ LLM providers (Anthropic / OpenAI / xAI Grok / MiniMax / DeepSeek / GLM / Kimi / InternLM / Xiaomi MiMo / OpenRouter). Apache 2.0.",
5
5
  "type": "module",
6
6
  "main": "dist/src/client.js",