@siteboon/claude-code-ui 1.25.2 → 1.26.2
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.de.md +239 -0
- package/README.ja.md +115 -230
- package/README.ko.md +116 -231
- package/README.md +2 -1
- package/README.ru.md +75 -54
- package/README.zh-CN.md +121 -238
- package/dist/assets/index-BenyXiE2.css +32 -0
- package/dist/assets/{index-DF_FFT3b.js → index-dyw-e9VE.js} +249 -237
- package/dist/index.html +2 -2
- package/dist/sw.js +102 -27
- package/package.json +3 -2
- package/server/claude-sdk.js +106 -62
- package/server/cli.js +10 -7
- package/server/cursor-cli.js +59 -73
- package/server/database/db.js +142 -1
- package/server/database/init.sql +28 -1
- package/server/gemini-cli.js +46 -48
- package/server/gemini-response-handler.js +12 -73
- package/server/index.js +82 -55
- package/server/middleware/auth.js +2 -2
- package/server/openai-codex.js +43 -28
- package/server/projects.js +1 -1
- package/server/providers/claude/adapter.js +278 -0
- package/server/providers/codex/adapter.js +248 -0
- package/server/providers/cursor/adapter.js +353 -0
- package/server/providers/gemini/adapter.js +186 -0
- package/server/providers/registry.js +44 -0
- package/server/providers/types.js +119 -0
- package/server/providers/utils.js +29 -0
- package/server/routes/agent.js +7 -5
- package/server/routes/cli-auth.js +38 -0
- package/server/routes/codex.js +1 -19
- package/server/routes/gemini.js +0 -30
- package/server/routes/git.js +48 -20
- package/server/routes/messages.js +61 -0
- package/server/routes/plugins.js +5 -1
- package/server/routes/settings.js +99 -1
- package/server/routes/taskmaster.js +2 -2
- package/server/services/notification-orchestrator.js +227 -0
- package/server/services/vapid-keys.js +35 -0
- package/server/utils/plugin-loader.js +53 -4
- package/shared/networkHosts.js +22 -0
- package/dist/assets/index-WNTmA_ug.css +0 -32
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import webPush from 'web-push';
|
|
2
|
+
import { notificationPreferencesDb, pushSubscriptionsDb, sessionNamesDb } from '../database/db.js';
|
|
3
|
+
|
|
4
|
+
const KIND_TO_PREF_KEY = {
|
|
5
|
+
action_required: 'actionRequired',
|
|
6
|
+
stop: 'stop',
|
|
7
|
+
error: 'error'
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const PROVIDER_LABELS = {
|
|
11
|
+
claude: 'Claude',
|
|
12
|
+
cursor: 'Cursor',
|
|
13
|
+
codex: 'Codex',
|
|
14
|
+
gemini: 'Gemini',
|
|
15
|
+
system: 'System'
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const recentEventKeys = new Map();
|
|
19
|
+
const DEDUPE_WINDOW_MS = 20000;
|
|
20
|
+
|
|
21
|
+
const cleanupOldEventKeys = () => {
|
|
22
|
+
const now = Date.now();
|
|
23
|
+
for (const [key, timestamp] of recentEventKeys.entries()) {
|
|
24
|
+
if (now - timestamp > DEDUPE_WINDOW_MS) {
|
|
25
|
+
recentEventKeys.delete(key);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
function shouldSendPush(preferences, event) {
|
|
31
|
+
const webPushEnabled = Boolean(preferences?.channels?.webPush);
|
|
32
|
+
const prefEventKey = KIND_TO_PREF_KEY[event.kind];
|
|
33
|
+
const eventEnabled = prefEventKey ? Boolean(preferences?.events?.[prefEventKey]) : true;
|
|
34
|
+
|
|
35
|
+
return webPushEnabled && eventEnabled;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function isDuplicate(event) {
|
|
39
|
+
cleanupOldEventKeys();
|
|
40
|
+
const key = event.dedupeKey || `${event.provider}:${event.kind || 'info'}:${event.code || 'generic'}:${event.sessionId || 'none'}`;
|
|
41
|
+
if (recentEventKeys.has(key)) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
recentEventKeys.set(key, Date.now());
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function createNotificationEvent({
|
|
49
|
+
provider,
|
|
50
|
+
sessionId = null,
|
|
51
|
+
kind = 'info',
|
|
52
|
+
code = 'generic.info',
|
|
53
|
+
meta = {},
|
|
54
|
+
severity = 'info',
|
|
55
|
+
dedupeKey = null,
|
|
56
|
+
requiresUserAction = false
|
|
57
|
+
}) {
|
|
58
|
+
return {
|
|
59
|
+
provider,
|
|
60
|
+
sessionId,
|
|
61
|
+
kind,
|
|
62
|
+
code,
|
|
63
|
+
meta,
|
|
64
|
+
severity,
|
|
65
|
+
requiresUserAction,
|
|
66
|
+
dedupeKey,
|
|
67
|
+
createdAt: new Date().toISOString()
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function normalizeErrorMessage(error) {
|
|
72
|
+
if (typeof error === 'string') {
|
|
73
|
+
return error;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (error && typeof error.message === 'string') {
|
|
77
|
+
return error.message;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (error == null) {
|
|
81
|
+
return 'Unknown error';
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return String(error);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function normalizeSessionName(sessionName) {
|
|
88
|
+
if (typeof sessionName !== 'string') {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const normalized = sessionName.replace(/\s+/g, ' ').trim();
|
|
93
|
+
if (!normalized) {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return normalized.length > 80 ? `${normalized.slice(0, 77)}...` : normalized;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function resolveSessionName(event) {
|
|
101
|
+
const explicitSessionName = normalizeSessionName(event.meta?.sessionName);
|
|
102
|
+
if (explicitSessionName) {
|
|
103
|
+
return explicitSessionName;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (!event.sessionId || !event.provider) {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return normalizeSessionName(sessionNamesDb.getName(event.sessionId, event.provider));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function buildPushBody(event) {
|
|
114
|
+
const CODE_MAP = {
|
|
115
|
+
'permission.required': event.meta?.toolName
|
|
116
|
+
? `Action Required: Tool "${event.meta.toolName}" needs approval`
|
|
117
|
+
: 'Action Required: A tool needs your approval',
|
|
118
|
+
'run.stopped': event.meta?.stopReason || 'Run Stopped: The run has stopped',
|
|
119
|
+
'run.failed': event.meta?.error ? `Run Failed: ${event.meta.error}` : 'Run Failed: The run encountered an error',
|
|
120
|
+
'agent.notification': event.meta?.message ? String(event.meta.message) : 'You have a new notification',
|
|
121
|
+
'push.enabled': 'Push notifications are now enabled!'
|
|
122
|
+
};
|
|
123
|
+
const providerLabel = PROVIDER_LABELS[event.provider] || 'Assistant';
|
|
124
|
+
const sessionName = resolveSessionName(event);
|
|
125
|
+
const message = CODE_MAP[event.code] || 'You have a new notification';
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
title: sessionName || 'Claude Code UI',
|
|
129
|
+
body: `${providerLabel}: ${message}`,
|
|
130
|
+
data: {
|
|
131
|
+
sessionId: event.sessionId || null,
|
|
132
|
+
code: event.code,
|
|
133
|
+
provider: event.provider || null,
|
|
134
|
+
sessionName,
|
|
135
|
+
tag: `${event.provider || 'assistant'}:${event.sessionId || 'none'}:${event.code}`
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
async function sendWebPush(userId, event) {
|
|
141
|
+
const subscriptions = pushSubscriptionsDb.getSubscriptions(userId);
|
|
142
|
+
if (!subscriptions.length) return;
|
|
143
|
+
|
|
144
|
+
const payload = JSON.stringify(buildPushBody(event));
|
|
145
|
+
|
|
146
|
+
const results = await Promise.allSettled(
|
|
147
|
+
subscriptions.map((sub) =>
|
|
148
|
+
webPush.sendNotification(
|
|
149
|
+
{
|
|
150
|
+
endpoint: sub.endpoint,
|
|
151
|
+
keys: {
|
|
152
|
+
p256dh: sub.keys_p256dh,
|
|
153
|
+
auth: sub.keys_auth
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
payload
|
|
157
|
+
)
|
|
158
|
+
)
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
// Clean up gone subscriptions (410 Gone or 404)
|
|
162
|
+
results.forEach((result, index) => {
|
|
163
|
+
if (result.status === 'rejected') {
|
|
164
|
+
const statusCode = result.reason?.statusCode;
|
|
165
|
+
if (statusCode === 410 || statusCode === 404) {
|
|
166
|
+
pushSubscriptionsDb.removeSubscription(subscriptions[index].endpoint);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function notifyUserIfEnabled({ userId, event }) {
|
|
173
|
+
if (!userId || !event) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const preferences = notificationPreferencesDb.getPreferences(userId);
|
|
178
|
+
if (!shouldSendPush(preferences, event)) {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
if (isDuplicate(event)) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
sendWebPush(userId, event).catch((err) => {
|
|
186
|
+
console.error('Web push send error:', err);
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function notifyRunStopped({ userId, provider, sessionId = null, stopReason = 'completed', sessionName = null }) {
|
|
191
|
+
notifyUserIfEnabled({
|
|
192
|
+
userId,
|
|
193
|
+
event: createNotificationEvent({
|
|
194
|
+
provider,
|
|
195
|
+
sessionId,
|
|
196
|
+
kind: 'stop',
|
|
197
|
+
code: 'run.stopped',
|
|
198
|
+
meta: { stopReason, sessionName },
|
|
199
|
+
severity: 'info',
|
|
200
|
+
dedupeKey: `${provider}:run:stop:${sessionId || 'none'}:${stopReason}`
|
|
201
|
+
})
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function notifyRunFailed({ userId, provider, sessionId = null, error, sessionName = null }) {
|
|
206
|
+
const errorMessage = normalizeErrorMessage(error);
|
|
207
|
+
|
|
208
|
+
notifyUserIfEnabled({
|
|
209
|
+
userId,
|
|
210
|
+
event: createNotificationEvent({
|
|
211
|
+
provider,
|
|
212
|
+
sessionId,
|
|
213
|
+
kind: 'error',
|
|
214
|
+
code: 'run.failed',
|
|
215
|
+
meta: { error: errorMessage, sessionName },
|
|
216
|
+
severity: 'error',
|
|
217
|
+
dedupeKey: `${provider}:run:error:${sessionId || 'none'}:${errorMessage}`
|
|
218
|
+
})
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export {
|
|
223
|
+
createNotificationEvent,
|
|
224
|
+
notifyUserIfEnabled,
|
|
225
|
+
notifyRunStopped,
|
|
226
|
+
notifyRunFailed
|
|
227
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import webPush from 'web-push';
|
|
2
|
+
import { db } from '../database/db.js';
|
|
3
|
+
|
|
4
|
+
let cachedKeys = null;
|
|
5
|
+
|
|
6
|
+
function ensureVapidKeys() {
|
|
7
|
+
if (cachedKeys) return cachedKeys;
|
|
8
|
+
|
|
9
|
+
const row = db.prepare('SELECT public_key, private_key FROM vapid_keys ORDER BY id DESC LIMIT 1').get();
|
|
10
|
+
if (row) {
|
|
11
|
+
cachedKeys = { publicKey: row.public_key, privateKey: row.private_key };
|
|
12
|
+
return cachedKeys;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const keys = webPush.generateVAPIDKeys();
|
|
16
|
+
db.prepare('INSERT INTO vapid_keys (public_key, private_key) VALUES (?, ?)').run(keys.publicKey, keys.privateKey);
|
|
17
|
+
cachedKeys = keys;
|
|
18
|
+
return cachedKeys;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function getPublicKey() {
|
|
22
|
+
return ensureVapidKeys().publicKey;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function configureWebPush() {
|
|
26
|
+
const keys = ensureVapidKeys();
|
|
27
|
+
webPush.setVapidDetails(
|
|
28
|
+
'mailto:noreply@claudecodeui.local',
|
|
29
|
+
keys.publicKey,
|
|
30
|
+
keys.privateKey
|
|
31
|
+
);
|
|
32
|
+
console.log('Web Push notifications configured');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { ensureVapidKeys, getPublicKey, configureWebPush };
|
|
@@ -93,6 +93,55 @@ export function validateManifest(manifest) {
|
|
|
93
93
|
return { valid: true };
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
const BUILD_TIMEOUT_MS = 60_000;
|
|
97
|
+
|
|
98
|
+
/** Run `npm run build` if the plugin's package.json declares a build script. */
|
|
99
|
+
function runBuildIfNeeded(dir, packageJsonPath, onSuccess, onError) {
|
|
100
|
+
try {
|
|
101
|
+
const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
102
|
+
if (!pkg.scripts?.build) {
|
|
103
|
+
return onSuccess();
|
|
104
|
+
}
|
|
105
|
+
} catch {
|
|
106
|
+
return onSuccess(); // Unreadable package.json — skip build
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const buildProcess = spawn('npm', ['run', 'build'], {
|
|
110
|
+
cwd: dir,
|
|
111
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
let stderr = '';
|
|
115
|
+
let settled = false;
|
|
116
|
+
|
|
117
|
+
const timer = setTimeout(() => {
|
|
118
|
+
if (settled) return;
|
|
119
|
+
settled = true;
|
|
120
|
+
buildProcess.removeAllListeners();
|
|
121
|
+
buildProcess.kill();
|
|
122
|
+
onError(new Error('npm run build timed out'));
|
|
123
|
+
}, BUILD_TIMEOUT_MS);
|
|
124
|
+
|
|
125
|
+
buildProcess.stderr.on('data', (data) => { stderr += data.toString(); });
|
|
126
|
+
|
|
127
|
+
buildProcess.on('close', (code) => {
|
|
128
|
+
if (settled) return;
|
|
129
|
+
settled = true;
|
|
130
|
+
clearTimeout(timer);
|
|
131
|
+
if (code !== 0) {
|
|
132
|
+
return onError(new Error(`npm run build failed (exit code ${code}): ${stderr.trim()}`));
|
|
133
|
+
}
|
|
134
|
+
onSuccess();
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
buildProcess.on('error', (err) => {
|
|
138
|
+
if (settled) return;
|
|
139
|
+
settled = true;
|
|
140
|
+
clearTimeout(timer);
|
|
141
|
+
onError(new Error(`Failed to spawn build: ${err.message}`));
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
96
145
|
export function scanPlugins() {
|
|
97
146
|
const pluginsDir = getPluginsDir();
|
|
98
147
|
const config = getPluginsConfig();
|
|
@@ -289,7 +338,7 @@ export function installPluginFromGit(url) {
|
|
|
289
338
|
// --ignore-scripts prevents postinstall hooks from executing arbitrary code.
|
|
290
339
|
const packageJsonPath = path.join(tempDir, 'package.json');
|
|
291
340
|
if (fs.existsSync(packageJsonPath)) {
|
|
292
|
-
const npmProcess = spawn('npm', ['install', '--
|
|
341
|
+
const npmProcess = spawn('npm', ['install', '--ignore-scripts'], {
|
|
293
342
|
cwd: tempDir,
|
|
294
343
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
295
344
|
});
|
|
@@ -299,7 +348,7 @@ export function installPluginFromGit(url) {
|
|
|
299
348
|
cleanupTemp();
|
|
300
349
|
return reject(new Error(`npm install for ${repoName} failed (exit code ${npmCode})`));
|
|
301
350
|
}
|
|
302
|
-
finalize(manifest);
|
|
351
|
+
runBuildIfNeeded(tempDir, packageJsonPath, () => finalize(manifest), (err) => { cleanupTemp(); reject(err); });
|
|
303
352
|
});
|
|
304
353
|
|
|
305
354
|
npmProcess.on('error', (err) => {
|
|
@@ -356,7 +405,7 @@ export function updatePluginFromGit(name) {
|
|
|
356
405
|
// Re-run npm install if package.json exists
|
|
357
406
|
const packageJsonPath = path.join(pluginDir, 'package.json');
|
|
358
407
|
if (fs.existsSync(packageJsonPath)) {
|
|
359
|
-
const npmProcess = spawn('npm', ['install', '--
|
|
408
|
+
const npmProcess = spawn('npm', ['install', '--ignore-scripts'], {
|
|
360
409
|
cwd: pluginDir,
|
|
361
410
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
362
411
|
});
|
|
@@ -364,7 +413,7 @@ export function updatePluginFromGit(name) {
|
|
|
364
413
|
if (npmCode !== 0) {
|
|
365
414
|
return reject(new Error(`npm install for ${name} failed (exit code ${npmCode})`));
|
|
366
415
|
}
|
|
367
|
-
resolve(manifest);
|
|
416
|
+
runBuildIfNeeded(pluginDir, packageJsonPath, () => resolve(manifest), (err) => reject(err));
|
|
368
417
|
});
|
|
369
418
|
npmProcess.on('error', (err) => reject(err));
|
|
370
419
|
} else {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export function isWildcardHost(host) {
|
|
2
|
+
return host === '0.0.0.0' || host === '::';
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function isLoopbackHost(host) {
|
|
6
|
+
return host === 'localhost' || host === '127.0.0.1' || host === '::1' || host === '[::1]';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function normalizeLoopbackHost(host) {
|
|
10
|
+
if (!host) {
|
|
11
|
+
return host;
|
|
12
|
+
}
|
|
13
|
+
return isLoopbackHost(host) ? 'localhost' : host;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Use localhost for connectable loopback and wildcard addresses in browser-facing URLs.
|
|
17
|
+
export function getConnectableHost(host) {
|
|
18
|
+
if (!host) {
|
|
19
|
+
return 'localhost';
|
|
20
|
+
}
|
|
21
|
+
return isWildcardHost(host) || isLoopbackHost(host) ? 'localhost' : host;
|
|
22
|
+
}
|