@clawchatsai/connector 0.0.40 → 0.0.41
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 +33 -0
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -1556,6 +1556,35 @@ async function handleWorkspaceFileWrite(req, res, query) {
|
|
|
1556
1556
|
send(res, 200, { ok: true });
|
|
1557
1557
|
}
|
|
1558
1558
|
|
|
1559
|
+
function handleWorkspaceFileDelete(req, res, query) {
|
|
1560
|
+
const filePath = query.path;
|
|
1561
|
+
if (!filePath) return sendError(res, 400, 'Missing path parameter');
|
|
1562
|
+
|
|
1563
|
+
const resolved = path.resolve(filePath.replace(/^~/, HOME));
|
|
1564
|
+
|
|
1565
|
+
// Security: only allow paths under home directory
|
|
1566
|
+
if (!resolved.startsWith(HOME)) {
|
|
1567
|
+
return sendError(res, 403, 'Access denied');
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1570
|
+
if (!fs.existsSync(resolved)) {
|
|
1571
|
+
return sendError(res, 404, 'Path not found');
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
try {
|
|
1575
|
+
const stat = fs.statSync(resolved);
|
|
1576
|
+
if (stat.isDirectory()) {
|
|
1577
|
+
fs.rmSync(resolved, { recursive: true, force: true });
|
|
1578
|
+
send(res, 200, { ok: true, type: 'dir' });
|
|
1579
|
+
} else {
|
|
1580
|
+
fs.unlinkSync(resolved);
|
|
1581
|
+
send(res, 200, { ok: true, type: 'file' });
|
|
1582
|
+
}
|
|
1583
|
+
} catch (err) {
|
|
1584
|
+
sendError(res, 500, 'Delete failed: ' + err.message);
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1559
1588
|
async function handleWorkspaceUpload(req, res, query) {
|
|
1560
1589
|
const targetDir = query.path;
|
|
1561
1590
|
if (!targetDir) return sendError(res, 400, 'Missing path parameter');
|
|
@@ -2288,6 +2317,9 @@ async function handleRequest(req, res) {
|
|
|
2288
2317
|
if (method === 'PUT' && urlPath === '/api/workspace/file') {
|
|
2289
2318
|
return await handleWorkspaceFileWrite(req, res, query);
|
|
2290
2319
|
}
|
|
2320
|
+
if (method === 'DELETE' && urlPath === '/api/workspace/file') {
|
|
2321
|
+
return handleWorkspaceFileDelete(req, res, query);
|
|
2322
|
+
}
|
|
2291
2323
|
if (method === 'POST' && urlPath === '/api/workspace/upload') {
|
|
2292
2324
|
return await handleWorkspaceUpload(req, res, query);
|
|
2293
2325
|
}
|
|
@@ -4404,6 +4436,7 @@ export function createApp(config = {}) {
|
|
|
4404
4436
|
if (method === 'GET' && urlPath === '/api/workspace') return handleWorkspaceList(req, res, query);
|
|
4405
4437
|
if (method === 'GET' && urlPath === '/api/workspace/file') return handleWorkspaceFileRead(req, res, query);
|
|
4406
4438
|
if (method === 'PUT' && urlPath === '/api/workspace/file') return await handleWorkspaceFileWrite(req, res, query);
|
|
4439
|
+
if (method === 'DELETE' && urlPath === '/api/workspace/file') return handleWorkspaceFileDelete(req, res, query);
|
|
4407
4440
|
if (method === 'POST' && urlPath === '/api/workspace/upload') return await handleWorkspaceUpload(req, res, query);
|
|
4408
4441
|
if (method === 'GET' && urlPath === '/api/memory/status') return await _handleMemoryStatus(req, res);
|
|
4409
4442
|
if (method === 'GET' && urlPath === '/api/memory/list') return await _handleMemoryList(req, res, query);
|