@yeaft/webchat-agent 0.1.101 → 0.1.103

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/claude.js CHANGED
@@ -515,8 +515,19 @@ async function processClaudeOutput(conversationId, claudeQuery, state) {
515
515
 
516
516
  console.log(`[RolePlay] Auto-continuing to role: ${to}`);
517
517
 
518
+ // ★ Send roleplay_status with updated currentRole so frontend knows which role is active
519
+ ctx.sendToServer({
520
+ type: 'roleplay_status',
521
+ conversationId,
522
+ currentRole: rpSession.currentRole,
523
+ round: rpSession.round,
524
+ features: rpSession.features ? Array.from(rpSession.features.values()) : [],
525
+ roleStates: rpSession.roleStates || {},
526
+ waitingHuman: false
527
+ });
528
+
518
529
  // ★ Pre-send compact check for RolePlay auto-continue
519
- const rpAutoCompactThreshold = ctx.CONFIG?.autoCompactThreshold || 110000;
530
+ const rpAutoCompactThreshold = ctx.CONFIG?.autoCompactThreshold || 100000;
520
531
  const rpEstimatedNewTokens = Math.ceil(prompt.length / 3);
521
532
  // Include output_tokens: the assistant's output becomes part of context for the next turn
522
533
  const rpOutputTokens = message.usage?.output_tokens || 0;
@@ -627,6 +638,17 @@ async function processClaudeOutput(conversationId, claudeQuery, state) {
627
638
  rpSession.roleStates[prevRole].status = 'idle';
628
639
  }
629
640
  console.log(`[RolePlay] Role switched: ${prevRole || 'none'} -> ${detectedRole}`);
641
+
642
+ // ★ Send roleplay_status so frontend fallbackRole stays in sync
643
+ ctx.sendToServer({
644
+ type: 'roleplay_status',
645
+ conversationId,
646
+ currentRole: rpSession.currentRole,
647
+ round: rpSession.round,
648
+ features: rpSession.features ? Array.from(rpSession.features.values()) : [],
649
+ roleStates: rpSession.roleStates || {},
650
+ waitingHuman: rpSession.waitingHuman || false
651
+ });
630
652
  }
631
653
  }
632
654
  }
package/conversation.js CHANGED
@@ -673,7 +673,7 @@ export async function handleUserInput(msg) {
673
673
  console.log(`[${conversationId}] Sending: ${prompt.substring(0, 100)}...`);
674
674
 
675
675
  // ★ Pre-send compact check: estimate total tokens and compact before sending if needed
676
- const autoCompactThreshold = ctx.CONFIG?.autoCompactThreshold || 110000;
676
+ const autoCompactThreshold = ctx.CONFIG?.autoCompactThreshold || 100000;
677
677
  const lastInputTokens = state.lastResultInputTokens || 0;
678
678
  const lastOutputTokens = state.lastResultOutputTokens || 0;
679
679
  const estimatedNewTokens = Math.ceil(effectivePrompt.length / 3); // conservative: ~3 chars per token
package/crew/routing.js CHANGED
@@ -195,7 +195,7 @@ export async function dispatchToRole(session, roleName, content, fromSource, tas
195
195
  });
196
196
 
197
197
  // ★ Pre-send compact check: estimate total tokens and clear+rebuild if needed
198
- const autoCompactThreshold = ctx.CONFIG?.autoCompactThreshold || 110000;
198
+ const autoCompactThreshold = ctx.CONFIG?.autoCompactThreshold || 100000;
199
199
  const lastInputTokens = roleState.lastInputTokens || 0;
200
200
  const estimatedNewTokens = Math.ceil((typeof content === 'string' ? content.length : 0) / 3);
201
201
  const estimatedTotal = lastInputTokens + estimatedNewTokens;
package/index.js CHANGED
@@ -78,7 +78,7 @@ const CONFIG = {
78
78
  // 最大上下文 tokens(用于百分比计算的分母)
79
79
  maxContextTokens: parseInt(process.env.MAX_CONTEXT_TOKENS || fileConfig.maxContextTokens, 10) || 128000,
80
80
  // Auto-compact 阈值(tokens):context 超过此值时自动触发 compact
81
- autoCompactThreshold: parseInt(process.env.AUTO_COMPACT_THRESHOLD || fileConfig.autoCompactThreshold, 10) || 110000
81
+ autoCompactThreshold: parseInt(process.env.AUTO_COMPACT_THRESHOLD || fileConfig.autoCompactThreshold, 10) || 100000
82
82
  };
83
83
 
84
84
  // 初始化共享上下文
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeaft/webchat-agent",
3
- "version": "0.1.101",
3
+ "version": "0.1.103",
4
4
  "description": "Remote agent for Yeaft WebChat — connects worker machines to the central server",
5
5
  "main": "index.js",
6
6
  "type": "module",