@umimoney/clawdbot-relay-plugin 0.1.17 → 0.1.18

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.
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://clawdbot.dev/schemas/plugin.json",
3
3
  "id": "umi-relay",
4
4
  "name": "UMI Relay",
5
- "version": "0.1.17",
5
+ "version": "0.1.18",
6
6
  "description": "Connect to UMI relay server for real-time chat visibility in UMI web UI",
7
7
  "type": "channel",
8
8
  "main": "index.js",
package/dist/index.d.mts CHANGED
@@ -50,6 +50,7 @@ declare class UmiRelayClient {
50
50
  private messageHandlers;
51
51
  private agentId;
52
52
  private isAuthenticated;
53
+ private isConnecting;
53
54
  constructor(config: RelayConfig);
54
55
  /**
55
56
  * Connect to the relay server
package/dist/index.d.ts CHANGED
@@ -50,6 +50,7 @@ declare class UmiRelayClient {
50
50
  private messageHandlers;
51
51
  private agentId;
52
52
  private isAuthenticated;
53
+ private isConnecting;
53
54
  constructor(config: RelayConfig);
54
55
  /**
55
56
  * Connect to the relay server
package/dist/index.js CHANGED
@@ -44,8 +44,9 @@ var UmiRelayClient = class {
44
44
  this.messageHandlers = /* @__PURE__ */ new Set();
45
45
  this.agentId = null;
46
46
  this.isAuthenticated = false;
47
+ this.isConnecting = false;
47
48
  this.config = {
48
- relayUrl: config.relayUrl || "wss://server.umi.app/ws/relay",
49
+ relayUrl: config.relayUrl || "wss://ws.umi.app/ws/relay",
49
50
  apiKey: config.apiKey,
50
51
  agentVersion: config.agentVersion || "1.0.0",
51
52
  capabilities: config.capabilities || ["chat"],
@@ -60,11 +61,25 @@ var UmiRelayClient = class {
60
61
  */
61
62
  connect() {
62
63
  return new Promise((resolve, reject) => {
64
+ if (this.isConnecting) {
65
+ console.log("[UmiRelay] Connection already in progress, skipping");
66
+ resolve();
67
+ return;
68
+ }
69
+ if (this.ws) {
70
+ console.log("[UmiRelay] Closing existing connection before reconnect");
71
+ const oldWs = this.ws;
72
+ this.ws = null;
73
+ oldWs.removeAllListeners();
74
+ oldWs.close();
75
+ }
76
+ this.isConnecting = true;
63
77
  try {
64
78
  const url = `${this.config.relayUrl}?type=agent`;
65
79
  console.log(`[UmiRelay] Connecting to ${url}`);
66
80
  this.ws = new import_ws.default(url);
67
81
  this.ws.on("open", () => {
82
+ this.isConnecting = false;
68
83
  console.log("[UmiRelay] Connected, authenticating...");
69
84
  this.authenticate();
70
85
  });
@@ -82,12 +97,14 @@ var UmiRelayClient = class {
82
97
  this.scheduleReconnect();
83
98
  });
84
99
  this.ws.on("error", (error) => {
100
+ this.isConnecting = false;
85
101
  console.error("[UmiRelay] WebSocket error:", error);
86
102
  if (!this.isAuthenticated) {
87
103
  reject(error);
88
104
  }
89
105
  });
90
106
  } catch (error) {
107
+ this.isConnecting = false;
91
108
  reject(error);
92
109
  }
93
110
  });
@@ -239,6 +256,7 @@ var UmiRelayClient = class {
239
256
  }
240
257
  cleanup() {
241
258
  this.isAuthenticated = false;
259
+ this.isConnecting = false;
242
260
  if (this.pingInterval) {
243
261
  clearInterval(this.pingInterval);
244
262
  this.pingInterval = null;
package/dist/index.mjs CHANGED
@@ -9,8 +9,9 @@ var UmiRelayClient = class {
9
9
  this.messageHandlers = /* @__PURE__ */ new Set();
10
10
  this.agentId = null;
11
11
  this.isAuthenticated = false;
12
+ this.isConnecting = false;
12
13
  this.config = {
13
- relayUrl: config.relayUrl || "wss://server.umi.app/ws/relay",
14
+ relayUrl: config.relayUrl || "wss://ws.umi.app/ws/relay",
14
15
  apiKey: config.apiKey,
15
16
  agentVersion: config.agentVersion || "1.0.0",
16
17
  capabilities: config.capabilities || ["chat"],
@@ -25,11 +26,25 @@ var UmiRelayClient = class {
25
26
  */
26
27
  connect() {
27
28
  return new Promise((resolve, reject) => {
29
+ if (this.isConnecting) {
30
+ console.log("[UmiRelay] Connection already in progress, skipping");
31
+ resolve();
32
+ return;
33
+ }
34
+ if (this.ws) {
35
+ console.log("[UmiRelay] Closing existing connection before reconnect");
36
+ const oldWs = this.ws;
37
+ this.ws = null;
38
+ oldWs.removeAllListeners();
39
+ oldWs.close();
40
+ }
41
+ this.isConnecting = true;
28
42
  try {
29
43
  const url = `${this.config.relayUrl}?type=agent`;
30
44
  console.log(`[UmiRelay] Connecting to ${url}`);
31
45
  this.ws = new WebSocket(url);
32
46
  this.ws.on("open", () => {
47
+ this.isConnecting = false;
33
48
  console.log("[UmiRelay] Connected, authenticating...");
34
49
  this.authenticate();
35
50
  });
@@ -47,12 +62,14 @@ var UmiRelayClient = class {
47
62
  this.scheduleReconnect();
48
63
  });
49
64
  this.ws.on("error", (error) => {
65
+ this.isConnecting = false;
50
66
  console.error("[UmiRelay] WebSocket error:", error);
51
67
  if (!this.isAuthenticated) {
52
68
  reject(error);
53
69
  }
54
70
  });
55
71
  } catch (error) {
72
+ this.isConnecting = false;
56
73
  reject(error);
57
74
  }
58
75
  });
@@ -204,6 +221,7 @@ var UmiRelayClient = class {
204
221
  }
205
222
  cleanup() {
206
223
  this.isAuthenticated = false;
224
+ this.isConnecting = false;
207
225
  if (this.pingInterval) {
208
226
  clearInterval(this.pingInterval);
209
227
  this.pingInterval = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umimoney/clawdbot-relay-plugin",
3
- "version": "0.1.17",
3
+ "version": "0.1.18",
4
4
  "description": "Clawdbot plugin for connecting to UMI relay server",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",