@cryptiklemur/lattice 1.40.5 → 1.40.7

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.40.5",
3
+ "version": "1.40.7",
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>",
@@ -230,6 +230,7 @@ export async function startDaemon(portOverride?: number | null): Promise<void> {
230
230
  Bun.serve<WsData>({
231
231
  port: config.port,
232
232
  hostname: "0.0.0.0",
233
+ reusePort: true,
233
234
  ...(tlsOptions ? { tls: tlsOptions } : {}),
234
235
 
235
236
  async fetch(req: Request, server: ReturnType<typeof Bun.serve>) {
@@ -121,10 +121,11 @@ async function runDaemon(): Promise<void> {
121
121
  stopMeshConnections();
122
122
 
123
123
  var waited = 0;
124
+ var maxWait = 2000;
124
125
  var checkInterval = setInterval(function () {
125
126
  var activeCount = getActiveStreamCount();
126
127
  waited += 500;
127
- if (activeCount === 0 || waited >= 5000) {
128
+ if (activeCount === 0 || waited >= maxWait) {
128
129
  clearInterval(checkInterval);
129
130
  closeAllClients();
130
131
  removePid();
@@ -52,7 +52,7 @@ function reconcilePeers(): void {
52
52
  continue;
53
53
  }
54
54
  var existing = connections.get(peer.id);
55
- if (existing && !existing.dead && existing.ws.readyState === WebSocket.OPEN) continue;
55
+ if (existing && !existing.dead && isWebSocketOpen(existing.ws)) continue;
56
56
  if (existing && !existing.dead && existing.retryTimer !== null) {
57
57
  log.meshConnect("skip %s — retry pending", peer.name);
58
58
  continue;
@@ -128,7 +128,7 @@ function openConnection(conn: PeerConnection, url: string): void {
128
128
  conn.ws = ws;
129
129
 
130
130
  var connectionTimer = setTimeout(function () {
131
- if (ws.readyState !== WebSocket.OPEN) {
131
+ if (!isWebSocketOpen(ws)) {
132
132
  log.meshConnect("connection timeout for %s at %s", conn.nodeId.slice(0, 8), url);
133
133
  ws.close();
134
134
  }
@@ -246,7 +246,7 @@ export function getPeerConnection(nodeId: string): WebSocket | undefined {
246
246
  if (!conn) {
247
247
  return undefined;
248
248
  }
249
- if (conn.ws.readyState !== WebSocket.OPEN) {
249
+ if (!isWebSocketOpen(conn.ws)) {
250
250
  return undefined;
251
251
  }
252
252
  return conn.ws;
@@ -254,7 +254,7 @@ export function getPeerConnection(nodeId: string): WebSocket | undefined {
254
254
 
255
255
  export function registerInboundPeer(nodeId: string, ws: { send: (data: string) => void; readyState: number }, peerProjects?: Array<{ slug: string; title: string }>): void {
256
256
  var existing = connections.get(nodeId);
257
- if (existing && !existing.dead && existing.ws.readyState === WebSocket.OPEN) {
257
+ if (existing && !existing.dead && isWebSocketOpen(existing.ws)) {
258
258
  log.meshConnect("inbound peer %s already connected, skipping", nodeId.slice(0, 8));
259
259
  return;
260
260
  }
@@ -342,7 +342,7 @@ export function reconnectPeer(nodeId: string): void {
342
342
  export function getConnectedPeerIds(): string[] {
343
343
  var ids: string[] = [];
344
344
  for (var [nodeId, conn] of connections) {
345
- if (conn.ws.readyState === WebSocket.OPEN) {
345
+ if (isWebSocketOpen(conn.ws)) {
346
346
  ids.push(nodeId);
347
347
  }
348
348
  }
@@ -361,9 +361,13 @@ export function onPeerMessage(callback: (nodeId: string, msg: MeshMessage) => vo
361
361
  messageCallbacks.push(callback);
362
362
  }
363
363
 
364
+ function isWebSocketOpen(ws: { readyState: number }): boolean {
365
+ return ws.readyState === WebSocket.OPEN || ws.readyState === 0;
366
+ }
367
+
364
368
  export function getConnectedPeerProjects(nodeId: string): Array<{ slug: string; title: string }> {
365
369
  var conn = connections.get(nodeId);
366
- if (!conn || conn.ws.readyState !== WebSocket.OPEN) return [];
370
+ if (!conn || !isWebSocketOpen(conn.ws)) return [];
367
371
  return conn.projects;
368
372
  }
369
373
 
@@ -402,7 +406,7 @@ export function getAllRemoteProjects(localNodeId: string): Array<{ slug: string;
402
406
 
403
407
  export function findNodeForProject(projectSlug: string): string | undefined {
404
408
  for (var [nodeId, conn] of connections) {
405
- if (conn.ws.readyState !== WebSocket.OPEN) {
409
+ if (!isWebSocketOpen(conn.ws)) {
406
410
  continue;
407
411
  }
408
412
  for (var i = 0; i < conn.projects.length; i++) {