agentgui 1.0.539 → 1.0.541
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/static/js/streaming-renderer.js +19 -82
package/package.json
CHANGED
|
@@ -1671,12 +1671,26 @@ class StreamingRenderer {
|
|
|
1671
1671
|
let html = '';
|
|
1672
1672
|
if (event.path) html += this.renderFilePath(event.path);
|
|
1673
1673
|
if (event.content) {
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1674
|
+
let base64Data = null;
|
|
1675
|
+
let mimeType = event.media_type || 'application/octet-stream';
|
|
1676
|
+
if (typeof event.content === 'string') {
|
|
1677
|
+
const imageInfo = this.detectBase64Image(event.content);
|
|
1678
|
+
if (imageInfo) {
|
|
1679
|
+
base64Data = imageInfo.data;
|
|
1680
|
+
mimeType = imageInfo.type === 'jpeg' ? 'image/jpeg' : `image/${imageInfo.type}`;
|
|
1681
|
+
}
|
|
1682
|
+
} else if (typeof event.content === 'object' && event.content !== null) {
|
|
1683
|
+
if (event.content.source?.type === 'base64' && event.content.source?.data) {
|
|
1684
|
+
base64Data = event.content.source.data;
|
|
1685
|
+
} else if (event.content.type === 'base64' && event.content.data) {
|
|
1686
|
+
base64Data = event.content.data;
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1689
|
+
if (base64Data) {
|
|
1690
|
+
html += `<div style="padding:0.5rem;display:flex;flex-direction:column;gap:0.5rem"><img src="data:${mimeType};base64,${this.escapeHtml(base64Data)}" 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
1691
|
} else {
|
|
1679
|
-
|
|
1692
|
+
const contentStr = typeof event.content === 'string' ? event.content : JSON.stringify(event.content, null, 2);
|
|
1693
|
+
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(contentStr, 2000))}</code></pre>`;
|
|
1680
1694
|
}
|
|
1681
1695
|
}
|
|
1682
1696
|
body.innerHTML = html;
|
|
@@ -1976,84 +1990,7 @@ class StreamingRenderer {
|
|
|
1976
1990
|
return div;
|
|
1977
1991
|
}
|
|
1978
1992
|
|
|
1979
|
-
/**
|
|
1980
|
-
* Render file read event with image detection
|
|
1981
|
-
*/
|
|
1982
|
-
renderFileRead(event) {
|
|
1983
|
-
const div = document.createElement('div');
|
|
1984
|
-
div.className = 'event-file-read mb-3 p-3 rounded border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900';
|
|
1985
|
-
div.dataset.eventId = event.id || '';
|
|
1986
|
-
div.dataset.eventType = 'file_read';
|
|
1987
|
-
|
|
1988
|
-
const filePath = event.path || '';
|
|
1989
|
-
const fileName = pathBasename(filePath);
|
|
1990
|
-
const isImage = this.isImagePath(filePath);
|
|
1991
|
-
|
|
1992
|
-
let html = `
|
|
1993
|
-
<div style="display:flex;align-items:center;gap:0.5rem;margin-bottom:${isImage ? '0.75rem' : '0'}">
|
|
1994
|
-
<svg viewBox="0 0 20 20" fill="currentColor" style="width:1rem;height:1rem;color:var(--color-info)">
|
|
1995
|
-
<path d="M8 16a2 2 0 100-4 2 2 0 000 4zM9 2a1 1 0 011 1v2h2V3a1 1 0 112 0v2h2V3a1 1 0 112 0v2h2a2 2 0 012 2v2h2a1 1 0 110 2h-2v2h2a1 1 0 110 2h-2v2a2 2 0 01-2 2h-2v2a1 1 0 11-2 0v-2h-2v2a1 1 0 11-2 0v-2H9a2 2 0 01-2-2v-2H5a1 1 0 110-2h2V9H5a1 1 0 010-2h2V5H5a1 1 0 010-2h2V3a1 1 0 011-1z"/>
|
|
1996
|
-
</svg>
|
|
1997
|
-
<code style="font-size:0.75rem;color:var(--color-text-primary);font-family:'Monaco','Menlo','Ubuntu Mono',monospace">${this.escapeHtml(filePath)}</code>
|
|
1998
|
-
</div>
|
|
1999
|
-
`;
|
|
2000
|
-
|
|
2001
|
-
if (isImage) {
|
|
2002
|
-
html += `<div style="margin-top:0.75rem" class="lazy-image-container" data-image-path="${this.escapeHtml(filePath)}"></div>`;
|
|
2003
|
-
}
|
|
2004
|
-
|
|
2005
|
-
div.innerHTML = html;
|
|
2006
|
-
|
|
2007
|
-
if (isImage) {
|
|
2008
|
-
const container = div.querySelector('.lazy-image-container');
|
|
2009
|
-
if (container && window.imageLoader) {
|
|
2010
|
-
const imgElement = window.imageLoader.createImageElement(filePath);
|
|
2011
|
-
container.appendChild(imgElement);
|
|
2012
|
-
}
|
|
2013
|
-
}
|
|
2014
|
-
|
|
2015
|
-
return div;
|
|
2016
|
-
}
|
|
2017
1993
|
|
|
2018
|
-
/**
|
|
2019
|
-
* Render file write event
|
|
2020
|
-
*/
|
|
2021
|
-
renderFileWrite(event) {
|
|
2022
|
-
const div = document.createElement('div');
|
|
2023
|
-
div.className = 'event-file-write mb-3 p-3 rounded border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900';
|
|
2024
|
-
div.dataset.eventId = event.id || '';
|
|
2025
|
-
div.dataset.eventType = 'file_write';
|
|
2026
|
-
|
|
2027
|
-
const filePath = event.path || '';
|
|
2028
|
-
const icon = '<svg viewBox="0 0 20 20" fill="currentColor" style="width:1rem;height:1rem;color:var(--color-success)"><path d="M11 3a1 1 0 10-2 0v1a1 1 0 102 0V3zM15.657 5.757a1 1 0 00-1.414-1.414l-.707.707a1 1 0 001.414 1.414l.707-.707zM18 10a1 1 0 01-1 1h-1a1 1 0 110-2h1a1 1 0 011 1zM16.243 15.657a1 1 0 001.414-1.414l-.707-.707a1 1 0 00-1.414 1.414l.707.707zM10 15a1 1 0 01-1-1v-1a1 1 0 112 0v1a1 1 0 01-1 1zM5.757 16.243a1 1 0 01-1.414-1.414l.707-.707a1 1 0 011.414 1.414l-.707.707zM5 10a1 1 0 01-1-1V8a1 1 0 012 0v1a1 1 0 01-1 1zM5.757 5.757a1 1 0 000-1.414l-.707-.707a1 1 0 00-1.414 1.414l.707.707zM10 5a1 1 0 011-1h1a1 1 0 110 2h-1a1 1 0 01-1-1z"/></svg>';
|
|
2029
|
-
|
|
2030
|
-
div.innerHTML = `
|
|
2031
|
-
<div style="display:flex;align-items:center;gap:0.5rem">
|
|
2032
|
-
${icon}
|
|
2033
|
-
<code style="font-size:0.75rem;color:var(--color-text-primary);font-family:'Monaco','Menlo','Ubuntu Mono',monospace">${this.escapeHtml(filePath)}</code>
|
|
2034
|
-
</div>
|
|
2035
|
-
`;
|
|
2036
|
-
|
|
2037
|
-
return div;
|
|
2038
|
-
}
|
|
2039
|
-
|
|
2040
|
-
/**
|
|
2041
|
-
* Check if a path is an image file
|
|
2042
|
-
*/
|
|
2043
|
-
isImagePath(filePath) {
|
|
2044
|
-
if (!filePath || typeof filePath !== 'string') return false;
|
|
2045
|
-
const imageExts = ['png', 'jpg', 'jpeg', 'gif', 'webp', 'svg'];
|
|
2046
|
-
const ext = this.getFileExtension(filePath);
|
|
2047
|
-
return imageExts.includes(ext);
|
|
2048
|
-
}
|
|
2049
|
-
|
|
2050
|
-
/**
|
|
2051
|
-
* Extract file extension
|
|
2052
|
-
*/
|
|
2053
|
-
getFileExtension(filePath) {
|
|
2054
|
-
const match = filePath.match(/\.([^.]+)$/);
|
|
2055
|
-
return match ? match[1].toLowerCase() : '';
|
|
2056
|
-
}
|
|
2057
1994
|
|
|
2058
1995
|
/**
|
|
2059
1996
|
* Render generic event with formatted key-value pairs
|