@sleep2agi/agent-network 2.0.0-preview.15 → 2.0.0-preview.16
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/dist/bin/cli.js +1 -1
- package/dist/src/client.js +1 -1
- package/dist/src/node-server.js +1 -1
- package/package.json +1 -1
package/dist/src/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a0_0x5bf5(_0x37dc89,_0x413e76){_0x37dc89=_0x37dc89-0x14d;const _0x5049de=a0_0x5049();let _0x5bf58f=_0x5049de[_0x37dc89];return _0x5bf58f;}const a0_0x109892=a0_0x5bf5;(function(_0x5d68fb,_0x5aa746){const _0x58a8b9=a0_0x5bf5,_0x35399c=_0x5d68fb();while(!![]){try{const _0x22d9f8=-parseInt(_0x58a8b9(0x18a))/0x1+-parseInt(_0x58a8b9(0x19e))/0x2*(-parseInt(_0x58a8b9(0x178))/0x3)+-parseInt(_0x58a8b9(0x193))/0x4*(parseInt(_0x58a8b9(0x190))/0x5)+parseInt(_0x58a8b9(0x16b))/0x6*(parseInt(_0x58a8b9(0x15d))/0x7)+-parseInt(_0x58a8b9(0x197))/0x8+-parseInt(_0x58a8b9(0x15e))/0x9+-parseInt(_0x58a8b9(0x17d))/0xa*(-parseInt(_0x58a8b9(0x179))/0xb);if(_0x22d9f8===_0x5aa746)break;else _0x35399c['push'](_0x35399c['shift']());}catch(_0x4efec4){_0x35399c['push'](_0x35399c['shift']());}}}(a0_0x5049,0x5d33e));function a0_0x5049(){const _0x4e23a4=['agent','application/json,\x20text/event-stream','new_task','replace','running',']\x20[commhub:','processInbox','catch','alias','new_message','497474krMZjm','sdk','name','type','sleep','server','5jkYzgQ','sdk-','min','1641216HDKaOu','log','/mcp','signal','4707560cvwKPe','AbortError','url','connected','connect','parse','heartbeat\x20failed:\x20','142OusRkA','autoConnect','heartbeatInterval','SSE\x20connected','broadcast','send_message','SSE\x20reconnecting\x20in\x20','status','match','inbox\x20error:\x20','SSE\x20error:\x20','body','message','/events/','SSE\x20failed:\x20','completed','resumeId','now','token','call','toTimeString','from_session','disconnected','2.0','cwd','text/event-stream','112qEzSso','6598764VBJlYS','abort','task','registered','heartbeatTimer','error','getReader','POST','Bearer\x20','reconnectDelay','idle','report_status','text','177588TNAVps','emit','sseAbort','offline','messages','ack_inbox','connectSSE','send_task','slice','decode','application/json','send','content','20193SyclUV','507133bzYauX','tools/call','s...','reply','360NFwBXE','startsWith','getAllStatus'];a0_0x5049=function(){return _0x4e23a4;};return a0_0x5049();}import{EventEmitter as a0_0xad638d}from'events';import{hostname as a0_0x4c4825}from'os';class T extends a0_0xad638d{['url'];['alias'];[a0_0x109892(0x155)];[a0_0x109892(0x180)];[a0_0x109892(0x153)];[a0_0x109892(0x1a0)];[a0_0x109892(0x167)];[a0_0x109892(0x162)];[a0_0x109892(0x16d)];[a0_0x109892(0x184)]=!0x1;constructor(_0x2e6136){const _0x166e77=a0_0x109892;super();if(this['url']=_0x2e6136['url'][_0x166e77(0x183)](/\/$/,''),this[_0x166e77(0x188)]=_0x2e6136[_0x166e77(0x188)],this[_0x166e77(0x155)]=_0x2e6136[_0x166e77(0x155)],this['agent']=_0x2e6136[_0x166e77(0x180)]||_0x166e77(0x18b),this[_0x166e77(0x153)]=_0x166e77(0x191)+_0x2e6136[_0x166e77(0x188)]+'-'+Date[_0x166e77(0x154)]()['toString'](0x24),this[_0x166e77(0x1a0)]=_0x2e6136['heartbeatInterval']??0x2bf20,this['reconnectDelay']=_0x2e6136[_0x166e77(0x167)]??0xbb8,_0x2e6136[_0x166e77(0x19f)]!==!0x1)this['connect']();}[a0_0x109892(0x194)](_0x3e2596){const _0x1a9640=a0_0x109892;console[_0x1a9640(0x194)]('['+new Date()[_0x1a9640(0x157)]()[_0x1a9640(0x173)](0x0,0x8)+_0x1a9640(0x185)+this[_0x1a9640(0x188)]+']\x20'+_0x3e2596);}async[a0_0x109892(0x156)](_0x15da70,_0x20beed){const _0x14e856=a0_0x109892;let _0xac0881={'Content-Type':_0x14e856(0x175),'Accept':_0x14e856(0x181)};if(this[_0x14e856(0x155)])_0xac0881['Authorization']=_0x14e856(0x166)+this[_0x14e856(0x155)];let _0x477ef6=await(await fetch(this[_0x14e856(0x199)]+_0x14e856(0x195),{'method':_0x14e856(0x165),'headers':_0xac0881,'body':JSON['stringify']({'jsonrpc':_0x14e856(0x15a),'id':Date[_0x14e856(0x154)](),'method':_0x14e856(0x17a),'params':{'name':_0x15da70,'arguments':_0x20beed}})}))[_0x14e856(0x16a)](),_0x2beb52=_0x477ef6[_0x14e856(0x1a6)](/data: (.+)/),_0x5b3459=_0x2beb52?JSON[_0x14e856(0x19c)](_0x2beb52[0x1]):JSON[_0x14e856(0x19c)](_0x477ef6),_0x95c8a6=_0x5b3459?.['result']?.['content']?.[0x0]?.[_0x14e856(0x16a)];return _0x95c8a6?JSON['parse'](_0x95c8a6):_0x5b3459;}async[a0_0x109892(0x19b)](){const _0x1f79ae=a0_0x109892;if(this['running'])return;this[_0x1f79ae(0x184)]=!0x0,await this[_0x1f79ae(0x1a5)](_0x1f79ae(0x168)),this[_0x1f79ae(0x194)](_0x1f79ae(0x161)),this[_0x1f79ae(0x162)]=setInterval(()=>{const _0x5db0c8=_0x1f79ae;this[_0x5db0c8(0x1a5)](_0x5db0c8(0x168))[_0x5db0c8(0x187)](_0x4d520c=>this[_0x5db0c8(0x194)](_0x5db0c8(0x19d)+_0x4d520c['message']));},this[_0x1f79ae(0x1a0)]),this[_0x1f79ae(0x171)]();}async['disconnect'](){const _0x50ce1e=a0_0x109892;if(this[_0x50ce1e(0x184)]=!0x1,this[_0x50ce1e(0x16d)]?.[_0x50ce1e(0x15f)](),this['heartbeatTimer'])clearInterval(this['heartbeatTimer']);await this[_0x50ce1e(0x1a5)](_0x50ce1e(0x16e))[_0x50ce1e(0x187)](()=>{}),this[_0x50ce1e(0x194)](_0x50ce1e(0x159));}async[a0_0x109892(0x176)](_0x2e7873,_0x15c023,_0xc7c806='normal'){const _0x2e836c=a0_0x109892;return this[_0x2e836c(0x156)](_0x2e836c(0x172),{'alias':_0x2e7873,'task':_0x15c023,'priority':_0xc7c806,'from_session':this[_0x2e836c(0x188)]});}async[a0_0x109892(0x14f)](_0xbb901a,_0x5c0317){const _0x11a78f=a0_0x109892;return this[_0x11a78f(0x156)](_0x11a78f(0x1a3),{'alias':_0xbb901a,'message':_0x5c0317,'from_session':this['alias']});}async[a0_0x109892(0x17c)](_0xf2abfe,_0x215ff,_0x33e2ea=a0_0x109892(0x152)){const _0xa74fd=a0_0x109892;return this[_0xa74fd(0x156)](_0xa74fd(0x17c),{'task_id':_0xf2abfe,'text':_0x215ff,'status':_0x33e2ea});}async['status'](_0x5aae5d,_0x3e6465){const _0xaa5c8e=a0_0x109892;return this[_0xaa5c8e(0x156)](_0xaa5c8e(0x169),{'resume_id':this['resumeId'],'alias':this[_0xaa5c8e(0x188)],'status':_0x5aae5d,'server':a0_0x4c4825(),'hostname':a0_0x4c4825(),'agent':this[_0xaa5c8e(0x180)],'project_dir':process[_0xaa5c8e(0x15b)](),..._0x3e6465});}async[a0_0x109892(0x17f)](){const _0x59435c=a0_0x109892;return this[_0x59435c(0x156)]('get_all_status',{});}async[a0_0x109892(0x1a2)](_0x515458,_0x1bdba5){const _0x25d86f=a0_0x109892;return this[_0x25d86f(0x156)](_0x25d86f(0x1a2),{'message':_0x515458,'filter_server':_0x1bdba5?.[_0x25d86f(0x18f)],'filter_status':_0x1bdba5?.[_0x25d86f(0x1a5)]});}async[a0_0x109892(0x171)](){const _0x555c25=a0_0x109892;let _0x332f2e=encodeURIComponent(this['alias']),_0x23b244=this['url']+_0x555c25(0x150)+_0x332f2e,_0x1ac369=this[_0x555c25(0x167)];while(this[_0x555c25(0x184)]){try{this[_0x555c25(0x16d)]=new AbortController();let _0x3acfb7={'Accept':_0x555c25(0x15c)};if(this[_0x555c25(0x155)])_0x3acfb7['Authorization']=_0x555c25(0x166)+this[_0x555c25(0x155)];let _0x526932=await fetch(_0x23b244,{'headers':_0x3acfb7,'signal':this[_0x555c25(0x16d)][_0x555c25(0x196)]});if(!_0x526932['ok']||!_0x526932[_0x555c25(0x14e)]){this[_0x555c25(0x194)](_0x555c25(0x151)+_0x526932[_0x555c25(0x1a5)]),await this['sleep'](_0x1ac369),_0x1ac369=Math[_0x555c25(0x192)](_0x1ac369*1.5,0xea60);continue;}_0x1ac369=this[_0x555c25(0x167)];let _0x33159a=_0x526932[_0x555c25(0x14e)][_0x555c25(0x164)](),_0x10c689=new TextDecoder(),_0x4cb3ab='';while(this[_0x555c25(0x184)]){let {done:_0x549abc,value:_0x323ad5}=await _0x33159a['read']();if(_0x549abc)break;_0x4cb3ab+=_0x10c689[_0x555c25(0x174)](_0x323ad5,{'stream':!0x0});let _0xc701c3=_0x4cb3ab['split']('\x0a');_0x4cb3ab=_0xc701c3['pop']()||'';for(let _0x22ceda of _0xc701c3){if(!_0x22ceda[_0x555c25(0x17e)]('data:\x20'))continue;try{let _0x11512e=JSON[_0x555c25(0x19c)](_0x22ceda['slice'](0x6));if(_0x11512e[_0x555c25(0x18d)]===_0x555c25(0x19a)){this[_0x555c25(0x194)](_0x555c25(0x1a1)),this[_0x555c25(0x16c)](_0x555c25(0x19a));continue;}if(_0x11512e[_0x555c25(0x18d)]===_0x555c25(0x182)||_0x11512e['type']===_0x555c25(0x189)||_0x11512e[_0x555c25(0x18d)]===_0x555c25(0x1a2))await this[_0x555c25(0x186)]();}catch{}}}}catch(_0x58a257){if(_0x58a257[_0x555c25(0x18c)]===_0x555c25(0x198))break;this['emit'](_0x555c25(0x163),_0x58a257),this['log'](_0x555c25(0x14d)+_0x58a257[_0x555c25(0x14f)]);}if(this[_0x555c25(0x184)])this[_0x555c25(0x16c)](_0x555c25(0x159)),this[_0x555c25(0x194)](_0x555c25(0x1a4)+_0x1ac369/0x3e8+_0x555c25(0x17b)),await this[_0x555c25(0x18e)](_0x1ac369),_0x1ac369=Math[_0x555c25(0x192)](_0x1ac369*1.5,0xea60);}}async[a0_0x109892(0x186)](){const _0x5f0ee1=a0_0x109892;try{let _0x284709=(await this[_0x5f0ee1(0x156)]('get_inbox',{'alias':this[_0x5f0ee1(0x188)],'limit':0xa}))?.[_0x5f0ee1(0x16f)]||[];for(let _0x23dd4a of _0x284709)await this[_0x5f0ee1(0x156)](_0x5f0ee1(0x170),{'alias':this[_0x5f0ee1(0x188)],'message_id':_0x23dd4a['id']}),this['log']('←\x20'+_0x23dd4a[_0x5f0ee1(0x158)]+':\x20'+_0x23dd4a[_0x5f0ee1(0x177)][_0x5f0ee1(0x173)](0x0,0x3c)),this['emit'](_0x5f0ee1(0x160),_0x23dd4a),this[_0x5f0ee1(0x16c)](_0x5f0ee1(0x14f),_0x23dd4a);}catch(_0x2c9197){this[_0x5f0ee1(0x194)](_0x5f0ee1(0x1a7)+_0x2c9197[_0x5f0ee1(0x14f)]);}}[a0_0x109892(0x18e)](_0x3d0216){return new Promise(_0x4dca30=>setTimeout(_0x4dca30,_0x3d0216));}}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_0x196d7c=a0_0x19e8;(function(_0x54142f,_0x2b71cc){const _0x4d4f8b=a0_0x19e8,_0x496756=_0x54142f();while(!![]){try{const _0x206930=parseInt(_0x4d4f8b(0xa2))/0x1+parseInt(_0x4d4f8b(0xa6))/0x2+-parseInt(_0x4d4f8b(0xe9))/0x3+-parseInt(_0x4d4f8b(0xd5))/0x4+parseInt(_0x4d4f8b(0x8b))/0x5*(parseInt(_0x4d4f8b(0xc8))/0x6)+parseInt(_0x4d4f8b(0x95))/0x7+-parseInt(_0x4d4f8b(0xba))/0x8*(parseInt(_0x4d4f8b(0xc6))/0x9);if(_0x206930===_0x2b71cc)break;else _0x496756['push'](_0x496756['shift']());}catch(_0x2f4913){_0x496756['push'](_0x496756['shift']());}}}(a0_0x5274,0x73e95));import{readFileSync as a0_0x1df49d,existsSync as a0_0x4236d4}from'fs';import{join as a0_0x43c99c}from'path';import{hostname as a0_0x4d5f8a}from'os';import{execSync as a0_0x2628d9}from'child_process';import{Server as a0_0x524037}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport as a0_0x10a924}from'@modelcontextprotocol/sdk/server/stdio.js';import{ListToolsRequestSchema as a0_0x1078a5,CallToolRequestSchema as a0_0xfb936e}from'@modelcontextprotocol/sdk/types.js';function p(_0x2e1856){const _0x262137=a0_0x19e8;if(!a0_0x4236d4(_0x2e1856))return;for(let _0x4aa320 of a0_0x1df49d(_0x2e1856,_0x262137(0x111))[_0x262137(0xb9)]('\x0a')){let _0x1d8319=_0x4aa320[_0x262137(0x105)]();if(!_0x1d8319||_0x1d8319[_0x262137(0xbd)]('#'))continue;let _0x57cae3=_0x1d8319['indexOf']('=');if(_0x57cae3<0x0)continue;let _0x160af1=_0x1d8319[_0x262137(0xe7)](0x0,_0x57cae3)[_0x262137(0x105)](),_0x2d892c=_0x1d8319[_0x262137(0xe7)](_0x57cae3+0x1)['trim']()[_0x262137(0xa8)](/^["']|["']$/g,'');if(!process.env[_0x160af1])process.env[_0x160af1]=_0x2d892c;}}var C=process.env.HOME||'~',T=a0_0x43c99c(C,a0_0x196d7c(0xac));p(a0_0x43c99c(T,'.env'));var L=process[a0_0x196d7c(0xc9)]()[a0_0x196d7c(0xa8)](/\//g,'-');p(a0_0x43c99c(T,L,a0_0x196d7c(0x93)));function U(){const _0x22e668=a0_0x196d7c;try{return a0_0x2628d9(_0x22e668(0xaa),{'encoding':_0x22e668(0x111),'timeout':0x7d0})[_0x22e668(0x105)]();}catch{return'';}}function c(){const _0x5edb68=a0_0x196d7c;try{let _0x1dc678=a0_0x43c99c(C,'.anet',_0x5edb68(0x9a));if(a0_0x4236d4(_0x1dc678))return JSON[_0x5edb68(0x113)](a0_0x1df49d(_0x1dc678,_0x5edb68(0x111)));}catch{}return{};}var H=c(),D=process.env.COMMHUB_URL||H[a0_0x196d7c(0x91)]||'http://127.0.0.1:9200',f=process.env.COMMHUB_TMUX||U(),Z=process.env.COMMHUB_ALIAS||f||a0_0x4d5f8a(),w=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||crypto[a0_0x196d7c(0xaf)](),X=process.env.COMMHUB_TOKEN||H[a0_0x196d7c(0xe2)]||'';function Y(_0x11b794){const _0x14ab13=a0_0x196d7c;let _0x1a9c26=new Date()['toTimeString']()[_0x14ab13(0xe7)](0x0,0x8);process[_0x14ab13(0xd0)][_0x14ab13(0xdc)]('['+_0x1a9c26+_0x14ab13(0xee)+_0x11b794+'\x0a');}function h(_0xc0eec4){return new Promise(_0x4bfccc=>setTimeout(_0x4bfccc,_0xc0eec4));}Y(a0_0x196d7c(0xe6)+D+'\x20ALIAS='+Z+a0_0x196d7c(0x112)+w[a0_0x196d7c(0xe7)](0x0,0x8)+a0_0x196d7c(0x9f)+(f||'none')+a0_0x196d7c(0x108)+process[a0_0x196d7c(0xc9)]()+a0_0x196d7c(0x115)+L);var k=new Map(),K=new a0_0x524037({'name':a0_0x196d7c(0xb0),'version':a0_0x196d7c(0x104)},{'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_0x196d7c(0x8c),a0_0x196d7c(0xcd),'You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.',a0_0x196d7c(0x10f)+Z][a0_0x196d7c(0xbe)]('\x0a')});K[a0_0x196d7c(0xed)](a0_0x1078a5,async()=>({'tools':[{'name':a0_0x196d7c(0xda),'description':a0_0x196d7c(0x9c),'inputSchema':{'type':'object','properties':{'task_id':{'type':'string','description':'The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)'},'text':{'type':'string','description':a0_0x196d7c(0xc0)},'status':{'type':a0_0x196d7c(0xbc),'enum':[a0_0x196d7c(0xf9),a0_0x196d7c(0xeb),a0_0x196d7c(0xb5),a0_0x196d7c(0x94),a0_0x196d7c(0xab),a0_0x196d7c(0xf3)],'description':a0_0x196d7c(0xf4)}},'required':[a0_0x196d7c(0xe1)]}},{'name':a0_0x196d7c(0x102),'description':'Update\x20this\x20session\x27s\x20status\x20in\x20CommHub\x20(working/idle/blocked/error).\x20Returns\x20inbox_count.','inputSchema':{'type':a0_0x196d7c(0xa9),'properties':{'status':{'type':'string','enum':['working',a0_0x196d7c(0x101),'blocked',a0_0x196d7c(0xab)]},'task':{'type':'string','description':a0_0x196d7c(0xd8)},'progress':{'type':a0_0x196d7c(0xf2),'description':a0_0x196d7c(0x9d)}},'required':[a0_0x196d7c(0x97)]}},{'name':a0_0x196d7c(0xb7),'description':a0_0x196d7c(0x10a),'inputSchema':{'type':a0_0x196d7c(0xa9),'properties':{'alias':{'type':a0_0x196d7c(0xbc),'description':a0_0x196d7c(0xe5)},'task':{'type':a0_0x196d7c(0xbc),'description':'Task\x20content'},'priority':{'type':a0_0x196d7c(0xbc),'enum':[a0_0x196d7c(0xfb),'normal','low'],'description':a0_0x196d7c(0xdb)}},'required':[a0_0x196d7c(0xea),a0_0x196d7c(0xc7)]}},{'name':a0_0x196d7c(0x92),'description':a0_0x196d7c(0x9e),'inputSchema':{'type':a0_0x196d7c(0xa9),'properties':{'alias':{'type':a0_0x196d7c(0xbc),'description':a0_0x196d7c(0xe5)},'message':{'type':'string','description':a0_0x196d7c(0x107)}},'required':[a0_0x196d7c(0xea),a0_0x196d7c(0xb3)]}},{'name':a0_0x196d7c(0xae),'description':a0_0x196d7c(0xe3),'inputSchema':{'type':a0_0x196d7c(0xa9),'properties':{}}}]}));async function P(_0x5d6562,_0x3fe7af){const _0x398f59=a0_0x196d7c;let _0x1cd9a5=await fetch(D+_0x398f59(0x10d),{'method':_0x398f59(0xa3),'headers':{'Content-Type':_0x398f59(0xf7),'Accept':'application/json,\x20text/event-stream',...X?{'Authorization':_0x398f59(0x99)+X}:{}},'body':JSON['stringify']({'jsonrpc':'2.0','id':0x1,'method':'initialize','params':{'protocolVersion':_0x398f59(0xc4),'capabilities':{},'clientInfo':{'name':_0x398f59(0xb0),'version':_0x398f59(0x104)}}})});if(!_0x1cd9a5['ok']){let _0x522799=await _0x1cd9a5[_0x398f59(0xe1)]();return Y(_0x398f59(0x10b)+_0x1cd9a5[_0x398f59(0x97)]+'\x20'+_0x522799[_0x398f59(0xe7)](0x0,0x64)),{'ok':!0x1,'error':_0x398f59(0xcc)+_0x1cd9a5['status']};}await _0x1cd9a5[_0x398f59(0xe1)]();let _0x394295=(await(await fetch(D+_0x398f59(0x10d),{'method':_0x398f59(0xa3),'headers':{'Content-Type':_0x398f59(0xf7),'Accept':'application/json,\x20text/event-stream',...X?{'Authorization':_0x398f59(0x99)+X}:{}},'body':JSON[_0x398f59(0x100)]({'jsonrpc':_0x398f59(0xb8),'id':0x2,'method':_0x398f59(0xdd),'params':{'name':_0x5d6562,'arguments':_0x3fe7af}})}))[_0x398f59(0xe1)]())[_0x398f59(0xb9)]('\x0a')[_0x398f59(0xe4)](_0x496020=>_0x496020[_0x398f59(0xbd)](_0x398f59(0x114)));if(_0x394295){let _0x411ab8=JSON[_0x398f59(0x113)](_0x394295[_0x398f59(0xe7)](0x6));return _0x411ab8?.[_0x398f59(0x9b)]?.[_0x398f59(0xb6)]?.[0x0]?.[_0x398f59(0xe1)]?JSON[_0x398f59(0x113)](_0x411ab8[_0x398f59(0x9b)][_0x398f59(0xb6)][0x0][_0x398f59(0xe1)]):_0x411ab8;}return{'ok':!0x1,'error':_0x398f59(0xad)};}K[a0_0x196d7c(0xed)](a0_0xfb936e,async _0xdbac49=>{const _0x355eb7=a0_0x196d7c;let {name:_0x138b93,arguments:_0x57f912}=_0xdbac49[_0x355eb7(0xbf)];if(_0x138b93===_0x355eb7(0xda)){let {task_id:_0x3bc34b,text:_0x5d00d3,status:_0x4e0747}=_0x57f912;if(_0x4e0747===_0x355eb7(0xf9)||_0x4e0747===_0x355eb7(0xeb)||_0x4e0747===_0x355eb7(0xb5)){let _0xc3f533=_0x4e0747==='completed'?_0x355eb7(0xa7):_0x4e0747,_0x4d47b6=_0x3bc34b?k[_0x355eb7(0x96)](_0x3bc34b)||_0x355eb7(0x91):_0x355eb7(0x91),_0x240555=await P('send_reply',{'alias':_0x4d47b6,'text':_0x5d00d3,'in_reply_to':_0x3bc34b||void 0x0,'status':_0xc3f533,'from_session':Z});if(_0x3bc34b)k[_0x355eb7(0x8f)](_0x3bc34b);return{'content':[{'type':_0x355eb7(0xe1),'text':JSON['stringify'](_0x240555)}]};}let _0x217d0f=await P('report_status',{'resume_id':w,'alias':Z,'status':_0x4e0747===_0x355eb7(0x94)?'blocked':_0x4e0747===_0x355eb7(0xab)?_0x355eb7(0xab):'working','task':_0x5d00d3[_0x355eb7(0xe7)](0x0,0xc8),'output':_0x5d00d3});return{'content':[{'type':_0x355eb7(0xe1),'text':JSON['stringify'](_0x217d0f)}]};}if(_0x138b93===_0x355eb7(0x102)){let {status:_0xa8c782,task:_0x49c261,progress:_0x12d2d2}=_0x57f912,_0x616958=await P(_0x355eb7(0xa0),{'resume_id':w,'alias':Z,'status':_0xa8c782,'task':_0x49c261,'progress':_0x12d2d2});return{'content':[{'type':_0x355eb7(0xe1),'text':JSON['stringify'](_0x616958)}]};}if(_0x138b93==='commhub_send_task'){let {alias:_0x178604,task:_0x432e27,priority:_0x4f8a4b}=_0x57f912,_0x193f57=await P('send_task',{'alias':_0x178604,'task':_0x432e27,'priority':_0x4f8a4b||_0x355eb7(0xe8),'from_session':Z});return{'content':[{'type':_0x355eb7(0xe1),'text':JSON[_0x355eb7(0x100)](_0x193f57)}]};}if(_0x138b93===_0x355eb7(0x92)){let {alias:_0x7e3bad,message:_0x55bac4}=_0x57f912,_0x38b601=await P(_0x355eb7(0xde),{'alias':_0x7e3bad,'message':_0x55bac4,'from_session':Z});return{'content':[{'type':_0x355eb7(0xe1),'text':JSON[_0x355eb7(0x100)](_0x38b601)}]};}if(_0x138b93===_0x355eb7(0xae)){let _0x233f3a=await P(_0x355eb7(0xfc),{});return{'content':[{'type':_0x355eb7(0xe1),'text':JSON[_0x355eb7(0x100)](_0x233f3a)}]};}return{'content':[{'type':_0x355eb7(0xe1),'text':JSON[_0x355eb7(0x100)]({'error':_0x355eb7(0xdf)})}]};});function a0_0x19e8(_0xd1073c,_0x80dbe2){_0xd1073c=_0xd1073c-0x8b;const _0x5274f4=a0_0x5274();let _0x19e811=_0x5274f4[_0xd1073c];return _0x19e811;}async function v(){const _0x9b5b65=a0_0x196d7c;let _0x4e3804=D+'/events/'+encodeURIComponent(Z),_0x286635={};if(X)_0x286635[_0x9b5b65(0x8d)]='Bearer\x20'+X;Y(_0x9b5b65(0xb2)+_0x4e3804);while(!0x0){try{let _0x4d333a=await fetch(_0x4e3804,{'headers':_0x286635});if(!_0x4d333a['ok']){Y(_0x9b5b65(0xc3)+_0x4d333a[_0x9b5b65(0x97)]+'\x20'+_0x4d333a[_0x9b5b65(0xa1)]),await h(0x1388);continue;}let _0x18e8b4=_0x4d333a[_0x9b5b65(0xca)][_0x9b5b65(0xf5)](),_0xc7efd2=new TextDecoder(),_0xc2869d='';while(!0x0){let {done:_0x446aa8,value:_0x5c6a08}=await _0x18e8b4[_0x9b5b65(0x10e)]();if(_0x446aa8)break;_0xc2869d+=_0xc7efd2[_0x9b5b65(0x103)](_0x5c6a08,{'stream':!0x0});let _0x4468f7=_0xc2869d[_0x9b5b65(0xb9)]('\x0a\x0a');_0xc2869d=_0x4468f7[_0x9b5b65(0x90)]()||'';for(let _0x4695c6 of _0x4468f7){let _0x514b78=_0x4695c6['split']('\x0a')['find'](_0x7b1800=>_0x7b1800[_0x9b5b65(0xbd)](_0x9b5b65(0x114)));if(!_0x514b78)continue;try{let _0x4cb5ff=JSON[_0x9b5b65(0x113)](_0x514b78[_0x9b5b65(0xe7)](0x6));await u(_0x4cb5ff);}catch(_0x334bdc){Y(_0x9b5b65(0xbb)+_0x334bdc);}}}Y('SSE\x20stream\x20ended,\x20reconnecting...');}catch(_0x3eeabb){Y('SSE\x20connection\x20error:\x20'+_0x3eeabb);}await h(0xbb8);}}async function u(_0x186fcd){const _0x3fed35=a0_0x196d7c;if(_0x186fcd['type']===_0x3fed35(0xf8)){Y(_0x3fed35(0xd9)+Z+'\x22');return;}if(_0x186fcd[_0x3fed35(0xf1)]==='new_message'){if(Y('←\x20message\x20from\x20'+_0x186fcd['from']+':\x20'+_0x186fcd['message'][_0x3fed35(0xe7)](0x0,0x3c)),await K[_0x3fed35(0x10c)]({'method':'notifications/claude/channel','params':{'content':_0x186fcd[_0x3fed35(0xb3)],'meta':{'sender':_0x186fcd['from']||_0x3fed35(0x91),'sender_id':_0x3fed35(0xff),'user':_0x186fcd[_0x3fed35(0xef)]||_0x3fed35(0x91),'priority':_0x3fed35(0xe8)}}}),_0x186fcd[_0x3fed35(0xc5)])await P(_0x3fed35(0xfe),{'alias':Z,'message_id':_0x186fcd[_0x3fed35(0xc5)]});return;}if(_0x186fcd['type']===_0x3fed35(0x109)||_0x186fcd['type']==='broadcast'){Y('←\x20'+_0x186fcd['type']+_0x3fed35(0xc2)+_0x186fcd[_0x3fed35(0xd6)]+'\x20priority='+(_0x186fcd[_0x3fed35(0xcf)]||_0x3fed35(0xe8)));let _0x978aa4=await P(_0x3fed35(0xa4),{'alias':Z,'limit':0x5});if(_0x978aa4?.['ok']&&_0x978aa4[_0x3fed35(0xe0)]?.[_0x3fed35(0x98)]>0x0)for(let _0xb73873 of _0x978aa4[_0x3fed35(0xe0)]){let _0x44ed94={'sender':_0xb73873[_0x3fed35(0xf6)]||_0x3fed35(0x91),'sender_id':'commhub','user':_0xb73873[_0x3fed35(0xf6)]||_0x3fed35(0x91),'task_id':_0xb73873['id'],'priority':_0xb73873['priority']||_0x3fed35(0xe8)};k[_0x3fed35(0x110)](_0xb73873['id'],_0xb73873['from_session']||_0x3fed35(0x91)),await K[_0x3fed35(0x10c)]({'method':_0x3fed35(0xc1),'params':{'content':_0xb73873[_0x3fed35(0xb6)],'meta':_0x44ed94}}),Y('→\x20injected\x20task\x20'+_0xb73873['id'][_0x3fed35(0xe7)](0x0,0x8)+_0x3fed35(0xfa)+_0xb73873[_0x3fed35(0xf6)]+':\x20'+_0xb73873['content'][_0x3fed35(0xe7)](0x0,0x3c)),await P(_0x3fed35(0xfe),{'alias':Z,'message_id':_0xb73873['id']});}}}async function S(){const _0x1efc53=a0_0x196d7c;let _0x4b2136=new a0_0x10a924();await K['connect'](_0x4b2136),Y(_0x1efc53(0x8e)),Y('starting\x20SSE\x20listener...'),v()[_0x1efc53(0xb1)](_0x47f97e=>Y(_0x1efc53(0xfd)+_0x47f97e)),P('report_status',{'resume_id':w,'alias':Z,'status':'idle','server':a0_0x4d5f8a(),'hostname':a0_0x4d5f8a(),'agent':_0x1efc53(0xf0),'project_dir':process['cwd'](),'tmux_name':f||void 0x0})[_0x1efc53(0xd3)](()=>Y(_0x1efc53(0xd7)+Z+_0x1efc53(0xec)+w[_0x1efc53(0xe7)](0x0,0x8)+')'))[_0x1efc53(0xb1)](_0x13e86b=>Y('warning:\x20could\x20not\x20register:\x20'+_0x13e86b)),setInterval(()=>{const _0x4781a9=_0x1efc53;P(_0x4781a9(0xa0),{'resume_id':w,'alias':Z,'status':'idle','server':a0_0x4d5f8a(),'hostname':a0_0x4d5f8a(),'agent':'claude-code','project_dir':process[_0x4781a9(0xc9)](),'tmux_name':f||void 0x0})[_0x4781a9(0xb1)](_0x51c231=>Y(_0x4781a9(0xa5)+_0x51c231));},0x2bf20),Y(_0x1efc53(0xb4));}S()[a0_0x196d7c(0xb1)](_0x15bd4e=>{const _0x554d4e=a0_0x196d7c;Y(_0x554d4e(0xd4)+_0x15bd4e),process['exit'](0x1);});async function N(){const _0x12a694=a0_0x196d7c;Y(_0x12a694(0xd1)),await P('report_status',{'resume_id':w,'alias':Z,'status':_0x12a694(0xab),'task':_0x12a694(0xd2)})['catch'](()=>{}),process[_0x12a694(0xce)](0x0);}process[a0_0x196d7c(0xcb)]['on']('end',()=>N()),process['on'](a0_0x196d7c(0x106),()=>N()),process['on']('SIGINT',()=>N());function a0_0x5274(){const _0x37270a=['text','token','Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','find','Target\x20session\x20alias','ENV:\x20URL=','slice','normal','553335NIZuLU','alias','failed','\x22\x20(','setRequestHandler',']\x20[commhub]\x20','from','claude-code','type','number','in_progress','Task\x20outcome:\x20completed/failed/cancelled\x20for\x20final\x20results,\x20blocked/error/in_progress\x20for\x20status\x20updates','getReader','from_session','application/json','connected','completed','\x20from\x20','high','get_all_status','SSE\x20fatal:\x20','ack_inbox','commhub','stringify','idle','commhub_report_status','decode','0.3.0','trim','SIGTERM','Message\x20content','\x20CWD=','new_task','Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.','CommHub\x20init\x20failed:\x20','notification','/mcp','read','Session\x20alias:\x20','set','utf-8','\x20RESUME_ID=','parse','data:\x20','\x20PROJECT_ENV=','1195dOhwcl','These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.','Authorization','MCP\x20stdio\x20connected','delete','pop','hub','commhub_send_message','.env','blocked','4631662AtuMdj','get','status','length','Bearer\x20','config.json','result','Reply\x20to\x20a\x20CommHub\x20task\x20—\x20report\x20completion\x20or\x20send\x20a\x20message\x20back\x20to\x20the\x20hub.','Progress\x200-100','Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.','...\x20TMUX=','report_status','statusText','338452srSJRH','POST','get_inbox','heartbeat\x20failed:\x20','504776NZkgzJ','replied','replace','object','tmux\x20display-message\x20-p\x20\x27#S\x27','error','.claude/channels/commhub','no\x20response','commhub_get_all_status','randomUUID','commhub-channel','catch','connecting\x20to\x20','message','ready\x20—\x20waiting\x20for\x20events','cancelled','content','commhub_send_task','2.0','split','1264QyIPHI','parse\x20error:\x20','string','startsWith','join','params','Reply\x20text\x20/\x20result\x20summary','notifications/claude/channel',':\x20inbox_count=','SSE\x20error:\x20','2025-03-26','message_id','45297GiZNwp','task','21606ONWcIo','cwd','body','stdin','init\x20failed:\x20','Reply\x20using\x20the\x20commhub_reply\x20tool\x20to\x20report\x20status\x20or\x20results\x20back.','exit','priority','stderr','shutting\x20down,\x20reporting\x20offline...','session\x20disconnected','then','fatal:\x20','2634852CdORQS','inbox_count','registered\x20as\x20\x22','Current\x20task\x20description','SSE\x20connected\x20as\x20\x22','commhub_reply','Priority\x20(default:\x20normal)','write','tools/call','send_message','unknown\x20tool','messages'];a0_0x5274=function(){return _0x37270a;};return a0_0x5274();}
|
|
2
|
+
const a0_0x21d675=a0_0xf0c9;(function(_0x4d95c5,_0x3d1b96){const _0x3b6519=a0_0xf0c9,_0x4de32b=_0x4d95c5();while(!![]){try{const _0x2fcb40=-parseInt(_0x3b6519(0x151))/0x1*(-parseInt(_0x3b6519(0x1ce))/0x2)+parseInt(_0x3b6519(0x14d))/0x3*(-parseInt(_0x3b6519(0x1a6))/0x4)+parseInt(_0x3b6519(0x1d9))/0x5*(parseInt(_0x3b6519(0x1af))/0x6)+-parseInt(_0x3b6519(0x172))/0x7+parseInt(_0x3b6519(0x16f))/0x8*(-parseInt(_0x3b6519(0x1c9))/0x9)+-parseInt(_0x3b6519(0x19a))/0xa*(-parseInt(_0x3b6519(0x150))/0xb)+-parseInt(_0x3b6519(0x164))/0xc;if(_0x2fcb40===_0x3d1b96)break;else _0x4de32b['push'](_0x4de32b['shift']());}catch(_0x32724b){_0x4de32b['push'](_0x4de32b['shift']());}}}(a0_0x2e99,0x18b4f));import{readFileSync as a0_0x4b5a9d,existsSync as a0_0x48b755}from'fs';function a0_0xf0c9(_0x189399,_0x5a6579){_0x189399=_0x189399-0x148;const _0x2e999d=a0_0x2e99();let _0xf0c9b6=_0x2e999d[_0x189399];return _0xf0c9b6;}import{join as a0_0x491528}from'path';import{hostname as a0_0x3ccc66}from'os';import{execSync as a0_0x965a1}from'child_process';import{Server as a0_0x384a49}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport as a0_0x270f7d}from'@modelcontextprotocol/sdk/server/stdio.js';import{ListToolsRequestSchema as a0_0x4109b0,CallToolRequestSchema as a0_0x3fb2ac}from'@modelcontextprotocol/sdk/types.js';function p(_0x2cb145){const _0x3da3aa=a0_0xf0c9;if(!a0_0x48b755(_0x2cb145))return;for(let _0x5eed2a of a0_0x4b5a9d(_0x2cb145,'utf-8')[_0x3da3aa(0x1ca)]('\x0a')){let _0x27f9a1=_0x5eed2a[_0x3da3aa(0x19e)]();if(!_0x27f9a1||_0x27f9a1[_0x3da3aa(0x1a7)]('#'))continue;let _0x440e9d=_0x27f9a1[_0x3da3aa(0x14c)]('=');if(_0x440e9d<0x0)continue;let _0x274d3e=_0x27f9a1['slice'](0x0,_0x440e9d)['trim'](),_0x292b42=_0x27f9a1[_0x3da3aa(0x184)](_0x440e9d+0x1)['trim']()[_0x3da3aa(0x1c5)](/^["']|["']$/g,'');if(!process.env[_0x274d3e])process.env[_0x274d3e]=_0x292b42;}}var C=process.env.HOME||'~',T=a0_0x491528(C,'.claude/channels/commhub');p(a0_0x491528(T,a0_0x21d675(0x1a5)));var L=process[a0_0x21d675(0x195)]()['replace'](/\//g,'-');p(a0_0x491528(T,L,a0_0x21d675(0x1a5)));function a0_0x2e99(){const _0x3eea40=['commhub_report_status','2742DlGbsW','ready\x20—\x20waiting\x20for\x20events','hub','Current\x20task\x20description','...\x20TMUX=','\x22\x20(','0.3.0','error','status','data:\x20','/mcp','2025-03-26','no\x20response','unknown\x20tool','idle','get_inbox','ENV:\x20URL=','find','length','exit','randomUUID','\x20PROJECT_ENV=','replace','token','init\x20failed:\x20','SSE\x20stream\x20ended,\x20reconnecting...','45lAAnRy','split','session\x20disconnected','utf-8','pop','352136nxBzhz','catch',']\x20[commhub]\x20','none','The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)','commhub_send_task','Bearer\x20','SSE\x20error:\x20','application/json','get','normal','2005eZwTdU','shutting\x20down,\x20reporting\x20offline...','object','result','fatal:\x20','indexOf','8166ZlpEWT','type','connect','90178HhmowS','1IjnRus','POST','send_task','warning:\x20could\x20not\x20register:\x20','cancelled','connecting\x20to\x20','high','Authorization','low','commhub_send_message','new_task','failed','text','\x20ALIAS=','config.json','commhub_reply','/events/','claude-code','message_id','3206100VbVSsF','message','parse','SIGINT','report_status','from_session','body','string','statusText',':\x20inbox_count=','registered\x20as\x20\x22','121488PlirOI','in_progress','inbox_count','496377wlNVSY','application/json,\x20text/event-stream','number','blocked','You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.','delete','Target\x20session\x20alias','working','content','http://127.0.0.1:9200','broadcast','heartbeat\x20failed:\x20','tools/call','Messages\x20from\x20CommHub\x20arrive\x20as\x20<channel\x20source=\x22commhub\x22\x20task_id=\x22...\x22\x20priority=\x22...\x22\x20from=\x22...\x22>','setRequestHandler','←\x20message\x20from\x20','CommHub\x20init\x20failed:\x20','SIGTERM','slice','\x20CWD=','Progress\x200-100','commhub','initialize','2.0','.anet','commhub_get_all_status','from','ack_inbox','Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.','completed','read','then','\x20from\x20','messages','Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.','cwd','priority','Session\x20alias:\x20','MCP\x20stdio\x20connected','replied','230cPKzNw','Reply\x20to\x20a\x20CommHub\x20task\x20—\x20report\x20completion\x20or\x20send\x20a\x20message\x20back\x20to\x20the\x20hub.','task','params','trim','→\x20injected\x20task\x20','Task\x20outcome:\x20completed/failed/cancelled\x20for\x20final\x20results,\x20blocked/error/in_progress\x20for\x20status\x20updates','send_reply','\x20priority=','send_message','stringify','.env','48Dohsya','startsWith','notification','tmux\x20display-message\x20-p\x20\x27#S\x27','SSE\x20connection\x20error:\x20','notifications/claude/channel','decode','These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.'];a0_0x2e99=function(){return _0x3eea40;};return a0_0x2e99();}function U(){const _0x51f3e7=a0_0x21d675;try{return a0_0x965a1(_0x51f3e7(0x1a9),{'encoding':'utf-8','timeout':0x7d0})[_0x51f3e7(0x19e)]();}catch{return'';}}function c(){const _0x118c83=a0_0x21d675;try{let _0x217ef9=a0_0x491528(C,_0x118c83(0x18a),_0x118c83(0x15f));if(a0_0x48b755(_0x217ef9))return JSON[_0x118c83(0x166)](a0_0x4b5a9d(_0x217ef9,_0x118c83(0x1cc)));}catch{}return{};}var H=c(),D=process.env.COMMHUB_URL||H[a0_0x21d675(0x1b1)]||a0_0x21d675(0x17b),f=process.env.COMMHUB_TMUX||U(),Z=process.env.COMMHUB_ALIAS||f||a0_0x3ccc66(),w=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||crypto[a0_0x21d675(0x1c3)](),X=process.env.COMMHUB_TOKEN||H[a0_0x21d675(0x1c6)]||'';function Y(_0x5efddf){const _0x9de8c0=a0_0x21d675;let _0x3109dd=new Date()['toTimeString']()[_0x9de8c0(0x184)](0x0,0x8);process['stderr']['write']('['+_0x3109dd+_0x9de8c0(0x1d0)+_0x5efddf+'\x0a');}function h(_0x5edc6a){return new Promise(_0x3ed3a3=>setTimeout(_0x3ed3a3,_0x5edc6a));}Y(a0_0x21d675(0x1bf)+D+a0_0x21d675(0x15e)+Z+'\x20RESUME_ID='+w['slice'](0x0,0x8)+a0_0x21d675(0x1b3)+(f||a0_0x21d675(0x1d1))+a0_0x21d675(0x185)+process[a0_0x21d675(0x195)]()+a0_0x21d675(0x1c4)+L);var k=new Map(),K=new a0_0x384a49({'name':'commhub-channel','version':a0_0x21d675(0x1b5)},{'capabilities':{'experimental':{'claude/channel':{}},'tools':{}},'instructions':[a0_0x21d675(0x17f),a0_0x21d675(0x1ad),'Reply\x20using\x20the\x20commhub_reply\x20tool\x20to\x20report\x20status\x20or\x20results\x20back.',a0_0x21d675(0x176),a0_0x21d675(0x197)+Z]['join']('\x0a')});K['setRequestHandler'](a0_0x4109b0,async()=>({'tools':[{'name':a0_0x21d675(0x160),'description':a0_0x21d675(0x19b),'inputSchema':{'type':a0_0x21d675(0x149),'properties':{'task_id':{'type':a0_0x21d675(0x16b),'description':a0_0x21d675(0x1d2)},'text':{'type':a0_0x21d675(0x16b),'description':'Reply\x20text\x20/\x20result\x20summary'},'status':{'type':a0_0x21d675(0x16b),'enum':[a0_0x21d675(0x18f),a0_0x21d675(0x15c),a0_0x21d675(0x155),a0_0x21d675(0x175),'error',a0_0x21d675(0x170)],'description':a0_0x21d675(0x1a0)}},'required':['text']}},{'name':a0_0x21d675(0x1ae),'description':'Update\x20this\x20session\x27s\x20status\x20in\x20CommHub\x20(working/idle/blocked/error).\x20Returns\x20inbox_count.','inputSchema':{'type':a0_0x21d675(0x149),'properties':{'status':{'type':a0_0x21d675(0x16b),'enum':['working',a0_0x21d675(0x1bd),a0_0x21d675(0x175),'error']},'task':{'type':'string','description':a0_0x21d675(0x1b2)},'progress':{'type':a0_0x21d675(0x174),'description':a0_0x21d675(0x186)}},'required':['status']}},{'name':a0_0x21d675(0x1d3),'description':a0_0x21d675(0x18e),'inputSchema':{'type':a0_0x21d675(0x149),'properties':{'alias':{'type':a0_0x21d675(0x16b),'description':a0_0x21d675(0x178)},'task':{'type':a0_0x21d675(0x16b),'description':'Task\x20content'},'priority':{'type':a0_0x21d675(0x16b),'enum':[a0_0x21d675(0x157),a0_0x21d675(0x1d8),a0_0x21d675(0x159)],'description':'Priority\x20(default:\x20normal)'}},'required':['alias',a0_0x21d675(0x19c)]}},{'name':a0_0x21d675(0x15a),'description':a0_0x21d675(0x194),'inputSchema':{'type':a0_0x21d675(0x149),'properties':{'alias':{'type':a0_0x21d675(0x16b),'description':a0_0x21d675(0x178)},'message':{'type':a0_0x21d675(0x16b),'description':'Message\x20content'}},'required':['alias',a0_0x21d675(0x165)]}},{'name':a0_0x21d675(0x18b),'description':'Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','inputSchema':{'type':a0_0x21d675(0x149),'properties':{}}}]}));async function P(_0x3b4c53,_0x24cdde){const _0xd484ab=a0_0x21d675;let _0x1e9111=await fetch(D+_0xd484ab(0x1b9),{'method':_0xd484ab(0x152),'headers':{'Content-Type':_0xd484ab(0x1d6),'Accept':_0xd484ab(0x173),...X?{'Authorization':'Bearer\x20'+X}:{}},'body':JSON[_0xd484ab(0x1a4)]({'jsonrpc':_0xd484ab(0x189),'id':0x1,'method':_0xd484ab(0x188),'params':{'protocolVersion':_0xd484ab(0x1ba),'capabilities':{},'clientInfo':{'name':'commhub-channel','version':'0.3.0'}}})});if(!_0x1e9111['ok']){let _0x2bb74e=await _0x1e9111['text']();return Y(_0xd484ab(0x182)+_0x1e9111['status']+'\x20'+_0x2bb74e[_0xd484ab(0x184)](0x0,0x64)),{'ok':!0x1,'error':_0xd484ab(0x1c7)+_0x1e9111[_0xd484ab(0x1b7)]};}await _0x1e9111['text']();let _0x504f9b=(await(await fetch(D+'/mcp',{'method':_0xd484ab(0x152),'headers':{'Content-Type':_0xd484ab(0x1d6),'Accept':'application/json,\x20text/event-stream',...X?{'Authorization':_0xd484ab(0x1d4)+X}:{}},'body':JSON[_0xd484ab(0x1a4)]({'jsonrpc':_0xd484ab(0x189),'id':0x2,'method':_0xd484ab(0x17e),'params':{'name':_0x3b4c53,'arguments':_0x24cdde}})}))[_0xd484ab(0x15d)]())['split']('\x0a')[_0xd484ab(0x1c0)](_0x305e33=>_0x305e33[_0xd484ab(0x1a7)](_0xd484ab(0x1b8)));if(_0x504f9b){let _0x2ab237=JSON[_0xd484ab(0x166)](_0x504f9b[_0xd484ab(0x184)](0x6));return _0x2ab237?.['result']?.[_0xd484ab(0x17a)]?.[0x0]?.[_0xd484ab(0x15d)]?JSON[_0xd484ab(0x166)](_0x2ab237[_0xd484ab(0x14a)][_0xd484ab(0x17a)][0x0][_0xd484ab(0x15d)]):_0x2ab237;}return{'ok':!0x1,'error':_0xd484ab(0x1bb)};}K[a0_0x21d675(0x180)](a0_0x3fb2ac,async _0x171416=>{const _0x3376ba=a0_0x21d675;let {name:_0x241619,arguments:_0x485317}=_0x171416[_0x3376ba(0x19d)];if(_0x241619===_0x3376ba(0x160)){let {task_id:_0x402a05,text:_0x330f1c,status:_0x3c4d12}=_0x485317;if(_0x3c4d12==='completed'||_0x3c4d12==='failed'||_0x3c4d12===_0x3376ba(0x155)){let _0x17ba3d=_0x3c4d12===_0x3376ba(0x18f)?_0x3376ba(0x199):_0x3c4d12,_0x4103c3=_0x402a05?k[_0x3376ba(0x1d7)](_0x402a05)||_0x3376ba(0x1b1):_0x3376ba(0x1b1),_0x122a61=await P(_0x3376ba(0x1a1),{'alias':_0x4103c3,'text':_0x330f1c,'in_reply_to':_0x402a05||void 0x0,'status':_0x17ba3d,'from_session':Z});if(_0x402a05)k[_0x3376ba(0x177)](_0x402a05);return{'content':[{'type':'text','text':JSON[_0x3376ba(0x1a4)](_0x122a61)}]};}let _0x4fbc90=await P(_0x3376ba(0x168),{'resume_id':w,'alias':Z,'status':_0x3c4d12===_0x3376ba(0x175)?_0x3376ba(0x175):_0x3c4d12===_0x3376ba(0x1b6)?'error':_0x3376ba(0x179),'task':_0x330f1c[_0x3376ba(0x184)](0x0,0xc8),'output':_0x330f1c});return{'content':[{'type':'text','text':JSON[_0x3376ba(0x1a4)](_0x4fbc90)}]};}if(_0x241619===_0x3376ba(0x1ae)){let {status:_0x525d65,task:_0x2e932d,progress:_0x29a36f}=_0x485317,_0x15a843=await P(_0x3376ba(0x168),{'resume_id':w,'alias':Z,'status':_0x525d65,'task':_0x2e932d,'progress':_0x29a36f});return{'content':[{'type':_0x3376ba(0x15d),'text':JSON[_0x3376ba(0x1a4)](_0x15a843)}]};}if(_0x241619==='commhub_send_task'){let {alias:_0x2ab342,task:_0x5ea12e,priority:_0x393973}=_0x485317,_0x126040=await P(_0x3376ba(0x153),{'alias':_0x2ab342,'task':_0x5ea12e,'priority':_0x393973||_0x3376ba(0x1d8),'from_session':Z});return{'content':[{'type':'text','text':JSON[_0x3376ba(0x1a4)](_0x126040)}]};}if(_0x241619==='commhub_send_message'){let {alias:_0x253970,message:_0xda7e6a}=_0x485317,_0x4c157b=await P(_0x3376ba(0x1a3),{'alias':_0x253970,'message':_0xda7e6a,'from_session':Z});return{'content':[{'type':_0x3376ba(0x15d),'text':JSON[_0x3376ba(0x1a4)](_0x4c157b)}]};}if(_0x241619==='commhub_get_all_status'){let _0x4604d6=await P('get_all_status',{});return{'content':[{'type':_0x3376ba(0x15d),'text':JSON[_0x3376ba(0x1a4)](_0x4604d6)}]};}return{'content':[{'type':_0x3376ba(0x15d),'text':JSON[_0x3376ba(0x1a4)]({'error':_0x3376ba(0x1bc)})}]};});async function v(){const _0x1bff58=a0_0x21d675;let _0x515422=D+_0x1bff58(0x161)+encodeURIComponent(Z),_0xb8ed56={};if(X)_0xb8ed56[_0x1bff58(0x158)]=_0x1bff58(0x1d4)+X;Y(_0x1bff58(0x156)+_0x515422);while(!0x0){try{let _0x3901dd=await fetch(_0x515422,{'headers':_0xb8ed56});if(!_0x3901dd['ok']){Y(_0x1bff58(0x1d5)+_0x3901dd[_0x1bff58(0x1b7)]+'\x20'+_0x3901dd[_0x1bff58(0x16c)]),await h(0x1388);continue;}let _0x559447=_0x3901dd[_0x1bff58(0x16a)]['getReader'](),_0x227180=new TextDecoder(),_0x2ed4bb='';while(!0x0){let {done:_0x4bc505,value:_0x402214}=await _0x559447[_0x1bff58(0x190)]();if(_0x4bc505)break;_0x2ed4bb+=_0x227180[_0x1bff58(0x1ac)](_0x402214,{'stream':!0x0});let _0x1ff00a=_0x2ed4bb[_0x1bff58(0x1ca)]('\x0a\x0a');_0x2ed4bb=_0x1ff00a[_0x1bff58(0x1cd)]()||'';for(let _0x17e55c of _0x1ff00a){let _0x50a05c=_0x17e55c['split']('\x0a')[_0x1bff58(0x1c0)](_0x224a21=>_0x224a21['startsWith'](_0x1bff58(0x1b8)));if(!_0x50a05c)continue;try{let _0x4c6412=JSON[_0x1bff58(0x166)](_0x50a05c[_0x1bff58(0x184)](0x6));await u(_0x4c6412);}catch(_0x45f4f7){Y('parse\x20error:\x20'+_0x45f4f7);}}}Y(_0x1bff58(0x1c8));}catch(_0x37faf9){Y(_0x1bff58(0x1aa)+_0x37faf9);}await h(0xbb8);}}async function u(_0x2cd881){const _0x280ed2=a0_0x21d675;if(_0x2cd881[_0x280ed2(0x14e)]==='connected'){Y('SSE\x20connected\x20as\x20\x22'+Z+'\x22');return;}if(_0x2cd881[_0x280ed2(0x14e)]==='new_message'){if(Y(_0x280ed2(0x181)+_0x2cd881[_0x280ed2(0x18c)]+':\x20'+_0x2cd881['message']['slice'](0x0,0x3c)),await K[_0x280ed2(0x1a8)]({'method':_0x280ed2(0x1ab),'params':{'content':_0x2cd881[_0x280ed2(0x165)],'meta':{'sender':_0x2cd881['from']||_0x280ed2(0x1b1),'sender_id':_0x280ed2(0x187),'user':_0x2cd881[_0x280ed2(0x18c)]||'hub','priority':_0x280ed2(0x1d8)}}}),_0x2cd881[_0x280ed2(0x163)])await P(_0x280ed2(0x18d),{'alias':Z,'message_id':_0x2cd881['message_id']});return;}if(_0x2cd881[_0x280ed2(0x14e)]===_0x280ed2(0x15b)||_0x2cd881[_0x280ed2(0x14e)]===_0x280ed2(0x17c)){Y('←\x20'+_0x2cd881[_0x280ed2(0x14e)]+_0x280ed2(0x16d)+_0x2cd881[_0x280ed2(0x171)]+_0x280ed2(0x1a2)+(_0x2cd881['priority']||_0x280ed2(0x1d8)));let _0x54afd7=await P(_0x280ed2(0x1be),{'alias':Z,'limit':0x5});if(_0x54afd7?.['ok']&&_0x54afd7['messages']?.[_0x280ed2(0x1c1)]>0x0)for(let _0x4090a8 of _0x54afd7[_0x280ed2(0x193)]){let _0xf7f54f={'sender':_0x4090a8[_0x280ed2(0x169)]||_0x280ed2(0x1b1),'sender_id':_0x280ed2(0x187),'user':_0x4090a8['from_session']||_0x280ed2(0x1b1),'task_id':_0x4090a8['id'],'priority':_0x4090a8[_0x280ed2(0x196)]||_0x280ed2(0x1d8)};k['set'](_0x4090a8['id'],_0x4090a8['from_session']||'hub'),await K['notification']({'method':_0x280ed2(0x1ab),'params':{'content':_0x4090a8[_0x280ed2(0x17a)],'meta':_0xf7f54f}}),Y(_0x280ed2(0x19f)+_0x4090a8['id']['slice'](0x0,0x8)+_0x280ed2(0x192)+_0x4090a8[_0x280ed2(0x169)]+':\x20'+_0x4090a8[_0x280ed2(0x17a)][_0x280ed2(0x184)](0x0,0x3c)),await P(_0x280ed2(0x18d),{'alias':Z,'message_id':_0x4090a8['id']});}}}async function S(){const _0x5b51ee=a0_0x21d675;let _0x12dd80=new a0_0x270f7d();await K[_0x5b51ee(0x14f)](_0x12dd80),Y(_0x5b51ee(0x198)),Y('starting\x20SSE\x20listener...'),v()[_0x5b51ee(0x1cf)](_0x57593d=>Y('SSE\x20fatal:\x20'+_0x57593d)),P(_0x5b51ee(0x168),{'resume_id':w,'alias':Z,'status':'idle','server':a0_0x3ccc66(),'hostname':a0_0x3ccc66(),'agent':_0x5b51ee(0x162),'project_dir':process[_0x5b51ee(0x195)](),'tmux_name':f||void 0x0})[_0x5b51ee(0x191)](()=>Y(_0x5b51ee(0x16e)+Z+_0x5b51ee(0x1b4)+w['slice'](0x0,0x8)+')'))[_0x5b51ee(0x1cf)](_0x54c1e4=>Y(_0x5b51ee(0x154)+_0x54c1e4)),setInterval(()=>{const _0x5383fe=_0x5b51ee;P(_0x5383fe(0x168),{'resume_id':w,'alias':Z,'status':_0x5383fe(0x1bd),'server':a0_0x3ccc66(),'hostname':a0_0x3ccc66(),'agent':_0x5383fe(0x162),'project_dir':process[_0x5383fe(0x195)](),'tmux_name':f||void 0x0})[_0x5383fe(0x1cf)](_0x470f3e=>Y(_0x5383fe(0x17d)+_0x470f3e));},0x2bf20),Y(_0x5b51ee(0x1b0));}S()[a0_0x21d675(0x1cf)](_0x4609be=>{const _0x59eaf8=a0_0x21d675;Y(_0x59eaf8(0x14b)+_0x4609be),process[_0x59eaf8(0x1c2)](0x1);});async function N(){const _0x3752ef=a0_0x21d675;Y(_0x3752ef(0x148)),await P(_0x3752ef(0x168),{'resume_id':w,'alias':Z,'status':_0x3752ef(0x1b6),'task':_0x3752ef(0x1cb)})[_0x3752ef(0x1cf)](()=>{}),process[_0x3752ef(0x1c2)](0x0);}process['stdin']['on']('end',()=>N()),process['on'](a0_0x21d675(0x183),()=>N()),process['on'](a0_0x21d675(0x167),()=>N());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sleep2agi/agent-network",
|
|
3
|
-
"version": "2.0.0-preview.
|
|
3
|
+
"version": "2.0.0-preview.16",
|
|
4
4
|
"description": "AI Agent Network — Server + Client + Setup in one package. SSE real-time communication for multi-agent orchestration.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/src/client.js",
|