claw-subagent-service 0.0.154 → 0.0.155

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": "claw-subagent-service",
3
- "version": "0.0.154",
3
+ "version": "0.0.155",
4
4
  "description": "虾说智能助手",
5
5
  "main": "cli.js",
6
6
  "bin": {
@@ -176,7 +176,15 @@ class RongyunMessageSender {
176
176
 
177
177
  // 优先使用自定义消息类型发送 P2P 消息
178
178
  let result;
179
- if (this.rongcloudClient.SystemServiceMessage) {
179
+ if (this.rongcloudClient.ServiceChatMessage && msgType.includes('service')) {
180
+ // 客服相关消息使用 service_chat 自定义消息类型
181
+ result = await this.rongcloudClient.sendCustomMessage(
182
+ targetId,
183
+ messagePayload,
184
+ 1, // PRIVATE
185
+ 'service_chat'
186
+ );
187
+ } else if (this.rongcloudClient.SystemServiceMessage) {
180
188
  result = await this.rongcloudClient.sendCustomMessage(
181
189
  targetId,
182
190
  messagePayload,
@@ -44,11 +44,15 @@ class RongCloudClient {
44
44
  if (typeof RongIMLib.registerMessageType === 'function') {
45
45
  this.SystemServiceMessage = RongIMLib.registerMessageType('command', false, false);
46
46
  this.log?.info('[RongCloudClient] command 自定义消息类型已注册');
47
+
48
+ // 注册 service_chat 自定义消息类型(客服消息)
49
+ this.ServiceChatMessage = RongIMLib.registerMessageType('service_chat', false, false);
50
+ this.log?.info('[RongCloudClient] service_chat 自定义消息类型已注册');
47
51
  } else {
48
52
  this.log?.warn('[RongCloudClient] SDK 不支持 registerMessageType');
49
53
  }
50
54
  } catch (err) {
51
- this.log?.warn(`[RongCloudClient] 注册 command 消息类型失败: ${err.message}`);
55
+ this.log?.warn(`[RongCloudClient] 注册自定义消息类型失败: ${err.message}`);
52
56
  }
53
57
 
54
58
  this.log?.info(`[RongCloudClient] SDK Events: ${JSON.stringify(Object.keys(RongIMLib.Events || {}))}`);
@@ -286,8 +290,14 @@ class RongCloudClient {
286
290
  return false;
287
291
  }
288
292
 
289
- if (!this.SystemServiceMessage) {
290
- this.log?.error('[RongCloudClient] command 消息类型未注册');
293
+ // 根据消息类型选择对应的构造函数
294
+ let MessageCtor = this.SystemServiceMessage;
295
+ if (customType === 'service_chat') {
296
+ MessageCtor = this.ServiceChatMessage;
297
+ }
298
+
299
+ if (!MessageCtor) {
300
+ this.log?.error(`[RongCloudClient] ${customType} 消息类型未注册`);
291
301
  return false;
292
302
  }
293
303
 
@@ -297,7 +307,7 @@ class RongCloudClient {
297
307
  : (RongIMLib.ConversationType?.PRIVATE || ConversationType.PRIVATE);
298
308
 
299
309
  const messageContent = typeof content === 'string' ? JSON.parse(content) : content;
300
- const customMsg = new this.SystemServiceMessage(messageContent);
310
+ const customMsg = new MessageCtor(messageContent);
301
311
 
302
312
  const result = await RongIMLib.sendMessage(
303
313
  { conversationType: convType, targetId },