@clagentic/console 1.0.0-beta.4 → 1.0.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/CREDITS.md +1 -0
- package/LICENSE +1 -0
- package/README.md +64 -174
- package/bin/cli.js +10 -15
- package/lib/agents-favorites.js +1 -0
- package/lib/ask-user-mcp-server.js +1 -0
- package/lib/config.js +1 -0
- package/lib/crisis-safety.js +1 -0
- package/lib/daemon.js +38 -2
- package/lib/dm.js +1 -0
- package/lib/mcp-local.js +1 -0
- package/lib/os-users.js +1 -0
- package/lib/pages.js +8 -71
- package/lib/project-connection.js +3 -28
- package/lib/project-external-trigger.js +1 -0
- package/lib/project-http.js +1 -0
- package/lib/project-knowledge.js +3 -2
- package/lib/project-loop.js +1 -1
- package/lib/project-mcp.js +1 -0
- package/lib/project-memory.js +1 -0
- package/lib/project-sessions.js +2 -1
- package/lib/project-user-message.js +2 -1
- package/lib/project.js +1 -0
- package/lib/public/app.js +2 -1
- package/lib/public/css/admin.css +23 -0
- package/lib/public/css/base.css +52 -0
- package/lib/public/css/channel-layout.css +1 -0
- package/lib/public/css/debate.css +1 -0
- package/lib/public/css/filebrowser.css +14 -0
- package/lib/public/css/home-hub.css +1 -0
- package/lib/public/css/icon-strip.css +2 -15
- package/lib/public/css/loop.css +1 -0
- package/lib/public/css/mention.css +2 -1
- package/lib/public/css/server-settings.css +206 -41
- package/lib/public/css/session-search.css +1 -0
- package/lib/public/css/stt.css +1 -0
- package/lib/public/index.html +45 -48
- package/lib/public/modules/admin.js +55 -2
- package/lib/public/modules/app-connection.js +1 -1
- package/lib/public/modules/app-dm.js +1 -1
- package/lib/public/modules/app-favicon.js +1 -0
- package/lib/public/modules/app-home-hub.js +1 -0
- package/lib/public/modules/app-loop-ui.js +1 -1
- package/lib/public/modules/app-loop-wizard.js +1 -1
- package/lib/public/modules/app-messages.js +16 -4
- package/lib/public/modules/app-misc.js +2 -9
- package/lib/public/modules/app-notifications.js +2 -2
- package/lib/public/modules/app-panels.js +13 -7
- package/lib/public/modules/app-projects.js +1 -0
- package/lib/public/modules/app-rate-limit.js +1 -1
- package/lib/public/modules/app-rendering.js +9 -4
- package/lib/public/modules/app-skills-install.js +1 -1
- package/lib/public/modules/command-palette.js +1 -1
- package/lib/public/modules/mention.js +3 -2
- package/lib/public/modules/notifications.js +34 -0
- package/lib/public/modules/playbook.js +1 -0
- package/lib/public/modules/profile.js +1 -1
- package/lib/public/modules/project-settings.js +179 -12
- package/lib/public/modules/project-switcher.js +29 -91
- package/lib/public/modules/server-settings.js +234 -11
- package/lib/public/modules/session-search.js +1 -0
- package/lib/public/modules/sidebar-mobile.js +0 -1
- package/lib/public/modules/sidebar-projects.js +19 -0
- package/lib/public/modules/sidebar-sessions.js +1 -0
- package/lib/public/modules/sidebar-users.js +3 -3
- package/lib/public/modules/store.js +26 -4
- package/lib/public/modules/theme.js +9 -9
- package/lib/public/modules/tools.js +2 -1
- package/lib/public/modules/user-settings.js +1 -1
- package/lib/public/style.css +1 -0
- package/lib/public/sw.js +10 -2
- package/lib/push.js +2 -1
- package/lib/sdk-bridge.js +1 -0
- package/lib/sdk-message-processor.js +11 -0
- package/lib/sdk-worker.js +1 -0
- package/lib/server-auth.js +2 -2
- package/lib/server-dm.js +1 -0
- package/lib/server-palette.js +1 -0
- package/lib/server-settings.js +26 -25
- package/lib/server-skills.js +1 -1
- package/lib/server.js +28 -4
- package/lib/session-search.js +1 -0
- package/lib/sessions.js +4 -1
- package/lib/smtp.js +7 -7
- package/lib/users-auth.js +30 -5
- package/lib/users-preferences.js +1 -0
- package/lib/users.js +2 -0
- package/lib/ws-schema.js +1 -0
- package/lib/yoke/adapters/claude-worker.js +1 -0
- package/lib/yoke/adapters/claude.js +1 -0
- package/lib/yoke/adapters/codex.js +1 -1
- package/lib/yoke/mcp-bridge-server.js +1 -0
- package/package.json +3 -3
|
@@ -266,7 +266,7 @@ function computeMermaidVars(theme) {
|
|
|
266
266
|
// --- State ---
|
|
267
267
|
// All themes loaded from server: bundled + custom, keyed by id
|
|
268
268
|
var themes = {};
|
|
269
|
-
var customSet = {}; // ids that came from ~/.
|
|
269
|
+
var customSet = {}; // ids that came from ~/.clagentic/themes/
|
|
270
270
|
var themesLoaded = false;
|
|
271
271
|
var currentThemeId = "clagentic-dark";
|
|
272
272
|
var changeCallbacks = [];
|
|
@@ -462,7 +462,7 @@ function getSystemMode() {
|
|
|
462
462
|
// Returns the effective mode: user override or system
|
|
463
463
|
function getEffectiveMode() {
|
|
464
464
|
var saved = null;
|
|
465
|
-
try { saved = localStorage.getItem(MODE_KEY)
|
|
465
|
+
try { saved = localStorage.getItem(MODE_KEY); } catch (e) {}
|
|
466
466
|
if (saved === "light" || saved === "dark") return saved;
|
|
467
467
|
return getSystemMode();
|
|
468
468
|
}
|
|
@@ -470,7 +470,7 @@ function getEffectiveMode() {
|
|
|
470
470
|
// Get/set the active brand ("clagentic" | "classic")
|
|
471
471
|
export function getBrand() {
|
|
472
472
|
var b = null;
|
|
473
|
-
try { b = localStorage.getItem(BRAND_KEY)
|
|
473
|
+
try { b = localStorage.getItem(BRAND_KEY); } catch (e) {}
|
|
474
474
|
return (b === "classic") ? "classic" : "clagentic";
|
|
475
475
|
}
|
|
476
476
|
|
|
@@ -500,14 +500,14 @@ function themeIdForMode(mode) {
|
|
|
500
500
|
|
|
501
501
|
export function isWideView() {
|
|
502
502
|
try {
|
|
503
|
-
var v = localStorage.getItem(WIDE_KEY)
|
|
503
|
+
var v = localStorage.getItem(WIDE_KEY);
|
|
504
504
|
return v === null ? true : v !== "bubble"; // default: Channel (wide)
|
|
505
505
|
} catch (e) { return true; }
|
|
506
506
|
}
|
|
507
507
|
|
|
508
508
|
export function getChatLayout() {
|
|
509
509
|
try {
|
|
510
|
-
var v = localStorage.getItem(WIDE_KEY)
|
|
510
|
+
var v = localStorage.getItem(WIDE_KEY);
|
|
511
511
|
return v === "bubble" ? "bubble" : "channel";
|
|
512
512
|
} catch (e) { return "channel"; }
|
|
513
513
|
}
|
|
@@ -718,7 +718,7 @@ export function applyServerThemePrefs(themeMode, themeBrand) {
|
|
|
718
718
|
var changed = false;
|
|
719
719
|
if (themeBrand && (themeBrand === "classic" || themeBrand === "clagentic")) {
|
|
720
720
|
var local = null;
|
|
721
|
-
try { local = localStorage.getItem(BRAND_KEY)
|
|
721
|
+
try { local = localStorage.getItem(BRAND_KEY); } catch (e) {}
|
|
722
722
|
if (local !== themeBrand) {
|
|
723
723
|
try { localStorage.setItem(BRAND_KEY, themeBrand); } catch (e) {}
|
|
724
724
|
changed = true;
|
|
@@ -726,7 +726,7 @@ export function applyServerThemePrefs(themeMode, themeBrand) {
|
|
|
726
726
|
}
|
|
727
727
|
if (themeMode && (themeMode === "light" || themeMode === "dark")) {
|
|
728
728
|
var localMode = null;
|
|
729
|
-
try { localMode = localStorage.getItem(MODE_KEY)
|
|
729
|
+
try { localMode = localStorage.getItem(MODE_KEY); } catch (e) {}
|
|
730
730
|
if (localMode !== themeMode) {
|
|
731
731
|
try { localStorage.setItem(MODE_KEY, themeMode); } catch (e) {}
|
|
732
732
|
changed = true;
|
|
@@ -744,7 +744,7 @@ export function applyServerThemePrefs(themeMode, themeBrand) {
|
|
|
744
744
|
export function initTheme() {
|
|
745
745
|
// Determine initial theme from saved mode + skin, or system preference
|
|
746
746
|
var saved = null;
|
|
747
|
-
try { saved = localStorage.getItem(STORAGE_KEY)
|
|
747
|
+
try { saved = localStorage.getItem(STORAGE_KEY); } catch (e) {}
|
|
748
748
|
|
|
749
749
|
if (saved) {
|
|
750
750
|
currentThemeId = saved;
|
|
@@ -768,7 +768,7 @@ export function initTheme() {
|
|
|
768
768
|
var mq = window.matchMedia("(prefers-color-scheme: dark)");
|
|
769
769
|
var handler = function () {
|
|
770
770
|
var userMode = null;
|
|
771
|
-
try { userMode = localStorage.getItem(MODE_KEY)
|
|
771
|
+
try { userMode = localStorage.getItem(MODE_KEY); } catch (e) {}
|
|
772
772
|
if (!userMode) {
|
|
773
773
|
// No manual override — follow system
|
|
774
774
|
var sysMode = getSystemMode();
|
|
@@ -775,7 +775,7 @@ function renderConversationalPermission(requestId, toolName, toolInput, mateId,
|
|
|
775
775
|
|
|
776
776
|
// Avatar (left column)
|
|
777
777
|
var avi = document.createElement("img");
|
|
778
|
-
avi.className = "dm-bubble-avatar dm-bubble-avatar-
|
|
778
|
+
avi.className = "dm-bubble-avatar dm-bubble-avatar-agent";
|
|
779
779
|
avi.src = identity.avatar;
|
|
780
780
|
avi.alt = "";
|
|
781
781
|
container.appendChild(avi);
|
|
@@ -2283,3 +2283,4 @@ export function resetToolState() {
|
|
|
2283
2283
|
export function initTools(_ctx) {
|
|
2284
2284
|
ctx = _ctx;
|
|
2285
2285
|
}
|
|
2286
|
+
|
|
@@ -333,7 +333,7 @@ function populateAccount() {
|
|
|
333
333
|
}).then(function (data) {
|
|
334
334
|
if (!data) return;
|
|
335
335
|
currentProfile = data;
|
|
336
|
-
var displayName = data.name || data.displayName || data.username || '
|
|
336
|
+
var displayName = data.name || data.displayName || data.username || 'User';
|
|
337
337
|
var avatarImg = document.getElementById('us-account-avatar-img');
|
|
338
338
|
var avatarFallback = document.getElementById('us-account-avatar-fallback');
|
|
339
339
|
var accountName = document.getElementById('us-account-name');
|
package/lib/public/style.css
CHANGED
package/lib/public/sw.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var CACHE_NAME = "clagentic-offline-
|
|
1
|
+
var CACHE_NAME = "clagentic-offline-v__VERSION__";
|
|
2
2
|
|
|
3
3
|
self.addEventListener("install", function (event) {
|
|
4
4
|
event.waitUntil(self.skipWaiting());
|
|
@@ -14,6 +14,13 @@ self.addEventListener("activate", function (event) {
|
|
|
14
14
|
);
|
|
15
15
|
}).then(function () {
|
|
16
16
|
return self.clients.claim();
|
|
17
|
+
}).then(function () {
|
|
18
|
+
// Notify all open clients that a new version is active so they can reload
|
|
19
|
+
return self.clients.matchAll({ type: "window" }).then(function (clientList) {
|
|
20
|
+
for (var i = 0; i < clientList.length; i++) {
|
|
21
|
+
clientList[i].postMessage({ type: "sw-updated" });
|
|
22
|
+
}
|
|
23
|
+
});
|
|
17
24
|
})
|
|
18
25
|
);
|
|
19
26
|
});
|
|
@@ -95,7 +102,7 @@ self.addEventListener("push", function (event) {
|
|
|
95
102
|
|
|
96
103
|
var options = {
|
|
97
104
|
body: data.body || "",
|
|
98
|
-
tag: data.tag || "
|
|
105
|
+
tag: data.tag || "clagentic",
|
|
99
106
|
data: data,
|
|
100
107
|
};
|
|
101
108
|
|
|
@@ -157,3 +164,4 @@ self.addEventListener("notificationclick", function (event) {
|
|
|
157
164
|
})
|
|
158
165
|
);
|
|
159
166
|
});
|
|
167
|
+
|
package/lib/push.js
CHANGED
|
@@ -27,7 +27,7 @@ function initPush() {
|
|
|
27
27
|
var keys = loadOrCreateVapidKeys();
|
|
28
28
|
|
|
29
29
|
var vapidDetails = {
|
|
30
|
-
subject: "mailto:push@
|
|
30
|
+
subject: "mailto:push@clagentic.dev",
|
|
31
31
|
publicKey: keys.publicKey,
|
|
32
32
|
privateKey: keys.privateKey,
|
|
33
33
|
};
|
|
@@ -147,3 +147,4 @@ function initPush() {
|
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
module.exports = { initPush };
|
|
150
|
+
|
package/lib/sdk-bridge.js
CHANGED
|
@@ -453,6 +453,17 @@ function attachMessageProcessor(ctx) {
|
|
|
453
453
|
sessionId: parsed.sessionId,
|
|
454
454
|
lastStreamInputTokens: lastStreamInput,
|
|
455
455
|
});
|
|
456
|
+
// Accumulate server-side cumulative usage for accurate history_done replay
|
|
457
|
+
if (!session.cumulativeUsage) {
|
|
458
|
+
session.cumulativeUsage = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, turns: 0 };
|
|
459
|
+
}
|
|
460
|
+
if (parsed.usage) {
|
|
461
|
+
session.cumulativeUsage.input += parsed.usage.input_tokens || parsed.usage.inputTokens || 0;
|
|
462
|
+
session.cumulativeUsage.output += parsed.usage.output_tokens || parsed.usage.outputTokens || 0;
|
|
463
|
+
session.cumulativeUsage.cacheRead += parsed.usage.cache_read_input_tokens || parsed.usage.cacheReadInputTokens || 0;
|
|
464
|
+
session.cumulativeUsage.cacheWrite += parsed.usage.cache_creation_input_tokens || parsed.usage.cacheCreationInputTokens || 0;
|
|
465
|
+
}
|
|
466
|
+
session.cumulativeUsage.turns++;
|
|
456
467
|
if (parsed.fastModeState) {
|
|
457
468
|
sendAndRecord(session, { type: "fast_mode_state", state: parsed.fastModeState });
|
|
458
469
|
}
|
package/lib/sdk-worker.js
CHANGED
package/lib/server-auth.js
CHANGED
|
@@ -706,10 +706,10 @@ function attachAuth(ctx) {
|
|
|
706
706
|
var validation = users.validateInvite(inviteCode);
|
|
707
707
|
if (!validation.valid) {
|
|
708
708
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
709
|
-
res.end('<!DOCTYPE html><html><head><title>
|
|
709
|
+
res.end('<!DOCTYPE html><html><head><title>Clagentic:Console</title>' +
|
|
710
710
|
'<style>body{background:#2F2E2B;color:#E8E5DE;font-family:system-ui;display:flex;align-items:center;justify-content:center;min-height:100vh;margin:0}' +
|
|
711
711
|
'.c{text-align:center;max-width:360px;padding:20px}h1{color:#DA7756;margin-bottom:16px}p{color:#908B81}</style></head>' +
|
|
712
|
-
'<body><div class="c"><h1>
|
|
712
|
+
'<body><div class="c"><h1>Clagentic:Console</h1><p>' + (validation.error === "Invite expired" ? "This invite link has expired." : validation.error === "Invite already used" ? "This invite link has already been used." : "Invalid invite link.") + '</p></div></body></html>');
|
|
713
713
|
return true;
|
|
714
714
|
}
|
|
715
715
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
package/lib/server-dm.js
CHANGED
package/lib/server-palette.js
CHANGED
package/lib/server-settings.js
CHANGED
|
@@ -236,7 +236,7 @@ function attachSettings(ctx) {
|
|
|
236
236
|
res.end('{"error":"Current PIN is required"}');
|
|
237
237
|
return;
|
|
238
238
|
}
|
|
239
|
-
if (
|
|
239
|
+
if (!users.verifyPin(data.currentPin, mu.pinHash)) {
|
|
240
240
|
res.writeHead(400, { "Content-Type": "application/json" });
|
|
241
241
|
res.end('{"error":"Current PIN is incorrect"}');
|
|
242
242
|
return;
|
|
@@ -435,30 +435,6 @@ function attachSettings(ctx) {
|
|
|
435
435
|
return true;
|
|
436
436
|
}
|
|
437
437
|
|
|
438
|
-
// POST /api/user/mate-onboarded
|
|
439
|
-
if (req.method === "POST" && fullUrl === "/api/user/mate-onboarded") {
|
|
440
|
-
var isMultiUser = users.isMultiUser();
|
|
441
|
-
var mu = getMultiUserFromReq(req);
|
|
442
|
-
if (!isMultiUser) {
|
|
443
|
-
// Single-user: save to daemon config
|
|
444
|
-
if (typeof opts.onSetMateOnboarded === "function") {
|
|
445
|
-
opts.onSetMateOnboarded();
|
|
446
|
-
}
|
|
447
|
-
res.writeHead(200, { "Content-Type": "application/json" });
|
|
448
|
-
res.end('{"ok":true}');
|
|
449
|
-
} else {
|
|
450
|
-
if (!mu) {
|
|
451
|
-
res.writeHead(401, { "Content-Type": "application/json" });
|
|
452
|
-
res.end('{"error":"unauthorized"}');
|
|
453
|
-
return true;
|
|
454
|
-
}
|
|
455
|
-
users.setMateOnboarded(mu.id);
|
|
456
|
-
res.writeHead(200, { "Content-Type": "application/json" });
|
|
457
|
-
res.end('{"ok":true}');
|
|
458
|
-
}
|
|
459
|
-
return true;
|
|
460
|
-
}
|
|
461
|
-
|
|
462
438
|
// GET /api/user/tool-palettes
|
|
463
439
|
if (req.method === "GET" && fullUrl === "/api/user/tool-palettes") {
|
|
464
440
|
var isMultiUser = users.isMultiUser();
|
|
@@ -544,6 +520,30 @@ function attachSettings(ctx) {
|
|
|
544
520
|
return true;
|
|
545
521
|
}
|
|
546
522
|
|
|
523
|
+
|
|
524
|
+
// POST /api/settings/enable-multiuser — Enable multi-user mode (single-user only)
|
|
525
|
+
if (req.method === "POST" && fullUrl === "/api/settings/enable-multiuser") {
|
|
526
|
+
if (users.isMultiUser()) {
|
|
527
|
+
res.writeHead(400, { "Content-Type": "application/json" });
|
|
528
|
+
res.end('{"error":"Already in multi-user mode"}');
|
|
529
|
+
return true;
|
|
530
|
+
}
|
|
531
|
+
// Only allow in single-user mode with PIN
|
|
532
|
+
if (!opts.pinHash) {
|
|
533
|
+
res.writeHead(400, { "Content-Type": "application/json" });
|
|
534
|
+
res.end('{"error":"PIN mode not enabled"}');
|
|
535
|
+
return true;
|
|
536
|
+
}
|
|
537
|
+
var result = users.enableMultiUser();
|
|
538
|
+
if (result.error) {
|
|
539
|
+
res.writeHead(400, { "Content-Type": "application/json" });
|
|
540
|
+
res.end(JSON.stringify({ error: result.error }));
|
|
541
|
+
return true;
|
|
542
|
+
}
|
|
543
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
544
|
+
res.end(JSON.stringify({ ok: true, setupCode: result.setupCode }));
|
|
545
|
+
return true;
|
|
546
|
+
}
|
|
547
547
|
return false;
|
|
548
548
|
}
|
|
549
549
|
|
|
@@ -551,3 +551,4 @@ function attachSettings(ctx) {
|
|
|
551
551
|
}
|
|
552
552
|
|
|
553
553
|
module.exports = { attachSettings: attachSettings };
|
|
554
|
+
|
package/lib/server-skills.js
CHANGED
|
@@ -8,7 +8,7 @@ var skillsCache = {};
|
|
|
8
8
|
function httpGet(url) {
|
|
9
9
|
return new Promise(function (resolve, reject) {
|
|
10
10
|
var mod = url.startsWith("https") ? https : http;
|
|
11
|
-
mod.get(url, { headers: { "User-Agent": "
|
|
11
|
+
mod.get(url, { headers: { "User-Agent": "Clagentic/1.0" } }, function (resp) {
|
|
12
12
|
if (resp.statusCode >= 300 && resp.statusCode < 400 && resp.headers.location) {
|
|
13
13
|
return httpGet(resp.headers.location).then(resolve, reject);
|
|
14
14
|
}
|
package/lib/server.js
CHANGED
|
@@ -29,7 +29,7 @@ var userThemesDir = path.join(CONFIG_DIR, "themes");
|
|
|
29
29
|
function httpGetBinary(url) {
|
|
30
30
|
return new Promise(function (resolve, reject) {
|
|
31
31
|
var mod = url.startsWith("https") ? https : http;
|
|
32
|
-
mod.get(url, { headers: { "User-Agent": "
|
|
32
|
+
mod.get(url, { headers: { "User-Agent": "Clagentic/1.0" } }, function (resp) {
|
|
33
33
|
if (resp.statusCode >= 300 && resp.statusCode < 400 && resp.headers.location) {
|
|
34
34
|
return httpGetBinary(resp.headers.location).then(resolve, reject);
|
|
35
35
|
}
|
|
@@ -66,6 +66,29 @@ var verifyPin = serverAuth.verifyPin;
|
|
|
66
66
|
function serveStatic(urlPath, res) {
|
|
67
67
|
if (urlPath === "/") urlPath = "/index.html";
|
|
68
68
|
|
|
69
|
+
// Special case: inject version into sw.js cache name at serve time
|
|
70
|
+
if (urlPath === "/sw.js") {
|
|
71
|
+
var swPath = path.join(publicDir, "sw.js");
|
|
72
|
+
try {
|
|
73
|
+
var swContent = fs.readFileSync(swPath, "utf8");
|
|
74
|
+
var appVersion = pkg.version;
|
|
75
|
+
// Replace the static cache name with a version-stamped one
|
|
76
|
+
swContent = swContent.replace(
|
|
77
|
+
/var CACHE_NAME = "clagentic-offline-[^"]*"/,
|
|
78
|
+
'var CACHE_NAME = "clagentic-offline-v' + appVersion + '"'
|
|
79
|
+
);
|
|
80
|
+
res.writeHead(200, {
|
|
81
|
+
"Content-Type": "application/javascript; charset=utf-8",
|
|
82
|
+
"Cache-Control": "no-cache",
|
|
83
|
+
"Service-Worker-Allowed": "/",
|
|
84
|
+
});
|
|
85
|
+
res.end(swContent);
|
|
86
|
+
return true;
|
|
87
|
+
} catch (e) {
|
|
88
|
+
// Fall through to normal static serving on error
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
69
92
|
var filePath = path.join(publicDir, urlPath);
|
|
70
93
|
|
|
71
94
|
if (!filePath.startsWith(publicDir)) {
|
|
@@ -461,7 +484,8 @@ function createServer(opts) {
|
|
|
461
484
|
if (req.method === "GET" && fullUrl === "/api/me") {
|
|
462
485
|
if (!users.isMultiUser()) {
|
|
463
486
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
464
|
-
|
|
487
|
+
var singleUserData = { multiUser: false, singleUserMigrationAvailable: !!pinHash };
|
|
488
|
+
res.end(JSON.stringify(singleUserData));
|
|
465
489
|
return;
|
|
466
490
|
}
|
|
467
491
|
var mu = getMultiUserFromReq(req);
|
|
@@ -492,7 +516,7 @@ function createServer(opts) {
|
|
|
492
516
|
var targetSlug = null;
|
|
493
517
|
var reqUser = users.isMultiUser() ? getMultiUserFromReq(req) : null;
|
|
494
518
|
// Check for last-visited project cookie
|
|
495
|
-
var lastProject = parseCookies(req)["clay_last_project"];
|
|
519
|
+
var lastProject = parseCookies(req)["clagentic_last_project"] || parseCookies(req)["clay_last_project"];
|
|
496
520
|
if (lastProject && projects.has(lastProject)) {
|
|
497
521
|
if (reqUser && onGetProjectAccess) {
|
|
498
522
|
var lpAccess = onGetProjectAccess(lastProject);
|
|
@@ -604,7 +628,7 @@ function createServer(opts) {
|
|
|
604
628
|
}
|
|
605
629
|
|
|
606
630
|
// Set last-visited project cookie for root redirect
|
|
607
|
-
res.setHeader("Set-Cookie", "
|
|
631
|
+
res.setHeader("Set-Cookie", "clagentic_last_project=" + slug + "; Path=/; SameSite=Strict; Max-Age=31536000" + (tlsOptions ? "; Secure" : ""));
|
|
608
632
|
|
|
609
633
|
// Multi-user: check project access for HTTP requests
|
|
610
634
|
if (users.isMultiUser() && onGetProjectAccess) {
|
package/lib/session-search.js
CHANGED
package/lib/sessions.js
CHANGED
|
@@ -264,6 +264,7 @@ function createSessionManager(opts) {
|
|
|
264
264
|
favoriteOrder: null,
|
|
265
265
|
vendor: (sessionOpts && sessionOpts.vendor) || null,
|
|
266
266
|
agentName: (sessionOpts && sessionOpts.agentName) || null,
|
|
267
|
+
cumulativeUsage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, turns: 0 },
|
|
267
268
|
};
|
|
268
269
|
sessions.set(localId, session);
|
|
269
270
|
switchSession(localId, targetWs);
|
|
@@ -297,6 +298,7 @@ function createSessionManager(opts) {
|
|
|
297
298
|
favoriteOrder: null,
|
|
298
299
|
vendor: (sessionOpts && sessionOpts.vendor) || null,
|
|
299
300
|
agentName: (sessionOpts && sessionOpts.agentName) || null,
|
|
301
|
+
cumulativeUsage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, turns: 0 },
|
|
300
302
|
};
|
|
301
303
|
sessions.set(localId, session);
|
|
302
304
|
return session;
|
|
@@ -353,7 +355,7 @@ function createSessionManager(opts) {
|
|
|
353
355
|
}
|
|
354
356
|
}
|
|
355
357
|
|
|
356
|
-
_send({ type: "history_done", lastUsage: lastUsage, lastModelUsage: lastModelUsage, lastCost: lastCost, lastStreamInputTokens: lastStreamInputTokens, contextUsage: session.lastContextUsage || null });
|
|
358
|
+
_send({ type: "history_done", lastUsage: lastUsage, lastModelUsage: lastModelUsage, lastCost: lastCost, lastStreamInputTokens: lastStreamInputTokens, contextUsage: session.lastContextUsage || null, cumulativeUsage: session.cumulativeUsage || null });
|
|
357
359
|
}
|
|
358
360
|
|
|
359
361
|
function switchSession(localId, targetWs, transform) {
|
|
@@ -845,6 +847,7 @@ function createSessionManager(opts) {
|
|
|
845
847
|
deleteSessionQuiet: deleteSessionQuiet,
|
|
846
848
|
deleteSessionsBulk: deleteSessionsBulk,
|
|
847
849
|
resumeSession: resumeSession,
|
|
850
|
+
mapSessionForClient: mapSessionForClient,
|
|
848
851
|
broadcastSessionList: broadcastSessionList,
|
|
849
852
|
getTotalUnread: function (ws) {
|
|
850
853
|
var unreadMap = ws && ws._clayUnread ? ws._clayUnread : singleUserUnread;
|
package/lib/smtp.js
CHANGED
|
@@ -89,9 +89,9 @@ function sendTestEmail(cfg, toEmail) {
|
|
|
89
89
|
return t.sendMail({
|
|
90
90
|
from: cfg.from,
|
|
91
91
|
to: toEmail,
|
|
92
|
-
subject: "
|
|
92
|
+
subject: "Clagentic:Console SMTP Test",
|
|
93
93
|
html: '<div style="font-family:system-ui,sans-serif;max-width:400px;margin:0 auto;padding:24px">' +
|
|
94
|
-
'<h2 style="color:#DA7756;margin:0 0 16px">
|
|
94
|
+
'<h2 style="color:#DA7756;margin:0 0 16px">Clagentic:Console</h2>' +
|
|
95
95
|
'<p style="color:#333;margin:0">SMTP is configured correctly. You will receive login codes and invite emails at this address.</p>' +
|
|
96
96
|
'</div>',
|
|
97
97
|
}).then(function (info) {
|
|
@@ -169,9 +169,9 @@ function verifyOtp(email, code) {
|
|
|
169
169
|
// --- Email templates ---
|
|
170
170
|
|
|
171
171
|
function sendOtpEmail(email, code) {
|
|
172
|
-
var subject = "Your
|
|
172
|
+
var subject = "Your Clagentic login code: " + code;
|
|
173
173
|
var html = '<div style="font-family:system-ui,sans-serif;max-width:400px;margin:0 auto;padding:24px">' +
|
|
174
|
-
'<h2 style="color:#DA7756;margin:0 0 16px">
|
|
174
|
+
'<h2 style="color:#DA7756;margin:0 0 16px">Clagentic:Console</h2>' +
|
|
175
175
|
'<p style="color:#333;margin:0 0 16px">Your verification code is:</p>' +
|
|
176
176
|
'<div style="font-size:32px;font-weight:700;letter-spacing:8px;padding:16px 0;text-align:center;' +
|
|
177
177
|
'background:#f5f5f5;border-radius:8px;color:#333;font-family:monospace">' + code + '</div>' +
|
|
@@ -181,10 +181,10 @@ function sendOtpEmail(email, code) {
|
|
|
181
181
|
}
|
|
182
182
|
|
|
183
183
|
function sendInviteEmail(email, inviteUrl, inviterName) {
|
|
184
|
-
var subject = "You've been invited to
|
|
184
|
+
var subject = "You've been invited to Clagentic:Console";
|
|
185
185
|
var html = '<div style="font-family:system-ui,sans-serif;max-width:400px;margin:0 auto;padding:24px">' +
|
|
186
|
-
'<h2 style="color:#DA7756;margin:0 0 16px">
|
|
187
|
-
'<p style="color:#333;margin:0 0 16px">' + (inviterName || "An admin") + ' has invited you to join
|
|
186
|
+
'<h2 style="color:#DA7756;margin:0 0 16px">Clagentic:Console</h2>' +
|
|
187
|
+
'<p style="color:#333;margin:0 0 16px">' + (inviterName || "An admin") + ' has invited you to join Clagentic:Console.</p>' +
|
|
188
188
|
'<p style="margin:0 0 16px"><a href="' + inviteUrl + '" style="display:inline-block;padding:12px 24px;' +
|
|
189
189
|
'background:#DA7756;color:#fff;text-decoration:none;border-radius:8px;font-weight:600">Accept Invite</a></p>' +
|
|
190
190
|
'<p style="color:#999;font-size:13px;margin:0">This invite link expires in 24 hours.</p>' +
|
package/lib/users-auth.js
CHANGED
|
@@ -77,10 +77,30 @@ function attachAuth(deps) {
|
|
|
77
77
|
return data.setupCode === code;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
// --- Pin hashing ---
|
|
80
|
+
// --- Pin hashing with scrypt ---
|
|
81
81
|
|
|
82
82
|
function hashPin(pin) {
|
|
83
|
-
|
|
83
|
+
var salt = crypto.randomBytes(16).toString("hex");
|
|
84
|
+
var hash = crypto.scryptSync(pin, salt, 64, { N: 16384, r: 8, p: 1 }).toString("hex");
|
|
85
|
+
return "scrypt:" + salt + ":" + hash;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Verify PIN against stored hash, supporting both scrypt and legacy SHA256
|
|
89
|
+
function verifyPin(pin, storedHash) {
|
|
90
|
+
if (!storedHash) return false;
|
|
91
|
+
if (storedHash.startsWith("scrypt:")) {
|
|
92
|
+
var parts = storedHash.split(":");
|
|
93
|
+
if (parts.length !== 3) return false;
|
|
94
|
+
var salt = parts[1];
|
|
95
|
+
var expected = parts[2];
|
|
96
|
+
var actual = crypto.scryptSync(pin, salt, 64, { N: 16384, r: 8, p: 1 }).toString("hex");
|
|
97
|
+
// Constant-time comparison to prevent timing attacks
|
|
98
|
+
if (actual.length !== expected.length) return false;
|
|
99
|
+
return crypto.timingSafeEqual(Buffer.from(actual, "hex"), Buffer.from(expected, "hex"));
|
|
100
|
+
}
|
|
101
|
+
// Legacy SHA256 fallback
|
|
102
|
+
var legacyHash = crypto.createHash("sha256").update("clay-user:" + pin).digest("hex");
|
|
103
|
+
return legacyHash === storedHash;
|
|
84
104
|
}
|
|
85
105
|
|
|
86
106
|
// Generate a random 6-digit PIN
|
|
@@ -93,7 +113,7 @@ function attachAuth(deps) {
|
|
|
93
113
|
return digits;
|
|
94
114
|
}
|
|
95
115
|
|
|
96
|
-
// --- Authentication ---
|
|
116
|
+
// --- Authentication with lazy upgrade ---
|
|
97
117
|
|
|
98
118
|
function authenticateUser(username, pin) {
|
|
99
119
|
var data = loadUsers();
|
|
@@ -105,8 +125,12 @@ function attachAuth(deps) {
|
|
|
105
125
|
}
|
|
106
126
|
}
|
|
107
127
|
if (!user) return null;
|
|
108
|
-
|
|
109
|
-
if
|
|
128
|
+
if (!verifyPin(pin, user.pinHash)) return null;
|
|
129
|
+
// Lazy upgrade: if stored hash is legacy SHA256, re-hash with scrypt now
|
|
130
|
+
if (user.pinHash && !user.pinHash.startsWith("scrypt:")) {
|
|
131
|
+
user.pinHash = hashPin(pin);
|
|
132
|
+
saveUsers(data);
|
|
133
|
+
}
|
|
110
134
|
return user;
|
|
111
135
|
}
|
|
112
136
|
|
|
@@ -136,6 +160,7 @@ function attachAuth(deps) {
|
|
|
136
160
|
clearSetupCode: clearSetupCode,
|
|
137
161
|
validateSetupCode: validateSetupCode,
|
|
138
162
|
hashPin: hashPin,
|
|
163
|
+
verifyPin: verifyPin,
|
|
139
164
|
generatePin: generatePin,
|
|
140
165
|
authenticateUser: authenticateUser,
|
|
141
166
|
generateUserAuthToken: generateUserAuthToken,
|
package/lib/users-preferences.js
CHANGED
package/lib/users.js
CHANGED
|
@@ -374,6 +374,7 @@ var validateSetupCode = auth.validateSetupCode;
|
|
|
374
374
|
var hashPin = auth.hashPin;
|
|
375
375
|
var generatePin = auth.generatePin;
|
|
376
376
|
var authenticateUser = auth.authenticateUser;
|
|
377
|
+
var verifyPin = auth.verifyPin;
|
|
377
378
|
var generateUserAuthToken = auth.generateUserAuthToken;
|
|
378
379
|
var parseAuthCookie = auth.parseAuthCookie;
|
|
379
380
|
|
|
@@ -414,6 +415,7 @@ module.exports = {
|
|
|
414
415
|
validateSetupCode: validateSetupCode,
|
|
415
416
|
generateUserId: generateUserId,
|
|
416
417
|
hashPin: hashPin,
|
|
418
|
+
verifyPin: verifyPin,
|
|
417
419
|
createUser: createUser,
|
|
418
420
|
createAdmin: createAdmin,
|
|
419
421
|
findAdmin: findAdmin,
|
package/lib/ws-schema.js
CHANGED
|
@@ -1297,7 +1297,7 @@ function createCodexAdapter(opts) {
|
|
|
1297
1297
|
await _appServer.start();
|
|
1298
1298
|
|
|
1299
1299
|
await _appServer.send("initialize", {
|
|
1300
|
-
clientInfo: { name: "
|
|
1300
|
+
clientInfo: { name: "clagentic", title: "Clagentic:Console", version: "1.0.0" },
|
|
1301
1301
|
capabilities: { experimentalApi: true },
|
|
1302
1302
|
});
|
|
1303
1303
|
_appServer.notify("initialized", {});
|
package/package.json
CHANGED
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.0.
|
|
6
|
+
"version": "1.0.1",
|
|
7
7
|
"description": "Self-hosted console for Claude Code and Codex. Multi-user, browser-based, persistent AI sessions.",
|
|
8
8
|
"bin": {
|
|
9
9
|
"clagentic": "./bin/cli.js",
|
|
10
|
-
"clagentic-console": "./bin/cli.js"
|
|
11
|
-
"clay-server": "./bin/cli.js"
|
|
10
|
+
"clagentic-console": "./bin/cli.js"
|
|
12
11
|
},
|
|
13
12
|
"scripts": {
|
|
14
13
|
"dev": "node bin/cli.js --dev",
|
|
14
|
+
"test": "node --test test/*.test.js",
|
|
15
15
|
"semantic-release": "semantic-release"
|
|
16
16
|
},
|
|
17
17
|
"files": [
|