@umimoney/clawdbot-relay-plugin 0.1.10 → 0.1.12

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.10",
5
+ "version": "0.1.12",
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
@@ -154,18 +154,39 @@ interface ChannelPlugin {
154
154
  };
155
155
  }
156
156
  interface GatewayContext {
157
- cfg: any;
157
+ cfg: any & {
158
+ channels?: Record<string, any>;
159
+ };
160
+ account?: {
161
+ config?: any;
162
+ };
158
163
  runtime: {
159
- inbound: (msg: InboundMessage) => void;
164
+ channel: {
165
+ reply: {
166
+ dispatchReplyWithBufferedBlockDispatcher: (opts: {
167
+ ctx: {
168
+ channel: string;
169
+ From: string;
170
+ Text: string;
171
+ accountId?: string;
172
+ ts?: number;
173
+ metadata?: Record<string, any>;
174
+ };
175
+ cfg: any;
176
+ dispatcherOptions: {
177
+ deliver: (payload: {
178
+ text: string;
179
+ metadata?: any;
180
+ }) => Promise<void>;
181
+ };
182
+ }) => void;
183
+ };
184
+ routing: {
185
+ resolveAgentRoute: (opts: any) => any;
186
+ };
187
+ };
160
188
  };
161
189
  }
162
- interface InboundMessage {
163
- channel: string;
164
- from: string;
165
- text: string;
166
- ts?: number;
167
- metadata?: Record<string, any>;
168
- }
169
190
  declare const _default: {
170
191
  id: string;
171
192
  register(api: ClawdbotPluginApi): void;
package/dist/index.d.ts CHANGED
@@ -154,18 +154,39 @@ interface ChannelPlugin {
154
154
  };
155
155
  }
156
156
  interface GatewayContext {
157
- cfg: any;
157
+ cfg: any & {
158
+ channels?: Record<string, any>;
159
+ };
160
+ account?: {
161
+ config?: any;
162
+ };
158
163
  runtime: {
159
- inbound: (msg: InboundMessage) => void;
164
+ channel: {
165
+ reply: {
166
+ dispatchReplyWithBufferedBlockDispatcher: (opts: {
167
+ ctx: {
168
+ channel: string;
169
+ From: string;
170
+ Text: string;
171
+ accountId?: string;
172
+ ts?: number;
173
+ metadata?: Record<string, any>;
174
+ };
175
+ cfg: any;
176
+ dispatcherOptions: {
177
+ deliver: (payload: {
178
+ text: string;
179
+ metadata?: any;
180
+ }) => Promise<void>;
181
+ };
182
+ }) => void;
183
+ };
184
+ routing: {
185
+ resolveAgentRoute: (opts: any) => any;
186
+ };
187
+ };
160
188
  };
161
189
  }
