@cryptiklemur/lattice 1.36.1 → 1.36.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.
- package/package.json +1 -1
- package/server/src/mesh/proxy.ts +19 -22
- package/server/src/ws/broadcast.ts +14 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cryptiklemur/lattice",
|
|
3
|
-
"version": "1.36.
|
|
3
|
+
"version": "1.36.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>",
|
package/server/src/mesh/proxy.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import type { ClientMessage, MeshProxyRequestMessage, MeshProxyResponseMessage, ServerMessage } from "@lattice/shared";
|
|
3
3
|
import { getPeerConnection } from "./connector";
|
|
4
|
-
import { sendTo, broadcast } from "../ws/broadcast";
|
|
4
|
+
import { sendTo, broadcast, registerVirtualClient, removeVirtualClient } from "../ws/broadcast";
|
|
5
5
|
import { routeMessage } from "../ws/router";
|
|
6
6
|
|
|
7
7
|
var pendingRequests = new Map<string, string>();
|
|
@@ -30,29 +30,26 @@ export function proxyToRemoteNode(nodeId: string, projectSlug: string, clientId:
|
|
|
30
30
|
export function handleProxyRequest(sourceNodeId: string, msg: MeshProxyRequestMessage): void {
|
|
31
31
|
var proxyClientId = "mesh-proxy:" + sourceNodeId + ":" + msg.requestId;
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (!ws) {
|
|
40
|
-
console.warn("[mesh/proxy] Cannot send response, no connection to: " + sourceNodeId);
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
var envelope: MeshProxyResponseMessage = {
|
|
45
|
-
type: "mesh:proxy_response",
|
|
46
|
-
projectSlug: msg.projectSlug,
|
|
47
|
-
requestId: msg.requestId,
|
|
48
|
-
payload: response as ServerMessage,
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
ws.send(JSON.stringify(envelope));
|
|
33
|
+
registerVirtualClient(proxyClientId, function (response: object) {
|
|
34
|
+
var ws = getPeerConnection(sourceNodeId);
|
|
35
|
+
if (!ws) {
|
|
36
|
+
console.warn("[mesh/proxy] Cannot send response, no connection to: " + sourceNodeId);
|
|
37
|
+
removeVirtualClient(proxyClientId);
|
|
38
|
+
return;
|
|
52
39
|
}
|
|
53
|
-
};
|
|
54
40
|
|
|
55
|
-
|
|
41
|
+
var envelope: MeshProxyResponseMessage = {
|
|
42
|
+
type: "mesh:proxy_response",
|
|
43
|
+
projectSlug: msg.projectSlug,
|
|
44
|
+
requestId: msg.requestId,
|
|
45
|
+
payload: response as ServerMessage,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
ws.send(JSON.stringify(envelope));
|
|
49
|
+
removeVirtualClient(proxyClientId);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
routeMessage(proxyClientId, msg.payload);
|
|
56
53
|
}
|
|
57
54
|
|
|
58
55
|
export function handleProxyResponse(msg: MeshProxyResponseMessage): void {
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import type { ServerWebSocket } from "bun";
|
|
2
2
|
|
|
3
3
|
var clients = new Map<string, ServerWebSocket<{ id: string }>>();
|
|
4
|
+
var virtualSendHandlers = new Map<string, (message: object) => void>();
|
|
5
|
+
|
|
6
|
+
export function registerVirtualClient(id: string, handler: (message: object) => void): void {
|
|
7
|
+
virtualSendHandlers.set(id, handler);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function removeVirtualClient(id: string): void {
|
|
11
|
+
virtualSendHandlers.delete(id);
|
|
12
|
+
}
|
|
4
13
|
|
|
5
14
|
export function addClient(ws: ServerWebSocket<{ id: string }>): void {
|
|
6
15
|
clients.set(ws.data.id, ws);
|
|
@@ -23,6 +32,11 @@ export function sendTo(id: string, message: object): void {
|
|
|
23
32
|
var ws = clients.get(id);
|
|
24
33
|
if (ws) {
|
|
25
34
|
ws.send(JSON.stringify(message));
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
var virtualHandler = virtualSendHandlers.get(id);
|
|
38
|
+
if (virtualHandler) {
|
|
39
|
+
virtualHandler(message);
|
|
26
40
|
}
|
|
27
41
|
}
|
|
28
42
|
|