claude-bridge-cli 2.0.5 → 2.0.6
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/lib/bridge.js +15 -1
- package/package.json +1 -1
package/lib/bridge.js
CHANGED
|
@@ -140,6 +140,15 @@ function saveSessionFile(sid, name, dataB64) {
|
|
|
140
140
|
fs.writeFileSync(fp, buf, { mode: 0o600 });
|
|
141
141
|
return { name: final, size: buf.length, mime: mimeFor(final), path: fp };
|
|
142
142
|
}
|
|
143
|
+
function deleteSessionFile(sid, name) {
|
|
144
|
+
const dir = sessionFilesDir(sid);
|
|
145
|
+
const safe = path.basename(name || "");
|
|
146
|
+
if (!safe || safe !== name || !FILE_NAME_RE.test(safe)) throw new Error("bad file name");
|
|
147
|
+
const fp = path.join(dir, safe);
|
|
148
|
+
if (!fs.existsSync(fp) || !fs.statSync(fp).isFile()) { const e = new Error("file not found"); e.notFound = true; throw e; }
|
|
149
|
+
fs.unlinkSync(fp);
|
|
150
|
+
return { deleted: safe };
|
|
151
|
+
}
|
|
143
152
|
|
|
144
153
|
function splitUserTextAndImages(text) {
|
|
145
154
|
const m = text.match(/\nThe user attached \d+ image\(s\) at these absolute paths\. Use the Read tool to view them:\n([\s\S]+)$/);
|
|
@@ -860,13 +869,18 @@ function startBridge(config) {
|
|
|
860
869
|
return;
|
|
861
870
|
}
|
|
862
871
|
}
|
|
863
|
-
// Session files — download one (
|
|
872
|
+
// Session files — download one (GET) / remove one (DELETE)
|
|
864
873
|
m = url.pathname.match(/^\/sessions\/([A-Za-z0-9._-]+)\/files\/(.+)$/);
|
|
865
874
|
if (m && req.method === "GET") {
|
|
866
875
|
try { send(200, readSessionFile(m[1], decodeURIComponent(m[2]))); }
|
|
867
876
|
catch (e) { send(e.notFound ? 404 : 400, { error: String(e.message || e) }); }
|
|
868
877
|
return;
|
|
869
878
|
}
|
|
879
|
+
if (m && req.method === "DELETE") {
|
|
880
|
+
try { send(200, deleteSessionFile(m[1], decodeURIComponent(m[2]))); }
|
|
881
|
+
catch (e) { send(e.notFound ? 404 : 400, { error: String(e.message || e) }); }
|
|
882
|
+
return;
|
|
883
|
+
}
|
|
870
884
|
|
|
871
885
|
send(404, { error: "not found" });
|
|
872
886
|
});
|
package/package.json
CHANGED