agentgui 1.0.966 → 1.0.968

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.966",
3
+ "version": "1.0.968",
4
4
  "description": "Multi-agent ACP client with real-time communication",
5
5
  "type": "module",
6
6
  "main": "electron/main.js",
@@ -34,7 +34,12 @@ export function getBackend() {
34
34
  const u = new URL(location.href);
35
35
  const fromQs = u.searchParams.get('backend');
36
36
  if (fromQs) { lsSet(KEY, fromQs); return fromQs; }
37
- return lsGet(KEY) || DEFAULT_BACKEND;
37
+ // Same-origin default: honour the server-injected router prefix so HTTP
38
+ // calls (/health, /v1/history/*, /api/*) stay under the proxied path
39
+ // (e.g. /gm) instead of hitting the site root, where a path-routing proxy
40
+ // (nginx Basic auth) challenges and the browser re-prompts for a password.
41
+ const bu = (typeof window !== 'undefined' && window.__BASE_URL) || '';
42
+ return lsGet(KEY) || DEFAULT_BACKEND || String(bu).replace(/\/+$/, '');
38
43
  }
39
44
 
40
45
  export function setBackend(url) { lsSet(KEY, url); }
@@ -200,20 +205,26 @@ function scheduleReconnect() {
200
205
  }
201
206
 
202
207
  function wsUrl(base) {
203
- let proto, host;
208
+ let proto, host, prefix = '';
204
209
  if (base) {
205
210
  try {
206
211
  const u = new URL(base);
207
212
  proto = u.protocol === 'https:' ? 'wss:' : 'ws:';
208
213
  host = u.host;
214
+ // A custom backend URL may carry a routing path prefix (e.g. https://host/gm).
215
+ prefix = u.pathname.replace(/\/+$/, '');
209
216
  } catch {}
210
217
  }
211
218
  if (!host) {
212
219
  proto = location.protocol === 'https:' ? 'wss:' : 'ws:';
213
220
  host = location.host;
221
+ // Same-origin: honour the server-injected router prefix so the socket is
222
+ // routed correctly behind a path-routing proxy (e.g. nginx /gm/ -> 9897).
223
+ const bu = (typeof window !== 'undefined' && window.__BASE_URL) || '';
224
+ prefix = String(bu).replace(/\/+$/, '');
214
225
  }
215
226
  const tok = authToken();
216
- return proto + '//' + host + SYNC_PATH + (tok ? '?token=' + encodeURIComponent(tok) : '');
227
+ return proto + '//' + host + prefix + SYNC_PATH + (tok ? '?token=' + encodeURIComponent(tok) : '');
217
228
  }
218
229
 
219
230
  function ensureWs(base) {
@@ -231,7 +242,9 @@ function ensureWs(base) {
231
242
  }
232
243
  resolve(_ws);
233
244
  });
234
- _ws.addEventListener('error', (e) => { emitStatus('error'); reject(e); });
245
+ // The error Event has no .message; reject with a real Error so callers log
246
+ // a usable reason instead of "undefined" (e.g. "agents fetch failed: ...").
247
+ _ws.addEventListener('error', () => { emitStatus('error'); reject(new Error('WebSocket connection failed')); });
235
248
  _ws.addEventListener('close', () => {
236
249
  emitStatus('closed');
237
250
  for (const [, p] of _pending) p.reject(new Error('ws closed'));