162
- interface InboundMessage {
163
- channel: string;
164
- from: string;
165
- text: string;
166
- ts?: number;
167
- metadata?: Record<string, any>;
168
- }
169
190
  declare const _default: {
170
191
  id: string;
171
192
  register(api: ClawdbotPluginApi): void;
package/dist/index.js CHANGED
@@ -315,13 +315,20 @@ var umiRelayChannel = {
315
315
  },
316
316
  gateway: {
317
317
  startAccount: async (ctx) => {
318
+ console.log("[UmiRelay] ctx keys:", Object.keys(ctx));
319
+ console.log("[UmiRelay] ctx.account:", ctx.account);
320
+ console.log("[UmiRelay] ctx.cfg:", ctx.cfg);
321
+ console.log("[UmiRelay] ctx.cfg?.channels:", ctx.cfg?.channels);
322
+ console.log('[UmiRelay] ctx.cfg?.channels?.["umi-relay"]:', ctx.cfg?.channels?.["umi-relay"]);
323
+ const channelConfig = ctx.account?.config || ctx.cfg?.channels?.["umi-relay"] || ctx.cfg || {};
318
324
  const config = {
319
- apiKey: ctx.cfg?.apiKey || process.env.UMI_API_KEY || "",
320
- relayUrl: ctx.cfg?.relayUrl || "wss://ws.umi.app/ws/relay",
321
- agentVersion: ctx.cfg?.agentVersion || "1.0.0",
322
- capabilities: ctx.cfg?.capabilities || ["chat"],
323
- autoReconnect: ctx.cfg?.autoReconnect ?? true
325
+ apiKey: channelConfig.apiKey || process.env.UMI_API_KEY || "",
326
+ relayUrl: channelConfig.relayUrl || "wss://ws.umi.app/ws/relay",
327
+ agentVersion: channelConfig.agentVersion || "1.0.0",
328
+ capabilities: channelConfig.capabilities || ["chat"],
329
+ autoReconnect: channelConfig.autoReconnect ?? true
324
330
  };
331
+ console.log("[UmiRelay] Resolved config:", { ...config, apiKey: config.apiKey ? "***" : "MISSING" });
325
332
  if (!config.apiKey) {
326
333
  console.error("[UmiRelay] No API key provided. Set UMI_API_KEY or pass apiKey in config.");
327
334
  return { stop: () => {
@@ -330,14 +337,28 @@ var umiRelayChannel = {
330
337
  relayClient = new UmiRelayClient(config);
331
338
  relayClient.onMessage((message) => {
332
339
  if (message.type === "platform:message") {
333
- ctx.runtime.inbound({
334
- channel: "umi-relay",
335
- from: message.userId || "unknown",
336
- text: message.content,
337
- ts: message.timestamp,
338
- metadata: {
339
- userId: message.userId,
340
- agentId: message.agentId
340
+ const userId = message.userId || "unknown";
341
+ console.log("[UmiRelay] Dispatching message to Clawdbot:", message.content);
342
+ ctx.runtime.channel.reply.dispatchReplyWithBufferedBlockDispatcher({
343
+ ctx: {
344
+ channel: "umi-relay",
345
+ From: userId,
346
+ Text: message.content,
347
+ accountId: "default",
348
+ ts: message.timestamp,
349
+ metadata: {
350
+ userId: message.userId,
351
+ agentId: message.agentId
352
+ }
353
+ },
354
+ cfg: ctx.cfg,
355
+ dispatcherOptions: {
356
+ deliver: async (payload) => {
357
+ console.log("[UmiRelay] Delivering response back to UMI:", payload.text?.substring(0, 50) + "...");
358
+ if (relayClient?.isConnected) {
359
+ relayClient.sendMessage(payload.text, { to: userId });
360
+ }
361
+ }
341
362
  }
342
363
  });
343
364
  }
package/dist/index.mjs CHANGED
@@ -280,13 +280,20 @@ var umiRelayChannel = {
280
280
  },
281
281
  gateway: {
282
282
  startAccount: async (ctx) => {
283
+ console.log("[UmiRelay] ctx keys:", Object.keys(ctx));
284
+ console.log("[UmiRelay] ctx.account:", ctx.account);
285
+ console.log("[UmiRelay] ctx.cfg:", ctx.cfg);
286
+ console.log("[UmiRelay] ctx.cfg?.channels:", ctx.cfg?.channels);
287
+ console.log('[UmiRelay] ctx.cfg?.channels?.["umi-relay"]:', ctx.cfg?.channels?.["umi-relay"]);
288
+ const channelConfig = ctx.account?.config || ctx.cfg?.channels?.["umi-relay"] || ctx.cfg || {};
283
289
  const config = {
284
- apiKey: ctx.cfg?.apiKey || process.env.UMI_API_KEY || "",
285
- relayUrl: ctx.cfg?.relayUrl || "wss://ws.umi.app/ws/relay",
286
- agentVersion: ctx.cfg?.agentVersion || "1.0.0",
287
- capabilities: ctx.cfg?.capabilities || ["chat"],
288
- autoReconnect: ctx.cfg?.autoReconnect ?? true
290
+ apiKey: channelConfig.apiKey || process.env.UMI_API_KEY || "",
291
+ relayUrl: channelConfig.relayUrl || "wss://ws.umi.app/ws/relay",
292
+ agentVersion: channelConfig.agentVersion || "1.0.0",
293
+ capabilities: channelConfig.capabilities || ["chat"],
294
+ autoReconnect: channelConfig.autoReconnect ?? true
289
295
  };
296
+ console.log("[UmiRelay] Resolved config:", { ...config, apiKey: config.apiKey ? "***" : "MISSING" });
290
297
  if (!config.apiKey) {
291
298
  console.error("[UmiRelay] No API key provided. Set UMI_API_KEY or pass apiKey in config.");
292
299
  return { stop: () => {
@@ -295,14 +302,28 @@ var umiRelayChannel = {
295
302
  relayClient = new UmiRelayClient(config);
296
303
  relayClient.onMessage((message) => {
297
304
  if (message.type === "platform:message") {
298
- ctx.runtime.inbound({
299
- channel: "umi-relay",
300
- from: message.userId || "unknown",
301
- text: message.content,
302
- ts: message.timestamp,
303
- metadata: {
304
- userId: message.userId,
305
- agentId: message.agentId
305
+ const userId = message.userId || "unknown";
306
+ console.log("[UmiRelay] Dispatching message to Clawdbot:", message.content);
307
+ ctx.runtime.channel.reply.dispatchReplyWithBufferedBlockDispatcher({
308
+ ctx: {
309
+ channel: "umi-relay",
310
+ From: userId,
311
+ Text: message.content,
312
+ accountId: "default",
313
+ ts: message.timestamp,
314
+ metadata: {
315
+ userId: message.userId,
316
+ agentId: message.agentId
317
+ }
318
+ },
319
+ cfg: ctx.cfg,
320
+ dispatcherOptions: {
321
+ deliver: async (payload) => {
322
+ console.log("[UmiRelay] Delivering response back to UMI:", payload.text?.substring(0, 50) + "...");
323
+ if (relayClient?.isConnected) {
324
+ relayClient.sendMessage(payload.text, { to: userId });
325
+ }
326
+ }
306
327
  }
307
328
  });
308
329
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umimoney/clawdbot-relay-plugin",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "description": "Clawdbot plugin for connecting to UMI relay server",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",