@clagentic/console 1.9.0-beta.2 → 1.9.0-beta.3

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/bin/cli.js CHANGED
@@ -33,7 +33,7 @@ var { forkDaemon, devMode, setDaemonWatcherOpts } = require("../lib/cli/daemon-l
33
33
  var { setup, promptRestoreProjects, showMainMenu } = require("../lib/cli/menus");
34
34
  var { getLocalIP } = require("../lib/cli/net-detect");
35
35
  var { log, a, sym } = require("../lib/cli/tui");
36
- var { handleShutdown, handleRestart, handleAdd, handleRemove, handleList, handleActivityDiagnostics } = require("../lib/cli/ipc-subcommands");
36
+ var { handleShutdown, handleRestart, handleAdd, handleRemove, handleList, handleActivityDiagnostics, handleProcessBuildStatus } = require("../lib/cli/ipc-subcommands");
37
37
 
38
38
  var args = process.argv.slice(2);
39
39
 
@@ -70,6 +70,7 @@ var addPath = null;
70
70
  var removePath = null;
71
71
  var listMode = false;
72
72
  var activityDiagnosticsMode = false;
73
+ var processBuildStatusMode = false;
73
74
  var dangerouslySkipPermissions = false;
74
75
  var headlessMode = false;
75
76
  var watchMode = false;
@@ -121,6 +122,8 @@ for (var i = 0; i < args.length; i++) {
121
122
  listMode = true;
122
123
  } else if (args[i] === "--activity-diagnostics") {
123
124
  activityDiagnosticsMode = true;
125
+ } else if (args[i] === "--process-build-status") {
126
+ processBuildStatusMode = true;
124
127
  } else if (args[i] === "--headless") {
125
128
  headlessMode = true;
126
129
  autoYes = true;
@@ -136,6 +139,7 @@ for (var i = 0; i < args.length; i++) {
136
139
  console.log(" clagentic-console --remove <path> Remove a project from the running daemon");
137
140
  console.log(" clagentic-console --list List registered projects");
138
141
  console.log(" clagentic-console --activity-diagnostics Print activity-divergence probe totals as JSON (agent-readable)");
142
+ console.log(" clagentic-console --process-build-status Print the running process's loaded build SHA as JSON (agent-readable)");
139
143
  console.log(" clagentic-console release list-betas List promotable beta versions (maintainer/release-engineering)");
140
144
  console.log("");
141
145
  console.log("Options:");
@@ -154,6 +158,7 @@ for (var i = 0; i < args.length; i++) {
154
158
  console.log(" --remove <path> Remove a project directory");
155
159
  console.log(" --list List all registered projects");
156
160
  console.log(" --activity-diagnostics Print activity-divergence probe totals as JSON");
161
+ console.log(" --process-build-status Print the running process's loaded build SHA as JSON");
157
162
  console.log(" --headless Start daemon and exit immediately (implies --yes)");
158
163
  console.log(" --multi-user Start in multi-user mode (use with --yes for headless)");
159
164
  console.log(" --os-users Enable OS-level user isolation (Linux, requires root + --multi-user)");
@@ -205,6 +210,12 @@ if (activityDiagnosticsMode) {
205
210
  return;
206
211
  }
207
212
 
213
+ // --- Handle --process-build-status before anything else ---
214
+ if (processBuildStatusMode) {
215
+ handleProcessBuildStatus();
216
+ return;
217
+ }
218
+
208
219
  // --multi-user / --os-users are now handled in the main entry flow (setup wizard or repeat run)
209
220
  // Flags are parsed above and applied during forkDaemon()
210
221
 
@@ -1,4 +1,4 @@
1
1
  {
2
- "sha": "99208748c957f643a44ee6fab76a8fc1891f3b1b",
3
- "writtenAt": "2026-08-27T22:24:59.717Z"
2
+ "sha": "15119b80509da03dc53f5b059127646df851109a",
3
+ "writtenAt": "2026-09-04T15:36:46.197Z"
4
4
  }
@@ -10,6 +10,10 @@
10
10
  // (Bash+Read, no browser/WS/devtools) retrieval path for the lr-58c813
11
11
  // server-side activity-divergence probe. Prints raw JSON to stdout so a
12
12
  // read-only crew agent can run this directly.
13
+ // --process-build-status added by lr-dc9a3b: reports the build SHA the
14
+ // RUNNING daemon actually loaded at startup (distinct from the on-disk
15
+ // artifact's build-sha.json), so scripts/verify-installed-build.js can gate
16
+ // on process build identity, not just artifact build identity.
13
17
 
14
18
  var fs = require("fs");
15
19
  var path = require("path");
@@ -182,6 +186,45 @@ function handleList() {
182
186
  });
183
187
  }
184
188
 
189
+ // lr-dc9a3b: prints the running process's build-identity status (same data
190
+ // lib/daemon.js's "get_build_status" IPC case returns) as raw JSON to
191
+ // stdout. This is the retrieval path scripts/verify-installed-build.js uses
192
+ // to check what the RUNNING daemon loaded, distinct from what the ON-DISK
193
+ // artifact contains (see that script's own header comment for the
194
+ // artifact-vs-process distinction this exists to close):
195
+ // `clagentic-console --process-build-status`.
196
+ function handleProcessBuildStatus() {
197
+ var statusConfig = loadConfig();
198
+ isDaemonAliveAsync(statusConfig).then(function (alive) {
199
+ if (!alive) {
200
+ // No running daemon is not itself an error here -- a caller comparing
201
+ // artifact vs. process needs to be able to tell "nothing to compare
202
+ // against" apart from "compared and it mismatched". Distinguish via
203
+ // ok:false + a stable error string rather than a bare non-zero exit
204
+ // with no machine-readable reason.
205
+ console.log(JSON.stringify({ ok: false, error: "no running daemon" }, null, 2));
206
+ process.exit(1);
207
+ return;
208
+ }
209
+ sendIPCCommand(socketPath(), { cmd: "get_build_status" }).then(function (res) {
210
+ if (!res.ok) {
211
+ console.error("Failed: " + (res.error || "unknown error"));
212
+ process.exit(1);
213
+ return;
214
+ }
215
+ // Raw JSON to stdout -- the point is machine readability for a gate
216
+ // script, not a human-formatted summary (contrast handleList's
217
+ // formatted output).
218
+ console.log(JSON.stringify({
219
+ loadedBuildSha: res.loadedBuildSha,
220
+ staleInodes: res.staleInodes,
221
+ pid: res.pid,
222
+ }, null, 2));
223
+ process.exit(0);
224
+ });
225
+ });
226
+ }
227
+
185
228
  // lr-8b476f: prints the activity-divergence probe totals (same data
186
229
  // process_stats's WS response folds in, see lib/daemon.js's
187
230
  // "get_activity_diagnostics" IPC case) as raw JSON to stdout. This is the
@@ -219,4 +262,5 @@ module.exports = {
219
262
  handleRemove: handleRemove,
220
263
  handleList: handleList,
221
264
  handleActivityDiagnostics: handleActivityDiagnostics,
265
+ handleProcessBuildStatus: handleProcessBuildStatus,
222
266
  };
package/lib/daemon.js CHANGED
@@ -106,6 +106,25 @@ function checkStaleInodes() {
106
106
  }
107
107
  }
108
108
 
109
+ // lr-dc9a3b: the SHA this process actually loaded lib/build-sha.json with at
110
+ // startup, captured once here so a later re-read of the on-disk file (after
111
+ // an install replaces it) can never be confused with what THIS process is
112
+ // running. Read defensively — a dev checkout that has never run `npm pack`
113
+ // (prepack writes this file, and it is gitignored) will not have it, and
114
+ // that is a legitimate "no build-identity signal available" state, not an
115
+ // error.
116
+ var loadedBuildSha = null;
117
+ try {
118
+ var _buildShaContents = fs.readFileSync(path.join(__dirname, 'build-sha.json'), 'utf8');
119
+ var _buildShaParsed = JSON.parse(_buildShaContents);
120
+ if (_buildShaParsed && typeof _buildShaParsed.sha === 'string') {
121
+ loadedBuildSha = _buildShaParsed.sha;
122
+ }
123
+ } catch (_) {
124
+ // lib/build-sha.json missing/unreadable/malformed — loadedBuildSha stays
125
+ // null, which get_build_status reports honestly rather than guessing.
126
+ }
127
+
109
128
  if (checkStaleInodes()) {
110
129
  console.warn('[daemon] WARNING: this process is serving STALE code — on-disk JS has been replaced');
111
130
  console.warn('[daemon] WARNING: restart the daemon to load the new build:');
@@ -260,6 +279,10 @@ var relay = createServer({
260
279
  tlsOptions: tlsOptions,
261
280
  caPath: caRoot,
262
281
  builtinCert: config.builtinCert || false,
282
+ // lr-20e71c: operator-declared trust boundary for reading X-Forwarded-Proto
283
+ // from a reverse proxy (e.g. Caddy). Never read the header unconditionally —
284
+ // see lib/effective-protocol.js.
285
+ trustedProxy: !!config.trustedProxy,
263
286
  port: config.port,
264
287
  debug: config.debug || false,
265
288
  dangerouslySkipPermissions: config.dangerouslySkipPermissions || false,
@@ -1112,10 +1135,19 @@ var relay = createServer({
1112
1135
  }
1113
1136
  return { ok: false, error: "Project not found" };
1114
1137
  },
1115
- onGetDaemonConfig: function () {
1138
+ // lr-20e71c: `tls` stays the accurate name for daemon-internal TLS
1139
+ // termination (tlsOptions !== null) — it must NOT be repurposed to mean
1140
+ // "reachable over HTTPS". effectiveProtocol is the separate, request-scoped
1141
+ // source of truth for that: server.js resolves it per-WS-connection via
1142
+ // lib/effective-protocol.js (trustedProxy-gated X-Forwarded-Proto) and
1143
+ // passes it in here so the settings badge and any other consumer render
1144
+ // the real external protocol, not the internal-termination flag.
1145
+ onGetDaemonConfig: function (effectiveProtocol) {
1116
1146
  return {
1117
1147
  port: config.port,
1118
1148
  tls: !!tlsOptions,
1149
+ tlsEffective: effectiveProtocol ? effectiveProtocol.protocol === "https" : !!tlsOptions,
1150
+ tlsState: effectiveProtocol ? effectiveProtocol.state : (tlsOptions ? "direct" : "disabled"),
1119
1151
  debug: !!config.debug,
1120
1152
  headless: !!config.headless,
1121
1153
  keepAwake: !!config.keepAwake,
@@ -1130,7 +1162,13 @@ var relay = createServer({
1130
1162
  updateChannel: config.updateChannel || "stable",
1131
1163
  imageRetentionDays: config.imageRetentionDays !== undefined ? config.imageRetentionDays : 7,
1132
1164
  memAvailableMinMB: config.memAvailableMinMB !== undefined ? config.memAvailableMinMB : DEFAULT_MEM_AVAILABLE_MIN_MB,
1165
+ // lr-9e6569: config.memAvailableMinMB absent means the value below is a
1166
+ // fallback default, not something the operator ever saved -- renders
1167
+ // identically to a persisted value equal to the default without this
1168
+ // flag, which is part of why a silently-discarded edit went unnoticed.
1169
+ memAvailableMinMBIsDefault: config.memAvailableMinMB === undefined,
1133
1170
  tokensPerMbHeadroom: config.tokensPerMbHeadroom !== undefined ? config.tokensPerMbHeadroom : DEFAULT_TOKENS_PER_MB_HEADROOM,
1171
+ tokensPerMbHeadroomIsDefault: config.tokensPerMbHeadroom === undefined,
1134
1172
  liteAutoEnroll: !!config.liteAutoEnroll,
1135
1173
  };
1136
1174
  },
@@ -1188,7 +1226,15 @@ var relay = createServer({
1188
1226
  },
1189
1227
  onSetMemAvailableThreshold: function (mb) {
1190
1228
  var val = parseInt(mb, 10);
1191
- if (isNaN(val) || val < 0) val = DEFAULT_MEM_AVAILABLE_MIN_MB;
1229
+ // lr-93e3c8 (item 6): out-of-range used to silently reset to the
1230
+ // default and still report ok:true -- a UX trap on the exact knob an
1231
+ // operator reaches for while already blocked by this same guard.
1232
+ // Reject and report instead of silently substituting a value the
1233
+ // caller didn't ask for.
1234
+ if (isNaN(val) || val < 0) {
1235
+ console.warn("[daemon] MemAvailable threshold rejected: " + mb + " (must be a number >= 0)");
1236
+ return { ok: false, error: "Value must be a number >= 0", memAvailableMinMB: config.memAvailableMinMB !== undefined ? config.memAvailableMinMB : DEFAULT_MEM_AVAILABLE_MIN_MB };
1237
+ }
1192
1238
  config.memAvailableMinMB = val;
1193
1239
  saveConfig(config);
1194
1240
  console.log("[daemon] MemAvailable threshold:", val, "MB (web)");
@@ -1196,8 +1242,13 @@ var relay = createServer({
1196
1242
  },
1197
1243
  onSetTokensPerMbHeadroom: function (tpm) {
1198
1244
  var val = parseInt(tpm, 10);
1199
- // Valid range: 10–500 tokens/MB; outside that range reset to default.
1200
- if (isNaN(val) || val < 10 || val > 500) val = DEFAULT_TOKENS_PER_MB_HEADROOM;
1245
+ // lr-93e3c8 (item 6): valid range 10-500 tokens/MB. Out-of-range used to
1246
+ // silently clamp to the default and still report ok:true -- see comment
1247
+ // on onSetMemAvailableThreshold above; same trap, same fix.
1248
+ if (isNaN(val) || val < 10 || val > 500) {
1249
+ console.warn("[daemon] Tokens per MB headroom rejected: " + tpm + " (must be 10-500)");
1250
+ return { ok: false, error: "Value must be 10-500", tokensPerMbHeadroom: config.tokensPerMbHeadroom !== undefined ? config.tokensPerMbHeadroom : DEFAULT_TOKENS_PER_MB_HEADROOM };
1251
+ }
1201
1252
  config.tokensPerMbHeadroom = val;
1202
1253
  saveConfig(config);
1203
1254
  console.log("[daemon] Tokens per MB headroom:", val, "(web)");
@@ -1577,6 +1628,29 @@ var ipc = createIPCServer(socketPath(), function (msg) {
1577
1628
  case "get_activity_diagnostics":
1578
1629
  return buildActivityDiagnosticsResponse();
1579
1630
 
1631
+ // lr-dc9a3b: makes the running-vs-installed mismatch a first-class,
1632
+ // queryable signal instead of a journalctl-only warning nothing
1633
+ // consumes. verify-installed-build.js (the post-merge gate) already
1634
+ // compares the ON-DISK build-sha.json against merged HEAD -- that
1635
+ // proves the ARTIFACT is right, not that the RUNNING PROCESS loaded
1636
+ // it. This reports the SHA this process actually loaded at startup
1637
+ // (loadedBuildSha, captured once above -- never re-read, so an install
1638
+ // replacing the file on disk after startup cannot change what this
1639
+ // reports) plus the existing checkStaleInodes() detector's live
1640
+ // result, so a caller can tell "process never picked up the new
1641
+ // build" apart from "process picked it up but its deleted-inode
1642
+ // handles say the file has since moved again".
1643
+ //
1644
+ // Read-only, mutates nothing, same OS-level socket gate as every other
1645
+ // command on this connection (CONFIG_DIR is chmod 0700).
1646
+ case "get_build_status":
1647
+ return {
1648
+ ok: true,
1649
+ loadedBuildSha: loadedBuildSha,
1650
+ staleInodes: checkStaleInodes(),
1651
+ pid: process.pid,
1652
+ };
1653
+
1580
1654
  case "set_pin": {
1581
1655
  config.pinHash = msg.pinHash || null;
1582
1656
  relay.setAuthToken(config.pinHash);
@@ -1787,8 +1861,14 @@ var MAX_LISTEN_RETRIES = 15;
1787
1861
 
1788
1862
  function startListening() {
1789
1863
  relay.server.listen(config.port, listenHost, function () {
1790
- var protocol = tlsOptions ? "https" : "http";
1791
- console.log("[daemon] Listening on " + protocol + "://" + listenHost + ":" + config.port);
1864
+ // Startup has no live request, so there is no X-Forwarded-Proto to read —
1865
+ // resolveEffectiveProtocol's "proxy" state requires one. Reflect the
1866
+ // operator's trustedProxy declaration directly instead of silently
1867
+ // printing http:// for a deployment they've told us sits behind a
1868
+ // TLS-terminating proxy (lr-20e71c).
1869
+ var protocol = tlsOptions ? "https" : (config.trustedProxy ? "https" : "http");
1870
+ var protocolNote = (!tlsOptions && config.trustedProxy) ? " (proxy-terminated)" : "";
1871
+ console.log("[daemon] Listening on " + protocol + "://" + listenHost + ":" + config.port + protocolNote);
1792
1872
  console.log("[daemon] PID:", process.pid);
1793
1873
  console.log("[daemon] Projects:", config.projects.length);
1794
1874
 
@@ -0,0 +1,82 @@
1
+ // effective-protocol.js — single source of truth for the EXTERNAL protocol a
2
+ // client actually reached this daemon over, as distinct from tlsOptions
3
+ // (daemon-internal TLS termination only, see lib/daemon.js).
4
+ //
5
+ // Root cause (lr-20e71c): tlsOptions is non-null only when the daemon itself
6
+ // terminates TLS from CONFIG_DIR/certs. A deployment fronted by a reverse
7
+ // proxy (e.g. Caddy) that terminates TLS and forwards plain HTTP to the
8
+ // daemon is genuinely served over HTTPS, but tlsOptions is correctly null —
9
+ // so any code that read tlsOptions as a stand-in for "is this HTTPS" (the
10
+ // System Settings badge, the share-URL protocol) reported a false negative.
11
+ //
12
+ // X-Forwarded-Proto is NOT trusted unconditionally — an untrusted client
13
+ // could set it to spoof an "Enabled" readout over what is really plain HTTP.
14
+ // It is only consulted when the operator has explicitly declared this
15
+ // deployment sits behind a trusted proxy (config.trustedProxy). Caddy sets
16
+ // the header automatically; the operator's config declaration is the trust
17
+ // boundary, not the header's mere presence.
18
+ //
19
+ // Multi-hop chains (comma-separated header value): per RFC 7239 / the de
20
+ // facto X-Forwarded-* convention, each proxy in a chain APPENDS its own
21
+ // value to the right, so the LEFTMOST entry is the value the ORIGINAL
22
+ // client supplied (attacker-controlled) and the RIGHTMOST is the value the
23
+ // hop closest to this daemon set. "Rightmost is authoritative" is only true
24
+ // when every hop between the client and this daemon is itself trusted not
25
+ // to pass an untouched client-supplied value through — and config.trustedProxy
26
+ // is a single boolean with no hop-count, so it cannot express "trust exactly
27
+ // the last N hops" or "trust hop closest to us but not earlier ones". A
28
+ // misconfigured or attacker-reachable intermediate hop could still leave an
29
+ // attacker-controlled value in the rightmost position under some proxy
30
+ // topologies. Given that ambiguity, a multi-valued header is treated as
31
+ // untrustworthy under this trust model and ignored entirely (falls through
32
+ // to "disabled") rather than guessing which position is safe. Operators
33
+ // running a single, directly-adjacent trusted proxy (the Caddy deployment
34
+ // this repo ships) always see a single-valued header and are unaffected;
35
+ // only a chain deeper than one hop is refused.
36
+
37
+ /**
38
+ * Resolve the three possible states a deployment's external protocol can be in.
39
+ *
40
+ * @param {Object} params
41
+ * @param {Object|null} params.tlsOptions - daemon-internal TLS cert material
42
+ * (non-null only when Node itself is terminating TLS). Name stays
43
+ * unchanged — it is NOT the effective-protocol source of truth.
44
+ * @param {boolean} params.trustedProxy - operator-declared trust boundary
45
+ * for reading X-Forwarded-Proto from this request.
46
+ * @param {string|null|undefined} params.forwardedProtoHeader - the raw
47
+ * X-Forwarded-Proto header value. A single value is trusted when
48
+ * trustedProxy is set; a comma-separated (multi-hop) value is rejected
49
+ * outright, since a single trustedProxy boolean cannot express which hop
50
+ * in the chain is the trustworthy one (see module comment above).
51
+ * @returns {{protocol: "http"|"https", state: "direct"|"proxy"|"disabled"}}
52
+ * state drives the three badge renders: "direct" = daemon terminates TLS
53
+ * itself; "proxy" = a trusted proxy terminates TLS in front of the daemon;
54
+ * "disabled" = genuinely unencrypted, must stay visibly distinct from the
55
+ * other two.
56
+ */
57
+ function resolveEffectiveProtocol(params) {
58
+ var tlsOptions = params && params.tlsOptions;
59
+ var trustedProxy = !!(params && params.trustedProxy);
60
+ var forwardedProtoHeader = params && params.forwardedProtoHeader;
61
+
62
+ if (tlsOptions) {
63
+ return { protocol: "https", state: "direct" };
64
+ }
65
+
66
+ if (trustedProxy && forwardedProtoHeader) {
67
+ var rawHeader = String(forwardedProtoHeader);
68
+ // A multi-hop (comma-separated) value is refused rather than guessed at
69
+ // — see module comment above for why neither "leftmost" nor "rightmost"
70
+ // is safe to assume under a single-boolean trust model.
71
+ if (rawHeader.indexOf(",") === -1) {
72
+ var singleProto = rawHeader.trim().toLowerCase();
73
+ if (singleProto === "https") {
74
+ return { protocol: "https", state: "proxy" };
75
+ }
76
+ }
77
+ }
78
+
79
+ return { protocol: "http", state: "disabled" };
80
+ }
81
+
82
+ module.exports = { resolveEffectiveProtocol: resolveEffectiveProtocol };
@@ -89,7 +89,7 @@ function attachConnection(ctx) {
89
89
  }
90
90
 
91
91
  function handleConnection(ws, wsUser, handleMessage, handleDisconnection) {
92
- ws._clayUser = wsUser || null;
92
+ ws._clagenticUser = wsUser || null;
93
93
  clients.add(ws);
94
94
  broadcastClientCount();
95
95
 
@@ -113,7 +113,7 @@ function attachConnection(ctx) {
113
113
  var projectOwnerId = getProjectOwnerId();
114
114
 
115
115
  // Send cached state
116
- var _userId = ws._clayUser ? ws._clayUser.id : null;
116
+ var _userId = ws._clagenticUser ? ws._clagenticUser.id : null;
117
117
  var _filteredProjects = getProjectList(_userId);
118
118
  var title = getTitle();
119
119
  var project = getProject();
@@ -189,7 +189,7 @@ function attachConnection(ctx) {
189
189
  autoCreated = true;
190
190
  }
191
191
  if (active && !autoCreated) {
192
- ws._clayActiveSession = active.localId;
192
+ ws._clagenticActiveSession = active.localId;
193
193
  var _vendorCaps = (sm.capabilitiesByVendor && sm.capabilitiesByVendor[active.vendor || sm.defaultVendor || "claude"]) || {};
194
194
  // Load history from disk before checking hasHistory — the session may have
195
195
  // been evicted from the LRU cache (lr-f311 lazy load), in which case
@@ -315,10 +315,10 @@ function attachConnection(ctx) {
315
315
  }
316
316
 
317
317
  function handleDisconnection(ws) {
318
- if (ws._clayActiveSession) {
319
- var dcPresKey = ws._clayUser ? ws._clayUser.id : "_default";
318
+ if (ws._clagenticActiveSession) {
319
+ var dcPresKey = ws._clagenticUser ? ws._clagenticUser.id : "_default";
320
320
  var dcExisting = userPresence.getPresence(slug, dcPresKey);
321
- userPresence.setPresence(slug, dcPresKey, ws._clayActiveSession, dcExisting ? dcExisting.mateDm : null);
321
+ userPresence.setPresence(slug, dcPresKey, ws._clagenticActiveSession, dcExisting ? dcExisting.mateDm : null);
322
322
  }
323
323
  tm.detachAll(ws);
324
324
  clients.delete(ws);
@@ -43,8 +43,8 @@ function attachFilesystem(ctx) {
43
43
  function handleFilesystemMessage(ws, msg) {
44
44
  // --- File browser permission gate ---
45
45
  if (msg.type === "fs_list" || msg.type === "fs_read" || msg.type === "fs_write" || msg.type === "fs_delete" || msg.type === "fs_rename" || msg.type === "fs_mkdir" || msg.type === "fs_upload" || msg.type === "fs_search") {
46
- if (ws._clayUser) {
47
- var fbPerms = usersModule.getEffectivePermissions(ws._clayUser, osUsers);
46
+ if (ws._clagenticUser) {
47
+ var fbPerms = usersModule.getEffectivePermissions(ws._clagenticUser, osUsers);
48
48
  if (!fbPerms.fileBrowser) {
49
49
  sendTo(ws, { type: msg.type + "_result", error: "File browser access is not permitted" });
50
50
  return true;
@@ -231,8 +231,8 @@ function attachFilesystem(ctx) {
231
231
  msg.type === "read_global_claude_md" || msg.type === "write_global_claude_md" ||
232
232
  msg.type === "get_shared_env" || msg.type === "set_shared_env" ||
233
233
  msg.type === "transfer_project_owner") {
234
- if (ws._clayUser) {
235
- var psPerms = usersModule.getEffectivePermissions(ws._clayUser, osUsers);
234
+ if (ws._clagenticUser) {
235
+ var psPerms = usersModule.getEffectivePermissions(ws._clagenticUser, osUsers);
236
236
  if (!psPerms.projectSettings) {
237
237
  sendTo(ws, { type: "error", text: "Project settings access is not permitted" });
238
238
  return true;
@@ -174,10 +174,10 @@ function attachHTTP(ctx) {
174
174
  // Make readable by all local users and chown to session owner
175
175
  try { fs.chmodSync(destPath, 0o644); } catch (e2) {}
176
176
  try { fs.chmodSync(tmpDir, 0o755); } catch (e2) {}
177
- if (req._clayUser && req._clayUser.linuxUser) {
177
+ if (req._clagenticUser && req._clagenticUser.linuxUser) {
178
178
  try {
179
179
  var _osUM = require("./os-users");
180
- var _uid = _osUM.getLinuxUserUid(req._clayUser.linuxUser);
180
+ var _uid = _osUM.getLinuxUserUid(req._clagenticUser.linuxUser);
181
181
  if (_uid != null) {
182
182
  execFileSync("chown", [String(_uid), destPath]);
183
183
  execFileSync("chown", [String(_uid), tmpDir]);
@@ -297,8 +297,8 @@ function attachHTTP(ctx) {
297
297
 
298
298
  // Skills permission gate
299
299
  if (urlPath === "/api/install-skill" || urlPath === "/api/uninstall-skill" || urlPath === "/api/installed-skills") {
300
- if (req._clayUser) {
301
- var skPerms = usersModule.getEffectivePermissions(req._clayUser, osUsers);
300
+ if (req._clagenticUser) {
301
+ var skPerms = usersModule.getEffectivePermissions(req._clagenticUser, osUsers);
302
302
  if (!skPerms.skills) {
303
303
  res.writeHead(403, { "Content-Type": "application/json" });
304
304
  res.end('{"error":"Skills access is not permitted"}');
@@ -1018,9 +1018,9 @@ function attachLoop(ctx) {
1018
1018
  // for removal (loop_message_remove below) independent of its array
1019
1019
  // position, which shifts as other messages are queued/delivered.
1020
1020
  var _lmEntry = { id: crypto.randomBytes(8).toString("hex"), text: _lmText, ts: Date.now() };
1021
- if (ws && ws._clayUser) {
1022
- _lmEntry.from = ws._clayUser.id;
1023
- _lmEntry.fromName = ws._clayUser.displayName || ws._clayUser.username || "";
1021
+ if (ws && ws._clagenticUser) {
1022
+ _lmEntry.from = ws._clagenticUser.id;
1023
+ _lmEntry.fromName = ws._clagenticUser.displayName || ws._clagenticUser.username || "";
1024
1024
  }
1025
1025
  loopState.pendingUserMessages.push(_lmEntry);
1026
1026
  saveLoopState();
@@ -1402,7 +1402,7 @@ function attachLoop(ctx) {
1402
1402
  // connected (most-recently-active) project crowded out the genuinely most
1403
1403
  // recent sessions overall. getAllProjectSessions returns annotated shallow
1404
1404
  // copies carrying _projectSlug/_projectTitle/_projectIcon for every project.
1405
- var hubUserId = ws._clayUser ? ws._clayUser.id : null;
1405
+ var hubUserId = ws._clagenticUser ? ws._clagenticUser.id : null;
1406
1406
  var allSessions = getAllProjectSessions ? getAllProjectSessions(true, hubUserId) : [];
1407
1407
  // Sort newest-first by lastActivity
1408
1408
  allSessions.sort(function (a, b) {