agentgui 1.0.245 → 1.0.247
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 +5 -3
- package/static/js/client.js +33 -13
- package/static/js/streaming-renderer.js +6 -0
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -51,8 +51,10 @@ async function ensureModelsDownloaded() {
|
|
|
51
51
|
try {
|
|
52
52
|
const { createRequire: cr } = await import('module');
|
|
53
53
|
const r = cr(import.meta.url);
|
|
54
|
-
|
|
55
|
-
const
|
|
54
|
+
|
|
55
|
+
const gmguiModels = path.join(os.homedir(), '.gmgui', 'models');
|
|
56
|
+
const sttDir = path.join(gmguiModels, 'onnx-community', 'whisper-base');
|
|
57
|
+
const ttsDir = path.join(gmguiModels, 'tts');
|
|
56
58
|
|
|
57
59
|
const sttOk = fs.existsSync(sttDir) && fs.readdirSync(sttDir).length > 0;
|
|
58
60
|
const ttsOk = fs.existsSync(ttsDir) && fs.readdirSync(ttsDir).length > 0;
|
|
@@ -70,7 +72,7 @@ async function ensureModelsDownloaded() {
|
|
|
70
72
|
const webtalkTTS = r('webtalk/tts-models');
|
|
71
73
|
const { createConfig } = r('webtalk/config');
|
|
72
74
|
const config = createConfig({ sdkDir: path.dirname(fileURLToPath(import.meta.url)) });
|
|
73
|
-
config.modelsDir =
|
|
75
|
+
config.modelsDir = gmguiModels;
|
|
74
76
|
config.ttsModelsDir = ttsDir;
|
|
75
77
|
config.sttModelsDir = sttDir;
|
|
76
78
|
config.whisperBaseUrl = 'https://huggingface.co/';
|
package/static/js/client.js
CHANGED
|
@@ -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
|
}
|
|
@@ -2368,12 +2382,18 @@ class AgentGUIClient {
|
|
|
2368
2382
|
const blockFrag = document.createDocumentFragment();
|
|
2369
2383
|
sessionChunkList.forEach(chunk => {
|
|
2370
2384
|
if (!chunk.block?.type) return;
|
|
2371
|
-
const element = this.renderer.renderBlock(chunk.block, chunk, blockFrag);
|
|
2372
|
-
if (!element) return;
|
|
2373
2385
|
if (chunk.block.type === 'tool_result') {
|
|
2374
2386
|
const lastInFrag = blockFrag.lastElementChild;
|
|
2375
|
-
if (lastInFrag?.classList?.contains('block-tool-use')) {
|
|
2387
|
+
if (lastInFrag?.classList?.contains('block-tool-use')) {
|
|
2388
|
+
const parentIsOpen = lastInFrag.hasAttribute('open');
|
|
2389
|
+
const contextWithParent = { ...chunk, parentIsOpen };
|
|
2390
|
+
const element = this.renderer.renderBlock(chunk.block, contextWithParent, blockFrag);
|
|
2391
|
+
if (element) { lastInFrag.appendChild(element); }
|
|
2392
|
+
return;
|
|
2393
|
+
}
|
|
2376
2394
|
}
|
|
2395
|
+
const element = this.renderer.renderBlock(chunk.block, chunk, blockFrag);
|
|
2396
|
+
if (!element) return;
|
|
2377
2397
|
blockFrag.appendChild(element);
|
|
2378
2398
|
});
|
|
2379
2399
|
blocksEl.appendChild(blockFrag);
|
|
@@ -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
|
}
|