agentgui 1.0.617 → 1.0.618

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/server.js +18 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentgui",
3
- "version": "1.0.617",
3
+ "version": "1.0.618",
4
4
  "description": "Multi-agent ACP client with real-time communication",
5
5
  "type": "module",
6
6
  "main": "server.js",
package/server.js CHANGED
@@ -372,19 +372,32 @@ expressApp.post(BASE_URL + '/api/upload/:conversationId', (req, res) => {
372
372
  }
373
373
  });
374
374
 
375
+ // Cache fsbrowse routers per conversation to ensure API calls work
376
+ const fsbrowseRouters = new Map();
377
+
375
378
  // fsbrowse file browser - mounted per conversation workingDirectory
376
379
  // Route: /gm/files/:conversationId/*
377
380
  expressApp.use(BASE_URL + '/files/:conversationId', (req, res, next) => {
378
- const conv = queries.getConversation(req.params.conversationId);
381
+ const convId = req.params.conversationId;
382
+ const conv = queries.getConversation(convId);
379
383
  if (!conv || !conv.workingDirectory) {
380
384
  return res.status(404).json({ error: 'Conversation not found or no working directory' });
381
385
  }
386
+
382
387
  // Normalize the working directory path to avoid Windows path duplication issues
383
388
  const normalizedWorkingDir = path.resolve(conv.workingDirectory);
384
- // Create a fresh fsbrowse router for this conversation's directory
385
- const router = fsbrowse({ baseDir: normalizedWorkingDir, name: 'Files' });
386
- // Strip the conversationId param from the path before passing to fsbrowse
387
- req.baseUrl = BASE_URL + '/files/' + req.params.conversationId;
389
+
390
+ // Get or create cached fsbrowse router for this conversation
391
+ let router = fsbrowseRouters.get(convId);
392
+ if (!router) {
393
+ router = fsbrowse({ baseDir: normalizedWorkingDir, name: 'Files' });
394
+ fsbrowseRouters.set(convId, router);
395
+ }
396
+
397
+ // Set baseUrl before calling the router
398
+ req.baseUrl = BASE_URL + '/files/' + convId;
399
+ req.url = req.url.replace(new RegExp(`^${BASE_URL}/files/${convId}`), '');
400
+
388
401
  router(req, res, next);
389
402
  });
390
403