@cryptiklemur/lattice 4.0.0 → 4.0.2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/server/index.ts +17 -11
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cryptiklemur/lattice",
3
- "version": "4.0.0",
3
+ "version": "4.0.2",
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>",
@@ -6,7 +6,6 @@ import { existsSync, readFileSync, writeFileSync, unlinkSync, openSync } from "n
6
6
  import { join, dirname } from "node:path";
7
7
  import { fileURLToPath } from "node:url";
8
8
  import { spawn, execSync } from "node:child_process";
9
- import { DAEMON_PID_FILE } from "#shared";
10
9
  import { getLatticeHome, loadConfig } from "./config";
11
10
 
12
11
  var __filename_local = fileURLToPath(import.meta.url);
@@ -36,12 +35,17 @@ for (var i = 0; i < args.length; i++) {
36
35
  }
37
36
  }
38
37
 
39
- function getPidPath(): string {
40
- return join(getLatticeHome(), DAEMON_PID_FILE);
38
+ function getEffectivePort(): number {
39
+ return portOverride ?? loadConfig().port;
41
40
  }
42
41
 
43
- function readPid(): number | null {
44
- var pidPath = getPidPath();
42
+ function getPidPath(port?: number): string {
43
+ var p = port ?? getEffectivePort();
44
+ return join(getLatticeHome(), "daemon-" + p + ".pid");
45
+ }
46
+
47
+ function readPid(port?: number): number | null {
48
+ var pidPath = getPidPath(port);
45
49
  if (!existsSync(pidPath)) {
46
50
  return null;
47
51
  }
@@ -54,17 +58,16 @@ function readPid(): number | null {
54
58
  }
55
59
  }
56
60
 
57
- function writePid(pid: number): void {
58
- writeFileSync(getPidPath(), String(pid), "utf-8");
61
+ function writePid(pid: number, port?: number): void {
62
+ writeFileSync(getPidPath(port), String(pid), "utf-8");
59
63
  }
60
64
 
61
- function removePid(): void {
62
- var pidPath = getPidPath();
65
+ function removePid(port?: number): void {
66
+ var pidPath = getPidPath(port);
63
67
  if (existsSync(pidPath)) {
64
68
  try {
65
69
  unlinkSync(pidPath);
66
70
  } catch {
67
- // ignore
68
71
  }
69
72
  }
70
73
  }
@@ -81,7 +84,10 @@ function isDaemonRunning(pid: number): boolean {
81
84
  function spawnDaemon(port: number): number {
82
85
  var logPath = join(getLatticeHome(), "daemon.log");
83
86
  var logFd = openSync(logPath, "a");
84
- var child = spawn("tsx", [__filename_local, "daemon", "--port", String(port)], {
87
+ var pkgRoot = join(__dirname_local, "..");
88
+ var localTsx = join(pkgRoot, "node_modules", ".bin", "tsx");
89
+ var tsxBin = existsSync(localTsx) ? localTsx : "tsx";
90
+ var child = spawn(tsxBin, ["--tsconfig", join(pkgRoot, "tsconfig.json"), __filename_local, "daemon", "--port", String(port)], {
85
91
  detached: true,
86
92
  stdio: ["ignore", logFd, logFd],
87
93
  env: { ...process.env, LATTICE_PORT: undefined },