@umimoney/clawdbot-relay-plugin 0.1.12 → 0.1.14
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 +1 -2
- package/dist/index.d.mts +27 -27
- package/dist/index.d.ts +27 -27
- package/dist/index.js +35 -20
- package/dist/index.mjs +35 -20
- 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.14",
|
|
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",
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
"configSchema": {
|
|
12
12
|
"type": "object",
|
|
13
13
|
"additionalProperties": false,
|
|
14
|
-
"required": ["apiKey"],
|
|
15
14
|
"properties": {
|
|
16
15
|
"apiKey": {
|
|
17
16
|
"type": "string",
|
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",
|
|
@@ -339,28 +347,33 @@ var umiRelayChannel = {
|
|
|
339
347
|
if (message.type === "platform:message") {
|
|
340
348
|
const userId = message.userId || "unknown";
|
|
341
349
|
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
|
-
|
|
350
|
+
try {
|
|
351
|
+
const runtime = getPluginRuntime();
|
|
352
|
+
runtime.channel.reply.dispatchReplyWithBufferedBlockDispatcher({
|
|
353
|
+
ctx: {
|
|
354
|
+
channel: "umi-relay",
|
|
355
|
+
From: userId,
|
|
356
|
+
Text: message.content,
|
|
357
|
+
accountId: "default",
|
|
358
|
+
ts: message.timestamp,
|
|
359
|
+
metadata: {
|
|
360
|
+
userId: message.userId,
|
|
361
|
+
agentId: message.agentId
|
|
362
|
+
}
|
|
363
|
+
},
|
|
364
|
+
cfg: ctx.cfg,
|
|
365
|
+
dispatcherOptions: {
|
|
366
|
+
deliver: async (payload) => {
|
|
367
|
+
console.log("[UmiRelay] Delivering response back to UMI:", payload.text?.substring(0, 50) + "...");
|
|
368
|
+
if (relayClient?.isConnected) {
|
|
369
|
+
relayClient.sendMessage(payload.text, { to: userId });
|
|
370
|
+
}
|
|
360
371
|
}
|
|
361
372
|
}
|
|
362
|
-
}
|
|
363
|
-
})
|
|
373
|
+
});
|
|
374
|
+
} catch (error) {
|
|
375
|
+
console.error("[UmiRelay] Failed to dispatch message:", error);
|
|
376
|
+
}
|
|
364
377
|
}
|
|
365
378
|
});
|
|
366
379
|
try {
|
|
@@ -384,6 +397,8 @@ var umiRelayChannel = {
|
|
|
384
397
|
var index_default = {
|
|
385
398
|
id: "umi-relay",
|
|
386
399
|
register(api) {
|
|
400
|
+
setPluginRuntime(api.runtime);
|
|
401
|
+
console.log("[UmiRelay] Runtime stored, registering channel...");
|
|
387
402
|
api.registerChannel({ plugin: umiRelayChannel });
|
|
388
403
|
}
|
|
389
404
|
};
|
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",
|
|
@@ -304,28 +312,33 @@ var umiRelayChannel = {
|
|
|
304
312
|
if (message.type === "platform:message") {
|
|
305
313
|
const userId = message.userId || "unknown";
|
|
306
314
|
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
|
-
|
|
315
|
+
try {
|
|
316
|
+
const runtime = getPluginRuntime();
|
|
317
|
+
runtime.channel.reply.dispatchReplyWithBufferedBlockDispatcher({
|
|
318
|
+
ctx: {
|
|
319
|
+
channel: "umi-relay",
|
|
320
|
+
From: userId,
|
|
321
|
+
Text: message.content,
|
|
322
|
+
accountId: "default",
|
|
323
|
+
ts: message.timestamp,
|
|
324
|
+
metadata: {
|
|
325
|
+
userId: message.userId,
|
|
326
|
+
agentId: message.agentId
|
|
327
|
+
}
|
|
328
|
+
},
|
|
329
|
+
cfg: ctx.cfg,
|
|
330
|
+
dispatcherOptions: {
|
|
331
|
+
deliver: async (payload) => {
|
|
332
|
+
console.log("[UmiRelay] Delivering response back to UMI:", payload.text?.substring(0, 50) + "...");
|
|
333
|
+
if (relayClient?.isConnected) {
|
|
334
|
+
relayClient.sendMessage(payload.text, { to: userId });
|
|
335
|
+
}
|
|
325
336
|
}
|
|
326
337
|
}
|
|
327
|
-
}
|
|
328
|
-
})
|
|
338
|
+
});
|
|
339
|
+
} catch (error) {
|
|
340
|
+
console.error("[UmiRelay] Failed to dispatch message:", error);
|
|
341
|
+
}
|
|
329
342
|
}
|
|
330
343
|
});
|
|
331
344
|
try {
|
|
@@ -349,6 +362,8 @@ var umiRelayChannel = {
|
|
|
349
362
|
var index_default = {
|
|
350
363
|
id: "umi-relay",
|
|
351
364
|
register(api) {
|
|
365
|
+
setPluginRuntime(api.runtime);
|
|
366
|
+
console.log("[UmiRelay] Runtime stored, registering channel...");
|
|
352
367
|
api.registerChannel({ plugin: umiRelayChannel });
|
|
353
368
|
}
|
|
354
369
|
};
|