rol-websocket-channel 1.0.6 → 1.0.7
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/package.json
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
|
+
import { execFile } from 'node:child_process';
|
|
1
2
|
import path from 'node:path';
|
|
3
|
+
import { promisify } from 'node:util';
|
|
2
4
|
|
|
3
5
|
import { pathExists, readJsonFile, writeJsonFile } from '../lib/fs.ts';
|
|
4
6
|
import { JsonRpcException, JSON_RPC_ERRORS } from '../jsonrpc.ts';
|
|
5
7
|
import type { JsonValue, MethodContext } from '../types.ts';
|
|
6
8
|
|
|
9
|
+
const execFileAsync = promisify(execFile);
|
|
10
|
+
|
|
7
11
|
const DEFAULT_PLUGIN_ID = 'rol-websocket-channel';
|
|
8
12
|
const DEFAULT_PAIR_ENDPOINT = 'http://api.deotaland.local/api-core-bot/front/agent/agent/key/query';
|
|
13
|
+
const GATEWAY_SERVICE = 'openclaw-gateway.service';
|
|
9
14
|
|
|
10
15
|
interface PairingCommandOptions {
|
|
11
16
|
key: string;
|
|
@@ -57,6 +62,7 @@ export async function pairWithKey(
|
|
|
57
62
|
const payload = await exchangePairKey(key, options.endpoint, options.auth, existingMqttUrl);
|
|
58
63
|
applyPairingConfig(config, key, payload);
|
|
59
64
|
await writeJsonFile(configPath, config);
|
|
65
|
+
const restart = await restartGateway(context.projectRoot);
|
|
60
66
|
|
|
61
67
|
return {
|
|
62
68
|
ok: true,
|
|
@@ -69,7 +75,7 @@ export async function pairWithKey(
|
|
|
69
75
|
`channels.${payload.pluginId}`
|
|
70
76
|
],
|
|
71
77
|
channel: payload.channel,
|
|
72
|
-
|
|
78
|
+
restart
|
|
73
79
|
};
|
|
74
80
|
}
|
|
75
81
|
|
|
@@ -285,6 +291,23 @@ function resolveExistingMqttUrl(config: OpenClawConfig): string | null {
|
|
|
285
291
|
return pickString(channelConfig.mqttUrl);
|
|
286
292
|
}
|
|
287
293
|
|
|
294
|
+
async function restartGateway(cwd: string): Promise<JsonValue> {
|
|
295
|
+
try {
|
|
296
|
+
await execFileAsync('systemctl', ['--user', 'restart', GATEWAY_SERVICE], { cwd });
|
|
297
|
+
return {
|
|
298
|
+
attempted: true,
|
|
299
|
+
success: true
|
|
300
|
+
};
|
|
301
|
+
} catch (error: any) {
|
|
302
|
+
return {
|
|
303
|
+
attempted: true,
|
|
304
|
+
success: false,
|
|
305
|
+
message: error instanceof Error ? error.message : String(error),
|
|
306
|
+
stderr: typeof error?.stderr === 'string' ? error.stderr : ''
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
288
311
|
function normalizeGroupPolicy(value: string): 'pairing' | 'allowlist' | 'open' | 'disabled' {
|
|
289
312
|
if (value === 'pairing' || value === 'allowlist' || value === 'open' || value === 'disabled') {
|
|
290
313
|
return value;
|
|
@@ -63,12 +63,11 @@ export function parseUsernameFromTopic(topic: string): string {
|
|
|
63
63
|
*/
|
|
64
64
|
export function getSubscribeTopic(topic: string): string {
|
|
65
65
|
const username = parseUsernameFromTopic(topic);
|
|
66
|
-
if (username !== "default_name") {
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
if (topic.endsWith("#")) return topic;
|
|
70
|
-
|
|
71
|
-
return `${topic}/#`;
|
|
66
|
+
// if (username !== "default_name") {
|
|
67
|
+
// return `announcement/${username}/#`;
|
|
68
|
+
// }
|
|
69
|
+
// if (topic.endsWith("#")) return topic;
|
|
70
|
+
return topic;
|
|
72
71
|
}
|
|
73
72
|
|
|
74
73
|
/**
|