@clagentic/console 1.2.0-beta.2 → 1.2.1-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/daemon.js CHANGED
@@ -1320,44 +1320,32 @@ var ipc = createIPCServer(socketPath(), function (msg) {
1320
1320
  return { ok: true };
1321
1321
  }
1322
1322
 
1323
- // Production: fetch latest via npx, then spawn updated daemon
1324
- var { execSync: execSyncUpd, spawn: spawnUpd } = require("child_process");
1323
+ // Production: install to global npm, then shut down so the process manager
1324
+ // (systemd / clagentic-daemon.sh) restarts from the updated global install.
1325
+ // This is the only reliable path — npx installs to a cache location that the
1326
+ // restart wrapper does not consult, so npx-spawned daemons get replaced by the
1327
+ // old global version on the next supervised restart.
1328
+ var { execFileSync: execFileUpd } = require("child_process");
1325
1329
  var updTag = config.updateChannel === "beta" ? "beta" : "latest";
1326
- var updDaemonScript;
1330
+ var updOk = false;
1327
1331
  try {
1328
- // npx downloads the package and puts a bin symlink; `which` prints its path
1329
- var binPath = execSyncUpd(
1330
- "npx --yes --package=clagentic-console@" + updTag + " -- which clagentic-console",
1331
- { stdio: ["ignore", "pipe", "pipe"], timeout: 120000, encoding: "utf8" }
1332
- ).trim();
1333
- // Resolve symlink to get the actual package directory
1334
- var realBin = fs.realpathSync(binPath);
1335
- updDaemonScript = path.join(path.dirname(realBin), "..", "lib", "daemon.js");
1336
- updDaemonScript = path.resolve(updDaemonScript);
1337
- console.log("[daemon] Resolved updated daemon:", updDaemonScript);
1332
+ console.log("[daemon] Installing @clagentic/console@" + updTag + " globally...");
1333
+ execFileUpd("npm", ["install", "-g", "@clagentic/console@" + updTag], {
1334
+ stdio: ["ignore", "pipe", "pipe"],
1335
+ timeout: 120000,
1336
+ encoding: "utf8",
1337
+ });
1338
+ console.log("[daemon] Global install complete. Shutting down for supervised restart.");
1339
+ updOk = true;
1338
1340
  } catch (updErr) {
1339
- console.log("[daemon] npx resolve failed:", updErr.message);
1340
- // Fallback: restart with current code
1341
- updDaemonScript = path.join(__dirname, "daemon.js");
1341
+ console.log("[daemon] Global install failed:", updErr.message);
1342
+ relay.broadcastAll({ type: "update_failed", error: updErr.message });
1343
+ return { ok: false, error: updErr.message };
1344
+ }
1345
+ if (updOk) {
1346
+ updateHandoff = true;
1347
+ setTimeout(function () { gracefulShutdown(); }, 100);
1342
1348
  }
1343
- // Spawn new daemon process — it will retry if port is still in use
1344
- var { logPath: updLogPath, configPath: updConfigPath } = require("./config");
1345
- var updLogFd = fs.openSync(updLogPath(), "a");
1346
- var updChild = spawnUpd(process.execPath, [updDaemonScript], {
1347
- detached: true,
1348
- windowsHide: true,
1349
- stdio: ["ignore", updLogFd, updLogFd],
1350
- env: Object.assign({}, process.env, {
1351
- CLAGENTIC_CONFIG: updConfigPath(),
1352
- }),
1353
- });
1354
- updChild.unref();
1355
- fs.closeSync(updLogFd);
1356
- config.pid = updChild.pid;
1357
- saveConfig(config);
1358
- console.log("[daemon] Spawned new daemon (PID " + updChild.pid + "), shutting down...");
1359
- updateHandoff = true;
1360
- setTimeout(function () { gracefulShutdown(); }, 100);
1361
1349
  return { ok: true };
1362
1350
  }
1363
1351
 
