agentgui 1.0.653 → 1.0.654
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 +2 -2
- package/static/js/dialogs.js +1 -4
- package/static/js/event-processor.js +1 -257
- package/static/js/sync-debug.js +11 -13
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -2208,13 +2208,13 @@ const server = http.createServer(async (req, res) => {
|
|
|
2208
2208
|
if (modelsMatch && req.method === 'GET') {
|
|
2209
2209
|
const agentId = modelsMatch[1];
|
|
2210
2210
|
const cached = modelCache.get(agentId);
|
|
2211
|
-
if (cached && (Date.now() - cached.
|
|
2211
|
+
if (cached && (Date.now() - cached.timestamp) < 300000) {
|
|
2212
2212
|
sendJSON(req, res, 200, { models: cached.models });
|
|
2213
2213
|
return;
|
|
2214
2214
|
}
|
|
2215
2215
|
try {
|
|
2216
2216
|
const models = await getModelsForAgent(agentId);
|
|
2217
|
-
modelCache.set(agentId, { models,
|
|
2217
|
+
modelCache.set(agentId, { models, timestamp: Date.now() });
|
|
2218
2218
|
sendJSON(req, res, 200, { models });
|
|
2219
2219
|
} catch (err) {
|
|
2220
2220
|
sendJSON(req, res, 200, { models: [] });
|
package/static/js/dialogs.js
CHANGED
|
@@ -2,10 +2,7 @@
|
|
|
2
2
|
var activeDialogs = [];
|
|
3
3
|
var dialogZIndex = 10000;
|
|
4
4
|
|
|
5
|
-
function escapeHtml(text) {
|
|
6
|
-
var map = { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' };
|
|
7
|
-
return String(text).replace(/[&<>"']/g, function(c) { return map[c]; });
|
|
8
|
-
}
|
|
5
|
+
function escapeHtml(text) { return window._escHtml(text); }
|
|
9
6
|
|
|
10
7
|
function createOverlay() {
|
|
11
8
|
var overlay = document.createElement('div');
|
|
@@ -1,71 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Event Processor
|
|
3
|
-
* Transforms, validates, and enriches streaming events
|
|
4
|
-
* Handles ANSI colors, markdown, diffs, and other data transformations
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
1
|
class EventProcessor {
|
|
8
2
|
constructor(config = {}) {
|
|
9
3
|
this.config = {
|
|
10
4
|
enableSyntaxHighlight: config.enableSyntaxHighlight !== false,
|
|
11
|
-
enableMarkdown: config.enableMarkdown !== false,
|
|
12
|
-
enableANSI: config.enableANSI !== false,
|
|
13
|
-
maxContentLength: config.maxContentLength || 100000,
|
|
14
5
|
...config
|
|
15
6
|
};
|
|
16
7
|
|
|
17
|
-
// ANSI color codes mapping
|
|
18
|
-
this.ansiCodes = {
|
|
19
|
-
reset: '\x1b[0m',
|
|
20
|
-
bold: '\x1b[1m',
|
|
21
|
-
dim: '\x1b[2m',
|
|
22
|
-
italic: '\x1b[3m',
|
|
23
|
-
underline: '\x1b[4m',
|
|
24
|
-
blink: '\x1b[5m',
|
|
25
|
-
reverse: '\x1b[7m',
|
|
26
|
-
hidden: '\x1b[8m',
|
|
27
|
-
strikethrough: '\x1b[9m',
|
|
28
|
-
// Foreground colors
|
|
29
|
-
black: '\x1b[30m',
|
|
30
|
-
red: '\x1b[31m',
|
|
31
|
-
green: '\x1b[32m',
|
|
32
|
-
yellow: '\x1b[33m',
|
|
33
|
-
blue: '\x1b[34m',
|
|
34
|
-
magenta: '\x1b[35m',
|
|
35
|
-
cyan: '\x1b[36m',
|
|
36
|
-
white: '\x1b[37m',
|
|
37
|
-
// Background colors
|
|
38
|
-
bgBlack: '\x1b[40m',
|
|
39
|
-
bgRed: '\x1b[41m',
|
|
40
|
-
bgGreen: '\x1b[42m',
|
|
41
|
-
bgYellow: '\x1b[43m',
|
|
42
|
-
bgBlue: '\x1b[44m',
|
|
43
|
-
bgMagenta: '\x1b[45m',
|
|
44
|
-
bgCyan: '\x1b[46m',
|
|
45
|
-
bgWhite: '\x1b[47m'
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
// CSS color mapping
|
|
49
|
-
this.colorMap = {
|
|
50
|
-
'30': '#000000', // black
|
|
51
|
-
'31': '#ff6b6b', // red
|
|
52
|
-
'32': '#51cf66', // green
|
|
53
|
-
'33': '#ffd43b', // yellow
|
|
54
|
-
'34': '#4dabf7', // blue
|
|
55
|
-
'35': '#da77f2', // magenta
|
|
56
|
-
'36': '#20c997', // cyan
|
|
57
|
-
'37': '#ffffff', // white
|
|
58
|
-
'90': '#666666', // bright black
|
|
59
|
-
'91': '#ff8787', // bright red
|
|
60
|
-
'92': '#69db7c', // bright green
|
|
61
|
-
'93': '#ffe066', // bright yellow
|
|
62
|
-
'94': '#74c0fc', // bright blue
|
|
63
|
-
'95': '#e599f7', // bright magenta
|
|
64
|
-
'96': '#38f9d7', // bright cyan
|
|
65
|
-
'97': '#f8f9fa' // bright white
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
// Statistics
|
|
69
8
|
this.stats = {
|
|
70
9
|
totalEvents: 0,
|
|
71
10
|
processedEvents: 0,
|
|
@@ -103,29 +42,13 @@ class EventProcessor {
|
|
|
103
42
|
processTime: 0
|
|
104
43
|
};
|
|
105
44
|
|
|
106
|
-
// Transform event based on type
|
|
107
|
-
if (event.type === 'text_block' || event.type === 'code_block') {
|
|
108
|
-
processed.content = this.transformContent(event.content || '', event.type);
|
|
109
|
-
this.stats.transformedEvents++;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (event.type === 'command_execute' && event.output) {
|
|
113
|
-
processed.output = this.transformANSI(event.output);
|
|
114
|
-
this.stats.transformedEvents++;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if (event.type === 'file_diff' || event.type === 'git_diff') {
|
|
118
|
-
processed.diff = this.transformDiff(event.diff || event.content || '');
|
|
119
|
-
this.stats.transformedEvents++;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
45
|
if (event.type === 'file_read' && event.path && this.isImagePath(event.path)) {
|
|
123
46
|
processed.isImage = true;
|
|
124
47
|
processed.imagePath = event.path;
|
|
125
48
|
this.stats.transformedEvents++;
|
|
126
49
|
}
|
|
127
50
|
|
|
128
|
-
if ((event.type === 'text_block' || event.type === 'command_execute' || event.type === 'streaming_progress') && event.content || event.output) {
|
|
51
|
+
if ((event.type === 'text_block' || event.type === 'command_execute' || event.type === 'streaming_progress') && (event.content || event.output)) {
|
|
129
52
|
const imagePaths = this.extractImagePaths(event.content || event.output || '');
|
|
130
53
|
if (imagePaths.length > 0) {
|
|
131
54
|
processed.detectedImages = imagePaths;
|
|
@@ -178,151 +101,6 @@ class EventProcessor {
|
|
|
178
101
|
return true;
|
|
179
102
|
}
|
|
180
103
|
|
|
181
|
-
/**
|
|
182
|
-
* Transform content based on type
|
|
183
|
-
*/
|
|
184
|
-
transformContent(content, type) {
|
|
185
|
-
if (typeof content !== 'string') {
|
|
186
|
-
return content;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
if (content.length > this.config.maxContentLength) {
|
|
190
|
-
return content.substring(0, this.config.maxContentLength) + '\n... (truncated)';
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
return content;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* Transform ANSI escape codes to HTML/CSS
|
|
198
|
-
*/
|
|
199
|
-
transformANSI(text) {
|
|
200
|
-
if (!this.config.enableANSI || typeof text !== 'string') {
|
|
201
|
-
return text;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
let result = '';
|
|
205
|
-
let currentStyle = { fg: null, bg: null, bold: false };
|
|
206
|
-
const stack = [];
|
|
207
|
-
|
|
208
|
-
// Pattern for ANSI escape sequences
|
|
209
|
-
const pattern = /\x1b\[([0-9;]*?)m/g;
|
|
210
|
-
let lastIndex = 0;
|
|
211
|
-
let match;
|
|
212
|
-
|
|
213
|
-
while ((match = pattern.exec(text)) !== null) {
|
|
214
|
-
// Add text before this escape sequence
|
|
215
|
-
if (match.index > lastIndex) {
|
|
216
|
-
const plainText = text.substring(lastIndex, match.index);
|
|
217
|
-
result += this.escapeHtml(plainText);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
// Parse ANSI code
|
|
221
|
-
const codes = match[1].split(';').map(c => parseInt(c, 10));
|
|
222
|
-
for (const code of codes) {
|
|
223
|
-
if (code === 0) {
|
|
224
|
-
// Reset
|
|
225
|
-
currentStyle = { fg: null, bg: null, bold: false };
|
|
226
|
-
} else if (code === 1) {
|
|
227
|
-
currentStyle.bold = true;
|
|
228
|
-
} else if (code >= 30 && code <= 37) {
|
|
229
|
-
currentStyle.fg = this.colorMap[code];
|
|
230
|
-
} else if (code >= 40 && code <= 47) {
|
|
231
|
-
currentStyle.bg = this.colorMap[String(code - 10)];
|
|
232
|
-
} else if (code >= 90 && code <= 97) {
|
|
233
|
-
currentStyle.fg = this.colorMap[code];
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
lastIndex = pattern.lastIndex;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
// Add remaining text
|
|
241
|
-
if (lastIndex < text.length) {
|
|
242
|
-
result += this.escapeHtml(text.substring(lastIndex));
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
return result;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* Transform unified diff format
|
|
250
|
-
*/
|
|
251
|
-
transformDiff(diffText) {
|
|
252
|
-
if (typeof diffText !== 'string') {
|
|
253
|
-
return diffText;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
const lines = diffText.split('\n');
|
|
257
|
-
const parsed = {
|
|
258
|
-
headers: [],
|
|
259
|
-
hunks: []
|
|
260
|
-
};
|
|
261
|
-
|
|
262
|
-
let currentHunk = null;
|
|
263
|
-
|
|
264
|
-
for (const line of lines) {
|
|
265
|
-
if (line.startsWith('---') || line.startsWith('+++')) {
|
|
266
|
-
parsed.headers.push(line);
|
|
267
|
-
} else if (line.startsWith('@@')) {
|
|
268
|
-
if (currentHunk) {
|
|
269
|
-
parsed.hunks.push(currentHunk);
|
|
270
|
-
}
|
|
271
|
-
currentHunk = {
|
|
272
|
-
header: line,
|
|
273
|
-
changes: []
|
|
274
|
-
};
|
|
275
|
-
} else if (currentHunk) {
|
|
276
|
-
if (line.startsWith('-')) {
|
|
277
|
-
currentHunk.changes.push({ type: 'deleted', line: line.substring(1) });
|
|
278
|
-
} else if (line.startsWith('+')) {
|
|
279
|
-
currentHunk.changes.push({ type: 'added', line: line.substring(1) });
|
|
280
|
-
} else if (line.startsWith(' ')) {
|
|
281
|
-
currentHunk.changes.push({ type: 'context', line: line.substring(1) });
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
if (currentHunk) {
|
|
287
|
-
parsed.hunks.push(currentHunk);
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
return parsed;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
|
-
* Convert markdown to HTML (simple implementation)
|
|
295
|
-
*/
|
|
296
|
-
transformMarkdown(markdown) {
|
|
297
|
-
if (!this.config.enableMarkdown || typeof markdown !== 'string') {
|
|
298
|
-
return markdown;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
let html = this.escapeHtml(markdown);
|
|
302
|
-
|
|
303
|
-
// Bold
|
|
304
|
-
html = html.replace(/\*\*(.+?)\*\*/g, '<strong>$1</strong>');
|
|
305
|
-
|
|
306
|
-
// Italic
|
|
307
|
-
html = html.replace(/\*(.+?)\*/g, '<em>$1</em>');
|
|
308
|
-
|
|
309
|
-
// Code
|
|
310
|
-
html = html.replace(/`(.+?)`/g, '<code>$1</code>');
|
|
311
|
-
|
|
312
|
-
// Links
|
|
313
|
-
html = html.replace(/\[(.+?)\]\((.+?)\)/g, '<a href="$2" target="_blank">$1</a>');
|
|
314
|
-
|
|
315
|
-
// Headings
|
|
316
|
-
html = html.replace(/^### (.+)$/gm, '<h3>$1</h3>');
|
|
317
|
-
html = html.replace(/^## (.+)$/gm, '<h2>$1</h2>');
|
|
318
|
-
html = html.replace(/^# (.+)$/gm, '<h1>$1</h1>');
|
|
319
|
-
|
|
320
|
-
// Line breaks
|
|
321
|
-
html = html.replace(/\n/g, '<br>');
|
|
322
|
-
|
|
323
|
-
return html;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
104
|
/**
|
|
327
105
|
* Detect language from content or hint
|
|
328
106
|
*/
|
|
@@ -379,40 +157,6 @@ class EventProcessor {
|
|
|
379
157
|
return match ? match[1].toLowerCase() : null;
|
|
380
158
|
}
|
|
381
159
|
|
|
382
|
-
/**
|
|
383
|
-
* Determine syntax highlighter language from file extension
|
|
384
|
-
*/
|
|
385
|
-
getLanguageFromExtension(ext) {
|
|
386
|
-
const extMap = {
|
|
387
|
-
'js': 'javascript',
|
|
388
|
-
'jsx': 'jsx',
|
|
389
|
-
'ts': 'typescript',
|
|
390
|
-
'tsx': 'typescript',
|
|
391
|
-
'py': 'python',
|
|
392
|
-
'java': 'java',
|
|
393
|
-
'cpp': 'cpp',
|
|
394
|
-
'c': 'c',
|
|
395
|
-
'cs': 'csharp',
|
|
396
|
-
'php': 'php',
|
|
397
|
-
'rb': 'ruby',
|
|
398
|
-
'go': 'go',
|
|
399
|
-
'rs': 'rust',
|
|
400
|
-
'json': 'json',
|
|
401
|
-
'xml': 'xml',
|
|
402
|
-
'html': 'html',
|
|
403
|
-
'css': 'css',
|
|
404
|
-
'scss': 'scss',
|
|
405
|
-
'yaml': 'yaml',
|
|
406
|
-
'yml': 'yaml',
|
|
407
|
-
'sql': 'sql',
|
|
408
|
-
'sh': 'bash',
|
|
409
|
-
'bash': 'bash',
|
|
410
|
-
'zsh': 'bash'
|
|
411
|
-
};
|
|
412
|
-
|
|
413
|
-
return extMap[ext?.toLowerCase()] || 'plaintext';
|
|
414
|
-
}
|
|
415
|
-
|
|
416
160
|
/**
|
|
417
161
|
* Truncate text with ellipsis
|
|
418
162
|
*/
|
package/static/js/sync-debug.js
CHANGED
|
@@ -133,16 +133,14 @@ class SyncDebugger {
|
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
|
|
137
|
-
window.syncDebugger = new SyncDebugger();
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
window.
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
console.log('[SyncDebug] Available. Use: debugSync.enable(), debugSync.report(), debugSync.clear()');
|
|
136
|
+
if (window.__DEBUG__) {
|
|
137
|
+
window.syncDebugger = new SyncDebugger();
|
|
138
|
+
window.debugSync = {
|
|
139
|
+
enable: () => window.syncDebugger.enable(),
|
|
140
|
+
disable: () => window.syncDebugger.disable(),
|
|
141
|
+
report: () => window.syncDebugger.printReport(),
|
|
142
|
+
clear: () => window.syncDebugger.clearLogs(),
|
|
143
|
+
get: () => window.syncDebugger.getReport()
|
|
144
|
+
};
|
|
145
|
+
console.log('[SyncDebug] Available. Use: debugSync.enable(), debugSync.report(), debugSync.clear()');
|
|
146
|
+
}
|