claw-subagent-service 0.0.70 → 0.0.71

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.70",
3
+ "version": "0.0.71",
4
4
  "description": "虾说智能助手",
5
5
  "main": "cli.js",
6
6
  "bin": {
@@ -234,19 +234,21 @@ class MessageHandler {
234
234
  buffer += delta;
235
235
  seq += 1;
236
236
  this.log?.info(`[MessageHandler] onDelta: seq=${seq}, delta_len=${delta.length}, buffer_len=${buffer.length}`);
237
- await this._sendStreamChunk(fromUserId, targetId, conversationType, buffer, streamId, seq === 1, false, seq);
237
+ // 发送增量(delta),让前端做增量拼接,避免内容重复
238
+ await this._sendStreamChunk(fromUserId, targetId, conversationType, delta, streamId, seq === 1, false, seq);
238
239
  hasSentChunk = true;
239
240
  },
240
241
  async (fullText) => {
241
242
  this.log?.info(`[MessageHandler] onDone 触发, fullText.length=${fullText.length}, buffer.length=${buffer.length}, hasSentChunk=${hasSentChunk}`);
242
243
  if (buffer.trim()) {
244
+ // 发送尾流:空字符串表示流结束,前端保留已拼接的完整内容
243
245
  seq += 1;
244
- await this._sendStreamChunk(fromUserId, targetId, conversationType, buffer, streamId, seq === 1, true, seq);
246
+ await this._sendStreamChunk(fromUserId, targetId, conversationType, '', streamId, false, true, seq);
245
247
  hasSentChunk = true;
246
248
  } else if (hasSentChunk) {
247
249
  // 已经发送过内容,单独发送结束标记
248
250
  seq += 1;
249
- await this._sendStreamChunk(fromUserId, targetId, conversationType, buffer, streamId, false, true, seq);
251
+ await this._sendStreamChunk(fromUserId, targetId, conversationType, '', streamId, false, true, seq);
250
252
  } else {
251
253
  // 完全没有收到内容,发送错误提示
252
254
  await this._sendStreamChunk(fromUserId, targetId, conversationType, '抱歉,AI 暂时没有回复内容。', streamId, true, true, 1);