agentgui 1.0.86 → 1.0.88

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/.prd CHANGED
@@ -0,0 +1,44 @@
1
+ HTML Code Block Rendering Implementation
2
+
3
+ GOAL: Render HTML code blocks as actual HTML elements instead of escaped text
4
+
5
+ DEPENDENCIES:
6
+ - streaming-renderer.js renderCode() method modification
7
+ - client.js renderMessageContent() method modification
8
+ - client.js renderMessages() method modification
9
+
10
+ COMPLETED ITEMS:
11
+
12
+ 1. DONE: Update streaming-renderer.js renderCode() to detect HTML blocks
13
+ - Check if language === 'html' ✓
14
+ - If HTML: render content with innerHTML (Claude responses trusted) ✓
15
+ - If not HTML: keep existing escaped text rendering ✓
16
+ - Wrap HTML output in styled container ✓
17
+
18
+ 2. DONE: Update client.js renderMessageContent() to handle HTML code blocks
19
+ - Detect block.type === 'code_block' AND block.language === 'html' ✓
20
+ - If HTML: render with innerHTML in wrapper div ✓
21
+ - If not HTML: escape and display as text ✓
22
+
23
+ 3. DONE: Update client.js renderMessages() to handle HTML code blocks
24
+ - Detect block.type === 'code_block' AND block.language === 'html' ✓
25
+ - If HTML: render with innerHTML in wrapper div ✓
26
+ - If not HTML: escape and display as text ✓
27
+
28
+ 4. DONE: Style HTML rendered blocks appropriately
29
+ - Add CSS classes for container styling ✓
30
+ - Ensure proper padding and borders ✓
31
+ - Add label indicating "Rendered HTML" ✓
32
+
33
+ 5. DONE: Test implementation
34
+ - Created test cases for HTML detection logic ✓
35
+ - Verified HTML detection correctly identifies html language ✓
36
+ - Verified non-HTML code blocks use escaped rendering ✓
37
+ - Confirmed no breaking changes to existing logic ✓
38
+
39
+ 6. DONE: Commit changes
40
+ - Stage modified files ✓
41
+ - Create meaningful commit message ✓
42
+ - Commit hash: 13ee551 ✓
43
+
44
+ ALL WORK COMPLETED ✓
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentgui",
3
- "version": "1.0.86",
3
+ "version": "1.0.88",
4
4
  "description": "Multi-agent ACP client with real-time communication",
5
5
  "type": "module",
6
6
  "main": "server.js",
package/server.js CHANGED
@@ -7,6 +7,9 @@ import { execSync } from 'child_process';
7
7
  import { queries } from './database.js';
8
8
  import { runClaudeWithStreaming } from './lib/claude-runner.js';
9
9
 
10
+ // System prompt for Claude to format responses as HTML
11
+ const SYSTEM_PROMPT = `Always write your responses in ripple-ui enhanced HTML. Avoid overriding light/dark mode CSS variables. Use all the benefits of HTML to express technical details with proper semantic markup, tables, code blocks, headings, and lists. Write clean, well-structured HTML that respects the existing design system.`;
12
+
10
13
  // Debug logging to file
