@sleep2agi/agent-network 2.1.8 → 2.1.9
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.
- package/README.md +0 -1
- package/dist/bin/cli.js +1 -1
- package/dist/src/client.js +1 -1
- package/dist/src/node-server.js +1 -1
- package/package.json +3 -2
- package/dist/client.d.ts +0 -78
package/dist/src/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a0_0xc3775a=a0_0x1620;(function(_0x7e81ed,_0x238b18){const _0xf45c2f=a0_0x1620,_0x31c1c9=_0x7e81ed();while(!![]){try{const _0x42c987=-parseInt(_0xf45c2f(0x1cd))/0x1*(parseInt(_0xf45c2f(0x1cc))/0x2)+-parseInt(_0xf45c2f(0x1b1))/0x3+parseInt(_0xf45c2f(0x1c2))/0x4*(parseInt(_0xf45c2f(0x193))/0x5)+parseInt(_0xf45c2f(0x1cb))/0x6*(parseInt(_0xf45c2f(0x1a9))/0x7)+-parseInt(_0xf45c2f(0x1e7))/0x8*(parseInt(_0xf45c2f(0x1d6))/0x9)+-parseInt(_0xf45c2f(0x1c8))/0xa*(parseInt(_0xf45c2f(0x19d))/0xb)+parseInt(_0xf45c2f(0x197))/0xc*(parseInt(_0xf45c2f(0x1e2))/0xd);if(_0x42c987===_0x238b18)break;else _0x31c1c9['push'](_0x31c1c9['shift']());}catch(_0x458646){_0x31c1c9['push'](_0x31c1c9['shift']());}}}(a0_0x5a32,0x2f778));function a0_0x1620(_0x2c719d,_0x4b5ffb){_0x2c719d=_0x2c719d-0x18b;const _0x5a320a=a0_0x5a32();let _0x1620b9=_0x5a320a[_0x2c719d];return _0x1620b9;}function a0_0x5a32(){const _0x42de24=['/mcp','toTimeString','connect','match','server','type','cwd','581581kKtrQZ','completed','catch','running','disconnected','263528OITtiI','heartbeatInterval','send_reply','reply','signal','reconnectDelay','slice','connectSSE','token','startsWith','890YgBmNv','alias','getAllStatus','get_all_status','84XeRnwC','application/json,\x20text/event-stream','send_task','emit','status','connected','938377FHubRV','name','idle','data:\x20','text','error','Authorization','message','registered','broadcast','read','/events/','693BwjPzt','toString',']\x20[commhub:','AbortError','content','resumeId','SSE\x20connected','new_task','679941uuOOkn','now','task','body','text/event-stream','call','POST','Bearer\x20','2.0','disconnect','parse','processInbox','heartbeatTimer','sleep','agent','normal','messages','6712PfqDSY','new_message','application/json','sdk-','url','min','20QwgnKa','pop','ack_inbox','2250ecWWty','24342viJeta','2ezKyro','tools/call','replace','sseAbort','SSE\x20reconnecting\x20in\x20','inbox\x20error:\x20','log','getReader','abort','9rPJQKe','send_message','from_session','s...','report_status'];a0_0x5a32=function(){return _0x42de24;};return a0_0x5a32();}import{EventEmitter as a0_0x5de05e}from'events';import{hostname as a0_0xb19dbf}from'os';class T extends a0_0x5de05e{[a0_0xc3775a(0x1c6)];['alias'];['token'];['agent'];[a0_0xc3775a(0x1ae)];['heartbeatInterval'];[a0_0xc3775a(0x18e)];[a0_0xc3775a(0x1bd)];[a0_0xc3775a(0x1d0)];[a0_0xc3775a(0x1e5)]=!0x1;constructor(_0x4f78b6){const _0x575b5f=a0_0xc3775a;super();if(this[_0x575b5f(0x1c6)]=_0x4f78b6[_0x575b5f(0x1c6)][_0x575b5f(0x1cf)](/\/$/,''),this[_0x575b5f(0x194)]=_0x4f78b6[_0x575b5f(0x194)],this['token']=_0x4f78b6['token'],this[_0x575b5f(0x1bf)]=_0x4f78b6['agent']||'sdk',this[_0x575b5f(0x1ae)]=_0x575b5f(0x1c5)+_0x4f78b6['alias']+'-'+Date[_0x575b5f(0x1b2)]()[_0x575b5f(0x1aa)](0x24),this[_0x575b5f(0x1e8)]=_0x4f78b6[_0x575b5f(0x1e8)]??0x2bf20,this[_0x575b5f(0x18e)]=_0x4f78b6[_0x575b5f(0x18e)]??0xbb8,_0x4f78b6['autoConnect']!==!0x1)this[_0x575b5f(0x1dd)]();}[a0_0xc3775a(0x1d3)](_0x5648f6){const _0x362c04=a0_0xc3775a;console[_0x362c04(0x1d3)]('['+new Date()[_0x362c04(0x1dc)]()[_0x362c04(0x18f)](0x0,0x8)+_0x362c04(0x1ab)+this[_0x362c04(0x194)]+']\x20'+_0x5648f6);}async[a0_0xc3775a(0x1b6)](_0x1af9f4,_0x270c95){const _0x579c20=a0_0xc3775a;let _0x366733={'Content-Type':_0x579c20(0x1c4),'Accept':_0x579c20(0x198)};if(this['token'])_0x366733[_0x579c20(0x1a3)]=_0x579c20(0x1b8)+this[_0x579c20(0x191)];let _0x314783=await(await fetch(this[_0x579c20(0x1c6)]+_0x579c20(0x1db),{'method':_0x579c20(0x1b7),'headers':_0x366733,'body':JSON['stringify']({'jsonrpc':_0x579c20(0x1b9),'id':Date['now'](),'method':_0x579c20(0x1ce),'params':{'name':_0x1af9f4,'arguments':_0x270c95}})}))[_0x579c20(0x1a1)](),_0x18f4b4=_0x314783[_0x579c20(0x1de)](/data: (.+)/),_0x2b5360=_0x18f4b4?JSON[_0x579c20(0x1bb)](_0x18f4b4[0x1]):JSON[_0x579c20(0x1bb)](_0x314783),_0x34238a=_0x2b5360?.['result']?.['content']?.[0x0]?.[_0x579c20(0x1a1)];return _0x34238a?JSON[_0x579c20(0x1bb)](_0x34238a):_0x2b5360;}async[a0_0xc3775a(0x1dd)](){const _0x1c4b9f=a0_0xc3775a;if(this[_0x1c4b9f(0x1e5)])return;this[_0x1c4b9f(0x1e5)]=!0x0,await this[_0x1c4b9f(0x19b)](_0x1c4b9f(0x19f)),this['log'](_0x1c4b9f(0x1a5)),this['heartbeatTimer']=setInterval(()=>{const _0x2461ed=_0x1c4b9f;this[_0x2461ed(0x19b)](_0x2461ed(0x19f))['catch'](_0x40bd89=>this[_0x2461ed(0x1d3)]('heartbeat\x20failed:\x20'+_0x40bd89[_0x2461ed(0x1a4)]));},this['heartbeatInterval']),this[_0x1c4b9f(0x190)]();}async[a0_0xc3775a(0x1ba)](){const _0xa1e595=a0_0xc3775a;if(this[_0xa1e595(0x1e5)]=!0x1,this[_0xa1e595(0x1d0)]?.[_0xa1e595(0x1d5)](),this['heartbeatTimer'])clearInterval(this[_0xa1e595(0x1bd)]);await this[_0xa1e595(0x19b)]('offline')[_0xa1e595(0x1e4)](()=>{}),this[_0xa1e595(0x1d3)]('disconnected');}async['send'](_0xff37a8,_0xc2d5fe,_0x4a0839=a0_0xc3775a(0x1c0)){const _0x1c93ff=a0_0xc3775a;return this[_0x1c93ff(0x1b6)](_0x1c93ff(0x199),{'alias':_0xff37a8,'task':_0xc2d5fe,'priority':_0x4a0839,'from_session':this[_0x1c93ff(0x194)]});}async[a0_0xc3775a(0x1a4)](_0x38ab8a,_0x3c8810){const _0x263968=a0_0xc3775a;return this[_0x263968(0x1b6)](_0x263968(0x1d7),{'alias':_0x38ab8a,'message':_0x3c8810,'from_session':this[_0x263968(0x194)]});}async[a0_0xc3775a(0x18c)](_0x6b5a86,_0x248aa0,_0x25e08d=a0_0xc3775a(0x1e3)){const _0x48393a=a0_0xc3775a;return this[_0x48393a(0x1b6)](_0x48393a(0x18b),{'in_reply_to':_0x6b5a86,'text':_0x248aa0,'status':_0x25e08d});}async[a0_0xc3775a(0x19b)](_0x3c50a,_0x34e431){const _0x410dab=a0_0xc3775a;return this['call'](_0x410dab(0x1da),{'resume_id':this[_0x410dab(0x1ae)],'alias':this[_0x410dab(0x194)],'status':_0x3c50a,'server':a0_0xb19dbf(),'hostname':a0_0xb19dbf(),'agent':this[_0x410dab(0x1bf)],'project_dir':process[_0x410dab(0x1e1)](),..._0x34e431});}async[a0_0xc3775a(0x195)](){const _0x1098d8=a0_0xc3775a;return this[_0x1098d8(0x1b6)](_0x1098d8(0x196),{});}async[a0_0xc3775a(0x1a6)](_0x220d4f,_0x5841f1){const _0x4e3480=a0_0xc3775a;return this[_0x4e3480(0x1b6)](_0x4e3480(0x1a6),{'message':_0x220d4f,'filter_server':_0x5841f1?.[_0x4e3480(0x1df)],'filter_status':_0x5841f1?.[_0x4e3480(0x19b)]});}async[a0_0xc3775a(0x190)](){const _0xcd4bb1=a0_0xc3775a;let _0x396dbf=encodeURIComponent(this[_0xcd4bb1(0x194)]),_0x345755=this[_0xcd4bb1(0x1c6)]+_0xcd4bb1(0x1a8)+_0x396dbf,_0x1628c2=this['reconnectDelay'];while(this[_0xcd4bb1(0x1e5)]){try{this[_0xcd4bb1(0x1d0)]=new AbortController();let _0x4031aa={'Accept':_0xcd4bb1(0x1b5)};if(this[_0xcd4bb1(0x191)])_0x4031aa[_0xcd4bb1(0x1a3)]='Bearer\x20'+this[_0xcd4bb1(0x191)];let _0x9e5205=await fetch(_0x345755,{'headers':_0x4031aa,'signal':this[_0xcd4bb1(0x1d0)][_0xcd4bb1(0x18d)]});if(!_0x9e5205['ok']||!_0x9e5205[_0xcd4bb1(0x1b4)]){this[_0xcd4bb1(0x1d3)]('SSE\x20failed:\x20'+_0x9e5205[_0xcd4bb1(0x19b)]),await this['sleep'](_0x1628c2),_0x1628c2=Math[_0xcd4bb1(0x1c7)](_0x1628c2*1.5,0xea60);continue;}_0x1628c2=this[_0xcd4bb1(0x18e)];let _0x479e21=_0x9e5205['body'][_0xcd4bb1(0x1d4)](),_0x156ead=new TextDecoder(),_0x4dfbf4='';while(this[_0xcd4bb1(0x1e5)]){let {done:_0x146e4b,value:_0x552206}=await _0x479e21[_0xcd4bb1(0x1a7)]();if(_0x146e4b)break;_0x4dfbf4+=_0x156ead['decode'](_0x552206,{'stream':!0x0});let _0x28b7e0=_0x4dfbf4['split']('\x0a');_0x4dfbf4=_0x28b7e0[_0xcd4bb1(0x1c9)]()||'';for(let _0x832aef of _0x28b7e0){if(!_0x832aef[_0xcd4bb1(0x192)](_0xcd4bb1(0x1a0)))continue;try{let _0x4579fd=JSON[_0xcd4bb1(0x1bb)](_0x832aef[_0xcd4bb1(0x18f)](0x6));if(_0x4579fd[_0xcd4bb1(0x1e0)]===_0xcd4bb1(0x19c)){this[_0xcd4bb1(0x1d3)](_0xcd4bb1(0x1af)),this[_0xcd4bb1(0x19a)](_0xcd4bb1(0x19c));continue;}if(_0x4579fd[_0xcd4bb1(0x1e0)]===_0xcd4bb1(0x1b0)||_0x4579fd[_0xcd4bb1(0x1e0)]===_0xcd4bb1(0x1c3)||_0x4579fd[_0xcd4bb1(0x1e0)]===_0xcd4bb1(0x1a6))await this['processInbox']();}catch{}}}}catch(_0x3bc04a){if(_0x3bc04a[_0xcd4bb1(0x19e)]===_0xcd4bb1(0x1ac))break;this[_0xcd4bb1(0x19a)](_0xcd4bb1(0x1a2),_0x3bc04a),this[_0xcd4bb1(0x1d3)]('SSE\x20error:\x20'+_0x3bc04a['message']);}if(this['running'])this[_0xcd4bb1(0x19a)](_0xcd4bb1(0x1e6)),this[_0xcd4bb1(0x1d3)](_0xcd4bb1(0x1d1)+_0x1628c2/0x3e8+_0xcd4bb1(0x1d9)),await this[_0xcd4bb1(0x1be)](_0x1628c2),_0x1628c2=Math[_0xcd4bb1(0x1c7)](_0x1628c2*1.5,0xea60);}}async[a0_0xc3775a(0x1bc)](){const _0xf5c8b5=a0_0xc3775a;try{let _0x23c7cd=(await this[_0xf5c8b5(0x1b6)]('get_inbox',{'alias':this[_0xf5c8b5(0x194)],'limit':0xa}))?.[_0xf5c8b5(0x1c1)]||[];for(let _0x874c9b of _0x23c7cd)await this[_0xf5c8b5(0x1b6)](_0xf5c8b5(0x1ca),{'alias':this[_0xf5c8b5(0x194)],'message_id':_0x874c9b['id']}),this['log']('←\x20'+_0x874c9b[_0xf5c8b5(0x1d8)]+':\x20'+_0x874c9b[_0xf5c8b5(0x1ad)][_0xf5c8b5(0x18f)](0x0,0x3c)),this['emit'](_0xf5c8b5(0x1b3),_0x874c9b),this[_0xf5c8b5(0x19a)](_0xf5c8b5(0x1a4),_0x874c9b);}catch(_0x21c9e7){this[_0xf5c8b5(0x1d3)](_0xf5c8b5(0x1d2)+_0x21c9e7[_0xf5c8b5(0x1a4)]);}}['sleep'](_0x130326){return new Promise(_0x19ae3a=>setTimeout(_0x19ae3a,_0x130326));}}var $=T;export{$ as default,T as CommHub};
|
package/dist/src/node-server.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
const a0_0x33500c=a0_0x26ff;(function(_0x5b8fae,_0x2510bb){const _0x98abaf=a0_0x26ff,_0x4cdc44=_0x5b8fae();while(!![]){try{const _0x418d3f=parseInt(_0x98abaf(0xff))/0x1*(-parseInt(_0x98abaf(0xca))/0x2)+-parseInt(_0x98abaf(0x89))/0x3*(parseInt(_0x98abaf(0xd4))/0x4)+-parseInt(_0x98abaf(0x8f))/0x5+parseInt(_0x98abaf(0xdd))/0x6*(-parseInt(_0x98abaf(0x81))/0x7)+parseInt(_0x98abaf(0xa1))/0x8+parseInt(_0x98abaf(0x95))/0x9*(parseInt(_0x98abaf(0x86))/0xa)+parseInt(_0x98abaf(0xaf))/0xb;if(_0x418d3f===_0x2510bb)break;else _0x4cdc44['push'](_0x4cdc44['shift']());}catch(_0x63be5){_0x4cdc44['push'](_0x4cdc44['shift']());}}}(a0_0xb31a,0x716e2));import{readFileSync as a0_0x2bfbd9,existsSync as a0_0x3db3d4}from'fs';import{randomUUID as a0_0x552445}from'crypto';import{join as a0_0x2d7caa}from'path';import{hostname as a0_0x35d7f8}from'os';import{execSync as a0_0x4523a5}from'child_process';import{Server as a0_0x1bf77a}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport as a0_0x22d501}from'@modelcontextprotocol/sdk/server/stdio.js';import{ListToolsRequestSchema as a0_0x22e0c1,CallToolRequestSchema as a0_0xde2443}from'@modelcontextprotocol/sdk/types.js';function p(_0x1c66a9){const _0xfa26d9=a0_0x26ff;if(!a0_0x3db3d4(_0x1c66a9))return;for(let _0x343556 of a0_0x2bfbd9(_0x1c66a9,_0xfa26d9(0xa7))[_0xfa26d9(0xd5)]('\x0a')){let _0x24ed3a=_0x343556[_0xfa26d9(0xbb)]();if(!_0x24ed3a||_0x24ed3a[_0xfa26d9(0xc1)]('#'))continue;let _0x2b677a=_0x24ed3a[_0xfa26d9(0xdb)]('=');if(_0x2b677a<0x0)continue;let _0x1354aa=_0x24ed3a[_0xfa26d9(0xbe)](0x0,_0x2b677a)[_0xfa26d9(0xbb)](),_0x1d227d=_0x24ed3a[_0xfa26d9(0xbe)](_0x2b677a+0x1)['trim']()[_0xfa26d9(0xb0)](/^["']|["']$/g,'');if(!process.env[_0x1354aa])process.env[_0x1354aa]=_0x1d227d;}}var C=process.env.HOME||'~',T=a0_0x2d7caa(C,a0_0x33500c(0xe8));p(a0_0x2d7caa(T,a0_0x33500c(0x10a)));var L=process[a0_0x33500c(0x7f)]()[a0_0x33500c(0xb0)](/\//g,'-');p(a0_0x2d7caa(T,L,a0_0x33500c(0x10a)));function U(){const _0x10e02f=a0_0x33500c;try{return a0_0x4523a5(_0x10e02f(0xbf),{'encoding':_0x10e02f(0xa7),'timeout':0x7d0})[_0x10e02f(0xbb)]();}catch{return'';}}function v(){const _0x526352=a0_0x33500c;try{let _0x5b245a=a0_0x2d7caa(C,'.anet',_0x526352(0x100));if(a0_0x3db3d4(_0x5b245a))return JSON[_0x526352(0xa5)](a0_0x2bfbd9(_0x5b245a,_0x526352(0xa7)));}catch{}return{};}var H=v(),f=process.env.COMMHUB_URL||H['hub']||a0_0x33500c(0xae),j=process.env.COMMHUB_TMUX||U(),Z=process.env.COMMHUB_ALIAS||j||a0_0x35d7f8(),w=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||a0_0x552445(),X=process.env.COMMHUB_TOKEN||H['token']||'';function Y(_0x37cd22){const _0x3096d7=a0_0x33500c;let _0x4c4d60=new Date()[_0x3096d7(0xfc)]()['slice'](0x0,0x8);process[_0x3096d7(0x107)][_0x3096d7(0xcb)]('['+_0x4c4d60+_0x3096d7(0x94)+_0x37cd22+'\x0a');}function h(_0x1bafcc){return new Promise(_0x5d2380=>setTimeout(_0x5d2380,_0x1bafcc));}Y(a0_0x33500c(0xd0)+f+a0_0x33500c(0xc5)+Z+a0_0x33500c(0xe5)+w[a0_0x33500c(0xbe)](0x0,0x8)+'...\x20TMUX='+(j||a0_0x33500c(0xf6))+'\x20CWD='+process['cwd']()+'\x20PROJECT_ENV='+L);var k=new Map(),K=new a0_0x1bf77a({'name':a0_0x33500c(0xad),'version':a0_0x33500c(0xed)},{'capabilities':{'experimental':{'claude/channel':{}},'tools':{}},'instructions':[a0_0x33500c(0x98),'These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.',a0_0x33500c(0xf3),'You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.','Session\x20alias:\x20'+Z][a0_0x33500c(0xc6)]('\x0a')});K[a0_0x33500c(0xe4)](a0_0x22e0c1,async()=>({'tools':[{'name':a0_0x33500c(0xee),'description':'Reply\x20to\x20a\x20CommHub\x20task\x20—\x20report\x20completion\x20or\x20send\x20a\x20message\x20back\x20to\x20the\x20hub.','inputSchema':{'type':'object','properties':{'task_id':{'type':a0_0x33500c(0x83),'description':a0_0x33500c(0x92)},'text':{'type':a0_0x33500c(0x83),'description':'Reply\x20text\x20/\x20result\x20summary'},'status':{'type':'string','enum':[a0_0x33500c(0x8e),'failed',a0_0x33500c(0x80),'blocked',a0_0x33500c(0xda),a0_0x33500c(0x85)],'description':a0_0x33500c(0xa4)}},'required':[a0_0x33500c(0xba)]}},{'name':a0_0x33500c(0x97),'description':'Update\x20this\x20session\x27s\x20status\x20in\x20CommHub\x20(working/idle/blocked/error).\x20Returns\x20inbox_count.','inputSchema':{'type':a0_0x33500c(0xfe),'properties':{'status':{'type':'string','enum':[a0_0x33500c(0xb8),a0_0x33500c(0xb3),a0_0x33500c(0x8d),a0_0x33500c(0xda)]},'task':{'type':a0_0x33500c(0x83),'description':a0_0x33500c(0xe9)},'progress':{'type':a0_0x33500c(0x93),'description':'Progress\x200-100'}},'required':[a0_0x33500c(0xfb)]}},{'name':a0_0x33500c(0xac),'description':a0_0x33500c(0xe0),'inputSchema':{'type':'object','properties':{'alias':{'type':'string','description':a0_0x33500c(0xdf)},'task':{'type':a0_0x33500c(0x83),'description':a0_0x33500c(0xd3)},'priority':{'type':a0_0x33500c(0x83),'enum':[a0_0x33500c(0xb6),'normal',a0_0x33500c(0xb4)],'description':'Priority\x20(default:\x20normal)'}},'required':[a0_0x33500c(0xf7),a0_0x33500c(0x91)]}},{'name':a0_0x33500c(0xc2),'description':a0_0x33500c(0xa3),'inputSchema':{'type':a0_0x33500c(0xfe),'properties':{'alias':{'type':'string','description':a0_0x33500c(0xdf)},'message':{'type':a0_0x33500c(0x83),'description':a0_0x33500c(0xc7)}},'required':[a0_0x33500c(0xf7),a0_0x33500c(0x96)]}},{'name':a0_0x33500c(0xab),'description':a0_0x33500c(0xd1),'inputSchema':{'type':a0_0x33500c(0xfe),'properties':{}}}]}));async function P(_0x5572e1,_0x3496d6){const _0x47ce75=a0_0x33500c;let _0x79e885=await fetch(f+_0x47ce75(0xf2),{'method':'POST','headers':{'Content-Type':'application/json','Accept':_0x47ce75(0xc8),...X?{'Authorization':_0x47ce75(0xe6)+X}:{}},'body':JSON['stringify']({'jsonrpc':_0x47ce75(0xeb),'id':0x1,'method':_0x47ce75(0xe7),'params':{'protocolVersion':_0x47ce75(0x84),'capabilities':{},'clientInfo':{'name':_0x47ce75(0xad),'version':_0x47ce75(0xed)}}})});if(!_0x79e885['ok']){let _0x54b34d=await _0x79e885[_0x47ce75(0xba)]();return Y(_0x47ce75(0xbc)+_0x79e885[_0x47ce75(0xfb)]+'\x20'+_0x54b34d[_0x47ce75(0xbe)](0x0,0x64)),{'ok':!0x1,'error':_0x47ce75(0x109)+_0x79e885[_0x47ce75(0xfb)]};}await _0x79e885[_0x47ce75(0xba)]();let _0x8e1ad9=(await(await fetch(f+_0x47ce75(0xf2),{'method':'POST','headers':{'Content-Type':_0x47ce75(0xea),'Accept':_0x47ce75(0xc8),...X?{'Authorization':_0x47ce75(0xe6)+X}:{}},'body':JSON['stringify']({'jsonrpc':_0x47ce75(0xeb),'id':0x2,'method':_0x47ce75(0x9a),'params':{'name':_0x5572e1,'arguments':_0x3496d6}})}))['text']())[_0x47ce75(0xd5)]('\x0a')[_0x47ce75(0xe1)](_0xd72ae3=>_0xd72ae3['startsWith'](_0x47ce75(0x103)));if(_0x8e1ad9){let _0x2e7fa5=JSON[_0x47ce75(0xa5)](_0x8e1ad9[_0x47ce75(0xbe)](0x6));return _0x2e7fa5?.[_0x47ce75(0xb9)]?.[_0x47ce75(0x88)]?.[0x0]?.[_0x47ce75(0xba)]?JSON[_0x47ce75(0xa5)](_0x2e7fa5[_0x47ce75(0xb9)][_0x47ce75(0x88)][0x0][_0x47ce75(0xba)]):_0x2e7fa5;}return{'ok':!0x1,'error':_0x47ce75(0x9d)};}K[a0_0x33500c(0xe4)](a0_0xde2443,async _0x1d03e5=>{const _0x2a64c9=a0_0x33500c;let {name:_0x264874,arguments:_0x5d307}=_0x1d03e5['params'];if(_0x264874===_0x2a64c9(0xee)){let {task_id:_0x55541f,text:_0x5b071b,status:_0x2dc305}=_0x5d307;if(_0x2dc305==='completed'||_0x2dc305==='failed'||_0x2dc305==='cancelled'){let _0x5f51ab=_0x2dc305==='completed'?_0x2a64c9(0xf9):_0x2dc305,_0x251ac3=_0x55541f?k[_0x2a64c9(0x8a)](_0x55541f)||_0x2a64c9(0x82):_0x2a64c9(0x82),_0x30997f=await P('send_reply',{'alias':_0x251ac3,'text':_0x5b071b,'in_reply_to':_0x55541f||void 0x0,'status':_0x5f51ab,'from_session':Z});if(_0x55541f)k[_0x2a64c9(0xa6)](_0x55541f);return{'content':[{'type':_0x2a64c9(0xba),'text':JSON[_0x2a64c9(0x8c)](_0x30997f)}]};}let _0x1b350f=await P('report_status',{'resume_id':w,'alias':Z,'status':_0x2dc305==='blocked'?_0x2a64c9(0x8d):_0x2dc305===_0x2a64c9(0xda)?_0x2a64c9(0xda):_0x2a64c9(0xb8),'task':_0x5b071b[_0x2a64c9(0xbe)](0x0,0xc8),'output':_0x5b071b});return{'content':[{'type':'text','text':JSON[_0x2a64c9(0x8c)](_0x1b350f)}]};}if(_0x264874===_0x2a64c9(0x97)){let {status:_0x8b7fae,task:_0x334d0e,progress:_0x2d8b14}=_0x5d307,_0x4a607f=await P(_0x2a64c9(0x105),{'resume_id':w,'alias':Z,'status':_0x8b7fae,'task':_0x334d0e,'progress':_0x2d8b14});return{'content':[{'type':_0x2a64c9(0xba),'text':JSON['stringify'](_0x4a607f)}]};}if(_0x264874===_0x2a64c9(0xac)){let {alias:_0x4a2bd5,task:_0x129e22,priority:_0x1729c2}=_0x5d307,_0x3883e2=await P('send_task',{'alias':_0x4a2bd5,'task':_0x129e22,'priority':_0x1729c2||_0x2a64c9(0x101),'from_session':Z});return{'content':[{'type':_0x2a64c9(0xba),'text':JSON[_0x2a64c9(0x8c)](_0x3883e2)}]};}if(_0x264874===_0x2a64c9(0xc2)){let {alias:_0x1bf519,message:_0x3f9d2e}=_0x5d307,_0x267f21=await P(_0x2a64c9(0xb7),{'alias':_0x1bf519,'message':_0x3f9d2e,'from_session':Z});return{'content':[{'type':_0x2a64c9(0xba),'text':JSON[_0x2a64c9(0x8c)](_0x267f21)}]};}if(_0x264874===_0x2a64c9(0xab)){let _0x55b85e=await P(_0x2a64c9(0xc0),{});return{'content':[{'type':'text','text':JSON[_0x2a64c9(0x8c)](_0x55b85e)}]};}return{'content':[{'type':_0x2a64c9(0xba),'text':JSON[_0x2a64c9(0x8c)]({'error':'unknown\x20tool'})}]};});async function u(){const _0xca3611=a0_0x33500c;let _0x746d2c=f+_0xca3611(0xde)+encodeURIComponent(Z),_0x5d11cd={};if(X)_0x5d11cd[_0xca3611(0xf5)]=_0xca3611(0xe6)+X;Y(_0xca3611(0x104)+_0x746d2c);while(!0x0){try{let _0x311eaf=await fetch(_0x746d2c,{'headers':_0x5d11cd});if(!_0x311eaf['ok']){Y(_0xca3611(0x9f)+_0x311eaf[_0xca3611(0xfb)]+'\x20'+_0x311eaf[_0xca3611(0xcc)]),await h(0x1388);continue;}let _0x200944=_0x311eaf[_0xca3611(0xc9)][_0xca3611(0x7e)](),_0x3d1ca1=new TextDecoder(),_0x549ece='';while(!0x0){let {done:_0xde6625,value:_0x5ae65f}=await _0x200944[_0xca3611(0x9c)]();if(_0xde6625)break;_0x549ece+=_0x3d1ca1[_0xca3611(0xf8)](_0x5ae65f,{'stream':!0x0});let _0x51db40=_0x549ece['split']('\x0a\x0a');_0x549ece=_0x51db40[_0xca3611(0xa2)]()||'';for(let _0x5dccd4 of _0x51db40){let _0x232734=_0x5dccd4[_0xca3611(0xd5)]('\x0a')[_0xca3611(0xe1)](_0x3932e6=>_0x3932e6[_0xca3611(0xc1)](_0xca3611(0x103)));if(!_0x232734)continue;try{let _0x3bbab8=JSON[_0xca3611(0xa5)](_0x232734[_0xca3611(0xbe)](0x6));await S(_0x3bbab8);}catch(_0x542e3c){Y(_0xca3611(0xb1)+_0x542e3c);}}}Y(_0xca3611(0xcf));}catch(_0xc2ea05){Y(_0xca3611(0xd8)+_0xc2ea05);}await h(0xbb8);}}async function S(_0x351a94){const _0x2f0283=a0_0x33500c;if(_0x351a94['type']===_0x2f0283(0xa0)){Y('SSE\x20connected\x20as\x20\x22'+Z+'\x22');return;}if(_0x351a94[_0x2f0283(0xb2)]==='new_message'){if(Y(_0x2f0283(0x9b)+_0x351a94[_0x2f0283(0xcd)]+':\x20'+_0x351a94[_0x2f0283(0x96)][_0x2f0283(0xbe)](0x0,0x3c)),await K[_0x2f0283(0xa8)]({'method':_0x2f0283(0xce),'params':{'content':_0x351a94[_0x2f0283(0x96)],'meta':{'sender':_0x351a94[_0x2f0283(0xcd)]||'hub','sender_id':_0x2f0283(0x90),'user':_0x351a94[_0x2f0283(0xcd)]||_0x2f0283(0x82),'priority':_0x2f0283(0x101)}}}),_0x351a94['message_id'])await P(_0x2f0283(0xec),{'alias':Z,'message_id':_0x351a94[_0x2f0283(0x8b)]});return;}if(_0x351a94[_0x2f0283(0xb2)]===_0x2f0283(0xfa)||_0x351a94[_0x2f0283(0xb2)]==='broadcast'){Y('←\x20'+_0x351a94[_0x2f0283(0xb2)]+':\x20inbox_count='+_0x351a94[_0x2f0283(0xd6)]+_0x2f0283(0xe3)+(_0x351a94[_0x2f0283(0xe2)]||_0x2f0283(0x101)));let _0x4ae22a=await P(_0x2f0283(0x87),{'alias':Z,'limit':0x5});if(_0x4ae22a?.['ok']&&_0x4ae22a[_0x2f0283(0x106)]?.['length']>0x0)for(let _0x172e6b of _0x4ae22a['messages']){let _0x1b5db8={'sender':_0x172e6b[_0x2f0283(0xfd)]||_0x2f0283(0x82),'sender_id':_0x2f0283(0x90),'user':_0x172e6b[_0x2f0283(0xfd)]||'hub','task_id':_0x172e6b['id'],'priority':_0x172e6b[_0x2f0283(0xe2)]||'normal'};k['set'](_0x172e6b['id'],_0x172e6b[_0x2f0283(0xfd)]||_0x2f0283(0x82)),await K[_0x2f0283(0xa8)]({'method':'notifications/claude/channel','params':{'content':_0x172e6b['content'],'meta':_0x1b5db8}}),Y(_0x2f0283(0xaa)+_0x172e6b['id'][_0x2f0283(0xbe)](0x0,0x8)+_0x2f0283(0x102)+_0x172e6b[_0x2f0283(0xfd)]+':\x20'+_0x172e6b[_0x2f0283(0x88)][_0x2f0283(0xbe)](0x0,0x3c)),await P(_0x2f0283(0xec),{'alias':Z,'message_id':_0x172e6b['id']});}}}async function A(){const _0x4c0189=a0_0x33500c;let _0xbb0a18=new a0_0x22d501();await K['connect'](_0xbb0a18),Y(_0x4c0189(0xd7)),Y(_0x4c0189(0xbd)),u()[_0x4c0189(0x9e)](_0x4b16f1=>Y(_0x4c0189(0xef)+_0x4b16f1)),P(_0x4c0189(0x105),{'resume_id':w,'alias':Z,'status':_0x4c0189(0xb3),'server':a0_0x35d7f8(),'hostname':a0_0x35d7f8(),'agent':_0x4c0189(0x108),'project_dir':process[_0x4c0189(0x7f)](),'tmux_name':j||void 0x0})['then'](()=>Y(_0x4c0189(0xc3)+Z+_0x4c0189(0xb5)+w[_0x4c0189(0xbe)](0x0,0x8)+')'))[_0x4c0189(0x9e)](_0x4c184d=>Y(_0x4c0189(0xf4)+_0x4c184d)),setInterval(()=>{const _0x1e9665=_0x4c0189;P(_0x1e9665(0x105),{'resume_id':w,'alias':Z,'status':_0x1e9665(0xb3),'server':a0_0x35d7f8(),'hostname':a0_0x35d7f8(),'agent':_0x1e9665(0x108),'project_dir':process[_0x1e9665(0x7f)](),'tmux_name':j||void 0x0})['catch'](_0x556a93=>Y(_0x1e9665(0xd9)+_0x556a93));},0x2bf20),Y(_0x4c0189(0xdc));}function a0_0x26ff(_0x44ab22,_0x5ace9d){_0x44ab22=_0x44ab22-0x7e;const _0xb31aa6=a0_0xb31a();let _0x26ff0d=_0xb31aa6[_0x44ab22];return _0x26ff0d;}A()[a0_0x33500c(0x9e)](_0x2476e1=>{const _0xc229f4=a0_0x33500c;Y(_0xc229f4(0xd2)+_0x2476e1),process[_0xc229f4(0x99)](0x1);});async function N(){const _0x2a63a4=a0_0x33500c;Y(_0x2a63a4(0xf0)),await P(_0x2a63a4(0x105),{'resume_id':w,'alias':Z,'status':_0x2a63a4(0xda),'task':'session\x20disconnected'})[_0x2a63a4(0x9e)](()=>{}),process[_0x2a63a4(0x99)](0x0);}function a0_0xb31a(){const _0x1ca179=['send_message','working','result','text','trim','CommHub\x20init\x20failed:\x20','starting\x20SSE\x20listener...','slice','tmux\x20display-message\x20-p\x20\x27#S\x27','get_all_status','startsWith','commhub_send_message','registered\x20as\x20\x22','stdin','\x20ALIAS=','join','Message\x20content','application/json,\x20text/event-stream','body','22OizNdQ','write','statusText','from','notifications/claude/channel','SSE\x20stream\x20ended,\x20reconnecting...','ENV:\x20URL=','Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','fatal:\x20','Task\x20content','229816lxrcrV','split','inbox_count','MCP\x20stdio\x20connected','SSE\x20connection\x20error:\x20','heartbeat\x20failed:\x20','error','indexOf','ready\x20—\x20waiting\x20for\x20events','6QLhwGT','/events/','Target\x20session\x20alias','Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.','find','priority','\x20priority=','setRequestHandler','\x20RESUME_ID=','Bearer\x20','initialize','.claude/channels/commhub','Current\x20task\x20description','application/json','2.0','ack_inbox','0.3.0','commhub_reply','SSE\x20fatal:\x20','shutting\x20down,\x20reporting\x20offline...','end','/mcp','Reply\x20using\x20the\x20commhub_reply\x20tool\x20to\x20report\x20status\x20or\x20results\x20back.','warning:\x20could\x20not\x20register:\x20','Authorization','none','alias','decode','replied','new_task','status','toTimeString','from_session','object','51959kFnuRf','config.json','normal','\x20from\x20','data:\x20','connecting\x20to\x20','report_status','messages','stderr','claude-code','init\x20failed:\x20','.env','getReader','cwd','cancelled','5013659fwBYNI','hub','string','2025-03-26','in_progress','10IZFAzb','get_inbox','content','39LrMkrD','get','message_id','stringify','blocked','completed','1540520sBjCep','commhub','task','The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)','number',']\x20[commhub]\x20','1479267spzcCM','message','commhub_report_status','Messages\x20from\x20CommHub\x20arrive\x20as\x20<channel\x20source=\x22commhub\x22\x20task_id=\x22...\x22\x20priority=\x22...\x22\x20from=\x22...\x22>','exit','tools/call','←\x20message\x20from\x20','read','no\x20response','catch','SSE\x20error:\x20','connected','7170184akhBfO','pop','Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.','Task\x20outcome:\x20completed/failed/cancelled\x20for\x20final\x20results,\x20blocked/error/in_progress\x20for\x20status\x20updates','parse','delete','utf-8','notification','SIGTERM','→\x20injected\x20task\x20','commhub_get_all_status','commhub_send_task','commhub-channel','http://127.0.0.1:9200','19214426aahVTe','replace','parse\x20error:\x20','type','idle','low','\x22\x20(','high'];a0_0xb31a=function(){return _0x1ca179;};return a0_0xb31a();}process[a0_0x33500c(0xc4)]['on'](a0_0x33500c(0xf1),()=>N()),process['on'](a0_0x33500c(0xa9),()=>N()),process['on']('SIGINT',()=>N());
|
|
2
|
+
const a0_0xbe730c=a0_0x648b;(function(_0x18a0f6,_0x457523){const _0x515177=a0_0x648b,_0x3bae61=_0x18a0f6();while(!![]){try{const _0x3a8290=-parseInt(_0x515177(0x13b))/0x1+parseInt(_0x515177(0x127))/0x2+parseInt(_0x515177(0x184))/0x3*(parseInt(_0x515177(0x13d))/0x4)+-parseInt(_0x515177(0x115))/0x5+parseInt(_0x515177(0x132))/0x6*(-parseInt(_0x515177(0x12c))/0x7)+-parseInt(_0x515177(0x146))/0x8*(-parseInt(_0x515177(0x19e))/0x9)+parseInt(_0x515177(0x123))/0xa*(parseInt(_0x515177(0x181))/0xb);if(_0x3a8290===_0x457523)break;else _0x3bae61['push'](_0x3bae61['shift']());}catch(_0x6528f5){_0x3bae61['push'](_0x3bae61['shift']());}}}(a0_0x2470,0x84522));import{readFileSync as a0_0x321d9c,existsSync as a0_0x10f767}from'fs';import{randomUUID as a0_0x120571}from'crypto';import{join as a0_0xfd789c}from'path';import{hostname as a0_0x185e2f}from'os';import{execSync as a0_0x4b6388}from'child_process';import{Server as a0_0x3e6ef2}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport as a0_0x14707b}from'@modelcontextprotocol/sdk/server/stdio.js';import{ListToolsRequestSchema as a0_0x2ed2f7,CallToolRequestSchema as a0_0x89ef28}from'@modelcontextprotocol/sdk/types.js';function p(_0x31c114){const _0x58385e=a0_0x648b;if(!a0_0x10f767(_0x31c114))return;for(let _0x2859f0 of a0_0x321d9c(_0x31c114,'utf-8')['split']('\x0a')){let _0x2272e9=_0x2859f0[_0x58385e(0x16f)]();if(!_0x2272e9||_0x2272e9[_0x58385e(0x13e)]('#'))continue;let _0x22b478=_0x2272e9[_0x58385e(0x151)]('=');if(_0x22b478<0x0)continue;let _0x4ebb79=_0x2272e9[_0x58385e(0x197)](0x0,_0x22b478)['trim'](),_0x1b9e57=_0x2272e9[_0x58385e(0x197)](_0x22b478+0x1)[_0x58385e(0x16f)]()[_0x58385e(0x133)](/^["']|["']$/g,'');if(!process.env[_0x4ebb79])process.env[_0x4ebb79]=_0x1b9e57;}}var C=process.env.HOME||'~',T=a0_0xfd789c(C,'.claude/channels/commhub');p(a0_0xfd789c(T,a0_0xbe730c(0x14c)));var L=process[a0_0xbe730c(0x141)]()[a0_0xbe730c(0x133)](/\//g,'-');p(a0_0xfd789c(T,L,'.env'));function U(){const _0x3fb68d=a0_0xbe730c;try{return a0_0x4b6388(_0x3fb68d(0x14a),{'encoding':_0x3fb68d(0x131),'timeout':0x7d0})[_0x3fb68d(0x16f)]();}catch{return'';}}function v(){const _0x25f3b5=a0_0xbe730c;try{let _0x20c762=a0_0xfd789c(C,_0x25f3b5(0x143),_0x25f3b5(0x17e));if(a0_0x10f767(_0x20c762))return JSON[_0x25f3b5(0x19f)](a0_0x321d9c(_0x20c762,_0x25f3b5(0x131)));}catch{}return{};}var H=v(),f=process.env.COMMHUB_URL||H[a0_0xbe730c(0x16e)]||a0_0xbe730c(0x158),j=process.env.COMMHUB_TMUX||U(),Z=process.env.COMMHUB_ALIAS||j||a0_0x185e2f(),w=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||a0_0x120571(),X=process.env.COMMHUB_TOKEN||H[a0_0xbe730c(0x1a0)]||'';function Y(_0x3ca8ef){const _0x27a0ae=a0_0xbe730c;let _0x572f49=new Date()[_0x27a0ae(0x150)]()[_0x27a0ae(0x197)](0x0,0x8);process[_0x27a0ae(0x183)][_0x27a0ae(0x130)]('['+_0x572f49+_0x27a0ae(0x162)+_0x3ca8ef+'\x0a');}function h(_0x33d5db){return new Promise(_0x277639=>setTimeout(_0x277639,_0x33d5db));}Y('ENV:\x20URL='+f+a0_0xbe730c(0x16c)+Z+a0_0xbe730c(0x12a)+w[a0_0xbe730c(0x197)](0x0,0x8)+a0_0xbe730c(0x194)+(j||a0_0xbe730c(0x163))+a0_0xbe730c(0x14e)+process[a0_0xbe730c(0x141)]()+a0_0xbe730c(0x12b)+L);function a0_0x2470(){const _0x2dbb06=['decode','send_task','read','...\x20TMUX=','get','completed','slice','notification','delete','notifications/claude/channel','params','exit','Update\x20this\x20session\x27s\x20status\x20in\x20CommHub\x20(working/idle/blocked/error).\x20Returns\x20inbox_count.','18etACVR','parse','token','heartbeat\x20failed:\x20','Reply\x20to\x20a\x20CommHub\x20task\x20—\x20report\x20completion\x20or\x20send\x20a\x20message\x20back\x20to\x20the\x20hub.','5388125OfjrHv','blocked','new_task','stringify','error','2.0','join','task','object','Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','Reply\x20using\x20the\x20commhub_reply\x20tool\x20to\x20report\x20status\x20or\x20results\x20back.','\x22\x20(','message','←\x20message\x20from\x20','70GoAGrM','find','init\x20failed:\x20','/mcp','172378XRVTrd','pop','priority','\x20RESUME_ID=','\x20PROJECT_ENV=','490014gnQcJF','body','starting\x20SSE\x20listener...','send_message','write','utf-8','48uPwhFq','replace','→\x20injected\x20task\x20','end','commhub_reply','application/json,\x20text/event-stream','result','broadcast','commhub_send_message','231152DATemL','connect','132XxdPue','startsWith','low','commhub_get_all_status','cwd','/events/','.anet','You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.',':\x20inbox_count=','2102408ZzZNdQ','in_progress','connected','ack_inbox','tmux\x20display-message\x20-p\x20\x27#S\x27','string','.env','These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.','\x20CWD=','number','toTimeString','indexOf','cancelled','Session\x20alias:\x20','new_message','high','alias','from_session','http://127.0.0.1:9200','SSE\x20connected\x20as\x20\x22','Bearer\x20','Authorization','commhub_send_task','messages','status','Target\x20session\x20alias','SSE\x20stream\x20ended,\x20reconnecting...','text',']\x20[commhub]\x20','none','MCP\x20stdio\x20connected','normal','session\x20disconnected','Progress\x200-100','Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.','\x20from\x20','tools/call','get_inbox','\x20ALIAS=','message_id','hub','trim','type','POST','content','working','0.3.0','SSE\x20error:\x20','catch','Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.','split','commhub-channel','initialize','from','Reply\x20text\x20/\x20result\x20summary','data:\x20','config.json','replied','\x20priority=','2437171KscOcJ','failed','stderr','22551fNNEnK','CommHub\x20init\x20failed:\x20','Priority\x20(default:\x20normal)','stdin','get_all_status','application/json','The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)','commhub_report_status','setRequestHandler','send_reply','report_status','2025-03-26','ready\x20—\x20waiting\x20for\x20events'];a0_0x2470=function(){return _0x2dbb06;};return a0_0x2470();}var k=new Map(),K=new a0_0x3e6ef2({'name':a0_0xbe730c(0x179),'version':a0_0xbe730c(0x174)},{'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_0xbe730c(0x14d),a0_0xbe730c(0x11f),a0_0xbe730c(0x144),a0_0xbe730c(0x153)+Z][a0_0xbe730c(0x11b)]('\x0a')});K[a0_0xbe730c(0x18c)](a0_0x2ed2f7,async()=>({'tools':[{'name':'commhub_reply','description':a0_0xbe730c(0x1a2),'inputSchema':{'type':a0_0xbe730c(0x11d),'properties':{'task_id':{'type':a0_0xbe730c(0x14b),'description':a0_0xbe730c(0x18a)},'text':{'type':'string','description':a0_0xbe730c(0x17c)},'status':{'type':a0_0xbe730c(0x14b),'enum':[a0_0xbe730c(0x196),'failed',a0_0xbe730c(0x152),a0_0xbe730c(0x116),a0_0xbe730c(0x119),a0_0xbe730c(0x147)],'description':'Task\x20outcome:\x20completed/failed/cancelled\x20for\x20final\x20results,\x20blocked/error/in_progress\x20for\x20status\x20updates'}},'required':[a0_0xbe730c(0x161)]}},{'name':a0_0xbe730c(0x18b),'description':a0_0xbe730c(0x19d),'inputSchema':{'type':a0_0xbe730c(0x11d),'properties':{'status':{'type':a0_0xbe730c(0x14b),'enum':['working','idle',a0_0xbe730c(0x116),a0_0xbe730c(0x119)]},'task':{'type':a0_0xbe730c(0x14b),'description':'Current\x20task\x20description'},'progress':{'type':a0_0xbe730c(0x14f),'description':a0_0xbe730c(0x167)}},'required':[a0_0xbe730c(0x15e)]}},{'name':'commhub_send_task','description':a0_0xbe730c(0x177),'inputSchema':{'type':a0_0xbe730c(0x11d),'properties':{'alias':{'type':a0_0xbe730c(0x14b),'description':'Target\x20session\x20alias'},'task':{'type':a0_0xbe730c(0x14b),'description':'Task\x20content'},'priority':{'type':a0_0xbe730c(0x14b),'enum':[a0_0xbe730c(0x155),a0_0xbe730c(0x165),a0_0xbe730c(0x13f)],'description':a0_0xbe730c(0x186)}},'required':['alias',a0_0xbe730c(0x11c)]}},{'name':a0_0xbe730c(0x13a),'description':a0_0xbe730c(0x168),'inputSchema':{'type':a0_0xbe730c(0x11d),'properties':{'alias':{'type':a0_0xbe730c(0x14b),'description':a0_0xbe730c(0x15f)},'message':{'type':a0_0xbe730c(0x14b),'description':'Message\x20content'}},'required':[a0_0xbe730c(0x156),'message']}},{'name':'commhub_get_all_status','description':a0_0xbe730c(0x11e),'inputSchema':{'type':a0_0xbe730c(0x11d),'properties':{}}}]}));async function P(_0x1d3e99,_0x287b20){const _0x517039=a0_0xbe730c;let _0x381b90=await fetch(f+'/mcp',{'method':_0x517039(0x171),'headers':{'Content-Type':_0x517039(0x189),'Accept':_0x517039(0x137),...X?{'Authorization':'Bearer\x20'+X}:{}},'body':JSON['stringify']({'jsonrpc':_0x517039(0x11a),'id':0x1,'method':_0x517039(0x17a),'params':{'protocolVersion':_0x517039(0x18f),'capabilities':{},'clientInfo':{'name':_0x517039(0x179),'version':_0x517039(0x174)}}})});if(!_0x381b90['ok']){let _0x2a5eb3=await _0x381b90[_0x517039(0x161)]();return Y(_0x517039(0x185)+_0x381b90[_0x517039(0x15e)]+'\x20'+_0x2a5eb3['slice'](0x0,0x64)),{'ok':!0x1,'error':_0x517039(0x125)+_0x381b90['status']};}await _0x381b90['text']();let _0x4241c6=(await(await fetch(f+_0x517039(0x126),{'method':'POST','headers':{'Content-Type':_0x517039(0x189),'Accept':_0x517039(0x137),...X?{'Authorization':'Bearer\x20'+X}:{}},'body':JSON['stringify']({'jsonrpc':_0x517039(0x11a),'id':0x2,'method':_0x517039(0x16a),'params':{'name':_0x1d3e99,'arguments':_0x287b20}})}))[_0x517039(0x161)]())[_0x517039(0x178)]('\x0a')[_0x517039(0x124)](_0x2f4189=>_0x2f4189[_0x517039(0x13e)]('data:\x20'));if(_0x4241c6){let _0x57c7b0=JSON[_0x517039(0x19f)](_0x4241c6['slice'](0x6));return _0x57c7b0?.[_0x517039(0x138)]?.[_0x517039(0x172)]?.[0x0]?.[_0x517039(0x161)]?JSON[_0x517039(0x19f)](_0x57c7b0[_0x517039(0x138)]['content'][0x0][_0x517039(0x161)]):_0x57c7b0;}return{'ok':!0x1,'error':'no\x20response'};}K[a0_0xbe730c(0x18c)](a0_0x89ef28,async _0x13a5ee=>{const _0x8a8ecd=a0_0xbe730c;let {name:_0x401ee5,arguments:_0xeb1121}=_0x13a5ee[_0x8a8ecd(0x19b)];if(_0x401ee5===_0x8a8ecd(0x136)){let {task_id:_0x4220fb,text:_0x45ca33,status:_0x12cc0c}=_0xeb1121;if(_0x12cc0c==='completed'||_0x12cc0c===_0x8a8ecd(0x182)||_0x12cc0c==='cancelled'){let _0xdd6bed=_0x12cc0c===_0x8a8ecd(0x196)?_0x8a8ecd(0x17f):_0x12cc0c,_0x4460d5=_0x4220fb?k[_0x8a8ecd(0x195)](_0x4220fb)||_0x8a8ecd(0x16e):_0x8a8ecd(0x16e),_0x5d8fd5=await P(_0x8a8ecd(0x18d),{'alias':_0x4460d5,'text':_0x45ca33,'in_reply_to':_0x4220fb||void 0x0,'status':_0xdd6bed,'from_session':Z});if(_0x4220fb)k[_0x8a8ecd(0x199)](_0x4220fb);return{'content':[{'type':_0x8a8ecd(0x161),'text':JSON[_0x8a8ecd(0x118)](_0x5d8fd5)}]};}let _0x128de7=await P('report_status',{'resume_id':w,'alias':Z,'status':_0x12cc0c==='blocked'?_0x8a8ecd(0x116):_0x12cc0c===_0x8a8ecd(0x119)?_0x8a8ecd(0x119):_0x8a8ecd(0x173),'task':_0x45ca33[_0x8a8ecd(0x197)](0x0,0xc8),'output':_0x45ca33});return{'content':[{'type':'text','text':JSON['stringify'](_0x128de7)}]};}if(_0x401ee5===_0x8a8ecd(0x18b)){let {status:_0x3a091c,task:_0x6e2876,progress:_0x31e55e}=_0xeb1121,_0x5bf12b=await P(_0x8a8ecd(0x18e),{'resume_id':w,'alias':Z,'status':_0x3a091c,'task':_0x6e2876,'progress':_0x31e55e});return{'content':[{'type':_0x8a8ecd(0x161),'text':JSON[_0x8a8ecd(0x118)](_0x5bf12b)}]};}if(_0x401ee5===_0x8a8ecd(0x15c)){let {alias:_0x3cdcba,task:_0x1699cb,priority:_0x3a4502}=_0xeb1121,_0x5d289f=await P(_0x8a8ecd(0x192),{'alias':_0x3cdcba,'task':_0x1699cb,'priority':_0x3a4502||_0x8a8ecd(0x165),'from_session':Z});return{'content':[{'type':_0x8a8ecd(0x161),'text':JSON[_0x8a8ecd(0x118)](_0x5d289f)}]};}if(_0x401ee5===_0x8a8ecd(0x13a)){let {alias:_0x3b3c92,message:_0x52da45}=_0xeb1121,_0x1799d0=await P(_0x8a8ecd(0x12f),{'alias':_0x3b3c92,'message':_0x52da45,'from_session':Z});return{'content':[{'type':_0x8a8ecd(0x161),'text':JSON[_0x8a8ecd(0x118)](_0x1799d0)}]};}if(_0x401ee5===_0x8a8ecd(0x140)){let _0x10c14f=await P(_0x8a8ecd(0x188),{});return{'content':[{'type':_0x8a8ecd(0x161),'text':JSON[_0x8a8ecd(0x118)](_0x10c14f)}]};}return{'content':[{'type':_0x8a8ecd(0x161),'text':JSON[_0x8a8ecd(0x118)]({'error':'unknown\x20tool'})}]};});async function u(){const _0x358ef0=a0_0xbe730c;let _0x556dce=f+_0x358ef0(0x142)+encodeURIComponent(Z),_0x3531c6={};if(X)_0x3531c6[_0x358ef0(0x15b)]=_0x358ef0(0x15a)+X;Y('connecting\x20to\x20'+_0x556dce);while(!0x0){try{let _0x586c00=await fetch(_0x556dce,{'headers':_0x3531c6});if(!_0x586c00['ok']){Y(_0x358ef0(0x175)+_0x586c00[_0x358ef0(0x15e)]+'\x20'+_0x586c00['statusText']),await h(0x1388);continue;}let _0x5143fa=_0x586c00[_0x358ef0(0x12d)]['getReader'](),_0x44c849=new TextDecoder(),_0x465ea4='';while(!0x0){let {done:_0x303618,value:_0x183335}=await _0x5143fa[_0x358ef0(0x193)]();if(_0x303618)break;_0x465ea4+=_0x44c849[_0x358ef0(0x191)](_0x183335,{'stream':!0x0});let _0x2c735b=_0x465ea4[_0x358ef0(0x178)]('\x0a\x0a');_0x465ea4=_0x2c735b[_0x358ef0(0x128)]()||'';for(let _0x1afd24 of _0x2c735b){let _0x5d72b1=_0x1afd24[_0x358ef0(0x178)]('\x0a')[_0x358ef0(0x124)](_0x553898=>_0x553898[_0x358ef0(0x13e)](_0x358ef0(0x17d)));if(!_0x5d72b1)continue;try{let _0x474c60=JSON['parse'](_0x5d72b1[_0x358ef0(0x197)](0x6));await S(_0x474c60);}catch(_0x54c26e){Y('parse\x20error:\x20'+_0x54c26e);}}}Y(_0x358ef0(0x160));}catch(_0x3f4f87){Y('SSE\x20connection\x20error:\x20'+_0x3f4f87);}await h(0xbb8);}}async function S(_0x166398){const _0x4e4d3c=a0_0xbe730c;if(_0x166398[_0x4e4d3c(0x170)]===_0x4e4d3c(0x148)){Y(_0x4e4d3c(0x159)+Z+'\x22');return;}if(_0x166398['type']===_0x4e4d3c(0x154)){if(Y(_0x4e4d3c(0x122)+_0x166398[_0x4e4d3c(0x17b)]+':\x20'+_0x166398['message']['slice'](0x0,0x3c)),await K[_0x4e4d3c(0x198)]({'method':_0x4e4d3c(0x19a),'params':{'content':_0x166398[_0x4e4d3c(0x121)],'meta':{'sender':_0x166398['from']||'hub','sender_id':'commhub','user':_0x166398[_0x4e4d3c(0x17b)]||_0x4e4d3c(0x16e),'priority':_0x4e4d3c(0x165)}}}),_0x166398[_0x4e4d3c(0x16d)])await P(_0x4e4d3c(0x149),{'alias':Z,'message_id':_0x166398[_0x4e4d3c(0x16d)]});return;}if(_0x166398[_0x4e4d3c(0x170)]===_0x4e4d3c(0x117)||_0x166398['type']===_0x4e4d3c(0x139)){Y('←\x20'+_0x166398[_0x4e4d3c(0x170)]+_0x4e4d3c(0x145)+_0x166398['inbox_count']+_0x4e4d3c(0x180)+(_0x166398['priority']||'normal'));let _0x5b4b73=await P(_0x4e4d3c(0x16b),{'alias':Z,'limit':0x5});if(_0x5b4b73?.['ok']&&_0x5b4b73[_0x4e4d3c(0x15d)]?.['length']>0x0)for(let _0x3e0cce of _0x5b4b73[_0x4e4d3c(0x15d)]){let _0xfa8590={'sender':_0x3e0cce[_0x4e4d3c(0x157)]||_0x4e4d3c(0x16e),'sender_id':'commhub','user':_0x3e0cce[_0x4e4d3c(0x157)]||'hub','task_id':_0x3e0cce['id'],'priority':_0x3e0cce[_0x4e4d3c(0x129)]||_0x4e4d3c(0x165)};k['set'](_0x3e0cce['id'],_0x3e0cce[_0x4e4d3c(0x157)]||_0x4e4d3c(0x16e)),await K[_0x4e4d3c(0x198)]({'method':'notifications/claude/channel','params':{'content':_0x3e0cce[_0x4e4d3c(0x172)],'meta':_0xfa8590}}),Y(_0x4e4d3c(0x134)+_0x3e0cce['id'][_0x4e4d3c(0x197)](0x0,0x8)+_0x4e4d3c(0x169)+_0x3e0cce[_0x4e4d3c(0x157)]+':\x20'+_0x3e0cce[_0x4e4d3c(0x172)]['slice'](0x0,0x3c)),await P(_0x4e4d3c(0x149),{'alias':Z,'message_id':_0x3e0cce['id']});}}}async function A(){const _0x3963c7=a0_0xbe730c;let _0x372b1e=new a0_0x14707b();await K[_0x3963c7(0x13c)](_0x372b1e),Y(_0x3963c7(0x164)),Y(_0x3963c7(0x12e)),u()[_0x3963c7(0x176)](_0x541e69=>Y('SSE\x20fatal:\x20'+_0x541e69)),P(_0x3963c7(0x18e),{'resume_id':w,'alias':Z,'status':'idle','server':a0_0x185e2f(),'hostname':a0_0x185e2f(),'agent':'claude-code','project_dir':process['cwd'](),'tmux_name':j||void 0x0})['then'](()=>Y('registered\x20as\x20\x22'+Z+_0x3963c7(0x120)+w[_0x3963c7(0x197)](0x0,0x8)+')'))['catch'](_0x2231f7=>Y('warning:\x20could\x20not\x20register:\x20'+_0x2231f7)),setInterval(()=>{const _0x268dc8=_0x3963c7;P(_0x268dc8(0x18e),{'resume_id':w,'alias':Z,'status':'idle','server':a0_0x185e2f(),'hostname':a0_0x185e2f(),'agent':'claude-code','project_dir':process['cwd'](),'tmux_name':j||void 0x0})['catch'](_0x12a33c=>Y(_0x268dc8(0x1a1)+_0x12a33c));},0x2bf20),Y(_0x3963c7(0x190));}function a0_0x648b(_0x2acc54,_0x5f4cfb){_0x2acc54=_0x2acc54-0x115;const _0x247003=a0_0x2470();let _0x648bb=_0x247003[_0x2acc54];return _0x648bb;}A()[a0_0xbe730c(0x176)](_0x42bdf4=>{const _0x558993=a0_0xbe730c;Y('fatal:\x20'+_0x42bdf4),process[_0x558993(0x19c)](0x1);});async function N(){const _0x1a2ab7=a0_0xbe730c;Y('shutting\x20down,\x20reporting\x20offline...'),await P(_0x1a2ab7(0x18e),{'resume_id':w,'alias':Z,'status':_0x1a2ab7(0x119),'task':_0x1a2ab7(0x166)})[_0x1a2ab7(0x176)](()=>{}),process[_0x1a2ab7(0x19c)](0x0);}process[a0_0xbe730c(0x187)]['on'](a0_0xbe730c(0x135),()=>N()),process['on']('SIGTERM',()=>N()),process['on']('SIGINT',()=>N());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sleep2agi/agent-network",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.9",
|
|
4
4
|
"description": "AI Agent Network CLI — Create multi-agent networks with user management, network isolation, and 3 AI runtimes (Claude/Codex/MiniMax). 39 commands.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/src/client.js",
|
|
@@ -52,7 +52,8 @@
|
|
|
52
52
|
"url": "https://github.com/sleep2agi/agent-network/issues"
|
|
53
53
|
},
|
|
54
54
|
"engines": {
|
|
55
|
-
"bun": ">=1.2.0"
|
|
55
|
+
"bun": ">=1.2.0",
|
|
56
|
+
"node": ">=22.13.0"
|
|
56
57
|
},
|
|
57
58
|
"dependencies": {
|
|
58
59
|
"@inquirer/prompts": "^8.4.3"
|
package/dist/client.d.ts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @sleep2agi/commhub-sdk
|
|
3
|
-
*
|
|
4
|
-
* CommHub 通信 SDK — 一个文件,SSE 长连接 + 自动重连 + 心跳。
|
|
5
|
-
* 支持 Node.js 18+ 和 Bun。
|
|
6
|
-
*/
|
|
7
|
-
import { EventEmitter } from "events";
|
|
8
|
-
export interface CommHubOptions {
|
|
9
|
-
/** CommHub Server URL, e.g. "http://YOUR_COMMHUB_IP:9200" */
|
|
10
|
-
url: string;
|
|
11
|
-
/** Session alias, e.g. "SDK马" */
|
|
12
|
-
alias: string;
|
|
13
|
-
/** Auth token (optional) */
|
|
14
|
-
token?: string;
|
|
15
|
-
/** Agent type for registration (default: "sdk") */
|
|
16
|
-
agent?: string;
|
|
17
|
-
/** Heartbeat interval in ms (default: 180000 = 3 min) */
|
|
18
|
-
heartbeatInterval?: number;
|
|
19
|
-
/** SSE reconnect base delay in ms (default: 3000) */
|
|
20
|
-
reconnectDelay?: number;
|
|
21
|
-
/** Auto-connect on creation (default: true) */
|
|
22
|
-
autoConnect?: boolean;
|
|
23
|
-
}
|
|
24
|
-
export interface InboxMessage {
|
|
25
|
-
id: string;
|
|
26
|
-
content: string;
|
|
27
|
-
from_session: string;
|
|
28
|
-
priority: string;
|
|
29
|
-
created_at: string;
|
|
30
|
-
}
|
|
31
|
-
export interface CommHubEvents {
|
|
32
|
-
task: (msg: InboxMessage) => void;
|
|
33
|
-
message: (msg: InboxMessage) => void;
|
|
34
|
-
connected: () => void;
|
|
35
|
-
disconnected: () => void;
|
|
36
|
-
error: (err: Error) => void;
|
|
37
|
-
}
|
|
38
|
-
export declare class CommHub extends EventEmitter {
|
|
39
|
-
private url;
|
|
40
|
-
private alias;
|
|
41
|
-
private token?;
|
|
42
|
-
private agent;
|
|
43
|
-
private resumeId;
|
|
44
|
-
private heartbeatInterval;
|
|
45
|
-
private reconnectDelay;
|
|
46
|
-
private heartbeatTimer?;
|
|
47
|
-
private sseAbort?;
|
|
48
|
-
private running;
|
|
49
|
-
constructor(opts: CommHubOptions);
|
|
50
|
-
private log;
|
|
51
|
-
private call;
|
|
52
|
-
/** Connect to CommHub: register + start SSE + heartbeat */
|
|
53
|
-
connect(): Promise<void>;
|
|
54
|
-
/** Disconnect: stop SSE + heartbeat, report offline */
|
|
55
|
-
disconnect(): Promise<void>;
|
|
56
|
-
/** Send a task to another session */
|
|
57
|
-
send(targetAlias: string, content: string, priority?: "high" | "normal" | "low"): Promise<any>;
|
|
58
|
-
/** Send a message (no task lifecycle) */
|
|
59
|
-
message(targetAlias: string, content: string): Promise<any>;
|
|
60
|
-
/** Reply to a task (update status) */
|
|
61
|
-
reply(taskId: string, text: string, status?: "completed" | "blocked" | "error" | "in_progress"): Promise<any>;
|
|
62
|
-
/** Update session status */
|
|
63
|
-
status(state: string, extra?: {
|
|
64
|
-
task?: string;
|
|
65
|
-
progress?: number;
|
|
66
|
-
}): Promise<any>;
|
|
67
|
-
/** Get all session statuses */
|
|
68
|
-
getAllStatus(): Promise<any>;
|
|
69
|
-
/** Broadcast to all sessions */
|
|
70
|
-
broadcast(content: string, filter?: {
|
|
71
|
-
server?: string;
|
|
72
|
-
status?: string;
|
|
73
|
-
}): Promise<any>;
|
|
74
|
-
private connectSSE;
|
|
75
|
-
private processInbox;
|
|
76
|
-
private sleep;
|
|
77
|
-
}
|
|
78
|
-
export default CommHub;
|