@xiaozhi-pro/openclaw-plugin 1.0.5 → 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.
@@ -1,5 +1,5 @@
1
1
  import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/account-id";
2
- import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";
2
+ import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
3
3
  import { XIAOZHI_PRO_WS_URL } from "./types.js";
4
4
  function normalizeAllowFrom(value) {
5
5
  if (!value)
@@ -30,7 +30,7 @@ export function resolveAccount(cfg, accountId) {
30
30
  return {
31
31
  accountId: accountId ?? DEFAULT_ACCOUNT_ID,
32
32
  enabled: raw.enabled !== false,
33
- token: normalizeLowercaseStringOrEmpty(raw.token),
33
+ token: normalizeOptionalString(raw.token) ?? "",
34
34
  dmPolicy: raw.dmPolicy ?? "open",
35
35
  allowedUserIds: normalizeAllowFrom(raw.allowedUserIds ?? raw.allowFrom),
36
36
  };
@@ -9,16 +9,19 @@ export function connectXiaozhiProWs(config) {
9
9
  let ws = null;
10
10
  let reconnectTimer = null;
11
11
  let reconnectAttempts = 0;
12
+ let authFatal = false;
12
13
  const MAX_RECONNECT_DELAY = 30_000;
13
14
  function connect() {
14
- if (abortSignal.aborted)
15
+ if (abortSignal.aborted || authFatal)
15
16
  return;
16
17
  ws = new WebSocket(url);
17
18
  ws.on("open", () => {
18
19
  reconnectAttempts = 0;
19
20
  log?.info?.(`[xiaozhi-pro] WS 已连接: ${url}`);
20
21
  // 发送 auth 消息(和小智Pro服务端协议对齐)
21
- ws.send(JSON.stringify({ type: "auth", token: account.token }));
22
+ const token = account.token;
23
+ log?.info?.(`[xiaozhi-pro] 发送认证: token=${token} (长度=${token.length})`);
24
+ ws.send(JSON.stringify({ type: "auth", token }));
22
25
  });
23
26
  ws.on("message", (raw) => {
24
27
  try {
@@ -29,6 +32,8 @@ export function connectXiaozhiProWs(config) {
29
32
  }
30
33
  if (data.type === "auth_fail") {
31
34
  log?.error?.(`[xiaozhi-pro] 认证失败: ${data.error} - ${data.message}`);
35
+ log?.error?.(`[xiaozhi-pro] 认证失败为不可恢复错误,停止重连。请检查 token 配置后重启服务。`);
36
+ authFatal = true;
32
37
  ws?.close();
33
38
  return;
34
39
  }
@@ -75,7 +80,7 @@ export function connectXiaozhiProWs(config) {
75
80
  activeConnections.set(accountId, ws);
76
81
  }
77
82
  function scheduleReconnect() {
78
- if (abortSignal.aborted)
83
+ if (abortSignal.aborted || authFatal)
79
84
  return;
80
85
  const delay = Math.min(1000 * Math.pow(2, reconnectAttempts), MAX_RECONNECT_DELAY);
81
86
  reconnectAttempts++;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xiaozhi-pro/openclaw-plugin",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "小智Pro (XiaoZhi Pro) channel plugin for OpenClaw via WebSocket",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",