@sleep2agi/agent-network 2.3.0-preview.0 → 2.3.0-preview.2

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_0x2b4509=a0_0xeda9;(function(_0x318ee9,_0x43332d){const _0x22d06b=a0_0xeda9,_0x8a1d78=_0x318ee9();while(!![]){try{const _0x5d4a54=-parseInt(_0x22d06b(0x1cc))/0x1*(parseInt(_0x22d06b(0x214))/0x2)+parseInt(_0x22d06b(0x1dc))/0x3*(parseInt(_0x22d06b(0x204))/0x4)+-parseInt(_0x22d06b(0x1dd))/0x5*(-parseInt(_0x22d06b(0x1ed))/0x6)+parseInt(_0x22d06b(0x212))/0x7+-parseInt(_0x22d06b(0x217))/0x8+parseInt(_0x22d06b(0x1fe))/0x9+-parseInt(_0x22d06b(0x1ff))/0xa;if(_0x5d4a54===_0x43332d)break;else _0x8a1d78['push'](_0x8a1d78['shift']());}catch(_0x403dab){_0x8a1d78['push'](_0x8a1d78['shift']());}}}(a0_0x51ac,0xeed51));import{EventEmitter as a0_0x1bac59}from'events';function a0_0xeda9(_0x2cb602,_0x2b14d5){_0x2cb602=_0x2cb602-0x1cb;const _0x51ac75=a0_0x51ac();let _0xeda93d=_0x51ac75[_0x2cb602];return _0xeda93d;}import{hostname as a0_0x1d6303}from'os';class T extends a0_0x1bac59{['url'];[a0_0x2b4509(0x1f9)];[a0_0x2b4509(0x21a)];[a0_0x2b4509(0x1ce)];[a0_0x2b4509(0x1e0)];[a0_0x2b4509(0x1d7)];[a0_0x2b4509(0x218)];[a0_0x2b4509(0x1fc)];[a0_0x2b4509(0x208)];[a0_0x2b4509(0x1d5)]=!0x1;constructor(_0x59a1d1){const _0x30d15e=a0_0x2b4509;super();if(this[_0x30d15e(0x20b)]=_0x59a1d1[_0x30d15e(0x20b)][_0x30d15e(0x1df)](/\/$/,''),this['alias']=_0x59a1d1[_0x30d15e(0x1f9)],this[_0x30d15e(0x21a)]=_0x59a1d1[_0x30d15e(0x21a)],this[_0x30d15e(0x1ce)]=_0x59a1d1[_0x30d15e(0x1ce)]||'sdk',this[_0x30d15e(0x1e0)]=_0x30d15e(0x20c)+_0x59a1d1['alias']+'-'+Date['now']()['toString'](0x24),this['heartbeatInterval']=_0x59a1d1[_0x30d15e(0x1d7)]??0x2bf20,this['reconnectDelay']=_0x59a1d1[_0x30d15e(0x218)]??0xbb8,_0x59a1d1[_0x30d15e(0x1d6)]!==!0x1)this[_0x30d15e(0x20d)]();}['log'](_0x13e662){const _0x563bd0=a0_0x2b4509;console[_0x563bd0(0x1f5)]('['+new Date()[_0x563bd0(0x1f0)]()[_0x563bd0(0x1eb)](0x0,0x8)+_0x563bd0(0x1fb)+this[_0x563bd0(0x1f9)]+']\x20'+_0x13e662);}async[a0_0x2b4509(0x1f7)](_0x140b3c,_0x496ccc){const _0x1043a5=a0_0x2b4509;let _0x357066={'Content-Type':_0x1043a5(0x1da),'Accept':'application/json,\x20text/event-stream'};if(this[_0x1043a5(0x21a)])_0x357066[_0x1043a5(0x1ea)]=_0x1043a5(0x20a)+this[_0x1043a5(0x21a)];let _0x1ba73e=await(await fetch(this[_0x1043a5(0x20b)]+_0x1043a5(0x20f),{'method':_0x1043a5(0x1ee),'headers':_0x357066,'body':JSON['stringify']({'jsonrpc':'2.0','id':Date[_0x1043a5(0x1fa)](),'method':'tools/call','params':{'name':_0x140b3c,'arguments':_0x496ccc}})}))['text'](),_0xa5a90e=_0x1ba73e[_0x1043a5(0x1e7)](/data: (.+)/),_0x2ecb63=_0xa5a90e?JSON[_0x1043a5(0x216)](_0xa5a90e[0x1]):JSON[_0x1043a5(0x216)](_0x1ba73e),_0x515184=_0x2ecb63?.[_0x1043a5(0x1cf)]?.[_0x1043a5(0x213)]?.[0x0]?.[_0x1043a5(0x1e9)];return _0x515184?JSON[_0x1043a5(0x216)](_0x515184):_0x2ecb63;}async[a0_0x2b4509(0x20d)](){const _0x5730ec=a0_0x2b4509;if(this['running'])return;this[_0x5730ec(0x1d5)]=!0x0,await this[_0x5730ec(0x21c)](_0x5730ec(0x207)),this[_0x5730ec(0x1f5)](_0x5730ec(0x1f8)),this[_0x5730ec(0x1fc)]=setInterval(()=>{const _0x324206=_0x5730ec;this[_0x324206(0x21c)](_0x324206(0x207))[_0x324206(0x1de)](_0xd48d87=>this[_0x324206(0x1f5)](_0x324206(0x1fd)+_0xd48d87['message']));},this[_0x5730ec(0x1d7)]),this[_0x5730ec(0x205)]();}async[a0_0x2b4509(0x1e5)](){const _0x595860=a0_0x2b4509;if(this[_0x595860(0x1d5)]=!0x1,this['sseAbort']?.[_0x595860(0x1ec)](),this[_0x595860(0x1fc)])clearInterval(this[_0x595860(0x1fc)]);await this['status'](_0x595860(0x201))[_0x595860(0x1de)](()=>{}),this['log'](_0x595860(0x206));}async['send'](_0x2b4958,_0xf9ecde,_0x458517=a0_0x2b4509(0x202)){const _0x4246e5=a0_0x2b4509;return this[_0x4246e5(0x1f7)](_0x4246e5(0x211),{'alias':_0x2b4958,'task':_0xf9ecde,'priority':_0x458517,'from_session':this['alias']});}async[a0_0x2b4509(0x1f2)](_0x22fed2,_0x46922a){const _0x35bc1f=a0_0x2b4509;return this['call']('send_message',{'alias':_0x22fed2,'message':_0x46922a,'from_session':this[_0x35bc1f(0x1f9)]});}async['reply'](_0x4138b5,_0xf1266a,_0x1a513a=a0_0x2b4509(0x21b)){const _0x269f30=a0_0x2b4509;return this['call'](_0x269f30(0x1f6),{'in_reply_to':_0x4138b5,'text':_0xf1266a,'status':_0x1a513a});}async[a0_0x2b4509(0x21c)](_0x1eff61,_0x234f27){const _0x1014ac=a0_0x2b4509;return this[_0x1014ac(0x1f7)]('report_status',{'resume_id':this[_0x1014ac(0x1e0)],'alias':this[_0x1014ac(0x1f9)],'status':_0x1eff61,'server':a0_0x1d6303(),'hostname':a0_0x1d6303(),'agent':this['agent'],'project_dir':process[_0x1014ac(0x1d2)](),..._0x234f27});}async[a0_0x2b4509(0x200)](){const _0x12a22c=a0_0x2b4509;return this[_0x12a22c(0x1f7)](_0x12a22c(0x1d3),{});}async['broadcast'](_0x36665c,_0x27b071){const _0x4ea681=a0_0x2b4509;return this[_0x4ea681(0x1f7)]('broadcast',{'message':_0x36665c,'filter_server':_0x27b071?.[_0x4ea681(0x220)],'filter_status':_0x27b071?.[_0x4ea681(0x21c)]});}async[a0_0x2b4509(0x205)](){const _0x243e9c=a0_0x2b4509;let _0x24293c=encodeURIComponent(this[_0x243e9c(0x1f9)]),_0x37bee0=this[_0x243e9c(0x20b)]+_0x243e9c(0x1db)+_0x24293c,_0x50b4b8=this[_0x243e9c(0x218)];while(this['running']){try{this[_0x243e9c(0x208)]=new AbortController();let _0x485c48={'Accept':_0x243e9c(0x1f3)};if(this[_0x243e9c(0x21a)])_0x485c48[_0x243e9c(0x1ea)]='Bearer\x20'+this[_0x243e9c(0x21a)];let _0x232c08=await fetch(_0x37bee0,{'headers':_0x485c48,'signal':this[_0x243e9c(0x208)][_0x243e9c(0x20e)]});if(!_0x232c08['ok']||!_0x232c08[_0x243e9c(0x219)]){this[_0x243e9c(0x1f5)](_0x243e9c(0x1d1)+_0x232c08[_0x243e9c(0x21c)]),await this['sleep'](_0x50b4b8),_0x50b4b8=Math[_0x243e9c(0x1e2)](_0x50b4b8*1.5,0xea60);continue;}_0x50b4b8=this[_0x243e9c(0x218)];let _0x439372=_0x232c08[_0x243e9c(0x219)]['getReader'](),_0x8128ad=new TextDecoder(),_0x5bb10f='';while(this[_0x243e9c(0x1d5)]){let {done:_0x1fbc09,value:_0x1e758b}=await _0x439372[_0x243e9c(0x21e)]();if(_0x1fbc09)break;_0x5bb10f+=_0x8128ad[_0x243e9c(0x1e4)](_0x1e758b,{'stream':!0x0});let _0xe5b50d=_0x5bb10f[_0x243e9c(0x1d8)]('\x0a');_0x5bb10f=_0xe5b50d[_0x243e9c(0x1f1)]()||'';for(let _0x1f5544 of _0xe5b50d){if(!_0x1f5544['startsWith'](_0x243e9c(0x21d)))continue;try{let _0x1e39ce=JSON[_0x243e9c(0x216)](_0x1f5544[_0x243e9c(0x1eb)](0x6));if(_0x1e39ce['type']==='connected'){this[_0x243e9c(0x1f5)](_0x243e9c(0x1cb)),this[_0x243e9c(0x1e8)](_0x243e9c(0x210));continue;}if(_0x1e39ce['type']==='new_task'||_0x1e39ce['type']==='new_message'||_0x1e39ce['type']==='broadcast')await this[_0x243e9c(0x215)]();}catch{}}}}catch(_0x55042f){if(_0x55042f[_0x243e9c(0x1d9)]===_0x243e9c(0x1cd))break;this[_0x243e9c(0x1e8)](_0x243e9c(0x203),_0x55042f),this[_0x243e9c(0x1f5)](_0x243e9c(0x1ef)+_0x55042f[_0x243e9c(0x1f2)]);}if(this[_0x243e9c(0x1d5)])this[_0x243e9c(0x1e8)]('disconnected'),this['log'](_0x243e9c(0x1e3)+_0x50b4b8/0x3e8+_0x243e9c(0x21f)),await this[_0x243e9c(0x1d4)](_0x50b4b8),_0x50b4b8=Math[_0x243e9c(0x1e2)](_0x50b4b8*1.5,0xea60);}}async[a0_0x2b4509(0x215)](){const _0x59775c=a0_0x2b4509;try{let _0x48397d=(await this[_0x59775c(0x1f7)](_0x59775c(0x1d0),{'alias':this[_0x59775c(0x1f9)],'limit':0xa}))?.[_0x59775c(0x1e1)]||[];for(let _0x198ecc of _0x48397d)await this[_0x59775c(0x1f7)](_0x59775c(0x209),{'alias':this[_0x59775c(0x1f9)],'message_id':_0x198ecc['id']}),this[_0x59775c(0x1f5)]('←\x20'+_0x198ecc[_0x59775c(0x1f4)]+':\x20'+_0x198ecc['content'][_0x59775c(0x1eb)](0x0,0x3c)),this[_0x59775c(0x1e8)]('task',_0x198ecc),this[_0x59775c(0x1e8)](_0x59775c(0x1f2),_0x198ecc);}catch(_0x49d4c0){this['log'](_0x59775c(0x1e6)+_0x49d4c0[_0x59775c(0x1f2)]);}}['sleep'](_0x54c77d){return new Promise(_0x28d263=>setTimeout(_0x28d263,_0x54c77d));}}var $=T;export{$ as default,T as CommHub};function a0_0x51ac(){const _0x1b7928=['emit','text','Authorization','slice','abort','60954RAXQAN','POST','SSE\x20error:\x20','toTimeString','pop','message','text/event-stream','from_session','log','send_reply','call','registered','alias','now',']\x20[commhub:','heartbeatTimer','heartbeat\x20failed:\x20','9988542sVTaus','12854220AxDfdK','getAllStatus','offline','normal','error','3628rxNEmB','connectSSE','disconnected','idle','sseAbort','ack_inbox','Bearer\x20','url','sdk-','connect','signal','/mcp','connected','send_task','6362188JoQPdc','content','94FeqdtI','processInbox','parse','859176YDVxqB','reconnectDelay','body','token','completed','status','data:\x20','read','s...','server','SSE\x20connected','19726mMhZmJ','AbortError','agent','result','get_inbox','SSE\x20failed:\x20','cwd','get_all_status','sleep','running','autoConnect','heartbeatInterval','split','name','application/json','/events/','771HehUqe','515QyXQmp','catch','replace','resumeId','messages','min','SSE\x20reconnecting\x20in\x20','decode','disconnect','inbox\x20error:\x20','match'];a0_0x51ac=function(){return _0x1b7928;};return a0_0x51ac();}
1
+ const a0_0x238205=a0_0x2b7c;function a0_0x2b7c(_0x175c5d,_0x2926b1){_0x175c5d=_0x175c5d-0x85;const _0x23a12f=a0_0x23a1();let _0x2b7c69=_0x23a12f[_0x175c5d];return _0x2b7c69;}(function(_0xb48d31,_0x3723fb){const _0x480c8f=a0_0x2b7c,_0x326564=_0xb48d31();while(!![]){try{const _0x381c99=-parseInt(_0x480c8f(0x9e))/0x1+parseInt(_0x480c8f(0xc3))/0x2+-parseInt(_0x480c8f(0x94))/0x3+-parseInt(_0x480c8f(0xa3))/0x4+-parseInt(_0x480c8f(0xab))/0x5+-parseInt(_0x480c8f(0xd4))/0x6*(parseInt(_0x480c8f(0xcb))/0x7)+parseInt(_0x480c8f(0xcf))/0x8;if(_0x381c99===_0x3723fb)break;else _0x326564['push'](_0x326564['shift']());}catch(_0x27405c){_0x326564['push'](_0x326564['shift']());}}}(a0_0x23a1,0x8127b));import{EventEmitter as a0_0x215187}from'events';import{hostname as a0_0x57b3e8}from'os';class T extends a0_0x215187{[a0_0x238205(0xad)];[a0_0x238205(0xb4)];[a0_0x238205(0xc0)];['agent'];[a0_0x238205(0xd2)];[a0_0x238205(0xae)];[a0_0x238205(0x99)];[a0_0x238205(0x9f)];[a0_0x238205(0xaf)];[a0_0x238205(0xd3)]=!0x1;constructor(_0x385ded){const _0x35e6f0=a0_0x238205;super();if(this[_0x35e6f0(0xad)]=_0x385ded['url'][_0x35e6f0(0xc5)](/\/$/,''),this['alias']=_0x385ded[_0x35e6f0(0xb4)],this[_0x35e6f0(0xc0)]=_0x385ded[_0x35e6f0(0xc0)],this[_0x35e6f0(0xb8)]=_0x385ded[_0x35e6f0(0xb8)]||'sdk',this[_0x35e6f0(0xd2)]=_0x35e6f0(0x92)+_0x385ded[_0x35e6f0(0xb4)]+'-'+Date[_0x35e6f0(0xb1)]()['toString'](0x24),this['heartbeatInterval']=_0x385ded[_0x35e6f0(0xae)]??0x2bf20,this[_0x35e6f0(0x99)]=_0x385ded[_0x35e6f0(0x99)]??0xbb8,_0x385ded['autoConnect']!==!0x1)this[_0x35e6f0(0xa2)]();}[a0_0x238205(0xac)](_0x4840fe){const _0x52658d=a0_0x238205;console['log']('['+new Date()[_0x52658d(0xa5)]()[_0x52658d(0xaa)](0x0,0x8)+_0x52658d(0x91)+this[_0x52658d(0xb4)]+']\x20'+_0x4840fe);}async[a0_0x238205(0x96)](_0x517436,_0x2a96c8){const _0x1d3e28=a0_0x238205;let _0x38450b={'Content-Type':_0x1d3e28(0xbf),'Accept':_0x1d3e28(0xa8)};if(this[_0x1d3e28(0xc0)])_0x38450b[_0x1d3e28(0x93)]=_0x1d3e28(0xbe)+this[_0x1d3e28(0xc0)];let _0x3cecd1=await(await fetch(this[_0x1d3e28(0xad)]+_0x1d3e28(0x8a),{'method':_0x1d3e28(0x8c),'headers':_0x38450b,'body':JSON[_0x1d3e28(0xd8)]({'jsonrpc':'2.0','id':Date['now'](),'method':_0x1d3e28(0xc7),'params':{'name':_0x517436,'arguments':_0x2a96c8}})}))[_0x1d3e28(0xa0)](),_0x431d3c=_0x3cecd1['match'](/data: (.+)/),_0x3783ee=_0x431d3c?JSON[_0x1d3e28(0xcc)](_0x431d3c[0x1]):JSON[_0x1d3e28(0xcc)](_0x3cecd1),_0xcfafca=_0x3783ee?.['result']?.[_0x1d3e28(0xbc)]?.[0x0]?.[_0x1d3e28(0xa0)];return _0xcfafca?JSON[_0x1d3e28(0xcc)](_0xcfafca):_0x3783ee;}async[a0_0x238205(0xa2)](){const _0x1bc965=a0_0x238205;if(this[_0x1bc965(0xd3)])return;this[_0x1bc965(0xd3)]=!0x0,await this[_0x1bc965(0xa1)](_0x1bc965(0xa6)),this[_0x1bc965(0xac)](_0x1bc965(0xd7)),this['heartbeatTimer']=setInterval(()=>{const _0x1760d2=_0x1bc965;this['status'](_0x1760d2(0xa6))[_0x1760d2(0xb2)](_0x44a3b6=>this[_0x1760d2(0xac)](_0x1760d2(0xd1)+_0x44a3b6['message']));},this[_0x1bc965(0xae)]),this[_0x1bc965(0xc9)]();}async[a0_0x238205(0x8e)](){const _0x51fa1c=a0_0x238205;if(this[_0x51fa1c(0xd3)]=!0x1,this['sseAbort']?.[_0x51fa1c(0xb7)](),this['heartbeatTimer'])clearInterval(this[_0x51fa1c(0x9f)]);await this[_0x51fa1c(0xa1)]('offline')[_0x51fa1c(0xb2)](()=>{}),this[_0x51fa1c(0xac)]('disconnected');}async[a0_0x238205(0x86)](_0x372dfe,_0x44cc24,_0x22957a='normal'){const _0x29c4b8=a0_0x238205;return this[_0x29c4b8(0x96)](_0x29c4b8(0x8b),{'alias':_0x372dfe,'task':_0x44cc24,'priority':_0x22957a,'from_session':this['alias']});}async['message'](_0x989e93,_0x493467){const _0x12fe94=a0_0x238205;return this[_0x12fe94(0x96)](_0x12fe94(0xd6),{'alias':_0x989e93,'message':_0x493467,'from_session':this['alias']});}async[a0_0x238205(0xa9)](_0x42872c,_0x35fb9b,_0x2c4a30=a0_0x238205(0xca)){const _0x2b0c57=a0_0x238205;return this['call'](_0x2b0c57(0xba),{'in_reply_to':_0x42872c,'text':_0x35fb9b,'status':_0x2c4a30});}async[a0_0x238205(0xa1)](_0x3a3f60,_0x2e5e21){const _0x4098ec=a0_0x238205;return this[_0x4098ec(0x96)](_0x4098ec(0xcd),{'resume_id':this[_0x4098ec(0xd2)],'alias':this[_0x4098ec(0xb4)],'status':_0x3a3f60,'server':a0_0x57b3e8(),'hostname':a0_0x57b3e8(),'agent':this[_0x4098ec(0xb8)],'project_dir':process['cwd'](),..._0x2e5e21});}async[a0_0x238205(0x89)](){return this['call']('get_all_status',{});}async[a0_0x238205(0x87)](_0x275aea,_0x5a5e2f){const _0x3ed4fc=a0_0x238205;return this[_0x3ed4fc(0x96)](_0x3ed4fc(0x87),{'message':_0x275aea,'filter_server':_0x5a5e2f?.[_0x3ed4fc(0xd9)],'filter_status':_0x5a5e2f?.[_0x3ed4fc(0xa1)]});}async['connectSSE'](){const _0x12de34=a0_0x238205;let _0x2fe4c8=encodeURIComponent(this['alias']),_0x3a9f03=this[_0x12de34(0xad)]+_0x12de34(0xb0)+_0x2fe4c8,_0x1aecc9=this[_0x12de34(0x99)];while(this[_0x12de34(0xd3)]){try{this[_0x12de34(0xaf)]=new AbortController();let _0x2cddf1={'Accept':_0x12de34(0x9d)};if(this[_0x12de34(0xc0)])_0x2cddf1[_0x12de34(0x93)]=_0x12de34(0xbe)+this[_0x12de34(0xc0)];let _0x33eda3=await fetch(_0x3a9f03,{'headers':_0x2cddf1,'signal':this[_0x12de34(0xaf)]['signal']});if(!_0x33eda3['ok']||!_0x33eda3['body']){this[_0x12de34(0xac)]('SSE\x20failed:\x20'+_0x33eda3[_0x12de34(0xa1)]),await this[_0x12de34(0xb3)](_0x1aecc9),_0x1aecc9=Math['min'](_0x1aecc9*1.5,0xea60);continue;}_0x1aecc9=this[_0x12de34(0x99)];let _0x341aac=_0x33eda3['body'][_0x12de34(0x8f)](),_0x35cc8e=new TextDecoder(),_0x4b108b='';while(this['running']){let {done:_0x24050f,value:_0x1bfb06}=await _0x341aac[_0x12de34(0x88)]();if(_0x24050f)break;_0x4b108b+=_0x35cc8e[_0x12de34(0x85)](_0x1bfb06,{'stream':!0x0});let _0x5e200b=_0x4b108b[_0x12de34(0x8d)]('\x0a');_0x4b108b=_0x5e200b[_0x12de34(0x9b)]()||'';for(let _0x384271 of _0x5e200b){if(!_0x384271[_0x12de34(0xb5)](_0x12de34(0xc1)))continue;try{let _0x3a961e=JSON[_0x12de34(0xcc)](_0x384271[_0x12de34(0xaa)](0x6));if(_0x3a961e[_0x12de34(0x95)]===_0x12de34(0x9a)){this[_0x12de34(0xac)]('SSE\x20connected'),this[_0x12de34(0x98)]('connected');continue;}if(_0x3a961e['type']===_0x12de34(0xa4)||_0x3a961e[_0x12de34(0x95)]===_0x12de34(0xce)||_0x3a961e[_0x12de34(0x95)]===_0x12de34(0x87))await this['processInbox']();}catch{}}}}catch(_0x571d98){if(_0x571d98[_0x12de34(0xa7)]===_0x12de34(0xc2))break;this[_0x12de34(0x98)](_0x12de34(0xbb),_0x571d98),this[_0x12de34(0xac)](_0x12de34(0xb9)+_0x571d98[_0x12de34(0x9c)]);}if(this[_0x12de34(0xd3)])this['emit'](_0x12de34(0xbd)),this[_0x12de34(0xac)]('SSE\x20reconnecting\x20in\x20'+_0x1aecc9/0x3e8+_0x12de34(0xc6)),await this[_0x12de34(0xb3)](_0x1aecc9),_0x1aecc9=Math[_0x12de34(0xb6)](_0x1aecc9*1.5,0xea60);}}async['processInbox'](){const _0x17178b=a0_0x238205;try{let _0x48b1bc=(await this[_0x17178b(0x96)](_0x17178b(0xd0),{'alias':this[_0x17178b(0xb4)],'limit':0xa}))?.[_0x17178b(0x90)]||[];for(let _0x34f496 of _0x48b1bc)await this['call'](_0x17178b(0xc8),{'alias':this[_0x17178b(0xb4)],'message_id':_0x34f496['id']}),this['log']('←\x20'+_0x34f496[_0x17178b(0xd5)]+':\x20'+_0x34f496[_0x17178b(0xbc)][_0x17178b(0xaa)](0x0,0x3c)),this[_0x17178b(0x98)](_0x17178b(0x97),_0x34f496),this[_0x17178b(0x98)]('message',_0x34f496);}catch(_0x7e4517){this['log'](_0x17178b(0xc4)+_0x7e4517['message']);}}[a0_0x238205(0xb3)](_0x53c25e){return new Promise(_0xb360dd=>setTimeout(_0xb360dd,_0x53c25e));}}var $=T;function a0_0x23a1(){const _0x5453aa=['data:\x20','AbortError','299620tuVXUi','inbox\x20error:\x20','replace','s...','tools/call','ack_inbox','connectSSE','completed','13237xRPZks','parse','report_status','new_message','27442120rKbIIY','get_inbox','heartbeat\x20failed:\x20','resumeId','running','1614SnCWod','from_session','send_message','registered','stringify','server','decode','send','broadcast','read','getAllStatus','/mcp','send_task','POST','split','disconnect','getReader','messages',']\x20[commhub:','sdk-','Authorization','1888005nrYQPX','type','call','task','emit','reconnectDelay','connected','pop','message','text/event-stream','848563eiDPPz','heartbeatTimer','text','status','connect','359936YELHsR','new_task','toTimeString','idle','name','application/json,\x20text/event-stream','reply','slice','4872475dnIcop','log','url','heartbeatInterval','sseAbort','/events/','now','catch','sleep','alias','startsWith','min','abort','agent','SSE\x20error:\x20','send_reply','error','content','disconnected','Bearer\x20','application/json','token'];a0_0x23a1=function(){return _0x5453aa;};return a0_0x23a1();}export{$ as default,T as CommHub};
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Outcome of one rule check against one `.gitignore` file.
3
+ */
4
+ export type EnsureRuleOutcome = "already-present" | "appended" | "created" | "skipped-no-anet";
5
+ /**
6
+ * Append `rule` to `gitignorePath` unless an exactly-matching line
7
+ * already exists. Returns the outcome. Never throws on missing parent
8
+ * directory — caller is expected to have created it (or wants the
9
+ * gitignore skipped, per the `.anet`-scoped writer below).
10
+ *
11
+ * The rule comparison is line-exact after `trim()`. Rules with leading
12
+ * `#` (comment lines in the same file) are ignored for the duplicate
13
+ * check, so an end-user can leave commented-out variants in place
14
+ * without confusing the idempotent guard.
15
+ */
16
+ export declare function ensureGitignoreRule(gitignorePath: string, rule: string): EnsureRuleOutcome;
17
+ /**
18
+ * Convenience: append multiple rules to one `.gitignore` file with one
19
+ * read/write pair. Returns the outcome per rule, in input order.
20
+ */
21
+ export declare function ensureGitignoreRules(gitignorePath: string, rules: string[]): EnsureRuleOutcome[];
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env bun
2
- const a0_0x428199=a0_0x17e9;(function(_0xa49539,_0x5e61de){const _0x557910=a0_0x17e9,_0x439bd5=_0xa49539();while(!![]){try{const _0x34a65d=parseInt(_0x557910(0x14c))/0x1+parseInt(_0x557910(0x151))/0x2*(-parseInt(_0x557910(0x147))/0x3)+parseInt(_0x557910(0x13d))/0x4+parseInt(_0x557910(0x14b))/0x5*(-parseInt(_0x557910(0x19b))/0x6)+parseInt(_0x557910(0x199))/0x7+parseInt(_0x557910(0x14d))/0x8+-parseInt(_0x557910(0x16a))/0x9*(parseInt(_0x557910(0x178))/0xa);if(_0x34a65d===_0x5e61de)break;else _0x439bd5['push'](_0x439bd5['shift']());}catch(_0x37fedf){_0x439bd5['push'](_0x439bd5['shift']());}}}(a0_0x10b9,0x34b38));import{readFileSync as a0_0x567be1,existsSync as a0_0x113046}from'fs';import{randomUUID as a0_0x518187}from'crypto';function a0_0x17e9(_0x1b32dd,_0x157267){_0x1b32dd=_0x1b32dd-0x11d;const _0x10b9e4=a0_0x10b9();let _0x17e984=_0x10b9e4[_0x1b32dd];return _0x17e984;}import{join as a0_0x3e60b7}from'path';import{hostname as a0_0x224891}from'os';import{execSync as a0_0xf75b1a}from'child_process';import{Server as a0_0x2b1d99}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport as a0_0x3db5a7}from'@modelcontextprotocol/sdk/server/stdio.js';import{ListToolsRequestSchema as a0_0x4277b,CallToolRequestSchema as a0_0x2ac4fd}from'@modelcontextprotocol/sdk/types.js';function I(_0x51f8be){const _0x5345a0=a0_0x17e9;if(!a0_0x113046(_0x51f8be))return;for(let _0x3a248e of a0_0x567be1(_0x51f8be,_0x5345a0(0x156))[_0x5345a0(0x157)]('\x0a')){let _0xe4a48=_0x3a248e[_0x5345a0(0x153)]();if(!_0xe4a48||_0xe4a48[_0x5345a0(0x152)]('#'))continue;let _0x280f25=_0xe4a48[_0x5345a0(0x1ac)]('=');if(_0x280f25<0x0)continue;let _0x3b07ac=_0xe4a48['slice'](0x0,_0x280f25)[_0x5345a0(0x153)](),_0x921fb3=_0xe4a48[_0x5345a0(0x173)](_0x280f25+0x1)['trim']()[_0x5345a0(0x133)](/^["']|["']$/g,'');if(!process.env[_0x3b07ac])process.env[_0x3b07ac]=_0x921fb3;}}var L=process.env.HOME||'~',U=a0_0x3e60b7(L,a0_0x428199(0x15c));I(a0_0x3e60b7(U,a0_0x428199(0x195)));var v=process[a0_0x428199(0x14e)]()[a0_0x428199(0x133)](/\//g,'-');I(a0_0x3e60b7(U,v,a0_0x428199(0x195)));function d(){const _0x1ab4fb=a0_0x428199;try{return a0_0xf75b1a(_0x1ab4fb(0x128),{'encoding':_0x1ab4fb(0x156),'timeout':0x7d0})[_0x1ab4fb(0x153)]();}catch{return'';}}function m(){const _0x516498=a0_0x428199;try{let _0x46f8aa=a0_0x3e60b7(L,_0x516498(0x14a),'config.json');if(a0_0x113046(_0x46f8aa))return JSON[_0x516498(0x129)](a0_0x567be1(_0x46f8aa,_0x516498(0x156)));}catch{}return{};}var u=m(),j=process.env.COMMHUB_URL||u[a0_0x428199(0x12e)]||'http://127.0.0.1:9200',f=process.env.COMMHUB_TMUX||d();function r(){const _0x1c6d4f=a0_0x428199;if(process.env.COMMHUB_ALIAS&&process.env.COMMHUB_ALIAS['trim']())return process.env.COMMHUB_ALIAS[_0x1c6d4f(0x153)]();return process[_0x1c6d4f(0x185)]['write'](_0x1c6d4f(0x124)+(_0x1c6d4f(0x1a0)+(f||_0x1c6d4f(0x1aa))+_0x1c6d4f(0x1a2)+a0_0x224891()+'.\x20Restart\x20node\x20via\x20`anet\x20node\x20start\x20<alias>`\x20so\x20the\x20env\x20is\x20set\x20explicitly\x20(#203).\x0a')),_0x1c6d4f(0x17c)+process[_0x1c6d4f(0x180)];}var G=r(),K=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||a0_0x518187(),F=process.env.COMMHUB_TOKEN||u[a0_0x428199(0x122)]||'';function W(_0x12a078){const _0x4b591f=a0_0x428199;let _0xc869d5=new Date()[_0x4b591f(0x161)]()[_0x4b591f(0x173)](0x0,0x8);process[_0x4b591f(0x185)][_0x4b591f(0x182)]('['+_0xc869d5+_0x4b591f(0x1a9)+_0x12a078+'\x0a');}function N(_0x2ad54a){return new Promise(_0x28eddc=>setTimeout(_0x28eddc,_0x2ad54a));}W(a0_0x428199(0x155)+j+a0_0x428199(0x186)+G+'\x20RESUME_ID='+K[a0_0x428199(0x173)](0x0,0x8)+a0_0x428199(0x13e)+(f||'none')+a0_0x428199(0x134)+process[a0_0x428199(0x14e)]()+a0_0x428199(0x175)+v);var D=new Map(),x=new a0_0x2b1d99({'name':'commhub-channel','version':'0.3.0'},{'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_0x428199(0x187),a0_0x428199(0x18e),'You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.',a0_0x428199(0x192)+G][a0_0x428199(0x143)]('\x0a')});x[a0_0x428199(0x148)](a0_0x4277b,async()=>({'tools':[{'name':a0_0x428199(0x1a4),'description':a0_0x428199(0x135),'inputSchema':{'type':'object','properties':{'task_id':{'type':a0_0x428199(0x194),'description':a0_0x428199(0x142)},'text':{'type':a0_0x428199(0x194),'description':a0_0x428199(0x165)},'status':{'type':a0_0x428199(0x194),'enum':[a0_0x428199(0x139),'failed',a0_0x428199(0x15e),'blocked','error',a0_0x428199(0x19f)],'description':'Task\x20outcome:\x20completed/failed/cancelled\x20for\x20final\x20results,\x20blocked/error/in_progress\x20for\x20status\x20updates'}},'required':[a0_0x428199(0x17a)]}},{'name':a0_0x428199(0x140),'description':a0_0x428199(0x197),'inputSchema':{'type':a0_0x428199(0x125),'properties':{'status':{'type':a0_0x428199(0x194),'enum':[a0_0x428199(0x12d),a0_0x428199(0x1a7),a0_0x428199(0x13a),a0_0x428199(0x15f)]},'task':{'type':a0_0x428199(0x194),'description':a0_0x428199(0x1a6)},'progress':{'type':a0_0x428199(0x16d),'description':a0_0x428199(0x17d)}},'required':['status']}},{'name':a0_0x428199(0x181),'description':a0_0x428199(0x146),'inputSchema':{'type':a0_0x428199(0x125),'properties':{'alias':{'type':a0_0x428199(0x194),'description':a0_0x428199(0x149)},'task':{'type':a0_0x428199(0x194),'description':a0_0x428199(0x18f)},'priority':{'type':'string','enum':[a0_0x428199(0x15d),'normal','low'],'description':a0_0x428199(0x184)}},'required':[a0_0x428199(0x183),a0_0x428199(0x141)]}},{'name':a0_0x428199(0x127),'description':a0_0x428199(0x126),'inputSchema':{'type':'object','properties':{'alias':{'type':'string','description':a0_0x428199(0x149)},'message':{'type':'string','description':'Message\x20content'}},'required':['alias',a0_0x428199(0x16b)]}},{'name':a0_0x428199(0x164),'description':a0_0x428199(0x12f),'inputSchema':{'type':a0_0x428199(0x125),'properties':{}}}]}));async function Y(_0x8f4818,_0x253e65){const _0x572991=a0_0x428199;let _0xff4c40=await fetch(j+_0x572991(0x1b0),{'method':_0x572991(0x136),'headers':{'Content-Type':_0x572991(0x18b),'Accept':_0x572991(0x171),...F?{'Authorization':_0x572991(0x158)+F}:{}},'body':JSON[_0x572991(0x15a)]({'jsonrpc':_0x572991(0x170),'id':0x1,'method':_0x572991(0x121),'params':{'protocolVersion':_0x572991(0x189),'capabilities':{},'clientInfo':{'name':_0x572991(0x1ab),'version':'0.3.0'}}})});if(!_0xff4c40['ok']){let _0x1d2b56=await _0xff4c40['text']();return W(_0x572991(0x12b)+_0xff4c40[_0x572991(0x191)]+'\x20'+_0x1d2b56['slice'](0x0,0x64)),{'ok':!0x1,'error':_0x572991(0x120)+_0xff4c40[_0x572991(0x191)]};}await _0xff4c40[_0x572991(0x17a)]();let _0x1d9bd9=(await(await fetch(j+_0x572991(0x1b0),{'method':'POST','headers':{'Content-Type':_0x572991(0x18b),'Accept':'application/json,\x20text/event-stream',...F?{'Authorization':_0x572991(0x158)+F}:{}},'body':JSON[_0x572991(0x15a)]({'jsonrpc':_0x572991(0x170),'id':0x2,'method':_0x572991(0x12c),'params':{'name':_0x8f4818,'arguments':_0x253e65}})}))[_0x572991(0x17a)]())['split']('\x0a')['find'](_0x503bad=>_0x503bad['startsWith'](_0x572991(0x1b1)));if(_0x1d9bd9){let _0x5abd29=JSON[_0x572991(0x129)](_0x1d9bd9['slice'](0x6));return _0x5abd29?.[_0x572991(0x1a3)]?.[_0x572991(0x145)]?.[0x0]?.[_0x572991(0x17a)]?JSON[_0x572991(0x129)](_0x5abd29['result'][_0x572991(0x145)][0x0][_0x572991(0x17a)]):_0x5abd29;}return{'ok':!0x1,'error':_0x572991(0x193)};}x[a0_0x428199(0x148)](a0_0x2ac4fd,async _0x1fd039=>{const _0x27e9d7=a0_0x428199;let {name:_0x4362d5,arguments:_0x24acd4}=_0x1fd039[_0x27e9d7(0x154)];if(_0x4362d5==='commhub_reply'){let {task_id:_0x5b6a4e,text:_0x296269,status:_0x1fc0ab}=_0x24acd4;if(_0x1fc0ab==='completed'||_0x1fc0ab==='failed'||_0x1fc0ab===_0x27e9d7(0x15e)){let _0x48d45a=_0x1fc0ab===_0x27e9d7(0x139)?_0x27e9d7(0x1ae):_0x1fc0ab,_0x11afeb=_0x5b6a4e?D[_0x27e9d7(0x18a)](_0x5b6a4e)||_0x27e9d7(0x12e):_0x27e9d7(0x12e),_0x11d770=await Y(_0x27e9d7(0x190),{'alias':_0x11afeb,'text':_0x296269,'in_reply_to':_0x5b6a4e||void 0x0,'status':_0x48d45a,'from_session':G});if(_0x5b6a4e)D['delete'](_0x5b6a4e);return{'content':[{'type':_0x27e9d7(0x17a),'text':JSON['stringify'](_0x11d770)}]};}let _0x1f2340=await Y(_0x27e9d7(0x167),{'resume_id':K,'alias':G,'status':_0x1fc0ab===_0x27e9d7(0x13a)?_0x27e9d7(0x13a):_0x1fc0ab===_0x27e9d7(0x15f)?_0x27e9d7(0x15f):_0x27e9d7(0x12d),'task':_0x296269['slice'](0x0,0xc8),'output':_0x296269});return{'content':[{'type':_0x27e9d7(0x17a),'text':JSON[_0x27e9d7(0x15a)](_0x1f2340)}]};}if(_0x4362d5===_0x27e9d7(0x140)){let {status:_0x598a74,task:_0x5eafe7,progress:_0x29b1b4}=_0x24acd4,_0x3180e9=await Y(_0x27e9d7(0x167),{'resume_id':K,'alias':G,'status':_0x598a74,'task':_0x5eafe7,'progress':_0x29b1b4});return{'content':[{'type':'text','text':JSON[_0x27e9d7(0x15a)](_0x3180e9)}]};}if(_0x4362d5===_0x27e9d7(0x181)){let {alias:_0x1976bb,task:_0x2f92b4,priority:_0x155388}=_0x24acd4,_0x2f289c=await Y('send_task',{'alias':_0x1976bb,'task':_0x2f92b4,'priority':_0x155388||_0x27e9d7(0x17b),'from_session':G});return{'content':[{'type':_0x27e9d7(0x17a),'text':JSON['stringify'](_0x2f289c)}]};}if(_0x4362d5===_0x27e9d7(0x127)){let {alias:_0x152708,message:_0x48d6a3}=_0x24acd4,_0x1c2e36=await Y('send_message',{'alias':_0x152708,'message':_0x48d6a3,'from_session':G});return{'content':[{'type':_0x27e9d7(0x17a),'text':JSON[_0x27e9d7(0x15a)](_0x1c2e36)}]};}if(_0x4362d5==='commhub_get_all_status'){let _0x5a8100=await Y('get_all_status',{});return{'content':[{'type':'text','text':JSON[_0x27e9d7(0x15a)](_0x5a8100)}]};}return{'content':[{'type':_0x27e9d7(0x17a),'text':JSON[_0x27e9d7(0x15a)]({'error':'unknown\x20tool'})}]};});var O=0x3e8,R=0x7530,T=0x36ee80;async function l(){const _0x1b92bf=a0_0x428199;try{await Y(_0x1b92bf(0x167),{'resume_id':K,'alias':G,'status':_0x1b92bf(0x1a7),'server':a0_0x224891(),'hostname':a0_0x224891(),'agent':_0x1b92bf(0x19e),'project_dir':process['cwd'](),'tmux_name':f||void 0x0}),W(_0x1b92bf(0x163)+G+_0x1b92bf(0x17f));}catch(_0x57c27d){W(_0x1b92bf(0x162)+_0x57c27d);}}async function o(){const _0x5ba89a=a0_0x428199;let _0x4008d6=j+_0x5ba89a(0x18d)+encodeURIComponent(G),_0x44e10a={};if(F)_0x44e10a['Authorization']='Bearer\x20'+F;W(_0x5ba89a(0x169)+_0x4008d6);let _0x4dca3e=O,_0x3c893e=!0x0,_0x1eaac0=null;while(!0x0){try{let _0x2529a9=await fetch(_0x4008d6,{'headers':_0x44e10a});if(!_0x2529a9['ok']){if(W(_0x5ba89a(0x174)+_0x2529a9['status']+'\x20'+_0x2529a9[_0x5ba89a(0x196)]),_0x1eaac0=_0x1eaac0??Date['now'](),Date[_0x5ba89a(0x13f)]()-_0x1eaac0>T){W('SSE\x20连续\x20>1h\x20连不上\x20hub\x20('+j+_0x5ba89a(0x172));return;}await N(_0x4dca3e),_0x4dca3e=Math[_0x5ba89a(0x13c)](_0x4dca3e*0x2,R);continue;}let _0x367499=_0x2529a9['body'][_0x5ba89a(0x15b)](),_0x5b6827=new TextDecoder(),_0x5265b9='';_0x4dca3e=O;while(!0x0){let {done:_0x10b8aa,value:_0x40412b}=await _0x367499['read']();if(_0x10b8aa)break;_0x5265b9+=_0x5b6827['decode'](_0x40412b,{'stream':!0x0});let _0x7d6a04=_0x5265b9[_0x5ba89a(0x157)]('\x0a\x0a');_0x5265b9=_0x7d6a04[_0x5ba89a(0x150)]()||'';for(let _0x1327bc of _0x7d6a04){let _0x4c778a=_0x1327bc['split']('\x0a')['find'](_0x4cd08e=>_0x4cd08e[_0x5ba89a(0x152)](_0x5ba89a(0x1b1)));if(!_0x4c778a)continue;try{let _0xaf659b=JSON[_0x5ba89a(0x129)](_0x4c778a[_0x5ba89a(0x173)](0x6));if(await a(_0xaf659b),_0xaf659b[_0x5ba89a(0x160)]===_0x5ba89a(0x123)){if(_0x1eaac0=null,!_0x3c893e)await l();_0x3c893e=!0x1;}}catch(_0x869b94){W(_0x5ba89a(0x1af)+_0x869b94);}}}W('SSE\x20stream\x20ended,\x20reconnecting...');}catch(_0x2b92de){W(_0x5ba89a(0x131)+_0x2b92de);}if(_0x1eaac0=_0x1eaac0??Date[_0x5ba89a(0x13f)](),Date[_0x5ba89a(0x13f)]()-_0x1eaac0>T){W(_0x5ba89a(0x179)+j+_0x5ba89a(0x172));return;}await N(_0x4dca3e),_0x4dca3e=Math[_0x5ba89a(0x13c)](_0x4dca3e*0x2,R);}}function a0_0x10b9(){const _0x3bb166=['completed','blocked','priority','min','1656204eUvJpA','...\x20TMUX=','now','commhub_report_status','task','The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)','join','from','content','Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.','981FhRVFj','setRequestHandler','Target\x20session\x20alias','.anet','50YixqeM','66220WrWnhF','567808ZwHDHD','cwd','length','pop','1678EngiOP','startsWith','trim','params','ENV:\x20URL=','utf-8','split','Bearer\x20','ready\x20—\x20waiting\x20for\x20events','stringify','getReader','.claude/channels/commhub','high','cancelled','error','type','toTimeString','re-register\x20failed:\x20','re-registered\x20as\x20\x22','commhub_get_all_status','Reply\x20text\x20/\x20result\x20summary','commhub','report_status','catch','connecting\x20to\x20','45SyRkzn','message','shutting\x20down,\x20reporting\x20offline...','number','from_session','set','2.0','application/json,\x20text/event-stream',')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。','slice','SSE\x20error:\x20','\x20PROJECT_ENV=','new_task','broadcast','100180YztqMu','SSE\x20连续\x20>1h\x20连不上\x20hub\x20(','text','normal','unattributed-','Progress\x200-100','ack_inbox','\x22\x20after\x20SSE\x20reconnect','pid','commhub_send_task','write','alias','Priority\x20(default:\x20normal)','stderr','\x20ALIAS=','These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.',':\x20inbox_count=','2025-03-26','get','application/json','new_message','/events/','Reply\x20using\x20the\x20commhub_reply\x20tool\x20to\x20report\x20status\x20or\x20results\x20back.','Task\x20content','send_reply','status','Session\x20alias:\x20','no\x20response','string','.env','statusText','Update\x20this\x20session\x27s\x20status\x20in\x20CommHub\x20(working/idle/blocked/error).\x20Returns\x20inbox_count.','notifications/claude/channel','1989470mbniBl','→\x20injected\x20task\x20','177090AbpNYg','notification','message_id','claude-code','in_progress','would\x20mis-attribute.\x20Refusing\x20to\x20guess\x20from\x20TMUX_NAME=','warning:\x20could\x20not\x20register:\x20','\x20/\x20hostname=','result','commhub_reply','←\x20message\x20from\x20','Current\x20task\x20description','idle','MCP\x20stdio\x20connected',']\x20[commhub]\x20','(none)','commhub-channel','indexOf','exit','replied','parse\x20error:\x20','/mcp','data:\x20','fatal:\x20','\x22\x20(','messages','end','init\x20failed:\x20','initialize','token','connected','[commhub]\x20WARN:\x20COMMHUB_ALIAS\x20env\x20var\x20is\x20unset\x20—\x20outbound\x20from_session\x20','object','Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.','commhub_send_message','tmux\x20display-message\x20-p\x20\x27#S\x27','parse','starting\x20SSE\x20listener...','CommHub\x20init\x20failed:\x20','tools/call','working','hub','Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','session\x20disconnected','SSE\x20connection\x20error:\x20','registered\x20as\x20\x22','replace','\x20CWD=','Reply\x20to\x20a\x20CommHub\x20task\x20—\x20report\x20completion\x20or\x20send\x20a\x20message\x20back\x20to\x20the\x20hub.','POST','get_inbox','SIGINT'];a0_0x10b9=function(){return _0x3bb166;};return a0_0x10b9();}async function a(_0x3243ee){const _0x19889d=a0_0x428199;if(_0x3243ee[_0x19889d(0x160)]===_0x19889d(0x123)){W('SSE\x20connected\x20as\x20\x22'+G+'\x22');return;}if(_0x3243ee['type']===_0x19889d(0x18c)){if(W(_0x19889d(0x1a5)+_0x3243ee[_0x19889d(0x144)]+':\x20'+_0x3243ee[_0x19889d(0x16b)]['slice'](0x0,0x3c)),await x[_0x19889d(0x19c)]({'method':'notifications/claude/channel','params':{'content':_0x3243ee[_0x19889d(0x16b)],'meta':{'sender':_0x3243ee[_0x19889d(0x144)]||_0x19889d(0x12e),'sender_id':_0x19889d(0x166),'user':_0x3243ee[_0x19889d(0x144)]||_0x19889d(0x12e),'priority':_0x19889d(0x17b)}}}),_0x3243ee[_0x19889d(0x19d)])await Y(_0x19889d(0x17e),{'alias':G,'message_id':_0x3243ee[_0x19889d(0x19d)]});return;}if(_0x3243ee['type']===_0x19889d(0x176)||_0x3243ee[_0x19889d(0x160)]===_0x19889d(0x177)){W('←\x20'+_0x3243ee[_0x19889d(0x160)]+_0x19889d(0x188)+_0x3243ee['inbox_count']+'\x20priority='+(_0x3243ee[_0x19889d(0x13b)]||_0x19889d(0x17b)));let _0x3f005f=await Y(_0x19889d(0x137),{'alias':G,'limit':0x5});if(_0x3f005f?.['ok']&&_0x3f005f['messages']?.[_0x19889d(0x14f)]>0x0)for(let _0x335fc1 of _0x3f005f[_0x19889d(0x11e)]){let _0x45daa4={'sender':_0x335fc1['from_session']||_0x19889d(0x12e),'sender_id':_0x19889d(0x166),'user':_0x335fc1[_0x19889d(0x16e)]||'hub','task_id':_0x335fc1['id'],'priority':_0x335fc1[_0x19889d(0x13b)]||_0x19889d(0x17b)};D[_0x19889d(0x16f)](_0x335fc1['id'],_0x335fc1[_0x19889d(0x16e)]||_0x19889d(0x12e)),await x[_0x19889d(0x19c)]({'method':_0x19889d(0x198),'params':{'content':_0x335fc1[_0x19889d(0x145)],'meta':_0x45daa4}}),W(_0x19889d(0x19a)+_0x335fc1['id']['slice'](0x0,0x8)+'\x20from\x20'+_0x335fc1[_0x19889d(0x16e)]+':\x20'+_0x335fc1[_0x19889d(0x145)][_0x19889d(0x173)](0x0,0x3c)),await Y(_0x19889d(0x17e),{'alias':G,'message_id':_0x335fc1['id']});}}}async function n(){const _0x2b9737=a0_0x428199;let _0x518b51=new a0_0x3db5a7();await x['connect'](_0x518b51),W(_0x2b9737(0x1a8)),W(_0x2b9737(0x12a)),o()[_0x2b9737(0x168)](_0x2deead=>W('SSE\x20fatal:\x20'+_0x2deead)),Y(_0x2b9737(0x167),{'resume_id':K,'alias':G,'status':'idle','server':a0_0x224891(),'hostname':a0_0x224891(),'agent':_0x2b9737(0x19e),'project_dir':process['cwd'](),'tmux_name':f||void 0x0})['then'](()=>W(_0x2b9737(0x132)+G+_0x2b9737(0x11d)+K['slice'](0x0,0x8)+')'))[_0x2b9737(0x168)](_0x1e1056=>W(_0x2b9737(0x1a1)+_0x1e1056)),setInterval(()=>{const _0x4b1785=_0x2b9737;Y(_0x4b1785(0x167),{'resume_id':K,'alias':G,'status':_0x4b1785(0x1a7),'server':a0_0x224891(),'hostname':a0_0x224891(),'agent':_0x4b1785(0x19e),'project_dir':process['cwd'](),'tmux_name':f||void 0x0})[_0x4b1785(0x168)](_0x5a9af3=>W('heartbeat\x20failed:\x20'+_0x5a9af3));},0x2bf20),W(_0x2b9737(0x159));}n()[a0_0x428199(0x168)](_0x428e41=>{const _0x459451=a0_0x428199;W(_0x459451(0x1b2)+_0x428e41),process[_0x459451(0x1ad)](0x1);});async function b(){const _0x2d10cf=a0_0x428199;W(_0x2d10cf(0x16c)),await Y(_0x2d10cf(0x167),{'resume_id':K,'alias':G,'status':'offline','task':_0x2d10cf(0x130)})[_0x2d10cf(0x168)](()=>{}),process[_0x2d10cf(0x1ad)](0x0);}process['stdin']['on'](a0_0x428199(0x11f),()=>b()),process['on']('SIGTERM',()=>b()),process['on'](a0_0x428199(0x138),()=>b());
2
+ const a0_0x193669=a0_0x2430;(function(_0x593117,_0xa976d7){const _0x7bd123=a0_0x2430,_0x5da658=_0x593117();while(!![]){try{const _0x84ab2e=parseInt(_0x7bd123(0x1f3))/0x1*(parseInt(_0x7bd123(0x1c0))/0x2)+-parseInt(_0x7bd123(0x190))/0x3+-parseInt(_0x7bd123(0x1ea))/0x4+parseInt(_0x7bd123(0x19f))/0x5+-parseInt(_0x7bd123(0x1c7))/0x6*(-parseInt(_0x7bd123(0x20c))/0x7)+parseInt(_0x7bd123(0x1d3))/0x8*(parseInt(_0x7bd123(0x1be))/0x9)+-parseInt(_0x7bd123(0x1dc))/0xa;if(_0x84ab2e===_0xa976d7)break;else _0x5da658['push'](_0x5da658['shift']());}catch(_0x493ec9){_0x5da658['push'](_0x5da658['shift']());}}}(a0_0x2a6f,0x4f63c));import{readFileSync as a0_0x44c519,existsSync as a0_0x19da89}from'fs';import{randomUUID as a0_0x4968da}from'crypto';import{join as a0_0x1843f3}from'path';import{hostname as a0_0x4ad13a}from'os';import{execSync as a0_0x4a5f1d}from'child_process';import{Server as a0_0x2a8829}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport as a0_0x58076e}from'@modelcontextprotocol/sdk/server/stdio.js';import{ListToolsRequestSchema as a0_0x449c53,CallToolRequestSchema as a0_0x1520fd}from'@modelcontextprotocol/sdk/types.js';function I(_0x2ca5de){const _0x2e5a27=a0_0x2430;if(!a0_0x19da89(_0x2ca5de))return;for(let _0x908165 of a0_0x44c519(_0x2ca5de,'utf-8')[_0x2e5a27(0x1e6)]('\x0a')){let _0x3448a=_0x908165[_0x2e5a27(0x211)]();if(!_0x3448a||_0x3448a['startsWith']('#'))continue;let _0x5df3da=_0x3448a[_0x2e5a27(0x20e)]('=');if(_0x5df3da<0x0)continue;let _0x31dc80=_0x3448a[_0x2e5a27(0x1ab)](0x0,_0x5df3da)[_0x2e5a27(0x211)](),_0x35d471=_0x3448a[_0x2e5a27(0x1ab)](_0x5df3da+0x1)[_0x2e5a27(0x211)]()['replace'](/^["']|["']$/g,'');if(!process.env[_0x31dc80])process.env[_0x31dc80]=_0x35d471;}}var L=process.env.HOME||'~',U=a0_0x1843f3(L,a0_0x193669(0x1f0));I(a0_0x1843f3(U,a0_0x193669(0x1c1)));var v=process[a0_0x193669(0x19a)]()[a0_0x193669(0x1c3)](/\//g,'-');I(a0_0x1843f3(U,v,a0_0x193669(0x1c1)));function d(){const _0x3d9960=a0_0x193669;try{return a0_0x4a5f1d('tmux\x20display-message\x20-p\x20\x27#S\x27',{'encoding':_0x3d9960(0x19c),'timeout':0x7d0})['trim']();}catch{return'';}}function m(){const _0xb86702=a0_0x193669;try{let _0x2c700e=a0_0x1843f3(L,'.anet',_0xb86702(0x19b));if(a0_0x19da89(_0x2c700e))return JSON[_0xb86702(0x21e)](a0_0x44c519(_0x2c700e,_0xb86702(0x19c)));}catch{}return{};}var u=m(),j=process.env.COMMHUB_URL||u[a0_0x193669(0x217)]||a0_0x193669(0x1f2),f=process.env.COMMHUB_TMUX||d();function r(){const _0x146d32=a0_0x193669;if(process.env.COMMHUB_ALIAS&&process.env.COMMHUB_ALIAS[_0x146d32(0x211)]())return process.env.COMMHUB_ALIAS[_0x146d32(0x211)]();return process[_0x146d32(0x215)][_0x146d32(0x1fb)]('[commhub]\x20WARN:\x20COMMHUB_ALIAS\x20env\x20var\x20is\x20unset\x20—\x20outbound\x20from_session\x20'+('would\x20mis-attribute.\x20Refusing\x20to\x20guess\x20from\x20TMUX_NAME='+(f||_0x146d32(0x1f5))+_0x146d32(0x1ac)+a0_0x4ad13a()+'.\x20Restart\x20node\x20via\x20`anet\x20node\x20start\x20<alias>`\x20so\x20the\x20env\x20is\x20set\x20explicitly\x20(#203).\x0a')),'unattributed-'+process['pid'];}var G=r(),K=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||a0_0x4968da(),F=process.env.COMMHUB_TOKEN||u[a0_0x193669(0x1b9)]||'';function W(_0x59cf3d){const _0x300654=a0_0x193669;let _0x4f98e1=new Date()[_0x300654(0x1bc)]()[_0x300654(0x1ab)](0x0,0x8);process[_0x300654(0x215)][_0x300654(0x1fb)]('['+_0x4f98e1+_0x300654(0x1fd)+_0x59cf3d+'\x0a');}function a0_0x2430(_0x4b1b7f,_0x26d08c){_0x4b1b7f=_0x4b1b7f-0x18e;const _0x2a6fa3=a0_0x2a6f();let _0x2430c0=_0x2a6fa3[_0x4b1b7f];return _0x2430c0;}function N(_0x550ac0){return new Promise(_0x47cd66=>setTimeout(_0x47cd66,_0x550ac0));}W(a0_0x193669(0x1a7)+j+'\x20ALIAS='+G+'\x20RESUME_ID='+K[a0_0x193669(0x1ab)](0x0,0x8)+'...\x20TMUX='+(f||a0_0x193669(0x1ee))+a0_0x193669(0x1cc)+process[a0_0x193669(0x19a)]()+a0_0x193669(0x218)+v);var D=new Map(),x=new a0_0x2a8829({'name':'commhub-channel','version':a0_0x193669(0x210)},{'capabilities':{'experimental':{'claude/channel':{}},'tools':{}},'instructions':[a0_0x193669(0x196),a0_0x193669(0x1bd),a0_0x193669(0x1c4),'You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.',a0_0x193669(0x1e5)+G][a0_0x193669(0x208)]('\x0a')});function a0_0x2a6f(){const _0x156167=['stringify','new_message','2553060GLQrgK','Target\x20session\x20alias','commhub_get_all_status','SSE\x20stream\x20ended,\x20reconnecting...','shutting\x20down,\x20reporting\x20offline...','replied','message','registered\x20as\x20\x22','ENV:\x20URL=','setRequestHandler','Task\x20outcome:\x20completed/failed/cancelled\x20for\x20final\x20results,\x20blocked/error/in_progress\x20for\x20status\x20updates','connecting\x20to\x20','slice','\x20/\x20hostname=','Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.','completed','SSE\x20error:\x20','low','no\x20response','alias','blocked','data:\x20','text','fatal:\x20','params','commhub_report_status','token','object','priority','toTimeString','These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.','117Zqnabv','warning:\x20could\x20not\x20register:\x20','68754wDoSya','.env','Message\x20content','replace','Reply\x20using\x20the\x20commhub_reply\x20tool\x20to\x20report\x20status\x20or\x20results\x20back.','find','content','1211172CAhCtd','parse\x20error:\x20','startsWith','catch','commhub_send_message','\x20CWD=','offline','SSE\x20connected\x20as\x20\x22','stdin','inbox_count','unknown\x20tool','Current\x20task\x20description','299400qMUItP','from_session','commhub_send_task','decode','SSE\x20连续\x20>1h\x20连不上\x20hub\x20(','commhub','min','Bearer\x20','idle','4293020lxYKSl','Reply\x20to\x20a\x20CommHub\x20task\x20—\x20report\x20completion\x20or\x20send\x20a\x20message\x20back\x20to\x20the\x20hub.','commhub_reply','notification','commhub-channel','error','length','2.0','type','Session\x20alias:\x20','split','CommHub\x20init\x20failed:\x20','Reply\x20text\x20/\x20result\x20summary','cancelled','1828884FATaHN','MCP\x20stdio\x20connected','session\x20disconnected','exit','none','string','.claude/channels/commhub','statusText','http://127.0.0.1:9200','1CTmwyE','claude-code','(none)','in_progress','from','body','ack_inbox','task','write','SIGTERM',']\x20[commhub]\x20','The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)','new_task','status','ready\x20—\x20waiting\x20for\x20events','message_id',')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。','end','get_all_status','\x20from\x20',':\x20inbox_count=','join','tools/call','result','getReader','7HrRCHO','Task\x20content','indexOf','/mcp','0.3.0','trim','report_status','now','notifications/claude/channel','stderr','re-registered\x20as\x20\x22','hub','\x20PROJECT_ENV=','pop','connected','\x22\x20after\x20SSE\x20reconnect','set','broadcast','parse','delete','working','re-register\x20failed:\x20','application/json,\x20text/event-stream','connect','65019dTPoOM','normal','get_inbox','failed','Priority\x20(default:\x20normal)','starting\x20SSE\x20listener...','Messages\x20from\x20CommHub\x20arrive\x20as\x20<channel\x20source=\x22commhub\x22\x20task_id=\x22...\x22\x20priority=\x22...\x22\x20from=\x22...\x22>','Progress\x200-100','initialize','POST','cwd','config.json','utf-8'];a0_0x2a6f=function(){return _0x156167;};return a0_0x2a6f();}x[a0_0x193669(0x1a8)](a0_0x449c53,async()=>({'tools':[{'name':a0_0x193669(0x1de),'description':a0_0x193669(0x1dd),'inputSchema':{'type':a0_0x193669(0x1ba),'properties':{'task_id':{'type':a0_0x193669(0x1ef),'description':a0_0x193669(0x1fe)},'text':{'type':a0_0x193669(0x1ef),'description':a0_0x193669(0x1e8)},'status':{'type':a0_0x193669(0x1ef),'enum':[a0_0x193669(0x1ae),a0_0x193669(0x193),a0_0x193669(0x1e9),'blocked',a0_0x193669(0x1e1),a0_0x193669(0x1f6)],'description':a0_0x193669(0x1a9)}},'required':['text']}},{'name':a0_0x193669(0x1b8),'description':'Update\x20this\x20session\x27s\x20status\x20in\x20CommHub\x20(working/idle/blocked/error).\x20Returns\x20inbox_count.','inputSchema':{'type':a0_0x193669(0x1ba),'properties':{'status':{'type':a0_0x193669(0x1ef),'enum':['working','idle',a0_0x193669(0x1b3),a0_0x193669(0x1e1)]},'task':{'type':a0_0x193669(0x1ef),'description':a0_0x193669(0x1d2)},'progress':{'type':'number','description':a0_0x193669(0x197)}},'required':[a0_0x193669(0x200)]}},{'name':a0_0x193669(0x1d5),'description':a0_0x193669(0x1ad),'inputSchema':{'type':a0_0x193669(0x1ba),'properties':{'alias':{'type':'string','description':a0_0x193669(0x1a0)},'task':{'type':'string','description':a0_0x193669(0x20d)},'priority':{'type':a0_0x193669(0x1ef),'enum':['high','normal',a0_0x193669(0x1b0)],'description':a0_0x193669(0x194)}},'required':[a0_0x193669(0x1b2),a0_0x193669(0x1fa)]}},{'name':'commhub_send_message','description':'Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.','inputSchema':{'type':'object','properties':{'alias':{'type':a0_0x193669(0x1ef),'description':a0_0x193669(0x1a0)},'message':{'type':a0_0x193669(0x1ef),'description':a0_0x193669(0x1c2)}},'required':[a0_0x193669(0x1b2),a0_0x193669(0x1a5)]}},{'name':a0_0x193669(0x1a1),'description':'Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','inputSchema':{'type':a0_0x193669(0x1ba),'properties':{}}}]}));async function Y(_0x168976,_0x124495){const _0x5b522e=a0_0x193669;let _0x2470ce=await fetch(j+_0x5b522e(0x20f),{'method':_0x5b522e(0x199),'headers':{'Content-Type':'application/json','Accept':_0x5b522e(0x18e),...F?{'Authorization':_0x5b522e(0x1da)+F}:{}},'body':JSON['stringify']({'jsonrpc':'2.0','id':0x1,'method':_0x5b522e(0x198),'params':{'protocolVersion':'2025-03-26','capabilities':{},'clientInfo':{'name':_0x5b522e(0x1e0),'version':_0x5b522e(0x210)}}})});if(!_0x2470ce['ok']){let _0x43c200=await _0x2470ce[_0x5b522e(0x1b5)]();return W(_0x5b522e(0x1e7)+_0x2470ce[_0x5b522e(0x200)]+'\x20'+_0x43c200['slice'](0x0,0x64)),{'ok':!0x1,'error':'init\x20failed:\x20'+_0x2470ce[_0x5b522e(0x200)]};}await _0x2470ce[_0x5b522e(0x1b5)]();let _0x5af720=(await(await fetch(j+_0x5b522e(0x20f),{'method':_0x5b522e(0x199),'headers':{'Content-Type':'application/json','Accept':_0x5b522e(0x18e),...F?{'Authorization':_0x5b522e(0x1da)+F}:{}},'body':JSON[_0x5b522e(0x19d)]({'jsonrpc':_0x5b522e(0x1e3),'id':0x2,'method':_0x5b522e(0x209),'params':{'name':_0x168976,'arguments':_0x124495}})}))[_0x5b522e(0x1b5)]())[_0x5b522e(0x1e6)]('\x0a')[_0x5b522e(0x1c5)](_0x4f6d24=>_0x4f6d24[_0x5b522e(0x1c9)](_0x5b522e(0x1b4)));if(_0x5af720){let _0x4d72bd=JSON[_0x5b522e(0x21e)](_0x5af720[_0x5b522e(0x1ab)](0x6));return _0x4d72bd?.['result']?.['content']?.[0x0]?.['text']?JSON[_0x5b522e(0x21e)](_0x4d72bd[_0x5b522e(0x20a)][_0x5b522e(0x1c6)][0x0][_0x5b522e(0x1b5)]):_0x4d72bd;}return{'ok':!0x1,'error':_0x5b522e(0x1b1)};}x[a0_0x193669(0x1a8)](a0_0x1520fd,async _0x244963=>{const _0x778788=a0_0x193669;let {name:_0x48f7e9,arguments:_0x1639fe}=_0x244963[_0x778788(0x1b7)];if(_0x48f7e9===_0x778788(0x1de)){let {task_id:_0x187c97,text:_0x6adb20,status:_0x59f23f}=_0x1639fe;if(_0x59f23f===_0x778788(0x1ae)||_0x59f23f===_0x778788(0x193)||_0x59f23f==='cancelled'){let _0x31028a=_0x59f23f===_0x778788(0x1ae)?_0x778788(0x1a4):_0x59f23f,_0x37db71=_0x187c97?D['get'](_0x187c97)||_0x778788(0x217):_0x778788(0x217),_0x520dd7=await Y('send_reply',{'alias':_0x37db71,'text':_0x6adb20,'in_reply_to':_0x187c97||void 0x0,'status':_0x31028a,'from_session':G});if(_0x187c97)D[_0x778788(0x21f)](_0x187c97);return{'content':[{'type':_0x778788(0x1b5),'text':JSON['stringify'](_0x520dd7)}]};}let _0x163b96=await Y(_0x778788(0x212),{'resume_id':K,'alias':G,'status':_0x59f23f===_0x778788(0x1b3)?_0x778788(0x1b3):_0x59f23f===_0x778788(0x1e1)?'error':_0x778788(0x220),'task':_0x6adb20[_0x778788(0x1ab)](0x0,0xc8),'output':_0x6adb20});return{'content':[{'type':_0x778788(0x1b5),'text':JSON['stringify'](_0x163b96)}]};}if(_0x48f7e9==='commhub_report_status'){let {status:_0x5dac0d,task:_0x3236a8,progress:_0xc33f86}=_0x1639fe,_0x218117=await Y(_0x778788(0x212),{'resume_id':K,'alias':G,'status':_0x5dac0d,'task':_0x3236a8,'progress':_0xc33f86});return{'content':[{'type':_0x778788(0x1b5),'text':JSON[_0x778788(0x19d)](_0x218117)}]};}if(_0x48f7e9===_0x778788(0x1d5)){let {alias:_0x6cb6b8,task:_0x176a6a,priority:_0x305b0e}=_0x1639fe,_0x3cac46=await Y('send_task',{'alias':_0x6cb6b8,'task':_0x176a6a,'priority':_0x305b0e||_0x778788(0x191),'from_session':G});return{'content':[{'type':_0x778788(0x1b5),'text':JSON[_0x778788(0x19d)](_0x3cac46)}]};}if(_0x48f7e9===_0x778788(0x1cb)){let {alias:_0x1c102f,message:_0xed3ef7}=_0x1639fe,_0x59f59e=await Y('send_message',{'alias':_0x1c102f,'message':_0xed3ef7,'from_session':G});return{'content':[{'type':_0x778788(0x1b5),'text':JSON[_0x778788(0x19d)](_0x59f59e)}]};}if(_0x48f7e9===_0x778788(0x1a1)){let _0x4e0c26=await Y(_0x778788(0x205),{});return{'content':[{'type':_0x778788(0x1b5),'text':JSON[_0x778788(0x19d)](_0x4e0c26)}]};}return{'content':[{'type':_0x778788(0x1b5),'text':JSON['stringify']({'error':_0x778788(0x1d1)})}]};});var O=0x3e8,R=0x7530,T=0x36ee80;async function l(){const _0x33edc8=a0_0x193669;try{await Y(_0x33edc8(0x212),{'resume_id':K,'alias':G,'status':'idle','server':a0_0x4ad13a(),'hostname':a0_0x4ad13a(),'agent':_0x33edc8(0x1f4),'project_dir':process[_0x33edc8(0x19a)](),'tmux_name':f||void 0x0}),W(_0x33edc8(0x216)+G+_0x33edc8(0x21b));}catch(_0x597ba7){W(_0x33edc8(0x221)+_0x597ba7);}}async function o(){const _0x1b9c74=a0_0x193669;let _0x54d47c=j+'/events/'+encodeURIComponent(G),_0x472a59={};if(F)_0x472a59['Authorization']=_0x1b9c74(0x1da)+F;W(_0x1b9c74(0x1aa)+_0x54d47c);let _0x2730b0=O,_0x3c5e4b=!0x0,_0x788c4e=null;while(!0x0){try{let _0x4e6f39=await fetch(_0x54d47c,{'headers':_0x472a59});if(!_0x4e6f39['ok']){if(W(_0x1b9c74(0x1af)+_0x4e6f39[_0x1b9c74(0x200)]+'\x20'+_0x4e6f39[_0x1b9c74(0x1f1)]),_0x788c4e=_0x788c4e??Date['now'](),Date[_0x1b9c74(0x213)]()-_0x788c4e>T){W(_0x1b9c74(0x1d7)+j+_0x1b9c74(0x203));return;}await N(_0x2730b0),_0x2730b0=Math[_0x1b9c74(0x1d9)](_0x2730b0*0x2,R);continue;}let _0x1958c6=_0x4e6f39[_0x1b9c74(0x1f8)][_0x1b9c74(0x20b)](),_0x50f421=new TextDecoder(),_0x54c148='';_0x2730b0=O;while(!0x0){let {done:_0x27b274,value:_0xd8f27f}=await _0x1958c6['read']();if(_0x27b274)break;_0x54c148+=_0x50f421[_0x1b9c74(0x1d6)](_0xd8f27f,{'stream':!0x0});let _0xbd4b97=_0x54c148[_0x1b9c74(0x1e6)]('\x0a\x0a');_0x54c148=_0xbd4b97[_0x1b9c74(0x219)]()||'';for(let _0x31f2d2 of _0xbd4b97){let _0x47f9eb=_0x31f2d2[_0x1b9c74(0x1e6)]('\x0a')['find'](_0x22f8ca=>_0x22f8ca['startsWith'](_0x1b9c74(0x1b4)));if(!_0x47f9eb)continue;try{let _0x4752d0=JSON['parse'](_0x47f9eb[_0x1b9c74(0x1ab)](0x6));if(await a(_0x4752d0),_0x4752d0[_0x1b9c74(0x1e4)]===_0x1b9c74(0x21a)){if(_0x788c4e=null,!_0x3c5e4b)await l();_0x3c5e4b=!0x1;}}catch(_0x437e2e){W(_0x1b9c74(0x1c8)+_0x437e2e);}}}W(_0x1b9c74(0x1a2));}catch(_0x35991c){W('SSE\x20connection\x20error:\x20'+_0x35991c);}if(_0x788c4e=_0x788c4e??Date[_0x1b9c74(0x213)](),Date['now']()-_0x788c4e>T){W(_0x1b9c74(0x1d7)+j+')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。');return;}await N(_0x2730b0),_0x2730b0=Math[_0x1b9c74(0x1d9)](_0x2730b0*0x2,R);}}async function a(_0x32771b){const _0x5978c7=a0_0x193669;if(_0x32771b['type']==='connected'){W(_0x5978c7(0x1ce)+G+'\x22');return;}if(_0x32771b[_0x5978c7(0x1e4)]===_0x5978c7(0x19e)){if(W('←\x20message\x20from\x20'+_0x32771b[_0x5978c7(0x1f7)]+':\x20'+_0x32771b[_0x5978c7(0x1a5)][_0x5978c7(0x1ab)](0x0,0x3c)),await x[_0x5978c7(0x1df)]({'method':_0x5978c7(0x214),'params':{'content':_0x32771b['message'],'meta':{'sender':_0x32771b[_0x5978c7(0x1f7)]||_0x5978c7(0x217),'sender_id':_0x5978c7(0x1d8),'user':_0x32771b[_0x5978c7(0x1f7)]||_0x5978c7(0x217),'priority':_0x5978c7(0x191)}}}),_0x32771b[_0x5978c7(0x202)])await Y(_0x5978c7(0x1f9),{'alias':G,'message_id':_0x32771b[_0x5978c7(0x202)]});return;}if(_0x32771b[_0x5978c7(0x1e4)]===_0x5978c7(0x1ff)||_0x32771b[_0x5978c7(0x1e4)]===_0x5978c7(0x21d)){W('←\x20'+_0x32771b['type']+_0x5978c7(0x207)+_0x32771b[_0x5978c7(0x1d0)]+'\x20priority='+(_0x32771b[_0x5978c7(0x1bb)]||_0x5978c7(0x191)));let _0x15e15b=await Y(_0x5978c7(0x192),{'alias':G,'limit':0x5});if(_0x15e15b?.['ok']&&_0x15e15b['messages']?.[_0x5978c7(0x1e2)]>0x0)for(let _0x1be1f6 of _0x15e15b['messages']){let _0x528625={'sender':_0x1be1f6['from_session']||'hub','sender_id':_0x5978c7(0x1d8),'user':_0x1be1f6[_0x5978c7(0x1d4)]||_0x5978c7(0x217),'task_id':_0x1be1f6['id'],'priority':_0x1be1f6['priority']||_0x5978c7(0x191)};D[_0x5978c7(0x21c)](_0x1be1f6['id'],_0x1be1f6['from_session']||_0x5978c7(0x217)),await x[_0x5978c7(0x1df)]({'method':_0x5978c7(0x214),'params':{'content':_0x1be1f6[_0x5978c7(0x1c6)],'meta':_0x528625}}),W('→\x20injected\x20task\x20'+_0x1be1f6['id'][_0x5978c7(0x1ab)](0x0,0x8)+_0x5978c7(0x206)+_0x1be1f6[_0x5978c7(0x1d4)]+':\x20'+_0x1be1f6[_0x5978c7(0x1c6)][_0x5978c7(0x1ab)](0x0,0x3c)),await Y(_0x5978c7(0x1f9),{'alias':G,'message_id':_0x1be1f6['id']});}}}async function n(){const _0x602df3=a0_0x193669;let _0x3540b6=new a0_0x58076e();await x[_0x602df3(0x18f)](_0x3540b6),W(_0x602df3(0x1eb)),W(_0x602df3(0x195)),o()['catch'](_0x45a77a=>W('SSE\x20fatal:\x20'+_0x45a77a)),Y(_0x602df3(0x212),{'resume_id':K,'alias':G,'status':_0x602df3(0x1db),'server':a0_0x4ad13a(),'hostname':a0_0x4ad13a(),'agent':_0x602df3(0x1f4),'project_dir':process[_0x602df3(0x19a)](),'tmux_name':f||void 0x0})['then'](()=>W(_0x602df3(0x1a6)+G+'\x22\x20('+K['slice'](0x0,0x8)+')'))[_0x602df3(0x1ca)](_0x6addf4=>W(_0x602df3(0x1bf)+_0x6addf4)),setInterval(()=>{const _0x2fab15=_0x602df3;Y(_0x2fab15(0x212),{'resume_id':K,'alias':G,'status':_0x2fab15(0x1db),'server':a0_0x4ad13a(),'hostname':a0_0x4ad13a(),'agent':'claude-code','project_dir':process['cwd'](),'tmux_name':f||void 0x0})[_0x2fab15(0x1ca)](_0x27cc4b=>W('heartbeat\x20failed:\x20'+_0x27cc4b));},0x2bf20),W(_0x602df3(0x201));}n()[a0_0x193669(0x1ca)](_0x583d21=>{const _0x1833cf=a0_0x193669;W(_0x1833cf(0x1b6)+_0x583d21),process[_0x1833cf(0x1ed)](0x1);});async function b(){const _0x25c833=a0_0x193669;W(_0x25c833(0x1a3)),await Y(_0x25c833(0x212),{'resume_id':K,'alias':G,'status':_0x25c833(0x1cd),'task':_0x25c833(0x1ec)})[_0x25c833(0x1ca)](()=>{}),process[_0x25c833(0x1ed)](0x0);}process[a0_0x193669(0x1cf)]['on'](a0_0x193669(0x204),()=>b()),process['on'](a0_0x193669(0x1fc),()=>b()),process['on']('SIGINT',()=>b());
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Per-iteration controller passed into `runOnce`. Today exposes only
3
+ * `markStable`; a future stop-the-current-iteration affordance would
4
+ * be a sibling field on this interface.
5
+ */
6
+ export interface SupervisedIterationController {
7
+ /**
8
+ * Signal that this iteration crossed the "actually working" threshold.
9
+ * Resets the backoff to `baseDelayMs` and zeroes the cumulative
10
+ * downtime counter. Safe to call multiple times per iteration — only
11
+ * the first call has effect within a single iteration.
12
+ */
13
+ markStable(): void;
14
+ }
15
+ export interface SuperviseChildOpts {
16
+ /** Short label for log / error messages. e.g. "feishu" / "sse". */
17
+ label: string;
18
+ /** Returns true when the supervisor should stop without rescheduling. */
19
+ shutdownGate: () => boolean;
20
+ /**
21
+ * One iteration of the supervised child. Resolves when the iteration
22
+ * ends (child exits / stream closes); throws to log + reschedule.
23
+ * Receives a controller for the iteration to call `markStable` on
24
+ * once the work crosses its "really working" threshold.
25
+ */
26
+ runOnce: (ctrl: SupervisedIterationController) => Promise<void>;
27
+ /** Initial backoff delay in ms. Default 1_000. */
28
+ baseDelayMs?: number;
29
+ /** Maximum backoff after exponential growth. Default 30_000. */
30
+ maxDelayMs?: number;
31
+ /**
32
+ * Jitter ratio (±N×delay). Default 0.25 (±25%). Set 0 to disable.
33
+ * The waited time per backoff is `max(100, delay + delay * jitter *
34
+ * (Math.random() * 2 - 1))`.
35
+ */
36
+ jitterRatio?: number;
37
+ /**
38
+ * If cumulative downtime (consecutive iterations that did NOT call
39
+ * markStable, plus their inter-iteration sleeps) exceeds this, the
40
+ * supervisor invokes `onAbandon` and returns. Default `Infinity`
41
+ * (never abandon). Set to a finite value (e.g. 3_600_000 = 1 h) to
42
+ * give up after a long unsuccessful run.
43
+ */
44
+ abandonAfterMs?: number;
45
+ /** Called once if the supervisor abandons. */
46
+ onAbandon?: () => void;
47
+ /** Called with the runOnce error before scheduling the next iteration. */
48
+ onError?: (err: unknown) => void;
49
+ /** Called before sleeping with the resolved backoff (and the jittered wait). */
50
+ onRetryWait?: (waitMs: number, backoffMs: number) => void;
51
+ /**
52
+ * Sleep primitive — overridden by tests to skip real timers. Default
53
+ * uses `setTimeout`. Must respect `ms <= 0` as "no wait".
54
+ */
55
+ sleep?: (ms: number) => Promise<void>;
56
+ /**
57
+ * Random source — overridden by tests for deterministic jitter.
58
+ * Default `Math.random`.
59
+ */
60
+ random?: () => number;
61
+ /** Current-time source — overridden by tests. Default `Date.now`. */
62
+ now?: () => number;
63
+ }
64
+ /**
65
+ * Run the supervisor loop. Resolves when the shutdown gate triggers or
66
+ * the abandon threshold fires; never throws (runOnce errors are routed
67
+ * to `onError`).
68
+ */
69
+ export declare function superviseChild(opts: SuperviseChildOpts): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sleep2agi/agent-network",
3
- "version": "2.3.0-preview.0",
3
+ "version": "2.3.0-preview.2",
4
4
  "description": "AI Agent Network CLI \u2014 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",