rol-websocket-channel 1.8.6 → 1.8.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/dist/index.js CHANGED
@@ -400,7 +400,7 @@ const WebSocketChannel = {
400
400
  if (targetTopic.endsWith("#")) {
401
401
  targetTopic = targetTopic.slice(0, -1) + "bot";
402
402
  }
403
- conn.ws.publish(targetTopic, replyMessage, { retain: true });
403
+ conn.ws.publish(targetTopic, replyMessage, { retain: false });
404
404
  return {
405
405
  content: [{ type: "text", text: JSON.stringify({ ok: true }) }],
406
406
  details: {},
@@ -573,6 +573,7 @@ async function handleIncomingMessage(payload, account, cfg, runtime, log, mqttTo
573
573
  });
574
574
  // 用户传参覆盖自动路由结果
575
575
  const resolvedAccountId = targetAgentId ?? route.accountId;
576
+ //
576
577
  const resolvedSessionKey = targetSessionId ?? route.sessionKey;
577
578
  // 缓存最新请求上下文(双键:sessionKey 和 senderId)
578
579
  sessionContextMap.set(resolvedSessionKey, { traceId, agentId: resolvedAccountId });
@@ -624,7 +625,7 @@ async function handleIncomingMessage(payload, account, cfg, runtime, log, mqttTo
624
625
  targetTopic = targetTopic.slice(0, -1) + 'app';
625
626
  }
626
627
  targetTopic = targetTopic.replace('device', 'app').replace('bot', 'app');
627
- conn.ws.publish(targetTopic, JSON.stringify(replyMessage), { retain: true });
628
+ conn.ws.publish(targetTopic, JSON.stringify(replyMessage), { retain: false });
628
629
  },
629
630
  onError: (err) => {
630
631
  log?.error(`[rol-websocket-channel] Delivery error: ${err.message} ${err.stack}`);
@@ -649,7 +650,7 @@ async function handleIncomingMessage(payload, account, cfg, runtime, log, mqttTo
649
650
  log?.error(`[rol-websocket-channel] Failed to process message: ${err instanceof Error ? err.message : String(err)}`);
650
651
  }
651
652
  }
652
- const immediateAckMessageTypes = new Set(["pluginSelfUpdate"]);
653
+ const immediateAckMessageTypes = new Set(["pluginSelfUpdate", "expertsSync"]);
653
654
  export async function handleCustomMessageType(msgType, innerData, traceId, accountId, mqttTopic) {
654
655
  const isSkillInstallFlow = msgType === "skillsInstallFromClawHub" || msgType === "skillsUpdateFromClawHub";
655
656
  const response = {
@@ -768,7 +769,7 @@ function publishCustomMessageResponse(response, innerData, mqttTopic) {
768
769
  targetTopic = targetTopic.slice(0, -1) + 'app';
769
770
  }
770
771
  targetTopic = targetTopic.replace('device', 'app').replace('bot', 'app');
771
- conn.ws.publish(targetTopic, JSON.stringify(response), { retain: true });
772
+ conn.ws.publish(targetTopic, JSON.stringify(response), { retain: false });
772
773
  }
773
774
  }
774
775
  // ============================================
@@ -16,6 +16,7 @@ import { getUsagePageSummary, getUsageTimeseries, getUsageBreakdown, getUsageSum
16
16
  import { listInstalledSkills, installSkillFromNpm, searchClawHubSkills, installSkillFromClawHub, updateSkillFromClawHub } from './src/admin/methods/skills.js';
17
17
  import { uninstallSkill } from './src/admin/methods/skills-extended.js';
18
18
  import { toggleSkill } from './src/admin/methods/skills-toggle.js';
19
+ import { syncExperts } from './src/admin/methods/experts.js';
19
20
  import { listMemoryFiles, getMemoryFile, backupMemory, exportMemoryZip, getMemoryPresignedPost, createMemoryBackupRecord, importMemoryZip, } from './src/admin/methods/memory.js';
20
21
  import { getMem9Config, installMem9, reconnectMem9 } from './src/admin/methods/mem9.js';
21
22
  import { currentVersion, doctorFix, logs, pluginSelfUpdate, restart, stop } from './src/admin/methods/system.js';
@@ -331,6 +332,12 @@ export class MessageHandler {
331
332
  return await toggleSkill(data, context);
332
333
  });
333
334
  }
335
+ async expertsSync(data) {
336
+ return wrapAdminCall(async () => {
337
+ const context = getContext();
338
+ return await syncExperts(data, context);
339
+ });
340
+ }
334
341
  /**
335
342
  * 列出 memory 文件
336
343
  */
@@ -2,7 +2,8 @@ import fs from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  export async function readJsonFile(filePath) {
4
4
  const raw = await fs.readFile(filePath, 'utf8');
5
- return JSON.parse(raw);
5
+ const json = raw.charCodeAt(0) === 0xfeff ? raw.slice(1) : raw;
6
+ return JSON.parse(json);
6
7
  }
7
8
  export async function writeJsonFile(filePath, data) {
8
9
  const json = JSON.stringify(data, null, 2);