@clagentic/console 1.5.0-beta.3 → 1.5.0-beta.4
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 +18 -14
- package/lib/cli-sessions.js +71 -18
- package/lib/daemon.js +72 -24
- package/lib/pages.js +1 -42
- package/lib/project-connection.js +4 -8
- package/lib/project-loop.js +1 -1
- package/lib/project-notifications.js +3 -18
- package/lib/project-sessions.js +19 -26
- package/lib/project-user-message.js +5 -10
- package/lib/project.js +39 -52
- package/lib/public/app.js +5 -15
- package/lib/public/modules/admin.js +1 -52
- package/lib/public/modules/agent-picker.js +11 -3
- package/lib/public/modules/app-cursors.js +43 -47
- package/lib/public/modules/app-messages.js +5 -12
- package/lib/public/modules/app-rendering.js +1 -2
- package/lib/public/modules/sidebar-projects.js +1 -1
- package/lib/public/modules/sidebar-sessions.js +2 -2
- package/lib/public/modules/sidebar-users.js +2 -12
- package/lib/public/modules/user-settings.js +0 -3
- package/lib/sdk-bridge.js +47 -7
- package/lib/sdk-message-processor.js +3 -4
- package/lib/server-admin.js +1 -86
- package/lib/server-auth.js +13 -124
- package/lib/server-dm.js +2 -7
- package/lib/server-palette.js +9 -20
- package/lib/server-settings.js +41 -243
- package/lib/server-skills.js +11 -13
- package/lib/server.js +25 -60
- package/lib/sessions.js +16 -50
- package/lib/terminal-manager.js +13 -15
- package/lib/users-auth.js +0 -38
- package/lib/users.js +14 -11
- package/lib/yoke/adapters/claude.js +5 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<img src="media/logo/console-lockup-256.png" alt="Clagentic: Console" width="260" />
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
|
-
<h4 align="center">
|
|
5
|
+
<h4 align="center">A shared workspace for humans and AI agents.</h4>
|
|
6
6
|
|
|
7
7
|
<p align="center">
|
|
8
8
|
<a href="https://clagentic.ai"><img src="https://img.shields.io/badge/-clagentic.ai-00CFFF?style=flat&logoColor=white" alt="clagentic.ai" /></a>
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
<a href="https://ko-fi.com/clagentic"><img src="https://img.shields.io/badge/Ko--fi-FF5E5B?style=flat&logo=ko-fi&logoColor=white&label=support" alt="Support on Ko-fi" /></a>
|
|
14
14
|
</p>
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Clagentic: Console is a self-hosted team workspace where human developers and named AI agents share the same interface. Multiple users connect to a single daemon, each with their own account and project access. Agents are first-class participants — not background processes you poll, but named entities with their own conversation history, context window, and session state, visible to the whole team. Every project, every session, every tool approval lives on your machine and stays there.
|
|
17
17
|
|
|
18
18
|
## Install
|
|
19
19
|
|
|
@@ -47,23 +47,25 @@ npm install -g @clagentic/console --ignore-scripts
|
|
|
47
47
|
|
|
48
48
|
## What it does
|
|
49
49
|
|
|
50
|
-
- **
|
|
50
|
+
- **Real team accounts.** Every team member gets their own login. Multiple users connect to the same Console daemon simultaneously — each with their own session history, project access, and tool approval flow. No shared credentials, no per-user installs.
|
|
51
51
|
|
|
52
|
-
- **
|
|
53
|
-
|
|
54
|
-
- **Loop automation.** Write a `PROMPT.md`, start a loop. Clagentic: Console runs the prompt, evaluates the result, and retries until done or capped. Schedule loops with standard cron syntax to run unattended.
|
|
52
|
+
- **Agents as first-class participants.** Named agents defined in `.claude/agents/` or `~/.claude/agents/` are not background scripts — they're full participants. Each runs in its own session with its own conversation history, context window, and state. Team members can favorite agents, DM them directly, and see which agents are active. Type `@` in the session input to launch one by name.
|
|
55
53
|
|
|
56
|
-
- **
|
|
54
|
+
- **Team panel.** A dedicated Team surface lists every human user and named agent connected to the Console. Direct-message any participant, see who's online, and manage the agent roster — all from the same sidebar that shows your projects.
|
|
57
55
|
|
|
58
|
-
- **
|
|
56
|
+
- **Vendor-agnostic via YOKE.** The YOKE adapter layer treats Claude Code (Claude Agent SDK), ChatGPT Codex (codex app-server JSON-RPC), and future local models as interchangeable backends. Switch vendors per session; sessions remember their choice. YOKE also cross-injects instruction files — `CLAUDE.md`, `AGENTS.md`, `.cursorrules`, `COPILOT.md`, `.github/copilot-instructions.md` — so project context reaches whichever model is running.
|
|
59
57
|
|
|
60
58
|
- **Multi-project dashboard.** Every repo registered with the daemon in one sidebar. Jump between projects, run sessions in parallel, see live status at a glance.
|
|
61
59
|
|
|
62
|
-
- **
|
|
60
|
+
- **Context injection.** Pin running terminals, live browser tabs, and sticky notes as active context sources. Their content flows into every message automatically: terminal output as a delta since your last message, browser tabs as full snapshots. No manual copy-paste. No extra prompting.
|
|
63
61
|
|
|
64
|
-
- **
|
|
62
|
+
- **Loop automation.** Write a `PROMPT.md`, start a loop. Clagentic: Console runs the prompt, evaluates the result, and retries until done or capped. Schedule loops with standard cron syntax to run unattended.
|
|
63
|
+
|
|
64
|
+
- **External triggers.** Drop a JSON file into `~/.clagentic/external-triggers/` to spawn a new AI session or inject a message into an existing one. Use this to wire agents into scripts, CI pipelines, or other AI processes — no API, no polling, just a file drop.
|
|
65
65
|
|
|
66
|
-
- **
|
|
66
|
+
- **Mobile PWA + push notifications.** Installable on iOS and Android. Approve tool calls from your phone. Push fires on approval requests, errors, and task completion.
|
|
67
|
+
|
|
68
|
+
- **OS-level isolation (Linux).** On Linux, opt in: each user maps to a real system account, file ACLs via `setfacl`, processes spawn under the correct UID/GID.
|
|
67
69
|
|
|
68
70
|
- **MCP servers.** Built-in ask-user and browser servers. User-configured MCPs via `~/.clagentic/mcp.json`. Works in both Claude and Codex sessions.
|
|
69
71
|
|
|
@@ -73,7 +75,9 @@ npm install -g @clagentic/console --ignore-scripts
|
|
|
73
75
|
|
|
74
76
|
## Getting Started
|
|
75
77
|
|
|
76
|
-
On first run you'll be asked for a port and prompted to create your admin account. Open the URL from any device on your network.
|
|
78
|
+
On first run you'll be asked for a port and prompted to create your admin account. Open the URL from any device on your network — team members can log in with their own accounts from their own machines.
|
|
79
|
+
|
|
80
|
+
Enable multi-user mode in System Settings to activate OS-level isolation (Linux) and the team-management panel. Additional accounts are created from the admin UI or CLI; each user gets independent session history and project access.
|
|
77
81
|
|
|
78
82
|
For remote access, use a tunnel — Tailscale, Cloudflare Tunnel, or your existing VPN.
|
|
79
83
|
|
|
@@ -173,7 +177,7 @@ Run the suite: `npm test`
|
|
|
173
177
|
No. Clagentic: Console drives Claude Code through the Claude Agent SDK and Codex through the Codex app-server protocol. It adds multi-session orchestration, named agent sessions, scheduled agents, multi-user support, built-in MCP servers, context injection, external triggers, and a full browser UI on top.
|
|
174
178
|
|
|
175
179
|
**"What are named agents?"**
|
|
176
|
-
Agents defined in your Claude Code config (`.claude/agents/` or `~/.claude/agents/`)
|
|
180
|
+
Agents defined in your Claude Code config (`.claude/agents/` or `~/.claude/agents/`) are first-class team participants. Type `@` in the session input to see every installed agent and launch one directly — its own conversation history, context window, and session state. Team members can favorite agents and DM them from the Team panel alongside human users.
|
|
177
181
|
|
|
178
182
|
Named agents are **currently Claude Code only.** The Codex adapter has no equivalent API for per-session agent identity injection. When you're in a Codex session, the agent entry point is hidden. Partial Codex parity (system-prompt prepend) is planned.
|
|
179
183
|
|
|
@@ -208,7 +212,7 @@ Yes. Install as a PWA on iOS or Android. Push notifications for approvals, error
|
|
|
208
212
|
Yes. User-configured MCPs from `~/.clagentic/mcp.json` plus built-in ask-user and browser servers work in both Claude and Codex sessions.
|
|
209
213
|
|
|
210
214
|
**"Multi-user support?"**
|
|
211
|
-
Yes.
|
|
215
|
+
Yes — it is a core design goal, not an add-on. Real accounts, independent session history, and a Team panel that shows every human user and agent connected to the Console. On Linux, enable OS-level isolation: each user maps to a real Linux account, file ACLs via `setfacl`, processes spawn under the correct UID/GID.
|
|
212
216
|
|
|
213
217
|
**"Does it integrate with Clagentic: Lite?"**
|
|
214
218
|
Yes, optionally. [Clagentic: Lite](https://clagentic.ai/tools) adds agentic gates, session memory, and audit trails to any repo. If Lite is installed (`~/.clagentic/lite/`), Console detects it automatically and shows an enrollment panel in each project's settings. Enable auto-enroll in system settings to wire up every project on add. Lite is never required — Console works normally without it.
|
package/lib/cli-sessions.js
CHANGED
|
@@ -6,6 +6,19 @@ var { REAL_HOME } = require("./config");
|
|
|
6
6
|
|
|
7
7
|
var encodeCwd = utils.encodeCwd;
|
|
8
8
|
|
|
9
|
+
// Maximum number of sessions returned by listCliSessions().
|
|
10
|
+
// Prevents OOM on installs with large session archives (e.g. 30K+ files).
|
|
11
|
+
// Tunable: raise if users need deeper history in the session picker.
|
|
12
|
+
var MAX_CLI_SESSIONS = 200;
|
|
13
|
+
|
|
14
|
+
// Sessions older than this are excluded before any file I/O.
|
|
15
|
+
// 90 days keeps the session picker relevant without opening stale files.
|
|
16
|
+
var CLI_SESSION_MAX_AGE_MS = 90 * 24 * 60 * 60 * 1000;
|
|
17
|
+
|
|
18
|
+
// Max simultaneous parseSessionFile() calls inside listCliSessions().
|
|
19
|
+
// Caps readline stream count; too high → fd exhaustion; too low → slow.
|
|
20
|
+
var PARSE_CONCURRENCY = 20;
|
|
21
|
+
|
|
9
22
|
/**
|
|
10
23
|
* Parse the first ~20 lines of a CLI session JSONL file to extract metadata.
|
|
11
24
|
* Returns null if the file can't be parsed or has no user messages.
|
|
@@ -105,6 +118,12 @@ function parseSessionFile(filePath, maxLines) {
|
|
|
105
118
|
* List CLI sessions for a given project directory.
|
|
106
119
|
* Reads ~/.claude/projects/{encoded-cwd}/ and parses JSONL metadata.
|
|
107
120
|
* Returns array sorted by lastActivity descending (most recent first).
|
|
121
|
+
*
|
|
122
|
+
* Two-stage to prevent OOM on large session archives:
|
|
123
|
+
* Stage 1 — stat + cap: filter by recency (CLI_SESSION_MAX_AGE_MS), sort by
|
|
124
|
+
* mtime descending, slice to MAX_CLI_SESSIONS.
|
|
125
|
+
* Stage 2 — promise pool: parse the capped list with at most
|
|
126
|
+
* PARSE_CONCURRENCY simultaneous parseSessionFile() calls.
|
|
108
127
|
*/
|
|
109
128
|
function listCliSessions(cwd) {
|
|
110
129
|
var encoded = encodeCwd(cwd);
|
|
@@ -114,32 +133,66 @@ function listCliSessions(cwd) {
|
|
|
114
133
|
fs.readdir(projectDir, { withFileTypes: true }, function (err, entries) {
|
|
115
134
|
if (err) return resolve([]);
|
|
116
135
|
|
|
117
|
-
var
|
|
136
|
+
var now = Date.now();
|
|
137
|
+
var cutoff = now - CLI_SESSION_MAX_AGE_MS;
|
|
138
|
+
|
|
139
|
+
// Stage 1: stat every .jsonl file, drop stale entries, sort and cap.
|
|
140
|
+
var candidates = [];
|
|
118
141
|
for (var i = 0; i < entries.length; i++) {
|
|
119
|
-
if (entries[i].isFile()
|
|
120
|
-
|
|
142
|
+
if (!entries[i].isFile() || !entries[i].name.endsWith(".jsonl")) continue;
|
|
143
|
+
var filePath = path.join(projectDir, entries[i].name);
|
|
144
|
+
try {
|
|
145
|
+
var st = fs.statSync(filePath);
|
|
146
|
+
if (st.mtimeMs >= cutoff) {
|
|
147
|
+
candidates.push({ filePath: filePath, mtimeMs: st.mtimeMs });
|
|
148
|
+
}
|
|
149
|
+
} catch (e) {
|
|
150
|
+
// File disappeared between readdir and stat — skip it.
|
|
121
151
|
}
|
|
122
152
|
}
|
|
123
153
|
|
|
124
|
-
if (
|
|
154
|
+
if (candidates.length === 0) return resolve([]);
|
|
125
155
|
|
|
126
|
-
|
|
127
|
-
|
|
156
|
+
// Sort newest-first, then cap.
|
|
157
|
+
candidates.sort(function (a, b) { return b.mtimeMs - a.mtimeMs; });
|
|
158
|
+
if (candidates.length > MAX_CLI_SESSIONS) {
|
|
159
|
+
candidates = candidates.slice(0, MAX_CLI_SESSIONS);
|
|
160
|
+
}
|
|
128
161
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
162
|
+
// Stage 2: promise pool — at most PARSE_CONCURRENCY concurrent parses.
|
|
163
|
+
var results = [];
|
|
164
|
+
var index = 0; // next candidate to start
|
|
165
|
+
var active = 0; // currently running parseSessionFile calls
|
|
166
|
+
var total = candidates.length;
|
|
167
|
+
var done = 0; // completed calls
|
|
168
|
+
|
|
169
|
+
function finish() {
|
|
170
|
+
results.sort(function (a, b) {
|
|
171
|
+
var ta = a.lastActivity || "";
|
|
172
|
+
var tb = b.lastActivity || "";
|
|
173
|
+
return ta < tb ? 1 : ta > tb ? -1 : 0;
|
|
141
174
|
});
|
|
175
|
+
resolve(results);
|
|
142
176
|
}
|
|
177
|
+
|
|
178
|
+
function schedule() {
|
|
179
|
+
while (active < PARSE_CONCURRENCY && index < total) {
|
|
180
|
+
var item = candidates[index++];
|
|
181
|
+
active++;
|
|
182
|
+
parseSessionFile(item.filePath).then(function (session) {
|
|
183
|
+
if (session) results.push(session);
|
|
184
|
+
active--;
|
|
185
|
+
done++;
|
|
186
|
+
if (done === total) {
|
|
187
|
+
finish();
|
|
188
|
+
} else {
|
|
189
|
+
schedule();
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
schedule();
|
|
143
196
|
});
|
|
144
197
|
});
|
|
145
198
|
}
|
package/lib/daemon.js
CHANGED
|
@@ -25,7 +25,7 @@ var fs = require("fs");
|
|
|
25
25
|
var path = require("path");
|
|
26
26
|
var { loadConfig, saveConfig, socketPath, ensureConfigDir, generateSlug, syncClayrc, removeFromClayrc, writeCrashInfo, readCrashInfo, clearCrashInfo, isPidAlive, clearStaleConfig, REAL_HOME } = require("./config");
|
|
27
27
|
var { createIPCServer } = require("./ipc");
|
|
28
|
-
var { createServer
|
|
28
|
+
var { createServer } = require("./server");
|
|
29
29
|
var { checkAclSupport, grantProjectAccess, revokeProjectAccess, provisionAllUsers, provisionLinuxUser, grantAllUsersAccess, deactivateLinuxUser, ensureProjectsDir } = require("./os-users");
|
|
30
30
|
var usersModule = require("./users");
|
|
31
31
|
var { createWorktree, removeWorktree, isWorktree } = require("./worktree");
|
|
@@ -109,13 +109,76 @@ if (checkStaleInodes()) {
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
|
|
112
|
-
// --- Single-user migration
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
112
|
+
// --- Single-user to multi-user migration (lr-ec2d) ---
|
|
113
|
+
function migrateSingleUserToMultiUser(cfg, data) {
|
|
114
|
+
if (data.multiUser) return; // already migrated, no-op
|
|
115
|
+
|
|
116
|
+
var fsMig = require("fs");
|
|
117
|
+
var pathMig = require("path");
|
|
118
|
+
var cryptoMig = require("crypto");
|
|
119
|
+
var usersFilePath = usersModule.USERS_FILE;
|
|
120
|
+
|
|
121
|
+
var hasPin = !!(cfg && cfg.pinHash);
|
|
122
|
+
var hasAdmin = data.users && data.users.some(function (u) { return u.role === "admin"; });
|
|
123
|
+
|
|
124
|
+
data.multiUser = true;
|
|
125
|
+
|
|
126
|
+
// Generate setup code using the users module's exported function
|
|
127
|
+
var setupCode = cryptoMig.randomBytes(4).toString("hex").toUpperCase();
|
|
128
|
+
data.setupCode = setupCode;
|
|
129
|
+
|
|
130
|
+
// Case A: PIN set, no users — create admin stub (PIN cannot be transferred, incompatible hash formats)
|
|
131
|
+
if (hasPin && (!data.users || data.users.length === 0)) {
|
|
132
|
+
var adminId = cryptoMig.randomUUID();
|
|
133
|
+
data.users = [{
|
|
134
|
+
id: adminId,
|
|
135
|
+
username: "admin",
|
|
136
|
+
email: null,
|
|
137
|
+
displayName: "Admin",
|
|
138
|
+
pinHash: null, // PIN cannot be transferred — incompatible hash formats (lr-ec2d spec §7 risk 1)
|
|
139
|
+
role: "admin",
|
|
140
|
+
createdAt: Date.now(),
|
|
141
|
+
mustChangePin: false,
|
|
142
|
+
linuxUser: null,
|
|
143
|
+
profile: {
|
|
144
|
+
name: "Admin",
|
|
145
|
+
lang: "en-US",
|
|
146
|
+
avatarColor: "#7c3aed",
|
|
147
|
+
avatarStyle: "thumbs",
|
|
148
|
+
avatarSeed: cryptoMig.randomBytes(4).toString("hex"),
|
|
149
|
+
},
|
|
150
|
+
}];
|
|
117
151
|
}
|
|
152
|
+
// Case B: users present but no admin — set setupCode, keep existing users (done above)
|
|
153
|
+
// Case C: no PIN, no users — set setupCode, users stay empty (done above)
|
|
154
|
+
|
|
155
|
+
// Atomic synchronous write
|
|
156
|
+
var tmpFile = usersFilePath + ".tmp." + process.pid;
|
|
157
|
+
fsMig.writeFileSync(tmpFile, JSON.stringify(data, null, 2), { mode: 0o600 });
|
|
158
|
+
fsMig.renameSync(tmpFile, usersFilePath);
|
|
159
|
+
|
|
160
|
+
// Prominent banner
|
|
161
|
+
var port = (cfg && cfg.port) || 3000;
|
|
162
|
+
var url = "http://localhost:" + port + "/auth/setup?setupCode=" + setupCode;
|
|
163
|
+
console.log("");
|
|
164
|
+
console.log("┌─────────────────────────────────────────────────────────────┐");
|
|
165
|
+
console.log("│ Clagentic: Console — one-time upgrade step required │");
|
|
166
|
+
console.log("│ │");
|
|
167
|
+
console.log("│ Your install has been migrated to multi-user mode. │");
|
|
168
|
+
console.log("│ Open this URL to set your admin PIN: │");
|
|
169
|
+
console.log("│ │");
|
|
170
|
+
console.log("│ " + url.padEnd(61) + "│");
|
|
171
|
+
console.log("│ │");
|
|
172
|
+
console.log("│ Setup code also stored in ~/.clagentic/users.json │");
|
|
173
|
+
console.log("│ Your previous PIN cannot be transferred (format change). │");
|
|
174
|
+
console.log("│ Set a new PIN via the setup URL above. │");
|
|
175
|
+
console.log("└─────────────────────────────────────────────────────────────┘");
|
|
176
|
+
console.log("");
|
|
118
177
|
}
|
|
178
|
+
|
|
179
|
+
var _usersDataForMigration = usersModule.loadUsers();
|
|
180
|
+
migrateSingleUserToMultiUser(config, _usersDataForMigration);
|
|
181
|
+
|
|
119
182
|
// --- OS users mode: check required system dependencies ---
|
|
120
183
|
if (config.osUsers) {
|
|
121
184
|
var checkExec = require("child_process").execFileSync;
|
|
@@ -191,7 +254,6 @@ var relay = createServer({
|
|
|
191
254
|
tlsOptions: tlsOptions,
|
|
192
255
|
caPath: caRoot,
|
|
193
256
|
builtinCert: config.builtinCert || false,
|
|
194
|
-
pinHash: config.pinHash || null,
|
|
195
257
|
port: config.port,
|
|
196
258
|
debug: config.debug || false,
|
|
197
259
|
dangerouslySkipPermissions: config.dangerouslySkipPermissions || false,
|
|
@@ -968,23 +1030,9 @@ var relay = createServer({
|
|
|
968
1030
|
console.log("[daemon] Update channel:", config.updateChannel, "(web)");
|
|
969
1031
|
return { ok: true, updateChannel: config.updateChannel };
|
|
970
1032
|
},
|
|
971
|
-
onSetPin
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
} else {
|
|
975
|
-
config.pinHash = null;
|
|
976
|
-
}
|
|
977
|
-
relay.setAuthToken(config.pinHash);
|
|
978
|
-
saveConfig(config);
|
|
979
|
-
console.log("[daemon] PIN", pin ? "set" : "removed", "(web)");
|
|
980
|
-
return { ok: true, pinEnabled: !!config.pinHash };
|
|
981
|
-
},
|
|
982
|
-
onUpgradePin: function (newHash) {
|
|
983
|
-
config.pinHash = newHash;
|
|
984
|
-
relay.setAuthToken(newHash);
|
|
985
|
-
saveConfig(config);
|
|
986
|
-
console.log("[daemon] PIN hash auto-upgraded to scrypt");
|
|
987
|
-
},
|
|
1033
|
+
// onSetPin intentionally removed — single-user PIN mode no longer exists (lr-ec2d).
|
|
1034
|
+
// Individual user PINs are managed via users.js / server-admin.js.
|
|
1035
|
+
onSetPin: null,
|
|
988
1036
|
onSetChatLayout: function (layout) {
|
|
989
1037
|
var val = (layout === "bubble") ? "bubble" : "channel";
|
|
990
1038
|
config.chatLayout = val;
|
package/lib/pages.js
CHANGED
|
@@ -1,44 +1,3 @@
|
|
|
1
|
-
function pinPageHtml() {
|
|
2
|
-
return '<!DOCTYPE html><html lang="en"><head>' +
|
|
3
|
-
'<meta charset="UTF-8">' +
|
|
4
|
-
'<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">' +
|
|
5
|
-
'<meta name="mobile-web-app-capable" content="yes">' +
|
|
6
|
-
'<link rel="icon" type="image/png" href="/favicon-banded.png">' +
|
|
7
|
-
'<link rel="apple-touch-icon" href="/apple-touch-icon.png">' +
|
|
8
|
-
'<title>Clagentic:Console</title>' +
|
|
9
|
-
'<style>' + authPageStyles + '</style></head><body><div class="c">' +
|
|
10
|
-
'<h1 id="greeting"></h1>' +
|
|
11
|
-
'<div class="sub">Enter your PIN to continue</div>' +
|
|
12
|
-
pinBoxesHtml +
|
|
13
|
-
'<div class="err" id="err"></div>' +
|
|
14
|
-
'<script>' +
|
|
15
|
-
'(function(){' +
|
|
16
|
-
'var h=document.getElementById("greeting");' +
|
|
17
|
-
'var visited=localStorage.getItem("clay_visited");' +
|
|
18
|
-
'if(visited){h.textContent="Welcome back"}' +
|
|
19
|
-
'else{h.textContent="Welcome to Clagentic:Console";localStorage.setItem("clay_visited","1")}' +
|
|
20
|
-
'})();' +
|
|
21
|
-
pinBoxScript +
|
|
22
|
-
'var err=document.getElementById("err");' +
|
|
23
|
-
'function submitPin(){' +
|
|
24
|
-
'var pin=document.getElementById("pin").value;' +
|
|
25
|
-
'var boxes=document.querySelectorAll(".pin-digit");' +
|
|
26
|
-
'fetch("/auth",{method:"POST",headers:{"Content-Type":"application/json"},' +
|
|
27
|
-
'body:JSON.stringify({pin:pin})})' +
|
|
28
|
-
'.then(function(r){return r.json()})' +
|
|
29
|
-
'.then(function(d){' +
|
|
30
|
-
'if(d.ok){location.reload();return}' +
|
|
31
|
-
'if(d.locked){for(var i=0;i<boxes.length;i++)boxes[i].disabled=true;' +
|
|
32
|
-
'err.textContent="Too many attempts. Try again in "+Math.ceil(d.retryAfter/60)+" min";' +
|
|
33
|
-
'setTimeout(function(){for(var i=0;i<boxes.length;i++)boxes[i].disabled=false;' +
|
|
34
|
-
'err.textContent="";resetPinBoxes()},d.retryAfter*1000);return}' +
|
|
35
|
-
'var msg="Wrong PIN";if(typeof d.attemptsLeft==="number"&&d.attemptsLeft<=3)msg+=" ("+d.attemptsLeft+" left)";' +
|
|
36
|
-
'err.textContent=msg;resetPinBoxes()})' +
|
|
37
|
-
'.catch(function(){err.textContent="Connection error"})}' +
|
|
38
|
-
'initPinBoxes("pin-boxes","pin",submitPin);' +
|
|
39
|
-
'</script></div></body></html>';
|
|
40
|
-
}
|
|
41
|
-
|
|
42
1
|
function setupPageHtml(httpsUrl, httpUrl, hasCert, lanMode) {
|
|
43
2
|
return `<!DOCTYPE html><html lang="en"><head>
|
|
44
3
|
<meta charset="UTF-8">
|
|
@@ -1259,4 +1218,4 @@ function noProjectsPageHtml() {
|
|
|
1259
1218
|
'</div></body></html>';
|
|
1260
1219
|
}
|
|
1261
1220
|
|
|
1262
|
-
module.exports = {
|
|
1221
|
+
module.exports = { setupPageHtml: setupPageHtml, adminSetupPageHtml: adminSetupPageHtml, multiUserLoginPageHtml: multiUserLoginPageHtml, smtpLoginPageHtml: smtpLoginPageHtml, invitePageHtml: invitePageHtml, smtpInvitePageHtml: smtpInvitePageHtml, noProjectsPageHtml: noProjectsPageHtml };
|
|
@@ -73,10 +73,8 @@ function attachConnection(ctx) {
|
|
|
73
73
|
if (s.cliSessionId && s.cliSessionId === storedPresence.sessionId) active = s;
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
|
-
if (active &&
|
|
76
|
+
if (active && wsUser) {
|
|
77
77
|
if (!usersModule.canAccessSession(wsUser.id, active, { visibility: "public" })) active = null;
|
|
78
|
-
} else if (active && !usersModule.isMultiUser() && active.ownerId) {
|
|
79
|
-
active = null;
|
|
80
78
|
}
|
|
81
79
|
}
|
|
82
80
|
if (!active && allSessions.length > 0) {
|
|
@@ -121,12 +119,10 @@ function attachConnection(ctx) {
|
|
|
121
119
|
var project = getProject();
|
|
122
120
|
var ownerLocked = !!(osUsers && osUsers.length > 0 && /^\/home\/[^/]+\//.test(cwd));
|
|
123
121
|
var allSessions = [].concat(Array.from(sm.sessions.values())).filter(function (s) { return !s.hidden; });
|
|
124
|
-
if (
|
|
122
|
+
if (wsUser) {
|
|
125
123
|
allSessions = allSessions.filter(function (s) {
|
|
126
124
|
return usersModule.canAccessSession(wsUser.id, s, { visibility: "public" });
|
|
127
125
|
});
|
|
128
|
-
} else if (!usersModule.isMultiUser()) {
|
|
129
|
-
allSessions = allSessions.filter(function (s) { return !s.ownerId; });
|
|
130
126
|
}
|
|
131
127
|
var restoredState = findRestoredActiveSession(ws, wsUser, allSessions);
|
|
132
128
|
var restoredActive = restoredState.active;
|
|
@@ -176,7 +172,7 @@ function attachConnection(ctx) {
|
|
|
176
172
|
var autoCreated = false;
|
|
177
173
|
if (!active) {
|
|
178
174
|
var autoOpts = {};
|
|
179
|
-
if (wsUser
|
|
175
|
+
if (wsUser) autoOpts.ownerId = wsUser.id;
|
|
180
176
|
// TODO(lr-f311): defer createSession until first user message — every
|
|
181
177
|
// network blip or browser reload creates an empty session file here.
|
|
182
178
|
// The reconnect/presence path is subtle; fix deferred to a follow-up PR.
|
|
@@ -184,7 +180,7 @@ function attachConnection(ctx) {
|
|
|
184
180
|
autoCreated = true;
|
|
185
181
|
}
|
|
186
182
|
if (active && !autoCreated) {
|
|
187
|
-
if (!active.ownerId && wsUser
|
|
183
|
+
if (!active.ownerId && wsUser) {
|
|
188
184
|
active.ownerId = wsUser.id;
|
|
189
185
|
sm.saveSessionFile(active);
|
|
190
186
|
}
|
package/lib/project-loop.js
CHANGED
|
@@ -725,7 +725,7 @@ function attachLoop(ctx) {
|
|
|
725
725
|
type: "done", slug: slug, title: "Loop Complete", body: _finishBody, tag: "ralph-loop-done",
|
|
726
726
|
};
|
|
727
727
|
// Route to loop session owner only — body carries iteration status.
|
|
728
|
-
if (
|
|
728
|
+
if (_loopOwnerUserId && pushModule.sendPushToUser) {
|
|
729
729
|
pushModule.sendPushToUser(_loopOwnerUserId, _loopDonePayload);
|
|
730
730
|
} else {
|
|
731
731
|
pushModule.sendPush(_loopDonePayload);
|
|
@@ -112,8 +112,6 @@ function attachNotifications(ctx) {
|
|
|
112
112
|
var broadcastAll = ctx.broadcastAll;
|
|
113
113
|
var sendToUser = ctx.sendToUser || null; // (userId, msg) -> void; iterates all project clients
|
|
114
114
|
var pushModule = ctx.pushModule;
|
|
115
|
-
var isMultiUser = ctx.isMultiUser || function () { return false; };
|
|
116
|
-
|
|
117
115
|
var notifications = loadNotifications();
|
|
118
116
|
var reminderTimer = null;
|
|
119
117
|
|
|
@@ -206,22 +204,9 @@ function attachNotifications(ctx) {
|
|
|
206
204
|
// --- Periodic reminder ---
|
|
207
205
|
|
|
208
206
|
function startReminder() {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
// The body (unread count) is per-project state that would leak to all
|
|
213
|
-
// push subscribers regardless of which user owns the notifications.
|
|
214
|
-
if (isMultiUser()) return;
|
|
215
|
-
var count = getUnreadCount();
|
|
216
|
-
if (count > 0 && pushModule) {
|
|
217
|
-
pushModule.sendPush({
|
|
218
|
-
type: "reminder",
|
|
219
|
-
title: "Clagentic:Console",
|
|
220
|
-
body: count + " unread notification" + (count > 1 ? "s" : ""),
|
|
221
|
-
tag: "clay-notif-reminder",
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
}, REMINDER_INTERVAL);
|
|
207
|
+
// Reminder push is suppressed in multi-user mode: the unread count is
|
|
208
|
+
// per-project state that would leak to all push subscribers regardless of
|
|
209
|
+
// which user owns the notifications.
|
|
225
210
|
}
|
|
226
211
|
|
|
227
212
|
function stopReminder() {
|
package/lib/project-sessions.js
CHANGED
|
@@ -132,7 +132,7 @@ function attachSessions(ctx) {
|
|
|
132
132
|
|
|
133
133
|
if (msg.type === "new_session") {
|
|
134
134
|
var sessionOpts = {};
|
|
135
|
-
if (ws._clayUser
|
|
135
|
+
if (ws._clayUser) sessionOpts.ownerId = ws._clayUser.id;
|
|
136
136
|
if (msg.sessionVisibility) sessionOpts.sessionVisibility = msg.sessionVisibility;
|
|
137
137
|
if (msg.vendor) sessionOpts.vendor = msg.vendor;
|
|
138
138
|
if (msg.agentName && typeof msg.agentName === "string") {
|
|
@@ -157,9 +157,7 @@ function attachSessions(ctx) {
|
|
|
157
157
|
}
|
|
158
158
|
var nsPresKey = ws._clayUser ? ws._clayUser.id : "_default";
|
|
159
159
|
userPresence.setPresence(slug, nsPresKey, newSess.localId, null);
|
|
160
|
-
|
|
161
|
-
broadcastPresence();
|
|
162
|
-
}
|
|
160
|
+
broadcastPresence();
|
|
163
161
|
return true;
|
|
164
162
|
}
|
|
165
163
|
|
|
@@ -264,7 +262,7 @@ function attachSessions(ctx) {
|
|
|
264
262
|
if (typeof msg.sessionId !== "number") return true;
|
|
265
263
|
var agentTarget = sm.sessions.get(msg.sessionId);
|
|
266
264
|
if (!agentTarget) return true;
|
|
267
|
-
if (
|
|
265
|
+
if (ws._clayUser) {
|
|
268
266
|
if (!usersModule.canAccessSession(ws._clayUser.id, agentTarget, { visibility: "public" })) return true;
|
|
269
267
|
}
|
|
270
268
|
var nextAgent = (msg.agentName && typeof msg.agentName === "string") ? msg.agentName : null;
|
|
@@ -283,7 +281,7 @@ function attachSessions(ctx) {
|
|
|
283
281
|
if (typeof msg.sessionId === "number" && (msg.visibility === "shared" || msg.visibility === "private")) {
|
|
284
282
|
var visTarget = sm.sessions.get(msg.sessionId);
|
|
285
283
|
if (!visTarget) return true;
|
|
286
|
-
if (
|
|
284
|
+
if (ws._clayUser) {
|
|
287
285
|
if (!usersModule.canAccessSession(ws._clayUser.id, visTarget, { visibility: "public" })) return true;
|
|
288
286
|
}
|
|
289
287
|
sm.setSessionVisibility(msg.sessionId, msg.visibility);
|
|
@@ -295,7 +293,7 @@ function attachSessions(ctx) {
|
|
|
295
293
|
if (typeof msg.sessionId === "number") {
|
|
296
294
|
var bookmarkTarget = sm.sessions.get(msg.sessionId);
|
|
297
295
|
if (!bookmarkTarget) return true;
|
|
298
|
-
if (
|
|
296
|
+
if (ws._clayUser) {
|
|
299
297
|
if (!usersModule.canAccessSession(ws._clayUser.id, bookmarkTarget, { visibility: "public" })) return true;
|
|
300
298
|
}
|
|
301
299
|
sm.setSessionBookmarked(msg.sessionId, !!msg.bookmarked);
|
|
@@ -308,7 +306,7 @@ function attachSessions(ctx) {
|
|
|
308
306
|
var source = sm.sessions.get(msg.sourceId);
|
|
309
307
|
var target = sm.sessions.get(msg.targetId);
|
|
310
308
|
if (!source || !target) return true;
|
|
311
|
-
if (
|
|
309
|
+
if (ws._clayUser) {
|
|
312
310
|
if (!usersModule.canAccessSession(ws._clayUser.id, source, { visibility: "public" })) return true;
|
|
313
311
|
if (!usersModule.canAccessSession(ws._clayUser.id, target, { visibility: "public" })) return true;
|
|
314
312
|
}
|
|
@@ -325,7 +323,7 @@ function attachSessions(ctx) {
|
|
|
325
323
|
if (typeof bulkId !== "number") continue;
|
|
326
324
|
var bulkTarget = sm.sessions.get(bulkId);
|
|
327
325
|
if (!bulkTarget) continue;
|
|
328
|
-
if (
|
|
326
|
+
if (ws._clayUser) {
|
|
329
327
|
if (!usersModule.canAccessSession(ws._clayUser.id, bulkTarget, { visibility: "public" })) continue;
|
|
330
328
|
}
|
|
331
329
|
deletableIds.push(bulkId);
|
|
@@ -479,17 +477,14 @@ function attachSessions(ctx) {
|
|
|
479
477
|
sm.currentModel = "";
|
|
480
478
|
}
|
|
481
479
|
}
|
|
482
|
-
// Check access
|
|
483
|
-
if (
|
|
480
|
+
// Check session access
|
|
481
|
+
if (ws._clayUser) {
|
|
484
482
|
var switchTarget = sm.sessions.get(msg.id);
|
|
485
483
|
if (!usersModule.canAccessSession(ws._clayUser.id, switchTarget, { visibility: "public" })) return true;
|
|
486
|
-
ws._clayActiveSession = msg.id;
|
|
487
|
-
sm.switchSession(msg.id, ws, hydrateImageRefs);
|
|
488
|
-
broadcastPresence();
|
|
489
|
-
} else {
|
|
490
|
-
ws._clayActiveSession = msg.id;
|
|
491
|
-
sm.switchSession(msg.id, ws, hydrateImageRefs);
|
|
492
484
|
}
|
|
485
|
+
ws._clayActiveSession = msg.id;
|
|
486
|
+
sm.switchSession(msg.id, ws, hydrateImageRefs);
|
|
487
|
+
broadcastPresence();
|
|
493
488
|
// Send per-session context sources
|
|
494
489
|
if (typeof loadContextSources === "function") {
|
|
495
490
|
var switchedSources = loadContextSources(slug, msg.id);
|
|
@@ -580,7 +575,7 @@ function attachSessions(ctx) {
|
|
|
580
575
|
}
|
|
581
576
|
|
|
582
577
|
if (msg.type === "update_now") {
|
|
583
|
-
if (
|
|
578
|
+
if (!ws._clayUser || ws._clayUser.role !== "admin") return true;
|
|
584
579
|
send({ type: "update_started", version: getLatestVersion() || "" });
|
|
585
580
|
var _ipc = require("./ipc");
|
|
586
581
|
var _config = require("./config");
|
|
@@ -644,7 +639,7 @@ function attachSessions(ctx) {
|
|
|
644
639
|
if (msg.type === "kill_process") {
|
|
645
640
|
// Restrict to admins in multi-user mode — any user could otherwise SIGTERM
|
|
646
641
|
// another user's running claude subprocess (lr-eb1a).
|
|
647
|
-
if (
|
|
642
|
+
if (!ws._clayUser || ws._clayUser.role !== "admin") {
|
|
648
643
|
sendTo(ws, { type: "error", message: "Admin access required" });
|
|
649
644
|
return true;
|
|
650
645
|
}
|
|
@@ -1096,7 +1091,7 @@ function attachSessions(ctx) {
|
|
|
1096
1091
|
}
|
|
1097
1092
|
|
|
1098
1093
|
if (msg.type === "cursor_move" || msg.type === "cursor_leave" || msg.type === "text_select") {
|
|
1099
|
-
if (!
|
|
1094
|
+
if (!ws._clayUser) return true;
|
|
1100
1095
|
var u = ws._clayUser;
|
|
1101
1096
|
var p = u.profile || {};
|
|
1102
1097
|
var cursorMsg = {
|
|
@@ -1596,12 +1591,10 @@ function attachSessions(ctx) {
|
|
|
1596
1591
|
msg.type === "set_tokens_per_mb_headroom" ||
|
|
1597
1592
|
msg.type === "set_lite_auto_enroll" ||
|
|
1598
1593
|
msg.type === "shutdown_server" || msg.type === "restart_server") {
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
return true;
|
|
1604
|
-
}
|
|
1594
|
+
var _wsUser = ws._clayUser;
|
|
1595
|
+
if (!_wsUser || _wsUser.role !== "admin") {
|
|
1596
|
+
sendTo(ws, { type: "error", message: "Admin access required" });
|
|
1597
|
+
return true;
|
|
1605
1598
|
}
|
|
1606
1599
|
}
|
|
1607
1600
|
|
|
@@ -72,17 +72,12 @@ function attachUserMessage(ctx) {
|
|
|
72
72
|
|
|
73
73
|
// --------------- Terminal list broadcast ---------------
|
|
74
74
|
|
|
75
|
-
//
|
|
76
|
-
// send filtered term_list messages individually instead of broadcasting one.
|
|
75
|
+
// Each client only sees their own terminals — send filtered term_list messages individually.
|
|
77
76
|
function broadcastTermList() {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
sendTo(bws, { type: "term_list", terminals: tm.list(bws) });
|
|
82
|
-
}
|
|
77
|
+
for (var bws of clients) {
|
|
78
|
+
if (bws.readyState === 1) {
|
|
79
|
+
sendTo(bws, { type: "term_list", terminals: tm.list(bws) });
|
|
83
80
|
}
|
|
84
|
-
} else {
|
|
85
|
-
send({ type: "term_list", terminals: tm.list() });
|
|
86
81
|
}
|
|
87
82
|
}
|
|
88
83
|
|
|
@@ -314,7 +309,7 @@ function attachUserMessage(ctx) {
|
|
|
314
309
|
}
|
|
315
310
|
|
|
316
311
|
// Backfill ownerId for legacy sessions restored without one (multi-user only)
|
|
317
|
-
if (!session.ownerId && ws._clayUser
|
|
312
|
+
if (!session.ownerId && ws._clayUser) {
|
|
318
313
|
session.ownerId = ws._clayUser.id;
|
|
319
314
|
sm.saveSessionFile(session);
|
|
320
315
|
}
|