@sleep2agi/agent-network 2.0.0-preview.15 → 2.0.0-preview.17
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
|
+
const a0_0x318584=a0_0x1896;(function(_0x3829ee,_0x9f1140){const _0x5efc87=a0_0x1896,_0x139c2c=_0x3829ee();while(!![]){try{const _0x52ba98=parseInt(_0x5efc87(0x93))/0x1*(-parseInt(_0x5efc87(0xd4))/0x2)+-parseInt(_0x5efc87(0xb8))/0x3+-parseInt(_0x5efc87(0xa0))/0x4+-parseInt(_0x5efc87(0xd3))/0x5+-parseInt(_0x5efc87(0xc9))/0x6+parseInt(_0x5efc87(0xbd))/0x7+parseInt(_0x5efc87(0x96))/0x8;if(_0x52ba98===_0x9f1140)break;else _0x139c2c['push'](_0x139c2c['shift']());}catch(_0x305a51){_0x139c2c['push'](_0x139c2c['shift']());}}}(a0_0x2bc1,0xf1598));function a0_0x1896(_0x13e788,_0x312d11){_0x13e788=_0x13e788-0x89;const _0x2bc110=a0_0x2bc1();let _0x189608=_0x2bc110[_0x13e788];return _0x189608;}function a0_0x2bc1(){const _0x386924=['text/event-stream','text','connect','parse','inbox\x20error:\x20','autoConnect','Bearer\x20','agent','new_task','1438100BphrbC','startsWith','toTimeString','running','SSE\x20error:\x20','reply','connected','catch','resumeId','emit','disconnected','registered','replace','body','get_inbox','heartbeatInterval','cwd','task','SSE\x20connected','offline','heartbeatTimer','split','slice','send_task','3182556hWrFyI','read','new_message','sdk-','tools/call','11389945jGyaVd','reconnectDelay','server','status','alias','pop','sdk','from_session','data:\x20','getReader','log','toString','653766nMHaFX','call','token','now','name','idle','SSE\x20reconnecting\x20in\x20','disconnect','/mcp','send','8212695HTvIXu','239312ECeRlD','sleep','get_all_status','result','broadcast','completed','application/json','Authorization','message','SSE\x20failed:\x20',']\x20[commhub:','/events/','processInbox','sseAbort','s...','min','url','decode','normal','content','type','2.0','5kHPrfY','abort','getAllStatus','25052720ktCXvE'];a0_0x2bc1=function(){return _0x386924;};return a0_0x2bc1();}import{EventEmitter as a0_0x12ea5b}from'events';import{hostname as a0_0x4f1ddc}from'os';class T extends a0_0x12ea5b{['url'];[a0_0x318584(0xc1)];[a0_0x318584(0xcb)];[a0_0x318584(0x9e)];['resumeId'];[a0_0x318584(0xaf)];['reconnectDelay'];[a0_0x318584(0xb4)];[a0_0x318584(0x8a)];[a0_0x318584(0xa3)]=!0x1;constructor(_0x25205e){const _0x879bfa=a0_0x318584;super();if(this['url']=_0x25205e[_0x879bfa(0x8d)][_0x879bfa(0xac)](/\/$/,''),this[_0x879bfa(0xc1)]=_0x25205e[_0x879bfa(0xc1)],this[_0x879bfa(0xcb)]=_0x25205e[_0x879bfa(0xcb)],this['agent']=_0x25205e[_0x879bfa(0x9e)]||_0x879bfa(0xc3),this['resumeId']=_0x879bfa(0xbb)+_0x25205e['alias']+'-'+Date[_0x879bfa(0xcc)]()[_0x879bfa(0xc8)](0x24),this[_0x879bfa(0xaf)]=_0x25205e[_0x879bfa(0xaf)]??0x2bf20,this[_0x879bfa(0xbe)]=_0x25205e[_0x879bfa(0xbe)]??0xbb8,_0x25205e[_0x879bfa(0x9c)]!==!0x1)this[_0x879bfa(0x99)]();}['log'](_0x53bb53){const _0x4a56f4=a0_0x318584;console['log']('['+new Date()[_0x4a56f4(0xa2)]()['slice'](0x0,0x8)+_0x4a56f4(0xde)+this[_0x4a56f4(0xc1)]+']\x20'+_0x53bb53);}async['call'](_0x39db74,_0x3ae48f){const _0x2bb2d0=a0_0x318584;let _0x4be48a={'Content-Type':_0x2bb2d0(0xda),'Accept':'application/json,\x20text/event-stream'};if(this[_0x2bb2d0(0xcb)])_0x4be48a[_0x2bb2d0(0xdb)]=_0x2bb2d0(0x9d)+this[_0x2bb2d0(0xcb)];let _0x38dfd8=await(await fetch(this[_0x2bb2d0(0x8d)]+_0x2bb2d0(0xd1),{'method':'POST','headers':_0x4be48a,'body':JSON['stringify']({'jsonrpc':_0x2bb2d0(0x92),'id':Date[_0x2bb2d0(0xcc)](),'method':_0x2bb2d0(0xbc),'params':{'name':_0x39db74,'arguments':_0x3ae48f}})}))[_0x2bb2d0(0x98)](),_0x4adc22=_0x38dfd8['match'](/data: (.+)/),_0x5ae4d0=_0x4adc22?JSON['parse'](_0x4adc22[0x1]):JSON[_0x2bb2d0(0x9a)](_0x38dfd8),_0x18d973=_0x5ae4d0?.[_0x2bb2d0(0xd7)]?.[_0x2bb2d0(0x90)]?.[0x0]?.[_0x2bb2d0(0x98)];return _0x18d973?JSON[_0x2bb2d0(0x9a)](_0x18d973):_0x5ae4d0;}async[a0_0x318584(0x99)](){const _0x3b1b82=a0_0x318584;if(this[_0x3b1b82(0xa3)])return;this[_0x3b1b82(0xa3)]=!0x0,await this[_0x3b1b82(0xc0)](_0x3b1b82(0xce)),this[_0x3b1b82(0xc7)](_0x3b1b82(0xab)),this[_0x3b1b82(0xb4)]=setInterval(()=>{const _0x1665c4=_0x3b1b82;this[_0x1665c4(0xc0)](_0x1665c4(0xce))[_0x1665c4(0xa7)](_0x2bb3a9=>this['log']('heartbeat\x20failed:\x20'+_0x2bb3a9[_0x1665c4(0xdc)]));},this[_0x3b1b82(0xaf)]),this['connectSSE']();}async[a0_0x318584(0xd0)](){const _0xc1d1ad=a0_0x318584;if(this['running']=!0x1,this[_0xc1d1ad(0x8a)]?.[_0xc1d1ad(0x94)](),this['heartbeatTimer'])clearInterval(this[_0xc1d1ad(0xb4)]);await this[_0xc1d1ad(0xc0)](_0xc1d1ad(0xb3))[_0xc1d1ad(0xa7)](()=>{}),this['log']('disconnected');}async[a0_0x318584(0xd2)](_0x149986,_0x3c16a1,_0x5eb8a5=a0_0x318584(0x8f)){const _0x44266f=a0_0x318584;return this['call'](_0x44266f(0xb7),{'alias':_0x149986,'task':_0x3c16a1,'priority':_0x5eb8a5,'from_session':this[_0x44266f(0xc1)]});}async[a0_0x318584(0xdc)](_0xb4fd42,_0x4de716){const _0x50e38b=a0_0x318584;return this[_0x50e38b(0xca)]('send_message',{'alias':_0xb4fd42,'message':_0x4de716,'from_session':this['alias']});}async[a0_0x318584(0xa5)](_0xb4c0f0,_0x4c61fa,_0x3ec983=a0_0x318584(0xd9)){const _0x4e2f4f=a0_0x318584;return this[_0x4e2f4f(0xca)]('reply',{'task_id':_0xb4c0f0,'text':_0x4c61fa,'status':_0x3ec983});}async[a0_0x318584(0xc0)](_0x8c6477,_0x555ceb){const _0x9b5d59=a0_0x318584;return this[_0x9b5d59(0xca)]('report_status',{'resume_id':this[_0x9b5d59(0xa8)],'alias':this['alias'],'status':_0x8c6477,'server':a0_0x4f1ddc(),'hostname':a0_0x4f1ddc(),'agent':this[_0x9b5d59(0x9e)],'project_dir':process[_0x9b5d59(0xb0)](),..._0x555ceb});}async[a0_0x318584(0x95)](){const _0x4140a8=a0_0x318584;return this['call'](_0x4140a8(0xd6),{});}async['broadcast'](_0x4eb291,_0x35595f){const _0x3b5b7e=a0_0x318584;return this['call'](_0x3b5b7e(0xd8),{'message':_0x4eb291,'filter_server':_0x35595f?.[_0x3b5b7e(0xbf)],'filter_status':_0x35595f?.['status']});}async['connectSSE'](){const _0x2d4ab9=a0_0x318584;let _0x452259=encodeURIComponent(this[_0x2d4ab9(0xc1)]),_0x312e26=this[_0x2d4ab9(0x8d)]+_0x2d4ab9(0xdf)+_0x452259,_0x21f0b4=this[_0x2d4ab9(0xbe)];while(this[_0x2d4ab9(0xa3)]){try{this[_0x2d4ab9(0x8a)]=new AbortController();let _0x594191={'Accept':_0x2d4ab9(0x97)};if(this[_0x2d4ab9(0xcb)])_0x594191[_0x2d4ab9(0xdb)]=_0x2d4ab9(0x9d)+this[_0x2d4ab9(0xcb)];let _0x35fe4b=await fetch(_0x312e26,{'headers':_0x594191,'signal':this['sseAbort']['signal']});if(!_0x35fe4b['ok']||!_0x35fe4b['body']){this[_0x2d4ab9(0xc7)](_0x2d4ab9(0xdd)+_0x35fe4b['status']),await this[_0x2d4ab9(0xd5)](_0x21f0b4),_0x21f0b4=Math['min'](_0x21f0b4*1.5,0xea60);continue;}_0x21f0b4=this[_0x2d4ab9(0xbe)];let _0x20ce8c=_0x35fe4b[_0x2d4ab9(0xad)][_0x2d4ab9(0xc6)](),_0x3b63f9=new TextDecoder(),_0x29758c='';while(this[_0x2d4ab9(0xa3)]){let {done:_0x28370b,value:_0x2df8a2}=await _0x20ce8c[_0x2d4ab9(0xb9)]();if(_0x28370b)break;_0x29758c+=_0x3b63f9[_0x2d4ab9(0x8e)](_0x2df8a2,{'stream':!0x0});let _0x53e4a4=_0x29758c[_0x2d4ab9(0xb5)]('\x0a');_0x29758c=_0x53e4a4[_0x2d4ab9(0xc2)]()||'';for(let _0x20960e of _0x53e4a4){if(!_0x20960e[_0x2d4ab9(0xa1)](_0x2d4ab9(0xc5)))continue;try{let _0x26be07=JSON['parse'](_0x20960e[_0x2d4ab9(0xb6)](0x6));if(_0x26be07[_0x2d4ab9(0x91)]==='connected'){this[_0x2d4ab9(0xc7)](_0x2d4ab9(0xb2)),this[_0x2d4ab9(0xa9)](_0x2d4ab9(0xa6));continue;}if(_0x26be07['type']===_0x2d4ab9(0x9f)||_0x26be07[_0x2d4ab9(0x91)]===_0x2d4ab9(0xba)||_0x26be07[_0x2d4ab9(0x91)]==='broadcast')await this[_0x2d4ab9(0x89)]();}catch{}}}}catch(_0x70749e){if(_0x70749e[_0x2d4ab9(0xcd)]==='AbortError')break;this['emit']('error',_0x70749e),this['log'](_0x2d4ab9(0xa4)+_0x70749e[_0x2d4ab9(0xdc)]);}if(this['running'])this['emit'](_0x2d4ab9(0xaa)),this[_0x2d4ab9(0xc7)](_0x2d4ab9(0xcf)+_0x21f0b4/0x3e8+_0x2d4ab9(0x8b)),await this[_0x2d4ab9(0xd5)](_0x21f0b4),_0x21f0b4=Math[_0x2d4ab9(0x8c)](_0x21f0b4*1.5,0xea60);}}async[a0_0x318584(0x89)](){const _0x5b98f8=a0_0x318584;try{let _0xaffe26=(await this[_0x5b98f8(0xca)](_0x5b98f8(0xae),{'alias':this[_0x5b98f8(0xc1)],'limit':0xa}))?.['messages']||[];for(let _0x3ab57f of _0xaffe26)await this['call']('ack_inbox',{'alias':this[_0x5b98f8(0xc1)],'message_id':_0x3ab57f['id']}),this[_0x5b98f8(0xc7)]('←\x20'+_0x3ab57f[_0x5b98f8(0xc4)]+':\x20'+_0x3ab57f[_0x5b98f8(0x90)]['slice'](0x0,0x3c)),this['emit'](_0x5b98f8(0xb1),_0x3ab57f),this[_0x5b98f8(0xa9)](_0x5b98f8(0xdc),_0x3ab57f);}catch(_0x566267){this[_0x5b98f8(0xc7)](_0x5b98f8(0x9b)+_0x566267[_0x5b98f8(0xdc)]);}}[a0_0x318584(0xd5)](_0xf4e1bf){return new Promise(_0x131889=>setTimeout(_0x131889,_0xf4e1bf));}}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_0x3f9457=a0_0x2e54;(function(_0x27b174,_0x472186){const _0x4ec7d3=a0_0x2e54,_0x5648bf=_0x27b174();while(!![]){try{const _0x10bf98=-parseInt(_0x4ec7d3(0x19d))/0x1*(-parseInt(_0x4ec7d3(0x18d))/0x2)+parseInt(_0x4ec7d3(0x1dc))/0x3+-parseInt(_0x4ec7d3(0x199))/0x4*(parseInt(_0x4ec7d3(0x1df))/0x5)+parseInt(_0x4ec7d3(0x1a3))/0x6+parseInt(_0x4ec7d3(0x1d6))/0x7+-parseInt(_0x4ec7d3(0x19f))/0x8*(-parseInt(_0x4ec7d3(0x1aa))/0x9)+-parseInt(_0x4ec7d3(0x1a7))/0xa*(parseInt(_0x4ec7d3(0x1bc))/0xb);if(_0x10bf98===_0x472186)break;else _0x5648bf['push'](_0x5648bf['shift']());}catch(_0x39b0f1){_0x5648bf['push'](_0x5648bf['shift']());}}}(a0_0x567c,0x3a5b0));import{readFileSync as a0_0x3c8986,existsSync as a0_0x3720a2}from'fs';import{join as a0_0x1bab10}from'path';import{hostname as a0_0x18189b}from'os';import{execSync as a0_0x487488}from'child_process';import{Server as a0_0x2cf970}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport as a0_0x413c4a}from'@modelcontextprotocol/sdk/server/stdio.js';import{ListToolsRequestSchema as a0_0x148448,CallToolRequestSchema as a0_0x464ebb}from'@modelcontextprotocol/sdk/types.js';function p(_0x411e62){const _0x33fd50=a0_0x2e54;if(!a0_0x3720a2(_0x411e62))return;for(let _0x2d4aa1 of a0_0x3c8986(_0x411e62,_0x33fd50(0x1de))['split']('\x0a')){let _0x37deb6=_0x2d4aa1[_0x33fd50(0x1cf)]();if(!_0x37deb6||_0x37deb6[_0x33fd50(0x1f3)]('#'))continue;let _0x21ec9b=_0x37deb6[_0x33fd50(0x1f8)]('=');if(_0x21ec9b<0x0)continue;let _0x3d79c3=_0x37deb6[_0x33fd50(0x194)](0x0,_0x21ec9b)[_0x33fd50(0x1cf)](),_0xd5e3eb=_0x37deb6[_0x33fd50(0x194)](_0x21ec9b+0x1)[_0x33fd50(0x1cf)]()['replace'](/^["']|["']$/g,'');if(!process.env[_0x3d79c3])process.env[_0x3d79c3]=_0xd5e3eb;}}var C=process.env.HOME||'~',T=a0_0x1bab10(C,'.claude/channels/commhub');p(a0_0x1bab10(T,'.env'));var L=process[a0_0x3f9457(0x19a)]()[a0_0x3f9457(0x1c9)](/\//g,'-');p(a0_0x1bab10(T,L,'.env'));function U(){const _0x5c4306=a0_0x3f9457;try{return a0_0x487488(_0x5c4306(0x1d8),{'encoding':_0x5c4306(0x1de),'timeout':0x7d0})[_0x5c4306(0x1cf)]();}catch{return'';}}function c(){const _0x42d670=a0_0x3f9457;try{let _0xf86164=a0_0x1bab10(C,_0x42d670(0x1a6),_0x42d670(0x1fc));if(a0_0x3720a2(_0xf86164))return JSON[_0x42d670(0x196)](a0_0x3c8986(_0xf86164,_0x42d670(0x1de)));}catch{}return{};}var H=c(),D=process.env.COMMHUB_URL||H[a0_0x3f9457(0x1c8)]||a0_0x3f9457(0x192),f=process.env.COMMHUB_TMUX||U(),Z=process.env.COMMHUB_ALIAS||f||a0_0x18189b(),w=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||crypto[a0_0x3f9457(0x20d)](),X=process.env.COMMHUB_TOKEN||H[a0_0x3f9457(0x1a2)]||'';function Y(_0x264a6b){const _0x1d9626=a0_0x3f9457;let _0x2ed097=new Date()[_0x1d9626(0x1c3)]()[_0x1d9626(0x194)](0x0,0x8);process[_0x1d9626(0x1b1)][_0x1d9626(0x1dd)]('['+_0x2ed097+_0x1d9626(0x1b2)+_0x264a6b+'\x0a');}function h(_0x3e4d21){return new Promise(_0x2934bd=>setTimeout(_0x2934bd,_0x3e4d21));}Y('ENV:\x20URL='+D+'\x20ALIAS='+Z+'\x20RESUME_ID='+w[a0_0x3f9457(0x194)](0x0,0x8)+a0_0x3f9457(0x193)+(f||'none')+a0_0x3f9457(0x1f9)+process[a0_0x3f9457(0x19a)]()+a0_0x3f9457(0x1c0)+L);var k=new Map(),K=new a0_0x2cf970({'name':a0_0x3f9457(0x191),'version':a0_0x3f9457(0x1c1)},{'capabilities':{'experimental':{'claude/channel':{}},'tools':{}},'instructions':[a0_0x3f9457(0x1ec),a0_0x3f9457(0x1a1),a0_0x3f9457(0x210),'You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.',a0_0x3f9457(0x1f7)+Z][a0_0x3f9457(0x188)]('\x0a')});K[a0_0x3f9457(0x1bb)](a0_0x148448,async()=>({'tools':[{'name':a0_0x3f9457(0x1a0),'description':'Reply\x20to\x20a\x20CommHub\x20task\x20—\x20report\x20completion\x20or\x20send\x20a\x20message\x20back\x20to\x20the\x20hub.','inputSchema':{'type':a0_0x3f9457(0x1c4),'properties':{'task_id':{'type':a0_0x3f9457(0x20f),'description':'The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)'},'text':{'type':a0_0x3f9457(0x20f),'description':a0_0x3f9457(0x19c)},'status':{'type':'string','enum':[a0_0x3f9457(0x1e7),'failed',a0_0x3f9457(0x205),a0_0x3f9457(0x1d3),a0_0x3f9457(0x1ff),'in_progress'],'description':a0_0x3f9457(0x18c)}},'required':[a0_0x3f9457(0x1d2)]}},{'name':'commhub_report_status','description':a0_0x3f9457(0x1a9),'inputSchema':{'type':'object','properties':{'status':{'type':a0_0x3f9457(0x20f),'enum':[a0_0x3f9457(0x1ca),a0_0x3f9457(0x201),a0_0x3f9457(0x1d3),a0_0x3f9457(0x1ff)]},'task':{'type':a0_0x3f9457(0x20f),'description':'Current\x20task\x20description'},'progress':{'type':'number','description':'Progress\x200-100'}},'required':[a0_0x3f9457(0x1ba)]}},{'name':a0_0x3f9457(0x211),'description':a0_0x3f9457(0x19e),'inputSchema':{'type':a0_0x3f9457(0x1c4),'properties':{'alias':{'type':a0_0x3f9457(0x20f),'description':a0_0x3f9457(0x1af)},'task':{'type':a0_0x3f9457(0x20f),'description':a0_0x3f9457(0x18e)},'priority':{'type':a0_0x3f9457(0x20f),'enum':['high','normal','low'],'description':a0_0x3f9457(0x1e0)}},'required':[a0_0x3f9457(0x1e8),a0_0x3f9457(0x1ab)]}},{'name':a0_0x3f9457(0x1db),'description':'Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.','inputSchema':{'type':a0_0x3f9457(0x1c4),'properties':{'alias':{'type':'string','description':a0_0x3f9457(0x1af)},'message':{'type':a0_0x3f9457(0x20f),'description':a0_0x3f9457(0x1f5)}},'required':[a0_0x3f9457(0x1e8),a0_0x3f9457(0x1f2)]}},{'name':a0_0x3f9457(0x1ea),'description':a0_0x3f9457(0x1fd),'inputSchema':{'type':a0_0x3f9457(0x1c4),'properties':{}}}]}));function a0_0x567c(){const _0xa55d0e=['4220OZZSkS','send_message','Update\x20this\x20session\x27s\x20status\x20in\x20CommHub\x20(working/idle/blocked/error).\x20Returns\x20inbox_count.','20151oHPOSg','task','content','heartbeat\x20failed:\x20',':\x20inbox_count=','Target\x20session\x20alias','report_status','stderr',']\x20[commhub]\x20','ready\x20—\x20waiting\x20for\x20events','unknown\x20tool','send_reply','registered\x20as\x20\x22','normal','CommHub\x20init\x20failed:\x20','then','status','setRequestHandler','12001FcDDZo','init\x20failed:\x20','read','getReader','\x20PROJECT_ENV=','0.3.0','notification','toTimeString','object','get_all_status','send_task','application/json,\x20text/event-stream','hub','replace','working','get','fatal:\x20','find','connecting\x20to\x20','trim','2025-03-26','Bearer\x20','text','blocked','length','exit','1240911CmyPiK','stdin','tmux\x20display-message\x20-p\x20\x27#S\x27','type','SSE\x20fatal:\x20','commhub_send_message','453573KcJsXJ','write','utf-8','35WBDUvL','Priority\x20(default:\x20normal)','\x20from\x20','end','from','new_task','tools/call','commhub','completed','alias','warning:\x20could\x20not\x20register:\x20','commhub_get_all_status','priority','Messages\x20from\x20CommHub\x20arrive\x20as\x20<channel\x20source=\x22commhub\x22\x20task_id=\x22...\x22\x20priority=\x22...\x22\x20from=\x22...\x22>','catch','messages','ack_inbox','claude-code','statusText','message','startsWith','\x20priority=','Message\x20content','commhub_report_status','Session\x20alias:\x20','indexOf','\x20CWD=','SIGTERM','POST','config.json','Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','from_session','error','replied','idle','notifications/claude/channel','pop','initialize','cancelled','body','message_id','data:\x20','stringify','SSE\x20connected\x20as\x20\x22','SSE\x20error:\x20','→\x20injected\x20task\x20','randomUUID','split','string','Reply\x20using\x20the\x20commhub_reply\x20tool\x20to\x20report\x20status\x20or\x20results\x20back.','commhub_send_task','2.0','set','join','inbox_count','application/json','get_inbox','Task\x20outcome:\x20completed/failed/cancelled\x20for\x20final\x20results,\x20blocked/error/in_progress\x20for\x20status\x20updates','2duYyWw','Task\x20content','SSE\x20connection\x20error:\x20','result','commhub-channel','http://127.0.0.1:9200','...\x20TMUX=','slice','←\x20message\x20from\x20','parse','SIGINT','\x22\x20(','83728IQOJSx','cwd','Authorization','Reply\x20text\x20/\x20result\x20summary','105454lZVNqi','Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.','1352zkxtMH','commhub_reply','These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.','token','201846dMyBOb','/mcp','starting\x20SSE\x20listener...','.anet'];a0_0x567c=function(){return _0xa55d0e;};return a0_0x567c();}async function P(_0x586232,_0x3be638){const _0x3c247b=a0_0x3f9457;let _0x519abf=await fetch(D+_0x3c247b(0x1a4),{'method':'POST','headers':{'Content-Type':_0x3c247b(0x18a),'Accept':_0x3c247b(0x1c7),...X?{'Authorization':_0x3c247b(0x1d1)+X}:{}},'body':JSON['stringify']({'jsonrpc':_0x3c247b(0x186),'id':0x1,'method':_0x3c247b(0x204),'params':{'protocolVersion':_0x3c247b(0x1d0),'capabilities':{},'clientInfo':{'name':_0x3c247b(0x191),'version':_0x3c247b(0x1c1)}}})});if(!_0x519abf['ok']){let _0x5423e5=await _0x519abf['text']();return Y(_0x3c247b(0x1b8)+_0x519abf[_0x3c247b(0x1ba)]+'\x20'+_0x5423e5[_0x3c247b(0x194)](0x0,0x64)),{'ok':!0x1,'error':_0x3c247b(0x1bd)+_0x519abf[_0x3c247b(0x1ba)]};}await _0x519abf[_0x3c247b(0x1d2)]();let _0x3394d0=(await(await fetch(D+_0x3c247b(0x1a4),{'method':_0x3c247b(0x1fb),'headers':{'Content-Type':'application/json','Accept':_0x3c247b(0x1c7),...X?{'Authorization':_0x3c247b(0x1d1)+X}:{}},'body':JSON['stringify']({'jsonrpc':_0x3c247b(0x186),'id':0x2,'method':_0x3c247b(0x1e5),'params':{'name':_0x586232,'arguments':_0x3be638}})}))['text']())[_0x3c247b(0x20e)]('\x0a')[_0x3c247b(0x1cd)](_0x52787f=>_0x52787f[_0x3c247b(0x1f3)](_0x3c247b(0x208)));if(_0x3394d0){let _0x209654=JSON['parse'](_0x3394d0[_0x3c247b(0x194)](0x6));return _0x209654?.['result']?.[_0x3c247b(0x1ac)]?.[0x0]?.[_0x3c247b(0x1d2)]?JSON[_0x3c247b(0x196)](_0x209654[_0x3c247b(0x190)]['content'][0x0]['text']):_0x209654;}return{'ok':!0x1,'error':'no\x20response'};}K[a0_0x3f9457(0x1bb)](a0_0x464ebb,async _0x498375=>{const _0x12551c=a0_0x3f9457;let {name:_0xa9a72b,arguments:_0x1f549c}=_0x498375['params'];if(_0xa9a72b===_0x12551c(0x1a0)){let {task_id:_0x3746db,text:_0x241a43,status:_0x204f48}=_0x1f549c;if(_0x204f48===_0x12551c(0x1e7)||_0x204f48==='failed'||_0x204f48===_0x12551c(0x205)){let _0x1a0607=_0x204f48===_0x12551c(0x1e7)?_0x12551c(0x200):_0x204f48,_0x2002a4=_0x3746db?k[_0x12551c(0x1cb)](_0x3746db)||_0x12551c(0x1c8):_0x12551c(0x1c8),_0x5badad=await P(_0x12551c(0x1b5),{'alias':_0x2002a4,'text':_0x241a43,'in_reply_to':_0x3746db||void 0x0,'status':_0x1a0607,'from_session':Z});if(_0x3746db)k['delete'](_0x3746db);return{'content':[{'type':'text','text':JSON[_0x12551c(0x209)](_0x5badad)}]};}let _0x1ff913=await P('report_status',{'resume_id':w,'alias':Z,'status':_0x204f48==='blocked'?'blocked':_0x204f48===_0x12551c(0x1ff)?'error':_0x12551c(0x1ca),'task':_0x241a43['slice'](0x0,0xc8),'output':_0x241a43});return{'content':[{'type':_0x12551c(0x1d2),'text':JSON[_0x12551c(0x209)](_0x1ff913)}]};}if(_0xa9a72b===_0x12551c(0x1f6)){let {status:_0xd9eb04,task:_0x394a6f,progress:_0xd72ac0}=_0x1f549c,_0x537bf9=await P(_0x12551c(0x1b0),{'resume_id':w,'alias':Z,'status':_0xd9eb04,'task':_0x394a6f,'progress':_0xd72ac0});return{'content':[{'type':_0x12551c(0x1d2),'text':JSON[_0x12551c(0x209)](_0x537bf9)}]};}if(_0xa9a72b===_0x12551c(0x211)){let {alias:_0x5aedd1,task:_0x370ae3,priority:_0x432009}=_0x1f549c,_0x29f3bb=await P(_0x12551c(0x1c6),{'alias':_0x5aedd1,'task':_0x370ae3,'priority':_0x432009||_0x12551c(0x1b7),'from_session':Z});return{'content':[{'type':_0x12551c(0x1d2),'text':JSON[_0x12551c(0x209)](_0x29f3bb)}]};}if(_0xa9a72b===_0x12551c(0x1db)){let {alias:_0x4862cc,message:_0x1d0ae8}=_0x1f549c,_0x12d196=await P(_0x12551c(0x1a8),{'alias':_0x4862cc,'message':_0x1d0ae8,'from_session':Z});return{'content':[{'type':'text','text':JSON[_0x12551c(0x209)](_0x12d196)}]};}if(_0xa9a72b===_0x12551c(0x1ea)){let _0x48f9fb=await P(_0x12551c(0x1c5),{});return{'content':[{'type':_0x12551c(0x1d2),'text':JSON[_0x12551c(0x209)](_0x48f9fb)}]};}return{'content':[{'type':_0x12551c(0x1d2),'text':JSON[_0x12551c(0x209)]({'error':_0x12551c(0x1b4)})}]};});async function v(){const _0x1eb3ac=a0_0x3f9457;let _0x6cf983=D+'/events/'+encodeURIComponent(Z),_0x39de25={};if(X)_0x39de25[_0x1eb3ac(0x19b)]=_0x1eb3ac(0x1d1)+X;Y(_0x1eb3ac(0x1ce)+_0x6cf983);while(!0x0){try{let _0x37a79d=await fetch(_0x6cf983,{'headers':_0x39de25});if(!_0x37a79d['ok']){Y(_0x1eb3ac(0x20b)+_0x37a79d['status']+'\x20'+_0x37a79d[_0x1eb3ac(0x1f1)]),await h(0x1388);continue;}let _0x165474=_0x37a79d[_0x1eb3ac(0x206)][_0x1eb3ac(0x1bf)](),_0x11e10c=new TextDecoder(),_0x55f1b7='';while(!0x0){let {done:_0x3b13e6,value:_0x1ca109}=await _0x165474[_0x1eb3ac(0x1be)]();if(_0x3b13e6)break;_0x55f1b7+=_0x11e10c['decode'](_0x1ca109,{'stream':!0x0});let _0x500d6f=_0x55f1b7[_0x1eb3ac(0x20e)]('\x0a\x0a');_0x55f1b7=_0x500d6f[_0x1eb3ac(0x203)]()||'';for(let _0x11b77a of _0x500d6f){let _0x3995a9=_0x11b77a['split']('\x0a')[_0x1eb3ac(0x1cd)](_0x1e1ddc=>_0x1e1ddc[_0x1eb3ac(0x1f3)](_0x1eb3ac(0x208)));if(!_0x3995a9)continue;try{let _0x3dc0bb=JSON[_0x1eb3ac(0x196)](_0x3995a9[_0x1eb3ac(0x194)](0x6));await u(_0x3dc0bb);}catch(_0x170001){Y('parse\x20error:\x20'+_0x170001);}}}Y('SSE\x20stream\x20ended,\x20reconnecting...');}catch(_0x48391a){Y(_0x1eb3ac(0x18f)+_0x48391a);}await h(0xbb8);}}async function u(_0x114523){const _0x2526e8=a0_0x3f9457;if(_0x114523[_0x2526e8(0x1d9)]==='connected'){Y(_0x2526e8(0x20a)+Z+'\x22');return;}if(_0x114523[_0x2526e8(0x1d9)]==='new_message'){if(Y(_0x2526e8(0x195)+_0x114523[_0x2526e8(0x1e3)]+':\x20'+_0x114523['message']['slice'](0x0,0x3c)),await K[_0x2526e8(0x1c2)]({'method':'notifications/claude/channel','params':{'content':_0x114523['message'],'meta':{'sender':_0x114523[_0x2526e8(0x1e3)]||'hub','sender_id':'commhub','user':_0x114523[_0x2526e8(0x1e3)]||_0x2526e8(0x1c8),'priority':_0x2526e8(0x1b7)}}}),_0x114523['message_id'])await P(_0x2526e8(0x1ef),{'alias':Z,'message_id':_0x114523[_0x2526e8(0x207)]});return;}if(_0x114523[_0x2526e8(0x1d9)]===_0x2526e8(0x1e4)||_0x114523['type']==='broadcast'){Y('←\x20'+_0x114523['type']+_0x2526e8(0x1ae)+_0x114523[_0x2526e8(0x189)]+_0x2526e8(0x1f4)+(_0x114523[_0x2526e8(0x1eb)]||_0x2526e8(0x1b7)));let _0x3ea452=await P(_0x2526e8(0x18b),{'alias':Z,'limit':0x5});if(_0x3ea452?.['ok']&&_0x3ea452[_0x2526e8(0x1ee)]?.[_0x2526e8(0x1d4)]>0x0)for(let _0x2a01fe of _0x3ea452['messages']){let _0x1d8775={'sender':_0x2a01fe[_0x2526e8(0x1fe)]||'hub','sender_id':_0x2526e8(0x1e6),'user':_0x2a01fe[_0x2526e8(0x1fe)]||_0x2526e8(0x1c8),'task_id':_0x2a01fe['id'],'priority':_0x2a01fe[_0x2526e8(0x1eb)]||_0x2526e8(0x1b7)};k[_0x2526e8(0x187)](_0x2a01fe['id'],_0x2a01fe[_0x2526e8(0x1fe)]||_0x2526e8(0x1c8)),await K[_0x2526e8(0x1c2)]({'method':_0x2526e8(0x202),'params':{'content':_0x2a01fe[_0x2526e8(0x1ac)],'meta':_0x1d8775}}),Y(_0x2526e8(0x20c)+_0x2a01fe['id'][_0x2526e8(0x194)](0x0,0x8)+_0x2526e8(0x1e1)+_0x2a01fe[_0x2526e8(0x1fe)]+':\x20'+_0x2a01fe[_0x2526e8(0x1ac)][_0x2526e8(0x194)](0x0,0x3c)),await P('ack_inbox',{'alias':Z,'message_id':_0x2a01fe['id']});}}}function a0_0x2e54(_0x2ba69e,_0x42d34f){_0x2ba69e=_0x2ba69e-0x186;const _0x567c50=a0_0x567c();let _0x2e54b9=_0x567c50[_0x2ba69e];return _0x2e54b9;}async function S(){const _0x3104b1=a0_0x3f9457;let _0x4844c0=new a0_0x413c4a();await K['connect'](_0x4844c0),Y('MCP\x20stdio\x20connected'),Y(_0x3104b1(0x1a5)),v()[_0x3104b1(0x1ed)](_0x32c776=>Y(_0x3104b1(0x1da)+_0x32c776)),P(_0x3104b1(0x1b0),{'resume_id':w,'alias':Z,'status':_0x3104b1(0x201),'server':a0_0x18189b(),'hostname':a0_0x18189b(),'agent':_0x3104b1(0x1f0),'project_dir':process[_0x3104b1(0x19a)](),'tmux_name':f||void 0x0})[_0x3104b1(0x1b9)](()=>Y(_0x3104b1(0x1b6)+Z+_0x3104b1(0x198)+w[_0x3104b1(0x194)](0x0,0x8)+')'))['catch'](_0x399822=>Y(_0x3104b1(0x1e9)+_0x399822)),setInterval(()=>{const _0x5185e4=_0x3104b1;P(_0x5185e4(0x1b0),{'resume_id':w,'alias':Z,'status':_0x5185e4(0x201),'server':a0_0x18189b(),'hostname':a0_0x18189b(),'agent':_0x5185e4(0x1f0),'project_dir':process['cwd'](),'tmux_name':f||void 0x0})['catch'](_0x3f8a6d=>Y(_0x5185e4(0x1ad)+_0x3f8a6d));},0x2bf20),Y(_0x3104b1(0x1b3));}S()[a0_0x3f9457(0x1ed)](_0x5381bc=>{const _0xe3a58d=a0_0x3f9457;Y(_0xe3a58d(0x1cc)+_0x5381bc),process[_0xe3a58d(0x1d5)](0x1);});async function N(){const _0x4e50f5=a0_0x3f9457;Y('shutting\x20down,\x20reporting\x20offline...'),await P('report_status',{'resume_id':w,'alias':Z,'status':'error','task':'session\x20disconnected'})['catch'](()=>{}),process[_0x4e50f5(0x1d5)](0x0);}process[a0_0x3f9457(0x1d7)]['on'](a0_0x3f9457(0x1e2),()=>N()),process['on'](a0_0x3f9457(0x1fa),()=>N()),process['on'](a0_0x3f9457(0x197),()=>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.17",
|
|
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",
|