agentgui 1.0.658 → 1.0.660

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.
@@ -1,7 +1,9 @@
1
1
  import path from 'path';
2
+ import os from 'os';
2
3
 
3
4
  function fail(code, message) { const e = new Error(message); e.code = code; throw e; }
4
5
  function notFound(msg = 'Not found') { fail(404, msg); }
6
+ function expandTilde(p) { return p && p.startsWith('~') ? path.join(os.homedir(), p.slice(1)) : p; }
5
7
 
6
8
  export function register(router, deps) {
7
9
  const { queries, activeExecutions, messageQueues, rateLimitState,
@@ -14,7 +16,7 @@ export function register(router, deps) {
14
16
  });
15
17
 
16
18
  router.handle('conv.new', (p) => {
17
- const wd = p.workingDirectory ? path.resolve(p.workingDirectory) : null;
19
+ const wd = p.workingDirectory ? path.resolve(expandTilde(p.workingDirectory)) : null;
18
20
  const conv = queries.createConversation(p.agentId, p.title, wd, p.model || null, p.subAgent || null);
19
21
  queries.createEvent('conversation.created', { agentId: p.agentId, workingDirectory: conv.workingDirectory, model: conv.model, subAgent: conv.subAgent }, conv.id);
20
22
  broadcastSync({ type: 'conversation_created', conversation: conv });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentgui",
3
- "version": "1.0.658",
3
+ "version": "1.0.660",
4
4
  "description": "Multi-agent ACP client with real-time communication",
5
5
  "type": "module",
6
6
  "main": "server.js",
package/server.js CHANGED
@@ -1153,8 +1153,9 @@ const server = http.createServer(async (req, res) => {
1153
1153
 
1154
1154
  if (pathOnly === '/api/conversations' && req.method === 'POST') {
1155
1155
  const body = await parseBody(req);
1156
- // Normalize working directory to avoid Windows path issues
1157
- const normalizedWorkingDir = body.workingDirectory ? path.resolve(body.workingDirectory) : null;
1156
+ // Normalize working directory to avoid Windows path issues; expand ~ to home
1157
+ const expandTilde = p => p && p.startsWith('~') ? path.join(os.homedir(), p.slice(1)) : p;
1158
+ const normalizedWorkingDir = body.workingDirectory ? path.resolve(expandTilde(body.workingDirectory)) : null;
1158
1159
  const conversation = queries.createConversation(body.agentId, body.title, normalizedWorkingDir, body.model || null);
1159
1160
  queries.createEvent('conversation.created', { agentId: body.agentId, workingDirectory: conversation.workingDirectory, model: conversation.model }, conversation.id);
1160
1161
  broadcastSync({ type: 'conversation_created', conversation });
@@ -1181,9 +1182,10 @@ const server = http.createServer(async (req, res) => {
1181
1182
 
1182
1183
  if (req.method === 'POST' || req.method === 'PUT') {
1183
1184
  const body = await parseBody(req);
1184
- // Normalize working directory if present to avoid Windows path issues
1185
+ // Normalize working directory if present to avoid Windows path issues; expand ~ to home
1185
1186
  if (body.workingDirectory) {
1186
- body.workingDirectory = path.resolve(body.workingDirectory);
1187
+ const expandTilde = p => p && p.startsWith('~') ? path.join(os.homedir(), p.slice(1)) : p;
1188
+ body.workingDirectory = path.resolve(expandTilde(body.workingDirectory));
1187
1189
  }
1188
1190
  const conv = queries.updateConversation(convMatch[1], body);
1189
1191
  if (!conv) { sendJSON(req, res, 404, { error: 'Conversation not found' }); return; }
@@ -1140,14 +1140,25 @@ class AgentGUIClient {
1140
1140
  }
1141
1141
 
1142
1142
  const sessionId = data.sessionId || this.state.currentSession?.id;
1143
+
1144
+ // Remove all orphaned streaming indicators (handles case where session never started)
1145
+ const outputEl2 = document.getElementById('output');
1146
+ if (outputEl2) {
1147
+ outputEl2.querySelectorAll('.streaming-indicator').forEach(ind => {
1148
+ ind.innerHTML = `<span style="color:var(--color-error);">Error: ${this.escapeHtml(data.error || 'Unknown error')}</span>`;
1149
+ });
1150
+ }
1151
+
1143
1152
  const streamingEl = document.getElementById(`streaming-${sessionId}`);
1144
1153
  if (streamingEl) {
1154
+ streamingEl.classList.remove('streaming-message');
1145
1155
  const indicator = streamingEl.querySelector('.streaming-indicator');
1146
1156
  if (indicator) {
1147
1157
  indicator.innerHTML = `<span style="color:var(--color-error);">Error: ${this.escapeHtml(data.error || 'Unknown error')}</span>`;
1148
1158
  }
1149
1159
  }
1150
1160
 
1161
+ this.unlockAgentAndModel();
1151
1162
  this.enableControls();
1152
1163
  this.emit('streaming:error', data);
1153
1164
  }
@@ -1306,6 +1317,7 @@ class AgentGUIClient {
1306
1317
  }
1307
1318
  }
1308
1319
 
1320
+ outputEl.querySelectorAll('p.text-secondary').forEach(p => p.remove());
1309
1321
  const messageHtml = `
1310
1322
  <div class="message message-${data.message.role}" data-msg-id="${data.message.id}">
1311
1323
  <div class="message-role">${data.message.role.charAt(0).toUpperCase() + data.message.role.slice(1)}</div>
@@ -1723,6 +1735,7 @@ class AgentGUIClient {
1723
1735
  _showOptimisticMessage(pendingId, content) {
1724
1736
  const messagesEl = document.querySelector('.conversation-messages');
1725
1737
  if (!messagesEl) return;
1738
+ messagesEl.querySelectorAll('p.text-secondary').forEach(p => p.remove());
1726
1739
  const div = document.createElement('div');
1727
1740
  div.className = 'message message-user message-sending';
1728
1741
  div.id = pendingId;
@@ -78,12 +78,14 @@ class WsClient {
78
78
 
79
79
  window.WsClient = WsClient;
80
80
 
81
- // Bootstrap: load codec (which pulls gpt-tokenizer from esm.sh), then connect
81
+ // Bootstrap: create wsManager and wsClient synchronously so other modules can use them immediately.
82
+ // Codec is loaded async and upgrades encoding once ready; websocket-manager falls back to msgpackr until then.
83
+ window.wsManager = new WebSocketManager();
84
+ window.wsClient = new WsClient(window.wsManager);
85
+ window.wsManager.connect().catch(function() {});
86
+
82
87
  import('./codec.js').then(codec => {
83
88
  window._codec = codec;
84
- window.wsManager = new WebSocketManager();
85
- window.wsClient = new WsClient(window.wsManager);
86
- window.wsManager.connect().catch(function() {});
87
89
  }).catch(e => {
88
- console.error('[ws-client] Failed to load codec:', e);
90
+ console.error('[ws-client] Failed to load codec, using msgpackr fallback:', e);
89
91
  });