agentgui 1.0.127 → 1.0.129
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/index.html +2 -0
- package/static/js/streaming-renderer.js +5 -74
package/package.json
CHANGED
package/static/index.html
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
|
|
9
9
|
<link href="https://unpkg.com/rippleui@0.14.0/dist/ripple.css" rel="stylesheet">
|
|
10
10
|
<link href="https://unpkg.com/prism@1.29.0/themes/prism-dark.css" rel="stylesheet">
|
|
11
|
+
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/styles/github-dark.min.css" rel="stylesheet">
|
|
12
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/highlight.min.js"></script>
|
|
11
13
|
|
|
12
14
|
<style>
|
|
13
15
|
*, *::before, *::after { box-sizing: border-box; }
|
|
@@ -991,81 +991,12 @@ class StreamingRenderer {
|
|
|
991
991
|
* Render code with basic syntax highlighting
|
|
992
992
|
*/
|
|
993
993
|
static renderCodeWithHighlight(code, esc) {
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
const isJSON = (code.trim().startsWith('{') || code.trim().startsWith('[')) &&
|
|
999
|
-
code.includes('"') && (code.includes(':') || code.includes(','));
|
|
1000
|
-
|
|
1001
|
-
if (isJSON) {
|
|
1002
|
-
// JSON-specific highlighting
|
|
1003
|
-
const jsonHighlights = [
|
|
1004
|
-
// Property names (keys) in quotes
|
|
1005
|
-
{ pattern: /"([^"]+)"\s*:/g, replacement: '"<span style="color:#3b82f6;font-weight:600">$1</span>":' },
|
|
1006
|
-
// String values
|
|
1007
|
-
{ pattern: /:\s*"([^"]*)"/g, replacement: ': "<span style="color:#10b981">$1</span>"' },
|
|
1008
|
-
// Numbers
|
|
1009
|
-
{ pattern: /:\s*(\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/g, replacement: ': <span style="color:#f59e0b">$1</span>' },
|
|
1010
|
-
// Booleans and null
|
|
1011
|
-
{ pattern: /:\s*(true|false|null)/g, replacement: ': <span style="color:#ef4444">$1</span>' },
|
|
1012
|
-
// Array/object brackets
|
|
1013
|
-
{ pattern: /([\[\]{}])/g, replacement: '<span style="color:#6b7280;font-weight:600">$1</span>' },
|
|
1014
|
-
];
|
|
1015
|
-
|
|
1016
|
-
jsonHighlights.forEach(({ pattern, replacement }) => {
|
|
1017
|
-
highlighted = highlighted.replace(pattern, replacement);
|
|
1018
|
-
});
|
|
1019
|
-
} else {
|
|
1020
|
-
// General code syntax highlighting
|
|
1021
|
-
const highlights = [
|
|
1022
|
-
// Comments (do these first to avoid conflicts)
|
|
1023
|
-
{ pattern: /(\/\/[^\n]*)/g, replacement: '<span style="color:#6b7280;font-style:italic">$1</span>' },
|
|
1024
|
-
{ pattern: /(\/\*[\s\S]*?\*\/)/g, replacement: '<span style="color:#6b7280;font-style:italic">$1</span>' },
|
|
1025
|
-
{ pattern: /(#[^\n]*)/g, replacement: '<span style="color:#6b7280;font-style:italic">$1</span>' },
|
|
1026
|
-
|
|
1027
|
-
// Strings (improved to handle escaped quotes)
|
|
1028
|
-
{ pattern: /(["'])(?:[^\\]|\\.)*?\1/g, replacement: (match) => `<span style="color:#10b981">${match}</span>` },
|
|
1029
|
-
|
|
1030
|
-
// Template literals (backticks)
|
|
1031
|
-
{ pattern: /`([^`]*)`/g, replacement: '<span style="color:#10b981">`$1`</span>' },
|
|
1032
|
-
|
|
1033
|
-
// Keywords
|
|
1034
|
-
{ pattern: /\b(function|const|let|var|class|import|export|async|await|return|if|else|for|while|try|catch|throw|new|typeof|instanceof|this|super|switch|case|default|break|continue|do)\b/g,
|
|
1035
|
-
replacement: '<span style="color:#8b5cf6;font-weight:600">$1</span>' },
|
|
1036
|
-
{ pattern: /\b(def|class|import|from|return|if|elif|else|for|while|try|except|raise|with|as|lambda|pass|break|continue|yield|global|nonlocal)\b/g,
|
|
1037
|
-
replacement: '<span style="color:#8b5cf6;font-weight:600">$1</span>' },
|
|
1038
|
-
{ pattern: /\b(public|private|protected|static|final|abstract|interface|extends|implements|package|void|int|string|boolean|float|double|char)\b/g,
|
|
1039
|
-
replacement: '<span style="color:#8b5cf6;font-weight:600">$1</span>' },
|
|
1040
|
-
|
|
1041
|
-
// Type annotations
|
|
1042
|
-
{ pattern: /:\s*([A-Z][a-zA-Z0-9_]*)/g, replacement: ': <span style="color:#0891b2">$1</span>' },
|
|
1043
|
-
|
|
1044
|
-
// Numbers
|
|
1045
|
-
{ pattern: /\b(\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)\b/g, replacement: '<span style="color:#f59e0b">$1</span>' },
|
|
1046
|
-
|
|
1047
|
-
// Booleans and null
|
|
1048
|
-
{ pattern: /\b(true|false|null|undefined|None|True|False|nil)\b/g, replacement: '<span style="color:#ef4444">$1</span>' },
|
|
1049
|
-
|
|
1050
|
-
// Function/method names (improved)
|
|
1051
|
-
{ pattern: /\b([a-zA-Z_][a-zA-Z0-9_]*)(?=\s*\()/g, replacement: '<span style="color:#3b82f6">$1</span>' },
|
|
1052
|
-
|
|
1053
|
-
// Operators
|
|
1054
|
-
{ pattern: /(===|!==|==|!=|<=|>=|&&|\|\||\+=|-=|\*=|\/=|%=|=>|->)/g, replacement: '<span style="color:#a855f7">$1</span>' },
|
|
1055
|
-
];
|
|
1056
|
-
|
|
1057
|
-
// Apply highlights
|
|
1058
|
-
highlights.forEach(({ pattern, replacement }) => {
|
|
1059
|
-
if (typeof replacement === 'function') {
|
|
1060
|
-
highlighted = highlighted.replace(pattern, replacement);
|
|
1061
|
-
} else {
|
|
1062
|
-
highlighted = highlighted.replace(pattern, replacement);
|
|
1063
|
-
}
|
|
1064
|
-
});
|
|
994
|
+
const preStyle = "background:#1e293b;padding:1rem;border-radius:0.375rem;overflow-x:auto;font-family:'Monaco','Menlo','Ubuntu Mono',monospace;font-size:0.875rem;line-height:1.6;color:#e2e8f0;border:1px solid #334155";
|
|
995
|
+
if (typeof hljs !== 'undefined') {
|
|
996
|
+
const result = hljs.highlightAuto(code);
|
|
997
|
+
return `<pre style="${preStyle}"><code class="hljs">${result.value}</code></pre>`;
|
|
1065
998
|
}
|
|
1066
|
-
|
|
1067
|
-
// Use a dark theme that works well for code
|
|
1068
|
-
return `<pre style="background:#1e293b;padding:1rem;border-radius:0.375rem;overflow-x:auto;font-family:'Monaco','Menlo','Ubuntu Mono',monospace;font-size:0.875rem;line-height:1.6;color:#e2e8f0;border:1px solid #334155;box-shadow:0 2px 4px rgba(0,0,0,0.1)">${highlighted}</pre>`;
|
|
999
|
+
return `<pre style="${preStyle}">${esc(code)}</pre>`;
|
|
1069
1000
|
}
|
|
1070
1001
|
|
|
1071
1002
|
/**
|