@cryptiklemur/lattice 1.33.0 → 1.35.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cryptiklemur/lattice",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.35.0",
|
|
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>",
|
|
@@ -5,9 +5,11 @@ import { loadConfig } from "../config";
|
|
|
5
5
|
import { loadOrCreateIdentity } from "../identity";
|
|
6
6
|
import { generateInviteCode, parseInviteCode, validatePairingToken, consumePairingToken } from "../mesh/pairing";
|
|
7
7
|
import { addPeer, removePeer, loadPeers, getPeer } from "../mesh/peers";
|
|
8
|
-
import { getConnectedPeerIds, connectToPeer, reconnectPeer } from "../mesh/connector";
|
|
8
|
+
import { getConnectedPeerIds, connectToPeer, reconnectPeer, getPeerConnection, disconnectPeer } from "../mesh/connector";
|
|
9
9
|
import type { PeerInfo } from "@lattice/shared";
|
|
10
10
|
import { networkInterfaces } from "node:os";
|
|
11
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
12
|
+
import { execSync } from "node:child_process";
|
|
11
13
|
|
|
12
14
|
function getLocalAddress(): string {
|
|
13
15
|
var all = getAllAddresses();
|
|
@@ -27,6 +29,48 @@ function getAllAddresses(): Array<{ name: string; address: string }> {
|
|
|
27
29
|
}
|
|
28
30
|
}
|
|
29
31
|
}
|
|
32
|
+
|
|
33
|
+
if (isWSL()) {
|
|
34
|
+
var windowsAddrs = getWindowsHostAddresses();
|
|
35
|
+
for (var w = 0; w < windowsAddrs.length; w++) {
|
|
36
|
+
var exists = results.some(function (r) { return r.address === windowsAddrs[w].address; });
|
|
37
|
+
if (!exists) {
|
|
38
|
+
results.push(windowsAddrs[w]);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return results;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function isWSL(): boolean {
|
|
47
|
+
try {
|
|
48
|
+
if (existsSync("/proc/version")) {
|
|
49
|
+
var version = readFileSync("/proc/version", "utf-8");
|
|
50
|
+
return version.toLowerCase().includes("microsoft");
|
|
51
|
+
}
|
|
52
|
+
} catch {}
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function getWindowsHostAddresses(): Array<{ name: string; address: string }> {
|
|
57
|
+
var results: Array<{ name: string; address: string }> = [];
|
|
58
|
+
try {
|
|
59
|
+
var output = execSync(
|
|
60
|
+
"powershell.exe -NoProfile -Command \"Get-NetIPAddress -AddressFamily IPv4 | ForEach-Object { \\$_.IPAddress + '|' + \\$_.InterfaceAlias }\"",
|
|
61
|
+
{ encoding: "utf-8", timeout: 5000, stdio: ["pipe", "pipe", "pipe"] }
|
|
62
|
+
);
|
|
63
|
+
var lines = output.trim().split(/\r?\n/);
|
|
64
|
+
for (var i = 0; i < lines.length; i++) {
|
|
65
|
+
var parts = lines[i].trim().split("|");
|
|
66
|
+
var ip = parts[0];
|
|
67
|
+
var iface = parts[1] || "windows";
|
|
68
|
+
if (!ip || ip === "127.0.0.1") continue;
|
|
69
|
+
if (ip.startsWith("169.254.")) continue;
|
|
70
|
+
if (iface.includes("WSL")) continue;
|
|
71
|
+
results.push({ name: iface.toLowerCase().replace(/\s+/g, "-"), address: ip });
|
|
72
|
+
}
|
|
73
|
+
} catch {}
|
|
30
74
|
return results;
|
|
31
75
|
}
|
|
32
76
|
|
|
@@ -237,10 +281,26 @@ registerHandler("mesh", function (clientId: string, message: ClientMessage) {
|
|
|
237
281
|
|
|
238
282
|
if (message.type === "mesh:unpair") {
|
|
239
283
|
var unpairMsg = message as MeshUnpairMessage;
|
|
284
|
+
var identity = loadOrCreateIdentity();
|
|
285
|
+
var peerWs = getPeerConnection(unpairMsg.nodeId);
|
|
286
|
+
if (peerWs) {
|
|
287
|
+
peerWs.send(JSON.stringify({ type: "mesh:unpaired", nodeId: identity.id }));
|
|
288
|
+
}
|
|
289
|
+
disconnectPeer(unpairMsg.nodeId);
|
|
240
290
|
var removed = removePeer(unpairMsg.nodeId);
|
|
241
291
|
if (removed) {
|
|
242
292
|
broadcast({ type: "mesh:nodes", nodes: buildNodesMessage() });
|
|
243
293
|
}
|
|
244
294
|
return;
|
|
245
295
|
}
|
|
296
|
+
|
|
297
|
+
if ((message as any).type === "mesh:unpaired") {
|
|
298
|
+
var unpaired = message as any as { type: "mesh:unpaired"; nodeId: string };
|
|
299
|
+
disconnectPeer(unpaired.nodeId);
|
|
300
|
+
var wasRemoved = removePeer(unpaired.nodeId);
|
|
301
|
+
if (wasRemoved) {
|
|
302
|
+
broadcast({ type: "mesh:nodes", nodes: buildNodesMessage() });
|
|
303
|
+
}
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
246
306
|
});
|
|
@@ -239,6 +239,20 @@ export function getPeerConnection(nodeId: string): WebSocket | undefined {
|
|
|
239
239
|
return conn.ws;
|
|
240
240
|
}
|
|
241
241
|
|
|
242
|
+
export function disconnectPeer(nodeId: string): void {
|
|
243
|
+
var existing = connections.get(nodeId);
|
|
244
|
+
if (existing) {
|
|
245
|
+
existing.dead = true;
|
|
246
|
+
if (existing.retryTimer !== null) {
|
|
247
|
+
clearTimeout(existing.retryTimer);
|
|
248
|
+
existing.retryTimer = null;
|
|
249
|
+
}
|
|
250
|
+
existing.ws.close();
|
|
251
|
+
connections.delete(nodeId);
|
|
252
|
+
}
|
|
253
|
+
circuitBreakers.delete(nodeId);
|
|
254
|
+
}
|
|
255
|
+
|
|
242
256
|
export function reconnectPeer(nodeId: string): void {
|
|
243
257
|
var existing = connections.get(nodeId);
|
|
244
258
|
if (existing) {
|