@yeaft/webchat-agent 0.1.87 → 0.1.89
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 +3 -1
- package/conversation.js +12 -1
- package/package.json +1 -1
package/claude.js
CHANGED
|
@@ -572,11 +572,13 @@ async function processClaudeOutput(conversationId, claudeQuery, state) {
|
|
|
572
572
|
// ★ Send pending user message after compact completes
|
|
573
573
|
if (state._pendingUserMessage && state.inputStream) {
|
|
574
574
|
const pendingMsg = state._pendingUserMessage;
|
|
575
|
+
const pendingDisplayMsg = state._pendingDisplayMessage || pendingMsg;
|
|
575
576
|
state._pendingUserMessage = null;
|
|
577
|
+
state._pendingDisplayMessage = null;
|
|
576
578
|
console.log(`[${conversationId}] Sending pending message after compact`);
|
|
577
579
|
state.turnActive = true;
|
|
578
580
|
state.turnResultReceived = false;
|
|
579
|
-
sendOutput(conversationId,
|
|
581
|
+
sendOutput(conversationId, pendingDisplayMsg);
|
|
580
582
|
state.inputStream.enqueue(pendingMsg);
|
|
581
583
|
sendConversationList();
|
|
582
584
|
}
|
package/conversation.js
CHANGED
|
@@ -607,6 +607,9 @@ export async function handleUserInput(msg) {
|
|
|
607
607
|
console.log(`[RolePlay] Human responded, resuming from ${fromRole}'s request`);
|
|
608
608
|
}
|
|
609
609
|
|
|
610
|
+
// ★ Save displayPrompt before rolePrefix injection (preserves waitingHuman prefix but excludes ROLE signal)
|
|
611
|
+
const displayPrompt = effectivePrompt;
|
|
612
|
+
|
|
610
613
|
// ★ RolePlay: handle @mention targetRole routing
|
|
611
614
|
const targetRole = msg.targetRole;
|
|
612
615
|
if (targetRole && rpSession && rpSession._routeInitialized) {
|
|
@@ -654,10 +657,17 @@ export async function handleUserInput(msg) {
|
|
|
654
657
|
}
|
|
655
658
|
}
|
|
656
659
|
|
|
660
|
+
// ★ Separate display message (shown to user) from Claude message (sent to model)
|
|
661
|
+
// displayPrompt: user's original text + waitingHuman prefix (no ROLE signal)
|
|
662
|
+
// effectivePrompt: may include ROLE signal prefix for @mention routing
|
|
657
663
|
const userMessage = {
|
|
658
664
|
type: 'user',
|
|
659
665
|
message: { role: 'user', content: effectivePrompt }
|
|
660
666
|
};
|
|
667
|
+
const displayMessage = {
|
|
668
|
+
type: 'user',
|
|
669
|
+
message: { role: 'user', content: displayPrompt }
|
|
670
|
+
};
|
|
661
671
|
|
|
662
672
|
console.log(`[${conversationId}] Sending: ${prompt.substring(0, 100)}...`);
|
|
663
673
|
|
|
@@ -678,6 +688,7 @@ export async function handleUserInput(msg) {
|
|
|
678
688
|
// Send /compact first, then the user message will be sent after compact completes
|
|
679
689
|
// by storing it as a pending message
|
|
680
690
|
state._pendingUserMessage = userMessage;
|
|
691
|
+
state._pendingDisplayMessage = displayMessage;
|
|
681
692
|
state.turnActive = true;
|
|
682
693
|
state.turnResultReceived = false;
|
|
683
694
|
sendConversationList();
|
|
@@ -691,7 +702,7 @@ export async function handleUserInput(msg) {
|
|
|
691
702
|
state.turnActive = true;
|
|
692
703
|
state.turnResultReceived = false; // 重置 per-turn 去重标志
|
|
693
704
|
sendConversationList(); // 在 turnActive=true 后通知 server,确保 processing 状态正确
|
|
694
|
-
sendOutput(conversationId,
|
|
705
|
+
sendOutput(conversationId, displayMessage);
|
|
695
706
|
state.inputStream.enqueue(userMessage);
|
|
696
707
|
}
|
|
697
708
|
|