@umimoney/clawdbot-relay-plugin 0.1.7 → 0.1.8

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.7",
5
+ "version": "0.1.8",
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
@@ -96,25 +96,62 @@ declare class UmiRelayClient {
96
96
  private scheduleReconnect;
97
97
  private generateId;
98
98
  }
99
- interface ClawdbotContext {
100
- injectMessage: (params: {
101
- channel: string;
102
- text: string;
103
- metadata?: any;
99
+ interface ClawdbotPluginApi {
100
+ registerChannel: (opts: {
101
+ plugin: ChannelPlugin;
104
102
  }) => void;
105
- registerSend: (channel: string, handler: (response: any) => void) => void;
103
+ runtime: any;
106
104
  }
107
- /** Plugin ID - must match manifest */
108
- declare const id = "umi-relay";
109
- /**
110
- * Activate the UMI Relay plugin (Clawdbot standard export)
111
- * Note: Clawdbot ignores async, so we fire-and-forget the connection
112
- */
113
- declare function activate(ctx: ClawdbotContext, config?: RelayConfig): void;
114
- /**
115
- * Deactivate the UMI Relay plugin
116
- */
117
- declare function deactivate(): void;
118
- declare const register: typeof activate;
105
+ interface ChannelPlugin {
106
+ id: string;
107
+ meta: {
108
+ id: string;
109
+ label: string;
110
+ description?: string;
111
+ };
112
+ capabilities: {
113
+ chatTypes: string[];
114
+ media: boolean;
115
+ };
116
+ outbound: {
117
+ deliveryMode: 'direct' | 'queued';
118
+ resolveTarget: (opts: {
119
+ to: string;
120
+ }) => {
121
+ ok: boolean;
122
+ to: string;
123
+ };
124
+ sendText: (opts: {
125
+ cfg: any;
126
+ to: string;
127
+ text: string;
128
+ }) => Promise<{
129
+ channel: string;
130
+ ok: boolean;
131
+ }>;
132
+ };
133
+ gateway: {
134
+ startAccount: (ctx: GatewayContext) => Promise<{
135
+ stop: () => void;
136
+ }>;
137
+ };
138
+ }
139
+ interface GatewayContext {
140
+ cfg: any;
141
+ runtime: {
142
+ inbound: (msg: InboundMessage) => void;
143
+ };
144
+ }
145
+ interface InboundMessage {
146
+ channel: string;
147
+ from: string;
148
+ text: string;
149
+ ts?: number;
150
+ metadata?: Record<string, any>;
151
+ }
152
+ declare const _default: {
153
+ id: string;
154
+ register(api: ClawdbotPluginApi): void;
155
+ };
119
156
 
120
- export { type ClawdbotContext, type MessageHandler, type RelayConfig, type RelayMessage, type StateUpdate, UmiRelayClient, activate, deactivate, id, register };
157
+ export { type MessageHandler, type RelayConfig, type RelayMessage, type StateUpdate, UmiRelayClient, _default as default };
package/dist/index.d.ts CHANGED
@@ -96,25 +96,62 @@ declare class UmiRelayClient {
96
96
  private scheduleReconnect;
97
97
  private generateId;
98
98
  }
99
- interface ClawdbotContext {
100
- injectMessage: (params: {
101
- channel: string;
102
- text: string;
103
- metadata?: any;
99
+ interface ClawdbotPluginApi {
100
+ registerChannel: (opts: {
101
+ plugin: ChannelPlugin;
104
102
  }) => void;
105
- registerSend: (channel: string, handler: (response: any) => void) => void;
103
+ runtime: any;
106
104
  }
107
- /** Plugin ID - must match manifest */
108
- declare const id = "umi-relay";
109
- /**
110
- * Activate the UMI Relay plugin (Clawdbot standard export)
111
- * Note: Clawdbot ignores async, so we fire-and-forget the connection
112
- */
113
- declare function activate(ctx: ClawdbotContext, config?: RelayConfig): void;
114
- /**
115
- * Deactivate the UMI Relay plugin
116
- */
117
- declare function deactivate(): void;
118
- declare const register: typeof activate;
105
+ interface ChannelPlugin {
106
+ id: string;
107
+ meta: {
108
+ id: string;
109
+ label: string;
110
+ description?: string;
111
+ };
112
+ capabilities: {
113
+ chatTypes: string[];
114
+ media: boolean;
115
+ };
116
+ outbound: {
117
+ deliveryMode: 'direct' | 'queued';
118
+ resolveTarget: (opts: {
119
+ to: string;
120
+ }) => {
121
+ ok: boolean;
122
+ to: string;
123
+ };
124
+ sendText: (opts: {
125
+ cfg: any;
126
+ to: string;
127
+ text: string;
128
+ }) => Promise<{
129
+ channel: string;
130
+ ok: boolean;
131
+ }>;
132
+ };
133
+ gateway: {
134
+ startAccount: (ctx: GatewayContext) => Promise<{
135
+ stop: () => void;
136
+ }>;
137
+ };
138
+ }
139
+ interface GatewayContext {
140
+ cfg: any;
141
+ runtime: {
142
+ inbound: (msg: InboundMessage) => void;
143
+ };
144
+ }
145
+ interface InboundMessage {
146
+ channel: string;
147
+ from: string;
148
+ text: string;
149
+ ts?: number;
150
+ metadata?: Record<string, any>;
151
+ }
152
+ declare const _default: {
153
+ id: string;
154
+ register(api: ClawdbotPluginApi): void;
155
+ };
119
156
 
120
- export { type ClawdbotContext, type MessageHandler, type RelayConfig, type RelayMessage, type StateUpdate, UmiRelayClient, activate, deactivate, id, register };
157
+ export { type MessageHandler, type RelayConfig, type RelayMessage, type StateUpdate, UmiRelayClient, _default as default };
package/dist/index.js CHANGED
@@ -31,10 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
33
  UmiRelayClient: () => UmiRelayClient,
34
- activate: () => activate,
35
- deactivate: () => deactivate,
36
- id: () => id,
37
- register: () => register
34
+ default: () => index_default
38
35
  });
39
36
  module.exports = __toCommonJS(index_exports);
40
37
  var import_ws = __toESM(require("ws"));
@@ -274,56 +271,82 @@ var UmiRelayClient = class {
274
271
  }
275
272
  };
276
273
  var relayClient = null;
277
- var id = "umi-relay";
278
- function activate(ctx, config) {
279
- const resolvedConfig = {
280
- apiKey: config?.apiKey || process.env.UMI_API_KEY || "",
281
- relayUrl: config?.relayUrl || "wss://ws.umi.app/ws/relay",
282
- agentVersion: config?.agentVersion || "1.0.0",
283
- capabilities: config?.capabilities || ["chat"],
284
- autoReconnect: config?.autoReconnect ?? true
285
- };
286
- if (!resolvedConfig.apiKey) {
287
- console.error("[UmiRelay] No API key provided. Set UMI_API_KEY or pass apiKey in config.");
288
- return;
289
- }
290
- relayClient = new UmiRelayClient(resolvedConfig);
291
- relayClient.onMessage((message) => {
292
- if (message.type === "platform:message") {
293
- ctx.injectMessage({
294
- channel: "umi",
295
- text: message.content,
296
- metadata: {
297
- userId: message.userId,
298
- agentId: message.agentId
274
+ var umiRelayChannel = {
275
+ id: "umi-relay",
276
+ meta: {
277
+ id: "umi-relay",
278
+ label: "UMI Relay",
279
+ description: "Connect to UMI relay server for real-time chat"
280
+ },
281
+ capabilities: {
282
+ chatTypes: ["direct"],
283
+ media: false
284
+ },
285
+ outbound: {
286
+ deliveryMode: "direct",
287
+ resolveTarget: ({ to }) => ({ ok: true, to }),
288
+ sendText: async ({ cfg, to, text }) => {
289
+ if (relayClient?.isConnected) {
290
+ relayClient.sendMessage(text, { to });
291
+ return { channel: "umi-relay", ok: true };
292
+ }
293
+ return { channel: "umi-relay", ok: false };
294
+ }
295
+ },
296
+ gateway: {
297
+ startAccount: async (ctx) => {
298
+ const config = {
299
+ apiKey: ctx.cfg?.apiKey || process.env.UMI_API_KEY || "",
300
+ relayUrl: ctx.cfg?.relayUrl || "wss://ws.umi.app/ws/relay",
301
+ agentVersion: ctx.cfg?.agentVersion || "1.0.0",
302
+ capabilities: ctx.cfg?.capabilities || ["chat"],
303
+ autoReconnect: ctx.cfg?.autoReconnect ?? true
304
+ };
305
+ if (!config.apiKey) {
306
+ console.error("[UmiRelay] No API key provided. Set UMI_API_KEY or pass apiKey in config.");
307
+ return { stop: () => {
308
+ } };
309
+ }
310
+ relayClient = new UmiRelayClient(config);
311
+ relayClient.onMessage((message) => {
312
+ if (message.type === "platform:message") {
313
+ ctx.runtime.inbound({
314
+ channel: "umi-relay",
315
+ from: message.userId || "unknown",
316
+ text: message.content,
317
+ ts: message.timestamp,
318
+ metadata: {
319
+ userId: message.userId,
320
+ agentId: message.agentId
321
+ }
322
+ });
299
323
  }
300
324
  });
325
+ try {
326
+ await relayClient.connect();
327
+ console.log("[UmiRelay] Connected to relay");
328
+ } catch (error) {
329
+ console.error("[UmiRelay] Failed to connect:", error);
330
+ }
331
+ return {
332
+ stop: () => {
333
+ if (relayClient) {
334
+ relayClient.disconnect();
335
+ relayClient = null;
336
+ }
337
+ console.log("[UmiRelay] Disconnected");
338
+ }
339
+ };
301
340
  }
302
- });
303
- ctx.registerSend("umi", (response) => {
304
- if (relayClient?.isConnected) {
305
- relayClient.sendMessage(response.text || response.content, response.metadata);
306
- }
307
- });
308
- relayClient.connect().then(() => {
309
- console.log("[UmiRelay] Plugin activated and connected");
310
- }).catch((error) => {
311
- console.error("[UmiRelay] Failed to connect:", error);
312
- });
313
- }
314
- function deactivate() {
315
- if (relayClient) {
316
- relayClient.disconnect();
317
- relayClient = null;
318
341
  }
319
- console.log("[UmiRelay] Plugin deactivated");
320
- }
321
- var register = activate;
342
+ };
343
+ var index_default = {
344
+ id: "umi-relay",
345
+ register(api) {
346
+ api.registerChannel({ plugin: umiRelayChannel });
347
+ }
348
+ };
322
349
  // Annotate the CommonJS export names for ESM import in node:
323
350
  0 && (module.exports = {
324
- UmiRelayClient,
325
- activate,
326
- deactivate,
327
- id,
328
- register
351
+ UmiRelayClient
329
352
  });
package/dist/index.mjs CHANGED
@@ -236,55 +236,82 @@ var UmiRelayClient = class {
236
236
  }
237
237
  };
238
238
  var relayClient = null;
239
- var id = "umi-relay";
240
- function activate(ctx, config) {
241
- const resolvedConfig = {
242
- apiKey: config?.apiKey || process.env.UMI_API_KEY || "",
243
- relayUrl: config?.relayUrl || "wss://ws.umi.app/ws/relay",
244
- agentVersion: config?.agentVersion || "1.0.0",
245
- capabilities: config?.capabilities || ["chat"],
246
- autoReconnect: config?.autoReconnect ?? true
247
- };
248
- if (!resolvedConfig.apiKey) {
249
- console.error("[UmiRelay] No API key provided. Set UMI_API_KEY or pass apiKey in config.");
250
- return;
251
- }
252
- relayClient = new UmiRelayClient(resolvedConfig);
253
- relayClient.onMessage((message) => {
254
- if (message.type === "platform:message") {
255
- ctx.injectMessage({
256
- channel: "umi",
257
- text: message.content,
258
- metadata: {
259
- userId: message.userId,
260
- agentId: message.agentId
239
+ var umiRelayChannel = {
240
+ id: "umi-relay",
241
+ meta: {
242
+ id: "umi-relay",
243
+ label: "UMI Relay",
244
+ description: "Connect to UMI relay server for real-time chat"
245
+ },
246
+ capabilities: {
247
+ chatTypes: ["direct"],
248
+ media: false
249
+ },
250
+ outbound: {
251
+ deliveryMode: "direct",
252
+ resolveTarget: ({ to }) => ({ ok: true, to }),
253
+ sendText: async ({ cfg, to, text }) => {
254
+ if (relayClient?.isConnected) {
255
+ relayClient.sendMessage(text, { to });
256
+ return { channel: "umi-relay", ok: true };
257
+ }
258
+ return { channel: "umi-relay", ok: false };
259
+ }
260
+ },
261
+ gateway: {
262
+ startAccount: async (ctx) => {
263
+ const config = {
264
+ apiKey: ctx.cfg?.apiKey || process.env.UMI_API_KEY || "",
265
+ relayUrl: ctx.cfg?.relayUrl || "wss://ws.umi.app/ws/relay",
266
+ agentVersion: ctx.cfg?.agentVersion || "1.0.0",
267
+ capabilities: ctx.cfg?.capabilities || ["chat"],
268
+ autoReconnect: ctx.cfg?.autoReconnect ?? true
269
+ };
270
+ if (!config.apiKey) {
271
+ console.error("[UmiRelay] No API key provided. Set UMI_API_KEY or pass apiKey in config.");
272
+ return { stop: () => {
273
+ } };
274
+ }
275
+ relayClient = new UmiRelayClient(config);
276
+ relayClient.onMessage((message) => {
277
+ if (message.type === "platform:message") {
278
+ ctx.runtime.inbound({
279
+ channel: "umi-relay",
280
+ from: message.userId || "unknown",
281
+ text: message.content,
282
+ ts: message.timestamp,
283
+ metadata: {
284
+ userId: message.userId,
285
+ agentId: message.agentId
286
+ }
287
+ });
261
288
  }
262
289
  });
290
+ try {
291
+ await relayClient.connect();
292
+ console.log("[UmiRelay] Connected to relay");
293
+ } catch (error) {
294
+ console.error("[UmiRelay] Failed to connect:", error);
295
+ }
296
+ return {
297
+ stop: () => {
298
+ if (relayClient) {
299
+ relayClient.disconnect();
300
+ relayClient = null;
301
+ }
302
+ console.log("[UmiRelay] Disconnected");
303
+ }
304
+ };
263
305
  }
264
- });
265
- ctx.registerSend("umi", (response) => {
266
- if (relayClient?.isConnected) {
267
- relayClient.sendMessage(response.text || response.content, response.metadata);
268
- }
269
- });
270
- relayClient.connect().then(() => {
271
- console.log("[UmiRelay] Plugin activated and connected");
272
- }).catch((error) => {
273
- console.error("[UmiRelay] Failed to connect:", error);
274
- });
275
- }
276
- function deactivate() {
277
- if (relayClient) {
278
- relayClient.disconnect();
279
- relayClient = null;
280
306
  }
281
- console.log("[UmiRelay] Plugin deactivated");
282
- }
283
- var register = activate;
307
+ };
308
+ var index_default = {
309
+ id: "umi-relay",
310
+ register(api) {
311
+ api.registerChannel({ plugin: umiRelayChannel });
312
+ }
313
+ };
284
314
  export {
285
315
  UmiRelayClient,
286
- activate,
287
- deactivate,
288
- id,
289
- register
316
+ index_default as default
290
317
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umimoney/clawdbot-relay-plugin",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Clawdbot plugin for connecting to UMI relay server",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",