@delt/claude-alarm 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +166 -0
- package/dist/channel/server.js +333 -0
- package/dist/channel/server.js.map +1 -0
- package/dist/cli.js +921 -0
- package/dist/cli.js.map +1 -0
- package/dist/dashboard/index.html +580 -0
- package/dist/hub/server.js +512 -0
- package/dist/hub/server.js.map +1 -0
- package/dist/index.d.ts +196 -0
- package/dist/index.js +696 -0
- package/dist/index.js.map +1 -0
- package/package.json +54 -0
- package/src/dashboard/index.html +580 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/** Session status */
|
|
2
|
+
type SessionStatus = 'idle' | 'working' | 'waiting_input';
|
|
3
|
+
/** Session info tracked by the hub */
|
|
4
|
+
interface SessionInfo {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
status: SessionStatus;
|
|
8
|
+
connectedAt: number;
|
|
9
|
+
lastActivity: number;
|
|
10
|
+
cwd?: string;
|
|
11
|
+
}
|
|
12
|
+
/** Messages sent between channel server and hub */
|
|
13
|
+
type ChannelMessage = {
|
|
14
|
+
type: 'register';
|
|
15
|
+
session: SessionInfo;
|
|
16
|
+
} | {
|
|
17
|
+
type: 'status';
|
|
18
|
+
sessionId: string;
|
|
19
|
+
status: SessionStatus;
|
|
20
|
+
} | {
|
|
21
|
+
type: 'notify';
|
|
22
|
+
sessionId: string;
|
|
23
|
+
title: string;
|
|
24
|
+
message: string;
|
|
25
|
+
level?: NotifyLevel;
|
|
26
|
+
} | {
|
|
27
|
+
type: 'reply';
|
|
28
|
+
sessionId: string;
|
|
29
|
+
content: string;
|
|
30
|
+
} | {
|
|
31
|
+
type: 'message_to_session';
|
|
32
|
+
sessionId: string;
|
|
33
|
+
content: string;
|
|
34
|
+
} | {
|
|
35
|
+
type: 'sessions_list';
|
|
36
|
+
sessions: SessionInfo[];
|
|
37
|
+
} | {
|
|
38
|
+
type: 'session_connected';
|
|
39
|
+
session: SessionInfo;
|
|
40
|
+
} | {
|
|
41
|
+
type: 'session_disconnected';
|
|
42
|
+
sessionId: string;
|
|
43
|
+
} | {
|
|
44
|
+
type: 'session_updated';
|
|
45
|
+
session: SessionInfo;
|
|
46
|
+
} | {
|
|
47
|
+
type: 'notification';
|
|
48
|
+
sessionId: string;
|
|
49
|
+
title: string;
|
|
50
|
+
message: string;
|
|
51
|
+
level?: NotifyLevel;
|
|
52
|
+
timestamp: number;
|
|
53
|
+
} | {
|
|
54
|
+
type: 'reply_from_session';
|
|
55
|
+
sessionId: string;
|
|
56
|
+
content: string;
|
|
57
|
+
timestamp: number;
|
|
58
|
+
} | {
|
|
59
|
+
type: 'error';
|
|
60
|
+
message: string;
|
|
61
|
+
};
|
|
62
|
+
type NotifyLevel = 'info' | 'warning' | 'error' | 'success';
|
|
63
|
+
/** Webhook configuration */
|
|
64
|
+
interface WebhookConfig {
|
|
65
|
+
url: string;
|
|
66
|
+
events?: string[];
|
|
67
|
+
headers?: Record<string, string>;
|
|
68
|
+
}
|
|
69
|
+
/** App configuration stored in ~/.claude-alarm/config.json */
|
|
70
|
+
interface AppConfig {
|
|
71
|
+
hub: {
|
|
72
|
+
host: string;
|
|
73
|
+
port: number;
|
|
74
|
+
token?: string;
|
|
75
|
+
};
|
|
76
|
+
notifications: {
|
|
77
|
+
desktop: boolean;
|
|
78
|
+
sound: boolean;
|
|
79
|
+
};
|
|
80
|
+
webhooks: WebhookConfig[];
|
|
81
|
+
}
|
|
82
|
+
/** Hub status response */
|
|
83
|
+
interface HubStatus {
|
|
84
|
+
running: boolean;
|
|
85
|
+
pid?: number;
|
|
86
|
+
port?: number;
|
|
87
|
+
sessions?: number;
|
|
88
|
+
uptime?: number;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
declare class HubServer {
|
|
92
|
+
private httpServer;
|
|
93
|
+
private wssChannel;
|
|
94
|
+
private wssDashboard;
|
|
95
|
+
private sessions;
|
|
96
|
+
private notifier;
|
|
97
|
+
private startTime;
|
|
98
|
+
private channelSockets;
|
|
99
|
+
private dashboardSockets;
|
|
100
|
+
private host;
|
|
101
|
+
private port;
|
|
102
|
+
private token?;
|
|
103
|
+
constructor(config?: Partial<AppConfig>);
|
|
104
|
+
start(): Promise<void>;
|
|
105
|
+
stop(): Promise<void>;
|
|
106
|
+
private handleHttp;
|
|
107
|
+
private serveDashboard;
|
|
108
|
+
private handleApiSend;
|
|
109
|
+
private handleApiNotify;
|
|
110
|
+
private handleChannelConnection;
|
|
111
|
+
private handleChannelMessage;
|
|
112
|
+
private handleDashboardConnection;
|
|
113
|
+
private broadcastToDashboards;
|
|
114
|
+
private jsonResponse;
|
|
115
|
+
private isLocalRequest;
|
|
116
|
+
private readBody;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
declare class HubClient {
|
|
120
|
+
private sessionId;
|
|
121
|
+
private sessionName;
|
|
122
|
+
private hubHost;
|
|
123
|
+
private hubPort;
|
|
124
|
+
private token?;
|
|
125
|
+
private ws;
|
|
126
|
+
private reconnectTimer;
|
|
127
|
+
private messageHandlers;
|
|
128
|
+
private queue;
|
|
129
|
+
private connected;
|
|
130
|
+
constructor(sessionId: string, sessionName: string, hubHost?: string, hubPort?: number, token?: string | undefined);
|
|
131
|
+
connect(): void;
|
|
132
|
+
send(msg: ChannelMessage): void;
|
|
133
|
+
onMessage(handler: (msg: ChannelMessage) => void): void;
|
|
134
|
+
disconnect(): void;
|
|
135
|
+
private scheduleReconnect;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
declare class SessionManager {
|
|
139
|
+
private sessions;
|
|
140
|
+
register(session: SessionInfo): void;
|
|
141
|
+
unregister(sessionId: string): SessionInfo | undefined;
|
|
142
|
+
updateStatus(sessionId: string, status: SessionStatus): SessionInfo | undefined;
|
|
143
|
+
updateActivity(sessionId: string): void;
|
|
144
|
+
get(sessionId: string): SessionInfo | undefined;
|
|
145
|
+
getAll(): SessionInfo[];
|
|
146
|
+
count(): number;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
declare class Notifier {
|
|
150
|
+
private webhooks;
|
|
151
|
+
private desktopEnabled;
|
|
152
|
+
private notificationSettingsOpened;
|
|
153
|
+
private dashboardUrl?;
|
|
154
|
+
configure(options: {
|
|
155
|
+
desktop?: boolean;
|
|
156
|
+
webhooks?: WebhookConfig[];
|
|
157
|
+
dashboardUrl?: string;
|
|
158
|
+
}): void;
|
|
159
|
+
notify(title: string, message: string, level?: NotifyLevel): Promise<void>;
|
|
160
|
+
private sendDesktop;
|
|
161
|
+
private checkWindowsNotifications;
|
|
162
|
+
private openNotificationSettings;
|
|
163
|
+
private sendWebhook;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
declare function loadConfig(): AppConfig;
|
|
167
|
+
declare function saveConfig(config: AppConfig): void;
|
|
168
|
+
/**
|
|
169
|
+
* Add claude-alarm as an MCP channel server to .mcp.json
|
|
170
|
+
*/
|
|
171
|
+
declare function setupMcpConfig(targetDir?: string): string;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Logger that writes to stderr only.
|
|
175
|
+
* CRITICAL: In MCP channel servers, stdout is used for the stdio protocol.
|
|
176
|
+
* Any console.log() would corrupt the protocol. Always use this logger.
|
|
177
|
+
*/
|
|
178
|
+
declare const logger: {
|
|
179
|
+
info(msg: string, ...args: unknown[]): void;
|
|
180
|
+
warn(msg: string, ...args: unknown[]): void;
|
|
181
|
+
error(msg: string, ...args: unknown[]): void;
|
|
182
|
+
debug(msg: string, ...args: unknown[]): void;
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
declare const DEFAULT_HUB_HOST = "127.0.0.1";
|
|
186
|
+
declare const DEFAULT_HUB_PORT = 7890;
|
|
187
|
+
declare const CONFIG_DIR: string;
|
|
188
|
+
declare const CONFIG_FILE: string;
|
|
189
|
+
declare const PID_FILE: string;
|
|
190
|
+
declare const LOG_FILE: string;
|
|
191
|
+
declare const WS_PATH_CHANNEL = "/ws/channel";
|
|
192
|
+
declare const WS_PATH_DASHBOARD = "/ws/dashboard";
|
|
193
|
+
declare const CHANNEL_SERVER_NAME = "claude-alarm";
|
|
194
|
+
declare const CHANNEL_SERVER_VERSION = "0.1.0";
|
|
195
|
+
|
|
196
|
+
export { type AppConfig, CHANNEL_SERVER_NAME, CHANNEL_SERVER_VERSION, CONFIG_DIR, CONFIG_FILE, type ChannelMessage, DEFAULT_HUB_HOST, DEFAULT_HUB_PORT, HubClient, HubServer, type HubStatus, LOG_FILE, Notifier, type NotifyLevel, PID_FILE, type SessionInfo, SessionManager, type SessionStatus, WS_PATH_CHANNEL, WS_PATH_DASHBOARD, type WebhookConfig, loadConfig, logger, saveConfig, setupMcpConfig };
|