claw-subagent-service 0.0.154 → 0.0.156
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
|
@@ -176,7 +176,22 @@ class RongyunMessageSender {
|
|
|
176
176
|
|
|
177
177
|
// 优先使用自定义消息类型发送 P2P 消息
|
|
178
178
|
let result;
|
|
179
|
-
if (this.rongcloudClient.
|
|
179
|
+
if (this.rongcloudClient.ServiceChatMessage && msgType.includes('service')) {
|
|
180
|
+
// 客服相关消息使用 service_chat 自定义消息类型
|
|
181
|
+
// 对于客服消息,直接将业务内容放在顶层,方便前端解析
|
|
182
|
+
const serviceChatPayload = {
|
|
183
|
+
msg_type: msgType,
|
|
184
|
+
...content, // 展开业务内容(status, content, sessionId, userId 等)
|
|
185
|
+
request_id: requestId || '',
|
|
186
|
+
timestamp: Math.floor(Date.now() / 1000),
|
|
187
|
+
};
|
|
188
|
+
result = await this.rongcloudClient.sendCustomMessage(
|
|
189
|
+
targetId,
|
|
190
|
+
serviceChatPayload,
|
|
191
|
+
1, // PRIVATE
|
|
192
|
+
'service_chat'
|
|
193
|
+
);
|
|
194
|
+
} else if (this.rongcloudClient.SystemServiceMessage) {
|
|
180
195
|
result = await this.rongcloudClient.sendCustomMessage(
|
|
181
196
|
targetId,
|
|
182
197
|
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]
|
|
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
|
-
|
|
290
|
-
|
|
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
|
|
310
|
+
const customMsg = new MessageCtor(messageContent);
|
|
301
311
|
|
|
302
312
|
const result = await RongIMLib.sendMessage(
|
|
303
313
|
{ conversationType: convType, targetId },
|