agentgui 1.0.537 → 1.0.538
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
|
@@ -1626,6 +1626,26 @@ class StreamingRenderer {
|
|
|
1626
1626
|
return div;
|
|
1627
1627
|
}
|
|
1628
1628
|
|
|
1629
|
+
/**
|
|
1630
|
+
* Detect if content is a base64-encoded image
|
|
1631
|
+
*/
|
|
1632
|
+
detectBase64Image(content) {
|
|
1633
|
+
if (!content || typeof content !== 'string') return null;
|
|
1634
|
+
const trimmed = content.trim();
|
|
1635
|
+
const signatures = {
|
|
1636
|
+
'png': /^iVBORw0KGgo/,
|
|
1637
|
+
'jpeg': /^\/9j\/4AAQ/,
|
|
1638
|
+
'webp': /^UklGRi/,
|
|
1639
|
+
'gif': /^R0lGODlh/
|
|
1640
|
+
};
|
|
1641
|
+
for (const [type, pattern] of Object.entries(signatures)) {
|
|
1642
|
+
if (pattern.test(trimmed)) {
|
|
1643
|
+
return { type, isBase64: true, data: trimmed };
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
return null;
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1629
1649
|
/**
|
|
1630
1650
|
* Render file read event
|
|
1631
1651
|
*/
|
|
@@ -1651,7 +1671,13 @@ class StreamingRenderer {
|
|
|
1651
1671
|
let html = '';
|
|
1652
1672
|
if (event.path) html += this.renderFilePath(event.path);
|
|
1653
1673
|
if (event.content) {
|
|
1654
|
-
|
|
1674
|
+
const imageInfo = this.detectBase64Image(event.content);
|
|
1675
|
+
if (imageInfo) {
|
|
1676
|
+
const mimeType = imageInfo.type === 'jpeg' ? 'image/jpeg' : `image/${imageInfo.type}`;
|
|
1677
|
+
html += `<div style="padding:0.5rem;display:flex;flex-direction:column;gap:0.5rem"><img src="data:${mimeType};base64,${this.escapeHtml(imageInfo.data)}" style="max-width:100%;max-height:600px;border-radius:0.375rem;border:1px solid #334155" loading="lazy"><div style="font-size:0.7rem;color:#64748b;font-family:'Monaco','Menlo','Ubuntu Mono',monospace;word-break:break-all">${this.escapeHtml(event.path)}</div></div>`;
|
|
1678
|
+
} else {
|
|
1679
|
+
html += `<pre style="background:#1e293b;padding:0.75rem;border-radius:0.375rem;overflow-x:auto;font-family:'Monaco','Menlo','Ubuntu Mono',monospace;font-size:0.75rem;line-height:1.5;color:#e2e8f0;margin:0.5rem 0 0 0"><code class="lazy-hl">${this.escapeHtml(this.truncateContent(event.content, 2000))}</code></pre>`;
|
|
1680
|
+
}
|
|
1655
1681
|
}
|
|
1656
1682
|
body.innerHTML = html;
|
|
1657
1683
|
details.appendChild(body);
|