@sleep2agi/agent-network 2.1.1 → 2.1.3-preview.0
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.d.ts +12 -0
- package/dist/bin/cli.js +1 -1
- package/dist/src/client.d.ts +78 -0
- package/dist/src/client.js +1 -1
- package/dist/src/node-server.d.ts +14 -0
- package/dist/src/node-server.js +1 -1
- package/package.json +3 -4
|
@@ -0,0 +1,78 @@
|
|
|
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;
|
package/dist/src/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function a0_0x30f6(){const _0x4cd47e=['min','heartbeatInterval','messages','SSE\x20failed:\x20',']\x20[commhub:','sdk','3181JSpPFN','disconnected','status','error','24944bRWGGK','connectSSE','2093436AUGuna','abort','result','heartbeat\x20failed:\x20','POST','new_task','text/event-stream','name','stringify','sleep','reply','call','application/json,\x20text/event-stream','split','2.0','parse','resumeId','replace','AbortError','agent','SSE\x20connected','idle','connected','33EkeYDc','match','5898WGcRwp','5522481WGQFtr','get_all_status','getReader','connect','send','log','autoConnect','slice','cwd','614ALyNRA','read','application/json','broadcast','processInbox','get_inbox','toString','Authorization','reconnectDelay','offline','4088CNsvTi','sdk-','getAllStatus','8ohZJvS','alias','send_message','task','text','heartbeatTimer','disconnect','Bearer\x20','url','report_status','pop','SSE\x20reconnecting\x20in\x20','token','running','219200XWcOCz','content','decode','body','catch','signal','9739320WvIakJ','startsWith','955BbNxNc','normal','emit','type','sseAbort','message'];a0_0x30f6=function(){return _0x4cd47e;};return a0_0x30f6();}const a0_0x4163cf=a0_0x2a5c;function a0_0x2a5c(_0x3f729c,_0x351c37){_0x3f729c=_0x3f729c-0x1a2;const _0x30f609=a0_0x30f6();let _0x2a5cdd=_0x30f609[_0x3f729c];return _0x2a5cdd;}(function(_0x553891,_0x4c3a42){const _0x189280=a0_0x2a5c,_0x355b7e=_0x553891();while(!![]){try{const _0x3cfc42=parseInt(_0x189280(0x1c5))/0x1*(-parseInt(_0x189280(0x1ee))/0x2)+-parseInt(_0x189280(0x1cb))/0x3+parseInt(_0x189280(0x1c9))/0x4*(parseInt(_0x189280(0x1b9))/0x5)+parseInt(_0x189280(0x1e4))/0x6*(-parseInt(_0x189280(0x1f8))/0x7)+-parseInt(_0x189280(0x1a3))/0x8*(parseInt(_0x189280(0x1e5))/0x9)+parseInt(_0x189280(0x1b1))/0xa+-parseInt(_0x189280(0x1e2))/0xb*(-parseInt(_0x189280(0x1b7))/0xc);if(_0x3cfc42===_0x4c3a42)break;else _0x355b7e['push'](_0x355b7e['shift']());}catch(_0x26ff9c){_0x355b7e['push'](_0x355b7e['shift']());}}}(a0_0x30f6,0xbfd66));import{EventEmitter as a0_0x36537b}from'events';import{hostname as a0_0x521de1}from'os';class T extends a0_0x36537b{[a0_0x4163cf(0x1ab)];[a0_0x4163cf(0x1a4)];[a0_0x4163cf(0x1af)];[a0_0x4163cf(0x1de)];[a0_0x4163cf(0x1db)];[a0_0x4163cf(0x1c0)];['reconnectDelay'];[a0_0x4163cf(0x1a8)];[a0_0x4163cf(0x1bd)];[a0_0x4163cf(0x1b0)]=!0x1;constructor(_0x23d577){const _0x43b7fd=a0_0x4163cf;super();if(this[_0x43b7fd(0x1ab)]=_0x23d577[_0x43b7fd(0x1ab)][_0x43b7fd(0x1dc)](/\/$/,''),this[_0x43b7fd(0x1a4)]=_0x23d577[_0x43b7fd(0x1a4)],this[_0x43b7fd(0x1af)]=_0x23d577[_0x43b7fd(0x1af)],this[_0x43b7fd(0x1de)]=_0x23d577[_0x43b7fd(0x1de)]||_0x43b7fd(0x1c4),this['resumeId']=_0x43b7fd(0x1f9)+_0x23d577[_0x43b7fd(0x1a4)]+'-'+Date['now']()[_0x43b7fd(0x1f4)](0x24),this['heartbeatInterval']=_0x23d577[_0x43b7fd(0x1c0)]??0x2bf20,this['reconnectDelay']=_0x23d577[_0x43b7fd(0x1f6)]??0xbb8,_0x23d577[_0x43b7fd(0x1eb)]!==!0x1)this[_0x43b7fd(0x1e8)]();}[a0_0x4163cf(0x1ea)](_0x3e0629){const _0x24380e=a0_0x4163cf;console[_0x24380e(0x1ea)]('['+new Date()['toTimeString']()[_0x24380e(0x1ec)](0x0,0x8)+_0x24380e(0x1c3)+this[_0x24380e(0x1a4)]+']\x20'+_0x3e0629);}async['call'](_0x1b5185,_0x70052e){const _0x38de33=a0_0x4163cf;let _0x5dc29f={'Content-Type':_0x38de33(0x1f0),'Accept':_0x38de33(0x1d7)};if(this['token'])_0x5dc29f['Authorization']=_0x38de33(0x1aa)+this[_0x38de33(0x1af)];let _0x2a3ded=await(await fetch(this['url']+'/mcp',{'method':_0x38de33(0x1cf),'headers':_0x5dc29f,'body':JSON[_0x38de33(0x1d3)]({'jsonrpc':_0x38de33(0x1d9),'id':Date['now'](),'method':'tools/call','params':{'name':_0x1b5185,'arguments':_0x70052e}})}))[_0x38de33(0x1a7)](),_0x5a98cd=_0x2a3ded[_0x38de33(0x1e3)](/data: (.+)/),_0x338d78=_0x5a98cd?JSON[_0x38de33(0x1da)](_0x5a98cd[0x1]):JSON[_0x38de33(0x1da)](_0x2a3ded),_0x556671=_0x338d78?.[_0x38de33(0x1cd)]?.[_0x38de33(0x1b2)]?.[0x0]?.[_0x38de33(0x1a7)];return _0x556671?JSON[_0x38de33(0x1da)](_0x556671):_0x338d78;}async[a0_0x4163cf(0x1e8)](){const _0x13f1eb=a0_0x4163cf;if(this[_0x13f1eb(0x1b0)])return;this[_0x13f1eb(0x1b0)]=!0x0,await this['status'](_0x13f1eb(0x1e0)),this[_0x13f1eb(0x1ea)]('registered'),this[_0x13f1eb(0x1a8)]=setInterval(()=>{const _0x18acf2=_0x13f1eb;this[_0x18acf2(0x1c7)](_0x18acf2(0x1e0))['catch'](_0x17e3d0=>this[_0x18acf2(0x1ea)](_0x18acf2(0x1ce)+_0x17e3d0[_0x18acf2(0x1be)]));},this['heartbeatInterval']),this['connectSSE']();}async[a0_0x4163cf(0x1a9)](){const _0x29507f=a0_0x4163cf;if(this[_0x29507f(0x1b0)]=!0x1,this['sseAbort']?.[_0x29507f(0x1cc)](),this[_0x29507f(0x1a8)])clearInterval(this[_0x29507f(0x1a8)]);await this[_0x29507f(0x1c7)](_0x29507f(0x1f7))[_0x29507f(0x1b5)](()=>{}),this[_0x29507f(0x1ea)](_0x29507f(0x1c6));}async[a0_0x4163cf(0x1e9)](_0xf962ba,_0x514f41,_0x195260=a0_0x4163cf(0x1ba)){return this['call']('send_task',{'alias':_0xf962ba,'task':_0x514f41,'priority':_0x195260,'from_session':this['alias']});}async[a0_0x4163cf(0x1be)](_0x344924,_0x475ec4){const _0x31b885=a0_0x4163cf;return this[_0x31b885(0x1d6)](_0x31b885(0x1a5),{'alias':_0x344924,'message':_0x475ec4,'from_session':this[_0x31b885(0x1a4)]});}async[a0_0x4163cf(0x1d5)](_0x2b74e0,_0x16986b,_0x8955b2='completed'){const _0x2a1223=a0_0x4163cf;return this[_0x2a1223(0x1d6)]('send_reply',{'in_reply_to':_0x2b74e0,'text':_0x16986b,'status':_0x8955b2});}async[a0_0x4163cf(0x1c7)](_0x124e5f,_0x1725e7){const _0xab5a3f=a0_0x4163cf;return this[_0xab5a3f(0x1d6)](_0xab5a3f(0x1ac),{'resume_id':this[_0xab5a3f(0x1db)],'alias':this[_0xab5a3f(0x1a4)],'status':_0x124e5f,'server':a0_0x521de1(),'hostname':a0_0x521de1(),'agent':this[_0xab5a3f(0x1de)],'project_dir':process[_0xab5a3f(0x1ed)](),..._0x1725e7});}async[a0_0x4163cf(0x1a2)](){const _0x4ce709=a0_0x4163cf;return this[_0x4ce709(0x1d6)](_0x4ce709(0x1e6),{});}async[a0_0x4163cf(0x1f1)](_0x523943,_0x3a8964){const _0x352016=a0_0x4163cf;return this['call'](_0x352016(0x1f1),{'message':_0x523943,'filter_server':_0x3a8964?.['server'],'filter_status':_0x3a8964?.[_0x352016(0x1c7)]});}async[a0_0x4163cf(0x1ca)](){const _0x11e6af=a0_0x4163cf;let _0xff5c8d=encodeURIComponent(this[_0x11e6af(0x1a4)]),_0x1baf1e=this[_0x11e6af(0x1ab)]+'/events/'+_0xff5c8d,_0x978e61=this['reconnectDelay'];while(this['running']){try{this[_0x11e6af(0x1bd)]=new AbortController();let _0x2b7647={'Accept':_0x11e6af(0x1d1)};if(this[_0x11e6af(0x1af)])_0x2b7647[_0x11e6af(0x1f5)]=_0x11e6af(0x1aa)+this['token'];let _0x4fb1b8=await fetch(_0x1baf1e,{'headers':_0x2b7647,'signal':this[_0x11e6af(0x1bd)][_0x11e6af(0x1b6)]});if(!_0x4fb1b8['ok']||!_0x4fb1b8[_0x11e6af(0x1b4)]){this['log'](_0x11e6af(0x1c2)+_0x4fb1b8[_0x11e6af(0x1c7)]),await this[_0x11e6af(0x1d4)](_0x978e61),_0x978e61=Math['min'](_0x978e61*1.5,0xea60);continue;}_0x978e61=this[_0x11e6af(0x1f6)];let _0xe1b785=_0x4fb1b8[_0x11e6af(0x1b4)][_0x11e6af(0x1e7)](),_0x40706a=new TextDecoder(),_0x210796='';while(this[_0x11e6af(0x1b0)]){let {done:_0x4bea24,value:_0x4cbf4d}=await _0xe1b785[_0x11e6af(0x1ef)]();if(_0x4bea24)break;_0x210796+=_0x40706a[_0x11e6af(0x1b3)](_0x4cbf4d,{'stream':!0x0});let _0x3a11c8=_0x210796[_0x11e6af(0x1d8)]('\x0a');_0x210796=_0x3a11c8[_0x11e6af(0x1ad)]()||'';for(let _0x176b67 of _0x3a11c8){if(!_0x176b67[_0x11e6af(0x1b8)]('data:\x20'))continue;try{let _0x1f1e87=JSON[_0x11e6af(0x1da)](_0x176b67[_0x11e6af(0x1ec)](0x6));if(_0x1f1e87['type']===_0x11e6af(0x1e1)){this['log'](_0x11e6af(0x1df)),this['emit'](_0x11e6af(0x1e1));continue;}if(_0x1f1e87[_0x11e6af(0x1bc)]===_0x11e6af(0x1d0)||_0x1f1e87[_0x11e6af(0x1bc)]==='new_message'||_0x1f1e87['type']===_0x11e6af(0x1f1))await this[_0x11e6af(0x1f2)]();}catch{}}}}catch(_0x5c9231){if(_0x5c9231[_0x11e6af(0x1d2)]===_0x11e6af(0x1dd))break;this[_0x11e6af(0x1bb)](_0x11e6af(0x1c8),_0x5c9231),this[_0x11e6af(0x1ea)]('SSE\x20error:\x20'+_0x5c9231[_0x11e6af(0x1be)]);}if(this[_0x11e6af(0x1b0)])this[_0x11e6af(0x1bb)](_0x11e6af(0x1c6)),this[_0x11e6af(0x1ea)](_0x11e6af(0x1ae)+_0x978e61/0x3e8+'s...'),await this['sleep'](_0x978e61),_0x978e61=Math[_0x11e6af(0x1bf)](_0x978e61*1.5,0xea60);}}async[a0_0x4163cf(0x1f2)](){const _0x21a174=a0_0x4163cf;try{let _0x3d080c=(await this[_0x21a174(0x1d6)](_0x21a174(0x1f3),{'alias':this[_0x21a174(0x1a4)],'limit':0xa}))?.[_0x21a174(0x1c1)]||[];for(let _0x36aed3 of _0x3d080c)await this[_0x21a174(0x1d6)]('ack_inbox',{'alias':this['alias'],'message_id':_0x36aed3['id']}),this['log']('←\x20'+_0x36aed3['from_session']+':\x20'+_0x36aed3['content']['slice'](0x0,0x3c)),this[_0x21a174(0x1bb)](_0x21a174(0x1a6),_0x36aed3),this[_0x21a174(0x1bb)](_0x21a174(0x1be),_0x36aed3);}catch(_0x3951c6){this[_0x21a174(0x1ea)]('inbox\x20error:\x20'+_0x3951c6[_0x21a174(0x1be)]);}}[a0_0x4163cf(0x1d4)](_0xe9ce34){return new Promise(_0x30c398=>setTimeout(_0x30c398,_0xe9ce34));}}var $=T;export{$ as default,T as CommHub};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* CommHub Channel Plugin for Claude Code
|
|
4
|
+
*
|
|
5
|
+
* Alias resolution (priority order):
|
|
6
|
+
* 1. COMMHUB_ALIAS env var
|
|
7
|
+
* 2. Project .env: ~/.claude/channels/commhub/{project-path}/.env
|
|
8
|
+
* 3. tmux session name
|
|
9
|
+
* 4. hostname
|
|
10
|
+
*
|
|
11
|
+
* Shared config from: ~/.claude/channels/commhub/.env
|
|
12
|
+
* COMMHUB_URL, COMMHUB_TOKEN
|
|
13
|
+
*/
|
|
14
|
+
export {};
|
package/dist/src/node-server.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
const a0_0x158381=a0_0xf5ad;(function(_0x306d4a,_0x5f5daf){const _0x39c0da=a0_0xf5ad,_0x3d423a=_0x306d4a();while(!![]){try{const _0x1393f3=-parseInt(_0x39c0da(0x173))/0x1+-parseInt(_0x39c0da(0x1cf))/0x2+-parseInt(_0x39c0da(0x19d))/0x3*(parseInt(_0x39c0da(0x17e))/0x4)+parseInt(_0x39c0da(0x1b1))/0x5*(-parseInt(_0x39c0da(0x1d8))/0x6)+-parseInt(_0x39c0da(0x1b5))/0x7+-parseInt(_0x39c0da(0x17d))/0x8*(parseInt(_0x39c0da(0x17a))/0x9)+parseInt(_0x39c0da(0x165))/0xa;if(_0x1393f3===_0x5f5daf)break;else _0x3d423a['push'](_0x3d423a['shift']());}catch(_0x4d06fe){_0x3d423a['push'](_0x3d423a['shift']());}}}(a0_0x54b2,0x88302));import{readFileSync as a0_0x1ed82a,existsSync as a0_0x17f8bf}from'fs';import{randomUUID as a0_0x51ec75}from'crypto';import{join as a0_0x59f17f}from'path';import{hostname as a0_0x592bbe}from'os';import{execSync as a0_0x5b9049}from'child_process';import{Server as a0_0x43ba51}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport as a0_0x3104be}from'@modelcontextprotocol/sdk/server/stdio.js';import{ListToolsRequestSchema as a0_0x253b39,CallToolRequestSchema as a0_0x4f97f4}from'@modelcontextprotocol/sdk/types.js';function p(_0x3a8aa6){const _0x5ad673=a0_0xf5ad;if(!a0_0x17f8bf(_0x3a8aa6))return;for(let _0x434adb of a0_0x1ed82a(_0x3a8aa6,'utf-8')['split']('\x0a')){let _0x1a1dea=_0x434adb[_0x5ad673(0x1ce)]();if(!_0x1a1dea||_0x1a1dea[_0x5ad673(0x1a7)]('#'))continue;let _0x10eea9=_0x1a1dea[_0x5ad673(0x16d)]('=');if(_0x10eea9<0x0)continue;let _0x322ea6=_0x1a1dea[_0x5ad673(0x1d3)](0x0,_0x10eea9)[_0x5ad673(0x1ce)](),_0x5ec558=_0x1a1dea[_0x5ad673(0x1d3)](_0x10eea9+0x1)[_0x5ad673(0x1ce)]()['replace'](/^["']|["']$/g,'');if(!process.env[_0x322ea6])process.env[_0x322ea6]=_0x5ec558;}}var C=process.env.HOME||'~',T=a0_0x59f17f(C,a0_0x158381(0x1b3));p(a0_0x59f17f(T,'.env'));var L=process['cwd']()[a0_0x158381(0x18b)](/\//g,'-');p(a0_0x59f17f(T,L,'.env'));function U(){const _0x820496=a0_0x158381;try{return a0_0x5b9049(_0x820496(0x1b4),{'encoding':_0x820496(0x175),'timeout':0x7d0})[_0x820496(0x1ce)]();}catch{return'';}}function v(){const _0x2394a9=a0_0x158381;try{let _0x45cfc2=a0_0x59f17f(C,_0x2394a9(0x194),_0x2394a9(0x15e));if(a0_0x17f8bf(_0x45cfc2))return JSON[_0x2394a9(0x163)](a0_0x1ed82a(_0x45cfc2,_0x2394a9(0x175)));}catch{}return{};}var H=v(),f=process.env.COMMHUB_URL||H[a0_0x158381(0x1a5)]||a0_0x158381(0x187),j=process.env.COMMHUB_TMUX||U(),Z=process.env.COMMHUB_ALIAS||j||a0_0x592bbe(),w=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||a0_0x51ec75(),X=process.env.COMMHUB_TOKEN||H[a0_0x158381(0x1b9)]||'';function Y(_0x4d9f1b){const _0x1851ad=a0_0x158381;let _0x284be6=new Date()[_0x1851ad(0x1be)]()[_0x1851ad(0x1d3)](0x0,0x8);process[_0x1851ad(0x171)]['write']('['+_0x284be6+']\x20[commhub]\x20'+_0x4d9f1b+'\x0a');}function h(_0x4c327c){return new Promise(_0xcb323=>setTimeout(_0xcb323,_0x4c327c));}function a0_0xf5ad(_0x51b4d9,_0x116f96){_0x51b4d9=_0x51b4d9-0x15b;const _0x54b22d=a0_0x54b2();let _0xf5add3=_0x54b22d[_0x51b4d9];return _0xf5add3;}Y(a0_0x158381(0x178)+f+'\x20ALIAS='+Z+a0_0x158381(0x1e0)+w[a0_0x158381(0x1d3)](0x0,0x8)+a0_0x158381(0x1b0)+(j||a0_0x158381(0x18f))+a0_0x158381(0x16a)+process[a0_0x158381(0x1bd)]()+'\x20PROJECT_ENV='+L);var k=new Map(),K=new a0_0x43ba51({'name':a0_0x158381(0x196),'version':'0.3.0'},{'capabilities':{'experimental':{'claude/channel':{}},'tools':{}},'instructions':[a0_0x158381(0x18c),a0_0x158381(0x19c),a0_0x158381(0x182),a0_0x158381(0x1e3),a0_0x158381(0x186)+Z][a0_0x158381(0x180)]('\x0a')});K['setRequestHandler'](a0_0x253b39,async()=>({'tools':[{'name':'commhub_reply','description':a0_0x158381(0x1b6),'inputSchema':{'type':a0_0x158381(0x1bf),'properties':{'task_id':{'type':a0_0x158381(0x1a9),'description':a0_0x158381(0x15c)},'text':{'type':a0_0x158381(0x1a9),'description':'Reply\x20text\x20/\x20result\x20summary'},'status':{'type':'string','enum':[a0_0x158381(0x192),a0_0x158381(0x1a2),'cancelled',a0_0x158381(0x15d),a0_0x158381(0x1ab),'in_progress'],'description':a0_0x158381(0x1de)}},'required':[a0_0x158381(0x1a6)]}},{'name':'commhub_report_status','description':a0_0x158381(0x166),'inputSchema':{'type':a0_0x158381(0x1bf),'properties':{'status':{'type':a0_0x158381(0x1a9),'enum':[a0_0x158381(0x184),a0_0x158381(0x1dd),'blocked',a0_0x158381(0x1ab)]},'task':{'type':a0_0x158381(0x1a9),'description':a0_0x158381(0x1ac)},'progress':{'type':a0_0x158381(0x1db),'description':a0_0x158381(0x164)}},'required':['status']}},{'name':a0_0x158381(0x15b),'description':a0_0x158381(0x1ae),'inputSchema':{'type':a0_0x158381(0x1bf),'properties':{'alias':{'type':a0_0x158381(0x1a9),'description':'Target\x20session\x20alias'},'task':{'type':a0_0x158381(0x1a9),'description':a0_0x158381(0x1aa)},'priority':{'type':'string','enum':[a0_0x158381(0x199),a0_0x158381(0x1bb),'low'],'description':a0_0x158381(0x167)}},'required':[a0_0x158381(0x1c3),a0_0x158381(0x1a1)]}},{'name':a0_0x158381(0x1b7),'description':a0_0x158381(0x177),'inputSchema':{'type':'object','properties':{'alias':{'type':'string','description':'Target\x20session\x20alias'},'message':{'type':a0_0x158381(0x1a9),'description':a0_0x158381(0x1c5)}},'required':[a0_0x158381(0x1c3),a0_0x158381(0x188)]}},{'name':a0_0x158381(0x172),'description':a0_0x158381(0x170),'inputSchema':{'type':a0_0x158381(0x1bf),'properties':{}}}]}));async function P(_0x391961,_0x286c77){const _0x30faf3=a0_0x158381;let _0x456cc0=await fetch(f+_0x30faf3(0x1d9),{'method':_0x30faf3(0x183),'headers':{'Content-Type':_0x30faf3(0x1bc),'Accept':_0x30faf3(0x16c),...X?{'Authorization':_0x30faf3(0x19a)+X}:{}},'body':JSON['stringify']({'jsonrpc':'2.0','id':0x1,'method':'initialize','params':{'protocolVersion':'2025-03-26','capabilities':{},'clientInfo':{'name':'commhub-channel','version':_0x30faf3(0x189)}}})});if(!_0x456cc0['ok']){let _0x50730d=await _0x456cc0[_0x30faf3(0x1a6)]();return Y(_0x30faf3(0x1d2)+_0x456cc0[_0x30faf3(0x168)]+'\x20'+_0x50730d[_0x30faf3(0x1d3)](0x0,0x64)),{'ok':!0x1,'error':_0x30faf3(0x1e5)+_0x456cc0['status']};}await _0x456cc0[_0x30faf3(0x1a6)]();let _0xb72f72=(await(await fetch(f+_0x30faf3(0x1d9),{'method':_0x30faf3(0x183),'headers':{'Content-Type':_0x30faf3(0x1bc),'Accept':'application/json,\x20text/event-stream',...X?{'Authorization':_0x30faf3(0x19a)+X}:{}},'body':JSON[_0x30faf3(0x181)]({'jsonrpc':'2.0','id':0x2,'method':_0x30faf3(0x1b8),'params':{'name':_0x391961,'arguments':_0x286c77}})}))[_0x30faf3(0x1a6)]())['split']('\x0a')[_0x30faf3(0x16b)](_0x59d7e8=>_0x59d7e8[_0x30faf3(0x1a7)](_0x30faf3(0x197)));if(_0xb72f72){let _0x5306a3=JSON[_0x30faf3(0x163)](_0xb72f72['slice'](0x6));return _0x5306a3?.['result']?.['content']?.[0x0]?.[_0x30faf3(0x1a6)]?JSON[_0x30faf3(0x163)](_0x5306a3[_0x30faf3(0x1cd)][_0x30faf3(0x179)][0x0][_0x30faf3(0x1a6)]):_0x5306a3;}return{'ok':!0x1,'error':_0x30faf3(0x191)};}K['setRequestHandler'](a0_0x4f97f4,async _0x4792da=>{const _0x3794d5=a0_0x158381;let {name:_0x29cb5a,arguments:_0x1f9fe5}=_0x4792da['params'];if(_0x29cb5a===_0x3794d5(0x1a3)){let {task_id:_0x450f94,text:_0x263368,status:_0x3bdf19}=_0x1f9fe5;if(_0x3bdf19===_0x3794d5(0x192)||_0x3bdf19===_0x3794d5(0x1a2)||_0x3bdf19===_0x3794d5(0x19f)){let _0x444892=_0x3bdf19===_0x3794d5(0x192)?_0x3794d5(0x1c0):_0x3bdf19,_0x2be51f=_0x450f94?k[_0x3794d5(0x190)](_0x450f94)||_0x3794d5(0x1a5):_0x3794d5(0x1a5),_0x387538=await P(_0x3794d5(0x1c6),{'alias':_0x2be51f,'text':_0x263368,'in_reply_to':_0x450f94||void 0x0,'status':_0x444892,'from_session':Z});if(_0x450f94)k[_0x3794d5(0x161)](_0x450f94);return{'content':[{'type':'text','text':JSON[_0x3794d5(0x181)](_0x387538)}]};}let _0x3e21b5=await P(_0x3794d5(0x1cc),{'resume_id':w,'alias':Z,'status':_0x3bdf19===_0x3794d5(0x15d)?_0x3794d5(0x15d):_0x3bdf19===_0x3794d5(0x1ab)?_0x3794d5(0x1ab):_0x3794d5(0x184),'task':_0x263368[_0x3794d5(0x1d3)](0x0,0xc8),'output':_0x263368});return{'content':[{'type':_0x3794d5(0x1a6),'text':JSON[_0x3794d5(0x181)](_0x3e21b5)}]};}if(_0x29cb5a===_0x3794d5(0x1e7)){let {status:_0x3b4f6b,task:_0x43c927,progress:_0x581db5}=_0x1f9fe5,_0x189285=await P('report_status',{'resume_id':w,'alias':Z,'status':_0x3b4f6b,'task':_0x43c927,'progress':_0x581db5});return{'content':[{'type':_0x3794d5(0x1a6),'text':JSON['stringify'](_0x189285)}]};}if(_0x29cb5a==='commhub_send_task'){let {alias:_0x403709,task:_0x3f9e6a,priority:_0x2f5115}=_0x1f9fe5,_0x340f6f=await P('send_task',{'alias':_0x403709,'task':_0x3f9e6a,'priority':_0x2f5115||_0x3794d5(0x1bb),'from_session':Z});return{'content':[{'type':_0x3794d5(0x1a6),'text':JSON[_0x3794d5(0x181)](_0x340f6f)}]};}if(_0x29cb5a===_0x3794d5(0x1b7)){let {alias:_0x43868c,message:_0x15e748}=_0x1f9fe5,_0x3b1b79=await P(_0x3794d5(0x162),{'alias':_0x43868c,'message':_0x15e748,'from_session':Z});return{'content':[{'type':'text','text':JSON['stringify'](_0x3b1b79)}]};}if(_0x29cb5a===_0x3794d5(0x172)){let _0x47778a=await P(_0x3794d5(0x18d),{});return{'content':[{'type':_0x3794d5(0x1a6),'text':JSON['stringify'](_0x47778a)}]};}return{'content':[{'type':_0x3794d5(0x1a6),'text':JSON[_0x3794d5(0x181)]({'error':_0x3794d5(0x1e4)})}]};});async function u(){const _0x32d053=a0_0x158381;let _0x28dfee=f+_0x32d053(0x1d4)+encodeURIComponent(Z),_0x1cd3e7={};if(X)_0x1cd3e7[_0x32d053(0x1c2)]=_0x32d053(0x19a)+X;Y(_0x32d053(0x198)+_0x28dfee);while(!0x0){try{let _0xedb4a5=await fetch(_0x28dfee,{'headers':_0x1cd3e7});if(!_0xedb4a5['ok']){Y(_0x32d053(0x1dc)+_0xedb4a5[_0x32d053(0x168)]+'\x20'+_0xedb4a5[_0x32d053(0x18e)]),await h(0x1388);continue;}let _0x448791=_0xedb4a5[_0x32d053(0x16e)][_0x32d053(0x1a4)](),_0x2d20df=new TextDecoder(),_0x27dd06='';while(!0x0){let {done:_0x5f0ae6,value:_0x3499eb}=await _0x448791[_0x32d053(0x169)]();if(_0x5f0ae6)break;_0x27dd06+=_0x2d20df[_0x32d053(0x1d0)](_0x3499eb,{'stream':!0x0});let _0x5eaec6=_0x27dd06['split']('\x0a\x0a');_0x27dd06=_0x5eaec6[_0x32d053(0x16f)]()||'';for(let _0x32cad4 of _0x5eaec6){let _0x864d99=_0x32cad4[_0x32d053(0x176)]('\x0a')[_0x32d053(0x16b)](_0x4414ca=>_0x4414ca[_0x32d053(0x1a7)](_0x32d053(0x197)));if(!_0x864d99)continue;try{let _0x5e1b00=JSON[_0x32d053(0x163)](_0x864d99[_0x32d053(0x1d3)](0x6));await S(_0x5e1b00);}catch(_0x210798){Y(_0x32d053(0x185)+_0x210798);}}}Y('SSE\x20stream\x20ended,\x20reconnecting...');}catch(_0x54d55f){Y(_0x32d053(0x1a8)+_0x54d55f);}await h(0xbb8);}}async function S(_0xc0d174){const _0x918b61=a0_0x158381;if(_0xc0d174[_0x918b61(0x1e2)]==='connected'){Y(_0x918b61(0x1b2)+Z+'\x22');return;}if(_0xc0d174['type']==='new_message'){if(Y(_0x918b61(0x1af)+_0xc0d174[_0x918b61(0x1c9)]+':\x20'+_0xc0d174[_0x918b61(0x188)][_0x918b61(0x1d3)](0x0,0x3c)),await K[_0x918b61(0x17f)]({'method':_0x918b61(0x1e1),'params':{'content':_0xc0d174['message'],'meta':{'sender':_0xc0d174[_0x918b61(0x1c9)]||_0x918b61(0x1a5),'sender_id':'commhub','user':_0xc0d174['from']||_0x918b61(0x1a5),'priority':_0x918b61(0x1bb)}}}),_0xc0d174['message_id'])await P(_0x918b61(0x19e),{'alias':Z,'message_id':_0xc0d174[_0x918b61(0x1e6)]});return;}if(_0xc0d174[_0x918b61(0x1e2)]===_0x918b61(0x1df)||_0xc0d174['type']==='broadcast'){Y('←\x20'+_0xc0d174[_0x918b61(0x1e2)]+':\x20inbox_count='+_0xc0d174[_0x918b61(0x17b)]+'\x20priority='+(_0xc0d174[_0x918b61(0x1ca)]||_0x918b61(0x1bb)));let _0x4aa6ea=await P('get_inbox',{'alias':Z,'limit':0x5});if(_0x4aa6ea?.['ok']&&_0x4aa6ea[_0x918b61(0x1d5)]?.[_0x918b61(0x1ba)]>0x0)for(let _0x2213d3 of _0x4aa6ea['messages']){let _0xfd8e97={'sender':_0x2213d3[_0x918b61(0x1c7)]||'hub','sender_id':'commhub','user':_0x2213d3[_0x918b61(0x1c7)]||_0x918b61(0x1a5),'task_id':_0x2213d3['id'],'priority':_0x2213d3[_0x918b61(0x1ca)]||_0x918b61(0x1bb)};k[_0x918b61(0x1c8)](_0x2213d3['id'],_0x2213d3[_0x918b61(0x1c7)]||'hub'),await K['notification']({'method':_0x918b61(0x1e1),'params':{'content':_0x2213d3[_0x918b61(0x179)],'meta':_0xfd8e97}}),Y(_0x918b61(0x17c)+_0x2213d3['id'][_0x918b61(0x1d3)](0x0,0x8)+_0x918b61(0x160)+_0x2213d3[_0x918b61(0x1c7)]+':\x20'+_0x2213d3['content'][_0x918b61(0x1d3)](0x0,0x3c)),await P(_0x918b61(0x19e),{'alias':Z,'message_id':_0x2213d3['id']});}}}function a0_0x54b2(){const _0x399726=['length','normal','application/json','cwd','toTimeString','object','replied','stdin','Authorization','alias','claude-code','Message\x20content','send_reply','from_session','set','from','priority','shutting\x20down,\x20reporting\x20offline...','report_status','result','trim','1764292lwtAte','decode','then','CommHub\x20init\x20failed:\x20','slice','/events/','messages','registered\x20as\x20\x22','warning:\x20could\x20not\x20register:\x20','1206RtchPP','/mcp','SIGINT','number','SSE\x20error:\x20','idle','Task\x20outcome:\x20completed/failed/cancelled\x20for\x20final\x20results,\x20blocked/error/in_progress\x20for\x20status\x20updates','new_task','\x20RESUME_ID=','notifications/claude/channel','type','You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.','unknown\x20tool','init\x20failed:\x20','message_id','commhub_report_status','commhub_send_task','The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)','blocked','config.json','catch','\x20from\x20','delete','send_message','parse','Progress\x200-100','40636200nmudAX','Update\x20this\x20session\x27s\x20status\x20in\x20CommHub\x20(working/idle/blocked/error).\x20Returns\x20inbox_count.','Priority\x20(default:\x20normal)','status','read','\x20CWD=','find','application/json,\x20text/event-stream','indexOf','body','pop','Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','stderr','commhub_get_all_status','611952NqEwGM','exit','utf-8','split','Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.','ENV:\x20URL=','content','18QldZyj','inbox_count','→\x20injected\x20task\x20','92368zOcUxP','4384748kxkWnM','notification','join','stringify','Reply\x20using\x20the\x20commhub_reply\x20tool\x20to\x20report\x20status\x20or\x20results\x20back.','POST','working','parse\x20error:\x20','Session\x20alias:\x20','http://127.0.0.1:9200','message','0.3.0','connect','replace','Messages\x20from\x20CommHub\x20arrive\x20as\x20<channel\x20source=\x22commhub\x22\x20task_id=\x22...\x22\x20priority=\x22...\x22\x20from=\x22...\x22>','get_all_status','statusText','none','get','no\x20response','completed','end','.anet','SSE\x20fatal:\x20','commhub-channel','data:\x20','connecting\x20to\x20','high','Bearer\x20','\x22\x20(','These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.','3pSDlAv','ack_inbox','cancelled','fatal:\x20','task','failed','commhub_reply','getReader','hub','text','startsWith','SSE\x20connection\x20error:\x20','string','Task\x20content','error','Current\x20task\x20description','session\x20disconnected','Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.','←\x20message\x20from\x20','...\x20TMUX=','955wcDudw','SSE\x20connected\x20as\x20\x22','.claude/channels/commhub','tmux\x20display-message\x20-p\x20\x27#S\x27','5978182jUEjrb','Reply\x20to\x20a\x20CommHub\x20task\x20—\x20report\x20completion\x20or\x20send\x20a\x20message\x20back\x20to\x20the\x20hub.','commhub_send_message','tools/call','token'];a0_0x54b2=function(){return _0x399726;};return a0_0x54b2();}async function A(){const _0x3e4c25=a0_0x158381;let _0x4e0b5f=new a0_0x3104be();await K[_0x3e4c25(0x18a)](_0x4e0b5f),Y('MCP\x20stdio\x20connected'),Y('starting\x20SSE\x20listener...'),u()['catch'](_0x159475=>Y(_0x3e4c25(0x195)+_0x159475)),P(_0x3e4c25(0x1cc),{'resume_id':w,'alias':Z,'status':_0x3e4c25(0x1dd),'server':a0_0x592bbe(),'hostname':a0_0x592bbe(),'agent':'claude-code','project_dir':process['cwd'](),'tmux_name':j||void 0x0})[_0x3e4c25(0x1d1)](()=>Y(_0x3e4c25(0x1d6)+Z+_0x3e4c25(0x19b)+w['slice'](0x0,0x8)+')'))[_0x3e4c25(0x15f)](_0x4d36ad=>Y(_0x3e4c25(0x1d7)+_0x4d36ad)),setInterval(()=>{const _0x4b594f=_0x3e4c25;P(_0x4b594f(0x1cc),{'resume_id':w,'alias':Z,'status':_0x4b594f(0x1dd),'server':a0_0x592bbe(),'hostname':a0_0x592bbe(),'agent':_0x4b594f(0x1c4),'project_dir':process[_0x4b594f(0x1bd)](),'tmux_name':j||void 0x0})[_0x4b594f(0x15f)](_0x4dc7f5=>Y('heartbeat\x20failed:\x20'+_0x4dc7f5));},0x2bf20),Y('ready\x20—\x20waiting\x20for\x20events');}A()[a0_0x158381(0x15f)](_0x2a8255=>{const _0x3a96ed=a0_0x158381;Y(_0x3a96ed(0x1a0)+_0x2a8255),process[_0x3a96ed(0x174)](0x1);});async function N(){const _0x2e996f=a0_0x158381;Y(_0x2e996f(0x1cb)),await P(_0x2e996f(0x1cc),{'resume_id':w,'alias':Z,'status':'error','task':_0x2e996f(0x1ad)})['catch'](()=>{}),process[_0x2e996f(0x174)](0x0);}process[a0_0x158381(0x1c1)]['on'](a0_0x158381(0x193),()=>N()),process['on']('SIGTERM',()=>N()),process['on'](a0_0x158381(0x1da),()=>N());
|
|
2
|
+
const a0_0x590876=a0_0x10f1;(function(_0x97fd6,_0x31eb17){const _0x2ae8df=a0_0x10f1,_0x3f301d=_0x97fd6();while(!![]){try{const _0x4fba51=parseInt(_0x2ae8df(0x13f))/0x1*(parseInt(_0x2ae8df(0xf2))/0x2)+-parseInt(_0x2ae8df(0x168))/0x3+-parseInt(_0x2ae8df(0x13d))/0x4*(-parseInt(_0x2ae8df(0x11e))/0x5)+-parseInt(_0x2ae8df(0x101))/0x6+-parseInt(_0x2ae8df(0x162))/0x7*(parseInt(_0x2ae8df(0x13a))/0x8)+parseInt(_0x2ae8df(0x146))/0x9*(parseInt(_0x2ae8df(0x14d))/0xa)+parseInt(_0x2ae8df(0x152))/0xb;if(_0x4fba51===_0x31eb17)break;else _0x3f301d['push'](_0x3f301d['shift']());}catch(_0x3839cd){_0x3f301d['push'](_0x3f301d['shift']());}}}(a0_0x5afb,0xaeebd));import{readFileSync as a0_0x1863ec,existsSync as a0_0x1a7dd5}from'fs';import{randomUUID as a0_0x501545}from'crypto';import{join as a0_0x2b1168}from'path';import{hostname as a0_0x5df9a6}from'os';import{execSync as a0_0xd26412}from'child_process';import{Server as a0_0x54a809}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport as a0_0x69e475}from'@modelcontextprotocol/sdk/server/stdio.js';import{ListToolsRequestSchema as a0_0x345e7f,CallToolRequestSchema as a0_0x29da7d}from'@modelcontextprotocol/sdk/types.js';function p(_0x3f76a2){const _0x390a37=a0_0x10f1;if(!a0_0x1a7dd5(_0x3f76a2))return;for(let _0x2d5739 of a0_0x1863ec(_0x3f76a2,_0x390a37(0x15e))[_0x390a37(0x11c)]('\x0a')){let _0x39ab27=_0x2d5739['trim']();if(!_0x39ab27||_0x39ab27[_0x390a37(0x147)]('#'))continue;let _0x3c2680=_0x39ab27['indexOf']('=');if(_0x3c2680<0x0)continue;let _0x5b31ba=_0x39ab27['slice'](0x0,_0x3c2680)[_0x390a37(0xee)](),_0xaa983c=_0x39ab27[_0x390a37(0x142)](_0x3c2680+0x1)['trim']()[_0x390a37(0x10b)](/^["']|["']$/g,'');if(!process.env[_0x5b31ba])process.env[_0x5b31ba]=_0xaa983c;}}var C=process.env.HOME||'~',T=a0_0x2b1168(C,a0_0x590876(0x105));p(a0_0x2b1168(T,a0_0x590876(0x130)));function a0_0x5afb(){const _0x4c191c=['none','commhub_send_task','Target\x20session\x20alias','commhub_get_all_status','idle','stringify','then','get','split','\x20priority=','5EDYOdu','SSE\x20error:\x20','text','\x20from\x20','\x20ALIAS=','commhub','CommHub\x20init\x20failed:\x20','config.json','commhub_report_status','replied','Current\x20task\x20description','failed','priority','registered\x20as\x20\x22','POST','string','connecting\x20to\x20','normal','.env','status','object','.anet','\x20CWD=','session\x20disconnected','SSE\x20connected\x20as\x20\x22','unknown\x20tool','Session\x20alias:\x20','pop','16wBfCoQ','The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)','send_task','2298984oeoTgq','claude-code','12407uaheTX','Reply\x20text\x20/\x20result\x20summary','getReader','slice','SSE\x20fatal:\x20','length','commhub-channel','1053WXNjsH','startsWith','delete','setRequestHandler','new_message','Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','tools/call','71350gCKfVA','2.0','exit','Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.','notifications/claude/channel','8156016wXDnRr','message','token','from','completed','heartbeat\x20failed:\x20','get_all_status','Update\x20this\x20session\x27s\x20status\x20in\x20CommHub\x20(working/idle/blocked/error).\x20Returns\x20inbox_count.','Reply\x20to\x20a\x20CommHub\x20task\x20—\x20report\x20completion\x20or\x20send\x20a\x20message\x20back\x20to\x20the\x20hub.','message_id','end','Priority\x20(default:\x20normal)','utf-8','Progress\x200-100','stdin','catch','4734723dJipEv','messages','blocked','commhub_reply','hub','commhub_send_message','3156453viJHTK','These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.','ack_inbox','params','Messages\x20from\x20CommHub\x20arrive\x20as\x20<channel\x20source=\x22commhub\x22\x20task_id=\x22...\x22\x20priority=\x22...\x22\x20from=\x22...\x22>','read','→\x20injected\x20task\x20','Bearer\x20','/events/','ENV:\x20URL=','send_message','from_session','task','in_progress','connect','/mcp','starting\x20SSE\x20listener...','get_inbox','SIGINT','trim','tmux\x20display-message\x20-p\x20\x27#S\x27','shutting\x20down,\x20reporting\x20offline...',']\x20[commhub]\x20','166wNTIpB','new_task','cwd','0.3.0','cancelled','Authorization','Message\x20content','http://127.0.0.1:9200','MCP\x20stdio\x20connected','send_reply','alias','result','content','find','type','356232lgxDkT','no\x20response','You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.','\x20RESUME_ID=','.claude/channels/commhub','parse\x20error:\x20','report_status','notification','error','initialize','replace','SSE\x20stream\x20ended,\x20reconnecting...','2025-03-26','...\x20TMUX=','working','application/json','parse','data:\x20',':\x20inbox_count='];a0_0x5afb=function(){return _0x4c191c;};return a0_0x5afb();}var L=process['cwd']()[a0_0x590876(0x10b)](/\//g,'-');function a0_0x10f1(_0x48f889,_0x1d5f4f){_0x48f889=_0x48f889-0xed;const _0x5afb68=a0_0x5afb();let _0x10f19c=_0x5afb68[_0x48f889];return _0x10f19c;}p(a0_0x2b1168(T,L,'.env'));function U(){const _0x296b66=a0_0x590876;try{return a0_0xd26412(_0x296b66(0xef),{'encoding':'utf-8','timeout':0x7d0})['trim']();}catch{return'';}}function v(){const _0x135566=a0_0x590876;try{let _0x1c04b1=a0_0x2b1168(C,_0x135566(0x133),_0x135566(0x125));if(a0_0x1a7dd5(_0x1c04b1))return JSON[_0x135566(0x111)](a0_0x1863ec(_0x1c04b1,_0x135566(0x15e)));}catch{}return{};}var H=v(),f=process.env.COMMHUB_URL||H[a0_0x590876(0x166)]||a0_0x590876(0xf9),j=process.env.COMMHUB_TMUX||U(),Z=process.env.COMMHUB_ALIAS||j||a0_0x5df9a6(),w=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||a0_0x501545(),X=process.env.COMMHUB_TOKEN||H[a0_0x590876(0x154)]||'';function Y(_0x2fb427){const _0x55f1a2=a0_0x590876;let _0x27d0f6=new Date()['toTimeString']()[_0x55f1a2(0x142)](0x0,0x8);process['stderr']['write']('['+_0x27d0f6+_0x55f1a2(0xf1)+_0x2fb427+'\x0a');}function h(_0x1f20c6){return new Promise(_0x49bb98=>setTimeout(_0x49bb98,_0x1f20c6));}Y(a0_0x590876(0x171)+f+a0_0x590876(0x122)+Z+a0_0x590876(0x104)+w['slice'](0x0,0x8)+a0_0x590876(0x10e)+(j||a0_0x590876(0x114))+a0_0x590876(0x134)+process['cwd']()+'\x20PROJECT_ENV='+L);var k=new Map(),K=new a0_0x54a809({'name':a0_0x590876(0x145),'version':a0_0x590876(0xf5)},{'capabilities':{'experimental':{'claude/channel':{}},'tools':{}},'instructions':[a0_0x590876(0x16c),a0_0x590876(0x169),'Reply\x20using\x20the\x20commhub_reply\x20tool\x20to\x20report\x20status\x20or\x20results\x20back.',a0_0x590876(0x103),a0_0x590876(0x138)+Z]['join']('\x0a')});K[a0_0x590876(0x149)](a0_0x345e7f,async()=>({'tools':[{'name':a0_0x590876(0x165),'description':a0_0x590876(0x15a),'inputSchema':{'type':'object','properties':{'task_id':{'type':a0_0x590876(0x12d),'description':a0_0x590876(0x13b)},'text':{'type':a0_0x590876(0x12d),'description':a0_0x590876(0x140)},'status':{'type':'string','enum':[a0_0x590876(0x156),a0_0x590876(0x129),'cancelled',a0_0x590876(0x164),a0_0x590876(0x109),a0_0x590876(0x175)],'description':'Task\x20outcome:\x20completed/failed/cancelled\x20for\x20final\x20results,\x20blocked/error/in_progress\x20for\x20status\x20updates'}},'required':[a0_0x590876(0x120)]}},{'name':a0_0x590876(0x126),'description':a0_0x590876(0x159),'inputSchema':{'type':a0_0x590876(0x132),'properties':{'status':{'type':'string','enum':[a0_0x590876(0x10f),a0_0x590876(0x118),a0_0x590876(0x164),a0_0x590876(0x109)]},'task':{'type':a0_0x590876(0x12d),'description':a0_0x590876(0x128)},'progress':{'type':'number','description':a0_0x590876(0x15f)}},'required':[a0_0x590876(0x131)]}},{'name':a0_0x590876(0x115),'description':'Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.','inputSchema':{'type':a0_0x590876(0x132),'properties':{'alias':{'type':a0_0x590876(0x12d),'description':a0_0x590876(0x116)},'task':{'type':a0_0x590876(0x12d),'description':'Task\x20content'},'priority':{'type':a0_0x590876(0x12d),'enum':['high',a0_0x590876(0x12f),'low'],'description':a0_0x590876(0x15d)}},'required':[a0_0x590876(0xfc),a0_0x590876(0x174)]}},{'name':a0_0x590876(0x167),'description':a0_0x590876(0x150),'inputSchema':{'type':a0_0x590876(0x132),'properties':{'alias':{'type':a0_0x590876(0x12d),'description':a0_0x590876(0x116)},'message':{'type':'string','description':a0_0x590876(0xf8)}},'required':[a0_0x590876(0xfc),'message']}},{'name':a0_0x590876(0x117),'description':a0_0x590876(0x14b),'inputSchema':{'type':a0_0x590876(0x132),'properties':{}}}]}));async function P(_0x59fc4b,_0x308272){const _0x9b492b=a0_0x590876;let _0x11f2ed=await fetch(f+_0x9b492b(0x177),{'method':_0x9b492b(0x12c),'headers':{'Content-Type':'application/json','Accept':'application/json,\x20text/event-stream',...X?{'Authorization':_0x9b492b(0x16f)+X}:{}},'body':JSON[_0x9b492b(0x119)]({'jsonrpc':_0x9b492b(0x14e),'id':0x1,'method':_0x9b492b(0x10a),'params':{'protocolVersion':_0x9b492b(0x10d),'capabilities':{},'clientInfo':{'name':_0x9b492b(0x145),'version':_0x9b492b(0xf5)}}})});if(!_0x11f2ed['ok']){let _0x19f9d7=await _0x11f2ed['text']();return Y(_0x9b492b(0x124)+_0x11f2ed[_0x9b492b(0x131)]+'\x20'+_0x19f9d7['slice'](0x0,0x64)),{'ok':!0x1,'error':'init\x20failed:\x20'+_0x11f2ed['status']};}await _0x11f2ed['text']();let _0x43094c=(await(await fetch(f+_0x9b492b(0x177),{'method':_0x9b492b(0x12c),'headers':{'Content-Type':_0x9b492b(0x110),'Accept':'application/json,\x20text/event-stream',...X?{'Authorization':_0x9b492b(0x16f)+X}:{}},'body':JSON['stringify']({'jsonrpc':'2.0','id':0x2,'method':_0x9b492b(0x14c),'params':{'name':_0x59fc4b,'arguments':_0x308272}})}))[_0x9b492b(0x120)]())[_0x9b492b(0x11c)]('\x0a')[_0x9b492b(0xff)](_0x23b081=>_0x23b081[_0x9b492b(0x147)](_0x9b492b(0x112)));if(_0x43094c){let _0x1c09a0=JSON[_0x9b492b(0x111)](_0x43094c[_0x9b492b(0x142)](0x6));return _0x1c09a0?.[_0x9b492b(0xfd)]?.[_0x9b492b(0xfe)]?.[0x0]?.[_0x9b492b(0x120)]?JSON[_0x9b492b(0x111)](_0x1c09a0['result']['content'][0x0][_0x9b492b(0x120)]):_0x1c09a0;}return{'ok':!0x1,'error':_0x9b492b(0x102)};}K[a0_0x590876(0x149)](a0_0x29da7d,async _0x139843=>{const _0x31b35c=a0_0x590876;let {name:_0x5ea47c,arguments:_0x3508c8}=_0x139843[_0x31b35c(0x16b)];if(_0x5ea47c===_0x31b35c(0x165)){let {task_id:_0x487764,text:_0x29a4f3,status:_0x4e7fda}=_0x3508c8;if(_0x4e7fda===_0x31b35c(0x156)||_0x4e7fda==='failed'||_0x4e7fda===_0x31b35c(0xf6)){let _0xc5e0d=_0x4e7fda==='completed'?_0x31b35c(0x127):_0x4e7fda,_0x1bd083=_0x487764?k[_0x31b35c(0x11b)](_0x487764)||_0x31b35c(0x166):_0x31b35c(0x166),_0xd707a7=await P(_0x31b35c(0xfb),{'alias':_0x1bd083,'text':_0x29a4f3,'in_reply_to':_0x487764||void 0x0,'status':_0xc5e0d,'from_session':Z});if(_0x487764)k[_0x31b35c(0x148)](_0x487764);return{'content':[{'type':_0x31b35c(0x120),'text':JSON['stringify'](_0xd707a7)}]};}let _0xb52c74=await P(_0x31b35c(0x107),{'resume_id':w,'alias':Z,'status':_0x4e7fda===_0x31b35c(0x164)?_0x31b35c(0x164):_0x4e7fda===_0x31b35c(0x109)?_0x31b35c(0x109):_0x31b35c(0x10f),'task':_0x29a4f3[_0x31b35c(0x142)](0x0,0xc8),'output':_0x29a4f3});return{'content':[{'type':_0x31b35c(0x120),'text':JSON['stringify'](_0xb52c74)}]};}if(_0x5ea47c==='commhub_report_status'){let {status:_0x3b638a,task:_0x54254d,progress:_0x13e545}=_0x3508c8,_0x52a1ef=await P(_0x31b35c(0x107),{'resume_id':w,'alias':Z,'status':_0x3b638a,'task':_0x54254d,'progress':_0x13e545});return{'content':[{'type':_0x31b35c(0x120),'text':JSON[_0x31b35c(0x119)](_0x52a1ef)}]};}if(_0x5ea47c==='commhub_send_task'){let {alias:_0x34ad58,task:_0x2e10ab,priority:_0x57ae2c}=_0x3508c8,_0xee8df5=await P(_0x31b35c(0x13c),{'alias':_0x34ad58,'task':_0x2e10ab,'priority':_0x57ae2c||_0x31b35c(0x12f),'from_session':Z});return{'content':[{'type':_0x31b35c(0x120),'text':JSON[_0x31b35c(0x119)](_0xee8df5)}]};}if(_0x5ea47c===_0x31b35c(0x167)){let {alias:_0x1e6e60,message:_0x34ce10}=_0x3508c8,_0x4c9253=await P(_0x31b35c(0x172),{'alias':_0x1e6e60,'message':_0x34ce10,'from_session':Z});return{'content':[{'type':_0x31b35c(0x120),'text':JSON['stringify'](_0x4c9253)}]};}if(_0x5ea47c===_0x31b35c(0x117)){let _0x166c3e=await P(_0x31b35c(0x158),{});return{'content':[{'type':_0x31b35c(0x120),'text':JSON[_0x31b35c(0x119)](_0x166c3e)}]};}return{'content':[{'type':_0x31b35c(0x120),'text':JSON[_0x31b35c(0x119)]({'error':_0x31b35c(0x137)})}]};});async function u(){const _0x4ab3c6=a0_0x590876;let _0x567ac2=f+_0x4ab3c6(0x170)+encodeURIComponent(Z),_0x4eee2e={};if(X)_0x4eee2e[_0x4ab3c6(0xf7)]='Bearer\x20'+X;Y(_0x4ab3c6(0x12e)+_0x567ac2);while(!0x0){try{let _0x104e37=await fetch(_0x567ac2,{'headers':_0x4eee2e});if(!_0x104e37['ok']){Y(_0x4ab3c6(0x11f)+_0x104e37[_0x4ab3c6(0x131)]+'\x20'+_0x104e37['statusText']),await h(0x1388);continue;}let _0x14b92b=_0x104e37['body'][_0x4ab3c6(0x141)](),_0x2a6a6c=new TextDecoder(),_0x24fc1a='';while(!0x0){let {done:_0x21faf0,value:_0x2c6d88}=await _0x14b92b[_0x4ab3c6(0x16d)]();if(_0x21faf0)break;_0x24fc1a+=_0x2a6a6c['decode'](_0x2c6d88,{'stream':!0x0});let _0x1f261f=_0x24fc1a[_0x4ab3c6(0x11c)]('\x0a\x0a');_0x24fc1a=_0x1f261f[_0x4ab3c6(0x139)]()||'';for(let _0x1d67e6 of _0x1f261f){let _0xd2b58b=_0x1d67e6[_0x4ab3c6(0x11c)]('\x0a')[_0x4ab3c6(0xff)](_0x2d9348=>_0x2d9348['startsWith'](_0x4ab3c6(0x112)));if(!_0xd2b58b)continue;try{let _0x4edf6b=JSON['parse'](_0xd2b58b[_0x4ab3c6(0x142)](0x6));await S(_0x4edf6b);}catch(_0xdb27e7){Y(_0x4ab3c6(0x106)+_0xdb27e7);}}}Y(_0x4ab3c6(0x10c));}catch(_0x15411f){Y('SSE\x20connection\x20error:\x20'+_0x15411f);}await h(0xbb8);}}async function S(_0x2d74b0){const _0x298d90=a0_0x590876;if(_0x2d74b0[_0x298d90(0x100)]==='connected'){Y(_0x298d90(0x136)+Z+'\x22');return;}if(_0x2d74b0[_0x298d90(0x100)]===_0x298d90(0x14a)){if(Y('←\x20message\x20from\x20'+_0x2d74b0[_0x298d90(0x155)]+':\x20'+_0x2d74b0[_0x298d90(0x153)]['slice'](0x0,0x3c)),await K['notification']({'method':_0x298d90(0x151),'params':{'content':_0x2d74b0[_0x298d90(0x153)],'meta':{'sender':_0x2d74b0[_0x298d90(0x155)]||_0x298d90(0x166),'sender_id':'commhub','user':_0x2d74b0['from']||_0x298d90(0x166),'priority':_0x298d90(0x12f)}}}),_0x2d74b0[_0x298d90(0x15b)])await P(_0x298d90(0x16a),{'alias':Z,'message_id':_0x2d74b0[_0x298d90(0x15b)]});return;}if(_0x2d74b0['type']===_0x298d90(0xf3)||_0x2d74b0[_0x298d90(0x100)]==='broadcast'){Y('←\x20'+_0x2d74b0[_0x298d90(0x100)]+_0x298d90(0x113)+_0x2d74b0['inbox_count']+_0x298d90(0x11d)+(_0x2d74b0[_0x298d90(0x12a)]||_0x298d90(0x12f)));let _0x3453bf=await P(_0x298d90(0x179),{'alias':Z,'limit':0x5});if(_0x3453bf?.['ok']&&_0x3453bf[_0x298d90(0x163)]?.[_0x298d90(0x144)]>0x0)for(let _0x565cf5 of _0x3453bf[_0x298d90(0x163)]){let _0x35b4ab={'sender':_0x565cf5[_0x298d90(0x173)]||_0x298d90(0x166),'sender_id':_0x298d90(0x123),'user':_0x565cf5[_0x298d90(0x173)]||_0x298d90(0x166),'task_id':_0x565cf5['id'],'priority':_0x565cf5['priority']||_0x298d90(0x12f)};k['set'](_0x565cf5['id'],_0x565cf5[_0x298d90(0x173)]||_0x298d90(0x166)),await K[_0x298d90(0x108)]({'method':_0x298d90(0x151),'params':{'content':_0x565cf5['content'],'meta':_0x35b4ab}}),Y(_0x298d90(0x16e)+_0x565cf5['id'][_0x298d90(0x142)](0x0,0x8)+_0x298d90(0x121)+_0x565cf5[_0x298d90(0x173)]+':\x20'+_0x565cf5[_0x298d90(0xfe)][_0x298d90(0x142)](0x0,0x3c)),await P('ack_inbox',{'alias':Z,'message_id':_0x565cf5['id']});}}}async function A(){const _0x1fe7f5=a0_0x590876;let _0x4f2c5a=new a0_0x69e475();await K[_0x1fe7f5(0x176)](_0x4f2c5a),Y(_0x1fe7f5(0xfa)),Y(_0x1fe7f5(0x178)),u()[_0x1fe7f5(0x161)](_0x411b44=>Y(_0x1fe7f5(0x143)+_0x411b44)),P(_0x1fe7f5(0x107),{'resume_id':w,'alias':Z,'status':'idle','server':a0_0x5df9a6(),'hostname':a0_0x5df9a6(),'agent':'claude-code','project_dir':process[_0x1fe7f5(0xf4)](),'tmux_name':j||void 0x0})[_0x1fe7f5(0x11a)](()=>Y(_0x1fe7f5(0x12b)+Z+'\x22\x20('+w[_0x1fe7f5(0x142)](0x0,0x8)+')'))['catch'](_0x2793e9=>Y('warning:\x20could\x20not\x20register:\x20'+_0x2793e9)),setInterval(()=>{const _0x26abce=_0x1fe7f5;P(_0x26abce(0x107),{'resume_id':w,'alias':Z,'status':'idle','server':a0_0x5df9a6(),'hostname':a0_0x5df9a6(),'agent':_0x26abce(0x13e),'project_dir':process['cwd'](),'tmux_name':j||void 0x0})[_0x26abce(0x161)](_0x3d23f5=>Y(_0x26abce(0x157)+_0x3d23f5));},0x2bf20),Y('ready\x20—\x20waiting\x20for\x20events');}A()[a0_0x590876(0x161)](_0x3bc93a=>{const _0x282ce6=a0_0x590876;Y('fatal:\x20'+_0x3bc93a),process[_0x282ce6(0x14f)](0x1);});async function N(){const _0x1cb17f=a0_0x590876;Y(_0x1cb17f(0xf0)),await P('report_status',{'resume_id':w,'alias':Z,'status':_0x1cb17f(0x109),'task':_0x1cb17f(0x135)})[_0x1cb17f(0x161)](()=>{}),process[_0x1cb17f(0x14f)](0x0);}process[a0_0x590876(0x160)]['on'](a0_0x590876(0x15c),()=>N()),process['on']('SIGTERM',()=>N()),process['on'](a0_0x590876(0xed),()=>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.3-preview.0",
|
|
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",
|
|
@@ -9,9 +9,6 @@
|
|
|
9
9
|
".": {
|
|
10
10
|
"import": "./dist/src/client.js",
|
|
11
11
|
"types": "./dist/client.d.ts"
|
|
12
|
-
},
|
|
13
|
-
"./server": {
|
|
14
|
-
"import": "./src/server.ts"
|
|
15
12
|
}
|
|
16
13
|
},
|
|
17
14
|
"bin": {
|
|
@@ -21,6 +18,7 @@
|
|
|
21
18
|
"dist"
|
|
22
19
|
],
|
|
23
20
|
"scripts": {
|
|
21
|
+
"typecheck": "tsc --noEmit",
|
|
24
22
|
"build": "bun build src/client.ts --outdir dist/src --target node --minify && bun build bin/cli.ts --outdir dist/bin --target node --minify --external @sleep2agi/commhub-server --external bun:sqlite --external '../../server/*' && bun build src/node-server.ts --outdir dist/src --target node --minify --external @modelcontextprotocol/sdk && tsc --emitDeclarationOnly --declaration --outDir dist && npx javascript-obfuscator dist/bin/cli.js --output dist/bin/cli.js --compact true --string-array true --string-array-encoding base64 && npx javascript-obfuscator dist/src/client.js --output dist/src/client.js --compact true --string-array true && npx javascript-obfuscator dist/src/node-server.js --output dist/src/node-server.js --compact true --string-array true",
|
|
25
23
|
"prepublishOnly": "npm run build"
|
|
26
24
|
},
|
|
@@ -60,6 +58,7 @@
|
|
|
60
58
|
"@inquirer/prompts": "^7.10.1"
|
|
61
59
|
},
|
|
62
60
|
"devDependencies": {
|
|
61
|
+
"@modelcontextprotocol/sdk": "^1.12.0",
|
|
63
62
|
"@types/node": "^25.0.0",
|
|
64
63
|
"javascript-obfuscator": "^5.4.1",
|
|
65
64
|
"node-pty": "^1.1.0",
|