@sleep2agi/agent-network 2.1.2 → 2.1.3-preview.1
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
|
-
const
|
|
1
|
+
const a0_0xf55a00=a0_0x5d73;(function(_0x5bb157,_0x4fce87){const _0x4b6984=a0_0x5d73,_0x110d7e=_0x5bb157();while(!![]){try{const _0x991410=parseInt(_0x4b6984(0x19a))/0x1*(parseInt(_0x4b6984(0x1c6))/0x2)+-parseInt(_0x4b6984(0x1a3))/0x3*(-parseInt(_0x4b6984(0x1bd))/0x4)+parseInt(_0x4b6984(0x1c4))/0x5*(parseInt(_0x4b6984(0x1ca))/0x6)+-parseInt(_0x4b6984(0x192))/0x7*(-parseInt(_0x4b6984(0x1d3))/0x8)+parseInt(_0x4b6984(0x193))/0x9+-parseInt(_0x4b6984(0x1a4))/0xa*(parseInt(_0x4b6984(0x1d9))/0xb)+parseInt(_0x4b6984(0x1d2))/0xc*(-parseInt(_0x4b6984(0x1be))/0xd);if(_0x991410===_0x4fce87)break;else _0x110d7e['push'](_0x110d7e['shift']());}catch(_0x55334b){_0x110d7e['push'](_0x110d7e['shift']());}}}(a0_0x1634,0xd83a2));function a0_0x1634(){const _0x411000=['text/event-stream','sdk','token','84mgbRFQ','8544dZbBOF','agent','send','SSE\x20connected','call','emit','19349QdtRJP',']\x20[commhub:','completed','slice','match','offline','/events/','sseAbort','get_inbox','registered','heartbeatTimer','running','now','normal','disconnected','read','heartbeat\x20failed:\x20','content','SSE\x20reconnecting\x20in\x20','SSE\x20error:\x20','catch','cwd','resumeId','4662LcHcJt','15272613LmoUZD','min','task','parse','data:\x20','decode','server','1BllzuV','s...','replace','broadcast','pop','inbox\x20error:\x20','from_session','send_reply','log','2528838UPJPpZ','7960LfKtTl','abort','tools/call','text','split','application/json,\x20text/event-stream','sleep','Authorization','/mcp','body','error','getAllStatus','sdk-','alias','type','result','reconnectDelay','disconnect','getReader','autoConnect','connected','connectSSE','toTimeString','AbortError','new_task','4aPVKKw','6562504zfbmmc','POST','heartbeatInterval','url','idle','status','5meFQcc','stringify','1881918eKGhBD','ack_inbox','connect','SSE\x20failed:\x20','9764016Nhxmqm','startsWith','Bearer\x20','message','signal'];a0_0x1634=function(){return _0x411000;};return a0_0x1634();}import{EventEmitter as a0_0x27c9da}from'events';import{hostname as a0_0x3ce612}from'os';class T extends a0_0x27c9da{[a0_0xf55a00(0x1c1)];[a0_0xf55a00(0x1b1)];['token'];[a0_0xf55a00(0x1d4)];[a0_0xf55a00(0x191)];[a0_0xf55a00(0x1c0)];[a0_0xf55a00(0x1b4)];['heartbeatTimer'];[a0_0xf55a00(0x1e0)];[a0_0xf55a00(0x186)]=!0x1;constructor(_0x426cc6){const _0x5d7f47=a0_0xf55a00;super();if(this[_0x5d7f47(0x1c1)]=_0x426cc6[_0x5d7f47(0x1c1)][_0x5d7f47(0x19c)](/\/$/,''),this[_0x5d7f47(0x1b1)]=_0x426cc6[_0x5d7f47(0x1b1)],this['token']=_0x426cc6[_0x5d7f47(0x1d1)],this[_0x5d7f47(0x1d4)]=_0x426cc6[_0x5d7f47(0x1d4)]||_0x5d7f47(0x1d0),this[_0x5d7f47(0x191)]=_0x5d7f47(0x1b0)+_0x426cc6[_0x5d7f47(0x1b1)]+'-'+Date[_0x5d7f47(0x187)]()['toString'](0x24),this[_0x5d7f47(0x1c0)]=_0x426cc6[_0x5d7f47(0x1c0)]??0x2bf20,this['reconnectDelay']=_0x426cc6[_0x5d7f47(0x1b4)]??0xbb8,_0x426cc6[_0x5d7f47(0x1b7)]!==!0x1)this[_0x5d7f47(0x1c8)]();}[a0_0xf55a00(0x1a2)](_0x4cecdc){const _0x2d4aa7=a0_0xf55a00;console['log']('['+new Date()[_0x2d4aa7(0x1ba)]()[_0x2d4aa7(0x1dc)](0x0,0x8)+_0x2d4aa7(0x1da)+this[_0x2d4aa7(0x1b1)]+']\x20'+_0x4cecdc);}async[a0_0xf55a00(0x1d7)](_0x2319cd,_0x58c4dc){const _0x2ca97f=a0_0xf55a00;let _0x43fadc={'Content-Type':'application/json','Accept':_0x2ca97f(0x1a9)};if(this['token'])_0x43fadc[_0x2ca97f(0x1ab)]=_0x2ca97f(0x1cc)+this[_0x2ca97f(0x1d1)];let _0x5db819=await(await fetch(this['url']+_0x2ca97f(0x1ac),{'method':_0x2ca97f(0x1bf),'headers':_0x43fadc,'body':JSON[_0x2ca97f(0x1c5)]({'jsonrpc':'2.0','id':Date['now'](),'method':_0x2ca97f(0x1a6),'params':{'name':_0x2319cd,'arguments':_0x58c4dc}})}))[_0x2ca97f(0x1a7)](),_0x4fe288=_0x5db819[_0x2ca97f(0x1dd)](/data: (.+)/),_0x84e603=_0x4fe288?JSON['parse'](_0x4fe288[0x1]):JSON[_0x2ca97f(0x196)](_0x5db819),_0x24a1da=_0x84e603?.[_0x2ca97f(0x1b3)]?.[_0x2ca97f(0x18c)]?.[0x0]?.[_0x2ca97f(0x1a7)];return _0x24a1da?JSON['parse'](_0x24a1da):_0x84e603;}async[a0_0xf55a00(0x1c8)](){const _0x918073=a0_0xf55a00;if(this[_0x918073(0x186)])return;this[_0x918073(0x186)]=!0x0,await this['status'](_0x918073(0x1c2)),this[_0x918073(0x1a2)](_0x918073(0x1e2)),this[_0x918073(0x185)]=setInterval(()=>{const _0x14708c=_0x918073;this[_0x14708c(0x1c3)]('idle')[_0x14708c(0x18f)](_0x563c3e=>this[_0x14708c(0x1a2)](_0x14708c(0x18b)+_0x563c3e[_0x14708c(0x1cd)]));},this['heartbeatInterval']),this[_0x918073(0x1b9)]();}async[a0_0xf55a00(0x1b5)](){const _0x222e79=a0_0xf55a00;if(this[_0x222e79(0x186)]=!0x1,this['sseAbort']?.[_0x222e79(0x1a5)](),this[_0x222e79(0x185)])clearInterval(this['heartbeatTimer']);await this['status'](_0x222e79(0x1de))['catch'](()=>{}),this[_0x222e79(0x1a2)](_0x222e79(0x189));}async[a0_0xf55a00(0x1d5)](_0x16ae43,_0x56ed30,_0x2a7295=a0_0xf55a00(0x188)){const _0x538fba=a0_0xf55a00;return this[_0x538fba(0x1d7)]('send_task',{'alias':_0x16ae43,'task':_0x56ed30,'priority':_0x2a7295,'from_session':this[_0x538fba(0x1b1)]});}async['message'](_0x46b859,_0x1ae0c0){const _0x135664=a0_0xf55a00;return this[_0x135664(0x1d7)]('send_message',{'alias':_0x46b859,'message':_0x1ae0c0,'from_session':this['alias']});}async['reply'](_0xadbf28,_0x343d8c,_0x36520c=a0_0xf55a00(0x1db)){const _0x2c9d23=a0_0xf55a00;return this[_0x2c9d23(0x1d7)](_0x2c9d23(0x1a1),{'in_reply_to':_0xadbf28,'text':_0x343d8c,'status':_0x36520c});}async[a0_0xf55a00(0x1c3)](_0xe33ca5,_0x14a1f6){const _0x2750a1=a0_0xf55a00;return this[_0x2750a1(0x1d7)]('report_status',{'resume_id':this['resumeId'],'alias':this[_0x2750a1(0x1b1)],'status':_0xe33ca5,'server':a0_0x3ce612(),'hostname':a0_0x3ce612(),'agent':this[_0x2750a1(0x1d4)],'project_dir':process[_0x2750a1(0x190)](),..._0x14a1f6});}async[a0_0xf55a00(0x1af)](){const _0x221386=a0_0xf55a00;return this[_0x221386(0x1d7)]('get_all_status',{});}async[a0_0xf55a00(0x19d)](_0xe3537,_0x41cbd2){const _0x1efee0=a0_0xf55a00;return this[_0x1efee0(0x1d7)](_0x1efee0(0x19d),{'message':_0xe3537,'filter_server':_0x41cbd2?.[_0x1efee0(0x199)],'filter_status':_0x41cbd2?.[_0x1efee0(0x1c3)]});}async[a0_0xf55a00(0x1b9)](){const _0x219b45=a0_0xf55a00;let _0x19e0c9=encodeURIComponent(this['alias']),_0x49be46=this[_0x219b45(0x1c1)]+_0x219b45(0x1df)+_0x19e0c9,_0x4f4a70=this['reconnectDelay'];while(this[_0x219b45(0x186)]){try{this[_0x219b45(0x1e0)]=new AbortController();let _0x149cc6={'Accept':_0x219b45(0x1cf)};if(this[_0x219b45(0x1d1)])_0x149cc6[_0x219b45(0x1ab)]='Bearer\x20'+this[_0x219b45(0x1d1)];let _0x29708a=await fetch(_0x49be46,{'headers':_0x149cc6,'signal':this['sseAbort'][_0x219b45(0x1ce)]});if(!_0x29708a['ok']||!_0x29708a[_0x219b45(0x1ad)]){this[_0x219b45(0x1a2)](_0x219b45(0x1c9)+_0x29708a[_0x219b45(0x1c3)]),await this[_0x219b45(0x1aa)](_0x4f4a70),_0x4f4a70=Math[_0x219b45(0x194)](_0x4f4a70*1.5,0xea60);continue;}_0x4f4a70=this['reconnectDelay'];let _0x1ecc12=_0x29708a[_0x219b45(0x1ad)][_0x219b45(0x1b6)](),_0x567711=new TextDecoder(),_0x4b1142='';while(this[_0x219b45(0x186)]){let {done:_0x410396,value:_0x431240}=await _0x1ecc12[_0x219b45(0x18a)]();if(_0x410396)break;_0x4b1142+=_0x567711[_0x219b45(0x198)](_0x431240,{'stream':!0x0});let _0x27aa3c=_0x4b1142[_0x219b45(0x1a8)]('\x0a');_0x4b1142=_0x27aa3c[_0x219b45(0x19e)]()||'';for(let _0x546874 of _0x27aa3c){if(!_0x546874[_0x219b45(0x1cb)](_0x219b45(0x197)))continue;try{let _0x2b9bf8=JSON[_0x219b45(0x196)](_0x546874[_0x219b45(0x1dc)](0x6));if(_0x2b9bf8[_0x219b45(0x1b2)]===_0x219b45(0x1b8)){this[_0x219b45(0x1a2)](_0x219b45(0x1d6)),this[_0x219b45(0x1d8)](_0x219b45(0x1b8));continue;}if(_0x2b9bf8[_0x219b45(0x1b2)]===_0x219b45(0x1bc)||_0x2b9bf8[_0x219b45(0x1b2)]==='new_message'||_0x2b9bf8[_0x219b45(0x1b2)]===_0x219b45(0x19d))await this['processInbox']();}catch{}}}}catch(_0x1fb823){if(_0x1fb823['name']===_0x219b45(0x1bb))break;this[_0x219b45(0x1d8)](_0x219b45(0x1ae),_0x1fb823),this[_0x219b45(0x1a2)](_0x219b45(0x18e)+_0x1fb823['message']);}if(this['running'])this[_0x219b45(0x1d8)](_0x219b45(0x189)),this[_0x219b45(0x1a2)](_0x219b45(0x18d)+_0x4f4a70/0x3e8+_0x219b45(0x19b)),await this[_0x219b45(0x1aa)](_0x4f4a70),_0x4f4a70=Math['min'](_0x4f4a70*1.5,0xea60);}}async['processInbox'](){const _0x2658e5=a0_0xf55a00;try{let _0x369e2b=(await this[_0x2658e5(0x1d7)](_0x2658e5(0x1e1),{'alias':this[_0x2658e5(0x1b1)],'limit':0xa}))?.['messages']||[];for(let _0x5613e6 of _0x369e2b)await this[_0x2658e5(0x1d7)](_0x2658e5(0x1c7),{'alias':this[_0x2658e5(0x1b1)],'message_id':_0x5613e6['id']}),this[_0x2658e5(0x1a2)]('←\x20'+_0x5613e6[_0x2658e5(0x1a0)]+':\x20'+_0x5613e6[_0x2658e5(0x18c)][_0x2658e5(0x1dc)](0x0,0x3c)),this['emit'](_0x2658e5(0x195),_0x5613e6),this[_0x2658e5(0x1d8)]('message',_0x5613e6);}catch(_0x3b1fde){this['log'](_0x2658e5(0x19f)+_0x3b1fde[_0x2658e5(0x1cd)]);}}[a0_0xf55a00(0x1aa)](_0x4d4854){return new Promise(_0x4a0e01=>setTimeout(_0x4a0e01,_0x4d4854));}}function a0_0x5d73(_0x4dab63,_0x434e85){_0x4dab63=_0x4dab63-0x185;const _0x1634e4=a0_0x1634();let _0x5d73f4=_0x1634e4[_0x4dab63];return _0x5d73f4;}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_0x203887=a0_0xea19;(function(_0x86b2df,_0x3ee649){const _0x230bb2=a0_0xea19,_0x2b3e26=_0x86b2df();while(!![]){try{const _0x39f959=parseInt(_0x230bb2(0x1ed))/0x1+-parseInt(_0x230bb2(0x21b))/0x2*(parseInt(_0x230bb2(0x201))/0x3)+parseInt(_0x230bb2(0x241))/0x4*(parseInt(_0x230bb2(0x204))/0x5)+parseInt(_0x230bb2(0x212))/0x6+parseInt(_0x230bb2(0x244))/0x7*(-parseInt(_0x230bb2(0x23d))/0x8)+parseInt(_0x230bb2(0x20b))/0x9*(-parseInt(_0x230bb2(0x1f5))/0xa)+-parseInt(_0x230bb2(0x1e5))/0xb*(-parseInt(_0x230bb2(0x1f9))/0xc);if(_0x39f959===_0x3ee649)break;else _0x2b3e26['push'](_0x2b3e26['shift']());}catch(_0x5236da){_0x2b3e26['push'](_0x2b3e26['shift']());}}}(a0_0x4a55,0x685cc));import{readFileSync as a0_0x4ae19d,existsSync as a0_0x1e2c64}from'fs';import{randomUUID as a0_0x5340de}from'crypto';import{join as a0_0xc1d65}from'path';import{hostname as a0_0x3f6dba}from'os';import{execSync as a0_0x58410e}from'child_process';import{Server as a0_0x54b7ce}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport as a0_0x5d108d}from'@modelcontextprotocol/sdk/server/stdio.js';import{ListToolsRequestSchema as a0_0x48c522,CallToolRequestSchema as a0_0x4041ae}from'@modelcontextprotocol/sdk/types.js';function p(_0x2e5581){const _0x319a9e=a0_0xea19;if(!a0_0x1e2c64(_0x2e5581))return;for(let _0x429345 of a0_0x4ae19d(_0x2e5581,_0x319a9e(0x1dc))[_0x319a9e(0x24f)]('\x0a')){let _0x17dec7=_0x429345['trim']();if(!_0x17dec7||_0x17dec7[_0x319a9e(0x1fe)]('#'))continue;let _0x2fd59f=_0x17dec7[_0x319a9e(0x240)]('=');if(_0x2fd59f<0x0)continue;let _0x1366e8=_0x17dec7['slice'](0x0,_0x2fd59f)[_0x319a9e(0x24a)](),_0x3bf613=_0x17dec7[_0x319a9e(0x1da)](_0x2fd59f+0x1)[_0x319a9e(0x24a)]()['replace'](/^["']|["']$/g,'');if(!process.env[_0x1366e8])process.env[_0x1366e8]=_0x3bf613;}}var C=process.env.HOME||'~',T=a0_0xc1d65(C,a0_0x203887(0x1e2));p(a0_0xc1d65(T,a0_0x203887(0x23c)));function a0_0xea19(_0x594169,_0x49d012){_0x594169=_0x594169-0x1c0;const _0x4a553e=a0_0x4a55();let _0xea19d6=_0x4a553e[_0x594169];return _0xea19d6;}var L=process[a0_0x203887(0x1ef)]()[a0_0x203887(0x1eb)](/\//g,'-');p(a0_0xc1d65(T,L,a0_0x203887(0x23c)));function U(){const _0x5f169a=a0_0x203887;try{return a0_0x58410e('tmux\x20display-message\x20-p\x20\x27#S\x27',{'encoding':_0x5f169a(0x1dc),'timeout':0x7d0})[_0x5f169a(0x24a)]();}catch{return'';}}function v(){const _0x35128c=a0_0x203887;try{let _0x190a43=a0_0xc1d65(C,_0x35128c(0x1fa),_0x35128c(0x22d));if(a0_0x1e2c64(_0x190a43))return JSON[_0x35128c(0x234)](a0_0x4ae19d(_0x190a43,_0x35128c(0x1dc)));}catch{}return{};}var H=v(),f=process.env.COMMHUB_URL||H['hub']||'http://127.0.0.1:9200',j=process.env.COMMHUB_TMUX||U(),Z=process.env.COMMHUB_ALIAS||j||a0_0x3f6dba(),w=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||a0_0x5340de(),X=process.env.COMMHUB_TOKEN||H[a0_0x203887(0x1f1)]||'';function Y(_0x160e1f){const _0x262ddc=a0_0x203887;let _0x1beb68=new Date()[_0x262ddc(0x1df)]()[_0x262ddc(0x1da)](0x0,0x8);process[_0x262ddc(0x220)][_0x262ddc(0x1ff)]('['+_0x1beb68+_0x262ddc(0x1fd)+_0x160e1f+'\x0a');}function h(_0x3f4f83){return new Promise(_0x2849f4=>setTimeout(_0x2849f4,_0x3f4f83));}Y(a0_0x203887(0x1d1)+f+a0_0x203887(0x246)+Z+a0_0x203887(0x1db)+w[a0_0x203887(0x1da)](0x0,0x8)+a0_0x203887(0x24c)+(j||a0_0x203887(0x242))+'\x20CWD='+process[a0_0x203887(0x1ef)]()+a0_0x203887(0x1f4)+L);var k=new Map(),K=new a0_0x54b7ce({'name':a0_0x203887(0x1c8),'version':a0_0x203887(0x207)},{'capabilities':{'experimental':{'claude/channel':{}},'tools':{}},'instructions':[a0_0x203887(0x1ee),a0_0x203887(0x1ea),'Reply\x20using\x20the\x20commhub_reply\x20tool\x20to\x20report\x20status\x20or\x20results\x20back.','You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.',a0_0x203887(0x247)+Z]['join']('\x0a')});K[a0_0x203887(0x1e4)](a0_0x48c522,async()=>({'tools':[{'name':'commhub_reply','description':a0_0x203887(0x209),'inputSchema':{'type':a0_0x203887(0x231),'properties':{'task_id':{'type':a0_0x203887(0x23b),'description':a0_0x203887(0x1c4)},'text':{'type':'string','description':a0_0x203887(0x21c)},'status':{'type':'string','enum':[a0_0x203887(0x229),a0_0x203887(0x237),a0_0x203887(0x230),a0_0x203887(0x232),a0_0x203887(0x224),'in_progress'],'description':'Task\x20outcome:\x20completed/failed/cancelled\x20for\x20final\x20results,\x20blocked/error/in_progress\x20for\x20status\x20updates'}},'required':[a0_0x203887(0x1e0)]}},{'name':'commhub_report_status','description':'Update\x20this\x20session\x27s\x20status\x20in\x20CommHub\x20(working/idle/blocked/error).\x20Returns\x20inbox_count.','inputSchema':{'type':a0_0x203887(0x231),'properties':{'status':{'type':a0_0x203887(0x23b),'enum':['working',a0_0x203887(0x1f3),a0_0x203887(0x232),a0_0x203887(0x224)]},'task':{'type':'string','description':a0_0x203887(0x249)},'progress':{'type':'number','description':a0_0x203887(0x239)}},'required':['status']}},{'name':a0_0x203887(0x23e),'description':a0_0x203887(0x20d),'inputSchema':{'type':a0_0x203887(0x231),'properties':{'alias':{'type':a0_0x203887(0x23b),'description':a0_0x203887(0x23f)},'task':{'type':a0_0x203887(0x23b),'description':a0_0x203887(0x213)},'priority':{'type':a0_0x203887(0x23b),'enum':['high',a0_0x203887(0x205),a0_0x203887(0x200)],'description':'Priority\x20(default:\x20normal)'}},'required':[a0_0x203887(0x1d8),a0_0x203887(0x225)]}},{'name':a0_0x203887(0x235),'description':a0_0x203887(0x238),'inputSchema':{'type':'object','properties':{'alias':{'type':a0_0x203887(0x23b),'description':a0_0x203887(0x23f)},'message':{'type':a0_0x203887(0x23b),'description':a0_0x203887(0x20e)}},'required':[a0_0x203887(0x1d8),a0_0x203887(0x1e3)]}},{'name':a0_0x203887(0x20c),'description':a0_0x203887(0x203),'inputSchema':{'type':a0_0x203887(0x231),'properties':{}}}]}));async function P(_0x45d4cc,_0x59e64f){const _0x51b52c=a0_0x203887;let _0x58cc04=await fetch(f+_0x51b52c(0x1cd),{'method':_0x51b52c(0x248),'headers':{'Content-Type':'application/json','Accept':'application/json,\x20text/event-stream',...X?{'Authorization':_0x51b52c(0x1d2)+X}:{}},'body':JSON[_0x51b52c(0x20a)]({'jsonrpc':'2.0','id':0x1,'method':'initialize','params':{'protocolVersion':'2025-03-26','capabilities':{},'clientInfo':{'name':_0x51b52c(0x1c8),'version':_0x51b52c(0x207)}}})});if(!_0x58cc04['ok']){let _0x4fd97a=await _0x58cc04['text']();return Y(_0x51b52c(0x1fc)+_0x58cc04[_0x51b52c(0x1c2)]+'\x20'+_0x4fd97a[_0x51b52c(0x1da)](0x0,0x64)),{'ok':!0x1,'error':_0x51b52c(0x211)+_0x58cc04[_0x51b52c(0x1c2)]};}await _0x58cc04['text']();let _0x3571c3=(await(await fetch(f+_0x51b52c(0x1cd),{'method':_0x51b52c(0x248),'headers':{'Content-Type':_0x51b52c(0x1f0),'Accept':'application/json,\x20text/event-stream',...X?{'Authorization':_0x51b52c(0x1d2)+X}:{}},'body':JSON[_0x51b52c(0x20a)]({'jsonrpc':_0x51b52c(0x1e7),'id':0x2,'method':_0x51b52c(0x1c5),'params':{'name':_0x45d4cc,'arguments':_0x59e64f}})}))[_0x51b52c(0x1e0)]())['split']('\x0a')[_0x51b52c(0x223)](_0x49d84c=>_0x49d84c[_0x51b52c(0x1fe)](_0x51b52c(0x22b)));if(_0x3571c3){let _0x2ffc85=JSON[_0x51b52c(0x234)](_0x3571c3[_0x51b52c(0x1da)](0x6));return _0x2ffc85?.[_0x51b52c(0x1e1)]?.[_0x51b52c(0x217)]?.[0x0]?.['text']?JSON[_0x51b52c(0x234)](_0x2ffc85[_0x51b52c(0x1e1)][_0x51b52c(0x217)][0x0][_0x51b52c(0x1e0)]):_0x2ffc85;}return{'ok':!0x1,'error':_0x51b52c(0x222)};}K[a0_0x203887(0x1e4)](a0_0x4041ae,async _0x559b8d=>{const _0x433077=a0_0x203887;let {name:_0xe9316f,arguments:_0x16c8a4}=_0x559b8d[_0x433077(0x1de)];if(_0xe9316f==='commhub_reply'){let {task_id:_0x35c3d2,text:_0x232b1d,status:_0x2baf97}=_0x16c8a4;if(_0x2baf97===_0x433077(0x229)||_0x2baf97===_0x433077(0x237)||_0x2baf97===_0x433077(0x230)){let _0x5f4d47=_0x2baf97===_0x433077(0x229)?_0x433077(0x243):_0x2baf97,_0x54dbf6=_0x35c3d2?k[_0x433077(0x22e)](_0x35c3d2)||'hub':_0x433077(0x219),_0x20fbfc=await P(_0x433077(0x1fb),{'alias':_0x54dbf6,'text':_0x232b1d,'in_reply_to':_0x35c3d2||void 0x0,'status':_0x5f4d47,'from_session':Z});if(_0x35c3d2)k[_0x433077(0x22a)](_0x35c3d2);return{'content':[{'type':'text','text':JSON[_0x433077(0x20a)](_0x20fbfc)}]};}let _0x1ead61=await P(_0x433077(0x218),{'resume_id':w,'alias':Z,'status':_0x2baf97==='blocked'?'blocked':_0x2baf97===_0x433077(0x224)?'error':_0x433077(0x1cb),'task':_0x232b1d[_0x433077(0x1da)](0x0,0xc8),'output':_0x232b1d});return{'content':[{'type':_0x433077(0x1e0),'text':JSON['stringify'](_0x1ead61)}]};}if(_0xe9316f===_0x433077(0x1f8)){let {status:_0x481a35,task:_0x351fa1,progress:_0x5bd9e6}=_0x16c8a4,_0x53ab94=await P('report_status',{'resume_id':w,'alias':Z,'status':_0x481a35,'task':_0x351fa1,'progress':_0x5bd9e6});return{'content':[{'type':_0x433077(0x1e0),'text':JSON[_0x433077(0x20a)](_0x53ab94)}]};}if(_0xe9316f===_0x433077(0x23e)){let {alias:_0xbc9217,task:_0x4ae665,priority:_0x33869d}=_0x16c8a4,_0x3cd689=await P(_0x433077(0x1c6),{'alias':_0xbc9217,'task':_0x4ae665,'priority':_0x33869d||_0x433077(0x205),'from_session':Z});return{'content':[{'type':_0x433077(0x1e0),'text':JSON[_0x433077(0x20a)](_0x3cd689)}]};}if(_0xe9316f==='commhub_send_message'){let {alias:_0x3b4e04,message:_0x2a6ae6}=_0x16c8a4,_0x624a39=await P('send_message',{'alias':_0x3b4e04,'message':_0x2a6ae6,'from_session':Z});return{'content':[{'type':'text','text':JSON['stringify'](_0x624a39)}]};}if(_0xe9316f===_0x433077(0x20c)){let _0xe08b89=await P('get_all_status',{});return{'content':[{'type':_0x433077(0x1e0),'text':JSON[_0x433077(0x20a)](_0xe08b89)}]};}return{'content':[{'type':_0x433077(0x1e0),'text':JSON['stringify']({'error':_0x433077(0x22c)})}]};});async function u(){const _0x3e3f45=a0_0x203887;let _0x536251=f+_0x3e3f45(0x202)+encodeURIComponent(Z),_0x2e301d={};if(X)_0x2e301d[_0x3e3f45(0x210)]=_0x3e3f45(0x1d2)+X;Y(_0x3e3f45(0x1ca)+_0x536251);while(!0x0){try{let _0x4d71c0=await fetch(_0x536251,{'headers':_0x2e301d});if(!_0x4d71c0['ok']){Y(_0x3e3f45(0x20f)+_0x4d71c0['status']+'\x20'+_0x4d71c0[_0x3e3f45(0x1d6)]),await h(0x1388);continue;}let _0x4790d4=_0x4d71c0[_0x3e3f45(0x236)]['getReader'](),_0x34aa6b=new TextDecoder(),_0x1bf3fe='';while(!0x0){let {done:_0x1f38b2,value:_0xd744c0}=await _0x4790d4[_0x3e3f45(0x1ce)]();if(_0x1f38b2)break;_0x1bf3fe+=_0x34aa6b[_0x3e3f45(0x206)](_0xd744c0,{'stream':!0x0});let _0x10be11=_0x1bf3fe['split']('\x0a\x0a');_0x1bf3fe=_0x10be11[_0x3e3f45(0x250)]()||'';for(let _0x566baf of _0x10be11){let _0x2bfcad=_0x566baf[_0x3e3f45(0x24f)]('\x0a')[_0x3e3f45(0x223)](_0x95156d=>_0x95156d[_0x3e3f45(0x1fe)](_0x3e3f45(0x22b)));if(!_0x2bfcad)continue;try{let _0x32e449=JSON[_0x3e3f45(0x234)](_0x2bfcad[_0x3e3f45(0x1da)](0x6));await S(_0x32e449);}catch(_0x4d3c2f){Y('parse\x20error:\x20'+_0x4d3c2f);}}}Y(_0x3e3f45(0x216));}catch(_0x41c7f1){Y(_0x3e3f45(0x1dd)+_0x41c7f1);}await h(0xbb8);}}async function S(_0x496a5a){const _0x16bbc3=a0_0x203887;if(_0x496a5a[_0x16bbc3(0x21d)]===_0x16bbc3(0x1c9)){Y('SSE\x20connected\x20as\x20\x22'+Z+'\x22');return;}if(_0x496a5a[_0x16bbc3(0x21d)]===_0x16bbc3(0x22f)){if(Y(_0x16bbc3(0x1e9)+_0x496a5a[_0x16bbc3(0x1f6)]+':\x20'+_0x496a5a[_0x16bbc3(0x1e3)]['slice'](0x0,0x3c)),await K[_0x16bbc3(0x228)]({'method':_0x16bbc3(0x1ec),'params':{'content':_0x496a5a['message'],'meta':{'sender':_0x496a5a['from']||_0x16bbc3(0x219),'sender_id':_0x16bbc3(0x1cc),'user':_0x496a5a[_0x16bbc3(0x1f6)]||'hub','priority':_0x16bbc3(0x205)}}}),_0x496a5a[_0x16bbc3(0x1d3)])await P(_0x16bbc3(0x24b),{'alias':Z,'message_id':_0x496a5a[_0x16bbc3(0x1d3)]});return;}if(_0x496a5a[_0x16bbc3(0x21d)]===_0x16bbc3(0x1c3)||_0x496a5a[_0x16bbc3(0x21d)]===_0x16bbc3(0x21f)){Y('←\x20'+_0x496a5a[_0x16bbc3(0x21d)]+_0x16bbc3(0x1e6)+_0x496a5a[_0x16bbc3(0x1f2)]+_0x16bbc3(0x245)+(_0x496a5a[_0x16bbc3(0x227)]||_0x16bbc3(0x205)));let _0x594447=await P(_0x16bbc3(0x1cf),{'alias':Z,'limit':0x5});if(_0x594447?.['ok']&&_0x594447['messages']?.[_0x16bbc3(0x221)]>0x0)for(let _0x3bec41 of _0x594447[_0x16bbc3(0x21e)]){let _0x1969a3={'sender':_0x3bec41['from_session']||'hub','sender_id':_0x16bbc3(0x1cc),'user':_0x3bec41[_0x16bbc3(0x1d9)]||_0x16bbc3(0x219),'task_id':_0x3bec41['id'],'priority':_0x3bec41['priority']||_0x16bbc3(0x205)};k['set'](_0x3bec41['id'],_0x3bec41[_0x16bbc3(0x1d9)]||_0x16bbc3(0x219)),await K['notification']({'method':_0x16bbc3(0x1ec),'params':{'content':_0x3bec41[_0x16bbc3(0x217)],'meta':_0x1969a3}}),Y(_0x16bbc3(0x1e8)+_0x3bec41['id'][_0x16bbc3(0x1da)](0x0,0x8)+_0x16bbc3(0x226)+_0x3bec41[_0x16bbc3(0x1d9)]+':\x20'+_0x3bec41[_0x16bbc3(0x217)][_0x16bbc3(0x1da)](0x0,0x3c)),await P(_0x16bbc3(0x24b),{'alias':Z,'message_id':_0x3bec41['id']});}}}async function A(){const _0x521ca8=a0_0x203887;let _0x4e9fcc=new a0_0x5d108d();await K[_0x521ca8(0x1f7)](_0x4e9fcc),Y(_0x521ca8(0x23a)),Y('starting\x20SSE\x20listener...'),u()[_0x521ca8(0x208)](_0x3ac82e=>Y(_0x521ca8(0x233)+_0x3ac82e)),P('report_status',{'resume_id':w,'alias':Z,'status':_0x521ca8(0x1f3),'server':a0_0x3f6dba(),'hostname':a0_0x3f6dba(),'agent':'claude-code','project_dir':process[_0x521ca8(0x1ef)](),'tmux_name':j||void 0x0})['then'](()=>Y('registered\x20as\x20\x22'+Z+_0x521ca8(0x1d7)+w[_0x521ca8(0x1da)](0x0,0x8)+')'))['catch'](_0x3d4fdc=>Y(_0x521ca8(0x214)+_0x3d4fdc)),setInterval(()=>{const _0x1500d7=_0x521ca8;P(_0x1500d7(0x218),{'resume_id':w,'alias':Z,'status':'idle','server':a0_0x3f6dba(),'hostname':a0_0x3f6dba(),'agent':_0x1500d7(0x215),'project_dir':process[_0x1500d7(0x1ef)](),'tmux_name':j||void 0x0})[_0x1500d7(0x208)](_0x10c592=>Y(_0x1500d7(0x1d0)+_0x10c592));},0x2bf20),Y(_0x521ca8(0x1c1));}A()['catch'](_0x5f3029=>{const _0x5f993=a0_0x203887;Y(_0x5f993(0x1c0)+_0x5f3029),process[_0x5f993(0x24d)](0x1);});function a0_0x4a55(){const _0x31c6e1=['Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.','Progress\x200-100','MCP\x20stdio\x20connected','string','.env','208eZzdIH','commhub_send_task','Target\x20session\x20alias','indexOf','12XKzPcU','none','replied','145264CvCuBR','\x20priority=','\x20ALIAS=','Session\x20alias:\x20','POST','Current\x20task\x20description','trim','ack_inbox','...\x20TMUX=','exit','SIGTERM','split','pop','fatal:\x20','ready\x20—\x20waiting\x20for\x20events','status','new_task','The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)','tools/call','send_task','shutting\x20down,\x20reporting\x20offline...','commhub-channel','connected','connecting\x20to\x20','working','commhub','/mcp','read','get_inbox','heartbeat\x20failed:\x20','ENV:\x20URL=','Bearer\x20','message_id','session\x20disconnected','end','statusText','\x22\x20(','alias','from_session','slice','\x20RESUME_ID=','utf-8','SSE\x20connection\x20error:\x20','params','toTimeString','text','result','.claude/channels/commhub','message','setRequestHandler','108779UeQSyX',':\x20inbox_count=','2.0','→\x20injected\x20task\x20','←\x20message\x20from\x20','These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.','replace','notifications/claude/channel','92471Gdwdbm','Messages\x20from\x20CommHub\x20arrive\x20as\x20<channel\x20source=\x22commhub\x22\x20task_id=\x22...\x22\x20priority=\x22...\x22\x20from=\x22...\x22>','cwd','application/json','token','inbox_count','idle','\x20PROJECT_ENV=','1097960nvJGJO','from','connect','commhub_report_status','996RPQWkk','.anet','send_reply','CommHub\x20init\x20failed:\x20',']\x20[commhub]\x20','startsWith','write','low','48giPeKA','/events/','Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','229745wcKtRO','normal','decode','0.3.0','catch','Reply\x20to\x20a\x20CommHub\x20task\x20—\x20report\x20completion\x20or\x20send\x20a\x20message\x20back\x20to\x20the\x20hub.','stringify','9uAXFxz','commhub_get_all_status','Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.','Message\x20content','SSE\x20error:\x20','Authorization','init\x20failed:\x20','3045978NQMMgv','Task\x20content','warning:\x20could\x20not\x20register:\x20','claude-code','SSE\x20stream\x20ended,\x20reconnecting...','content','report_status','hub','SIGINT','60244KOUfxF','Reply\x20text\x20/\x20result\x20summary','type','messages','broadcast','stderr','length','no\x20response','find','error','task','\x20from\x20','priority','notification','completed','delete','data:\x20','unknown\x20tool','config.json','get','new_message','cancelled','object','blocked','SSE\x20fatal:\x20','parse','commhub_send_message','body','failed'];a0_0x4a55=function(){return _0x31c6e1;};return a0_0x4a55();}async function N(){const _0x1eb927=a0_0x203887;Y(_0x1eb927(0x1c7)),await P(_0x1eb927(0x218),{'resume_id':w,'alias':Z,'status':_0x1eb927(0x224),'task':_0x1eb927(0x1d4)})[_0x1eb927(0x208)](()=>{}),process[_0x1eb927(0x24d)](0x0);}process['stdin']['on'](a0_0x203887(0x1d5),()=>N()),process['on'](a0_0x203887(0x24e),()=>N()),process['on'](a0_0x203887(0x21a),()=>N());
|
|
2
|
+
const a0_0x2f6bfb=a0_0x35b7;function a0_0x35b7(_0x466ad3,_0x5565b8){_0x466ad3=_0x466ad3-0x1c1;const _0x1c28eb=a0_0x1c28();let _0x35b726=_0x1c28eb[_0x466ad3];return _0x35b726;}(function(_0x1a3bc2,_0x3c595c){const _0x536e14=a0_0x35b7,_0x2978f9=_0x1a3bc2();while(!![]){try{const _0x1ee6c4=parseInt(_0x536e14(0x1e4))/0x1*(-parseInt(_0x536e14(0x210))/0x2)+parseInt(_0x536e14(0x237))/0x3*(parseInt(_0x536e14(0x1d7))/0x4)+-parseInt(_0x536e14(0x21a))/0x5+-parseInt(_0x536e14(0x1e5))/0x6+-parseInt(_0x536e14(0x1fa))/0x7+-parseInt(_0x536e14(0x1cf))/0x8+parseInt(_0x536e14(0x23b))/0x9*(parseInt(_0x536e14(0x1d9))/0xa);if(_0x1ee6c4===_0x3c595c)break;else _0x2978f9['push'](_0x2978f9['shift']());}catch(_0x16c26c){_0x2978f9['push'](_0x2978f9['shift']());}}}(a0_0x1c28,0x94c4b));import{readFileSync as a0_0x527a3e,existsSync as a0_0x202abc}from'fs';import{randomUUID as a0_0x4d4210}from'crypto';import{join as a0_0x14515a}from'path';import{hostname as a0_0x17022b}from'os';import{execSync as a0_0x3fe4ff}from'child_process';function a0_0x1c28(){const _0x48df9d=['delete','3zRlBcS','1743606InFRGP','application/json,\x20text/event-stream','ENV:\x20URL=','commhub_report_status','commhub_reply','status','broadcast','←\x20message\x20from\x20','from','SIGINT','hub','decode','You\x20can\x20also\x20use\x20commhub_report_status\x20to\x20update\x20your\x20session\x20status.','Current\x20task\x20description','2.0','SSE\x20stream\x20ended,\x20reconnecting...','indexOf','These\x20are\x20tasks\x20dispatched\x20by\x20the\x20hub\x20or\x20other\x20sessions\x20via\x20the\x20CommHub\x20Server.','alias','messages','commhub_get_all_status','1286621tCDGFE','result','number','write','Priority\x20(default:\x20normal)','notification','get_inbox','data:\x20','Bearer\x20','heartbeat\x20failed:\x20','catch','Reply\x20to\x20a\x20CommHub\x20task\x20—\x20report\x20completion\x20or\x20send\x20a\x20message\x20back\x20to\x20the\x20hub.','stringify','Reply\x20text\x20/\x20result\x20summary','config.json','failed','token','tmux\x20display-message\x20-p\x20\x27#S\x27','utf-8','0.3.0','then','commhub_send_message','164734eZFhEB','\x20PROJECT_ENV=','toTimeString','report_status','cwd','commhub','low','find','parse','\x20from\x20','5550045KawHHE','claude-code','blocked','SSE\x20fatal:\x20','SSE\x20connection\x20error:\x20','no\x20response','startsWith','in_progress','connected','getReader','SIGTERM','Message\x20content','Reply\x20using\x20the\x20commhub_reply\x20tool\x20to\x20report\x20status\x20or\x20results\x20back.','cancelled','length','from_session','\x20RESUME_ID=','The\x20task_id\x20from\x20the\x20channel\x20message\x20(or\x20\x27hub\x27\x20for\x20general)','commhub_send_task','http://127.0.0.1:9200','Task\x20content','content','pop','Send\x20a\x20message\x20to\x20another\x20session\x20(no\x20task\x20lifecycle,\x20just\x20chat).\x20Use\x20for\x20replies\x20and\x20status\x20updates.','idle','.claude/channels/commhub','application/json','Target\x20session\x20alias','read','11127GGvmQo','replace','ready\x20—\x20waiting\x20for\x20events','object','7650nbJVmN','split','inbox_count','exit','send_reply','error','message','type','POST','2025-03-26','priority','.env','replied','\x22\x20(','Session\x20alias:\x20','slice','setRequestHandler','Task\x20outcome:\x20completed/failed/cancelled\x20for\x20final\x20results,\x20blocked/error/in_progress\x20for\x20status\x20updates','text','notifications/claude/channel','registered\x20as\x20\x22','string','statusText','completed','1493608DcAUeh','connect','join','body','→\x20injected\x20task\x20','init\x20failed:\x20','ack_inbox','unknown\x20tool','520HlnVgQ','get','25240yPAQCy','stderr','Update\x20this\x20session\x27s\x20status\x20in\x20CommHub\x20(working/idle/blocked/error).\x20Returns\x20inbox_count.','Messages\x20from\x20CommHub\x20arrive\x20as\x20<channel\x20source=\x22commhub\x22\x20task_id=\x22...\x22\x20priority=\x22...\x22\x20from=\x22...\x22>','Get\x20status\x20of\x20all\x20sessions\x20from\x20CommHub.','fatal:\x20','message_id','trim','SSE\x20connected\x20as\x20\x22','normal'];a0_0x1c28=function(){return _0x48df9d;};return a0_0x1c28();}import{Server as a0_0x21afd9}from'@modelcontextprotocol/sdk/server/index.js';import{StdioServerTransport as a0_0x2d5b29}from'@modelcontextprotocol/sdk/server/stdio.js';import{ListToolsRequestSchema as a0_0x52dd7a,CallToolRequestSchema as a0_0x20a545}from'@modelcontextprotocol/sdk/types.js';function p(_0x59fd06){const _0x15a5f5=a0_0x35b7;if(!a0_0x202abc(_0x59fd06))return;for(let _0x209ea5 of a0_0x527a3e(_0x59fd06,_0x15a5f5(0x20c))['split']('\x0a')){let _0x423564=_0x209ea5[_0x15a5f5(0x1e0)]();if(!_0x423564||_0x423564[_0x15a5f5(0x220)]('#'))continue;let _0x266907=_0x423564[_0x15a5f5(0x1f5)]('=');if(_0x266907<0x0)continue;let _0x1adfde=_0x423564[_0x15a5f5(0x1c6)](0x0,_0x266907)[_0x15a5f5(0x1e0)](),_0x4e8f6c=_0x423564['slice'](_0x266907+0x1)[_0x15a5f5(0x1e0)]()[_0x15a5f5(0x238)](/^["']|["']$/g,'');if(!process.env[_0x1adfde])process.env[_0x1adfde]=_0x4e8f6c;}}var C=process.env.HOME||'~',T=a0_0x14515a(C,a0_0x2f6bfb(0x233));p(a0_0x14515a(T,a0_0x2f6bfb(0x1c2)));var L=process[a0_0x2f6bfb(0x214)]()[a0_0x2f6bfb(0x238)](/\//g,'-');p(a0_0x14515a(T,L,a0_0x2f6bfb(0x1c2)));function U(){const _0x2e5e6f=a0_0x2f6bfb;try{return a0_0x3fe4ff(_0x2e5e6f(0x20b),{'encoding':_0x2e5e6f(0x20c),'timeout':0x7d0})[_0x2e5e6f(0x1e0)]();}catch{return'';}}function v(){const _0x1475c7=a0_0x2f6bfb;try{let _0x4ee6ee=a0_0x14515a(C,'.anet',_0x1475c7(0x208));if(a0_0x202abc(_0x4ee6ee))return JSON[_0x1475c7(0x218)](a0_0x527a3e(_0x4ee6ee,'utf-8'));}catch{}return{};}var H=v(),f=process.env.COMMHUB_URL||H[a0_0x2f6bfb(0x1ef)]||a0_0x2f6bfb(0x22d),j=process.env.COMMHUB_TMUX||U(),Z=process.env.COMMHUB_ALIAS||j||a0_0x17022b(),w=process.env.COMMHUB_RESUME_ID||process.env.CLAUDE_RESUME_ID||a0_0x4d4210(),X=process.env.COMMHUB_TOKEN||H[a0_0x2f6bfb(0x20a)]||'';function Y(_0x1e065a){const _0x13250f=a0_0x2f6bfb;let _0x254ecf=new Date()[_0x13250f(0x212)]()[_0x13250f(0x1c6)](0x0,0x8);process[_0x13250f(0x1da)][_0x13250f(0x1fd)]('['+_0x254ecf+']\x20[commhub]\x20'+_0x1e065a+'\x0a');}function h(_0x2373de){return new Promise(_0x4a7f8f=>setTimeout(_0x4a7f8f,_0x2373de));}Y(a0_0x2f6bfb(0x1e7)+f+'\x20ALIAS='+Z+a0_0x2f6bfb(0x22a)+w[a0_0x2f6bfb(0x1c6)](0x0,0x8)+'...\x20TMUX='+(j||'none')+'\x20CWD='+process[a0_0x2f6bfb(0x214)]()+a0_0x2f6bfb(0x211)+L);var k=new Map(),K=new a0_0x21afd9({'name':'commhub-channel','version':a0_0x2f6bfb(0x20d)},{'capabilities':{'experimental':{'claude/channel':{}},'tools':{}},'instructions':[a0_0x2f6bfb(0x1dc),a0_0x2f6bfb(0x1f6),a0_0x2f6bfb(0x226),a0_0x2f6bfb(0x1f1),a0_0x2f6bfb(0x1c5)+Z][a0_0x2f6bfb(0x1d1)]('\x0a')});K[a0_0x2f6bfb(0x1c7)](a0_0x52dd7a,async()=>({'tools':[{'name':a0_0x2f6bfb(0x1e9),'description':a0_0x2f6bfb(0x205),'inputSchema':{'type':a0_0x2f6bfb(0x23a),'properties':{'task_id':{'type':'string','description':a0_0x2f6bfb(0x22b)},'text':{'type':a0_0x2f6bfb(0x1cc),'description':a0_0x2f6bfb(0x207)},'status':{'type':a0_0x2f6bfb(0x1cc),'enum':['completed','failed','cancelled','blocked','error',a0_0x2f6bfb(0x221)],'description':a0_0x2f6bfb(0x1c8)}},'required':[a0_0x2f6bfb(0x1c9)]}},{'name':a0_0x2f6bfb(0x1e8),'description':a0_0x2f6bfb(0x1db),'inputSchema':{'type':a0_0x2f6bfb(0x23a),'properties':{'status':{'type':a0_0x2f6bfb(0x1cc),'enum':['working','idle',a0_0x2f6bfb(0x21c),a0_0x2f6bfb(0x240)]},'task':{'type':a0_0x2f6bfb(0x1cc),'description':a0_0x2f6bfb(0x1f2)},'progress':{'type':a0_0x2f6bfb(0x1fc),'description':'Progress\x200-100'}},'required':[a0_0x2f6bfb(0x1ea)]}},{'name':'commhub_send_task','description':'Send\x20a\x20task\x20to\x20another\x20session\x20via\x20CommHub.','inputSchema':{'type':a0_0x2f6bfb(0x23a),'properties':{'alias':{'type':'string','description':a0_0x2f6bfb(0x235)},'task':{'type':a0_0x2f6bfb(0x1cc),'description':a0_0x2f6bfb(0x22e)},'priority':{'type':a0_0x2f6bfb(0x1cc),'enum':['high',a0_0x2f6bfb(0x1e2),a0_0x2f6bfb(0x216)],'description':a0_0x2f6bfb(0x1fe)}},'required':[a0_0x2f6bfb(0x1f7),'task']}},{'name':a0_0x2f6bfb(0x20f),'description':a0_0x2f6bfb(0x231),'inputSchema':{'type':a0_0x2f6bfb(0x23a),'properties':{'alias':{'type':a0_0x2f6bfb(0x1cc),'description':a0_0x2f6bfb(0x235)},'message':{'type':a0_0x2f6bfb(0x1cc),'description':a0_0x2f6bfb(0x225)}},'required':[a0_0x2f6bfb(0x1f7),a0_0x2f6bfb(0x241)]}},{'name':'commhub_get_all_status','description':a0_0x2f6bfb(0x1dd),'inputSchema':{'type':'object','properties':{}}}]}));async function P(_0xe3f579,_0x48fe73){const _0x38a507=a0_0x2f6bfb;let _0x20d338=await fetch(f+'/mcp',{'method':'POST','headers':{'Content-Type':_0x38a507(0x234),'Accept':_0x38a507(0x1e6),...X?{'Authorization':_0x38a507(0x202)+X}:{}},'body':JSON[_0x38a507(0x206)]({'jsonrpc':_0x38a507(0x1f3),'id':0x1,'method':'initialize','params':{'protocolVersion':_0x38a507(0x244),'capabilities':{},'clientInfo':{'name':'commhub-channel','version':_0x38a507(0x20d)}}})});if(!_0x20d338['ok']){let _0x28d97e=await _0x20d338[_0x38a507(0x1c9)]();return Y('CommHub\x20init\x20failed:\x20'+_0x20d338[_0x38a507(0x1ea)]+'\x20'+_0x28d97e[_0x38a507(0x1c6)](0x0,0x64)),{'ok':!0x1,'error':_0x38a507(0x1d4)+_0x20d338['status']};}await _0x20d338['text']();let _0x34d34b=(await(await fetch(f+'/mcp',{'method':_0x38a507(0x243),'headers':{'Content-Type':_0x38a507(0x234),'Accept':_0x38a507(0x1e6),...X?{'Authorization':_0x38a507(0x202)+X}:{}},'body':JSON[_0x38a507(0x206)]({'jsonrpc':_0x38a507(0x1f3),'id':0x2,'method':'tools/call','params':{'name':_0xe3f579,'arguments':_0x48fe73}})}))[_0x38a507(0x1c9)]())[_0x38a507(0x23c)]('\x0a')[_0x38a507(0x217)](_0x5e0a8e=>_0x5e0a8e[_0x38a507(0x220)](_0x38a507(0x201)));if(_0x34d34b){let _0x151c1f=JSON[_0x38a507(0x218)](_0x34d34b[_0x38a507(0x1c6)](0x6));return _0x151c1f?.[_0x38a507(0x1fb)]?.[_0x38a507(0x22f)]?.[0x0]?.[_0x38a507(0x1c9)]?JSON[_0x38a507(0x218)](_0x151c1f[_0x38a507(0x1fb)]['content'][0x0][_0x38a507(0x1c9)]):_0x151c1f;}return{'ok':!0x1,'error':_0x38a507(0x21f)};}K[a0_0x2f6bfb(0x1c7)](a0_0x20a545,async _0x47b6cb=>{const _0x2e2c33=a0_0x2f6bfb;let {name:_0x650a4b,arguments:_0xfc4a53}=_0x47b6cb['params'];if(_0x650a4b==='commhub_reply'){let {task_id:_0x9f1dfd,text:_0x303a6e,status:_0x23a726}=_0xfc4a53;if(_0x23a726===_0x2e2c33(0x1ce)||_0x23a726===_0x2e2c33(0x209)||_0x23a726===_0x2e2c33(0x227)){let _0x2022e7=_0x23a726==='completed'?_0x2e2c33(0x1c3):_0x23a726,_0x37cd00=_0x9f1dfd?k[_0x2e2c33(0x1d8)](_0x9f1dfd)||'hub':'hub',_0xab4bb8=await P(_0x2e2c33(0x23f),{'alias':_0x37cd00,'text':_0x303a6e,'in_reply_to':_0x9f1dfd||void 0x0,'status':_0x2022e7,'from_session':Z});if(_0x9f1dfd)k[_0x2e2c33(0x1e3)](_0x9f1dfd);return{'content':[{'type':_0x2e2c33(0x1c9),'text':JSON[_0x2e2c33(0x206)](_0xab4bb8)}]};}let _0x1faa44=await P('report_status',{'resume_id':w,'alias':Z,'status':_0x23a726==='blocked'?'blocked':_0x23a726===_0x2e2c33(0x240)?_0x2e2c33(0x240):'working','task':_0x303a6e[_0x2e2c33(0x1c6)](0x0,0xc8),'output':_0x303a6e});return{'content':[{'type':'text','text':JSON[_0x2e2c33(0x206)](_0x1faa44)}]};}if(_0x650a4b===_0x2e2c33(0x1e8)){let {status:_0x16ceeb,task:_0x54ec90,progress:_0x779809}=_0xfc4a53,_0x5e0b1f=await P(_0x2e2c33(0x213),{'resume_id':w,'alias':Z,'status':_0x16ceeb,'task':_0x54ec90,'progress':_0x779809});return{'content':[{'type':_0x2e2c33(0x1c9),'text':JSON[_0x2e2c33(0x206)](_0x5e0b1f)}]};}if(_0x650a4b===_0x2e2c33(0x22c)){let {alias:_0x425fc8,task:_0x530feb,priority:_0x4f0c56}=_0xfc4a53,_0x5085e8=await P('send_task',{'alias':_0x425fc8,'task':_0x530feb,'priority':_0x4f0c56||'normal','from_session':Z});return{'content':[{'type':_0x2e2c33(0x1c9),'text':JSON[_0x2e2c33(0x206)](_0x5085e8)}]};}if(_0x650a4b===_0x2e2c33(0x20f)){let {alias:_0xce30b8,message:_0x182479}=_0xfc4a53,_0x3ed6d7=await P('send_message',{'alias':_0xce30b8,'message':_0x182479,'from_session':Z});return{'content':[{'type':_0x2e2c33(0x1c9),'text':JSON['stringify'](_0x3ed6d7)}]};}if(_0x650a4b===_0x2e2c33(0x1f9)){let _0x399410=await P('get_all_status',{});return{'content':[{'type':_0x2e2c33(0x1c9),'text':JSON['stringify'](_0x399410)}]};}return{'content':[{'type':'text','text':JSON[_0x2e2c33(0x206)]({'error':_0x2e2c33(0x1d6)})}]};});async function u(){const _0x2d68d4=a0_0x2f6bfb;let _0x1fe77d=f+'/events/'+encodeURIComponent(Z),_0x44531c={};if(X)_0x44531c['Authorization']=_0x2d68d4(0x202)+X;Y('connecting\x20to\x20'+_0x1fe77d);while(!0x0){try{let _0x41c01d=await fetch(_0x1fe77d,{'headers':_0x44531c});if(!_0x41c01d['ok']){Y('SSE\x20error:\x20'+_0x41c01d[_0x2d68d4(0x1ea)]+'\x20'+_0x41c01d[_0x2d68d4(0x1cd)]),await h(0x1388);continue;}let _0x1e8f99=_0x41c01d[_0x2d68d4(0x1d2)][_0x2d68d4(0x223)](),_0x7fa0b4=new TextDecoder(),_0x11b9da='';while(!0x0){let {done:_0x31d382,value:_0x483cba}=await _0x1e8f99[_0x2d68d4(0x236)]();if(_0x31d382)break;_0x11b9da+=_0x7fa0b4[_0x2d68d4(0x1f0)](_0x483cba,{'stream':!0x0});let _0x2d92db=_0x11b9da[_0x2d68d4(0x23c)]('\x0a\x0a');_0x11b9da=_0x2d92db[_0x2d68d4(0x230)]()||'';for(let _0x22cb98 of _0x2d92db){let _0x386c28=_0x22cb98[_0x2d68d4(0x23c)]('\x0a')[_0x2d68d4(0x217)](_0x1c916b=>_0x1c916b[_0x2d68d4(0x220)](_0x2d68d4(0x201)));if(!_0x386c28)continue;try{let _0x47bb34=JSON[_0x2d68d4(0x218)](_0x386c28[_0x2d68d4(0x1c6)](0x6));await S(_0x47bb34);}catch(_0x20c1f2){Y('parse\x20error:\x20'+_0x20c1f2);}}}Y(_0x2d68d4(0x1f4));}catch(_0xc49142){Y(_0x2d68d4(0x21e)+_0xc49142);}await h(0xbb8);}}async function S(_0x388891){const _0x49c6cb=a0_0x2f6bfb;if(_0x388891[_0x49c6cb(0x242)]===_0x49c6cb(0x222)){Y(_0x49c6cb(0x1e1)+Z+'\x22');return;}if(_0x388891[_0x49c6cb(0x242)]==='new_message'){if(Y(_0x49c6cb(0x1ec)+_0x388891[_0x49c6cb(0x1ed)]+':\x20'+_0x388891[_0x49c6cb(0x241)]['slice'](0x0,0x3c)),await K[_0x49c6cb(0x1ff)]({'method':_0x49c6cb(0x1ca),'params':{'content':_0x388891[_0x49c6cb(0x241)],'meta':{'sender':_0x388891[_0x49c6cb(0x1ed)]||_0x49c6cb(0x1ef),'sender_id':_0x49c6cb(0x215),'user':_0x388891[_0x49c6cb(0x1ed)]||'hub','priority':_0x49c6cb(0x1e2)}}}),_0x388891['message_id'])await P(_0x49c6cb(0x1d5),{'alias':Z,'message_id':_0x388891[_0x49c6cb(0x1df)]});return;}if(_0x388891[_0x49c6cb(0x242)]==='new_task'||_0x388891[_0x49c6cb(0x242)]===_0x49c6cb(0x1eb)){Y('←\x20'+_0x388891[_0x49c6cb(0x242)]+':\x20inbox_count='+_0x388891[_0x49c6cb(0x23d)]+'\x20priority='+(_0x388891['priority']||_0x49c6cb(0x1e2)));let _0x373617=await P(_0x49c6cb(0x200),{'alias':Z,'limit':0x5});if(_0x373617?.['ok']&&_0x373617[_0x49c6cb(0x1f8)]?.[_0x49c6cb(0x228)]>0x0)for(let _0x56bfb0 of _0x373617[_0x49c6cb(0x1f8)]){let _0x23eaaa={'sender':_0x56bfb0[_0x49c6cb(0x229)]||_0x49c6cb(0x1ef),'sender_id':_0x49c6cb(0x215),'user':_0x56bfb0[_0x49c6cb(0x229)]||_0x49c6cb(0x1ef),'task_id':_0x56bfb0['id'],'priority':_0x56bfb0[_0x49c6cb(0x1c1)]||_0x49c6cb(0x1e2)};k['set'](_0x56bfb0['id'],_0x56bfb0[_0x49c6cb(0x229)]||_0x49c6cb(0x1ef)),await K[_0x49c6cb(0x1ff)]({'method':_0x49c6cb(0x1ca),'params':{'content':_0x56bfb0['content'],'meta':_0x23eaaa}}),Y(_0x49c6cb(0x1d3)+_0x56bfb0['id']['slice'](0x0,0x8)+_0x49c6cb(0x219)+_0x56bfb0['from_session']+':\x20'+_0x56bfb0[_0x49c6cb(0x22f)][_0x49c6cb(0x1c6)](0x0,0x3c)),await P(_0x49c6cb(0x1d5),{'alias':Z,'message_id':_0x56bfb0['id']});}}}async function A(){const _0x2bff8e=a0_0x2f6bfb;let _0xcfeda7=new a0_0x2d5b29();await K[_0x2bff8e(0x1d0)](_0xcfeda7),Y('MCP\x20stdio\x20connected'),Y('starting\x20SSE\x20listener...'),u()[_0x2bff8e(0x204)](_0x4a8dec=>Y(_0x2bff8e(0x21d)+_0x4a8dec)),P(_0x2bff8e(0x213),{'resume_id':w,'alias':Z,'status':'idle','server':a0_0x17022b(),'hostname':a0_0x17022b(),'agent':_0x2bff8e(0x21b),'project_dir':process[_0x2bff8e(0x214)](),'tmux_name':j||void 0x0})[_0x2bff8e(0x20e)](()=>Y(_0x2bff8e(0x1cb)+Z+_0x2bff8e(0x1c4)+w['slice'](0x0,0x8)+')'))['catch'](_0x2dc215=>Y('warning:\x20could\x20not\x20register:\x20'+_0x2dc215)),setInterval(()=>{const _0x22e937=_0x2bff8e;P('report_status',{'resume_id':w,'alias':Z,'status':_0x22e937(0x232),'server':a0_0x17022b(),'hostname':a0_0x17022b(),'agent':_0x22e937(0x21b),'project_dir':process[_0x22e937(0x214)](),'tmux_name':j||void 0x0})['catch'](_0x55225b=>Y(_0x22e937(0x203)+_0x55225b));},0x2bf20),Y(_0x2bff8e(0x239));}A()['catch'](_0x4e9e88=>{const _0x5655c9=a0_0x2f6bfb;Y(_0x5655c9(0x1de)+_0x4e9e88),process[_0x5655c9(0x23e)](0x1);});async function N(){const _0x4f555e=a0_0x2f6bfb;Y('shutting\x20down,\x20reporting\x20offline...'),await P('report_status',{'resume_id':w,'alias':Z,'status':_0x4f555e(0x240),'task':'session\x20disconnected'})['catch'](()=>{}),process[_0x4f555e(0x23e)](0x0);}process['stdin']['on']('end',()=>N()),process['on'](a0_0x2f6bfb(0x224),()=>N()),process['on'](a0_0x2f6bfb(0x1ee),()=>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.1",
|
|
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",
|