@yeaft/webchat-agent 0.1.303 → 0.1.305

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.
Files changed (2) hide show
  1. package/claude.js +16 -0
  2. package/package.json +1 -1
package/claude.js CHANGED
@@ -351,6 +351,9 @@ async function processClaudeOutput(conversationId, claudeQuery, state) {
351
351
  // 捕获 compact 相关的 system 消息
352
352
  // Claude Code 在 context 不足时会自动 compact
353
353
  if (message.type === 'system') {
354
+ // Debug: log all system messages for compact signal analysis
355
+ console.log(`[${conversationId}] System msg: subtype=${message.subtype}, status=${message.status}, message=${(message.message || '').substring(0, 80)}`);
356
+
354
357
  // 新格式: subtype: 'status', status: 'compacting'
355
358
  if (message.subtype === 'status' && message.status === 'compacting') {
356
359
  state._compacting = true;
@@ -396,6 +399,19 @@ async function processClaudeOutput(conversationId, claudeQuery, state) {
396
399
  message: message.message || 'Context compacted successfully'
397
400
  });
398
401
  }
402
+ // 文本兜底: message.message 包含 compact/compacting 关键词
403
+ if (!state._compacting && typeof message.message === 'string'
404
+ && /compact/i.test(message.message)
405
+ && !/compacted successfully/i.test(message.message)) {
406
+ state._compacting = true;
407
+ console.log(`[${conversationId}] Compact started (text fallback: ${message.message.substring(0, 60)})`);
408
+ ctx.sendToServer({
409
+ type: 'compact_status',
410
+ conversationId,
411
+ status: 'compacting',
412
+ message: message.message
413
+ });
414
+ }
399
415
  }
400
416
 
401
417
  // 过滤 compact 过程中的 system 消息(如 status:null、重新 init)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeaft/webchat-agent",
3
- "version": "0.1.303",
3
+ "version": "0.1.305",
4
4
  "description": "Remote agent for Yeaft WebChat — connects worker machines to the central server",
5
5
  "main": "index.js",
6
6
  "type": "module",