11
14
  const debugLog = (msg) => {
12
15
  const timestamp = new Date().toISOString();
@@ -386,7 +389,10 @@ async function processMessageWithStreaming(conversationId, messageId, sessionId,
386
389
  print: true
387
390
  };
388
391
 
389
- const outputs = await runClaudeWithStreaming(content, cwd, actualAgentId, config);
392
+ // Prepend system prompt to user content
393
+ const promptWithSystem = `${SYSTEM_PROMPT}\n\n${content}`;
394
+
395
+ const outputs = await runClaudeWithStreaming(promptWithSystem, cwd, actualAgentId, config);
390
396
  debugLog(`[stream] Claude returned ${outputs.length} streaming outputs`);
391
397
 
392
398
  // Process streaming outputs similar to processMessage
@@ -503,7 +509,9 @@ async function processMessage(conversationId, messageId, content, agentId) {
503
509
  const actualAgentId = agentId || 'claude-code';
504
510
 
505
511
  debugLog(`[processMessage] Calling runClaudeWithStreaming with prompt: "${content.substring(0, 50)}..."`);
506
- const outputs = await runClaudeWithStreaming(content, cwd, actualAgentId);
512
+ // Prepend system prompt to user content
513
+ const promptWithSystem = `${SYSTEM_PROMPT}\n\n${content}`;
514
+ const outputs = await runClaudeWithStreaming(promptWithSystem, cwd, actualAgentId);
507
515
  debugLog(`[processMessage] Claude returned ${outputs.length} outputs`);
508
516
 
509
517
  // Collect all message blocks to preserve full execution details
package/static/index.html CHANGED
@@ -74,6 +74,7 @@
74
74
  background-color: var(--color-bg-secondary);
75
75
  border-right: 1px solid var(--color-border);
76
76
  overflow: hidden;
77
+ min-height: 0;
77
78
  }
78
79
 
79
80
  .sidebar-header {
@@ -271,8 +271,25 @@ class AgentGUIClient {
271
271
  agentId: data.agentId,
272
272
  startTime: Date.now()
273
273
  };
274
+ this.state.currentConversation = { id: data.conversationId };
274
275
  this.state.sessionEvents = [];
275
- this.renderer.clear();
276
+
277
+ // Auto-select the streaming conversation in the sidebar
278
+ if (window.conversationManager) {
279
+ window.conversationManager.select(data.conversationId);
280
+ }
281
+
282
+ // Load the conversation to display it in real-time
283
+ this.loadConversationMessages(data.conversationId).then(() => {
284
+ // Clear output and prepare for streaming
285
+ const outputEl = document.getElementById('output');
286
+ if (outputEl) {
287
+ outputEl.innerHTML = '';
288
+ }
289
+ }).catch(err => {
290
+ console.error('Failed to load conversation during streaming:', err);
291
+ this.renderer.clear();
292
+ });
276
293
 
277
294
  this.renderer.queueEvent({
278
295
  type: 'streaming_start',
@@ -324,9 +341,68 @@ class AgentGUIClient {
324
341
  * Handle message created
325
342
  */
326
343
  handleMessageCreated(data) {
344
+ // If the message is for the currently displayed conversation, append it to the output
345
+ if (data.conversationId === this.state.currentConversation?.id && data.message) {
346
+ const outputEl = document.querySelector('.conversation-messages');
347
+ if (outputEl) {
348
+ const messageHtml = `
349
+ <div class="message message-${data.message.role}">
350
+ <div class="message-role">${data.message.role.charAt(0).toUpperCase() + data.message.role.slice(1)}</div>
351
+ ${this.renderMessageContent(data.message.content)}
352
+ <div class="message-timestamp">${new Date(data.message.created_at).toLocaleString()}</div>
353
+ </div>
354
+ `;
355
+ outputEl.insertAdjacentHTML('beforeend', messageHtml);
356
+ // Scroll to bottom
357
+ const scrollContainer = document.getElementById('output-scroll');
358
+ if (scrollContainer) {
359
+ scrollContainer.scrollTop = scrollContainer.scrollHeight;
360
+ }
361
+ }
362
+ }
327
363
  this.emit('message:created', data);
328
364
  }
329
365
 
366
+ /**
367
+ * Render message content based on type
368
+ */
369
+ renderMessageContent(content) {
370
+ if (typeof content === 'string') {
371
+ return `<div class="message-text">${this.escapeHtml(content)}</div>`;
372
+ } else if (content && typeof content === 'object' && content.type === 'claude_execution') {
373
+ let html = '<div class="message-blocks">';
374
+ if (content.blocks && Array.isArray(content.blocks)) {
375
+ content.blocks.forEach(block => {
376
+ if (block.type === 'text') {
377
+ html += `<div class="message-text">${this.escapeHtml(block.text)}</div>`;
378
+ } else if (block.type === 'code_block') {
379
+ // Render HTML code blocks as actual HTML elements
380
+ if (block.language === 'html') {
381
+ html += `
382
+ <div class="message-code">
383
+ <div class="html-rendered-label mb-2 p-2 bg-blue-50 dark:bg-blue-900 rounded border border-blue-200 dark:border-blue-700 text-xs text-blue-700 dark:text-blue-300">
384
+ Rendered HTML
385
+ </div>
386
+ <div class="html-content bg-white dark:bg-gray-800 p-4 rounded border border-gray-200 dark:border-gray-700 overflow-x-auto">
387
+ ${block.code}
388
+ </div>
389
+ </div>
390
+ `;
391
+ } else {
392
+ html += `<div class="message-code"><pre>${this.escapeHtml(block.code)}</pre></div>`;
393
+ }
394
+ } else if (block.type === 'tool_use') {
395
+ html += `<div class="message-tool">[Tool: ${this.escapeHtml(block.name)}]</div>`;
396
+ }
397
+ });
398
+ }
399
+ html += '</div>';
400
+ return html;
401
+ } else {
402
+ return `<div class="message-text">${this.escapeHtml(JSON.stringify(content))}</div>`;
403
+ }
404
+ }
405
+
330
406
  /**
331
407
  * Start execution
332
408
  */
@@ -581,7 +657,21 @@ class AgentGUIClient {
581
657
  if (block.type === 'text') {
582
658
  contentHtml += `<div class="message-text">${this.escapeHtml(block.text)}</div>`;
583
659
  } else if (block.type === 'code_block') {
584
- contentHtml += `<div class="message-code"><pre>${this.escapeHtml(block.code)}</pre></div>`;
660
+ // Render HTML code blocks as actual HTML elements
661
+ if (block.language === 'html') {
662
+ contentHtml += `
663
+ <div class="message-code">
664
+ <div class="html-rendered-label mb-2 p-2 bg-blue-50 dark:bg-blue-900 rounded border border-blue-200 dark:border-blue-700 text-xs text-blue-700 dark:text-blue-300">
665
+ Rendered HTML
666
+ </div>
667
+ <div class="html-content bg-white dark:bg-gray-800 p-4 rounded border border-gray-200 dark:border-gray-700 overflow-x-auto">
668
+ ${block.code}
669
+ </div>
670
+ </div>
671
+ `;
672
+ } else {
673
+ contentHtml += `<div class="message-code"><pre>${this.escapeHtml(block.code)}</pre></div>`;
674
+ }
585
675
  } else if (block.type === 'tool_use') {
586
676
  contentHtml += `<div class="message-tool">[Tool: ${this.escapeHtml(block.name)}]</div>`;
587
677
  }
@@ -595,9 +595,21 @@ class StreamingRenderer {
595
595
  const code = event.code || event.content || '';
596
596
  const language = event.language || 'plaintext';
597
597
 
598
- div.innerHTML = `
599
- <pre class="bg-gray-900 text-gray-100 p-4 rounded overflow-x-auto"><code class="language-${this.escapeHtml(language)}">${this.escapeHtml(code)}</code></pre>
600
- `;
598
+ // Render HTML code blocks as actual HTML elements
599
+ if (language === 'html') {
600
+ div.innerHTML = `
601
+ <div class="html-rendered-container mb-2 p-2 bg-blue-50 dark:bg-blue-900 rounded border border-blue-200 dark:border-blue-700 text-xs text-blue-700 dark:text-blue-300">
602
+ Rendered HTML
603
+ </div>
604
+ <div class="html-content bg-white dark:bg-gray-800 p-4 rounded border border-gray-200 dark:border-gray-700 overflow-x-auto">
605
+ ${code}
606
+ </div>
607
+ `;
608
+ } else {
609
+ div.innerHTML = `
610
+ <pre class="bg-gray-900 text-gray-100 p-4 rounded overflow-x-auto"><code class="language-${this.escapeHtml(language)}">${this.escapeHtml(code)}</code></pre>
611
+ `;
612
+ }
601
613
  return div;
602
614
  }
603
615