@clagentic/console 1.2.0-beta.2 → 1.2.0

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
 
@@ -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