agentgui 1.0.86 → 1.0.87

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentgui",
3
- "version": "1.0.86",
3
+ "version": "1.0.87",
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,54 @@ 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
+ html += `<div class="message-code"><pre>${this.escapeHtml(block.code)}</pre></div>`;
380
+ } else if (block.type === 'tool_use') {
381
+ html += `<div class="message-tool">[Tool: ${this.escapeHtml(block.name)}]</div>`;
382
+ }
383
+ });
384
+ }
385
+ html += '</div>';
386
+ return html;
387
+ } else {
388
+ return `<div class="message-text">${this.escapeHtml(JSON.stringify(content))}</div>`;
389
+ }
390
+ }
391
+
330
392
  /**
331
393
  * Start execution
332
394
  */