clawmatrix 0.5.0 → 0.5.1

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": "clawmatrix",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Decentralized mesh cluster plugin for OpenClaw — inter-gateway communication, model proxy, task handoff, and tool proxy.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/connection.ts CHANGED
@@ -269,6 +269,16 @@ export class Connection extends EventEmitter<ConnectionEvents> {
269
269
  private async onRawMessage(data: unknown) {
270
270
  this.lastReceivedAt = Date.now();
271
271
 
272
+ // Normalize non-Buffer binary types to Buffer.
273
+ // Node.js 24+'s built-in WebSocket (undici) delivers binary frames as Blob
274
+ // (binaryType "blob") or ArrayBuffer (binaryType "arraybuffer").
275
+ // The ws package delivers Buffer (binaryType "nodebuffer").
276
+ if (data instanceof ArrayBuffer) {
277
+ data = Buffer.from(data);
278
+ } else if (typeof Blob !== "undefined" && data instanceof Blob) {
279
+ data = Buffer.from(await data.arrayBuffer());
280
+ }
281
+
272
282
  let frame: AnyClusterFrame | undefined;
273
283
 
274
284
  // Binary frame (Buffer) — decrypt directly without base64
@@ -643,10 +643,14 @@ export class PeerManager extends EventEmitter<PeerManagerEvents> {
643
643
  const attempt = this.reconnectAttempts.get(channelKey) ?? 0;
644
644
  debug("peer", `connectToChannel(${nodeId}): attempt=${attempt} url=${url}`);
645
645
 
646
- // Use a common WS subprotocol for traffic disguise
647
- let ws: WebSocket;
646
+ // Use the `ws` package for outbound connections.
647
+ // Node.js 24+'s built-in WebSocket (undici) defaults binaryType to "blob",
648
+ // causing binary frames to arrive as Blob instead of Buffer — which
649
+ // onRawMessage cannot handle, silently dropping encrypted frames (including auth_ok).
650
+ // The `ws` package defaults to binaryType "nodebuffer", avoiding this issue.
651
+ let ws: InstanceType<typeof WsWebSocket>;
648
652
  try {
649
- ws = new WebSocket(url, ["graphql-transport-ws"]);
653
+ ws = new WsWebSocket(url, ["graphql-transport-ws"]);
650
654
  } catch (err) {
651
655
  debug("peer", `connectToChannel(${nodeId}): WebSocket constructor threw: ${err}`);
652
656
  this.scheduleChannelReconnect(nodeId, url);
package/src/sentinel.ts CHANGED
@@ -177,7 +177,7 @@ function buildCapabilities(): NodeCapabilities {
177
177
  }
178
178
 
179
179
  function connectToPeer(peer: { nodeId: string; url: string }) {
180
- const ws = new WebSocket(peer.url, ["graphql-transport-ws"]);
180
+ const ws = new WsWebSocket(peer.url, ["graphql-transport-ws"]);
181
181
  const e2eeOpts: ConnectionE2eeOptions = {
182
182
  e2ee: config.e2ee,
183
183
  compression: config.compression,