agentgui 1.0.671 → 1.0.673

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.
@@ -625,7 +625,7 @@ registry.register({
625
625
  closeStdin: true, // close stdin so claude doesn't wait for input in --print mode
626
626
  useJsonRpcStdin: false,
627
627
  supportedFeatures: ['streaming', 'resume', 'system-prompt', 'permissions-skip', 'steering'],
628
- spawnEnv: { MAX_THINKING_TOKENS: '0', AGENTGUI_SUBPROCESS: '1', CLAUDECODE: undefined },
628
+ spawnEnv: { MAX_THINKING_TOKENS: '0', AGENTGUI_SUBPROCESS: '1' },
629
629
 
630
630
  buildArgs(prompt, config) {
631
631
  const {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentgui",
3
- "version": "1.0.671",
3
+ "version": "1.0.673",
4
4
  "description": "Multi-agent ACP client with real-time communication",
5
5
  "type": "module",
6
6
  "main": "server.js",
package/server.js CHANGED
@@ -3237,7 +3237,7 @@ function serveFile(filePath, res, req) {
3237
3237
  'Content-Type': contentType,
3238
3238
  'Content-Length': stats.size,
3239
3239
  'ETag': etag,
3240
- 'Cache-Control': ['.js', '.css'].includes(ext) ? 'no-cache' : 'public, max-age=3600, must-revalidate'
3240
+ 'Cache-Control': ['.js', '.css'].includes(ext) ? 'public, max-age=0, must-revalidate' : 'public, max-age=3600, must-revalidate'
3241
3241
  };
3242
3242
  if (acceptsEncoding(req, 'br') && stats.size > 860) {
3243
3243
  const stream = fs.createReadStream(filePath);
@@ -4151,7 +4151,8 @@ wsRouter.onLegacy((data, ws) => {
4151
4151
  try { ws.terminalProc.kill(); } catch(e) {}
4152
4152
  }
4153
4153
  try {
4154
- const pty = require('node-pty');
4154
+ const _req = createRequire(import.meta.url);
4155
+ const pty = _req('node-pty');
4155
4156
  const shell = process.env.SHELL || '/bin/bash';
4156
4157
  const cwd = data.cwd || process.env.STARTUP_CWD || process.env.HOME || '/';
4157
4158
  const proc = pty.spawn(shell, [], {
@@ -4178,7 +4179,6 @@ wsRouter.onLegacy((data, ws) => {
4178
4179
  sendWs(ws, ({ type: 'terminal_started', timestamp: Date.now() }));
4179
4180
  } catch (e) {
4180
4181
  console.error('[TERMINAL] Failed to spawn PTY, falling back to pipes:', e.message);
4181
- const { spawn } = require('child_process');
4182
4182
  const shell = process.env.SHELL || '/bin/bash';
4183
4183
  const cwd = data.cwd || process.env.STARTUP_CWD || process.env.HOME || '/';
4184
4184
  const proc = spawn(shell, ['-i'], { cwd, env: { ...process.env, TERM: 'xterm-256color', COLORTERM: 'truecolor' }, stdio: ['pipe', 'pipe', 'pipe'] });
@@ -1156,6 +1156,8 @@ class AgentGUIClient {
1156
1156
  if (indicator) {
1157
1157
  indicator.innerHTML = `<span style="color:var(--color-error);">Error: ${this.escapeHtml(data.error || 'Unknown error')}</span>`;
1158
1158
  }
1159
+ // Remove all thinking blocks on error
1160
+ streamingEl.querySelectorAll('.block-thinking').forEach(block => block.remove());
1159
1161
  } else {
1160
1162
  const outputEl3 = document.getElementById('output');
1161
1163
  const messagesEl3 = outputEl3 && outputEl3.querySelector('.conversation-messages');
@@ -1219,6 +1221,9 @@ class AgentGUIClient {
1219
1221
  const prevTextEl = streamingEl.querySelector('.streaming-text-current');
1220
1222
  if (prevTextEl) prevTextEl.classList.remove('streaming-text-current');
1221
1223
 
1224
+ // Remove all thinking blocks (block-thinking elements)
1225
+ streamingEl.querySelectorAll('.block-thinking').forEach(block => block.remove());
1226
+
1222
1227
  const ts = document.createElement('div');
1223
1228
  ts.className = 'message-timestamp';
1224
1229
  ts.textContent = new Date().toLocaleString();
@@ -1232,7 +1232,9 @@ class StreamingRenderer {
1232
1232
  const details = document.createElement('details');
1233
1233
  details.className = 'folded-tool' + (isError ? ' folded-tool-error' : ' folded-tool-success');
1234
1234
  details.dataset.eventType = 'tool_result';
1235
- if (!isError) details.open = true;
1235
+ // Only open by default if the content is an image
1236
+ const isImageContent = contentStr.includes('data:image/') || (block.content && block.content.type === 'base64');
1237
+ if (!isError && isImageContent) details.open = true;
1236
1238
  if (block.tool_use_id) details.dataset.toolUseId = block.tool_use_id;
1237
1239
  details.classList.add(this._getBlockTypeClass('tool_result'));
1238
1240
 
@@ -1,39 +1,31 @@
1
1
  (function() {
2
- var ws = null;
3
2
  var term = null;
4
3
  var fitAddon = null;
5
4
  var termActive = false;
6
5
  var BASE = window.__BASE_URL || '';
7
-
8
- function getWsUrl() {
9
- var proto = location.protocol === 'https:' ? 'wss:' : 'ws:';
10
- return proto + '//' + location.host + BASE + '/sync';
11
- }
6
+ var _wsListener = null;
12
7
 
13
8
  function getCwd() {
14
9
  try {
15
- // Try conversation manager first
16
10
  if (window.conversationManager && window.conversationManager.activeId) {
17
11
  var mgr = window.conversationManager;
18
- var id = mgr.activeId;
19
- if (mgr.conversations) {
20
- var conv = mgr.conversations.find(function(c) { return c.id === id; });
21
- if (conv && conv.workingDirectory) return conv.workingDirectory;
22
- }
12
+ var conv = mgr.conversations && mgr.conversations.find(function(c) { return c.id === mgr.activeId; });
13
+ if (conv && conv.workingDirectory) return conv.workingDirectory;
23
14
  }
24
- // Fallback to global currentConversation
25
- if (window.currentConversation) {
26
- var convId = window.currentConversation;
27
- if (window.conversationManager && window.conversationManager.conversations) {
28
- var convList = window.conversationManager.conversations;
29
- var match = convList.find(function(c) { return c.id === convId; });
30
- if (match && match.workingDirectory) return match.workingDirectory;
31
- }
15
+ if (window.currentConversation && window.conversationManager && window.conversationManager.conversations) {
16
+ var match = window.conversationManager.conversations.find(function(c) { return c.id === window.currentConversation; });
17
+ if (match && match.workingDirectory) return match.workingDirectory;
32
18
  }
33
19
  } catch (_) {}
34
20
  return undefined;
35
21
  }
36
22
 
23
+ function wsSend(obj) {
24
+ if (window.wsManager && window.wsManager.send) {
25
+ window.wsManager.send(obj);
26
+ }
27
+ }
28
+
37
29
  function ensureTerm() {
38
30
  var output = document.getElementById('terminalOutput');
39
31
  if (!output) return false;
@@ -60,16 +52,12 @@
60
52
  fitAddon.fit();
61
53
 
62
54
  term.onData(function(data) {
63
- if (ws && ws.readyState === WebSocket.OPEN) {
64
- var encoded = btoa(unescape(encodeURIComponent(data)));
65
- ws.send(JSON.stringify({ type: 'terminal_input', data: encoded }));
66
- }
55
+ var encoded = btoa(unescape(encodeURIComponent(data)));
56
+ wsSend({ type: 'terminal_input', data: encoded });
67
57
  });
68
58
 
69
59
  term.onResize(function(size) {
70
- if (ws && ws.readyState === WebSocket.OPEN) {
71
- ws.send(JSON.stringify({ type: 'terminal_resize', cols: size.cols, rows: size.rows }));
72
- }
60
+ wsSend({ type: 'terminal_resize', cols: size.cols, rows: size.rows });
73
61
  });
74
62
 
75
63
  var resizeTimer;
@@ -78,57 +66,42 @@
78
66
  try { fitAddon.fit(); } catch(_) {}
79
67
  clearTimeout(resizeTimer);
80
68
  resizeTimer = setTimeout(function() {
81
- if (term && ws && ws.readyState === WebSocket.OPEN) {
82
- ws.send(JSON.stringify({ type: 'terminal_resize', cols: term.cols, rows: term.rows }));
83
- }
69
+ if (term) wsSend({ type: 'terminal_resize', cols: term.cols, rows: term.rows });
84
70
  }, 200);
85
71
  }
86
72
  });
87
73
 
88
- output.addEventListener('click', function() {
74
+ document.getElementById('terminalOutput').addEventListener('click', function() {
89
75
  if (term && term.focus) term.focus();
90
76
  });
91
77
 
92
78
  return true;
93
79
  }
94
80
 
95
- function connectAndStart() {
96
- var cwd = getCwd();
97
- if (ws && ws.readyState === WebSocket.OPEN) {
98
- var dims = term ? { cols: term.cols, rows: term.rows } : { cols: 80, rows: 24 };
99
- ws.send(JSON.stringify({ type: 'terminal_start', cwd: cwd, cols: dims.cols, rows: dims.rows }));
100
- setTimeout(function() { if (term && term.focus) term.focus(); }, 100);
101
- return;
102
- }
103
- if (ws && ws.readyState === WebSocket.CONNECTING) {
104
- return;
105
- }
106
-
107
- ws = new WebSocket(getWsUrl());
108
- ws.onopen = function() {
109
- var dims = term ? { cols: term.cols, rows: term.rows } : { cols: 80, rows: 24 };
110
- ws.send(JSON.stringify({ type: 'terminal_start', cwd: cwd, cols: dims.cols, rows: dims.rows }));
111
- setTimeout(function() { if (term && term.focus) term.focus(); }, 100);
112
- };
113
- ws.onmessage = function(e) {
114
- try {
115
- var msg = JSON.parse(e.data);
116
- if (msg.type === 'terminal_output' && term) {
117
- var raw = msg.encoding === 'base64'
118
- ? decodeURIComponent(escape(atob(msg.data)))
119
- : msg.data;
120
- term.write(raw);
121
- } else if (msg.type === 'terminal_exit' && term) {
122
- term.write('\r\n[Process exited with code ' + msg.code + ']\r\n');
123
- if (termActive) setTimeout(connectAndStart, 2000);
124
- }
125
- } catch(_) {}
126
- };
127
- ws.onclose = function() {
128
- ws = null;
129
- if (termActive) setTimeout(connectAndStart, 2000);
81
+ function installWsListener() {
82
+ if (_wsListener || !window.wsManager) return;
83
+ _wsListener = function(msg) {
84
+ if (!termActive) return;
85
+ if (msg.type === 'terminal_output' && term) {
86
+ var raw = msg.encoding === 'base64'
87
+ ? decodeURIComponent(escape(atob(msg.data)))
88
+ : msg.data;
89
+ term.write(raw);
90
+ } else if (msg.type === 'terminal_exit' && term) {
91
+ term.write('\r\n[Process exited with code ' + msg.code + ']\r\n');
92
+ if (termActive) setTimeout(startSession, 2000);
93
+ }
130
94
  };
131
- ws.onerror = function() {};
95
+ window.wsManager.on('message', _wsListener);
96
+ }
97
+
98
+ function startSession() {
99
+ if (!window.wsManager) return;
100
+ installWsListener();
101
+ var cwd = getCwd();
102
+ var dims = term ? { cols: term.cols, rows: term.rows } : { cols: 80, rows: 24 };
103
+ wsSend({ type: 'terminal_start', cwd: cwd, cols: dims.cols, rows: dims.rows });
104
+ setTimeout(function() { if (term && term.focus) term.focus(); }, 100);
132
105
  }
133
106
 
134
107
  function startTerminal() {
@@ -137,19 +110,21 @@
137
110
  return;
138
111
  }
139
112
  termActive = true;
140
- connectAndStart();
113
+ if (window.wsManager && window.wsManager.isConnected) {
114
+ startSession();
115
+ } else if (window.wsManager) {
116
+ var onConnected = function() {
117
+ window.wsManager.off('connected', onConnected);
118
+ startSession();
119
+ };
120
+ window.wsManager.on('connected', onConnected);
121
+ }
141
122
  setTimeout(function() { if (fitAddon) try { fitAddon.fit(); } catch(_) {} }, 100);
142
123
  }
143
124
 
144
125
  function stopTerminal() {
145
126
  termActive = false;
146
- if (ws && ws.readyState === WebSocket.OPEN) {
147
- ws.send(JSON.stringify({ type: 'terminal_stop' }));
148
- }
149
- if (ws) {
150
- ws.close();
151
- ws = null;
152
- }
127
+ wsSend({ type: 'terminal_stop' });
153
128
  }
154
129
 
155
130
  function initTerminalEarly() {
@@ -172,7 +147,7 @@
172
147
  return;
173
148
  }
174
149
  termActive = true;
175
- connectAndStart();
150
+ startSession();
176
151
  setTimeout(function() { if (fitAddon) try { fitAddon.fit(); } catch(_) {} }, 50);
177
152
  setTimeout(function() { if (fitAddon) try { fitAddon.fit(); } catch(_) {} }, 300);
178
153
  } else if (termActive) {
@@ -180,15 +155,12 @@
180
155
  }
181
156
  });
182
157
 
183
- // Restart terminal in the new conversation's cwd when conversation switches while terminal is active
184
- window.addEventListener('conversation-changed', function(e) {
158
+ window.addEventListener('conversation-changed', function() {
185
159
  if (!termActive) return;
186
160
  var cwd = getCwd();
187
- if (ws && ws.readyState === WebSocket.OPEN) {
188
- var dims = term ? { cols: term.cols, rows: term.rows } : { cols: 80, rows: 24 };
189
- ws.send(JSON.stringify({ type: 'terminal_start', cwd: cwd, cols: dims.cols, rows: dims.rows }));
190
- if (term) term.write('\r\n\x1b[33m[Switched to: ' + (cwd || '/') + ']\x1b[0m\r\n');
191
- }
161
+ var dims = term ? { cols: term.cols, rows: term.rows } : { cols: 80, rows: 24 };
162
+ wsSend({ type: 'terminal_start', cwd: cwd, cols: dims.cols, rows: dims.rows });
163
+ if (term) term.write('\r\n\x1b[33m[Switched to: ' + (cwd || '/') + ']\x1b[0m\r\n');
192
164
  });
193
165
 
194
166
  window.terminalModule = {