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.
- package/package.json +1 -1
- package/server.js +18 -5
package/package.json
CHANGED
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
|
|
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
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
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
|
|