@umimoney/clawdbot-relay-plugin 0.1.16 → 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.16",
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
@@ -103,7 +104,14 @@ interface PluginRuntime {
103
104
  ctx: {
104
105
  channel: string;
105
106
  From: string;
106
- Text: string;
107
+ To?: string;
108
+ Body?: string;
109
+ BodyForAgent?: string;
110
+ RawBody?: string;
111
+ CommandBody?: string;
112
+ Text?: string;
113
+ SessionKey?: string;
114
+ AccountId?: string;
107
115
  accountId?: string;
108
116
  ts?: number;
109
117
  metadata?: Record<string, any>;
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
@@ -103,7 +104,14 @@ interface PluginRuntime {
103
104
  ctx: {
104
105
  channel: string;
105
106
  From: string;
106
- Text: string;
107
+ To?: string;
108
+ Body?: string;
109
+ BodyForAgent?: string;
110
+ RawBody?: string;
111
+ CommandBody?: string;
112
+ Text?: string;
113
+ SessionKey?: string;
114
+ AccountId?: string;
107
115
  accountId?: string;
108
116
  ts?: number;
109
117
  metadata?: Record<string, any>;
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;
@@ -345,13 +363,23 @@ var umiRelayChannel = {
345
363
  console.log("[UmiRelay] Dispatching message to Clawdbot:", message.content, "from:", userId);
346
364
  try {
347
365
  const runtime = getPluginRuntime();
366
+ const content = String(message.content || "");
367
+ const sessionKey = `umi-relay:default:${userId}`;
348
368
  runtime.channel.reply.dispatchReplyWithBufferedBlockDispatcher({
349
369
  ctx: {
350
370
  channel: "umi-relay",
351
371
  From: userId,
352
372
  // Must be string
353
- Text: String(message.content || ""),
354
- accountId: "default",
373
+ To: "umi-relay:default",
374
+ Body: content,
375
+ // REQUIRED - agent reads this
376
+ BodyForAgent: content,
377
+ // REQUIRED - agent reads this
378
+ RawBody: content,
379
+ CommandBody: content,
380
+ Text: content,
381
+ SessionKey: sessionKey,
382
+ AccountId: "default",
355
383
  ts: message.timestamp,
356
384
  metadata: {
357
385
  userId: message.userId,
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;
@@ -310,13 +328,23 @@ var umiRelayChannel = {
310
328
  console.log("[UmiRelay] Dispatching message to Clawdbot:", message.content, "from:", userId);
311
329
  try {
312
330
  const runtime = getPluginRuntime();
331
+ const content = String(message.content || "");
332
+ const sessionKey = `umi-relay:default:${userId}`;
313
333
  runtime.channel.reply.dispatchReplyWithBufferedBlockDispatcher({
314
334
  ctx: {
315
335
  channel: "umi-relay",
316
336
  From: userId,
317
337
  // Must be string
318
- Text: String(message.content || ""),
319
- accountId: "default",
338
+ To: "umi-relay:default",
339
+ Body: content,
340
+ // REQUIRED - agent reads this
341
+ BodyForAgent: content,
342
+ // REQUIRED - agent reads this
343
+ RawBody: content,
344
+ CommandBody: content,
345
+ Text: content,
346
+ SessionKey: sessionKey,
347
+ AccountId: "default",
320
348
  ts: message.timestamp,
321
349
  metadata: {
322
350
  userId: message.userId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umimoney/clawdbot-relay-plugin",
3
- "version": "0.1.16",
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",