@clawchatsai/connector 0.0.70 → 0.0.71
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 +7 -4
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -903,9 +903,6 @@ function handleDeleteWorkspace(req, res, params) {
|
|
|
903
903
|
if (Object.keys(ws.workspaces).length <= 1) {
|
|
904
904
|
return sendError(res, 400, 'Cannot delete the only workspace');
|
|
905
905
|
}
|
|
906
|
-
if (ws.active === params.name) {
|
|
907
|
-
return sendError(res, 400, 'Cannot delete the active workspace');
|
|
908
|
-
}
|
|
909
906
|
// Close and remove DB
|
|
910
907
|
closeDb(params.name);
|
|
911
908
|
const dbPath = path.join(DATA_DIR, `${params.name}.db`);
|
|
@@ -921,6 +918,12 @@ function handleDeleteWorkspace(req, res, params) {
|
|
|
921
918
|
}
|
|
922
919
|
|
|
923
920
|
delete ws.workspaces[params.name];
|
|
921
|
+
|
|
922
|
+
// If this was the active workspace, switch active to the first remaining one
|
|
923
|
+
if (ws.active === params.name) {
|
|
924
|
+
ws.active = Object.keys(ws.workspaces)[0] || null;
|
|
925
|
+
}
|
|
926
|
+
|
|
924
927
|
setWorkspaces(ws);
|
|
925
928
|
send(res, 200, { ok: true });
|
|
926
929
|
}
|
|
@@ -3667,7 +3670,6 @@ export function createApp(config = {}) {
|
|
|
3667
3670
|
const ws = _getWorkspaces();
|
|
3668
3671
|
if (!ws.workspaces[params.name]) return sendError(res, 404, 'Workspace not found');
|
|
3669
3672
|
if (Object.keys(ws.workspaces).length <= 1) return sendError(res, 400, 'Cannot delete the only workspace');
|
|
3670
|
-
if (ws.active === params.name) return sendError(res, 400, 'Cannot delete the active workspace');
|
|
3671
3673
|
_closeDb(params.name);
|
|
3672
3674
|
const dbPath = path.join(_DATA_DIR, `${params.name}.db`);
|
|
3673
3675
|
try { fs.unlinkSync(dbPath); } catch { /* ok */ }
|
|
@@ -3677,6 +3679,7 @@ export function createApp(config = {}) {
|
|
|
3677
3679
|
const cleaned = cleanGatewaySessionsByPrefix(`agent:${wsAgentForDelete}:${params.name}:chat:`);
|
|
3678
3680
|
if (cleaned > 0) console.log(`Cleaned ${cleaned} gateway sessions for workspace: ${params.name}`);
|
|
3679
3681
|
delete ws.workspaces[params.name];
|
|
3682
|
+
if (ws.active === params.name) ws.active = Object.keys(ws.workspaces)[0] || null;
|
|
3680
3683
|
_setWorkspaces(ws);
|
|
3681
3684
|
send(res, 200, { ok: true });
|
|
3682
3685
|
}
|