openclaw-elys 1.7.1 → 1.7.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/dist/src/monitor.js
CHANGED
|
@@ -30,12 +30,12 @@ export async function monitorElysProvider(opts) {
|
|
|
30
30
|
// 3. Set up command handler using PluginRuntime (same pattern as feishu)
|
|
31
31
|
const core = getElysRuntime();
|
|
32
32
|
const dispatchReplyFromConfig = core?.channel?.reply?.dispatchReplyFromConfig;
|
|
33
|
-
const
|
|
33
|
+
const createDispatcher = core?.channel?.reply?.createReplyDispatcherWithTyping;
|
|
34
34
|
const finalizeCtx = core?.channel?.reply?.finalizeInboundContext;
|
|
35
|
-
log(`[elys] pluginRuntime available: ${!!core}, dispatchReplyFromConfig: ${!!dispatchReplyFromConfig}, finalizeCtx: ${!!finalizeCtx}`);
|
|
35
|
+
log(`[elys] pluginRuntime available: ${!!core}, dispatchReplyFromConfig: ${!!dispatchReplyFromConfig}, createDispatcher: ${!!createDispatcher}, finalizeCtx: ${!!finalizeCtx}`);
|
|
36
36
|
const commandHandler = async (cmd, signal) => {
|
|
37
37
|
log(`[elys] executing command: ${cmd.command}`, cmd.args);
|
|
38
|
-
if (dispatchReplyFromConfig && finalizeCtx &&
|
|
38
|
+
if (dispatchReplyFromConfig && finalizeCtx && createDispatcher) {
|
|
39
39
|
try {
|
|
40
40
|
let seq = 0;
|
|
41
41
|
let fullText = "";
|
|
@@ -63,7 +63,7 @@ export async function monitorElysProvider(opts) {
|
|
|
63
63
|
fullText += payload.text;
|
|
64
64
|
seq++;
|
|
65
65
|
const done = info.kind === "final";
|
|
66
|
-
mqttClient.publishStreamChunk(cmd.id, payload.text, seq, done
|
|
66
|
+
mqttClient.publishStreamChunk(cmd.id, payload.text, seq, done);
|
|
67
67
|
if (info.kind === "block") {
|
|
68
68
|
log(`[elys] stream chunk #${seq}: ${payload.text.slice(0, 80)}...`);
|
|
69
69
|
}
|
|
@@ -73,12 +73,11 @@ export async function monitorElysProvider(opts) {
|
|
|
73
73
|
}
|
|
74
74
|
else if (info.kind === "final") {
|
|
75
75
|
seq++;
|
|
76
|
-
mqttClient.publishStreamChunk(cmd.id, "", seq, true
|
|
76
|
+
mqttClient.publishStreamChunk(cmd.id, "", seq, true);
|
|
77
77
|
log(`[elys] final reply delivered (empty)`);
|
|
78
78
|
}
|
|
79
79
|
};
|
|
80
80
|
// Create dispatcher + dispatch (same pattern as feishu built-in channel)
|
|
81
|
-
const createDispatcher = core.channel.reply.createReplyDispatcherWithTyping;
|
|
82
81
|
const { dispatcher, replyOptions, markDispatchIdle } = createDispatcher({
|
|
83
82
|
deliver,
|
|
84
83
|
onError: (err, info) => {
|
|
@@ -35,7 +35,7 @@ export declare class ElysDeviceMQTTClient {
|
|
|
35
35
|
connect(abortSignal?: AbortSignal): Promise<void>;
|
|
36
36
|
disconnect(): void;
|
|
37
37
|
/** Send a stream chunk (for streaming AI responses) */
|
|
38
|
-
publishStreamChunk(commandId: string, chunk: string, seq: number, done: boolean
|
|
38
|
+
publishStreamChunk(commandId: string, chunk: string, seq: number, done: boolean): void;
|
|
39
39
|
private onMessage;
|
|
40
40
|
private flushDebounce;
|
|
41
41
|
/** Merge multiple buffered commands into one. Joins text args with newline. */
|
package/dist/src/mqtt-client.js
CHANGED
|
@@ -120,7 +120,7 @@ export class ElysDeviceMQTTClient {
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
/** Send a stream chunk (for streaming AI responses) */
|
|
123
|
-
publishStreamChunk(commandId, chunk, seq, done
|
|
123
|
+
publishStreamChunk(commandId, chunk, seq, done) {
|
|
124
124
|
const msg = {
|
|
125
125
|
id: commandId,
|
|
126
126
|
type: "stream",
|
|
@@ -129,7 +129,7 @@ export class ElysDeviceMQTTClient {
|
|
|
129
129
|
seq,
|
|
130
130
|
done,
|
|
131
131
|
};
|
|
132
|
-
this.publish(msg
|
|
132
|
+
this.publish(msg);
|
|
133
133
|
}
|
|
134
134
|
// ─── Inbound message pipeline: dedup → ack → debounce → abort → execute ───
|
|
135
135
|
onMessage(payload) {
|
|
@@ -201,7 +201,6 @@ export class ElysDeviceMQTTClient {
|
|
|
201
201
|
async executeCommand(cmd, signal) {
|
|
202
202
|
if (!this.commandHandler)
|
|
203
203
|
return;
|
|
204
|
-
const replyTo = cmd.reply_to;
|
|
205
204
|
try {
|
|
206
205
|
const result = await Promise.race([
|
|
207
206
|
this.commandHandler(cmd, signal),
|
|
@@ -209,12 +208,11 @@ export class ElysDeviceMQTTClient {
|
|
|
209
208
|
const timer = setTimeout(() => {
|
|
210
209
|
reject(new Error(`command timed out after ${this.commandTimeoutMs / 1000}s`));
|
|
211
210
|
}, this.commandTimeoutMs);
|
|
212
|
-
// Clean up timer if command completes or is aborted
|
|
213
211
|
signal.addEventListener("abort", () => clearTimeout(timer), { once: true });
|
|
214
212
|
}),
|
|
215
213
|
]);
|
|
216
214
|
if (!signal.aborted) {
|
|
217
|
-
this.publish(result
|
|
215
|
+
this.publish(result);
|
|
218
216
|
}
|
|
219
217
|
}
|
|
220
218
|
catch (err) {
|
|
@@ -229,7 +227,7 @@ export class ElysDeviceMQTTClient {
|
|
|
229
227
|
timestamp: Math.floor(Date.now() / 1000),
|
|
230
228
|
status: "error",
|
|
231
229
|
error: errMsg,
|
|
232
|
-
}
|
|
230
|
+
});
|
|
233
231
|
}
|
|
234
232
|
}
|
|
235
233
|
cleanupDedup() {
|
|
@@ -249,10 +247,10 @@ export class ElysDeviceMQTTClient {
|
|
|
249
247
|
};
|
|
250
248
|
this.publish(msg);
|
|
251
249
|
}
|
|
252
|
-
publish(msg
|
|
250
|
+
publish(msg) {
|
|
253
251
|
if (!this.client)
|
|
254
252
|
return;
|
|
255
|
-
const topic =
|
|
253
|
+
const topic = `elys/up/${this.credentials.deviceId}`;
|
|
256
254
|
this.client.publish(topic, JSON.stringify(msg), { qos: 1 }, (err) => {
|
|
257
255
|
if (err) {
|
|
258
256
|
this.log(`[elys] failed to publish to ${topic}:`, err);
|
package/dist/src/types.d.ts
CHANGED
|
@@ -24,8 +24,6 @@ export interface CommandMessage extends MQTTBaseMessage {
|
|
|
24
24
|
type: "command";
|
|
25
25
|
command: string;
|
|
26
26
|
args?: Record<string, unknown>;
|
|
27
|
-
/** If set, device should publish result/stream to this topic instead of elys/up/{device_id} */
|
|
28
|
-
reply_to?: string;
|
|
29
27
|
}
|
|
30
28
|
export interface AckMessage extends MQTTBaseMessage {
|
|
31
29
|
type: "ack";
|