@sleep2agi/agent-network 2.1.2 → 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.
@@ -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;
@@ -1 +1 @@
1
- const a0_0x3649cd=a0_0x2b65;(function(_0x362644,_0x592b17){const _0x2959d5=a0_0x2b65,_0x1d3385=_0x362644();while(!![]){try{const _0xc9a5f8=-parseInt(_0x2959d5(0x1a2))/0x1+-parseInt(_0x2959d5(0x192))/0x2*(parseInt(_0x2959d5(0x1ce))/0x3)+parseInt(_0x2959d5(0x1d3))/0x4+-parseInt(_0x2959d5(0x1c3))/0x5*(parseInt(_0x2959d5(0x18c))/0x6)+-parseInt(_0x2959d5(0x1ad))/0x7*(-parseInt(_0x2959d5(0x1b3))/0x8)+-parseInt(_0x2959d5(0x1af))/0x9*(parseInt(_0x2959d5(0x1d6))/0xa)+parseInt(_0x2959d5(0x1b4))/0xb;if(_0xc9a5f8===_0x592b17)break;else _0x1d3385['push'](_0x1d3385['shift']());}catch(_0x9b0386){_0x1d3385['push'](_0x1d3385['shift']());}}}(a0_0x3f5b,0x91402));function a0_0x3f5b(){const _0x5532f5=['body',']\x20[commhub:','2.0','578gQvLgq','text','reply','replace','pop','content','tools/call','cwd','/events/','name','registered','type','getAllStatus','Bearer\x20','parse','message','1187655hUIFSg','url','sleep','AbortError','connectSSE','call','SSE\x20failed:\x20','SSE\x20connected','token','server','disconnected','7qUNEJU','sdk','9JfSmJw','text/event-stream','split','POST','7986448PVPMcp','21675225SuRQdI','reconnectDelay','match','toTimeString','offline','startsWith','send_message','emit','normal','disconnect','processInbox','stringify','report_status','decode','SSE\x20error:\x20','25pTvJkB','new_task','alias','resumeId','error','data:\x20','heartbeatInterval','s...','min','get_all_status','toString','11733tWVjnp','connect','log','connected','agent','737216iyTXeG','broadcast','status','510900BACDHq','heartbeat\x20failed:\x20','now','new_message','Authorization','idle','heartbeatTimer','result','inbox\x20error:\x20','sseAbort','running','/mcp','autoConnect','completed','slice','abort','226938BuEjsr','send_task','SSE\x20reconnecting\x20in\x20'];a0_0x3f5b=function(){return _0x5532f5;};return a0_0x3f5b();}import{EventEmitter as a0_0x541063}from'events';import{hostname as a0_0xca84c6}from'os';class T extends a0_0x541063{[a0_0x3649cd(0x1a3)];[a0_0x3649cd(0x1c5)];[a0_0x3649cd(0x1aa)];['agent'];[a0_0x3649cd(0x1c6)];['heartbeatInterval'];['reconnectDelay'];[a0_0x3649cd(0x1dc)];[a0_0x3649cd(0x1df)];[a0_0x3649cd(0x1e0)]=!0x1;constructor(_0x480800){const _0x2882bf=a0_0x3649cd;super();if(this[_0x2882bf(0x1a3)]=_0x480800[_0x2882bf(0x1a3)][_0x2882bf(0x195)](/\/$/,''),this[_0x2882bf(0x1c5)]=_0x480800['alias'],this['token']=_0x480800[_0x2882bf(0x1aa)],this[_0x2882bf(0x1d2)]=_0x480800[_0x2882bf(0x1d2)]||_0x2882bf(0x1ae),this[_0x2882bf(0x1c6)]='sdk-'+_0x480800[_0x2882bf(0x1c5)]+'-'+Date[_0x2882bf(0x1d8)]()[_0x2882bf(0x1cd)](0x24),this['heartbeatInterval']=_0x480800[_0x2882bf(0x1c9)]??0x2bf20,this[_0x2882bf(0x1b5)]=_0x480800[_0x2882bf(0x1b5)]??0xbb8,_0x480800[_0x2882bf(0x188)]!==!0x1)this[_0x2882bf(0x1cf)]();}[a0_0x3649cd(0x1d0)](_0x357428){const _0x8102fe=a0_0x3649cd;console[_0x8102fe(0x1d0)]('['+new Date()[_0x8102fe(0x1b7)]()[_0x8102fe(0x18a)](0x0,0x8)+_0x8102fe(0x190)+this[_0x8102fe(0x1c5)]+']\x20'+_0x357428);}async[a0_0x3649cd(0x1a7)](_0x3247b3,_0xdd10b0){const _0x574a8d=a0_0x3649cd;let _0x33cc21={'Content-Type':'application/json','Accept':'application/json,\x20text/event-stream'};if(this[_0x574a8d(0x1aa)])_0x33cc21[_0x574a8d(0x1da)]=_0x574a8d(0x19f)+this[_0x574a8d(0x1aa)];let _0x18e03c=await(await fetch(this[_0x574a8d(0x1a3)]+_0x574a8d(0x187),{'method':_0x574a8d(0x1b2),'headers':_0x33cc21,'body':JSON[_0x574a8d(0x1bf)]({'jsonrpc':_0x574a8d(0x191),'id':Date[_0x574a8d(0x1d8)](),'method':_0x574a8d(0x198),'params':{'name':_0x3247b3,'arguments':_0xdd10b0}})}))[_0x574a8d(0x193)](),_0x18a041=_0x18e03c[_0x574a8d(0x1b6)](/data: (.+)/),_0x7bbf61=_0x18a041?JSON[_0x574a8d(0x1a0)](_0x18a041[0x1]):JSON[_0x574a8d(0x1a0)](_0x18e03c),_0x57a823=_0x7bbf61?.[_0x574a8d(0x1dd)]?.[_0x574a8d(0x197)]?.[0x0]?.[_0x574a8d(0x193)];return _0x57a823?JSON['parse'](_0x57a823):_0x7bbf61;}async[a0_0x3649cd(0x1cf)](){const _0x1b79a3=a0_0x3649cd;if(this[_0x1b79a3(0x1e0)])return;this[_0x1b79a3(0x1e0)]=!0x0,await this[_0x1b79a3(0x1d5)](_0x1b79a3(0x1db)),this[_0x1b79a3(0x1d0)](_0x1b79a3(0x19c)),this['heartbeatTimer']=setInterval(()=>{const _0x1f03e0=_0x1b79a3;this[_0x1f03e0(0x1d5)](_0x1f03e0(0x1db))['catch'](_0x7a70a8=>this[_0x1f03e0(0x1d0)](_0x1f03e0(0x1d7)+_0x7a70a8[_0x1f03e0(0x1a1)]));},this[_0x1b79a3(0x1c9)]),this[_0x1b79a3(0x1a6)]();}async[a0_0x3649cd(0x1bd)](){const _0x1876d6=a0_0x3649cd;if(this['running']=!0x1,this['sseAbort']?.[_0x1876d6(0x18b)](),this[_0x1876d6(0x1dc)])clearInterval(this[_0x1876d6(0x1dc)]);await this['status'](_0x1876d6(0x1b8))['catch'](()=>{}),this[_0x1876d6(0x1d0)](_0x1876d6(0x1ac));}async['send'](_0x278180,_0x30ede9,_0x3b16c7=a0_0x3649cd(0x1bc)){const _0x397ba3=a0_0x3649cd;return this['call'](_0x397ba3(0x18d),{'alias':_0x278180,'task':_0x30ede9,'priority':_0x3b16c7,'from_session':this[_0x397ba3(0x1c5)]});}async[a0_0x3649cd(0x1a1)](_0x295e44,_0x52c6cc){const _0x532dbc=a0_0x3649cd;return this['call'](_0x532dbc(0x1ba),{'alias':_0x295e44,'message':_0x52c6cc,'from_session':this[_0x532dbc(0x1c5)]});}async[a0_0x3649cd(0x194)](_0x5d6ceb,_0x527b04,_0x437461=a0_0x3649cd(0x189)){const _0x5ebb7b=a0_0x3649cd;return this[_0x5ebb7b(0x1a7)](_0x5ebb7b(0x194),{'task_id':_0x5d6ceb,'text':_0x527b04,'status':_0x437461});}async[a0_0x3649cd(0x1d5)](_0x11219,_0x6b4c36){const _0x210f7d=a0_0x3649cd;return this[_0x210f7d(0x1a7)](_0x210f7d(0x1c0),{'resume_id':this[_0x210f7d(0x1c6)],'alias':this[_0x210f7d(0x1c5)],'status':_0x11219,'server':a0_0xca84c6(),'hostname':a0_0xca84c6(),'agent':this[_0x210f7d(0x1d2)],'project_dir':process[_0x210f7d(0x199)](),..._0x6b4c36});}async[a0_0x3649cd(0x19e)](){const _0x2c40ea=a0_0x3649cd;return this[_0x2c40ea(0x1a7)](_0x2c40ea(0x1cc),{});}async[a0_0x3649cd(0x1d4)](_0x52564a,_0x312a04){const _0x4641e9=a0_0x3649cd;return this[_0x4641e9(0x1a7)]('broadcast',{'message':_0x52564a,'filter_server':_0x312a04?.[_0x4641e9(0x1ab)],'filter_status':_0x312a04?.[_0x4641e9(0x1d5)]});}async[a0_0x3649cd(0x1a6)](){const _0x1a1dc5=a0_0x3649cd;let _0x2b5f6=encodeURIComponent(this[_0x1a1dc5(0x1c5)]),_0x4d2e2b=this[_0x1a1dc5(0x1a3)]+_0x1a1dc5(0x19a)+_0x2b5f6,_0x6b58ac=this[_0x1a1dc5(0x1b5)];while(this['running']){try{this[_0x1a1dc5(0x1df)]=new AbortController();let _0x3064b0={'Accept':_0x1a1dc5(0x1b0)};if(this[_0x1a1dc5(0x1aa)])_0x3064b0[_0x1a1dc5(0x1da)]=_0x1a1dc5(0x19f)+this[_0x1a1dc5(0x1aa)];let _0x58b0d5=await fetch(_0x4d2e2b,{'headers':_0x3064b0,'signal':this[_0x1a1dc5(0x1df)]['signal']});if(!_0x58b0d5['ok']||!_0x58b0d5[_0x1a1dc5(0x18f)]){this[_0x1a1dc5(0x1d0)](_0x1a1dc5(0x1a8)+_0x58b0d5[_0x1a1dc5(0x1d5)]),await this['sleep'](_0x6b58ac),_0x6b58ac=Math[_0x1a1dc5(0x1cb)](_0x6b58ac*1.5,0xea60);continue;}_0x6b58ac=this['reconnectDelay'];let _0x1259c1=_0x58b0d5[_0x1a1dc5(0x18f)]['getReader'](),_0x10a321=new TextDecoder(),_0x133b14='';while(this['running']){let {done:_0xff8fa1,value:_0x374bcc}=await _0x1259c1['read']();if(_0xff8fa1)break;_0x133b14+=_0x10a321[_0x1a1dc5(0x1c1)](_0x374bcc,{'stream':!0x0});let _0x5f6ca7=_0x133b14[_0x1a1dc5(0x1b1)]('\x0a');_0x133b14=_0x5f6ca7[_0x1a1dc5(0x196)]()||'';for(let _0x4a7ec8 of _0x5f6ca7){if(!_0x4a7ec8[_0x1a1dc5(0x1b9)](_0x1a1dc5(0x1c8)))continue;try{let _0x2900f3=JSON[_0x1a1dc5(0x1a0)](_0x4a7ec8[_0x1a1dc5(0x18a)](0x6));if(_0x2900f3[_0x1a1dc5(0x19d)]==='connected'){this[_0x1a1dc5(0x1d0)](_0x1a1dc5(0x1a9)),this[_0x1a1dc5(0x1bb)](_0x1a1dc5(0x1d1));continue;}if(_0x2900f3[_0x1a1dc5(0x19d)]===_0x1a1dc5(0x1c4)||_0x2900f3[_0x1a1dc5(0x19d)]===_0x1a1dc5(0x1d9)||_0x2900f3[_0x1a1dc5(0x19d)]==='broadcast')await this[_0x1a1dc5(0x1be)]();}catch{}}}}catch(_0x16e83c){if(_0x16e83c[_0x1a1dc5(0x19b)]===_0x1a1dc5(0x1a5))break;this['emit'](_0x1a1dc5(0x1c7),_0x16e83c),this[_0x1a1dc5(0x1d0)](_0x1a1dc5(0x1c2)+_0x16e83c[_0x1a1dc5(0x1a1)]);}if(this[_0x1a1dc5(0x1e0)])this['emit']('disconnected'),this[_0x1a1dc5(0x1d0)](_0x1a1dc5(0x18e)+_0x6b58ac/0x3e8+_0x1a1dc5(0x1ca)),await this[_0x1a1dc5(0x1a4)](_0x6b58ac),_0x6b58ac=Math['min'](_0x6b58ac*1.5,0xea60);}}async[a0_0x3649cd(0x1be)](){const _0x394251=a0_0x3649cd;try{let _0x334a4f=(await this[_0x394251(0x1a7)]('get_inbox',{'alias':this[_0x394251(0x1c5)],'limit':0xa}))?.['messages']||[];for(let _0x1d50b4 of _0x334a4f)await this[_0x394251(0x1a7)]('ack_inbox',{'alias':this['alias'],'message_id':_0x1d50b4['id']}),this['log']('←\x20'+_0x1d50b4['from_session']+':\x20'+_0x1d50b4['content']['slice'](0x0,0x3c)),this[_0x394251(0x1bb)]('task',_0x1d50b4),this['emit'](_0x394251(0x1a1),_0x1d50b4);}catch(_0x393cc0){this[_0x394251(0x1d0)](_0x394251(0x1de)+_0x393cc0['message']);}}[a0_0x3649cd(0x1a4)](_0x5856e0){return new Promise(_0x24572e=>setTimeout(_0x24572e,_0x5856e0));}}var $=T;function a0_0x2b65(_0x3dcb05,_0x7529a3){_0x3dcb05=_0x3dcb05-0x187;const _0x3f5bd4=a0_0x3f5b();let _0x2b658c=_0x3f5bd4[_0x3dcb05];return _0x2b658c;}export{$ as default,T as CommHub};
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 {};
@@ -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_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.2",
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",