@umimoney/clawdbot-relay-plugin 0.1.1 → 0.1.3
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/clawdbot.plugin.json +1 -1
- package/dist/index.d.mts +10 -8
- package/dist/index.d.ts +10 -8
- package/dist/index.js +34 -35
- package/dist/index.mjs +31 -34
- package/package.json +1 -1
package/clawdbot.plugin.json
CHANGED
|
@@ -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.3",
|
|
6
6
|
"description": "Connect to UMI relay server for real-time chat visibility in UMI web UI",
|
|
7
7
|
"type": "channel",
|
|
8
8
|
"main": "dist/index.js",
|
package/dist/index.d.mts
CHANGED
|
@@ -104,12 +104,14 @@ interface ClawdbotContext {
|
|
|
104
104
|
}) => void;
|
|
105
105
|
registerSend: (channel: string, handler: (response: any) => void) => void;
|
|
106
106
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
107
|
+
/**
|
|
108
|
+
* Activate the UMI Relay plugin (Clawdbot standard export)
|
|
109
|
+
*/
|
|
110
|
+
declare function activate(ctx: ClawdbotContext, config: RelayConfig): Promise<void>;
|
|
111
|
+
/**
|
|
112
|
+
* Deactivate the UMI Relay plugin
|
|
113
|
+
*/
|
|
114
|
+
declare function deactivate(): void;
|
|
115
|
+
declare const register: typeof activate;
|
|
114
116
|
|
|
115
|
-
export { type ClawdbotContext, type
|
|
117
|
+
export { type ClawdbotContext, type MessageHandler, type RelayConfig, type RelayMessage, type StateUpdate, UmiRelayClient, activate, deactivate, register };
|
package/dist/index.d.ts
CHANGED
|
@@ -104,12 +104,14 @@ interface ClawdbotContext {
|
|
|
104
104
|
}) => void;
|
|
105
105
|
registerSend: (channel: string, handler: (response: any) => void) => void;
|
|
106
106
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
107
|
+
/**
|
|
108
|
+
* Activate the UMI Relay plugin (Clawdbot standard export)
|
|
109
|
+
*/
|
|
110
|
+
declare function activate(ctx: ClawdbotContext, config: RelayConfig): Promise<void>;
|
|
111
|
+
/**
|
|
112
|
+
* Deactivate the UMI Relay plugin
|
|
113
|
+
*/
|
|
114
|
+
declare function deactivate(): void;
|
|
115
|
+
declare const register: typeof activate;
|
|
114
116
|
|
|
115
|
-
export { type ClawdbotContext, type
|
|
117
|
+
export { type ClawdbotContext, type MessageHandler, type RelayConfig, type RelayMessage, type StateUpdate, UmiRelayClient, activate, deactivate, register };
|
package/dist/index.js
CHANGED
|
@@ -31,8 +31,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
UmiRelayClient: () => UmiRelayClient,
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
activate: () => activate,
|
|
35
|
+
deactivate: () => deactivate,
|
|
36
|
+
register: () => register
|
|
36
37
|
});
|
|
37
38
|
module.exports = __toCommonJS(index_exports);
|
|
38
39
|
var import_ws = __toESM(require("ws"));
|
|
@@ -272,42 +273,40 @@ var UmiRelayClient = class {
|
|
|
272
273
|
}
|
|
273
274
|
};
|
|
274
275
|
var relayClient = null;
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
agentId: message.agentId
|
|
288
|
-
}
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
});
|
|
292
|
-
ctx.registerSend("umi", (response) => {
|
|
293
|
-
if (relayClient?.isConnected) {
|
|
294
|
-
relayClient.sendMessage(response.text || response.content, response.metadata);
|
|
295
|
-
}
|
|
296
|
-
});
|
|
297
|
-
await relayClient.connect();
|
|
298
|
-
console.log("[UmiRelay] Plugin started");
|
|
299
|
-
},
|
|
300
|
-
stop() {
|
|
301
|
-
if (relayClient) {
|
|
302
|
-
relayClient.disconnect();
|
|
303
|
-
relayClient = null;
|
|
276
|
+
async function activate(ctx, config) {
|
|
277
|
+
relayClient = new UmiRelayClient(config);
|
|
278
|
+
relayClient.onMessage((message) => {
|
|
279
|
+
if (message.type === "platform:message") {
|
|
280
|
+
ctx.injectMessage({
|
|
281
|
+
channel: "umi",
|
|
282
|
+
text: message.content,
|
|
283
|
+
metadata: {
|
|
284
|
+
userId: message.userId,
|
|
285
|
+
agentId: message.agentId
|
|
286
|
+
}
|
|
287
|
+
});
|
|
304
288
|
}
|
|
305
|
-
|
|
289
|
+
});
|
|
290
|
+
ctx.registerSend("umi", (response) => {
|
|
291
|
+
if (relayClient?.isConnected) {
|
|
292
|
+
relayClient.sendMessage(response.text || response.content, response.metadata);
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
await relayClient.connect();
|
|
296
|
+
console.log("[UmiRelay] Plugin activated");
|
|
297
|
+
}
|
|
298
|
+
function deactivate() {
|
|
299
|
+
if (relayClient) {
|
|
300
|
+
relayClient.disconnect();
|
|
301
|
+
relayClient = null;
|
|
306
302
|
}
|
|
307
|
-
|
|
308
|
-
|
|
303
|
+
console.log("[UmiRelay] Plugin deactivated");
|
|
304
|
+
}
|
|
305
|
+
var register = activate;
|
|
309
306
|
// Annotate the CommonJS export names for ESM import in node:
|
|
310
307
|
0 && (module.exports = {
|
|
311
308
|
UmiRelayClient,
|
|
312
|
-
|
|
309
|
+
activate,
|
|
310
|
+
deactivate,
|
|
311
|
+
register
|
|
313
312
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -236,42 +236,39 @@ var UmiRelayClient = class {
|
|
|
236
236
|
}
|
|
237
237
|
};
|
|
238
238
|
var relayClient = null;
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
agentId: message.agentId
|
|
252
|
-
}
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
});
|
|
256
|
-
ctx.registerSend("umi", (response) => {
|
|
257
|
-
if (relayClient?.isConnected) {
|
|
258
|
-
relayClient.sendMessage(response.text || response.content, response.metadata);
|
|
259
|
-
}
|
|
260
|
-
});
|
|
261
|
-
await relayClient.connect();
|
|
262
|
-
console.log("[UmiRelay] Plugin started");
|
|
263
|
-
},
|
|
264
|
-
stop() {
|
|
265
|
-
if (relayClient) {
|
|
266
|
-
relayClient.disconnect();
|
|
267
|
-
relayClient = null;
|
|
239
|
+
async function activate(ctx, config) {
|
|
240
|
+
relayClient = new UmiRelayClient(config);
|
|
241
|
+
relayClient.onMessage((message) => {
|
|
242
|
+
if (message.type === "platform:message") {
|
|
243
|
+
ctx.injectMessage({
|
|
244
|
+
channel: "umi",
|
|
245
|
+
text: message.content,
|
|
246
|
+
metadata: {
|
|
247
|
+
userId: message.userId,
|
|
248
|
+
agentId: message.agentId
|
|
249
|
+
}
|
|
250
|
+
});
|
|
268
251
|
}
|
|
269
|
-
|
|
252
|
+
});
|
|
253
|
+
ctx.registerSend("umi", (response) => {
|
|
254
|
+
if (relayClient?.isConnected) {
|
|
255
|
+
relayClient.sendMessage(response.text || response.content, response.metadata);
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
await relayClient.connect();
|
|
259
|
+
console.log("[UmiRelay] Plugin activated");
|
|
260
|
+
}
|
|
261
|
+
function deactivate() {
|
|
262
|
+
if (relayClient) {
|
|
263
|
+
relayClient.disconnect();
|
|
264
|
+
relayClient = null;
|
|
270
265
|
}
|
|
271
|
-
|
|
272
|
-
|
|
266
|
+
console.log("[UmiRelay] Plugin deactivated");
|
|
267
|
+
}
|
|
268
|
+
var register = activate;
|
|
273
269
|
export {
|
|
274
270
|
UmiRelayClient,
|
|
275
|
-
|
|
276
|
-
|
|
271
|
+
activate,
|
|
272
|
+
deactivate,
|
|
273
|
+
register
|
|
277
274
|
};
|