@sleep2agi/agent-network
Advanced tools
@@ -1,1 +0,1 @@ | ||
| function a0_0x855f(_0x39248a,_0x4f8b92){_0x39248a=_0x39248a-0x17e;const _0x1fdedc=a0_0x1fde();let _0x855f3a=_0x1fdedc[_0x39248a];return _0x855f3a;}const a0_0x4d231b=a0_0x855f;function a0_0x1fde(){const _0x6156d4=['1284230tDpjGQ','send','4054gZjmun','new_message','token','12sHOfGT','replace','application/json,\x20text/event-stream','name','content','510fdmlNL','completed','signal','startsWith','send_task','sdk-','url','decode','connected','alias','cwd','idle','SSE\x20failed:\x20','SSE\x20error:\x20','reconnectDelay','tools/call','report_status','203291GZjLqV','1420065tZtERR','body','POST','s...','292812gmjImy','sseAbort','emit','connect',']\x20[commhub:','Bearer\x20','180AKOQIx','Authorization','parse','normal','error','327072wpmrft','reply','sleep','status','text','toString','text/event-stream','heartbeatTimer','min','ack_inbox','/events/','387qyGICo','autoConnect','log','message','read','send_message','disconnect','pop','broadcast','agent','catch','abort','running','18GuMYSJ','type','connectSSE','getReader','data:\x20','server','get_inbox','registered','offline','slice','new_task','455xtKROn','call','disconnected','heartbeatInterval','split','messages','sdk','task','match','resumeId','processInbox','1860873HDbrtt','/mcp'];a0_0x1fde=function(){return _0x6156d4;};return a0_0x1fde();}(function(_0x69f157,_0x34d6a8){const _0x16a939=a0_0x855f,_0x43f872=_0x69f157();while(!![]){try{const _0x163c93=parseInt(_0x16a939(0x18e))/0x1*(parseInt(_0x16a939(0x1b5))/0x2)+parseInt(_0x16a939(0x1cf))/0x3+parseInt(_0x16a939(0x1b8))/0x4*(parseInt(_0x16a939(0x1b3))/0x5)+-parseInt(_0x16a939(0x19b))/0x6*(parseInt(_0x16a939(0x1b1))/0x7)+parseInt(_0x16a939(0x183))/0x8*(-parseInt(_0x16a939(0x17e))/0x9)+parseInt(_0x16a939(0x1bd))/0xa*(parseInt(_0x16a939(0x1ce))/0xb)+-parseInt(_0x16a939(0x1d3))/0xc*(parseInt(_0x16a939(0x1a6))/0xd);if(_0x163c93===_0x34d6a8)break;else _0x43f872['push'](_0x43f872['shift']());}catch(_0xff4c24){_0x43f872['push'](_0x43f872['shift']());}}}(a0_0x1fde,0x7a789));import{EventEmitter as a0_0x124210}from'events';import{hostname as a0_0x4fa072}from'os';class T extends a0_0x124210{[a0_0x4d231b(0x1c3)];[a0_0x4d231b(0x1c6)];[a0_0x4d231b(0x1b7)];[a0_0x4d231b(0x197)];[a0_0x4d231b(0x1af)];[a0_0x4d231b(0x1a9)];[a0_0x4d231b(0x1cb)];[a0_0x4d231b(0x18a)];[a0_0x4d231b(0x1d4)];[a0_0x4d231b(0x19a)]=!0x1;constructor(_0x378de7){const _0x3e0180=a0_0x4d231b;super();if(this[_0x3e0180(0x1c3)]=_0x378de7[_0x3e0180(0x1c3)][_0x3e0180(0x1b9)](/\/$/,''),this[_0x3e0180(0x1c6)]=_0x378de7[_0x3e0180(0x1c6)],this[_0x3e0180(0x1b7)]=_0x378de7[_0x3e0180(0x1b7)],this['agent']=_0x378de7[_0x3e0180(0x197)]||_0x3e0180(0x1ac),this[_0x3e0180(0x1af)]=_0x3e0180(0x1c2)+_0x378de7[_0x3e0180(0x1c6)]+'-'+Date['now']()[_0x3e0180(0x188)](0x24),this[_0x3e0180(0x1a9)]=_0x378de7[_0x3e0180(0x1a9)]??0x2bf20,this[_0x3e0180(0x1cb)]=_0x378de7['reconnectDelay']??0xbb8,_0x378de7[_0x3e0180(0x18f)]!==!0x1)this[_0x3e0180(0x1d6)]();}[a0_0x4d231b(0x190)](_0x1bcd5e){const _0x1c84f5=a0_0x4d231b;console['log']('['+new Date()['toTimeString']()[_0x1c84f5(0x1a4)](0x0,0x8)+_0x1c84f5(0x1d7)+this['alias']+']\x20'+_0x1bcd5e);}async['call'](_0x2c471f,_0x1d8c39){const _0x3f9e56=a0_0x4d231b;let _0x11ef76={'Content-Type':'application/json','Accept':_0x3f9e56(0x1ba)};if(this['token'])_0x11ef76[_0x3f9e56(0x17f)]=_0x3f9e56(0x1d8)+this[_0x3f9e56(0x1b7)];let _0x32392e=await(await fetch(this[_0x3f9e56(0x1c3)]+_0x3f9e56(0x1b2),{'method':_0x3f9e56(0x1d1),'headers':_0x11ef76,'body':JSON['stringify']({'jsonrpc':'2.0','id':Date['now'](),'method':_0x3f9e56(0x1cc),'params':{'name':_0x2c471f,'arguments':_0x1d8c39}})}))['text'](),_0x4a9b2d=_0x32392e[_0x3f9e56(0x1ae)](/data: (.+)/),_0x29381a=_0x4a9b2d?JSON['parse'](_0x4a9b2d[0x1]):JSON[_0x3f9e56(0x180)](_0x32392e),_0x40fe30=_0x29381a?.['result']?.['content']?.[0x0]?.[_0x3f9e56(0x187)];return _0x40fe30?JSON[_0x3f9e56(0x180)](_0x40fe30):_0x29381a;}async[a0_0x4d231b(0x1d6)](){const _0x490e88=a0_0x4d231b;if(this[_0x490e88(0x19a)])return;this[_0x490e88(0x19a)]=!0x0,await this[_0x490e88(0x186)](_0x490e88(0x1c8)),this[_0x490e88(0x190)](_0x490e88(0x1a2)),this['heartbeatTimer']=setInterval(()=>{const _0x323a3d=_0x490e88;this[_0x323a3d(0x186)](_0x323a3d(0x1c8))[_0x323a3d(0x198)](_0x2688bf=>this['log']('heartbeat\x20failed:\x20'+_0x2688bf[_0x323a3d(0x191)]));},this[_0x490e88(0x1a9)]),this[_0x490e88(0x19d)]();}async[a0_0x4d231b(0x194)](){const _0x48dfe2=a0_0x4d231b;if(this[_0x48dfe2(0x19a)]=!0x1,this['sseAbort']?.[_0x48dfe2(0x199)](),this['heartbeatTimer'])clearInterval(this[_0x48dfe2(0x18a)]);await this['status'](_0x48dfe2(0x1a3))['catch'](()=>{}),this[_0x48dfe2(0x190)](_0x48dfe2(0x1a8));}async[a0_0x4d231b(0x1b4)](_0x3e0fac,_0x58ed5e,_0x2a11e7=a0_0x4d231b(0x181)){const _0x32dbcc=a0_0x4d231b;return this[_0x32dbcc(0x1a7)](_0x32dbcc(0x1c1),{'alias':_0x3e0fac,'task':_0x58ed5e,'priority':_0x2a11e7,'from_session':this['alias']});}async[a0_0x4d231b(0x191)](_0x78ee4d,_0x4cd5f2){const _0x42f76f=a0_0x4d231b;return this[_0x42f76f(0x1a7)](_0x42f76f(0x193),{'alias':_0x78ee4d,'message':_0x4cd5f2,'from_session':this[_0x42f76f(0x1c6)]});}async[a0_0x4d231b(0x184)](_0x4ac7fd,_0x4eaf65,_0x4d2158=a0_0x4d231b(0x1be)){const _0x9807bc=a0_0x4d231b;return this[_0x9807bc(0x1a7)]('send_reply',{'in_reply_to':_0x4ac7fd,'text':_0x4eaf65,'status':_0x4d2158});}async[a0_0x4d231b(0x186)](_0x2a2d4a,_0x33278e){const _0x9d60a7=a0_0x4d231b;return this[_0x9d60a7(0x1a7)](_0x9d60a7(0x1cd),{'resume_id':this[_0x9d60a7(0x1af)],'alias':this[_0x9d60a7(0x1c6)],'status':_0x2a2d4a,'server':a0_0x4fa072(),'hostname':a0_0x4fa072(),'agent':this[_0x9d60a7(0x197)],'project_dir':process[_0x9d60a7(0x1c7)](),..._0x33278e});}async['getAllStatus'](){const _0x4a2eae=a0_0x4d231b;return this[_0x4a2eae(0x1a7)]('get_all_status',{});}async[a0_0x4d231b(0x196)](_0x2c4132,_0x1b73f1){const _0x1d63a4=a0_0x4d231b;return this['call'](_0x1d63a4(0x196),{'message':_0x2c4132,'filter_server':_0x1b73f1?.[_0x1d63a4(0x1a0)],'filter_status':_0x1b73f1?.[_0x1d63a4(0x186)]});}async['connectSSE'](){const _0x1cc7a5=a0_0x4d231b;let _0x4667ef=encodeURIComponent(this[_0x1cc7a5(0x1c6)]),_0x493abb=this['url']+_0x1cc7a5(0x18d)+_0x4667ef,_0xcdf218=this[_0x1cc7a5(0x1cb)];while(this[_0x1cc7a5(0x19a)]){try{this[_0x1cc7a5(0x1d4)]=new AbortController();let _0x11a55a={'Accept':_0x1cc7a5(0x189)};if(this[_0x1cc7a5(0x1b7)])_0x11a55a['Authorization']=_0x1cc7a5(0x1d8)+this['token'];let _0x21e48a=await fetch(_0x493abb,{'headers':_0x11a55a,'signal':this['sseAbort'][_0x1cc7a5(0x1bf)]});if(!_0x21e48a['ok']||!_0x21e48a['body']){this[_0x1cc7a5(0x190)](_0x1cc7a5(0x1c9)+_0x21e48a['status']),await this[_0x1cc7a5(0x185)](_0xcdf218),_0xcdf218=Math[_0x1cc7a5(0x18b)](_0xcdf218*1.5,0xea60);continue;}_0xcdf218=this['reconnectDelay'];let _0x1aa8d2=_0x21e48a[_0x1cc7a5(0x1d0)][_0x1cc7a5(0x19e)](),_0x5c90d3=new TextDecoder(),_0x3ad1a8='';while(this[_0x1cc7a5(0x19a)]){let {done:_0x21a8a7,value:_0x2f9942}=await _0x1aa8d2[_0x1cc7a5(0x192)]();if(_0x21a8a7)break;_0x3ad1a8+=_0x5c90d3[_0x1cc7a5(0x1c4)](_0x2f9942,{'stream':!0x0});let _0x564e1a=_0x3ad1a8[_0x1cc7a5(0x1aa)]('\x0a');_0x3ad1a8=_0x564e1a[_0x1cc7a5(0x195)]()||'';for(let _0x527343 of _0x564e1a){if(!_0x527343[_0x1cc7a5(0x1c0)](_0x1cc7a5(0x19f)))continue;try{let _0x15a837=JSON['parse'](_0x527343[_0x1cc7a5(0x1a4)](0x6));if(_0x15a837['type']===_0x1cc7a5(0x1c5)){this['log']('SSE\x20connected'),this[_0x1cc7a5(0x1d5)]('connected');continue;}if(_0x15a837[_0x1cc7a5(0x19c)]===_0x1cc7a5(0x1a5)||_0x15a837[_0x1cc7a5(0x19c)]===_0x1cc7a5(0x1b6)||_0x15a837[_0x1cc7a5(0x19c)]===_0x1cc7a5(0x196))await this['processInbox']();}catch{}}}}catch(_0x511634){if(_0x511634[_0x1cc7a5(0x1bb)]==='AbortError')break;this[_0x1cc7a5(0x1d5)](_0x1cc7a5(0x182),_0x511634),this['log'](_0x1cc7a5(0x1ca)+_0x511634['message']);}if(this[_0x1cc7a5(0x19a)])this[_0x1cc7a5(0x1d5)]('disconnected'),this['log']('SSE\x20reconnecting\x20in\x20'+_0xcdf218/0x3e8+_0x1cc7a5(0x1d2)),await this[_0x1cc7a5(0x185)](_0xcdf218),_0xcdf218=Math[_0x1cc7a5(0x18b)](_0xcdf218*1.5,0xea60);}}async[a0_0x4d231b(0x1b0)](){const _0x3f29f2=a0_0x4d231b;try{let _0x203ada=(await this[_0x3f29f2(0x1a7)](_0x3f29f2(0x1a1),{'alias':this[_0x3f29f2(0x1c6)],'limit':0xa}))?.[_0x3f29f2(0x1ab)]||[];for(let _0x12737f of _0x203ada)await this['call'](_0x3f29f2(0x18c),{'alias':this[_0x3f29f2(0x1c6)],'message_id':_0x12737f['id']}),this['log']('←\x20'+_0x12737f['from_session']+':\x20'+_0x12737f[_0x3f29f2(0x1bc)]['slice'](0x0,0x3c)),this['emit'](_0x3f29f2(0x1ad),_0x12737f),this[_0x3f29f2(0x1d5)](_0x3f29f2(0x191),_0x12737f);}catch(_0x2e2065){this[_0x3f29f2(0x190)]('inbox\x20error:\x20'+_0x2e2065['message']);}}[a0_0x4d231b(0x185)](_0x1b81ae){return new Promise(_0x12eb0d=>setTimeout(_0x12eb0d,_0x1b81ae));}}var $=T;export{$ as default,T as CommHub}; | ||
| function a0_0x6de1(_0x4e3e59,_0x1b9c4f){_0x4e3e59=_0x4e3e59-0xea;const _0x40fe82=a0_0x40fe();let _0x6de1e1=_0x40fe82[_0x4e3e59];return _0x6de1e1;}const a0_0x230d08=a0_0x6de1;function a0_0x40fe(){const _0x14968a=['url','slice','parse','new_task','sseAbort','text/event-stream','report_status','replace','emit','type','4091458iZWsQm','toTimeString','144765bkuQHm','/events/','catch','heartbeatInterval','getAllStatus','24726GPhIpb','token','connectSSE','520RwIKTP','running','10BPzsZx','signal','reconnectDelay','15568289UrBTPk','SSE\x20failed:\x20','new_message','disconnect','startsWith','text','5490CuQXkh','error','decode','Bearer\x20','get_inbox','s...','695eQhJwC','stringify','content','log','connected',']\x20[commhub:','now','task','sdk','normal','processInbox','sdk-','cwd','Authorization','min','agent','heartbeat\x20failed:\x20','message','get_all_status','status','pop','inbox\x20error:\x20','autoConnect','2.0','application/json,\x20text/event-stream','SSE\x20connected','connect','514lHxAnX','send_message','resumeId','call','disconnected','3430986Elwrzi','5313740UULazF','/mcp','send','getReader','reply','tools/call','alias','body','messages','ack_inbox','name','data:\x20','heartbeatTimer','read','broadcast','server','sleep','send_reply'];a0_0x40fe=function(){return _0x14968a;};return a0_0x40fe();}(function(_0x6bcbe2,_0x394dd0){const _0x28270e=a0_0x6de1,_0x11eb5c=_0x6bcbe2();while(!![]){try{const _0x3862fd=parseInt(_0x28270e(0x131))/0x1*(-parseInt(_0x28270e(0xfa))/0x2)+parseInt(_0x28270e(0xff))/0x3+-parseInt(_0x28270e(0x100))/0x4+parseInt(_0x28270e(0x137))/0x5*(-parseInt(_0x28270e(0x123))/0x6)+parseInt(_0x28270e(0x11c))/0x7+-parseInt(_0x28270e(0x126))/0x8*(-parseInt(_0x28270e(0x11e))/0x9)+parseInt(_0x28270e(0x128))/0xa*(parseInt(_0x28270e(0x12b))/0xb);if(_0x3862fd===_0x394dd0)break;else _0x11eb5c['push'](_0x11eb5c['shift']());}catch(_0x2fac3a){_0x11eb5c['push'](_0x11eb5c['shift']());}}}(a0_0x40fe,0xd60fc));import{EventEmitter as a0_0x5ce8b4}from'events';import{hostname as a0_0x37fdd8}from'os';class T extends a0_0x5ce8b4{[a0_0x230d08(0x112)];[a0_0x230d08(0x106)];[a0_0x230d08(0x124)];[a0_0x230d08(0xee)];['resumeId'];[a0_0x230d08(0x121)];[a0_0x230d08(0x12a)];[a0_0x230d08(0x10c)];['sseAbort'];[a0_0x230d08(0x127)]=!0x1;constructor(_0x5bc09d){const _0x5c0a7b=a0_0x230d08;super();if(this[_0x5c0a7b(0x112)]=_0x5bc09d[_0x5c0a7b(0x112)][_0x5c0a7b(0x119)](/\/$/,''),this[_0x5c0a7b(0x106)]=_0x5bc09d[_0x5c0a7b(0x106)],this[_0x5c0a7b(0x124)]=_0x5bc09d['token'],this[_0x5c0a7b(0xee)]=_0x5bc09d['agent']||_0x5c0a7b(0x13f),this[_0x5c0a7b(0xfc)]=_0x5c0a7b(0xea)+_0x5bc09d[_0x5c0a7b(0x106)]+'-'+Date[_0x5c0a7b(0x13d)]()['toString'](0x24),this[_0x5c0a7b(0x121)]=_0x5bc09d[_0x5c0a7b(0x121)]??0x2bf20,this[_0x5c0a7b(0x12a)]=_0x5bc09d[_0x5c0a7b(0x12a)]??0xbb8,_0x5bc09d[_0x5c0a7b(0xf5)]!==!0x1)this[_0x5c0a7b(0xf9)]();}[a0_0x230d08(0x13a)](_0x1f9b0e){const _0x275549=a0_0x230d08;console[_0x275549(0x13a)]('['+new Date()[_0x275549(0x11d)]()[_0x275549(0x113)](0x0,0x8)+_0x275549(0x13c)+this['alias']+']\x20'+_0x1f9b0e);}async['call'](_0x29f9c4,_0x201e70){const _0x411ac6=a0_0x230d08;let _0x220afa={'Content-Type':'application/json','Accept':_0x411ac6(0xf7)};if(this['token'])_0x220afa[_0x411ac6(0xec)]='Bearer\x20'+this['token'];let _0x4b27f6=await(await fetch(this[_0x411ac6(0x112)]+_0x411ac6(0x101),{'method':'POST','headers':_0x220afa,'body':JSON[_0x411ac6(0x138)]({'jsonrpc':_0x411ac6(0xf6),'id':Date[_0x411ac6(0x13d)](),'method':_0x411ac6(0x105),'params':{'name':_0x29f9c4,'arguments':_0x201e70}})}))[_0x411ac6(0x130)](),_0x5acd89=_0x4b27f6['match'](/data: (.+)/),_0x372246=_0x5acd89?JSON[_0x411ac6(0x114)](_0x5acd89[0x1]):JSON[_0x411ac6(0x114)](_0x4b27f6),_0x92053b=_0x372246?.['result']?.[_0x411ac6(0x139)]?.[0x0]?.['text'];return _0x92053b?JSON[_0x411ac6(0x114)](_0x92053b):_0x372246;}async[a0_0x230d08(0xf9)](){const _0x2ebdc6=a0_0x230d08;if(this[_0x2ebdc6(0x127)])return;this[_0x2ebdc6(0x127)]=!0x0,await this['status']('idle'),this[_0x2ebdc6(0x13a)]('registered'),this['heartbeatTimer']=setInterval(()=>{const _0x2f5259=_0x2ebdc6;this[_0x2f5259(0xf2)]('idle')[_0x2f5259(0x120)](_0x57cd61=>this[_0x2f5259(0x13a)](_0x2f5259(0xef)+_0x57cd61[_0x2f5259(0xf0)]));},this['heartbeatInterval']),this[_0x2ebdc6(0x125)]();}async[a0_0x230d08(0x12e)](){const _0x183f5f=a0_0x230d08;if(this[_0x183f5f(0x127)]=!0x1,this[_0x183f5f(0x116)]?.['abort'](),this[_0x183f5f(0x10c)])clearInterval(this['heartbeatTimer']);await this['status']('offline')[_0x183f5f(0x120)](()=>{}),this['log'](_0x183f5f(0xfe));}async[a0_0x230d08(0x102)](_0x3a7d95,_0x47a952,_0x36398e=a0_0x230d08(0x140)){const _0x2a160d=a0_0x230d08;return this[_0x2a160d(0xfd)]('send_task',{'alias':_0x3a7d95,'task':_0x47a952,'priority':_0x36398e,'from_session':this[_0x2a160d(0x106)]});}async[a0_0x230d08(0xf0)](_0x484042,_0xf535cf){const _0x24802d=a0_0x230d08;return this[_0x24802d(0xfd)](_0x24802d(0xfb),{'alias':_0x484042,'message':_0xf535cf,'from_session':this[_0x24802d(0x106)]});}async[a0_0x230d08(0x104)](_0x394ec4,_0x1abafa,_0x1408f2='completed'){const _0x144317=a0_0x230d08;return this[_0x144317(0xfd)](_0x144317(0x111),{'in_reply_to':_0x394ec4,'text':_0x1abafa,'status':_0x1408f2});}async[a0_0x230d08(0xf2)](_0x56e212,_0x2c4ef9){const _0x226ed9=a0_0x230d08;return this['call'](_0x226ed9(0x118),{'resume_id':this['resumeId'],'alias':this[_0x226ed9(0x106)],'status':_0x56e212,'server':a0_0x37fdd8(),'hostname':a0_0x37fdd8(),'agent':this[_0x226ed9(0xee)],'project_dir':process[_0x226ed9(0xeb)](),..._0x2c4ef9});}async[a0_0x230d08(0x122)](){const _0x4103bf=a0_0x230d08;return this[_0x4103bf(0xfd)](_0x4103bf(0xf1),{});}async[a0_0x230d08(0x10e)](_0x94aed9,_0x54955a){const _0x343276=a0_0x230d08;return this[_0x343276(0xfd)](_0x343276(0x10e),{'message':_0x94aed9,'filter_server':_0x54955a?.[_0x343276(0x10f)],'filter_status':_0x54955a?.['status']});}async[a0_0x230d08(0x125)](){const _0x3a741a=a0_0x230d08;let _0x38bfda=encodeURIComponent(this[_0x3a741a(0x106)]),_0x62700f=this[_0x3a741a(0x112)]+_0x3a741a(0x11f)+_0x38bfda,_0x18d07f=this[_0x3a741a(0x12a)];while(this[_0x3a741a(0x127)]){try{this['sseAbort']=new AbortController();let _0x386080={'Accept':_0x3a741a(0x117)};if(this['token'])_0x386080[_0x3a741a(0xec)]=_0x3a741a(0x134)+this['token'];let _0x25c195=await fetch(_0x62700f,{'headers':_0x386080,'signal':this[_0x3a741a(0x116)][_0x3a741a(0x129)]});if(!_0x25c195['ok']||!_0x25c195[_0x3a741a(0x107)]){this[_0x3a741a(0x13a)](_0x3a741a(0x12c)+_0x25c195[_0x3a741a(0xf2)]),await this['sleep'](_0x18d07f),_0x18d07f=Math[_0x3a741a(0xed)](_0x18d07f*1.5,0xea60);continue;}_0x18d07f=this['reconnectDelay'];let _0x223947=_0x25c195[_0x3a741a(0x107)][_0x3a741a(0x103)](),_0x47e6d3=new TextDecoder(),_0x291c17='';while(this[_0x3a741a(0x127)]){let {done:_0x7a321d,value:_0x5719eb}=await _0x223947[_0x3a741a(0x10d)]();if(_0x7a321d)break;_0x291c17+=_0x47e6d3[_0x3a741a(0x133)](_0x5719eb,{'stream':!0x0});let _0x544ff5=_0x291c17['split']('\x0a');_0x291c17=_0x544ff5[_0x3a741a(0xf3)]()||'';for(let _0xa90ef6 of _0x544ff5){if(!_0xa90ef6[_0x3a741a(0x12f)](_0x3a741a(0x10b)))continue;try{let _0x4003a3=JSON[_0x3a741a(0x114)](_0xa90ef6[_0x3a741a(0x113)](0x6));if(_0x4003a3[_0x3a741a(0x11b)]===_0x3a741a(0x13b)){this[_0x3a741a(0x13a)](_0x3a741a(0xf8)),this[_0x3a741a(0x11a)](_0x3a741a(0x13b));continue;}if(_0x4003a3['type']===_0x3a741a(0x115)||_0x4003a3['type']===_0x3a741a(0x12d)||_0x4003a3[_0x3a741a(0x11b)]===_0x3a741a(0x10e))await this[_0x3a741a(0x141)]();}catch{}}}}catch(_0x56ecd7){if(_0x56ecd7[_0x3a741a(0x10a)]==='AbortError')break;this[_0x3a741a(0x11a)](_0x3a741a(0x132),_0x56ecd7),this[_0x3a741a(0x13a)]('SSE\x20error:\x20'+_0x56ecd7['message']);}if(this[_0x3a741a(0x127)])this[_0x3a741a(0x11a)](_0x3a741a(0xfe)),this[_0x3a741a(0x13a)]('SSE\x20reconnecting\x20in\x20'+_0x18d07f/0x3e8+_0x3a741a(0x136)),await this['sleep'](_0x18d07f),_0x18d07f=Math[_0x3a741a(0xed)](_0x18d07f*1.5,0xea60);}}async[a0_0x230d08(0x141)](){const _0x549c3d=a0_0x230d08;try{let _0x4348a1=(await this[_0x549c3d(0xfd)](_0x549c3d(0x135),{'alias':this[_0x549c3d(0x106)],'limit':0xa}))?.[_0x549c3d(0x108)]||[];for(let _0x212c2b of _0x4348a1)await this[_0x549c3d(0xfd)](_0x549c3d(0x109),{'alias':this[_0x549c3d(0x106)],'message_id':_0x212c2b['id']}),this[_0x549c3d(0x13a)]('←\x20'+_0x212c2b['from_session']+':\x20'+_0x212c2b[_0x549c3d(0x139)][_0x549c3d(0x113)](0x0,0x3c)),this['emit'](_0x549c3d(0x13e),_0x212c2b),this[_0x549c3d(0x11a)](_0x549c3d(0xf0),_0x212c2b);}catch(_0x39cfba){this[_0x549c3d(0x13a)](_0x549c3d(0xf4)+_0x39cfba['message']);}}[a0_0x230d08(0x110)](_0x3aad9b){return new Promise(_0x44066d=>setTimeout(_0x44066d,_0x3aad9b));}}var $=T;export{$ as default,T as CommHub}; |
| #!/usr/bin/env bun | ||
| const a0_0x3998da=a0_0x497d;(function(_0x51f69e,_0xb5e54a){const _0x5aa0d3=a0_0x497d,_0x14ecfb=_0x51f69e();while(!![]){try{const _0x3c4231=parseInt(_0x5aa0d3(0x12c))/0x1*(parseInt(_0x5aa0d3(0x119))/0x2)+-parseInt(_0x5aa0d3(0x105))/0x3+-parseInt(_0x5aa0d3(0x15c))/0x4+parseInt(_0x5aa0d3(0x10b))/0x5+parseInt(_0x5aa0d3(0x185))/0x6+parseInt(_0x5aa0d3(0x17d))/0x7+parseInt(_0x5aa0d3(0x141))/0x8*(-parseInt(_0x5aa0d3(0x113))/0x9);if(_0x3c4231===_0xb5e54a)break;else _0x14ecfb['push'](_0x14ecfb['shift']());}catch(_0x176713){_0x14ecfb['push'](_0x14ecfb['shift']());}}}(a0_0x5b0c,0x297fb));import{readFileSync as a0_0xb14a48,existsSync as a0_0x4e597a}from'fs';import{randomUUID as a0_0x59272c}from'crypto';import{join as a0_0x3fa273}from'path';import{hostname as a0_0xd1cc4e}from'os';import{execSync as a0_0x2e0630}from'child_process';function B(_0xcd48dc){const _0x23a6ed=a0_0x497d;let _0x3d2961=_0xcd48dc['replace'](/[^a-zA-Z0-9\-_]/g,'-');return _0x3d2961===''?_0x23a6ed(0xff):_0x3d2961;}import{Server as a0_0x417339}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport as a0_0xc4434c}from'@modelcontextprotocol/sdk/server/stdio.js';import{ListToolsRequestSchema as a0_0x5b019d,CallToolRequestSchema as a0_0x44159d}from'@modelcontextprotocol/sdk/types.js';function T(_0x30c0d8){const _0x8bc4c8=a0_0x497d;if(!a0_0x4e597a(_0x30c0d8))return;for(let _0x22a5a7 of a0_0xb14a48(_0x30c0d8,_0x8bc4c8(0x180))[_0x8bc4c8(0x132)]('\x0a')){let _0x2064ba=_0x22a5a7[_0x8bc4c8(0xfc)]();if(!_0x2064ba||_0x2064ba[_0x8bc4c8(0x16f)]('#'))continue;let _0x561314=_0x2064ba[_0x8bc4c8(0x179)]('=');if(_0x561314<0x0)continue;let _0x36fc57=_0x2064ba[_0x8bc4c8(0x193)](0x0,_0x561314)[_0x8bc4c8(0xfc)](),_0x32b677=_0x2064ba[_0x8bc4c8(0x193)](_0x561314+0x1)[_0x8bc4c8(0xfc)]()[_0x8bc4c8(0x139)](/^["']|["']$/g,'');if(!process.env[_0x36fc57])process.env[_0x36fc57]=_0x32b677;}}var C=process.env.HOME||'~',r=a0_0x3fa273(C,'.claude/channels/commhub');function a0_0x5b0c(){const _0x36d998=['utf-8','Session\x20alias:\x20','unref',']\x20[commhub]\x20','Task\x20outcome:\x20completed/failed/cancelled\x20for\x20final\x20results,\x20blocked/error/in_progress\x20for\x20status\x20updates','1087032XHTiqc','failed','content','commhub_report_status',')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。','none','2.0','send_task','Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.','SSE\x20error:\x20','\x20RESUME_ID=','notification','low','cwd','slice','connected','get','text','catch','high','task',':\x20inbox_count=','trim','send_reply','read','unknown','messages','2025-03-26','length','/events/','Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.','149097VzEDbr','Task\x20content','type','working','set','re-register\x20failed:\x20','574205DPGnXJ','now','code','\x20PROJECT_ENV=','Reply\x20to\x20a\x20Dashboard/UI-originated\x20CommHub\x20task.\x20⚠\x20For\x20agent-to-agent\x20replies\x20use\x20commhub_send_task\x20instead\x20—\x20commhub_reply\x20does\x20NOT\x20wake\x20agent\x20peers\x20via\x20SSE\x20(Vincent\x202026-07-28\x20全网规则).\x20status=\x22completed\x22\x20(terminal)\x20routes\x20to\x20send_reply\x20and\x20emits\x20new_reply\x20SSE\x20for\x20the\x20live\x20Dashboard;\x20non-terminal\x20status\x20(in_progress/blocked/error)\x20only\x20updates\x20session\x20status\x20(report_status)\x20and\x20does\x20NOT\x20reach\x20the\x20Dashboard.','Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','decode','statusText','9OeJacA','normal','commhub_send_task','POST','Current\x20task\x20description','parent\x20claude\x20died\x20(reparented\x20to\x20PID\x201\x20from\x20','6ANKPhy','→\x20injected\x20task\x20','send_message','unknown\x20tool','blocked','SSE\x20连续\x20>1h\x20连不上\x20hub\x20(','.anet','Reply\x20text\x20/\x20result\x20summary','stdin','ppid','result','commhub_reply','commhub','report_status','warning:\x20could\x20not\x20register:\x20','SSE\x20connected\x20as\x20\x22','commhub_get_all_status','Progress\x200-100','completed','16202DdDXvL','parse','message_id','MCP\x20stdio\x20connected','\x20ALIAS=','session\x20disconnected','split','setRequestHandler','claude-code','function','http://127.0.0.1:9200','commhub-channel','SSE\x20connection\x20error:\x20','replace','replied','pid','Bearer\x20','registered\x20as\x20\x22','SSE\x20fatal:\x20','(none)','initialize','2996296peoWYW','toTimeString','find','Messages\x20from\x20CommHub\x20arrive\x20as\x20<channel\x20source=\x22commhub\x22\x20task_id=\x22...\x22\x20priority=\x22...\x22\x20from=\x22...\x22>','/mcp','SIGTERM','notifications/claude/channel','application/json','data:\x20','ack_inbox','0.3.0','\x20\x20•\x20If\x20the\x20sender\x20is\x20another\x20agent\x20node\x20(from\x20CommHub,\x20from\x20your\x20peer\x27s\x20session\x20alias),\x20reply\x20with\x20commhub_send_task(alias=\x22<their\x20alias>\x22,\x20task=\x22<your\x20reply>\x22).\x20This\x20creates\x20a\x20new\x20routable\x20task\x20that\x20wakes\x20the\x20peer\x20via\x20new_task\x20SSE\x20so\x20they\x20process\x20it.\x20commhub_reply\x20does\x20NOT\x20wake\x20agent\x20peers\x20—\x20they\x27d\x20only\x20see\x20it\x20on\x20the\x20next\x20inbox\x20poll\x20(Vincent\x202026-07-28\x20全网规则).','then','connect','[commhub]\x20WARN:\x20COMMHUB_ALIAS\x20env\x20var\x20is\x20unset\x20—\x20outbound\x20from_session\x20','min','\x20/\x20hostname=','priority','stringify','write','SIGINT','You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.','exit','kill','shutting\x20down,\x20reporting\x20offline...','hub','\x20CWD=','308764SeRrgP','idle','Priority\x20(default:\x20normal)','message','no\x20response','end','.env','from','fatal:\x20','pop','ENV:\x20URL=','params','init\x20failed:\x20','config.json','status','tools/call','heartbeat\x20failed:\x20','from_session','cancelled','startsWith','new_message','parent\x20claude\x20pid=','tmux\x20display-message\x20-p\x20\x27#S\x27','in_progress','string','\x22\x20after\x20SSE\x20reconnect','token','ready\x20—\x20waiting\x20for\x20events','starting\x20SSE\x20listener...','indexOf','stderr','Target\x20session\x20alias','unattributed-','2287509jtjsOm','object','error'];a0_0x5b0c=function(){return _0x36d998;};return a0_0x5b0c();}T(a0_0x3fa273(r,a0_0x3998da(0x162)));var H=B(process[a0_0x3998da(0x192)]());T(a0_0x3fa273(r,H,a0_0x3998da(0x162)));function E(){const _0x30a24b=a0_0x3998da;try{return a0_0x2e0630(_0x30a24b(0x172),{'encoding':_0x30a24b(0x180),'timeout':0x7d0})[_0x30a24b(0xfc)]();}catch{return'';}}function _(){const _0x80465=a0_0x3998da;try{let _0x4684b4=a0_0x3fa273(C,_0x80465(0x11f),_0x80465(0x169));if(a0_0x4e597a(_0x4684b4))return JSON[_0x80465(0x12d)](a0_0xb14a48(_0x4684b4,_0x80465(0x180)));}catch{}return{};}var R=_(),Y=process.env.COMMHUB_URL||R[a0_0x3998da(0x15a)]||a0_0x3998da(0x136),j=process.env.COMMHUB_TMUX||E();function a0_0x497d(_0x2b7237,_0x1da58b){_0x2b7237=_0x2b7237-0xf5;const _0x5b0c1d=a0_0x5b0c();let _0x497d38=_0x5b0c1d[_0x2b7237];return _0x497d38;}function S(){const _0xf8d3ec=a0_0x3998da;if(process.env.COMMHUB_ALIAS&&process.env.COMMHUB_ALIAS['trim']())return process.env.COMMHUB_ALIAS['trim']();return process[_0xf8d3ec(0x17a)][_0xf8d3ec(0x154)](_0xf8d3ec(0x14f)+('would\x20mis-attribute.\x20Refusing\x20to\x20guess\x20from\x20TMUX_NAME='+(j||_0xf8d3ec(0x13f))+_0xf8d3ec(0x151)+a0_0xd1cc4e()+'.\x20Restart\x20node\x20via\x20`anet\x20node\x20start\x20<alias>`\x20so\x20the\x20env\x20is\x20set\x20explicitly\x20(#203).\x0a')),_0xf8d3ec(0x17c)+process[_0xf8d3ec(0x13b)];}var p=S(),V=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||a0_0x59272c(),k=process.env.COMMHUB_TOKEN||R[a0_0x3998da(0x176)]||'';function z(_0x21b7ba){const _0x1538bd=a0_0x3998da;let _0x322f6b=new Date()[_0x1538bd(0x142)]()[_0x1538bd(0x193)](0x0,0x8);process[_0x1538bd(0x17a)]['write']('['+_0x322f6b+_0x1538bd(0x183)+_0x21b7ba+'\x0a');}function i(_0xddae49){return new Promise(_0x32bd71=>setTimeout(_0x32bd71,_0xddae49));}z(a0_0x3998da(0x166)+Y+a0_0x3998da(0x130)+p+a0_0x3998da(0x18f)+V[a0_0x3998da(0x193)](0x0,0x8)+'...\x20TMUX='+(j||a0_0x3998da(0x18a))+a0_0x3998da(0x15b)+process[a0_0x3998da(0x192)]()+a0_0x3998da(0x10e)+H);var G=new Map(),K=new a0_0x417339({'name':a0_0x3998da(0x137),'version':'0.3.0'},{'capabilities':{'experimental':{'claude/channel':{}},'tools':{}},'instructions':[a0_0x3998da(0x144),'These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.','Reply\x20routing\x20(IMPORTANT\x20—\x20the\x20tool\x20you\x20pick\x20determines\x20whether\x20the\x20receiver\x20actually\x20gets\x20woken\x20up):',a0_0x3998da(0x14c),'\x20\x20•\x20Only\x20use\x20commhub_reply\x20when\x20the\x20sender\x20is\x20the\x20Dashboard/UI\x20(task_id\x20came\x20from\x20a\x20browser\x20chat).\x20Use\x20status=\x22completed\x22\x20(terminal)\x20so\x20send_reply\x20routes\x20it,\x20updates\x20the\x20task\x20row\x20(Dashboard\x20displays\x20it),\x20and\x20emits\x20new_reply\x20SSE\x20for\x20the\x20live\x20Dashboard\x20viewer.\x20Non-terminal\x20status\x20(in_progress/blocked/error)\x20just\x20updates\x20your\x20session\x20status\x20and\x20does\x20NOT\x20reach\x20the\x20Dashboard.',a0_0x3998da(0x156),a0_0x3998da(0x181)+p]['join']('\x0a')});K[a0_0x3998da(0x133)](a0_0x5b019d,async()=>({'tools':[{'name':a0_0x3998da(0x124),'description':a0_0x3998da(0x10f),'inputSchema':{'type':a0_0x3998da(0x17e),'properties':{'task_id':{'type':'string','description':'The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)'},'text':{'type':a0_0x3998da(0x174),'description':a0_0x3998da(0x120)},'status':{'type':a0_0x3998da(0x174),'enum':[a0_0x3998da(0x12b),a0_0x3998da(0x186),a0_0x3998da(0x16e),'blocked',a0_0x3998da(0x17f),a0_0x3998da(0x173)],'description':a0_0x3998da(0x184)}},'required':[a0_0x3998da(0xf7)]}},{'name':a0_0x3998da(0x188),'description':'Update\x20this\x20session\x27s\x20status\x20in\x20CommHub\x20(working/idle/blocked/error).\x20Returns\x20inbox_count.','inputSchema':{'type':a0_0x3998da(0x17e),'properties':{'status':{'type':a0_0x3998da(0x174),'enum':['working','idle','blocked',a0_0x3998da(0x17f)]},'task':{'type':a0_0x3998da(0x174),'description':a0_0x3998da(0x117)},'progress':{'type':'number','description':a0_0x3998da(0x12a)}},'required':[a0_0x3998da(0x16a)]}},{'name':a0_0x3998da(0x115),'description':a0_0x3998da(0x104),'inputSchema':{'type':a0_0x3998da(0x17e),'properties':{'alias':{'type':'string','description':'Target\x20session\x20alias'},'task':{'type':'string','description':a0_0x3998da(0x106)},'priority':{'type':a0_0x3998da(0x174),'enum':[a0_0x3998da(0xf9),'normal',a0_0x3998da(0x191)],'description':a0_0x3998da(0x15e)}},'required':['alias',a0_0x3998da(0xfa)]}},{'name':'commhub_send_message','description':a0_0x3998da(0x18d),'inputSchema':{'type':a0_0x3998da(0x17e),'properties':{'alias':{'type':'string','description':a0_0x3998da(0x17b)},'message':{'type':a0_0x3998da(0x174),'description':'Message\x20content'}},'required':['alias',a0_0x3998da(0x15f)]}},{'name':'commhub_get_all_status','description':a0_0x3998da(0x110),'inputSchema':{'type':'object','properties':{}}}]}));async function Q(_0x1315ba,_0x40a4cf){const _0x7811c8=a0_0x3998da;let _0x3a4dd7=await fetch(Y+_0x7811c8(0x145),{'method':_0x7811c8(0x116),'headers':{'Content-Type':_0x7811c8(0x148),'Accept':'application/json,\x20text/event-stream',...k?{'Authorization':_0x7811c8(0x13c)+k}:{}},'body':JSON[_0x7811c8(0x153)]({'jsonrpc':_0x7811c8(0x18b),'id':0x1,'method':_0x7811c8(0x140),'params':{'protocolVersion':_0x7811c8(0x101),'capabilities':{},'clientInfo':{'name':_0x7811c8(0x137),'version':_0x7811c8(0x14b)}}})});if(!_0x3a4dd7['ok']){let _0x1b5ea0=await _0x3a4dd7[_0x7811c8(0xf7)]();return z('CommHub\x20init\x20failed:\x20'+_0x3a4dd7[_0x7811c8(0x16a)]+'\x20'+_0x1b5ea0[_0x7811c8(0x193)](0x0,0x64)),{'ok':!0x1,'error':_0x7811c8(0x168)+_0x3a4dd7['status']};}await _0x3a4dd7[_0x7811c8(0xf7)]();let _0x9e7fcd=(await(await fetch(Y+_0x7811c8(0x145),{'method':_0x7811c8(0x116),'headers':{'Content-Type':_0x7811c8(0x148),'Accept':'application/json,\x20text/event-stream',...k?{'Authorization':'Bearer\x20'+k}:{}},'body':JSON['stringify']({'jsonrpc':_0x7811c8(0x18b),'id':0x2,'method':_0x7811c8(0x16b),'params':{'name':_0x1315ba,'arguments':_0x40a4cf}})}))[_0x7811c8(0xf7)]())[_0x7811c8(0x132)]('\x0a')[_0x7811c8(0x143)](_0x206328=>_0x206328['startsWith'](_0x7811c8(0x149)));if(_0x9e7fcd){let _0x42a9a8=JSON[_0x7811c8(0x12d)](_0x9e7fcd[_0x7811c8(0x193)](0x6));return _0x42a9a8?.[_0x7811c8(0x123)]?.[_0x7811c8(0x187)]?.[0x0]?.[_0x7811c8(0xf7)]?JSON[_0x7811c8(0x12d)](_0x42a9a8[_0x7811c8(0x123)]['content'][0x0][_0x7811c8(0xf7)]):_0x42a9a8;}return{'ok':!0x1,'error':_0x7811c8(0x160)};}K['setRequestHandler'](a0_0x44159d,async _0x571893=>{const _0x4bc984=a0_0x3998da;let {name:_0xad1f02,arguments:_0x1e0f64}=_0x571893[_0x4bc984(0x167)];if(_0xad1f02===_0x4bc984(0x124)){let {task_id:_0x1a76c0,text:_0x4913cc,status:_0x35803a}=_0x1e0f64;if(_0x35803a===_0x4bc984(0x12b)||_0x35803a===_0x4bc984(0x186)||_0x35803a==='cancelled'){let _0x57a8fa=_0x35803a===_0x4bc984(0x12b)?_0x4bc984(0x13a):_0x35803a,_0x559a54=_0x1a76c0?G[_0x4bc984(0xf6)](_0x1a76c0)||_0x4bc984(0x15a):'hub',_0x49fc23=await Q(_0x4bc984(0xfd),{'alias':_0x559a54,'text':_0x4913cc,'in_reply_to':_0x1a76c0||void 0x0,'status':_0x57a8fa,'from_session':p});if(_0x1a76c0)G['delete'](_0x1a76c0);return{'content':[{'type':_0x4bc984(0xf7),'text':JSON['stringify'](_0x49fc23)}]};}let _0x5a5262=await Q('report_status',{'resume_id':V,'alias':p,'status':_0x35803a===_0x4bc984(0x11d)?_0x4bc984(0x11d):_0x35803a===_0x4bc984(0x17f)?_0x4bc984(0x17f):_0x4bc984(0x108),'task':_0x4913cc[_0x4bc984(0x193)](0x0,0xc8),'output':_0x4913cc});return{'content':[{'type':_0x4bc984(0xf7),'text':JSON['stringify'](_0x5a5262)}]};}if(_0xad1f02===_0x4bc984(0x188)){let {status:_0x589d8a,task:_0x5d08e1,progress:_0x1e2639}=_0x1e0f64,_0x22f75d=await Q('report_status',{'resume_id':V,'alias':p,'status':_0x589d8a,'task':_0x5d08e1,'progress':_0x1e2639});return{'content':[{'type':_0x4bc984(0xf7),'text':JSON['stringify'](_0x22f75d)}]};}if(_0xad1f02==='commhub_send_task'){let {alias:_0x5a415f,task:_0x1ea4a4,priority:_0x5d9ca9}=_0x1e0f64,_0x4aeec9=await Q(_0x4bc984(0x18c),{'alias':_0x5a415f,'task':_0x1ea4a4,'priority':_0x5d9ca9||_0x4bc984(0x114),'from_session':p});return{'content':[{'type':_0x4bc984(0xf7),'text':JSON[_0x4bc984(0x153)](_0x4aeec9)}]};}if(_0xad1f02==='commhub_send_message'){let {alias:_0x24b048,message:_0x5b11d0}=_0x1e0f64,_0x44ee77=await Q(_0x4bc984(0x11b),{'alias':_0x24b048,'message':_0x5b11d0,'from_session':p});return{'content':[{'type':_0x4bc984(0xf7),'text':JSON[_0x4bc984(0x153)](_0x44ee77)}]};}if(_0xad1f02===_0x4bc984(0x129)){let _0x21e99d=await Q('get_all_status',{});return{'content':[{'type':_0x4bc984(0xf7),'text':JSON['stringify'](_0x21e99d)}]};}return{'content':[{'type':_0x4bc984(0xf7),'text':JSON['stringify']({'error':_0x4bc984(0x11c)})}]};});var D=0x3e8,v=0x7530,O=0x36ee80;async function m(){const _0x1d9abe=a0_0x3998da;try{await Q(_0x1d9abe(0x126),{'resume_id':V,'alias':p,'status':_0x1d9abe(0x15d),'server':a0_0xd1cc4e(),'hostname':a0_0xd1cc4e(),'agent':_0x1d9abe(0x134),'project_dir':process[_0x1d9abe(0x192)](),'tmux_name':j||void 0x0}),z('re-registered\x20as\x20\x22'+p+_0x1d9abe(0x175));}catch(_0x439e42){z(_0x1d9abe(0x10a)+_0x439e42);}}async function l(){const _0x3cc62f=a0_0x3998da;let _0xea8e30=Y+_0x3cc62f(0x103)+encodeURIComponent(p),_0x53aa0f={};if(k)_0x53aa0f['Authorization']=_0x3cc62f(0x13c)+k;z('connecting\x20to\x20'+_0xea8e30);let _0x4c6ff5=D,_0x5ebb04=!0x0,_0x3c462b=null;while(!0x0){try{let _0xbf13d4=await fetch(_0xea8e30,{'headers':_0x53aa0f});if(!_0xbf13d4['ok']){if(z(_0x3cc62f(0x18e)+_0xbf13d4[_0x3cc62f(0x16a)]+'\x20'+_0xbf13d4[_0x3cc62f(0x112)]),_0x3c462b=_0x3c462b??Date[_0x3cc62f(0x10c)](),Date['now']()-_0x3c462b>O){z('SSE\x20连续\x20>1h\x20连不上\x20hub\x20('+Y+')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。');return;}await i(_0x4c6ff5),_0x4c6ff5=Math['min'](_0x4c6ff5*0x2,v);continue;}let _0x4c11da=_0xbf13d4['body']['getReader'](),_0x5b6ff4=new TextDecoder(),_0x366469='';_0x4c6ff5=D;while(!0x0){let {done:_0x2f6554,value:_0x575fe2}=await _0x4c11da[_0x3cc62f(0xfe)]();if(_0x2f6554)break;_0x366469+=_0x5b6ff4[_0x3cc62f(0x111)](_0x575fe2,{'stream':!0x0});let _0x5b76a2=_0x366469[_0x3cc62f(0x132)]('\x0a\x0a');_0x366469=_0x5b76a2[_0x3cc62f(0x165)]()||'';for(let _0x26f2f6 of _0x5b76a2){let _0x2a5cbf=_0x26f2f6[_0x3cc62f(0x132)]('\x0a')[_0x3cc62f(0x143)](_0x3f56d7=>_0x3f56d7[_0x3cc62f(0x16f)]('data:\x20'));if(!_0x2a5cbf)continue;try{let _0x33d77b=JSON['parse'](_0x2a5cbf[_0x3cc62f(0x193)](0x6));if(await A(_0x33d77b),_0x33d77b[_0x3cc62f(0x107)]===_0x3cc62f(0xf5)){if(_0x3c462b=null,!_0x5ebb04)await m();_0x5ebb04=!0x1;}}catch(_0x308181){z('parse\x20error:\x20'+_0x308181);}}}z('SSE\x20stream\x20ended,\x20reconnecting...');}catch(_0x5f3642){z(_0x3cc62f(0x138)+_0x5f3642);}if(_0x3c462b=_0x3c462b??Date[_0x3cc62f(0x10c)](),Date[_0x3cc62f(0x10c)]()-_0x3c462b>O){z(_0x3cc62f(0x11e)+Y+_0x3cc62f(0x189));return;}await i(_0x4c6ff5),_0x4c6ff5=Math[_0x3cc62f(0x150)](_0x4c6ff5*0x2,v);}}async function A(_0x26c82c){const _0x4fc10b=a0_0x3998da;if(_0x26c82c[_0x4fc10b(0x107)]===_0x4fc10b(0xf5)){z(_0x4fc10b(0x128)+p+'\x22');return;}if(_0x26c82c[_0x4fc10b(0x107)]===_0x4fc10b(0x170)){if(z('←\x20message\x20from\x20'+_0x26c82c[_0x4fc10b(0x163)]+':\x20'+_0x26c82c['message']['slice'](0x0,0x3c)),await K[_0x4fc10b(0x190)]({'method':'notifications/claude/channel','params':{'content':_0x26c82c[_0x4fc10b(0x15f)],'meta':{'sender':_0x26c82c[_0x4fc10b(0x163)]||'hub','sender_id':_0x4fc10b(0x125),'user':_0x26c82c[_0x4fc10b(0x163)]||_0x4fc10b(0x15a),'priority':_0x4fc10b(0x114)}}}),_0x26c82c[_0x4fc10b(0x12e)])await Q(_0x4fc10b(0x14a),{'alias':p,'message_id':_0x26c82c[_0x4fc10b(0x12e)]});return;}if(_0x26c82c[_0x4fc10b(0x107)]==='new_task'||_0x26c82c[_0x4fc10b(0x107)]==='broadcast'){z('←\x20'+_0x26c82c[_0x4fc10b(0x107)]+_0x4fc10b(0xfb)+_0x26c82c['inbox_count']+'\x20priority='+(_0x26c82c[_0x4fc10b(0x152)]||_0x4fc10b(0x114)));let _0x10054b=await Q('get_inbox',{'alias':p,'limit':0x5});if(_0x10054b?.['ok']&&_0x10054b[_0x4fc10b(0x100)]?.[_0x4fc10b(0x102)]>0x0)for(let _0x3c4839 of _0x10054b[_0x4fc10b(0x100)]){let _0x553fd1={'sender':_0x3c4839['from_session']||_0x4fc10b(0x15a),'sender_id':'commhub','user':_0x3c4839[_0x4fc10b(0x16d)]||_0x4fc10b(0x15a),'task_id':_0x3c4839['id'],'priority':_0x3c4839[_0x4fc10b(0x152)]||_0x4fc10b(0x114)};G[_0x4fc10b(0x109)](_0x3c4839['id'],_0x3c4839['from_session']||'hub'),await K[_0x4fc10b(0x190)]({'method':_0x4fc10b(0x147),'params':{'content':_0x3c4839[_0x4fc10b(0x187)],'meta':_0x553fd1}}),z(_0x4fc10b(0x11a)+_0x3c4839['id'][_0x4fc10b(0x193)](0x0,0x8)+'\x20from\x20'+_0x3c4839[_0x4fc10b(0x16d)]+':\x20'+_0x3c4839[_0x4fc10b(0x187)][_0x4fc10b(0x193)](0x0,0x3c)),await Q(_0x4fc10b(0x14a),{'alias':p,'message_id':_0x3c4839['id']});}}}async function t(){const _0x2ef511=a0_0x3998da;let _0x32af90=new a0_0xc4434c();await K[_0x2ef511(0x14e)](_0x32af90),z(_0x2ef511(0x12f)),z(_0x2ef511(0x178)),l()[_0x2ef511(0xf8)](_0x78b2f0=>z(_0x2ef511(0x13e)+_0x78b2f0)),Q(_0x2ef511(0x126),{'resume_id':V,'alias':p,'status':_0x2ef511(0x15d),'server':a0_0xd1cc4e(),'hostname':a0_0xd1cc4e(),'agent':_0x2ef511(0x134),'project_dir':process[_0x2ef511(0x192)](),'tmux_name':j||void 0x0})[_0x2ef511(0x14d)](()=>z(_0x2ef511(0x13d)+p+'\x22\x20('+V['slice'](0x0,0x8)+')'))[_0x2ef511(0xf8)](_0x2948cd=>z(_0x2ef511(0x127)+_0x2948cd)),setInterval(()=>{const _0x52493b=_0x2ef511;Q(_0x52493b(0x126),{'resume_id':V,'alias':p,'status':_0x52493b(0x15d),'server':a0_0xd1cc4e(),'hostname':a0_0xd1cc4e(),'agent':'claude-code','project_dir':process[_0x52493b(0x192)](),'tmux_name':j||void 0x0})[_0x52493b(0xf8)](_0x5311a8=>z(_0x52493b(0x16c)+_0x5311a8));},0x2bf20),z(_0x2ef511(0x177));}t()[a0_0x3998da(0xf8)](_0x219017=>{const _0x3c6010=a0_0x3998da;z(_0x3c6010(0x164)+_0x219017),process[_0x3c6010(0x157)](0x1);});async function b(){const _0x174360=a0_0x3998da;z(_0x174360(0x159)),await Q('report_status',{'resume_id':V,'alias':p,'status':'offline','task':_0x174360(0x131)})[_0x174360(0xf8)](()=>{}),process['exit'](0x0);}process[a0_0x3998da(0x121)]['on'](a0_0x3998da(0x161),()=>b()),process['on'](a0_0x3998da(0x146),()=>b()),process['on'](a0_0x3998da(0x155),()=>b());var d=process['ppid'];if(d&&d>0x1){let h=setInterval(()=>{const _0x1554d0=a0_0x3998da;if(process[_0x1554d0(0x122)]===0x1&&d!==0x1){z(_0x1554d0(0x118)+d+')\x20—\x20self-exit\x20to\x20avoid\x20ghost\x20heart-beat'),b();return;}try{process[_0x1554d0(0x158)](d,0x0);}catch(_0x325ac9){if(_0x325ac9?.[_0x1554d0(0x10d)]==='ESRCH')z(_0x1554d0(0x171)+d+'\x20no\x20longer\x20exists\x20(kill-0\x20ESRCH)\x20—\x20self-exit\x20to\x20avoid\x20ghost\x20heart-beat'),b();}},0x7530);if(typeof h[a0_0x3998da(0x182)]===a0_0x3998da(0x135))h[a0_0x3998da(0x182)]();} | ||
| const a0_0x2c4552=a0_0x3be1;(function(_0x2cbe21,_0x1a2a66){const _0x1c4e5d=a0_0x3be1,_0x339a5d=_0x2cbe21();while(!![]){try{const _0x1f49e4=parseInt(_0x1c4e5d(0x1ad))/0x1*(-parseInt(_0x1c4e5d(0x224))/0x2)+-parseInt(_0x1c4e5d(0x1d9))/0x3*(-parseInt(_0x1c4e5d(0x217))/0x4)+-parseInt(_0x1c4e5d(0x1f9))/0x5*(parseInt(_0x1c4e5d(0x1f2))/0x6)+-parseInt(_0x1c4e5d(0x182))/0x7*(parseInt(_0x1c4e5d(0x21d))/0x8)+-parseInt(_0x1c4e5d(0x21e))/0x9*(-parseInt(_0x1c4e5d(0x1e1))/0xa)+-parseInt(_0x1c4e5d(0x1c1))/0xb*(-parseInt(_0x1c4e5d(0x215))/0xc)+parseInt(_0x1c4e5d(0x1e5))/0xd*(parseInt(_0x1c4e5d(0x1cd))/0xe);if(_0x1f49e4===_0x1a2a66)break;else _0x339a5d['push'](_0x339a5d['shift']());}catch(_0x810d97){_0x339a5d['push'](_0x339a5d['shift']());}}}(a0_0x2318,0xc76e4));import{readFileSync as a0_0x4289c7,existsSync as a0_0x16af32}from'fs';import{randomUUID as a0_0x1c158b}from'crypto';import{join as a0_0x453f6b}from'path';function a0_0x2318(){const _0x30202e=['cwd','...\x20TMUX=','13610qJEaMx','body','setRequestHandler','length','16123341CRAGpF','utf-8','commhub_report_status','(none)','\x22\x20(','\x20\x20•\x20If\x20the\x20sender\x20is\x20another\x20agent\x20node\x20(from\x20CommHub,\x20from\x20your\x20peer\x27s\x20session\x20alias),\x20reply\x20with\x20commhub_send_task(alias=\x22<their\x20alias>\x22,\x20task=\x22<your\x20reply>\x22).\x20This\x20creates\x20a\x20new\x20routable\x20task\x20that\x20wakes\x20the\x20peer\x20via\x20new_task\x20SSE\x20so\x20they\x20process\x20it.\x20commhub_reply\x20does\x20NOT\x20wake\x20agent\x20peers\x20—\x20they\x27d\x20only\x20see\x20it\x20on\x20the\x20next\x20inbox\x20poll\x20(Vincent\x202026-07-28\x20全网规则).','\x20no\x20longer\x20exists\x20(kill-0\x20ESRCH)\x20—\x20self-exit\x20to\x20avoid\x20ghost\x20heart-beat','session\x20disconnected','warning:\x20could\x20not\x20register:\x20','from_session','stderr','send_message','replied','4261950YzhiJe','task','idle','from','.claude/channels/commhub','Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.','would\x20mis-attribute.\x20Refusing\x20to\x20guess\x20from\x20TMUX_NAME=','5wsSxJW','connected','code','MCP\x20stdio\x20connected','startsWith','\x20\x20•\x20Only\x20use\x20commhub_reply\x20when\x20the\x20sender\x20is\x20the\x20Dashboard/UI\x20(task_id\x20came\x20from\x20a\x20browser\x20chat).\x20Use\x20status=\x22completed\x22\x20(terminal)\x20so\x20send_reply\x20routes\x20it,\x20updates\x20the\x20task\x20row\x20(Dashboard\x20displays\x20it),\x20and\x20emits\x20new_reply\x20SSE\x20for\x20the\x20live\x20Dashboard\x20viewer.\x20Non-terminal\x20status\x20(in_progress/blocked/error)\x20just\x20updates\x20your\x20session\x20status\x20and\x20does\x20NOT\x20reach\x20the\x20Dashboard.','claude-code','Priority\x20(default:\x20normal)','get','Task\x20outcome:\x20completed/failed/cancelled\x20for\x20final\x20results,\x20blocked/error/in_progress\x20for\x20status\x20updates','registered\x20as\x20\x22','write','SIGTERM','string','ENV:\x20URL=','SIGINT','no\x20response','commhub','commhub_send_message','SSE\x20连续\x20>1h\x20连不上\x20hub\x20(','slice','decode','high',':\x20inbox_count=','message_id','unref','failed','re-register\x20failed:\x20','216poWawz','blocked','4sBHLzO','Reply\x20to\x20a\x20Dashboard/UI-originated\x20CommHub\x20task.\x20⚠\x20For\x20agent-to-agent\x20replies\x20use\x20commhub_send_task\x20instead\x20—\x20commhub_reply\x20does\x20NOT\x20wake\x20agent\x20peers\x20via\x20SSE\x20(Vincent\x202026-07-28\x20全网规则).\x20status=\x22completed\x22\x20(terminal)\x20routes\x20to\x20send_reply\x20and\x20emits\x20new_reply\x20SSE\x20for\x20the\x20live\x20Dashboard;\x20non-terminal\x20status\x20(in_progress/blocked/error)\x20only\x20updates\x20session\x20status\x20(report_status)\x20and\x20does\x20NOT\x20reach\x20the\x20Dashboard.','read','report_status','.\x20Restart\x20node\x20via\x20`anet\x20node\x20start\x20<alias>`\x20so\x20the\x20env\x20is\x20set\x20explicitly\x20(#203).\x0a','commhub_get_all_status','8JFLiOK','3285CyCRFz','tmux\x20display-message\x20-p\x20\x27#S\x27',']\x20[commhub]\x20','send_reply','offline','pop','242618FQXzXr','catch','ack_inbox','result','2025-03-26','Messages\x20from\x20CommHub\x20arrive\x20as\x20<channel\x20source=\x22commhub\x22\x20task_id=\x22...\x22\x20priority=\x22...\x22\x20from=\x22...\x22>','join','5474798HBQJwr','fatal:\x20','get_inbox','statusText','error','ESRCH','priority','notifications/claude/channel','new_task','token','working','replace','content','commhub_reply','\x20RESUME_ID=','send_task','now','[commhub]\x20WARN:\x20COMMHUB_ALIAS\x20env\x20var\x20is\x20unset\x20—\x20outbound\x20from_session\x20','\x20CWD=','.env','0.3.0','split','connect','commhub-channel','Update\x20this\x20session\x27s\x20status\x20in\x20CommHub\x20(working/idle/blocked/error).\x20Returns\x20inbox_count.','CommHub\x20init\x20failed:\x20','application/json','config.json','Current\x20task\x20description','inbox_count','exit','find','\x22\x20after\x20SSE\x20reconnect','\x20from\x20','delete','SSE\x20connection\x20error:\x20','SSE\x20error:\x20','hub','These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.','stdin','Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','kill','normal','12IGXfmw','ppid',')\x20—\x20放弃自动重连。手动\x20anet\x20node\x20start\x20恢复。','←\x20message\x20from\x20','Task\x20content','type','SSE\x20connected\x20as\x20\x22','Progress\x200-100','→\x20injected\x20task\x20','shutting\x20down,\x20reporting\x20offline...','You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.','status','Authorization','POST','heartbeat\x20failed:\x20','completed','data:\x20','pid','text','unknown\x20tool','380589XZKlfy','min','notification','\x20/\x20hostname=','new_message','in_progress','stringify','application/json,\x20text/event-stream','starting\x20SSE\x20listener...','SSE\x20fatal:\x20','parse','message','14YQWtlw','get_all_status','messages','unknown',')\x20—\x20self-exit\x20to\x20avoid\x20ghost\x20heart-beat','trim','Session\x20alias:\x20','then','Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.','object','The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)','params','4215633qBJyLm','init\x20failed:\x20','\x20PROJECT_ENV=','http://127.0.0.1:9200','alias','Target\x20session\x20alias'];a0_0x2318=function(){return _0x30202e;};return a0_0x2318();}import{hostname as a0_0x2b7f10}from'os';import{execSync as a0_0x3a9435}from'child_process';function B(_0x4d6419){const _0x4ca303=a0_0x3be1;let _0x389a94=_0x4d6419['replace'](/[^a-zA-Z0-9\-_]/g,'-');return _0x389a94===''?_0x4ca303(0x1d0):_0x389a94;}import{Server as a0_0x4fdfae}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport as a0_0x2e972b}from'@modelcontextprotocol/sdk/server/stdio.js';import{ListToolsRequestSchema as a0_0x38cfb7,CallToolRequestSchema as a0_0x1b6d63}from'@modelcontextprotocol/sdk/types.js';function T(_0x19bbfe){const _0x34c8e5=a0_0x3be1;if(!a0_0x16af32(_0x19bbfe))return;for(let _0x30d49b of a0_0x4289c7(_0x19bbfe,_0x34c8e5(0x1e6))[_0x34c8e5(0x197)]('\x0a')){let _0x4b021e=_0x30d49b['trim']();if(!_0x4b021e||_0x4b021e[_0x34c8e5(0x1fd)]('#'))continue;let _0x1e85e4=_0x4b021e['indexOf']('=');if(_0x1e85e4<0x0)continue;let _0xde92f8=_0x4b021e[_0x34c8e5(0x20d)](0x0,_0x1e85e4)['trim'](),_0x58c892=_0x4b021e[_0x34c8e5(0x20d)](_0x1e85e4+0x1)['trim']()[_0x34c8e5(0x18d)](/^["']|["']$/g,'');if(!process.env[_0xde92f8])process.env[_0xde92f8]=_0x58c892;}}var C=process.env.HOME||'~',r=a0_0x453f6b(C,a0_0x2c4552(0x1f6));T(a0_0x453f6b(r,'.env'));var H=B(process[a0_0x2c4552(0x1df)]());T(a0_0x453f6b(r,H,a0_0x2c4552(0x195)));function E(){const _0x4f6673=a0_0x2c4552;try{return a0_0x3a9435(_0x4f6673(0x21f),{'encoding':_0x4f6673(0x1e6),'timeout':0x7d0})[_0x4f6673(0x1d2)]();}catch{return'';}}function _(){const _0x4fa482=a0_0x2c4552;try{let _0x871d9e=a0_0x453f6b(C,'.anet',_0x4fa482(0x19d));if(a0_0x16af32(_0x871d9e))return JSON[_0x4fa482(0x1cb)](a0_0x4289c7(_0x871d9e,'utf-8'));}catch{}return{};}function a0_0x3be1(_0x51ae3a,_0x1a29bd){_0x51ae3a=_0x51ae3a-0x17e;const _0x231827=a0_0x2318();let _0x3be1fc=_0x231827[_0x51ae3a];return _0x3be1fc;}var R=_(),Y=process.env.COMMHUB_URL||R['hub']||a0_0x2c4552(0x1dc),j=process.env.COMMHUB_TMUX||E();function S(){const _0x5ad3c4=a0_0x2c4552;if(process.env.COMMHUB_ALIAS&&process.env.COMMHUB_ALIAS[_0x5ad3c4(0x1d2)]())return process.env.COMMHUB_ALIAS[_0x5ad3c4(0x1d2)]();return process[_0x5ad3c4(0x1ef)][_0x5ad3c4(0x204)](_0x5ad3c4(0x193)+(_0x5ad3c4(0x1f8)+(j||_0x5ad3c4(0x1e8))+_0x5ad3c4(0x1c4)+a0_0x2b7f10()+_0x5ad3c4(0x21b))),'unattributed-'+process[_0x5ad3c4(0x1be)];}var p=S(),V=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||a0_0x1c158b(),k=process.env.COMMHUB_TOKEN||R[a0_0x2c4552(0x18b)]||'';function z(_0x30b81c){const _0x45e3a4=a0_0x2c4552;let _0x34a07c=new Date()['toTimeString']()[_0x45e3a4(0x20d)](0x0,0x8);process['stderr'][_0x45e3a4(0x204)]('['+_0x34a07c+_0x45e3a4(0x220)+_0x30b81c+'\x0a');}function i(_0x16344d){return new Promise(_0x31e5f7=>setTimeout(_0x31e5f7,_0x16344d));}z(a0_0x2c4552(0x207)+Y+'\x20ALIAS='+p+a0_0x2c4552(0x190)+V[a0_0x2c4552(0x20d)](0x0,0x8)+a0_0x2c4552(0x1e0)+(j||'none')+a0_0x2c4552(0x194)+process[a0_0x2c4552(0x1df)]()+a0_0x2c4552(0x1db)+H);var G=new Map(),K=new a0_0x4fdfae({'name':a0_0x2c4552(0x199),'version':'0.3.0'},{'capabilities':{'experimental':{'claude/channel':{}},'tools':{}},'instructions':[a0_0x2c4552(0x180),a0_0x2c4552(0x1a8),'Reply\x20routing\x20(IMPORTANT\x20—\x20the\x20tool\x20you\x20pick\x20determines\x20whether\x20the\x20receiver\x20actually\x20gets\x20woken\x20up):',a0_0x2c4552(0x1ea),a0_0x2c4552(0x1fe),a0_0x2c4552(0x1b7),a0_0x2c4552(0x1d3)+p][a0_0x2c4552(0x181)]('\x0a')});K[a0_0x2c4552(0x1e3)](a0_0x38cfb7,async()=>({'tools':[{'name':a0_0x2c4552(0x18f),'description':a0_0x2c4552(0x218),'inputSchema':{'type':'object','properties':{'task_id':{'type':a0_0x2c4552(0x206),'description':a0_0x2c4552(0x1d7)},'text':{'type':a0_0x2c4552(0x206),'description':'Reply\x20text\x20/\x20result\x20summary'},'status':{'type':a0_0x2c4552(0x206),'enum':['completed',a0_0x2c4552(0x213),'cancelled',a0_0x2c4552(0x216),'error',a0_0x2c4552(0x1c6)],'description':a0_0x2c4552(0x202)}},'required':[a0_0x2c4552(0x1bf)]}},{'name':a0_0x2c4552(0x1e7),'description':a0_0x2c4552(0x19a),'inputSchema':{'type':'object','properties':{'status':{'type':a0_0x2c4552(0x206),'enum':[a0_0x2c4552(0x18c),a0_0x2c4552(0x1f4),a0_0x2c4552(0x216),a0_0x2c4552(0x186)]},'task':{'type':a0_0x2c4552(0x206),'description':a0_0x2c4552(0x19e)},'progress':{'type':'number','description':a0_0x2c4552(0x1b4)}},'required':[a0_0x2c4552(0x1b8)]}},{'name':'commhub_send_task','description':a0_0x2c4552(0x1d5),'inputSchema':{'type':a0_0x2c4552(0x1d6),'properties':{'alias':{'type':'string','description':'Target\x20session\x20alias'},'task':{'type':a0_0x2c4552(0x206),'description':a0_0x2c4552(0x1b1)},'priority':{'type':'string','enum':[a0_0x2c4552(0x20f),a0_0x2c4552(0x1ac),'low'],'description':a0_0x2c4552(0x200)}},'required':[a0_0x2c4552(0x1dd),a0_0x2c4552(0x1f3)]}},{'name':a0_0x2c4552(0x20b),'description':a0_0x2c4552(0x1f7),'inputSchema':{'type':'object','properties':{'alias':{'type':a0_0x2c4552(0x206),'description':a0_0x2c4552(0x1de)},'message':{'type':'string','description':'Message\x20content'}},'required':[a0_0x2c4552(0x1dd),a0_0x2c4552(0x1cc)]}},{'name':a0_0x2c4552(0x21c),'description':a0_0x2c4552(0x1aa),'inputSchema':{'type':a0_0x2c4552(0x1d6),'properties':{}}}]}));async function Q(_0x3c66b9,_0xbbd1ce){const _0x165339=a0_0x2c4552;let _0x3f7358=await fetch(Y+'/mcp',{'method':_0x165339(0x1ba),'headers':{'Content-Type':_0x165339(0x19c),'Accept':_0x165339(0x1c8),...k?{'Authorization':'Bearer\x20'+k}:{}},'body':JSON[_0x165339(0x1c7)]({'jsonrpc':'2.0','id':0x1,'method':'initialize','params':{'protocolVersion':_0x165339(0x17f),'capabilities':{},'clientInfo':{'name':_0x165339(0x199),'version':_0x165339(0x196)}}})});if(!_0x3f7358['ok']){let _0x22caed=await _0x3f7358['text']();return z(_0x165339(0x19b)+_0x3f7358[_0x165339(0x1b8)]+'\x20'+_0x22caed[_0x165339(0x20d)](0x0,0x64)),{'ok':!0x1,'error':_0x165339(0x1da)+_0x3f7358[_0x165339(0x1b8)]};}await _0x3f7358['text']();let _0x3a4d87=(await(await fetch(Y+'/mcp',{'method':_0x165339(0x1ba),'headers':{'Content-Type':_0x165339(0x19c),'Accept':_0x165339(0x1c8),...k?{'Authorization':'Bearer\x20'+k}:{}},'body':JSON['stringify']({'jsonrpc':'2.0','id':0x2,'method':'tools/call','params':{'name':_0x3c66b9,'arguments':_0xbbd1ce}})}))[_0x165339(0x1bf)]())[_0x165339(0x197)]('\x0a')['find'](_0x5027b8=>_0x5027b8[_0x165339(0x1fd)](_0x165339(0x1bd)));if(_0x3a4d87){let _0x3dd1fb=JSON['parse'](_0x3a4d87[_0x165339(0x20d)](0x6));return _0x3dd1fb?.[_0x165339(0x17e)]?.[_0x165339(0x18e)]?.[0x0]?.[_0x165339(0x1bf)]?JSON[_0x165339(0x1cb)](_0x3dd1fb['result'][_0x165339(0x18e)][0x0][_0x165339(0x1bf)]):_0x3dd1fb;}return{'ok':!0x1,'error':_0x165339(0x209)};}K[a0_0x2c4552(0x1e3)](a0_0x1b6d63,async _0x154a65=>{const _0x541d6a=a0_0x2c4552;let {name:_0x31a92d,arguments:_0x41a2ab}=_0x154a65[_0x541d6a(0x1d8)];if(_0x31a92d===_0x541d6a(0x18f)){let {task_id:_0x5da221,text:_0x1c0b97,status:_0x294e69}=_0x41a2ab;if(_0x294e69===_0x541d6a(0x1bc)||_0x294e69===_0x541d6a(0x213)||_0x294e69==='cancelled'){let _0x20911b=_0x294e69===_0x541d6a(0x1bc)?_0x541d6a(0x1f1):_0x294e69,_0x4c4240=_0x5da221?G[_0x541d6a(0x201)](_0x5da221)||'hub':'hub',_0x145383=await Q(_0x541d6a(0x221),{'alias':_0x4c4240,'text':_0x1c0b97,'in_reply_to':_0x5da221||void 0x0,'status':_0x20911b,'from_session':p});if(_0x5da221)G[_0x541d6a(0x1a4)](_0x5da221);return{'content':[{'type':'text','text':JSON[_0x541d6a(0x1c7)](_0x145383)}]};}let _0x198239=await Q(_0x541d6a(0x21a),{'resume_id':V,'alias':p,'status':_0x294e69===_0x541d6a(0x216)?'blocked':_0x294e69===_0x541d6a(0x186)?_0x541d6a(0x186):'working','task':_0x1c0b97[_0x541d6a(0x20d)](0x0,0xc8),'output':_0x1c0b97});return{'content':[{'type':_0x541d6a(0x1bf),'text':JSON[_0x541d6a(0x1c7)](_0x198239)}]};}if(_0x31a92d==='commhub_report_status'){let {status:_0xbc30f3,task:_0x593395,progress:_0x559b26}=_0x41a2ab,_0x251fe7=await Q('report_status',{'resume_id':V,'alias':p,'status':_0xbc30f3,'task':_0x593395,'progress':_0x559b26});return{'content':[{'type':'text','text':JSON['stringify'](_0x251fe7)}]};}if(_0x31a92d==='commhub_send_task'){let {alias:_0x27c473,task:_0x56202c,priority:_0x10f37e}=_0x41a2ab,_0x44b444=await Q(_0x541d6a(0x191),{'alias':_0x27c473,'task':_0x56202c,'priority':_0x10f37e||_0x541d6a(0x1ac),'from_session':p});return{'content':[{'type':_0x541d6a(0x1bf),'text':JSON[_0x541d6a(0x1c7)](_0x44b444)}]};}if(_0x31a92d===_0x541d6a(0x20b)){let {alias:_0x5245d0,message:_0x5e246d}=_0x41a2ab,_0x2ce042=await Q(_0x541d6a(0x1f0),{'alias':_0x5245d0,'message':_0x5e246d,'from_session':p});return{'content':[{'type':_0x541d6a(0x1bf),'text':JSON[_0x541d6a(0x1c7)](_0x2ce042)}]};}if(_0x31a92d==='commhub_get_all_status'){let _0x5a7c9e=await Q(_0x541d6a(0x1ce),{});return{'content':[{'type':'text','text':JSON[_0x541d6a(0x1c7)](_0x5a7c9e)}]};}return{'content':[{'type':_0x541d6a(0x1bf),'text':JSON[_0x541d6a(0x1c7)]({'error':_0x541d6a(0x1c0)})}]};});var D=0x3e8,v=0x7530,O=0x36ee80;async function m(){const _0x3e275d=a0_0x2c4552;try{await Q('report_status',{'resume_id':V,'alias':p,'status':'idle','server':a0_0x2b7f10(),'hostname':a0_0x2b7f10(),'agent':_0x3e275d(0x1ff),'project_dir':process[_0x3e275d(0x1df)](),'tmux_name':j||void 0x0}),z('re-registered\x20as\x20\x22'+p+_0x3e275d(0x1a2));}catch(_0x5c2899){z(_0x3e275d(0x214)+_0x5c2899);}}async function l(){const _0x5f560d=a0_0x2c4552;let _0xc2e708=Y+'/events/'+encodeURIComponent(p),_0x3041ab={};if(k)_0x3041ab[_0x5f560d(0x1b9)]='Bearer\x20'+k;z('connecting\x20to\x20'+_0xc2e708);let _0x5bb519=D,_0x467333=!0x0,_0x5a889c=null;while(!0x0){try{let _0x5b3cdd=await fetch(_0xc2e708,{'headers':_0x3041ab});if(!_0x5b3cdd['ok']){if(z(_0x5f560d(0x1a6)+_0x5b3cdd[_0x5f560d(0x1b8)]+'\x20'+_0x5b3cdd[_0x5f560d(0x185)]),_0x5a889c=_0x5a889c??Date['now'](),Date['now']()-_0x5a889c>O){z(_0x5f560d(0x20c)+Y+_0x5f560d(0x1af));return;}await i(_0x5bb519),_0x5bb519=Math[_0x5f560d(0x1c2)](_0x5bb519*0x2,v);continue;}let _0x7459c4=_0x5b3cdd[_0x5f560d(0x1e2)]['getReader'](),_0x620e50=new TextDecoder(),_0x1e778f='';_0x5bb519=D;while(!0x0){let {done:_0x5a9faf,value:_0x479f88}=await _0x7459c4[_0x5f560d(0x219)]();if(_0x5a9faf)break;_0x1e778f+=_0x620e50[_0x5f560d(0x20e)](_0x479f88,{'stream':!0x0});let _0x39ee81=_0x1e778f[_0x5f560d(0x197)]('\x0a\x0a');_0x1e778f=_0x39ee81[_0x5f560d(0x223)]()||'';for(let _0x23cf8d of _0x39ee81){let _0x5327da=_0x23cf8d[_0x5f560d(0x197)]('\x0a')[_0x5f560d(0x1a1)](_0x3f0030=>_0x3f0030[_0x5f560d(0x1fd)](_0x5f560d(0x1bd)));if(!_0x5327da)continue;try{let _0x3d3dbb=JSON[_0x5f560d(0x1cb)](_0x5327da[_0x5f560d(0x20d)](0x6));if(await A(_0x3d3dbb),_0x3d3dbb[_0x5f560d(0x1b2)]===_0x5f560d(0x1fa)){if(_0x5a889c=null,!_0x467333)await m();_0x467333=!0x1;}}catch(_0x13f210){z('parse\x20error:\x20'+_0x13f210);}}}z('SSE\x20stream\x20ended,\x20reconnecting...');}catch(_0x31208b){z(_0x5f560d(0x1a5)+_0x31208b);}if(_0x5a889c=_0x5a889c??Date[_0x5f560d(0x192)](),Date['now']()-_0x5a889c>O){z(_0x5f560d(0x20c)+Y+_0x5f560d(0x1af));return;}await i(_0x5bb519),_0x5bb519=Math['min'](_0x5bb519*0x2,v);}}async function A(_0x3522f4){const _0x2327ce=a0_0x2c4552;if(_0x3522f4[_0x2327ce(0x1b2)]===_0x2327ce(0x1fa)){z(_0x2327ce(0x1b3)+p+'\x22');return;}if(_0x3522f4[_0x2327ce(0x1b2)]===_0x2327ce(0x1c5)){if(z(_0x2327ce(0x1b0)+_0x3522f4[_0x2327ce(0x1f5)]+':\x20'+_0x3522f4[_0x2327ce(0x1cc)][_0x2327ce(0x20d)](0x0,0x3c)),await K[_0x2327ce(0x1c3)]({'method':_0x2327ce(0x189),'params':{'content':_0x3522f4[_0x2327ce(0x1cc)],'meta':{'sender':_0x3522f4[_0x2327ce(0x1f5)]||_0x2327ce(0x1a7),'sender_id':_0x2327ce(0x20a),'user':_0x3522f4['from']||_0x2327ce(0x1a7),'priority':_0x2327ce(0x1ac)}}}),_0x3522f4[_0x2327ce(0x211)])await Q(_0x2327ce(0x226),{'alias':p,'message_id':_0x3522f4[_0x2327ce(0x211)]});return;}if(_0x3522f4[_0x2327ce(0x1b2)]===_0x2327ce(0x18a)||_0x3522f4[_0x2327ce(0x1b2)]==='broadcast'){z('←\x20'+_0x3522f4['type']+_0x2327ce(0x210)+_0x3522f4[_0x2327ce(0x19f)]+'\x20priority='+(_0x3522f4[_0x2327ce(0x188)]||'normal'));let _0x30292b=await Q(_0x2327ce(0x184),{'alias':p,'limit':0x5});if(_0x30292b?.['ok']&&_0x30292b[_0x2327ce(0x1cf)]?.[_0x2327ce(0x1e4)]>0x0)for(let _0x5eba3c of _0x30292b[_0x2327ce(0x1cf)]){let _0x304692={'sender':_0x5eba3c['from_session']||_0x2327ce(0x1a7),'sender_id':_0x2327ce(0x20a),'user':_0x5eba3c[_0x2327ce(0x1ee)]||'hub','task_id':_0x5eba3c['id'],'priority':_0x5eba3c['priority']||_0x2327ce(0x1ac)};G['set'](_0x5eba3c['id'],_0x5eba3c[_0x2327ce(0x1ee)]||'hub'),await K[_0x2327ce(0x1c3)]({'method':_0x2327ce(0x189),'params':{'content':_0x5eba3c['content'],'meta':_0x304692}}),z(_0x2327ce(0x1b5)+_0x5eba3c['id'][_0x2327ce(0x20d)](0x0,0x8)+_0x2327ce(0x1a3)+_0x5eba3c[_0x2327ce(0x1ee)]+':\x20'+_0x5eba3c['content']['slice'](0x0,0x3c)),await Q(_0x2327ce(0x226),{'alias':p,'message_id':_0x5eba3c['id']});}}}async function t(){const _0x17a8e7=a0_0x2c4552;let _0x4ef0db=new a0_0x2e972b();await K[_0x17a8e7(0x198)](_0x4ef0db),z(_0x17a8e7(0x1fc)),z(_0x17a8e7(0x1c9)),l()[_0x17a8e7(0x225)](_0x3d2499=>z(_0x17a8e7(0x1ca)+_0x3d2499)),Q(_0x17a8e7(0x21a),{'resume_id':V,'alias':p,'status':_0x17a8e7(0x1f4),'server':a0_0x2b7f10(),'hostname':a0_0x2b7f10(),'agent':'claude-code','project_dir':process['cwd'](),'tmux_name':j||void 0x0})[_0x17a8e7(0x1d4)](()=>z(_0x17a8e7(0x203)+p+_0x17a8e7(0x1e9)+V['slice'](0x0,0x8)+')'))[_0x17a8e7(0x225)](_0x3bd44c=>z(_0x17a8e7(0x1ed)+_0x3bd44c)),setInterval(()=>{const _0x53f364=_0x17a8e7;Q(_0x53f364(0x21a),{'resume_id':V,'alias':p,'status':'idle','server':a0_0x2b7f10(),'hostname':a0_0x2b7f10(),'agent':_0x53f364(0x1ff),'project_dir':process['cwd'](),'tmux_name':j||void 0x0})['catch'](_0x37eb18=>z(_0x53f364(0x1bb)+_0x37eb18));},0x2bf20),z('ready\x20—\x20waiting\x20for\x20events');}t()['catch'](_0x5667be=>{const _0x50eea1=a0_0x2c4552;z(_0x50eea1(0x183)+_0x5667be),process[_0x50eea1(0x1a0)](0x1);});async function b(){const _0x3b3bad=a0_0x2c4552;z(_0x3b3bad(0x1b6)),await Q(_0x3b3bad(0x21a),{'resume_id':V,'alias':p,'status':_0x3b3bad(0x222),'task':_0x3b3bad(0x1ec)})[_0x3b3bad(0x225)](()=>{}),process[_0x3b3bad(0x1a0)](0x0);}process[a0_0x2c4552(0x1a9)]['on']('end',()=>b()),process['on'](a0_0x2c4552(0x205),()=>b()),process['on'](a0_0x2c4552(0x208),()=>b());var d=process[a0_0x2c4552(0x1ae)];if(d&&d>0x1){let h=setInterval(()=>{const _0x4c20f8=a0_0x2c4552;if(process[_0x4c20f8(0x1ae)]===0x1&&d!==0x1){z('parent\x20claude\x20died\x20(reparented\x20to\x20PID\x201\x20from\x20'+d+_0x4c20f8(0x1d1)),b();return;}try{process[_0x4c20f8(0x1ab)](d,0x0);}catch(_0x23cf66){if(_0x23cf66?.[_0x4c20f8(0x1fb)]===_0x4c20f8(0x187))z('parent\x20claude\x20pid='+d+_0x4c20f8(0x1eb)),b();}},0x7530);if(typeof h[a0_0x2c4552(0x212)]==='function')h['unref']();} |
@@ -1,2 +0,2 @@ | ||
| export declare const OPENCODE_AGENT_NETWORK_VERSION = "2.3.0-preview.36"; | ||
| export declare const OPENCODE_AGENT_NETWORK_VERSION = "2.3.0-preview.34"; | ||
| export declare const OPENCODE_AGENT_NODE_VERSION = "2.5.0-preview.26"; | ||
@@ -3,0 +3,0 @@ export declare const OPENCODE_AGENT_NODE_SPEC = "@sleep2agi/agent-node@2.5.0-preview.26"; |
+1
-1
| { | ||
| "name": "@sleep2agi/agent-network", | ||
| "version": "2.3.0-preview.36", | ||
| "version": "2.3.0-preview.37", | ||
| "description": "AI Agent Network CLI — Local-first multi-agent orchestration across 6 runtimes (Claude Code CLI / Claude Agent SDK / Codex SDK / Codex app-server / Grok Build ACP / OpenCode CLI) and 8+ LLM providers. Apache 2.0.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
+35
-334
@@ -8,97 +8,33 @@ # Agent Network (`anet`) | ||
| Run a local network of AI agents from one CLI. | ||
| `anet` connects local AI agents through one self-hosted Hub. It starts CommHub and the Dashboard, creates node identities, and manages node lifecycle, networks, tokens, tasks, and channels. | ||
| `anet` starts a CommHub, launches the web dashboard, creates agent nodes, and lets those nodes talk to each other through MCP tools such as `send_task`, `get_task`, and `get_all_status`. | ||
| ## What It Is | ||
| Agent Network is a local-first multi-agent runtime: | ||
| - **CommHub**: MCP + REST + SSE hub for task routing, auth, networks, and status. | ||
| - **Agent nodes**: long-running AI workers backed by Claude Code, Claude Agent SDK, Codex SDK, Codex app-server, Grok Build ACP, or OpenCode ACP. | ||
| - **Dashboard**: browser UI for topology, chat, tasks, node health, and server telemetry. | ||
| - **CLI**: `anet`, the single entry point for setup, auth, node lifecycle, and demos. | ||
| The default path runs entirely on your machine. LAN sharing is opt-in. | ||
| ## Requirements | ||
| - Node.js **>= 22.13.0** | ||
| - npm **>= 10** | ||
| - Bun **>= 1.2.0** (`anet hub start` lazy-runs the Bun-based CommHub server) | ||
| - macOS or Linux | ||
| Install Bun if needed: | ||
| ```bash | ||
| curl -fsSL https://bun.sh/install | bash | ||
| ``` | ||
| ## Install | ||
| Stable: | ||
| Requires Node.js ≥ 22.13 and Bun ≥ 1.2. | ||
| ```bash | ||
| npm install -g @sleep2agi/agent-network | ||
| anet -v | ||
| npm install -g bun @sleep2agi/agent-network @sleep2agi/agent-node | ||
| ``` | ||
| Preview channel: | ||
| Stable releases use npm's `latest` tag. Features that are still being validated use `preview`: | ||
| ```bash | ||
| npm install -g @sleep2agi/agent-network@preview | ||
| anet -v | ||
| anet upgrade --channel preview | ||
| ``` | ||
| Canonical OpenCode preview (exact vetted pair; automatic `npx` fallback is intentionally disabled): | ||
| Do not copy fixed package or preview numbers from old issues. Check the [versioning guide](https://anet.sh/guide/versioning) and npm dist-tags for the current release. | ||
| ```bash | ||
| npm install -g @sleep2agi/agent-network@2.3.0-preview.34 \ | ||
| @sleep2agi/agent-node@2.5.0-preview.26 \ | ||
| opencode-ai@1.18.1 | ||
| ``` | ||
| ## Quick start | ||
| Current npm dist-tags verified on 2026-05-28 (v0.10.11 stable): | ||
| Open three terminals: | ||
| | Package | latest | preview | | ||
| |---|---:|---:| | ||
| | `@sleep2agi/agent-network` | `2.2.10` | `2.2.10-preview.3` | | ||
| | `@sleep2agi/commhub-server` | `0.8.4` | `0.8.4-preview.1` | | ||
| | `@sleep2agi/agent-network-dashboard` | `0.5.6` | `0.5.7-preview.2` | | ||
| | `@sleep2agi/agent-node` | `2.4.7` | `2.4.8-preview.0` | | ||
| ## 5-Minute Quick Start | ||
| Open three terminals. | ||
| ### 1. Start CommHub | ||
| ```bash | ||
| # Terminal 1 — Hub | ||
| anet hub start | ||
| ``` | ||
| Default local URL: | ||
| ```text | ||
| http://127.0.0.1:9200 | ||
| ``` | ||
| By default the hub binds to localhost. Use `--host 0.0.0.0` only when you intentionally want LAN clients to connect. | ||
| ### 2. Start Dashboard | ||
| ```bash | ||
| # Terminal 2 — Dashboard | ||
| anet hub dashboard | ||
| ``` | ||
| Open: | ||
| ```text | ||
| http://localhost:3000 | ||
| ``` | ||
| ### 3. Log In, Create A Node, Start It | ||
| ```bash | ||
| anet login --hub http://127.0.0.1:9200 --username admin --password anethub | ||
| # Terminal 3 — login, create, start | ||
| anet login --hub http://127.0.0.1:9200 --username admin | ||
| anet node create my-bot | ||
@@ -108,272 +44,37 @@ anet node start my-bot | ||
| `anet node create` walks you through: | ||
| The node is ready after its log reports `SSE connected`. Open `http://localhost:3000` and send it a task from Dashboard. | ||
| 1. Runtime: `claude-agent-sdk`, `claude-code-cli`, `codex-sdk`, `codex-app-server`, `grok-build-acp`, or `opencode-cli` (the canonical preview picker has exactly these 6 choices). | ||
| 2. Provider preset: Anthropic, MiniMax, InternLM, Xiaomi MiMo, or `custom` (any Anthropic-compatible endpoint — used for DeepSeek / GLM / Kimi / OpenRouter etc.; Codex runtimes reuse Codex auth; grok-build-acp reuses Grok auth; opencode-cli offers Anthropic/OpenAI presets). | ||
| 3. API key and model settings. | ||
| ## Runtime selection | ||
| When the node starts successfully, look for: | ||
| `anet node create` shows only runtimes available in the installed release channel. Installation, authentication, permissions, and current availability are maintained in the [runtime guide](https://anet.sh/guide/runtimes). | ||
| ```text | ||
| SSE connected | ||
| ``` | ||
| - Claude Code, Claude Agent SDK, Codex SDK, and Grok Build ACP are the published task-runtime paths. | ||
| - Codex TUI co-presence is preview-only and must be started and recovered with `--copresence`; see the [co-presence guide](https://anet.sh/guide/codex-copresence). | ||
| - OpenCode support is preview-only. Its automatic `npx` fallback is intentionally disabled, so install the documented CLI explicitly. | ||
| - Neither npm `latest` nor `preview` includes a shared Grok TUI. Use `grok-build-acp` for published Grok nodes and follow the [Grok TUI status page](https://anet.sh/guide/grok-copresence). | ||
| Then use the Dashboard chat panel to send `my-bot` a message. | ||
| Development branches may contain source-only runtime experiments. They are not supported installation paths until they appear in an npm dist-tag and the runtime guide. | ||
| ## Multi-Agent Collaboration | ||
| ## What it provides | ||
| Create a second node: | ||
| - **CommHub** — MCP, REST, SSE task delivery, authentication, networks, and audit state. | ||
| - **Agent Node** — long-running workers backed by the selected runtime. | ||
| - **Dashboard** — topology, chat, tasks, messages, and node health. | ||
| - **CLI** — setup, login, node/project lifecycle, channels, tokens, and diagnostics. | ||
| ```bash | ||
| anet node create reviewer | ||
| anet node start reviewer | ||
| ``` | ||
| Runtimes with CommHub tool integration can discover peers and delegate work with tools such as `get_all_status`, `send_task`, and `get_task`. Replies and ordinary messages do not recursively invoke another model; see the [task lifecycle](https://anet.sh/concepts/task-lifecycle). | ||
| Ask `my-bot`: | ||
| ## Security | ||
| ```text | ||
| Ask reviewer to review this plan and summarize the risks. | ||
| ``` | ||
| The default Hub is local-only. Before exposing it beyond localhost, change the initial password and follow the [production deployment guide](https://anet.sh/deploy/production). Do not copy `.anet` node configs between machines: they contain network-bound identity and token material. | ||
| The first agent can discover peers with `get_all_status`, delegate work with `send_task`, poll with `get_task`, and integrate the reply. The dashboard Tasks and Messages views show the chain. | ||
| ## LAN Hub | ||
| On the hub machine: | ||
| ```bash | ||
| anet hub start --host 0.0.0.0 | ||
| ``` | ||
| On another machine: | ||
| ```bash | ||
| npm install -g @sleep2agi/agent-network | ||
| anet init --hub http://<HUB-LAN-IP>:9200 | ||
| anet login --username admin --password anethub | ||
| anet node create remote-bot | ||
| anet node start remote-bot | ||
| ``` | ||
| Do not expose the hub directly to the public internet without a reverse proxy, HTTPS, firewall rules, and reviewed auth settings. | ||
| ## Runtimes | ||
| | Runtime | Use When | Notes | | ||
| |---|---|---| | ||
| | `claude-code-cli` | You want Claude Code CLI sessions and channel support | Uses Claude Code process; supports stable `COMMHUB_RESUME_ID` in recent previews | | ||
| | `claude-agent-sdk` | You want Anthropic-compatible API providers | Good default for provider presets | | ||
| | `codex-sdk` | You want Codex-backed nodes | Useful as a backup runtime when Claude quota is constrained | | ||
| | `codex-app-server` | You want a Codex TUI thread shared with network tasks | Canonical preview; connects to the local app-server over WebSocket | | ||
| | `grok-build-acp` | You want Grok Build through `grok agent stdio` | Requires Grok Build CLI auth; stable for receive/reply, session persistence, and explicit `send_task` delegation | | ||
| | `opencode-cli` | You want public OpenCode ACP with Anthropic/OpenAI presets | Canonical preview; exact `opencode-ai@1.18.1` and exact network/node pair required | | ||
| ### Grok Build ACP | ||
| `grok-build-acp` uses the local Grok Build CLI via Agent Client Protocol (ACP). Install and authenticate Grok first: | ||
| ```bash | ||
| curl -fsSL https://x.ai/cli/install.sh | bash | ||
| grok | ||
| ``` | ||
| Create and start a node: | ||
| ```bash | ||
| anet node create grok-demo --runtime grok-build-acp | ||
| anet node start grok-demo | ||
| ``` | ||
| Look for: | ||
| ```text | ||
| runtime: grok-build-acp | ||
| SSE connected | ||
| ``` | ||
| Stable support: | ||
| - Receive CommHub tasks through SSE. | ||
| - Run one Grok Build ACP turn per task. | ||
| - Persist `grokSession` into `.anet/nodes/<name>/config.json`. | ||
| - Resume the saved Grok session on the next task. | ||
| - Reply to the original sender through CommHub. | ||
| - Explicit delegation such as `给 A站助手 发任务: ...` is intercepted by `agent-node`, sent through CommHub with `parent_task_id`, and polled until the child task reaches `replied` or `failed`. | ||
| Current boundary: | ||
| - Grok native MCP tool injection is not the stable path yet. | ||
| - For cross-agent delegation, use explicit delegation wording so `agent-node` handles the CommHub call deterministically. | ||
| - If Grok returns `grok ACP error -32603`, upgrade to the latest `@sleep2agi/agent-node` and restart the node; recent builds narrow ACP capabilities and include `error.data` diagnostics. | ||
| Details: `docs/grok-build-runtime.md`. | ||
| ## Provider Presets | ||
| `anet node create` writes the correct provider environment into `.anet/nodes/<name>/config.json`. | ||
| | Provider | Status | Notes | | ||
| |---|---|---| | ||
| | Anthropic | verified path | Native Anthropic Messages API | | ||
| | MiniMax | verified path | Anthropic-compatible endpoint | | ||
| | DeepSeek | verified path | Anthropic-compatible endpoint | | ||
| | GLM / Zhipu | verified path | Anthropic-compatible endpoint | | ||
| | Kimi / Moonshot | verified path | Anthropic-compatible endpoint | | ||
| | OpenRouter | available | Anthropic-compatible routing | | ||
| | Custom | available | Provide base URL, model, and token | | ||
| ## Common Commands | ||
| ```bash | ||
| # Hub and dashboard | ||
| anet hub start | ||
| anet hub dashboard | ||
| # Auth | ||
| anet register | ||
| anet login --username <user> --password <password> | ||
| anet logout | ||
| anet whoami | ||
| anet passwd | ||
| # Nodes | ||
| anet node create <name> | ||
| anet node start <name> | ||
| anet node start --all | ||
| anet node stop <name> | ||
| anet node resume <name> | ||
| anet node rename <old> <new> --force | ||
| anet node delete <name> | ||
| anet node ls | ||
| anet info <name> | ||
| anet logs <name> | ||
| # Network status and repair | ||
| anet status | ||
| anet tasks [status] | ||
| anet doctor | ||
| anet doctor --fix | ||
| # Project and session helpers | ||
| anet init --hub <url> | ||
| anet init project | ||
| anet project up | ||
| anet project restart | ||
| anet project down | ||
| anet session ls | ||
| # Channels and upgrades | ||
| anet channel add telegram <name> --bot-token <tok> --allow <uid> | ||
| anet channel add feishu <name> --app-id <id> --app-secret <secret> --allow <open-id> # see docs/feishu-quickstart.md | ||
| anet channel ls | ||
| anet upgrade | ||
| anet upgrade --channel preview --dry-run | ||
| # Batch / demos | ||
| anet create --batch | ||
| anet batch list | ||
| anet batch stop <prefix> | ||
| anet demo sci-team | ||
| ``` | ||
| ## Configuration Files | ||
| ```text | ||
| ~/.anet/config.json | ||
| Global CLI profile: hub URL, user token, default network. | ||
| ~/.anet/server/admin-utok.json | ||
| Local bootstrap admin token for the hub. | ||
| {project}/.anet/nodes/<name>/config.json | ||
| Per-node runtime, model, provider env, node token, channels, and session IDs. | ||
| ``` | ||
| Example node config: | ||
| ```json | ||
| { | ||
| "node_id": "n_a1b2c3d4", | ||
| "node_name": "my-bot", | ||
| "alias": "my-bot", | ||
| "hub": "http://127.0.0.1:9200", | ||
| "network_id": "default", | ||
| "token": "ntok_...", | ||
| "runtime": "claude-agent-sdk", | ||
| "model": "your-model", | ||
| "channels": ["server:commhub"], | ||
| "tools": ["Read", "Write", "Edit", "Bash", "Glob", "Grep"], | ||
| "env": { | ||
| "ANTHROPIC_BASE_URL": "https://example.com/anthropic", | ||
| "ANTHROPIC_AUTH_TOKEN": "sk-..." | ||
| }, | ||
| "flags": { | ||
| "dangerouslySkipPermissions": true, | ||
| "teammateMode": "in-process", | ||
| "maxTurns": 50 | ||
| } | ||
| } | ||
| ``` | ||
| Do not commit `.anet/` or provider API keys. | ||
| ## Security Notes | ||
| - The hub binds to `127.0.0.1` by default. | ||
| - LAN mode is explicit: `anet hub start --host 0.0.0.0`. | ||
| - Node tokens are network-scoped `ntok_` tokens; user tokens are `utok_`. | ||
| - Keep API keys in local node config or env refs; never paste real keys into issues or docs. | ||
| - Treat tmux / terminal streaming features as local-admin tools. | ||
| ## What Is Stable vs Experimental | ||
| Stable day-to-day path: | ||
| - `anet hub start` / `anet hub stop` / `anet hub status` (v0.10.11+: SIGTERM → 3s grace → SIGKILL stop; status shows PID + port + `/health` version — no more manual `lsof+kill`) | ||
| - `anet hub dashboard` | ||
| - `anet login` | ||
| - `anet node create/start/stop/delete/rename` | ||
| - `anet node start --all` | ||
| - `anet project up/restart/down` | ||
| - Dashboard chat, task list, topology, and status views | ||
| Actively evolving: | ||
| - IM platform integration (Feishu / Slack / WhatsApp / WeCom) | ||
| - Telegram channel binding | ||
| - Advanced dashboard topology edges | ||
| - Batch orchestration and science-team demos | ||
| - Codex runtime expansion | ||
| - Grok Build ACP runtime | ||
| - Cross-version rename hot-reload | ||
| ## Documentation | ||
| - Docs site: https://anet.sh | ||
| - Getting started: https://anet.sh/guide/getting-started | ||
| - Preview guide: https://anet.sh/guide/preview/getting-started | ||
| - Issues: https://github.com/sleep2agi/agent-network/issues | ||
| - [Getting started](https://anet.sh/guide/getting-started) | ||
| - [CLI reference](https://anet.sh/guide/cli) | ||
| - [Runtime guide](https://anet.sh/guide/runtimes) | ||
| - [Tokens and permissions](https://anet.sh/concepts/tokens) | ||
| - [Troubleshooting](https://anet.sh/troubleshooting) | ||
| - [GitHub repository](https://github.com/sleep2agi/agent-network) | ||
| ## Repository Layout | ||
| This package lives in the `agent-network/` subdirectory of the monorepo: | ||
| ```text | ||
| agent-network/ | ||
| bin/cli.ts anet CLI | ||
| src/client.ts SDK client | ||
| src/node-server.ts CommHub MCP server bridge used by claude-code-cli | ||
| src/im/ IM integration contracts and future adapters | ||
| ``` | ||
| Related packages live next to it: | ||
| ```text | ||
| server/ @sleep2agi/commhub-server | ||
| agent-node/ @sleep2agi/agent-node | ||
| docs-site/ anet.sh documentation site | ||
| ``` | ||
| ## License | ||
| Apache-2.0 | ||
| Apache-2.0. |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Obfuscated code
Supply chain riskObfuscated files are intentionally packed to hide their behavior. This could be a sign of malware.
Found 2 instances
Obfuscated code
Supply chain riskObfuscated files are intentionally packed to hide their behavior. This could be a sign of malware.
Found 2 instances
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
12
-7.69%4323614
-0.69%11062
-0.01%79
-79.1%