@@ -26,6 +26,7 @@ function attachFilesystem(ctx) {
26
26
  var sendTo = ctx.sendTo;
27
27
  var safePath = ctx.safePath;
28
28
  var safeAbsPath = ctx.safeAbsPath;
29
+ var safeClaudePath = ctx.safeClaudePath;
29
30
  var getOsUserInfoForWs = ctx.getOsUserInfoForWs;
30
31
  var startFileWatch = ctx.startFileWatch;
31
32
  var stopFileWatch = ctx.stopFileWatch;
@@ -58,6 +59,10 @@ function attachFilesystem(ctx) {
58
59
  if (!fsDir && getOsUserInfoForWs(ws)) {
59
60
  fsDir = safeAbsPath(msg.path);
60
61
  }
62
+ // Allow read-only access to paths within ~/.claude/ (e.g. plans/)
63
+ if (!fsDir && safeClaudePath) {
64
+ fsDir = safeClaudePath(msg.path);
65
+ }
61
66
  if (!fsDir) {
62
67
  sendTo(ws, { type: "fs_list_result", path: msg.path, entries: [], error: "Access denied" });
63
68
  return true;
@@ -150,6 +155,10 @@ function attachFilesystem(ctx) {
150
155
  if (!fsFile && getOsUserInfoForWs(ws)) {
151
156
  fsFile = safeAbsPath(msg.path);
152
157
  }
158
+ // Allow read-only access to paths within ~/.claude/ (e.g. plans/)
159
+ if (!fsFile && safeClaudePath) {
160
+ fsFile = safeClaudePath(msg.path);
161
+ }
153
162
  if (!fsFile) {
154
163
  sendTo(ws, { type: "fs_read_result", path: msg.path, error: "Access denied" });
155
164
  return true;
@@ -1,7 +1,6 @@
1
1
  /**
2
- * Memory engine stub — memory was a Clay Mates feature.
3
- * Mates have been removed (lr-316f). This stub satisfies the
4
- * project.js interface so existing call sites compile cleanly.
2
+ * Memory engine stub — memory was part of the Mates feature (removed lr-316f).
3
+ * This stub satisfies the project.js interface so existing call sites compile cleanly.
5
4
  *
6
5
  * handleMemoryList / handleMemorySearch / handleMemoryDelete are
7
6
  * kept as no-ops; the WS message types (memory_list etc.) still
package/lib/project.js CHANGED
@@ -121,6 +121,23 @@ function safeAbsPath(requested) {
121
121
  }
122
122
  }
123
123
 
124
+ // Resolve an absolute path within the Claude Code data directory (~/.claude/).
125
+ // Used as read-only fallback so plan files and other Claude-owned paths that live
126
+ // outside the project cwd (e.g. ~/.claude/plans/) can be previewed in the file viewer.
127
+ function safeClaudePath(requested) {
128
+ if (!requested) return null;
129
+ var claudeDir = path.join(require("./config").REAL_HOME, ".claude");
130
+ var resolved = path.resolve(requested);
131
+ if (resolved !== claudeDir && !resolved.startsWith(claudeDir + path.sep)) return null;
132
+ try {
133
+ var real = fs.realpathSync(resolved);
134
+ if (real !== claudeDir && !real.startsWith(claudeDir + path.sep)) return null;
135
+ return real;
136
+ } catch (e) {
137
+ return null;
138
+ }
139
+ }
140
+
124
141
  /**
125
142
  * Create a project context — per-project state and handlers.
126
143
  * opts: { cwd, slug, title, pushModule, debug, dangerouslySkipPermissions, currentVersion }
@@ -969,6 +986,7 @@ function createProjectContext(opts) {
969
986
  sendTo: sendTo,
970
987
  safePath: safePath,
971
988
  safeAbsPath: safeAbsPath,
989
+ safeClaudePath: safeClaudePath,
972
990
  getOsUserInfoForWs: getOsUserInfoForWs,
973
991
  startFileWatch: startFileWatch,
974
992
  stopFileWatch: stopFileWatch,
@@ -1324,5 +1342,5 @@ function createProjectContext(opts) {
1324
1342
  };
1325
1343
  }
1326
1344
 
1327
- module.exports = { createProjectContext: createProjectContext, safePath: safePath, validateEnvString: validateEnvString };
1345
+ module.exports = { createProjectContext: createProjectContext, safePath: safePath, safeClaudePath: safeClaudePath, validateEnvString: validateEnvString };
1328
1346