agentgui 1.0.246 → 1.0.248
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
package/static/js/client.js
CHANGED
|
@@ -516,11 +516,6 @@ class AgentGUIClient {
|
|
|
516
516
|
this._serverProcessingEstimate = 0.7 * this._serverProcessingEstimate + 0.3 * serverTime;
|
|
517
517
|
}
|
|
518
518
|
|
|
519
|
-
// Show stop and inject buttons when streaming starts
|
|
520
|
-
if (this.ui.stopButton) this.ui.stopButton.classList.add('visible');
|
|
521
|
-
if (this.ui.injectButton) this.ui.injectButton.classList.add('visible');
|
|
522
|
-
if (this.ui.sendButton) this.ui.sendButton.style.display = 'none';
|
|
523
|
-
|
|
524
519
|
// If this streaming event is for a different conversation than what we are viewing,
|
|
525
520
|
// just track the state but do not modify the DOM or start polling
|
|
526
521
|
if (this.state.currentConversation?.id !== data.conversationId) {
|
|
@@ -530,6 +525,11 @@ class AgentGUIClient {
|
|
|
530
525
|
return;
|
|
531
526
|
}
|
|
532
527
|
|
|
528
|
+
// Show stop and inject buttons when streaming starts for current conversation
|
|
529
|
+
if (this.ui.stopButton) this.ui.stopButton.classList.add('visible');
|
|
530
|
+
if (this.ui.injectButton) this.ui.injectButton.classList.add('visible');
|
|
531
|
+
if (this.ui.sendButton) this.ui.sendButton.style.display = 'none';
|
|
532
|
+
|
|
533
533
|
this.state.streamingConversations.set(data.conversationId, true);
|
|
534
534
|
this.state.currentSession = {
|
|
535
535
|
id: data.sessionId,
|
|
@@ -598,12 +598,18 @@ class AgentGUIClient {
|
|
|
598
598
|
const bFrag = document.createDocumentFragment();
|
|
599
599
|
sList.forEach(chunk => {
|
|
600
600
|
if (!chunk.block?.type) return;
|
|
601
|
-
const el = this.renderer.renderBlock(chunk.block, chunk, bFrag);
|
|
602
|
-
if (!el) return;
|
|
603
601
|
if (chunk.block.type === 'tool_result') {
|
|
604
602
|
const lastInFrag = bFrag.lastElementChild;
|
|
605
|
-
if (lastInFrag?.classList?.contains('block-tool-use')) {
|
|
603
|
+
if (lastInFrag?.classList?.contains('block-tool-use')) {
|
|
604
|
+
const parentIsOpen = lastInFrag.hasAttribute('open');
|
|
605
|
+
const contextWithParent = { ...chunk, parentIsOpen };
|
|
606
|
+
const el = this.renderer.renderBlock(chunk.block, contextWithParent, bFrag);
|
|
607
|
+
if (el) { lastInFrag.appendChild(el); }
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
606
610
|
}
|
|
611
|
+
const el = this.renderer.renderBlock(chunk.block, chunk, bFrag);
|
|
612
|
+
if (!el) return;
|
|
607
613
|
bFrag.appendChild(el);
|
|
608
614
|
});
|
|
609
615
|
bEl.appendChild(bFrag);
|
|
@@ -1759,14 +1765,20 @@ class AgentGUIClient {
|
|
|
1759
1765
|
if (!streamingEl) return;
|
|
1760
1766
|
const blocksEl = streamingEl.querySelector('.streaming-blocks');
|
|
1761
1767
|
if (!blocksEl) return;
|
|
1762
|
-
const element = this.renderer.renderBlock(chunk.block, chunk, blocksEl);
|
|
1763
|
-
if (!element) { this.scrollToBottom(); return; }
|
|
1764
1768
|
if (chunk.block.type === 'tool_result') {
|
|
1765
1769
|
const matchById = chunk.block.tool_use_id && blocksEl.querySelector(`.block-tool-use[data-tool-use-id="${chunk.block.tool_use_id}"]`);
|
|
1766
1770
|
const lastEl = blocksEl.lastElementChild;
|
|
1767
1771
|
const toolUseEl = matchById || (lastEl?.classList?.contains('block-tool-use') ? lastEl : null);
|
|
1768
|
-
if (toolUseEl) {
|
|
1772
|
+
if (toolUseEl) {
|
|
1773
|
+
const parentIsOpen = toolUseEl.hasAttribute('open');
|
|
1774
|
+
const contextWithParent = { ...chunk, parentIsOpen };
|
|
1775
|
+
const element = this.renderer.renderBlock(chunk.block, contextWithParent, blocksEl);
|
|
1776
|
+
if (element) { toolUseEl.appendChild(element); this.scrollToBottom(); }
|
|
1777
|
+
return;
|
|
1778
|
+
}
|
|
1769
1779
|
}
|
|
1780
|
+
const element = this.renderer.renderBlock(chunk.block, chunk, blocksEl);
|
|
1781
|
+
if (!element) { this.scrollToBottom(); return; }
|
|
1770
1782
|
blocksEl.appendChild(element);
|
|
1771
1783
|
this.scrollToBottom();
|
|
1772
1784
|
}
|
|
@@ -1813,18 +1825,20 @@ class AgentGUIClient {
|
|
|
1813
1825
|
const blocksEl = streamingEl.querySelector('.streaming-blocks');
|
|
1814
1826
|
if (!blocksEl) continue;
|
|
1815
1827
|
for (const chunk of groups[sid]) {
|
|
1816
|
-
const el = this.renderer.renderBlock(chunk.block, chunk, blocksEl);
|
|
1817
|
-
if (!el) { appended = true; continue; }
|
|
1818
1828
|
if (chunk.block.type === 'tool_result') {
|
|
1819
1829
|
const matchById = chunk.block.tool_use_id && blocksEl.querySelector(`.block-tool-use[data-tool-use-id="${chunk.block.tool_use_id}"]`);
|
|
1820
1830
|
const lastEl = blocksEl.lastElementChild;
|
|
1821
1831
|
const toolUseEl = matchById || (lastEl?.classList?.contains('block-tool-use') ? lastEl : null);
|
|
1822
1832
|
if (toolUseEl) {
|
|
1823
|
-
toolUseEl.
|
|
1824
|
-
|
|
1833
|
+
const parentIsOpen = toolUseEl.hasAttribute('open');
|
|
1834
|
+
const contextWithParent = { ...chunk, parentIsOpen };
|
|
1835
|
+
const el = this.renderer.renderBlock(chunk.block, contextWithParent, blocksEl);
|
|
1836
|
+
if (el) { toolUseEl.appendChild(el); appended = true; }
|
|
1825
1837
|
continue;
|
|
1826
1838
|
}
|
|
1827
1839
|
}
|
|
1840
|
+
const el = this.renderer.renderBlock(chunk.block, chunk, blocksEl);
|
|
1841
|
+
if (!el) { appended = true; continue; }
|
|
1828
1842
|
blocksEl.appendChild(el);
|
|
1829
1843
|
appended = true;
|
|
1830
1844
|
}
|
|
@@ -1870,10 +1884,16 @@ class AgentGUIClient {
|
|
|
1870
1884
|
} else if (status.modelsDownloading) {
|
|
1871
1885
|
this._modelDownloadProgress = status.modelsProgress || { downloading: true };
|
|
1872
1886
|
this._modelDownloadInProgress = true;
|
|
1887
|
+
} else {
|
|
1888
|
+
this._modelDownloadProgress = { done: false };
|
|
1889
|
+
this._modelDownloadInProgress = false;
|
|
1873
1890
|
}
|
|
1874
1891
|
this._updateVoiceTabState();
|
|
1875
1892
|
} catch (error) {
|
|
1876
1893
|
console.error('Failed to check speech status:', error);
|
|
1894
|
+
this._modelDownloadProgress = { done: false };
|
|
1895
|
+
this._modelDownloadInProgress = false;
|
|
1896
|
+
this._updateVoiceTabState();
|
|
1877
1897
|
}
|
|
1878
1898
|
}
|
|
1879
1899
|
|
|
@@ -2044,6 +2064,11 @@ class AgentGUIClient {
|
|
|
2044
2064
|
}
|
|
2045
2065
|
}, 500);
|
|
2046
2066
|
}
|
|
2067
|
+
if (window._voiceTabPendingOpen) {
|
|
2068
|
+
window._voiceTabPendingOpen = false;
|
|
2069
|
+
var voiceBtn = document.querySelector('[data-view="voice"]');
|
|
2070
|
+
if (voiceBtn) voiceBtn.click();
|
|
2071
|
+
}
|
|
2047
2072
|
return;
|
|
2048
2073
|
}
|
|
2049
2074
|
|
|
@@ -2368,12 +2393,18 @@ class AgentGUIClient {
|
|
|
2368
2393
|
const blockFrag = document.createDocumentFragment();
|
|
2369
2394
|
sessionChunkList.forEach(chunk => {
|
|
2370
2395
|
if (!chunk.block?.type) return;
|
|
2371
|
-
const element = this.renderer.renderBlock(chunk.block, chunk, blockFrag);
|
|
2372
|
-
if (!element) return;
|
|
2373
2396
|
if (chunk.block.type === 'tool_result') {
|
|
2374
2397
|
const lastInFrag = blockFrag.lastElementChild;
|
|
2375
|
-
if (lastInFrag?.classList?.contains('block-tool-use')) {
|
|
2398
|
+
if (lastInFrag?.classList?.contains('block-tool-use')) {
|
|
2399
|
+
const parentIsOpen = lastInFrag.hasAttribute('open');
|
|
2400
|
+
const contextWithParent = { ...chunk, parentIsOpen };
|
|
2401
|
+
const element = this.renderer.renderBlock(chunk.block, contextWithParent, blockFrag);
|
|
2402
|
+
if (element) { lastInFrag.appendChild(element); }
|
|
2403
|
+
return;
|
|
2404
|
+
}
|
|
2376
2405
|
}
|
|
2406
|
+
const element = this.renderer.renderBlock(chunk.block, chunk, blockFrag);
|
|
2407
|
+
if (!element) return;
|
|
2377
2408
|
blockFrag.appendChild(element);
|
|
2378
2409
|
});
|
|
2379
2410
|
blocksEl.appendChild(blockFrag);
|
package/static/js/features.js
CHANGED
|
@@ -189,7 +189,7 @@
|
|
|
189
189
|
btn.addEventListener('click', function() {
|
|
190
190
|
var view = btn.dataset.view;
|
|
191
191
|
if (view === 'voice' && !isVoiceReady()) {
|
|
192
|
-
|
|
192
|
+
triggerVoiceModelDownload();
|
|
193
193
|
return;
|
|
194
194
|
}
|
|
195
195
|
switchView(view);
|
|
@@ -198,11 +198,35 @@
|
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
function isVoiceReady() {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
201
|
+
var client = window.agentGUIClient;
|
|
202
|
+
if (!client) return false;
|
|
203
|
+
if (client._modelDownloadInProgress) return false;
|
|
204
|
+
var p = client._modelDownloadProgress;
|
|
205
|
+
return p != null && (p.done === true || p.complete === true);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function triggerVoiceModelDownload() {
|
|
209
|
+
var client = window.agentGUIClient;
|
|
210
|
+
if (client && client._modelDownloadInProgress) {
|
|
211
|
+
showToast('Voice models downloading... please wait', 'info');
|
|
212
|
+
return;
|
|
204
213
|
}
|
|
205
|
-
|
|
214
|
+
showToast('Starting voice model download...', 'info');
|
|
215
|
+
fetch((window.__BASE_URL || '') + '/api/speech-status', {
|
|
216
|
+
method: 'POST',
|
|
217
|
+
headers: { 'Content-Type': 'application/json' },
|
|
218
|
+
body: JSON.stringify({ forceDownload: true })
|
|
219
|
+
}).then(function(res) { return res.json(); })
|
|
220
|
+
.then(function(data) {
|
|
221
|
+
if (data.ok) {
|
|
222
|
+
showToast('Downloading voice models... will auto-open when ready', 'info');
|
|
223
|
+
window._voiceTabPendingOpen = true;
|
|
224
|
+
} else {
|
|
225
|
+
showToast('Failed to start download: ' + (data.error || 'unknown'), 'error');
|
|
226
|
+
}
|
|
227
|
+
}).catch(function(err) {
|
|
228
|
+
showToast('Download request failed: ' + err.message, 'error');
|
|
229
|
+
});
|
|
206
230
|
}
|
|
207
231
|
|
|
208
232
|
window.__checkVoiceReady = isVoiceReady;
|
|
@@ -1216,6 +1216,7 @@ class StreamingRenderer {
|
|
|
1216
1216
|
const isError = block.is_error || false;
|
|
1217
1217
|
const content = block.content || '';
|
|
1218
1218
|
const contentStr = typeof content === 'string' ? content : JSON.stringify(content, null, 2);
|
|
1219
|
+
const parentIsOpen = context.parentIsOpen !== undefined ? context.parentIsOpen : true;
|
|
1219
1220
|
|
|
1220
1221
|
const wrapper = document.createElement('div');
|
|
1221
1222
|
wrapper.className = 'tool-result-inline' + (isError ? ' tool-result-error' : '');
|
|
@@ -1240,6 +1241,9 @@ class StreamingRenderer {
|
|
|
1240
1241
|
const renderedContent = StreamingRenderer.renderSmartContentHTML(contentStr, this.escapeHtml.bind(this));
|
|
1241
1242
|
const body = document.createElement('div');
|
|
1242
1243
|
body.className = 'folded-tool-body';
|
|
1244
|
+
if (!parentIsOpen) {
|
|
1245
|
+
body.style.display = 'none';
|
|
1246
|
+
}
|
|
1243
1247
|
body.innerHTML = renderedContent;
|
|
1244
1248
|
wrapper.appendChild(body);
|
|
1245
1249
|
|
|
@@ -1479,12 +1483,14 @@ class StreamingRenderer {
|
|
|
1479
1483
|
div.className = 'folded-tool folded-tool-error block-premature';
|
|
1480
1484
|
div.style.borderLeft = `3px solid var(--block-color-${this._getBlockColorIndex('premature')})`;
|
|
1481
1485
|
const code = block.exitCode != null ? ` (exit ${block.exitCode})` : '';
|
|
1486
|
+
const stderrDisplay = block.stderrText ? `<div class="folded-tool-content" style="margin-top:8px;padding:8px;background:rgba(0,0,0,0.05);border-radius:4px;font-family:monospace;font-size:0.9em;white-space:pre-wrap;">${this.escapeHtml(block.stderrText)}</div>` : '';
|
|
1482
1487
|
div.innerHTML = `
|
|
1483
1488
|
<div class="folded-tool-bar" style="background:rgba(245,158,11,0.1)">
|
|
1484
1489
|
<span class="folded-tool-icon" style="color:#f59e0b"><svg viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z" clip-rule="evenodd"/></svg></span>
|
|
1485
1490
|
<span class="folded-tool-name" style="color:#f59e0b">ACP Ended Prematurely${this.escapeHtml(code)}</span>
|
|
1486
1491
|
<span class="folded-tool-desc">${this.escapeHtml(block.error || 'Process exited without output')}</span>
|
|
1487
1492
|
</div>
|
|
1493
|
+
${stderrDisplay}
|
|
1488
1494
|
`;
|
|
1489
1495
|
return div;
|
|
1490
1496
|
}
|