agentgui 1.0.537 → 1.0.539

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.537",
3
+ "version": "1.0.539",
4
4
  "description": "Multi-agent ACP client with real-time communication",
5
5
  "type": "module",
6
6
  "main": "server.js",
@@ -1350,7 +1350,8 @@ class AgentGUIClient {
1350
1350
  }
1351
1351
 
1352
1352
  this.disableControls();
1353
- const savedPrompt = prompt;
1353
+ const ttsActive = window.TTSHandler && window.TTSHandler.getAutoSpeak && window.TTSHandler.getAutoSpeak();
1354
+ const savedPrompt = ttsActive ? prompt + '\n\n[Respond optimized for text-to-speech: use short sentences, simple words, and focus on clarity.]' : prompt;
1354
1355
  if (this.ui.messageInput) {
1355
1356
  this.ui.messageInput.value = '';
1356
1357
  this.ui.messageInput.style.height = 'auto';
@@ -1626,6 +1626,26 @@ class StreamingRenderer {
1626
1626
  return div;
1627
1627
  }
1628
1628
 
1629
+ /**
1630
+ * Detect if content is a base64-encoded image
1631
+ */
1632
+ detectBase64Image(content) {
1633
+ if (!content || typeof content !== 'string') return null;
1634
+ const trimmed = content.trim();
1635
+ const signatures = {
1636
+ 'png': /^iVBORw0KGgo/,
1637
+ 'jpeg': /^\/9j\/4AAQ/,
1638
+ 'webp': /^UklGRi/,
1639
+ 'gif': /^R0lGODlh/
1640
+ };
1641
+ for (const [type, pattern] of Object.entries(signatures)) {
1642
+ if (pattern.test(trimmed)) {
1643
+ return { type, isBase64: true, data: trimmed };
1644
+ }
1645
+ }
1646
+ return null;
1647
+ }
1648
+
1629
1649
  /**
1630
1650
  * Render file read event
1631
1651
  */
@@ -1651,7 +1671,13 @@ class StreamingRenderer {
1651
1671
  let html = '';
1652
1672
  if (event.path) html += this.renderFilePath(event.path);
1653
1673
  if (event.content) {
1654
- 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(event.content, 2000))}</code></pre>`;
1674
+ const imageInfo = this.detectBase64Image(event.content);
1675
+ if (imageInfo) {
1676
+ const mimeType = imageInfo.type === 'jpeg' ? 'image/jpeg' : `image/${imageInfo.type}`;
1677
+ html += `<div style="padding:0.5rem;display:flex;flex-direction:column;gap:0.5rem"><img src="data:${mimeType};base64,${this.escapeHtml(imageInfo.data)}" 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
+ } else {
1679
+ 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(event.content, 2000))}</code></pre>`;
1680
+ }
1655
1681
  }
1656
1682
  body.innerHTML = html;
1657
1683
  details.appendChild(body);
@@ -60,7 +60,6 @@
60
60
  audioChunkQueue = []; isPlayingChunk = false;
61
61
  var cached = ttsAudioCache.get(selectedVoiceId + ':' + text);
62
62
  if (cached) { ttsConsecutiveFailures = 0; audioChunkQueue.push(cached); streamDone = true; if (!isPlayingChunk) playNextChunk(); return; }
63
- var opt = text + ' [Optimize for speech: Keep it short. Use simple words. Use short sentences. Focus on clarity.]';
64
63
  function ok() { ttsConsecutiveFailures = 0; }
65
64
  function fail() {
66
65
  if (++ttsConsecutiveFailures >= TTS_MAX_FAILURES) { ttsDisabledUntilReset = true; speechQueue = []; }
@@ -68,8 +67,8 @@
68
67
  if (!ttsDisabledUntilReset) processQueue();
69
68
  }
70
69
  function stream() {
71
- if (!streamingSupported) { nonStream(opt); return; }
72
- fetch(BASE + '/api/tts-stream', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ text: opt, voiceId: selectedVoiceId }) })
70
+ if (!streamingSupported) { nonStream(text); return; }
71
+ fetch(BASE + '/api/tts-stream', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ text: text, voiceId: selectedVoiceId }) })
73
72
  .then(function(r) {
74
73
  if (!r.ok) { streamingSupported = false; throw 0; }
75
74
  var reader = r.body.getReader(), buf = new Uint8Array(0);