@cryptiklemur/lattice 1.36.3 → 1.36.5
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/package.json +1 -1
- package/server/src/handlers/update.ts +26 -3
- package/server/src/index.ts +22 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cryptiklemur/lattice",
|
|
3
|
-
"version": "1.36.
|
|
3
|
+
"version": "1.36.5",
|
|
4
4
|
"description": "Multi-machine agentic dashboard for Claude Code. Monitor sessions, manage MCP servers and skills, orchestrate across mesh-networked nodes.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Aaron Scherer <me@aaronscherer.me>",
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import { chmodSync,
|
|
1
|
+
import { chmodSync, writeFileSync, accessSync, copyFileSync, unlinkSync, constants as fsConstants } from "node:fs";
|
|
2
|
+
import { tmpdir } from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { execSync } from "node:child_process";
|
|
2
5
|
import type { ClientMessage } from "@lattice/shared";
|
|
3
6
|
import { registerHandler } from "../ws/router";
|
|
4
7
|
import { sendTo, broadcast } from "../ws/broadcast";
|
|
@@ -43,11 +46,31 @@ async function downloadBinaryUpdate(): Promise<{ success: boolean; message: stri
|
|
|
43
46
|
|
|
44
47
|
var binary = new Uint8Array(await downloadRes.arrayBuffer());
|
|
45
48
|
var execPath = process.execPath;
|
|
46
|
-
var tmpPath =
|
|
49
|
+
var tmpPath = join(tmpdir(), "lattice-update-" + Date.now());
|
|
47
50
|
|
|
48
51
|
writeFileSync(tmpPath, binary);
|
|
49
52
|
chmodSync(tmpPath, 0o755);
|
|
50
|
-
|
|
53
|
+
|
|
54
|
+
var needsSudo = false;
|
|
55
|
+
try {
|
|
56
|
+
accessSync(execPath, fsConstants.W_OK);
|
|
57
|
+
} catch {
|
|
58
|
+
needsSudo = true;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (needsSudo) {
|
|
62
|
+
try {
|
|
63
|
+
execSync("sudo cp " + JSON.stringify(tmpPath) + " " + JSON.stringify(execPath), { stdio: "pipe", timeout: 10000 });
|
|
64
|
+
execSync("sudo chmod +x " + JSON.stringify(execPath), { stdio: "pipe", timeout: 5000 });
|
|
65
|
+
unlinkSync(tmpPath);
|
|
66
|
+
} catch {
|
|
67
|
+
return { success: false, message: "Update downloaded but needs sudo to install. Run: sudo cp " + tmpPath + " " + execPath };
|
|
68
|
+
}
|
|
69
|
+
} else {
|
|
70
|
+
copyFileSync(tmpPath, execPath);
|
|
71
|
+
chmodSync(execPath, 0o755);
|
|
72
|
+
unlinkSync(tmpPath);
|
|
73
|
+
}
|
|
51
74
|
|
|
52
75
|
return { success: true, message: "Updated successfully. Restart the server to apply." };
|
|
53
76
|
} catch (err) {
|
package/server/src/index.ts
CHANGED
|
@@ -243,10 +243,30 @@ async function runUpdate(): Promise<void> {
|
|
|
243
243
|
console.log("[lattice] Downloading " + assetName + "...");
|
|
244
244
|
var downloadRes = await fetch(asset.browser_download_url);
|
|
245
245
|
var binary = new Uint8Array(await downloadRes.arrayBuffer());
|
|
246
|
-
var
|
|
246
|
+
var { tmpdir } = await import("node:os");
|
|
247
|
+
var tmpPath = join(tmpdir(), "lattice-update-" + Date.now());
|
|
247
248
|
writeFileSync(tmpPath, binary);
|
|
248
249
|
chmodSync(tmpPath, 0o755);
|
|
249
|
-
|
|
250
|
+
|
|
251
|
+
var needsSudo = false;
|
|
252
|
+
try {
|
|
253
|
+
var { accessSync, constants: fsConstants } = await import("node:fs");
|
|
254
|
+
accessSync(process.execPath, fsConstants.W_OK);
|
|
255
|
+
} catch {
|
|
256
|
+
needsSudo = true;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (needsSudo) {
|
|
260
|
+
console.log("[lattice] Needs elevated permissions to replace binary...");
|
|
261
|
+
var { execSync } = await import("node:child_process");
|
|
262
|
+
execSync("sudo cp " + JSON.stringify(tmpPath) + " " + JSON.stringify(process.execPath), { stdio: "inherit" });
|
|
263
|
+
execSync("sudo chmod +x " + JSON.stringify(process.execPath), { stdio: "inherit" });
|
|
264
|
+
} else {
|
|
265
|
+
var { copyFileSync: cpSync, unlinkSync: rmSync } = await import("node:fs");
|
|
266
|
+
cpSync(tmpPath, process.execPath);
|
|
267
|
+
chmodSync(process.execPath, 0o755);
|
|
268
|
+
rmSync(tmpPath);
|
|
269
|
+
}
|
|
250
270
|
code = 0;
|
|
251
271
|
} catch (err) {
|
|
252
272
|
console.error("[lattice] Download failed:", err instanceof Error ? err.message : String(err));
|