@clagentic/console 1.4.1 → 1.5.0-beta.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.md +90 -21
- package/bin/cli.js +170 -60
- package/deploy/clagentic-console.service +2 -0
- package/lib/agents-favorites.js +3 -1
- package/lib/agents.js +75 -5
- package/lib/audit.js +23 -2
- package/lib/browser-mcp-server.js +5 -5
- package/lib/clone-validate.js +44 -0
- package/lib/config.js +175 -2
- package/lib/daemon.js +115 -9
- package/lib/dm.js +12 -1
- package/lib/ipc.js +12 -0
- package/lib/lite-detect.js +92 -0
- package/lib/os-users.js +8 -8
- package/lib/project-connection.js +7 -1
- package/lib/project-external-trigger.js +65 -6
- package/lib/project-loop.js +44 -3
- package/lib/project-sessions.js +95 -37
- package/lib/project.js +6 -1
- package/lib/public/app.js +6 -3
- package/lib/public/css/at-agents.css +68 -0
- package/lib/public/index.html +60 -0
- package/lib/public/modules/app-messages.js +38 -4
- package/lib/public/modules/at-agents.js +248 -0
- package/lib/public/modules/escape-html.js +19 -0
- package/lib/public/modules/filebrowser.js +12 -9
- package/lib/public/modules/input.js +26 -4
- package/lib/public/modules/pending-navigate.js +28 -0
- package/lib/public/modules/playbook.js +1 -1
- package/lib/public/modules/project-settings.js +75 -0
- package/lib/public/modules/project-switcher.js +1 -1
- package/lib/public/modules/server-settings.js +33 -0
- package/lib/public/modules/sticky-notes-fmt.js +52 -0
- package/lib/public/modules/sticky-notes.js +23 -5
- package/lib/public/modules/theme.js +1 -1
- package/lib/public/modules/tool-palette.js +1 -1
- package/lib/public/modules/utils.js +1 -3
- package/lib/public/style.css +1 -0
- package/lib/push.js +13 -2
- package/lib/scheduler.js +26 -2
- package/lib/sdk-bridge.js +7 -4
- package/lib/server-admin.js +1 -1
- package/lib/server-dm.js +16 -0
- package/lib/server-settings.js +42 -0
- package/lib/server-skills.js +10 -7
- package/lib/server.js +14 -3
- package/lib/sessions.js +4 -0
- package/lib/ws-schema.js +11 -1
- package/lib/yoke/adapters/claude-worker.js +2 -2
- package/lib/yoke/adapters/claude.js +47 -10
- package/lib/yoke/adapters/codex.js +14 -3
- package/lib/yoke/mcp-bridge-server.js +7 -7
- package/package.json +3 -2
- package/lib/relay-agent-claims.js +0 -480
|
@@ -558,7 +558,7 @@ function registerBuiltinPlaybooks() {
|
|
|
558
558
|
try {
|
|
559
559
|
var n = new Notification("Clagentic:Console", {
|
|
560
560
|
body: "Notifications are working! 🎉",
|
|
561
|
-
tag: "
|
|
561
|
+
tag: "clagentic-test-" + Date.now(),
|
|
562
562
|
});
|
|
563
563
|
n.onclick = function () { window.focus(); n.close(); };
|
|
564
564
|
setTimeout(function () { try { n.close(); } catch (e) {} }, 5000);
|
|
@@ -24,6 +24,7 @@ var PS_SECTIONS = [
|
|
|
24
24
|
{ section: "defaults", label: "Model", group: "General", icon: "cpu" },
|
|
25
25
|
{ section: "instructions", label: "Instructions", group: "Config", icon: "file-text" },
|
|
26
26
|
{ section: "environment", label: "Environment", group: "Config", icon: "terminal" },
|
|
27
|
+
{ section: "lite", label: "Lite", group: "Config", icon: "zap", conditionalId: "ps-nav-lite" },
|
|
27
28
|
];
|
|
28
29
|
|
|
29
30
|
// ===== Init =====
|
|
@@ -255,6 +256,7 @@ function switchSection(name) {
|
|
|
255
256
|
// Lazy-load section data
|
|
256
257
|
if (name === "defaults") populateDefaults();
|
|
257
258
|
if (name === "instructions") loadInstructions();
|
|
259
|
+
if (name === "lite") loadLiteSection();
|
|
258
260
|
if (name === "environment") {
|
|
259
261
|
// Reset tabs to "project" tab
|
|
260
262
|
var envTabs = panelEl.querySelectorAll(".ps-env-tab");
|
|
@@ -321,6 +323,11 @@ function renderPsPaletteResults(query) {
|
|
|
321
323
|
var visible = [];
|
|
322
324
|
for (var i = 0; i < PS_SECTIONS.length; i++) {
|
|
323
325
|
var s = PS_SECTIONS[i];
|
|
326
|
+
// Skip conditional sections that are hidden
|
|
327
|
+
if (s.conditionalId) {
|
|
328
|
+
var condEl = document.getElementById(s.conditionalId);
|
|
329
|
+
if (!condEl || condEl.classList.contains("hidden")) continue;
|
|
330
|
+
}
|
|
324
331
|
if (!q || s.label.toLowerCase().indexOf(q) !== -1 || s.group.toLowerCase().indexOf(q) !== -1) {
|
|
325
332
|
visible.push(s);
|
|
326
333
|
}
|
|
@@ -1017,3 +1024,71 @@ export function handleProjectOwnerChanged(msg) {
|
|
|
1017
1024
|
if (ownerNameEl) ownerNameEl.textContent = msg.ownerName || msg.ownerId || "Not set";
|
|
1018
1025
|
showToast("Project ownership transferred to " + (msg.ownerName || "new owner"));
|
|
1019
1026
|
}
|
|
1027
|
+
|
|
1028
|
+
// ===== Clagentic: Lite section =====
|
|
1029
|
+
|
|
1030
|
+
/**
|
|
1031
|
+
* Show or hide the Lite nav entry and section based on whether Lite is installed.
|
|
1032
|
+
* Called from app.js when the /info response is received.
|
|
1033
|
+
*/
|
|
1034
|
+
export function updateLiteVisibility(liteInstalled) {
|
|
1035
|
+
var navItem = document.getElementById("ps-nav-lite");
|
|
1036
|
+
var section = document.getElementById("ps-section-lite");
|
|
1037
|
+
if (navItem) navItem.classList.toggle("hidden", !liteInstalled);
|
|
1038
|
+
if (section) section.classList.toggle("hidden", !liteInstalled);
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
function loadLiteSection() {
|
|
1042
|
+
if (ctx.ws && ctx.connected) {
|
|
1043
|
+
ctx.ws.send(JSON.stringify({ type: "get_lite_project_status" }));
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
export function handleLiteProjectStatus(msg) {
|
|
1048
|
+
var statusEl = document.getElementById("ps-lite-status-text");
|
|
1049
|
+
var enrollBtn = document.getElementById("ps-lite-enroll-btn");
|
|
1050
|
+
var unenrollBtn = document.getElementById("ps-lite-unenroll-btn");
|
|
1051
|
+
var errorEl = document.getElementById("ps-lite-error");
|
|
1052
|
+
|
|
1053
|
+
if (statusEl) statusEl.textContent = msg.enrolled ? "Enrolled" : "Not enrolled";
|
|
1054
|
+
if (enrollBtn) enrollBtn.classList.toggle("hidden", !!msg.enrolled);
|
|
1055
|
+
if (unenrollBtn) unenrollBtn.classList.toggle("hidden", !msg.enrolled);
|
|
1056
|
+
if (errorEl) errorEl.textContent = "";
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
export function handleLiteEnrollResult(msg) {
|
|
1060
|
+
var errorEl = document.getElementById("ps-lite-error");
|
|
1061
|
+
if (!msg.ok) {
|
|
1062
|
+
if (errorEl) errorEl.textContent = msg.error || "Enroll failed";
|
|
1063
|
+
showToast("Lite enroll failed: " + (msg.error || "unknown error"));
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
export function handleLiteUnenrollResult(msg) {
|
|
1068
|
+
var errorEl = document.getElementById("ps-lite-error");
|
|
1069
|
+
if (!msg.ok) {
|
|
1070
|
+
if (errorEl) errorEl.textContent = msg.error || "Unenroll failed";
|
|
1071
|
+
showToast("Lite unenroll failed: " + (msg.error || "unknown error"));
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
export function initLiteButtons() {
|
|
1076
|
+
var enrollBtn = document.getElementById("ps-lite-enroll-btn");
|
|
1077
|
+
var unenrollBtn = document.getElementById("ps-lite-unenroll-btn");
|
|
1078
|
+
|
|
1079
|
+
if (enrollBtn) {
|
|
1080
|
+
enrollBtn.addEventListener("click", function () {
|
|
1081
|
+
if (ctx.ws && ctx.connected) {
|
|
1082
|
+
ctx.ws.send(JSON.stringify({ type: "lite_enroll_project" }));
|
|
1083
|
+
}
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
if (unenrollBtn) {
|
|
1088
|
+
unenrollBtn.addEventListener("click", function () {
|
|
1089
|
+
if (ctx.ws && ctx.connected) {
|
|
1090
|
+
ctx.ws.send(JSON.stringify({ type: "lite_unenroll_project" }));
|
|
1091
|
+
}
|
|
1092
|
+
});
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
@@ -152,7 +152,7 @@ function openSwitcher() {
|
|
|
152
152
|
_overlay.classList.remove('hidden');
|
|
153
153
|
_open = true;
|
|
154
154
|
refreshIcons();
|
|
155
|
-
// UI chrome matches the rest of
|
|
155
|
+
// UI chrome matches the rest of the app by swapping native emoji into
|
|
156
156
|
// Twemoji <img>s (same pattern as title bar, icon strip, project
|
|
157
157
|
// settings). The global COLR font fallback alone isn't reliable for
|
|
158
158
|
// UI surfaces because OS emoji fonts tend to match first.
|
|
@@ -24,6 +24,7 @@ var SETTINGS_SECTIONS = [
|
|
|
24
24
|
{ section: 'claudemd', label: 'Instructions', group: 'Config', icon: 'file-text', danger: false },
|
|
25
25
|
{ section: 'environment', label: 'Environment', group: 'Config', icon: 'terminal', danger: false },
|
|
26
26
|
{ section: 'storage', label: 'Storage', group: 'Config', icon: 'database', danger: false },
|
|
27
|
+
{ section: 'lite', label: 'Lite', group: 'Clagentic', icon: 'zap', danger: false },
|
|
27
28
|
{ section: 'admin-users', label: 'Users', group: 'Admin', icon: 'users', danger: false, adminOnly: true },
|
|
28
29
|
{ section: 'admin-invites', label: 'Invites', group: 'Admin', icon: 'mail', danger: false, adminOnly: true },
|
|
29
30
|
{ section: 'admin-projects', label: 'Projects', group: 'Admin', icon: 'folder', danger: false, adminOnly: true },
|
|
@@ -731,6 +732,12 @@ export function updateDaemonConfig(config) {
|
|
|
731
732
|
};
|
|
732
733
|
}
|
|
733
734
|
|
|
735
|
+
// Lite auto-enroll toggle
|
|
736
|
+
var liteAutoEnrollToggle = document.getElementById("settings-lite-auto-enroll");
|
|
737
|
+
if (liteAutoEnrollToggle && config.liteAutoEnroll !== undefined) {
|
|
738
|
+
liteAutoEnrollToggle.checked = !!config.liteAutoEnroll;
|
|
739
|
+
}
|
|
740
|
+
|
|
734
741
|
// Show keep awake section/nav only on macOS
|
|
735
742
|
var keepAwakeSection = document.getElementById("settings-keep-awake-section");
|
|
736
743
|
var keepAwakeNav = document.getElementById("settings-keep-awake-nav");
|
|
@@ -1066,3 +1073,29 @@ function formatUptime(seconds) {
|
|
|
1066
1073
|
if (h > 0) return h + "h " + m + "m " + s + "s";
|
|
1067
1074
|
return m + "m " + s + "s";
|
|
1068
1075
|
}
|
|
1076
|
+
|
|
1077
|
+
// ===== Clagentic: Lite system settings =====
|
|
1078
|
+
|
|
1079
|
+
/**
|
|
1080
|
+
* Toggle between the installed and not-installed sub-states in the Lite section.
|
|
1081
|
+
* The nav item and section are always visible in the HTML; only the sub-states change.
|
|
1082
|
+
* Called from app.js when the /info response is received.
|
|
1083
|
+
*/
|
|
1084
|
+
export function updateSsLiteVisibility(liteInstalled) {
|
|
1085
|
+
var installedEl = document.getElementById("settings-clagentic-installed");
|
|
1086
|
+
var notInstalledEl = document.getElementById("settings-clagentic-not-installed");
|
|
1087
|
+
if (installedEl) installedEl.classList.toggle("hidden", !liteInstalled);
|
|
1088
|
+
if (notInstalledEl) notInstalledEl.classList.toggle("hidden", !!liteInstalled);
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
export function initSsLiteToggle() {
|
|
1092
|
+
var liteAutoEnrollToggle = document.getElementById("settings-lite-auto-enroll");
|
|
1093
|
+
if (liteAutoEnrollToggle) {
|
|
1094
|
+
liteAutoEnrollToggle.addEventListener("change", function () {
|
|
1095
|
+
var ws = ctx.ws;
|
|
1096
|
+
if (ws && ws.readyState === 1) {
|
|
1097
|
+
ws.send(JSON.stringify({ type: "set_lite_auto_enroll", value: liteAutoEnrollToggle.checked }));
|
|
1098
|
+
}
|
|
1099
|
+
});
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// DOM-free export of the sticky-note text formatter used in renderMiniMarkdown.
|
|
2
|
+
//
|
|
3
|
+
// This module exists so Node-based tests can import and exercise the XSS-relevant
|
|
4
|
+
// escaping and auto-link logic without requiring a browser environment.
|
|
5
|
+
//
|
|
6
|
+
// The fmt() function inside renderMiniMarkdown is not independently exported from
|
|
7
|
+
// sticky-notes.js (it is browser-ESM with DOM deps). This module mirrors its exact
|
|
8
|
+
// implementation so that the regression tests call the real production logic pattern.
|
|
9
|
+
// Any change to fmt() in sticky-notes.js must be reflected here.
|
|
10
|
+
|
|
11
|
+
// The URL auto-link regex used in fmt(), exported for direct inspection in tests.
|
|
12
|
+
// Excludes whitespace, HTML special chars, and quote chars from URL matches so that
|
|
13
|
+
// a crafted URL like http://x.com"onmouseover="alert(1) cannot break out of the href.
|
|
14
|
+
export var AUTO_LINK_RE = /(https?:\/\/[^\s<>"']+)/g;
|
|
15
|
+
|
|
16
|
+
function escapeHtmlBasic(s) {
|
|
17
|
+
return s
|
|
18
|
+
.replace(/&/g, "&")
|
|
19
|
+
.replace(/</g, "<")
|
|
20
|
+
.replace(/>/g, ">")
|
|
21
|
+
.replace(/"/g, """)
|
|
22
|
+
.replace(/'/g, "'");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function fmt(s) {
|
|
26
|
+
// Split on raw URLs first (before any HTML escaping), so quote chars in the
|
|
27
|
+
// surrounding text still act as natural URL terminators in AUTO_LINK_RE.
|
|
28
|
+
// Non-URL segments are HTML-escaped; URL segments are escaped then wrapped in
|
|
29
|
+
// an anchor (the href value is also escaped so &, <, > inside URLs are safe).
|
|
30
|
+
AUTO_LINK_RE.lastIndex = 0;
|
|
31
|
+
var parts = s.split(AUTO_LINK_RE);
|
|
32
|
+
// split() with a capturing group produces: [text, url, text, url, ...]
|
|
33
|
+
var out = "";
|
|
34
|
+
for (var i = 0; i < parts.length; i++) {
|
|
35
|
+
if (i % 2 === 0) {
|
|
36
|
+
// Non-URL segment — HTML-escape fully.
|
|
37
|
+
out += escapeHtmlBasic(parts[i]);
|
|
38
|
+
} else {
|
|
39
|
+
// URL segment — escape for safe embedding in href and link text.
|
|
40
|
+
var safeUrl = escapeHtmlBasic(parts[i]);
|
|
41
|
+
out += '<a href="' + safeUrl + '" target="_blank" rel="noopener">' + safeUrl + "</a>";
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return out
|
|
45
|
+
.replace(/\*\*(.+?)\*\*/g, "<strong>$1</strong>")
|
|
46
|
+
.replace(/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g, "<em>$1</em>")
|
|
47
|
+
.replace(/`([^`]+)`/g, "<code>$1</code>")
|
|
48
|
+
.replace(/~~(.+?)~~/g, "<del>$1</del>")
|
|
49
|
+
.replace(/^- \[x\]/gm, '<span class="sn-check checked">✓</span>')
|
|
50
|
+
.replace(/^- \[ \]/gm, '<span class="sn-check">☐</span>')
|
|
51
|
+
.replace(/\n/g, "<br>");
|
|
52
|
+
}
|
|
@@ -150,13 +150,31 @@ function renderMiniMarkdown(text) {
|
|
|
150
150
|
var title = lines[0];
|
|
151
151
|
var body = lines.slice(1).join("\n");
|
|
152
152
|
|
|
153
|
-
|
|
154
|
-
|
|
153
|
+
var AUTO_LINK_RE = /(https?:\/\/[^\s<>"']+)/g;
|
|
154
|
+
function escHtml(s) {
|
|
155
|
+
return s
|
|
155
156
|
.replace(/&/g, "&")
|
|
156
157
|
.replace(/</g, "<")
|
|
157
|
-
.replace(/>/g, ">")
|
|
158
|
-
|
|
159
|
-
.replace(/
|
|
158
|
+
.replace(/>/g, ">")
|
|
159
|
+
.replace(/"/g, """)
|
|
160
|
+
.replace(/'/g, "'");
|
|
161
|
+
}
|
|
162
|
+
function fmt(s) {
|
|
163
|
+
// Split on raw URLs first so quote chars still terminate URL matches even
|
|
164
|
+
// after HTML-escaping. Non-URL segments are fully escaped; URL segments are
|
|
165
|
+
// escaped and wrapped in an anchor.
|
|
166
|
+
AUTO_LINK_RE.lastIndex = 0;
|
|
167
|
+
var parts = s.split(AUTO_LINK_RE);
|
|
168
|
+
var out = "";
|
|
169
|
+
for (var i = 0; i < parts.length; i++) {
|
|
170
|
+
if (i % 2 === 0) {
|
|
171
|
+
out += escHtml(parts[i]);
|
|
172
|
+
} else {
|
|
173
|
+
var safeUrl = escHtml(parts[i]);
|
|
174
|
+
out += '<a href="' + safeUrl + '" target="_blank" rel="noopener">' + safeUrl + "</a>";
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return out
|
|
160
178
|
.replace(/\*\*(.+?)\*\*/g, "<strong>$1</strong>")
|
|
161
179
|
.replace(/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g, "<em>$1</em>")
|
|
162
180
|
.replace(/`([^`]+)`/g, "<code>$1</code>")
|
|
@@ -629,7 +629,7 @@ function buildPickerContent() {
|
|
|
629
629
|
}
|
|
630
630
|
}
|
|
631
631
|
|
|
632
|
-
//
|
|
632
|
+
// Default themes always first in their section
|
|
633
633
|
function pinFirst(arr, pinId) {
|
|
634
634
|
var idx = arr.indexOf(pinId);
|
|
635
635
|
if (idx > 0) { arr.splice(idx, 1); arr.unshift(pinId); }
|
|
@@ -433,7 +433,7 @@ document.addEventListener('keydown', function (e) {
|
|
|
433
433
|
|
|
434
434
|
// Enter pick mode on Cmd/Ctrl + O (letter O). Intercepted globally
|
|
435
435
|
// including inside text inputs — the browser's native Cmd+O is a
|
|
436
|
-
// file-picker dialog
|
|
436
|
+
// file-picker dialog the app never wants, so taking it over costs the
|
|
437
437
|
// user nothing and is especially useful when jumping to a tool from
|
|
438
438
|
// the session search box.
|
|
439
439
|
if ((e.metaKey || e.ctrlKey) && !e.altKey && !e.shiftKey && e.key && e.key.toLowerCase() === 'o') {
|
|
@@ -51,6 +51,4 @@ export function copyToClipboard(text) {
|
|
|
51
51
|
return p.then(function () { showToast("Copied to clipboard"); });
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
export
|
|
55
|
-
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
56
|
-
}
|
|
54
|
+
export { escapeHtml } from './escape-html.js';
|
package/lib/public/style.css
CHANGED
package/lib/push.js
CHANGED
|
@@ -80,9 +80,20 @@ function initPush() {
|
|
|
80
80
|
|
|
81
81
|
function addSubscription(sub, replaceEndpoint, userId) {
|
|
82
82
|
if (!sub || !sub.endpoint) return;
|
|
83
|
-
// Remove previous subscription from the same client if endpoint changed
|
|
83
|
+
// Remove previous subscription from the same client if endpoint changed.
|
|
84
|
+
// Only delete replaceEndpoint if it belongs to the same caller — prevents an
|
|
85
|
+
// unauthenticated request from unsubscribing arbitrary known endpoints.
|
|
84
86
|
if (replaceEndpoint && replaceEndpoint !== sub.endpoint) {
|
|
85
|
-
subscriptions.
|
|
87
|
+
var existing = subscriptions.get(replaceEndpoint);
|
|
88
|
+
// In multi-user mode (userId set), require ownership match.
|
|
89
|
+
// In single-user / anonymous mode (userId null), allow the replacement
|
|
90
|
+
// only if the stored subscription is also anonymous (no _userId).
|
|
91
|
+
var callerOwns = userId
|
|
92
|
+
? (existing && existing._userId === userId)
|
|
93
|
+
: (existing && !existing._userId);
|
|
94
|
+
if (callerOwns) {
|
|
95
|
+
subscriptions.delete(replaceEndpoint);
|
|
96
|
+
}
|
|
86
97
|
}
|
|
87
98
|
// Attach userId for per-user targeting (backward-compatible: old subs without userId still work for broadcast)
|
|
88
99
|
if (userId) sub._userId = userId;
|
package/lib/scheduler.js
CHANGED
|
@@ -12,6 +12,11 @@ var path = require("path");
|
|
|
12
12
|
var { CONFIG_DIR } = require("./config");
|
|
13
13
|
var { encodeCwd } = require("./utils");
|
|
14
14
|
|
|
15
|
+
// NOTE: this regex mirrors validateLoopId() in project-loop.js. A circular
|
|
16
|
+
// import prevents sharing the function directly (project-loop requires this
|
|
17
|
+
// module). If the allowlist changes, update both. Tracked: lr-d049 nit.
|
|
18
|
+
var LOOP_ID_RE = /^loop_[A-Za-z0-9_-]+$/;
|
|
19
|
+
|
|
15
20
|
// --- Cron parser (5-field: minute hour day-of-month month day-of-week) ---
|
|
16
21
|
|
|
17
22
|
function parseCronField(field, min, max) {
|
|
@@ -24,6 +29,11 @@ function parseCronField(field, min, max) {
|
|
|
24
29
|
if (part.indexOf("/") !== -1) {
|
|
25
30
|
var slashParts = part.split("/");
|
|
26
31
|
var step = parseInt(slashParts[1], 10);
|
|
32
|
+
// Guard: step must be a positive integer. step=0 causes an infinite loop
|
|
33
|
+
// (v += 0 never advances); non-integer steps are not valid cron syntax.
|
|
34
|
+
if (!Number.isInteger(step) || step < 1) {
|
|
35
|
+
throw new Error("invalid cron step value: " + slashParts[1] + " (must be a positive integer)");
|
|
36
|
+
}
|
|
27
37
|
var rangeStr = slashParts[0];
|
|
28
38
|
var rangeMin = min;
|
|
29
39
|
var rangeMax = max;
|
|
@@ -297,8 +307,15 @@ function createLoopRegistry(opts) {
|
|
|
297
307
|
// --- CRUD ---
|
|
298
308
|
|
|
299
309
|
function register(data) {
|
|
310
|
+
// Validate caller-supplied id before storing it.
|
|
311
|
+
// Auto-generated IDs (the default) always pass the regex; this guard
|
|
312
|
+
// blocks client-supplied IDs that could later be used in path construction.
|
|
313
|
+
var suppliedId = data.id || null;
|
|
314
|
+
if (suppliedId !== null && !LOOP_ID_RE.test(suppliedId)) {
|
|
315
|
+
throw new Error("invalid_loop_id: " + suppliedId);
|
|
316
|
+
}
|
|
300
317
|
var rec = {
|
|
301
|
-
id:
|
|
318
|
+
id: suppliedId || ("loop_" + Date.now() + "_" + require("crypto").randomBytes(3).toString("hex")),
|
|
302
319
|
name: data.name || "Untitled",
|
|
303
320
|
task: data.task || "",
|
|
304
321
|
cron: data.cron || null,
|
|
@@ -468,4 +485,11 @@ function createLoopRegistry(opts) {
|
|
|
468
485
|
};
|
|
469
486
|
}
|
|
470
487
|
|
|
471
|
-
module.exports = {
|
|
488
|
+
module.exports = {
|
|
489
|
+
createLoopRegistry: createLoopRegistry,
|
|
490
|
+
// Exported for unit testing.
|
|
491
|
+
parseCronField: parseCronField,
|
|
492
|
+
parseCron: parseCron,
|
|
493
|
+
cronMatches: cronMatches,
|
|
494
|
+
nextRunTime: nextRunTime,
|
|
495
|
+
};
|
package/lib/sdk-bridge.js
CHANGED
|
@@ -1451,10 +1451,10 @@ function createSDKBridge(opts) {
|
|
|
1451
1451
|
adapterOptions: {
|
|
1452
1452
|
CLAUDE: claudeOpts,
|
|
1453
1453
|
CODEX: {
|
|
1454
|
-
// Always use "never" (auto-approve) because
|
|
1454
|
+
// Always use "never" (auto-approve) because Clagentic: Console handles tool
|
|
1455
1455
|
// permissions via its own UI (checkToolWhitelist + handleCanUseTool).
|
|
1456
1456
|
// Codex's native approval prompts are terminal-based and cannot be
|
|
1457
|
-
// relayed through
|
|
1457
|
+
// relayed through the web UI, causing MCP tool calls to hang.
|
|
1458
1458
|
approvalPolicy: "never",
|
|
1459
1459
|
sandboxMode: codexConfig.sandbox,
|
|
1460
1460
|
webSearchMode: codexConfig.webSearch,
|
|
@@ -1779,8 +1779,11 @@ function createSDKBridge(opts) {
|
|
|
1779
1779
|
}
|
|
1780
1780
|
}
|
|
1781
1781
|
|
|
1782
|
-
async function stopTask(taskId) {
|
|
1783
|
-
|
|
1782
|
+
async function stopTask(taskId, session) {
|
|
1783
|
+
// Accept an explicit session so multi-session installs stop the correct
|
|
1784
|
+
// session rather than the globally-active one (lr-e0de). Falls back to
|
|
1785
|
+
// sm.getActiveSession() so single-user installs are unaffected.
|
|
1786
|
+
if (!session) session = sm.getActiveSession();
|
|
1784
1787
|
if (!session) return;
|
|
1785
1788
|
session.taskStopRequested = true;
|
|
1786
1789
|
if (!session.queryInstance) return;
|
package/lib/server-admin.js
CHANGED
|
@@ -745,7 +745,7 @@ function attachAdmin(ctx) {
|
|
|
745
745
|
res.end('{"error":"Admin access required"}');
|
|
746
746
|
return true;
|
|
747
747
|
}
|
|
748
|
-
var auditPath = require("
|
|
748
|
+
var auditPath = require("./audit").auditLogPath();
|
|
749
749
|
var fs = require("fs");
|
|
750
750
|
try {
|
|
751
751
|
var raw = fs.readFileSync(auditPath, "utf8");
|
package/lib/server-dm.js
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
// Strict allow-list for client-supplied dmKey values.
|
|
2
|
+
// Accepts exactly two segments separated by a single colon, each containing
|
|
3
|
+
// only alphanumeric characters, hyphens, and underscores. This prevents path
|
|
4
|
+
// traversal via .. or / while keeping all legitimate userId:otherId keys valid.
|
|
5
|
+
var DM_KEY_RE = /^[A-Za-z0-9_-]+:[A-Za-z0-9_-]+$/;
|
|
6
|
+
|
|
7
|
+
function isValidDmKey(key) {
|
|
8
|
+
return typeof key === "string" && DM_KEY_RE.test(key);
|
|
9
|
+
}
|
|
10
|
+
|
|
1
11
|
function attachDm(ctx) {
|
|
2
12
|
var users = ctx.users;
|
|
3
13
|
var dm = ctx.dm;
|
|
@@ -62,6 +72,9 @@ function attachDm(ctx) {
|
|
|
62
72
|
// Relay typing indicator to DM partner
|
|
63
73
|
var dmKey = msg.dmKey;
|
|
64
74
|
if (!dmKey) return true;
|
|
75
|
+
// Reject any key not matching the strict allow-list pattern to prevent
|
|
76
|
+
// path traversal via crafted dmKey values (lr-6849).
|
|
77
|
+
if (!isValidDmKey(dmKey)) return true;
|
|
65
78
|
var parts = dmKey.split(":");
|
|
66
79
|
if (parts.indexOf(userId) === -1) return true;
|
|
67
80
|
var targetId = parts[0] === userId ? parts[1] : parts[0];
|
|
@@ -78,6 +91,9 @@ function attachDm(ctx) {
|
|
|
78
91
|
|
|
79
92
|
if (msg.type === "dm_send") {
|
|
80
93
|
if (!msg.dmKey || !msg.text) return true;
|
|
94
|
+
// Reject any key not matching the strict allow-list pattern to prevent
|
|
95
|
+
// path traversal via crafted dmKey values (lr-6849).
|
|
96
|
+
if (!isValidDmKey(msg.dmKey)) return true;
|
|
81
97
|
var parts = msg.dmKey.split(":");
|
|
82
98
|
|
|
83
99
|
// Verify sender is a participant
|
package/lib/server-settings.js
CHANGED
|
@@ -5,6 +5,7 @@ var audit = require("./audit");
|
|
|
5
5
|
function attachSettings(ctx) {
|
|
6
6
|
var users = ctx.users;
|
|
7
7
|
var getMultiUserFromReq = ctx.getMultiUserFromReq;
|
|
8
|
+
var isRequestAuthed = ctx.isRequestAuthed;
|
|
8
9
|
var projects = ctx.projects;
|
|
9
10
|
var opts = ctx.opts;
|
|
10
11
|
var CONFIG_DIR = ctx.CONFIG_DIR;
|
|
@@ -98,6 +99,11 @@ function attachSettings(ctx) {
|
|
|
98
99
|
pCtx.refreshUserProfile(mu.id);
|
|
99
100
|
});
|
|
100
101
|
} else {
|
|
102
|
+
if (!isRequestAuthed(req)) {
|
|
103
|
+
res.writeHead(401, { "Content-Type": "application/json" });
|
|
104
|
+
res.end('{"error":"unauthorized"}');
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
101
107
|
fs.writeFileSync(profilePath, JSON.stringify(profile, null, 2), "utf8");
|
|
102
108
|
if (process.platform !== "win32") {
|
|
103
109
|
try { fs.chmodSync(profilePath, 0o600); } catch (chmodErr) {}
|
|
@@ -153,6 +159,12 @@ function attachSettings(ctx) {
|
|
|
153
159
|
return;
|
|
154
160
|
}
|
|
155
161
|
userId = mu.id;
|
|
162
|
+
} else {
|
|
163
|
+
if (!isRequestAuthed(req)) {
|
|
164
|
+
res.writeHead(401, { "Content-Type": "application/json" });
|
|
165
|
+
res.end('{"error":"unauthorized"}');
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
156
168
|
}
|
|
157
169
|
var filename = userId + "." + ext;
|
|
158
170
|
// Remove old avatar files for this user
|
|
@@ -265,6 +277,11 @@ function attachSettings(ctx) {
|
|
|
265
277
|
var mu = getMultiUserFromReq(req);
|
|
266
278
|
if (!isMultiUser) {
|
|
267
279
|
// Single-user: use daemon config fallback
|
|
280
|
+
if (!isRequestAuthed(req)) {
|
|
281
|
+
res.writeHead(401, { "Content-Type": "application/json" });
|
|
282
|
+
res.end('{"error":"unauthorized"}');
|
|
283
|
+
return true;
|
|
284
|
+
}
|
|
268
285
|
var body = "";
|
|
269
286
|
req.on("data", function (chunk) { body += chunk; });
|
|
270
287
|
req.on("end", function () {
|
|
@@ -314,6 +331,11 @@ function attachSettings(ctx) {
|
|
|
314
331
|
var mu = getMultiUserFromReq(req);
|
|
315
332
|
if (!isMultiUser) {
|
|
316
333
|
// Single-user: save to daemon config
|
|
334
|
+
if (!isRequestAuthed(req)) {
|
|
335
|
+
res.writeHead(401, { "Content-Type": "application/json" });
|
|
336
|
+
res.end('{"error":"unauthorized"}');
|
|
337
|
+
return true;
|
|
338
|
+
}
|
|
317
339
|
var body = "";
|
|
318
340
|
req.on("data", function (chunk) { body += chunk; });
|
|
319
341
|
req.on("end", function () {
|
|
@@ -362,6 +384,11 @@ function attachSettings(ctx) {
|
|
|
362
384
|
if (req.method === "PUT" && fullUrl === "/api/user/theme-mode") {
|
|
363
385
|
var isMultiUser = users.isMultiUser();
|
|
364
386
|
var mu = getMultiUserFromReq(req);
|
|
387
|
+
if (!isMultiUser && !isRequestAuthed(req)) {
|
|
388
|
+
res.writeHead(401, { "Content-Type": "application/json" });
|
|
389
|
+
res.end('{"error":"unauthorized"}');
|
|
390
|
+
return true;
|
|
391
|
+
}
|
|
365
392
|
var body = "";
|
|
366
393
|
req.on("data", function (chunk) { body += chunk; });
|
|
367
394
|
req.on("end", function () {
|
|
@@ -401,6 +428,11 @@ function attachSettings(ctx) {
|
|
|
401
428
|
if (req.method === "PUT" && fullUrl === "/api/user/theme-brand") {
|
|
402
429
|
var isMultiUser = users.isMultiUser();
|
|
403
430
|
var mu = getMultiUserFromReq(req);
|
|
431
|
+
if (!isMultiUser && !isRequestAuthed(req)) {
|
|
432
|
+
res.writeHead(401, { "Content-Type": "application/json" });
|
|
433
|
+
res.end('{"error":"unauthorized"}');
|
|
434
|
+
return true;
|
|
435
|
+
}
|
|
404
436
|
var body = "";
|
|
405
437
|
req.on("data", function (chunk) { body += chunk; });
|
|
406
438
|
req.on("end", function () {
|
|
@@ -462,6 +494,11 @@ function attachSettings(ctx) {
|
|
|
462
494
|
if (req.method === "PUT" && fullUrl === "/api/user/tool-palettes") {
|
|
463
495
|
var isMultiUser = users.isMultiUser();
|
|
464
496
|
var muPut = getMultiUserFromReq(req);
|
|
497
|
+
if (!isMultiUser && !isRequestAuthed(req)) {
|
|
498
|
+
res.writeHead(401, { "Content-Type": "application/json" });
|
|
499
|
+
res.end('{"error":"unauthorized"}');
|
|
500
|
+
return true;
|
|
501
|
+
}
|
|
465
502
|
var bodyTp = "";
|
|
466
503
|
req.on("data", function (chunk) { bodyTp += chunk; });
|
|
467
504
|
req.on("end", function () {
|
|
@@ -529,6 +566,11 @@ function attachSettings(ctx) {
|
|
|
529
566
|
res.end('{"error":"Already in multi-user mode"}');
|
|
530
567
|
return true;
|
|
531
568
|
}
|
|
569
|
+
if (!isRequestAuthed(req)) {
|
|
570
|
+
res.writeHead(401, { "Content-Type": "application/json" });
|
|
571
|
+
res.end('{"error":"unauthorized"}');
|
|
572
|
+
return true;
|
|
573
|
+
}
|
|
532
574
|
// Only allow in single-user mode with PIN
|
|
533
575
|
if (!opts.pinHash) {
|
|
534
576
|
res.writeHead(400, { "Content-Type": "application/json" });
|
package/lib/server-skills.js
CHANGED
|
@@ -164,13 +164,16 @@ function attachSkills(ctx) {
|
|
|
164
164
|
// Permission gate
|
|
165
165
|
if (users.isMultiUser()) {
|
|
166
166
|
var skMu = getMultiUserFromReq(req);
|
|
167
|
-
if (skMu) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
167
|
+
if (!skMu) {
|
|
168
|
+
res.writeHead(401, { "Content-Type": "application/json" });
|
|
169
|
+
res.end('{"error":"unauthorized"}');
|
|
170
|
+
return true;
|
|
171
|
+
}
|
|
172
|
+
var skPerms = users.getEffectivePermissions(skMu, osUsers);
|
|
173
|
+
if (!skPerms.skills) {
|
|
174
|
+
res.writeHead(403, { "Content-Type": "application/json" });
|
|
175
|
+
res.end('{"error":"Skills access is not permitted"}');
|
|
176
|
+
return true;
|
|
174
177
|
}
|
|
175
178
|
}
|
|
176
179
|
|
package/lib/server.js
CHANGED
|
@@ -16,6 +16,7 @@ var serverPalette = require("./server-palette");
|
|
|
16
16
|
|
|
17
17
|
var { CONFIG_DIR } = require("./config");
|
|
18
18
|
var { provisionLinuxUser } = require("./os-users");
|
|
19
|
+
var { detectLite } = require("./lite-detect");
|
|
19
20
|
|
|
20
21
|
var https = require("https");
|
|
21
22
|
var pkg = require("../package.json");
|
|
@@ -181,6 +182,7 @@ function createServer(opts) {
|
|
|
181
182
|
var onSetKeepAwake = opts.onSetKeepAwake || null;
|
|
182
183
|
var onSetImageRetention = opts.onSetImageRetention || null;
|
|
183
184
|
var onSetMemAvailableThreshold = opts.onSetMemAvailableThreshold || null;
|
|
185
|
+
var onSetLiteAutoEnroll = opts.onSetLiteAutoEnroll || null;
|
|
184
186
|
var onShutdown = opts.onShutdown || null;
|
|
185
187
|
var onRestart = opts.onRestart || null;
|
|
186
188
|
var onSetUpdateChannel = opts.onSetUpdateChannel || null;
|
|
@@ -245,6 +247,7 @@ function createServer(opts) {
|
|
|
245
247
|
var settings = serverSettings.attachSettings({
|
|
246
248
|
users: users,
|
|
247
249
|
getMultiUserFromReq: getMultiUserFromReq,
|
|
250
|
+
isRequestAuthed: isRequestAuthed,
|
|
248
251
|
projects: projects,
|
|
249
252
|
opts: opts,
|
|
250
253
|
CONFIG_DIR: CONFIG_DIR,
|
|
@@ -274,7 +277,7 @@ function createServer(opts) {
|
|
|
274
277
|
});
|
|
275
278
|
|
|
276
279
|
// --- External trigger watcher (global singleton) ---
|
|
277
|
-
// Watches ~/.
|
|
280
|
+
// Watches ~/.clagentic/external-triggers/ for JSON files dropped by external
|
|
278
281
|
// processes. On valid file: spawns a session in the named project with
|
|
279
282
|
// initialPrompt pre-loaded as the first user-turn. No UI notification is
|
|
280
283
|
// emitted — the trigger carries its own notification channel (e.g. ntfy).
|
|
@@ -441,7 +444,7 @@ function createServer(opts) {
|
|
|
441
444
|
return;
|
|
442
445
|
}
|
|
443
446
|
|
|
444
|
-
// Theme list: bundled (lib/themes/) + user (~/.
|
|
447
|
+
// Theme list: bundled (lib/themes/) + user (~/.clagentic/themes/)
|
|
445
448
|
if (req.method === "GET" && fullUrl === "/api/themes") {
|
|
446
449
|
var bundled = {};
|
|
447
450
|
var custom = {};
|
|
@@ -574,8 +577,15 @@ function createServer(opts) {
|
|
|
574
577
|
projects.forEach(function (ctx, slug) {
|
|
575
578
|
projectList.push({ slug: slug, project: ctx.project });
|
|
576
579
|
});
|
|
580
|
+
var liteStatus = detectLite();
|
|
577
581
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
578
|
-
res.end(JSON.stringify({
|
|
582
|
+
res.end(JSON.stringify({
|
|
583
|
+
projects: projectList,
|
|
584
|
+
version: currentVersion,
|
|
585
|
+
authenticated: true,
|
|
586
|
+
liteInstalled: liteStatus.installed,
|
|
587
|
+
liteHome: liteStatus.liteHome,
|
|
588
|
+
}));
|
|
579
589
|
return;
|
|
580
590
|
}
|
|
581
591
|
|
|
@@ -1077,6 +1087,7 @@ function createServer(opts) {
|
|
|
1077
1087
|
onSetKeepAwake: onSetKeepAwake,
|
|
1078
1088
|
onSetImageRetention: onSetImageRetention,
|
|
1079
1089
|
onSetMemAvailableThreshold: onSetMemAvailableThreshold,
|
|
1090
|
+
onSetLiteAutoEnroll: onSetLiteAutoEnroll,
|
|
1080
1091
|
onSetUpdateChannel: onSetUpdateChannel,
|
|
1081
1092
|
updateChannel: onGetDaemonConfig ? (onGetDaemonConfig().updateChannel || "stable") : "stable",
|
|
1082
1093
|
onShutdown: onShutdown,
|
package/lib/sessions.js
CHANGED
|
@@ -45,6 +45,10 @@ function createSessionManager(opts) {
|
|
|
45
45
|
|
|
46
46
|
function saveSessionFile(session) {
|
|
47
47
|
if (!session.cliSessionId) return;
|
|
48
|
+
// Flush any pending async-append buffer before rewriting the file so that
|
|
49
|
+
// lines already queued by doSendAndRecord are not double-appended once the
|
|
50
|
+
// timer fires after the atomic rename completes (lr-e0de).
|
|
51
|
+
flushSessionBuffer(session);
|
|
48
52
|
try {
|
|
49
53
|
var metaObj = {
|
|
50
54
|
type: "meta",
|