agentgui 1.0.480 → 1.0.482
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 +1 -1
- package/server.js +4 -0
- package/static/js/voice.js +35 -12
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -3406,6 +3406,7 @@ async function processMessageWithStreaming(conversationId, messageId, sessionId,
|
|
|
3406
3406
|
sessionId,
|
|
3407
3407
|
conversationId,
|
|
3408
3408
|
block: systemBlock,
|
|
3409
|
+
blockRole: 'system',
|
|
3409
3410
|
blockIndex: allBlocks.length,
|
|
3410
3411
|
seq: currentSequence,
|
|
3411
3412
|
timestamp: Date.now()
|
|
@@ -3422,6 +3423,7 @@ async function processMessageWithStreaming(conversationId, messageId, sessionId,
|
|
|
3422
3423
|
sessionId,
|
|
3423
3424
|
conversationId,
|
|
3424
3425
|
block,
|
|
3426
|
+
blockRole: 'assistant',
|
|
3425
3427
|
blockIndex: allBlocks.length - 1,
|
|
3426
3428
|
seq: currentSequence,
|
|
3427
3429
|
timestamp: Date.now()
|
|
@@ -3525,6 +3527,7 @@ async function processMessageWithStreaming(conversationId, messageId, sessionId,
|
|
|
3525
3527
|
sessionId,
|
|
3526
3528
|
conversationId,
|
|
3527
3529
|
block: toolResultBlock,
|
|
3530
|
+
blockRole: 'tool_result',
|
|
3528
3531
|
blockIndex: allBlocks.length,
|
|
3529
3532
|
seq: currentSequence,
|
|
3530
3533
|
timestamp: Date.now()
|
|
@@ -3550,6 +3553,7 @@ async function processMessageWithStreaming(conversationId, messageId, sessionId,
|
|
|
3550
3553
|
sessionId,
|
|
3551
3554
|
conversationId,
|
|
3552
3555
|
block: resultBlock,
|
|
3556
|
+
blockRole: 'result',
|
|
3553
3557
|
blockIndex: allBlocks.length,
|
|
3554
3558
|
isResult: true,
|
|
3555
3559
|
seq: currentSequence,
|
package/static/js/voice.js
CHANGED
|
@@ -117,26 +117,41 @@
|
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
function
|
|
120
|
+
function syncVoiceSelectorWithRetry(maxRetries) {
|
|
121
|
+
maxRetries = maxRetries || 20;
|
|
121
122
|
var voiceSelector = document.querySelector('[data-voice-agent-selector]');
|
|
122
123
|
var mainSelector = document.querySelector('[data-agent-selector]');
|
|
123
124
|
if (!voiceSelector || !mainSelector) return;
|
|
125
|
+
if (mainSelector.innerHTML.trim() === '' && maxRetries > 0) {
|
|
126
|
+
setTimeout(function() { syncVoiceSelectorWithRetry(maxRetries - 1); }, 250);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
124
129
|
voiceSelector.innerHTML = mainSelector.innerHTML;
|
|
125
130
|
if (mainSelector.value) voiceSelector.value = mainSelector.value;
|
|
126
131
|
}
|
|
127
132
|
|
|
128
|
-
function
|
|
133
|
+
function syncVoiceCliSelectorWithRetry(maxRetries) {
|
|
134
|
+
maxRetries = maxRetries || 20;
|
|
129
135
|
var voiceCliSelector = document.querySelector('[data-voice-cli-selector]');
|
|
130
136
|
var mainCliSelector = document.querySelector('[data-cli-selector]');
|
|
131
137
|
if (!voiceCliSelector || !mainCliSelector) return;
|
|
138
|
+
if (mainCliSelector.innerHTML.trim() === '' && maxRetries > 0) {
|
|
139
|
+
setTimeout(function() { syncVoiceCliSelectorWithRetry(maxRetries - 1); }, 250);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
132
142
|
voiceCliSelector.innerHTML = mainCliSelector.innerHTML;
|
|
133
143
|
if (mainCliSelector.value) voiceCliSelector.value = mainCliSelector.value;
|
|
134
144
|
}
|
|
135
145
|
|
|
136
|
-
function
|
|
146
|
+
function syncVoiceModelSelectorWithRetry(maxRetries) {
|
|
147
|
+
maxRetries = maxRetries || 20;
|
|
137
148
|
var voiceModelSelector = document.querySelector('[data-voice-model-selector]');
|
|
138
149
|
var mainModelSelector = document.querySelector('[data-model-selector]');
|
|
139
150
|
if (!voiceModelSelector || !mainModelSelector) return;
|
|
151
|
+
if (mainModelSelector.innerHTML.trim() === '' && maxRetries > 0) {
|
|
152
|
+
setTimeout(function() { syncVoiceModelSelectorWithRetry(maxRetries - 1); }, 250);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
140
155
|
voiceModelSelector.innerHTML = mainModelSelector.innerHTML;
|
|
141
156
|
if (mainModelSelector.value) voiceModelSelector.value = mainModelSelector.value;
|
|
142
157
|
}
|
|
@@ -146,7 +161,9 @@
|
|
|
146
161
|
if (!voiceSelector) return;
|
|
147
162
|
var mainSelector = document.querySelector('[data-agent-selector]');
|
|
148
163
|
if (mainSelector) {
|
|
149
|
-
|
|
164
|
+
syncVoiceSelectorWithRetry();
|
|
165
|
+
var observer = new MutationObserver(syncVoiceSelectorWithRetry);
|
|
166
|
+
observer.observe(mainSelector, { childList: true, subtree: true });
|
|
150
167
|
mainSelector.addEventListener('change', function() {
|
|
151
168
|
voiceSelector.value = mainSelector.value;
|
|
152
169
|
});
|
|
@@ -154,11 +171,13 @@
|
|
|
154
171
|
mainSelector.value = voiceSelector.value;
|
|
155
172
|
});
|
|
156
173
|
}
|
|
157
|
-
window.addEventListener('agents-loaded',
|
|
174
|
+
window.addEventListener('agents-loaded', syncVoiceSelectorWithRetry);
|
|
158
175
|
|
|
159
176
|
var mainCliSelector = document.querySelector('[data-cli-selector]');
|
|
160
177
|
if (mainCliSelector) {
|
|
161
|
-
|
|
178
|
+
syncVoiceCliSelectorWithRetry();
|
|
179
|
+
var cliObserver = new MutationObserver(syncVoiceCliSelectorWithRetry);
|
|
180
|
+
cliObserver.observe(mainCliSelector, { childList: true, subtree: true });
|
|
162
181
|
mainCliSelector.addEventListener('change', function() {
|
|
163
182
|
var voiceCliSelector = document.querySelector('[data-voice-cli-selector]');
|
|
164
183
|
if (voiceCliSelector) voiceCliSelector.value = mainCliSelector.value;
|
|
@@ -173,7 +192,9 @@
|
|
|
173
192
|
|
|
174
193
|
var mainModelSelector = document.querySelector('[data-model-selector]');
|
|
175
194
|
if (mainModelSelector) {
|
|
176
|
-
|
|
195
|
+
syncVoiceModelSelectorWithRetry();
|
|
196
|
+
var modelObserver = new MutationObserver(syncVoiceModelSelectorWithRetry);
|
|
197
|
+
modelObserver.observe(mainModelSelector, { childList: true, subtree: true });
|
|
177
198
|
mainModelSelector.addEventListener('change', function() {
|
|
178
199
|
var voiceModelSelector = document.querySelector('[data-voice-model-selector]');
|
|
179
200
|
if (voiceModelSelector) voiceModelSelector.value = mainModelSelector.value;
|
|
@@ -746,7 +767,7 @@
|
|
|
746
767
|
if (data.conversationId && data.conversationId !== currentConversationId) return;
|
|
747
768
|
if (data.seq !== undefined && renderedSeqs.has(data.seq)) return;
|
|
748
769
|
if (data.seq !== undefined) renderedSeqs.add(data.seq);
|
|
749
|
-
handleVoiceBlock(data.block, true);
|
|
770
|
+
handleVoiceBlock(data.block, true, data.blockRole);
|
|
750
771
|
}
|
|
751
772
|
if (data.type === 'streaming_start') {
|
|
752
773
|
if (data.conversationId && data.conversationId !== currentConversationId) return;
|
|
@@ -770,7 +791,7 @@
|
|
|
770
791
|
});
|
|
771
792
|
}
|
|
772
793
|
|
|
773
|
-
function handleVoiceBlock(block, isNew) {
|
|
794
|
+
function handleVoiceBlock(block, isNew, blockRole) {
|
|
774
795
|
if (!block || !block.type) return;
|
|
775
796
|
if (block.type === 'text' && block.text) {
|
|
776
797
|
var now = Date.now();
|
|
@@ -780,8 +801,9 @@
|
|
|
780
801
|
_lastVoiceBlockText = block.text;
|
|
781
802
|
_lastVoiceBlockTime = now;
|
|
782
803
|
|
|
783
|
-
var
|
|
784
|
-
|
|
804
|
+
var isUser = blockRole === 'user' || blockRole === 'tool_result';
|
|
805
|
+
var div = addVoiceBlock(block.text, isUser);
|
|
806
|
+
if (div && isNew && ttsEnabled && blockRole === 'assistant') {
|
|
785
807
|
div.classList.add('speaking');
|
|
786
808
|
speak(block.text);
|
|
787
809
|
setTimeout(function() { div.classList.remove('speaking'); }, 2000);
|
|
@@ -820,7 +842,8 @@
|
|
|
820
842
|
var block = typeof chunk.data === 'string' ? JSON.parse(chunk.data) : chunk.data;
|
|
821
843
|
if (!block) return;
|
|
822
844
|
if (block.type === 'text' && block.text) {
|
|
823
|
-
|
|
845
|
+
var isUser = chunk.type === 'user';
|
|
846
|
+
addVoiceBlock(block.text, isUser);
|
|
824
847
|
hasContent = true;
|
|
825
848
|
} else if (block.type === 'result') {
|
|
826
849
|
_voiceBreakNext = true;
|