@umimoney/clawdbot-relay-plugin 0.1.13 → 0.1.15
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/dist/clawdbot.plugin.json +3 -33
- package/dist/index.d.mts +27 -27
- package/dist/index.d.ts +27 -27
- package/dist/index.js +44 -33
- package/dist/index.mjs +44 -33
- package/package.json +1 -1
|
@@ -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.
|
|
5
|
+
"version": "0.1.15",
|
|
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",
|
|
@@ -10,38 +10,8 @@
|
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"configSchema": {
|
|
12
12
|
"type": "object",
|
|
13
|
-
"additionalProperties":
|
|
14
|
-
"properties": {
|
|
15
|
-
"apiKey": {
|
|
16
|
-
"type": "string",
|
|
17
|
-
"description": "UMI API key (starts with umi_)"
|
|
18
|
-
},
|
|
19
|
-
"relayUrl": {
|
|
20
|
-
"type": "string",
|
|
21
|
-
"default": "wss://ws.umi.app/ws/relay",
|
|
22
|
-
"description": "UMI relay server URL"
|
|
23
|
-
},
|
|
24
|
-
"agentVersion": {
|
|
25
|
-
"type": "string",
|
|
26
|
-
"default": "1.0.0",
|
|
27
|
-
"description": "Agent version string"
|
|
28
|
-
},
|
|
29
|
-
"capabilities": {
|
|
30
|
-
"type": "array",
|
|
31
|
-
"items": { "type": "string" },
|
|
32
|
-
"default": ["chat"],
|
|
33
|
-
"description": "Agent capabilities"
|
|
34
|
-
},
|
|
35
|
-
"autoReconnect": {
|
|
36
|
-
"type": "boolean",
|
|
37
|
-
"default": true,
|
|
38
|
-
"description": "Reconnect on disconnect"
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
"uiHints": {
|
|
43
|
-
"apiKey": { "label": "API Key", "sensitive": true, "env": "UMI_API_KEY" },
|
|
44
|
-
"relayUrl": { "label": "Relay URL", "placeholder": "wss://ws.umi.app/ws/relay" }
|
|
13
|
+
"additionalProperties": true,
|
|
14
|
+
"properties": {}
|
|
45
15
|
},
|
|
46
16
|
"channels": ["umi-relay"]
|
|
47
17
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -96,11 +96,37 @@ declare class UmiRelayClient {
|
|
|
96
96
|
private scheduleReconnect;
|
|
97
97
|
private generateId;
|
|
98
98
|
}
|
|
99
|
+
interface PluginRuntime {
|
|
100
|
+
channel: {
|
|
101
|
+
reply: {
|
|
102
|
+
dispatchReplyWithBufferedBlockDispatcher: (opts: {
|
|
103
|
+
ctx: {
|
|
104
|
+
channel: string;
|
|
105
|
+
From: string;
|
|
106
|
+
Text: string;
|
|
107
|
+
accountId?: string;
|
|
108
|
+
ts?: number;
|
|
109
|
+
metadata?: Record<string, any>;
|
|
110
|
+
};
|
|
111
|
+
cfg: any;
|
|
112
|
+
dispatcherOptions: {
|
|
113
|
+
deliver: (payload: {
|
|
114
|
+
text: string;
|
|
115
|
+
metadata?: any;
|
|
116
|
+
}) => Promise<void>;
|
|
117
|
+
};
|
|
118
|
+
}) => void;
|
|
119
|
+
};
|
|
120
|
+
routing: {
|
|
121
|
+
resolveAgentRoute: (opts: any) => any;
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
}
|
|
99
125
|
interface ClawdbotPluginApi {
|
|
100
126
|
registerChannel: (opts: {
|
|
101
127
|
plugin: ChannelPlugin;
|
|
102
128
|
}) => void;
|
|
103
|
-
runtime:
|
|
129
|
+
runtime: PluginRuntime;
|
|
104
130
|
}
|
|
105
131
|
interface AccountInfo {
|
|
106
132
|
accountId: string;
|
|
@@ -160,32 +186,6 @@ interface GatewayContext {
|
|
|
160
186
|
account?: {
|
|
161
187
|
config?: any;
|
|
162
188
|
};
|
|
163
|
-
runtime: {
|
|
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
|
-
};
|
|
188
|
-
};
|
|
189
189
|
}
|
|
190
190
|
declare const _default: {
|
|
191
191
|
id: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -96,11 +96,37 @@ declare class UmiRelayClient {
|
|
|
96
96
|
private scheduleReconnect;
|
|
97
97
|
private generateId;
|
|
98
98
|
}
|
|
99
|
+
interface PluginRuntime {
|
|
100
|
+
channel: {
|
|
101
|
+
reply: {
|
|
102
|
+
dispatchReplyWithBufferedBlockDispatcher: (opts: {
|
|
103
|
+
ctx: {
|
|
104
|
+
channel: string;
|
|
105
|
+
From: string;
|
|
106
|
+
Text: string;
|
|
107
|
+
accountId?: string;
|
|
108
|
+
ts?: number;
|
|
109
|
+
metadata?: Record<string, any>;
|
|
110
|
+
};
|
|
111
|
+
cfg: any;
|
|
112
|
+
dispatcherOptions: {
|
|
113
|
+
deliver: (payload: {
|
|
114
|
+
text: string;
|
|
115
|
+
metadata?: any;
|
|
116
|
+
}) => Promise<void>;
|
|
117
|
+
};
|
|
118
|
+
}) => void;
|
|
119
|
+
};
|
|
120
|
+
routing: {
|
|
121
|
+
resolveAgentRoute: (opts: any) => any;
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
}
|
|
99
125
|
interface ClawdbotPluginApi {
|
|
100
126
|
registerChannel: (opts: {
|
|
101
127
|
plugin: ChannelPlugin;
|
|
102
128
|
}) => void;
|
|
103
|
-
runtime:
|
|
129
|
+
runtime: PluginRuntime;
|
|
104
130
|
}
|
|
105
131
|
interface AccountInfo {
|
|
106
132
|
accountId: string;
|
|
@@ -160,32 +186,6 @@ interface GatewayContext {
|
|
|
160
186
|
account?: {
|
|
161
187
|
config?: any;
|
|
162
188
|
};
|
|
163
|
-
runtime: {
|
|
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
|
-
};
|
|
188
|
-
};
|
|
189
189
|
}
|
|
190
190
|
declare const _default: {
|
|
191
191
|
id: string;
|
package/dist/index.js
CHANGED
|
@@ -270,6 +270,14 @@ var UmiRelayClient = class {
|
|
|
270
270
|
return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
271
271
|
}
|
|
272
272
|
};
|
|
273
|
+
var pluginRuntime = null;
|
|
274
|
+
function setPluginRuntime(runtime) {
|
|
275
|
+
pluginRuntime = runtime;
|
|
276
|
+
}
|
|
277
|
+
function getPluginRuntime() {
|
|
278
|
+
if (!pluginRuntime) throw new Error("[UmiRelay] Plugin runtime not initialized");
|
|
279
|
+
return pluginRuntime;
|
|
280
|
+
}
|
|
273
281
|
var relayClient = null;
|
|
274
282
|
var umiRelayChannel = {
|
|
275
283
|
id: "umi-relay",
|
|
@@ -282,10 +290,11 @@ var umiRelayChannel = {
|
|
|
282
290
|
chatTypes: ["direct"],
|
|
283
291
|
media: false
|
|
284
292
|
},
|
|
293
|
+
// Empty plugin config - all config comes from channel (channels.umi-relay)
|
|
285
294
|
configSchema: {
|
|
286
295
|
type: "object",
|
|
287
296
|
properties: {},
|
|
288
|
-
additionalProperties:
|
|
297
|
+
additionalProperties: true
|
|
289
298
|
},
|
|
290
299
|
config: {
|
|
291
300
|
listAccountIds: () => ["default"],
|
|
@@ -315,20 +324,15 @@ var umiRelayChannel = {
|
|
|
315
324
|
},
|
|
316
325
|
gateway: {
|
|
317
326
|
startAccount: async (ctx) => {
|
|
318
|
-
|
|
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 || {};
|
|
327
|
+
const account = ctx.account || {};
|
|
324
328
|
const config = {
|
|
325
|
-
apiKey:
|
|
326
|
-
relayUrl:
|
|
327
|
-
agentVersion:
|
|
328
|
-
capabilities:
|
|
329
|
-
autoReconnect:
|
|
329
|
+
apiKey: account.apiKey || account.config?.apiKey || process.env.UMI_API_KEY || "",
|
|
330
|
+
relayUrl: account.relayUrl || account.config?.relayUrl || "wss://ws.umi.app/ws/relay",
|
|
331
|
+
agentVersion: account.agentVersion || account.config?.agentVersion || "1.0.0",
|
|
332
|
+
capabilities: account.capabilities || account.config?.capabilities || ["chat"],
|
|
333
|
+
autoReconnect: account.autoReconnect ?? account.config?.autoReconnect ?? true
|
|
330
334
|
};
|
|
331
|
-
console.log("[UmiRelay]
|
|
335
|
+
console.log("[UmiRelay] Config from channel:", { ...config, apiKey: config.apiKey ? "***" : "MISSING" });
|
|
332
336
|
if (!config.apiKey) {
|
|
333
337
|
console.error("[UmiRelay] No API key provided. Set UMI_API_KEY or pass apiKey in config.");
|
|
334
338
|
return { stop: () => {
|
|
@@ -339,28 +343,33 @@ var umiRelayChannel = {
|
|
|
339
343
|
if (message.type === "platform:message") {
|
|
340
344
|
const userId = message.userId || "unknown";
|
|
341
345
|
console.log("[UmiRelay] Dispatching message to Clawdbot:", message.content);
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
346
|
+
try {
|
|
347
|
+
const runtime = getPluginRuntime();
|
|
348
|
+
runtime.channel.reply.dispatchReplyWithBufferedBlockDispatcher({
|
|
349
|
+
ctx: {
|
|
350
|
+
channel: "umi-relay",
|
|
351
|
+
From: userId,
|
|
352
|
+
Text: message.content,
|
|
353
|
+
accountId: "default",
|
|
354
|
+
ts: message.timestamp,
|
|
355
|
+
metadata: {
|
|
356
|
+
userId: message.userId,
|
|
357
|
+
agentId: message.agentId
|
|
358
|
+
}
|
|
359
|
+
},
|
|
360
|
+
cfg: ctx.cfg,
|
|
361
|
+
dispatcherOptions: {
|
|
362
|
+
deliver: async (payload) => {
|
|
363
|
+
console.log("[UmiRelay] Delivering response back to UMI:", payload.text?.substring(0, 50) + "...");
|
|
364
|
+
if (relayClient?.isConnected) {
|
|
365
|
+
relayClient.sendMessage(payload.text, { to: userId });
|
|
366
|
+
}
|
|
360
367
|
}
|
|
361
368
|
}
|
|
362
|
-
}
|
|
363
|
-
})
|
|
369
|
+
});
|
|
370
|
+
} catch (error) {
|
|
371
|
+
console.error("[UmiRelay] Failed to dispatch message:", error);
|
|
372
|
+
}
|
|
364
373
|
}
|
|
365
374
|
});
|
|
366
375
|
try {
|
|
@@ -384,6 +393,8 @@ var umiRelayChannel = {
|
|
|
384
393
|
var index_default = {
|
|
385
394
|
id: "umi-relay",
|
|
386
395
|
register(api) {
|
|
396
|
+
setPluginRuntime(api.runtime);
|
|
397
|
+
console.log("[UmiRelay] Runtime stored, registering channel...");
|
|
387
398
|
api.registerChannel({ plugin: umiRelayChannel });
|
|
388
399
|
}
|
|
389
400
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -235,6 +235,14 @@ var UmiRelayClient = class {
|
|
|
235
235
|
return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
236
236
|
}
|
|
237
237
|
};
|
|
238
|
+
var pluginRuntime = null;
|
|
239
|
+
function setPluginRuntime(runtime) {
|
|
240
|
+
pluginRuntime = runtime;
|
|
241
|
+
}
|
|
242
|
+
function getPluginRuntime() {
|
|
243
|
+
if (!pluginRuntime) throw new Error("[UmiRelay] Plugin runtime not initialized");
|
|
244
|
+
return pluginRuntime;
|
|
245
|
+
}
|
|
238
246
|
var relayClient = null;
|
|
239
247
|
var umiRelayChannel = {
|
|
240
248
|
id: "umi-relay",
|
|
@@ -247,10 +255,11 @@ var umiRelayChannel = {
|
|
|
247
255
|
chatTypes: ["direct"],
|
|
248
256
|
media: false
|
|
249
257
|
},
|
|
258
|
+
// Empty plugin config - all config comes from channel (channels.umi-relay)
|
|
250
259
|
configSchema: {
|
|
251
260
|
type: "object",
|
|
252
261
|
properties: {},
|
|
253
|
-
additionalProperties:
|
|
262
|
+
additionalProperties: true
|
|
254
263
|
},
|
|
255
264
|
config: {
|
|
256
265
|
listAccountIds: () => ["default"],
|
|
@@ -280,20 +289,15 @@ var umiRelayChannel = {
|
|
|
280
289
|
},
|
|
281
290
|
gateway: {
|
|
282
291
|
startAccount: async (ctx) => {
|
|
283
|
-
|
|
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 || {};
|
|
292
|
+
const account = ctx.account || {};
|
|
289
293
|
const config = {
|
|
290
|
-
apiKey:
|
|
291
|
-
relayUrl:
|
|
292
|
-
agentVersion:
|
|
293
|
-
capabilities:
|
|
294
|
-
autoReconnect:
|
|
294
|
+
apiKey: account.apiKey || account.config?.apiKey || process.env.UMI_API_KEY || "",
|
|
295
|
+
relayUrl: account.relayUrl || account.config?.relayUrl || "wss://ws.umi.app/ws/relay",
|
|
296
|
+
agentVersion: account.agentVersion || account.config?.agentVersion || "1.0.0",
|
|
297
|
+
capabilities: account.capabilities || account.config?.capabilities || ["chat"],
|
|
298
|
+
autoReconnect: account.autoReconnect ?? account.config?.autoReconnect ?? true
|
|
295
299
|
};
|
|
296
|
-
console.log("[UmiRelay]
|
|
300
|
+
console.log("[UmiRelay] Config from channel:", { ...config, apiKey: config.apiKey ? "***" : "MISSING" });
|
|
297
301
|
if (!config.apiKey) {
|
|
298
302
|
console.error("[UmiRelay] No API key provided. Set UMI_API_KEY or pass apiKey in config.");
|
|
299
303
|
return { stop: () => {
|
|
@@ -304,28 +308,33 @@ var umiRelayChannel = {
|
|
|
304
308
|
if (message.type === "platform:message") {
|
|
305
309
|
const userId = message.userId || "unknown";
|
|
306
310
|
console.log("[UmiRelay] Dispatching message to Clawdbot:", message.content);
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
311
|
+
try {
|
|
312
|
+
const runtime = getPluginRuntime();
|
|
313
|
+
runtime.channel.reply.dispatchReplyWithBufferedBlockDispatcher({
|
|
314
|
+
ctx: {
|
|
315
|
+
channel: "umi-relay",
|
|
316
|
+
From: userId,
|
|
317
|
+
Text: message.content,
|
|
318
|
+
accountId: "default",
|
|
319
|
+
ts: message.timestamp,
|
|
320
|
+
metadata: {
|
|
321
|
+
userId: message.userId,
|
|
322
|
+
agentId: message.agentId
|
|
323
|
+
}
|
|
324
|
+
},
|
|
325
|
+
cfg: ctx.cfg,
|
|
326
|
+
dispatcherOptions: {
|
|
327
|
+
deliver: async (payload) => {
|
|
328
|
+
console.log("[UmiRelay] Delivering response back to UMI:", payload.text?.substring(0, 50) + "...");
|
|
329
|
+
if (relayClient?.isConnected) {
|
|
330
|
+
relayClient.sendMessage(payload.text, { to: userId });
|
|
331
|
+
}
|
|
325
332
|
}
|
|
326
333
|
}
|
|
327
|
-
}
|
|
328
|
-
})
|
|
334
|
+
});
|
|
335
|
+
} catch (error) {
|
|
336
|
+
console.error("[UmiRelay] Failed to dispatch message:", error);
|
|
337
|
+
}
|
|
329
338
|
}
|
|
330
339
|
});
|
|
331
340
|
try {
|
|
@@ -349,6 +358,8 @@ var umiRelayChannel = {
|
|
|
349
358
|
var index_default = {
|
|
350
359
|
id: "umi-relay",
|
|
351
360
|
register(api) {
|
|
361
|
+
setPluginRuntime(api.runtime);
|
|
362
|
+
console.log("[UmiRelay] Runtime stored, registering channel...");
|
|
352
363
|
api.registerChannel({ plugin: umiRelayChannel });
|
|
353
364
|
}
|
|
354
365
|
};
|