rol-websocket-channel 1.0.7 → 1.0.8

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,6 +1,6 @@
1
1
  {
2
2
  "name": "rol-websocket-channel",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "Unified OpenClaw plugin: MQTT Channel + Admin Bridge for remote management",
5
5
  "license": "MIT",
6
6
  "author": "nixgnehc",
@@ -9,7 +9,7 @@ import type { JsonValue, MethodContext } from '../types.ts';
9
9
  const execFileAsync = promisify(execFile);
10
10
 
11
11
  const DEFAULT_PLUGIN_ID = 'rol-websocket-channel';
12
- const DEFAULT_PAIR_ENDPOINT = 'http://api.deotaland.local/api-core-bot/front/agent/agent/key/query';
12
+ const DEFAULT_PRODUCTION_BASE_URL = 'https://api.deotaland.ai';
13
13
  const GATEWAY_SERVICE = 'openclaw-gateway.service';
14
14
 
15
15
  interface PairingCommandOptions {
@@ -106,8 +106,7 @@ async function exchangePairKey(
106
106
  authOverride?: string,
107
107
  existingMqttUrl?: string | null
108
108
  ): Promise<PairingPayload> {
109
- const endpoint = pickString(endpointOverride)
110
- ?? DEFAULT_PAIR_ENDPOINT;
109
+ const endpoint = buildPairEndpoint(endpointOverride);
111
110
  const auth = pickString(authOverride);
112
111
 
113
112
  const headers: Record<string, string> = {
@@ -151,8 +150,6 @@ function normalizePairingPayload(
151
150
  const apiCoreBotValue = isRecord(root.apiCoreBot) ? root.apiCoreBot : {};
152
151
  const channelValue = isRecord(root.channel) ? root.channel : {};
153
152
 
154
- const apiCoreBotBaseUrl = pickString(apiCoreBotValue.baseUrl)
155
- ?? deriveBaseUrl(endpoint);
156
153
  const apiCoreBotAuthToken = pickString(apiCoreBotValue.authToken)
157
154
  ?? pickString(root.authToken)
158
155
  ?? pickString(root.token);
@@ -185,7 +182,6 @@ function normalizePairingPayload(
185
182
  ...(rawValue ? { rawValue } : {})
186
183
  },
187
184
  apiCoreBot: {
188
- baseUrl: apiCoreBotBaseUrl,
189
185
  ...(apiCoreBotAuthToken ? { authToken: apiCoreBotAuthToken } : {})
190
186
  },
191
187
  channel: {
@@ -225,7 +221,7 @@ function applyPairingConfig(config: OpenClawConfig, key: string, payload: Pairin
225
221
  },
226
222
  apiCoreBot: {
227
223
  ...(isRecord(existingPluginConfig.apiCoreBot) ? existingPluginConfig.apiCoreBot : {}),
228
- ...payload.apiCoreBot
224
+ ...(payload.apiCoreBot.authToken ? { authToken: payload.apiCoreBot.authToken } : {})
229
225
  }
230
226
  }
231
227
  };
@@ -276,10 +272,14 @@ function tryParseJson(raw: string): unknown {
276
272
  }
277
273
  }
278
274
 
279
- function deriveBaseUrl(endpoint: string): string {
280
- const marker = '/front/';
281
- const markerIndex = endpoint.indexOf(marker);
282
- return markerIndex >= 0 ? endpoint.slice(0, markerIndex) : endpoint.replace(/\/+$/, '');
275
+ function buildPairEndpoint(endpointOverride?: string): string {
276
+ const override = pickString(endpointOverride);
277
+ if (override) {
278
+ return override;
279
+ }
280
+
281
+ const baseUrl = getDeotalandApiBaseUrl();
282
+ return `${baseUrl}/api-core-bot/front/agent/agent/key/query`;
283
283
  }
284
284
 
285
285
  function resolveExistingMqttUrl(config: OpenClawConfig): string | null {
@@ -325,6 +325,11 @@ function pickString(value: unknown): string | null {
325
325
  return trimmed.length > 0 ? trimmed : null;
326
326
  }
327
327
 
328
+ function getDeotalandApiBaseUrl(): string {
329
+ const configured = pickString(process.env.DEOTALAND_API_BASE_URL);
330
+ return (configured ?? DEFAULT_PRODUCTION_BASE_URL).replace(/\/+$/, '');
331
+ }
332
+
328
333
  function isRecord(value: unknown): value is Record<string, any> {
329
334
  return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
330
335
  }